diff --git "a/assets/ChatMessage-BafVtpfl.js" "b/assets/ChatMessage-BafVtpfl.js" new file mode 100644--- /dev/null +++ "b/assets/ChatMessage-BafVtpfl.js" @@ -0,0 +1,128 @@ +var Sh=Object.defineProperty;var Eh=(e,t,r)=>t in e?Sh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var ne=(e,t,r)=>Eh(e,typeof t!="symbol"?t+"":t,r);import{d as $r,r as yt,j as S,z as K,N as su,E as ht,X as kh,C as Ph}from"./index-ryuR5tcl.js";import{u as ou,a as au,b as iu,M as Th,R as Rh,W as jh,d as oa,A as Ch,n as Nh,K as Ih,L as cu,N as Oh}from"./chatSessions-8IHkVjVC.js";import"./katex.min-BSBacQyE.js";import{H as aa,a as ia,b as ca}from"./hover-card-c_-5VAjG.js";import{u as xh}from"./useQuery-CheZF3Ta.js";import{f as Ah,p as Mh}from"./github-BvLB5-ej.js";import{G as la}from"./github-BEj1zBW_.js";import{r as zh,a as Dh,P as lu}from"./PaperPreviewLink-BNGFQRkb.js";import{M as qh,r as Uh,d as Fh}from"./index-CaKBWujY.js";import{E as Lh}from"./external-link-2_neZqwG.js";import{c as jc}from"./chat-19vuvLqj.js";import{F as Vh}from"./file-text-DoDFt2ua.js";/** + * @license lucide-react v0.462.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Hh=$r("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** + * @license lucide-react v0.462.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Cc=$r("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/** + * @license lucide-react v0.462.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Nc=$r("FileCode2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]]);/** + * @license lucide-react v0.462.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Zh=$r("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/** + * @license lucide-react v0.462.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Kh=$r("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/** + * @license lucide-react v0.462.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Gh=$r("ThumbsDown",[["path",{d:"M17 14V2",key:"8ymqnk"}],["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",key:"m61m77"}]]);/** + * @license lucide-react v0.462.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Wh=$r("ThumbsUp",[["path",{d:"M7 10v12",key:"1qc93n"}],["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}]]);function Os({selection:e,editable:t=!1,onRemove:r}){const n=yt.useId(),s=yt.useRef(null),[o,a]=yt.useState(!1),[i,c]=yt.useState(!1),l=`Selection · Page ${e.page}`;return yt.useEffect(()=>{const d=s.current;!d||o||c(d.scrollHeight>d.clientHeight+1)},[o,e.text]),S.jsxs("div",{className:`chat-paper-selection${t?" is-editable":""}`,children:[S.jsxs("div",{className:"chat-paper-selection-header",children:[S.jsx("span",{className:"chat-paper-selection-label",children:l}),S.jsxs("div",{className:"chat-paper-selection-actions",children:[(i||o)&&S.jsx("button",{type:"button",className:"chat-paper-selection-toggle","aria-expanded":o,"aria-controls":n,onClick:()=>a(d=>!d),children:o?"Collapse":"Expand"}),t&&r&&S.jsx("button",{type:"button",className:"chat-paper-selection-remove","aria-label":"Remove selected paper passage",onClick:r,children:"Remove"})]})]}),S.jsx("blockquote",{id:n,ref:s,className:`chat-paper-selection-quote${o?" is-expanded":""}`,children:e.text})]})}const Bh=Nh(),Fj=({onSend:e,busy:t,placeholder:r,autoFocus:n,draft:s,onDraftChange:o,onStop:a,models:i=[],selectedModel:c,onModelChange:l,disabled:d=!1,describedBy:f,paperMentionsEnabled:_=!1,paperSelectionEnabled:y=!0,webSearchAvailable:g=!1,webSearchEnabled:$=!1,onWebSearchChange:m,reasoningEffort:h="low",onReasoningEffortChange:v})=>{const[k,R]=yt.useState(Bh),E=s??k,I=yt.useRef(null),[x,q]=yt.useState(0),Z=U=>{s||R(U),o==null||o(U)},D=ou({draft:E,onChange:Z,enabled:_,textareaRef:I});yt.useEffect(()=>{const U=I.current;U&&(U.style.height="auto",U.style.height=`${Math.min(U.scrollHeight,200)}px`)},[E.text]),yt.useEffect(()=>{var U;n&&((U=I.current)==null||U.focus())},[n]);const L=()=>{const U=E.text.length-E.text.trimStart().length,le=E.text.trim(),je=!!E.paperSelection&&!y;if(!le||t||d||je)return;const _e=U+le.length,it={text:le,paperMentions:E.paperMentions.filter(Ie=>Ie.start>=U&&Ie.end<=_e).map(Ie=>({...Ie,start:Ie.start-U,end:Ie.end-U})),...E.paperSelection?{paperSelection:E.paperSelection}:{}};e(it)},B=!!E.paperSelection&&!y,ce=!!E.text.trim()&&!B;return S.jsxs("div",{className:"chat-composer",children:[E.paperSelection&&S.jsx(Os,{selection:E.paperSelection,editable:!0,onRemove:()=>{var U;Z({text:E.text,paperMentions:E.paperMentions}),(U=I.current)==null||U.focus()}}),B&&S.jsx("div",{className:"chat-paper-selection-disabled",role:"status",children:"Paper selection is currently disabled. Remove the selected passage or wait for the feature to recover."}),S.jsxs("div",{className:"chat-composer-textarea-wrap",children:[S.jsx(au,{text:E.text,mentions:E.paperMentions,scrollTop:x}),S.jsx("textarea",{ref:I,rows:1,value:E.text,placeholder:r||(E.paperSelection?"Ask about this selection…":"Ask anything about research…"),onChange:U=>D.updateText(U.target.value,U.target.selectionStart),onSelect:U=>D.refresh(U.currentTarget.selectionStart),onClick:U=>D.refresh(U.currentTarget.selectionStart),onScroll:U=>q(U.currentTarget.scrollTop),onBlur:U=>{var le,je;(je=(le=U.relatedTarget)==null?void 0:le.closest)!=null&&je.call(le,".chat-paper-picker")||window.setTimeout(D.close,0)},onKeyDown:U=>{D.keyDown(U)||U.key==="Enter"&&!U.shiftKey&&!U.nativeEvent.isComposing&&(U.preventDefault(),L())},role:"combobox","aria-expanded":D.open,"aria-controls":D.open?D.pickerId:void 0,"aria-activedescendant":D.open&&D.results.length?`${D.optionIdPrefix}-${D.activeIndex}`:void 0,"aria-autocomplete":"list","aria-describedby":[f,D.message?"chat-paper-mention-message":null].filter(Boolean).join(" ")||void 0}),S.jsx(iu,{open:D.open,query:D.query,results:D.results,activeIndex:D.activeIndex,loading:D.loading,error:D.error,onSelect:D.select,id:D.pickerId,optionIdPrefix:D.optionIdPrefix})]}),D.message&&S.jsx("div",{id:"chat-paper-mention-message",className:"chat-paper-mention-message",role:"alert",children:D.message}),S.jsxs("div",{className:"chat-composer-row",children:[S.jsxs("div",{className:"chat-composer-tools",children:[i.length>0&&c&&l&&S.jsx(Th,{models:i,selectedModel:c,onModelChange:l,disabled:t}),v&&S.jsx(Rh,{value:h,onChange:v,disabled:t}),g&&m&&S.jsx(jh,{enabled:$,onChange:m,disabled:t}),S.jsx("span",{className:"chat-composer-hint",children:"Enter to send · Shift+Enter for newline"})]}),S.jsx("button",{type:"button",className:`chat-send${t||ce?" chat-send-on":""}`,onClick:t?a:L,disabled:d||(t?!a:!ce),"aria-label":t?"Stop generating":"Send message",children:t?a?S.jsx("span",{"aria-hidden":"true",children:"■"}):S.jsx(oa,{light:!0}):S.jsx(Ch,{})})]})]})},eo=new Map,uu=e=>{if(!e)return Promise.resolve();const t=eo.get(e);if(t)return t;const r=new Promise(n=>{const s=new Image;s.onload=()=>{n()},s.onerror=()=>{eo.delete(e),n()},s.src=e});return eo.set(e,r),r},Jh=new Set(["huggingface.co","www.huggingface.co"]),Qh=new Set(["api","blog","chat","collections","docs","enterprise","join","login","models","new","organizations","papers","posts","pricing","search","settings","spaces","tasks"]);function Yh(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!=="https:"||!Jh.has(t.hostname))return null;const r=t.pathname.split("/").filter(Boolean),n=r[0]==="datasets"?"dataset":"model",s=n==="dataset"?r.slice(1):r;if(s.length!==2||n==="model"&&Qh.has(s[0])||s.some(l=>!l||l==="."||l===".."))return null;const o=s.join("/"),a=s.map(encodeURIComponent).join("/"),i=n==="dataset"?`datasets/${a}`:a,c=n==="dataset"?"datasets":"models";return{type:n,repoId:o,url:`https://huggingface.co/${i}`,thumbnailUrl:`https://cdn-thumbnails.huggingface.co/social-thumbnails/${c}/${a}.png`}}const Xh=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches,ep=({repo:e})=>{const[t,r]=K.useState(!1);return S.jsxs("div",{className:"hf-preview-card",children:[t?S.jsx("div",{className:"hf-preview-fallback","aria-hidden":"true",children:"🤗"}):S.jsx("img",{className:"hf-preview-image","data-testid":"hf-preview-image",src:e.thumbnailUrl,alt:"",loading:"eager",decoding:"async",onError:()=>r(!0)}),S.jsxs("div",{className:"hf-preview-meta",children:[S.jsxs("span",{className:"hf-preview-kind",children:["Hugging Face ",e.type]}),S.jsx("strong",{children:e.repoId}),S.jsx("span",{children:"huggingface.co"})]})]})},tp=({repo:e,children:t})=>{const[r,n]=K.useState(!1),s=K.useRef(null),o=K.useCallback(()=>{uu(e.thumbnailUrl)},[e.thumbnailUrl]);return K.useEffect(()=>{const a=s.current;if(!a||typeof IntersectionObserver>"u")return;const i=new IntersectionObserver(([c])=>{c.isIntersecting&&(o(),i.disconnect())},{rootMargin:"200px"});return i.observe(a),()=>i.disconnect()},[o]),S.jsxs(aa,{open:r,onOpenChange:a=>{(!a||!Xh())&&n(a)},openDelay:150,closeDelay:100,children:[S.jsx(ia,{asChild:!0,children:S.jsx("a",{ref:s,className:"chat-paper-link chat-hf-link",href:e.url,target:"_blank",rel:"noopener noreferrer",onPointerEnter:o,onFocus:o,children:t})}),S.jsx(ca,{className:"hf-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:S.jsx(ep,{repo:e})})]})},rp=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches,np=({repo:e,preview:t,unavailable:r})=>{const[n,s]=K.useState(!1),o=!!(t!=null&&t.avatarUrl)&&!n;return S.jsxs("div",{className:"github-preview-card",children:[o?S.jsx("img",{className:"github-preview-image","data-testid":"github-preview-image",src:t==null?void 0:t.avatarUrl,alt:"",loading:"eager",decoding:"async",onError:()=>s(!0)}):S.jsx("div",{className:"github-preview-fallback","aria-hidden":"true",children:S.jsx(la,{})}),S.jsxs("div",{className:"github-preview-meta",children:[S.jsx("span",{className:"github-preview-kind",children:"GitHub repository"}),S.jsx("strong",{children:e.repoId}),(t==null?void 0:t.description)&&S.jsx("span",{className:"github-preview-description",children:t.description}),t?S.jsxs("span",{className:"github-preview-stats",children:[t.language&&S.jsxs(S.Fragment,{children:[t.language," · "]}),"★ ",t.stars.toLocaleString()," · ⑂ ",t.forks.toLocaleString(),t.archived&&S.jsx(S.Fragment,{children:" · Archived"})]}):S.jsx("span",{children:r?"Preview unavailable":"Loading preview…"})]})]})},sp=({repo:e,children:t})=>{var l;const[r,n]=K.useState(!1),[s,o]=K.useState(!1),a=K.useRef(null),i=K.useCallback(()=>o(!0),[]),c=xh({queryKey:["github-repository-preview",e.repoId.toLowerCase()],queryFn:({signal:d})=>Ah(e,d),enabled:r||s,staleTime:30*60*1e3,gcTime:60*60*1e3,retry:!1});return K.useEffect(()=>{const d=a.current;if(!d||typeof IntersectionObserver>"u")return;const f=new IntersectionObserver(([_])=>{_.isIntersecting&&(i(),f.disconnect())},{rootMargin:"200px"});return f.observe(d),()=>f.disconnect()},[i]),K.useEffect(()=>{var d;(d=c.data)!=null&&d.avatarUrl&&uu(c.data.avatarUrl)},[(l=c.data)==null?void 0:l.avatarUrl]),S.jsxs(aa,{open:r,onOpenChange:d=>{(!d||!rp())&&n(d)},openDelay:150,closeDelay:100,children:[S.jsx(ia,{asChild:!0,children:S.jsxs("a",{ref:a,className:"chat-github-link",href:e.url,target:"_blank",rel:"noopener noreferrer",onPointerEnter:i,onFocus:i,children:[S.jsx(la,{"aria-hidden":"true"}),t]})}),S.jsx(ca,{className:"github-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:S.jsx(np,{repo:e,preview:c.data,unavailable:c.isError})})]})},op=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches;function ap(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return"Web source"}}const ip=({citation:e})=>{const[t,r]=K.useState(!1),[n,s]=K.useState(!1),o=e.thumbnail_url,a=e.favicon_url;return S.jsxs("div",{className:"web-preview-card",children:[o&&!t&&S.jsx("img",{className:"web-preview-image","data-testid":"web-preview-image",src:o,alt:"",loading:"eager",decoding:"async",referrerPolicy:"no-referrer",onError:()=>r(!0)}),S.jsxs("div",{className:"web-preview-meta",children:[S.jsxs("div",{className:"web-preview-source",children:[a&&!n&&S.jsx("img",{src:a,alt:"",loading:"eager",decoding:"async",referrerPolicy:"no-referrer",onError:()=>s(!0)}),S.jsx("span",{children:ap(e.url??"")}),e.published&&S.jsxs(S.Fragment,{children:[S.jsx("span",{"aria-hidden":"true",children:"·"}),S.jsx("time",{children:e.published.slice(0,10)})]})]}),S.jsx("strong",{children:e.title}),e.excerpt&&S.jsx("p",{children:e.excerpt.replace(/\s+/g," ").trim()})]})]})},cp=({citation:e,children:t})=>{const[r,n]=K.useState(!1),s=e.url??"";return S.jsxs(aa,{open:r,onOpenChange:o=>{(!o||!op())&&n(o)},openDelay:150,closeDelay:100,children:[S.jsx(ia,{asChild:!0,children:S.jsx("a",{href:s,className:"chat-web-citation",target:"_blank",rel:"noopener noreferrer",children:t})}),S.jsx(ca,{className:"web-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:S.jsx(ip,{citation:e})})]})};function lp(e){const t=[];let r=0,n=null;for(const s of e.match(/.*(?:\n|$)/g)??[]){if(!s)continue;const o=s.endsWith(` +`)?s.slice(0,-1):s;if(n){const c=o.match(/^ {0,3}(`+|~+)[ \t]*$/);c&&c[1][0]===n.marker&&c[1].length>=n.length&&(t.push({start:n.start,end:r+s.length}),n=null),r+=s.length;continue}const a=o.match(/^ {0,3}(`{3,}|~{3,})/);if(a){n={marker:a[1][0],length:a[1].length,start:r},r+=s.length;continue}let i=0;for(;it>=r.start&&t=0&&e[n]==="\\";n-=1)r+=1;return r%2===0}function xc(e,t,r,n){const s=[];let o=0;for(;on.name),published:t.metadata.published,conference:t.metadata.conference,citationCount:t.metadata.citation_count,tasks:t.metadata.tasks};if(r)return{routeId:e,title:r.title,arxivId:r.arxiv_id??null,source:r.arxiv_id?"arxiv":"external",sourceUrl:r.source_url,thumbnailUrl:r.thumbnail_url??null,authors:r.authors??[],published:r.published??null,conference:r.conference??null,citationCount:r.citation_count??null,tasks:[]}}const du=({routeId:e,paper:t,citation:r,className:n="chat-paper-link",children:s})=>S.jsx(lu,{routeId:e,initialData:dp(e,t,r),className:n,target:"_blank",children:s});function fp(e){const t=e.lastIndexOf("[");if(t===-1)return e;const r=e.slice(t);return/^\[[^\]]*(\]\(?[^)\s]*)?$/.test(r)?e.slice(0,t):e}const hp=e=>e.startsWith("paper:")?e:Fh(e);function pp(e){try{const t=new URL(e);return t.protocol==="https:"&&(t.hostname==="github.com"||t.hostname==="www.github.com")}catch{return!1}}const $o=({text:e,streaming:t,papers:r,citations:n,webCitations:s})=>{const o=up(t?fp(e):e);return S.jsx(qh,{remarkPlugins:[Uh,Dh],rehypePlugins:[zh],urlTransform:hp,components:{a:({href:a,children:i})=>{if(a!=null&&a.startsWith("paper:")){const d=a.slice(6);return!r[d]&&!(n!=null&&n[d])?S.jsx("span",{className:"chat-invalid-citation",children:i}):S.jsx(du,{routeId:d,paper:r[d],citation:n==null?void 0:n[d],children:i})}const c=a?Yh(a):null;if(c)return S.jsx(tp,{repo:c,children:i});const l=a?Mh(a):null;return l?S.jsx(sp,{repo:l,children:i}):a&&pp(a)?S.jsxs("a",{href:a,className:"chat-github-link",target:"_blank",rel:"noopener noreferrer",children:[S.jsx(la,{"aria-hidden":"true"}),i]}):a!=null&&a.startsWith("https://")&&(s!=null&&s[a])?S.jsx(cp,{citation:s[a],children:i}):a!=null&&a.startsWith("https://")?S.jsx("a",{href:a,className:"chat-external-link",target:"_blank",rel:"noopener noreferrer",children:i}):S.jsx("span",{children:i})}},children:o})},mp=Object.freeze({status:"aborted"});function A(e,t,r){function n(i,c){var l;Object.defineProperty(i,"_zod",{value:i._zod??{},enumerable:!1}),(l=i._zod).traits??(l.traits=new Set),i._zod.traits.add(e),t(i,c);for(const d in a.prototype)d in i||Object.defineProperty(i,d,{value:a.prototype[d].bind(i)});i._zod.constr=a,i._zod.def=c}const s=(r==null?void 0:r.Parent)??Object;class o extends s{}Object.defineProperty(o,"name",{value:e});function a(i){var c;const l=r!=null&&r.Parent?new o:this;n(l,i),(c=l._zod).deferred??(c.deferred=[]);for(const d of l._zod.deferred)d();return l}return Object.defineProperty(a,"init",{value:n}),Object.defineProperty(a,Symbol.hasInstance,{value:i=>{var c,l;return r!=null&&r.Parent&&i instanceof r.Parent?!0:(l=(c=i==null?void 0:i._zod)==null?void 0:c.traits)==null?void 0:l.has(e)}}),Object.defineProperty(a,"name",{value:e}),a}class vn extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const fu={};function Ut(e){return fu}function gp(e){const t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,s])=>t.indexOf(+n)===-1).map(([n,s])=>s)}function _p(e,t){return typeof t=="bigint"?t.toString():t}function ua(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function da(e){return e==null}function fa(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function yp(e,t){const r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,s=r>n?r:n,o=Number.parseInt(e.toFixed(s).replace(".","")),a=Number.parseInt(t.toFixed(s).replace(".",""));return o%a/10**s}function Ee(e,t,r){Object.defineProperty(e,t,{get(){{const n=r();return e[t]=n,n}},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function xs(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Yr(e){return JSON.stringify(e)}const hu=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function hs(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const vp=ua(()=>{var e;if(typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)!=null&&e.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function ps(e){if(hs(e)===!1)return!1;const t=e.constructor;if(t===void 0)return!0;const r=t.prototype;return!(hs(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}const $p=new Set(["string","number","symbol"]);function kn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function wr(e,t,r){const n=new e._zod.constr(t??e._zod.def);return(!t||r!=null&&r.parent)&&(n._zod.parent=e),n}function W(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function wp(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const bp={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Sp(e,t){const r={},n=e._zod.def;for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&(r[s]=n.shape[s])}return wr(e,{...e._zod.def,shape:r,checks:[]})}function Ep(e,t){const r={...e._zod.def.shape},n=e._zod.def;for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&delete r[s]}return wr(e,{...e._zod.def,shape:r,checks:[]})}function kp(e,t){if(!ps(t))throw new Error("Invalid input to extend: expected a plain object");const r={...e._zod.def,get shape(){const n={...e._zod.def.shape,...t};return xs(this,"shape",n),n},checks:[]};return wr(e,r)}function Pp(e,t){return wr(e,{...e._zod.def,get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return xs(this,"shape",r),r},catchall:t._zod.def.catchall,checks:[]})}function Tp(e,t,r){const n=t._zod.def.shape,s={...n};if(r)for(const o in r){if(!(o in n))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(s[o]=e?new e({type:"optional",innerType:n[o]}):n[o])}else for(const o in n)s[o]=e?new e({type:"optional",innerType:n[o]}):n[o];return wr(t,{...t._zod.def,shape:s,checks:[]})}function Rp(e,t,r){const n=t._zod.def.shape,s={...n};if(r)for(const o in r){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(s[o]=new e({type:"nonoptional",innerType:n[o]}))}else for(const o in n)s[o]=new e({type:"nonoptional",innerType:n[o]});return wr(t,{...t._zod.def,shape:s,checks:[]})}function cn(e,t=0){var r;for(let n=t;n{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Fn(e){return typeof e=="string"?e:e==null?void 0:e.message}function Ft(e,t,r){var s,o,a,i,c,l;const n={...e,path:e.path??[]};if(!e.message){const d=Fn((a=(o=(s=e.inst)==null?void 0:s._zod.def)==null?void 0:o.error)==null?void 0:a.call(o,e))??Fn((i=t==null?void 0:t.error)==null?void 0:i.call(t,e))??Fn((c=r.customError)==null?void 0:c.call(r,e))??Fn((l=r.localeError)==null?void 0:l.call(r,e))??"Invalid input";n.message=d}return delete n.inst,delete n.continue,t!=null&&t.reportInput||delete n.input,n}function ha(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function $n(...e){const[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}const pu=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(t,_p,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},mu=A("$ZodError",pu),gu=A("$ZodError",pu,{Parent:Error});function jp(e,t=r=>r.message){const r={},n=[];for(const s of e.issues)s.path.length>0?(r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(t(s))):n.push(t(s));return{formErrors:n,fieldErrors:r}}function Cp(e,t){const r=t||function(o){return o.message},n={_errors:[]},s=o=>{for(const a of o.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(i=>s({issues:i}));else if(a.code==="invalid_key")s({issues:a.issues});else if(a.code==="invalid_element")s({issues:a.issues});else if(a.path.length===0)n._errors.push(r(a));else{let i=n,c=0;for(;c(t,r,n,s)=>{const o=n?Object.assign(n,{async:!1}):{async:!1},a=t._zod.run({value:r,issues:[]},o);if(a instanceof Promise)throw new vn;if(a.issues.length){const i=new((s==null?void 0:s.Err)??e)(a.issues.map(c=>Ft(c,o,Ut())));throw hu(i,s==null?void 0:s.callee),i}return a.value},Ip=e=>async(t,r,n,s)=>{const o=n?Object.assign(n,{async:!0}):{async:!0};let a=t._zod.run({value:r,issues:[]},o);if(a instanceof Promise&&(a=await a),a.issues.length){const i=new((s==null?void 0:s.Err)??e)(a.issues.map(c=>Ft(c,o,Ut())));throw hu(i,s==null?void 0:s.callee),i}return a.value},_u=e=>(t,r,n)=>{const s=n?{...n,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},s);if(o instanceof Promise)throw new vn;return o.issues.length?{success:!1,error:new(e??mu)(o.issues.map(a=>Ft(a,s,Ut())))}:{success:!0,data:o.value}},yu=_u(gu),vu=e=>async(t,r,n)=>{const s=n?Object.assign(n,{async:!0}):{async:!0};let o=t._zod.run({value:r,issues:[]},s);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(a=>Ft(a,s,Ut())))}:{success:!0,data:o.value}},Op=vu(gu),xp=/^[cC][^\s-]{8,}$/,Ap=/^[0-9a-z]+$/,Mp=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,zp=/^[0-9a-vA-V]{20}$/,Dp=/^[A-Za-z0-9]{27}$/,qp=/^[a-zA-Z0-9_-]{21}$/,Up=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Fp=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Ac=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,Lp=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Vp="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Hp(){return new RegExp(Vp,"u")}const Zp=/^(?:(?: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])$/,Kp=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,Gp=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Wp=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Bp=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,$u=/^[A-Za-z0-9_-]*$/,Jp=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,Qp=/^\+(?:[0-9]){6,14}[0-9]$/,wu="(?:(?:\\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])))",Yp=new RegExp(`^${wu}$`);function bu(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Xp(e){return new RegExp(`^${bu(e)}$`)}function em(e){const t=bu({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-]\\d{2}:\\d{2})");const n=`${t}(?:${r.join("|")})`;return new RegExp(`^${wu}T(?:${n})$`)}const tm=e=>{const t=e?`[\\s\\S]{${(e==null?void 0:e.minimum)??0},${(e==null?void 0:e.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},rm=/^\d+$/,nm=/^-?\d+(?:\.\d+)?/i,sm=/true|false/i,om=/null/i,am=/undefined/i,im=/^[^A-Z]*$/,cm=/^[^a-z]*$/,Xe=A("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Su={number:"number",bigint:"bigint",object:"date"},Eu=A("$ZodCheckLessThan",(e,t)=>{Xe.init(e,t);const r=Su[typeof t.value];e._zod.onattach.push(n=>{const s=n._zod.bag,o=(t.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value{(t.inclusive?n.value<=t.value:n.value{Xe.init(e,t);const r=Su[typeof t.value];e._zod.onattach.push(n=>{const s=n._zod.bag,o=(t.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?s.minimum=t.value:s.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),lm=A("$ZodCheckMultipleOf",(e,t)=>{Xe.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):yp(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),um=A("$ZodCheckNumberFormat",(e,t)=>{var a;Xe.init(e,t),t.format=t.format||"float64";const r=(a=t.format)==null?void 0:a.includes("int"),n=r?"int":"number",[s,o]=bp[t.format];e._zod.onattach.push(i=>{const c=i._zod.bag;c.format=t.format,c.minimum=s,c.maximum=o,r&&(c.pattern=rm)}),e._zod.check=i=>{const c=i.value;if(r){if(!Number.isInteger(c)){i.issues.push({expected:n,format:t.format,code:"invalid_type",input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?i.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort}):i.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort});return}}co&&i.issues.push({origin:"number",input:c,code:"too_big",maximum:o,inst:e})}}),dm=A("$ZodCheckMaxLength",(e,t)=>{var r;Xe.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!da(s)&&s.length!==void 0}),e._zod.onattach.push(n=>{const s=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum{const s=n.value;if(s.length<=t.maximum)return;const a=ha(s);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),fm=A("$ZodCheckMinLength",(e,t)=>{var r;Xe.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!da(s)&&s.length!==void 0}),e._zod.onattach.push(n=>{const s=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>s&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const s=n.value;if(s.length>=t.minimum)return;const a=ha(s);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),hm=A("$ZodCheckLengthEquals",(e,t)=>{var r;Xe.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!da(s)&&s.length!==void 0}),e._zod.onattach.push(n=>{const s=n._zod.bag;s.minimum=t.length,s.maximum=t.length,s.length=t.length}),e._zod.check=n=>{const s=n.value,o=s.length;if(o===t.length)return;const a=ha(s),i=o>t.length;n.issues.push({origin:a,...i?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),As=A("$ZodCheckStringFormat",(e,t)=>{var r,n;Xe.init(e,t),e._zod.onattach.push(s=>{const o=s._zod.bag;o.format=t.format,t.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=s=>{t.pattern.lastIndex=0,!t.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:t.format,input:s.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),pm=A("$ZodCheckRegex",(e,t)=>{As.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),mm=A("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=im),As.init(e,t)}),gm=A("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=cm),As.init(e,t)}),_m=A("$ZodCheckIncludes",(e,t)=>{Xe.init(e,t);const r=kn(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(s=>{const o=s._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=s=>{s.value.includes(t.includes,t.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:s.value,inst:e,continue:!t.abort})}}),ym=A("$ZodCheckStartsWith",(e,t)=>{Xe.init(e,t);const r=new RegExp(`^${kn(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),vm=A("$ZodCheckEndsWith",(e,t)=>{Xe.init(e,t);const r=new RegExp(`.*${kn(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{const s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),$m=A("$ZodCheckOverwrite",(e,t)=>{Xe.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});class wm{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const n=t.split(` +`).filter(a=>a),s=Math.min(...n.map(a=>a.length-a.trimStart().length)),o=n.map(a=>a.slice(s)).map(a=>" ".repeat(this.indent*2)+a);for(const a of o)this.content.push(a)}compile(){const t=Function,r=this==null?void 0:this.args,s=[...((this==null?void 0:this.content)??[""]).map(o=>` ${o}`)];return new t(...r,s.join(` +`))}}const bm={major:4,minor:0,patch:0},we=A("$ZodType",(e,t)=>{var s;var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=bm;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const o of n)for(const a of o._zod.onattach)a(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),(s=e._zod.deferred)==null||s.push(()=>{e._zod.run=e._zod.parse});else{const o=(a,i,c)=>{let l=cn(a),d;for(const f of i){if(f._zod.def.when){if(!f._zod.def.when(a))continue}else if(l)continue;const _=a.issues.length,y=f._zod.check(a);if(y instanceof Promise&&(c==null?void 0:c.async)===!1)throw new vn;if(d||y instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await y,a.issues.length!==_&&(l||(l=cn(a,_)))});else{if(a.issues.length===_)continue;l||(l=cn(a,_))}}return d?d.then(()=>a):a};e._zod.run=(a,i)=>{const c=e._zod.parse(a,i);if(c instanceof Promise){if(i.async===!1)throw new vn;return c.then(l=>o(l,n,i))}return o(c,n,i)}}e["~standard"]={validate:o=>{var a;try{const i=yu(e,o);return i.success?{value:i.data}:{issues:(a=i.error)==null?void 0:a.issues}}catch{return Op(e,o).then(c=>{var l;return c.success?{value:c.data}:{issues:(l=c.error)==null?void 0:l.issues}})}},vendor:"zod",version:1}}),pa=A("$ZodString",(e,t)=>{var r;we.init(e,t),e._zod.pattern=[...((r=e==null?void 0:e._zod.bag)==null?void 0:r.patterns)??[]].pop()??tm(e._zod.bag),e._zod.parse=(n,s)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Pe=A("$ZodStringFormat",(e,t)=>{As.init(e,t),pa.init(e,t)}),Sm=A("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Fp),Pe.init(e,t)}),Em=A("$ZodUUID",(e,t)=>{if(t.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Ac(n))}else t.pattern??(t.pattern=Ac());Pe.init(e,t)}),km=A("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Lp),Pe.init(e,t)}),Pm=A("$ZodURL",(e,t)=>{Pe.init(e,t),e._zod.check=r=>{try{const n=r.value,s=new URL(n),o=s.href;t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(s.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:Jp.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(s.protocol.endsWith(":")?s.protocol.slice(0,-1):s.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),!n.endsWith("/")&&o.endsWith("/")?r.value=o.slice(0,-1):r.value=o;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Tm=A("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Hp()),Pe.init(e,t)}),Rm=A("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=qp),Pe.init(e,t)}),jm=A("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=xp),Pe.init(e,t)}),Cm=A("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Ap),Pe.init(e,t)}),Nm=A("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Mp),Pe.init(e,t)}),Im=A("$ZodXID",(e,t)=>{t.pattern??(t.pattern=zp),Pe.init(e,t)}),Om=A("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Dp),Pe.init(e,t)}),xm=A("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=em(t)),Pe.init(e,t)}),Am=A("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Yp),Pe.init(e,t)}),Mm=A("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Xp(t)),Pe.init(e,t)}),zm=A("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Up),Pe.init(e,t)}),Dm=A("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Zp),Pe.init(e,t),e._zod.onattach.push(r=>{const n=r._zod.bag;n.format="ipv4"})}),qm=A("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Kp),Pe.init(e,t),e._zod.onattach.push(r=>{const n=r._zod.bag;n.format="ipv6"}),e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),Um=A("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Gp),Pe.init(e,t)}),Fm=A("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Wp),Pe.init(e,t),e._zod.check=r=>{const[n,s]=r.value.split("/");try{if(!s)throw new Error;const o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function Pu(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Lm=A("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Bp),Pe.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),e._zod.check=r=>{Pu(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function Vm(e){if(!$u.test(e))return!1;const t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return Pu(r)}const Hm=A("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=$u),Pe.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),e._zod.check=r=>{Vm(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Zm=A("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Qp),Pe.init(e,t)});function Km(e,t=null){try{const r=e.split(".");if(r.length!==3)return!1;const[n]=r;if(!n)return!1;const s=JSON.parse(atob(n));return!("typ"in s&&(s==null?void 0:s.typ)!=="JWT"||!s.alg||t&&(!("alg"in s)||s.alg!==t))}catch{return!1}}const Gm=A("$ZodJWT",(e,t)=>{Pe.init(e,t),e._zod.check=r=>{Km(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),Tu=A("$ZodNumber",(e,t)=>{we.init(e,t),e._zod.pattern=e._zod.bag.pattern??nm,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}const s=r.value;if(typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s))return r;const o=typeof s=="number"?Number.isNaN(s)?"NaN":Number.isFinite(s)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:s,inst:e,...o?{received:o}:{}}),r}}),Wm=A("$ZodNumber",(e,t)=>{um.init(e,t),Tu.init(e,t)}),Bm=A("$ZodBoolean",(e,t)=>{we.init(e,t),e._zod.pattern=sm,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}const s=r.value;return typeof s=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:s,inst:e}),r}}),Jm=A("$ZodUndefined",(e,t)=>{we.init(e,t),e._zod.pattern=am,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(r,n)=>{const s=r.value;return typeof s>"u"||r.issues.push({expected:"undefined",code:"invalid_type",input:s,inst:e}),r}}),Qm=A("$ZodNull",(e,t)=>{we.init(e,t),e._zod.pattern=om,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{const s=r.value;return s===null||r.issues.push({expected:"null",code:"invalid_type",input:s,inst:e}),r}}),Ym=A("$ZodAny",(e,t)=>{we.init(e,t),e._zod.parse=r=>r}),Xm=A("$ZodUnknown",(e,t)=>{we.init(e,t),e._zod.parse=r=>r}),eg=A("$ZodNever",(e,t)=>{we.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function Mc(e,t,r){e.issues.length&&t.issues.push(...hr(r,e.issues)),t.value[r]=e.value}const tg=A("$ZodArray",(e,t)=>{we.init(e,t),e._zod.parse=(r,n)=>{const s=r.value;if(!Array.isArray(s))return r.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),r;r.value=Array(s.length);const o=[];for(let a=0;aMc(l,r,a))):Mc(c,r,a)}return o.length?Promise.all(o).then(()=>r):r}});function Ln(e,t,r){e.issues.length&&t.issues.push(...hr(r,e.issues)),t.value[r]=e.value}function zc(e,t,r,n){e.issues.length?n[r]===void 0?r in n?t.value[r]=void 0:t.value[r]=e.value:t.issues.push(...hr(r,e.issues)):e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}const rg=A("$ZodObject",(e,t)=>{we.init(e,t);const r=ua(()=>{const f=Object.keys(t.shape);for(const y of f)if(!(t.shape[y]instanceof we))throw new Error(`Invalid element at key "${y}": expected a Zod schema`);const _=wp(t.shape);return{shape:t.shape,keys:f,keySet:new Set(f),numKeys:f.length,optionalKeys:new Set(_)}});Ee(e._zod,"propValues",()=>{const f=t.shape,_={};for(const y in f){const g=f[y]._zod;if(g.values){_[y]??(_[y]=new Set);for(const $ of g.values)_[y].add($)}}return _});const n=f=>{const _=new wm(["shape","payload","ctx"]),y=r.value,g=v=>{const k=Yr(v);return`shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`};_.write("const input = payload.value;");const $=Object.create(null);let m=0;for(const v of y.keys)$[v]=`key_${m++}`;_.write("const newResult = {}");for(const v of y.keys)if(y.optionalKeys.has(v)){const k=$[v];_.write(`const ${k} = ${g(v)};`);const R=Yr(v);_.write(` + if (${k}.issues.length) { + if (input[${R}] === undefined) { + if (${R} in input) { + newResult[${R}] = undefined; + } + } else { + payload.issues = payload.issues.concat( + ${k}.issues.map((iss) => ({ + ...iss, + path: iss.path ? [${R}, ...iss.path] : [${R}], + })) + ); + } + } else if (${k}.value === undefined) { + if (${R} in input) newResult[${R}] = undefined; + } else { + newResult[${R}] = ${k}.value; + } + `)}else{const k=$[v];_.write(`const ${k} = ${g(v)};`),_.write(` + if (${k}.issues.length) payload.issues = payload.issues.concat(${k}.issues.map(iss => ({ + ...iss, + path: iss.path ? [${Yr(v)}, ...iss.path] : [${Yr(v)}] + })));`),_.write(`newResult[${Yr(v)}] = ${k}.value`)}_.write("payload.value = newResult;"),_.write("return payload;");const h=_.compile();return(v,k)=>h(f,v,k)};let s;const o=hs,a=!fu.jitless,c=a&&vp.value,l=t.catchall;let d;e._zod.parse=(f,_)=>{d??(d=r.value);const y=f.value;if(!o(y))return f.issues.push({expected:"object",code:"invalid_type",input:y,inst:e}),f;const g=[];if(a&&c&&(_==null?void 0:_.async)===!1&&_.jitless!==!0)s||(s=n(t.shape)),f=s(f,_);else{f.value={};const k=d.shape;for(const R of d.keys){const E=k[R],I=E._zod.run({value:y[R],issues:[]},_),x=E._zod.optin==="optional"&&E._zod.optout==="optional";I instanceof Promise?g.push(I.then(q=>x?zc(q,f,R,y):Ln(q,f,R))):x?zc(I,f,R,y):Ln(I,f,R)}}if(!l)return g.length?Promise.all(g).then(()=>f):f;const $=[],m=d.keySet,h=l._zod,v=h.def.type;for(const k of Object.keys(y)){if(m.has(k))continue;if(v==="never"){$.push(k);continue}const R=h.run({value:y[k],issues:[]},_);R instanceof Promise?g.push(R.then(E=>Ln(E,f,k))):Ln(R,f,k)}return $.length&&f.issues.push({code:"unrecognized_keys",keys:$,input:y,inst:e}),g.length?Promise.all(g).then(()=>f):f}});function Dc(e,t,r,n){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(s=>s.issues.map(o=>Ft(o,n,Ut())))}),t}const Ru=A("$ZodUnion",(e,t)=>{we.init(e,t),Ee(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),Ee(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),Ee(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),Ee(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(n=>n._zod.pattern);return new RegExp(`^(${r.map(n=>fa(n.source)).join("|")})$`)}}),e._zod.parse=(r,n)=>{let s=!1;const o=[];for(const a of t.options){const i=a._zod.run({value:r.value,issues:[]},n);if(i instanceof Promise)o.push(i),s=!0;else{if(i.issues.length===0)return i;o.push(i)}}return s?Promise.all(o).then(a=>Dc(a,r,e,n)):Dc(o,r,e,n)}}),ng=A("$ZodDiscriminatedUnion",(e,t)=>{Ru.init(e,t);const r=e._zod.parse;Ee(e._zod,"propValues",()=>{const s={};for(const o of t.options){const a=o._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(const[i,c]of Object.entries(a)){s[i]||(s[i]=new Set);for(const l of c)s[i].add(l)}}return s});const n=ua(()=>{const s=t.options,o=new Map;for(const a of s){const i=a._zod.propValues[t.discriminator];if(!i||i.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(const c of i){if(o.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);o.set(c,a)}}return o});e._zod.parse=(s,o)=>{const a=s.value;if(!hs(a))return s.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),s;const i=n.value.get(a==null?void 0:a[t.discriminator]);return i?i._zod.run(s,o):t.unionFallback?r(s,o):(s.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:a,path:[t.discriminator],inst:e}),s)}}),sg=A("$ZodIntersection",(e,t)=>{we.init(e,t),e._zod.parse=(r,n)=>{const s=r.value,o=t.left._zod.run({value:s,issues:[]},n),a=t.right._zod.run({value:s,issues:[]},n);return o instanceof Promise||a instanceof Promise?Promise.all([o,a]).then(([c,l])=>qc(r,c,l)):qc(r,o,a)}});function wo(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(ps(e)&&ps(t)){const r=Object.keys(t),n=Object.keys(e).filter(o=>r.indexOf(o)!==-1),s={...e,...t};for(const o of n){const a=wo(e[o],t[o]);if(!a.valid)return{valid:!1,mergeErrorPath:[o,...a.mergeErrorPath]};s[o]=a.data}return{valid:!0,data:s}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n{we.init(e,t),e._zod.parse=(r,n)=>{const s=r.value;if(!ps(s))return r.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),r;const o=[];if(t.keyType._zod.values){const a=t.keyType._zod.values;r.value={};for(const c of a)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){const l=t.valueType._zod.run({value:s[c],issues:[]},n);l instanceof Promise?o.push(l.then(d=>{d.issues.length&&r.issues.push(...hr(c,d.issues)),r.value[c]=d.value})):(l.issues.length&&r.issues.push(...hr(c,l.issues)),r.value[c]=l.value)}let i;for(const c in s)a.has(c)||(i=i??[],i.push(c));i&&i.length>0&&r.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:i})}else{r.value={};for(const a of Reflect.ownKeys(s)){if(a==="__proto__")continue;const i=t.keyType._zod.run({value:a,issues:[]},n);if(i instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(i.issues.length){r.issues.push({origin:"record",code:"invalid_key",issues:i.issues.map(l=>Ft(l,n,Ut())),input:a,path:[a],inst:e}),r.value[i.value]=i.value;continue}const c=t.valueType._zod.run({value:s[a],issues:[]},n);c instanceof Promise?o.push(c.then(l=>{l.issues.length&&r.issues.push(...hr(a,l.issues)),r.value[i.value]=l.value})):(c.issues.length&&r.issues.push(...hr(a,c.issues)),r.value[i.value]=c.value)}}return o.length?Promise.all(o).then(()=>r):r}}),ag=A("$ZodEnum",(e,t)=>{we.init(e,t);const r=gp(t.entries);e._zod.values=new Set(r),e._zod.pattern=new RegExp(`^(${r.filter(n=>$p.has(typeof n)).map(n=>typeof n=="string"?kn(n):n.toString()).join("|")})$`),e._zod.parse=(n,s)=>{const o=n.value;return e._zod.values.has(o)||n.issues.push({code:"invalid_value",values:r,input:o,inst:e}),n}}),ig=A("$ZodLiteral",(e,t)=>{we.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?kn(r):r?r.toString():String(r)).join("|")})$`),e._zod.parse=(r,n)=>{const s=r.value;return e._zod.values.has(s)||r.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),r}}),cg=A("$ZodTransform",(e,t)=>{we.init(e,t),e._zod.parse=(r,n)=>{const s=t.transform(r.value,r);if(n.async)return(s instanceof Promise?s:Promise.resolve(s)).then(a=>(r.value=a,r));if(s instanceof Promise)throw new vn;return r.value=s,r}}),lg=A("$ZodOptional",(e,t)=>{we.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Ee(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Ee(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${fa(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>t.innerType._zod.optin==="optional"?t.innerType._zod.run(r,n):r.value===void 0?r:t.innerType._zod.run(r,n)}),ug=A("$ZodNullable",(e,t)=>{we.init(e,t),Ee(e._zod,"optin",()=>t.innerType._zod.optin),Ee(e._zod,"optout",()=>t.innerType._zod.optout),Ee(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${fa(r.source)}|null)$`):void 0}),Ee(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),dg=A("$ZodDefault",(e,t)=>{we.init(e,t),e._zod.optin="optional",Ee(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(r.value===void 0)return r.value=t.defaultValue,r;const s=t.innerType._zod.run(r,n);return s instanceof Promise?s.then(o=>Uc(o,t)):Uc(s,t)}});function Uc(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const fg=A("$ZodPrefault",(e,t)=>{we.init(e,t),e._zod.optin="optional",Ee(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),hg=A("$ZodNonOptional",(e,t)=>{we.init(e,t),Ee(e._zod,"values",()=>{const r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{const s=t.innerType._zod.run(r,n);return s instanceof Promise?s.then(o=>Fc(o,e)):Fc(s,e)}});function Fc(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const pg=A("$ZodCatch",(e,t)=>{we.init(e,t),e._zod.optin="optional",Ee(e._zod,"optout",()=>t.innerType._zod.optout),Ee(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{const s=t.innerType._zod.run(r,n);return s instanceof Promise?s.then(o=>(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(a=>Ft(a,n,Ut()))},input:r.value}),r.issues=[]),r)):(r.value=s.value,s.issues.length&&(r.value=t.catchValue({...r,error:{issues:s.issues.map(o=>Ft(o,n,Ut()))},input:r.value}),r.issues=[]),r)}}),mg=A("$ZodPipe",(e,t)=>{we.init(e,t),Ee(e._zod,"values",()=>t.in._zod.values),Ee(e._zod,"optin",()=>t.in._zod.optin),Ee(e._zod,"optout",()=>t.out._zod.optout),e._zod.parse=(r,n)=>{const s=t.in._zod.run(r,n);return s instanceof Promise?s.then(o=>Lc(o,t,n)):Lc(s,t,n)}});function Lc(e,t,r){return cn(e)?e:t.out._zod.run({value:e.value,issues:e.issues},r)}const gg=A("$ZodReadonly",(e,t)=>{we.init(e,t),Ee(e._zod,"propValues",()=>t.innerType._zod.propValues),Ee(e._zod,"values",()=>t.innerType._zod.values),Ee(e._zod,"optin",()=>t.innerType._zod.optin),Ee(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(r,n)=>{const s=t.innerType._zod.run(r,n);return s instanceof Promise?s.then(Vc):Vc(s)}});function Vc(e){return e.value=Object.freeze(e.value),e}const _g=A("$ZodCustom",(e,t)=>{Xe.init(e,t),we.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{const n=r.value,s=t.fn(n);if(s instanceof Promise)return s.then(o=>Hc(o,r,n,e));Hc(s,r,n,e)}});function Hc(e,t,r,n){if(!e){const s={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(s.params=n._zod.def.params),t.issues.push($n(s))}}class yg{constructor(){this._map=new Map,this._idmap=new Map}add(t,...r){const n=r[0];if(this._map.set(t,n),n&&typeof n=="object"&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,t)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(t){const r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){const r=t._zod.parent;if(r){const n={...this.get(r)??{}};return delete n.id,{...n,...this._map.get(t)}}return this._map.get(t)}has(t){return this._map.has(t)}}function vg(){return new yg}const Vn=vg();function $g(e,t){return new e({type:"string",...W(t)})}function wg(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...W(t)})}function Zc(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...W(t)})}function bg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...W(t)})}function Sg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...W(t)})}function Eg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...W(t)})}function kg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...W(t)})}function ju(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...W(t)})}function Pg(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...W(t)})}function Tg(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...W(t)})}function Rg(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...W(t)})}function jg(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...W(t)})}function Cg(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...W(t)})}function Ng(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...W(t)})}function Ig(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...W(t)})}function Og(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...W(t)})}function xg(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...W(t)})}function Ag(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...W(t)})}function Mg(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...W(t)})}function zg(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...W(t)})}function Dg(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...W(t)})}function qg(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...W(t)})}function Ug(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...W(t)})}function Fg(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...W(t)})}function Lg(e,t){return new e({type:"string",format:"date",check:"string_format",...W(t)})}function Vg(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...W(t)})}function Hg(e,t){return new e({type:"string",format:"duration",check:"string_format",...W(t)})}function Zg(e,t){return new e({type:"number",checks:[],...W(t)})}function Kg(e,t){return new e({type:"number",coerce:!0,checks:[],...W(t)})}function Gg(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...W(t)})}function Wg(e,t){return new e({type:"boolean",...W(t)})}function Bg(e,t){return new e({type:"undefined",...W(t)})}function Jg(e,t){return new e({type:"null",...W(t)})}function Qg(e){return new e({type:"any"})}function Yg(e){return new e({type:"unknown"})}function Xg(e,t){return new e({type:"never",...W(t)})}function Kc(e,t){return new Eu({check:"less_than",...W(t),value:e,inclusive:!1})}function to(e,t){return new Eu({check:"less_than",...W(t),value:e,inclusive:!0})}function Gc(e,t){return new ku({check:"greater_than",...W(t),value:e,inclusive:!1})}function ro(e,t){return new ku({check:"greater_than",...W(t),value:e,inclusive:!0})}function Wc(e,t){return new lm({check:"multiple_of",...W(t),value:e})}function Cu(e,t){return new dm({check:"max_length",...W(t),maximum:e})}function ms(e,t){return new fm({check:"min_length",...W(t),minimum:e})}function Nu(e,t){return new hm({check:"length_equals",...W(t),length:e})}function e_(e,t){return new pm({check:"string_format",format:"regex",...W(t),pattern:e})}function t_(e){return new mm({check:"string_format",format:"lowercase",...W(e)})}function r_(e){return new gm({check:"string_format",format:"uppercase",...W(e)})}function n_(e,t){return new _m({check:"string_format",format:"includes",...W(t),includes:e})}function s_(e,t){return new ym({check:"string_format",format:"starts_with",...W(t),prefix:e})}function o_(e,t){return new vm({check:"string_format",format:"ends_with",...W(t),suffix:e})}function Pn(e){return new $m({check:"overwrite",tx:e})}function a_(e){return Pn(t=>t.normalize(e))}function i_(){return Pn(e=>e.trim())}function c_(){return Pn(e=>e.toLowerCase())}function l_(){return Pn(e=>e.toUpperCase())}function u_(e,t,r){return new e({type:"array",element:t,...W(r)})}function d_(e,t,r){const n=W(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function f_(e,t,r){return new e({type:"custom",check:"custom",fn:t,...W(r)})}const h_=A("ZodISODateTime",(e,t)=>{xm.init(e,t),Re.init(e,t)});function Iu(e){return Fg(h_,e)}const p_=A("ZodISODate",(e,t)=>{Am.init(e,t),Re.init(e,t)});function m_(e){return Lg(p_,e)}const g_=A("ZodISOTime",(e,t)=>{Mm.init(e,t),Re.init(e,t)});function __(e){return Vg(g_,e)}const y_=A("ZodISODuration",(e,t)=>{zm.init(e,t),Re.init(e,t)});function v_(e){return Hg(y_,e)}const $_=(e,t)=>{mu.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>Cp(e,r)},flatten:{value:r=>jp(e,r)},addIssue:{value:r=>e.issues.push(r)},addIssues:{value:r=>e.issues.push(...r)},isEmpty:{get(){return e.issues.length===0}}})},Ms=A("ZodError",$_,{Parent:Error}),w_=Np(Ms),b_=Ip(Ms),S_=_u(Ms),E_=vu(Ms),ke=A("ZodType",(e,t)=>(we.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),e.clone=(r,n)=>wr(e,r,n),e.brand=()=>e,e.register=(r,n)=>(r.add(e,n),e),e.parse=(r,n)=>w_(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>S_(e,r,n),e.parseAsync=async(r,n)=>b_(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>E_(e,r,n),e.spa=e.safeParseAsync,e.refine=(r,n)=>e.check(gy(r,n)),e.superRefine=r=>e.check(_y(r)),e.overwrite=r=>e.check(Pn(r)),e.optional=()=>Te(e),e.nullable=()=>Qc(e),e.nullish=()=>Te(Qc(e)),e.nonoptional=r=>cy(e,r),e.array=()=>F(e),e.or=r=>pe([e,r]),e.and=r=>_a(e,r),e.transform=r=>ko(e,Du(r)),e.default=r=>oy(e,r),e.prefault=r=>iy(e,r),e.catch=r=>uy(e,r),e.pipe=r=>ko(e,r),e.readonly=()=>hy(e),e.describe=r=>{const n=e.clone();return Vn.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){var r;return(r=Vn.get(e))==null?void 0:r.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return Vn.get(e);const n=e.clone();return Vn.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),Ou=A("_ZodString",(e,t)=>{pa.init(e,t),ke.init(e,t);const r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...n)=>e.check(e_(...n)),e.includes=(...n)=>e.check(n_(...n)),e.startsWith=(...n)=>e.check(s_(...n)),e.endsWith=(...n)=>e.check(o_(...n)),e.min=(...n)=>e.check(ms(...n)),e.max=(...n)=>e.check(Cu(...n)),e.length=(...n)=>e.check(Nu(...n)),e.nonempty=(...n)=>e.check(ms(1,...n)),e.lowercase=n=>e.check(t_(n)),e.uppercase=n=>e.check(r_(n)),e.trim=()=>e.check(i_()),e.normalize=(...n)=>e.check(a_(...n)),e.toLowerCase=()=>e.check(c_()),e.toUpperCase=()=>e.check(l_())}),k_=A("ZodString",(e,t)=>{pa.init(e,t),Ou.init(e,t),e.email=r=>e.check(wg(P_,r)),e.url=r=>e.check(ju(xu,r)),e.jwt=r=>e.check(Ug(L_,r)),e.emoji=r=>e.check(Pg(R_,r)),e.guid=r=>e.check(Zc(Bc,r)),e.uuid=r=>e.check(bg(Hn,r)),e.uuidv4=r=>e.check(Sg(Hn,r)),e.uuidv6=r=>e.check(Eg(Hn,r)),e.uuidv7=r=>e.check(kg(Hn,r)),e.nanoid=r=>e.check(Tg(j_,r)),e.guid=r=>e.check(Zc(Bc,r)),e.cuid=r=>e.check(Rg(C_,r)),e.cuid2=r=>e.check(jg(N_,r)),e.ulid=r=>e.check(Cg(I_,r)),e.base64=r=>e.check(zg(q_,r)),e.base64url=r=>e.check(Dg(U_,r)),e.xid=r=>e.check(Ng(O_,r)),e.ksuid=r=>e.check(Ig(x_,r)),e.ipv4=r=>e.check(Og(A_,r)),e.ipv6=r=>e.check(xg(M_,r)),e.cidrv4=r=>e.check(Ag(z_,r)),e.cidrv6=r=>e.check(Mg(D_,r)),e.e164=r=>e.check(qg(F_,r)),e.datetime=r=>e.check(Iu(r)),e.date=r=>e.check(m_(r)),e.time=r=>e.check(__(r)),e.duration=r=>e.check(v_(r))});function T(e){return $g(k_,e)}const Re=A("ZodStringFormat",(e,t)=>{Pe.init(e,t),Ou.init(e,t)}),P_=A("ZodEmail",(e,t)=>{km.init(e,t),Re.init(e,t)}),Bc=A("ZodGUID",(e,t)=>{Sm.init(e,t),Re.init(e,t)}),Hn=A("ZodUUID",(e,t)=>{Em.init(e,t),Re.init(e,t)}),xu=A("ZodURL",(e,t)=>{Pm.init(e,t),Re.init(e,t)});function T_(e){return ju(xu,e)}const R_=A("ZodEmoji",(e,t)=>{Tm.init(e,t),Re.init(e,t)}),j_=A("ZodNanoID",(e,t)=>{Rm.init(e,t),Re.init(e,t)}),C_=A("ZodCUID",(e,t)=>{jm.init(e,t),Re.init(e,t)}),N_=A("ZodCUID2",(e,t)=>{Cm.init(e,t),Re.init(e,t)}),I_=A("ZodULID",(e,t)=>{Nm.init(e,t),Re.init(e,t)}),O_=A("ZodXID",(e,t)=>{Im.init(e,t),Re.init(e,t)}),x_=A("ZodKSUID",(e,t)=>{Om.init(e,t),Re.init(e,t)}),A_=A("ZodIPv4",(e,t)=>{Dm.init(e,t),Re.init(e,t)}),M_=A("ZodIPv6",(e,t)=>{qm.init(e,t),Re.init(e,t)}),z_=A("ZodCIDRv4",(e,t)=>{Um.init(e,t),Re.init(e,t)}),D_=A("ZodCIDRv6",(e,t)=>{Fm.init(e,t),Re.init(e,t)}),q_=A("ZodBase64",(e,t)=>{Lm.init(e,t),Re.init(e,t)}),U_=A("ZodBase64URL",(e,t)=>{Hm.init(e,t),Re.init(e,t)}),F_=A("ZodE164",(e,t)=>{Zm.init(e,t),Re.init(e,t)}),L_=A("ZodJWT",(e,t)=>{Gm.init(e,t),Re.init(e,t)}),ma=A("ZodNumber",(e,t)=>{Tu.init(e,t),ke.init(e,t),e.gt=(n,s)=>e.check(Gc(n,s)),e.gte=(n,s)=>e.check(ro(n,s)),e.min=(n,s)=>e.check(ro(n,s)),e.lt=(n,s)=>e.check(Kc(n,s)),e.lte=(n,s)=>e.check(to(n,s)),e.max=(n,s)=>e.check(to(n,s)),e.int=n=>e.check(Jc(n)),e.safe=n=>e.check(Jc(n)),e.positive=n=>e.check(Gc(0,n)),e.nonnegative=n=>e.check(ro(0,n)),e.negative=n=>e.check(Kc(0,n)),e.nonpositive=n=>e.check(to(0,n)),e.multipleOf=(n,s)=>e.check(Wc(n,s)),e.step=(n,s)=>e.check(Wc(n,s)),e.finite=()=>e;const r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function ae(e){return Zg(ma,e)}const V_=A("ZodNumberFormat",(e,t)=>{Wm.init(e,t),ma.init(e,t)});function Jc(e){return Gg(V_,e)}const H_=A("ZodBoolean",(e,t)=>{Bm.init(e,t),ke.init(e,t)});function me(e){return Wg(H_,e)}const Z_=A("ZodUndefined",(e,t)=>{Jm.init(e,t),ke.init(e,t)});function bo(e){return Bg(Z_,e)}const K_=A("ZodNull",(e,t)=>{Qm.init(e,t),ke.init(e,t)});function G_(e){return Jg(K_,e)}const W_=A("ZodAny",(e,t)=>{Ym.init(e,t),ke.init(e,t)});function ga(){return Qg(W_)}const B_=A("ZodUnknown",(e,t)=>{Xm.init(e,t),ke.init(e,t)});function $e(){return Yg(B_)}const J_=A("ZodNever",(e,t)=>{eg.init(e,t),ke.init(e,t)});function So(e){return Xg(J_,e)}const Q_=A("ZodArray",(e,t)=>{tg.init(e,t),ke.init(e,t),e.element=t.element,e.min=(r,n)=>e.check(ms(r,n)),e.nonempty=r=>e.check(ms(1,r)),e.max=(r,n)=>e.check(Cu(r,n)),e.length=(r,n)=>e.check(Nu(r,n)),e.unwrap=()=>e.element});function F(e,t){return u_(Q_,e,t)}const Au=A("ZodObject",(e,t)=>{rg.init(e,t),ke.init(e,t),Ee(e,"shape",()=>t.shape),e.keyof=()=>tt(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:$e()}),e.loose=()=>e.clone({...e._zod.def,catchall:$e()}),e.strict=()=>e.clone({...e._zod.def,catchall:So()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>kp(e,r),e.merge=r=>Pp(e,r),e.pick=r=>Sp(e,r),e.omit=r=>Ep(e,r),e.partial=(...r)=>Tp(qu,e,r[0]),e.required=(...r)=>Rp(Uu,e,r[0])});function O(e,t){const r={type:"object",get shape(){return xs(this,"shape",{...e}),this.shape},...W(t)};return new Au(r)}function Le(e,t){return new Au({type:"object",get shape(){return xs(this,"shape",{...e}),this.shape},catchall:$e(),...W(t)})}const Mu=A("ZodUnion",(e,t)=>{Ru.init(e,t),ke.init(e,t),e.options=t.options});function pe(e,t){return new Mu({type:"union",options:e,...W(t)})}const Y_=A("ZodDiscriminatedUnion",(e,t)=>{Mu.init(e,t),ng.init(e,t)});function zu(e,t,r){return new Y_({type:"union",options:t,discriminator:e,...W(r)})}const X_=A("ZodIntersection",(e,t)=>{sg.init(e,t),ke.init(e,t)});function _a(e,t){return new X_({type:"intersection",left:e,right:t})}const ey=A("ZodRecord",(e,t)=>{og.init(e,t),ke.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function ge(e,t,r){return new ey({type:"record",keyType:e,valueType:t,...W(r)})}const Eo=A("ZodEnum",(e,t)=>{ag.init(e,t),ke.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);const r=new Set(Object.keys(t.entries));e.extract=(n,s)=>{const o={};for(const a of n)if(r.has(a))o[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new Eo({...t,checks:[],...W(s),entries:o})},e.exclude=(n,s)=>{const o={...t.entries};for(const a of n)if(r.has(a))delete o[a];else throw new Error(`Key ${a} not found in enum`);return new Eo({...t,checks:[],...W(s),entries:o})}});function tt(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new Eo({type:"enum",entries:r,...W(t)})}const ty=A("ZodLiteral",(e,t)=>{ig.init(e,t),ke.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function C(e,t){return new ty({type:"literal",values:Array.isArray(e)?e:[e],...W(t)})}const ry=A("ZodTransform",(e,t)=>{cg.init(e,t),ke.init(e,t),e._zod.parse=(r,n)=>{r.addIssue=o=>{if(typeof o=="string")r.issues.push($n(o,r.value,t));else{const a=o;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=r.value),a.inst??(a.inst=e),a.continue??(a.continue=!0),r.issues.push($n(a))}};const s=t.transform(r.value,r);return s instanceof Promise?s.then(o=>(r.value=o,r)):(r.value=s,r)}});function Du(e){return new ry({type:"transform",transform:e})}const qu=A("ZodOptional",(e,t)=>{lg.init(e,t),ke.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Te(e){return new qu({type:"optional",innerType:e})}const ny=A("ZodNullable",(e,t)=>{ug.init(e,t),ke.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Qc(e){return new ny({type:"nullable",innerType:e})}const sy=A("ZodDefault",(e,t)=>{dg.init(e,t),ke.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function oy(e,t){return new sy({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const ay=A("ZodPrefault",(e,t)=>{fg.init(e,t),ke.init(e,t),e.unwrap=()=>e._zod.def.innerType});function iy(e,t){return new ay({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const Uu=A("ZodNonOptional",(e,t)=>{hg.init(e,t),ke.init(e,t),e.unwrap=()=>e._zod.def.innerType});function cy(e,t){return new Uu({type:"nonoptional",innerType:e,...W(t)})}const ly=A("ZodCatch",(e,t)=>{pg.init(e,t),ke.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function uy(e,t){return new ly({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const dy=A("ZodPipe",(e,t)=>{mg.init(e,t),ke.init(e,t),e.in=t.in,e.out=t.out});function ko(e,t){return new dy({type:"pipe",in:e,out:t})}const fy=A("ZodReadonly",(e,t)=>{gg.init(e,t),ke.init(e,t)});function hy(e){return new fy({type:"readonly",innerType:e})}const Fu=A("ZodCustom",(e,t)=>{_g.init(e,t),ke.init(e,t)});function py(e){const t=new Xe({check:"custom"});return t._zod.check=e,t}function my(e,t){return d_(Fu,e??(()=>!0),t)}function gy(e,t={}){return f_(Fu,e,t)}function _y(e){const t=py(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push($n(n,r.value,t._zod.def));else{const s=n;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=t),s.continue??(s.continue=!t._zod.def.abort),r.issues.push($n(s))}},e(r.value,r)));return t}function Lu(e,t){return ko(Du(e),t)}const yy={custom:"custom"};function vy(e){return Kg(ma,e)}const zs="2025-11-25",$y=[zs,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],ar="io.modelcontextprotocol/related-task",Ds="2.0",Ae=my(e=>e!==null&&(typeof e=="object"||typeof e=="function")),Vu=pe([T(),ae().int()]),Hu=T();Le({ttl:ae().optional(),pollInterval:ae().optional()});const wy=O({ttl:ae().optional()}),by=O({taskId:T()}),ya=Le({progressToken:Vu.optional(),[ar]:by.optional()}),rt=O({_meta:ya.optional()}),Tn=rt.extend({task:wy.optional()}),Sy=e=>Tn.safeParse(e).success,Ve=O({method:T(),params:rt.loose().optional()}),ot=O({_meta:ya.optional()}),at=O({method:T(),params:ot.loose().optional()}),He=Le({_meta:ya.optional()}),Rn=pe([T(),ae().int()]),Zu=O({jsonrpc:C(Ds),id:Rn,...Ve.shape}).strict(),Po=e=>Zu.safeParse(e).success,Ku=O({jsonrpc:C(Ds),...at.shape}).strict(),Ey=e=>Ku.safeParse(e).success,va=O({jsonrpc:C(Ds),id:Rn,result:He}).strict(),nn=e=>va.safeParse(e).success;var re;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(re||(re={}));const $a=O({jsonrpc:C(Ds),id:Rn.optional(),error:O({code:ae().int(),message:T(),data:$e().optional()})}).strict(),ky=e=>$a.safeParse(e).success,rs=pe([Zu,Ku,va,$a]);pe([va,$a]);const Cr=He.strict(),Py=ot.extend({requestId:Rn.optional(),reason:T().optional()}),wa=at.extend({method:C("notifications/cancelled"),params:Py}),Ty=O({src:T(),mimeType:T().optional(),sizes:F(T()).optional(),theme:tt(["light","dark"]).optional()}),jn=O({icons:F(Ty).optional()}),zr=O({name:T(),title:T().optional()}),qs=zr.extend({...zr.shape,...jn.shape,version:T(),websiteUrl:T().optional(),description:T().optional()}),Ry=_a(O({applyDefaults:me().optional()}),ge(T(),$e())),jy=Lu(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,_a(O({form:Ry.optional(),url:Ae.optional()}),ge(T(),$e()).optional())),Cy=Le({list:Ae.optional(),cancel:Ae.optional(),requests:Le({sampling:Le({createMessage:Ae.optional()}).optional(),elicitation:Le({create:Ae.optional()}).optional()}).optional()}),Ny=Le({list:Ae.optional(),cancel:Ae.optional(),requests:Le({tools:Le({call:Ae.optional()}).optional()}).optional()}),Iy=O({experimental:ge(T(),Ae).optional(),sampling:O({context:Ae.optional(),tools:Ae.optional()}).optional(),elicitation:jy.optional(),roots:O({listChanged:me().optional()}).optional(),tasks:Cy.optional(),extensions:ge(T(),Ae).optional()}),Oy=rt.extend({protocolVersion:T(),capabilities:Iy,clientInfo:qs}),xy=Ve.extend({method:C("initialize"),params:Oy}),Ay=O({experimental:ge(T(),Ae).optional(),logging:Ae.optional(),completions:Ae.optional(),prompts:O({listChanged:me().optional()}).optional(),resources:O({subscribe:me().optional(),listChanged:me().optional()}).optional(),tools:O({listChanged:me().optional()}).optional(),tasks:Ny.optional(),extensions:ge(T(),Ae).optional()}),Gu=He.extend({protocolVersion:T(),capabilities:Ay,serverInfo:qs,instructions:T().optional()}),Wu=at.extend({method:C("notifications/initialized"),params:ot.optional()}),My=e=>Wu.safeParse(e).success,Us=Ve.extend({method:C("ping"),params:rt.optional()}),zy=O({progress:ae(),total:Te(ae()),message:Te(T())}),Dy=O({...ot.shape,...zy.shape,progressToken:Vu}),ba=at.extend({method:C("notifications/progress"),params:Dy}),qy=rt.extend({cursor:Hu.optional()}),Cn=Ve.extend({params:qy.optional()}),Nn=He.extend({nextCursor:Hu.optional()}),Uy=tt(["working","input_required","completed","failed","cancelled"]),In=O({taskId:T(),status:Uy,ttl:pe([ae(),G_()]),createdAt:T(),lastUpdatedAt:T(),pollInterval:Te(ae()),statusMessage:Te(T())}),wn=He.extend({task:In}),Fy=ot.merge(In),gs=at.extend({method:C("notifications/tasks/status"),params:Fy}),Sa=Ve.extend({method:C("tasks/get"),params:rt.extend({taskId:T()})}),Ea=He.merge(In),ka=Ve.extend({method:C("tasks/result"),params:rt.extend({taskId:T()})});He.loose();const Pa=Cn.extend({method:C("tasks/list")}),Ta=Nn.extend({tasks:F(In)}),Ra=Ve.extend({method:C("tasks/cancel"),params:rt.extend({taskId:T()})}),Ly=He.merge(In),Bu=O({uri:T(),mimeType:Te(T()),_meta:ge(T(),$e()).optional()}),Ju=Bu.extend({text:T()}),ja=T().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Qu=Bu.extend({blob:ja}),On=tt(["user","assistant"]),Vr=O({audience:F(On).optional(),priority:ae().min(0).max(1).optional(),lastModified:Iu({offset:!0}).optional()}),Yu=O({...zr.shape,...jn.shape,uri:T(),description:Te(T()),mimeType:Te(T()),size:Te(ae()),annotations:Vr.optional(),_meta:Te(Le({}))}),Vy=O({...zr.shape,...jn.shape,uriTemplate:T(),description:Te(T()),mimeType:Te(T()),annotations:Vr.optional(),_meta:Te(Le({}))}),Xu=Cn.extend({method:C("resources/list")}),Ca=Nn.extend({resources:F(Yu)}),ed=Cn.extend({method:C("resources/templates/list")}),Na=Nn.extend({resourceTemplates:F(Vy)}),Ia=rt.extend({uri:T()}),Hy=Ia,td=Ve.extend({method:C("resources/read"),params:Hy}),Oa=He.extend({contents:F(pe([Ju,Qu]))}),xa=at.extend({method:C("notifications/resources/list_changed"),params:ot.optional()}),Zy=Ia,Ky=Ve.extend({method:C("resources/subscribe"),params:Zy}),Gy=Ia,Wy=Ve.extend({method:C("resources/unsubscribe"),params:Gy}),By=ot.extend({uri:T()}),Jy=at.extend({method:C("notifications/resources/updated"),params:By}),Qy=O({name:T(),description:Te(T()),required:Te(me())}),Yy=O({...zr.shape,...jn.shape,description:Te(T()),arguments:Te(F(Qy)),_meta:Te(Le({}))}),rd=Cn.extend({method:C("prompts/list")}),Aa=Nn.extend({prompts:F(Yy)}),Xy=rt.extend({name:T(),arguments:ge(T(),T()).optional()}),ev=Ve.extend({method:C("prompts/get"),params:Xy}),Ma=O({type:C("text"),text:T(),annotations:Vr.optional(),_meta:ge(T(),$e()).optional()}),za=O({type:C("image"),data:ja,mimeType:T(),annotations:Vr.optional(),_meta:ge(T(),$e()).optional()}),Da=O({type:C("audio"),data:ja,mimeType:T(),annotations:Vr.optional(),_meta:ge(T(),$e()).optional()}),tv=O({type:C("tool_use"),name:T(),id:T(),input:ge(T(),$e()),_meta:ge(T(),$e()).optional()}),nd=O({type:C("resource"),resource:pe([Ju,Qu]),annotations:Vr.optional(),_meta:ge(T(),$e()).optional()}),sd=Yu.extend({type:C("resource_link")}),xn=pe([Ma,za,Da,sd,nd]),rv=O({role:On,content:xn}),od=He.extend({description:T().optional(),messages:F(rv)}),qa=at.extend({method:C("notifications/prompts/list_changed"),params:ot.optional()}),nv=O({title:T().optional(),readOnlyHint:me().optional(),destructiveHint:me().optional(),idempotentHint:me().optional(),openWorldHint:me().optional()}),sv=O({taskSupport:tt(["required","optional","forbidden"]).optional()}),Ua=O({...zr.shape,...jn.shape,description:T().optional(),inputSchema:O({type:C("object"),properties:ge(T(),Ae).optional(),required:F(T()).optional()}).catchall($e()),outputSchema:O({type:C("object"),properties:ge(T(),Ae).optional(),required:F(T()).optional()}).catchall($e()).optional(),annotations:nv.optional(),execution:sv.optional(),_meta:ge(T(),$e()).optional()}),ov=Cn.extend({method:C("tools/list")}),Fa=Nn.extend({tools:F(Ua)}),pr=He.extend({content:F(xn).default([]),structuredContent:ge(T(),$e()).optional(),isError:me().optional()});pr.or(He.extend({toolResult:$e()}));const av=Tn.extend({name:T(),arguments:ge(T(),$e()).optional()}),ad=Ve.extend({method:C("tools/call"),params:av}),La=at.extend({method:C("notifications/tools/list_changed"),params:ot.optional()}),iv=O({autoRefresh:me().default(!0),debounceMs:ae().int().nonnegative().default(300)}),id=tt(["debug","info","notice","warning","error","critical","alert","emergency"]),cv=rt.extend({level:id}),lv=Ve.extend({method:C("logging/setLevel"),params:cv}),uv=ot.extend({level:id,logger:T().optional(),data:$e()}),cd=at.extend({method:C("notifications/message"),params:uv}),dv=O({name:T().optional()}),fv=O({hints:F(dv).optional(),costPriority:ae().min(0).max(1).optional(),speedPriority:ae().min(0).max(1).optional(),intelligencePriority:ae().min(0).max(1).optional()}),hv=O({mode:tt(["auto","required","none"]).optional()}),pv=O({type:C("tool_result"),toolUseId:T().describe("The unique identifier for the corresponding tool call."),content:F(xn).default([]),structuredContent:O({}).loose().optional(),isError:me().optional(),_meta:ge(T(),$e()).optional()}),mv=zu("type",[Ma,za,Da]),_s=zu("type",[Ma,za,Da,tv,pv]),gv=O({role:On,content:pe([_s,F(_s)]),_meta:ge(T(),$e()).optional()}),_v=Tn.extend({messages:F(gv),modelPreferences:fv.optional(),systemPrompt:T().optional(),includeContext:tt(["none","thisServer","allServers"]).optional(),temperature:ae().optional(),maxTokens:ae().int(),stopSequences:F(T()).optional(),metadata:Ae.optional(),tools:F(Ua).optional(),toolChoice:hv.optional()}),Va=Ve.extend({method:C("sampling/createMessage"),params:_v}),ld=He.extend({model:T(),stopReason:Te(tt(["endTurn","stopSequence","maxTokens"]).or(T())),role:On,content:mv}),ud=He.extend({model:T(),stopReason:Te(tt(["endTurn","stopSequence","maxTokens","toolUse"]).or(T())),role:On,content:pe([_s,F(_s)])}),yv=O({type:C("boolean"),title:T().optional(),description:T().optional(),default:me().optional()}),vv=O({type:C("string"),title:T().optional(),description:T().optional(),minLength:ae().optional(),maxLength:ae().optional(),format:tt(["email","uri","date","date-time"]).optional(),default:T().optional()}),$v=O({type:tt(["number","integer"]),title:T().optional(),description:T().optional(),minimum:ae().optional(),maximum:ae().optional(),default:ae().optional()}),wv=O({type:C("string"),title:T().optional(),description:T().optional(),enum:F(T()),default:T().optional()}),bv=O({type:C("string"),title:T().optional(),description:T().optional(),oneOf:F(O({const:T(),title:T()})),default:T().optional()}),Sv=O({type:C("string"),title:T().optional(),description:T().optional(),enum:F(T()),enumNames:F(T()).optional(),default:T().optional()}),Ev=pe([wv,bv]),kv=O({type:C("array"),title:T().optional(),description:T().optional(),minItems:ae().optional(),maxItems:ae().optional(),items:O({type:C("string"),enum:F(T())}),default:F(T()).optional()}),Pv=O({type:C("array"),title:T().optional(),description:T().optional(),minItems:ae().optional(),maxItems:ae().optional(),items:O({anyOf:F(O({const:T(),title:T()}))}),default:F(T()).optional()}),Tv=pe([kv,Pv]),Rv=pe([Sv,Ev,Tv]),jv=pe([Rv,yv,vv,$v]),Cv=Tn.extend({mode:C("form").optional(),message:T(),requestedSchema:O({type:C("object"),properties:ge(T(),jv),required:F(T()).optional()})}),Nv=Tn.extend({mode:C("url"),message:T(),elicitationId:T(),url:T().url()}),Iv=pe([Cv,Nv]),dd=Ve.extend({method:C("elicitation/create"),params:Iv}),Ov=ot.extend({elicitationId:T()}),xv=at.extend({method:C("notifications/elicitation/complete"),params:Ov}),fd=He.extend({action:tt(["accept","decline","cancel"]),content:Lu(e=>e===null?void 0:e,ge(T(),pe([T(),ae(),me(),F(T())])).optional())}),Av=O({type:C("ref/resource"),uri:T()}),Mv=O({type:C("ref/prompt"),name:T()}),zv=rt.extend({ref:pe([Mv,Av]),argument:O({name:T(),value:T()}),context:O({arguments:ge(T(),T()).optional()}).optional()}),Dv=Ve.extend({method:C("completion/complete"),params:zv}),hd=He.extend({completion:Le({values:F(T()).max(100),total:Te(ae().int()),hasMore:Te(me())})}),qv=O({uri:T().startsWith("file://"),name:T().optional(),_meta:ge(T(),$e()).optional()}),Uv=Ve.extend({method:C("roots/list"),params:rt.optional()}),Fv=He.extend({roots:F(qv)}),Lv=at.extend({method:C("notifications/roots/list_changed"),params:ot.optional()});pe([Us,xy,Dv,lv,ev,rd,Xu,ed,td,Ky,Wy,ad,ov,Sa,ka,Pa,Ra]);pe([wa,ba,Wu,Lv,gs]);pe([Cr,ld,ud,fd,Fv,Ea,Ta,wn]);pe([Us,Va,dd,Uv,Sa,ka,Pa,Ra]);pe([wa,ba,cd,Jy,xa,La,qa,gs,xv]);pe([Cr,Gu,hd,od,Aa,Ca,Na,Oa,pr,Fa,Ea,Ta,wn]);class X extends Error{constructor(t,r,n){super(`MCP error ${t}: ${r}`),this.code=t,this.data=n,this.name="McpError"}static fromError(t,r,n){if(t===re.UrlElicitationRequired&&n){const s=n;if(s.elicitations)return new Vv(s.elicitations,r)}return new X(t,r,n)}}class Vv extends X{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(re.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){var t;return((t=this.data)==null?void 0:t.elicitations)??[]}}function Ha(e){return!!e._zod}function Ot(e,t){return Ha(e)?yu(e,t):e.safeParse(t)}function pd(e){var r,n;if(!e)return;let t;if(Ha(e)?t=(n=(r=e._zod)==null?void 0:r.def)==null?void 0:n.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function md(e){var s;if(Ha(e)){const a=(s=e._zod)==null?void 0:s.def;if(a){if(a.value!==void 0)return a.value;if(Array.isArray(a.values)&&a.values.length>0)return a.values[0]}}const r=e._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}const n=e.value;if(n!==void 0)return n}function rr(e){return e==="completed"||e==="failed"||e==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Yc(e){const t=pd(e),r=t==null?void 0:t.method;if(!r)throw new Error("Schema is missing a method literal");const n=md(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function Xc(e,t){const r=Ot(e,t);if(!r.success)throw r.error;return r.data}const Hv=6e4;class gd{constructor(t){this._options=t,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(wa,r=>{this._oncancel(r)}),this.setNotificationHandler(ba,r=>{this._onprogress(r)}),this.setRequestHandler(Us,r=>({})),this._taskStore=t==null?void 0:t.taskStore,this._taskMessageQueue=t==null?void 0:t.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Sa,async(r,n)=>{const s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new X(re.InvalidParams,"Failed to retrieve task: Task not found");return{...s}}),this.setRequestHandler(ka,async(r,n)=>{const s=async()=>{var i;const o=r.params.taskId;if(this._taskMessageQueue){let c;for(;c=await this._taskMessageQueue.dequeue(o,n.sessionId);){if(c.type==="response"||c.type==="error"){const l=c.message,d=l.id,f=this._requestResolvers.get(d);if(f)if(this._requestResolvers.delete(d),c.type==="response")f(l);else{const _=l,y=new X(_.error.code,_.error.message,_.error.data);f(y)}else{const _=c.type==="response"?"Response":"Error";this._onerror(new Error(`${_} handler missing for request ${d}`))}continue}await((i=this._transport)==null?void 0:i.send(c.message,{relatedRequestId:n.requestId}))}}const a=await this._taskStore.getTask(o,n.sessionId);if(!a)throw new X(re.InvalidParams,`Task not found: ${o}`);if(!rr(a.status))return await this._waitForTaskUpdate(o,n.signal),await s();if(rr(a.status)){const c=await this._taskStore.getTaskResult(o,n.sessionId);return this._clearTaskQueue(o),{...c,_meta:{...c._meta,[ar]:{taskId:o}}}}return await s()};return await s()}),this.setRequestHandler(Pa,async(r,n)=>{var s;try{const{tasks:o,nextCursor:a}=await this._taskStore.listTasks((s=r.params)==null?void 0:s.cursor,n.sessionId);return{tasks:o,nextCursor:a,_meta:{}}}catch(o){throw new X(re.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(Ra,async(r,n)=>{try{const s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new X(re.InvalidParams,`Task not found: ${r.params.taskId}`);if(rr(s.status))throw new X(re.InvalidParams,`Cannot cancel task in terminal status: ${s.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);const o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new X(re.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...o}}catch(s){throw s instanceof X?s:new X(re.InvalidRequest,`Failed to cancel task: ${s instanceof Error?s.message:String(s)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;const r=this._requestHandlerAbortControllers.get(t.params.requestId);r==null||r.abort(t.params.reason)}_setupTimeout(t,r,n,s,o=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(s,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:o,onTimeout:s})}_resetTimeout(t){const r=this._timeoutInfo.get(t);if(!r)return!1;const n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(t),X.fromError(re.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(t){const r=this._timeoutInfo.get(t);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(t))}async connect(t){var o,a,i;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=t;const r=(o=this.transport)==null?void 0:o.onclose;this._transport.onclose=()=>{r==null||r(),this._onclose()};const n=(a=this.transport)==null?void 0:a.onerror;this._transport.onerror=c=>{n==null||n(c),this._onerror(c)};const s=(i=this._transport)==null?void 0:i.onmessage;this._transport.onmessage=(c,l)=>{s==null||s(c,l),nn(c)||ky(c)?this._onresponse(c):Po(c)?this._onrequest(c,l):Ey(c)?this._onnotification(c):this._onerror(new Error(`Unknown message type: ${JSON.stringify(c)}`))},await this._transport.start()}_onclose(){var n;const t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(const s of this._timeoutInfo.values())clearTimeout(s.timeoutId);this._timeoutInfo.clear();for(const s of this._requestHandlerAbortControllers.values())s.abort();this._requestHandlerAbortControllers.clear();const r=X.fromError(re.ConnectionClosed,"Connection closed");this._transport=void 0,(n=this.onclose)==null||n.call(this);for(const s of t.values())s(r)}_onerror(t){var r;(r=this.onerror)==null||r.call(this,t)}_onnotification(t){const r=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(t)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(t,r){var d,f,_,y;const n=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,s=this._transport,o=(_=(f=(d=t.params)==null?void 0:d._meta)==null?void 0:f[ar])==null?void 0:_.taskId;if(n===void 0){const g={jsonrpc:"2.0",id:t.id,error:{code:re.MethodNotFound,message:"Method not found"}};o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:g,timestamp:Date.now()},s==null?void 0:s.sessionId).catch($=>this._onerror(new Error(`Failed to enqueue error response: ${$}`))):s==null||s.send(g).catch($=>this._onerror(new Error(`Failed to send an error response: ${$}`)));return}const a=new AbortController;this._requestHandlerAbortControllers.set(t.id,a);const i=Sy(t.params)?t.params.task:void 0,c=this._taskStore?this.requestTaskStore(t,s==null?void 0:s.sessionId):void 0,l={signal:a.signal,sessionId:s==null?void 0:s.sessionId,_meta:(y=t.params)==null?void 0:y._meta,sendNotification:async g=>{if(a.signal.aborted)return;const $={relatedRequestId:t.id};o&&($.relatedTask={taskId:o}),await this.notification(g,$)},sendRequest:async(g,$,m)=>{var k;if(a.signal.aborted)throw new X(re.ConnectionClosed,"Request was cancelled");const h={...m,relatedRequestId:t.id};o&&!h.relatedTask&&(h.relatedTask={taskId:o});const v=((k=h.relatedTask)==null?void 0:k.taskId)??o;return v&&c&&await c.updateTaskStatus(v,"input_required"),await this.request(g,$,h)},authInfo:r==null?void 0:r.authInfo,requestId:t.id,requestInfo:r==null?void 0:r.requestInfo,taskId:o,taskStore:c,taskRequestedTtl:i==null?void 0:i.ttl,closeSSEStream:r==null?void 0:r.closeSSEStream,closeStandaloneSSEStream:r==null?void 0:r.closeStandaloneSSEStream};Promise.resolve().then(()=>{i&&this.assertTaskHandlerCapability(t.method)}).then(()=>n(t,l)).then(async g=>{if(a.signal.aborted)return;const $={result:g,jsonrpc:"2.0",id:t.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:$,timestamp:Date.now()},s==null?void 0:s.sessionId):await(s==null?void 0:s.send($))},async g=>{if(a.signal.aborted)return;const $={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(g.code)?g.code:re.InternalError,message:g.message??"Internal error",...g.data!==void 0&&{data:g.data}}};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"error",message:$,timestamp:Date.now()},s==null?void 0:s.sessionId):await(s==null?void 0:s.send($))}).catch(g=>this._onerror(new Error(`Failed to send response: ${g}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===a&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){const{progressToken:r,...n}=t.params,s=Number(r),o=this._progressHandlers.get(s);if(!o){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}const a=this._responseHandlers.get(s),i=this._timeoutInfo.get(s);if(i&&a&&i.resetTimeoutOnProgress)try{this._resetTimeout(s)}catch(c){this._responseHandlers.delete(s),this._progressHandlers.delete(s),this._cleanupTimeout(s),a(c);return}o(n)}_onresponse(t){const r=Number(t.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),nn(t))n(t);else{const a=new X(t.error.code,t.error.message,t.error.data);n(a)}return}const s=this._responseHandlers.get(r);if(s===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let o=!1;if(nn(t)&&t.result&&typeof t.result=="object"){const a=t.result;if(a.task&&typeof a.task=="object"){const i=a.task;typeof i.taskId=="string"&&(o=!0,this._taskProgressTokens.set(i.taskId,r))}}if(o||this._progressHandlers.delete(r),nn(t))s(t);else{const a=X.fromError(t.error.code,t.error.message,t.error.data);s(a)}}get transport(){return this._transport}async close(){var t;await((t=this._transport)==null?void 0:t.close())}async*requestStream(t,r,n){var a,i;const{task:s}=n??{};if(!s){try{yield{type:"result",result:await this.request(t,r,n)}}catch(c){yield{type:"error",error:c instanceof X?c:new X(re.InternalError,String(c))}}return}let o;try{const c=await this.request(t,wn,n);if(c.task)o=c.task.taskId,yield{type:"taskCreated",task:c.task};else throw new X(re.InternalError,"Task creation did not return a task");for(;;){const l=await this.getTask({taskId:o},n);if(yield{type:"taskStatus",task:l},rr(l.status)){l.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},r,n)}:l.status==="failed"?yield{type:"error",error:new X(re.InternalError,`Task ${o} failed`)}:l.status==="cancelled"&&(yield{type:"error",error:new X(re.InternalError,`Task ${o} was cancelled`)});return}if(l.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:o},r,n)};return}const d=l.pollInterval??((a=this._options)==null?void 0:a.defaultTaskPollInterval)??1e3;await new Promise(f=>setTimeout(f,d)),(i=n==null?void 0:n.signal)==null||i.throwIfAborted()}}catch(c){yield{type:"error",error:c instanceof X?c:new X(re.InternalError,String(c))}}}request(t,r,n){const{relatedRequestId:s,resumptionToken:o,onresumptiontoken:a,task:i,relatedTask:c}=n??{};return new Promise((l,d)=>{var v,k,R,E,I;const f=x=>{d(x)};if(!this._transport){f(new Error("Not connected"));return}if(((v=this._options)==null?void 0:v.enforceStrictCapabilities)===!0)try{this.assertCapabilityForMethod(t.method),i&&this.assertTaskCapability(t.method)}catch(x){f(x);return}(k=n==null?void 0:n.signal)==null||k.throwIfAborted();const _=this._requestMessageId++,y={...t,jsonrpc:"2.0",id:_};n!=null&&n.onprogress&&(this._progressHandlers.set(_,n.onprogress),y.params={...t.params,_meta:{...((R=t.params)==null?void 0:R._meta)||{},progressToken:_}}),i&&(y.params={...y.params,task:i}),c&&(y.params={...y.params,_meta:{...((E=y.params)==null?void 0:E._meta)||{},[ar]:c}});const g=x=>{var Z;this._responseHandlers.delete(_),this._progressHandlers.delete(_),this._cleanupTimeout(_),(Z=this._transport)==null||Z.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:_,reason:String(x)}},{relatedRequestId:s,resumptionToken:o,onresumptiontoken:a}).catch(D=>this._onerror(new Error(`Failed to send cancellation: ${D}`)));const q=x instanceof X?x:new X(re.RequestTimeout,String(x));d(q)};this._responseHandlers.set(_,x=>{var q;if(!((q=n==null?void 0:n.signal)!=null&&q.aborted)){if(x instanceof Error)return d(x);try{const Z=Ot(r,x.result);Z.success?l(Z.data):d(Z.error)}catch(Z){d(Z)}}}),(I=n==null?void 0:n.signal)==null||I.addEventListener("abort",()=>{var x;g((x=n==null?void 0:n.signal)==null?void 0:x.reason)});const $=(n==null?void 0:n.timeout)??Hv,m=()=>g(X.fromError(re.RequestTimeout,"Request timed out",{timeout:$}));this._setupTimeout(_,$,n==null?void 0:n.maxTotalTimeout,m,(n==null?void 0:n.resetTimeoutOnProgress)??!1);const h=c==null?void 0:c.taskId;if(h){const x=q=>{const Z=this._responseHandlers.get(_);Z?Z(q):this._onerror(new Error(`Response handler missing for side-channeled request ${_}`))};this._requestResolvers.set(_,x),this._enqueueTaskMessage(h,{type:"request",message:y,timestamp:Date.now()}).catch(q=>{this._cleanupTimeout(_),d(q)})}else this._transport.send(y,{relatedRequestId:s,resumptionToken:o,onresumptiontoken:a}).catch(x=>{this._cleanupTimeout(_),d(x)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},Ea,r)}async getTaskResult(t,r,n){return this.request({method:"tasks/result",params:t},r,n)}async listTasks(t,r){return this.request({method:"tasks/list",params:t},Ta,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},Ly,r)}async notification(t,r){var i,c,l,d;if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);const n=(i=r==null?void 0:r.relatedTask)==null?void 0:i.taskId;if(n){const f={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...((c=t.params)==null?void 0:c._meta)||{},[ar]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:f,timestamp:Date.now()});return}if((((l=this._options)==null?void 0:l.debouncedNotificationMethods)??[]).includes(t.method)&&!t.params&&!(r!=null&&r.relatedRequestId)&&!(r!=null&&r.relatedTask)){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{var _,y;if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let f={...t,jsonrpc:"2.0"};r!=null&&r.relatedTask&&(f={...f,params:{...f.params,_meta:{...((_=f.params)==null?void 0:_._meta)||{},[ar]:r.relatedTask}}}),(y=this._transport)==null||y.send(f,r).catch(g=>this._onerror(g))});return}let a={...t,jsonrpc:"2.0"};r!=null&&r.relatedTask&&(a={...a,params:{...a.params,_meta:{...((d=a.params)==null?void 0:d._meta)||{},[ar]:r.relatedTask}}}),await this._transport.send(a,r)}setRequestHandler(t,r){const n=Yc(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(s,o)=>{const a=Xc(t,s);return Promise.resolve(r(a,o))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,r){const n=Yc(t);this._notificationHandlers.set(n,s=>{const o=Xc(t,s);return Promise.resolve(r(o))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){const r=this._taskProgressTokens.get(t);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,r,n){var o;if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const s=(o=this._options)==null?void 0:o.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,r,n,s)}async _clearTaskQueue(t,r){if(this._taskMessageQueue){const n=await this._taskMessageQueue.dequeueAll(t,r);for(const s of n)if(s.type==="request"&&Po(s.message)){const o=s.message.id,a=this._requestResolvers.get(o);a?(a(new X(re.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(o)):this._onerror(new Error(`Resolver missing for request ${o} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,r){var s,o;let n=((s=this._options)==null?void 0:s.defaultTaskPollInterval)??1e3;try{const a=await((o=this._taskStore)==null?void 0:o.getTask(t));a!=null&&a.pollInterval&&(n=a.pollInterval)}catch{}return new Promise((a,i)=>{if(r.aborted){i(new X(re.InvalidRequest,"Request cancelled"));return}const c=setTimeout(a,n);r.addEventListener("abort",()=>{clearTimeout(c),i(new X(re.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,r){const n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async s=>{if(!t)throw new Error("No request provided");return await n.createTask(s,t.id,{method:t.method,params:t.params},r)},getTask:async s=>{const o=await n.getTask(s,r);if(!o)throw new X(re.InvalidParams,"Failed to retrieve task: Task not found");return o},storeTaskResult:async(s,o,a)=>{await n.storeTaskResult(s,o,a,r);const i=await n.getTask(s,r);if(i){const c=gs.parse({method:"notifications/tasks/status",params:i});await this.notification(c),rr(i.status)&&this._cleanupTaskProgressHandler(s)}},getTaskResult:s=>n.getTaskResult(s,r),updateTaskStatus:async(s,o,a)=>{const i=await n.getTask(s,r);if(!i)throw new X(re.InvalidParams,`Task "${s}" not found - it may have been cleaned up`);if(rr(i.status))throw new X(re.InvalidParams,`Cannot update task "${s}" from terminal status "${i.status}" to "${o}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(s,o,a,r);const c=await n.getTask(s,r);if(c){const l=gs.parse({method:"notifications/tasks/status",params:c});await this.notification(l),rr(c.status)&&this._cleanupTaskProgressHandler(s)}},listTasks:s=>n.listTasks(s,r)}}}function el(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Zv(e,t){const r={...e};for(const n in t){const s=n,o=t[s];if(o===void 0)continue;const a=r[s];el(a)&&el(o)?r[s]={...a,...o}:r[s]=o}return r}(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});class Kv extends gd{constructor(){super(...arguments);ne(this,"_registeredMethods",new Set);ne(this,"_eventSlots",new Map);ne(this,"setRequestHandler",(r,n)=>{this._assertMethodNotRegistered(r,"setRequestHandler"),super.setRequestHandler(r,n)});ne(this,"setNotificationHandler",(r,n)=>{this._assertMethodNotRegistered(r,"setNotificationHandler"),super.setNotificationHandler(r,n)});ne(this,"replaceRequestHandler",(r,n)=>{let s=r.shape.method.value;this._registeredMethods.add(s),super.setRequestHandler(r,n)})}onEventDispatch(r,n){}_ensureEventSlot(r){let n=this._eventSlots.get(r);if(!n){let s=this.eventSchemas[r];if(!s)throw Error(`Unknown event: ${String(r)}`);n={listeners:[]},this._eventSlots.set(r,n);let o=s.shape.method.value;this._registeredMethods.add(o);let a=n;super.setNotificationHandler(s,i=>{var l;let c=i.params;this.onEventDispatch(r,c),(l=a.onHandler)==null||l.call(a,c);for(let d of[...a.listeners])d(c)})}return n}setEventHandler(r,n){let s=this._ensureEventSlot(r);s.onHandler&&n&&console.warn(`[MCP Apps] on${String(r)} handler replaced. Use addEventListener("${String(r)}", …) to add multiple listeners without replacing.`),s.onHandler=n}getEventHandler(r){var n;return(n=this._eventSlots.get(r))==null?void 0:n.onHandler}addEventListener(r,n){this._ensureEventSlot(r).listeners.push(n)}removeEventListener(r,n){let s=this._eventSlots.get(r);if(!s)return;let o=s.listeners.indexOf(n);o!==-1&&s.listeners.splice(o,1)}warnIfRequestHandlerReplaced(r,n,s){n&&s&&console.warn(`[MCP Apps] ${r} handler replaced. Previous handler will no longer be called.`)}_assertMethodNotRegistered(r,n){let s=r.shape.method.value;if(this._registeredMethods.has(s))throw Error(`Handler for "${s}" already registered (via ${n}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);this._registeredMethods.add(s)}}var _d="2026-01-26",Gv="ui/notifications/tool-input-partial",Wv=pe([C("light"),C("dark")]).describe("Color theme preference for the host environment."),bn=pe([C("inline"),C("fullscreen"),C("pip")]).describe("Display mode for UI presentation."),Bv=pe([C("--color-background-primary"),C("--color-background-secondary"),C("--color-background-tertiary"),C("--color-background-inverse"),C("--color-background-ghost"),C("--color-background-info"),C("--color-background-danger"),C("--color-background-success"),C("--color-background-warning"),C("--color-background-disabled"),C("--color-text-primary"),C("--color-text-secondary"),C("--color-text-tertiary"),C("--color-text-inverse"),C("--color-text-ghost"),C("--color-text-info"),C("--color-text-danger"),C("--color-text-success"),C("--color-text-warning"),C("--color-text-disabled"),C("--color-border-primary"),C("--color-border-secondary"),C("--color-border-tertiary"),C("--color-border-inverse"),C("--color-border-ghost"),C("--color-border-info"),C("--color-border-danger"),C("--color-border-success"),C("--color-border-warning"),C("--color-border-disabled"),C("--color-ring-primary"),C("--color-ring-secondary"),C("--color-ring-inverse"),C("--color-ring-info"),C("--color-ring-danger"),C("--color-ring-success"),C("--color-ring-warning"),C("--font-sans"),C("--font-mono"),C("--font-weight-normal"),C("--font-weight-medium"),C("--font-weight-semibold"),C("--font-weight-bold"),C("--font-text-xs-size"),C("--font-text-sm-size"),C("--font-text-md-size"),C("--font-text-lg-size"),C("--font-heading-xs-size"),C("--font-heading-sm-size"),C("--font-heading-md-size"),C("--font-heading-lg-size"),C("--font-heading-xl-size"),C("--font-heading-2xl-size"),C("--font-heading-3xl-size"),C("--font-text-xs-line-height"),C("--font-text-sm-line-height"),C("--font-text-md-line-height"),C("--font-text-lg-line-height"),C("--font-heading-xs-line-height"),C("--font-heading-sm-line-height"),C("--font-heading-md-line-height"),C("--font-heading-lg-line-height"),C("--font-heading-xl-line-height"),C("--font-heading-2xl-line-height"),C("--font-heading-3xl-line-height"),C("--border-radius-xs"),C("--border-radius-sm"),C("--border-radius-md"),C("--border-radius-lg"),C("--border-radius-xl"),C("--border-radius-full"),C("--border-width-regular"),C("--shadow-hairline"),C("--shadow-sm"),C("--shadow-md"),C("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),Jv=ge(Bv.describe(`Style variables for theming MCP apps. + +Individual style keys are optional - hosts may provide any subset of these values. +Values are strings containing CSS values (colors, sizes, font stacks, etc.). + +Note: This type uses \`Record\` rather than \`Partial>\` +for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),pe([T(),bo()]).describe(`Style variables for theming MCP apps. + +Individual style keys are optional - hosts may provide any subset of these values. +Values are strings containing CSS values (colors, sizes, font stacks, etc.). + +Note: This type uses \`Record\` rather than \`Partial>\` +for compatibility with Zod schema generation. Both are functionally equivalent for validation.`)).describe(`Style variables for theming MCP apps. + +Individual style keys are optional - hosts may provide any subset of these values. +Values are strings containing CSS values (colors, sizes, font stacks, etc.). + +Note: This type uses \`Record\` rather than \`Partial>\` +for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),Qv=O({method:C("ui/open-link"),params:O({url:T().describe("URL to open in the host's browser")})});O({isError:me().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough();O({isError:me().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough();O({isError:me().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough();var Yv=O({method:C("ui/notifications/sandbox-proxy-ready"),params:O({})}),Za=O({connectDomains:F(T()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket). + +- Maps to CSP \`connect-src\` directive +- Empty or omitted → no network connections (secure default)`),resourceDomains:F(T()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"),frameDomains:F(T()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:F(T()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)")}),Ka=O({camera:O({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:O({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:O({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:O({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")}),Xv=O({method:C("ui/notifications/size-changed"),params:O({width:ae().optional().describe("New width in pixels."),height:ae().optional().describe("New height in pixels.")})});O({method:C("ui/notifications/tool-input"),params:O({arguments:ge(T(),$e().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})});O({method:C("ui/notifications/tool-input-partial"),params:O({arguments:ge(T(),$e().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})});O({method:C("ui/notifications/tool-cancelled"),params:O({reason:T().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})});var e$=O({fonts:T().optional()}),t$=O({variables:Jv.optional().describe("CSS variables for theming the app."),css:e$.optional().describe("CSS blocks that apps can inject.")});O({method:C("ui/resource-teardown"),params:O({})});var r$=ge(T(),$e()),tl=O({text:O({}).optional().describe("Host supports text content blocks."),image:O({}).optional().describe("Host supports image content blocks."),audio:O({}).optional().describe("Host supports audio content blocks."),resource:O({}).optional().describe("Host supports resource content blocks."),resourceLink:O({}).optional().describe("Host supports resource link content blocks."),structuredContent:O({}).optional().describe("Host supports structured content.")}),n$=O({method:C("ui/notifications/request-teardown"),params:O({}).optional()}),s$=O({experimental:ge(T(),ge(T(),ga()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),openLinks:O({}).optional().describe("Host supports opening external URLs."),downloadFile:O({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:O({listChanged:me().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:O({listChanged:me().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:O({}).optional().describe("Host accepts log messages."),sandbox:O({permissions:Ka.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:Za.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:tl.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:tl.optional().describe("Host supports receiving content messages (ui/message) from the view."),sampling:O({tools:O({}).optional().describe("Host supports tool use via `tools` and `toolChoice` parameters.")}).optional().describe("Host supports LLM sampling (sampling/createMessage) from the view.\nMirrors the MCP `ClientCapabilities.sampling` shape so hosts can pass it through.")}),o$=O({experimental:ge(T(),ge(T(),ga()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),tools:O({listChanged:me().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:F(bn).optional().describe("Display modes the app supports.")}),a$=O({method:C("ui/notifications/initialized"),params:O({}).optional()});O({csp:Za.optional().describe("Content Security Policy configuration for UI resources."),permissions:Ka.optional().describe("Sandbox permissions requested by the UI resource."),domain:T().optional().describe(`Dedicated origin for view sandbox. + +Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists. + +**Host-dependent:** The format and validation rules for this field are determined by each host. Servers MUST consult host-specific documentation for the expected domain format. Common patterns include: +- Hash-based subdomains (e.g., \`{hash}.claudemcpcontent.com\`) +- URL-derived subdomains (e.g., \`www-example-com.oaiusercontent.com\`) + +If omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:me().optional().describe(`Visual boundary preference - true if view prefers a visible border. + +Boolean requesting whether a visible border and background is provided by the host. Specifying an explicit value for this is recommended because hosts' defaults may vary. + +- \`true\`: request visible border + background +- \`false\`: request no visible border + background +- omitted: host decides border`)});var rl=O({method:C("ui/request-display-mode"),params:O({mode:bn.describe("The display mode being requested.")})});O({mode:bn.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough();var i$=pe([C("model"),C("app")]).describe("Tool visibility scope - who can access the tool.");O({resourceUri:T().optional(),visibility:F(i$).optional().describe(`Who can access this tool. Default: ["model", "app"] +- "model": Tool visible to and callable by the agent +- "app": Tool callable by the app from this server only`),csp:So().optional(),permissions:So().optional()});O({mimeTypes:F(T()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});var c$=O({method:C("ui/download-file"),params:O({contents:F(pe([nd,sd])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),l$=O({method:C("ui/message"),params:O({role:C("user").describe('Message role, currently only "user" is supported.'),content:F(xn).describe("Message content blocks (text, image, etc.).")})});O({method:C("ui/notifications/sandbox-resource-ready"),params:O({html:T().describe("HTML content to load into the inner iframe."),sandbox:T().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:Za.optional().describe("CSP configuration from resource metadata."),permissions:Ka.optional().describe("Sandbox permissions from resource metadata.")})});O({method:C("ui/notifications/tool-result"),params:pr.describe("Standard MCP tool execution result.")});var yd=O({toolInfo:O({id:Rn.optional().describe("JSON-RPC id of the tools/call request."),tool:Ua.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:Wv.optional().describe("Current color theme preference."),styles:t$.optional().describe("Style configuration for theming the app."),displayMode:bn.optional().describe("How the UI is currently displayed."),availableDisplayModes:F(bn).optional().describe("Display modes the host supports."),containerDimensions:pe([O({height:ae().describe("Fixed container height in pixels.")}),O({maxHeight:pe([ae(),bo()]).optional().describe("Maximum container height in pixels.")})]).and(pe([O({width:ae().describe("Fixed container width in pixels.")}),O({maxWidth:pe([ae(),bo()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other +container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:T().optional().describe("User's language and region preference in BCP 47 format."),timeZone:T().optional().describe("User's timezone in IANA format."),userAgent:T().optional().describe("Host application identifier."),platform:pe([C("web"),C("desktop"),C("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:O({touch:me().optional().describe("Whether the device supports touch input."),hover:me().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:O({top:ae().describe("Top safe area inset in pixels."),right:ae().describe("Right safe area inset in pixels."),bottom:ae().describe("Bottom safe area inset in pixels."),left:ae().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough();O({method:C("ui/notifications/host-context-changed"),params:yd.describe("Partial context update containing only changed fields.")});var u$=O({method:C("ui/update-model-context"),params:O({content:F(xn).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:ge(T(),$e().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),d$=O({method:C("ui/initialize"),params:O({appInfo:qs.describe("App identification (name and version)."),appCapabilities:o$.describe("Features and capabilities this app provides."),protocolVersion:T().describe("Protocol version this app supports.")})});O({protocolVersion:T().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:qs.describe("Host application identification and version."),hostCapabilities:s$.describe("Features and capabilities provided by the host."),hostContext:yd.describe("Rich context about the host environment.")}).passthrough();class f${constructor(t=window.parent,r){ne(this,"eventTarget");ne(this,"eventSource");ne(this,"messageListener");ne(this,"onclose");ne(this,"onerror");ne(this,"onmessage");ne(this,"sessionId");ne(this,"setProtocolVersion");this.eventTarget=t,this.eventSource=r,this.messageListener=n=>{var o,a,i;if(r&&n.source!==this.eventSource){console.debug("Ignoring message from unknown source",n);return}let s=rs.safeParse(n.data);s.success?(console.debug("Parsed message",s.data),(o=this.onmessage)==null||o.call(this,s.data)):((a=n.data)==null?void 0:a.jsonrpc)!=="2.0"?console.debug("Ignoring non-JSON-RPC message",s.error.message,n):(console.error("Failed to parse message",s.error.message,n),(i=this.onerror)==null||i.call(this,Error("Invalid JSON-RPC message received: "+s.error.message)))}}async start(){window.addEventListener("message",this.messageListener)}async send(t,r){t.method!==Gv&&console.debug("Sending message",t),this.eventTarget.postMessage(t,"*")}async close(){var t;window.removeEventListener("message",this.messageListener),(t=this.onclose)==null||t.call(this)}}var h$=[_d];class p$ extends Kv{constructor(r,n,s,o){super(o);ne(this,"_client");ne(this,"_hostInfo");ne(this,"_capabilities");ne(this,"_appCapabilities");ne(this,"_hostContext",{});ne(this,"_appInfo");ne(this,"_initializedReceived",!1);ne(this,"_baseReplaceRequestHandler",this.replaceRequestHandler);ne(this,"replaceRequestHandler",(r,n)=>{this._baseReplaceRequestHandler(r,(s,o)=>(this._initializedReceived||console.warn(`[ext-apps] AppBridge received '${s.method}' before ui/notifications/initialized. The View is calling host methods before completing the handshake; it should await app.connect() first.`),n(s,o)))});ne(this,"eventSchemas",{sizechange:Xv,sandboxready:Yv,initialized:a$,requestteardown:n$,loggingmessage:cd});ne(this,"onping");ne(this,"_onmessage");ne(this,"_onopenlink");ne(this,"_ondownloadfile");ne(this,"_onrequestdisplaymode");ne(this,"_onupdatemodelcontext");ne(this,"_oncalltool");ne(this,"_onlistresources");ne(this,"_onlistresourcetemplates");ne(this,"_onreadresource");ne(this,"_onlistprompts");ne(this,"sendResourceTeardown",this.teardownResource);this._client=r,this._hostInfo=n,this._capabilities=s,this.addEventListener("initialized",()=>{this._initializedReceived=!0}),this._hostContext=(o==null?void 0:o.hostContext)||{},this.setRequestHandler(d$,a=>this._oninitialize(a)),this.setRequestHandler(Us,(a,i)=>{var c;return(c=this.onping)==null||c.call(this,a.params,i),{}}),this.replaceRequestHandler(rl,a=>({mode:this._hostContext.displayMode??"inline"}))}getAppCapabilities(){return this._appCapabilities}getAppVersion(){return this._appInfo}get onsizechange(){return this.getEventHandler("sizechange")}set onsizechange(r){this.setEventHandler("sizechange",r)}get onsandboxready(){return this.getEventHandler("sandboxready")}set onsandboxready(r){this.setEventHandler("sandboxready",r)}get oninitialized(){return this.getEventHandler("initialized")}set oninitialized(r){this.setEventHandler("initialized",r)}get onmessage(){return this._onmessage}set onmessage(r){this.warnIfRequestHandlerReplaced("onmessage",this._onmessage,r),this._onmessage=r,this.replaceRequestHandler(l$,async(n,s)=>{if(!this._onmessage)throw Error("No onmessage handler set");return this._onmessage(n.params,s)})}get onopenlink(){return this._onopenlink}set onopenlink(r){this.warnIfRequestHandlerReplaced("onopenlink",this._onopenlink,r),this._onopenlink=r,this.replaceRequestHandler(Qv,async(n,s)=>{if(!this._onopenlink)throw Error("No onopenlink handler set");return this._onopenlink(n.params,s)})}get ondownloadfile(){return this._ondownloadfile}set ondownloadfile(r){this.warnIfRequestHandlerReplaced("ondownloadfile",this._ondownloadfile,r),this._ondownloadfile=r,this.replaceRequestHandler(c$,async(n,s)=>{if(!this._ondownloadfile)throw Error("No ondownloadfile handler set");return this._ondownloadfile(n.params,s)})}get onrequestteardown(){return this.getEventHandler("requestteardown")}set onrequestteardown(r){this.setEventHandler("requestteardown",r)}get onrequestdisplaymode(){return this._onrequestdisplaymode}set onrequestdisplaymode(r){this.warnIfRequestHandlerReplaced("onrequestdisplaymode",this._onrequestdisplaymode,r),this._onrequestdisplaymode=r,this.replaceRequestHandler(rl,async(n,s)=>{if(!this._onrequestdisplaymode)throw Error("No onrequestdisplaymode handler set");return this._onrequestdisplaymode(n.params,s)})}get onloggingmessage(){return this.getEventHandler("loggingmessage")}set onloggingmessage(r){this.setEventHandler("loggingmessage",r)}get onupdatemodelcontext(){return this._onupdatemodelcontext}set onupdatemodelcontext(r){this.warnIfRequestHandlerReplaced("onupdatemodelcontext",this._onupdatemodelcontext,r),this._onupdatemodelcontext=r,this.replaceRequestHandler(u$,async(n,s)=>{if(!this._onupdatemodelcontext)throw Error("No onupdatemodelcontext handler set");return this._onupdatemodelcontext(n.params,s)})}get oncalltool(){return this._oncalltool}set oncalltool(r){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,r),this._oncalltool=r,this.replaceRequestHandler(ad,async(n,s)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(n.params,s)})}set oncreatesamplingmessage(r){this.setRequestHandler(Va,async(n,s)=>r(n.params,s))}sendToolListChanged(r={}){return this.notification({method:"notifications/tools/list_changed",params:r})}get onlistresources(){return this._onlistresources}set onlistresources(r){this.warnIfRequestHandlerReplaced("onlistresources",this._onlistresources,r),this._onlistresources=r,this.replaceRequestHandler(Xu,async(n,s)=>{if(!this._onlistresources)throw Error("No onlistresources handler set");return this._onlistresources(n.params,s)})}get onlistresourcetemplates(){return this._onlistresourcetemplates}set onlistresourcetemplates(r){this.warnIfRequestHandlerReplaced("onlistresourcetemplates",this._onlistresourcetemplates,r),this._onlistresourcetemplates=r,this.replaceRequestHandler(ed,async(n,s)=>{if(!this._onlistresourcetemplates)throw Error("No onlistresourcetemplates handler set");return this._onlistresourcetemplates(n.params,s)})}get onreadresource(){return this._onreadresource}set onreadresource(r){this.warnIfRequestHandlerReplaced("onreadresource",this._onreadresource,r),this._onreadresource=r,this.replaceRequestHandler(td,async(n,s)=>{if(!this._onreadresource)throw Error("No onreadresource handler set");return this._onreadresource(n.params,s)})}sendResourceListChanged(r={}){return this.notification({method:"notifications/resources/list_changed",params:r})}get onlistprompts(){return this._onlistprompts}set onlistprompts(r){this.warnIfRequestHandlerReplaced("onlistprompts",this._onlistprompts,r),this._onlistprompts=r,this.replaceRequestHandler(rd,async(n,s)=>{if(!this._onlistprompts)throw Error("No onlistprompts handler set");return this._onlistprompts(n.params,s)})}sendPromptListChanged(r={}){return this.notification({method:"notifications/prompts/list_changed",params:r})}assertCapabilityForMethod(r){}assertRequestHandlerCapability(r){}assertNotificationCapability(r){}assertTaskCapability(r){throw Error("Tasks are not supported in MCP Apps")}assertTaskHandlerCapability(r){throw Error("Task handlers are not supported in MCP Apps")}getCapabilities(){return this._capabilities}async _oninitialize(r){let n=r.params.protocolVersion;return this._appInfo!==void 0&&console.warn("[ext-apps] AppBridge received a second ui/initialize. The View may be double-mounting (e.g. React StrictMode in dev) without closing the previous App instance. Responding normally; the latest appInfo/appCapabilities replace the previous values."),this._appCapabilities=r.params.appCapabilities,this._appInfo=r.params.appInfo,{protocolVersion:h$.includes(n)?n:_d,hostCapabilities:this.getCapabilities(),hostInfo:this._hostInfo,hostContext:this._hostContext}}setHostContext(r){let n={},s=!1;for(let o of Object.keys(r)){let a=this._hostContext[o],i=r[o];m$(a,i)||(n[o]=i,s=!0)}s&&(this._hostContext=r,this.sendHostContextChange(n))}sendHostContextChange(r){return this.notification({method:"ui/notifications/host-context-changed",params:r})}sendToolInput(r){return this.notification({method:"ui/notifications/tool-input",params:r})}sendToolInputPartial(r){return this.notification({method:"ui/notifications/tool-input-partial",params:r})}sendToolResult(r){return this.notification({method:"ui/notifications/tool-result",params:r})}sendToolCancelled(r){return this.notification({method:"ui/notifications/tool-cancelled",params:r})}sendSandboxResourceReady(r){return this.notification({method:"ui/notifications/sandbox-resource-ready",params:r})}teardownResource(r,n){return this.request({method:"ui/resource-teardown",params:r},r$,n)}callTool(r,n){return this.request({method:"tools/call",params:r},pr,n)}listTools(r,n){return this.request({method:"tools/list",params:r},Fa,n)}async connect(r){if(this.transport)throw Error("AppBridge is already connected. Call close() before connecting again.");if(this._initializedReceived=!1,this._client){let n=this._client.getServerCapabilities();if(!n)throw Error("Client server capabilities not available");n.tools&&(this.oncalltool=async(s,o)=>this._client.request({method:"tools/call",params:s},pr,{signal:o.signal}),n.tools.listChanged&&this._client.setNotificationHandler(La,s=>this.sendToolListChanged(s.params))),n.resources&&(this.onlistresources=async(s,o)=>this._client.request({method:"resources/list",params:s},Ca,{signal:o.signal}),this.onlistresourcetemplates=async(s,o)=>this._client.request({method:"resources/templates/list",params:s},Na,{signal:o.signal}),this.onreadresource=async(s,o)=>this._client.request({method:"resources/read",params:s},Oa,{signal:o.signal}),n.resources.listChanged&&this._client.setNotificationHandler(xa,s=>this.sendResourceListChanged(s.params))),n.prompts&&(this.onlistprompts=async(s,o)=>this._client.request({method:"prompts/list",params:s},Aa,{signal:o.signal}),n.prompts.listChanged&&this._client.setNotificationHandler(qa,s=>this.sendPromptListChanged(s.params)))}return super.connect(r)}}function m$(e,t){return JSON.stringify(e)===JSON.stringify(t)}const g$={x:0,y:0,width:1024,height:768},To=28,_$=12,y$=.9;function xt(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function vd(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return e}function Ro(e){if(Array.isArray(e))return e.map(Ro);const t=vd(e);return t?Object.fromEntries(Object.entries(t).map(([r,n])=>[r,(r==="text"||r==="originalText")&&typeof n=="string"?n.replace(/\\r\\n|\\n|\\r/gu,` +`):Ro(n)])):e}function v$(e){return e.type==="text"&&typeof(e.text??e.originalText)=="string"}function $d(e){const t=String(e.text??e.originalText??""),r=xt(e.fontSize)??20,n=t.length*r*y$,s=xt(e.width);return Math.max(s&&s>0?s:0,n)}function $$(e){for(const t of e){if(t.type!=="cameraUpdate")continue;const r=xt(t.width),n=xt(t.height);if(!(!r||r<=0||!n||n<=0))return{x:xt(t.x)??0,y:xt(t.y)??0,width:r,height:n}}return g$}function w$(e,t){const r=xt(e.x);if(r===void 0)return!1;const n=$d(e),s=t.x+To,o=t.x+t.width-To;return ro+1}function b$(e,t){const r={...e},n=xt(r.fontSize)??20;let s=$d(r);const o=Math.max(1,t.width-To*2);if(s>o){const a=o/s;r.fontSize=Math.max(_$,n*a),typeof r.height=="number"&&(r.height*=Number(r.fontSize)/n),s=Math.min(o,s*(Number(r.fontSize)/n))}return r.width=s,r.autoResize=!1,r.textAlign="left",r.x=t.x+(t.width-s)/2,r}function S$(e){const r=Ro(e).map(vd);if(r.some(o=>o===void 0))return e;const n=r,s=$$(n);return n.map(o=>!v$(o)||!w$(o,s)?o:b$(o,s))}var jo={exports:{}},wd={},gt={},Dr={},An={},fe={},Sn={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;class t{}e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class r extends t{constructor(v){if(super(),!e.IDENTIFIER.test(v))throw new Error("CodeGen: name must be a valid identifier");this.str=v}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}e.Name=r;class n extends t{constructor(v){super(),this._items=typeof v=="string"?[v]:v}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const v=this._items[0];return v===""||v==='""'}get str(){var v;return(v=this._str)!==null&&v!==void 0?v:this._str=this._items.reduce((k,R)=>`${k}${R}`,"")}get names(){var v;return(v=this._names)!==null&&v!==void 0?v:this._names=this._items.reduce((k,R)=>(R instanceof r&&(k[R.str]=(k[R.str]||0)+1),k),{})}}e._Code=n,e.nil=new n("");function s(h,...v){const k=[h[0]];let R=0;for(;R{if(f.scopePath===void 0)throw new Error(`CodeGen: name "${f}" has no value`);return(0,t._)`${l}${f.scopePath}`})}scopeCode(l=this._values,d,f){return this._reduceValues(l,_=>{if(_.value===void 0)throw new Error(`CodeGen: name "${_}" has no value`);return _.value.code},d,f)}_reduceValues(l,d,f={},_){let y=t.nil;for(const g in l){const $=l[g];if(!$)continue;const m=f[g]=f[g]||new Map;$.forEach(h=>{if(m.has(h))return;m.set(h,n.Started);let v=d(h);if(v){const k=this.opts.es5?e.varKinds.var:e.varKinds.const;y=(0,t._)`${y}${k} ${h} = ${v};${this.opts._n}`}else if(v=_==null?void 0:_(h))y=(0,t._)`${y}${v}${this.opts._n}`;else throw new r(h);m.set(h,n.Completed)})}return y}}e.ValueScope=i})(Co);(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;const t=Sn,r=Co;var n=Sn;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return n.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return n.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return n.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return n.Name}});var s=Co;Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return s.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return s.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return s.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return s.varKinds}}),e.operators={GT:new t._Code(">"),GTE:new t._Code(">="),LT:new t._Code("<"),LTE:new t._Code("<="),EQ:new t._Code("==="),NEQ:new t._Code("!=="),NOT:new t._Code("!"),OR:new t._Code("||"),AND:new t._Code("&&"),ADD:new t._Code("+")};class o{optimizeNodes(){return this}optimizeNames(u,p){return this}}class a extends o{constructor(u,p,P){super(),this.varKind=u,this.name=p,this.rhs=P}render({es5:u,_n:p}){const P=u?r.varKinds.var:this.varKind,M=this.rhs===void 0?"":` = ${this.rhs}`;return`${P} ${this.name}${M};`+p}optimizeNames(u,p){if(u[this.name.str])return this.rhs&&(this.rhs=U(this.rhs,u,p)),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}}class i extends o{constructor(u,p,P){super(),this.lhs=u,this.rhs=p,this.sideEffects=P}render({_n:u}){return`${this.lhs} = ${this.rhs};`+u}optimizeNames(u,p){if(!(this.lhs instanceof t.Name&&!u[this.lhs.str]&&!this.sideEffects))return this.rhs=U(this.rhs,u,p),this}get names(){const u=this.lhs instanceof t.Name?{}:{...this.lhs.names};return ce(u,this.rhs)}}class c extends i{constructor(u,p,P,M){super(u,P,M),this.op=p}render({_n:u}){return`${this.lhs} ${this.op}= ${this.rhs};`+u}}class l extends o{constructor(u){super(),this.label=u,this.names={}}render({_n:u}){return`${this.label}:`+u}}class d extends o{constructor(u){super(),this.label=u,this.names={}}render({_n:u}){return`break${this.label?` ${this.label}`:""};`+u}}class f extends o{constructor(u){super(),this.error=u}render({_n:u}){return`throw ${this.error};`+u}get names(){return this.error.names}}class _ extends o{constructor(u){super(),this.code=u}render({_n:u}){return`${this.code};`+u}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(u,p){return this.code=U(this.code,u,p),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}}class y extends o{constructor(u=[]){super(),this.nodes=u}render(u){return this.nodes.reduce((p,P)=>p+P.render(u),"")}optimizeNodes(){const{nodes:u}=this;let p=u.length;for(;p--;){const P=u[p].optimizeNodes();Array.isArray(P)?u.splice(p,1,...P):P?u[p]=P:u.splice(p,1)}return u.length>0?this:void 0}optimizeNames(u,p){const{nodes:P}=this;let M=P.length;for(;M--;){const z=P[M];z.optimizeNames(u,p)||(le(u,z.names),P.splice(M,1))}return P.length>0?this:void 0}get names(){return this.nodes.reduce((u,p)=>B(u,p.names),{})}}class g extends y{render(u){return"{"+u._n+super.render(u)+"}"+u._n}}class $ extends y{}class m extends g{}m.kind="else";class h extends g{constructor(u,p){super(p),this.condition=u}render(u){let p=`if(${this.condition})`+super.render(u);return this.else&&(p+="else "+this.else.render(u)),p}optimizeNodes(){super.optimizeNodes();const u=this.condition;if(u===!0)return this.nodes;let p=this.else;if(p){const P=p.optimizeNodes();p=this.else=Array.isArray(P)?new m(P):P}if(p)return u===!1?p instanceof h?p:p.nodes:this.nodes.length?this:new h(je(u),p instanceof h?[p]:p.nodes);if(!(u===!1||!this.nodes.length))return this}optimizeNames(u,p){var P;if(this.else=(P=this.else)===null||P===void 0?void 0:P.optimizeNames(u,p),!!(super.optimizeNames(u,p)||this.else))return this.condition=U(this.condition,u,p),this}get names(){const u=super.names;return ce(u,this.condition),this.else&&B(u,this.else.names),u}}h.kind="if";class v extends g{}v.kind="for";class k extends v{constructor(u){super(),this.iteration=u}render(u){return`for(${this.iteration})`+super.render(u)}optimizeNames(u,p){if(super.optimizeNames(u,p))return this.iteration=U(this.iteration,u,p),this}get names(){return B(super.names,this.iteration.names)}}class R extends v{constructor(u,p,P,M){super(),this.varKind=u,this.name=p,this.from=P,this.to=M}render(u){const p=u.es5?r.varKinds.var:this.varKind,{name:P,from:M,to:z}=this;return`for(${p} ${P}=${M}; ${P}<${z}; ${P}++)`+super.render(u)}get names(){const u=ce(super.names,this.from);return ce(u,this.to)}}class E extends v{constructor(u,p,P,M){super(),this.loop=u,this.varKind=p,this.name=P,this.iterable=M}render(u){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(u)}optimizeNames(u,p){if(super.optimizeNames(u,p))return this.iterable=U(this.iterable,u,p),this}get names(){return B(super.names,this.iterable.names)}}class I extends g{constructor(u,p,P){super(),this.name=u,this.args=p,this.async=P}render(u){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(u)}}I.kind="func";class x extends y{render(u){return"return "+super.render(u)}}x.kind="return";class q extends g{render(u){let p="try"+super.render(u);return this.catch&&(p+=this.catch.render(u)),this.finally&&(p+=this.finally.render(u)),p}optimizeNodes(){var u,p;return super.optimizeNodes(),(u=this.catch)===null||u===void 0||u.optimizeNodes(),(p=this.finally)===null||p===void 0||p.optimizeNodes(),this}optimizeNames(u,p){var P,M;return super.optimizeNames(u,p),(P=this.catch)===null||P===void 0||P.optimizeNames(u,p),(M=this.finally)===null||M===void 0||M.optimizeNames(u,p),this}get names(){const u=super.names;return this.catch&&B(u,this.catch.names),this.finally&&B(u,this.finally.names),u}}class Z extends g{constructor(u){super(),this.error=u}render(u){return`catch(${this.error})`+super.render(u)}}Z.kind="catch";class D extends g{render(u){return"finally"+super.render(u)}}D.kind="finally";class L{constructor(u,p={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...p,_n:p.lines?` +`:""},this._extScope=u,this._scope=new r.Scope({parent:u}),this._nodes=[new $]}toString(){return this._root.render(this.opts)}name(u){return this._scope.name(u)}scopeName(u){return this._extScope.name(u)}scopeValue(u,p){const P=this._extScope.value(u,p);return(this._values[P.prefix]||(this._values[P.prefix]=new Set)).add(P),P}getScopeValue(u,p){return this._extScope.getValue(u,p)}scopeRefs(u){return this._extScope.scopeRefs(u,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(u,p,P,M){const z=this._scope.toName(p);return P!==void 0&&M&&(this._constants[z.str]=P),this._leafNode(new a(u,z,P)),z}const(u,p,P){return this._def(r.varKinds.const,u,p,P)}let(u,p,P){return this._def(r.varKinds.let,u,p,P)}var(u,p,P){return this._def(r.varKinds.var,u,p,P)}assign(u,p,P){return this._leafNode(new i(u,p,P))}add(u,p){return this._leafNode(new c(u,e.operators.ADD,p))}code(u){return typeof u=="function"?u():u!==t.nil&&this._leafNode(new _(u)),this}object(...u){const p=["{"];for(const[P,M]of u)p.length>1&&p.push(","),p.push(P),(P!==M||this.opts.es5)&&(p.push(":"),(0,t.addCodeArg)(p,M));return p.push("}"),new t._Code(p)}if(u,p,P){if(this._blockNode(new h(u)),p&&P)this.code(p).else().code(P).endIf();else if(p)this.code(p).endIf();else if(P)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(u){return this._elseNode(new h(u))}else(){return this._elseNode(new m)}endIf(){return this._endBlockNode(h,m)}_for(u,p){return this._blockNode(u),p&&this.code(p).endFor(),this}for(u,p){return this._for(new k(u),p)}forRange(u,p,P,M,z=this.opts.es5?r.varKinds.var:r.varKinds.let){const J=this._scope.toName(u);return this._for(new R(z,J,p,P),()=>M(J))}forOf(u,p,P,M=r.varKinds.const){const z=this._scope.toName(u);if(this.opts.es5){const J=p instanceof t.Name?p:this.var("_arr",p);return this.forRange("_i",0,(0,t._)`${J}.length`,G=>{this.var(z,(0,t._)`${J}[${G}]`),P(z)})}return this._for(new E("of",M,z,p),()=>P(z))}forIn(u,p,P,M=this.opts.es5?r.varKinds.var:r.varKinds.const){if(this.opts.ownProperties)return this.forOf(u,(0,t._)`Object.keys(${p})`,P);const z=this._scope.toName(u);return this._for(new E("in",M,z,p),()=>P(z))}endFor(){return this._endBlockNode(v)}label(u){return this._leafNode(new l(u))}break(u){return this._leafNode(new d(u))}return(u){const p=new x;if(this._blockNode(p),this.code(u),p.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(x)}try(u,p,P){if(!p&&!P)throw new Error('CodeGen: "try" without "catch" and "finally"');const M=new q;if(this._blockNode(M),this.code(u),p){const z=this.name("e");this._currNode=M.catch=new Z(z),p(z)}return P&&(this._currNode=M.finally=new D,this.code(P)),this._endBlockNode(Z,D)}throw(u){return this._leafNode(new f(u))}block(u,p){return this._blockStarts.push(this._nodes.length),u&&this.code(u).endBlock(p),this}endBlock(u){const p=this._blockStarts.pop();if(p===void 0)throw new Error("CodeGen: not in self-balancing block");const P=this._nodes.length-p;if(P<0||u!==void 0&&P!==u)throw new Error(`CodeGen: wrong number of nodes: ${P} vs ${u} expected`);return this._nodes.length=p,this}func(u,p=t.nil,P,M){return this._blockNode(new I(u,p,P)),M&&this.code(M).endFunc(),this}endFunc(){return this._endBlockNode(I)}optimize(u=1){for(;u-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(u){return this._currNode.nodes.push(u),this}_blockNode(u){this._currNode.nodes.push(u),this._nodes.push(u)}_endBlockNode(u,p){const P=this._currNode;if(P instanceof u||p&&P instanceof p)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${p?`${u.kind}/${p.kind}`:u.kind}"`)}_elseNode(u){const p=this._currNode;if(!(p instanceof h))throw new Error('CodeGen: "else" without "if"');return this._currNode=p.else=u,this}get _root(){return this._nodes[0]}get _currNode(){const u=this._nodes;return u[u.length-1]}set _currNode(u){const p=this._nodes;p[p.length-1]=u}}e.CodeGen=L;function B(b,u){for(const p in u)b[p]=(b[p]||0)+(u[p]||0);return b}function ce(b,u){return u instanceof t._CodeOrName?B(b,u.names):b}function U(b,u,p){if(b instanceof t.Name)return P(b);if(!M(b))return b;return new t._Code(b._items.reduce((z,J)=>(J instanceof t.Name&&(J=P(J)),J instanceof t._Code?z.push(...J._items):z.push(J),z),[]));function P(z){const J=p[z.str];return J===void 0||u[z.str]!==1?z:(delete u[z.str],J)}function M(z){return z instanceof t._Code&&z._items.some(J=>J instanceof t.Name&&u[J.str]===1&&p[J.str]!==void 0)}}function le(b,u){for(const p in u)b[p]=(b[p]||0)-(u[p]||0)}function je(b){return typeof b=="boolean"||typeof b=="number"||b===null?!b:(0,t._)`!${j(b)}`}e.not=je;const _e=w(e.operators.AND);function it(...b){return b.reduce(_e)}e.and=it;const Ie=w(e.operators.OR);function N(...b){return b.reduce(Ie)}e.or=N;function w(b){return(u,p)=>u===t.nil?p:p===t.nil?u:(0,t._)`${j(u)} ${b} ${j(p)}`}function j(b){return b instanceof t.Name?b:(0,t._)`(${b})`}})(fe);var V={};Object.defineProperty(V,"__esModule",{value:!0});V.checkStrictMode=V.getErrorPath=V.Type=V.useFunc=V.setEvaluated=V.evaluatedPropsToName=V.mergeEvaluated=V.eachItem=V.unescapeJsonPointer=V.escapeJsonPointer=V.escapeFragment=V.unescapeFragment=V.schemaRefOrVal=V.schemaHasRulesButRef=V.schemaHasRules=V.checkUnknownRules=V.alwaysValidSchema=V.toHash=void 0;const ye=fe,E$=Sn;function k$(e){const t={};for(const r of e)t[r]=!0;return t}V.toHash=k$;function P$(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(bd(e,t),!Sd(t,e.self.RULES.all))}V.alwaysValidSchema=P$;function bd(e,t=e.schema){const{opts:r,self:n}=e;if(!r.strictSchema||typeof t=="boolean")return;const s=n.RULES.keywords;for(const o in t)s[o]||Pd(e,`unknown keyword: "${o}"`)}V.checkUnknownRules=bd;function Sd(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(t[r])return!0;return!1}V.schemaHasRules=Sd;function T$(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}V.schemaHasRulesButRef=T$;function R$({topSchemaRef:e,schemaPath:t},r,n,s){if(!s){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,ye._)`${r}`}return(0,ye._)`${e}${t}${(0,ye.getProperty)(n)}`}V.schemaRefOrVal=R$;function j$(e){return Ed(decodeURIComponent(e))}V.unescapeFragment=j$;function C$(e){return encodeURIComponent(Ga(e))}V.escapeFragment=C$;function Ga(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}V.escapeJsonPointer=Ga;function Ed(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}V.unescapeJsonPointer=Ed;function N$(e,t){if(Array.isArray(e))for(const r of e)t(r);else t(e)}V.eachItem=N$;function nl({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(s,o,a,i)=>{const c=a===void 0?o:a instanceof ye.Name?(o instanceof ye.Name?e(s,o,a):t(s,o,a),a):o instanceof ye.Name?(t(s,a,o),o):r(o,a);return i===ye.Name&&!(c instanceof ye.Name)?n(s,c):c}}V.mergeEvaluated={props:nl({mergeNames:(e,t,r)=>e.if((0,ye._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,ye._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,ye._)`${r} || {}`).code((0,ye._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,ye._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,ye._)`${r} || {}`),Wa(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:kd}),items:nl({mergeNames:(e,t,r)=>e.if((0,ye._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,ye._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,ye._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,ye._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function kd(e,t){if(t===!0)return e.var("props",!0);const r=e.var("props",(0,ye._)`{}`);return t!==void 0&&Wa(e,r,t),r}V.evaluatedPropsToName=kd;function Wa(e,t,r){Object.keys(r).forEach(n=>e.assign((0,ye._)`${t}${(0,ye.getProperty)(n)}`,!0))}V.setEvaluated=Wa;const sl={};function I$(e,t){return e.scopeValue("func",{ref:t,code:sl[t.code]||(sl[t.code]=new E$._Code(t.code))})}V.useFunc=I$;var No;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(No||(V.Type=No={}));function O$(e,t,r){if(e instanceof ye.Name){const n=t===No.Num;return r?n?(0,ye._)`"[" + ${e} + "]"`:(0,ye._)`"['" + ${e} + "']"`:n?(0,ye._)`"/" + ${e}`:(0,ye._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,ye.getProperty)(e).toString():"/"+Ga(e)}V.getErrorPath=O$;function Pd(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}V.checkStrictMode=Pd;var St={};Object.defineProperty(St,"__esModule",{value:!0});const Ze=fe,x$={data:new Ze.Name("data"),valCxt:new Ze.Name("valCxt"),instancePath:new Ze.Name("instancePath"),parentData:new Ze.Name("parentData"),parentDataProperty:new Ze.Name("parentDataProperty"),rootData:new Ze.Name("rootData"),dynamicAnchors:new Ze.Name("dynamicAnchors"),vErrors:new Ze.Name("vErrors"),errors:new Ze.Name("errors"),this:new Ze.Name("this"),self:new Ze.Name("self"),scope:new Ze.Name("scope"),json:new Ze.Name("json"),jsonPos:new Ze.Name("jsonPos"),jsonLen:new Ze.Name("jsonLen"),jsonPart:new Ze.Name("jsonPart")};St.default=x$;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;const t=fe,r=V,n=St;e.keywordError={message:({keyword:m})=>(0,t.str)`must pass "${m}" keyword validation`},e.keyword$DataError={message:({keyword:m,schemaType:h})=>h?(0,t.str)`"${m}" keyword must be ${h} ($data)`:(0,t.str)`"${m}" keyword is invalid ($data)`};function s(m,h=e.keywordError,v,k){const{it:R}=m,{gen:E,compositeRule:I,allErrors:x}=R,q=f(m,h,v);k??(I||x)?c(E,q):l(R,(0,t._)`[${q}]`)}e.reportError=s;function o(m,h=e.keywordError,v){const{it:k}=m,{gen:R,compositeRule:E,allErrors:I}=k,x=f(m,h,v);c(R,x),E||I||l(k,n.default.vErrors)}e.reportExtraError=o;function a(m,h){m.assign(n.default.errors,h),m.if((0,t._)`${n.default.vErrors} !== null`,()=>m.if(h,()=>m.assign((0,t._)`${n.default.vErrors}.length`,h),()=>m.assign(n.default.vErrors,null)))}e.resetErrorsCount=a;function i({gen:m,keyword:h,schemaValue:v,data:k,errsCount:R,it:E}){if(R===void 0)throw new Error("ajv implementation error");const I=m.name("err");m.forRange("i",R,n.default.errors,x=>{m.const(I,(0,t._)`${n.default.vErrors}[${x}]`),m.if((0,t._)`${I}.instancePath === undefined`,()=>m.assign((0,t._)`${I}.instancePath`,(0,t.strConcat)(n.default.instancePath,E.errorPath))),m.assign((0,t._)`${I}.schemaPath`,(0,t.str)`${E.errSchemaPath}/${h}`),E.opts.verbose&&(m.assign((0,t._)`${I}.schema`,v),m.assign((0,t._)`${I}.data`,k))})}e.extendErrors=i;function c(m,h){const v=m.const("err",h);m.if((0,t._)`${n.default.vErrors} === null`,()=>m.assign(n.default.vErrors,(0,t._)`[${v}]`),(0,t._)`${n.default.vErrors}.push(${v})`),m.code((0,t._)`${n.default.errors}++`)}function l(m,h){const{gen:v,validateName:k,schemaEnv:R}=m;R.$async?v.throw((0,t._)`new ${m.ValidationError}(${h})`):(v.assign((0,t._)`${k}.errors`,h),v.return(!1))}const d={keyword:new t.Name("keyword"),schemaPath:new t.Name("schemaPath"),params:new t.Name("params"),propertyName:new t.Name("propertyName"),message:new t.Name("message"),schema:new t.Name("schema"),parentSchema:new t.Name("parentSchema")};function f(m,h,v){const{createErrors:k}=m.it;return k===!1?(0,t._)`{}`:_(m,h,v)}function _(m,h,v={}){const{gen:k,it:R}=m,E=[y(R,v),g(m,v)];return $(m,h,E),k.object(...E)}function y({errorPath:m},{instancePath:h}){const v=h?(0,t.str)`${m}${(0,r.getErrorPath)(h,r.Type.Str)}`:m;return[n.default.instancePath,(0,t.strConcat)(n.default.instancePath,v)]}function g({keyword:m,it:{errSchemaPath:h}},{schemaPath:v,parentSchema:k}){let R=k?h:(0,t.str)`${h}/${m}`;return v&&(R=(0,t.str)`${R}${(0,r.getErrorPath)(v,r.Type.Str)}`),[d.schemaPath,R]}function $(m,{params:h,message:v},k){const{keyword:R,data:E,schemaValue:I,it:x}=m,{opts:q,propertyName:Z,topSchemaRef:D,schemaPath:L}=x;k.push([d.keyword,R],[d.params,typeof h=="function"?h(m):h||(0,t._)`{}`]),q.messages&&k.push([d.message,typeof v=="function"?v(m):v]),q.verbose&&k.push([d.schema,I],[d.parentSchema,(0,t._)`${D}${L}`],[n.default.data,E]),Z&&k.push([d.propertyName,Z])}})(An);Object.defineProperty(Dr,"__esModule",{value:!0});Dr.boolOrEmptySchema=Dr.topBoolOrEmptySchema=void 0;const A$=An,M$=fe,z$=St,D$={message:"boolean schema is false"};function q$(e){const{gen:t,schema:r,validateName:n}=e;r===!1?Td(e,!1):typeof r=="object"&&r.$async===!0?t.return(z$.default.data):(t.assign((0,M$._)`${n}.errors`,null),t.return(!0))}Dr.topBoolOrEmptySchema=q$;function U$(e,t){const{gen:r,schema:n}=e;n===!1?(r.var(t,!1),Td(e)):r.var(t,!0)}Dr.boolOrEmptySchema=U$;function Td(e,t){const{gen:r,data:n}=e,s={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,A$.reportError)(s,D$,void 0,t)}var Oe={},mr={};Object.defineProperty(mr,"__esModule",{value:!0});mr.getRules=mr.isJSONType=void 0;const F$=["string","number","integer","boolean","null","object","array"],L$=new Set(F$);function V$(e){return typeof e=="string"&&L$.has(e)}mr.isJSONType=V$;function H$(){const e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}mr.getRules=H$;var kt={};Object.defineProperty(kt,"__esModule",{value:!0});kt.shouldUseRule=kt.shouldUseGroup=kt.schemaHasRulesForType=void 0;function Z$({schema:e,self:t},r){const n=t.RULES.types[r];return n&&n!==!0&&Rd(e,n)}kt.schemaHasRulesForType=Z$;function Rd(e,t){return t.rules.some(r=>jd(e,r))}kt.shouldUseGroup=Rd;function jd(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(n=>e[n]!==void 0))}kt.shouldUseRule=jd;Object.defineProperty(Oe,"__esModule",{value:!0});Oe.reportTypeError=Oe.checkDataTypes=Oe.checkDataType=Oe.coerceAndCheckDataType=Oe.getJSONTypes=Oe.getSchemaTypes=Oe.DataType=void 0;const K$=mr,G$=kt,W$=An,se=fe,Cd=V;var Or;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Or||(Oe.DataType=Or={}));function B$(e){const t=Nd(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}Oe.getSchemaTypes=B$;function Nd(e){const t=Array.isArray(e)?e:e?[e]:[];if(t.every(K$.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}Oe.getJSONTypes=Nd;function J$(e,t){const{gen:r,data:n,opts:s}=e,o=Q$(t,s.coerceTypes),a=t.length>0&&!(o.length===0&&t.length===1&&(0,G$.schemaHasRulesForType)(e,t[0]));if(a){const i=Ba(t,n,s.strictNumbers,Or.Wrong);r.if(i,()=>{o.length?Y$(e,t,o):Ja(e)})}return a}Oe.coerceAndCheckDataType=J$;const Id=new Set(["string","number","integer","boolean","null"]);function Q$(e,t){return t?e.filter(r=>Id.has(r)||t==="array"&&r==="array"):[]}function Y$(e,t,r){const{gen:n,data:s,opts:o}=e,a=n.let("dataType",(0,se._)`typeof ${s}`),i=n.let("coerced",(0,se._)`undefined`);o.coerceTypes==="array"&&n.if((0,se._)`${a} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>n.assign(s,(0,se._)`${s}[0]`).assign(a,(0,se._)`typeof ${s}`).if(Ba(t,s,o.strictNumbers),()=>n.assign(i,s))),n.if((0,se._)`${i} !== undefined`);for(const l of r)(Id.has(l)||l==="array"&&o.coerceTypes==="array")&&c(l);n.else(),Ja(e),n.endIf(),n.if((0,se._)`${i} !== undefined`,()=>{n.assign(s,i),X$(e,i)});function c(l){switch(l){case"string":n.elseIf((0,se._)`${a} == "number" || ${a} == "boolean"`).assign(i,(0,se._)`"" + ${s}`).elseIf((0,se._)`${s} === null`).assign(i,(0,se._)`""`);return;case"number":n.elseIf((0,se._)`${a} == "boolean" || ${s} === null + || (${a} == "string" && ${s} && ${s} == +${s})`).assign(i,(0,se._)`+${s}`);return;case"integer":n.elseIf((0,se._)`${a} === "boolean" || ${s} === null + || (${a} === "string" && ${s} && ${s} == +${s} && !(${s} % 1))`).assign(i,(0,se._)`+${s}`);return;case"boolean":n.elseIf((0,se._)`${s} === "false" || ${s} === 0 || ${s} === null`).assign(i,!1).elseIf((0,se._)`${s} === "true" || ${s} === 1`).assign(i,!0);return;case"null":n.elseIf((0,se._)`${s} === "" || ${s} === 0 || ${s} === false`),n.assign(i,null);return;case"array":n.elseIf((0,se._)`${a} === "string" || ${a} === "number" + || ${a} === "boolean" || ${s} === null`).assign(i,(0,se._)`[${s}]`)}}}function X$({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,se._)`${t} !== undefined`,()=>e.assign((0,se._)`${t}[${r}]`,n))}function Io(e,t,r,n=Or.Correct){const s=n===Or.Correct?se.operators.EQ:se.operators.NEQ;let o;switch(e){case"null":return(0,se._)`${t} ${s} null`;case"array":o=(0,se._)`Array.isArray(${t})`;break;case"object":o=(0,se._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":o=a((0,se._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":o=a();break;default:return(0,se._)`typeof ${t} ${s} ${e}`}return n===Or.Correct?o:(0,se.not)(o);function a(i=se.nil){return(0,se.and)((0,se._)`typeof ${t} == "number"`,i,r?(0,se._)`isFinite(${t})`:se.nil)}}Oe.checkDataType=Io;function Ba(e,t,r,n){if(e.length===1)return Io(e[0],t,r,n);let s;const o=(0,Cd.toHash)(e);if(o.array&&o.object){const a=(0,se._)`typeof ${t} != "object"`;s=o.null?a:(0,se._)`!${t} || ${a}`,delete o.null,delete o.array,delete o.object}else s=se.nil;o.number&&delete o.integer;for(const a in o)s=(0,se.and)(s,Io(a,t,r,n));return s}Oe.checkDataTypes=Ba;const ew={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,se._)`{type: ${e}}`:(0,se._)`{type: ${t}}`};function Ja(e){const t=tw(e);(0,W$.reportError)(t,ew)}Oe.reportTypeError=Ja;function tw(e){const{gen:t,data:r,schema:n}=e,s=(0,Cd.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:e}}var Fs={};Object.defineProperty(Fs,"__esModule",{value:!0});Fs.assignDefaults=void 0;const br=fe,rw=V;function nw(e,t){const{properties:r,items:n}=e.schema;if(t==="object"&&r)for(const s in r)ol(e,s,r[s].default);else t==="array"&&Array.isArray(n)&&n.forEach((s,o)=>ol(e,o,s.default))}Fs.assignDefaults=nw;function ol(e,t,r){const{gen:n,compositeRule:s,data:o,opts:a}=e;if(r===void 0)return;const i=(0,br._)`${o}${(0,br.getProperty)(t)}`;if(s){(0,rw.checkStrictMode)(e,`default is ignored for: ${i}`);return}let c=(0,br._)`${i} === undefined`;a.useDefaults==="empty"&&(c=(0,br._)`${c} || ${i} === null || ${i} === ""`),n.if(c,(0,br._)`${i} = ${(0,br.stringify)(r)}`)}var wt={},ue={};Object.defineProperty(ue,"__esModule",{value:!0});ue.validateUnion=ue.validateArray=ue.usePattern=ue.callValidateCode=ue.schemaProperties=ue.allSchemaProperties=ue.noPropertyInData=ue.propertyInData=ue.isOwnProperty=ue.hasPropFunc=ue.reportMissingProp=ue.checkMissingProp=ue.checkReportMissingProp=void 0;const be=fe,Qa=V,jt=St,sw=V;function ow(e,t){const{gen:r,data:n,it:s}=e;r.if(Xa(r,n,t,s.opts.ownProperties),()=>{e.setParams({missingProperty:(0,be._)`${t}`},!0),e.error()})}ue.checkReportMissingProp=ow;function aw({gen:e,data:t,it:{opts:r}},n,s){return(0,be.or)(...n.map(o=>(0,be.and)(Xa(e,t,o,r.ownProperties),(0,be._)`${s} = ${o}`)))}ue.checkMissingProp=aw;function iw(e,t){e.setParams({missingProperty:t},!0),e.error()}ue.reportMissingProp=iw;function Od(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,be._)`Object.prototype.hasOwnProperty`})}ue.hasPropFunc=Od;function Ya(e,t,r){return(0,be._)`${Od(e)}.call(${t}, ${r})`}ue.isOwnProperty=Ya;function cw(e,t,r,n){const s=(0,be._)`${t}${(0,be.getProperty)(r)} !== undefined`;return n?(0,be._)`${s} && ${Ya(e,t,r)}`:s}ue.propertyInData=cw;function Xa(e,t,r,n){const s=(0,be._)`${t}${(0,be.getProperty)(r)} === undefined`;return n?(0,be.or)(s,(0,be.not)(Ya(e,t,r))):s}ue.noPropertyInData=Xa;function xd(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}ue.allSchemaProperties=xd;function lw(e,t){return xd(t).filter(r=>!(0,Qa.alwaysValidSchema)(e,t[r]))}ue.schemaProperties=lw;function uw({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:s,errorPath:o},it:a},i,c,l){const d=l?(0,be._)`${e}, ${t}, ${n}${s}`:t,f=[[jt.default.instancePath,(0,be.strConcat)(jt.default.instancePath,o)],[jt.default.parentData,a.parentData],[jt.default.parentDataProperty,a.parentDataProperty],[jt.default.rootData,jt.default.rootData]];a.opts.dynamicRef&&f.push([jt.default.dynamicAnchors,jt.default.dynamicAnchors]);const _=(0,be._)`${d}, ${r.object(...f)}`;return c!==be.nil?(0,be._)`${i}.call(${c}, ${_})`:(0,be._)`${i}(${_})`}ue.callValidateCode=uw;const dw=(0,be._)`new RegExp`;function fw({gen:e,it:{opts:t}},r){const n=t.unicodeRegExp?"u":"",{regExp:s}=t.code,o=s(r,n);return e.scopeValue("pattern",{key:o.toString(),ref:o,code:(0,be._)`${s.code==="new RegExp"?dw:(0,sw.useFunc)(e,s)}(${r}, ${n})`})}ue.usePattern=fw;function hw(e){const{gen:t,data:r,keyword:n,it:s}=e,o=t.name("valid");if(s.allErrors){const i=t.let("valid",!0);return a(()=>t.assign(i,!1)),i}return t.var(o,!0),a(()=>t.break()),o;function a(i){const c=t.const("len",(0,be._)`${r}.length`);t.forRange("i",0,c,l=>{e.subschema({keyword:n,dataProp:l,dataPropType:Qa.Type.Num},o),t.if((0,be.not)(o),i)})}}ue.validateArray=hw;function pw(e){const{gen:t,schema:r,keyword:n,it:s}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,Qa.alwaysValidSchema)(s,c))&&!s.opts.unevaluated)return;const a=t.let("valid",!1),i=t.name("_valid");t.block(()=>r.forEach((c,l)=>{const d=e.subschema({keyword:n,schemaProp:l,compositeRule:!0},i);t.assign(a,(0,be._)`${a} || ${i}`),e.mergeValidEvaluated(d,i)||t.if((0,be.not)(a))})),e.result(a,()=>e.reset(),()=>e.error(!0))}ue.validateUnion=pw;Object.defineProperty(wt,"__esModule",{value:!0});wt.validateKeywordUsage=wt.validSchemaType=wt.funcKeywordCode=wt.macroKeywordCode=void 0;const Ge=fe,ir=St,mw=ue,gw=An;function _w(e,t){const{gen:r,keyword:n,schema:s,parentSchema:o,it:a}=e,i=t.macro.call(a.self,s,o,a),c=Ad(r,n,i);a.opts.validateSchema!==!1&&a.self.validateSchema(i,!0);const l=r.name("valid");e.subschema({schema:i,schemaPath:Ge.nil,errSchemaPath:`${a.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},l),e.pass(l,()=>e.error(!0))}wt.macroKeywordCode=_w;function yw(e,t){var r;const{gen:n,keyword:s,schema:o,parentSchema:a,$data:i,it:c}=e;$w(c,t);const l=!i&&t.compile?t.compile.call(c.self,o,a,c):t.validate,d=Ad(n,s,l),f=n.let("valid");e.block$data(f,_),e.ok((r=t.valid)!==null&&r!==void 0?r:f);function _(){if(t.errors===!1)$(),t.modifying&&al(e),m(()=>e.error());else{const h=t.async?y():g();t.modifying&&al(e),m(()=>vw(e,h))}}function y(){const h=n.let("ruleErrs",null);return n.try(()=>$((0,Ge._)`await `),v=>n.assign(f,!1).if((0,Ge._)`${v} instanceof ${c.ValidationError}`,()=>n.assign(h,(0,Ge._)`${v}.errors`),()=>n.throw(v))),h}function g(){const h=(0,Ge._)`${d}.errors`;return n.assign(h,null),$(Ge.nil),h}function $(h=t.async?(0,Ge._)`await `:Ge.nil){const v=c.opts.passContext?ir.default.this:ir.default.self,k=!("compile"in t&&!i||t.schema===!1);n.assign(f,(0,Ge._)`${h}${(0,mw.callValidateCode)(e,d,v,k)}`,t.modifying)}function m(h){var v;n.if((0,Ge.not)((v=t.valid)!==null&&v!==void 0?v:f),h)}}wt.funcKeywordCode=yw;function al(e){const{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,Ge._)`${n.parentData}[${n.parentDataProperty}]`))}function vw(e,t){const{gen:r}=e;r.if((0,Ge._)`Array.isArray(${t})`,()=>{r.assign(ir.default.vErrors,(0,Ge._)`${ir.default.vErrors} === null ? ${t} : ${ir.default.vErrors}.concat(${t})`).assign(ir.default.errors,(0,Ge._)`${ir.default.vErrors}.length`),(0,gw.extendErrors)(e)},()=>e.error())}function $w({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function Ad(e,t,r){if(r===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,Ge.stringify)(r)})}function ww(e,t,r=!1){return!t.length||t.some(n=>n==="array"?Array.isArray(e):n==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==n||r&&typeof e>"u")}wt.validSchemaType=ww;function bw({schema:e,opts:t,self:r,errSchemaPath:n},s,o){if(Array.isArray(s.keyword)?!s.keyword.includes(o):s.keyword!==o)throw new Error("ajv implementation error");const a=s.dependencies;if(a!=null&&a.some(i=>!Object.prototype.hasOwnProperty.call(e,i)))throw new Error(`parent schema must have dependencies of ${o}: ${a.join(",")}`);if(s.validateSchema&&!s.validateSchema(e[o])){const c=`keyword "${o}" value is invalid at path "${n}": `+r.errorsText(s.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}wt.validateKeywordUsage=bw;var Dt={};Object.defineProperty(Dt,"__esModule",{value:!0});Dt.extendSubschemaMode=Dt.extendSubschemaData=Dt.getSubschema=void 0;const vt=fe,Md=V;function Sw(e,{keyword:t,schemaProp:r,schema:n,schemaPath:s,errSchemaPath:o,topSchemaRef:a}){if(t!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){const i=e.schema[t];return r===void 0?{schema:i,schemaPath:(0,vt._)`${e.schemaPath}${(0,vt.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:i[r],schemaPath:(0,vt._)`${e.schemaPath}${(0,vt.getProperty)(t)}${(0,vt.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,Md.escapeFragment)(r)}`}}if(n!==void 0){if(s===void 0||o===void 0||a===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:s,topSchemaRef:a,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')}Dt.getSubschema=Sw;function Ew(e,t,{dataProp:r,dataPropType:n,data:s,dataTypes:o,propertyName:a}){if(s!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:i}=t;if(r!==void 0){const{errorPath:l,dataPathArr:d,opts:f}=t,_=i.let("data",(0,vt._)`${t.data}${(0,vt.getProperty)(r)}`,!0);c(_),e.errorPath=(0,vt.str)`${l}${(0,Md.getErrorPath)(r,n,f.jsPropertySyntax)}`,e.parentDataProperty=(0,vt._)`${r}`,e.dataPathArr=[...d,e.parentDataProperty]}if(s!==void 0){const l=s instanceof vt.Name?s:i.let("data",s,!0);c(l),a!==void 0&&(e.propertyName=a)}o&&(e.dataTypes=o);function c(l){e.data=l,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,l]}}Dt.extendSubschemaData=Ew;function kw(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:s,allErrors:o}){n!==void 0&&(e.compositeRule=n),s!==void 0&&(e.createErrors=s),o!==void 0&&(e.allErrors=o),e.jtdDiscriminator=t,e.jtdMetadata=r}Dt.extendSubschemaMode=kw;var Ue={},Ls=function e(t,r){if(t===r)return!0;if(t&&r&&typeof t=="object"&&typeof r=="object"){if(t.constructor!==r.constructor)return!1;var n,s,o;if(Array.isArray(t)){if(n=t.length,n!=r.length)return!1;for(s=n;s--!==0;)if(!e(t[s],r[s]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if(o=Object.keys(t),n=o.length,n!==Object.keys(r).length)return!1;for(s=n;s--!==0;)if(!Object.prototype.hasOwnProperty.call(r,o[s]))return!1;for(s=n;s--!==0;){var a=o[s];if(!e(t[a],r[a]))return!1}return!0}return t!==t&&r!==r},zd={exports:{}},At=zd.exports=function(e,t,r){typeof t=="function"&&(r=t,t={}),r=t.cb||r;var n=typeof r=="function"?r:r.pre||function(){},s=r.post||function(){};ns(t,n,s,e,"",e)};At.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};At.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};At.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};At.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 ns(e,t,r,n,s,o,a,i,c,l){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,s,o,a,i,c,l);for(var d in n){var f=n[d];if(Array.isArray(f)){if(d in At.arrayKeywords)for(var _=0;_t+=Dd(n)),t===1/0))return 1/0}return t}function qd(e,t="",r){r!==!1&&(t=xr(t));const n=e.parse(t);return Ud(e,n)}Ue.getFullPath=qd;function Ud(e,t){return e.serialize(t).split("#")[0]+"#"}Ue._getFullPath=Ud;const xw=/#\/?$/;function xr(e){return e?e.replace(xw,""):""}Ue.normalizeId=xr;function Aw(e,t,r){return r=xr(r),e.resolve(t,r)}Ue.resolveUrl=Aw;const Mw=/^[a-z_][-a-z0-9._]*$/i;function zw(e,t){if(typeof e=="boolean")return{};const{schemaId:r,uriResolver:n}=this.opts,s=xr(e[r]||t),o={"":s},a=qd(n,s,!1),i={},c=new Set;return Cw(e,{allKeys:!0},(f,_,y,g)=>{if(g===void 0)return;const $=a+_;let m=o[g];typeof f[r]=="string"&&(m=h.call(this,f[r])),v.call(this,f.$anchor),v.call(this,f.$dynamicAnchor),o[_]=m;function h(k){const R=this.opts.uriResolver.resolve;if(k=xr(m?R(m,k):k),c.has(k))throw d(k);c.add(k);let E=this.refs[k];return typeof E=="string"&&(E=this.refs[E]),typeof E=="object"?l(f,E.schema,k):k!==xr($)&&(k[0]==="#"?(l(f,i[k],k),i[k]=f):this.refs[k]=$),k}function v(k){if(typeof k=="string"){if(!Mw.test(k))throw new Error(`invalid anchor "${k}"`);h.call(this,`#${k}`)}}}),i;function l(f,_,y){if(_!==void 0&&!jw(f,_))throw d(y)}function d(f){return new Error(`reference "${f}" resolves to more than one schema`)}}Ue.getSchemaRefs=zw;Object.defineProperty(gt,"__esModule",{value:!0});gt.getData=gt.KeywordCxt=gt.validateFunctionCode=void 0;const Fd=Dr,il=Oe,ei=kt,ys=Oe,Dw=Fs,ln=wt,no=Dt,Q=fe,ee=St,qw=Ue,Pt=V,Xr=An;function Uw(e){if(Hd(e)&&(Zd(e),Vd(e))){Vw(e);return}Ld(e,()=>(0,Fd.topBoolOrEmptySchema)(e))}gt.validateFunctionCode=Uw;function Ld({gen:e,validateName:t,schema:r,schemaEnv:n,opts:s},o){s.code.es5?e.func(t,(0,Q._)`${ee.default.data}, ${ee.default.valCxt}`,n.$async,()=>{e.code((0,Q._)`"use strict"; ${cl(r,s)}`),Lw(e,s),e.code(o)}):e.func(t,(0,Q._)`${ee.default.data}, ${Fw(s)}`,n.$async,()=>e.code(cl(r,s)).code(o))}function Fw(e){return(0,Q._)`{${ee.default.instancePath}="", ${ee.default.parentData}, ${ee.default.parentDataProperty}, ${ee.default.rootData}=${ee.default.data}${e.dynamicRef?(0,Q._)`, ${ee.default.dynamicAnchors}={}`:Q.nil}}={}`}function Lw(e,t){e.if(ee.default.valCxt,()=>{e.var(ee.default.instancePath,(0,Q._)`${ee.default.valCxt}.${ee.default.instancePath}`),e.var(ee.default.parentData,(0,Q._)`${ee.default.valCxt}.${ee.default.parentData}`),e.var(ee.default.parentDataProperty,(0,Q._)`${ee.default.valCxt}.${ee.default.parentDataProperty}`),e.var(ee.default.rootData,(0,Q._)`${ee.default.valCxt}.${ee.default.rootData}`),t.dynamicRef&&e.var(ee.default.dynamicAnchors,(0,Q._)`${ee.default.valCxt}.${ee.default.dynamicAnchors}`)},()=>{e.var(ee.default.instancePath,(0,Q._)`""`),e.var(ee.default.parentData,(0,Q._)`undefined`),e.var(ee.default.parentDataProperty,(0,Q._)`undefined`),e.var(ee.default.rootData,ee.default.data),t.dynamicRef&&e.var(ee.default.dynamicAnchors,(0,Q._)`{}`)})}function Vw(e){const{schema:t,opts:r,gen:n}=e;Ld(e,()=>{r.$comment&&t.$comment&&Gd(e),Ww(e),n.let(ee.default.vErrors,null),n.let(ee.default.errors,0),r.unevaluated&&Hw(e),Kd(e),Qw(e)})}function Hw(e){const{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,Q._)`${r}.evaluated`),t.if((0,Q._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,Q._)`${e.evaluated}.props`,(0,Q._)`undefined`)),t.if((0,Q._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,Q._)`${e.evaluated}.items`,(0,Q._)`undefined`))}function cl(e,t){const r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,Q._)`/*# sourceURL=${r} */`:Q.nil}function Zw(e,t){if(Hd(e)&&(Zd(e),Vd(e))){Kw(e,t);return}(0,Fd.boolOrEmptySchema)(e,t)}function Vd({schema:e,self:t}){if(typeof e=="boolean")return!e;for(const r in e)if(t.RULES.all[r])return!0;return!1}function Hd(e){return typeof e.schema!="boolean"}function Kw(e,t){const{schema:r,gen:n,opts:s}=e;s.$comment&&r.$comment&&Gd(e),Bw(e),Jw(e);const o=n.const("_errs",ee.default.errors);Kd(e,o),n.var(t,(0,Q._)`${o} === ${ee.default.errors}`)}function Zd(e){(0,Pt.checkUnknownRules)(e),Gw(e)}function Kd(e,t){if(e.opts.jtd)return ll(e,[],!1,t);const r=(0,il.getSchemaTypes)(e.schema),n=(0,il.coerceAndCheckDataType)(e,r);ll(e,r,!n,t)}function Gw(e){const{schema:t,errSchemaPath:r,opts:n,self:s}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,Pt.schemaHasRulesButRef)(t,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function Ww(e){const{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Pt.checkStrictMode)(e,"default is ignored in the schema root")}function Bw(e){const t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,qw.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function Jw(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function Gd({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:s}){const o=r.$comment;if(s.$comment===!0)e.code((0,Q._)`${ee.default.self}.logger.log(${o})`);else if(typeof s.$comment=="function"){const a=(0,Q.str)`${n}/$comment`,i=e.scopeValue("root",{ref:t.root});e.code((0,Q._)`${ee.default.self}.opts.$comment(${o}, ${a}, ${i}.schema)`)}}function Qw(e){const{gen:t,schemaEnv:r,validateName:n,ValidationError:s,opts:o}=e;r.$async?t.if((0,Q._)`${ee.default.errors} === 0`,()=>t.return(ee.default.data),()=>t.throw((0,Q._)`new ${s}(${ee.default.vErrors})`)):(t.assign((0,Q._)`${n}.errors`,ee.default.vErrors),o.unevaluated&&Yw(e),t.return((0,Q._)`${ee.default.errors} === 0`))}function Yw({gen:e,evaluated:t,props:r,items:n}){r instanceof Q.Name&&e.assign((0,Q._)`${t}.props`,r),n instanceof Q.Name&&e.assign((0,Q._)`${t}.items`,n)}function ll(e,t,r,n){const{gen:s,schema:o,data:a,allErrors:i,opts:c,self:l}=e,{RULES:d}=l;if(o.$ref&&(c.ignoreKeywordsWithRef||!(0,Pt.schemaHasRulesButRef)(o,d))){s.block(()=>Jd(e,"$ref",d.all.$ref.definition));return}c.jtd||Xw(e,t),s.block(()=>{for(const _ of d.rules)f(_);f(d.post)});function f(_){(0,ei.shouldUseGroup)(o,_)&&(_.type?(s.if((0,ys.checkDataType)(_.type,a,c.strictNumbers)),ul(e,_),t.length===1&&t[0]===_.type&&r&&(s.else(),(0,ys.reportTypeError)(e)),s.endIf()):ul(e,_),i||s.if((0,Q._)`${ee.default.errors} === ${n||0}`))}}function ul(e,t){const{gen:r,schema:n,opts:{useDefaults:s}}=e;s&&(0,Dw.assignDefaults)(e,t.type),r.block(()=>{for(const o of t.rules)(0,ei.shouldUseRule)(n,o)&&Jd(e,o.keyword,o.definition,t.type)})}function Xw(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(e0(e,t),e.opts.allowUnionTypes||t0(e,t),r0(e,e.dataTypes))}function e0(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{Wd(e.dataTypes,r)||ti(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),s0(e,t)}}function t0(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&ti(e,"use allowUnionTypes to allow union type keyword")}function r0(e,t){const r=e.self.RULES.all;for(const n in r){const s=r[n];if(typeof s=="object"&&(0,ei.shouldUseRule)(e.schema,s)){const{type:o}=s.definition;o.length&&!o.some(a=>n0(t,a))&&ti(e,`missing type "${o.join(",")}" for keyword "${n}"`)}}}function n0(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function Wd(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function s0(e,t){const r=[];for(const n of e.dataTypes)Wd(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function ti(e,t){const r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,Pt.checkStrictMode)(e,t,e.opts.strictTypes)}let Bd=class{constructor(t,r,n){if((0,ln.validateKeywordUsage)(t,r,n),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=n,this.data=t.data,this.schema=t.schema[n],this.$data=r.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Pt.schemaRefOrVal)(t,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=r,this.$data)this.schemaCode=t.gen.const("vSchema",Qd(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,ln.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=t.gen.const("_errs",ee.default.errors))}result(t,r,n){this.failResult((0,Q.not)(t),r,n)}failResult(t,r,n){this.gen.if(t),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,r){this.failResult((0,Q.not)(t),void 0,r)}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);const{schemaCode:r}=this;this.fail((0,Q._)`${r} !== undefined && (${(0,Q.or)(this.invalid$data(),t)})`)}error(t,r,n){if(r){this.setParams(r),this._error(t,n),this.setParams({});return}this._error(t,n)}_error(t,r){(t?Xr.reportExtraError:Xr.reportError)(this,this.def.error,r)}$dataError(){(0,Xr.reportError)(this,this.def.$dataError||Xr.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Xr.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,r){r?Object.assign(this.params,t):this.params=t}block$data(t,r,n=Q.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=Q.nil,r=Q.nil){if(!this.$data)return;const{gen:n,schemaCode:s,schemaType:o,def:a}=this;n.if((0,Q.or)((0,Q._)`${s} === undefined`,r)),t!==Q.nil&&n.assign(t,!0),(o.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==Q.nil&&n.assign(t,!1)),n.else()}invalid$data(){const{gen:t,schemaCode:r,schemaType:n,def:s,it:o}=this;return(0,Q.or)(a(),i());function a(){if(n.length){if(!(r instanceof Q.Name))throw new Error("ajv implementation error");const c=Array.isArray(n)?n:[n];return(0,Q._)`${(0,ys.checkDataTypes)(c,r,o.opts.strictNumbers,ys.DataType.Wrong)}`}return Q.nil}function i(){if(s.validateSchema){const c=t.scopeValue("validate$data",{ref:s.validateSchema});return(0,Q._)`!${c}(${r})`}return Q.nil}}subschema(t,r){const n=(0,no.getSubschema)(this.it,t);(0,no.extendSubschemaData)(n,this.it,t),(0,no.extendSubschemaMode)(n,t);const s={...this.it,...n,items:void 0,props:void 0};return Zw(s,r),s}mergeEvaluated(t,r){const{it:n,gen:s}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=Pt.mergeEvaluated.props(s,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=Pt.mergeEvaluated.items(s,t.items,n.items,r)))}mergeValidEvaluated(t,r){const{it:n,gen:s}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return s.if(r,()=>this.mergeEvaluated(t,Q.Name)),!0}};gt.KeywordCxt=Bd;function Jd(e,t,r,n){const s=new Bd(e,r,t);"code"in r?r.code(s,n):s.$data&&r.validate?(0,ln.funcKeywordCode)(s,r):"macro"in r?(0,ln.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0,ln.funcKeywordCode)(s,r)}const o0=/^\/(?:[^~]|~0|~1)*$/,a0=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Qd(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let s,o;if(e==="")return ee.default.rootData;if(e[0]==="/"){if(!o0.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);s=e,o=ee.default.rootData}else{const l=a0.exec(e);if(!l)throw new Error(`Invalid JSON-pointer: ${e}`);const d=+l[1];if(s=l[2],s==="#"){if(d>=t)throw new Error(c("property/index",d));return n[t-d]}if(d>t)throw new Error(c("data",d));if(o=r[t-d],!s)return o}let a=o;const i=s.split("/");for(const l of i)l&&(o=(0,Q._)`${o}${(0,Q.getProperty)((0,Pt.unescapeJsonPointer)(l))}`,a=(0,Q._)`${a} && ${o}`);return a;function c(l,d){return`Cannot access ${l} ${d} levels up, current level is ${t}`}}gt.getData=Qd;var Mn={};Object.defineProperty(Mn,"__esModule",{value:!0});let i0=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};Mn.default=i0;var Hr={};Object.defineProperty(Hr,"__esModule",{value:!0});const so=Ue;let c0=class extends Error{constructor(t,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,so.resolveUrl)(t,r,n),this.missingSchema=(0,so.normalizeId)((0,so.getFullPath)(t,this.missingRef))}};Hr.default=c0;var Qe={};Object.defineProperty(Qe,"__esModule",{value:!0});Qe.resolveSchema=Qe.getCompilingSchema=Qe.resolveRef=Qe.compileSchema=Qe.SchemaEnv=void 0;const lt=fe,l0=Mn,nr=St,pt=Ue,dl=V,u0=gt;let Vs=class{constructor(t){var r;this.refs={},this.dynamicAnchors={};let n;typeof t.schema=="object"&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0,pt.normalizeId)(n==null?void 0:n[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n==null?void 0:n.$async,this.refs={}}};Qe.SchemaEnv=Vs;function ri(e){const t=Yd.call(this,e);if(t)return t;const r=(0,pt.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:s}=this.opts.code,{ownProperties:o}=this.opts,a=new lt.CodeGen(this.scope,{es5:n,lines:s,ownProperties:o});let i;e.$async&&(i=a.scopeValue("Error",{ref:l0.default,code:(0,lt._)`require("ajv/dist/runtime/validation_error").default`}));const c=a.scopeName("validate");e.validateName=c;const l={gen:a,allErrors:this.opts.allErrors,data:nr.default.data,parentData:nr.default.parentData,parentDataProperty:nr.default.parentDataProperty,dataNames:[nr.default.data],dataPathArr:[lt.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:a.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,lt.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:i,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:lt.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,lt._)`""`,opts:this.opts,self:this};let d;try{this._compilations.add(e),(0,u0.validateFunctionCode)(l),a.optimize(this.opts.code.optimize);const f=a.toString();d=`${a.scopeRefs(nr.default.scope)}return ${f}`,this.opts.code.process&&(d=this.opts.code.process(d,e));const y=new Function(`${nr.default.self}`,`${nr.default.scope}`,d)(this,this.scope.get());if(this.scope.value(c,{ref:y}),y.errors=null,y.schema=e.schema,y.schemaEnv=e,e.$async&&(y.$async=!0),this.opts.code.source===!0&&(y.source={validateName:c,validateCode:f,scopeValues:a._values}),this.opts.unevaluated){const{props:g,items:$}=l;y.evaluated={props:g instanceof lt.Name?void 0:g,items:$ instanceof lt.Name?void 0:$,dynamicProps:g instanceof lt.Name,dynamicItems:$ instanceof lt.Name},y.source&&(y.source.evaluated=(0,lt.stringify)(y.evaluated))}return e.validate=y,e}catch(f){throw delete e.validate,delete e.validateName,d&&this.logger.error("Error compiling schema, function code:",d),f}finally{this._compilations.delete(e)}}Qe.compileSchema=ri;function d0(e,t,r){var n;r=(0,pt.resolveUrl)(this.opts.uriResolver,t,r);const s=e.refs[r];if(s)return s;let o=p0.call(this,e,r);if(o===void 0){const a=(n=e.localRefs)===null||n===void 0?void 0:n[r],{schemaId:i}=this.opts;a&&(o=new Vs({schema:a,schemaId:i,root:e,baseId:t}))}if(o!==void 0)return e.refs[r]=f0.call(this,o)}Qe.resolveRef=d0;function f0(e){return(0,pt.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:ri.call(this,e)}function Yd(e){for(const t of this._compilations)if(h0(t,e))return t}Qe.getCompilingSchema=Yd;function h0(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function p0(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||Hs.call(this,e,t)}function Hs(e,t){const r=this.opts.uriResolver.parse(t),n=(0,pt._getFullPath)(this.opts.uriResolver,r);let s=(0,pt.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===s)return oo.call(this,r,e);const o=(0,pt.normalizeId)(n),a=this.refs[o]||this.schemas[o];if(typeof a=="string"){const i=Hs.call(this,e,a);return typeof(i==null?void 0:i.schema)!="object"?void 0:oo.call(this,r,i)}if(typeof(a==null?void 0:a.schema)=="object"){if(a.validate||ri.call(this,a),o===(0,pt.normalizeId)(t)){const{schema:i}=a,{schemaId:c}=this.opts,l=i[c];return l&&(s=(0,pt.resolveUrl)(this.opts.uriResolver,s,l)),new Vs({schema:i,schemaId:c,root:e,baseId:s})}return oo.call(this,r,a)}}Qe.resolveSchema=Hs;const m0=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function oo(e,{baseId:t,schema:r,root:n}){var s;if(((s=e.fragment)===null||s===void 0?void 0:s[0])!=="/")return;for(const i of e.fragment.slice(1).split("/")){if(typeof r=="boolean")return;const c=r[(0,dl.unescapeFragment)(i)];if(c===void 0)return;r=c;const l=typeof r=="object"&&r[this.opts.schemaId];!m0.has(i)&&l&&(t=(0,pt.resolveUrl)(this.opts.uriResolver,t,l))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,dl.schemaHasRulesButRef)(r,this.RULES)){const i=(0,pt.resolveUrl)(this.opts.uriResolver,t,r.$ref);o=Hs.call(this,n,i)}const{schemaId:a}=this.opts;if(o=o||new Vs({schema:r,schemaId:a,root:n,baseId:t}),o.schema!==o.root.schema)return o}const g0="https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",_0="Meta-schema for $data reference (JSON AnySchema extension proposal)",y0="object",v0=["$data"],$0={$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},w0=!1,b0={$id:g0,description:_0,type:y0,required:v0,properties:$0,additionalProperties:w0};var ni={},Zs={exports:{}};const S0=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),Xd=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),si=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),ef=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),E0=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function tf(e){let t="",r=0,n=0;for(n=0;n=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n];break}for(n+=1;n=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n]}return t}const k0=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function fl(e){return e.length=0,!0}function P0(e,t,r){if(e.length){const n=tf(e);if(n!=="")t.push(n);else return r.error=!0,!1;e.length=0}return!0}function T0(e){let t=0;const r={error:!1,address:"",zone:""},n=[],s=[];let o=!1,a=!1,i=P0;for(let c=0;c7){r.error=!0;break}c>0&&e[c-1]===":"&&(o=!0),n.push(":");continue}else if(l==="%"){if(!i(s,n,r))break;i=fl}else{s.push(l);continue}}return s.length&&(i===fl?r.zone=s.join(""):a?n.push(s.join("")):n.push(tf(s))),r.address=n.join(""),r}function rf(e){if(R0(e,":")<2)return{host:e,isIPV6:!1};const t=T0(e);if(t.error)return{host:e,isIPV6:!1};{let r=t.address,n=t.address;return t.zone&&(r+="%"+t.zone,n+="%25"+t.zone),{host:r,isIPV6:!0,escapedHost:n}}}function R0(e,t){let r=0;for(let n=0;nC0[n])}function O0(e,t=!1){if(e.indexOf("%")===-1)return e;let r="";for(let n=0;n65535))return"URI port is malformed."}function $s(e,t){const r=Object.assign({},t),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0};let s=!1,o=!1;r.reference==="suffix"&&(r.scheme?e=r.scheme+":"+e:e="//"+e);const a=e.match(lb);a!==null&&a[1].indexOf("\\")!==-1&&(n.error="URI authority must not contain a literal backslash.",s=!0);const i=e.match(ub);if(i!==null){const l=i[1],d=l.replace(/[\t\n\r]/g,"");d.length>=2&&(d.slice(0,2)!=="//"?(n.error=n.error||"URI authority must not contain a literal backslash.",s=!0):l.length!==d.length&&(n.error=n.error||"URI authority introducer must not contain whitespace.",s=!0))}const c=e.match(cb);if(c){n.scheme=c[1],n.userinfo=c[3],n.host=c[4],n.port=parseInt(c[5],10),n.path=c[6]||"",n.query=c[7],n.fragment=c[8],isNaN(n.port)&&(n.port=c[5]);const l=db(n,c);if(l!==void 0&&(n.error=n.error||l,s=!0),n.host)if(rb(n.host)===!1){const _=J0(n.host);n.host=_.host.toLowerCase(),o=_.isIPV6}else o=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");const d=uf(r.scheme||n.scheme);if(!r.unicodeSupport&&(!d||!d.unicodeSupport)&&n.host&&(r.domainHost||d&&d.domainHost)&&o===!1&&nb(n.host))try{n.host=new URL("http://"+n.host).hostname}catch(f){n.error=n.error||"Host's domain name can not be converted to ASCII: "+f}if((!d||d&&!d.skipNormalize)&&(e.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=tb(unescape(n.host),o))),n.path&&(n.path=X0(n.path)),n.fragment))try{n.fragment=encodeURI(decodeURIComponent(n.fragment))}catch{n.error=n.error||"URI malformed"}d&&d.parse&&d.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return{parsed:n,malformedAuthorityOrPort:s}}function ws(e,t){return $s(e,t).parsed}function fb(e,t){return ff(e,t).normalized}function ff(e,t){const{parsed:r,malformedAuthorityOrPort:n}=$s(e,t);return{normalized:n?e:gr(r,t),malformedAuthorityOrPort:n}}function hl(e,t){if(typeof e=="string"){const{normalized:r,malformedAuthorityOrPort:n}=ff(e,t);return n?void 0:r}if(typeof e=="object")return gr(e,t)}const ai={SCHEMES:sb,normalize:ob,resolve:ab,resolveComponent:df,equal:ib,serialize:gr,parse:ws};Zs.exports=ai;Zs.exports.default=ai;Zs.exports.fastUri=ai;var hf=Zs.exports;Object.defineProperty(ni,"__esModule",{value:!0});const pf=hf;pf.code='require("ajv/dist/runtime/uri").default';ni.default=pf;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=gt;Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var r=fe;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return r.CodeGen}});const n=Mn,s=Hr,o=mr,a=Qe,i=fe,c=Ue,l=Oe,d=V,f=b0,_=ni,y=(N,w)=>new RegExp(N,w);y.code="new RegExp";const g=["removeAdditional","useDefaults","coerceTypes"],$=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),m={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."},h={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},v=200;function k(N){var w,j,b,u,p,P,M,z,J,G,he,et,Lt,Vt,Ht,Zt,Kt,Gt,Wt,Bt,Jt,Qt,Yt,Xt,er;const ct=N.strict,tr=(w=N.code)===null||w===void 0?void 0:w.optimize,Jr=tr===!0||tr===void 0?1:tr||0,Qr=(b=(j=N.code)===null||j===void 0?void 0:j.regExp)!==null&&b!==void 0?b:y,Xs=(u=N.uriResolver)!==null&&u!==void 0?u:_.default;return{strictSchema:(P=(p=N.strictSchema)!==null&&p!==void 0?p:ct)!==null&&P!==void 0?P:!0,strictNumbers:(z=(M=N.strictNumbers)!==null&&M!==void 0?M:ct)!==null&&z!==void 0?z:!0,strictTypes:(G=(J=N.strictTypes)!==null&&J!==void 0?J:ct)!==null&&G!==void 0?G:"log",strictTuples:(et=(he=N.strictTuples)!==null&&he!==void 0?he:ct)!==null&&et!==void 0?et:"log",strictRequired:(Vt=(Lt=N.strictRequired)!==null&&Lt!==void 0?Lt:ct)!==null&&Vt!==void 0?Vt:!1,code:N.code?{...N.code,optimize:Jr,regExp:Qr}:{optimize:Jr,regExp:Qr},loopRequired:(Ht=N.loopRequired)!==null&&Ht!==void 0?Ht:v,loopEnum:(Zt=N.loopEnum)!==null&&Zt!==void 0?Zt:v,meta:(Kt=N.meta)!==null&&Kt!==void 0?Kt:!0,messages:(Gt=N.messages)!==null&&Gt!==void 0?Gt:!0,inlineRefs:(Wt=N.inlineRefs)!==null&&Wt!==void 0?Wt:!0,schemaId:(Bt=N.schemaId)!==null&&Bt!==void 0?Bt:"$id",addUsedSchema:(Jt=N.addUsedSchema)!==null&&Jt!==void 0?Jt:!0,validateSchema:(Qt=N.validateSchema)!==null&&Qt!==void 0?Qt:!0,validateFormats:(Yt=N.validateFormats)!==null&&Yt!==void 0?Yt:!0,unicodeRegExp:(Xt=N.unicodeRegExp)!==null&&Xt!==void 0?Xt:!0,int32range:(er=N.int32range)!==null&&er!==void 0?er:!0,uriResolver:Xs}}class R{constructor(w={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,w=this.opts={...w,...k(w)};const{es5:j,lines:b}=this.opts.code;this.scope=new i.ValueScope({scope:{},prefixes:$,es5:j,lines:b}),this.logger=B(w.logger);const u=w.validateFormats;w.validateFormats=!1,this.RULES=(0,o.getRules)(),E.call(this,m,w,"NOT SUPPORTED"),E.call(this,h,w,"DEPRECATED","warn"),this._metaOpts=D.call(this),w.formats&&q.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),w.keywords&&Z.call(this,w.keywords),typeof w.meta=="object"&&this.addMetaSchema(w.meta),x.call(this),w.validateFormats=u}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:w,meta:j,schemaId:b}=this.opts;let u=f;b==="id"&&(u={...f},u.id=u.$id,delete u.$id),j&&w&&this.addMetaSchema(u,u[b],!1)}defaultMeta(){const{meta:w,schemaId:j}=this.opts;return this.opts.defaultMeta=typeof w=="object"?w[j]||w:void 0}validate(w,j){let b;if(typeof w=="string"){if(b=this.getSchema(w),!b)throw new Error(`no schema with key or ref "${w}"`)}else b=this.compile(w);const u=b(j);return"$async"in b||(this.errors=b.errors),u}compile(w,j){const b=this._addSchema(w,j);return b.validate||this._compileSchemaEnv(b)}compileAsync(w,j){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");const{loadSchema:b}=this.opts;return u.call(this,w,j);async function u(G,he){await p.call(this,G.$schema);const et=this._addSchema(G,he);return et.validate||P.call(this,et)}async function p(G){G&&!this.getSchema(G)&&await u.call(this,{$ref:G},!0)}async function P(G){try{return this._compileSchemaEnv(G)}catch(he){if(!(he instanceof s.default))throw he;return M.call(this,he),await z.call(this,he.missingSchema),P.call(this,G)}}function M({missingSchema:G,missingRef:he}){if(this.refs[G])throw new Error(`AnySchema ${G} is loaded but ${he} cannot be resolved`)}async function z(G){const he=await J.call(this,G);this.refs[G]||await p.call(this,he.$schema),this.refs[G]||this.addSchema(he,G,j)}async function J(G){const he=this._loading[G];if(he)return he;try{return await(this._loading[G]=b(G))}finally{delete this._loading[G]}}}addSchema(w,j,b,u=this.opts.validateSchema){if(Array.isArray(w)){for(const P of w)this.addSchema(P,void 0,b,u);return this}let p;if(typeof w=="object"){const{schemaId:P}=this.opts;if(p=w[P],p!==void 0&&typeof p!="string")throw new Error(`schema ${P} must be string`)}return j=(0,c.normalizeId)(j||p),this._checkUnique(j),this.schemas[j]=this._addSchema(w,b,j,u,!0),this}addMetaSchema(w,j,b=this.opts.validateSchema){return this.addSchema(w,j,!0,b),this}validateSchema(w,j){if(typeof w=="boolean")return!0;let b;if(b=w.$schema,b!==void 0&&typeof b!="string")throw new Error("$schema must be a string");if(b=b||this.opts.defaultMeta||this.defaultMeta(),!b)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const u=this.validate(b,w);if(!u&&j){const p="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(p);else throw new Error(p)}return u}getSchema(w){let j;for(;typeof(j=I.call(this,w))=="string";)w=j;if(j===void 0){const{schemaId:b}=this.opts,u=new a.SchemaEnv({schema:{},schemaId:b});if(j=a.resolveSchema.call(this,u,w),!j)return;this.refs[w]=j}return j.validate||this._compileSchemaEnv(j)}removeSchema(w){if(w instanceof RegExp)return this._removeAllSchemas(this.schemas,w),this._removeAllSchemas(this.refs,w),this;switch(typeof w){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const j=I.call(this,w);return typeof j=="object"&&this._cache.delete(j.schema),delete this.schemas[w],delete this.refs[w],this}case"object":{const j=w;this._cache.delete(j);let b=w[this.opts.schemaId];return b&&(b=(0,c.normalizeId)(b),delete this.schemas[b],delete this.refs[b]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(w){for(const j of w)this.addKeyword(j);return this}addKeyword(w,j){let b;if(typeof w=="string")b=w,typeof j=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),j.keyword=b);else if(typeof w=="object"&&j===void 0){if(j=w,b=j.keyword,Array.isArray(b)&&!b.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(U.call(this,b,j),!j)return(0,d.eachItem)(b,p=>le.call(this,p)),this;_e.call(this,j);const u={...j,type:(0,l.getJSONTypes)(j.type),schemaType:(0,l.getJSONTypes)(j.schemaType)};return(0,d.eachItem)(b,u.type.length===0?p=>le.call(this,p,u):p=>u.type.forEach(P=>le.call(this,p,u,P))),this}getKeyword(w){const j=this.RULES.all[w];return typeof j=="object"?j.definition:!!j}removeKeyword(w){const{RULES:j}=this;delete j.keywords[w],delete j.all[w];for(const b of j.rules){const u=b.rules.findIndex(p=>p.keyword===w);u>=0&&b.rules.splice(u,1)}return this}addFormat(w,j){return typeof j=="string"&&(j=new RegExp(j)),this.formats[w]=j,this}errorsText(w=this.errors,{separator:j=", ",dataVar:b="data"}={}){return!w||w.length===0?"No errors":w.map(u=>`${b}${u.instancePath} ${u.message}`).reduce((u,p)=>u+j+p)}$dataMetaSchema(w,j){const b=this.RULES.all;w=JSON.parse(JSON.stringify(w));for(const u of j){const p=u.split("/").slice(1);let P=w;for(const M of p)P=P[M];for(const M in b){const z=b[M];if(typeof z!="object")continue;const{$data:J}=z.definition,G=P[M];J&&G&&(P[M]=Ie(G))}}return w}_removeAllSchemas(w,j){for(const b in w){const u=w[b];(!j||j.test(b))&&(typeof u=="string"?delete w[b]:u&&!u.meta&&(this._cache.delete(u.schema),delete w[b]))}}_addSchema(w,j,b,u=this.opts.validateSchema,p=this.opts.addUsedSchema){let P;const{schemaId:M}=this.opts;if(typeof w=="object")P=w[M];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof w!="boolean")throw new Error("schema must be object or boolean")}let z=this._cache.get(w);if(z!==void 0)return z;b=(0,c.normalizeId)(P||b);const J=c.getSchemaRefs.call(this,w,b);return z=new a.SchemaEnv({schema:w,schemaId:M,meta:j,baseId:b,localRefs:J}),this._cache.set(z.schema,z),p&&!b.startsWith("#")&&(b&&this._checkUnique(b),this.refs[b]=z),u&&this.validateSchema(w,!0),z}_checkUnique(w){if(this.schemas[w]||this.refs[w])throw new Error(`schema with key or id "${w}" already exists`)}_compileSchemaEnv(w){if(w.meta?this._compileMetaSchema(w):a.compileSchema.call(this,w),!w.validate)throw new Error("ajv implementation error");return w.validate}_compileMetaSchema(w){const j=this.opts;this.opts=this._metaOpts;try{a.compileSchema.call(this,w)}finally{this.opts=j}}}R.ValidationError=n.default,R.MissingRefError=s.default,e.default=R;function E(N,w,j,b="error"){for(const u in N){const p=u;p in w&&this.logger[b](`${j}: option ${u}. ${N[p]}`)}}function I(N){return N=(0,c.normalizeId)(N),this.schemas[N]||this.refs[N]}function x(){const N=this.opts.schemas;if(N)if(Array.isArray(N))this.addSchema(N);else for(const w in N)this.addSchema(N[w],w)}function q(){for(const N in this.opts.formats){const w=this.opts.formats[N];w&&this.addFormat(N,w)}}function Z(N){if(Array.isArray(N)){this.addVocabulary(N);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const w in N){const j=N[w];j.keyword||(j.keyword=w),this.addKeyword(j)}}function D(){const N={...this.opts};for(const w of g)delete N[w];return N}const L={log(){},warn(){},error(){}};function B(N){if(N===!1)return L;if(N===void 0)return console;if(N.log&&N.warn&&N.error)return N;throw new Error("logger must implement log, warn and error methods")}const ce=/^[a-z_$][a-z0-9_$:-]*$/i;function U(N,w){const{RULES:j}=this;if((0,d.eachItem)(N,b=>{if(j.keywords[b])throw new Error(`Keyword ${b} is already defined`);if(!ce.test(b))throw new Error(`Keyword ${b} has invalid name`)}),!!w&&w.$data&&!("code"in w||"validate"in w))throw new Error('$data keyword must have "code" or "validate" function')}function le(N,w,j){var b;const u=w==null?void 0:w.post;if(j&&u)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:p}=this;let P=u?p.post:p.rules.find(({type:z})=>z===j);if(P||(P={type:j,rules:[]},p.rules.push(P)),p.keywords[N]=!0,!w)return;const M={keyword:N,definition:{...w,type:(0,l.getJSONTypes)(w.type),schemaType:(0,l.getJSONTypes)(w.schemaType)}};w.before?je.call(this,P,M,w.before):P.rules.push(M),p.all[N]=M,(b=w.implements)===null||b===void 0||b.forEach(z=>this.addKeyword(z))}function je(N,w,j){const b=N.rules.findIndex(u=>u.keyword===j);b>=0?N.rules.splice(b,0,w):(N.rules.push(w),this.logger.warn(`rule ${j} is not defined`))}function _e(N){let{metaSchema:w}=N;w!==void 0&&(N.$data&&this.opts.$data&&(w=Ie(w)),N.validateSchema=this.compile(w,!0))}const it={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Ie(N){return{anyOf:[N,it]}}})(wd);var ii={},ci={},li={};Object.defineProperty(li,"__esModule",{value:!0});const hb={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};li.default=hb;var _r={};Object.defineProperty(_r,"__esModule",{value:!0});_r.callRef=_r.getValidate=void 0;const pb=Hr,pl=ue,Be=fe,Sr=St,ml=Qe,Zn=V,mb={keyword:"$ref",schemaType:"string",code(e){const{gen:t,schema:r,it:n}=e,{baseId:s,schemaEnv:o,validateName:a,opts:i,self:c}=n,{root:l}=o;if((r==="#"||r==="#/")&&s===l.baseId)return f();const d=ml.resolveRef.call(c,l,s,r);if(d===void 0)throw new pb.default(n.opts.uriResolver,s,r);if(d instanceof ml.SchemaEnv)return _(d);return y(d);function f(){if(o===l)return os(e,a,o,o.$async);const g=t.scopeValue("root",{ref:l});return os(e,(0,Be._)`${g}.validate`,l,l.$async)}function _(g){const $=mf(e,g);os(e,$,g,g.$async)}function y(g){const $=t.scopeValue("schema",i.code.source===!0?{ref:g,code:(0,Be.stringify)(g)}:{ref:g}),m=t.name("valid"),h=e.subschema({schema:g,dataTypes:[],schemaPath:Be.nil,topSchemaRef:$,errSchemaPath:r},m);e.mergeEvaluated(h),e.ok(m)}}};function mf(e,t){const{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,Be._)`${r.scopeValue("wrapper",{ref:t})}.validate`}_r.getValidate=mf;function os(e,t,r,n){const{gen:s,it:o}=e,{allErrors:a,schemaEnv:i,opts:c}=o,l=c.passContext?Sr.default.this:Be.nil;n?d():f();function d(){if(!i.$async)throw new Error("async schema referenced by sync schema");const g=s.let("valid");s.try(()=>{s.code((0,Be._)`await ${(0,pl.callValidateCode)(e,t,l)}`),y(t),a||s.assign(g,!0)},$=>{s.if((0,Be._)`!(${$} instanceof ${o.ValidationError})`,()=>s.throw($)),_($),a||s.assign(g,!1)}),e.ok(g)}function f(){e.result((0,pl.callValidateCode)(e,t,l),()=>y(t),()=>_(t))}function _(g){const $=(0,Be._)`${g}.errors`;s.assign(Sr.default.vErrors,(0,Be._)`${Sr.default.vErrors} === null ? ${$} : ${Sr.default.vErrors}.concat(${$})`),s.assign(Sr.default.errors,(0,Be._)`${Sr.default.vErrors}.length`)}function y(g){var $;if(!o.opts.unevaluated)return;const m=($=r==null?void 0:r.validate)===null||$===void 0?void 0:$.evaluated;if(o.props!==!0)if(m&&!m.dynamicProps)m.props!==void 0&&(o.props=Zn.mergeEvaluated.props(s,m.props,o.props));else{const h=s.var("props",(0,Be._)`${g}.evaluated.props`);o.props=Zn.mergeEvaluated.props(s,h,o.props,Be.Name)}if(o.items!==!0)if(m&&!m.dynamicItems)m.items!==void 0&&(o.items=Zn.mergeEvaluated.items(s,m.items,o.items));else{const h=s.var("items",(0,Be._)`${g}.evaluated.items`);o.items=Zn.mergeEvaluated.items(s,h,o.items,Be.Name)}}}_r.callRef=os;_r.default=mb;Object.defineProperty(ci,"__esModule",{value:!0});const gb=li,_b=_r,yb=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",gb.default,_b.default];ci.default=yb;var ui={},di={};Object.defineProperty(di,"__esModule",{value:!0});const bs=fe,Ct=bs.operators,Ss={maximum:{okStr:"<=",ok:Ct.LTE,fail:Ct.GT},minimum:{okStr:">=",ok:Ct.GTE,fail:Ct.LT},exclusiveMaximum:{okStr:"<",ok:Ct.LT,fail:Ct.GTE},exclusiveMinimum:{okStr:">",ok:Ct.GT,fail:Ct.LTE}},vb={message:({keyword:e,schemaCode:t})=>(0,bs.str)`must be ${Ss[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,bs._)`{comparison: ${Ss[e].okStr}, limit: ${t}}`},$b={keyword:Object.keys(Ss),type:"number",schemaType:"number",$data:!0,error:vb,code(e){const{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,bs._)`${r} ${Ss[t].fail} ${n} || isNaN(${r})`)}};di.default=$b;var fi={};Object.defineProperty(fi,"__esModule",{value:!0});const un=fe,wb={message:({schemaCode:e})=>(0,un.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,un._)`{multipleOf: ${e}}`},bb={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:wb,code(e){const{gen:t,data:r,schemaCode:n,it:s}=e,o=s.opts.multipleOfPrecision,a=t.let("res"),i=o?(0,un._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${o}`:(0,un._)`${a} !== parseInt(${a})`;e.fail$data((0,un._)`(${n} === 0 || (${a} = ${r}/${n}, ${i}))`)}};fi.default=bb;var hi={},pi={};Object.defineProperty(pi,"__esModule",{value:!0});function gf(e){const t=e.length;let r=0,n=0,s;for(;n=55296&&s<=56319&&n(0,cr._)`{limit: ${e}}`},Pb={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:kb,code(e){const{keyword:t,data:r,schemaCode:n,it:s}=e,o=t==="maxLength"?cr.operators.GT:cr.operators.LT,a=s.opts.unicode===!1?(0,cr._)`${r}.length`:(0,cr._)`${(0,Sb.useFunc)(e.gen,Eb.default)}(${r})`;e.fail$data((0,cr._)`${a} ${o} ${n}`)}};hi.default=Pb;var mi={};Object.defineProperty(mi,"__esModule",{value:!0});const Tb=ue,Rb=V,Nr=fe,jb={message:({schemaCode:e})=>(0,Nr.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Nr._)`{pattern: ${e}}`},Cb={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:jb,code(e){const{gen:t,data:r,$data:n,schema:s,schemaCode:o,it:a}=e,i=a.opts.unicodeRegExp?"u":"";if(n){const{regExp:c}=a.opts.code,l=c.code==="new RegExp"?(0,Nr._)`new RegExp`:(0,Rb.useFunc)(t,c),d=t.let("valid");t.try(()=>t.assign(d,(0,Nr._)`${l}(${o}, ${i}).test(${r})`),()=>t.assign(d,!1)),e.fail$data((0,Nr._)`!${d}`)}else{const c=(0,Tb.usePattern)(e,s);e.fail$data((0,Nr._)`!${c}.test(${r})`)}}};mi.default=Cb;var gi={};Object.defineProperty(gi,"__esModule",{value:!0});const dn=fe,Nb={message({keyword:e,schemaCode:t}){const r=e==="maxProperties"?"more":"fewer";return(0,dn.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,dn._)`{limit: ${e}}`},Ib={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:Nb,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxProperties"?dn.operators.GT:dn.operators.LT;e.fail$data((0,dn._)`Object.keys(${r}).length ${s} ${n}`)}};gi.default=Ib;var _i={};Object.defineProperty(_i,"__esModule",{value:!0});const en=ue,fn=fe,Ob=V,xb={message:({params:{missingProperty:e}})=>(0,fn.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,fn._)`{missingProperty: ${e}}`},Ab={keyword:"required",type:"object",schemaType:"array",$data:!0,error:xb,code(e){const{gen:t,schema:r,schemaCode:n,data:s,$data:o,it:a}=e,{opts:i}=a;if(!o&&r.length===0)return;const c=r.length>=i.loopRequired;if(a.allErrors?l():d(),i.strictRequired){const y=e.parentSchema.properties,{definedProperties:g}=e.it;for(const $ of r)if((y==null?void 0:y[$])===void 0&&!g.has($)){const m=a.schemaEnv.baseId+a.errSchemaPath,h=`required property "${$}" is not defined at "${m}" (strictRequired)`;(0,Ob.checkStrictMode)(a,h,a.opts.strictRequired)}}function l(){if(c||o)e.block$data(fn.nil,f);else for(const y of r)(0,en.checkReportMissingProp)(e,y)}function d(){const y=t.let("missing");if(c||o){const g=t.let("valid",!0);e.block$data(g,()=>_(y,g)),e.ok(g)}else t.if((0,en.checkMissingProp)(e,r,y)),(0,en.reportMissingProp)(e,y),t.else()}function f(){t.forOf("prop",n,y=>{e.setParams({missingProperty:y}),t.if((0,en.noPropertyInData)(t,s,y,i.ownProperties),()=>e.error())})}function _(y,g){e.setParams({missingProperty:y}),t.forOf(y,n,()=>{t.assign(g,(0,en.propertyInData)(t,s,y,i.ownProperties)),t.if((0,fn.not)(g),()=>{e.error(),t.break()})},fn.nil)}}};_i.default=Ab;var yi={};Object.defineProperty(yi,"__esModule",{value:!0});const hn=fe,Mb={message({keyword:e,schemaCode:t}){const r=e==="maxItems"?"more":"fewer";return(0,hn.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,hn._)`{limit: ${e}}`},zb={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:Mb,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxItems"?hn.operators.GT:hn.operators.LT;e.fail$data((0,hn._)`${r}.length ${s} ${n}`)}};yi.default=zb;var vi={},zn={};Object.defineProperty(zn,"__esModule",{value:!0});const _f=Ls;_f.code='require("ajv/dist/runtime/equal").default';zn.default=_f;Object.defineProperty(vi,"__esModule",{value:!0});const ao=Oe,ze=fe,Db=V,qb=zn,Ub={message:({params:{i:e,j:t}})=>(0,ze.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,ze._)`{i: ${e}, j: ${t}}`},Fb={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:Ub,code(e){const{gen:t,data:r,$data:n,schema:s,parentSchema:o,schemaCode:a,it:i}=e;if(!n&&!s)return;const c=t.let("valid"),l=o.items?(0,ao.getSchemaTypes)(o.items):[];e.block$data(c,d,(0,ze._)`${a} === false`),e.ok(c);function d(){const g=t.let("i",(0,ze._)`${r}.length`),$=t.let("j");e.setParams({i:g,j:$}),t.assign(c,!0),t.if((0,ze._)`${g} > 1`,()=>(f()?_:y)(g,$))}function f(){return l.length>0&&!l.some(g=>g==="object"||g==="array")}function _(g,$){const m=t.name("item"),h=(0,ao.checkDataTypes)(l,m,i.opts.strictNumbers,ao.DataType.Wrong),v=t.const("indices",(0,ze._)`{}`);t.for((0,ze._)`;${g}--;`,()=>{t.let(m,(0,ze._)`${r}[${g}]`),t.if(h,(0,ze._)`continue`),l.length>1&&t.if((0,ze._)`typeof ${m} == "string"`,(0,ze._)`${m} += "_"`),t.if((0,ze._)`typeof ${v}[${m}] == "number"`,()=>{t.assign($,(0,ze._)`${v}[${m}]`),e.error(),t.assign(c,!1).break()}).code((0,ze._)`${v}[${m}] = ${g}`)})}function y(g,$){const m=(0,Db.useFunc)(t,qb.default),h=t.name("outer");t.label(h).for((0,ze._)`;${g}--;`,()=>t.for((0,ze._)`${$} = ${g}; ${$}--;`,()=>t.if((0,ze._)`${m}(${r}[${g}], ${r}[${$}])`,()=>{e.error(),t.assign(c,!1).break(h)})))}}};vi.default=Fb;var $i={};Object.defineProperty($i,"__esModule",{value:!0});const xo=fe,Lb=V,Vb=zn,Hb={message:"must be equal to constant",params:({schemaCode:e})=>(0,xo._)`{allowedValue: ${e}}`},Zb={keyword:"const",$data:!0,error:Hb,code(e){const{gen:t,data:r,$data:n,schemaCode:s,schema:o}=e;n||o&&typeof o=="object"?e.fail$data((0,xo._)`!${(0,Lb.useFunc)(t,Vb.default)}(${r}, ${s})`):e.fail((0,xo._)`${o} !== ${r}`)}};$i.default=Zb;var wi={};Object.defineProperty(wi,"__esModule",{value:!0});const on=fe,Kb=V,Gb=zn,Wb={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,on._)`{allowedValues: ${e}}`},Bb={keyword:"enum",schemaType:"array",$data:!0,error:Wb,code(e){const{gen:t,data:r,$data:n,schema:s,schemaCode:o,it:a}=e;if(!n&&s.length===0)throw new Error("enum must have non-empty array");const i=s.length>=a.opts.loopEnum;let c;const l=()=>c??(c=(0,Kb.useFunc)(t,Gb.default));let d;if(i||n)d=t.let("valid"),e.block$data(d,f);else{if(!Array.isArray(s))throw new Error("ajv implementation error");const y=t.const("vSchema",o);d=(0,on.or)(...s.map((g,$)=>_(y,$)))}e.pass(d);function f(){t.assign(d,!1),t.forOf("v",o,y=>t.if((0,on._)`${l()}(${r}, ${y})`,()=>t.assign(d,!0).break()))}function _(y,g){const $=s[g];return typeof $=="object"&&$!==null?(0,on._)`${l()}(${r}, ${y}[${g}])`:(0,on._)`${r} === ${$}`}}};wi.default=Bb;Object.defineProperty(ui,"__esModule",{value:!0});const Jb=di,Qb=fi,Yb=hi,Xb=mi,eS=gi,tS=_i,rS=yi,nS=vi,sS=$i,oS=wi,aS=[Jb.default,Qb.default,Yb.default,Xb.default,eS.default,tS.default,rS.default,nS.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},sS.default,oS.default];ui.default=aS;var bi={},Zr={};Object.defineProperty(Zr,"__esModule",{value:!0});Zr.validateAdditionalItems=void 0;const lr=fe,Ao=V,iS={message:({params:{len:e}})=>(0,lr.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,lr._)`{limit: ${e}}`},cS={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:iS,code(e){const{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,Ao.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}yf(e,n)}};function yf(e,t){const{gen:r,schema:n,data:s,keyword:o,it:a}=e;a.items=!0;const i=r.const("len",(0,lr._)`${s}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,lr._)`${i} <= ${t.length}`);else if(typeof n=="object"&&!(0,Ao.alwaysValidSchema)(a,n)){const l=r.var("valid",(0,lr._)`${i} <= ${t.length}`);r.if((0,lr.not)(l),()=>c(l)),e.ok(l)}function c(l){r.forRange("i",t.length,i,d=>{e.subschema({keyword:o,dataProp:d,dataPropType:Ao.Type.Num},l),a.allErrors||r.if((0,lr.not)(l),()=>r.break())})}}Zr.validateAdditionalItems=yf;Zr.default=cS;var Si={},Kr={};Object.defineProperty(Kr,"__esModule",{value:!0});Kr.validateTuple=void 0;const gl=fe,as=V,lS=ue,uS={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:t,it:r}=e;if(Array.isArray(t))return vf(e,"additionalItems",t);r.items=!0,!(0,as.alwaysValidSchema)(r,t)&&e.ok((0,lS.validateArray)(e))}};function vf(e,t,r=e.schema){const{gen:n,parentSchema:s,data:o,keyword:a,it:i}=e;d(s),i.opts.unevaluated&&r.length&&i.items!==!0&&(i.items=as.mergeEvaluated.items(n,r.length,i.items));const c=n.name("valid"),l=n.const("len",(0,gl._)`${o}.length`);r.forEach((f,_)=>{(0,as.alwaysValidSchema)(i,f)||(n.if((0,gl._)`${l} > ${_}`,()=>e.subschema({keyword:a,schemaProp:_,dataProp:_},c)),e.ok(c))});function d(f){const{opts:_,errSchemaPath:y}=i,g=r.length,$=g===f.minItems&&(g===f.maxItems||f[t]===!1);if(_.strictTuples&&!$){const m=`"${a}" is ${g}-tuple, but minItems or maxItems/${t} are not specified or different at path "${y}"`;(0,as.checkStrictMode)(i,m,_.strictTuples)}}}Kr.validateTuple=vf;Kr.default=uS;Object.defineProperty(Si,"__esModule",{value:!0});const dS=Kr,fS={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,dS.validateTuple)(e,"items")};Si.default=fS;var Ei={};Object.defineProperty(Ei,"__esModule",{value:!0});const _l=fe,hS=V,pS=ue,mS=Zr,gS={message:({params:{len:e}})=>(0,_l.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,_l._)`{limit: ${e}}`},_S={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:gS,code(e){const{schema:t,parentSchema:r,it:n}=e,{prefixItems:s}=r;n.items=!0,!(0,hS.alwaysValidSchema)(n,t)&&(s?(0,mS.validateAdditionalItems)(e,s):e.ok((0,pS.validateArray)(e)))}};Ei.default=_S;var ki={};Object.defineProperty(ki,"__esModule",{value:!0});const nt=fe,Kn=V,yS={message:({params:{min:e,max:t}})=>t===void 0?(0,nt.str)`must contain at least ${e} valid item(s)`:(0,nt.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,nt._)`{minContains: ${e}}`:(0,nt._)`{minContains: ${e}, maxContains: ${t}}`},vS={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:yS,code(e){const{gen:t,schema:r,parentSchema:n,data:s,it:o}=e;let a,i;const{minContains:c,maxContains:l}=n;o.opts.next?(a=c===void 0?1:c,i=l):a=1;const d=t.const("len",(0,nt._)`${s}.length`);if(e.setParams({min:a,max:i}),i===void 0&&a===0){(0,Kn.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(i!==void 0&&a>i){(0,Kn.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,Kn.alwaysValidSchema)(o,r)){let $=(0,nt._)`${d} >= ${a}`;i!==void 0&&($=(0,nt._)`${$} && ${d} <= ${i}`),e.pass($);return}o.items=!0;const f=t.name("valid");i===void 0&&a===1?y(f,()=>t.if(f,()=>t.break())):a===0?(t.let(f,!0),i!==void 0&&t.if((0,nt._)`${s}.length > 0`,_)):(t.let(f,!1),_()),e.result(f,()=>e.reset());function _(){const $=t.name("_valid"),m=t.let("count",0);y($,()=>t.if($,()=>g(m)))}function y($,m){t.forRange("i",0,d,h=>{e.subschema({keyword:"contains",dataProp:h,dataPropType:Kn.Type.Num,compositeRule:!0},$),m()})}function g($){t.code((0,nt._)`${$}++`),i===void 0?t.if((0,nt._)`${$} >= ${a}`,()=>t.assign(f,!0).break()):(t.if((0,nt._)`${$} > ${i}`,()=>t.assign(f,!1).break()),a===1?t.assign(f,!0):t.if((0,nt._)`${$} >= ${a}`,()=>t.assign(f,!0)))}}};ki.default=vS;var $f={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;const t=fe,r=V,n=ue;e.error={message:({params:{property:c,depsCount:l,deps:d}})=>{const f=l===1?"property":"properties";return(0,t.str)`must have ${f} ${d} when property ${c} is present`},params:({params:{property:c,depsCount:l,deps:d,missingProperty:f}})=>(0,t._)`{property: ${c}, + missingProperty: ${f}, + depsCount: ${l}, + deps: ${d}}`};const s={keyword:"dependencies",type:"object",schemaType:"object",error:e.error,code(c){const[l,d]=o(c);a(c,l),i(c,d)}};function o({schema:c}){const l={},d={};for(const f in c){if(f==="__proto__")continue;const _=Array.isArray(c[f])?l:d;_[f]=c[f]}return[l,d]}function a(c,l=c.schema){const{gen:d,data:f,it:_}=c;if(Object.keys(l).length===0)return;const y=d.let("missing");for(const g in l){const $=l[g];if($.length===0)continue;const m=(0,n.propertyInData)(d,f,g,_.opts.ownProperties);c.setParams({property:g,depsCount:$.length,deps:$.join(", ")}),_.allErrors?d.if(m,()=>{for(const h of $)(0,n.checkReportMissingProp)(c,h)}):(d.if((0,t._)`${m} && (${(0,n.checkMissingProp)(c,$,y)})`),(0,n.reportMissingProp)(c,y),d.else())}}e.validatePropertyDeps=a;function i(c,l=c.schema){const{gen:d,data:f,keyword:_,it:y}=c,g=d.name("valid");for(const $ in l)(0,r.alwaysValidSchema)(y,l[$])||(d.if((0,n.propertyInData)(d,f,$,y.opts.ownProperties),()=>{const m=c.subschema({keyword:_,schemaProp:$},g);c.mergeValidEvaluated(m,g)},()=>d.var(g,!0)),c.ok(g))}e.validateSchemaDeps=i,e.default=s})($f);var Pi={};Object.defineProperty(Pi,"__esModule",{value:!0});const wf=fe,$S=V,wS={message:"property name must be valid",params:({params:e})=>(0,wf._)`{propertyName: ${e.propertyName}}`},bS={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:wS,code(e){const{gen:t,schema:r,data:n,it:s}=e;if((0,$S.alwaysValidSchema)(s,r))return;const o=t.name("valid");t.forIn("key",n,a=>{e.setParams({propertyName:a}),e.subschema({keyword:"propertyNames",data:a,dataTypes:["string"],propertyName:a,compositeRule:!0},o),t.if((0,wf.not)(o),()=>{e.error(!0),s.allErrors||t.break()})}),e.ok(o)}};Pi.default=bS;var Ks={};Object.defineProperty(Ks,"__esModule",{value:!0});const Gn=ue,dt=fe,SS=St,Wn=V,ES={message:"must NOT have additional properties",params:({params:e})=>(0,dt._)`{additionalProperty: ${e.additionalProperty}}`},kS={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:ES,code(e){const{gen:t,schema:r,parentSchema:n,data:s,errsCount:o,it:a}=e;if(!o)throw new Error("ajv implementation error");const{allErrors:i,opts:c}=a;if(a.props=!0,c.removeAdditional!=="all"&&(0,Wn.alwaysValidSchema)(a,r))return;const l=(0,Gn.allSchemaProperties)(n.properties),d=(0,Gn.allSchemaProperties)(n.patternProperties);f(),e.ok((0,dt._)`${o} === ${SS.default.errors}`);function f(){t.forIn("key",s,m=>{!l.length&&!d.length?g(m):t.if(_(m),()=>g(m))})}function _(m){let h;if(l.length>8){const v=(0,Wn.schemaRefOrVal)(a,n.properties,"properties");h=(0,Gn.isOwnProperty)(t,v,m)}else l.length?h=(0,dt.or)(...l.map(v=>(0,dt._)`${m} === ${v}`)):h=dt.nil;return d.length&&(h=(0,dt.or)(h,...d.map(v=>(0,dt._)`${(0,Gn.usePattern)(e,v)}.test(${m})`))),(0,dt.not)(h)}function y(m){t.code((0,dt._)`delete ${s}[${m}]`)}function g(m){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){y(m);return}if(r===!1){e.setParams({additionalProperty:m}),e.error(),i||t.break();return}if(typeof r=="object"&&!(0,Wn.alwaysValidSchema)(a,r)){const h=t.name("valid");c.removeAdditional==="failing"?($(m,h,!1),t.if((0,dt.not)(h),()=>{e.reset(),y(m)})):($(m,h),i||t.if((0,dt.not)(h),()=>t.break()))}}function $(m,h,v){const k={keyword:"additionalProperties",dataProp:m,dataPropType:Wn.Type.Str};v===!1&&Object.assign(k,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(k,h)}}};Ks.default=kS;var Ti={};Object.defineProperty(Ti,"__esModule",{value:!0});const PS=gt,yl=ue,io=V,vl=Ks,TS={keyword:"properties",type:"object",schemaType:"object",code(e){const{gen:t,schema:r,parentSchema:n,data:s,it:o}=e;o.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&vl.default.code(new PS.KeywordCxt(o,vl.default,"additionalProperties"));const a=(0,yl.allSchemaProperties)(r);for(const f of a)o.definedProperties.add(f);o.opts.unevaluated&&a.length&&o.props!==!0&&(o.props=io.mergeEvaluated.props(t,(0,io.toHash)(a),o.props));const i=a.filter(f=>!(0,io.alwaysValidSchema)(o,r[f]));if(i.length===0)return;const c=t.name("valid");for(const f of i)l(f)?d(f):(t.if((0,yl.propertyInData)(t,s,f,o.opts.ownProperties)),d(f),o.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(f),e.ok(c);function l(f){return o.opts.useDefaults&&!o.compositeRule&&r[f].default!==void 0}function d(f){e.subschema({keyword:"properties",schemaProp:f,dataProp:f},c)}}};Ti.default=TS;var Ri={};Object.defineProperty(Ri,"__esModule",{value:!0});const $l=ue,Bn=fe,wl=V,bl=V,RS={keyword:"patternProperties",type:"object",schemaType:"object",code(e){const{gen:t,schema:r,data:n,parentSchema:s,it:o}=e,{opts:a}=o,i=(0,$l.allSchemaProperties)(r),c=i.filter($=>(0,wl.alwaysValidSchema)(o,r[$]));if(i.length===0||c.length===i.length&&(!o.opts.unevaluated||o.props===!0))return;const l=a.strictSchema&&!a.allowMatchingProperties&&s.properties,d=t.name("valid");o.props!==!0&&!(o.props instanceof Bn.Name)&&(o.props=(0,bl.evaluatedPropsToName)(t,o.props));const{props:f}=o;_();function _(){for(const $ of i)l&&y($),o.allErrors?g($):(t.var(d,!0),g($),t.if(d))}function y($){for(const m in l)new RegExp($).test(m)&&(0,wl.checkStrictMode)(o,`property ${m} matches pattern ${$} (use allowMatchingProperties)`)}function g($){t.forIn("key",n,m=>{t.if((0,Bn._)`${(0,$l.usePattern)(e,$)}.test(${m})`,()=>{const h=c.includes($);h||e.subschema({keyword:"patternProperties",schemaProp:$,dataProp:m,dataPropType:bl.Type.Str},d),o.opts.unevaluated&&f!==!0?t.assign((0,Bn._)`${f}[${m}]`,!0):!h&&!o.allErrors&&t.if((0,Bn.not)(d),()=>t.break())})})}}};Ri.default=RS;var ji={};Object.defineProperty(ji,"__esModule",{value:!0});const jS=V,CS={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:r,it:n}=e;if((0,jS.alwaysValidSchema)(n,r)){e.fail();return}const s=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},s),e.failResult(s,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};ji.default=CS;var Ci={};Object.defineProperty(Ci,"__esModule",{value:!0});const NS=ue,IS={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:NS.validateUnion,error:{message:"must match a schema in anyOf"}};Ci.default=IS;var Ni={};Object.defineProperty(Ni,"__esModule",{value:!0});const is=fe,OS=V,xS={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,is._)`{passingSchemas: ${e.passing}}`},AS={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:xS,code(e){const{gen:t,schema:r,parentSchema:n,it:s}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(s.opts.discriminator&&n.discriminator)return;const o=r,a=t.let("valid",!1),i=t.let("passing",null),c=t.name("_valid");e.setParams({passing:i}),t.block(l),e.result(a,()=>e.reset(),()=>e.error(!0));function l(){o.forEach((d,f)=>{let _;(0,OS.alwaysValidSchema)(s,d)?t.var(c,!0):_=e.subschema({keyword:"oneOf",schemaProp:f,compositeRule:!0},c),f>0&&t.if((0,is._)`${c} && ${a}`).assign(a,!1).assign(i,(0,is._)`[${i}, ${f}]`).else(),t.if(c,()=>{t.assign(a,!0),t.assign(i,f),_&&e.mergeEvaluated(_,is.Name)})})}}};Ni.default=AS;var Ii={};Object.defineProperty(Ii,"__esModule",{value:!0});const MS=V,zS={keyword:"allOf",schemaType:"array",code(e){const{gen:t,schema:r,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");const s=t.name("valid");r.forEach((o,a)=>{if((0,MS.alwaysValidSchema)(n,o))return;const i=e.subschema({keyword:"allOf",schemaProp:a},s);e.ok(s),e.mergeEvaluated(i)})}};Ii.default=zS;var Oi={};Object.defineProperty(Oi,"__esModule",{value:!0});const Es=fe,bf=V,DS={message:({params:e})=>(0,Es.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,Es._)`{failingKeyword: ${e.ifClause}}`},qS={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:DS,code(e){const{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,bf.checkStrictMode)(n,'"if" without "then" and "else" is ignored');const s=Sl(n,"then"),o=Sl(n,"else");if(!s&&!o)return;const a=t.let("valid",!0),i=t.name("_valid");if(c(),e.reset(),s&&o){const d=t.let("ifClause");e.setParams({ifClause:d}),t.if(i,l("then",d),l("else",d))}else s?t.if(i,l("then")):t.if((0,Es.not)(i),l("else"));e.pass(a,()=>e.error(!0));function c(){const d=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},i);e.mergeEvaluated(d)}function l(d,f){return()=>{const _=e.subschema({keyword:d},i);t.assign(a,i),e.mergeValidEvaluated(_,a),f?t.assign(f,(0,Es._)`${d}`):e.setParams({ifClause:d})}}}};function Sl(e,t){const r=e.schema[t];return r!==void 0&&!(0,bf.alwaysValidSchema)(e,r)}Oi.default=qS;var xi={};Object.defineProperty(xi,"__esModule",{value:!0});const US=V,FS={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,US.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};xi.default=FS;Object.defineProperty(bi,"__esModule",{value:!0});const LS=Zr,VS=Si,HS=Kr,ZS=Ei,KS=ki,GS=$f,WS=Pi,BS=Ks,JS=Ti,QS=Ri,YS=ji,XS=Ci,eE=Ni,tE=Ii,rE=Oi,nE=xi;function sE(e=!1){const t=[YS.default,XS.default,eE.default,tE.default,rE.default,nE.default,WS.default,BS.default,GS.default,JS.default,QS.default];return e?t.push(VS.default,ZS.default):t.push(LS.default,HS.default),t.push(KS.default),t}bi.default=sE;var Ai={},Mi={};Object.defineProperty(Mi,"__esModule",{value:!0});const Ce=fe,oE={message:({schemaCode:e})=>(0,Ce.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,Ce._)`{format: ${e}}`},aE={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:oE,code(e,t){const{gen:r,data:n,$data:s,schema:o,schemaCode:a,it:i}=e,{opts:c,errSchemaPath:l,schemaEnv:d,self:f}=i;if(!c.validateFormats)return;s?_():y();function _(){const g=r.scopeValue("formats",{ref:f.formats,code:c.code.formats}),$=r.const("fDef",(0,Ce._)`${g}[${a}]`),m=r.let("fType"),h=r.let("format");r.if((0,Ce._)`typeof ${$} == "object" && !(${$} instanceof RegExp)`,()=>r.assign(m,(0,Ce._)`${$}.type || "string"`).assign(h,(0,Ce._)`${$}.validate`),()=>r.assign(m,(0,Ce._)`"string"`).assign(h,$)),e.fail$data((0,Ce.or)(v(),k()));function v(){return c.strictSchema===!1?Ce.nil:(0,Ce._)`${a} && !${h}`}function k(){const R=d.$async?(0,Ce._)`(${$}.async ? await ${h}(${n}) : ${h}(${n}))`:(0,Ce._)`${h}(${n})`,E=(0,Ce._)`(typeof ${h} == "function" ? ${R} : ${h}.test(${n}))`;return(0,Ce._)`${h} && ${h} !== true && ${m} === ${t} && !${E}`}}function y(){const g=f.formats[o];if(!g){v();return}if(g===!0)return;const[$,m,h]=k(g);$===t&&e.pass(R());function v(){if(c.strictSchema===!1){f.logger.warn(E());return}throw new Error(E());function E(){return`unknown format "${o}" ignored in schema at path "${l}"`}}function k(E){const I=E instanceof RegExp?(0,Ce.regexpCode)(E):c.code.formats?(0,Ce._)`${c.code.formats}${(0,Ce.getProperty)(o)}`:void 0,x=r.scopeValue("formats",{key:o,ref:E,code:I});return typeof E=="object"&&!(E instanceof RegExp)?[E.type||"string",E.validate,(0,Ce._)`${x}.validate`]:["string",E,x]}function R(){if(typeof g=="object"&&!(g instanceof RegExp)&&g.async){if(!d.$async)throw new Error("async format in sync schema");return(0,Ce._)`await ${h}(${n})`}return typeof m=="function"?(0,Ce._)`${h}(${n})`:(0,Ce._)`${h}.test(${n})`}}}};Mi.default=aE;Object.defineProperty(Ai,"__esModule",{value:!0});const iE=Mi,cE=[iE.default];Ai.default=cE;var qr={};Object.defineProperty(qr,"__esModule",{value:!0});qr.contentVocabulary=qr.metadataVocabulary=void 0;qr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];qr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];Object.defineProperty(ii,"__esModule",{value:!0});const lE=ci,uE=ui,dE=bi,fE=Ai,El=qr,hE=[lE.default,uE.default,(0,dE.default)(),fE.default,El.metadataVocabulary,El.contentVocabulary];ii.default=hE;var zi={},Gs={};Object.defineProperty(Gs,"__esModule",{value:!0});Gs.DiscrError=void 0;var kl;(function(e){e.Tag="tag",e.Mapping="mapping"})(kl||(Gs.DiscrError=kl={}));Object.defineProperty(zi,"__esModule",{value:!0});const Rr=fe,Mo=Gs,Pl=Qe,pE=Hr,mE=V,gE={message:({params:{discrError:e,tagName:t}})=>e===Mo.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,Rr._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},_E={keyword:"discriminator",type:"object",schemaType:"object",error:gE,code(e){const{gen:t,data:r,schema:n,parentSchema:s,it:o}=e,{oneOf:a}=s;if(!o.opts.discriminator)throw new Error("discriminator: requires discriminator option");const i=n.propertyName;if(typeof i!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!a)throw new Error("discriminator: requires oneOf keyword");const c=t.let("valid",!1),l=t.const("tag",(0,Rr._)`${r}${(0,Rr.getProperty)(i)}`);t.if((0,Rr._)`typeof ${l} == "string"`,()=>d(),()=>e.error(!1,{discrError:Mo.DiscrError.Tag,tag:l,tagName:i})),e.ok(c);function d(){const y=_();t.if(!1);for(const g in y)t.elseIf((0,Rr._)`${l} === ${g}`),t.assign(c,f(y[g]));t.else(),e.error(!1,{discrError:Mo.DiscrError.Mapping,tag:l,tagName:i}),t.endIf()}function f(y){const g=t.name("valid"),$=e.subschema({keyword:"oneOf",schemaProp:y},g);return e.mergeEvaluated($,Rr.Name),g}function _(){var y;const g={},$=h(s);let m=!0;for(let R=0;Rthis.addVocabulary(g)),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const g=this.opts.$data?this.$dataMetaSchema(o,a):o;this.addMetaSchema(g,i,!1),this.refs["http://json-schema.org/schema"]=i}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(i)?i:void 0)}}t.Ajv=c,e.exports=t=c,e.exports.Ajv=c,Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var l=gt;Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return l.KeywordCxt}});var d=fe;Object.defineProperty(t,"_",{enumerable:!0,get:function(){return d._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return d.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return d.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return d.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return d.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return d.CodeGen}});var f=Mn;Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return f.default}});var _=Hr;Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return _.default}})})(jo,jo.exports);var kE=jo.exports;const PE=su(kE);var zo={exports:{}},Sf={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0;function t(L,B){return{validate:L,compare:B}}e.fullFormats={date:t(o,a),time:t(c(!0),l),"date-time":t(_(!0),y),"iso-time":t(c(),d),"iso-date-time":t(_(),g),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:h,"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:D,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:k,int32:{type:"number",validate:I},int64:{type:"number",validate:x},float:{type:"number",validate:q},double:{type:"number",validate:q},password:!0,binary:!0},e.fastFormats={...e.fullFormats,date:t(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,a),time:t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,l),"date-time":t(/^\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,y),"iso-time":t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,d),"iso-date-time":t(/^\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,g),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},e.formatNames=Object.keys(e.fullFormats);function r(L){return L%4===0&&(L%100!==0||L%400===0)}const n=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,s=[0,31,28,31,30,31,30,31,31,30,31,30,31];function o(L){const B=n.exec(L);if(!B)return!1;const ce=+B[1],U=+B[2],le=+B[3];return U>=1&&U<=12&&le>=1&&le<=(U===2&&r(ce)?29:s[U])}function a(L,B){if(L&&B)return L>B?1:L23||w>59||L&&!it)return!1;if(le<=23&&je<=59&&_e<60)return!0;const j=je-w*Ie,b=le-N*Ie-(j<0?1:0);return(b===23||b===-1)&&(j===59||j===-1)&&_e<61}}function l(L,B){if(!(L&&B))return;const ce=new Date("2020-01-01T"+L).valueOf(),U=new Date("2020-01-01T"+B).valueOf();if(ce&&U)return ce-U}function d(L,B){if(!(L&&B))return;const ce=i.exec(L),U=i.exec(B);if(ce&&U)return L=ce[1]+ce[2]+ce[3],B=U[1]+U[2]+U[3],L>B?1:L=R}function x(L){return Number.isInteger(L)}function q(){return!0}const Z=/[^\\]\\Z/;function D(L){if(Z.test(L))return!1;try{return new RegExp(L),!0}catch{return!1}}})(Sf);var Ef={},Do={exports:{}},kf={},_t={},Ur={},Dn={},ie={},En={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;class t{}e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class r extends t{constructor(v){if(super(),!e.IDENTIFIER.test(v))throw new Error("CodeGen: name must be a valid identifier");this.str=v}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}e.Name=r;class n extends t{constructor(v){super(),this._items=typeof v=="string"?[v]:v}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const v=this._items[0];return v===""||v==='""'}get str(){var v;return(v=this._str)!==null&&v!==void 0?v:this._str=this._items.reduce((k,R)=>`${k}${R}`,"")}get names(){var v;return(v=this._names)!==null&&v!==void 0?v:this._names=this._items.reduce((k,R)=>(R instanceof r&&(k[R.str]=(k[R.str]||0)+1),k),{})}}e._Code=n,e.nil=new n("");function s(h,...v){const k=[h[0]];let R=0;for(;R{if(f.scopePath===void 0)throw new Error(`CodeGen: name "${f}" has no value`);return(0,t._)`${l}${f.scopePath}`})}scopeCode(l=this._values,d,f){return this._reduceValues(l,_=>{if(_.value===void 0)throw new Error(`CodeGen: name "${_}" has no value`);return _.value.code},d,f)}_reduceValues(l,d,f={},_){let y=t.nil;for(const g in l){const $=l[g];if(!$)continue;const m=f[g]=f[g]||new Map;$.forEach(h=>{if(m.has(h))return;m.set(h,n.Started);let v=d(h);if(v){const k=this.opts.es5?e.varKinds.var:e.varKinds.const;y=(0,t._)`${y}${k} ${h} = ${v};${this.opts._n}`}else if(v=_==null?void 0:_(h))y=(0,t._)`${y}${v}${this.opts._n}`;else throw new r(h);m.set(h,n.Completed)})}return y}}e.ValueScope=i})(qo);(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;const t=En,r=qo;var n=En;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return n.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return n.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return n.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return n.Name}});var s=qo;Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return s.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return s.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return s.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return s.varKinds}}),e.operators={GT:new t._Code(">"),GTE:new t._Code(">="),LT:new t._Code("<"),LTE:new t._Code("<="),EQ:new t._Code("==="),NEQ:new t._Code("!=="),NOT:new t._Code("!"),OR:new t._Code("||"),AND:new t._Code("&&"),ADD:new t._Code("+")};class o{optimizeNodes(){return this}optimizeNames(u,p){return this}}class a extends o{constructor(u,p,P){super(),this.varKind=u,this.name=p,this.rhs=P}render({es5:u,_n:p}){const P=u?r.varKinds.var:this.varKind,M=this.rhs===void 0?"":` = ${this.rhs}`;return`${P} ${this.name}${M};`+p}optimizeNames(u,p){if(u[this.name.str])return this.rhs&&(this.rhs=U(this.rhs,u,p)),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}}class i extends o{constructor(u,p,P){super(),this.lhs=u,this.rhs=p,this.sideEffects=P}render({_n:u}){return`${this.lhs} = ${this.rhs};`+u}optimizeNames(u,p){if(!(this.lhs instanceof t.Name&&!u[this.lhs.str]&&!this.sideEffects))return this.rhs=U(this.rhs,u,p),this}get names(){const u=this.lhs instanceof t.Name?{}:{...this.lhs.names};return ce(u,this.rhs)}}class c extends i{constructor(u,p,P,M){super(u,P,M),this.op=p}render({_n:u}){return`${this.lhs} ${this.op}= ${this.rhs};`+u}}class l extends o{constructor(u){super(),this.label=u,this.names={}}render({_n:u}){return`${this.label}:`+u}}class d extends o{constructor(u){super(),this.label=u,this.names={}}render({_n:u}){return`break${this.label?` ${this.label}`:""};`+u}}class f extends o{constructor(u){super(),this.error=u}render({_n:u}){return`throw ${this.error};`+u}get names(){return this.error.names}}class _ extends o{constructor(u){super(),this.code=u}render({_n:u}){return`${this.code};`+u}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(u,p){return this.code=U(this.code,u,p),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}}class y extends o{constructor(u=[]){super(),this.nodes=u}render(u){return this.nodes.reduce((p,P)=>p+P.render(u),"")}optimizeNodes(){const{nodes:u}=this;let p=u.length;for(;p--;){const P=u[p].optimizeNodes();Array.isArray(P)?u.splice(p,1,...P):P?u[p]=P:u.splice(p,1)}return u.length>0?this:void 0}optimizeNames(u,p){const{nodes:P}=this;let M=P.length;for(;M--;){const z=P[M];z.optimizeNames(u,p)||(le(u,z.names),P.splice(M,1))}return P.length>0?this:void 0}get names(){return this.nodes.reduce((u,p)=>B(u,p.names),{})}}class g extends y{render(u){return"{"+u._n+super.render(u)+"}"+u._n}}class $ extends y{}class m extends g{}m.kind="else";class h extends g{constructor(u,p){super(p),this.condition=u}render(u){let p=`if(${this.condition})`+super.render(u);return this.else&&(p+="else "+this.else.render(u)),p}optimizeNodes(){super.optimizeNodes();const u=this.condition;if(u===!0)return this.nodes;let p=this.else;if(p){const P=p.optimizeNodes();p=this.else=Array.isArray(P)?new m(P):P}if(p)return u===!1?p instanceof h?p:p.nodes:this.nodes.length?this:new h(je(u),p instanceof h?[p]:p.nodes);if(!(u===!1||!this.nodes.length))return this}optimizeNames(u,p){var P;if(this.else=(P=this.else)===null||P===void 0?void 0:P.optimizeNames(u,p),!!(super.optimizeNames(u,p)||this.else))return this.condition=U(this.condition,u,p),this}get names(){const u=super.names;return ce(u,this.condition),this.else&&B(u,this.else.names),u}}h.kind="if";class v extends g{}v.kind="for";class k extends v{constructor(u){super(),this.iteration=u}render(u){return`for(${this.iteration})`+super.render(u)}optimizeNames(u,p){if(super.optimizeNames(u,p))return this.iteration=U(this.iteration,u,p),this}get names(){return B(super.names,this.iteration.names)}}class R extends v{constructor(u,p,P,M){super(),this.varKind=u,this.name=p,this.from=P,this.to=M}render(u){const p=u.es5?r.varKinds.var:this.varKind,{name:P,from:M,to:z}=this;return`for(${p} ${P}=${M}; ${P}<${z}; ${P}++)`+super.render(u)}get names(){const u=ce(super.names,this.from);return ce(u,this.to)}}class E extends v{constructor(u,p,P,M){super(),this.loop=u,this.varKind=p,this.name=P,this.iterable=M}render(u){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(u)}optimizeNames(u,p){if(super.optimizeNames(u,p))return this.iterable=U(this.iterable,u,p),this}get names(){return B(super.names,this.iterable.names)}}class I extends g{constructor(u,p,P){super(),this.name=u,this.args=p,this.async=P}render(u){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(u)}}I.kind="func";class x extends y{render(u){return"return "+super.render(u)}}x.kind="return";class q extends g{render(u){let p="try"+super.render(u);return this.catch&&(p+=this.catch.render(u)),this.finally&&(p+=this.finally.render(u)),p}optimizeNodes(){var u,p;return super.optimizeNodes(),(u=this.catch)===null||u===void 0||u.optimizeNodes(),(p=this.finally)===null||p===void 0||p.optimizeNodes(),this}optimizeNames(u,p){var P,M;return super.optimizeNames(u,p),(P=this.catch)===null||P===void 0||P.optimizeNames(u,p),(M=this.finally)===null||M===void 0||M.optimizeNames(u,p),this}get names(){const u=super.names;return this.catch&&B(u,this.catch.names),this.finally&&B(u,this.finally.names),u}}class Z extends g{constructor(u){super(),this.error=u}render(u){return`catch(${this.error})`+super.render(u)}}Z.kind="catch";class D extends g{render(u){return"finally"+super.render(u)}}D.kind="finally";class L{constructor(u,p={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...p,_n:p.lines?` +`:""},this._extScope=u,this._scope=new r.Scope({parent:u}),this._nodes=[new $]}toString(){return this._root.render(this.opts)}name(u){return this._scope.name(u)}scopeName(u){return this._extScope.name(u)}scopeValue(u,p){const P=this._extScope.value(u,p);return(this._values[P.prefix]||(this._values[P.prefix]=new Set)).add(P),P}getScopeValue(u,p){return this._extScope.getValue(u,p)}scopeRefs(u){return this._extScope.scopeRefs(u,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(u,p,P,M){const z=this._scope.toName(p);return P!==void 0&&M&&(this._constants[z.str]=P),this._leafNode(new a(u,z,P)),z}const(u,p,P){return this._def(r.varKinds.const,u,p,P)}let(u,p,P){return this._def(r.varKinds.let,u,p,P)}var(u,p,P){return this._def(r.varKinds.var,u,p,P)}assign(u,p,P){return this._leafNode(new i(u,p,P))}add(u,p){return this._leafNode(new c(u,e.operators.ADD,p))}code(u){return typeof u=="function"?u():u!==t.nil&&this._leafNode(new _(u)),this}object(...u){const p=["{"];for(const[P,M]of u)p.length>1&&p.push(","),p.push(P),(P!==M||this.opts.es5)&&(p.push(":"),(0,t.addCodeArg)(p,M));return p.push("}"),new t._Code(p)}if(u,p,P){if(this._blockNode(new h(u)),p&&P)this.code(p).else().code(P).endIf();else if(p)this.code(p).endIf();else if(P)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(u){return this._elseNode(new h(u))}else(){return this._elseNode(new m)}endIf(){return this._endBlockNode(h,m)}_for(u,p){return this._blockNode(u),p&&this.code(p).endFor(),this}for(u,p){return this._for(new k(u),p)}forRange(u,p,P,M,z=this.opts.es5?r.varKinds.var:r.varKinds.let){const J=this._scope.toName(u);return this._for(new R(z,J,p,P),()=>M(J))}forOf(u,p,P,M=r.varKinds.const){const z=this._scope.toName(u);if(this.opts.es5){const J=p instanceof t.Name?p:this.var("_arr",p);return this.forRange("_i",0,(0,t._)`${J}.length`,G=>{this.var(z,(0,t._)`${J}[${G}]`),P(z)})}return this._for(new E("of",M,z,p),()=>P(z))}forIn(u,p,P,M=this.opts.es5?r.varKinds.var:r.varKinds.const){if(this.opts.ownProperties)return this.forOf(u,(0,t._)`Object.keys(${p})`,P);const z=this._scope.toName(u);return this._for(new E("in",M,z,p),()=>P(z))}endFor(){return this._endBlockNode(v)}label(u){return this._leafNode(new l(u))}break(u){return this._leafNode(new d(u))}return(u){const p=new x;if(this._blockNode(p),this.code(u),p.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(x)}try(u,p,P){if(!p&&!P)throw new Error('CodeGen: "try" without "catch" and "finally"');const M=new q;if(this._blockNode(M),this.code(u),p){const z=this.name("e");this._currNode=M.catch=new Z(z),p(z)}return P&&(this._currNode=M.finally=new D,this.code(P)),this._endBlockNode(Z,D)}throw(u){return this._leafNode(new f(u))}block(u,p){return this._blockStarts.push(this._nodes.length),u&&this.code(u).endBlock(p),this}endBlock(u){const p=this._blockStarts.pop();if(p===void 0)throw new Error("CodeGen: not in self-balancing block");const P=this._nodes.length-p;if(P<0||u!==void 0&&P!==u)throw new Error(`CodeGen: wrong number of nodes: ${P} vs ${u} expected`);return this._nodes.length=p,this}func(u,p=t.nil,P,M){return this._blockNode(new I(u,p,P)),M&&this.code(M).endFunc(),this}endFunc(){return this._endBlockNode(I)}optimize(u=1){for(;u-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(u){return this._currNode.nodes.push(u),this}_blockNode(u){this._currNode.nodes.push(u),this._nodes.push(u)}_endBlockNode(u,p){const P=this._currNode;if(P instanceof u||p&&P instanceof p)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${p?`${u.kind}/${p.kind}`:u.kind}"`)}_elseNode(u){const p=this._currNode;if(!(p instanceof h))throw new Error('CodeGen: "else" without "if"');return this._currNode=p.else=u,this}get _root(){return this._nodes[0]}get _currNode(){const u=this._nodes;return u[u.length-1]}set _currNode(u){const p=this._nodes;p[p.length-1]=u}}e.CodeGen=L;function B(b,u){for(const p in u)b[p]=(b[p]||0)+(u[p]||0);return b}function ce(b,u){return u instanceof t._CodeOrName?B(b,u.names):b}function U(b,u,p){if(b instanceof t.Name)return P(b);if(!M(b))return b;return new t._Code(b._items.reduce((z,J)=>(J instanceof t.Name&&(J=P(J)),J instanceof t._Code?z.push(...J._items):z.push(J),z),[]));function P(z){const J=p[z.str];return J===void 0||u[z.str]!==1?z:(delete u[z.str],J)}function M(z){return z instanceof t._Code&&z._items.some(J=>J instanceof t.Name&&u[J.str]===1&&p[J.str]!==void 0)}}function le(b,u){for(const p in u)b[p]=(b[p]||0)-(u[p]||0)}function je(b){return typeof b=="boolean"||typeof b=="number"||b===null?!b:(0,t._)`!${j(b)}`}e.not=je;const _e=w(e.operators.AND);function it(...b){return b.reduce(_e)}e.and=it;const Ie=w(e.operators.OR);function N(...b){return b.reduce(Ie)}e.or=N;function w(b){return(u,p)=>u===t.nil?p:p===t.nil?u:(0,t._)`${j(u)} ${b} ${j(p)}`}function j(b){return b instanceof t.Name?b:(0,t._)`(${b})`}})(ie);var H={};Object.defineProperty(H,"__esModule",{value:!0});H.checkStrictMode=H.getErrorPath=H.Type=H.useFunc=H.setEvaluated=H.evaluatedPropsToName=H.mergeEvaluated=H.eachItem=H.unescapeJsonPointer=H.escapeJsonPointer=H.escapeFragment=H.unescapeFragment=H.schemaRefOrVal=H.schemaHasRulesButRef=H.schemaHasRules=H.checkUnknownRules=H.alwaysValidSchema=H.toHash=void 0;const ve=ie,TE=En;function RE(e){const t={};for(const r of e)t[r]=!0;return t}H.toHash=RE;function jE(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(Pf(e,t),!Tf(t,e.self.RULES.all))}H.alwaysValidSchema=jE;function Pf(e,t=e.schema){const{opts:r,self:n}=e;if(!r.strictSchema||typeof t=="boolean")return;const s=n.RULES.keywords;for(const o in t)s[o]||Cf(e,`unknown keyword: "${o}"`)}H.checkUnknownRules=Pf;function Tf(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(t[r])return!0;return!1}H.schemaHasRules=Tf;function CE(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}H.schemaHasRulesButRef=CE;function NE({topSchemaRef:e,schemaPath:t},r,n,s){if(!s){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,ve._)`${r}`}return(0,ve._)`${e}${t}${(0,ve.getProperty)(n)}`}H.schemaRefOrVal=NE;function IE(e){return Rf(decodeURIComponent(e))}H.unescapeFragment=IE;function OE(e){return encodeURIComponent(Di(e))}H.escapeFragment=OE;function Di(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}H.escapeJsonPointer=Di;function Rf(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}H.unescapeJsonPointer=Rf;function xE(e,t){if(Array.isArray(e))for(const r of e)t(r);else t(e)}H.eachItem=xE;function Tl({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(s,o,a,i)=>{const c=a===void 0?o:a instanceof ve.Name?(o instanceof ve.Name?e(s,o,a):t(s,o,a),a):o instanceof ve.Name?(t(s,a,o),o):r(o,a);return i===ve.Name&&!(c instanceof ve.Name)?n(s,c):c}}H.mergeEvaluated={props:Tl({mergeNames:(e,t,r)=>e.if((0,ve._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,ve._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,ve._)`${r} || {}`).code((0,ve._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,ve._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,ve._)`${r} || {}`),qi(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:jf}),items:Tl({mergeNames:(e,t,r)=>e.if((0,ve._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,ve._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,ve._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,ve._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function jf(e,t){if(t===!0)return e.var("props",!0);const r=e.var("props",(0,ve._)`{}`);return t!==void 0&&qi(e,r,t),r}H.evaluatedPropsToName=jf;function qi(e,t,r){Object.keys(r).forEach(n=>e.assign((0,ve._)`${t}${(0,ve.getProperty)(n)}`,!0))}H.setEvaluated=qi;const Rl={};function AE(e,t){return e.scopeValue("func",{ref:t,code:Rl[t.code]||(Rl[t.code]=new TE._Code(t.code))})}H.useFunc=AE;var Uo;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(Uo||(H.Type=Uo={}));function ME(e,t,r){if(e instanceof ve.Name){const n=t===Uo.Num;return r?n?(0,ve._)`"[" + ${e} + "]"`:(0,ve._)`"['" + ${e} + "']"`:n?(0,ve._)`"/" + ${e}`:(0,ve._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,ve.getProperty)(e).toString():"/"+Di(e)}H.getErrorPath=ME;function Cf(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}H.checkStrictMode=Cf;var Et={};Object.defineProperty(Et,"__esModule",{value:!0});const Ke=ie,zE={data:new Ke.Name("data"),valCxt:new Ke.Name("valCxt"),instancePath:new Ke.Name("instancePath"),parentData:new Ke.Name("parentData"),parentDataProperty:new Ke.Name("parentDataProperty"),rootData:new Ke.Name("rootData"),dynamicAnchors:new Ke.Name("dynamicAnchors"),vErrors:new Ke.Name("vErrors"),errors:new Ke.Name("errors"),this:new Ke.Name("this"),self:new Ke.Name("self"),scope:new Ke.Name("scope"),json:new Ke.Name("json"),jsonPos:new Ke.Name("jsonPos"),jsonLen:new Ke.Name("jsonLen"),jsonPart:new Ke.Name("jsonPart")};Et.default=zE;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;const t=ie,r=H,n=Et;e.keywordError={message:({keyword:m})=>(0,t.str)`must pass "${m}" keyword validation`},e.keyword$DataError={message:({keyword:m,schemaType:h})=>h?(0,t.str)`"${m}" keyword must be ${h} ($data)`:(0,t.str)`"${m}" keyword is invalid ($data)`};function s(m,h=e.keywordError,v,k){const{it:R}=m,{gen:E,compositeRule:I,allErrors:x}=R,q=f(m,h,v);k??(I||x)?c(E,q):l(R,(0,t._)`[${q}]`)}e.reportError=s;function o(m,h=e.keywordError,v){const{it:k}=m,{gen:R,compositeRule:E,allErrors:I}=k,x=f(m,h,v);c(R,x),E||I||l(k,n.default.vErrors)}e.reportExtraError=o;function a(m,h){m.assign(n.default.errors,h),m.if((0,t._)`${n.default.vErrors} !== null`,()=>m.if(h,()=>m.assign((0,t._)`${n.default.vErrors}.length`,h),()=>m.assign(n.default.vErrors,null)))}e.resetErrorsCount=a;function i({gen:m,keyword:h,schemaValue:v,data:k,errsCount:R,it:E}){if(R===void 0)throw new Error("ajv implementation error");const I=m.name("err");m.forRange("i",R,n.default.errors,x=>{m.const(I,(0,t._)`${n.default.vErrors}[${x}]`),m.if((0,t._)`${I}.instancePath === undefined`,()=>m.assign((0,t._)`${I}.instancePath`,(0,t.strConcat)(n.default.instancePath,E.errorPath))),m.assign((0,t._)`${I}.schemaPath`,(0,t.str)`${E.errSchemaPath}/${h}`),E.opts.verbose&&(m.assign((0,t._)`${I}.schema`,v),m.assign((0,t._)`${I}.data`,k))})}e.extendErrors=i;function c(m,h){const v=m.const("err",h);m.if((0,t._)`${n.default.vErrors} === null`,()=>m.assign(n.default.vErrors,(0,t._)`[${v}]`),(0,t._)`${n.default.vErrors}.push(${v})`),m.code((0,t._)`${n.default.errors}++`)}function l(m,h){const{gen:v,validateName:k,schemaEnv:R}=m;R.$async?v.throw((0,t._)`new ${m.ValidationError}(${h})`):(v.assign((0,t._)`${k}.errors`,h),v.return(!1))}const d={keyword:new t.Name("keyword"),schemaPath:new t.Name("schemaPath"),params:new t.Name("params"),propertyName:new t.Name("propertyName"),message:new t.Name("message"),schema:new t.Name("schema"),parentSchema:new t.Name("parentSchema")};function f(m,h,v){const{createErrors:k}=m.it;return k===!1?(0,t._)`{}`:_(m,h,v)}function _(m,h,v={}){const{gen:k,it:R}=m,E=[y(R,v),g(m,v)];return $(m,h,E),k.object(...E)}function y({errorPath:m},{instancePath:h}){const v=h?(0,t.str)`${m}${(0,r.getErrorPath)(h,r.Type.Str)}`:m;return[n.default.instancePath,(0,t.strConcat)(n.default.instancePath,v)]}function g({keyword:m,it:{errSchemaPath:h}},{schemaPath:v,parentSchema:k}){let R=k?h:(0,t.str)`${h}/${m}`;return v&&(R=(0,t.str)`${R}${(0,r.getErrorPath)(v,r.Type.Str)}`),[d.schemaPath,R]}function $(m,{params:h,message:v},k){const{keyword:R,data:E,schemaValue:I,it:x}=m,{opts:q,propertyName:Z,topSchemaRef:D,schemaPath:L}=x;k.push([d.keyword,R],[d.params,typeof h=="function"?h(m):h||(0,t._)`{}`]),q.messages&&k.push([d.message,typeof v=="function"?v(m):v]),q.verbose&&k.push([d.schema,I],[d.parentSchema,(0,t._)`${D}${L}`],[n.default.data,E]),Z&&k.push([d.propertyName,Z])}})(Dn);Object.defineProperty(Ur,"__esModule",{value:!0});Ur.boolOrEmptySchema=Ur.topBoolOrEmptySchema=void 0;const DE=Dn,qE=ie,UE=Et,FE={message:"boolean schema is false"};function LE(e){const{gen:t,schema:r,validateName:n}=e;r===!1?Nf(e,!1):typeof r=="object"&&r.$async===!0?t.return(UE.default.data):(t.assign((0,qE._)`${n}.errors`,null),t.return(!0))}Ur.topBoolOrEmptySchema=LE;function VE(e,t){const{gen:r,schema:n}=e;n===!1?(r.var(t,!1),Nf(e)):r.var(t,!0)}Ur.boolOrEmptySchema=VE;function Nf(e,t){const{gen:r,data:n}=e,s={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,DE.reportError)(s,FE,void 0,t)}var xe={},yr={};Object.defineProperty(yr,"__esModule",{value:!0});yr.getRules=yr.isJSONType=void 0;const HE=["string","number","integer","boolean","null","object","array"],ZE=new Set(HE);function KE(e){return typeof e=="string"&&ZE.has(e)}yr.isJSONType=KE;function GE(){const e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}yr.getRules=GE;var Tt={};Object.defineProperty(Tt,"__esModule",{value:!0});Tt.shouldUseRule=Tt.shouldUseGroup=Tt.schemaHasRulesForType=void 0;function WE({schema:e,self:t},r){const n=t.RULES.types[r];return n&&n!==!0&&If(e,n)}Tt.schemaHasRulesForType=WE;function If(e,t){return t.rules.some(r=>Of(e,r))}Tt.shouldUseGroup=If;function Of(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(n=>e[n]!==void 0))}Tt.shouldUseRule=Of;Object.defineProperty(xe,"__esModule",{value:!0});xe.reportTypeError=xe.checkDataTypes=xe.checkDataType=xe.coerceAndCheckDataType=xe.getJSONTypes=xe.getSchemaTypes=xe.DataType=void 0;const BE=yr,JE=Tt,QE=Dn,oe=ie,xf=H;var Ar;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Ar||(xe.DataType=Ar={}));function YE(e){const t=Af(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}xe.getSchemaTypes=YE;function Af(e){const t=Array.isArray(e)?e:e?[e]:[];if(t.every(BE.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}xe.getJSONTypes=Af;function XE(e,t){const{gen:r,data:n,opts:s}=e,o=ek(t,s.coerceTypes),a=t.length>0&&!(o.length===0&&t.length===1&&(0,JE.schemaHasRulesForType)(e,t[0]));if(a){const i=Ui(t,n,s.strictNumbers,Ar.Wrong);r.if(i,()=>{o.length?tk(e,t,o):Fi(e)})}return a}xe.coerceAndCheckDataType=XE;const Mf=new Set(["string","number","integer","boolean","null"]);function ek(e,t){return t?e.filter(r=>Mf.has(r)||t==="array"&&r==="array"):[]}function tk(e,t,r){const{gen:n,data:s,opts:o}=e,a=n.let("dataType",(0,oe._)`typeof ${s}`),i=n.let("coerced",(0,oe._)`undefined`);o.coerceTypes==="array"&&n.if((0,oe._)`${a} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>n.assign(s,(0,oe._)`${s}[0]`).assign(a,(0,oe._)`typeof ${s}`).if(Ui(t,s,o.strictNumbers),()=>n.assign(i,s))),n.if((0,oe._)`${i} !== undefined`);for(const l of r)(Mf.has(l)||l==="array"&&o.coerceTypes==="array")&&c(l);n.else(),Fi(e),n.endIf(),n.if((0,oe._)`${i} !== undefined`,()=>{n.assign(s,i),rk(e,i)});function c(l){switch(l){case"string":n.elseIf((0,oe._)`${a} == "number" || ${a} == "boolean"`).assign(i,(0,oe._)`"" + ${s}`).elseIf((0,oe._)`${s} === null`).assign(i,(0,oe._)`""`);return;case"number":n.elseIf((0,oe._)`${a} == "boolean" || ${s} === null + || (${a} == "string" && ${s} && ${s} == +${s})`).assign(i,(0,oe._)`+${s}`);return;case"integer":n.elseIf((0,oe._)`${a} === "boolean" || ${s} === null + || (${a} === "string" && ${s} && ${s} == +${s} && !(${s} % 1))`).assign(i,(0,oe._)`+${s}`);return;case"boolean":n.elseIf((0,oe._)`${s} === "false" || ${s} === 0 || ${s} === null`).assign(i,!1).elseIf((0,oe._)`${s} === "true" || ${s} === 1`).assign(i,!0);return;case"null":n.elseIf((0,oe._)`${s} === "" || ${s} === 0 || ${s} === false`),n.assign(i,null);return;case"array":n.elseIf((0,oe._)`${a} === "string" || ${a} === "number" + || ${a} === "boolean" || ${s} === null`).assign(i,(0,oe._)`[${s}]`)}}}function rk({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,oe._)`${t} !== undefined`,()=>e.assign((0,oe._)`${t}[${r}]`,n))}function Fo(e,t,r,n=Ar.Correct){const s=n===Ar.Correct?oe.operators.EQ:oe.operators.NEQ;let o;switch(e){case"null":return(0,oe._)`${t} ${s} null`;case"array":o=(0,oe._)`Array.isArray(${t})`;break;case"object":o=(0,oe._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":o=a((0,oe._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":o=a();break;default:return(0,oe._)`typeof ${t} ${s} ${e}`}return n===Ar.Correct?o:(0,oe.not)(o);function a(i=oe.nil){return(0,oe.and)((0,oe._)`typeof ${t} == "number"`,i,r?(0,oe._)`isFinite(${t})`:oe.nil)}}xe.checkDataType=Fo;function Ui(e,t,r,n){if(e.length===1)return Fo(e[0],t,r,n);let s;const o=(0,xf.toHash)(e);if(o.array&&o.object){const a=(0,oe._)`typeof ${t} != "object"`;s=o.null?a:(0,oe._)`!${t} || ${a}`,delete o.null,delete o.array,delete o.object}else s=oe.nil;o.number&&delete o.integer;for(const a in o)s=(0,oe.and)(s,Fo(a,t,r,n));return s}xe.checkDataTypes=Ui;const nk={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,oe._)`{type: ${e}}`:(0,oe._)`{type: ${t}}`};function Fi(e){const t=sk(e);(0,QE.reportError)(t,nk)}xe.reportTypeError=Fi;function sk(e){const{gen:t,data:r,schema:n}=e,s=(0,xf.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:e}}var Ws={};Object.defineProperty(Ws,"__esModule",{value:!0});Ws.assignDefaults=void 0;const Er=ie,ok=H;function ak(e,t){const{properties:r,items:n}=e.schema;if(t==="object"&&r)for(const s in r)jl(e,s,r[s].default);else t==="array"&&Array.isArray(n)&&n.forEach((s,o)=>jl(e,o,s.default))}Ws.assignDefaults=ak;function jl(e,t,r){const{gen:n,compositeRule:s,data:o,opts:a}=e;if(r===void 0)return;const i=(0,Er._)`${o}${(0,Er.getProperty)(t)}`;if(s){(0,ok.checkStrictMode)(e,`default is ignored for: ${i}`);return}let c=(0,Er._)`${i} === undefined`;a.useDefaults==="empty"&&(c=(0,Er._)`${c} || ${i} === null || ${i} === ""`),n.if(c,(0,Er._)`${i} = ${(0,Er.stringify)(r)}`)}var bt={},de={};Object.defineProperty(de,"__esModule",{value:!0});de.validateUnion=de.validateArray=de.usePattern=de.callValidateCode=de.schemaProperties=de.allSchemaProperties=de.noPropertyInData=de.propertyInData=de.isOwnProperty=de.hasPropFunc=de.reportMissingProp=de.checkMissingProp=de.checkReportMissingProp=void 0;const Se=ie,Li=H,Nt=Et,ik=H;function ck(e,t){const{gen:r,data:n,it:s}=e;r.if(Hi(r,n,t,s.opts.ownProperties),()=>{e.setParams({missingProperty:(0,Se._)`${t}`},!0),e.error()})}de.checkReportMissingProp=ck;function lk({gen:e,data:t,it:{opts:r}},n,s){return(0,Se.or)(...n.map(o=>(0,Se.and)(Hi(e,t,o,r.ownProperties),(0,Se._)`${s} = ${o}`)))}de.checkMissingProp=lk;function uk(e,t){e.setParams({missingProperty:t},!0),e.error()}de.reportMissingProp=uk;function zf(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Se._)`Object.prototype.hasOwnProperty`})}de.hasPropFunc=zf;function Vi(e,t,r){return(0,Se._)`${zf(e)}.call(${t}, ${r})`}de.isOwnProperty=Vi;function dk(e,t,r,n){const s=(0,Se._)`${t}${(0,Se.getProperty)(r)} !== undefined`;return n?(0,Se._)`${s} && ${Vi(e,t,r)}`:s}de.propertyInData=dk;function Hi(e,t,r,n){const s=(0,Se._)`${t}${(0,Se.getProperty)(r)} === undefined`;return n?(0,Se.or)(s,(0,Se.not)(Vi(e,t,r))):s}de.noPropertyInData=Hi;function Df(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}de.allSchemaProperties=Df;function fk(e,t){return Df(t).filter(r=>!(0,Li.alwaysValidSchema)(e,t[r]))}de.schemaProperties=fk;function hk({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:s,errorPath:o},it:a},i,c,l){const d=l?(0,Se._)`${e}, ${t}, ${n}${s}`:t,f=[[Nt.default.instancePath,(0,Se.strConcat)(Nt.default.instancePath,o)],[Nt.default.parentData,a.parentData],[Nt.default.parentDataProperty,a.parentDataProperty],[Nt.default.rootData,Nt.default.rootData]];a.opts.dynamicRef&&f.push([Nt.default.dynamicAnchors,Nt.default.dynamicAnchors]);const _=(0,Se._)`${d}, ${r.object(...f)}`;return c!==Se.nil?(0,Se._)`${i}.call(${c}, ${_})`:(0,Se._)`${i}(${_})`}de.callValidateCode=hk;const pk=(0,Se._)`new RegExp`;function mk({gen:e,it:{opts:t}},r){const n=t.unicodeRegExp?"u":"",{regExp:s}=t.code,o=s(r,n);return e.scopeValue("pattern",{key:o.toString(),ref:o,code:(0,Se._)`${s.code==="new RegExp"?pk:(0,ik.useFunc)(e,s)}(${r}, ${n})`})}de.usePattern=mk;function gk(e){const{gen:t,data:r,keyword:n,it:s}=e,o=t.name("valid");if(s.allErrors){const i=t.let("valid",!0);return a(()=>t.assign(i,!1)),i}return t.var(o,!0),a(()=>t.break()),o;function a(i){const c=t.const("len",(0,Se._)`${r}.length`);t.forRange("i",0,c,l=>{e.subschema({keyword:n,dataProp:l,dataPropType:Li.Type.Num},o),t.if((0,Se.not)(o),i)})}}de.validateArray=gk;function _k(e){const{gen:t,schema:r,keyword:n,it:s}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,Li.alwaysValidSchema)(s,c))&&!s.opts.unevaluated)return;const a=t.let("valid",!1),i=t.name("_valid");t.block(()=>r.forEach((c,l)=>{const d=e.subschema({keyword:n,schemaProp:l,compositeRule:!0},i);t.assign(a,(0,Se._)`${a} || ${i}`),e.mergeValidEvaluated(d,i)||t.if((0,Se.not)(a))})),e.result(a,()=>e.reset(),()=>e.error(!0))}de.validateUnion=_k;Object.defineProperty(bt,"__esModule",{value:!0});bt.validateKeywordUsage=bt.validSchemaType=bt.funcKeywordCode=bt.macroKeywordCode=void 0;const We=ie,ur=Et,yk=de,vk=Dn;function $k(e,t){const{gen:r,keyword:n,schema:s,parentSchema:o,it:a}=e,i=t.macro.call(a.self,s,o,a),c=qf(r,n,i);a.opts.validateSchema!==!1&&a.self.validateSchema(i,!0);const l=r.name("valid");e.subschema({schema:i,schemaPath:We.nil,errSchemaPath:`${a.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},l),e.pass(l,()=>e.error(!0))}bt.macroKeywordCode=$k;function wk(e,t){var r;const{gen:n,keyword:s,schema:o,parentSchema:a,$data:i,it:c}=e;Sk(c,t);const l=!i&&t.compile?t.compile.call(c.self,o,a,c):t.validate,d=qf(n,s,l),f=n.let("valid");e.block$data(f,_),e.ok((r=t.valid)!==null&&r!==void 0?r:f);function _(){if(t.errors===!1)$(),t.modifying&&Cl(e),m(()=>e.error());else{const h=t.async?y():g();t.modifying&&Cl(e),m(()=>bk(e,h))}}function y(){const h=n.let("ruleErrs",null);return n.try(()=>$((0,We._)`await `),v=>n.assign(f,!1).if((0,We._)`${v} instanceof ${c.ValidationError}`,()=>n.assign(h,(0,We._)`${v}.errors`),()=>n.throw(v))),h}function g(){const h=(0,We._)`${d}.errors`;return n.assign(h,null),$(We.nil),h}function $(h=t.async?(0,We._)`await `:We.nil){const v=c.opts.passContext?ur.default.this:ur.default.self,k=!("compile"in t&&!i||t.schema===!1);n.assign(f,(0,We._)`${h}${(0,yk.callValidateCode)(e,d,v,k)}`,t.modifying)}function m(h){var v;n.if((0,We.not)((v=t.valid)!==null&&v!==void 0?v:f),h)}}bt.funcKeywordCode=wk;function Cl(e){const{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,We._)`${n.parentData}[${n.parentDataProperty}]`))}function bk(e,t){const{gen:r}=e;r.if((0,We._)`Array.isArray(${t})`,()=>{r.assign(ur.default.vErrors,(0,We._)`${ur.default.vErrors} === null ? ${t} : ${ur.default.vErrors}.concat(${t})`).assign(ur.default.errors,(0,We._)`${ur.default.vErrors}.length`),(0,vk.extendErrors)(e)},()=>e.error())}function Sk({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function qf(e,t,r){if(r===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,We.stringify)(r)})}function Ek(e,t,r=!1){return!t.length||t.some(n=>n==="array"?Array.isArray(e):n==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==n||r&&typeof e>"u")}bt.validSchemaType=Ek;function kk({schema:e,opts:t,self:r,errSchemaPath:n},s,o){if(Array.isArray(s.keyword)?!s.keyword.includes(o):s.keyword!==o)throw new Error("ajv implementation error");const a=s.dependencies;if(a!=null&&a.some(i=>!Object.prototype.hasOwnProperty.call(e,i)))throw new Error(`parent schema must have dependencies of ${o}: ${a.join(",")}`);if(s.validateSchema&&!s.validateSchema(e[o])){const c=`keyword "${o}" value is invalid at path "${n}": `+r.errorsText(s.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}bt.validateKeywordUsage=kk;var qt={};Object.defineProperty(qt,"__esModule",{value:!0});qt.extendSubschemaMode=qt.extendSubschemaData=qt.getSubschema=void 0;const $t=ie,Uf=H;function Pk(e,{keyword:t,schemaProp:r,schema:n,schemaPath:s,errSchemaPath:o,topSchemaRef:a}){if(t!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){const i=e.schema[t];return r===void 0?{schema:i,schemaPath:(0,$t._)`${e.schemaPath}${(0,$t.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:i[r],schemaPath:(0,$t._)`${e.schemaPath}${(0,$t.getProperty)(t)}${(0,$t.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,Uf.escapeFragment)(r)}`}}if(n!==void 0){if(s===void 0||o===void 0||a===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:s,topSchemaRef:a,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')}qt.getSubschema=Pk;function Tk(e,t,{dataProp:r,dataPropType:n,data:s,dataTypes:o,propertyName:a}){if(s!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:i}=t;if(r!==void 0){const{errorPath:l,dataPathArr:d,opts:f}=t,_=i.let("data",(0,$t._)`${t.data}${(0,$t.getProperty)(r)}`,!0);c(_),e.errorPath=(0,$t.str)`${l}${(0,Uf.getErrorPath)(r,n,f.jsPropertySyntax)}`,e.parentDataProperty=(0,$t._)`${r}`,e.dataPathArr=[...d,e.parentDataProperty]}if(s!==void 0){const l=s instanceof $t.Name?s:i.let("data",s,!0);c(l),a!==void 0&&(e.propertyName=a)}o&&(e.dataTypes=o);function c(l){e.data=l,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,l]}}qt.extendSubschemaData=Tk;function Rk(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:s,allErrors:o}){n!==void 0&&(e.compositeRule=n),s!==void 0&&(e.createErrors=s),o!==void 0&&(e.allErrors=o),e.jtdDiscriminator=t,e.jtdMetadata=r}qt.extendSubschemaMode=Rk;var Fe={},Ff={exports:{}},Mt=Ff.exports=function(e,t,r){typeof t=="function"&&(r=t,t={}),r=t.cb||r;var n=typeof r=="function"?r:r.pre||function(){},s=r.post||function(){};cs(t,n,s,e,"",e)};Mt.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Mt.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Mt.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Mt.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 cs(e,t,r,n,s,o,a,i,c,l){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,s,o,a,i,c,l);for(var d in n){var f=n[d];if(Array.isArray(f)){if(d in Mt.arrayKeywords)for(var _=0;_t+=Lf(n)),t===1/0))return 1/0}return t}function Vf(e,t="",r){r!==!1&&(t=Mr(t));const n=e.parse(t);return Hf(e,n)}Fe.getFullPath=Vf;function Hf(e,t){return e.serialize(t).split("#")[0]+"#"}Fe._getFullPath=Hf;const zk=/#\/?$/;function Mr(e){return e?e.replace(zk,""):""}Fe.normalizeId=Mr;function Dk(e,t,r){return r=Mr(r),e.resolve(t,r)}Fe.resolveUrl=Dk;const qk=/^[a-z_][-a-z0-9._]*$/i;function Uk(e,t){if(typeof e=="boolean")return{};const{schemaId:r,uriResolver:n}=this.opts,s=Mr(e[r]||t),o={"":s},a=Vf(n,s,!1),i={},c=new Set;return Ok(e,{allKeys:!0},(f,_,y,g)=>{if(g===void 0)return;const $=a+_;let m=o[g];typeof f[r]=="string"&&(m=h.call(this,f[r])),v.call(this,f.$anchor),v.call(this,f.$dynamicAnchor),o[_]=m;function h(k){const R=this.opts.uriResolver.resolve;if(k=Mr(m?R(m,k):k),c.has(k))throw d(k);c.add(k);let E=this.refs[k];return typeof E=="string"&&(E=this.refs[E]),typeof E=="object"?l(f,E.schema,k):k!==Mr($)&&(k[0]==="#"?(l(f,i[k],k),i[k]=f):this.refs[k]=$),k}function v(k){if(typeof k=="string"){if(!qk.test(k))throw new Error(`invalid anchor "${k}"`);h.call(this,`#${k}`)}}}),i;function l(f,_,y){if(_!==void 0&&!Ik(f,_))throw d(y)}function d(f){return new Error(`reference "${f}" resolves to more than one schema`)}}Fe.getSchemaRefs=Uk;Object.defineProperty(_t,"__esModule",{value:!0});_t.getData=_t.KeywordCxt=_t.validateFunctionCode=void 0;const Zf=Ur,Nl=xe,Zi=Tt,ks=xe,Fk=Ws,pn=bt,co=qt,Y=ie,te=Et,Lk=Fe,Rt=H,tn=Dn;function Vk(e){if(Wf(e)&&(Bf(e),Gf(e))){Kk(e);return}Kf(e,()=>(0,Zf.topBoolOrEmptySchema)(e))}_t.validateFunctionCode=Vk;function Kf({gen:e,validateName:t,schema:r,schemaEnv:n,opts:s},o){s.code.es5?e.func(t,(0,Y._)`${te.default.data}, ${te.default.valCxt}`,n.$async,()=>{e.code((0,Y._)`"use strict"; ${Il(r,s)}`),Zk(e,s),e.code(o)}):e.func(t,(0,Y._)`${te.default.data}, ${Hk(s)}`,n.$async,()=>e.code(Il(r,s)).code(o))}function Hk(e){return(0,Y._)`{${te.default.instancePath}="", ${te.default.parentData}, ${te.default.parentDataProperty}, ${te.default.rootData}=${te.default.data}${e.dynamicRef?(0,Y._)`, ${te.default.dynamicAnchors}={}`:Y.nil}}={}`}function Zk(e,t){e.if(te.default.valCxt,()=>{e.var(te.default.instancePath,(0,Y._)`${te.default.valCxt}.${te.default.instancePath}`),e.var(te.default.parentData,(0,Y._)`${te.default.valCxt}.${te.default.parentData}`),e.var(te.default.parentDataProperty,(0,Y._)`${te.default.valCxt}.${te.default.parentDataProperty}`),e.var(te.default.rootData,(0,Y._)`${te.default.valCxt}.${te.default.rootData}`),t.dynamicRef&&e.var(te.default.dynamicAnchors,(0,Y._)`${te.default.valCxt}.${te.default.dynamicAnchors}`)},()=>{e.var(te.default.instancePath,(0,Y._)`""`),e.var(te.default.parentData,(0,Y._)`undefined`),e.var(te.default.parentDataProperty,(0,Y._)`undefined`),e.var(te.default.rootData,te.default.data),t.dynamicRef&&e.var(te.default.dynamicAnchors,(0,Y._)`{}`)})}function Kk(e){const{schema:t,opts:r,gen:n}=e;Kf(e,()=>{r.$comment&&t.$comment&&Qf(e),Qk(e),n.let(te.default.vErrors,null),n.let(te.default.errors,0),r.unevaluated&&Gk(e),Jf(e),e1(e)})}function Gk(e){const{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,Y._)`${r}.evaluated`),t.if((0,Y._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,Y._)`${e.evaluated}.props`,(0,Y._)`undefined`)),t.if((0,Y._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,Y._)`${e.evaluated}.items`,(0,Y._)`undefined`))}function Il(e,t){const r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,Y._)`/*# sourceURL=${r} */`:Y.nil}function Wk(e,t){if(Wf(e)&&(Bf(e),Gf(e))){Bk(e,t);return}(0,Zf.boolOrEmptySchema)(e,t)}function Gf({schema:e,self:t}){if(typeof e=="boolean")return!e;for(const r in e)if(t.RULES.all[r])return!0;return!1}function Wf(e){return typeof e.schema!="boolean"}function Bk(e,t){const{schema:r,gen:n,opts:s}=e;s.$comment&&r.$comment&&Qf(e),Yk(e),Xk(e);const o=n.const("_errs",te.default.errors);Jf(e,o),n.var(t,(0,Y._)`${o} === ${te.default.errors}`)}function Bf(e){(0,Rt.checkUnknownRules)(e),Jk(e)}function Jf(e,t){if(e.opts.jtd)return Ol(e,[],!1,t);const r=(0,Nl.getSchemaTypes)(e.schema),n=(0,Nl.coerceAndCheckDataType)(e,r);Ol(e,r,!n,t)}function Jk(e){const{schema:t,errSchemaPath:r,opts:n,self:s}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,Rt.schemaHasRulesButRef)(t,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function Qk(e){const{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Rt.checkStrictMode)(e,"default is ignored in the schema root")}function Yk(e){const t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,Lk.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function Xk(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function Qf({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:s}){const o=r.$comment;if(s.$comment===!0)e.code((0,Y._)`${te.default.self}.logger.log(${o})`);else if(typeof s.$comment=="function"){const a=(0,Y.str)`${n}/$comment`,i=e.scopeValue("root",{ref:t.root});e.code((0,Y._)`${te.default.self}.opts.$comment(${o}, ${a}, ${i}.schema)`)}}function e1(e){const{gen:t,schemaEnv:r,validateName:n,ValidationError:s,opts:o}=e;r.$async?t.if((0,Y._)`${te.default.errors} === 0`,()=>t.return(te.default.data),()=>t.throw((0,Y._)`new ${s}(${te.default.vErrors})`)):(t.assign((0,Y._)`${n}.errors`,te.default.vErrors),o.unevaluated&&t1(e),t.return((0,Y._)`${te.default.errors} === 0`))}function t1({gen:e,evaluated:t,props:r,items:n}){r instanceof Y.Name&&e.assign((0,Y._)`${t}.props`,r),n instanceof Y.Name&&e.assign((0,Y._)`${t}.items`,n)}function Ol(e,t,r,n){const{gen:s,schema:o,data:a,allErrors:i,opts:c,self:l}=e,{RULES:d}=l;if(o.$ref&&(c.ignoreKeywordsWithRef||!(0,Rt.schemaHasRulesButRef)(o,d))){s.block(()=>eh(e,"$ref",d.all.$ref.definition));return}c.jtd||r1(e,t),s.block(()=>{for(const _ of d.rules)f(_);f(d.post)});function f(_){(0,Zi.shouldUseGroup)(o,_)&&(_.type?(s.if((0,ks.checkDataType)(_.type,a,c.strictNumbers)),xl(e,_),t.length===1&&t[0]===_.type&&r&&(s.else(),(0,ks.reportTypeError)(e)),s.endIf()):xl(e,_),i||s.if((0,Y._)`${te.default.errors} === ${n||0}`))}}function xl(e,t){const{gen:r,schema:n,opts:{useDefaults:s}}=e;s&&(0,Fk.assignDefaults)(e,t.type),r.block(()=>{for(const o of t.rules)(0,Zi.shouldUseRule)(n,o)&&eh(e,o.keyword,o.definition,t.type)})}function r1(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(n1(e,t),e.opts.allowUnionTypes||s1(e,t),o1(e,e.dataTypes))}function n1(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{Yf(e.dataTypes,r)||Ki(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),i1(e,t)}}function s1(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&Ki(e,"use allowUnionTypes to allow union type keyword")}function o1(e,t){const r=e.self.RULES.all;for(const n in r){const s=r[n];if(typeof s=="object"&&(0,Zi.shouldUseRule)(e.schema,s)){const{type:o}=s.definition;o.length&&!o.some(a=>a1(t,a))&&Ki(e,`missing type "${o.join(",")}" for keyword "${n}"`)}}}function a1(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function Yf(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function i1(e,t){const r=[];for(const n of e.dataTypes)Yf(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function Ki(e,t){const r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,Rt.checkStrictMode)(e,t,e.opts.strictTypes)}class Xf{constructor(t,r,n){if((0,pn.validateKeywordUsage)(t,r,n),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=n,this.data=t.data,this.schema=t.schema[n],this.$data=r.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Rt.schemaRefOrVal)(t,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=r,this.$data)this.schemaCode=t.gen.const("vSchema",th(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,pn.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=t.gen.const("_errs",te.default.errors))}result(t,r,n){this.failResult((0,Y.not)(t),r,n)}failResult(t,r,n){this.gen.if(t),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,r){this.failResult((0,Y.not)(t),void 0,r)}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);const{schemaCode:r}=this;this.fail((0,Y._)`${r} !== undefined && (${(0,Y.or)(this.invalid$data(),t)})`)}error(t,r,n){if(r){this.setParams(r),this._error(t,n),this.setParams({});return}this._error(t,n)}_error(t,r){(t?tn.reportExtraError:tn.reportError)(this,this.def.error,r)}$dataError(){(0,tn.reportError)(this,this.def.$dataError||tn.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,tn.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,r){r?Object.assign(this.params,t):this.params=t}block$data(t,r,n=Y.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=Y.nil,r=Y.nil){if(!this.$data)return;const{gen:n,schemaCode:s,schemaType:o,def:a}=this;n.if((0,Y.or)((0,Y._)`${s} === undefined`,r)),t!==Y.nil&&n.assign(t,!0),(o.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==Y.nil&&n.assign(t,!1)),n.else()}invalid$data(){const{gen:t,schemaCode:r,schemaType:n,def:s,it:o}=this;return(0,Y.or)(a(),i());function a(){if(n.length){if(!(r instanceof Y.Name))throw new Error("ajv implementation error");const c=Array.isArray(n)?n:[n];return(0,Y._)`${(0,ks.checkDataTypes)(c,r,o.opts.strictNumbers,ks.DataType.Wrong)}`}return Y.nil}function i(){if(s.validateSchema){const c=t.scopeValue("validate$data",{ref:s.validateSchema});return(0,Y._)`!${c}(${r})`}return Y.nil}}subschema(t,r){const n=(0,co.getSubschema)(this.it,t);(0,co.extendSubschemaData)(n,this.it,t),(0,co.extendSubschemaMode)(n,t);const s={...this.it,...n,items:void 0,props:void 0};return Wk(s,r),s}mergeEvaluated(t,r){const{it:n,gen:s}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=Rt.mergeEvaluated.props(s,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=Rt.mergeEvaluated.items(s,t.items,n.items,r)))}mergeValidEvaluated(t,r){const{it:n,gen:s}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return s.if(r,()=>this.mergeEvaluated(t,Y.Name)),!0}}_t.KeywordCxt=Xf;function eh(e,t,r,n){const s=new Xf(e,r,t);"code"in r?r.code(s,n):s.$data&&r.validate?(0,pn.funcKeywordCode)(s,r):"macro"in r?(0,pn.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0,pn.funcKeywordCode)(s,r)}const c1=/^\/(?:[^~]|~0|~1)*$/,l1=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function th(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let s,o;if(e==="")return te.default.rootData;if(e[0]==="/"){if(!c1.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);s=e,o=te.default.rootData}else{const l=l1.exec(e);if(!l)throw new Error(`Invalid JSON-pointer: ${e}`);const d=+l[1];if(s=l[2],s==="#"){if(d>=t)throw new Error(c("property/index",d));return n[t-d]}if(d>t)throw new Error(c("data",d));if(o=r[t-d],!s)return o}let a=o;const i=s.split("/");for(const l of i)l&&(o=(0,Y._)`${o}${(0,Y.getProperty)((0,Rt.unescapeJsonPointer)(l))}`,a=(0,Y._)`${a} && ${o}`);return a;function c(l,d){return`Cannot access ${l} ${d} levels up, current level is ${t}`}}_t.getData=th;var qn={};Object.defineProperty(qn,"__esModule",{value:!0});class u1 extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}}qn.default=u1;var Gr={};Object.defineProperty(Gr,"__esModule",{value:!0});const lo=Fe;class d1 extends Error{constructor(t,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,lo.resolveUrl)(t,r,n),this.missingSchema=(0,lo.normalizeId)((0,lo.getFullPath)(t,this.missingRef))}}Gr.default=d1;var Ye={};Object.defineProperty(Ye,"__esModule",{value:!0});Ye.resolveSchema=Ye.getCompilingSchema=Ye.resolveRef=Ye.compileSchema=Ye.SchemaEnv=void 0;const ut=ie,f1=qn,sr=Et,mt=Fe,Al=H,h1=_t;class Bs{constructor(t){var r;this.refs={},this.dynamicAnchors={};let n;typeof t.schema=="object"&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0,mt.normalizeId)(n==null?void 0:n[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n==null?void 0:n.$async,this.refs={}}}Ye.SchemaEnv=Bs;function Gi(e){const t=rh.call(this,e);if(t)return t;const r=(0,mt.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:s}=this.opts.code,{ownProperties:o}=this.opts,a=new ut.CodeGen(this.scope,{es5:n,lines:s,ownProperties:o});let i;e.$async&&(i=a.scopeValue("Error",{ref:f1.default,code:(0,ut._)`require("ajv/dist/runtime/validation_error").default`}));const c=a.scopeName("validate");e.validateName=c;const l={gen:a,allErrors:this.opts.allErrors,data:sr.default.data,parentData:sr.default.parentData,parentDataProperty:sr.default.parentDataProperty,dataNames:[sr.default.data],dataPathArr:[ut.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:a.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,ut.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:i,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:ut.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,ut._)`""`,opts:this.opts,self:this};let d;try{this._compilations.add(e),(0,h1.validateFunctionCode)(l),a.optimize(this.opts.code.optimize);const f=a.toString();d=`${a.scopeRefs(sr.default.scope)}return ${f}`,this.opts.code.process&&(d=this.opts.code.process(d,e));const y=new Function(`${sr.default.self}`,`${sr.default.scope}`,d)(this,this.scope.get());if(this.scope.value(c,{ref:y}),y.errors=null,y.schema=e.schema,y.schemaEnv=e,e.$async&&(y.$async=!0),this.opts.code.source===!0&&(y.source={validateName:c,validateCode:f,scopeValues:a._values}),this.opts.unevaluated){const{props:g,items:$}=l;y.evaluated={props:g instanceof ut.Name?void 0:g,items:$ instanceof ut.Name?void 0:$,dynamicProps:g instanceof ut.Name,dynamicItems:$ instanceof ut.Name},y.source&&(y.source.evaluated=(0,ut.stringify)(y.evaluated))}return e.validate=y,e}catch(f){throw delete e.validate,delete e.validateName,d&&this.logger.error("Error compiling schema, function code:",d),f}finally{this._compilations.delete(e)}}Ye.compileSchema=Gi;function p1(e,t,r){var n;r=(0,mt.resolveUrl)(this.opts.uriResolver,t,r);const s=e.refs[r];if(s)return s;let o=_1.call(this,e,r);if(o===void 0){const a=(n=e.localRefs)===null||n===void 0?void 0:n[r],{schemaId:i}=this.opts;a&&(o=new Bs({schema:a,schemaId:i,root:e,baseId:t}))}if(o!==void 0)return e.refs[r]=m1.call(this,o)}Ye.resolveRef=p1;function m1(e){return(0,mt.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Gi.call(this,e)}function rh(e){for(const t of this._compilations)if(g1(t,e))return t}Ye.getCompilingSchema=rh;function g1(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function _1(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||Js.call(this,e,t)}function Js(e,t){const r=this.opts.uriResolver.parse(t),n=(0,mt._getFullPath)(this.opts.uriResolver,r);let s=(0,mt.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===s)return uo.call(this,r,e);const o=(0,mt.normalizeId)(n),a=this.refs[o]||this.schemas[o];if(typeof a=="string"){const i=Js.call(this,e,a);return typeof(i==null?void 0:i.schema)!="object"?void 0:uo.call(this,r,i)}if(typeof(a==null?void 0:a.schema)=="object"){if(a.validate||Gi.call(this,a),o===(0,mt.normalizeId)(t)){const{schema:i}=a,{schemaId:c}=this.opts,l=i[c];return l&&(s=(0,mt.resolveUrl)(this.opts.uriResolver,s,l)),new Bs({schema:i,schemaId:c,root:e,baseId:s})}return uo.call(this,r,a)}}Ye.resolveSchema=Js;const y1=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function uo(e,{baseId:t,schema:r,root:n}){var s;if(((s=e.fragment)===null||s===void 0?void 0:s[0])!=="/")return;for(const i of e.fragment.slice(1).split("/")){if(typeof r=="boolean")return;const c=r[(0,Al.unescapeFragment)(i)];if(c===void 0)return;r=c;const l=typeof r=="object"&&r[this.opts.schemaId];!y1.has(i)&&l&&(t=(0,mt.resolveUrl)(this.opts.uriResolver,t,l))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,Al.schemaHasRulesButRef)(r,this.RULES)){const i=(0,mt.resolveUrl)(this.opts.uriResolver,t,r.$ref);o=Js.call(this,n,i)}const{schemaId:a}=this.opts;if(o=o||new Bs({schema:r,schemaId:a,root:n,baseId:t}),o.schema!==o.root.schema)return o}const v1="https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",$1="Meta-schema for $data reference (JSON AnySchema extension proposal)",w1="object",b1=["$data"],S1={$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},E1=!1,k1={$id:v1,description:$1,type:w1,required:b1,properties:S1,additionalProperties:E1};var Wi={};Object.defineProperty(Wi,"__esModule",{value:!0});const nh=hf;nh.code='require("ajv/dist/runtime/uri").default';Wi.default=nh;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=_t;Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var r=ie;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return r.CodeGen}});const n=qn,s=Gr,o=yr,a=Ye,i=ie,c=Fe,l=xe,d=H,f=k1,_=Wi,y=(N,w)=>new RegExp(N,w);y.code="new RegExp";const g=["removeAdditional","useDefaults","coerceTypes"],$=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),m={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."},h={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},v=200;function k(N){var w,j,b,u,p,P,M,z,J,G,he,et,Lt,Vt,Ht,Zt,Kt,Gt,Wt,Bt,Jt,Qt,Yt,Xt,er;const ct=N.strict,tr=(w=N.code)===null||w===void 0?void 0:w.optimize,Jr=tr===!0||tr===void 0?1:tr||0,Qr=(b=(j=N.code)===null||j===void 0?void 0:j.regExp)!==null&&b!==void 0?b:y,Xs=(u=N.uriResolver)!==null&&u!==void 0?u:_.default;return{strictSchema:(P=(p=N.strictSchema)!==null&&p!==void 0?p:ct)!==null&&P!==void 0?P:!0,strictNumbers:(z=(M=N.strictNumbers)!==null&&M!==void 0?M:ct)!==null&&z!==void 0?z:!0,strictTypes:(G=(J=N.strictTypes)!==null&&J!==void 0?J:ct)!==null&&G!==void 0?G:"log",strictTuples:(et=(he=N.strictTuples)!==null&&he!==void 0?he:ct)!==null&&et!==void 0?et:"log",strictRequired:(Vt=(Lt=N.strictRequired)!==null&&Lt!==void 0?Lt:ct)!==null&&Vt!==void 0?Vt:!1,code:N.code?{...N.code,optimize:Jr,regExp:Qr}:{optimize:Jr,regExp:Qr},loopRequired:(Ht=N.loopRequired)!==null&&Ht!==void 0?Ht:v,loopEnum:(Zt=N.loopEnum)!==null&&Zt!==void 0?Zt:v,meta:(Kt=N.meta)!==null&&Kt!==void 0?Kt:!0,messages:(Gt=N.messages)!==null&&Gt!==void 0?Gt:!0,inlineRefs:(Wt=N.inlineRefs)!==null&&Wt!==void 0?Wt:!0,schemaId:(Bt=N.schemaId)!==null&&Bt!==void 0?Bt:"$id",addUsedSchema:(Jt=N.addUsedSchema)!==null&&Jt!==void 0?Jt:!0,validateSchema:(Qt=N.validateSchema)!==null&&Qt!==void 0?Qt:!0,validateFormats:(Yt=N.validateFormats)!==null&&Yt!==void 0?Yt:!0,unicodeRegExp:(Xt=N.unicodeRegExp)!==null&&Xt!==void 0?Xt:!0,int32range:(er=N.int32range)!==null&&er!==void 0?er:!0,uriResolver:Xs}}class R{constructor(w={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,w=this.opts={...w,...k(w)};const{es5:j,lines:b}=this.opts.code;this.scope=new i.ValueScope({scope:{},prefixes:$,es5:j,lines:b}),this.logger=B(w.logger);const u=w.validateFormats;w.validateFormats=!1,this.RULES=(0,o.getRules)(),E.call(this,m,w,"NOT SUPPORTED"),E.call(this,h,w,"DEPRECATED","warn"),this._metaOpts=D.call(this),w.formats&&q.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),w.keywords&&Z.call(this,w.keywords),typeof w.meta=="object"&&this.addMetaSchema(w.meta),x.call(this),w.validateFormats=u}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:w,meta:j,schemaId:b}=this.opts;let u=f;b==="id"&&(u={...f},u.id=u.$id,delete u.$id),j&&w&&this.addMetaSchema(u,u[b],!1)}defaultMeta(){const{meta:w,schemaId:j}=this.opts;return this.opts.defaultMeta=typeof w=="object"?w[j]||w:void 0}validate(w,j){let b;if(typeof w=="string"){if(b=this.getSchema(w),!b)throw new Error(`no schema with key or ref "${w}"`)}else b=this.compile(w);const u=b(j);return"$async"in b||(this.errors=b.errors),u}compile(w,j){const b=this._addSchema(w,j);return b.validate||this._compileSchemaEnv(b)}compileAsync(w,j){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");const{loadSchema:b}=this.opts;return u.call(this,w,j);async function u(G,he){await p.call(this,G.$schema);const et=this._addSchema(G,he);return et.validate||P.call(this,et)}async function p(G){G&&!this.getSchema(G)&&await u.call(this,{$ref:G},!0)}async function P(G){try{return this._compileSchemaEnv(G)}catch(he){if(!(he instanceof s.default))throw he;return M.call(this,he),await z.call(this,he.missingSchema),P.call(this,G)}}function M({missingSchema:G,missingRef:he}){if(this.refs[G])throw new Error(`AnySchema ${G} is loaded but ${he} cannot be resolved`)}async function z(G){const he=await J.call(this,G);this.refs[G]||await p.call(this,he.$schema),this.refs[G]||this.addSchema(he,G,j)}async function J(G){const he=this._loading[G];if(he)return he;try{return await(this._loading[G]=b(G))}finally{delete this._loading[G]}}}addSchema(w,j,b,u=this.opts.validateSchema){if(Array.isArray(w)){for(const P of w)this.addSchema(P,void 0,b,u);return this}let p;if(typeof w=="object"){const{schemaId:P}=this.opts;if(p=w[P],p!==void 0&&typeof p!="string")throw new Error(`schema ${P} must be string`)}return j=(0,c.normalizeId)(j||p),this._checkUnique(j),this.schemas[j]=this._addSchema(w,b,j,u,!0),this}addMetaSchema(w,j,b=this.opts.validateSchema){return this.addSchema(w,j,!0,b),this}validateSchema(w,j){if(typeof w=="boolean")return!0;let b;if(b=w.$schema,b!==void 0&&typeof b!="string")throw new Error("$schema must be a string");if(b=b||this.opts.defaultMeta||this.defaultMeta(),!b)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const u=this.validate(b,w);if(!u&&j){const p="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(p);else throw new Error(p)}return u}getSchema(w){let j;for(;typeof(j=I.call(this,w))=="string";)w=j;if(j===void 0){const{schemaId:b}=this.opts,u=new a.SchemaEnv({schema:{},schemaId:b});if(j=a.resolveSchema.call(this,u,w),!j)return;this.refs[w]=j}return j.validate||this._compileSchemaEnv(j)}removeSchema(w){if(w instanceof RegExp)return this._removeAllSchemas(this.schemas,w),this._removeAllSchemas(this.refs,w),this;switch(typeof w){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const j=I.call(this,w);return typeof j=="object"&&this._cache.delete(j.schema),delete this.schemas[w],delete this.refs[w],this}case"object":{const j=w;this._cache.delete(j);let b=w[this.opts.schemaId];return b&&(b=(0,c.normalizeId)(b),delete this.schemas[b],delete this.refs[b]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(w){for(const j of w)this.addKeyword(j);return this}addKeyword(w,j){let b;if(typeof w=="string")b=w,typeof j=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),j.keyword=b);else if(typeof w=="object"&&j===void 0){if(j=w,b=j.keyword,Array.isArray(b)&&!b.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(U.call(this,b,j),!j)return(0,d.eachItem)(b,p=>le.call(this,p)),this;_e.call(this,j);const u={...j,type:(0,l.getJSONTypes)(j.type),schemaType:(0,l.getJSONTypes)(j.schemaType)};return(0,d.eachItem)(b,u.type.length===0?p=>le.call(this,p,u):p=>u.type.forEach(P=>le.call(this,p,u,P))),this}getKeyword(w){const j=this.RULES.all[w];return typeof j=="object"?j.definition:!!j}removeKeyword(w){const{RULES:j}=this;delete j.keywords[w],delete j.all[w];for(const b of j.rules){const u=b.rules.findIndex(p=>p.keyword===w);u>=0&&b.rules.splice(u,1)}return this}addFormat(w,j){return typeof j=="string"&&(j=new RegExp(j)),this.formats[w]=j,this}errorsText(w=this.errors,{separator:j=", ",dataVar:b="data"}={}){return!w||w.length===0?"No errors":w.map(u=>`${b}${u.instancePath} ${u.message}`).reduce((u,p)=>u+j+p)}$dataMetaSchema(w,j){const b=this.RULES.all;w=JSON.parse(JSON.stringify(w));for(const u of j){const p=u.split("/").slice(1);let P=w;for(const M of p)P=P[M];for(const M in b){const z=b[M];if(typeof z!="object")continue;const{$data:J}=z.definition,G=P[M];J&&G&&(P[M]=Ie(G))}}return w}_removeAllSchemas(w,j){for(const b in w){const u=w[b];(!j||j.test(b))&&(typeof u=="string"?delete w[b]:u&&!u.meta&&(this._cache.delete(u.schema),delete w[b]))}}_addSchema(w,j,b,u=this.opts.validateSchema,p=this.opts.addUsedSchema){let P;const{schemaId:M}=this.opts;if(typeof w=="object")P=w[M];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof w!="boolean")throw new Error("schema must be object or boolean")}let z=this._cache.get(w);if(z!==void 0)return z;b=(0,c.normalizeId)(P||b);const J=c.getSchemaRefs.call(this,w,b);return z=new a.SchemaEnv({schema:w,schemaId:M,meta:j,baseId:b,localRefs:J}),this._cache.set(z.schema,z),p&&!b.startsWith("#")&&(b&&this._checkUnique(b),this.refs[b]=z),u&&this.validateSchema(w,!0),z}_checkUnique(w){if(this.schemas[w]||this.refs[w])throw new Error(`schema with key or id "${w}" already exists`)}_compileSchemaEnv(w){if(w.meta?this._compileMetaSchema(w):a.compileSchema.call(this,w),!w.validate)throw new Error("ajv implementation error");return w.validate}_compileMetaSchema(w){const j=this.opts;this.opts=this._metaOpts;try{a.compileSchema.call(this,w)}finally{this.opts=j}}}R.ValidationError=n.default,R.MissingRefError=s.default,e.default=R;function E(N,w,j,b="error"){for(const u in N){const p=u;p in w&&this.logger[b](`${j}: option ${u}. ${N[p]}`)}}function I(N){return N=(0,c.normalizeId)(N),this.schemas[N]||this.refs[N]}function x(){const N=this.opts.schemas;if(N)if(Array.isArray(N))this.addSchema(N);else for(const w in N)this.addSchema(N[w],w)}function q(){for(const N in this.opts.formats){const w=this.opts.formats[N];w&&this.addFormat(N,w)}}function Z(N){if(Array.isArray(N)){this.addVocabulary(N);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const w in N){const j=N[w];j.keyword||(j.keyword=w),this.addKeyword(j)}}function D(){const N={...this.opts};for(const w of g)delete N[w];return N}const L={log(){},warn(){},error(){}};function B(N){if(N===!1)return L;if(N===void 0)return console;if(N.log&&N.warn&&N.error)return N;throw new Error("logger must implement log, warn and error methods")}const ce=/^[a-z_$][a-z0-9_$:-]*$/i;function U(N,w){const{RULES:j}=this;if((0,d.eachItem)(N,b=>{if(j.keywords[b])throw new Error(`Keyword ${b} is already defined`);if(!ce.test(b))throw new Error(`Keyword ${b} has invalid name`)}),!!w&&w.$data&&!("code"in w||"validate"in w))throw new Error('$data keyword must have "code" or "validate" function')}function le(N,w,j){var b;const u=w==null?void 0:w.post;if(j&&u)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:p}=this;let P=u?p.post:p.rules.find(({type:z})=>z===j);if(P||(P={type:j,rules:[]},p.rules.push(P)),p.keywords[N]=!0,!w)return;const M={keyword:N,definition:{...w,type:(0,l.getJSONTypes)(w.type),schemaType:(0,l.getJSONTypes)(w.schemaType)}};w.before?je.call(this,P,M,w.before):P.rules.push(M),p.all[N]=M,(b=w.implements)===null||b===void 0||b.forEach(z=>this.addKeyword(z))}function je(N,w,j){const b=N.rules.findIndex(u=>u.keyword===j);b>=0?N.rules.splice(b,0,w):(N.rules.push(w),this.logger.warn(`rule ${j} is not defined`))}function _e(N){let{metaSchema:w}=N;w!==void 0&&(N.$data&&this.opts.$data&&(w=Ie(w)),N.validateSchema=this.compile(w,!0))}const it={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Ie(N){return{anyOf:[N,it]}}})(kf);var Bi={},Ji={},Qi={};Object.defineProperty(Qi,"__esModule",{value:!0});const P1={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Qi.default=P1;var vr={};Object.defineProperty(vr,"__esModule",{value:!0});vr.callRef=vr.getValidate=void 0;const T1=Gr,Ml=de,Je=ie,kr=Et,zl=Ye,Jn=H,R1={keyword:"$ref",schemaType:"string",code(e){const{gen:t,schema:r,it:n}=e,{baseId:s,schemaEnv:o,validateName:a,opts:i,self:c}=n,{root:l}=o;if((r==="#"||r==="#/")&&s===l.baseId)return f();const d=zl.resolveRef.call(c,l,s,r);if(d===void 0)throw new T1.default(n.opts.uriResolver,s,r);if(d instanceof zl.SchemaEnv)return _(d);return y(d);function f(){if(o===l)return ls(e,a,o,o.$async);const g=t.scopeValue("root",{ref:l});return ls(e,(0,Je._)`${g}.validate`,l,l.$async)}function _(g){const $=sh(e,g);ls(e,$,g,g.$async)}function y(g){const $=t.scopeValue("schema",i.code.source===!0?{ref:g,code:(0,Je.stringify)(g)}:{ref:g}),m=t.name("valid"),h=e.subschema({schema:g,dataTypes:[],schemaPath:Je.nil,topSchemaRef:$,errSchemaPath:r},m);e.mergeEvaluated(h),e.ok(m)}}};function sh(e,t){const{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,Je._)`${r.scopeValue("wrapper",{ref:t})}.validate`}vr.getValidate=sh;function ls(e,t,r,n){const{gen:s,it:o}=e,{allErrors:a,schemaEnv:i,opts:c}=o,l=c.passContext?kr.default.this:Je.nil;n?d():f();function d(){if(!i.$async)throw new Error("async schema referenced by sync schema");const g=s.let("valid");s.try(()=>{s.code((0,Je._)`await ${(0,Ml.callValidateCode)(e,t,l)}`),y(t),a||s.assign(g,!0)},$=>{s.if((0,Je._)`!(${$} instanceof ${o.ValidationError})`,()=>s.throw($)),_($),a||s.assign(g,!1)}),e.ok(g)}function f(){e.result((0,Ml.callValidateCode)(e,t,l),()=>y(t),()=>_(t))}function _(g){const $=(0,Je._)`${g}.errors`;s.assign(kr.default.vErrors,(0,Je._)`${kr.default.vErrors} === null ? ${$} : ${kr.default.vErrors}.concat(${$})`),s.assign(kr.default.errors,(0,Je._)`${kr.default.vErrors}.length`)}function y(g){var $;if(!o.opts.unevaluated)return;const m=($=r==null?void 0:r.validate)===null||$===void 0?void 0:$.evaluated;if(o.props!==!0)if(m&&!m.dynamicProps)m.props!==void 0&&(o.props=Jn.mergeEvaluated.props(s,m.props,o.props));else{const h=s.var("props",(0,Je._)`${g}.evaluated.props`);o.props=Jn.mergeEvaluated.props(s,h,o.props,Je.Name)}if(o.items!==!0)if(m&&!m.dynamicItems)m.items!==void 0&&(o.items=Jn.mergeEvaluated.items(s,m.items,o.items));else{const h=s.var("items",(0,Je._)`${g}.evaluated.items`);o.items=Jn.mergeEvaluated.items(s,h,o.items,Je.Name)}}}vr.callRef=ls;vr.default=R1;Object.defineProperty(Ji,"__esModule",{value:!0});const j1=Qi,C1=vr,N1=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",j1.default,C1.default];Ji.default=N1;var Yi={},Xi={};Object.defineProperty(Xi,"__esModule",{value:!0});const Ps=ie,It=Ps.operators,Ts={maximum:{okStr:"<=",ok:It.LTE,fail:It.GT},minimum:{okStr:">=",ok:It.GTE,fail:It.LT},exclusiveMaximum:{okStr:"<",ok:It.LT,fail:It.GTE},exclusiveMinimum:{okStr:">",ok:It.GT,fail:It.LTE}},I1={message:({keyword:e,schemaCode:t})=>(0,Ps.str)`must be ${Ts[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,Ps._)`{comparison: ${Ts[e].okStr}, limit: ${t}}`},O1={keyword:Object.keys(Ts),type:"number",schemaType:"number",$data:!0,error:I1,code(e){const{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,Ps._)`${r} ${Ts[t].fail} ${n} || isNaN(${r})`)}};Xi.default=O1;var ec={};Object.defineProperty(ec,"__esModule",{value:!0});const mn=ie,x1={message:({schemaCode:e})=>(0,mn.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,mn._)`{multipleOf: ${e}}`},A1={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:x1,code(e){const{gen:t,data:r,schemaCode:n,it:s}=e,o=s.opts.multipleOfPrecision,a=t.let("res"),i=o?(0,mn._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${o}`:(0,mn._)`${a} !== parseInt(${a})`;e.fail$data((0,mn._)`(${n} === 0 || (${a} = ${r}/${n}, ${i}))`)}};ec.default=A1;var tc={},rc={};Object.defineProperty(rc,"__esModule",{value:!0});function oh(e){const t=e.length;let r=0,n=0,s;for(;n=55296&&s<=56319&&n(0,dr._)`{limit: ${e}}`},q1={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:D1,code(e){const{keyword:t,data:r,schemaCode:n,it:s}=e,o=t==="maxLength"?dr.operators.GT:dr.operators.LT,a=s.opts.unicode===!1?(0,dr._)`${r}.length`:(0,dr._)`${(0,M1.useFunc)(e.gen,z1.default)}(${r})`;e.fail$data((0,dr._)`${a} ${o} ${n}`)}};tc.default=q1;var nc={};Object.defineProperty(nc,"__esModule",{value:!0});const U1=de,F1=H,Ir=ie,L1={message:({schemaCode:e})=>(0,Ir.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Ir._)`{pattern: ${e}}`},V1={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:L1,code(e){const{gen:t,data:r,$data:n,schema:s,schemaCode:o,it:a}=e,i=a.opts.unicodeRegExp?"u":"";if(n){const{regExp:c}=a.opts.code,l=c.code==="new RegExp"?(0,Ir._)`new RegExp`:(0,F1.useFunc)(t,c),d=t.let("valid");t.try(()=>t.assign(d,(0,Ir._)`${l}(${o}, ${i}).test(${r})`),()=>t.assign(d,!1)),e.fail$data((0,Ir._)`!${d}`)}else{const c=(0,U1.usePattern)(e,s);e.fail$data((0,Ir._)`!${c}.test(${r})`)}}};nc.default=V1;var sc={};Object.defineProperty(sc,"__esModule",{value:!0});const gn=ie,H1={message({keyword:e,schemaCode:t}){const r=e==="maxProperties"?"more":"fewer";return(0,gn.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,gn._)`{limit: ${e}}`},Z1={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:H1,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxProperties"?gn.operators.GT:gn.operators.LT;e.fail$data((0,gn._)`Object.keys(${r}).length ${s} ${n}`)}};sc.default=Z1;var oc={};Object.defineProperty(oc,"__esModule",{value:!0});const rn=de,_n=ie,K1=H,G1={message:({params:{missingProperty:e}})=>(0,_n.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,_n._)`{missingProperty: ${e}}`},W1={keyword:"required",type:"object",schemaType:"array",$data:!0,error:G1,code(e){const{gen:t,schema:r,schemaCode:n,data:s,$data:o,it:a}=e,{opts:i}=a;if(!o&&r.length===0)return;const c=r.length>=i.loopRequired;if(a.allErrors?l():d(),i.strictRequired){const y=e.parentSchema.properties,{definedProperties:g}=e.it;for(const $ of r)if((y==null?void 0:y[$])===void 0&&!g.has($)){const m=a.schemaEnv.baseId+a.errSchemaPath,h=`required property "${$}" is not defined at "${m}" (strictRequired)`;(0,K1.checkStrictMode)(a,h,a.opts.strictRequired)}}function l(){if(c||o)e.block$data(_n.nil,f);else for(const y of r)(0,rn.checkReportMissingProp)(e,y)}function d(){const y=t.let("missing");if(c||o){const g=t.let("valid",!0);e.block$data(g,()=>_(y,g)),e.ok(g)}else t.if((0,rn.checkMissingProp)(e,r,y)),(0,rn.reportMissingProp)(e,y),t.else()}function f(){t.forOf("prop",n,y=>{e.setParams({missingProperty:y}),t.if((0,rn.noPropertyInData)(t,s,y,i.ownProperties),()=>e.error())})}function _(y,g){e.setParams({missingProperty:y}),t.forOf(y,n,()=>{t.assign(g,(0,rn.propertyInData)(t,s,y,i.ownProperties)),t.if((0,_n.not)(g),()=>{e.error(),t.break()})},_n.nil)}}};oc.default=W1;var ac={};Object.defineProperty(ac,"__esModule",{value:!0});const yn=ie,B1={message({keyword:e,schemaCode:t}){const r=e==="maxItems"?"more":"fewer";return(0,yn.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,yn._)`{limit: ${e}}`},J1={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:B1,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxItems"?yn.operators.GT:yn.operators.LT;e.fail$data((0,yn._)`${r}.length ${s} ${n}`)}};ac.default=J1;var ic={},Un={};Object.defineProperty(Un,"__esModule",{value:!0});const ah=Ls;ah.code='require("ajv/dist/runtime/equal").default';Un.default=ah;Object.defineProperty(ic,"__esModule",{value:!0});const fo=xe,De=ie,Q1=H,Y1=Un,X1={message:({params:{i:e,j:t}})=>(0,De.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,De._)`{i: ${e}, j: ${t}}`},eP={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:X1,code(e){const{gen:t,data:r,$data:n,schema:s,parentSchema:o,schemaCode:a,it:i}=e;if(!n&&!s)return;const c=t.let("valid"),l=o.items?(0,fo.getSchemaTypes)(o.items):[];e.block$data(c,d,(0,De._)`${a} === false`),e.ok(c);function d(){const g=t.let("i",(0,De._)`${r}.length`),$=t.let("j");e.setParams({i:g,j:$}),t.assign(c,!0),t.if((0,De._)`${g} > 1`,()=>(f()?_:y)(g,$))}function f(){return l.length>0&&!l.some(g=>g==="object"||g==="array")}function _(g,$){const m=t.name("item"),h=(0,fo.checkDataTypes)(l,m,i.opts.strictNumbers,fo.DataType.Wrong),v=t.const("indices",(0,De._)`{}`);t.for((0,De._)`;${g}--;`,()=>{t.let(m,(0,De._)`${r}[${g}]`),t.if(h,(0,De._)`continue`),l.length>1&&t.if((0,De._)`typeof ${m} == "string"`,(0,De._)`${m} += "_"`),t.if((0,De._)`typeof ${v}[${m}] == "number"`,()=>{t.assign($,(0,De._)`${v}[${m}]`),e.error(),t.assign(c,!1).break()}).code((0,De._)`${v}[${m}] = ${g}`)})}function y(g,$){const m=(0,Q1.useFunc)(t,Y1.default),h=t.name("outer");t.label(h).for((0,De._)`;${g}--;`,()=>t.for((0,De._)`${$} = ${g}; ${$}--;`,()=>t.if((0,De._)`${m}(${r}[${g}], ${r}[${$}])`,()=>{e.error(),t.assign(c,!1).break(h)})))}}};ic.default=eP;var cc={};Object.defineProperty(cc,"__esModule",{value:!0});const Vo=ie,tP=H,rP=Un,nP={message:"must be equal to constant",params:({schemaCode:e})=>(0,Vo._)`{allowedValue: ${e}}`},sP={keyword:"const",$data:!0,error:nP,code(e){const{gen:t,data:r,$data:n,schemaCode:s,schema:o}=e;n||o&&typeof o=="object"?e.fail$data((0,Vo._)`!${(0,tP.useFunc)(t,rP.default)}(${r}, ${s})`):e.fail((0,Vo._)`${o} !== ${r}`)}};cc.default=sP;var lc={};Object.defineProperty(lc,"__esModule",{value:!0});const an=ie,oP=H,aP=Un,iP={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,an._)`{allowedValues: ${e}}`},cP={keyword:"enum",schemaType:"array",$data:!0,error:iP,code(e){const{gen:t,data:r,$data:n,schema:s,schemaCode:o,it:a}=e;if(!n&&s.length===0)throw new Error("enum must have non-empty array");const i=s.length>=a.opts.loopEnum;let c;const l=()=>c??(c=(0,oP.useFunc)(t,aP.default));let d;if(i||n)d=t.let("valid"),e.block$data(d,f);else{if(!Array.isArray(s))throw new Error("ajv implementation error");const y=t.const("vSchema",o);d=(0,an.or)(...s.map((g,$)=>_(y,$)))}e.pass(d);function f(){t.assign(d,!1),t.forOf("v",o,y=>t.if((0,an._)`${l()}(${r}, ${y})`,()=>t.assign(d,!0).break()))}function _(y,g){const $=s[g];return typeof $=="object"&&$!==null?(0,an._)`${l()}(${r}, ${y}[${g}])`:(0,an._)`${r} === ${$}`}}};lc.default=cP;Object.defineProperty(Yi,"__esModule",{value:!0});const lP=Xi,uP=ec,dP=tc,fP=nc,hP=sc,pP=oc,mP=ac,gP=ic,_P=cc,yP=lc,vP=[lP.default,uP.default,dP.default,fP.default,hP.default,pP.default,mP.default,gP.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},_P.default,yP.default];Yi.default=vP;var uc={},Wr={};Object.defineProperty(Wr,"__esModule",{value:!0});Wr.validateAdditionalItems=void 0;const fr=ie,Ho=H,$P={message:({params:{len:e}})=>(0,fr.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,fr._)`{limit: ${e}}`},wP={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:$P,code(e){const{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,Ho.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}ih(e,n)}};function ih(e,t){const{gen:r,schema:n,data:s,keyword:o,it:a}=e;a.items=!0;const i=r.const("len",(0,fr._)`${s}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,fr._)`${i} <= ${t.length}`);else if(typeof n=="object"&&!(0,Ho.alwaysValidSchema)(a,n)){const l=r.var("valid",(0,fr._)`${i} <= ${t.length}`);r.if((0,fr.not)(l),()=>c(l)),e.ok(l)}function c(l){r.forRange("i",t.length,i,d=>{e.subschema({keyword:o,dataProp:d,dataPropType:Ho.Type.Num},l),a.allErrors||r.if((0,fr.not)(l),()=>r.break())})}}Wr.validateAdditionalItems=ih;Wr.default=wP;var dc={},Br={};Object.defineProperty(Br,"__esModule",{value:!0});Br.validateTuple=void 0;const Dl=ie,us=H,bP=de,SP={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:t,it:r}=e;if(Array.isArray(t))return ch(e,"additionalItems",t);r.items=!0,!(0,us.alwaysValidSchema)(r,t)&&e.ok((0,bP.validateArray)(e))}};function ch(e,t,r=e.schema){const{gen:n,parentSchema:s,data:o,keyword:a,it:i}=e;d(s),i.opts.unevaluated&&r.length&&i.items!==!0&&(i.items=us.mergeEvaluated.items(n,r.length,i.items));const c=n.name("valid"),l=n.const("len",(0,Dl._)`${o}.length`);r.forEach((f,_)=>{(0,us.alwaysValidSchema)(i,f)||(n.if((0,Dl._)`${l} > ${_}`,()=>e.subschema({keyword:a,schemaProp:_,dataProp:_},c)),e.ok(c))});function d(f){const{opts:_,errSchemaPath:y}=i,g=r.length,$=g===f.minItems&&(g===f.maxItems||f[t]===!1);if(_.strictTuples&&!$){const m=`"${a}" is ${g}-tuple, but minItems or maxItems/${t} are not specified or different at path "${y}"`;(0,us.checkStrictMode)(i,m,_.strictTuples)}}}Br.validateTuple=ch;Br.default=SP;Object.defineProperty(dc,"__esModule",{value:!0});const EP=Br,kP={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,EP.validateTuple)(e,"items")};dc.default=kP;var fc={};Object.defineProperty(fc,"__esModule",{value:!0});const ql=ie,PP=H,TP=de,RP=Wr,jP={message:({params:{len:e}})=>(0,ql.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,ql._)`{limit: ${e}}`},CP={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:jP,code(e){const{schema:t,parentSchema:r,it:n}=e,{prefixItems:s}=r;n.items=!0,!(0,PP.alwaysValidSchema)(n,t)&&(s?(0,RP.validateAdditionalItems)(e,s):e.ok((0,TP.validateArray)(e)))}};fc.default=CP;var hc={};Object.defineProperty(hc,"__esModule",{value:!0});const st=ie,Qn=H,NP={message:({params:{min:e,max:t}})=>t===void 0?(0,st.str)`must contain at least ${e} valid item(s)`:(0,st.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,st._)`{minContains: ${e}}`:(0,st._)`{minContains: ${e}, maxContains: ${t}}`},IP={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:NP,code(e){const{gen:t,schema:r,parentSchema:n,data:s,it:o}=e;let a,i;const{minContains:c,maxContains:l}=n;o.opts.next?(a=c===void 0?1:c,i=l):a=1;const d=t.const("len",(0,st._)`${s}.length`);if(e.setParams({min:a,max:i}),i===void 0&&a===0){(0,Qn.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(i!==void 0&&a>i){(0,Qn.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,Qn.alwaysValidSchema)(o,r)){let $=(0,st._)`${d} >= ${a}`;i!==void 0&&($=(0,st._)`${$} && ${d} <= ${i}`),e.pass($);return}o.items=!0;const f=t.name("valid");i===void 0&&a===1?y(f,()=>t.if(f,()=>t.break())):a===0?(t.let(f,!0),i!==void 0&&t.if((0,st._)`${s}.length > 0`,_)):(t.let(f,!1),_()),e.result(f,()=>e.reset());function _(){const $=t.name("_valid"),m=t.let("count",0);y($,()=>t.if($,()=>g(m)))}function y($,m){t.forRange("i",0,d,h=>{e.subschema({keyword:"contains",dataProp:h,dataPropType:Qn.Type.Num,compositeRule:!0},$),m()})}function g($){t.code((0,st._)`${$}++`),i===void 0?t.if((0,st._)`${$} >= ${a}`,()=>t.assign(f,!0).break()):(t.if((0,st._)`${$} > ${i}`,()=>t.assign(f,!1).break()),a===1?t.assign(f,!0):t.if((0,st._)`${$} >= ${a}`,()=>t.assign(f,!0)))}}};hc.default=IP;var lh={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;const t=ie,r=H,n=de;e.error={message:({params:{property:c,depsCount:l,deps:d}})=>{const f=l===1?"property":"properties";return(0,t.str)`must have ${f} ${d} when property ${c} is present`},params:({params:{property:c,depsCount:l,deps:d,missingProperty:f}})=>(0,t._)`{property: ${c}, + missingProperty: ${f}, + depsCount: ${l}, + deps: ${d}}`};const s={keyword:"dependencies",type:"object",schemaType:"object",error:e.error,code(c){const[l,d]=o(c);a(c,l),i(c,d)}};function o({schema:c}){const l={},d={};for(const f in c){if(f==="__proto__")continue;const _=Array.isArray(c[f])?l:d;_[f]=c[f]}return[l,d]}function a(c,l=c.schema){const{gen:d,data:f,it:_}=c;if(Object.keys(l).length===0)return;const y=d.let("missing");for(const g in l){const $=l[g];if($.length===0)continue;const m=(0,n.propertyInData)(d,f,g,_.opts.ownProperties);c.setParams({property:g,depsCount:$.length,deps:$.join(", ")}),_.allErrors?d.if(m,()=>{for(const h of $)(0,n.checkReportMissingProp)(c,h)}):(d.if((0,t._)`${m} && (${(0,n.checkMissingProp)(c,$,y)})`),(0,n.reportMissingProp)(c,y),d.else())}}e.validatePropertyDeps=a;function i(c,l=c.schema){const{gen:d,data:f,keyword:_,it:y}=c,g=d.name("valid");for(const $ in l)(0,r.alwaysValidSchema)(y,l[$])||(d.if((0,n.propertyInData)(d,f,$,y.opts.ownProperties),()=>{const m=c.subschema({keyword:_,schemaProp:$},g);c.mergeValidEvaluated(m,g)},()=>d.var(g,!0)),c.ok(g))}e.validateSchemaDeps=i,e.default=s})(lh);var pc={};Object.defineProperty(pc,"__esModule",{value:!0});const uh=ie,OP=H,xP={message:"property name must be valid",params:({params:e})=>(0,uh._)`{propertyName: ${e.propertyName}}`},AP={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:xP,code(e){const{gen:t,schema:r,data:n,it:s}=e;if((0,OP.alwaysValidSchema)(s,r))return;const o=t.name("valid");t.forIn("key",n,a=>{e.setParams({propertyName:a}),e.subschema({keyword:"propertyNames",data:a,dataTypes:["string"],propertyName:a,compositeRule:!0},o),t.if((0,uh.not)(o),()=>{e.error(!0),s.allErrors||t.break()})}),e.ok(o)}};pc.default=AP;var Qs={};Object.defineProperty(Qs,"__esModule",{value:!0});const Yn=de,ft=ie,MP=Et,Xn=H,zP={message:"must NOT have additional properties",params:({params:e})=>(0,ft._)`{additionalProperty: ${e.additionalProperty}}`},DP={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:zP,code(e){const{gen:t,schema:r,parentSchema:n,data:s,errsCount:o,it:a}=e;if(!o)throw new Error("ajv implementation error");const{allErrors:i,opts:c}=a;if(a.props=!0,c.removeAdditional!=="all"&&(0,Xn.alwaysValidSchema)(a,r))return;const l=(0,Yn.allSchemaProperties)(n.properties),d=(0,Yn.allSchemaProperties)(n.patternProperties);f(),e.ok((0,ft._)`${o} === ${MP.default.errors}`);function f(){t.forIn("key",s,m=>{!l.length&&!d.length?g(m):t.if(_(m),()=>g(m))})}function _(m){let h;if(l.length>8){const v=(0,Xn.schemaRefOrVal)(a,n.properties,"properties");h=(0,Yn.isOwnProperty)(t,v,m)}else l.length?h=(0,ft.or)(...l.map(v=>(0,ft._)`${m} === ${v}`)):h=ft.nil;return d.length&&(h=(0,ft.or)(h,...d.map(v=>(0,ft._)`${(0,Yn.usePattern)(e,v)}.test(${m})`))),(0,ft.not)(h)}function y(m){t.code((0,ft._)`delete ${s}[${m}]`)}function g(m){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){y(m);return}if(r===!1){e.setParams({additionalProperty:m}),e.error(),i||t.break();return}if(typeof r=="object"&&!(0,Xn.alwaysValidSchema)(a,r)){const h=t.name("valid");c.removeAdditional==="failing"?($(m,h,!1),t.if((0,ft.not)(h),()=>{e.reset(),y(m)})):($(m,h),i||t.if((0,ft.not)(h),()=>t.break()))}}function $(m,h,v){const k={keyword:"additionalProperties",dataProp:m,dataPropType:Xn.Type.Str};v===!1&&Object.assign(k,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(k,h)}}};Qs.default=DP;var mc={};Object.defineProperty(mc,"__esModule",{value:!0});const qP=_t,Ul=de,ho=H,Fl=Qs,UP={keyword:"properties",type:"object",schemaType:"object",code(e){const{gen:t,schema:r,parentSchema:n,data:s,it:o}=e;o.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&Fl.default.code(new qP.KeywordCxt(o,Fl.default,"additionalProperties"));const a=(0,Ul.allSchemaProperties)(r);for(const f of a)o.definedProperties.add(f);o.opts.unevaluated&&a.length&&o.props!==!0&&(o.props=ho.mergeEvaluated.props(t,(0,ho.toHash)(a),o.props));const i=a.filter(f=>!(0,ho.alwaysValidSchema)(o,r[f]));if(i.length===0)return;const c=t.name("valid");for(const f of i)l(f)?d(f):(t.if((0,Ul.propertyInData)(t,s,f,o.opts.ownProperties)),d(f),o.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(f),e.ok(c);function l(f){return o.opts.useDefaults&&!o.compositeRule&&r[f].default!==void 0}function d(f){e.subschema({keyword:"properties",schemaProp:f,dataProp:f},c)}}};mc.default=UP;var gc={};Object.defineProperty(gc,"__esModule",{value:!0});const Ll=de,es=ie,Vl=H,Hl=H,FP={keyword:"patternProperties",type:"object",schemaType:"object",code(e){const{gen:t,schema:r,data:n,parentSchema:s,it:o}=e,{opts:a}=o,i=(0,Ll.allSchemaProperties)(r),c=i.filter($=>(0,Vl.alwaysValidSchema)(o,r[$]));if(i.length===0||c.length===i.length&&(!o.opts.unevaluated||o.props===!0))return;const l=a.strictSchema&&!a.allowMatchingProperties&&s.properties,d=t.name("valid");o.props!==!0&&!(o.props instanceof es.Name)&&(o.props=(0,Hl.evaluatedPropsToName)(t,o.props));const{props:f}=o;_();function _(){for(const $ of i)l&&y($),o.allErrors?g($):(t.var(d,!0),g($),t.if(d))}function y($){for(const m in l)new RegExp($).test(m)&&(0,Vl.checkStrictMode)(o,`property ${m} matches pattern ${$} (use allowMatchingProperties)`)}function g($){t.forIn("key",n,m=>{t.if((0,es._)`${(0,Ll.usePattern)(e,$)}.test(${m})`,()=>{const h=c.includes($);h||e.subschema({keyword:"patternProperties",schemaProp:$,dataProp:m,dataPropType:Hl.Type.Str},d),o.opts.unevaluated&&f!==!0?t.assign((0,es._)`${f}[${m}]`,!0):!h&&!o.allErrors&&t.if((0,es.not)(d),()=>t.break())})})}}};gc.default=FP;var _c={};Object.defineProperty(_c,"__esModule",{value:!0});const LP=H,VP={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:r,it:n}=e;if((0,LP.alwaysValidSchema)(n,r)){e.fail();return}const s=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},s),e.failResult(s,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};_c.default=VP;var yc={};Object.defineProperty(yc,"__esModule",{value:!0});const HP=de,ZP={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:HP.validateUnion,error:{message:"must match a schema in anyOf"}};yc.default=ZP;var vc={};Object.defineProperty(vc,"__esModule",{value:!0});const ds=ie,KP=H,GP={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,ds._)`{passingSchemas: ${e.passing}}`},WP={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:GP,code(e){const{gen:t,schema:r,parentSchema:n,it:s}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(s.opts.discriminator&&n.discriminator)return;const o=r,a=t.let("valid",!1),i=t.let("passing",null),c=t.name("_valid");e.setParams({passing:i}),t.block(l),e.result(a,()=>e.reset(),()=>e.error(!0));function l(){o.forEach((d,f)=>{let _;(0,KP.alwaysValidSchema)(s,d)?t.var(c,!0):_=e.subschema({keyword:"oneOf",schemaProp:f,compositeRule:!0},c),f>0&&t.if((0,ds._)`${c} && ${a}`).assign(a,!1).assign(i,(0,ds._)`[${i}, ${f}]`).else(),t.if(c,()=>{t.assign(a,!0),t.assign(i,f),_&&e.mergeEvaluated(_,ds.Name)})})}}};vc.default=WP;var $c={};Object.defineProperty($c,"__esModule",{value:!0});const BP=H,JP={keyword:"allOf",schemaType:"array",code(e){const{gen:t,schema:r,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");const s=t.name("valid");r.forEach((o,a)=>{if((0,BP.alwaysValidSchema)(n,o))return;const i=e.subschema({keyword:"allOf",schemaProp:a},s);e.ok(s),e.mergeEvaluated(i)})}};$c.default=JP;var wc={};Object.defineProperty(wc,"__esModule",{value:!0});const Rs=ie,dh=H,QP={message:({params:e})=>(0,Rs.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,Rs._)`{failingKeyword: ${e.ifClause}}`},YP={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:QP,code(e){const{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,dh.checkStrictMode)(n,'"if" without "then" and "else" is ignored');const s=Zl(n,"then"),o=Zl(n,"else");if(!s&&!o)return;const a=t.let("valid",!0),i=t.name("_valid");if(c(),e.reset(),s&&o){const d=t.let("ifClause");e.setParams({ifClause:d}),t.if(i,l("then",d),l("else",d))}else s?t.if(i,l("then")):t.if((0,Rs.not)(i),l("else"));e.pass(a,()=>e.error(!0));function c(){const d=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},i);e.mergeEvaluated(d)}function l(d,f){return()=>{const _=e.subschema({keyword:d},i);t.assign(a,i),e.mergeValidEvaluated(_,a),f?t.assign(f,(0,Rs._)`${d}`):e.setParams({ifClause:d})}}}};function Zl(e,t){const r=e.schema[t];return r!==void 0&&!(0,dh.alwaysValidSchema)(e,r)}wc.default=YP;var bc={};Object.defineProperty(bc,"__esModule",{value:!0});const XP=H,eT={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,XP.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};bc.default=eT;Object.defineProperty(uc,"__esModule",{value:!0});const tT=Wr,rT=dc,nT=Br,sT=fc,oT=hc,aT=lh,iT=pc,cT=Qs,lT=mc,uT=gc,dT=_c,fT=yc,hT=vc,pT=$c,mT=wc,gT=bc;function _T(e=!1){const t=[dT.default,fT.default,hT.default,pT.default,mT.default,gT.default,iT.default,cT.default,aT.default,lT.default,uT.default];return e?t.push(rT.default,sT.default):t.push(tT.default,nT.default),t.push(oT.default),t}uc.default=_T;var Sc={},Ec={};Object.defineProperty(Ec,"__esModule",{value:!0});const Ne=ie,yT={message:({schemaCode:e})=>(0,Ne.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,Ne._)`{format: ${e}}`},vT={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:yT,code(e,t){const{gen:r,data:n,$data:s,schema:o,schemaCode:a,it:i}=e,{opts:c,errSchemaPath:l,schemaEnv:d,self:f}=i;if(!c.validateFormats)return;s?_():y();function _(){const g=r.scopeValue("formats",{ref:f.formats,code:c.code.formats}),$=r.const("fDef",(0,Ne._)`${g}[${a}]`),m=r.let("fType"),h=r.let("format");r.if((0,Ne._)`typeof ${$} == "object" && !(${$} instanceof RegExp)`,()=>r.assign(m,(0,Ne._)`${$}.type || "string"`).assign(h,(0,Ne._)`${$}.validate`),()=>r.assign(m,(0,Ne._)`"string"`).assign(h,$)),e.fail$data((0,Ne.or)(v(),k()));function v(){return c.strictSchema===!1?Ne.nil:(0,Ne._)`${a} && !${h}`}function k(){const R=d.$async?(0,Ne._)`(${$}.async ? await ${h}(${n}) : ${h}(${n}))`:(0,Ne._)`${h}(${n})`,E=(0,Ne._)`(typeof ${h} == "function" ? ${R} : ${h}.test(${n}))`;return(0,Ne._)`${h} && ${h} !== true && ${m} === ${t} && !${E}`}}function y(){const g=f.formats[o];if(!g){v();return}if(g===!0)return;const[$,m,h]=k(g);$===t&&e.pass(R());function v(){if(c.strictSchema===!1){f.logger.warn(E());return}throw new Error(E());function E(){return`unknown format "${o}" ignored in schema at path "${l}"`}}function k(E){const I=E instanceof RegExp?(0,Ne.regexpCode)(E):c.code.formats?(0,Ne._)`${c.code.formats}${(0,Ne.getProperty)(o)}`:void 0,x=r.scopeValue("formats",{key:o,ref:E,code:I});return typeof E=="object"&&!(E instanceof RegExp)?[E.type||"string",E.validate,(0,Ne._)`${x}.validate`]:["string",E,x]}function R(){if(typeof g=="object"&&!(g instanceof RegExp)&&g.async){if(!d.$async)throw new Error("async format in sync schema");return(0,Ne._)`await ${h}(${n})`}return typeof m=="function"?(0,Ne._)`${h}(${n})`:(0,Ne._)`${h}.test(${n})`}}}};Ec.default=vT;Object.defineProperty(Sc,"__esModule",{value:!0});const $T=Ec,wT=[$T.default];Sc.default=wT;var Fr={};Object.defineProperty(Fr,"__esModule",{value:!0});Fr.contentVocabulary=Fr.metadataVocabulary=void 0;Fr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Fr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];Object.defineProperty(Bi,"__esModule",{value:!0});const bT=Ji,ST=Yi,ET=uc,kT=Sc,Kl=Fr,PT=[bT.default,ST.default,(0,ET.default)(),kT.default,Kl.metadataVocabulary,Kl.contentVocabulary];Bi.default=PT;var kc={},Ys={};Object.defineProperty(Ys,"__esModule",{value:!0});Ys.DiscrError=void 0;var Gl;(function(e){e.Tag="tag",e.Mapping="mapping"})(Gl||(Ys.DiscrError=Gl={}));Object.defineProperty(kc,"__esModule",{value:!0});const jr=ie,Zo=Ys,Wl=Ye,TT=Gr,RT=H,jT={message:({params:{discrError:e,tagName:t}})=>e===Zo.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,jr._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},CT={keyword:"discriminator",type:"object",schemaType:"object",error:jT,code(e){const{gen:t,data:r,schema:n,parentSchema:s,it:o}=e,{oneOf:a}=s;if(!o.opts.discriminator)throw new Error("discriminator: requires discriminator option");const i=n.propertyName;if(typeof i!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!a)throw new Error("discriminator: requires oneOf keyword");const c=t.let("valid",!1),l=t.const("tag",(0,jr._)`${r}${(0,jr.getProperty)(i)}`);t.if((0,jr._)`typeof ${l} == "string"`,()=>d(),()=>e.error(!1,{discrError:Zo.DiscrError.Tag,tag:l,tagName:i})),e.ok(c);function d(){const y=_();t.if(!1);for(const g in y)t.elseIf((0,jr._)`${l} === ${g}`),t.assign(c,f(y[g]));t.else(),e.error(!1,{discrError:Zo.DiscrError.Mapping,tag:l,tagName:i}),t.endIf()}function f(y){const g=t.name("valid"),$=e.subschema({keyword:"oneOf",schemaProp:y},g);return e.mergeEvaluated($,jr.Name),g}function _(){var y;const g={},$=h(s);let m=!0;for(let R=0;Rthis.addVocabulary(g)),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const g=this.opts.$data?this.$dataMetaSchema(o,a):o;this.addMetaSchema(g,i,!1),this.refs["http://json-schema.org/schema"]=i}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(i)?i:void 0)}}t.Ajv=c,e.exports=t=c,e.exports.Ajv=c,Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var l=_t;Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return l.KeywordCxt}});var d=ie;Object.defineProperty(t,"_",{enumerable:!0,get:function(){return d._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return d.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return d.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return d.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return d.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return d.CodeGen}});var f=qn;Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return f.default}});var _=Gr;Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return _.default}})})(Do,Do.exports);var DT=Do.exports;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.formatLimitDefinition=void 0;const t=DT,r=ie,n=r.operators,s={formatMaximum:{okStr:"<=",ok:n.LTE,fail:n.GT},formatMinimum:{okStr:">=",ok:n.GTE,fail:n.LT},formatExclusiveMaximum:{okStr:"<",ok:n.LT,fail:n.GTE},formatExclusiveMinimum:{okStr:">",ok:n.GT,fail:n.LTE}},o={message:({keyword:i,schemaCode:c})=>(0,r.str)`should be ${s[i].okStr} ${c}`,params:({keyword:i,schemaCode:c})=>(0,r._)`{comparison: ${s[i].okStr}, limit: ${c}}`};e.formatLimitDefinition={keyword:Object.keys(s),type:"string",schemaType:"string",$data:!0,error:o,code(i){const{gen:c,data:l,schemaCode:d,keyword:f,it:_}=i,{opts:y,self:g}=_;if(!y.validateFormats)return;const $=new t.KeywordCxt(_,g.RULES.all.format.definition,"format");$.$data?m():h();function m(){const k=c.scopeValue("formats",{ref:g.formats,code:y.code.formats}),R=c.const("fmt",(0,r._)`${k}[${$.schemaCode}]`);i.fail$data((0,r.or)((0,r._)`typeof ${R} != "object"`,(0,r._)`${R} instanceof RegExp`,(0,r._)`typeof ${R}.compare != "function"`,v(R)))}function h(){const k=$.schema,R=g.formats[k];if(!R||R===!0)return;if(typeof R!="object"||R instanceof RegExp||typeof R.compare!="function")throw new Error(`"${f}": format "${k}" does not define "compare" function`);const E=c.scopeValue("formats",{key:k,ref:R,code:y.code.formats?(0,r._)`${y.code.formats}${(0,r.getProperty)(k)}`:void 0});i.fail$data(v(E))}function v(k){return(0,r._)`${k}.compare(${l}, ${d}) ${s[f].fail} 0`}},dependencies:["format"]};const a=i=>(i.addKeyword(e.formatLimitDefinition),i);e.default=a})(Ef);(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const r=Sf,n=Ef,s=ie,o=new s.Name("fullFormats"),a=new s.Name("fastFormats"),i=(l,d={keywords:!0})=>{if(Array.isArray(d))return c(l,d,r.fullFormats,o),l;const[f,_]=d.mode==="fast"?[r.fastFormats,a]:[r.fullFormats,o],y=d.formats||r.formatNames;return c(l,y,f,_),d.keywords&&(0,n.default)(l),l};i.get=(l,d="full")=>{const _=(d==="fast"?r.fastFormats:r.fullFormats)[l];if(!_)throw new Error(`Unknown format "${l}"`);return _};function c(l,d,f,_){var y,g;(y=(g=l.opts.code).formats)!==null&&y!==void 0||(g.formats=(0,s._)`require("ajv-formats/dist/formats").${_}`);for(const $ of d)l.addFormat($,f[$])}e.exports=t=i,Object.defineProperty(t,"__esModule",{value:!0}),t.default=i})(zo,zo.exports);var qT=zo.exports;const UT=su(qT);function FT(){const e=new PE({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return UT(e),e}class LT{constructor(t){this._ajv=t??FT()}getValidator(t){const r="$id"in t&&typeof t.$id=="string"?this._ajv.getSchema(t.$id)??this._ajv.compile(t):this._ajv.compile(t);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}}class VT{constructor(t){this._client=t}async*callToolStream(t,r=pr,n){const s=this._client,o={...n,task:(n==null?void 0:n.task)??(s.isToolTask(t.name)?{}:void 0)},a=s.requestStream({method:"tools/call",params:t},r,o),i=s.getToolOutputValidator(t.name);for await(const c of a){if(c.type==="result"&&i){const l=c.result;if(!l.structuredContent&&!l.isError){yield{type:"error",error:new X(re.InvalidRequest,`Tool ${t.name} has an output schema but did not return structured content`)};return}if(l.structuredContent)try{const d=i(l.structuredContent);if(!d.valid){yield{type:"error",error:new X(re.InvalidParams,`Structured content does not match the tool's output schema: ${d.errorMessage}`)};return}}catch(d){if(d instanceof X){yield{type:"error",error:d};return}yield{type:"error",error:new X(re.InvalidParams,`Failed to validate structured content: ${d instanceof Error?d.message:String(d)}`)};return}}yield c}}async getTask(t,r){return this._client.getTask({taskId:t},r)}async getTaskResult(t,r,n){return this._client.getTaskResult({taskId:t},r,n)}async listTasks(t,r){return this._client.listTasks(t?{cursor:t}:void 0,r)}async cancelTask(t,r){return this._client.cancelTask({taskId:t},r)}requestStream(t,r,n){return this._client.requestStream(t,r,n)}}function HT(e,t,r){var n;if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"tools/call":if(!((n=e.tools)!=null&&n.call))throw new Error(`${r} does not support task creation for tools/call (required for ${t})`);break}}function ZT(e,t,r){var n,s;if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!((n=e.sampling)!=null&&n.createMessage))throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!((s=e.elicitation)!=null&&s.create))throw new Error(`${r} does not support task creation for elicitation/create (required for ${t})`);break}}function fs(e,t){if(!(!e||t===null||typeof t!="object")){if(e.type==="object"&&e.properties&&typeof e.properties=="object"){const r=t,n=e.properties;for(const s of Object.keys(n)){const o=n[s];r[s]===void 0&&Object.prototype.hasOwnProperty.call(o,"default")&&(r[s]=o.default),r[s]!==void 0&&fs(o,r[s])}}if(Array.isArray(e.anyOf))for(const r of e.anyOf)typeof r!="boolean"&&fs(r,t);if(Array.isArray(e.oneOf))for(const r of e.oneOf)typeof r!="boolean"&&fs(r,t)}}function KT(e){if(!e)return{supportsFormMode:!1,supportsUrlMode:!1};const t=e.form!==void 0,r=e.url!==void 0;return{supportsFormMode:t||!t&&!r,supportsUrlMode:r}}class GT extends gd{constructor(t,r){super(r),this._clientInfo=t,this._cachedToolOutputValidators=new Map,this._cachedKnownTaskTools=new Set,this._cachedRequiredTaskTools=new Set,this._listChangedDebounceTimers=new Map,this._capabilities=(r==null?void 0:r.capabilities)??{},this._jsonSchemaValidator=(r==null?void 0:r.jsonSchemaValidator)??new LT,r!=null&&r.listChanged&&(this._pendingListChangedConfig=r.listChanged)}_setupListChangedHandlers(t){var r,n,s,o,a,i;t.tools&&((n=(r=this._serverCapabilities)==null?void 0:r.tools)!=null&&n.listChanged)&&this._setupListChangedHandler("tools",La,t.tools,async()=>(await this.listTools()).tools),t.prompts&&((o=(s=this._serverCapabilities)==null?void 0:s.prompts)!=null&&o.listChanged)&&this._setupListChangedHandler("prompts",qa,t.prompts,async()=>(await this.listPrompts()).prompts),t.resources&&((i=(a=this._serverCapabilities)==null?void 0:a.resources)!=null&&i.listChanged)&&this._setupListChangedHandler("resources",xa,t.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new VT(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Zv(this._capabilities,t)}setRequestHandler(t,r){const n=pd(t),s=n==null?void 0:n.method;if(!s)throw new Error("Schema is missing a method literal");const o=md(s);if(typeof o!="string")throw new Error("Schema method literal must be a string");const a=o;if(a==="elicitation/create"){const i=async(c,l)=>{var v,k;const d=Ot(dd,c);if(!d.success){const R=d.error instanceof Error?d.error.message:String(d.error);throw new X(re.InvalidParams,`Invalid elicitation request: ${R}`)}const{params:f}=d.data;f.mode=f.mode??"form";const{supportsFormMode:_,supportsUrlMode:y}=KT(this._capabilities.elicitation);if(f.mode==="form"&&!_)throw new X(re.InvalidParams,"Client does not support form-mode elicitation requests");if(f.mode==="url"&&!y)throw new X(re.InvalidParams,"Client does not support URL-mode elicitation requests");const g=await Promise.resolve(r(c,l));if(f.task){const R=Ot(wn,g);if(!R.success){const E=R.error instanceof Error?R.error.message:String(R.error);throw new X(re.InvalidParams,`Invalid task creation result: ${E}`)}return R.data}const $=Ot(fd,g);if(!$.success){const R=$.error instanceof Error?$.error.message:String($.error);throw new X(re.InvalidParams,`Invalid elicitation result: ${R}`)}const m=$.data,h=f.mode==="form"?f.requestedSchema:void 0;if(f.mode==="form"&&m.action==="accept"&&m.content&&h&&(k=(v=this._capabilities.elicitation)==null?void 0:v.form)!=null&&k.applyDefaults)try{fs(h,m.content)}catch{}return m};return super.setRequestHandler(t,i)}if(a==="sampling/createMessage"){const i=async(c,l)=>{const d=Ot(Va,c);if(!d.success){const m=d.error instanceof Error?d.error.message:String(d.error);throw new X(re.InvalidParams,`Invalid sampling request: ${m}`)}const{params:f}=d.data,_=await Promise.resolve(r(c,l));if(f.task){const m=Ot(wn,_);if(!m.success){const h=m.error instanceof Error?m.error.message:String(m.error);throw new X(re.InvalidParams,`Invalid task creation result: ${h}`)}return m.data}const g=f.tools||f.toolChoice?ud:ld,$=Ot(g,_);if(!$.success){const m=$.error instanceof Error?$.error.message:String($.error);throw new X(re.InvalidParams,`Invalid sampling result: ${m}`)}return $.data};return super.setRequestHandler(t,i)}return super.setRequestHandler(t,r)}assertCapability(t,r){var n;if(!((n=this._serverCapabilities)!=null&&n[t]))throw new Error(`Server does not support ${t} (required for ${r})`)}async connect(t,r){if(await super.connect(t),t.sessionId===void 0)try{const n=await this.request({method:"initialize",params:{protocolVersion:zs,capabilities:this._capabilities,clientInfo:this._clientInfo}},Gu,r);if(n===void 0)throw new Error(`Server sent invalid initialize result: ${n}`);if(!$y.includes(n.protocolVersion))throw new Error(`Server's protocol version is not supported: ${n.protocolVersion}`);this._serverCapabilities=n.capabilities,this._serverVersion=n.serverInfo,t.setProtocolVersion&&t.setProtocolVersion(n.protocolVersion),this._instructions=n.instructions,await this.notification({method:"notifications/initialized"}),this._pendingListChangedConfig&&(this._setupListChangedHandlers(this._pendingListChangedConfig),this._pendingListChangedConfig=void 0)}catch(n){throw this.close(),n}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(t){var r,n,s,o,a;switch(t){case"logging/setLevel":if(!((r=this._serverCapabilities)!=null&&r.logging))throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!((n=this._serverCapabilities)!=null&&n.prompts))throw new Error(`Server does not support prompts (required for ${t})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!((s=this._serverCapabilities)!=null&&s.resources))throw new Error(`Server does not support resources (required for ${t})`);if(t==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${t})`);break;case"tools/call":case"tools/list":if(!((o=this._serverCapabilities)!=null&&o.tools))throw new Error(`Server does not support tools (required for ${t})`);break;case"completion/complete":if(!((a=this._serverCapabilities)!=null&&a.completions))throw new Error(`Server does not support completions (required for ${t})`);break}}assertNotificationCapability(t){var r;switch(t){case"notifications/roots/list_changed":if(!((r=this._capabilities.roots)!=null&&r.listChanged))throw new Error(`Client does not support roots list changed notifications (required for ${t})`);break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${t})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${t})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${t})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Client does not support tasks capability (required for ${t})`);break}}assertTaskCapability(t){var r,n;HT((n=(r=this._serverCapabilities)==null?void 0:r.tasks)==null?void 0:n.requests,t,"Server")}assertTaskHandlerCapability(t){var r;this._capabilities&&ZT((r=this._capabilities.tasks)==null?void 0:r.requests,t,"Client")}async ping(t){return this.request({method:"ping"},Cr,t)}async complete(t,r){return this.request({method:"completion/complete",params:t},hd,r)}async setLoggingLevel(t,r){return this.request({method:"logging/setLevel",params:{level:t}},Cr,r)}async getPrompt(t,r){return this.request({method:"prompts/get",params:t},od,r)}async listPrompts(t,r){return this.request({method:"prompts/list",params:t},Aa,r)}async listResources(t,r){return this.request({method:"resources/list",params:t},Ca,r)}async listResourceTemplates(t,r){return this.request({method:"resources/templates/list",params:t},Na,r)}async readResource(t,r){return this.request({method:"resources/read",params:t},Oa,r)}async subscribeResource(t,r){return this.request({method:"resources/subscribe",params:t},Cr,r)}async unsubscribeResource(t,r){return this.request({method:"resources/unsubscribe",params:t},Cr,r)}async callTool(t,r=pr,n){if(this.isToolTaskRequired(t.name))throw new X(re.InvalidRequest,`Tool "${t.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);const s=await this.request({method:"tools/call",params:t},r,n),o=this.getToolOutputValidator(t.name);if(o){if(!s.structuredContent&&!s.isError)throw new X(re.InvalidRequest,`Tool ${t.name} has an output schema but did not return structured content`);if(s.structuredContent)try{const a=o(s.structuredContent);if(!a.valid)throw new X(re.InvalidParams,`Structured content does not match the tool's output schema: ${a.errorMessage}`)}catch(a){throw a instanceof X?a:new X(re.InvalidParams,`Failed to validate structured content: ${a instanceof Error?a.message:String(a)}`)}}return s}isToolTask(t){var r,n,s,o;return(o=(s=(n=(r=this._serverCapabilities)==null?void 0:r.tasks)==null?void 0:n.requests)==null?void 0:s.tools)!=null&&o.call?this._cachedKnownTaskTools.has(t):!1}isToolTaskRequired(t){return this._cachedRequiredTaskTools.has(t)}cacheToolMetadata(t){var r;this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(const n of t){if(n.outputSchema){const o=this._jsonSchemaValidator.getValidator(n.outputSchema);this._cachedToolOutputValidators.set(n.name,o)}const s=(r=n.execution)==null?void 0:r.taskSupport;(s==="required"||s==="optional")&&this._cachedKnownTaskTools.add(n.name),s==="required"&&this._cachedRequiredTaskTools.add(n.name)}}getToolOutputValidator(t){return this._cachedToolOutputValidators.get(t)}async listTools(t,r){const n=await this.request({method:"tools/list",params:t},Fa,r);return this.cacheToolMetadata(n.tools),n}_setupListChangedHandler(t,r,n,s){const o=iv.safeParse(n);if(!o.success)throw new Error(`Invalid ${t} listChanged options: ${o.error.message}`);if(typeof n.onChanged!="function")throw new Error(`Invalid ${t} listChanged options: onChanged must be a function`);const{autoRefresh:a,debounceMs:i}=o.data,{onChanged:c}=n,l=async()=>{if(!a){c(null,null);return}try{const f=await s();c(null,f)}catch(f){const _=f instanceof Error?f:new Error(String(f));c(_,null)}},d=()=>{if(i){const f=this._listChangedDebounceTimers.get(t);f&&clearTimeout(f);const _=setTimeout(l,i);this._listChangedDebounceTimers.set(t,_)}else l()};this.setNotificationHandler(r,d)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}}var Pc={};/*! + * content-type + * Copyright(c) 2015 Douglas Christopher Wilson + * MIT Licensed + */var Bl=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,WT=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,fh=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,BT=/\\([\u000b\u0020-\u00ff])/g,JT=/([\\"])/g,hh=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;Pc.format=QT;Pc.parse=YT;function QT(e){if(!e||typeof e!="object")throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!hh.test(r))throw new TypeError("invalid type");var n=r;if(t&&typeof t=="object")for(var s,o=Object.keys(t).sort(),a=0;a0&&!WT.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(JT,"\\$1")+'"'}function tR(e){this.parameters=Object.create(null),this.type=e}function rR(e){if(e)try{return Pc.parse(e).type}catch{const t=(e.split(";",1)[0]??"").trim().toLowerCase();return t===""||e.slice(t.length).includes(",")?void 0:t}}function Ko(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function nR(e=fetch,t){return t?async(r,n)=>{const s={...t,...n,headers:n!=null&&n.headers?{...Ko(t.headers),...Ko(n.headers)}:t.headers};return e(r,s)}:e}let Tc;Tc=globalThis.crypto;async function sR(e){return(await Tc).getRandomValues(new Uint8Array(e))}async function oR(e){const t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",r=Math.pow(2,8)-Math.pow(2,8)%t.length;let n="";for(;n.length128)throw`Expected a length between 43 and 128. Received ${e}.`;const t=await aR(e),r=await iR(t);return{code_verifier:t,code_challenge:r}}const qe=T_().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:yy.custom,message:"URL must be parseable",fatal:!0}),mp}).refine(e=>{const t=new URL(e);return t.protocol!=="javascript:"&&t.protocol!=="data:"&&t.protocol!=="vbscript:"},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),lR=Le({resource:T().url(),authorization_servers:F(qe).optional(),jwks_uri:T().url().optional(),scopes_supported:F(T()).optional(),bearer_methods_supported:F(T()).optional(),resource_signing_alg_values_supported:F(T()).optional(),resource_name:T().optional(),resource_documentation:T().optional(),resource_policy_uri:T().url().optional(),resource_tos_uri:T().url().optional(),tls_client_certificate_bound_access_tokens:me().optional(),authorization_details_types_supported:F(T()).optional(),dpop_signing_alg_values_supported:F(T()).optional(),dpop_bound_access_tokens_required:me().optional()}),ph=Le({issuer:T(),authorization_endpoint:qe,token_endpoint:qe,registration_endpoint:qe.optional(),scopes_supported:F(T()).optional(),response_types_supported:F(T()),response_modes_supported:F(T()).optional(),grant_types_supported:F(T()).optional(),token_endpoint_auth_methods_supported:F(T()).optional(),token_endpoint_auth_signing_alg_values_supported:F(T()).optional(),service_documentation:qe.optional(),revocation_endpoint:qe.optional(),revocation_endpoint_auth_methods_supported:F(T()).optional(),revocation_endpoint_auth_signing_alg_values_supported:F(T()).optional(),introspection_endpoint:T().optional(),introspection_endpoint_auth_methods_supported:F(T()).optional(),introspection_endpoint_auth_signing_alg_values_supported:F(T()).optional(),code_challenge_methods_supported:F(T()).optional(),client_id_metadata_document_supported:me().optional()}),uR=Le({issuer:T(),authorization_endpoint:qe,token_endpoint:qe,userinfo_endpoint:qe.optional(),jwks_uri:qe,registration_endpoint:qe.optional(),scopes_supported:F(T()).optional(),response_types_supported:F(T()),response_modes_supported:F(T()).optional(),grant_types_supported:F(T()).optional(),acr_values_supported:F(T()).optional(),subject_types_supported:F(T()),id_token_signing_alg_values_supported:F(T()),id_token_encryption_alg_values_supported:F(T()).optional(),id_token_encryption_enc_values_supported:F(T()).optional(),userinfo_signing_alg_values_supported:F(T()).optional(),userinfo_encryption_alg_values_supported:F(T()).optional(),userinfo_encryption_enc_values_supported:F(T()).optional(),request_object_signing_alg_values_supported:F(T()).optional(),request_object_encryption_alg_values_supported:F(T()).optional(),request_object_encryption_enc_values_supported:F(T()).optional(),token_endpoint_auth_methods_supported:F(T()).optional(),token_endpoint_auth_signing_alg_values_supported:F(T()).optional(),display_values_supported:F(T()).optional(),claim_types_supported:F(T()).optional(),claims_supported:F(T()).optional(),service_documentation:T().optional(),claims_locales_supported:F(T()).optional(),ui_locales_supported:F(T()).optional(),claims_parameter_supported:me().optional(),request_parameter_supported:me().optional(),request_uri_parameter_supported:me().optional(),require_request_uri_registration:me().optional(),op_policy_uri:qe.optional(),op_tos_uri:qe.optional(),client_id_metadata_document_supported:me().optional()}),dR=O({...uR.shape,...ph.pick({code_challenge_methods_supported:!0}).shape}),fR=O({access_token:T(),id_token:T().optional(),token_type:T(),expires_in:vy().optional(),scope:T().optional(),refresh_token:T().optional()}).strip(),hR=O({error:T(),error_description:T().optional(),error_uri:T().optional()}),Jl=qe.optional().or(C("").transform(()=>{})),pR=O({redirect_uris:F(qe),token_endpoint_auth_method:T().optional(),grant_types:F(T()).optional(),response_types:F(T()).optional(),client_name:T().optional(),client_uri:qe.optional(),logo_uri:Jl,scope:T().optional(),contacts:F(T()).optional(),tos_uri:Jl,policy_uri:T().optional(),jwks_uri:qe.optional(),jwks:ga().optional(),software_id:T().optional(),software_version:T().optional(),software_statement:T().optional()}).strip(),mR=O({client_id:T(),client_secret:T().optional(),client_id_issued_at:ae().optional(),client_secret_expires_at:ae().optional()}).strip(),gR=pR.merge(mR);O({error:T(),error_description:T().optional()}).strip();O({token:T(),token_type_hint:T().optional()}).strip();function _R(e){const t=typeof e=="string"?new URL(e):new URL(e.href);return t.hash="",t}function yR({requestedResource:e,configuredResource:t}){const r=typeof e=="string"?new URL(e):new URL(e.href),n=typeof t=="string"?new URL(t):new URL(t.href);if(r.origin!==n.origin||r.pathname.length=400&&e.status<500&&t!=="/"}async function CR(e,t,r,n){const s=new URL(e),o=(n==null?void 0:n.protocolVersion)??zs;let a;if(n!=null&&n.metadataUrl)a=new URL(n.metadataUrl);else{const c=RR(t,s.pathname);a=new URL(c,(n==null?void 0:n.metadataServerUrl)??s),a.search=s.search}let i=await Yl(a,o,r);if(!(n!=null&&n.metadataUrl)&&jR(i,s.pathname)){const c=new URL(`/.well-known/${t}`,s);i=await Yl(c,o,r)}return i}function NR(e){const t=typeof e=="string"?new URL(e):e,r=t.pathname!=="/",n=[];if(!r)return n.push({url:new URL("/.well-known/oauth-authorization-server",t.origin),type:"oauth"}),n.push({url:new URL("/.well-known/openid-configuration",t.origin),type:"oidc"}),n;let s=t.pathname;return s.endsWith("/")&&(s=s.slice(0,-1)),n.push({url:new URL(`/.well-known/oauth-authorization-server${s}`,t.origin),type:"oauth"}),n.push({url:new URL(`/.well-known/openid-configuration${s}`,t.origin),type:"oidc"}),n.push({url:new URL(`${s}/.well-known/openid-configuration`,t.origin),type:"oidc"}),n}async function _h(e,{fetchFn:t=fetch,protocolVersion:r=zs}={}){var o;const n={"MCP-Protocol-Version":r,Accept:"application/json"},s=NR(e);for(const{url:a,type:i}of s){const c=await Rc(a,n,t);if(c){if(!c.ok){if(await((o=c.body)==null?void 0:o.cancel()),c.status>=400&&c.status<500)continue;throw new Error(`HTTP ${c.status} trying to load ${i==="oauth"?"OAuth":"OpenID provider"} metadata from ${a}`)}return i==="oauth"?ph.parse(await c.json()):dR.parse(await c.json())}}}async function IR(e,t){let r,n;try{r=await gh(e,{resourceMetadataUrl:t==null?void 0:t.resourceMetadataUrl},t==null?void 0:t.fetchFn),r.authorization_servers&&r.authorization_servers.length>0&&(n=r.authorization_servers[0])}catch{}n||(n=String(new URL("/",e)));const s=await _h(n,{fetchFn:t==null?void 0:t.fetchFn});return{authorizationServerUrl:n,authorizationServerMetadata:s,resourceMetadata:r}}async function OR(e,{metadata:t,clientInformation:r,redirectUrl:n,scope:s,state:o,resource:a}){let i;if(t){if(i=new URL(t.authorization_endpoint),!t.response_types_supported.includes(po))throw new Error(`Incompatible auth server: does not support response type ${po}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(mo))throw new Error(`Incompatible auth server: does not support code challenge method ${mo}`)}else i=new URL("/authorize",e);const c=await cR(),l=c.code_verifier,d=c.code_challenge;return i.searchParams.set("response_type",po),i.searchParams.set("client_id",r.client_id),i.searchParams.set("code_challenge",d),i.searchParams.set("code_challenge_method",mo),i.searchParams.set("redirect_uri",String(n)),o&&i.searchParams.set("state",o),s&&i.searchParams.set("scope",s),s!=null&&s.includes("offline_access")&&i.searchParams.append("prompt","consent"),a&&i.searchParams.set("resource",a.href),{authorizationUrl:i,codeVerifier:l}}function xR(e,t,r){return new URLSearchParams({grant_type:"authorization_code",code:e,code_verifier:t,redirect_uri:String(r)})}async function yh(e,{metadata:t,tokenRequestParams:r,clientInformation:n,addClientAuthentication:s,resource:o,fetchFn:a}){const i=t!=null&&t.token_endpoint?new URL(t.token_endpoint):new URL("/token",e),c=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});if(o&&r.set("resource",o.href),s)await s(c,r,i,t);else if(n){const d=(t==null?void 0:t.token_endpoint_auth_methods_supported)??[],f=wR(n,d);bR(f,n,c,r)}const l=await(a??fetch)(i,{method:"POST",headers:c,body:r});if(!l.ok)throw await mh(l);return fR.parse(await l.json())}async function AR(e,{metadata:t,clientInformation:r,refreshToken:n,resource:s,addClientAuthentication:o,fetchFn:a}){const i=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),c=await yh(e,{metadata:t,tokenRequestParams:i,clientInformation:r,addClientAuthentication:o,resource:s,fetchFn:a});return{refresh_token:n,...c}}async function MR(e,t,{metadata:r,resource:n,authorizationCode:s,fetchFn:o}={}){const a=e.clientMetadata.scope;let i;if(e.prepareTokenRequest&&(i=await e.prepareTokenRequest(a)),!i){if(!s)throw new Error("Either provider.prepareTokenRequest() or authorizationCode is required");if(!e.redirectUrl)throw new Error("redirectUrl is required for authorization_code flow");const l=await e.codeVerifier();i=xR(s,l,e.redirectUrl)}const c=await e.clientInformation();return yh(t,{metadata:r,tokenRequestParams:i,clientInformation:c??void 0,addClientAuthentication:e.addClientAuthentication,resource:n,fetchFn:o})}async function zR(e,{metadata:t,clientMetadata:r,scope:n,fetchFn:s}){let o;if(t){if(!t.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");o=new URL(t.registration_endpoint)}else o=new URL("/register",e);const a=await(s??fetch)(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...r,...n!==void 0?{scope:n}:{}})});if(!a.ok)throw await mh(a);return gR.parse(await a.json())}class yo extends Error{constructor(t,r){super(t),this.name="ParseError",this.type=r.type,this.field=r.field,this.value=r.value,this.line=r.line}}const Xl=10,DR=13,or=32;function vo(e){}function qR(e){if(typeof e=="function")throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");const{onEvent:t=vo,onError:r=vo,onRetry:n=vo,onComment:s,maxBufferSize:o}=e,a=[];let i=0,c=!0,l,d="",f=0,_,y=!1;function g(E){if(y)throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(c&&(c=!1,E.charCodeAt(0)===239&&E.charCodeAt(1)===187&&E.charCodeAt(2)===191&&(E=E.slice(3))),a.length===0){const q=m(E);q!==""&&(a.push(q),i=q.length),$();return}if(E.indexOf(` +`)===-1&&E.indexOf("\r")===-1){a.push(E),i+=E.length,$();return}a.push(E);const I=a.join("");a.length=0,i=0;const x=m(I);x!==""&&(a.push(x),i=x.length),$()}function $(){o!==void 0&&(i+d.length<=o||(y=!0,a.length=0,i=0,l=void 0,d="",f=0,_=void 0,r(new yo(`Buffered data exceeded max buffer size of ${o} characters`,{type:"max-buffer-size-exceeded"}))))}function m(E){let I=0;if(E.indexOf("\r")===-1){let x=E.indexOf(` +`,I);for(;x!==-1;){if(I===x){f>0&&t({id:l,event:_,data:d}),l=void 0,d="",f=0,_=void 0,I=x+1,x=E.indexOf(` +`,I);continue}const q=E.charCodeAt(I);if(eu(E,I,q)){const Z=E.charCodeAt(I+5)===or?I+6:I+5,D=E.slice(Z,x);if(f===0&&E.charCodeAt(x+1)===Xl){t({id:l,event:_,data:D}),l=void 0,d="",_=void 0,I=x+2,x=E.indexOf(` +`,I);continue}d=f===0?D:`${d} +${D}`,f++}else tu(E,I,q)?_=E.slice(E.charCodeAt(I+6)===or?I+7:I+6,x)||void 0:h(E,I,x);I=x+1,x=E.indexOf(` +`,I)}return E.slice(I)}for(;I20?`${E.slice(0,20)}…`:E}"`,{type:"unknown-field",field:E,value:I,line:x}));break}}function k(){f>0&&t({id:l,event:_,data:d}),l=void 0,d="",f=0,_=void 0}function R(E={}){if(E.consume&&a.length>0){const I=a.join("");h(I,0,I.length)}c=!0,l=void 0,d="",f=0,_=void 0,a.length=0,i=0,y=!1}return{feed:g,reset:R}}function eu(e,t,r){return r===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function tu(e,t,r){return r===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}class UR extends TransformStream{constructor({onError:t,onRetry:r,onComment:n,maxBufferSize:s}={}){let o;super({start(a){o=qR({onEvent:i=>{a.enqueue(i)},onError(i){typeof t=="function"&&t(i),(t==="terminate"||i.type==="max-buffer-size-exceeded")&&a.error(i)},onRetry:r,onComment:n,maxBufferSize:s})},transform(a){o.feed(a)}})}}const FR={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class Tr extends Error{constructor(t,r){super(`Streamable HTTP error: ${r}`),this.code=t}}class LR{constructor(t,r){this._hasCompletedAuthFlow=!1,this._url=t,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=r==null?void 0:r.requestInit,this._authProvider=r==null?void 0:r.authProvider,this._fetch=r==null?void 0:r.fetch,this._fetchWithInit=nR(r==null?void 0:r.fetch,r==null?void 0:r.requestInit),this._sessionId=r==null?void 0:r.sessionId,this._reconnectionOptions=(r==null?void 0:r.reconnectionOptions)??FR}async _authThenStart(){var r;if(!this._authProvider)throw new Pr("No auth provider");let t;try{t=await ts(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(n){throw(r=this.onerror)==null||r.call(this,n),n}if(t!=="AUTHORIZED")throw new Pr;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){var n;const t={};if(this._authProvider){const s=await this._authProvider.tokens();s&&(t.Authorization=`Bearer ${s.access_token}`)}this._sessionId&&(t["mcp-session-id"]=this._sessionId),this._protocolVersion&&(t["mcp-protocol-version"]=this._protocolVersion);const r=Ko((n=this._requestInit)==null?void 0:n.headers);return new Headers({...t,...r})}async _startOrAuthSse(t){var n,s,o;const{resumptionToken:r}=t;try{const a=await this._commonHeaders();a.set("Accept","text/event-stream"),r&&a.set("last-event-id",r);const i=await(this._fetch??fetch)(this._url,{method:"GET",headers:a,signal:(n=this._abortController)==null?void 0:n.signal});if(!i.ok){if(await((s=i.body)==null?void 0:s.cancel()),i.status===401&&this._authProvider)return await this._authThenStart();if(i.status===405)return;throw new Tr(i.status,`Failed to open SSE stream: ${i.statusText}`)}this._handleSseStream(i.body,t,!0)}catch(a){throw(o=this.onerror)==null||o.call(this,a),a}}_getNextReconnectionDelay(t){if(this._serverRetryMs!==void 0)return this._serverRetryMs;const r=this._reconnectionOptions.initialReconnectionDelay,n=this._reconnectionOptions.reconnectionDelayGrowFactor,s=this._reconnectionOptions.maxReconnectionDelay;return Math.min(r*Math.pow(n,t),s)}_scheduleReconnection(t,r=0){var o;const n=this._reconnectionOptions.maxRetries;if(r>=n){(o=this.onerror)==null||o.call(this,new Error(`Maximum reconnection attempts (${n}) exceeded.`));return}const s=this._getNextReconnectionDelay(r);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(t).catch(a=>{var i;(i=this.onerror)==null||i.call(this,new Error(`Failed to reconnect SSE stream: ${a instanceof Error?a.message:String(a)}`)),this._scheduleReconnection(t,r+1)})},s)}_handleSseStream(t,r,n){if(!t)return;const{onresumptiontoken:s,replayMessageId:o}=r;let a,i=!1,c=!1;(async()=>{var d,f,_,y;try{const g=t.pipeThrough(new TextDecoderStream).pipeThrough(new UR({onRetry:h=>{this._serverRetryMs=h}})).getReader();for(;;){const{value:h,done:v}=await g.read();if(v)break;if(h.id&&(a=h.id,i=!0,s==null||s(h.id)),!!h.data&&(!h.event||h.event==="message"))try{const k=rs.parse(JSON.parse(h.data));nn(k)&&(c=!0,o!==void 0&&(k.id=o)),(d=this.onmessage)==null||d.call(this,k)}catch(k){(f=this.onerror)==null||f.call(this,k)}}(n||i)&&!c&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:a,onresumptiontoken:s,replayMessageId:o},0)}catch(g){if((_=this.onerror)==null||_.call(this,new Error(`SSE stream disconnected: ${g}`)),(n||i)&&!c&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:a,onresumptiontoken:s,replayMessageId:o},0)}catch(h){(y=this.onerror)==null||y.call(this,new Error(`Failed to reconnect: ${h instanceof Error?h.message:String(h)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(t){if(!this._authProvider)throw new Pr("No auth provider");if(await ts(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Pr("Failed to authorize")}async close(){var t,r;this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),(t=this._abortController)==null||t.abort(),(r=this.onclose)==null||r.call(this)}async send(t,r){var n,s,o,a,i,c;try{const{resumptionToken:l,onresumptiontoken:d}=r||{};if(l){this._startOrAuthSse({resumptionToken:l,replayMessageId:Po(t)?t.id:void 0}).catch(k=>{var R;return(R=this.onerror)==null?void 0:R.call(this,k)});return}const f=await this._commonHeaders();f.set("content-type","application/json"),f.set("accept","application/json, text/event-stream");const _={...this._requestInit,method:"POST",headers:f,body:JSON.stringify(t),signal:(n=this._abortController)==null?void 0:n.signal},y=await(this._fetch??fetch)(this._url,_),g=y.headers.get("mcp-session-id");if(g&&(this._sessionId=g),!y.ok){const k=await y.text().catch(()=>null);if(y.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Tr(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:R,scope:E}=Ql(y);if(this._resourceMetadataUrl=R,this._scope=E,await ts(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Pr;return this._hasCompletedAuthFlow=!0,this.send(t)}if(y.status===403&&this._authProvider){const{resourceMetadataUrl:R,scope:E,error:I}=Ql(y);if(I==="insufficient_scope"){const x=y.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===x)throw new Tr(403,"Server returned 403 after trying upscoping");if(E&&(this._scope=E),R&&(this._resourceMetadataUrl=R),this._lastUpscopingHeader=x??void 0,await ts(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new Pr;return this.send(t)}}throw new Tr(y.status,`Error POSTing to endpoint: ${k}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,y.status===202){await((s=y.body)==null?void 0:s.cancel()),My(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(k=>{var R;return(R=this.onerror)==null?void 0:R.call(this,k)});return}const m=(Array.isArray(t)?t:[t]).filter(k=>"method"in k&&"id"in k&&k.id!==void 0).length>0,h=y.headers.get("content-type"),v=rR(h);if(m)if(v==="text/event-stream")this._handleSseStream(y.body,{onresumptiontoken:d},!1);else if(v==="application/json"){const k=await y.json(),R=Array.isArray(k)?k.map(E=>rs.parse(E)):[rs.parse(k)];for(const E of R)(o=this.onmessage)==null||o.call(this,E)}else throw await((a=y.body)==null?void 0:a.cancel()),new Tr(-1,`Unexpected content type: ${h}`);else await((i=y.body)==null?void 0:i.cancel())}catch(l){throw(c=this.onerror)==null||c.call(this,l),l}}get sessionId(){return this._sessionId}async terminateSession(){var t,r,n;if(this._sessionId)try{const s=await this._commonHeaders(),o={...this._requestInit,method:"DELETE",headers:s,signal:(t=this._abortController)==null?void 0:t.signal},a=await(this._fetch??fetch)(this._url,o);if(await((r=a.body)==null?void 0:r.cancel()),!a.ok&&a.status!==405)throw new Tr(a.status,`Failed to terminate session: ${a.statusText}`);this._sessionId=void 0}catch(s){throw(n=this.onerror)==null||n.call(this,s),s}}setProtocolVersion(t){this._protocolVersion=t}get protocolVersion(){return this._protocolVersion}async resumeStream(t,r){await this._startOrAuthSse({resumptionToken:t,onresumptiontoken:r==null?void 0:r.onresumptiontoken})}}const VR="https://mcp.excalidraw.com/mcp",HR="mcp.excalidraw.com",ZR="/api/v1/chat/mcp-apps/excalidraw",vh="ui://excalidraw/mcp-app.html",KR=["read_me","create_view"],$h=new Set(["export_to_excalidraw","save_checkpoint","read_checkpoint"]),GR=256*1024,WR=1024*1024,BR=1024*1024,JR=240,QR=720,YR=525;function XR(e){return!Number.isFinite(e)||e<=0?YR:Math.max(JR,Math.min(QR,Math.round(e*3/4)))}const ej={excalidraw:{id:"excalidraw",endpoint:VR,hostname:HR,resourceUri:vh,modelTools:KR,appTools:$h}};function tj(e){return ej[e]}function rj(){return new URL(ht(ZR),window.location.origin)}class nj{constructor(){ne(this,"client",new GT({name:"pwc-chat-mcp-app-host",version:"1"}));ne(this,"transport",new LR(rj(),{requestInit:{credentials:"include"}}));ne(this,"connected");ne(this,"bytes",0);ne(this,"closed",!1)}connect(){return this.closed?Promise.reject(new Error("App host client is closed")):(this.connected||(this.connected=this.client.connect(this.transport).then(()=>{},t=>{throw this.connected=void 0,this.retire(),t})),this.connected)}async readResource(t){if(t!==vh)throw new Error("Unapproved App resource");await this.connect();const n=(await this.client.readResource({uri:t})).contents[0];if(!n||!("text"in n)||typeof n.text!="string"||n.mimeType!=="text/html;profile=mcp-app")throw new Error("Incompatible App resource");this.consume(n.text,BR);const s=await ij(n.text);return{text:n.text,digest:s}}async callTool(t,r){if(!$h.has(t))throw new Error("Unapproved App tool");const n=JSON.stringify(r);this.consume(n);try{await this.connect();const s=await this.client.callTool({name:t,arguments:r});return this.consume(JSON.stringify(s)),s}catch(s){throw this.retire(),s}}close(){this.closed=!0,this.connected=void 0,this.transport.close()}retire(){this.close(),zt===this&&(zt=void 0)}consume(t,r=GR){const n=new TextEncoder().encode(t).byteLength;if(n>r||this.bytes+n>WR)throw new Error("App request exceeds host limit");this.bytes+=n}}let zt;function sj(){return zt??(zt=new nj),zt}function oj(){zt==null||zt.close(),zt=void 0}function aj(e){oj()}async function ij(e){const t=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",t);return[...new Uint8Array(r)].map(n=>n.toString(16).padStart(2,"0")).join("")}function cj(e,t){let r=!1,n=0;const s=()=>{r||!e.contentWindow||(r=!0,t())};e.addEventListener("load",s);const o=window.requestAnimationFrame(()=>{n=window.requestAnimationFrame(s)});return()=>{r=!0,e.removeEventListener("load",s),window.cancelAnimationFrame(o),window.cancelAnimationFrame(n)}}const lj=({block:e})=>{const t=K.useRef(null),r=K.useRef(null),n=K.useRef(!1),s=K.useRef(e),o=K.useRef(!1);s.current=e;const[a,i]=K.useState(),[c,l]=K.useState("loading"),[d,f]=K.useState(e.height),[_,y]=K.useState(!1),[g,$]=K.useState(0),m=K.useRef(null),h=e.input.elements,v=!!e.permissions.clipboardWrite;o.current=_;const k=K.useCallback(()=>{y(!1),document.fullscreenElement&&document.exitFullscreen()},[]),R=K.useCallback(()=>{var x,q;if(_){k();return}y(!0),(q=(x=m.current)==null?void 0:x.requestFullscreen)==null||q.call(x).catch(()=>{})},[k,_]),E=K.useCallback(()=>{aj(),i(void 0),l("loading"),$(x=>x+1)},[]);K.useEffect(()=>{const x=m.current;if(!x)return;const q=()=>{o.current||f(XR(x.clientWidth))};q();const Z=new ResizeObserver(q);return Z.observe(x),()=>Z.disconnect()},[]),K.useEffect(()=>{if(!_)return;const x=m.current,q=D=>{D.key==="Escape"&&(document.fullscreenElement||k())},Z=()=>{document.fullscreenElement||y(!1)};return window.addEventListener("keydown",q),document.addEventListener("fullscreenchange",Z),()=>{window.removeEventListener("keydown",q),document.removeEventListener("fullscreenchange",Z),document.fullscreenElement===x&&document.exitFullscreen()}},[k,_]),K.useEffect(()=>{tj(e.provider);{l("unavailable");return}},[g,e.provider,e.resource_uri]),K.useEffect(()=>{if(!a||c!=="ready")return;const x=t.current;if(!x)return;let q=null;const Z=cj(x,()=>{x.contentWindow&&(q=new p$(null,{name:"Papers with Code",version:"1"},{serverTools:{},openLinks:{},logging:{},...v?{clipboard:{write:{}}}:{}},{hostContext:{theme:document.documentElement.dataset.theme==="dark"?"dark":"light",displayMode:_?"fullscreen":"inline"}}),q.oncalltool=async({name:D,arguments:L})=>{if(s.current.public_fork&&D!=="export_to_excalidraw")throw new Error("Shared diagrams cannot mutate owner state");return sj().callTool(D,L??{})},q.onopenlink=async({url:D})=>{const L=new URL(D);if(L.protocol!=="https:"||L.hostname!=="excalidraw.com")throw new Error("External navigation denied");if(!window.confirm("This export opens Excalidraw and uploads the diagram to its service. Continue?"))throw new Error("Export cancelled");return window.open(L.href,"_blank","noopener,noreferrer"),{}},q.onsizechange=()=>{},q.oninitialized=()=>{n.current=!0;try{const D=JSON.parse(h);q.sendToolInput({arguments:{elements:Array.isArray(D)?S$(D):D}}),q.sendToolResult(s.current.result)}catch{l("error")}},r.current=q,q.connect(new f$(x.contentWindow??void 0,x.contentWindow)).catch(()=>l("error")))});return()=>{Z(),n.current=!1,q==null||q.teardownResource({}).catch(()=>{}),r.current===q&&(r.current=null)}},[a,c,_,h,v,g]),K.useEffect(()=>{var x;c!=="ready"||!n.current||(x=r.current)==null||x.sendToolResult(e.result).catch(()=>{})},[e.result,c]);const I=c==="unavailable"||c==="incompatible"||c==="error";return S.jsxs("section",{ref:m,className:`chat-mcp-app${_?" chat-mcp-app-fullscreen":""}`,"aria-label":"Interactive Excalidraw diagram",children:[S.jsx("header",{children:S.jsx("button",{type:"button",onClick:R,children:_?"Exit fullscreen":"Fullscreen"})}),c==="loading"&&S.jsx("div",{className:"chat-mcp-loading",role:"status",children:"Loading interactive diagram…"}),I&&S.jsxs("div",{className:"chat-mcp-error",children:["Interactive diagram unavailable. The cited text answer is still available.",S.jsx("button",{type:"button",onClick:E,children:"Retry diagram"})]}),a&&c==="ready"&&S.jsx("iframe",{ref:t,title:"Interactive Excalidraw diagram",sandbox:"allow-scripts",allow:v?"clipboard-write":void 0,srcDoc:a,style:{height:d}},g)]})},uj="https://github.com/Chenruishuo/posterly/tree/b9f42e5578a49a27525a68f85376bb3bb25af86f";function dj(){if(typeof window>"u")return null;const e=window.location.pathname.match(/^\/share\/([^/]+)/u);return e?decodeURIComponent(e[1]):null}function ru(e){if(e.scope==="public"){const r=dj();if(!r||!e.public_capability)return null;const n=`/api/v1/chat/shares/${encodeURIComponent(r)}/artifacts/${encodeURIComponent(e.public_capability)}`;return{preview:ht(`${n}/preview`),png:ht(`${n}/download/png`),pdf:ht(`${n}/download/pdf`),manifest:null,source:null,gate:null}}if(!e.artifact_id||!e.version_id)return null;const t=`/api/v1/chat/artifacts/${encodeURIComponent(e.artifact_id)}/versions/${encodeURIComponent(e.version_id)}`;return{preview:ht(`${t}/preview`),png:ht(`${t}/download/${encodeURIComponent("poster.png")}`),pdf:null,manifest:ht(`${t}/manifest`),source:r=>ht(`${t}/source/${r.split("/").map(encodeURIComponent).join("/")}`),gate:r=>ht(`${t}/source/${r.split("/").map(encodeURIComponent).join("/")}`),download:r=>ht(`${t}/download/${r.split("/").map(encodeURIComponent).join("/")}`)}}const nu=e=>({passed:"Passed",warnings:"Passed with warnings",failed:"Non-final draft"})[e??"passed"],fj=({block:e})=>{var R;const[t,r]=K.useState(!1),[n,s]=K.useState("preview"),[o,a]=K.useState(null),[i,c]=K.useState(null),[l,d]=K.useState([]),[f,_]=K.useState(null),y=K.useRef(e.status),g=f?{...e,version_id:f.version_id,version:f.version,gate_status:f.gate_status,total_bytes:f.total_bytes}:e,$=ru(e),m=ru(g);if(K.useEffect(()=>{y.current==="generating"&&e.status==="ready"&&e.scope==="owner"&&r(!0),y.current=e.status},[e.scope,e.status]),K.useEffect(()=>{!t||e.scope!=="owner"||!e.artifact_id||l.length||fetch(ht(`/api/v1/chat/artifacts/${encodeURIComponent(e.artifact_id)}`),{credentials:"include",cache:"no-store"}).then(E=>E.ok?E.json():Promise.reject()).then(E=>d(E.versions)).catch(()=>{})},[e.artifact_id,e.scope,t,l.length]),K.useEffect(()=>{!t||!(m!=null&&m.manifest)||o||fetch(m.manifest,{credentials:"include",cache:"no-store"}).then(E=>E.ok?E.json():Promise.reject()).then(a).catch(()=>{})},[m==null?void 0:m.manifest,o,t]),K.useEffect(()=>{if(n!=="source"||i!==null||!o||!(m!=null&&m.source))return;const E=m.source(o.entrypoint);fetch(E,{credentials:"include",cache:"no-store"}).then(I=>I.ok?I.text():Promise.reject()).then(c).catch(()=>c("Source could not be loaded."))},[m,o,i,n]),e.status==="generating")return S.jsxs("div",{className:"chat-artifact-card chat-artifact-generating",role:"status",children:[S.jsx("span",{className:"chat-artifact-pulse","aria-hidden":"true"}),S.jsxs("span",{children:[S.jsx("strong",{children:e.title}),S.jsx("small",{children:"Publishing Posterly preview…"})]})]});if(e.status==="error")return S.jsxs("div",{className:"chat-artifact-card chat-artifact-error",role:"alert",children:[S.jsx(Nc,{"aria-hidden":"true"}),S.jsxs("span",{children:[S.jsx("strong",{children:e.title}),S.jsx("small",{children:e.error_message??"Poster publication failed."})]})]});if(!m||!$)return null;const h=(R=o==null?void 0:o.downloads[0])==null?void 0:R.path,v=e.scope==="public"?m.pdf:h&&typeof m.download=="function"?m.download(h):null,k=e.scope==="public"?m.png:m.preview;return S.jsxs(S.Fragment,{children:[S.jsxs("button",{type:"button",className:"chat-artifact-card",onClick:()=>r(!0),children:[S.jsx("img",{src:$.preview,alt:`Preview of ${e.title}`}),S.jsxs("span",{className:"chat-artifact-card-copy",children:[S.jsxs("span",{className:"chat-artifact-kicker",children:[S.jsx(Zh,{"aria-hidden":"true"})," Posterly · v",e.version]}),S.jsx("strong",{children:e.title}),S.jsx("small",{className:`chat-artifact-gate chat-artifact-gate-${e.gate_status}`,children:nu(e.gate_status)})]})]}),t&&S.jsx("div",{className:"chat-artifact-overlay",role:"presentation",onMouseDown:E=>{E.target===E.currentTarget&&r(!1)},children:S.jsxs("section",{className:"chat-artifact-panel",role:"dialog","aria-modal":"true","aria-label":e.title,children:[S.jsxs("header",{children:[S.jsxs("div",{children:[S.jsx("span",{children:"Posterly artifact"}),S.jsx("h2",{children:e.title})]}),l.length>1&&S.jsxs("label",{className:"chat-artifact-version",children:["Version",S.jsx("select",{value:g.version_id,onChange:E=>{_(l.find(I=>I.version_id===E.target.value)??null),a(null),c(null),s("preview")},children:[...l].reverse().map(E=>S.jsxs("option",{value:E.version_id,children:["v",E.version]},E.version_id))})]}),S.jsx("button",{type:"button","aria-label":"Close poster",onClick:()=>r(!1),children:S.jsx(kh,{})})]}),S.jsxs("nav",{"aria-label":"Poster views",children:[S.jsx("button",{type:"button",className:n==="preview"?"active":"",onClick:()=>s("preview"),children:"Preview"}),e.scope==="owner"&&S.jsx("button",{type:"button",className:n==="source"?"active":"",onClick:()=>s("source"),children:"Source"})]}),S.jsx("div",{className:"chat-artifact-panel-body",children:n==="preview"?S.jsx("img",{src:m.preview,alt:`Full preview of ${e.title}`}):S.jsx("pre",{children:S.jsx("code",{children:i??"Loading source…"})})}),S.jsxs("footer",{children:[S.jsxs("div",{className:"chat-artifact-metadata",children:[S.jsx("strong",{children:nu(g.gate_status)}),o&&S.jsxs("span",{children:[o.canvas.width," × ",o.canvas.height," ",o.canvas.unit," · ",o.canvas.orientation," · ",o.direction]}),o==null?void 0:o.gate_summary.map(E=>S.jsx("span",{children:E},E))]}),S.jsxs("div",{className:"chat-artifact-actions",children:[S.jsxs("a",{href:k,download:!0,children:[S.jsx(Cc,{})," PNG"]}),g.gate_status!=="failed"&&v&&S.jsxs("a",{href:v,download:!0,children:[S.jsx(Cc,{})," PDF"]}),e.scope==="owner"&&o&&m.source&&S.jsxs("a",{href:m.source(o.entrypoint),download:!0,children:[S.jsx(Nc,{})," HTML"]}),e.scope==="owner"&&o&&m.gate&&S.jsx("a",{href:m.gate(o.gate_report),download:!0,children:"Gate report"}),S.jsxs("a",{href:uj,target:"_blank",rel:"noreferrer",children:[S.jsx(Lh,{})," Posterly source · AGPL-3.0"]})]})]})]})})]})};function hj(e){if(!e.authors.length)return"";const t=e.authors.slice(0,3).map(r=>r.name).join(", ");return e.authors.length>3?`${t}, et al.`:t}function pj(e){var r;if(e.conference)return e.conference;const t=(r=e.published)==null?void 0:r.slice(0,4);if(e.arxiv_id)return t?`arXiv ${t}`:"arXiv";if(e.source_url)try{return new URL(e.source_url).hostname.replace(/^www\./,"")}catch{}return t??"external"}function mj(e,t=240){const r=e.content.trim();return r.length<=t?r:`${r.slice(0,t).trimEnd()}…`}const gj="https://huggingface.co/pro",_j="https://huggingface.co/docs/inference-providers/pricing",yj="https://paperswithcode.co/chat",wh=()=>S.jsx("span",{className:"chat-caret"}),vj=e=>{var r;if(!e.streaming)return!1;const t=(r=e.blocks)==null?void 0:r.at(-1);return t?t.kind==="reasoning"?!t.active:t.kind==="tool"?t.status!=="running":!1:!0},$j=e=>{var y,g;const t=e.currentTarget,r=t.ownerDocument,n=(y=r.caretPositionFromPoint)==null?void 0:y.call(r,e.clientX,e.clientY),s=n?null:(g=r.caretRangeFromPoint)==null?void 0:g.call(r,e.clientX,e.clientY),o=(n==null?void 0:n.offsetNode)??(s==null?void 0:s.startContainer),a=(n==null?void 0:n.offset)??(s==null?void 0:s.startOffset);if(!(o instanceof Text)||a===void 0||!t.contains(o))return;const i=o.data,c=/[\p{L}\p{M}\p{N}_'-]/u;let l=Math.min(a,i.length),d=l;for(;l>0&&c.test(i[l-1]);)l-=1;for(;d{const r=[];let n=0;for(const s of[...t].sort((o,a)=>o.start-a.start)){const o=e.slice(s.start,s.end);s.starte.length||o!==s.title&&o!==`@${s.title}`||(r.push(e.slice(n,s.start)),r.push(S.jsxs("span",{className:"chat-inline-paper-mention",children:[S.jsx(Vh,{size:13,"aria-hidden":"true"}),S.jsx(lu,{routeId:s.route_id,className:"chat-inline-paper-link",children:o.startsWith("@")?o.slice(1):o})]},s.key)),n=s.end)}return r.push(e.slice(n)),S.jsx(S.Fragment,{children:r})},bj=({block:e,papers:t,citations:r,webCitations:n,onToggle:s})=>e.active?S.jsxs("div",{className:"chat-reason-live",children:[S.jsxs("div",{className:"chat-reason-live-head",children:[S.jsx(oa,{})," ",S.jsx("span",{children:"Thinking…"})]}),S.jsxs("div",{className:"chat-reason-live-body chat-answer chat-reason-markdown",children:[S.jsx($o,{text:e.text,streaming:!0,papers:t,citations:r,webCitations:n}),S.jsx(wh,{})]})]}):S.jsxs("div",{className:"chat-reason-done",children:[S.jsxs("button",{type:"button",className:"chat-reason-done-head",onClick:s,"aria-expanded":e.open,children:[S.jsx(Ih,{}),S.jsx("span",{children:"Thought for a few seconds"}),S.jsx(cu,{open:e.open})]}),e.open&&S.jsx("div",{className:"chat-reason-done-body chat-answer chat-reason-markdown",children:S.jsx($o,{text:e.text,papers:t,citations:r,webCitations:n})})]}),Sj=({block:e,papers:t,onToggle:r})=>{var d,f,_,y;const n=e.status==="running",s=e.schema_version===2||!!e.content,o=e.status==="error"||e.status==="denied",a=typeof e.args.query=="string"?e.args.query:"",i=typeof e.args.command=="string"?e.args.command:typeof e.args.file_path=="string"?e.args.file_path:a,c=((d=e.content)==null?void 0:d.map(g=>g.text).join(""))??"",l=n?"running…":s?`${e.status} · ${e.took_ms??0} ms`:`${e.hits} results · ${e.took_ms} ms`;return S.jsxs("div",{className:`chat-tool${n?" chat-tool-running":""}${o?" chat-tool-failed":""}`,children:[S.jsxs("button",{type:"button",className:"chat-tool-head",onClick:r,disabled:n,"aria-expanded":n?void 0:e.open,children:[S.jsxs("span",{className:"chat-tool-head-left",children:[n?S.jsx(oa,{}):S.jsx(Oh,{}),S.jsx("code",{className:"chat-tool-name",children:e.name}),S.jsx("span",{className:"chat-tool-query",children:s?i:`("${a}")`})]}),S.jsxs("span",{className:"chat-tool-head-right",children:[S.jsx("span",{className:"chat-tool-status",children:l}),!n&&S.jsx(cu,{open:e.open})]})]}),!n&&e.open&&S.jsxs("div",{className:"chat-tool-body",children:[S.jsxs("div",{className:"chat-tool-args",children:[S.jsx("span",{className:"chat-tool-label",children:"arguments"}),S.jsx("pre",{children:JSON.stringify(e.args,null,2)})]}),s?S.jsxs(S.Fragment,{children:[S.jsxs("div",{className:"chat-tool-output-head",children:[S.jsx("span",{className:"chat-tool-label",children:"result"}),S.jsx("button",{type:"button",className:"chat-tool-copy",onClick:()=>void navigator.clipboard.writeText(c),children:"Copy"})]}),S.jsx("pre",{className:"chat-tool-output",children:S.jsx("code",{children:c})}),((f=e.metadata)==null?void 0:f.output_truncated)&&S.jsx("div",{className:"chat-tool-truncated",children:"Output was truncated."})]}):S.jsxs(S.Fragment,{children:[S.jsxs("div",{className:"chat-tool-label chat-tool-results-label",children:["returned ",((_=e.results)==null?void 0:_.length)??0," papers"]}),S.jsx("ol",{className:"chat-tool-results",children:(y=e.results)==null?void 0:y.map(g=>S.jsxs("li",{className:"chat-hit",children:[S.jsx("div",{className:"chat-hit-top",children:S.jsx(du,{routeId:g.route_id,paper:t[g.route_id],className:"chat-hit-title",children:g.title})}),S.jsx("div",{className:"chat-hit-meta",children:[hj(g.metadata),pj(g.metadata)].filter(Boolean).join(" · ")}),S.jsxs("div",{className:"chat-hit-snippet",children:[mj(g),g.content_truncated&&S.jsx("span",{className:"chat-hit-truncated",children:" (truncated)"})]})]},g.route_id))})]})]})]})},Ej=({block:e,papers:t,citations:r,webCitations:n,streaming:s})=>S.jsxs("div",{className:"chat-answer",children:[S.jsx($o,{text:e.text,streaming:s,papers:t,citations:r,webCitations:n}),s&&!!e.text.trim()&&S.jsx(wh,{})]}),kj=({block:e})=>S.jsx(lj,{block:e}),bh=e=>{const t=K.useRef(null),r=K.useCallback(()=>{const n=t.current;if(!n)return;n.style.height="auto";const s=Math.max(120,window.innerHeight*.4);n.style.height=`${Math.min(n.scrollHeight,s)}px`,n.style.overflowY=n.scrollHeight>s?"auto":"hidden"},[]);return K.useLayoutEffect(()=>{var n,s;(n=t.current)==null||n.focus(),(s=t.current)==null||s.setSelectionRange(e.length,e.length),r()},[r,e.length]),{textareaRef:t,resize:r}},Pj=({id:e,text:t,paperSelection:r,editNotice:n,onCancel:s,onResend:o,onResendDraft:a})=>{const[i,c]=K.useState(t),[l,d]=K.useState(r),[f,_]=K.useState(!1),{textareaRef:y,resize:g}=bh(t);K.useLayoutEffect(g,[g,i]);const $=!!i.trim()&&i.length<=8e3,m=()=>{if(!$||f)return;_(!0),((a==null?void 0:a({text:i,paperMentions:[],...l?{paperSelection:l}:{}}))??(o==null?void 0:o(i))??!1)||_(!1)};return S.jsx("div",{className:"chat-msg chat-msg-user chat-msg-user-editing","data-message-id":e,children:S.jsxs("div",{className:"chat-inline-editor",children:[l&&S.jsx(Os,{selection:l,editable:!0,onRemove:()=>d(void 0)}),S.jsx("textarea",{ref:y,className:"chat-inline-editor-textarea","aria-label":"Edit message",value:i,maxLength:8e3,onChange:h=>c(h.target.value),onKeyDown:h=>{h.key==="Escape"?(h.preventDefault(),s==null||s()):h.key==="Enter"&&!h.shiftKey&&!h.nativeEvent.isComposing&&(h.preventDefault(),m())}}),n&&S.jsx("div",{className:"chat-inline-editor-notice",children:n}),S.jsxs("div",{className:"chat-inline-editor-actions",children:[S.jsx("button",{type:"button",onClick:s,children:"Cancel"}),S.jsx("button",{type:"button",className:"chat-inline-editor-send",disabled:!$||f,onClick:m,children:"Send"})]})]})})},Tj=({id:e,text:t,paperMentions:r,paperSelection:n,enabled:s,editNotice:o,onCancel:a,onResend:i,onResendDraft:c})=>{const[l,d]=K.useState({text:t,paperMentions:r,...n?{paperSelection:n}:{}}),[f,_]=K.useState(!1),[y,g]=K.useState(0),{textareaRef:$,resize:m}=bh(t),h=ou({draft:l,onChange:d,enabled:s,textareaRef:$});K.useLayoutEffect(m,[m,l.text]);const v=!!l.text.trim()&&l.text.length<=8e3&&(s||l.paperMentions.length===0),k=()=>{if(!v||f)return;_(!0),((c==null?void 0:c(l))??(i==null?void 0:i(l.text))??!1)||_(!1)};return S.jsx("div",{className:"chat-msg chat-msg-user chat-msg-user-editing","data-message-id":e,children:S.jsxs("div",{className:"chat-inline-editor",children:[l.paperSelection&&S.jsx(Os,{selection:l.paperSelection,editable:!0,onRemove:()=>d({text:l.text,paperMentions:l.paperMentions})}),S.jsxs("div",{className:"chat-inline-editor-textarea-wrap",children:[S.jsx(au,{text:l.text,mentions:l.paperMentions,scrollTop:y,variant:"editor"}),S.jsx("textarea",{ref:$,className:"chat-inline-editor-textarea","aria-label":"Edit message",value:l.text,maxLength:8e3,role:"combobox","aria-autocomplete":"list","aria-expanded":h.open,"aria-controls":h.open?h.pickerId:void 0,"aria-activedescendant":h.open&&h.results.length?`${h.optionIdPrefix}-${h.activeIndex}`:void 0,onChange:R=>h.updateText(R.target.value,R.target.selectionStart),onSelect:R=>h.refresh(R.currentTarget.selectionStart),onScroll:R=>g(R.currentTarget.scrollTop),onKeyDown:R=>{h.keyDown(R)||(R.key==="Escape"?(R.preventDefault(),a==null||a()):R.key==="Enter"&&!R.shiftKey&&!R.nativeEvent.isComposing&&(R.preventDefault(),k()))}}),S.jsx(iu,{open:h.open,query:h.query,results:h.results,activeIndex:h.activeIndex,loading:h.loading,error:h.error,onSelect:h.select,id:h.pickerId,optionIdPrefix:h.optionIdPrefix})]}),!s&&l.paperMentions.length>0&&S.jsx("div",{className:"chat-inline-editor-notice",role:"status",children:"Paper mentions are currently disabled. Remove them before sending."}),o&&S.jsx("div",{className:"chat-inline-editor-notice",children:o}),S.jsxs("div",{className:"chat-inline-editor-actions",children:[S.jsx("button",{type:"button",onClick:a,children:"Cancel"}),S.jsx("button",{type:"button",className:"chat-inline-editor-send",disabled:!v||f,onClick:k,children:"Send"})]})]})})},Kj=({id:e,text:t,paperMentions:r=[],paperSelection:n,paperMentionsEnabled:s=!1,editingAllowed:o=!1,editing:a=!1,editNotice:i,onEdit:c,onCancel:l,onResend:d,onResendDraft:f})=>{const[_,y]=K.useState(!1),g=K.useRef(null);K.useEffect(()=>()=>{g.current!==null&&window.clearTimeout(g.current)},[]);const $=async()=>{var m;if((m=navigator.clipboard)!=null&&m.writeText)try{await navigator.clipboard.writeText(t),y(!0),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>y(!1),1500)}catch{}};return a?!s&&r.length===0?S.jsx(Pj,{id:e,text:t,paperSelection:n,editNotice:i,onCancel:l,onResend:d,onResendDraft:f}):S.jsx(Tj,{id:e,text:t,paperMentions:r,paperSelection:n,enabled:s,editNotice:i,onCancel:l,onResend:d,onResendDraft:f}):S.jsx("div",{className:"chat-msg chat-msg-user","data-message-id":e,children:S.jsxs("div",{className:"chat-user-message-wrap",children:[n&&S.jsx(Os,{selection:n}),S.jsx("div",{className:"chat-bubble",onDoubleClick:$j,children:S.jsx(wj,{text:t,mentions:r})}),S.jsxs("div",{className:"chat-user-actions",children:[S.jsx("button",{type:"button",className:"chat-user-action","aria-label":_?"Message copied":"Copy message",title:_?"Copied":"Copy",onClick:()=>void $(),children:_?S.jsx(Ph,{"aria-hidden":"true"}):S.jsx(Hh,{"aria-hidden":"true"})}),o&&S.jsx("button",{type:"button",className:"chat-user-action","aria-label":"Edit message",title:"Edit",onClick:c,children:S.jsx(Kh,{"aria-hidden":"true"})})]})]})})},Gj=({msg:e,papers:t,onToggleBlock:r,onArchiveOldChats:n,onArchiveOldestChats:s,archivePending:o=null,hfBilling:a=null,openRouterFallbackEnabled:i=!1,feedbackEnabled:c=!1})=>{var x,q,Z;const[l,d]=K.useState(null),[f,_]=K.useState(!1),[y,g]=K.useState(!1),[$,m]=K.useState(!1),[h,v]=K.useState(""),k=K.useRef(null),R=`chat-feedback-panel-${e.id}`,E=c&&!e.streaming&&!e.error&&!!((x=e.blocks)!=null&&x.some(D=>D.kind==="answer"&&D.text.trim()));K.useEffect(()=>{var D;$&&((D=k.current)==null||D.focus())},[$]);const I=async(D,L)=>{if(!f){_(!0),g(!1);try{L===void 0?await jc.reportFeedback(e.id,D):await jc.reportFeedback(e.id,D,L),d(D),m(!1),v("")}catch{g(!0)}finally{_(!1)}}};return S.jsx("div",{className:"chat-msg chat-msg-assistant",children:S.jsxs("div",{className:"chat-msg-blocks",children:[(q=e.blocks)==null?void 0:q.map((D,L)=>{var je;const B=`${e.id}-${L}`,ce="citations"in D&&D.citations!==void 0?D.citations:e.citations??[],U=Object.fromEntries(ce.filter(_e=>(_e.kind??"paper")==="paper"&&_e.route_id).map(_e=>[_e.route_id,_e])),le=Object.fromEntries(ce.filter(_e=>_e.kind==="web"&&_e.url).map(_e=>[_e.url,_e]));return D.kind==="reasoning"?S.jsx(bj,{block:D,papers:t,citations:U,webCitations:le,onToggle:()=>r(e.id,L)},B):D.kind==="tool"?S.jsx(Sj,{block:D,papers:t,onToggle:()=>r(e.id,L)},B):D.kind==="app"?S.jsx(kj,{block:D},D.instance_id||B):D.kind==="artifact"?S.jsx(fj,{block:D},D.publication_id||D.version_id||B):S.jsx(Ej,{block:D,papers:t,citations:U,webCitations:le,streaming:!!(e.streaming&&L===(((je=e.blocks)==null?void 0:je.length)??0)-1)},B)}),vj(e)&&S.jsx("div",{className:"chat-waiting",role:"status","aria-live":"polite",children:S.jsx("span",{className:"chat-thinking",children:(((Z=e.blocks)==null?void 0:Z.length)??0)===0?e.status??"Thinking…":"Thinking…"})}),e.error&&S.jsxs("div",{className:"chat-error",children:[S.jsx("span",{children:e.errorCode==="chat_disabled_interrupted"?"Chat was disabled while this response was running. The partial response is saved. Please try again later.":e.errorCode==="chat_session_quota_exceeded"?e.error:`The assistant hit an error: ${e.error}`}),["hf_inference_billing_required","hf_inference_credential_expired"].includes(e.errorCode??"")&&S.jsx("a",{href:"/settings",children:"Re-sign in with Hugging Face"}),e.errorCode==="hf_inference_billing_exhausted"&&S.jsxs(S.Fragment,{children:[(a==null?void 0:a.account_type)==="Free"&&!a.bill_to?S.jsx("a",{href:gj,target:"_blank",rel:"noreferrer",children:"Upgrade to Hugging Face PRO — $9/month for 20× more included credits"}):S.jsx("a",{href:(a==null?void 0:a.usage_url)??"/settings",target:a?"_blank":void 0,rel:a?"noreferrer":void 0,children:"Review Hugging Face usage and billing"}),S.jsx("a",{href:_j,target:"_blank",rel:"noreferrer",children:"Inference Providers pricing and billing details"})]}),e.errorCode==="openrouter_monthly_budget_exhausted"&&S.jsxs(S.Fragment,{children:[i?S.jsx("span",{children:"This response started on the shared allowance. Your connected OpenRouter key will be used when you explicitly retry."}):S.jsx("a",{href:"/settings#openrouter-byok",children:"Connect your own OpenRouter key"}),S.jsx("span",{children:"Or select a Hugging Face-backed model and explicitly retry."})]}),e.errorCode==="openrouter_staging_funding_disabled"&&S.jsx("a",{href:yj,children:"Continue on paperswithcode.co"}),e.errorCode==="openrouter_unavailable"&&S.jsxs(S.Fragment,{children:[S.jsx("a",{href:"/settings#openrouter-byok",children:"Bring your own key in Settings"}),S.jsx("a",{href:"https://github.com/huggingface/paperswithcode-feedback",target:"_blank",rel:"noreferrer",children:"File an issue"})]}),e.errorCode==="openrouter_byok_billing_error"&&S.jsx("a",{href:"https://openrouter.ai/settings/credits",target:"_blank",rel:"noreferrer",children:"Review OpenRouter billing"}),["openrouter_byok_credential_invalid","openrouter_byok_rate_limit"].includes(e.errorCode??"")&&S.jsx("a",{href:"/settings#openrouter-byok",children:"Review OpenRouter settings"}),e.errorCode==="chat_session_quota_exceeded"&&(n||s)&&S.jsxs("span",{className:"chat-error-actions",children:[n&&S.jsx("button",{type:"button",disabled:o!==null,onClick:n,children:o==="old"?"Archiving…":"Archive chats older than 30 days"}),s&&S.jsx("button",{type:"button",disabled:o!==null,onClick:s,children:o==="oldest"?"Archiving…":"Archive oldest 50 chats"})]})]}),!e.streaming&&e.finishReason&&e.finishReason!=="success"&&S.jsx("div",{className:"chat-finish-note",children:["tool_limit","max_turns"].includes(e.finishReason)?"The assistant stopped at the execution limit.":`The assistant stopped early (${e.finishReason.replace(/_/g," ")}).`}),E&&S.jsxs("div",{className:"chat-feedback","aria-label":"Rate this response",children:[S.jsx("span",{className:"chat-feedback-label",children:l===null?"Was this helpful?":"Thanks for your feedback"}),S.jsx("button",{type:"button",className:`chat-feedback-action${l===!0?" chat-feedback-action-selected":""}`,"aria-label":"Helpful response","aria-pressed":l===!0,disabled:f,onClick:()=>{m(!1),I(!0)},children:S.jsx(Wh,{"aria-hidden":"true"})}),S.jsx("button",{type:"button",className:`chat-feedback-action${l===!1?" chat-feedback-action-selected":""}`,"aria-label":"Unhelpful response","aria-pressed":l===!1,"aria-expanded":$,"aria-controls":R,disabled:f,onClick:()=>{g(!1),m(!0)},children:S.jsx(Gh,{"aria-hidden":"true"})}),y&&S.jsx("span",{className:"chat-feedback-error",role:"status",children:"Couldn’t send feedback."})]}),E&&$&&S.jsxs("div",{className:"chat-feedback-panel",id:R,role:"group","aria-labelledby":`${R}-title`,children:[S.jsx("div",{className:"chat-feedback-panel-title",id:`${R}-title`,children:"Additional feedback"}),S.jsx("label",{className:"chat-feedback-panel-label",htmlFor:`${R}-comment`,children:"Tell us what went wrong (optional)"}),S.jsx("textarea",{ref:k,id:`${R}-comment`,className:"chat-feedback-comment",value:h,maxLength:500,rows:4,disabled:f,onChange:D=>v(D.target.value),onKeyDown:D=>{D.key==="Escape"&&(D.preventDefault(),m(!1))}}),S.jsxs("div",{className:"chat-feedback-panel-actions",children:[S.jsx("button",{type:"button",className:"chat-feedback-skip",disabled:f,onClick:()=>void I(!1),children:"Skip"}),S.jsx("button",{type:"button",className:"chat-feedback-submit",disabled:f,onClick:()=>void I(!1,h.trim()||void 0),children:f?"Submitting…":"Submit"})]})]})]})})};export{Gj as A,Fj as C,Kj as U};