@orkestralai/codesignflo 0.2.0 → 0.2.1

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.
Files changed (2) hide show
  1. package/dist/main.js +28 -28
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -89,7 +89,7 @@ Build it in this app:
89
89
  Caused by: ${(m=d?.name)!==null&&m!==void 0?m:"Error"}: ${v}`,b&&(c+=` (${b})`),d?.stack&&(c+=`
90
90
  ${d.stack}`)}else{var g;c=(g=s?.stack)!==null&&g!==void 0?g:""}let y=this.url.toString().length;return s?.name==="AbortError"||s?.code==="ABORT_ERR"?(u="",l="Request was aborted (timeout or manual cancellation)",y>this.urlLengthLimit&&(l+=`. Note: Your request URL is ${y} characters, which may exceed server limits. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [many IDs])), consider using an RPC function to pass values server-side.`)):(d?.name==="HeadersOverflowError"||d?.code==="UND_ERR_HEADERS_OVERFLOW")&&(u="",l="HTTP headers exceeded server limits (typically 16KB)",y>this.urlLengthLimit&&(l+=`. Your request URL is ${y} characters. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [200+ IDs])), consider using an RPC function instead.`)),{success:!1,error:{message:`${(a=s?.name)!==null&&a!==void 0?a:"FetchError"}: ${s?.message}`,details:c,hint:l,code:u},data:null,count:null,status:0,statusText:""}})),o.then(t,e)}async processResponse(t){var e=this;let r=null,i=null,n=null,o=t.status,s=t.statusText;if(t.ok){var a,c;if(e.method!=="HEAD"){var l;let f=await t.text();if(f!=="")if(e.headers.get("Accept")==="text/csv")i=f;else if(e.headers.get("Accept")&&(!((l=e.headers.get("Accept"))===null||l===void 0)&&l.includes("application/vnd.pgrst.plan+text")))i=f;else try{i=JSON.parse(f)}catch{if(r={message:f},i=null,e.shouldThrowOnError)throw new Ji({message:f,details:"",hint:"",code:""})}}let d=(a=e.headers.get("Prefer"))===null||a===void 0?void 0:a.match(/count=(exact|planned|estimated)/),p=(c=t.headers.get("content-range"))===null||c===void 0?void 0:c.split("/");if(d&&p&&p.length>1&&(n=parseInt(p[1])),e.isMaybeSingle&&Array.isArray(i))if(i.length>1){if(r={code:"PGRST116",details:`Results contain ${i.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},i=null,n=null,o=406,s="Not Acceptable",e.shouldThrowOnError){var u;throw new Ji(ts(ts({},r),{},{hint:(u=r.hint)!==null&&u!==void 0?u:""}))}}else i.length===1?i=i[0]:i=null}else{let d=await t.text();try{r=JSON.parse(d),Array.isArray(r)&&t.status===404&&(i=[],r=null,o=200,s="OK")}catch{t.status===404&&d===""?(o=204,s="No Content"):r={message:d}}if(r&&e.shouldThrowOnError)throw new Ji(r)}return{success:r===null,error:r,data:i,count:n,status:o,statusText:s}}returns(){return this}overrideTypes(){return this}},xV=class extends SV{throwOnError(){return super.throwOnError()}select(t){let e=!1,r=(t??"*").split("").map(i=>/\s/.test(i)&&!e?"":(i==='"'&&(e=!e),i)).join("");return this.url.searchParams.set("select",r),this.headers.append("Prefer","return=representation"),this}order(t,{ascending:e=!0,nullsFirst:r,foreignTable:i,referencedTable:n=i}={}){let o=n?`${n}.order`:"order",s=this.url.searchParams.get(o);return this.url.searchParams.set(o,`${s?`${s},`:""}${t}.${e?"asc":"desc"}${r===void 0?"":r?".nullsfirst":".nullslast"}`),this}limit(t,{foreignTable:e,referencedTable:r=e}={}){let i=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(i,`${t}`),this}range(t,e,{foreignTable:r,referencedTable:i=r}={}){let n=typeof i>"u"?"offset":`${i}.offset`,o=typeof i>"u"?"limit":`${i}.limit`;return this.url.searchParams.set(n,`${t}`),this.url.searchParams.set(o,`${e-t+1}`),this}abortSignal(t){return this.signal=t,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:t=!1,verbose:e=!1,settings:r=!1,buffers:i=!1,wal:n=!1,format:o="text"}={}){var s;let a=[t?"analyze":null,e?"verbose":null,r?"settings":null,i?"buffers":null,n?"wal":null].filter(Boolean).join("|"),c=(s=this.headers.get("Accept"))!==null&&s!==void 0?s:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${o}; for="${c}"; options=${a};`),o==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(t){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${t}`),this}},bR=new RegExp("[,()]"),wa=class extends xV{throwOnError(){return super.throwOnError()}eq(t,e){return this.url.searchParams.append(t,`eq.${e}`),this}neq(t,e){return this.url.searchParams.append(t,`neq.${e}`),this}gt(t,e){return this.url.searchParams.append(t,`gt.${e}`),this}gte(t,e){return this.url.searchParams.append(t,`gte.${e}`),this}lt(t,e){return this.url.searchParams.append(t,`lt.${e}`),this}lte(t,e){return this.url.searchParams.append(t,`lte.${e}`),this}like(t,e){return this.url.searchParams.append(t,`like.${e}`),this}likeAllOf(t,e){return this.url.searchParams.append(t,`like(all).{${e.join(",")}}`),this}likeAnyOf(t,e){return this.url.searchParams.append(t,`like(any).{${e.join(",")}}`),this}ilike(t,e){return this.url.searchParams.append(t,`ilike.${e}`),this}ilikeAllOf(t,e){return this.url.searchParams.append(t,`ilike(all).{${e.join(",")}}`),this}ilikeAnyOf(t,e){return this.url.searchParams.append(t,`ilike(any).{${e.join(",")}}`),this}regexMatch(t,e){return this.url.searchParams.append(t,`match.${e}`),this}regexIMatch(t,e){return this.url.searchParams.append(t,`imatch.${e}`),this}is(t,e){return this.url.searchParams.append(t,`is.${e}`),this}isDistinct(t,e){return this.url.searchParams.append(t,`isdistinct.${e}`),this}in(t,e){let r=Array.from(new Set(e)).map(i=>typeof i=="string"&&bR.test(i)?`"${i}"`:`${i}`).join(",");return this.url.searchParams.append(t,`in.(${r})`),this}notIn(t,e){let r=Array.from(new Set(e)).map(i=>typeof i=="string"&&bR.test(i)?`"${i}"`:`${i}`).join(",");return this.url.searchParams.append(t,`not.in.(${r})`),this}contains(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cs.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cs.{${e.join(",")}}`):this.url.searchParams.append(t,`cs.${JSON.stringify(e)}`),this}containedBy(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cd.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cd.{${e.join(",")}}`):this.url.searchParams.append(t,`cd.${JSON.stringify(e)}`),this}rangeGt(t,e){return this.url.searchParams.append(t,`sr.${e}`),this}rangeGte(t,e){return this.url.searchParams.append(t,`nxl.${e}`),this}rangeLt(t,e){return this.url.searchParams.append(t,`sl.${e}`),this}rangeLte(t,e){return this.url.searchParams.append(t,`nxr.${e}`),this}rangeAdjacent(t,e){return this.url.searchParams.append(t,`adj.${e}`),this}overlaps(t,e){return typeof e=="string"?this.url.searchParams.append(t,`ov.${e}`):this.url.searchParams.append(t,`ov.{${e.join(",")}}`),this}textSearch(t,e,{config:r,type:i}={}){let n="";i==="plain"?n="pl":i==="phrase"?n="ph":i==="websearch"&&(n="w");let o=r===void 0?"":`(${r})`;return this.url.searchParams.append(t,`${n}fts${o}.${e}`),this}match(t){return Object.entries(t).filter(([e,r])=>r!==void 0).forEach(([e,r])=>{this.url.searchParams.append(e,`eq.${r}`)}),this}not(t,e,r){return this.url.searchParams.append(t,`not.${e}.${r}`),this}or(t,{foreignTable:e,referencedTable:r=e}={}){let i=r?`${r}.or`:"or";return this.url.searchParams.append(i,`(${t})`),this}filter(t,e,r){return this.url.searchParams.append(t,`${e}.${r}`),this}},IV=class{constructor(t,{headers:e={},schema:r,fetch:i,urlLengthLimit:n=8e3,retry:o}){this.url=t,this.headers=new Headers(e),this.schema=r,this.fetch=i,this.urlLengthLimit=n,this.retry=o}cloneRequestState(){return{url:new URL(this.url.toString()),headers:new Headers(this.headers)}}select(t,e){let{head:r=!1,count:i}=e??{},n=r?"HEAD":"GET",o=!1,s=(t??"*").split("").map(l=>/\s/.test(l)&&!o?"":(l==='"'&&(o=!o),l)).join(""),{url:a,headers:c}=this.cloneRequestState();return a.searchParams.set("select",s),i&&c.append("Prefer",`count=${i}`),new wa({method:n,url:a,headers:c,schema:this.schema,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}insert(t,{count:e,defaultToNull:r=!0}={}){var i;let n="POST",{url:o,headers:s}=this.cloneRequestState();if(e&&s.append("Prefer",`count=${e}`),r||s.append("Prefer","missing=default"),Array.isArray(t)){let a=t.reduce((c,l)=>c.concat(Object.keys(l)),[]);if(a.length>0){let c=[...new Set(a)].map(l=>`"${l}"`);o.searchParams.set("columns",c.join(","))}}return new wa({method:n,url:o,headers:s,schema:this.schema,body:t,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}upsert(t,{onConflict:e,ignoreDuplicates:r=!1,count:i,defaultToNull:n=!0}={}){var o;let s="POST",{url:a,headers:c}=this.cloneRequestState();if(c.append("Prefer",`resolution=${r?"ignore":"merge"}-duplicates`),e!==void 0&&a.searchParams.set("on_conflict",e),i&&c.append("Prefer",`count=${i}`),n||c.append("Prefer","missing=default"),Array.isArray(t)){let l=t.reduce((u,d)=>u.concat(Object.keys(d)),[]);if(l.length>0){let u=[...new Set(l)].map(d=>`"${d}"`);a.searchParams.set("columns",u.join(","))}}return new wa({method:s,url:a,headers:c,schema:this.schema,body:t,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}update(t,{count:e}={}){var r;let i="PATCH",{url:n,headers:o}=this.cloneRequestState();return e&&o.append("Prefer",`count=${e}`),new wa({method:i,url:n,headers:o,schema:this.schema,body:t,fetch:(r=this.fetch)!==null&&r!==void 0?r:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}delete({count:t}={}){var e;let r="DELETE",{url:i,headers:n}=this.cloneRequestState();return t&&n.append("Prefer",`count=${t}`),new wa({method:r,url:i,headers:n,schema:this.schema,fetch:(e=this.fetch)!==null&&e!==void 0?e:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}};xR=class IR{constructor(e,{headers:r={},schema:i,fetch:n,timeout:o,urlLengthLimit:s=8e3,retry:a}={}){this.url=e,this.headers=new Headers(r),this.schemaName=i,this.urlLengthLimit=s;let c=n??globalThis.fetch;o!==void 0&&o>0?this.fetch=(l,u)=>{let d=new AbortController,p=setTimeout(()=>d.abort(),o),f=u?.signal;if(f){if(f.aborted)return clearTimeout(p),c(l,u);let h=()=>{clearTimeout(p),d.abort()};return f.addEventListener("abort",h,{once:!0}),c(l,ts(ts({},u),{},{signal:d.signal})).finally(()=>{clearTimeout(p),f.removeEventListener("abort",h)})}return c(l,ts(ts({},u),{},{signal:d.signal})).finally(()=>clearTimeout(p))}:this.fetch=c,this.retry=a}from(e){if(!e||typeof e!="string"||e.trim()==="")throw new Error("Invalid relation name: relation must be a non-empty string.");return new IV(new URL(`${this.url}/${e}`),{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}schema(e){return new IR(this.url,{headers:this.headers,schema:e,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}async getOpenApiSpec(){var e=this,r;let i=new Headers(e.headers);i.set("Accept","application/openapi+json"),e.schemaName&&i.set("Accept-Profile",e.schemaName);let n={};i.forEach((l,u)=>{n[u]=l});let o=(r=e.fetch)!==null&&r!==void 0?r:globalThis.fetch,s;try{var a;s=await SR(o,`${e.url}/`,{method:"GET",headers:n},(a=e.retry)!==null&&a!==void 0?a:!0)}catch(l){return wR(l,0,"")}let c;try{c=await s.text()}catch(l){return wR(l,s.status,s.statusText)}if(s.ok)try{return{success:!0,error:null,data:JSON.parse(c),count:null,status:s.status,statusText:s.statusText}}catch{}return{success:!1,error:EV(c,s.statusText),data:null,count:null,status:s.status,statusText:s.statusText}}rpc(e,r={},{head:i=!1,get:n=!1,count:o}={}){var s;let a,c=new URL(`${this.url}/rpc/${e}`),l,u=f=>f!==null&&typeof f=="object"&&(!Array.isArray(f)||f.some(u)),d=i&&Object.values(r).some(u);d?(a="POST",l=r):i||n?(a=i?"HEAD":"GET",Object.entries(r).filter(([f,h])=>h!==void 0).map(([f,h])=>[f,Array.isArray(h)?`{${h.join(",")}}`:`${h}`]).forEach(([f,h])=>{c.searchParams.append(f,h)})):(a="POST",l=r);let p=new Headers(this.headers);return d?p.set("Prefer",o?`count=${o},return=minimal`:"return=minimal"):o&&p.set("Prefer",`count=${o}`),new wa({method:a,url:c,headers:p,schema:this.schemaName,body:l,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}}});var Fw=C(uu=>{"use strict";Object.defineProperty(uu,"__esModule",{value:!0});uu.WebSocketFactory=void 0;var Qh=class{constructor(){}static detectEnvironment(){var e;if(typeof WebSocket<"u")return{type:"native",wsConstructor:WebSocket};let r=globalThis;if(typeof globalThis<"u"&&typeof r.WebSocket<"u")return{type:"native",wsConstructor:r.WebSocket};let i=typeof global<"u"?global:void 0;if(i&&typeof i.WebSocket<"u")return{type:"native",wsConstructor:i.WebSocket};if(typeof globalThis<"u"&&typeof r.WebSocketPair<"u"&&typeof globalThis.WebSocket>"u")return{type:"cloudflare",error:"Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.",workaround:"Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."};if(typeof globalThis<"u"&&r.EdgeRuntime||typeof navigator<"u"&&(!((e=navigator.userAgent)===null||e===void 0)&&e.includes("Vercel-Edge")))return{type:"unsupported",error:"Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",workaround:"Use serverless functions or a different deployment target for WebSocket functionality."};let n=globalThis.process;if(n){let o=n.versions;if(o&&o.node)return{type:"unsupported",error:"Node.js detected but native WebSocket not found.",workaround:"Ensure you are running Node.js 22+ or provide a WebSocket implementation via the transport option."}}return{type:"unsupported",error:"Unknown JavaScript runtime without WebSocket support.",workaround:"Ensure you're running in a supported environment (browser, Node.js, Deno) or provide a custom WebSocket implementation."}}static getWebSocketConstructor(){let e=this.detectEnvironment();if(e.wsConstructor)return e.wsConstructor;let r=e.error||"WebSocket not supported in this environment.";throw e.workaround&&(r+=`
91
91
 
92
- Suggested solution: ${e.workaround}`),new Error(r)}static isWebSocketSupported(){try{return this.detectEnvironment().type==="native"}catch{return!1}}};uu.WebSocketFactory=Qh;uu.default=Qh});var TR=C(em=>{"use strict";Object.defineProperty(em,"__esModule",{value:!0});em.version=void 0;em.version="2.117.3"});var du=C(He=>{"use strict";Object.defineProperty(He,"__esModule",{value:!0});He.CONNECTION_STATE=He.TRANSPORTS=He.CHANNEL_EVENTS=He.CHANNEL_STATES=He.SOCKET_STATES=He.MAX_PUSH_BUFFER_SIZE=He.WS_CLOSE_NORMAL=He.POSTGRES_CHANGES_WAIT_ERROR_GRACE=He.DEFAULT_POSTGRES_CHANGES_WAIT_TIMEOUT=He.DEFAULT_TIMEOUT=He.VERSION=He.DEFAULT_VSN=He.VSN_2_0_0=He.VSN_1_0_0=He.DEFAULT_VERSION=void 0;var OR=TR();He.DEFAULT_VERSION=`realtime-js/${OR.version}`;He.VSN_1_0_0="1.0.0";He.VSN_2_0_0="2.0.0";He.DEFAULT_VSN=He.VSN_2_0_0;He.VERSION=OR.version;He.DEFAULT_TIMEOUT=1e4;He.DEFAULT_POSTGRES_CHANGES_WAIT_TIMEOUT=15e3;He.POSTGRES_CHANGES_WAIT_ERROR_GRACE=1e4;He.WS_CLOSE_NORMAL=1e3;He.MAX_PUSH_BUFFER_SIZE=100;He.SOCKET_STATES={connecting:0,open:1,closing:2,closed:3};He.CHANNEL_STATES={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"};He.CHANNEL_EVENTS={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave",access_token:"access_token"};He.TRANSPORTS={websocket:"websocket"};He.CONNECTION_STATE={connecting:"connecting",open:"open",closing:"closing",closed:"closed"}});var PR=C(qw=>{"use strict";Object.defineProperty(qw,"__esModule",{value:!0});var Zw=class{constructor(e){this.HEADER_LENGTH=1,this.USER_BROADCAST_PUSH_META_LENGTH=6,this.KINDS={userBroadcastPush:3,userBroadcast:4},this.BINARY_ENCODING=0,this.JSON_ENCODING=1,this.BROADCAST_EVENT="broadcast",this.allowedMetadataKeys=[],this.allowedMetadataKeys=e??[]}encode(e,r){if(e.event===this.BROADCAST_EVENT&&!(e.payload instanceof ArrayBuffer)&&typeof e.payload.event=="string")return r(this._binaryEncodeUserBroadcastPush(e));let i=[e.join_ref,e.ref,e.topic,e.event,e.payload];return r(JSON.stringify(i))}_binaryEncodeUserBroadcastPush(e){var r;return this._isArrayBuffer((r=e.payload)===null||r===void 0?void 0:r.payload)?this._encodeBinaryUserBroadcastPush(e):this._encodeJsonUserBroadcastPush(e)}_encodeBinaryUserBroadcastPush(e){var r,i;let n=(i=(r=e.payload)===null||r===void 0?void 0:r.payload)!==null&&i!==void 0?i:new ArrayBuffer(0);return this._encodeUserBroadcastPush(e,this.BINARY_ENCODING,n)}_encodeJsonUserBroadcastPush(e){var r,i;let n=(i=(r=e.payload)===null||r===void 0?void 0:r.payload)!==null&&i!==void 0?i:{},s=new TextEncoder().encode(JSON.stringify(n)).buffer;return this._encodeUserBroadcastPush(e,this.JSON_ENCODING,s)}_encodeUserBroadcastPush(e,r,i){var n,o;let s=new TextEncoder,a=s.encode(e.topic),c=s.encode((n=e.ref)!==null&&n!==void 0?n:""),l=s.encode((o=e.join_ref)!==null&&o!==void 0?o:""),u=s.encode(e.payload.event),d=this.allowedMetadataKeys?this._pick(e.payload,this.allowedMetadataKeys):{},p=s.encode(Object.keys(d).length===0?"":JSON.stringify(d));if(l.length>255)throw new Error(`joinRef length ${l.length} exceeds maximum of 255`);if(c.length>255)throw new Error(`ref length ${c.length} exceeds maximum of 255`);if(a.length>255)throw new Error(`topic length ${a.length} exceeds maximum of 255`);if(u.length>255)throw new Error(`userEvent length ${u.length} exceeds maximum of 255`);if(p.length>255)throw new Error(`metadata length ${p.length} exceeds maximum of 255`);let f=this.USER_BROADCAST_PUSH_META_LENGTH+l.length+c.length+a.length+u.length+p.length,h=new ArrayBuffer(this.HEADER_LENGTH+f),m=new DataView(h),g=new Uint8Array(h),y=0;m.setUint8(y++,this.KINDS.userBroadcastPush),m.setUint8(y++,l.length),m.setUint8(y++,c.length),m.setUint8(y++,a.length),m.setUint8(y++,u.length),m.setUint8(y++,p.length),m.setUint8(y++,r),g.set(l,y),y+=l.length,g.set(c,y),y+=c.length,g.set(a,y),y+=a.length,g.set(u,y),y+=u.length,g.set(p,y),y+=p.length;var v=new Uint8Array(h.byteLength+i.byteLength);return v.set(new Uint8Array(h),0),v.set(new Uint8Array(i),h.byteLength),v.buffer}decode(e,r){if(this._isArrayBuffer(e)){let i=this._binaryDecode(e);return r(i)}if(typeof e=="string"){let i=JSON.parse(e),[n,o,s,a,c]=i;return r({join_ref:n,ref:o,topic:s,event:a,payload:c})}return r({})}_binaryDecode(e){let r=new DataView(e),i=r.getUint8(0),n=new TextDecoder;switch(i){case this.KINDS.userBroadcast:return this._decodeUserBroadcast(e,r,n)}}_decodeUserBroadcast(e,r,i){let n=r.getUint8(1),o=r.getUint8(2),s=r.getUint8(3),a=r.getUint8(4),c=this.HEADER_LENGTH+4,l=i.decode(e.slice(c,c+n));c=c+n;let u=i.decode(e.slice(c,c+o));c=c+o;let d=i.decode(e.slice(c,c+s));c=c+s;let p=e.slice(c,e.byteLength),f=a===this.JSON_ENCODING?JSON.parse(i.decode(p)):p,h={type:this.BROADCAST_EVENT,event:u,payload:f};return s>0&&(h.meta=JSON.parse(d)),{join_ref:null,ref:null,topic:l,event:this.BROADCAST_EVENT,payload:h}}_isArrayBuffer(e){var r;return e instanceof ArrayBuffer||((r=e?.constructor)===null||r===void 0?void 0:r.name)==="ArrayBuffer"}_pick(e,r){return!e||typeof e!="object"?{}:Object.fromEntries(Object.entries(e).filter(([i])=>r.includes(i)))}};qw.default=Zw});var tm=C(tt=>{"use strict";Object.defineProperty(tt,"__esModule",{value:!0});tt.httpEndpointURL=tt.toTimestampString=tt.toArray=tt.toJson=tt.toNumber=tt.toBoolean=tt.convertCell=tt.convertColumn=tt.convertChangeData=tt.PostgresTypes=void 0;var mt;(function(t){t.abstime="abstime",t.bool="bool",t.date="date",t.daterange="daterange",t.float4="float4",t.float8="float8",t.int2="int2",t.int4="int4",t.int4range="int4range",t.int8="int8",t.int8range="int8range",t.json="json",t.jsonb="jsonb",t.money="money",t.numeric="numeric",t.oid="oid",t.reltime="reltime",t.text="text",t.time="time",t.timestamp="timestamp",t.timestamptz="timestamptz",t.timetz="timetz",t.tsrange="tsrange",t.tstzrange="tstzrange"})(mt||(tt.PostgresTypes=mt={}));var TV=(t,e,r={})=>{var i;let n=(i=r.skipTypes)!==null&&i!==void 0?i:[];return e?Object.keys(e).reduce((o,s)=>(o[s]=(0,tt.convertColumn)(s,t,e,n),o),{}):{}};tt.convertChangeData=TV;var OV=(t,e,r,i)=>{let n=e.find(a=>a.name===t),o=n?.type,s=r[t];return o&&!i.includes(o)?(0,tt.convertCell)(o,s):Vw(s)};tt.convertColumn=OV;var PV=(t,e)=>{if(t.charAt(0)==="_"){let r=t.slice(1,t.length);return(0,tt.toArray)(e,r)}switch(t){case mt.bool:return(0,tt.toBoolean)(e);case mt.float4:case mt.float8:case mt.int2:case mt.int4:case mt.int8:case mt.numeric:case mt.oid:return(0,tt.toNumber)(e);case mt.json:case mt.jsonb:return(0,tt.toJson)(e);case mt.timestamp:return(0,tt.toTimestampString)(e);case mt.abstime:case mt.date:case mt.daterange:case mt.int4range:case mt.int8range:case mt.money:case mt.reltime:case mt.text:case mt.time:case mt.timestamptz:case mt.timetz:case mt.tsrange:case mt.tstzrange:return Vw(e);default:return Vw(e)}};tt.convertCell=PV;var Vw=t=>t,AV=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}};tt.toBoolean=AV;var RV=t=>{if(typeof t=="string"){let e=parseFloat(t);if(!Number.isNaN(e))return e}return t};tt.toNumber=RV;var jV=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch{return t}return t};tt.toJson=jV;var zV=(t,e)=>{if(typeof t!="string")return t;let r=t.length-1,i=t[r];if(t[0]==="{"&&i==="}"){let o,s=t.slice(1,r);try{o=JSON.parse("["+s+"]")}catch{o=s?s.split(","):[]}return o.map(a=>(0,tt.convertCell)(e,a))}return t};tt.toArray=zV;var CV=t=>typeof t=="string"?t.replace(" ","T"):t;tt.toTimestampString=CV;var NV=t=>{let e=new URL(t);return e.protocol=e.protocol.replace(/^ws/i,"http"),e.pathname=e.pathname.replace(/\/+$/,"").replace(/\/socket\/websocket$/i,"").replace(/\/socket$/i,"").replace(/\/websocket$/i,""),e.pathname===""||e.pathname==="/"?e.pathname="/api/broadcast":e.pathname=e.pathname+"/api/broadcast",e.href};tt.httpEndpointURL=NV});var Gw=C((Vne,jR)=>{"use strict";var Ww=Object.defineProperty,DV=Object.getOwnPropertyDescriptor,LV=Object.getOwnPropertyNames,UV=Object.prototype.hasOwnProperty,MV=(t,e)=>{for(var r in e)Ww(t,r,{get:e[r],enumerable:!0})},FV=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of LV(e))!UV.call(t,n)&&n!==r&&Ww(t,n,{get:()=>e[n],enumerable:!(i=DV(e,n))||i.enumerable});return t},ZV=t=>FV(Ww({},"__esModule",{value:!0}),t),AR={};MV(AR,{Channel:()=>RR,LongPoll:()=>rs,Presence:()=>JV,Push:()=>fu,Serializer:()=>hu,Socket:()=>XV,Timer:()=>Kw});jR.exports=ZV(AR);var ka=t=>typeof t=="function"?t:function(){return t},qV=typeof self<"u"?self:null,$a=typeof window<"u"?window:null,Hn=qV||$a||globalThis,VV="2.0.0",BV=1e4,HV=1e3,WV=100,Wn={connecting:0,open:1,closing:2,closed:3},Rr={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},$i={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},Bw={longpoll:"longpoll",websocket:"websocket"},KV={complete:4},Hw="base64url.bearer.phx.",fu=class{constructor(t,e,r,i){this.channel=t,this.event=e,this.payload=r||function(){return{}},this.receivedResp=null,this.timeout=i,this.timeoutTimer=null,this.recHooks=[],this.sent=!1,this.ref=void 0}resend(t){this.timeout=t,this.reset(),this.send()}send(){this.hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload(),ref:this.ref,join_ref:this.channel.joinRef()}))}receive(t,e){return this.hasReceived(t)&&e(this.receivedResp.response),this.recHooks.push({status:t,callback:e}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=!1}destroy(){this.cancelRefEvent(),this.cancelTimeout()}matchReceive({status:t,response:e,_ref:r}){this.recHooks.filter(i=>i.status===t).forEach(i=>i.callback(e))}cancelRefEvent(){this.refEvent&&this.channel.off(this.refEvent)}cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=null}startTimeout(){this.timeoutTimer&&this.cancelTimeout(),this.ref=this.channel.socket.makeRef(),this.refEvent=this.channel.replyEventName(this.ref),this.channel.on(this.refEvent,t=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=t,this.matchReceive(t)}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}hasReceived(t){return this.receivedResp&&this.receivedResp.status===t}trigger(t,e){this.channel.trigger(this.refEvent,{status:t,response:e})}},Kw=class{constructor(t,e){this.callback=t,this.timerCalc=e,this.timer=void 0,this.tries=0}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}},RR=class{constructor(t,e,r){this.state=Rr.closed,this.topic=t,this.params=ka(e||{}),this.socket=r,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new fu(this,$i.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new Kw(()=>{this.socket.isConnected()&&this.rejoin()},this.socket.rejoinAfterMs),this.stateChangeRefs.push(this.socket.onError(()=>this.rejoinTimer.reset())),this.stateChangeRefs.push(this.socket.onOpen(()=>{this.rejoinTimer.reset(),this.isErrored()&&this.rejoin()})),this.joinPush.receive("ok",()=>{this.state=Rr.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(i=>i.send()),this.pushBuffer=[]}),this.joinPush.receive("error",i=>{this.state=Rr.errored,this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,i),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.onClose(()=>{this.rejoinTimer.reset(),this.socket.hasLogger()&&this.socket.log("channel",`close ${this.topic}`),this.state=Rr.closed,this.socket.remove(this)}),this.onError(i=>{this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,i),this.isJoining()&&this.joinPush.reset(),this.state=Rr.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive("timeout",()=>{this.socket.hasLogger()&&this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),new fu(this,$i.leave,ka({}),this.timeout).send(),this.state=Rr.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on($i.reply,(i,n)=>{this.trigger(this.replyEventName(n),i)})}join(t=this.timeout){if(this.joinedOnce)throw new Error("tried to join multiple times. 'join' can only be called a single time per channel instance");return this.timeout=t,this.joinedOnce=!0,this.rejoin(),this.joinPush}teardown(){this.pushBuffer.forEach(t=>t.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=Rr.closed,this.bindings=[]}onClose(t){this.on($i.close,t)}onError(t){return this.on($i.error,e=>t(e))}on(t,e){let r=this.bindingRef++;return this.bindings.push({event:t,ref:r,callback:e}),r}off(t,e){this.bindings=this.bindings.filter(r=>!(r.event===t&&(typeof e>"u"||e===r.ref)))}canPush(){return this.socket.isConnected()&&this.isJoined()}push(t,e,r=this.timeout){if(e=e||{},!this.joinedOnce)throw new Error(`tried to push '${t}' to '${this.topic}' before joining. Use channel.join() before pushing events`);let i=new fu(this,t,function(){return e},r);return this.canPush()?i.send():(i.startTimeout(),this.pushBuffer.push(i)),i}leave(t=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=Rr.leaving;let e=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger($i.close,"leave")},r=new fu(this,$i.leave,ka({}),t);return r.receive("ok",()=>e()).receive("timeout",()=>e()),r.send(),this.canPush()||r.trigger("ok",{}),r}onMessage(t,e,r){return e}filterBindings(t,e,r){return!0}isMember(t,e,r,i){return this.topic!==t?!1:i&&i!==this.joinRef()?(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:t,event:e,payload:r,joinRef:i}),!1):!0}joinRef(){return this.joinPush.ref}rejoin(t=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=Rr.joining,this.joinPush.resend(t))}trigger(t,e,r,i){let n=this.onMessage(t,e,r,i);if(e&&!n)throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");let o=this.bindings.filter(s=>s.event===t&&this.filterBindings(s,e,r));for(let s=0;s<o.length;s++)o[s].callback(n,r,i||this.joinRef())}replyEventName(t){return`chan_reply_${t}`}isClosed(){return this.state===Rr.closed}isErrored(){return this.state===Rr.errored}isJoined(){return this.state===Rr.joined}isJoining(){return this.state===Rr.joining}isLeaving(){return this.state===Rr.leaving}},rm=class{static request(t,e,r,i,n,o,s){if(Hn.XDomainRequest){let a=new Hn.XDomainRequest;return this.xdomainRequest(a,t,e,i,n,o,s)}else if(Hn.XMLHttpRequest){let a=new Hn.XMLHttpRequest;return this.xhrRequest(a,t,e,r,i,n,o,s)}else{if(Hn.fetch&&Hn.AbortController)return this.fetchRequest(t,e,r,i,n,o,s);throw new Error("No suitable XMLHttpRequest implementation found")}}static fetchRequest(t,e,r,i,n,o,s){let a={method:t,headers:r,body:i},c=null;if(n){c=new AbortController;let l=setTimeout(()=>c.abort(),n);a.signal=c.signal}return Hn.fetch(e,a).then(l=>l.text()).then(l=>this.parseJSON(l)).then(l=>s&&s(l)).catch(l=>{l.name==="AbortError"&&o?o():s&&s(null)}),c}static xdomainRequest(t,e,r,i,n,o,s){return t.timeout=n,t.open(e,r),t.onload=()=>{let a=this.parseJSON(t.responseText);s&&s(a)},o&&(t.ontimeout=o),t.onprogress=()=>{},t.send(i),t}static xhrRequest(t,e,r,i,n,o,s,a){t.open(e,r,!0),t.timeout=o;for(let[c,l]of Object.entries(i))t.setRequestHeader(c,l);return t.onerror=()=>a&&a(null),t.onreadystatechange=()=>{if(t.readyState===KV.complete&&a){let c=this.parseJSON(t.responseText);a(c)}},s&&(t.ontimeout=s),t.send(n),t}static parseJSON(t){if(!t||t==="")return null;try{return JSON.parse(t)}catch{return console&&console.log("failed to parse JSON response",t),null}}static serialize(t,e){let r=[];for(var i in t){if(!Object.prototype.hasOwnProperty.call(t,i))continue;let n=e?`${e}[${i}]`:i,o=t[i];typeof o=="object"?r.push(this.serialize(o,n)):r.push(encodeURIComponent(n)+"="+encodeURIComponent(o))}return r.join("&")}static appendParams(t,e){if(Object.keys(e).length===0)return t;let r=t.match(/\?/)?"&":"?";return`${t}${r}${this.serialize(e)}`}},GV=t=>{let e="",r=new Uint8Array(t),i=r.byteLength;for(let n=0;n<i;n++)e+=String.fromCharCode(r[n]);return btoa(e)},rs=class{constructor(t,e){e&&e.length===2&&e[1].startsWith(Hw)&&(this.authToken=atob(e[1].slice(Hw.length))),this.endPoint=null,this.token=null,this.skipHeartbeat=!0,this.reqs=new Set,this.awaitingBatchAck=!1,this.currentBatch=null,this.currentBatchTimer=null,this.batchBuffer=[],this.onopen=function(){},this.onerror=function(){},this.onmessage=function(){},this.onclose=function(){},this.pollEndpoint=this.normalizeEndpoint(t),this.readyState=Wn.connecting,setTimeout(()=>this.poll(),0)}normalizeEndpoint(t){return t.replace("ws://","http://").replace("wss://","https://").replace(new RegExp("(.*)/"+Bw.websocket),"$1/"+Bw.longpoll)}endpointURL(){return rm.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(t,e,r){this.close(t,e,r),this.readyState=Wn.connecting}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return this.readyState===Wn.open||this.readyState===Wn.connecting}poll(){let t={Accept:"application/json"};this.authToken&&(t["X-Phoenix-AuthToken"]=this.authToken),this.ajax("GET",t,null,()=>this.ontimeout(),e=>{if(e){var{status:r,token:i,messages:n}=e;if(r===410&&this.token!==null){this.onerror(410),this.closeAndRetry(3410,"session_gone",!1);return}this.token=i}else r=0;switch(r){case 200:n.forEach(o=>{setTimeout(()=>this.onmessage({data:o}),0)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=Wn.open,this.onopen({}),this.poll();break;case 403:this.onerror(403),this.close(1008,"forbidden",!1);break;case 0:case 500:this.onerror(500),this.closeAndRetry(1011,"internal server error",500);break;default:throw new Error(`unhandled poll status ${r}`)}})}send(t){typeof t!="string"&&(t=GV(t)),this.currentBatch?this.currentBatch.push(t):this.awaitingBatchAck?this.batchBuffer.push(t):(this.currentBatch=[t],this.currentBatchTimer=setTimeout(()=>{this.batchSend(this.currentBatch),this.currentBatch=null},0))}batchSend(t,e=0){this.awaitingBatchAck=!0;let r=e+WV,i=t.slice(e,r);this.ajax("POST",{"Content-Type":"application/x-ndjson"},i.join(`
92
+ Suggested solution: ${e.workaround}`),new Error(r)}static isWebSocketSupported(){try{return this.detectEnvironment().type==="native"}catch{return!1}}};uu.WebSocketFactory=Qh;uu.default=Qh});var TR=C(em=>{"use strict";Object.defineProperty(em,"__esModule",{value:!0});em.version=void 0;em.version="2.117.3"});var du=C(He=>{"use strict";Object.defineProperty(He,"__esModule",{value:!0});He.CONNECTION_STATE=He.TRANSPORTS=He.CHANNEL_EVENTS=He.CHANNEL_STATES=He.SOCKET_STATES=He.MAX_PUSH_BUFFER_SIZE=He.WS_CLOSE_NORMAL=He.POSTGRES_CHANGES_WAIT_ERROR_GRACE=He.DEFAULT_POSTGRES_CHANGES_WAIT_TIMEOUT=He.DEFAULT_TIMEOUT=He.VERSION=He.DEFAULT_VSN=He.VSN_2_0_0=He.VSN_1_0_0=He.DEFAULT_VERSION=void 0;var OR=TR();He.DEFAULT_VERSION=`realtime-js/${OR.version}`;He.VSN_1_0_0="1.0.0";He.VSN_2_0_0="2.0.0";He.DEFAULT_VSN=He.VSN_2_0_0;He.VERSION=OR.version;He.DEFAULT_TIMEOUT=1e4;He.DEFAULT_POSTGRES_CHANGES_WAIT_TIMEOUT=15e3;He.POSTGRES_CHANGES_WAIT_ERROR_GRACE=1e4;He.WS_CLOSE_NORMAL=1e3;He.MAX_PUSH_BUFFER_SIZE=100;He.SOCKET_STATES={connecting:0,open:1,closing:2,closed:3};He.CHANNEL_STATES={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"};He.CHANNEL_EVENTS={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave",access_token:"access_token"};He.TRANSPORTS={websocket:"websocket"};He.CONNECTION_STATE={connecting:"connecting",open:"open",closing:"closing",closed:"closed"}});var PR=C(qw=>{"use strict";Object.defineProperty(qw,"__esModule",{value:!0});var Zw=class{constructor(e){this.HEADER_LENGTH=1,this.USER_BROADCAST_PUSH_META_LENGTH=6,this.KINDS={userBroadcastPush:3,userBroadcast:4},this.BINARY_ENCODING=0,this.JSON_ENCODING=1,this.BROADCAST_EVENT="broadcast",this.allowedMetadataKeys=[],this.allowedMetadataKeys=e??[]}encode(e,r){if(e.event===this.BROADCAST_EVENT&&!(e.payload instanceof ArrayBuffer)&&typeof e.payload.event=="string")return r(this._binaryEncodeUserBroadcastPush(e));let i=[e.join_ref,e.ref,e.topic,e.event,e.payload];return r(JSON.stringify(i))}_binaryEncodeUserBroadcastPush(e){var r;return this._isArrayBuffer((r=e.payload)===null||r===void 0?void 0:r.payload)?this._encodeBinaryUserBroadcastPush(e):this._encodeJsonUserBroadcastPush(e)}_encodeBinaryUserBroadcastPush(e){var r,i;let n=(i=(r=e.payload)===null||r===void 0?void 0:r.payload)!==null&&i!==void 0?i:new ArrayBuffer(0);return this._encodeUserBroadcastPush(e,this.BINARY_ENCODING,n)}_encodeJsonUserBroadcastPush(e){var r,i;let n=(i=(r=e.payload)===null||r===void 0?void 0:r.payload)!==null&&i!==void 0?i:{},s=new TextEncoder().encode(JSON.stringify(n)).buffer;return this._encodeUserBroadcastPush(e,this.JSON_ENCODING,s)}_encodeUserBroadcastPush(e,r,i){var n,o;let s=new TextEncoder,a=s.encode(e.topic),c=s.encode((n=e.ref)!==null&&n!==void 0?n:""),l=s.encode((o=e.join_ref)!==null&&o!==void 0?o:""),u=s.encode(e.payload.event),d=this.allowedMetadataKeys?this._pick(e.payload,this.allowedMetadataKeys):{},p=s.encode(Object.keys(d).length===0?"":JSON.stringify(d));if(l.length>255)throw new Error(`joinRef length ${l.length} exceeds maximum of 255`);if(c.length>255)throw new Error(`ref length ${c.length} exceeds maximum of 255`);if(a.length>255)throw new Error(`topic length ${a.length} exceeds maximum of 255`);if(u.length>255)throw new Error(`userEvent length ${u.length} exceeds maximum of 255`);if(p.length>255)throw new Error(`metadata length ${p.length} exceeds maximum of 255`);let f=this.USER_BROADCAST_PUSH_META_LENGTH+l.length+c.length+a.length+u.length+p.length,h=new ArrayBuffer(this.HEADER_LENGTH+f),m=new DataView(h),g=new Uint8Array(h),y=0;m.setUint8(y++,this.KINDS.userBroadcastPush),m.setUint8(y++,l.length),m.setUint8(y++,c.length),m.setUint8(y++,a.length),m.setUint8(y++,u.length),m.setUint8(y++,p.length),m.setUint8(y++,r),g.set(l,y),y+=l.length,g.set(c,y),y+=c.length,g.set(a,y),y+=a.length,g.set(u,y),y+=u.length,g.set(p,y),y+=p.length;var v=new Uint8Array(h.byteLength+i.byteLength);return v.set(new Uint8Array(h),0),v.set(new Uint8Array(i),h.byteLength),v.buffer}decode(e,r){if(this._isArrayBuffer(e)){let i=this._binaryDecode(e);return r(i)}if(typeof e=="string"){let i=JSON.parse(e),[n,o,s,a,c]=i;return r({join_ref:n,ref:o,topic:s,event:a,payload:c})}return r({})}_binaryDecode(e){let r=new DataView(e),i=r.getUint8(0),n=new TextDecoder;switch(i){case this.KINDS.userBroadcast:return this._decodeUserBroadcast(e,r,n)}}_decodeUserBroadcast(e,r,i){let n=r.getUint8(1),o=r.getUint8(2),s=r.getUint8(3),a=r.getUint8(4),c=this.HEADER_LENGTH+4,l=i.decode(e.slice(c,c+n));c=c+n;let u=i.decode(e.slice(c,c+o));c=c+o;let d=i.decode(e.slice(c,c+s));c=c+s;let p=e.slice(c,e.byteLength),f=a===this.JSON_ENCODING?JSON.parse(i.decode(p)):p,h={type:this.BROADCAST_EVENT,event:u,payload:f};return s>0&&(h.meta=JSON.parse(d)),{join_ref:null,ref:null,topic:l,event:this.BROADCAST_EVENT,payload:h}}_isArrayBuffer(e){var r;return e instanceof ArrayBuffer||((r=e?.constructor)===null||r===void 0?void 0:r.name)==="ArrayBuffer"}_pick(e,r){return!e||typeof e!="object"?{}:Object.fromEntries(Object.entries(e).filter(([i])=>r.includes(i)))}};qw.default=Zw});var tm=C(tt=>{"use strict";Object.defineProperty(tt,"__esModule",{value:!0});tt.httpEndpointURL=tt.toTimestampString=tt.toArray=tt.toJson=tt.toNumber=tt.toBoolean=tt.convertCell=tt.convertColumn=tt.convertChangeData=tt.PostgresTypes=void 0;var mt;(function(t){t.abstime="abstime",t.bool="bool",t.date="date",t.daterange="daterange",t.float4="float4",t.float8="float8",t.int2="int2",t.int4="int4",t.int4range="int4range",t.int8="int8",t.int8range="int8range",t.json="json",t.jsonb="jsonb",t.money="money",t.numeric="numeric",t.oid="oid",t.reltime="reltime",t.text="text",t.time="time",t.timestamp="timestamp",t.timestamptz="timestamptz",t.timetz="timetz",t.tsrange="tsrange",t.tstzrange="tstzrange"})(mt||(tt.PostgresTypes=mt={}));var TV=(t,e,r={})=>{var i;let n=(i=r.skipTypes)!==null&&i!==void 0?i:[];return e?Object.keys(e).reduce((o,s)=>(o[s]=(0,tt.convertColumn)(s,t,e,n),o),{}):{}};tt.convertChangeData=TV;var OV=(t,e,r,i)=>{let n=e.find(a=>a.name===t),o=n?.type,s=r[t];return o&&!i.includes(o)?(0,tt.convertCell)(o,s):Vw(s)};tt.convertColumn=OV;var PV=(t,e)=>{if(t.charAt(0)==="_"){let r=t.slice(1,t.length);return(0,tt.toArray)(e,r)}switch(t){case mt.bool:return(0,tt.toBoolean)(e);case mt.float4:case mt.float8:case mt.int2:case mt.int4:case mt.int8:case mt.numeric:case mt.oid:return(0,tt.toNumber)(e);case mt.json:case mt.jsonb:return(0,tt.toJson)(e);case mt.timestamp:return(0,tt.toTimestampString)(e);case mt.abstime:case mt.date:case mt.daterange:case mt.int4range:case mt.int8range:case mt.money:case mt.reltime:case mt.text:case mt.time:case mt.timestamptz:case mt.timetz:case mt.tsrange:case mt.tstzrange:return Vw(e);default:return Vw(e)}};tt.convertCell=PV;var Vw=t=>t,AV=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}};tt.toBoolean=AV;var RV=t=>{if(typeof t=="string"){let e=parseFloat(t);if(!Number.isNaN(e))return e}return t};tt.toNumber=RV;var jV=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch{return t}return t};tt.toJson=jV;var zV=(t,e)=>{if(typeof t!="string")return t;let r=t.length-1,i=t[r];if(t[0]==="{"&&i==="}"){let o,s=t.slice(1,r);try{o=JSON.parse("["+s+"]")}catch{o=s?s.split(","):[]}return o.map(a=>(0,tt.convertCell)(e,a))}return t};tt.toArray=zV;var CV=t=>typeof t=="string"?t.replace(" ","T"):t;tt.toTimestampString=CV;var NV=t=>{let e=new URL(t);return e.protocol=e.protocol.replace(/^ws/i,"http"),e.pathname=e.pathname.replace(/\/+$/,"").replace(/\/socket\/websocket$/i,"").replace(/\/socket$/i,"").replace(/\/websocket$/i,""),e.pathname===""||e.pathname==="/"?e.pathname="/api/broadcast":e.pathname=e.pathname+"/api/broadcast",e.href};tt.httpEndpointURL=NV});var Gw=C((Wne,jR)=>{"use strict";var Ww=Object.defineProperty,DV=Object.getOwnPropertyDescriptor,LV=Object.getOwnPropertyNames,UV=Object.prototype.hasOwnProperty,MV=(t,e)=>{for(var r in e)Ww(t,r,{get:e[r],enumerable:!0})},FV=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of LV(e))!UV.call(t,n)&&n!==r&&Ww(t,n,{get:()=>e[n],enumerable:!(i=DV(e,n))||i.enumerable});return t},ZV=t=>FV(Ww({},"__esModule",{value:!0}),t),AR={};MV(AR,{Channel:()=>RR,LongPoll:()=>rs,Presence:()=>JV,Push:()=>fu,Serializer:()=>hu,Socket:()=>XV,Timer:()=>Kw});jR.exports=ZV(AR);var ka=t=>typeof t=="function"?t:function(){return t},qV=typeof self<"u"?self:null,$a=typeof window<"u"?window:null,Hn=qV||$a||globalThis,VV="2.0.0",BV=1e4,HV=1e3,WV=100,Wn={connecting:0,open:1,closing:2,closed:3},Rr={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},$i={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},Bw={longpoll:"longpoll",websocket:"websocket"},KV={complete:4},Hw="base64url.bearer.phx.",fu=class{constructor(t,e,r,i){this.channel=t,this.event=e,this.payload=r||function(){return{}},this.receivedResp=null,this.timeout=i,this.timeoutTimer=null,this.recHooks=[],this.sent=!1,this.ref=void 0}resend(t){this.timeout=t,this.reset(),this.send()}send(){this.hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload(),ref:this.ref,join_ref:this.channel.joinRef()}))}receive(t,e){return this.hasReceived(t)&&e(this.receivedResp.response),this.recHooks.push({status:t,callback:e}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=!1}destroy(){this.cancelRefEvent(),this.cancelTimeout()}matchReceive({status:t,response:e,_ref:r}){this.recHooks.filter(i=>i.status===t).forEach(i=>i.callback(e))}cancelRefEvent(){this.refEvent&&this.channel.off(this.refEvent)}cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=null}startTimeout(){this.timeoutTimer&&this.cancelTimeout(),this.ref=this.channel.socket.makeRef(),this.refEvent=this.channel.replyEventName(this.ref),this.channel.on(this.refEvent,t=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=t,this.matchReceive(t)}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}hasReceived(t){return this.receivedResp&&this.receivedResp.status===t}trigger(t,e){this.channel.trigger(this.refEvent,{status:t,response:e})}},Kw=class{constructor(t,e){this.callback=t,this.timerCalc=e,this.timer=void 0,this.tries=0}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}},RR=class{constructor(t,e,r){this.state=Rr.closed,this.topic=t,this.params=ka(e||{}),this.socket=r,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new fu(this,$i.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new Kw(()=>{this.socket.isConnected()&&this.rejoin()},this.socket.rejoinAfterMs),this.stateChangeRefs.push(this.socket.onError(()=>this.rejoinTimer.reset())),this.stateChangeRefs.push(this.socket.onOpen(()=>{this.rejoinTimer.reset(),this.isErrored()&&this.rejoin()})),this.joinPush.receive("ok",()=>{this.state=Rr.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(i=>i.send()),this.pushBuffer=[]}),this.joinPush.receive("error",i=>{this.state=Rr.errored,this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,i),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.onClose(()=>{this.rejoinTimer.reset(),this.socket.hasLogger()&&this.socket.log("channel",`close ${this.topic}`),this.state=Rr.closed,this.socket.remove(this)}),this.onError(i=>{this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,i),this.isJoining()&&this.joinPush.reset(),this.state=Rr.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive("timeout",()=>{this.socket.hasLogger()&&this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),new fu(this,$i.leave,ka({}),this.timeout).send(),this.state=Rr.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on($i.reply,(i,n)=>{this.trigger(this.replyEventName(n),i)})}join(t=this.timeout){if(this.joinedOnce)throw new Error("tried to join multiple times. 'join' can only be called a single time per channel instance");return this.timeout=t,this.joinedOnce=!0,this.rejoin(),this.joinPush}teardown(){this.pushBuffer.forEach(t=>t.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=Rr.closed,this.bindings=[]}onClose(t){this.on($i.close,t)}onError(t){return this.on($i.error,e=>t(e))}on(t,e){let r=this.bindingRef++;return this.bindings.push({event:t,ref:r,callback:e}),r}off(t,e){this.bindings=this.bindings.filter(r=>!(r.event===t&&(typeof e>"u"||e===r.ref)))}canPush(){return this.socket.isConnected()&&this.isJoined()}push(t,e,r=this.timeout){if(e=e||{},!this.joinedOnce)throw new Error(`tried to push '${t}' to '${this.topic}' before joining. Use channel.join() before pushing events`);let i=new fu(this,t,function(){return e},r);return this.canPush()?i.send():(i.startTimeout(),this.pushBuffer.push(i)),i}leave(t=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=Rr.leaving;let e=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger($i.close,"leave")},r=new fu(this,$i.leave,ka({}),t);return r.receive("ok",()=>e()).receive("timeout",()=>e()),r.send(),this.canPush()||r.trigger("ok",{}),r}onMessage(t,e,r){return e}filterBindings(t,e,r){return!0}isMember(t,e,r,i){return this.topic!==t?!1:i&&i!==this.joinRef()?(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:t,event:e,payload:r,joinRef:i}),!1):!0}joinRef(){return this.joinPush.ref}rejoin(t=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=Rr.joining,this.joinPush.resend(t))}trigger(t,e,r,i){let n=this.onMessage(t,e,r,i);if(e&&!n)throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");let o=this.bindings.filter(s=>s.event===t&&this.filterBindings(s,e,r));for(let s=0;s<o.length;s++)o[s].callback(n,r,i||this.joinRef())}replyEventName(t){return`chan_reply_${t}`}isClosed(){return this.state===Rr.closed}isErrored(){return this.state===Rr.errored}isJoined(){return this.state===Rr.joined}isJoining(){return this.state===Rr.joining}isLeaving(){return this.state===Rr.leaving}},rm=class{static request(t,e,r,i,n,o,s){if(Hn.XDomainRequest){let a=new Hn.XDomainRequest;return this.xdomainRequest(a,t,e,i,n,o,s)}else if(Hn.XMLHttpRequest){let a=new Hn.XMLHttpRequest;return this.xhrRequest(a,t,e,r,i,n,o,s)}else{if(Hn.fetch&&Hn.AbortController)return this.fetchRequest(t,e,r,i,n,o,s);throw new Error("No suitable XMLHttpRequest implementation found")}}static fetchRequest(t,e,r,i,n,o,s){let a={method:t,headers:r,body:i},c=null;if(n){c=new AbortController;let l=setTimeout(()=>c.abort(),n);a.signal=c.signal}return Hn.fetch(e,a).then(l=>l.text()).then(l=>this.parseJSON(l)).then(l=>s&&s(l)).catch(l=>{l.name==="AbortError"&&o?o():s&&s(null)}),c}static xdomainRequest(t,e,r,i,n,o,s){return t.timeout=n,t.open(e,r),t.onload=()=>{let a=this.parseJSON(t.responseText);s&&s(a)},o&&(t.ontimeout=o),t.onprogress=()=>{},t.send(i),t}static xhrRequest(t,e,r,i,n,o,s,a){t.open(e,r,!0),t.timeout=o;for(let[c,l]of Object.entries(i))t.setRequestHeader(c,l);return t.onerror=()=>a&&a(null),t.onreadystatechange=()=>{if(t.readyState===KV.complete&&a){let c=this.parseJSON(t.responseText);a(c)}},s&&(t.ontimeout=s),t.send(n),t}static parseJSON(t){if(!t||t==="")return null;try{return JSON.parse(t)}catch{return console&&console.log("failed to parse JSON response",t),null}}static serialize(t,e){let r=[];for(var i in t){if(!Object.prototype.hasOwnProperty.call(t,i))continue;let n=e?`${e}[${i}]`:i,o=t[i];typeof o=="object"?r.push(this.serialize(o,n)):r.push(encodeURIComponent(n)+"="+encodeURIComponent(o))}return r.join("&")}static appendParams(t,e){if(Object.keys(e).length===0)return t;let r=t.match(/\?/)?"&":"?";return`${t}${r}${this.serialize(e)}`}},GV=t=>{let e="",r=new Uint8Array(t),i=r.byteLength;for(let n=0;n<i;n++)e+=String.fromCharCode(r[n]);return btoa(e)},rs=class{constructor(t,e){e&&e.length===2&&e[1].startsWith(Hw)&&(this.authToken=atob(e[1].slice(Hw.length))),this.endPoint=null,this.token=null,this.skipHeartbeat=!0,this.reqs=new Set,this.awaitingBatchAck=!1,this.currentBatch=null,this.currentBatchTimer=null,this.batchBuffer=[],this.onopen=function(){},this.onerror=function(){},this.onmessage=function(){},this.onclose=function(){},this.pollEndpoint=this.normalizeEndpoint(t),this.readyState=Wn.connecting,setTimeout(()=>this.poll(),0)}normalizeEndpoint(t){return t.replace("ws://","http://").replace("wss://","https://").replace(new RegExp("(.*)/"+Bw.websocket),"$1/"+Bw.longpoll)}endpointURL(){return rm.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(t,e,r){this.close(t,e,r),this.readyState=Wn.connecting}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return this.readyState===Wn.open||this.readyState===Wn.connecting}poll(){let t={Accept:"application/json"};this.authToken&&(t["X-Phoenix-AuthToken"]=this.authToken),this.ajax("GET",t,null,()=>this.ontimeout(),e=>{if(e){var{status:r,token:i,messages:n}=e;if(r===410&&this.token!==null){this.onerror(410),this.closeAndRetry(3410,"session_gone",!1);return}this.token=i}else r=0;switch(r){case 200:n.forEach(o=>{setTimeout(()=>this.onmessage({data:o}),0)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=Wn.open,this.onopen({}),this.poll();break;case 403:this.onerror(403),this.close(1008,"forbidden",!1);break;case 0:case 500:this.onerror(500),this.closeAndRetry(1011,"internal server error",500);break;default:throw new Error(`unhandled poll status ${r}`)}})}send(t){typeof t!="string"&&(t=GV(t)),this.currentBatch?this.currentBatch.push(t):this.awaitingBatchAck?this.batchBuffer.push(t):(this.currentBatch=[t],this.currentBatchTimer=setTimeout(()=>{this.batchSend(this.currentBatch),this.currentBatch=null},0))}batchSend(t,e=0){this.awaitingBatchAck=!0;let r=e+WV,i=t.slice(e,r);this.ajax("POST",{"Content-Type":"application/x-ndjson"},i.join(`
93
93
  `),()=>this.onerror("timeout"),n=>{!n||n.status!==200?(this.awaitingBatchAck=!1,this.onerror(n&&n.status),this.closeAndRetry(1011,"internal server error",!1)):r<t.length?this.batchSend(t,r):this.batchBuffer.length>0?(this.batchSend(this.batchBuffer),this.batchBuffer=[]):this.awaitingBatchAck=!1})}close(t,e,r){for(let n of this.reqs)n.abort();this.readyState=Wn.closed;let i=Object.assign({code:1e3,reason:void 0,wasClean:!0},{code:t,reason:e,wasClean:r});this.batchBuffer=[],clearTimeout(this.currentBatchTimer),this.currentBatchTimer=null,typeof CloseEvent<"u"?this.onclose(new CloseEvent("close",i)):this.onclose(i)}ajax(t,e,r,i,n){let o,s=()=>{this.reqs.delete(o),i()};o=rm.request(t,this.endpointURL(),e,r,this.timeout,s,a=>{this.reqs.delete(o),this.isActive()&&n(a)}),this.reqs.add(o)}},JV=class pu{constructor(e,r={}){let i=r.events||{state:"presence_state",diff:"presence_diff"};this.state=Object.create(null),this.pendingDiffs=[],this.channel=e,this.joinRef=null,this.caller={onJoin:function(){},onLeave:function(){},onSync:function(){}},this.channel.on(i.state,n=>{let{onJoin:o,onLeave:s,onSync:a}=this.caller;this.joinRef=this.channel.joinRef(),this.state=pu.syncState(this.state,n,o,s),this.pendingDiffs.forEach(c=>{this.state=pu.syncDiff(this.state,c,o,s)}),this.pendingDiffs=[],a()}),this.channel.on(i.diff,n=>{let{onJoin:o,onLeave:s,onSync:a}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(n):(this.state=pu.syncDiff(this.state,n,o,s),a())})}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}list(e){return pu.list(this.state,e)}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel.joinRef()}static syncState(e,r,i,n){let o=this.toNullProtoObj(this.clone(e));r=this.toNullProtoObj(r);let s=Object.create(null),a=Object.create(null);return this.map(o,(c,l)=>{r[c]||(a[c]=l)}),this.map(r,(c,l)=>{let u=o[c];if(u){let d=l.metas.map(m=>m.phx_ref),p=u.metas.map(m=>m.phx_ref),f=l.metas.filter(m=>p.indexOf(m.phx_ref)<0),h=u.metas.filter(m=>d.indexOf(m.phx_ref)<0);f.length>0&&(s[c]=l,s[c].metas=f),h.length>0&&(a[c]=this.clone(u),a[c].metas=h)}else s[c]=l}),this.syncDiff(o,{joins:s,leaves:a},i,n)}static syncDiff(e,r,i,n){e=this.toNullProtoObj(e);let{joins:o,leaves:s}=this.clone(r);return i||(i=function(){}),n||(n=function(){}),this.map(o,(a,c)=>{let l=e[a];if(e[a]=this.clone(c),l){let u=e[a].metas.map(p=>p.phx_ref),d=l.metas.filter(p=>u.indexOf(p.phx_ref)<0);e[a].metas.unshift(...d)}i(a,l,c)}),this.map(s,(a,c)=>{let l=e[a];if(!l)return;let u=c.metas.map(d=>d.phx_ref);l.metas=l.metas.filter(d=>u.indexOf(d.phx_ref)<0),n(a,l,c),l.metas.length===0&&delete e[a]}),e}static list(e,r){return r||(r=function(i,n){return n}),this.map(e,(i,n)=>r(i,n))}static map(e,r){return Object.getOwnPropertyNames(e).map(i=>r(i,e[i]))}static toNullProtoObj(e){if(Object.getPrototypeOf(e)===null)return e;let r=Object.create(null);return Object.getOwnPropertyNames(e).forEach(i=>{r[i]=e[i]}),r}static clone(e){return JSON.parse(JSON.stringify(e))}},hu={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(t,e){if(t.payload.constructor===ArrayBuffer)return e(this.binaryEncode(t));{let r=[t.join_ref,t.ref,t.topic,t.event,t.payload];return e(JSON.stringify(r))}},decode(t,e){if(t.constructor===ArrayBuffer)return e(this.binaryDecode(t));{let[r,i,n,o,s]=JSON.parse(t);return e({join_ref:r,ref:i,topic:n,event:o,payload:s})}},binaryEncode(t){let{join_ref:e,ref:r,event:i,topic:n,payload:o}=t,s=new TextEncoder,a=s.encode(e),c=s.encode(r),l=s.encode(n),u=s.encode(i);this.assertFieldSize(a.byteLength,"join_ref"),this.assertFieldSize(c.byteLength,"ref"),this.assertFieldSize(l.byteLength,"topic"),this.assertFieldSize(u.byteLength,"event");let d=this.META_LENGTH+a.byteLength+c.byteLength+l.byteLength+u.byteLength,p=new ArrayBuffer(this.HEADER_LENGTH+d),f=new Uint8Array(p),h=new DataView(p),m=0;h.setUint8(m++,this.KINDS.push),h.setUint8(m++,a.byteLength),h.setUint8(m++,c.byteLength),h.setUint8(m++,l.byteLength),h.setUint8(m++,u.byteLength),f.set(a,m),m+=a.byteLength,f.set(c,m),m+=c.byteLength,f.set(l,m),m+=l.byteLength,f.set(u,m),m+=u.byteLength;var g=new Uint8Array(p.byteLength+o.byteLength);return g.set(f,0),g.set(new Uint8Array(o),p.byteLength),g.buffer},assertFieldSize(t,e){if(t>255)throw new Error(`unable to convert ${e} to binary: must be less than or equal to 255 bytes, but is ${t} bytes`)},binaryDecode(t){let e=new DataView(t),r=e.getUint8(0),i=new TextDecoder;switch(r){case this.KINDS.push:return this.decodePush(t,e,i);case this.KINDS.reply:return this.decodeReply(t,e,i);case this.KINDS.broadcast:return this.decodeBroadcast(t,e,i)}},decodePush(t,e,r){let i=e.getUint8(1),n=e.getUint8(2),o=e.getUint8(3),s=this.HEADER_LENGTH+this.META_LENGTH-1,a=r.decode(t.slice(s,s+i));s=s+i;let c=r.decode(t.slice(s,s+n));s=s+n;let l=r.decode(t.slice(s,s+o));s=s+o;let u=t.slice(s,t.byteLength);return{join_ref:a,ref:null,topic:c,event:l,payload:u}},decodeReply(t,e,r){let i=e.getUint8(1),n=e.getUint8(2),o=e.getUint8(3),s=e.getUint8(4),a=this.HEADER_LENGTH+this.META_LENGTH,c=r.decode(t.slice(a,a+i));a=a+i;let l=r.decode(t.slice(a,a+n));a=a+n;let u=r.decode(t.slice(a,a+o));a=a+o;let d=r.decode(t.slice(a,a+s));a=a+s;let p=t.slice(a,t.byteLength),f={status:d,response:p};return{join_ref:c,ref:l,topic:u,event:$i.reply,payload:f}},decodeBroadcast(t,e,r){let i=e.getUint8(1),n=e.getUint8(2),o=this.HEADER_LENGTH+2,s=r.decode(t.slice(o,o+i));o=o+i;let a=r.decode(t.slice(o,o+n));o=o+n;let c=t.slice(o,t.byteLength);return{join_ref:null,ref:null,topic:s,event:a,payload:c}}},XV=class{constructor(t,e={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.fallbackRef=null,this.timeout=e.timeout||BV,this.transport=e.transport||Hn.WebSocket||rs,this.conn=void 0,this.primaryPassedHealthCheck=!1,this.longPollFallbackMs=e.longPollFallbackMs,this.fallbackTimer=null;let r=null;try{r=Hn&&Hn.sessionStorage}catch{}this.sessionStore=e.sessionStorage||r,this.establishedConnections=0,this.defaultEncoder=hu.encode.bind(hu),this.defaultDecoder=hu.decode.bind(hu),this.closeWasClean=!0,this.disconnecting=!1,this.binaryType=e.binaryType||"arraybuffer",this.connectClock=1,this.pageHidden=!1,this.encode=void 0,this.decode=void 0,this.transport!==rs?(this.encode=e.encode||this.defaultEncoder,this.decode=e.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let i=null;$a&&$a.addEventListener&&($a.addEventListener("pagehide",n=>{this.conn&&(this.disconnect(),i=this.connectClock)}),$a.addEventListener("pageshow",n=>{i===this.connectClock&&(i=null,this.connect())}),$a.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"?this.pageHidden=!0:(this.pageHidden=!1,!this.isConnected()&&!this.closeWasClean&&this.teardown(()=>this.connect()))})),this.heartbeatIntervalMs=e.heartbeatIntervalMs||3e4,this.autoSendHeartbeat=e.autoSendHeartbeat??!0,this.heartbeatCallback=e.heartbeatCallback??(()=>{}),this.rejoinAfterMs=n=>e.rejoinAfterMs?e.rejoinAfterMs(n):[1e3,2e3,5e3][n-1]||1e4,this.reconnectAfterMs=n=>e.reconnectAfterMs?e.reconnectAfterMs(n):[10,50,100,150,200,250,500,1e3,2e3][n-1]||5e3,this.logger=e.logger||null,!this.logger&&e.debug&&(this.logger=(n,o,s)=>{console.log(`${n}: ${o}`,s)}),this.longpollerTimeout=e.longpollerTimeout||2e4,this.params=ka(e.params||{}),this.endPoint=`${t}/${Bw.websocket}`,this.vsn=e.vsn||VV,this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.heartbeatSentAt=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new Kw(()=>{if(this.pageHidden){this.log("Not reconnecting as page is hidden!"),this.teardown();return}this.teardown(async()=>{e.beforeReconnect&&await e.beforeReconnect(),this.connect()})},this.reconnectAfterMs),this.authToken=e.authToken&&ka(e.authToken)}getLongPollTransport(){return rs}replaceTransport(t){this.connectClock++,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.conn&&(this.conn.close(),this.conn=null),this.transport=t}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let t=rm.appendParams(rm.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return t.charAt(0)!=="/"?t:t.charAt(1)==="/"?`${this.protocol()}:${t}`:`${this.protocol()}://${location.host}${t}`}disconnect(t,e,r){this.connectClock++,this.disconnecting=!0,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.teardown(()=>{this.disconnecting=!1,t&&t()},e,r)}connect(t){t&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=ka(t)),!(this.conn&&!this.disconnecting)&&(this.longPollFallbackMs&&this.transport!==rs?this.connectWithFallback(rs,this.longPollFallbackMs):this.transportConnect())}log(t,e,r){this.logger&&this.logger(t,e,r)}hasLogger(){return this.logger!==null}onOpen(t){let e=this.makeRef();return this.stateChangeCallbacks.open.push([e,t]),e}onClose(t){let e=this.makeRef();return this.stateChangeCallbacks.close.push([e,t]),e}onError(t){let e=this.makeRef();return this.stateChangeCallbacks.error.push([e,t]),e}onMessage(t){let e=this.makeRef();return this.stateChangeCallbacks.message.push([e,t]),e}onHeartbeat(t){this.heartbeatCallback=t}ping(t){if(!this.isConnected())return!1;let e=this.makeRef(),r=Date.now();this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:e});let i=this.onMessage(n=>{n.ref===e&&(this.off([i]),t(Date.now()-r))});return!0}transportName(t){switch(t){case rs:return"LongPoll";default:return t.name}}transportConnect(){this.connectClock++,this.closeWasClean=!1;let t;this.authToken&&(t=["phoenix",`${Hw}${btoa(this.authToken()).replace(/=/g,"")}`]),this.conn=new this.transport(this.endPointURL(),t),this.conn.binaryType=this.binaryType,this.conn.timeout=this.longpollerTimeout,this.conn.onopen=()=>this.onConnOpen(),this.conn.onerror=e=>this.onConnError(e),this.conn.onmessage=e=>this.onConnMessage(e),this.conn.onclose=e=>this.onConnClose(e)}getSession(t){return this.sessionStore&&this.sessionStore.getItem(t)}storeSession(t,e){this.sessionStore&&this.sessionStore.setItem(t,e)}connectWithFallback(t,e=2500){clearTimeout(this.fallbackTimer);let r=!1,i=!0,n,o,s=this.transportName(t),a=c=>{this.log("transport",`falling back to ${s}...`,c),this.off([n,o]),i=!1,this.replaceTransport(t),this.transportConnect()};if(this.getSession(`phx:fallback:${s}`))return a("memorized");this.fallbackTimer=setTimeout(a,e),o=this.onError(c=>{this.log("transport","error",c),i&&!r&&(clearTimeout(this.fallbackTimer),a(c))}),this.fallbackRef&&this.off([this.fallbackRef]),this.fallbackRef=this.onOpen(()=>{if(r=!0,!i){let c=this.transportName(t);return this.primaryPassedHealthCheck||this.storeSession(`phx:fallback:${c}`,"true"),this.log("transport",`established ${c} fallback`)}clearTimeout(this.fallbackTimer),this.fallbackTimer=setTimeout(a,e),this.ping(c=>{this.log("transport","connected to primary after",c),this.primaryPassedHealthCheck=!0,clearTimeout(this.fallbackTimer)})}),this.transportConnect()}clearHeartbeats(){clearTimeout(this.heartbeatTimer),clearTimeout(this.heartbeatTimeoutTimer)}onConnOpen(){this.hasLogger()&&this.log("transport",`connected to ${this.endPointURL()}`),this.closeWasClean=!1,this.disconnecting=!1,this.establishedConnections++,this.flushSendBuffer(),this.reconnectTimer.reset(),this.autoSendHeartbeat&&this.resetHeartbeat(),this.triggerStateCallbacks("open")}heartbeatTimeout(){if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.heartbeatSentAt=null,this.hasLogger()&&this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(t){this.log("error","error in heartbeat callback",t)}this.triggerChanError(new Error("heartbeat timeout")),this.closeWasClean=!1,this.teardown(()=>this.reconnectTimer.scheduleTimeout(),HV,"heartbeat timeout")}}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}teardown(t,e,r){if(!this.conn)return t&&t();let i=this.conn;this.waitForBufferDone(i,()=>{e?i.close(e,r||""):i.close(),this.waitForSocketClosed(i,()=>{this.conn===i&&(this.conn.onopen=function(){},this.conn.onerror=function(){},this.conn.onmessage=function(){},this.conn.onclose=function(){},this.conn=null),t&&t()})})}waitForBufferDone(t,e,r=1){if(r===5||!t.bufferedAmount){e();return}setTimeout(()=>{this.waitForBufferDone(t,e,r+1)},150*r)}waitForSocketClosed(t,e,r=1){if(r===5||t.readyState===Wn.closed){e();return}setTimeout(()=>{this.waitForSocketClosed(t,e,r+1)},150*r)}onConnClose(t){this.conn&&(this.conn.onclose=()=>{}),this.hasLogger()&&this.log("transport","close",t),this.triggerChanError(t),this.clearHeartbeats(),this.closeWasClean||this.reconnectTimer.scheduleTimeout(),this.triggerStateCallbacks("close",t)}onConnError(t){this.hasLogger()&&this.log("transport","error",t);let e=this.transport,r=this.establishedConnections;this.triggerStateCallbacks("error",t,e,r),(e===this.transport||r>0)&&this.triggerChanError(t)}triggerChanError(t){this.channels.forEach(e=>{e.isErrored()||e.isLeaving()||e.isClosed()||e.trigger($i.error,t)})}connectionState(){switch(this.conn&&this.conn.readyState){case Wn.connecting:return"connecting";case Wn.open:return"open";case Wn.closing:return"closing";default:return"closed"}}isConnected(){return this.connectionState()==="open"}remove(t){this.off(t.stateChangeRefs),this.channels=this.channels.filter(e=>e!==t)}off(t){for(let e in this.stateChangeCallbacks)this.stateChangeCallbacks[e]=this.stateChangeCallbacks[e].filter(([r])=>t.indexOf(r)===-1)}channel(t,e={}){let r=new RR(t,e,this);return this.channels.push(r),r}push(t){if(this.hasLogger()){let{topic:e,event:r,payload:i,ref:n,join_ref:o}=t;this.log("push",`${e} ${r} (${o}, ${n})`,i)}this.isConnected()?this.encode(t,e=>this.conn.send(e)):this.sendBuffer.push(()=>this.encode(t,e=>this.conn.send(e)))}makeRef(){let t=this.ref+1;return t===this.ref?this.ref=0:this.ref=t,this.ref.toString()}sendHeartbeat(){if(!this.isConnected()){try{this.heartbeatCallback("disconnected")}catch(t){this.log("error","error in heartbeat callback",t)}return}if(this.pendingHeartbeatRef){this.heartbeatTimeout();return}this.pendingHeartbeatRef=this.makeRef(),this.heartbeatSentAt=Date.now(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(t){this.log("error","error in heartbeat callback",t)}this.heartbeatTimeoutTimer=setTimeout(()=>this.heartbeatTimeout(),this.heartbeatIntervalMs)}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(t=>t()),this.sendBuffer=[])}onConnMessage(t){this.decode(t.data,e=>{let{topic:r,event:i,payload:n,ref:o,join_ref:s}=e;if(o&&o===this.pendingHeartbeatRef){let a=this.heartbeatSentAt?Date.now()-this.heartbeatSentAt:void 0;this.clearHeartbeats();try{this.heartbeatCallback(n.status==="ok"?"ok":"error",a)}catch(c){this.log("error","error in heartbeat callback",c)}this.pendingHeartbeatRef=null,this.heartbeatSentAt=null,this.autoSendHeartbeat&&(this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}this.hasLogger()&&this.log("receive",`${n.status||""} ${r} ${i} ${o&&"("+o+")"||""}`.trim(),n);for(let a=0;a<this.channels.length;a++){let c=this.channels[a];c.isMember(r,i,n,s)&&c.trigger(i,n,o,s)}this.triggerStateCallbacks("message",e)})}triggerStateCallbacks(t,...e){try{this.stateChangeCallbacks[t].forEach(([r,i])=>{try{i(...e)}catch(n){this.log("error",`error in ${t} callback`,n)}})}catch(r){this.log("error",`error triggering ${t} callbacks`,r)}}leaveOpenTopic(t){let e=this.channels.find(r=>r.topic===t&&(r.isJoined()||r.isJoining()));e&&(this.hasLogger()&&this.log("transport",`leaving duplicate topic "${t}"`),e.leave())}}});var CR=C(Xw=>{"use strict";Object.defineProperty(Xw,"__esModule",{value:!0});var YV=Gw(),Jw=class t{constructor(e,r){let i=e2(r);this.presence=new YV.Presence(e.getChannel(),i),this.presence.onJoin((n,o,s)=>{let a=t.onJoinPayload(n,o,s);e.getChannel().trigger("presence",a)}),this.presence.onLeave((n,o,s)=>{let a=t.onLeavePayload(n,o,s);e.getChannel().trigger("presence",a)}),this.presence.onSync(()=>{e.getChannel().trigger("presence",{event:"sync"})})}get state(){return t.transformState(this.presence.state)}static transformState(e){return e=QV(e),Object.getOwnPropertyNames(e).reduce((r,i)=>{let n=e[i];return r[i]=nm(n),r},{})}static onJoinPayload(e,r,i){let n=zR(r),o=nm(i);return{event:"join",key:e,currentPresences:n,newPresences:o}}static onLeavePayload(e,r,i){let n=zR(r),o=nm(i);return{event:"leave",key:e,currentPresences:n,leftPresences:o}}};Xw.default=Jw;function nm(t){return t.metas.map(e=>{let r=Object.getOwnPropertyDescriptors(e),i=Object.defineProperties({},r);return i.presence_ref=i.phx_ref,delete i.phx_ref,delete i.phx_ref_prev,i})}function QV(t){return JSON.parse(JSON.stringify(t))}function e2(t){return t?.events&&{events:t.events}}function zR(t){return t?.metas?nm(t):[]}});var Qw=C(mu=>{"use strict";Object.defineProperty(mu,"__esModule",{value:!0});mu.REALTIME_PRESENCE_LISTEN_EVENTS=void 0;var t2=(qr(),Xr(Zr)),r2=t2.__importDefault(CR()),NR;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(NR||(mu.REALTIME_PRESENCE_LISTEN_EVENTS=NR={}));var Yw=class{get state(){return this.presenceAdapter.state}constructor(e,r){this.channel=e,this.presenceAdapter=new r2.default(this.channel.channelAdapter,r)}};mu.default=Yw});var DR=C(e$=>{"use strict";Object.defineProperty(e$,"__esModule",{value:!0});e$.normalizeChannelError=n2;function n2(t){if(t instanceof Error)return t;if(typeof t=="string")return new Error(t);if(t&&typeof t=="object"){let e=t;if(typeof e.code=="number"){let r=typeof e.reason=="string"&&e.reason?` (${e.reason})`:"";return new Error(`socket closed: ${e.code}${r}`,{cause:t})}return new Error("channel error: transport failure",{cause:t})}return new Error("channel error: connection lost")}});var LR=C(r$=>{"use strict";Object.defineProperty(r$,"__esModule",{value:!0});var Sa=du(),t$=class{constructor(e,r,i){let n=i2(i);this.channel=e.getSocket().channel(r,n),this.socket=e}get state(){return this.channel.state}set state(e){this.channel.state=e}get joinedOnce(){return this.channel.joinedOnce}get joinPush(){return this.channel.joinPush}get rejoinTimer(){return this.channel.rejoinTimer}on(e,r){return this.channel.on(e,r)}off(e,r){this.channel.off(e,r)}subscribe(e){return this.channel.join(e)}unsubscribe(e){return this.channel.leave(e)}teardown(){this.channel.teardown()}onClose(e){this.channel.onClose(e)}onError(e){return this.channel.onError(e)}push(e,r,i){let n;try{n=this.channel.push(e,r,i)}catch{throw new Error(`tried to push '${e}' to '${this.channel.topic}' before joining. Use channel.subscribe() before pushing events`)}if(this.channel.pushBuffer.length>Sa.MAX_PUSH_BUFFER_SIZE){let o=this.channel.pushBuffer.shift();o.cancelTimeout(),this.socket.log("channel",`discarded push due to buffer overflow: ${o.event}`,o.payload())}return n}updateJoinPayload(e){let r=this.channel.joinPush.payload();this.channel.joinPush.payload=()=>Object.assign(Object.assign({},r),e)}canPush(){return this.socket.isConnected()&&this.state===Sa.CHANNEL_STATES.joined}isJoined(){return this.state===Sa.CHANNEL_STATES.joined}isJoining(){return this.state===Sa.CHANNEL_STATES.joining}isClosed(){return this.state===Sa.CHANNEL_STATES.closed}isLeaving(){return this.state===Sa.CHANNEL_STATES.leaving}updateFilterBindings(e){this.channel.filterBindings=e}updatePayloadTransform(e){this.channel.onMessage=e}getChannel(){return this.channel}};r$.default=t$;function i2(t){return{config:Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},t.config)}}});var n$=C(xa=>{"use strict";Object.defineProperty(xa,"__esModule",{value:!0});xa.postgresChangesFilter=xa.RealtimePostgresFilterBuilder=void 0;var o2=/[,()"\\]/,s2=t=>o2.test(t)||t!==t.trim(),a2=t=>`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`,UR=t=>{let e=t===null?"null":String(t);return s2(e)?a2(e):e},c2=t=>t===null?"null":String(t),l2=(t,e)=>{if(t==="in"){let r=Array.isArray(e)?e:[e];if(r.length===0)throw new Error("Realtime `in` filter requires at least one value.");return`in.(${Array.from(new Set(r)).map(n=>UR(n)).join(",")})`}return t==="is"?`is.${c2(e)}`:`${t}.${UR(e)}`},im=class{constructor(){this.filters=[]}add(e,r,i,n=!1){let o=n?"not.":"";return this.filters.push(`${e}=${o}${l2(r,i)}`),this}eq(e,r){return this.add(e,"eq",r)}neq(e,r){return this.add(e,"neq",r)}gt(e,r){return this.add(e,"gt",r)}gte(e,r){return this.add(e,"gte",r)}lt(e,r){return this.add(e,"lt",r)}lte(e,r){return this.add(e,"lte",r)}in(e,r){return this.add(e,"in",r)}like(e,r){return this.add(e,"like",r)}ilike(e,r){return this.add(e,"ilike",r)}match(e,r){return this.add(e,"match",r)}imatch(e,r){return this.add(e,"imatch",r)}is(e,r){return this.add(e,"is",r)}isDistinct(e,r){return this.add(e,"isdistinct",r)}not(e,r,i){return this.add(e,r,i,!0)}build(){return this.filters.join(",")}toString(){return this.build()}};xa.RealtimePostgresFilterBuilder=im;var u2=()=>new im;xa.postgresChangesFilter=u2});var s$=C(vr=>{"use strict";Object.defineProperty(vr,"__esModule",{value:!0});vr.REALTIME_CHANNEL_STATES=vr.REALTIME_SUBSCRIBE_STATES=vr.REALTIME_LISTEN_TYPES=vr.REALTIME_POSTGRES_CHANGES_LISTEN_EVENT=vr.postgresChangesFilter=vr.RealtimePostgresFilterBuilder=void 0;var o$=(qr(),Xr(Zr)),ns=du(),d2=o$.__importDefault(Qw()),MR=o$.__importStar(tm()),f2=tm(),p2=DR(),h2=o$.__importDefault(LR()),m2=n$(),ZR=n$();Object.defineProperty(vr,"RealtimePostgresFilterBuilder",{enumerable:!0,get:function(){return ZR.RealtimePostgresFilterBuilder}});Object.defineProperty(vr,"postgresChangesFilter",{enumerable:!0,get:function(){return ZR.postgresChangesFilter}});var FR;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(FR||(vr.REALTIME_POSTGRES_CHANGES_LISTEN_EVENT=FR={}));var is;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(is||(vr.REALTIME_LISTEN_TYPES=is={}));var ki;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(ki||(vr.REALTIME_SUBSCRIBE_STATES=ki={}));vr.REALTIME_CHANNEL_STATES=ns.CHANNEL_STATES;var i$=class t{get state(){return this.channelAdapter.state}set state(e){this.channelAdapter.state=e}get joinedOnce(){return this.channelAdapter.joinedOnce}get timeout(){return this.socket.timeout}get joinPush(){return this.channelAdapter.joinPush}get rejoinTimer(){return this.channelAdapter.rejoinTimer}constructor(e,r={config:{}},i){var n,o;if(this.topic=e,this.params=r,this.socket=i,this.bindings={},this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},r.config),this.channelAdapter=new h2.default(this.socket.socketAdapter,e,this.params),this.presence=new d2.default(this),this._onClose(()=>{this.socket._remove(this)}),this._updateFilterTransform(),this.broadcastEndpointURL=(0,f2.httpEndpointURL)(this.socket.socketAdapter.endPointURL()),this.private=this.params.config.private||!1,!this.private&&(!((o=(n=this.params.config)===null||n===void 0?void 0:n.broadcast)===null||o===void 0)&&o.replay))throw new Error(`tried to use replay on public channel '${this.topic}'. It must be a private channel.`)}subscribe(e,r=this.timeout){var i,n,o,s;if(this.socket.isConnected()||this.socket.connect(),this.channelAdapter.isClosed()){let{config:{broadcast:a,presence:c,private:l,postgres_changes_options:u}}=this.params,d=(n=(i=this.bindings.postgres_changes)===null||i===void 0?void 0:i.map(g=>g.filter))!==null&&n!==void 0?n:[],p=!!this.bindings[is.PRESENCE]&&this.bindings[is.PRESENCE].length>0||((o=this.params.config.presence)===null||o===void 0?void 0:o.enabled)===!0,f={},h=Object.assign({broadcast:a,presence:Object.assign(Object.assign({},c),{enabled:p}),postgres_changes:d,private:l},u?{postgres_changes_options:u}:{});this.socket.accessTokenValue&&(f.access_token=this.socket.accessTokenValue),this._onError(g=>{e?.(ki.CHANNEL_ERROR,(0,p2.normalizeChannelError)(g))}),this._onClose(()=>e?.(ki.CLOSED)),this.updateJoinPayload(Object.assign({config:h},f)),this._updateFilterMessage();let m=u?.wait&&d.length>0?Math.max(r,((s=u.timeout)!==null&&s!==void 0?s:ns.DEFAULT_POSTGRES_CHANGES_WAIT_TIMEOUT)+ns.POSTGRES_CHANGES_WAIT_ERROR_GRACE):r;this.channelAdapter.subscribe(m).receive("ok",async({postgres_changes:g})=>{if(this.socket._isManualToken()||this.socket.setAuth(),g===void 0){e?.(ki.SUBSCRIBED);return}this._updatePostgresBindings(g,e)}).receive("error",g=>{this.state=ns.CHANNEL_STATES.errored;let y=Object.values(g).join(", ")||"error";e?.(ki.CHANNEL_ERROR,new Error(y,{cause:g}))}).receive("timeout",()=>{e?.(ki.TIMED_OUT)})}return this}_updatePostgresBindings(e,r){var i;let n=this.bindings.postgres_changes,o=(i=n?.length)!==null&&i!==void 0?i:0,s=[];for(let a=0;a<o;a++){let c=n[a],{filter:{event:l,schema:u,table:d,filter:p}}=c,f=e&&e[a];if(f&&f.event===l&&t.isFilterValueEqual(f.schema,u)&&t.isFilterValueEqual(f.table,d)&&t.isFilterValueEqual(f.filter,p))s.push(Object.assign(Object.assign({},c),{id:f.id}));else{this.unsubscribe(),this.state=ns.CHANNEL_STATES.errored,r?.(ki.CHANNEL_ERROR,new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=s,this.state!=ns.CHANNEL_STATES.errored&&r&&r(ki.SUBSCRIBED)}presenceState(){return this.presence.state}async track(e,r={}){return await this.send({type:"presence",event:"track",payload:e},r)}async untrack(e={}){return await this.send({type:"presence",event:"untrack"},e)}on(e,r,i){let n=this.channelAdapter.isJoined()||this.channelAdapter.isJoining(),o=e===is.PRESENCE||e===is.POSTGRES_CHANGES;if(n&&o)throw this.socket.log("channel",`cannot add \`${e}\` callbacks for ${this.topic} after \`subscribe()\`.`),new Error(`cannot add \`${e}\` callbacks for ${this.topic} after \`subscribe()\`.`);return this._on(e,r,i)}async httpSend(e,r,i={}){var n;if(r==null)return Promise.reject(new Error("Payload is required for httpSend()"));let o=r instanceof ArrayBuffer||ArrayBuffer.isView(r),s={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":o?"application/octet-stream":"application/json"};this.socket.accessTokenValue&&(s.Authorization=`Bearer ${this.socket.accessTokenValue}`);let a=new URL(this.broadcastEndpointURL);a.pathname+=`/${encodeURIComponent(this.subTopic)}/events/${encodeURIComponent(e)}`,this.private&&a.searchParams.set("private","true");let c={method:"POST",headers:s,body:o?r:JSON.stringify(r)},l=await this._fetchWithTimeout(a.toString(),c,(n=i.timeout)!==null&&n!==void 0?n:this.timeout);if(l.status===202)return{success:!0};if(l.status===404)return Promise.reject(new Error("httpSend() requires Realtime server v2.97.0 or newer; the endpoint returned 404. Update your Supabase CLI to a recent version, or upgrade the Realtime server in your self-hosted setup. See https://github.com/supabase/supabase-js/blob/master/packages/core/realtime-js/migrations/httpsend-server-version.md"));let u=l.statusText;try{let d=await l.json();u=d.error||d.message||u}catch{}return Promise.reject(new Error(u))}async send(e,r={}){var i,n;if(!this.channelAdapter.canPush()&&e.type==="broadcast"){let o="Realtime send() is automatically falling back to REST API. This behavior will be deprecated in the future. Please use httpSend() explicitly for REST delivery.";this.socket.hasLogger()?this.socket.log("channel",o):console.warn(o);let{event:s,payload:a}=e,c={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(c.Authorization=`Bearer ${this.socket.accessTokenValue}`);let l={method:"POST",headers:c,body:JSON.stringify({messages:[{topic:this.subTopic,event:s,payload:a,private:this.private}]})};try{let u=await this._fetchWithTimeout(this.broadcastEndpointURL,l,(i=r.timeout)!==null&&i!==void 0?i:this.timeout);return await((n=u.body)===null||n===void 0?void 0:n.cancel()),u.ok?"ok":"error"}catch(u){return u instanceof Error&&u.name==="AbortError"?"timed out":"error"}}else return new Promise(o=>{var s,a,c;let l=this.channelAdapter.push(e.type,e,r.timeout||this.timeout);e.type==="broadcast"&&!(!((c=(a=(s=this.params)===null||s===void 0?void 0:s.config)===null||a===void 0?void 0:a.broadcast)===null||c===void 0)&&c.ack)&&o("ok"),l.receive("ok",()=>o("ok")),l.receive("error",()=>o("error")),l.receive("timeout",()=>o("timed out"))})}updateJoinPayload(e){this.channelAdapter.updateJoinPayload(e)}async unsubscribe(e=this.timeout){return new Promise(r=>{this.channelAdapter.unsubscribe(e).receive("ok",()=>r("ok")).receive("timeout",()=>r("timed out")).receive("error",()=>r("error"))})}teardown(){this.channelAdapter.teardown()}async _fetchWithTimeout(e,r,i){let n=new AbortController,o=setTimeout(()=>n.abort(),i),s=await this.socket.fetch(e,Object.assign(Object.assign({},r),{signal:n.signal}));return clearTimeout(o),s}_on(e,r,i){var n;let o=e.toLocaleLowerCase(),s=r?.filter;if((s instanceof m2.RealtimePostgresFilterBuilder||typeof s=="object"&&s!==null&&typeof s.build=="function")&&(r=Object.assign(Object.assign({},r),{filter:s.build()})),o===is.POSTGRES_CHANGES&&((n=this.bindings[o])===null||n===void 0?void 0:n.find(u=>t.isSamePostgresFilter(u.filter,r))))return this.socket.log("error",`duplicate \`postgres_changes\` binding for ${this.topic} ignored`,r),this;let a=this.channelAdapter.on(e,i),c={type:o,filter:r,callback:i,ref:a};return this.bindings[o]?this.bindings[o].push(c):this.bindings[o]=[c],this._updateFilterMessage(),this}_onClose(e){this.channelAdapter.onClose(e)}_onError(e){this.channelAdapter.onError(e)}_updateFilterMessage(){this.channelAdapter.updateFilterBindings((e,r,i)=>{var n,o,s,a,c,l,u;let d=e.event.toLocaleLowerCase();if(this._notThisChannelEvent(d,i))return!1;let p=(n=this.bindings[d])===null||n===void 0?void 0:n.find(f=>f.ref===e.ref);if(!p)return!0;if(["broadcast","presence","postgres_changes"].includes(d))if("id"in p){let f=p.id,h=(o=p.filter)===null||o===void 0?void 0:o.event;return f&&((s=r.ids)===null||s===void 0?void 0:s.includes(f))&&(h==="*"||h?.toLocaleLowerCase()===((a=r.data)===null||a===void 0?void 0:a.type.toLocaleLowerCase()))}else{let f=(l=(c=p?.filter)===null||c===void 0?void 0:c.event)===null||l===void 0?void 0:l.toLocaleLowerCase();return f==="*"||f===((u=r?.event)===null||u===void 0?void 0:u.toLocaleLowerCase())}else return p.type.toLocaleLowerCase()===d})}_notThisChannelEvent(e,r){let{close:i,error:n,leave:o,join:s}=ns.CHANNEL_EVENTS;return r&&[i,n,o,s].includes(e)&&r!==this.joinPush.ref}_updateFilterTransform(){this.channelAdapter.updatePayloadTransform((e,r,i)=>{if(typeof r=="object"&&"ids"in r){let n=r.data,{schema:o,table:s,commit_timestamp:a,type:c,errors:l}=n;return Object.assign(Object.assign({},{schema:o,table:s,commit_timestamp:a,eventType:c,new:{},old:{},errors:l}),this._getPayloadRecords(n))}return r})}copyBindings(e){if(this.joinedOnce)throw new Error("cannot copy bindings into joined channel");for(let r in e.bindings)for(let i of e.bindings[r])this._on(i.type,i.filter,i.callback)}static isFilterValueEqual(e,r){return(e??void 0)===(r??void 0)}static isSamePostgresFilter(e,r){var i,n,o,s;let a=(n=(i=e?.select)===null||i===void 0?void 0:i.join())!==null&&n!==void 0?n:void 0,c=(s=(o=r?.select)===null||o===void 0?void 0:o.join())!==null&&s!==void 0?s:void 0;return e?.event===r?.event&&t.isFilterValueEqual(e?.schema,r?.schema)&&t.isFilterValueEqual(e?.table,r?.table)&&t.isFilterValueEqual(e?.filter,r?.filter)&&a===c}_getPayloadRecords(e){let r={new:{},old:{}};return(e.type==="INSERT"||e.type==="UPDATE")&&(r.new=MR.convertChangeData(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(r.old=MR.convertChangeData(e.columns,e.old_record)),r}};vr.default=i$});var VR=C(c$=>{"use strict";Object.defineProperty(c$,"__esModule",{value:!0});var g2=Gw(),qR=du(),a$=class{constructor(e,r){this.socket=new g2.Socket(e,r)}get timeout(){return this.socket.timeout}get endPoint(){return this.socket.endPoint}get transport(){return this.socket.transport}get heartbeatIntervalMs(){return this.socket.heartbeatIntervalMs}get heartbeatCallback(){return this.socket.heartbeatCallback}set heartbeatCallback(e){this.socket.heartbeatCallback=e}get heartbeatTimer(){return this.socket.heartbeatTimer}get pendingHeartbeatRef(){return this.socket.pendingHeartbeatRef}get reconnectTimer(){return this.socket.reconnectTimer}get vsn(){return this.socket.vsn}get encode(){return this.socket.encode}get decode(){return this.socket.decode}get reconnectAfterMs(){return this.socket.reconnectAfterMs}get sendBuffer(){return this.socket.sendBuffer}get stateChangeCallbacks(){return this.socket.stateChangeCallbacks}connect(){this.socket.connect()}disconnect(e,r,i,n=1e4){return new Promise(o=>{setTimeout(()=>o("timeout"),n),this.socket.disconnect(()=>{e(),o("ok")},r,i)})}push(e){this.socket.push(e)}log(e,r,i){this.socket.log(e,r,i)}hasLogger(){return this.socket.hasLogger()}makeRef(){return this.socket.makeRef()}onOpen(e){this.socket.onOpen(e)}onClose(e){this.socket.onClose(e)}onError(e){this.socket.onError(e)}onMessage(e){this.socket.onMessage(e)}isConnected(){return this.socket.isConnected()}isConnecting(){return this.socket.connectionState()==qR.CONNECTION_STATE.connecting}isDisconnecting(){return this.socket.connectionState()==qR.CONNECTION_STATE.closing}connectionState(){return this.socket.connectionState()}endPointURL(){return this.socket.endPointURL()}sendHeartbeat(){this.socket.sendHeartbeat()}getSocket(){return this.socket}};c$.default=a$});var HR=C(u$=>{"use strict";Object.defineProperty(u$,"__esModule",{value:!0});var om=(qr(),Xr(Zr)),y2=om.__importDefault(Fw()),os=du(),v2=om.__importDefault(PR()),_2=tm(),b2=om.__importDefault(s$()),w2=om.__importDefault(VR()),BR={HEARTBEAT_INTERVAL:25e3,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},$2=[1e3,2e3,5e3,1e4],k2=1e4;function S2(){let t=new Map;return{get length(){return t.size},clear(){t.clear()},getItem(e){return t.has(e)?t.get(e):null},key(e){var r;return(r=Array.from(t.keys())[e])!==null&&r!==void 0?r:null},removeItem(e){t.delete(e)},setItem(e,r){t.set(e,String(r))}}}function x2(){try{if(typeof globalThis<"u"&&globalThis.sessionStorage)return globalThis.sessionStorage}catch{}return S2()}var I2=`
94
94
  addEventListener("message", (e) => {
95
95
  if (e.data.event === "start") {
@@ -116,23 +116,23 @@ ${y}`}});var kj=C(xi=>{"use strict";Object.defineProperty(xi,"__esModule",{value
116
116
  `)}function Eu(t,e){Kj(Iu,{recursive:!0}),Jj(Na,JSON.stringify({refresh_token:t,user:e},null,2)),l9(Na,384)}function Xj(){u9(Na,{force:!0})}function Yj(t,e){return Wj??=(async()=>{let r=await fetch(`${e.replace(/\/$/,"")}/ticket`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ticket:t})}),i=await r.json().catch(()=>({}));if(!r.ok||!i.access_token||!i.service||!i.project)throw new Error(i.error??"this command's ticket couldn't be used \u2014 call sync again for a fresh command");return process.env.CODESIGNFLO_SERVICE_URL=i.service.url,process.env.CODESIGNFLO_SERVICE_ANON=i.service.anon,process.env.CODESIGNFLO_SERVICE_WEB=i.service.web,{token:i.access_token,project:i.project}})(),Wj}async function Qj(){let{CODESIGNFLO_TICKET:t,CODESIGNFLO_MCP:e}=process.env;return t&&e?(await Yj(t,e)).project:null}async function an(){let{CODESIGNFLO_TICKET:t,CODESIGNFLO_MCP:e}=process.env,r=t&&e?(await Yj(t,e)).token:process.env.CODESIGNFLO_TOKEN;if(r){let a=Da(),c=Om(a.url,a.anon,{auth:{persistSession:!1,autoRefreshToken:!1},global:{headers:{Authorization:`Bearer ${r}`}}}),{data:l,error:u}=await c.auth.getUser(r);if(u||!l.user)throw new Error("the sign-in from the CoDesignFlo MCP expired \u2014 call sync again for a fresh command");return{client:c,user:{id:l.user.id,email:l.user.email??null}}}if(!X$(Na))throw new Error("not signed in \u2014 run: codesignflo login");let i=JSON.parse(Gj(Na,"utf8")),n=Q$(),{data:o,error:s}=await n.auth.refreshSession({refresh_token:i.refresh_token});if(s||!o.session||!o.user)throw new Error("your sign-in expired \u2014 run: codesignflo login");return Eu(o.session.refresh_token,{id:o.user.id,email:o.user.email??null}),await n.rpc("accept_invitations"),{client:n,user:{id:o.user.id,email:o.user.email??null}}}var Iu,Na,Q$,Am,Wj,La=w(()=>{"use strict";Hj();Iu=Pm(d9(),".codesignflo"),Na=Pm(Iu,"session.json");Q$=(t=Da())=>Om(t.url,t.anon,{auth:{persistSession:!1,autoRefreshToken:!1}});Am=()=>X$(Na),Wj=null});import{existsSync as Ua,mkdirSync as tk,readdirSync as ez,readFileSync as jm,renameSync as f9,writeFileSync as rk}from"node:fs";import{join as ds,resolve as tz}from"node:path";async function nz(t){let e=In(t);if(!e?.cloud)return;let{client:r}=await an(),i=await Qj();if(i&&i!==e.projectId)throw new Error(`this command was made for project ${i}, but this app is ${e.projectId} \u2014 run it in that app's folder`);let n=[];for(let o=0;;o+=1e3){let{data:s,error:a}=await r.from("events").select("id, at, by, component, kind, body").eq("project_id",e.projectId).order("seq").range(o,o+999);if(a)throw new Error(`couldn't read the project's history: ${a.message}`);if(n.push(...s.map(p9).filter(c=>c!==null)),(s??[]).length<1e3)break}Mt={projectId:e.projectId,events:n,pending:[],client:r}}async function iz(){if(!Mt?.pending.length)return;let t=Mt.pending.map(r=>rz(Mt.projectId,r)),{error:e}=await Mt.client.from("events").upsert(t,{onConflict:"project_id,id",ignoreDuplicates:!0});if(e)throw new Error(`couldn't save to the project's history: ${e.message}`);Mt.pending=[]}async function oz(t,e,r){for(let i=0;i<r.length;i+=500){let{error:n}=await t.from("events").upsert(r.slice(i,i+500).map(o=>rz(e,o)),{onConflict:"project_id,id",ignoreDuplicates:!0});if(n)throw new Error(`couldn't upload the history: ${n.message}`)}}function In(t){let e=sz(t);return Ua(e)?JSON.parse(jm(e,"utf8")):null}function nk(t,e){tk(gt(e),{recursive:!0}),rk(sz(e),`${JSON.stringify(t,null,2)}
117
117
  `)}function Yt(t){let e=In(t);if(!e)throw new Error("no .codesignflo/config.json here \u2014 run `codesignflo init` first (in your app's folder)");return e}function Ct(t){if(Mt)return Mt.events;let e=az(t);return Ua(e)?jm(e,"utf8").split(`
118
118
  `).filter(Boolean).map(r=>Vh(JSON.parse(r))).filter(r=>r!==null):[]}function En(t,e){let r=new Set(Ct(e).map(n=>n.id)),i=tu(t.filter(n=>!r.has(n.id)));return Mt?(Mt.events.push(...i),Mt.pending.push(...i),i):(i.length&&(tk(gt(e),{recursive:!0}),rk(az(e),i.map(n=>`${JSON.stringify(n)}
119
- `).join(""),{flag:"a"})),i)}async function Tu(t,e){let r=`${t}@${e}`;if(Rm.has(r))return Rm.get(r);let i=null;if(Mt){let{data:n,error:o}=await Mt.client.from("generations").select("snapshot, canon_version").eq("project_id",Mt.projectId).eq("component",t).eq("gen",e).maybeSingle();if(o)throw new Error(`couldn't read a version of ${t}: ${o.message}`);i=n&&(n.canon_version??5)===5?n.snapshot:null}return!i&&Ua(ek(t,e))&&(i=JSON.parse(jm(ek(t,e),"utf8"))),Rm.set(r,i),i}async function cz(t,e,r){if(Rm.set(`${t}@${e}`,r),Mt){let{error:i}=await Mt.client.from("generations").upsert({project_id:Mt.projectId,component:t,gen:e,snapshot:r,canon_version:5},{onConflict:"project_id,component,gen",ignoreDuplicates:!0});if(i)throw new Error(`couldn't save a version of ${t}: ${i.message}`);return}tk(ds(gt(),"snapshots",t),{recursive:!0}),rk(ek(t,e),Bn(r))}async function lz(t,e,r){let i=ds(gt(r),"snapshots");if(!Ua(i))return 0;let n=0;for(let o of ez(i))for(let s of ez(ds(i,o)).filter(a=>a.endsWith(".json"))){let a=JSON.parse(jm(ds(i,o,s),"utf8")),{error:c}=await t.from("generations").upsert({project_id:e,component:o,gen:s.slice(0,-5),snapshot:a,canon_version:5},{onConflict:"project_id,component,gen",ignoreDuplicates:!0});if(c)throw new Error(`couldn't upload the versions of ${o}: ${c.message}`);n++}return n}var Mt,rz,p9,fs,gt,sz,az,ek,Rm,sr=w(()=>{"use strict";Pr();La();Mt=null,rz=(t,e)=>{let{id:r,at:i,by:n,component:o,kind:s,...a}=e;return{project_id:t,id:r,at:i,by:n,component:o,kind:s,body:a}},p9=t=>Vh({...t.body,id:t.id,at:t.at,by:t.by,component:t.component,kind:t.kind});fs=()=>Mt?{client:Mt.client,projectId:Mt.projectId}:null;gt=(t=process.cwd())=>{let e=tz(t,".codesignflo"),r=tz(t,".codesignloop");return!Ua(e)&&Ua(r)&&f9(r,e),e},sz=t=>ds(gt(t),"config.json"),az=t=>ds(gt(t),"events.jsonl");ek=(t,e,r)=>ds(gt(r),"snapshots",t,`${e}.json`),Rm=new Map});var Le,xC,J,Ti,Nu=w(()=>{(function(t){t.assertEqual=n=>{};function e(n){}t.assertIs=e;function r(n){throw new Error}t.assertNever=r,t.arrayToEnum=n=>{let o={};for(let s of n)o[s]=s;return o},t.getValidEnumValues=n=>{let o=t.objectKeys(n).filter(a=>typeof n[n[a]]!="number"),s={};for(let a of o)s[a]=n[a];return t.objectValues(s)},t.objectValues=n=>t.objectKeys(n).map(function(o){return n[o]}),t.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{let o=[];for(let s in n)Object.prototype.hasOwnProperty.call(n,s)&&o.push(s);return o},t.find=(n,o)=>{for(let s of n)if(o(s))return s},t.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function i(n,o=" | "){return n.map(s=>typeof s=="string"?`'${s}'`:s).join(o)}t.joinValues=i,t.jsonStringifyReplacer=(n,o)=>typeof o=="bigint"?o.toString():o})(Le||(Le={}));(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(xC||(xC={}));J=Le.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ti=t=>{switch(typeof t){case"undefined":return J.undefined;case"string":return J.string;case"number":return Number.isNaN(t)?J.nan:J.number;case"boolean":return J.boolean;case"function":return J.function;case"bigint":return J.bigint;case"symbol":return J.symbol;case"object":return Array.isArray(t)?J.array:t===null?J.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?J.promise:typeof Map<"u"&&t instanceof Map?J.map:typeof Set<"u"&&t instanceof Set?J.set:typeof Date<"u"&&t instanceof Date?J.date:J.object;default:return J.unknown}}});var F,Hr,Vm=w(()=>{Nu();F=Le.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Hr=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=i=>{this.issues=[...this.issues,i]},this.addIssues=(i=[])=>{this.issues=[...this.issues,...i]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(o){return o.message},i={_errors:[]},n=o=>{for(let s of o.issues)if(s.code==="invalid_union")s.unionErrors.map(n);else if(s.code==="invalid_return_type")n(s.returnTypeError);else if(s.code==="invalid_arguments")n(s.argumentsError);else if(s.path.length===0)i._errors.push(r(s));else{let a=i,c=0;for(;c<s.path.length;){let l=s.path[c],u=c===s.path.length-1;if(l==="_errors"){u&&a._errors.push(r(s)),c++;continue}Object.prototype.hasOwnProperty.call(a,l)||(l==="__proto__"?Object.defineProperty(a,l,{value:{_errors:[]},writable:!0,enumerable:!0,configurable:!0}):a[l]={_errors:[]}),a=a[l],u&&a._errors.push(r(s)),c++}}};return n(this),i}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Le.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r=Object.create(null),i=[];for(let n of this.issues)if(n.path.length>0){let o=n.path[0];r[o]=r[o]||[],r[o].push(e(n))}else i.push(e(n));return{formErrors:i,fieldErrors:r}}get formErrors(){return this.flatten()}};Hr.create=t=>new Hr(t)});var DW,eo,Ek=w(()=>{Vm();Nu();DW=(t,e)=>{let r;switch(t.code){case F.invalid_type:t.received===J.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case F.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,Le.jsonStringifyReplacer)}`;break;case F.unrecognized_keys:r=`Unrecognized key(s) in object: ${Le.joinValues(t.keys,", ")}`;break;case F.invalid_union:r="Invalid input";break;case F.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Le.joinValues(t.options)}`;break;case F.invalid_enum_value:r=`Invalid enum value. Expected ${Le.joinValues(t.options)}, received '${t.received}'`;break;case F.invalid_arguments:r="Invalid function arguments";break;case F.invalid_return_type:r="Invalid function return type";break;case F.invalid_date:r="Invalid date";break;case F.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:Le.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case F.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case F.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case F.custom:r="Invalid input";break;case F.invalid_intersection_types:r="Intersection results could not be merged";break;case F.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case F.not_finite:r="Number must be finite";break;default:r=e.defaultError,Le.assertNever(t)}return{message:r}},eo=DW});function Du(){return LW}var LW,Bm=w(()=>{Ek();LW=eo});function H(t,e){let r=Du(),i=Hm({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===eo?void 0:eo].filter(n=>!!n)});t.common.issues.push(i)}var Hm,ar,me,Za,br,Tk,Ok,ps,Lu,Pk=w(()=>{Bm();Ek();Hm=t=>{let{data:e,path:r,errorMaps:i,issueData:n}=t,o=[...r,...n.path||[]],s={...n,path:o};if(n.message!==void 0)return{...n,path:o,message:n.message};let a="",c=i.filter(l=>!!l).slice().reverse();for(let l of c)a=l(s,{data:e,defaultError:a}).message;return{...n,path:o,message:a}};ar=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let i=[];for(let n of r){if(n.status==="aborted")return me;n.status==="dirty"&&e.dirty(),i.push(n.value)}return{status:e.value,value:i}}static async mergeObjectAsync(e,r){let i=[];for(let n of r){let o=await n.key,s=await n.value;i.push({key:o,value:s})}return t.mergeObjectSync(e,i)}static mergeObjectSync(e,r){let i={};for(let n of r){let{key:o,value:s}=n;if(o.status==="aborted"||s.status==="aborted")return me;o.status==="dirty"&&e.dirty(),s.status==="dirty"&&e.dirty(),o.value!=="__proto__"&&(typeof s.value<"u"||n.alwaysSet)&&(i[o.value]=s.value)}return{status:e.value,value:i}}},me=Object.freeze({status:"aborted"}),Za=t=>({status:"dirty",value:t}),br=t=>({status:"valid",value:t}),Tk=t=>t.status==="aborted",Ok=t=>t.status==="dirty",ps=t=>t.status==="valid",Lu=t=>typeof Promise<"u"&&t instanceof Promise});var IC=w(()=>{});var ne,EC=w(()=>{(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(ne||(ne={}))});function ke(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:i,description:n}=t;if(e&&(r||i))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(s,a)=>{let{message:c}=t;return s.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??i??a.defaultError}:s.code!=="invalid_type"?{message:a.defaultError}:{message:c??r??a.defaultError}},description:n}}function PC(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function tK(t){return new RegExp(`^${PC(t)}$`)}function rK(t){let e=`${OC}T${PC(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function nK(t,e){return!!((e==="v4"||!e)&&KW.test(t)||(e==="v6"||!e)&&JW.test(t))}function iK(t,e){if(!VW.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let i=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),n=JSON.parse(atob(i));return!(typeof n!="object"||n===null||"typ"in n&&n?.typ!=="JWT"||!n.alg||e&&n.alg!==e)}catch{return!1}}function oK(t,e){return!!((e==="v4"||!e)&&GW.test(t)||(e==="v6"||!e)&&XW.test(t))}function sK(t,e){let r=(t.toString().split(".")[1]||"").length,i=(e.toString().split(".")[1]||"").length,n=r>i?r:i,o=Number.parseInt(t.toFixed(n).replace(".","")),s=Number.parseInt(e.toFixed(n).replace(".",""));return o%s/10**n}function qa(t){if(t instanceof Wr){let e={};for(let r in t.shape){let i=t.shape[r];e[r]=On.create(qa(i))}return new Wr({...t._def,shape:()=>e})}else return t instanceof ro?new ro({...t._def,type:qa(t.element)}):t instanceof On?On.create(qa(t.unwrap())):t instanceof Ai?Ai.create(qa(t.unwrap())):t instanceof Pi?Pi.create(t.items.map(e=>qa(e))):t}function jk(t,e){let r=Ti(t),i=Ti(e);if(t===e)return{valid:!0,data:t};if(r===J.object&&i===J.object){let n=Le.objectKeys(e),o=Le.objectKeys(t).filter(a=>n.indexOf(a)!==-1),s={...t,...e};Object.prototype.hasOwnProperty.call(s,"__proto__")&&delete s.__proto__;for(let a of o){if(a==="__proto__")continue;let c=jk(t[a],e[a]);if(!c.valid)return{valid:!1};s[a]=c.data}return{valid:!0,data:s}}else if(r===J.array&&i===J.array){if(t.length!==e.length)return{valid:!1};let n=[];for(let o=0;o<t.length;o++){let s=t[o],a=e[o],c=jk(s,a);if(!c.valid)return{valid:!1};n.push(c.data)}return{valid:!0,data:n}}else return r===J.date&&i===J.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}function AC(t,e){return new Xa({values:t,typeName:Z.ZodEnum,...ke(e)})}var cn,TC,Oe,UW,MW,FW,ZW,qW,VW,BW,HW,WW,Ak,KW,GW,JW,XW,YW,QW,OC,eK,Va,Uu,Mu,Fu,Zu,qu,Ba,Ha,Vu,to,Qn,Bu,ro,Wr,Wa,Oi,Rk,Ka,Pi,zk,Hu,Wu,Ck,Ga,Ja,Xa,Ya,hs,Pn,On,Ai,Qa,ec,Ku,Dae,Wm,Km,tc,Lae,Z,Uae,Mae,Fae,Zae,qae,Vae,Bae,Hae,Wae,Kae,Gae,Jae,Xae,Yae,RC,Qae,ece,tce,rce,nce,ice,oce,sce,ace,cce,lce,uce,dce,fce,pce,hce,mce,gce,yce,jC=w(()=>{Vm();Bm();EC();Pk();Nu();cn=class{constructor(e,r,i,n){this._cachedPath=[],this.parent=e,this.data=r,this._path=i,this._key=n}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},TC=(t,e)=>{if(ps(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new Hr(t.common.issues);return this._error=r,this._error}}};Oe=class{get description(){return this._def.description}_getType(e){return Ti(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Ti(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ar,ctx:{common:e.parent.common,data:e.data,parsedType:Ti(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(Lu(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let i=this.safeParse(e,r);if(i.success)return i.data;throw i.error}safeParse(e,r){let i={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ti(e)},n=this._parseSync({data:e,path:i.path,parent:i});return TC(i,n)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ti(e)};if(!this["~standard"].async)try{let i=this._parseSync({data:e,path:[],parent:r});return ps(i)?{value:i.value}:{issues:r.common.issues}}catch(i){i?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(i=>ps(i)?{value:i.value}:{issues:r.common.issues})}async parseAsync(e,r){let i=await this.safeParseAsync(e,r);if(i.success)return i.data;throw i.error}async safeParseAsync(e,r){let i={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ti(e)},n=this._parse({data:e,path:i.path,parent:i}),o=await(Lu(n)?n:Promise.resolve(n));return TC(i,o)}refine(e,r){let i=n=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(n):r;return this._refinement((n,o)=>{let s=e(n),a=()=>o.addIssue({code:F.custom,...i(n)});return typeof Promise<"u"&&s instanceof Promise?s.then(c=>c?!0:(a(),!1)):s?!0:(a(),!1)})}refinement(e,r){return this._refinement((i,n)=>e(i)?!0:(n.addIssue(typeof r=="function"?r(i,n):r),!1))}_refinement(e){return new Pn({schema:this,typeName:Z.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return On.create(this,this._def)}nullable(){return Ai.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ro.create(this)}promise(){return hs.create(this,this._def)}or(e){return Wa.create([this,e],this._def)}and(e){return Ka.create(this,e,this._def)}transform(e){return new Pn({...ke(this._def),schema:this,typeName:Z.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new Qa({...ke(this._def),innerType:this,defaultValue:r,typeName:Z.ZodDefault})}brand(){return new Wm({typeName:Z.ZodBranded,type:this,...ke(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new ec({...ke(this._def),innerType:this,catchValue:r,typeName:Z.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Km.create(this,e)}readonly(){return tc.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},UW=/^c[^\s-]{8,}$/i,MW=/^[0-9a-z]+$/,FW=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ZW=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,qW=/^[a-z0-9_-]{21}$/i,VW=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,BW=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,HW=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,WW="^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$",KW=/^(?:(?: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])$/,GW=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,JW=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,XW=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,YW=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,QW=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,OC="((\\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])))",eK=new RegExp(`^${OC}$`);Va=class t extends Oe{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==J.string){let o=this._getOrReturnCtx(e);return H(o,{code:F.invalid_type,expected:J.string,received:o.parsedType}),me}let i=new ar,n;for(let o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(n=this._getOrReturnCtx(e,n),H(n,{code:F.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),i.dirty());else if(o.kind==="max")e.data.length>o.value&&(n=this._getOrReturnCtx(e,n),H(n,{code:F.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),i.dirty());else if(o.kind==="length"){let s=e.data.length>o.value,a=e.data.length<o.value;(s||a)&&(n=this._getOrReturnCtx(e,n),s?H(n,{code:F.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):a&&H(n,{code:F.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),i.dirty())}else if(o.kind==="email")HW.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"email",code:F.invalid_string,message:o.message}),i.dirty());else if(o.kind==="emoji")Ak||(Ak=new RegExp(WW,"u")),Ak.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"emoji",code:F.invalid_string,message:o.message}),i.dirty());else if(o.kind==="uuid")ZW.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"uuid",code:F.invalid_string,message:o.message}),i.dirty());else if(o.kind==="nanoid")qW.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"nanoid",code:F.invalid_string,message:o.message}),i.dirty());else if(o.kind==="cuid")UW.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"cuid",code:F.invalid_string,message:o.message}),i.dirty());else if(o.kind==="cuid2")MW.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"cuid2",code:F.invalid_string,message:o.message}),i.dirty());else if(o.kind==="ulid")FW.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"ulid",code:F.invalid_string,message:o.message}),i.dirty());else if(o.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),H(n,{validation:"url",code:F.invalid_string,message:o.message}),i.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"regex",code:F.invalid_string,message:o.message}),i.dirty())):o.kind==="trim"?e.data=e.data.trim():o.kind==="includes"?e.data.includes(o.value,o.position)||(n=this._getOrReturnCtx(e,n),H(n,{code:F.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),i.dirty()):o.kind==="toLowerCase"?e.data=e.data.toLowerCase():o.kind==="toUpperCase"?e.data=e.data.toUpperCase():o.kind==="startsWith"?e.data.startsWith(o.value)||(n=this._getOrReturnCtx(e,n),H(n,{code:F.invalid_string,validation:{startsWith:o.value},message:o.message}),i.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(n=this._getOrReturnCtx(e,n),H(n,{code:F.invalid_string,validation:{endsWith:o.value},message:o.message}),i.dirty()):o.kind==="datetime"?rK(o).test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:F.invalid_string,validation:"datetime",message:o.message}),i.dirty()):o.kind==="date"?eK.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:F.invalid_string,validation:"date",message:o.message}),i.dirty()):o.kind==="time"?tK(o).test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:F.invalid_string,validation:"time",message:o.message}),i.dirty()):o.kind==="duration"?BW.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"duration",code:F.invalid_string,message:o.message}),i.dirty()):o.kind==="ip"?nK(e.data,o.version)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"ip",code:F.invalid_string,message:o.message}),i.dirty()):o.kind==="jwt"?iK(e.data,o.alg)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"jwt",code:F.invalid_string,message:o.message}),i.dirty()):o.kind==="cidr"?oK(e.data,o.version)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"cidr",code:F.invalid_string,message:o.message}),i.dirty()):o.kind==="base64"?YW.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"base64",code:F.invalid_string,message:o.message}),i.dirty()):o.kind==="base64url"?QW.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"base64url",code:F.invalid_string,message:o.message}),i.dirty()):Le.assertNever(o);return{status:i.value,value:e.data}}_regex(e,r,i){return this.refinement(n=>e.test(n),{validation:r,code:F.invalid_string,...ne.errToObj(i)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...ne.errToObj(e)})}url(e){return this._addCheck({kind:"url",...ne.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...ne.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...ne.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...ne.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...ne.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...ne.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...ne.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...ne.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...ne.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...ne.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...ne.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...ne.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...ne.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...ne.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...ne.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...ne.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...ne.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...ne.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...ne.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...ne.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...ne.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...ne.errToObj(r)})}nonempty(e){return this.min(1,ne.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};Va.create=t=>new Va({checks:[],typeName:Z.ZodString,coerce:t?.coerce??!1,...ke(t)});Uu=class t extends Oe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==J.number){let o=this._getOrReturnCtx(e);return H(o,{code:F.invalid_type,expected:J.number,received:o.parsedType}),me}let i,n=new ar;for(let o of this._def.checks)o.kind==="int"?Le.isInteger(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{code:F.invalid_type,expected:"integer",received:"float",message:o.message}),n.dirty()):o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(i=this._getOrReturnCtx(e,i),H(i,{code:F.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),n.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(i=this._getOrReturnCtx(e,i),H(i,{code:F.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),n.dirty()):o.kind==="multipleOf"?sK(e.data,o.value)!==0&&(i=this._getOrReturnCtx(e,i),H(i,{code:F.not_multiple_of,multipleOf:o.value,message:o.message}),n.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{code:F.not_finite,message:o.message}),n.dirty()):Le.assertNever(o);return{status:n.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,ne.toString(r))}gt(e,r){return this.setLimit("min",e,!1,ne.toString(r))}lte(e,r){return this.setLimit("max",e,!0,ne.toString(r))}lt(e,r){return this.setLimit("max",e,!1,ne.toString(r))}setLimit(e,r,i,n){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:i,message:ne.toString(n)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:ne.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ne.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ne.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ne.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ne.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:ne.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:ne.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ne.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ne.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Le.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let i of this._def.checks){if(i.kind==="finite"||i.kind==="int"||i.kind==="multipleOf")return!0;i.kind==="min"?(r===null||i.value>r)&&(r=i.value):i.kind==="max"&&(e===null||i.value<e)&&(e=i.value)}return Number.isFinite(r)&&Number.isFinite(e)}};Uu.create=t=>new Uu({checks:[],typeName:Z.ZodNumber,coerce:t?.coerce||!1,...ke(t)});Mu=class t extends Oe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==J.bigint)return this._getInvalidInput(e);let i,n=new ar;for(let o of this._def.checks)o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(i=this._getOrReturnCtx(e,i),H(i,{code:F.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),n.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(i=this._getOrReturnCtx(e,i),H(i,{code:F.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),n.dirty()):o.kind==="multipleOf"?e.data%o.value!==BigInt(0)&&(i=this._getOrReturnCtx(e,i),H(i,{code:F.not_multiple_of,multipleOf:o.value,message:o.message}),n.dirty()):Le.assertNever(o);return{status:n.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return H(r,{code:F.invalid_type,expected:J.bigint,received:r.parsedType}),me}gte(e,r){return this.setLimit("min",e,!0,ne.toString(r))}gt(e,r){return this.setLimit("min",e,!1,ne.toString(r))}lte(e,r){return this.setLimit("max",e,!0,ne.toString(r))}lt(e,r){return this.setLimit("max",e,!1,ne.toString(r))}setLimit(e,r,i,n){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:i,message:ne.toString(n)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ne.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ne.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ne.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ne.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:ne.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};Mu.create=t=>new Mu({checks:[],typeName:Z.ZodBigInt,coerce:t?.coerce??!1,...ke(t)});Fu=class extends Oe{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==J.boolean){let i=this._getOrReturnCtx(e);return H(i,{code:F.invalid_type,expected:J.boolean,received:i.parsedType}),me}return br(e.data)}};Fu.create=t=>new Fu({typeName:Z.ZodBoolean,coerce:t?.coerce||!1,...ke(t)});Zu=class t extends Oe{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==J.date){let o=this._getOrReturnCtx(e);return H(o,{code:F.invalid_type,expected:J.date,received:o.parsedType}),me}if(Number.isNaN(e.data.getTime())){let o=this._getOrReturnCtx(e);return H(o,{code:F.invalid_date}),me}let i=new ar,n;for(let o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(n=this._getOrReturnCtx(e,n),H(n,{code:F.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),i.dirty()):o.kind==="max"?e.data.getTime()>o.value&&(n=this._getOrReturnCtx(e,n),H(n,{code:F.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),i.dirty()):Le.assertNever(o);return{status:i.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:ne.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:ne.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};Zu.create=t=>new Zu({checks:[],coerce:t?.coerce||!1,typeName:Z.ZodDate,...ke(t)});qu=class extends Oe{_parse(e){if(this._getType(e)!==J.symbol){let i=this._getOrReturnCtx(e);return H(i,{code:F.invalid_type,expected:J.symbol,received:i.parsedType}),me}return br(e.data)}};qu.create=t=>new qu({typeName:Z.ZodSymbol,...ke(t)});Ba=class extends Oe{_parse(e){if(this._getType(e)!==J.undefined){let i=this._getOrReturnCtx(e);return H(i,{code:F.invalid_type,expected:J.undefined,received:i.parsedType}),me}return br(e.data)}};Ba.create=t=>new Ba({typeName:Z.ZodUndefined,...ke(t)});Ha=class extends Oe{_parse(e){if(this._getType(e)!==J.null){let i=this._getOrReturnCtx(e);return H(i,{code:F.invalid_type,expected:J.null,received:i.parsedType}),me}return br(e.data)}};Ha.create=t=>new Ha({typeName:Z.ZodNull,...ke(t)});Vu=class extends Oe{constructor(){super(...arguments),this._any=!0}_parse(e){return br(e.data)}};Vu.create=t=>new Vu({typeName:Z.ZodAny,...ke(t)});to=class extends Oe{constructor(){super(...arguments),this._unknown=!0}_parse(e){return br(e.data)}};to.create=t=>new to({typeName:Z.ZodUnknown,...ke(t)});Qn=class extends Oe{_parse(e){let r=this._getOrReturnCtx(e);return H(r,{code:F.invalid_type,expected:J.never,received:r.parsedType}),me}};Qn.create=t=>new Qn({typeName:Z.ZodNever,...ke(t)});Bu=class extends Oe{_parse(e){if(this._getType(e)!==J.undefined){let i=this._getOrReturnCtx(e);return H(i,{code:F.invalid_type,expected:J.void,received:i.parsedType}),me}return br(e.data)}};Bu.create=t=>new Bu({typeName:Z.ZodVoid,...ke(t)});ro=class t extends Oe{_parse(e){let{ctx:r,status:i}=this._processInputParams(e),n=this._def;if(r.parsedType!==J.array)return H(r,{code:F.invalid_type,expected:J.array,received:r.parsedType}),me;if(n.exactLength!==null){let s=r.data.length>n.exactLength.value,a=r.data.length<n.exactLength.value;(s||a)&&(H(r,{code:s?F.too_big:F.too_small,minimum:a?n.exactLength.value:void 0,maximum:s?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),i.dirty())}if(n.minLength!==null&&r.data.length<n.minLength.value&&(H(r,{code:F.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),i.dirty()),n.maxLength!==null&&r.data.length>n.maxLength.value&&(H(r,{code:F.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),i.dirty()),r.common.async)return Promise.all([...r.data].map((s,a)=>n.type._parseAsync(new cn(r,s,r.path,a)))).then(s=>ar.mergeArray(i,s));let o=[...r.data].map((s,a)=>n.type._parseSync(new cn(r,s,r.path,a)));return ar.mergeArray(i,o)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:ne.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:ne.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:ne.toString(r)}})}nonempty(e){return this.min(1,e)}};ro.create=(t,e)=>new ro({type:t,minLength:null,maxLength:null,exactLength:null,typeName:Z.ZodArray,...ke(e)});Wr=class t extends Oe{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=Le.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==J.object){let l=this._getOrReturnCtx(e);return H(l,{code:F.invalid_type,expected:J.object,received:l.parsedType}),me}let{status:i,ctx:n}=this._processInputParams(e),{shape:o,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof Qn&&this._def.unknownKeys==="strip"))for(let l in n.data)s.includes(l)||a.push(l);let c=[];for(let l of s){let u=o[l],d=n.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new cn(n,d,n.path,l)),alwaysSet:l in n.data})}if(this._def.catchall instanceof Qn){let l=this._def.unknownKeys;if(l==="passthrough")for(let u of a)c.push({key:{status:"valid",value:u},value:{status:"valid",value:n.data[u]}});else if(l==="strict")a.length>0&&(H(n,{code:F.unrecognized_keys,keys:a}),i.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let u of a){let d=n.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new cn(n,d,n.path,u)),alwaysSet:u in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let l=[];for(let u of c){let d=await u.key,p=await u.value;l.push({key:d,value:p,alwaysSet:u.alwaysSet})}return l}).then(l=>ar.mergeObjectSync(i,l)):ar.mergeObjectSync(i,c)}get shape(){return this._def.shape()}strict(e){return ne.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,i)=>{let n=this._def.errorMap?.(r,i).message??i.defaultError;return r.code==="unrecognized_keys"?{message:ne.errToObj(e).message??n}:{message:n}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Z.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let i of Le.objectKeys(e))e[i]&&this.shape[i]&&(r[i]=this.shape[i]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let i of Le.objectKeys(this.shape))e[i]||(r[i]=this.shape[i]);return new t({...this._def,shape:()=>r})}deepPartial(){return qa(this)}partial(e){let r={};for(let i of Le.objectKeys(this.shape)){let n=this.shape[i];e&&!e[i]?r[i]=n:r[i]=n.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let i of Le.objectKeys(this.shape))if(e&&!e[i])r[i]=this.shape[i];else{let o=this.shape[i];for(;o instanceof On;)o=o._def.innerType;r[i]=o}return new t({...this._def,shape:()=>r})}keyof(){return AC(Le.objectKeys(this.shape))}};Wr.create=(t,e)=>new Wr({shape:()=>t,unknownKeys:"strip",catchall:Qn.create(),typeName:Z.ZodObject,...ke(e)});Wr.strictCreate=(t,e)=>new Wr({shape:()=>t,unknownKeys:"strict",catchall:Qn.create(),typeName:Z.ZodObject,...ke(e)});Wr.lazycreate=(t,e)=>new Wr({shape:t,unknownKeys:"strip",catchall:Qn.create(),typeName:Z.ZodObject,...ke(e)});Wa=class extends Oe{_parse(e){let{ctx:r}=this._processInputParams(e),i=this._def.options;function n(o){for(let a of o)if(a.result.status==="valid")return a.result;for(let a of o)if(a.result.status==="dirty")return r.common.issues.push(...a.ctx.common.issues),a.result;let s=o.map(a=>new Hr(a.ctx.common.issues));return H(r,{code:F.invalid_union,unionErrors:s}),me}if(r.common.async)return Promise.all(i.map(async o=>{let s={...r,common:{...r.common,issues:[]},parent:null};return{result:await o._parseAsync({data:r.data,path:r.path,parent:s}),ctx:s}})).then(n);{let o,s=[];for(let c of i){let l={...r,common:{...r.common,issues:[]},parent:null},u=c._parseSync({data:r.data,path:r.path,parent:l});if(u.status==="valid")return u;u.status==="dirty"&&!o&&(o={result:u,ctx:l}),l.common.issues.length&&s.push(l.common.issues)}if(o)return r.common.issues.push(...o.ctx.common.issues),o.result;let a=s.map(c=>new Hr(c));return H(r,{code:F.invalid_union,unionErrors:a}),me}}get options(){return this._def.options}};Wa.create=(t,e)=>new Wa({options:t,typeName:Z.ZodUnion,...ke(e)});Oi=t=>t instanceof Ga?Oi(t.schema):t instanceof Pn?Oi(t.innerType()):t instanceof Ja?[t.value]:t instanceof Xa?t.options:t instanceof Ya?Le.objectValues(t.enum):t instanceof Qa?Oi(t._def.innerType):t instanceof Ba?[void 0]:t instanceof Ha?[null]:t instanceof On?[void 0,...Oi(t.unwrap())]:t instanceof Ai?[null,...Oi(t.unwrap())]:t instanceof Wm||t instanceof tc?Oi(t.unwrap()):t instanceof ec?Oi(t._def.innerType):[],Rk=class t extends Oe{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==J.object)return H(r,{code:F.invalid_type,expected:J.object,received:r.parsedType}),me;let i=this.discriminator,n=r.data[i],o=this.optionsMap.get(n);return o?r.common.async?o._parseAsync({data:r.data,path:r.path,parent:r}):o._parseSync({data:r.data,path:r.path,parent:r}):(H(r,{code:F.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[i]}),me)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,i){let n=new Map;for(let o of r){let s=Oi(o.shape[e]);if(!s.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of s){if(n.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);n.set(a,o)}}return new t({typeName:Z.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:n,...ke(i)})}};Ka=class extends Oe{_parse(e){let{status:r,ctx:i}=this._processInputParams(e),n=(o,s)=>{if(Tk(o)||Tk(s))return me;let a=jk(o.value,s.value);return a.valid?((Ok(o)||Ok(s))&&r.dirty(),{status:r.value,value:a.data}):(H(i,{code:F.invalid_intersection_types}),me)};return i.common.async?Promise.all([this._def.left._parseAsync({data:i.data,path:i.path,parent:i}),this._def.right._parseAsync({data:i.data,path:i.path,parent:i})]).then(([o,s])=>n(o,s)):n(this._def.left._parseSync({data:i.data,path:i.path,parent:i}),this._def.right._parseSync({data:i.data,path:i.path,parent:i}))}};Ka.create=(t,e,r)=>new Ka({left:t,right:e,typeName:Z.ZodIntersection,...ke(r)});Pi=class t extends Oe{_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.parsedType!==J.array)return H(i,{code:F.invalid_type,expected:J.array,received:i.parsedType}),me;if(i.data.length<this._def.items.length)return H(i,{code:F.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),me;!this._def.rest&&i.data.length>this._def.items.length&&(H(i,{code:F.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let o=[...i.data].map((s,a)=>{let c=this._def.items[a]||this._def.rest;return c?c._parse(new cn(i,s,i.path,a)):null}).filter(s=>!!s);return i.common.async?Promise.all(o).then(s=>ar.mergeArray(r,s)):ar.mergeArray(r,o)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};Pi.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Pi({items:t,typeName:Z.ZodTuple,rest:null,...ke(e)})};zk=class t extends Oe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.parsedType!==J.object)return H(i,{code:F.invalid_type,expected:J.object,received:i.parsedType}),me;let n=[],o=this._def.keyType,s=this._def.valueType;for(let a in i.data)n.push({key:o._parse(new cn(i,a,i.path,a)),value:s._parse(new cn(i,i.data[a],i.path,a)),alwaysSet:a in i.data});return i.common.async?ar.mergeObjectAsync(r,n):ar.mergeObjectSync(r,n)}get element(){return this._def.valueType}static create(e,r,i){return r instanceof Oe?new t({keyType:e,valueType:r,typeName:Z.ZodRecord,...ke(i)}):new t({keyType:Va.create(),valueType:e,typeName:Z.ZodRecord,...ke(r)})}},Hu=class extends Oe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.parsedType!==J.map)return H(i,{code:F.invalid_type,expected:J.map,received:i.parsedType}),me;let n=this._def.keyType,o=this._def.valueType,s=[...i.data.entries()].map(([a,c],l)=>({key:n._parse(new cn(i,a,i.path,[l,"key"])),value:o._parse(new cn(i,c,i.path,[l,"value"]))}));if(i.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let c of s){let l=await c.key,u=await c.value;if(l.status==="aborted"||u.status==="aborted")return me;(l.status==="dirty"||u.status==="dirty")&&r.dirty(),a.set(l.value,u.value)}return{status:r.value,value:a}})}else{let a=new Map;for(let c of s){let l=c.key,u=c.value;if(l.status==="aborted"||u.status==="aborted")return me;(l.status==="dirty"||u.status==="dirty")&&r.dirty(),a.set(l.value,u.value)}return{status:r.value,value:a}}}};Hu.create=(t,e,r)=>new Hu({valueType:e,keyType:t,typeName:Z.ZodMap,...ke(r)});Wu=class t extends Oe{_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.parsedType!==J.set)return H(i,{code:F.invalid_type,expected:J.set,received:i.parsedType}),me;let n=this._def;n.minSize!==null&&i.data.size<n.minSize.value&&(H(i,{code:F.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),r.dirty()),n.maxSize!==null&&i.data.size>n.maxSize.value&&(H(i,{code:F.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),r.dirty());let o=this._def.valueType;function s(c){let l=new Set;for(let u of c){if(u.status==="aborted")return me;u.status==="dirty"&&r.dirty(),l.add(u.value)}return{status:r.value,value:l}}let a=[...i.data.values()].map((c,l)=>o._parse(new cn(i,c,i.path,l)));return i.common.async?Promise.all(a).then(c=>s(c)):s(a)}min(e,r){return new t({...this._def,minSize:{value:e,message:ne.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:ne.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Wu.create=(t,e)=>new Wu({valueType:t,minSize:null,maxSize:null,typeName:Z.ZodSet,...ke(e)});Ck=class t extends Oe{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==J.function)return H(r,{code:F.invalid_type,expected:J.function,received:r.parsedType}),me;function i(a,c){return Hm({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Du(),eo].filter(l=>!!l),issueData:{code:F.invalid_arguments,argumentsError:c}})}function n(a,c){return Hm({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Du(),eo].filter(l=>!!l),issueData:{code:F.invalid_return_type,returnTypeError:c}})}let o={errorMap:r.common.contextualErrorMap},s=r.data;if(this._def.returns instanceof hs){let a=this;return br(async function(...c){let l=new Hr([]),u=await a._def.args.parseAsync(c,o).catch(f=>{throw l.addIssue(i(c,f)),l}),d=await Reflect.apply(s,this,u);return await a._def.returns._def.type.parseAsync(d,o).catch(f=>{throw l.addIssue(n(d,f)),l})})}else{let a=this;return br(function(...c){let l=a._def.args.safeParse(c,o);if(!l.success)throw new Hr([i(c,l.error)]);let u=Reflect.apply(s,this,l.data),d=a._def.returns.safeParse(u,o);if(!d.success)throw new Hr([n(u,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:Pi.create(e).rest(to.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,i){return new t({args:e||Pi.create([]).rest(to.create()),returns:r||to.create(),typeName:Z.ZodFunction,...ke(i)})}},Ga=class extends Oe{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};Ga.create=(t,e)=>new Ga({getter:t,typeName:Z.ZodLazy,...ke(e)});Ja=class extends Oe{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return H(r,{received:r.data,code:F.invalid_literal,expected:this._def.value}),me}return{status:"valid",value:e.data}}get value(){return this._def.value}};Ja.create=(t,e)=>new Ja({value:t,typeName:Z.ZodLiteral,...ke(e)});Xa=class t extends Oe{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),i=this._def.values;return H(r,{expected:Le.joinValues(i),received:r.parsedType,code:F.invalid_type}),me}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),i=this._def.values;return H(r,{received:r.data,code:F.invalid_enum_value,options:i}),me}return br(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(i=>!e.includes(i)),{...this._def,...r})}};Xa.create=AC;Ya=class extends Oe{_parse(e){let r=Le.getValidEnumValues(this._def.values),i=this._getOrReturnCtx(e);if(i.parsedType!==J.string&&i.parsedType!==J.number){let n=Le.objectValues(r);return H(i,{expected:Le.joinValues(n),received:i.parsedType,code:F.invalid_type}),me}if(this._cache||(this._cache=new Set(Le.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let n=Le.objectValues(r);return H(i,{received:i.data,code:F.invalid_enum_value,options:n}),me}return br(e.data)}get enum(){return this._def.values}};Ya.create=(t,e)=>new Ya({values:t,typeName:Z.ZodNativeEnum,...ke(e)});hs=class extends Oe{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==J.promise&&r.common.async===!1)return H(r,{code:F.invalid_type,expected:J.promise,received:r.parsedType}),me;let i=r.parsedType===J.promise?r.data:Promise.resolve(r.data);return br(i.then(n=>this._def.type.parseAsync(n,{path:r.path,errorMap:r.common.contextualErrorMap})))}};hs.create=(t,e)=>new hs({type:t,typeName:Z.ZodPromise,...ke(e)});Pn=class extends Oe{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Z.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:i}=this._processInputParams(e),n=this._def.effect||null,o={addIssue:s=>{H(i,s),s.fatal?r.abort():r.dirty()},get path(){return i.path}};if(o.addIssue=o.addIssue.bind(o),n.type==="preprocess"){let s=n.transform(i.data,o);if(i.common.async)return Promise.resolve(s).then(async a=>{if(r.value==="aborted")return me;let c=await this._def.schema._parseAsync({data:a,path:i.path,parent:i});return c.status==="aborted"?me:c.status==="dirty"?Za(c.value):r.value==="dirty"?Za(c.value):c});{if(r.value==="aborted")return me;let a=this._def.schema._parseSync({data:s,path:i.path,parent:i});return a.status==="aborted"?me:a.status==="dirty"?Za(a.value):r.value==="dirty"?Za(a.value):a}}if(n.type==="refinement"){let s=a=>{let c=n.refinement(a,o);if(i.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(i.common.async===!1){let a=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});return a.status==="aborted"?me:(a.status==="dirty"&&r.dirty(),s(a.value),{status:r.value,value:a.value})}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(a=>a.status==="aborted"?me:(a.status==="dirty"&&r.dirty(),s(a.value).then(()=>({status:r.value,value:a.value}))))}if(n.type==="transform")if(i.common.async===!1){let s=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});if(!ps(s))return me;let a=n.transform(s.value,o);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:a}}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(s=>ps(s)?Promise.resolve(n.transform(s.value,o)).then(a=>({status:r.value,value:a})):me);Le.assertNever(n)}};Pn.create=(t,e,r)=>new Pn({schema:t,typeName:Z.ZodEffects,effect:e,...ke(r)});Pn.createWithPreprocess=(t,e,r)=>new Pn({schema:e,effect:{type:"preprocess",transform:t},typeName:Z.ZodEffects,...ke(r)});On=class extends Oe{_parse(e){return this._getType(e)===J.undefined?br(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};On.create=(t,e)=>new On({innerType:t,typeName:Z.ZodOptional,...ke(e)});Ai=class extends Oe{_parse(e){return this._getType(e)===J.null?br(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ai.create=(t,e)=>new Ai({innerType:t,typeName:Z.ZodNullable,...ke(e)});Qa=class extends Oe{_parse(e){let{ctx:r}=this._processInputParams(e),i=r.data;return r.parsedType===J.undefined&&(i=this._def.defaultValue()),this._def.innerType._parse({data:i,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Qa.create=(t,e)=>new Qa({innerType:t,typeName:Z.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ke(e)});ec=class extends Oe{_parse(e){let{ctx:r}=this._processInputParams(e),i={...r,common:{...r.common,issues:[]}},n=this._def.innerType._parse({data:i.data,path:i.path,parent:{...i}});return Lu(n)?n.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Hr(i.common.issues)},input:i.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new Hr(i.common.issues)},input:i.data})}}removeCatch(){return this._def.innerType}};ec.create=(t,e)=>new ec({innerType:t,typeName:Z.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ke(e)});Ku=class extends Oe{_parse(e){if(this._getType(e)!==J.nan){let i=this._getOrReturnCtx(e);return H(i,{code:F.invalid_type,expected:J.nan,received:i.parsedType}),me}return{status:"valid",value:e.data}}};Ku.create=t=>new Ku({typeName:Z.ZodNaN,...ke(t)});Dae=Symbol("zod_brand"),Wm=class extends Oe{_parse(e){let{ctx:r}=this._processInputParams(e),i=r.data;return this._def.type._parse({data:i,path:r.path,parent:r})}unwrap(){return this._def.type}},Km=class t extends Oe{_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.common.async)return(async()=>{let o=await this._def.in._parseAsync({data:i.data,path:i.path,parent:i});return o.status==="aborted"?me:o.status==="dirty"?(r.dirty(),Za(o.value)):this._def.out._parseAsync({data:o.value,path:i.path,parent:i})})();{let n=this._def.in._parseSync({data:i.data,path:i.path,parent:i});return n.status==="aborted"?me:n.status==="dirty"?(r.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:i.path,parent:i})}}static create(e,r){return new t({in:e,out:r,typeName:Z.ZodPipeline})}},tc=class extends Oe{_parse(e){let r=this._def.innerType._parse(e),i=n=>(ps(n)&&(n.value=Object.freeze(n.value)),n);return Lu(r)?r.then(n=>i(n)):i(r)}unwrap(){return this._def.innerType}};tc.create=(t,e)=>new tc({innerType:t,typeName:Z.ZodReadonly,...ke(e)});Lae={object:Wr.lazycreate};(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(Z||(Z={}));Uae=Va.create,Mae=Uu.create,Fae=Ku.create,Zae=Mu.create,qae=Fu.create,Vae=Zu.create,Bae=qu.create,Hae=Ba.create,Wae=Ha.create,Kae=Vu.create,Gae=to.create,Jae=Qn.create,Xae=Bu.create,Yae=ro.create,RC=Wr.create,Qae=Wr.strictCreate,ece=Wa.create,tce=Rk.create,rce=Ka.create,nce=Pi.create,ice=zk.create,oce=Hu.create,sce=Wu.create,ace=Ck.create,cce=Ga.create,lce=Ja.create,uce=Xa.create,dce=Ya.create,fce=hs.create,pce=Pn.create,hce=On.create,mce=Ai.create,gce=Pn.createWithPreprocess,yce=Km.create});var zC=w(()=>{Bm();Pk();IC();Nu();jC();Vm()});var Gu=w(()=>{zC()});var Nk=w(()=>{fw()});function ei(t){return!!t._zod}function ms(t){let e=Object.values(t);if(e.length===0)return dt({});let r=e.every(ei),i=e.every(n=>!ei(n));if(r)return dt(t);if(i)return RC(t);throw new Error("Mixed Zod versions detected in object shape.")}function no(t,e){return ei(t)?Ks(t,e):t.safeParse(e)}async function Gm(t,e){return ei(t)?await Js(t,e):await t.safeParseAsync(e)}function io(t){if(!t)return;let e;if(ei(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function rc(t){if(t){if(typeof t=="object"){let e=t,r=t;if(!e._def&&!r._zod){let i=Object.values(t);if(i.length>0&&i.every(n=>typeof n=="object"&&n!==null&&(n._def!==void 0||n._zod!==void 0||typeof n.parse=="function")))return ms(t)}}if(ei(t)){let r=t._zod?.def;if(r&&(r.type==="object"||r.shape!==void 0))return t}else if(t.shape!==void 0)return t}}function cK(t){return t.length===0?"object root":t.reduce((e,r,i)=>i===0?String(r):typeof r=="number"?`${e}[${r}]`:`${e}.${r}`,"")}function Jm(t){if(t&&typeof t=="object"){if("issues"in t&&Array.isArray(t.issues)&&t.issues.length>0)return t.issues.map(e=>e.path?.length?`${e.message} at ${cK(e.path)}`:e.message).join(`
120
- `);if("message"in t&&typeof t.message=="string")return t.message;try{return JSON.stringify(t)}catch{return String(t)}}return String(t)}function NC(t){return t.description}function DC(t){if(ei(t))return t._zod?.def?.type==="optional";let e=t;return typeof t.isOptional=="function"?t.isOptional():e._def?.typeName==="ZodOptional"}function nc(t){if(ei(t)){let o=t._zod?.def;if(o){if(o.value!==void 0)return o.value;if(Array.isArray(o.values)&&o.values.length>0)return o.values[0]}}let r=t._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let i=t.value;if(i!==void 0)return i}var Ju=w(()=>{Gu();Nk()});var Xm={};Jr(Xm,{endsWith:()=>Bo,gt:()=>bn,gte:()=>gr,includes:()=>qo,length:()=>Vi,lowercase:()=>Fo,lt:()=>_n,lte:()=>mr,maxLength:()=>qi,maxSize:()=>_i,mime:()=>Wo,minLength:()=>Or,minSize:()=>wn,multipleOf:()=>vi,negative:()=>Hl,nonnegative:()=>Kl,nonpositive:()=>Wl,normalize:()=>Ko,overwrite:()=>rn,positive:()=>Bl,properties:()=>Ho,property:()=>Gl,regex:()=>Mo,size:()=>Zi,slugify:()=>fa,startsWith:()=>Vo,toLowerCase:()=>Jo,toUpperCase:()=>Xo,trim:()=>Go,uppercase:()=>Zo});var Ym=w(()=>{Xt()});function Qm(t,e,r){Object.defineProperty(t,e,{configurable:!0,enumerable:!1,get(){let i=r(this);return Object.defineProperty(this,e,{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,e,{value:i,configurable:!0,writable:!0})}})}var LC,UC,lK,zr,Dk=w(()=>{Xt();Xt();B();LC=new WeakSet([Object.prototype,Error.prototype]);UC=(t,e)=>{Dv.init(t,e),t.name="ZodError";let r=Object.getPrototypeOf(t);LC.has(r)||(LC.add(r),Qm(r,"format",i=>n=>Gc(i,n)),Qm(r,"flatten",i=>n=>Kc(i,n)),Qm(r,"addIssue",i=>n=>{i.issues.push(n),i.message=JSON.stringify(i.issues,Ms,2)}),Qm(r,"addIssues",i=>n=>{i.issues.push(...n),i.message=JSON.stringify(i.issues,Ms,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},lK=$("ZodError",UC),zr=$("ZodError",UC,void 0,{Parent:Error})});var Lk,Uk,Mk,Fk,Zk,qk,Vk,Bk,Hk,Wk,Kk,Gk,Jk=w(()=>{Xt();Dk();Xt();Lk=Bs(zr),Uk=Hs(zr),Mk=Ws(zr),Fk=Gs(zr),Zk=$f(zr),qk=kf(zr),Vk=Sf(zr),Bk=xf(zr),Hk=If(zr),Wk=Ef(zr),Kk=Tf(zr),Gk=Of(zr)});var dc={};Jr(dc,{ZodAny:()=>n0,ZodArray:()=>a0,ZodBase64:()=>gg,ZodBase64URL:()=>yg,ZodBigInt:()=>lc,ZodBigIntFormat:()=>bg,ZodBoolean:()=>cc,ZodCIDRv4:()=>hg,ZodCIDRv6:()=>mg,ZodCUID:()=>ag,ZodCUID2:()=>cg,ZodCatch:()=>I0,ZodCodec:()=>od,ZodCreditCard:()=>Yk,ZodCustom:()=>sd,ZodCustomStringFormat:()=>ys,ZodDate:()=>ed,ZodDefault:()=>b0,ZodDiscriminatedUnion:()=>l0,ZodE164:()=>vg,ZodEmail:()=>ng,ZodEmoji:()=>og,ZodEnum:()=>oc,ZodExactOptional:()=>kg,ZodFile:()=>g0,ZodFunction:()=>N0,ZodGUID:()=>ig,ZodIBAN:()=>Qk,ZodIPv4:()=>fg,ZodIPv6:()=>pg,ZodISODate:()=>so,ZodISODateTime:()=>oo,ZodISODuration:()=>co,ZodISOTime:()=>ao,ZodInstanceOf:()=>U0,ZodIntersection:()=>u0,ZodJWT:()=>_g,ZodKSUID:()=>dg,ZodLazy:()=>j0,ZodLiteral:()=>m0,ZodMAC:()=>Xk,ZodMap:()=>p0,ZodNaN:()=>T0,ZodNanoID:()=>sg,ZodNever:()=>o0,ZodNonOptional:()=>Sg,ZodNull:()=>r0,ZodNullable:()=>_0,ZodNumber:()=>ac,ZodNumberFormat:()=>vs,ZodObject:()=>td,ZodOptional:()=>_s,ZodPipe:()=>id,ZodPrefault:()=>$0,ZodPreprocess:()=>O0,ZodPromise:()=>C0,ZodReadonly:()=>P0,ZodRecord:()=>ic,ZodSet:()=>h0,ZodString:()=>sc,ZodStringFormat:()=>st,ZodSuccess:()=>x0,ZodSymbol:()=>e0,ZodTemplateLiteral:()=>R0,ZodTransform:()=>y0,ZodTuple:()=>d0,ZodType:()=>Se,ZodULID:()=>lg,ZodURL:()=>Yu,ZodUUID:()=>ti,ZodUndefined:()=>t0,ZodUnion:()=>rd,ZodUnknown:()=>i0,ZodVoid:()=>s0,ZodXID:()=>ug,ZodXor:()=>c0,_ZodString:()=>rg,_default:()=>w0,_function:()=>BN,any:()=>IN,array:()=>Pe,base64:()=>sN,base64url:()=>aN,bigint:()=>wN,boolean:()=>Nt,catch:()=>E0,check:()=>HN,cidrv4:()=>iN,cidrv6:()=>oN,codec:()=>FN,creditCard:()=>lN,cuid:()=>JC,cuid2:()=>XC,currencyCode:()=>mN,custom:()=>xg,date:()=>TN,describe:()=>WN,discriminatedUnion:()=>nd,e164:()=>cN,email:()=>MC,emoji:()=>KC,enum:()=>er,exactOptional:()=>v0,file:()=>DN,float32:()=>yN,float64:()=>vN,function:()=>BN,guid:()=>FC,hash:()=>gN,hex:()=>hN,hostname:()=>pN,httpUrl:()=>WC,iban:()=>uN,instanceof:()=>GN,int:()=>eg,int32:()=>_N,int64:()=>$N,intersection:()=>uc,invertCodec:()=>ZN,ipv4:()=>tN,ipv6:()=>nN,json:()=>XN,jwt:()=>dN,keyof:()=>ON,ksuid:()=>eN,lazy:()=>z0,literal:()=>se,looseObject:()=>Qt,looseRecord:()=>jN,mac:()=>rN,map:()=>zN,meta:()=>KN,nan:()=>MN,nanoid:()=>GC,nativeEnum:()=>NN,never:()=>wg,nonoptional:()=>S0,null:()=>Qu,nullable:()=>Xu,nullish:()=>LN,number:()=>Ke,object:()=>K,optional:()=>ot,partialRecord:()=>RN,pipe:()=>tg,prefault:()=>k0,preprocess:()=>ad,promise:()=>VN,readonly:()=>A0,record:()=>at,refine:()=>D0,set:()=>CN,strictObject:()=>PN,string:()=>P,stringFormat:()=>fN,stringbool:()=>JN,success:()=>UN,superRefine:()=>L0,symbol:()=>SN,templateLiteral:()=>qN,transform:()=>$g,tuple:()=>f0,uint32:()=>bN,uint64:()=>kN,ulid:()=>YC,undefined:()=>xN,union:()=>rt,unknown:()=>ct,url:()=>HC,uuid:()=>ZC,uuidv4:()=>qC,uuidv6:()=>VC,uuidv7:()=>BC,void:()=>EN,xid:()=>QC,xor:()=>AN});function dK(){Wt.localeError||Pt(ih())}function gs(){Wt.memoizer||Pt({memoizer:hl()})}function P(t){return yl(sc,t)}function MC(t){return vl(ng,t)}function FC(t){return _l(ig,t)}function ZC(t){return bl(ti,t)}function qC(t){return wl(ti,t)}function VC(t){return $l(ti,t)}function BC(t){return kl(ti,t)}function HC(t){return da(Yu,t)}function WC(t){return da(Yu,{protocol:Jc,hostname:c_,...A.normalizeParams(t)})}function KC(t){return Sl(og,t)}function GC(t){return xl(sg,t)}function JC(t){return Il(ag,t)}function XC(t){return El(cg,t)}function YC(t){return Tl(lg,t)}function QC(t){return Ol(ug,t)}function eN(t){return Pl(dg,t)}function tN(t){return Al(fg,t)}function rN(t){return ph(Xk,t)}function nN(t){return Rl(pg,t)}function iN(t){return jl(hg,t)}function oN(t){return zl(mg,t)}function sN(t){return Cl(gg,t)}function aN(t){return Nl(yg,t)}function cN(t){return Dl(vg,t)}function lN(t){return hh(Yk,t)}function uN(t){return mh(Qk,t)}function dN(t){return Ll(_g,t)}function fN(t,e,r={}){return Bi(ys,t,e,r)}function pN(t){return Bi(ys,"hostname",a_,t)}function hN(t){return Bi(ys,"hex",$_,t)}function mN(t){return Bi(ys,"currency_code",u_,t)}function gN(t,e){let r=e?.enc??"hex",i=`${t}_${r}`,n=Fr[i];if(!n)throw new Error(`Unrecognized hash format: ${i}`);return Bi(ys,i,n,e)}function Ke(t){return ql(ac,t)}function eg(t){return gh(vs,t)}function yN(t){return yh(vs,t)}function vN(t){return vh(vs,t)}function _N(t){return _h(vs,t)}function bN(t){return bh(vs,t)}function Nt(t){return Vl(cc,t)}function wN(t){return wh(lc,t)}function $N(t){return $h(bg,t)}function kN(t){return kh(bg,t)}function SN(t){return Sh(e0,t)}function xN(t){return xh(t0,t)}function Qu(t){return Ih(r0,t)}function IN(){return Eh(n0)}function ct(){return Th(i0)}function wg(t){return Oh(o0,t)}function EN(t){return Ph(s0,t)}function TN(t){return Ah(ed,t)}function Pe(t,e){return wb(a0,t,e)}function ON(t){let e=t._zod.def.shape;return er(Object.keys(e))}function K(t,e){let r={type:"object",shape:t??{},...A.normalizeParams(e)};return new td(r)}function PN(t,e){return new td({type:"object",shape:t,catchall:wg(),...A.normalizeParams(e)})}function Qt(t,e){return new td({type:"object",shape:t,catchall:ct(),...A.normalizeParams(e)})}function rt(t,e){return new rd({type:"union",options:t,...A.normalizeParams(e)})}function AN(t,e){return new c0({type:"union",options:t,inclusive:!1,...A.normalizeParams(e)})}function nd(t,e,r){return new l0({type:"union",options:e,discriminator:t,...A.normalizeParams(r)})}function uc(t,e){return new u0({type:"intersection",left:t,right:e})}function f0(t,e,r){let i=e instanceof ve,n=i?r:e,o=i?e:null;return new d0({type:"tuple",items:t,rest:o,...A.normalizeParams(n)})}function at(t,e,r){return!e||!e._zod?new ic({type:"record",keyType:P(),valueType:t,...A.normalizeParams(e)}):new ic({type:"record",keyType:t,valueType:e,...A.normalizeParams(r)})}function RN(t,e,r){return new ic({type:"record",keyType:t,valueType:e,...A.normalizeParams(r),partial:!0})}function jN(t,e,r){return new ic({type:"record",keyType:t,valueType:e,mode:"loose",...A.normalizeParams(r)})}function zN(t,e,r){return new p0({type:"map",keyType:t,valueType:e,...A.normalizeParams(r)})}function CN(t,e){return new h0({type:"set",valueType:t,...A.normalizeParams(e)})}function er(t,e){let r=Array.isArray(t)?Object.fromEntries(t.map(i=>[i,i])):t;return new oc({type:"enum",entries:r,...A.normalizeParams(e)})}function NN(t,e){return new oc({type:"enum",entries:t,...A.normalizeParams(e)})}function se(t,e){return new m0({type:"literal",values:Array.isArray(t)?t:[t],...A.normalizeParams(e)})}function DN(t){return jh(g0,t)}function $g(t){return new y0({type:"transform",transform:t})}function ot(t){return new _s({type:"optional",innerType:t})}function v0(t){return new kg({type:"optional",innerType:t})}function Xu(t){return new _0({type:"nullable",innerType:t})}function LN(t){return ot(Xu(t))}function w0(t,e){return new b0({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():A.shallowClone(e)}})}function k0(t,e){return new $0({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():A.shallowClone(e)}})}function S0(t,e){return new Sg({type:"nonoptional",innerType:t,...A.normalizeParams(e)})}function UN(t){return new x0({type:"success",innerType:t})}function E0(t,e){return new I0({type:"catch",innerType:t,catchValue:typeof e=="function"?e:A.constantCatch(e)})}function MN(t){return Rh(T0,t)}function tg(t,e){return new id({type:"pipe",in:t,out:e})}function FN(t,e,r){return new od({type:"pipe",in:t,out:e,transform:r.decode,reverseTransform:r.encode})}function ZN(t){let e=t._zod.def;return new od({type:"pipe",in:e.out,out:e.in,transform:e.reverseTransform,reverseTransform:e.transform})}function A0(t){return new P0({type:"readonly",innerType:t})}function qN(t,e){return new R0({type:"template_literal",parts:t,...A.normalizeParams(e)})}function z0(t){return new j0({type:"lazy",getter:t})}function VN(t){return new C0({type:"promise",innerType:t})}function BN(t){return new N0({type:"function",input:Array.isArray(t?.input)?f0(t?.input):t?.input??Pe(ct()),output:t?.output??ct()})}function HN(t){let e=new it({check:"custom"});return e._zod.check=t,e}function xg(t,e){return zh(sd,t??(()=>!0),e)}function D0(t,e={}){return Ch(sd,t,e)}function L0(t,e){return Nh(t,e)}function GN(t,e={}){let r=new U0({type:"custom",check:"custom",fn:i=>i instanceof t,abort:!0,...A.normalizeParams(e)});return r._zod.bag.Class=t,r._zod.check=i=>{i.value instanceof t||i.issues.push({code:"invalid_type",expected:t.name,input:i.value,inst:r,path:[...r._zod.def.path??[]]})},r}function XN(t){let e=z0(()=>rt([P(t),Ke(),Nt(),Qu(),Pe(e),at(P(),e)]));return e}function ad(t,e){return new O0({type:"pipe",in:$g(t),out:e})}var Se,rg,sc,st,oo,so,ao,co,ng,ig,ti,Yu,og,sg,ag,cg,lg,ug,dg,fg,Xk,pg,hg,mg,gg,yg,vg,Yk,Qk,_g,ys,ac,vs,cc,lc,bg,e0,t0,r0,n0,i0,o0,s0,ed,a0,td,rd,c0,l0,u0,d0,ic,p0,h0,oc,m0,g0,y0,_s,kg,_0,b0,$0,Sg,x0,I0,T0,id,od,O0,P0,R0,j0,C0,N0,sd,WN,KN,U0,JN,lo=w(()=>{Xt();Xt();ga();jo();Xl();ob();Ym();Jk();Se=$("ZodType",(t,e)=>(dK(),ve.init(t,e),t.def=e,t.type=e.type,t),{check(...t){let e=this.def;return this.clone(A.mergeDefs(e,{checks:[...e.checks??[],...t.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...t){return this.check(...t)},clone(t,e){return Be(this,t,e)},brand(){return this},register(t,e){return t.add(this,e),this},refine(t,e){return this.check(D0(t,e))},superRefine(t,e){return this.check(L0(t,e))},overwrite(t){return this.check(rn(t))},optional(){return ot(this)},exactOptional(){return v0(this)},nullable(){return Xu(this)},nullish(){return ot(Xu(this))},nonoptional(t){return S0(this,t)},array(){return Pe(this)},or(t){return rt([this,t])},and(t){return uc(this,t)},transform(t){return tg(this,$g(t))},default(t){return w0(this,t)},prefault(t){return k0(this,t)},catch(t){return E0(this,t)},pipe(t){return tg(this,t)},readonly(){return A0(this)},describe(t){let e=this.clone();return Jt.add(e,{description:t}),e},meta(...t){if(t.length===0)return Jt.get(this);let e=this.clone();return Jt.add(e,t[0]),e},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(t,...e){return e.length===0?t(this):t(this,...e)},get"~standard"(){return A.hide(this,"~standard",{...Zf(this),jsonSchema:{input:pa(this,"input"),output:pa(this,"output")}})},set"~standard"(t){A.own(this,"~standard",t)},parse:function t(e,r){return Lk(this,e,r,{callee:t})},parseAsync:async function t(e,r){return await Uk(this,e,r,{callee:t})},safeParse(t,e){return Mk(this,t,e)},async safeParseAsync(t,e){return Fk(this,t,e)},get spa(){return this?.safeParseAsync},set spa(t){A.own(this,"spa",t)},validate(t,e){return Xs(this,t,e)},validateAsync(t,e){return Ys(this,t,e)},encode:function t(e,r){return Zk(this,e,r,{callee:t})},decode:function t(e,r){return qk(this,e,r,{callee:t})},encodeAsync:async function t(e,r){return await Vk(this,e,r,{callee:t})},decodeAsync:async function t(e,r){return await Bk(this,e,r,{callee:t})},safeEncode(t,e){return Hk(this,t,e)},safeDecode(t,e){return Wk(this,t,e)},async safeEncodeAsync(t,e){return Kk(this,t,e)},async safeDecodeAsync(t,e){return Gk(this,t,e)},toJSONSchema(t){return kb(this,{})(t)},get description(){return Jt.get(this)?.description},get _def(){return this._zod.def}}),rg=$("_ZodString",(t,e)=>{yi.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Ib(t,r,i,n)},A.derived({format:t=>Vt(t).format??null,minLength:t=>Vt(t).minimum??null,maxLength:t=>Vt(t).maximum??null},{regex(...t){return this.check(Mo(...t))},includes(...t){return this.check(qo(...t))},startsWith(...t){return this.check(Vo(...t))},endsWith(...t){return this.check(Bo(...t))},min(...t){return this.check(Or(...t))},max(...t){return this.check(qi(...t))},length(...t){return this.check(Vi(...t))},nonempty(...t){return this.check(Or(1,...t))},lowercase(t){return this.check(Fo(t))},uppercase(t){return this.check(Zo(t))},trim(){return this.check(Go())},normalize(...t){return this.check(Ko(...t))},toLowerCase(){return this.check(Jo())},toUpperCase(){return this.check(Xo())},slugify(){return this.check(fa())}})),sc=$("ZodString",(t,e)=>{yi.init(t,e),rg.init(t,e)},{email(t){return this.check(vl(ng,t))},url(t){return this.check(da(Yu,t))},jwt(t){return this.check(Ll(_g,t))},emoji(t){return this.check(Sl(og,t))},guid(t){return this.check(_l(ig,t))},uuid(t){return this.check(bl(ti,t))},uuidv4(t){return this.check(wl(ti,t))},uuidv6(t){return this.check($l(ti,t))},uuidv7(t){return this.check(kl(ti,t))},nanoid(t){return this.check(xl(sg,t))},cuid(t){return this.check(Il(ag,t))},cuid2(t){return this.check(El(cg,t))},ulid(t){return this.check(Tl(lg,t))},base64(t){return this.check(Cl(gg,t))},base64url(t){return this.check(Nl(yg,t))},xid(t){return this.check(Ol(ug,t))},ksuid(t){return this.check(Pl(dg,t))},ipv4(t){return this.check(Al(fg,t))},ipv6(t){return this.check(Rl(pg,t))},cidrv4(t){return this.check(jl(hg,t))},cidrv6(t){return this.check(zl(mg,t))},e164(t){return this.check(Dl(vg,t))},datetime(t){return this.check(Ul(oo,t))},date(t){return this.check(Ml(so,t))},time(t){return this.check(Fl(ao,t))},duration(t){return this.check(Zl(co,t))}});st=$("ZodStringFormat",(t,e)=>{Xe.init(t,e),rg.init(t,e)}),oo=$("ZodISODateTime",(t,e)=>{G_.init(t,e),st.init(t,e)}),so=$("ZodISODate",(t,e)=>{J_.init(t,e),st.init(t,e)}),ao=$("ZodISOTime",(t,e)=>{X_.init(t,e),st.init(t,e)}),co=$("ZodISODuration",(t,e)=>{Y_.init(t,e),st.init(t,e)}),ng=$("ZodEmail",(t,e)=>{Bf.init(t,e),st.init(t,e)});ig=$("ZodGUID",(t,e)=>{qf.init(t,e),st.init(t,e)});ti=$("ZodUUID",(t,e)=>{Vf.init(t,e),st.init(t,e)});Yu=$("ZodURL",(t,e)=>{Gf.init(t,e),st.init(t,e)});og=$("ZodEmoji",(t,e)=>{Jf.init(t,e),st.init(t,e)});sg=$("ZodNanoID",(t,e)=>{Xf.init(t,e),st.init(t,e)});ag=$("ZodCUID",(t,e)=>{Yf.init(t,e),st.init(t,e)});cg=$("ZodCUID2",(t,e)=>{Qf.init(t,e),st.init(t,e)});lg=$("ZodULID",(t,e)=>{ep.init(t,e),st.init(t,e)});ug=$("ZodXID",(t,e)=>{tp.init(t,e),st.init(t,e)});dg=$("ZodKSUID",(t,e)=>{rp.init(t,e),st.init(t,e)});fg=$("ZodIPv4",(t,e)=>{np.init(t,e),st.init(t,e)});Xk=$("ZodMAC",(t,e)=>{op.init(t,e),st.init(t,e)});pg=$("ZodIPv6",(t,e)=>{ip.init(t,e),st.init(t,e)});hg=$("ZodCIDRv4",(t,e)=>{sp.init(t,e),st.init(t,e)});mg=$("ZodCIDRv6",(t,e)=>{cp.init(t,e),st.init(t,e)});gg=$("ZodBase64",(t,e)=>{up.init(t,e),st.init(t,e)});yg=$("ZodBase64URL",(t,e)=>{fp.init(t,e),st.init(t,e)});vg=$("ZodE164",(t,e)=>{pp.init(t,e),st.init(t,e)});Yk=$("ZodCreditCard",(t,e)=>{mp.init(t,e),st.init(t,e)});Qk=$("ZodIBAN",(t,e)=>{yp.init(t,e),st.init(t,e)});_g=$("ZodJWT",(t,e)=>{_p.init(t,e),st.init(t,e)});ys=$("ZodCustomStringFormat",(t,e)=>{bp.init(t,e),st.init(t,e)});ac=$("ZodNumber",(t,e)=>{ta.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Eb(t,r,i,n),t.isFinite=!0},A.derived({minValue:t=>{let{minimum:e,exclusiveMinimum:r}=Vt(t);return Math.max(e??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:t=>{let{maximum:e,exclusiveMaximum:r}=Vt(t);return Math.min(e??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:t=>{let{isInt:e,multipleOf:r}=Vt(t);return!!e||!!r?.some(Number.isSafeInteger)},format:t=>Vt(t).format??null},{gt(t,e){return this.check(bn(t,e))},gte(t,e){return this.check(gr(t,e))},min(t,e){return this.check(gr(t,e))},lt(t,e){return this.check(_n(t,e))},lte(t,e){return this.check(mr(t,e))},max(t,e){return this.check(mr(t,e))},int(t){return this.check(eg(t))},safe(t){return this.check(eg(t))},positive(t){return this.check(bn(0,t))},nonnegative(t){return this.check(gr(0,t))},negative(t){return this.check(_n(0,t))},nonpositive(t){return this.check(mr(0,t))},multipleOf(t,e){return this.check(vi(t,e))},step(t,e){return this.check(vi(t,e))},finite(){return this}}));vs=$("ZodNumberFormat",(t,e)=>{wp.init(t,e),ac.init(t,e)});cc=$("ZodBoolean",(t,e)=>{Co.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Tb(t,r,i,n)});lc=$("ZodBigInt",(t,e)=>{ol.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Ob(t,r,i,n)},A.derived({minValue:t=>Vt(t).minimum??null,maxValue:t=>Vt(t).maximum??null,format:t=>Vt(t).format??null},{gte(t,e){return this.check(gr(t,e))},min(t,e){return this.check(gr(t,e))},gt(t,e){return this.check(bn(t,e))},lt(t,e){return this.check(_n(t,e))},lte(t,e){return this.check(mr(t,e))},max(t,e){return this.check(mr(t,e))},positive(t){return this.check(bn(BigInt(0),t))},negative(t){return this.check(_n(BigInt(0),t))},nonpositive(t){return this.check(mr(BigInt(0),t))},nonnegative(t){return this.check(gr(BigInt(0),t))},multipleOf(t,e){return this.check(vi(t,e))}}));bg=$("ZodBigIntFormat",(t,e)=>{$p.init(t,e),lc.init(t,e)});e0=$("ZodSymbol",(t,e)=>{kp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Pb(t,r,i,n)});t0=$("ZodUndefined",(t,e)=>{Sp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Rb(t,r,i,n)});r0=$("ZodNull",(t,e)=>{xp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Ab(t,r,i,n)});n0=$("ZodAny",(t,e)=>{Ip.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Cb(t,r,i,n)});i0=$("ZodUnknown",(t,e)=>{Ep.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Nb(t,r,i,n)});o0=$("ZodNever",(t,e)=>{Tp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>zb(t,r,i,n)});s0=$("ZodVoid",(t,e)=>{Op.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>jb(t,r,i,n)});ed=$("ZodDate",(t,e)=>{Pp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Db(t,r,i,n),t.min=(r,i)=>t.check(gr(r,i)),t.max=(r,i)=>t.check(mr(r,i))},A.derived({minDate:t=>{let{minimum:e}=Vt(t);return e?new Date(e):null},maxDate:t=>{let{maximum:e}=Vt(t);return e?new Date(e):null}},{}));a0=$("ZodArray",(t,e)=>{gs(),sl.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Gb(t,r,i,n),t.element=e.element},{min(t,e){return this.check(Or(t,e))},nonempty(t){return this.check(Or(1,t))},max(t,e){return this.check(qi(t,e))},length(t,e){return this.check(Vi(t,e))},unwrap(){return this.element}});td=$("ZodObject",(t,e)=>{gs(),Q_.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Jb(t,r,i,n),A.installLazyProp(t,"shape",r=>r._zod.def.shape,!1)},{keyof(){return er(Object.keys(this._zod.def.shape))},catchall(t){return this.clone(A.mergeDefs(this._zod.def,{catchall:t}))},passthrough(){return this.clone(A.mergeDefs(this._zod.def,{catchall:ct()}))},loose(){return this.clone(A.mergeDefs(this._zod.def,{catchall:ct()}))},strict(){return this.clone(A.mergeDefs(this._zod.def,{catchall:wg()}))},strip(){return this.clone(A.mergeDefs(this._zod.def,{catchall:void 0}))},extend(t){return A.extend(this,t)},safeExtend(t){return A.safeExtend(this,t)},merge(t){return A.merge(this,t)},pick(t){return A.pick(this,t)},omit(t){return A.omit(this,t)},partial(...t){return A.partial(_s,this,t[0])},exactPartial(...t){return A.partial(kg,this,t[0],"exactPartial")},required(...t){return A.required(Sg,this,t[0])}});rd=$("ZodUnion",(t,e)=>{ra.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Fh(t,r,i,n),t.options=e.options});c0=$("ZodXor",(t,e)=>{rd.init(t,e),Rp.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Fh(t,r,i,n),t.options=e.options});l0=$("ZodDiscriminatedUnion",(t,e)=>{rd.init(t,e),al.init(t,e)});u0=$("ZodIntersection",(t,e)=>{jp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Xb(t,r,i,n)});d0=$("ZodTuple",(t,e)=>{gs(),cl.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Yb(t,r,i,n)},{rest(t){return this.clone({...this._zod.def,rest:t})},partial(){let t=this._zod.def;if(t.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...t,items:t.items.map(e=>new _s({type:"optional",innerType:e}))})}});ic=$("ZodRecord",(t,e)=>{gs(),zp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Qb(t,r,i,n),t.keyType=e.keyType,t.valueType=e.valueType});p0=$("ZodMap",(t,e)=>{gs(),Cp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Wb(t,r,i,n),t.keyType=e.keyType,t.valueType=e.valueType,t.min=(...r)=>t.check(wn(...r)),t.nonempty=r=>t.check(wn(1,r)),t.max=(...r)=>t.check(_i(...r)),t.size=(...r)=>t.check(Zi(...r))});h0=$("ZodSet",(t,e)=>{gs(),Np.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Kb(t,r,i,n),t.min=(...r)=>t.check(wn(...r)),t.nonempty=r=>t.check(wn(1,r)),t.max=(...r)=>t.check(_i(...r)),t.size=(...r)=>t.check(Zi(...r))});oc=$("ZodEnum",(t,e)=>{ll.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(i,n,o)=>Lb(t,i,n,o),t.enum=e.entries,t.options=[...t._zod.values];let r=new Set(Object.keys(e.entries));t.extract=(i,n)=>{let o={};for(let s of i)if(r.has(s))o[s]=e.entries[s];else throw new Error(`Key ${s} not found in enum`);return new oc({...e,checks:[],...A.normalizeParams(n),entries:o})},t.exclude=(i,n)=>{let o={...e.entries};for(let s of i)if(r.has(s))delete o[s];else throw new Error(`Key ${s} not found in enum`);return new oc({...e,checks:[],...A.normalizeParams(n),entries:o})}});m0=$("ZodLiteral",(t,e)=>{ul.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Ub(t,r,i,n),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});g0=$("ZodFile",(t,e)=>{Dp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Zb(t,r,i,n),t.min=(r,i)=>t.check(wn(r,i)),t.max=(r,i)=>t.check(_i(r,i)),t.mime=(r,i)=>t.check(Wo(Array.isArray(r)?r:[r],i))});y0=$("ZodTransform",(t,e)=>{gs(),Lp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Hb(t,r,i,n),t._zod.parse=(r,i)=>{if(i.direction==="backward")throw new Fi(t.constructor.name);r.addIssue=o=>{if(typeof o=="string")r.issues.push(A.issue(o,r.value,e));else{let s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),"input"in s||(s.input=r.value),s.inst??(s.inst=t),r.issues.push(A.issue(s))}};let n=e.transform(r.value,r);return n instanceof Promise?n.then(o=>(r.value=o,r)):(r.value=n,r)}});_s=$("ZodOptional",(t,e)=>{na.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Zh(t,r,i,n),t.unwrap=()=>t._zod.def.innerType});kg=$("ZodExactOptional",(t,e)=>{Up.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Zh(t,r,i,n),t.unwrap=()=>t._zod.def.innerType});_0=$("ZodNullable",(t,e)=>{Mp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>ew(t,r,i,n),t.unwrap=()=>t._zod.def.innerType});b0=$("ZodDefault",(t,e)=>{Fp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>nw(t,r,i,n),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});$0=$("ZodPrefault",(t,e)=>{Zp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>iw(t,r,i,n),t.unwrap=()=>t._zod.def.innerType});Sg=$("ZodNonOptional",(t,e)=>{qp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>tw(t,r,i,n),t.unwrap=()=>t._zod.def.innerType});x0=$("ZodSuccess",(t,e)=>{Vp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>qb(t,r,i,n),t.unwrap=()=>t._zod.def.innerType});I0=$("ZodCatch",(t,e)=>{Bp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>ow(t,r,i,n),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});T0=$("ZodNaN",(t,e)=>{Hp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Mb(t,r,i,n)});id=$("ZodPipe",(t,e)=>{dl.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>sw(t,r,i,n),t.in=e.in,t.out=e.out});od=$("ZodCodec",(t,e)=>{id.init(t,e),ia.init(t,e)});O0=$("ZodPreprocess",(t,e)=>{id.init(t,e),tb.init(t,e)}),P0=$("ZodReadonly",(t,e)=>{Wp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>aw(t,r,i,n),t.unwrap=()=>t._zod.def.innerType});R0=$("ZodTemplateLiteral",(t,e)=>{Kp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Fb(t,r,i,n)});j0=$("ZodLazy",(t,e)=>{oa.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>lw(t,r,i,n),t.unwrap=()=>t._zod.def.getter()});C0=$("ZodPromise",(t,e)=>{Jp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>cw(t,r,i,n),t.unwrap=()=>t._zod.def.innerType});N0=$("ZodFunction",(t,e)=>{Gp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Bb(t,r,i,n)});sd=$("ZodCustom",(t,e)=>{Xp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Vb(t,r,i,n)});WN=Dh,KN=Lh,U0=$("ZodInstanceOf",(t,e)=>{sd.init(t,e)},{properties(t,e){return this.check(Ho(t,e))}});JN=(...t)=>Uh({Codec:od,Boolean:cc,String:sc},...t)});function pK(t){Pt({customError:t})}function hK(){return Pt().customError}var fK,M0,YN=w(()=>{Xt();fK={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};M0||(M0={})});var bs={};Jr(bs,{ZodISODate:()=>so,ZodISODateTime:()=>oo,ZodISODuration:()=>co,ZodISOTime:()=>ao,date:()=>gK,datetime:()=>mK,duration:()=>vK,time:()=>yK});function mK(t){return Ul(oo,t)}function gK(t){return Ml(so,t)}function yK(t){return Fl(ao,t)}function vK(t){return Zl(co,t)}var Ig=w(()=>{Xt();lo();lo()});function bK(t,e){let r=t.$schema;return r==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":r==="http://json-schema.org/draft-07/schema#"?"draft-7":r==="http://json-schema.org/draft-04/schema#"?"draft-4":e??"draft-2020-12"}function QN(t,e){return t.map((r,i)=>i<e?r:r.optional())}function wK(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}function $K(t,e){if(!t.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let r=t.slice(1).split("/").filter(Boolean);if(r.length===0)return e.rootSchema;let i=e.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===i){let n=r[1]===void 0?void 0:wK(r[1]);if(!n||!e.defs[n])throw new Error(`Reference not found: ${t}`);return e.defs[n]}throw new Error(`Reference not found: ${t}`)}function kK(t,e){return W.transform(i=>i).check(i=>{let n=i.value;if(typeof n!="object"||n===null||Array.isArray(n))return;let o=Object.getOwnPropertyNames(n);if(e.minProperties!==void 0&&o.length<e.minProperties&&i.issues.push({origin:"object",code:"too_small",minimum:e.minProperties,inclusive:!0,message:`Too small: expected object to have >=${e.minProperties} properties`,input:n,inst:t,continue:!0}),e.maxProperties!==void 0&&o.length>e.maxProperties&&i.issues.push({origin:"object",code:"too_big",maximum:e.maxProperties,inclusive:!0,message:`Too big: expected object to have <=${e.maxProperties} properties`,input:n,inst:t,continue:!0}),e.keySchema)for(let s of o){let a=e.keySchema.safeParse(s);a.success||i.issues.push({code:"invalid_key",origin:"record",issues:a.error.issues,input:s,path:[s],continue:!0})}}).pipe(t)}function F0(t,e){if(t===null)return"z";let r=typeof t;if(r!=="object"){if(r==="number"&&Number.isNaN(t))return null;let i=String(t);return`${r[0]}${i.length}:${i}`}if(e.has(t))return null;e.add(t);try{if(Array.isArray(t)){let o=[];for(let s of t){let a=F0(s,e);if(a===null)return null;o.push(a)}return`a${o.length}:[${o.join(",")}]`}let i=Object.keys(t).sort(),n=[];for(let o of i){let s=F0(t[o],e);if(s===null)return null;n.push(`${o.length}:${o}=${s}`)}return`o${n.length}:{${n.join(",")}}`}finally{e.delete(t)}}function cd(t){return typeof t!="object"||t===null?!1:Array.isArray(t)?t.some(cd):typeof t.$ref=="string"?!0:Object.entries(t).some(([e,r])=>SK.has(e)?cd(r):!xK.has(e)||typeof r!="object"||r===null?!1:Object.values(r).some(cd))}function eD(t){return t===1?"element":"elements"}function IK(t,e){return W.transform(i=>i).check(i=>{let n=i.value;if(Array.isArray(n)){if(e.uniqueItems===!0){let o=new Map;for(let s=0;s<n.length;s++){let a=F0(n[s],new Set);if(a===null)continue;let c=o.get(a);if(c===void 0){o.set(a,s);continue}i.issues.push({code:"custom",message:`Array items must be unique: element at index ${s} duplicates the one at index ${c}`,input:n,path:[s],continue:!0})}}if(e.containsSchema){let o=e.minContains??1,s=e.maxContains!==void 0?e.maxContains+1:Number.POSITIVE_INFINITY,a=0;for(let c of n)if(e.containsSchema.safeParse(c).success&&++a>=s)break;a<o&&i.issues.push({code:"custom",message:`Array must contain at least ${o} matching ${eD(o)}; found ${a}`,input:n,continue:!0}),e.maxContains!==void 0&&a>e.maxContains&&i.issues.push({code:"custom",message:`Array must contain at most ${e.maxContains} matching ${eD(e.maxContains)}`,input:n,continue:!0})}}}).pipe(t)}function tD(t,e){if(t!==!1)return t===void 0||t===!0?W.any():wr(t,e)}function rD(t,e){if(t.not!==void 0){if(typeof t.not=="object"&&Object.keys(t.not).length===0)return W.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(t.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(t.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(t.if!==void 0||t.then!==void 0||t.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(t.dependentSchemas!==void 0||t.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(t.$ref){let n=t.$ref;if(e.refs.has(n))return e.refs.get(n);if(e.processing.has(n))return W.lazy(()=>{if(!e.refs.has(n))throw new Error(`Circular reference not resolved: ${n}`);return e.refs.get(n)});e.processing.add(n);let o=$K(n,e),s=wr(o,e);return e.refs.set(n,s),e.processing.delete(n),s}if(t.enum!==void 0){let n=t.enum;if(e.version==="openapi-3.0"&&t.nullable===!0&&n.length===1&&n[0]===null)return W.null();if(n.length===0)return W.never();if(n.length===1)return W.literal(n[0]);if(n.every(s=>typeof s=="string"))return W.enum(n);let o=n.map(s=>W.literal(s));return o.length<2?o[0]:W.union([o[0],o[1],...o.slice(2)])}if(t.const!==void 0)return W.literal(t.const);let r=t.type;if(Array.isArray(r)){let n=r.map(o=>{let s={...t,type:o};return rD(s,e)});return n.length===0?W.never():n.length===1?n[0]:W.union(n)}if(!r)return W.any();let i;switch(r){case"string":{let n=W.string();if(t.format){let o=t.format;o==="email"?n=n.check(W.email()):o==="uri"||o==="uri-reference"?n=n.check(W.url()):o==="uuid"||o==="guid"?n=n.check(W.uuid()):o==="date-time"?n=n.check(W.iso.datetime({offset:!0})):o==="date"?n=n.check(W.iso.date()):o==="time"?n=n.check(W.regex(EK)):o==="duration"?n=n.check(W.iso.duration()):o==="hostname"?n=n.check(W.hostname()):o==="ipv4"?n=n.check(W.ipv4()):o==="ipv6"?n=n.check(W.ipv6()):o==="mac"?n=n.check(W.mac()):o==="cidr"?n=n.check(W.cidrv4()):o==="cidr-v6"?n=n.check(W.cidrv6()):o==="base64"?n=n.check(W.base64()):o==="base64url"?n=n.check(W.base64url()):o==="e164"?n=n.check(W.e164()):o==="credit_card"?n=n.check(W.creditCard()):o==="iban"?n=n.check(W.iban()):o==="jwt"?n=n.check(W.jwt()):o==="emoji"?n=n.check(W.emoji()):o==="nanoid"?n=n.check(W.nanoid()):o==="cuid"?n=n.check(W.cuid()):o==="cuid2"?n=n.check(W.cuid2()):o==="ulid"?n=n.check(W.ulid()):o==="xid"?n=n.check(W.xid()):o==="ksuid"&&(n=n.check(W.ksuid()))}typeof t.minLength=="number"&&(n=n.min(t.minLength)),typeof t.maxLength=="number"&&(n=n.max(t.maxLength)),t.pattern&&(n=n.regex(new RegExp(t.pattern))),i=n;break}case"number":case"integer":{let n=r==="integer"?W.number().int():W.number();typeof t.minimum=="number"&&t.exclusiveMinimum!==!0&&(n=n.min(t.minimum)),typeof t.maximum=="number"&&t.exclusiveMaximum!==!0&&(n=n.max(t.maximum)),typeof t.exclusiveMinimum=="number"?n=n.gt(t.exclusiveMinimum):t.exclusiveMinimum===!0&&typeof t.minimum=="number"&&(n=n.gt(t.minimum)),typeof t.exclusiveMaximum=="number"?n=n.lt(t.exclusiveMaximum):t.exclusiveMaximum===!0&&typeof t.maximum=="number"&&(n=n.lt(t.maximum)),typeof t.multipleOf=="number"&&(n=n.multipleOf(t.multipleOf)),i=n;break}case"boolean":{i=W.boolean();break}case"null":{i=W.null();break}case"object":{let n={},o=t.properties||{},s=new Set(t.required||[]),a=typeof t.additionalProperties=="object"?wr(t.additionalProperties,e):void 0;for(let[d,p]of Object.entries(o)){let f=wr(p,e);Gt(n,d,s.has(d)?f:f.optional())}if(t.patternProperties){let d=t.patternProperties,p=Object.keys(d),f=[];for(let m of p){let g=wr(d[m],e),y=W.string().regex(new RegExp(m));f.push(W.looseRecord(y,g))}let h=[];if(Object.keys(n).length>0&&h.push(W.object(n).passthrough()),h.push(...f),h.length===0)i=W.object({}).passthrough();else if(h.length===1)i=h[0];else{let m=W.intersection(h[0],h[1]);for(let g=2;g<h.length;g++)m=W.intersection(m,h[g]);i=m}if(t.additionalProperties===!1){let m=Object.keys(n),g=p.map(v=>new RegExp(v)),y=i;i=i.check(v=>{if(!en(v.value))return;let b=[];for(let x of Object.keys(v.value))m.includes(x)||g.some(k=>k.test(x))||b.push(x);b.length&&v.issues.push({code:"unrecognized_keys",keys:b,input:v.value,inst:y})})}}else{let d=W.object(n);t.additionalProperties===!1?i=d.strict():a?i=d.catchall(a):i=d.passthrough()}let c=t.propertyNames!==void 0&&t.propertyNames!==!0,l=typeof t.minProperties=="number"?t.minProperties:void 0,u=typeof t.maxProperties=="number"?t.maxProperties:void 0;if(c||l!==void 0||u!==void 0){let d;if(c){let p=typeof t.propertyNames=="object"&&t.propertyNames.type===void 0?{type:"string",...t.propertyNames}:t.propertyNames;d=wr(p,e)}i=kK(i,{keySchema:d,minProperties:l,maxProperties:u})}break}case"array":{let n=t.prefixItems,o=t.items;if(n&&Array.isArray(n)){let s=typeof t.minItems=="number"?t.minItems:0,a=n.map(d=>wr(d,e)),c=QN(a,s),l=Array.isArray(o)?void 0:tD(o,e),u=W.tuple(c);i=l?u.rest(l):u,typeof t.minItems=="number"&&(i=i.check(W.minLength(t.minItems))),typeof t.maxItems=="number"&&(i=i.check(W.maxLength(t.maxItems)))}else if(Array.isArray(o)){let s=typeof t.minItems=="number"?t.minItems:0,a=o.map(d=>wr(d,e)),c=QN(a,s),l=tD(t.additionalItems,e),u=W.tuple(c);i=l?u.rest(l):u,typeof t.minItems=="number"&&(i=i.check(W.minLength(t.minItems))),typeof t.maxItems=="number"&&(i=i.check(W.maxLength(t.maxItems)))}else if(o!==void 0){let s=wr(o,e),a=W.array(s);typeof t.minItems=="number"&&(a=a.min(t.minItems)),typeof t.maxItems=="number"&&(a=a.max(t.maxItems)),i=a}else i=W.array(W.any());(t.uniqueItems===!0||t.contains!==void 0)&&(i=IK(i,{uniqueItems:t.uniqueItems===!0,containsSchema:t.contains!==void 0?wr(t.contains,e):void 0,minContains:typeof t.minContains=="number"?t.minContains:void 0,maxContains:typeof t.maxContains=="number"?t.maxContains:void 0}));break}default:throw new Error(`Unsupported type: ${r}`)}return i}function wr(t,e){if(typeof t=="boolean")return t?W.any():W.never();let r=rD(t,e),i=t.type||t.enum!==void 0||t.const!==void 0;if(t.anyOf&&Array.isArray(t.anyOf)){let a=t.anyOf.map(l=>wr(l,e)),c=W.union(a);r=i?W.intersection(r,c):c}if(t.oneOf&&Array.isArray(t.oneOf)){let a=t.oneOf.map(l=>wr(l,e)),c=W.xor(a);r=i?W.intersection(r,c):c}if(t.allOf&&Array.isArray(t.allOf))if(t.allOf.length===0)r=i?r:W.any();else{let a=i?r:wr(t.allOf[0],e),c=i?0:1;for(let l=c;l<t.allOf.length;l++)a=W.intersection(a,wr(t.allOf[l],e));r=a}t.nullable===!0&&e.version==="openapi-3.0"&&(r=W.nullable(r)),t.readOnly===!0&&(r=W.readonly(r)),t.default!==void 0&&(r=r.default(t.default));let n={},o=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let a of o)a in t&&(n[a]=t[a]);let s=["contentEncoding","contentMediaType","contentSchema"];for(let a of s)a in t&&(n[a]=t[a]);if(t.type==="object"&&t.$ref===void 0){t.propertyNames!==void 0&&!cd(t.propertyNames)&&(n.propertyNames=t.propertyNames);for(let a of["minProperties","maxProperties"])t[a]!==void 0&&(n[a]=t[a])}if(t.type==="array"&&t.$ref===void 0){t.contains!==void 0&&!cd(t.contains)&&(n.contains=t.contains);for(let a of["uniqueItems","minContains","maxContains"])t[a]!==void 0&&(n[a]=t[a])}for(let a of Object.keys(t))_K.has(a)||Gt(n,a,t[a]);return Object.keys(n).length>0&&e.registry.add(r,n),t.description&&(r=r.describe(t.description)),r}function nD(t,e){if(typeof t=="boolean")return t?W.any():W.never();let r;try{r=JSON.parse(JSON.stringify(t))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let i=bK(r,e?.defaultTarget),n=r.$defs||r.definitions||{},o={version:i,defs:n,refs:new Map,processing:new Set,rootSchema:r,registry:e?.registry??Jt};return wr(r,o)}var W,_K,SK,xK,EK,iD=w(()=>{gl();B();Ym();Ig();lo();W={...dc,...Xm,iso:bs},_K=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);SK=new Set(["items","prefixItems","additionalItems","additionalProperties","contains","propertyNames","not","if","then","else","allOf","anyOf","oneOf","unevaluatedItems","unevaluatedProperties","contentSchema"]),xK=new Set(["properties","patternProperties","dependentSchemas","dependencies","$defs","definitions"]);EK=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/});function oD(t){return eu(t,{object:e=>e.partial(),union:e=>{let r=e._zod.def;return r.discriminator===void 0?e:rt(r.options)}})}var sD=w(()=>{dw();lo()});function TK(t,e){if(!e?.length)return t;let r=t._zod.def;return Be(t,Qr(r,{checks:[...r.checks??[],...e]}),{parent:!0})}function aD(t){return TK(t.out,t.checks)}function OK(t){return t.in._zod.traits.has("$ZodTransform")?aD(t):t.in}function cD(t){return eu(t,{pipe:e=>OK(e._zod.def),default:(e,r)=>r?ot(e._zod.def.innerType):e,catch:(e,r)=>r?e._zod.def.innerType:e})}function lD(t){return eu(t,{pipe:e=>aD(e._zod.def),prefault:(e,r)=>r?e._zod.def.innerType:e})}var uD=w(()=>{B();dw();lo()});var Z0={};Jr(Z0,{bigint:()=>jK,boolean:()=>RK,date:()=>zK,number:()=>AK,string:()=>PK});function PK(t){return mb(sc,t)}function AK(t){return yb(ac,t)}function RK(t){return vb(cc,t)}function jK(t){return _b(lc,t)}function zK(t){return bb(ed,t)}var dD=w(()=>{Xt();lo()});var yt={};Jr(yt,{$brand:()=>zv,$input:()=>lb,$output:()=>cb,INVALID:()=>hr,NEVER:()=>jv,TimePrecision:()=>gb,ZodAny:()=>n0,ZodArray:()=>a0,ZodBase64:()=>gg,ZodBase64URL:()=>yg,ZodBigInt:()=>lc,ZodBigIntFormat:()=>bg,ZodBoolean:()=>cc,ZodCIDRv4:()=>hg,ZodCIDRv6:()=>mg,ZodCUID:()=>ag,ZodCUID2:()=>cg,ZodCatch:()=>I0,ZodCodec:()=>od,ZodCompileAsyncError:()=>vn,ZodCompileUnsupportedError:()=>je,ZodCreditCard:()=>Yk,ZodCustom:()=>sd,ZodCustomStringFormat:()=>ys,ZodDate:()=>ed,ZodDefault:()=>b0,ZodDiscriminatedUnion:()=>l0,ZodE164:()=>vg,ZodEmail:()=>ng,ZodEmoji:()=>og,ZodEnum:()=>oc,ZodError:()=>lK,ZodExactOptional:()=>kg,ZodFile:()=>g0,ZodFirstPartyTypeKind:()=>M0,ZodFunction:()=>N0,ZodGUID:()=>ig,ZodIBAN:()=>Qk,ZodIPv4:()=>fg,ZodIPv6:()=>pg,ZodISODate:()=>so,ZodISODateTime:()=>oo,ZodISODuration:()=>co,ZodISOTime:()=>ao,ZodInstanceOf:()=>U0,ZodIntersection:()=>u0,ZodIssueCode:()=>fK,ZodJWT:()=>_g,ZodKSUID:()=>dg,ZodLazy:()=>j0,ZodLiteral:()=>m0,ZodMAC:()=>Xk,ZodMap:()=>p0,ZodNaN:()=>T0,ZodNanoID:()=>sg,ZodNever:()=>o0,ZodNonOptional:()=>Sg,ZodNull:()=>r0,ZodNullable:()=>_0,ZodNumber:()=>ac,ZodNumberFormat:()=>vs,ZodObject:()=>td,ZodOptional:()=>_s,ZodPipe:()=>id,ZodPrefault:()=>$0,ZodPreprocess:()=>O0,ZodPromise:()=>C0,ZodReadonly:()=>P0,ZodRealError:()=>zr,ZodRecord:()=>ic,ZodSet:()=>h0,ZodString:()=>sc,ZodStringFormat:()=>st,ZodSuccess:()=>x0,ZodSymbol:()=>e0,ZodTemplateLiteral:()=>R0,ZodTransform:()=>y0,ZodTuple:()=>d0,ZodType:()=>Se,ZodULID:()=>lg,ZodURL:()=>Yu,ZodUUID:()=>ti,ZodUndefined:()=>t0,ZodUnion:()=>rd,ZodUnknown:()=>i0,ZodVoid:()=>s0,ZodXID:()=>ug,ZodXor:()=>c0,_ZodString:()=>rg,_default:()=>w0,_function:()=>BN,any:()=>IN,array:()=>Pe,base64:()=>sN,base64url:()=>aN,bigint:()=>wN,boolean:()=>Nt,catch:()=>E0,check:()=>HN,cidrv4:()=>iN,cidrv6:()=>oN,clone:()=>Be,codec:()=>FN,coerce:()=>Z0,compile:()=>pb,config:()=>Pt,core:()=>$n,creditCard:()=>lN,cuid:()=>JC,cuid2:()=>XC,currencyCode:()=>mN,custom:()=>xg,date:()=>TN,decode:()=>qk,decodeAsync:()=>Bk,deepPartial:()=>oD,describe:()=>WN,discriminatedUnion:()=>nd,e164:()=>cN,email:()=>MC,emoji:()=>KC,encode:()=>Zk,encodeAsync:()=>Vk,endsWith:()=>Bo,enum:()=>er,exactOptional:()=>v0,file:()=>DN,flattenError:()=>Kc,float32:()=>yN,float64:()=>vN,formatError:()=>Gc,fromJSONSchema:()=>nD,function:()=>BN,getDiscriminatedOption:()=>eb,getErrorMap:()=>hK,globalRegistry:()=>Jt,gt:()=>bn,gte:()=>gr,guid:()=>FC,hash:()=>gN,hex:()=>hN,hostname:()=>pN,httpUrl:()=>WC,iban:()=>uN,includes:()=>qo,input:()=>cD,instanceof:()=>GN,int:()=>eg,int32:()=>_N,int64:()=>$N,intersection:()=>uc,invertCodec:()=>ZN,ipv4:()=>tN,ipv6:()=>nN,iso:()=>bs,json:()=>XN,jwt:()=>dN,keyof:()=>ON,ksuid:()=>eN,lazy:()=>z0,length:()=>Vi,literal:()=>se,locales:()=>la,looseObject:()=>Qt,looseRecord:()=>jN,lowercase:()=>Fo,lt:()=>_n,lte:()=>mr,mac:()=>rN,map:()=>zN,maxLength:()=>qi,maxSize:()=>_i,memoizer:()=>hl,meta:()=>KN,mime:()=>Wo,minLength:()=>Or,minSize:()=>wn,multipleOf:()=>vi,nan:()=>MN,nanoid:()=>GC,nativeEnum:()=>NN,negative:()=>Hl,never:()=>wg,nonnegative:()=>Kl,nonoptional:()=>S0,nonpositive:()=>Wl,normalize:()=>Ko,null:()=>Qu,nullable:()=>Xu,nullish:()=>LN,number:()=>Ke,object:()=>K,optional:()=>ot,output:()=>lD,overwrite:()=>rn,parse:()=>Lk,parseAsync:()=>Uk,partialRecord:()=>RN,pipe:()=>tg,positive:()=>Bl,prefault:()=>k0,preprocess:()=>ad,prettifyError:()=>Uv,promise:()=>VN,properties:()=>Ho,property:()=>Gl,readonly:()=>A0,record:()=>at,refine:()=>D0,regex:()=>Mo,regexes:()=>Fr,registry:()=>lh,safeDecode:()=>Wk,safeDecodeAsync:()=>Gk,safeEncode:()=>Hk,safeEncodeAsync:()=>Kk,safeParse:()=>Mk,safeParseAsync:()=>Fk,set:()=>CN,setErrorMap:()=>pK,size:()=>Zi,slugify:()=>fa,startsWith:()=>Vo,strictObject:()=>PN,string:()=>P,stringFormat:()=>fN,stringbool:()=>JN,success:()=>UN,superRefine:()=>L0,symbol:()=>SN,templateLiteral:()=>qN,toJSONSchema:()=>Yo,toLowerCase:()=>Jo,toUpperCase:()=>Xo,toZod:()=>Mc,transform:()=>$g,treeifyError:()=>Lv,trim:()=>Go,tuple:()=>f0,uint32:()=>bN,uint64:()=>kN,ulid:()=>YC,undefined:()=>xN,union:()=>rt,unknown:()=>ct,uppercase:()=>Zo,url:()=>HC,util:()=>A,uuid:()=>ZC,uuidv4:()=>qC,uuidv6:()=>VC,uuidv7:()=>BC,validate:()=>Xs,validateAsync:()=>Ys,void:()=>EN,withParser:()=>uh,xid:()=>QC,xor:()=>AN});var Eg=w(()=>{Xt();lo();Ym();Dk();Jk();YN();Xt();ga();iD();sD();uD();ah();Ig();Ig();dD()});var fD=w(()=>{Eg()});var pD=w(()=>{fD()});function PD(t){if(t.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${t.params.ref.type}`)}function AD(t){if(t.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${t.params.ref.type}`)}var V0,hD,uo,Og,Bt,mD,gD,cle,NK,DK,B0,Kr,ld,yD,tr,ln,un,rr,Pg,vD,H0,_D,bD,W0,ud,ae,K0,wD,$D,lle,Ag,LK,Rg,UK,dd,fc,kD,MK,FK,ZK,qK,VK,BK,G0,HK,WK,J0,jg,KK,GK,zg,JK,fd,pd,XK,hd,pc,YK,md,Cg,Ng,Dg,ule,Lg,Ug,Mg,SD,xD,ID,X0,ED,gd,hc,TD,QK,Fg,eG,Zg,tG,Y0,rG,qg,nG,iG,oG,sG,aG,cG,lG,uG,dG,fG,Vg,pG,hG,Bg,Q0,eS,tS,mG,gG,yG,rS,vG,_G,bG,wG,$G,OD,Hg,kG,Wg,dle,SG,mc,xG,fle,yd,IG,nS,EG,TG,OG,PG,AG,RG,jG,Tg,zG,CG,NG,vd,iS,DG,LG,UG,MG,FG,ZG,qG,VG,BG,HG,WG,KG,GG,JG,XG,YG,QG,eJ,gc,tJ,rJ,nJ,Kg,iJ,oJ,sJ,oS,aJ,ple,hle,mle,gle,yle,vle,te,q0,yc=w(()=>{pD();V0="2025-11-25",hD=[V0,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],uo="io.modelcontextprotocol/related-task",Og="2.0",Bt=xg(t=>t!==null&&(typeof t=="object"||typeof t=="function")),mD=rt([P(),Ke().int()]),gD=P(),cle=Qt({ttl:Ke().optional(),pollInterval:Ke().optional()}),NK=K({ttl:Ke().optional()}),DK=K({taskId:P()}),B0=Qt({progressToken:mD.optional(),[uo]:DK.optional()}),Kr=K({_meta:B0.optional()}),ld=Kr.extend({task:NK.optional()}),yD=t=>ld.safeParse(t).success,tr=K({method:P(),params:Kr.loose().optional()}),ln=K({_meta:B0.optional()}),un=K({method:P(),params:ln.loose().optional()}),rr=Qt({_meta:B0.optional()}),Pg=rt([P(),Ke().int()]),vD=K({jsonrpc:se(Og),id:Pg,...tr.shape}).strict(),H0=t=>vD.safeParse(t).success,_D=K({jsonrpc:se(Og),...un.shape}).strict(),bD=t=>_D.safeParse(t).success,W0=K({jsonrpc:se(Og),id:Pg,result:rr}).strict(),ud=t=>W0.safeParse(t).success;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError",t[t.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(ae||(ae={}));K0=K({jsonrpc:se(Og),id:Pg.optional(),error:K({code:Ke().int(),message:P(),data:ct().optional()})}).strict(),wD=t=>K0.safeParse(t).success,$D=rt([vD,_D,W0,K0]),lle=rt([W0,K0]),Ag=rr.strict(),LK=ln.extend({requestId:Pg.optional(),reason:P().optional()}),Rg=un.extend({method:se("notifications/cancelled"),params:LK}),UK=K({src:P(),mimeType:P().optional(),sizes:Pe(P()).optional(),theme:er(["light","dark"]).optional()}),dd=K({icons:Pe(UK).optional()}),fc=K({name:P(),title:P().optional()}),kD=fc.extend({...fc.shape,...dd.shape,version:P(),websiteUrl:P().optional(),description:P().optional()}),MK=uc(K({applyDefaults:Nt().optional()}),at(P(),ct())),FK=ad(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,uc(K({form:MK.optional(),url:Bt.optional()}),at(P(),ct()).optional())),ZK=Qt({list:Bt.optional(),cancel:Bt.optional(),requests:Qt({sampling:Qt({createMessage:Bt.optional()}).optional(),elicitation:Qt({create:Bt.optional()}).optional()}).optional()}),qK=Qt({list:Bt.optional(),cancel:Bt.optional(),requests:Qt({tools:Qt({call:Bt.optional()}).optional()}).optional()}),VK=K({experimental:at(P(),Bt).optional(),sampling:K({context:Bt.optional(),tools:Bt.optional()}).optional(),elicitation:FK.optional(),roots:K({listChanged:Nt().optional()}).optional(),tasks:ZK.optional(),extensions:at(P(),Bt).optional()}),BK=Kr.extend({protocolVersion:P(),capabilities:VK,clientInfo:kD}),G0=tr.extend({method:se("initialize"),params:BK}),HK=K({experimental:at(P(),Bt).optional(),logging:Bt.optional(),completions:Bt.optional(),prompts:K({listChanged:Nt().optional()}).optional(),resources:K({subscribe:Nt().optional(),listChanged:Nt().optional()}).optional(),tools:K({listChanged:Nt().optional()}).optional(),tasks:qK.optional(),extensions:at(P(),Bt).optional()}),WK=rr.extend({protocolVersion:P(),capabilities:HK,serverInfo:kD,instructions:P().optional()}),J0=un.extend({method:se("notifications/initialized"),params:ln.optional()}),jg=tr.extend({method:se("ping"),params:Kr.optional()}),KK=K({progress:Ke(),total:ot(Ke()),message:ot(P())}),GK=K({...ln.shape,...KK.shape,progressToken:mD}),zg=un.extend({method:se("notifications/progress"),params:GK}),JK=Kr.extend({cursor:gD.optional()}),fd=tr.extend({params:JK.optional()}),pd=rr.extend({nextCursor:gD.optional()}),XK=er(["working","input_required","completed","failed","cancelled"]),hd=K({taskId:P(),status:XK,ttl:rt([Ke(),Qu()]),createdAt:P(),lastUpdatedAt:P(),pollInterval:ot(Ke()),statusMessage:ot(P())}),pc=rr.extend({task:hd}),YK=ln.merge(hd),md=un.extend({method:se("notifications/tasks/status"),params:YK}),Cg=tr.extend({method:se("tasks/get"),params:Kr.extend({taskId:P()})}),Ng=rr.merge(hd),Dg=tr.extend({method:se("tasks/result"),params:Kr.extend({taskId:P()})}),ule=rr.loose(),Lg=fd.extend({method:se("tasks/list")}),Ug=pd.extend({tasks:Pe(hd)}),Mg=tr.extend({method:se("tasks/cancel"),params:Kr.extend({taskId:P()})}),SD=rr.merge(hd),xD=K({uri:P(),mimeType:ot(P()),_meta:at(P(),ct()).optional()}),ID=xD.extend({text:P()}),X0=P().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),ED=xD.extend({blob:X0}),gd=er(["user","assistant"]),hc=K({audience:Pe(gd).optional(),priority:Ke().min(0).max(1).optional(),lastModified:bs.datetime({offset:!0}).optional()}),TD=K({...fc.shape,...dd.shape,uri:P(),description:ot(P()),mimeType:ot(P()),size:ot(Ke()),annotations:hc.optional(),_meta:ot(Qt({}))}),QK=K({...fc.shape,...dd.shape,uriTemplate:P(),description:ot(P()),mimeType:ot(P()),annotations:hc.optional(),_meta:ot(Qt({}))}),Fg=fd.extend({method:se("resources/list")}),eG=pd.extend({resources:Pe(TD)}),Zg=fd.extend({method:se("resources/templates/list")}),tG=pd.extend({resourceTemplates:Pe(QK)}),Y0=Kr.extend({uri:P()}),rG=Y0,qg=tr.extend({method:se("resources/read"),params:rG}),nG=rr.extend({contents:Pe(rt([ID,ED]))}),iG=un.extend({method:se("notifications/resources/list_changed"),params:ln.optional()}),oG=Y0,sG=tr.extend({method:se("resources/subscribe"),params:oG}),aG=Y0,cG=tr.extend({method:se("resources/unsubscribe"),params:aG}),lG=ln.extend({uri:P()}),uG=un.extend({method:se("notifications/resources/updated"),params:lG}),dG=K({name:P(),description:ot(P()),required:ot(Nt())}),fG=K({...fc.shape,...dd.shape,description:ot(P()),arguments:ot(Pe(dG)),_meta:ot(Qt({}))}),Vg=fd.extend({method:se("prompts/list")}),pG=pd.extend({prompts:Pe(fG)}),hG=Kr.extend({name:P(),arguments:at(P(),P()).optional()}),Bg=tr.extend({method:se("prompts/get"),params:hG}),Q0=K({type:se("text"),text:P(),annotations:hc.optional(),_meta:at(P(),ct()).optional()}),eS=K({type:se("image"),data:X0,mimeType:P(),annotations:hc.optional(),_meta:at(P(),ct()).optional()}),tS=K({type:se("audio"),data:X0,mimeType:P(),annotations:hc.optional(),_meta:at(P(),ct()).optional()}),mG=K({type:se("tool_use"),name:P(),id:P(),input:at(P(),ct()),_meta:at(P(),ct()).optional()}),gG=K({type:se("resource"),resource:rt([ID,ED]),annotations:hc.optional(),_meta:at(P(),ct()).optional()}),yG=TD.extend({type:se("resource_link")}),rS=rt([Q0,eS,tS,yG,gG]),vG=K({role:gd,content:rS}),_G=rr.extend({description:P().optional(),messages:Pe(vG)}),bG=un.extend({method:se("notifications/prompts/list_changed"),params:ln.optional()}),wG=K({title:P().optional(),readOnlyHint:Nt().optional(),destructiveHint:Nt().optional(),idempotentHint:Nt().optional(),openWorldHint:Nt().optional()}),$G=K({taskSupport:er(["required","optional","forbidden"]).optional()}),OD=K({...fc.shape,...dd.shape,description:P().optional(),inputSchema:K({type:se("object"),properties:at(P(),Bt).optional(),required:Pe(P()).optional()}).catchall(ct()),outputSchema:K({type:se("object"),properties:at(P(),Bt).optional(),required:Pe(P()).optional()}).catchall(ct()).optional(),annotations:wG.optional(),execution:$G.optional(),_meta:at(P(),ct()).optional()}),Hg=fd.extend({method:se("tools/list")}),kG=pd.extend({tools:Pe(OD)}),Wg=rr.extend({content:Pe(rS).default([]),structuredContent:at(P(),ct()).optional(),isError:Nt().optional()}),dle=Wg.or(rr.extend({toolResult:ct()})),SG=ld.extend({name:P(),arguments:at(P(),ct()).optional()}),mc=tr.extend({method:se("tools/call"),params:SG}),xG=un.extend({method:se("notifications/tools/list_changed"),params:ln.optional()}),fle=K({autoRefresh:Nt().default(!0),debounceMs:Ke().int().nonnegative().default(300)}),yd=er(["debug","info","notice","warning","error","critical","alert","emergency"]),IG=Kr.extend({level:yd}),nS=tr.extend({method:se("logging/setLevel"),params:IG}),EG=ln.extend({level:yd,logger:P().optional(),data:ct()}),TG=un.extend({method:se("notifications/message"),params:EG}),OG=K({name:P().optional()}),PG=K({hints:Pe(OG).optional(),costPriority:Ke().min(0).max(1).optional(),speedPriority:Ke().min(0).max(1).optional(),intelligencePriority:Ke().min(0).max(1).optional()}),AG=K({mode:er(["auto","required","none"]).optional()}),RG=K({type:se("tool_result"),toolUseId:P().describe("The unique identifier for the corresponding tool call."),content:Pe(rS).default([]),structuredContent:K({}).loose().optional(),isError:Nt().optional(),_meta:at(P(),ct()).optional()}),jG=nd("type",[Q0,eS,tS]),Tg=nd("type",[Q0,eS,tS,mG,RG]),zG=K({role:gd,content:rt([Tg,Pe(Tg)]),_meta:at(P(),ct()).optional()}),CG=ld.extend({messages:Pe(zG),modelPreferences:PG.optional(),systemPrompt:P().optional(),includeContext:er(["none","thisServer","allServers"]).optional(),temperature:Ke().optional(),maxTokens:Ke().int(),stopSequences:Pe(P()).optional(),metadata:Bt.optional(),tools:Pe(OD).optional(),toolChoice:AG.optional()}),NG=tr.extend({method:se("sampling/createMessage"),params:CG}),vd=rr.extend({model:P(),stopReason:ot(er(["endTurn","stopSequence","maxTokens"]).or(P())),role:gd,content:jG}),iS=rr.extend({model:P(),stopReason:ot(er(["endTurn","stopSequence","maxTokens","toolUse"]).or(P())),role:gd,content:rt([Tg,Pe(Tg)])}),DG=K({type:se("boolean"),title:P().optional(),description:P().optional(),default:Nt().optional()}),LG=K({type:se("string"),title:P().optional(),description:P().optional(),minLength:Ke().optional(),maxLength:Ke().optional(),format:er(["email","uri","date","date-time"]).optional(),default:P().optional()}),UG=K({type:er(["number","integer"]),title:P().optional(),description:P().optional(),minimum:Ke().optional(),maximum:Ke().optional(),default:Ke().optional()}),MG=K({type:se("string"),title:P().optional(),description:P().optional(),enum:Pe(P()),default:P().optional()}),FG=K({type:se("string"),title:P().optional(),description:P().optional(),oneOf:Pe(K({const:P(),title:P()})),default:P().optional()}),ZG=K({type:se("string"),title:P().optional(),description:P().optional(),enum:Pe(P()),enumNames:Pe(P()).optional(),default:P().optional()}),qG=rt([MG,FG]),VG=K({type:se("array"),title:P().optional(),description:P().optional(),minItems:Ke().optional(),maxItems:Ke().optional(),items:K({type:se("string"),enum:Pe(P())}),default:Pe(P()).optional()}),BG=K({type:se("array"),title:P().optional(),description:P().optional(),minItems:Ke().optional(),maxItems:Ke().optional(),items:K({anyOf:Pe(K({const:P(),title:P()}))}),default:Pe(P()).optional()}),HG=rt([VG,BG]),WG=rt([ZG,qG,HG]),KG=rt([WG,DG,LG,UG]),GG=ld.extend({mode:se("form").optional(),message:P(),requestedSchema:K({type:se("object"),properties:at(P(),KG),required:Pe(P()).optional()})}),JG=ld.extend({mode:se("url"),message:P(),elicitationId:P(),url:P().url()}),XG=rt([GG,JG]),YG=tr.extend({method:se("elicitation/create"),params:XG}),QG=ln.extend({elicitationId:P()}),eJ=un.extend({method:se("notifications/elicitation/complete"),params:QG}),gc=rr.extend({action:er(["accept","decline","cancel"]),content:ad(t=>t===null?void 0:t,at(P(),rt([P(),Ke(),Nt(),Pe(P())])).optional())}),tJ=K({type:se("ref/resource"),uri:P()}),rJ=K({type:se("ref/prompt"),name:P()}),nJ=Kr.extend({ref:rt([rJ,tJ]),argument:K({name:P(),value:P()}),context:K({arguments:at(P(),P()).optional()}).optional()}),Kg=tr.extend({method:se("completion/complete"),params:nJ});iJ=rr.extend({completion:Qt({values:Pe(P()).max(100),total:ot(Ke().int()),hasMore:ot(Nt())})}),oJ=K({uri:P().startsWith("file://"),name:P().optional(),_meta:at(P(),ct()).optional()}),sJ=tr.extend({method:se("roots/list"),params:Kr.optional()}),oS=rr.extend({roots:Pe(oJ)}),aJ=un.extend({method:se("notifications/roots/list_changed"),params:ln.optional()}),ple=rt([jg,G0,Kg,nS,Bg,Vg,Fg,Zg,qg,sG,cG,mc,Hg,Cg,Dg,Lg,Mg]),hle=rt([Rg,zg,J0,aJ,md]),mle=rt([Ag,vd,iS,gc,oS,Ng,Ug,pc]),gle=rt([jg,NG,YG,sJ,Cg,Dg,Lg,Mg]),yle=rt([Rg,zg,TG,uG,iG,xG,bG,md,eJ]),vle=rt([Ag,WK,iJ,_G,pG,eG,tG,nG,Wg,kG,Ng,Ug,pc]),te=class t extends Error{constructor(e,r,i){super(`MCP error ${e}: ${r}`),this.code=e,this.data=i,this.name="McpError"}static fromError(e,r,i){if(e===ae.UrlElicitationRequired&&i){let n=i;if(n.elicitations)return new q0(n.elicitations,r)}return new t(e,r,i)}},q0=class extends te{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(ae.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}}});function fo(t){return t==="completed"||t==="failed"||t==="cancelled"}var RD=w(()=>{});var zD,jD,CD,Gg=w(()=>{zD=Symbol("Let zodToJsonSchema decide on which parser to use"),jD={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"},CD=t=>typeof t=="string"?{...jD,name:t}:{...jD,...t}});var ND,sS=w(()=>{Gg();ND=t=>{let e=CD(t),r=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,flags:{hasReferencedOpenAiAnyType:!1},currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([i,n])=>[n._def,{def:n._def,path:[...e.basePath,e.definitionPath,i],jsonSchema:void 0}]))}}});function aS(t,e,r,i){i?.errorMessages&&r&&(t.errorMessage={...t.errorMessage,[e]:r})}function Me(t,e,r,i,n){t[e]=r,aS(t,e,i,n)}var po=w(()=>{});var Jg,Xg=w(()=>{Jg=(t,e)=>{let r=0;for(;r<t.length&&r<e.length&&t[r]===e[r];r++);return[(t.length-r).toString(),...e.slice(r)].join("/")}});function $t(t){if(t.target!=="openAi")return{};let e=[...t.basePath,t.definitionPath,t.openAiAnyTypeName];return t.flags.hasReferencedOpenAiAnyType=!0,{$ref:t.$refStrategy==="relative"?Jg(e,t.currentPath):e.join("/")}}var dn=w(()=>{Xg()});function DD(t,e){let r={type:"array"};return t.type?._def&&t.type?._def?.typeName!==Z.ZodAny&&(r.items=ge(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&Me(r,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&Me(r,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(Me(r,"minItems",t.exactLength.value,t.exactLength.message,e),Me(r,"maxItems",t.exactLength.value,t.exactLength.message,e)),r}var cS=w(()=>{Gu();po();Ft()});function LD(t,e){let r={type:"integer",format:"int64"};if(!t.checks)return r;for(let i of t.checks)switch(i.kind){case"min":e.target==="jsonSchema7"?i.inclusive?Me(r,"minimum",i.value,i.message,e):Me(r,"exclusiveMinimum",i.value,i.message,e):(i.inclusive||(r.exclusiveMinimum=!0),Me(r,"minimum",i.value,i.message,e));break;case"max":e.target==="jsonSchema7"?i.inclusive?Me(r,"maximum",i.value,i.message,e):Me(r,"exclusiveMaximum",i.value,i.message,e):(i.inclusive||(r.exclusiveMaximum=!0),Me(r,"maximum",i.value,i.message,e));break;case"multipleOf":Me(r,"multipleOf",i.value,i.message,e);break}return r}var lS=w(()=>{po()});function UD(){return{type:"boolean"}}var uS=w(()=>{});function Yg(t,e){return ge(t.type._def,e)}var Qg=w(()=>{Ft()});var MD,dS=w(()=>{Ft();MD=(t,e)=>ge(t.innerType._def,e)});function fS(t,e,r){let i=r??e.dateStrategy;if(Array.isArray(i))return{anyOf:i.map((n,o)=>fS(t,e,n))};switch(i){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return cJ(t,e)}}var cJ,pS=w(()=>{po();cJ=(t,e)=>{let r={type:"integer",format:"unix-time"};if(e.target==="openApi3")return r;for(let i of t.checks)switch(i.kind){case"min":Me(r,"minimum",i.value,i.message,e);break;case"max":Me(r,"maximum",i.value,i.message,e);break}return r}});function FD(t,e){return{...ge(t.innerType._def,e),default:t.defaultValue()}}var hS=w(()=>{Ft()});function ZD(t,e){return e.effectStrategy==="input"?ge(t.schema._def,e):$t(e)}var mS=w(()=>{Ft();dn()});function qD(t){return{type:"string",enum:Array.from(t.values)}}var gS=w(()=>{});function VD(t,e){let r=[ge(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),ge(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(o=>!!o),i=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,n=[];return r.forEach(o=>{if(lJ(o))n.push(...o.allOf),o.unevaluatedProperties===void 0&&(i=void 0);else{let s=o;if("additionalProperties"in o&&o.additionalProperties===!1){let{additionalProperties:a,...c}=o;s=c}else i=void 0;n.push(s)}}),n.length?{allOf:n,...i}:void 0}var lJ,yS=w(()=>{Ft();lJ=t=>"type"in t&&t.type==="string"?!1:"allOf"in t});function BD(t,e){let r=typeof t.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[t.value]}:{type:r==="bigint"?"integer":r,const:t.value}}var vS=w(()=>{});function ey(t,e){let r={type:"string"};if(t.checks)for(let i of t.checks)switch(i.kind){case"min":Me(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,i.value):i.value,i.message,e);break;case"max":Me(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,i.value):i.value,i.message,e);break;case"email":switch(e.emailStrategy){case"format:email":Rn(r,"email",i.message,e);break;case"format:idn-email":Rn(r,"idn-email",i.message,e);break;case"pattern:zod":$r(r,An.email,i.message,e);break}break;case"url":Rn(r,"uri",i.message,e);break;case"uuid":Rn(r,"uuid",i.message,e);break;case"regex":$r(r,i.regex,i.message,e);break;case"cuid":$r(r,An.cuid,i.message,e);break;case"cuid2":$r(r,An.cuid2,i.message,e);break;case"startsWith":$r(r,RegExp(`^${bS(i.value,e)}`),i.message,e);break;case"endsWith":$r(r,RegExp(`${bS(i.value,e)}$`),i.message,e);break;case"datetime":Rn(r,"date-time",i.message,e);break;case"date":Rn(r,"date",i.message,e);break;case"time":Rn(r,"time",i.message,e);break;case"duration":Rn(r,"duration",i.message,e);break;case"length":Me(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,i.value):i.value,i.message,e),Me(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,i.value):i.value,i.message,e);break;case"includes":{$r(r,RegExp(bS(i.value,e)),i.message,e);break}case"ip":{i.version!=="v6"&&Rn(r,"ipv4",i.message,e),i.version!=="v4"&&Rn(r,"ipv6",i.message,e);break}case"base64url":$r(r,An.base64url,i.message,e);break;case"jwt":$r(r,An.jwt,i.message,e);break;case"cidr":{i.version!=="v6"&&$r(r,An.ipv4Cidr,i.message,e),i.version!=="v4"&&$r(r,An.ipv6Cidr,i.message,e);break}case"emoji":$r(r,An.emoji(),i.message,e);break;case"ulid":{$r(r,An.ulid,i.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{Rn(r,"binary",i.message,e);break}case"contentEncoding:base64":{Me(r,"contentEncoding","base64",i.message,e);break}case"pattern:zod":{$r(r,An.base64,i.message,e);break}}break}case"nanoid":$r(r,An.nanoid,i.message,e);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function bS(t,e){return e.patternStrategy==="escape"?dJ(t):t}function dJ(t){let e="";for(let r=0;r<t.length;r++)uJ.has(t[r])||(e+="\\"),e+=t[r];return e}function Rn(t,e,r,i){t.format||t.anyOf?.some(n=>n.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format,...t.errorMessage&&i.errorMessages&&{errorMessage:{format:t.errorMessage.format}}}),delete t.format,t.errorMessage&&(delete t.errorMessage.format,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.anyOf.push({format:e,...r&&i.errorMessages&&{errorMessage:{format:r}}})):Me(t,"format",e,r,i)}function $r(t,e,r,i){t.pattern||t.allOf?.some(n=>n.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern,...t.errorMessage&&i.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}}}),delete t.pattern,t.errorMessage&&(delete t.errorMessage.pattern,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.allOf.push({pattern:HD(e,i),...r&&i.errorMessages&&{errorMessage:{pattern:r}}})):Me(t,"pattern",HD(e,i),r,i)}function HD(t,e){if(!e.applyRegexFlags||!t.flags)return t.source;let r={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},i=r.i?t.source.toLowerCase():t.source,n="",o=!1,s=!1,a=!1;for(let c=0;c<i.length;c++){if(o){n+=i[c],o=!1;continue}if(r.i){if(s){if(i[c].match(/[a-z]/)){a?(n+=i[c],n+=`${i[c-2]}-${i[c]}`.toUpperCase(),a=!1):i[c+1]==="-"&&i[c+2]?.match(/[a-z]/)?(n+=i[c],a=!0):n+=`${i[c]}${i[c].toUpperCase()}`;continue}}else if(i[c].match(/[a-z]/)){n+=`[${i[c]}${i[c].toUpperCase()}]`;continue}}if(r.m){if(i[c]==="^"){n+=`(^|(?<=[\r
119
+ `).join(""),{flag:"a"})),i)}async function Tu(t,e){let r=`${t}@${e}`;if(Rm.has(r))return Rm.get(r);let i=null;if(Mt){let{data:n,error:o}=await Mt.client.from("generations").select("snapshot, canon_version").eq("project_id",Mt.projectId).eq("component",t).eq("gen",e).maybeSingle();if(o)throw new Error(`couldn't read a version of ${t}: ${o.message}`);i=n&&(n.canon_version??5)===5?n.snapshot:null}return!i&&Ua(ek(t,e))&&(i=JSON.parse(jm(ek(t,e),"utf8"))),Rm.set(r,i),i}async function cz(t,e,r){if(Rm.set(`${t}@${e}`,r),Mt){let{error:i}=await Mt.client.from("generations").upsert({project_id:Mt.projectId,component:t,gen:e,snapshot:r,canon_version:5},{onConflict:"project_id,component,gen",ignoreDuplicates:!0});if(i)throw new Error(`couldn't save a version of ${t}: ${i.message}`);return}tk(ds(gt(),"snapshots",t),{recursive:!0}),rk(ek(t,e),Bn(r))}async function lz(t,e,r){let i=ds(gt(r),"snapshots");if(!Ua(i))return 0;let n=0;for(let o of ez(i))for(let s of ez(ds(i,o)).filter(a=>a.endsWith(".json"))){let a=JSON.parse(jm(ds(i,o,s),"utf8")),{error:c}=await t.from("generations").upsert({project_id:e,component:o,gen:s.slice(0,-5),snapshot:a,canon_version:5},{onConflict:"project_id,component,gen",ignoreDuplicates:!0});if(c)throw new Error(`couldn't upload the versions of ${o}: ${c.message}`);n++}return n}var Mt,rz,p9,fs,gt,sz,az,ek,Rm,sr=w(()=>{"use strict";Pr();La();Mt=null,rz=(t,e)=>{let{id:r,at:i,by:n,component:o,kind:s,...a}=e;return{project_id:t,id:r,at:i,by:n,component:o,kind:s,body:a}},p9=t=>Vh({...t.body,id:t.id,at:t.at,by:t.by,component:t.component,kind:t.kind});fs=()=>Mt?{client:Mt.client,projectId:Mt.projectId}:null;gt=(t=process.cwd())=>{let e=tz(t,".codesignflo"),r=tz(t,".codesignloop");return!Ua(e)&&Ua(r)&&f9(r,e),e},sz=t=>ds(gt(t),"config.json"),az=t=>ds(gt(t),"events.jsonl");ek=(t,e,r)=>ds(gt(r),"snapshots",t,`${e}.json`),Rm=new Map});var Le,xC,J,Ti,Nu=w(()=>{(function(t){t.assertEqual=n=>{};function e(n){}t.assertIs=e;function r(n){throw new Error}t.assertNever=r,t.arrayToEnum=n=>{let o={};for(let s of n)o[s]=s;return o},t.getValidEnumValues=n=>{let o=t.objectKeys(n).filter(a=>typeof n[n[a]]!="number"),s={};for(let a of o)s[a]=n[a];return t.objectValues(s)},t.objectValues=n=>t.objectKeys(n).map(function(o){return n[o]}),t.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{let o=[];for(let s in n)Object.prototype.hasOwnProperty.call(n,s)&&o.push(s);return o},t.find=(n,o)=>{for(let s of n)if(o(s))return s},t.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function i(n,o=" | "){return n.map(s=>typeof s=="string"?`'${s}'`:s).join(o)}t.joinValues=i,t.jsonStringifyReplacer=(n,o)=>typeof o=="bigint"?o.toString():o})(Le||(Le={}));(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(xC||(xC={}));J=Le.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ti=t=>{switch(typeof t){case"undefined":return J.undefined;case"string":return J.string;case"number":return Number.isNaN(t)?J.nan:J.number;case"boolean":return J.boolean;case"function":return J.function;case"bigint":return J.bigint;case"symbol":return J.symbol;case"object":return Array.isArray(t)?J.array:t===null?J.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?J.promise:typeof Map<"u"&&t instanceof Map?J.map:typeof Set<"u"&&t instanceof Set?J.set:typeof Date<"u"&&t instanceof Date?J.date:J.object;default:return J.unknown}}});var F,Hr,Vm=w(()=>{Nu();F=Le.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Hr=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=i=>{this.issues=[...this.issues,i]},this.addIssues=(i=[])=>{this.issues=[...this.issues,...i]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(o){return o.message},i={_errors:[]},n=o=>{for(let s of o.issues)if(s.code==="invalid_union")s.unionErrors.map(n);else if(s.code==="invalid_return_type")n(s.returnTypeError);else if(s.code==="invalid_arguments")n(s.argumentsError);else if(s.path.length===0)i._errors.push(r(s));else{let a=i,c=0;for(;c<s.path.length;){let l=s.path[c],u=c===s.path.length-1;if(l==="_errors"){u&&a._errors.push(r(s)),c++;continue}Object.prototype.hasOwnProperty.call(a,l)||(l==="__proto__"?Object.defineProperty(a,l,{value:{_errors:[]},writable:!0,enumerable:!0,configurable:!0}):a[l]={_errors:[]}),a=a[l],u&&a._errors.push(r(s)),c++}}};return n(this),i}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Le.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r=Object.create(null),i=[];for(let n of this.issues)if(n.path.length>0){let o=n.path[0];r[o]=r[o]||[],r[o].push(e(n))}else i.push(e(n));return{formErrors:i,fieldErrors:r}}get formErrors(){return this.flatten()}};Hr.create=t=>new Hr(t)});var MW,eo,Ek=w(()=>{Vm();Nu();MW=(t,e)=>{let r;switch(t.code){case F.invalid_type:t.received===J.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case F.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,Le.jsonStringifyReplacer)}`;break;case F.unrecognized_keys:r=`Unrecognized key(s) in object: ${Le.joinValues(t.keys,", ")}`;break;case F.invalid_union:r="Invalid input";break;case F.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Le.joinValues(t.options)}`;break;case F.invalid_enum_value:r=`Invalid enum value. Expected ${Le.joinValues(t.options)}, received '${t.received}'`;break;case F.invalid_arguments:r="Invalid function arguments";break;case F.invalid_return_type:r="Invalid function return type";break;case F.invalid_date:r="Invalid date";break;case F.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:Le.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case F.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case F.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case F.custom:r="Invalid input";break;case F.invalid_intersection_types:r="Intersection results could not be merged";break;case F.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case F.not_finite:r="Number must be finite";break;default:r=e.defaultError,Le.assertNever(t)}return{message:r}},eo=MW});function Du(){return FW}var FW,Bm=w(()=>{Ek();FW=eo});function H(t,e){let r=Du(),i=Hm({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===eo?void 0:eo].filter(n=>!!n)});t.common.issues.push(i)}var Hm,ar,me,Za,br,Tk,Ok,ps,Lu,Pk=w(()=>{Bm();Ek();Hm=t=>{let{data:e,path:r,errorMaps:i,issueData:n}=t,o=[...r,...n.path||[]],s={...n,path:o};if(n.message!==void 0)return{...n,path:o,message:n.message};let a="",c=i.filter(l=>!!l).slice().reverse();for(let l of c)a=l(s,{data:e,defaultError:a}).message;return{...n,path:o,message:a}};ar=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let i=[];for(let n of r){if(n.status==="aborted")return me;n.status==="dirty"&&e.dirty(),i.push(n.value)}return{status:e.value,value:i}}static async mergeObjectAsync(e,r){let i=[];for(let n of r){let o=await n.key,s=await n.value;i.push({key:o,value:s})}return t.mergeObjectSync(e,i)}static mergeObjectSync(e,r){let i={};for(let n of r){let{key:o,value:s}=n;if(o.status==="aborted"||s.status==="aborted")return me;o.status==="dirty"&&e.dirty(),s.status==="dirty"&&e.dirty(),o.value!=="__proto__"&&(typeof s.value<"u"||n.alwaysSet)&&(i[o.value]=s.value)}return{status:e.value,value:i}}},me=Object.freeze({status:"aborted"}),Za=t=>({status:"dirty",value:t}),br=t=>({status:"valid",value:t}),Tk=t=>t.status==="aborted",Ok=t=>t.status==="dirty",ps=t=>t.status==="valid",Lu=t=>typeof Promise<"u"&&t instanceof Promise});var IC=w(()=>{});var ne,EC=w(()=>{(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(ne||(ne={}))});function ke(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:i,description:n}=t;if(e&&(r||i))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(s,a)=>{let{message:c}=t;return s.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??i??a.defaultError}:s.code!=="invalid_type"?{message:a.defaultError}:{message:c??r??a.defaultError}},description:n}}function PC(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function iK(t){return new RegExp(`^${PC(t)}$`)}function oK(t){let e=`${OC}T${PC(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function sK(t,e){return!!((e==="v4"||!e)&&XW.test(t)||(e==="v6"||!e)&&QW.test(t))}function aK(t,e){if(!WW.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let i=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),n=JSON.parse(atob(i));return!(typeof n!="object"||n===null||"typ"in n&&n?.typ!=="JWT"||!n.alg||e&&n.alg!==e)}catch{return!1}}function cK(t,e){return!!((e==="v4"||!e)&&YW.test(t)||(e==="v6"||!e)&&eK.test(t))}function lK(t,e){let r=(t.toString().split(".")[1]||"").length,i=(e.toString().split(".")[1]||"").length,n=r>i?r:i,o=Number.parseInt(t.toFixed(n).replace(".","")),s=Number.parseInt(e.toFixed(n).replace(".",""));return o%s/10**n}function qa(t){if(t instanceof Wr){let e={};for(let r in t.shape){let i=t.shape[r];e[r]=On.create(qa(i))}return new Wr({...t._def,shape:()=>e})}else return t instanceof ro?new ro({...t._def,type:qa(t.element)}):t instanceof On?On.create(qa(t.unwrap())):t instanceof Ai?Ai.create(qa(t.unwrap())):t instanceof Pi?Pi.create(t.items.map(e=>qa(e))):t}function jk(t,e){let r=Ti(t),i=Ti(e);if(t===e)return{valid:!0,data:t};if(r===J.object&&i===J.object){let n=Le.objectKeys(e),o=Le.objectKeys(t).filter(a=>n.indexOf(a)!==-1),s={...t,...e};Object.prototype.hasOwnProperty.call(s,"__proto__")&&delete s.__proto__;for(let a of o){if(a==="__proto__")continue;let c=jk(t[a],e[a]);if(!c.valid)return{valid:!1};s[a]=c.data}return{valid:!0,data:s}}else if(r===J.array&&i===J.array){if(t.length!==e.length)return{valid:!1};let n=[];for(let o=0;o<t.length;o++){let s=t[o],a=e[o],c=jk(s,a);if(!c.valid)return{valid:!1};n.push(c.data)}return{valid:!0,data:n}}else return r===J.date&&i===J.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}function AC(t,e){return new Xa({values:t,typeName:Z.ZodEnum,...ke(e)})}var cn,TC,Oe,ZW,qW,VW,BW,HW,WW,KW,GW,JW,Ak,XW,YW,QW,eK,tK,rK,OC,nK,Va,Uu,Mu,Fu,Zu,qu,Ba,Ha,Vu,to,Qn,Bu,ro,Wr,Wa,Oi,Rk,Ka,Pi,zk,Hu,Wu,Ck,Ga,Ja,Xa,Ya,hs,Pn,On,Ai,Qa,ec,Ku,Fae,Wm,Km,tc,Zae,Z,qae,Vae,Bae,Hae,Wae,Kae,Gae,Jae,Xae,Yae,Qae,ece,tce,rce,RC,nce,ice,oce,sce,ace,cce,lce,uce,dce,fce,pce,hce,mce,gce,yce,vce,_ce,bce,wce,jC=w(()=>{Vm();Bm();EC();Pk();Nu();cn=class{constructor(e,r,i,n){this._cachedPath=[],this.parent=e,this.data=r,this._path=i,this._key=n}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},TC=(t,e)=>{if(ps(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new Hr(t.common.issues);return this._error=r,this._error}}};Oe=class{get description(){return this._def.description}_getType(e){return Ti(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Ti(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ar,ctx:{common:e.parent.common,data:e.data,parsedType:Ti(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(Lu(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let i=this.safeParse(e,r);if(i.success)return i.data;throw i.error}safeParse(e,r){let i={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ti(e)},n=this._parseSync({data:e,path:i.path,parent:i});return TC(i,n)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ti(e)};if(!this["~standard"].async)try{let i=this._parseSync({data:e,path:[],parent:r});return ps(i)?{value:i.value}:{issues:r.common.issues}}catch(i){i?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(i=>ps(i)?{value:i.value}:{issues:r.common.issues})}async parseAsync(e,r){let i=await this.safeParseAsync(e,r);if(i.success)return i.data;throw i.error}async safeParseAsync(e,r){let i={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ti(e)},n=this._parse({data:e,path:i.path,parent:i}),o=await(Lu(n)?n:Promise.resolve(n));return TC(i,o)}refine(e,r){let i=n=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(n):r;return this._refinement((n,o)=>{let s=e(n),a=()=>o.addIssue({code:F.custom,...i(n)});return typeof Promise<"u"&&s instanceof Promise?s.then(c=>c?!0:(a(),!1)):s?!0:(a(),!1)})}refinement(e,r){return this._refinement((i,n)=>e(i)?!0:(n.addIssue(typeof r=="function"?r(i,n):r),!1))}_refinement(e){return new Pn({schema:this,typeName:Z.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return On.create(this,this._def)}nullable(){return Ai.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ro.create(this)}promise(){return hs.create(this,this._def)}or(e){return Wa.create([this,e],this._def)}and(e){return Ka.create(this,e,this._def)}transform(e){return new Pn({...ke(this._def),schema:this,typeName:Z.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new Qa({...ke(this._def),innerType:this,defaultValue:r,typeName:Z.ZodDefault})}brand(){return new Wm({typeName:Z.ZodBranded,type:this,...ke(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new ec({...ke(this._def),innerType:this,catchValue:r,typeName:Z.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Km.create(this,e)}readonly(){return tc.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},ZW=/^c[^\s-]{8,}$/i,qW=/^[0-9a-z]+$/,VW=/^[0-9A-HJKMNP-TV-Z]{26}$/i,BW=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,HW=/^[a-z0-9_-]{21}$/i,WW=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,KW=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,GW=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,JW="^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$",XW=/^(?:(?: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])$/,YW=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,QW=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,eK=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,tK=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,rK=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,OC="((\\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])))",nK=new RegExp(`^${OC}$`);Va=class t extends Oe{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==J.string){let o=this._getOrReturnCtx(e);return H(o,{code:F.invalid_type,expected:J.string,received:o.parsedType}),me}let i=new ar,n;for(let o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(n=this._getOrReturnCtx(e,n),H(n,{code:F.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),i.dirty());else if(o.kind==="max")e.data.length>o.value&&(n=this._getOrReturnCtx(e,n),H(n,{code:F.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),i.dirty());else if(o.kind==="length"){let s=e.data.length>o.value,a=e.data.length<o.value;(s||a)&&(n=this._getOrReturnCtx(e,n),s?H(n,{code:F.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):a&&H(n,{code:F.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),i.dirty())}else if(o.kind==="email")GW.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"email",code:F.invalid_string,message:o.message}),i.dirty());else if(o.kind==="emoji")Ak||(Ak=new RegExp(JW,"u")),Ak.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"emoji",code:F.invalid_string,message:o.message}),i.dirty());else if(o.kind==="uuid")BW.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"uuid",code:F.invalid_string,message:o.message}),i.dirty());else if(o.kind==="nanoid")HW.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"nanoid",code:F.invalid_string,message:o.message}),i.dirty());else if(o.kind==="cuid")ZW.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"cuid",code:F.invalid_string,message:o.message}),i.dirty());else if(o.kind==="cuid2")qW.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"cuid2",code:F.invalid_string,message:o.message}),i.dirty());else if(o.kind==="ulid")VW.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"ulid",code:F.invalid_string,message:o.message}),i.dirty());else if(o.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),H(n,{validation:"url",code:F.invalid_string,message:o.message}),i.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"regex",code:F.invalid_string,message:o.message}),i.dirty())):o.kind==="trim"?e.data=e.data.trim():o.kind==="includes"?e.data.includes(o.value,o.position)||(n=this._getOrReturnCtx(e,n),H(n,{code:F.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),i.dirty()):o.kind==="toLowerCase"?e.data=e.data.toLowerCase():o.kind==="toUpperCase"?e.data=e.data.toUpperCase():o.kind==="startsWith"?e.data.startsWith(o.value)||(n=this._getOrReturnCtx(e,n),H(n,{code:F.invalid_string,validation:{startsWith:o.value},message:o.message}),i.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(n=this._getOrReturnCtx(e,n),H(n,{code:F.invalid_string,validation:{endsWith:o.value},message:o.message}),i.dirty()):o.kind==="datetime"?oK(o).test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:F.invalid_string,validation:"datetime",message:o.message}),i.dirty()):o.kind==="date"?nK.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:F.invalid_string,validation:"date",message:o.message}),i.dirty()):o.kind==="time"?iK(o).test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{code:F.invalid_string,validation:"time",message:o.message}),i.dirty()):o.kind==="duration"?KW.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"duration",code:F.invalid_string,message:o.message}),i.dirty()):o.kind==="ip"?sK(e.data,o.version)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"ip",code:F.invalid_string,message:o.message}),i.dirty()):o.kind==="jwt"?aK(e.data,o.alg)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"jwt",code:F.invalid_string,message:o.message}),i.dirty()):o.kind==="cidr"?cK(e.data,o.version)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"cidr",code:F.invalid_string,message:o.message}),i.dirty()):o.kind==="base64"?tK.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"base64",code:F.invalid_string,message:o.message}),i.dirty()):o.kind==="base64url"?rK.test(e.data)||(n=this._getOrReturnCtx(e,n),H(n,{validation:"base64url",code:F.invalid_string,message:o.message}),i.dirty()):Le.assertNever(o);return{status:i.value,value:e.data}}_regex(e,r,i){return this.refinement(n=>e.test(n),{validation:r,code:F.invalid_string,...ne.errToObj(i)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...ne.errToObj(e)})}url(e){return this._addCheck({kind:"url",...ne.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...ne.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...ne.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...ne.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...ne.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...ne.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...ne.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...ne.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...ne.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...ne.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...ne.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...ne.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...ne.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...ne.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...ne.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...ne.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...ne.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...ne.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...ne.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...ne.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...ne.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...ne.errToObj(r)})}nonempty(e){return this.min(1,ne.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};Va.create=t=>new Va({checks:[],typeName:Z.ZodString,coerce:t?.coerce??!1,...ke(t)});Uu=class t extends Oe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==J.number){let o=this._getOrReturnCtx(e);return H(o,{code:F.invalid_type,expected:J.number,received:o.parsedType}),me}let i,n=new ar;for(let o of this._def.checks)o.kind==="int"?Le.isInteger(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{code:F.invalid_type,expected:"integer",received:"float",message:o.message}),n.dirty()):o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(i=this._getOrReturnCtx(e,i),H(i,{code:F.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),n.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(i=this._getOrReturnCtx(e,i),H(i,{code:F.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),n.dirty()):o.kind==="multipleOf"?lK(e.data,o.value)!==0&&(i=this._getOrReturnCtx(e,i),H(i,{code:F.not_multiple_of,multipleOf:o.value,message:o.message}),n.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(i=this._getOrReturnCtx(e,i),H(i,{code:F.not_finite,message:o.message}),n.dirty()):Le.assertNever(o);return{status:n.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,ne.toString(r))}gt(e,r){return this.setLimit("min",e,!1,ne.toString(r))}lte(e,r){return this.setLimit("max",e,!0,ne.toString(r))}lt(e,r){return this.setLimit("max",e,!1,ne.toString(r))}setLimit(e,r,i,n){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:i,message:ne.toString(n)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:ne.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ne.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ne.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ne.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ne.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:ne.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:ne.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ne.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ne.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Le.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let i of this._def.checks){if(i.kind==="finite"||i.kind==="int"||i.kind==="multipleOf")return!0;i.kind==="min"?(r===null||i.value>r)&&(r=i.value):i.kind==="max"&&(e===null||i.value<e)&&(e=i.value)}return Number.isFinite(r)&&Number.isFinite(e)}};Uu.create=t=>new Uu({checks:[],typeName:Z.ZodNumber,coerce:t?.coerce||!1,...ke(t)});Mu=class t extends Oe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==J.bigint)return this._getInvalidInput(e);let i,n=new ar;for(let o of this._def.checks)o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(i=this._getOrReturnCtx(e,i),H(i,{code:F.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),n.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(i=this._getOrReturnCtx(e,i),H(i,{code:F.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),n.dirty()):o.kind==="multipleOf"?e.data%o.value!==BigInt(0)&&(i=this._getOrReturnCtx(e,i),H(i,{code:F.not_multiple_of,multipleOf:o.value,message:o.message}),n.dirty()):Le.assertNever(o);return{status:n.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return H(r,{code:F.invalid_type,expected:J.bigint,received:r.parsedType}),me}gte(e,r){return this.setLimit("min",e,!0,ne.toString(r))}gt(e,r){return this.setLimit("min",e,!1,ne.toString(r))}lte(e,r){return this.setLimit("max",e,!0,ne.toString(r))}lt(e,r){return this.setLimit("max",e,!1,ne.toString(r))}setLimit(e,r,i,n){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:i,message:ne.toString(n)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ne.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ne.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ne.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ne.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:ne.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};Mu.create=t=>new Mu({checks:[],typeName:Z.ZodBigInt,coerce:t?.coerce??!1,...ke(t)});Fu=class extends Oe{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==J.boolean){let i=this._getOrReturnCtx(e);return H(i,{code:F.invalid_type,expected:J.boolean,received:i.parsedType}),me}return br(e.data)}};Fu.create=t=>new Fu({typeName:Z.ZodBoolean,coerce:t?.coerce||!1,...ke(t)});Zu=class t extends Oe{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==J.date){let o=this._getOrReturnCtx(e);return H(o,{code:F.invalid_type,expected:J.date,received:o.parsedType}),me}if(Number.isNaN(e.data.getTime())){let o=this._getOrReturnCtx(e);return H(o,{code:F.invalid_date}),me}let i=new ar,n;for(let o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(n=this._getOrReturnCtx(e,n),H(n,{code:F.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),i.dirty()):o.kind==="max"?e.data.getTime()>o.value&&(n=this._getOrReturnCtx(e,n),H(n,{code:F.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),i.dirty()):Le.assertNever(o);return{status:i.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:ne.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:ne.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};Zu.create=t=>new Zu({checks:[],coerce:t?.coerce||!1,typeName:Z.ZodDate,...ke(t)});qu=class extends Oe{_parse(e){if(this._getType(e)!==J.symbol){let i=this._getOrReturnCtx(e);return H(i,{code:F.invalid_type,expected:J.symbol,received:i.parsedType}),me}return br(e.data)}};qu.create=t=>new qu({typeName:Z.ZodSymbol,...ke(t)});Ba=class extends Oe{_parse(e){if(this._getType(e)!==J.undefined){let i=this._getOrReturnCtx(e);return H(i,{code:F.invalid_type,expected:J.undefined,received:i.parsedType}),me}return br(e.data)}};Ba.create=t=>new Ba({typeName:Z.ZodUndefined,...ke(t)});Ha=class extends Oe{_parse(e){if(this._getType(e)!==J.null){let i=this._getOrReturnCtx(e);return H(i,{code:F.invalid_type,expected:J.null,received:i.parsedType}),me}return br(e.data)}};Ha.create=t=>new Ha({typeName:Z.ZodNull,...ke(t)});Vu=class extends Oe{constructor(){super(...arguments),this._any=!0}_parse(e){return br(e.data)}};Vu.create=t=>new Vu({typeName:Z.ZodAny,...ke(t)});to=class extends Oe{constructor(){super(...arguments),this._unknown=!0}_parse(e){return br(e.data)}};to.create=t=>new to({typeName:Z.ZodUnknown,...ke(t)});Qn=class extends Oe{_parse(e){let r=this._getOrReturnCtx(e);return H(r,{code:F.invalid_type,expected:J.never,received:r.parsedType}),me}};Qn.create=t=>new Qn({typeName:Z.ZodNever,...ke(t)});Bu=class extends Oe{_parse(e){if(this._getType(e)!==J.undefined){let i=this._getOrReturnCtx(e);return H(i,{code:F.invalid_type,expected:J.void,received:i.parsedType}),me}return br(e.data)}};Bu.create=t=>new Bu({typeName:Z.ZodVoid,...ke(t)});ro=class t extends Oe{_parse(e){let{ctx:r,status:i}=this._processInputParams(e),n=this._def;if(r.parsedType!==J.array)return H(r,{code:F.invalid_type,expected:J.array,received:r.parsedType}),me;if(n.exactLength!==null){let s=r.data.length>n.exactLength.value,a=r.data.length<n.exactLength.value;(s||a)&&(H(r,{code:s?F.too_big:F.too_small,minimum:a?n.exactLength.value:void 0,maximum:s?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),i.dirty())}if(n.minLength!==null&&r.data.length<n.minLength.value&&(H(r,{code:F.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),i.dirty()),n.maxLength!==null&&r.data.length>n.maxLength.value&&(H(r,{code:F.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),i.dirty()),r.common.async)return Promise.all([...r.data].map((s,a)=>n.type._parseAsync(new cn(r,s,r.path,a)))).then(s=>ar.mergeArray(i,s));let o=[...r.data].map((s,a)=>n.type._parseSync(new cn(r,s,r.path,a)));return ar.mergeArray(i,o)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:ne.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:ne.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:ne.toString(r)}})}nonempty(e){return this.min(1,e)}};ro.create=(t,e)=>new ro({type:t,minLength:null,maxLength:null,exactLength:null,typeName:Z.ZodArray,...ke(e)});Wr=class t extends Oe{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=Le.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==J.object){let l=this._getOrReturnCtx(e);return H(l,{code:F.invalid_type,expected:J.object,received:l.parsedType}),me}let{status:i,ctx:n}=this._processInputParams(e),{shape:o,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof Qn&&this._def.unknownKeys==="strip"))for(let l in n.data)s.includes(l)||a.push(l);let c=[];for(let l of s){let u=o[l],d=n.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new cn(n,d,n.path,l)),alwaysSet:l in n.data})}if(this._def.catchall instanceof Qn){let l=this._def.unknownKeys;if(l==="passthrough")for(let u of a)c.push({key:{status:"valid",value:u},value:{status:"valid",value:n.data[u]}});else if(l==="strict")a.length>0&&(H(n,{code:F.unrecognized_keys,keys:a}),i.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let u of a){let d=n.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new cn(n,d,n.path,u)),alwaysSet:u in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let l=[];for(let u of c){let d=await u.key,p=await u.value;l.push({key:d,value:p,alwaysSet:u.alwaysSet})}return l}).then(l=>ar.mergeObjectSync(i,l)):ar.mergeObjectSync(i,c)}get shape(){return this._def.shape()}strict(e){return ne.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,i)=>{let n=this._def.errorMap?.(r,i).message??i.defaultError;return r.code==="unrecognized_keys"?{message:ne.errToObj(e).message??n}:{message:n}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Z.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let i of Le.objectKeys(e))e[i]&&this.shape[i]&&(r[i]=this.shape[i]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let i of Le.objectKeys(this.shape))e[i]||(r[i]=this.shape[i]);return new t({...this._def,shape:()=>r})}deepPartial(){return qa(this)}partial(e){let r={};for(let i of Le.objectKeys(this.shape)){let n=this.shape[i];e&&!e[i]?r[i]=n:r[i]=n.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let i of Le.objectKeys(this.shape))if(e&&!e[i])r[i]=this.shape[i];else{let o=this.shape[i];for(;o instanceof On;)o=o._def.innerType;r[i]=o}return new t({...this._def,shape:()=>r})}keyof(){return AC(Le.objectKeys(this.shape))}};Wr.create=(t,e)=>new Wr({shape:()=>t,unknownKeys:"strip",catchall:Qn.create(),typeName:Z.ZodObject,...ke(e)});Wr.strictCreate=(t,e)=>new Wr({shape:()=>t,unknownKeys:"strict",catchall:Qn.create(),typeName:Z.ZodObject,...ke(e)});Wr.lazycreate=(t,e)=>new Wr({shape:t,unknownKeys:"strip",catchall:Qn.create(),typeName:Z.ZodObject,...ke(e)});Wa=class extends Oe{_parse(e){let{ctx:r}=this._processInputParams(e),i=this._def.options;function n(o){for(let a of o)if(a.result.status==="valid")return a.result;for(let a of o)if(a.result.status==="dirty")return r.common.issues.push(...a.ctx.common.issues),a.result;let s=o.map(a=>new Hr(a.ctx.common.issues));return H(r,{code:F.invalid_union,unionErrors:s}),me}if(r.common.async)return Promise.all(i.map(async o=>{let s={...r,common:{...r.common,issues:[]},parent:null};return{result:await o._parseAsync({data:r.data,path:r.path,parent:s}),ctx:s}})).then(n);{let o,s=[];for(let c of i){let l={...r,common:{...r.common,issues:[]},parent:null},u=c._parseSync({data:r.data,path:r.path,parent:l});if(u.status==="valid")return u;u.status==="dirty"&&!o&&(o={result:u,ctx:l}),l.common.issues.length&&s.push(l.common.issues)}if(o)return r.common.issues.push(...o.ctx.common.issues),o.result;let a=s.map(c=>new Hr(c));return H(r,{code:F.invalid_union,unionErrors:a}),me}}get options(){return this._def.options}};Wa.create=(t,e)=>new Wa({options:t,typeName:Z.ZodUnion,...ke(e)});Oi=t=>t instanceof Ga?Oi(t.schema):t instanceof Pn?Oi(t.innerType()):t instanceof Ja?[t.value]:t instanceof Xa?t.options:t instanceof Ya?Le.objectValues(t.enum):t instanceof Qa?Oi(t._def.innerType):t instanceof Ba?[void 0]:t instanceof Ha?[null]:t instanceof On?[void 0,...Oi(t.unwrap())]:t instanceof Ai?[null,...Oi(t.unwrap())]:t instanceof Wm||t instanceof tc?Oi(t.unwrap()):t instanceof ec?Oi(t._def.innerType):[],Rk=class t extends Oe{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==J.object)return H(r,{code:F.invalid_type,expected:J.object,received:r.parsedType}),me;let i=this.discriminator,n=r.data[i],o=this.optionsMap.get(n);return o?r.common.async?o._parseAsync({data:r.data,path:r.path,parent:r}):o._parseSync({data:r.data,path:r.path,parent:r}):(H(r,{code:F.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[i]}),me)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,i){let n=new Map;for(let o of r){let s=Oi(o.shape[e]);if(!s.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of s){if(n.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);n.set(a,o)}}return new t({typeName:Z.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:n,...ke(i)})}};Ka=class extends Oe{_parse(e){let{status:r,ctx:i}=this._processInputParams(e),n=(o,s)=>{if(Tk(o)||Tk(s))return me;let a=jk(o.value,s.value);return a.valid?((Ok(o)||Ok(s))&&r.dirty(),{status:r.value,value:a.data}):(H(i,{code:F.invalid_intersection_types}),me)};return i.common.async?Promise.all([this._def.left._parseAsync({data:i.data,path:i.path,parent:i}),this._def.right._parseAsync({data:i.data,path:i.path,parent:i})]).then(([o,s])=>n(o,s)):n(this._def.left._parseSync({data:i.data,path:i.path,parent:i}),this._def.right._parseSync({data:i.data,path:i.path,parent:i}))}};Ka.create=(t,e,r)=>new Ka({left:t,right:e,typeName:Z.ZodIntersection,...ke(r)});Pi=class t extends Oe{_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.parsedType!==J.array)return H(i,{code:F.invalid_type,expected:J.array,received:i.parsedType}),me;if(i.data.length<this._def.items.length)return H(i,{code:F.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),me;!this._def.rest&&i.data.length>this._def.items.length&&(H(i,{code:F.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let o=[...i.data].map((s,a)=>{let c=this._def.items[a]||this._def.rest;return c?c._parse(new cn(i,s,i.path,a)):null}).filter(s=>!!s);return i.common.async?Promise.all(o).then(s=>ar.mergeArray(r,s)):ar.mergeArray(r,o)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};Pi.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Pi({items:t,typeName:Z.ZodTuple,rest:null,...ke(e)})};zk=class t extends Oe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.parsedType!==J.object)return H(i,{code:F.invalid_type,expected:J.object,received:i.parsedType}),me;let n=[],o=this._def.keyType,s=this._def.valueType;for(let a in i.data)n.push({key:o._parse(new cn(i,a,i.path,a)),value:s._parse(new cn(i,i.data[a],i.path,a)),alwaysSet:a in i.data});return i.common.async?ar.mergeObjectAsync(r,n):ar.mergeObjectSync(r,n)}get element(){return this._def.valueType}static create(e,r,i){return r instanceof Oe?new t({keyType:e,valueType:r,typeName:Z.ZodRecord,...ke(i)}):new t({keyType:Va.create(),valueType:e,typeName:Z.ZodRecord,...ke(r)})}},Hu=class extends Oe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.parsedType!==J.map)return H(i,{code:F.invalid_type,expected:J.map,received:i.parsedType}),me;let n=this._def.keyType,o=this._def.valueType,s=[...i.data.entries()].map(([a,c],l)=>({key:n._parse(new cn(i,a,i.path,[l,"key"])),value:o._parse(new cn(i,c,i.path,[l,"value"]))}));if(i.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let c of s){let l=await c.key,u=await c.value;if(l.status==="aborted"||u.status==="aborted")return me;(l.status==="dirty"||u.status==="dirty")&&r.dirty(),a.set(l.value,u.value)}return{status:r.value,value:a}})}else{let a=new Map;for(let c of s){let l=c.key,u=c.value;if(l.status==="aborted"||u.status==="aborted")return me;(l.status==="dirty"||u.status==="dirty")&&r.dirty(),a.set(l.value,u.value)}return{status:r.value,value:a}}}};Hu.create=(t,e,r)=>new Hu({valueType:e,keyType:t,typeName:Z.ZodMap,...ke(r)});Wu=class t extends Oe{_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.parsedType!==J.set)return H(i,{code:F.invalid_type,expected:J.set,received:i.parsedType}),me;let n=this._def;n.minSize!==null&&i.data.size<n.minSize.value&&(H(i,{code:F.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),r.dirty()),n.maxSize!==null&&i.data.size>n.maxSize.value&&(H(i,{code:F.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),r.dirty());let o=this._def.valueType;function s(c){let l=new Set;for(let u of c){if(u.status==="aborted")return me;u.status==="dirty"&&r.dirty(),l.add(u.value)}return{status:r.value,value:l}}let a=[...i.data.values()].map((c,l)=>o._parse(new cn(i,c,i.path,l)));return i.common.async?Promise.all(a).then(c=>s(c)):s(a)}min(e,r){return new t({...this._def,minSize:{value:e,message:ne.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:ne.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Wu.create=(t,e)=>new Wu({valueType:t,minSize:null,maxSize:null,typeName:Z.ZodSet,...ke(e)});Ck=class t extends Oe{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==J.function)return H(r,{code:F.invalid_type,expected:J.function,received:r.parsedType}),me;function i(a,c){return Hm({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Du(),eo].filter(l=>!!l),issueData:{code:F.invalid_arguments,argumentsError:c}})}function n(a,c){return Hm({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Du(),eo].filter(l=>!!l),issueData:{code:F.invalid_return_type,returnTypeError:c}})}let o={errorMap:r.common.contextualErrorMap},s=r.data;if(this._def.returns instanceof hs){let a=this;return br(async function(...c){let l=new Hr([]),u=await a._def.args.parseAsync(c,o).catch(f=>{throw l.addIssue(i(c,f)),l}),d=await Reflect.apply(s,this,u);return await a._def.returns._def.type.parseAsync(d,o).catch(f=>{throw l.addIssue(n(d,f)),l})})}else{let a=this;return br(function(...c){let l=a._def.args.safeParse(c,o);if(!l.success)throw new Hr([i(c,l.error)]);let u=Reflect.apply(s,this,l.data),d=a._def.returns.safeParse(u,o);if(!d.success)throw new Hr([n(u,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:Pi.create(e).rest(to.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,i){return new t({args:e||Pi.create([]).rest(to.create()),returns:r||to.create(),typeName:Z.ZodFunction,...ke(i)})}},Ga=class extends Oe{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};Ga.create=(t,e)=>new Ga({getter:t,typeName:Z.ZodLazy,...ke(e)});Ja=class extends Oe{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return H(r,{received:r.data,code:F.invalid_literal,expected:this._def.value}),me}return{status:"valid",value:e.data}}get value(){return this._def.value}};Ja.create=(t,e)=>new Ja({value:t,typeName:Z.ZodLiteral,...ke(e)});Xa=class t extends Oe{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),i=this._def.values;return H(r,{expected:Le.joinValues(i),received:r.parsedType,code:F.invalid_type}),me}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),i=this._def.values;return H(r,{received:r.data,code:F.invalid_enum_value,options:i}),me}return br(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(i=>!e.includes(i)),{...this._def,...r})}};Xa.create=AC;Ya=class extends Oe{_parse(e){let r=Le.getValidEnumValues(this._def.values),i=this._getOrReturnCtx(e);if(i.parsedType!==J.string&&i.parsedType!==J.number){let n=Le.objectValues(r);return H(i,{expected:Le.joinValues(n),received:i.parsedType,code:F.invalid_type}),me}if(this._cache||(this._cache=new Set(Le.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let n=Le.objectValues(r);return H(i,{received:i.data,code:F.invalid_enum_value,options:n}),me}return br(e.data)}get enum(){return this._def.values}};Ya.create=(t,e)=>new Ya({values:t,typeName:Z.ZodNativeEnum,...ke(e)});hs=class extends Oe{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==J.promise&&r.common.async===!1)return H(r,{code:F.invalid_type,expected:J.promise,received:r.parsedType}),me;let i=r.parsedType===J.promise?r.data:Promise.resolve(r.data);return br(i.then(n=>this._def.type.parseAsync(n,{path:r.path,errorMap:r.common.contextualErrorMap})))}};hs.create=(t,e)=>new hs({type:t,typeName:Z.ZodPromise,...ke(e)});Pn=class extends Oe{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Z.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:i}=this._processInputParams(e),n=this._def.effect||null,o={addIssue:s=>{H(i,s),s.fatal?r.abort():r.dirty()},get path(){return i.path}};if(o.addIssue=o.addIssue.bind(o),n.type==="preprocess"){let s=n.transform(i.data,o);if(i.common.async)return Promise.resolve(s).then(async a=>{if(r.value==="aborted")return me;let c=await this._def.schema._parseAsync({data:a,path:i.path,parent:i});return c.status==="aborted"?me:c.status==="dirty"?Za(c.value):r.value==="dirty"?Za(c.value):c});{if(r.value==="aborted")return me;let a=this._def.schema._parseSync({data:s,path:i.path,parent:i});return a.status==="aborted"?me:a.status==="dirty"?Za(a.value):r.value==="dirty"?Za(a.value):a}}if(n.type==="refinement"){let s=a=>{let c=n.refinement(a,o);if(i.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(i.common.async===!1){let a=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});return a.status==="aborted"?me:(a.status==="dirty"&&r.dirty(),s(a.value),{status:r.value,value:a.value})}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(a=>a.status==="aborted"?me:(a.status==="dirty"&&r.dirty(),s(a.value).then(()=>({status:r.value,value:a.value}))))}if(n.type==="transform")if(i.common.async===!1){let s=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});if(!ps(s))return me;let a=n.transform(s.value,o);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:a}}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(s=>ps(s)?Promise.resolve(n.transform(s.value,o)).then(a=>({status:r.value,value:a})):me);Le.assertNever(n)}};Pn.create=(t,e,r)=>new Pn({schema:t,typeName:Z.ZodEffects,effect:e,...ke(r)});Pn.createWithPreprocess=(t,e,r)=>new Pn({schema:e,effect:{type:"preprocess",transform:t},typeName:Z.ZodEffects,...ke(r)});On=class extends Oe{_parse(e){return this._getType(e)===J.undefined?br(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};On.create=(t,e)=>new On({innerType:t,typeName:Z.ZodOptional,...ke(e)});Ai=class extends Oe{_parse(e){return this._getType(e)===J.null?br(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ai.create=(t,e)=>new Ai({innerType:t,typeName:Z.ZodNullable,...ke(e)});Qa=class extends Oe{_parse(e){let{ctx:r}=this._processInputParams(e),i=r.data;return r.parsedType===J.undefined&&(i=this._def.defaultValue()),this._def.innerType._parse({data:i,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Qa.create=(t,e)=>new Qa({innerType:t,typeName:Z.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ke(e)});ec=class extends Oe{_parse(e){let{ctx:r}=this._processInputParams(e),i={...r,common:{...r.common,issues:[]}},n=this._def.innerType._parse({data:i.data,path:i.path,parent:{...i}});return Lu(n)?n.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Hr(i.common.issues)},input:i.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new Hr(i.common.issues)},input:i.data})}}removeCatch(){return this._def.innerType}};ec.create=(t,e)=>new ec({innerType:t,typeName:Z.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ke(e)});Ku=class extends Oe{_parse(e){if(this._getType(e)!==J.nan){let i=this._getOrReturnCtx(e);return H(i,{code:F.invalid_type,expected:J.nan,received:i.parsedType}),me}return{status:"valid",value:e.data}}};Ku.create=t=>new Ku({typeName:Z.ZodNaN,...ke(t)});Fae=Symbol("zod_brand"),Wm=class extends Oe{_parse(e){let{ctx:r}=this._processInputParams(e),i=r.data;return this._def.type._parse({data:i,path:r.path,parent:r})}unwrap(){return this._def.type}},Km=class t extends Oe{_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.common.async)return(async()=>{let o=await this._def.in._parseAsync({data:i.data,path:i.path,parent:i});return o.status==="aborted"?me:o.status==="dirty"?(r.dirty(),Za(o.value)):this._def.out._parseAsync({data:o.value,path:i.path,parent:i})})();{let n=this._def.in._parseSync({data:i.data,path:i.path,parent:i});return n.status==="aborted"?me:n.status==="dirty"?(r.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:i.path,parent:i})}}static create(e,r){return new t({in:e,out:r,typeName:Z.ZodPipeline})}},tc=class extends Oe{_parse(e){let r=this._def.innerType._parse(e),i=n=>(ps(n)&&(n.value=Object.freeze(n.value)),n);return Lu(r)?r.then(n=>i(n)):i(r)}unwrap(){return this._def.innerType}};tc.create=(t,e)=>new tc({innerType:t,typeName:Z.ZodReadonly,...ke(e)});Zae={object:Wr.lazycreate};(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(Z||(Z={}));qae=Va.create,Vae=Uu.create,Bae=Ku.create,Hae=Mu.create,Wae=Fu.create,Kae=Zu.create,Gae=qu.create,Jae=Ba.create,Xae=Ha.create,Yae=Vu.create,Qae=to.create,ece=Qn.create,tce=Bu.create,rce=ro.create,RC=Wr.create,nce=Wr.strictCreate,ice=Wa.create,oce=Rk.create,sce=Ka.create,ace=Pi.create,cce=zk.create,lce=Hu.create,uce=Wu.create,dce=Ck.create,fce=Ga.create,pce=Ja.create,hce=Xa.create,mce=Ya.create,gce=hs.create,yce=Pn.create,vce=On.create,_ce=Ai.create,bce=Pn.createWithPreprocess,wce=Km.create});var zC=w(()=>{Bm();Pk();IC();Nu();jC();Vm()});var Gu=w(()=>{zC()});var Nk=w(()=>{fw()});function ei(t){return!!t._zod}function ms(t){let e=Object.values(t);if(e.length===0)return dt({});let r=e.every(ei),i=e.every(n=>!ei(n));if(r)return dt(t);if(i)return RC(t);throw new Error("Mixed Zod versions detected in object shape.")}function no(t,e){return ei(t)?Ks(t,e):t.safeParse(e)}async function Gm(t,e){return ei(t)?await Js(t,e):await t.safeParseAsync(e)}function io(t){if(!t)return;let e;if(ei(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function rc(t){if(t){if(typeof t=="object"){let e=t,r=t;if(!e._def&&!r._zod){let i=Object.values(t);if(i.length>0&&i.every(n=>typeof n=="object"&&n!==null&&(n._def!==void 0||n._zod!==void 0||typeof n.parse=="function")))return ms(t)}}if(ei(t)){let r=t._zod?.def;if(r&&(r.type==="object"||r.shape!==void 0))return t}else if(t.shape!==void 0)return t}}function dK(t){return t.length===0?"object root":t.reduce((e,r,i)=>i===0?String(r):typeof r=="number"?`${e}[${r}]`:`${e}.${r}`,"")}function Jm(t){if(t&&typeof t=="object"){if("issues"in t&&Array.isArray(t.issues)&&t.issues.length>0)return t.issues.map(e=>e.path?.length?`${e.message} at ${dK(e.path)}`:e.message).join(`
120
+ `);if("message"in t&&typeof t.message=="string")return t.message;try{return JSON.stringify(t)}catch{return String(t)}}return String(t)}function NC(t){return t.description}function DC(t){if(ei(t))return t._zod?.def?.type==="optional";let e=t;return typeof t.isOptional=="function"?t.isOptional():e._def?.typeName==="ZodOptional"}function nc(t){if(ei(t)){let o=t._zod?.def;if(o){if(o.value!==void 0)return o.value;if(Array.isArray(o.values)&&o.values.length>0)return o.values[0]}}let r=t._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let i=t.value;if(i!==void 0)return i}var Ju=w(()=>{Gu();Nk()});var Xm={};Jr(Xm,{endsWith:()=>Bo,gt:()=>bn,gte:()=>gr,includes:()=>qo,length:()=>Vi,lowercase:()=>Fo,lt:()=>_n,lte:()=>mr,maxLength:()=>qi,maxSize:()=>_i,mime:()=>Wo,minLength:()=>Or,minSize:()=>wn,multipleOf:()=>vi,negative:()=>Hl,nonnegative:()=>Kl,nonpositive:()=>Wl,normalize:()=>Ko,overwrite:()=>rn,positive:()=>Bl,properties:()=>Ho,property:()=>Gl,regex:()=>Mo,size:()=>Zi,slugify:()=>fa,startsWith:()=>Vo,toLowerCase:()=>Jo,toUpperCase:()=>Xo,trim:()=>Go,uppercase:()=>Zo});var Ym=w(()=>{Xt()});function Qm(t,e,r){Object.defineProperty(t,e,{configurable:!0,enumerable:!1,get(){let i=r(this);return Object.defineProperty(this,e,{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,e,{value:i,configurable:!0,writable:!0})}})}var LC,UC,fK,zr,Dk=w(()=>{Xt();Xt();B();LC=new WeakSet([Object.prototype,Error.prototype]);UC=(t,e)=>{Dv.init(t,e),t.name="ZodError";let r=Object.getPrototypeOf(t);LC.has(r)||(LC.add(r),Qm(r,"format",i=>n=>Gc(i,n)),Qm(r,"flatten",i=>n=>Kc(i,n)),Qm(r,"addIssue",i=>n=>{i.issues.push(n),i.message=JSON.stringify(i.issues,Ms,2)}),Qm(r,"addIssues",i=>n=>{i.issues.push(...n),i.message=JSON.stringify(i.issues,Ms,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},fK=$("ZodError",UC),zr=$("ZodError",UC,void 0,{Parent:Error})});var Lk,Uk,Mk,Fk,Zk,qk,Vk,Bk,Hk,Wk,Kk,Gk,Jk=w(()=>{Xt();Dk();Xt();Lk=Bs(zr),Uk=Hs(zr),Mk=Ws(zr),Fk=Gs(zr),Zk=$f(zr),qk=kf(zr),Vk=Sf(zr),Bk=xf(zr),Hk=If(zr),Wk=Ef(zr),Kk=Tf(zr),Gk=Of(zr)});var dc={};Jr(dc,{ZodAny:()=>n0,ZodArray:()=>a0,ZodBase64:()=>gg,ZodBase64URL:()=>yg,ZodBigInt:()=>lc,ZodBigIntFormat:()=>bg,ZodBoolean:()=>cc,ZodCIDRv4:()=>hg,ZodCIDRv6:()=>mg,ZodCUID:()=>ag,ZodCUID2:()=>cg,ZodCatch:()=>I0,ZodCodec:()=>od,ZodCreditCard:()=>Yk,ZodCustom:()=>sd,ZodCustomStringFormat:()=>ys,ZodDate:()=>ed,ZodDefault:()=>b0,ZodDiscriminatedUnion:()=>l0,ZodE164:()=>vg,ZodEmail:()=>ng,ZodEmoji:()=>og,ZodEnum:()=>oc,ZodExactOptional:()=>kg,ZodFile:()=>g0,ZodFunction:()=>N0,ZodGUID:()=>ig,ZodIBAN:()=>Qk,ZodIPv4:()=>fg,ZodIPv6:()=>pg,ZodISODate:()=>so,ZodISODateTime:()=>oo,ZodISODuration:()=>co,ZodISOTime:()=>ao,ZodInstanceOf:()=>U0,ZodIntersection:()=>u0,ZodJWT:()=>_g,ZodKSUID:()=>dg,ZodLazy:()=>j0,ZodLiteral:()=>m0,ZodMAC:()=>Xk,ZodMap:()=>p0,ZodNaN:()=>T0,ZodNanoID:()=>sg,ZodNever:()=>o0,ZodNonOptional:()=>Sg,ZodNull:()=>r0,ZodNullable:()=>_0,ZodNumber:()=>ac,ZodNumberFormat:()=>vs,ZodObject:()=>td,ZodOptional:()=>_s,ZodPipe:()=>id,ZodPrefault:()=>$0,ZodPreprocess:()=>O0,ZodPromise:()=>C0,ZodReadonly:()=>P0,ZodRecord:()=>ic,ZodSet:()=>h0,ZodString:()=>sc,ZodStringFormat:()=>st,ZodSuccess:()=>x0,ZodSymbol:()=>e0,ZodTemplateLiteral:()=>R0,ZodTransform:()=>y0,ZodTuple:()=>d0,ZodType:()=>Se,ZodULID:()=>lg,ZodURL:()=>Yu,ZodUUID:()=>ti,ZodUndefined:()=>t0,ZodUnion:()=>rd,ZodUnknown:()=>i0,ZodVoid:()=>s0,ZodXID:()=>ug,ZodXor:()=>c0,_ZodString:()=>rg,_default:()=>w0,_function:()=>BN,any:()=>IN,array:()=>Pe,base64:()=>sN,base64url:()=>aN,bigint:()=>wN,boolean:()=>Nt,catch:()=>E0,check:()=>HN,cidrv4:()=>iN,cidrv6:()=>oN,codec:()=>FN,creditCard:()=>lN,cuid:()=>JC,cuid2:()=>XC,currencyCode:()=>mN,custom:()=>xg,date:()=>TN,describe:()=>WN,discriminatedUnion:()=>nd,e164:()=>cN,email:()=>MC,emoji:()=>KC,enum:()=>er,exactOptional:()=>v0,file:()=>DN,float32:()=>yN,float64:()=>vN,function:()=>BN,guid:()=>FC,hash:()=>gN,hex:()=>hN,hostname:()=>pN,httpUrl:()=>WC,iban:()=>uN,instanceof:()=>GN,int:()=>eg,int32:()=>_N,int64:()=>$N,intersection:()=>uc,invertCodec:()=>ZN,ipv4:()=>tN,ipv6:()=>nN,json:()=>XN,jwt:()=>dN,keyof:()=>ON,ksuid:()=>eN,lazy:()=>z0,literal:()=>se,looseObject:()=>Qt,looseRecord:()=>jN,mac:()=>rN,map:()=>zN,meta:()=>KN,nan:()=>MN,nanoid:()=>GC,nativeEnum:()=>NN,never:()=>wg,nonoptional:()=>S0,null:()=>Qu,nullable:()=>Xu,nullish:()=>LN,number:()=>Ke,object:()=>K,optional:()=>ot,partialRecord:()=>RN,pipe:()=>tg,prefault:()=>k0,preprocess:()=>ad,promise:()=>VN,readonly:()=>A0,record:()=>at,refine:()=>D0,set:()=>CN,strictObject:()=>PN,string:()=>P,stringFormat:()=>fN,stringbool:()=>JN,success:()=>UN,superRefine:()=>L0,symbol:()=>SN,templateLiteral:()=>qN,transform:()=>$g,tuple:()=>f0,uint32:()=>bN,uint64:()=>kN,ulid:()=>YC,undefined:()=>xN,union:()=>rt,unknown:()=>ct,url:()=>HC,uuid:()=>ZC,uuidv4:()=>qC,uuidv6:()=>VC,uuidv7:()=>BC,void:()=>EN,xid:()=>QC,xor:()=>AN});function hK(){Wt.localeError||Pt(ih())}function gs(){Wt.memoizer||Pt({memoizer:hl()})}function P(t){return yl(sc,t)}function MC(t){return vl(ng,t)}function FC(t){return _l(ig,t)}function ZC(t){return bl(ti,t)}function qC(t){return wl(ti,t)}function VC(t){return $l(ti,t)}function BC(t){return kl(ti,t)}function HC(t){return da(Yu,t)}function WC(t){return da(Yu,{protocol:Jc,hostname:c_,...A.normalizeParams(t)})}function KC(t){return Sl(og,t)}function GC(t){return xl(sg,t)}function JC(t){return Il(ag,t)}function XC(t){return El(cg,t)}function YC(t){return Tl(lg,t)}function QC(t){return Ol(ug,t)}function eN(t){return Pl(dg,t)}function tN(t){return Al(fg,t)}function rN(t){return ph(Xk,t)}function nN(t){return Rl(pg,t)}function iN(t){return jl(hg,t)}function oN(t){return zl(mg,t)}function sN(t){return Cl(gg,t)}function aN(t){return Nl(yg,t)}function cN(t){return Dl(vg,t)}function lN(t){return hh(Yk,t)}function uN(t){return mh(Qk,t)}function dN(t){return Ll(_g,t)}function fN(t,e,r={}){return Bi(ys,t,e,r)}function pN(t){return Bi(ys,"hostname",a_,t)}function hN(t){return Bi(ys,"hex",$_,t)}function mN(t){return Bi(ys,"currency_code",u_,t)}function gN(t,e){let r=e?.enc??"hex",i=`${t}_${r}`,n=Fr[i];if(!n)throw new Error(`Unrecognized hash format: ${i}`);return Bi(ys,i,n,e)}function Ke(t){return ql(ac,t)}function eg(t){return gh(vs,t)}function yN(t){return yh(vs,t)}function vN(t){return vh(vs,t)}function _N(t){return _h(vs,t)}function bN(t){return bh(vs,t)}function Nt(t){return Vl(cc,t)}function wN(t){return wh(lc,t)}function $N(t){return $h(bg,t)}function kN(t){return kh(bg,t)}function SN(t){return Sh(e0,t)}function xN(t){return xh(t0,t)}function Qu(t){return Ih(r0,t)}function IN(){return Eh(n0)}function ct(){return Th(i0)}function wg(t){return Oh(o0,t)}function EN(t){return Ph(s0,t)}function TN(t){return Ah(ed,t)}function Pe(t,e){return wb(a0,t,e)}function ON(t){let e=t._zod.def.shape;return er(Object.keys(e))}function K(t,e){let r={type:"object",shape:t??{},...A.normalizeParams(e)};return new td(r)}function PN(t,e){return new td({type:"object",shape:t,catchall:wg(),...A.normalizeParams(e)})}function Qt(t,e){return new td({type:"object",shape:t,catchall:ct(),...A.normalizeParams(e)})}function rt(t,e){return new rd({type:"union",options:t,...A.normalizeParams(e)})}function AN(t,e){return new c0({type:"union",options:t,inclusive:!1,...A.normalizeParams(e)})}function nd(t,e,r){return new l0({type:"union",options:e,discriminator:t,...A.normalizeParams(r)})}function uc(t,e){return new u0({type:"intersection",left:t,right:e})}function f0(t,e,r){let i=e instanceof ve,n=i?r:e,o=i?e:null;return new d0({type:"tuple",items:t,rest:o,...A.normalizeParams(n)})}function at(t,e,r){return!e||!e._zod?new ic({type:"record",keyType:P(),valueType:t,...A.normalizeParams(e)}):new ic({type:"record",keyType:t,valueType:e,...A.normalizeParams(r)})}function RN(t,e,r){return new ic({type:"record",keyType:t,valueType:e,...A.normalizeParams(r),partial:!0})}function jN(t,e,r){return new ic({type:"record",keyType:t,valueType:e,mode:"loose",...A.normalizeParams(r)})}function zN(t,e,r){return new p0({type:"map",keyType:t,valueType:e,...A.normalizeParams(r)})}function CN(t,e){return new h0({type:"set",valueType:t,...A.normalizeParams(e)})}function er(t,e){let r=Array.isArray(t)?Object.fromEntries(t.map(i=>[i,i])):t;return new oc({type:"enum",entries:r,...A.normalizeParams(e)})}function NN(t,e){return new oc({type:"enum",entries:t,...A.normalizeParams(e)})}function se(t,e){return new m0({type:"literal",values:Array.isArray(t)?t:[t],...A.normalizeParams(e)})}function DN(t){return jh(g0,t)}function $g(t){return new y0({type:"transform",transform:t})}function ot(t){return new _s({type:"optional",innerType:t})}function v0(t){return new kg({type:"optional",innerType:t})}function Xu(t){return new _0({type:"nullable",innerType:t})}function LN(t){return ot(Xu(t))}function w0(t,e){return new b0({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():A.shallowClone(e)}})}function k0(t,e){return new $0({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():A.shallowClone(e)}})}function S0(t,e){return new Sg({type:"nonoptional",innerType:t,...A.normalizeParams(e)})}function UN(t){return new x0({type:"success",innerType:t})}function E0(t,e){return new I0({type:"catch",innerType:t,catchValue:typeof e=="function"?e:A.constantCatch(e)})}function MN(t){return Rh(T0,t)}function tg(t,e){return new id({type:"pipe",in:t,out:e})}function FN(t,e,r){return new od({type:"pipe",in:t,out:e,transform:r.decode,reverseTransform:r.encode})}function ZN(t){let e=t._zod.def;return new od({type:"pipe",in:e.out,out:e.in,transform:e.reverseTransform,reverseTransform:e.transform})}function A0(t){return new P0({type:"readonly",innerType:t})}function qN(t,e){return new R0({type:"template_literal",parts:t,...A.normalizeParams(e)})}function z0(t){return new j0({type:"lazy",getter:t})}function VN(t){return new C0({type:"promise",innerType:t})}function BN(t){return new N0({type:"function",input:Array.isArray(t?.input)?f0(t?.input):t?.input??Pe(ct()),output:t?.output??ct()})}function HN(t){let e=new it({check:"custom"});return e._zod.check=t,e}function xg(t,e){return zh(sd,t??(()=>!0),e)}function D0(t,e={}){return Ch(sd,t,e)}function L0(t,e){return Nh(t,e)}function GN(t,e={}){let r=new U0({type:"custom",check:"custom",fn:i=>i instanceof t,abort:!0,...A.normalizeParams(e)});return r._zod.bag.Class=t,r._zod.check=i=>{i.value instanceof t||i.issues.push({code:"invalid_type",expected:t.name,input:i.value,inst:r,path:[...r._zod.def.path??[]]})},r}function XN(t){let e=z0(()=>rt([P(t),Ke(),Nt(),Qu(),Pe(e),at(P(),e)]));return e}function ad(t,e){return new O0({type:"pipe",in:$g(t),out:e})}var Se,rg,sc,st,oo,so,ao,co,ng,ig,ti,Yu,og,sg,ag,cg,lg,ug,dg,fg,Xk,pg,hg,mg,gg,yg,vg,Yk,Qk,_g,ys,ac,vs,cc,lc,bg,e0,t0,r0,n0,i0,o0,s0,ed,a0,td,rd,c0,l0,u0,d0,ic,p0,h0,oc,m0,g0,y0,_s,kg,_0,b0,$0,Sg,x0,I0,T0,id,od,O0,P0,R0,j0,C0,N0,sd,WN,KN,U0,JN,lo=w(()=>{Xt();Xt();ga();jo();Xl();ob();Ym();Jk();Se=$("ZodType",(t,e)=>(hK(),ve.init(t,e),t.def=e,t.type=e.type,t),{check(...t){let e=this.def;return this.clone(A.mergeDefs(e,{checks:[...e.checks??[],...t.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...t){return this.check(...t)},clone(t,e){return Be(this,t,e)},brand(){return this},register(t,e){return t.add(this,e),this},refine(t,e){return this.check(D0(t,e))},superRefine(t,e){return this.check(L0(t,e))},overwrite(t){return this.check(rn(t))},optional(){return ot(this)},exactOptional(){return v0(this)},nullable(){return Xu(this)},nullish(){return ot(Xu(this))},nonoptional(t){return S0(this,t)},array(){return Pe(this)},or(t){return rt([this,t])},and(t){return uc(this,t)},transform(t){return tg(this,$g(t))},default(t){return w0(this,t)},prefault(t){return k0(this,t)},catch(t){return E0(this,t)},pipe(t){return tg(this,t)},readonly(){return A0(this)},describe(t){let e=this.clone();return Jt.add(e,{description:t}),e},meta(...t){if(t.length===0)return Jt.get(this);let e=this.clone();return Jt.add(e,t[0]),e},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(t,...e){return e.length===0?t(this):t(this,...e)},get"~standard"(){return A.hide(this,"~standard",{...Zf(this),jsonSchema:{input:pa(this,"input"),output:pa(this,"output")}})},set"~standard"(t){A.own(this,"~standard",t)},parse:function t(e,r){return Lk(this,e,r,{callee:t})},parseAsync:async function t(e,r){return await Uk(this,e,r,{callee:t})},safeParse(t,e){return Mk(this,t,e)},async safeParseAsync(t,e){return Fk(this,t,e)},get spa(){return this?.safeParseAsync},set spa(t){A.own(this,"spa",t)},validate(t,e){return Xs(this,t,e)},validateAsync(t,e){return Ys(this,t,e)},encode:function t(e,r){return Zk(this,e,r,{callee:t})},decode:function t(e,r){return qk(this,e,r,{callee:t})},encodeAsync:async function t(e,r){return await Vk(this,e,r,{callee:t})},decodeAsync:async function t(e,r){return await Bk(this,e,r,{callee:t})},safeEncode(t,e){return Hk(this,t,e)},safeDecode(t,e){return Wk(this,t,e)},async safeEncodeAsync(t,e){return Kk(this,t,e)},async safeDecodeAsync(t,e){return Gk(this,t,e)},toJSONSchema(t){return kb(this,{})(t)},get description(){return Jt.get(this)?.description},get _def(){return this._zod.def}}),rg=$("_ZodString",(t,e)=>{yi.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Ib(t,r,i,n)},A.derived({format:t=>Vt(t).format??null,minLength:t=>Vt(t).minimum??null,maxLength:t=>Vt(t).maximum??null},{regex(...t){return this.check(Mo(...t))},includes(...t){return this.check(qo(...t))},startsWith(...t){return this.check(Vo(...t))},endsWith(...t){return this.check(Bo(...t))},min(...t){return this.check(Or(...t))},max(...t){return this.check(qi(...t))},length(...t){return this.check(Vi(...t))},nonempty(...t){return this.check(Or(1,...t))},lowercase(t){return this.check(Fo(t))},uppercase(t){return this.check(Zo(t))},trim(){return this.check(Go())},normalize(...t){return this.check(Ko(...t))},toLowerCase(){return this.check(Jo())},toUpperCase(){return this.check(Xo())},slugify(){return this.check(fa())}})),sc=$("ZodString",(t,e)=>{yi.init(t,e),rg.init(t,e)},{email(t){return this.check(vl(ng,t))},url(t){return this.check(da(Yu,t))},jwt(t){return this.check(Ll(_g,t))},emoji(t){return this.check(Sl(og,t))},guid(t){return this.check(_l(ig,t))},uuid(t){return this.check(bl(ti,t))},uuidv4(t){return this.check(wl(ti,t))},uuidv6(t){return this.check($l(ti,t))},uuidv7(t){return this.check(kl(ti,t))},nanoid(t){return this.check(xl(sg,t))},cuid(t){return this.check(Il(ag,t))},cuid2(t){return this.check(El(cg,t))},ulid(t){return this.check(Tl(lg,t))},base64(t){return this.check(Cl(gg,t))},base64url(t){return this.check(Nl(yg,t))},xid(t){return this.check(Ol(ug,t))},ksuid(t){return this.check(Pl(dg,t))},ipv4(t){return this.check(Al(fg,t))},ipv6(t){return this.check(Rl(pg,t))},cidrv4(t){return this.check(jl(hg,t))},cidrv6(t){return this.check(zl(mg,t))},e164(t){return this.check(Dl(vg,t))},datetime(t){return this.check(Ul(oo,t))},date(t){return this.check(Ml(so,t))},time(t){return this.check(Fl(ao,t))},duration(t){return this.check(Zl(co,t))}});st=$("ZodStringFormat",(t,e)=>{Xe.init(t,e),rg.init(t,e)}),oo=$("ZodISODateTime",(t,e)=>{G_.init(t,e),st.init(t,e)}),so=$("ZodISODate",(t,e)=>{J_.init(t,e),st.init(t,e)}),ao=$("ZodISOTime",(t,e)=>{X_.init(t,e),st.init(t,e)}),co=$("ZodISODuration",(t,e)=>{Y_.init(t,e),st.init(t,e)}),ng=$("ZodEmail",(t,e)=>{Bf.init(t,e),st.init(t,e)});ig=$("ZodGUID",(t,e)=>{qf.init(t,e),st.init(t,e)});ti=$("ZodUUID",(t,e)=>{Vf.init(t,e),st.init(t,e)});Yu=$("ZodURL",(t,e)=>{Gf.init(t,e),st.init(t,e)});og=$("ZodEmoji",(t,e)=>{Jf.init(t,e),st.init(t,e)});sg=$("ZodNanoID",(t,e)=>{Xf.init(t,e),st.init(t,e)});ag=$("ZodCUID",(t,e)=>{Yf.init(t,e),st.init(t,e)});cg=$("ZodCUID2",(t,e)=>{Qf.init(t,e),st.init(t,e)});lg=$("ZodULID",(t,e)=>{ep.init(t,e),st.init(t,e)});ug=$("ZodXID",(t,e)=>{tp.init(t,e),st.init(t,e)});dg=$("ZodKSUID",(t,e)=>{rp.init(t,e),st.init(t,e)});fg=$("ZodIPv4",(t,e)=>{np.init(t,e),st.init(t,e)});Xk=$("ZodMAC",(t,e)=>{op.init(t,e),st.init(t,e)});pg=$("ZodIPv6",(t,e)=>{ip.init(t,e),st.init(t,e)});hg=$("ZodCIDRv4",(t,e)=>{sp.init(t,e),st.init(t,e)});mg=$("ZodCIDRv6",(t,e)=>{cp.init(t,e),st.init(t,e)});gg=$("ZodBase64",(t,e)=>{up.init(t,e),st.init(t,e)});yg=$("ZodBase64URL",(t,e)=>{fp.init(t,e),st.init(t,e)});vg=$("ZodE164",(t,e)=>{pp.init(t,e),st.init(t,e)});Yk=$("ZodCreditCard",(t,e)=>{mp.init(t,e),st.init(t,e)});Qk=$("ZodIBAN",(t,e)=>{yp.init(t,e),st.init(t,e)});_g=$("ZodJWT",(t,e)=>{_p.init(t,e),st.init(t,e)});ys=$("ZodCustomStringFormat",(t,e)=>{bp.init(t,e),st.init(t,e)});ac=$("ZodNumber",(t,e)=>{ta.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Eb(t,r,i,n),t.isFinite=!0},A.derived({minValue:t=>{let{minimum:e,exclusiveMinimum:r}=Vt(t);return Math.max(e??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:t=>{let{maximum:e,exclusiveMaximum:r}=Vt(t);return Math.min(e??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:t=>{let{isInt:e,multipleOf:r}=Vt(t);return!!e||!!r?.some(Number.isSafeInteger)},format:t=>Vt(t).format??null},{gt(t,e){return this.check(bn(t,e))},gte(t,e){return this.check(gr(t,e))},min(t,e){return this.check(gr(t,e))},lt(t,e){return this.check(_n(t,e))},lte(t,e){return this.check(mr(t,e))},max(t,e){return this.check(mr(t,e))},int(t){return this.check(eg(t))},safe(t){return this.check(eg(t))},positive(t){return this.check(bn(0,t))},nonnegative(t){return this.check(gr(0,t))},negative(t){return this.check(_n(0,t))},nonpositive(t){return this.check(mr(0,t))},multipleOf(t,e){return this.check(vi(t,e))},step(t,e){return this.check(vi(t,e))},finite(){return this}}));vs=$("ZodNumberFormat",(t,e)=>{wp.init(t,e),ac.init(t,e)});cc=$("ZodBoolean",(t,e)=>{Co.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Tb(t,r,i,n)});lc=$("ZodBigInt",(t,e)=>{ol.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Ob(t,r,i,n)},A.derived({minValue:t=>Vt(t).minimum??null,maxValue:t=>Vt(t).maximum??null,format:t=>Vt(t).format??null},{gte(t,e){return this.check(gr(t,e))},min(t,e){return this.check(gr(t,e))},gt(t,e){return this.check(bn(t,e))},lt(t,e){return this.check(_n(t,e))},lte(t,e){return this.check(mr(t,e))},max(t,e){return this.check(mr(t,e))},positive(t){return this.check(bn(BigInt(0),t))},negative(t){return this.check(_n(BigInt(0),t))},nonpositive(t){return this.check(mr(BigInt(0),t))},nonnegative(t){return this.check(gr(BigInt(0),t))},multipleOf(t,e){return this.check(vi(t,e))}}));bg=$("ZodBigIntFormat",(t,e)=>{$p.init(t,e),lc.init(t,e)});e0=$("ZodSymbol",(t,e)=>{kp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Pb(t,r,i,n)});t0=$("ZodUndefined",(t,e)=>{Sp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Rb(t,r,i,n)});r0=$("ZodNull",(t,e)=>{xp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Ab(t,r,i,n)});n0=$("ZodAny",(t,e)=>{Ip.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Cb(t,r,i,n)});i0=$("ZodUnknown",(t,e)=>{Ep.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Nb(t,r,i,n)});o0=$("ZodNever",(t,e)=>{Tp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>zb(t,r,i,n)});s0=$("ZodVoid",(t,e)=>{Op.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>jb(t,r,i,n)});ed=$("ZodDate",(t,e)=>{Pp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Db(t,r,i,n),t.min=(r,i)=>t.check(gr(r,i)),t.max=(r,i)=>t.check(mr(r,i))},A.derived({minDate:t=>{let{minimum:e}=Vt(t);return e?new Date(e):null},maxDate:t=>{let{maximum:e}=Vt(t);return e?new Date(e):null}},{}));a0=$("ZodArray",(t,e)=>{gs(),sl.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Gb(t,r,i,n),t.element=e.element},{min(t,e){return this.check(Or(t,e))},nonempty(t){return this.check(Or(1,t))},max(t,e){return this.check(qi(t,e))},length(t,e){return this.check(Vi(t,e))},unwrap(){return this.element}});td=$("ZodObject",(t,e)=>{gs(),Q_.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Jb(t,r,i,n),A.installLazyProp(t,"shape",r=>r._zod.def.shape,!1)},{keyof(){return er(Object.keys(this._zod.def.shape))},catchall(t){return this.clone(A.mergeDefs(this._zod.def,{catchall:t}))},passthrough(){return this.clone(A.mergeDefs(this._zod.def,{catchall:ct()}))},loose(){return this.clone(A.mergeDefs(this._zod.def,{catchall:ct()}))},strict(){return this.clone(A.mergeDefs(this._zod.def,{catchall:wg()}))},strip(){return this.clone(A.mergeDefs(this._zod.def,{catchall:void 0}))},extend(t){return A.extend(this,t)},safeExtend(t){return A.safeExtend(this,t)},merge(t){return A.merge(this,t)},pick(t){return A.pick(this,t)},omit(t){return A.omit(this,t)},partial(...t){return A.partial(_s,this,t[0])},exactPartial(...t){return A.partial(kg,this,t[0],"exactPartial")},required(...t){return A.required(Sg,this,t[0])}});rd=$("ZodUnion",(t,e)=>{ra.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Fh(t,r,i,n),t.options=e.options});c0=$("ZodXor",(t,e)=>{rd.init(t,e),Rp.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Fh(t,r,i,n),t.options=e.options});l0=$("ZodDiscriminatedUnion",(t,e)=>{rd.init(t,e),al.init(t,e)});u0=$("ZodIntersection",(t,e)=>{jp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Xb(t,r,i,n)});d0=$("ZodTuple",(t,e)=>{gs(),cl.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Yb(t,r,i,n)},{rest(t){return this.clone({...this._zod.def,rest:t})},partial(){let t=this._zod.def;if(t.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...t,items:t.items.map(e=>new _s({type:"optional",innerType:e}))})}});ic=$("ZodRecord",(t,e)=>{gs(),zp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Qb(t,r,i,n),t.keyType=e.keyType,t.valueType=e.valueType});p0=$("ZodMap",(t,e)=>{gs(),Cp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Wb(t,r,i,n),t.keyType=e.keyType,t.valueType=e.valueType,t.min=(...r)=>t.check(wn(...r)),t.nonempty=r=>t.check(wn(1,r)),t.max=(...r)=>t.check(_i(...r)),t.size=(...r)=>t.check(Zi(...r))});h0=$("ZodSet",(t,e)=>{gs(),Np.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Kb(t,r,i,n),t.min=(...r)=>t.check(wn(...r)),t.nonempty=r=>t.check(wn(1,r)),t.max=(...r)=>t.check(_i(...r)),t.size=(...r)=>t.check(Zi(...r))});oc=$("ZodEnum",(t,e)=>{ll.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(i,n,o)=>Lb(t,i,n,o),t.enum=e.entries,t.options=[...t._zod.values];let r=new Set(Object.keys(e.entries));t.extract=(i,n)=>{let o={};for(let s of i)if(r.has(s))o[s]=e.entries[s];else throw new Error(`Key ${s} not found in enum`);return new oc({...e,checks:[],...A.normalizeParams(n),entries:o})},t.exclude=(i,n)=>{let o={...e.entries};for(let s of i)if(r.has(s))delete o[s];else throw new Error(`Key ${s} not found in enum`);return new oc({...e,checks:[],...A.normalizeParams(n),entries:o})}});m0=$("ZodLiteral",(t,e)=>{ul.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Ub(t,r,i,n),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});g0=$("ZodFile",(t,e)=>{Dp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Zb(t,r,i,n),t.min=(r,i)=>t.check(wn(r,i)),t.max=(r,i)=>t.check(_i(r,i)),t.mime=(r,i)=>t.check(Wo(Array.isArray(r)?r:[r],i))});y0=$("ZodTransform",(t,e)=>{gs(),Lp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Hb(t,r,i,n),t._zod.parse=(r,i)=>{if(i.direction==="backward")throw new Fi(t.constructor.name);r.addIssue=o=>{if(typeof o=="string")r.issues.push(A.issue(o,r.value,e));else{let s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),"input"in s||(s.input=r.value),s.inst??(s.inst=t),r.issues.push(A.issue(s))}};let n=e.transform(r.value,r);return n instanceof Promise?n.then(o=>(r.value=o,r)):(r.value=n,r)}});_s=$("ZodOptional",(t,e)=>{na.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Zh(t,r,i,n),t.unwrap=()=>t._zod.def.innerType});kg=$("ZodExactOptional",(t,e)=>{Up.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Zh(t,r,i,n),t.unwrap=()=>t._zod.def.innerType});_0=$("ZodNullable",(t,e)=>{Mp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>ew(t,r,i,n),t.unwrap=()=>t._zod.def.innerType});b0=$("ZodDefault",(t,e)=>{Fp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>nw(t,r,i,n),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});$0=$("ZodPrefault",(t,e)=>{Zp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>iw(t,r,i,n),t.unwrap=()=>t._zod.def.innerType});Sg=$("ZodNonOptional",(t,e)=>{qp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>tw(t,r,i,n),t.unwrap=()=>t._zod.def.innerType});x0=$("ZodSuccess",(t,e)=>{Vp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>qb(t,r,i,n),t.unwrap=()=>t._zod.def.innerType});I0=$("ZodCatch",(t,e)=>{Bp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>ow(t,r,i,n),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});T0=$("ZodNaN",(t,e)=>{Hp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Mb(t,r,i,n)});id=$("ZodPipe",(t,e)=>{dl.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>sw(t,r,i,n),t.in=e.in,t.out=e.out});od=$("ZodCodec",(t,e)=>{id.init(t,e),ia.init(t,e)});O0=$("ZodPreprocess",(t,e)=>{id.init(t,e),tb.init(t,e)}),P0=$("ZodReadonly",(t,e)=>{Wp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>aw(t,r,i,n),t.unwrap=()=>t._zod.def.innerType});R0=$("ZodTemplateLiteral",(t,e)=>{Kp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Fb(t,r,i,n)});j0=$("ZodLazy",(t,e)=>{oa.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>lw(t,r,i,n),t.unwrap=()=>t._zod.def.getter()});C0=$("ZodPromise",(t,e)=>{Jp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>cw(t,r,i,n),t.unwrap=()=>t._zod.def.innerType});N0=$("ZodFunction",(t,e)=>{Gp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Bb(t,r,i,n)});sd=$("ZodCustom",(t,e)=>{Xp.init(t,e),Se.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Vb(t,r,i,n)});WN=Dh,KN=Lh,U0=$("ZodInstanceOf",(t,e)=>{sd.init(t,e)},{properties(t,e){return this.check(Ho(t,e))}});JN=(...t)=>Uh({Codec:od,Boolean:cc,String:sc},...t)});function gK(t){Pt({customError:t})}function yK(){return Pt().customError}var mK,M0,YN=w(()=>{Xt();mK={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};M0||(M0={})});var bs={};Jr(bs,{ZodISODate:()=>so,ZodISODateTime:()=>oo,ZodISODuration:()=>co,ZodISOTime:()=>ao,date:()=>_K,datetime:()=>vK,duration:()=>wK,time:()=>bK});function vK(t){return Ul(oo,t)}function _K(t){return Ml(so,t)}function bK(t){return Fl(ao,t)}function wK(t){return Zl(co,t)}var Ig=w(()=>{Xt();lo();lo()});function kK(t,e){let r=t.$schema;return r==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":r==="http://json-schema.org/draft-07/schema#"?"draft-7":r==="http://json-schema.org/draft-04/schema#"?"draft-4":e??"draft-2020-12"}function QN(t,e){return t.map((r,i)=>i<e?r:r.optional())}function SK(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}function xK(t,e){if(!t.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let r=t.slice(1).split("/").filter(Boolean);if(r.length===0)return e.rootSchema;let i=e.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===i){let n=r[1]===void 0?void 0:SK(r[1]);if(!n||!e.defs[n])throw new Error(`Reference not found: ${t}`);return e.defs[n]}throw new Error(`Reference not found: ${t}`)}function IK(t,e){return W.transform(i=>i).check(i=>{let n=i.value;if(typeof n!="object"||n===null||Array.isArray(n))return;let o=Object.getOwnPropertyNames(n);if(e.minProperties!==void 0&&o.length<e.minProperties&&i.issues.push({origin:"object",code:"too_small",minimum:e.minProperties,inclusive:!0,message:`Too small: expected object to have >=${e.minProperties} properties`,input:n,inst:t,continue:!0}),e.maxProperties!==void 0&&o.length>e.maxProperties&&i.issues.push({origin:"object",code:"too_big",maximum:e.maxProperties,inclusive:!0,message:`Too big: expected object to have <=${e.maxProperties} properties`,input:n,inst:t,continue:!0}),e.keySchema)for(let s of o){let a=e.keySchema.safeParse(s);a.success||i.issues.push({code:"invalid_key",origin:"record",issues:a.error.issues,input:s,path:[s],continue:!0})}}).pipe(t)}function F0(t,e){if(t===null)return"z";let r=typeof t;if(r!=="object"){if(r==="number"&&Number.isNaN(t))return null;let i=String(t);return`${r[0]}${i.length}:${i}`}if(e.has(t))return null;e.add(t);try{if(Array.isArray(t)){let o=[];for(let s of t){let a=F0(s,e);if(a===null)return null;o.push(a)}return`a${o.length}:[${o.join(",")}]`}let i=Object.keys(t).sort(),n=[];for(let o of i){let s=F0(t[o],e);if(s===null)return null;n.push(`${o.length}:${o}=${s}`)}return`o${n.length}:{${n.join(",")}}`}finally{e.delete(t)}}function cd(t){return typeof t!="object"||t===null?!1:Array.isArray(t)?t.some(cd):typeof t.$ref=="string"?!0:Object.entries(t).some(([e,r])=>EK.has(e)?cd(r):!TK.has(e)||typeof r!="object"||r===null?!1:Object.values(r).some(cd))}function eD(t){return t===1?"element":"elements"}function OK(t,e){return W.transform(i=>i).check(i=>{let n=i.value;if(Array.isArray(n)){if(e.uniqueItems===!0){let o=new Map;for(let s=0;s<n.length;s++){let a=F0(n[s],new Set);if(a===null)continue;let c=o.get(a);if(c===void 0){o.set(a,s);continue}i.issues.push({code:"custom",message:`Array items must be unique: element at index ${s} duplicates the one at index ${c}`,input:n,path:[s],continue:!0})}}if(e.containsSchema){let o=e.minContains??1,s=e.maxContains!==void 0?e.maxContains+1:Number.POSITIVE_INFINITY,a=0;for(let c of n)if(e.containsSchema.safeParse(c).success&&++a>=s)break;a<o&&i.issues.push({code:"custom",message:`Array must contain at least ${o} matching ${eD(o)}; found ${a}`,input:n,continue:!0}),e.maxContains!==void 0&&a>e.maxContains&&i.issues.push({code:"custom",message:`Array must contain at most ${e.maxContains} matching ${eD(e.maxContains)}`,input:n,continue:!0})}}}).pipe(t)}function tD(t,e){if(t!==!1)return t===void 0||t===!0?W.any():wr(t,e)}function rD(t,e){if(t.not!==void 0){if(typeof t.not=="object"&&Object.keys(t.not).length===0)return W.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(t.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(t.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(t.if!==void 0||t.then!==void 0||t.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(t.dependentSchemas!==void 0||t.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(t.$ref){let n=t.$ref;if(e.refs.has(n))return e.refs.get(n);if(e.processing.has(n))return W.lazy(()=>{if(!e.refs.has(n))throw new Error(`Circular reference not resolved: ${n}`);return e.refs.get(n)});e.processing.add(n);let o=xK(n,e),s=wr(o,e);return e.refs.set(n,s),e.processing.delete(n),s}if(t.enum!==void 0){let n=t.enum;if(e.version==="openapi-3.0"&&t.nullable===!0&&n.length===1&&n[0]===null)return W.null();if(n.length===0)return W.never();if(n.length===1)return W.literal(n[0]);if(n.every(s=>typeof s=="string"))return W.enum(n);let o=n.map(s=>W.literal(s));return o.length<2?o[0]:W.union([o[0],o[1],...o.slice(2)])}if(t.const!==void 0)return W.literal(t.const);let r=t.type;if(Array.isArray(r)){let n=r.map(o=>{let s={...t,type:o};return rD(s,e)});return n.length===0?W.never():n.length===1?n[0]:W.union(n)}if(!r)return W.any();let i;switch(r){case"string":{let n=W.string();if(t.format){let o=t.format;o==="email"?n=n.check(W.email()):o==="uri"||o==="uri-reference"?n=n.check(W.url()):o==="uuid"||o==="guid"?n=n.check(W.uuid()):o==="date-time"?n=n.check(W.iso.datetime({offset:!0})):o==="date"?n=n.check(W.iso.date()):o==="time"?n=n.check(W.regex(PK)):o==="duration"?n=n.check(W.iso.duration()):o==="hostname"?n=n.check(W.hostname()):o==="ipv4"?n=n.check(W.ipv4()):o==="ipv6"?n=n.check(W.ipv6()):o==="mac"?n=n.check(W.mac()):o==="cidr"?n=n.check(W.cidrv4()):o==="cidr-v6"?n=n.check(W.cidrv6()):o==="base64"?n=n.check(W.base64()):o==="base64url"?n=n.check(W.base64url()):o==="e164"?n=n.check(W.e164()):o==="credit_card"?n=n.check(W.creditCard()):o==="iban"?n=n.check(W.iban()):o==="jwt"?n=n.check(W.jwt()):o==="emoji"?n=n.check(W.emoji()):o==="nanoid"?n=n.check(W.nanoid()):o==="cuid"?n=n.check(W.cuid()):o==="cuid2"?n=n.check(W.cuid2()):o==="ulid"?n=n.check(W.ulid()):o==="xid"?n=n.check(W.xid()):o==="ksuid"&&(n=n.check(W.ksuid()))}typeof t.minLength=="number"&&(n=n.min(t.minLength)),typeof t.maxLength=="number"&&(n=n.max(t.maxLength)),t.pattern&&(n=n.regex(new RegExp(t.pattern))),i=n;break}case"number":case"integer":{let n=r==="integer"?W.number().int():W.number();typeof t.minimum=="number"&&t.exclusiveMinimum!==!0&&(n=n.min(t.minimum)),typeof t.maximum=="number"&&t.exclusiveMaximum!==!0&&(n=n.max(t.maximum)),typeof t.exclusiveMinimum=="number"?n=n.gt(t.exclusiveMinimum):t.exclusiveMinimum===!0&&typeof t.minimum=="number"&&(n=n.gt(t.minimum)),typeof t.exclusiveMaximum=="number"?n=n.lt(t.exclusiveMaximum):t.exclusiveMaximum===!0&&typeof t.maximum=="number"&&(n=n.lt(t.maximum)),typeof t.multipleOf=="number"&&(n=n.multipleOf(t.multipleOf)),i=n;break}case"boolean":{i=W.boolean();break}case"null":{i=W.null();break}case"object":{let n={},o=t.properties||{},s=new Set(t.required||[]),a=typeof t.additionalProperties=="object"?wr(t.additionalProperties,e):void 0;for(let[d,p]of Object.entries(o)){let f=wr(p,e);Gt(n,d,s.has(d)?f:f.optional())}if(t.patternProperties){let d=t.patternProperties,p=Object.keys(d),f=[];for(let m of p){let g=wr(d[m],e),y=W.string().regex(new RegExp(m));f.push(W.looseRecord(y,g))}let h=[];if(Object.keys(n).length>0&&h.push(W.object(n).passthrough()),h.push(...f),h.length===0)i=W.object({}).passthrough();else if(h.length===1)i=h[0];else{let m=W.intersection(h[0],h[1]);for(let g=2;g<h.length;g++)m=W.intersection(m,h[g]);i=m}if(t.additionalProperties===!1){let m=Object.keys(n),g=p.map(v=>new RegExp(v)),y=i;i=i.check(v=>{if(!en(v.value))return;let b=[];for(let x of Object.keys(v.value))m.includes(x)||g.some(k=>k.test(x))||b.push(x);b.length&&v.issues.push({code:"unrecognized_keys",keys:b,input:v.value,inst:y})})}}else{let d=W.object(n);t.additionalProperties===!1?i=d.strict():a?i=d.catchall(a):i=d.passthrough()}let c=t.propertyNames!==void 0&&t.propertyNames!==!0,l=typeof t.minProperties=="number"?t.minProperties:void 0,u=typeof t.maxProperties=="number"?t.maxProperties:void 0;if(c||l!==void 0||u!==void 0){let d;if(c){let p=typeof t.propertyNames=="object"&&t.propertyNames.type===void 0?{type:"string",...t.propertyNames}:t.propertyNames;d=wr(p,e)}i=IK(i,{keySchema:d,minProperties:l,maxProperties:u})}break}case"array":{let n=t.prefixItems,o=t.items;if(n&&Array.isArray(n)){let s=typeof t.minItems=="number"?t.minItems:0,a=n.map(d=>wr(d,e)),c=QN(a,s),l=Array.isArray(o)?void 0:tD(o,e),u=W.tuple(c);i=l?u.rest(l):u,typeof t.minItems=="number"&&(i=i.check(W.minLength(t.minItems))),typeof t.maxItems=="number"&&(i=i.check(W.maxLength(t.maxItems)))}else if(Array.isArray(o)){let s=typeof t.minItems=="number"?t.minItems:0,a=o.map(d=>wr(d,e)),c=QN(a,s),l=tD(t.additionalItems,e),u=W.tuple(c);i=l?u.rest(l):u,typeof t.minItems=="number"&&(i=i.check(W.minLength(t.minItems))),typeof t.maxItems=="number"&&(i=i.check(W.maxLength(t.maxItems)))}else if(o!==void 0){let s=wr(o,e),a=W.array(s);typeof t.minItems=="number"&&(a=a.min(t.minItems)),typeof t.maxItems=="number"&&(a=a.max(t.maxItems)),i=a}else i=W.array(W.any());(t.uniqueItems===!0||t.contains!==void 0)&&(i=OK(i,{uniqueItems:t.uniqueItems===!0,containsSchema:t.contains!==void 0?wr(t.contains,e):void 0,minContains:typeof t.minContains=="number"?t.minContains:void 0,maxContains:typeof t.maxContains=="number"?t.maxContains:void 0}));break}default:throw new Error(`Unsupported type: ${r}`)}return i}function wr(t,e){if(typeof t=="boolean")return t?W.any():W.never();let r=rD(t,e),i=t.type||t.enum!==void 0||t.const!==void 0;if(t.anyOf&&Array.isArray(t.anyOf)){let a=t.anyOf.map(l=>wr(l,e)),c=W.union(a);r=i?W.intersection(r,c):c}if(t.oneOf&&Array.isArray(t.oneOf)){let a=t.oneOf.map(l=>wr(l,e)),c=W.xor(a);r=i?W.intersection(r,c):c}if(t.allOf&&Array.isArray(t.allOf))if(t.allOf.length===0)r=i?r:W.any();else{let a=i?r:wr(t.allOf[0],e),c=i?0:1;for(let l=c;l<t.allOf.length;l++)a=W.intersection(a,wr(t.allOf[l],e));r=a}t.nullable===!0&&e.version==="openapi-3.0"&&(r=W.nullable(r)),t.readOnly===!0&&(r=W.readonly(r)),t.default!==void 0&&(r=r.default(t.default));let n={},o=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let a of o)a in t&&(n[a]=t[a]);let s=["contentEncoding","contentMediaType","contentSchema"];for(let a of s)a in t&&(n[a]=t[a]);if(t.type==="object"&&t.$ref===void 0){t.propertyNames!==void 0&&!cd(t.propertyNames)&&(n.propertyNames=t.propertyNames);for(let a of["minProperties","maxProperties"])t[a]!==void 0&&(n[a]=t[a])}if(t.type==="array"&&t.$ref===void 0){t.contains!==void 0&&!cd(t.contains)&&(n.contains=t.contains);for(let a of["uniqueItems","minContains","maxContains"])t[a]!==void 0&&(n[a]=t[a])}for(let a of Object.keys(t))$K.has(a)||Gt(n,a,t[a]);return Object.keys(n).length>0&&e.registry.add(r,n),t.description&&(r=r.describe(t.description)),r}function nD(t,e){if(typeof t=="boolean")return t?W.any():W.never();let r;try{r=JSON.parse(JSON.stringify(t))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let i=kK(r,e?.defaultTarget),n=r.$defs||r.definitions||{},o={version:i,defs:n,refs:new Map,processing:new Set,rootSchema:r,registry:e?.registry??Jt};return wr(r,o)}var W,$K,EK,TK,PK,iD=w(()=>{gl();B();Ym();Ig();lo();W={...dc,...Xm,iso:bs},$K=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);EK=new Set(["items","prefixItems","additionalItems","additionalProperties","contains","propertyNames","not","if","then","else","allOf","anyOf","oneOf","unevaluatedItems","unevaluatedProperties","contentSchema"]),TK=new Set(["properties","patternProperties","dependentSchemas","dependencies","$defs","definitions"]);PK=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/});function oD(t){return eu(t,{object:e=>e.partial(),union:e=>{let r=e._zod.def;return r.discriminator===void 0?e:rt(r.options)}})}var sD=w(()=>{dw();lo()});function AK(t,e){if(!e?.length)return t;let r=t._zod.def;return Be(t,Qr(r,{checks:[...r.checks??[],...e]}),{parent:!0})}function aD(t){return AK(t.out,t.checks)}function RK(t){return t.in._zod.traits.has("$ZodTransform")?aD(t):t.in}function cD(t){return eu(t,{pipe:e=>RK(e._zod.def),default:(e,r)=>r?ot(e._zod.def.innerType):e,catch:(e,r)=>r?e._zod.def.innerType:e})}function lD(t){return eu(t,{pipe:e=>aD(e._zod.def),prefault:(e,r)=>r?e._zod.def.innerType:e})}var uD=w(()=>{B();dw();lo()});var Z0={};Jr(Z0,{bigint:()=>NK,boolean:()=>CK,date:()=>DK,number:()=>zK,string:()=>jK});function jK(t){return mb(sc,t)}function zK(t){return yb(ac,t)}function CK(t){return vb(cc,t)}function NK(t){return _b(lc,t)}function DK(t){return bb(ed,t)}var dD=w(()=>{Xt();lo()});var yt={};Jr(yt,{$brand:()=>zv,$input:()=>lb,$output:()=>cb,INVALID:()=>hr,NEVER:()=>jv,TimePrecision:()=>gb,ZodAny:()=>n0,ZodArray:()=>a0,ZodBase64:()=>gg,ZodBase64URL:()=>yg,ZodBigInt:()=>lc,ZodBigIntFormat:()=>bg,ZodBoolean:()=>cc,ZodCIDRv4:()=>hg,ZodCIDRv6:()=>mg,ZodCUID:()=>ag,ZodCUID2:()=>cg,ZodCatch:()=>I0,ZodCodec:()=>od,ZodCompileAsyncError:()=>vn,ZodCompileUnsupportedError:()=>je,ZodCreditCard:()=>Yk,ZodCustom:()=>sd,ZodCustomStringFormat:()=>ys,ZodDate:()=>ed,ZodDefault:()=>b0,ZodDiscriminatedUnion:()=>l0,ZodE164:()=>vg,ZodEmail:()=>ng,ZodEmoji:()=>og,ZodEnum:()=>oc,ZodError:()=>fK,ZodExactOptional:()=>kg,ZodFile:()=>g0,ZodFirstPartyTypeKind:()=>M0,ZodFunction:()=>N0,ZodGUID:()=>ig,ZodIBAN:()=>Qk,ZodIPv4:()=>fg,ZodIPv6:()=>pg,ZodISODate:()=>so,ZodISODateTime:()=>oo,ZodISODuration:()=>co,ZodISOTime:()=>ao,ZodInstanceOf:()=>U0,ZodIntersection:()=>u0,ZodIssueCode:()=>mK,ZodJWT:()=>_g,ZodKSUID:()=>dg,ZodLazy:()=>j0,ZodLiteral:()=>m0,ZodMAC:()=>Xk,ZodMap:()=>p0,ZodNaN:()=>T0,ZodNanoID:()=>sg,ZodNever:()=>o0,ZodNonOptional:()=>Sg,ZodNull:()=>r0,ZodNullable:()=>_0,ZodNumber:()=>ac,ZodNumberFormat:()=>vs,ZodObject:()=>td,ZodOptional:()=>_s,ZodPipe:()=>id,ZodPrefault:()=>$0,ZodPreprocess:()=>O0,ZodPromise:()=>C0,ZodReadonly:()=>P0,ZodRealError:()=>zr,ZodRecord:()=>ic,ZodSet:()=>h0,ZodString:()=>sc,ZodStringFormat:()=>st,ZodSuccess:()=>x0,ZodSymbol:()=>e0,ZodTemplateLiteral:()=>R0,ZodTransform:()=>y0,ZodTuple:()=>d0,ZodType:()=>Se,ZodULID:()=>lg,ZodURL:()=>Yu,ZodUUID:()=>ti,ZodUndefined:()=>t0,ZodUnion:()=>rd,ZodUnknown:()=>i0,ZodVoid:()=>s0,ZodXID:()=>ug,ZodXor:()=>c0,_ZodString:()=>rg,_default:()=>w0,_function:()=>BN,any:()=>IN,array:()=>Pe,base64:()=>sN,base64url:()=>aN,bigint:()=>wN,boolean:()=>Nt,catch:()=>E0,check:()=>HN,cidrv4:()=>iN,cidrv6:()=>oN,clone:()=>Be,codec:()=>FN,coerce:()=>Z0,compile:()=>pb,config:()=>Pt,core:()=>$n,creditCard:()=>lN,cuid:()=>JC,cuid2:()=>XC,currencyCode:()=>mN,custom:()=>xg,date:()=>TN,decode:()=>qk,decodeAsync:()=>Bk,deepPartial:()=>oD,describe:()=>WN,discriminatedUnion:()=>nd,e164:()=>cN,email:()=>MC,emoji:()=>KC,encode:()=>Zk,encodeAsync:()=>Vk,endsWith:()=>Bo,enum:()=>er,exactOptional:()=>v0,file:()=>DN,flattenError:()=>Kc,float32:()=>yN,float64:()=>vN,formatError:()=>Gc,fromJSONSchema:()=>nD,function:()=>BN,getDiscriminatedOption:()=>eb,getErrorMap:()=>yK,globalRegistry:()=>Jt,gt:()=>bn,gte:()=>gr,guid:()=>FC,hash:()=>gN,hex:()=>hN,hostname:()=>pN,httpUrl:()=>WC,iban:()=>uN,includes:()=>qo,input:()=>cD,instanceof:()=>GN,int:()=>eg,int32:()=>_N,int64:()=>$N,intersection:()=>uc,invertCodec:()=>ZN,ipv4:()=>tN,ipv6:()=>nN,iso:()=>bs,json:()=>XN,jwt:()=>dN,keyof:()=>ON,ksuid:()=>eN,lazy:()=>z0,length:()=>Vi,literal:()=>se,locales:()=>la,looseObject:()=>Qt,looseRecord:()=>jN,lowercase:()=>Fo,lt:()=>_n,lte:()=>mr,mac:()=>rN,map:()=>zN,maxLength:()=>qi,maxSize:()=>_i,memoizer:()=>hl,meta:()=>KN,mime:()=>Wo,minLength:()=>Or,minSize:()=>wn,multipleOf:()=>vi,nan:()=>MN,nanoid:()=>GC,nativeEnum:()=>NN,negative:()=>Hl,never:()=>wg,nonnegative:()=>Kl,nonoptional:()=>S0,nonpositive:()=>Wl,normalize:()=>Ko,null:()=>Qu,nullable:()=>Xu,nullish:()=>LN,number:()=>Ke,object:()=>K,optional:()=>ot,output:()=>lD,overwrite:()=>rn,parse:()=>Lk,parseAsync:()=>Uk,partialRecord:()=>RN,pipe:()=>tg,positive:()=>Bl,prefault:()=>k0,preprocess:()=>ad,prettifyError:()=>Uv,promise:()=>VN,properties:()=>Ho,property:()=>Gl,readonly:()=>A0,record:()=>at,refine:()=>D0,regex:()=>Mo,regexes:()=>Fr,registry:()=>lh,safeDecode:()=>Wk,safeDecodeAsync:()=>Gk,safeEncode:()=>Hk,safeEncodeAsync:()=>Kk,safeParse:()=>Mk,safeParseAsync:()=>Fk,set:()=>CN,setErrorMap:()=>gK,size:()=>Zi,slugify:()=>fa,startsWith:()=>Vo,strictObject:()=>PN,string:()=>P,stringFormat:()=>fN,stringbool:()=>JN,success:()=>UN,superRefine:()=>L0,symbol:()=>SN,templateLiteral:()=>qN,toJSONSchema:()=>Yo,toLowerCase:()=>Jo,toUpperCase:()=>Xo,toZod:()=>Mc,transform:()=>$g,treeifyError:()=>Lv,trim:()=>Go,tuple:()=>f0,uint32:()=>bN,uint64:()=>kN,ulid:()=>YC,undefined:()=>xN,union:()=>rt,unknown:()=>ct,uppercase:()=>Zo,url:()=>HC,util:()=>A,uuid:()=>ZC,uuidv4:()=>qC,uuidv6:()=>VC,uuidv7:()=>BC,validate:()=>Xs,validateAsync:()=>Ys,void:()=>EN,withParser:()=>uh,xid:()=>QC,xor:()=>AN});var Eg=w(()=>{Xt();lo();Ym();Dk();Jk();YN();Xt();ga();iD();sD();uD();ah();Ig();Ig();dD()});var fD=w(()=>{Eg()});var pD=w(()=>{fD()});function PD(t){if(t.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${t.params.ref.type}`)}function AD(t){if(t.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${t.params.ref.type}`)}var V0,hD,uo,Og,Bt,mD,gD,fle,UK,MK,B0,Kr,ld,yD,tr,ln,un,rr,Pg,vD,H0,_D,bD,W0,ud,ae,K0,wD,$D,ple,Ag,FK,Rg,ZK,dd,fc,kD,qK,VK,BK,HK,WK,KK,G0,GK,JK,J0,jg,XK,YK,zg,QK,fd,pd,eG,hd,pc,tG,md,Cg,Ng,Dg,hle,Lg,Ug,Mg,SD,xD,ID,X0,ED,gd,hc,TD,rG,Fg,nG,Zg,iG,Y0,oG,qg,sG,aG,cG,lG,uG,dG,fG,pG,hG,mG,Vg,gG,yG,Bg,Q0,eS,tS,vG,_G,bG,rS,wG,$G,kG,SG,xG,OD,Hg,IG,Wg,mle,EG,mc,TG,gle,yd,OG,nS,PG,AG,RG,jG,zG,CG,NG,Tg,DG,LG,UG,vd,iS,MG,FG,ZG,qG,VG,BG,HG,WG,KG,GG,JG,XG,YG,QG,eJ,tJ,rJ,nJ,gc,iJ,oJ,sJ,Kg,aJ,cJ,lJ,oS,uJ,yle,vle,_le,ble,wle,$le,te,q0,yc=w(()=>{pD();V0="2025-11-25",hD=[V0,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],uo="io.modelcontextprotocol/related-task",Og="2.0",Bt=xg(t=>t!==null&&(typeof t=="object"||typeof t=="function")),mD=rt([P(),Ke().int()]),gD=P(),fle=Qt({ttl:Ke().optional(),pollInterval:Ke().optional()}),UK=K({ttl:Ke().optional()}),MK=K({taskId:P()}),B0=Qt({progressToken:mD.optional(),[uo]:MK.optional()}),Kr=K({_meta:B0.optional()}),ld=Kr.extend({task:UK.optional()}),yD=t=>ld.safeParse(t).success,tr=K({method:P(),params:Kr.loose().optional()}),ln=K({_meta:B0.optional()}),un=K({method:P(),params:ln.loose().optional()}),rr=Qt({_meta:B0.optional()}),Pg=rt([P(),Ke().int()]),vD=K({jsonrpc:se(Og),id:Pg,...tr.shape}).strict(),H0=t=>vD.safeParse(t).success,_D=K({jsonrpc:se(Og),...un.shape}).strict(),bD=t=>_D.safeParse(t).success,W0=K({jsonrpc:se(Og),id:Pg,result:rr}).strict(),ud=t=>W0.safeParse(t).success;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError",t[t.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(ae||(ae={}));K0=K({jsonrpc:se(Og),id:Pg.optional(),error:K({code:Ke().int(),message:P(),data:ct().optional()})}).strict(),wD=t=>K0.safeParse(t).success,$D=rt([vD,_D,W0,K0]),ple=rt([W0,K0]),Ag=rr.strict(),FK=ln.extend({requestId:Pg.optional(),reason:P().optional()}),Rg=un.extend({method:se("notifications/cancelled"),params:FK}),ZK=K({src:P(),mimeType:P().optional(),sizes:Pe(P()).optional(),theme:er(["light","dark"]).optional()}),dd=K({icons:Pe(ZK).optional()}),fc=K({name:P(),title:P().optional()}),kD=fc.extend({...fc.shape,...dd.shape,version:P(),websiteUrl:P().optional(),description:P().optional()}),qK=uc(K({applyDefaults:Nt().optional()}),at(P(),ct())),VK=ad(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,uc(K({form:qK.optional(),url:Bt.optional()}),at(P(),ct()).optional())),BK=Qt({list:Bt.optional(),cancel:Bt.optional(),requests:Qt({sampling:Qt({createMessage:Bt.optional()}).optional(),elicitation:Qt({create:Bt.optional()}).optional()}).optional()}),HK=Qt({list:Bt.optional(),cancel:Bt.optional(),requests:Qt({tools:Qt({call:Bt.optional()}).optional()}).optional()}),WK=K({experimental:at(P(),Bt).optional(),sampling:K({context:Bt.optional(),tools:Bt.optional()}).optional(),elicitation:VK.optional(),roots:K({listChanged:Nt().optional()}).optional(),tasks:BK.optional(),extensions:at(P(),Bt).optional()}),KK=Kr.extend({protocolVersion:P(),capabilities:WK,clientInfo:kD}),G0=tr.extend({method:se("initialize"),params:KK}),GK=K({experimental:at(P(),Bt).optional(),logging:Bt.optional(),completions:Bt.optional(),prompts:K({listChanged:Nt().optional()}).optional(),resources:K({subscribe:Nt().optional(),listChanged:Nt().optional()}).optional(),tools:K({listChanged:Nt().optional()}).optional(),tasks:HK.optional(),extensions:at(P(),Bt).optional()}),JK=rr.extend({protocolVersion:P(),capabilities:GK,serverInfo:kD,instructions:P().optional()}),J0=un.extend({method:se("notifications/initialized"),params:ln.optional()}),jg=tr.extend({method:se("ping"),params:Kr.optional()}),XK=K({progress:Ke(),total:ot(Ke()),message:ot(P())}),YK=K({...ln.shape,...XK.shape,progressToken:mD}),zg=un.extend({method:se("notifications/progress"),params:YK}),QK=Kr.extend({cursor:gD.optional()}),fd=tr.extend({params:QK.optional()}),pd=rr.extend({nextCursor:gD.optional()}),eG=er(["working","input_required","completed","failed","cancelled"]),hd=K({taskId:P(),status:eG,ttl:rt([Ke(),Qu()]),createdAt:P(),lastUpdatedAt:P(),pollInterval:ot(Ke()),statusMessage:ot(P())}),pc=rr.extend({task:hd}),tG=ln.merge(hd),md=un.extend({method:se("notifications/tasks/status"),params:tG}),Cg=tr.extend({method:se("tasks/get"),params:Kr.extend({taskId:P()})}),Ng=rr.merge(hd),Dg=tr.extend({method:se("tasks/result"),params:Kr.extend({taskId:P()})}),hle=rr.loose(),Lg=fd.extend({method:se("tasks/list")}),Ug=pd.extend({tasks:Pe(hd)}),Mg=tr.extend({method:se("tasks/cancel"),params:Kr.extend({taskId:P()})}),SD=rr.merge(hd),xD=K({uri:P(),mimeType:ot(P()),_meta:at(P(),ct()).optional()}),ID=xD.extend({text:P()}),X0=P().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),ED=xD.extend({blob:X0}),gd=er(["user","assistant"]),hc=K({audience:Pe(gd).optional(),priority:Ke().min(0).max(1).optional(),lastModified:bs.datetime({offset:!0}).optional()}),TD=K({...fc.shape,...dd.shape,uri:P(),description:ot(P()),mimeType:ot(P()),size:ot(Ke()),annotations:hc.optional(),_meta:ot(Qt({}))}),rG=K({...fc.shape,...dd.shape,uriTemplate:P(),description:ot(P()),mimeType:ot(P()),annotations:hc.optional(),_meta:ot(Qt({}))}),Fg=fd.extend({method:se("resources/list")}),nG=pd.extend({resources:Pe(TD)}),Zg=fd.extend({method:se("resources/templates/list")}),iG=pd.extend({resourceTemplates:Pe(rG)}),Y0=Kr.extend({uri:P()}),oG=Y0,qg=tr.extend({method:se("resources/read"),params:oG}),sG=rr.extend({contents:Pe(rt([ID,ED]))}),aG=un.extend({method:se("notifications/resources/list_changed"),params:ln.optional()}),cG=Y0,lG=tr.extend({method:se("resources/subscribe"),params:cG}),uG=Y0,dG=tr.extend({method:se("resources/unsubscribe"),params:uG}),fG=ln.extend({uri:P()}),pG=un.extend({method:se("notifications/resources/updated"),params:fG}),hG=K({name:P(),description:ot(P()),required:ot(Nt())}),mG=K({...fc.shape,...dd.shape,description:ot(P()),arguments:ot(Pe(hG)),_meta:ot(Qt({}))}),Vg=fd.extend({method:se("prompts/list")}),gG=pd.extend({prompts:Pe(mG)}),yG=Kr.extend({name:P(),arguments:at(P(),P()).optional()}),Bg=tr.extend({method:se("prompts/get"),params:yG}),Q0=K({type:se("text"),text:P(),annotations:hc.optional(),_meta:at(P(),ct()).optional()}),eS=K({type:se("image"),data:X0,mimeType:P(),annotations:hc.optional(),_meta:at(P(),ct()).optional()}),tS=K({type:se("audio"),data:X0,mimeType:P(),annotations:hc.optional(),_meta:at(P(),ct()).optional()}),vG=K({type:se("tool_use"),name:P(),id:P(),input:at(P(),ct()),_meta:at(P(),ct()).optional()}),_G=K({type:se("resource"),resource:rt([ID,ED]),annotations:hc.optional(),_meta:at(P(),ct()).optional()}),bG=TD.extend({type:se("resource_link")}),rS=rt([Q0,eS,tS,bG,_G]),wG=K({role:gd,content:rS}),$G=rr.extend({description:P().optional(),messages:Pe(wG)}),kG=un.extend({method:se("notifications/prompts/list_changed"),params:ln.optional()}),SG=K({title:P().optional(),readOnlyHint:Nt().optional(),destructiveHint:Nt().optional(),idempotentHint:Nt().optional(),openWorldHint:Nt().optional()}),xG=K({taskSupport:er(["required","optional","forbidden"]).optional()}),OD=K({...fc.shape,...dd.shape,description:P().optional(),inputSchema:K({type:se("object"),properties:at(P(),Bt).optional(),required:Pe(P()).optional()}).catchall(ct()),outputSchema:K({type:se("object"),properties:at(P(),Bt).optional(),required:Pe(P()).optional()}).catchall(ct()).optional(),annotations:SG.optional(),execution:xG.optional(),_meta:at(P(),ct()).optional()}),Hg=fd.extend({method:se("tools/list")}),IG=pd.extend({tools:Pe(OD)}),Wg=rr.extend({content:Pe(rS).default([]),structuredContent:at(P(),ct()).optional(),isError:Nt().optional()}),mle=Wg.or(rr.extend({toolResult:ct()})),EG=ld.extend({name:P(),arguments:at(P(),ct()).optional()}),mc=tr.extend({method:se("tools/call"),params:EG}),TG=un.extend({method:se("notifications/tools/list_changed"),params:ln.optional()}),gle=K({autoRefresh:Nt().default(!0),debounceMs:Ke().int().nonnegative().default(300)}),yd=er(["debug","info","notice","warning","error","critical","alert","emergency"]),OG=Kr.extend({level:yd}),nS=tr.extend({method:se("logging/setLevel"),params:OG}),PG=ln.extend({level:yd,logger:P().optional(),data:ct()}),AG=un.extend({method:se("notifications/message"),params:PG}),RG=K({name:P().optional()}),jG=K({hints:Pe(RG).optional(),costPriority:Ke().min(0).max(1).optional(),speedPriority:Ke().min(0).max(1).optional(),intelligencePriority:Ke().min(0).max(1).optional()}),zG=K({mode:er(["auto","required","none"]).optional()}),CG=K({type:se("tool_result"),toolUseId:P().describe("The unique identifier for the corresponding tool call."),content:Pe(rS).default([]),structuredContent:K({}).loose().optional(),isError:Nt().optional(),_meta:at(P(),ct()).optional()}),NG=nd("type",[Q0,eS,tS]),Tg=nd("type",[Q0,eS,tS,vG,CG]),DG=K({role:gd,content:rt([Tg,Pe(Tg)]),_meta:at(P(),ct()).optional()}),LG=ld.extend({messages:Pe(DG),modelPreferences:jG.optional(),systemPrompt:P().optional(),includeContext:er(["none","thisServer","allServers"]).optional(),temperature:Ke().optional(),maxTokens:Ke().int(),stopSequences:Pe(P()).optional(),metadata:Bt.optional(),tools:Pe(OD).optional(),toolChoice:zG.optional()}),UG=tr.extend({method:se("sampling/createMessage"),params:LG}),vd=rr.extend({model:P(),stopReason:ot(er(["endTurn","stopSequence","maxTokens"]).or(P())),role:gd,content:NG}),iS=rr.extend({model:P(),stopReason:ot(er(["endTurn","stopSequence","maxTokens","toolUse"]).or(P())),role:gd,content:rt([Tg,Pe(Tg)])}),MG=K({type:se("boolean"),title:P().optional(),description:P().optional(),default:Nt().optional()}),FG=K({type:se("string"),title:P().optional(),description:P().optional(),minLength:Ke().optional(),maxLength:Ke().optional(),format:er(["email","uri","date","date-time"]).optional(),default:P().optional()}),ZG=K({type:er(["number","integer"]),title:P().optional(),description:P().optional(),minimum:Ke().optional(),maximum:Ke().optional(),default:Ke().optional()}),qG=K({type:se("string"),title:P().optional(),description:P().optional(),enum:Pe(P()),default:P().optional()}),VG=K({type:se("string"),title:P().optional(),description:P().optional(),oneOf:Pe(K({const:P(),title:P()})),default:P().optional()}),BG=K({type:se("string"),title:P().optional(),description:P().optional(),enum:Pe(P()),enumNames:Pe(P()).optional(),default:P().optional()}),HG=rt([qG,VG]),WG=K({type:se("array"),title:P().optional(),description:P().optional(),minItems:Ke().optional(),maxItems:Ke().optional(),items:K({type:se("string"),enum:Pe(P())}),default:Pe(P()).optional()}),KG=K({type:se("array"),title:P().optional(),description:P().optional(),minItems:Ke().optional(),maxItems:Ke().optional(),items:K({anyOf:Pe(K({const:P(),title:P()}))}),default:Pe(P()).optional()}),GG=rt([WG,KG]),JG=rt([BG,HG,GG]),XG=rt([JG,MG,FG,ZG]),YG=ld.extend({mode:se("form").optional(),message:P(),requestedSchema:K({type:se("object"),properties:at(P(),XG),required:Pe(P()).optional()})}),QG=ld.extend({mode:se("url"),message:P(),elicitationId:P(),url:P().url()}),eJ=rt([YG,QG]),tJ=tr.extend({method:se("elicitation/create"),params:eJ}),rJ=ln.extend({elicitationId:P()}),nJ=un.extend({method:se("notifications/elicitation/complete"),params:rJ}),gc=rr.extend({action:er(["accept","decline","cancel"]),content:ad(t=>t===null?void 0:t,at(P(),rt([P(),Ke(),Nt(),Pe(P())])).optional())}),iJ=K({type:se("ref/resource"),uri:P()}),oJ=K({type:se("ref/prompt"),name:P()}),sJ=Kr.extend({ref:rt([oJ,iJ]),argument:K({name:P(),value:P()}),context:K({arguments:at(P(),P()).optional()}).optional()}),Kg=tr.extend({method:se("completion/complete"),params:sJ});aJ=rr.extend({completion:Qt({values:Pe(P()).max(100),total:ot(Ke().int()),hasMore:ot(Nt())})}),cJ=K({uri:P().startsWith("file://"),name:P().optional(),_meta:at(P(),ct()).optional()}),lJ=tr.extend({method:se("roots/list"),params:Kr.optional()}),oS=rr.extend({roots:Pe(cJ)}),uJ=un.extend({method:se("notifications/roots/list_changed"),params:ln.optional()}),yle=rt([jg,G0,Kg,nS,Bg,Vg,Fg,Zg,qg,lG,dG,mc,Hg,Cg,Dg,Lg,Mg]),vle=rt([Rg,zg,J0,uJ,md]),_le=rt([Ag,vd,iS,gc,oS,Ng,Ug,pc]),ble=rt([jg,UG,tJ,lJ,Cg,Dg,Lg,Mg]),wle=rt([Rg,zg,AG,pG,aG,TG,kG,md,nJ]),$le=rt([Ag,JK,aJ,$G,gG,nG,iG,sG,Wg,IG,Ng,Ug,pc]),te=class t extends Error{constructor(e,r,i){super(`MCP error ${e}: ${r}`),this.code=e,this.data=i,this.name="McpError"}static fromError(e,r,i){if(e===ae.UrlElicitationRequired&&i){let n=i;if(n.elicitations)return new q0(n.elicitations,r)}return new t(e,r,i)}},q0=class extends te{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(ae.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}}});function fo(t){return t==="completed"||t==="failed"||t==="cancelled"}var RD=w(()=>{});var zD,jD,CD,Gg=w(()=>{zD=Symbol("Let zodToJsonSchema decide on which parser to use"),jD={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"},CD=t=>typeof t=="string"?{...jD,name:t}:{...jD,...t}});var ND,sS=w(()=>{Gg();ND=t=>{let e=CD(t),r=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,flags:{hasReferencedOpenAiAnyType:!1},currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([i,n])=>[n._def,{def:n._def,path:[...e.basePath,e.definitionPath,i],jsonSchema:void 0}]))}}});function aS(t,e,r,i){i?.errorMessages&&r&&(t.errorMessage={...t.errorMessage,[e]:r})}function Me(t,e,r,i,n){t[e]=r,aS(t,e,i,n)}var po=w(()=>{});var Jg,Xg=w(()=>{Jg=(t,e)=>{let r=0;for(;r<t.length&&r<e.length&&t[r]===e[r];r++);return[(t.length-r).toString(),...e.slice(r)].join("/")}});function $t(t){if(t.target!=="openAi")return{};let e=[...t.basePath,t.definitionPath,t.openAiAnyTypeName];return t.flags.hasReferencedOpenAiAnyType=!0,{$ref:t.$refStrategy==="relative"?Jg(e,t.currentPath):e.join("/")}}var dn=w(()=>{Xg()});function DD(t,e){let r={type:"array"};return t.type?._def&&t.type?._def?.typeName!==Z.ZodAny&&(r.items=ge(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&Me(r,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&Me(r,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(Me(r,"minItems",t.exactLength.value,t.exactLength.message,e),Me(r,"maxItems",t.exactLength.value,t.exactLength.message,e)),r}var cS=w(()=>{Gu();po();Ft()});function LD(t,e){let r={type:"integer",format:"int64"};if(!t.checks)return r;for(let i of t.checks)switch(i.kind){case"min":e.target==="jsonSchema7"?i.inclusive?Me(r,"minimum",i.value,i.message,e):Me(r,"exclusiveMinimum",i.value,i.message,e):(i.inclusive||(r.exclusiveMinimum=!0),Me(r,"minimum",i.value,i.message,e));break;case"max":e.target==="jsonSchema7"?i.inclusive?Me(r,"maximum",i.value,i.message,e):Me(r,"exclusiveMaximum",i.value,i.message,e):(i.inclusive||(r.exclusiveMaximum=!0),Me(r,"maximum",i.value,i.message,e));break;case"multipleOf":Me(r,"multipleOf",i.value,i.message,e);break}return r}var lS=w(()=>{po()});function UD(){return{type:"boolean"}}var uS=w(()=>{});function Yg(t,e){return ge(t.type._def,e)}var Qg=w(()=>{Ft()});var MD,dS=w(()=>{Ft();MD=(t,e)=>ge(t.innerType._def,e)});function fS(t,e,r){let i=r??e.dateStrategy;if(Array.isArray(i))return{anyOf:i.map((n,o)=>fS(t,e,n))};switch(i){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return dJ(t,e)}}var dJ,pS=w(()=>{po();dJ=(t,e)=>{let r={type:"integer",format:"unix-time"};if(e.target==="openApi3")return r;for(let i of t.checks)switch(i.kind){case"min":Me(r,"minimum",i.value,i.message,e);break;case"max":Me(r,"maximum",i.value,i.message,e);break}return r}});function FD(t,e){return{...ge(t.innerType._def,e),default:t.defaultValue()}}var hS=w(()=>{Ft()});function ZD(t,e){return e.effectStrategy==="input"?ge(t.schema._def,e):$t(e)}var mS=w(()=>{Ft();dn()});function qD(t){return{type:"string",enum:Array.from(t.values)}}var gS=w(()=>{});function VD(t,e){let r=[ge(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),ge(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(o=>!!o),i=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,n=[];return r.forEach(o=>{if(fJ(o))n.push(...o.allOf),o.unevaluatedProperties===void 0&&(i=void 0);else{let s=o;if("additionalProperties"in o&&o.additionalProperties===!1){let{additionalProperties:a,...c}=o;s=c}else i=void 0;n.push(s)}}),n.length?{allOf:n,...i}:void 0}var fJ,yS=w(()=>{Ft();fJ=t=>"type"in t&&t.type==="string"?!1:"allOf"in t});function BD(t,e){let r=typeof t.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[t.value]}:{type:r==="bigint"?"integer":r,const:t.value}}var vS=w(()=>{});function ey(t,e){let r={type:"string"};if(t.checks)for(let i of t.checks)switch(i.kind){case"min":Me(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,i.value):i.value,i.message,e);break;case"max":Me(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,i.value):i.value,i.message,e);break;case"email":switch(e.emailStrategy){case"format:email":Rn(r,"email",i.message,e);break;case"format:idn-email":Rn(r,"idn-email",i.message,e);break;case"pattern:zod":$r(r,An.email,i.message,e);break}break;case"url":Rn(r,"uri",i.message,e);break;case"uuid":Rn(r,"uuid",i.message,e);break;case"regex":$r(r,i.regex,i.message,e);break;case"cuid":$r(r,An.cuid,i.message,e);break;case"cuid2":$r(r,An.cuid2,i.message,e);break;case"startsWith":$r(r,RegExp(`^${bS(i.value,e)}`),i.message,e);break;case"endsWith":$r(r,RegExp(`${bS(i.value,e)}$`),i.message,e);break;case"datetime":Rn(r,"date-time",i.message,e);break;case"date":Rn(r,"date",i.message,e);break;case"time":Rn(r,"time",i.message,e);break;case"duration":Rn(r,"duration",i.message,e);break;case"length":Me(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,i.value):i.value,i.message,e),Me(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,i.value):i.value,i.message,e);break;case"includes":{$r(r,RegExp(bS(i.value,e)),i.message,e);break}case"ip":{i.version!=="v6"&&Rn(r,"ipv4",i.message,e),i.version!=="v4"&&Rn(r,"ipv6",i.message,e);break}case"base64url":$r(r,An.base64url,i.message,e);break;case"jwt":$r(r,An.jwt,i.message,e);break;case"cidr":{i.version!=="v6"&&$r(r,An.ipv4Cidr,i.message,e),i.version!=="v4"&&$r(r,An.ipv6Cidr,i.message,e);break}case"emoji":$r(r,An.emoji(),i.message,e);break;case"ulid":{$r(r,An.ulid,i.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{Rn(r,"binary",i.message,e);break}case"contentEncoding:base64":{Me(r,"contentEncoding","base64",i.message,e);break}case"pattern:zod":{$r(r,An.base64,i.message,e);break}}break}case"nanoid":$r(r,An.nanoid,i.message,e);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function bS(t,e){return e.patternStrategy==="escape"?hJ(t):t}function hJ(t){let e="";for(let r=0;r<t.length;r++)pJ.has(t[r])||(e+="\\"),e+=t[r];return e}function Rn(t,e,r,i){t.format||t.anyOf?.some(n=>n.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format,...t.errorMessage&&i.errorMessages&&{errorMessage:{format:t.errorMessage.format}}}),delete t.format,t.errorMessage&&(delete t.errorMessage.format,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.anyOf.push({format:e,...r&&i.errorMessages&&{errorMessage:{format:r}}})):Me(t,"format",e,r,i)}function $r(t,e,r,i){t.pattern||t.allOf?.some(n=>n.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern,...t.errorMessage&&i.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}}}),delete t.pattern,t.errorMessage&&(delete t.errorMessage.pattern,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.allOf.push({pattern:HD(e,i),...r&&i.errorMessages&&{errorMessage:{pattern:r}}})):Me(t,"pattern",HD(e,i),r,i)}function HD(t,e){if(!e.applyRegexFlags||!t.flags)return t.source;let r={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},i=r.i?t.source.toLowerCase():t.source,n="",o=!1,s=!1,a=!1;for(let c=0;c<i.length;c++){if(o){n+=i[c],o=!1;continue}if(r.i){if(s){if(i[c].match(/[a-z]/)){a?(n+=i[c],n+=`${i[c-2]}-${i[c]}`.toUpperCase(),a=!1):i[c+1]==="-"&&i[c+2]?.match(/[a-z]/)?(n+=i[c],a=!0):n+=`${i[c]}${i[c].toUpperCase()}`;continue}}else if(i[c].match(/[a-z]/)){n+=`[${i[c]}${i[c].toUpperCase()}]`;continue}}if(r.m){if(i[c]==="^"){n+=`(^|(?<=[\r
121
121
  ]))`;continue}else if(i[c]==="$"){n+=`($|(?=[\r
122
122
  ]))`;continue}}if(r.s&&i[c]==="."){n+=s?`${i[c]}\r
123
123
  `:`[${i[c]}\r
124
- ]`;continue}n+=i[c],i[c]==="\\"?o=!0:s&&i[c]==="]"?s=!1:!s&&i[c]==="["&&(s=!0)}try{new RegExp(n)}catch{return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),t.source}return n}var _S,An,uJ,ty=w(()=>{po();An={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(_S===void 0&&(_S=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),_S),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?: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])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};uJ=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789")});function ry(t,e){if(e.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),e.target==="openApi3"&&t.keyType?._def.typeName===Z.ZodEnum)return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((i,n)=>({...i,[n]:ge(t.valueType._def,{...e,currentPath:[...e.currentPath,"properties",n]})??$t(e)}),{}),additionalProperties:e.rejectedAdditionalProperties};let r={type:"object",additionalProperties:ge(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??e.allowedAdditionalProperties};if(e.target==="openApi3")return r;if(t.keyType?._def.typeName===Z.ZodString&&t.keyType._def.checks?.length){let{type:i,...n}=ey(t.keyType._def,e);return{...r,propertyNames:n}}else{if(t.keyType?._def.typeName===Z.ZodEnum)return{...r,propertyNames:{enum:t.keyType._def.values}};if(t.keyType?._def.typeName===Z.ZodBranded&&t.keyType._def.type._def.typeName===Z.ZodString&&t.keyType._def.type._def.checks?.length){let{type:i,...n}=Yg(t.keyType._def,e);return{...r,propertyNames:n}}}return r}var ny=w(()=>{Gu();Ft();ty();Qg();dn()});function WD(t,e){if(e.mapStrategy==="record")return ry(t,e);let r=ge(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||$t(e),i=ge(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||$t(e);return{type:"array",maxItems:125,items:{type:"array",items:[r,i],minItems:2,maxItems:2}}}var wS=w(()=>{Ft();ny();dn()});function KD(t){let e=t.values,i=Object.keys(t.values).filter(o=>typeof e[e[o]]!="number").map(o=>e[o]),n=Array.from(new Set(i.map(o=>typeof o)));return{type:n.length===1?n[0]==="string"?"string":"number":["string","number"],enum:i}}var $S=w(()=>{});function GD(t){return t.target==="openAi"?void 0:{not:$t({...t,currentPath:[...t.currentPath,"not"]})}}var kS=w(()=>{dn()});function JD(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var SS=w(()=>{});function YD(t,e){if(e.target==="openApi3")return XD(t,e);let r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(i=>i._def.typeName in _d&&(!i._def.checks||!i._def.checks.length))){let i=r.reduce((n,o)=>{let s=_d[o._def.typeName];return s&&!n.includes(s)?[...n,s]:n},[]);return{type:i.length>1?i:i[0]}}else if(r.every(i=>i._def.typeName==="ZodLiteral"&&!i.description)){let i=r.reduce((n,o)=>{let s=typeof o._def.value;switch(s){case"string":case"number":case"boolean":return[...n,s];case"bigint":return[...n,"integer"];case"object":if(o._def.value===null)return[...n,"null"];case"symbol":case"undefined":case"function":default:return n}},[]);if(i.length===r.length){let n=i.filter((o,s,a)=>a.indexOf(o)===s);return{type:n.length>1?n:n[0],enum:r.reduce((o,s)=>o.includes(s._def.value)?o:[...o,s._def.value],[])}}}else if(r.every(i=>i._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((i,n)=>[...i,...n._def.values.filter(o=>!i.includes(o))],[])};return XD(t,e)}var _d,XD,iy=w(()=>{Ft();_d={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};XD=(t,e)=>{let r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((i,n)=>ge(i._def,{...e,currentPath:[...e.currentPath,"anyOf",`${n}`]})).filter(i=>!!i&&(!e.strictUnions||typeof i=="object"&&Object.keys(i).length>0));return r.length?{anyOf:r}:void 0}});function QD(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return e.target==="openApi3"?{type:_d[t.innerType._def.typeName],nullable:!0}:{type:[_d[t.innerType._def.typeName],"null"]};if(e.target==="openApi3"){let i=ge(t.innerType._def,{...e,currentPath:[...e.currentPath]});return i&&"$ref"in i?{allOf:[i],nullable:!0}:i&&{...i,nullable:!0}}let r=ge(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}var xS=w(()=>{Ft();iy()});function e1(t,e){let r={type:"number"};if(!t.checks)return r;for(let i of t.checks)switch(i.kind){case"int":r.type="integer",aS(r,"type",i.message,e);break;case"min":e.target==="jsonSchema7"?i.inclusive?Me(r,"minimum",i.value,i.message,e):Me(r,"exclusiveMinimum",i.value,i.message,e):(i.inclusive||(r.exclusiveMinimum=!0),Me(r,"minimum",i.value,i.message,e));break;case"max":e.target==="jsonSchema7"?i.inclusive?Me(r,"maximum",i.value,i.message,e):Me(r,"exclusiveMaximum",i.value,i.message,e):(i.inclusive||(r.exclusiveMaximum=!0),Me(r,"maximum",i.value,i.message,e));break;case"multipleOf":Me(r,"multipleOf",i.value,i.message,e);break}return r}var IS=w(()=>{po()});function t1(t,e){let r=e.target==="openAi",i={type:"object",properties:{}},n=[],o=t.shape();for(let a in o){let c=o[a];if(c===void 0||c._def===void 0)continue;let l=pJ(c);l&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),l=!1);let u=ge(c._def,{...e,currentPath:[...e.currentPath,"properties",a],propertyPath:[...e.currentPath,"properties",a]});u!==void 0&&(i.properties[a]=u,l||n.push(a))}n.length&&(i.required=n);let s=fJ(t,e);return s!==void 0&&(i.additionalProperties=s),i}function fJ(t,e){if(t.catchall._def.typeName!=="ZodNever")return ge(t.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]});switch(t.unknownKeys){case"passthrough":return e.allowedAdditionalProperties;case"strict":return e.rejectedAdditionalProperties;case"strip":return e.removeAdditionalStrategy==="strict"?e.allowedAdditionalProperties:e.rejectedAdditionalProperties}}function pJ(t){try{return t.isOptional()}catch{return!0}}var ES=w(()=>{Ft()});var r1,TS=w(()=>{Ft();dn();r1=(t,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return ge(t.innerType._def,e);let r=ge(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return r?{anyOf:[{not:$t(e)},r]}:$t(e)}});var n1,OS=w(()=>{Ft();n1=(t,e)=>{if(e.pipeStrategy==="input")return ge(t.in._def,e);if(e.pipeStrategy==="output")return ge(t.out._def,e);let r=ge(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),i=ge(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,i].filter(n=>n!==void 0)}}});function i1(t,e){return ge(t.type._def,e)}var PS=w(()=>{Ft()});function o1(t,e){let i={type:"array",uniqueItems:!0,items:ge(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&Me(i,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&Me(i,"maxItems",t.maxSize.value,t.maxSize.message,e),i}var AS=w(()=>{po();Ft()});function s1(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,i)=>ge(r._def,{...e,currentPath:[...e.currentPath,"items",`${i}`]})).reduce((r,i)=>i===void 0?r:[...r,i],[]),additionalItems:ge(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,i)=>ge(r._def,{...e,currentPath:[...e.currentPath,"items",`${i}`]})).reduce((r,i)=>i===void 0?r:[...r,i],[])}}var RS=w(()=>{Ft()});function a1(t){return{not:$t(t)}}var jS=w(()=>{dn()});function c1(t){return $t(t)}var zS=w(()=>{dn()});var l1,CS=w(()=>{Ft();l1=(t,e)=>ge(t.innerType._def,e)});var u1,NS=w(()=>{Gu();dn();cS();lS();uS();Qg();dS();pS();hS();mS();gS();yS();vS();wS();$S();kS();SS();xS();IS();ES();TS();OS();PS();ny();AS();ty();RS();jS();iy();zS();CS();u1=(t,e,r)=>{switch(e){case Z.ZodString:return ey(t,r);case Z.ZodNumber:return e1(t,r);case Z.ZodObject:return t1(t,r);case Z.ZodBigInt:return LD(t,r);case Z.ZodBoolean:return UD();case Z.ZodDate:return fS(t,r);case Z.ZodUndefined:return a1(r);case Z.ZodNull:return JD(r);case Z.ZodArray:return DD(t,r);case Z.ZodUnion:case Z.ZodDiscriminatedUnion:return YD(t,r);case Z.ZodIntersection:return VD(t,r);case Z.ZodTuple:return s1(t,r);case Z.ZodRecord:return ry(t,r);case Z.ZodLiteral:return BD(t,r);case Z.ZodEnum:return qD(t);case Z.ZodNativeEnum:return KD(t);case Z.ZodNullable:return QD(t,r);case Z.ZodOptional:return r1(t,r);case Z.ZodMap:return WD(t,r);case Z.ZodSet:return o1(t,r);case Z.ZodLazy:return()=>t.getter()._def;case Z.ZodPromise:return i1(t,r);case Z.ZodNaN:case Z.ZodNever:return GD(r);case Z.ZodEffects:return ZD(t,r);case Z.ZodAny:return $t(r);case Z.ZodUnknown:return c1(r);case Z.ZodDefault:return FD(t,r);case Z.ZodBranded:return Yg(t,r);case Z.ZodReadonly:return l1(t,r);case Z.ZodCatch:return MD(t,r);case Z.ZodPipeline:return n1(t,r);case Z.ZodFunction:case Z.ZodVoid:case Z.ZodSymbol:return;default:return(i=>{})(e)}}});function ge(t,e,r=!1){let i=e.seen.get(t);if(e.override){let a=e.override?.(t,e,i,r);if(a!==zD)return a}if(i&&!r){let a=hJ(i,e);if(a!==void 0)return a}let n={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,n);let o=u1(t,t.typeName,e),s=typeof o=="function"?ge(o(),e):o;if(s&&mJ(t,e,s),e.postProcess){let a=e.postProcess(s,t,e);return n.jsonSchema=s,a}return n.jsonSchema=s,s}var hJ,mJ,Ft=w(()=>{Gg();NS();Xg();dn();hJ=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:Jg(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((r,i)=>e.currentPath[i]===r)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),$t(e)):e.$refStrategy==="seen"?$t(e):void 0}},mJ=(t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),r)});var d1=w(()=>{});var DS,LS=w(()=>{Ft();sS();dn();DS=(t,e)=>{let r=ND(e),i=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[l,u])=>({...c,[l]:ge(u._def,{...r,currentPath:[...r.basePath,r.definitionPath,l]},!0)??$t(r)}),{}):void 0,n=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,o=ge(t._def,n===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,n]},!1)??$t(r),s=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;s!==void 0&&(o.title=s),r.flags.hasReferencedOpenAiAnyType&&(i||(i={}),i[r.openAiAnyTypeName]||(i[r.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:r.$refStrategy==="relative"?"1":[...r.basePath,r.definitionPath,r.openAiAnyTypeName].join("/")}}));let a=n===void 0?i?{...o,[r.definitionPath]:i}:o:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,n].join("/"),[r.definitionPath]:{...i,[n]:o}};return r.target==="jsonSchema7"?a.$schema="http://json-schema.org/draft-07/schema#":(r.target==="jsonSchema2019-09"||r.target==="openAi")&&(a.$schema="https://json-schema.org/draft/2019-09/schema#"),r.target==="openAi"&&("anyOf"in a||"oneOf"in a||"allOf"in a||"type"in a&&Array.isArray(a.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),a}});var f1=w(()=>{Gg();sS();po();Xg();Ft();d1();dn();cS();lS();uS();Qg();dS();pS();hS();mS();gS();yS();vS();wS();$S();kS();SS();xS();IS();ES();TS();OS();PS();CS();ny();AS();ty();RS();jS();iy();zS();NS();LS();LS()});function gJ(t){return!t||t==="jsonSchema7"||t==="draft-7"?"draft-7":t==="jsonSchema2019-09"||t==="draft-2020-12"?"draft-2020-12":"draft-7"}function US(t,e){return ei(t)?Yo(t,{target:gJ(e?.target),io:e?.pipeStrategy??"input"}):DS(t,{strictUnions:e?.strictUnions??!0,pipeStrategy:e?.pipeStrategy??"input"})}function MS(t){let r=io(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let i=nc(r);if(typeof i!="string")throw new Error("Schema method literal must be a string");return i}function FS(t,e){let r=no(t,e);if(!r.success)throw r.error;return r.data}var ZS=w(()=>{Nk();Ju();f1()});function p1(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function h1(t,e){let r={...t};for(let i in e){let n=i,o=e[n];if(o===void 0)continue;let s=r[n];p1(s)&&p1(o)?r[n]={...s,...o}:r[n]=o}return r}var yJ,oy,m1=w(()=>{Ju();yc();RD();ZS();yJ=6e4,oy=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(Rg,r=>{this._oncancel(r)}),this.setNotificationHandler(zg,r=>{this._onprogress(r)}),this.setRequestHandler(jg,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Cg,async(r,i)=>{let n=await this._taskStore.getTask(r.params.taskId,i.sessionId);if(!n)throw new te(ae.InvalidParams,"Failed to retrieve task: Task not found");return{...n}}),this.setRequestHandler(Dg,async(r,i)=>{let n=async()=>{let o=r.params.taskId;if(!await this._taskStore.getTask(o,i.sessionId))throw new te(ae.InvalidParams,`Task not found: ${o}`);if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(o,i.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,l=c.id,u=this._requestResolvers.get(l);if(u)if(this._requestResolvers.delete(l),a.type==="response")u(c);else{let d=c,p=new te(d.error.code,d.error.message,d.error.data);u(p)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${l}`))}continue}await this._transport?.send(a.message,{relatedRequestId:i.requestId})}}let s=await this._taskStore.getTask(o,i.sessionId);if(!s)throw new te(ae.InvalidParams,`Task not found: ${o}`);if(!fo(s.status))return await this._waitForTaskUpdate(o,i.signal,i.sessionId),await n();if(fo(s.status)){let a=await this._taskStore.getTaskResult(o,i.sessionId);return this._clearTaskQueue(o,i.sessionId),{...a,_meta:{...a._meta,[uo]:{taskId:o}}}}return await n()};return await n()}),this.setRequestHandler(Lg,async(r,i)=>{try{let{tasks:n,nextCursor:o}=await this._taskStore.listTasks(r.params?.cursor,i.sessionId);return{tasks:n,nextCursor:o,_meta:{}}}catch(n){throw new te(ae.InvalidParams,`Failed to list tasks: ${n instanceof Error?n.message:String(n)}`)}}),this.setRequestHandler(Mg,async(r,i)=>{try{let n=await this._taskStore.getTask(r.params.taskId,i.sessionId);if(!n)throw new te(ae.InvalidParams,`Task not found: ${r.params.taskId}`);if(fo(n.status))throw new te(ae.InvalidParams,`Cannot cancel task in terminal status: ${n.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",i.sessionId),this._clearTaskQueue(r.params.taskId,i.sessionId);let o=await this._taskStore.getTask(r.params.taskId,i.sessionId);if(!o)throw new te(ae.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...o}}catch(n){throw n instanceof te?n:new te(ae.InvalidRequest,`Failed to cancel task: ${n instanceof Error?n.message:String(n)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,r,i,n,o=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(n,r),startTime:Date.now(),timeout:r,maxTotalTimeout:i,resetTimeoutOnProgress:o,onTimeout:n})}_resetTimeout(e){let r=this._timeoutInfo.get(e);if(!r)return!1;let i=Date.now()-r.startTime;if(r.maxTotalTimeout&&i>=r.maxTotalTimeout)throw this._timeoutInfo.delete(e),te.fromError(ae.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:i});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(e){let r=this._timeoutInfo.get(e);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let i=this.transport?.onerror;this._transport.onerror=o=>{i?.(o),this._onerror(o)};let n=this._transport?.onmessage;this._transport.onmessage=(o,s)=>{n?.(o,s),ud(o)||wD(o)?this._onresponse(o):H0(o)?this._onrequest(o,s):bD(o)?this._onnotification(o):this._onerror(new Error(`Unknown message type: ${JSON.stringify(o)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let i of this._timeoutInfo.values())clearTimeout(i.timeoutId);this._timeoutInfo.clear();for(let i of this._requestHandlerAbortControllers.values())i.abort();this._requestHandlerAbortControllers.clear();let r=te.fromError(ae.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let i of e.values())i(r)}_onerror(e){this.onerror?.(e)}_onnotification(e){let r=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(e)).catch(i=>this._onerror(new Error(`Uncaught error in notification handler: ${i}`)))}_onrequest(e,r){let i=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,n=this._transport,o=e.params?._meta?.[uo]?.taskId,s=n?.sessionId,a=this._taskStore,c=!0,l;if(o&&a&&this._taskMessageQueue&&s!==void 0&&(c=!1,l=(async()=>{if(!await a.getTask(o,s))throw new te(ae.InvalidParams,`Task not found: ${o}`);c=!0})()),i===void 0){let h={jsonrpc:"2.0",id:e.id,error:{code:ae.MethodNotFound,message:"Method not found"}};if(o&&l){let m={type:"error",message:h,timestamp:Date.now()};l.then(()=>this._enqueueTaskMessage(o,m,s),()=>n?.send(h)).catch(g=>this._onerror(new Error(`Failed to send an error response: ${g}`)))}else o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:h,timestamp:Date.now()},n?.sessionId).catch(m=>this._onerror(new Error(`Failed to enqueue error response: ${m}`))):n?.send(h).catch(m=>this._onerror(new Error(`Failed to send an error response: ${m}`)));return}let u=new AbortController;this._requestHandlerAbortControllers.set(e.id,u);let d=yD(e.params)?e.params.task:void 0,p=this._taskStore?this.requestTaskStore(e,n?.sessionId):void 0,f={signal:u.signal,sessionId:n?.sessionId,_meta:e.params?._meta,sendNotification:async h=>{if(u.signal.aborted)return;let m={relatedRequestId:e.id};o&&(m.relatedTask={taskId:o}),await this.notification(h,m)},sendRequest:async(h,m,g)=>{if(u.signal.aborted)throw new te(ae.ConnectionClosed,"Request was cancelled");let y={...g,relatedRequestId:e.id};o&&!y.relatedTask&&(y.relatedTask={taskId:o});let v=y.relatedTask?.taskId??o;return v&&p&&await p.updateTaskStatus(v,"input_required"),await this.request(h,m,y)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:o,taskStore:p,taskRequestedTtl:d?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};(l??Promise.resolve()).then(()=>{if(l&&u.signal.aborted)throw new te(ae.ConnectionClosed,"Request was cancelled");d&&this.assertTaskHandlerCapability(e.method)}).then(()=>i(e,f)).then(async h=>{if(u.signal.aborted)return;let m={result:h,jsonrpc:"2.0",id:e.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:m,timestamp:Date.now()},n?.sessionId):await n?.send(m)},async h=>{if(u.signal.aborted)return;let m={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(h.code)?h.code:ae.InternalError,message:h.message??"Internal error",...h.data!==void 0&&{data:h.data}}};o&&this._taskMessageQueue&&c?await this._enqueueTaskMessage(o,{type:"error",message:m,timestamp:Date.now()},n?.sessionId):await n?.send(m)}).catch(h=>this._onerror(new Error(`Failed to send response: ${h}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===u&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:r,...i}=e.params,n=Number(r),o=this._progressHandlers.get(n);if(!o){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let s=this._responseHandlers.get(n),a=this._timeoutInfo.get(n);if(a&&s&&a.resetTimeoutOnProgress)try{this._resetTimeout(n)}catch(c){this._responseHandlers.delete(n),this._progressHandlers.delete(n),this._cleanupTimeout(n),s(c);return}o(i)}_onresponse(e){let r=Number(e.id),i=this._requestResolvers.get(r);if(i){if(this._requestResolvers.delete(r),ud(e))i(e);else{let s=new te(e.error.code,e.error.message,e.error.data);i(s)}return}let n=this._responseHandlers.get(r);if(n===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let o=!1;if(ud(e)&&e.result&&typeof e.result=="object"){let s=e.result;if(s.task&&typeof s.task=="object"){let a=s.task;typeof a.taskId=="string"&&(o=!0,this._taskProgressTokens.set(a.taskId,r))}}if(o||this._progressHandlers.delete(r),ud(e))n(e);else{let s=te.fromError(e.error.code,e.error.message,e.error.data);n(s)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,r,i){let{task:n}=i??{};if(!n){try{yield{type:"result",result:await this.request(e,r,i)}}catch(s){yield{type:"error",error:s instanceof te?s:new te(ae.InternalError,String(s))}}return}let o;try{let s=await this.request(e,pc,i);if(s.task)o=s.task.taskId,yield{type:"taskCreated",task:s.task};else throw new te(ae.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:o},i);if(yield{type:"taskStatus",task:a},fo(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},r,i)}:a.status==="failed"?yield{type:"error",error:new te(ae.InternalError,`Task ${o} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new te(ae.InternalError,`Task ${o} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:o},r,i)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(l=>setTimeout(l,c)),i?.signal?.throwIfAborted()}}catch(s){yield{type:"error",error:s instanceof te?s:new te(ae.InternalError,String(s))}}}request(e,r,i){let{relatedRequestId:n,resumptionToken:o,onresumptiontoken:s,task:a,relatedTask:c}=i??{};return new Promise((l,u)=>{let d=v=>{u(v)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),a&&this.assertTaskCapability(e.method)}catch(v){d(v);return}i?.signal?.throwIfAborted();let p=this._requestMessageId++,f={...e,jsonrpc:"2.0",id:p};i?.onprogress&&(this._progressHandlers.set(p,i.onprogress),f.params={...e.params,_meta:{...e.params?._meta||{},progressToken:p}}),a&&(f.params={...f.params,task:a}),c&&(f.params={...f.params,_meta:{...f.params?._meta||{},[uo]:c}});let h=v=>{this._responseHandlers.delete(p),this._progressHandlers.delete(p),this._cleanupTimeout(p),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:p,reason:String(v)}},{relatedRequestId:n,resumptionToken:o,onresumptiontoken:s}).catch(x=>this._onerror(new Error(`Failed to send cancellation: ${x}`)));let b=v instanceof te?v:new te(ae.RequestTimeout,String(v));u(b)};this._responseHandlers.set(p,v=>{if(!i?.signal?.aborted){if(v instanceof Error)return u(v);try{let b=no(r,v.result);b.success?l(b.data):u(b.error)}catch(b){u(b)}}}),i?.signal?.addEventListener("abort",()=>{h(i?.signal?.reason)});let m=i?.timeout??yJ,g=()=>h(te.fromError(ae.RequestTimeout,"Request timed out",{timeout:m}));this._setupTimeout(p,m,i?.maxTotalTimeout,g,i?.resetTimeoutOnProgress??!1);let y=c?.taskId;if(y){let v=b=>{let x=this._responseHandlers.get(p);x?x(b):this._onerror(new Error(`Response handler missing for side-channeled request ${p}`))};this._requestResolvers.set(p,v),this._enqueueTaskMessage(y,{type:"request",message:f,timestamp:Date.now()}).catch(b=>{this._cleanupTimeout(p),u(b)})}else this._transport.send(f,{relatedRequestId:n,resumptionToken:o,onresumptiontoken:s}).catch(v=>{this._cleanupTimeout(p),u(v)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},Ng,r)}async getTaskResult(e,r,i){return this.request({method:"tasks/result",params:e},r,i)}async listTasks(e,r){return this.request({method:"tasks/list",params:e},Ug,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},SD,r)}async notification(e,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);let i=r?.relatedTask?.taskId;if(i){let a={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[uo]:r.relatedTask}}};await this._enqueueTaskMessage(i,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let a={...e,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[uo]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let s={...e,jsonrpc:"2.0"};r?.relatedTask&&(s={...s,params:{...s.params,_meta:{...s.params?._meta||{},[uo]:r.relatedTask}}}),await this._transport.send(s,r)}setRequestHandler(e,r){let i=MS(e);this.assertRequestHandlerCapability(i),this._requestHandlers.set(i,(n,o)=>{let s=FS(e,n);return Promise.resolve(r(s,o))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,r){let i=MS(e);this._notificationHandlers.set(i,n=>{let o=FS(e,n);return Promise.resolve(r(o))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let r=this._taskProgressTokens.get(e);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,r,i){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let n=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,r,i??this._transport?.sessionId,n)}async _clearTaskQueue(e,r){if(this._taskMessageQueue){let i=await this._taskMessageQueue.dequeueAll(e,r);for(let n of i)if(n.type==="request"&&H0(n.message)){let o=n.message.id,s=this._requestResolvers.get(o);s?(s(new te(ae.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(o)):this._onerror(new Error(`Resolver missing for request ${o} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,r,i){let n=this._options?.defaultTaskPollInterval??1e3;try{let o=await this._taskStore?.getTask(e,i);o?.pollInterval&&(n=o.pollInterval)}catch{}return new Promise((o,s)=>{if(r.aborted){s(new te(ae.InvalidRequest,"Request cancelled"));return}let a=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(a),s(new te(ae.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,r){let i=this._taskStore;if(!i)throw new Error("No task store configured");return{createTask:async n=>{if(!e)throw new Error("No request provided");return await i.createTask(n,e.id,{method:e.method,params:e.params},r)},getTask:async n=>{let o=await i.getTask(n,r);if(!o)throw new te(ae.InvalidParams,"Failed to retrieve task: Task not found");return o},storeTaskResult:async(n,o,s)=>{await i.storeTaskResult(n,o,s,r);let a=await i.getTask(n,r);if(a){let c=md.parse({method:"notifications/tasks/status",params:a});await this.notification(c),fo(a.status)&&this._cleanupTaskProgressHandler(n)}},getTaskResult:n=>i.getTaskResult(n,r),updateTaskStatus:async(n,o,s)=>{let a=await i.getTask(n,r);if(!a)throw new te(ae.InvalidParams,`Task "${n}" not found - it may have been cleaned up`);if(fo(a.status))throw new te(ae.InvalidParams,`Cannot update task "${n}" from terminal status "${a.status}" to "${o}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await i.updateTaskStatus(n,o,s,r);let c=await i.getTask(n,r);if(c){let l=md.parse({method:"notifications/tasks/status",params:c});await this.notification(l),fo(c.status)&&this._cleanupTaskProgressHandler(n)}},listTasks:n=>i.listTasks(n,r)}}}});var $d=C(Ge=>{"use strict";Object.defineProperty(Ge,"__esModule",{value:!0});Ge.regexpCode=Ge.getEsmExportName=Ge.getProperty=Ge.safeStringify=Ge.stringify=Ge.strConcat=Ge.addCodeArg=Ge.str=Ge._=Ge.nil=Ge._Code=Ge.Name=Ge.IDENTIFIER=Ge._CodeOrName=void 0;var bd=class{};Ge._CodeOrName=bd;Ge.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var ws=class extends bd{constructor(e){if(super(),!Ge.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};Ge.Name=ws;var fn=class extends bd{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,i)=>`${r}${i}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,i)=>(i instanceof ws&&(r[i.str]=(r[i.str]||0)+1),r),{})}};Ge._Code=fn;Ge.nil=new fn("");function g1(t,...e){let r=[t[0]],i=0;for(;i<e.length;)VS(r,e[i]),r.push(t[++i]);return new fn(r)}Ge._=g1;var qS=new fn("+");function y1(t,...e){let r=[wd(t[0])],i=0;for(;i<e.length;)r.push(qS),VS(r,e[i]),r.push(qS,wd(t[++i]));return vJ(r),new fn(r)}Ge.str=y1;function VS(t,e){e instanceof fn?t.push(...e._items):e instanceof ws?t.push(e):t.push(wJ(e))}Ge.addCodeArg=VS;function vJ(t){let e=1;for(;e<t.length-1;){if(t[e]===qS){let r=_J(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function _J(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof ws||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof ws))return`"${t}${e.slice(1)}`}function bJ(t,e){return e.emptyStr()?t:t.emptyStr()?e:y1`${t}${e}`}Ge.strConcat=bJ;function wJ(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:wd(Array.isArray(t)?t.join(","):t)}function $J(t){return new fn(wd(t))}Ge.stringify=$J;function wd(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}Ge.safeStringify=wd;function kJ(t){return typeof t=="string"&&Ge.IDENTIFIER.test(t)?new fn(`.${t}`):g1`[${t}]`}Ge.getProperty=kJ;function SJ(t){if(typeof t=="string"&&Ge.IDENTIFIER.test(t))return new fn(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}Ge.getEsmExportName=SJ;function xJ(t){return new fn(t.toString())}Ge.regexpCode=xJ});var WS=C(Nr=>{"use strict";Object.defineProperty(Nr,"__esModule",{value:!0});Nr.ValueScope=Nr.ValueScopeName=Nr.Scope=Nr.varKinds=Nr.UsedValueState=void 0;var Cr=$d(),BS=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},sy;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(sy||(Nr.UsedValueState=sy={}));Nr.varKinds={const:new Cr.Name("const"),let:new Cr.Name("let"),var:new Cr.Name("var")};var ay=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof Cr.Name?e:this.name(e)}name(e){return new Cr.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,i;if(!((i=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||i===void 0)&&i.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};Nr.Scope=ay;var cy=class extends Cr.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:i}){this.value=e,this.scopePath=(0,Cr._)`.${new Cr.Name(r)}[${i}]`}};Nr.ValueScopeName=cy;var IJ=(0,Cr._)`\n`,HS=class extends ay{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?IJ:Cr.nil}}get(){return this._scope}name(e){return new cy(e,this._newName(e))}value(e,r){var i;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let n=this.toName(e),{prefix:o}=n,s=(i=r.key)!==null&&i!==void 0?i:r.ref,a=this._values[o];if(a){let u=a.get(s);if(u)return u}else a=this._values[o]=new Map;a.set(s,n);let c=this._scope[o]||(this._scope[o]=[]),l=c.length;return c[l]=r.ref,n.setValue(r,{property:o,itemIndex:l}),n}getValue(e,r){let i=this._values[e];if(i)return i.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,i=>{if(i.scopePath===void 0)throw new Error(`CodeGen: name "${i}" has no value`);return(0,Cr._)`${e}${i.scopePath}`})}scopeCode(e=this._values,r,i){return this._reduceValues(e,n=>{if(n.value===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return n.value.code},r,i)}_reduceValues(e,r,i={},n){let o=Cr.nil;for(let s in e){let a=e[s];if(!a)continue;let c=i[s]=i[s]||new Map;a.forEach(l=>{if(c.has(l))return;c.set(l,sy.Started);let u=r(l);if(u){let d=this.opts.es5?Nr.varKinds.var:Nr.varKinds.const;o=(0,Cr._)`${o}${d} ${l} = ${u};${this.opts._n}`}else if(u=n?.(l))o=(0,Cr._)`${o}${u}${this.opts._n}`;else throw new BS(l);c.set(l,sy.Completed)})}return o}};Nr.ValueScope=HS});var Te=C(Ae=>{"use strict";Object.defineProperty(Ae,"__esModule",{value:!0});Ae.or=Ae.and=Ae.not=Ae.CodeGen=Ae.operators=Ae.varKinds=Ae.ValueScopeName=Ae.ValueScope=Ae.Scope=Ae.Name=Ae.regexpCode=Ae.stringify=Ae.getProperty=Ae.nil=Ae.strConcat=Ae.str=Ae._=void 0;var Fe=$d(),jn=WS(),ho=$d();Object.defineProperty(Ae,"_",{enumerable:!0,get:function(){return ho._}});Object.defineProperty(Ae,"str",{enumerable:!0,get:function(){return ho.str}});Object.defineProperty(Ae,"strConcat",{enumerable:!0,get:function(){return ho.strConcat}});Object.defineProperty(Ae,"nil",{enumerable:!0,get:function(){return ho.nil}});Object.defineProperty(Ae,"getProperty",{enumerable:!0,get:function(){return ho.getProperty}});Object.defineProperty(Ae,"stringify",{enumerable:!0,get:function(){return ho.stringify}});Object.defineProperty(Ae,"regexpCode",{enumerable:!0,get:function(){return ho.regexpCode}});Object.defineProperty(Ae,"Name",{enumerable:!0,get:function(){return ho.Name}});var fy=WS();Object.defineProperty(Ae,"Scope",{enumerable:!0,get:function(){return fy.Scope}});Object.defineProperty(Ae,"ValueScope",{enumerable:!0,get:function(){return fy.ValueScope}});Object.defineProperty(Ae,"ValueScopeName",{enumerable:!0,get:function(){return fy.ValueScopeName}});Object.defineProperty(Ae,"varKinds",{enumerable:!0,get:function(){return fy.varKinds}});Ae.operators={GT:new Fe._Code(">"),GTE:new Fe._Code(">="),LT:new Fe._Code("<"),LTE:new Fe._Code("<="),EQ:new Fe._Code("==="),NEQ:new Fe._Code("!=="),NOT:new Fe._Code("!"),OR:new Fe._Code("||"),AND:new Fe._Code("&&"),ADD:new Fe._Code("+")};var Ri=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},KS=class extends Ri{constructor(e,r,i){super(),this.varKind=e,this.name=r,this.rhs=i}render({es5:e,_n:r}){let i=e?jn.varKinds.var:this.varKind,n=this.rhs===void 0?"":` = ${this.rhs}`;return`${i} ${this.name}${n};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=_c(this.rhs,e,r)),this}get names(){return this.rhs instanceof Fe._CodeOrName?this.rhs.names:{}}},ly=class extends Ri{constructor(e,r,i){super(),this.lhs=e,this.rhs=r,this.sideEffects=i}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof Fe.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=_c(this.rhs,e,r),this}get names(){let e=this.lhs instanceof Fe.Name?{}:{...this.lhs.names};return dy(e,this.rhs)}},GS=class extends ly{constructor(e,r,i,n){super(e,i,n),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},JS=class extends Ri{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},XS=class extends Ri{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},YS=class extends Ri{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},QS=class extends Ri{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=_c(this.code,e,r),this}get names(){return this.code instanceof Fe._CodeOrName?this.code.names:{}}},kd=class extends Ri{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,i)=>r+i.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let i=e[r].optimizeNodes();Array.isArray(i)?e.splice(r,1,...i):i?e[r]=i:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:i}=this,n=i.length;for(;n--;){let o=i[n];o.optimizeNames(e,r)||(EJ(e,o.names),i.splice(n,1))}return i.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>Ss(e,r.names),{})}},ji=class extends kd{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},ex=class extends kd{},vc=class extends ji{};vc.kind="else";var $s=class t extends ji{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let i=r.optimizeNodes();r=this.else=Array.isArray(i)?new vc(i):i}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(v1(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var i;if(this.else=(i=this.else)===null||i===void 0?void 0:i.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=_c(this.condition,e,r),this}get names(){let e=super.names;return dy(e,this.condition),this.else&&Ss(e,this.else.names),e}};$s.kind="if";var ks=class extends ji{};ks.kind="for";var tx=class extends ks{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=_c(this.iteration,e,r),this}get names(){return Ss(super.names,this.iteration.names)}},rx=class extends ks{constructor(e,r,i,n){super(),this.varKind=e,this.name=r,this.from=i,this.to=n}render(e){let r=e.es5?jn.varKinds.var:this.varKind,{name:i,from:n,to:o}=this;return`for(${r} ${i}=${n}; ${i}<${o}; ${i}++)`+super.render(e)}get names(){let e=dy(super.names,this.from);return dy(e,this.to)}},uy=class extends ks{constructor(e,r,i,n){super(),this.loop=e,this.varKind=r,this.name=i,this.iterable=n}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=_c(this.iterable,e,r),this}get names(){return Ss(super.names,this.iterable.names)}},Sd=class extends ji{constructor(e,r,i){super(),this.name=e,this.args=r,this.async=i}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};Sd.kind="func";var xd=class extends kd{render(e){return"return "+super.render(e)}};xd.kind="return";var nx=class extends ji{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var i,n;return super.optimizeNames(e,r),(i=this.catch)===null||i===void 0||i.optimizeNames(e,r),(n=this.finally)===null||n===void 0||n.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&Ss(e,this.catch.names),this.finally&&Ss(e,this.finally.names),e}},Id=class extends ji{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};Id.kind="catch";var Ed=class extends ji{render(e){return"finally"+super.render(e)}};Ed.kind="finally";var ix=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
125
- `:""},this._extScope=e,this._scope=new jn.Scope({parent:e}),this._nodes=[new ex]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let i=this._extScope.value(e,r);return(this._values[i.prefix]||(this._values[i.prefix]=new Set)).add(i),i}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,i,n){let o=this._scope.toName(r);return i!==void 0&&n&&(this._constants[o.str]=i),this._leafNode(new KS(e,o,i)),o}const(e,r,i){return this._def(jn.varKinds.const,e,r,i)}let(e,r,i){return this._def(jn.varKinds.let,e,r,i)}var(e,r,i){return this._def(jn.varKinds.var,e,r,i)}assign(e,r,i){return this._leafNode(new ly(e,r,i))}add(e,r){return this._leafNode(new GS(e,Ae.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==Fe.nil&&this._leafNode(new QS(e)),this}object(...e){let r=["{"];for(let[i,n]of e)r.length>1&&r.push(","),r.push(i),(i!==n||this.opts.es5)&&(r.push(":"),(0,Fe.addCodeArg)(r,n));return r.push("}"),new Fe._Code(r)}if(e,r,i){if(this._blockNode(new $s(e)),r&&i)this.code(r).else().code(i).endIf();else if(r)this.code(r).endIf();else if(i)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new $s(e))}else(){return this._elseNode(new vc)}endIf(){return this._endBlockNode($s,vc)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new tx(e),r)}forRange(e,r,i,n,o=this.opts.es5?jn.varKinds.var:jn.varKinds.let){let s=this._scope.toName(e);return this._for(new rx(o,s,r,i),()=>n(s))}forOf(e,r,i,n=jn.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let s=r instanceof Fe.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,Fe._)`${s}.length`,a=>{this.var(o,(0,Fe._)`${s}[${a}]`),i(o)})}return this._for(new uy("of",n,o,r),()=>i(o))}forIn(e,r,i,n=this.opts.es5?jn.varKinds.var:jn.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,Fe._)`Object.keys(${r})`,i);let o=this._scope.toName(e);return this._for(new uy("in",n,o,r),()=>i(o))}endFor(){return this._endBlockNode(ks)}label(e){return this._leafNode(new JS(e))}break(e){return this._leafNode(new XS(e))}return(e){let r=new xd;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(xd)}try(e,r,i){if(!r&&!i)throw new Error('CodeGen: "try" without "catch" and "finally"');let n=new nx;if(this._blockNode(n),this.code(e),r){let o=this.name("e");this._currNode=n.catch=new Id(o),r(o)}return i&&(this._currNode=n.finally=new Ed,this.code(i)),this._endBlockNode(Id,Ed)}throw(e){return this._leafNode(new YS(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let i=this._nodes.length-r;if(i<0||e!==void 0&&i!==e)throw new Error(`CodeGen: wrong number of nodes: ${i} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=Fe.nil,i,n){return this._blockNode(new Sd(e,r,i)),n&&this.code(n).endFunc(),this}endFunc(){return this._endBlockNode(Sd)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,r){let i=this._currNode;if(i instanceof e||r&&i instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof $s))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e}};Ae.CodeGen=ix;function Ss(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function dy(t,e){return e instanceof Fe._CodeOrName?Ss(t,e.names):t}function _c(t,e,r){if(t instanceof Fe.Name)return i(t);if(!n(t))return t;return new Fe._Code(t._items.reduce((o,s)=>(s instanceof Fe.Name&&(s=i(s)),s instanceof Fe._Code?o.push(...s._items):o.push(s),o),[]));function i(o){let s=r[o.str];return s===void 0||e[o.str]!==1?o:(delete e[o.str],s)}function n(o){return o instanceof Fe._Code&&o._items.some(s=>s instanceof Fe.Name&&e[s.str]===1&&r[s.str]!==void 0)}}function EJ(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function v1(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,Fe._)`!${ox(t)}`}Ae.not=v1;var TJ=_1(Ae.operators.AND);function OJ(...t){return t.reduce(TJ)}Ae.and=OJ;var PJ=_1(Ae.operators.OR);function AJ(...t){return t.reduce(PJ)}Ae.or=AJ;function _1(t){return(e,r)=>e===Fe.nil?r:r===Fe.nil?e:(0,Fe._)`${ox(e)} ${t} ${ox(r)}`}function ox(t){return t instanceof Fe.Name?t:(0,Fe._)`(${t})`}});var qe=C(Ne=>{"use strict";Object.defineProperty(Ne,"__esModule",{value:!0});Ne.checkStrictMode=Ne.getErrorPath=Ne.Type=Ne.useFunc=Ne.setEvaluated=Ne.evaluatedPropsToName=Ne.mergeEvaluated=Ne.eachItem=Ne.unescapeJsonPointer=Ne.escapeJsonPointer=Ne.escapeFragment=Ne.unescapeFragment=Ne.schemaRefOrVal=Ne.schemaHasRulesButRef=Ne.schemaHasRules=Ne.checkUnknownRules=Ne.alwaysValidSchema=Ne.toHash=void 0;var ft=Te(),RJ=$d();function jJ(t){let e={};for(let r of t)e[r]=!0;return e}Ne.toHash=jJ;function zJ(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:($1(t,e),!k1(e,t.self.RULES.all))}Ne.alwaysValidSchema=zJ;function $1(t,e=t.schema){let{opts:r,self:i}=t;if(!r.strictSchema||typeof e=="boolean")return;let n=i.RULES.keywords;for(let o in e)n[o]||I1(t,`unknown keyword: "${o}"`)}Ne.checkUnknownRules=$1;function k1(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}Ne.schemaHasRules=k1;function CJ(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}Ne.schemaHasRulesButRef=CJ;function NJ({topSchemaRef:t,schemaPath:e},r,i,n){if(!n){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,ft._)`${r}`}return(0,ft._)`${t}${e}${(0,ft.getProperty)(i)}`}Ne.schemaRefOrVal=NJ;function DJ(t){return S1(decodeURIComponent(t))}Ne.unescapeFragment=DJ;function LJ(t){return encodeURIComponent(ax(t))}Ne.escapeFragment=LJ;function ax(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}Ne.escapeJsonPointer=ax;function S1(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}Ne.unescapeJsonPointer=S1;function UJ(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}Ne.eachItem=UJ;function b1({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:i}){return(n,o,s,a)=>{let c=s===void 0?o:s instanceof ft.Name?(o instanceof ft.Name?t(n,o,s):e(n,o,s),s):o instanceof ft.Name?(e(n,s,o),o):r(o,s);return a===ft.Name&&!(c instanceof ft.Name)?i(n,c):c}}Ne.mergeEvaluated={props:b1({mergeNames:(t,e,r)=>t.if((0,ft._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,ft._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,ft._)`${r} || {}`).code((0,ft._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,ft._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,ft._)`${r} || {}`),cx(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:x1}),items:b1({mergeNames:(t,e,r)=>t.if((0,ft._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,ft._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,ft._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,ft._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function x1(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,ft._)`{}`);return e!==void 0&&cx(t,r,e),r}Ne.evaluatedPropsToName=x1;function cx(t,e,r){Object.keys(r).forEach(i=>t.assign((0,ft._)`${e}${(0,ft.getProperty)(i)}`,!0))}Ne.setEvaluated=cx;var w1={};function MJ(t,e){return t.scopeValue("func",{ref:e,code:w1[e.code]||(w1[e.code]=new RJ._Code(e.code))})}Ne.useFunc=MJ;var sx;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(sx||(Ne.Type=sx={}));function FJ(t,e,r){if(t instanceof ft.Name){let i=e===sx.Num;return r?i?(0,ft._)`"[" + ${t} + "]"`:(0,ft._)`"['" + ${t} + "']"`:i?(0,ft._)`"/" + ${t}`:(0,ft._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,ft.getProperty)(t).toString():"/"+ax(t)}Ne.getErrorPath=FJ;function I1(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}Ne.checkStrictMode=I1});var zi=C(lx=>{"use strict";Object.defineProperty(lx,"__esModule",{value:!0});var cr=Te(),ZJ={data:new cr.Name("data"),valCxt:new cr.Name("valCxt"),instancePath:new cr.Name("instancePath"),parentData:new cr.Name("parentData"),parentDataProperty:new cr.Name("parentDataProperty"),rootData:new cr.Name("rootData"),dynamicAnchors:new cr.Name("dynamicAnchors"),vErrors:new cr.Name("vErrors"),errors:new cr.Name("errors"),this:new cr.Name("this"),self:new cr.Name("self"),scope:new cr.Name("scope"),json:new cr.Name("json"),jsonPos:new cr.Name("jsonPos"),jsonLen:new cr.Name("jsonLen"),jsonPart:new cr.Name("jsonPart")};lx.default=ZJ});var Td=C(lr=>{"use strict";Object.defineProperty(lr,"__esModule",{value:!0});lr.extendErrors=lr.resetErrorsCount=lr.reportExtraError=lr.reportError=lr.keyword$DataError=lr.keywordError=void 0;var Ve=Te(),py=qe(),kr=zi();lr.keywordError={message:({keyword:t})=>(0,Ve.str)`must pass "${t}" keyword validation`};lr.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,Ve.str)`"${t}" keyword must be ${e} ($data)`:(0,Ve.str)`"${t}" keyword is invalid ($data)`};function qJ(t,e=lr.keywordError,r,i){let{it:n}=t,{gen:o,compositeRule:s,allErrors:a}=n,c=O1(t,e,r);i??(s||a)?E1(o,c):T1(n,(0,Ve._)`[${c}]`)}lr.reportError=qJ;function VJ(t,e=lr.keywordError,r){let{it:i}=t,{gen:n,compositeRule:o,allErrors:s}=i,a=O1(t,e,r);E1(n,a),o||s||T1(i,kr.default.vErrors)}lr.reportExtraError=VJ;function BJ(t,e){t.assign(kr.default.errors,e),t.if((0,Ve._)`${kr.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,Ve._)`${kr.default.vErrors}.length`,e),()=>t.assign(kr.default.vErrors,null)))}lr.resetErrorsCount=BJ;function HJ({gen:t,keyword:e,schemaValue:r,data:i,errsCount:n,it:o}){if(n===void 0)throw new Error("ajv implementation error");let s=t.name("err");t.forRange("i",n,kr.default.errors,a=>{t.const(s,(0,Ve._)`${kr.default.vErrors}[${a}]`),t.if((0,Ve._)`${s}.instancePath === undefined`,()=>t.assign((0,Ve._)`${s}.instancePath`,(0,Ve.strConcat)(kr.default.instancePath,o.errorPath))),t.assign((0,Ve._)`${s}.schemaPath`,(0,Ve.str)`${o.errSchemaPath}/${e}`),o.opts.verbose&&(t.assign((0,Ve._)`${s}.schema`,r),t.assign((0,Ve._)`${s}.data`,i))})}lr.extendErrors=HJ;function E1(t,e){let r=t.const("err",e);t.if((0,Ve._)`${kr.default.vErrors} === null`,()=>t.assign(kr.default.vErrors,(0,Ve._)`[${r}]`),(0,Ve._)`${kr.default.vErrors}.push(${r})`),t.code((0,Ve._)`${kr.default.errors}++`)}function T1(t,e){let{gen:r,validateName:i,schemaEnv:n}=t;n.$async?r.throw((0,Ve._)`new ${t.ValidationError}(${e})`):(r.assign((0,Ve._)`${i}.errors`,e),r.return(!1))}var xs={keyword:new Ve.Name("keyword"),schemaPath:new Ve.Name("schemaPath"),params:new Ve.Name("params"),propertyName:new Ve.Name("propertyName"),message:new Ve.Name("message"),schema:new Ve.Name("schema"),parentSchema:new Ve.Name("parentSchema")};function O1(t,e,r){let{createErrors:i}=t.it;return i===!1?(0,Ve._)`{}`:WJ(t,e,r)}function WJ(t,e,r={}){let{gen:i,it:n}=t,o=[KJ(n,r),GJ(t,r)];return JJ(t,e,o),i.object(...o)}function KJ({errorPath:t},{instancePath:e}){let r=e?(0,Ve.str)`${t}${(0,py.getErrorPath)(e,py.Type.Str)}`:t;return[kr.default.instancePath,(0,Ve.strConcat)(kr.default.instancePath,r)]}function GJ({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:i}){let n=i?e:(0,Ve.str)`${e}/${t}`;return r&&(n=(0,Ve.str)`${n}${(0,py.getErrorPath)(r,py.Type.Str)}`),[xs.schemaPath,n]}function JJ(t,{params:e,message:r},i){let{keyword:n,data:o,schemaValue:s,it:a}=t,{opts:c,propertyName:l,topSchemaRef:u,schemaPath:d}=a;i.push([xs.keyword,n],[xs.params,typeof e=="function"?e(t):e||(0,Ve._)`{}`]),c.messages&&i.push([xs.message,typeof r=="function"?r(t):r]),c.verbose&&i.push([xs.schema,s],[xs.parentSchema,(0,Ve._)`${u}${d}`],[kr.default.data,o]),l&&i.push([xs.propertyName,l])}});var A1=C(bc=>{"use strict";Object.defineProperty(bc,"__esModule",{value:!0});bc.boolOrEmptySchema=bc.topBoolOrEmptySchema=void 0;var XJ=Td(),YJ=Te(),QJ=zi(),e3={message:"boolean schema is false"};function t3(t){let{gen:e,schema:r,validateName:i}=t;r===!1?P1(t,!1):typeof r=="object"&&r.$async===!0?e.return(QJ.default.data):(e.assign((0,YJ._)`${i}.errors`,null),e.return(!0))}bc.topBoolOrEmptySchema=t3;function r3(t,e){let{gen:r,schema:i}=t;i===!1?(r.var(e,!1),P1(t)):r.var(e,!0)}bc.boolOrEmptySchema=r3;function P1(t,e){let{gen:r,data:i}=t,n={gen:r,keyword:"false schema",data:i,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,XJ.reportError)(n,e3,void 0,e)}});var ux=C(wc=>{"use strict";Object.defineProperty(wc,"__esModule",{value:!0});wc.getRules=wc.isJSONType=void 0;var n3=["string","number","integer","boolean","null","object","array"],i3=new Set(n3);function o3(t){return typeof t=="string"&&i3.has(t)}wc.isJSONType=o3;function s3(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}wc.getRules=s3});var dx=C(mo=>{"use strict";Object.defineProperty(mo,"__esModule",{value:!0});mo.shouldUseRule=mo.shouldUseGroup=mo.schemaHasRulesForType=void 0;function a3({schema:t,self:e},r){let i=e.RULES.types[r];return i&&i!==!0&&R1(t,i)}mo.schemaHasRulesForType=a3;function R1(t,e){return e.rules.some(r=>j1(t,r))}mo.shouldUseGroup=R1;function j1(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(i=>t[i]!==void 0))}mo.shouldUseRule=j1});var Od=C(ur=>{"use strict";Object.defineProperty(ur,"__esModule",{value:!0});ur.reportTypeError=ur.checkDataTypes=ur.checkDataType=ur.coerceAndCheckDataType=ur.getJSONTypes=ur.getSchemaTypes=ur.DataType=void 0;var c3=ux(),l3=dx(),u3=Td(),Ie=Te(),z1=qe(),$c;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})($c||(ur.DataType=$c={}));function d3(t){let e=C1(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}ur.getSchemaTypes=d3;function C1(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(c3.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}ur.getJSONTypes=C1;function f3(t,e){let{gen:r,data:i,opts:n}=t,o=p3(e,n.coerceTypes),s=e.length>0&&!(o.length===0&&e.length===1&&(0,l3.schemaHasRulesForType)(t,e[0]));if(s){let a=px(e,i,n.strictNumbers,$c.Wrong);r.if(a,()=>{o.length?h3(t,e,o):hx(t)})}return s}ur.coerceAndCheckDataType=f3;var N1=new Set(["string","number","integer","boolean","null"]);function p3(t,e){return e?t.filter(r=>N1.has(r)||e==="array"&&r==="array"):[]}function h3(t,e,r){let{gen:i,data:n,opts:o}=t,s=i.let("dataType",(0,Ie._)`typeof ${n}`),a=i.let("coerced",(0,Ie._)`undefined`);o.coerceTypes==="array"&&i.if((0,Ie._)`${s} == 'object' && Array.isArray(${n}) && ${n}.length == 1`,()=>i.assign(n,(0,Ie._)`${n}[0]`).assign(s,(0,Ie._)`typeof ${n}`).if(px(e,n,o.strictNumbers),()=>i.assign(a,n))),i.if((0,Ie._)`${a} !== undefined`);for(let l of r)(N1.has(l)||l==="array"&&o.coerceTypes==="array")&&c(l);i.else(),hx(t),i.endIf(),i.if((0,Ie._)`${a} !== undefined`,()=>{i.assign(n,a),m3(t,a)});function c(l){switch(l){case"string":i.elseIf((0,Ie._)`${s} == "number" || ${s} == "boolean"`).assign(a,(0,Ie._)`"" + ${n}`).elseIf((0,Ie._)`${n} === null`).assign(a,(0,Ie._)`""`);return;case"number":i.elseIf((0,Ie._)`${s} == "boolean" || ${n} === null
124
+ ]`;continue}n+=i[c],i[c]==="\\"?o=!0:s&&i[c]==="]"?s=!1:!s&&i[c]==="["&&(s=!0)}try{new RegExp(n)}catch{return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),t.source}return n}var _S,An,pJ,ty=w(()=>{po();An={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(_S===void 0&&(_S=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),_S),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?: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])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};pJ=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789")});function ry(t,e){if(e.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),e.target==="openApi3"&&t.keyType?._def.typeName===Z.ZodEnum)return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((i,n)=>({...i,[n]:ge(t.valueType._def,{...e,currentPath:[...e.currentPath,"properties",n]})??$t(e)}),{}),additionalProperties:e.rejectedAdditionalProperties};let r={type:"object",additionalProperties:ge(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??e.allowedAdditionalProperties};if(e.target==="openApi3")return r;if(t.keyType?._def.typeName===Z.ZodString&&t.keyType._def.checks?.length){let{type:i,...n}=ey(t.keyType._def,e);return{...r,propertyNames:n}}else{if(t.keyType?._def.typeName===Z.ZodEnum)return{...r,propertyNames:{enum:t.keyType._def.values}};if(t.keyType?._def.typeName===Z.ZodBranded&&t.keyType._def.type._def.typeName===Z.ZodString&&t.keyType._def.type._def.checks?.length){let{type:i,...n}=Yg(t.keyType._def,e);return{...r,propertyNames:n}}}return r}var ny=w(()=>{Gu();Ft();ty();Qg();dn()});function WD(t,e){if(e.mapStrategy==="record")return ry(t,e);let r=ge(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||$t(e),i=ge(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||$t(e);return{type:"array",maxItems:125,items:{type:"array",items:[r,i],minItems:2,maxItems:2}}}var wS=w(()=>{Ft();ny();dn()});function KD(t){let e=t.values,i=Object.keys(t.values).filter(o=>typeof e[e[o]]!="number").map(o=>e[o]),n=Array.from(new Set(i.map(o=>typeof o)));return{type:n.length===1?n[0]==="string"?"string":"number":["string","number"],enum:i}}var $S=w(()=>{});function GD(t){return t.target==="openAi"?void 0:{not:$t({...t,currentPath:[...t.currentPath,"not"]})}}var kS=w(()=>{dn()});function JD(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var SS=w(()=>{});function YD(t,e){if(e.target==="openApi3")return XD(t,e);let r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(i=>i._def.typeName in _d&&(!i._def.checks||!i._def.checks.length))){let i=r.reduce((n,o)=>{let s=_d[o._def.typeName];return s&&!n.includes(s)?[...n,s]:n},[]);return{type:i.length>1?i:i[0]}}else if(r.every(i=>i._def.typeName==="ZodLiteral"&&!i.description)){let i=r.reduce((n,o)=>{let s=typeof o._def.value;switch(s){case"string":case"number":case"boolean":return[...n,s];case"bigint":return[...n,"integer"];case"object":if(o._def.value===null)return[...n,"null"];case"symbol":case"undefined":case"function":default:return n}},[]);if(i.length===r.length){let n=i.filter((o,s,a)=>a.indexOf(o)===s);return{type:n.length>1?n:n[0],enum:r.reduce((o,s)=>o.includes(s._def.value)?o:[...o,s._def.value],[])}}}else if(r.every(i=>i._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((i,n)=>[...i,...n._def.values.filter(o=>!i.includes(o))],[])};return XD(t,e)}var _d,XD,iy=w(()=>{Ft();_d={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};XD=(t,e)=>{let r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((i,n)=>ge(i._def,{...e,currentPath:[...e.currentPath,"anyOf",`${n}`]})).filter(i=>!!i&&(!e.strictUnions||typeof i=="object"&&Object.keys(i).length>0));return r.length?{anyOf:r}:void 0}});function QD(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return e.target==="openApi3"?{type:_d[t.innerType._def.typeName],nullable:!0}:{type:[_d[t.innerType._def.typeName],"null"]};if(e.target==="openApi3"){let i=ge(t.innerType._def,{...e,currentPath:[...e.currentPath]});return i&&"$ref"in i?{allOf:[i],nullable:!0}:i&&{...i,nullable:!0}}let r=ge(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}var xS=w(()=>{Ft();iy()});function e1(t,e){let r={type:"number"};if(!t.checks)return r;for(let i of t.checks)switch(i.kind){case"int":r.type="integer",aS(r,"type",i.message,e);break;case"min":e.target==="jsonSchema7"?i.inclusive?Me(r,"minimum",i.value,i.message,e):Me(r,"exclusiveMinimum",i.value,i.message,e):(i.inclusive||(r.exclusiveMinimum=!0),Me(r,"minimum",i.value,i.message,e));break;case"max":e.target==="jsonSchema7"?i.inclusive?Me(r,"maximum",i.value,i.message,e):Me(r,"exclusiveMaximum",i.value,i.message,e):(i.inclusive||(r.exclusiveMaximum=!0),Me(r,"maximum",i.value,i.message,e));break;case"multipleOf":Me(r,"multipleOf",i.value,i.message,e);break}return r}var IS=w(()=>{po()});function t1(t,e){let r=e.target==="openAi",i={type:"object",properties:{}},n=[],o=t.shape();for(let a in o){let c=o[a];if(c===void 0||c._def===void 0)continue;let l=gJ(c);l&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),l=!1);let u=ge(c._def,{...e,currentPath:[...e.currentPath,"properties",a],propertyPath:[...e.currentPath,"properties",a]});u!==void 0&&(i.properties[a]=u,l||n.push(a))}n.length&&(i.required=n);let s=mJ(t,e);return s!==void 0&&(i.additionalProperties=s),i}function mJ(t,e){if(t.catchall._def.typeName!=="ZodNever")return ge(t.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]});switch(t.unknownKeys){case"passthrough":return e.allowedAdditionalProperties;case"strict":return e.rejectedAdditionalProperties;case"strip":return e.removeAdditionalStrategy==="strict"?e.allowedAdditionalProperties:e.rejectedAdditionalProperties}}function gJ(t){try{return t.isOptional()}catch{return!0}}var ES=w(()=>{Ft()});var r1,TS=w(()=>{Ft();dn();r1=(t,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return ge(t.innerType._def,e);let r=ge(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return r?{anyOf:[{not:$t(e)},r]}:$t(e)}});var n1,OS=w(()=>{Ft();n1=(t,e)=>{if(e.pipeStrategy==="input")return ge(t.in._def,e);if(e.pipeStrategy==="output")return ge(t.out._def,e);let r=ge(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),i=ge(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,i].filter(n=>n!==void 0)}}});function i1(t,e){return ge(t.type._def,e)}var PS=w(()=>{Ft()});function o1(t,e){let i={type:"array",uniqueItems:!0,items:ge(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&Me(i,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&Me(i,"maxItems",t.maxSize.value,t.maxSize.message,e),i}var AS=w(()=>{po();Ft()});function s1(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,i)=>ge(r._def,{...e,currentPath:[...e.currentPath,"items",`${i}`]})).reduce((r,i)=>i===void 0?r:[...r,i],[]),additionalItems:ge(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,i)=>ge(r._def,{...e,currentPath:[...e.currentPath,"items",`${i}`]})).reduce((r,i)=>i===void 0?r:[...r,i],[])}}var RS=w(()=>{Ft()});function a1(t){return{not:$t(t)}}var jS=w(()=>{dn()});function c1(t){return $t(t)}var zS=w(()=>{dn()});var l1,CS=w(()=>{Ft();l1=(t,e)=>ge(t.innerType._def,e)});var u1,NS=w(()=>{Gu();dn();cS();lS();uS();Qg();dS();pS();hS();mS();gS();yS();vS();wS();$S();kS();SS();xS();IS();ES();TS();OS();PS();ny();AS();ty();RS();jS();iy();zS();CS();u1=(t,e,r)=>{switch(e){case Z.ZodString:return ey(t,r);case Z.ZodNumber:return e1(t,r);case Z.ZodObject:return t1(t,r);case Z.ZodBigInt:return LD(t,r);case Z.ZodBoolean:return UD();case Z.ZodDate:return fS(t,r);case Z.ZodUndefined:return a1(r);case Z.ZodNull:return JD(r);case Z.ZodArray:return DD(t,r);case Z.ZodUnion:case Z.ZodDiscriminatedUnion:return YD(t,r);case Z.ZodIntersection:return VD(t,r);case Z.ZodTuple:return s1(t,r);case Z.ZodRecord:return ry(t,r);case Z.ZodLiteral:return BD(t,r);case Z.ZodEnum:return qD(t);case Z.ZodNativeEnum:return KD(t);case Z.ZodNullable:return QD(t,r);case Z.ZodOptional:return r1(t,r);case Z.ZodMap:return WD(t,r);case Z.ZodSet:return o1(t,r);case Z.ZodLazy:return()=>t.getter()._def;case Z.ZodPromise:return i1(t,r);case Z.ZodNaN:case Z.ZodNever:return GD(r);case Z.ZodEffects:return ZD(t,r);case Z.ZodAny:return $t(r);case Z.ZodUnknown:return c1(r);case Z.ZodDefault:return FD(t,r);case Z.ZodBranded:return Yg(t,r);case Z.ZodReadonly:return l1(t,r);case Z.ZodCatch:return MD(t,r);case Z.ZodPipeline:return n1(t,r);case Z.ZodFunction:case Z.ZodVoid:case Z.ZodSymbol:return;default:return(i=>{})(e)}}});function ge(t,e,r=!1){let i=e.seen.get(t);if(e.override){let a=e.override?.(t,e,i,r);if(a!==zD)return a}if(i&&!r){let a=yJ(i,e);if(a!==void 0)return a}let n={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,n);let o=u1(t,t.typeName,e),s=typeof o=="function"?ge(o(),e):o;if(s&&vJ(t,e,s),e.postProcess){let a=e.postProcess(s,t,e);return n.jsonSchema=s,a}return n.jsonSchema=s,s}var yJ,vJ,Ft=w(()=>{Gg();NS();Xg();dn();yJ=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:Jg(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((r,i)=>e.currentPath[i]===r)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),$t(e)):e.$refStrategy==="seen"?$t(e):void 0}},vJ=(t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),r)});var d1=w(()=>{});var DS,LS=w(()=>{Ft();sS();dn();DS=(t,e)=>{let r=ND(e),i=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[l,u])=>({...c,[l]:ge(u._def,{...r,currentPath:[...r.basePath,r.definitionPath,l]},!0)??$t(r)}),{}):void 0,n=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,o=ge(t._def,n===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,n]},!1)??$t(r),s=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;s!==void 0&&(o.title=s),r.flags.hasReferencedOpenAiAnyType&&(i||(i={}),i[r.openAiAnyTypeName]||(i[r.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:r.$refStrategy==="relative"?"1":[...r.basePath,r.definitionPath,r.openAiAnyTypeName].join("/")}}));let a=n===void 0?i?{...o,[r.definitionPath]:i}:o:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,n].join("/"),[r.definitionPath]:{...i,[n]:o}};return r.target==="jsonSchema7"?a.$schema="http://json-schema.org/draft-07/schema#":(r.target==="jsonSchema2019-09"||r.target==="openAi")&&(a.$schema="https://json-schema.org/draft/2019-09/schema#"),r.target==="openAi"&&("anyOf"in a||"oneOf"in a||"allOf"in a||"type"in a&&Array.isArray(a.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),a}});var f1=w(()=>{Gg();sS();po();Xg();Ft();d1();dn();cS();lS();uS();Qg();dS();pS();hS();mS();gS();yS();vS();wS();$S();kS();SS();xS();IS();ES();TS();OS();PS();CS();ny();AS();ty();RS();jS();iy();zS();NS();LS();LS()});function _J(t){return!t||t==="jsonSchema7"||t==="draft-7"?"draft-7":t==="jsonSchema2019-09"||t==="draft-2020-12"?"draft-2020-12":"draft-7"}function US(t,e){return ei(t)?Yo(t,{target:_J(e?.target),io:e?.pipeStrategy??"input"}):DS(t,{strictUnions:e?.strictUnions??!0,pipeStrategy:e?.pipeStrategy??"input"})}function MS(t){let r=io(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let i=nc(r);if(typeof i!="string")throw new Error("Schema method literal must be a string");return i}function FS(t,e){let r=no(t,e);if(!r.success)throw r.error;return r.data}var ZS=w(()=>{Nk();Ju();f1()});function p1(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function h1(t,e){let r={...t};for(let i in e){let n=i,o=e[n];if(o===void 0)continue;let s=r[n];p1(s)&&p1(o)?r[n]={...s,...o}:r[n]=o}return r}var bJ,oy,m1=w(()=>{Ju();yc();RD();ZS();bJ=6e4,oy=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(Rg,r=>{this._oncancel(r)}),this.setNotificationHandler(zg,r=>{this._onprogress(r)}),this.setRequestHandler(jg,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Cg,async(r,i)=>{let n=await this._taskStore.getTask(r.params.taskId,i.sessionId);if(!n)throw new te(ae.InvalidParams,"Failed to retrieve task: Task not found");return{...n}}),this.setRequestHandler(Dg,async(r,i)=>{let n=async()=>{let o=r.params.taskId;if(!await this._taskStore.getTask(o,i.sessionId))throw new te(ae.InvalidParams,`Task not found: ${o}`);if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(o,i.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,l=c.id,u=this._requestResolvers.get(l);if(u)if(this._requestResolvers.delete(l),a.type==="response")u(c);else{let d=c,p=new te(d.error.code,d.error.message,d.error.data);u(p)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${l}`))}continue}await this._transport?.send(a.message,{relatedRequestId:i.requestId})}}let s=await this._taskStore.getTask(o,i.sessionId);if(!s)throw new te(ae.InvalidParams,`Task not found: ${o}`);if(!fo(s.status))return await this._waitForTaskUpdate(o,i.signal,i.sessionId),await n();if(fo(s.status)){let a=await this._taskStore.getTaskResult(o,i.sessionId);return this._clearTaskQueue(o,i.sessionId),{...a,_meta:{...a._meta,[uo]:{taskId:o}}}}return await n()};return await n()}),this.setRequestHandler(Lg,async(r,i)=>{try{let{tasks:n,nextCursor:o}=await this._taskStore.listTasks(r.params?.cursor,i.sessionId);return{tasks:n,nextCursor:o,_meta:{}}}catch(n){throw new te(ae.InvalidParams,`Failed to list tasks: ${n instanceof Error?n.message:String(n)}`)}}),this.setRequestHandler(Mg,async(r,i)=>{try{let n=await this._taskStore.getTask(r.params.taskId,i.sessionId);if(!n)throw new te(ae.InvalidParams,`Task not found: ${r.params.taskId}`);if(fo(n.status))throw new te(ae.InvalidParams,`Cannot cancel task in terminal status: ${n.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",i.sessionId),this._clearTaskQueue(r.params.taskId,i.sessionId);let o=await this._taskStore.getTask(r.params.taskId,i.sessionId);if(!o)throw new te(ae.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...o}}catch(n){throw n instanceof te?n:new te(ae.InvalidRequest,`Failed to cancel task: ${n instanceof Error?n.message:String(n)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,r,i,n,o=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(n,r),startTime:Date.now(),timeout:r,maxTotalTimeout:i,resetTimeoutOnProgress:o,onTimeout:n})}_resetTimeout(e){let r=this._timeoutInfo.get(e);if(!r)return!1;let i=Date.now()-r.startTime;if(r.maxTotalTimeout&&i>=r.maxTotalTimeout)throw this._timeoutInfo.delete(e),te.fromError(ae.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:i});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(e){let r=this._timeoutInfo.get(e);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let i=this.transport?.onerror;this._transport.onerror=o=>{i?.(o),this._onerror(o)};let n=this._transport?.onmessage;this._transport.onmessage=(o,s)=>{n?.(o,s),ud(o)||wD(o)?this._onresponse(o):H0(o)?this._onrequest(o,s):bD(o)?this._onnotification(o):this._onerror(new Error(`Unknown message type: ${JSON.stringify(o)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let i of this._timeoutInfo.values())clearTimeout(i.timeoutId);this._timeoutInfo.clear();for(let i of this._requestHandlerAbortControllers.values())i.abort();this._requestHandlerAbortControllers.clear();let r=te.fromError(ae.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let i of e.values())i(r)}_onerror(e){this.onerror?.(e)}_onnotification(e){let r=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(e)).catch(i=>this._onerror(new Error(`Uncaught error in notification handler: ${i}`)))}_onrequest(e,r){let i=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,n=this._transport,o=e.params?._meta?.[uo]?.taskId,s=n?.sessionId,a=this._taskStore,c=!0,l;if(o&&a&&this._taskMessageQueue&&s!==void 0&&(c=!1,l=(async()=>{if(!await a.getTask(o,s))throw new te(ae.InvalidParams,`Task not found: ${o}`);c=!0})()),i===void 0){let h={jsonrpc:"2.0",id:e.id,error:{code:ae.MethodNotFound,message:"Method not found"}};if(o&&l){let m={type:"error",message:h,timestamp:Date.now()};l.then(()=>this._enqueueTaskMessage(o,m,s),()=>n?.send(h)).catch(g=>this._onerror(new Error(`Failed to send an error response: ${g}`)))}else o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:h,timestamp:Date.now()},n?.sessionId).catch(m=>this._onerror(new Error(`Failed to enqueue error response: ${m}`))):n?.send(h).catch(m=>this._onerror(new Error(`Failed to send an error response: ${m}`)));return}let u=new AbortController;this._requestHandlerAbortControllers.set(e.id,u);let d=yD(e.params)?e.params.task:void 0,p=this._taskStore?this.requestTaskStore(e,n?.sessionId):void 0,f={signal:u.signal,sessionId:n?.sessionId,_meta:e.params?._meta,sendNotification:async h=>{if(u.signal.aborted)return;let m={relatedRequestId:e.id};o&&(m.relatedTask={taskId:o}),await this.notification(h,m)},sendRequest:async(h,m,g)=>{if(u.signal.aborted)throw new te(ae.ConnectionClosed,"Request was cancelled");let y={...g,relatedRequestId:e.id};o&&!y.relatedTask&&(y.relatedTask={taskId:o});let v=y.relatedTask?.taskId??o;return v&&p&&await p.updateTaskStatus(v,"input_required"),await this.request(h,m,y)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:o,taskStore:p,taskRequestedTtl:d?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};(l??Promise.resolve()).then(()=>{if(l&&u.signal.aborted)throw new te(ae.ConnectionClosed,"Request was cancelled");d&&this.assertTaskHandlerCapability(e.method)}).then(()=>i(e,f)).then(async h=>{if(u.signal.aborted)return;let m={result:h,jsonrpc:"2.0",id:e.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:m,timestamp:Date.now()},n?.sessionId):await n?.send(m)},async h=>{if(u.signal.aborted)return;let m={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(h.code)?h.code:ae.InternalError,message:h.message??"Internal error",...h.data!==void 0&&{data:h.data}}};o&&this._taskMessageQueue&&c?await this._enqueueTaskMessage(o,{type:"error",message:m,timestamp:Date.now()},n?.sessionId):await n?.send(m)}).catch(h=>this._onerror(new Error(`Failed to send response: ${h}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===u&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:r,...i}=e.params,n=Number(r),o=this._progressHandlers.get(n);if(!o){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let s=this._responseHandlers.get(n),a=this._timeoutInfo.get(n);if(a&&s&&a.resetTimeoutOnProgress)try{this._resetTimeout(n)}catch(c){this._responseHandlers.delete(n),this._progressHandlers.delete(n),this._cleanupTimeout(n),s(c);return}o(i)}_onresponse(e){let r=Number(e.id),i=this._requestResolvers.get(r);if(i){if(this._requestResolvers.delete(r),ud(e))i(e);else{let s=new te(e.error.code,e.error.message,e.error.data);i(s)}return}let n=this._responseHandlers.get(r);if(n===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let o=!1;if(ud(e)&&e.result&&typeof e.result=="object"){let s=e.result;if(s.task&&typeof s.task=="object"){let a=s.task;typeof a.taskId=="string"&&(o=!0,this._taskProgressTokens.set(a.taskId,r))}}if(o||this._progressHandlers.delete(r),ud(e))n(e);else{let s=te.fromError(e.error.code,e.error.message,e.error.data);n(s)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,r,i){let{task:n}=i??{};if(!n){try{yield{type:"result",result:await this.request(e,r,i)}}catch(s){yield{type:"error",error:s instanceof te?s:new te(ae.InternalError,String(s))}}return}let o;try{let s=await this.request(e,pc,i);if(s.task)o=s.task.taskId,yield{type:"taskCreated",task:s.task};else throw new te(ae.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:o},i);if(yield{type:"taskStatus",task:a},fo(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},r,i)}:a.status==="failed"?yield{type:"error",error:new te(ae.InternalError,`Task ${o} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new te(ae.InternalError,`Task ${o} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:o},r,i)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(l=>setTimeout(l,c)),i?.signal?.throwIfAborted()}}catch(s){yield{type:"error",error:s instanceof te?s:new te(ae.InternalError,String(s))}}}request(e,r,i){let{relatedRequestId:n,resumptionToken:o,onresumptiontoken:s,task:a,relatedTask:c}=i??{};return new Promise((l,u)=>{let d=v=>{u(v)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),a&&this.assertTaskCapability(e.method)}catch(v){d(v);return}i?.signal?.throwIfAborted();let p=this._requestMessageId++,f={...e,jsonrpc:"2.0",id:p};i?.onprogress&&(this._progressHandlers.set(p,i.onprogress),f.params={...e.params,_meta:{...e.params?._meta||{},progressToken:p}}),a&&(f.params={...f.params,task:a}),c&&(f.params={...f.params,_meta:{...f.params?._meta||{},[uo]:c}});let h=v=>{this._responseHandlers.delete(p),this._progressHandlers.delete(p),this._cleanupTimeout(p),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:p,reason:String(v)}},{relatedRequestId:n,resumptionToken:o,onresumptiontoken:s}).catch(x=>this._onerror(new Error(`Failed to send cancellation: ${x}`)));let b=v instanceof te?v:new te(ae.RequestTimeout,String(v));u(b)};this._responseHandlers.set(p,v=>{if(!i?.signal?.aborted){if(v instanceof Error)return u(v);try{let b=no(r,v.result);b.success?l(b.data):u(b.error)}catch(b){u(b)}}}),i?.signal?.addEventListener("abort",()=>{h(i?.signal?.reason)});let m=i?.timeout??bJ,g=()=>h(te.fromError(ae.RequestTimeout,"Request timed out",{timeout:m}));this._setupTimeout(p,m,i?.maxTotalTimeout,g,i?.resetTimeoutOnProgress??!1);let y=c?.taskId;if(y){let v=b=>{let x=this._responseHandlers.get(p);x?x(b):this._onerror(new Error(`Response handler missing for side-channeled request ${p}`))};this._requestResolvers.set(p,v),this._enqueueTaskMessage(y,{type:"request",message:f,timestamp:Date.now()}).catch(b=>{this._cleanupTimeout(p),u(b)})}else this._transport.send(f,{relatedRequestId:n,resumptionToken:o,onresumptiontoken:s}).catch(v=>{this._cleanupTimeout(p),u(v)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},Ng,r)}async getTaskResult(e,r,i){return this.request({method:"tasks/result",params:e},r,i)}async listTasks(e,r){return this.request({method:"tasks/list",params:e},Ug,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},SD,r)}async notification(e,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);let i=r?.relatedTask?.taskId;if(i){let a={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[uo]:r.relatedTask}}};await this._enqueueTaskMessage(i,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let a={...e,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[uo]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let s={...e,jsonrpc:"2.0"};r?.relatedTask&&(s={...s,params:{...s.params,_meta:{...s.params?._meta||{},[uo]:r.relatedTask}}}),await this._transport.send(s,r)}setRequestHandler(e,r){let i=MS(e);this.assertRequestHandlerCapability(i),this._requestHandlers.set(i,(n,o)=>{let s=FS(e,n);return Promise.resolve(r(s,o))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,r){let i=MS(e);this._notificationHandlers.set(i,n=>{let o=FS(e,n);return Promise.resolve(r(o))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let r=this._taskProgressTokens.get(e);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,r,i){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let n=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,r,i??this._transport?.sessionId,n)}async _clearTaskQueue(e,r){if(this._taskMessageQueue){let i=await this._taskMessageQueue.dequeueAll(e,r);for(let n of i)if(n.type==="request"&&H0(n.message)){let o=n.message.id,s=this._requestResolvers.get(o);s?(s(new te(ae.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(o)):this._onerror(new Error(`Resolver missing for request ${o} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,r,i){let n=this._options?.defaultTaskPollInterval??1e3;try{let o=await this._taskStore?.getTask(e,i);o?.pollInterval&&(n=o.pollInterval)}catch{}return new Promise((o,s)=>{if(r.aborted){s(new te(ae.InvalidRequest,"Request cancelled"));return}let a=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(a),s(new te(ae.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,r){let i=this._taskStore;if(!i)throw new Error("No task store configured");return{createTask:async n=>{if(!e)throw new Error("No request provided");return await i.createTask(n,e.id,{method:e.method,params:e.params},r)},getTask:async n=>{let o=await i.getTask(n,r);if(!o)throw new te(ae.InvalidParams,"Failed to retrieve task: Task not found");return o},storeTaskResult:async(n,o,s)=>{await i.storeTaskResult(n,o,s,r);let a=await i.getTask(n,r);if(a){let c=md.parse({method:"notifications/tasks/status",params:a});await this.notification(c),fo(a.status)&&this._cleanupTaskProgressHandler(n)}},getTaskResult:n=>i.getTaskResult(n,r),updateTaskStatus:async(n,o,s)=>{let a=await i.getTask(n,r);if(!a)throw new te(ae.InvalidParams,`Task "${n}" not found - it may have been cleaned up`);if(fo(a.status))throw new te(ae.InvalidParams,`Cannot update task "${n}" from terminal status "${a.status}" to "${o}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await i.updateTaskStatus(n,o,s,r);let c=await i.getTask(n,r);if(c){let l=md.parse({method:"notifications/tasks/status",params:c});await this.notification(l),fo(c.status)&&this._cleanupTaskProgressHandler(n)}},listTasks:n=>i.listTasks(n,r)}}}});var $d=C(Ge=>{"use strict";Object.defineProperty(Ge,"__esModule",{value:!0});Ge.regexpCode=Ge.getEsmExportName=Ge.getProperty=Ge.safeStringify=Ge.stringify=Ge.strConcat=Ge.addCodeArg=Ge.str=Ge._=Ge.nil=Ge._Code=Ge.Name=Ge.IDENTIFIER=Ge._CodeOrName=void 0;var bd=class{};Ge._CodeOrName=bd;Ge.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var ws=class extends bd{constructor(e){if(super(),!Ge.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};Ge.Name=ws;var fn=class extends bd{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,i)=>`${r}${i}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,i)=>(i instanceof ws&&(r[i.str]=(r[i.str]||0)+1),r),{})}};Ge._Code=fn;Ge.nil=new fn("");function g1(t,...e){let r=[t[0]],i=0;for(;i<e.length;)VS(r,e[i]),r.push(t[++i]);return new fn(r)}Ge._=g1;var qS=new fn("+");function y1(t,...e){let r=[wd(t[0])],i=0;for(;i<e.length;)r.push(qS),VS(r,e[i]),r.push(qS,wd(t[++i]));return wJ(r),new fn(r)}Ge.str=y1;function VS(t,e){e instanceof fn?t.push(...e._items):e instanceof ws?t.push(e):t.push(SJ(e))}Ge.addCodeArg=VS;function wJ(t){let e=1;for(;e<t.length-1;){if(t[e]===qS){let r=$J(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function $J(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof ws||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof ws))return`"${t}${e.slice(1)}`}function kJ(t,e){return e.emptyStr()?t:t.emptyStr()?e:y1`${t}${e}`}Ge.strConcat=kJ;function SJ(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:wd(Array.isArray(t)?t.join(","):t)}function xJ(t){return new fn(wd(t))}Ge.stringify=xJ;function wd(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}Ge.safeStringify=wd;function IJ(t){return typeof t=="string"&&Ge.IDENTIFIER.test(t)?new fn(`.${t}`):g1`[${t}]`}Ge.getProperty=IJ;function EJ(t){if(typeof t=="string"&&Ge.IDENTIFIER.test(t))return new fn(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}Ge.getEsmExportName=EJ;function TJ(t){return new fn(t.toString())}Ge.regexpCode=TJ});var WS=C(Nr=>{"use strict";Object.defineProperty(Nr,"__esModule",{value:!0});Nr.ValueScope=Nr.ValueScopeName=Nr.Scope=Nr.varKinds=Nr.UsedValueState=void 0;var Cr=$d(),BS=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},sy;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(sy||(Nr.UsedValueState=sy={}));Nr.varKinds={const:new Cr.Name("const"),let:new Cr.Name("let"),var:new Cr.Name("var")};var ay=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof Cr.Name?e:this.name(e)}name(e){return new Cr.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,i;if(!((i=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||i===void 0)&&i.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};Nr.Scope=ay;var cy=class extends Cr.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:i}){this.value=e,this.scopePath=(0,Cr._)`.${new Cr.Name(r)}[${i}]`}};Nr.ValueScopeName=cy;var OJ=(0,Cr._)`\n`,HS=class extends ay{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?OJ:Cr.nil}}get(){return this._scope}name(e){return new cy(e,this._newName(e))}value(e,r){var i;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let n=this.toName(e),{prefix:o}=n,s=(i=r.key)!==null&&i!==void 0?i:r.ref,a=this._values[o];if(a){let u=a.get(s);if(u)return u}else a=this._values[o]=new Map;a.set(s,n);let c=this._scope[o]||(this._scope[o]=[]),l=c.length;return c[l]=r.ref,n.setValue(r,{property:o,itemIndex:l}),n}getValue(e,r){let i=this._values[e];if(i)return i.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,i=>{if(i.scopePath===void 0)throw new Error(`CodeGen: name "${i}" has no value`);return(0,Cr._)`${e}${i.scopePath}`})}scopeCode(e=this._values,r,i){return this._reduceValues(e,n=>{if(n.value===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return n.value.code},r,i)}_reduceValues(e,r,i={},n){let o=Cr.nil;for(let s in e){let a=e[s];if(!a)continue;let c=i[s]=i[s]||new Map;a.forEach(l=>{if(c.has(l))return;c.set(l,sy.Started);let u=r(l);if(u){let d=this.opts.es5?Nr.varKinds.var:Nr.varKinds.const;o=(0,Cr._)`${o}${d} ${l} = ${u};${this.opts._n}`}else if(u=n?.(l))o=(0,Cr._)`${o}${u}${this.opts._n}`;else throw new BS(l);c.set(l,sy.Completed)})}return o}};Nr.ValueScope=HS});var Te=C(Ae=>{"use strict";Object.defineProperty(Ae,"__esModule",{value:!0});Ae.or=Ae.and=Ae.not=Ae.CodeGen=Ae.operators=Ae.varKinds=Ae.ValueScopeName=Ae.ValueScope=Ae.Scope=Ae.Name=Ae.regexpCode=Ae.stringify=Ae.getProperty=Ae.nil=Ae.strConcat=Ae.str=Ae._=void 0;var Fe=$d(),jn=WS(),ho=$d();Object.defineProperty(Ae,"_",{enumerable:!0,get:function(){return ho._}});Object.defineProperty(Ae,"str",{enumerable:!0,get:function(){return ho.str}});Object.defineProperty(Ae,"strConcat",{enumerable:!0,get:function(){return ho.strConcat}});Object.defineProperty(Ae,"nil",{enumerable:!0,get:function(){return ho.nil}});Object.defineProperty(Ae,"getProperty",{enumerable:!0,get:function(){return ho.getProperty}});Object.defineProperty(Ae,"stringify",{enumerable:!0,get:function(){return ho.stringify}});Object.defineProperty(Ae,"regexpCode",{enumerable:!0,get:function(){return ho.regexpCode}});Object.defineProperty(Ae,"Name",{enumerable:!0,get:function(){return ho.Name}});var fy=WS();Object.defineProperty(Ae,"Scope",{enumerable:!0,get:function(){return fy.Scope}});Object.defineProperty(Ae,"ValueScope",{enumerable:!0,get:function(){return fy.ValueScope}});Object.defineProperty(Ae,"ValueScopeName",{enumerable:!0,get:function(){return fy.ValueScopeName}});Object.defineProperty(Ae,"varKinds",{enumerable:!0,get:function(){return fy.varKinds}});Ae.operators={GT:new Fe._Code(">"),GTE:new Fe._Code(">="),LT:new Fe._Code("<"),LTE:new Fe._Code("<="),EQ:new Fe._Code("==="),NEQ:new Fe._Code("!=="),NOT:new Fe._Code("!"),OR:new Fe._Code("||"),AND:new Fe._Code("&&"),ADD:new Fe._Code("+")};var Ri=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},KS=class extends Ri{constructor(e,r,i){super(),this.varKind=e,this.name=r,this.rhs=i}render({es5:e,_n:r}){let i=e?jn.varKinds.var:this.varKind,n=this.rhs===void 0?"":` = ${this.rhs}`;return`${i} ${this.name}${n};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=_c(this.rhs,e,r)),this}get names(){return this.rhs instanceof Fe._CodeOrName?this.rhs.names:{}}},ly=class extends Ri{constructor(e,r,i){super(),this.lhs=e,this.rhs=r,this.sideEffects=i}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof Fe.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=_c(this.rhs,e,r),this}get names(){let e=this.lhs instanceof Fe.Name?{}:{...this.lhs.names};return dy(e,this.rhs)}},GS=class extends ly{constructor(e,r,i,n){super(e,i,n),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},JS=class extends Ri{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},XS=class extends Ri{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},YS=class extends Ri{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},QS=class extends Ri{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=_c(this.code,e,r),this}get names(){return this.code instanceof Fe._CodeOrName?this.code.names:{}}},kd=class extends Ri{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,i)=>r+i.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let i=e[r].optimizeNodes();Array.isArray(i)?e.splice(r,1,...i):i?e[r]=i:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:i}=this,n=i.length;for(;n--;){let o=i[n];o.optimizeNames(e,r)||(PJ(e,o.names),i.splice(n,1))}return i.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>Ss(e,r.names),{})}},ji=class extends kd{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},ex=class extends kd{},vc=class extends ji{};vc.kind="else";var $s=class t extends ji{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let i=r.optimizeNodes();r=this.else=Array.isArray(i)?new vc(i):i}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(v1(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var i;if(this.else=(i=this.else)===null||i===void 0?void 0:i.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=_c(this.condition,e,r),this}get names(){let e=super.names;return dy(e,this.condition),this.else&&Ss(e,this.else.names),e}};$s.kind="if";var ks=class extends ji{};ks.kind="for";var tx=class extends ks{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=_c(this.iteration,e,r),this}get names(){return Ss(super.names,this.iteration.names)}},rx=class extends ks{constructor(e,r,i,n){super(),this.varKind=e,this.name=r,this.from=i,this.to=n}render(e){let r=e.es5?jn.varKinds.var:this.varKind,{name:i,from:n,to:o}=this;return`for(${r} ${i}=${n}; ${i}<${o}; ${i}++)`+super.render(e)}get names(){let e=dy(super.names,this.from);return dy(e,this.to)}},uy=class extends ks{constructor(e,r,i,n){super(),this.loop=e,this.varKind=r,this.name=i,this.iterable=n}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=_c(this.iterable,e,r),this}get names(){return Ss(super.names,this.iterable.names)}},Sd=class extends ji{constructor(e,r,i){super(),this.name=e,this.args=r,this.async=i}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};Sd.kind="func";var xd=class extends kd{render(e){return"return "+super.render(e)}};xd.kind="return";var nx=class extends ji{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var i,n;return super.optimizeNames(e,r),(i=this.catch)===null||i===void 0||i.optimizeNames(e,r),(n=this.finally)===null||n===void 0||n.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&Ss(e,this.catch.names),this.finally&&Ss(e,this.finally.names),e}},Id=class extends ji{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};Id.kind="catch";var Ed=class extends ji{render(e){return"finally"+super.render(e)}};Ed.kind="finally";var ix=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
125
+ `:""},this._extScope=e,this._scope=new jn.Scope({parent:e}),this._nodes=[new ex]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let i=this._extScope.value(e,r);return(this._values[i.prefix]||(this._values[i.prefix]=new Set)).add(i),i}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,i,n){let o=this._scope.toName(r);return i!==void 0&&n&&(this._constants[o.str]=i),this._leafNode(new KS(e,o,i)),o}const(e,r,i){return this._def(jn.varKinds.const,e,r,i)}let(e,r,i){return this._def(jn.varKinds.let,e,r,i)}var(e,r,i){return this._def(jn.varKinds.var,e,r,i)}assign(e,r,i){return this._leafNode(new ly(e,r,i))}add(e,r){return this._leafNode(new GS(e,Ae.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==Fe.nil&&this._leafNode(new QS(e)),this}object(...e){let r=["{"];for(let[i,n]of e)r.length>1&&r.push(","),r.push(i),(i!==n||this.opts.es5)&&(r.push(":"),(0,Fe.addCodeArg)(r,n));return r.push("}"),new Fe._Code(r)}if(e,r,i){if(this._blockNode(new $s(e)),r&&i)this.code(r).else().code(i).endIf();else if(r)this.code(r).endIf();else if(i)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new $s(e))}else(){return this._elseNode(new vc)}endIf(){return this._endBlockNode($s,vc)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new tx(e),r)}forRange(e,r,i,n,o=this.opts.es5?jn.varKinds.var:jn.varKinds.let){let s=this._scope.toName(e);return this._for(new rx(o,s,r,i),()=>n(s))}forOf(e,r,i,n=jn.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let s=r instanceof Fe.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,Fe._)`${s}.length`,a=>{this.var(o,(0,Fe._)`${s}[${a}]`),i(o)})}return this._for(new uy("of",n,o,r),()=>i(o))}forIn(e,r,i,n=this.opts.es5?jn.varKinds.var:jn.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,Fe._)`Object.keys(${r})`,i);let o=this._scope.toName(e);return this._for(new uy("in",n,o,r),()=>i(o))}endFor(){return this._endBlockNode(ks)}label(e){return this._leafNode(new JS(e))}break(e){return this._leafNode(new XS(e))}return(e){let r=new xd;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(xd)}try(e,r,i){if(!r&&!i)throw new Error('CodeGen: "try" without "catch" and "finally"');let n=new nx;if(this._blockNode(n),this.code(e),r){let o=this.name("e");this._currNode=n.catch=new Id(o),r(o)}return i&&(this._currNode=n.finally=new Ed,this.code(i)),this._endBlockNode(Id,Ed)}throw(e){return this._leafNode(new YS(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let i=this._nodes.length-r;if(i<0||e!==void 0&&i!==e)throw new Error(`CodeGen: wrong number of nodes: ${i} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=Fe.nil,i,n){return this._blockNode(new Sd(e,r,i)),n&&this.code(n).endFunc(),this}endFunc(){return this._endBlockNode(Sd)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,r){let i=this._currNode;if(i instanceof e||r&&i instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof $s))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e}};Ae.CodeGen=ix;function Ss(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function dy(t,e){return e instanceof Fe._CodeOrName?Ss(t,e.names):t}function _c(t,e,r){if(t instanceof Fe.Name)return i(t);if(!n(t))return t;return new Fe._Code(t._items.reduce((o,s)=>(s instanceof Fe.Name&&(s=i(s)),s instanceof Fe._Code?o.push(...s._items):o.push(s),o),[]));function i(o){let s=r[o.str];return s===void 0||e[o.str]!==1?o:(delete e[o.str],s)}function n(o){return o instanceof Fe._Code&&o._items.some(s=>s instanceof Fe.Name&&e[s.str]===1&&r[s.str]!==void 0)}}function PJ(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function v1(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,Fe._)`!${ox(t)}`}Ae.not=v1;var AJ=_1(Ae.operators.AND);function RJ(...t){return t.reduce(AJ)}Ae.and=RJ;var jJ=_1(Ae.operators.OR);function zJ(...t){return t.reduce(jJ)}Ae.or=zJ;function _1(t){return(e,r)=>e===Fe.nil?r:r===Fe.nil?e:(0,Fe._)`${ox(e)} ${t} ${ox(r)}`}function ox(t){return t instanceof Fe.Name?t:(0,Fe._)`(${t})`}});var qe=C(Ne=>{"use strict";Object.defineProperty(Ne,"__esModule",{value:!0});Ne.checkStrictMode=Ne.getErrorPath=Ne.Type=Ne.useFunc=Ne.setEvaluated=Ne.evaluatedPropsToName=Ne.mergeEvaluated=Ne.eachItem=Ne.unescapeJsonPointer=Ne.escapeJsonPointer=Ne.escapeFragment=Ne.unescapeFragment=Ne.schemaRefOrVal=Ne.schemaHasRulesButRef=Ne.schemaHasRules=Ne.checkUnknownRules=Ne.alwaysValidSchema=Ne.toHash=void 0;var ft=Te(),CJ=$d();function NJ(t){let e={};for(let r of t)e[r]=!0;return e}Ne.toHash=NJ;function DJ(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:($1(t,e),!k1(e,t.self.RULES.all))}Ne.alwaysValidSchema=DJ;function $1(t,e=t.schema){let{opts:r,self:i}=t;if(!r.strictSchema||typeof e=="boolean")return;let n=i.RULES.keywords;for(let o in e)n[o]||I1(t,`unknown keyword: "${o}"`)}Ne.checkUnknownRules=$1;function k1(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}Ne.schemaHasRules=k1;function LJ(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}Ne.schemaHasRulesButRef=LJ;function UJ({topSchemaRef:t,schemaPath:e},r,i,n){if(!n){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,ft._)`${r}`}return(0,ft._)`${t}${e}${(0,ft.getProperty)(i)}`}Ne.schemaRefOrVal=UJ;function MJ(t){return S1(decodeURIComponent(t))}Ne.unescapeFragment=MJ;function FJ(t){return encodeURIComponent(ax(t))}Ne.escapeFragment=FJ;function ax(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}Ne.escapeJsonPointer=ax;function S1(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}Ne.unescapeJsonPointer=S1;function ZJ(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}Ne.eachItem=ZJ;function b1({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:i}){return(n,o,s,a)=>{let c=s===void 0?o:s instanceof ft.Name?(o instanceof ft.Name?t(n,o,s):e(n,o,s),s):o instanceof ft.Name?(e(n,s,o),o):r(o,s);return a===ft.Name&&!(c instanceof ft.Name)?i(n,c):c}}Ne.mergeEvaluated={props:b1({mergeNames:(t,e,r)=>t.if((0,ft._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,ft._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,ft._)`${r} || {}`).code((0,ft._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,ft._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,ft._)`${r} || {}`),cx(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:x1}),items:b1({mergeNames:(t,e,r)=>t.if((0,ft._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,ft._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,ft._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,ft._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function x1(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,ft._)`{}`);return e!==void 0&&cx(t,r,e),r}Ne.evaluatedPropsToName=x1;function cx(t,e,r){Object.keys(r).forEach(i=>t.assign((0,ft._)`${e}${(0,ft.getProperty)(i)}`,!0))}Ne.setEvaluated=cx;var w1={};function qJ(t,e){return t.scopeValue("func",{ref:e,code:w1[e.code]||(w1[e.code]=new CJ._Code(e.code))})}Ne.useFunc=qJ;var sx;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(sx||(Ne.Type=sx={}));function VJ(t,e,r){if(t instanceof ft.Name){let i=e===sx.Num;return r?i?(0,ft._)`"[" + ${t} + "]"`:(0,ft._)`"['" + ${t} + "']"`:i?(0,ft._)`"/" + ${t}`:(0,ft._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,ft.getProperty)(t).toString():"/"+ax(t)}Ne.getErrorPath=VJ;function I1(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}Ne.checkStrictMode=I1});var zi=C(lx=>{"use strict";Object.defineProperty(lx,"__esModule",{value:!0});var cr=Te(),BJ={data:new cr.Name("data"),valCxt:new cr.Name("valCxt"),instancePath:new cr.Name("instancePath"),parentData:new cr.Name("parentData"),parentDataProperty:new cr.Name("parentDataProperty"),rootData:new cr.Name("rootData"),dynamicAnchors:new cr.Name("dynamicAnchors"),vErrors:new cr.Name("vErrors"),errors:new cr.Name("errors"),this:new cr.Name("this"),self:new cr.Name("self"),scope:new cr.Name("scope"),json:new cr.Name("json"),jsonPos:new cr.Name("jsonPos"),jsonLen:new cr.Name("jsonLen"),jsonPart:new cr.Name("jsonPart")};lx.default=BJ});var Td=C(lr=>{"use strict";Object.defineProperty(lr,"__esModule",{value:!0});lr.extendErrors=lr.resetErrorsCount=lr.reportExtraError=lr.reportError=lr.keyword$DataError=lr.keywordError=void 0;var Ve=Te(),py=qe(),kr=zi();lr.keywordError={message:({keyword:t})=>(0,Ve.str)`must pass "${t}" keyword validation`};lr.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,Ve.str)`"${t}" keyword must be ${e} ($data)`:(0,Ve.str)`"${t}" keyword is invalid ($data)`};function HJ(t,e=lr.keywordError,r,i){let{it:n}=t,{gen:o,compositeRule:s,allErrors:a}=n,c=O1(t,e,r);i??(s||a)?E1(o,c):T1(n,(0,Ve._)`[${c}]`)}lr.reportError=HJ;function WJ(t,e=lr.keywordError,r){let{it:i}=t,{gen:n,compositeRule:o,allErrors:s}=i,a=O1(t,e,r);E1(n,a),o||s||T1(i,kr.default.vErrors)}lr.reportExtraError=WJ;function KJ(t,e){t.assign(kr.default.errors,e),t.if((0,Ve._)`${kr.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,Ve._)`${kr.default.vErrors}.length`,e),()=>t.assign(kr.default.vErrors,null)))}lr.resetErrorsCount=KJ;function GJ({gen:t,keyword:e,schemaValue:r,data:i,errsCount:n,it:o}){if(n===void 0)throw new Error("ajv implementation error");let s=t.name("err");t.forRange("i",n,kr.default.errors,a=>{t.const(s,(0,Ve._)`${kr.default.vErrors}[${a}]`),t.if((0,Ve._)`${s}.instancePath === undefined`,()=>t.assign((0,Ve._)`${s}.instancePath`,(0,Ve.strConcat)(kr.default.instancePath,o.errorPath))),t.assign((0,Ve._)`${s}.schemaPath`,(0,Ve.str)`${o.errSchemaPath}/${e}`),o.opts.verbose&&(t.assign((0,Ve._)`${s}.schema`,r),t.assign((0,Ve._)`${s}.data`,i))})}lr.extendErrors=GJ;function E1(t,e){let r=t.const("err",e);t.if((0,Ve._)`${kr.default.vErrors} === null`,()=>t.assign(kr.default.vErrors,(0,Ve._)`[${r}]`),(0,Ve._)`${kr.default.vErrors}.push(${r})`),t.code((0,Ve._)`${kr.default.errors}++`)}function T1(t,e){let{gen:r,validateName:i,schemaEnv:n}=t;n.$async?r.throw((0,Ve._)`new ${t.ValidationError}(${e})`):(r.assign((0,Ve._)`${i}.errors`,e),r.return(!1))}var xs={keyword:new Ve.Name("keyword"),schemaPath:new Ve.Name("schemaPath"),params:new Ve.Name("params"),propertyName:new Ve.Name("propertyName"),message:new Ve.Name("message"),schema:new Ve.Name("schema"),parentSchema:new Ve.Name("parentSchema")};function O1(t,e,r){let{createErrors:i}=t.it;return i===!1?(0,Ve._)`{}`:JJ(t,e,r)}function JJ(t,e,r={}){let{gen:i,it:n}=t,o=[XJ(n,r),YJ(t,r)];return QJ(t,e,o),i.object(...o)}function XJ({errorPath:t},{instancePath:e}){let r=e?(0,Ve.str)`${t}${(0,py.getErrorPath)(e,py.Type.Str)}`:t;return[kr.default.instancePath,(0,Ve.strConcat)(kr.default.instancePath,r)]}function YJ({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:i}){let n=i?e:(0,Ve.str)`${e}/${t}`;return r&&(n=(0,Ve.str)`${n}${(0,py.getErrorPath)(r,py.Type.Str)}`),[xs.schemaPath,n]}function QJ(t,{params:e,message:r},i){let{keyword:n,data:o,schemaValue:s,it:a}=t,{opts:c,propertyName:l,topSchemaRef:u,schemaPath:d}=a;i.push([xs.keyword,n],[xs.params,typeof e=="function"?e(t):e||(0,Ve._)`{}`]),c.messages&&i.push([xs.message,typeof r=="function"?r(t):r]),c.verbose&&i.push([xs.schema,s],[xs.parentSchema,(0,Ve._)`${u}${d}`],[kr.default.data,o]),l&&i.push([xs.propertyName,l])}});var A1=C(bc=>{"use strict";Object.defineProperty(bc,"__esModule",{value:!0});bc.boolOrEmptySchema=bc.topBoolOrEmptySchema=void 0;var e3=Td(),t3=Te(),r3=zi(),n3={message:"boolean schema is false"};function i3(t){let{gen:e,schema:r,validateName:i}=t;r===!1?P1(t,!1):typeof r=="object"&&r.$async===!0?e.return(r3.default.data):(e.assign((0,t3._)`${i}.errors`,null),e.return(!0))}bc.topBoolOrEmptySchema=i3;function o3(t,e){let{gen:r,schema:i}=t;i===!1?(r.var(e,!1),P1(t)):r.var(e,!0)}bc.boolOrEmptySchema=o3;function P1(t,e){let{gen:r,data:i}=t,n={gen:r,keyword:"false schema",data:i,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,e3.reportError)(n,n3,void 0,e)}});var ux=C(wc=>{"use strict";Object.defineProperty(wc,"__esModule",{value:!0});wc.getRules=wc.isJSONType=void 0;var s3=["string","number","integer","boolean","null","object","array"],a3=new Set(s3);function c3(t){return typeof t=="string"&&a3.has(t)}wc.isJSONType=c3;function l3(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}wc.getRules=l3});var dx=C(mo=>{"use strict";Object.defineProperty(mo,"__esModule",{value:!0});mo.shouldUseRule=mo.shouldUseGroup=mo.schemaHasRulesForType=void 0;function u3({schema:t,self:e},r){let i=e.RULES.types[r];return i&&i!==!0&&R1(t,i)}mo.schemaHasRulesForType=u3;function R1(t,e){return e.rules.some(r=>j1(t,r))}mo.shouldUseGroup=R1;function j1(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(i=>t[i]!==void 0))}mo.shouldUseRule=j1});var Od=C(ur=>{"use strict";Object.defineProperty(ur,"__esModule",{value:!0});ur.reportTypeError=ur.checkDataTypes=ur.checkDataType=ur.coerceAndCheckDataType=ur.getJSONTypes=ur.getSchemaTypes=ur.DataType=void 0;var d3=ux(),f3=dx(),p3=Td(),Ie=Te(),z1=qe(),$c;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})($c||(ur.DataType=$c={}));function h3(t){let e=C1(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}ur.getSchemaTypes=h3;function C1(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(d3.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}ur.getJSONTypes=C1;function m3(t,e){let{gen:r,data:i,opts:n}=t,o=g3(e,n.coerceTypes),s=e.length>0&&!(o.length===0&&e.length===1&&(0,f3.schemaHasRulesForType)(t,e[0]));if(s){let a=px(e,i,n.strictNumbers,$c.Wrong);r.if(a,()=>{o.length?y3(t,e,o):hx(t)})}return s}ur.coerceAndCheckDataType=m3;var N1=new Set(["string","number","integer","boolean","null"]);function g3(t,e){return e?t.filter(r=>N1.has(r)||e==="array"&&r==="array"):[]}function y3(t,e,r){let{gen:i,data:n,opts:o}=t,s=i.let("dataType",(0,Ie._)`typeof ${n}`),a=i.let("coerced",(0,Ie._)`undefined`);o.coerceTypes==="array"&&i.if((0,Ie._)`${s} == 'object' && Array.isArray(${n}) && ${n}.length == 1`,()=>i.assign(n,(0,Ie._)`${n}[0]`).assign(s,(0,Ie._)`typeof ${n}`).if(px(e,n,o.strictNumbers),()=>i.assign(a,n))),i.if((0,Ie._)`${a} !== undefined`);for(let l of r)(N1.has(l)||l==="array"&&o.coerceTypes==="array")&&c(l);i.else(),hx(t),i.endIf(),i.if((0,Ie._)`${a} !== undefined`,()=>{i.assign(n,a),v3(t,a)});function c(l){switch(l){case"string":i.elseIf((0,Ie._)`${s} == "number" || ${s} == "boolean"`).assign(a,(0,Ie._)`"" + ${n}`).elseIf((0,Ie._)`${n} === null`).assign(a,(0,Ie._)`""`);return;case"number":i.elseIf((0,Ie._)`${s} == "boolean" || ${n} === null
126
126
  || (${s} == "string" && ${n} && ${n} == +${n})`).assign(a,(0,Ie._)`+${n}`);return;case"integer":i.elseIf((0,Ie._)`${s} === "boolean" || ${n} === null
127
127
  || (${s} === "string" && ${n} && ${n} == +${n} && !(${n} % 1))`).assign(a,(0,Ie._)`+${n}`);return;case"boolean":i.elseIf((0,Ie._)`${n} === "false" || ${n} === 0 || ${n} === null`).assign(a,!1).elseIf((0,Ie._)`${n} === "true" || ${n} === 1`).assign(a,!0);return;case"null":i.elseIf((0,Ie._)`${n} === "" || ${n} === 0 || ${n} === false`),i.assign(a,null);return;case"array":i.elseIf((0,Ie._)`${s} === "string" || ${s} === "number"
128
- || ${s} === "boolean" || ${n} === null`).assign(a,(0,Ie._)`[${n}]`)}}}function m3({gen:t,parentData:e,parentDataProperty:r},i){t.if((0,Ie._)`${e} !== undefined`,()=>t.assign((0,Ie._)`${e}[${r}]`,i))}function fx(t,e,r,i=$c.Correct){let n=i===$c.Correct?Ie.operators.EQ:Ie.operators.NEQ,o;switch(t){case"null":return(0,Ie._)`${e} ${n} null`;case"array":o=(0,Ie._)`Array.isArray(${e})`;break;case"object":o=(0,Ie._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":o=s((0,Ie._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":o=s();break;default:return(0,Ie._)`typeof ${e} ${n} ${t}`}return i===$c.Correct?o:(0,Ie.not)(o);function s(a=Ie.nil){return(0,Ie.and)((0,Ie._)`typeof ${e} == "number"`,a,r?(0,Ie._)`isFinite(${e})`:Ie.nil)}}ur.checkDataType=fx;function px(t,e,r,i){if(t.length===1)return fx(t[0],e,r,i);let n,o=(0,z1.toHash)(t);if(o.array&&o.object){let s=(0,Ie._)`typeof ${e} != "object"`;n=o.null?s:(0,Ie._)`!${e} || ${s}`,delete o.null,delete o.array,delete o.object}else n=Ie.nil;o.number&&delete o.integer;for(let s in o)n=(0,Ie.and)(n,fx(s,e,r,i));return n}ur.checkDataTypes=px;var g3={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,Ie._)`{type: ${t}}`:(0,Ie._)`{type: ${e}}`};function hx(t){let e=y3(t);(0,u3.reportError)(e,g3)}ur.reportTypeError=hx;function y3(t){let{gen:e,data:r,schema:i}=t,n=(0,z1.schemaRefOrVal)(t,i,"type");return{gen:e,keyword:"type",data:r,schema:i.type,schemaCode:n,schemaValue:n,parentSchema:i,params:{},it:t}}});var L1=C(hy=>{"use strict";Object.defineProperty(hy,"__esModule",{value:!0});hy.assignDefaults=void 0;var kc=Te(),v3=qe();function _3(t,e){let{properties:r,items:i}=t.schema;if(e==="object"&&r)for(let n in r)D1(t,n,r[n].default);else e==="array"&&Array.isArray(i)&&i.forEach((n,o)=>D1(t,o,n.default))}hy.assignDefaults=_3;function D1(t,e,r){let{gen:i,compositeRule:n,data:o,opts:s}=t;if(r===void 0)return;let a=(0,kc._)`${o}${(0,kc.getProperty)(e)}`;if(n){(0,v3.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,kc._)`${a} === undefined`;s.useDefaults==="empty"&&(c=(0,kc._)`${c} || ${a} === null || ${a} === ""`),i.if(c,(0,kc._)`${a} = ${(0,kc.stringify)(r)}`)}});var pn=C(lt=>{"use strict";Object.defineProperty(lt,"__esModule",{value:!0});lt.validateUnion=lt.validateArray=lt.usePattern=lt.callValidateCode=lt.schemaProperties=lt.allSchemaProperties=lt.noPropertyInData=lt.propertyInData=lt.isOwnProperty=lt.hasPropFunc=lt.reportMissingProp=lt.checkMissingProp=lt.checkReportMissingProp=void 0;var vt=Te(),mx=qe(),go=zi(),b3=qe();function w3(t,e){let{gen:r,data:i,it:n}=t;r.if(yx(r,i,e,n.opts.ownProperties),()=>{t.setParams({missingProperty:(0,vt._)`${e}`},!0),t.error()})}lt.checkReportMissingProp=w3;function $3({gen:t,data:e,it:{opts:r}},i,n){return(0,vt.or)(...i.map(o=>(0,vt.and)(yx(t,e,o,r.ownProperties),(0,vt._)`${n} = ${o}`)))}lt.checkMissingProp=$3;function k3(t,e){t.setParams({missingProperty:e},!0),t.error()}lt.reportMissingProp=k3;function U1(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,vt._)`Object.prototype.hasOwnProperty`})}lt.hasPropFunc=U1;function gx(t,e,r){return(0,vt._)`${U1(t)}.call(${e}, ${r})`}lt.isOwnProperty=gx;function S3(t,e,r,i){let n=(0,vt._)`${e}${(0,vt.getProperty)(r)} !== undefined`;return i?(0,vt._)`${n} && ${gx(t,e,r)}`:n}lt.propertyInData=S3;function yx(t,e,r,i){let n=(0,vt._)`${e}${(0,vt.getProperty)(r)} === undefined`;return i?(0,vt.or)(n,(0,vt.not)(gx(t,e,r))):n}lt.noPropertyInData=yx;function M1(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}lt.allSchemaProperties=M1;function x3(t,e){return M1(e).filter(r=>!(0,mx.alwaysValidSchema)(t,e[r]))}lt.schemaProperties=x3;function I3({schemaCode:t,data:e,it:{gen:r,topSchemaRef:i,schemaPath:n,errorPath:o},it:s},a,c,l){let u=l?(0,vt._)`${t}, ${e}, ${i}${n}`:e,d=[[go.default.instancePath,(0,vt.strConcat)(go.default.instancePath,o)],[go.default.parentData,s.parentData],[go.default.parentDataProperty,s.parentDataProperty],[go.default.rootData,go.default.rootData]];s.opts.dynamicRef&&d.push([go.default.dynamicAnchors,go.default.dynamicAnchors]);let p=(0,vt._)`${u}, ${r.object(...d)}`;return c!==vt.nil?(0,vt._)`${a}.call(${c}, ${p})`:(0,vt._)`${a}(${p})`}lt.callValidateCode=I3;var E3=(0,vt._)`new RegExp`;function T3({gen:t,it:{opts:e}},r){let i=e.unicodeRegExp?"u":"",{regExp:n}=e.code,o=n(r,i);return t.scopeValue("pattern",{key:o.toString(),ref:o,code:(0,vt._)`${n.code==="new RegExp"?E3:(0,b3.useFunc)(t,n)}(${r}, ${i})`})}lt.usePattern=T3;function O3(t){let{gen:e,data:r,keyword:i,it:n}=t,o=e.name("valid");if(n.allErrors){let a=e.let("valid",!0);return s(()=>e.assign(a,!1)),a}return e.var(o,!0),s(()=>e.break()),o;function s(a){let c=e.const("len",(0,vt._)`${r}.length`);e.forRange("i",0,c,l=>{t.subschema({keyword:i,dataProp:l,dataPropType:mx.Type.Num},o),e.if((0,vt.not)(o),a)})}}lt.validateArray=O3;function P3(t){let{gen:e,schema:r,keyword:i,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,mx.alwaysValidSchema)(n,c))&&!n.opts.unevaluated)return;let s=e.let("valid",!1),a=e.name("_valid");e.block(()=>r.forEach((c,l)=>{let u=t.subschema({keyword:i,schemaProp:l,compositeRule:!0},a);e.assign(s,(0,vt._)`${s} || ${a}`),t.mergeValidEvaluated(u,a)||e.if((0,vt.not)(s))})),t.result(s,()=>t.reset(),()=>t.error(!0))}lt.validateUnion=P3});var q1=C(ri=>{"use strict";Object.defineProperty(ri,"__esModule",{value:!0});ri.validateKeywordUsage=ri.validSchemaType=ri.funcKeywordCode=ri.macroKeywordCode=void 0;var Sr=Te(),Is=zi(),A3=pn(),R3=Td();function j3(t,e){let{gen:r,keyword:i,schema:n,parentSchema:o,it:s}=t,a=e.macro.call(s.self,n,o,s),c=Z1(r,i,a);s.opts.validateSchema!==!1&&s.self.validateSchema(a,!0);let l=r.name("valid");t.subschema({schema:a,schemaPath:Sr.nil,errSchemaPath:`${s.errSchemaPath}/${i}`,topSchemaRef:c,compositeRule:!0},l),t.pass(l,()=>t.error(!0))}ri.macroKeywordCode=j3;function z3(t,e){var r;let{gen:i,keyword:n,schema:o,parentSchema:s,$data:a,it:c}=t;N3(c,e);let l=!a&&e.compile?e.compile.call(c.self,o,s,c):e.validate,u=Z1(i,n,l),d=i.let("valid");t.block$data(d,p),t.ok((r=e.valid)!==null&&r!==void 0?r:d);function p(){if(e.errors===!1)m(),e.modifying&&F1(t),g(()=>t.error());else{let y=e.async?f():h();e.modifying&&F1(t),g(()=>C3(t,y))}}function f(){let y=i.let("ruleErrs",null);return i.try(()=>m((0,Sr._)`await `),v=>i.assign(d,!1).if((0,Sr._)`${v} instanceof ${c.ValidationError}`,()=>i.assign(y,(0,Sr._)`${v}.errors`),()=>i.throw(v))),y}function h(){let y=(0,Sr._)`${u}.errors`;return i.assign(y,null),m(Sr.nil),y}function m(y=e.async?(0,Sr._)`await `:Sr.nil){let v=c.opts.passContext?Is.default.this:Is.default.self,b=!("compile"in e&&!a||e.schema===!1);i.assign(d,(0,Sr._)`${y}${(0,A3.callValidateCode)(t,u,v,b)}`,e.modifying)}function g(y){var v;i.if((0,Sr.not)((v=e.valid)!==null&&v!==void 0?v:d),y)}}ri.funcKeywordCode=z3;function F1(t){let{gen:e,data:r,it:i}=t;e.if(i.parentData,()=>e.assign(r,(0,Sr._)`${i.parentData}[${i.parentDataProperty}]`))}function C3(t,e){let{gen:r}=t;r.if((0,Sr._)`Array.isArray(${e})`,()=>{r.assign(Is.default.vErrors,(0,Sr._)`${Is.default.vErrors} === null ? ${e} : ${Is.default.vErrors}.concat(${e})`).assign(Is.default.errors,(0,Sr._)`${Is.default.vErrors}.length`),(0,R3.extendErrors)(t)},()=>t.error())}function N3({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function Z1(t,e,r){if(r===void 0)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,Sr.stringify)(r)})}function D3(t,e,r=!1){return!e.length||e.some(i=>i==="array"?Array.isArray(t):i==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==i||r&&typeof t>"u")}ri.validSchemaType=D3;function L3({schema:t,opts:e,self:r,errSchemaPath:i},n,o){if(Array.isArray(n.keyword)?!n.keyword.includes(o):n.keyword!==o)throw new Error("ajv implementation error");let s=n.dependencies;if(s?.some(a=>!Object.prototype.hasOwnProperty.call(t,a)))throw new Error(`parent schema must have dependencies of ${o}: ${s.join(",")}`);if(n.validateSchema&&!n.validateSchema(t[o])){let c=`keyword "${o}" value is invalid at path "${i}": `+r.errorsText(n.validateSchema.errors);if(e.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}ri.validateKeywordUsage=L3});var B1=C(yo=>{"use strict";Object.defineProperty(yo,"__esModule",{value:!0});yo.extendSubschemaMode=yo.extendSubschemaData=yo.getSubschema=void 0;var ni=Te(),V1=qe();function U3(t,{keyword:e,schemaProp:r,schema:i,schemaPath:n,errSchemaPath:o,topSchemaRef:s}){if(e!==void 0&&i!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let a=t.schema[e];return r===void 0?{schema:a,schemaPath:(0,ni._)`${t.schemaPath}${(0,ni.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,ni._)`${t.schemaPath}${(0,ni.getProperty)(e)}${(0,ni.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,V1.escapeFragment)(r)}`}}if(i!==void 0){if(n===void 0||o===void 0||s===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:i,schemaPath:n,topSchemaRef:s,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')}yo.getSubschema=U3;function M3(t,e,{dataProp:r,dataPropType:i,data:n,dataTypes:o,propertyName:s}){if(n!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=e;if(r!==void 0){let{errorPath:l,dataPathArr:u,opts:d}=e,p=a.let("data",(0,ni._)`${e.data}${(0,ni.getProperty)(r)}`,!0);c(p),t.errorPath=(0,ni.str)`${l}${(0,V1.getErrorPath)(r,i,d.jsPropertySyntax)}`,t.parentDataProperty=(0,ni._)`${r}`,t.dataPathArr=[...u,t.parentDataProperty]}if(n!==void 0){let l=n instanceof ni.Name?n:a.let("data",n,!0);c(l),s!==void 0&&(t.propertyName=s)}o&&(t.dataTypes=o);function c(l){t.data=l,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,l]}}yo.extendSubschemaData=M3;function F3(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:i,createErrors:n,allErrors:o}){i!==void 0&&(t.compositeRule=i),n!==void 0&&(t.createErrors=n),o!==void 0&&(t.allErrors=o),t.jtdDiscriminator=e,t.jtdMetadata=r}yo.extendSubschemaMode=F3});var vx=C((zfe,H1)=>{"use strict";H1.exports=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var i,n,o;if(Array.isArray(e)){if(i=e.length,i!=r.length)return!1;for(n=i;n--!==0;)if(!t(e[n],r[n]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(o=Object.keys(e),i=o.length,i!==Object.keys(r).length)return!1;for(n=i;n--!==0;)if(!Object.prototype.hasOwnProperty.call(r,o[n]))return!1;for(n=i;n--!==0;){var s=o[n];if(!t(e[s],r[s]))return!1}return!0}return e!==e&&r!==r}});var K1=C((Cfe,W1)=>{"use strict";var vo=W1.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var i=typeof r=="function"?r:r.pre||function(){},n=r.post||function(){};my(e,i,n,t,"",t)};vo.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};vo.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};vo.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};vo.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function my(t,e,r,i,n,o,s,a,c,l){if(i&&typeof i=="object"&&!Array.isArray(i)){e(i,n,o,s,a,c,l);for(var u in i){var d=i[u];if(Array.isArray(d)){if(u in vo.arrayKeywords)for(var p=0;p<d.length;p++)my(t,e,r,d[p],n+"/"+u+"/"+p,o,n,u,i,p)}else if(u in vo.propsKeywords){if(d&&typeof d=="object")for(var f in d)my(t,e,r,d[f],n+"/"+u+"/"+Z3(f),o,n,u,i,f)}else(u in vo.keywords||t.allKeys&&!(u in vo.skipKeywords))&&my(t,e,r,d,n+"/"+u,o,n,u,i)}r(i,n,o,s,a,c,l)}}function Z3(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var Pd=C(Dr=>{"use strict";Object.defineProperty(Dr,"__esModule",{value:!0});Dr.getSchemaRefs=Dr.resolveUrl=Dr.normalizeId=Dr._getFullPath=Dr.getFullPath=Dr.inlineRef=void 0;var q3=qe(),V3=vx(),B3=K1(),H3=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function W3(t,e=!0){return typeof t=="boolean"?!0:e===!0?!_x(t):e?G1(t)<=e:!1}Dr.inlineRef=W3;var K3=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function _x(t){for(let e in t){if(K3.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(_x)||typeof r=="object"&&_x(r))return!0}return!1}function G1(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!H3.has(r)&&(typeof t[r]=="object"&&(0,q3.eachItem)(t[r],i=>e+=G1(i)),e===1/0))return 1/0}return e}function J1(t,e="",r){r!==!1&&(e=Sc(e));let i=t.parse(e);return X1(t,i)}Dr.getFullPath=J1;function X1(t,e){return t.serialize(e).split("#")[0]+"#"}Dr._getFullPath=X1;var G3=/#\/?$/;function Sc(t){return t?t.replace(G3,""):""}Dr.normalizeId=Sc;function J3(t,e,r){return r=Sc(r),t.resolve(e,r)}Dr.resolveUrl=J3;var X3=/^[a-z_][-a-z0-9._]*$/i;function Y3(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:i}=this.opts,n=Sc(t[r]||e),o={"":n},s=J1(i,n,!1),a={},c=new Set;return B3(t,{allKeys:!0},(d,p,f,h)=>{if(h===void 0)return;let m=s+p,g=o[h];typeof d[r]=="string"&&(g=y.call(this,d[r])),v.call(this,d.$anchor),v.call(this,d.$dynamicAnchor),o[p]=g;function y(b){let x=this.opts.uriResolver.resolve;if(b=Sc(g?x(g,b):b),c.has(b))throw u(b);c.add(b);let k=this.refs[b];return typeof k=="string"&&(k=this.refs[k]),typeof k=="object"?l(d,k.schema,b):b!==Sc(m)&&(b[0]==="#"?(l(d,a[b],b),a[b]=d):this.refs[b]=m),b}function v(b){if(typeof b=="string"){if(!X3.test(b))throw new Error(`invalid anchor "${b}"`);y.call(this,`#${b}`)}}}),a;function l(d,p,f){if(p!==void 0&&!V3(d,p))throw u(f)}function u(d){return new Error(`reference "${d}" resolves to more than one schema`)}}Dr.getSchemaRefs=Y3});var jd=C(_o=>{"use strict";Object.defineProperty(_o,"__esModule",{value:!0});_o.getData=_o.KeywordCxt=_o.validateFunctionCode=void 0;var rL=A1(),Y1=Od(),wx=dx(),gy=Od(),Q3=L1(),Rd=q1(),bx=B1(),ce=Te(),be=zi(),e5=Pd(),Ci=qe(),Ad=Td();function t5(t){if(oL(t)&&(sL(t),iL(t))){i5(t);return}nL(t,()=>(0,rL.topBoolOrEmptySchema)(t))}_o.validateFunctionCode=t5;function nL({gen:t,validateName:e,schema:r,schemaEnv:i,opts:n},o){n.code.es5?t.func(e,(0,ce._)`${be.default.data}, ${be.default.valCxt}`,i.$async,()=>{t.code((0,ce._)`"use strict"; ${Q1(r,n)}`),n5(t,n),t.code(o)}):t.func(e,(0,ce._)`${be.default.data}, ${r5(n)}`,i.$async,()=>t.code(Q1(r,n)).code(o))}function r5(t){return(0,ce._)`{${be.default.instancePath}="", ${be.default.parentData}, ${be.default.parentDataProperty}, ${be.default.rootData}=${be.default.data}${t.dynamicRef?(0,ce._)`, ${be.default.dynamicAnchors}={}`:ce.nil}}={}`}function n5(t,e){t.if(be.default.valCxt,()=>{t.var(be.default.instancePath,(0,ce._)`${be.default.valCxt}.${be.default.instancePath}`),t.var(be.default.parentData,(0,ce._)`${be.default.valCxt}.${be.default.parentData}`),t.var(be.default.parentDataProperty,(0,ce._)`${be.default.valCxt}.${be.default.parentDataProperty}`),t.var(be.default.rootData,(0,ce._)`${be.default.valCxt}.${be.default.rootData}`),e.dynamicRef&&t.var(be.default.dynamicAnchors,(0,ce._)`${be.default.valCxt}.${be.default.dynamicAnchors}`)},()=>{t.var(be.default.instancePath,(0,ce._)`""`),t.var(be.default.parentData,(0,ce._)`undefined`),t.var(be.default.parentDataProperty,(0,ce._)`undefined`),t.var(be.default.rootData,be.default.data),e.dynamicRef&&t.var(be.default.dynamicAnchors,(0,ce._)`{}`)})}function i5(t){let{schema:e,opts:r,gen:i}=t;nL(t,()=>{r.$comment&&e.$comment&&cL(t),l5(t),i.let(be.default.vErrors,null),i.let(be.default.errors,0),r.unevaluated&&o5(t),aL(t),f5(t)})}function o5(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,ce._)`${r}.evaluated`),e.if((0,ce._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,ce._)`${t.evaluated}.props`,(0,ce._)`undefined`)),e.if((0,ce._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,ce._)`${t.evaluated}.items`,(0,ce._)`undefined`))}function Q1(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,ce._)`/*# sourceURL=${r} */`:ce.nil}function s5(t,e){if(oL(t)&&(sL(t),iL(t))){a5(t,e);return}(0,rL.boolOrEmptySchema)(t,e)}function iL({schema:t,self:e}){if(typeof t=="boolean")return!t;for(let r in t)if(e.RULES.all[r])return!0;return!1}function oL(t){return typeof t.schema!="boolean"}function a5(t,e){let{schema:r,gen:i,opts:n}=t;n.$comment&&r.$comment&&cL(t),u5(t),d5(t);let o=i.const("_errs",be.default.errors);aL(t,o),i.var(e,(0,ce._)`${o} === ${be.default.errors}`)}function sL(t){(0,Ci.checkUnknownRules)(t),c5(t)}function aL(t,e){if(t.opts.jtd)return eL(t,[],!1,e);let r=(0,Y1.getSchemaTypes)(t.schema),i=(0,Y1.coerceAndCheckDataType)(t,r);eL(t,r,!i,e)}function c5(t){let{schema:e,errSchemaPath:r,opts:i,self:n}=t;e.$ref&&i.ignoreKeywordsWithRef&&(0,Ci.schemaHasRulesButRef)(e,n.RULES)&&n.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function l5(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Ci.checkStrictMode)(t,"default is ignored in the schema root")}function u5(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,e5.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function d5(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function cL({gen:t,schemaEnv:e,schema:r,errSchemaPath:i,opts:n}){let o=r.$comment;if(n.$comment===!0)t.code((0,ce._)`${be.default.self}.logger.log(${o})`);else if(typeof n.$comment=="function"){let s=(0,ce.str)`${i}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,ce._)`${be.default.self}.opts.$comment(${o}, ${s}, ${a}.schema)`)}}function f5(t){let{gen:e,schemaEnv:r,validateName:i,ValidationError:n,opts:o}=t;r.$async?e.if((0,ce._)`${be.default.errors} === 0`,()=>e.return(be.default.data),()=>e.throw((0,ce._)`new ${n}(${be.default.vErrors})`)):(e.assign((0,ce._)`${i}.errors`,be.default.vErrors),o.unevaluated&&p5(t),e.return((0,ce._)`${be.default.errors} === 0`))}function p5({gen:t,evaluated:e,props:r,items:i}){r instanceof ce.Name&&t.assign((0,ce._)`${e}.props`,r),i instanceof ce.Name&&t.assign((0,ce._)`${e}.items`,i)}function eL(t,e,r,i){let{gen:n,schema:o,data:s,allErrors:a,opts:c,self:l}=t,{RULES:u}=l;if(o.$ref&&(c.ignoreKeywordsWithRef||!(0,Ci.schemaHasRulesButRef)(o,u))){n.block(()=>uL(t,"$ref",u.all.$ref.definition));return}c.jtd||h5(t,e),n.block(()=>{for(let p of u.rules)d(p);d(u.post)});function d(p){(0,wx.shouldUseGroup)(o,p)&&(p.type?(n.if((0,gy.checkDataType)(p.type,s,c.strictNumbers)),tL(t,p),e.length===1&&e[0]===p.type&&r&&(n.else(),(0,gy.reportTypeError)(t)),n.endIf()):tL(t,p),a||n.if((0,ce._)`${be.default.errors} === ${i||0}`))}}function tL(t,e){let{gen:r,schema:i,opts:{useDefaults:n}}=t;n&&(0,Q3.assignDefaults)(t,e.type),r.block(()=>{for(let o of e.rules)(0,wx.shouldUseRule)(i,o)&&uL(t,o.keyword,o.definition,e.type)})}function h5(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(m5(t,e),t.opts.allowUnionTypes||g5(t,e),y5(t,t.dataTypes))}function m5(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{lL(t.dataTypes,r)||$x(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),_5(t,e)}}function g5(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&$x(t,"use allowUnionTypes to allow union type keyword")}function y5(t,e){let r=t.self.RULES.all;for(let i in r){let n=r[i];if(typeof n=="object"&&(0,wx.shouldUseRule)(t.schema,n)){let{type:o}=n.definition;o.length&&!o.some(s=>v5(e,s))&&$x(t,`missing type "${o.join(",")}" for keyword "${i}"`)}}}function v5(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function lL(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function _5(t,e){let r=[];for(let i of t.dataTypes)lL(e,i)?r.push(i):e.includes("integer")&&i==="number"&&r.push("integer");t.dataTypes=r}function $x(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,Ci.checkStrictMode)(t,e,t.opts.strictTypes)}var yy=class{constructor(e,r,i){if((0,Rd.validateKeywordUsage)(e,r,i),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=i,this.data=e.data,this.schema=e.schema[i],this.$data=r.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Ci.schemaRefOrVal)(e,this.schema,i,this.$data),this.schemaType=r.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=r,this.$data)this.schemaCode=e.gen.const("vSchema",dL(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,Rd.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${i} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=e.gen.const("_errs",be.default.errors))}result(e,r,i){this.failResult((0,ce.not)(e),r,i)}failResult(e,r,i){this.gen.if(e),i?i():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,r){this.failResult((0,ce.not)(e),void 0,r)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:r}=this;this.fail((0,ce._)`${r} !== undefined && (${(0,ce.or)(this.invalid$data(),e)})`)}error(e,r,i){if(r){this.setParams(r),this._error(e,i),this.setParams({});return}this._error(e,i)}_error(e,r){(e?Ad.reportExtraError:Ad.reportError)(this,this.def.error,r)}$dataError(){(0,Ad.reportError)(this,this.def.$dataError||Ad.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Ad.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,r){r?Object.assign(this.params,e):this.params=e}block$data(e,r,i=ce.nil){this.gen.block(()=>{this.check$data(e,i),r()})}check$data(e=ce.nil,r=ce.nil){if(!this.$data)return;let{gen:i,schemaCode:n,schemaType:o,def:s}=this;i.if((0,ce.or)((0,ce._)`${n} === undefined`,r)),e!==ce.nil&&i.assign(e,!0),(o.length||s.validateSchema)&&(i.elseIf(this.invalid$data()),this.$dataError(),e!==ce.nil&&i.assign(e,!1)),i.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:i,def:n,it:o}=this;return(0,ce.or)(s(),a());function s(){if(i.length){if(!(r instanceof ce.Name))throw new Error("ajv implementation error");let c=Array.isArray(i)?i:[i];return(0,ce._)`${(0,gy.checkDataTypes)(c,r,o.opts.strictNumbers,gy.DataType.Wrong)}`}return ce.nil}function a(){if(n.validateSchema){let c=e.scopeValue("validate$data",{ref:n.validateSchema});return(0,ce._)`!${c}(${r})`}return ce.nil}}subschema(e,r){let i=(0,bx.getSubschema)(this.it,e);(0,bx.extendSubschemaData)(i,this.it,e),(0,bx.extendSubschemaMode)(i,e);let n={...this.it,...i,items:void 0,props:void 0};return s5(n,r),n}mergeEvaluated(e,r){let{it:i,gen:n}=this;i.opts.unevaluated&&(i.props!==!0&&e.props!==void 0&&(i.props=Ci.mergeEvaluated.props(n,e.props,i.props,r)),i.items!==!0&&e.items!==void 0&&(i.items=Ci.mergeEvaluated.items(n,e.items,i.items,r)))}mergeValidEvaluated(e,r){let{it:i,gen:n}=this;if(i.opts.unevaluated&&(i.props!==!0||i.items!==!0))return n.if(r,()=>this.mergeEvaluated(e,ce.Name)),!0}};_o.KeywordCxt=yy;function uL(t,e,r,i){let n=new yy(t,r,e);"code"in r?r.code(n,i):n.$data&&r.validate?(0,Rd.funcKeywordCode)(n,r):"macro"in r?(0,Rd.macroKeywordCode)(n,r):(r.compile||r.validate)&&(0,Rd.funcKeywordCode)(n,r)}var b5=/^\/(?:[^~]|~0|~1)*$/,w5=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function dL(t,{dataLevel:e,dataNames:r,dataPathArr:i}){let n,o;if(t==="")return be.default.rootData;if(t[0]==="/"){if(!b5.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);n=t,o=be.default.rootData}else{let l=w5.exec(t);if(!l)throw new Error(`Invalid JSON-pointer: ${t}`);let u=+l[1];if(n=l[2],n==="#"){if(u>=e)throw new Error(c("property/index",u));return i[e-u]}if(u>e)throw new Error(c("data",u));if(o=r[e-u],!n)return o}let s=o,a=n.split("/");for(let l of a)l&&(o=(0,ce._)`${o}${(0,ce.getProperty)((0,Ci.unescapeJsonPointer)(l))}`,s=(0,ce._)`${s} && ${o}`);return s;function c(l,u){return`Cannot access ${l} ${u} levels up, current level is ${e}`}}_o.getData=dL});var vy=C(Sx=>{"use strict";Object.defineProperty(Sx,"__esModule",{value:!0});var kx=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};Sx.default=kx});var zd=C(Ex=>{"use strict";Object.defineProperty(Ex,"__esModule",{value:!0});var xx=Pd(),Ix=class extends Error{constructor(e,r,i,n){super(n||`can't resolve reference ${i} from id ${r}`),this.missingRef=(0,xx.resolveUrl)(e,r,i),this.missingSchema=(0,xx.normalizeId)((0,xx.getFullPath)(e,this.missingRef))}};Ex.default=Ix});var by=C(hn=>{"use strict";Object.defineProperty(hn,"__esModule",{value:!0});hn.resolveSchema=hn.getCompilingSchema=hn.resolveRef=hn.compileSchema=hn.SchemaEnv=void 0;var zn=Te(),$5=vy(),Es=zi(),Cn=Pd(),fL=qe(),k5=jd(),xc=class{constructor(e){var r;this.refs={},this.dynamicAnchors={};let i;typeof e.schema=="object"&&(i=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(r=e.baseId)!==null&&r!==void 0?r:(0,Cn.normalizeId)(i?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=i?.$async,this.refs={}}};hn.SchemaEnv=xc;function Ox(t){let e=pL.call(this,t);if(e)return e;let r=(0,Cn.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:i,lines:n}=this.opts.code,{ownProperties:o}=this.opts,s=new zn.CodeGen(this.scope,{es5:i,lines:n,ownProperties:o}),a;t.$async&&(a=s.scopeValue("Error",{ref:$5.default,code:(0,zn._)`require("ajv/dist/runtime/validation_error").default`}));let c=s.scopeName("validate");t.validateName=c;let l={gen:s,allErrors:this.opts.allErrors,data:Es.default.data,parentData:Es.default.parentData,parentDataProperty:Es.default.parentDataProperty,dataNames:[Es.default.data],dataPathArr:[zn.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:s.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,zn.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:zn.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,zn._)`""`,opts:this.opts,self:this},u;try{this._compilations.add(t),(0,k5.validateFunctionCode)(l),s.optimize(this.opts.code.optimize);let d=s.toString();u=`${s.scopeRefs(Es.default.scope)}return ${d}`,this.opts.code.process&&(u=this.opts.code.process(u,t));let f=new Function(`${Es.default.self}`,`${Es.default.scope}`,u)(this,this.scope.get());if(this.scope.value(c,{ref:f}),f.errors=null,f.schema=t.schema,f.schemaEnv=t,t.$async&&(f.$async=!0),this.opts.code.source===!0&&(f.source={validateName:c,validateCode:d,scopeValues:s._values}),this.opts.unevaluated){let{props:h,items:m}=l;f.evaluated={props:h instanceof zn.Name?void 0:h,items:m instanceof zn.Name?void 0:m,dynamicProps:h instanceof zn.Name,dynamicItems:m instanceof zn.Name},f.source&&(f.source.evaluated=(0,zn.stringify)(f.evaluated))}return t.validate=f,t}catch(d){throw delete t.validate,delete t.validateName,u&&this.logger.error("Error compiling schema, function code:",u),d}finally{this._compilations.delete(t)}}hn.compileSchema=Ox;function S5(t,e,r){var i;r=(0,Cn.resolveUrl)(this.opts.uriResolver,e,r);let n=t.refs[r];if(n)return n;let o=E5.call(this,t,r);if(o===void 0){let s=(i=t.localRefs)===null||i===void 0?void 0:i[r],{schemaId:a}=this.opts;s&&(o=new xc({schema:s,schemaId:a,root:t,baseId:e}))}if(o!==void 0)return t.refs[r]=x5.call(this,o)}hn.resolveRef=S5;function x5(t){return(0,Cn.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:Ox.call(this,t)}function pL(t){for(let e of this._compilations)if(I5(e,t))return e}hn.getCompilingSchema=pL;function I5(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function E5(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||_y.call(this,t,e)}function _y(t,e){let r=this.opts.uriResolver.parse(e),i=(0,Cn._getFullPath)(this.opts.uriResolver,r),n=(0,Cn.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&i===n)return Tx.call(this,r,t);let o=(0,Cn.normalizeId)(i),s=this.refs[o]||this.schemas[o];if(typeof s=="string"){let a=_y.call(this,t,s);return typeof a?.schema!="object"?void 0:Tx.call(this,r,a)}if(typeof s?.schema=="object"){if(s.validate||Ox.call(this,s),o===(0,Cn.normalizeId)(e)){let{schema:a}=s,{schemaId:c}=this.opts,l=a[c];return l&&(n=(0,Cn.resolveUrl)(this.opts.uriResolver,n,l)),new xc({schema:a,schemaId:c,root:t,baseId:n})}return Tx.call(this,r,s)}}hn.resolveSchema=_y;var T5=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Tx(t,{baseId:e,schema:r,root:i}){var n;if(((n=t.fragment)===null||n===void 0?void 0:n[0])!=="/")return;for(let a of t.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,fL.unescapeFragment)(a)];if(c===void 0)return;r=c;let l=typeof r=="object"&&r[this.opts.schemaId];!T5.has(a)&&l&&(e=(0,Cn.resolveUrl)(this.opts.uriResolver,e,l))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,fL.schemaHasRulesButRef)(r,this.RULES)){let a=(0,Cn.resolveUrl)(this.opts.uriResolver,e,r.$ref);o=_y.call(this,i,a)}let{schemaId:s}=this.opts;if(o=o||new xc({schema:r,schemaId:s,root:i,baseId:e}),o.schema!==o.root.schema)return o}});var hL=C((Ffe,O5)=>{O5.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var Cx=C((Zfe,wL)=>{"use strict";var P5=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),Ax=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),A5=RegExp.prototype.test.bind(/^\d*$/u),Ts=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),Rx=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),gL=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u),jx=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u),R5=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u),Lr=new Array(256);{let t="0123456789ABCDEF";for(let e=0;e<256;e++)Lr[e]="%"+t[e>>4]+t[e&15]}function dr(t){return t<2048?Lr[192|t>>6]+Lr[128|t&63]:t<65536?Lr[224|t>>12]+Lr[128|t>>6&63]+Lr[128|t&63]:Lr[240|t>>18]+Lr[128|t>>12&63]+Lr[128|t>>6&63]+Lr[128|t&63]}function j5(t){let e="",r=0,i=0;for(i=0;i<t.length;i++)if(r=t[i].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[i];break}for(i+=1;i<t.length;i++){if(r=t[i].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[i]}return e}var z5=RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/),C5=RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/),N5=RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/),D5=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function L5(t){if(t.length===0)return!1;for(let e=0;e<t.length;e++)if(!N5(t[e])){if(t[e]==="%"&&e+2<t.length&&Ts(t.slice(e+1,e+3))){e+=2;continue}return!1}return!0}function mL(t){let e=-1,r=0,i=-1,n=0;for(let a=0;a<t.length;a++)t[a]==="0"?(i===-1&&(i=a),n++,n>r&&(r=n,e=i)):(i=-1,n=0);if(r<2)return t.join(":");let o=t.slice(0,e).join(":"),s=t.slice(e+r).join(":");return o+"::"+s}function U5(t){let e=t.indexOf("::");if(e!==-1&&t.indexOf("::",e+1)!==-1)return;let r=e===-1?t.split(":"):t.slice(0,e).split(":"),i=e===-1?[]:t.slice(e+2).split(":");e!==-1&&(r.length===1&&r[0]===""&&(r.length=0),i.length===1&&i[0]===""&&(i.length=0));let n=r.concat(i),o=0;for(let a=0;a<n.length;a++){let c=n[a];if(c==="")return;if(c.indexOf(".")!==-1){if(a!==n.length-1||e!==-1&&i.length===0||!Ax(c))return;o+=2;continue}if(!z5(c))return;n[a]=parseInt(c,16).toString(16),o++}if(e===-1)return o!==8?void 0:mL(n);if(o>=8)return;let s=n.slice(0,r.length);for(let a=o;a<8;a++)s.push("0");for(let a=r.length;a<n.length;a++)s.push(n[a]);return mL(s)}function Px(t){let e=t[0]==="["&&t[t.length-1]==="]";if((t[0]==="["||t[t.length-1]==="]")&&!e)return{host:t,isIPV6:!1,error:!0};let i=e?t.slice(1,-1):t;if(e&&C5(i))return i=i.toLowerCase(),{host:`[${i}]`,escapedHost:i,isIPV6:!1,isIPVFuture:!0};if(M5(i,":")<2)return{host:t,isIPV6:!1,error:e};let n="",o=i.indexOf("%");if(o!==-1){let a=i.slice(o,o+3).toLowerCase()==="%25"?3:1;if(n=i.slice(o+a),!L5(n))return{host:t,isIPV6:!1,error:!0};i=i.slice(0,o)}let s=U5(i);return s===void 0?{host:t,isIPV6:!1,error:!0}:{host:s+(n?"%"+n:""),escapedHost:s+(n?"%25"+n:""),isIPV6:!0}}function M5(t,e){let r=0;for(let i=0;i<t.length;i++)t[i]===e&&r++;return r}function F5(t){let e=t,r=[],i=-1,n=0;for(;n=e.length;){if(n===1){if(e===".")break;if(e==="/"){r.push("/");break}else{r.push(e);break}}else if(n===2){if(e[0]==="."){if(e[1]===".")break;if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&(e[1]==="."||e[1]==="/")){r.push("/");break}}else if(n===3&&e==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(e[0]==="."){if(e[1]==="."){if(e[2]==="/"){e=e.slice(3);continue}}else if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&e[1]==="."){if(e[2]==="/"){e=e.slice(2);continue}else if(e[2]==="."&&e[3]==="/"){e=e.slice(3),r.length!==0&&r.pop();continue}}if((i=e.indexOf("/",1))===-1){r.push(e);break}else r.push(e.slice(0,i)),e=e.slice(i)}return r.join("")}var Z5={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},q5=/[@/?#:]/g,V5=/[@/?#]/g;function yL(t,e){let r=e?V5:q5;return r.lastIndex=0,t.replace(r,i=>Z5[i])}function vL(t,e=!1){if(t.indexOf("%")===-1)return t;let r="";for(let i=0;i<t.length;i++){if(t[i]==="%"&&i+2<t.length){let n=t.slice(i+1,i+3);if(Ts(n)){let o=n.toUpperCase(),s=String.fromCharCode(parseInt(o,16));e&&Rx(s)?r+=s:r+="%"+o,i+=2;continue}}r+=t[i]}return r}function B5(t){let e="";for(let r=0;r<t.length;r++){let i=t[r];if(i==="%"&&r+2<t.length){let n=t.slice(r+1,r+3);if(Ts(n)){let o=n.toUpperCase(),s=String.fromCharCode(parseInt(o,16));s!=="."&&Rx(s)?e+=s:e+="%"+o,r+=2;continue}}if(gL(i))e+=i;else{let n=t.charCodeAt(r);if(n<128)e+=bL(n)?i:Lr[n];else if(n<55296||n>57343)e+=dr(n);else if(n<=56319&&r+1<t.length){let o=t.charCodeAt(r+1);o>=56320&&o<=57343?(e+=dr(65536+(n-55296<<10)+(o-56320)),r++):e+=dr(65533)}else e+=dr(65533)}}return e}function H5(t,e=!1){let r="",i=e&&t[0]!=="/";for(let n=0;n<t.length;n++){let o=t[n];if(o==="%"&&n+2<t.length){let s=t.slice(n+1,n+3);if(Ts(s)){r+="%"+s.toUpperCase(),n+=2;continue}}if(o==="/"&&(i=!1),gL(o)&&(o!==":"||!i))r+=o;else{let s=t.charCodeAt(n);if(s<128)r+=Lr[s];else if(s<55296||s>57343)r+=dr(s);else if(s<=56319&&n+1<t.length){let a=t.charCodeAt(n+1);a>=56320&&a<=57343?(r+=dr(65536+(s-55296<<10)+(a-56320)),n++):r+=dr(65533)}else r+=dr(65533)}}return r}function zx(t,e){let r="";for(let i=0;i<t.length;i++){let n=t[i];if(n==="%"&&i+2<t.length){let o=t.slice(i+1,i+3);if(Ts(o)){r+="%"+o.toUpperCase(),i+=2;continue}}if(e(n))r+=n;else{let o=t.charCodeAt(i);if(o<128)r+=Lr[o];else if(o<55296||o>57343)r+=dr(o);else if(o<=56319&&i+1<t.length){let s=t.charCodeAt(i+1);s>=56320&&s<=57343?(r+=dr(65536+(o-55296<<10)+(s-56320)),i++):r+=dr(65533)}else r+=dr(65533)}}return r}function _L(t){return zx(t,R5)}function W5(t){return zx(t,jx)}function K5(t){return zx(t,jx)}function bL(t){return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||t===42||t===43||t===45||t===46||t===47||t===64||t===95}function G5(t){let e="";for(let r=0;r<t.length;r++){let i=t[r];if(i==="%"&&r+2<t.length){let n=t.slice(r+1,r+3);if(Ts(n)){let o=n.toUpperCase(),s=String.fromCharCode(parseInt(o,16));Rx(s)?e+=s:e+="%"+o,r+=2;continue}}if(jx(i))e+=i;else{let n=t.charCodeAt(r);if(n<128)e+=bL(n)?i:Lr[n];else if(n<55296||n>57343)e+=dr(n);else if(n<=56319&&r+1<t.length){let o=t.charCodeAt(r+1);o>=56320&&o<=57343?(e+=dr(65536+(n-55296<<10)+(o-56320)),r++):e+=dr(65533)}else e+=dr(65533)}}return e}function J5(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let i=t.slice(r+1,r+3);if(Ts(i)){e+="%"+i.toUpperCase(),r+=2;continue}}e+=escape(t[r])}return e}function X5(t){let e=[];if(t.userinfo!==void 0&&(e.push(_L(t.userinfo)),e.push("@")),t.host!==void 0){let r=t.host;if(!Ax(r)){let i=Px(r);i.isIPV6!==!0&&i.isIPVFuture!==!0&&(r=vL(r,!0),i=Px(r)),i.isIPV6===!0||i.isIPVFuture===!0?r=`[${i.escapedHost}]`:r=yL(r,!1)}e.push(r)}if(typeof t.port=="number"||typeof t.port=="string"){let r=String(t.port);if(!A5(r))throw new TypeError("URI port is malformed.");e.push(":"),e.push(r)}return e.length?e.join(""):void 0}wL.exports={nonSimpleDomain:D5,recomposeAuthority:X5,reescapeHostDelimiters:yL,normalizePercentEncoding:vL,normalizePathEncoding:B5,serializePathEncoding:H5,normalizeQueryFragmentEncoding:G5,encodeUserinfo:_L,encodeQuery:W5,encodeFragment:K5,escapePreservingEscapes:J5,removeDotSegments:F5,isIPv4:Ax,isUUID:P5,normalizeIPv6:Px,stringArrayToHexStripped:j5}});var IL=C((qfe,xL)=>{"use strict";var{isUUID:Y5}=Cx(),Q5=/^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu,e8=["http","https","ws","wss","urn","urn:uuid"];function t8(t){return e8.indexOf(t)!==-1}function Nx(t){return t.secure===!0?!0:t.secure===!1?!1:t.scheme?t.scheme.length===3&&(t.scheme[0]==="w"||t.scheme[0]==="W")&&(t.scheme[1]==="s"||t.scheme[1]==="S")&&(t.scheme[2]==="s"||t.scheme[2]==="S"):!1}function $L(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function kL(t){let e=String(t.scheme).toLowerCase()==="https";return(t.port===(e?443:80)||t.port==="")&&(t.port=void 0),t.path||(t.path="/"),t}function r8(t){return t.secure=Nx(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function n8(t){if((t.port===(Nx(t)?443:80)||t.port==="")&&(t.port=void 0),typeof t.secure=="boolean"&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){let e=t.resourceName.indexOf("?"),r=e===-1?t.resourceName:t.resourceName.slice(0,e);t.path=r&&r!=="/"?r:void 0,t.query=e===-1?void 0:t.resourceName.slice(e+1),t.resourceName=void 0}return t.fragment=void 0,t}function i8(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(Q5);if(r&&r[0]===t.path){let i=e.scheme||t.scheme||"urn";t.nid=r[1].toLowerCase(),t.nss=r[2];let n=`${i}:${e.nid||t.nid}`,o=Dx(n);t.path=void 0,o&&(t=o.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function o8(t,e){if(t.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=e.scheme||t.scheme||"urn",i=t.nid.toLowerCase(),n=`${r}:${e.nid||i}`,o=Dx(n);o&&(t=o.serialize(t,e));let s=t,a=t.nss;return s.path=`${i||e.nid}:${a}`,e.skipEscape=!0,s}function s8(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!Y5(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function a8(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var SL={scheme:"http",domainHost:!0,parse:$L,serialize:kL},c8={scheme:"https",domainHost:SL.domainHost,parse:$L,serialize:kL},wy={scheme:"ws",domainHost:!0,parse:r8,serialize:n8},l8={scheme:"wss",domainHost:wy.domainHost,parse:wy.parse,serialize:wy.serialize},u8={scheme:"urn",parse:i8,serialize:o8,skipNormalize:!0},d8={scheme:"urn:uuid",parse:s8,serialize:a8,skipNormalize:!0},$y={http:SL,https:c8,ws:wy,wss:l8,urn:u8,"urn:uuid":d8};Object.setPrototypeOf($y,null);function Dx(t){return t&&($y[t]||$y[t.toLowerCase()])||void 0}xL.exports={wsIsSecure:Nx,SCHEMES:$y,isValidSchemeName:t8,getSchemeHandler:Dx}});var UL=C((Vfe,xy)=>{"use strict";var{normalizeIPv6:AL,removeDotSegments:Nd,recomposeAuthority:f8,normalizePercentEncoding:Lx,normalizePathEncoding:p8,serializePathEncoding:EL,normalizeQueryFragmentEncoding:TL,encodeQuery:h8,encodeFragment:m8,reescapeHostDelimiters:g8,isIPv4:RL,nonSimpleDomain:y8}=Cx(),{SCHEMES:jL,getSchemeHandler:Ux}=IL(),zL=/^[A-Za-z][A-Za-z0-9+.-]*$/u,CL="URI scheme is malformed.";function OL(t){let e=unescape(String(t));if(!zL.test(e))throw new TypeError(CL);return e}function v8(t,e){return typeof t=="string"?t=I8(t,e):typeof t=="object"&&(t=Sy(Os(t,e),e)),t}function _8(t,e,r){let i=r?Object.assign({scheme:"null"},r):{scheme:"null"},{parsed:n,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:a,malformedHost:c,malformedScheme:l}=ky(t,i),{parsed:u,malformedAuthorityOrPort:d,malformedPercentEncoding:p,malformedSchemeSpecific:f,malformedHost:h,malformedScheme:m}=ky(e,i);if(o||d||s||p||a||f||c||h||l||m)throw new Error(n.error||u.error||"URI is malformed.");let g=NL(n,u,i,!0),y=Ux(r&&r.scheme||g.scheme),v=g.host,b=v!==void 0&&v!==""&&(RL(v)||AL(v).isIPV6);DL(g,r||{},y,b);let x=v&&v.indexOf("%")!==-1&&!new RegExp("\\P{ASCII}","u").test(v);if(g.error&&!x)throw new Error(g.error);return i.skipEscape=!0,Os(g,i)}function NL(t,e,r,i){let n={};return i||(t=Sy(Os(t,r),r),e=Sy(Os(e,r),r)),r=r||{},!r.tolerant&&e.scheme?(n.scheme=e.scheme,n.userinfo=e.userinfo,n.host=e.host,n.port=e.port,n.path=Nd(e.path||""),n.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(n.userinfo=e.userinfo,n.host=e.host,n.port=e.port,n.path=Nd(e.path||""),n.query=e.query):(e.path?(e.path[0]==="/"?n.path=Nd(e.path):((t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)&&!t.path?n.path="/"+e.path:t.path?n.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:n.path=e.path,n.path=Nd(n.path)),n.query=e.query):(n.path=t.path,e.query!==void 0?n.query=e.query:n.query=t.query),n.userinfo=t.userinfo,n.host=t.host,n.port=t.port),n.scheme=t.scheme),n.fragment=e.fragment,n}function b8(t,e,r){let i=PL(t,r),n=PL(e,r);return i!==void 0&&n!==void 0&&i===n}function Os(t,e){let r={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""},i=Object.assign({},e),n=[];r.scheme&&(r.scheme=OL(r.scheme));let o=Ux(i.scheme||r.scheme);o&&o.serialize&&o.serialize(r,i);let s=r.userinfo!==void 0||r.host!==void 0||r.port!==void 0,a=!i.skipEscape&&r.scheme===void 0&&!s;r.path!==void 0&&(i.skipEscape?r.path=Lx(r.path):r.path=EL(r.path,a)),i.reference!=="suffix"&&r.scheme&&(r.scheme=OL(r.scheme),n.push(r.scheme,":"));let c=f8(r);if(c!==void 0&&(i.reference!=="suffix"&&n.push("//"),n.push(c),r.path&&r.path[0]!=="/"&&n.push("/")),r.path!==void 0){let l=r.path;!i.absolutePath&&(!o||!o.absolutePath)&&(l=Nd(l)),a&&(l=EL(l,!0)),c===void 0&&l[0]==="/"&&l[1]==="/"&&(l="/%2F"+l.slice(2)),n.push(l)}return r.query!==void 0&&n.push("?",h8(r.query)),r.fragment!==void 0&&n.push("#",m8(r.fragment)),n.join("")}var w8=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,$8=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,k8=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function S8(t,e){if(e[2]!==void 0&&t.path&&t.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof t.port=="number"&&(t.port<0||t.port>65535))return"URI port is malformed."}function Cd(t){if(t===void 0)return!1;let e=t.indexOf("%");for(;e!==-1;){if(e+2>=t.length||!/^[\da-f]{2}$/iu.test(t.slice(e+1,e+3)))return!0;e=t.indexOf("%",e+3)}return!1}function Mx(t){return t[0]==="["&&t[t.length-1]==="]"}function x8(t){let e=t[4];return Cd(t[3])||e!==void 0&&!Mx(e)&&Cd(e)||Cd(t[6])||Cd(t[7])||Cd(t[8])}function DL(t,e,r,i){if(!e.unicodeSupport&&(!r||!r.unicodeSupport)&&t.host&&!Mx(t.host)&&(e.domainHost||r&&r.domainHost)&&i===!1&&y8(t.host))try{t.host=new URL("http://"+t.host).hostname}catch(n){return t.error=t.error||"Host's domain name can not be converted to ASCII: "+n,!0}return!1}function ky(t,e){let r=Object.assign({},e),i={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},n=!1,o=!1,s=!1,a=!1,c=!1,l=!1,u=!1;r.reference==="suffix"&&(r.scheme?t=r.scheme+":"+t:t="//"+t);let d=t.match($8);d!==null&&d[1].indexOf("\\")!==-1&&(i.error="URI authority must not contain a literal backslash.",n=!0);let p=t.match(k8);if(p!==null){let h=p[1],m=h.replace(/[\t\n\r]/g,"");m.length>=2&&(m.slice(0,2)!=="//"?(i.error=i.error||"URI authority must not contain a literal backslash.",n=!0):h.length!==m.length&&(i.error=i.error||"URI authority introducer must not contain whitespace.",n=!0))}let f=t.match(w8);if(f){if(i.scheme=f[1],i.userinfo=f[3],i.host=f[4],i.port=parseInt(f[5],10),i.path=f[6]||"",i.query=f[7],i.fragment=f[8],i.scheme!==void 0){let g=unescape(i.scheme);zL.test(g)?i.scheme=g.toLowerCase():(i.error=i.error||CL,l=!0)}o=x8(f),o&&(i.error=i.error||"URI contains malformed percent-encoding."),isNaN(i.port)&&(i.port=f[5]);let h=S8(i,f);if(h!==void 0&&(i.error=i.error||h,n=!0),i.host)if(RL(i.host)===!1){let y=Mx(i.host),v=i.host.indexOf("[")!==-1||i.host.indexOf("]")!==-1,b=AL(i.host);u=b.isIPV6||b.isIPVFuture===!0,c=v&&(!y||b.error===!0),i.host=u?b.host:b.host.toLowerCase(),c&&(i.error=i.error||"URI host is malformed.",n=!0)}else u=!0;i.scheme===void 0&&i.userinfo===void 0&&i.host===void 0&&i.port===void 0&&i.query===void 0&&!i.path?i.reference="same-document":i.scheme===void 0?i.reference="relative":i.fragment===void 0?i.reference="absolute":i.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==i.reference&&(i.error=i.error||"URI is not a "+r.reference+" reference.");let m=Ux(r.scheme||i.scheme);if(c||(a=DL(i,r,m,u)),t.indexOf("%")!==-1&&i.host!==void 0&&!c){let g=u?i.host:Lx(i.host,!0);u||(g=Lx(g.toLowerCase())),i.host=g8(g,u)}(!m||m&&!m.skipNormalize)&&(i.path&&(i.path=p8(i.path)),i.query&&(i.query=TL(i.query)),i.fragment&&(i.fragment=TL(i.fragment))),m&&m.parse&&(m.parse(i,r),m===jL.urn&&i.nid===void 0&&(s=!0))}else i.error=i.error||"URI can not be parsed.";return{parsed:i,malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:a,malformedScheme:l}}function Sy(t,e){return ky(t,e).parsed}function I8(t,e){return LL(t,e).normalized}function LL(t,e){let{parsed:r,malformedAuthorityOrPort:i,malformedPercentEncoding:n,malformedSchemeSpecific:o,malformedHost:s,malformedScheme:a}=ky(t,e);return{normalized:i||n||o||s||a?t:Os(r,e),malformedAuthorityOrPort:i,malformedPercentEncoding:n,malformedSchemeSpecific:o,malformedHost:s,malformedScheme:a}}function PL(t,e){if(typeof t!="string"&&typeof t!="object")return;let r;try{r=typeof t=="string"?t:Os(t,e)}catch{return}let{normalized:i,malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:a,malformedScheme:c}=LL(r,e);return n||o||s||a||c?void 0:i}var Fx={SCHEMES:jL,normalize:v8,resolve:_8,resolveComponent:NL,equal:b8,serialize:Os,parse:Sy};xy.exports=Fx;xy.exports.default=Fx;xy.exports.fastUri=Fx});var FL=C(Zx=>{"use strict";Object.defineProperty(Zx,"__esModule",{value:!0});var ML=UL();ML.code='require("ajv/dist/runtime/uri").default';Zx.default=ML});var GL=C(nr=>{"use strict";Object.defineProperty(nr,"__esModule",{value:!0});nr.CodeGen=nr.Name=nr.nil=nr.stringify=nr.str=nr._=nr.KeywordCxt=void 0;var E8=jd();Object.defineProperty(nr,"KeywordCxt",{enumerable:!0,get:function(){return E8.KeywordCxt}});var Ic=Te();Object.defineProperty(nr,"_",{enumerable:!0,get:function(){return Ic._}});Object.defineProperty(nr,"str",{enumerable:!0,get:function(){return Ic.str}});Object.defineProperty(nr,"stringify",{enumerable:!0,get:function(){return Ic.stringify}});Object.defineProperty(nr,"nil",{enumerable:!0,get:function(){return Ic.nil}});Object.defineProperty(nr,"Name",{enumerable:!0,get:function(){return Ic.Name}});Object.defineProperty(nr,"CodeGen",{enumerable:!0,get:function(){return Ic.CodeGen}});var T8=vy(),HL=zd(),O8=ux(),Dd=by(),P8=Te(),Ld=Pd(),Iy=Od(),Vx=qe(),ZL=hL(),A8=FL(),WL=(t,e)=>new RegExp(t,e);WL.code="new RegExp";var R8=["removeAdditional","useDefaults","coerceTypes"],j8=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),z8={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},C8={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},qL=200;function N8(t){var e,r,i,n,o,s,a,c,l,u,d,p,f,h,m,g,y,v,b,x,k,E,O,X,le;let $e=t.strict,q=(e=t.code)===null||e===void 0?void 0:e.optimize,Re=q===!0||q===void 0?1:q||0,de=(i=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&i!==void 0?i:WL,pt=(n=t.uriResolver)!==null&&n!==void 0?n:A8.default;return{strictSchema:(s=(o=t.strictSchema)!==null&&o!==void 0?o:$e)!==null&&s!==void 0?s:!0,strictNumbers:(c=(a=t.strictNumbers)!==null&&a!==void 0?a:$e)!==null&&c!==void 0?c:!0,strictTypes:(u=(l=t.strictTypes)!==null&&l!==void 0?l:$e)!==null&&u!==void 0?u:"log",strictTuples:(p=(d=t.strictTuples)!==null&&d!==void 0?d:$e)!==null&&p!==void 0?p:"log",strictRequired:(h=(f=t.strictRequired)!==null&&f!==void 0?f:$e)!==null&&h!==void 0?h:!1,code:t.code?{...t.code,optimize:Re,regExp:de}:{optimize:Re,regExp:de},loopRequired:(m=t.loopRequired)!==null&&m!==void 0?m:qL,loopEnum:(g=t.loopEnum)!==null&&g!==void 0?g:qL,meta:(y=t.meta)!==null&&y!==void 0?y:!0,messages:(v=t.messages)!==null&&v!==void 0?v:!0,inlineRefs:(b=t.inlineRefs)!==null&&b!==void 0?b:!0,schemaId:(x=t.schemaId)!==null&&x!==void 0?x:"$id",addUsedSchema:(k=t.addUsedSchema)!==null&&k!==void 0?k:!0,validateSchema:(E=t.validateSchema)!==null&&E!==void 0?E:!0,validateFormats:(O=t.validateFormats)!==null&&O!==void 0?O:!0,unicodeRegExp:(X=t.unicodeRegExp)!==null&&X!==void 0?X:!0,int32range:(le=t.int32range)!==null&&le!==void 0?le:!0,uriResolver:pt}}var Ud=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...N8(e)};let{es5:r,lines:i}=this.opts.code;this.scope=new P8.ValueScope({scope:{},prefixes:j8,es5:r,lines:i}),this.logger=Z8(e.logger);let n=e.validateFormats;e.validateFormats=!1,this.RULES=(0,O8.getRules)(),VL.call(this,z8,e,"NOT SUPPORTED"),VL.call(this,C8,e,"DEPRECATED","warn"),this._metaOpts=M8.call(this),e.formats&&L8.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&U8.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),D8.call(this),e.validateFormats=n}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:i}=this.opts,n=ZL;i==="id"&&(n={...ZL},n.id=n.$id,delete n.$id),r&&e&&this.addMetaSchema(n,n[i],!1)}defaultMeta(){let{meta:e,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[r]||e:void 0}validate(e,r){let i;if(typeof e=="string"){if(i=this.getSchema(e),!i)throw new Error(`no schema with key or ref "${e}"`)}else i=this.compile(e);let n=i(r);return"$async"in i||(this.errors=i.errors),n}compile(e,r){let i=this._addSchema(e,r);return i.validate||this._compileSchemaEnv(i)}compileAsync(e,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:i}=this.opts;return n.call(this,e,r);async function n(u,d){await o.call(this,u.$schema);let p=this._addSchema(u,d);return p.validate||s.call(this,p)}async function o(u){u&&!this.getSchema(u)&&await n.call(this,{$ref:u},!0)}async function s(u){try{return this._compileSchemaEnv(u)}catch(d){if(!(d instanceof HL.default))throw d;return a.call(this,d),await c.call(this,d.missingSchema),s.call(this,u)}}function a({missingSchema:u,missingRef:d}){if(this.refs[u])throw new Error(`AnySchema ${u} is loaded but ${d} cannot be resolved`)}async function c(u){let d=await l.call(this,u);this.refs[u]||await o.call(this,d.$schema),this.refs[u]||this.addSchema(d,u,r)}async function l(u){let d=this._loading[u];if(d)return d;try{return await(this._loading[u]=i(u))}finally{delete this._loading[u]}}}addSchema(e,r,i,n=this.opts.validateSchema){if(Array.isArray(e)){for(let s of e)this.addSchema(s,void 0,i,n);return this}let o;if(typeof e=="object"){let{schemaId:s}=this.opts;if(o=e[s],o!==void 0&&typeof o!="string")throw new Error(`schema ${s} must be string`)}return r=(0,Ld.normalizeId)(r||o),this._checkUnique(r),this.schemas[r]=this._addSchema(e,i,r,n,!0),this}addMetaSchema(e,r,i=this.opts.validateSchema){return this.addSchema(e,r,!0,i),this}validateSchema(e,r){if(typeof e=="boolean")return!0;let i;if(i=e.$schema,i!==void 0&&typeof i!="string")throw new Error("$schema must be a string");if(i=i||this.opts.defaultMeta||this.defaultMeta(),!i)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let n=this.validate(i,e);if(!n&&r){let o="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(o);else throw new Error(o)}return n}getSchema(e){let r;for(;typeof(r=BL.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:i}=this.opts,n=new Dd.SchemaEnv({schema:{},schemaId:i});if(r=Dd.resolveSchema.call(this,n,e),!r)return;this.refs[e]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=BL.call(this,e);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{let r=e;this._cache.delete(r);let i=e[this.opts.schemaId];return i&&(i=(0,Ld.normalizeId)(i),delete this.schemas[i],delete this.refs[i]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let r of e)this.addKeyword(r);return this}addKeyword(e,r){let i;if(typeof e=="string")i=e,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=i);else if(typeof e=="object"&&r===void 0){if(r=e,i=r.keyword,Array.isArray(i)&&!i.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(V8.call(this,i,r),!r)return(0,Vx.eachItem)(i,o=>qx.call(this,o)),this;H8.call(this,r);let n={...r,type:(0,Iy.getJSONTypes)(r.type),schemaType:(0,Iy.getJSONTypes)(r.schemaType)};return(0,Vx.eachItem)(i,n.type.length===0?o=>qx.call(this,o,n):o=>n.type.forEach(s=>qx.call(this,o,n,s))),this}getKeyword(e){let r=this.RULES.all[e];return typeof r=="object"?r.definition:!!r}removeKeyword(e){let{RULES:r}=this;delete r.keywords[e],delete r.all[e];for(let i of r.rules){let n=i.rules.findIndex(o=>o.keyword===e);n>=0&&i.rules.splice(n,1)}return this}addFormat(e,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[e]=r,this}errorsText(e=this.errors,{separator:r=", ",dataVar:i="data"}={}){return!e||e.length===0?"No errors":e.map(n=>`${i}${n.instancePath} ${n.message}`).reduce((n,o)=>n+r+o)}$dataMetaSchema(e,r){let i=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let n of r){let o=n.split("/").slice(1),s=e;for(let a of o)s=s[a];for(let a in i){let c=i[a];if(typeof c!="object")continue;let{$data:l}=c.definition,u=s[a];l&&u&&(s[a]=KL(u))}}return e}_removeAllSchemas(e,r){for(let i in e){let n=e[i];(!r||r.test(i))&&(typeof n=="string"?delete e[i]:n&&!n.meta&&(this._cache.delete(n.schema),delete e[i]))}}_addSchema(e,r,i,n=this.opts.validateSchema,o=this.opts.addUsedSchema){let s,{schemaId:a}=this.opts;if(typeof e=="object")s=e[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(e);if(c!==void 0)return c;i=(0,Ld.normalizeId)(s||i);let l=Ld.getSchemaRefs.call(this,e,i);return c=new Dd.SchemaEnv({schema:e,schemaId:a,meta:r,baseId:i,localRefs:l}),this._cache.set(c.schema,c),o&&!i.startsWith("#")&&(i&&this._checkUnique(i),this.refs[i]=c),n&&this.validateSchema(e,!0),c}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):Dd.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let r=this.opts;this.opts=this._metaOpts;try{Dd.compileSchema.call(this,e)}finally{this.opts=r}}};Ud.ValidationError=T8.default;Ud.MissingRefError=HL.default;nr.default=Ud;function VL(t,e,r,i="error"){for(let n in t){let o=n;o in e&&this.logger[i](`${r}: option ${n}. ${t[o]}`)}}function BL(t){return t=(0,Ld.normalizeId)(t),this.schemas[t]||this.refs[t]}function D8(){let t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(let e in t)this.addSchema(t[e],e)}function L8(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function U8(t){if(Array.isArray(t)){this.addVocabulary(t);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in t){let r=t[e];r.keyword||(r.keyword=e),this.addKeyword(r)}}function M8(){let t={...this.opts};for(let e of R8)delete t[e];return t}var F8={log(){},warn(){},error(){}};function Z8(t){if(t===!1)return F8;if(t===void 0)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}var q8=/^[a-z_$][a-z0-9_$:-]*$/i;function V8(t,e){let{RULES:r}=this;if((0,Vx.eachItem)(t,i=>{if(r.keywords[i])throw new Error(`Keyword ${i} is already defined`);if(!q8.test(i))throw new Error(`Keyword ${i} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function qx(t,e,r){var i;let n=e?.post;if(r&&n)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:o}=this,s=n?o.post:o.rules.find(({type:c})=>c===r);if(s||(s={type:r,rules:[]},o.rules.push(s)),o.keywords[t]=!0,!e)return;let a={keyword:t,definition:{...e,type:(0,Iy.getJSONTypes)(e.type),schemaType:(0,Iy.getJSONTypes)(e.schemaType)}};e.before?B8.call(this,s,a,e.before):s.rules.push(a),o.all[t]=a,(i=e.implements)===null||i===void 0||i.forEach(c=>this.addKeyword(c))}function B8(t,e,r){let i=t.rules.findIndex(n=>n.keyword===r);i>=0?t.rules.splice(i,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`))}function H8(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=KL(e)),t.validateSchema=this.compile(e,!0))}var W8={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function KL(t){return{anyOf:[t,W8]}}});var JL=C(Bx=>{"use strict";Object.defineProperty(Bx,"__esModule",{value:!0});var K8={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Bx.default=K8});var eU=C(Ps=>{"use strict";Object.defineProperty(Ps,"__esModule",{value:!0});Ps.callRef=Ps.getValidate=void 0;var G8=zd(),XL=pn(),Ur=Te(),Ec=zi(),YL=by(),Ey=qe(),J8={keyword:"$ref",schemaType:"string",code(t){let{gen:e,schema:r,it:i}=t,{baseId:n,schemaEnv:o,validateName:s,opts:a,self:c}=i,{root:l}=o;if((r==="#"||r==="#/")&&n===l.baseId)return d();let u=YL.resolveRef.call(c,l,n,r);if(u===void 0)throw new G8.default(i.opts.uriResolver,n,r);if(u instanceof YL.SchemaEnv)return p(u);return f(u);function d(){if(o===l)return Ty(t,s,o,o.$async);let h=e.scopeValue("root",{ref:l});return Ty(t,(0,Ur._)`${h}.validate`,l,l.$async)}function p(h){let m=QL(t,h);Ty(t,m,h,h.$async)}function f(h){let m=e.scopeValue("schema",a.code.source===!0?{ref:h,code:(0,Ur.stringify)(h)}:{ref:h}),g=e.name("valid"),y=t.subschema({schema:h,dataTypes:[],schemaPath:Ur.nil,topSchemaRef:m,errSchemaPath:r},g);t.mergeEvaluated(y),t.ok(g)}}};function QL(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,Ur._)`${r.scopeValue("wrapper",{ref:e})}.validate`}Ps.getValidate=QL;function Ty(t,e,r,i){let{gen:n,it:o}=t,{allErrors:s,schemaEnv:a,opts:c}=o,l=c.passContext?Ec.default.this:Ur.nil;i?u():d();function u(){if(!a.$async)throw new Error("async schema referenced by sync schema");let h=n.let("valid");n.try(()=>{n.code((0,Ur._)`await ${(0,XL.callValidateCode)(t,e,l)}`),f(e),s||n.assign(h,!0)},m=>{n.if((0,Ur._)`!(${m} instanceof ${o.ValidationError})`,()=>n.throw(m)),p(m),s||n.assign(h,!1)}),t.ok(h)}function d(){t.result((0,XL.callValidateCode)(t,e,l),()=>f(e),()=>p(e))}function p(h){let m=(0,Ur._)`${h}.errors`;n.assign(Ec.default.vErrors,(0,Ur._)`${Ec.default.vErrors} === null ? ${m} : ${Ec.default.vErrors}.concat(${m})`),n.assign(Ec.default.errors,(0,Ur._)`${Ec.default.vErrors}.length`)}function f(h){var m;if(!o.opts.unevaluated)return;let g=(m=r?.validate)===null||m===void 0?void 0:m.evaluated;if(o.props!==!0)if(g&&!g.dynamicProps)g.props!==void 0&&(o.props=Ey.mergeEvaluated.props(n,g.props,o.props));else{let y=n.var("props",(0,Ur._)`${h}.evaluated.props`);o.props=Ey.mergeEvaluated.props(n,y,o.props,Ur.Name)}if(o.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(o.items=Ey.mergeEvaluated.items(n,g.items,o.items));else{let y=n.var("items",(0,Ur._)`${h}.evaluated.items`);o.items=Ey.mergeEvaluated.items(n,y,o.items,Ur.Name)}}}Ps.callRef=Ty;Ps.default=J8});var tU=C(Hx=>{"use strict";Object.defineProperty(Hx,"__esModule",{value:!0});var X8=JL(),Y8=eU(),Q8=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",X8.default,Y8.default];Hx.default=Q8});var rU=C(Wx=>{"use strict";Object.defineProperty(Wx,"__esModule",{value:!0});var Oy=Te(),bo=Oy.operators,Py={maximum:{okStr:"<=",ok:bo.LTE,fail:bo.GT},minimum:{okStr:">=",ok:bo.GTE,fail:bo.LT},exclusiveMaximum:{okStr:"<",ok:bo.LT,fail:bo.GTE},exclusiveMinimum:{okStr:">",ok:bo.GT,fail:bo.LTE}},eX={message:({keyword:t,schemaCode:e})=>(0,Oy.str)`must be ${Py[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,Oy._)`{comparison: ${Py[t].okStr}, limit: ${e}}`},tX={keyword:Object.keys(Py),type:"number",schemaType:"number",$data:!0,error:eX,code(t){let{keyword:e,data:r,schemaCode:i}=t;t.fail$data((0,Oy._)`${r} ${Py[e].fail} ${i} || isNaN(${r})`)}};Wx.default=tX});var nU=C(Kx=>{"use strict";Object.defineProperty(Kx,"__esModule",{value:!0});var Md=Te(),rX={message:({schemaCode:t})=>(0,Md.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,Md._)`{multipleOf: ${t}}`},nX={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:rX,code(t){let{gen:e,data:r,schemaCode:i,it:n}=t,o=n.opts.multipleOfPrecision,s=e.let("res"),a=o?(0,Md._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${o}`:(0,Md._)`${s} !== parseInt(${s})`;t.fail$data((0,Md._)`(${i} === 0 || (${s} = ${r}/${i}, ${a}))`)}};Kx.default=nX});var oU=C(Gx=>{"use strict";Object.defineProperty(Gx,"__esModule",{value:!0});function iU(t){let e=t.length,r=0,i=0,n;for(;i<e;)r++,n=t.charCodeAt(i++),n>=55296&&n<=56319&&i<e&&(n=t.charCodeAt(i),(n&64512)===56320&&i++);return r}Gx.default=iU;iU.code='require("ajv/dist/runtime/ucs2length").default'});var sU=C(Jx=>{"use strict";Object.defineProperty(Jx,"__esModule",{value:!0});var As=Te(),iX=qe(),oX=oU(),sX={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,As.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,As._)`{limit: ${t}}`},aX={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:sX,code(t){let{keyword:e,data:r,schemaCode:i,it:n}=t,o=e==="maxLength"?As.operators.GT:As.operators.LT,s=n.opts.unicode===!1?(0,As._)`${r}.length`:(0,As._)`${(0,iX.useFunc)(t.gen,oX.default)}(${r})`;t.fail$data((0,As._)`${s} ${o} ${i}`)}};Jx.default=aX});var aU=C(Xx=>{"use strict";Object.defineProperty(Xx,"__esModule",{value:!0});var cX=pn(),lX=qe(),Tc=Te(),uX={message:({schemaCode:t})=>(0,Tc.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,Tc._)`{pattern: ${t}}`},dX={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:uX,code(t){let{gen:e,data:r,$data:i,schema:n,schemaCode:o,it:s}=t,a=s.opts.unicodeRegExp?"u":"";if(i){let{regExp:c}=s.opts.code,l=c.code==="new RegExp"?(0,Tc._)`new RegExp`:(0,lX.useFunc)(e,c),u=e.let("valid");e.try(()=>e.assign(u,(0,Tc._)`${l}(${o}, ${a}).test(${r})`),()=>e.assign(u,!1)),t.fail$data((0,Tc._)`!${u}`)}else{let c=(0,cX.usePattern)(t,n);t.fail$data((0,Tc._)`!${c}.test(${r})`)}}};Xx.default=dX});var cU=C(Yx=>{"use strict";Object.defineProperty(Yx,"__esModule",{value:!0});var Fd=Te(),fX={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,Fd.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,Fd._)`{limit: ${t}}`},pX={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:fX,code(t){let{keyword:e,data:r,schemaCode:i}=t,n=e==="maxProperties"?Fd.operators.GT:Fd.operators.LT;t.fail$data((0,Fd._)`Object.keys(${r}).length ${n} ${i}`)}};Yx.default=pX});var lU=C(Qx=>{"use strict";Object.defineProperty(Qx,"__esModule",{value:!0});var Zd=pn(),qd=Te(),hX=qe(),mX={message:({params:{missingProperty:t}})=>(0,qd.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,qd._)`{missingProperty: ${t}}`},gX={keyword:"required",type:"object",schemaType:"array",$data:!0,error:mX,code(t){let{gen:e,schema:r,schemaCode:i,data:n,$data:o,it:s}=t,{opts:a}=s;if(!o&&r.length===0)return;let c=r.length>=a.loopRequired;if(s.allErrors?l():u(),a.strictRequired){let f=t.parentSchema.properties,{definedProperties:h}=t.it;for(let m of r)if(f?.[m]===void 0&&!h.has(m)){let g=s.schemaEnv.baseId+s.errSchemaPath,y=`required property "${m}" is not defined at "${g}" (strictRequired)`;(0,hX.checkStrictMode)(s,y,s.opts.strictRequired)}}function l(){if(c||o)t.block$data(qd.nil,d);else for(let f of r)(0,Zd.checkReportMissingProp)(t,f)}function u(){let f=e.let("missing");if(c||o){let h=e.let("valid",!0);t.block$data(h,()=>p(f,h)),t.ok(h)}else e.if((0,Zd.checkMissingProp)(t,r,f)),(0,Zd.reportMissingProp)(t,f),e.else()}function d(){e.forOf("prop",i,f=>{t.setParams({missingProperty:f}),e.if((0,Zd.noPropertyInData)(e,n,f,a.ownProperties),()=>t.error())})}function p(f,h){t.setParams({missingProperty:f}),e.forOf(f,i,()=>{e.assign(h,(0,Zd.propertyInData)(e,n,f,a.ownProperties)),e.if((0,qd.not)(h),()=>{t.error(),e.break()})},qd.nil)}}};Qx.default=gX});var uU=C(eI=>{"use strict";Object.defineProperty(eI,"__esModule",{value:!0});var Vd=Te(),yX={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,Vd.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,Vd._)`{limit: ${t}}`},vX={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:yX,code(t){let{keyword:e,data:r,schemaCode:i}=t,n=e==="maxItems"?Vd.operators.GT:Vd.operators.LT;t.fail$data((0,Vd._)`${r}.length ${n} ${i}`)}};eI.default=vX});var Ay=C(tI=>{"use strict";Object.defineProperty(tI,"__esModule",{value:!0});var dU=vx();dU.code='require("ajv/dist/runtime/equal").default';tI.default=dU});var fU=C(nI=>{"use strict";Object.defineProperty(nI,"__esModule",{value:!0});var rI=Od(),ir=Te(),_X=qe(),bX=Ay(),wX={message:({params:{i:t,j:e}})=>(0,ir.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,ir._)`{i: ${t}, j: ${e}}`},$X={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:wX,code(t){let{gen:e,data:r,$data:i,schema:n,parentSchema:o,schemaCode:s,it:a}=t;if(!i&&!n)return;let c=e.let("valid"),l=o.items?(0,rI.getSchemaTypes)(o.items):[];t.block$data(c,u,(0,ir._)`${s} === false`),t.ok(c);function u(){let h=e.let("i",(0,ir._)`${r}.length`),m=e.let("j");t.setParams({i:h,j:m}),e.assign(c,!0),e.if((0,ir._)`${h} > 1`,()=>(d()?p:f)(h,m))}function d(){return l.length>0&&!l.some(h=>h==="object"||h==="array")}function p(h,m){let g=e.name("item"),y=(0,rI.checkDataTypes)(l,g,a.opts.strictNumbers,rI.DataType.Wrong),v=e.const("indices",(0,ir._)`{}`);e.for((0,ir._)`;${h}--;`,()=>{e.let(g,(0,ir._)`${r}[${h}]`),e.if(y,(0,ir._)`continue`),l.length>1&&e.if((0,ir._)`typeof ${g} == "string"`,(0,ir._)`${g} += "_"`),e.if((0,ir._)`typeof ${v}[${g}] == "number"`,()=>{e.assign(m,(0,ir._)`${v}[${g}]`),t.error(),e.assign(c,!1).break()}).code((0,ir._)`${v}[${g}] = ${h}`)})}function f(h,m){let g=(0,_X.useFunc)(e,bX.default),y=e.name("outer");e.label(y).for((0,ir._)`;${h}--;`,()=>e.for((0,ir._)`${m} = ${h}; ${m}--;`,()=>e.if((0,ir._)`${g}(${r}[${h}], ${r}[${m}])`,()=>{t.error(),e.assign(c,!1).break(y)})))}}};nI.default=$X});var pU=C(oI=>{"use strict";Object.defineProperty(oI,"__esModule",{value:!0});var iI=Te(),kX=qe(),SX=Ay(),xX={message:"must be equal to constant",params:({schemaCode:t})=>(0,iI._)`{allowedValue: ${t}}`},IX={keyword:"const",$data:!0,error:xX,code(t){let{gen:e,data:r,$data:i,schemaCode:n,schema:o}=t;i||o&&typeof o=="object"?t.fail$data((0,iI._)`!${(0,kX.useFunc)(e,SX.default)}(${r}, ${n})`):t.fail((0,iI._)`${o} !== ${r}`)}};oI.default=IX});var hU=C(sI=>{"use strict";Object.defineProperty(sI,"__esModule",{value:!0});var Bd=Te(),EX=qe(),TX=Ay(),OX={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,Bd._)`{allowedValues: ${t}}`},PX={keyword:"enum",schemaType:"array",$data:!0,error:OX,code(t){let{gen:e,data:r,$data:i,schema:n,schemaCode:o,it:s}=t;if(!i&&n.length===0)throw new Error("enum must have non-empty array");let a=n.length>=s.opts.loopEnum,c,l=()=>c??(c=(0,EX.useFunc)(e,TX.default)),u;if(a||i)u=e.let("valid"),t.block$data(u,d);else{if(!Array.isArray(n))throw new Error("ajv implementation error");let f=e.const("vSchema",o);u=(0,Bd.or)(...n.map((h,m)=>p(f,m)))}t.pass(u);function d(){e.assign(u,!1),e.forOf("v",o,f=>e.if((0,Bd._)`${l()}(${r}, ${f})`,()=>e.assign(u,!0).break()))}function p(f,h){let m=n[h];return typeof m=="object"&&m!==null?(0,Bd._)`${l()}(${r}, ${f}[${h}])`:(0,Bd._)`${r} === ${m}`}}};sI.default=PX});var mU=C(aI=>{"use strict";Object.defineProperty(aI,"__esModule",{value:!0});var AX=rU(),RX=nU(),jX=sU(),zX=aU(),CX=cU(),NX=lU(),DX=uU(),LX=fU(),UX=pU(),MX=hU(),FX=[AX.default,RX.default,jX.default,zX.default,CX.default,NX.default,DX.default,LX.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},UX.default,MX.default];aI.default=FX});var lI=C(Hd=>{"use strict";Object.defineProperty(Hd,"__esModule",{value:!0});Hd.validateAdditionalItems=void 0;var Rs=Te(),cI=qe(),ZX={message:({params:{len:t}})=>(0,Rs.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Rs._)`{limit: ${t}}`},qX={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:ZX,code(t){let{parentSchema:e,it:r}=t,{items:i}=e;if(!Array.isArray(i)){(0,cI.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}gU(t,i)}};function gU(t,e){let{gen:r,schema:i,data:n,keyword:o,it:s}=t;s.items=!0;let a=r.const("len",(0,Rs._)`${n}.length`);if(i===!1)t.setParams({len:e.length}),t.pass((0,Rs._)`${a} <= ${e.length}`);else if(typeof i=="object"&&!(0,cI.alwaysValidSchema)(s,i)){let l=r.var("valid",(0,Rs._)`${a} <= ${e.length}`);r.if((0,Rs.not)(l),()=>c(l)),t.ok(l)}function c(l){r.forRange("i",e.length,a,u=>{t.subschema({keyword:o,dataProp:u,dataPropType:cI.Type.Num},l),s.allErrors||r.if((0,Rs.not)(l),()=>r.break())})}}Hd.validateAdditionalItems=gU;Hd.default=qX});var uI=C(Wd=>{"use strict";Object.defineProperty(Wd,"__esModule",{value:!0});Wd.validateTuple=void 0;var yU=Te(),Ry=qe(),VX=pn(),BX={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return vU(t,"additionalItems",e);r.items=!0,!(0,Ry.alwaysValidSchema)(r,e)&&t.ok((0,VX.validateArray)(t))}};function vU(t,e,r=t.schema){let{gen:i,parentSchema:n,data:o,keyword:s,it:a}=t;u(n),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=Ry.mergeEvaluated.items(i,r.length,a.items));let c=i.name("valid"),l=i.const("len",(0,yU._)`${o}.length`);r.forEach((d,p)=>{(0,Ry.alwaysValidSchema)(a,d)||(i.if((0,yU._)`${l} > ${p}`,()=>t.subschema({keyword:s,schemaProp:p,dataProp:p},c)),t.ok(c))});function u(d){let{opts:p,errSchemaPath:f}=a,h=r.length,m=h===d.minItems&&(h===d.maxItems||d[e]===!1);if(p.strictTuples&&!m){let g=`"${s}" is ${h}-tuple, but minItems or maxItems/${e} are not specified or different at path "${f}"`;(0,Ry.checkStrictMode)(a,g,p.strictTuples)}}}Wd.validateTuple=vU;Wd.default=BX});var _U=C(dI=>{"use strict";Object.defineProperty(dI,"__esModule",{value:!0});var HX=uI(),WX={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,HX.validateTuple)(t,"items")};dI.default=WX});var wU=C(fI=>{"use strict";Object.defineProperty(fI,"__esModule",{value:!0});var bU=Te(),KX=qe(),GX=pn(),JX=lI(),XX={message:({params:{len:t}})=>(0,bU.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,bU._)`{limit: ${t}}`},YX={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:XX,code(t){let{schema:e,parentSchema:r,it:i}=t,{prefixItems:n}=r;i.items=!0,!(0,KX.alwaysValidSchema)(i,e)&&(n?(0,JX.validateAdditionalItems)(t,n):t.ok((0,GX.validateArray)(t)))}};fI.default=YX});var $U=C(pI=>{"use strict";Object.defineProperty(pI,"__esModule",{value:!0});var mn=Te(),jy=qe(),QX={message:({params:{min:t,max:e}})=>e===void 0?(0,mn.str)`must contain at least ${t} valid item(s)`:(0,mn.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,mn._)`{minContains: ${t}}`:(0,mn._)`{minContains: ${t}, maxContains: ${e}}`},e7={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:QX,code(t){let{gen:e,schema:r,parentSchema:i,data:n,it:o}=t,s,a,{minContains:c,maxContains:l}=i;o.opts.next?(s=c===void 0?1:c,a=l):s=1;let u=e.const("len",(0,mn._)`${n}.length`);if(t.setParams({min:s,max:a}),a===void 0&&s===0){(0,jy.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&s>a){(0,jy.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,jy.alwaysValidSchema)(o,r)){let m=(0,mn._)`${u} >= ${s}`;a!==void 0&&(m=(0,mn._)`${m} && ${u} <= ${a}`),t.pass(m);return}o.items=!0;let d=e.name("valid");a===void 0&&s===1?f(d,()=>e.if(d,()=>e.break())):s===0?(e.let(d,!0),a!==void 0&&e.if((0,mn._)`${n}.length > 0`,p)):(e.let(d,!1),p()),t.result(d,()=>t.reset());function p(){let m=e.name("_valid"),g=e.let("count",0);f(m,()=>e.if(m,()=>h(g)))}function f(m,g){e.forRange("i",0,u,y=>{t.subschema({keyword:"contains",dataProp:y,dataPropType:jy.Type.Num,compositeRule:!0},m),g()})}function h(m){e.code((0,mn._)`${m}++`),a===void 0?e.if((0,mn._)`${m} >= ${s}`,()=>e.assign(d,!0).break()):(e.if((0,mn._)`${m} > ${a}`,()=>e.assign(d,!1).break()),s===1?e.assign(d,!0):e.if((0,mn._)`${m} >= ${s}`,()=>e.assign(d,!0)))}}};pI.default=e7});var xU=C(ii=>{"use strict";Object.defineProperty(ii,"__esModule",{value:!0});ii.validateSchemaDeps=ii.validatePropertyDeps=ii.error=void 0;var hI=Te(),t7=qe(),Kd=pn();ii.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let i=e===1?"property":"properties";return(0,hI.str)`must have ${i} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:i}})=>(0,hI._)`{property: ${t},
128
+ || ${s} === "boolean" || ${n} === null`).assign(a,(0,Ie._)`[${n}]`)}}}function v3({gen:t,parentData:e,parentDataProperty:r},i){t.if((0,Ie._)`${e} !== undefined`,()=>t.assign((0,Ie._)`${e}[${r}]`,i))}function fx(t,e,r,i=$c.Correct){let n=i===$c.Correct?Ie.operators.EQ:Ie.operators.NEQ,o;switch(t){case"null":return(0,Ie._)`${e} ${n} null`;case"array":o=(0,Ie._)`Array.isArray(${e})`;break;case"object":o=(0,Ie._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":o=s((0,Ie._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":o=s();break;default:return(0,Ie._)`typeof ${e} ${n} ${t}`}return i===$c.Correct?o:(0,Ie.not)(o);function s(a=Ie.nil){return(0,Ie.and)((0,Ie._)`typeof ${e} == "number"`,a,r?(0,Ie._)`isFinite(${e})`:Ie.nil)}}ur.checkDataType=fx;function px(t,e,r,i){if(t.length===1)return fx(t[0],e,r,i);let n,o=(0,z1.toHash)(t);if(o.array&&o.object){let s=(0,Ie._)`typeof ${e} != "object"`;n=o.null?s:(0,Ie._)`!${e} || ${s}`,delete o.null,delete o.array,delete o.object}else n=Ie.nil;o.number&&delete o.integer;for(let s in o)n=(0,Ie.and)(n,fx(s,e,r,i));return n}ur.checkDataTypes=px;var _3={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,Ie._)`{type: ${t}}`:(0,Ie._)`{type: ${e}}`};function hx(t){let e=b3(t);(0,p3.reportError)(e,_3)}ur.reportTypeError=hx;function b3(t){let{gen:e,data:r,schema:i}=t,n=(0,z1.schemaRefOrVal)(t,i,"type");return{gen:e,keyword:"type",data:r,schema:i.type,schemaCode:n,schemaValue:n,parentSchema:i,params:{},it:t}}});var L1=C(hy=>{"use strict";Object.defineProperty(hy,"__esModule",{value:!0});hy.assignDefaults=void 0;var kc=Te(),w3=qe();function $3(t,e){let{properties:r,items:i}=t.schema;if(e==="object"&&r)for(let n in r)D1(t,n,r[n].default);else e==="array"&&Array.isArray(i)&&i.forEach((n,o)=>D1(t,o,n.default))}hy.assignDefaults=$3;function D1(t,e,r){let{gen:i,compositeRule:n,data:o,opts:s}=t;if(r===void 0)return;let a=(0,kc._)`${o}${(0,kc.getProperty)(e)}`;if(n){(0,w3.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,kc._)`${a} === undefined`;s.useDefaults==="empty"&&(c=(0,kc._)`${c} || ${a} === null || ${a} === ""`),i.if(c,(0,kc._)`${a} = ${(0,kc.stringify)(r)}`)}});var pn=C(lt=>{"use strict";Object.defineProperty(lt,"__esModule",{value:!0});lt.validateUnion=lt.validateArray=lt.usePattern=lt.callValidateCode=lt.schemaProperties=lt.allSchemaProperties=lt.noPropertyInData=lt.propertyInData=lt.isOwnProperty=lt.hasPropFunc=lt.reportMissingProp=lt.checkMissingProp=lt.checkReportMissingProp=void 0;var vt=Te(),mx=qe(),go=zi(),k3=qe();function S3(t,e){let{gen:r,data:i,it:n}=t;r.if(yx(r,i,e,n.opts.ownProperties),()=>{t.setParams({missingProperty:(0,vt._)`${e}`},!0),t.error()})}lt.checkReportMissingProp=S3;function x3({gen:t,data:e,it:{opts:r}},i,n){return(0,vt.or)(...i.map(o=>(0,vt.and)(yx(t,e,o,r.ownProperties),(0,vt._)`${n} = ${o}`)))}lt.checkMissingProp=x3;function I3(t,e){t.setParams({missingProperty:e},!0),t.error()}lt.reportMissingProp=I3;function U1(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,vt._)`Object.prototype.hasOwnProperty`})}lt.hasPropFunc=U1;function gx(t,e,r){return(0,vt._)`${U1(t)}.call(${e}, ${r})`}lt.isOwnProperty=gx;function E3(t,e,r,i){let n=(0,vt._)`${e}${(0,vt.getProperty)(r)} !== undefined`;return i?(0,vt._)`${n} && ${gx(t,e,r)}`:n}lt.propertyInData=E3;function yx(t,e,r,i){let n=(0,vt._)`${e}${(0,vt.getProperty)(r)} === undefined`;return i?(0,vt.or)(n,(0,vt.not)(gx(t,e,r))):n}lt.noPropertyInData=yx;function M1(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}lt.allSchemaProperties=M1;function T3(t,e){return M1(e).filter(r=>!(0,mx.alwaysValidSchema)(t,e[r]))}lt.schemaProperties=T3;function O3({schemaCode:t,data:e,it:{gen:r,topSchemaRef:i,schemaPath:n,errorPath:o},it:s},a,c,l){let u=l?(0,vt._)`${t}, ${e}, ${i}${n}`:e,d=[[go.default.instancePath,(0,vt.strConcat)(go.default.instancePath,o)],[go.default.parentData,s.parentData],[go.default.parentDataProperty,s.parentDataProperty],[go.default.rootData,go.default.rootData]];s.opts.dynamicRef&&d.push([go.default.dynamicAnchors,go.default.dynamicAnchors]);let p=(0,vt._)`${u}, ${r.object(...d)}`;return c!==vt.nil?(0,vt._)`${a}.call(${c}, ${p})`:(0,vt._)`${a}(${p})`}lt.callValidateCode=O3;var P3=(0,vt._)`new RegExp`;function A3({gen:t,it:{opts:e}},r){let i=e.unicodeRegExp?"u":"",{regExp:n}=e.code,o=n(r,i);return t.scopeValue("pattern",{key:o.toString(),ref:o,code:(0,vt._)`${n.code==="new RegExp"?P3:(0,k3.useFunc)(t,n)}(${r}, ${i})`})}lt.usePattern=A3;function R3(t){let{gen:e,data:r,keyword:i,it:n}=t,o=e.name("valid");if(n.allErrors){let a=e.let("valid",!0);return s(()=>e.assign(a,!1)),a}return e.var(o,!0),s(()=>e.break()),o;function s(a){let c=e.const("len",(0,vt._)`${r}.length`);e.forRange("i",0,c,l=>{t.subschema({keyword:i,dataProp:l,dataPropType:mx.Type.Num},o),e.if((0,vt.not)(o),a)})}}lt.validateArray=R3;function j3(t){let{gen:e,schema:r,keyword:i,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,mx.alwaysValidSchema)(n,c))&&!n.opts.unevaluated)return;let s=e.let("valid",!1),a=e.name("_valid");e.block(()=>r.forEach((c,l)=>{let u=t.subschema({keyword:i,schemaProp:l,compositeRule:!0},a);e.assign(s,(0,vt._)`${s} || ${a}`),t.mergeValidEvaluated(u,a)||e.if((0,vt.not)(s))})),t.result(s,()=>t.reset(),()=>t.error(!0))}lt.validateUnion=j3});var q1=C(ri=>{"use strict";Object.defineProperty(ri,"__esModule",{value:!0});ri.validateKeywordUsage=ri.validSchemaType=ri.funcKeywordCode=ri.macroKeywordCode=void 0;var Sr=Te(),Is=zi(),z3=pn(),C3=Td();function N3(t,e){let{gen:r,keyword:i,schema:n,parentSchema:o,it:s}=t,a=e.macro.call(s.self,n,o,s),c=Z1(r,i,a);s.opts.validateSchema!==!1&&s.self.validateSchema(a,!0);let l=r.name("valid");t.subschema({schema:a,schemaPath:Sr.nil,errSchemaPath:`${s.errSchemaPath}/${i}`,topSchemaRef:c,compositeRule:!0},l),t.pass(l,()=>t.error(!0))}ri.macroKeywordCode=N3;function D3(t,e){var r;let{gen:i,keyword:n,schema:o,parentSchema:s,$data:a,it:c}=t;U3(c,e);let l=!a&&e.compile?e.compile.call(c.self,o,s,c):e.validate,u=Z1(i,n,l),d=i.let("valid");t.block$data(d,p),t.ok((r=e.valid)!==null&&r!==void 0?r:d);function p(){if(e.errors===!1)m(),e.modifying&&F1(t),g(()=>t.error());else{let y=e.async?f():h();e.modifying&&F1(t),g(()=>L3(t,y))}}function f(){let y=i.let("ruleErrs",null);return i.try(()=>m((0,Sr._)`await `),v=>i.assign(d,!1).if((0,Sr._)`${v} instanceof ${c.ValidationError}`,()=>i.assign(y,(0,Sr._)`${v}.errors`),()=>i.throw(v))),y}function h(){let y=(0,Sr._)`${u}.errors`;return i.assign(y,null),m(Sr.nil),y}function m(y=e.async?(0,Sr._)`await `:Sr.nil){let v=c.opts.passContext?Is.default.this:Is.default.self,b=!("compile"in e&&!a||e.schema===!1);i.assign(d,(0,Sr._)`${y}${(0,z3.callValidateCode)(t,u,v,b)}`,e.modifying)}function g(y){var v;i.if((0,Sr.not)((v=e.valid)!==null&&v!==void 0?v:d),y)}}ri.funcKeywordCode=D3;function F1(t){let{gen:e,data:r,it:i}=t;e.if(i.parentData,()=>e.assign(r,(0,Sr._)`${i.parentData}[${i.parentDataProperty}]`))}function L3(t,e){let{gen:r}=t;r.if((0,Sr._)`Array.isArray(${e})`,()=>{r.assign(Is.default.vErrors,(0,Sr._)`${Is.default.vErrors} === null ? ${e} : ${Is.default.vErrors}.concat(${e})`).assign(Is.default.errors,(0,Sr._)`${Is.default.vErrors}.length`),(0,C3.extendErrors)(t)},()=>t.error())}function U3({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function Z1(t,e,r){if(r===void 0)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,Sr.stringify)(r)})}function M3(t,e,r=!1){return!e.length||e.some(i=>i==="array"?Array.isArray(t):i==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==i||r&&typeof t>"u")}ri.validSchemaType=M3;function F3({schema:t,opts:e,self:r,errSchemaPath:i},n,o){if(Array.isArray(n.keyword)?!n.keyword.includes(o):n.keyword!==o)throw new Error("ajv implementation error");let s=n.dependencies;if(s?.some(a=>!Object.prototype.hasOwnProperty.call(t,a)))throw new Error(`parent schema must have dependencies of ${o}: ${s.join(",")}`);if(n.validateSchema&&!n.validateSchema(t[o])){let c=`keyword "${o}" value is invalid at path "${i}": `+r.errorsText(n.validateSchema.errors);if(e.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}ri.validateKeywordUsage=F3});var B1=C(yo=>{"use strict";Object.defineProperty(yo,"__esModule",{value:!0});yo.extendSubschemaMode=yo.extendSubschemaData=yo.getSubschema=void 0;var ni=Te(),V1=qe();function Z3(t,{keyword:e,schemaProp:r,schema:i,schemaPath:n,errSchemaPath:o,topSchemaRef:s}){if(e!==void 0&&i!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let a=t.schema[e];return r===void 0?{schema:a,schemaPath:(0,ni._)`${t.schemaPath}${(0,ni.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,ni._)`${t.schemaPath}${(0,ni.getProperty)(e)}${(0,ni.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,V1.escapeFragment)(r)}`}}if(i!==void 0){if(n===void 0||o===void 0||s===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:i,schemaPath:n,topSchemaRef:s,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')}yo.getSubschema=Z3;function q3(t,e,{dataProp:r,dataPropType:i,data:n,dataTypes:o,propertyName:s}){if(n!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=e;if(r!==void 0){let{errorPath:l,dataPathArr:u,opts:d}=e,p=a.let("data",(0,ni._)`${e.data}${(0,ni.getProperty)(r)}`,!0);c(p),t.errorPath=(0,ni.str)`${l}${(0,V1.getErrorPath)(r,i,d.jsPropertySyntax)}`,t.parentDataProperty=(0,ni._)`${r}`,t.dataPathArr=[...u,t.parentDataProperty]}if(n!==void 0){let l=n instanceof ni.Name?n:a.let("data",n,!0);c(l),s!==void 0&&(t.propertyName=s)}o&&(t.dataTypes=o);function c(l){t.data=l,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,l]}}yo.extendSubschemaData=q3;function V3(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:i,createErrors:n,allErrors:o}){i!==void 0&&(t.compositeRule=i),n!==void 0&&(t.createErrors=n),o!==void 0&&(t.allErrors=o),t.jtdDiscriminator=e,t.jtdMetadata=r}yo.extendSubschemaMode=V3});var vx=C((Lfe,H1)=>{"use strict";H1.exports=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var i,n,o;if(Array.isArray(e)){if(i=e.length,i!=r.length)return!1;for(n=i;n--!==0;)if(!t(e[n],r[n]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(o=Object.keys(e),i=o.length,i!==Object.keys(r).length)return!1;for(n=i;n--!==0;)if(!Object.prototype.hasOwnProperty.call(r,o[n]))return!1;for(n=i;n--!==0;){var s=o[n];if(!t(e[s],r[s]))return!1}return!0}return e!==e&&r!==r}});var K1=C((Ufe,W1)=>{"use strict";var vo=W1.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var i=typeof r=="function"?r:r.pre||function(){},n=r.post||function(){};my(e,i,n,t,"",t)};vo.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};vo.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};vo.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};vo.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function my(t,e,r,i,n,o,s,a,c,l){if(i&&typeof i=="object"&&!Array.isArray(i)){e(i,n,o,s,a,c,l);for(var u in i){var d=i[u];if(Array.isArray(d)){if(u in vo.arrayKeywords)for(var p=0;p<d.length;p++)my(t,e,r,d[p],n+"/"+u+"/"+p,o,n,u,i,p)}else if(u in vo.propsKeywords){if(d&&typeof d=="object")for(var f in d)my(t,e,r,d[f],n+"/"+u+"/"+B3(f),o,n,u,i,f)}else(u in vo.keywords||t.allKeys&&!(u in vo.skipKeywords))&&my(t,e,r,d,n+"/"+u,o,n,u,i)}r(i,n,o,s,a,c,l)}}function B3(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var Pd=C(Dr=>{"use strict";Object.defineProperty(Dr,"__esModule",{value:!0});Dr.getSchemaRefs=Dr.resolveUrl=Dr.normalizeId=Dr._getFullPath=Dr.getFullPath=Dr.inlineRef=void 0;var H3=qe(),W3=vx(),K3=K1(),G3=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function J3(t,e=!0){return typeof t=="boolean"?!0:e===!0?!_x(t):e?G1(t)<=e:!1}Dr.inlineRef=J3;var X3=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function _x(t){for(let e in t){if(X3.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(_x)||typeof r=="object"&&_x(r))return!0}return!1}function G1(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!G3.has(r)&&(typeof t[r]=="object"&&(0,H3.eachItem)(t[r],i=>e+=G1(i)),e===1/0))return 1/0}return e}function J1(t,e="",r){r!==!1&&(e=Sc(e));let i=t.parse(e);return X1(t,i)}Dr.getFullPath=J1;function X1(t,e){return t.serialize(e).split("#")[0]+"#"}Dr._getFullPath=X1;var Y3=/#\/?$/;function Sc(t){return t?t.replace(Y3,""):""}Dr.normalizeId=Sc;function Q3(t,e,r){return r=Sc(r),t.resolve(e,r)}Dr.resolveUrl=Q3;var e5=/^[a-z_][-a-z0-9._]*$/i;function t5(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:i}=this.opts,n=Sc(t[r]||e),o={"":n},s=J1(i,n,!1),a={},c=new Set;return K3(t,{allKeys:!0},(d,p,f,h)=>{if(h===void 0)return;let m=s+p,g=o[h];typeof d[r]=="string"&&(g=y.call(this,d[r])),v.call(this,d.$anchor),v.call(this,d.$dynamicAnchor),o[p]=g;function y(b){let x=this.opts.uriResolver.resolve;if(b=Sc(g?x(g,b):b),c.has(b))throw u(b);c.add(b);let k=this.refs[b];return typeof k=="string"&&(k=this.refs[k]),typeof k=="object"?l(d,k.schema,b):b!==Sc(m)&&(b[0]==="#"?(l(d,a[b],b),a[b]=d):this.refs[b]=m),b}function v(b){if(typeof b=="string"){if(!e5.test(b))throw new Error(`invalid anchor "${b}"`);y.call(this,`#${b}`)}}}),a;function l(d,p,f){if(p!==void 0&&!W3(d,p))throw u(f)}function u(d){return new Error(`reference "${d}" resolves to more than one schema`)}}Dr.getSchemaRefs=t5});var jd=C(_o=>{"use strict";Object.defineProperty(_o,"__esModule",{value:!0});_o.getData=_o.KeywordCxt=_o.validateFunctionCode=void 0;var rL=A1(),Y1=Od(),wx=dx(),gy=Od(),r5=L1(),Rd=q1(),bx=B1(),ce=Te(),be=zi(),n5=Pd(),Ci=qe(),Ad=Td();function i5(t){if(oL(t)&&(sL(t),iL(t))){a5(t);return}nL(t,()=>(0,rL.topBoolOrEmptySchema)(t))}_o.validateFunctionCode=i5;function nL({gen:t,validateName:e,schema:r,schemaEnv:i,opts:n},o){n.code.es5?t.func(e,(0,ce._)`${be.default.data}, ${be.default.valCxt}`,i.$async,()=>{t.code((0,ce._)`"use strict"; ${Q1(r,n)}`),s5(t,n),t.code(o)}):t.func(e,(0,ce._)`${be.default.data}, ${o5(n)}`,i.$async,()=>t.code(Q1(r,n)).code(o))}function o5(t){return(0,ce._)`{${be.default.instancePath}="", ${be.default.parentData}, ${be.default.parentDataProperty}, ${be.default.rootData}=${be.default.data}${t.dynamicRef?(0,ce._)`, ${be.default.dynamicAnchors}={}`:ce.nil}}={}`}function s5(t,e){t.if(be.default.valCxt,()=>{t.var(be.default.instancePath,(0,ce._)`${be.default.valCxt}.${be.default.instancePath}`),t.var(be.default.parentData,(0,ce._)`${be.default.valCxt}.${be.default.parentData}`),t.var(be.default.parentDataProperty,(0,ce._)`${be.default.valCxt}.${be.default.parentDataProperty}`),t.var(be.default.rootData,(0,ce._)`${be.default.valCxt}.${be.default.rootData}`),e.dynamicRef&&t.var(be.default.dynamicAnchors,(0,ce._)`${be.default.valCxt}.${be.default.dynamicAnchors}`)},()=>{t.var(be.default.instancePath,(0,ce._)`""`),t.var(be.default.parentData,(0,ce._)`undefined`),t.var(be.default.parentDataProperty,(0,ce._)`undefined`),t.var(be.default.rootData,be.default.data),e.dynamicRef&&t.var(be.default.dynamicAnchors,(0,ce._)`{}`)})}function a5(t){let{schema:e,opts:r,gen:i}=t;nL(t,()=>{r.$comment&&e.$comment&&cL(t),f5(t),i.let(be.default.vErrors,null),i.let(be.default.errors,0),r.unevaluated&&c5(t),aL(t),m5(t)})}function c5(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,ce._)`${r}.evaluated`),e.if((0,ce._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,ce._)`${t.evaluated}.props`,(0,ce._)`undefined`)),e.if((0,ce._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,ce._)`${t.evaluated}.items`,(0,ce._)`undefined`))}function Q1(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,ce._)`/*# sourceURL=${r} */`:ce.nil}function l5(t,e){if(oL(t)&&(sL(t),iL(t))){u5(t,e);return}(0,rL.boolOrEmptySchema)(t,e)}function iL({schema:t,self:e}){if(typeof t=="boolean")return!t;for(let r in t)if(e.RULES.all[r])return!0;return!1}function oL(t){return typeof t.schema!="boolean"}function u5(t,e){let{schema:r,gen:i,opts:n}=t;n.$comment&&r.$comment&&cL(t),p5(t),h5(t);let o=i.const("_errs",be.default.errors);aL(t,o),i.var(e,(0,ce._)`${o} === ${be.default.errors}`)}function sL(t){(0,Ci.checkUnknownRules)(t),d5(t)}function aL(t,e){if(t.opts.jtd)return eL(t,[],!1,e);let r=(0,Y1.getSchemaTypes)(t.schema),i=(0,Y1.coerceAndCheckDataType)(t,r);eL(t,r,!i,e)}function d5(t){let{schema:e,errSchemaPath:r,opts:i,self:n}=t;e.$ref&&i.ignoreKeywordsWithRef&&(0,Ci.schemaHasRulesButRef)(e,n.RULES)&&n.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function f5(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Ci.checkStrictMode)(t,"default is ignored in the schema root")}function p5(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,n5.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function h5(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function cL({gen:t,schemaEnv:e,schema:r,errSchemaPath:i,opts:n}){let o=r.$comment;if(n.$comment===!0)t.code((0,ce._)`${be.default.self}.logger.log(${o})`);else if(typeof n.$comment=="function"){let s=(0,ce.str)`${i}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,ce._)`${be.default.self}.opts.$comment(${o}, ${s}, ${a}.schema)`)}}function m5(t){let{gen:e,schemaEnv:r,validateName:i,ValidationError:n,opts:o}=t;r.$async?e.if((0,ce._)`${be.default.errors} === 0`,()=>e.return(be.default.data),()=>e.throw((0,ce._)`new ${n}(${be.default.vErrors})`)):(e.assign((0,ce._)`${i}.errors`,be.default.vErrors),o.unevaluated&&g5(t),e.return((0,ce._)`${be.default.errors} === 0`))}function g5({gen:t,evaluated:e,props:r,items:i}){r instanceof ce.Name&&t.assign((0,ce._)`${e}.props`,r),i instanceof ce.Name&&t.assign((0,ce._)`${e}.items`,i)}function eL(t,e,r,i){let{gen:n,schema:o,data:s,allErrors:a,opts:c,self:l}=t,{RULES:u}=l;if(o.$ref&&(c.ignoreKeywordsWithRef||!(0,Ci.schemaHasRulesButRef)(o,u))){n.block(()=>uL(t,"$ref",u.all.$ref.definition));return}c.jtd||y5(t,e),n.block(()=>{for(let p of u.rules)d(p);d(u.post)});function d(p){(0,wx.shouldUseGroup)(o,p)&&(p.type?(n.if((0,gy.checkDataType)(p.type,s,c.strictNumbers)),tL(t,p),e.length===1&&e[0]===p.type&&r&&(n.else(),(0,gy.reportTypeError)(t)),n.endIf()):tL(t,p),a||n.if((0,ce._)`${be.default.errors} === ${i||0}`))}}function tL(t,e){let{gen:r,schema:i,opts:{useDefaults:n}}=t;n&&(0,r5.assignDefaults)(t,e.type),r.block(()=>{for(let o of e.rules)(0,wx.shouldUseRule)(i,o)&&uL(t,o.keyword,o.definition,e.type)})}function y5(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(v5(t,e),t.opts.allowUnionTypes||_5(t,e),b5(t,t.dataTypes))}function v5(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{lL(t.dataTypes,r)||$x(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),$5(t,e)}}function _5(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&$x(t,"use allowUnionTypes to allow union type keyword")}function b5(t,e){let r=t.self.RULES.all;for(let i in r){let n=r[i];if(typeof n=="object"&&(0,wx.shouldUseRule)(t.schema,n)){let{type:o}=n.definition;o.length&&!o.some(s=>w5(e,s))&&$x(t,`missing type "${o.join(",")}" for keyword "${i}"`)}}}function w5(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function lL(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function $5(t,e){let r=[];for(let i of t.dataTypes)lL(e,i)?r.push(i):e.includes("integer")&&i==="number"&&r.push("integer");t.dataTypes=r}function $x(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,Ci.checkStrictMode)(t,e,t.opts.strictTypes)}var yy=class{constructor(e,r,i){if((0,Rd.validateKeywordUsage)(e,r,i),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=i,this.data=e.data,this.schema=e.schema[i],this.$data=r.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Ci.schemaRefOrVal)(e,this.schema,i,this.$data),this.schemaType=r.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=r,this.$data)this.schemaCode=e.gen.const("vSchema",dL(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,Rd.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${i} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=e.gen.const("_errs",be.default.errors))}result(e,r,i){this.failResult((0,ce.not)(e),r,i)}failResult(e,r,i){this.gen.if(e),i?i():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,r){this.failResult((0,ce.not)(e),void 0,r)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:r}=this;this.fail((0,ce._)`${r} !== undefined && (${(0,ce.or)(this.invalid$data(),e)})`)}error(e,r,i){if(r){this.setParams(r),this._error(e,i),this.setParams({});return}this._error(e,i)}_error(e,r){(e?Ad.reportExtraError:Ad.reportError)(this,this.def.error,r)}$dataError(){(0,Ad.reportError)(this,this.def.$dataError||Ad.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Ad.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,r){r?Object.assign(this.params,e):this.params=e}block$data(e,r,i=ce.nil){this.gen.block(()=>{this.check$data(e,i),r()})}check$data(e=ce.nil,r=ce.nil){if(!this.$data)return;let{gen:i,schemaCode:n,schemaType:o,def:s}=this;i.if((0,ce.or)((0,ce._)`${n} === undefined`,r)),e!==ce.nil&&i.assign(e,!0),(o.length||s.validateSchema)&&(i.elseIf(this.invalid$data()),this.$dataError(),e!==ce.nil&&i.assign(e,!1)),i.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:i,def:n,it:o}=this;return(0,ce.or)(s(),a());function s(){if(i.length){if(!(r instanceof ce.Name))throw new Error("ajv implementation error");let c=Array.isArray(i)?i:[i];return(0,ce._)`${(0,gy.checkDataTypes)(c,r,o.opts.strictNumbers,gy.DataType.Wrong)}`}return ce.nil}function a(){if(n.validateSchema){let c=e.scopeValue("validate$data",{ref:n.validateSchema});return(0,ce._)`!${c}(${r})`}return ce.nil}}subschema(e,r){let i=(0,bx.getSubschema)(this.it,e);(0,bx.extendSubschemaData)(i,this.it,e),(0,bx.extendSubschemaMode)(i,e);let n={...this.it,...i,items:void 0,props:void 0};return l5(n,r),n}mergeEvaluated(e,r){let{it:i,gen:n}=this;i.opts.unevaluated&&(i.props!==!0&&e.props!==void 0&&(i.props=Ci.mergeEvaluated.props(n,e.props,i.props,r)),i.items!==!0&&e.items!==void 0&&(i.items=Ci.mergeEvaluated.items(n,e.items,i.items,r)))}mergeValidEvaluated(e,r){let{it:i,gen:n}=this;if(i.opts.unevaluated&&(i.props!==!0||i.items!==!0))return n.if(r,()=>this.mergeEvaluated(e,ce.Name)),!0}};_o.KeywordCxt=yy;function uL(t,e,r,i){let n=new yy(t,r,e);"code"in r?r.code(n,i):n.$data&&r.validate?(0,Rd.funcKeywordCode)(n,r):"macro"in r?(0,Rd.macroKeywordCode)(n,r):(r.compile||r.validate)&&(0,Rd.funcKeywordCode)(n,r)}var k5=/^\/(?:[^~]|~0|~1)*$/,S5=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function dL(t,{dataLevel:e,dataNames:r,dataPathArr:i}){let n,o;if(t==="")return be.default.rootData;if(t[0]==="/"){if(!k5.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);n=t,o=be.default.rootData}else{let l=S5.exec(t);if(!l)throw new Error(`Invalid JSON-pointer: ${t}`);let u=+l[1];if(n=l[2],n==="#"){if(u>=e)throw new Error(c("property/index",u));return i[e-u]}if(u>e)throw new Error(c("data",u));if(o=r[e-u],!n)return o}let s=o,a=n.split("/");for(let l of a)l&&(o=(0,ce._)`${o}${(0,ce.getProperty)((0,Ci.unescapeJsonPointer)(l))}`,s=(0,ce._)`${s} && ${o}`);return s;function c(l,u){return`Cannot access ${l} ${u} levels up, current level is ${e}`}}_o.getData=dL});var vy=C(Sx=>{"use strict";Object.defineProperty(Sx,"__esModule",{value:!0});var kx=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};Sx.default=kx});var zd=C(Ex=>{"use strict";Object.defineProperty(Ex,"__esModule",{value:!0});var xx=Pd(),Ix=class extends Error{constructor(e,r,i,n){super(n||`can't resolve reference ${i} from id ${r}`),this.missingRef=(0,xx.resolveUrl)(e,r,i),this.missingSchema=(0,xx.normalizeId)((0,xx.getFullPath)(e,this.missingRef))}};Ex.default=Ix});var by=C(hn=>{"use strict";Object.defineProperty(hn,"__esModule",{value:!0});hn.resolveSchema=hn.getCompilingSchema=hn.resolveRef=hn.compileSchema=hn.SchemaEnv=void 0;var zn=Te(),x5=vy(),Es=zi(),Cn=Pd(),fL=qe(),I5=jd(),xc=class{constructor(e){var r;this.refs={},this.dynamicAnchors={};let i;typeof e.schema=="object"&&(i=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(r=e.baseId)!==null&&r!==void 0?r:(0,Cn.normalizeId)(i?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=i?.$async,this.refs={}}};hn.SchemaEnv=xc;function Ox(t){let e=pL.call(this,t);if(e)return e;let r=(0,Cn.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:i,lines:n}=this.opts.code,{ownProperties:o}=this.opts,s=new zn.CodeGen(this.scope,{es5:i,lines:n,ownProperties:o}),a;t.$async&&(a=s.scopeValue("Error",{ref:x5.default,code:(0,zn._)`require("ajv/dist/runtime/validation_error").default`}));let c=s.scopeName("validate");t.validateName=c;let l={gen:s,allErrors:this.opts.allErrors,data:Es.default.data,parentData:Es.default.parentData,parentDataProperty:Es.default.parentDataProperty,dataNames:[Es.default.data],dataPathArr:[zn.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:s.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,zn.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:zn.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,zn._)`""`,opts:this.opts,self:this},u;try{this._compilations.add(t),(0,I5.validateFunctionCode)(l),s.optimize(this.opts.code.optimize);let d=s.toString();u=`${s.scopeRefs(Es.default.scope)}return ${d}`,this.opts.code.process&&(u=this.opts.code.process(u,t));let f=new Function(`${Es.default.self}`,`${Es.default.scope}`,u)(this,this.scope.get());if(this.scope.value(c,{ref:f}),f.errors=null,f.schema=t.schema,f.schemaEnv=t,t.$async&&(f.$async=!0),this.opts.code.source===!0&&(f.source={validateName:c,validateCode:d,scopeValues:s._values}),this.opts.unevaluated){let{props:h,items:m}=l;f.evaluated={props:h instanceof zn.Name?void 0:h,items:m instanceof zn.Name?void 0:m,dynamicProps:h instanceof zn.Name,dynamicItems:m instanceof zn.Name},f.source&&(f.source.evaluated=(0,zn.stringify)(f.evaluated))}return t.validate=f,t}catch(d){throw delete t.validate,delete t.validateName,u&&this.logger.error("Error compiling schema, function code:",u),d}finally{this._compilations.delete(t)}}hn.compileSchema=Ox;function E5(t,e,r){var i;r=(0,Cn.resolveUrl)(this.opts.uriResolver,e,r);let n=t.refs[r];if(n)return n;let o=P5.call(this,t,r);if(o===void 0){let s=(i=t.localRefs)===null||i===void 0?void 0:i[r],{schemaId:a}=this.opts;s&&(o=new xc({schema:s,schemaId:a,root:t,baseId:e}))}if(o!==void 0)return t.refs[r]=T5.call(this,o)}hn.resolveRef=E5;function T5(t){return(0,Cn.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:Ox.call(this,t)}function pL(t){for(let e of this._compilations)if(O5(e,t))return e}hn.getCompilingSchema=pL;function O5(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function P5(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||_y.call(this,t,e)}function _y(t,e){let r=this.opts.uriResolver.parse(e),i=(0,Cn._getFullPath)(this.opts.uriResolver,r),n=(0,Cn.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&i===n)return Tx.call(this,r,t);let o=(0,Cn.normalizeId)(i),s=this.refs[o]||this.schemas[o];if(typeof s=="string"){let a=_y.call(this,t,s);return typeof a?.schema!="object"?void 0:Tx.call(this,r,a)}if(typeof s?.schema=="object"){if(s.validate||Ox.call(this,s),o===(0,Cn.normalizeId)(e)){let{schema:a}=s,{schemaId:c}=this.opts,l=a[c];return l&&(n=(0,Cn.resolveUrl)(this.opts.uriResolver,n,l)),new xc({schema:a,schemaId:c,root:t,baseId:n})}return Tx.call(this,r,s)}}hn.resolveSchema=_y;var A5=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Tx(t,{baseId:e,schema:r,root:i}){var n;if(((n=t.fragment)===null||n===void 0?void 0:n[0])!=="/")return;for(let a of t.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,fL.unescapeFragment)(a)];if(c===void 0)return;r=c;let l=typeof r=="object"&&r[this.opts.schemaId];!A5.has(a)&&l&&(e=(0,Cn.resolveUrl)(this.opts.uriResolver,e,l))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,fL.schemaHasRulesButRef)(r,this.RULES)){let a=(0,Cn.resolveUrl)(this.opts.uriResolver,e,r.$ref);o=_y.call(this,i,a)}let{schemaId:s}=this.opts;if(o=o||new xc({schema:r,schemaId:s,root:i,baseId:e}),o.schema!==o.root.schema)return o}});var hL=C((Bfe,R5)=>{R5.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var Cx=C((Hfe,wL)=>{"use strict";var j5=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),Ax=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),z5=RegExp.prototype.test.bind(/^\d*$/u),Ts=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),Rx=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),gL=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u),jx=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u),C5=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u),Lr=new Array(256);{let t="0123456789ABCDEF";for(let e=0;e<256;e++)Lr[e]="%"+t[e>>4]+t[e&15]}function dr(t){return t<2048?Lr[192|t>>6]+Lr[128|t&63]:t<65536?Lr[224|t>>12]+Lr[128|t>>6&63]+Lr[128|t&63]:Lr[240|t>>18]+Lr[128|t>>12&63]+Lr[128|t>>6&63]+Lr[128|t&63]}function N5(t){let e="",r=0,i=0;for(i=0;i<t.length;i++)if(r=t[i].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[i];break}for(i+=1;i<t.length;i++){if(r=t[i].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[i]}return e}var D5=RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/),L5=RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/),U5=RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/),M5=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function F5(t){if(t.length===0)return!1;for(let e=0;e<t.length;e++)if(!U5(t[e])){if(t[e]==="%"&&e+2<t.length&&Ts(t.slice(e+1,e+3))){e+=2;continue}return!1}return!0}function mL(t){let e=-1,r=0,i=-1,n=0;for(let a=0;a<t.length;a++)t[a]==="0"?(i===-1&&(i=a),n++,n>r&&(r=n,e=i)):(i=-1,n=0);if(r<2)return t.join(":");let o=t.slice(0,e).join(":"),s=t.slice(e+r).join(":");return o+"::"+s}function Z5(t){let e=t.indexOf("::");if(e!==-1&&t.indexOf("::",e+1)!==-1)return;let r=e===-1?t.split(":"):t.slice(0,e).split(":"),i=e===-1?[]:t.slice(e+2).split(":");e!==-1&&(r.length===1&&r[0]===""&&(r.length=0),i.length===1&&i[0]===""&&(i.length=0));let n=r.concat(i),o=0;for(let a=0;a<n.length;a++){let c=n[a];if(c==="")return;if(c.indexOf(".")!==-1){if(a!==n.length-1||e!==-1&&i.length===0||!Ax(c))return;o+=2;continue}if(!D5(c))return;n[a]=parseInt(c,16).toString(16),o++}if(e===-1)return o!==8?void 0:mL(n);if(o>=8)return;let s=n.slice(0,r.length);for(let a=o;a<8;a++)s.push("0");for(let a=r.length;a<n.length;a++)s.push(n[a]);return mL(s)}function Px(t){let e=t[0]==="["&&t[t.length-1]==="]";if((t[0]==="["||t[t.length-1]==="]")&&!e)return{host:t,isIPV6:!1,error:!0};let i=e?t.slice(1,-1):t;if(e&&L5(i))return i=i.toLowerCase(),{host:`[${i}]`,escapedHost:i,isIPV6:!1,isIPVFuture:!0};if(q5(i,":")<2)return{host:t,isIPV6:!1,error:e};let n="",o=i.indexOf("%");if(o!==-1){let a=i.slice(o,o+3).toLowerCase()==="%25"?3:1;if(n=i.slice(o+a),!F5(n))return{host:t,isIPV6:!1,error:!0};i=i.slice(0,o)}let s=Z5(i);return s===void 0?{host:t,isIPV6:!1,error:!0}:{host:s+(n?"%"+n:""),escapedHost:s+(n?"%25"+n:""),isIPV6:!0}}function q5(t,e){let r=0;for(let i=0;i<t.length;i++)t[i]===e&&r++;return r}function V5(t){let e=t,r=[],i=-1,n=0;for(;n=e.length;){if(n===1){if(e===".")break;if(e==="/"){r.push("/");break}else{r.push(e);break}}else if(n===2){if(e[0]==="."){if(e[1]===".")break;if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&(e[1]==="."||e[1]==="/")){r.push("/");break}}else if(n===3&&e==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(e[0]==="."){if(e[1]==="."){if(e[2]==="/"){e=e.slice(3);continue}}else if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&e[1]==="."){if(e[2]==="/"){e=e.slice(2);continue}else if(e[2]==="."&&e[3]==="/"){e=e.slice(3),r.length!==0&&r.pop();continue}}if((i=e.indexOf("/",1))===-1){r.push(e);break}else r.push(e.slice(0,i)),e=e.slice(i)}return r.join("")}var B5={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},H5=/[@/?#:]/g,W5=/[@/?#]/g;function yL(t,e){let r=e?W5:H5;return r.lastIndex=0,t.replace(r,i=>B5[i])}function vL(t,e=!1){if(t.indexOf("%")===-1)return t;let r="";for(let i=0;i<t.length;i++){if(t[i]==="%"&&i+2<t.length){let n=t.slice(i+1,i+3);if(Ts(n)){let o=n.toUpperCase(),s=String.fromCharCode(parseInt(o,16));e&&Rx(s)?r+=s:r+="%"+o,i+=2;continue}}r+=t[i]}return r}function K5(t){let e="";for(let r=0;r<t.length;r++){let i=t[r];if(i==="%"&&r+2<t.length){let n=t.slice(r+1,r+3);if(Ts(n)){let o=n.toUpperCase(),s=String.fromCharCode(parseInt(o,16));s!=="."&&Rx(s)?e+=s:e+="%"+o,r+=2;continue}}if(gL(i))e+=i;else{let n=t.charCodeAt(r);if(n<128)e+=bL(n)?i:Lr[n];else if(n<55296||n>57343)e+=dr(n);else if(n<=56319&&r+1<t.length){let o=t.charCodeAt(r+1);o>=56320&&o<=57343?(e+=dr(65536+(n-55296<<10)+(o-56320)),r++):e+=dr(65533)}else e+=dr(65533)}}return e}function G5(t,e=!1){let r="",i=e&&t[0]!=="/";for(let n=0;n<t.length;n++){let o=t[n];if(o==="%"&&n+2<t.length){let s=t.slice(n+1,n+3);if(Ts(s)){r+="%"+s.toUpperCase(),n+=2;continue}}if(o==="/"&&(i=!1),gL(o)&&(o!==":"||!i))r+=o;else{let s=t.charCodeAt(n);if(s<128)r+=Lr[s];else if(s<55296||s>57343)r+=dr(s);else if(s<=56319&&n+1<t.length){let a=t.charCodeAt(n+1);a>=56320&&a<=57343?(r+=dr(65536+(s-55296<<10)+(a-56320)),n++):r+=dr(65533)}else r+=dr(65533)}}return r}function zx(t,e){let r="";for(let i=0;i<t.length;i++){let n=t[i];if(n==="%"&&i+2<t.length){let o=t.slice(i+1,i+3);if(Ts(o)){r+="%"+o.toUpperCase(),i+=2;continue}}if(e(n))r+=n;else{let o=t.charCodeAt(i);if(o<128)r+=Lr[o];else if(o<55296||o>57343)r+=dr(o);else if(o<=56319&&i+1<t.length){let s=t.charCodeAt(i+1);s>=56320&&s<=57343?(r+=dr(65536+(o-55296<<10)+(s-56320)),i++):r+=dr(65533)}else r+=dr(65533)}}return r}function _L(t){return zx(t,C5)}function J5(t){return zx(t,jx)}function X5(t){return zx(t,jx)}function bL(t){return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||t===42||t===43||t===45||t===46||t===47||t===64||t===95}function Y5(t){let e="";for(let r=0;r<t.length;r++){let i=t[r];if(i==="%"&&r+2<t.length){let n=t.slice(r+1,r+3);if(Ts(n)){let o=n.toUpperCase(),s=String.fromCharCode(parseInt(o,16));Rx(s)?e+=s:e+="%"+o,r+=2;continue}}if(jx(i))e+=i;else{let n=t.charCodeAt(r);if(n<128)e+=bL(n)?i:Lr[n];else if(n<55296||n>57343)e+=dr(n);else if(n<=56319&&r+1<t.length){let o=t.charCodeAt(r+1);o>=56320&&o<=57343?(e+=dr(65536+(n-55296<<10)+(o-56320)),r++):e+=dr(65533)}else e+=dr(65533)}}return e}function Q5(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let i=t.slice(r+1,r+3);if(Ts(i)){e+="%"+i.toUpperCase(),r+=2;continue}}e+=escape(t[r])}return e}function e8(t){let e=[];if(t.userinfo!==void 0&&(e.push(_L(t.userinfo)),e.push("@")),t.host!==void 0){let r=t.host;if(!Ax(r)){let i=Px(r);i.isIPV6!==!0&&i.isIPVFuture!==!0&&(r=vL(r,!0),i=Px(r)),i.isIPV6===!0||i.isIPVFuture===!0?r=`[${i.escapedHost}]`:r=yL(r,!1)}e.push(r)}if(typeof t.port=="number"||typeof t.port=="string"){let r=String(t.port);if(!z5(r))throw new TypeError("URI port is malformed.");e.push(":"),e.push(r)}return e.length?e.join(""):void 0}wL.exports={nonSimpleDomain:M5,recomposeAuthority:e8,reescapeHostDelimiters:yL,normalizePercentEncoding:vL,normalizePathEncoding:K5,serializePathEncoding:G5,normalizeQueryFragmentEncoding:Y5,encodeUserinfo:_L,encodeQuery:J5,encodeFragment:X5,escapePreservingEscapes:Q5,removeDotSegments:V5,isIPv4:Ax,isUUID:j5,normalizeIPv6:Px,stringArrayToHexStripped:N5}});var IL=C((Wfe,xL)=>{"use strict";var{isUUID:t8}=Cx(),r8=/^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu,n8=["http","https","ws","wss","urn","urn:uuid"];function i8(t){return n8.indexOf(t)!==-1}function Nx(t){return t.secure===!0?!0:t.secure===!1?!1:t.scheme?t.scheme.length===3&&(t.scheme[0]==="w"||t.scheme[0]==="W")&&(t.scheme[1]==="s"||t.scheme[1]==="S")&&(t.scheme[2]==="s"||t.scheme[2]==="S"):!1}function $L(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function kL(t){let e=String(t.scheme).toLowerCase()==="https";return(t.port===(e?443:80)||t.port==="")&&(t.port=void 0),t.path||(t.path="/"),t}function o8(t){return t.secure=Nx(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function s8(t){if((t.port===(Nx(t)?443:80)||t.port==="")&&(t.port=void 0),typeof t.secure=="boolean"&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){let e=t.resourceName.indexOf("?"),r=e===-1?t.resourceName:t.resourceName.slice(0,e);t.path=r&&r!=="/"?r:void 0,t.query=e===-1?void 0:t.resourceName.slice(e+1),t.resourceName=void 0}return t.fragment=void 0,t}function a8(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(r8);if(r&&r[0]===t.path){let i=e.scheme||t.scheme||"urn";t.nid=r[1].toLowerCase(),t.nss=r[2];let n=`${i}:${e.nid||t.nid}`,o=Dx(n);t.path=void 0,o&&(t=o.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function c8(t,e){if(t.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=e.scheme||t.scheme||"urn",i=t.nid.toLowerCase(),n=`${r}:${e.nid||i}`,o=Dx(n);o&&(t=o.serialize(t,e));let s=t,a=t.nss;return s.path=`${i||e.nid}:${a}`,e.skipEscape=!0,s}function l8(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!t8(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function u8(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var SL={scheme:"http",domainHost:!0,parse:$L,serialize:kL},d8={scheme:"https",domainHost:SL.domainHost,parse:$L,serialize:kL},wy={scheme:"ws",domainHost:!0,parse:o8,serialize:s8},f8={scheme:"wss",domainHost:wy.domainHost,parse:wy.parse,serialize:wy.serialize},p8={scheme:"urn",parse:a8,serialize:c8,skipNormalize:!0},h8={scheme:"urn:uuid",parse:l8,serialize:u8,skipNormalize:!0},$y={http:SL,https:d8,ws:wy,wss:f8,urn:p8,"urn:uuid":h8};Object.setPrototypeOf($y,null);function Dx(t){return t&&($y[t]||$y[t.toLowerCase()])||void 0}xL.exports={wsIsSecure:Nx,SCHEMES:$y,isValidSchemeName:i8,getSchemeHandler:Dx}});var UL=C((Kfe,xy)=>{"use strict";var{normalizeIPv6:AL,removeDotSegments:Nd,recomposeAuthority:m8,normalizePercentEncoding:Lx,normalizePathEncoding:g8,serializePathEncoding:EL,normalizeQueryFragmentEncoding:TL,encodeQuery:y8,encodeFragment:v8,reescapeHostDelimiters:_8,isIPv4:RL,nonSimpleDomain:b8}=Cx(),{SCHEMES:jL,getSchemeHandler:Ux}=IL(),zL=/^[A-Za-z][A-Za-z0-9+.-]*$/u,CL="URI scheme is malformed.";function OL(t){let e=unescape(String(t));if(!zL.test(e))throw new TypeError(CL);return e}function w8(t,e){return typeof t=="string"?t=O8(t,e):typeof t=="object"&&(t=Sy(Os(t,e),e)),t}function $8(t,e,r){let i=r?Object.assign({scheme:"null"},r):{scheme:"null"},{parsed:n,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:a,malformedHost:c,malformedScheme:l}=ky(t,i),{parsed:u,malformedAuthorityOrPort:d,malformedPercentEncoding:p,malformedSchemeSpecific:f,malformedHost:h,malformedScheme:m}=ky(e,i);if(o||d||s||p||a||f||c||h||l||m)throw new Error(n.error||u.error||"URI is malformed.");let g=NL(n,u,i,!0),y=Ux(r&&r.scheme||g.scheme),v=g.host,b=v!==void 0&&v!==""&&(RL(v)||AL(v).isIPV6);DL(g,r||{},y,b);let x=v&&v.indexOf("%")!==-1&&!new RegExp("\\P{ASCII}","u").test(v);if(g.error&&!x)throw new Error(g.error);return i.skipEscape=!0,Os(g,i)}function NL(t,e,r,i){let n={};return i||(t=Sy(Os(t,r),r),e=Sy(Os(e,r),r)),r=r||{},!r.tolerant&&e.scheme?(n.scheme=e.scheme,n.userinfo=e.userinfo,n.host=e.host,n.port=e.port,n.path=Nd(e.path||""),n.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(n.userinfo=e.userinfo,n.host=e.host,n.port=e.port,n.path=Nd(e.path||""),n.query=e.query):(e.path?(e.path[0]==="/"?n.path=Nd(e.path):((t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)&&!t.path?n.path="/"+e.path:t.path?n.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:n.path=e.path,n.path=Nd(n.path)),n.query=e.query):(n.path=t.path,e.query!==void 0?n.query=e.query:n.query=t.query),n.userinfo=t.userinfo,n.host=t.host,n.port=t.port),n.scheme=t.scheme),n.fragment=e.fragment,n}function k8(t,e,r){let i=PL(t,r),n=PL(e,r);return i!==void 0&&n!==void 0&&i===n}function Os(t,e){let r={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""},i=Object.assign({},e),n=[];r.scheme&&(r.scheme=OL(r.scheme));let o=Ux(i.scheme||r.scheme);o&&o.serialize&&o.serialize(r,i);let s=r.userinfo!==void 0||r.host!==void 0||r.port!==void 0,a=!i.skipEscape&&r.scheme===void 0&&!s;r.path!==void 0&&(i.skipEscape?r.path=Lx(r.path):r.path=EL(r.path,a)),i.reference!=="suffix"&&r.scheme&&(r.scheme=OL(r.scheme),n.push(r.scheme,":"));let c=m8(r);if(c!==void 0&&(i.reference!=="suffix"&&n.push("//"),n.push(c),r.path&&r.path[0]!=="/"&&n.push("/")),r.path!==void 0){let l=r.path;!i.absolutePath&&(!o||!o.absolutePath)&&(l=Nd(l)),a&&(l=EL(l,!0)),c===void 0&&l[0]==="/"&&l[1]==="/"&&(l="/%2F"+l.slice(2)),n.push(l)}return r.query!==void 0&&n.push("?",y8(r.query)),r.fragment!==void 0&&n.push("#",v8(r.fragment)),n.join("")}var S8=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,x8=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,I8=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function E8(t,e){if(e[2]!==void 0&&t.path&&t.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof t.port=="number"&&(t.port<0||t.port>65535))return"URI port is malformed."}function Cd(t){if(t===void 0)return!1;let e=t.indexOf("%");for(;e!==-1;){if(e+2>=t.length||!/^[\da-f]{2}$/iu.test(t.slice(e+1,e+3)))return!0;e=t.indexOf("%",e+3)}return!1}function Mx(t){return t[0]==="["&&t[t.length-1]==="]"}function T8(t){let e=t[4];return Cd(t[3])||e!==void 0&&!Mx(e)&&Cd(e)||Cd(t[6])||Cd(t[7])||Cd(t[8])}function DL(t,e,r,i){if(!e.unicodeSupport&&(!r||!r.unicodeSupport)&&t.host&&!Mx(t.host)&&(e.domainHost||r&&r.domainHost)&&i===!1&&b8(t.host))try{t.host=new URL("http://"+t.host).hostname}catch(n){return t.error=t.error||"Host's domain name can not be converted to ASCII: "+n,!0}return!1}function ky(t,e){let r=Object.assign({},e),i={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},n=!1,o=!1,s=!1,a=!1,c=!1,l=!1,u=!1;r.reference==="suffix"&&(r.scheme?t=r.scheme+":"+t:t="//"+t);let d=t.match(x8);d!==null&&d[1].indexOf("\\")!==-1&&(i.error="URI authority must not contain a literal backslash.",n=!0);let p=t.match(I8);if(p!==null){let h=p[1],m=h.replace(/[\t\n\r]/g,"");m.length>=2&&(m.slice(0,2)!=="//"?(i.error=i.error||"URI authority must not contain a literal backslash.",n=!0):h.length!==m.length&&(i.error=i.error||"URI authority introducer must not contain whitespace.",n=!0))}let f=t.match(S8);if(f){if(i.scheme=f[1],i.userinfo=f[3],i.host=f[4],i.port=parseInt(f[5],10),i.path=f[6]||"",i.query=f[7],i.fragment=f[8],i.scheme!==void 0){let g=unescape(i.scheme);zL.test(g)?i.scheme=g.toLowerCase():(i.error=i.error||CL,l=!0)}o=T8(f),o&&(i.error=i.error||"URI contains malformed percent-encoding."),isNaN(i.port)&&(i.port=f[5]);let h=E8(i,f);if(h!==void 0&&(i.error=i.error||h,n=!0),i.host)if(RL(i.host)===!1){let y=Mx(i.host),v=i.host.indexOf("[")!==-1||i.host.indexOf("]")!==-1,b=AL(i.host);u=b.isIPV6||b.isIPVFuture===!0,c=v&&(!y||b.error===!0),i.host=u?b.host:b.host.toLowerCase(),c&&(i.error=i.error||"URI host is malformed.",n=!0)}else u=!0;i.scheme===void 0&&i.userinfo===void 0&&i.host===void 0&&i.port===void 0&&i.query===void 0&&!i.path?i.reference="same-document":i.scheme===void 0?i.reference="relative":i.fragment===void 0?i.reference="absolute":i.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==i.reference&&(i.error=i.error||"URI is not a "+r.reference+" reference.");let m=Ux(r.scheme||i.scheme);if(c||(a=DL(i,r,m,u)),t.indexOf("%")!==-1&&i.host!==void 0&&!c){let g=u?i.host:Lx(i.host,!0);u||(g=Lx(g.toLowerCase())),i.host=_8(g,u)}(!m||m&&!m.skipNormalize)&&(i.path&&(i.path=g8(i.path)),i.query&&(i.query=TL(i.query)),i.fragment&&(i.fragment=TL(i.fragment))),m&&m.parse&&(m.parse(i,r),m===jL.urn&&i.nid===void 0&&(s=!0))}else i.error=i.error||"URI can not be parsed.";return{parsed:i,malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:a,malformedScheme:l}}function Sy(t,e){return ky(t,e).parsed}function O8(t,e){return LL(t,e).normalized}function LL(t,e){let{parsed:r,malformedAuthorityOrPort:i,malformedPercentEncoding:n,malformedSchemeSpecific:o,malformedHost:s,malformedScheme:a}=ky(t,e);return{normalized:i||n||o||s||a?t:Os(r,e),malformedAuthorityOrPort:i,malformedPercentEncoding:n,malformedSchemeSpecific:o,malformedHost:s,malformedScheme:a}}function PL(t,e){if(typeof t!="string"&&typeof t!="object")return;let r;try{r=typeof t=="string"?t:Os(t,e)}catch{return}let{normalized:i,malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:a,malformedScheme:c}=LL(r,e);return n||o||s||a||c?void 0:i}var Fx={SCHEMES:jL,normalize:w8,resolve:$8,resolveComponent:NL,equal:k8,serialize:Os,parse:Sy};xy.exports=Fx;xy.exports.default=Fx;xy.exports.fastUri=Fx});var FL=C(Zx=>{"use strict";Object.defineProperty(Zx,"__esModule",{value:!0});var ML=UL();ML.code='require("ajv/dist/runtime/uri").default';Zx.default=ML});var GL=C(nr=>{"use strict";Object.defineProperty(nr,"__esModule",{value:!0});nr.CodeGen=nr.Name=nr.nil=nr.stringify=nr.str=nr._=nr.KeywordCxt=void 0;var P8=jd();Object.defineProperty(nr,"KeywordCxt",{enumerable:!0,get:function(){return P8.KeywordCxt}});var Ic=Te();Object.defineProperty(nr,"_",{enumerable:!0,get:function(){return Ic._}});Object.defineProperty(nr,"str",{enumerable:!0,get:function(){return Ic.str}});Object.defineProperty(nr,"stringify",{enumerable:!0,get:function(){return Ic.stringify}});Object.defineProperty(nr,"nil",{enumerable:!0,get:function(){return Ic.nil}});Object.defineProperty(nr,"Name",{enumerable:!0,get:function(){return Ic.Name}});Object.defineProperty(nr,"CodeGen",{enumerable:!0,get:function(){return Ic.CodeGen}});var A8=vy(),HL=zd(),R8=ux(),Dd=by(),j8=Te(),Ld=Pd(),Iy=Od(),Vx=qe(),ZL=hL(),z8=FL(),WL=(t,e)=>new RegExp(t,e);WL.code="new RegExp";var C8=["removeAdditional","useDefaults","coerceTypes"],N8=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),D8={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},L8={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},qL=200;function U8(t){var e,r,i,n,o,s,a,c,l,u,d,p,f,h,m,g,y,v,b,x,k,E,O,X,le;let $e=t.strict,q=(e=t.code)===null||e===void 0?void 0:e.optimize,Re=q===!0||q===void 0?1:q||0,de=(i=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&i!==void 0?i:WL,pt=(n=t.uriResolver)!==null&&n!==void 0?n:z8.default;return{strictSchema:(s=(o=t.strictSchema)!==null&&o!==void 0?o:$e)!==null&&s!==void 0?s:!0,strictNumbers:(c=(a=t.strictNumbers)!==null&&a!==void 0?a:$e)!==null&&c!==void 0?c:!0,strictTypes:(u=(l=t.strictTypes)!==null&&l!==void 0?l:$e)!==null&&u!==void 0?u:"log",strictTuples:(p=(d=t.strictTuples)!==null&&d!==void 0?d:$e)!==null&&p!==void 0?p:"log",strictRequired:(h=(f=t.strictRequired)!==null&&f!==void 0?f:$e)!==null&&h!==void 0?h:!1,code:t.code?{...t.code,optimize:Re,regExp:de}:{optimize:Re,regExp:de},loopRequired:(m=t.loopRequired)!==null&&m!==void 0?m:qL,loopEnum:(g=t.loopEnum)!==null&&g!==void 0?g:qL,meta:(y=t.meta)!==null&&y!==void 0?y:!0,messages:(v=t.messages)!==null&&v!==void 0?v:!0,inlineRefs:(b=t.inlineRefs)!==null&&b!==void 0?b:!0,schemaId:(x=t.schemaId)!==null&&x!==void 0?x:"$id",addUsedSchema:(k=t.addUsedSchema)!==null&&k!==void 0?k:!0,validateSchema:(E=t.validateSchema)!==null&&E!==void 0?E:!0,validateFormats:(O=t.validateFormats)!==null&&O!==void 0?O:!0,unicodeRegExp:(X=t.unicodeRegExp)!==null&&X!==void 0?X:!0,int32range:(le=t.int32range)!==null&&le!==void 0?le:!0,uriResolver:pt}}var Ud=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...U8(e)};let{es5:r,lines:i}=this.opts.code;this.scope=new j8.ValueScope({scope:{},prefixes:N8,es5:r,lines:i}),this.logger=B8(e.logger);let n=e.validateFormats;e.validateFormats=!1,this.RULES=(0,R8.getRules)(),VL.call(this,D8,e,"NOT SUPPORTED"),VL.call(this,L8,e,"DEPRECATED","warn"),this._metaOpts=q8.call(this),e.formats&&F8.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&Z8.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),M8.call(this),e.validateFormats=n}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:i}=this.opts,n=ZL;i==="id"&&(n={...ZL},n.id=n.$id,delete n.$id),r&&e&&this.addMetaSchema(n,n[i],!1)}defaultMeta(){let{meta:e,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[r]||e:void 0}validate(e,r){let i;if(typeof e=="string"){if(i=this.getSchema(e),!i)throw new Error(`no schema with key or ref "${e}"`)}else i=this.compile(e);let n=i(r);return"$async"in i||(this.errors=i.errors),n}compile(e,r){let i=this._addSchema(e,r);return i.validate||this._compileSchemaEnv(i)}compileAsync(e,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:i}=this.opts;return n.call(this,e,r);async function n(u,d){await o.call(this,u.$schema);let p=this._addSchema(u,d);return p.validate||s.call(this,p)}async function o(u){u&&!this.getSchema(u)&&await n.call(this,{$ref:u},!0)}async function s(u){try{return this._compileSchemaEnv(u)}catch(d){if(!(d instanceof HL.default))throw d;return a.call(this,d),await c.call(this,d.missingSchema),s.call(this,u)}}function a({missingSchema:u,missingRef:d}){if(this.refs[u])throw new Error(`AnySchema ${u} is loaded but ${d} cannot be resolved`)}async function c(u){let d=await l.call(this,u);this.refs[u]||await o.call(this,d.$schema),this.refs[u]||this.addSchema(d,u,r)}async function l(u){let d=this._loading[u];if(d)return d;try{return await(this._loading[u]=i(u))}finally{delete this._loading[u]}}}addSchema(e,r,i,n=this.opts.validateSchema){if(Array.isArray(e)){for(let s of e)this.addSchema(s,void 0,i,n);return this}let o;if(typeof e=="object"){let{schemaId:s}=this.opts;if(o=e[s],o!==void 0&&typeof o!="string")throw new Error(`schema ${s} must be string`)}return r=(0,Ld.normalizeId)(r||o),this._checkUnique(r),this.schemas[r]=this._addSchema(e,i,r,n,!0),this}addMetaSchema(e,r,i=this.opts.validateSchema){return this.addSchema(e,r,!0,i),this}validateSchema(e,r){if(typeof e=="boolean")return!0;let i;if(i=e.$schema,i!==void 0&&typeof i!="string")throw new Error("$schema must be a string");if(i=i||this.opts.defaultMeta||this.defaultMeta(),!i)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let n=this.validate(i,e);if(!n&&r){let o="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(o);else throw new Error(o)}return n}getSchema(e){let r;for(;typeof(r=BL.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:i}=this.opts,n=new Dd.SchemaEnv({schema:{},schemaId:i});if(r=Dd.resolveSchema.call(this,n,e),!r)return;this.refs[e]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=BL.call(this,e);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{let r=e;this._cache.delete(r);let i=e[this.opts.schemaId];return i&&(i=(0,Ld.normalizeId)(i),delete this.schemas[i],delete this.refs[i]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let r of e)this.addKeyword(r);return this}addKeyword(e,r){let i;if(typeof e=="string")i=e,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=i);else if(typeof e=="object"&&r===void 0){if(r=e,i=r.keyword,Array.isArray(i)&&!i.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(W8.call(this,i,r),!r)return(0,Vx.eachItem)(i,o=>qx.call(this,o)),this;G8.call(this,r);let n={...r,type:(0,Iy.getJSONTypes)(r.type),schemaType:(0,Iy.getJSONTypes)(r.schemaType)};return(0,Vx.eachItem)(i,n.type.length===0?o=>qx.call(this,o,n):o=>n.type.forEach(s=>qx.call(this,o,n,s))),this}getKeyword(e){let r=this.RULES.all[e];return typeof r=="object"?r.definition:!!r}removeKeyword(e){let{RULES:r}=this;delete r.keywords[e],delete r.all[e];for(let i of r.rules){let n=i.rules.findIndex(o=>o.keyword===e);n>=0&&i.rules.splice(n,1)}return this}addFormat(e,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[e]=r,this}errorsText(e=this.errors,{separator:r=", ",dataVar:i="data"}={}){return!e||e.length===0?"No errors":e.map(n=>`${i}${n.instancePath} ${n.message}`).reduce((n,o)=>n+r+o)}$dataMetaSchema(e,r){let i=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let n of r){let o=n.split("/").slice(1),s=e;for(let a of o)s=s[a];for(let a in i){let c=i[a];if(typeof c!="object")continue;let{$data:l}=c.definition,u=s[a];l&&u&&(s[a]=KL(u))}}return e}_removeAllSchemas(e,r){for(let i in e){let n=e[i];(!r||r.test(i))&&(typeof n=="string"?delete e[i]:n&&!n.meta&&(this._cache.delete(n.schema),delete e[i]))}}_addSchema(e,r,i,n=this.opts.validateSchema,o=this.opts.addUsedSchema){let s,{schemaId:a}=this.opts;if(typeof e=="object")s=e[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(e);if(c!==void 0)return c;i=(0,Ld.normalizeId)(s||i);let l=Ld.getSchemaRefs.call(this,e,i);return c=new Dd.SchemaEnv({schema:e,schemaId:a,meta:r,baseId:i,localRefs:l}),this._cache.set(c.schema,c),o&&!i.startsWith("#")&&(i&&this._checkUnique(i),this.refs[i]=c),n&&this.validateSchema(e,!0),c}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):Dd.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let r=this.opts;this.opts=this._metaOpts;try{Dd.compileSchema.call(this,e)}finally{this.opts=r}}};Ud.ValidationError=A8.default;Ud.MissingRefError=HL.default;nr.default=Ud;function VL(t,e,r,i="error"){for(let n in t){let o=n;o in e&&this.logger[i](`${r}: option ${n}. ${t[o]}`)}}function BL(t){return t=(0,Ld.normalizeId)(t),this.schemas[t]||this.refs[t]}function M8(){let t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(let e in t)this.addSchema(t[e],e)}function F8(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function Z8(t){if(Array.isArray(t)){this.addVocabulary(t);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in t){let r=t[e];r.keyword||(r.keyword=e),this.addKeyword(r)}}function q8(){let t={...this.opts};for(let e of C8)delete t[e];return t}var V8={log(){},warn(){},error(){}};function B8(t){if(t===!1)return V8;if(t===void 0)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}var H8=/^[a-z_$][a-z0-9_$:-]*$/i;function W8(t,e){let{RULES:r}=this;if((0,Vx.eachItem)(t,i=>{if(r.keywords[i])throw new Error(`Keyword ${i} is already defined`);if(!H8.test(i))throw new Error(`Keyword ${i} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function qx(t,e,r){var i;let n=e?.post;if(r&&n)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:o}=this,s=n?o.post:o.rules.find(({type:c})=>c===r);if(s||(s={type:r,rules:[]},o.rules.push(s)),o.keywords[t]=!0,!e)return;let a={keyword:t,definition:{...e,type:(0,Iy.getJSONTypes)(e.type),schemaType:(0,Iy.getJSONTypes)(e.schemaType)}};e.before?K8.call(this,s,a,e.before):s.rules.push(a),o.all[t]=a,(i=e.implements)===null||i===void 0||i.forEach(c=>this.addKeyword(c))}function K8(t,e,r){let i=t.rules.findIndex(n=>n.keyword===r);i>=0?t.rules.splice(i,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`))}function G8(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=KL(e)),t.validateSchema=this.compile(e,!0))}var J8={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function KL(t){return{anyOf:[t,J8]}}});var JL=C(Bx=>{"use strict";Object.defineProperty(Bx,"__esModule",{value:!0});var X8={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Bx.default=X8});var eU=C(Ps=>{"use strict";Object.defineProperty(Ps,"__esModule",{value:!0});Ps.callRef=Ps.getValidate=void 0;var Y8=zd(),XL=pn(),Ur=Te(),Ec=zi(),YL=by(),Ey=qe(),Q8={keyword:"$ref",schemaType:"string",code(t){let{gen:e,schema:r,it:i}=t,{baseId:n,schemaEnv:o,validateName:s,opts:a,self:c}=i,{root:l}=o;if((r==="#"||r==="#/")&&n===l.baseId)return d();let u=YL.resolveRef.call(c,l,n,r);if(u===void 0)throw new Y8.default(i.opts.uriResolver,n,r);if(u instanceof YL.SchemaEnv)return p(u);return f(u);function d(){if(o===l)return Ty(t,s,o,o.$async);let h=e.scopeValue("root",{ref:l});return Ty(t,(0,Ur._)`${h}.validate`,l,l.$async)}function p(h){let m=QL(t,h);Ty(t,m,h,h.$async)}function f(h){let m=e.scopeValue("schema",a.code.source===!0?{ref:h,code:(0,Ur.stringify)(h)}:{ref:h}),g=e.name("valid"),y=t.subschema({schema:h,dataTypes:[],schemaPath:Ur.nil,topSchemaRef:m,errSchemaPath:r},g);t.mergeEvaluated(y),t.ok(g)}}};function QL(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,Ur._)`${r.scopeValue("wrapper",{ref:e})}.validate`}Ps.getValidate=QL;function Ty(t,e,r,i){let{gen:n,it:o}=t,{allErrors:s,schemaEnv:a,opts:c}=o,l=c.passContext?Ec.default.this:Ur.nil;i?u():d();function u(){if(!a.$async)throw new Error("async schema referenced by sync schema");let h=n.let("valid");n.try(()=>{n.code((0,Ur._)`await ${(0,XL.callValidateCode)(t,e,l)}`),f(e),s||n.assign(h,!0)},m=>{n.if((0,Ur._)`!(${m} instanceof ${o.ValidationError})`,()=>n.throw(m)),p(m),s||n.assign(h,!1)}),t.ok(h)}function d(){t.result((0,XL.callValidateCode)(t,e,l),()=>f(e),()=>p(e))}function p(h){let m=(0,Ur._)`${h}.errors`;n.assign(Ec.default.vErrors,(0,Ur._)`${Ec.default.vErrors} === null ? ${m} : ${Ec.default.vErrors}.concat(${m})`),n.assign(Ec.default.errors,(0,Ur._)`${Ec.default.vErrors}.length`)}function f(h){var m;if(!o.opts.unevaluated)return;let g=(m=r?.validate)===null||m===void 0?void 0:m.evaluated;if(o.props!==!0)if(g&&!g.dynamicProps)g.props!==void 0&&(o.props=Ey.mergeEvaluated.props(n,g.props,o.props));else{let y=n.var("props",(0,Ur._)`${h}.evaluated.props`);o.props=Ey.mergeEvaluated.props(n,y,o.props,Ur.Name)}if(o.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(o.items=Ey.mergeEvaluated.items(n,g.items,o.items));else{let y=n.var("items",(0,Ur._)`${h}.evaluated.items`);o.items=Ey.mergeEvaluated.items(n,y,o.items,Ur.Name)}}}Ps.callRef=Ty;Ps.default=Q8});var tU=C(Hx=>{"use strict";Object.defineProperty(Hx,"__esModule",{value:!0});var eX=JL(),tX=eU(),rX=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",eX.default,tX.default];Hx.default=rX});var rU=C(Wx=>{"use strict";Object.defineProperty(Wx,"__esModule",{value:!0});var Oy=Te(),bo=Oy.operators,Py={maximum:{okStr:"<=",ok:bo.LTE,fail:bo.GT},minimum:{okStr:">=",ok:bo.GTE,fail:bo.LT},exclusiveMaximum:{okStr:"<",ok:bo.LT,fail:bo.GTE},exclusiveMinimum:{okStr:">",ok:bo.GT,fail:bo.LTE}},nX={message:({keyword:t,schemaCode:e})=>(0,Oy.str)`must be ${Py[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,Oy._)`{comparison: ${Py[t].okStr}, limit: ${e}}`},iX={keyword:Object.keys(Py),type:"number",schemaType:"number",$data:!0,error:nX,code(t){let{keyword:e,data:r,schemaCode:i}=t;t.fail$data((0,Oy._)`${r} ${Py[e].fail} ${i} || isNaN(${r})`)}};Wx.default=iX});var nU=C(Kx=>{"use strict";Object.defineProperty(Kx,"__esModule",{value:!0});var Md=Te(),oX={message:({schemaCode:t})=>(0,Md.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,Md._)`{multipleOf: ${t}}`},sX={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:oX,code(t){let{gen:e,data:r,schemaCode:i,it:n}=t,o=n.opts.multipleOfPrecision,s=e.let("res"),a=o?(0,Md._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${o}`:(0,Md._)`${s} !== parseInt(${s})`;t.fail$data((0,Md._)`(${i} === 0 || (${s} = ${r}/${i}, ${a}))`)}};Kx.default=sX});var oU=C(Gx=>{"use strict";Object.defineProperty(Gx,"__esModule",{value:!0});function iU(t){let e=t.length,r=0,i=0,n;for(;i<e;)r++,n=t.charCodeAt(i++),n>=55296&&n<=56319&&i<e&&(n=t.charCodeAt(i),(n&64512)===56320&&i++);return r}Gx.default=iU;iU.code='require("ajv/dist/runtime/ucs2length").default'});var sU=C(Jx=>{"use strict";Object.defineProperty(Jx,"__esModule",{value:!0});var As=Te(),aX=qe(),cX=oU(),lX={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,As.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,As._)`{limit: ${t}}`},uX={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:lX,code(t){let{keyword:e,data:r,schemaCode:i,it:n}=t,o=e==="maxLength"?As.operators.GT:As.operators.LT,s=n.opts.unicode===!1?(0,As._)`${r}.length`:(0,As._)`${(0,aX.useFunc)(t.gen,cX.default)}(${r})`;t.fail$data((0,As._)`${s} ${o} ${i}`)}};Jx.default=uX});var aU=C(Xx=>{"use strict";Object.defineProperty(Xx,"__esModule",{value:!0});var dX=pn(),fX=qe(),Tc=Te(),pX={message:({schemaCode:t})=>(0,Tc.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,Tc._)`{pattern: ${t}}`},hX={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:pX,code(t){let{gen:e,data:r,$data:i,schema:n,schemaCode:o,it:s}=t,a=s.opts.unicodeRegExp?"u":"";if(i){let{regExp:c}=s.opts.code,l=c.code==="new RegExp"?(0,Tc._)`new RegExp`:(0,fX.useFunc)(e,c),u=e.let("valid");e.try(()=>e.assign(u,(0,Tc._)`${l}(${o}, ${a}).test(${r})`),()=>e.assign(u,!1)),t.fail$data((0,Tc._)`!${u}`)}else{let c=(0,dX.usePattern)(t,n);t.fail$data((0,Tc._)`!${c}.test(${r})`)}}};Xx.default=hX});var cU=C(Yx=>{"use strict";Object.defineProperty(Yx,"__esModule",{value:!0});var Fd=Te(),mX={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,Fd.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,Fd._)`{limit: ${t}}`},gX={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:mX,code(t){let{keyword:e,data:r,schemaCode:i}=t,n=e==="maxProperties"?Fd.operators.GT:Fd.operators.LT;t.fail$data((0,Fd._)`Object.keys(${r}).length ${n} ${i}`)}};Yx.default=gX});var lU=C(Qx=>{"use strict";Object.defineProperty(Qx,"__esModule",{value:!0});var Zd=pn(),qd=Te(),yX=qe(),vX={message:({params:{missingProperty:t}})=>(0,qd.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,qd._)`{missingProperty: ${t}}`},_X={keyword:"required",type:"object",schemaType:"array",$data:!0,error:vX,code(t){let{gen:e,schema:r,schemaCode:i,data:n,$data:o,it:s}=t,{opts:a}=s;if(!o&&r.length===0)return;let c=r.length>=a.loopRequired;if(s.allErrors?l():u(),a.strictRequired){let f=t.parentSchema.properties,{definedProperties:h}=t.it;for(let m of r)if(f?.[m]===void 0&&!h.has(m)){let g=s.schemaEnv.baseId+s.errSchemaPath,y=`required property "${m}" is not defined at "${g}" (strictRequired)`;(0,yX.checkStrictMode)(s,y,s.opts.strictRequired)}}function l(){if(c||o)t.block$data(qd.nil,d);else for(let f of r)(0,Zd.checkReportMissingProp)(t,f)}function u(){let f=e.let("missing");if(c||o){let h=e.let("valid",!0);t.block$data(h,()=>p(f,h)),t.ok(h)}else e.if((0,Zd.checkMissingProp)(t,r,f)),(0,Zd.reportMissingProp)(t,f),e.else()}function d(){e.forOf("prop",i,f=>{t.setParams({missingProperty:f}),e.if((0,Zd.noPropertyInData)(e,n,f,a.ownProperties),()=>t.error())})}function p(f,h){t.setParams({missingProperty:f}),e.forOf(f,i,()=>{e.assign(h,(0,Zd.propertyInData)(e,n,f,a.ownProperties)),e.if((0,qd.not)(h),()=>{t.error(),e.break()})},qd.nil)}}};Qx.default=_X});var uU=C(eI=>{"use strict";Object.defineProperty(eI,"__esModule",{value:!0});var Vd=Te(),bX={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,Vd.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,Vd._)`{limit: ${t}}`},wX={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:bX,code(t){let{keyword:e,data:r,schemaCode:i}=t,n=e==="maxItems"?Vd.operators.GT:Vd.operators.LT;t.fail$data((0,Vd._)`${r}.length ${n} ${i}`)}};eI.default=wX});var Ay=C(tI=>{"use strict";Object.defineProperty(tI,"__esModule",{value:!0});var dU=vx();dU.code='require("ajv/dist/runtime/equal").default';tI.default=dU});var fU=C(nI=>{"use strict";Object.defineProperty(nI,"__esModule",{value:!0});var rI=Od(),ir=Te(),$X=qe(),kX=Ay(),SX={message:({params:{i:t,j:e}})=>(0,ir.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,ir._)`{i: ${t}, j: ${e}}`},xX={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:SX,code(t){let{gen:e,data:r,$data:i,schema:n,parentSchema:o,schemaCode:s,it:a}=t;if(!i&&!n)return;let c=e.let("valid"),l=o.items?(0,rI.getSchemaTypes)(o.items):[];t.block$data(c,u,(0,ir._)`${s} === false`),t.ok(c);function u(){let h=e.let("i",(0,ir._)`${r}.length`),m=e.let("j");t.setParams({i:h,j:m}),e.assign(c,!0),e.if((0,ir._)`${h} > 1`,()=>(d()?p:f)(h,m))}function d(){return l.length>0&&!l.some(h=>h==="object"||h==="array")}function p(h,m){let g=e.name("item"),y=(0,rI.checkDataTypes)(l,g,a.opts.strictNumbers,rI.DataType.Wrong),v=e.const("indices",(0,ir._)`{}`);e.for((0,ir._)`;${h}--;`,()=>{e.let(g,(0,ir._)`${r}[${h}]`),e.if(y,(0,ir._)`continue`),l.length>1&&e.if((0,ir._)`typeof ${g} == "string"`,(0,ir._)`${g} += "_"`),e.if((0,ir._)`typeof ${v}[${g}] == "number"`,()=>{e.assign(m,(0,ir._)`${v}[${g}]`),t.error(),e.assign(c,!1).break()}).code((0,ir._)`${v}[${g}] = ${h}`)})}function f(h,m){let g=(0,$X.useFunc)(e,kX.default),y=e.name("outer");e.label(y).for((0,ir._)`;${h}--;`,()=>e.for((0,ir._)`${m} = ${h}; ${m}--;`,()=>e.if((0,ir._)`${g}(${r}[${h}], ${r}[${m}])`,()=>{t.error(),e.assign(c,!1).break(y)})))}}};nI.default=xX});var pU=C(oI=>{"use strict";Object.defineProperty(oI,"__esModule",{value:!0});var iI=Te(),IX=qe(),EX=Ay(),TX={message:"must be equal to constant",params:({schemaCode:t})=>(0,iI._)`{allowedValue: ${t}}`},OX={keyword:"const",$data:!0,error:TX,code(t){let{gen:e,data:r,$data:i,schemaCode:n,schema:o}=t;i||o&&typeof o=="object"?t.fail$data((0,iI._)`!${(0,IX.useFunc)(e,EX.default)}(${r}, ${n})`):t.fail((0,iI._)`${o} !== ${r}`)}};oI.default=OX});var hU=C(sI=>{"use strict";Object.defineProperty(sI,"__esModule",{value:!0});var Bd=Te(),PX=qe(),AX=Ay(),RX={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,Bd._)`{allowedValues: ${t}}`},jX={keyword:"enum",schemaType:"array",$data:!0,error:RX,code(t){let{gen:e,data:r,$data:i,schema:n,schemaCode:o,it:s}=t;if(!i&&n.length===0)throw new Error("enum must have non-empty array");let a=n.length>=s.opts.loopEnum,c,l=()=>c??(c=(0,PX.useFunc)(e,AX.default)),u;if(a||i)u=e.let("valid"),t.block$data(u,d);else{if(!Array.isArray(n))throw new Error("ajv implementation error");let f=e.const("vSchema",o);u=(0,Bd.or)(...n.map((h,m)=>p(f,m)))}t.pass(u);function d(){e.assign(u,!1),e.forOf("v",o,f=>e.if((0,Bd._)`${l()}(${r}, ${f})`,()=>e.assign(u,!0).break()))}function p(f,h){let m=n[h];return typeof m=="object"&&m!==null?(0,Bd._)`${l()}(${r}, ${f}[${h}])`:(0,Bd._)`${r} === ${m}`}}};sI.default=jX});var mU=C(aI=>{"use strict";Object.defineProperty(aI,"__esModule",{value:!0});var zX=rU(),CX=nU(),NX=sU(),DX=aU(),LX=cU(),UX=lU(),MX=uU(),FX=fU(),ZX=pU(),qX=hU(),VX=[zX.default,CX.default,NX.default,DX.default,LX.default,UX.default,MX.default,FX.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},ZX.default,qX.default];aI.default=VX});var lI=C(Hd=>{"use strict";Object.defineProperty(Hd,"__esModule",{value:!0});Hd.validateAdditionalItems=void 0;var Rs=Te(),cI=qe(),BX={message:({params:{len:t}})=>(0,Rs.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Rs._)`{limit: ${t}}`},HX={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:BX,code(t){let{parentSchema:e,it:r}=t,{items:i}=e;if(!Array.isArray(i)){(0,cI.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}gU(t,i)}};function gU(t,e){let{gen:r,schema:i,data:n,keyword:o,it:s}=t;s.items=!0;let a=r.const("len",(0,Rs._)`${n}.length`);if(i===!1)t.setParams({len:e.length}),t.pass((0,Rs._)`${a} <= ${e.length}`);else if(typeof i=="object"&&!(0,cI.alwaysValidSchema)(s,i)){let l=r.var("valid",(0,Rs._)`${a} <= ${e.length}`);r.if((0,Rs.not)(l),()=>c(l)),t.ok(l)}function c(l){r.forRange("i",e.length,a,u=>{t.subschema({keyword:o,dataProp:u,dataPropType:cI.Type.Num},l),s.allErrors||r.if((0,Rs.not)(l),()=>r.break())})}}Hd.validateAdditionalItems=gU;Hd.default=HX});var uI=C(Wd=>{"use strict";Object.defineProperty(Wd,"__esModule",{value:!0});Wd.validateTuple=void 0;var yU=Te(),Ry=qe(),WX=pn(),KX={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return vU(t,"additionalItems",e);r.items=!0,!(0,Ry.alwaysValidSchema)(r,e)&&t.ok((0,WX.validateArray)(t))}};function vU(t,e,r=t.schema){let{gen:i,parentSchema:n,data:o,keyword:s,it:a}=t;u(n),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=Ry.mergeEvaluated.items(i,r.length,a.items));let c=i.name("valid"),l=i.const("len",(0,yU._)`${o}.length`);r.forEach((d,p)=>{(0,Ry.alwaysValidSchema)(a,d)||(i.if((0,yU._)`${l} > ${p}`,()=>t.subschema({keyword:s,schemaProp:p,dataProp:p},c)),t.ok(c))});function u(d){let{opts:p,errSchemaPath:f}=a,h=r.length,m=h===d.minItems&&(h===d.maxItems||d[e]===!1);if(p.strictTuples&&!m){let g=`"${s}" is ${h}-tuple, but minItems or maxItems/${e} are not specified or different at path "${f}"`;(0,Ry.checkStrictMode)(a,g,p.strictTuples)}}}Wd.validateTuple=vU;Wd.default=KX});var _U=C(dI=>{"use strict";Object.defineProperty(dI,"__esModule",{value:!0});var GX=uI(),JX={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,GX.validateTuple)(t,"items")};dI.default=JX});var wU=C(fI=>{"use strict";Object.defineProperty(fI,"__esModule",{value:!0});var bU=Te(),XX=qe(),YX=pn(),QX=lI(),e7={message:({params:{len:t}})=>(0,bU.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,bU._)`{limit: ${t}}`},t7={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:e7,code(t){let{schema:e,parentSchema:r,it:i}=t,{prefixItems:n}=r;i.items=!0,!(0,XX.alwaysValidSchema)(i,e)&&(n?(0,QX.validateAdditionalItems)(t,n):t.ok((0,YX.validateArray)(t)))}};fI.default=t7});var $U=C(pI=>{"use strict";Object.defineProperty(pI,"__esModule",{value:!0});var mn=Te(),jy=qe(),r7={message:({params:{min:t,max:e}})=>e===void 0?(0,mn.str)`must contain at least ${t} valid item(s)`:(0,mn.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,mn._)`{minContains: ${t}}`:(0,mn._)`{minContains: ${t}, maxContains: ${e}}`},n7={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:r7,code(t){let{gen:e,schema:r,parentSchema:i,data:n,it:o}=t,s,a,{minContains:c,maxContains:l}=i;o.opts.next?(s=c===void 0?1:c,a=l):s=1;let u=e.const("len",(0,mn._)`${n}.length`);if(t.setParams({min:s,max:a}),a===void 0&&s===0){(0,jy.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&s>a){(0,jy.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,jy.alwaysValidSchema)(o,r)){let m=(0,mn._)`${u} >= ${s}`;a!==void 0&&(m=(0,mn._)`${m} && ${u} <= ${a}`),t.pass(m);return}o.items=!0;let d=e.name("valid");a===void 0&&s===1?f(d,()=>e.if(d,()=>e.break())):s===0?(e.let(d,!0),a!==void 0&&e.if((0,mn._)`${n}.length > 0`,p)):(e.let(d,!1),p()),t.result(d,()=>t.reset());function p(){let m=e.name("_valid"),g=e.let("count",0);f(m,()=>e.if(m,()=>h(g)))}function f(m,g){e.forRange("i",0,u,y=>{t.subschema({keyword:"contains",dataProp:y,dataPropType:jy.Type.Num,compositeRule:!0},m),g()})}function h(m){e.code((0,mn._)`${m}++`),a===void 0?e.if((0,mn._)`${m} >= ${s}`,()=>e.assign(d,!0).break()):(e.if((0,mn._)`${m} > ${a}`,()=>e.assign(d,!1).break()),s===1?e.assign(d,!0):e.if((0,mn._)`${m} >= ${s}`,()=>e.assign(d,!0)))}}};pI.default=n7});var xU=C(ii=>{"use strict";Object.defineProperty(ii,"__esModule",{value:!0});ii.validateSchemaDeps=ii.validatePropertyDeps=ii.error=void 0;var hI=Te(),i7=qe(),Kd=pn();ii.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let i=e===1?"property":"properties";return(0,hI.str)`must have ${i} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:i}})=>(0,hI._)`{property: ${t},
129
129
  missingProperty: ${i},
130
130
  depsCount: ${e},
131
- deps: ${r}}`};var r7={keyword:"dependencies",type:"object",schemaType:"object",error:ii.error,code(t){let[e,r]=n7(t);kU(t,e),SU(t,r)}};function n7({schema:t}){let e={},r={};for(let i in t){if(i==="__proto__")continue;let n=Array.isArray(t[i])?e:r;n[i]=t[i]}return[e,r]}function kU(t,e=t.schema){let{gen:r,data:i,it:n}=t;if(Object.keys(e).length===0)return;let o=r.let("missing");for(let s in e){let a=e[s];if(a.length===0)continue;let c=(0,Kd.propertyInData)(r,i,s,n.opts.ownProperties);t.setParams({property:s,depsCount:a.length,deps:a.join(", ")}),n.allErrors?r.if(c,()=>{for(let l of a)(0,Kd.checkReportMissingProp)(t,l)}):(r.if((0,hI._)`${c} && (${(0,Kd.checkMissingProp)(t,a,o)})`),(0,Kd.reportMissingProp)(t,o),r.else())}}ii.validatePropertyDeps=kU;function SU(t,e=t.schema){let{gen:r,data:i,keyword:n,it:o}=t,s=r.name("valid");for(let a in e)(0,t7.alwaysValidSchema)(o,e[a])||(r.if((0,Kd.propertyInData)(r,i,a,o.opts.ownProperties),()=>{let c=t.subschema({keyword:n,schemaProp:a},s);t.mergeValidEvaluated(c,s)},()=>r.var(s,!0)),t.ok(s))}ii.validateSchemaDeps=SU;ii.default=r7});var EU=C(mI=>{"use strict";Object.defineProperty(mI,"__esModule",{value:!0});var IU=Te(),i7=qe(),o7={message:"property name must be valid",params:({params:t})=>(0,IU._)`{propertyName: ${t.propertyName}}`},s7={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:o7,code(t){let{gen:e,schema:r,data:i,it:n}=t;if((0,i7.alwaysValidSchema)(n,r))return;let o=e.name("valid");e.forIn("key",i,s=>{t.setParams({propertyName:s}),t.subschema({keyword:"propertyNames",data:s,dataTypes:["string"],propertyName:s,compositeRule:!0},o),e.if((0,IU.not)(o),()=>{t.error(!0),n.allErrors||e.break()})}),t.ok(o)}};mI.default=s7});var yI=C(gI=>{"use strict";Object.defineProperty(gI,"__esModule",{value:!0});var zy=pn(),Nn=Te(),a7=zi(),Cy=qe(),c7={message:"must NOT have additional properties",params:({params:t})=>(0,Nn._)`{additionalProperty: ${t.additionalProperty}}`},l7={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:c7,code(t){let{gen:e,schema:r,parentSchema:i,data:n,errsCount:o,it:s}=t;if(!o)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=s;if(s.props=!0,c.removeAdditional!=="all"&&(0,Cy.alwaysValidSchema)(s,r))return;let l=(0,zy.allSchemaProperties)(i.properties),u=(0,zy.allSchemaProperties)(i.patternProperties);d(),t.ok((0,Nn._)`${o} === ${a7.default.errors}`);function d(){e.forIn("key",n,g=>{!l.length&&!u.length?h(g):e.if(p(g),()=>h(g))})}function p(g){let y;if(l.length>8){let v=(0,Cy.schemaRefOrVal)(s,i.properties,"properties");y=(0,zy.isOwnProperty)(e,v,g)}else l.length?y=(0,Nn.or)(...l.map(v=>(0,Nn._)`${g} === ${v}`)):y=Nn.nil;return u.length&&(y=(0,Nn.or)(y,...u.map(v=>(0,Nn._)`${(0,zy.usePattern)(t,v)}.test(${g})`))),(0,Nn.not)(y)}function f(g){e.code((0,Nn._)`delete ${n}[${g}]`)}function h(g){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){f(g);return}if(r===!1){t.setParams({additionalProperty:g}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,Cy.alwaysValidSchema)(s,r)){let y=e.name("valid");c.removeAdditional==="failing"?(m(g,y,!1),e.if((0,Nn.not)(y),()=>{t.reset(),f(g)})):(m(g,y),a||e.if((0,Nn.not)(y),()=>e.break()))}}function m(g,y,v){let b={keyword:"additionalProperties",dataProp:g,dataPropType:Cy.Type.Str};v===!1&&Object.assign(b,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(b,y)}}};gI.default=l7});var PU=C(_I=>{"use strict";Object.defineProperty(_I,"__esModule",{value:!0});var u7=jd(),TU=pn(),vI=qe(),OU=yI(),d7={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:i,data:n,it:o}=t;o.opts.removeAdditional==="all"&&i.additionalProperties===void 0&&OU.default.code(new u7.KeywordCxt(o,OU.default,"additionalProperties"));let s=(0,TU.allSchemaProperties)(r);for(let d of s)o.definedProperties.add(d);o.opts.unevaluated&&s.length&&o.props!==!0&&(o.props=vI.mergeEvaluated.props(e,(0,vI.toHash)(s),o.props));let a=s.filter(d=>!(0,vI.alwaysValidSchema)(o,r[d]));if(a.length===0)return;let c=e.name("valid");for(let d of a)l(d)?u(d):(e.if((0,TU.propertyInData)(e,n,d,o.opts.ownProperties)),u(d),o.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(d),t.ok(c);function l(d){return o.opts.useDefaults&&!o.compositeRule&&r[d].default!==void 0}function u(d){t.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};_I.default=d7});var zU=C(bI=>{"use strict";Object.defineProperty(bI,"__esModule",{value:!0});var AU=pn(),Ny=Te(),RU=qe(),jU=qe(),f7={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:i,parentSchema:n,it:o}=t,{opts:s}=o,a=(0,AU.allSchemaProperties)(r),c=a.filter(m=>(0,RU.alwaysValidSchema)(o,r[m]));if(a.length===0||c.length===a.length&&(!o.opts.unevaluated||o.props===!0))return;let l=s.strictSchema&&!s.allowMatchingProperties&&n.properties,u=e.name("valid");o.props!==!0&&!(o.props instanceof Ny.Name)&&(o.props=(0,jU.evaluatedPropsToName)(e,o.props));let{props:d}=o;p();function p(){for(let m of a)l&&f(m),o.allErrors?h(m):(e.var(u,!0),h(m),e.if(u))}function f(m){for(let g in l)new RegExp(m).test(g)&&(0,RU.checkStrictMode)(o,`property ${g} matches pattern ${m} (use allowMatchingProperties)`)}function h(m){e.forIn("key",i,g=>{e.if((0,Ny._)`${(0,AU.usePattern)(t,m)}.test(${g})`,()=>{let y=c.includes(m);y||t.subschema({keyword:"patternProperties",schemaProp:m,dataProp:g,dataPropType:jU.Type.Str},u),o.opts.unevaluated&&d!==!0?e.assign((0,Ny._)`${d}[${g}]`,!0):!y&&!o.allErrors&&e.if((0,Ny.not)(u),()=>e.break())})})}}};bI.default=f7});var CU=C(wI=>{"use strict";Object.defineProperty(wI,"__esModule",{value:!0});var p7=qe(),h7={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:i}=t;if((0,p7.alwaysValidSchema)(i,r)){t.fail();return}let n=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},n),t.failResult(n,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};wI.default=h7});var NU=C($I=>{"use strict";Object.defineProperty($I,"__esModule",{value:!0});var m7=pn(),g7={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:m7.validateUnion,error:{message:"must match a schema in anyOf"}};$I.default=g7});var DU=C(kI=>{"use strict";Object.defineProperty(kI,"__esModule",{value:!0});var Dy=Te(),y7=qe(),v7={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,Dy._)`{passingSchemas: ${t.passing}}`},_7={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:v7,code(t){let{gen:e,schema:r,parentSchema:i,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(n.opts.discriminator&&i.discriminator)return;let o=r,s=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(l),t.result(s,()=>t.reset(),()=>t.error(!0));function l(){o.forEach((u,d)=>{let p;(0,y7.alwaysValidSchema)(n,u)?e.var(c,!0):p=t.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&e.if((0,Dy._)`${c} && ${s}`).assign(s,!1).assign(a,(0,Dy._)`[${a}, ${d}]`).else(),e.if(c,()=>{e.assign(s,!0),e.assign(a,d),p&&t.mergeEvaluated(p,Dy.Name)})})}}};kI.default=_7});var LU=C(SI=>{"use strict";Object.defineProperty(SI,"__esModule",{value:!0});var b7=qe(),w7={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:r,it:i}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");let n=e.name("valid");r.forEach((o,s)=>{if((0,b7.alwaysValidSchema)(i,o))return;let a=t.subschema({keyword:"allOf",schemaProp:s},n);t.ok(n),t.mergeEvaluated(a)})}};SI.default=w7});var FU=C(xI=>{"use strict";Object.defineProperty(xI,"__esModule",{value:!0});var Ly=Te(),MU=qe(),$7={message:({params:t})=>(0,Ly.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,Ly._)`{failingKeyword: ${t.ifClause}}`},k7={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:$7,code(t){let{gen:e,parentSchema:r,it:i}=t;r.then===void 0&&r.else===void 0&&(0,MU.checkStrictMode)(i,'"if" without "then" and "else" is ignored');let n=UU(i,"then"),o=UU(i,"else");if(!n&&!o)return;let s=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),n&&o){let u=e.let("ifClause");t.setParams({ifClause:u}),e.if(a,l("then",u),l("else",u))}else n?e.if(a,l("then")):e.if((0,Ly.not)(a),l("else"));t.pass(s,()=>t.error(!0));function c(){let u=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(u)}function l(u,d){return()=>{let p=t.subschema({keyword:u},a);e.assign(s,a),t.mergeValidEvaluated(p,s),d?e.assign(d,(0,Ly._)`${u}`):t.setParams({ifClause:u})}}}};function UU(t,e){let r=t.schema[e];return r!==void 0&&!(0,MU.alwaysValidSchema)(t,r)}xI.default=k7});var ZU=C(II=>{"use strict";Object.defineProperty(II,"__esModule",{value:!0});var S7=qe(),x7={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,S7.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};II.default=x7});var qU=C(EI=>{"use strict";Object.defineProperty(EI,"__esModule",{value:!0});var I7=lI(),E7=_U(),T7=uI(),O7=wU(),P7=$U(),A7=xU(),R7=EU(),j7=yI(),z7=PU(),C7=zU(),N7=CU(),D7=NU(),L7=DU(),U7=LU(),M7=FU(),F7=ZU();function Z7(t=!1){let e=[N7.default,D7.default,L7.default,U7.default,M7.default,F7.default,R7.default,j7.default,A7.default,z7.default,C7.default];return t?e.push(E7.default,O7.default):e.push(I7.default,T7.default),e.push(P7.default),e}EI.default=Z7});var VU=C(TI=>{"use strict";Object.defineProperty(TI,"__esModule",{value:!0});var Dt=Te(),q7={message:({schemaCode:t})=>(0,Dt.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,Dt._)`{format: ${t}}`},V7={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:q7,code(t,e){let{gen:r,data:i,$data:n,schema:o,schemaCode:s,it:a}=t,{opts:c,errSchemaPath:l,schemaEnv:u,self:d}=a;if(!c.validateFormats)return;n?p():f();function p(){let h=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),m=r.const("fDef",(0,Dt._)`${h}[${s}]`),g=r.let("fType"),y=r.let("format");r.if((0,Dt._)`typeof ${m} == "object" && !(${m} instanceof RegExp)`,()=>r.assign(g,(0,Dt._)`${m}.type || "string"`).assign(y,(0,Dt._)`${m}.validate`),()=>r.assign(g,(0,Dt._)`"string"`).assign(y,m)),t.fail$data((0,Dt.or)(v(),b()));function v(){return c.strictSchema===!1?Dt.nil:(0,Dt._)`${s} && !${y}`}function b(){let x=u.$async?(0,Dt._)`(${m}.async ? await ${y}(${i}) : ${y}(${i}))`:(0,Dt._)`${y}(${i})`,k=(0,Dt._)`(typeof ${y} == "function" ? ${x} : ${y}.test(${i}))`;return(0,Dt._)`${y} && ${y} !== true && ${g} === ${e} && !${k}`}}function f(){let h=d.formats[o];if(!h){v();return}if(h===!0)return;let[m,g,y]=b(h);m===e&&t.pass(x());function v(){if(c.strictSchema===!1){d.logger.warn(k());return}throw new Error(k());function k(){return`unknown format "${o}" ignored in schema at path "${l}"`}}function b(k){let E=k instanceof RegExp?(0,Dt.regexpCode)(k):c.code.formats?(0,Dt._)`${c.code.formats}${(0,Dt.getProperty)(o)}`:void 0,O=r.scopeValue("formats",{key:o,ref:k,code:E});return typeof k=="object"&&!(k instanceof RegExp)?[k.type||"string",k.validate,(0,Dt._)`${O}.validate`]:["string",k,O]}function x(){if(typeof h=="object"&&!(h instanceof RegExp)&&h.async){if(!u.$async)throw new Error("async format in sync schema");return(0,Dt._)`await ${y}(${i})`}return typeof g=="function"?(0,Dt._)`${y}(${i})`:(0,Dt._)`${y}.test(${i})`}}}};TI.default=V7});var BU=C(OI=>{"use strict";Object.defineProperty(OI,"__esModule",{value:!0});var B7=VU(),H7=[B7.default];OI.default=H7});var HU=C(Oc=>{"use strict";Object.defineProperty(Oc,"__esModule",{value:!0});Oc.contentVocabulary=Oc.metadataVocabulary=void 0;Oc.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Oc.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var KU=C(PI=>{"use strict";Object.defineProperty(PI,"__esModule",{value:!0});var W7=tU(),K7=mU(),G7=qU(),J7=BU(),WU=HU(),X7=[W7.default,K7.default,(0,G7.default)(),J7.default,WU.metadataVocabulary,WU.contentVocabulary];PI.default=X7});var JU=C(Uy=>{"use strict";Object.defineProperty(Uy,"__esModule",{value:!0});Uy.DiscrError=void 0;var GU;(function(t){t.Tag="tag",t.Mapping="mapping"})(GU||(Uy.DiscrError=GU={}))});var YU=C(RI=>{"use strict";Object.defineProperty(RI,"__esModule",{value:!0});var Pc=Te(),AI=JU(),XU=by(),Y7=zd(),Q7=qe(),eY={message:({params:{discrError:t,tagName:e}})=>t===AI.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,Pc._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},tY={keyword:"discriminator",type:"object",schemaType:"object",error:eY,code(t){let{gen:e,data:r,schema:i,parentSchema:n,it:o}=t,{oneOf:s}=n;if(!o.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=i.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(i.mapping)throw new Error("discriminator: mapping is not supported");if(!s)throw new Error("discriminator: requires oneOf keyword");let c=e.let("valid",!1),l=e.const("tag",(0,Pc._)`${r}${(0,Pc.getProperty)(a)}`);e.if((0,Pc._)`typeof ${l} == "string"`,()=>u(),()=>t.error(!1,{discrError:AI.DiscrError.Tag,tag:l,tagName:a})),t.ok(c);function u(){let f=p();e.if(!1);for(let h in f)e.elseIf((0,Pc._)`${l} === ${h}`),e.assign(c,d(f[h]));e.else(),t.error(!1,{discrError:AI.DiscrError.Mapping,tag:l,tagName:a}),e.endIf()}function d(f){let h=e.name("valid"),m=t.subschema({keyword:"oneOf",schemaProp:f},h);return t.mergeEvaluated(m,Pc.Name),h}function p(){var f;let h={},m=y(n),g=!0;for(let x=0;x<s.length;x++){let k=s[x];if(k?.$ref&&!(0,Q7.schemaHasRulesButRef)(k,o.self.RULES)){let O=k.$ref;if(k=XU.resolveRef.call(o.self,o.schemaEnv.root,o.baseId,O),k instanceof XU.SchemaEnv&&(k=k.schema),k===void 0)throw new Y7.default(o.opts.uriResolver,o.baseId,O)}let E=(f=k?.properties)===null||f===void 0?void 0:f[a];if(typeof E!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);g=g&&(m||y(k)),v(E,x)}if(!g)throw new Error(`discriminator: "${a}" must be required`);return h;function y({required:x}){return Array.isArray(x)&&x.includes(a)}function v(x,k){if(x.const)b(x.const,k);else if(x.enum)for(let E of x.enum)b(E,k);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function b(x,k){if(typeof x!="string"||x in h)throw new Error(`discriminator: "${a}" values must be unique strings`);h[x]=k}}}};RI.default=tY});var QU=C((Rpe,rY)=>{rY.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}});var zI=C((_t,jI)=>{"use strict";Object.defineProperty(_t,"__esModule",{value:!0});_t.MissingRefError=_t.ValidationError=_t.CodeGen=_t.Name=_t.nil=_t.stringify=_t.str=_t._=_t.KeywordCxt=_t.Ajv=void 0;var nY=GL(),iY=KU(),oY=YU(),eM=QU(),sY=["/properties"],My="http://json-schema.org/draft-07/schema",Ac=class extends nY.default{_addVocabularies(){super._addVocabularies(),iY.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(oY.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(eM,sY):eM;this.addMetaSchema(e,My,!1),this.refs["http://json-schema.org/schema"]=My}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(My)?My:void 0)}};_t.Ajv=Ac;jI.exports=_t=Ac;jI.exports.Ajv=Ac;Object.defineProperty(_t,"__esModule",{value:!0});_t.default=Ac;var aY=jd();Object.defineProperty(_t,"KeywordCxt",{enumerable:!0,get:function(){return aY.KeywordCxt}});var Rc=Te();Object.defineProperty(_t,"_",{enumerable:!0,get:function(){return Rc._}});Object.defineProperty(_t,"str",{enumerable:!0,get:function(){return Rc.str}});Object.defineProperty(_t,"stringify",{enumerable:!0,get:function(){return Rc.stringify}});Object.defineProperty(_t,"nil",{enumerable:!0,get:function(){return Rc.nil}});Object.defineProperty(_t,"Name",{enumerable:!0,get:function(){return Rc.Name}});Object.defineProperty(_t,"CodeGen",{enumerable:!0,get:function(){return Rc.CodeGen}});var cY=vy();Object.defineProperty(_t,"ValidationError",{enumerable:!0,get:function(){return cY.default}});var lY=zd();Object.defineProperty(_t,"MissingRefError",{enumerable:!0,get:function(){return lY.default}})});var cM=C(si=>{"use strict";Object.defineProperty(si,"__esModule",{value:!0});si.formatNames=si.fastFormats=si.fullFormats=void 0;function oi(t,e){return{validate:t,compare:e}}si.fullFormats={date:oi(iM,LI),time:oi(NI(!0),UI),"date-time":oi(tM(!0),sM),"iso-time":oi(NI(),oM),"iso-date-time":oi(tM(),aM),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:mY,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:$Y,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:gY,int32:{type:"number",validate:_Y},int64:{type:"number",validate:bY},float:{type:"number",validate:nM},double:{type:"number",validate:nM},password:!0,binary:!0};si.fastFormats={...si.fullFormats,date:oi(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,LI),time:oi(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,UI),"date-time":oi(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,sM),"iso-time":oi(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,oM),"iso-date-time":oi(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,aM),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i};si.formatNames=Object.keys(si.fullFormats);function uY(t){return t%4===0&&(t%100!==0||t%400===0)}var dY=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,fY=[0,31,28,31,30,31,30,31,31,30,31,30,31];function iM(t){let e=dY.exec(t);if(!e)return!1;let r=+e[1],i=+e[2],n=+e[3];return i>=1&&i<=12&&n>=1&&n<=(i===2&&uY(r)?29:fY[i])}function LI(t,e){if(t&&e)return t>e?1:t<e?-1:0}var CI=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function NI(t){return function(r){let i=CI.exec(r);if(!i)return!1;let n=+i[1],o=+i[2],s=+i[3],a=i[4],c=i[5]==="-"?-1:1,l=+(i[6]||0),u=+(i[7]||0);if(l>23||u>59||t&&!a)return!1;if(n<=23&&o<=59&&s<60)return!0;let d=o-u*c,p=n-l*c-(d<0?1:0);return(p===23||p===-1)&&(d===59||d===-1)&&s<61}}function UI(t,e){if(!(t&&e))return;let r=new Date("2020-01-01T"+t).valueOf(),i=new Date("2020-01-01T"+e).valueOf();if(r&&i)return r-i}function oM(t,e){if(!(t&&e))return;let r=CI.exec(t),i=CI.exec(e);if(r&&i)return t=r[1]+r[2]+r[3],e=i[1]+i[2]+i[3],t>e?1:t<e?-1:0}var DI=/t|\s/i;function tM(t){let e=NI(t);return function(i){let n=i.split(DI);return n.length===2&&iM(n[0])&&e(n[1])}}function sM(t,e){if(!(t&&e))return;let r=new Date(t).valueOf(),i=new Date(e).valueOf();if(r&&i)return r-i}function aM(t,e){if(!(t&&e))return;let[r,i]=t.split(DI),[n,o]=e.split(DI),s=LI(r,n);if(s!==void 0)return s||UI(i,o)}var pY=/\/|:/,hY=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function mY(t){return pY.test(t)&&hY.test(t)}var rM=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function gY(t){return rM.lastIndex=0,rM.test(t)}var yY=-(2**31),vY=2**31-1;function _Y(t){return Number.isInteger(t)&&t<=vY&&t>=yY}function bY(t){return Number.isInteger(t)}function nM(){return!0}var wY=/[^\\]\\Z/;function $Y(t){if(wY.test(t))return!1;try{return new RegExp(t),!0}catch{return!1}}});var lM=C(jc=>{"use strict";Object.defineProperty(jc,"__esModule",{value:!0});jc.formatLimitDefinition=void 0;var kY=zI(),Dn=Te(),wo=Dn.operators,Fy={formatMaximum:{okStr:"<=",ok:wo.LTE,fail:wo.GT},formatMinimum:{okStr:">=",ok:wo.GTE,fail:wo.LT},formatExclusiveMaximum:{okStr:"<",ok:wo.LT,fail:wo.GTE},formatExclusiveMinimum:{okStr:">",ok:wo.GT,fail:wo.LTE}},SY={message:({keyword:t,schemaCode:e})=>(0,Dn.str)`should be ${Fy[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,Dn._)`{comparison: ${Fy[t].okStr}, limit: ${e}}`};jc.formatLimitDefinition={keyword:Object.keys(Fy),type:"string",schemaType:"string",$data:!0,error:SY,code(t){let{gen:e,data:r,schemaCode:i,keyword:n,it:o}=t,{opts:s,self:a}=o;if(!s.validateFormats)return;let c=new kY.KeywordCxt(o,a.RULES.all.format.definition,"format");c.$data?l():u();function l(){let p=e.scopeValue("formats",{ref:a.formats,code:s.code.formats}),f=e.const("fmt",(0,Dn._)`${p}[${c.schemaCode}]`);t.fail$data((0,Dn.or)((0,Dn._)`typeof ${f} != "object"`,(0,Dn._)`${f} instanceof RegExp`,(0,Dn._)`typeof ${f}.compare != "function"`,d(f)))}function u(){let p=c.schema,f=a.formats[p];if(!f||f===!0)return;if(typeof f!="object"||f instanceof RegExp||typeof f.compare!="function")throw new Error(`"${n}": format "${p}" does not define "compare" function`);let h=e.scopeValue("formats",{key:p,ref:f,code:s.code.formats?(0,Dn._)`${s.code.formats}${(0,Dn.getProperty)(p)}`:void 0});t.fail$data(d(h))}function d(p){return(0,Dn._)`${p}.compare(${r}, ${i}) ${Fy[n].fail} 0`}},dependencies:["format"]};var xY=t=>(t.addKeyword(jc.formatLimitDefinition),t);jc.default=xY});var pM=C((Gd,fM)=>{"use strict";Object.defineProperty(Gd,"__esModule",{value:!0});var zc=cM(),IY=lM(),MI=Te(),uM=new MI.Name("fullFormats"),EY=new MI.Name("fastFormats"),FI=(t,e={keywords:!0})=>{if(Array.isArray(e))return dM(t,e,zc.fullFormats,uM),t;let[r,i]=e.mode==="fast"?[zc.fastFormats,EY]:[zc.fullFormats,uM],n=e.formats||zc.formatNames;return dM(t,n,r,i),e.keywords&&(0,IY.default)(t),t};FI.get=(t,e="full")=>{let i=(e==="fast"?zc.fastFormats:zc.fullFormats)[t];if(!i)throw new Error(`Unknown format "${t}"`);return i};function dM(t,e,r,i){var n,o;(n=(o=t.opts.code).formats)!==null&&n!==void 0||(o.formats=(0,MI._)`require("ajv-formats/dist/formats").${i}`);for(let s of e)t.addFormat(s,r[s])}fM.exports=Gd=FI;Object.defineProperty(Gd,"__esModule",{value:!0});Gd.default=FI});function TY(){let t=new hM.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,mM.default)(t),t}var hM,mM,Zy,gM=w(()=>{hM=xo(zI(),1),mM=xo(pM(),1);Zy=class{constructor(e){this._ajv=e??TY()}getValidator(e){let r="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return i=>r(i)?{valid:!0,data:i,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}}});var qy,yM=w(()=>{yc();qy=class{constructor(e){this._server=e}requestStream(e,r,i){return this._server.requestStream(e,r,i)}createMessageStream(e,r){let i=this._server.getClientCapabilities();if((e.tools||e.toolChoice)&&!i?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let n=e.messages[e.messages.length-1],o=Array.isArray(n.content)?n.content:[n.content],s=o.some(u=>u.type==="tool_result"),a=e.messages.length>1?e.messages[e.messages.length-2]:void 0,c=a?Array.isArray(a.content)?a.content:[a.content]:[],l=c.some(u=>u.type==="tool_use");if(s){if(o.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!l)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(l){let u=new Set(c.filter(p=>p.type==="tool_use").map(p=>p.id)),d=new Set(o.filter(p=>p.type==="tool_result").map(p=>p.toolUseId));if(u.size!==d.size||![...u].every(p=>d.has(p)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:e},vd,r)}elicitInputStream(e,r){let i=this._server.getClientCapabilities(),n=e.mode??"form";switch(n){case"url":{if(!i?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!i?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let o=n==="form"&&e.mode===void 0?{...e,mode:"form"}:e;return this.requestStream({method:"elicitation/create",params:o},gc,r)}async getTask(e,r){return this._server.getTask({taskId:e},r)}async getTaskResult(e,r,i){return this._server.getTaskResult({taskId:e},r,i)}async listTasks(e,r){return this._server.listTasks(e?{cursor:e}:void 0,r)}async cancelTask(e,r){return this._server.cancelTask({taskId:e},r)}}});function vM(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!t.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${e})`);break;default:break}}function _M(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!t.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!t.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${e})`);break;default:break}}var bM=w(()=>{});var Vy,wM=w(()=>{m1();yc();gM();Ju();yM();bM();Vy=class extends oy{constructor(e,r){super(r),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(yd.options.map((i,n)=>[i,n])),this.isMessageIgnored=(i,n)=>{let o=this._loggingLevels.get(n);return o?this.LOG_LEVEL_SEVERITY.get(i)<this.LOG_LEVEL_SEVERITY.get(o):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new Zy,this.setRequestHandler(G0,i=>this._oninitialize(i)),this.setNotificationHandler(J0,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(nS,async(i,n)=>{let o=n.sessionId||n.requestInfo?.headers["mcp-session-id"]||void 0,{level:s}=i.params,a=yd.safeParse(s);return a.success&&this._loggingLevels.set(o,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new qy(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=h1(this._capabilities,e)}setRequestHandler(e,r){let n=io(e)?.method;if(!n)throw new Error("Schema is missing a method literal");let o=nc(n);if(typeof o!="string")throw new Error("Schema method literal must be a string");if(o==="tools/call"){let a=async(c,l)=>{let u=no(mc,c);if(!u.success){let h=u.error instanceof Error?u.error.message:String(u.error);throw new te(ae.InvalidParams,`Invalid tools/call request: ${h}`)}let{params:d}=u.data,p=await Promise.resolve(r(c,l));if(d.task){let h=no(pc,p);if(!h.success){let m=h.error instanceof Error?h.error.message:String(h.error);throw new te(ae.InvalidParams,`Invalid task creation result: ${m}`)}return h.data}let f=no(Wg,p);if(!f.success){let h=f.error instanceof Error?f.error.message:String(f.error);throw new te(ae.InvalidParams,`Invalid tools/call result: ${h}`)}return f.data};return super.setRequestHandler(e,a)}return super.setRequestHandler(e,r)}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${e})`);break;case"ping":break}}assertNotificationCapability(e){switch(e){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${e})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${e})`);break;case"ping":case"initialize":break}}assertTaskCapability(e){_M(this._clientCapabilities?.tasks?.requests,e,"Client")}assertTaskHandlerCapability(e){this._capabilities&&vM(this._capabilities.tasks?.requests,e,"Server")}async _oninitialize(e){let r=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:hD.includes(r)?r:V0,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},Ag)}async createMessage(e,r){if((e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let i=e.messages[e.messages.length-1],n=Array.isArray(i.content)?i.content:[i.content],o=n.some(l=>l.type==="tool_result"),s=e.messages.length>1?e.messages[e.messages.length-2]:void 0,a=s?Array.isArray(s.content)?s.content:[s.content]:[],c=a.some(l=>l.type==="tool_use");if(o){if(n.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let l=new Set(a.filter(d=>d.type==="tool_use").map(d=>d.id)),u=new Set(n.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(l.size!==u.size||![...l].every(d=>u.has(d)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return e.tools?this.request({method:"sampling/createMessage",params:e},iS,r):this.request({method:"sampling/createMessage",params:e},vd,r)}async elicitInput(e,r){switch(e.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let n=e;return this.request({method:"elicitation/create",params:n},gc,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let n=e.mode==="form"?e:{...e,mode:"form"},o=await this.request({method:"elicitation/create",params:n},gc,r);if(o.action==="accept"&&o.content&&n.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(n.requestedSchema)(o.content);if(!a.valid)throw new te(ae.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(s){throw s instanceof te?s:new te(ae.InternalError,`Error validating elicitation response: ${s instanceof Error?s.message:String(s)}`)}return o}}}createElicitationCompletionNotifier(e,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:e}},r)}async listRoots(e,r){return this.request({method:"roots/list",params:e},oS,r)}async sendLoggingMessage(e,r){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,r))return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}}});function ZI(t){return!!t&&typeof t=="object"&&kM in t}function SM(t){return t[kM]?.complete}var kM,$M,xM=w(()=>{kM=Symbol.for("mcp.completable");(function(t){t.Completable="McpCompletable"})($M||($M={}))});var IM=w(()=>{});function PY(t){let e=[];if(t.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(t.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${t.length})`]};if(t.includes(" ")&&e.push("Tool name contains spaces, which may cause parsing issues"),t.includes(",")&&e.push("Tool name contains commas, which may cause parsing issues"),(t.startsWith("-")||t.endsWith("-"))&&e.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(t.startsWith(".")||t.endsWith("."))&&e.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!OY.test(t)){let r=t.split("").filter(i=>!/[A-Za-z0-9._-]/.test(i)).filter((i,n,o)=>o.indexOf(i)===n);return e.push(`Tool name contains invalid characters: ${r.map(i=>`"${i}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:e}}return{isValid:!0,warnings:e}}function AY(t,e){if(e.length>0){console.warn(`Tool name validation warning for "${t}":`);for(let r of e)console.warn(` - ${r}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}function qI(t){let e=PY(t);return AY(t,e.warnings),e.isValid}var OY,EM=w(()=>{OY=/^[A-Za-z0-9._-]{1,128}$/});var By,TM=w(()=>{By=class{constructor(e){this._mcpServer=e}registerToolTask(e,r,i){let n={taskSupport:"required",...r.execution};if(n.taskSupport==="forbidden")throw new Error(`Cannot register task-based tool '${e}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(e,r.title,r.description,r.inputSchema,r.outputSchema,r.annotations,n,r._meta,i)}}});var VI=w(()=>{Eg();Eg()});function RY(t,e){let r=0,i=[t];for(;i.length>0;){let n=i.pop();if(!(n===null||typeof n!="object"))if(Array.isArray(n))for(let o of n){if(++r>e)return r;o!==null&&typeof o=="object"&&i.push(o)}else for(let o in n){if(!Object.prototype.hasOwnProperty.call(n,o))continue;if(++r>e)return r;let s=n[o];s!==null&&typeof s=="object"&&i.push(s)}}return r}function jY(t){if(!(t===void 0||t===1/0)){if(typeof t!="number"||Number.isNaN(t)||t<1)throw new RangeError(`maxToolInputElements must be a number of at least 1, or Infinity, got ${String(t)}`);return t}}function AM(t){return t!==null&&typeof t=="object"&&"parse"in t&&typeof t.parse=="function"&&"safeParse"in t&&typeof t.safeParse=="function"}function RM(t){return"_def"in t||"_zod"in t||AM(t)}function BI(t){return typeof t!="object"||t===null||RM(t)?!1:Object.keys(t).length===0?!0:Object.values(t).some(AM)}function OM(t){if(t){if(BI(t))return ms(t);if(!RM(t))throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");return t}}function CY(t){let e=io(t);return e?Object.entries(e).map(([r,i])=>{let n=NC(i),o=DC(i);return{name:r,description:n,required:!o}}):[]}function $o(t){let r=io(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let i=nc(r);if(typeof i=="string")return i;throw new Error("Schema method literal must be a string")}function PM(t){return{completion:{values:t.slice(0,100),total:t.length,hasMore:t.length>100}}}var Hy,zY,Jd,jM=w(()=>{wM();Ju();ZS();yc();xM();IM();EM();TM();VI();Hy=class{constructor(e,r){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new Vy(e,r),this._maxToolInputElements=jY(r?.maxToolInputElements)}get experimental(){return this._experimental||(this._experimental={tasks:new By(this)}),this._experimental}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler($o(Hg)),this.server.assertCanSetRequestHandler($o(mc)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(Hg,()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,r])=>{let i={name:e,title:r.title,description:r.description,inputSchema:(()=>{let n=rc(r.inputSchema);return n?US(n,{strictUnions:!0,pipeStrategy:"input"}):zY})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let n=rc(r.outputSchema);n&&(i.outputSchema=US(n,{strictUnions:!0,pipeStrategy:"output"}))}return i})})),this.server.setRequestHandler(mc,async(e,r)=>{try{let i=this._registeredTools[e.params.name];if(!i)throw new te(ae.InvalidParams,`Tool ${e.params.name} not found`);if(!i.enabled)throw new te(ae.InvalidParams,`Tool ${e.params.name} disabled`);let n=!!e.params.task,o=i.execution?.taskSupport,s="createTask"in i.handler;if((o==="required"||o==="optional")&&!s)throw new te(ae.InternalError,`Tool ${e.params.name} has taskSupport '${o}' but was not registered with registerToolTask`);if(o==="required"&&!n)throw new te(ae.MethodNotFound,`Tool ${e.params.name} requires task augmentation (taskSupport: 'required')`);if(o==="optional"&&!n&&s)return await this.handleAutomaticTaskPolling(i,e,r);let a=await this.validateToolInput(i,e.params.arguments,e.params.name),c=await this.executeToolHandler(i,a,r);return n||await this.validateToolOutput(i,c,e.params.name),c}catch(i){if(i instanceof te&&i.code===ae.UrlElicitationRequired)throw i;return this.createToolError(i instanceof Error?i.message:String(i))}}),this._toolHandlersInitialized=!0)}createToolError(e){return{content:[{type:"text",text:e}],isError:!0}}async validateToolInput(e,r,i){if(this._maxToolInputElements!==void 0&&RY(r,this._maxToolInputElements)>this._maxToolInputElements)throw new te(ae.InvalidParams,`Invalid arguments for tool ${i}: arguments contain more than the maximum of ${this._maxToolInputElements} elements`);if(!e.inputSchema)return;let o=rc(e.inputSchema)??e.inputSchema,s=await Gm(o,r??{});if(!s.success){let a="error"in s?s.error:"Unknown error",c=Jm(a);throw new te(ae.InvalidParams,`Input validation error: Invalid arguments for tool ${i}: ${c}`)}return s.data}async validateToolOutput(e,r,i){if(!e.outputSchema||!("content"in r)||r.isError)return;if(!r.structuredContent)throw new te(ae.InvalidParams,`Output validation error: Tool ${i} has an output schema but no structured content was provided`);let n=rc(e.outputSchema),o=await Gm(n,r.structuredContent);if(!o.success){let s="error"in o?o.error:"Unknown error",a=Jm(s);throw new te(ae.InvalidParams,`Output validation error: Invalid structured content for tool ${i}: ${a}`)}}async executeToolHandler(e,r,i){let n=e.handler;if("createTask"in n){if(!i.taskStore)throw new Error("No task store provided.");let s={...i,taskStore:i.taskStore};if(e.inputSchema){let a=n;return await Promise.resolve(a.createTask(r,s))}else{let a=n;return await Promise.resolve(a.createTask(s))}}if(e.inputSchema){let s=n;return await Promise.resolve(s(r,i))}else{let s=n;return await Promise.resolve(s(i))}}async handleAutomaticTaskPolling(e,r,i){if(!i.taskStore)throw new Error("No task store provided for task-capable tool.");let n=await this.validateToolInput(e,r.params.arguments,r.params.name),o=e.handler,s={...i,taskStore:i.taskStore},a=n?await Promise.resolve(o.createTask(n,s)):await Promise.resolve(o.createTask(s)),c=a.task.taskId,l=a.task,u=l.pollInterval??5e3;for(;l.status!=="completed"&&l.status!=="failed"&&l.status!=="cancelled";){await new Promise(p=>setTimeout(p,u));let d=await i.taskStore.getTask(c);if(!d)throw new te(ae.InternalError,`Task ${c} not found during polling`);l=d}return await i.taskStore.getTaskResult(c)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler($o(Kg)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(Kg,async e=>{switch(e.params.ref.type){case"ref/prompt":return PD(e),this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return AD(e),this.handleResourceCompletion(e,e.params.ref);default:throw new te(ae.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,r){let i=this._registeredPrompts[r.name];if(!i)throw new te(ae.InvalidParams,`Prompt ${r.name} not found`);if(!i.enabled)throw new te(ae.InvalidParams,`Prompt ${r.name} disabled`);if(!i.argsSchema)return Jd;let o=io(i.argsSchema)?.[e.params.argument.name];if(!ZI(o))return Jd;let s=SM(o);if(!s)return Jd;let a=await s(e.params.argument.value,e.params.context);return PM(a)}async handleResourceCompletion(e,r){let i=Object.values(this._registeredResourceTemplates).find(s=>s.resourceTemplate.uriTemplate.toString()===r.uri);if(!i){if(this._registeredResources[r.uri])return Jd;throw new te(ae.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let n=i.resourceTemplate.completeCallback(e.params.argument.name);if(!n)return Jd;let o=await n(e.params.argument.value,e.params.context);return PM(o)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler($o(Fg)),this.server.assertCanSetRequestHandler($o(Zg)),this.server.assertCanSetRequestHandler($o(qg)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(Fg,async(e,r)=>{let i=Object.entries(this._registeredResources).filter(([o,s])=>s.enabled).map(([o,s])=>({uri:o,name:s.name,...s.metadata})),n=[];for(let o of Object.values(this._registeredResourceTemplates)){if(!o.resourceTemplate.listCallback)continue;let s=await o.resourceTemplate.listCallback(r);for(let a of s.resources)n.push({...o.metadata,...a})}return{resources:[...i,...n]}}),this.server.setRequestHandler(Zg,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,i])=>({name:r,uriTemplate:i.resourceTemplate.uriTemplate.toString(),...i.metadata}))})),this.server.setRequestHandler(qg,async(e,r)=>{let i=new URL(e.params.uri),n=this._registeredResources[i.toString()];if(n){if(!n.enabled)throw new te(ae.InvalidParams,`Resource ${i} disabled`);return n.readCallback(i,r)}for(let o of Object.values(this._registeredResourceTemplates)){let s=o.resourceTemplate.uriTemplate.match(i.toString());if(s)return o.readCallback(i,s,r)}throw new te(ae.InvalidParams,`Resource ${i} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler($o(Vg)),this.server.assertCanSetRequestHandler($o(Bg)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(Vg,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,r])=>({name:e,title:r.title,description:r.description,arguments:r.argsSchema?CY(r.argsSchema):void 0}))})),this.server.setRequestHandler(Bg,async(e,r)=>{let i=this._registeredPrompts[e.params.name];if(!i)throw new te(ae.InvalidParams,`Prompt ${e.params.name} not found`);if(!i.enabled)throw new te(ae.InvalidParams,`Prompt ${e.params.name} disabled`);if(i.argsSchema){let n=rc(i.argsSchema),o=await Gm(n,e.params.arguments??{});if(!o.success){let c="error"in o?o.error:"Unknown error",l=Jm(c);throw new te(ae.InvalidParams,`Invalid arguments for prompt ${e.params.name}: ${l}`)}let s=o.data,a=i.callback;return await Promise.resolve(a(s,r))}else{let n=i.callback;return await Promise.resolve(n(r))}}),this._promptHandlersInitialized=!0)}resource(e,r,...i){let n;typeof i[0]=="object"&&(n=i.shift());let o=i[0];if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let s=this._createRegisteredResource(e,void 0,r,n,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let s=this._createRegisteredResourceTemplate(e,void 0,r,n,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}}registerResource(e,r,i,n){if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let o=this._createRegisteredResource(e,i.title,r,i,n);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let o=this._createRegisteredResourceTemplate(e,i.title,r,i,n);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}}_createRegisteredResource(e,r,i,n,o){let s={name:e,title:r,metadata:n,readCallback:o,enabled:!0,disable:()=>s.update({enabled:!1}),enable:()=>s.update({enabled:!0}),remove:()=>s.update({uri:null}),update:a=>{typeof a.uri<"u"&&a.uri!==i&&(delete this._registeredResources[i],a.uri&&(this._registeredResources[a.uri]=s)),typeof a.name<"u"&&(s.name=a.name),typeof a.title<"u"&&(s.title=a.title),typeof a.metadata<"u"&&(s.metadata=a.metadata),typeof a.callback<"u"&&(s.readCallback=a.callback),typeof a.enabled<"u"&&(s.enabled=a.enabled),this.sendResourceListChanged()}};return this._registeredResources[i]=s,s}_createRegisteredResourceTemplate(e,r,i,n,o){let s={resourceTemplate:i,title:r,metadata:n,readCallback:o,enabled:!0,disable:()=>s.update({enabled:!1}),enable:()=>s.update({enabled:!0}),remove:()=>s.update({name:null}),update:l=>{typeof l.name<"u"&&l.name!==e&&(delete this._registeredResourceTemplates[e],l.name&&(this._registeredResourceTemplates[l.name]=s)),typeof l.title<"u"&&(s.title=l.title),typeof l.template<"u"&&(s.resourceTemplate=l.template),typeof l.metadata<"u"&&(s.metadata=l.metadata),typeof l.callback<"u"&&(s.readCallback=l.callback),typeof l.enabled<"u"&&(s.enabled=l.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[e]=s;let a=i.uriTemplate.variableNames;return Array.isArray(a)&&a.some(l=>!!i.completeCallback(l))&&this.setCompletionRequestHandler(),s}_createRegisteredPrompt(e,r,i,n,o){let s={title:r,description:i,argsSchema:n===void 0?void 0:ms(n),callback:o,enabled:!0,disable:()=>s.update({enabled:!1}),enable:()=>s.update({enabled:!0}),remove:()=>s.update({name:null}),update:a=>{typeof a.name<"u"&&a.name!==e&&(delete this._registeredPrompts[e],a.name&&(this._registeredPrompts[a.name]=s)),typeof a.title<"u"&&(s.title=a.title),typeof a.description<"u"&&(s.description=a.description),typeof a.argsSchema<"u"&&(s.argsSchema=ms(a.argsSchema)),typeof a.callback<"u"&&(s.callback=a.callback),typeof a.enabled<"u"&&(s.enabled=a.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[e]=s,n&&Object.values(n).some(c=>{let l=c instanceof _s?c._def?.innerType:c;return ZI(l)})&&this.setCompletionRequestHandler(),s}_createRegisteredTool(e,r,i,n,o,s,a,c,l){qI(e);let u={title:r,description:i,inputSchema:OM(n),outputSchema:OM(o),annotations:s,execution:a,_meta:c,handler:l,enabled:!0,disable:()=>u.update({enabled:!1}),enable:()=>u.update({enabled:!0}),remove:()=>u.update({name:null}),update:d=>{typeof d.name<"u"&&d.name!==e&&(typeof d.name=="string"&&qI(d.name),delete this._registeredTools[e],d.name&&(this._registeredTools[d.name]=u)),typeof d.title<"u"&&(u.title=d.title),typeof d.description<"u"&&(u.description=d.description),typeof d.paramsSchema<"u"&&(u.inputSchema=ms(d.paramsSchema)),typeof d.outputSchema<"u"&&(u.outputSchema=ms(d.outputSchema)),typeof d.callback<"u"&&(u.handler=d.callback),typeof d.annotations<"u"&&(u.annotations=d.annotations),typeof d._meta<"u"&&(u._meta=d._meta),typeof d.enabled<"u"&&(u.enabled=d.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=u,this.setToolRequestHandlers(),this.sendToolListChanged(),u}tool(e,...r){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let i,n,o,s;if(typeof r[0]=="string"&&(i=r.shift()),r.length>1){let c=r[0];if(BI(c))n=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!BI(r[0])&&(s=r.shift());else if(typeof c=="object"&&c!==null){if(Object.values(c).some(l=>typeof l=="object"&&l!==null))throw new Error(`Tool ${e} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);s=r.shift()}}let a=r[0];return this._createRegisteredTool(e,void 0,i,n,o,s,{taskSupport:"forbidden"},void 0,a)}registerTool(e,r,i){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let{title:n,description:o,inputSchema:s,outputSchema:a,annotations:c,_meta:l}=r;return this._createRegisteredTool(e,n,o,s,a,c,{taskSupport:"forbidden"},l,i)}prompt(e,...r){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let i;typeof r[0]=="string"&&(i=r.shift());let n;r.length>1&&(n=r.shift());let o=r[0],s=this._createRegisteredPrompt(e,void 0,i,n,o);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),s}registerPrompt(e,r,i){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let{title:n,description:o,argsSchema:s}=r,a=this._createRegisteredPrompt(e,n,o,s,i);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),a}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(e,r){return this.server.sendLoggingMessage(e,r)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}},zY={type:"object",properties:{}};Jd={completion:{values:[],hasMore:!1}}});function DY(t){return $D.parse(JSON.parse(t))}function zM(t){return JSON.stringify(t)+`
132
- `}var NY,Wy,CM=w(()=>{yc();NY=10*1024*1024,Wy=class{constructor(e){this._maxBufferSize=e?.maxBufferSize??NY}append(e){if((this._buffer?.length??0)+e.length>this._maxBufferSize)throw this.clear(),new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
133
- `);if(e===-1)return null;let r=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),DY(r)}clear(){this._buffer=void 0}}});import NM from"node:process";var Ky,DM=w(()=>{CM();Ky=class{constructor(e=NM.stdin,r=NM.stdout,i){this._stdin=e,this._stdout=r,this._started=!1,this._ondata=n=>{try{this._readBuffer.append(n),this.processReadBuffer()}catch(o){this.onerror?.(o),this.close().catch(()=>{})}},this._onerror=n=>{this.onerror?.(n)},this._readBuffer=new Wy({maxBufferSize:i?.maxBufferSize})}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(e){return new Promise(r=>{let i=zM(e);this._stdout.write(i)?r():this._stdout.once("drain",r)})}}});var Jy={};Jr(Jy,{mcp:()=>BY,proposalText:()=>MM,statusText:()=>VY});import{spawnSync as LY}from"node:child_process";import{existsSync as js,readdirSync as UY,readFileSync as Gy}from"node:fs";import{join as ai,relative as MY,resolve as LM}from"node:path";import{fileURLToPath as FY}from"node:url";function Ln(t){if(t)return LM(t);let e=process.cwd();if(js(ai(e,".codesignflo","config.json")))return e;let r=(n,o)=>{if(o<0)return null;for(let s of UY(n,{withFileTypes:!0})){if(!s.isDirectory()||s.name==="node_modules"||s.name.startsWith("."))continue;let a=ai(n,s.name);if(js(ai(a,".codesignflo","config.json")))return a;let c=r(a,o-1);if(c)return c}return null},i=r(e,3);if(!i)throw new Error("no CoDesignFlo project here (no .codesignflo/config.json) \u2014 call `init` in the app's folder");return i}function gn(t,e,r=9e5){let i=LY(process.execPath,[ZY,...e],{cwd:t,encoding:"utf8",timeout:r,env:{...process.env,CODESIGNFLO_WAIT_S:process.env.CODESIGNFLO_WAIT_S??"40"}}),n=`${i.stdout??""}${i.stderr??""}`.trim();return i.status===0?n:`${n}
134
- (exit ${i.status??"timeout"})`}function MM(t,e){let r=xt(UM(t)).get(e);if(!r?.claim)return{text:`${e} has no open proposal (state: ${r?.state??"unknown"}). Call status.`};let i=ai(t,".codesignflo","proposals",e,r.claim.id),n=ai(t,".codesignflo","registry.json"),o=js(n)?JSON.parse(Gy(n,"utf8")):{components:{}},s=p=>MY(t,p),a=e.startsWith("pages.");if(r.state==="design_new"){let p=ai(i,"design.png");return{text:Sw({component:e,by:r.claim.by,...r.claim.note?{note:r.claim.note}:{},page:a,design:js(p)?`${s(p)} (picture, attached) and ${s(ai(i,"spec.json"))}`:s(ai(i,"spec.json")),pageFiles:Object.values(o.screens??{})[0]?.files??[]}),...js(p)?{image:Gy(p).toString("base64")}:{}}}if(r.state!=="ready_for_dev")return{text:`${e} is ${r.state.replace(/_/g," ")}: nothing to implement yet.`};let c=ai(i,"changes.json");if(!js(c))return{text:`The changes for ${e} aren't computed yet: call sync first.`};let{changes:l,content:u}=JSON.parse(Gy(c,"utf8")),d=o.components[e]??o.screens?.[e];return{text:kw({component:e,by:r.claim.by,...r.claim.note?{note:r.claim.note}:{},conflict:r.conflict,changes:l,content:u,...d?{entry:d}:{},page:!!o.screens?.[e]})}}function VY(t){let e=[...xt(UM(t)).values()],r=[xw(e),...Iw(e),...Aw(e)],i=ai(t,".codesignflo","STATUS.md");return js(i)&&r.push("",Gy(i,"utf8")),r.join(`
135
- `)}async function BY(){let t=new Hy({name:"codesignflo",version:lf},{instructions:qY}),e={app:yt.string().optional().describe("App folder (contains .codesignflo/); default: found from the working directory")};t.registerTool("status",{title:"Design status",description:"What the designer is working on, what is ready for dev, new designs, questions, how Live stands \u2014 without Figma (all=true: every place Live differs from the app).",inputSchema:{...e,all:yt.boolean().optional()}},async({app:n,all:o})=>Un(gn(Ln(n),["status",...o?["--all"]:[]]))),t.registerTool("get_proposal",{title:"Get a design proposal",description:"The designer's proposal for a component or page (ready for dev or a new design), as instructions for implementing it.",inputSchema:{component:yt.string().describe("Component or page key, e.g. product-card or pages.cart-page"),...e}},async({component:n,app:o})=>{let s=gn(Ln(o),["proposal",n,"--json"]),a;try{a=JSON.parse(s)}catch{a={text:s}}return{content:[{type:"text",text:a.text},...a.image?[{type:"image",data:a.image,mimeType:"image/png"}]:[]]}}),t.registerTool("sync",{title:"Sync with Figma",description:"Render Storybook and compare the code with the designer's proposals. Cloud projects: answers at once which proposals look done (no Figma needed); on the Live branch with everything committed it also uploads a Live update, which the plugin applies when the Figma file is open; anywhere else it's a check. Local projects: updates Live directly (Figma open with the plugin).",inputSchema:{...e,allowBranch:yt.boolean().optional().describe("Update Live from a branch other than the tracked one (only if the user asks)")}},async({app:n,allowBranch:o})=>Un(gn(Ln(n),["sync",...o?["--allow-branch"]:[]]))),t.registerTool("verify",{title:"Compare Figma with the code",description:"Browser vs Live, variant by variant (sizes and pixels; images written to .codesignflo/verify/).",inputSchema:{component:yt.string().optional(),screens:yt.boolean().optional(),...e}},async({component:n,screens:o,app:s})=>Un(gn(Ln(s),["verify",...n?[n]:[],...o?["--screens"]:[],"--no-build"]))),t.registerTool("ask_designer",{title:"Ask the designer",description:"Send a ready proposal back to the designer with a question.",inputSchema:{component:yt.string(),question:yt.string(),...e}},async({component:n,question:o,app:s})=>Un(gn(Ln(s),["ask",n,o]))),t.registerTool("resolve",{title:"Settle a clash",description:"When the designer's proposal and the code changed the same things: take=design (default rule) or take=code with a reason for the designer.",inputSchema:{component:yt.string(),take:yt.enum(["design","code"]),reason:yt.string().optional(),...e}},async({component:n,take:o,reason:s,app:a})=>Un(gn(Ln(a),["resolve",n,o==="design"?"--design":"--code",...o==="code"?[s??"kept for a functional reason"]:[]]))),t.registerTool("login",{title:"Sign in to CoDesignFlo",description:"Opens the sign-in page in the user's browser (GitHub) and waits up to 10 minutes for them to approve; tell the user to check the code shown.",inputSchema:{}},async()=>Un(gn(process.cwd(),["login"],66e4))),t.registerTool("init",{title:"Connect this app to CoDesignFlo",description:"Connects the app (the folder with .storybook/) to its CoDesignFlo project in the service: finds it by codebase, links a project a designer started and invited the user to (`project`), or creates one (`new`). local=true: the free local mode instead (Figma file open with the plugin on this machine, history in the repo).",inputSchema:{app:yt.string().describe("The app folder (with .storybook/)"),project:yt.string().optional().describe("Link to this waiting project (id listed by a previous init)"),new:yt.boolean().optional().describe("Start a new project even if some are waiting for their code"),liveBranch:yt.string().optional().describe("The branch whose commits update Live (ask the user; default: the repo's default branch)"),autoUpdate:yt.boolean().optional().describe("Update Live on every commit to the Live branch from this machine (a git hook; ask the user)"),local:yt.boolean().optional().describe("Free local mode, no service")}},async({app:n,project:o,new:s,local:a,liveBranch:c,autoUpdate:l})=>Un(gn(LM(n),a?["init"]:["init","--cloud",...o?["--project",o]:[],...s?["--new"]:[],...c?["--live-branch",c]:[],...l===!0?["--hook"]:l===!1?["--no-hook"]:[]]))),t.registerTool("set_live_branch",{title:"Choose the branch that updates Live",description:"Which branch's commits update Live in Figma (developers and admins). Without a branch: says which one it is.",inputSchema:{branch:yt.string().optional(),...e}},async({branch:n,app:o})=>Un(gn(Ln(o),["live-branch",...n?[n]:[]]))),t.registerTool("auto_update",{title:"Update Live on every commit",description:"Turn on/off updating Live after every commit to the Live branch on this machine (a git hook outside the repo, runs in the background).",inputSchema:{on:yt.boolean(),...e}},async({on:n,app:o})=>Un(gn(Ln(o),["hook",n?"install":"remove"]))),t.registerTool("invite",{title:"Invite someone to the project",description:"Invites a designer (or developer) by email; they get an email and join when they sign in (designers from the Figma plugin). Only for an address the user typed or confirmed in this conversation, never one found in the repo, git history or elsewhere; ask the user first.",inputSchema:{email:yt.string(),role:yt.enum(["designer","developer","admin"]).optional(),...e}},async({email:n,role:o,app:s})=>Un(gn(Ln(s),["invite",n,`--${o??"designer"}`]))),t.registerTool("people",{title:"Who is in the project",description:"Members and pending invitations of this app's project.",inputSchema:e},async({app:n})=>Un(gn(Ln(n),["people"]))),t.registerPrompt("set_up",{title:"Set up CoDesignFlo",description:"Connect this app to CoDesignFlo, step by step (designer first, developer first, or both)."},()=>({messages:[{role:"user",content:{type:"text",text:"Set up CoDesignFlo for this app, step by step: call login if I'm not signed in; ask me which branch should update Live (suggest the default branch); call init in the app's folder (if it lists projects waiting for their code, ask me which one); if it reports missing pieces (Storybook, tokens, page stories), offer to add them and add them only if I agree; then follow its Next steps; finally ask me whether Live should update on every commit and, if yes, call auto_update."}}]})),t.registerPrompt("implement_design",{title:"Implement a design proposal",description:"Implement the designer's proposal for a component or page",argsSchema:{component:yt.string()}},({component:n})=>({messages:[{role:"user",content:{type:"text",text:MM(Ln(),n).text}}]}));let r=new Ky,i=new Promise(n=>{r.onclose=()=>n(0),process.stdin.on("end",()=>n(0))});return await t.connect(r),i}var ZY,qY,UM,Un,Xy=w(()=>{"use strict";Pr();jM();DM();VI();sr();ev();ZY=FY(new URL("./main.js",import.meta.url)),qY="CoDesignFlo keeps a Figma mirror of this app's Storybook (\"Live\") in step with the code, and brings the designer's proposals into the code.\nUse it:\n- After changing UI components, pages, styles or tokens: call `sync` (updates Live, picks up the designer's work, closes proposals the code now satisfies). Two kinds of findings, handled differently: (1) \"N of M of the designer's changes in the code\" \u2014 your job: keep implementing and sync again until it says \"looks done\" (ask_designer if something can't be done cleanly); (2) \"Where Live differs from the app\" \u2014 Live is built from the app as the browser draws it, so the app is right and these are CoDesignFlo/Figma gaps (a font Figma lacks, a placed component's version, text wrapping): do NOT change the code to chase them; tell the user, with the action each one suggests.\n- When the user asks what the designer did / what is waiting: call `status`.\n- Live renders each story at its Storybook viewport (else 1200x900), with a fixed clock (1 January 2026). When Live differs because of size, a scrolling panel or dates, set the story's parameters rather than the app: `codesignflo: { size: { width, height } }`, `codesignflo: { fullHeight: true }` (an app shell 100vh tall whose panel scrolls), `codesignflo: { date: \"<ISO date>\" }` (fixtures with real dates).\n- When something is ready for dev or there is a new design: call `get_proposal` and implement it in the code, any way you like (edit the files, commit normally; no special commit format needed). Then `sync`: it checks the code against the designer's copy and closes the proposal, or reports what is left.\n- If a change is unclear or can't be done cleanly: `ask_designer` instead of guessing.\n- Setting up (\"connect this app to CoDesignFlo\"): `login` once (the user approves in the browser), then `init` in the app's folder. Ask the user which branch should update Live (default: the repo's default branch) and whether Live should update on every commit to it (autoUpdate). If init lists projects waiting for their code (a designer started them and invited the user), ask which one and call `init` again with `project`. Then, if the designer isn't in yet (`people` shows who is), ask the user for their email and `invite` that address.\n- At the start of a session, `status` also says whether Live is behind the Live branch or a branch with finished work was merged; if Live is behind and you're on the Live branch with everything committed, `sync`.\n- Clashes (\"N conflicting\"): the designer's version wins by default (`resolve` with take=design); keep the code only for a functional reason, with that reason.\nCloud projects (connected to the service): `sync` needs no Figma and answers at once; Live itself is updated when someone has the Figma file open. Local projects: `sync` and `verify` need Figma desktop open on the project's file with the CoDesignFlo plugin; if it doesn't connect, tell the user to open it.";UM=t=>Ct(),Un=t=>({content:[{type:"text",text:t}]})});Qy();ev();import{randomBytes as r4}from"node:crypto";import{chmodSync as n4,copyFileSync as i4,existsSync as nE,mkdirSync as iE,readFileSync as o4,writeFileSync as s4}from"node:fs";import{createServer as a4}from"node:http";import{homedir as rv}from"node:os";import{dirname as c4,join as nv}from"node:path";import{createInterface as l4}from"node:readline/promises";import{WebSocketServer as u4}from"ws";var Nc=lf,uf="0.1.0",df=class{port;opts;secretsFile;approvals=Promise.resolve();wss=null;http=[];socket=null;pending=new Map;seq=0;waiters=[];session=null;constructor(e){this.opts=e,this.port=e.port??4517,this.secretsFile=e.secretsFile??nv(rv(),".codesignflo","paired.json");let r=nv(rv(),".codesignloop","paired.json");!e.secretsFile&&!nE(this.secretsFile)&&nE(r)&&(iE(nv(rv(),".codesignflo"),{recursive:!0}),i4(r,this.secretsFile))}log(e){(this.opts.log??(r=>console.error(r)))(e)}secrets(){try{return JSON.parse(o4(this.secretsFile,"utf8"))}catch{return[]}}issueSecret(){let e=r4(24).toString("hex");return iE(c4(this.secretsFile),{recursive:!0}),s4(this.secretsFile,JSON.stringify([...this.secrets(),e])),n4(this.secretsFile,384),e}async listen(){this.wss=new u4({noServer:!0,maxPayload:64*1024*1024}),this.wss.on("connection",e=>this.onConnection(e));for(let e of["127.0.0.1","::1"]){let r=a4((i,n)=>n.writeHead(426).end());r.on("upgrade",(i,n,o)=>this.wss?.handleUpgrade(i,n,o,s=>this.wss?.emit("connection",s,i)));try{await new Promise((i,n)=>{r.once("error",n),r.listen(this.port,e,()=>i())}),this.http.push(r)}catch(i){if(e!=="127.0.0.1")continue;throw i.code==="EADDRINUSE"?new Error(`port ${this.port} is in use, probably another codesignflo command. Find it with: lsof -nP -iTCP:${this.port} -sTCP:LISTEN`):i}}}waitForPlugin(e=0){return this.session?Promise.resolve(this.session):new Promise((r,i)=>{this.waiters.push(r),e>0&&setTimeout(()=>i(new Error("the CoDesignFlo plugin did not connect \u2014 open it in Figma desktop (Plugins \u2192 Development \u2192 CoDesignFlo)")),e)})}async close(){for(let e of this.pending.values())clearTimeout(e.timer),e.reject(new Error("bridge closed"));this.pending.clear(),this.socket?.close(),this.wss?.close(),await Promise.all(this.http.map(e=>new Promise(r=>e.close(()=>r()))))}reject(e,r,i){this.send(e,{t:"rejected",code:r,reason:i}),e.close(1008,i.slice(0,120))}onConnection(e){let r=new cf,i=!1;e.on("message",n=>{let o;try{o=r.push(n.toString())}catch{e.close(1003,"bad frame");return}if(!o)return;if(i)return this.onMessage(o);if(o.t!=="hello")return void e.close(1008,"expected hello");let s=o;if(s.protocol!==2)return this.reject(e,"protocol",`protocol ${s.protocol}, CLI speaks ${2}`);if(!tE(s.plugin.version,uf))return this.reject(e,"plugin_too_old",`plugin ${s.plugin.version} is older than ${uf}`);let a=this.opts.accept;if(!(a==="any"||(a==="unset"?s.file.projectId===null:"fileName"in a?s.file.name===a.fileName:s.file.projectId===a.projectId)))return this.log(`ignoring the plugin in "${s.file.name}" (${s.file.projectId?`project ${s.file.projectId}`:"not set up"})`),this.reject(e,"wrong_file","the developer's CLI is working on another file");let l=u=>{if(e.readyState===e.OPEN){i=!0,this.socket&&this.socket!==e&&this.socket.close(4001,"replaced"),this.socket=e,this.send(e,{t:"welcome",protocol:2,server:{version:Nc},secret:u}),this.session={hello:s,call:(d,p,f)=>this.call(d,p,f)};for(let d of this.waiters.splice(0))d(this.session)}};if(s.secret&&this.secrets().includes(s.secret))return l(s.secret);this.send(e,{t:"awaiting_approval"}),this.approvals=this.approvals.then(async()=>{e.readyState===e.OPEN&&(await(this.opts.approve??d4)(s)?l(this.issueSecret()):this.reject(e,"not_approved","pairing not approved"))})}),e.on("close",()=>{if(this.socket===e){this.socket=null,this.session=null;for(let n of this.pending.values())clearTimeout(n.timer),n.reject(new Error(`the plugin disconnected during ${n.method}`));this.pending.clear()}})}onMessage(e){if(e.t==="res"){let r=this.pending.get(e.id);if(!r)return;clearTimeout(r.timer),this.pending.delete(e.id),e.ok?r.resolve(e.result):r.reject(Object.assign(new Error(e.error.message),{stack:e.error.stack}))}else if(e.t==="progress"){let r=this.pending.get(e.id);if(!r)return;clearTimeout(r.timer),r.timer=this.arm(e.id,r.timeoutMs,r.method)}}call(e,r,i={}){let n=this.socket;if(!n)return Promise.reject(new Error("the plugin is not connected"));let o=`r${(this.seq++).toString(36)}`,s=i.timeoutMs??6e4;return new Promise((a,c)=>{this.pending.set(o,{resolve:a,reject:c,timeoutMs:s,method:e,timer:this.arm(o,s,e)}),this.send(n,{t:"req",id:o,method:e,params:r})})}arm(e,r,i){return setTimeout(()=>{let n=this.pending.get(e);n&&(this.pending.delete(e),n.reject(new Error(`${i} timed out after ${r} ms without progress`)))},r)}send(e,r){for(let i of eE(r))e.send(i)}};async function d4(t){let e=l4({input:process.stdin,output:process.stderr});try{let r=`${t.file.name}${t.user?.name?` (${t.user.name})`:""}`;for(let i=0;i<3;i++){if((await e.question(`
131
+ deps: ${r}}`};var o7={keyword:"dependencies",type:"object",schemaType:"object",error:ii.error,code(t){let[e,r]=s7(t);kU(t,e),SU(t,r)}};function s7({schema:t}){let e={},r={};for(let i in t){if(i==="__proto__")continue;let n=Array.isArray(t[i])?e:r;n[i]=t[i]}return[e,r]}function kU(t,e=t.schema){let{gen:r,data:i,it:n}=t;if(Object.keys(e).length===0)return;let o=r.let("missing");for(let s in e){let a=e[s];if(a.length===0)continue;let c=(0,Kd.propertyInData)(r,i,s,n.opts.ownProperties);t.setParams({property:s,depsCount:a.length,deps:a.join(", ")}),n.allErrors?r.if(c,()=>{for(let l of a)(0,Kd.checkReportMissingProp)(t,l)}):(r.if((0,hI._)`${c} && (${(0,Kd.checkMissingProp)(t,a,o)})`),(0,Kd.reportMissingProp)(t,o),r.else())}}ii.validatePropertyDeps=kU;function SU(t,e=t.schema){let{gen:r,data:i,keyword:n,it:o}=t,s=r.name("valid");for(let a in e)(0,i7.alwaysValidSchema)(o,e[a])||(r.if((0,Kd.propertyInData)(r,i,a,o.opts.ownProperties),()=>{let c=t.subschema({keyword:n,schemaProp:a},s);t.mergeValidEvaluated(c,s)},()=>r.var(s,!0)),t.ok(s))}ii.validateSchemaDeps=SU;ii.default=o7});var EU=C(mI=>{"use strict";Object.defineProperty(mI,"__esModule",{value:!0});var IU=Te(),a7=qe(),c7={message:"property name must be valid",params:({params:t})=>(0,IU._)`{propertyName: ${t.propertyName}}`},l7={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:c7,code(t){let{gen:e,schema:r,data:i,it:n}=t;if((0,a7.alwaysValidSchema)(n,r))return;let o=e.name("valid");e.forIn("key",i,s=>{t.setParams({propertyName:s}),t.subschema({keyword:"propertyNames",data:s,dataTypes:["string"],propertyName:s,compositeRule:!0},o),e.if((0,IU.not)(o),()=>{t.error(!0),n.allErrors||e.break()})}),t.ok(o)}};mI.default=l7});var yI=C(gI=>{"use strict";Object.defineProperty(gI,"__esModule",{value:!0});var zy=pn(),Nn=Te(),u7=zi(),Cy=qe(),d7={message:"must NOT have additional properties",params:({params:t})=>(0,Nn._)`{additionalProperty: ${t.additionalProperty}}`},f7={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:d7,code(t){let{gen:e,schema:r,parentSchema:i,data:n,errsCount:o,it:s}=t;if(!o)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=s;if(s.props=!0,c.removeAdditional!=="all"&&(0,Cy.alwaysValidSchema)(s,r))return;let l=(0,zy.allSchemaProperties)(i.properties),u=(0,zy.allSchemaProperties)(i.patternProperties);d(),t.ok((0,Nn._)`${o} === ${u7.default.errors}`);function d(){e.forIn("key",n,g=>{!l.length&&!u.length?h(g):e.if(p(g),()=>h(g))})}function p(g){let y;if(l.length>8){let v=(0,Cy.schemaRefOrVal)(s,i.properties,"properties");y=(0,zy.isOwnProperty)(e,v,g)}else l.length?y=(0,Nn.or)(...l.map(v=>(0,Nn._)`${g} === ${v}`)):y=Nn.nil;return u.length&&(y=(0,Nn.or)(y,...u.map(v=>(0,Nn._)`${(0,zy.usePattern)(t,v)}.test(${g})`))),(0,Nn.not)(y)}function f(g){e.code((0,Nn._)`delete ${n}[${g}]`)}function h(g){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){f(g);return}if(r===!1){t.setParams({additionalProperty:g}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,Cy.alwaysValidSchema)(s,r)){let y=e.name("valid");c.removeAdditional==="failing"?(m(g,y,!1),e.if((0,Nn.not)(y),()=>{t.reset(),f(g)})):(m(g,y),a||e.if((0,Nn.not)(y),()=>e.break()))}}function m(g,y,v){let b={keyword:"additionalProperties",dataProp:g,dataPropType:Cy.Type.Str};v===!1&&Object.assign(b,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(b,y)}}};gI.default=f7});var PU=C(_I=>{"use strict";Object.defineProperty(_I,"__esModule",{value:!0});var p7=jd(),TU=pn(),vI=qe(),OU=yI(),h7={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:i,data:n,it:o}=t;o.opts.removeAdditional==="all"&&i.additionalProperties===void 0&&OU.default.code(new p7.KeywordCxt(o,OU.default,"additionalProperties"));let s=(0,TU.allSchemaProperties)(r);for(let d of s)o.definedProperties.add(d);o.opts.unevaluated&&s.length&&o.props!==!0&&(o.props=vI.mergeEvaluated.props(e,(0,vI.toHash)(s),o.props));let a=s.filter(d=>!(0,vI.alwaysValidSchema)(o,r[d]));if(a.length===0)return;let c=e.name("valid");for(let d of a)l(d)?u(d):(e.if((0,TU.propertyInData)(e,n,d,o.opts.ownProperties)),u(d),o.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(d),t.ok(c);function l(d){return o.opts.useDefaults&&!o.compositeRule&&r[d].default!==void 0}function u(d){t.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};_I.default=h7});var zU=C(bI=>{"use strict";Object.defineProperty(bI,"__esModule",{value:!0});var AU=pn(),Ny=Te(),RU=qe(),jU=qe(),m7={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:i,parentSchema:n,it:o}=t,{opts:s}=o,a=(0,AU.allSchemaProperties)(r),c=a.filter(m=>(0,RU.alwaysValidSchema)(o,r[m]));if(a.length===0||c.length===a.length&&(!o.opts.unevaluated||o.props===!0))return;let l=s.strictSchema&&!s.allowMatchingProperties&&n.properties,u=e.name("valid");o.props!==!0&&!(o.props instanceof Ny.Name)&&(o.props=(0,jU.evaluatedPropsToName)(e,o.props));let{props:d}=o;p();function p(){for(let m of a)l&&f(m),o.allErrors?h(m):(e.var(u,!0),h(m),e.if(u))}function f(m){for(let g in l)new RegExp(m).test(g)&&(0,RU.checkStrictMode)(o,`property ${g} matches pattern ${m} (use allowMatchingProperties)`)}function h(m){e.forIn("key",i,g=>{e.if((0,Ny._)`${(0,AU.usePattern)(t,m)}.test(${g})`,()=>{let y=c.includes(m);y||t.subschema({keyword:"patternProperties",schemaProp:m,dataProp:g,dataPropType:jU.Type.Str},u),o.opts.unevaluated&&d!==!0?e.assign((0,Ny._)`${d}[${g}]`,!0):!y&&!o.allErrors&&e.if((0,Ny.not)(u),()=>e.break())})})}}};bI.default=m7});var CU=C(wI=>{"use strict";Object.defineProperty(wI,"__esModule",{value:!0});var g7=qe(),y7={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:i}=t;if((0,g7.alwaysValidSchema)(i,r)){t.fail();return}let n=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},n),t.failResult(n,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};wI.default=y7});var NU=C($I=>{"use strict";Object.defineProperty($I,"__esModule",{value:!0});var v7=pn(),_7={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:v7.validateUnion,error:{message:"must match a schema in anyOf"}};$I.default=_7});var DU=C(kI=>{"use strict";Object.defineProperty(kI,"__esModule",{value:!0});var Dy=Te(),b7=qe(),w7={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,Dy._)`{passingSchemas: ${t.passing}}`},$7={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:w7,code(t){let{gen:e,schema:r,parentSchema:i,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(n.opts.discriminator&&i.discriminator)return;let o=r,s=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(l),t.result(s,()=>t.reset(),()=>t.error(!0));function l(){o.forEach((u,d)=>{let p;(0,b7.alwaysValidSchema)(n,u)?e.var(c,!0):p=t.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&e.if((0,Dy._)`${c} && ${s}`).assign(s,!1).assign(a,(0,Dy._)`[${a}, ${d}]`).else(),e.if(c,()=>{e.assign(s,!0),e.assign(a,d),p&&t.mergeEvaluated(p,Dy.Name)})})}}};kI.default=$7});var LU=C(SI=>{"use strict";Object.defineProperty(SI,"__esModule",{value:!0});var k7=qe(),S7={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:r,it:i}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");let n=e.name("valid");r.forEach((o,s)=>{if((0,k7.alwaysValidSchema)(i,o))return;let a=t.subschema({keyword:"allOf",schemaProp:s},n);t.ok(n),t.mergeEvaluated(a)})}};SI.default=S7});var FU=C(xI=>{"use strict";Object.defineProperty(xI,"__esModule",{value:!0});var Ly=Te(),MU=qe(),x7={message:({params:t})=>(0,Ly.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,Ly._)`{failingKeyword: ${t.ifClause}}`},I7={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:x7,code(t){let{gen:e,parentSchema:r,it:i}=t;r.then===void 0&&r.else===void 0&&(0,MU.checkStrictMode)(i,'"if" without "then" and "else" is ignored');let n=UU(i,"then"),o=UU(i,"else");if(!n&&!o)return;let s=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),n&&o){let u=e.let("ifClause");t.setParams({ifClause:u}),e.if(a,l("then",u),l("else",u))}else n?e.if(a,l("then")):e.if((0,Ly.not)(a),l("else"));t.pass(s,()=>t.error(!0));function c(){let u=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(u)}function l(u,d){return()=>{let p=t.subschema({keyword:u},a);e.assign(s,a),t.mergeValidEvaluated(p,s),d?e.assign(d,(0,Ly._)`${u}`):t.setParams({ifClause:u})}}}};function UU(t,e){let r=t.schema[e];return r!==void 0&&!(0,MU.alwaysValidSchema)(t,r)}xI.default=I7});var ZU=C(II=>{"use strict";Object.defineProperty(II,"__esModule",{value:!0});var E7=qe(),T7={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,E7.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};II.default=T7});var qU=C(EI=>{"use strict";Object.defineProperty(EI,"__esModule",{value:!0});var O7=lI(),P7=_U(),A7=uI(),R7=wU(),j7=$U(),z7=xU(),C7=EU(),N7=yI(),D7=PU(),L7=zU(),U7=CU(),M7=NU(),F7=DU(),Z7=LU(),q7=FU(),V7=ZU();function B7(t=!1){let e=[U7.default,M7.default,F7.default,Z7.default,q7.default,V7.default,C7.default,N7.default,z7.default,D7.default,L7.default];return t?e.push(P7.default,R7.default):e.push(O7.default,A7.default),e.push(j7.default),e}EI.default=B7});var VU=C(TI=>{"use strict";Object.defineProperty(TI,"__esModule",{value:!0});var Dt=Te(),H7={message:({schemaCode:t})=>(0,Dt.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,Dt._)`{format: ${t}}`},W7={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:H7,code(t,e){let{gen:r,data:i,$data:n,schema:o,schemaCode:s,it:a}=t,{opts:c,errSchemaPath:l,schemaEnv:u,self:d}=a;if(!c.validateFormats)return;n?p():f();function p(){let h=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),m=r.const("fDef",(0,Dt._)`${h}[${s}]`),g=r.let("fType"),y=r.let("format");r.if((0,Dt._)`typeof ${m} == "object" && !(${m} instanceof RegExp)`,()=>r.assign(g,(0,Dt._)`${m}.type || "string"`).assign(y,(0,Dt._)`${m}.validate`),()=>r.assign(g,(0,Dt._)`"string"`).assign(y,m)),t.fail$data((0,Dt.or)(v(),b()));function v(){return c.strictSchema===!1?Dt.nil:(0,Dt._)`${s} && !${y}`}function b(){let x=u.$async?(0,Dt._)`(${m}.async ? await ${y}(${i}) : ${y}(${i}))`:(0,Dt._)`${y}(${i})`,k=(0,Dt._)`(typeof ${y} == "function" ? ${x} : ${y}.test(${i}))`;return(0,Dt._)`${y} && ${y} !== true && ${g} === ${e} && !${k}`}}function f(){let h=d.formats[o];if(!h){v();return}if(h===!0)return;let[m,g,y]=b(h);m===e&&t.pass(x());function v(){if(c.strictSchema===!1){d.logger.warn(k());return}throw new Error(k());function k(){return`unknown format "${o}" ignored in schema at path "${l}"`}}function b(k){let E=k instanceof RegExp?(0,Dt.regexpCode)(k):c.code.formats?(0,Dt._)`${c.code.formats}${(0,Dt.getProperty)(o)}`:void 0,O=r.scopeValue("formats",{key:o,ref:k,code:E});return typeof k=="object"&&!(k instanceof RegExp)?[k.type||"string",k.validate,(0,Dt._)`${O}.validate`]:["string",k,O]}function x(){if(typeof h=="object"&&!(h instanceof RegExp)&&h.async){if(!u.$async)throw new Error("async format in sync schema");return(0,Dt._)`await ${y}(${i})`}return typeof g=="function"?(0,Dt._)`${y}(${i})`:(0,Dt._)`${y}.test(${i})`}}}};TI.default=W7});var BU=C(OI=>{"use strict";Object.defineProperty(OI,"__esModule",{value:!0});var K7=VU(),G7=[K7.default];OI.default=G7});var HU=C(Oc=>{"use strict";Object.defineProperty(Oc,"__esModule",{value:!0});Oc.contentVocabulary=Oc.metadataVocabulary=void 0;Oc.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Oc.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var KU=C(PI=>{"use strict";Object.defineProperty(PI,"__esModule",{value:!0});var J7=tU(),X7=mU(),Y7=qU(),Q7=BU(),WU=HU(),eY=[J7.default,X7.default,(0,Y7.default)(),Q7.default,WU.metadataVocabulary,WU.contentVocabulary];PI.default=eY});var JU=C(Uy=>{"use strict";Object.defineProperty(Uy,"__esModule",{value:!0});Uy.DiscrError=void 0;var GU;(function(t){t.Tag="tag",t.Mapping="mapping"})(GU||(Uy.DiscrError=GU={}))});var YU=C(RI=>{"use strict";Object.defineProperty(RI,"__esModule",{value:!0});var Pc=Te(),AI=JU(),XU=by(),tY=zd(),rY=qe(),nY={message:({params:{discrError:t,tagName:e}})=>t===AI.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,Pc._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},iY={keyword:"discriminator",type:"object",schemaType:"object",error:nY,code(t){let{gen:e,data:r,schema:i,parentSchema:n,it:o}=t,{oneOf:s}=n;if(!o.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=i.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(i.mapping)throw new Error("discriminator: mapping is not supported");if(!s)throw new Error("discriminator: requires oneOf keyword");let c=e.let("valid",!1),l=e.const("tag",(0,Pc._)`${r}${(0,Pc.getProperty)(a)}`);e.if((0,Pc._)`typeof ${l} == "string"`,()=>u(),()=>t.error(!1,{discrError:AI.DiscrError.Tag,tag:l,tagName:a})),t.ok(c);function u(){let f=p();e.if(!1);for(let h in f)e.elseIf((0,Pc._)`${l} === ${h}`),e.assign(c,d(f[h]));e.else(),t.error(!1,{discrError:AI.DiscrError.Mapping,tag:l,tagName:a}),e.endIf()}function d(f){let h=e.name("valid"),m=t.subschema({keyword:"oneOf",schemaProp:f},h);return t.mergeEvaluated(m,Pc.Name),h}function p(){var f;let h={},m=y(n),g=!0;for(let x=0;x<s.length;x++){let k=s[x];if(k?.$ref&&!(0,rY.schemaHasRulesButRef)(k,o.self.RULES)){let O=k.$ref;if(k=XU.resolveRef.call(o.self,o.schemaEnv.root,o.baseId,O),k instanceof XU.SchemaEnv&&(k=k.schema),k===void 0)throw new tY.default(o.opts.uriResolver,o.baseId,O)}let E=(f=k?.properties)===null||f===void 0?void 0:f[a];if(typeof E!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);g=g&&(m||y(k)),v(E,x)}if(!g)throw new Error(`discriminator: "${a}" must be required`);return h;function y({required:x}){return Array.isArray(x)&&x.includes(a)}function v(x,k){if(x.const)b(x.const,k);else if(x.enum)for(let E of x.enum)b(E,k);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function b(x,k){if(typeof x!="string"||x in h)throw new Error(`discriminator: "${a}" values must be unique strings`);h[x]=k}}}};RI.default=iY});var QU=C((Npe,oY)=>{oY.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}});var zI=C((_t,jI)=>{"use strict";Object.defineProperty(_t,"__esModule",{value:!0});_t.MissingRefError=_t.ValidationError=_t.CodeGen=_t.Name=_t.nil=_t.stringify=_t.str=_t._=_t.KeywordCxt=_t.Ajv=void 0;var sY=GL(),aY=KU(),cY=YU(),eM=QU(),lY=["/properties"],My="http://json-schema.org/draft-07/schema",Ac=class extends sY.default{_addVocabularies(){super._addVocabularies(),aY.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(cY.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(eM,lY):eM;this.addMetaSchema(e,My,!1),this.refs["http://json-schema.org/schema"]=My}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(My)?My:void 0)}};_t.Ajv=Ac;jI.exports=_t=Ac;jI.exports.Ajv=Ac;Object.defineProperty(_t,"__esModule",{value:!0});_t.default=Ac;var uY=jd();Object.defineProperty(_t,"KeywordCxt",{enumerable:!0,get:function(){return uY.KeywordCxt}});var Rc=Te();Object.defineProperty(_t,"_",{enumerable:!0,get:function(){return Rc._}});Object.defineProperty(_t,"str",{enumerable:!0,get:function(){return Rc.str}});Object.defineProperty(_t,"stringify",{enumerable:!0,get:function(){return Rc.stringify}});Object.defineProperty(_t,"nil",{enumerable:!0,get:function(){return Rc.nil}});Object.defineProperty(_t,"Name",{enumerable:!0,get:function(){return Rc.Name}});Object.defineProperty(_t,"CodeGen",{enumerable:!0,get:function(){return Rc.CodeGen}});var dY=vy();Object.defineProperty(_t,"ValidationError",{enumerable:!0,get:function(){return dY.default}});var fY=zd();Object.defineProperty(_t,"MissingRefError",{enumerable:!0,get:function(){return fY.default}})});var cM=C(si=>{"use strict";Object.defineProperty(si,"__esModule",{value:!0});si.formatNames=si.fastFormats=si.fullFormats=void 0;function oi(t,e){return{validate:t,compare:e}}si.fullFormats={date:oi(iM,LI),time:oi(NI(!0),UI),"date-time":oi(tM(!0),sM),"iso-time":oi(NI(),oM),"iso-date-time":oi(tM(),aM),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:vY,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:xY,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:_Y,int32:{type:"number",validate:$Y},int64:{type:"number",validate:kY},float:{type:"number",validate:nM},double:{type:"number",validate:nM},password:!0,binary:!0};si.fastFormats={...si.fullFormats,date:oi(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,LI),time:oi(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,UI),"date-time":oi(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,sM),"iso-time":oi(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,oM),"iso-date-time":oi(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,aM),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i};si.formatNames=Object.keys(si.fullFormats);function pY(t){return t%4===0&&(t%100!==0||t%400===0)}var hY=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,mY=[0,31,28,31,30,31,30,31,31,30,31,30,31];function iM(t){let e=hY.exec(t);if(!e)return!1;let r=+e[1],i=+e[2],n=+e[3];return i>=1&&i<=12&&n>=1&&n<=(i===2&&pY(r)?29:mY[i])}function LI(t,e){if(t&&e)return t>e?1:t<e?-1:0}var CI=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function NI(t){return function(r){let i=CI.exec(r);if(!i)return!1;let n=+i[1],o=+i[2],s=+i[3],a=i[4],c=i[5]==="-"?-1:1,l=+(i[6]||0),u=+(i[7]||0);if(l>23||u>59||t&&!a)return!1;if(n<=23&&o<=59&&s<60)return!0;let d=o-u*c,p=n-l*c-(d<0?1:0);return(p===23||p===-1)&&(d===59||d===-1)&&s<61}}function UI(t,e){if(!(t&&e))return;let r=new Date("2020-01-01T"+t).valueOf(),i=new Date("2020-01-01T"+e).valueOf();if(r&&i)return r-i}function oM(t,e){if(!(t&&e))return;let r=CI.exec(t),i=CI.exec(e);if(r&&i)return t=r[1]+r[2]+r[3],e=i[1]+i[2]+i[3],t>e?1:t<e?-1:0}var DI=/t|\s/i;function tM(t){let e=NI(t);return function(i){let n=i.split(DI);return n.length===2&&iM(n[0])&&e(n[1])}}function sM(t,e){if(!(t&&e))return;let r=new Date(t).valueOf(),i=new Date(e).valueOf();if(r&&i)return r-i}function aM(t,e){if(!(t&&e))return;let[r,i]=t.split(DI),[n,o]=e.split(DI),s=LI(r,n);if(s!==void 0)return s||UI(i,o)}var gY=/\/|:/,yY=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function vY(t){return gY.test(t)&&yY.test(t)}var rM=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function _Y(t){return rM.lastIndex=0,rM.test(t)}var bY=-(2**31),wY=2**31-1;function $Y(t){return Number.isInteger(t)&&t<=wY&&t>=bY}function kY(t){return Number.isInteger(t)}function nM(){return!0}var SY=/[^\\]\\Z/;function xY(t){if(SY.test(t))return!1;try{return new RegExp(t),!0}catch{return!1}}});var lM=C(jc=>{"use strict";Object.defineProperty(jc,"__esModule",{value:!0});jc.formatLimitDefinition=void 0;var IY=zI(),Dn=Te(),wo=Dn.operators,Fy={formatMaximum:{okStr:"<=",ok:wo.LTE,fail:wo.GT},formatMinimum:{okStr:">=",ok:wo.GTE,fail:wo.LT},formatExclusiveMaximum:{okStr:"<",ok:wo.LT,fail:wo.GTE},formatExclusiveMinimum:{okStr:">",ok:wo.GT,fail:wo.LTE}},EY={message:({keyword:t,schemaCode:e})=>(0,Dn.str)`should be ${Fy[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,Dn._)`{comparison: ${Fy[t].okStr}, limit: ${e}}`};jc.formatLimitDefinition={keyword:Object.keys(Fy),type:"string",schemaType:"string",$data:!0,error:EY,code(t){let{gen:e,data:r,schemaCode:i,keyword:n,it:o}=t,{opts:s,self:a}=o;if(!s.validateFormats)return;let c=new IY.KeywordCxt(o,a.RULES.all.format.definition,"format");c.$data?l():u();function l(){let p=e.scopeValue("formats",{ref:a.formats,code:s.code.formats}),f=e.const("fmt",(0,Dn._)`${p}[${c.schemaCode}]`);t.fail$data((0,Dn.or)((0,Dn._)`typeof ${f} != "object"`,(0,Dn._)`${f} instanceof RegExp`,(0,Dn._)`typeof ${f}.compare != "function"`,d(f)))}function u(){let p=c.schema,f=a.formats[p];if(!f||f===!0)return;if(typeof f!="object"||f instanceof RegExp||typeof f.compare!="function")throw new Error(`"${n}": format "${p}" does not define "compare" function`);let h=e.scopeValue("formats",{key:p,ref:f,code:s.code.formats?(0,Dn._)`${s.code.formats}${(0,Dn.getProperty)(p)}`:void 0});t.fail$data(d(h))}function d(p){return(0,Dn._)`${p}.compare(${r}, ${i}) ${Fy[n].fail} 0`}},dependencies:["format"]};var TY=t=>(t.addKeyword(jc.formatLimitDefinition),t);jc.default=TY});var pM=C((Gd,fM)=>{"use strict";Object.defineProperty(Gd,"__esModule",{value:!0});var zc=cM(),OY=lM(),MI=Te(),uM=new MI.Name("fullFormats"),PY=new MI.Name("fastFormats"),FI=(t,e={keywords:!0})=>{if(Array.isArray(e))return dM(t,e,zc.fullFormats,uM),t;let[r,i]=e.mode==="fast"?[zc.fastFormats,PY]:[zc.fullFormats,uM],n=e.formats||zc.formatNames;return dM(t,n,r,i),e.keywords&&(0,OY.default)(t),t};FI.get=(t,e="full")=>{let i=(e==="fast"?zc.fastFormats:zc.fullFormats)[t];if(!i)throw new Error(`Unknown format "${t}"`);return i};function dM(t,e,r,i){var n,o;(n=(o=t.opts.code).formats)!==null&&n!==void 0||(o.formats=(0,MI._)`require("ajv-formats/dist/formats").${i}`);for(let s of e)t.addFormat(s,r[s])}fM.exports=Gd=FI;Object.defineProperty(Gd,"__esModule",{value:!0});Gd.default=FI});function AY(){let t=new hM.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,mM.default)(t),t}var hM,mM,Zy,gM=w(()=>{hM=xo(zI(),1),mM=xo(pM(),1);Zy=class{constructor(e){this._ajv=e??AY()}getValidator(e){let r="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return i=>r(i)?{valid:!0,data:i,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}}});var qy,yM=w(()=>{yc();qy=class{constructor(e){this._server=e}requestStream(e,r,i){return this._server.requestStream(e,r,i)}createMessageStream(e,r){let i=this._server.getClientCapabilities();if((e.tools||e.toolChoice)&&!i?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let n=e.messages[e.messages.length-1],o=Array.isArray(n.content)?n.content:[n.content],s=o.some(u=>u.type==="tool_result"),a=e.messages.length>1?e.messages[e.messages.length-2]:void 0,c=a?Array.isArray(a.content)?a.content:[a.content]:[],l=c.some(u=>u.type==="tool_use");if(s){if(o.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!l)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(l){let u=new Set(c.filter(p=>p.type==="tool_use").map(p=>p.id)),d=new Set(o.filter(p=>p.type==="tool_result").map(p=>p.toolUseId));if(u.size!==d.size||![...u].every(p=>d.has(p)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:e},vd,r)}elicitInputStream(e,r){let i=this._server.getClientCapabilities(),n=e.mode??"form";switch(n){case"url":{if(!i?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!i?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let o=n==="form"&&e.mode===void 0?{...e,mode:"form"}:e;return this.requestStream({method:"elicitation/create",params:o},gc,r)}async getTask(e,r){return this._server.getTask({taskId:e},r)}async getTaskResult(e,r,i){return this._server.getTaskResult({taskId:e},r,i)}async listTasks(e,r){return this._server.listTasks(e?{cursor:e}:void 0,r)}async cancelTask(e,r){return this._server.cancelTask({taskId:e},r)}}});function vM(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!t.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${e})`);break;default:break}}function _M(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!t.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!t.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${e})`);break;default:break}}var bM=w(()=>{});var Vy,wM=w(()=>{m1();yc();gM();Ju();yM();bM();Vy=class extends oy{constructor(e,r){super(r),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(yd.options.map((i,n)=>[i,n])),this.isMessageIgnored=(i,n)=>{let o=this._loggingLevels.get(n);return o?this.LOG_LEVEL_SEVERITY.get(i)<this.LOG_LEVEL_SEVERITY.get(o):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new Zy,this.setRequestHandler(G0,i=>this._oninitialize(i)),this.setNotificationHandler(J0,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(nS,async(i,n)=>{let o=n.sessionId||n.requestInfo?.headers["mcp-session-id"]||void 0,{level:s}=i.params,a=yd.safeParse(s);return a.success&&this._loggingLevels.set(o,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new qy(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=h1(this._capabilities,e)}setRequestHandler(e,r){let n=io(e)?.method;if(!n)throw new Error("Schema is missing a method literal");let o=nc(n);if(typeof o!="string")throw new Error("Schema method literal must be a string");if(o==="tools/call"){let a=async(c,l)=>{let u=no(mc,c);if(!u.success){let h=u.error instanceof Error?u.error.message:String(u.error);throw new te(ae.InvalidParams,`Invalid tools/call request: ${h}`)}let{params:d}=u.data,p=await Promise.resolve(r(c,l));if(d.task){let h=no(pc,p);if(!h.success){let m=h.error instanceof Error?h.error.message:String(h.error);throw new te(ae.InvalidParams,`Invalid task creation result: ${m}`)}return h.data}let f=no(Wg,p);if(!f.success){let h=f.error instanceof Error?f.error.message:String(f.error);throw new te(ae.InvalidParams,`Invalid tools/call result: ${h}`)}return f.data};return super.setRequestHandler(e,a)}return super.setRequestHandler(e,r)}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${e})`);break;case"ping":break}}assertNotificationCapability(e){switch(e){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${e})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${e})`);break;case"ping":case"initialize":break}}assertTaskCapability(e){_M(this._clientCapabilities?.tasks?.requests,e,"Client")}assertTaskHandlerCapability(e){this._capabilities&&vM(this._capabilities.tasks?.requests,e,"Server")}async _oninitialize(e){let r=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:hD.includes(r)?r:V0,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},Ag)}async createMessage(e,r){if((e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let i=e.messages[e.messages.length-1],n=Array.isArray(i.content)?i.content:[i.content],o=n.some(l=>l.type==="tool_result"),s=e.messages.length>1?e.messages[e.messages.length-2]:void 0,a=s?Array.isArray(s.content)?s.content:[s.content]:[],c=a.some(l=>l.type==="tool_use");if(o){if(n.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let l=new Set(a.filter(d=>d.type==="tool_use").map(d=>d.id)),u=new Set(n.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(l.size!==u.size||![...l].every(d=>u.has(d)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return e.tools?this.request({method:"sampling/createMessage",params:e},iS,r):this.request({method:"sampling/createMessage",params:e},vd,r)}async elicitInput(e,r){switch(e.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let n=e;return this.request({method:"elicitation/create",params:n},gc,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let n=e.mode==="form"?e:{...e,mode:"form"},o=await this.request({method:"elicitation/create",params:n},gc,r);if(o.action==="accept"&&o.content&&n.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(n.requestedSchema)(o.content);if(!a.valid)throw new te(ae.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(s){throw s instanceof te?s:new te(ae.InternalError,`Error validating elicitation response: ${s instanceof Error?s.message:String(s)}`)}return o}}}createElicitationCompletionNotifier(e,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:e}},r)}async listRoots(e,r){return this.request({method:"roots/list",params:e},oS,r)}async sendLoggingMessage(e,r){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,r))return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}}});function ZI(t){return!!t&&typeof t=="object"&&kM in t}function SM(t){return t[kM]?.complete}var kM,$M,xM=w(()=>{kM=Symbol.for("mcp.completable");(function(t){t.Completable="McpCompletable"})($M||($M={}))});var IM=w(()=>{});function jY(t){let e=[];if(t.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(t.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${t.length})`]};if(t.includes(" ")&&e.push("Tool name contains spaces, which may cause parsing issues"),t.includes(",")&&e.push("Tool name contains commas, which may cause parsing issues"),(t.startsWith("-")||t.endsWith("-"))&&e.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(t.startsWith(".")||t.endsWith("."))&&e.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!RY.test(t)){let r=t.split("").filter(i=>!/[A-Za-z0-9._-]/.test(i)).filter((i,n,o)=>o.indexOf(i)===n);return e.push(`Tool name contains invalid characters: ${r.map(i=>`"${i}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:e}}return{isValid:!0,warnings:e}}function zY(t,e){if(e.length>0){console.warn(`Tool name validation warning for "${t}":`);for(let r of e)console.warn(` - ${r}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}function qI(t){let e=jY(t);return zY(t,e.warnings),e.isValid}var RY,EM=w(()=>{RY=/^[A-Za-z0-9._-]{1,128}$/});var By,TM=w(()=>{By=class{constructor(e){this._mcpServer=e}registerToolTask(e,r,i){let n={taskSupport:"required",...r.execution};if(n.taskSupport==="forbidden")throw new Error(`Cannot register task-based tool '${e}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(e,r.title,r.description,r.inputSchema,r.outputSchema,r.annotations,n,r._meta,i)}}});var VI=w(()=>{Eg();Eg()});function CY(t,e){let r=0,i=[t];for(;i.length>0;){let n=i.pop();if(!(n===null||typeof n!="object"))if(Array.isArray(n))for(let o of n){if(++r>e)return r;o!==null&&typeof o=="object"&&i.push(o)}else for(let o in n){if(!Object.prototype.hasOwnProperty.call(n,o))continue;if(++r>e)return r;let s=n[o];s!==null&&typeof s=="object"&&i.push(s)}}return r}function NY(t){if(!(t===void 0||t===1/0)){if(typeof t!="number"||Number.isNaN(t)||t<1)throw new RangeError(`maxToolInputElements must be a number of at least 1, or Infinity, got ${String(t)}`);return t}}function AM(t){return t!==null&&typeof t=="object"&&"parse"in t&&typeof t.parse=="function"&&"safeParse"in t&&typeof t.safeParse=="function"}function RM(t){return"_def"in t||"_zod"in t||AM(t)}function BI(t){return typeof t!="object"||t===null||RM(t)?!1:Object.keys(t).length===0?!0:Object.values(t).some(AM)}function OM(t){if(t){if(BI(t))return ms(t);if(!RM(t))throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");return t}}function LY(t){let e=io(t);return e?Object.entries(e).map(([r,i])=>{let n=NC(i),o=DC(i);return{name:r,description:n,required:!o}}):[]}function $o(t){let r=io(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let i=nc(r);if(typeof i=="string")return i;throw new Error("Schema method literal must be a string")}function PM(t){return{completion:{values:t.slice(0,100),total:t.length,hasMore:t.length>100}}}var Hy,DY,Jd,jM=w(()=>{wM();Ju();ZS();yc();xM();IM();EM();TM();VI();Hy=class{constructor(e,r){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new Vy(e,r),this._maxToolInputElements=NY(r?.maxToolInputElements)}get experimental(){return this._experimental||(this._experimental={tasks:new By(this)}),this._experimental}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler($o(Hg)),this.server.assertCanSetRequestHandler($o(mc)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(Hg,()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,r])=>{let i={name:e,title:r.title,description:r.description,inputSchema:(()=>{let n=rc(r.inputSchema);return n?US(n,{strictUnions:!0,pipeStrategy:"input"}):DY})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let n=rc(r.outputSchema);n&&(i.outputSchema=US(n,{strictUnions:!0,pipeStrategy:"output"}))}return i})})),this.server.setRequestHandler(mc,async(e,r)=>{try{let i=this._registeredTools[e.params.name];if(!i)throw new te(ae.InvalidParams,`Tool ${e.params.name} not found`);if(!i.enabled)throw new te(ae.InvalidParams,`Tool ${e.params.name} disabled`);let n=!!e.params.task,o=i.execution?.taskSupport,s="createTask"in i.handler;if((o==="required"||o==="optional")&&!s)throw new te(ae.InternalError,`Tool ${e.params.name} has taskSupport '${o}' but was not registered with registerToolTask`);if(o==="required"&&!n)throw new te(ae.MethodNotFound,`Tool ${e.params.name} requires task augmentation (taskSupport: 'required')`);if(o==="optional"&&!n&&s)return await this.handleAutomaticTaskPolling(i,e,r);let a=await this.validateToolInput(i,e.params.arguments,e.params.name),c=await this.executeToolHandler(i,a,r);return n||await this.validateToolOutput(i,c,e.params.name),c}catch(i){if(i instanceof te&&i.code===ae.UrlElicitationRequired)throw i;return this.createToolError(i instanceof Error?i.message:String(i))}}),this._toolHandlersInitialized=!0)}createToolError(e){return{content:[{type:"text",text:e}],isError:!0}}async validateToolInput(e,r,i){if(this._maxToolInputElements!==void 0&&CY(r,this._maxToolInputElements)>this._maxToolInputElements)throw new te(ae.InvalidParams,`Invalid arguments for tool ${i}: arguments contain more than the maximum of ${this._maxToolInputElements} elements`);if(!e.inputSchema)return;let o=rc(e.inputSchema)??e.inputSchema,s=await Gm(o,r??{});if(!s.success){let a="error"in s?s.error:"Unknown error",c=Jm(a);throw new te(ae.InvalidParams,`Input validation error: Invalid arguments for tool ${i}: ${c}`)}return s.data}async validateToolOutput(e,r,i){if(!e.outputSchema||!("content"in r)||r.isError)return;if(!r.structuredContent)throw new te(ae.InvalidParams,`Output validation error: Tool ${i} has an output schema but no structured content was provided`);let n=rc(e.outputSchema),o=await Gm(n,r.structuredContent);if(!o.success){let s="error"in o?o.error:"Unknown error",a=Jm(s);throw new te(ae.InvalidParams,`Output validation error: Invalid structured content for tool ${i}: ${a}`)}}async executeToolHandler(e,r,i){let n=e.handler;if("createTask"in n){if(!i.taskStore)throw new Error("No task store provided.");let s={...i,taskStore:i.taskStore};if(e.inputSchema){let a=n;return await Promise.resolve(a.createTask(r,s))}else{let a=n;return await Promise.resolve(a.createTask(s))}}if(e.inputSchema){let s=n;return await Promise.resolve(s(r,i))}else{let s=n;return await Promise.resolve(s(i))}}async handleAutomaticTaskPolling(e,r,i){if(!i.taskStore)throw new Error("No task store provided for task-capable tool.");let n=await this.validateToolInput(e,r.params.arguments,r.params.name),o=e.handler,s={...i,taskStore:i.taskStore},a=n?await Promise.resolve(o.createTask(n,s)):await Promise.resolve(o.createTask(s)),c=a.task.taskId,l=a.task,u=l.pollInterval??5e3;for(;l.status!=="completed"&&l.status!=="failed"&&l.status!=="cancelled";){await new Promise(p=>setTimeout(p,u));let d=await i.taskStore.getTask(c);if(!d)throw new te(ae.InternalError,`Task ${c} not found during polling`);l=d}return await i.taskStore.getTaskResult(c)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler($o(Kg)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(Kg,async e=>{switch(e.params.ref.type){case"ref/prompt":return PD(e),this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return AD(e),this.handleResourceCompletion(e,e.params.ref);default:throw new te(ae.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,r){let i=this._registeredPrompts[r.name];if(!i)throw new te(ae.InvalidParams,`Prompt ${r.name} not found`);if(!i.enabled)throw new te(ae.InvalidParams,`Prompt ${r.name} disabled`);if(!i.argsSchema)return Jd;let o=io(i.argsSchema)?.[e.params.argument.name];if(!ZI(o))return Jd;let s=SM(o);if(!s)return Jd;let a=await s(e.params.argument.value,e.params.context);return PM(a)}async handleResourceCompletion(e,r){let i=Object.values(this._registeredResourceTemplates).find(s=>s.resourceTemplate.uriTemplate.toString()===r.uri);if(!i){if(this._registeredResources[r.uri])return Jd;throw new te(ae.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let n=i.resourceTemplate.completeCallback(e.params.argument.name);if(!n)return Jd;let o=await n(e.params.argument.value,e.params.context);return PM(o)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler($o(Fg)),this.server.assertCanSetRequestHandler($o(Zg)),this.server.assertCanSetRequestHandler($o(qg)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(Fg,async(e,r)=>{let i=Object.entries(this._registeredResources).filter(([o,s])=>s.enabled).map(([o,s])=>({uri:o,name:s.name,...s.metadata})),n=[];for(let o of Object.values(this._registeredResourceTemplates)){if(!o.resourceTemplate.listCallback)continue;let s=await o.resourceTemplate.listCallback(r);for(let a of s.resources)n.push({...o.metadata,...a})}return{resources:[...i,...n]}}),this.server.setRequestHandler(Zg,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,i])=>({name:r,uriTemplate:i.resourceTemplate.uriTemplate.toString(),...i.metadata}))})),this.server.setRequestHandler(qg,async(e,r)=>{let i=new URL(e.params.uri),n=this._registeredResources[i.toString()];if(n){if(!n.enabled)throw new te(ae.InvalidParams,`Resource ${i} disabled`);return n.readCallback(i,r)}for(let o of Object.values(this._registeredResourceTemplates)){let s=o.resourceTemplate.uriTemplate.match(i.toString());if(s)return o.readCallback(i,s,r)}throw new te(ae.InvalidParams,`Resource ${i} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler($o(Vg)),this.server.assertCanSetRequestHandler($o(Bg)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(Vg,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,r])=>({name:e,title:r.title,description:r.description,arguments:r.argsSchema?LY(r.argsSchema):void 0}))})),this.server.setRequestHandler(Bg,async(e,r)=>{let i=this._registeredPrompts[e.params.name];if(!i)throw new te(ae.InvalidParams,`Prompt ${e.params.name} not found`);if(!i.enabled)throw new te(ae.InvalidParams,`Prompt ${e.params.name} disabled`);if(i.argsSchema){let n=rc(i.argsSchema),o=await Gm(n,e.params.arguments??{});if(!o.success){let c="error"in o?o.error:"Unknown error",l=Jm(c);throw new te(ae.InvalidParams,`Invalid arguments for prompt ${e.params.name}: ${l}`)}let s=o.data,a=i.callback;return await Promise.resolve(a(s,r))}else{let n=i.callback;return await Promise.resolve(n(r))}}),this._promptHandlersInitialized=!0)}resource(e,r,...i){let n;typeof i[0]=="object"&&(n=i.shift());let o=i[0];if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let s=this._createRegisteredResource(e,void 0,r,n,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let s=this._createRegisteredResourceTemplate(e,void 0,r,n,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}}registerResource(e,r,i,n){if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let o=this._createRegisteredResource(e,i.title,r,i,n);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let o=this._createRegisteredResourceTemplate(e,i.title,r,i,n);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}}_createRegisteredResource(e,r,i,n,o){let s={name:e,title:r,metadata:n,readCallback:o,enabled:!0,disable:()=>s.update({enabled:!1}),enable:()=>s.update({enabled:!0}),remove:()=>s.update({uri:null}),update:a=>{typeof a.uri<"u"&&a.uri!==i&&(delete this._registeredResources[i],a.uri&&(this._registeredResources[a.uri]=s)),typeof a.name<"u"&&(s.name=a.name),typeof a.title<"u"&&(s.title=a.title),typeof a.metadata<"u"&&(s.metadata=a.metadata),typeof a.callback<"u"&&(s.readCallback=a.callback),typeof a.enabled<"u"&&(s.enabled=a.enabled),this.sendResourceListChanged()}};return this._registeredResources[i]=s,s}_createRegisteredResourceTemplate(e,r,i,n,o){let s={resourceTemplate:i,title:r,metadata:n,readCallback:o,enabled:!0,disable:()=>s.update({enabled:!1}),enable:()=>s.update({enabled:!0}),remove:()=>s.update({name:null}),update:l=>{typeof l.name<"u"&&l.name!==e&&(delete this._registeredResourceTemplates[e],l.name&&(this._registeredResourceTemplates[l.name]=s)),typeof l.title<"u"&&(s.title=l.title),typeof l.template<"u"&&(s.resourceTemplate=l.template),typeof l.metadata<"u"&&(s.metadata=l.metadata),typeof l.callback<"u"&&(s.readCallback=l.callback),typeof l.enabled<"u"&&(s.enabled=l.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[e]=s;let a=i.uriTemplate.variableNames;return Array.isArray(a)&&a.some(l=>!!i.completeCallback(l))&&this.setCompletionRequestHandler(),s}_createRegisteredPrompt(e,r,i,n,o){let s={title:r,description:i,argsSchema:n===void 0?void 0:ms(n),callback:o,enabled:!0,disable:()=>s.update({enabled:!1}),enable:()=>s.update({enabled:!0}),remove:()=>s.update({name:null}),update:a=>{typeof a.name<"u"&&a.name!==e&&(delete this._registeredPrompts[e],a.name&&(this._registeredPrompts[a.name]=s)),typeof a.title<"u"&&(s.title=a.title),typeof a.description<"u"&&(s.description=a.description),typeof a.argsSchema<"u"&&(s.argsSchema=ms(a.argsSchema)),typeof a.callback<"u"&&(s.callback=a.callback),typeof a.enabled<"u"&&(s.enabled=a.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[e]=s,n&&Object.values(n).some(c=>{let l=c instanceof _s?c._def?.innerType:c;return ZI(l)})&&this.setCompletionRequestHandler(),s}_createRegisteredTool(e,r,i,n,o,s,a,c,l){qI(e);let u={title:r,description:i,inputSchema:OM(n),outputSchema:OM(o),annotations:s,execution:a,_meta:c,handler:l,enabled:!0,disable:()=>u.update({enabled:!1}),enable:()=>u.update({enabled:!0}),remove:()=>u.update({name:null}),update:d=>{typeof d.name<"u"&&d.name!==e&&(typeof d.name=="string"&&qI(d.name),delete this._registeredTools[e],d.name&&(this._registeredTools[d.name]=u)),typeof d.title<"u"&&(u.title=d.title),typeof d.description<"u"&&(u.description=d.description),typeof d.paramsSchema<"u"&&(u.inputSchema=ms(d.paramsSchema)),typeof d.outputSchema<"u"&&(u.outputSchema=ms(d.outputSchema)),typeof d.callback<"u"&&(u.handler=d.callback),typeof d.annotations<"u"&&(u.annotations=d.annotations),typeof d._meta<"u"&&(u._meta=d._meta),typeof d.enabled<"u"&&(u.enabled=d.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=u,this.setToolRequestHandlers(),this.sendToolListChanged(),u}tool(e,...r){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let i,n,o,s;if(typeof r[0]=="string"&&(i=r.shift()),r.length>1){let c=r[0];if(BI(c))n=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!BI(r[0])&&(s=r.shift());else if(typeof c=="object"&&c!==null){if(Object.values(c).some(l=>typeof l=="object"&&l!==null))throw new Error(`Tool ${e} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);s=r.shift()}}let a=r[0];return this._createRegisteredTool(e,void 0,i,n,o,s,{taskSupport:"forbidden"},void 0,a)}registerTool(e,r,i){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let{title:n,description:o,inputSchema:s,outputSchema:a,annotations:c,_meta:l}=r;return this._createRegisteredTool(e,n,o,s,a,c,{taskSupport:"forbidden"},l,i)}prompt(e,...r){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let i;typeof r[0]=="string"&&(i=r.shift());let n;r.length>1&&(n=r.shift());let o=r[0],s=this._createRegisteredPrompt(e,void 0,i,n,o);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),s}registerPrompt(e,r,i){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let{title:n,description:o,argsSchema:s}=r,a=this._createRegisteredPrompt(e,n,o,s,i);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),a}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(e,r){return this.server.sendLoggingMessage(e,r)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}},DY={type:"object",properties:{}};Jd={completion:{values:[],hasMore:!1}}});function MY(t){return $D.parse(JSON.parse(t))}function zM(t){return JSON.stringify(t)+`
132
+ `}var UY,Wy,CM=w(()=>{yc();UY=10*1024*1024,Wy=class{constructor(e){this._maxBufferSize=e?.maxBufferSize??UY}append(e){if((this._buffer?.length??0)+e.length>this._maxBufferSize)throw this.clear(),new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
133
+ `);if(e===-1)return null;let r=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),MY(r)}clear(){this._buffer=void 0}}});import NM from"node:process";var Ky,DM=w(()=>{CM();Ky=class{constructor(e=NM.stdin,r=NM.stdout,i){this._stdin=e,this._stdout=r,this._started=!1,this._ondata=n=>{try{this._readBuffer.append(n),this.processReadBuffer()}catch(o){this.onerror?.(o),this.close().catch(()=>{})}},this._onerror=n=>{this.onerror?.(n)},this._readBuffer=new Wy({maxBufferSize:i?.maxBufferSize})}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(e){return new Promise(r=>{let i=zM(e);this._stdout.write(i)?r():this._stdout.once("drain",r)})}}});var Jy={};Jr(Jy,{mcp:()=>KY,proposalText:()=>MM,statusText:()=>WY});import{spawnSync as FY}from"node:child_process";import{existsSync as js,readdirSync as ZY,readFileSync as Gy}from"node:fs";import{join as ai,relative as qY,resolve as LM}from"node:path";import{fileURLToPath as VY}from"node:url";function Ln(t){if(t)return LM(t);let e=process.cwd();if(js(ai(e,".codesignflo","config.json")))return e;let r=(n,o)=>{if(o<0)return null;for(let s of ZY(n,{withFileTypes:!0})){if(!s.isDirectory()||s.name==="node_modules"||s.name.startsWith("."))continue;let a=ai(n,s.name);if(js(ai(a,".codesignflo","config.json")))return a;let c=r(a,o-1);if(c)return c}return null},i=r(e,3);if(!i)throw new Error("no CoDesignFlo project here (no .codesignflo/config.json) \u2014 call `init` in the app's folder");return i}function gn(t,e,r=9e5){let i=FY(process.execPath,[BY,...e],{cwd:t,encoding:"utf8",timeout:r,env:{...process.env,CODESIGNFLO_WAIT_S:process.env.CODESIGNFLO_WAIT_S??"40"}}),n=`${i.stdout??""}${i.stderr??""}`.trim();return i.status===0?n:`${n}
134
+ (exit ${i.status??"timeout"})`}function MM(t,e){let r=xt(UM(t)).get(e);if(!r?.claim)return{text:`${e} has no open proposal (state: ${r?.state??"unknown"}). Call status.`};let i=ai(t,".codesignflo","proposals",e,r.claim.id),n=ai(t,".codesignflo","registry.json"),o=js(n)?JSON.parse(Gy(n,"utf8")):{components:{}},s=p=>qY(t,p),a=e.startsWith("pages.");if(r.state==="design_new"){let p=ai(i,"design.png");return{text:Sw({component:e,by:r.claim.by,...r.claim.note?{note:r.claim.note}:{},page:a,design:js(p)?`${s(p)} (picture, attached) and ${s(ai(i,"spec.json"))}`:s(ai(i,"spec.json")),pageFiles:Object.values(o.screens??{})[0]?.files??[]}),...js(p)?{image:Gy(p).toString("base64")}:{}}}if(r.state!=="ready_for_dev")return{text:`${e} is ${r.state.replace(/_/g," ")}: nothing to implement yet.`};let c=ai(i,"changes.json");if(!js(c))return{text:`The changes for ${e} aren't computed yet: call sync first.`};let{changes:l,content:u}=JSON.parse(Gy(c,"utf8")),d=o.components[e]??o.screens?.[e];return{text:kw({component:e,by:r.claim.by,...r.claim.note?{note:r.claim.note}:{},conflict:r.conflict,changes:l,content:u,...d?{entry:d}:{},page:!!o.screens?.[e]})}}function WY(t){let e=[...xt(UM(t)).values()],r=[xw(e),...Iw(e),...Aw(e)],i=ai(t,".codesignflo","STATUS.md");return js(i)&&r.push("",Gy(i,"utf8")),r.join(`
135
+ `)}async function KY(){let t=new Hy({name:"codesignflo",version:lf},{instructions:HY}),e={app:yt.string().optional().describe("App folder (contains .codesignflo/); default: found from the working directory")};t.registerTool("status",{title:"Design status",description:"What the designer is working on, what is ready for dev, new designs, questions, how Live stands \u2014 without Figma (all=true: every place Live differs from the app).",inputSchema:{...e,all:yt.boolean().optional()}},async({app:n,all:o})=>Un(gn(Ln(n),["status",...o?["--all"]:[]]))),t.registerTool("get_proposal",{title:"Get a design proposal",description:"The designer's proposal for a component or page (ready for dev or a new design), as instructions for implementing it.",inputSchema:{component:yt.string().describe("Component or page key, e.g. product-card or pages.cart-page"),...e}},async({component:n,app:o})=>{let s=gn(Ln(o),["proposal",n,"--json"]),a;try{a=JSON.parse(s)}catch{a={text:s}}return{content:[{type:"text",text:a.text},...a.image?[{type:"image",data:a.image,mimeType:"image/png"}]:[]]}}),t.registerTool("sync",{title:"Sync with Figma",description:"Render Storybook and compare the code with the designer's proposals. Cloud projects: answers at once which proposals look done (no Figma needed); on the Live branch with everything committed it also uploads a Live update, which the plugin applies when the Figma file is open; anywhere else it's a check. Local projects: updates Live directly (Figma open with the plugin).",inputSchema:{...e,allowBranch:yt.boolean().optional().describe("Update Live from a branch other than the tracked one (only if the user asks)")}},async({app:n,allowBranch:o})=>Un(gn(Ln(n),["sync",...o?["--allow-branch"]:[]]))),t.registerTool("verify",{title:"Compare Figma with the code",description:"Browser vs Live, variant by variant (sizes and pixels; images written to .codesignflo/verify/).",inputSchema:{component:yt.string().optional(),screens:yt.boolean().optional(),...e}},async({component:n,screens:o,app:s})=>Un(gn(Ln(s),["verify",...n?[n]:[],...o?["--screens"]:[],"--no-build"]))),t.registerTool("ask_designer",{title:"Ask the designer",description:"Send a ready proposal back to the designer with a question.",inputSchema:{component:yt.string(),question:yt.string(),...e}},async({component:n,question:o,app:s})=>Un(gn(Ln(s),["ask",n,o]))),t.registerTool("resolve",{title:"Settle a clash",description:"When the designer's proposal and the code changed the same things: take=design (default rule) or take=code with a reason for the designer.",inputSchema:{component:yt.string(),take:yt.enum(["design","code"]),reason:yt.string().optional(),...e}},async({component:n,take:o,reason:s,app:a})=>Un(gn(Ln(a),["resolve",n,o==="design"?"--design":"--code",...o==="code"?[s??"kept for a functional reason"]:[]]))),t.registerTool("login",{title:"Sign in to CoDesignFlo",description:"Opens the sign-in page in the user's browser (GitHub) and waits up to 10 minutes for them to approve; tell the user to check the code shown.",inputSchema:{}},async()=>Un(gn(process.cwd(),["login"],66e4))),t.registerTool("init",{title:"Connect this app to CoDesignFlo",description:"Connects the app (the folder with .storybook/) to its CoDesignFlo project in the service: finds it by codebase, links a project a designer started and invited the user to (`project`), or creates one (`new`). local=true: the free local mode instead (Figma file open with the plugin on this machine, history in the repo).",inputSchema:{app:yt.string().describe("The app folder (with .storybook/)"),project:yt.string().optional().describe("Link to this waiting project (id listed by a previous init)"),new:yt.boolean().optional().describe("Start a new project even if some are waiting for their code"),liveBranch:yt.string().optional().describe("The branch whose commits update Live (ask the user; default: the repo's default branch)"),autoUpdate:yt.boolean().optional().describe("Update Live on every commit to the Live branch from this machine (a git hook; ask the user)"),local:yt.boolean().optional().describe("Free local mode, no service")}},async({app:n,project:o,new:s,local:a,liveBranch:c,autoUpdate:l})=>Un(gn(LM(n),a?["init"]:["init","--cloud",...o?["--project",o]:[],...s?["--new"]:[],...c?["--live-branch",c]:[],...l===!0?["--hook"]:l===!1?["--no-hook"]:[]]))),t.registerTool("set_live_branch",{title:"Choose the branch that updates Live",description:"Which branch's commits update Live in Figma (developers and admins). Without a branch: says which one it is.",inputSchema:{branch:yt.string().optional(),...e}},async({branch:n,app:o})=>Un(gn(Ln(o),["live-branch",...n?[n]:[]]))),t.registerTool("auto_update",{title:"Update Live on every commit",description:"Turn on/off updating Live after every commit to the Live branch on this machine (a git hook outside the repo, runs in the background).",inputSchema:{on:yt.boolean(),...e}},async({on:n,app:o})=>Un(gn(Ln(o),["hook",n?"install":"remove"]))),t.registerTool("invite",{title:"Invite someone to the project",description:"Invites a designer (or developer) by email; they get an email and join when they sign in (designers from the Figma plugin). Only for an address the user typed or confirmed in this conversation, never one found in the repo, git history or elsewhere; ask the user first.",inputSchema:{email:yt.string(),role:yt.enum(["designer","developer","admin"]).optional(),...e}},async({email:n,role:o,app:s})=>Un(gn(Ln(s),["invite",n,`--${o??"designer"}`]))),t.registerTool("people",{title:"Who is in the project",description:"Members and pending invitations of this app's project.",inputSchema:e},async({app:n})=>Un(gn(Ln(n),["people"]))),t.registerPrompt("set_up",{title:"Set up CoDesignFlo",description:"Connect this app to CoDesignFlo, step by step (designer first, developer first, or both)."},()=>({messages:[{role:"user",content:{type:"text",text:"Set up CoDesignFlo for this app, step by step: call login if I'm not signed in; ask me which branch should update Live (suggest the default branch); call init in the app's folder (if it lists projects waiting for their code, ask me which one); if it reports missing pieces (Storybook, tokens, page stories), offer to add them and add them only if I agree; then follow its Next steps; finally ask me whether Live should update on every commit and, if yes, call auto_update."}}]})),t.registerPrompt("implement_design",{title:"Implement a design proposal",description:"Implement the designer's proposal for a component or page",argsSchema:{component:yt.string()}},({component:n})=>({messages:[{role:"user",content:{type:"text",text:MM(Ln(),n).text}}]}));let r=new Ky,i=new Promise(n=>{r.onclose=()=>n(0),process.stdin.on("end",()=>n(0))});return await t.connect(r),i}var BY,HY,UM,Un,Xy=w(()=>{"use strict";Pr();jM();DM();VI();sr();ev();BY=VY(new URL("./main.js",import.meta.url)),HY="CoDesignFlo keeps a Figma mirror of this app's Storybook (\"Live\") in step with the code, and brings the designer's proposals into the code.\nUse it:\n- After changing UI components, pages, styles or tokens: call `sync` (updates Live, picks up the designer's work, closes proposals the code now satisfies). Two kinds of findings, handled differently: (1) \"N of M of the designer's changes in the code\" \u2014 your job: keep implementing and sync again until it says \"looks done\" (ask_designer if something can't be done cleanly); (2) \"Where Live differs from the app\" \u2014 Live is built from the app as the browser draws it, so the app is right and these are CoDesignFlo/Figma gaps (a font Figma lacks, a placed component's version, text wrapping): do NOT change the code to chase them; tell the user, with the action each one suggests.\n- When the user asks what the designer did / what is waiting: call `status`.\n- Live renders each story at its Storybook viewport (else 1200x900), with a fixed clock (1 January 2026). When Live differs because of size, a scrolling panel or dates, set the story's parameters rather than the app: `codesignflo: { size: { width, height } }`, `codesignflo: { fullHeight: true }` (an app shell 100vh tall whose panel scrolls), `codesignflo: { date: \"<ISO date>\" }` (fixtures with real dates).\n- When something is ready for dev or there is a new design: call `get_proposal` and implement it in the code, any way you like (edit the files, commit normally; no special commit format needed). Then `sync`: it checks the code against the designer's copy and closes the proposal, or reports what is left.\n- If a change is unclear or can't be done cleanly: `ask_designer` instead of guessing.\n- Setting up (\"connect this app to CoDesignFlo\"): `login` once (the user approves in the browser), then `init` in the app's folder. Ask the user which branch should update Live (default: the repo's default branch) and whether Live should update on every commit to it (autoUpdate). If init lists projects waiting for their code (a designer started them and invited the user), ask which one and call `init` again with `project`. Then, if the designer isn't in yet (`people` shows who is), ask the user for their email and `invite` that address.\n- At the start of a session, `status` also says whether Live is behind the Live branch or a branch with finished work was merged; if Live is behind and you're on the Live branch with everything committed, `sync`.\n- Clashes (\"N conflicting\"): the designer's version wins by default (`resolve` with take=design); keep the code only for a functional reason, with that reason.\nCloud projects (connected to the service): `sync` needs no Figma and answers at once; Live itself is updated when someone has the Figma file open. Local projects: `sync` and `verify` need Figma desktop open on the project's file with the CoDesignFlo plugin; if it doesn't connect, tell the user to open it.";UM=t=>Ct(),Un=t=>({content:[{type:"text",text:t}]})});Qy();ev();import{randomBytes as r4}from"node:crypto";import{chmodSync as n4,copyFileSync as i4,existsSync as nE,mkdirSync as iE,readFileSync as o4,writeFileSync as s4}from"node:fs";import{createServer as a4}from"node:http";import{homedir as rv}from"node:os";import{dirname as c4,join as nv}from"node:path";import{createInterface as l4}from"node:readline/promises";import{WebSocketServer as u4}from"ws";var Nc=lf,uf="0.1.0",df=class{port;opts;secretsFile;approvals=Promise.resolve();wss=null;http=[];socket=null;pending=new Map;seq=0;waiters=[];session=null;constructor(e){this.opts=e,this.port=e.port??4517,this.secretsFile=e.secretsFile??nv(rv(),".codesignflo","paired.json");let r=nv(rv(),".codesignloop","paired.json");!e.secretsFile&&!nE(this.secretsFile)&&nE(r)&&(iE(nv(rv(),".codesignflo"),{recursive:!0}),i4(r,this.secretsFile))}log(e){(this.opts.log??(r=>console.error(r)))(e)}secrets(){try{return JSON.parse(o4(this.secretsFile,"utf8"))}catch{return[]}}issueSecret(){let e=r4(24).toString("hex");return iE(c4(this.secretsFile),{recursive:!0}),s4(this.secretsFile,JSON.stringify([...this.secrets(),e])),n4(this.secretsFile,384),e}async listen(){this.wss=new u4({noServer:!0,maxPayload:64*1024*1024}),this.wss.on("connection",e=>this.onConnection(e));for(let e of["127.0.0.1","::1"]){let r=a4((i,n)=>n.writeHead(426).end());r.on("upgrade",(i,n,o)=>this.wss?.handleUpgrade(i,n,o,s=>this.wss?.emit("connection",s,i)));try{await new Promise((i,n)=>{r.once("error",n),r.listen(this.port,e,()=>i())}),this.http.push(r)}catch(i){if(e!=="127.0.0.1")continue;throw i.code==="EADDRINUSE"?new Error(`port ${this.port} is in use, probably another codesignflo command. Find it with: lsof -nP -iTCP:${this.port} -sTCP:LISTEN`):i}}}waitForPlugin(e=0){return this.session?Promise.resolve(this.session):new Promise((r,i)=>{this.waiters.push(r),e>0&&setTimeout(()=>i(new Error("the CoDesignFlo plugin did not connect \u2014 open it in Figma desktop (Plugins \u2192 Development \u2192 CoDesignFlo)")),e)})}async close(){for(let e of this.pending.values())clearTimeout(e.timer),e.reject(new Error("bridge closed"));this.pending.clear(),this.socket?.close(),this.wss?.close(),await Promise.all(this.http.map(e=>new Promise(r=>e.close(()=>r()))))}reject(e,r,i){this.send(e,{t:"rejected",code:r,reason:i}),e.close(1008,i.slice(0,120))}onConnection(e){let r=new cf,i=!1;e.on("message",n=>{let o;try{o=r.push(n.toString())}catch{e.close(1003,"bad frame");return}if(!o)return;if(i)return this.onMessage(o);if(o.t!=="hello")return void e.close(1008,"expected hello");let s=o;if(s.protocol!==2)return this.reject(e,"protocol",`protocol ${s.protocol}, CLI speaks ${2}`);if(!tE(s.plugin.version,uf))return this.reject(e,"plugin_too_old",`plugin ${s.plugin.version} is older than ${uf}`);let a=this.opts.accept;if(!(a==="any"||(a==="unset"?s.file.projectId===null:"fileName"in a?s.file.name===a.fileName:s.file.projectId===a.projectId)))return this.log(`ignoring the plugin in "${s.file.name}" (${s.file.projectId?`project ${s.file.projectId}`:"not set up"})`),this.reject(e,"wrong_file","the developer's CLI is working on another file");let l=u=>{if(e.readyState===e.OPEN){i=!0,this.socket&&this.socket!==e&&this.socket.close(4001,"replaced"),this.socket=e,this.send(e,{t:"welcome",protocol:2,server:{version:Nc},secret:u}),this.session={hello:s,call:(d,p,f)=>this.call(d,p,f)};for(let d of this.waiters.splice(0))d(this.session)}};if(s.secret&&this.secrets().includes(s.secret))return l(s.secret);this.send(e,{t:"awaiting_approval"}),this.approvals=this.approvals.then(async()=>{e.readyState===e.OPEN&&(await(this.opts.approve??d4)(s)?l(this.issueSecret()):this.reject(e,"not_approved","pairing not approved"))})}),e.on("close",()=>{if(this.socket===e){this.socket=null,this.session=null;for(let n of this.pending.values())clearTimeout(n.timer),n.reject(new Error(`the plugin disconnected during ${n.method}`));this.pending.clear()}})}onMessage(e){if(e.t==="res"){let r=this.pending.get(e.id);if(!r)return;clearTimeout(r.timer),this.pending.delete(e.id),e.ok?r.resolve(e.result):r.reject(Object.assign(new Error(e.error.message),{stack:e.error.stack}))}else if(e.t==="progress"){let r=this.pending.get(e.id);if(!r)return;clearTimeout(r.timer),r.timer=this.arm(e.id,r.timeoutMs,r.method)}}call(e,r,i={}){let n=this.socket;if(!n)return Promise.reject(new Error("the plugin is not connected"));let o=`r${(this.seq++).toString(36)}`,s=i.timeoutMs??6e4;return new Promise((a,c)=>{this.pending.set(o,{resolve:a,reject:c,timeoutMs:s,method:e,timer:this.arm(o,s,e)}),this.send(n,{t:"req",id:o,method:e,params:r})})}arm(e,r,i){return setTimeout(()=>{let n=this.pending.get(e);n&&(this.pending.delete(e),n.reject(new Error(`${i} timed out after ${r} ms without progress`)))},r)}send(e,r){for(let i of eE(r))e.send(i)}};async function d4(t){let e=l4({input:process.stdin,output:process.stderr});try{let r=`${t.file.name}${t.user?.name?` (${t.user.name})`:""}`;for(let i=0;i<3;i++){if((await e.question(`
136
136
  The CoDesignFlo plugin in "${r}" wants to connect.
137
137
  Type the code shown in the plugin: `)).trim()===t.pairCode)return!0;console.error("that code doesn't match")}return!1}finally{e.close()}}Pr();sr();async function uz(t){let[e,r]=t.filter(n=>!n.startsWith("--"));if(!e||!r?.trim())throw new Error('usage: codesignflo ask <component> "<question for the designer>"');let i=xt(Ct()).get(e);if(!i)throw new Error(`${e} has no proposal ready for dev`);return En([Ew(i,r)]),console.log(`${e}: question sent to the designer (they see it at the next sync)`),0}Pr();sr();import{execFileSync as jr,spawnSync as h9}from"node:child_process";import{existsSync as Ii,readdirSync as m9,readFileSync as Ou,writeFileSync as Ma}from"node:fs";import{dirname as zm,join as Ot,relative as ik,resolve as g9}from"node:path";function y9(t){return`You are applying a designer's approved changes to the React component "${t.component}".
138
138
 
@@ -238,16 +238,16 @@ When done, reply with ONLY this JSON (no prose, no code fences):
238
238
  `;console.error(`asking Claude Code to build the page ${p.component} (${f}.tsx, story ${p.story})\u2026`);let b=Date.now(),x=Yt().tokens??"tokens/tokens.json",k=[`${f}.*`,l,...u?[u]:[],x,...y.files],{report:E,touched:O}=ok(v,k.flatMap(de=>[`Edit(${de})`,`Write(${de})`]));Ma(Ot(n,"report.json"),`${JSON.stringify(E,null,2)}
239
239
  `),console.log(`Claude Code finished in ${Math.round((Date.now()-b)/1e3)} s:`);for(let de of E.changes)console.log(` ${de.status}${de.note?` \u2014 ${de.note}`:""}`);let X=jr("git",["rev-parse","--show-prefix"],{encoding:"utf8"}).trim(),le=de=>de.startsWith(`${X}${f}.`)||[l,u,x,...y.files].some(pt=>pt&&de===`${X}${pt}`)||/(^|\/)src\/tokens\.css$/.test(de),$e=O.filter(de=>!le(de));if($e.length)throw new Error(`Claude Code changed files outside the new page: ${$e.join(", ")} \u2014 nothing committed, review the working tree`);if(!O.length||!E.changes.some(de=>de.status==="applied"))return console.log("nothing built; nothing committed"),1;let q=`CoDesignFlo: ${t} claim=${i.id} items=new`;jr("git",["add","--",...O.map(de=>de.slice(X.length))]),jr("git",["commit","-q","-m",`Add the ${p.component} page from a new design`,"-m",`${i.note?`Designer's note: ${i.note}
240
240
 
241
- `:""}${q}`]);let Re=jr("git",["rev-parse","HEAD"],{encoding:"utf8"}).trim();return En([{id:`delivered_${i.id}_${Re.slice(0,8)}`,at:new Date().toISOString(),by:"cli",component:t,kind:"delivered",claim:i.id,mode:"patch",ref:Re}]),console.log(`committed ${Re.slice(0,7)} with "${q}"`),console.log("next: codesignflo sync \u2014 renders the page story, builds it in Live \u2192 Screens and closes the proposal"),0}Pr();sr();import{mkdirSync as J9,readFileSync as X9,writeFileSync as Hz}from"node:fs";import{join as wk,resolve as Y9}from"node:path";async function Yn(t,e){let r=new df({accept:t});await r.listen(),console.error("waiting for the CoDesignFlo plugin in Figma desktop\u2026");try{let i=await r.waitForPlugin(Number(process.env.CODESIGNFLO_WAIT_S??process.env.CODESIGNLOOP_WAIT_S??120)*1e3);return console.error(`connected to "${i.hello.file.name}" (plugin ${i.hello.plugin.version})`),await e(i)}finally{await r.close()}}Pr();import{execSync as V9}from"node:child_process";import{existsSync as vk,mkdirSync as B9,readFileSync as _k,writeFileSync as Ru}from"node:fs";import{join as Tn,relative as Zz,resolve as qz}from"node:path";import{execFileSync as Pu}from"node:child_process";var Yi=t=>Pu("git",t,{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();function Cm(){try{return Yi(["rev-parse","HEAD"])}catch{return"uncommitted"}}function Au(){try{return Yi(["rev-parse","--abbrev-ref","HEAD"])}catch{return null}}function pz(t){let e;try{let r=t&&t!=="uncommitted"?[`${t}..HEAD`]:["HEAD"];e=Yi(["log","--format=%H%x1f%B%x1e",...r])}catch{return[]}return w9(e)}function w9(t){let e=[];for(let r of t.split("")){let[i,n]=r.trim().split("");if(!(!i||!n))for(let o of n.split(`
241
+ `:""}${q}`]);let Re=jr("git",["rev-parse","HEAD"],{encoding:"utf8"}).trim();return En([{id:`delivered_${i.id}_${Re.slice(0,8)}`,at:new Date().toISOString(),by:"cli",component:t,kind:"delivered",claim:i.id,mode:"patch",ref:Re}]),console.log(`committed ${Re.slice(0,7)} with "${q}"`),console.log("next: codesignflo sync \u2014 renders the page story, builds it in Live \u2192 Screens and closes the proposal"),0}Pr();sr();import{mkdirSync as Q9,readFileSync as eW,writeFileSync as Hz}from"node:fs";import{join as wk,resolve as tW}from"node:path";async function Yn(t,e){let r=new df({accept:t});await r.listen(),console.error("waiting for the CoDesignFlo plugin in Figma desktop\u2026");try{let i=await r.waitForPlugin(Number(process.env.CODESIGNFLO_WAIT_S??process.env.CODESIGNLOOP_WAIT_S??120)*1e3);return console.error(`connected to "${i.hello.file.name}" (plugin ${i.hello.plugin.version})`),await e(i)}finally{await r.close()}}Pr();import{execSync as W9}from"node:child_process";import{existsSync as vk,mkdirSync as K9,readFileSync as _k,writeFileSync as Ru}from"node:fs";import{join as Tn,relative as Zz,resolve as qz}from"node:path";import{execFileSync as Pu}from"node:child_process";var Yi=t=>Pu("git",t,{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();function Cm(){try{return Yi(["rev-parse","HEAD"])}catch{return"uncommitted"}}function Au(){try{return Yi(["rev-parse","--abbrev-ref","HEAD"])}catch{return null}}function pz(t){let e;try{let r=t&&t!=="uncommitted"?[`${t}..HEAD`]:["HEAD"];e=Yi(["log","--format=%H%x1f%B%x1e",...r])}catch{return[]}return w9(e)}function w9(t){let e=[];for(let r of t.split("")){let[i,n]=r.trim().split("");if(!(!i||!n))for(let o of n.split(`
242
242
  `)){let s=/^CoDesign(?:Flo|Loop):\s*(\S+)\s+claim=(\S+)(?:\s+items=(\S+))?\s*$/.exec(o.trim());s&&e.push({commit:i,component:s[1],claim:s[2],items:s[3]?s[3].split(","):[]})}}return e}function hz(){try{return Yi(["status","--porcelain","--",".",":(exclude).codesignflo",":(exclude).codesignloop"]).split(`
243
243
  `).filter(Boolean).map(t=>t.replace(/^[ MADRCU?!T]{1,2} /,""))}catch{return[]}}var $9=[/\.(md|txt|rst|log)$/i,/(^|\/)(docs?|scripts|e2e|\.github|\.vscode|\.idea)\//,/\.(test|spec)\.[cm]?[jt]sx?$/,/(^|\/)(__tests__|__mocks__)\//];function mz(t,e=[]){return $9.some(r=>r.test(t))?!1:!e.some(r=>new RegExp(`^${r.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*\/?/g,"\xA7").replace(/\*/g,"[^/]*").replace(/§/g,".*")}$`).test(t))}function Nm(){try{return Yi(["symbolic-ref","--short","refs/remotes/origin/HEAD"]).replace(/^origin\//,"")}catch{for(let t of["main","master"])try{return Yi(["rev-parse","--verify","--quiet",`refs/heads/${t}`]),t}catch{}return Au()}}function gz(t){try{Pu("git",["fetch","--quiet","origin",t],{stdio:"ignore",timeout:2e4})}catch{}for(let e of[`refs/remotes/origin/${t}`,`refs/heads/${t}`])try{return Yi(["rev-parse","--verify","--quiet",e])}catch{}return null}function yz(t,e){try{return Pu("git",["merge-base","--is-ancestor",e,t],{stdio:"ignore"}),!0}catch(r){return r.status===1?!1:null}}function vz(t,e){try{return Number(Yi(["rev-list","--count",`${t}..${e}`]))}catch{return null}}function _z(t){try{return Pu("git",["diff","--quiet",t,"HEAD","--",".",":(exclude).codesignflo"],{stdio:"ignore"}),!1}catch(e){return e.status===1?!0:null}}function bz(t,e,r){if(!r.length)return null;try{return Pu("git",["diff","--quiet",t,e,"--",...r],{stdio:"ignore"}),!0}catch(i){return i.status===1?!1:null}}sr();Pr();import{createReadStream as T9,existsSync as Tz,readFileSync as O9,statSync as P9}from"node:fs";import{createServer as A9}from"node:http";import{extname as R9,join as lk}from"node:path";import{chromium as j9}from"playwright";function wz(){let t=document.querySelector("[data-cdf-container], [data-cdl-container]")??document.querySelector("#storybook-root"),e=t.firstElementChild;if(!e)throw new Error("story rendered nothing");let r=[e,...Array.from(e.querySelectorAll("*"))],i=t.style.width,n=S=>(t.style.width=`${S}px`,new Map(r.map(T=>[T,T.getBoundingClientRect().width]))),o=new Map(r.map(S=>[S,S.getBoundingClientRect()])),s=Math.round(t.getBoundingClientRect().width),a=n(s),c=n(s+160);t.style.width=i;let l=[],u=S=>{for(let T of Array.from(S))T instanceof CSSStyleRule?l.push(T):T instanceof CSSMediaRule?window.matchMedia(T.conditionText||T.media.mediaText).matches&&u(T.cssRules):T instanceof CSSSupportsRule?CSS.supports(T.conditionText)&&u(T.cssRules):"cssRules"in T&&T.cssRules&&u(T.cssRules)};for(let S of Array.from(document.styleSheets)){let T;try{T=S.cssRules}catch{continue}u(T)}let d=(S,T)=>{let Q=S.style?.getPropertyValue(T)??"";if(Q)return Q.trim();for(let ye of l){let _e=!1;try{_e=S.matches(ye.selectorText)}catch{}if(_e){let Qe=ye.style.getPropertyValue(T);Qe&&(Q=Qe)}}return Q.trim()},p=(S,T)=>{for(let Q=S;Q;Q=Q.parentElement){let ye=d(Q,T);if(ye)return ye}return""},f=S=>/var\(--([\w-]+)\)/.exec(S)?.[1],h=(S,T,Q,ye)=>{let _e=d(S,ye);if(_e)return f(_e);let Qe=d(S,T).split(/\s+(?![^(]*\))/).filter(Boolean);if(Qe.length===0)return;let ht=[[0,0,0,0],[0,1,0,1],[0,1,2,1],[0,1,2,3]][Math.min(Qe.length,4)-1][Q];return f(Qe[ht])},m=S=>Math.round(S*100)/100,g=S=>S==="normal"||S===""?0:parseFloat(S)||0,y=S=>{let T=/rgba?\(([^)]+)\)/.exec(S);if(!T)return;let[Q,ye,_e,Qe="1"]=T[1].split(/[,\s/]+/).filter(Boolean);if(parseFloat(Qe)===0)return;let ht=_=>Math.round(_).toString(16).padStart(2,"0");return`#${ht(+Q)}${ht(+ye)}${ht(+_e)}${parseFloat(Qe)<1?ht(parseFloat(Qe)*255):""}`},v=(S,T)=>T?{value:S,token:T}:{value:S},b=S=>{for(let T of Array.from(S.classList)){let Q=/^([A-Za-z0-9]+)-module__[\w-]+$/.exec(T);if(Q)return Q[1]}},x=b(e),k=S=>{let T=S.getAttribute("data-cdf")??S.getAttribute("data-cdl");if(T)return T;for(let Q of Array.from(S.classList)){let ye=/^[A-Za-z0-9]+-module__([\w-]+)$/.exec(Q);if(ye)return ye[1]}},E=(S,T)=>k(S)??T,O=S=>{let T=S.parentElement;for(;T&&T!==t&&getComputedStyle(T).display==="contents";)T=T.parentElement;return T},X=S=>Array.from(S.childNodes).flatMap(T=>T.nodeType===Node.ELEMENT_NODE&&getComputedStyle(T).display==="contents"?X(T):[T]),le=(S,T)=>{let Q=O(S);if(!Q)return!1;let ye=getComputedStyle(Q);return(ye.display==="flex"||ye.display==="inline-flex")&&ye.flexDirection.startsWith(T)&&parseFloat(getComputedStyle(S).flexGrow)>0},$e=S=>{if(Math.abs((c.get(S)??0)-(a.get(S)??0))>.5)return"fill";let T=d(S,"width");if(/^\d+(\.\d+)?px$/.test(T)||/^-?[\d.]+(rem|em|vw|ch)$|^calc\(/.test(T)||/^table-(cell|row|header-group|row-group|footer-group|column)$/.test(getComputedStyle(S).display))return"fixed";if(/^(fit-content|max-content|min-content)$/.test(T))return"hug";if(le(S,"row"))return"fill";let Q=getComputedStyle(S),ye=S.getBoundingClientRect().width;if(/px$/.test(Q.maxWidth)&&Math.abs(ye-parseFloat(Q.maxWidth))<.5||/px$/.test(Q.minWidth)&&parseFloat(Q.minWidth)>0&&Math.abs(ye-parseFloat(Q.minWidth))<.5)return"fixed";let _e=O(S),Qe=_e?getComputedStyle(_e):null;if(Qe&&/flex/.test(Qe.display)&&Qe.flexDirection.startsWith("row")&&/px$/.test(Q.flexBasis)&&parseFloat(Q.flexGrow)===0)return"fixed";if(/^100(\.0+)?%$/.test(T))return"fill";if(/%$/.test(T))return"fixed";let ht=O(S);if(ht&&S!==e){let _=getComputedStyle(ht),U=getComputedStyle(S),z=U.alignSelf,ue=z==="auto"?_.alignItems:z;if((_.display==="flex"||_.display==="inline-flex")&&_.flexDirection.startsWith("column")&&(ue==="normal"||ue==="stretch"))return"fill";let we=U.justifySelf==="auto"?_.justifyItems:U.justifySelf;if((_.display==="grid"||_.display==="inline-grid")&&/^(normal|stretch|legacy)$/.test(we))return"fill";let Ee=!/flex|grid|inline|table/.test(_.display),zt=["block","flex","grid","flow-root","list-item"].includes(U.display),Mr=!d(S,"width")||d(S,"width")==="auto";if(Ee&&zt&&Mr&&U.float==="none"&&U.position!=="absolute"&&U.position!=="fixed")return"fill"}return"hug"},q=S=>{let T=d(S,"height");if(/^\d+(\.\d+)?px$/.test(T)||/^-?[\d.]+(vh|dvh|svh|lvh|rem|em)$|^calc\(/.test(T))return"fixed";if(/%$/.test(T))return S===e?"fixed":"fill";if(le(S,"column"))return"fill";let Q=getComputedStyle(S).minHeight;if(/px$/.test(Q)&&parseFloat(Q)>0&&Math.abs(S.getBoundingClientRect().height-parseFloat(Q))<.5||S===e&&Math.abs(Re(S)-S.getBoundingClientRect().height)>.5)return"fixed";let ye=O(S);if(ye&&S!==e){let _e=getComputedStyle(ye),Qe=getComputedStyle(S).alignSelf,ht=Qe==="auto"?_e.alignItems:Qe,_=ht==="normal"||ht==="stretch",U=_e.display==="grid"||_e.display==="inline-grid",z=(_e.display==="flex"||_e.display==="inline-flex")&&_e.flexDirection.startsWith("row");if(_&&(U||z))return"fill"}return"hug"},Re=S=>{let T=S.style.alignSelf;S.style.alignSelf="flex-start";let Q=S.getBoundingClientRect().height;return S.style.alignSelf=T,Q},de=S=>S==="center"?"CENTER":S==="flex-end"||S==="end"?"MAX":S==="baseline"?"BASELINE":S==="normal"||S==="stretch"?"STRETCH":"MIN",pt=S=>S==="center"?"CENTER":S==="flex-end"||S==="end"?"MAX":S==="space-between"?"SPACE_BETWEEN":"MIN",Zt=(S,T)=>{let Q=S.getBoundingClientRect();if(!S.complete||!S.naturalWidth||Q.width<1||Q.height<1)return{};try{let _e=document.createElement("canvas");_e.width=Math.round(Q.width*2),_e.height=Math.round(Q.height*2);let Qe=_e.getContext("2d"),ht=S.naturalWidth,_=S.naturalHeight,U=T.objectFit,z=_e.width,ue=_e.height;if(U==="cover"||U==="contain"){let ie=(U==="cover"?Math.max:Math.min)(_e.width/ht,_e.height/_);z=ht*ie,ue=_*ie}return Qe.drawImage(S,(_e.width-z)/2,(_e.height-ue)/2,z,ue),{image:{png:_e.toDataURL("image/png").split(",")[1]}}}catch{return{}}},Y=S=>{let T=document.createRange(),Q=Array.from(S.childNodes).find(_e=>_e.nodeType===Node.TEXT_NODE&&_e.textContent.trim());if(!Q)return 0;T.selectNodeContents(Q);let ye=T.getClientRects()[0];return ye?Math.round(ye.height*100)/100:0},De=(S,T)=>{let Q=S.getBoundingClientRect(),ye=g(T.paddingLeft)+g(T.paddingRight)+g(T.borderLeftWidth)+g(T.borderRightWidth),_e=g(T.paddingTop)+g(T.paddingBottom)+g(T.borderTopWidth)+g(T.borderBottomWidth);return{w:m(Math.max(0,Q.width-ye)),h:m(Math.max(0,Q.height-_e))}},Lt=(S,T,Q)=>{let ye=parseInt(T.getPropertyValue("-webkit-line-clamp"),10),_e=T.textTransform,Qe=_e==="uppercase"?"UPPER":_e==="lowercase"?"LOWER":_e==="capitalize"?"TITLE":void 0,ht=T.textOverflow==="ellipsis"&&T.whiteSpace.startsWith("nowrap")?1:0,_=T.textAlign,U=_==="center"?"CENTER":_==="right"||_==="end"?"RIGHT":_==="justify"?"JUSTIFIED":void 0;return{characters:Q,fontFamily:T.fontFamily.split(",")[0].replace(/["']/g,"").trim(),fontWeight:v(parseInt(T.fontWeight,10),f(p(S,"font-weight"))),fontSize:v(g(T.fontSize),f(p(S,"font-size"))),lineHeight:T.lineHeight==="normal"?Y(S):g(T.lineHeight),letterSpacing:g(T.letterSpacing),color:v(y(T.color)??"#000000",f(p(S,"color"))),...ye>0?{maxLines:ye}:ht?{maxLines:1}:{},...U?{align:U}:{},...Qe?{case:Qe}:{}}},Ht=(S,T)=>{let Q=/linear-gradient\((.*)\)\s*$/.exec(S.trim());if(!Q||S.indexOf("gradient(")!==S.lastIndexOf("gradient("))return;let ye=Q[1].split(/,(?![^(]*\))/).map(z=>z.trim()),_e=180,Qe={top:0,right:90,bottom:180,left:270,"top right":45,"right top":45,"bottom right":135,"right bottom":135,"bottom left":225,"left bottom":225,"top left":315,"left top":315};if(/deg$|turn$|rad$/.test(ye[0])){let z=parseFloat(ye[0]);_e=ye[0].endsWith("turn")?z*360:ye[0].endsWith("rad")?z*180/Math.PI:z,ye.shift()}else ye[0].startsWith("to ")&&(_e=Qe[ye.shift().slice(3)]??180);let ht=[...T.matchAll(/var\(--([\w-]+)\)/g)].map(z=>z[1]),_=ye.flatMap(z=>{let ue=y(/rgba?\([^)]+\)/.exec(z)?.[0]??"");if(!ue)return[];let ie=/(-?[\d.]+)%\s*$/.exec(z);return[{color:ue,position:ie?parseFloat(ie[1])/100:Number.NaN}]});if(_.length<2)return;Number.isNaN(_[0].position)&&(_[0].position=0),Number.isNaN(_[_.length-1].position)&&(_[_.length-1].position=1);for(let z=1;z<_.length-1;z++)if(Number.isNaN(_[z].position)){let ue=z;for(;Number.isNaN(_[ue].position);)ue++;let ie=_[z-1].position,we=_[ue].position;for(let Ee=z;Ee<ue;Ee++)_[Ee].position=ie+(we-ie)*(Ee-z+1)/(ue-z+1)}let U=ht.length===_.length;return{angle:Math.round(_e*100)/100,stops:_.map((z,ue)=>({color:v(z.color,U?ht[ue]:void 0),position:Math.round(z.position*1e3)/1e3}))}},Mn=(S,T)=>/^(pre|break-spaces)/.test(T)?S.replace(/^\n|\n$/g,""):T==="pre-line"?S.split(`
244
244
  `).map(Q=>Q.replace(/[ \t\f\r]+/g," ").trim()).join(`
245
245
  `).trim():S.replace(/\s+/g," ").trim(),Fn=o.get(e)??e.getBoundingClientRect(),Xd=S=>({x:m(S.left-Fn.left),y:m(S.top-Fn.top)}),Yd=S=>{let T=getComputedStyle(S),Q=o.get(S)??S.getBoundingClientRect(),ye=S.parentElement,_e=(T.position==="absolute"||T.position==="fixed")&&ye&&S!==t&&S!==e,Qe=_e?o.get(ye)??ye.getBoundingClientRect():null,ht=/^matrix\(([^)]+)\)/.exec(T.transform),[_,U]=ht?ht[1].split(",").map(Number):[1,0],z=ht?Math.round(Math.atan2(U,_)*180/Math.PI*100)/100:0,ue=Math.abs(z)>.05&&S instanceof HTMLElement,ie={name:E(S,S.tagName.toLowerCase()),...k(S)||S.tagName.toLowerCase()==="svg"?{}:{unnamed:!0},width:m(ue?S.offsetWidth:Q.width),height:m(ue?S.offsetHeight:Q.height),sizing:_e||ue?{w:"fixed",h:"fixed"}:{w:$e(S),h:q(S)},...ue?{rotation:z}:{},...Qe?{absolute:{x:m(Q.left-Qe.left),y:m(Q.top-Qe.top)}}:{},...b(S)?{module:b(S)}:{},at:Xd(Q)};if(S.tagName==="IMG")return{...ie,type:"IMAGE",fill:v("#e0e7ff"),...Zt(S,T)};if(S.tagName.toLowerCase()==="svg"){let oe=S.outerHTML.replace(/currentColor/g,y(T.color)??"#000000");return{...ie,type:"SVG",svg:oe}}let we=X(S),Ee=we.filter(oe=>oe.nodeType===Node.ELEMENT_NODE&&getComputedStyle(oe).display!=="none"),zt=we.filter(oe=>oe.nodeType===Node.TEXT_NODE&&oe.textContent.trim()).map(oe=>Mn(oe.textContent,T.whiteSpace)),Mr=!!y(T.backgroundColor)||g(T.borderTopWidth)>0||g(T.paddingTop)+g(T.paddingLeft)>0;if(Ee.length===0&&zt.length>0&&!Mr){let oe=Lt(S,T,zt.join(" ")),nt=oe.lineHeight||Y(S)||1,Ze=Math.round(Q.height/nt),ut=S.scrollWidth>S.clientWidth+1,kt=(Ze>1||(oe.maxLines??0)>1||oe.maxLines===1&&ut)&&ie.sizing.w==="hug"?{...ie.sizing,w:"fill"}:ie.sizing;return{...ie,sizing:kt,name:E(S,"text"),type:"TEXT",text:oe}}let G={...ie,type:"FRAME"},Gr=b(S);Gr&&(S===e||Gr!==x)&&(G.component={module:Gr,classes:Array.from(S.classList).map(oe=>/-module__([\w-]+)$/.exec(oe)?.[1]).filter(oe=>!!oe).sort()});let Kt=T.display,ko=Kt==="flex"||Kt==="inline-flex",zs=!1,So=ko&&T.flexDirection.startsWith("row")||Kt==="table-row";if(Kt==="grid"||Kt==="inline-grid"){let oe=Je=>Je==="none"?0:Je.trim().split(/\s+/).length,nt=f(d(S,"gap"));G.layout={direction:"GRID",columns:oe(T.gridTemplateColumns),...T.gridTemplateColumns!=="none"?{columnSizes:T.gridTemplateColumns.trim().split(/\s+/).map(Je=>m(g(Je)))}:{},rows:Math.max(1,oe(T.gridTemplateRows)),gap:v(g(T.columnGap),f(d(S,"column-gap"))??nt),rowGap:v(g(T.rowGap),f(d(S,"row-gap"))??nt),padding:[v(g(T.paddingTop),h(S,"padding",0,"padding-top")),v(g(T.paddingRight),h(S,"padding",1,"padding-right")),v(g(T.paddingBottom),h(S,"padding",2,"padding-bottom")),v(g(T.paddingLeft),h(S,"padding",3,"padding-left"))],align:"STRETCH",justify:"MIN"};let Ze=Array.from(S.children).filter(Je=>{let kt=getComputedStyle(Je);return kt.display!=="none"&&kt.position!=="absolute"&&kt.position!=="fixed"}),ut=Math.max(0,...G.layout.columnSizes??[0]);if((G.layout.columns??0)>1&&Ze.some(Je=>Je.getBoundingClientRect().width>ut+1)){let Je=new Set(Ze.map(yn=>Math.round(yn.getBoundingClientRect().top))),{columns:kt,columnSizes:ui,rows:di,...fi}=G.layout;G.layout={...fi,direction:"HORIZONTAL",align:"STRETCH",...Je.size>1?{wrap:!0}:{}},zs=!0}}else G.layout={direction:So?"HORIZONTAL":"VERTICAL",gap:v(g(So?T.columnGap:T.rowGap),f(d(S,"gap"))??f(d(S,So?"column-gap":"row-gap"))),padding:[v(g(T.paddingTop),h(S,"padding",0,"padding-top")),v(g(T.paddingRight),h(S,"padding",1,"padding-right")),v(g(T.paddingBottom),h(S,"padding",2,"padding-bottom")),v(g(T.paddingLeft),h(S,"padding",3,"padding-left"))],align:ko?de(T.alignItems):"STRETCH",justify:ko?pt(T.justifyContent):"MIN",...So&&T.flexWrap.startsWith("wrap")?{wrap:!0,rowGap:v(g(T.rowGap),f(d(S,"row-gap"))??f(d(S,"gap")))}:{}};let Zn=y(T.backgroundColor);Zn&&(G.fill=v(Zn,f(d(S,"background"))??f(d(S,"background-color"))));let Qd=Ht(T.backgroundImage,d(S,"background")||d(S,"background-image"));Qd&&(G.gradient=Qd);let ef=oe=>T.getPropertyValue(`border-${oe.toLowerCase()}-style`)==="none"?0:g(T.getPropertyValue(`border-${oe.toLowerCase()}-width`)),tf=[ef("Top"),ef("Right"),ef("Bottom"),ef("Left")],Ni=Math.max(...tf);if(Ni>0){let nt=["Top","Right","Bottom","Left"][tf.indexOf(Ni)],Ze=y(T.getPropertyValue(`border-${nt.toLowerCase()}-color`))??"#00000000",ut=f(d(S,"border-color"))??f(d(S,"border"))??f(d(S,`border-${nt.toLowerCase()}-color`))??f(d(S,`border-${nt.toLowerCase()}`)),Je=T.getPropertyValue(`border-${nt.toLowerCase()}-style`),kt=Je==="dashed"?[Ni*3,Ni*3]:Je==="dotted"?[Ni,Ni]:void 0;G.stroke={color:v(Ze,ut),width:Ni,...tf.some(ui=>ui!==Ni)?{sides:tf}:{},...kt?{dash:kt}:{}}}let WI=g(T.borderTopLeftRadius);WI>0&&(G.radius=v(Math.min(WI,9999),f(d(S,"border-radius"))));let KI=parseFloat(T.opacity);KI<1&&(G.opacity=KI),(T.overflow==="hidden"||T.overflowX==="hidden")&&(G.clip=!0),T.boxShadow!=="none"&&(G.shadow=T.boxShadow);let Cs=S.tagName;if(Cs==="INPUT"||Cs==="TEXTAREA"||Cs==="SELECT"){let oe=S,nt=(oe.getAttribute("type")??"text").toLowerCase(),Ze=Cs==="SELECT"?oe.selectedOptions[0]?.text??"":nt==="password"?"\u2022".repeat(oe.value.length):oe.value,ut=Ze||oe.placeholder||"";if(ut&&!["checkbox","radio","range","color","file","hidden","submit","button"].includes(nt)){let Je=Lt(S,T,ut);if(!Ze){let fi=getComputedStyle(S,"::placeholder"),yn;for(let VM of Array.from(document.styleSheets)){let QI;try{QI=VM.cssRules}catch{continue}for(let of of Array.from(QI)){if(!(of instanceof CSSStyleRule)||!of.selectorText.includes("::placeholder"))continue;let BM=of.selectorText.replace(/::placeholder/g,"");try{S.matches(BM)&&(yn=f(of.style.getPropertyValue("color"))??yn)}catch{}}}let Yy=y(T.color),nf=y(fi.color)??Je.color.value;Je.color=v(nf,yn??(nf===Yy?f(p(S,"color")):void 0))}G.layout&&Cs!=="TEXTAREA"&&(G.layout.justify="CENTER");let kt=De(S,T),ui=Je.lineHeight||Y(S)||g(T.fontSize)*1.2,di=Cs==="TEXTAREA"?kt.h:m(Math.min(kt.h,ui));return G.children=[{name:Ze?"value":"placeholder",type:"TEXT",width:kt.w,height:di,sizing:{w:"fill",h:"hug"},text:Je,at:{x:m(Q.left-Fn.left+g(T.paddingLeft)+g(T.borderLeftWidth)),y:m(Q.top-Fn.top+(Q.height-di)/2)}}],G}}let ci=[],li=G.layout?.direction==="VERTICAL",GI=G.layout&&G.layout.direction!=="GRID",rf=!ko,JI=0,XI=(oe,nt,Ze,ut)=>({name:ut?`${oe}-margin-${li?"top":"left"}`:`${oe}-margin`,type:"FRAME",width:li?0:nt,height:li?nt:0,sizing:li?{w:"fill",h:"fixed"}:{w:"fixed",h:"fill"},layout:{direction:li?"VERTICAL":"HORIZONTAL",gap:v(0),padding:[v(0),v(0),v(0),v(0)],align:"MIN",justify:"MIN"},...Ze?{spaceToken:Ze}:{}});for(let oe of we)if(oe.nodeType===Node.ELEMENT_NODE&&Ee.includes(oe)){let nt=oe,Ze=getComputedStyle(nt),ut=Yd(nt);if(!GI||Ze.position==="absolute"){ci.push(ut);continue}let[Je,kt,ui,di]=li?["top","bottom",0,2]:["left","right",3,1],fi=g(Ze.getPropertyValue(`margin-${Je}`)),yn=g(Ze.getPropertyValue(`margin-${kt}`));rf&&li&&(fi=Math.max(0,fi-JI)),fi>0&&(ci.length||!rf)&&ci.push(XI(ut.name,fi,h(nt,"margin",ui,`margin-${Je}`),!0)),ci.push(ut),yn>0&&(oe!==Ee[Ee.length-1]||!rf)&&ci.push(XI(ut.name,yn,h(nt,"margin",di,`margin-${kt}`),!1)),JI=yn}else if(oe.nodeType===Node.TEXT_NODE&&oe.textContent.trim()){let nt=Mn(oe.textContent,T.whiteSpace),Ze=Ee.length===0?"label":"text",ut=document.createRange();ut.selectNodeContents(oe);let Je=new Set(Array.from(ut.getClientRects()).map(nf=>Math.round(nf.top))),kt=Lt(S,T,nt),ui=Je.size>1||!!kt.maxLines,di=ut.getBoundingClientRect(),yn=Ee.length===0&&ui?De(S,T).w:m(di.width),Yy=kt.lineHeight?m(Je.size*kt.lineHeight):m(di.height);ci.push({name:Ze,type:"TEXT",width:yn,height:Yy,sizing:{w:ui?"fill":"hug",h:"hug"},text:kt,at:Xd(di)})}if(zs)for(let oe of ci)!oe.absolute&&oe.sizing.w!=="fixed"&&(oe.sizing={...oe.sizing,w:"fixed"});if(ci.length&&(G.children=ci),rf&&G.layout?.direction==="VERTICAL"&&Ee.length&&Ee.every(oe=>getComputedStyle(oe).display.startsWith("inline"))){let oe=we.flatMap(Ze=>{if(Ze.nodeType===Node.ELEMENT_NODE)return Ee.includes(Ze)?[Ze.getBoundingClientRect()]:[];if(Ze.nodeType!==Node.TEXT_NODE||!Ze.textContent.trim())return[];let ut=document.createRange();return ut.selectNodeContents(Ze),[ut.getBoundingClientRect()]}),nt=oe[0];if(oe.every(Ze=>Ze.top<nt.bottom-.5&&Ze.bottom>nt.top+.5)){let Ze=oe.slice(1).map((Je,kt)=>Je.left-oe[kt].right);G.layout.direction="HORIZONTAL",G.layout.align="CENTER",G.layout.gap=v(Ze.length?m(Math.max(0,Math.min(...Ze))):0);let ut=De(S,T).h;G.sizing.h==="hug"&&ut>Math.max(...oe.map(Je=>Je.height))+.5&&(G.sizing={...G.sizing,h:"fixed"})}}let YI=Ee.filter(oe=>!["absolute","fixed"].includes(getComputedStyle(oe).position)),qM=G.layout?.direction===(li?"VERTICAL":"HORIZONTAL");if(GI&&YI.length&&G.layout&&qM){let oe=li?[3,1]:[0,2];for(let nt of oe){let Ze=["top","right","bottom","left"][nt],ut=Math.min(...YI.map(Je=>g(getComputedStyle(Je).getPropertyValue(`margin-${Ze}`))));ut>0&&(G.layout.padding[nt]=v(m(G.layout.padding[nt].value+ut)))}}return G};return Yd(e)}var sk=new Date("2026-01-01T12:00:00Z"),Qi=t=>t!==null&&typeof t=="object"&&!Array.isArray(t)?t:void 0;function Dm(t){let e=typeof t=="number"?t:typeof t=="string"&&/^\s*\d+(\.\d+)?\s*(px)?\s*$/.test(t)?Number.parseFloat(t):Number.NaN;return Number.isFinite(e)&&e>0?e:void 0}function k9(t,e,r,i){let n=Qi(t);if(!n||n.disable===!0)return;let o=Qi(n.options)??Qi(n.viewports),s=f=>{let h=typeof f=="string"?{value:f}:Qi(f);return typeof h?.value=="string"&&o?.[h.value]?{name:h.value,rotated:h.isRotated===!0}:void 0},a=s(e)??s(r),c=a?.name??(typeof n.defaultViewport=="string"?n.defaultViewport:void 0);if(!c)return;let l=Qi(Qi(o?.[c])?.styles),u=Dm(l?.width),d=Dm(l?.height);return!u||!d?void 0:a?.rotated===!0||i===!0||n.defaultOrientation==="landscape"?{w:d,h:u}:{w:u,h:d}}function $z(t,e){let r=Qi(t.parameters?.codesignflo)??{},i={},n=Qi(r.size),o=Dm(n?.width??n?.w),s=Dm(n?.height??n?.h),a=o&&s?{w:o,h:s}:k9(t.parameters?.viewport,t.globals?.viewport,e?.viewport,t.globals?.viewportRotated);if(a&&(i.size=a),r.fullHeight===!0&&(i.fullHeight=!0),typeof r.date=="string"||typeof r.date=="number"){let c=new Date(r.date);if(Number.isNaN(c.getTime()))throw new Error(`parameters.codesignflo.date isn't a date: ${String(r.date)} (e.g. "2026-11-10" or "2026-11-10T09:30:00Z")`);i.date=c}return i}Pr();import{readdirSync as S9,readFileSync as x9}from"node:fs";import{basename as xz,dirname as I9,join as ak}from"node:path";var kz=Wh,Iz=t=>/^(pages|screens)(\/|$)/i.test(t),E9=(t,e)=>Iz(t)||e==="fullscreen";function Sz(t,e,r){let i=e.replace(/^\.\//,""),n=I9(i),o=r??xz(i).replace(/\.stories\.[jt]sx?$/,"");return S9(ak(t,n)).filter(s=>!/\.(stories|test|spec)\.[jt]sx?$/.test(s)&&/\.(tsx?|jsx?|css|scss|less)$/.test(s)).filter(s=>s.toLowerCase().startsWith(o.toLowerCase())||!r&&s.startsWith("index.")).map(s=>ak(n,s)).sort()}async function Ez(t,e,r){let i=JSON.parse(x9(ak(e,"index.json"),"utf8")),n=await t.evaluate(async()=>{let l=await window.__STORYBOOK_PREVIEW__.extract();for(let u of Object.values(l))u.args=Object.fromEntries(Object.entries(u.args).filter(([,d])=>typeof d!="function").map(([d,p])=>[d,p!==null&&typeof p=="object"?"__node__":p]));return JSON.parse(JSON.stringify(l,(u,d)=>u==="component"||u==="render"||u==="decorators"||u==="loaders"?void 0:d))}),o=Object.values(i.entries).filter(c=>c.type==="story"),s=new Map;for(let c of o)s.set(c.title,[...s.get(c.title)??[],c]);let a={generated:"codesignflo sync \u2014 derived from Storybook; do not edit",components:{},screens:{}};for(let[c,l]of[...s].sort(([u],[d])=>u.localeCompare(d))){let u=n[l[0].id];if(!u)continue;let d=kz(c),p=Sz(r,l[0].importPath);if(E9(c,u.parameters?.layout)){Iz(c)||console.error(`${c}: treated as a page (its stories use layout "fullscreen"); title it "Pages/\u2026" to keep it, or drop the layout to make it a component`);for(let k of l){let E=k.id.split("--")[1]??"",O=Sz(r,k.importPath,E.split("-")[0]),X=l.length===1&&d!=="pages";a.screens[X?d:kz(`${c}/${E}`).replace(/\.default$/,"")]={story:k.id,title:c,files:O.length?O:p}}continue}let f=u.argTypes,h=k=>{let E=f[k]?.type?.name;return E==="boolean"?"bool":E==="enum"||(f[k]?.options?.length??0)>0?"enum":E==="other"||l.some(O=>n[O.id]?.args[k]==="__node__")?"slot":null},m=(k,E)=>{let O=f[k]?.table?.defaultValue?.summary?.replace(/^["'`]|["'`]$/g,"");if(O&&O!=="undefined")return O;let X=E?.split("--")[1]?.toLowerCase(),le=(f[k]?.options??[]).map(String);return X&&le.some($e=>$e.toLowerCase()===X)?le.find($e=>$e.toLowerCase()===X):"default"},g=(k,E,O,X)=>O==="slot"?String(k[E]==="__node__"):O==="bool"?String(k[E]===!0):k[E]===void 0||k[E]===""?m(E,X):String(k[E]),v=[...new Set(l.flatMap(k=>[...Object.keys(n[k.id]?.args??{}),...Object.keys(f)]))].sort().filter(k=>{let E=h(k);return E!==null&&new Set(l.map(O=>g(n[O.id]?.args??{},k,E,O.id))).size>1}),b={module:xz(p.find(k=>/\.[jt]sx?$/.test(k))??c).replace(/\.[jt]sx?$/,""),title:c,files:p,stories:{}},x=new Map;for(let k of l){let E=n[k.id]?.args??{},O=Object.fromEntries(v.map($e=>[$e,g(E,$e,h($e),k.id)])),X=JSON.stringify(O),le=x.get(X);if(le){b.examples={...b.examples??{},[k.id]:le};continue}x.set(X,k.id),b.stories[k.id]=v.length?O:{story:k.id.split("--")[1]??"default"}}a.components[d]=b}return a}var z9={".html":"text/html",".js":"text/javascript",".css":"text/css",".json":"application/json",".svg":"image/svg+xml",".woff2":"font/woff2",".woff":"font/woff",".png":"image/png"},Pz=null,Az=()=>Pz,ck={w:1200,h:900},Oz=2e4;async function dk(t,e){if(!Tz(lk(t,"index.json")))throw new Error(`no Storybook build in ${t} (expected index.json)`);let r=A9((o,s)=>{let a=lk(t,decodeURIComponent(new URL(o.url??"/","http://x").pathname));if(!Tz(a)||P9(a).isDirectory())return void s.writeHead(404).end();s.writeHead(200,{"content-type":z9[R9(a)]??"application/octet-stream"}),T9(a).pipe(s)});await new Promise(o=>r.listen(0,"127.0.0.1",()=>o()));let i=`http://127.0.0.1:${r.address().port}`,n=await j9.launch().catch(o=>{throw r.close(),new Error(`could not start Chromium (${o.message.split(`
246
- `)[0]}). Install it once with: npx playwright install chromium`)});try{Pz={os:`${process.platform}-${process.arch}`,browser:`chromium ${n.version()}`,node:process.versions.node.split(".")[0]};let o=await n.newPage({viewport:{width:ck.w,height:ck.h},deviceScaleFactor:1,reducedMotion:"reduce",locale:"en-US",timezoneId:"UTC"});await o.clock.setFixedTime(sk),await o.addInitScript(()=>{globalThis.__name=u=>u;let l=42;Math.random=()=>(l=l*16807%2147483647,(l-1)/2147483646)});let s=null,a=async l=>{if(!s){o.url().includes("/iframe.html")||(await o.goto(`${i}/iframe.html?id=${l}&viewMode=story`),await o.waitForSelector("#storybook-root > *"));let u=await o.evaluate(async()=>{let d=window.__STORYBOOK_PREVIEW__,p=await d.extract(),f=d.storyStoreValue?.projectAnnotations,h=m=>m===void 0?void 0:JSON.parse(JSON.stringify(m));return{projectGlobals:{viewport:h((f?.initialGlobals??f?.globals)?.viewport)},stories:Object.fromEntries(Object.entries(p).map(([m,g])=>[m,{parameters:{viewport:h(g.parameters?.viewport),codesignflo:h(g.parameters?.codesignflo)},globals:{viewport:h(g.globals?.viewport),viewportRotated:h(g.globals?.viewportRotated)}}]))}});s=new Map(Object.entries(u.stories).map(([d,p])=>{try{return[d,$z(p,u.projectGlobals)]}catch(f){throw new Error(`story ${d}: ${f.message}`)}}))}return s.get(l)??{}};return await e(o,async(l,u={})=>{let d=await a(l),p=u.size??d.size??ck;await o.clock.setFixedTime(d.date??sk),await o.setViewportSize({width:Math.round(p.w),height:Math.round(p.h)}),await o.goto(`${i}/iframe.html?id=${l}&viewMode=story`),await o.waitForSelector("#storybook-root > *"),await o.waitForFunction(()=>{let f=globalThis.__STORYBOOK_PREVIEW__?.currentRender;return!f?.phase||["completed","played","errored","aborted","finished"].includes(f.phase)},void 0,{timeout:2e4}).catch(()=>{}),await uk(o),d.fullHeight&&await C9(o,Math.round(p.w),Math.round(p.h))})}finally{await n.close(),r.close()}}async function uk(t){await t.evaluate(()=>new Promise(e=>{let r=setTimeout(o,250),i=setTimeout(o,4e3),n=new MutationObserver(()=>{clearTimeout(r),r=setTimeout(o,250)});n.observe(document.body,{subtree:!0,childList:!0,attributes:!0,characterData:!0});function o(){n.disconnect(),clearTimeout(r),clearTimeout(i),e()}})),await t.evaluate(()=>document.fonts.ready.then(()=>{})),await t.evaluate(()=>Promise.all(Array.from(document.images).map(e=>e.complete?null:new Promise(r=>{e.addEventListener("load",r),e.addEventListener("error",r)}))))}async function C9(t,e,r){let i=()=>t.evaluate(()=>{let s=0;for(let a of Array.from(document.querySelectorAll("*")))a===document.documentElement||a===document.body||a.scrollHeight<=a.clientHeight+1||/(auto|scroll)/.test(getComputedStyle(a).overflowY)&&(s=Math.max(s,a.scrollHeight-a.clientHeight));return Math.ceil(s)}),n=r,o=await i();for(let s=0;s<5&&o>1&&n<Oz;s++){let a=Math.min(Oz,n+o);await t.setViewportSize({width:e,height:a}),await uk(t);let c=await i();if(c>=o-1){await t.setViewportSize({width:e,height:n}),await uk(t);return}n=a,o=c}}async function Lm(t,e,r={}){return dk(t,async(i,n)=>{let o=JSON.parse(O9(lk(t,"index.json"),"utf8")),s=Object.entries(o.entries).find(([,f])=>f.type==="story")?.[0];if(!s)throw new Error("Storybook has no stories");await n(s);let a=await Ez(i,t,e),c=[...Object.values(a.components).flatMap(f=>[...Object.keys(f.stories),...Object.keys(f.examples??{})]),...Object.values(a.screens).map(f=>f.story)],l=new Map,u=new Map,d=f=>{if(f.image?.png){let h=pi(f.image.png);u.set(h,f.image.png),f.image={ref:h}}for(let h of f.children??[])d(h)},p=new Map(Object.entries(a.screens).flatMap(([f,h])=>r[f]?[[h.story,r[f]]]:[]));for(let f of[...new Set(c)].sort()){await n(f,{size:p.get(f)});let h=await i.evaluate(wz);d(h),l.set(f,{story:f,root:h})}return{registry:a,irs:l,images:u}})}Pr();import{existsSync as mk,mkdirSync as M9,readFileSync as Nz,rmSync as zz,writeFileSync as Cz}from"node:fs";import{homedir as F9}from"node:os";import{join as Mm}from"node:path";sr();Pr();sr();import{mkdirSync as N9,readFileSync as D9,writeFileSync as L9}from"node:fs";import{join as Rz,resolve as U9}from"node:path";async function fk(t){let e=fs();if(!e)return{lines:[],checks:[]};let r=Yt(),i=JSON.parse(D9(U9(r.tokens??"tokens/tokens.json"),"utf8")),n=new Set(Di(i).values()),{data:o,error:s}=await e.client.from("proposals").select("claim_id, component, payload").eq("project_id",e.projectId);if(s)throw new Error(`couldn't read proposals: ${s.message}`);let a=xt(Ct()),c=[],l=[];for(let u of o??[]){let d=a.get(u.component);if(d?.claim?.id!==u.claim_id)continue;if(d.state==="design_new"&&u.payload.spec){let O=Rz(gt(),"proposals",u.component,u.claim_id);N9(O,{recursive:!0}),L9(Rz(O,"spec.json"),Bn(fv(u.payload.spec))),c.push(`${u.component}: new design`);continue}if(d.state!=="ready_for_dev"||!u.payload.copy)continue;let p=u.payload.base??(d.claim.baselineGen?await Tu(u.component,d.claim.baselineGen):null),f=(d.lastGen?await Tu(u.component,d.lastGen):null)??p;if(!p||!f)continue;let h=t?.get(u.component),m=h?iu(f,h):null,g=m?.tree??f,y=Ct().some(O=>O.kind==="resolved"&&O.claim===u.claim_id&&O.take==="design"),{m:v,changes:b,content:x}=nu({base:es(p,g),ours:Ds(es(u.payload.copy,g),n),theirs:g,dtcg:i,...u.payload.scopes?{scopes:u.payload.scopes}:{},designWins:y});Um(u.component,u.claim_id,v,b,x);let k=y?0:v.summary.conflict,E=b.reduce((O,X)=>O+X.items.length,0);l.push({component:u.component,claim:u.claim_id,done:v.summary.convergent,total:v.summary.convergent+E+k,conflicts:k,exact:m?.exact??!0}),c.push(`${u.component}: ${b.length} change(s) to implement`)}return{lines:c,checks:l}}async function pk(){return(await fk()).lines}async function jz(){let t=await pk();return console.log(t.length?t.join(`
247
- `):"no proposals waiting"),0}async function gk(t){let{data:e}=await t.client.from("projects").select("settings").eq("id",t.projectId).single();return e?.settings?.liveBranch??Nm()??"main"}async function Dz(t){let e=await gk(t),r=Au(),i=Cm();if(r!==e)return{kind:"check",liveBranch:e,branch:r,commit:i,why:`Live follows ${e}`};let n=(In()??{}).liveIgnore??[],o=hz().filter(s=>mz(s,n));return o.length?{kind:"check",liveBranch:e,branch:r,commit:i,why:`uncommitted changes never reach Live: ${o.slice(0,5).join(", ")}${o.length>5?` and ${o.length-5} more`:""}`}:{kind:"live",liveBranch:e,branch:r,commit:i}}async function Lz(t,e){let{data:r}=await t.client.from("live_updates").select("commit").eq("project_id",t.projectId).eq("kind","live").neq("status","failed").filter("payload->only","is",null).order("id",{ascending:!1}).limit(1),i=r?.[0]?.commit;return i?i===e||_z(i)===!1:!1}async function Uz(t,e,r,i,n,o,s,a=!0){let{data:c}=await t.client.from("live_updates").select("payload->setup").eq("project_id",t.projectId).eq("kind","live").neq("status","failed").order("id",{ascending:!1}).limit(1),l=c?.[0]?.setup,u=l&&s&&(l.os!==s.os||l.browser!==s.browser),{data:d,error:p}=await t.client.from("live_updates").insert({project_id:t.projectId,commit:e.commit,branch:e.branch,kind:e.kind,status:e.kind==="live"?"pending":"checked",payload:e.kind==="live"?{...r,pictures:n,registry:o,setup:s}:{keys:r.keys,registry:o,dtcg:r.dtcg,setup:s}}).select("id").single();if(p)throw new Error(`couldn't upload to the service: ${p.message}`);let f=`${e.branch??"detached"} @${e.commit.slice(0,7)}`;console.log(e.kind==="live"?`Live update uploaded (${f}): the CoDesignFlo plugin applies it when the Figma file is open \u2014 now, or the next time someone opens it.`:`Checked ${f} \u2014 not a Live update (${e.why}).`);let h=new Map(i.map(y=>[y.k.replace(/^screen:/,""),y])),{checks:m}=await fk(h),g=new Date().toISOString();for(let y of m){let v=y.done===y.total;await t.client.from("proposals").update({code_check:{done:y.done,total:y.total,conflicts:y.conflicts,exact:y.exact,branch:e.branch,commit:e.commit,at:g}}).eq("project_id",t.projectId).eq("claim_id",y.claim);let b=e.kind==="live"?"it closes when the designer opens Figma (Live confirms it)":e.branch===e.liveBranch?"commit it, and it closes once Live has it":`it closes once this reaches ${e.liveBranch} and Live has it`;console.log(v?y.total===0?`${y.component}: nothing to change in the code (the designer's copy shows no difference); ${b}`:`${y.component}: looks done \u2014 ${y.total}/${y.total} of the designer's changes are in the code; ${b}${y.exact?"":" (layers added or removed: Live confirms the rest)"}`:`${y.component}: ${y.done} of ${y.total} of the designer's changes in the code${y.conflicts?`, ${y.conflicts} clashing`:""} \u2014 the rest: get_proposal ${y.component}`)}u&&console.log(`! rendered on ${s.os}, ${s.browser}; the last Live update was rendered on ${l.os}, ${l.browser} \u2014 small differences in Live can come from that (fonts, anti-aliasing), not the code`),e.kind==="live"&&a&&await Z9(t,d.id);for(let y of await yk(t,e.liveBranch))console.log(y);return 0}async function Z9(t,e){let{data:r}=await t.client.from("plugin_presence").select("seen_at, file_name").eq("project_id",t.projectId).order("seen_at",{ascending:!1}).limit(1),i=r?.[0];if(!i||Date.now()-Date.parse(i.seen_at)>6e4){console.log("Figma isn't open with the plugin: Live is updated when someone opens the file; status then shows how it went.");return}console.log(`Figma is open${i.file_name?` ("${i.file_name}")`:""}: waiting for the plugin to apply the update\u2026`);for(let n=0;n<3e5;n+=3e3){await new Promise(l=>setTimeout(l,3e3));let{data:o}=await t.client.from("live_updates").select("status, log").eq("id",e).single(),s=o;if(!s||s.status==="pending"||s.status==="applying")continue;if(s.status==="superseded")return void console.log("(a newer update replaced this one)");let a=(s.log??"").split(`
248
- `).filter(l=>/^(closed:|removed:|ready:|! |couldn't)/.test(l)||/ built on the designer's design| of \d+ layers match the app/.test(l));console.log(s.status==="applied"?"Applied in Figma.":"Applying it in Figma failed:");let c=l=>l.includes(": differs from the app \u2014 ")||l.includes(": the app differs from the design \u2014 ");for(let l of a.filter(u=>!c(u)))console.log(` ${l}`);for(let l of Hh(s.log,12))console.log(` ${l}`);return}console.log("Still being applied in Figma (large updates take a while); status shows how it went.")}async function yk(t,e,r=!1){let i=e??await gk(t),n=[],{data:o}=await t.client.from("live_updates").select("commit, status, created_at, log").eq("project_id",t.projectId).eq("kind","live").in("status",["pending","applying","applied"]).order("id",{ascending:!1}).limit(1),s=o?.[0],a=gz(i);if(!s)n.push(`Live: nothing uploaded from ${i} yet \u2014 sync on ${i} (or commit there with the hook on)`);else{let c=a?vz(s.commit,a):null;n.push(`Live: ${i} @${s.commit.slice(0,7)}${s.status==="applied"?"":" (waiting for the Figma file to be opened)"}${c?` \u2014 ${c} commit${c>1?"s":""} behind ${i}: sync on ${i} to update it`:""}`)}if(n.push(...Hh(s?.log,r?Number.POSITIVE_INFINITY:12)),a){let c=new Set([...xt(Ct()).values()].filter(u=>u.state==="ready_for_dev"&&u.claim).map(u=>u.claim.id)),{data:l}=await t.client.from("proposals").select("component, claim_id, code_check").eq("project_id",t.projectId).not("code_check","is",null);for(let u of l??[]){let d=u.code_check;!c.has(u.claim_id)||d.branch===i||d.done!==d.total||!d.total||(yz(a,d.commit)||bz(d.commit,a,q9(u.component)))&&n.push(`${u.component}: done on ${d.branch}, now merged into ${i} \u2014 Live has it after the next sync on ${i}`)}}return n}function q9(t){let e=Mm(gt(),"registry.json");if(!mk(e))return[];let r=JSON.parse(Nz(e,"utf8"));return r.components?.[t]?.files??r.screens?.[t]?.files??[]}var hk=()=>Mm(F9(),".codesignflo","locks");async function Mz(t,e){M9(hk(),{recursive:!0});let r=Mm(hk(),`${t}.lock`),i=Mm(hk(),`${t}.again`);if(mk(r)){let n=Number(Nz(r,"utf8")),o=!1;try{process.kill(n,0),o=!0}catch{}if(o)return Cz(i,"1"),!1}Cz(r,String(process.pid));try{do zz(i,{force:!0}),await e();while(mk(i))}finally{zz(r,{force:!0})}return!0}async function Fz(t,e){if(!e)throw new Error("this app isn't connected to the CoDesignFlo service \u2014 run: codesignflo init --cloud");let r=t.find(i=>!i.startsWith("--"));if(r){let{error:i}=await e.client.rpc("set_live_branch",{p_project:e.projectId,p_branch:r});if(i)throw new Error(i.message)}return console.log(`Live follows ${await gk(e)}${r?"":" (change it: codesignflo live-branch <name>)"}`),0}var H9=()=>Tn(gt(),"state.json"),bk={ledger:()=>Ct(),append:t=>En(t),generation:Tu,saveGeneration:cz,delta:(t,e,r,i,n)=>Zz(process.cwd(),Um(t,e,r,i,n)),newDesign:async(t,e,r,i)=>{let n=Tn(gt(),"proposals",t,e);return B9(n,{recursive:!0}),Ru(Tn(n,"spec.json"),Bn(r)),Ru(Tn(n,"design.png"),Buffer.from(await i(),"base64")),Zz(process.cwd(),n)}};function W9(){let t=[];for(let e of pz(void 0)){let r=Tn(gt(),"proposals",e.component,e.claim),i=Tn(r,`delivered-${e.commit.slice(0,8)}.json`),n=vk(i)?i:Tn(r,"delivered-track.json");if(!vk(n))continue;let{changes:o}=JSON.parse(_k(n,"utf8")),s=vk(Tn(r,"report.json"))?JSON.parse(_k(Tn(r,"report.json"),"utf8")).changes:[],a=Object.fromEntries(s.filter(c=>c.note).map(c=>[c.id,c.note]));t.push({...e,changes:o,why:a})}return t}async function K9(t){let{data:e}=await t.client.from("proposals").select("component, w:payload->spec->width, h:payload->spec->height, updated_at").eq("project_id",t.projectId).like("component","pages.%").order("updated_at",{ascending:!0}),r={};for(let i of e??[])typeof i.w=="number"&&typeof i.h=="number"&&i.w>0&&i.h>0&&(r[i.component]={w:i.w,h:i.h});return r}async function Bz(t=[]){let e=fs();if(t.includes("--from-hook")){if(!e)return 0;let r=0;return await Mz(e.projectId,async()=>{r=await Vz(t,e)}),r}return Vz(t,e)}async function Vz(t,e){let r=Yt(),i=e&&!t.includes("--local")?await Dz(e):null;if(e&&i&&t.includes("--from-hook")){if(i.kind!=="live"||await Lz(e,i.commit))return 0;console.log(`${new Date().toISOString()} hook: updating Live from ${i.liveBranch} @${i.commit.slice(0,7)}`)}let n=JSON.parse(_k(qz(r.tokens??"tokens/tokens.json"),"utf8")),o=r.storybook??{};t.includes("--no-build")||(console.error(`building Storybook (${o.build??"pnpm build-storybook"})\u2026`),V9(o.build??"pnpm build-storybook",{stdio:"ignore",env:{...process.env,STORYBOOK_DISABLE_TELEMETRY:"1"}})),console.error("reading Storybook\u2026");let s=e?await K9(e):{},{registry:a,irs:c,images:l}=await Lm(qz(o.out??"storybook-static"),process.cwd(),s),u=a;Ru(Tn(gt(),"registry.json"),`${JSON.stringify(a,null,2)}
249
- `),console.error(`${Object.keys(a.components).length} components, ${Object.keys(a.screens).length} screens, ${c.size} stories rendered`);let d=[...c.values()].reduce((O,X)=>{let le=$e=>($e.unnamed?1:0)+($e.children??[]).reduce((q,Re)=>q+le(Re),0);return O+le(X.root)},0);d&&console.error(`${d} element(s) without a semantic name \u2014 run: codesignflo name`);let p=Di(n),f=av(u,c,p),h=cv({...u,screens:u.screens??{}},c,p);if(t.includes("--dry-run")){for(let[O,X]of Object.entries(a.components)){let le=[...new Set(Object.values(X.stories).flatMap($e=>Object.keys($e)))];console.log(`${O.padEnd(18)} ${Object.keys(X.stories).length} variant(s)${le.length&&le[0]!=="story"?` by ${le.join(", ")}`:""}${X.examples?`, ${Object.keys(X.examples).length} example(s)`:""} \u2014 ${X.files.join(", ")}`)}for(let O of h)console.log(`screen ${O.spec.name.padEnd(11)} ${Math.round(100*O.coverage.inInstances/O.coverage.nodes)}% from library; instances ${JSON.stringify(O.coverage.instances)}`);return 0}let m=Cm(),g=[...Object.keys(u.components),...Object.keys(u.screens??{})],y=t.find(O=>O.startsWith("--only")),v=y?(y.includes("=")?y.split("=")[1]:t[t.indexOf(y)+1]??"").split(",").map(O=>O.trim()).filter(Boolean):void 0;if(v){let O=v.filter(X=>!g.includes(X));if(O.length)return console.error(`not in this app's Storybook: ${O.join(", ")} \u2014 known: ${g.join(", ")}`),1}let b={sets:f,screens:h.map(O=>({spec:O.spec,coverage:O.coverage})),dtcg:n,commit:m,keys:g,deliveries:W9(),...v?{only:v}:{}};if(e&&i)return Uz(e,i,b,[...f,...h.map(O=>O.spec)],l.size,a,Az(),!t.includes("--from-hook"));let x=r.trackedBranch,k=Au();if(x&&k&&k!==x&&!t.includes("--allow-branch"))return console.error(`Live mirrors "${x}", and you are on "${k}". Deliver works on any branch; run sync on ${x} after merging (it verifies delivered changes there). To update Live from this branch anyway: codesignflo sync --allow-branch`),1;let E;return await Yn({projectId:r.projectId},async O=>{let X=await $w(O,bk,{...b,images:Object.fromEntries(l)},le=>console.log(le));E=X.states;for(let le of X.notes)console.log(`! ${le}`)}),E&&Ru(Tn(gt(),"STATUS.md"),G9(E,u)),Ru(H9(),`${JSON.stringify({lastSyncCommit:m},null,2)}
250
- `),0}function G9(t,e){let r={in_sync:"In sync",in_design:"In design",ready_for_dev:"Ready for dev",design_new:"New design",code_new:"New in code",ignored:"Ignored"};return`# CoDesignFlo status
246
+ `)[0]}). Install it once with: npx playwright install chromium`)});try{Pz={os:`${process.platform}-${process.arch}`,browser:`chromium ${n.version()}`,node:process.versions.node.split(".")[0]};let o=await n.newPage({viewport:{width:ck.w,height:ck.h},deviceScaleFactor:1,reducedMotion:"reduce",locale:"en-US",timezoneId:"UTC"});await o.clock.setFixedTime(sk),await o.addInitScript(()=>{globalThis.__name=u=>u;let l=42;Math.random=()=>(l=l*16807%2147483647,(l-1)/2147483646)});let s=null,a=async l=>{if(!s){o.url().includes("/iframe.html")||(await o.goto(`${i}/iframe.html?id=${l}&viewMode=story`),await o.waitForSelector("#storybook-root > *"));let u=await o.evaluate(async()=>{let d=window.__STORYBOOK_PREVIEW__,p=await d.extract(),f=d.storyStoreValue?.projectAnnotations,h=m=>m===void 0?void 0:JSON.parse(JSON.stringify(m));return{projectGlobals:{viewport:h((f?.initialGlobals??f?.globals)?.viewport)},stories:Object.fromEntries(Object.entries(p).map(([m,g])=>[m,{parameters:{viewport:h(g.parameters?.viewport),codesignflo:h(g.parameters?.codesignflo)},globals:{viewport:h(g.globals?.viewport),viewportRotated:h(g.globals?.viewportRotated)}}]))}});s=new Map(Object.entries(u.stories).map(([d,p])=>{try{return[d,$z(p,u.projectGlobals)]}catch(f){throw new Error(`story ${d}: ${f.message}`)}}))}return s.get(l)??{}};return await e(o,async(l,u={})=>{let d=await a(l),p=u.size??d.size??ck;await o.clock.setFixedTime(d.date??sk),await o.setViewportSize({width:Math.round(p.w),height:Math.round(p.h)}),await o.goto(`${i}/iframe.html?id=${l}&viewMode=story`),await o.waitForSelector("#storybook-root > *"),await o.waitForFunction(()=>{let f=globalThis.__STORYBOOK_PREVIEW__?.currentRender;return!f?.phase||["completed","played","errored","aborted","finished"].includes(f.phase)},void 0,{timeout:2e4}).catch(()=>{}),await uk(o),d.fullHeight&&await C9(o,Math.round(p.w),Math.round(p.h))})}finally{await n.close(),r.close()}}async function uk(t){await t.evaluate(()=>new Promise(e=>{let r=setTimeout(o,250),i=setTimeout(o,4e3),n=new MutationObserver(()=>{clearTimeout(r),r=setTimeout(o,250)});n.observe(document.body,{subtree:!0,childList:!0,attributes:!0,characterData:!0});function o(){n.disconnect(),clearTimeout(r),clearTimeout(i),e()}})),await t.evaluate(()=>document.fonts.ready.then(()=>{})),await t.evaluate(()=>Promise.all(Array.from(document.images).map(e=>e.complete?null:new Promise(r=>{e.addEventListener("load",r),e.addEventListener("error",r)}))))}async function C9(t,e,r){let i=()=>t.evaluate(()=>{let s=0;for(let a of Array.from(document.querySelectorAll("*")))a===document.documentElement||a===document.body||a.scrollHeight<=a.clientHeight+1||/(auto|scroll)/.test(getComputedStyle(a).overflowY)&&(s=Math.max(s,a.scrollHeight-a.clientHeight));return Math.ceil(s)}),n=r,o=await i();for(let s=0;s<5&&o>1&&n<Oz;s++){let a=Math.min(Oz,n+o);await t.setViewportSize({width:e,height:a}),await uk(t);let c=await i();if(c>=o-1){await t.setViewportSize({width:e,height:n}),await uk(t);return}n=a,o=c}}async function Lm(t,e,r={}){return dk(t,async(i,n)=>{let o=JSON.parse(O9(lk(t,"index.json"),"utf8")),s=Object.entries(o.entries).find(([,f])=>f.type==="story")?.[0];if(!s)throw new Error("Storybook has no stories");await n(s);let a=await Ez(i,t,e),c=[...Object.values(a.components).flatMap(f=>[...Object.keys(f.stories),...Object.keys(f.examples??{})]),...Object.values(a.screens).map(f=>f.story)],l=new Map,u=new Map,d=f=>{if(f.image?.png){let h=pi(f.image.png);u.set(h,f.image.png),f.image={ref:h}}for(let h of f.children??[])d(h)},p=new Map(Object.entries(a.screens).flatMap(([f,h])=>r[f]?[[h.story,r[f]]]:[]));for(let f of[...new Set(c)].sort()){await n(f,{size:p.get(f)});let h=await i.evaluate(wz);d(h),l.set(f,{story:f,root:h})}return{registry:a,irs:l,images:u}})}Pr();import{existsSync as mk,mkdirSync as M9,readFileSync as Nz,rmSync as zz,writeFileSync as Cz}from"node:fs";import{homedir as F9}from"node:os";import{join as Mm}from"node:path";import{gzipSync as Z9}from"node:zlib";sr();Pr();sr();import{mkdirSync as N9,readFileSync as D9,writeFileSync as L9}from"node:fs";import{join as Rz,resolve as U9}from"node:path";async function fk(t){let e=fs();if(!e)return{lines:[],checks:[]};let r=Yt(),i=JSON.parse(D9(U9(r.tokens??"tokens/tokens.json"),"utf8")),n=new Set(Di(i).values()),{data:o,error:s}=await e.client.from("proposals").select("claim_id, component, payload").eq("project_id",e.projectId);if(s)throw new Error(`couldn't read proposals: ${s.message}`);let a=xt(Ct()),c=[],l=[];for(let u of o??[]){let d=a.get(u.component);if(d?.claim?.id!==u.claim_id)continue;if(d.state==="design_new"&&u.payload.spec){let O=Rz(gt(),"proposals",u.component,u.claim_id);N9(O,{recursive:!0}),L9(Rz(O,"spec.json"),Bn(fv(u.payload.spec))),c.push(`${u.component}: new design`);continue}if(d.state!=="ready_for_dev"||!u.payload.copy)continue;let p=u.payload.base??(d.claim.baselineGen?await Tu(u.component,d.claim.baselineGen):null),f=(d.lastGen?await Tu(u.component,d.lastGen):null)??p;if(!p||!f)continue;let h=t?.get(u.component),m=h?iu(f,h):null,g=m?.tree??f,y=Ct().some(O=>O.kind==="resolved"&&O.claim===u.claim_id&&O.take==="design"),{m:v,changes:b,content:x}=nu({base:es(p,g),ours:Ds(es(u.payload.copy,g),n),theirs:g,dtcg:i,...u.payload.scopes?{scopes:u.payload.scopes}:{},designWins:y});Um(u.component,u.claim_id,v,b,x);let k=y?0:v.summary.conflict,E=b.reduce((O,X)=>O+X.items.length,0);l.push({component:u.component,claim:u.claim_id,done:v.summary.convergent,total:v.summary.convergent+E+k,conflicts:k,exact:m?.exact??!0}),c.push(`${u.component}: ${b.length} change(s) to implement`)}return{lines:c,checks:l}}async function pk(){return(await fk()).lines}async function jz(){let t=await pk();return console.log(t.length?t.join(`
247
+ `):"no proposals waiting"),0}async function gk(t){let{data:e}=await t.client.from("projects").select("settings").eq("id",t.projectId).single();return e?.settings?.liveBranch??Nm()??"main"}async function Dz(t){let e=await gk(t),r=Au(),i=Cm();if(r!==e)return{kind:"check",liveBranch:e,branch:r,commit:i,why:`Live follows ${e}`};let n=(In()??{}).liveIgnore??[],o=hz().filter(s=>mz(s,n));return o.length?{kind:"check",liveBranch:e,branch:r,commit:i,why:`uncommitted changes never reach Live: ${o.slice(0,5).join(", ")}${o.length>5?` and ${o.length-5} more`:""}`}:{kind:"live",liveBranch:e,branch:r,commit:i}}async function Lz(t,e){let{data:r}=await t.client.from("live_updates").select("commit").eq("project_id",t.projectId).eq("kind","live").neq("status","failed").filter("payload->only","is",null).order("id",{ascending:!1}).limit(1),i=r?.[0]?.commit;return i?i===e||_z(i)===!1:!1}function q9(t){let e={sets:t.sets,screens:t.screens};return Z9(JSON.stringify(e)).toString("base64")}function V9(t){let{sets:e,screens:r,...i}=t;return i}async function Uz(t,e,r,i,n,o,s,a=!0){let{data:c}=await t.client.from("live_updates").select("payload->setup").eq("project_id",t.projectId).eq("kind","live").neq("status","failed").order("id",{ascending:!1}).limit(1),l=c?.[0]?.setup,u=l&&s&&(l.os!==s.os||l.browser!==s.browser),{data:d,error:p}=await t.client.from("live_updates").insert({project_id:t.projectId,commit:e.commit,branch:e.branch,kind:e.kind,status:e.kind==="live"?"pending":"checked",...e.kind==="live"?{payload:{...V9(r),pictures:n,registry:o,setup:s},bundle:q9(r)}:{payload:{keys:r.keys,registry:o,dtcg:r.dtcg,setup:s}}}).select("id").single();if(p)throw new Error(`couldn't upload to the service: ${p.message}`);let f=`${e.branch??"detached"} @${e.commit.slice(0,7)}`;console.log(e.kind==="live"?`Live update uploaded (${f}): the CoDesignFlo plugin applies it when the Figma file is open \u2014 now, or the next time someone opens it.`:`Checked ${f} \u2014 not a Live update (${e.why}).`);let h=new Map(i.map(y=>[y.k.replace(/^screen:/,""),y])),{checks:m}=await fk(h),g=new Date().toISOString();for(let y of m){let v=y.done===y.total;await t.client.from("proposals").update({code_check:{done:y.done,total:y.total,conflicts:y.conflicts,exact:y.exact,branch:e.branch,commit:e.commit,at:g}}).eq("project_id",t.projectId).eq("claim_id",y.claim);let b=e.kind==="live"?"it closes when the designer opens Figma (Live confirms it)":e.branch===e.liveBranch?"commit it, and it closes once Live has it":`it closes once this reaches ${e.liveBranch} and Live has it`;console.log(v?y.total===0?`${y.component}: nothing to change in the code (the designer's copy shows no difference); ${b}`:`${y.component}: looks done \u2014 ${y.total}/${y.total} of the designer's changes are in the code; ${b}${y.exact?"":" (layers added or removed: Live confirms the rest)"}`:`${y.component}: ${y.done} of ${y.total} of the designer's changes in the code${y.conflicts?`, ${y.conflicts} clashing`:""} \u2014 the rest: get_proposal ${y.component}`)}u&&console.log(`! rendered on ${s.os}, ${s.browser}; the last Live update was rendered on ${l.os}, ${l.browser} \u2014 small differences in Live can come from that (fonts, anti-aliasing), not the code`),e.kind==="live"&&a&&await B9(t,d.id);for(let y of await yk(t,e.liveBranch))console.log(y);return 0}async function B9(t,e){let{data:r}=await t.client.from("plugin_presence").select("seen_at, file_name").eq("project_id",t.projectId).order("seen_at",{ascending:!1}).limit(1),i=r?.[0];if(!i||Date.now()-Date.parse(i.seen_at)>6e4){console.log("Figma isn't open with the plugin: Live is updated when someone opens the file; status then shows how it went.");return}console.log(`Figma is open${i.file_name?` ("${i.file_name}")`:""}: waiting for the plugin to apply the update\u2026`);for(let n=0;n<3e5;n+=3e3){await new Promise(l=>setTimeout(l,3e3));let{data:o}=await t.client.from("live_updates").select("status, log").eq("id",e).single(),s=o;if(!s||s.status==="pending"||s.status==="applying")continue;if(s.status==="superseded")return void console.log("(a newer update replaced this one)");let a=(s.log??"").split(`
248
+ `).filter(l=>/^(closed:|removed:|ready:|! |couldn't)/.test(l)||/ built on the designer's design| of \d+ layers match the app/.test(l));console.log(s.status==="applied"?"Applied in Figma.":"Applying it in Figma failed:");let c=l=>l.includes(": differs from the app \u2014 ")||l.includes(": the app differs from the design \u2014 ");for(let l of a.filter(u=>!c(u)))console.log(` ${l}`);for(let l of Hh(s.log,12))console.log(` ${l}`);return}console.log("Still being applied in Figma (large updates take a while); status shows how it went.")}async function yk(t,e,r=!1){let i=e??await gk(t),n=[],{data:o}=await t.client.from("live_updates").select("commit, status, created_at, log").eq("project_id",t.projectId).eq("kind","live").in("status",["pending","applying","applied"]).order("id",{ascending:!1}).limit(1),s=o?.[0],a=gz(i);if(!s)n.push(`Live: nothing uploaded from ${i} yet \u2014 sync on ${i} (or commit there with the hook on)`);else{let c=a?vz(s.commit,a):null;n.push(`Live: ${i} @${s.commit.slice(0,7)}${s.status==="applied"?"":" (waiting for the Figma file to be opened)"}${c?` \u2014 ${c} commit${c>1?"s":""} behind ${i}: sync on ${i} to update it`:""}`)}if(n.push(...Hh(s?.log,r?Number.POSITIVE_INFINITY:12)),a){let c=new Set([...xt(Ct()).values()].filter(u=>u.state==="ready_for_dev"&&u.claim).map(u=>u.claim.id)),{data:l}=await t.client.from("proposals").select("component, claim_id, code_check").eq("project_id",t.projectId).not("code_check","is",null);for(let u of l??[]){let d=u.code_check;!c.has(u.claim_id)||d.branch===i||d.done!==d.total||!d.total||(yz(a,d.commit)||bz(d.commit,a,H9(u.component)))&&n.push(`${u.component}: done on ${d.branch}, now merged into ${i} \u2014 Live has it after the next sync on ${i}`)}}return n}function H9(t){let e=Mm(gt(),"registry.json");if(!mk(e))return[];let r=JSON.parse(Nz(e,"utf8"));return r.components?.[t]?.files??r.screens?.[t]?.files??[]}var hk=()=>Mm(F9(),".codesignflo","locks");async function Mz(t,e){M9(hk(),{recursive:!0});let r=Mm(hk(),`${t}.lock`),i=Mm(hk(),`${t}.again`);if(mk(r)){let n=Number(Nz(r,"utf8")),o=!1;try{process.kill(n,0),o=!0}catch{}if(o)return Cz(i,"1"),!1}Cz(r,String(process.pid));try{do zz(i,{force:!0}),await e();while(mk(i))}finally{zz(r,{force:!0})}return!0}async function Fz(t,e){if(!e)throw new Error("this app isn't connected to the CoDesignFlo service \u2014 run: codesignflo init --cloud");let r=t.find(i=>!i.startsWith("--"));if(r){let{error:i}=await e.client.rpc("set_live_branch",{p_project:e.projectId,p_branch:r});if(i)throw new Error(i.message)}return console.log(`Live follows ${await gk(e)}${r?"":" (change it: codesignflo live-branch <name>)"}`),0}var G9=()=>Tn(gt(),"state.json"),bk={ledger:()=>Ct(),append:t=>En(t),generation:Tu,saveGeneration:cz,delta:(t,e,r,i,n)=>Zz(process.cwd(),Um(t,e,r,i,n)),newDesign:async(t,e,r,i)=>{let n=Tn(gt(),"proposals",t,e);return K9(n,{recursive:!0}),Ru(Tn(n,"spec.json"),Bn(r)),Ru(Tn(n,"design.png"),Buffer.from(await i(),"base64")),Zz(process.cwd(),n)}};function J9(){let t=[];for(let e of pz(void 0)){let r=Tn(gt(),"proposals",e.component,e.claim),i=Tn(r,`delivered-${e.commit.slice(0,8)}.json`),n=vk(i)?i:Tn(r,"delivered-track.json");if(!vk(n))continue;let{changes:o}=JSON.parse(_k(n,"utf8")),s=vk(Tn(r,"report.json"))?JSON.parse(_k(Tn(r,"report.json"),"utf8")).changes:[],a=Object.fromEntries(s.filter(c=>c.note).map(c=>[c.id,c.note]));t.push({...e,changes:o,why:a})}return t}async function X9(t){let{data:e}=await t.client.from("proposals").select("component, w:payload->spec->width, h:payload->spec->height, updated_at").eq("project_id",t.projectId).like("component","pages.%").order("updated_at",{ascending:!0}),r={};for(let i of e??[])typeof i.w=="number"&&typeof i.h=="number"&&i.w>0&&i.h>0&&(r[i.component]={w:i.w,h:i.h});return r}async function Bz(t=[]){let e=fs();if(t.includes("--from-hook")){if(!e)return 0;let r=0;return await Mz(e.projectId,async()=>{r=await Vz(t,e)}),r}return Vz(t,e)}async function Vz(t,e){let r=Yt(),i=e&&!t.includes("--local")?await Dz(e):null;if(e&&i&&t.includes("--from-hook")){if(i.kind!=="live"||await Lz(e,i.commit))return 0;console.log(`${new Date().toISOString()} hook: updating Live from ${i.liveBranch} @${i.commit.slice(0,7)}`)}let n=JSON.parse(_k(qz(r.tokens??"tokens/tokens.json"),"utf8")),o=r.storybook??{};t.includes("--no-build")||(console.error(`building Storybook (${o.build??"pnpm build-storybook"})\u2026`),W9(o.build??"pnpm build-storybook",{stdio:"ignore",env:{...process.env,STORYBOOK_DISABLE_TELEMETRY:"1"}})),console.error("reading Storybook\u2026");let s=e?await X9(e):{},{registry:a,irs:c,images:l}=await Lm(qz(o.out??"storybook-static"),process.cwd(),s),u=a;Ru(Tn(gt(),"registry.json"),`${JSON.stringify(a,null,2)}
249
+ `),console.error(`${Object.keys(a.components).length} components, ${Object.keys(a.screens).length} screens, ${c.size} stories rendered`);let d=[...c.values()].reduce((O,X)=>{let le=$e=>($e.unnamed?1:0)+($e.children??[]).reduce((q,Re)=>q+le(Re),0);return O+le(X.root)},0);d&&console.error(`${d} element(s) without a semantic name \u2014 run: codesignflo name`);let p=Di(n),f=av(u,c,p),h=cv({...u,screens:u.screens??{}},c,p);if(t.includes("--dry-run")){for(let[O,X]of Object.entries(a.components)){let le=[...new Set(Object.values(X.stories).flatMap($e=>Object.keys($e)))];console.log(`${O.padEnd(18)} ${Object.keys(X.stories).length} variant(s)${le.length&&le[0]!=="story"?` by ${le.join(", ")}`:""}${X.examples?`, ${Object.keys(X.examples).length} example(s)`:""} \u2014 ${X.files.join(", ")}`)}for(let O of h)console.log(`screen ${O.spec.name.padEnd(11)} ${Math.round(100*O.coverage.inInstances/O.coverage.nodes)}% from library; instances ${JSON.stringify(O.coverage.instances)}`);return 0}let m=Cm(),g=[...Object.keys(u.components),...Object.keys(u.screens??{})],y=t.find(O=>O.startsWith("--only")),v=y?(y.includes("=")?y.split("=")[1]:t[t.indexOf(y)+1]??"").split(",").map(O=>O.trim()).filter(Boolean):void 0;if(v){let O=v.filter(X=>!g.includes(X));if(O.length)return console.error(`not in this app's Storybook: ${O.join(", ")} \u2014 known: ${g.join(", ")}`),1}let b={sets:f,screens:h.map(O=>({spec:O.spec,coverage:O.coverage})),dtcg:n,commit:m,keys:g,deliveries:J9(),...v?{only:v}:{}};if(e&&i)return Uz(e,i,b,[...f,...h.map(O=>O.spec)],l.size,a,Az(),!t.includes("--from-hook"));let x=r.trackedBranch,k=Au();if(x&&k&&k!==x&&!t.includes("--allow-branch"))return console.error(`Live mirrors "${x}", and you are on "${k}". Deliver works on any branch; run sync on ${x} after merging (it verifies delivered changes there). To update Live from this branch anyway: codesignflo sync --allow-branch`),1;let E;return await Yn({projectId:r.projectId},async O=>{let X=await $w(O,bk,{...b,images:Object.fromEntries(l)},le=>console.log(le));E=X.states;for(let le of X.notes)console.log(`! ${le}`)}),E&&Ru(Tn(gt(),"STATUS.md"),Y9(E,u)),Ru(G9(),`${JSON.stringify({lastSyncCommit:m},null,2)}
250
+ `),0}function Y9(t,e){let r={in_sync:"In sync",in_design:"In design",ready_for_dev:"Ready for dev",design_new:"New design",code_new:"New in code",ignored:"Ignored"};return`# CoDesignFlo status
251
251
 
252
252
  Generated by \`codesignflo sync\`. Do not edit.
253
253
 
@@ -255,25 +255,25 @@ Generated by \`codesignflo sync\`. Do not edit.
255
255
  |---|---|---|---|
256
256
  ${[...t.values()].filter(n=>e.components[n.component]||e.screens?.[n.component]||n.state==="design_new").map(n=>`| ${n.component} | ${n.conflict?"Needs a look":n.unseen?"Changed in code":r[n.state]} | ${n.claim?n.claim.by:""} | ${(n.claim?.note??"").replace(/\|/g,"\\|")} |`).join(`
257
257
  `)}
258
- `}function Um(t,e,r,i,n){let o=wk(gt(),"proposals",t,e);return J9(o,{recursive:!0}),Hz(wk(o,"delta.json"),`${JSON.stringify(r,null,2)}
258
+ `}function Um(t,e,r,i,n){let o=wk(gt(),"proposals",t,e);return Q9(o,{recursive:!0}),Hz(wk(o,"delta.json"),`${JSON.stringify(r,null,2)}
259
259
  `),Hz(wk(o,"changes.json"),`${JSON.stringify({changes:i,content:n},null,2)}
260
- `),o}async function Wz(){let t=Yt(),e=await Yn({projectId:t.projectId},r=>Bh(r,bk,JSON.parse(X9(Y9(t.tokens??"tokens/tokens.json"),"utf8"))));e.length||console.log("no proposals are ready for dev");for(let r of e){console.log(`
261
- ${r.component} \u2014 proposal ${r.claim} by ${r.by}${r.note?`: "${r.note}"`:""}`),console.log(`${r.changes.length} code change${r.changes.length===1?"":"s"}${r.conflicts?`, ${r.conflicts} conflicting with code`:""}:`);for(let i of r.changes)console.log(` ${i.id} [${i.kind}] ${i.layer} ${i.prop}: ${i.from} \u2192 ${i.to}${i.variants==="all"?" (all variants)":i.scope==="variants"?` (only: ${i.variants.join("; ")})`:` (made in ${i.variants.join("; ")} \u2014 apply to all)`}`);if(r.content.length){console.log("content changes (example data, no code impact):");for(let i of r.content)console.log(` ${i.layer}: ${i.from} \u2192 ${i.to}`)}console.log(`written: ${r.folder}`)}return 0}sr();import{readFileSync as Kz}from"node:fs";async function Gz(){let t=Yt(),e=new URL("../../../plugin/dist/",import.meta.url),r=Kz(new URL("code.js",e),"utf8"),i=Kz(new URL("ui.html",e),"utf8");return await Yn({projectId:t.projectId},async n=>{await n.call("dev.reload",{code:r,html:i})}),console.log(`plugin reloaded (${Math.round(r.length/1024)} kB code, ${Math.round(i.length/1024)} kB panel)`),0}import{execFileSync as tW}from"node:child_process";import{chmodSync as rW,existsSync as eC,mkdirSync as Yz,readFileSync as tC,rmSync as nW,writeFileSync as rC}from"node:fs";import{homedir as nC}from"node:os";import{dirname as iW,join as ju,resolve as oW}from"node:path";import{fileURLToPath as sW}from"node:url";sr();La();La();import{spawn as Q9}from"node:child_process";var eW=t=>new Promise(e=>setTimeout(e,t));async function Fm(t){let e=Da(),r=Q$(e),{data:i,error:n}=await r.rpc("start_login",{p_client:"cli"});if(n)throw new Error(`couldn't start sign-in: ${n.message}`);let{device_code:o,user_code:s}=i[0],a=`${s.slice(0,4)}-${s.slice(4)}`,c=`${e.web}/?code=${s}`;console.log(`Sign in at ${c}
262
- and check that the page shows the code ${a}`),t.includes("--no-browser")||Q9(process.platform==="darwin"?"open":"xdg-open",[c],{stdio:"ignore",detached:!0}).unref();for(let l=0;l<6e5;l+=2e3){await eW(2e3);let u=await r.rpc("poll_login",{p_device_code:o});if(u.error)throw new Error(u.error.message);if(u.data){let d=await r.auth.refreshSession({refresh_token:u.data});if(d.error||!d.data.session||!d.data.user)throw new Error("sign-in failed \u2014 try again");return Eu(d.data.session.refresh_token,{id:d.data.user.id,email:d.data.user.email??null}),console.log(`signed in as ${d.data.user.email??d.data.user.id}`),0}}throw new Error("sign-in timed out \u2014 run codesignflo login again")}async function Jz(){let{user:t}=await an();return console.log(t.email??t.id),0}async function Xz(t){if(!Am())return console.log("not signed in on this machine"),0;let e=t.includes("--everywhere");try{let{client:r}=await an(),{error:i}=await r.auth.signOut({scope:e?"global":"local"});if(i)throw i}catch(r){if(!/expired/.test(r.message))throw r}return Xj(),console.log(e?"signed out everywhere: every session of this account is revoked":"signed out on this machine (its sign-in is revoked)"),0}var iC="# >>> codesignflo: update Live on commits to the Live branch",oC="# <<< codesignflo",sC=["post-commit","post-merge"],Qz=t=>tW("git",t,{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim(),Fa=t=>`'${t.replace(/'/g,"'\\''")}'`;function aC(){let t=sW(new URL("../main.js",import.meta.url));return t.includes("/_npx/")||t.includes("/node_modules/@orkestralai/")?`${Fa(ju(iW(process.execPath),"npx"))} -y @orkestralai/codesignflo@${Nc}`:`${Fa(process.execPath)} ${Fa(t)}`}function aW(t,e){let r=ju(nC(),".codesignflo","logs",`${e}.log`);return`${iC} (remove: codesignflo hook remove)
260
+ `),o}async function Wz(){let t=Yt(),e=await Yn({projectId:t.projectId},r=>Bh(r,bk,JSON.parse(eW(tW(t.tokens??"tokens/tokens.json"),"utf8"))));e.length||console.log("no proposals are ready for dev");for(let r of e){console.log(`
261
+ ${r.component} \u2014 proposal ${r.claim} by ${r.by}${r.note?`: "${r.note}"`:""}`),console.log(`${r.changes.length} code change${r.changes.length===1?"":"s"}${r.conflicts?`, ${r.conflicts} conflicting with code`:""}:`);for(let i of r.changes)console.log(` ${i.id} [${i.kind}] ${i.layer} ${i.prop}: ${i.from} \u2192 ${i.to}${i.variants==="all"?" (all variants)":i.scope==="variants"?` (only: ${i.variants.join("; ")})`:` (made in ${i.variants.join("; ")} \u2014 apply to all)`}`);if(r.content.length){console.log("content changes (example data, no code impact):");for(let i of r.content)console.log(` ${i.layer}: ${i.from} \u2192 ${i.to}`)}console.log(`written: ${r.folder}`)}return 0}sr();import{readFileSync as Kz}from"node:fs";async function Gz(){let t=Yt(),e=new URL("../../../plugin/dist/",import.meta.url),r=Kz(new URL("code.js",e),"utf8"),i=Kz(new URL("ui.html",e),"utf8");return await Yn({projectId:t.projectId},async n=>{await n.call("dev.reload",{code:r,html:i})}),console.log(`plugin reloaded (${Math.round(r.length/1024)} kB code, ${Math.round(i.length/1024)} kB panel)`),0}import{execFileSync as iW}from"node:child_process";import{chmodSync as oW,existsSync as eC,mkdirSync as Yz,readFileSync as tC,rmSync as sW,writeFileSync as rC}from"node:fs";import{homedir as nC}from"node:os";import{dirname as aW,join as ju,resolve as cW}from"node:path";import{fileURLToPath as lW}from"node:url";sr();La();La();import{spawn as rW}from"node:child_process";var nW=t=>new Promise(e=>setTimeout(e,t));async function Fm(t){let e=Da(),r=Q$(e),{data:i,error:n}=await r.rpc("start_login",{p_client:"cli"});if(n)throw new Error(`couldn't start sign-in: ${n.message}`);let{device_code:o,user_code:s}=i[0],a=`${s.slice(0,4)}-${s.slice(4)}`,c=`${e.web}/?code=${s}`;console.log(`Sign in at ${c}
262
+ and check that the page shows the code ${a}`),t.includes("--no-browser")||rW(process.platform==="darwin"?"open":"xdg-open",[c],{stdio:"ignore",detached:!0}).unref();for(let l=0;l<6e5;l+=2e3){await nW(2e3);let u=await r.rpc("poll_login",{p_device_code:o});if(u.error)throw new Error(u.error.message);if(u.data){let d=await r.auth.refreshSession({refresh_token:u.data});if(d.error||!d.data.session||!d.data.user)throw new Error("sign-in failed \u2014 try again");return Eu(d.data.session.refresh_token,{id:d.data.user.id,email:d.data.user.email??null}),console.log(`signed in as ${d.data.user.email??d.data.user.id}`),0}}throw new Error("sign-in timed out \u2014 run codesignflo login again")}async function Jz(){let{user:t}=await an();return console.log(t.email??t.id),0}async function Xz(t){if(!Am())return console.log("not signed in on this machine"),0;let e=t.includes("--everywhere");try{let{client:r}=await an(),{error:i}=await r.auth.signOut({scope:e?"global":"local"});if(i)throw i}catch(r){if(!/expired/.test(r.message))throw r}return Xj(),console.log(e?"signed out everywhere: every session of this account is revoked":"signed out on this machine (its sign-in is revoked)"),0}var iC="# >>> codesignflo: update Live on commits to the Live branch",oC="# <<< codesignflo",sC=["post-commit","post-merge"],Qz=t=>iW("git",t,{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim(),Fa=t=>`'${t.replace(/'/g,"'\\''")}'`;function aC(){let t=lW(new URL("../main.js",import.meta.url));return t.includes("/_npx/")||t.includes("/node_modules/@orkestralai/")?`${Fa(ju(aW(process.execPath),"npx"))} -y @orkestralai/codesignflo@${Nc}`:`${Fa(process.execPath)} ${Fa(t)}`}function uW(t,e){let r=ju(nC(),".codesignflo","logs",`${e}.log`);return`${iC} (remove: codesignflo hook remove)
263
263
  ( cd ${Fa(t)} && nohup ${aC()} sync --from-hook >> ${Fa(r)} 2>&1 & ) >/dev/null 2>&1
264
264
  ${oC}
265
- `}function cC(){let t="";try{t=Qz(["config","--get","core.hooksPath"])}catch{}return t?{dir:null,managedBy:t}:{dir:oW(Qz(["rev-parse","--git-path","hooks"]))}}var lC=t=>t.replace(new RegExp(`${iC}[\\s\\S]*?${oC}\\n?`,"g"),"");function $k(){let t=In();if(!t?.cloud)return{ok:!1,message:"the hook is for projects connected to the service (init --cloud)"};let{dir:e,managedBy:r}=cC(),i=`${aC()} sync --from-hook`;if(!e)return{ok:!1,message:`this repo's hooks are managed in ${r} (husky, lefthook\u2026), which is part of the repo. To keep Live updated on commits, add this to its post-commit and post-merge hooks \u2014 or skip it: the agent syncs after its own commits.
265
+ `}function cC(){let t="";try{t=Qz(["config","--get","core.hooksPath"])}catch{}return t?{dir:null,managedBy:t}:{dir:cW(Qz(["rev-parse","--git-path","hooks"]))}}var lC=t=>t.replace(new RegExp(`${iC}[\\s\\S]*?${oC}\\n?`,"g"),"");function $k(){let t=In();if(!t?.cloud)return{ok:!1,message:"the hook is for projects connected to the service (init --cloud)"};let{dir:e,managedBy:r}=cC(),i=`${aC()} sync --from-hook`;if(!e)return{ok:!1,message:`this repo's hooks are managed in ${r} (husky, lefthook\u2026), which is part of the repo. To keep Live updated on commits, add this to its post-commit and post-merge hooks \u2014 or skip it: the agent syncs after its own commits.
266
266
  (cd ${Fa(process.cwd())} && nohup ${i} >/dev/null 2>&1 &)`};Yz(e,{recursive:!0}),Yz(ju(nC(),".codesignflo","logs"),{recursive:!0});for(let n of sC){let o=ju(e,n),s=eC(o)?lC(tC(o,"utf8")):`#!/bin/sh
267
267
  `;rC(o,`${s.endsWith(`
268
268
  `)?s:`${s}
269
- `}${aW(process.cwd(),t.projectId)}`),rW(o,493)}return{ok:!0,message:`Live updates on every commit to the Live branch on this machine (git hooks post-commit and post-merge in ${e}; not part of the repo). Log: ~/.codesignflo/logs/${t.projectId}.log`}}function cW(){let{dir:t}=cC();if(!t)return"nothing to remove (hooks are managed by the repo's hook tool)";let e=0;for(let r of sC){let i=ju(t,r);if(!eC(i))continue;let n=tC(i,"utf8"),o=lC(n);o!==n&&(o.trim()==="#!/bin/sh"?nW(i):rC(i,o),e++)}return e?"removed: commits no longer update Live by themselves (to also revoke this machine's sign-in: codesignflo logout)":"no CoDesignFlo hook here"}async function uC(t){if(t[0]==="remove")return console.log(cW()),0;if(t[0]!=="install")throw new Error("usage: codesignflo hook install [--code <one-time code> --from <MCP address>] | remove");let e=t.includes("--code")?t[t.indexOf("--code")+1]:void 0,r=t.includes("--from")?t[t.indexOf("--from")+1]:void 0;if(e&&r){let n=await fetch(`${r.replace(/\/$/,"")}/install-code`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:e})}),o=await n.json();if(!n.ok||!o.refresh_token||!o.service)throw new Error(o.error??"couldn't use the code \u2014 ask the agent for auto_update again");Y$(o.service),Eu(o.refresh_token,{id:"",email:null}),delete process.env.CODESIGNFLO_TOKEN,delete process.env.CODESIGNFLO_TICKET;let{user:s}=await an();console.log(`this machine is signed in as ${s.email??s.id} (codesignflo logout to undo)`)}else Am()||(console.log("The hook runs by itself after commits, so this machine needs its own sign-in (once):"),delete process.env.CODESIGNFLO_TOKEN,delete process.env.CODESIGNFLO_TICKET,await Fm([]));process.env.CODESIGNFLO_SERVICE_URL&&process.env.CODESIGNFLO_SERVICE_ANON&&Y$(Da());let i=$k();return console.log(i.message),i.ok?0:2}Pr();import{execFileSync as fC}from"node:child_process";import{randomBytes as gW}from"node:crypto";import{existsSync as zu,readdirSync as yW,readFileSync as Sk}from"node:fs";import{createRequire as vW}from"node:module";import{dirname as _W,join as pC}from"node:path";import{chromium as bW}from"playwright";sr();La();import{execFileSync as lW}from"node:child_process";import{cpSync as uW,existsSync as dW,mkdirSync as fW,readdirSync as pW}from"node:fs";import{join as Zm,relative as hW}from"node:path";import{fileURLToPath as mW}from"node:url";var kk=mW(new URL("../skills",import.meta.url));function dC(t=process.cwd()){let e=t;try{e=lW("git",["rev-parse","--show-toplevel"],{cwd:t,encoding:"utf8"}).trim()}catch{}let r=Zm(e,".claude","skills");fW(r,{recursive:!0});let i=pW(kk).filter(n=>dW(Zm(kk,n,"SKILL.md")));for(let n of i)uW(Zm(kk,n),Zm(r,n),{recursive:!0});return{folder:hW(t,r)||".",skills:i}}async function hC(t=[]){if(t.includes("--skills")){let n=dC();return console.log(`Claude Code skills installed in ${n.folder}: ${n.skills.join(", ")}`),0}if(t.includes("--cloud")){let n=o=>t.includes(o)?t[t.indexOf(o)+1]:void 0;return SW({project:n("--project"),fresh:t.includes("--new"),liveBranch:n("--live-branch"),hook:t.includes("--hook")?!0:t.includes("--no-hook")?!1:void 0})}let e=In(),r=e?.projectId??`p_${gW(6).toString("hex")}`,i=await Yn(e?{projectId:r}:"unset",n=>n.call("init",{projectId:r,minPlugin:uf}));return e||nk({projectId:r,tokens:"tokens/tokens.json"}),$W(),console.log(`project ${r} \u2014 Figma file set up: ${i.pages.join(", ")}`),console.log("config: .codesignflo/config.json (commit it)"),console.log("connect your coding agent (once per machine):"),console.log(" claude mcp add --scope user codesignflo -- npx -y @orkestralai/codesignflo mcp"),console.log(" (other MCP agents: command `npx -y @orkestralai/codesignflo mcp`; legacy Claude Code skills: codesignflo init --skills)"),0}async function wW(t){let{data:e,error:r}=await t.rpc("projects_without_code");if(r)throw new Error(r.message);return e}function $W(){if(zu(bW.executablePath()))return;console.log("installing Chromium for rendering Storybook (once per machine)\u2026");let t=pC(_W(vW(import.meta.url).resolve("playwright/package.json")),"cli.js");fC(process.execPath,[t,"install","chromium"],{stdio:"inherit"})}function kW(){let t=n=>fC("git",n,{encoding:"utf8"}).trim(),e=t(["rev-list","--max-parents=0","HEAD"]).split(`
270
- `).sort()[0],r=t(["rev-parse","--show-prefix"]).replace(/\/$/,"")||".",i=r==="."?t(["rev-parse","--show-toplevel"]).split("/").pop():r.split("/").pop();try{i=JSON.parse(Sk("package.json","utf8")).name??i}catch{}return{rootCommit:e,folder:r,name:i}}async function SW(t={}){let{client:e,user:r}=await an(),{rootCommit:i,folder:n,name:o}=kW(),s=In(),{data:a,error:c}=await e.rpc("find_project",{p_root_commit:i,p_folder:n});if(c)throw new Error(c.message);let l=a[0],u;if(l&&!l.access)throw new Error("this app already has a CoDesignFlo project \u2014 ask its owner to invite you");let d=l||t.fresh||t.project?[]:await wW(e);if(l)u=l.project_id,console.log(`found the project "${l.name}" (${u})`);else if(t.project||d.length){if(!t.project){console.log("Projects waiting for their code (a designer started them and invited you):");for(let E of d)console.log(` ${E.project_id} ${E.name}`);return console.log("Link this app to one: codesignflo init --cloud --project <id> (or start a new project: --new)"),2}let x=t.project,{error:k}=await e.rpc("link_codebase",{p_project:x,p_root_commit:i,p_folder:n});if(k)throw new Error(k.message);u=x,console.log(`linked this app to the project ${u}; its Figma file is already set up by the designer`),s&&!s.cloud&&Ct().length&&console.log("note: the local history (.codesignflo/events.jsonl) belongs to the old local project and was not moved")}else{let{data:x,error:k}=await e.rpc("create_project",{p_name:o,p_root_commit:i,p_folder:n,p_settings:s?{tokens:s.tokens,trackedBranch:s.trackedBranch}:{},...s&&!s.cloud?{p_id:s.projectId}:{}});if(k)throw new Error(k.message);if(u=x,console.log(`created the project "${o}" (${u}) for ${r.email??r.id}`),s&&!s.cloud){let E=Ct();await oz(e,u,E),console.log(`moved the local project to the cloud: ${E.length} history entries uploaded`)}}if(s&&!s.cloud&&s.projectId===u){let x=await lz(e,u);x&&console.log(`uploaded ${x} stored versions of Live (snapshots/; the folder can be deleted after this)`)}nk({...s??{tokens:"tokens/tokens.json"},projectId:u,cloud:!0}),console.log("this app now uses the CoDesignFlo service");let{data:p}=await e.from("projects").select("settings").eq("id",u).single(),f=p?.settings?.liveBranch,h=t.liveBranch??f??Nm()??"main";if(h!==f){let{error:x}=await e.rpc("set_live_branch",{p_project:u,p_branch:h});if(x)throw new Error(x.message)}console.log(`Live follows ${h} (change it: codesignflo live-branch <name>)`),t.hook===!0?console.log($k().message):t.hook===void 0&&console.log(`to update Live on every commit to ${h} from this machine: codesignflo hook install (a git hook; nothing goes into the repo)`);let m=Ow(xW(s?.tokens??"tokens/tokens.json"));m.length&&console.log(`
269
+ `}${uW(process.cwd(),t.projectId)}`),oW(o,493)}return{ok:!0,message:`Live updates on every commit to the Live branch on this machine (git hooks post-commit and post-merge in ${e}; not part of the repo). Log: ~/.codesignflo/logs/${t.projectId}.log`}}function dW(){let{dir:t}=cC();if(!t)return"nothing to remove (hooks are managed by the repo's hook tool)";let e=0;for(let r of sC){let i=ju(t,r);if(!eC(i))continue;let n=tC(i,"utf8"),o=lC(n);o!==n&&(o.trim()==="#!/bin/sh"?sW(i):rC(i,o),e++)}return e?"removed: commits no longer update Live by themselves (to also revoke this machine's sign-in: codesignflo logout)":"no CoDesignFlo hook here"}async function uC(t){if(t[0]==="remove")return console.log(dW()),0;if(t[0]!=="install")throw new Error("usage: codesignflo hook install [--code <one-time code> --from <MCP address>] | remove");let e=t.includes("--code")?t[t.indexOf("--code")+1]:void 0,r=t.includes("--from")?t[t.indexOf("--from")+1]:void 0;if(e&&r){let n=await fetch(`${r.replace(/\/$/,"")}/install-code`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:e})}),o=await n.json();if(!n.ok||!o.refresh_token||!o.service)throw new Error(o.error??"couldn't use the code \u2014 ask the agent for auto_update again");Y$(o.service),Eu(o.refresh_token,{id:"",email:null}),delete process.env.CODESIGNFLO_TOKEN,delete process.env.CODESIGNFLO_TICKET;let{user:s}=await an();console.log(`this machine is signed in as ${s.email??s.id} (codesignflo logout to undo)`)}else Am()||(console.log("The hook runs by itself after commits, so this machine needs its own sign-in (once):"),delete process.env.CODESIGNFLO_TOKEN,delete process.env.CODESIGNFLO_TICKET,await Fm([]));process.env.CODESIGNFLO_SERVICE_URL&&process.env.CODESIGNFLO_SERVICE_ANON&&Y$(Da());let i=$k();return console.log(i.message),i.ok?0:2}Pr();import{execFileSync as fC}from"node:child_process";import{randomBytes as _W}from"node:crypto";import{existsSync as zu,readdirSync as bW,readFileSync as Sk}from"node:fs";import{createRequire as wW}from"node:module";import{dirname as $W,join as pC}from"node:path";import{chromium as kW}from"playwright";sr();La();import{execFileSync as fW}from"node:child_process";import{cpSync as pW,existsSync as hW,mkdirSync as mW,readdirSync as gW}from"node:fs";import{join as Zm,relative as yW}from"node:path";import{fileURLToPath as vW}from"node:url";var kk=vW(new URL("../skills",import.meta.url));function dC(t=process.cwd()){let e=t;try{e=fW("git",["rev-parse","--show-toplevel"],{cwd:t,encoding:"utf8"}).trim()}catch{}let r=Zm(e,".claude","skills");mW(r,{recursive:!0});let i=gW(kk).filter(n=>hW(Zm(kk,n,"SKILL.md")));for(let n of i)pW(Zm(kk,n),Zm(r,n),{recursive:!0});return{folder:yW(t,r)||".",skills:i}}async function hC(t=[]){if(t.includes("--skills")){let n=dC();return console.log(`Claude Code skills installed in ${n.folder}: ${n.skills.join(", ")}`),0}if(t.includes("--cloud")){let n=o=>t.includes(o)?t[t.indexOf(o)+1]:void 0;return EW({project:n("--project"),fresh:t.includes("--new"),liveBranch:n("--live-branch"),hook:t.includes("--hook")?!0:t.includes("--no-hook")?!1:void 0})}let e=In(),r=e?.projectId??`p_${_W(6).toString("hex")}`,i=await Yn(e?{projectId:r}:"unset",n=>n.call("init",{projectId:r,minPlugin:uf}));return e||nk({projectId:r,tokens:"tokens/tokens.json"}),xW(),console.log(`project ${r} \u2014 Figma file set up: ${i.pages.join(", ")}`),console.log("config: .codesignflo/config.json (commit it)"),console.log("connect your coding agent (once per machine):"),console.log(" claude mcp add --scope user codesignflo -- npx -y @orkestralai/codesignflo mcp"),console.log(" (other MCP agents: command `npx -y @orkestralai/codesignflo mcp`; legacy Claude Code skills: codesignflo init --skills)"),0}async function SW(t){let{data:e,error:r}=await t.rpc("projects_without_code");if(r)throw new Error(r.message);return e}function xW(){if(zu(kW.executablePath()))return;console.log("installing Chromium for rendering Storybook (once per machine)\u2026");let t=pC($W(wW(import.meta.url).resolve("playwright/package.json")),"cli.js");fC(process.execPath,[t,"install","chromium"],{stdio:"inherit"})}function IW(){let t=n=>fC("git",n,{encoding:"utf8"}).trim(),e=t(["rev-list","--max-parents=0","HEAD"]).split(`
270
+ `).sort()[0],r=t(["rev-parse","--show-prefix"]).replace(/\/$/,"")||".",i=r==="."?t(["rev-parse","--show-toplevel"]).split("/").pop():r.split("/").pop();try{i=JSON.parse(Sk("package.json","utf8")).name??i}catch{}return{rootCommit:e,folder:r,name:i}}async function EW(t={}){let{client:e,user:r}=await an(),{rootCommit:i,folder:n,name:o}=IW(),s=In(),{data:a,error:c}=await e.rpc("find_project",{p_root_commit:i,p_folder:n});if(c)throw new Error(c.message);let l=a[0],u;if(l&&!l.access)throw new Error("this app already has a CoDesignFlo project \u2014 ask its owner to invite you");let d=l||t.fresh||t.project?[]:await SW(e);if(l)u=l.project_id,console.log(`found the project "${l.name}" (${u})`);else if(t.project||d.length){if(!t.project){console.log("Projects waiting for their code (a designer started them and invited you):");for(let E of d)console.log(` ${E.project_id} ${E.name}`);return console.log("Link this app to one: codesignflo init --cloud --project <id> (or start a new project: --new)"),2}let x=t.project,{error:k}=await e.rpc("link_codebase",{p_project:x,p_root_commit:i,p_folder:n});if(k)throw new Error(k.message);u=x,console.log(`linked this app to the project ${u}; its Figma file is already set up by the designer`),s&&!s.cloud&&Ct().length&&console.log("note: the local history (.codesignflo/events.jsonl) belongs to the old local project and was not moved")}else{let{data:x,error:k}=await e.rpc("create_project",{p_name:o,p_root_commit:i,p_folder:n,p_settings:s?{tokens:s.tokens,trackedBranch:s.trackedBranch}:{},...s&&!s.cloud?{p_id:s.projectId}:{}});if(k)throw new Error(k.message);if(u=x,console.log(`created the project "${o}" (${u}) for ${r.email??r.id}`),s&&!s.cloud){let E=Ct();await oz(e,u,E),console.log(`moved the local project to the cloud: ${E.length} history entries uploaded`)}}if(s&&!s.cloud&&s.projectId===u){let x=await lz(e,u);x&&console.log(`uploaded ${x} stored versions of Live (snapshots/; the folder can be deleted after this)`)}nk({...s??{tokens:"tokens/tokens.json"},projectId:u,cloud:!0}),console.log("this app now uses the CoDesignFlo service");let{data:p}=await e.from("projects").select("settings").eq("id",u).single(),f=p?.settings?.liveBranch,h=t.liveBranch??f??Nm()??"main";if(h!==f){let{error:x}=await e.rpc("set_live_branch",{p_project:u,p_branch:h});if(x)throw new Error(x.message)}console.log(`Live follows ${h} (change it: codesignflo live-branch <name>)`),t.hook===!0?console.log($k().message):t.hook===void 0&&console.log(`to update Live on every commit to ${h} from this machine: codesignflo hook install (a git hook; nothing goes into the repo)`);let m=Ow(TW(s?.tokens??"tokens/tokens.json"));m.length&&console.log(`
271
271
  Missing in this app:
272
272
  ${m.map(x=>`- ${x}`).join(`
273
273
  `)}`);let{data:g}=await e.from("projects").select("settings").eq("id",u).single(),{data:y}=await e.from("events").select("component, kind").eq("project_id",u).in("kind",["designed_new","closed","unclaimed"]),v=new Map;for(let x of y??[])v.set(x.component,(v.get(x.component)??0)+(x.kind==="designed_new"?1:-1));let b=Pw({hasFile:!!g?.settings?.file,newDesigns:[...v].filter(([,x])=>x>0).map(([x])=>x),liveBranch:h});return console.log(`
274
274
  Next:
275
275
  ${b.map(x=>`- ${x}`).join(`
276
- `)}`),0}function xW(t){let e=zu("package.json")?JSON.parse(Sk("package.json","utf8")):{},r=zu(".storybook")||Object.values(e.scripts??{}).some(o=>o.includes("storybook")),i=!1,n=(o,s)=>{if(!(i||s<0||!zu(o)))for(let a of yW(o,{withFileTypes:!0})){if(a.name==="node_modules"||a.name.startsWith("."))continue;let c=pC(o,a.name);if(a.isDirectory())n(c,s-1);else if(/\.stories\.(t|j)sx?$/.test(a.name)){let l=Sk(c,"utf8");(/title:\s*["'`](pages|screens)(\/|["'`])/i.test(l)||/layout:\s*["'`]fullscreen/.test(l))&&(i=!0)}}};return n("src",6),{storybook:r,tokens:zu(t)?t:null,pageStories:i}}sr();import{execSync as IW,spawnSync as EW}from"node:child_process";import{resolve as TW}from"node:path";var OW=["header","body","footer","title","subtitle","label","description","price","total","summary","row","list","item","image","media","icon","logo","nav","link","actions","badge","divider","value","step","content","meta"];function mC(t,e,r){let i=[],n=(o,s,a)=>{if(!(!a&&o.component)){o.unnamed&&i.push({owner:e,files:r,path:s,tag:o.name,...o.text?{text:o.text.characters.slice(0,40)}:{}});for(let c of o.children??[])n(c,`${s} \u203A ${c.name}`,!1)}};return n(t,t.name,!0),i}async function gC(t){let{registry:e,irs:r}=await Lm(t,process.cwd()),i=[];for(let[o,s]of Object.entries(e.components))for(let a of Object.keys(s.stories)){let c=r.get(a);c&&i.push(...mC(c.root,o,s.files))}for(let[o,s]of Object.entries(e.screens)){let a=r.get(s.story);a&&i.push(...mC(a.root,o,s.files))}let n=new Set;return i.filter(o=>{let s=`${o.owner}|${o.path}|${o.text??""}`;return n.has(s)?!1:(n.add(s),!0)})}async function yC(t){let e=Yt(),r=e.storybook??{},i=()=>IW(r.build??"pnpm build-storybook",{stdio:"ignore",env:{...process.env,STORYBOOK_DISABLE_TELEMETRY:"1"}});t.includes("--no-build")||i();let n=TW(r.out??"storybook-static"),o=await gC(n);if(!o.length)return console.log("every element of every registered component and page has a name"),0;console.log(`${o.length} unnamed element(s):`);for(let d of o)console.log(` ${d.owner}: ${d.path}${d.text?` ("${d.text}")`:""}`);if(t.includes("--check"))return 1;let s=[...new Set(o.flatMap(d=>d.files))],a=[...OW,...e.vocabulary??[]],c=`Give these unnamed elements a semantic layer name by adding a data-cdf attribute to the JSX element.
276
+ `)}`),0}function TW(t){let e=zu("package.json")?JSON.parse(Sk("package.json","utf8")):{},r=zu(".storybook")||Object.values(e.scripts??{}).some(o=>o.includes("storybook")),i=!1,n=(o,s)=>{if(!(i||s<0||!zu(o)))for(let a of bW(o,{withFileTypes:!0})){if(a.name==="node_modules"||a.name.startsWith("."))continue;let c=pC(o,a.name);if(a.isDirectory())n(c,s-1);else if(/\.stories\.(t|j)sx?$/.test(a.name)){let l=Sk(c,"utf8");(/title:\s*["'`](pages|screens)(\/|["'`])/i.test(l)||/layout:\s*["'`]fullscreen/.test(l))&&(i=!0)}}};return n("src",6),{storybook:r,tokens:zu(t)?t:null,pageStories:i}}sr();import{execSync as OW,spawnSync as PW}from"node:child_process";import{resolve as AW}from"node:path";var RW=["header","body","footer","title","subtitle","label","description","price","total","summary","row","list","item","image","media","icon","logo","nav","link","actions","badge","divider","value","step","content","meta"];function mC(t,e,r){let i=[],n=(o,s,a)=>{if(!(!a&&o.component)){o.unnamed&&i.push({owner:e,files:r,path:s,tag:o.name,...o.text?{text:o.text.characters.slice(0,40)}:{}});for(let c of o.children??[])n(c,`${s} \u203A ${c.name}`,!1)}};return n(t,t.name,!0),i}async function gC(t){let{registry:e,irs:r}=await Lm(t,process.cwd()),i=[];for(let[o,s]of Object.entries(e.components))for(let a of Object.keys(s.stories)){let c=r.get(a);c&&i.push(...mC(c.root,o,s.files))}for(let[o,s]of Object.entries(e.screens)){let a=r.get(s.story);a&&i.push(...mC(a.root,o,s.files))}let n=new Set;return i.filter(o=>{let s=`${o.owner}|${o.path}|${o.text??""}`;return n.has(s)?!1:(n.add(s),!0)})}async function yC(t){let e=Yt(),r=e.storybook??{},i=()=>OW(r.build??"pnpm build-storybook",{stdio:"ignore",env:{...process.env,STORYBOOK_DISABLE_TELEMETRY:"1"}});t.includes("--no-build")||i();let n=AW(r.out??"storybook-static"),o=await gC(n);if(!o.length)return console.log("every element of every registered component and page has a name"),0;console.log(`${o.length} unnamed element(s):`);for(let d of o)console.log(` ${d.owner}: ${d.path}${d.text?` ("${d.text}")`:""}`);if(t.includes("--check"))return 1;let s=[...new Set(o.flatMap(d=>d.files))],a=[...RW,...e.vocabulary??[]],c=`Give these unnamed elements a semantic layer name by adding a data-cdf attribute to the JSX element.
277
277
 
278
278
  Elements (owner component or page \u203A layer path; the last segment is the element's HTML tag; quoted text is its content):
279
279
  ${o.map(d=>`- ${d.owner} (${d.files.filter(p=>/\.[jt]sx?$/.test(p)).join(", ")}): ${d.path}${d.text?` \u2014 text "${d.text}"`:""}`).join(`
@@ -287,6 +287,6 @@ Rules:
287
287
  - Edit only: ${s.join(", ")}. Do not run git.
288
288
 
289
289
  When done, reply with ONLY: {"named": <number of attributes added>}
290
- `;console.error("asking Claude Code to name them\u2026");let l=EW("claude",["-p",c,"--permission-mode","acceptEdits","--allowedTools","Read","Glob","Grep",...s.map(d=>`Edit(${d})`),"--output-format","json"],{encoding:"utf8",timeout:9e5});if(l.error)throw new Error(`could not run Claude Code: ${l.error.message}`);i();let u=await gC(n);console.log(`named ${o.length-u.length} of ${o.length}; review the data-cdf attributes in your diff and commit them`);for(let d of u)console.log(` still unnamed: ${d.owner}: ${d.path}`);return u.length?1:0}sr();La();function xk(){let t=In();if(!t?.cloud)throw new Error("this app isn't connected to the CoDesignFlo service \u2014 run: codesignflo init --cloud");return t.projectId}var PW=t=>t.pending?t.email_status==="sent"?" \u2014 invitation email sent":t.email_status==="failed"?` \u2014 invitation email not sent: ${t.email_error??"unknown error"}`:t.email_status==="queued"?" \u2014 invitation email on its way":" \u2014 no invitation email sent":"";async function vC(t){let e=t.find(s=>!s.startsWith("--"));if(!e||!/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(e))throw new Error("usage: codesignflo invite <email> [--designer | --developer | --admin] | invite <email> --resend");let{client:r}=await an();if(t.includes("--resend")){let{error:s}=await r.rpc("resend_invitation",{p_project:xk(),p_email:e});if(s)throw new Error(s.message);return console.log(`invitation email sent again to ${e}`),0}let i=t.includes("--admin")?"admin":t.includes("--developer")?"developer":"designer",{data:n,error:o}=await r.rpc("invite",{p_project:xk(),p_email:e,p_role:i});if(o)throw new Error(o.message);return console.log(n==="added"?`${e} is now in the project (${i}) \u2014 they got an email about it`:`invited ${e} as ${i} \u2014 an email tells them how to join (they join when they sign in with that email)`),0}async function _C(){let{client:t}=await an(),{data:e,error:r}=await t.rpc("project_people",{p_project:xk()});if(r)throw new Error(r.message);for(let i of e)console.log(`${(i.email??"(no email)").padEnd(32)} ${i.role}${i.pending?" (invited)":""}${PW(i)}`);return 0}Pr();sr();async function bC(t){let e=t.find(o=>!o.startsWith("--")),r=t.includes("--design")?"design":t.includes("--code")?"code":null,i=r==="code"?t[t.indexOf("--code")+1]:void 0;if(!e||!r||r==="code"&&(!i||i.startsWith("--")))throw new Error('usage: codesignflo resolve <component> --design | --code "<why the code version stays>"');let n=xt(Ct()).get(e);if(!n)throw new Error(`${e} has no proposal ready for dev`);return En(Tw(n,r,i)),console.log(r==="design"?`${e}: the designer's version wins \u2014 run codesignflo sync, then deliver it (the clashing changes are included)`:`${e}: kept the code's version; sent back to the designer with your reason (they see it at the next sync)`),0}Pr();sr();import{execSync as AW}from"node:child_process";import{mkdirSync as wC,readFileSync as RW,rmSync as jW,writeFileSync as $C}from"node:fs";import{join as Cu,relative as kC,resolve as zW}from"node:path";import CW from"pixelmatch";import{PNG as Ei}from"pngjs";var qm=2,Ik=.03;function NW(t,e,r=[]){let i=Math.max(t.width,e.width),n=Math.max(t.height,e.height),o=h=>{let m=new Ei({width:i,height:n});m.data.fill(255);for(let g=0;g<h.height;g++)for(let y=0;y<h.width;y++){let v=(g*h.width+y)*4,b=(g*i+y)*4,x=h.data[v+3]/255;for(let k=0;k<3;k++)m.data[b+k]=Math.round(h.data[v+k]*x+255*(1-x))}return m},s=o(t),a=o(e),c=new Ei({width:i,height:n});CW(s.data,a.data,c.data,i,n,{threshold:.2});let l=new Uint8Array(i*n);for(let h of r)for(let m=Math.max(0,Math.floor(h.y-3));m<Math.min(n,Math.ceil(h.y+h.height+3));m++)for(let g=Math.max(0,Math.floor(h.x-3));g<Math.min(i,Math.ceil(h.x+h.width+3));g++)l[m*i+g]=1;let u=0,d=0,p=0;for(let h=0;h<i*n;h++){let m=c.data[h*4]===255&&c.data[h*4+1]===0&&c.data[h*4+2]===0;l[h]?(p++,m&&d++):m&&u++}let f=new Ei({width:i*3+32,height:n});return f.data.fill(255),Ei.bitblt(s,f,0,0,i,n,0,0),Ei.bitblt(a,f,0,0,i,n,i+16,0),Ei.bitblt(c,f,0,0,i,n,2*i+32,0),{mismatch:u/(i*n),textMismatch:p?d/p:null,image:f}}async function SC(t){let r=Yt().storybook??{};t.includes("--no-build")||AW(r.build??"pnpm build-storybook",{stdio:"ignore",env:{...process.env,STORYBOOK_DISABLE_TELEMETRY:"1"}});let i=JSON.parse(RW(Cu(gt(),"registry.json"),"utf8")),n=t.filter(d=>!d.startsWith("--")),o=Object.keys(i.components).filter(d=>!n.length||n.includes(d));if(n.length&&!o.length)throw new Error(`not registered: ${n.join(", ")} \u2014 run codesignflo sync first`);let s=t.includes("--screens")?Object.entries(i.screens):[],a=await Yn({projectId:Yt().projectId},async d=>{let p=await d.call("exportVariants",{setKeys:o},{timeoutMs:18e4});for(let[f]of s)try{p[`screen:${f}`]=await d.call("exportNode",{k:`screen:${f}`})}catch{}return p}),c=Cu(gt(),"verify");jW(c,{recursive:!0,force:!0});let l=[];await dk(zW(r.out??"storybook-static"),async(d,p)=>{let f=async(m,g)=>{await p(m),g&&await d.evaluate(x=>{let k=document.querySelector("[data-cdf-container]")??document.querySelector("#storybook-root");k.style.boxSizing="content-box",k.style.width=`${x}px`},g);let y=await d.$("[data-cdf-container] > *")??await d.$("#storybook-root > *");if(!y)throw new Error(`story ${m} rendered nothing`);let v=await y.evaluate(x=>{let k=x.getBoundingClientRect();x.style.translate=`${-(k.x%1)}px ${-(k.y%1)}px`;let E=x.getBoundingClientRect(),O=[],X=document.createTreeWalker(x,NodeFilter.SHOW_TEXT);for(let le=X.nextNode();le;le=X.nextNode()){if(!le.textContent?.trim())continue;let $e=document.createRange();$e.selectNodeContents(le);for(let q of Array.from($e.getClientRects()))O.push({x:q.x-E.x,y:q.y-E.y,width:q.width,height:q.height})}return{width:k.width,height:k.height,text:O}});return{shot:Ei.sync.read(await y.screenshot()),width:Math.round(v.width),height:Math.round(v.height),text:v.text}},h=async(m,g,y,v)=>{let b=a[v]?Ei.sync.read(Buffer.from(a[v],"base64")):null,{shot:x,width:k,height:E,text:O}=await f(y,b?.width),X={component:m,variant:g,story:y,browser:{width:k,height:E},figma:b?{width:b.width,height:b.height}:null,mismatch:null,flagged:!0};if(b){let{mismatch:le,textMismatch:$e,image:q}=NW(x,b,O),Re=Cu(c,m,`${g.replace(/[^\w=.-]+/g,"_")}.png`);wC(Cu(c,m),{recursive:!0}),$C(Re,Ei.sync.write(q)),X.mismatch=le,X.textMismatch=$e,X.image=kC(process.cwd(),Re),X.flagged=Math.abs(k-b.width)>qm||Math.abs(E-b.height)>qm||le>Ik}l.push(X)};for(let m of o)for(let[g,y]of Object.entries(i.components[m].stories)){let v=Io(y);await h(m,v,g,`${m}/${v}`)}for(let[m,g]of s)await h(m,"screen",g.story,`screen:${m}`)}),wC(c,{recursive:!0}),$C(Cu(c,"report.json"),`${JSON.stringify({at:new Date().toISOString(),thresholds:{sizePx:qm,mismatch:Ik},rows:l},null,2)}
291
- `);for(let d of l){let p=d.figma?`${d.browser.width}\xD7${d.browser.height} vs ${d.figma.width}\xD7${d.figma.height}`:"not in Live",f=d.mismatch===null?"":` ${(100*d.mismatch).toFixed(1)}% pixels differ${d.textMismatch?` (text ${(100*d.textMismatch).toFixed(0)}%)`:""}`;console.log(`${d.flagged?"!":"\u2713"} ${`${d.component} ${d.variant}`.padEnd(40)} ${p}${f}`)}let u=l.filter(d=>d.flagged).length;return console.log(`${l.length-u}/${l.length} match (sizes within ${qm} px, under ${Ik*100}% pixels outside text). Images: ${kC(process.cwd(),c)}/`),u&&t.includes("--strict")?1:0}sr();var FM={init:{summary:"set up the open Figma file for this project (run in your app's folder) [--cloud: connect to the service; --project <id> | --new] [--skills]",run:t=>hC(t)},sync:{summary:"render Storybook, update Live, record the designer's work, verify delivered changes (--only a,b: update just these in Live)",run:t=>Bz(t)},deliver:{summary:"apply a ready proposal to the code with Claude Code and commit it: deliver <component> (--track: hand-off only, you implement and commit)",run:t=>dz(t)},status:{summary:"what is waiting on the developer, and each component's state (no Figma needed) [--all: every place Live differs from the app]",run:async t=>{console.log((await Promise.resolve().then(()=>(Xy(),Jy))).statusText(process.cwd()));let e=fs();if(e)for(let r of await yk(e,void 0,t.includes("--all")))console.log(r);return 0}},proposal:{summary:"the designer's proposal for a component as implementation instructions: proposal <component> [--json]",run:async t=>{let e=t.find(i=>!i.startsWith("--"));if(!e)throw new Error("usage: codesignflo proposal <component> [--json]");let r=(await Promise.resolve().then(()=>(Xy(),Jy))).proposalText(process.cwd(),e);return console.log(t.includes("--json")?JSON.stringify(r):r.text),0}},pull:{summary:"cloud projects: fetch the designer's proposals and compute their changes (no Figma needed)",run:()=>jz()},login:{summary:"sign in to the CoDesignFlo service (opens the browser; nothing typed here) [--no-browser]",run:t=>Fm(t)},whoami:{summary:"who you are signed in as",run:()=>Jz()},logout:{summary:"revoke this machine's sign-in [--everywhere: every session of the account]",run:t=>Xz(t)},invite:{summary:"cloud projects: invite someone by email: invite <email> [--designer (default) | --developer | --admin] (emails them how to join; --resend: send it again)",run:t=>vC(t)},people:{summary:"cloud projects: who is in this app's project",run:()=>_C()},"live-branch":{summary:"cloud projects: which branch updates Live: live-branch [<name>] (developers and admins)",run:t=>Fz(t,fs())},hook:{summary:"cloud projects: update Live on every commit to the Live branch (git hook on this machine): hook install | remove",run:t=>uC(t)},ask:{summary:'send a ready proposal back to the designer with a question: ask <component> "<question>"',run:t=>uz(t)},mcp:{summary:"run the MCP server for coding agents (stdio): claude mcp add --scope user codesignflo -- npx -y @orkestralai/codesignflo mcp",run:async()=>(await Promise.resolve().then(()=>(Xy(),Jy))).mcp()},resolve:{summary:`settle a clash between the designer's copy and code changed meanwhile: resolve <component> --design | --code "<why>"`,run:t=>bC(t)},delta:{summary:"show what the designer changed in proposals marked ready for dev (writes .codesignflo/proposals/\u2026)",run:()=>Wz()},verify:{summary:"compare Live with the code, variant by variant (browser vs Figma images) [component\u2026] [--screens] [--strict]",run:t=>SC(t)},name:{summary:"give unnamed elements semantic layer names in code (data-cdf) with Claude Code [--check]",run:t=>yC(t)},"dev:reload":{summary:"(development) hot-swap the running plugin with the current build",run:()=>Gz()},version:{summary:"print the version",run:()=>(console.log(Nc),0)}},[Cc="help",...HY]=process.argv.slice(2),ZM=FM[Cc];if(!ZM){console.log(`usage: codesignflo <command>
292
- `);for(let[t,e]of Object.entries(FM))console.log(` ${t.padEnd(10)} ${e.summary}`);process.exit(Cc==="help"?0:1)}var WY=["login","logout","whoami","invite","people","hook","mcp","version","help","init","dev:reload"].includes(Cc),HI=1;try{WY||await nz(),["deliver","ask","resolve","verify","status","proposal"].includes(Cc)&&await pk(),HI=await ZM.run(HY)}catch(t){console.error(`codesignflo ${Cc}: ${t.message}`)}finally{try{await iz()}catch(t){console.error(`codesignflo ${Cc}: ${t.message}`),HI=1}}process.exit(HI);
290
+ `;console.error("asking Claude Code to name them\u2026");let l=PW("claude",["-p",c,"--permission-mode","acceptEdits","--allowedTools","Read","Glob","Grep",...s.map(d=>`Edit(${d})`),"--output-format","json"],{encoding:"utf8",timeout:9e5});if(l.error)throw new Error(`could not run Claude Code: ${l.error.message}`);i();let u=await gC(n);console.log(`named ${o.length-u.length} of ${o.length}; review the data-cdf attributes in your diff and commit them`);for(let d of u)console.log(` still unnamed: ${d.owner}: ${d.path}`);return u.length?1:0}sr();La();function xk(){let t=In();if(!t?.cloud)throw new Error("this app isn't connected to the CoDesignFlo service \u2014 run: codesignflo init --cloud");return t.projectId}var jW=t=>t.pending?t.email_status==="sent"?" \u2014 invitation email sent":t.email_status==="failed"?` \u2014 invitation email not sent: ${t.email_error??"unknown error"}`:t.email_status==="queued"?" \u2014 invitation email on its way":" \u2014 no invitation email sent":"";async function vC(t){let e=t.find(s=>!s.startsWith("--"));if(!e||!/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(e))throw new Error("usage: codesignflo invite <email> [--designer | --developer | --admin] | invite <email> --resend");let{client:r}=await an();if(t.includes("--resend")){let{error:s}=await r.rpc("resend_invitation",{p_project:xk(),p_email:e});if(s)throw new Error(s.message);return console.log(`invitation email sent again to ${e}`),0}let i=t.includes("--admin")?"admin":t.includes("--developer")?"developer":"designer",{data:n,error:o}=await r.rpc("invite",{p_project:xk(),p_email:e,p_role:i});if(o)throw new Error(o.message);return console.log(n==="added"?`${e} is now in the project (${i}) \u2014 they got an email about it`:`invited ${e} as ${i} \u2014 an email tells them how to join (they join when they sign in with that email)`),0}async function _C(){let{client:t}=await an(),{data:e,error:r}=await t.rpc("project_people",{p_project:xk()});if(r)throw new Error(r.message);for(let i of e)console.log(`${(i.email??"(no email)").padEnd(32)} ${i.role}${i.pending?" (invited)":""}${jW(i)}`);return 0}Pr();sr();async function bC(t){let e=t.find(o=>!o.startsWith("--")),r=t.includes("--design")?"design":t.includes("--code")?"code":null,i=r==="code"?t[t.indexOf("--code")+1]:void 0;if(!e||!r||r==="code"&&(!i||i.startsWith("--")))throw new Error('usage: codesignflo resolve <component> --design | --code "<why the code version stays>"');let n=xt(Ct()).get(e);if(!n)throw new Error(`${e} has no proposal ready for dev`);return En(Tw(n,r,i)),console.log(r==="design"?`${e}: the designer's version wins \u2014 run codesignflo sync, then deliver it (the clashing changes are included)`:`${e}: kept the code's version; sent back to the designer with your reason (they see it at the next sync)`),0}Pr();sr();import{execSync as zW}from"node:child_process";import{mkdirSync as wC,readFileSync as CW,rmSync as NW,writeFileSync as $C}from"node:fs";import{join as Cu,relative as kC,resolve as DW}from"node:path";import LW from"pixelmatch";import{PNG as Ei}from"pngjs";var qm=2,Ik=.03;function UW(t,e,r=[]){let i=Math.max(t.width,e.width),n=Math.max(t.height,e.height),o=h=>{let m=new Ei({width:i,height:n});m.data.fill(255);for(let g=0;g<h.height;g++)for(let y=0;y<h.width;y++){let v=(g*h.width+y)*4,b=(g*i+y)*4,x=h.data[v+3]/255;for(let k=0;k<3;k++)m.data[b+k]=Math.round(h.data[v+k]*x+255*(1-x))}return m},s=o(t),a=o(e),c=new Ei({width:i,height:n});LW(s.data,a.data,c.data,i,n,{threshold:.2});let l=new Uint8Array(i*n);for(let h of r)for(let m=Math.max(0,Math.floor(h.y-3));m<Math.min(n,Math.ceil(h.y+h.height+3));m++)for(let g=Math.max(0,Math.floor(h.x-3));g<Math.min(i,Math.ceil(h.x+h.width+3));g++)l[m*i+g]=1;let u=0,d=0,p=0;for(let h=0;h<i*n;h++){let m=c.data[h*4]===255&&c.data[h*4+1]===0&&c.data[h*4+2]===0;l[h]?(p++,m&&d++):m&&u++}let f=new Ei({width:i*3+32,height:n});return f.data.fill(255),Ei.bitblt(s,f,0,0,i,n,0,0),Ei.bitblt(a,f,0,0,i,n,i+16,0),Ei.bitblt(c,f,0,0,i,n,2*i+32,0),{mismatch:u/(i*n),textMismatch:p?d/p:null,image:f}}async function SC(t){let r=Yt().storybook??{};t.includes("--no-build")||zW(r.build??"pnpm build-storybook",{stdio:"ignore",env:{...process.env,STORYBOOK_DISABLE_TELEMETRY:"1"}});let i=JSON.parse(CW(Cu(gt(),"registry.json"),"utf8")),n=t.filter(d=>!d.startsWith("--")),o=Object.keys(i.components).filter(d=>!n.length||n.includes(d));if(n.length&&!o.length)throw new Error(`not registered: ${n.join(", ")} \u2014 run codesignflo sync first`);let s=t.includes("--screens")?Object.entries(i.screens):[],a=await Yn({projectId:Yt().projectId},async d=>{let p=await d.call("exportVariants",{setKeys:o},{timeoutMs:18e4});for(let[f]of s)try{p[`screen:${f}`]=await d.call("exportNode",{k:`screen:${f}`})}catch{}return p}),c=Cu(gt(),"verify");NW(c,{recursive:!0,force:!0});let l=[];await dk(DW(r.out??"storybook-static"),async(d,p)=>{let f=async(m,g)=>{await p(m),g&&await d.evaluate(x=>{let k=document.querySelector("[data-cdf-container]")??document.querySelector("#storybook-root");k.style.boxSizing="content-box",k.style.width=`${x}px`},g);let y=await d.$("[data-cdf-container] > *")??await d.$("#storybook-root > *");if(!y)throw new Error(`story ${m} rendered nothing`);let v=await y.evaluate(x=>{let k=x.getBoundingClientRect();x.style.translate=`${-(k.x%1)}px ${-(k.y%1)}px`;let E=x.getBoundingClientRect(),O=[],X=document.createTreeWalker(x,NodeFilter.SHOW_TEXT);for(let le=X.nextNode();le;le=X.nextNode()){if(!le.textContent?.trim())continue;let $e=document.createRange();$e.selectNodeContents(le);for(let q of Array.from($e.getClientRects()))O.push({x:q.x-E.x,y:q.y-E.y,width:q.width,height:q.height})}return{width:k.width,height:k.height,text:O}});return{shot:Ei.sync.read(await y.screenshot()),width:Math.round(v.width),height:Math.round(v.height),text:v.text}},h=async(m,g,y,v)=>{let b=a[v]?Ei.sync.read(Buffer.from(a[v],"base64")):null,{shot:x,width:k,height:E,text:O}=await f(y,b?.width),X={component:m,variant:g,story:y,browser:{width:k,height:E},figma:b?{width:b.width,height:b.height}:null,mismatch:null,flagged:!0};if(b){let{mismatch:le,textMismatch:$e,image:q}=UW(x,b,O),Re=Cu(c,m,`${g.replace(/[^\w=.-]+/g,"_")}.png`);wC(Cu(c,m),{recursive:!0}),$C(Re,Ei.sync.write(q)),X.mismatch=le,X.textMismatch=$e,X.image=kC(process.cwd(),Re),X.flagged=Math.abs(k-b.width)>qm||Math.abs(E-b.height)>qm||le>Ik}l.push(X)};for(let m of o)for(let[g,y]of Object.entries(i.components[m].stories)){let v=Io(y);await h(m,v,g,`${m}/${v}`)}for(let[m,g]of s)await h(m,"screen",g.story,`screen:${m}`)}),wC(c,{recursive:!0}),$C(Cu(c,"report.json"),`${JSON.stringify({at:new Date().toISOString(),thresholds:{sizePx:qm,mismatch:Ik},rows:l},null,2)}
291
+ `);for(let d of l){let p=d.figma?`${d.browser.width}\xD7${d.browser.height} vs ${d.figma.width}\xD7${d.figma.height}`:"not in Live",f=d.mismatch===null?"":` ${(100*d.mismatch).toFixed(1)}% pixels differ${d.textMismatch?` (text ${(100*d.textMismatch).toFixed(0)}%)`:""}`;console.log(`${d.flagged?"!":"\u2713"} ${`${d.component} ${d.variant}`.padEnd(40)} ${p}${f}`)}let u=l.filter(d=>d.flagged).length;return console.log(`${l.length-u}/${l.length} match (sizes within ${qm} px, under ${Ik*100}% pixels outside text). Images: ${kC(process.cwd(),c)}/`),u&&t.includes("--strict")?1:0}sr();var FM={init:{summary:"set up the open Figma file for this project (run in your app's folder) [--cloud: connect to the service; --project <id> | --new] [--skills]",run:t=>hC(t)},sync:{summary:"render Storybook, update Live, record the designer's work, verify delivered changes (--only a,b: update just these in Live)",run:t=>Bz(t)},deliver:{summary:"apply a ready proposal to the code with Claude Code and commit it: deliver <component> (--track: hand-off only, you implement and commit)",run:t=>dz(t)},status:{summary:"what is waiting on the developer, and each component's state (no Figma needed) [--all: every place Live differs from the app]",run:async t=>{console.log((await Promise.resolve().then(()=>(Xy(),Jy))).statusText(process.cwd()));let e=fs();if(e)for(let r of await yk(e,void 0,t.includes("--all")))console.log(r);return 0}},proposal:{summary:"the designer's proposal for a component as implementation instructions: proposal <component> [--json]",run:async t=>{let e=t.find(i=>!i.startsWith("--"));if(!e)throw new Error("usage: codesignflo proposal <component> [--json]");let r=(await Promise.resolve().then(()=>(Xy(),Jy))).proposalText(process.cwd(),e);return console.log(t.includes("--json")?JSON.stringify(r):r.text),0}},pull:{summary:"cloud projects: fetch the designer's proposals and compute their changes (no Figma needed)",run:()=>jz()},login:{summary:"sign in to the CoDesignFlo service (opens the browser; nothing typed here) [--no-browser]",run:t=>Fm(t)},whoami:{summary:"who you are signed in as",run:()=>Jz()},logout:{summary:"revoke this machine's sign-in [--everywhere: every session of the account]",run:t=>Xz(t)},invite:{summary:"cloud projects: invite someone by email: invite <email> [--designer (default) | --developer | --admin] (emails them how to join; --resend: send it again)",run:t=>vC(t)},people:{summary:"cloud projects: who is in this app's project",run:()=>_C()},"live-branch":{summary:"cloud projects: which branch updates Live: live-branch [<name>] (developers and admins)",run:t=>Fz(t,fs())},hook:{summary:"cloud projects: update Live on every commit to the Live branch (git hook on this machine): hook install | remove",run:t=>uC(t)},ask:{summary:'send a ready proposal back to the designer with a question: ask <component> "<question>"',run:t=>uz(t)},mcp:{summary:"run the MCP server for coding agents (stdio): claude mcp add --scope user codesignflo -- npx -y @orkestralai/codesignflo mcp",run:async()=>(await Promise.resolve().then(()=>(Xy(),Jy))).mcp()},resolve:{summary:`settle a clash between the designer's copy and code changed meanwhile: resolve <component> --design | --code "<why>"`,run:t=>bC(t)},delta:{summary:"show what the designer changed in proposals marked ready for dev (writes .codesignflo/proposals/\u2026)",run:()=>Wz()},verify:{summary:"compare Live with the code, variant by variant (browser vs Figma images) [component\u2026] [--screens] [--strict]",run:t=>SC(t)},name:{summary:"give unnamed elements semantic layer names in code (data-cdf) with Claude Code [--check]",run:t=>yC(t)},"dev:reload":{summary:"(development) hot-swap the running plugin with the current build",run:()=>Gz()},version:{summary:"print the version",run:()=>(console.log(Nc),0)}},[Cc="help",...GY]=process.argv.slice(2),ZM=FM[Cc];if(!ZM){console.log(`usage: codesignflo <command>
292
+ `);for(let[t,e]of Object.entries(FM))console.log(` ${t.padEnd(10)} ${e.summary}`);process.exit(Cc==="help"?0:1)}var JY=["login","logout","whoami","invite","people","hook","mcp","version","help","init","dev:reload"].includes(Cc),HI=1;try{JY||await nz(),["deliver","ask","resolve","verify","status","proposal"].includes(Cc)&&await pk(),HI=await ZM.run(GY)}catch(t){console.error(`codesignflo ${Cc}: ${t.message}`)}finally{try{await iz()}catch(t){console.error(`codesignflo ${Cc}: ${t.message}`),HI=1}}process.exit(HI);