diff --git "a/assets/ChatMessage-BFHm1LcY.js" "b/assets/ChatMessage-BFHm1LcY.js" new file mode 100644--- /dev/null +++ "b/assets/ChatMessage-BFHm1LcY.js" @@ -0,0 +1,111 @@ +var hh=Object.defineProperty;var ph=(e,t,r)=>t in e?hh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var ae=(e,t,r)=>ph(e,typeof t!="symbol"?t+"":t,r);import{d as Ns,r as gt,j as T,z as X,N as Ql,E as mh,C as _h}from"./index-CbUf1h9B.js";import{u as Yl,a as Xl,b as eu,M as gh,R as yh,W as vh,d as ra,A as $h,n as wh,K as bh,L as tu,N as Sh}from"./chatSessions-BXeLbeCo.js";import"./katex.min-BSBacQyE.js";import{H as na,a as sa,b as oa}from"./hover-card-C4tN9A-Q.js";import{u as Eh}from"./useQuery-BsDKLWHo.js";import{f as kh,p as Ph}from"./github-CpVZWs3Y.js";import{G as aa}from"./github-BVTHv1OF.js";import{r as Th,a as Rh,P as ru}from"./PaperPreviewLink-tvZEIxI8.js";import{M as Ch,r as Nh,d as Ih}from"./index-BKHYTfy9.js";import{c as Tc}from"./chat-D0lFqpf_.js";import{F as jh}from"./file-text-CsygKJy9.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 Oh=Ns("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 Ah=Ns("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 zh=Ns("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 Mh=Ns("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 Is({selection:e,editable:t=!1,onRemove:r}){const n=gt.useId(),s=gt.useRef(null),[o,a]=gt.useState(!1),[i,c]=gt.useState(!1),l=`Selection · Page ${e.page}`;return gt.useEffect(()=>{const d=s.current;!d||o||c(d.scrollHeight>d.clientHeight+1)},[o,e.text]),T.jsxs("div",{className:`chat-paper-selection${t?" is-editable":""}`,children:[T.jsxs("div",{className:"chat-paper-selection-header",children:[T.jsx("span",{className:"chat-paper-selection-label",children:l}),T.jsxs("div",{className:"chat-paper-selection-actions",children:[(i||o)&&T.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&&T.jsx("button",{type:"button",className:"chat-paper-selection-remove","aria-label":"Remove selected paper passage",onClick:r,children:"Remove"})]})]}),T.jsx("blockquote",{id:n,ref:s,className:`chat-paper-selection-quote${o?" is-expanded":""}`,children:e.text})]})}const xh=wh(),_C=({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:g=!1,paperSelectionEnabled:y=!0,webSearchAvailable:_=!1,webSearchEnabled:$=!1,onWebSearchChange:m,reasoningEffort:h="low",onReasoningEffortChange:v})=>{const[S,R]=gt.useState(xh),P=s??S,I=gt.useRef(null),[A,U]=gt.useState(0),Z=q=>{s||R(q),o==null||o(q)},V=Yl({draft:P,onChange:Z,enabled:g,textareaRef:I});gt.useEffect(()=>{const q=I.current;q&&(q.style.height="auto",q.style.height=`${Math.min(q.scrollHeight,200)}px`)},[P.text]),gt.useEffect(()=>{var q;n&&((q=I.current)==null||q.focus())},[n]);const L=()=>{const q=P.text.length-P.text.trimStart().length,le=P.text.trim(),Ce=!!P.paperSelection&&!y;if(!le||t||d||Ce)return;const ge=q+le.length,it={text:le,paperMentions:P.paperMentions.filter(je=>je.start>=q&&je.end<=ge).map(je=>({...je,start:je.start-q,end:je.end-q})),...P.paperSelection?{paperSelection:P.paperSelection}:{}};e(it)},W=!!P.paperSelection&&!y,ce=!!P.text.trim()&&!W;return T.jsxs("div",{className:"chat-composer",children:[P.paperSelection&&T.jsx(Is,{selection:P.paperSelection,editable:!0,onRemove:()=>{var q;Z({text:P.text,paperMentions:P.paperMentions}),(q=I.current)==null||q.focus()}}),W&&T.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."}),T.jsxs("div",{className:"chat-composer-textarea-wrap",children:[T.jsx(Xl,{text:P.text,mentions:P.paperMentions,scrollTop:A}),T.jsx("textarea",{ref:I,rows:1,value:P.text,placeholder:r||(P.paperSelection?"Ask about this selection…":"Ask anything about research…"),onChange:q=>V.updateText(q.target.value,q.target.selectionStart),onSelect:q=>V.refresh(q.currentTarget.selectionStart),onClick:q=>V.refresh(q.currentTarget.selectionStart),onScroll:q=>U(q.currentTarget.scrollTop),onBlur:q=>{var le,Ce;(Ce=(le=q.relatedTarget)==null?void 0:le.closest)!=null&&Ce.call(le,".chat-paper-picker")||window.setTimeout(V.close,0)},onKeyDown:q=>{V.keyDown(q)||q.key==="Enter"&&!q.shiftKey&&!q.nativeEvent.isComposing&&(q.preventDefault(),L())},role:"combobox","aria-expanded":V.open,"aria-controls":V.open?V.pickerId:void 0,"aria-activedescendant":V.open&&V.results.length?`${V.optionIdPrefix}-${V.activeIndex}`:void 0,"aria-autocomplete":"list","aria-describedby":[f,V.message?"chat-paper-mention-message":null].filter(Boolean).join(" ")||void 0}),T.jsx(eu,{open:V.open,query:V.query,results:V.results,activeIndex:V.activeIndex,loading:V.loading,error:V.error,onSelect:V.select,id:V.pickerId,optionIdPrefix:V.optionIdPrefix})]}),V.message&&T.jsx("div",{id:"chat-paper-mention-message",className:"chat-paper-mention-message",role:"alert",children:V.message}),T.jsxs("div",{className:"chat-composer-row",children:[T.jsxs("div",{className:"chat-composer-tools",children:[i.length>0&&c&&l&&T.jsx(gh,{models:i,selectedModel:c,onModelChange:l,disabled:t}),v&&T.jsx(yh,{value:h,onChange:v,disabled:t}),_&&m&&T.jsx(vh,{enabled:$,onChange:m,disabled:t}),T.jsx("span",{className:"chat-composer-hint",children:"Enter to send · Shift+Enter for newline"})]}),T.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?T.jsx("span",{"aria-hidden":"true",children:"■"}):T.jsx(ra,{light:!0}):T.jsx($h,{})})]})]})},Ys=new Map,qh=e=>{if(!e)return Promise.resolve();const t=Ys.get(e);if(t)return t;const r=new Promise(n=>{const s=new Image;s.onload=()=>{n()},s.onerror=()=>{Ys.delete(e),n()},s.src=e});return Ys.set(e,r),r},Dh=new Set(["huggingface.co","www.huggingface.co"]),Uh=new Set(["api","blog","chat","collections","docs","enterprise","join","login","models","new","organizations","papers","posts","pricing","search","settings","spaces","tasks"]);function Vh(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!=="https:"||!Dh.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"&&Uh.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 Lh=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches,Fh=({repo:e})=>{const[t,r]=X.useState(!1);return T.jsxs("div",{className:"hf-preview-card",children:[t?T.jsx("div",{className:"hf-preview-fallback","aria-hidden":"true",children:"🤗"}):T.jsx("img",{className:"hf-preview-image","data-testid":"hf-preview-image",src:e.thumbnailUrl,alt:"",loading:"eager",decoding:"async",onError:()=>r(!0)}),T.jsxs("div",{className:"hf-preview-meta",children:[T.jsxs("span",{className:"hf-preview-kind",children:["Hugging Face ",e.type]}),T.jsx("strong",{children:e.repoId}),T.jsx("span",{children:"huggingface.co"})]})]})},Hh=({repo:e,children:t})=>{const[r,n]=X.useState(!1),s=X.useRef(null),o=X.useCallback(()=>{qh(e.thumbnailUrl)},[e.thumbnailUrl]);return X.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]),T.jsxs(na,{open:r,onOpenChange:a=>{(!a||!Lh())&&n(a)},openDelay:150,closeDelay:100,children:[T.jsx(sa,{asChild:!0,children:T.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})}),T.jsx(oa,{className:"hf-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:T.jsx(Fh,{repo:e})})]})},Zh=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches,Kh=({repo:e,preview:t,unavailable:r})=>{const[n,s]=X.useState(!1),o=!!(t!=null&&t.avatarUrl)&&!n;return T.jsxs("div",{className:"github-preview-card",children:[o?T.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)}):T.jsx("div",{className:"github-preview-fallback","aria-hidden":"true",children:T.jsx(aa,{})}),T.jsxs("div",{className:"github-preview-meta",children:[T.jsx("span",{className:"github-preview-kind",children:"GitHub repository"}),T.jsx("strong",{children:e.repoId}),(t==null?void 0:t.description)&&T.jsx("span",{className:"github-preview-description",children:t.description}),t?T.jsxs("span",{className:"github-preview-stats",children:[t.language&&T.jsxs(T.Fragment,{children:[t.language," · "]}),"★ ",t.stars.toLocaleString()," · ⑂ ",t.forks.toLocaleString(),t.archived&&T.jsx(T.Fragment,{children:" · Archived"})]}):T.jsx("span",{children:r?"Preview unavailable":"Loading preview…"})]})]})},Gh=({repo:e,children:t})=>{const[r,n]=X.useState(!1),s=Eh({queryKey:["github-repository-preview",e.repoId.toLowerCase()],queryFn:({signal:o})=>kh(e,o),enabled:r,staleTime:30*60*1e3,gcTime:60*60*1e3,retry:!1});return T.jsxs(na,{open:r,onOpenChange:o=>{(!o||!Zh())&&n(o)},openDelay:150,closeDelay:100,children:[T.jsx(sa,{asChild:!0,children:T.jsxs("a",{className:"chat-github-link",href:e.url,target:"_blank",rel:"noopener noreferrer",children:[T.jsx(aa,{"aria-hidden":"true"}),t]})}),T.jsx(oa,{className:"github-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:T.jsx(Kh,{repo:e,preview:s.data,unavailable:s.isError})})]})},Wh=()=>typeof window.matchMedia=="function"&&window.matchMedia("(hover: none), (pointer: coarse)").matches;function Bh(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return"Web source"}}const Jh=({citation:e})=>{const[t,r]=X.useState(!1),[n,s]=X.useState(!1),o=e.thumbnail_url,a=e.favicon_url;return T.jsxs("div",{className:"web-preview-card",children:[o&&!t&&T.jsx("img",{className:"web-preview-image","data-testid":"web-preview-image",src:o,alt:"",loading:"eager",decoding:"async",referrerPolicy:"no-referrer",onError:()=>r(!0)}),T.jsxs("div",{className:"web-preview-meta",children:[T.jsxs("div",{className:"web-preview-source",children:[a&&!n&&T.jsx("img",{src:a,alt:"",loading:"eager",decoding:"async",referrerPolicy:"no-referrer",onError:()=>s(!0)}),T.jsx("span",{children:Bh(e.url??"")}),e.published&&T.jsxs(T.Fragment,{children:[T.jsx("span",{"aria-hidden":"true",children:"·"}),T.jsx("time",{children:e.published.slice(0,10)})]})]}),T.jsx("strong",{children:e.title}),e.excerpt&&T.jsx("p",{children:e.excerpt.replace(/\s+/g," ").trim()})]})]})},Qh=({citation:e,children:t})=>{const[r,n]=X.useState(!1),s=e.url??"";return T.jsxs(na,{open:r,onOpenChange:o=>{(!o||!Wh())&&n(o)},openDelay:150,closeDelay:100,children:[T.jsx(sa,{asChild:!0,children:T.jsx("a",{href:s,className:"chat-web-citation",target:"_blank",rel:"noopener noreferrer",children:t})}),T.jsx(oa,{className:"web-preview-pop",side:"bottom",align:"start",collisionPadding:12,children:T.jsx(Jh,{citation:e})})]})};function Yh(e,t,r){if(t)return{routeId:e,title:t.title,arxivId:t.metadata.arxiv_id,source:t.metadata.source,sourceUrl:t.metadata.source_url,thumbnailUrl:t.metadata.thumbnail_url,authors:t.metadata.authors.map(n=>n.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 nu=({routeId:e,paper:t,citation:r,className:n="chat-paper-link",children:s})=>T.jsx(ru,{routeId:e,initialData:Yh(e,t,r),className:n,target:"_blank",children:s});function Xh(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 ep=e=>e.startsWith("paper:")?e:Ih(e);function tp(e){try{const t=new URL(e);return t.protocol==="https:"&&(t.hostname==="github.com"||t.hostname==="www.github.com")}catch{return!1}}const yo=({text:e,streaming:t,papers:r,citations:n,webCitations:s})=>{const o=t?Xh(e):e;return T.jsx(Ch,{remarkPlugins:[Nh,Rh],rehypePlugins:[Th],urlTransform:ep,components:{a:({href:a,children:i})=>{if(a!=null&&a.startsWith("paper:")){const d=a.slice(6);return!r[d]&&!(n!=null&&n[d])?T.jsx("span",{className:"chat-invalid-citation",children:i}):T.jsx(nu,{routeId:d,paper:r[d],citation:n==null?void 0:n[d],children:i})}const c=a?Vh(a):null;if(c)return T.jsx(Hh,{repo:c,children:i});const l=a?Ph(a):null;return l?T.jsx(Gh,{repo:l,children:i}):a&&tp(a)?T.jsxs("a",{href:a,className:"chat-github-link",target:"_blank",rel:"noopener noreferrer",children:[T.jsx(aa,{"aria-hidden":"true"}),i]}):a!=null&&a.startsWith("https://")&&(s!=null&&s[a])?T.jsx(Qh,{citation:s[a],children:i}):a!=null&&a.startsWith("https://")?T.jsx("a",{href:a,className:"chat-external-link",target:"_blank",rel:"noopener noreferrer",children:i}):T.jsx("span",{children:i})}},children:o})},rp=Object.freeze({status:"aborted"});function z(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 _n extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const su={};function qt(e){return su}function np(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 sp(e,t){return typeof t=="bigint"?t.toString():t}function ia(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function ca(e){return e==null}function la(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function op(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 js(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Br(e){return JSON.stringify(e)}const ou=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function us(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const ap=ia(()=>{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 ds(e){if(us(e)===!1)return!1;const t=e.constructor;if(t===void 0)return!0;const r=t.prototype;return!(us(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}const ip=new Set(["string","number","symbol"]);function bn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function yr(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 G(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 cp(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const lp={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 up(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 yr(e,{...e._zod.def,shape:r,checks:[]})}function dp(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 yr(e,{...e._zod.def,shape:r,checks:[]})}function fp(e,t){if(!ds(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 js(this,"shape",n),n},checks:[]};return yr(e,r)}function hp(e,t){return yr(e,{...e._zod.def,get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return js(this,"shape",r),r},catchall:t._zod.def.catchall,checks:[]})}function pp(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 yr(t,{...t._zod.def,shape:s,checks:[]})}function mp(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 yr(t,{...t._zod.def,shape:s,checks:[]})}function sn(e,t=0){var r;for(let n=t;n{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function qn(e){return typeof e=="string"?e:e==null?void 0:e.message}function Dt(e,t,r){var s,o,a,i,c,l;const n={...e,path:e.path??[]};if(!e.message){const d=qn((a=(o=(s=e.inst)==null?void 0:s._zod.def)==null?void 0:o.error)==null?void 0:a.call(o,e))??qn((i=t==null?void 0:t.error)==null?void 0:i.call(t,e))??qn((c=r.customError)==null?void 0:c.call(r,e))??qn((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 ua(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function gn(...e){const[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}const au=(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,sp,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},iu=z("$ZodError",au),cu=z("$ZodError",au,{Parent:Error});function _p(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 gp(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 _n;if(a.issues.length){const i=new((s==null?void 0:s.Err)??e)(a.issues.map(c=>Dt(c,o,qt())));throw ou(i,s==null?void 0:s.callee),i}return a.value},vp=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=>Dt(c,o,qt())));throw ou(i,s==null?void 0:s.callee),i}return a.value},lu=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 _n;return o.issues.length?{success:!1,error:new(e??iu)(o.issues.map(a=>Dt(a,s,qt())))}:{success:!0,data:o.value}},uu=lu(cu),du=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=>Dt(a,s,qt())))}:{success:!0,data:o.value}},$p=du(cu),wp=/^[cC][^\s-]{8,}$/,bp=/^[0-9a-z]+$/,Sp=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Ep=/^[0-9a-vA-V]{20}$/,kp=/^[A-Za-z0-9]{27}$/,Pp=/^[a-zA-Z0-9_-]{21}$/,Tp=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Rp=/^([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})$/,Rc=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)$/,Cp=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Np="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Ip(){return new RegExp(Np,"u")}const jp=/^(?:(?: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])$/,Op=/^(([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})$/,Ap=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,zp=/^(([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])$/,Mp=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,fu=/^[A-Za-z0-9_-]*$/,xp=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,qp=/^\+(?:[0-9]){6,14}[0-9]$/,hu="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Dp=new RegExp(`^${hu}$`);function pu(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 Up(e){return new RegExp(`^${pu(e)}$`)}function Vp(e){const t=pu({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(`^${hu}T(?:${n})$`)}const Lp=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}$`)},Fp=/^\d+$/,Hp=/^-?\d+(?:\.\d+)?/i,Zp=/true|false/i,Kp=/null/i,Gp=/undefined/i,Wp=/^[^A-Z]*$/,Bp=/^[^a-z]*$/,Xe=z("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),mu={number:"number",bigint:"bigint",object:"date"},_u=z("$ZodCheckLessThan",(e,t)=>{Xe.init(e,t);const r=mu[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=mu[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})}}),Jp=z("$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):op(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})}}),Qp=z("$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]=lp[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=Fp)}),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})}}),Yp=z("$ZodCheckMaxLength",(e,t)=>{var r;Xe.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!ca(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=ua(s);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),Xp=z("$ZodCheckMinLength",(e,t)=>{var r;Xe.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!ca(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=ua(s);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),em=z("$ZodCheckLengthEquals",(e,t)=>{var r;Xe.init(e,t),(r=e._zod.def).when??(r.when=n=>{const s=n.value;return!ca(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=ua(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})}}),Os=z("$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=()=>{})}),tm=z("$ZodCheckRegex",(e,t)=>{Os.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})}}),rm=z("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Wp),Os.init(e,t)}),nm=z("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Bp),Os.init(e,t)}),sm=z("$ZodCheckIncludes",(e,t)=>{Xe.init(e,t);const r=bn(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})}}),om=z("$ZodCheckStartsWith",(e,t)=>{Xe.init(e,t);const r=new RegExp(`^${bn(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})}}),am=z("$ZodCheckEndsWith",(e,t)=>{Xe.init(e,t);const r=new RegExp(`.*${bn(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})}}),im=z("$ZodCheckOverwrite",(e,t)=>{Xe.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});class cm{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 lm={major:4,minor:0,patch:0},we=z("$ZodType",(e,t)=>{var s;var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=lm;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=sn(a),d;for(const f of i){if(f._zod.def.when){if(!f._zod.def.when(a))continue}else if(l)continue;const g=a.issues.length,y=f._zod.check(a);if(y instanceof Promise&&(c==null?void 0:c.async)===!1)throw new _n;if(d||y instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await y,a.issues.length!==g&&(l||(l=sn(a,g)))});else{if(a.issues.length===g)continue;l||(l=sn(a,g))}}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 _n;return c.then(l=>o(l,n,i))}return o(c,n,i)}}e["~standard"]={validate:o=>{var a;try{const i=uu(e,o);return i.success?{value:i.data}:{issues:(a=i.error)==null?void 0:a.issues}}catch{return $p(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}}),da=z("$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()??Lp(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=z("$ZodStringFormat",(e,t)=>{Os.init(e,t),da.init(e,t)}),um=z("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Rp),Pe.init(e,t)}),dm=z("$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=Rc(n))}else t.pattern??(t.pattern=Rc());Pe.init(e,t)}),fm=z("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Cp),Pe.init(e,t)}),hm=z("$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:xp.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})}}}),pm=z("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Ip()),Pe.init(e,t)}),mm=z("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Pp),Pe.init(e,t)}),_m=z("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=wp),Pe.init(e,t)}),gm=z("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=bp),Pe.init(e,t)}),ym=z("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Sp),Pe.init(e,t)}),vm=z("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Ep),Pe.init(e,t)}),$m=z("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=kp),Pe.init(e,t)}),wm=z("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Vp(t)),Pe.init(e,t)}),bm=z("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Dp),Pe.init(e,t)}),Sm=z("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Up(t)),Pe.init(e,t)}),Em=z("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Tp),Pe.init(e,t)}),km=z("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=jp),Pe.init(e,t),e._zod.onattach.push(r=>{const n=r._zod.bag;n.format="ipv4"})}),Pm=z("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Op),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})}}}),Tm=z("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Ap),Pe.init(e,t)}),Rm=z("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=zp),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 yu(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Cm=z("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Mp),Pe.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),e._zod.check=r=>{yu(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function Nm(e){if(!fu.test(e))return!1;const t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return yu(r)}const Im=z("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=fu),Pe.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),e._zod.check=r=>{Nm(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),jm=z("$ZodE164",(e,t)=>{t.pattern??(t.pattern=qp),Pe.init(e,t)});function Om(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 Am=z("$ZodJWT",(e,t)=>{Pe.init(e,t),e._zod.check=r=>{Om(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),vu=z("$ZodNumber",(e,t)=>{we.init(e,t),e._zod.pattern=e._zod.bag.pattern??Hp,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}}),zm=z("$ZodNumber",(e,t)=>{Qp.init(e,t),vu.init(e,t)}),Mm=z("$ZodBoolean",(e,t)=>{we.init(e,t),e._zod.pattern=Zp,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}}),xm=z("$ZodUndefined",(e,t)=>{we.init(e,t),e._zod.pattern=Gp,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=z("$ZodNull",(e,t)=>{we.init(e,t),e._zod.pattern=Kp,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}}),Dm=z("$ZodAny",(e,t)=>{we.init(e,t),e._zod.parse=r=>r}),Um=z("$ZodUnknown",(e,t)=>{we.init(e,t),e._zod.parse=r=>r}),Vm=z("$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 Cc(e,t,r){e.issues.length&&t.issues.push(...dr(r,e.issues)),t.value[r]=e.value}const Lm=z("$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;aCc(l,r,a))):Cc(c,r,a)}return o.length?Promise.all(o).then(()=>r):r}});function Dn(e,t,r){e.issues.length&&t.issues.push(...dr(r,e.issues)),t.value[r]=e.value}function Nc(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(...dr(r,e.issues)):e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}const Fm=z("$ZodObject",(e,t)=>{we.init(e,t);const r=ia(()=>{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 g=cp(t.shape);return{shape:t.shape,keys:f,keySet:new Set(f),numKeys:f.length,optionalKeys:new Set(g)}});Ee(e._zod,"propValues",()=>{const f=t.shape,g={};for(const y in f){const _=f[y]._zod;if(_.values){g[y]??(g[y]=new Set);for(const $ of _.values)g[y].add($)}}return g});const n=f=>{const g=new cm(["shape","payload","ctx"]),y=r.value,_=v=>{const S=Br(v);return`shape[${S}]._zod.run({ value: input[${S}], issues: [] }, ctx)`};g.write("const input = payload.value;");const $=Object.create(null);let m=0;for(const v of y.keys)$[v]=`key_${m++}`;g.write("const newResult = {}");for(const v of y.keys)if(y.optionalKeys.has(v)){const S=$[v];g.write(`const ${S} = ${_(v)};`);const R=Br(v);g.write(` + if (${S}.issues.length) { + if (input[${R}] === undefined) { + if (${R} in input) { + newResult[${R}] = undefined; + } + } else { + payload.issues = payload.issues.concat( + ${S}.issues.map((iss) => ({ + ...iss, + path: iss.path ? [${R}, ...iss.path] : [${R}], + })) + ); + } + } else if (${S}.value === undefined) { + if (${R} in input) newResult[${R}] = undefined; + } else { + newResult[${R}] = ${S}.value; + } + `)}else{const S=$[v];g.write(`const ${S} = ${_(v)};`),g.write(` + if (${S}.issues.length) payload.issues = payload.issues.concat(${S}.issues.map(iss => ({ + ...iss, + path: iss.path ? [${Br(v)}, ...iss.path] : [${Br(v)}] + })));`),g.write(`newResult[${Br(v)}] = ${S}.value`)}g.write("payload.value = newResult;"),g.write("return payload;");const h=g.compile();return(v,S)=>h(f,v,S)};let s;const o=us,a=!su.jitless,c=a&&ap.value,l=t.catchall;let d;e._zod.parse=(f,g)=>{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 _=[];if(a&&c&&(g==null?void 0:g.async)===!1&&g.jitless!==!0)s||(s=n(t.shape)),f=s(f,g);else{f.value={};const S=d.shape;for(const R of d.keys){const P=S[R],I=P._zod.run({value:y[R],issues:[]},g),A=P._zod.optin==="optional"&&P._zod.optout==="optional";I instanceof Promise?_.push(I.then(U=>A?Nc(U,f,R,y):Dn(U,f,R))):A?Nc(I,f,R,y):Dn(I,f,R)}}if(!l)return _.length?Promise.all(_).then(()=>f):f;const $=[],m=d.keySet,h=l._zod,v=h.def.type;for(const S of Object.keys(y)){if(m.has(S))continue;if(v==="never"){$.push(S);continue}const R=h.run({value:y[S],issues:[]},g);R instanceof Promise?_.push(R.then(P=>Dn(P,f,S))):Dn(R,f,S)}return $.length&&f.issues.push({code:"unrecognized_keys",keys:$,input:y,inst:e}),_.length?Promise.all(_).then(()=>f):f}});function Ic(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=>Dt(o,n,qt())))}),t}const $u=z("$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=>la(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=>Ic(a,r,e,n)):Ic(o,r,e,n)}}),Hm=z("$ZodDiscriminatedUnion",(e,t)=>{$u.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=ia(()=>{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(!us(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)}}),Zm=z("$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])=>jc(r,c,l)):jc(r,o,a)}});function vo(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(ds(e)&&ds(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=vo(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(!ds(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(...dr(c,d.issues)),r.value[c]=d.value})):(l.issues.length&&r.issues.push(...dr(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=>Dt(l,n,qt())),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(...dr(a,l.issues)),r.value[i.value]=l.value})):(c.issues.length&&r.issues.push(...dr(a,c.issues)),r.value[i.value]=c.value)}}return o.length?Promise.all(o).then(()=>r):r}}),Gm=z("$ZodEnum",(e,t)=>{we.init(e,t);const r=np(t.entries);e._zod.values=new Set(r),e._zod.pattern=new RegExp(`^(${r.filter(n=>ip.has(typeof n)).map(n=>typeof n=="string"?bn(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}}),Wm=z("$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"?bn(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}}),Bm=z("$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 _n;return r.value=s,r}}),Jm=z("$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(`^(${la(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)}),Qm=z("$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(`^(${la(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)}),Ym=z("$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=>Oc(o,t)):Oc(s,t)}});function Oc(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Xm=z("$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))}),e_=z("$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=>Ac(o,e)):Ac(s,e)}});function Ac(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 t_=z("$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=>Dt(a,n,qt()))},input:r.value}),r.issues=[]),r)):(r.value=s.value,s.issues.length&&(r.value=t.catchValue({...r,error:{issues:s.issues.map(o=>Dt(o,n,qt()))},input:r.value}),r.issues=[]),r)}}),r_=z("$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=>zc(o,t,n)):zc(s,t,n)}});function zc(e,t,r){return sn(e)?e:t.out._zod.run({value:e.value,issues:e.issues},r)}const n_=z("$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(Mc):Mc(s)}});function Mc(e){return e.value=Object.freeze(e.value),e}const s_=z("$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=>xc(o,r,n,e));xc(s,r,n,e)}});function xc(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(gn(s))}}class o_{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 a_(){return new o_}const Un=a_();function i_(e,t){return new e({type:"string",...G(t)})}function c_(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...G(t)})}function qc(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...G(t)})}function l_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...G(t)})}function u_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...G(t)})}function d_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...G(t)})}function f_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...G(t)})}function wu(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...G(t)})}function h_(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...G(t)})}function p_(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...G(t)})}function m_(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...G(t)})}function __(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...G(t)})}function g_(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...G(t)})}function y_(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...G(t)})}function v_(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...G(t)})}function $_(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...G(t)})}function w_(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...G(t)})}function b_(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...G(t)})}function S_(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...G(t)})}function E_(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...G(t)})}function k_(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...G(t)})}function P_(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...G(t)})}function T_(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...G(t)})}function R_(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...G(t)})}function C_(e,t){return new e({type:"string",format:"date",check:"string_format",...G(t)})}function N_(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...G(t)})}function I_(e,t){return new e({type:"string",format:"duration",check:"string_format",...G(t)})}function j_(e,t){return new e({type:"number",checks:[],...G(t)})}function O_(e,t){return new e({type:"number",coerce:!0,checks:[],...G(t)})}function A_(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...G(t)})}function z_(e,t){return new e({type:"boolean",...G(t)})}function M_(e,t){return new e({type:"undefined",...G(t)})}function x_(e,t){return new e({type:"null",...G(t)})}function q_(e){return new e({type:"any"})}function D_(e){return new e({type:"unknown"})}function U_(e,t){return new e({type:"never",...G(t)})}function Dc(e,t){return new _u({check:"less_than",...G(t),value:e,inclusive:!1})}function Xs(e,t){return new _u({check:"less_than",...G(t),value:e,inclusive:!0})}function Uc(e,t){return new gu({check:"greater_than",...G(t),value:e,inclusive:!1})}function eo(e,t){return new gu({check:"greater_than",...G(t),value:e,inclusive:!0})}function Vc(e,t){return new Jp({check:"multiple_of",...G(t),value:e})}function bu(e,t){return new Yp({check:"max_length",...G(t),maximum:e})}function fs(e,t){return new Xp({check:"min_length",...G(t),minimum:e})}function Su(e,t){return new em({check:"length_equals",...G(t),length:e})}function V_(e,t){return new tm({check:"string_format",format:"regex",...G(t),pattern:e})}function L_(e){return new rm({check:"string_format",format:"lowercase",...G(e)})}function F_(e){return new nm({check:"string_format",format:"uppercase",...G(e)})}function H_(e,t){return new sm({check:"string_format",format:"includes",...G(t),includes:e})}function Z_(e,t){return new om({check:"string_format",format:"starts_with",...G(t),prefix:e})}function K_(e,t){return new am({check:"string_format",format:"ends_with",...G(t),suffix:e})}function Sn(e){return new im({check:"overwrite",tx:e})}function G_(e){return Sn(t=>t.normalize(e))}function W_(){return Sn(e=>e.trim())}function B_(){return Sn(e=>e.toLowerCase())}function J_(){return Sn(e=>e.toUpperCase())}function Q_(e,t,r){return new e({type:"array",element:t,...G(r)})}function Y_(e,t,r){const n=G(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function X_(e,t,r){return new e({type:"custom",check:"custom",fn:t,...G(r)})}const eg=z("ZodISODateTime",(e,t)=>{wm.init(e,t),Re.init(e,t)});function Eu(e){return R_(eg,e)}const tg=z("ZodISODate",(e,t)=>{bm.init(e,t),Re.init(e,t)});function rg(e){return C_(tg,e)}const ng=z("ZodISOTime",(e,t)=>{Sm.init(e,t),Re.init(e,t)});function sg(e){return N_(ng,e)}const og=z("ZodISODuration",(e,t)=>{Em.init(e,t),Re.init(e,t)});function ag(e){return I_(og,e)}const ig=(e,t)=>{iu.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>gp(e,r)},flatten:{value:r=>_p(e,r)},addIssue:{value:r=>e.issues.push(r)},addIssues:{value:r=>e.issues.push(...r)},isEmpty:{get(){return e.issues.length===0}}})},As=z("ZodError",ig,{Parent:Error}),cg=yp(As),lg=vp(As),ug=lu(As),dg=du(As),ke=z("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)=>yr(e,r,n),e.brand=()=>e,e.register=(r,n)=>(r.add(e,n),e),e.parse=(r,n)=>cg(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>ug(e,r,n),e.parseAsync=async(r,n)=>lg(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>dg(e,r,n),e.spa=e.safeParseAsync,e.refine=(r,n)=>e.check(ny(r,n)),e.superRefine=r=>e.check(sy(r)),e.overwrite=r=>e.check(Sn(r)),e.optional=()=>Te(e),e.nullable=()=>Hc(e),e.nullish=()=>Te(Hc(e)),e.nonoptional=r=>Bg(e,r),e.array=()=>D(e),e.or=r=>pe([e,r]),e.and=r=>pa(e,r),e.transform=r=>So(e,Nu(r)),e.default=r=>Kg(e,r),e.prefault=r=>Wg(e,r),e.catch=r=>Qg(e,r),e.pipe=r=>So(e,r),e.readonly=()=>ey(e),e.describe=r=>{const n=e.clone();return Un.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){var r;return(r=Un.get(e))==null?void 0:r.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return Un.get(e);const n=e.clone();return Un.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),ku=z("_ZodString",(e,t)=>{da.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(V_(...n)),e.includes=(...n)=>e.check(H_(...n)),e.startsWith=(...n)=>e.check(Z_(...n)),e.endsWith=(...n)=>e.check(K_(...n)),e.min=(...n)=>e.check(fs(...n)),e.max=(...n)=>e.check(bu(...n)),e.length=(...n)=>e.check(Su(...n)),e.nonempty=(...n)=>e.check(fs(1,...n)),e.lowercase=n=>e.check(L_(n)),e.uppercase=n=>e.check(F_(n)),e.trim=()=>e.check(W_()),e.normalize=(...n)=>e.check(G_(...n)),e.toLowerCase=()=>e.check(B_()),e.toUpperCase=()=>e.check(J_())}),fg=z("ZodString",(e,t)=>{da.init(e,t),ku.init(e,t),e.email=r=>e.check(c_(hg,r)),e.url=r=>e.check(wu(Pu,r)),e.jwt=r=>e.check(T_(Cg,r)),e.emoji=r=>e.check(h_(mg,r)),e.guid=r=>e.check(qc(Lc,r)),e.uuid=r=>e.check(l_(Vn,r)),e.uuidv4=r=>e.check(u_(Vn,r)),e.uuidv6=r=>e.check(d_(Vn,r)),e.uuidv7=r=>e.check(f_(Vn,r)),e.nanoid=r=>e.check(p_(_g,r)),e.guid=r=>e.check(qc(Lc,r)),e.cuid=r=>e.check(m_(gg,r)),e.cuid2=r=>e.check(__(yg,r)),e.ulid=r=>e.check(g_(vg,r)),e.base64=r=>e.check(E_(Pg,r)),e.base64url=r=>e.check(k_(Tg,r)),e.xid=r=>e.check(y_($g,r)),e.ksuid=r=>e.check(v_(wg,r)),e.ipv4=r=>e.check($_(bg,r)),e.ipv6=r=>e.check(w_(Sg,r)),e.cidrv4=r=>e.check(b_(Eg,r)),e.cidrv6=r=>e.check(S_(kg,r)),e.e164=r=>e.check(P_(Rg,r)),e.datetime=r=>e.check(Eu(r)),e.date=r=>e.check(rg(r)),e.time=r=>e.check(sg(r)),e.duration=r=>e.check(ag(r))});function k(e){return i_(fg,e)}const Re=z("ZodStringFormat",(e,t)=>{Pe.init(e,t),ku.init(e,t)}),hg=z("ZodEmail",(e,t)=>{fm.init(e,t),Re.init(e,t)}),Lc=z("ZodGUID",(e,t)=>{um.init(e,t),Re.init(e,t)}),Vn=z("ZodUUID",(e,t)=>{dm.init(e,t),Re.init(e,t)}),Pu=z("ZodURL",(e,t)=>{hm.init(e,t),Re.init(e,t)});function pg(e){return wu(Pu,e)}const mg=z("ZodEmoji",(e,t)=>{pm.init(e,t),Re.init(e,t)}),_g=z("ZodNanoID",(e,t)=>{mm.init(e,t),Re.init(e,t)}),gg=z("ZodCUID",(e,t)=>{_m.init(e,t),Re.init(e,t)}),yg=z("ZodCUID2",(e,t)=>{gm.init(e,t),Re.init(e,t)}),vg=z("ZodULID",(e,t)=>{ym.init(e,t),Re.init(e,t)}),$g=z("ZodXID",(e,t)=>{vm.init(e,t),Re.init(e,t)}),wg=z("ZodKSUID",(e,t)=>{$m.init(e,t),Re.init(e,t)}),bg=z("ZodIPv4",(e,t)=>{km.init(e,t),Re.init(e,t)}),Sg=z("ZodIPv6",(e,t)=>{Pm.init(e,t),Re.init(e,t)}),Eg=z("ZodCIDRv4",(e,t)=>{Tm.init(e,t),Re.init(e,t)}),kg=z("ZodCIDRv6",(e,t)=>{Rm.init(e,t),Re.init(e,t)}),Pg=z("ZodBase64",(e,t)=>{Cm.init(e,t),Re.init(e,t)}),Tg=z("ZodBase64URL",(e,t)=>{Im.init(e,t),Re.init(e,t)}),Rg=z("ZodE164",(e,t)=>{jm.init(e,t),Re.init(e,t)}),Cg=z("ZodJWT",(e,t)=>{Am.init(e,t),Re.init(e,t)}),fa=z("ZodNumber",(e,t)=>{vu.init(e,t),ke.init(e,t),e.gt=(n,s)=>e.check(Uc(n,s)),e.gte=(n,s)=>e.check(eo(n,s)),e.min=(n,s)=>e.check(eo(n,s)),e.lt=(n,s)=>e.check(Dc(n,s)),e.lte=(n,s)=>e.check(Xs(n,s)),e.max=(n,s)=>e.check(Xs(n,s)),e.int=n=>e.check(Fc(n)),e.safe=n=>e.check(Fc(n)),e.positive=n=>e.check(Uc(0,n)),e.nonnegative=n=>e.check(eo(0,n)),e.negative=n=>e.check(Dc(0,n)),e.nonpositive=n=>e.check(Xs(0,n)),e.multipleOf=(n,s)=>e.check(Vc(n,s)),e.step=(n,s)=>e.check(Vc(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 oe(e){return j_(fa,e)}const Ng=z("ZodNumberFormat",(e,t)=>{zm.init(e,t),fa.init(e,t)});function Fc(e){return A_(Ng,e)}const Ig=z("ZodBoolean",(e,t)=>{Mm.init(e,t),ke.init(e,t)});function me(e){return z_(Ig,e)}const jg=z("ZodUndefined",(e,t)=>{xm.init(e,t),ke.init(e,t)});function $o(e){return M_(jg,e)}const Og=z("ZodNull",(e,t)=>{qm.init(e,t),ke.init(e,t)});function Ag(e){return x_(Og,e)}const zg=z("ZodAny",(e,t)=>{Dm.init(e,t),ke.init(e,t)});function ha(){return q_(zg)}const Mg=z("ZodUnknown",(e,t)=>{Um.init(e,t),ke.init(e,t)});function $e(){return D_(Mg)}const xg=z("ZodNever",(e,t)=>{Vm.init(e,t),ke.init(e,t)});function wo(e){return U_(xg,e)}const qg=z("ZodArray",(e,t)=>{Lm.init(e,t),ke.init(e,t),e.element=t.element,e.min=(r,n)=>e.check(fs(r,n)),e.nonempty=r=>e.check(fs(1,r)),e.max=(r,n)=>e.check(bu(r,n)),e.length=(r,n)=>e.check(Su(r,n)),e.unwrap=()=>e.element});function D(e,t){return Q_(qg,e,t)}const Tu=z("ZodObject",(e,t)=>{Fm.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:wo()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>fp(e,r),e.merge=r=>hp(e,r),e.pick=r=>up(e,r),e.omit=r=>dp(e,r),e.partial=(...r)=>pp(Iu,e,r[0]),e.required=(...r)=>mp(ju,e,r[0])});function O(e,t){const r={type:"object",get shape(){return js(this,"shape",{...e}),this.shape},...G(t)};return new Tu(r)}function Le(e,t){return new Tu({type:"object",get shape(){return js(this,"shape",{...e}),this.shape},catchall:$e(),...G(t)})}const Ru=z("ZodUnion",(e,t)=>{$u.init(e,t),ke.init(e,t),e.options=t.options});function pe(e,t){return new Ru({type:"union",options:e,...G(t)})}const Dg=z("ZodDiscriminatedUnion",(e,t)=>{Ru.init(e,t),Hm.init(e,t)});function Cu(e,t,r){return new Dg({type:"union",options:t,discriminator:e,...G(r)})}const Ug=z("ZodIntersection",(e,t)=>{Zm.init(e,t),ke.init(e,t)});function pa(e,t){return new Ug({type:"intersection",left:e,right:t})}const Vg=z("ZodRecord",(e,t)=>{Km.init(e,t),ke.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function _e(e,t,r){return new Vg({type:"record",keyType:e,valueType:t,...G(r)})}const bo=z("ZodEnum",(e,t)=>{Gm.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 bo({...t,checks:[],...G(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 bo({...t,checks:[],...G(s),entries:o})}});function tt(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new bo({type:"enum",entries:r,...G(t)})}const Lg=z("ZodLiteral",(e,t)=>{Wm.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 N(e,t){return new Lg({type:"literal",values:Array.isArray(e)?e:[e],...G(t)})}const Fg=z("ZodTransform",(e,t)=>{Bm.init(e,t),ke.init(e,t),e._zod.parse=(r,n)=>{r.addIssue=o=>{if(typeof o=="string")r.issues.push(gn(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(gn(a))}};const s=t.transform(r.value,r);return s instanceof Promise?s.then(o=>(r.value=o,r)):(r.value=s,r)}});function Nu(e){return new Fg({type:"transform",transform:e})}const Iu=z("ZodOptional",(e,t)=>{Jm.init(e,t),ke.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Te(e){return new Iu({type:"optional",innerType:e})}const Hg=z("ZodNullable",(e,t)=>{Qm.init(e,t),ke.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Hc(e){return new Hg({type:"nullable",innerType:e})}const Zg=z("ZodDefault",(e,t)=>{Ym.init(e,t),ke.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Kg(e,t){return new Zg({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const Gg=z("ZodPrefault",(e,t)=>{Xm.init(e,t),ke.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Wg(e,t){return new Gg({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const ju=z("ZodNonOptional",(e,t)=>{e_.init(e,t),ke.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Bg(e,t){return new ju({type:"nonoptional",innerType:e,...G(t)})}const Jg=z("ZodCatch",(e,t)=>{t_.init(e,t),ke.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Qg(e,t){return new Jg({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const Yg=z("ZodPipe",(e,t)=>{r_.init(e,t),ke.init(e,t),e.in=t.in,e.out=t.out});function So(e,t){return new Yg({type:"pipe",in:e,out:t})}const Xg=z("ZodReadonly",(e,t)=>{n_.init(e,t),ke.init(e,t)});function ey(e){return new Xg({type:"readonly",innerType:e})}const Ou=z("ZodCustom",(e,t)=>{s_.init(e,t),ke.init(e,t)});function ty(e){const t=new Xe({check:"custom"});return t._zod.check=e,t}function ry(e,t){return Y_(Ou,e??(()=>!0),t)}function ny(e,t={}){return X_(Ou,e,t)}function sy(e){const t=ty(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(gn(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(gn(s))}},e(r.value,r)));return t}function Au(e,t){return So(Nu(e),t)}const oy={custom:"custom"};function ay(e){return O_(fa,e)}const zs="2025-11-25",iy=[zs,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],sr="io.modelcontextprotocol/related-task",Ms="2.0",ze=ry(e=>e!==null&&(typeof e=="object"||typeof e=="function")),zu=pe([k(),oe().int()]),Mu=k();Le({ttl:oe().optional(),pollInterval:oe().optional()});const cy=O({ttl:oe().optional()}),ly=O({taskId:k()}),ma=Le({progressToken:zu.optional(),[sr]:ly.optional()}),rt=O({_meta:ma.optional()}),En=rt.extend({task:cy.optional()}),uy=e=>En.safeParse(e).success,Fe=O({method:k(),params:rt.loose().optional()}),ot=O({_meta:ma.optional()}),at=O({method:k(),params:ot.loose().optional()}),He=Le({_meta:ma.optional()}),kn=pe([k(),oe().int()]),xu=O({jsonrpc:N(Ms),id:kn,...Fe.shape}).strict(),Eo=e=>xu.safeParse(e).success,qu=O({jsonrpc:N(Ms),...at.shape}).strict(),dy=e=>qu.safeParse(e).success,_a=O({jsonrpc:N(Ms),id:kn,result:He}).strict(),en=e=>_a.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 ga=O({jsonrpc:N(Ms),id:kn.optional(),error:O({code:oe().int(),message:k(),data:$e().optional()})}).strict(),fy=e=>ga.safeParse(e).success,Xn=pe([xu,qu,_a,ga]);pe([_a,ga]);const Tr=He.strict(),hy=ot.extend({requestId:kn.optional(),reason:k().optional()}),ya=at.extend({method:N("notifications/cancelled"),params:hy}),py=O({src:k(),mimeType:k().optional(),sizes:D(k()).optional(),theme:tt(["light","dark"]).optional()}),Pn=O({icons:D(py).optional()}),Ar=O({name:k(),title:k().optional()}),xs=Ar.extend({...Ar.shape,...Pn.shape,version:k(),websiteUrl:k().optional(),description:k().optional()}),my=pa(O({applyDefaults:me().optional()}),_e(k(),$e())),_y=Au(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,pa(O({form:my.optional(),url:ze.optional()}),_e(k(),$e()).optional())),gy=Le({list:ze.optional(),cancel:ze.optional(),requests:Le({sampling:Le({createMessage:ze.optional()}).optional(),elicitation:Le({create:ze.optional()}).optional()}).optional()}),yy=Le({list:ze.optional(),cancel:ze.optional(),requests:Le({tools:Le({call:ze.optional()}).optional()}).optional()}),vy=O({experimental:_e(k(),ze).optional(),sampling:O({context:ze.optional(),tools:ze.optional()}).optional(),elicitation:_y.optional(),roots:O({listChanged:me().optional()}).optional(),tasks:gy.optional(),extensions:_e(k(),ze).optional()}),$y=rt.extend({protocolVersion:k(),capabilities:vy,clientInfo:xs}),wy=Fe.extend({method:N("initialize"),params:$y}),by=O({experimental:_e(k(),ze).optional(),logging:ze.optional(),completions:ze.optional(),prompts:O({listChanged:me().optional()}).optional(),resources:O({subscribe:me().optional(),listChanged:me().optional()}).optional(),tools:O({listChanged:me().optional()}).optional(),tasks:yy.optional(),extensions:_e(k(),ze).optional()}),Du=He.extend({protocolVersion:k(),capabilities:by,serverInfo:xs,instructions:k().optional()}),Uu=at.extend({method:N("notifications/initialized"),params:ot.optional()}),Sy=e=>Uu.safeParse(e).success,qs=Fe.extend({method:N("ping"),params:rt.optional()}),Ey=O({progress:oe(),total:Te(oe()),message:Te(k())}),ky=O({...ot.shape,...Ey.shape,progressToken:zu}),va=at.extend({method:N("notifications/progress"),params:ky}),Py=rt.extend({cursor:Mu.optional()}),Tn=Fe.extend({params:Py.optional()}),Rn=He.extend({nextCursor:Mu.optional()}),Ty=tt(["working","input_required","completed","failed","cancelled"]),Cn=O({taskId:k(),status:Ty,ttl:pe([oe(),Ag()]),createdAt:k(),lastUpdatedAt:k(),pollInterval:Te(oe()),statusMessage:Te(k())}),yn=He.extend({task:Cn}),Ry=ot.merge(Cn),hs=at.extend({method:N("notifications/tasks/status"),params:Ry}),$a=Fe.extend({method:N("tasks/get"),params:rt.extend({taskId:k()})}),wa=He.merge(Cn),ba=Fe.extend({method:N("tasks/result"),params:rt.extend({taskId:k()})});He.loose();const Sa=Tn.extend({method:N("tasks/list")}),Ea=Rn.extend({tasks:D(Cn)}),ka=Fe.extend({method:N("tasks/cancel"),params:rt.extend({taskId:k()})}),Cy=He.merge(Cn),Vu=O({uri:k(),mimeType:Te(k()),_meta:_e(k(),$e()).optional()}),Lu=Vu.extend({text:k()}),Pa=k().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Fu=Vu.extend({blob:Pa}),Nn=tt(["user","assistant"]),Ur=O({audience:D(Nn).optional(),priority:oe().min(0).max(1).optional(),lastModified:Eu({offset:!0}).optional()}),Hu=O({...Ar.shape,...Pn.shape,uri:k(),description:Te(k()),mimeType:Te(k()),size:Te(oe()),annotations:Ur.optional(),_meta:Te(Le({}))}),Ny=O({...Ar.shape,...Pn.shape,uriTemplate:k(),description:Te(k()),mimeType:Te(k()),annotations:Ur.optional(),_meta:Te(Le({}))}),Zu=Tn.extend({method:N("resources/list")}),Ta=Rn.extend({resources:D(Hu)}),Ku=Tn.extend({method:N("resources/templates/list")}),Ra=Rn.extend({resourceTemplates:D(Ny)}),Ca=rt.extend({uri:k()}),Iy=Ca,Gu=Fe.extend({method:N("resources/read"),params:Iy}),Na=He.extend({contents:D(pe([Lu,Fu]))}),Ia=at.extend({method:N("notifications/resources/list_changed"),params:ot.optional()}),jy=Ca,Oy=Fe.extend({method:N("resources/subscribe"),params:jy}),Ay=Ca,zy=Fe.extend({method:N("resources/unsubscribe"),params:Ay}),My=ot.extend({uri:k()}),xy=at.extend({method:N("notifications/resources/updated"),params:My}),qy=O({name:k(),description:Te(k()),required:Te(me())}),Dy=O({...Ar.shape,...Pn.shape,description:Te(k()),arguments:Te(D(qy)),_meta:Te(Le({}))}),Wu=Tn.extend({method:N("prompts/list")}),ja=Rn.extend({prompts:D(Dy)}),Uy=rt.extend({name:k(),arguments:_e(k(),k()).optional()}),Vy=Fe.extend({method:N("prompts/get"),params:Uy}),Oa=O({type:N("text"),text:k(),annotations:Ur.optional(),_meta:_e(k(),$e()).optional()}),Aa=O({type:N("image"),data:Pa,mimeType:k(),annotations:Ur.optional(),_meta:_e(k(),$e()).optional()}),za=O({type:N("audio"),data:Pa,mimeType:k(),annotations:Ur.optional(),_meta:_e(k(),$e()).optional()}),Ly=O({type:N("tool_use"),name:k(),id:k(),input:_e(k(),$e()),_meta:_e(k(),$e()).optional()}),Bu=O({type:N("resource"),resource:pe([Lu,Fu]),annotations:Ur.optional(),_meta:_e(k(),$e()).optional()}),Ju=Hu.extend({type:N("resource_link")}),In=pe([Oa,Aa,za,Ju,Bu]),Fy=O({role:Nn,content:In}),Qu=He.extend({description:k().optional(),messages:D(Fy)}),Ma=at.extend({method:N("notifications/prompts/list_changed"),params:ot.optional()}),Hy=O({title:k().optional(),readOnlyHint:me().optional(),destructiveHint:me().optional(),idempotentHint:me().optional(),openWorldHint:me().optional()}),Zy=O({taskSupport:tt(["required","optional","forbidden"]).optional()}),xa=O({...Ar.shape,...Pn.shape,description:k().optional(),inputSchema:O({type:N("object"),properties:_e(k(),ze).optional(),required:D(k()).optional()}).catchall($e()),outputSchema:O({type:N("object"),properties:_e(k(),ze).optional(),required:D(k()).optional()}).catchall($e()).optional(),annotations:Hy.optional(),execution:Zy.optional(),_meta:_e(k(),$e()).optional()}),Ky=Tn.extend({method:N("tools/list")}),qa=Rn.extend({tools:D(xa)}),fr=He.extend({content:D(In).default([]),structuredContent:_e(k(),$e()).optional(),isError:me().optional()});fr.or(He.extend({toolResult:$e()}));const Gy=En.extend({name:k(),arguments:_e(k(),$e()).optional()}),Yu=Fe.extend({method:N("tools/call"),params:Gy}),Da=at.extend({method:N("notifications/tools/list_changed"),params:ot.optional()}),Wy=O({autoRefresh:me().default(!0),debounceMs:oe().int().nonnegative().default(300)}),Xu=tt(["debug","info","notice","warning","error","critical","alert","emergency"]),By=rt.extend({level:Xu}),Jy=Fe.extend({method:N("logging/setLevel"),params:By}),Qy=ot.extend({level:Xu,logger:k().optional(),data:$e()}),ed=at.extend({method:N("notifications/message"),params:Qy}),Yy=O({name:k().optional()}),Xy=O({hints:D(Yy).optional(),costPriority:oe().min(0).max(1).optional(),speedPriority:oe().min(0).max(1).optional(),intelligencePriority:oe().min(0).max(1).optional()}),ev=O({mode:tt(["auto","required","none"]).optional()}),tv=O({type:N("tool_result"),toolUseId:k().describe("The unique identifier for the corresponding tool call."),content:D(In).default([]),structuredContent:O({}).loose().optional(),isError:me().optional(),_meta:_e(k(),$e()).optional()}),rv=Cu("type",[Oa,Aa,za]),ps=Cu("type",[Oa,Aa,za,Ly,tv]),nv=O({role:Nn,content:pe([ps,D(ps)]),_meta:_e(k(),$e()).optional()}),sv=En.extend({messages:D(nv),modelPreferences:Xy.optional(),systemPrompt:k().optional(),includeContext:tt(["none","thisServer","allServers"]).optional(),temperature:oe().optional(),maxTokens:oe().int(),stopSequences:D(k()).optional(),metadata:ze.optional(),tools:D(xa).optional(),toolChoice:ev.optional()}),Ua=Fe.extend({method:N("sampling/createMessage"),params:sv}),td=He.extend({model:k(),stopReason:Te(tt(["endTurn","stopSequence","maxTokens"]).or(k())),role:Nn,content:rv}),rd=He.extend({model:k(),stopReason:Te(tt(["endTurn","stopSequence","maxTokens","toolUse"]).or(k())),role:Nn,content:pe([ps,D(ps)])}),ov=O({type:N("boolean"),title:k().optional(),description:k().optional(),default:me().optional()}),av=O({type:N("string"),title:k().optional(),description:k().optional(),minLength:oe().optional(),maxLength:oe().optional(),format:tt(["email","uri","date","date-time"]).optional(),default:k().optional()}),iv=O({type:tt(["number","integer"]),title:k().optional(),description:k().optional(),minimum:oe().optional(),maximum:oe().optional(),default:oe().optional()}),cv=O({type:N("string"),title:k().optional(),description:k().optional(),enum:D(k()),default:k().optional()}),lv=O({type:N("string"),title:k().optional(),description:k().optional(),oneOf:D(O({const:k(),title:k()})),default:k().optional()}),uv=O({type:N("string"),title:k().optional(),description:k().optional(),enum:D(k()),enumNames:D(k()).optional(),default:k().optional()}),dv=pe([cv,lv]),fv=O({type:N("array"),title:k().optional(),description:k().optional(),minItems:oe().optional(),maxItems:oe().optional(),items:O({type:N("string"),enum:D(k())}),default:D(k()).optional()}),hv=O({type:N("array"),title:k().optional(),description:k().optional(),minItems:oe().optional(),maxItems:oe().optional(),items:O({anyOf:D(O({const:k(),title:k()}))}),default:D(k()).optional()}),pv=pe([fv,hv]),mv=pe([uv,dv,pv]),_v=pe([mv,ov,av,iv]),gv=En.extend({mode:N("form").optional(),message:k(),requestedSchema:O({type:N("object"),properties:_e(k(),_v),required:D(k()).optional()})}),yv=En.extend({mode:N("url"),message:k(),elicitationId:k(),url:k().url()}),vv=pe([gv,yv]),nd=Fe.extend({method:N("elicitation/create"),params:vv}),$v=ot.extend({elicitationId:k()}),wv=at.extend({method:N("notifications/elicitation/complete"),params:$v}),sd=He.extend({action:tt(["accept","decline","cancel"]),content:Au(e=>e===null?void 0:e,_e(k(),pe([k(),oe(),me(),D(k())])).optional())}),bv=O({type:N("ref/resource"),uri:k()}),Sv=O({type:N("ref/prompt"),name:k()}),Ev=rt.extend({ref:pe([Sv,bv]),argument:O({name:k(),value:k()}),context:O({arguments:_e(k(),k()).optional()}).optional()}),kv=Fe.extend({method:N("completion/complete"),params:Ev}),od=He.extend({completion:Le({values:D(k()).max(100),total:Te(oe().int()),hasMore:Te(me())})}),Pv=O({uri:k().startsWith("file://"),name:k().optional(),_meta:_e(k(),$e()).optional()}),Tv=Fe.extend({method:N("roots/list"),params:rt.optional()}),Rv=He.extend({roots:D(Pv)}),Cv=at.extend({method:N("notifications/roots/list_changed"),params:ot.optional()});pe([qs,wy,kv,Jy,Vy,Wu,Zu,Ku,Gu,Oy,zy,Yu,Ky,$a,ba,Sa,ka]);pe([ya,va,Uu,Cv,hs]);pe([Tr,td,rd,sd,Rv,wa,Ea,yn]);pe([qs,Ua,nd,Tv,$a,ba,Sa,ka]);pe([ya,va,ed,xy,Ia,Da,Ma,hs,wv]);pe([Tr,Du,od,Qu,ja,Ta,Ra,Na,fr,qa,wa,Ea,yn]);class Y 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 Nv(s.elicitations,r)}return new Y(t,r,n)}}class Nv extends Y{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 Va(e){return!!e._zod}function Ot(e,t){return Va(e)?uu(e,t):e.safeParse(t)}function ad(e){var r,n;if(!e)return;let t;if(Va(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 id(e){var s;if(Va(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 er(e){return e==="completed"||e==="failed"||e==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Zc(e){const t=ad(e),r=t==null?void 0:t.method;if(!r)throw new Error("Schema is missing a method literal");const n=id(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function Kc(e,t){const r=Ot(e,t);if(!r.success)throw r.error;return r.data}const Iv=6e4;class cd{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(ya,r=>{this._oncancel(r)}),this.setNotificationHandler(va,r=>{this._onprogress(r)}),this.setRequestHandler(qs,r=>({})),this._taskStore=t==null?void 0:t.taskStore,this._taskMessageQueue=t==null?void 0:t.taskMessageQueue,this._taskStore&&(this.setRequestHandler($a,async(r,n)=>{const s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new Y(re.InvalidParams,"Failed to retrieve task: Task not found");return{...s}}),this.setRequestHandler(ba,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 g=l,y=new Y(g.error.code,g.error.message,g.error.data);f(y)}else{const g=c.type==="response"?"Response":"Error";this._onerror(new Error(`${g} 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 Y(re.InvalidParams,`Task not found: ${o}`);if(!er(a.status))return await this._waitForTaskUpdate(o,n.signal),await s();if(er(a.status)){const c=await this._taskStore.getTaskResult(o,n.sessionId);return this._clearTaskQueue(o),{...c,_meta:{...c._meta,[sr]:{taskId:o}}}}return await s()};return await s()}),this.setRequestHandler(Sa,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 Y(re.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(ka,async(r,n)=>{try{const s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new Y(re.InvalidParams,`Task not found: ${r.params.taskId}`);if(er(s.status))throw new Y(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 Y(re.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...o}}catch(s){throw s instanceof Y?s:new Y(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),Y.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),en(c)||fy(c)?this._onresponse(c):Eo(c)?this._onrequest(c,l):dy(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=Y.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,g,y;const n=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,s=this._transport,o=(g=(f=(d=t.params)==null?void 0:d._meta)==null?void 0:f[sr])==null?void 0:g.taskId;if(n===void 0){const _={jsonrpc:"2.0",id:t.id,error:{code:re.MethodNotFound,message:"Method not found"}};o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:_,timestamp:Date.now()},s==null?void 0:s.sessionId).catch($=>this._onerror(new Error(`Failed to enqueue error response: ${$}`))):s==null||s.send(_).catch($=>this._onerror(new Error(`Failed to send an error response: ${$}`)));return}const a=new AbortController;this._requestHandlerAbortControllers.set(t.id,a);const i=uy(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 _=>{if(a.signal.aborted)return;const $={relatedRequestId:t.id};o&&($.relatedTask={taskId:o}),await this.notification(_,$)},sendRequest:async(_,$,m)=>{var S;if(a.signal.aborted)throw new Y(re.ConnectionClosed,"Request was cancelled");const h={...m,relatedRequestId:t.id};o&&!h.relatedTask&&(h.relatedTask={taskId:o});const v=((S=h.relatedTask)==null?void 0:S.taskId)??o;return v&&c&&await c.updateTaskStatus(v,"input_required"),await this.request(_,$,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 _=>{if(a.signal.aborted)return;const $={result:_,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 _=>{if(a.signal.aborted)return;const $={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(_.code)?_.code:re.InternalError,message:_.message??"Internal error",..._.data!==void 0&&{data:_.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(_=>this._onerror(new Error(`Failed to send response: ${_}`))).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),en(t))n(t);else{const a=new Y(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(en(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),en(t))s(t);else{const a=Y.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 Y?c:new Y(re.InternalError,String(c))}}return}let o;try{const c=await this.request(t,yn,n);if(c.task)o=c.task.taskId,yield{type:"taskCreated",task:c.task};else throw new Y(re.InternalError,"Task creation did not return a task");for(;;){const l=await this.getTask({taskId:o},n);if(yield{type:"taskStatus",task:l},er(l.status)){l.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},r,n)}:l.status==="failed"?yield{type:"error",error:new Y(re.InternalError,`Task ${o} failed`)}:l.status==="cancelled"&&(yield{type:"error",error:new Y(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 Y?c:new Y(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,S,R,P,I;const f=A=>{d(A)};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(A){f(A);return}(S=n==null?void 0:n.signal)==null||S.throwIfAborted();const g=this._requestMessageId++,y={...t,jsonrpc:"2.0",id:g};n!=null&&n.onprogress&&(this._progressHandlers.set(g,n.onprogress),y.params={...t.params,_meta:{...((R=t.params)==null?void 0:R._meta)||{},progressToken:g}}),i&&(y.params={...y.params,task:i}),c&&(y.params={...y.params,_meta:{...((P=y.params)==null?void 0:P._meta)||{},[sr]:c}});const _=A=>{var Z;this._responseHandlers.delete(g),this._progressHandlers.delete(g),this._cleanupTimeout(g),(Z=this._transport)==null||Z.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:g,reason:String(A)}},{relatedRequestId:s,resumptionToken:o,onresumptiontoken:a}).catch(V=>this._onerror(new Error(`Failed to send cancellation: ${V}`)));const U=A instanceof Y?A:new Y(re.RequestTimeout,String(A));d(U)};this._responseHandlers.set(g,A=>{var U;if(!((U=n==null?void 0:n.signal)!=null&&U.aborted)){if(A instanceof Error)return d(A);try{const Z=Ot(r,A.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 A;_((A=n==null?void 0:n.signal)==null?void 0:A.reason)});const $=(n==null?void 0:n.timeout)??Iv,m=()=>_(Y.fromError(re.RequestTimeout,"Request timed out",{timeout:$}));this._setupTimeout(g,$,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 A=U=>{const Z=this._responseHandlers.get(g);Z?Z(U):this._onerror(new Error(`Response handler missing for side-channeled request ${g}`))};this._requestResolvers.set(g,A),this._enqueueTaskMessage(h,{type:"request",message:y,timestamp:Date.now()}).catch(U=>{this._cleanupTimeout(g),d(U)})}else this._transport.send(y,{relatedRequestId:s,resumptionToken:o,onresumptiontoken:a}).catch(A=>{this._cleanupTimeout(g),d(A)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},wa,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},Ea,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},Cy,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)||{},[sr]: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 g,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:{...((g=f.params)==null?void 0:g._meta)||{},[sr]:r.relatedTask}}}),(y=this._transport)==null||y.send(f,r).catch(_=>this._onerror(_))});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)||{},[sr]:r.relatedTask}}}),await this._transport.send(a,r)}setRequestHandler(t,r){const n=Zc(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(s,o)=>{const a=Kc(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=Zc(t);this._notificationHandlers.set(n,s=>{const o=Kc(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"&&Eo(s.message)){const o=s.message.id,a=this._requestResolvers.get(o);a?(a(new Y(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 Y(re.InvalidRequest,"Request cancelled"));return}const c=setTimeout(a,n);r.addEventListener("abort",()=>{clearTimeout(c),i(new Y(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 Y(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=hs.parse({method:"notifications/tasks/status",params:i});await this.notification(c),er(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 Y(re.InvalidParams,`Task "${s}" not found - it may have been cleaned up`);if(er(i.status))throw new Y(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=hs.parse({method:"notifications/tasks/status",params:c});await this.notification(l),er(c.status)&&this._cleanupTaskProgressHandler(s)}},listTasks:s=>n.listTasks(s,r)}}}function Gc(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function jv(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];Gc(a)&&Gc(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 Ov extends cd{constructor(){super(...arguments);ae(this,"_registeredMethods",new Set);ae(this,"_eventSlots",new Map);ae(this,"setRequestHandler",(r,n)=>{this._assertMethodNotRegistered(r,"setRequestHandler"),super.setRequestHandler(r,n)});ae(this,"setNotificationHandler",(r,n)=>{this._assertMethodNotRegistered(r,"setNotificationHandler"),super.setNotificationHandler(r,n)});ae(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 ld="2026-01-26",Av="ui/notifications/tool-input-partial",zv=pe([N("light"),N("dark")]).describe("Color theme preference for the host environment."),vn=pe([N("inline"),N("fullscreen"),N("pip")]).describe("Display mode for UI presentation."),Mv=pe([N("--color-background-primary"),N("--color-background-secondary"),N("--color-background-tertiary"),N("--color-background-inverse"),N("--color-background-ghost"),N("--color-background-info"),N("--color-background-danger"),N("--color-background-success"),N("--color-background-warning"),N("--color-background-disabled"),N("--color-text-primary"),N("--color-text-secondary"),N("--color-text-tertiary"),N("--color-text-inverse"),N("--color-text-ghost"),N("--color-text-info"),N("--color-text-danger"),N("--color-text-success"),N("--color-text-warning"),N("--color-text-disabled"),N("--color-border-primary"),N("--color-border-secondary"),N("--color-border-tertiary"),N("--color-border-inverse"),N("--color-border-ghost"),N("--color-border-info"),N("--color-border-danger"),N("--color-border-success"),N("--color-border-warning"),N("--color-border-disabled"),N("--color-ring-primary"),N("--color-ring-secondary"),N("--color-ring-inverse"),N("--color-ring-info"),N("--color-ring-danger"),N("--color-ring-success"),N("--color-ring-warning"),N("--font-sans"),N("--font-mono"),N("--font-weight-normal"),N("--font-weight-medium"),N("--font-weight-semibold"),N("--font-weight-bold"),N("--font-text-xs-size"),N("--font-text-sm-size"),N("--font-text-md-size"),N("--font-text-lg-size"),N("--font-heading-xs-size"),N("--font-heading-sm-size"),N("--font-heading-md-size"),N("--font-heading-lg-size"),N("--font-heading-xl-size"),N("--font-heading-2xl-size"),N("--font-heading-3xl-size"),N("--font-text-xs-line-height"),N("--font-text-sm-line-height"),N("--font-text-md-line-height"),N("--font-text-lg-line-height"),N("--font-heading-xs-line-height"),N("--font-heading-sm-line-height"),N("--font-heading-md-line-height"),N("--font-heading-lg-line-height"),N("--font-heading-xl-line-height"),N("--font-heading-2xl-line-height"),N("--font-heading-3xl-line-height"),N("--border-radius-xs"),N("--border-radius-sm"),N("--border-radius-md"),N("--border-radius-lg"),N("--border-radius-xl"),N("--border-radius-full"),N("--border-width-regular"),N("--shadow-hairline"),N("--shadow-sm"),N("--shadow-md"),N("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),xv=_e(Mv.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([k(),$o()]).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:N("ui/open-link"),params:O({url:k().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 Dv=O({method:N("ui/notifications/sandbox-proxy-ready"),params:O({})}),La=O({connectDomains:D(k()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket). + +- Maps to CSP \`connect-src\` directive +- Empty or omitted → no network connections (secure default)`),resourceDomains:D(k()).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:D(k()).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:D(k()).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'`)")}),Fa=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.")}),Uv=O({method:N("ui/notifications/size-changed"),params:O({width:oe().optional().describe("New width in pixels."),height:oe().optional().describe("New height in pixels.")})});O({method:N("ui/notifications/tool-input"),params:O({arguments:_e(k(),$e().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})});O({method:N("ui/notifications/tool-input-partial"),params:O({arguments:_e(k(),$e().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})});O({method:N("ui/notifications/tool-cancelled"),params:O({reason:k().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})});var Vv=O({fonts:k().optional()}),Lv=O({variables:xv.optional().describe("CSS variables for theming the app."),css:Vv.optional().describe("CSS blocks that apps can inject.")});O({method:N("ui/resource-teardown"),params:O({})});var Fv=_e(k(),$e()),Wc=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.")}),Hv=O({method:N("ui/notifications/request-teardown"),params:O({}).optional()}),Zv=O({experimental:_e(k(),_e(k(),ha()).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:Fa.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:La.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:Wc.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:Wc.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.")}),Kv=O({experimental:_e(k(),_e(k(),ha()).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:D(vn).optional().describe("Display modes the app supports.")}),Gv=O({method:N("ui/notifications/initialized"),params:O({}).optional()});O({csp:La.optional().describe("Content Security Policy configuration for UI resources."),permissions:Fa.optional().describe("Sandbox permissions requested by the UI resource."),domain:k().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 Bc=O({method:N("ui/request-display-mode"),params:O({mode:vn.describe("The display mode being requested.")})});O({mode:vn.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough();var Wv=pe([N("model"),N("app")]).describe("Tool visibility scope - who can access the tool.");O({resourceUri:k().optional(),visibility:D(Wv).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:wo().optional(),permissions:wo().optional()});O({mimeTypes:D(k()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});var Bv=O({method:N("ui/download-file"),params:O({contents:D(pe([Bu,Ju])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),Jv=O({method:N("ui/message"),params:O({role:N("user").describe('Message role, currently only "user" is supported.'),content:D(In).describe("Message content blocks (text, image, etc.).")})});O({method:N("ui/notifications/sandbox-resource-ready"),params:O({html:k().describe("HTML content to load into the inner iframe."),sandbox:k().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:La.optional().describe("CSP configuration from resource metadata."),permissions:Fa.optional().describe("Sandbox permissions from resource metadata.")})});O({method:N("ui/notifications/tool-result"),params:fr.describe("Standard MCP tool execution result.")});var ud=O({toolInfo:O({id:kn.optional().describe("JSON-RPC id of the tools/call request."),tool:xa.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:zv.optional().describe("Current color theme preference."),styles:Lv.optional().describe("Style configuration for theming the app."),displayMode:vn.optional().describe("How the UI is currently displayed."),availableDisplayModes:D(vn).optional().describe("Display modes the host supports."),containerDimensions:pe([O({height:oe().describe("Fixed container height in pixels.")}),O({maxHeight:pe([oe(),$o()]).optional().describe("Maximum container height in pixels.")})]).and(pe([O({width:oe().describe("Fixed container width in pixels.")}),O({maxWidth:pe([oe(),$o()]).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:k().optional().describe("User's language and region preference in BCP 47 format."),timeZone:k().optional().describe("User's timezone in IANA format."),userAgent:k().optional().describe("Host application identifier."),platform:pe([N("web"),N("desktop"),N("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:oe().describe("Top safe area inset in pixels."),right:oe().describe("Right safe area inset in pixels."),bottom:oe().describe("Bottom safe area inset in pixels."),left:oe().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough();O({method:N("ui/notifications/host-context-changed"),params:ud.describe("Partial context update containing only changed fields.")});var Qv=O({method:N("ui/update-model-context"),params:O({content:D(In).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:_e(k(),$e().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),Yv=O({method:N("ui/initialize"),params:O({appInfo:xs.describe("App identification (name and version)."),appCapabilities:Kv.describe("Features and capabilities this app provides."),protocolVersion:k().describe("Protocol version this app supports.")})});O({protocolVersion:k().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:xs.describe("Host application identification and version."),hostCapabilities:Zv.describe("Features and capabilities provided by the host."),hostContext:ud.describe("Rich context about the host environment.")}).passthrough();class Xv{constructor(t=window.parent,r){ae(this,"eventTarget");ae(this,"eventSource");ae(this,"messageListener");ae(this,"onclose");ae(this,"onerror");ae(this,"onmessage");ae(this,"sessionId");ae(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=Xn.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!==Av&&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 e$=[ld];class t$ extends Ov{constructor(r,n,s,o){super(o);ae(this,"_client");ae(this,"_hostInfo");ae(this,"_capabilities");ae(this,"_appCapabilities");ae(this,"_hostContext",{});ae(this,"_appInfo");ae(this,"_initializedReceived",!1);ae(this,"_baseReplaceRequestHandler",this.replaceRequestHandler);ae(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)))});ae(this,"eventSchemas",{sizechange:Uv,sandboxready:Dv,initialized:Gv,requestteardown:Hv,loggingmessage:ed});ae(this,"onping");ae(this,"_onmessage");ae(this,"_onopenlink");ae(this,"_ondownloadfile");ae(this,"_onrequestdisplaymode");ae(this,"_onupdatemodelcontext");ae(this,"_oncalltool");ae(this,"_onlistresources");ae(this,"_onlistresourcetemplates");ae(this,"_onreadresource");ae(this,"_onlistprompts");ae(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(Yv,a=>this._oninitialize(a)),this.setRequestHandler(qs,(a,i)=>{var c;return(c=this.onping)==null||c.call(this,a.params,i),{}}),this.replaceRequestHandler(Bc,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(Jv,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(Bv,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(Bc,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(Qv,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(Yu,async(n,s)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(n.params,s)})}set oncreatesamplingmessage(r){this.setRequestHandler(Ua,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(Zu,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(Ku,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(Gu,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(Wu,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:e$.includes(n)?n:ld,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];r$(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},Fv,n)}callTool(r,n){return this.request({method:"tools/call",params:r},fr,n)}listTools(r,n){return this.request({method:"tools/list",params:r},qa,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},fr,{signal:o.signal}),n.tools.listChanged&&this._client.setNotificationHandler(Da,s=>this.sendToolListChanged(s.params))),n.resources&&(this.onlistresources=async(s,o)=>this._client.request({method:"resources/list",params:s},Ta,{signal:o.signal}),this.onlistresourcetemplates=async(s,o)=>this._client.request({method:"resources/templates/list",params:s},Ra,{signal:o.signal}),this.onreadresource=async(s,o)=>this._client.request({method:"resources/read",params:s},Na,{signal:o.signal}),n.resources.listChanged&&this._client.setNotificationHandler(Ia,s=>this.sendResourceListChanged(s.params))),n.prompts&&(this.onlistprompts=async(s,o)=>this._client.request({method:"prompts/list",params:s},ja,{signal:o.signal}),n.prompts.listChanged&&this._client.setNotificationHandler(Ma,s=>this.sendPromptListChanged(s.params)))}return super.connect(r)}}function r$(e,t){return JSON.stringify(e)===JSON.stringify(t)}const n$=1024,s$=16;function yt(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function o$(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return e}function a$(e){return e.type!=="cameraUpdate"&&e.type!=="delete"&&e.type!=="restoreCheckpoint"}function ko(e){return e.type==="text"&&typeof(e.text??e.originalText)=="string"}function Ha(e){const t=yt(e.width);if(t!==void 0&&t>0)return t;const r=String(e.text??e.originalText??""),n=yt(e.fontSize)??20;return r.length*n*.65}function i$(e){const t=yt(e.x),r=yt(e.y);if(t===void 0||r===void 0)return null;const n=ko(e)?Ha(e):yt(e.width),s=yt(e.height)??(ko(e)?(yt(e.fontSize)??20)*1.4:0);return n===void 0||n<=0?null:{x:t,y:r,width:n,height:s}}function c$(e,t){const r=Math.min(e.x,t.x),n=Math.min(e.y,t.y);return{x:r,y:n,width:Math.max(e.x+e.width,t.x+t.width)-r,height:Math.max(e.y+e.height,t.y+t.height)-n}}function l$(e){let t=-1,r=1/0,n=-1;return e.forEach((s,o)=>{if(!ko(s))return;const a=yt(s.y);if(a===void 0)return;const i=yt(s.fontSize)??Ha(s);(an)&&(t=o,r=a,n=i)}),t}function u$(e){const t=e.map(o$);if(t.some(d=>d===void 0))return e;const r=t,n=l$(r);if(n<0)return e;let s=null;for(let d=0;d0?s.width:n$,l=Math.max(1,c-s$*2);if(a>l){const d=l/a,f=yt(o.fontSize)??20;o.fontSize=f*d,typeof o.height=="number"&&(o.height*=d),a=l}return o.width=a,o.textAlign="center",o.x=i+(c-a)/2,r.map((d,f)=>f===n?o:d)}var Po={exports:{}},dd={},mt={},zr={},jn={},fe={},$n={};(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((S,R)=>`${S}${R}`,"")}get names(){var v;return(v=this._names)!==null&&v!==void 0?v:this._names=this._items.reduce((S,R)=>(R instanceof r&&(S[R.str]=(S[R.str]||0)+1),S),{})}}e._Code=n,e.nil=new n("");function s(h,...v){const S=[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,g=>{if(g.value===void 0)throw new Error(`CodeGen: name "${g}" has no value`);return g.value.code},d,f)}_reduceValues(l,d,f={},g){let y=t.nil;for(const _ in l){const $=l[_];if(!$)continue;const m=f[_]=f[_]||new Map;$.forEach(h=>{if(m.has(h))return;m.set(h,n.Started);let v=d(h);if(v){const S=this.opts.es5?e.varKinds.var:e.varKinds.const;y=(0,t._)`${y}${S} ${h} = ${v};${this.opts._n}`}else if(v=g==null?void 0:g(h))y=(0,t._)`${y}${v}${this.opts._n}`;else throw new r(h);m.set(h,n.Completed)})}return y}}e.ValueScope=i})(To);(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=$n,r=To;var n=$n;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=To;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,E){super(),this.varKind=u,this.name=p,this.rhs=E}render({es5:u,_n:p}){const E=u?r.varKinds.var:this.varKind,M=this.rhs===void 0?"":` = ${this.rhs}`;return`${E} ${this.name}${M};`+p}optimizeNames(u,p){if(u[this.name.str])return this.rhs&&(this.rhs=q(this.rhs,u,p)),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}}class i extends o{constructor(u,p,E){super(),this.lhs=u,this.rhs=p,this.sideEffects=E}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=q(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,E,M){super(u,E,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 g 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=q(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,E)=>p+E.render(u),"")}optimizeNodes(){const{nodes:u}=this;let p=u.length;for(;p--;){const E=u[p].optimizeNodes();Array.isArray(E)?u.splice(p,1,...E):E?u[p]=E:u.splice(p,1)}return u.length>0?this:void 0}optimizeNames(u,p){const{nodes:E}=this;let M=E.length;for(;M--;){const x=E[M];x.optimizeNames(u,p)||(le(u,x.names),E.splice(M,1))}return E.length>0?this:void 0}get names(){return this.nodes.reduce((u,p)=>W(u,p.names),{})}}class _ extends y{render(u){return"{"+u._n+super.render(u)+"}"+u._n}}class $ extends y{}class m extends _{}m.kind="else";class h extends _{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 E=p.optimizeNodes();p=this.else=Array.isArray(E)?new m(E):E}if(p)return u===!1?p instanceof h?p:p.nodes:this.nodes.length?this:new h(Ce(u),p instanceof h?[p]:p.nodes);if(!(u===!1||!this.nodes.length))return this}optimizeNames(u,p){var E;if(this.else=(E=this.else)===null||E===void 0?void 0:E.optimizeNames(u,p),!!(super.optimizeNames(u,p)||this.else))return this.condition=q(this.condition,u,p),this}get names(){const u=super.names;return ce(u,this.condition),this.else&&W(u,this.else.names),u}}h.kind="if";class v extends _{}v.kind="for";class S 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=q(this.iteration,u,p),this}get names(){return W(super.names,this.iteration.names)}}class R extends v{constructor(u,p,E,M){super(),this.varKind=u,this.name=p,this.from=E,this.to=M}render(u){const p=u.es5?r.varKinds.var:this.varKind,{name:E,from:M,to:x}=this;return`for(${p} ${E}=${M}; ${E}<${x}; ${E}++)`+super.render(u)}get names(){const u=ce(super.names,this.from);return ce(u,this.to)}}class P extends v{constructor(u,p,E,M){super(),this.loop=u,this.varKind=p,this.name=E,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=q(this.iterable,u,p),this}get names(){return W(super.names,this.iterable.names)}}class I extends _{constructor(u,p,E){super(),this.name=u,this.args=p,this.async=E}render(u){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(u)}}I.kind="func";class A extends y{render(u){return"return "+super.render(u)}}A.kind="return";class U extends _{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 E,M;return super.optimizeNames(u,p),(E=this.catch)===null||E===void 0||E.optimizeNames(u,p),(M=this.finally)===null||M===void 0||M.optimizeNames(u,p),this}get names(){const u=super.names;return this.catch&&W(u,this.catch.names),this.finally&&W(u,this.finally.names),u}}class Z extends _{constructor(u){super(),this.error=u}render(u){return`catch(${this.error})`+super.render(u)}}Z.kind="catch";class V extends _{render(u){return"finally"+super.render(u)}}V.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 E=this._extScope.value(u,p);return(this._values[E.prefix]||(this._values[E.prefix]=new Set)).add(E),E}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,E,M){const x=this._scope.toName(p);return E!==void 0&&M&&(this._constants[x.str]=E),this._leafNode(new a(u,x,E)),x}const(u,p,E){return this._def(r.varKinds.const,u,p,E)}let(u,p,E){return this._def(r.varKinds.let,u,p,E)}var(u,p,E){return this._def(r.varKinds.var,u,p,E)}assign(u,p,E){return this._leafNode(new i(u,p,E))}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 g(u)),this}object(...u){const p=["{"];for(const[E,M]of u)p.length>1&&p.push(","),p.push(E),(E!==M||this.opts.es5)&&(p.push(":"),(0,t.addCodeArg)(p,M));return p.push("}"),new t._Code(p)}if(u,p,E){if(this._blockNode(new h(u)),p&&E)this.code(p).else().code(E).endIf();else if(p)this.code(p).endIf();else if(E)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 S(u),p)}forRange(u,p,E,M,x=this.opts.es5?r.varKinds.var:r.varKinds.let){const B=this._scope.toName(u);return this._for(new R(x,B,p,E),()=>M(B))}forOf(u,p,E,M=r.varKinds.const){const x=this._scope.toName(u);if(this.opts.es5){const B=p instanceof t.Name?p:this.var("_arr",p);return this.forRange("_i",0,(0,t._)`${B}.length`,K=>{this.var(x,(0,t._)`${B}[${K}]`),E(x)})}return this._for(new P("of",M,x,p),()=>E(x))}forIn(u,p,E,M=this.opts.es5?r.varKinds.var:r.varKinds.const){if(this.opts.ownProperties)return this.forOf(u,(0,t._)`Object.keys(${p})`,E);const x=this._scope.toName(u);return this._for(new P("in",M,x,p),()=>E(x))}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 A;if(this._blockNode(p),this.code(u),p.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(A)}try(u,p,E){if(!p&&!E)throw new Error('CodeGen: "try" without "catch" and "finally"');const M=new U;if(this._blockNode(M),this.code(u),p){const x=this.name("e");this._currNode=M.catch=new Z(x),p(x)}return E&&(this._currNode=M.finally=new V,this.code(E)),this._endBlockNode(Z,V)}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 E=this._nodes.length-p;if(E<0||u!==void 0&&E!==u)throw new Error(`CodeGen: wrong number of nodes: ${E} vs ${u} expected`);return this._nodes.length=p,this}func(u,p=t.nil,E,M){return this._blockNode(new I(u,p,E)),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 E=this._currNode;if(E instanceof u||p&&E 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 W(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?W(b,u.names):b}function q(b,u,p){if(b instanceof t.Name)return E(b);if(!M(b))return b;return new t._Code(b._items.reduce((x,B)=>(B instanceof t.Name&&(B=E(B)),B instanceof t._Code?x.push(...B._items):x.push(B),x),[]));function E(x){const B=p[x.str];return B===void 0||u[x.str]!==1?x:(delete u[x.str],B)}function M(x){return x instanceof t._Code&&x._items.some(B=>B instanceof t.Name&&u[B.str]===1&&p[B.str]!==void 0)}}function le(b,u){for(const p in u)b[p]=(b[p]||0)-(u[p]||0)}function Ce(b){return typeof b=="boolean"||typeof b=="number"||b===null?!b:(0,t._)`!${C(b)}`}e.not=Ce;const ge=w(e.operators.AND);function it(...b){return b.reduce(ge)}e.and=it;const je=w(e.operators.OR);function j(...b){return b.reduce(je)}e.or=j;function w(b){return(u,p)=>u===t.nil?p:p===t.nil?u:(0,t._)`${C(u)} ${b} ${C(p)}`}function C(b){return b instanceof t.Name?b:(0,t._)`(${b})`}})(fe);var F={};Object.defineProperty(F,"__esModule",{value:!0});F.checkStrictMode=F.getErrorPath=F.Type=F.useFunc=F.setEvaluated=F.evaluatedPropsToName=F.mergeEvaluated=F.eachItem=F.unescapeJsonPointer=F.escapeJsonPointer=F.escapeFragment=F.unescapeFragment=F.schemaRefOrVal=F.schemaHasRulesButRef=F.schemaHasRules=F.checkUnknownRules=F.alwaysValidSchema=F.toHash=void 0;const ye=fe,d$=$n;function f$(e){const t={};for(const r of e)t[r]=!0;return t}F.toHash=f$;function h$(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(fd(e,t),!hd(t,e.self.RULES.all))}F.alwaysValidSchema=h$;function fd(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]||_d(e,`unknown keyword: "${o}"`)}F.checkUnknownRules=fd;function hd(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(t[r])return!0;return!1}F.schemaHasRules=hd;function p$(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}F.schemaHasRulesButRef=p$;function m$({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)}`}F.schemaRefOrVal=m$;function _$(e){return pd(decodeURIComponent(e))}F.unescapeFragment=_$;function g$(e){return encodeURIComponent(Za(e))}F.escapeFragment=g$;function Za(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}F.escapeJsonPointer=Za;function pd(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}F.unescapeJsonPointer=pd;function y$(e,t){if(Array.isArray(e))for(const r of e)t(r);else t(e)}F.eachItem=y$;function Jc({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}}F.mergeEvaluated={props:Jc({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} || {}`),Ka(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:md}),items:Jc({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 md(e,t){if(t===!0)return e.var("props",!0);const r=e.var("props",(0,ye._)`{}`);return t!==void 0&&Ka(e,r,t),r}F.evaluatedPropsToName=md;function Ka(e,t,r){Object.keys(r).forEach(n=>e.assign((0,ye._)`${t}${(0,ye.getProperty)(n)}`,!0))}F.setEvaluated=Ka;const Qc={};function v$(e,t){return e.scopeValue("func",{ref:t,code:Qc[t.code]||(Qc[t.code]=new d$._Code(t.code))})}F.useFunc=v$;var Ro;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(Ro||(F.Type=Ro={}));function $$(e,t,r){if(e instanceof ye.Name){const n=t===Ro.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():"/"+Za(e)}F.getErrorPath=$$;function _d(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}F.checkStrictMode=_d;var St={};Object.defineProperty(St,"__esModule",{value:!0});const Ze=fe,w$={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=w$;(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=F,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,S){const{it:R}=m,{gen:P,compositeRule:I,allErrors:A}=R,U=f(m,h,v);S??(I||A)?c(P,U):l(R,(0,t._)`[${U}]`)}e.reportError=s;function o(m,h=e.keywordError,v){const{it:S}=m,{gen:R,compositeRule:P,allErrors:I}=S,A=f(m,h,v);c(R,A),P||I||l(S,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:S,errsCount:R,it:P}){if(R===void 0)throw new Error("ajv implementation error");const I=m.name("err");m.forRange("i",R,n.default.errors,A=>{m.const(I,(0,t._)`${n.default.vErrors}[${A}]`),m.if((0,t._)`${I}.instancePath === undefined`,()=>m.assign((0,t._)`${I}.instancePath`,(0,t.strConcat)(n.default.instancePath,P.errorPath))),m.assign((0,t._)`${I}.schemaPath`,(0,t.str)`${P.errSchemaPath}/${h}`),P.opts.verbose&&(m.assign((0,t._)`${I}.schema`,v),m.assign((0,t._)`${I}.data`,S))})}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:S,schemaEnv:R}=m;R.$async?v.throw((0,t._)`new ${m.ValidationError}(${h})`):(v.assign((0,t._)`${S}.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:S}=m.it;return S===!1?(0,t._)`{}`:g(m,h,v)}function g(m,h,v={}){const{gen:S,it:R}=m,P=[y(R,v),_(m,v)];return $(m,h,P),S.object(...P)}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 _({keyword:m,it:{errSchemaPath:h}},{schemaPath:v,parentSchema:S}){let R=S?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},S){const{keyword:R,data:P,schemaValue:I,it:A}=m,{opts:U,propertyName:Z,topSchemaRef:V,schemaPath:L}=A;S.push([d.keyword,R],[d.params,typeof h=="function"?h(m):h||(0,t._)`{}`]),U.messages&&S.push([d.message,typeof v=="function"?v(m):v]),U.verbose&&S.push([d.schema,I],[d.parentSchema,(0,t._)`${V}${L}`],[n.default.data,P]),Z&&S.push([d.propertyName,Z])}})(jn);Object.defineProperty(zr,"__esModule",{value:!0});zr.boolOrEmptySchema=zr.topBoolOrEmptySchema=void 0;const b$=jn,S$=fe,E$=St,k$={message:"boolean schema is false"};function P$(e){const{gen:t,schema:r,validateName:n}=e;r===!1?gd(e,!1):typeof r=="object"&&r.$async===!0?t.return(E$.default.data):(t.assign((0,S$._)`${n}.errors`,null),t.return(!0))}zr.topBoolOrEmptySchema=P$;function T$(e,t){const{gen:r,schema:n}=e;n===!1?(r.var(t,!1),gd(e)):r.var(t,!0)}zr.boolOrEmptySchema=T$;function gd(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,b$.reportError)(s,k$,void 0,t)}var Oe={},hr={};Object.defineProperty(hr,"__esModule",{value:!0});hr.getRules=hr.isJSONType=void 0;const R$=["string","number","integer","boolean","null","object","array"],C$=new Set(R$);function N$(e){return typeof e=="string"&&C$.has(e)}hr.isJSONType=N$;function I$(){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:{}}}hr.getRules=I$;var kt={};Object.defineProperty(kt,"__esModule",{value:!0});kt.shouldUseRule=kt.shouldUseGroup=kt.schemaHasRulesForType=void 0;function j$({schema:e,self:t},r){const n=t.RULES.types[r];return n&&n!==!0&&yd(e,n)}kt.schemaHasRulesForType=j$;function yd(e,t){return t.rules.some(r=>vd(e,r))}kt.shouldUseGroup=yd;function vd(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=vd;Object.defineProperty(Oe,"__esModule",{value:!0});Oe.reportTypeError=Oe.checkDataTypes=Oe.checkDataType=Oe.coerceAndCheckDataType=Oe.getJSONTypes=Oe.getSchemaTypes=Oe.DataType=void 0;const O$=hr,A$=kt,z$=jn,ne=fe,$d=F;var Nr;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Nr||(Oe.DataType=Nr={}));function M$(e){const t=wd(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=M$;function wd(e){const t=Array.isArray(e)?e:e?[e]:[];if(t.every(O$.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}Oe.getJSONTypes=wd;function x$(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,A$.schemaHasRulesForType)(e,t[0]));if(a){const i=Ga(t,n,s.strictNumbers,Nr.Wrong);r.if(i,()=>{o.length?D$(e,t,o):Wa(e)})}return a}Oe.coerceAndCheckDataType=x$;const bd=new Set(["string","number","integer","boolean","null"]);function q$(e,t){return t?e.filter(r=>bd.has(r)||t==="array"&&r==="array"):[]}function D$(e,t,r){const{gen:n,data:s,opts:o}=e,a=n.let("dataType",(0,ne._)`typeof ${s}`),i=n.let("coerced",(0,ne._)`undefined`);o.coerceTypes==="array"&&n.if((0,ne._)`${a} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>n.assign(s,(0,ne._)`${s}[0]`).assign(a,(0,ne._)`typeof ${s}`).if(Ga(t,s,o.strictNumbers),()=>n.assign(i,s))),n.if((0,ne._)`${i} !== undefined`);for(const l of r)(bd.has(l)||l==="array"&&o.coerceTypes==="array")&&c(l);n.else(),Wa(e),n.endIf(),n.if((0,ne._)`${i} !== undefined`,()=>{n.assign(s,i),U$(e,i)});function c(l){switch(l){case"string":n.elseIf((0,ne._)`${a} == "number" || ${a} == "boolean"`).assign(i,(0,ne._)`"" + ${s}`).elseIf((0,ne._)`${s} === null`).assign(i,(0,ne._)`""`);return;case"number":n.elseIf((0,ne._)`${a} == "boolean" || ${s} === null + || (${a} == "string" && ${s} && ${s} == +${s})`).assign(i,(0,ne._)`+${s}`);return;case"integer":n.elseIf((0,ne._)`${a} === "boolean" || ${s} === null + || (${a} === "string" && ${s} && ${s} == +${s} && !(${s} % 1))`).assign(i,(0,ne._)`+${s}`);return;case"boolean":n.elseIf((0,ne._)`${s} === "false" || ${s} === 0 || ${s} === null`).assign(i,!1).elseIf((0,ne._)`${s} === "true" || ${s} === 1`).assign(i,!0);return;case"null":n.elseIf((0,ne._)`${s} === "" || ${s} === 0 || ${s} === false`),n.assign(i,null);return;case"array":n.elseIf((0,ne._)`${a} === "string" || ${a} === "number" + || ${a} === "boolean" || ${s} === null`).assign(i,(0,ne._)`[${s}]`)}}}function U$({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,ne._)`${t} !== undefined`,()=>e.assign((0,ne._)`${t}[${r}]`,n))}function Co(e,t,r,n=Nr.Correct){const s=n===Nr.Correct?ne.operators.EQ:ne.operators.NEQ;let o;switch(e){case"null":return(0,ne._)`${t} ${s} null`;case"array":o=(0,ne._)`Array.isArray(${t})`;break;case"object":o=(0,ne._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":o=a((0,ne._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":o=a();break;default:return(0,ne._)`typeof ${t} ${s} ${e}`}return n===Nr.Correct?o:(0,ne.not)(o);function a(i=ne.nil){return(0,ne.and)((0,ne._)`typeof ${t} == "number"`,i,r?(0,ne._)`isFinite(${t})`:ne.nil)}}Oe.checkDataType=Co;function Ga(e,t,r,n){if(e.length===1)return Co(e[0],t,r,n);let s;const o=(0,$d.toHash)(e);if(o.array&&o.object){const a=(0,ne._)`typeof ${t} != "object"`;s=o.null?a:(0,ne._)`!${t} || ${a}`,delete o.null,delete o.array,delete o.object}else s=ne.nil;o.number&&delete o.integer;for(const a in o)s=(0,ne.and)(s,Co(a,t,r,n));return s}Oe.checkDataTypes=Ga;const V$={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,ne._)`{type: ${e}}`:(0,ne._)`{type: ${t}}`};function Wa(e){const t=L$(e);(0,z$.reportError)(t,V$)}Oe.reportTypeError=Wa;function L$(e){const{gen:t,data:r,schema:n}=e,s=(0,$d.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:e}}var Ds={};Object.defineProperty(Ds,"__esModule",{value:!0});Ds.assignDefaults=void 0;const vr=fe,F$=F;function H$(e,t){const{properties:r,items:n}=e.schema;if(t==="object"&&r)for(const s in r)Yc(e,s,r[s].default);else t==="array"&&Array.isArray(n)&&n.forEach((s,o)=>Yc(e,o,s.default))}Ds.assignDefaults=H$;function Yc(e,t,r){const{gen:n,compositeRule:s,data:o,opts:a}=e;if(r===void 0)return;const i=(0,vr._)`${o}${(0,vr.getProperty)(t)}`;if(s){(0,F$.checkStrictMode)(e,`default is ignored for: ${i}`);return}let c=(0,vr._)`${i} === undefined`;a.useDefaults==="empty"&&(c=(0,vr._)`${c} || ${i} === null || ${i} === ""`),n.if(c,(0,vr._)`${i} = ${(0,vr.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,Ba=F,Ct=St,Z$=F;function K$(e,t){const{gen:r,data:n,it:s}=e;r.if(Qa(r,n,t,s.opts.ownProperties),()=>{e.setParams({missingProperty:(0,be._)`${t}`},!0),e.error()})}ue.checkReportMissingProp=K$;function G$({gen:e,data:t,it:{opts:r}},n,s){return(0,be.or)(...n.map(o=>(0,be.and)(Qa(e,t,o,r.ownProperties),(0,be._)`${s} = ${o}`)))}ue.checkMissingProp=G$;function W$(e,t){e.setParams({missingProperty:t},!0),e.error()}ue.reportMissingProp=W$;function Sd(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,be._)`Object.prototype.hasOwnProperty`})}ue.hasPropFunc=Sd;function Ja(e,t,r){return(0,be._)`${Sd(e)}.call(${t}, ${r})`}ue.isOwnProperty=Ja;function B$(e,t,r,n){const s=(0,be._)`${t}${(0,be.getProperty)(r)} !== undefined`;return n?(0,be._)`${s} && ${Ja(e,t,r)}`:s}ue.propertyInData=B$;function Qa(e,t,r,n){const s=(0,be._)`${t}${(0,be.getProperty)(r)} === undefined`;return n?(0,be.or)(s,(0,be.not)(Ja(e,t,r))):s}ue.noPropertyInData=Qa;function Ed(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}ue.allSchemaProperties=Ed;function J$(e,t){return Ed(t).filter(r=>!(0,Ba.alwaysValidSchema)(e,t[r]))}ue.schemaProperties=J$;function Q$({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=[[Ct.default.instancePath,(0,be.strConcat)(Ct.default.instancePath,o)],[Ct.default.parentData,a.parentData],[Ct.default.parentDataProperty,a.parentDataProperty],[Ct.default.rootData,Ct.default.rootData]];a.opts.dynamicRef&&f.push([Ct.default.dynamicAnchors,Ct.default.dynamicAnchors]);const g=(0,be._)`${d}, ${r.object(...f)}`;return c!==be.nil?(0,be._)`${i}.call(${c}, ${g})`:(0,be._)`${i}(${g})`}ue.callValidateCode=Q$;const Y$=(0,be._)`new RegExp`;function X$({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"?Y$:(0,Z$.useFunc)(e,s)}(${r}, ${n})`})}ue.usePattern=X$;function ew(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:Ba.Type.Num},o),t.if((0,be.not)(o),i)})}}ue.validateArray=ew;function tw(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,Ba.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=tw;Object.defineProperty(wt,"__esModule",{value:!0});wt.validateKeywordUsage=wt.validSchemaType=wt.funcKeywordCode=wt.macroKeywordCode=void 0;const Ge=fe,or=St,rw=ue,nw=jn;function sw(e,t){const{gen:r,keyword:n,schema:s,parentSchema:o,it:a}=e,i=t.macro.call(a.self,s,o,a),c=kd(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=sw;function ow(e,t){var r;const{gen:n,keyword:s,schema:o,parentSchema:a,$data:i,it:c}=e;iw(c,t);const l=!i&&t.compile?t.compile.call(c.self,o,a,c):t.validate,d=kd(n,s,l),f=n.let("valid");e.block$data(f,g),e.ok((r=t.valid)!==null&&r!==void 0?r:f);function g(){if(t.errors===!1)$(),t.modifying&&Xc(e),m(()=>e.error());else{const h=t.async?y():_();t.modifying&&Xc(e),m(()=>aw(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 _(){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?or.default.this:or.default.self,S=!("compile"in t&&!i||t.schema===!1);n.assign(f,(0,Ge._)`${h}${(0,rw.callValidateCode)(e,d,v,S)}`,t.modifying)}function m(h){var v;n.if((0,Ge.not)((v=t.valid)!==null&&v!==void 0?v:f),h)}}wt.funcKeywordCode=ow;function Xc(e){const{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,Ge._)`${n.parentData}[${n.parentDataProperty}]`))}function aw(e,t){const{gen:r}=e;r.if((0,Ge._)`Array.isArray(${t})`,()=>{r.assign(or.default.vErrors,(0,Ge._)`${or.default.vErrors} === null ? ${t} : ${or.default.vErrors}.concat(${t})`).assign(or.default.errors,(0,Ge._)`${or.default.vErrors}.length`),(0,nw.extendErrors)(e)},()=>e.error())}function iw({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function kd(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 cw(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=cw;function lw({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=lw;var Mt={};Object.defineProperty(Mt,"__esModule",{value:!0});Mt.extendSubschemaMode=Mt.extendSubschemaData=Mt.getSubschema=void 0;const vt=fe,Pd=F;function uw(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,Pd.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')}Mt.getSubschema=uw;function dw(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,g=i.let("data",(0,vt._)`${t.data}${(0,vt.getProperty)(r)}`,!0);c(g),e.errorPath=(0,vt.str)`${l}${(0,Pd.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]}}Mt.extendSubschemaData=dw;function fw(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}Mt.extendSubschemaMode=fw;var Ue={},Us=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},Td={exports:{}},At=Td.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(){};es(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 es(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 g=0;gt+=Rd(n)),t===1/0))return 1/0}return t}function Cd(e,t="",r){r!==!1&&(t=Ir(t));const n=e.parse(t);return Nd(e,n)}Ue.getFullPath=Cd;function Nd(e,t){return e.serialize(t).split("#")[0]+"#"}Ue._getFullPath=Nd;const ww=/#\/?$/;function Ir(e){return e?e.replace(ww,""):""}Ue.normalizeId=Ir;function bw(e,t,r){return r=Ir(r),e.resolve(t,r)}Ue.resolveUrl=bw;const Sw=/^[a-z_][-a-z0-9._]*$/i;function Ew(e,t){if(typeof e=="boolean")return{};const{schemaId:r,uriResolver:n}=this.opts,s=Ir(e[r]||t),o={"":s},a=Cd(n,s,!1),i={},c=new Set;return gw(e,{allKeys:!0},(f,g,y,_)=>{if(_===void 0)return;const $=a+g;let m=o[_];typeof f[r]=="string"&&(m=h.call(this,f[r])),v.call(this,f.$anchor),v.call(this,f.$dynamicAnchor),o[g]=m;function h(S){const R=this.opts.uriResolver.resolve;if(S=Ir(m?R(m,S):S),c.has(S))throw d(S);c.add(S);let P=this.refs[S];return typeof P=="string"&&(P=this.refs[P]),typeof P=="object"?l(f,P.schema,S):S!==Ir($)&&(S[0]==="#"?(l(f,i[S],S),i[S]=f):this.refs[S]=$),S}function v(S){if(typeof S=="string"){if(!Sw.test(S))throw new Error(`invalid anchor "${S}"`);h.call(this,`#${S}`)}}}),i;function l(f,g,y){if(g!==void 0&&!_w(f,g))throw d(y)}function d(f){return new Error(`reference "${f}" resolves to more than one schema`)}}Ue.getSchemaRefs=Ew;Object.defineProperty(mt,"__esModule",{value:!0});mt.getData=mt.KeywordCxt=mt.validateFunctionCode=void 0;const Id=zr,el=Oe,Ya=kt,ms=Oe,kw=Ds,on=wt,to=Mt,J=fe,ee=St,Pw=Ue,Pt=F,Jr=jn;function Tw(e){if(Ad(e)&&(zd(e),Od(e))){Nw(e);return}jd(e,()=>(0,Id.topBoolOrEmptySchema)(e))}mt.validateFunctionCode=Tw;function jd({gen:e,validateName:t,schema:r,schemaEnv:n,opts:s},o){s.code.es5?e.func(t,(0,J._)`${ee.default.data}, ${ee.default.valCxt}`,n.$async,()=>{e.code((0,J._)`"use strict"; ${tl(r,s)}`),Cw(e,s),e.code(o)}):e.func(t,(0,J._)`${ee.default.data}, ${Rw(s)}`,n.$async,()=>e.code(tl(r,s)).code(o))}function Rw(e){return(0,J._)`{${ee.default.instancePath}="", ${ee.default.parentData}, ${ee.default.parentDataProperty}, ${ee.default.rootData}=${ee.default.data}${e.dynamicRef?(0,J._)`, ${ee.default.dynamicAnchors}={}`:J.nil}}={}`}function Cw(e,t){e.if(ee.default.valCxt,()=>{e.var(ee.default.instancePath,(0,J._)`${ee.default.valCxt}.${ee.default.instancePath}`),e.var(ee.default.parentData,(0,J._)`${ee.default.valCxt}.${ee.default.parentData}`),e.var(ee.default.parentDataProperty,(0,J._)`${ee.default.valCxt}.${ee.default.parentDataProperty}`),e.var(ee.default.rootData,(0,J._)`${ee.default.valCxt}.${ee.default.rootData}`),t.dynamicRef&&e.var(ee.default.dynamicAnchors,(0,J._)`${ee.default.valCxt}.${ee.default.dynamicAnchors}`)},()=>{e.var(ee.default.instancePath,(0,J._)`""`),e.var(ee.default.parentData,(0,J._)`undefined`),e.var(ee.default.parentDataProperty,(0,J._)`undefined`),e.var(ee.default.rootData,ee.default.data),t.dynamicRef&&e.var(ee.default.dynamicAnchors,(0,J._)`{}`)})}function Nw(e){const{schema:t,opts:r,gen:n}=e;jd(e,()=>{r.$comment&&t.$comment&&xd(e),zw(e),n.let(ee.default.vErrors,null),n.let(ee.default.errors,0),r.unevaluated&&Iw(e),Md(e),qw(e)})}function Iw(e){const{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,J._)`${r}.evaluated`),t.if((0,J._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,J._)`${e.evaluated}.props`,(0,J._)`undefined`)),t.if((0,J._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,J._)`${e.evaluated}.items`,(0,J._)`undefined`))}function tl(e,t){const r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,J._)`/*# sourceURL=${r} */`:J.nil}function jw(e,t){if(Ad(e)&&(zd(e),Od(e))){Ow(e,t);return}(0,Id.boolOrEmptySchema)(e,t)}function Od({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 Ad(e){return typeof e.schema!="boolean"}function Ow(e,t){const{schema:r,gen:n,opts:s}=e;s.$comment&&r.$comment&&xd(e),Mw(e),xw(e);const o=n.const("_errs",ee.default.errors);Md(e,o),n.var(t,(0,J._)`${o} === ${ee.default.errors}`)}function zd(e){(0,Pt.checkUnknownRules)(e),Aw(e)}function Md(e,t){if(e.opts.jtd)return rl(e,[],!1,t);const r=(0,el.getSchemaTypes)(e.schema),n=(0,el.coerceAndCheckDataType)(e,r);rl(e,r,!n,t)}function Aw(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 zw(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 Mw(e){const t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,Pw.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function xw(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function xd({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:s}){const o=r.$comment;if(s.$comment===!0)e.code((0,J._)`${ee.default.self}.logger.log(${o})`);else if(typeof s.$comment=="function"){const a=(0,J.str)`${n}/$comment`,i=e.scopeValue("root",{ref:t.root});e.code((0,J._)`${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,J._)`${ee.default.errors} === 0`,()=>t.return(ee.default.data),()=>t.throw((0,J._)`new ${s}(${ee.default.vErrors})`)):(t.assign((0,J._)`${n}.errors`,ee.default.vErrors),o.unevaluated&&Dw(e),t.return((0,J._)`${ee.default.errors} === 0`))}function Dw({gen:e,evaluated:t,props:r,items:n}){r instanceof J.Name&&e.assign((0,J._)`${t}.props`,r),n instanceof J.Name&&e.assign((0,J._)`${t}.items`,n)}function rl(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(()=>Ud(e,"$ref",d.all.$ref.definition));return}c.jtd||Uw(e,t),s.block(()=>{for(const g of d.rules)f(g);f(d.post)});function f(g){(0,Ya.shouldUseGroup)(o,g)&&(g.type?(s.if((0,ms.checkDataType)(g.type,a,c.strictNumbers)),nl(e,g),t.length===1&&t[0]===g.type&&r&&(s.else(),(0,ms.reportTypeError)(e)),s.endIf()):nl(e,g),i||s.if((0,J._)`${ee.default.errors} === ${n||0}`))}}function nl(e,t){const{gen:r,schema:n,opts:{useDefaults:s}}=e;s&&(0,kw.assignDefaults)(e,t.type),r.block(()=>{for(const o of t.rules)(0,Ya.shouldUseRule)(n,o)&&Ud(e,o.keyword,o.definition,t.type)})}function Uw(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(Vw(e,t),e.opts.allowUnionTypes||Lw(e,t),Fw(e,e.dataTypes))}function Vw(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{qd(e.dataTypes,r)||Xa(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),Zw(e,t)}}function Lw(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&Xa(e,"use allowUnionTypes to allow union type keyword")}function Fw(e,t){const r=e.self.RULES.all;for(const n in r){const s=r[n];if(typeof s=="object"&&(0,Ya.shouldUseRule)(e.schema,s)){const{type:o}=s.definition;o.length&&!o.some(a=>Hw(t,a))&&Xa(e,`missing type "${o.join(",")}" for keyword "${n}"`)}}}function Hw(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function qd(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function Zw(e,t){const r=[];for(const n of e.dataTypes)qd(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function Xa(e,t){const r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,Pt.checkStrictMode)(e,t,e.opts.strictTypes)}let Dd=class{constructor(t,r,n){if((0,on.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",Vd(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,on.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,J.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,J.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,J._)`${r} !== undefined && (${(0,J.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?Jr.reportExtraError:Jr.reportError)(this,this.def.error,r)}$dataError(){(0,Jr.reportError)(this,this.def.$dataError||Jr.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Jr.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=J.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=J.nil,r=J.nil){if(!this.$data)return;const{gen:n,schemaCode:s,schemaType:o,def:a}=this;n.if((0,J.or)((0,J._)`${s} === undefined`,r)),t!==J.nil&&n.assign(t,!0),(o.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==J.nil&&n.assign(t,!1)),n.else()}invalid$data(){const{gen:t,schemaCode:r,schemaType:n,def:s,it:o}=this;return(0,J.or)(a(),i());function a(){if(n.length){if(!(r instanceof J.Name))throw new Error("ajv implementation error");const c=Array.isArray(n)?n:[n];return(0,J._)`${(0,ms.checkDataTypes)(c,r,o.opts.strictNumbers,ms.DataType.Wrong)}`}return J.nil}function i(){if(s.validateSchema){const c=t.scopeValue("validate$data",{ref:s.validateSchema});return(0,J._)`!${c}(${r})`}return J.nil}}subschema(t,r){const n=(0,to.getSubschema)(this.it,t);(0,to.extendSubschemaData)(n,this.it,t),(0,to.extendSubschemaMode)(n,t);const s={...this.it,...n,items:void 0,props:void 0};return jw(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,J.Name)),!0}};mt.KeywordCxt=Dd;function Ud(e,t,r,n){const s=new Dd(e,r,t);"code"in r?r.code(s,n):s.$data&&r.validate?(0,on.funcKeywordCode)(s,r):"macro"in r?(0,on.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0,on.funcKeywordCode)(s,r)}const Kw=/^\/(?:[^~]|~0|~1)*$/,Gw=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Vd(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let s,o;if(e==="")return ee.default.rootData;if(e[0]==="/"){if(!Kw.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);s=e,o=ee.default.rootData}else{const l=Gw.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,J._)`${o}${(0,J.getProperty)((0,Pt.unescapeJsonPointer)(l))}`,a=(0,J._)`${a} && ${o}`);return a;function c(l,d){return`Cannot access ${l} ${d} levels up, current level is ${t}`}}mt.getData=Vd;var On={};Object.defineProperty(On,"__esModule",{value:!0});let Ww=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};On.default=Ww;var Vr={};Object.defineProperty(Vr,"__esModule",{value:!0});const ro=Ue;let Bw=class extends Error{constructor(t,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,ro.resolveUrl)(t,r,n),this.missingSchema=(0,ro.normalizeId)((0,ro.getFullPath)(t,this.missingRef))}};Vr.default=Bw;var Qe={};Object.defineProperty(Qe,"__esModule",{value:!0});Qe.resolveSchema=Qe.getCompilingSchema=Qe.resolveRef=Qe.compileSchema=Qe.SchemaEnv=void 0;const lt=fe,Jw=On,tr=St,ht=Ue,sl=F,Qw=mt;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,ht.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 ei(e){const t=Ld.call(this,e);if(t)return t;const r=(0,ht.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:Jw.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:tr.default.data,parentData:tr.default.parentData,parentDataProperty:tr.default.parentDataProperty,dataNames:[tr.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,Qw.validateFunctionCode)(l),a.optimize(this.opts.code.optimize);const f=a.toString();d=`${a.scopeRefs(tr.default.scope)}return ${f}`,this.opts.code.process&&(d=this.opts.code.process(d,e));const y=new Function(`${tr.default.self}`,`${tr.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:_,items:$}=l;y.evaluated={props:_ instanceof lt.Name?void 0:_,items:$ instanceof lt.Name?void 0:$,dynamicProps:_ 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=ei;function Yw(e,t,r){var n;r=(0,ht.resolveUrl)(this.opts.uriResolver,t,r);const s=e.refs[r];if(s)return s;let o=t0.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]=Xw.call(this,o)}Qe.resolveRef=Yw;function Xw(e){return(0,ht.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:ei.call(this,e)}function Ld(e){for(const t of this._compilations)if(e0(t,e))return t}Qe.getCompilingSchema=Ld;function e0(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function t0(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||Ls.call(this,e,t)}function Ls(e,t){const r=this.opts.uriResolver.parse(t),n=(0,ht._getFullPath)(this.opts.uriResolver,r);let s=(0,ht.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===s)return no.call(this,r,e);const o=(0,ht.normalizeId)(n),a=this.refs[o]||this.schemas[o];if(typeof a=="string"){const i=Ls.call(this,e,a);return typeof(i==null?void 0:i.schema)!="object"?void 0:no.call(this,r,i)}if(typeof(a==null?void 0:a.schema)=="object"){if(a.validate||ei.call(this,a),o===(0,ht.normalizeId)(t)){const{schema:i}=a,{schemaId:c}=this.opts,l=i[c];return l&&(s=(0,ht.resolveUrl)(this.opts.uriResolver,s,l)),new Vs({schema:i,schemaId:c,root:e,baseId:s})}return no.call(this,r,a)}}Qe.resolveSchema=Ls;const r0=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function no(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,sl.unescapeFragment)(i)];if(c===void 0)return;r=c;const l=typeof r=="object"&&r[this.opts.schemaId];!r0.has(i)&&l&&(t=(0,ht.resolveUrl)(this.opts.uriResolver,t,l))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,sl.schemaHasRulesButRef)(r,this.RULES)){const i=(0,ht.resolveUrl)(this.opts.uriResolver,t,r.$ref);o=Ls.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 n0="https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",s0="Meta-schema for $data reference (JSON AnySchema extension proposal)",o0="object",a0=["$data"],i0={$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},c0=!1,l0={$id:n0,description:s0,type:o0,required:a0,properties:i0,additionalProperties:c0};var ti={},Fs={exports:{}};const u0=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),Fd=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),ri=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),Hd=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),d0=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function Zd(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 f0=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function ol(e){return e.length=0,!0}function h0(e,t,r){if(e.length){const n=Zd(e);if(n!=="")t.push(n);else return r.error=!0,!1;e.length=0}return!0}function p0(e){let t=0;const r={error:!1,address:"",zone:""},n=[],s=[];let o=!1,a=!1,i=h0;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=ol}else{s.push(l);continue}}return s.length&&(i===ol?r.zone=s.join(""):a?n.push(s.join("")):n.push(Zd(s))),r.address=n.join(""),r}function Kd(e){if(m0(e,":")<2)return{host:e,isIPV6:!1};const t=p0(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 m0(e,t){let r=0;for(let n=0;ng0[n])}function $0(e,t=!1){if(e.indexOf("%")===-1)return e;let r="";for(let n=0;n65535))return"URI port is malformed."}function gs(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(J0);a!==null&&a[1].indexOf("\\")!==-1&&(n.error="URI authority must not contain a literal backslash.",s=!0);const i=e.match(Q0);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(B0);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=Y0(n,c);if(l!==void 0&&(n.error=n.error||l,s=!0),n.host)if(F0(n.host)===!1){const g=x0(n.host);n.host=g.host.toLowerCase(),o=g.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=Xd(r.scheme||n.scheme);if(!r.unicodeSupport&&(!d||!d.unicodeSupport)&&n.host&&(r.domainHost||d&&d.domainHost)&&o===!1&&H0(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=L0(unescape(n.host),o))),n.path&&(n.path=U0(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 ys(e,t){return gs(e,t).parsed}function X0(e,t){return tf(e,t).normalized}function tf(e,t){const{parsed:r,malformedAuthorityOrPort:n}=gs(e,t);return{normalized:n?e:pr(r,t),malformedAuthorityOrPort:n}}function al(e,t){if(typeof e=="string"){const{normalized:r,malformedAuthorityOrPort:n}=tf(e,t);return n?void 0:r}if(typeof e=="object")return pr(e,t)}const si={SCHEMES:Z0,normalize:K0,resolve:G0,resolveComponent:ef,equal:W0,serialize:pr,parse:ys};Fs.exports=si;Fs.exports.default=si;Fs.exports.fastUri=si;var rf=Fs.exports;Object.defineProperty(ti,"__esModule",{value:!0});const nf=rf;nf.code='require("ajv/dist/runtime/uri").default';ti.default=nf;(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=mt;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=On,s=Vr,o=hr,a=Qe,i=fe,c=Ue,l=Oe,d=F,f=l0,g=ti,y=(j,w)=>new RegExp(j,w);y.code="new RegExp";const _=["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 S(j){var w,C,b,u,p,E,M,x,B,K,he,et,Ut,Vt,Lt,Ft,Ht,Zt,Kt,Gt,Wt,Bt,Jt,Qt,Yt;const ct=j.strict,Xt=(w=j.code)===null||w===void 0?void 0:w.optimize,Gr=Xt===!0||Xt===void 0?1:Xt||0,Wr=(b=(C=j.code)===null||C===void 0?void 0:C.regExp)!==null&&b!==void 0?b:y,Qs=(u=j.uriResolver)!==null&&u!==void 0?u:g.default;return{strictSchema:(E=(p=j.strictSchema)!==null&&p!==void 0?p:ct)!==null&&E!==void 0?E:!0,strictNumbers:(x=(M=j.strictNumbers)!==null&&M!==void 0?M:ct)!==null&&x!==void 0?x:!0,strictTypes:(K=(B=j.strictTypes)!==null&&B!==void 0?B:ct)!==null&&K!==void 0?K:"log",strictTuples:(et=(he=j.strictTuples)!==null&&he!==void 0?he:ct)!==null&&et!==void 0?et:"log",strictRequired:(Vt=(Ut=j.strictRequired)!==null&&Ut!==void 0?Ut:ct)!==null&&Vt!==void 0?Vt:!1,code:j.code?{...j.code,optimize:Gr,regExp:Wr}:{optimize:Gr,regExp:Wr},loopRequired:(Lt=j.loopRequired)!==null&&Lt!==void 0?Lt:v,loopEnum:(Ft=j.loopEnum)!==null&&Ft!==void 0?Ft:v,meta:(Ht=j.meta)!==null&&Ht!==void 0?Ht:!0,messages:(Zt=j.messages)!==null&&Zt!==void 0?Zt:!0,inlineRefs:(Kt=j.inlineRefs)!==null&&Kt!==void 0?Kt:!0,schemaId:(Gt=j.schemaId)!==null&&Gt!==void 0?Gt:"$id",addUsedSchema:(Wt=j.addUsedSchema)!==null&&Wt!==void 0?Wt:!0,validateSchema:(Bt=j.validateSchema)!==null&&Bt!==void 0?Bt:!0,validateFormats:(Jt=j.validateFormats)!==null&&Jt!==void 0?Jt:!0,unicodeRegExp:(Qt=j.unicodeRegExp)!==null&&Qt!==void 0?Qt:!0,int32range:(Yt=j.int32range)!==null&&Yt!==void 0?Yt:!0,uriResolver:Qs}}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,...S(w)};const{es5:C,lines:b}=this.opts.code;this.scope=new i.ValueScope({scope:{},prefixes:$,es5:C,lines:b}),this.logger=W(w.logger);const u=w.validateFormats;w.validateFormats=!1,this.RULES=(0,o.getRules)(),P.call(this,m,w,"NOT SUPPORTED"),P.call(this,h,w,"DEPRECATED","warn"),this._metaOpts=V.call(this),w.formats&&U.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),w.keywords&&Z.call(this,w.keywords),typeof w.meta=="object"&&this.addMetaSchema(w.meta),A.call(this),w.validateFormats=u}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:w,meta:C,schemaId:b}=this.opts;let u=f;b==="id"&&(u={...f},u.id=u.$id,delete u.$id),C&&w&&this.addMetaSchema(u,u[b],!1)}defaultMeta(){const{meta:w,schemaId:C}=this.opts;return this.opts.defaultMeta=typeof w=="object"?w[C]||w:void 0}validate(w,C){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(C);return"$async"in b||(this.errors=b.errors),u}compile(w,C){const b=this._addSchema(w,C);return b.validate||this._compileSchemaEnv(b)}compileAsync(w,C){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,C);async function u(K,he){await p.call(this,K.$schema);const et=this._addSchema(K,he);return et.validate||E.call(this,et)}async function p(K){K&&!this.getSchema(K)&&await u.call(this,{$ref:K},!0)}async function E(K){try{return this._compileSchemaEnv(K)}catch(he){if(!(he instanceof s.default))throw he;return M.call(this,he),await x.call(this,he.missingSchema),E.call(this,K)}}function M({missingSchema:K,missingRef:he}){if(this.refs[K])throw new Error(`AnySchema ${K} is loaded but ${he} cannot be resolved`)}async function x(K){const he=await B.call(this,K);this.refs[K]||await p.call(this,he.$schema),this.refs[K]||this.addSchema(he,K,C)}async function B(K){const he=this._loading[K];if(he)return he;try{return await(this._loading[K]=b(K))}finally{delete this._loading[K]}}}addSchema(w,C,b,u=this.opts.validateSchema){if(Array.isArray(w)){for(const E of w)this.addSchema(E,void 0,b,u);return this}let p;if(typeof w=="object"){const{schemaId:E}=this.opts;if(p=w[E],p!==void 0&&typeof p!="string")throw new Error(`schema ${E} must be string`)}return C=(0,c.normalizeId)(C||p),this._checkUnique(C),this.schemas[C]=this._addSchema(w,b,C,u,!0),this}addMetaSchema(w,C,b=this.opts.validateSchema){return this.addSchema(w,C,!0,b),this}validateSchema(w,C){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&&C){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 C;for(;typeof(C=I.call(this,w))=="string";)w=C;if(C===void 0){const{schemaId:b}=this.opts,u=new a.SchemaEnv({schema:{},schemaId:b});if(C=a.resolveSchema.call(this,u,w),!C)return;this.refs[w]=C}return C.validate||this._compileSchemaEnv(C)}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 C=I.call(this,w);return typeof C=="object"&&this._cache.delete(C.schema),delete this.schemas[w],delete this.refs[w],this}case"object":{const C=w;this._cache.delete(C);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 C of w)this.addKeyword(C);return this}addKeyword(w,C){let b;if(typeof w=="string")b=w,typeof C=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),C.keyword=b);else if(typeof w=="object"&&C===void 0){if(C=w,b=C.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(q.call(this,b,C),!C)return(0,d.eachItem)(b,p=>le.call(this,p)),this;ge.call(this,C);const u={...C,type:(0,l.getJSONTypes)(C.type),schemaType:(0,l.getJSONTypes)(C.schemaType)};return(0,d.eachItem)(b,u.type.length===0?p=>le.call(this,p,u):p=>u.type.forEach(E=>le.call(this,p,u,E))),this}getKeyword(w){const C=this.RULES.all[w];return typeof C=="object"?C.definition:!!C}removeKeyword(w){const{RULES:C}=this;delete C.keywords[w],delete C.all[w];for(const b of C.rules){const u=b.rules.findIndex(p=>p.keyword===w);u>=0&&b.rules.splice(u,1)}return this}addFormat(w,C){return typeof C=="string"&&(C=new RegExp(C)),this.formats[w]=C,this}errorsText(w=this.errors,{separator:C=", ",dataVar:b="data"}={}){return!w||w.length===0?"No errors":w.map(u=>`${b}${u.instancePath} ${u.message}`).reduce((u,p)=>u+C+p)}$dataMetaSchema(w,C){const b=this.RULES.all;w=JSON.parse(JSON.stringify(w));for(const u of C){const p=u.split("/").slice(1);let E=w;for(const M of p)E=E[M];for(const M in b){const x=b[M];if(typeof x!="object")continue;const{$data:B}=x.definition,K=E[M];B&&K&&(E[M]=je(K))}}return w}_removeAllSchemas(w,C){for(const b in w){const u=w[b];(!C||C.test(b))&&(typeof u=="string"?delete w[b]:u&&!u.meta&&(this._cache.delete(u.schema),delete w[b]))}}_addSchema(w,C,b,u=this.opts.validateSchema,p=this.opts.addUsedSchema){let E;const{schemaId:M}=this.opts;if(typeof w=="object")E=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 x=this._cache.get(w);if(x!==void 0)return x;b=(0,c.normalizeId)(E||b);const B=c.getSchemaRefs.call(this,w,b);return x=new a.SchemaEnv({schema:w,schemaId:M,meta:C,baseId:b,localRefs:B}),this._cache.set(x.schema,x),p&&!b.startsWith("#")&&(b&&this._checkUnique(b),this.refs[b]=x),u&&this.validateSchema(w,!0),x}_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 C=this.opts;this.opts=this._metaOpts;try{a.compileSchema.call(this,w)}finally{this.opts=C}}}R.ValidationError=n.default,R.MissingRefError=s.default,e.default=R;function P(j,w,C,b="error"){for(const u in j){const p=u;p in w&&this.logger[b](`${C}: option ${u}. ${j[p]}`)}}function I(j){return j=(0,c.normalizeId)(j),this.schemas[j]||this.refs[j]}function A(){const j=this.opts.schemas;if(j)if(Array.isArray(j))this.addSchema(j);else for(const w in j)this.addSchema(j[w],w)}function U(){for(const j in this.opts.formats){const w=this.opts.formats[j];w&&this.addFormat(j,w)}}function Z(j){if(Array.isArray(j)){this.addVocabulary(j);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const w in j){const C=j[w];C.keyword||(C.keyword=w),this.addKeyword(C)}}function V(){const j={...this.opts};for(const w of _)delete j[w];return j}const L={log(){},warn(){},error(){}};function W(j){if(j===!1)return L;if(j===void 0)return console;if(j.log&&j.warn&&j.error)return j;throw new Error("logger must implement log, warn and error methods")}const ce=/^[a-z_$][a-z0-9_$:-]*$/i;function q(j,w){const{RULES:C}=this;if((0,d.eachItem)(j,b=>{if(C.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(j,w,C){var b;const u=w==null?void 0:w.post;if(C&&u)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:p}=this;let E=u?p.post:p.rules.find(({type:x})=>x===C);if(E||(E={type:C,rules:[]},p.rules.push(E)),p.keywords[j]=!0,!w)return;const M={keyword:j,definition:{...w,type:(0,l.getJSONTypes)(w.type),schemaType:(0,l.getJSONTypes)(w.schemaType)}};w.before?Ce.call(this,E,M,w.before):E.rules.push(M),p.all[j]=M,(b=w.implements)===null||b===void 0||b.forEach(x=>this.addKeyword(x))}function Ce(j,w,C){const b=j.rules.findIndex(u=>u.keyword===C);b>=0?j.rules.splice(b,0,w):(j.rules.push(w),this.logger.warn(`rule ${C} is not defined`))}function ge(j){let{metaSchema:w}=j;w!==void 0&&(j.$data&&this.opts.$data&&(w=je(w)),j.validateSchema=this.compile(w,!0))}const it={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function je(j){return{anyOf:[j,it]}}})(dd);var oi={},ai={},ii={};Object.defineProperty(ii,"__esModule",{value:!0});const eb={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};ii.default=eb;var mr={};Object.defineProperty(mr,"__esModule",{value:!0});mr.callRef=mr.getValidate=void 0;const tb=Vr,il=ue,Be=fe,$r=St,cl=Qe,Ln=F,rb={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=cl.resolveRef.call(c,l,s,r);if(d===void 0)throw new tb.default(n.opts.uriResolver,s,r);if(d instanceof cl.SchemaEnv)return g(d);return y(d);function f(){if(o===l)return rs(e,a,o,o.$async);const _=t.scopeValue("root",{ref:l});return rs(e,(0,Be._)`${_}.validate`,l,l.$async)}function g(_){const $=sf(e,_);rs(e,$,_,_.$async)}function y(_){const $=t.scopeValue("schema",i.code.source===!0?{ref:_,code:(0,Be.stringify)(_)}:{ref:_}),m=t.name("valid"),h=e.subschema({schema:_,dataTypes:[],schemaPath:Be.nil,topSchemaRef:$,errSchemaPath:r},m);e.mergeEvaluated(h),e.ok(m)}}};function sf(e,t){const{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,Be._)`${r.scopeValue("wrapper",{ref:t})}.validate`}mr.getValidate=sf;function rs(e,t,r,n){const{gen:s,it:o}=e,{allErrors:a,schemaEnv:i,opts:c}=o,l=c.passContext?$r.default.this:Be.nil;n?d():f();function d(){if(!i.$async)throw new Error("async schema referenced by sync schema");const _=s.let("valid");s.try(()=>{s.code((0,Be._)`await ${(0,il.callValidateCode)(e,t,l)}`),y(t),a||s.assign(_,!0)},$=>{s.if((0,Be._)`!(${$} instanceof ${o.ValidationError})`,()=>s.throw($)),g($),a||s.assign(_,!1)}),e.ok(_)}function f(){e.result((0,il.callValidateCode)(e,t,l),()=>y(t),()=>g(t))}function g(_){const $=(0,Be._)`${_}.errors`;s.assign($r.default.vErrors,(0,Be._)`${$r.default.vErrors} === null ? ${$} : ${$r.default.vErrors}.concat(${$})`),s.assign($r.default.errors,(0,Be._)`${$r.default.vErrors}.length`)}function y(_){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=Ln.mergeEvaluated.props(s,m.props,o.props));else{const h=s.var("props",(0,Be._)`${_}.evaluated.props`);o.props=Ln.mergeEvaluated.props(s,h,o.props,Be.Name)}if(o.items!==!0)if(m&&!m.dynamicItems)m.items!==void 0&&(o.items=Ln.mergeEvaluated.items(s,m.items,o.items));else{const h=s.var("items",(0,Be._)`${_}.evaluated.items`);o.items=Ln.mergeEvaluated.items(s,h,o.items,Be.Name)}}}mr.callRef=rs;mr.default=rb;Object.defineProperty(ai,"__esModule",{value:!0});const nb=ii,sb=mr,ob=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",nb.default,sb.default];ai.default=ob;var ci={},li={};Object.defineProperty(li,"__esModule",{value:!0});const vs=fe,Nt=vs.operators,$s={maximum:{okStr:"<=",ok:Nt.LTE,fail:Nt.GT},minimum:{okStr:">=",ok:Nt.GTE,fail:Nt.LT},exclusiveMaximum:{okStr:"<",ok:Nt.LT,fail:Nt.GTE},exclusiveMinimum:{okStr:">",ok:Nt.GT,fail:Nt.LTE}},ab={message:({keyword:e,schemaCode:t})=>(0,vs.str)`must be ${$s[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,vs._)`{comparison: ${$s[e].okStr}, limit: ${t}}`},ib={keyword:Object.keys($s),type:"number",schemaType:"number",$data:!0,error:ab,code(e){const{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,vs._)`${r} ${$s[t].fail} ${n} || isNaN(${r})`)}};li.default=ib;var ui={};Object.defineProperty(ui,"__esModule",{value:!0});const an=fe,cb={message:({schemaCode:e})=>(0,an.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,an._)`{multipleOf: ${e}}`},lb={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:cb,code(e){const{gen:t,data:r,schemaCode:n,it:s}=e,o=s.opts.multipleOfPrecision,a=t.let("res"),i=o?(0,an._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${o}`:(0,an._)`${a} !== parseInt(${a})`;e.fail$data((0,an._)`(${n} === 0 || (${a} = ${r}/${n}, ${i}))`)}};ui.default=lb;var di={},fi={};Object.defineProperty(fi,"__esModule",{value:!0});function of(e){const t=e.length;let r=0,n=0,s;for(;n=55296&&s<=56319&&n(0,ar._)`{limit: ${e}}`},hb={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:fb,code(e){const{keyword:t,data:r,schemaCode:n,it:s}=e,o=t==="maxLength"?ar.operators.GT:ar.operators.LT,a=s.opts.unicode===!1?(0,ar._)`${r}.length`:(0,ar._)`${(0,ub.useFunc)(e.gen,db.default)}(${r})`;e.fail$data((0,ar._)`${a} ${o} ${n}`)}};di.default=hb;var hi={};Object.defineProperty(hi,"__esModule",{value:!0});const pb=ue,mb=F,Rr=fe,_b={message:({schemaCode:e})=>(0,Rr.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Rr._)`{pattern: ${e}}`},gb={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:_b,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,Rr._)`new RegExp`:(0,mb.useFunc)(t,c),d=t.let("valid");t.try(()=>t.assign(d,(0,Rr._)`${l}(${o}, ${i}).test(${r})`),()=>t.assign(d,!1)),e.fail$data((0,Rr._)`!${d}`)}else{const c=(0,pb.usePattern)(e,s);e.fail$data((0,Rr._)`!${c}.test(${r})`)}}};hi.default=gb;var pi={};Object.defineProperty(pi,"__esModule",{value:!0});const cn=fe,yb={message({keyword:e,schemaCode:t}){const r=e==="maxProperties"?"more":"fewer";return(0,cn.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,cn._)`{limit: ${e}}`},vb={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:yb,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxProperties"?cn.operators.GT:cn.operators.LT;e.fail$data((0,cn._)`Object.keys(${r}).length ${s} ${n}`)}};pi.default=vb;var mi={};Object.defineProperty(mi,"__esModule",{value:!0});const Qr=ue,ln=fe,$b=F,wb={message:({params:{missingProperty:e}})=>(0,ln.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,ln._)`{missingProperty: ${e}}`},bb={keyword:"required",type:"object",schemaType:"array",$data:!0,error:wb,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:_}=e.it;for(const $ of r)if((y==null?void 0:y[$])===void 0&&!_.has($)){const m=a.schemaEnv.baseId+a.errSchemaPath,h=`required property "${$}" is not defined at "${m}" (strictRequired)`;(0,$b.checkStrictMode)(a,h,a.opts.strictRequired)}}function l(){if(c||o)e.block$data(ln.nil,f);else for(const y of r)(0,Qr.checkReportMissingProp)(e,y)}function d(){const y=t.let("missing");if(c||o){const _=t.let("valid",!0);e.block$data(_,()=>g(y,_)),e.ok(_)}else t.if((0,Qr.checkMissingProp)(e,r,y)),(0,Qr.reportMissingProp)(e,y),t.else()}function f(){t.forOf("prop",n,y=>{e.setParams({missingProperty:y}),t.if((0,Qr.noPropertyInData)(t,s,y,i.ownProperties),()=>e.error())})}function g(y,_){e.setParams({missingProperty:y}),t.forOf(y,n,()=>{t.assign(_,(0,Qr.propertyInData)(t,s,y,i.ownProperties)),t.if((0,ln.not)(_),()=>{e.error(),t.break()})},ln.nil)}}};mi.default=bb;var _i={};Object.defineProperty(_i,"__esModule",{value:!0});const un=fe,Sb={message({keyword:e,schemaCode:t}){const r=e==="maxItems"?"more":"fewer";return(0,un.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,un._)`{limit: ${e}}`},Eb={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:Sb,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxItems"?un.operators.GT:un.operators.LT;e.fail$data((0,un._)`${r}.length ${s} ${n}`)}};_i.default=Eb;var gi={},An={};Object.defineProperty(An,"__esModule",{value:!0});const af=Us;af.code='require("ajv/dist/runtime/equal").default';An.default=af;Object.defineProperty(gi,"__esModule",{value:!0});const so=Oe,xe=fe,kb=F,Pb=An,Tb={message:({params:{i:e,j:t}})=>(0,xe.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,xe._)`{i: ${e}, j: ${t}}`},Rb={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:Tb,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,so.getSchemaTypes)(o.items):[];e.block$data(c,d,(0,xe._)`${a} === false`),e.ok(c);function d(){const _=t.let("i",(0,xe._)`${r}.length`),$=t.let("j");e.setParams({i:_,j:$}),t.assign(c,!0),t.if((0,xe._)`${_} > 1`,()=>(f()?g:y)(_,$))}function f(){return l.length>0&&!l.some(_=>_==="object"||_==="array")}function g(_,$){const m=t.name("item"),h=(0,so.checkDataTypes)(l,m,i.opts.strictNumbers,so.DataType.Wrong),v=t.const("indices",(0,xe._)`{}`);t.for((0,xe._)`;${_}--;`,()=>{t.let(m,(0,xe._)`${r}[${_}]`),t.if(h,(0,xe._)`continue`),l.length>1&&t.if((0,xe._)`typeof ${m} == "string"`,(0,xe._)`${m} += "_"`),t.if((0,xe._)`typeof ${v}[${m}] == "number"`,()=>{t.assign($,(0,xe._)`${v}[${m}]`),e.error(),t.assign(c,!1).break()}).code((0,xe._)`${v}[${m}] = ${_}`)})}function y(_,$){const m=(0,kb.useFunc)(t,Pb.default),h=t.name("outer");t.label(h).for((0,xe._)`;${_}--;`,()=>t.for((0,xe._)`${$} = ${_}; ${$}--;`,()=>t.if((0,xe._)`${m}(${r}[${_}], ${r}[${$}])`,()=>{e.error(),t.assign(c,!1).break(h)})))}}};gi.default=Rb;var yi={};Object.defineProperty(yi,"__esModule",{value:!0});const Io=fe,Cb=F,Nb=An,Ib={message:"must be equal to constant",params:({schemaCode:e})=>(0,Io._)`{allowedValue: ${e}}`},jb={keyword:"const",$data:!0,error:Ib,code(e){const{gen:t,data:r,$data:n,schemaCode:s,schema:o}=e;n||o&&typeof o=="object"?e.fail$data((0,Io._)`!${(0,Cb.useFunc)(t,Nb.default)}(${r}, ${s})`):e.fail((0,Io._)`${o} !== ${r}`)}};yi.default=jb;var vi={};Object.defineProperty(vi,"__esModule",{value:!0});const rn=fe,Ob=F,Ab=An,zb={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,rn._)`{allowedValues: ${e}}`},Mb={keyword:"enum",schemaType:"array",$data:!0,error:zb,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,Ob.useFunc)(t,Ab.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,rn.or)(...s.map((_,$)=>g(y,$)))}e.pass(d);function f(){t.assign(d,!1),t.forOf("v",o,y=>t.if((0,rn._)`${l()}(${r}, ${y})`,()=>t.assign(d,!0).break()))}function g(y,_){const $=s[_];return typeof $=="object"&&$!==null?(0,rn._)`${l()}(${r}, ${y}[${_}])`:(0,rn._)`${r} === ${$}`}}};vi.default=Mb;Object.defineProperty(ci,"__esModule",{value:!0});const xb=li,qb=ui,Db=di,Ub=hi,Vb=pi,Lb=mi,Fb=_i,Hb=gi,Zb=yi,Kb=vi,Gb=[xb.default,qb.default,Db.default,Ub.default,Vb.default,Lb.default,Fb.default,Hb.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},Zb.default,Kb.default];ci.default=Gb;var $i={},Lr={};Object.defineProperty(Lr,"__esModule",{value:!0});Lr.validateAdditionalItems=void 0;const ir=fe,jo=F,Wb={message:({params:{len:e}})=>(0,ir.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,ir._)`{limit: ${e}}`},Bb={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:Wb,code(e){const{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,jo.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}cf(e,n)}};function cf(e,t){const{gen:r,schema:n,data:s,keyword:o,it:a}=e;a.items=!0;const i=r.const("len",(0,ir._)`${s}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,ir._)`${i} <= ${t.length}`);else if(typeof n=="object"&&!(0,jo.alwaysValidSchema)(a,n)){const l=r.var("valid",(0,ir._)`${i} <= ${t.length}`);r.if((0,ir.not)(l),()=>c(l)),e.ok(l)}function c(l){r.forRange("i",t.length,i,d=>{e.subschema({keyword:o,dataProp:d,dataPropType:jo.Type.Num},l),a.allErrors||r.if((0,ir.not)(l),()=>r.break())})}}Lr.validateAdditionalItems=cf;Lr.default=Bb;var wi={},Fr={};Object.defineProperty(Fr,"__esModule",{value:!0});Fr.validateTuple=void 0;const ll=fe,ns=F,Jb=ue,Qb={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:t,it:r}=e;if(Array.isArray(t))return lf(e,"additionalItems",t);r.items=!0,!(0,ns.alwaysValidSchema)(r,t)&&e.ok((0,Jb.validateArray)(e))}};function lf(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=ns.mergeEvaluated.items(n,r.length,i.items));const c=n.name("valid"),l=n.const("len",(0,ll._)`${o}.length`);r.forEach((f,g)=>{(0,ns.alwaysValidSchema)(i,f)||(n.if((0,ll._)`${l} > ${g}`,()=>e.subschema({keyword:a,schemaProp:g,dataProp:g},c)),e.ok(c))});function d(f){const{opts:g,errSchemaPath:y}=i,_=r.length,$=_===f.minItems&&(_===f.maxItems||f[t]===!1);if(g.strictTuples&&!$){const m=`"${a}" is ${_}-tuple, but minItems or maxItems/${t} are not specified or different at path "${y}"`;(0,ns.checkStrictMode)(i,m,g.strictTuples)}}}Fr.validateTuple=lf;Fr.default=Qb;Object.defineProperty(wi,"__esModule",{value:!0});const Yb=Fr,Xb={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,Yb.validateTuple)(e,"items")};wi.default=Xb;var bi={};Object.defineProperty(bi,"__esModule",{value:!0});const ul=fe,eS=F,tS=ue,rS=Lr,nS={message:({params:{len:e}})=>(0,ul.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,ul._)`{limit: ${e}}`},sS={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:nS,code(e){const{schema:t,parentSchema:r,it:n}=e,{prefixItems:s}=r;n.items=!0,!(0,eS.alwaysValidSchema)(n,t)&&(s?(0,rS.validateAdditionalItems)(e,s):e.ok((0,tS.validateArray)(e)))}};bi.default=sS;var Si={};Object.defineProperty(Si,"__esModule",{value:!0});const nt=fe,Fn=F,oS={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}}`},aS={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:oS,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,Fn.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(i!==void 0&&a>i){(0,Fn.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,Fn.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`,g)):(t.let(f,!1),g()),e.result(f,()=>e.reset());function g(){const $=t.name("_valid"),m=t.let("count",0);y($,()=>t.if($,()=>_(m)))}function y($,m){t.forRange("i",0,d,h=>{e.subschema({keyword:"contains",dataProp:h,dataPropType:Fn.Type.Num,compositeRule:!0},$),m()})}function _($){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)))}}};Si.default=aS;var uf={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;const t=fe,r=F,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 g=Array.isArray(c[f])?l:d;g[f]=c[f]}return[l,d]}function a(c,l=c.schema){const{gen:d,data:f,it:g}=c;if(Object.keys(l).length===0)return;const y=d.let("missing");for(const _ in l){const $=l[_];if($.length===0)continue;const m=(0,n.propertyInData)(d,f,_,g.opts.ownProperties);c.setParams({property:_,depsCount:$.length,deps:$.join(", ")}),g.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:g,it:y}=c,_=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:g,schemaProp:$},_);c.mergeValidEvaluated(m,_)},()=>d.var(_,!0)),c.ok(_))}e.validateSchemaDeps=i,e.default=s})(uf);var Ei={};Object.defineProperty(Ei,"__esModule",{value:!0});const df=fe,iS=F,cS={message:"property name must be valid",params:({params:e})=>(0,df._)`{propertyName: ${e.propertyName}}`},lS={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:cS,code(e){const{gen:t,schema:r,data:n,it:s}=e;if((0,iS.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,df.not)(o),()=>{e.error(!0),s.allErrors||t.break()})}),e.ok(o)}};Ei.default=lS;var Hs={};Object.defineProperty(Hs,"__esModule",{value:!0});const Hn=ue,dt=fe,uS=St,Zn=F,dS={message:"must NOT have additional properties",params:({params:e})=>(0,dt._)`{additionalProperty: ${e.additionalProperty}}`},fS={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:dS,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,Zn.alwaysValidSchema)(a,r))return;const l=(0,Hn.allSchemaProperties)(n.properties),d=(0,Hn.allSchemaProperties)(n.patternProperties);f(),e.ok((0,dt._)`${o} === ${uS.default.errors}`);function f(){t.forIn("key",s,m=>{!l.length&&!d.length?_(m):t.if(g(m),()=>_(m))})}function g(m){let h;if(l.length>8){const v=(0,Zn.schemaRefOrVal)(a,n.properties,"properties");h=(0,Hn.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,Hn.usePattern)(e,v)}.test(${m})`))),(0,dt.not)(h)}function y(m){t.code((0,dt._)`delete ${s}[${m}]`)}function _(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,Zn.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 S={keyword:"additionalProperties",dataProp:m,dataPropType:Zn.Type.Str};v===!1&&Object.assign(S,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(S,h)}}};Hs.default=fS;var ki={};Object.defineProperty(ki,"__esModule",{value:!0});const hS=mt,dl=ue,oo=F,fl=Hs,pS={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 hS.KeywordCxt(o,fl.default,"additionalProperties"));const a=(0,dl.allSchemaProperties)(r);for(const f of a)o.definedProperties.add(f);o.opts.unevaluated&&a.length&&o.props!==!0&&(o.props=oo.mergeEvaluated.props(t,(0,oo.toHash)(a),o.props));const i=a.filter(f=>!(0,oo.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,dl.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)}}};ki.default=pS;var Pi={};Object.defineProperty(Pi,"__esModule",{value:!0});const hl=ue,Kn=fe,pl=F,ml=F,mS={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,hl.allSchemaProperties)(r),c=i.filter($=>(0,pl.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 Kn.Name)&&(o.props=(0,ml.evaluatedPropsToName)(t,o.props));const{props:f}=o;g();function g(){for(const $ of i)l&&y($),o.allErrors?_($):(t.var(d,!0),_($),t.if(d))}function y($){for(const m in l)new RegExp($).test(m)&&(0,pl.checkStrictMode)(o,`property ${m} matches pattern ${$} (use allowMatchingProperties)`)}function _($){t.forIn("key",n,m=>{t.if((0,Kn._)`${(0,hl.usePattern)(e,$)}.test(${m})`,()=>{const h=c.includes($);h||e.subschema({keyword:"patternProperties",schemaProp:$,dataProp:m,dataPropType:ml.Type.Str},d),o.opts.unevaluated&&f!==!0?t.assign((0,Kn._)`${f}[${m}]`,!0):!h&&!o.allErrors&&t.if((0,Kn.not)(d),()=>t.break())})})}}};Pi.default=mS;var Ti={};Object.defineProperty(Ti,"__esModule",{value:!0});const _S=F,gS={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:r,it:n}=e;if((0,_S.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"}};Ti.default=gS;var Ri={};Object.defineProperty(Ri,"__esModule",{value:!0});const yS=ue,vS={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:yS.validateUnion,error:{message:"must match a schema in anyOf"}};Ri.default=vS;var Ci={};Object.defineProperty(Ci,"__esModule",{value:!0});const ss=fe,$S=F,wS={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,ss._)`{passingSchemas: ${e.passing}}`},bS={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:wS,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 g;(0,$S.alwaysValidSchema)(s,d)?t.var(c,!0):g=e.subschema({keyword:"oneOf",schemaProp:f,compositeRule:!0},c),f>0&&t.if((0,ss._)`${c} && ${a}`).assign(a,!1).assign(i,(0,ss._)`[${i}, ${f}]`).else(),t.if(c,()=>{t.assign(a,!0),t.assign(i,f),g&&e.mergeEvaluated(g,ss.Name)})})}}};Ci.default=bS;var Ni={};Object.defineProperty(Ni,"__esModule",{value:!0});const SS=F,ES={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,SS.alwaysValidSchema)(n,o))return;const i=e.subschema({keyword:"allOf",schemaProp:a},s);e.ok(s),e.mergeEvaluated(i)})}};Ni.default=ES;var Ii={};Object.defineProperty(Ii,"__esModule",{value:!0});const ws=fe,ff=F,kS={message:({params:e})=>(0,ws.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,ws._)`{failingKeyword: ${e.ifClause}}`},PS={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:kS,code(e){const{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,ff.checkStrictMode)(n,'"if" without "then" and "else" is ignored');const s=_l(n,"then"),o=_l(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,ws.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 g=e.subschema({keyword:d},i);t.assign(a,i),e.mergeValidEvaluated(g,a),f?t.assign(f,(0,ws._)`${d}`):e.setParams({ifClause:d})}}}};function _l(e,t){const r=e.schema[t];return r!==void 0&&!(0,ff.alwaysValidSchema)(e,r)}Ii.default=PS;var ji={};Object.defineProperty(ji,"__esModule",{value:!0});const TS=F,RS={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,TS.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};ji.default=RS;Object.defineProperty($i,"__esModule",{value:!0});const CS=Lr,NS=wi,IS=Fr,jS=bi,OS=Si,AS=uf,zS=Ei,MS=Hs,xS=ki,qS=Pi,DS=Ti,US=Ri,VS=Ci,LS=Ni,FS=Ii,HS=ji;function ZS(e=!1){const t=[DS.default,US.default,VS.default,LS.default,FS.default,HS.default,zS.default,MS.default,AS.default,xS.default,qS.default];return e?t.push(NS.default,jS.default):t.push(CS.default,IS.default),t.push(OS.default),t}$i.default=ZS;var Oi={},Ai={};Object.defineProperty(Ai,"__esModule",{value:!0});const Ne=fe,KS={message:({schemaCode:e})=>(0,Ne.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,Ne._)`{format: ${e}}`},GS={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:KS,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?g():y();function g(){const _=r.scopeValue("formats",{ref:f.formats,code:c.code.formats}),$=r.const("fDef",(0,Ne._)`${_}[${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(),S()));function v(){return c.strictSchema===!1?Ne.nil:(0,Ne._)`${a} && !${h}`}function S(){const R=d.$async?(0,Ne._)`(${$}.async ? await ${h}(${n}) : ${h}(${n}))`:(0,Ne._)`${h}(${n})`,P=(0,Ne._)`(typeof ${h} == "function" ? ${R} : ${h}.test(${n}))`;return(0,Ne._)`${h} && ${h} !== true && ${m} === ${t} && !${P}`}}function y(){const _=f.formats[o];if(!_){v();return}if(_===!0)return;const[$,m,h]=S(_);$===t&&e.pass(R());function v(){if(c.strictSchema===!1){f.logger.warn(P());return}throw new Error(P());function P(){return`unknown format "${o}" ignored in schema at path "${l}"`}}function S(P){const I=P instanceof RegExp?(0,Ne.regexpCode)(P):c.code.formats?(0,Ne._)`${c.code.formats}${(0,Ne.getProperty)(o)}`:void 0,A=r.scopeValue("formats",{key:o,ref:P,code:I});return typeof P=="object"&&!(P instanceof RegExp)?[P.type||"string",P.validate,(0,Ne._)`${A}.validate`]:["string",P,A]}function R(){if(typeof _=="object"&&!(_ instanceof RegExp)&&_.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})`}}}};Ai.default=GS;Object.defineProperty(Oi,"__esModule",{value:!0});const WS=Ai,BS=[WS.default];Oi.default=BS;var Mr={};Object.defineProperty(Mr,"__esModule",{value:!0});Mr.contentVocabulary=Mr.metadataVocabulary=void 0;Mr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Mr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];Object.defineProperty(oi,"__esModule",{value:!0});const JS=ai,QS=ci,YS=$i,XS=Oi,gl=Mr,eE=[JS.default,QS.default,(0,YS.default)(),XS.default,gl.metadataVocabulary,gl.contentVocabulary];oi.default=eE;var zi={},Zs={};Object.defineProperty(Zs,"__esModule",{value:!0});Zs.DiscrError=void 0;var yl;(function(e){e.Tag="tag",e.Mapping="mapping"})(yl||(Zs.DiscrError=yl={}));Object.defineProperty(zi,"__esModule",{value:!0});const kr=fe,Oo=Zs,vl=Qe,tE=Vr,rE=F,nE={message:({params:{discrError:e,tagName:t}})=>e===Oo.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,kr._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},sE={keyword:"discriminator",type:"object",schemaType:"object",error:nE,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,kr._)`${r}${(0,kr.getProperty)(i)}`);t.if((0,kr._)`typeof ${l} == "string"`,()=>d(),()=>e.error(!1,{discrError:Oo.DiscrError.Tag,tag:l,tagName:i})),e.ok(c);function d(){const y=g();t.if(!1);for(const _ in y)t.elseIf((0,kr._)`${l} === ${_}`),t.assign(c,f(y[_]));t.else(),e.error(!1,{discrError:Oo.DiscrError.Mapping,tag:l,tagName:i}),t.endIf()}function f(y){const _=t.name("valid"),$=e.subschema({keyword:"oneOf",schemaProp:y},_);return e.mergeEvaluated($,kr.Name),_}function g(){var y;const _={},$=h(s);let m=!0;for(let R=0;Rthis.addVocabulary(_)),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const _=this.opts.$data?this.$dataMetaSchema(o,a):o;this.addMetaSchema(_,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=mt;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=On;Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return f.default}});var g=Vr;Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return g.default}})})(Po,Po.exports);var fE=Po.exports;const hE=Ql(fE);var Ao={exports:{}},hf={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0;function t(L,W){return{validate:L,compare:W}}e.fullFormats={date:t(o,a),time:t(c(!0),l),"date-time":t(g(!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:V,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:S,int32:{type:"number",validate:I},int64:{type:"number",validate:A},float:{type:"number",validate:U},double:{type:"number",validate:U},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,_),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 W=n.exec(L);if(!W)return!1;const ce=+W[1],q=+W[2],le=+W[3];return q>=1&&q<=12&&le>=1&&le<=(q===2&&r(ce)?29:s[q])}function a(L,W){if(L&&W)return L>W?1:L23||w>59||L&&!it)return!1;if(le<=23&&Ce<=59&&ge<60)return!0;const C=Ce-w*je,b=le-j*je-(C<0?1:0);return(b===23||b===-1)&&(C===59||C===-1)&&ge<61}}function l(L,W){if(!(L&&W))return;const ce=new Date("2020-01-01T"+L).valueOf(),q=new Date("2020-01-01T"+W).valueOf();if(ce&&q)return ce-q}function d(L,W){if(!(L&&W))return;const ce=i.exec(L),q=i.exec(W);if(ce&&q)return L=ce[1]+ce[2]+ce[3],W=q[1]+q[2]+q[3],L>W?1:L=R}function A(L){return Number.isInteger(L)}function U(){return!0}const Z=/[^\\]\\Z/;function V(L){if(Z.test(L))return!1;try{return new RegExp(L),!0}catch{return!1}}})(hf);var pf={},zo={exports:{}},mf={},_t={},xr={},zn={},ie={},wn={};(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((S,R)=>`${S}${R}`,"")}get names(){var v;return(v=this._names)!==null&&v!==void 0?v:this._names=this._items.reduce((S,R)=>(R instanceof r&&(S[R.str]=(S[R.str]||0)+1),S),{})}}e._Code=n,e.nil=new n("");function s(h,...v){const S=[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,g=>{if(g.value===void 0)throw new Error(`CodeGen: name "${g}" has no value`);return g.value.code},d,f)}_reduceValues(l,d,f={},g){let y=t.nil;for(const _ in l){const $=l[_];if(!$)continue;const m=f[_]=f[_]||new Map;$.forEach(h=>{if(m.has(h))return;m.set(h,n.Started);let v=d(h);if(v){const S=this.opts.es5?e.varKinds.var:e.varKinds.const;y=(0,t._)`${y}${S} ${h} = ${v};${this.opts._n}`}else if(v=g==null?void 0:g(h))y=(0,t._)`${y}${v}${this.opts._n}`;else throw new r(h);m.set(h,n.Completed)})}return y}}e.ValueScope=i})(Mo);(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=wn,r=Mo;var n=wn;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=Mo;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,E){super(),this.varKind=u,this.name=p,this.rhs=E}render({es5:u,_n:p}){const E=u?r.varKinds.var:this.varKind,M=this.rhs===void 0?"":` = ${this.rhs}`;return`${E} ${this.name}${M};`+p}optimizeNames(u,p){if(u[this.name.str])return this.rhs&&(this.rhs=q(this.rhs,u,p)),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}}class i extends o{constructor(u,p,E){super(),this.lhs=u,this.rhs=p,this.sideEffects=E}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=q(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,E,M){super(u,E,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 g 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=q(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,E)=>p+E.render(u),"")}optimizeNodes(){const{nodes:u}=this;let p=u.length;for(;p--;){const E=u[p].optimizeNodes();Array.isArray(E)?u.splice(p,1,...E):E?u[p]=E:u.splice(p,1)}return u.length>0?this:void 0}optimizeNames(u,p){const{nodes:E}=this;let M=E.length;for(;M--;){const x=E[M];x.optimizeNames(u,p)||(le(u,x.names),E.splice(M,1))}return E.length>0?this:void 0}get names(){return this.nodes.reduce((u,p)=>W(u,p.names),{})}}class _ extends y{render(u){return"{"+u._n+super.render(u)+"}"+u._n}}class $ extends y{}class m extends _{}m.kind="else";class h extends _{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 E=p.optimizeNodes();p=this.else=Array.isArray(E)?new m(E):E}if(p)return u===!1?p instanceof h?p:p.nodes:this.nodes.length?this:new h(Ce(u),p instanceof h?[p]:p.nodes);if(!(u===!1||!this.nodes.length))return this}optimizeNames(u,p){var E;if(this.else=(E=this.else)===null||E===void 0?void 0:E.optimizeNames(u,p),!!(super.optimizeNames(u,p)||this.else))return this.condition=q(this.condition,u,p),this}get names(){const u=super.names;return ce(u,this.condition),this.else&&W(u,this.else.names),u}}h.kind="if";class v extends _{}v.kind="for";class S 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=q(this.iteration,u,p),this}get names(){return W(super.names,this.iteration.names)}}class R extends v{constructor(u,p,E,M){super(),this.varKind=u,this.name=p,this.from=E,this.to=M}render(u){const p=u.es5?r.varKinds.var:this.varKind,{name:E,from:M,to:x}=this;return`for(${p} ${E}=${M}; ${E}<${x}; ${E}++)`+super.render(u)}get names(){const u=ce(super.names,this.from);return ce(u,this.to)}}class P extends v{constructor(u,p,E,M){super(),this.loop=u,this.varKind=p,this.name=E,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=q(this.iterable,u,p),this}get names(){return W(super.names,this.iterable.names)}}class I extends _{constructor(u,p,E){super(),this.name=u,this.args=p,this.async=E}render(u){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(u)}}I.kind="func";class A extends y{render(u){return"return "+super.render(u)}}A.kind="return";class U extends _{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 E,M;return super.optimizeNames(u,p),(E=this.catch)===null||E===void 0||E.optimizeNames(u,p),(M=this.finally)===null||M===void 0||M.optimizeNames(u,p),this}get names(){const u=super.names;return this.catch&&W(u,this.catch.names),this.finally&&W(u,this.finally.names),u}}class Z extends _{constructor(u){super(),this.error=u}render(u){return`catch(${this.error})`+super.render(u)}}Z.kind="catch";class V extends _{render(u){return"finally"+super.render(u)}}V.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 E=this._extScope.value(u,p);return(this._values[E.prefix]||(this._values[E.prefix]=new Set)).add(E),E}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,E,M){const x=this._scope.toName(p);return E!==void 0&&M&&(this._constants[x.str]=E),this._leafNode(new a(u,x,E)),x}const(u,p,E){return this._def(r.varKinds.const,u,p,E)}let(u,p,E){return this._def(r.varKinds.let,u,p,E)}var(u,p,E){return this._def(r.varKinds.var,u,p,E)}assign(u,p,E){return this._leafNode(new i(u,p,E))}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 g(u)),this}object(...u){const p=["{"];for(const[E,M]of u)p.length>1&&p.push(","),p.push(E),(E!==M||this.opts.es5)&&(p.push(":"),(0,t.addCodeArg)(p,M));return p.push("}"),new t._Code(p)}if(u,p,E){if(this._blockNode(new h(u)),p&&E)this.code(p).else().code(E).endIf();else if(p)this.code(p).endIf();else if(E)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 S(u),p)}forRange(u,p,E,M,x=this.opts.es5?r.varKinds.var:r.varKinds.let){const B=this._scope.toName(u);return this._for(new R(x,B,p,E),()=>M(B))}forOf(u,p,E,M=r.varKinds.const){const x=this._scope.toName(u);if(this.opts.es5){const B=p instanceof t.Name?p:this.var("_arr",p);return this.forRange("_i",0,(0,t._)`${B}.length`,K=>{this.var(x,(0,t._)`${B}[${K}]`),E(x)})}return this._for(new P("of",M,x,p),()=>E(x))}forIn(u,p,E,M=this.opts.es5?r.varKinds.var:r.varKinds.const){if(this.opts.ownProperties)return this.forOf(u,(0,t._)`Object.keys(${p})`,E);const x=this._scope.toName(u);return this._for(new P("in",M,x,p),()=>E(x))}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 A;if(this._blockNode(p),this.code(u),p.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(A)}try(u,p,E){if(!p&&!E)throw new Error('CodeGen: "try" without "catch" and "finally"');const M=new U;if(this._blockNode(M),this.code(u),p){const x=this.name("e");this._currNode=M.catch=new Z(x),p(x)}return E&&(this._currNode=M.finally=new V,this.code(E)),this._endBlockNode(Z,V)}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 E=this._nodes.length-p;if(E<0||u!==void 0&&E!==u)throw new Error(`CodeGen: wrong number of nodes: ${E} vs ${u} expected`);return this._nodes.length=p,this}func(u,p=t.nil,E,M){return this._blockNode(new I(u,p,E)),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 E=this._currNode;if(E instanceof u||p&&E 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 W(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?W(b,u.names):b}function q(b,u,p){if(b instanceof t.Name)return E(b);if(!M(b))return b;return new t._Code(b._items.reduce((x,B)=>(B instanceof t.Name&&(B=E(B)),B instanceof t._Code?x.push(...B._items):x.push(B),x),[]));function E(x){const B=p[x.str];return B===void 0||u[x.str]!==1?x:(delete u[x.str],B)}function M(x){return x instanceof t._Code&&x._items.some(B=>B instanceof t.Name&&u[B.str]===1&&p[B.str]!==void 0)}}function le(b,u){for(const p in u)b[p]=(b[p]||0)-(u[p]||0)}function Ce(b){return typeof b=="boolean"||typeof b=="number"||b===null?!b:(0,t._)`!${C(b)}`}e.not=Ce;const ge=w(e.operators.AND);function it(...b){return b.reduce(ge)}e.and=it;const je=w(e.operators.OR);function j(...b){return b.reduce(je)}e.or=j;function w(b){return(u,p)=>u===t.nil?p:p===t.nil?u:(0,t._)`${C(u)} ${b} ${C(p)}`}function C(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,pE=wn;function mE(e){const t={};for(const r of e)t[r]=!0;return t}H.toHash=mE;function _E(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(_f(e,t),!gf(t,e.self.RULES.all))}H.alwaysValidSchema=_E;function _f(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]||$f(e,`unknown keyword: "${o}"`)}H.checkUnknownRules=_f;function gf(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(t[r])return!0;return!1}H.schemaHasRules=gf;function gE(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=gE;function yE({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=yE;function vE(e){return yf(decodeURIComponent(e))}H.unescapeFragment=vE;function $E(e){return encodeURIComponent(Mi(e))}H.escapeFragment=$E;function Mi(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}H.escapeJsonPointer=Mi;function yf(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}H.unescapeJsonPointer=yf;function wE(e,t){if(Array.isArray(e))for(const r of e)t(r);else t(e)}H.eachItem=wE;function $l({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:$l({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} || {}`),xi(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:vf}),items:$l({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 vf(e,t){if(t===!0)return e.var("props",!0);const r=e.var("props",(0,ve._)`{}`);return t!==void 0&&xi(e,r,t),r}H.evaluatedPropsToName=vf;function xi(e,t,r){Object.keys(r).forEach(n=>e.assign((0,ve._)`${t}${(0,ve.getProperty)(n)}`,!0))}H.setEvaluated=xi;const wl={};function bE(e,t){return e.scopeValue("func",{ref:t,code:wl[t.code]||(wl[t.code]=new pE._Code(t.code))})}H.useFunc=bE;var xo;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(xo||(H.Type=xo={}));function SE(e,t,r){if(e instanceof ve.Name){const n=t===xo.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():"/"+Mi(e)}H.getErrorPath=SE;function $f(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=$f;var Et={};Object.defineProperty(Et,"__esModule",{value:!0});const Ke=ie,EE={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=EE;(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,S){const{it:R}=m,{gen:P,compositeRule:I,allErrors:A}=R,U=f(m,h,v);S??(I||A)?c(P,U):l(R,(0,t._)`[${U}]`)}e.reportError=s;function o(m,h=e.keywordError,v){const{it:S}=m,{gen:R,compositeRule:P,allErrors:I}=S,A=f(m,h,v);c(R,A),P||I||l(S,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:S,errsCount:R,it:P}){if(R===void 0)throw new Error("ajv implementation error");const I=m.name("err");m.forRange("i",R,n.default.errors,A=>{m.const(I,(0,t._)`${n.default.vErrors}[${A}]`),m.if((0,t._)`${I}.instancePath === undefined`,()=>m.assign((0,t._)`${I}.instancePath`,(0,t.strConcat)(n.default.instancePath,P.errorPath))),m.assign((0,t._)`${I}.schemaPath`,(0,t.str)`${P.errSchemaPath}/${h}`),P.opts.verbose&&(m.assign((0,t._)`${I}.schema`,v),m.assign((0,t._)`${I}.data`,S))})}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:S,schemaEnv:R}=m;R.$async?v.throw((0,t._)`new ${m.ValidationError}(${h})`):(v.assign((0,t._)`${S}.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:S}=m.it;return S===!1?(0,t._)`{}`:g(m,h,v)}function g(m,h,v={}){const{gen:S,it:R}=m,P=[y(R,v),_(m,v)];return $(m,h,P),S.object(...P)}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 _({keyword:m,it:{errSchemaPath:h}},{schemaPath:v,parentSchema:S}){let R=S?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},S){const{keyword:R,data:P,schemaValue:I,it:A}=m,{opts:U,propertyName:Z,topSchemaRef:V,schemaPath:L}=A;S.push([d.keyword,R],[d.params,typeof h=="function"?h(m):h||(0,t._)`{}`]),U.messages&&S.push([d.message,typeof v=="function"?v(m):v]),U.verbose&&S.push([d.schema,I],[d.parentSchema,(0,t._)`${V}${L}`],[n.default.data,P]),Z&&S.push([d.propertyName,Z])}})(zn);Object.defineProperty(xr,"__esModule",{value:!0});xr.boolOrEmptySchema=xr.topBoolOrEmptySchema=void 0;const kE=zn,PE=ie,TE=Et,RE={message:"boolean schema is false"};function CE(e){const{gen:t,schema:r,validateName:n}=e;r===!1?wf(e,!1):typeof r=="object"&&r.$async===!0?t.return(TE.default.data):(t.assign((0,PE._)`${n}.errors`,null),t.return(!0))}xr.topBoolOrEmptySchema=CE;function NE(e,t){const{gen:r,schema:n}=e;n===!1?(r.var(t,!1),wf(e)):r.var(t,!0)}xr.boolOrEmptySchema=NE;function wf(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,kE.reportError)(s,RE,void 0,t)}var Ae={},_r={};Object.defineProperty(_r,"__esModule",{value:!0});_r.getRules=_r.isJSONType=void 0;const IE=["string","number","integer","boolean","null","object","array"],jE=new Set(IE);function OE(e){return typeof e=="string"&&jE.has(e)}_r.isJSONType=OE;function AE(){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:{}}}_r.getRules=AE;var Tt={};Object.defineProperty(Tt,"__esModule",{value:!0});Tt.shouldUseRule=Tt.shouldUseGroup=Tt.schemaHasRulesForType=void 0;function zE({schema:e,self:t},r){const n=t.RULES.types[r];return n&&n!==!0&&bf(e,n)}Tt.schemaHasRulesForType=zE;function bf(e,t){return t.rules.some(r=>Sf(e,r))}Tt.shouldUseGroup=bf;function Sf(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=Sf;Object.defineProperty(Ae,"__esModule",{value:!0});Ae.reportTypeError=Ae.checkDataTypes=Ae.checkDataType=Ae.coerceAndCheckDataType=Ae.getJSONTypes=Ae.getSchemaTypes=Ae.DataType=void 0;const ME=_r,xE=Tt,qE=zn,se=ie,Ef=H;var jr;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(jr||(Ae.DataType=jr={}));function DE(e){const t=kf(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}Ae.getSchemaTypes=DE;function kf(e){const t=Array.isArray(e)?e:e?[e]:[];if(t.every(ME.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}Ae.getJSONTypes=kf;function UE(e,t){const{gen:r,data:n,opts:s}=e,o=VE(t,s.coerceTypes),a=t.length>0&&!(o.length===0&&t.length===1&&(0,xE.schemaHasRulesForType)(e,t[0]));if(a){const i=qi(t,n,s.strictNumbers,jr.Wrong);r.if(i,()=>{o.length?LE(e,t,o):Di(e)})}return a}Ae.coerceAndCheckDataType=UE;const Pf=new Set(["string","number","integer","boolean","null"]);function VE(e,t){return t?e.filter(r=>Pf.has(r)||t==="array"&&r==="array"):[]}function LE(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(qi(t,s,o.strictNumbers),()=>n.assign(i,s))),n.if((0,se._)`${i} !== undefined`);for(const l of r)(Pf.has(l)||l==="array"&&o.coerceTypes==="array")&&c(l);n.else(),Di(e),n.endIf(),n.if((0,se._)`${i} !== undefined`,()=>{n.assign(s,i),FE(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 FE({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,se._)`${t} !== undefined`,()=>e.assign((0,se._)`${t}[${r}]`,n))}function qo(e,t,r,n=jr.Correct){const s=n===jr.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===jr.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)}}Ae.checkDataType=qo;function qi(e,t,r,n){if(e.length===1)return qo(e[0],t,r,n);let s;const o=(0,Ef.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,qo(a,t,r,n));return s}Ae.checkDataTypes=qi;const HE={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,se._)`{type: ${e}}`:(0,se._)`{type: ${t}}`};function Di(e){const t=ZE(e);(0,qE.reportError)(t,HE)}Ae.reportTypeError=Di;function ZE(e){const{gen:t,data:r,schema:n}=e,s=(0,Ef.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:e}}var Ks={};Object.defineProperty(Ks,"__esModule",{value:!0});Ks.assignDefaults=void 0;const wr=ie,KE=H;function GE(e,t){const{properties:r,items:n}=e.schema;if(t==="object"&&r)for(const s in r)bl(e,s,r[s].default);else t==="array"&&Array.isArray(n)&&n.forEach((s,o)=>bl(e,o,s.default))}Ks.assignDefaults=GE;function bl(e,t,r){const{gen:n,compositeRule:s,data:o,opts:a}=e;if(r===void 0)return;const i=(0,wr._)`${o}${(0,wr.getProperty)(t)}`;if(s){(0,KE.checkStrictMode)(e,`default is ignored for: ${i}`);return}let c=(0,wr._)`${i} === undefined`;a.useDefaults==="empty"&&(c=(0,wr._)`${c} || ${i} === null || ${i} === ""`),n.if(c,(0,wr._)`${i} = ${(0,wr.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,Ui=H,It=Et,WE=H;function BE(e,t){const{gen:r,data:n,it:s}=e;r.if(Li(r,n,t,s.opts.ownProperties),()=>{e.setParams({missingProperty:(0,Se._)`${t}`},!0),e.error()})}de.checkReportMissingProp=BE;function JE({gen:e,data:t,it:{opts:r}},n,s){return(0,Se.or)(...n.map(o=>(0,Se.and)(Li(e,t,o,r.ownProperties),(0,Se._)`${s} = ${o}`)))}de.checkMissingProp=JE;function QE(e,t){e.setParams({missingProperty:t},!0),e.error()}de.reportMissingProp=QE;function Tf(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Se._)`Object.prototype.hasOwnProperty`})}de.hasPropFunc=Tf;function Vi(e,t,r){return(0,Se._)`${Tf(e)}.call(${t}, ${r})`}de.isOwnProperty=Vi;function YE(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=YE;function Li(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=Li;function Rf(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}de.allSchemaProperties=Rf;function XE(e,t){return Rf(t).filter(r=>!(0,Ui.alwaysValidSchema)(e,t[r]))}de.schemaProperties=XE;function ek({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=[[It.default.instancePath,(0,Se.strConcat)(It.default.instancePath,o)],[It.default.parentData,a.parentData],[It.default.parentDataProperty,a.parentDataProperty],[It.default.rootData,It.default.rootData]];a.opts.dynamicRef&&f.push([It.default.dynamicAnchors,It.default.dynamicAnchors]);const g=(0,Se._)`${d}, ${r.object(...f)}`;return c!==Se.nil?(0,Se._)`${i}.call(${c}, ${g})`:(0,Se._)`${i}(${g})`}de.callValidateCode=ek;const tk=(0,Se._)`new RegExp`;function rk({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"?tk:(0,WE.useFunc)(e,s)}(${r}, ${n})`})}de.usePattern=rk;function nk(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:Ui.Type.Num},o),t.if((0,Se.not)(o),i)})}}de.validateArray=nk;function sk(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,Ui.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=sk;Object.defineProperty(bt,"__esModule",{value:!0});bt.validateKeywordUsage=bt.validSchemaType=bt.funcKeywordCode=bt.macroKeywordCode=void 0;const We=ie,cr=Et,ok=de,ak=zn;function ik(e,t){const{gen:r,keyword:n,schema:s,parentSchema:o,it:a}=e,i=t.macro.call(a.self,s,o,a),c=Cf(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=ik;function ck(e,t){var r;const{gen:n,keyword:s,schema:o,parentSchema:a,$data:i,it:c}=e;uk(c,t);const l=!i&&t.compile?t.compile.call(c.self,o,a,c):t.validate,d=Cf(n,s,l),f=n.let("valid");e.block$data(f,g),e.ok((r=t.valid)!==null&&r!==void 0?r:f);function g(){if(t.errors===!1)$(),t.modifying&&Sl(e),m(()=>e.error());else{const h=t.async?y():_();t.modifying&&Sl(e),m(()=>lk(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 _(){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?cr.default.this:cr.default.self,S=!("compile"in t&&!i||t.schema===!1);n.assign(f,(0,We._)`${h}${(0,ok.callValidateCode)(e,d,v,S)}`,t.modifying)}function m(h){var v;n.if((0,We.not)((v=t.valid)!==null&&v!==void 0?v:f),h)}}bt.funcKeywordCode=ck;function Sl(e){const{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,We._)`${n.parentData}[${n.parentDataProperty}]`))}function lk(e,t){const{gen:r}=e;r.if((0,We._)`Array.isArray(${t})`,()=>{r.assign(cr.default.vErrors,(0,We._)`${cr.default.vErrors} === null ? ${t} : ${cr.default.vErrors}.concat(${t})`).assign(cr.default.errors,(0,We._)`${cr.default.vErrors}.length`),(0,ak.extendErrors)(e)},()=>e.error())}function uk({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function Cf(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 dk(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=dk;function fk({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=fk;var xt={};Object.defineProperty(xt,"__esModule",{value:!0});xt.extendSubschemaMode=xt.extendSubschemaData=xt.getSubschema=void 0;const $t=ie,Nf=H;function hk(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,Nf.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')}xt.getSubschema=hk;function pk(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,g=i.let("data",(0,$t._)`${t.data}${(0,$t.getProperty)(r)}`,!0);c(g),e.errorPath=(0,$t.str)`${l}${(0,Nf.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]}}xt.extendSubschemaData=pk;function mk(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}xt.extendSubschemaMode=mk;var Ve={},If={exports:{}},zt=If.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(){};os(t,n,s,e,"",e)};zt.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};zt.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};zt.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};zt.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 os(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 zt.arrayKeywords)for(var g=0;gt+=jf(n)),t===1/0))return 1/0}return t}function Of(e,t="",r){r!==!1&&(t=Or(t));const n=e.parse(t);return Af(e,n)}Ve.getFullPath=Of;function Af(e,t){return e.serialize(t).split("#")[0]+"#"}Ve._getFullPath=Af;const Ek=/#\/?$/;function Or(e){return e?e.replace(Ek,""):""}Ve.normalizeId=Or;function kk(e,t,r){return r=Or(r),e.resolve(t,r)}Ve.resolveUrl=kk;const Pk=/^[a-z_][-a-z0-9._]*$/i;function Tk(e,t){if(typeof e=="boolean")return{};const{schemaId:r,uriResolver:n}=this.opts,s=Or(e[r]||t),o={"":s},a=Of(n,s,!1),i={},c=new Set;return $k(e,{allKeys:!0},(f,g,y,_)=>{if(_===void 0)return;const $=a+g;let m=o[_];typeof f[r]=="string"&&(m=h.call(this,f[r])),v.call(this,f.$anchor),v.call(this,f.$dynamicAnchor),o[g]=m;function h(S){const R=this.opts.uriResolver.resolve;if(S=Or(m?R(m,S):S),c.has(S))throw d(S);c.add(S);let P=this.refs[S];return typeof P=="string"&&(P=this.refs[P]),typeof P=="object"?l(f,P.schema,S):S!==Or($)&&(S[0]==="#"?(l(f,i[S],S),i[S]=f):this.refs[S]=$),S}function v(S){if(typeof S=="string"){if(!Pk.test(S))throw new Error(`invalid anchor "${S}"`);h.call(this,`#${S}`)}}}),i;function l(f,g,y){if(g!==void 0&&!vk(f,g))throw d(y)}function d(f){return new Error(`reference "${f}" resolves to more than one schema`)}}Ve.getSchemaRefs=Tk;Object.defineProperty(_t,"__esModule",{value:!0});_t.getData=_t.KeywordCxt=_t.validateFunctionCode=void 0;const zf=xr,El=Ae,Fi=Tt,bs=Ae,Rk=Ks,dn=bt,ao=xt,Q=ie,te=Et,Ck=Ve,Rt=H,Yr=zn;function Nk(e){if(qf(e)&&(Df(e),xf(e))){Ok(e);return}Mf(e,()=>(0,zf.topBoolOrEmptySchema)(e))}_t.validateFunctionCode=Nk;function Mf({gen:e,validateName:t,schema:r,schemaEnv:n,opts:s},o){s.code.es5?e.func(t,(0,Q._)`${te.default.data}, ${te.default.valCxt}`,n.$async,()=>{e.code((0,Q._)`"use strict"; ${kl(r,s)}`),jk(e,s),e.code(o)}):e.func(t,(0,Q._)`${te.default.data}, ${Ik(s)}`,n.$async,()=>e.code(kl(r,s)).code(o))}function Ik(e){return(0,Q._)`{${te.default.instancePath}="", ${te.default.parentData}, ${te.default.parentDataProperty}, ${te.default.rootData}=${te.default.data}${e.dynamicRef?(0,Q._)`, ${te.default.dynamicAnchors}={}`:Q.nil}}={}`}function jk(e,t){e.if(te.default.valCxt,()=>{e.var(te.default.instancePath,(0,Q._)`${te.default.valCxt}.${te.default.instancePath}`),e.var(te.default.parentData,(0,Q._)`${te.default.valCxt}.${te.default.parentData}`),e.var(te.default.parentDataProperty,(0,Q._)`${te.default.valCxt}.${te.default.parentDataProperty}`),e.var(te.default.rootData,(0,Q._)`${te.default.valCxt}.${te.default.rootData}`),t.dynamicRef&&e.var(te.default.dynamicAnchors,(0,Q._)`${te.default.valCxt}.${te.default.dynamicAnchors}`)},()=>{e.var(te.default.instancePath,(0,Q._)`""`),e.var(te.default.parentData,(0,Q._)`undefined`),e.var(te.default.parentDataProperty,(0,Q._)`undefined`),e.var(te.default.rootData,te.default.data),t.dynamicRef&&e.var(te.default.dynamicAnchors,(0,Q._)`{}`)})}function Ok(e){const{schema:t,opts:r,gen:n}=e;Mf(e,()=>{r.$comment&&t.$comment&&Vf(e),qk(e),n.let(te.default.vErrors,null),n.let(te.default.errors,0),r.unevaluated&&Ak(e),Uf(e),Vk(e)})}function Ak(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 kl(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 zk(e,t){if(qf(e)&&(Df(e),xf(e))){Mk(e,t);return}(0,zf.boolOrEmptySchema)(e,t)}function xf({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 qf(e){return typeof e.schema!="boolean"}function Mk(e,t){const{schema:r,gen:n,opts:s}=e;s.$comment&&r.$comment&&Vf(e),Dk(e),Uk(e);const o=n.const("_errs",te.default.errors);Uf(e,o),n.var(t,(0,Q._)`${o} === ${te.default.errors}`)}function Df(e){(0,Rt.checkUnknownRules)(e),xk(e)}function Uf(e,t){if(e.opts.jtd)return Pl(e,[],!1,t);const r=(0,El.getSchemaTypes)(e.schema),n=(0,El.coerceAndCheckDataType)(e,r);Pl(e,r,!n,t)}function xk(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 Dk(e){const t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,Ck.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function Uk(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function Vf({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:s}){const o=r.$comment;if(s.$comment===!0)e.code((0,Q._)`${te.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._)`${te.default.self}.opts.$comment(${o}, ${a}, ${i}.schema)`)}}function Vk(e){const{gen:t,schemaEnv:r,validateName:n,ValidationError:s,opts:o}=e;r.$async?t.if((0,Q._)`${te.default.errors} === 0`,()=>t.return(te.default.data),()=>t.throw((0,Q._)`new ${s}(${te.default.vErrors})`)):(t.assign((0,Q._)`${n}.errors`,te.default.vErrors),o.unevaluated&&Lk(e),t.return((0,Q._)`${te.default.errors} === 0`))}function Lk({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 Pl(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(()=>Hf(e,"$ref",d.all.$ref.definition));return}c.jtd||Fk(e,t),s.block(()=>{for(const g of d.rules)f(g);f(d.post)});function f(g){(0,Fi.shouldUseGroup)(o,g)&&(g.type?(s.if((0,bs.checkDataType)(g.type,a,c.strictNumbers)),Tl(e,g),t.length===1&&t[0]===g.type&&r&&(s.else(),(0,bs.reportTypeError)(e)),s.endIf()):Tl(e,g),i||s.if((0,Q._)`${te.default.errors} === ${n||0}`))}}function Tl(e,t){const{gen:r,schema:n,opts:{useDefaults:s}}=e;s&&(0,Rk.assignDefaults)(e,t.type),r.block(()=>{for(const o of t.rules)(0,Fi.shouldUseRule)(n,o)&&Hf(e,o.keyword,o.definition,t.type)})}function Fk(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(Hk(e,t),e.opts.allowUnionTypes||Zk(e,t),Kk(e,e.dataTypes))}function Hk(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{Lf(e.dataTypes,r)||Hi(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),Wk(e,t)}}function Zk(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&Hi(e,"use allowUnionTypes to allow union type keyword")}function Kk(e,t){const r=e.self.RULES.all;for(const n in r){const s=r[n];if(typeof s=="object"&&(0,Fi.shouldUseRule)(e.schema,s)){const{type:o}=s.definition;o.length&&!o.some(a=>Gk(t,a))&&Hi(e,`missing type "${o.join(",")}" for keyword "${n}"`)}}}function Gk(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function Lf(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function Wk(e,t){const r=[];for(const n of e.dataTypes)Lf(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function Hi(e,t){const r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,Rt.checkStrictMode)(e,t,e.opts.strictTypes)}class Ff{constructor(t,r,n){if((0,dn.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",Zf(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,dn.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,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?Yr.reportExtraError:Yr.reportError)(this,this.def.error,r)}$dataError(){(0,Yr.reportError)(this,this.def.$dataError||Yr.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Yr.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,bs.checkDataTypes)(c,r,o.opts.strictNumbers,bs.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,ao.getSubschema)(this.it,t);(0,ao.extendSubschemaData)(n,this.it,t),(0,ao.extendSubschemaMode)(n,t);const s={...this.it,...n,items:void 0,props:void 0};return zk(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,Q.Name)),!0}}_t.KeywordCxt=Ff;function Hf(e,t,r,n){const s=new Ff(e,r,t);"code"in r?r.code(s,n):s.$data&&r.validate?(0,dn.funcKeywordCode)(s,r):"macro"in r?(0,dn.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0,dn.funcKeywordCode)(s,r)}const Bk=/^\/(?:[^~]|~0|~1)*$/,Jk=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Zf(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let s,o;if(e==="")return te.default.rootData;if(e[0]==="/"){if(!Bk.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);s=e,o=te.default.rootData}else{const l=Jk.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,Rt.unescapeJsonPointer)(l))}`,a=(0,Q._)`${a} && ${o}`);return a;function c(l,d){return`Cannot access ${l} ${d} levels up, current level is ${t}`}}_t.getData=Zf;var Mn={};Object.defineProperty(Mn,"__esModule",{value:!0});class Qk extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}}Mn.default=Qk;var Hr={};Object.defineProperty(Hr,"__esModule",{value:!0});const io=Ve;class Yk extends Error{constructor(t,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,io.resolveUrl)(t,r,n),this.missingSchema=(0,io.normalizeId)((0,io.getFullPath)(t,this.missingRef))}}Hr.default=Yk;var Ye={};Object.defineProperty(Ye,"__esModule",{value:!0});Ye.resolveSchema=Ye.getCompilingSchema=Ye.resolveRef=Ye.compileSchema=Ye.SchemaEnv=void 0;const ut=ie,Xk=Mn,rr=Et,pt=Ve,Rl=H,eP=_t;class Gs{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={}}}Ye.SchemaEnv=Gs;function Zi(e){const t=Kf.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 ut.CodeGen(this.scope,{es5:n,lines:s,ownProperties:o});let i;e.$async&&(i=a.scopeValue("Error",{ref:Xk.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:rr.default.data,parentData:rr.default.parentData,parentDataProperty:rr.default.parentDataProperty,dataNames:[rr.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,eP.validateFunctionCode)(l),a.optimize(this.opts.code.optimize);const f=a.toString();d=`${a.scopeRefs(rr.default.scope)}return ${f}`,this.opts.code.process&&(d=this.opts.code.process(d,e));const y=new Function(`${rr.default.self}`,`${rr.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:_,items:$}=l;y.evaluated={props:_ instanceof ut.Name?void 0:_,items:$ instanceof ut.Name?void 0:$,dynamicProps:_ 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=Zi;function tP(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=sP.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 Gs({schema:a,schemaId:i,root:e,baseId:t}))}if(o!==void 0)return e.refs[r]=rP.call(this,o)}Ye.resolveRef=tP;function rP(e){return(0,pt.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Zi.call(this,e)}function Kf(e){for(const t of this._compilations)if(nP(t,e))return t}Ye.getCompilingSchema=Kf;function nP(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function sP(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||Ws.call(this,e,t)}function Ws(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 co.call(this,r,e);const o=(0,pt.normalizeId)(n),a=this.refs[o]||this.schemas[o];if(typeof a=="string"){const i=Ws.call(this,e,a);return typeof(i==null?void 0:i.schema)!="object"?void 0:co.call(this,r,i)}if(typeof(a==null?void 0:a.schema)=="object"){if(a.validate||Zi.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 Gs({schema:i,schemaId:c,root:e,baseId:s})}return co.call(this,r,a)}}Ye.resolveSchema=Ws;const oP=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function co(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,Rl.unescapeFragment)(i)];if(c===void 0)return;r=c;const l=typeof r=="object"&&r[this.opts.schemaId];!oP.has(i)&&l&&(t=(0,pt.resolveUrl)(this.opts.uriResolver,t,l))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,Rl.schemaHasRulesButRef)(r,this.RULES)){const i=(0,pt.resolveUrl)(this.opts.uriResolver,t,r.$ref);o=Ws.call(this,n,i)}const{schemaId:a}=this.opts;if(o=o||new Gs({schema:r,schemaId:a,root:n,baseId:t}),o.schema!==o.root.schema)return o}const aP="https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",iP="Meta-schema for $data reference (JSON AnySchema extension proposal)",cP="object",lP=["$data"],uP={$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},dP=!1,fP={$id:aP,description:iP,type:cP,required:lP,properties:uP,additionalProperties:dP};var Ki={};Object.defineProperty(Ki,"__esModule",{value:!0});const Gf=rf;Gf.code='require("ajv/dist/runtime/uri").default';Ki.default=Gf;(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=Mn,s=Hr,o=_r,a=Ye,i=ie,c=Ve,l=Ae,d=H,f=fP,g=Ki,y=(j,w)=>new RegExp(j,w);y.code="new RegExp";const _=["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 S(j){var w,C,b,u,p,E,M,x,B,K,he,et,Ut,Vt,Lt,Ft,Ht,Zt,Kt,Gt,Wt,Bt,Jt,Qt,Yt;const ct=j.strict,Xt=(w=j.code)===null||w===void 0?void 0:w.optimize,Gr=Xt===!0||Xt===void 0?1:Xt||0,Wr=(b=(C=j.code)===null||C===void 0?void 0:C.regExp)!==null&&b!==void 0?b:y,Qs=(u=j.uriResolver)!==null&&u!==void 0?u:g.default;return{strictSchema:(E=(p=j.strictSchema)!==null&&p!==void 0?p:ct)!==null&&E!==void 0?E:!0,strictNumbers:(x=(M=j.strictNumbers)!==null&&M!==void 0?M:ct)!==null&&x!==void 0?x:!0,strictTypes:(K=(B=j.strictTypes)!==null&&B!==void 0?B:ct)!==null&&K!==void 0?K:"log",strictTuples:(et=(he=j.strictTuples)!==null&&he!==void 0?he:ct)!==null&&et!==void 0?et:"log",strictRequired:(Vt=(Ut=j.strictRequired)!==null&&Ut!==void 0?Ut:ct)!==null&&Vt!==void 0?Vt:!1,code:j.code?{...j.code,optimize:Gr,regExp:Wr}:{optimize:Gr,regExp:Wr},loopRequired:(Lt=j.loopRequired)!==null&&Lt!==void 0?Lt:v,loopEnum:(Ft=j.loopEnum)!==null&&Ft!==void 0?Ft:v,meta:(Ht=j.meta)!==null&&Ht!==void 0?Ht:!0,messages:(Zt=j.messages)!==null&&Zt!==void 0?Zt:!0,inlineRefs:(Kt=j.inlineRefs)!==null&&Kt!==void 0?Kt:!0,schemaId:(Gt=j.schemaId)!==null&&Gt!==void 0?Gt:"$id",addUsedSchema:(Wt=j.addUsedSchema)!==null&&Wt!==void 0?Wt:!0,validateSchema:(Bt=j.validateSchema)!==null&&Bt!==void 0?Bt:!0,validateFormats:(Jt=j.validateFormats)!==null&&Jt!==void 0?Jt:!0,unicodeRegExp:(Qt=j.unicodeRegExp)!==null&&Qt!==void 0?Qt:!0,int32range:(Yt=j.int32range)!==null&&Yt!==void 0?Yt:!0,uriResolver:Qs}}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,...S(w)};const{es5:C,lines:b}=this.opts.code;this.scope=new i.ValueScope({scope:{},prefixes:$,es5:C,lines:b}),this.logger=W(w.logger);const u=w.validateFormats;w.validateFormats=!1,this.RULES=(0,o.getRules)(),P.call(this,m,w,"NOT SUPPORTED"),P.call(this,h,w,"DEPRECATED","warn"),this._metaOpts=V.call(this),w.formats&&U.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),w.keywords&&Z.call(this,w.keywords),typeof w.meta=="object"&&this.addMetaSchema(w.meta),A.call(this),w.validateFormats=u}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:w,meta:C,schemaId:b}=this.opts;let u=f;b==="id"&&(u={...f},u.id=u.$id,delete u.$id),C&&w&&this.addMetaSchema(u,u[b],!1)}defaultMeta(){const{meta:w,schemaId:C}=this.opts;return this.opts.defaultMeta=typeof w=="object"?w[C]||w:void 0}validate(w,C){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(C);return"$async"in b||(this.errors=b.errors),u}compile(w,C){const b=this._addSchema(w,C);return b.validate||this._compileSchemaEnv(b)}compileAsync(w,C){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,C);async function u(K,he){await p.call(this,K.$schema);const et=this._addSchema(K,he);return et.validate||E.call(this,et)}async function p(K){K&&!this.getSchema(K)&&await u.call(this,{$ref:K},!0)}async function E(K){try{return this._compileSchemaEnv(K)}catch(he){if(!(he instanceof s.default))throw he;return M.call(this,he),await x.call(this,he.missingSchema),E.call(this,K)}}function M({missingSchema:K,missingRef:he}){if(this.refs[K])throw new Error(`AnySchema ${K} is loaded but ${he} cannot be resolved`)}async function x(K){const he=await B.call(this,K);this.refs[K]||await p.call(this,he.$schema),this.refs[K]||this.addSchema(he,K,C)}async function B(K){const he=this._loading[K];if(he)return he;try{return await(this._loading[K]=b(K))}finally{delete this._loading[K]}}}addSchema(w,C,b,u=this.opts.validateSchema){if(Array.isArray(w)){for(const E of w)this.addSchema(E,void 0,b,u);return this}let p;if(typeof w=="object"){const{schemaId:E}=this.opts;if(p=w[E],p!==void 0&&typeof p!="string")throw new Error(`schema ${E} must be string`)}return C=(0,c.normalizeId)(C||p),this._checkUnique(C),this.schemas[C]=this._addSchema(w,b,C,u,!0),this}addMetaSchema(w,C,b=this.opts.validateSchema){return this.addSchema(w,C,!0,b),this}validateSchema(w,C){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&&C){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 C;for(;typeof(C=I.call(this,w))=="string";)w=C;if(C===void 0){const{schemaId:b}=this.opts,u=new a.SchemaEnv({schema:{},schemaId:b});if(C=a.resolveSchema.call(this,u,w),!C)return;this.refs[w]=C}return C.validate||this._compileSchemaEnv(C)}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 C=I.call(this,w);return typeof C=="object"&&this._cache.delete(C.schema),delete this.schemas[w],delete this.refs[w],this}case"object":{const C=w;this._cache.delete(C);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 C of w)this.addKeyword(C);return this}addKeyword(w,C){let b;if(typeof w=="string")b=w,typeof C=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),C.keyword=b);else if(typeof w=="object"&&C===void 0){if(C=w,b=C.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(q.call(this,b,C),!C)return(0,d.eachItem)(b,p=>le.call(this,p)),this;ge.call(this,C);const u={...C,type:(0,l.getJSONTypes)(C.type),schemaType:(0,l.getJSONTypes)(C.schemaType)};return(0,d.eachItem)(b,u.type.length===0?p=>le.call(this,p,u):p=>u.type.forEach(E=>le.call(this,p,u,E))),this}getKeyword(w){const C=this.RULES.all[w];return typeof C=="object"?C.definition:!!C}removeKeyword(w){const{RULES:C}=this;delete C.keywords[w],delete C.all[w];for(const b of C.rules){const u=b.rules.findIndex(p=>p.keyword===w);u>=0&&b.rules.splice(u,1)}return this}addFormat(w,C){return typeof C=="string"&&(C=new RegExp(C)),this.formats[w]=C,this}errorsText(w=this.errors,{separator:C=", ",dataVar:b="data"}={}){return!w||w.length===0?"No errors":w.map(u=>`${b}${u.instancePath} ${u.message}`).reduce((u,p)=>u+C+p)}$dataMetaSchema(w,C){const b=this.RULES.all;w=JSON.parse(JSON.stringify(w));for(const u of C){const p=u.split("/").slice(1);let E=w;for(const M of p)E=E[M];for(const M in b){const x=b[M];if(typeof x!="object")continue;const{$data:B}=x.definition,K=E[M];B&&K&&(E[M]=je(K))}}return w}_removeAllSchemas(w,C){for(const b in w){const u=w[b];(!C||C.test(b))&&(typeof u=="string"?delete w[b]:u&&!u.meta&&(this._cache.delete(u.schema),delete w[b]))}}_addSchema(w,C,b,u=this.opts.validateSchema,p=this.opts.addUsedSchema){let E;const{schemaId:M}=this.opts;if(typeof w=="object")E=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 x=this._cache.get(w);if(x!==void 0)return x;b=(0,c.normalizeId)(E||b);const B=c.getSchemaRefs.call(this,w,b);return x=new a.SchemaEnv({schema:w,schemaId:M,meta:C,baseId:b,localRefs:B}),this._cache.set(x.schema,x),p&&!b.startsWith("#")&&(b&&this._checkUnique(b),this.refs[b]=x),u&&this.validateSchema(w,!0),x}_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 C=this.opts;this.opts=this._metaOpts;try{a.compileSchema.call(this,w)}finally{this.opts=C}}}R.ValidationError=n.default,R.MissingRefError=s.default,e.default=R;function P(j,w,C,b="error"){for(const u in j){const p=u;p in w&&this.logger[b](`${C}: option ${u}. ${j[p]}`)}}function I(j){return j=(0,c.normalizeId)(j),this.schemas[j]||this.refs[j]}function A(){const j=this.opts.schemas;if(j)if(Array.isArray(j))this.addSchema(j);else for(const w in j)this.addSchema(j[w],w)}function U(){for(const j in this.opts.formats){const w=this.opts.formats[j];w&&this.addFormat(j,w)}}function Z(j){if(Array.isArray(j)){this.addVocabulary(j);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const w in j){const C=j[w];C.keyword||(C.keyword=w),this.addKeyword(C)}}function V(){const j={...this.opts};for(const w of _)delete j[w];return j}const L={log(){},warn(){},error(){}};function W(j){if(j===!1)return L;if(j===void 0)return console;if(j.log&&j.warn&&j.error)return j;throw new Error("logger must implement log, warn and error methods")}const ce=/^[a-z_$][a-z0-9_$:-]*$/i;function q(j,w){const{RULES:C}=this;if((0,d.eachItem)(j,b=>{if(C.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(j,w,C){var b;const u=w==null?void 0:w.post;if(C&&u)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:p}=this;let E=u?p.post:p.rules.find(({type:x})=>x===C);if(E||(E={type:C,rules:[]},p.rules.push(E)),p.keywords[j]=!0,!w)return;const M={keyword:j,definition:{...w,type:(0,l.getJSONTypes)(w.type),schemaType:(0,l.getJSONTypes)(w.schemaType)}};w.before?Ce.call(this,E,M,w.before):E.rules.push(M),p.all[j]=M,(b=w.implements)===null||b===void 0||b.forEach(x=>this.addKeyword(x))}function Ce(j,w,C){const b=j.rules.findIndex(u=>u.keyword===C);b>=0?j.rules.splice(b,0,w):(j.rules.push(w),this.logger.warn(`rule ${C} is not defined`))}function ge(j){let{metaSchema:w}=j;w!==void 0&&(j.$data&&this.opts.$data&&(w=je(w)),j.validateSchema=this.compile(w,!0))}const it={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function je(j){return{anyOf:[j,it]}}})(mf);var Gi={},Wi={},Bi={};Object.defineProperty(Bi,"__esModule",{value:!0});const hP={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Bi.default=hP;var gr={};Object.defineProperty(gr,"__esModule",{value:!0});gr.callRef=gr.getValidate=void 0;const pP=Hr,Cl=de,Je=ie,br=Et,Nl=Ye,Gn=H,mP={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=Nl.resolveRef.call(c,l,s,r);if(d===void 0)throw new pP.default(n.opts.uriResolver,s,r);if(d instanceof Nl.SchemaEnv)return g(d);return y(d);function f(){if(o===l)return as(e,a,o,o.$async);const _=t.scopeValue("root",{ref:l});return as(e,(0,Je._)`${_}.validate`,l,l.$async)}function g(_){const $=Wf(e,_);as(e,$,_,_.$async)}function y(_){const $=t.scopeValue("schema",i.code.source===!0?{ref:_,code:(0,Je.stringify)(_)}:{ref:_}),m=t.name("valid"),h=e.subschema({schema:_,dataTypes:[],schemaPath:Je.nil,topSchemaRef:$,errSchemaPath:r},m);e.mergeEvaluated(h),e.ok(m)}}};function Wf(e,t){const{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,Je._)`${r.scopeValue("wrapper",{ref:t})}.validate`}gr.getValidate=Wf;function as(e,t,r,n){const{gen:s,it:o}=e,{allErrors:a,schemaEnv:i,opts:c}=o,l=c.passContext?br.default.this:Je.nil;n?d():f();function d(){if(!i.$async)throw new Error("async schema referenced by sync schema");const _=s.let("valid");s.try(()=>{s.code((0,Je._)`await ${(0,Cl.callValidateCode)(e,t,l)}`),y(t),a||s.assign(_,!0)},$=>{s.if((0,Je._)`!(${$} instanceof ${o.ValidationError})`,()=>s.throw($)),g($),a||s.assign(_,!1)}),e.ok(_)}function f(){e.result((0,Cl.callValidateCode)(e,t,l),()=>y(t),()=>g(t))}function g(_){const $=(0,Je._)`${_}.errors`;s.assign(br.default.vErrors,(0,Je._)`${br.default.vErrors} === null ? ${$} : ${br.default.vErrors}.concat(${$})`),s.assign(br.default.errors,(0,Je._)`${br.default.vErrors}.length`)}function y(_){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=Gn.mergeEvaluated.props(s,m.props,o.props));else{const h=s.var("props",(0,Je._)`${_}.evaluated.props`);o.props=Gn.mergeEvaluated.props(s,h,o.props,Je.Name)}if(o.items!==!0)if(m&&!m.dynamicItems)m.items!==void 0&&(o.items=Gn.mergeEvaluated.items(s,m.items,o.items));else{const h=s.var("items",(0,Je._)`${_}.evaluated.items`);o.items=Gn.mergeEvaluated.items(s,h,o.items,Je.Name)}}}gr.callRef=as;gr.default=mP;Object.defineProperty(Wi,"__esModule",{value:!0});const _P=Bi,gP=gr,yP=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",_P.default,gP.default];Wi.default=yP;var Ji={},Qi={};Object.defineProperty(Qi,"__esModule",{value:!0});const Ss=ie,jt=Ss.operators,Es={maximum:{okStr:"<=",ok:jt.LTE,fail:jt.GT},minimum:{okStr:">=",ok:jt.GTE,fail:jt.LT},exclusiveMaximum:{okStr:"<",ok:jt.LT,fail:jt.GTE},exclusiveMinimum:{okStr:">",ok:jt.GT,fail:jt.LTE}},vP={message:({keyword:e,schemaCode:t})=>(0,Ss.str)`must be ${Es[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,Ss._)`{comparison: ${Es[e].okStr}, limit: ${t}}`},$P={keyword:Object.keys(Es),type:"number",schemaType:"number",$data:!0,error:vP,code(e){const{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,Ss._)`${r} ${Es[t].fail} ${n} || isNaN(${r})`)}};Qi.default=$P;var Yi={};Object.defineProperty(Yi,"__esModule",{value:!0});const fn=ie,wP={message:({schemaCode:e})=>(0,fn.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,fn._)`{multipleOf: ${e}}`},bP={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:wP,code(e){const{gen:t,data:r,schemaCode:n,it:s}=e,o=s.opts.multipleOfPrecision,a=t.let("res"),i=o?(0,fn._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${o}`:(0,fn._)`${a} !== parseInt(${a})`;e.fail$data((0,fn._)`(${n} === 0 || (${a} = ${r}/${n}, ${i}))`)}};Yi.default=bP;var Xi={},ec={};Object.defineProperty(ec,"__esModule",{value:!0});function Bf(e){const t=e.length;let r=0,n=0,s;for(;n=55296&&s<=56319&&n(0,lr._)`{limit: ${e}}`},PP={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:kP,code(e){const{keyword:t,data:r,schemaCode:n,it:s}=e,o=t==="maxLength"?lr.operators.GT:lr.operators.LT,a=s.opts.unicode===!1?(0,lr._)`${r}.length`:(0,lr._)`${(0,SP.useFunc)(e.gen,EP.default)}(${r})`;e.fail$data((0,lr._)`${a} ${o} ${n}`)}};Xi.default=PP;var tc={};Object.defineProperty(tc,"__esModule",{value:!0});const TP=de,RP=H,Cr=ie,CP={message:({schemaCode:e})=>(0,Cr.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Cr._)`{pattern: ${e}}`},NP={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:CP,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,Cr._)`new RegExp`:(0,RP.useFunc)(t,c),d=t.let("valid");t.try(()=>t.assign(d,(0,Cr._)`${l}(${o}, ${i}).test(${r})`),()=>t.assign(d,!1)),e.fail$data((0,Cr._)`!${d}`)}else{const c=(0,TP.usePattern)(e,s);e.fail$data((0,Cr._)`!${c}.test(${r})`)}}};tc.default=NP;var rc={};Object.defineProperty(rc,"__esModule",{value:!0});const hn=ie,IP={message({keyword:e,schemaCode:t}){const r=e==="maxProperties"?"more":"fewer";return(0,hn.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,hn._)`{limit: ${e}}`},jP={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:IP,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxProperties"?hn.operators.GT:hn.operators.LT;e.fail$data((0,hn._)`Object.keys(${r}).length ${s} ${n}`)}};rc.default=jP;var nc={};Object.defineProperty(nc,"__esModule",{value:!0});const Xr=de,pn=ie,OP=H,AP={message:({params:{missingProperty:e}})=>(0,pn.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,pn._)`{missingProperty: ${e}}`},zP={keyword:"required",type:"object",schemaType:"array",$data:!0,error:AP,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:_}=e.it;for(const $ of r)if((y==null?void 0:y[$])===void 0&&!_.has($)){const m=a.schemaEnv.baseId+a.errSchemaPath,h=`required property "${$}" is not defined at "${m}" (strictRequired)`;(0,OP.checkStrictMode)(a,h,a.opts.strictRequired)}}function l(){if(c||o)e.block$data(pn.nil,f);else for(const y of r)(0,Xr.checkReportMissingProp)(e,y)}function d(){const y=t.let("missing");if(c||o){const _=t.let("valid",!0);e.block$data(_,()=>g(y,_)),e.ok(_)}else t.if((0,Xr.checkMissingProp)(e,r,y)),(0,Xr.reportMissingProp)(e,y),t.else()}function f(){t.forOf("prop",n,y=>{e.setParams({missingProperty:y}),t.if((0,Xr.noPropertyInData)(t,s,y,i.ownProperties),()=>e.error())})}function g(y,_){e.setParams({missingProperty:y}),t.forOf(y,n,()=>{t.assign(_,(0,Xr.propertyInData)(t,s,y,i.ownProperties)),t.if((0,pn.not)(_),()=>{e.error(),t.break()})},pn.nil)}}};nc.default=zP;var sc={};Object.defineProperty(sc,"__esModule",{value:!0});const mn=ie,MP={message({keyword:e,schemaCode:t}){const r=e==="maxItems"?"more":"fewer";return(0,mn.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,mn._)`{limit: ${e}}`},xP={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:MP,code(e){const{keyword:t,data:r,schemaCode:n}=e,s=t==="maxItems"?mn.operators.GT:mn.operators.LT;e.fail$data((0,mn._)`${r}.length ${s} ${n}`)}};sc.default=xP;var oc={},xn={};Object.defineProperty(xn,"__esModule",{value:!0});const Jf=Us;Jf.code='require("ajv/dist/runtime/equal").default';xn.default=Jf;Object.defineProperty(oc,"__esModule",{value:!0});const lo=Ae,qe=ie,qP=H,DP=xn,UP={message:({params:{i:e,j:t}})=>(0,qe.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,qe._)`{i: ${e}, j: ${t}}`},VP={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:UP,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,lo.getSchemaTypes)(o.items):[];e.block$data(c,d,(0,qe._)`${a} === false`),e.ok(c);function d(){const _=t.let("i",(0,qe._)`${r}.length`),$=t.let("j");e.setParams({i:_,j:$}),t.assign(c,!0),t.if((0,qe._)`${_} > 1`,()=>(f()?g:y)(_,$))}function f(){return l.length>0&&!l.some(_=>_==="object"||_==="array")}function g(_,$){const m=t.name("item"),h=(0,lo.checkDataTypes)(l,m,i.opts.strictNumbers,lo.DataType.Wrong),v=t.const("indices",(0,qe._)`{}`);t.for((0,qe._)`;${_}--;`,()=>{t.let(m,(0,qe._)`${r}[${_}]`),t.if(h,(0,qe._)`continue`),l.length>1&&t.if((0,qe._)`typeof ${m} == "string"`,(0,qe._)`${m} += "_"`),t.if((0,qe._)`typeof ${v}[${m}] == "number"`,()=>{t.assign($,(0,qe._)`${v}[${m}]`),e.error(),t.assign(c,!1).break()}).code((0,qe._)`${v}[${m}] = ${_}`)})}function y(_,$){const m=(0,qP.useFunc)(t,DP.default),h=t.name("outer");t.label(h).for((0,qe._)`;${_}--;`,()=>t.for((0,qe._)`${$} = ${_}; ${$}--;`,()=>t.if((0,qe._)`${m}(${r}[${_}], ${r}[${$}])`,()=>{e.error(),t.assign(c,!1).break(h)})))}}};oc.default=VP;var ac={};Object.defineProperty(ac,"__esModule",{value:!0});const Uo=ie,LP=H,FP=xn,HP={message:"must be equal to constant",params:({schemaCode:e})=>(0,Uo._)`{allowedValue: ${e}}`},ZP={keyword:"const",$data:!0,error:HP,code(e){const{gen:t,data:r,$data:n,schemaCode:s,schema:o}=e;n||o&&typeof o=="object"?e.fail$data((0,Uo._)`!${(0,LP.useFunc)(t,FP.default)}(${r}, ${s})`):e.fail((0,Uo._)`${o} !== ${r}`)}};ac.default=ZP;var ic={};Object.defineProperty(ic,"__esModule",{value:!0});const nn=ie,KP=H,GP=xn,WP={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,nn._)`{allowedValues: ${e}}`},BP={keyword:"enum",schemaType:"array",$data:!0,error:WP,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,KP.useFunc)(t,GP.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,nn.or)(...s.map((_,$)=>g(y,$)))}e.pass(d);function f(){t.assign(d,!1),t.forOf("v",o,y=>t.if((0,nn._)`${l()}(${r}, ${y})`,()=>t.assign(d,!0).break()))}function g(y,_){const $=s[_];return typeof $=="object"&&$!==null?(0,nn._)`${l()}(${r}, ${y}[${_}])`:(0,nn._)`${r} === ${$}`}}};ic.default=BP;Object.defineProperty(Ji,"__esModule",{value:!0});const JP=Qi,QP=Yi,YP=Xi,XP=tc,e1=rc,t1=nc,r1=sc,n1=oc,s1=ac,o1=ic,a1=[JP.default,QP.default,YP.default,XP.default,e1.default,t1.default,r1.default,n1.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},s1.default,o1.default];Ji.default=a1;var cc={},Zr={};Object.defineProperty(Zr,"__esModule",{value:!0});Zr.validateAdditionalItems=void 0;const ur=ie,Vo=H,i1={message:({params:{len:e}})=>(0,ur.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,ur._)`{limit: ${e}}`},c1={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:i1,code(e){const{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,Vo.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Qf(e,n)}};function Qf(e,t){const{gen:r,schema:n,data:s,keyword:o,it:a}=e;a.items=!0;const i=r.const("len",(0,ur._)`${s}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,ur._)`${i} <= ${t.length}`);else if(typeof n=="object"&&!(0,Vo.alwaysValidSchema)(a,n)){const l=r.var("valid",(0,ur._)`${i} <= ${t.length}`);r.if((0,ur.not)(l),()=>c(l)),e.ok(l)}function c(l){r.forRange("i",t.length,i,d=>{e.subschema({keyword:o,dataProp:d,dataPropType:Vo.Type.Num},l),a.allErrors||r.if((0,ur.not)(l),()=>r.break())})}}Zr.validateAdditionalItems=Qf;Zr.default=c1;var lc={},Kr={};Object.defineProperty(Kr,"__esModule",{value:!0});Kr.validateTuple=void 0;const Il=ie,is=H,l1=de,u1={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:t,it:r}=e;if(Array.isArray(t))return Yf(e,"additionalItems",t);r.items=!0,!(0,is.alwaysValidSchema)(r,t)&&e.ok((0,l1.validateArray)(e))}};function Yf(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=is.mergeEvaluated.items(n,r.length,i.items));const c=n.name("valid"),l=n.const("len",(0,Il._)`${o}.length`);r.forEach((f,g)=>{(0,is.alwaysValidSchema)(i,f)||(n.if((0,Il._)`${l} > ${g}`,()=>e.subschema({keyword:a,schemaProp:g,dataProp:g},c)),e.ok(c))});function d(f){const{opts:g,errSchemaPath:y}=i,_=r.length,$=_===f.minItems&&(_===f.maxItems||f[t]===!1);if(g.strictTuples&&!$){const m=`"${a}" is ${_}-tuple, but minItems or maxItems/${t} are not specified or different at path "${y}"`;(0,is.checkStrictMode)(i,m,g.strictTuples)}}}Kr.validateTuple=Yf;Kr.default=u1;Object.defineProperty(lc,"__esModule",{value:!0});const d1=Kr,f1={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,d1.validateTuple)(e,"items")};lc.default=f1;var uc={};Object.defineProperty(uc,"__esModule",{value:!0});const jl=ie,h1=H,p1=de,m1=Zr,_1={message:({params:{len:e}})=>(0,jl.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,jl._)`{limit: ${e}}`},g1={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:_1,code(e){const{schema:t,parentSchema:r,it:n}=e,{prefixItems:s}=r;n.items=!0,!(0,h1.alwaysValidSchema)(n,t)&&(s?(0,m1.validateAdditionalItems)(e,s):e.ok((0,p1.validateArray)(e)))}};uc.default=g1;var dc={};Object.defineProperty(dc,"__esModule",{value:!0});const st=ie,Wn=H,y1={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}}`},v1={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:y1,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,Wn.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(i!==void 0&&a>i){(0,Wn.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,Wn.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`,g)):(t.let(f,!1),g()),e.result(f,()=>e.reset());function g(){const $=t.name("_valid"),m=t.let("count",0);y($,()=>t.if($,()=>_(m)))}function y($,m){t.forRange("i",0,d,h=>{e.subschema({keyword:"contains",dataProp:h,dataPropType:Wn.Type.Num,compositeRule:!0},$),m()})}function _($){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)))}}};dc.default=v1;var Xf={};(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 g=Array.isArray(c[f])?l:d;g[f]=c[f]}return[l,d]}function a(c,l=c.schema){const{gen:d,data:f,it:g}=c;if(Object.keys(l).length===0)return;const y=d.let("missing");for(const _ in l){const $=l[_];if($.length===0)continue;const m=(0,n.propertyInData)(d,f,_,g.opts.ownProperties);c.setParams({property:_,depsCount:$.length,deps:$.join(", ")}),g.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:g,it:y}=c,_=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:g,schemaProp:$},_);c.mergeValidEvaluated(m,_)},()=>d.var(_,!0)),c.ok(_))}e.validateSchemaDeps=i,e.default=s})(Xf);var fc={};Object.defineProperty(fc,"__esModule",{value:!0});const eh=ie,$1=H,w1={message:"property name must be valid",params:({params:e})=>(0,eh._)`{propertyName: ${e.propertyName}}`},b1={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:w1,code(e){const{gen:t,schema:r,data:n,it:s}=e;if((0,$1.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,eh.not)(o),()=>{e.error(!0),s.allErrors||t.break()})}),e.ok(o)}};fc.default=b1;var Bs={};Object.defineProperty(Bs,"__esModule",{value:!0});const Bn=de,ft=ie,S1=Et,Jn=H,E1={message:"must NOT have additional properties",params:({params:e})=>(0,ft._)`{additionalProperty: ${e.additionalProperty}}`},k1={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:E1,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,Jn.alwaysValidSchema)(a,r))return;const l=(0,Bn.allSchemaProperties)(n.properties),d=(0,Bn.allSchemaProperties)(n.patternProperties);f(),e.ok((0,ft._)`${o} === ${S1.default.errors}`);function f(){t.forIn("key",s,m=>{!l.length&&!d.length?_(m):t.if(g(m),()=>_(m))})}function g(m){let h;if(l.length>8){const v=(0,Jn.schemaRefOrVal)(a,n.properties,"properties");h=(0,Bn.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,Bn.usePattern)(e,v)}.test(${m})`))),(0,ft.not)(h)}function y(m){t.code((0,ft._)`delete ${s}[${m}]`)}function _(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,Jn.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 S={keyword:"additionalProperties",dataProp:m,dataPropType:Jn.Type.Str};v===!1&&Object.assign(S,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(S,h)}}};Bs.default=k1;var hc={};Object.defineProperty(hc,"__esModule",{value:!0});const P1=_t,Ol=de,uo=H,Al=Bs,T1={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&&Al.default.code(new P1.KeywordCxt(o,Al.default,"additionalProperties"));const a=(0,Ol.allSchemaProperties)(r);for(const f of a)o.definedProperties.add(f);o.opts.unevaluated&&a.length&&o.props!==!0&&(o.props=uo.mergeEvaluated.props(t,(0,uo.toHash)(a),o.props));const i=a.filter(f=>!(0,uo.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,Ol.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)}}};hc.default=T1;var pc={};Object.defineProperty(pc,"__esModule",{value:!0});const zl=de,Qn=ie,Ml=H,xl=H,R1={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,zl.allSchemaProperties)(r),c=i.filter($=>(0,Ml.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 Qn.Name)&&(o.props=(0,xl.evaluatedPropsToName)(t,o.props));const{props:f}=o;g();function g(){for(const $ of i)l&&y($),o.allErrors?_($):(t.var(d,!0),_($),t.if(d))}function y($){for(const m in l)new RegExp($).test(m)&&(0,Ml.checkStrictMode)(o,`property ${m} matches pattern ${$} (use allowMatchingProperties)`)}function _($){t.forIn("key",n,m=>{t.if((0,Qn._)`${(0,zl.usePattern)(e,$)}.test(${m})`,()=>{const h=c.includes($);h||e.subschema({keyword:"patternProperties",schemaProp:$,dataProp:m,dataPropType:xl.Type.Str},d),o.opts.unevaluated&&f!==!0?t.assign((0,Qn._)`${f}[${m}]`,!0):!h&&!o.allErrors&&t.if((0,Qn.not)(d),()=>t.break())})})}}};pc.default=R1;var mc={};Object.defineProperty(mc,"__esModule",{value:!0});const C1=H,N1={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:r,it:n}=e;if((0,C1.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"}};mc.default=N1;var _c={};Object.defineProperty(_c,"__esModule",{value:!0});const I1=de,j1={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:I1.validateUnion,error:{message:"must match a schema in anyOf"}};_c.default=j1;var gc={};Object.defineProperty(gc,"__esModule",{value:!0});const cs=ie,O1=H,A1={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,cs._)`{passingSchemas: ${e.passing}}`},z1={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:A1,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 g;(0,O1.alwaysValidSchema)(s,d)?t.var(c,!0):g=e.subschema({keyword:"oneOf",schemaProp:f,compositeRule:!0},c),f>0&&t.if((0,cs._)`${c} && ${a}`).assign(a,!1).assign(i,(0,cs._)`[${i}, ${f}]`).else(),t.if(c,()=>{t.assign(a,!0),t.assign(i,f),g&&e.mergeEvaluated(g,cs.Name)})})}}};gc.default=z1;var yc={};Object.defineProperty(yc,"__esModule",{value:!0});const M1=H,x1={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,M1.alwaysValidSchema)(n,o))return;const i=e.subschema({keyword:"allOf",schemaProp:a},s);e.ok(s),e.mergeEvaluated(i)})}};yc.default=x1;var vc={};Object.defineProperty(vc,"__esModule",{value:!0});const ks=ie,th=H,q1={message:({params:e})=>(0,ks.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,ks._)`{failingKeyword: ${e.ifClause}}`},D1={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:q1,code(e){const{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,th.checkStrictMode)(n,'"if" without "then" and "else" is ignored');const s=ql(n,"then"),o=ql(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,ks.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 g=e.subschema({keyword:d},i);t.assign(a,i),e.mergeValidEvaluated(g,a),f?t.assign(f,(0,ks._)`${d}`):e.setParams({ifClause:d})}}}};function ql(e,t){const r=e.schema[t];return r!==void 0&&!(0,th.alwaysValidSchema)(e,r)}vc.default=D1;var $c={};Object.defineProperty($c,"__esModule",{value:!0});const U1=H,V1={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,U1.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};$c.default=V1;Object.defineProperty(cc,"__esModule",{value:!0});const L1=Zr,F1=lc,H1=Kr,Z1=uc,K1=dc,G1=Xf,W1=fc,B1=Bs,J1=hc,Q1=pc,Y1=mc,X1=_c,eT=gc,tT=yc,rT=vc,nT=$c;function sT(e=!1){const t=[Y1.default,X1.default,eT.default,tT.default,rT.default,nT.default,W1.default,B1.default,G1.default,J1.default,Q1.default];return e?t.push(F1.default,Z1.default):t.push(L1.default,H1.default),t.push(K1.default),t}cc.default=sT;var wc={},bc={};Object.defineProperty(bc,"__esModule",{value:!0});const Ie=ie,oT={message:({schemaCode:e})=>(0,Ie.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,Ie._)`{format: ${e}}`},aT={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:oT,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?g():y();function g(){const _=r.scopeValue("formats",{ref:f.formats,code:c.code.formats}),$=r.const("fDef",(0,Ie._)`${_}[${a}]`),m=r.let("fType"),h=r.let("format");r.if((0,Ie._)`typeof ${$} == "object" && !(${$} instanceof RegExp)`,()=>r.assign(m,(0,Ie._)`${$}.type || "string"`).assign(h,(0,Ie._)`${$}.validate`),()=>r.assign(m,(0,Ie._)`"string"`).assign(h,$)),e.fail$data((0,Ie.or)(v(),S()));function v(){return c.strictSchema===!1?Ie.nil:(0,Ie._)`${a} && !${h}`}function S(){const R=d.$async?(0,Ie._)`(${$}.async ? await ${h}(${n}) : ${h}(${n}))`:(0,Ie._)`${h}(${n})`,P=(0,Ie._)`(typeof ${h} == "function" ? ${R} : ${h}.test(${n}))`;return(0,Ie._)`${h} && ${h} !== true && ${m} === ${t} && !${P}`}}function y(){const _=f.formats[o];if(!_){v();return}if(_===!0)return;const[$,m,h]=S(_);$===t&&e.pass(R());function v(){if(c.strictSchema===!1){f.logger.warn(P());return}throw new Error(P());function P(){return`unknown format "${o}" ignored in schema at path "${l}"`}}function S(P){const I=P instanceof RegExp?(0,Ie.regexpCode)(P):c.code.formats?(0,Ie._)`${c.code.formats}${(0,Ie.getProperty)(o)}`:void 0,A=r.scopeValue("formats",{key:o,ref:P,code:I});return typeof P=="object"&&!(P instanceof RegExp)?[P.type||"string",P.validate,(0,Ie._)`${A}.validate`]:["string",P,A]}function R(){if(typeof _=="object"&&!(_ instanceof RegExp)&&_.async){if(!d.$async)throw new Error("async format in sync schema");return(0,Ie._)`await ${h}(${n})`}return typeof m=="function"?(0,Ie._)`${h}(${n})`:(0,Ie._)`${h}.test(${n})`}}}};bc.default=aT;Object.defineProperty(wc,"__esModule",{value:!0});const iT=bc,cT=[iT.default];wc.default=cT;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(Gi,"__esModule",{value:!0});const lT=Wi,uT=Ji,dT=cc,fT=wc,Dl=qr,hT=[lT.default,uT.default,(0,dT.default)(),fT.default,Dl.metadataVocabulary,Dl.contentVocabulary];Gi.default=hT;var Sc={},Js={};Object.defineProperty(Js,"__esModule",{value:!0});Js.DiscrError=void 0;var Ul;(function(e){e.Tag="tag",e.Mapping="mapping"})(Ul||(Js.DiscrError=Ul={}));Object.defineProperty(Sc,"__esModule",{value:!0});const Pr=ie,Lo=Js,Vl=Ye,pT=Hr,mT=H,_T={message:({params:{discrError:e,tagName:t}})=>e===Lo.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,Pr._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},gT={keyword:"discriminator",type:"object",schemaType:"object",error:_T,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,Pr._)`${r}${(0,Pr.getProperty)(i)}`);t.if((0,Pr._)`typeof ${l} == "string"`,()=>d(),()=>e.error(!1,{discrError:Lo.DiscrError.Tag,tag:l,tagName:i})),e.ok(c);function d(){const y=g();t.if(!1);for(const _ in y)t.elseIf((0,Pr._)`${l} === ${_}`),t.assign(c,f(y[_]));t.else(),e.error(!1,{discrError:Lo.DiscrError.Mapping,tag:l,tagName:i}),t.endIf()}function f(y){const _=t.name("valid"),$=e.subschema({keyword:"oneOf",schemaProp:y},_);return e.mergeEvaluated($,Pr.Name),_}function g(){var y;const _={},$=h(s);let m=!0;for(let R=0;Rthis.addVocabulary(_)),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const _=this.opts.$data?this.$dataMetaSchema(o,a):o;this.addMetaSchema(_,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=Mn;Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return f.default}});var g=Hr;Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return g.default}})})(zo,zo.exports);var kT=zo.exports;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.formatLimitDefinition=void 0;const t=kT,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:g}=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 S=c.scopeValue("formats",{ref:_.formats,code:y.code.formats}),R=c.const("fmt",(0,r._)`${S}[${$.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 S=$.schema,R=_.formats[S];if(!R||R===!0)return;if(typeof R!="object"||R instanceof RegExp||typeof R.compare!="function")throw new Error(`"${f}": format "${S}" does not define "compare" function`);const P=c.scopeValue("formats",{key:S,ref:R,code:y.code.formats?(0,r._)`${y.code.formats}${(0,r.getProperty)(S)}`:void 0});i.fail$data(v(P))}function v(S){return(0,r._)`${S}.compare(${l}, ${d}) ${s[f].fail} 0`}},dependencies:["format"]};const a=i=>(i.addKeyword(e.formatLimitDefinition),i);e.default=a})(pf);(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const r=hf,n=pf,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,g]=d.mode==="fast"?[r.fastFormats,a]:[r.fullFormats,o],y=d.formats||r.formatNames;return c(l,y,f,g),d.keywords&&(0,n.default)(l),l};i.get=(l,d="full")=>{const g=(d==="fast"?r.fastFormats:r.fullFormats)[l];if(!g)throw new Error(`Unknown format "${l}"`);return g};function c(l,d,f,g){var y,_;(y=(_=l.opts.code).formats)!==null&&y!==void 0||(_.formats=(0,s._)`require("ajv-formats/dist/formats").${g}`);for(const $ of d)l.addFormat($,f[$])}e.exports=t=i,Object.defineProperty(t,"__esModule",{value:!0}),t.default=i})(Ao,Ao.exports);var PT=Ao.exports;const TT=Ql(PT);function RT(){const e=new hE({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return TT(e),e}class CT{constructor(t){this._ajv=t??RT()}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 NT{constructor(t){this._client=t}async*callToolStream(t,r=fr,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 Y(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 Y(re.InvalidParams,`Structured content does not match the tool's output schema: ${d.errorMessage}`)};return}}catch(d){if(d instanceof Y){yield{type:"error",error:d};return}yield{type:"error",error:new Y(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 IT(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 jT(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 ls(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&&ls(o,r[s])}}if(Array.isArray(e.anyOf))for(const r of e.anyOf)typeof r!="boolean"&&ls(r,t);if(Array.isArray(e.oneOf))for(const r of e.oneOf)typeof r!="boolean"&&ls(r,t)}}function OT(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 AT extends cd{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 CT,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",Da,t.tools,async()=>(await this.listTools()).tools),t.prompts&&((o=(s=this._serverCapabilities)==null?void 0:s.prompts)!=null&&o.listChanged)&&this._setupListChangedHandler("prompts",Ma,t.prompts,async()=>(await this.listPrompts()).prompts),t.resources&&((i=(a=this._serverCapabilities)==null?void 0:a.resources)!=null&&i.listChanged)&&this._setupListChangedHandler("resources",Ia,t.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new NT(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=jv(this._capabilities,t)}setRequestHandler(t,r){const n=ad(t),s=n==null?void 0:n.method;if(!s)throw new Error("Schema is missing a method literal");const o=id(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,S;const d=Ot(nd,c);if(!d.success){const R=d.error instanceof Error?d.error.message:String(d.error);throw new Y(re.InvalidParams,`Invalid elicitation request: ${R}`)}const{params:f}=d.data;f.mode=f.mode??"form";const{supportsFormMode:g,supportsUrlMode:y}=OT(this._capabilities.elicitation);if(f.mode==="form"&&!g)throw new Y(re.InvalidParams,"Client does not support form-mode elicitation requests");if(f.mode==="url"&&!y)throw new Y(re.InvalidParams,"Client does not support URL-mode elicitation requests");const _=await Promise.resolve(r(c,l));if(f.task){const R=Ot(yn,_);if(!R.success){const P=R.error instanceof Error?R.error.message:String(R.error);throw new Y(re.InvalidParams,`Invalid task creation result: ${P}`)}return R.data}const $=Ot(sd,_);if(!$.success){const R=$.error instanceof Error?$.error.message:String($.error);throw new Y(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&&(S=(v=this._capabilities.elicitation)==null?void 0:v.form)!=null&&S.applyDefaults)try{ls(h,m.content)}catch{}return m};return super.setRequestHandler(t,i)}if(a==="sampling/createMessage"){const i=async(c,l)=>{const d=Ot(Ua,c);if(!d.success){const m=d.error instanceof Error?d.error.message:String(d.error);throw new Y(re.InvalidParams,`Invalid sampling request: ${m}`)}const{params:f}=d.data,g=await Promise.resolve(r(c,l));if(f.task){const m=Ot(yn,g);if(!m.success){const h=m.error instanceof Error?m.error.message:String(m.error);throw new Y(re.InvalidParams,`Invalid task creation result: ${h}`)}return m.data}const _=f.tools||f.toolChoice?rd:td,$=Ot(_,g);if(!$.success){const m=$.error instanceof Error?$.error.message:String($.error);throw new Y(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}},Du,r);if(n===void 0)throw new Error(`Server sent invalid initialize result: ${n}`);if(!iy.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;IT((n=(r=this._serverCapabilities)==null?void 0:r.tasks)==null?void 0:n.requests,t,"Server")}assertTaskHandlerCapability(t){var r;this._capabilities&&jT((r=this._capabilities.tasks)==null?void 0:r.requests,t,"Client")}async ping(t){return this.request({method:"ping"},Tr,t)}async complete(t,r){return this.request({method:"completion/complete",params:t},od,r)}async setLoggingLevel(t,r){return this.request({method:"logging/setLevel",params:{level:t}},Tr,r)}async getPrompt(t,r){return this.request({method:"prompts/get",params:t},Qu,r)}async listPrompts(t,r){return this.request({method:"prompts/list",params:t},ja,r)}async listResources(t,r){return this.request({method:"resources/list",params:t},Ta,r)}async listResourceTemplates(t,r){return this.request({method:"resources/templates/list",params:t},Ra,r)}async readResource(t,r){return this.request({method:"resources/read",params:t},Na,r)}async subscribeResource(t,r){return this.request({method:"resources/subscribe",params:t},Tr,r)}async unsubscribeResource(t,r){return this.request({method:"resources/unsubscribe",params:t},Tr,r)}async callTool(t,r=fr,n){if(this.isToolTaskRequired(t.name))throw new Y(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 Y(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 Y(re.InvalidParams,`Structured content does not match the tool's output schema: ${a.errorMessage}`)}catch(a){throw a instanceof Y?a:new Y(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},qa,r);return this.cacheToolMetadata(n.tools),n}_setupListChangedHandler(t,r,n,s){const o=Wy.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 g=f instanceof Error?f:new Error(String(f));c(g,null)}},d=()=>{if(i){const f=this._listChangedDebounceTimers.get(t);f&&clearTimeout(f);const g=setTimeout(l,i);this._listChangedDebounceTimers.set(t,g)}else l()};this.setNotificationHandler(r,d)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}}var Ec={};/*! + * content-type + * Copyright(c) 2015 Douglas Christopher Wilson + * MIT Licensed + */var Ll=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,zT=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,rh=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,MT=/\\([\u000b\u0020-\u00ff])/g,xT=/([\\"])/g,nh=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;Ec.format=qT;Ec.parse=DT;function qT(e){if(!e||typeof e!="object")throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!nh.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&&!zT.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(xT,"\\$1")+'"'}function LT(e){this.parameters=Object.create(null),this.type=e}function FT(e){if(e)try{return Ec.parse(e).type}catch{const t=(e.split(";",1)[0]??"").trim().toLowerCase();return t===""||e.slice(t.length).includes(",")?void 0:t}}function Fo(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function HT(e=fetch,t){return t?async(r,n)=>{const s={...t,...n,headers:n!=null&&n.headers?{...Fo(t.headers),...Fo(n.headers)}:t.headers};return e(r,s)}:e}let kc;kc=globalThis.crypto;async function ZT(e){return(await kc).getRandomValues(new Uint8Array(e))}async function KT(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 GT(e),r=await WT(t);return{code_verifier:t,code_challenge:r}}const De=pg().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:oy.custom,message:"URL must be parseable",fatal:!0}),rp}).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"}),JT=Le({resource:k().url(),authorization_servers:D(De).optional(),jwks_uri:k().url().optional(),scopes_supported:D(k()).optional(),bearer_methods_supported:D(k()).optional(),resource_signing_alg_values_supported:D(k()).optional(),resource_name:k().optional(),resource_documentation:k().optional(),resource_policy_uri:k().url().optional(),resource_tos_uri:k().url().optional(),tls_client_certificate_bound_access_tokens:me().optional(),authorization_details_types_supported:D(k()).optional(),dpop_signing_alg_values_supported:D(k()).optional(),dpop_bound_access_tokens_required:me().optional()}),sh=Le({issuer:k(),authorization_endpoint:De,token_endpoint:De,registration_endpoint:De.optional(),scopes_supported:D(k()).optional(),response_types_supported:D(k()),response_modes_supported:D(k()).optional(),grant_types_supported:D(k()).optional(),token_endpoint_auth_methods_supported:D(k()).optional(),token_endpoint_auth_signing_alg_values_supported:D(k()).optional(),service_documentation:De.optional(),revocation_endpoint:De.optional(),revocation_endpoint_auth_methods_supported:D(k()).optional(),revocation_endpoint_auth_signing_alg_values_supported:D(k()).optional(),introspection_endpoint:k().optional(),introspection_endpoint_auth_methods_supported:D(k()).optional(),introspection_endpoint_auth_signing_alg_values_supported:D(k()).optional(),code_challenge_methods_supported:D(k()).optional(),client_id_metadata_document_supported:me().optional()}),QT=Le({issuer:k(),authorization_endpoint:De,token_endpoint:De,userinfo_endpoint:De.optional(),jwks_uri:De,registration_endpoint:De.optional(),scopes_supported:D(k()).optional(),response_types_supported:D(k()),response_modes_supported:D(k()).optional(),grant_types_supported:D(k()).optional(),acr_values_supported:D(k()).optional(),subject_types_supported:D(k()),id_token_signing_alg_values_supported:D(k()),id_token_encryption_alg_values_supported:D(k()).optional(),id_token_encryption_enc_values_supported:D(k()).optional(),userinfo_signing_alg_values_supported:D(k()).optional(),userinfo_encryption_alg_values_supported:D(k()).optional(),userinfo_encryption_enc_values_supported:D(k()).optional(),request_object_signing_alg_values_supported:D(k()).optional(),request_object_encryption_alg_values_supported:D(k()).optional(),request_object_encryption_enc_values_supported:D(k()).optional(),token_endpoint_auth_methods_supported:D(k()).optional(),token_endpoint_auth_signing_alg_values_supported:D(k()).optional(),display_values_supported:D(k()).optional(),claim_types_supported:D(k()).optional(),claims_supported:D(k()).optional(),service_documentation:k().optional(),claims_locales_supported:D(k()).optional(),ui_locales_supported:D(k()).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:De.optional(),op_tos_uri:De.optional(),client_id_metadata_document_supported:me().optional()}),YT=O({...QT.shape,...sh.pick({code_challenge_methods_supported:!0}).shape}),XT=O({access_token:k(),id_token:k().optional(),token_type:k(),expires_in:ay().optional(),scope:k().optional(),refresh_token:k().optional()}).strip(),eR=O({error:k(),error_description:k().optional(),error_uri:k().optional()}),Fl=De.optional().or(N("").transform(()=>{})),tR=O({redirect_uris:D(De),token_endpoint_auth_method:k().optional(),grant_types:D(k()).optional(),response_types:D(k()).optional(),client_name:k().optional(),client_uri:De.optional(),logo_uri:Fl,scope:k().optional(),contacts:D(k()).optional(),tos_uri:Fl,policy_uri:k().optional(),jwks_uri:De.optional(),jwks:ha().optional(),software_id:k().optional(),software_version:k().optional(),software_statement:k().optional()}).strip(),rR=O({client_id:k(),client_secret:k().optional(),client_id_issued_at:oe().optional(),client_secret_expires_at:oe().optional()}).strip(),nR=tR.merge(rR);O({error:k(),error_description:k().optional()}).strip();O({token:k(),token_type_hint:k().optional()}).strip();function sR(e){const t=typeof e=="string"?new URL(e):new URL(e.href);return t.hash="",t}function oR({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 gR(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=mR(t,s.pathname);a=new URL(c,(n==null?void 0:n.metadataServerUrl)??s),a.search=s.search}let i=await Zl(a,o,r);if(!(n!=null&&n.metadataUrl)&&_R(i,s.pathname)){const c=new URL(`/.well-known/${t}`,s);i=await Zl(c,o,r)}return i}function yR(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 ih(e,{fetchFn:t=fetch,protocolVersion:r=zs}={}){var o;const n={"MCP-Protocol-Version":r,Accept:"application/json"},s=yR(e);for(const{url:a,type:i}of s){const c=await Pc(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"?sh.parse(await c.json()):YT.parse(await c.json())}}}async function vR(e,t){let r,n;try{r=await ah(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 ih(n,{fetchFn:t==null?void 0:t.fetchFn});return{authorizationServerUrl:n,authorizationServerMetadata:s,resourceMetadata:r}}async function $R(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(fo))throw new Error(`Incompatible auth server: does not support response type ${fo}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(ho))throw new Error(`Incompatible auth server: does not support code challenge method ${ho}`)}else i=new URL("/authorize",e);const c=await BT(),l=c.code_verifier,d=c.code_challenge;return i.searchParams.set("response_type",fo),i.searchParams.set("client_id",r.client_id),i.searchParams.set("code_challenge",d),i.searchParams.set("code_challenge_method",ho),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 wR(e,t,r){return new URLSearchParams({grant_type:"authorization_code",code:e,code_verifier:t,redirect_uri:String(r)})}async function ch(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=cR(n,d);lR(f,n,c,r)}const l=await(a??fetch)(i,{method:"POST",headers:c,body:r});if(!l.ok)throw await oh(l);return XT.parse(await l.json())}async function bR(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 ch(e,{metadata:t,tokenRequestParams:i,clientInformation:r,addClientAuthentication:o,resource:s,fetchFn:a});return{refresh_token:n,...c}}async function SR(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=wR(s,l,e.redirectUrl)}const c=await e.clientInformation();return ch(t,{metadata:r,tokenRequestParams:i,clientInformation:c??void 0,addClientAuthentication:e.addClientAuthentication,resource:n,fetchFn:o})}async function ER(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 oh(a);return nR.parse(await a.json())}class _o 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 Kl=10,kR=13,nr=32;function go(e){}function PR(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=go,onError:r=go,onRetry:n=go,onComment:s,maxBufferSize:o}=e,a=[];let i=0,c=!0,l,d="",f=0,g,y=!1;function _(P){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,P.charCodeAt(0)===239&&P.charCodeAt(1)===187&&P.charCodeAt(2)===191&&(P=P.slice(3))),a.length===0){const U=m(P);U!==""&&(a.push(U),i=U.length),$();return}if(P.indexOf(` +`)===-1&&P.indexOf("\r")===-1){a.push(P),i+=P.length,$();return}a.push(P);const I=a.join("");a.length=0,i=0;const A=m(I);A!==""&&(a.push(A),i=A.length),$()}function $(){o!==void 0&&(i+d.length<=o||(y=!0,a.length=0,i=0,l=void 0,d="",f=0,g=void 0,r(new _o(`Buffered data exceeded max buffer size of ${o} characters`,{type:"max-buffer-size-exceeded"}))))}function m(P){let I=0;if(P.indexOf("\r")===-1){let A=P.indexOf(` +`,I);for(;A!==-1;){if(I===A){f>0&&t({id:l,event:g,data:d}),l=void 0,d="",f=0,g=void 0,I=A+1,A=P.indexOf(` +`,I);continue}const U=P.charCodeAt(I);if(Gl(P,I,U)){const Z=P.charCodeAt(I+5)===nr?I+6:I+5,V=P.slice(Z,A);if(f===0&&P.charCodeAt(A+1)===Kl){t({id:l,event:g,data:V}),l=void 0,d="",g=void 0,I=A+2,A=P.indexOf(` +`,I);continue}d=f===0?V:`${d} +${V}`,f++}else Wl(P,I,U)?g=P.slice(P.charCodeAt(I+6)===nr?I+7:I+6,A)||void 0:h(P,I,A);I=A+1,A=P.indexOf(` +`,I)}return P.slice(I)}for(;I20?`${P.slice(0,20)}…`:P}"`,{type:"unknown-field",field:P,value:I,line:A}));break}}function S(){f>0&&t({id:l,event:g,data:d}),l=void 0,d="",f=0,g=void 0}function R(P={}){if(P.consume&&a.length>0){const I=a.join("");h(I,0,I.length)}c=!0,l=void 0,d="",f=0,g=void 0,a.length=0,i=0,y=!1}return{feed:_,reset:R}}function Gl(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 Wl(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 TR extends TransformStream{constructor({onError:t,onRetry:r,onComment:n,maxBufferSize:s}={}){let o;super({start(a){o=PR({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 RR={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class Er extends Error{constructor(t,r){super(`Streamable HTTP error: ${r}`),this.code=t}}class CR{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=HT(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)??RR}async _authThenStart(){var r;if(!this._authProvider)throw new Sr("No auth provider");let t;try{t=await Yn(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 Sr;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=Fo((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 Er(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,g,y;try{const _=t.pipeThrough(new TextDecoderStream).pipeThrough(new TR({onRetry:h=>{this._serverRetryMs=h}})).getReader();for(;;){const{value:h,done:v}=await _.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 S=Xn.parse(JSON.parse(h.data));en(S)&&(c=!0,o!==void 0&&(S.id=o)),(d=this.onmessage)==null||d.call(this,S)}catch(S){(f=this.onerror)==null||f.call(this,S)}}(n||i)&&!c&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:a,onresumptiontoken:s,replayMessageId:o},0)}catch(_){if((g=this.onerror)==null||g.call(this,new Error(`SSE stream disconnected: ${_}`)),(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 Sr("No auth provider");if(await Yn(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Sr("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:Eo(t)?t.id:void 0}).catch(S=>{var R;return(R=this.onerror)==null?void 0:R.call(this,S)});return}const f=await this._commonHeaders();f.set("content-type","application/json"),f.set("accept","application/json, text/event-stream");const g={...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(_&&(this._sessionId=_),!y.ok){const S=await y.text().catch(()=>null);if(y.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Er(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:R,scope:P}=Hl(y);if(this._resourceMetadataUrl=R,this._scope=P,await Yn(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Sr;return this._hasCompletedAuthFlow=!0,this.send(t)}if(y.status===403&&this._authProvider){const{resourceMetadataUrl:R,scope:P,error:I}=Hl(y);if(I==="insufficient_scope"){const A=y.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===A)throw new Er(403,"Server returned 403 after trying upscoping");if(P&&(this._scope=P),R&&(this._resourceMetadataUrl=R),this._lastUpscopingHeader=A??void 0,await Yn(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new Sr;return this.send(t)}}throw new Er(y.status,`Error POSTing to endpoint: ${S}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,y.status===202){await((s=y.body)==null?void 0:s.cancel()),Sy(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(S=>{var R;return(R=this.onerror)==null?void 0:R.call(this,S)});return}const m=(Array.isArray(t)?t:[t]).filter(S=>"method"in S&&"id"in S&&S.id!==void 0).length>0,h=y.headers.get("content-type"),v=FT(h);if(m)if(v==="text/event-stream")this._handleSseStream(y.body,{onresumptiontoken:d},!1);else if(v==="application/json"){const S=await y.json(),R=Array.isArray(S)?S.map(P=>Xn.parse(P)):[Xn.parse(S)];for(const P of R)(o=this.onmessage)==null||o.call(this,P)}else throw await((a=y.body)==null?void 0:a.cancel()),new Er(-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 Er(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 NR="https://mcp.excalidraw.com/mcp",IR="mcp.excalidraw.com",jR="/api/v1/chat/mcp-apps/excalidraw",lh="ui://excalidraw/mcp-app.html",OR=["read_me","create_view"],uh=new Set(["export_to_excalidraw","save_checkpoint","read_checkpoint"]),AR=256*1024,zR=1024*1024,MR={excalidraw:{id:"excalidraw",endpoint:NR,hostname:IR,resourceUri:lh,modelTools:OR,appTools:uh}};function xR(e){return MR[e]}function qR(){return new URL(mh(jR),window.location.origin)}class DR{constructor(){ae(this,"client",new AT({name:"pwc-chat-mcp-app-host",version:"1"}));ae(this,"transport",new CR(qR(),{requestInit:{credentials:"include"}}));ae(this,"connected");ae(this,"bytes",0)}connect(){return this.connected??(this.connected=this.client.connect(this.transport)),this.connected}async readResource(t){if(t!==lh)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,1024*1024);const s=await VR(n.text);return{text:n.text,digest:s}}async callTool(t,r){if(!uh.has(t))throw new Error("Unapproved App tool");const n=JSON.stringify(r);this.consume(n),await this.connect();const s=await this.client.callTool({name:t,arguments:r});return this.consume(JSON.stringify(s)),s}close(){this.transport.close()}consume(t,r=AR){const n=new TextEncoder().encode(t).byteLength;if(n>r||this.bytes+n>zR)throw new Error("App request exceeds host limit");this.bytes+=n}}let Bl;function UR(){return Bl??(Bl=new DR),Bl}async function VR(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("")}const Jl=e=>Math.max(240,Math.min(720,e)),LR=({block:e})=>{const t=X.useRef(null),r=X.useRef(null),n=X.useRef(!1),s=X.useRef(e),o=X.useRef(e.status);s.current=e,o.current=e.status;const[a,i]=X.useState(),[c,l]=X.useState(e.status),[d,f]=X.useState(Jl(e.height)),[g,y]=X.useState(!1),[_,$]=X.useState(0),m=X.useRef(null),h=e.input.elements,v=!!e.permissions.clipboardWrite,S=X.useCallback(()=>{y(!1),document.fullscreenElement&&document.exitFullscreen()},[]),R=X.useCallback(()=>{var I,A;if(g){S();return}y(!0),(A=(I=m.current)==null?void 0:I.requestFullscreen)==null||A.call(I).catch(()=>{})},[S,g]);X.useEffect(()=>{if(!g)return;const I=m.current,A=Z=>{Z.key==="Escape"&&(document.fullscreenElement||S())},U=()=>{document.fullscreenElement||y(!1)};return window.addEventListener("keydown",A),document.addEventListener("fullscreenchange",U),()=>{window.removeEventListener("keydown",A),document.removeEventListener("fullscreenchange",U),document.fullscreenElement===I&&document.exitFullscreen()}},[S,g]),X.useEffect(()=>{xR(e.provider);{l("unavailable");return}},[_,e.provider,e.resource_uri]),X.useEffect(()=>{if(!a||!t.current||c!=="ready")return;const I=t.current,A=new t$(null,{name:"Papers with Code",version:"1"},{serverTools:{},openLinks:{},logging:{},...v?{clipboard:{write:{}}}:{}},{hostContext:{theme:document.documentElement.dataset.theme==="dark"?"dark":"light",displayMode:g?"fullscreen":"inline"}});return A.oncalltool=async({name:U,arguments:Z})=>{if(s.current.public_fork&&U!=="export_to_excalidraw")throw new Error("Shared diagrams cannot mutate owner state");return UR().callTool(U,Z??{})},A.onopenlink=async({url:U})=>{const Z=new URL(U);if(Z.protocol!=="https:"||Z.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(Z.href,"_blank","noopener,noreferrer"),{}},A.onsizechange=({height:U})=>{typeof U=="number"&&f(Jl(U))},A.oninitialized=()=>{n.current=!0;try{const U=JSON.parse(h);A.sendToolInput({arguments:{elements:Array.isArray(U)?u$(U):U}}),A.sendToolResult(s.current.result)}catch{l("error")}},r.current=A,A.connect(new Xv(I.contentWindow??void 0,I.contentWindow)).catch(()=>l("error")),()=>{n.current=!1,A.teardownResource({}).catch(()=>{}),r.current===A&&(r.current=null)}},[a,c,g,h,v]),X.useEffect(()=>{var I;c!=="ready"||!n.current||(I=r.current)==null||I.sendToolResult(e.result).catch(()=>{})},[e.result,c]);const P=c==="unavailable"||c==="incompatible"||c==="error";return T.jsxs("section",{ref:m,className:`chat-mcp-app${g?" chat-mcp-app-fullscreen":""}`,"aria-label":"Interactive Excalidraw diagram",children:[T.jsx("header",{children:T.jsx("button",{type:"button",onClick:R,children:g?"Exit fullscreen":"Fullscreen"})}),c==="loading"&&T.jsx("div",{className:"chat-mcp-loading",role:"status",children:"Loading interactive diagram…"}),P&&T.jsxs("div",{className:"chat-mcp-error",children:["Interactive diagram unavailable. The cited text answer is still available.",T.jsx("button",{type:"button",onClick:()=>$(I=>I+1),children:"Retry diagram"})]}),a&&c==="ready"&&T.jsx("iframe",{ref:t,title:"Interactive Excalidraw diagram",sandbox:"allow-scripts",allow:v?"clipboard-write":void 0,srcDoc:a,style:{height:d}})]})};function FR(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 HR(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 ZR(e,t=240){const r=e.content.trim();return r.length<=t?r:`${r.slice(0,t).trimEnd()}…`}const KR="https://huggingface.co/pro",GR="https://huggingface.co/docs/inference-providers/pricing",WR="https://paperswithcode.co/chat",dh=()=>T.jsx("span",{className:"chat-caret"}),BR=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},JR=e=>{var y,_;const t=e.currentTarget,r=t.ownerDocument,n=(y=r.caretPositionFromPoint)==null?void 0:y.call(r,e.clientX,e.clientY),s=n?null:(_=r.caretRangeFromPoint)==null?void 0:_.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(T.jsxs("span",{className:"chat-inline-paper-mention",children:[T.jsx(jh,{size:13,"aria-hidden":"true"}),T.jsx(ru,{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)),T.jsx(T.Fragment,{children:r})},YR=({block:e,papers:t,citations:r,webCitations:n,onToggle:s})=>e.active?T.jsxs("div",{className:"chat-reason-live",children:[T.jsxs("div",{className:"chat-reason-live-head",children:[T.jsx(ra,{})," ",T.jsx("span",{children:"Thinking…"})]}),T.jsxs("div",{className:"chat-reason-live-body chat-answer chat-reason-markdown",children:[T.jsx(yo,{text:e.text,streaming:!0,papers:t,citations:r,webCitations:n}),T.jsx(dh,{})]})]}):T.jsxs("div",{className:"chat-reason-done",children:[T.jsxs("button",{type:"button",className:"chat-reason-done-head",onClick:s,"aria-expanded":e.open,children:[T.jsx(bh,{}),T.jsx("span",{children:"Thought for a few seconds"}),T.jsx(tu,{open:e.open})]}),e.open&&T.jsx("div",{className:"chat-reason-done-body chat-answer chat-reason-markdown",children:T.jsx(yo,{text:e.text,papers:t,citations:r,webCitations:n})})]}),XR=({block:e,papers:t,onToggle:r})=>{var d,f,g,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(_=>_.text).join(""))??"",l=n?"running…":s?`${e.status} · ${e.took_ms??0} ms`:`${e.hits} results · ${e.took_ms} ms`;return T.jsxs("div",{className:`chat-tool${n?" chat-tool-running":""}${o?" chat-tool-failed":""}`,children:[T.jsxs("button",{type:"button",className:"chat-tool-head",onClick:r,disabled:n,"aria-expanded":n?void 0:e.open,children:[T.jsxs("span",{className:"chat-tool-head-left",children:[n?T.jsx(ra,{}):T.jsx(Sh,{}),T.jsx("code",{className:"chat-tool-name",children:e.name}),T.jsx("span",{className:"chat-tool-query",children:s?i:`("${a}")`})]}),T.jsxs("span",{className:"chat-tool-head-right",children:[T.jsx("span",{className:"chat-tool-status",children:l}),!n&&T.jsx(tu,{open:e.open})]})]}),!n&&e.open&&T.jsxs("div",{className:"chat-tool-body",children:[T.jsxs("div",{className:"chat-tool-args",children:[T.jsx("span",{className:"chat-tool-label",children:"arguments"}),T.jsx("pre",{children:JSON.stringify(e.args,null,2)})]}),s?T.jsxs(T.Fragment,{children:[T.jsxs("div",{className:"chat-tool-output-head",children:[T.jsx("span",{className:"chat-tool-label",children:"result"}),T.jsx("button",{type:"button",className:"chat-tool-copy",onClick:()=>void navigator.clipboard.writeText(c),children:"Copy"})]}),T.jsx("pre",{className:"chat-tool-output",children:T.jsx("code",{children:c})}),((f=e.metadata)==null?void 0:f.output_truncated)&&T.jsx("div",{className:"chat-tool-truncated",children:"Output was truncated."})]}):T.jsxs(T.Fragment,{children:[T.jsxs("div",{className:"chat-tool-label chat-tool-results-label",children:["returned ",((g=e.results)==null?void 0:g.length)??0," papers"]}),T.jsx("ol",{className:"chat-tool-results",children:(y=e.results)==null?void 0:y.map(_=>T.jsxs("li",{className:"chat-hit",children:[T.jsx("div",{className:"chat-hit-top",children:T.jsx(nu,{routeId:_.route_id,paper:t[_.route_id],className:"chat-hit-title",children:_.title})}),T.jsx("div",{className:"chat-hit-meta",children:[FR(_.metadata),HR(_.metadata)].filter(Boolean).join(" · ")}),T.jsxs("div",{className:"chat-hit-snippet",children:[ZR(_),_.content_truncated&&T.jsx("span",{className:"chat-hit-truncated",children:" (truncated)"})]})]},_.route_id))})]})]})]})},eC=({block:e,papers:t,citations:r,webCitations:n,streaming:s})=>T.jsxs("div",{className:"chat-answer",children:[T.jsx(yo,{text:e.text,streaming:s,papers:t,citations:r,webCitations:n}),s&&!!e.text.trim()&&T.jsx(dh,{})]}),tC=({block:e})=>T.jsx(LR,{block:e}),fh=e=>{const t=X.useRef(null),r=X.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 X.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}},rC=({id:e,text:t,paperSelection:r,editNotice:n,onCancel:s,onResend:o,onResendDraft:a})=>{const[i,c]=X.useState(t),[l,d]=X.useState(r),[f,g]=X.useState(!1),{textareaRef:y,resize:_}=fh(t);X.useLayoutEffect(_,[_,i]);const $=!!i.trim()&&i.length<=8e3,m=()=>{if(!$||f)return;g(!0),((a==null?void 0:a({text:i,paperMentions:[],...l?{paperSelection:l}:{}}))??(o==null?void 0:o(i))??!1)||g(!1)};return T.jsx("div",{className:"chat-msg chat-msg-user chat-msg-user-editing","data-message-id":e,children:T.jsxs("div",{className:"chat-inline-editor",children:[l&&T.jsx(Is,{selection:l,editable:!0,onRemove:()=>d(void 0)}),T.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&&T.jsx("div",{className:"chat-inline-editor-notice",children:n}),T.jsxs("div",{className:"chat-inline-editor-actions",children:[T.jsx("button",{type:"button",onClick:s,children:"Cancel"}),T.jsx("button",{type:"button",className:"chat-inline-editor-send",disabled:!$||f,onClick:m,children:"Send"})]})]})})},nC=({id:e,text:t,paperMentions:r,paperSelection:n,enabled:s,editNotice:o,onCancel:a,onResend:i,onResendDraft:c})=>{const[l,d]=X.useState({text:t,paperMentions:r,...n?{paperSelection:n}:{}}),[f,g]=X.useState(!1),[y,_]=X.useState(0),{textareaRef:$,resize:m}=fh(t),h=Yl({draft:l,onChange:d,enabled:s,textareaRef:$});X.useLayoutEffect(m,[m,l.text]);const v=!!l.text.trim()&&l.text.length<=8e3&&(s||l.paperMentions.length===0),S=()=>{if(!v||f)return;g(!0),((c==null?void 0:c(l))??(i==null?void 0:i(l.text))??!1)||g(!1)};return T.jsx("div",{className:"chat-msg chat-msg-user chat-msg-user-editing","data-message-id":e,children:T.jsxs("div",{className:"chat-inline-editor",children:[l.paperSelection&&T.jsx(Is,{selection:l.paperSelection,editable:!0,onRemove:()=>d({text:l.text,paperMentions:l.paperMentions})}),T.jsxs("div",{className:"chat-inline-editor-textarea-wrap",children:[T.jsx(Xl,{text:l.text,mentions:l.paperMentions,scrollTop:y,variant:"editor"}),T.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=>_(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(),S()))}}),T.jsx(eu,{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&&T.jsx("div",{className:"chat-inline-editor-notice",role:"status",children:"Paper mentions are currently disabled. Remove them before sending."}),o&&T.jsx("div",{className:"chat-inline-editor-notice",children:o}),T.jsxs("div",{className:"chat-inline-editor-actions",children:[T.jsx("button",{type:"button",onClick:a,children:"Cancel"}),T.jsx("button",{type:"button",className:"chat-inline-editor-send",disabled:!v||f,onClick:S,children:"Send"})]})]})})},wC=({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[g,y]=X.useState(!1),_=X.useRef(null);X.useEffect(()=>()=>{_.current!==null&&window.clearTimeout(_.current)},[]);const $=async()=>{var m;if((m=navigator.clipboard)!=null&&m.writeText)try{await navigator.clipboard.writeText(t),y(!0),_.current!==null&&window.clearTimeout(_.current),_.current=window.setTimeout(()=>y(!1),1500)}catch{}};return a?!s&&r.length===0?T.jsx(rC,{id:e,text:t,paperSelection:n,editNotice:i,onCancel:l,onResend:d,onResendDraft:f}):T.jsx(nC,{id:e,text:t,paperMentions:r,paperSelection:n,enabled:s,editNotice:i,onCancel:l,onResend:d,onResendDraft:f}):T.jsx("div",{className:"chat-msg chat-msg-user","data-message-id":e,children:T.jsxs("div",{className:"chat-user-message-wrap",children:[n&&T.jsx(Is,{selection:n}),T.jsx("div",{className:"chat-bubble",onDoubleClick:JR,children:T.jsx(QR,{text:t,mentions:r})}),T.jsxs("div",{className:"chat-user-actions",children:[T.jsx("button",{type:"button",className:"chat-user-action","aria-label":g?"Message copied":"Copy message",title:g?"Copied":"Copy",onClick:()=>void $(),children:g?T.jsx(_h,{"aria-hidden":"true"}):T.jsx(Oh,{"aria-hidden":"true"})}),o&&T.jsx("button",{type:"button",className:"chat-user-action","aria-label":"Edit message",title:"Edit",onClick:c,children:T.jsx(Ah,{"aria-hidden":"true"})})]})]})})},bC=({msg:e,papers:t,onToggleBlock:r,onArchiveOldChats:n,onArchiveOldestChats:s,archivePending:o=null,hfBilling:a=null,openRouterFallbackEnabled:i=!1,feedbackEnabled:c=!1})=>{var A,U,Z;const[l,d]=X.useState(null),[f,g]=X.useState(!1),[y,_]=X.useState(!1),[$,m]=X.useState(!1),[h,v]=X.useState(""),S=X.useRef(null),R=`chat-feedback-panel-${e.id}`,P=c&&!e.streaming&&!e.error&&!!((A=e.blocks)!=null&&A.some(V=>V.kind==="answer"&&V.text.trim()));X.useEffect(()=>{var V;$&&((V=S.current)==null||V.focus())},[$]);const I=async(V,L)=>{if(!f){g(!0),_(!1);try{L===void 0?await Tc.reportFeedback(e.id,V):await Tc.reportFeedback(e.id,V,L),d(V),m(!1),v("")}catch{_(!0)}finally{g(!1)}}};return T.jsx("div",{className:"chat-msg chat-msg-assistant",children:T.jsxs("div",{className:"chat-msg-blocks",children:[(U=e.blocks)==null?void 0:U.map((V,L)=>{var Ce;const W=`${e.id}-${L}`,ce="citations"in V&&V.citations!==void 0?V.citations:e.citations??[],q=Object.fromEntries(ce.filter(ge=>(ge.kind??"paper")==="paper"&&ge.route_id).map(ge=>[ge.route_id,ge])),le=Object.fromEntries(ce.filter(ge=>ge.kind==="web"&&ge.url).map(ge=>[ge.url,ge]));return V.kind==="reasoning"?T.jsx(YR,{block:V,papers:t,citations:q,webCitations:le,onToggle:()=>r(e.id,L)},W):V.kind==="tool"?T.jsx(XR,{block:V,papers:t,onToggle:()=>r(e.id,L)},W):V.kind==="app"?T.jsx(tC,{block:V},W):T.jsx(eC,{block:V,papers:t,citations:q,webCitations:le,streaming:!!(e.streaming&&L===(((Ce=e.blocks)==null?void 0:Ce.length)??0)-1)},W)}),BR(e)&&T.jsx("div",{className:"chat-waiting",role:"status","aria-live":"polite",children:T.jsx("span",{className:"chat-thinking",children:(((Z=e.blocks)==null?void 0:Z.length)??0)===0?e.status??"Thinking…":"Thinking…"})}),e.error&&T.jsxs("div",{className:"chat-error",children:[T.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??"")&&T.jsx("a",{href:"/settings",children:"Re-sign in with Hugging Face"}),e.errorCode==="hf_inference_billing_exhausted"&&T.jsxs(T.Fragment,{children:[(a==null?void 0:a.account_type)==="Free"&&!a.bill_to?T.jsx("a",{href:KR,target:"_blank",rel:"noreferrer",children:"Upgrade to Hugging Face PRO — $9/month for 20× more included credits"}):T.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"}),T.jsx("a",{href:GR,target:"_blank",rel:"noreferrer",children:"Inference Providers pricing and billing details"})]}),e.errorCode==="openrouter_monthly_budget_exhausted"&&T.jsxs(T.Fragment,{children:[i?T.jsx("span",{children:"This response started on the shared allowance. Your connected OpenRouter key will be used when you explicitly retry."}):T.jsx("a",{href:"/settings#openrouter-byok",children:"Connect your own OpenRouter key"}),T.jsx("span",{children:"Or select a Hugging Face-backed model and explicitly retry."})]}),e.errorCode==="openrouter_staging_funding_disabled"&&T.jsx("a",{href:WR,children:"Continue on paperswithcode.co"}),e.errorCode==="openrouter_unavailable"&&T.jsxs(T.Fragment,{children:[T.jsx("a",{href:"/settings#openrouter-byok",children:"Bring your own key in Settings"}),T.jsx("a",{href:"https://github.com/huggingface/paperswithcode-feedback",target:"_blank",rel:"noreferrer",children:"File an issue"})]}),e.errorCode==="openrouter_byok_billing_error"&&T.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??"")&&T.jsx("a",{href:"/settings#openrouter-byok",children:"Review OpenRouter settings"}),e.errorCode==="chat_session_quota_exceeded"&&(n||s)&&T.jsxs("span",{className:"chat-error-actions",children:[n&&T.jsx("button",{type:"button",disabled:o!==null,onClick:n,children:o==="old"?"Archiving…":"Archive chats older than 30 days"}),s&&T.jsx("button",{type:"button",disabled:o!==null,onClick:s,children:o==="oldest"?"Archiving…":"Archive oldest 50 chats"})]})]}),!e.streaming&&e.finishReason&&e.finishReason!=="success"&&T.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," ")}).`}),P&&T.jsxs("div",{className:"chat-feedback","aria-label":"Rate this response",children:[T.jsx("span",{className:"chat-feedback-label",children:l===null?"Was this helpful?":"Thanks for your feedback"}),T.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:T.jsx(Mh,{"aria-hidden":"true"})}),T.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:()=>{_(!1),m(!0)},children:T.jsx(zh,{"aria-hidden":"true"})}),y&&T.jsx("span",{className:"chat-feedback-error",role:"status",children:"Couldn’t send feedback."})]}),P&&$&&T.jsxs("div",{className:"chat-feedback-panel",id:R,role:"group","aria-labelledby":`${R}-title`,children:[T.jsx("div",{className:"chat-feedback-panel-title",id:`${R}-title`,children:"Additional feedback"}),T.jsx("label",{className:"chat-feedback-panel-label",htmlFor:`${R}-comment`,children:"Tell us what went wrong (optional)"}),T.jsx("textarea",{ref:S,id:`${R}-comment`,className:"chat-feedback-comment",value:h,maxLength:500,rows:4,disabled:f,onChange:V=>v(V.target.value),onKeyDown:V=>{V.key==="Escape"&&(V.preventDefault(),m(!1))}}),T.jsxs("div",{className:"chat-feedback-panel-actions",children:[T.jsx("button",{type:"button",className:"chat-feedback-skip",disabled:f,onClick:()=>void I(!1),children:"Skip"}),T.jsx("button",{type:"button",className:"chat-feedback-submit",disabled:f,onClick:()=>void I(!1,h.trim()||void 0),children:f?"Submitting…":"Submit"})]})]})]})})};export{bC as A,_C as C,wC as U};