@agent-deck/backend 1.11.5 → 1.11.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -186,9 +186,9 @@ npx @piotr-agier/google-drive-mcp auth`})]}),(0,V.jsxs)(`li`,{children:[`Set `,(
|
|
|
186
186
|
|
|
187
187
|
${F.data.oauth.authorizationUrl?`Authorization URL: ${F.data.oauth.authorizationUrl}`:``}
|
|
188
188
|
${F.data.oauth.tokenUrl?`Token URL: ${F.data.oauth.tokenUrl}`:``}
|
|
189
|
-
${F.data.oauth.issuer?`Issuer: ${F.data.oauth.issuer}`:``}`;A({title:`OAuth Setup Instructions`,description:e,duration:1e4})},children:`📋 Setup Instructions`})]})]}),(0,V.jsxs)(`div`,{className:`mt-2 text-xs`,children:[(0,V.jsx)(`p`,{children:(0,V.jsx)(`strong`,{children:`💡 Next Steps:`})}),(0,V.jsxs)(`ul`,{className:`list-disc list-inside ml-2 space-y-1`,children:[(0,V.jsx)(`li`,{children:`For OAuth servers: Provide OAuth credentials in service settings`}),(0,V.jsx)(`li`,{children:`For SSE servers: We'll automatically use the correct protocol`}),(0,V.jsx)(`li`,{children:`For connection issues: Verify the server URL and status`})]})]})]}),L&&(0,V.jsxs)(`div`,{className:`mt-3 p-3 bg-red-500/20 rounded`,children:[(0,V.jsx)(`p`,{children:(0,V.jsx)(`strong`,{children:`❌ Discovery Failed`})}),(0,V.jsx)(`p`,{children:`Could not analyze MCP server configuration`}),(0,V.jsx)(`pre`,{className:`text-xs overflow-x-auto`,children:L instanceof Error?L.message:String(L)})]})]})]}),!de&&!ie&&!ce&&e.type===`a2a`&&!ue&&(0,V.jsxs)(`div`,{className:`bg-yellow-500/20 border border-yellow-500/30 rounded-lg p-4`,children:[(0,V.jsx)(`h3`,{className:`text-yellow-300 font-semibold mb-2`,children:`Agent Details Not Available`}),(0,V.jsxs)(`p`,{className:`text-yellow-200 text-sm`,children:[`Successfully connected to A2A agent at `,M?.url,`, but no manifest was found.`]}),(0,V.jsxs)(`div`,{className:`text-yellow-200 text-xs mt-2`,children:[(0,V.jsx)(`p`,{children:(0,V.jsx)(`strong`,{children:`This could mean:`})}),(0,V.jsxs)(`ul`,{className:`list-disc list-inside ml-2 space-y-1`,children:[(0,V.jsx)(`li`,{children:`The agent doesn't provide a manifest`}),(0,V.jsx)(`li`,{children:`Manifest endpoint is not implemented`}),(0,V.jsx)(`li`,{children:`Agent requires specific authentication`})]})]})]})]})]})})}function TE({open:e,onOpenChange:t}){let[n,r]=(0,b.useState)(null),[i,a]=(0,b.useState)(null),[o,s]=(0,b.useState)(null),[c,l]=(0,b.useState)(!1),u=Et(),{toast:d}=on(),f=()=>{r(null),a(null),s(null),l(!1)},p=Ht({mutationFn:async()=>{if(!n)throw Error(`Choose a bundle file first`);let e=await n.text(),t;try{t=JSON.parse(e)}catch{throw Error(`File is not valid JSON`)}return Vm(t)},onSuccess:e=>{s(e),u.invalidateQueries({queryKey:[`/api/decks`]}),u.invalidateQueries({queryKey:[`/api/services`]}),u.invalidateQueries({queryKey:[`/api/playbooks`]}),u.invalidateQueries({queryKey:[`/api/playbooks/collection`]}),u.invalidateQueries({queryKey:[`/api/credentials/collection`]}),u.invalidateQueries({queryKey:[`/api/collection/warnings`]}),d({title:`Import complete`,description:Wm(e)})},onError:e=>{d({title:`Import failed`,description:e.message,variant:`destructive`})}}),m=async e=>{if(r(e),s(null),!e){a(null);return}try{let t=await e.text(),n=JSON.parse(t);a(`${n.services?.length??0} services · ${n.playbooks?.length??0} playbooks · ${n.decks?.length??0} decks`)}catch{a(`Invalid JSON`)}};return(0,V.jsx)(Dp,{open:e,onOpenChange:e=>{e||f(),t(e)},children:(0,V.jsxs)(Ap,{className:`sm:max-w-lg border-border bg-[#161612] text-[#E8F6F4]`,children:[(0,V.jsxs)(jp,{children:[(0,V.jsx)(Mp,{children:`Import bundle`}),(0,V.jsx)(Np,{asChild:!0,children:(0,V.jsxs)(`div`,{className:`space-y-2 text-left text-sm text-[#A8C4C0]`,children:[(0,V.jsx)(`p`,{children:`Adds MCP, playbooks, and decks from a JSON file.`}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`font-medium text-amber-200/90`,children:`Notes`}),(0,V.jsxs)(`ul`,{className:`mt-1 list-disc space-y-0.5 pl-4`,children:[(0,V.jsx)(`li`,{children:`Same name as an existing card or deck is skipped (linked only).`}),(0,V.jsx)(`li`,{children:`No credentials or secrets — re-enter keys and reconnect OAuth.`})]})]})]})})]}),(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(zp,{htmlFor:`bundle-file`,children:`Bundle file`}),(0,V.jsx)(uu,{id:`bundle-file`,type:`file`,accept:`.json,.agent-deck.json,application/json`,className:`cursor-pointer bg-white/5 border-white/20`,onChange:e=>m(e.target.files?.[0]??null),"data-testid":`input-import-bundle`}),i&&(0,V.jsx)(`p`,{className:`text-xs text-[#A8C4C0]`,"data-testid":`import-preview`,children:i})]}),!o&&(0,V.jsx)(G,{onClick:()=>p.mutate(),disabled:!n||p.isPending||i===`Invalid JSON`,className:`rounded-full border px-6 text-sm font-semibold hover:opacity-90`,style:{background:`#C4B643`,borderColor:`#C4B643`,color:`black`},"data-testid":`button-import-apply`,children:p.isPending?`Importing…`:`Import`}),o&&(0,V.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-white/10 bg-white/5 p-3 text-sm`,"data-testid":`import-report`,children:[(0,V.jsx)(`p`,{className:`font-medium`,children:Wm(o)}),o.servicesNeedingOauth.length>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`text-amber-200`,children:`Needs OAuth reconnect:`}),(0,V.jsx)(`ul`,{className:`list-disc pl-5 text-[#A8C4C0]`,children:o.servicesNeedingOauth.map(e=>(0,V.jsx)(`li`,{children:e},e))})]}),o.warnings.length>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`text-amber-200`,children:`Warnings:`}),(0,V.jsx)(`ul`,{className:`list-disc pl-5 text-[#A8C4C0]`,children:o.warnings.map(e=>(0,V.jsx)(`li`,{children:e},e))})]}),(0,V.jsx)(G,{variant:`outline`,size:`sm`,className:`rounded-full border border-white/20 text-white hover:bg-white/10`,onClick:()=>l(e=>!e),children:c?`Hide id map`:`Show id map`}),c&&(0,V.jsx)(`pre`,{className:`max-h-40 overflow-auto rounded bg-black/40 p-2 text-xs`,children:JSON.stringify(o.idMap,null,2)}),(0,V.jsx)(G,{className:`rounded-full border px-6 text-sm font-semibold hover:opacity-90`,style:{background:`#C4B643`,borderColor:`#C4B643`,color:`black`},onClick:()=>{f(),t(!1)},children:`Done`})]})]})]})})}function EE(){let[e,t]=(0,b.useState)(`connecting`),[n,r]=(0,b.useState)(null),i=(0,b.useRef)(null),a=(0,b.useRef)(null),o=Et();return(0,b.useEffect)(()=>{let e=`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}/api/ws/events`,n=()=>{try{let s=new WebSocket(e);i.current=s,s.onopen=()=>{console.log(`WebSocket connected`),t(`connected`)},s.onmessage=e=>{try{let n=JSON.parse(e.data);r(n),n.type===`deck_update`?(console.log(`Received deck update:`,n),o.invalidateQueries({queryKey:[`/api/decks`]})):n.type===`service_update`?(console.log(`Received service update:`,n),pE(o,typeof n.data?.serviceId==`string`?n.data.serviceId:void 0)):n.type===`connection_status`&&t(n.status===`connected`?`connected`:`disconnected`)}catch(e){console.error(`Failed to parse WebSocket message:`,e)}},s.onclose=()=>{console.log(`WebSocket disconnected`),t(`disconnected`),a.current=setTimeout(()=>{console.log(`Attempting to reconnect WebSocket...`),t(`connecting`),n()},3e3)},s.onerror=e=>{console.error(`WebSocket error:`,e),t(`disconnected`)}}catch(e){console.error(`Failed to connect WebSocket:`,e),t(`disconnected`)}};n();let s=e=>{e.origin===window.location.origin&&hE(e.data)&&pE(o,e.data.serviceId)};return window.addEventListener(`message`,s),()=>{window.removeEventListener(`message`,s),a.current&&clearTimeout(a.current),i.current&&i.current.readyState===WebSocket.OPEN&&i.current.close()}},[o]),{connectionStatus:e,lastMessage:n}}async function DE(e,t){return(await(await H(`GET`,`/api/playbooks/dependents/check?${e===`credential`?`credentialId=${encodeURIComponent(t)}`:`serviceId=${encodeURIComponent(t)}`}`)).json()).data??[]}function OE(e){let[t,n]=(0,b.useState)(null),[r,i]=(0,b.useState)(null),[a,o]=(0,b.useState)(null),[s,c]=(0,b.useState)(!1),l=Et(),{toast:u}=on(),d=()=>{if(!e)throw Error(`Select a deck to edit first`);return e},f=Ht({mutationFn:async e=>{let t=d(),n=(await(await H(`GET`,`/api/decks`)).json()).data?.find(e=>e.id===t);if(!n)throw Error(`Selected deck not found`);if(n.services?.some(t=>t.id===e))throw Error(`Service is already in the deck`);let r=n.services?.length??0;return H(`POST`,`/api/decks/${t}/services`,{serviceId:e,position:r})},onSuccess:()=>{l.invalidateQueries({queryKey:[`/api/decks`]}),u({title:`Service added to deck`,description:`${t?.name||`Service`} has been added to the deck.`})},onError:e=>{u({title:`Failed to add service`,description:e.message,variant:`destructive`})}}),p=Ht({mutationFn:async e=>{let t=d();if(((await(await H(`GET`,`/api/decks`)).json()).data?.find(e=>e.id===t))?.credentials?.some(t=>t.id===e))throw Error(`API key is already in the deck`);return H(`POST`,`/api/decks/${t}/credentials`,{credentialId:e})},onSuccess:()=>{l.invalidateQueries({queryKey:[`/api/decks`]}),u({title:`API key added to deck`,description:`${r?.label||`API key`} is scoped to this deck.`})},onError:e=>{u({title:`Failed to add API key`,description:e.message,variant:`destructive`})}}),m=Ht({mutationFn:async e=>{let t=d();if(((await(await H(`GET`,`/api/decks`)).json()).data?.find(e=>e.id===t))?.playbooks?.some(t=>t.id===e))throw Error(`Playbook is already in the deck`);return H(`POST`,`/api/decks/${t}/playbooks`,{playbookId:e})},onSuccess:()=>{l.invalidateQueries({queryKey:[`/api/decks`]}),u({title:`Playbook added to deck`,description:`${a?.title||`Playbook`} is on this deck.`})},onError:e=>{u({title:`Failed to add playbook`,description:e.message,variant:`destructive`})}}),h=Ht({mutationFn:async e=>{let t=await DE(`service`,e);if(t.length>0){let e=t.map(e=>e.title).join(`, `);if(!window.confirm(`Warning: ${t.length} playbook(s) depend on this MCP (${e}). Remove from deck anyway?`))throw Error(`Cancelled`)}return H(`DELETE`,`/api/decks/${d()}/services`,{serviceId:e})},onSuccess:()=>{l.invalidateQueries({queryKey:[`/api/decks`]}),u({title:`Service removed from deck`,description:`${t?.name||`Service`} has been removed from the deck.`})},onError:e=>{e.message!==`Cancelled`&&u({title:`Failed to remove service`,description:e.message,variant:`destructive`})}}),g=Ht({mutationFn:async e=>{let t=await DE(`credential`,e);if(t.length>0){let e=t.map(e=>e.title).join(`, `);if(!window.confirm(`Warning: ${t.length} playbook(s) depend on this API key (${e}). Remove from deck anyway?`))throw Error(`Cancelled`)}return H(`DELETE`,`/api/decks/${d()}/credentials`,{credentialId:e})},onSuccess:()=>{l.invalidateQueries({queryKey:[`/api/decks`]}),u({title:`API key removed from deck`,description:`${r?.label||`API key`} is no longer on this deck.`})},onError:e=>{e.message!==`Cancelled`&&u({title:`Failed to remove API key`,description:e.message,variant:`destructive`})}}),_=Ht({mutationFn:async e=>H(`DELETE`,`/api/decks/${d()}/playbooks`,{playbookId:e}),onSuccess:()=>{l.invalidateQueries({queryKey:[`/api/decks`]}),u({title:`Playbook removed from deck`,description:`${a?.title||`Playbook`} is no longer on this deck.`})},onError:e=>{u({title:`Failed to remove playbook`,description:e.message,variant:`destructive`})}}),v=(e,t)=>{e.currentTarget instanceof HTMLElement&&(e.currentTarget.style.opacity=t)},y=(e,t)=>{e.dataTransfer.setData(`text/plain`,t.id),e.dataTransfer.setData(`application/json`,JSON.stringify(t)),e.dataTransfer.effectAllowed=t.fromDeck?`move`:`copy`},x=(e,t,r=!1)=>{n(t),i(null),o(null),c(r),y(e,{kind:`service`,id:t.id,fromDeck:r}),v(e,`0.5`)},S=(e,t,r=!1)=>{i(t),n(null),o(null),c(r),y(e,{kind:`credential`,id:t.id,fromDeck:r}),v(e,`0.5`)},C=(e,t,r=!1)=>{o(t),n(null),i(null),c(r),y(e,{kind:`playbook`,id:t.id,fromDeck:r}),v(e,`0.5`)},w=e=>{n(null),i(null),o(null),v(e,`1`)},T=e=>{if(e.kind===`service`){e.fromDeck?h.mutate(e.id):f.mutate(e.id);return}if(e.kind===`credential`){e.fromDeck?g.mutate(e.id):p.mutate(e.id);return}e.fromDeck?_.mutate(e.id):m.mutate(e.id)};return{draggedService:t,draggedCredential:r,draggedPlaybook:a,isDraggingFromDeck:s,handleDragStart:x,handleCredentialDragStart:S,handlePlaybookDragStart:C,handleDragEnd:w,handleDrop:e=>{e.preventDefault();let r=e.dataTransfer.getData(`application/json`);if(r){try{T(JSON.parse(r))}catch{let n=e.dataTransfer.getData(`text/plain`);n&&t&&f.mutate(n)}n(null),i(null),o(null),c(!1)}},handleGlobalDrop:e=>{e.preventDefault();let t=e.dataTransfer.getData(`application/json`);if(t){try{let e=JSON.parse(t);e.fromDeck&&T(e)}catch{}n(null),i(null),o(null),c(!1)}},isDropping:f.isPending||p.isPending||m.isPending||h.isPending||g.isPending||_.isPending}}var kE=`agent-deck-editing-deck-id`;function AE(e){let[t,n]=(0,b.useState)(()=>typeof window>`u`?null:localStorage.getItem(kE));return(0,b.useEffect)(()=>{if(e.length!==0&&!(t&&e.some(e=>e.id===t))){let t=e[0].id;n(t),localStorage.setItem(kE,t)}},[e,t]),{editingDeck:e.find(e=>e.id===t)??null,editingDeckId:t,setEditingDeckId:e=>{n(e),localStorage.setItem(kE,e)}}}function jE(e,[t,n]){return Math.min(n,Math.max(t,e))}function ME(e){let t=b.useRef({value:e,previous:e});return b.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var NE=[` `,`Enter`,`ArrowUp`,`ArrowDown`],PE=[` `,`Enter`],FE=`Select`,[IE,LE,RE]=Sn(FE),[zE,BE]=fn(FE,[RE,Ec]),VE=Ec(),[HE,UE]=zE(FE),[WE,GE]=zE(FE),KE=e=>{let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m}=e,h=VE(t),[g,_]=b.useState(null),[v,y]=b.useState(null),[x,S]=b.useState(!1),C=Vp(l),[w,T]=Zn({prop:r,defaultProp:i??!1,onChange:a,caller:FE}),[E,D]=Zn({prop:o,defaultProp:s,onChange:c,caller:FE}),O=b.useRef(null),k=!g||m||!!g.closest(`form`),[A,j]=b.useState(new Set),M=Array.from(A).map(e=>e.props.value).join(`;`);return(0,V.jsx)(Hc,{...h,children:(0,V.jsxs)(HE,{required:p,scope:t,trigger:g,onTriggerChange:_,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:x,onValueNodeHasChildrenChange:S,contentId:to(),value:E,onValueChange:D,open:w,onOpenChange:T,dir:C,triggerPointerDownPosRef:O,disabled:f,children:[(0,V.jsx)(IE.Provider,{scope:t,children:(0,V.jsx)(WE,{scope:e.__scopeSelect,onNativeOptionAdd:b.useCallback(e=>{j(t=>new Set(t).add(e))},[]),onNativeOptionRemove:b.useCallback(e=>{j(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),k?(0,V.jsxs)(VD,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:d,value:E,onChange:e=>D(e.target.value),disabled:f,form:m,children:[E===void 0?(0,V.jsx)(`option`,{value:``}):null,Array.from(A)]},M):null]})})};KE.displayName=FE;var qE=`SelectTrigger`,JE=b.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=VE(n),o=UE(qE,n),s=o.disabled||r,c=un(t,o.onTriggerChange),l=LE(n),u=b.useRef(`touch`),[d,f,p]=UD(e=>{let t=l().filter(e=>!e.disabled),n=WD(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),m=e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,V.jsx)(Uc,{asChild:!0,...a,children:(0,V.jsx)(Cn.button,{type:`button`,role:`combobox`,"aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":HD(o.value)?``:void 0,...i,ref:c,onClick:U(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:U(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(m(e),e.preventDefault())}),onKeyDown:U(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&NE.includes(e.key)&&(m(),e.preventDefault())})})})});JE.displayName=qE;var YE=`SelectValue`,XE=b.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=UE(YE,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=un(t,c.onValueNodeChange);return Hn(()=>{l(u)},[l,u]),(0,V.jsx)(Cn.span,{...s,ref:d,style:{pointerEvents:`none`},children:HD(c.value)?(0,V.jsx)(V.Fragment,{children:o}):a})});XE.displayName=YE;var ZE=`SelectIcon`,QE=b.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,V.jsx)(Cn.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});QE.displayName=ZE;var $E=`SelectPortal`,eD=e=>(0,V.jsx)(Wn,{asChild:!0,...e});eD.displayName=$E;var tD=`SelectContent`,nD=b.forwardRef((e,t)=>{let n=UE(tD,e.__scopeSelect),[r,i]=b.useState();if(Hn(()=>{i(new DocumentFragment)},[]),!n.open){let t=r;return t?sn.createPortal((0,V.jsx)(iD,{scope:e.__scopeSelect,children:(0,V.jsx)(IE.Slot,{scope:e.__scopeSelect,children:(0,V.jsx)(`div`,{children:e.children})})}),t):null}return(0,V.jsx)(cD,{...e,ref:t})});nD.displayName=tD;var rD=10,[iD,aD]=zE(tD),oD=`SelectContentImpl`,sD=mn(`SelectContent.RemoveScroll`),cD=b.forwardRef((e,t)=>{let{__scopeSelect:n,position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=UE(tD,n),[y,x]=b.useState(null),[S,C]=b.useState(null),w=un(t,e=>x(e)),[T,E]=b.useState(null),[D,O]=b.useState(null),k=LE(n),[A,j]=b.useState(!1),M=b.useRef(!1);b.useEffect(()=>{if(y)return zu(y)},[y]),pu();let N=b.useCallback(e=>{let[t,...n]=k().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&S&&(S.scrollTop=0),n===r&&S&&(S.scrollTop=S.scrollHeight),n?.focus(),document.activeElement!==i))return},[k,S]),P=b.useCallback(()=>N([T,y]),[N,T,y]);b.useEffect(()=>{A&&P()},[A,P]);let{onOpenChange:F,triggerPointerDownPosRef:I}=v;b.useEffect(()=>{if(y){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(I.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(I.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():y.contains(n.target)||F(!1),document.removeEventListener(`pointermove`,t),I.current=null};return I.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[y,F,I]),b.useEffect(()=>{let e=()=>F(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[F]);let[L,ee]=UD(e=>{let t=k().filter(e=>!e.disabled),n=WD(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),te=b.useCallback((e,t,n)=>{let r=!M.current&&!n;(v.value!==void 0&&v.value===t||r)&&(E(e),r&&(M.current=!0))},[v.value]),ne=b.useCallback(()=>y?.focus(),[y]),R=b.useCallback((e,t,n)=>{let r=!M.current&&!n;(v.value!==void 0&&v.value===t||r)&&O(e)},[v.value]),z=r===`popper`?fD:uD,B=z===fD?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,V.jsx)(iD,{scope:n,content:y,viewport:S,onViewportChange:C,itemRefCallback:te,selectedItem:T,onItemLeave:ne,itemTextRefCallback:R,focusSelectedItem:P,selectedItemText:D,position:r,isPositioned:A,searchRef:L,children:(0,V.jsx)(qd,{as:sD,allowPinchZoom:!0,children:(0,V.jsx)(yu,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:U(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,V.jsx)(Nn,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,V.jsx)(z,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...B,onPlaced:()=>j(!0),ref:w,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:U(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&ee(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=k().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>N(t)),e.preventDefault()}})})})})})})});cD.displayName=oD;var lD=`SelectItemAlignedPosition`,uD=b.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=UE(tD,n),o=aD(tD,n),[s,c]=b.useState(null),[l,u]=b.useState(null),d=un(t,e=>u(e)),f=LE(n),p=b.useRef(!1),m=b.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=b.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-rD,d=jE(a,[rD,Math.max(rD,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-rD,d=jE(a,[rD,Math.max(rD,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-rD*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),C=window.getComputedStyle(h),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-rD,D=c-E,O=g.offsetHeight/2,k=g.offsetTop+O,A=m+v+k,j=x-A;if(A<=E){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+h.offsetTop+(e?w:0)+O)+j;s.style.height=t+`px`,h.scrollTop=A-E+h.offsetTop}s.style.margin=`${rD}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);Hn(()=>y(),[y]);let[x,S]=b.useState();Hn(()=>{l&&S(window.getComputedStyle(l).zIndex)},[l]);let C=b.useCallback(e=>{e&&m.current===!0&&(y(),v?.(),m.current=!1)},[y,v]);return(0,V.jsx)(pD,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:C,children:(0,V.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:x},children:(0,V.jsx)(Cn.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});uD.displayName=lD;var dD=`SelectPopperPosition`,fD=b.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=rD,...a}=e,o=VE(n);return(0,V.jsx)(Wc,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});fD.displayName=dD;var[pD,mD]=zE(tD,{}),hD=`SelectViewport`,gD=b.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=aD(hD,n),o=mD(hD,n),s=un(t,a.onViewportChange),c=b.useRef(0);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,V.jsx)(IE.Slot,{scope:n,children:(0,V.jsx)(Cn.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:U(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-rD*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})});gD.displayName=hD;var _D=`SelectGroup`,[vD,yD]=zE(_D),bD=b.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=to();return(0,V.jsx)(vD,{scope:n,id:i,children:(0,V.jsx)(Cn.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});bD.displayName=_D;var xD=`SelectLabel`,SD=b.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=yD(xD,n);return(0,V.jsx)(Cn.div,{id:i.id,...r,ref:t})});SD.displayName=xD;var CD=`SelectItem`,[wD,TD]=zE(CD),ED=b.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=UE(CD,n),c=aD(CD,n),l=s.value===r,[u,d]=b.useState(a??``),[f,p]=b.useState(!1),m=un(t,e=>c.itemRefCallback?.(e,r,i)),h=to(),g=b.useRef(`touch`),_=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};if(r===``)throw Error(`A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.`);return(0,V.jsx)(wD,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:b.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,V.jsx)(IE.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,V.jsx)(Cn.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:U(o.onFocus,()=>p(!0)),onBlur:U(o.onBlur,()=>p(!1)),onClick:U(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:U(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:U(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:U(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:U(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:U(o.onKeyDown,e=>{(c.searchRef?.current===``||e.key!==` `)&&(PE.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});ED.displayName=CD;var DD=`SelectItemText`,OD=b.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=UE(DD,n),s=aD(DD,n),c=TD(DD,n),l=GE(DD,n),[u,d]=b.useState(null),f=un(t,e=>d(e),c.onItemTextChange,e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=u?.textContent,m=b.useMemo(()=>(0,V.jsx)(`option`,{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:h,onNativeOptionRemove:g}=l;return Hn(()=>(h(m),()=>g(m)),[h,g,m]),(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Cn.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?sn.createPortal(a.children,o.valueNode):null]})});OD.displayName=DD;var kD=`SelectItemIndicator`,AD=b.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return TD(kD,n).isSelected?(0,V.jsx)(Cn.span,{"aria-hidden":!0,...r,ref:t}):null});AD.displayName=kD;var jD=`SelectScrollUpButton`,MD=b.forwardRef((e,t)=>{let n=aD(jD,e.__scopeSelect),r=mD(jD,e.__scopeSelect),[i,a]=b.useState(!1),o=un(t,r.onScrollButtonChange);return Hn(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;a(e)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,V.jsx)(FD,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});MD.displayName=jD;var ND=`SelectScrollDownButton`,PD=b.forwardRef((e,t)=>{let n=aD(ND,e.__scopeSelect),r=mD(ND,e.__scopeSelect),[i,a]=b.useState(!1),o=un(t,r.onScrollButtonChange);return Hn(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,V.jsx)(FD,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});PD.displayName=ND;var FD=b.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=aD(`SelectScrollButton`,n),o=b.useRef(null),s=LE(n),c=b.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return b.useEffect(()=>()=>c(),[c]),Hn(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,V.jsx)(Cn.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:U(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:U(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:U(i.onPointerLeave,()=>{c()})})}),ID=`SelectSeparator`,LD=b.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,V.jsx)(Cn.div,{"aria-hidden":!0,...r,ref:t})});LD.displayName=ID;var RD=`SelectArrow`,zD=b.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=VE(n),a=UE(RD,n),o=aD(RD,n);return a.open&&o.position===`popper`?(0,V.jsx)(Gc,{...i,...r,ref:t}):null});zD.displayName=RD;var BD=`SelectBubbleInput`,VD=b.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=b.useRef(null),a=un(r,i),o=ME(t);return b.useEffect(()=>{let e=i.current;if(!e)return;let n=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(n,`value`).set;if(o!==t&&r){let n=new Event(`change`,{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}},[o,t]),(0,V.jsx)(Cn.select,{...n,style:{...er,...n.style},ref:a,defaultValue:t})});VD.displayName=BD;function HD(e){return e===``||e===void 0}function UD(e){let t=Tn(e),n=b.useRef(``),r=b.useRef(0),i=b.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=b.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return b.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function WD(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=GD(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function GD(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var KD=KE,qD=JE,JD=XE,YD=QE,XD=eD,ZD=nD,QD=gD,$D=SD,eO=ED,tO=OD,nO=AD,rO=MD,iO=PD,aO=LD,oO=KD,sO=JD,cO=b.forwardRef(({className:e,children:t,...n},r)=>(0,V.jsxs)(qD,{ref:r,className:W(`flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1`,e),...n,children:[t,(0,V.jsx)(YD,{asChild:!0,children:(0,V.jsx)(gi,{className:`h-4 w-4 opacity-50`})})]}));cO.displayName=qD.displayName;var lO=b.forwardRef(({className:e,...t},n)=>(0,V.jsx)(rO,{ref:n,className:W(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,V.jsx)(yi,{className:`h-4 w-4`})}));lO.displayName=rO.displayName;var uO=b.forwardRef(({className:e,...t},n)=>(0,V.jsx)(iO,{ref:n,className:W(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,V.jsx)(gi,{className:`h-4 w-4`})}));uO.displayName=iO.displayName;var dO=b.forwardRef(({className:e,children:t,position:n=`popper`,...r},i)=>(0,V.jsx)(XD,{children:(0,V.jsxs)(ZD,{ref:i,className:W(`relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,...r,children:[(0,V.jsx)(lO,{}),(0,V.jsx)(QD,{className:W(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]`),children:t}),(0,V.jsx)(uO,{})]})}));dO.displayName=ZD.displayName;var fO=b.forwardRef(({className:e,...t},n)=>(0,V.jsx)($D,{ref:n,className:W(`py-1.5 pl-8 pr-2 text-sm font-semibold`,e),...t}));fO.displayName=$D.displayName;var pO=b.forwardRef(({className:e,children:t,...n},r)=>(0,V.jsxs)(eO,{ref:r,className:W(`relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),...n,children:[(0,V.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,V.jsx)(nO,{children:(0,V.jsx)(hi,{className:`h-4 w-4`})})}),(0,V.jsx)(tO,{children:t})]}));pO.displayName=eO.displayName;var mO=b.forwardRef(({className:e,...t},n)=>(0,V.jsx)(aO,{ref:n,className:W(`-mx-1 my-1 h-px bg-muted`,e),...t}));mO.displayName=aO.displayName;var hO=`/api/mcp/endpoint`;async function gO(){let e=await fetch(hO,{credentials:`include`});if(!e.ok)throw Error(`MCP endpoint request failed: ${e.status}`);let t=(await e.json())?.data?.url;if(typeof t!=`string`||t.length===0)throw Error(`MCP endpoint response did not include a URL`);return t}async function _O(e){try{let t=await gO();await navigator.clipboard.writeText(t),e({title:`MCP URL copied!`,description:t})}catch(t){e({title:`Failed to copy MCP URL`,description:t instanceof Error?t.message:`Unknown error`,variant:`destructive`})}}var vO=`/assets/AgentDeckLogo3-X5qCXS2A.png`;function yO(){let[e,t]=(0,b.useState)(``),[n,r]=(0,b.useState)(``),[i,a]=(0,b.useState)(!1),[o,s]=(0,b.useState)(!1),[c,l]=(0,b.useState)(null),[u,d]=(0,b.useState)(!1),[f,p]=(0,b.useState)(!1),[m,h]=(0,b.useState)(null),[g,_]=(0,b.useState)(!1),[v,y]=(0,b.useState)(!1),[x,S]=(0,b.useState)(null),[C,w]=(0,b.useState)(!1),[T,E]=(0,b.useState)(!1),[D,O]=(0,b.useState)(!1),[k,A]=(0,b.useState)(null),{toast:j}=on(),{connectionStatus:M}=EE(),{data:N=[]}=Vt({queryKey:[`/api/playbook-patches`,`proposed`],queryFn:()=>Xm(`proposed`)}),{data:P=0}=Vt({queryKey:[`/api/feedback-signals/count`,`available`],queryFn:()=>nh()}),F=async()=>{O(!0);try{let e=await Bm({scope:`collection`});Hm(e,`backup.agent-deck.json`),j({title:`Exported collection`,description:`${e.services.length} services, ${e.playbooks.length} playbooks, ${e.decks.length} decks`})}catch(e){j({title:`Export failed`,description:e instanceof Error?e.message:`Unknown error`,variant:`destructive`})}finally{O(!1)}},{data:I,isLoading:L,error:ee}=Vt({queryKey:[`/api/decks`]}),te=I?.data||[],{editingDeck:ne,editingDeckId:R,setEditingDeckId:z}=AE(te),{handleDragStart:B,handleCredentialDragStart:re,handlePlaybookDragStart:ie,handleDragEnd:ae,handleDrop:oe,handleGlobalDrop:se,isDraggingFromDeck:ce}=OE(R),{data:le,isLoading:ue,error:de}=Vt({queryKey:[`/api/services`]}),{data:fe,isLoading:pe}=Vt({queryKey:[`/api/credentials/vault`]}),{data:me,isLoading:he}=Vt({queryKey:[`/api/playbooks/vault`]}),{data:ge}=Vt({queryKey:[`/api/collection/warnings`],staleTime:6e4}),_e=le?.data||[],ve=fe?.data||[],be=me?.data||[],xe=(0,b.useMemo)(()=>Ol(ge?.data),[ge?.data]),Se=(e,t)=>i?e===`service`?xe.serviceWarnings.has(t):e===`credential`?xe.credentialWarnings.has(t):xe.playbookWarnings.has(t):!0,Ce=_e.filter(t=>{if(!Se(`service`,t.id)||n===`api-key`||n===`playbook`)return!1;let r=t.name.toLowerCase().includes(e.toLowerCase())||t.description?.toLowerCase().includes(e.toLowerCase()),i=!n||n===`all`||t.type===n;return r&&i}),we=ve.filter(t=>!Se(`credential`,t.id)||n&&n!==`all`&&n!==`api-key`?!1:t.label.toLowerCase().includes(e.toLowerCase())),Te=be.filter(t=>!Se(`playbook`,t.id)||n&&n!==`all`&&n!==`playbook`?!1:t.title.toLowerCase().includes(e.toLowerCase())||t.body.toLowerCase().includes(e.toLowerCase())),Ee=Ce.length+we.length+Te.length;de&&console.error(`Services error:`,de),ee&&console.error(`Decks error:`,ee);let De=()=>{t(``),r(``),a(!1)},Oe=!!(e||n||i),ke=new Set((ne?.credentials??[]).map(e=>e.id)),Ae=new Set((ne?.playbooks??[]).map(e=>e.id)),je=ne?.services||[],Me=ne?.playbooks||[],Ne=e=>{l(e),d(!0)},Pe=e=>{S(e.id),w(!0)},Fe=e=>{h(e.id),_(!0)},Ie=e=>{A(e)};if(de||ee){let e=Wt(ee)||Wt(de),t=(ee instanceof Error?ee.message:null)??(de instanceof Error?de.message:null)??`There was an error loading the application data.`;return(0,V.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gray-900`,children:(0,V.jsxs)(`div`,{className:`text-center max-w-lg px-4`,children:[(0,V.jsx)(`h2`,{className:`text-2xl font-bold text-red-400 mb-4`,children:e?`Dashboard Access Expired`:`Error Loading Data`}),e?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:`text-gray-300 mb-2`,children:`Dashboard access has expired.`}),(0,V.jsx)(`p`,{className:`text-gray-400 text-sm mb-4`,children:`Reopen it securely from your terminal or the Agent Deck menubar.`}),(0,V.jsx)(`code`,{className:`mb-6 block rounded bg-black/30 px-3 py-2 text-gray-200`,children:`agent-deck open`}),(0,V.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(`agent-deck open`).then(()=>{j({title:`Command copied`,description:`Run it in your terminal.`})})},className:`px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700`,children:`Copy Command`})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:`text-gray-300 mb-2`,children:`There was an error loading the application data.`}),(0,V.jsx)(`p`,{className:`text-gray-400 text-sm mb-4`,children:t}),(0,V.jsxs)(`p`,{className:`text-gray-500 text-xs mb-6`,children:[`Is the API running? Try `,(0,V.jsx)(`code`,{className:`text-gray-300`,children:`agent-deck stop && agent-deck start`})]}),(0,V.jsx)(`button`,{onClick:()=>window.location.reload(),className:`px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700`,children:`Reload Page`})]})]})})}return ue||L||pe||he?(0,V.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gray-900`,children:(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(`div`,{className:`animate-spin rounded-full h-12 w-12 border-b-2 border-yellow-400 mx-auto mb-4`}),(0,V.jsx)(`p`,{className:`text-gray-300`,children:`Loading AgentDeck...`})]})}):(0,V.jsxs)(`div`,{className:`flex min-h-dvh flex-col overflow-x-hidden`,onDrop:se,onDragOver:e=>e.preventDefault(),style:{position:`relative`,...ce&&{background:`linear-gradient(to bottom right, #1a1a2e, #16213e, #0f3460)`}},children:[(0,V.jsx)(`header`,{className:`relative z-20 shrink-0 bg-black/30 backdrop-blur-md border-b border-white/10`,"data-testid":`top-bar`,children:(0,V.jsx)(`div`,{className:`container mx-auto px-4 py-2`,children:(0,V.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between sm:gap-3`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`img`,{src:vO,alt:`Agent Deck Logo`,className:`h-9 w-9 shrink-0 object-contain`}),(0,V.jsx)(`h1`,{className:`whitespace-nowrap text-xl font-bold bg-gradient-to-r from-yellow-400 to-yellow-600 bg-clip-text text-transparent`,style:{background:`linear-gradient(to right, #C4B643, #D4C760)`,WebkitBackgroundClip:`text`,WebkitTextFillColor:`transparent`,backgroundClip:`text`},children:`AgentDeck`}),(0,V.jsx)(`p`,{className:`sr-only`,children:`Build tool deck for your agent`})]}),(0,V.jsxs)(`div`,{className:`flex flex-nowrap items-center gap-2 overflow-x-auto -my-1 py-1 sm:gap-3`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`flex h-9 shrink-0 items-center gap-2 whitespace-nowrap rounded-full border px-3 text-sm ${M===`connected`?`bg-emerald-500/20 border-emerald-500/30`:`bg-red-500/20 border-red-500/30`}`,"data-testid":`button-copy-mcp-url`,onClick:()=>{_O(j)},title:`Click to copy MCP URL`,children:[(0,V.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full animate-pulse ${M===`connected`?`bg-emerald-400`:`bg-red-400`}`,"aria-hidden":!0}),(0,V.jsx)(`span`,{className:`font-ui-display hover:underline ${M===`connected`?`text-emerald-300`:`text-red-300`}`,children:`Get MCP URL`})]}),(0,V.jsx)(zf,{highlightDeckId:R??void 0}),(0,V.jsx)(ye,{href:`/feedback-signals`,children:(0,V.jsxs)(G,{variant:`outline`,size:`sm`,className:`relative shrink-0 border-white/20 bg-white/5 text-[#E8F6F4]`,children:[(0,V.jsx)(`span`,{className:`font-ui-display`,children:`Feedback`}),P>0&&(0,V.jsx)(`span`,{className:`ml-2 rounded-full px-2 py-0.5 text-xs font-semibold`,style:{background:`#C4B643`,color:`#0A0A07`},title:`Open feedback available for curation`,children:P})]})}),(0,V.jsx)(ye,{href:`/playbook-patches`,children:(0,V.jsxs)(G,{variant:`outline`,size:`sm`,className:`relative shrink-0 border-white/20 bg-white/5 text-[#E8F6F4]`,children:[(0,V.jsx)(ki,{className:`mr-2 h-4 w-4`}),(0,V.jsx)(`span`,{className:`font-ui-display`,children:`Review`}),N.length>0&&(0,V.jsx)(`span`,{className:`ml-2 rounded-full px-2 py-0.5 text-xs font-semibold`,style:{background:`#C4B643`,color:`#0A0A07`},title:`Proposed playbook patches`,children:N.length})]})})]})]})})}),ce&&(0,V.jsx)(`div`,{className:`fixed inset-0 pointer-events-none z-50 flex items-center justify-center`,children:(0,V.jsxs)(`div`,{className:`bg-red-500/20 border-2 border-dashed border-red-500/50 rounded-lg p-8 text-center`,children:[(0,V.jsx)(`div`,{className:`text-red-400 text-lg font-bold mb-2`,children:`Drop to Remove`}),(0,V.jsx)(`div`,{className:`text-red-300 text-sm`,children:`Release to remove card from deck`})]})}),(0,V.jsx)(`main`,{className:`container mx-auto flex min-h-0 flex-1 flex-col px-4 py-4 sm:py-6`,children:(0,V.jsxs)(`div`,{className:`grid min-w-0 grid-cols-1 gap-4 sm:gap-6 xl:min-h-0 xl:flex-1 xl:grid-cols-4 xl:overflow-hidden`,children:[(0,V.jsxs)(`div`,{className:`min-w-0 space-y-4 sm:space-y-6 xl:col-span-1 xl:min-h-0 xl:overflow-y-auto`,children:[(0,V.jsx)(`div`,{className:`panel-surface h-64 overflow-hidden p-4 min-w-0 sm:h-72 xl:h-80`,children:(0,V.jsx)(Gm,{decks:te,editingDeckId:R,onSelectDeck:z,isLoading:L})}),(0,V.jsxs)(`div`,{className:`panel-surface p-4`,children:[(0,V.jsxs)(`h2`,{className:`text-lg font-bold mb-3 flex items-center`,children:[(0,V.jsx)(di,{className:`w-4 h-4 mr-2`,style:{color:`#92E4DD`}}),(0,V.jsx)(`span`,{className:`font-ui-display`,style:{color:`#92E4DD`},children:`Add Cards`})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsxs)(G,{variant:`ghost`,className:`w-full border-2 text-sm py-2 hover:opacity-90 ${Ml}`,style:Pl(kl),onClick:()=>s(!0),"data-testid":`button-register-mcp`,children:[(0,V.jsx)(zi,{className:`w-3 h-3 mr-2`}),(0,V.jsx)(`span`,{className:`font-ui-display`,children:`Register MCP`})]}),(0,V.jsxs)(G,{variant:`ghost`,className:`w-full border-2 text-sm py-2 hover:opacity-90 ${Ml}`,style:Pl(Al),onClick:()=>p(!0),"data-testid":`button-register-api-key`,children:[(0,V.jsx)(Ai,{className:`w-3 h-3 mr-2`}),(0,V.jsx)(`span`,{className:`font-ui-display`,children:`Register API key`})]}),(0,V.jsxs)(G,{variant:`ghost`,className:`w-full border-2 text-sm py-2 hover:opacity-90 ${Ml}`,style:Pl(jl),onClick:()=>y(!0),"data-testid":`button-register-playbook`,children:[(0,V.jsx)(fi,{className:`w-3 h-3 mr-2`}),(0,V.jsx)(`span`,{className:`font-ui-display`,children:`Register Playbook`})]})]})]})]}),(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4 sm:gap-6 xl:col-span-3 xl:h-full xl:min-h-0`,children:[(0,V.jsx)(`div`,{className:`panel-surface h-64 shrink-0 overflow-hidden p-4 min-w-0 sm:h-72 xl:h-80`,children:ne?(0,V.jsx)(`div`,{className:`h-full`,children:(0,V.jsx)(du,{deck:ne,services:je,credentials:ne.credentials??[],playbooks:Me,allServices:_e,collectionWarnings:xe,onDrop:oe,onDragStart:B,onCredentialDragStart:re,onPlaybookDragStart:ie,onDragEnd:ae,onCardClick:Ne,onPlaybookClick:Pe,onCredentialClick:Fe})}):(0,V.jsxs)(`div`,{className:`text-center h-full flex flex-col justify-center`,children:[(0,V.jsx)(`div`,{className:`w-12 h-12 rounded-full bg-yellow-500/20 border border-yellow-500/30 flex items-center justify-center mx-auto mb-3`,children:(0,V.jsx)(Mi,{className:`w-6 h-6 text-yellow-400`})}),(0,V.jsx)(`h3`,{className:`text-lg font-bold mb-2`,style:{color:`#92E4DD`},children:`No deck selected`}),(0,V.jsx)(`p`,{className:`text-gray-300 mb-4 text-sm`,children:`Create a deck or select one from the sidebar to edit its cards.`}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,V.jsxs)(G,{onClick:()=>{let e=document.querySelector(`[data-testid="create-deck-button"]`);e&&e.click()},className:`border text-sm py-2`,style:{background:`#C4B643`,borderColor:`#C4B643`,color:`black`},children:[(0,V.jsx)(Ii,{className:`w-4 h-4 mr-2`}),`Create New Deck`]}),(0,V.jsxs)(G,{variant:`outline`,className:`border-white/20 text-white hover:bg-white/10 text-sm py-2`,onClick:()=>{let e=document.querySelector(`[data-testid="deck-management-panel"]`);e&&e.scrollIntoView({behavior:`smooth`})},children:[(0,V.jsx)(Mi,{className:`w-4 h-4 mr-2`}),`Manage Decks`]})]})]})}),(0,V.jsxs)(`div`,{className:`panel-surface flex min-h-[20rem] flex-col overflow-hidden p-4 min-w-0 sm:min-h-[24rem] xl:min-h-0 xl:flex-1`,"data-testid":`collection-panel`,children:[(0,V.jsxs)(`div`,{className:`mb-3 flex shrink-0 flex-wrap items-center justify-between gap-2`,children:[(0,V.jsxs)(`h2`,{className:`text-lg font-bold flex items-center`,children:[(0,V.jsx)(Ni,{className:`w-4 h-4 mr-2`,style:{color:`#92E4DD`}}),(0,V.jsx)(`span`,{className:`font-ui-display`,style:{color:`#92E4DD`},children:`My Collection`}),(0,V.jsxs)(`span`,{className:`ml-3 text-sm font-normal text-gray-400`,children:[`(`,Ee,` cards)`]})]}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsxs)(G,{size:`sm`,variant:`outline`,className:`h-8 px-2 text-xs border-white/20 text-white hover:bg-white/10`,onClick:F,disabled:D,title:`Export all MCP, playbooks, and decks`,"data-testid":`button-export-all`,children:[(0,V.jsx)(Ei,{className:`w-3 h-3 mr-1`}),(0,V.jsx)(`span`,{className:`font-ui-display`,children:D?`Exporting…`:`Export all`})]}),(0,V.jsxs)(G,{size:`sm`,variant:`outline`,className:`h-8 px-2 text-xs border-white/20 text-white hover:bg-white/10`,onClick:()=>E(!0),title:`Import a bundle file`,"data-testid":`button-import-bundle`,children:[(0,V.jsx)(Wi,{className:`w-3 h-3 mr-1`}),(0,V.jsx)(`span`,{className:`font-ui-display`,children:`Import`})]}),(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)(Ri,{className:`absolute left-2 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4`}),(0,V.jsx)(uu,{placeholder:`Search...`,value:e,onChange:e=>t(e.target.value),className:`h-8 w-36 pl-8 text-sm bg-white/10 border-white/20 text-white placeholder-gray-400 sm:w-48`,"data-testid":`input-search`})]}),(0,V.jsxs)(oO,{value:n||`all`,onValueChange:e=>r(e===`all`?``:e),children:[(0,V.jsxs)(cO,{className:`w-[7.5rem] h-8 bg-white/10 border-white/20 text-white text-xs shrink-0`,"data-testid":`select-type`,children:[(0,V.jsx)(Oi,{className:`w-3 h-3 mr-1 shrink-0`}),(0,V.jsx)(sO,{placeholder:`Type`})]}),(0,V.jsxs)(dO,{children:[(0,V.jsx)(pO,{value:`all`,children:`All`}),(0,V.jsx)(pO,{value:`mcp`,children:`MCP`}),(0,V.jsx)(pO,{value:`local-mcp`,children:`Local MCP`}),(0,V.jsx)(pO,{value:`api-key`,children:`API Key`}),(0,V.jsx)(pO,{value:`playbook`,children:`Playbook`})]})]}),(e||n||i)&&(0,V.jsx)(G,{size:`sm`,variant:`outline`,className:`h-8 px-2 text-xs border-white/20 text-white hover:bg-white/10`,onClick:De,title:`Clear all filters`,children:`Clear`})]})]}),xe.total>0&&(0,V.jsx)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`mb-3 w-full shrink-0 rounded-lg border px-3 py-2 text-left text-sm transition-colors ${i?`border-amber-300/60 bg-amber-500/15 text-amber-100`:`border-amber-400/30 bg-amber-500/10 text-amber-100 hover:bg-amber-500/15`}`,"data-testid":`button-collection-warnings`,children:(0,V.jsxs)(`span`,{className:`flex items-start gap-2`,children:[(0,V.jsx)(Ui,{className:`mt-0.5 h-4 w-4 shrink-0 text-amber-300`}),(0,V.jsx)(`span`,{children:i?(0,V.jsxs)(V.Fragment,{children:[`Showing `,(0,V.jsx)(`strong`,{children:Ee}),` card`,Ee===1?``:`s`,` needing attention.`,(0,V.jsx)(`span`,{className:`text-amber-200/80`,children:` Click to show all cards.`})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`strong`,{children:xe.total}),` card`,xe.total===1?``:`s`,` need attention`,xe.byKind.oauth_expired+xe.byKind.oauth_required>0&&(0,V.jsxs)(V.Fragment,{children:[` `,`(`,xe.byKind.oauth_expired+xe.byKind.oauth_required,` `,`OAuth)`]}),`. `,(0,V.jsx)(`span`,{className:`text-amber-200/80`,children:`Click to filter.`})]})})]})}),(0,V.jsx)(`div`,{className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto px-1 py-2`,children:ue||pe||he?(0,V.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,5rem)] gap-y-2 pr-12`,children:Array.from({length:10}).map((e,t)=>(0,V.jsx)(`div`,{className:`animate-pulse`,children:(0,V.jsx)(`div`,{className:`bg-white/10 rounded-lg w-32 h-48 aspect-[2/3]`})},t))}):Ee===0?(0,V.jsxs)(`div`,{className:`text-center py-12`,children:[(0,V.jsx)(`div`,{className:`text-gray-400 mb-4`,children:(0,V.jsx)(`i`,{className:`fas fa-layer-group text-4xl`})}),(0,V.jsx)(`h3`,{className:`text-lg font-semibold text-gray-300 mb-2`,children:`No cards yet`}),(0,V.jsx)(`p`,{className:`text-gray-400 text-sm mb-4`,children:Oe?i?`No cards with warnings match your current filters`:`Try adjusting your search or filters`:`Register an MCP server, API key, or playbook to get started`}),!Oe&&(0,V.jsxs)(`div`,{className:`flex gap-3 justify-center`,children:[(0,V.jsxs)(G,{variant:`ghost`,size:`sm`,className:`border-2 hover:opacity-90 bg-gradient-to-b from-gray-900 via-gray-800 to-gray-900`,style:Pl(`#92E4DD`),onClick:()=>s(!0),"data-testid":`button-register-mcp-empty`,children:[(0,V.jsx)(zi,{className:`w-3 h-3 mr-1`}),(0,V.jsx)(`span`,{className:`font-ui-display`,children:`Register MCP`})]}),(0,V.jsxs)(G,{variant:`ghost`,size:`sm`,className:`border-2 hover:opacity-90 bg-gradient-to-b from-gray-900 via-gray-800 to-gray-900`,style:Pl(`#F9386D`),onClick:()=>p(!0),"data-testid":`button-register-api-key-empty`,children:[(0,V.jsx)(Ai,{className:`w-3 h-3 mr-1`}),(0,V.jsx)(`span`,{className:`font-ui-display`,children:`Register API key`})]})]})]}):(0,V.jsxs)(`div`,{className:`relative isolate grid grid-cols-[repeat(auto-fill,5rem)] gap-y-2 pr-12`,style:{isolation:`isolate`},"data-testid":`collection-card-grid`,children:[Te.map((e,t)=>(0,V.jsx)(`div`,{className:`relative group`,style:{zIndex:k===e.id?999999:Ee-t},children:(0,V.jsx)(Yl,{playbook:e,isInActiveDeck:Ae.has(e.id),activeDeck:ne??void 0,isInCollection:!0,onDragStart:ie,onDragEnd:ae,onCardClick:Pe,onMouseEnter:()=>Ie(e.id),onMouseLeave:()=>Ie(null),warnings:xe.playbookWarnings.get(e.id)})},e.id)),we.map((e,t)=>(0,V.jsx)(`div`,{className:`relative group`,style:{zIndex:k===e.id?999999:Ee-Te.length-t},children:(0,V.jsx)(ql,{credential:e,isInActiveDeck:ke.has(e.id),activeDeck:ne??void 0,isInCollection:!0,onDragStart:re,onDragEnd:ae,onMouseEnter:()=>Ie(e.id),onMouseLeave:()=>Ie(null),onCardClick:Fe,warnings:xe.credentialWarnings.get(e.id)})},e.id)),Ce.map((e,t)=>(0,V.jsx)(`div`,{className:`relative group`,style:{zIndex:k===e.id?999999:Ee-Te.length-we.length-t},children:(0,V.jsx)(Ul,{service:e,onDragStart:B,onDragEnd:ae,isInActiveDeck:ne?.services?.some(t=>t.id===e.id)||!1,onCardClick:Ne,isInCollection:!0,onMouseEnter:()=>Ie(e.id),onMouseLeave:()=>Ie(null),activeDeck:ne??void 0,warnings:xe.serviceWarnings.get(e.id)})},e.id))]})})]})]})]})}),(0,V.jsxs)(`div`,{className:`fixed inset-0 pointer-events-none z-0 overflow-hidden`,children:[(0,V.jsx)(`div`,{className:`absolute top-20 left-20`,children:(0,V.jsx)(`div`,{className:`h-96 w-96 rounded-full bg-cyan-500/10 blur-3xl animate-orb-drift-1`})}),(0,V.jsx)(`div`,{className:`absolute bottom-20 right-20`,children:(0,V.jsx)(`div`,{className:`h-96 w-96 rounded-full bg-pink-500/10 blur-3xl animate-orb-drift-2`})}),(0,V.jsx)(`div`,{className:`absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2`,children:(0,V.jsx)(`div`,{className:`h-96 w-96 rounded-full bg-purple-500/5 blur-3xl animate-orb-drift-3`})})]}),(0,V.jsx)(Rm,{type:`mcp`,open:o,onOpenChange:s}),(0,V.jsx)(wE,{service:c,isOpen:u,onClose:()=>d(!1)}),(0,V.jsx)(Km,{open:f,onOpenChange:p}),(0,V.jsx)(uh,{credentialId:m,open:g,onOpenChange:_}),(0,V.jsx)(qm,{open:v,onOpenChange:y}),(0,V.jsx)(lh,{playbookId:x,open:C,onOpenChange:w}),(0,V.jsx)(TE,{open:T,onOpenChange:E})]})}var bO=b.forwardRef(({className:e,...t},n)=>(0,V.jsx)(`div`,{ref:n,className:W(`rounded-lg border bg-card text-card-foreground shadow-sm`,e),...t}));bO.displayName=`Card`;var xO=b.forwardRef(({className:e,...t},n)=>(0,V.jsx)(`div`,{ref:n,className:W(`flex flex-col space-y-1.5 p-6`,e),...t}));xO.displayName=`CardHeader`;var SO=b.forwardRef(({className:e,...t},n)=>(0,V.jsx)(`div`,{ref:n,className:W(`text-2xl font-semibold leading-none tracking-tight`,e),...t}));SO.displayName=`CardTitle`;var CO=b.forwardRef(({className:e,...t},n)=>(0,V.jsx)(`div`,{ref:n,className:W(`text-sm text-muted-foreground`,e),...t}));CO.displayName=`CardDescription`;var wO=b.forwardRef(({className:e,...t},n)=>(0,V.jsx)(`div`,{ref:n,className:W(`p-6 pt-0`,e),...t}));wO.displayName=`CardContent`;var TO=b.forwardRef(({className:e,...t},n)=>(0,V.jsx)(`div`,{ref:n,className:W(`flex items-center p-6 pt-0`,e),...t}));TO.displayName=`CardFooter`;function EO(){return(0,V.jsx)(`div`,{className:`min-h-screen w-full flex items-center justify-center bg-gray-50`,children:(0,V.jsx)(bO,{className:`w-full max-w-md mx-4`,children:(0,V.jsxs)(wO,{className:`pt-6`,children:[(0,V.jsxs)(`div`,{className:`flex mb-4 gap-2`,children:[(0,V.jsx)(bi,{className:`h-8 w-8 text-red-500`}),(0,V.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900`,children:`404 Page Not Found`})]}),(0,V.jsx)(`p`,{className:`mt-4 text-sm text-gray-600`,children:`Did you forget to add the page to the router?`})]})})})}function DO(){let[e]=pe(),[t,n]=(0,b.useState)(`loading`),[r,i]=(0,b.useState)(`Authenticating...`);return(0,b.useEffect)(()=>{(async()=>{try{let e=new URL(window.location.href),t=e.searchParams.get(`success`),r=e.searchParams.get(`error`),a=e.searchParams.get(`serviceId`);t===`true`?(n(`success`),i(`Authentication successful! This window will close automatically.`),window.opener&&!window.opener.closed&&window.opener.postMessage({type:mE,serviceId:a??void 0},window.location.origin),setTimeout(()=>{window.close()},2e3)):t===`false`?(n(`error`),i(`OAuth Error: ${r||`Authentication failed`}`)):(n(`error`),i(`Invalid OAuth callback - please try again`))}catch(e){n(`error`),i(e instanceof Error?e.message:`Authentication failed`)}})()},[e]),(0,V.jsx)(`div`,{className:`flex items-center justify-center min-h-screen bg-background`,children:(0,V.jsxs)(`div`,{className:`text-center space-y-4`,children:[t===`loading`&&(0,V.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto`}),t===`success`&&(0,V.jsx)(`div`,{className:`text-green-500 text-4xl`,children:`✓`}),t===`error`&&(0,V.jsx)(`div`,{className:`text-red-500 text-4xl`,children:`✗`}),(0,V.jsx)(`h1`,{className:`text-xl font-semibold`,children:r}),t===`error`&&(0,V.jsx)(`button`,{onClick:()=>window.close(),className:`px-4 py-2 bg-primary text-primary-foreground rounded hover:bg-primary/90`,children:`Close Window`})]})})}function OO(e){let t=()=>{throw Error(`Invalid url to pass to open(): ${e}`)},n;try{n=new URL(e)}catch{t()}return n.protocol!==`https:`&&n.protocol!==`http:`&&t(),n.hostname!==encodeURIComponent(n.hostname)&&t(),n.username&&(n.username=encodeURIComponent(n.username)),n.password&&(n.password=encodeURIComponent(n.password)),n.pathname=n.pathname.slice(0,1)+encodeURIComponent(n.pathname.slice(1)).replace(/%2f/gi,`/`),n.search=n.search.slice(0,1)+Array.from(n.searchParams.entries()).map(kO).join(`&`),n.hash=n.hash.slice(0,1)+encodeURIComponent(n.hash.slice(1)),n.href}function kO([e,t]){return`${encodeURIComponent(e)}${t.length>0?`=${encodeURIComponent(t)}`:``}`}var AO=class{serverUrl;storageKeyPrefix;serverUrlHash;clientName;clientUri;callbackUrl;preventAutoAuth;onPopupWindow;constructor(e,t={}){this.serverUrl=e,this.storageKeyPrefix=t.storageKeyPrefix||`mcp:auth`,this.serverUrlHash=this.hashString(e),this.clientName=t.clientName||`MCP Browser Client`,this.clientUri=t.clientUri||(typeof window<`u`?window.location.origin:``),this.callbackUrl=OO(t.callbackUrl||(typeof window<`u`?new URL(`/oauth/callback`,window.location.origin).toString():`/oauth/callback`)),this.preventAutoAuth=t.preventAutoAuth,this.onPopupWindow=t.onPopupWindow}get redirectUrl(){return OO(this.callbackUrl)}get clientMetadata(){return{redirect_uris:[this.redirectUrl],token_endpoint_auth_method:`none`,grant_types:[`authorization_code`,`refresh_token`],response_types:[`code`],client_name:this.clientName,client_uri:this.clientUri}}async clientInformation(){let e=this.getKey(`client_info`),t=localStorage.getItem(e);if(t)try{return JSON.parse(t)}catch(t){console.warn(`[${this.storageKeyPrefix}] Failed to parse client information:`,t),localStorage.removeItem(e);return}}async saveClientInformation(e){let t=this.getKey(`client_info`);localStorage.setItem(t,JSON.stringify(e))}async tokens(){let e=this.getKey(`tokens`),t=localStorage.getItem(e);if(t)try{return JSON.parse(t)}catch(t){console.warn(`[${this.storageKeyPrefix}] Failed to parse tokens:`,t),localStorage.removeItem(e);return}}async saveTokens(e){let t=this.getKey(`tokens`);localStorage.setItem(t,JSON.stringify(e)),localStorage.removeItem(this.getKey(`code_verifier`)),localStorage.removeItem(this.getKey(`last_auth_url`))}async saveCodeVerifier(e){let t=this.getKey(`code_verifier`);localStorage.setItem(t,e)}async codeVerifier(){let e=this.getKey(`code_verifier`),t=localStorage.getItem(e);if(!t)throw Error(`[${this.storageKeyPrefix}] Code verifier not found in storage for key ${e}. Auth flow likely corrupted or timed out.`);return t}async prepareAuthorizationUrl(e){let t=crypto.randomUUID(),n=`${this.storageKeyPrefix}:state_${t}`,r={serverUrlHash:this.serverUrlHash,expiry:Date.now()+6e5,providerOptions:{serverUrl:this.serverUrl,storageKeyPrefix:this.storageKeyPrefix,clientName:this.clientName,clientUri:this.clientUri,callbackUrl:this.callbackUrl}};localStorage.setItem(n,JSON.stringify(r)),e.searchParams.set(`state`,t);let i=OO(e.toString());return localStorage.setItem(this.getKey(`last_auth_url`),i),i}async redirectToAuthorization(e){if(this.preventAutoAuth)return;let t=await this.prepareAuthorizationUrl(e),n=`width=600,height=700,resizable=yes,scrollbars=yes,status=yes`;try{let e=window.open(t,`mcp_auth_${this.serverUrlHash}`,n);this.onPopupWindow&&this.onPopupWindow(t,n,e),!e||e.closed||e.closed===void 0?console.warn(`[${this.storageKeyPrefix}] Popup likely blocked by browser. Manual navigation might be required using the stored URL.`):(e.focus(),console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL in popup.`))}catch(e){console.error(`[${this.storageKeyPrefix}] Error opening popup window:`,e)}}getLastAttemptedAuthUrl(){let e=localStorage.getItem(this.getKey(`last_auth_url`));return e?OO(e):null}clearStorage(){let e=`${this.storageKeyPrefix}_${this.serverUrlHash}_`,t=`${this.storageKeyPrefix}:state_`,n=[],r=0;for(let r=0;r<localStorage.length;r++){let i=localStorage.key(r);if(i){if(i.startsWith(e))n.push(i);else if(i.startsWith(t))try{let e=localStorage.getItem(i);e&&JSON.parse(e).serverUrlHash===this.serverUrlHash&&n.push(i)}catch(e){console.warn(`[${this.storageKeyPrefix}] Error parsing state key ${i} during clearStorage:`,e)}}}return[...new Set(n)].forEach(e=>{localStorage.removeItem(e),r++}),r}hashString(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r,t&=t}return Math.abs(t).toString(16)}getKey(e){return`${this.storageKeyPrefix}_${this.serverUrlHash}_${e}`}},jO=Object.freeze({status:`aborted`});function J(e,t,n){function r(n,r){var i;Object.defineProperty(n,"_zod",{value:n._zod??{},enumerable:!1}),(i=n._zod).traits??(i.traits=new Set),n._zod.traits.add(e),t(n,r);for(let e in o.prototype)e in n||Object.defineProperty(n,e,{value:o.prototype[e].bind(n)});n._zod.constr=o,n._zod.def=r}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var MO=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},NO={};function PO(e){return e&&Object.assign(NO,e),NO}function FO(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function IO(e,t){return typeof t==`bigint`?t.toString():t}function LO(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function RO(e){return e==null}function zO(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function BO(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}function VO(e,t,n){Object.defineProperty(e,t,{get(){{let r=n();return e[t]=r,r}},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function HO(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function UO(e){return JSON.stringify(e)}var WO=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function GO(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var KO=LO(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function qO(e){if(GO(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return GO(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}var JO=new Set([`string`,`number`,`symbol`]);function YO(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function XO(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function Y(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function ZO(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var QO={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function $O(e,t){let n={},r=e._zod.def;for(let e in t){if(!(e in r.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&(n[e]=r.shape[e])}return XO(e,{...e._zod.def,shape:n,checks:[]})}function ek(e,t){let n={...e._zod.def.shape},r=e._zod.def;for(let e in t){if(!(e in r.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete n[e]}return XO(e,{...e._zod.def,shape:n,checks:[]})}function tk(e,t){if(!qO(t))throw Error(`Invalid input to extend: expected a plain object`);return XO(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return HO(this,`shape`,n),n},checks:[]})}function nk(e,t){return XO(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return HO(this,`shape`,n),n},catchall:t._zod.def.catchall,checks:[]})}function rk(e,t,n){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return XO(t,{...t._zod.def,shape:i,checks:[]})}function ik(e,t,n){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return XO(t,{...t._zod.def,shape:i,checks:[]})}function ak(e,t=0){for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function ok(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function sk(e){return typeof e==`string`?e:e?.message}function ck(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=sk(e.inst?._zod.def?.error?.(e))??sk(t?.error?.(e))??sk(n.customError?.(e))??sk(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function lk(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function uk(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var dk=(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,IO,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},fk=J(`$ZodError`,dk),pk=J(`$ZodError`,dk,{Parent:Error});function mk(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function hk(e,t){let n=t||function(e){return e.message},r={_errors:[]},i=e=>{for(let t of e.issues)if(t.code===`invalid_union`&&t.errors.length)t.errors.map(e=>i({issues:e}));else if(t.code===`invalid_key`)i({issues:t.issues});else if(t.code===`invalid_element`)i({issues:t.issues});else if(t.path.length===0)r._errors.push(n(t));else{let e=r,i=0;for(;i<t.path.length;){let r=t.path[i];i===t.path.length-1?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(n(t))):e[r]=e[r]||{_errors:[]},e=e[r],i++}}};return i(e),r}var gk=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new MO;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>ck(e,a,PO())));throw WO(t,i?.callee),t}return o.value},_k=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>ck(e,a,PO())));throw WO(t,i?.callee),t}return o.value},vk=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new MO;return a.issues.length?{success:!1,error:new(e??fk)(a.issues.map(e=>ck(e,i,PO())))}:{success:!0,data:a.value}},yk=vk(pk),bk=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>ck(e,i,PO())))}:{success:!0,data:a.value}},xk=bk(pk),Sk=/^[cC][^\s-]{8,}$/,Ck=/^[0-9a-z]+$/,wk=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Tk=/^[0-9a-vA-V]{20}$/,Ek=/^[A-Za-z0-9]{27}$/,Dk=/^[a-zA-Z0-9_-]{21}$/,Ok=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,kk=/^([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})$/,Ak=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,jk=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Mk=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function Nk(){return new RegExp(Mk,`u`)}var Pk=/^(?:(?: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])$/,Fk=/^(([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})$/,Ik=/^((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])$/,Lk=/^(([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])$/,Rk=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,zk=/^[A-Za-z0-9_-]*$/,Bk=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,Vk=/^\+(?:[0-9]){6,14}[0-9]$/,Hk=`(?:(?:\\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])))`,Uk=RegExp(`^${Hk}$`);function Wk(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Gk(e){return RegExp(`^${Wk(e)}$`)}function Kk(e){let t=Wk({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-]\\d{2}:\\d{2})`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${Hk}T(?:${r})$`)}var qk=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},Jk=/^\d+$/,Yk=/^-?\d+(?:\.\d+)?/i,Xk=/true|false/i,Zk=/null/i,Qk=/^[^A-Z]*$/,$k=/^[^a-z]*$/,eA=J(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),tA={number:`number`,bigint:`bigint`,object:`date`},nA=J(`$ZodCheckLessThan`,(e,t)=>{eA.init(e,t);let n=tA[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),rA=J(`$ZodCheckGreaterThan`,(e,t)=>{eA.init(e,t);let n=tA[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),iA=J(`$ZodCheckMultipleOf`,(e,t)=>{eA.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):BO(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),aA=J(`$ZodCheckNumberFormat`,(e,t)=>{eA.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=QO[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=Jk)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inst:e})}}),oA=J(`$ZodCheckMaxLength`,(e,t)=>{var n;eA.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!RO(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=lk(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),sA=J(`$ZodCheckMinLength`,(e,t)=>{var n;eA.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!RO(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=lk(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),cA=J(`$ZodCheckLengthEquals`,(e,t)=>{var n;eA.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!RO(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=lk(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),lA=J(`$ZodCheckStringFormat`,(e,t)=>{var n,r;eA.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),uA=J(`$ZodCheckRegex`,(e,t)=>{lA.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),dA=J(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Qk,lA.init(e,t)}),fA=J(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=$k,lA.init(e,t)}),pA=J(`$ZodCheckIncludes`,(e,t)=>{eA.init(e,t);let n=YO(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),mA=J(`$ZodCheckStartsWith`,(e,t)=>{eA.init(e,t);let n=RegExp(`^${YO(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),hA=J(`$ZodCheckEndsWith`,(e,t)=>{eA.init(e,t);let n=RegExp(`.*${YO(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),gA=J(`$ZodCheckOverwrite`,(e,t)=>{eA.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),_A=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
189
|
+
${F.data.oauth.issuer?`Issuer: ${F.data.oauth.issuer}`:``}`;A({title:`OAuth Setup Instructions`,description:e,duration:1e4})},children:`📋 Setup Instructions`})]})]}),(0,V.jsxs)(`div`,{className:`mt-2 text-xs`,children:[(0,V.jsx)(`p`,{children:(0,V.jsx)(`strong`,{children:`💡 Next Steps:`})}),(0,V.jsxs)(`ul`,{className:`list-disc list-inside ml-2 space-y-1`,children:[(0,V.jsx)(`li`,{children:`For OAuth servers: Provide OAuth credentials in service settings`}),(0,V.jsx)(`li`,{children:`For SSE servers: We'll automatically use the correct protocol`}),(0,V.jsx)(`li`,{children:`For connection issues: Verify the server URL and status`})]})]})]}),L&&(0,V.jsxs)(`div`,{className:`mt-3 p-3 bg-red-500/20 rounded`,children:[(0,V.jsx)(`p`,{children:(0,V.jsx)(`strong`,{children:`❌ Discovery Failed`})}),(0,V.jsx)(`p`,{children:`Could not analyze MCP server configuration`}),(0,V.jsx)(`pre`,{className:`text-xs overflow-x-auto`,children:L instanceof Error?L.message:String(L)})]})]})]}),!de&&!ie&&!ce&&e.type===`a2a`&&!ue&&(0,V.jsxs)(`div`,{className:`bg-yellow-500/20 border border-yellow-500/30 rounded-lg p-4`,children:[(0,V.jsx)(`h3`,{className:`text-yellow-300 font-semibold mb-2`,children:`Agent Details Not Available`}),(0,V.jsxs)(`p`,{className:`text-yellow-200 text-sm`,children:[`Successfully connected to A2A agent at `,M?.url,`, but no manifest was found.`]}),(0,V.jsxs)(`div`,{className:`text-yellow-200 text-xs mt-2`,children:[(0,V.jsx)(`p`,{children:(0,V.jsx)(`strong`,{children:`This could mean:`})}),(0,V.jsxs)(`ul`,{className:`list-disc list-inside ml-2 space-y-1`,children:[(0,V.jsx)(`li`,{children:`The agent doesn't provide a manifest`}),(0,V.jsx)(`li`,{children:`Manifest endpoint is not implemented`}),(0,V.jsx)(`li`,{children:`Agent requires specific authentication`})]})]})]})]})]})})}function TE({open:e,onOpenChange:t}){let[n,r]=(0,b.useState)(null),[i,a]=(0,b.useState)(null),[o,s]=(0,b.useState)(null),[c,l]=(0,b.useState)(!1),u=Et(),{toast:d}=on(),f=()=>{r(null),a(null),s(null),l(!1)},p=Ht({mutationFn:async()=>{if(!n)throw Error(`Choose a bundle file first`);let e=await n.text(),t;try{t=JSON.parse(e)}catch{throw Error(`File is not valid JSON`)}return Vm(t)},onSuccess:e=>{s(e),u.invalidateQueries({queryKey:[`/api/decks`]}),u.invalidateQueries({queryKey:[`/api/services`]}),u.invalidateQueries({queryKey:[`/api/playbooks`]}),u.invalidateQueries({queryKey:[`/api/playbooks/collection`]}),u.invalidateQueries({queryKey:[`/api/credentials/collection`]}),u.invalidateQueries({queryKey:[`/api/collection/warnings`]}),d({title:`Import complete`,description:Wm(e)})},onError:e=>{d({title:`Import failed`,description:e.message,variant:`destructive`})}}),m=async e=>{if(r(e),s(null),!e){a(null);return}try{let t=await e.text(),n=JSON.parse(t);a(`${n.services?.length??0} services · ${n.playbooks?.length??0} playbooks · ${n.decks?.length??0} decks`)}catch{a(`Invalid JSON`)}};return(0,V.jsx)(Dp,{open:e,onOpenChange:e=>{e||f(),t(e)},children:(0,V.jsxs)(Ap,{className:`sm:max-w-lg border-border bg-[#161612] text-[#E8F6F4]`,children:[(0,V.jsxs)(jp,{children:[(0,V.jsx)(Mp,{children:`Import bundle`}),(0,V.jsx)(Np,{asChild:!0,children:(0,V.jsxs)(`div`,{className:`space-y-2 text-left text-sm text-[#A8C4C0]`,children:[(0,V.jsx)(`p`,{children:`Adds MCP, playbooks, and decks from a JSON file.`}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`font-medium text-amber-200/90`,children:`Notes`}),(0,V.jsxs)(`ul`,{className:`mt-1 list-disc space-y-0.5 pl-4`,children:[(0,V.jsx)(`li`,{children:`Same name as an existing card or deck is skipped (linked only).`}),(0,V.jsx)(`li`,{children:`No credentials or secrets — re-enter keys and reconnect OAuth.`})]})]})]})})]}),(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(zp,{htmlFor:`bundle-file`,children:`Bundle file`}),(0,V.jsx)(uu,{id:`bundle-file`,type:`file`,accept:`.json,.agent-deck.json,application/json`,className:`cursor-pointer bg-white/5 border-white/20`,onChange:e=>m(e.target.files?.[0]??null),"data-testid":`input-import-bundle`}),i&&(0,V.jsx)(`p`,{className:`text-xs text-[#A8C4C0]`,"data-testid":`import-preview`,children:i})]}),!o&&(0,V.jsx)(G,{onClick:()=>p.mutate(),disabled:!n||p.isPending||i===`Invalid JSON`,className:`rounded-full border px-6 text-sm font-semibold hover:opacity-90`,style:{background:`#C4B643`,borderColor:`#C4B643`,color:`black`},"data-testid":`button-import-apply`,children:p.isPending?`Importing…`:`Import`}),o&&(0,V.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-white/10 bg-white/5 p-3 text-sm`,"data-testid":`import-report`,children:[(0,V.jsx)(`p`,{className:`font-medium`,children:Wm(o)}),o.servicesNeedingOauth.length>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`text-amber-200`,children:`Needs OAuth reconnect:`}),(0,V.jsx)(`ul`,{className:`list-disc pl-5 text-[#A8C4C0]`,children:o.servicesNeedingOauth.map(e=>(0,V.jsx)(`li`,{children:e},e))})]}),o.warnings.length>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`text-amber-200`,children:`Warnings:`}),(0,V.jsx)(`ul`,{className:`list-disc pl-5 text-[#A8C4C0]`,children:o.warnings.map(e=>(0,V.jsx)(`li`,{children:e},e))})]}),(0,V.jsx)(G,{variant:`outline`,size:`sm`,className:`rounded-full border border-white/20 text-white hover:bg-white/10`,onClick:()=>l(e=>!e),children:c?`Hide id map`:`Show id map`}),c&&(0,V.jsx)(`pre`,{className:`max-h-40 overflow-auto rounded bg-black/40 p-2 text-xs`,children:JSON.stringify(o.idMap,null,2)}),(0,V.jsx)(G,{className:`rounded-full border px-6 text-sm font-semibold hover:opacity-90`,style:{background:`#C4B643`,borderColor:`#C4B643`,color:`black`},onClick:()=>{f(),t(!1)},children:`Done`})]})]})]})})}function EE(){let[e,t]=(0,b.useState)(`connecting`),[n,r]=(0,b.useState)(null),i=(0,b.useRef)(null),a=(0,b.useRef)(null),o=Et();return(0,b.useEffect)(()=>{let e=`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}/api/ws/events`,n=()=>{try{let s=new WebSocket(e);i.current=s,s.onopen=()=>{console.log(`WebSocket connected`),t(`connected`)},s.onmessage=e=>{try{let n=JSON.parse(e.data);r(n),n.type===`deck_update`?(console.log(`Received deck update:`,n),o.invalidateQueries({queryKey:[`/api/decks`]})):n.type===`service_update`?(console.log(`Received service update:`,n),pE(o,typeof n.data?.serviceId==`string`?n.data.serviceId:void 0)):n.type===`connection_status`&&t(n.status===`connected`?`connected`:`disconnected`)}catch(e){console.error(`Failed to parse WebSocket message:`,e)}},s.onclose=()=>{console.log(`WebSocket disconnected`),t(`disconnected`),a.current=setTimeout(()=>{console.log(`Attempting to reconnect WebSocket...`),t(`connecting`),n()},3e3)},s.onerror=e=>{console.error(`WebSocket error:`,e),t(`disconnected`)}}catch(e){console.error(`Failed to connect WebSocket:`,e),t(`disconnected`)}};n();let s=e=>{e.origin===window.location.origin&&hE(e.data)&&pE(o,e.data.serviceId)};return window.addEventListener(`message`,s),()=>{window.removeEventListener(`message`,s),a.current&&clearTimeout(a.current),i.current&&i.current.readyState===WebSocket.OPEN&&i.current.close()}},[o]),{connectionStatus:e,lastMessage:n}}async function DE(e,t){return(await(await H(`GET`,`/api/playbooks/dependents/check?${e===`credential`?`credentialId=${encodeURIComponent(t)}`:`serviceId=${encodeURIComponent(t)}`}`)).json()).data??[]}function OE(e){let[t,n]=(0,b.useState)(null),[r,i]=(0,b.useState)(null),[a,o]=(0,b.useState)(null),[s,c]=(0,b.useState)(!1),l=Et(),{toast:u}=on(),d=()=>{if(!e)throw Error(`Select a deck to edit first`);return e},f=Ht({mutationFn:async e=>{let t=d(),n=(await(await H(`GET`,`/api/decks`)).json()).data?.find(e=>e.id===t);if(!n)throw Error(`Selected deck not found`);if(n.services?.some(t=>t.id===e))throw Error(`Service is already in the deck`);let r=n.services?.length??0;return H(`POST`,`/api/decks/${t}/services`,{serviceId:e,position:r})},onSuccess:()=>{l.invalidateQueries({queryKey:[`/api/decks`]}),u({title:`Service added to deck`,description:`${t?.name||`Service`} has been added to the deck.`})},onError:e=>{u({title:`Failed to add service`,description:e.message,variant:`destructive`})}}),p=Ht({mutationFn:async e=>{let t=d();if(((await(await H(`GET`,`/api/decks`)).json()).data?.find(e=>e.id===t))?.credentials?.some(t=>t.id===e))throw Error(`API key is already in the deck`);return H(`POST`,`/api/decks/${t}/credentials`,{credentialId:e})},onSuccess:()=>{l.invalidateQueries({queryKey:[`/api/decks`]}),u({title:`API key added to deck`,description:`${r?.label||`API key`} is scoped to this deck.`})},onError:e=>{u({title:`Failed to add API key`,description:e.message,variant:`destructive`})}}),m=Ht({mutationFn:async e=>{let t=d();if(((await(await H(`GET`,`/api/decks`)).json()).data?.find(e=>e.id===t))?.playbooks?.some(t=>t.id===e))throw Error(`Playbook is already in the deck`);return H(`POST`,`/api/decks/${t}/playbooks`,{playbookId:e})},onSuccess:()=>{l.invalidateQueries({queryKey:[`/api/decks`]}),u({title:`Playbook added to deck`,description:`${a?.title||`Playbook`} is on this deck.`})},onError:e=>{u({title:`Failed to add playbook`,description:e.message,variant:`destructive`})}}),h=Ht({mutationFn:async e=>{let t=await DE(`service`,e);if(t.length>0){let e=t.map(e=>e.title).join(`, `);if(!window.confirm(`Warning: ${t.length} playbook(s) depend on this MCP (${e}). Remove from deck anyway?`))throw Error(`Cancelled`)}return H(`DELETE`,`/api/decks/${d()}/services`,{serviceId:e})},onSuccess:()=>{l.invalidateQueries({queryKey:[`/api/decks`]}),u({title:`Service removed from deck`,description:`${t?.name||`Service`} has been removed from the deck.`})},onError:e=>{e.message!==`Cancelled`&&u({title:`Failed to remove service`,description:e.message,variant:`destructive`})}}),g=Ht({mutationFn:async e=>{let t=await DE(`credential`,e);if(t.length>0){let e=t.map(e=>e.title).join(`, `);if(!window.confirm(`Warning: ${t.length} playbook(s) depend on this API key (${e}). Remove from deck anyway?`))throw Error(`Cancelled`)}return H(`DELETE`,`/api/decks/${d()}/credentials`,{credentialId:e})},onSuccess:()=>{l.invalidateQueries({queryKey:[`/api/decks`]}),u({title:`API key removed from deck`,description:`${r?.label||`API key`} is no longer on this deck.`})},onError:e=>{e.message!==`Cancelled`&&u({title:`Failed to remove API key`,description:e.message,variant:`destructive`})}}),_=Ht({mutationFn:async e=>H(`DELETE`,`/api/decks/${d()}/playbooks`,{playbookId:e}),onSuccess:()=>{l.invalidateQueries({queryKey:[`/api/decks`]}),u({title:`Playbook removed from deck`,description:`${a?.title||`Playbook`} is no longer on this deck.`})},onError:e=>{u({title:`Failed to remove playbook`,description:e.message,variant:`destructive`})}}),v=(e,t)=>{e.currentTarget instanceof HTMLElement&&(e.currentTarget.style.opacity=t)},y=(e,t)=>{e.dataTransfer.setData(`text/plain`,t.id),e.dataTransfer.setData(`application/json`,JSON.stringify(t)),e.dataTransfer.effectAllowed=t.fromDeck?`move`:`copy`},x=(e,t,r=!1)=>{n(t),i(null),o(null),c(r),y(e,{kind:`service`,id:t.id,fromDeck:r}),v(e,`0.5`)},S=(e,t,r=!1)=>{i(t),n(null),o(null),c(r),y(e,{kind:`credential`,id:t.id,fromDeck:r}),v(e,`0.5`)},C=(e,t,r=!1)=>{o(t),n(null),i(null),c(r),y(e,{kind:`playbook`,id:t.id,fromDeck:r}),v(e,`0.5`)},w=e=>{n(null),i(null),o(null),v(e,`1`)},T=e=>{if(e.kind===`service`){e.fromDeck?h.mutate(e.id):f.mutate(e.id);return}if(e.kind===`credential`){e.fromDeck?g.mutate(e.id):p.mutate(e.id);return}e.fromDeck?_.mutate(e.id):m.mutate(e.id)};return{draggedService:t,draggedCredential:r,draggedPlaybook:a,isDraggingFromDeck:s,handleDragStart:x,handleCredentialDragStart:S,handlePlaybookDragStart:C,handleDragEnd:w,handleDrop:e=>{e.preventDefault();let r=e.dataTransfer.getData(`application/json`);if(r){try{T(JSON.parse(r))}catch{let n=e.dataTransfer.getData(`text/plain`);n&&t&&f.mutate(n)}n(null),i(null),o(null),c(!1)}},handleGlobalDrop:e=>{e.preventDefault();let t=e.dataTransfer.getData(`application/json`);if(t){try{let e=JSON.parse(t);e.fromDeck&&T(e)}catch{}n(null),i(null),o(null),c(!1)}},isDropping:f.isPending||p.isPending||m.isPending||h.isPending||g.isPending||_.isPending}}var kE=`agent-deck-editing-deck-id`;function AE(e){let[t,n]=(0,b.useState)(()=>typeof window>`u`?null:localStorage.getItem(kE));return(0,b.useEffect)(()=>{if(e.length!==0&&!(t&&e.some(e=>e.id===t))){let t=e[0].id;n(t),localStorage.setItem(kE,t)}},[e,t]),{editingDeck:e.find(e=>e.id===t)??null,editingDeckId:t,setEditingDeckId:e=>{n(e),localStorage.setItem(kE,e)}}}function jE(e,[t,n]){return Math.min(n,Math.max(t,e))}function ME(e){let t=b.useRef({value:e,previous:e});return b.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var NE=[` `,`Enter`,`ArrowUp`,`ArrowDown`],PE=[` `,`Enter`],FE=`Select`,[IE,LE,RE]=Sn(FE),[zE,BE]=fn(FE,[RE,Ec]),VE=Ec(),[HE,UE]=zE(FE),[WE,GE]=zE(FE),KE=e=>{let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m}=e,h=VE(t),[g,_]=b.useState(null),[v,y]=b.useState(null),[x,S]=b.useState(!1),C=Vp(l),[w,T]=Zn({prop:r,defaultProp:i??!1,onChange:a,caller:FE}),[E,D]=Zn({prop:o,defaultProp:s,onChange:c,caller:FE}),O=b.useRef(null),k=!g||m||!!g.closest(`form`),[A,j]=b.useState(new Set),M=Array.from(A).map(e=>e.props.value).join(`;`);return(0,V.jsx)(Hc,{...h,children:(0,V.jsxs)(HE,{required:p,scope:t,trigger:g,onTriggerChange:_,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:x,onValueNodeHasChildrenChange:S,contentId:to(),value:E,onValueChange:D,open:w,onOpenChange:T,dir:C,triggerPointerDownPosRef:O,disabled:f,children:[(0,V.jsx)(IE.Provider,{scope:t,children:(0,V.jsx)(WE,{scope:e.__scopeSelect,onNativeOptionAdd:b.useCallback(e=>{j(t=>new Set(t).add(e))},[]),onNativeOptionRemove:b.useCallback(e=>{j(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),k?(0,V.jsxs)(VD,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:d,value:E,onChange:e=>D(e.target.value),disabled:f,form:m,children:[E===void 0?(0,V.jsx)(`option`,{value:``}):null,Array.from(A)]},M):null]})})};KE.displayName=FE;var qE=`SelectTrigger`,JE=b.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=VE(n),o=UE(qE,n),s=o.disabled||r,c=un(t,o.onTriggerChange),l=LE(n),u=b.useRef(`touch`),[d,f,p]=UD(e=>{let t=l().filter(e=>!e.disabled),n=WD(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),m=e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,V.jsx)(Uc,{asChild:!0,...a,children:(0,V.jsx)(Cn.button,{type:`button`,role:`combobox`,"aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":HD(o.value)?``:void 0,...i,ref:c,onClick:U(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:U(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(m(e),e.preventDefault())}),onKeyDown:U(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&NE.includes(e.key)&&(m(),e.preventDefault())})})})});JE.displayName=qE;var YE=`SelectValue`,XE=b.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=UE(YE,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=un(t,c.onValueNodeChange);return Hn(()=>{l(u)},[l,u]),(0,V.jsx)(Cn.span,{...s,ref:d,style:{pointerEvents:`none`},children:HD(c.value)?(0,V.jsx)(V.Fragment,{children:o}):a})});XE.displayName=YE;var ZE=`SelectIcon`,QE=b.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,V.jsx)(Cn.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});QE.displayName=ZE;var $E=`SelectPortal`,eD=e=>(0,V.jsx)(Wn,{asChild:!0,...e});eD.displayName=$E;var tD=`SelectContent`,nD=b.forwardRef((e,t)=>{let n=UE(tD,e.__scopeSelect),[r,i]=b.useState();if(Hn(()=>{i(new DocumentFragment)},[]),!n.open){let t=r;return t?sn.createPortal((0,V.jsx)(iD,{scope:e.__scopeSelect,children:(0,V.jsx)(IE.Slot,{scope:e.__scopeSelect,children:(0,V.jsx)(`div`,{children:e.children})})}),t):null}return(0,V.jsx)(cD,{...e,ref:t})});nD.displayName=tD;var rD=10,[iD,aD]=zE(tD),oD=`SelectContentImpl`,sD=mn(`SelectContent.RemoveScroll`),cD=b.forwardRef((e,t)=>{let{__scopeSelect:n,position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=UE(tD,n),[y,x]=b.useState(null),[S,C]=b.useState(null),w=un(t,e=>x(e)),[T,E]=b.useState(null),[D,O]=b.useState(null),k=LE(n),[A,j]=b.useState(!1),M=b.useRef(!1);b.useEffect(()=>{if(y)return zu(y)},[y]),pu();let N=b.useCallback(e=>{let[t,...n]=k().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&S&&(S.scrollTop=0),n===r&&S&&(S.scrollTop=S.scrollHeight),n?.focus(),document.activeElement!==i))return},[k,S]),P=b.useCallback(()=>N([T,y]),[N,T,y]);b.useEffect(()=>{A&&P()},[A,P]);let{onOpenChange:F,triggerPointerDownPosRef:I}=v;b.useEffect(()=>{if(y){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(I.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(I.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():y.contains(n.target)||F(!1),document.removeEventListener(`pointermove`,t),I.current=null};return I.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[y,F,I]),b.useEffect(()=>{let e=()=>F(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[F]);let[L,ee]=UD(e=>{let t=k().filter(e=>!e.disabled),n=WD(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),te=b.useCallback((e,t,n)=>{let r=!M.current&&!n;(v.value!==void 0&&v.value===t||r)&&(E(e),r&&(M.current=!0))},[v.value]),ne=b.useCallback(()=>y?.focus(),[y]),R=b.useCallback((e,t,n)=>{let r=!M.current&&!n;(v.value!==void 0&&v.value===t||r)&&O(e)},[v.value]),z=r===`popper`?fD:uD,B=z===fD?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,V.jsx)(iD,{scope:n,content:y,viewport:S,onViewportChange:C,itemRefCallback:te,selectedItem:T,onItemLeave:ne,itemTextRefCallback:R,focusSelectedItem:P,selectedItemText:D,position:r,isPositioned:A,searchRef:L,children:(0,V.jsx)(qd,{as:sD,allowPinchZoom:!0,children:(0,V.jsx)(yu,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:U(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,V.jsx)(Nn,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,V.jsx)(z,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...B,onPlaced:()=>j(!0),ref:w,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:U(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&ee(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=k().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>N(t)),e.preventDefault()}})})})})})})});cD.displayName=oD;var lD=`SelectItemAlignedPosition`,uD=b.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=UE(tD,n),o=aD(tD,n),[s,c]=b.useState(null),[l,u]=b.useState(null),d=un(t,e=>u(e)),f=LE(n),p=b.useRef(!1),m=b.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=b.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-rD,d=jE(a,[rD,Math.max(rD,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-rD,d=jE(a,[rD,Math.max(rD,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-rD*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),C=window.getComputedStyle(h),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-rD,D=c-E,O=g.offsetHeight/2,k=g.offsetTop+O,A=m+v+k,j=x-A;if(A<=E){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+h.offsetTop+(e?w:0)+O)+j;s.style.height=t+`px`,h.scrollTop=A-E+h.offsetTop}s.style.margin=`${rD}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);Hn(()=>y(),[y]);let[x,S]=b.useState();Hn(()=>{l&&S(window.getComputedStyle(l).zIndex)},[l]);let C=b.useCallback(e=>{e&&m.current===!0&&(y(),v?.(),m.current=!1)},[y,v]);return(0,V.jsx)(pD,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:C,children:(0,V.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:x},children:(0,V.jsx)(Cn.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});uD.displayName=lD;var dD=`SelectPopperPosition`,fD=b.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=rD,...a}=e,o=VE(n);return(0,V.jsx)(Wc,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});fD.displayName=dD;var[pD,mD]=zE(tD,{}),hD=`SelectViewport`,gD=b.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=aD(hD,n),o=mD(hD,n),s=un(t,a.onViewportChange),c=b.useRef(0);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,V.jsx)(IE.Slot,{scope:n,children:(0,V.jsx)(Cn.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:U(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-rD*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})});gD.displayName=hD;var _D=`SelectGroup`,[vD,yD]=zE(_D),bD=b.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=to();return(0,V.jsx)(vD,{scope:n,id:i,children:(0,V.jsx)(Cn.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});bD.displayName=_D;var xD=`SelectLabel`,SD=b.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=yD(xD,n);return(0,V.jsx)(Cn.div,{id:i.id,...r,ref:t})});SD.displayName=xD;var CD=`SelectItem`,[wD,TD]=zE(CD),ED=b.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=UE(CD,n),c=aD(CD,n),l=s.value===r,[u,d]=b.useState(a??``),[f,p]=b.useState(!1),m=un(t,e=>c.itemRefCallback?.(e,r,i)),h=to(),g=b.useRef(`touch`),_=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};if(r===``)throw Error(`A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.`);return(0,V.jsx)(wD,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:b.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,V.jsx)(IE.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,V.jsx)(Cn.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:U(o.onFocus,()=>p(!0)),onBlur:U(o.onBlur,()=>p(!1)),onClick:U(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:U(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:U(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:U(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:U(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:U(o.onKeyDown,e=>{(c.searchRef?.current===``||e.key!==` `)&&(PE.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});ED.displayName=CD;var DD=`SelectItemText`,OD=b.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=UE(DD,n),s=aD(DD,n),c=TD(DD,n),l=GE(DD,n),[u,d]=b.useState(null),f=un(t,e=>d(e),c.onItemTextChange,e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=u?.textContent,m=b.useMemo(()=>(0,V.jsx)(`option`,{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:h,onNativeOptionRemove:g}=l;return Hn(()=>(h(m),()=>g(m)),[h,g,m]),(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Cn.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?sn.createPortal(a.children,o.valueNode):null]})});OD.displayName=DD;var kD=`SelectItemIndicator`,AD=b.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return TD(kD,n).isSelected?(0,V.jsx)(Cn.span,{"aria-hidden":!0,...r,ref:t}):null});AD.displayName=kD;var jD=`SelectScrollUpButton`,MD=b.forwardRef((e,t)=>{let n=aD(jD,e.__scopeSelect),r=mD(jD,e.__scopeSelect),[i,a]=b.useState(!1),o=un(t,r.onScrollButtonChange);return Hn(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;a(e)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,V.jsx)(FD,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});MD.displayName=jD;var ND=`SelectScrollDownButton`,PD=b.forwardRef((e,t)=>{let n=aD(ND,e.__scopeSelect),r=mD(ND,e.__scopeSelect),[i,a]=b.useState(!1),o=un(t,r.onScrollButtonChange);return Hn(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,V.jsx)(FD,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});PD.displayName=ND;var FD=b.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=aD(`SelectScrollButton`,n),o=b.useRef(null),s=LE(n),c=b.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return b.useEffect(()=>()=>c(),[c]),Hn(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,V.jsx)(Cn.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:U(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:U(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:U(i.onPointerLeave,()=>{c()})})}),ID=`SelectSeparator`,LD=b.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,V.jsx)(Cn.div,{"aria-hidden":!0,...r,ref:t})});LD.displayName=ID;var RD=`SelectArrow`,zD=b.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=VE(n),a=UE(RD,n),o=aD(RD,n);return a.open&&o.position===`popper`?(0,V.jsx)(Gc,{...i,...r,ref:t}):null});zD.displayName=RD;var BD=`SelectBubbleInput`,VD=b.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=b.useRef(null),a=un(r,i),o=ME(t);return b.useEffect(()=>{let e=i.current;if(!e)return;let n=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(n,`value`).set;if(o!==t&&r){let n=new Event(`change`,{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}},[o,t]),(0,V.jsx)(Cn.select,{...n,style:{...er,...n.style},ref:a,defaultValue:t})});VD.displayName=BD;function HD(e){return e===``||e===void 0}function UD(e){let t=Tn(e),n=b.useRef(``),r=b.useRef(0),i=b.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=b.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return b.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function WD(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=GD(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function GD(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var KD=KE,qD=JE,JD=XE,YD=QE,XD=eD,ZD=nD,QD=gD,$D=SD,eO=ED,tO=OD,nO=AD,rO=MD,iO=PD,aO=LD,oO=KD,sO=JD,cO=b.forwardRef(({className:e,children:t,...n},r)=>(0,V.jsxs)(qD,{ref:r,className:W(`flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1`,e),...n,children:[t,(0,V.jsx)(YD,{asChild:!0,children:(0,V.jsx)(gi,{className:`h-4 w-4 opacity-50`})})]}));cO.displayName=qD.displayName;var lO=b.forwardRef(({className:e,...t},n)=>(0,V.jsx)(rO,{ref:n,className:W(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,V.jsx)(yi,{className:`h-4 w-4`})}));lO.displayName=rO.displayName;var uO=b.forwardRef(({className:e,...t},n)=>(0,V.jsx)(iO,{ref:n,className:W(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,V.jsx)(gi,{className:`h-4 w-4`})}));uO.displayName=iO.displayName;var dO=b.forwardRef(({className:e,children:t,position:n=`popper`,...r},i)=>(0,V.jsx)(XD,{children:(0,V.jsxs)(ZD,{ref:i,className:W(`relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,...r,children:[(0,V.jsx)(lO,{}),(0,V.jsx)(QD,{className:W(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]`),children:t}),(0,V.jsx)(uO,{})]})}));dO.displayName=ZD.displayName;var fO=b.forwardRef(({className:e,...t},n)=>(0,V.jsx)($D,{ref:n,className:W(`py-1.5 pl-8 pr-2 text-sm font-semibold`,e),...t}));fO.displayName=$D.displayName;var pO=b.forwardRef(({className:e,children:t,...n},r)=>(0,V.jsxs)(eO,{ref:r,className:W(`relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),...n,children:[(0,V.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,V.jsx)(nO,{children:(0,V.jsx)(hi,{className:`h-4 w-4`})})}),(0,V.jsx)(tO,{children:t})]}));pO.displayName=eO.displayName;var mO=b.forwardRef(({className:e,...t},n)=>(0,V.jsx)(aO,{ref:n,className:W(`-mx-1 my-1 h-px bg-muted`,e),...t}));mO.displayName=aO.displayName;var hO=`/api/mcp/endpoint`;async function gO(){let e=await fetch(hO,{credentials:`include`});if(!e.ok)throw Error(`MCP endpoint request failed: ${e.status}`);let t=(await e.json())?.data?.url;if(typeof t!=`string`||t.length===0)throw Error(`MCP endpoint response did not include a URL`);return t}async function _O(e){try{let t=await gO();await navigator.clipboard.writeText(t),e({title:`MCP URL copied!`,description:t})}catch(t){e({title:`Failed to copy MCP URL`,description:t instanceof Error?t.message:`Unknown error`,variant:`destructive`})}}var vO=`/assets/AgentDeckLogo3-X5qCXS2A.png`,yO=`agent-deck open`,bO=`agent-deck://open`;function xO(e=document){let t=e.createElement(`iframe`);t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`tabindex`,`-1`),t.style.display=`none`,t.src=bO,e.body.appendChild(t),window.setTimeout(()=>{t.remove()},5e3)}async function SO(e=e=>navigator.clipboard.writeText(e)){try{return await e(yO),!0}catch{return!1}}var CO=`Agent Deck carries the method; Agent Dealer runs the issue queue.`;function wO(){let[e,t]=(0,b.useState)(!1),{toast:n}=on();return(0,V.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gray-900`,children:(0,V.jsxs)(`div`,{className:`text-center max-w-lg px-4`,"data-testid":`dashboard-recovery`,children:[(0,V.jsx)(`h2`,{className:`text-2xl font-bold text-gray-100 mb-4`,children:`Open your dashboard securely`}),(0,V.jsx)(`p`,{className:`text-gray-300 mb-2`,children:`This page is Agent Deck running on your own machine — nothing is broken.`}),(0,V.jsx)(`p`,{className:`text-gray-400 text-sm mb-6`,children:`Your browser just doesn't have a launch pass yet. Agent Deck opens the dashboard with a fresh pass each time, so typing this address alone can never sign anyone in — this page can't grant access by itself.`}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>{xO(),t(!0)},"data-testid":`button-open-dashboard`,className:`px-5 py-2.5 bg-blue-600 text-white rounded hover:bg-blue-700 font-medium`,children:(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,V.jsx)(Di,{className:`w-4 h-4`}),`Open dashboard`]})}),e&&(0,V.jsxs)(`div`,{className:`mt-6 rounded-lg border border-white/10 bg-black/30 p-4`,"data-testid":`dashboard-recovery-manual`,children:[(0,V.jsx)(`p`,{className:`text-gray-300 text-sm mb-1`,children:`If nothing opened, run this in your terminal:`}),(0,V.jsx)(`code`,{className:`mb-3 block rounded bg-black/40 px-3 py-2 text-gray-100 select-all`,children:`agent-deck open`}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>{SO().then(e=>{n(e?{title:`Command copied`,description:`Run it in your terminal.`}:{title:`Copy failed`,description:`Type this in your terminal: ${yO}`})})},"data-testid":`button-copy-open-command`,className:`px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 text-sm`,children:(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,V.jsx)(wi,{className:`w-4 h-4`}),`Copy command`]})}),(0,V.jsxs)(`p`,{className:`text-gray-500 text-xs mt-3`,children:[`Then come back here and reload — or pick `,(0,V.jsx)(`strong`,{children:`Open dashboard`}),` from the Agent Deck menubar, which runs the same command.`]})]})]})})}function TO(){let[e,t]=(0,b.useState)(``),[n,r]=(0,b.useState)(``),[i,a]=(0,b.useState)(!1),[o,s]=(0,b.useState)(!1),[c,l]=(0,b.useState)(null),[u,d]=(0,b.useState)(!1),[f,p]=(0,b.useState)(!1),[m,h]=(0,b.useState)(null),[g,_]=(0,b.useState)(!1),[v,y]=(0,b.useState)(!1),[x,S]=(0,b.useState)(null),[C,w]=(0,b.useState)(!1),[T,E]=(0,b.useState)(!1),[D,O]=(0,b.useState)(!1),[k,A]=(0,b.useState)(null),{toast:j}=on(),{connectionStatus:M}=EE(),{data:N=[]}=Vt({queryKey:[`/api/playbook-patches`,`proposed`],queryFn:()=>Xm(`proposed`)}),{data:P=0}=Vt({queryKey:[`/api/feedback-signals/count`,`available`],queryFn:()=>nh()}),F=async()=>{O(!0);try{let e=await Bm({scope:`collection`});Hm(e,`backup.agent-deck.json`),j({title:`Exported collection`,description:`${e.services.length} services, ${e.playbooks.length} playbooks, ${e.decks.length} decks`})}catch(e){j({title:`Export failed`,description:e instanceof Error?e.message:`Unknown error`,variant:`destructive`})}finally{O(!1)}},{data:I,isLoading:L,error:ee}=Vt({queryKey:[`/api/decks`]}),te=I?.data||[],{editingDeck:ne,editingDeckId:R,setEditingDeckId:z}=AE(te),{handleDragStart:B,handleCredentialDragStart:re,handlePlaybookDragStart:ie,handleDragEnd:ae,handleDrop:oe,handleGlobalDrop:se,isDraggingFromDeck:ce}=OE(R),{data:le,isLoading:ue,error:de}=Vt({queryKey:[`/api/services`]}),{data:fe,isLoading:pe}=Vt({queryKey:[`/api/credentials/vault`]}),{data:me,isLoading:he}=Vt({queryKey:[`/api/playbooks/vault`]}),{data:ge}=Vt({queryKey:[`/api/collection/warnings`],staleTime:6e4}),_e=le?.data||[],ve=fe?.data||[],be=me?.data||[],xe=(0,b.useMemo)(()=>Ol(ge?.data),[ge?.data]),Se=(e,t)=>i?e===`service`?xe.serviceWarnings.has(t):e===`credential`?xe.credentialWarnings.has(t):xe.playbookWarnings.has(t):!0,Ce=_e.filter(t=>{if(!Se(`service`,t.id)||n===`api-key`||n===`playbook`)return!1;let r=t.name.toLowerCase().includes(e.toLowerCase())||t.description?.toLowerCase().includes(e.toLowerCase()),i=!n||n===`all`||t.type===n;return r&&i}),we=ve.filter(t=>!Se(`credential`,t.id)||n&&n!==`all`&&n!==`api-key`?!1:t.label.toLowerCase().includes(e.toLowerCase())),Te=be.filter(t=>!Se(`playbook`,t.id)||n&&n!==`all`&&n!==`playbook`?!1:t.title.toLowerCase().includes(e.toLowerCase())||t.body.toLowerCase().includes(e.toLowerCase())),Ee=Ce.length+we.length+Te.length;de&&console.error(`Services error:`,de),ee&&console.error(`Decks error:`,ee);let De=()=>{t(``),r(``),a(!1)},Oe=!!(e||n||i),ke=new Set((ne?.credentials??[]).map(e=>e.id)),Ae=new Set((ne?.playbooks??[]).map(e=>e.id)),je=ne?.services||[],Me=ne?.playbooks||[],Ne=e=>{l(e),d(!0)},Pe=e=>{S(e.id),w(!0)},Fe=e=>{h(e.id),_(!0)},Ie=e=>{A(e)};if(de||ee){if(Wt(ee)||Wt(de))return(0,V.jsx)(wO,{});let e=(ee instanceof Error?ee.message:null)??(de instanceof Error?de.message:null)??`There was an error loading the application data.`;return(0,V.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gray-900`,children:(0,V.jsxs)(`div`,{className:`text-center max-w-lg px-4`,children:[(0,V.jsx)(`h2`,{className:`text-2xl font-bold text-red-400 mb-4`,children:`Error Loading Data`}),(0,V.jsx)(`p`,{className:`text-gray-300 mb-2`,children:`There was an error loading the application data.`}),(0,V.jsx)(`p`,{className:`text-gray-400 text-sm mb-4`,children:e}),(0,V.jsxs)(`p`,{className:`text-gray-500 text-xs mb-6`,children:[`Is the API running? Try `,(0,V.jsx)(`code`,{className:`text-gray-300`,children:`agent-deck stop && agent-deck start`})]}),(0,V.jsx)(`button`,{onClick:()=>window.location.reload(),className:`px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700`,children:`Reload Page`})]})})}return ue||L||pe||he?(0,V.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gray-900`,children:(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(`div`,{className:`animate-spin rounded-full h-12 w-12 border-b-2 border-yellow-400 mx-auto mb-4`}),(0,V.jsx)(`p`,{className:`text-gray-300`,children:`Loading AgentDeck...`})]})}):(0,V.jsxs)(`div`,{className:`flex min-h-dvh flex-col overflow-x-hidden`,onDrop:se,onDragOver:e=>e.preventDefault(),style:{position:`relative`,...ce&&{background:`linear-gradient(to bottom right, #1a1a2e, #16213e, #0f3460)`}},children:[(0,V.jsx)(`header`,{className:`relative z-20 shrink-0 bg-black/30 backdrop-blur-md border-b border-white/10`,"data-testid":`top-bar`,children:(0,V.jsx)(`div`,{className:`container mx-auto px-4 py-2`,children:(0,V.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between sm:gap-3`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`img`,{src:vO,alt:`Agent Deck Logo`,className:`h-9 w-9 shrink-0 object-contain`}),(0,V.jsx)(`h1`,{className:`whitespace-nowrap text-xl font-bold bg-gradient-to-r from-yellow-400 to-yellow-600 bg-clip-text text-transparent`,style:{background:`linear-gradient(to right, #C4B643, #D4C760)`,WebkitBackgroundClip:`text`,WebkitTextFillColor:`transparent`,backgroundClip:`text`},children:`AgentDeck`}),(0,V.jsx)(`p`,{className:`sr-only`,children:`Build tool deck for your agent`})]}),(0,V.jsxs)(`div`,{className:`flex flex-nowrap items-center gap-2 overflow-x-auto -my-1 py-1 sm:gap-3`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`flex h-9 shrink-0 items-center gap-2 whitespace-nowrap rounded-full border px-3 text-sm ${M===`connected`?`bg-emerald-500/20 border-emerald-500/30`:`bg-red-500/20 border-red-500/30`}`,"data-testid":`button-copy-mcp-url`,onClick:()=>{_O(j)},title:`Click to copy MCP URL`,children:[(0,V.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full animate-pulse ${M===`connected`?`bg-emerald-400`:`bg-red-400`}`,"aria-hidden":!0}),(0,V.jsx)(`span`,{className:`font-ui-display hover:underline ${M===`connected`?`text-emerald-300`:`text-red-300`}`,children:`Get MCP URL`})]}),(0,V.jsx)(zf,{highlightDeckId:R??void 0}),(0,V.jsx)(ye,{href:`/feedback-signals`,children:(0,V.jsxs)(G,{variant:`outline`,size:`sm`,className:`relative shrink-0 border-white/20 bg-white/5 text-[#E8F6F4]`,children:[(0,V.jsx)(`span`,{className:`font-ui-display`,children:`Feedback`}),P>0&&(0,V.jsx)(`span`,{className:`ml-2 rounded-full px-2 py-0.5 text-xs font-semibold`,style:{background:`#C4B643`,color:`#0A0A07`},title:`Open feedback available for curation`,children:P})]})}),(0,V.jsx)(ye,{href:`/playbook-patches`,children:(0,V.jsxs)(G,{variant:`outline`,size:`sm`,className:`relative shrink-0 border-white/20 bg-white/5 text-[#E8F6F4]`,children:[(0,V.jsx)(ki,{className:`mr-2 h-4 w-4`}),(0,V.jsx)(`span`,{className:`font-ui-display`,children:`Review`}),N.length>0&&(0,V.jsx)(`span`,{className:`ml-2 rounded-full px-2 py-0.5 text-xs font-semibold`,style:{background:`#C4B643`,color:`#0A0A07`},title:`Proposed playbook patches`,children:N.length})]})})]})]})})}),ce&&(0,V.jsx)(`div`,{className:`fixed inset-0 pointer-events-none z-50 flex items-center justify-center`,children:(0,V.jsxs)(`div`,{className:`bg-red-500/20 border-2 border-dashed border-red-500/50 rounded-lg p-8 text-center`,children:[(0,V.jsx)(`div`,{className:`text-red-400 text-lg font-bold mb-2`,children:`Drop to Remove`}),(0,V.jsx)(`div`,{className:`text-red-300 text-sm`,children:`Release to remove card from deck`})]})}),(0,V.jsx)(`main`,{className:`container mx-auto flex min-h-0 flex-1 flex-col px-4 py-4 sm:py-6`,children:(0,V.jsxs)(`div`,{className:`grid min-w-0 grid-cols-1 gap-4 sm:gap-6 xl:min-h-0 xl:flex-1 xl:grid-cols-4 xl:overflow-hidden`,children:[(0,V.jsxs)(`div`,{className:`min-w-0 space-y-4 sm:space-y-6 xl:col-span-1 xl:min-h-0 xl:overflow-y-auto`,children:[(0,V.jsx)(`div`,{className:`panel-surface h-64 overflow-hidden p-4 min-w-0 sm:h-72 xl:h-80`,children:(0,V.jsx)(Gm,{decks:te,editingDeckId:R,onSelectDeck:z,isLoading:L})}),(0,V.jsxs)(`div`,{className:`panel-surface p-4`,children:[(0,V.jsxs)(`h2`,{className:`text-lg font-bold mb-3 flex items-center`,children:[(0,V.jsx)(di,{className:`w-4 h-4 mr-2`,style:{color:`#92E4DD`}}),(0,V.jsx)(`span`,{className:`font-ui-display`,style:{color:`#92E4DD`},children:`Add Cards`})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsxs)(G,{variant:`ghost`,className:`w-full border-2 text-sm py-2 hover:opacity-90 ${Ml}`,style:Pl(kl),onClick:()=>s(!0),"data-testid":`button-register-mcp`,children:[(0,V.jsx)(zi,{className:`w-3 h-3 mr-2`}),(0,V.jsx)(`span`,{className:`font-ui-display`,children:`Register MCP`})]}),(0,V.jsxs)(G,{variant:`ghost`,className:`w-full border-2 text-sm py-2 hover:opacity-90 ${Ml}`,style:Pl(Al),onClick:()=>p(!0),"data-testid":`button-register-api-key`,children:[(0,V.jsx)(Ai,{className:`w-3 h-3 mr-2`}),(0,V.jsx)(`span`,{className:`font-ui-display`,children:`Register API key`})]}),(0,V.jsxs)(G,{variant:`ghost`,className:`w-full border-2 text-sm py-2 hover:opacity-90 ${Ml}`,style:Pl(jl),onClick:()=>y(!0),"data-testid":`button-register-playbook`,children:[(0,V.jsx)(fi,{className:`w-3 h-3 mr-2`}),(0,V.jsx)(`span`,{className:`font-ui-display`,children:`Register Playbook`})]})]})]})]}),(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4 sm:gap-6 xl:col-span-3 xl:h-full xl:min-h-0`,children:[(0,V.jsx)(`div`,{className:`panel-surface h-64 shrink-0 overflow-hidden p-4 min-w-0 sm:h-72 xl:h-80`,children:ne?(0,V.jsx)(`div`,{className:`h-full`,children:(0,V.jsx)(du,{deck:ne,services:je,credentials:ne.credentials??[],playbooks:Me,allServices:_e,collectionWarnings:xe,onDrop:oe,onDragStart:B,onCredentialDragStart:re,onPlaybookDragStart:ie,onDragEnd:ae,onCardClick:Ne,onPlaybookClick:Pe,onCredentialClick:Fe})}):(0,V.jsxs)(`div`,{className:`text-center h-full flex flex-col justify-center`,children:[(0,V.jsx)(`div`,{className:`w-12 h-12 rounded-full bg-yellow-500/20 border border-yellow-500/30 flex items-center justify-center mx-auto mb-3`,children:(0,V.jsx)(Mi,{className:`w-6 h-6 text-yellow-400`})}),(0,V.jsx)(`h3`,{className:`text-lg font-bold mb-2`,style:{color:`#92E4DD`},children:`No deck selected`}),(0,V.jsx)(`p`,{className:`text-gray-300 mb-4 text-sm`,children:`Create a deck or select one from the sidebar to edit its cards.`}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,V.jsxs)(G,{onClick:()=>{let e=document.querySelector(`[data-testid="create-deck-button"]`);e&&e.click()},className:`border text-sm py-2`,style:{background:`#C4B643`,borderColor:`#C4B643`,color:`black`},children:[(0,V.jsx)(Ii,{className:`w-4 h-4 mr-2`}),`Create New Deck`]}),(0,V.jsxs)(G,{variant:`outline`,className:`border-white/20 text-white hover:bg-white/10 text-sm py-2`,onClick:()=>{let e=document.querySelector(`[data-testid="deck-management-panel"]`);e&&e.scrollIntoView({behavior:`smooth`})},children:[(0,V.jsx)(Mi,{className:`w-4 h-4 mr-2`}),`Manage Decks`]})]})]})}),(0,V.jsxs)(`div`,{className:`panel-surface flex min-h-[20rem] flex-col overflow-hidden p-4 min-w-0 sm:min-h-[24rem] xl:min-h-0 xl:flex-1`,"data-testid":`collection-panel`,children:[(0,V.jsxs)(`div`,{className:`mb-3 flex shrink-0 flex-wrap items-center justify-between gap-2`,children:[(0,V.jsxs)(`h2`,{className:`text-lg font-bold flex items-center`,children:[(0,V.jsx)(Ni,{className:`w-4 h-4 mr-2`,style:{color:`#92E4DD`}}),(0,V.jsx)(`span`,{className:`font-ui-display`,style:{color:`#92E4DD`},children:`My Collection`}),(0,V.jsxs)(`span`,{className:`ml-3 text-sm font-normal text-gray-400`,children:[`(`,Ee,` cards)`]})]}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsxs)(G,{size:`sm`,variant:`outline`,className:`h-8 px-2 text-xs border-white/20 text-white hover:bg-white/10`,onClick:F,disabled:D,title:`Export all MCP, playbooks, and decks`,"data-testid":`button-export-all`,children:[(0,V.jsx)(Ei,{className:`w-3 h-3 mr-1`}),(0,V.jsx)(`span`,{className:`font-ui-display`,children:D?`Exporting…`:`Export all`})]}),(0,V.jsxs)(G,{size:`sm`,variant:`outline`,className:`h-8 px-2 text-xs border-white/20 text-white hover:bg-white/10`,onClick:()=>E(!0),title:`Import a bundle file`,"data-testid":`button-import-bundle`,children:[(0,V.jsx)(Wi,{className:`w-3 h-3 mr-1`}),(0,V.jsx)(`span`,{className:`font-ui-display`,children:`Import`})]}),(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)(Ri,{className:`absolute left-2 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4`}),(0,V.jsx)(uu,{placeholder:`Search...`,value:e,onChange:e=>t(e.target.value),className:`h-8 w-36 pl-8 text-sm bg-white/10 border-white/20 text-white placeholder-gray-400 sm:w-48`,"data-testid":`input-search`})]}),(0,V.jsxs)(oO,{value:n||`all`,onValueChange:e=>r(e===`all`?``:e),children:[(0,V.jsxs)(cO,{className:`w-[7.5rem] h-8 bg-white/10 border-white/20 text-white text-xs shrink-0`,"data-testid":`select-type`,children:[(0,V.jsx)(Oi,{className:`w-3 h-3 mr-1 shrink-0`}),(0,V.jsx)(sO,{placeholder:`Type`})]}),(0,V.jsxs)(dO,{children:[(0,V.jsx)(pO,{value:`all`,children:`All`}),(0,V.jsx)(pO,{value:`mcp`,children:`MCP`}),(0,V.jsx)(pO,{value:`local-mcp`,children:`Local MCP`}),(0,V.jsx)(pO,{value:`api-key`,children:`API Key`}),(0,V.jsx)(pO,{value:`playbook`,children:`Playbook`})]})]}),(e||n||i)&&(0,V.jsx)(G,{size:`sm`,variant:`outline`,className:`h-8 px-2 text-xs border-white/20 text-white hover:bg-white/10`,onClick:De,title:`Clear all filters`,children:`Clear`})]})]}),xe.total>0&&(0,V.jsx)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`mb-3 w-full shrink-0 rounded-lg border px-3 py-2 text-left text-sm transition-colors ${i?`border-amber-300/60 bg-amber-500/15 text-amber-100`:`border-amber-400/30 bg-amber-500/10 text-amber-100 hover:bg-amber-500/15`}`,"data-testid":`button-collection-warnings`,children:(0,V.jsxs)(`span`,{className:`flex items-start gap-2`,children:[(0,V.jsx)(Ui,{className:`mt-0.5 h-4 w-4 shrink-0 text-amber-300`}),(0,V.jsx)(`span`,{children:i?(0,V.jsxs)(V.Fragment,{children:[`Showing `,(0,V.jsx)(`strong`,{children:Ee}),` card`,Ee===1?``:`s`,` needing attention.`,(0,V.jsx)(`span`,{className:`text-amber-200/80`,children:` Click to show all cards.`})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`strong`,{children:xe.total}),` card`,xe.total===1?``:`s`,` need attention`,xe.byKind.oauth_expired+xe.byKind.oauth_required>0&&(0,V.jsxs)(V.Fragment,{children:[` `,`(`,xe.byKind.oauth_expired+xe.byKind.oauth_required,` `,`OAuth)`]}),`. `,(0,V.jsx)(`span`,{className:`text-amber-200/80`,children:`Click to filter.`})]})})]})}),(0,V.jsx)(`div`,{className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto px-1 py-2`,children:ue||pe||he?(0,V.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,5rem)] gap-y-2 pr-12`,children:Array.from({length:10}).map((e,t)=>(0,V.jsx)(`div`,{className:`animate-pulse`,children:(0,V.jsx)(`div`,{className:`bg-white/10 rounded-lg w-32 h-48 aspect-[2/3]`})},t))}):Ee===0?(0,V.jsxs)(`div`,{className:`text-center py-12`,children:[(0,V.jsx)(`div`,{className:`text-gray-400 mb-4`,children:(0,V.jsx)(`i`,{className:`fas fa-layer-group text-4xl`})}),(0,V.jsx)(`h3`,{className:`text-lg font-semibold text-gray-300 mb-2`,children:`No cards yet`}),(0,V.jsx)(`p`,{className:`text-gray-400 text-sm mb-4`,children:Oe?i?`No cards with warnings match your current filters`:`Try adjusting your search or filters`:`Register an MCP server, API key, or playbook to get started`}),!Oe&&(0,V.jsxs)(`div`,{className:`flex gap-3 justify-center`,children:[(0,V.jsxs)(G,{variant:`ghost`,size:`sm`,className:`border-2 hover:opacity-90 bg-gradient-to-b from-gray-900 via-gray-800 to-gray-900`,style:Pl(`#92E4DD`),onClick:()=>s(!0),"data-testid":`button-register-mcp-empty`,children:[(0,V.jsx)(zi,{className:`w-3 h-3 mr-1`}),(0,V.jsx)(`span`,{className:`font-ui-display`,children:`Register MCP`})]}),(0,V.jsxs)(G,{variant:`ghost`,size:`sm`,className:`border-2 hover:opacity-90 bg-gradient-to-b from-gray-900 via-gray-800 to-gray-900`,style:Pl(`#F9386D`),onClick:()=>p(!0),"data-testid":`button-register-api-key-empty`,children:[(0,V.jsx)(Ai,{className:`w-3 h-3 mr-1`}),(0,V.jsx)(`span`,{className:`font-ui-display`,children:`Register API key`})]})]})]}):(0,V.jsxs)(`div`,{className:`relative isolate grid grid-cols-[repeat(auto-fill,5rem)] gap-y-2 pr-12`,style:{isolation:`isolate`},"data-testid":`collection-card-grid`,children:[Te.map((e,t)=>(0,V.jsx)(`div`,{className:`relative group`,style:{zIndex:k===e.id?999999:Ee-t},children:(0,V.jsx)(Yl,{playbook:e,isInActiveDeck:Ae.has(e.id),activeDeck:ne??void 0,isInCollection:!0,onDragStart:ie,onDragEnd:ae,onCardClick:Pe,onMouseEnter:()=>Ie(e.id),onMouseLeave:()=>Ie(null),warnings:xe.playbookWarnings.get(e.id)})},e.id)),we.map((e,t)=>(0,V.jsx)(`div`,{className:`relative group`,style:{zIndex:k===e.id?999999:Ee-Te.length-t},children:(0,V.jsx)(ql,{credential:e,isInActiveDeck:ke.has(e.id),activeDeck:ne??void 0,isInCollection:!0,onDragStart:re,onDragEnd:ae,onMouseEnter:()=>Ie(e.id),onMouseLeave:()=>Ie(null),onCardClick:Fe,warnings:xe.credentialWarnings.get(e.id)})},e.id)),Ce.map((e,t)=>(0,V.jsx)(`div`,{className:`relative group`,style:{zIndex:k===e.id?999999:Ee-Te.length-we.length-t},children:(0,V.jsx)(Ul,{service:e,onDragStart:B,onDragEnd:ae,isInActiveDeck:ne?.services?.some(t=>t.id===e.id)||!1,onCardClick:Ne,isInCollection:!0,onMouseEnter:()=>Ie(e.id),onMouseLeave:()=>Ie(null),activeDeck:ne??void 0,warnings:xe.serviceWarnings.get(e.id)})},e.id))]})})]})]})]})}),(0,V.jsx)(`footer`,{className:`shrink-0 border-t border-white/5 py-2 text-center text-xs text-gray-500`,"data-testid":`deck-dealer-note`,children:CO}),(0,V.jsxs)(`div`,{className:`fixed inset-0 pointer-events-none z-0 overflow-hidden`,children:[(0,V.jsx)(`div`,{className:`absolute top-20 left-20`,children:(0,V.jsx)(`div`,{className:`h-96 w-96 rounded-full bg-cyan-500/10 blur-3xl animate-orb-drift-1`})}),(0,V.jsx)(`div`,{className:`absolute bottom-20 right-20`,children:(0,V.jsx)(`div`,{className:`h-96 w-96 rounded-full bg-pink-500/10 blur-3xl animate-orb-drift-2`})}),(0,V.jsx)(`div`,{className:`absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2`,children:(0,V.jsx)(`div`,{className:`h-96 w-96 rounded-full bg-purple-500/5 blur-3xl animate-orb-drift-3`})})]}),(0,V.jsx)(Rm,{type:`mcp`,open:o,onOpenChange:s}),(0,V.jsx)(wE,{service:c,isOpen:u,onClose:()=>d(!1)}),(0,V.jsx)(Km,{open:f,onOpenChange:p}),(0,V.jsx)(uh,{credentialId:m,open:g,onOpenChange:_}),(0,V.jsx)(qm,{open:v,onOpenChange:y}),(0,V.jsx)(lh,{playbookId:x,open:C,onOpenChange:w}),(0,V.jsx)(TE,{open:T,onOpenChange:E})]})}var EO=b.forwardRef(({className:e,...t},n)=>(0,V.jsx)(`div`,{ref:n,className:W(`rounded-lg border bg-card text-card-foreground shadow-sm`,e),...t}));EO.displayName=`Card`;var DO=b.forwardRef(({className:e,...t},n)=>(0,V.jsx)(`div`,{ref:n,className:W(`flex flex-col space-y-1.5 p-6`,e),...t}));DO.displayName=`CardHeader`;var OO=b.forwardRef(({className:e,...t},n)=>(0,V.jsx)(`div`,{ref:n,className:W(`text-2xl font-semibold leading-none tracking-tight`,e),...t}));OO.displayName=`CardTitle`;var kO=b.forwardRef(({className:e,...t},n)=>(0,V.jsx)(`div`,{ref:n,className:W(`text-sm text-muted-foreground`,e),...t}));kO.displayName=`CardDescription`;var AO=b.forwardRef(({className:e,...t},n)=>(0,V.jsx)(`div`,{ref:n,className:W(`p-6 pt-0`,e),...t}));AO.displayName=`CardContent`;var jO=b.forwardRef(({className:e,...t},n)=>(0,V.jsx)(`div`,{ref:n,className:W(`flex items-center p-6 pt-0`,e),...t}));jO.displayName=`CardFooter`;function MO(){return(0,V.jsx)(`div`,{className:`min-h-screen w-full flex items-center justify-center bg-gray-50`,children:(0,V.jsx)(EO,{className:`w-full max-w-md mx-4`,children:(0,V.jsxs)(AO,{className:`pt-6`,children:[(0,V.jsxs)(`div`,{className:`flex mb-4 gap-2`,children:[(0,V.jsx)(bi,{className:`h-8 w-8 text-red-500`}),(0,V.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900`,children:`404 Page Not Found`})]}),(0,V.jsx)(`p`,{className:`mt-4 text-sm text-gray-600`,children:`Did you forget to add the page to the router?`})]})})})}function NO(){let[e]=pe(),[t,n]=(0,b.useState)(`loading`),[r,i]=(0,b.useState)(`Authenticating...`);return(0,b.useEffect)(()=>{(async()=>{try{let e=new URL(window.location.href),t=e.searchParams.get(`success`),r=e.searchParams.get(`error`),a=e.searchParams.get(`serviceId`);t===`true`?(n(`success`),i(`Authentication successful! This window will close automatically.`),window.opener&&!window.opener.closed&&window.opener.postMessage({type:mE,serviceId:a??void 0},window.location.origin),setTimeout(()=>{window.close()},2e3)):t===`false`?(n(`error`),i(`OAuth Error: ${r||`Authentication failed`}`)):(n(`error`),i(`Invalid OAuth callback - please try again`))}catch(e){n(`error`),i(e instanceof Error?e.message:`Authentication failed`)}})()},[e]),(0,V.jsx)(`div`,{className:`flex items-center justify-center min-h-screen bg-background`,children:(0,V.jsxs)(`div`,{className:`text-center space-y-4`,children:[t===`loading`&&(0,V.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto`}),t===`success`&&(0,V.jsx)(`div`,{className:`text-green-500 text-4xl`,children:`✓`}),t===`error`&&(0,V.jsx)(`div`,{className:`text-red-500 text-4xl`,children:`✗`}),(0,V.jsx)(`h1`,{className:`text-xl font-semibold`,children:r}),t===`error`&&(0,V.jsx)(`button`,{onClick:()=>window.close(),className:`px-4 py-2 bg-primary text-primary-foreground rounded hover:bg-primary/90`,children:`Close Window`})]})})}function PO(e){let t=()=>{throw Error(`Invalid url to pass to open(): ${e}`)},n;try{n=new URL(e)}catch{t()}return n.protocol!==`https:`&&n.protocol!==`http:`&&t(),n.hostname!==encodeURIComponent(n.hostname)&&t(),n.username&&(n.username=encodeURIComponent(n.username)),n.password&&(n.password=encodeURIComponent(n.password)),n.pathname=n.pathname.slice(0,1)+encodeURIComponent(n.pathname.slice(1)).replace(/%2f/gi,`/`),n.search=n.search.slice(0,1)+Array.from(n.searchParams.entries()).map(FO).join(`&`),n.hash=n.hash.slice(0,1)+encodeURIComponent(n.hash.slice(1)),n.href}function FO([e,t]){return`${encodeURIComponent(e)}${t.length>0?`=${encodeURIComponent(t)}`:``}`}var IO=class{serverUrl;storageKeyPrefix;serverUrlHash;clientName;clientUri;callbackUrl;preventAutoAuth;onPopupWindow;constructor(e,t={}){this.serverUrl=e,this.storageKeyPrefix=t.storageKeyPrefix||`mcp:auth`,this.serverUrlHash=this.hashString(e),this.clientName=t.clientName||`MCP Browser Client`,this.clientUri=t.clientUri||(typeof window<`u`?window.location.origin:``),this.callbackUrl=PO(t.callbackUrl||(typeof window<`u`?new URL(`/oauth/callback`,window.location.origin).toString():`/oauth/callback`)),this.preventAutoAuth=t.preventAutoAuth,this.onPopupWindow=t.onPopupWindow}get redirectUrl(){return PO(this.callbackUrl)}get clientMetadata(){return{redirect_uris:[this.redirectUrl],token_endpoint_auth_method:`none`,grant_types:[`authorization_code`,`refresh_token`],response_types:[`code`],client_name:this.clientName,client_uri:this.clientUri}}async clientInformation(){let e=this.getKey(`client_info`),t=localStorage.getItem(e);if(t)try{return JSON.parse(t)}catch(t){console.warn(`[${this.storageKeyPrefix}] Failed to parse client information:`,t),localStorage.removeItem(e);return}}async saveClientInformation(e){let t=this.getKey(`client_info`);localStorage.setItem(t,JSON.stringify(e))}async tokens(){let e=this.getKey(`tokens`),t=localStorage.getItem(e);if(t)try{return JSON.parse(t)}catch(t){console.warn(`[${this.storageKeyPrefix}] Failed to parse tokens:`,t),localStorage.removeItem(e);return}}async saveTokens(e){let t=this.getKey(`tokens`);localStorage.setItem(t,JSON.stringify(e)),localStorage.removeItem(this.getKey(`code_verifier`)),localStorage.removeItem(this.getKey(`last_auth_url`))}async saveCodeVerifier(e){let t=this.getKey(`code_verifier`);localStorage.setItem(t,e)}async codeVerifier(){let e=this.getKey(`code_verifier`),t=localStorage.getItem(e);if(!t)throw Error(`[${this.storageKeyPrefix}] Code verifier not found in storage for key ${e}. Auth flow likely corrupted or timed out.`);return t}async prepareAuthorizationUrl(e){let t=crypto.randomUUID(),n=`${this.storageKeyPrefix}:state_${t}`,r={serverUrlHash:this.serverUrlHash,expiry:Date.now()+6e5,providerOptions:{serverUrl:this.serverUrl,storageKeyPrefix:this.storageKeyPrefix,clientName:this.clientName,clientUri:this.clientUri,callbackUrl:this.callbackUrl}};localStorage.setItem(n,JSON.stringify(r)),e.searchParams.set(`state`,t);let i=PO(e.toString());return localStorage.setItem(this.getKey(`last_auth_url`),i),i}async redirectToAuthorization(e){if(this.preventAutoAuth)return;let t=await this.prepareAuthorizationUrl(e),n=`width=600,height=700,resizable=yes,scrollbars=yes,status=yes`;try{let e=window.open(t,`mcp_auth_${this.serverUrlHash}`,n);this.onPopupWindow&&this.onPopupWindow(t,n,e),!e||e.closed||e.closed===void 0?console.warn(`[${this.storageKeyPrefix}] Popup likely blocked by browser. Manual navigation might be required using the stored URL.`):(e.focus(),console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL in popup.`))}catch(e){console.error(`[${this.storageKeyPrefix}] Error opening popup window:`,e)}}getLastAttemptedAuthUrl(){let e=localStorage.getItem(this.getKey(`last_auth_url`));return e?PO(e):null}clearStorage(){let e=`${this.storageKeyPrefix}_${this.serverUrlHash}_`,t=`${this.storageKeyPrefix}:state_`,n=[],r=0;for(let r=0;r<localStorage.length;r++){let i=localStorage.key(r);if(i){if(i.startsWith(e))n.push(i);else if(i.startsWith(t))try{let e=localStorage.getItem(i);e&&JSON.parse(e).serverUrlHash===this.serverUrlHash&&n.push(i)}catch(e){console.warn(`[${this.storageKeyPrefix}] Error parsing state key ${i} during clearStorage:`,e)}}}return[...new Set(n)].forEach(e=>{localStorage.removeItem(e),r++}),r}hashString(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r,t&=t}return Math.abs(t).toString(16)}getKey(e){return`${this.storageKeyPrefix}_${this.serverUrlHash}_${e}`}},LO=Object.freeze({status:`aborted`});function J(e,t,n){function r(n,r){var i;Object.defineProperty(n,"_zod",{value:n._zod??{},enumerable:!1}),(i=n._zod).traits??(i.traits=new Set),n._zod.traits.add(e),t(n,r);for(let e in o.prototype)e in n||Object.defineProperty(n,e,{value:o.prototype[e].bind(n)});n._zod.constr=o,n._zod.def=r}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var RO=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},zO={};function BO(e){return e&&Object.assign(zO,e),zO}function VO(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function HO(e,t){return typeof t==`bigint`?t.toString():t}function UO(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function WO(e){return e==null}function GO(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function KO(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}function qO(e,t,n){Object.defineProperty(e,t,{get(){{let r=n();return e[t]=r,r}},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function JO(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function YO(e){return JSON.stringify(e)}var XO=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function ZO(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var QO=UO(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function $O(e){if(ZO(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return ZO(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}var ek=new Set([`string`,`number`,`symbol`]);function tk(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function nk(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function Y(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function rk(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var ik={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function ak(e,t){let n={},r=e._zod.def;for(let e in t){if(!(e in r.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&(n[e]=r.shape[e])}return nk(e,{...e._zod.def,shape:n,checks:[]})}function ok(e,t){let n={...e._zod.def.shape},r=e._zod.def;for(let e in t){if(!(e in r.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete n[e]}return nk(e,{...e._zod.def,shape:n,checks:[]})}function sk(e,t){if(!$O(t))throw Error(`Invalid input to extend: expected a plain object`);return nk(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return JO(this,`shape`,n),n},checks:[]})}function ck(e,t){return nk(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return JO(this,`shape`,n),n},catchall:t._zod.def.catchall,checks:[]})}function lk(e,t,n){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return nk(t,{...t._zod.def,shape:i,checks:[]})}function uk(e,t,n){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return nk(t,{...t._zod.def,shape:i,checks:[]})}function dk(e,t=0){for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function fk(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function pk(e){return typeof e==`string`?e:e?.message}function mk(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=pk(e.inst?._zod.def?.error?.(e))??pk(t?.error?.(e))??pk(n.customError?.(e))??pk(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function hk(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function gk(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var _k=(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,HO,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},vk=J(`$ZodError`,_k),yk=J(`$ZodError`,_k,{Parent:Error});function bk(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function xk(e,t){let n=t||function(e){return e.message},r={_errors:[]},i=e=>{for(let t of e.issues)if(t.code===`invalid_union`&&t.errors.length)t.errors.map(e=>i({issues:e}));else if(t.code===`invalid_key`)i({issues:t.issues});else if(t.code===`invalid_element`)i({issues:t.issues});else if(t.path.length===0)r._errors.push(n(t));else{let e=r,i=0;for(;i<t.path.length;){let r=t.path[i];i===t.path.length-1?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(n(t))):e[r]=e[r]||{_errors:[]},e=e[r],i++}}};return i(e),r}var Sk=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new RO;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>mk(e,a,BO())));throw XO(t,i?.callee),t}return o.value},Ck=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>mk(e,a,BO())));throw XO(t,i?.callee),t}return o.value},wk=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new RO;return a.issues.length?{success:!1,error:new(e??vk)(a.issues.map(e=>mk(e,i,BO())))}:{success:!0,data:a.value}},Tk=wk(yk),Ek=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>mk(e,i,BO())))}:{success:!0,data:a.value}},Dk=Ek(yk),Ok=/^[cC][^\s-]{8,}$/,kk=/^[0-9a-z]+$/,Ak=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,jk=/^[0-9a-vA-V]{20}$/,Mk=/^[A-Za-z0-9]{27}$/,Nk=/^[a-zA-Z0-9_-]{21}$/,Pk=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Fk=/^([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})$/,Ik=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,Lk=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Rk=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function zk(){return new RegExp(Rk,`u`)}var Bk=/^(?:(?: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])$/,Vk=/^(([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})$/,Hk=/^((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])$/,Uk=/^(([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])$/,Wk=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Gk=/^[A-Za-z0-9_-]*$/,Kk=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,qk=/^\+(?:[0-9]){6,14}[0-9]$/,Jk=`(?:(?:\\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])))`,Yk=RegExp(`^${Jk}$`);function Xk(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Zk(e){return RegExp(`^${Xk(e)}$`)}function Qk(e){let t=Xk({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-]\\d{2}:\\d{2})`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${Jk}T(?:${r})$`)}var $k=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},eA=/^\d+$/,tA=/^-?\d+(?:\.\d+)?/i,nA=/true|false/i,rA=/null/i,iA=/^[^A-Z]*$/,aA=/^[^a-z]*$/,oA=J(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),sA={number:`number`,bigint:`bigint`,object:`date`},cA=J(`$ZodCheckLessThan`,(e,t)=>{oA.init(e,t);let n=sA[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),lA=J(`$ZodCheckGreaterThan`,(e,t)=>{oA.init(e,t);let n=sA[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),uA=J(`$ZodCheckMultipleOf`,(e,t)=>{oA.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):KO(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),dA=J(`$ZodCheckNumberFormat`,(e,t)=>{oA.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=ik[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=eA)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inst:e})}}),fA=J(`$ZodCheckMaxLength`,(e,t)=>{var n;oA.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!WO(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=hk(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),pA=J(`$ZodCheckMinLength`,(e,t)=>{var n;oA.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!WO(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=hk(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),mA=J(`$ZodCheckLengthEquals`,(e,t)=>{var n;oA.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!WO(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=hk(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),hA=J(`$ZodCheckStringFormat`,(e,t)=>{var n,r;oA.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),gA=J(`$ZodCheckRegex`,(e,t)=>{hA.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),_A=J(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=iA,hA.init(e,t)}),vA=J(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=aA,hA.init(e,t)}),yA=J(`$ZodCheckIncludes`,(e,t)=>{oA.init(e,t);let n=tk(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),bA=J(`$ZodCheckStartsWith`,(e,t)=>{oA.init(e,t);let n=RegExp(`^${tk(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),xA=J(`$ZodCheckEndsWith`,(e,t)=>{oA.init(e,t);let n=RegExp(`.*${tk(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),SA=J(`$ZodCheckOverwrite`,(e,t)=>{oA.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),CA=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
190
190
|
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
|
|
191
|
-
`))}},
|
|
191
|
+
`))}},wA={major:4,minor:0,patch:0},TA=J(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=wA;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=dk(e),i;for(let a of t){if(a._zod.def.when){if(!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new RO;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=dk(e,t))});else{if(e.issues.length===t)continue;r||=dk(e,t)}}return i?i.then(()=>e):e};e._zod.run=(n,i)=>{let a=e._zod.parse(n,i);if(a instanceof Promise){if(i.async===!1)throw new RO;return a.then(e=>t(e,r,i))}return t(a,r,i)}}e[`~standard`]={validate:t=>{try{let n=Tk(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return Dk(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}}),EA=J(`$ZodString`,(e,t)=>{TA.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??$k(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),DA=J(`$ZodStringFormat`,(e,t)=>{hA.init(e,t),EA.init(e,t)}),OA=J(`$ZodGUID`,(e,t)=>{t.pattern??=Fk,DA.init(e,t)}),kA=J(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Ik(e)}else t.pattern??=Ik();DA.init(e,t)}),AA=J(`$ZodEmail`,(e,t)=>{t.pattern??=Lk,DA.init(e,t)}),jA=J(`$ZodURL`,(e,t)=>{DA.init(e,t),e._zod.check=n=>{try{let r=n.value,i=new URL(r),a=i.href;t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:Kk.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),n.value=!r.endsWith(`/`)&&a.endsWith(`/`)?a.slice(0,-1):a;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),MA=J(`$ZodEmoji`,(e,t)=>{t.pattern??=zk(),DA.init(e,t)}),NA=J(`$ZodNanoID`,(e,t)=>{t.pattern??=Nk,DA.init(e,t)}),PA=J(`$ZodCUID`,(e,t)=>{t.pattern??=Ok,DA.init(e,t)}),FA=J(`$ZodCUID2`,(e,t)=>{t.pattern??=kk,DA.init(e,t)}),IA=J(`$ZodULID`,(e,t)=>{t.pattern??=Ak,DA.init(e,t)}),LA=J(`$ZodXID`,(e,t)=>{t.pattern??=jk,DA.init(e,t)}),RA=J(`$ZodKSUID`,(e,t)=>{t.pattern??=Mk,DA.init(e,t)}),zA=J(`$ZodISODateTime`,(e,t)=>{t.pattern??=Qk(t),DA.init(e,t)}),BA=J(`$ZodISODate`,(e,t)=>{t.pattern??=Yk,DA.init(e,t)}),VA=J(`$ZodISOTime`,(e,t)=>{t.pattern??=Zk(t),DA.init(e,t)}),HA=J(`$ZodISODuration`,(e,t)=>{t.pattern??=Pk,DA.init(e,t)}),UA=J(`$ZodIPv4`,(e,t)=>{t.pattern??=Bk,DA.init(e,t),e._zod.onattach.push(e=>{let t=e._zod.bag;t.format=`ipv4`})}),WA=J(`$ZodIPv6`,(e,t)=>{t.pattern??=Vk,DA.init(e,t),e._zod.onattach.push(e=>{let t=e._zod.bag;t.format=`ipv6`}),e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),GA=J(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Hk,DA.init(e,t)}),KA=J(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Uk,DA.init(e,t),e._zod.check=n=>{let[r,i]=n.value.split(`/`);try{if(!i)throw Error();let e=Number(i);if(`${e}`!==i||e<0||e>128)throw Error();new URL(`http://[${r}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function qA(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var JA=J(`$ZodBase64`,(e,t)=>{t.pattern??=Wk,DA.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64`}),e._zod.check=n=>{qA(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function YA(e){if(!Gk.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return qA(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var XA=J(`$ZodBase64URL`,(e,t)=>{t.pattern??=Gk,DA.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64url`}),e._zod.check=n=>{YA(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),ZA=J(`$ZodE164`,(e,t)=>{t.pattern??=qk,DA.init(e,t)});function QA(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var $A=J(`$ZodJWT`,(e,t)=>{DA.init(e,t),e._zod.check=n=>{QA(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),ej=J(`$ZodNumber`,(e,t)=>{TA.init(e,t),e._zod.pattern=e._zod.bag.pattern??tA,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),tj=J(`$ZodNumber`,(e,t)=>{dA.init(e,t),ej.init(e,t)}),nj=J(`$ZodBoolean`,(e,t)=>{TA.init(e,t),e._zod.pattern=nA,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),rj=J(`$ZodNull`,(e,t)=>{TA.init(e,t),e._zod.pattern=rA,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),ij=J(`$ZodAny`,(e,t)=>{TA.init(e,t),e._zod.parse=e=>e}),aj=J(`$ZodUnknown`,(e,t)=>{TA.init(e,t),e._zod.parse=e=>e}),oj=J(`$ZodNever`,(e,t)=>{TA.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function sj(e,t,n){e.issues.length&&t.issues.push(...fk(n,e.issues)),t.value[n]=e.value}var cj=J(`$ZodArray`,(e,t)=>{TA.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>sj(t,n,e))):sj(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function lj(e,t,n){e.issues.length&&t.issues.push(...fk(n,e.issues)),t.value[n]=e.value}function uj(e,t,n,r){e.issues.length?r[n]===void 0?n in r?t.value[n]=void 0:t.value[n]=e.value:t.issues.push(...fk(n,e.issues)):e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}var dj=J(`$ZodObject`,(e,t)=>{TA.init(e,t);let n=UO(()=>{let e=Object.keys(t.shape);for(let n of e)if(!(t.shape[n]instanceof TA))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=rk(t.shape);return{shape:t.shape,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(n)}});qO(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=e=>{let t=new CA([`shape`,`payload`,`ctx`]),r=n.value,i=e=>{let t=YO(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of r.keys)a[e]=`key_${o++}`;t.write(`const newResult = {}`);for(let e of r.keys)if(r.optionalKeys.has(e)){let n=a[e];t.write(`const ${n} = ${i(e)};`);let r=YO(e);t.write(`
|
|
192
192
|
if (${n}.issues.length) {
|
|
193
193
|
if (input[${r}] === undefined) {
|
|
194
194
|
if (${r} in input) {
|
|
@@ -210,26 +210,26 @@ ${F.data.oauth.issuer?`Issuer: ${F.data.oauth.issuer}`:``}`;A({title:`OAuth Setu
|
|
|
210
210
|
`)}else{let n=a[e];t.write(`const ${n} = ${i(e)};`),t.write(`
|
|
211
211
|
if (${n}.issues.length) payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
212
212
|
...iss,
|
|
213
|
-
path: iss.path ? [${
|
|
214
|
-
})));`),t.write(`newResult[${UO(e)}] = ${n}.value`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},i,a=GO,o=!NO.jitless,s=o&&KO.value,c=t.catchall,l;e._zod.parse=(u,d)=>{l??=n.value;let f=u.value;if(!a(f))return u.issues.push({expected:`object`,code:`invalid_type`,input:f,inst:e}),u;let p=[];if(o&&s&&d?.async===!1&&d.jitless!==!0)i||=r(t.shape),u=i(u,d);else{u.value={};let e=l.shape;for(let t of l.keys){let n=e[t],r=n._zod.run({value:f[t],issues:[]},d),i=n._zod.optin===`optional`&&n._zod.optout===`optional`;r instanceof Promise?p.push(r.then(e=>i?ij(e,u,t,f):rj(e,u,t))):i?ij(r,u,t,f):rj(r,u,t)}}if(!c)return p.length?Promise.all(p).then(()=>u):u;let m=[],h=l.keySet,g=c._zod,_=g.def.type;for(let e of Object.keys(f)){if(h.has(e))continue;if(_===`never`){m.push(e);continue}let t=g.run({value:f[e],issues:[]},d);t instanceof Promise?p.push(t.then(t=>rj(t,u,e))):rj(t,u,e)}return m.length&&u.issues.push({code:`unrecognized_keys`,keys:m,input:f,inst:e}),p.length?Promise.all(p).then(()=>u):u}});function oj(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;return t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>ck(e,r,PO())))}),t}var sj=J(`$ZodUnion`,(e,t)=>{yA.init(e,t),VO(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),VO(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),VO(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),VO(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>zO(e.source)).join(`|`)})$`)}}),e._zod.parse=(n,r)=>{let i=!1,a=[];for(let e of t.options){let t=e._zod.run({value:n.value,issues:[]},r);if(t instanceof Promise)a.push(t),i=!0;else{if(t.issues.length===0)return t;a.push(t)}}return i?Promise.all(a).then(t=>oj(t,n,e,r)):oj(a,n,e,r)}}),cj=J(`$ZodDiscriminatedUnion`,(e,t)=>{sj.init(e,t);let n=e._zod.parse;VO(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=LO(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!GO(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,input:o,path:[t.discriminator],inst:e}),i)}}),lj=J(`$ZodIntersection`,(e,t)=>{yA.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>dj(e,t,n)):dj(e,i,a)}});function uj(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(qO(e)&&qO(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=uj(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=uj(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function dj(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),ak(e))return e;let r=uj(t.value,n.value);if(!r.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}var fj=J(`$ZodRecord`,(e,t)=>{yA.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!qO(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[];if(t.keyType._zod.values){let o=t.keyType._zod.values;n.value={};for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(...ok(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...ok(e,o.issues)),n.value[e]=o.value)}let s;for(let e in i)o.has(e)||(s??=[],s.push(e));s&&s.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:s})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){n.issues.push({origin:`record`,code:`invalid_key`,issues:s.issues.map(e=>ck(e,r,PO())),input:o,path:[o],inst:e}),n.value[s.value]=s.value;continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...ok(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...ok(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),pj=J(`$ZodEnum`,(e,t)=>{yA.init(e,t);let n=FO(t.entries);e._zod.values=new Set(n),e._zod.pattern=RegExp(`^(${n.filter(e=>JO.has(typeof e)).map(e=>typeof e==`string`?YO(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,r)=>{let i=t.value;return e._zod.values.has(i)||t.issues.push({code:`invalid_value`,values:n,input:i,inst:e}),t}}),mj=J(`$ZodLiteral`,(e,t)=>{yA.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?YO(e):e?e.toString():String(e)).join(`|`)})$`),e._zod.parse=(n,r)=>{let i=n.value;return e._zod.values.has(i)||n.issues.push({code:`invalid_value`,values:t.values,input:i,inst:e}),n}}),hj=J(`$ZodTransform`,(e,t)=>{yA.init(e,t),e._zod.parse=(e,n)=>{let r=t.transform(e.value,e);if(n.async)return(r instanceof Promise?r:Promise.resolve(r)).then(t=>(e.value=t,e));if(r instanceof Promise)throw new MO;return e.value=r,e}}),gj=J(`$ZodOptional`,(e,t)=>{yA.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,VO(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),VO(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${zO(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>t.innerType._zod.optin===`optional`?t.innerType._zod.run(e,n):e.value===void 0?e:t.innerType._zod.run(e,n)}),_j=J(`$ZodNullable`,(e,t)=>{yA.init(e,t),VO(e._zod,`optin`,()=>t.innerType._zod.optin),VO(e._zod,`optout`,()=>t.innerType._zod.optout),VO(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${zO(e.source)}|null)$`):void 0}),VO(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),vj=J(`$ZodDefault`,(e,t)=>{yA.init(e,t),e._zod.optin=`optional`,VO(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>yj(e,t)):yj(r,t)}});function yj(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var bj=J(`$ZodPrefault`,(e,t)=>{yA.init(e,t),e._zod.optin=`optional`,VO(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),xj=J(`$ZodNonOptional`,(e,t)=>{yA.init(e,t),VO(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Sj(t,e)):Sj(i,e)}});function Sj(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var Cj=J(`$ZodCatch`,(e,t)=>{yA.init(e,t),e._zod.optin=`optional`,VO(e._zod,`optout`,()=>t.innerType._zod.optout),VO(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>ck(e,n,PO()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>ck(e,n,PO()))},input:e.value}),e.issues=[]),e)}}),wj=J(`$ZodPipe`,(e,t)=>{yA.init(e,t),VO(e._zod,`values`,()=>t.in._zod.values),VO(e._zod,`optin`,()=>t.in._zod.optin),VO(e._zod,`optout`,()=>t.out._zod.optout),e._zod.parse=(e,n)=>{let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Tj(e,t,n)):Tj(r,t,n)}});function Tj(e,t,n){return ak(e)?e:t.out._zod.run({value:e.value,issues:e.issues},n)}var Ej=J(`$ZodReadonly`,(e,t)=>{yA.init(e,t),VO(e._zod,`propValues`,()=>t.innerType._zod.propValues),VO(e._zod,`values`,()=>t.innerType._zod.values),VO(e._zod,`optin`,()=>t.innerType._zod.optin),VO(e._zod,`optout`,()=>t.innerType._zod.optout),e._zod.parse=(e,n)=>{let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Dj):Dj(r)}});function Dj(e){return e.value=Object.freeze(e.value),e}var Oj=J(`$ZodCustom`,(e,t)=>{eA.init(e,t),yA.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>kj(t,n,r,e));kj(i,n,r,e)}});function kj(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(uk(e))}}var Aj=class{constructor(){this._map=new Map,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==`object`&&`id`in n){if(this._idmap.has(n.id))throw Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};return delete n.id,{...n,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}};function jj(){return new Aj}var Mj=jj();function Nj(e,t){return new e({type:`string`,...Y(t)})}function Pj(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...Y(t)})}function Fj(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...Y(t)})}function Ij(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...Y(t)})}function Lj(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...Y(t)})}function Rj(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...Y(t)})}function zj(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...Y(t)})}function Bj(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...Y(t)})}function Vj(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...Y(t)})}function Hj(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...Y(t)})}function Uj(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...Y(t)})}function Wj(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...Y(t)})}function Gj(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...Y(t)})}function Kj(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...Y(t)})}function qj(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...Y(t)})}function Jj(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...Y(t)})}function Yj(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...Y(t)})}function Xj(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...Y(t)})}function Zj(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...Y(t)})}function Qj(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...Y(t)})}function $j(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...Y(t)})}function eM(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...Y(t)})}function tM(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...Y(t)})}function nM(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...Y(t)})}function rM(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...Y(t)})}function iM(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...Y(t)})}function aM(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...Y(t)})}function oM(e,t){return new e({type:`number`,checks:[],...Y(t)})}function sM(e,t){return new e({type:`number`,coerce:!0,checks:[],...Y(t)})}function cM(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...Y(t)})}function lM(e,t){return new e({type:`boolean`,...Y(t)})}function uM(e,t){return new e({type:`null`,...Y(t)})}function dM(e){return new e({type:`any`})}function fM(e){return new e({type:`unknown`})}function pM(e,t){return new e({type:`never`,...Y(t)})}function mM(e,t){return new nA({check:`less_than`,...Y(t),value:e,inclusive:!1})}function hM(e,t){return new nA({check:`less_than`,...Y(t),value:e,inclusive:!0})}function gM(e,t){return new rA({check:`greater_than`,...Y(t),value:e,inclusive:!1})}function _M(e,t){return new rA({check:`greater_than`,...Y(t),value:e,inclusive:!0})}function vM(e,t){return new iA({check:`multiple_of`,...Y(t),value:e})}function yM(e,t){return new oA({check:`max_length`,...Y(t),maximum:e})}function bM(e,t){return new sA({check:`min_length`,...Y(t),minimum:e})}function xM(e,t){return new cA({check:`length_equals`,...Y(t),length:e})}function SM(e,t){return new uA({check:`string_format`,format:`regex`,...Y(t),pattern:e})}function CM(e){return new dA({check:`string_format`,format:`lowercase`,...Y(e)})}function wM(e){return new fA({check:`string_format`,format:`uppercase`,...Y(e)})}function TM(e,t){return new pA({check:`string_format`,format:`includes`,...Y(t),includes:e})}function EM(e,t){return new mA({check:`string_format`,format:`starts_with`,...Y(t),prefix:e})}function DM(e,t){return new hA({check:`string_format`,format:`ends_with`,...Y(t),suffix:e})}function OM(e){return new gA({check:`overwrite`,tx:e})}function kM(e){return OM(t=>t.normalize(e))}function AM(){return OM(e=>e.trim())}function jM(){return OM(e=>e.toLowerCase())}function MM(){return OM(e=>e.toUpperCase())}function NM(e,t,n){return new e({type:`array`,element:t,...Y(n)})}function PM(e,t,n){let r=Y(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function FM(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...Y(n)})}var IM=J(`ZodISODateTime`,(e,t)=>{NA.init(e,t),$M.init(e,t)});function LM(e){return nM(IM,e)}var RM=J(`ZodISODate`,(e,t)=>{PA.init(e,t),$M.init(e,t)});function zM(e){return rM(RM,e)}var BM=J(`ZodISOTime`,(e,t)=>{FA.init(e,t),$M.init(e,t)});function VM(e){return iM(BM,e)}var HM=J(`ZodISODuration`,(e,t)=>{IA.init(e,t),$M.init(e,t)});function UM(e){return aM(HM,e)}var WM=(e,t)=>{fk.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>hk(e,t)},flatten:{value:t=>mk(e,t)},addIssue:{value:t=>e.issues.push(t)},addIssues:{value:t=>e.issues.push(...t)},isEmpty:{get(){return e.issues.length===0}}})};J(`ZodError`,WM);var GM=J(`ZodError`,WM,{Parent:Error}),KM=gk(GM),qM=_k(GM),JM=vk(GM),YM=bk(GM),XM=J(`ZodType`,(e,t)=>(yA.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),e.clone=(t,n)=>XO(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>KM(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>JM(e,t,n),e.parseAsync=async(t,n)=>qM(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>YM(e,t,n),e.spa=e.safeParseAsync,e.refine=(t,n)=>e.check(hP(t,n)),e.superRefine=t=>e.check(gP(t)),e.overwrite=t=>e.check(OM(t)),e.optional=()=>ZN(e),e.nullable=()=>$N(e),e.nullish=()=>ZN($N(e)),e.nonoptional=t=>aP(e,t),e.array=()=>Z(e),e.or=t=>RN([e,t]),e.and=t=>HN(e,t),e.transform=t=>lP(e,YN(t)),e.default=t=>tP(e,t),e.prefault=t=>rP(e,t),e.catch=t=>sP(e,t),e.pipe=t=>lP(e,t),e.readonly=()=>dP(e),e.describe=t=>{let n=e.clone();return Mj.add(n,{description:t}),n},Object.defineProperty(e,"description",{get(){return Mj.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return Mj.get(e);let n=e.clone();return Mj.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),ZM=J(`_ZodString`,(e,t)=>{bA.init(e,t),XM.init(e,t);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(SM(...t)),e.includes=(...t)=>e.check(TM(...t)),e.startsWith=(...t)=>e.check(EM(...t)),e.endsWith=(...t)=>e.check(DM(...t)),e.min=(...t)=>e.check(bM(...t)),e.max=(...t)=>e.check(yM(...t)),e.length=(...t)=>e.check(xM(...t)),e.nonempty=(...t)=>e.check(bM(1,...t)),e.lowercase=t=>e.check(CM(t)),e.uppercase=t=>e.check(wM(t)),e.trim=()=>e.check(AM()),e.normalize=(...t)=>e.check(kM(...t)),e.toLowerCase=()=>e.check(jM()),e.toUpperCase=()=>e.check(MM())}),QM=J(`ZodString`,(e,t)=>{bA.init(e,t),ZM.init(e,t),e.email=t=>e.check(Pj(eN,t)),e.url=t=>e.check(Bj(rN,t)),e.jwt=t=>e.check(tM(yN,t)),e.emoji=t=>e.check(Vj(aN,t)),e.guid=t=>e.check(Fj(tN,t)),e.uuid=t=>e.check(Ij(nN,t)),e.uuidv4=t=>e.check(Lj(nN,t)),e.uuidv6=t=>e.check(Rj(nN,t)),e.uuidv7=t=>e.check(zj(nN,t)),e.nanoid=t=>e.check(Hj(oN,t)),e.guid=t=>e.check(Fj(tN,t)),e.cuid=t=>e.check(Uj(sN,t)),e.cuid2=t=>e.check(Wj(cN,t)),e.ulid=t=>e.check(Gj(lN,t)),e.base64=t=>e.check(Qj(gN,t)),e.base64url=t=>e.check($j(_N,t)),e.xid=t=>e.check(Kj(uN,t)),e.ksuid=t=>e.check(qj(dN,t)),e.ipv4=t=>e.check(Jj(fN,t)),e.ipv6=t=>e.check(Yj(pN,t)),e.cidrv4=t=>e.check(Xj(mN,t)),e.cidrv6=t=>e.check(Zj(hN,t)),e.e164=t=>e.check(eM(vN,t)),e.datetime=t=>e.check(LM(t)),e.date=t=>e.check(zM(t)),e.time=t=>e.check(VM(t)),e.duration=t=>e.check(UM(t))});function X(e){return Nj(QM,e)}var $M=J(`ZodStringFormat`,(e,t)=>{xA.init(e,t),ZM.init(e,t)}),eN=J(`ZodEmail`,(e,t)=>{wA.init(e,t),$M.init(e,t)}),tN=J(`ZodGUID`,(e,t)=>{SA.init(e,t),$M.init(e,t)}),nN=J(`ZodUUID`,(e,t)=>{CA.init(e,t),$M.init(e,t)}),rN=J(`ZodURL`,(e,t)=>{TA.init(e,t),$M.init(e,t)});function iN(e){return Bj(rN,e)}var aN=J(`ZodEmoji`,(e,t)=>{EA.init(e,t),$M.init(e,t)}),oN=J(`ZodNanoID`,(e,t)=>{DA.init(e,t),$M.init(e,t)}),sN=J(`ZodCUID`,(e,t)=>{OA.init(e,t),$M.init(e,t)}),cN=J(`ZodCUID2`,(e,t)=>{kA.init(e,t),$M.init(e,t)}),lN=J(`ZodULID`,(e,t)=>{AA.init(e,t),$M.init(e,t)}),uN=J(`ZodXID`,(e,t)=>{jA.init(e,t),$M.init(e,t)}),dN=J(`ZodKSUID`,(e,t)=>{MA.init(e,t),$M.init(e,t)}),fN=J(`ZodIPv4`,(e,t)=>{LA.init(e,t),$M.init(e,t)}),pN=J(`ZodIPv6`,(e,t)=>{RA.init(e,t),$M.init(e,t)}),mN=J(`ZodCIDRv4`,(e,t)=>{zA.init(e,t),$M.init(e,t)}),hN=J(`ZodCIDRv6`,(e,t)=>{BA.init(e,t),$M.init(e,t)}),gN=J(`ZodBase64`,(e,t)=>{HA.init(e,t),$M.init(e,t)}),_N=J(`ZodBase64URL`,(e,t)=>{WA.init(e,t),$M.init(e,t)}),vN=J(`ZodE164`,(e,t)=>{GA.init(e,t),$M.init(e,t)}),yN=J(`ZodJWT`,(e,t)=>{qA.init(e,t),$M.init(e,t)}),bN=J(`ZodNumber`,(e,t)=>{JA.init(e,t),XM.init(e,t),e.gt=(t,n)=>e.check(gM(t,n)),e.gte=(t,n)=>e.check(_M(t,n)),e.min=(t,n)=>e.check(_M(t,n)),e.lt=(t,n)=>e.check(mM(t,n)),e.lte=(t,n)=>e.check(hM(t,n)),e.max=(t,n)=>e.check(hM(t,n)),e.int=t=>e.check(CN(t)),e.safe=t=>e.check(CN(t)),e.positive=t=>e.check(gM(0,t)),e.nonnegative=t=>e.check(_M(0,t)),e.negative=t=>e.check(mM(0,t)),e.nonpositive=t=>e.check(hM(0,t)),e.multipleOf=(t,n)=>e.check(vM(t,n)),e.step=(t,n)=>e.check(vM(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function xN(e){return oM(bN,e)}var SN=J(`ZodNumberFormat`,(e,t)=>{YA.init(e,t),bN.init(e,t)});function CN(e){return cM(SN,e)}var wN=J(`ZodBoolean`,(e,t)=>{XA.init(e,t),XM.init(e,t)});function TN(e){return lM(wN,e)}var EN=J(`ZodNull`,(e,t)=>{ZA.init(e,t),XM.init(e,t)});function DN(e){return uM(EN,e)}var ON=J(`ZodAny`,(e,t)=>{QA.init(e,t),XM.init(e,t)});function kN(){return dM(ON)}var AN=J(`ZodUnknown`,(e,t)=>{$A.init(e,t),XM.init(e,t)});function jN(){return fM(AN)}var MN=J(`ZodNever`,(e,t)=>{ej.init(e,t),XM.init(e,t)});function NN(e){return pM(MN,e)}var PN=J(`ZodArray`,(e,t)=>{nj.init(e,t),XM.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(bM(t,n)),e.nonempty=t=>e.check(bM(1,t)),e.max=(t,n)=>e.check(yM(t,n)),e.length=(t,n)=>e.check(xM(t,n)),e.unwrap=()=>e.element});function Z(e,t){return NM(PN,e,t)}var FN=J(`ZodObject`,(e,t)=>{aj.init(e,t),XM.init(e,t),VO(e,`shape`,()=>t.shape),e.keyof=()=>KN(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:jN()}),e.loose=()=>e.clone({...e._zod.def,catchall:jN()}),e.strict=()=>e.clone({...e._zod.def,catchall:NN()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>tk(e,t),e.merge=t=>nk(e,t),e.pick=t=>$O(e,t),e.omit=t=>ek(e,t),e.partial=(...t)=>rk(XN,e,t[0]),e.required=(...t)=>ik(iP,e,t[0])});function Q(e,t){return new FN({type:`object`,get shape(){return HO(this,`shape`,{...e}),this.shape},...Y(t)})}function IN(e,t){return new FN({type:`object`,get shape(){return HO(this,`shape`,{...e}),this.shape},catchall:jN(),...Y(t)})}var LN=J(`ZodUnion`,(e,t)=>{sj.init(e,t),XM.init(e,t),e.options=t.options});function RN(e,t){return new LN({type:`union`,options:e,...Y(t)})}var zN=J(`ZodDiscriminatedUnion`,(e,t)=>{LN.init(e,t),cj.init(e,t)});function BN(e,t,n){return new zN({type:`union`,options:t,discriminator:e,...Y(n)})}var VN=J(`ZodIntersection`,(e,t)=>{lj.init(e,t),XM.init(e,t)});function HN(e,t){return new VN({type:`intersection`,left:e,right:t})}var UN=J(`ZodRecord`,(e,t)=>{fj.init(e,t),XM.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function WN(e,t,n){return new UN({type:`record`,keyType:e,valueType:t,...Y(n)})}var GN=J(`ZodEnum`,(e,t)=>{pj.init(e,t),XM.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new GN({...t,checks:[],...Y(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new GN({...t,checks:[],...Y(r),entries:i})}});function KN(e,t){return new GN({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...Y(t)})}var qN=J(`ZodLiteral`,(e,t)=>{mj.init(e,t),XM.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function $(e,t){return new qN({type:`literal`,values:Array.isArray(e)?e:[e],...Y(t)})}var JN=J(`ZodTransform`,(e,t)=>{hj.init(e,t),XM.init(e,t),e._zod.parse=(n,r)=>{n.addIssue=r=>{if(typeof r==`string`)n.issues.push(uk(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,t.continue??=!0,n.issues.push(uk(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function YN(e){return new JN({type:`transform`,transform:e})}var XN=J(`ZodOptional`,(e,t)=>{gj.init(e,t),XM.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ZN(e){return new XN({type:`optional`,innerType:e})}var QN=J(`ZodNullable`,(e,t)=>{_j.init(e,t),XM.init(e,t),e.unwrap=()=>e._zod.def.innerType});function $N(e){return new QN({type:`nullable`,innerType:e})}var eP=J(`ZodDefault`,(e,t)=>{vj.init(e,t),XM.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function tP(e,t){return new eP({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}var nP=J(`ZodPrefault`,(e,t)=>{bj.init(e,t),XM.init(e,t),e.unwrap=()=>e._zod.def.innerType});function rP(e,t){return new nP({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}var iP=J(`ZodNonOptional`,(e,t)=>{xj.init(e,t),XM.init(e,t),e.unwrap=()=>e._zod.def.innerType});function aP(e,t){return new iP({type:`nonoptional`,innerType:e,...Y(t)})}var oP=J(`ZodCatch`,(e,t)=>{Cj.init(e,t),XM.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function sP(e,t){return new oP({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var cP=J(`ZodPipe`,(e,t)=>{wj.init(e,t),XM.init(e,t),e.in=t.in,e.out=t.out});function lP(e,t){return new cP({type:`pipe`,in:e,out:t})}var uP=J(`ZodReadonly`,(e,t)=>{Ej.init(e,t),XM.init(e,t)});function dP(e){return new uP({type:`readonly`,innerType:e})}var fP=J(`ZodCustom`,(e,t)=>{Oj.init(e,t),XM.init(e,t)});function pP(e){let t=new eA({check:`custom`});return t._zod.check=e,t}function mP(e,t){return PM(fP,e??(()=>!0),t)}function hP(e,t={}){return FM(fP,e,t)}function gP(e){let t=pP(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(uk(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(uk(r))}},e(n.value,n)));return t}function _P(e,t){return lP(YN(e),t)}var vP={invalid_type:`invalid_type`,too_big:`too_big`,too_small:`too_small`,invalid_format:`invalid_format`,not_multiple_of:`not_multiple_of`,unrecognized_keys:`unrecognized_keys`,invalid_union:`invalid_union`,invalid_key:`invalid_key`,invalid_element:`invalid_element`,invalid_value:`invalid_value`,custom:`custom`};function yP(e){return sM(bN,e)}var bP=`2025-11-25`,xP=[bP,`2025-06-18`,`2025-03-26`,`2024-11-05`,`2024-10-07`],SP=`io.modelcontextprotocol/related-task`,CP=mP(e=>e!==null&&(typeof e==`object`||typeof e==`function`)),wP=RN([X(),xN().int()]),TP=X();IN({ttl:xN().optional(),pollInterval:xN().optional()});var EP=Q({ttl:xN().optional()}),DP=Q({taskId:X()}),OP=IN({progressToken:wP.optional(),[SP]:DP.optional()}),kP=Q({_meta:OP.optional()}),AP=kP.extend({task:EP.optional()}),jP=e=>AP.safeParse(e).success,MP=Q({method:X(),params:kP.loose().optional()}),NP=Q({_meta:OP.optional()}),PP=Q({method:X(),params:NP.loose().optional()}),FP=IN({_meta:OP.optional()}),IP=RN([X(),xN().int()]),LP=Q({jsonrpc:$(`2.0`),id:IP,...MP.shape}).strict(),RP=e=>LP.safeParse(e).success,zP=Q({jsonrpc:$(`2.0`),...PP.shape}).strict(),BP=e=>zP.safeParse(e).success,VP=Q({jsonrpc:$(`2.0`),id:IP,result:FP}).strict(),HP=e=>VP.safeParse(e).success,UP;(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`})(UP||={});var WP=Q({jsonrpc:$(`2.0`),id:IP.optional(),error:Q({code:xN().int(),message:X(),data:jN().optional()})}).strict(),GP=e=>WP.safeParse(e).success,KP=RN([LP,zP,VP,WP]);RN([VP,WP]);var qP=FP.strict(),JP=NP.extend({requestId:IP.optional(),reason:X().optional()}),YP=PP.extend({method:$(`notifications/cancelled`),params:JP}),XP=Q({icons:Z(Q({src:X(),mimeType:X().optional(),sizes:Z(X()).optional(),theme:KN([`light`,`dark`]).optional()})).optional()}),ZP=Q({name:X(),title:X().optional()}),QP=ZP.extend({...ZP.shape,...XP.shape,version:X(),websiteUrl:X().optional(),description:X().optional()}),$P=_P(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,HN(Q({form:HN(Q({applyDefaults:TN().optional()}),WN(X(),jN())).optional(),url:CP.optional()}),WN(X(),jN()).optional())),eF=IN({list:CP.optional(),cancel:CP.optional(),requests:IN({sampling:IN({createMessage:CP.optional()}).optional(),elicitation:IN({create:CP.optional()}).optional()}).optional()}),tF=IN({list:CP.optional(),cancel:CP.optional(),requests:IN({tools:IN({call:CP.optional()}).optional()}).optional()}),nF=Q({experimental:WN(X(),CP).optional(),sampling:Q({context:CP.optional(),tools:CP.optional()}).optional(),elicitation:$P.optional(),roots:Q({listChanged:TN().optional()}).optional(),tasks:eF.optional(),extensions:WN(X(),CP).optional()}),rF=kP.extend({protocolVersion:X(),capabilities:nF,clientInfo:QP}),iF=MP.extend({method:$(`initialize`),params:rF}),aF=Q({experimental:WN(X(),CP).optional(),logging:CP.optional(),completions:CP.optional(),prompts:Q({listChanged:TN().optional()}).optional(),resources:Q({subscribe:TN().optional(),listChanged:TN().optional()}).optional(),tools:Q({listChanged:TN().optional()}).optional(),tasks:tF.optional(),extensions:WN(X(),CP).optional()}),oF=FP.extend({protocolVersion:X(),capabilities:aF,serverInfo:QP,instructions:X().optional()}),sF=PP.extend({method:$(`notifications/initialized`),params:NP.optional()}),cF=e=>sF.safeParse(e).success,lF=MP.extend({method:$(`ping`),params:kP.optional()}),uF=Q({progress:xN(),total:ZN(xN()),message:ZN(X())}),dF=Q({...NP.shape,...uF.shape,progressToken:wP}),fF=PP.extend({method:$(`notifications/progress`),params:dF}),pF=kP.extend({cursor:TP.optional()}),mF=MP.extend({params:pF.optional()}),hF=FP.extend({nextCursor:TP.optional()}),gF=KN([`working`,`input_required`,`completed`,`failed`,`cancelled`]),_F=Q({taskId:X(),status:gF,ttl:RN([xN(),DN()]),createdAt:X(),lastUpdatedAt:X(),pollInterval:ZN(xN()),statusMessage:ZN(X())}),vF=FP.extend({task:_F}),yF=NP.merge(_F),bF=PP.extend({method:$(`notifications/tasks/status`),params:yF}),xF=MP.extend({method:$(`tasks/get`),params:kP.extend({taskId:X()})}),SF=FP.merge(_F),CF=MP.extend({method:$(`tasks/result`),params:kP.extend({taskId:X()})});FP.loose();var wF=mF.extend({method:$(`tasks/list`)}),TF=hF.extend({tasks:Z(_F)}),EF=MP.extend({method:$(`tasks/cancel`),params:kP.extend({taskId:X()})}),DF=FP.merge(_F),OF=Q({uri:X(),mimeType:ZN(X()),_meta:WN(X(),jN()).optional()}),kF=OF.extend({text:X()}),AF=X().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),jF=OF.extend({blob:AF}),MF=KN([`user`,`assistant`]),NF=Q({audience:Z(MF).optional(),priority:xN().min(0).max(1).optional(),lastModified:LM({offset:!0}).optional()}),PF=Q({...ZP.shape,...XP.shape,uri:X(),description:ZN(X()),mimeType:ZN(X()),size:ZN(xN()),annotations:NF.optional(),_meta:ZN(IN({}))}),FF=Q({...ZP.shape,...XP.shape,uriTemplate:X(),description:ZN(X()),mimeType:ZN(X()),annotations:NF.optional(),_meta:ZN(IN({}))}),IF=mF.extend({method:$(`resources/list`)}),LF=hF.extend({resources:Z(PF)}),RF=mF.extend({method:$(`resources/templates/list`)}),zF=hF.extend({resourceTemplates:Z(FF)}),BF=kP.extend({uri:X()}),VF=BF,HF=MP.extend({method:$(`resources/read`),params:VF}),UF=FP.extend({contents:Z(RN([kF,jF]))}),WF=PP.extend({method:$(`notifications/resources/list_changed`),params:NP.optional()}),GF=BF,KF=MP.extend({method:$(`resources/subscribe`),params:GF}),qF=BF,JF=MP.extend({method:$(`resources/unsubscribe`),params:qF}),YF=NP.extend({uri:X()}),XF=PP.extend({method:$(`notifications/resources/updated`),params:YF}),ZF=Q({name:X(),description:ZN(X()),required:ZN(TN())}),QF=Q({...ZP.shape,...XP.shape,description:ZN(X()),arguments:ZN(Z(ZF)),_meta:ZN(IN({}))}),$F=mF.extend({method:$(`prompts/list`)}),eI=hF.extend({prompts:Z(QF)}),tI=kP.extend({name:X(),arguments:WN(X(),X()).optional()}),nI=MP.extend({method:$(`prompts/get`),params:tI}),rI=Q({type:$(`text`),text:X(),annotations:NF.optional(),_meta:WN(X(),jN()).optional()}),iI=Q({type:$(`image`),data:AF,mimeType:X(),annotations:NF.optional(),_meta:WN(X(),jN()).optional()}),aI=Q({type:$(`audio`),data:AF,mimeType:X(),annotations:NF.optional(),_meta:WN(X(),jN()).optional()}),oI=Q({type:$(`tool_use`),name:X(),id:X(),input:WN(X(),jN()),_meta:WN(X(),jN()).optional()}),sI=Q({type:$(`resource`),resource:RN([kF,jF]),annotations:NF.optional(),_meta:WN(X(),jN()).optional()}),cI=RN([rI,iI,aI,PF.extend({type:$(`resource_link`)}),sI]),lI=Q({role:MF,content:cI}),uI=FP.extend({description:X().optional(),messages:Z(lI)}),dI=PP.extend({method:$(`notifications/prompts/list_changed`),params:NP.optional()}),fI=Q({title:X().optional(),readOnlyHint:TN().optional(),destructiveHint:TN().optional(),idempotentHint:TN().optional(),openWorldHint:TN().optional()}),pI=Q({taskSupport:KN([`required`,`optional`,`forbidden`]).optional()}),mI=Q({...ZP.shape,...XP.shape,description:X().optional(),inputSchema:Q({type:$(`object`),properties:WN(X(),CP).optional(),required:Z(X()).optional()}).catchall(jN()),outputSchema:Q({type:$(`object`),properties:WN(X(),CP).optional(),required:Z(X()).optional()}).catchall(jN()).optional(),annotations:fI.optional(),execution:pI.optional(),_meta:WN(X(),jN()).optional()}),hI=mF.extend({method:$(`tools/list`)}),gI=hF.extend({tools:Z(mI)}),_I=FP.extend({content:Z(cI).default([]),structuredContent:WN(X(),jN()).optional(),isError:TN().optional()});_I.or(FP.extend({toolResult:jN()}));var vI=AP.extend({name:X(),arguments:WN(X(),jN()).optional()}),yI=MP.extend({method:$(`tools/call`),params:vI}),bI=PP.extend({method:$(`notifications/tools/list_changed`),params:NP.optional()}),xI=Q({autoRefresh:TN().default(!0),debounceMs:xN().int().nonnegative().default(300)}),SI=KN([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),CI=kP.extend({level:SI}),wI=MP.extend({method:$(`logging/setLevel`),params:CI}),TI=NP.extend({level:SI,logger:X().optional(),data:jN()}),EI=PP.extend({method:$(`notifications/message`),params:TI}),DI=Q({hints:Z(Q({name:X().optional()})).optional(),costPriority:xN().min(0).max(1).optional(),speedPriority:xN().min(0).max(1).optional(),intelligencePriority:xN().min(0).max(1).optional()}),OI=Q({mode:KN([`auto`,`required`,`none`]).optional()}),kI=Q({type:$(`tool_result`),toolUseId:X().describe(`The unique identifier for the corresponding tool call.`),content:Z(cI).default([]),structuredContent:Q({}).loose().optional(),isError:TN().optional(),_meta:WN(X(),jN()).optional()}),AI=BN(`type`,[rI,iI,aI]),jI=BN(`type`,[rI,iI,aI,oI,kI]),MI=Q({role:MF,content:RN([jI,Z(jI)]),_meta:WN(X(),jN()).optional()}),NI=AP.extend({messages:Z(MI),modelPreferences:DI.optional(),systemPrompt:X().optional(),includeContext:KN([`none`,`thisServer`,`allServers`]).optional(),temperature:xN().optional(),maxTokens:xN().int(),stopSequences:Z(X()).optional(),metadata:CP.optional(),tools:Z(mI).optional(),toolChoice:OI.optional()}),PI=MP.extend({method:$(`sampling/createMessage`),params:NI}),FI=FP.extend({model:X(),stopReason:ZN(KN([`endTurn`,`stopSequence`,`maxTokens`]).or(X())),role:MF,content:AI}),II=FP.extend({model:X(),stopReason:ZN(KN([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(X())),role:MF,content:RN([jI,Z(jI)])}),LI=Q({type:$(`boolean`),title:X().optional(),description:X().optional(),default:TN().optional()}),RI=Q({type:$(`string`),title:X().optional(),description:X().optional(),minLength:xN().optional(),maxLength:xN().optional(),format:KN([`email`,`uri`,`date`,`date-time`]).optional(),default:X().optional()}),zI=Q({type:KN([`number`,`integer`]),title:X().optional(),description:X().optional(),minimum:xN().optional(),maximum:xN().optional(),default:xN().optional()}),BI=Q({type:$(`string`),title:X().optional(),description:X().optional(),enum:Z(X()),default:X().optional()}),VI=Q({type:$(`string`),title:X().optional(),description:X().optional(),oneOf:Z(Q({const:X(),title:X()})),default:X().optional()}),HI=RN([RN([Q({type:$(`string`),title:X().optional(),description:X().optional(),enum:Z(X()),enumNames:Z(X()).optional(),default:X().optional()}),RN([BI,VI]),RN([Q({type:$(`array`),title:X().optional(),description:X().optional(),minItems:xN().optional(),maxItems:xN().optional(),items:Q({type:$(`string`),enum:Z(X())}),default:Z(X()).optional()}),Q({type:$(`array`),title:X().optional(),description:X().optional(),minItems:xN().optional(),maxItems:xN().optional(),items:Q({anyOf:Z(Q({const:X(),title:X()}))}),default:Z(X()).optional()})])]),LI,RI,zI]),UI=RN([AP.extend({mode:$(`form`).optional(),message:X(),requestedSchema:Q({type:$(`object`),properties:WN(X(),HI),required:Z(X()).optional()})}),AP.extend({mode:$(`url`),message:X(),elicitationId:X(),url:X().url()})]),WI=MP.extend({method:$(`elicitation/create`),params:UI}),GI=NP.extend({elicitationId:X()}),KI=PP.extend({method:$(`notifications/elicitation/complete`),params:GI}),qI=FP.extend({action:KN([`accept`,`decline`,`cancel`]),content:_P(e=>e===null?void 0:e,WN(X(),RN([X(),xN(),TN(),Z(X())])).optional())}),JI=Q({type:$(`ref/resource`),uri:X()}),YI=Q({type:$(`ref/prompt`),name:X()}),XI=kP.extend({ref:RN([YI,JI]),argument:Q({name:X(),value:X()}),context:Q({arguments:WN(X(),X()).optional()}).optional()}),ZI=MP.extend({method:$(`completion/complete`),params:XI}),QI=FP.extend({completion:IN({values:Z(X()).max(100),total:ZN(xN().int()),hasMore:ZN(TN())})}),$I=Q({uri:X().startsWith(`file://`),name:X().optional(),_meta:WN(X(),jN()).optional()}),eL=MP.extend({method:$(`roots/list`),params:kP.optional()}),tL=FP.extend({roots:Z($I)}),nL=PP.extend({method:$(`notifications/roots/list_changed`),params:NP.optional()});RN([lF,iF,ZI,wI,nI,$F,IF,RF,HF,KF,JF,yI,hI,xF,CF,wF,EF]),RN([YP,fF,sF,nL,bF]),RN([qP,FI,II,qI,tL,SF,TF,vF]),RN([lF,PI,WI,eL,xF,CF,wF,EF]),RN([YP,fF,EI,XF,WF,bI,dI,bF,KI]),RN([qP,oF,QI,uI,eI,LF,zF,UF,_I,gI,SF,TF,vF]);var rL=class e extends Error{constructor(e,t,n){super(`MCP error ${e}: ${t}`),this.code=e,this.data=n,this.name=`McpError`}static fromError(t,n,r){if(t===UP.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new iL(e.elicitations,n)}return new e(t,n,r)}},iL=class extends rL{constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(UP.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},aL=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}};function oL(e){}function sL(e){if(typeof e==`function`)throw TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");let{onEvent:t=oL,onError:n=oL,onRetry:r=oL,onComment:i}=e,a=``,o=!0,s,c=``,l=``;function u(e){let t=o?e.replace(/^\xEF\xBB\xBF/,``):e,[n,r]=cL(`${a}${t}`);for(let e of n)d(e);a=r,o=!1}function d(e){if(e===``){p();return}if(e.startsWith(`:`)){i&&i(e.slice(e.startsWith(`: `)?2:1));return}let t=e.indexOf(`:`);if(t!==-1){let n=e.slice(0,t),r=e[t+1]===` `?2:1;f(n,e.slice(t+r),e);return}f(e,``,e)}function f(e,t,i){switch(e){case`event`:l=t;break;case`data`:c=`${c}${t}
|
|
215
|
-
`;break;case`id`:s=t.includes(`\0`)?void 0:t;break;case`retry`:/^\d+$/.test(t)?r(parseInt(t,10)):n(new
|
|
216
|
-
`)?c.slice(0,-1):c}),s=void 0,c=``,l=``}function m(e={}){a&&e.consume&&d(a),o=!0,s=void 0,c=``,l=``,a=``}return{feed:u,reset:m}}function
|
|
213
|
+
path: iss.path ? [${YO(e)}, ...iss.path] : [${YO(e)}]
|
|
214
|
+
})));`),t.write(`newResult[${YO(e)}] = ${n}.value`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},i,a=ZO,o=!zO.jitless,s=o&&QO.value,c=t.catchall,l;e._zod.parse=(u,d)=>{l??=n.value;let f=u.value;if(!a(f))return u.issues.push({expected:`object`,code:`invalid_type`,input:f,inst:e}),u;let p=[];if(o&&s&&d?.async===!1&&d.jitless!==!0)i||=r(t.shape),u=i(u,d);else{u.value={};let e=l.shape;for(let t of l.keys){let n=e[t],r=n._zod.run({value:f[t],issues:[]},d),i=n._zod.optin===`optional`&&n._zod.optout===`optional`;r instanceof Promise?p.push(r.then(e=>i?uj(e,u,t,f):lj(e,u,t))):i?uj(r,u,t,f):lj(r,u,t)}}if(!c)return p.length?Promise.all(p).then(()=>u):u;let m=[],h=l.keySet,g=c._zod,_=g.def.type;for(let e of Object.keys(f)){if(h.has(e))continue;if(_===`never`){m.push(e);continue}let t=g.run({value:f[e],issues:[]},d);t instanceof Promise?p.push(t.then(t=>lj(t,u,e))):lj(t,u,e)}return m.length&&u.issues.push({code:`unrecognized_keys`,keys:m,input:f,inst:e}),p.length?Promise.all(p).then(()=>u):u}});function fj(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;return t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>mk(e,r,BO())))}),t}var pj=J(`$ZodUnion`,(e,t)=>{TA.init(e,t),qO(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),qO(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),qO(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),qO(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>GO(e.source)).join(`|`)})$`)}}),e._zod.parse=(n,r)=>{let i=!1,a=[];for(let e of t.options){let t=e._zod.run({value:n.value,issues:[]},r);if(t instanceof Promise)a.push(t),i=!0;else{if(t.issues.length===0)return t;a.push(t)}}return i?Promise.all(a).then(t=>fj(t,n,e,r)):fj(a,n,e,r)}}),mj=J(`$ZodDiscriminatedUnion`,(e,t)=>{pj.init(e,t);let n=e._zod.parse;qO(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=UO(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!ZO(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,input:o,path:[t.discriminator],inst:e}),i)}}),hj=J(`$ZodIntersection`,(e,t)=>{TA.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>_j(e,t,n)):_j(e,i,a)}});function gj(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if($O(e)&&$O(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=gj(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=gj(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function _j(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),dk(e))return e;let r=gj(t.value,n.value);if(!r.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}var vj=J(`$ZodRecord`,(e,t)=>{TA.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!$O(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[];if(t.keyType._zod.values){let o=t.keyType._zod.values;n.value={};for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(...fk(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...fk(e,o.issues)),n.value[e]=o.value)}let s;for(let e in i)o.has(e)||(s??=[],s.push(e));s&&s.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:s})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){n.issues.push({origin:`record`,code:`invalid_key`,issues:s.issues.map(e=>mk(e,r,BO())),input:o,path:[o],inst:e}),n.value[s.value]=s.value;continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...fk(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...fk(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),yj=J(`$ZodEnum`,(e,t)=>{TA.init(e,t);let n=VO(t.entries);e._zod.values=new Set(n),e._zod.pattern=RegExp(`^(${n.filter(e=>ek.has(typeof e)).map(e=>typeof e==`string`?tk(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,r)=>{let i=t.value;return e._zod.values.has(i)||t.issues.push({code:`invalid_value`,values:n,input:i,inst:e}),t}}),bj=J(`$ZodLiteral`,(e,t)=>{TA.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?tk(e):e?e.toString():String(e)).join(`|`)})$`),e._zod.parse=(n,r)=>{let i=n.value;return e._zod.values.has(i)||n.issues.push({code:`invalid_value`,values:t.values,input:i,inst:e}),n}}),xj=J(`$ZodTransform`,(e,t)=>{TA.init(e,t),e._zod.parse=(e,n)=>{let r=t.transform(e.value,e);if(n.async)return(r instanceof Promise?r:Promise.resolve(r)).then(t=>(e.value=t,e));if(r instanceof Promise)throw new RO;return e.value=r,e}}),Sj=J(`$ZodOptional`,(e,t)=>{TA.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,qO(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),qO(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${GO(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>t.innerType._zod.optin===`optional`?t.innerType._zod.run(e,n):e.value===void 0?e:t.innerType._zod.run(e,n)}),Cj=J(`$ZodNullable`,(e,t)=>{TA.init(e,t),qO(e._zod,`optin`,()=>t.innerType._zod.optin),qO(e._zod,`optout`,()=>t.innerType._zod.optout),qO(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${GO(e.source)}|null)$`):void 0}),qO(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),wj=J(`$ZodDefault`,(e,t)=>{TA.init(e,t),e._zod.optin=`optional`,qO(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Tj(e,t)):Tj(r,t)}});function Tj(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Ej=J(`$ZodPrefault`,(e,t)=>{TA.init(e,t),e._zod.optin=`optional`,qO(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Dj=J(`$ZodNonOptional`,(e,t)=>{TA.init(e,t),qO(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Oj(t,e)):Oj(i,e)}});function Oj(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var kj=J(`$ZodCatch`,(e,t)=>{TA.init(e,t),e._zod.optin=`optional`,qO(e._zod,`optout`,()=>t.innerType._zod.optout),qO(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>mk(e,n,BO()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>mk(e,n,BO()))},input:e.value}),e.issues=[]),e)}}),Aj=J(`$ZodPipe`,(e,t)=>{TA.init(e,t),qO(e._zod,`values`,()=>t.in._zod.values),qO(e._zod,`optin`,()=>t.in._zod.optin),qO(e._zod,`optout`,()=>t.out._zod.optout),e._zod.parse=(e,n)=>{let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>jj(e,t,n)):jj(r,t,n)}});function jj(e,t,n){return dk(e)?e:t.out._zod.run({value:e.value,issues:e.issues},n)}var Mj=J(`$ZodReadonly`,(e,t)=>{TA.init(e,t),qO(e._zod,`propValues`,()=>t.innerType._zod.propValues),qO(e._zod,`values`,()=>t.innerType._zod.values),qO(e._zod,`optin`,()=>t.innerType._zod.optin),qO(e._zod,`optout`,()=>t.innerType._zod.optout),e._zod.parse=(e,n)=>{let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Nj):Nj(r)}});function Nj(e){return e.value=Object.freeze(e.value),e}var Pj=J(`$ZodCustom`,(e,t)=>{oA.init(e,t),TA.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Fj(t,n,r,e));Fj(i,n,r,e)}});function Fj(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(gk(e))}}var Ij=class{constructor(){this._map=new Map,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==`object`&&`id`in n){if(this._idmap.has(n.id))throw Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};return delete n.id,{...n,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}};function Lj(){return new Ij}var Rj=Lj();function zj(e,t){return new e({type:`string`,...Y(t)})}function Bj(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...Y(t)})}function Vj(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...Y(t)})}function Hj(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...Y(t)})}function Uj(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...Y(t)})}function Wj(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...Y(t)})}function Gj(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...Y(t)})}function Kj(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...Y(t)})}function qj(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...Y(t)})}function Jj(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...Y(t)})}function Yj(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...Y(t)})}function Xj(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...Y(t)})}function Zj(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...Y(t)})}function Qj(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...Y(t)})}function $j(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...Y(t)})}function eM(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...Y(t)})}function tM(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...Y(t)})}function nM(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...Y(t)})}function rM(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...Y(t)})}function iM(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...Y(t)})}function aM(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...Y(t)})}function oM(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...Y(t)})}function sM(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...Y(t)})}function cM(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...Y(t)})}function lM(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...Y(t)})}function uM(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...Y(t)})}function dM(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...Y(t)})}function fM(e,t){return new e({type:`number`,checks:[],...Y(t)})}function pM(e,t){return new e({type:`number`,coerce:!0,checks:[],...Y(t)})}function mM(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...Y(t)})}function hM(e,t){return new e({type:`boolean`,...Y(t)})}function gM(e,t){return new e({type:`null`,...Y(t)})}function _M(e){return new e({type:`any`})}function vM(e){return new e({type:`unknown`})}function yM(e,t){return new e({type:`never`,...Y(t)})}function bM(e,t){return new cA({check:`less_than`,...Y(t),value:e,inclusive:!1})}function xM(e,t){return new cA({check:`less_than`,...Y(t),value:e,inclusive:!0})}function SM(e,t){return new lA({check:`greater_than`,...Y(t),value:e,inclusive:!1})}function CM(e,t){return new lA({check:`greater_than`,...Y(t),value:e,inclusive:!0})}function wM(e,t){return new uA({check:`multiple_of`,...Y(t),value:e})}function TM(e,t){return new fA({check:`max_length`,...Y(t),maximum:e})}function EM(e,t){return new pA({check:`min_length`,...Y(t),minimum:e})}function DM(e,t){return new mA({check:`length_equals`,...Y(t),length:e})}function OM(e,t){return new gA({check:`string_format`,format:`regex`,...Y(t),pattern:e})}function kM(e){return new _A({check:`string_format`,format:`lowercase`,...Y(e)})}function AM(e){return new vA({check:`string_format`,format:`uppercase`,...Y(e)})}function jM(e,t){return new yA({check:`string_format`,format:`includes`,...Y(t),includes:e})}function MM(e,t){return new bA({check:`string_format`,format:`starts_with`,...Y(t),prefix:e})}function NM(e,t){return new xA({check:`string_format`,format:`ends_with`,...Y(t),suffix:e})}function PM(e){return new SA({check:`overwrite`,tx:e})}function FM(e){return PM(t=>t.normalize(e))}function IM(){return PM(e=>e.trim())}function LM(){return PM(e=>e.toLowerCase())}function RM(){return PM(e=>e.toUpperCase())}function zM(e,t,n){return new e({type:`array`,element:t,...Y(n)})}function BM(e,t,n){let r=Y(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function VM(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...Y(n)})}var HM=J(`ZodISODateTime`,(e,t)=>{zA.init(e,t),aN.init(e,t)});function UM(e){return cM(HM,e)}var WM=J(`ZodISODate`,(e,t)=>{BA.init(e,t),aN.init(e,t)});function GM(e){return lM(WM,e)}var KM=J(`ZodISOTime`,(e,t)=>{VA.init(e,t),aN.init(e,t)});function qM(e){return uM(KM,e)}var JM=J(`ZodISODuration`,(e,t)=>{HA.init(e,t),aN.init(e,t)});function YM(e){return dM(JM,e)}var XM=(e,t)=>{vk.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>xk(e,t)},flatten:{value:t=>bk(e,t)},addIssue:{value:t=>e.issues.push(t)},addIssues:{value:t=>e.issues.push(...t)},isEmpty:{get(){return e.issues.length===0}}})};J(`ZodError`,XM);var ZM=J(`ZodError`,XM,{Parent:Error}),QM=Sk(ZM),$M=Ck(ZM),eN=wk(ZM),tN=Ek(ZM),nN=J(`ZodType`,(e,t)=>(TA.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),e.clone=(t,n)=>nk(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>QM(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>eN(e,t,n),e.parseAsync=async(t,n)=>$M(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>tN(e,t,n),e.spa=e.safeParseAsync,e.refine=(t,n)=>e.check(xP(t,n)),e.superRefine=t=>e.check(SP(t)),e.overwrite=t=>e.check(PM(t)),e.optional=()=>rP(e),e.nullable=()=>aP(e),e.nullish=()=>rP(aP(e)),e.nonoptional=t=>dP(e,t),e.array=()=>Z(e),e.or=t=>WN([e,t]),e.and=t=>JN(e,t),e.transform=t=>hP(e,tP(t)),e.default=t=>sP(e,t),e.prefault=t=>lP(e,t),e.catch=t=>pP(e,t),e.pipe=t=>hP(e,t),e.readonly=()=>_P(e),e.describe=t=>{let n=e.clone();return Rj.add(n,{description:t}),n},Object.defineProperty(e,"description",{get(){return Rj.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return Rj.get(e);let n=e.clone();return Rj.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),rN=J(`_ZodString`,(e,t)=>{EA.init(e,t),nN.init(e,t);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(OM(...t)),e.includes=(...t)=>e.check(jM(...t)),e.startsWith=(...t)=>e.check(MM(...t)),e.endsWith=(...t)=>e.check(NM(...t)),e.min=(...t)=>e.check(EM(...t)),e.max=(...t)=>e.check(TM(...t)),e.length=(...t)=>e.check(DM(...t)),e.nonempty=(...t)=>e.check(EM(1,...t)),e.lowercase=t=>e.check(kM(t)),e.uppercase=t=>e.check(AM(t)),e.trim=()=>e.check(IM()),e.normalize=(...t)=>e.check(FM(...t)),e.toLowerCase=()=>e.check(LM()),e.toUpperCase=()=>e.check(RM())}),iN=J(`ZodString`,(e,t)=>{EA.init(e,t),rN.init(e,t),e.email=t=>e.check(Bj(oN,t)),e.url=t=>e.check(Kj(lN,t)),e.jwt=t=>e.check(sM(TN,t)),e.emoji=t=>e.check(qj(dN,t)),e.guid=t=>e.check(Vj(sN,t)),e.uuid=t=>e.check(Hj(cN,t)),e.uuidv4=t=>e.check(Uj(cN,t)),e.uuidv6=t=>e.check(Wj(cN,t)),e.uuidv7=t=>e.check(Gj(cN,t)),e.nanoid=t=>e.check(Jj(fN,t)),e.guid=t=>e.check(Vj(sN,t)),e.cuid=t=>e.check(Yj(pN,t)),e.cuid2=t=>e.check(Xj(mN,t)),e.ulid=t=>e.check(Zj(hN,t)),e.base64=t=>e.check(iM(SN,t)),e.base64url=t=>e.check(aM(CN,t)),e.xid=t=>e.check(Qj(gN,t)),e.ksuid=t=>e.check($j(_N,t)),e.ipv4=t=>e.check(eM(vN,t)),e.ipv6=t=>e.check(tM(yN,t)),e.cidrv4=t=>e.check(nM(bN,t)),e.cidrv6=t=>e.check(rM(xN,t)),e.e164=t=>e.check(oM(wN,t)),e.datetime=t=>e.check(UM(t)),e.date=t=>e.check(GM(t)),e.time=t=>e.check(qM(t)),e.duration=t=>e.check(YM(t))});function X(e){return zj(iN,e)}var aN=J(`ZodStringFormat`,(e,t)=>{DA.init(e,t),rN.init(e,t)}),oN=J(`ZodEmail`,(e,t)=>{AA.init(e,t),aN.init(e,t)}),sN=J(`ZodGUID`,(e,t)=>{OA.init(e,t),aN.init(e,t)}),cN=J(`ZodUUID`,(e,t)=>{kA.init(e,t),aN.init(e,t)}),lN=J(`ZodURL`,(e,t)=>{jA.init(e,t),aN.init(e,t)});function uN(e){return Kj(lN,e)}var dN=J(`ZodEmoji`,(e,t)=>{MA.init(e,t),aN.init(e,t)}),fN=J(`ZodNanoID`,(e,t)=>{NA.init(e,t),aN.init(e,t)}),pN=J(`ZodCUID`,(e,t)=>{PA.init(e,t),aN.init(e,t)}),mN=J(`ZodCUID2`,(e,t)=>{FA.init(e,t),aN.init(e,t)}),hN=J(`ZodULID`,(e,t)=>{IA.init(e,t),aN.init(e,t)}),gN=J(`ZodXID`,(e,t)=>{LA.init(e,t),aN.init(e,t)}),_N=J(`ZodKSUID`,(e,t)=>{RA.init(e,t),aN.init(e,t)}),vN=J(`ZodIPv4`,(e,t)=>{UA.init(e,t),aN.init(e,t)}),yN=J(`ZodIPv6`,(e,t)=>{WA.init(e,t),aN.init(e,t)}),bN=J(`ZodCIDRv4`,(e,t)=>{GA.init(e,t),aN.init(e,t)}),xN=J(`ZodCIDRv6`,(e,t)=>{KA.init(e,t),aN.init(e,t)}),SN=J(`ZodBase64`,(e,t)=>{JA.init(e,t),aN.init(e,t)}),CN=J(`ZodBase64URL`,(e,t)=>{XA.init(e,t),aN.init(e,t)}),wN=J(`ZodE164`,(e,t)=>{ZA.init(e,t),aN.init(e,t)}),TN=J(`ZodJWT`,(e,t)=>{$A.init(e,t),aN.init(e,t)}),EN=J(`ZodNumber`,(e,t)=>{ej.init(e,t),nN.init(e,t),e.gt=(t,n)=>e.check(SM(t,n)),e.gte=(t,n)=>e.check(CM(t,n)),e.min=(t,n)=>e.check(CM(t,n)),e.lt=(t,n)=>e.check(bM(t,n)),e.lte=(t,n)=>e.check(xM(t,n)),e.max=(t,n)=>e.check(xM(t,n)),e.int=t=>e.check(kN(t)),e.safe=t=>e.check(kN(t)),e.positive=t=>e.check(SM(0,t)),e.nonnegative=t=>e.check(CM(0,t)),e.negative=t=>e.check(bM(0,t)),e.nonpositive=t=>e.check(xM(0,t)),e.multipleOf=(t,n)=>e.check(wM(t,n)),e.step=(t,n)=>e.check(wM(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function DN(e){return fM(EN,e)}var ON=J(`ZodNumberFormat`,(e,t)=>{tj.init(e,t),EN.init(e,t)});function kN(e){return mM(ON,e)}var AN=J(`ZodBoolean`,(e,t)=>{nj.init(e,t),nN.init(e,t)});function jN(e){return hM(AN,e)}var MN=J(`ZodNull`,(e,t)=>{rj.init(e,t),nN.init(e,t)});function NN(e){return gM(MN,e)}var PN=J(`ZodAny`,(e,t)=>{ij.init(e,t),nN.init(e,t)});function FN(){return _M(PN)}var IN=J(`ZodUnknown`,(e,t)=>{aj.init(e,t),nN.init(e,t)});function LN(){return vM(IN)}var RN=J(`ZodNever`,(e,t)=>{oj.init(e,t),nN.init(e,t)});function zN(e){return yM(RN,e)}var BN=J(`ZodArray`,(e,t)=>{cj.init(e,t),nN.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(EM(t,n)),e.nonempty=t=>e.check(EM(1,t)),e.max=(t,n)=>e.check(TM(t,n)),e.length=(t,n)=>e.check(DM(t,n)),e.unwrap=()=>e.element});function Z(e,t){return zM(BN,e,t)}var VN=J(`ZodObject`,(e,t)=>{dj.init(e,t),nN.init(e,t),qO(e,`shape`,()=>t.shape),e.keyof=()=>QN(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:LN()}),e.loose=()=>e.clone({...e._zod.def,catchall:LN()}),e.strict=()=>e.clone({...e._zod.def,catchall:zN()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>sk(e,t),e.merge=t=>ck(e,t),e.pick=t=>ak(e,t),e.omit=t=>ok(e,t),e.partial=(...t)=>lk(nP,e,t[0]),e.required=(...t)=>uk(uP,e,t[0])});function Q(e,t){return new VN({type:`object`,get shape(){return JO(this,`shape`,{...e}),this.shape},...Y(t)})}function HN(e,t){return new VN({type:`object`,get shape(){return JO(this,`shape`,{...e}),this.shape},catchall:LN(),...Y(t)})}var UN=J(`ZodUnion`,(e,t)=>{pj.init(e,t),nN.init(e,t),e.options=t.options});function WN(e,t){return new UN({type:`union`,options:e,...Y(t)})}var GN=J(`ZodDiscriminatedUnion`,(e,t)=>{UN.init(e,t),mj.init(e,t)});function KN(e,t,n){return new GN({type:`union`,options:t,discriminator:e,...Y(n)})}var qN=J(`ZodIntersection`,(e,t)=>{hj.init(e,t),nN.init(e,t)});function JN(e,t){return new qN({type:`intersection`,left:e,right:t})}var YN=J(`ZodRecord`,(e,t)=>{vj.init(e,t),nN.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function XN(e,t,n){return new YN({type:`record`,keyType:e,valueType:t,...Y(n)})}var ZN=J(`ZodEnum`,(e,t)=>{yj.init(e,t),nN.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new ZN({...t,checks:[],...Y(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new ZN({...t,checks:[],...Y(r),entries:i})}});function QN(e,t){return new ZN({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...Y(t)})}var $N=J(`ZodLiteral`,(e,t)=>{bj.init(e,t),nN.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function $(e,t){return new $N({type:`literal`,values:Array.isArray(e)?e:[e],...Y(t)})}var eP=J(`ZodTransform`,(e,t)=>{xj.init(e,t),nN.init(e,t),e._zod.parse=(n,r)=>{n.addIssue=r=>{if(typeof r==`string`)n.issues.push(gk(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,t.continue??=!0,n.issues.push(gk(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function tP(e){return new eP({type:`transform`,transform:e})}var nP=J(`ZodOptional`,(e,t)=>{Sj.init(e,t),nN.init(e,t),e.unwrap=()=>e._zod.def.innerType});function rP(e){return new nP({type:`optional`,innerType:e})}var iP=J(`ZodNullable`,(e,t)=>{Cj.init(e,t),nN.init(e,t),e.unwrap=()=>e._zod.def.innerType});function aP(e){return new iP({type:`nullable`,innerType:e})}var oP=J(`ZodDefault`,(e,t)=>{wj.init(e,t),nN.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function sP(e,t){return new oP({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}var cP=J(`ZodPrefault`,(e,t)=>{Ej.init(e,t),nN.init(e,t),e.unwrap=()=>e._zod.def.innerType});function lP(e,t){return new cP({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}var uP=J(`ZodNonOptional`,(e,t)=>{Dj.init(e,t),nN.init(e,t),e.unwrap=()=>e._zod.def.innerType});function dP(e,t){return new uP({type:`nonoptional`,innerType:e,...Y(t)})}var fP=J(`ZodCatch`,(e,t)=>{kj.init(e,t),nN.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function pP(e,t){return new fP({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var mP=J(`ZodPipe`,(e,t)=>{Aj.init(e,t),nN.init(e,t),e.in=t.in,e.out=t.out});function hP(e,t){return new mP({type:`pipe`,in:e,out:t})}var gP=J(`ZodReadonly`,(e,t)=>{Mj.init(e,t),nN.init(e,t)});function _P(e){return new gP({type:`readonly`,innerType:e})}var vP=J(`ZodCustom`,(e,t)=>{Pj.init(e,t),nN.init(e,t)});function yP(e){let t=new oA({check:`custom`});return t._zod.check=e,t}function bP(e,t){return BM(vP,e??(()=>!0),t)}function xP(e,t={}){return VM(vP,e,t)}function SP(e){let t=yP(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(gk(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(gk(r))}},e(n.value,n)));return t}function CP(e,t){return hP(tP(e),t)}var wP={invalid_type:`invalid_type`,too_big:`too_big`,too_small:`too_small`,invalid_format:`invalid_format`,not_multiple_of:`not_multiple_of`,unrecognized_keys:`unrecognized_keys`,invalid_union:`invalid_union`,invalid_key:`invalid_key`,invalid_element:`invalid_element`,invalid_value:`invalid_value`,custom:`custom`};function TP(e){return pM(EN,e)}var EP=`2025-11-25`,DP=[EP,`2025-06-18`,`2025-03-26`,`2024-11-05`,`2024-10-07`],OP=`io.modelcontextprotocol/related-task`,kP=bP(e=>e!==null&&(typeof e==`object`||typeof e==`function`)),AP=WN([X(),DN().int()]),jP=X();HN({ttl:DN().optional(),pollInterval:DN().optional()});var MP=Q({ttl:DN().optional()}),NP=Q({taskId:X()}),PP=HN({progressToken:AP.optional(),[OP]:NP.optional()}),FP=Q({_meta:PP.optional()}),IP=FP.extend({task:MP.optional()}),LP=e=>IP.safeParse(e).success,RP=Q({method:X(),params:FP.loose().optional()}),zP=Q({_meta:PP.optional()}),BP=Q({method:X(),params:zP.loose().optional()}),VP=HN({_meta:PP.optional()}),HP=WN([X(),DN().int()]),UP=Q({jsonrpc:$(`2.0`),id:HP,...RP.shape}).strict(),WP=e=>UP.safeParse(e).success,GP=Q({jsonrpc:$(`2.0`),...BP.shape}).strict(),KP=e=>GP.safeParse(e).success,qP=Q({jsonrpc:$(`2.0`),id:HP,result:VP}).strict(),JP=e=>qP.safeParse(e).success,YP;(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`})(YP||={});var XP=Q({jsonrpc:$(`2.0`),id:HP.optional(),error:Q({code:DN().int(),message:X(),data:LN().optional()})}).strict(),ZP=e=>XP.safeParse(e).success,QP=WN([UP,GP,qP,XP]);WN([qP,XP]);var $P=VP.strict(),eF=zP.extend({requestId:HP.optional(),reason:X().optional()}),tF=BP.extend({method:$(`notifications/cancelled`),params:eF}),nF=Q({icons:Z(Q({src:X(),mimeType:X().optional(),sizes:Z(X()).optional(),theme:QN([`light`,`dark`]).optional()})).optional()}),rF=Q({name:X(),title:X().optional()}),iF=rF.extend({...rF.shape,...nF.shape,version:X(),websiteUrl:X().optional(),description:X().optional()}),aF=CP(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,JN(Q({form:JN(Q({applyDefaults:jN().optional()}),XN(X(),LN())).optional(),url:kP.optional()}),XN(X(),LN()).optional())),oF=HN({list:kP.optional(),cancel:kP.optional(),requests:HN({sampling:HN({createMessage:kP.optional()}).optional(),elicitation:HN({create:kP.optional()}).optional()}).optional()}),sF=HN({list:kP.optional(),cancel:kP.optional(),requests:HN({tools:HN({call:kP.optional()}).optional()}).optional()}),cF=Q({experimental:XN(X(),kP).optional(),sampling:Q({context:kP.optional(),tools:kP.optional()}).optional(),elicitation:aF.optional(),roots:Q({listChanged:jN().optional()}).optional(),tasks:oF.optional(),extensions:XN(X(),kP).optional()}),lF=FP.extend({protocolVersion:X(),capabilities:cF,clientInfo:iF}),uF=RP.extend({method:$(`initialize`),params:lF}),dF=Q({experimental:XN(X(),kP).optional(),logging:kP.optional(),completions:kP.optional(),prompts:Q({listChanged:jN().optional()}).optional(),resources:Q({subscribe:jN().optional(),listChanged:jN().optional()}).optional(),tools:Q({listChanged:jN().optional()}).optional(),tasks:sF.optional(),extensions:XN(X(),kP).optional()}),fF=VP.extend({protocolVersion:X(),capabilities:dF,serverInfo:iF,instructions:X().optional()}),pF=BP.extend({method:$(`notifications/initialized`),params:zP.optional()}),mF=e=>pF.safeParse(e).success,hF=RP.extend({method:$(`ping`),params:FP.optional()}),gF=Q({progress:DN(),total:rP(DN()),message:rP(X())}),_F=Q({...zP.shape,...gF.shape,progressToken:AP}),vF=BP.extend({method:$(`notifications/progress`),params:_F}),yF=FP.extend({cursor:jP.optional()}),bF=RP.extend({params:yF.optional()}),xF=VP.extend({nextCursor:jP.optional()}),SF=QN([`working`,`input_required`,`completed`,`failed`,`cancelled`]),CF=Q({taskId:X(),status:SF,ttl:WN([DN(),NN()]),createdAt:X(),lastUpdatedAt:X(),pollInterval:rP(DN()),statusMessage:rP(X())}),wF=VP.extend({task:CF}),TF=zP.merge(CF),EF=BP.extend({method:$(`notifications/tasks/status`),params:TF}),DF=RP.extend({method:$(`tasks/get`),params:FP.extend({taskId:X()})}),OF=VP.merge(CF),kF=RP.extend({method:$(`tasks/result`),params:FP.extend({taskId:X()})});VP.loose();var AF=bF.extend({method:$(`tasks/list`)}),jF=xF.extend({tasks:Z(CF)}),MF=RP.extend({method:$(`tasks/cancel`),params:FP.extend({taskId:X()})}),NF=VP.merge(CF),PF=Q({uri:X(),mimeType:rP(X()),_meta:XN(X(),LN()).optional()}),FF=PF.extend({text:X()}),IF=X().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),LF=PF.extend({blob:IF}),RF=QN([`user`,`assistant`]),zF=Q({audience:Z(RF).optional(),priority:DN().min(0).max(1).optional(),lastModified:UM({offset:!0}).optional()}),BF=Q({...rF.shape,...nF.shape,uri:X(),description:rP(X()),mimeType:rP(X()),size:rP(DN()),annotations:zF.optional(),_meta:rP(HN({}))}),VF=Q({...rF.shape,...nF.shape,uriTemplate:X(),description:rP(X()),mimeType:rP(X()),annotations:zF.optional(),_meta:rP(HN({}))}),HF=bF.extend({method:$(`resources/list`)}),UF=xF.extend({resources:Z(BF)}),WF=bF.extend({method:$(`resources/templates/list`)}),GF=xF.extend({resourceTemplates:Z(VF)}),KF=FP.extend({uri:X()}),qF=KF,JF=RP.extend({method:$(`resources/read`),params:qF}),YF=VP.extend({contents:Z(WN([FF,LF]))}),XF=BP.extend({method:$(`notifications/resources/list_changed`),params:zP.optional()}),ZF=KF,QF=RP.extend({method:$(`resources/subscribe`),params:ZF}),$F=KF,eI=RP.extend({method:$(`resources/unsubscribe`),params:$F}),tI=zP.extend({uri:X()}),nI=BP.extend({method:$(`notifications/resources/updated`),params:tI}),rI=Q({name:X(),description:rP(X()),required:rP(jN())}),iI=Q({...rF.shape,...nF.shape,description:rP(X()),arguments:rP(Z(rI)),_meta:rP(HN({}))}),aI=bF.extend({method:$(`prompts/list`)}),oI=xF.extend({prompts:Z(iI)}),sI=FP.extend({name:X(),arguments:XN(X(),X()).optional()}),cI=RP.extend({method:$(`prompts/get`),params:sI}),lI=Q({type:$(`text`),text:X(),annotations:zF.optional(),_meta:XN(X(),LN()).optional()}),uI=Q({type:$(`image`),data:IF,mimeType:X(),annotations:zF.optional(),_meta:XN(X(),LN()).optional()}),dI=Q({type:$(`audio`),data:IF,mimeType:X(),annotations:zF.optional(),_meta:XN(X(),LN()).optional()}),fI=Q({type:$(`tool_use`),name:X(),id:X(),input:XN(X(),LN()),_meta:XN(X(),LN()).optional()}),pI=Q({type:$(`resource`),resource:WN([FF,LF]),annotations:zF.optional(),_meta:XN(X(),LN()).optional()}),mI=WN([lI,uI,dI,BF.extend({type:$(`resource_link`)}),pI]),hI=Q({role:RF,content:mI}),gI=VP.extend({description:X().optional(),messages:Z(hI)}),_I=BP.extend({method:$(`notifications/prompts/list_changed`),params:zP.optional()}),vI=Q({title:X().optional(),readOnlyHint:jN().optional(),destructiveHint:jN().optional(),idempotentHint:jN().optional(),openWorldHint:jN().optional()}),yI=Q({taskSupport:QN([`required`,`optional`,`forbidden`]).optional()}),bI=Q({...rF.shape,...nF.shape,description:X().optional(),inputSchema:Q({type:$(`object`),properties:XN(X(),kP).optional(),required:Z(X()).optional()}).catchall(LN()),outputSchema:Q({type:$(`object`),properties:XN(X(),kP).optional(),required:Z(X()).optional()}).catchall(LN()).optional(),annotations:vI.optional(),execution:yI.optional(),_meta:XN(X(),LN()).optional()}),xI=bF.extend({method:$(`tools/list`)}),SI=xF.extend({tools:Z(bI)}),CI=VP.extend({content:Z(mI).default([]),structuredContent:XN(X(),LN()).optional(),isError:jN().optional()});CI.or(VP.extend({toolResult:LN()}));var wI=IP.extend({name:X(),arguments:XN(X(),LN()).optional()}),TI=RP.extend({method:$(`tools/call`),params:wI}),EI=BP.extend({method:$(`notifications/tools/list_changed`),params:zP.optional()}),DI=Q({autoRefresh:jN().default(!0),debounceMs:DN().int().nonnegative().default(300)}),OI=QN([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),kI=FP.extend({level:OI}),AI=RP.extend({method:$(`logging/setLevel`),params:kI}),jI=zP.extend({level:OI,logger:X().optional(),data:LN()}),MI=BP.extend({method:$(`notifications/message`),params:jI}),NI=Q({hints:Z(Q({name:X().optional()})).optional(),costPriority:DN().min(0).max(1).optional(),speedPriority:DN().min(0).max(1).optional(),intelligencePriority:DN().min(0).max(1).optional()}),PI=Q({mode:QN([`auto`,`required`,`none`]).optional()}),FI=Q({type:$(`tool_result`),toolUseId:X().describe(`The unique identifier for the corresponding tool call.`),content:Z(mI).default([]),structuredContent:Q({}).loose().optional(),isError:jN().optional(),_meta:XN(X(),LN()).optional()}),II=KN(`type`,[lI,uI,dI]),LI=KN(`type`,[lI,uI,dI,fI,FI]),RI=Q({role:RF,content:WN([LI,Z(LI)]),_meta:XN(X(),LN()).optional()}),zI=IP.extend({messages:Z(RI),modelPreferences:NI.optional(),systemPrompt:X().optional(),includeContext:QN([`none`,`thisServer`,`allServers`]).optional(),temperature:DN().optional(),maxTokens:DN().int(),stopSequences:Z(X()).optional(),metadata:kP.optional(),tools:Z(bI).optional(),toolChoice:PI.optional()}),BI=RP.extend({method:$(`sampling/createMessage`),params:zI}),VI=VP.extend({model:X(),stopReason:rP(QN([`endTurn`,`stopSequence`,`maxTokens`]).or(X())),role:RF,content:II}),HI=VP.extend({model:X(),stopReason:rP(QN([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(X())),role:RF,content:WN([LI,Z(LI)])}),UI=Q({type:$(`boolean`),title:X().optional(),description:X().optional(),default:jN().optional()}),WI=Q({type:$(`string`),title:X().optional(),description:X().optional(),minLength:DN().optional(),maxLength:DN().optional(),format:QN([`email`,`uri`,`date`,`date-time`]).optional(),default:X().optional()}),GI=Q({type:QN([`number`,`integer`]),title:X().optional(),description:X().optional(),minimum:DN().optional(),maximum:DN().optional(),default:DN().optional()}),KI=Q({type:$(`string`),title:X().optional(),description:X().optional(),enum:Z(X()),default:X().optional()}),qI=Q({type:$(`string`),title:X().optional(),description:X().optional(),oneOf:Z(Q({const:X(),title:X()})),default:X().optional()}),JI=WN([WN([Q({type:$(`string`),title:X().optional(),description:X().optional(),enum:Z(X()),enumNames:Z(X()).optional(),default:X().optional()}),WN([KI,qI]),WN([Q({type:$(`array`),title:X().optional(),description:X().optional(),minItems:DN().optional(),maxItems:DN().optional(),items:Q({type:$(`string`),enum:Z(X())}),default:Z(X()).optional()}),Q({type:$(`array`),title:X().optional(),description:X().optional(),minItems:DN().optional(),maxItems:DN().optional(),items:Q({anyOf:Z(Q({const:X(),title:X()}))}),default:Z(X()).optional()})])]),UI,WI,GI]),YI=WN([IP.extend({mode:$(`form`).optional(),message:X(),requestedSchema:Q({type:$(`object`),properties:XN(X(),JI),required:Z(X()).optional()})}),IP.extend({mode:$(`url`),message:X(),elicitationId:X(),url:X().url()})]),XI=RP.extend({method:$(`elicitation/create`),params:YI}),ZI=zP.extend({elicitationId:X()}),QI=BP.extend({method:$(`notifications/elicitation/complete`),params:ZI}),$I=VP.extend({action:QN([`accept`,`decline`,`cancel`]),content:CP(e=>e===null?void 0:e,XN(X(),WN([X(),DN(),jN(),Z(X())])).optional())}),eL=Q({type:$(`ref/resource`),uri:X()}),tL=Q({type:$(`ref/prompt`),name:X()}),nL=FP.extend({ref:WN([tL,eL]),argument:Q({name:X(),value:X()}),context:Q({arguments:XN(X(),X()).optional()}).optional()}),rL=RP.extend({method:$(`completion/complete`),params:nL}),iL=VP.extend({completion:HN({values:Z(X()).max(100),total:rP(DN().int()),hasMore:rP(jN())})}),aL=Q({uri:X().startsWith(`file://`),name:X().optional(),_meta:XN(X(),LN()).optional()}),oL=RP.extend({method:$(`roots/list`),params:FP.optional()}),sL=VP.extend({roots:Z(aL)}),cL=BP.extend({method:$(`notifications/roots/list_changed`),params:zP.optional()});WN([hF,uF,rL,AI,cI,aI,HF,WF,JF,QF,eI,TI,xI,DF,kF,AF,MF]),WN([tF,vF,pF,cL,EF]),WN([$P,VI,HI,$I,sL,OF,jF,wF]),WN([hF,BI,XI,oL,DF,kF,AF,MF]),WN([tF,vF,MI,nI,XF,EI,_I,EF,QI]),WN([$P,fF,iL,gI,oI,UF,GF,YF,CI,SI,OF,jF,wF]);var lL=class e extends Error{constructor(e,t,n){super(`MCP error ${e}: ${t}`),this.code=e,this.data=n,this.name=`McpError`}static fromError(t,n,r){if(t===YP.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new uL(e.elicitations,n)}return new e(t,n,r)}},uL=class extends lL{constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(YP.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},dL=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}};function fL(e){}function pL(e){if(typeof e==`function`)throw TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");let{onEvent:t=fL,onError:n=fL,onRetry:r=fL,onComment:i}=e,a=``,o=!0,s,c=``,l=``;function u(e){let t=o?e.replace(/^\xEF\xBB\xBF/,``):e,[n,r]=mL(`${a}${t}`);for(let e of n)d(e);a=r,o=!1}function d(e){if(e===``){p();return}if(e.startsWith(`:`)){i&&i(e.slice(e.startsWith(`: `)?2:1));return}let t=e.indexOf(`:`);if(t!==-1){let n=e.slice(0,t),r=e[t+1]===` `?2:1;f(n,e.slice(t+r),e);return}f(e,``,e)}function f(e,t,i){switch(e){case`event`:l=t;break;case`data`:c=`${c}${t}
|
|
215
|
+
`;break;case`id`:s=t.includes(`\0`)?void 0:t;break;case`retry`:/^\d+$/.test(t)?r(parseInt(t,10)):n(new dL(`Invalid \`retry\` value: "${t}"`,{type:`invalid-retry`,value:t,line:i}));break;default:n(new dL(`Unknown field "${e.length>20?`${e.slice(0,20)}\u2026`:e}"`,{type:`unknown-field`,field:e,value:t,line:i}))}}function p(){c.length>0&&t({id:s,event:l||void 0,data:c.endsWith(`
|
|
216
|
+
`)?c.slice(0,-1):c}),s=void 0,c=``,l=``}function m(e={}){a&&e.consume&&d(a),o=!0,s=void 0,c=``,l=``,a=``}return{feed:u,reset:m}}function mL(e){let t=[],n=``,r=0;for(;r<e.length;){let i=e.indexOf(`\r`,r),a=e.indexOf(`
|
|
217
217
|
`,r),o=-1;if(i!==-1&&a!==-1?o=Math.min(i,a):i===-1?a!==-1&&(o=a):o=i===e.length-1?-1:i,o===-1){n=e.slice(r);break}{let n=e.slice(r,o);t.push(n),r=o+1,e[r-1]===`\r`&&e[r]===`
|
|
218
|
-
`&&r++}}return[t,n]}var lL=class extends Event{constructor(e,t){super(e),this.code=t?.code??void 0,this.message=t?.message??void 0}[Symbol.for(`nodejs.util.inspect.custom`)](e,t,n){return n(fL(this),t)}[Symbol.for(`Deno.customInspect`)](e,t){return e(fL(this),t)}};function uL(e){let t=globalThis.DOMException;return typeof t==`function`?new t(e,`SyntaxError`):SyntaxError(e)}function dL(e){return e instanceof Error?`errors`in e&&Array.isArray(e.errors)?e.errors.map(dL).join(`, `):`cause`in e&&e.cause instanceof Error?`${e}: ${dL(e.cause)}`:e.message:`${e}`}function fL(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var pL=e=>{throw TypeError(e)},mL=(e,t,n)=>t.has(e)||pL(`Cannot `+n),hL=(e,t,n)=>(mL(e,t,`read from private field`),n?n.call(e):t.get(e)),gL=(e,t,n)=>t.has(e)?pL(`Cannot add the same private member more than once`):t instanceof WeakSet?t.add(e):t.set(e,n),_L=(e,t,n,r)=>(mL(e,t,`write to private field`),t.set(e,n),n),vL=(e,t,n)=>(mL(e,t,`access private method`),n),yL,bL,xL,SL,CL,wL,TL,EL,DL,OL,kL,AL,jL,ML,NL,PL,FL,IL,LL,RL,zL,BL,VL,HL=class extends EventTarget{constructor(e,t){super(),gL(this,ML),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,gL(this,yL),gL(this,bL),gL(this,xL),gL(this,SL),gL(this,CL),gL(this,wL),gL(this,TL),gL(this,EL,null),gL(this,DL),gL(this,OL),gL(this,kL,null),gL(this,AL,null),gL(this,jL,null),gL(this,PL,async e=>{var t;hL(this,OL).reset();let{body:n,redirected:r,status:i,headers:a}=e;if(i===204){vL(this,ML,zL).call(this,`Server sent HTTP 204, not reconnecting`,204),this.close();return}if(r?_L(this,xL,new URL(e.url)):_L(this,xL,void 0),i!==200){vL(this,ML,zL).call(this,`Non-200 status code (${i})`,i);return}if(!(a.get(`content-type`)||``).startsWith(`text/event-stream`)){vL(this,ML,zL).call(this,`Invalid content type, expected "text/event-stream"`,i);return}if(hL(this,yL)===this.CLOSED)return;_L(this,yL,this.OPEN);let o=new Event(`open`);if((t=hL(this,jL))==null||t.call(this,o),this.dispatchEvent(o),typeof n!=`object`||!n||!(`getReader`in n)){vL(this,ML,zL).call(this,`Invalid response body, expected a web ReadableStream`,i),this.close();return}let s=new TextDecoder,c=n.getReader(),l=!0;do{let{done:e,value:t}=await c.read();t&&hL(this,OL).feed(s.decode(t,{stream:!e})),e&&(l=!1,hL(this,OL).reset(),vL(this,ML,BL).call(this))}while(l)}),gL(this,FL,e=>{_L(this,DL,void 0),e.name!==`AbortError`&&e.type!==`aborted`&&vL(this,ML,BL).call(this,dL(e))}),gL(this,LL,e=>{typeof e.id==`string`&&_L(this,EL,e.id);let t=new MessageEvent(e.event||`message`,{data:e.data,origin:hL(this,xL)?hL(this,xL).origin:hL(this,bL).origin,lastEventId:e.id||``});hL(this,AL)&&(!e.event||e.event===`message`)&&hL(this,AL).call(this,t),this.dispatchEvent(t)}),gL(this,RL,e=>{_L(this,wL,e)}),gL(this,VL,()=>{_L(this,TL,void 0),hL(this,yL)===this.CONNECTING&&vL(this,ML,NL).call(this)});try{if(e instanceof URL)_L(this,bL,e);else if(typeof e==`string`)_L(this,bL,new URL(e,UL()));else throw Error(`Invalid URL`)}catch{throw uL(`An invalid or illegal string was specified`)}_L(this,OL,sL({onEvent:hL(this,LL),onRetry:hL(this,RL)})),_L(this,yL,this.CONNECTING),_L(this,wL,3e3),_L(this,CL,t?.fetch??globalThis.fetch),_L(this,SL,t?.withCredentials??!1),vL(this,ML,NL).call(this)}get readyState(){return hL(this,yL)}get url(){return hL(this,bL).href}get withCredentials(){return hL(this,SL)}get onerror(){return hL(this,kL)}set onerror(e){_L(this,kL,e)}get onmessage(){return hL(this,AL)}set onmessage(e){_L(this,AL,e)}get onopen(){return hL(this,jL)}set onopen(e){_L(this,jL,e)}addEventListener(e,t,n){let r=t;super.addEventListener(e,r,n)}removeEventListener(e,t,n){let r=t;super.removeEventListener(e,r,n)}close(){hL(this,TL)&&clearTimeout(hL(this,TL)),hL(this,yL)!==this.CLOSED&&(hL(this,DL)&&hL(this,DL).abort(),_L(this,yL,this.CLOSED),_L(this,DL,void 0))}};yL=new WeakMap,bL=new WeakMap,xL=new WeakMap,SL=new WeakMap,CL=new WeakMap,wL=new WeakMap,TL=new WeakMap,EL=new WeakMap,DL=new WeakMap,OL=new WeakMap,kL=new WeakMap,AL=new WeakMap,jL=new WeakMap,ML=new WeakSet,NL=function(){_L(this,yL,this.CONNECTING),_L(this,DL,new AbortController),hL(this,CL)(hL(this,bL),vL(this,ML,IL).call(this)).then(hL(this,PL)).catch(hL(this,FL))},PL=new WeakMap,FL=new WeakMap,IL=function(){let e={mode:`cors`,redirect:`follow`,headers:{Accept:`text/event-stream`,...hL(this,EL)?{"Last-Event-ID":hL(this,EL)}:void 0},cache:`no-store`,signal:hL(this,DL)?.signal};return`window`in globalThis&&(e.credentials=this.withCredentials?`include`:`same-origin`),e},LL=new WeakMap,RL=new WeakMap,zL=function(e,t){var n;hL(this,yL)!==this.CLOSED&&_L(this,yL,this.CLOSED);let r=new lL(`error`,{code:t,message:e});(n=hL(this,kL))==null||n.call(this,r),this.dispatchEvent(r)},BL=function(e,t){var n;if(hL(this,yL)===this.CLOSED)return;_L(this,yL,this.CONNECTING);let r=new lL(`error`,{code:t,message:e});(n=hL(this,kL))==null||n.call(this,r),this.dispatchEvent(r),_L(this,TL,setTimeout(hL(this,VL),hL(this,wL)))},VL=new WeakMap,HL.CONNECTING=0,HL.OPEN=1,HL.CLOSED=2;function UL(){let e=`document`in globalThis?globalThis.document:void 0;return e&&typeof e==`object`&&`baseURI`in e&&typeof e.baseURI==`string`?e.baseURI:void 0}function WL(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function GL(e=fetch,t){return t?async(n,r)=>e(n,{...t,...r,headers:r?.headers?{...WL(t.headers),...WL(r.headers)}:t.headers}):e}var KL=globalThis.crypto;async function qL(e){return(await KL).getRandomValues(new Uint8Array(e))}async function JL(e){let t=``,n=await qL(e);for(let r=0;r<e;r++){let e=n[r]%66;t+=`abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~`[e]}return t}async function YL(e){return await JL(e)}async function XL(e){let t=await(await KL).subtle.digest(`SHA-256`,new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,`_`).replace(/\+/g,`-`).replace(/=/g,``)}async function ZL(e){if(e||=43,e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;let t=await YL(e);return{code_verifier:t,code_challenge:await XL(t)}}var QL=iN().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:vP.custom,message:`URL must be parseable`,fatal:!0}),jO}).refine(e=>{let t=new URL(e);return t.protocol!==`javascript:`&&t.protocol!==`data:`&&t.protocol!==`vbscript:`},{message:`URL cannot use javascript:, data:, or vbscript: scheme`}),$L=IN({resource:X().url(),authorization_servers:Z(QL).optional(),jwks_uri:X().url().optional(),scopes_supported:Z(X()).optional(),bearer_methods_supported:Z(X()).optional(),resource_signing_alg_values_supported:Z(X()).optional(),resource_name:X().optional(),resource_documentation:X().optional(),resource_policy_uri:X().url().optional(),resource_tos_uri:X().url().optional(),tls_client_certificate_bound_access_tokens:TN().optional(),authorization_details_types_supported:Z(X()).optional(),dpop_signing_alg_values_supported:Z(X()).optional(),dpop_bound_access_tokens_required:TN().optional()}),eR=IN({issuer:X(),authorization_endpoint:QL,token_endpoint:QL,registration_endpoint:QL.optional(),scopes_supported:Z(X()).optional(),response_types_supported:Z(X()),response_modes_supported:Z(X()).optional(),grant_types_supported:Z(X()).optional(),token_endpoint_auth_methods_supported:Z(X()).optional(),token_endpoint_auth_signing_alg_values_supported:Z(X()).optional(),service_documentation:QL.optional(),revocation_endpoint:QL.optional(),revocation_endpoint_auth_methods_supported:Z(X()).optional(),revocation_endpoint_auth_signing_alg_values_supported:Z(X()).optional(),introspection_endpoint:X().optional(),introspection_endpoint_auth_methods_supported:Z(X()).optional(),introspection_endpoint_auth_signing_alg_values_supported:Z(X()).optional(),code_challenge_methods_supported:Z(X()).optional(),client_id_metadata_document_supported:TN().optional()}),tR=Q({...IN({issuer:X(),authorization_endpoint:QL,token_endpoint:QL,userinfo_endpoint:QL.optional(),jwks_uri:QL,registration_endpoint:QL.optional(),scopes_supported:Z(X()).optional(),response_types_supported:Z(X()),response_modes_supported:Z(X()).optional(),grant_types_supported:Z(X()).optional(),acr_values_supported:Z(X()).optional(),subject_types_supported:Z(X()),id_token_signing_alg_values_supported:Z(X()),id_token_encryption_alg_values_supported:Z(X()).optional(),id_token_encryption_enc_values_supported:Z(X()).optional(),userinfo_signing_alg_values_supported:Z(X()).optional(),userinfo_encryption_alg_values_supported:Z(X()).optional(),userinfo_encryption_enc_values_supported:Z(X()).optional(),request_object_signing_alg_values_supported:Z(X()).optional(),request_object_encryption_alg_values_supported:Z(X()).optional(),request_object_encryption_enc_values_supported:Z(X()).optional(),token_endpoint_auth_methods_supported:Z(X()).optional(),token_endpoint_auth_signing_alg_values_supported:Z(X()).optional(),display_values_supported:Z(X()).optional(),claim_types_supported:Z(X()).optional(),claims_supported:Z(X()).optional(),service_documentation:X().optional(),claims_locales_supported:Z(X()).optional(),ui_locales_supported:Z(X()).optional(),claims_parameter_supported:TN().optional(),request_parameter_supported:TN().optional(),request_uri_parameter_supported:TN().optional(),require_request_uri_registration:TN().optional(),op_policy_uri:QL.optional(),op_tos_uri:QL.optional(),client_id_metadata_document_supported:TN().optional()}).shape,...eR.pick({code_challenge_methods_supported:!0}).shape}),nR=Q({access_token:X(),id_token:X().optional(),token_type:X(),expires_in:yP().optional(),scope:X().optional(),refresh_token:X().optional()}).strip(),rR=Q({error:X(),error_description:X().optional(),error_uri:X().optional()}),iR=QL.optional().or($(``).transform(()=>void 0)),aR=Q({redirect_uris:Z(QL),token_endpoint_auth_method:X().optional(),grant_types:Z(X()).optional(),response_types:Z(X()).optional(),client_name:X().optional(),client_uri:QL.optional(),logo_uri:iR,scope:X().optional(),contacts:Z(X()).optional(),tos_uri:iR,policy_uri:X().optional(),jwks_uri:QL.optional(),jwks:kN().optional(),software_id:X().optional(),software_version:X().optional(),software_statement:X().optional()}).strip(),oR=Q({client_id:X(),client_secret:X().optional(),client_id_issued_at:xN().optional(),client_secret_expires_at:xN().optional()}).strip(),sR=aR.merge(oR);Q({error:X(),error_description:X().optional()}).strip(),Q({token:X(),token_type_hint:X().optional()}).strip();function cR(e){let t=typeof e==`string`?new URL(e):new URL(e.href);return t.hash=``,t}function lR({requestedResource:e,configuredResource:t}){let n=typeof e==`string`?new URL(e):new URL(e.href),r=typeof t==`string`?new URL(t):new URL(t.href);if(n.origin!==r.origin||n.pathname.length<r.pathname.length)return!1;let i=n.pathname.endsWith(`/`)?n.pathname:n.pathname+`/`,a=r.pathname.endsWith(`/`)?r.pathname:r.pathname+`/`;return i.startsWith(a)}var uR=class extends Error{constructor(e,t){super(e),this.errorUri=t,this.name=this.constructor.name}toResponseObject(){let e={error:this.errorCode,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}get errorCode(){return this.constructor.errorCode}},dR=class extends uR{};dR.errorCode=`invalid_request`;var fR=class extends uR{};fR.errorCode=`invalid_client`;var pR=class extends uR{};pR.errorCode=`invalid_grant`;var mR=class extends uR{};mR.errorCode=`unauthorized_client`;var hR=class extends uR{};hR.errorCode=`unsupported_grant_type`;var gR=class extends uR{};gR.errorCode=`invalid_scope`;var _R=class extends uR{};_R.errorCode=`access_denied`;var vR=class extends uR{};vR.errorCode=`server_error`;var yR=class extends uR{};yR.errorCode=`temporarily_unavailable`;var bR=class extends uR{};bR.errorCode=`unsupported_response_type`;var xR=class extends uR{};xR.errorCode=`unsupported_token_type`;var SR=class extends uR{};SR.errorCode=`invalid_token`;var CR=class extends uR{};CR.errorCode=`method_not_allowed`;var wR=class extends uR{};wR.errorCode=`too_many_requests`;var TR=class extends uR{};TR.errorCode=`invalid_client_metadata`;var ER=class extends uR{};ER.errorCode=`insufficient_scope`;var DR=class extends uR{};DR.errorCode=`invalid_target`;var OR={[dR.errorCode]:dR,[fR.errorCode]:fR,[pR.errorCode]:pR,[mR.errorCode]:mR,[hR.errorCode]:hR,[gR.errorCode]:gR,[_R.errorCode]:_R,[vR.errorCode]:vR,[yR.errorCode]:yR,[bR.errorCode]:bR,[xR.errorCode]:xR,[SR.errorCode]:SR,[CR.errorCode]:CR,[wR.errorCode]:wR,[TR.errorCode]:TR,[ER.errorCode]:ER,[DR.errorCode]:DR},kR=class extends Error{constructor(e){super(e??`Unauthorized`)}};function AR(e){return[`client_secret_basic`,`client_secret_post`,`none`].includes(e)}var jR=`code`,MR=`S256`;function NR(e,t){let n=e.client_secret!==void 0;return`token_endpoint_auth_method`in e&&e.token_endpoint_auth_method&&AR(e.token_endpoint_auth_method)&&(t.length===0||t.includes(e.token_endpoint_auth_method))?e.token_endpoint_auth_method:t.length===0?n?`client_secret_basic`:`none`:n&&t.includes(`client_secret_basic`)?`client_secret_basic`:n&&t.includes(`client_secret_post`)?`client_secret_post`:t.includes(`none`)?`none`:n?`client_secret_post`:`none`}function PR(e,t,n,r){let{client_id:i,client_secret:a}=t;switch(e){case`client_secret_basic`:FR(i,a,n);return;case`client_secret_post`:IR(i,a,r);return;case`none`:LR(i,r);return;default:throw Error(`Unsupported client authentication method: ${e}`)}}function FR(e,t,n){if(!t)throw Error(`client_secret_basic authentication requires a client_secret`);let r=btoa(`${e}:${t}`);n.set(`Authorization`,`Basic ${r}`)}function IR(e,t,n){n.set(`client_id`,e),t&&n.set(`client_secret`,t)}function LR(e,t){t.set(`client_id`,e)}async function RR(e){let t=e instanceof Response?e.status:void 0,n=e instanceof Response?await e.text():e;try{let{error:e,error_description:t,error_uri:r}=rR.parse(JSON.parse(n));return new(OR[e]||vR)(t||``,r)}catch(e){return new vR(`${t?`HTTP ${t}: `:``}Invalid OAuth error response: ${e}. Raw body: ${n}`)}}async function zR(e,t){try{return await BR(e,t)}catch(n){if(n instanceof fR||n instanceof mR)return await e.invalidateCredentials?.(`all`),await BR(e,t);if(n instanceof pR)return await e.invalidateCredentials?.(`tokens`),await BR(e,t);throw n}}async function BR(e,{serverUrl:t,authorizationCode:n,scope:r,resourceMetadataUrl:i,fetchFn:a}){let o=await e.discoveryState?.(),s,c,l,u=i;if(!u&&o?.resourceMetadataUrl&&(u=new URL(o.resourceMetadataUrl)),o?.authorizationServerUrl){if(c=o.authorizationServerUrl,s=o.resourceMetadata,l=o.authorizationServerMetadata??await QR(c,{fetchFn:a}),!s)try{s=await GR(t,{resourceMetadataUrl:u},a)}catch{}(l!==o.authorizationServerMetadata||s!==o.resourceMetadata)&&await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:u?.toString(),resourceMetadata:s,authorizationServerMetadata:l})}else{let n=await $R(t,{resourceMetadataUrl:u,fetchFn:a});c=n.authorizationServerUrl,l=n.authorizationServerMetadata,s=n.resourceMetadata,await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:u?.toString(),resourceMetadata:s,authorizationServerMetadata:l})}let d=await HR(t,e,s),f=r||s?.scopes_supported?.join(` `)||e.clientMetadata.scope,p=await Promise.resolve(e.clientInformation());if(!p){if(n!==void 0)throw Error(`Existing OAuth client information is required when exchanging an authorization code`);let t=l?.client_id_metadata_document_supported===!0,r=e.clientMetadataUrl;if(r&&!VR(r))throw new TR(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${r}`);if(t&&r)p={client_id:r},await e.saveClientInformation?.(p);else{if(!e.saveClientInformation)throw Error(`OAuth client information must be saveable for dynamic registration`);let t=await az(c,{metadata:l,clientMetadata:e.clientMetadata,scope:f,fetchFn:a});await e.saveClientInformation(t),p=t}}let m=!e.redirectUrl;if(n!==void 0||m){let t=await iz(e,c,{metadata:l,resource:d,authorizationCode:n,fetchFn:a});return await e.saveTokens(t),`AUTHORIZED`}let h=await e.tokens();if(h?.refresh_token)try{let t=await rz(c,{metadata:l,clientInformation:p,refreshToken:h.refresh_token,resource:d,addClientAuthentication:e.addClientAuthentication,fetchFn:a});return await e.saveTokens(t),`AUTHORIZED`}catch(e){if(!(!(e instanceof uR)||e instanceof vR))throw e}let g=e.state?await e.state():void 0,{authorizationUrl:_,codeVerifier:v}=await ez(c,{metadata:l,clientInformation:p,state:g,redirectUrl:e.redirectUrl,scope:f,resource:d});return await e.saveCodeVerifier(v),await e.redirectToAuthorization(_),`REDIRECT`}function VR(e){if(!e)return!1;try{let t=new URL(e);return t.protocol===`https:`&&t.pathname!==`/`}catch{return!1}}async function HR(e,t,n){let r=cR(e);if(t.validateResourceURL)return await t.validateResourceURL(r,n?.resource);if(n){if(!lR({requestedResource:r,configuredResource:n.resource}))throw Error(`Protected resource ${n.resource} does not match expected ${r} (or origin)`);return new URL(n.resource)}}function UR(e){let t=e.headers.get(`WWW-Authenticate`);if(!t)return{};let[n,r]=t.split(` `);if(n.toLowerCase()!==`bearer`||!r)return{};let i=WR(e,`resource_metadata`)||void 0,a;if(i)try{a=new URL(i)}catch{}let o=WR(e,`scope`)||void 0,s=WR(e,`error`)||void 0;return{resourceMetadataUrl:a,scope:o,error:s}}function WR(e,t){let n=e.headers.get(`WWW-Authenticate`);if(!n)return null;let r=RegExp(`${t}=(?:"([^"]+)"|([^\\s,]+))`),i=n.match(r);return i?i[1]||i[2]:null}async function GR(e,t,n=fetch){let r=await XR(e,`oauth-protected-resource`,n,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!r||r.status===404)throw await r?.body?.cancel(),Error(`Resource server does not implement OAuth 2.0 Protected Resource Metadata.`);if(!r.ok)throw await r.body?.cancel(),Error(`HTTP ${r.status} trying to load well-known OAuth protected resource metadata.`);return $L.parse(await r.json())}async function KR(e,t,n=fetch){try{return await n(e,{headers:t})}catch(r){if(r instanceof TypeError)return t?KR(e,void 0,n):void 0;throw r}}function qR(e,t=``,n={}){return t.endsWith(`/`)&&(t=t.slice(0,-1)),n.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}async function JR(e,t,n=fetch){return await KR(e,{"MCP-Protocol-Version":t},n)}function YR(e,t){return!e||e.status>=400&&e.status<500&&t!==`/`}async function XR(e,t,n,r){let i=new URL(e),a=r?.protocolVersion??`2025-11-25`,o;if(r?.metadataUrl)o=new URL(r.metadataUrl);else{let e=qR(t,i.pathname);o=new URL(e,r?.metadataServerUrl??i),o.search=i.search}let s=await JR(o,a,n);return!r?.metadataUrl&&YR(s,i.pathname)&&(s=await JR(new URL(`/.well-known/${t}`,i),a,n)),s}function ZR(e){let t=typeof e==`string`?new URL(e):e,n=t.pathname!==`/`,r=[];if(!n)return r.push({url:new URL(`/.well-known/oauth-authorization-server`,t.origin),type:`oauth`}),r.push({url:new URL(`/.well-known/openid-configuration`,t.origin),type:`oidc`}),r;let i=t.pathname;return i.endsWith(`/`)&&(i=i.slice(0,-1)),r.push({url:new URL(`/.well-known/oauth-authorization-server${i}`,t.origin),type:`oauth`}),r.push({url:new URL(`/.well-known/openid-configuration${i}`,t.origin),type:`oidc`}),r.push({url:new URL(`${i}/.well-known/openid-configuration`,t.origin),type:`oidc`}),r}async function QR(e,{fetchFn:t=fetch,protocolVersion:n=bP}={}){let r={"MCP-Protocol-Version":n,Accept:`application/json`},i=ZR(e);for(let{url:e,type:n}of i){let i=await KR(e,r,t);if(i){if(!i.ok){if(await i.body?.cancel(),i.status>=400&&i.status<500)continue;throw Error(`HTTP ${i.status} trying to load ${n===`oauth`?`OAuth`:`OpenID provider`} metadata from ${e}`)}return n===`oauth`?eR.parse(await i.json()):tR.parse(await i.json())}}}async function $R(e,t){let n,r;try{n=await GR(e,{resourceMetadataUrl:t?.resourceMetadataUrl},t?.fetchFn),n.authorization_servers&&n.authorization_servers.length>0&&(r=n.authorization_servers[0])}catch{}r||=String(new URL(`/`,e));let i=await QR(r,{fetchFn:t?.fetchFn});return{authorizationServerUrl:r,authorizationServerMetadata:i,resourceMetadata:n}}async function ez(e,{metadata:t,clientInformation:n,redirectUrl:r,scope:i,state:a,resource:o}){let s;if(t){if(s=new URL(t.authorization_endpoint),!t.response_types_supported.includes(jR))throw Error(`Incompatible auth server: does not support response type ${jR}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(MR))throw Error(`Incompatible auth server: does not support code challenge method ${MR}`)}else s=new URL(`/authorize`,e);let c=await ZL(),l=c.code_verifier,u=c.code_challenge;return s.searchParams.set(`response_type`,jR),s.searchParams.set(`client_id`,n.client_id),s.searchParams.set(`code_challenge`,u),s.searchParams.set(`code_challenge_method`,MR),s.searchParams.set(`redirect_uri`,String(r)),a&&s.searchParams.set(`state`,a),i&&s.searchParams.set(`scope`,i),i?.includes(`offline_access`)&&s.searchParams.append(`prompt`,`consent`),o&&s.searchParams.set(`resource`,o.href),{authorizationUrl:s,codeVerifier:l}}function tz(e,t,n){return new URLSearchParams({grant_type:`authorization_code`,code:e,code_verifier:t,redirect_uri:String(n)})}async function nz(e,{metadata:t,tokenRequestParams:n,clientInformation:r,addClientAuthentication:i,resource:a,fetchFn:o}){let s=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`});a&&n.set(`resource`,a.href),i?await i(c,n,s,t):r&&PR(NR(r,t?.token_endpoint_auth_methods_supported??[]),r,c,n);let l=await(o??fetch)(s,{method:`POST`,headers:c,body:n});if(!l.ok)throw await RR(l);return nR.parse(await l.json())}async function rz(e,{metadata:t,clientInformation:n,refreshToken:r,resource:i,addClientAuthentication:a,fetchFn:o}){return{refresh_token:r,...await nz(e,{metadata:t,tokenRequestParams:new URLSearchParams({grant_type:`refresh_token`,refresh_token:r}),clientInformation:n,addClientAuthentication:a,resource:i,fetchFn:o})}}async function iz(e,t,{metadata:n,resource:r,authorizationCode:i,fetchFn:a}={}){let o=e.clientMetadata.scope,s;if(e.prepareTokenRequest&&(s=await e.prepareTokenRequest(o)),!s){if(!i)throw Error(`Either provider.prepareTokenRequest() or authorizationCode is required`);if(!e.redirectUrl)throw Error(`redirectUrl is required for authorization_code flow`);s=tz(i,await e.codeVerifier(),e.redirectUrl)}let c=await e.clientInformation();return nz(t,{metadata:n,tokenRequestParams:s,clientInformation:c??void 0,addClientAuthentication:e.addClientAuthentication,resource:r,fetchFn:a})}async function az(e,{metadata:t,clientMetadata:n,scope:r,fetchFn:i}){let a;if(t){if(!t.registration_endpoint)throw Error(`Incompatible auth server: does not support dynamic client registration`);a=new URL(t.registration_endpoint)}else a=new URL(`/register`,e);let o=await(i??fetch)(a,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...n,...r===void 0?{}:{scope:r}})});if(!o.ok)throw await RR(o);return sR.parse(await o.json())}var oz=class extends Error{constructor(e,t,n){super(`SSE error: ${t}`),this.code=e,this.event=n}},sz=class{constructor(e,t){this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._eventSourceInit=t?.eventSourceInit,this._requestInit=t?.requestInit,this._authProvider=t?.authProvider,this._fetch=t?.fetch,this._fetchWithInit=GL(t?.fetch,t?.requestInit)}async _authThenStart(){if(!this._authProvider)throw new kR(`No auth provider`);let e;try{e=await zR(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(e){throw this.onerror?.(e),e}if(e!==`AUTHORIZED`)throw new kR;return await this._startOrAuth()}async _commonHeaders(){let e={};if(this._authProvider){let t=await this._authProvider.tokens();t&&(e.Authorization=`Bearer ${t.access_token}`)}this._protocolVersion&&(e[`mcp-protocol-version`]=this._protocolVersion);let t=WL(this._requestInit?.headers);return new Headers({...e,...t})}_startOrAuth(){let e=this?._eventSourceInit?.fetch??this._fetch??fetch;return new Promise((t,n)=>{this._eventSource=new HL(this._url.href,{...this._eventSourceInit,fetch:async(t,n)=>{let r=await this._commonHeaders();r.set(`Accept`,`text/event-stream`);let i=await e(t,{...n,headers:r});if(i.status===401&&i.headers.has(`www-authenticate`)){let{resourceMetadataUrl:e,scope:t}=UR(i);this._resourceMetadataUrl=e,this._scope=t}return i}}),this._abortController=new AbortController,this._eventSource.onerror=e=>{if(e.code===401&&this._authProvider){this._authThenStart().then(t,n);return}let r=new oz(e.code,e.message,e);n(r),this.onerror?.(r)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener(`endpoint`,e=>{let r=e;try{if(this._endpoint=new URL(r.data,this._url),this._endpoint.origin!==this._url.origin)throw Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(e){n(e),this.onerror?.(e),this.close();return}t()}),this._eventSource.onmessage=e=>{let t=e,n;try{n=KP.parse(JSON.parse(t.data))}catch(e){this.onerror?.(e);return}this.onmessage?.(n)}})}async start(){if(this._eventSource)throw Error(`SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.`);return await this._startOrAuth()}async finishAuth(e){if(!this._authProvider)throw new kR(`No auth provider`);if(await zR(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new kR(`Failed to authorize`)}async close(){this._abortController?.abort(),this._eventSource?.close(),this.onclose?.()}async send(e){if(!this._endpoint)throw Error(`Not connected`);try{let t=await this._commonHeaders();t.set(`content-type`,`application/json`);let n={...this._requestInit,method:`POST`,headers:t,body:JSON.stringify(e),signal:this._abortController?.signal},r=await(this._fetch??fetch)(this._endpoint,n);if(!r.ok){let t=await r.text().catch(()=>null);if(r.status===401&&this._authProvider){let{resourceMetadataUrl:t,scope:n}=UR(r);if(this._resourceMetadataUrl=t,this._scope=n,await zR(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new kR;return this.send(e)}throw Error(`Error POSTing to endpoint (HTTP ${r.status}): ${t}`)}await r.body?.cancel()}catch(e){throw this.onerror?.(e),e}}setProtocolVersion(e){this._protocolVersion=e}},cz=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:n}={}){let r;super({start(i){r=sL({onEvent:e=>{i.enqueue(e)},onError(t){e===`terminate`?i.error(t):typeof e==`function`&&e(t)},onRetry:t,onComment:n})},transform(e){r.feed(e)}})}},lz={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},uz=class extends Error{constructor(e,t){super(`Streamable HTTP error: ${t}`),this.code=e}},dz=class{constructor(e,t){this._hasCompletedAuthFlow=!1,this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=t?.requestInit,this._authProvider=t?.authProvider,this._fetch=t?.fetch,this._fetchWithInit=GL(t?.fetch,t?.requestInit),this._sessionId=t?.sessionId,this._reconnectionOptions=t?.reconnectionOptions??lz}async _authThenStart(){if(!this._authProvider)throw new kR(`No auth provider`);let e;try{e=await zR(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(e){throw this.onerror?.(e),e}if(e!==`AUTHORIZED`)throw new kR;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){let e={};if(this._authProvider){let t=await this._authProvider.tokens();t&&(e.Authorization=`Bearer ${t.access_token}`)}this._sessionId&&(e[`mcp-session-id`]=this._sessionId),this._protocolVersion&&(e[`mcp-protocol-version`]=this._protocolVersion);let t=WL(this._requestInit?.headers);return new Headers({...e,...t})}async _startOrAuthSse(e){let{resumptionToken:t}=e;try{let n=await this._commonHeaders();n.set(`Accept`,`text/event-stream`),t&&n.set(`last-event-id`,t);let r=await(this._fetch??fetch)(this._url,{method:`GET`,headers:n,signal:this._abortController?.signal});if(!r.ok){if(await r.body?.cancel(),r.status===401&&this._authProvider)return await this._authThenStart();if(r.status===405)return;throw new uz(r.status,`Failed to open SSE stream: ${r.statusText}`)}this._handleSseStream(r.body,e,!0)}catch(e){throw this.onerror?.(e),e}}_getNextReconnectionDelay(e){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let t=this._reconnectionOptions.initialReconnectionDelay,n=this._reconnectionOptions.reconnectionDelayGrowFactor,r=this._reconnectionOptions.maxReconnectionDelay;return Math.min(t*n**+e,r)}_scheduleReconnection(e,t=0){let n=this._reconnectionOptions.maxRetries;if(t>=n){this.onerror?.(Error(`Maximum reconnection attempts (${n}) exceeded.`));return}let r=this._getNextReconnectionDelay(t);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(e).catch(n=>{this.onerror?.(Error(`Failed to reconnect SSE stream: ${n instanceof Error?n.message:String(n)}`)),this._scheduleReconnection(e,t+1)})},r)}_handleSseStream(e,t,n){if(!e)return;let{onresumptiontoken:r,replayMessageId:i}=t,a,o=!1,s=!1;(async()=>{try{let t=e.pipeThrough(new TextDecoderStream).pipeThrough(new cz({onRetry:e=>{this._serverRetryMs=e}})).getReader();for(;;){let{value:e,done:n}=await t.read();if(n)break;if(e.id&&(a=e.id,o=!0,r?.(e.id)),e.data&&(!e.event||e.event===`message`))try{let t=KP.parse(JSON.parse(e.data));HP(t)&&(s=!0,i!==void 0&&(t.id=i)),this.onmessage?.(t)}catch(e){this.onerror?.(e)}}(n||o)&&!s&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:a,onresumptiontoken:r,replayMessageId:i},0)}catch(e){if(this.onerror?.(Error(`SSE stream disconnected: ${e}`)),(n||o)&&!s&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:a,onresumptiontoken:r,replayMessageId:i},0)}catch(e){this.onerror?.(Error(`Failed to reconnect: ${e instanceof Error?e.message:String(e)}`))}}})()}async start(){if(this._abortController)throw Error(`StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.`);this._abortController=new AbortController}async finishAuth(e){if(!this._authProvider)throw new kR(`No auth provider`);if(await zR(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new kR(`Failed to authorize`)}async close(){this._reconnectionTimeout&&=(clearTimeout(this._reconnectionTimeout),void 0),this._abortController?.abort(),this.onclose?.()}async send(e,t){try{let{resumptionToken:n,onresumptiontoken:r}=t||{};if(n){this._startOrAuthSse({resumptionToken:n,replayMessageId:RP(e)?e.id:void 0}).catch(e=>this.onerror?.(e));return}let i=await this._commonHeaders();i.set(`content-type`,`application/json`),i.set(`accept`,`application/json, text/event-stream`);let a={...this._requestInit,method:`POST`,headers:i,body:JSON.stringify(e),signal:this._abortController?.signal},o=await(this._fetch??fetch)(this._url,a),s=o.headers.get(`mcp-session-id`);if(s&&(this._sessionId=s),!o.ok){let t=await o.text().catch(()=>null);if(o.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new uz(401,`Server returned 401 after successful authentication`);let{resourceMetadataUrl:t,scope:n}=UR(o);if(this._resourceMetadataUrl=t,this._scope=n,await zR(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new kR;return this._hasCompletedAuthFlow=!0,this.send(e)}if(o.status===403&&this._authProvider){let{resourceMetadataUrl:t,scope:n,error:r}=UR(o);if(r===`insufficient_scope`){let r=o.headers.get(`WWW-Authenticate`);if(this._lastUpscopingHeader===r)throw new uz(403,`Server returned 403 after trying upscoping`);if(n&&(this._scope=n),t&&(this._resourceMetadataUrl=t),this._lastUpscopingHeader=r??void 0,await zR(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!==`AUTHORIZED`)throw new kR;return this.send(e)}}throw new uz(o.status,`Error POSTing to endpoint: ${t}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,o.status===202){await o.body?.cancel(),cF(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(e=>this.onerror?.(e));return}let c=(Array.isArray(e)?e:[e]).filter(e=>`method`in e&&`id`in e&&e.id!==void 0).length>0,l=o.headers.get(`content-type`);if(c){if(l?.includes(`text/event-stream`))this._handleSseStream(o.body,{onresumptiontoken:r},!1);else if(l?.includes(`application/json`)){let e=await o.json(),t=Array.isArray(e)?e.map(e=>KP.parse(e)):[KP.parse(e)];for(let e of t)this.onmessage?.(e)}else throw await o.body?.cancel(),new uz(-1,`Unexpected content type: ${l}`)}else await o.body?.cancel()}catch(e){throw this.onerror?.(e),e}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{let e=await this._commonHeaders(),t={...this._requestInit,method:`DELETE`,headers:e,signal:this._abortController?.signal},n=await(this._fetch??fetch)(this._url,t);if(await n.body?.cancel(),!n.ok&&n.status!==405)throw new uz(n.status,`Failed to terminate session: ${n.statusText}`);this._sessionId=void 0}catch(e){throw this.onerror?.(e),e}}setProtocolVersion(e){this._protocolVersion=e}get protocolVersion(){return this._protocolVersion}async resumeStream(e,t){await this._startOrAuthSse({resumptionToken:e,onresumptiontoken:t?.onresumptiontoken})}};function fz(e){return!!e._zod}function pz(e,t){return fz(e)?yk(e,t):e.safeParse(t)}function mz(e){if(!e)return;let t;if(t=fz(e)?e._zod?.def?.shape:e.shape,t){if(typeof t==`function`)try{return t()}catch{return}return t}}function hz(e){if(fz(e)){let t=e._zod?.def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}}let t=e._def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}let n=e.value;if(n!==void 0)return n}function gz(e){return e===`completed`||e===`failed`||e===`cancelled`}function _z(e){let t=mz(e)?.method;if(!t)throw Error(`Schema is missing a method literal`);let n=hz(t);if(typeof n!=`string`)throw Error(`Schema method literal must be a string`);return n}function vz(e,t){let n=pz(e,t);if(!n.success)throw n.error;return n.data}var yz=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(YP,e=>{this._oncancel(e)}),this.setNotificationHandler(fF,e=>{this._onprogress(e)}),this.setRequestHandler(lF,e=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(xF,async(e,t)=>{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new rL(UP.InvalidParams,`Failed to retrieve task: Task not found`);return{...n}}),this.setRequestHandler(CF,async(e,t)=>{let n=async()=>{let r=e.params.taskId;if(this._taskMessageQueue){let e;for(;e=await this._taskMessageQueue.dequeue(r,t.sessionId);){if(e.type===`response`||e.type===`error`){let t=e.message,n=t.id,r=this._requestResolvers.get(n);if(r){if(this._requestResolvers.delete(n),e.type===`response`)r(t);else{let e=t;r(new rL(e.error.code,e.error.message,e.error.data))}}else{let t=e.type===`response`?`Response`:`Error`;this._onerror(Error(`${t} handler missing for request ${n}`))}continue}await this._transport?.send(e.message,{relatedRequestId:t.requestId})}}let i=await this._taskStore.getTask(r,t.sessionId);if(!i)throw new rL(UP.InvalidParams,`Task not found: ${r}`);if(!gz(i.status))return await this._waitForTaskUpdate(r,t.signal),await n();if(gz(i.status)){let e=await this._taskStore.getTaskResult(r,t.sessionId);return this._clearTaskQueue(r),{...e,_meta:{...e._meta,[SP]:{taskId:r}}}}return await n()};return await n()}),this.setRequestHandler(wF,async(e,t)=>{try{let{tasks:n,nextCursor:r}=await this._taskStore.listTasks(e.params?.cursor,t.sessionId);return{tasks:n,nextCursor:r,_meta:{}}}catch(e){throw new rL(UP.InvalidParams,`Failed to list tasks: ${e instanceof Error?e.message:String(e)}`)}}),this.setRequestHandler(EF,async(e,t)=>{try{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new rL(UP.InvalidParams,`Task not found: ${e.params.taskId}`);if(gz(n.status))throw new rL(UP.InvalidParams,`Cannot cancel task in terminal status: ${n.status}`);await this._taskStore.updateTaskStatus(e.params.taskId,`cancelled`,`Client cancelled task execution.`,t.sessionId),this._clearTaskQueue(e.params.taskId);let r=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!r)throw new rL(UP.InvalidParams,`Task not found after cancellation: ${e.params.taskId}`);return{_meta:{},...r}}catch(e){throw e instanceof rL?e:new rL(UP.InvalidRequest,`Failed to cancel task: ${e instanceof Error?e.message:String(e)}`)}}))}async _oncancel(e){e.params.requestId&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,n,r,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),rL.fromError(UP.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw Error(`Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.`);this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{t?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=e=>{n?.(e),this._onerror(e)};let r=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{r?.(e,t),HP(e)||GP(e)?this._onresponse(e):RP(e)?this._onrequest(e,t):BP(e)?this._onnotification(e):this._onerror(Error(`Unknown message type: ${JSON.stringify(e)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let e of this._timeoutInfo.values())clearTimeout(e.timeoutId);this._timeoutInfo.clear();for(let e of this._requestHandlerAbortControllers.values())e.abort();this._requestHandlerAbortControllers.clear();let t=rL.fromError(UP.ConnectionClosed,`Connection closed`);this._transport=void 0,this.onclose?.();for(let n of e.values())n(t)}_onerror(e){this.onerror?.(e)}_onnotification(e){let t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;t!==void 0&&Promise.resolve().then(()=>t(e)).catch(e=>this._onerror(Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,r=this._transport,i=e.params?._meta?.[SP]?.taskId;if(n===void 0){let t={jsonrpc:`2.0`,id:e.id,error:{code:UP.MethodNotFound,message:`Method not found`}};i&&this._taskMessageQueue?this._enqueueTaskMessage(i,{type:`error`,message:t,timestamp:Date.now()},r?.sessionId).catch(e=>this._onerror(Error(`Failed to enqueue error response: ${e}`))):r?.send(t).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)));return}let a=new AbortController;this._requestHandlerAbortControllers.set(e.id,a);let o=jP(e.params)?e.params.task:void 0,s=this._taskStore?this.requestTaskStore(e,r?.sessionId):void 0,c={signal:a.signal,sessionId:r?.sessionId,_meta:e.params?._meta,sendNotification:async t=>{if(a.signal.aborted)return;let n={relatedRequestId:e.id};i&&(n.relatedTask={taskId:i}),await this.notification(t,n)},sendRequest:async(t,n,r)=>{if(a.signal.aborted)throw new rL(UP.ConnectionClosed,`Request was cancelled`);let o={...r,relatedRequestId:e.id};i&&!o.relatedTask&&(o.relatedTask={taskId:i});let c=o.relatedTask?.taskId??i;return c&&s&&await s.updateTaskStatus(c,`input_required`),await this.request(t,n,o)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:i,taskStore:s,taskRequestedTtl:o?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};Promise.resolve().then(()=>{o&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,c)).then(async t=>{if(a.signal.aborted)return;let n={result:t,jsonrpc:`2.0`,id:e.id};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`response`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)},async t=>{if(a.signal.aborted)return;let n={jsonrpc:`2.0`,id:e.id,error:{code:Number.isSafeInteger(t.code)?t.code:UP.InternalError,message:t.message??`Internal error`,...t.data!==void 0&&{data:t.data}}};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`error`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===a&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,r=Number(t),i=this._progressHandlers.get(r);if(!i){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(r),o=this._timeoutInfo.get(r);if(o&&a&&o.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(e){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),a(e);return}i(n)}_onresponse(e){let t=Number(e.id),n=this._requestResolvers.get(t);if(n){this._requestResolvers.delete(t),HP(e)?n(e):n(new rL(e.error.code,e.error.message,e.error.data));return}let r=this._responseHandlers.get(t);if(r===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t);let i=!1;if(HP(e)&&e.result&&typeof e.result==`object`){let n=e.result;if(n.task&&typeof n.task==`object`){let e=n.task;typeof e.taskId==`string`&&(i=!0,this._taskProgressTokens.set(e.taskId,t))}}i||this._progressHandlers.delete(t),HP(e)?r(e):r(rL.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,t,n){let{task:r}=n??{};if(!r){try{yield{type:`result`,result:await this.request(e,t,n)}}catch(e){yield{type:`error`,error:e instanceof rL?e:new rL(UP.InternalError,String(e))}}return}let i;try{let r=await this.request(e,vF,n);if(r.task)i=r.task.taskId,yield{type:`taskCreated`,task:r.task};else throw new rL(UP.InternalError,`Task creation did not return a task`);for(;;){let e=await this.getTask({taskId:i},n);if(yield{type:`taskStatus`,task:e},gz(e.status)){e.status===`completed`?yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)}:e.status===`failed`?yield{type:`error`,error:new rL(UP.InternalError,`Task ${i} failed`)}:e.status===`cancelled`&&(yield{type:`error`,error:new rL(UP.InternalError,`Task ${i} was cancelled`)});return}if(e.status===`input_required`){yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)};return}let r=e.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(e=>setTimeout(e,r)),n?.signal?.throwIfAborted()}}catch(e){yield{type:`error`,error:e instanceof rL?e:new rL(UP.InternalError,String(e))}}}request(e,t,n){let{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a,task:o,relatedTask:s}=n??{};return new Promise((c,l)=>{let u=e=>{l(e)};if(!this._transport){u(Error(`Not connected`));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),o&&this.assertTaskCapability(e.method)}catch(e){u(e);return}n?.signal?.throwIfAborted();let d=this._requestMessageId++,f={...e,jsonrpc:`2.0`,id:d};n?.onprogress&&(this._progressHandlers.set(d,n.onprogress),f.params={...e.params,_meta:{...e.params?._meta||{},progressToken:d}}),o&&(f.params={...f.params,task:o}),s&&(f.params={...f.params,_meta:{...f.params?._meta||{},[SP]:s}});let p=e=>{this._responseHandlers.delete(d),this._progressHandlers.delete(d),this._cleanupTimeout(d),this._transport?.send({jsonrpc:`2.0`,method:`notifications/cancelled`,params:{requestId:d,reason:String(e)}},{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))),l(e instanceof rL?e:new rL(UP.RequestTimeout,String(e)))};this._responseHandlers.set(d,e=>{if(!n?.signal?.aborted){if(e instanceof Error)return l(e);try{let n=pz(t,e.result);n.success?c(n.data):l(n.error)}catch(e){l(e)}}}),n?.signal?.addEventListener(`abort`,()=>{p(n?.signal?.reason)});let m=n?.timeout??6e4;this._setupTimeout(d,m,n?.maxTotalTimeout,()=>p(rL.fromError(UP.RequestTimeout,`Request timed out`,{timeout:m})),n?.resetTimeoutOnProgress??!1);let h=s?.taskId;h?(this._requestResolvers.set(d,e=>{let t=this._responseHandlers.get(d);t?t(e):this._onerror(Error(`Response handler missing for side-channeled request ${d}`))}),this._enqueueTaskMessage(h,{type:`request`,message:f,timestamp:Date.now()}).catch(e=>{this._cleanupTimeout(d),l(e)})):this._transport.send(f,{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>{this._cleanupTimeout(d),l(e)})})}async getTask(e,t){return this.request({method:`tasks/get`,params:e},SF,t)}async getTaskResult(e,t,n){return this.request({method:`tasks/result`,params:e},t,n)}async listTasks(e,t){return this.request({method:`tasks/list`,params:e},TF,t)}async cancelTask(e,t){return this.request({method:`tasks/cancel`,params:e},DF,t)}async notification(e,t){if(!this._transport)throw Error(`Not connected`);this.assertNotificationCapability(e.method);let n=t?.relatedTask?.taskId;if(n){let r={...e,jsonrpc:`2.0`,params:{...e.params,_meta:{...e.params?._meta||{},[SP]:t.relatedTask}}};await this._enqueueTaskMessage(n,{type:`notification`,message:r,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!t?.relatedRequestId&&!t?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let n={...e,jsonrpc:`2.0`};t?.relatedTask&&(n={...n,params:{...n.params,_meta:{...n.params?._meta||{},[SP]:t.relatedTask}}}),this._transport?.send(n,t).catch(e=>this._onerror(e))});return}let r={...e,jsonrpc:`2.0`};t?.relatedTask&&(r={...r,params:{...r.params,_meta:{...r.params?._meta||{},[SP]:t.relatedTask}}}),await this._transport.send(r,t)}setRequestHandler(e,t){let n=_z(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(n,r)=>{let i=vz(e,n);return Promise.resolve(t(i,r))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){let n=_z(e);this._notificationHandlers.set(n,n=>{let r=vz(e,n);return Promise.resolve(t(r))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let t=this._taskProgressTokens.get(e);t!==void 0&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,n){if(!this._taskStore||!this._taskMessageQueue)throw Error(`Cannot enqueue task message: taskStore and taskMessageQueue are not configured`);let r=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,n,r)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,t);for(let t of n)if(t.type===`request`&&RP(t.message)){let n=t.message.id,r=this._requestResolvers.get(n);r?(r(new rL(UP.InternalError,`Task cancelled or completed`)),this._requestResolvers.delete(n)):this._onerror(Error(`Resolver missing for request ${n} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){let n=this._options?.defaultTaskPollInterval??1e3;try{let t=await this._taskStore?.getTask(e);t?.pollInterval&&(n=t.pollInterval)}catch{}return new Promise((e,r)=>{if(t.aborted){r(new rL(UP.InvalidRequest,`Request cancelled`));return}let i=setTimeout(e,n);t.addEventListener(`abort`,()=>{clearTimeout(i),r(new rL(UP.InvalidRequest,`Request cancelled`))},{once:!0})})}requestTaskStore(e,t){let n=this._taskStore;if(!n)throw Error(`No task store configured`);return{createTask:async r=>{if(!e)throw Error(`No request provided`);return await n.createTask(r,e.id,{method:e.method,params:e.params},t)},getTask:async e=>{let r=await n.getTask(e,t);if(!r)throw new rL(UP.InvalidParams,`Failed to retrieve task: Task not found`);return r},storeTaskResult:async(e,r,i)=>{await n.storeTaskResult(e,r,i,t);let a=await n.getTask(e,t);if(a){let t=bF.parse({method:`notifications/tasks/status`,params:a});await this.notification(t),gz(a.status)&&this._cleanupTaskProgressHandler(e)}},getTaskResult:e=>n.getTaskResult(e,t),updateTaskStatus:async(e,r,i)=>{let a=await n.getTask(e,t);if(!a)throw new rL(UP.InvalidParams,`Task "${e}" not found - it may have been cleaned up`);if(gz(a.status))throw new rL(UP.InvalidParams,`Cannot update task "${e}" from terminal status "${a.status}" to "${r}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(e,r,i,t);let o=await n.getTask(e,t);if(o){let t=bF.parse({method:`notifications/tasks/status`,params:o});await this.notification(t),gz(o.status)&&this._cleanupTaskProgressHandler(e)}},listTasks:e=>n.listTasks(e,t)}}};function bz(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function xz(e,t){let n={...e};for(let e in t){let r=e,i=t[r];if(i===void 0)continue;let a=n[r];n[r]=bz(a)&&bz(i)?{...a,...i}:i}return n}var Sz=s((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;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=n;var r=class extends t{constructor(e){super(),this._items=typeof e==`string`?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===``||e===`""`}get str(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};e._Code=r,e.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}e._=i;var a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}e.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}e.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}e.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}e.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}e.safeStringify=p;function m(t){return typeof t==`string`&&e.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}e.getProperty=m;function h(t){if(typeof t==`string`&&e.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(e){return new r(e.toString())}e.regexpCode=g})),Cz=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;var t=Sz(),n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r||(e.UsedValueState=r={})),e.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var i=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};e.Scope=i;var a=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};e.ValueScopeName=a;var o=(0,t._)`\n`;e.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?e.varKinds.var:e.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),wz=s((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;var t=Sz(),n=Cz(),r=Sz();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}});var i=Cz();Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return i.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(`+`)};var a=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},o=class extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let r=e?n.varKinds.var:this.varKind,i=this.rhs===void 0?``:` = ${this.rhs}`;return`${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&=k(this.rhs,e,t),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},s=class extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof t.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=k(this.rhs,e,n),this}get names(){return O(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends s{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},l=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},u=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},d=class extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},f=class extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=k(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},p=class extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),``)}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let i=n[r];i.optimizeNames(e,t)||(A(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>D(e,t.names),{})}},m=class extends p{render(e){return`{`+e._n+super.render(e)+`}`+e._n}},h=class extends p{},g=class extends m{};g.kind=`else`;var _=class e extends m{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+=`else `+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let e=n.optimizeNodes();n=this.else=Array.isArray(e)?new g(e):e}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(j(t),n instanceof e?[n]:n.nodes);if(t!==!1&&this.nodes.length)return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=k(this.condition,e,t),this}get names(){let e=super.names;return O(e,this.condition),this.else&&D(e,this.else.names),e}};_.kind=`if`;var v=class extends m{};v.kind=`for`;var y=class extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=k(this.iteration,e,t),this}get names(){return D(super.names,this.iteration.names)}},b=class extends v{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?n.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return`for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){return O(O(super.names,this.from),this.to)}},x=class extends v{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=k(this.iterable,e,t),this}get names(){return D(super.names,this.iterable.names)}},S=class extends m{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?`async `:``}function ${this.name}(${this.args})`+super.render(e)}};S.kind=`func`;var C=class extends p{render(e){return`return `+super.render(e)}};C.kind=`return`;var w=class extends m{render(e){let t=`try`+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)==null||e.optimizeNodes(),(t=this.finally)==null||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)==null||n.optimizeNames(e,t),(r=this.finally)==null||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&D(e,this.catch.names),this.finally&&D(e,this.finally.names),e}},T=class extends m{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};T.kind=`catch`;var E=class extends m{render(e){return`finally`+super.render(e)}};E.kind=`finally`,e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
|
|
219
|
-
`:``},this._extScope=e,this._scope=new n.Scope({parent:e}),this._nodes=[new h]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,r){let i=this._scope.toName(t);return n!==void 0&&r&&(this._constants[i.str]=n),this._leafNode(new o(e,i,n)),i}const(e,t,r){return this._def(n.varKinds.const,e,t,r)}let(e,t,r){return this._def(n.varKinds.let,e,t,r)}var(e,t,r){return this._def(n.varKinds.var,e,t,r)}assign(e,t,n){return this._leafNode(new s(e,t,n))}add(t,n){return this._leafNode(new c(t,e.operators.ADD,n))}code(e){return typeof e==`function`?e():e!==t.nil&&this._leafNode(new f(e)),this}object(...e){let n=[`{`];for(let[r,i]of e)n.length>1&&n.push(`,`),n.push(r),(r!==i||this.opts.es5)&&(n.push(`:`),(0,t.addCodeArg)(n,i));return n.push(`}`),new t._Code(n)}if(e,t,n){if(this._blockNode(new _(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw Error(`CodeGen: "else" body without "then" body`);return this}elseIf(e){return this._elseNode(new _(e))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(_,g)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new y(e),t)}forRange(e,t,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.let){let o=this._scope.toName(e);return this._for(new b(a,o,t,r),()=>i(o))}forOf(e,r,i,a=n.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let e=r instanceof t.Name?r:this.var(`_arr`,r);return this.forRange(`_i`,0,(0,t._)`${e}.length`,n=>{this.var(o,(0,t._)`${e}[${n}]`),i(o)})}return this._for(new x(`of`,a,o,r),()=>i(o))}forIn(e,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,t._)`Object.keys(${r})`,i);let o=this._scope.toName(e);return this._for(new x(`in`,a,o,r),()=>i(o))}endFor(){return this._endBlockNode(v)}label(e){return this._leafNode(new l(e))}break(e){return this._leafNode(new u(e))}return(e){let t=new C;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw Error(`CodeGen: "return" should have one node`);return this._endBlockNode(C)}try(e,t,n){if(!t&&!n)throw Error(`CodeGen: "try" without "catch" and "finally"`);let r=new w;if(this._blockNode(r),this.code(e),t){let e=this.name(`e`);this._currNode=r.catch=new T(e),t(e)}return n&&(this._currNode=r.finally=new E,this.code(n)),this._endBlockNode(T,E)}throw(e){return this._leafNode(new d(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw Error(`CodeGen: not in self-balancing block`);let n=this._nodes.length-t;if(n<0||e!==void 0&&n!==e)throw Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,n=t.nil,r,i){return this._blockNode(new S(e,n,r)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(S)}optimize(e=1){for(;e-->0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){let n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof _))throw Error(`CodeGen: "else" without "if"`);return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e}};function D(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function O(e,n){return n instanceof t._CodeOrName?D(e,n.names):e}function k(e,n,r){if(e instanceof t.Name)return i(e);if(!a(e))return e;return new t._Code(e._items.reduce((e,n)=>(n instanceof t.Name&&(n=i(n)),n instanceof t._Code?e.push(...n._items):e.push(n),e),[]));function i(e){let t=r[e.str];return t===void 0||n[e.str]!==1?e:(delete n[e.str],t)}function a(e){return e instanceof t._Code&&e._items.some(e=>e instanceof t.Name&&n[e.str]===1&&r[e.str]!==void 0)}}function A(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function j(e){return typeof e==`boolean`||typeof e==`number`||e===null?!e:(0,t._)`!${L(e)}`}e.not=j;var M=I(e.operators.AND);function N(...e){return e.reduce(M)}e.and=N;var P=I(e.operators.OR);function F(...e){return e.reduce(P)}e.or=F;function I(e){return(n,r)=>n===t.nil?r:r===t.nil?n:(0,t._)`${L(n)} ${e} ${L(r)}`}function L(e){return e instanceof t.Name?e:(0,t._)`(${e})`}})),Tz=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.checkStrictMode=e.getErrorPath=e.Type=e.useFunc=e.setEvaluated=e.evaluatedPropsToName=e.mergeEvaluated=e.eachItem=e.unescapeJsonPointer=e.escapeJsonPointer=e.escapeFragment=e.unescapeFragment=e.schemaRefOrVal=e.schemaHasRulesButRef=e.schemaHasRules=e.checkUnknownRules=e.alwaysValidSchema=e.toHash=void 0;var t=wz(),n=Sz();function r(e){let t={};for(let n of e)t[n]=!0;return t}e.toHash=r;function i(e,t){return typeof t==`boolean`?t:Object.keys(t).length===0||(a(e,t),!o(t,e.self.RULES.all))}e.alwaysValidSchema=i;function a(e,t=e.schema){let{opts:n,self:r}=e;if(!n.strictSchema||typeof t==`boolean`)return;let i=r.RULES.keywords;for(let n in t)i[n]||x(e,`unknown keyword: "${n}"`)}e.checkUnknownRules=a;function o(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(t[n])return!0;return!1}e.schemaHasRules=o;function s(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(n!==`$ref`&&t.all[n])return!0;return!1}e.schemaHasRulesButRef=s;function c({topSchemaRef:e,schemaPath:n},r,i,a){if(!a){if(typeof r==`number`||typeof r==`boolean`)return r;if(typeof r==`string`)return(0,t._)`${r}`}return(0,t._)`${e}${n}${(0,t.getProperty)(i)}`}e.schemaRefOrVal=c;function l(e){return f(decodeURIComponent(e))}e.unescapeFragment=l;function u(e){return encodeURIComponent(d(e))}e.escapeFragment=u;function d(e){return typeof e==`number`?`${e}`:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}e.escapeJsonPointer=d;function f(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}e.unescapeJsonPointer=f;function p(e,t){if(Array.isArray(e))for(let n of e)t(n);else t(e)}e.eachItem=p;function m({mergeNames:e,mergeToName:n,mergeValues:r,resultToName:i}){return(a,o,s,c)=>{let l=s===void 0?o:s instanceof t.Name?(o instanceof t.Name?e(a,o,s):n(a,o,s),s):o instanceof t.Name?(n(a,s,o),o):r(o,s);return c===t.Name&&!(l instanceof t.Name)?i(a,l):l}}e.mergeEvaluated={props:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>{e.if((0,t._)`${n} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,t._)`${r} || {}`).code((0,t._)`Object.assign(${r}, ${n})`))}),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>{n===!0?e.assign(r,!0):(e.assign(r,(0,t._)`${r} || {}`),g(e,r,n))}),mergeValues:(e,t)=>e===!0||{...e,...t},resultToName:h}),items:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>e.assign(r,(0,t._)`${n} === true ? true : ${r} > ${n} ? ${r} : ${n}`)),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>e.assign(r,n===!0||(0,t._)`${r} > ${n} ? ${r} : ${n}`)),mergeValues:(e,t)=>e===!0||Math.max(e,t),resultToName:(e,t)=>e.var(`items`,t)})};function h(e,n){if(n===!0)return e.var(`props`,!0);let r=e.var(`props`,(0,t._)`{}`);return n!==void 0&&g(e,r,n),r}e.evaluatedPropsToName=h;function g(e,n,r){Object.keys(r).forEach(r=>e.assign((0,t._)`${n}${(0,t.getProperty)(r)}`,!0))}e.setEvaluated=g;var _={};function v(e,t){return e.scopeValue(`func`,{ref:t,code:_[t.code]||(_[t.code]=new n._Code(t.code))})}e.useFunc=v;var y;(function(e){e[e.Num=0]=`Num`,e[e.Str=1]=`Str`})(y||(e.Type=y={}));function b(e,n,r){if(e instanceof t.Name){let i=n===y.Num;return r?i?(0,t._)`"[" + ${e} + "]"`:(0,t._)`"['" + ${e} + "']"`:i?(0,t._)`"/" + ${e}`:(0,t._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,t.getProperty)(e).toString():`/`+d(e)}e.getErrorPath=b;function x(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,n===!0)throw Error(t);e.self.logger.warn(t)}}e.checkStrictMode=x})),Ez=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=wz();e.default={data:new t.Name(`data`),valCxt:new t.Name(`valCxt`),instancePath:new t.Name(`instancePath`),parentData:new t.Name(`parentData`),parentDataProperty:new t.Name(`parentDataProperty`),rootData:new t.Name(`rootData`),dynamicAnchors:new t.Name(`dynamicAnchors`),vErrors:new t.Name(`vErrors`),errors:new t.Name(`errors`),this:new t.Name(`this`),self:new t.Name(`self`),scope:new t.Name(`scope`),json:new t.Name(`json`),jsonPos:new t.Name(`jsonPos`),jsonLen:new t.Name(`jsonLen`),jsonPart:new t.Name(`jsonPart`)}})),Dz=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;var t=wz(),n=Tz(),r=Ez();e.keywordError={message:({keyword:e})=>(0,t.str)`must pass "${e}" keyword validation`},e.keyword$DataError={message:({keyword:e,schemaType:n})=>n?(0,t.str)`"${e}" keyword must be ${n} ($data)`:(0,t.str)`"${e}" keyword is invalid ($data)`};function i(n,r=e.keywordError,i,a){let{it:o}=n,{gen:s,compositeRule:u,allErrors:f}=o,p=d(n,r,i);a??(u||f)?c(s,p):l(o,(0,t._)`[${p}]`)}e.reportError=i;function a(t,n=e.keywordError,i){let{it:a}=t,{gen:o,compositeRule:s,allErrors:u}=a;c(o,d(t,n,i)),s||u||l(a,r.default.vErrors)}e.reportExtraError=a;function o(e,n){e.assign(r.default.errors,n),e.if((0,t._)`${r.default.vErrors} !== null`,()=>e.if(n,()=>e.assign((0,t._)`${r.default.vErrors}.length`,n),()=>e.assign(r.default.vErrors,null)))}e.resetErrorsCount=o;function s({gen:e,keyword:n,schemaValue:i,data:a,errsCount:o,it:s}){if(o===void 0)throw Error(`ajv implementation error`);let c=e.name(`err`);e.forRange(`i`,o,r.default.errors,o=>{e.const(c,(0,t._)`${r.default.vErrors}[${o}]`),e.if((0,t._)`${c}.instancePath === undefined`,()=>e.assign((0,t._)`${c}.instancePath`,(0,t.strConcat)(r.default.instancePath,s.errorPath))),e.assign((0,t._)`${c}.schemaPath`,(0,t.str)`${s.errSchemaPath}/${n}`),s.opts.verbose&&(e.assign((0,t._)`${c}.schema`,i),e.assign((0,t._)`${c}.data`,a))})}e.extendErrors=s;function c(e,n){let i=e.const(`err`,n);e.if((0,t._)`${r.default.vErrors} === null`,()=>e.assign(r.default.vErrors,(0,t._)`[${i}]`),(0,t._)`${r.default.vErrors}.push(${i})`),e.code((0,t._)`${r.default.errors}++`)}function l(e,n){let{gen:r,validateName:i,schemaEnv:a}=e;a.$async?r.throw((0,t._)`new ${e.ValidationError}(${n})`):(r.assign((0,t._)`${i}.errors`,n),r.return(!1))}var u={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 d(e,n,r){let{createErrors:i}=e.it;return i===!1?(0,t._)`{}`:f(e,n,r)}function f(e,t,n={}){let{gen:r,it:i}=e,a=[p(i,n),m(e,n)];return h(e,t,a),r.object(...a)}function p({errorPath:e},{instancePath:i}){let a=i?(0,t.str)`${e}${(0,n.getErrorPath)(i,n.Type.Str)}`:e;return[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,a)]}function m({keyword:e,it:{errSchemaPath:r}},{schemaPath:i,parentSchema:a}){let o=a?r:(0,t.str)`${r}/${e}`;return i&&(o=(0,t.str)`${o}${(0,n.getErrorPath)(i,n.Type.Str)}`),[u.schemaPath,o]}function h(e,{params:n,message:i},a){let{keyword:o,data:s,schemaValue:c,it:l}=e,{opts:d,propertyName:f,topSchemaRef:p,schemaPath:m}=l;a.push([u.keyword,o],[u.params,typeof n==`function`?n(e):n||(0,t._)`{}`]),d.messages&&a.push([u.message,typeof i==`function`?i(e):i]),d.verbose&&a.push([u.schema,c],[u.parentSchema,(0,t._)`${p}${m}`],[r.default.data,s]),f&&a.push([u.propertyName,f])}})),Oz=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;var t=Dz(),n=wz(),r=Ez(),i={message:`boolean schema is false`};function a(e){let{gen:t,schema:i,validateName:a}=e;i===!1?s(e,!1):typeof i==`object`&&i.$async===!0?t.return(r.default.data):(t.assign((0,n._)`${a}.errors`,null),t.return(!0))}e.topBoolOrEmptySchema=a;function o(e,t){let{gen:n,schema:r}=e;r===!1?(n.var(t,!1),s(e)):n.var(t,!0)}e.boolOrEmptySchema=o;function s(e,n){let{gen:r,data:a}=e,o={gen:r,keyword:`false schema`,data:a,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,t.reportError)(o,i,void 0,n)}})),kz=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getRules=e.isJSONType=void 0;var t=new Set([`string`,`number`,`integer`,`boolean`,`null`,`object`,`array`]);function n(e){return typeof e==`string`&&t.has(e)}e.isJSONType=n;function r(){let 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:{}}}e.getRules=r})),Az=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.shouldUseRule=e.shouldUseGroup=e.schemaHasRulesForType=void 0;function t({schema:e,self:t},r){let i=t.RULES.types[r];return i&&i!==!0&&n(e,i)}e.schemaHasRulesForType=t;function n(e,t){return t.rules.some(t=>r(e,t))}e.shouldUseGroup=n;function r(e,t){return e[t.keyword]!==void 0||t.definition.implements?.some(t=>e[t]!==void 0)}e.shouldUseRule=r})),jz=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.reportTypeError=e.checkDataTypes=e.checkDataType=e.coerceAndCheckDataType=e.getJSONTypes=e.getSchemaTypes=e.DataType=void 0;var t=kz(),n=Az(),r=Dz(),i=wz(),a=Tz(),o;(function(e){e[e.Correct=0]=`Correct`,e[e.Wrong=1]=`Wrong`})(o||(e.DataType=o={}));function s(e){let t=c(e.type);if(t.includes(`null`)){if(e.nullable===!1)throw Error(`type: null contradicts nullable: false`)}else{if(!t.length&&e.nullable!==void 0)throw Error(`"nullable" cannot be used without "type"`);e.nullable===!0&&t.push(`null`)}return t}e.getSchemaTypes=s;function c(e){let n=Array.isArray(e)?e:e?[e]:[];if(n.every(t.isJSONType))return n;throw Error(`type must be JSONType or JSONType[]: `+n.join(`,`))}e.getJSONTypes=c;function l(e,t){let{gen:r,data:i,opts:a}=e,s=d(t,a.coerceTypes),c=t.length>0&&!(s.length===0&&t.length===1&&(0,n.schemaHasRulesForType)(e,t[0]));if(c){let n=h(t,i,a.strictNumbers,o.Wrong);r.if(n,()=>{s.length?f(e,t,s):_(e)})}return c}e.coerceAndCheckDataType=l;var u=new Set([`string`,`number`,`integer`,`boolean`,`null`]);function d(e,t){return t?e.filter(e=>u.has(e)||t===`array`&&e===`array`):[]}function f(e,t,n){let{gen:r,data:a,opts:o}=e,s=r.let(`dataType`,(0,i._)`typeof ${a}`),c=r.let(`coerced`,(0,i._)`undefined`);o.coerceTypes===`array`&&r.if((0,i._)`${s} == 'object' && Array.isArray(${a}) && ${a}.length == 1`,()=>r.assign(a,(0,i._)`${a}[0]`).assign(s,(0,i._)`typeof ${a}`).if(h(t,a,o.strictNumbers),()=>r.assign(c,a))),r.if((0,i._)`${c} !== undefined`);for(let e of n)(u.has(e)||e===`array`&&o.coerceTypes===`array`)&&l(e);r.else(),_(e),r.endIf(),r.if((0,i._)`${c} !== undefined`,()=>{r.assign(a,c),p(e,c)});function l(e){switch(e){case`string`:r.elseIf((0,i._)`${s} == "number" || ${s} == "boolean"`).assign(c,(0,i._)`"" + ${a}`).elseIf((0,i._)`${a} === null`).assign(c,(0,i._)`""`);return;case`number`:r.elseIf((0,i._)`${s} == "boolean" || ${a} === null
|
|
218
|
+
`&&r++}}return[t,n]}var hL=class extends Event{constructor(e,t){super(e),this.code=t?.code??void 0,this.message=t?.message??void 0}[Symbol.for(`nodejs.util.inspect.custom`)](e,t,n){return n(vL(this),t)}[Symbol.for(`Deno.customInspect`)](e,t){return e(vL(this),t)}};function gL(e){let t=globalThis.DOMException;return typeof t==`function`?new t(e,`SyntaxError`):SyntaxError(e)}function _L(e){return e instanceof Error?`errors`in e&&Array.isArray(e.errors)?e.errors.map(_L).join(`, `):`cause`in e&&e.cause instanceof Error?`${e}: ${_L(e.cause)}`:e.message:`${e}`}function vL(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var yL=e=>{throw TypeError(e)},bL=(e,t,n)=>t.has(e)||yL(`Cannot `+n),xL=(e,t,n)=>(bL(e,t,`read from private field`),n?n.call(e):t.get(e)),SL=(e,t,n)=>t.has(e)?yL(`Cannot add the same private member more than once`):t instanceof WeakSet?t.add(e):t.set(e,n),CL=(e,t,n,r)=>(bL(e,t,`write to private field`),t.set(e,n),n),wL=(e,t,n)=>(bL(e,t,`access private method`),n),TL,EL,DL,OL,kL,AL,jL,ML,NL,PL,FL,IL,LL,RL,zL,BL,VL,HL,UL,WL,GL,KL,qL,JL=class extends EventTarget{constructor(e,t){super(),SL(this,RL),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,SL(this,TL),SL(this,EL),SL(this,DL),SL(this,OL),SL(this,kL),SL(this,AL),SL(this,jL),SL(this,ML,null),SL(this,NL),SL(this,PL),SL(this,FL,null),SL(this,IL,null),SL(this,LL,null),SL(this,BL,async e=>{var t;xL(this,PL).reset();let{body:n,redirected:r,status:i,headers:a}=e;if(i===204){wL(this,RL,GL).call(this,`Server sent HTTP 204, not reconnecting`,204),this.close();return}if(r?CL(this,DL,new URL(e.url)):CL(this,DL,void 0),i!==200){wL(this,RL,GL).call(this,`Non-200 status code (${i})`,i);return}if(!(a.get(`content-type`)||``).startsWith(`text/event-stream`)){wL(this,RL,GL).call(this,`Invalid content type, expected "text/event-stream"`,i);return}if(xL(this,TL)===this.CLOSED)return;CL(this,TL,this.OPEN);let o=new Event(`open`);if((t=xL(this,LL))==null||t.call(this,o),this.dispatchEvent(o),typeof n!=`object`||!n||!(`getReader`in n)){wL(this,RL,GL).call(this,`Invalid response body, expected a web ReadableStream`,i),this.close();return}let s=new TextDecoder,c=n.getReader(),l=!0;do{let{done:e,value:t}=await c.read();t&&xL(this,PL).feed(s.decode(t,{stream:!e})),e&&(l=!1,xL(this,PL).reset(),wL(this,RL,KL).call(this))}while(l)}),SL(this,VL,e=>{CL(this,NL,void 0),e.name!==`AbortError`&&e.type!==`aborted`&&wL(this,RL,KL).call(this,_L(e))}),SL(this,UL,e=>{typeof e.id==`string`&&CL(this,ML,e.id);let t=new MessageEvent(e.event||`message`,{data:e.data,origin:xL(this,DL)?xL(this,DL).origin:xL(this,EL).origin,lastEventId:e.id||``});xL(this,IL)&&(!e.event||e.event===`message`)&&xL(this,IL).call(this,t),this.dispatchEvent(t)}),SL(this,WL,e=>{CL(this,AL,e)}),SL(this,qL,()=>{CL(this,jL,void 0),xL(this,TL)===this.CONNECTING&&wL(this,RL,zL).call(this)});try{if(e instanceof URL)CL(this,EL,e);else if(typeof e==`string`)CL(this,EL,new URL(e,YL()));else throw Error(`Invalid URL`)}catch{throw gL(`An invalid or illegal string was specified`)}CL(this,PL,pL({onEvent:xL(this,UL),onRetry:xL(this,WL)})),CL(this,TL,this.CONNECTING),CL(this,AL,3e3),CL(this,kL,t?.fetch??globalThis.fetch),CL(this,OL,t?.withCredentials??!1),wL(this,RL,zL).call(this)}get readyState(){return xL(this,TL)}get url(){return xL(this,EL).href}get withCredentials(){return xL(this,OL)}get onerror(){return xL(this,FL)}set onerror(e){CL(this,FL,e)}get onmessage(){return xL(this,IL)}set onmessage(e){CL(this,IL,e)}get onopen(){return xL(this,LL)}set onopen(e){CL(this,LL,e)}addEventListener(e,t,n){let r=t;super.addEventListener(e,r,n)}removeEventListener(e,t,n){let r=t;super.removeEventListener(e,r,n)}close(){xL(this,jL)&&clearTimeout(xL(this,jL)),xL(this,TL)!==this.CLOSED&&(xL(this,NL)&&xL(this,NL).abort(),CL(this,TL,this.CLOSED),CL(this,NL,void 0))}};TL=new WeakMap,EL=new WeakMap,DL=new WeakMap,OL=new WeakMap,kL=new WeakMap,AL=new WeakMap,jL=new WeakMap,ML=new WeakMap,NL=new WeakMap,PL=new WeakMap,FL=new WeakMap,IL=new WeakMap,LL=new WeakMap,RL=new WeakSet,zL=function(){CL(this,TL,this.CONNECTING),CL(this,NL,new AbortController),xL(this,kL)(xL(this,EL),wL(this,RL,HL).call(this)).then(xL(this,BL)).catch(xL(this,VL))},BL=new WeakMap,VL=new WeakMap,HL=function(){let e={mode:`cors`,redirect:`follow`,headers:{Accept:`text/event-stream`,...xL(this,ML)?{"Last-Event-ID":xL(this,ML)}:void 0},cache:`no-store`,signal:xL(this,NL)?.signal};return`window`in globalThis&&(e.credentials=this.withCredentials?`include`:`same-origin`),e},UL=new WeakMap,WL=new WeakMap,GL=function(e,t){var n;xL(this,TL)!==this.CLOSED&&CL(this,TL,this.CLOSED);let r=new hL(`error`,{code:t,message:e});(n=xL(this,FL))==null||n.call(this,r),this.dispatchEvent(r)},KL=function(e,t){var n;if(xL(this,TL)===this.CLOSED)return;CL(this,TL,this.CONNECTING);let r=new hL(`error`,{code:t,message:e});(n=xL(this,FL))==null||n.call(this,r),this.dispatchEvent(r),CL(this,jL,setTimeout(xL(this,qL),xL(this,AL)))},qL=new WeakMap,JL.CONNECTING=0,JL.OPEN=1,JL.CLOSED=2;function YL(){let e=`document`in globalThis?globalThis.document:void 0;return e&&typeof e==`object`&&`baseURI`in e&&typeof e.baseURI==`string`?e.baseURI:void 0}function XL(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function ZL(e=fetch,t){return t?async(n,r)=>e(n,{...t,...r,headers:r?.headers?{...XL(t.headers),...XL(r.headers)}:t.headers}):e}var QL=globalThis.crypto;async function $L(e){return(await QL).getRandomValues(new Uint8Array(e))}async function eR(e){let t=``,n=await $L(e);for(let r=0;r<e;r++){let e=n[r]%66;t+=`abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~`[e]}return t}async function tR(e){return await eR(e)}async function nR(e){let t=await(await QL).subtle.digest(`SHA-256`,new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,`_`).replace(/\+/g,`-`).replace(/=/g,``)}async function rR(e){if(e||=43,e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;let t=await tR(e);return{code_verifier:t,code_challenge:await nR(t)}}var iR=uN().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:wP.custom,message:`URL must be parseable`,fatal:!0}),LO}).refine(e=>{let t=new URL(e);return t.protocol!==`javascript:`&&t.protocol!==`data:`&&t.protocol!==`vbscript:`},{message:`URL cannot use javascript:, data:, or vbscript: scheme`}),aR=HN({resource:X().url(),authorization_servers:Z(iR).optional(),jwks_uri:X().url().optional(),scopes_supported:Z(X()).optional(),bearer_methods_supported:Z(X()).optional(),resource_signing_alg_values_supported:Z(X()).optional(),resource_name:X().optional(),resource_documentation:X().optional(),resource_policy_uri:X().url().optional(),resource_tos_uri:X().url().optional(),tls_client_certificate_bound_access_tokens:jN().optional(),authorization_details_types_supported:Z(X()).optional(),dpop_signing_alg_values_supported:Z(X()).optional(),dpop_bound_access_tokens_required:jN().optional()}),oR=HN({issuer:X(),authorization_endpoint:iR,token_endpoint:iR,registration_endpoint:iR.optional(),scopes_supported:Z(X()).optional(),response_types_supported:Z(X()),response_modes_supported:Z(X()).optional(),grant_types_supported:Z(X()).optional(),token_endpoint_auth_methods_supported:Z(X()).optional(),token_endpoint_auth_signing_alg_values_supported:Z(X()).optional(),service_documentation:iR.optional(),revocation_endpoint:iR.optional(),revocation_endpoint_auth_methods_supported:Z(X()).optional(),revocation_endpoint_auth_signing_alg_values_supported:Z(X()).optional(),introspection_endpoint:X().optional(),introspection_endpoint_auth_methods_supported:Z(X()).optional(),introspection_endpoint_auth_signing_alg_values_supported:Z(X()).optional(),code_challenge_methods_supported:Z(X()).optional(),client_id_metadata_document_supported:jN().optional()}),sR=Q({...HN({issuer:X(),authorization_endpoint:iR,token_endpoint:iR,userinfo_endpoint:iR.optional(),jwks_uri:iR,registration_endpoint:iR.optional(),scopes_supported:Z(X()).optional(),response_types_supported:Z(X()),response_modes_supported:Z(X()).optional(),grant_types_supported:Z(X()).optional(),acr_values_supported:Z(X()).optional(),subject_types_supported:Z(X()),id_token_signing_alg_values_supported:Z(X()),id_token_encryption_alg_values_supported:Z(X()).optional(),id_token_encryption_enc_values_supported:Z(X()).optional(),userinfo_signing_alg_values_supported:Z(X()).optional(),userinfo_encryption_alg_values_supported:Z(X()).optional(),userinfo_encryption_enc_values_supported:Z(X()).optional(),request_object_signing_alg_values_supported:Z(X()).optional(),request_object_encryption_alg_values_supported:Z(X()).optional(),request_object_encryption_enc_values_supported:Z(X()).optional(),token_endpoint_auth_methods_supported:Z(X()).optional(),token_endpoint_auth_signing_alg_values_supported:Z(X()).optional(),display_values_supported:Z(X()).optional(),claim_types_supported:Z(X()).optional(),claims_supported:Z(X()).optional(),service_documentation:X().optional(),claims_locales_supported:Z(X()).optional(),ui_locales_supported:Z(X()).optional(),claims_parameter_supported:jN().optional(),request_parameter_supported:jN().optional(),request_uri_parameter_supported:jN().optional(),require_request_uri_registration:jN().optional(),op_policy_uri:iR.optional(),op_tos_uri:iR.optional(),client_id_metadata_document_supported:jN().optional()}).shape,...oR.pick({code_challenge_methods_supported:!0}).shape}),cR=Q({access_token:X(),id_token:X().optional(),token_type:X(),expires_in:TP().optional(),scope:X().optional(),refresh_token:X().optional()}).strip(),lR=Q({error:X(),error_description:X().optional(),error_uri:X().optional()}),uR=iR.optional().or($(``).transform(()=>void 0)),dR=Q({redirect_uris:Z(iR),token_endpoint_auth_method:X().optional(),grant_types:Z(X()).optional(),response_types:Z(X()).optional(),client_name:X().optional(),client_uri:iR.optional(),logo_uri:uR,scope:X().optional(),contacts:Z(X()).optional(),tos_uri:uR,policy_uri:X().optional(),jwks_uri:iR.optional(),jwks:FN().optional(),software_id:X().optional(),software_version:X().optional(),software_statement:X().optional()}).strip(),fR=Q({client_id:X(),client_secret:X().optional(),client_id_issued_at:DN().optional(),client_secret_expires_at:DN().optional()}).strip(),pR=dR.merge(fR);Q({error:X(),error_description:X().optional()}).strip(),Q({token:X(),token_type_hint:X().optional()}).strip();function mR(e){let t=typeof e==`string`?new URL(e):new URL(e.href);return t.hash=``,t}function hR({requestedResource:e,configuredResource:t}){let n=typeof e==`string`?new URL(e):new URL(e.href),r=typeof t==`string`?new URL(t):new URL(t.href);if(n.origin!==r.origin||n.pathname.length<r.pathname.length)return!1;let i=n.pathname.endsWith(`/`)?n.pathname:n.pathname+`/`,a=r.pathname.endsWith(`/`)?r.pathname:r.pathname+`/`;return i.startsWith(a)}var gR=class extends Error{constructor(e,t){super(e),this.errorUri=t,this.name=this.constructor.name}toResponseObject(){let e={error:this.errorCode,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}get errorCode(){return this.constructor.errorCode}},_R=class extends gR{};_R.errorCode=`invalid_request`;var vR=class extends gR{};vR.errorCode=`invalid_client`;var yR=class extends gR{};yR.errorCode=`invalid_grant`;var bR=class extends gR{};bR.errorCode=`unauthorized_client`;var xR=class extends gR{};xR.errorCode=`unsupported_grant_type`;var SR=class extends gR{};SR.errorCode=`invalid_scope`;var CR=class extends gR{};CR.errorCode=`access_denied`;var wR=class extends gR{};wR.errorCode=`server_error`;var TR=class extends gR{};TR.errorCode=`temporarily_unavailable`;var ER=class extends gR{};ER.errorCode=`unsupported_response_type`;var DR=class extends gR{};DR.errorCode=`unsupported_token_type`;var OR=class extends gR{};OR.errorCode=`invalid_token`;var kR=class extends gR{};kR.errorCode=`method_not_allowed`;var AR=class extends gR{};AR.errorCode=`too_many_requests`;var jR=class extends gR{};jR.errorCode=`invalid_client_metadata`;var MR=class extends gR{};MR.errorCode=`insufficient_scope`;var NR=class extends gR{};NR.errorCode=`invalid_target`;var PR={[_R.errorCode]:_R,[vR.errorCode]:vR,[yR.errorCode]:yR,[bR.errorCode]:bR,[xR.errorCode]:xR,[SR.errorCode]:SR,[CR.errorCode]:CR,[wR.errorCode]:wR,[TR.errorCode]:TR,[ER.errorCode]:ER,[DR.errorCode]:DR,[OR.errorCode]:OR,[kR.errorCode]:kR,[AR.errorCode]:AR,[jR.errorCode]:jR,[MR.errorCode]:MR,[NR.errorCode]:NR},FR=class extends Error{constructor(e){super(e??`Unauthorized`)}};function IR(e){return[`client_secret_basic`,`client_secret_post`,`none`].includes(e)}var LR=`code`,RR=`S256`;function zR(e,t){let n=e.client_secret!==void 0;return`token_endpoint_auth_method`in e&&e.token_endpoint_auth_method&&IR(e.token_endpoint_auth_method)&&(t.length===0||t.includes(e.token_endpoint_auth_method))?e.token_endpoint_auth_method:t.length===0?n?`client_secret_basic`:`none`:n&&t.includes(`client_secret_basic`)?`client_secret_basic`:n&&t.includes(`client_secret_post`)?`client_secret_post`:t.includes(`none`)?`none`:n?`client_secret_post`:`none`}function BR(e,t,n,r){let{client_id:i,client_secret:a}=t;switch(e){case`client_secret_basic`:VR(i,a,n);return;case`client_secret_post`:HR(i,a,r);return;case`none`:UR(i,r);return;default:throw Error(`Unsupported client authentication method: ${e}`)}}function VR(e,t,n){if(!t)throw Error(`client_secret_basic authentication requires a client_secret`);let r=btoa(`${e}:${t}`);n.set(`Authorization`,`Basic ${r}`)}function HR(e,t,n){n.set(`client_id`,e),t&&n.set(`client_secret`,t)}function UR(e,t){t.set(`client_id`,e)}async function WR(e){let t=e instanceof Response?e.status:void 0,n=e instanceof Response?await e.text():e;try{let{error:e,error_description:t,error_uri:r}=lR.parse(JSON.parse(n));return new(PR[e]||wR)(t||``,r)}catch(e){return new wR(`${t?`HTTP ${t}: `:``}Invalid OAuth error response: ${e}. Raw body: ${n}`)}}async function GR(e,t){try{return await KR(e,t)}catch(n){if(n instanceof vR||n instanceof bR)return await e.invalidateCredentials?.(`all`),await KR(e,t);if(n instanceof yR)return await e.invalidateCredentials?.(`tokens`),await KR(e,t);throw n}}async function KR(e,{serverUrl:t,authorizationCode:n,scope:r,resourceMetadataUrl:i,fetchFn:a}){let o=await e.discoveryState?.(),s,c,l,u=i;if(!u&&o?.resourceMetadataUrl&&(u=new URL(o.resourceMetadataUrl)),o?.authorizationServerUrl){if(c=o.authorizationServerUrl,s=o.resourceMetadata,l=o.authorizationServerMetadata??await iz(c,{fetchFn:a}),!s)try{s=await ZR(t,{resourceMetadataUrl:u},a)}catch{}(l!==o.authorizationServerMetadata||s!==o.resourceMetadata)&&await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:u?.toString(),resourceMetadata:s,authorizationServerMetadata:l})}else{let n=await az(t,{resourceMetadataUrl:u,fetchFn:a});c=n.authorizationServerUrl,l=n.authorizationServerMetadata,s=n.resourceMetadata,await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:u?.toString(),resourceMetadata:s,authorizationServerMetadata:l})}let d=await JR(t,e,s),f=r||s?.scopes_supported?.join(` `)||e.clientMetadata.scope,p=await Promise.resolve(e.clientInformation());if(!p){if(n!==void 0)throw Error(`Existing OAuth client information is required when exchanging an authorization code`);let t=l?.client_id_metadata_document_supported===!0,r=e.clientMetadataUrl;if(r&&!qR(r))throw new jR(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${r}`);if(t&&r)p={client_id:r},await e.saveClientInformation?.(p);else{if(!e.saveClientInformation)throw Error(`OAuth client information must be saveable for dynamic registration`);let t=await dz(c,{metadata:l,clientMetadata:e.clientMetadata,scope:f,fetchFn:a});await e.saveClientInformation(t),p=t}}let m=!e.redirectUrl;if(n!==void 0||m){let t=await uz(e,c,{metadata:l,resource:d,authorizationCode:n,fetchFn:a});return await e.saveTokens(t),`AUTHORIZED`}let h=await e.tokens();if(h?.refresh_token)try{let t=await lz(c,{metadata:l,clientInformation:p,refreshToken:h.refresh_token,resource:d,addClientAuthentication:e.addClientAuthentication,fetchFn:a});return await e.saveTokens(t),`AUTHORIZED`}catch(e){if(!(!(e instanceof gR)||e instanceof wR))throw e}let g=e.state?await e.state():void 0,{authorizationUrl:_,codeVerifier:v}=await oz(c,{metadata:l,clientInformation:p,state:g,redirectUrl:e.redirectUrl,scope:f,resource:d});return await e.saveCodeVerifier(v),await e.redirectToAuthorization(_),`REDIRECT`}function qR(e){if(!e)return!1;try{let t=new URL(e);return t.protocol===`https:`&&t.pathname!==`/`}catch{return!1}}async function JR(e,t,n){let r=mR(e);if(t.validateResourceURL)return await t.validateResourceURL(r,n?.resource);if(n){if(!hR({requestedResource:r,configuredResource:n.resource}))throw Error(`Protected resource ${n.resource} does not match expected ${r} (or origin)`);return new URL(n.resource)}}function YR(e){let t=e.headers.get(`WWW-Authenticate`);if(!t)return{};let[n,r]=t.split(` `);if(n.toLowerCase()!==`bearer`||!r)return{};let i=XR(e,`resource_metadata`)||void 0,a;if(i)try{a=new URL(i)}catch{}let o=XR(e,`scope`)||void 0,s=XR(e,`error`)||void 0;return{resourceMetadataUrl:a,scope:o,error:s}}function XR(e,t){let n=e.headers.get(`WWW-Authenticate`);if(!n)return null;let r=RegExp(`${t}=(?:"([^"]+)"|([^\\s,]+))`),i=n.match(r);return i?i[1]||i[2]:null}async function ZR(e,t,n=fetch){let r=await nz(e,`oauth-protected-resource`,n,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!r||r.status===404)throw await r?.body?.cancel(),Error(`Resource server does not implement OAuth 2.0 Protected Resource Metadata.`);if(!r.ok)throw await r.body?.cancel(),Error(`HTTP ${r.status} trying to load well-known OAuth protected resource metadata.`);return aR.parse(await r.json())}async function QR(e,t,n=fetch){try{return await n(e,{headers:t})}catch(r){if(r instanceof TypeError)return t?QR(e,void 0,n):void 0;throw r}}function $R(e,t=``,n={}){return t.endsWith(`/`)&&(t=t.slice(0,-1)),n.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}async function ez(e,t,n=fetch){return await QR(e,{"MCP-Protocol-Version":t},n)}function tz(e,t){return!e||e.status>=400&&e.status<500&&t!==`/`}async function nz(e,t,n,r){let i=new URL(e),a=r?.protocolVersion??`2025-11-25`,o;if(r?.metadataUrl)o=new URL(r.metadataUrl);else{let e=$R(t,i.pathname);o=new URL(e,r?.metadataServerUrl??i),o.search=i.search}let s=await ez(o,a,n);return!r?.metadataUrl&&tz(s,i.pathname)&&(s=await ez(new URL(`/.well-known/${t}`,i),a,n)),s}function rz(e){let t=typeof e==`string`?new URL(e):e,n=t.pathname!==`/`,r=[];if(!n)return r.push({url:new URL(`/.well-known/oauth-authorization-server`,t.origin),type:`oauth`}),r.push({url:new URL(`/.well-known/openid-configuration`,t.origin),type:`oidc`}),r;let i=t.pathname;return i.endsWith(`/`)&&(i=i.slice(0,-1)),r.push({url:new URL(`/.well-known/oauth-authorization-server${i}`,t.origin),type:`oauth`}),r.push({url:new URL(`/.well-known/openid-configuration${i}`,t.origin),type:`oidc`}),r.push({url:new URL(`${i}/.well-known/openid-configuration`,t.origin),type:`oidc`}),r}async function iz(e,{fetchFn:t=fetch,protocolVersion:n=EP}={}){let r={"MCP-Protocol-Version":n,Accept:`application/json`},i=rz(e);for(let{url:e,type:n}of i){let i=await QR(e,r,t);if(i){if(!i.ok){if(await i.body?.cancel(),i.status>=400&&i.status<500)continue;throw Error(`HTTP ${i.status} trying to load ${n===`oauth`?`OAuth`:`OpenID provider`} metadata from ${e}`)}return n===`oauth`?oR.parse(await i.json()):sR.parse(await i.json())}}}async function az(e,t){let n,r;try{n=await ZR(e,{resourceMetadataUrl:t?.resourceMetadataUrl},t?.fetchFn),n.authorization_servers&&n.authorization_servers.length>0&&(r=n.authorization_servers[0])}catch{}r||=String(new URL(`/`,e));let i=await iz(r,{fetchFn:t?.fetchFn});return{authorizationServerUrl:r,authorizationServerMetadata:i,resourceMetadata:n}}async function oz(e,{metadata:t,clientInformation:n,redirectUrl:r,scope:i,state:a,resource:o}){let s;if(t){if(s=new URL(t.authorization_endpoint),!t.response_types_supported.includes(LR))throw Error(`Incompatible auth server: does not support response type ${LR}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(RR))throw Error(`Incompatible auth server: does not support code challenge method ${RR}`)}else s=new URL(`/authorize`,e);let c=await rR(),l=c.code_verifier,u=c.code_challenge;return s.searchParams.set(`response_type`,LR),s.searchParams.set(`client_id`,n.client_id),s.searchParams.set(`code_challenge`,u),s.searchParams.set(`code_challenge_method`,RR),s.searchParams.set(`redirect_uri`,String(r)),a&&s.searchParams.set(`state`,a),i&&s.searchParams.set(`scope`,i),i?.includes(`offline_access`)&&s.searchParams.append(`prompt`,`consent`),o&&s.searchParams.set(`resource`,o.href),{authorizationUrl:s,codeVerifier:l}}function sz(e,t,n){return new URLSearchParams({grant_type:`authorization_code`,code:e,code_verifier:t,redirect_uri:String(n)})}async function cz(e,{metadata:t,tokenRequestParams:n,clientInformation:r,addClientAuthentication:i,resource:a,fetchFn:o}){let s=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`});a&&n.set(`resource`,a.href),i?await i(c,n,s,t):r&&BR(zR(r,t?.token_endpoint_auth_methods_supported??[]),r,c,n);let l=await(o??fetch)(s,{method:`POST`,headers:c,body:n});if(!l.ok)throw await WR(l);return cR.parse(await l.json())}async function lz(e,{metadata:t,clientInformation:n,refreshToken:r,resource:i,addClientAuthentication:a,fetchFn:o}){return{refresh_token:r,...await cz(e,{metadata:t,tokenRequestParams:new URLSearchParams({grant_type:`refresh_token`,refresh_token:r}),clientInformation:n,addClientAuthentication:a,resource:i,fetchFn:o})}}async function uz(e,t,{metadata:n,resource:r,authorizationCode:i,fetchFn:a}={}){let o=e.clientMetadata.scope,s;if(e.prepareTokenRequest&&(s=await e.prepareTokenRequest(o)),!s){if(!i)throw Error(`Either provider.prepareTokenRequest() or authorizationCode is required`);if(!e.redirectUrl)throw Error(`redirectUrl is required for authorization_code flow`);s=sz(i,await e.codeVerifier(),e.redirectUrl)}let c=await e.clientInformation();return cz(t,{metadata:n,tokenRequestParams:s,clientInformation:c??void 0,addClientAuthentication:e.addClientAuthentication,resource:r,fetchFn:a})}async function dz(e,{metadata:t,clientMetadata:n,scope:r,fetchFn:i}){let a;if(t){if(!t.registration_endpoint)throw Error(`Incompatible auth server: does not support dynamic client registration`);a=new URL(t.registration_endpoint)}else a=new URL(`/register`,e);let o=await(i??fetch)(a,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...n,...r===void 0?{}:{scope:r}})});if(!o.ok)throw await WR(o);return pR.parse(await o.json())}var fz=class extends Error{constructor(e,t,n){super(`SSE error: ${t}`),this.code=e,this.event=n}},pz=class{constructor(e,t){this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._eventSourceInit=t?.eventSourceInit,this._requestInit=t?.requestInit,this._authProvider=t?.authProvider,this._fetch=t?.fetch,this._fetchWithInit=ZL(t?.fetch,t?.requestInit)}async _authThenStart(){if(!this._authProvider)throw new FR(`No auth provider`);let e;try{e=await GR(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(e){throw this.onerror?.(e),e}if(e!==`AUTHORIZED`)throw new FR;return await this._startOrAuth()}async _commonHeaders(){let e={};if(this._authProvider){let t=await this._authProvider.tokens();t&&(e.Authorization=`Bearer ${t.access_token}`)}this._protocolVersion&&(e[`mcp-protocol-version`]=this._protocolVersion);let t=XL(this._requestInit?.headers);return new Headers({...e,...t})}_startOrAuth(){let e=this?._eventSourceInit?.fetch??this._fetch??fetch;return new Promise((t,n)=>{this._eventSource=new JL(this._url.href,{...this._eventSourceInit,fetch:async(t,n)=>{let r=await this._commonHeaders();r.set(`Accept`,`text/event-stream`);let i=await e(t,{...n,headers:r});if(i.status===401&&i.headers.has(`www-authenticate`)){let{resourceMetadataUrl:e,scope:t}=YR(i);this._resourceMetadataUrl=e,this._scope=t}return i}}),this._abortController=new AbortController,this._eventSource.onerror=e=>{if(e.code===401&&this._authProvider){this._authThenStart().then(t,n);return}let r=new fz(e.code,e.message,e);n(r),this.onerror?.(r)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener(`endpoint`,e=>{let r=e;try{if(this._endpoint=new URL(r.data,this._url),this._endpoint.origin!==this._url.origin)throw Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(e){n(e),this.onerror?.(e),this.close();return}t()}),this._eventSource.onmessage=e=>{let t=e,n;try{n=QP.parse(JSON.parse(t.data))}catch(e){this.onerror?.(e);return}this.onmessage?.(n)}})}async start(){if(this._eventSource)throw Error(`SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.`);return await this._startOrAuth()}async finishAuth(e){if(!this._authProvider)throw new FR(`No auth provider`);if(await GR(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new FR(`Failed to authorize`)}async close(){this._abortController?.abort(),this._eventSource?.close(),this.onclose?.()}async send(e){if(!this._endpoint)throw Error(`Not connected`);try{let t=await this._commonHeaders();t.set(`content-type`,`application/json`);let n={...this._requestInit,method:`POST`,headers:t,body:JSON.stringify(e),signal:this._abortController?.signal},r=await(this._fetch??fetch)(this._endpoint,n);if(!r.ok){let t=await r.text().catch(()=>null);if(r.status===401&&this._authProvider){let{resourceMetadataUrl:t,scope:n}=YR(r);if(this._resourceMetadataUrl=t,this._scope=n,await GR(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new FR;return this.send(e)}throw Error(`Error POSTing to endpoint (HTTP ${r.status}): ${t}`)}await r.body?.cancel()}catch(e){throw this.onerror?.(e),e}}setProtocolVersion(e){this._protocolVersion=e}},mz=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:n}={}){let r;super({start(i){r=pL({onEvent:e=>{i.enqueue(e)},onError(t){e===`terminate`?i.error(t):typeof e==`function`&&e(t)},onRetry:t,onComment:n})},transform(e){r.feed(e)}})}},hz={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},gz=class extends Error{constructor(e,t){super(`Streamable HTTP error: ${t}`),this.code=e}},_z=class{constructor(e,t){this._hasCompletedAuthFlow=!1,this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=t?.requestInit,this._authProvider=t?.authProvider,this._fetch=t?.fetch,this._fetchWithInit=ZL(t?.fetch,t?.requestInit),this._sessionId=t?.sessionId,this._reconnectionOptions=t?.reconnectionOptions??hz}async _authThenStart(){if(!this._authProvider)throw new FR(`No auth provider`);let e;try{e=await GR(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(e){throw this.onerror?.(e),e}if(e!==`AUTHORIZED`)throw new FR;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){let e={};if(this._authProvider){let t=await this._authProvider.tokens();t&&(e.Authorization=`Bearer ${t.access_token}`)}this._sessionId&&(e[`mcp-session-id`]=this._sessionId),this._protocolVersion&&(e[`mcp-protocol-version`]=this._protocolVersion);let t=XL(this._requestInit?.headers);return new Headers({...e,...t})}async _startOrAuthSse(e){let{resumptionToken:t}=e;try{let n=await this._commonHeaders();n.set(`Accept`,`text/event-stream`),t&&n.set(`last-event-id`,t);let r=await(this._fetch??fetch)(this._url,{method:`GET`,headers:n,signal:this._abortController?.signal});if(!r.ok){if(await r.body?.cancel(),r.status===401&&this._authProvider)return await this._authThenStart();if(r.status===405)return;throw new gz(r.status,`Failed to open SSE stream: ${r.statusText}`)}this._handleSseStream(r.body,e,!0)}catch(e){throw this.onerror?.(e),e}}_getNextReconnectionDelay(e){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let t=this._reconnectionOptions.initialReconnectionDelay,n=this._reconnectionOptions.reconnectionDelayGrowFactor,r=this._reconnectionOptions.maxReconnectionDelay;return Math.min(t*n**+e,r)}_scheduleReconnection(e,t=0){let n=this._reconnectionOptions.maxRetries;if(t>=n){this.onerror?.(Error(`Maximum reconnection attempts (${n}) exceeded.`));return}let r=this._getNextReconnectionDelay(t);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(e).catch(n=>{this.onerror?.(Error(`Failed to reconnect SSE stream: ${n instanceof Error?n.message:String(n)}`)),this._scheduleReconnection(e,t+1)})},r)}_handleSseStream(e,t,n){if(!e)return;let{onresumptiontoken:r,replayMessageId:i}=t,a,o=!1,s=!1;(async()=>{try{let t=e.pipeThrough(new TextDecoderStream).pipeThrough(new mz({onRetry:e=>{this._serverRetryMs=e}})).getReader();for(;;){let{value:e,done:n}=await t.read();if(n)break;if(e.id&&(a=e.id,o=!0,r?.(e.id)),e.data&&(!e.event||e.event===`message`))try{let t=QP.parse(JSON.parse(e.data));JP(t)&&(s=!0,i!==void 0&&(t.id=i)),this.onmessage?.(t)}catch(e){this.onerror?.(e)}}(n||o)&&!s&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:a,onresumptiontoken:r,replayMessageId:i},0)}catch(e){if(this.onerror?.(Error(`SSE stream disconnected: ${e}`)),(n||o)&&!s&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:a,onresumptiontoken:r,replayMessageId:i},0)}catch(e){this.onerror?.(Error(`Failed to reconnect: ${e instanceof Error?e.message:String(e)}`))}}})()}async start(){if(this._abortController)throw Error(`StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.`);this._abortController=new AbortController}async finishAuth(e){if(!this._authProvider)throw new FR(`No auth provider`);if(await GR(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new FR(`Failed to authorize`)}async close(){this._reconnectionTimeout&&=(clearTimeout(this._reconnectionTimeout),void 0),this._abortController?.abort(),this.onclose?.()}async send(e,t){try{let{resumptionToken:n,onresumptiontoken:r}=t||{};if(n){this._startOrAuthSse({resumptionToken:n,replayMessageId:WP(e)?e.id:void 0}).catch(e=>this.onerror?.(e));return}let i=await this._commonHeaders();i.set(`content-type`,`application/json`),i.set(`accept`,`application/json, text/event-stream`);let a={...this._requestInit,method:`POST`,headers:i,body:JSON.stringify(e),signal:this._abortController?.signal},o=await(this._fetch??fetch)(this._url,a),s=o.headers.get(`mcp-session-id`);if(s&&(this._sessionId=s),!o.ok){let t=await o.text().catch(()=>null);if(o.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new gz(401,`Server returned 401 after successful authentication`);let{resourceMetadataUrl:t,scope:n}=YR(o);if(this._resourceMetadataUrl=t,this._scope=n,await GR(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new FR;return this._hasCompletedAuthFlow=!0,this.send(e)}if(o.status===403&&this._authProvider){let{resourceMetadataUrl:t,scope:n,error:r}=YR(o);if(r===`insufficient_scope`){let r=o.headers.get(`WWW-Authenticate`);if(this._lastUpscopingHeader===r)throw new gz(403,`Server returned 403 after trying upscoping`);if(n&&(this._scope=n),t&&(this._resourceMetadataUrl=t),this._lastUpscopingHeader=r??void 0,await GR(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!==`AUTHORIZED`)throw new FR;return this.send(e)}}throw new gz(o.status,`Error POSTing to endpoint: ${t}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,o.status===202){await o.body?.cancel(),mF(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(e=>this.onerror?.(e));return}let c=(Array.isArray(e)?e:[e]).filter(e=>`method`in e&&`id`in e&&e.id!==void 0).length>0,l=o.headers.get(`content-type`);if(c){if(l?.includes(`text/event-stream`))this._handleSseStream(o.body,{onresumptiontoken:r},!1);else if(l?.includes(`application/json`)){let e=await o.json(),t=Array.isArray(e)?e.map(e=>QP.parse(e)):[QP.parse(e)];for(let e of t)this.onmessage?.(e)}else throw await o.body?.cancel(),new gz(-1,`Unexpected content type: ${l}`)}else await o.body?.cancel()}catch(e){throw this.onerror?.(e),e}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{let e=await this._commonHeaders(),t={...this._requestInit,method:`DELETE`,headers:e,signal:this._abortController?.signal},n=await(this._fetch??fetch)(this._url,t);if(await n.body?.cancel(),!n.ok&&n.status!==405)throw new gz(n.status,`Failed to terminate session: ${n.statusText}`);this._sessionId=void 0}catch(e){throw this.onerror?.(e),e}}setProtocolVersion(e){this._protocolVersion=e}get protocolVersion(){return this._protocolVersion}async resumeStream(e,t){await this._startOrAuthSse({resumptionToken:e,onresumptiontoken:t?.onresumptiontoken})}};function vz(e){return!!e._zod}function yz(e,t){return vz(e)?Tk(e,t):e.safeParse(t)}function bz(e){if(!e)return;let t;if(t=vz(e)?e._zod?.def?.shape:e.shape,t){if(typeof t==`function`)try{return t()}catch{return}return t}}function xz(e){if(vz(e)){let t=e._zod?.def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}}let t=e._def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}let n=e.value;if(n!==void 0)return n}function Sz(e){return e===`completed`||e===`failed`||e===`cancelled`}function Cz(e){let t=bz(e)?.method;if(!t)throw Error(`Schema is missing a method literal`);let n=xz(t);if(typeof n!=`string`)throw Error(`Schema method literal must be a string`);return n}function wz(e,t){let n=yz(e,t);if(!n.success)throw n.error;return n.data}var Tz=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(tF,e=>{this._oncancel(e)}),this.setNotificationHandler(vF,e=>{this._onprogress(e)}),this.setRequestHandler(hF,e=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(DF,async(e,t)=>{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new lL(YP.InvalidParams,`Failed to retrieve task: Task not found`);return{...n}}),this.setRequestHandler(kF,async(e,t)=>{let n=async()=>{let r=e.params.taskId;if(this._taskMessageQueue){let e;for(;e=await this._taskMessageQueue.dequeue(r,t.sessionId);){if(e.type===`response`||e.type===`error`){let t=e.message,n=t.id,r=this._requestResolvers.get(n);if(r){if(this._requestResolvers.delete(n),e.type===`response`)r(t);else{let e=t;r(new lL(e.error.code,e.error.message,e.error.data))}}else{let t=e.type===`response`?`Response`:`Error`;this._onerror(Error(`${t} handler missing for request ${n}`))}continue}await this._transport?.send(e.message,{relatedRequestId:t.requestId})}}let i=await this._taskStore.getTask(r,t.sessionId);if(!i)throw new lL(YP.InvalidParams,`Task not found: ${r}`);if(!Sz(i.status))return await this._waitForTaskUpdate(r,t.signal),await n();if(Sz(i.status)){let e=await this._taskStore.getTaskResult(r,t.sessionId);return this._clearTaskQueue(r),{...e,_meta:{...e._meta,[OP]:{taskId:r}}}}return await n()};return await n()}),this.setRequestHandler(AF,async(e,t)=>{try{let{tasks:n,nextCursor:r}=await this._taskStore.listTasks(e.params?.cursor,t.sessionId);return{tasks:n,nextCursor:r,_meta:{}}}catch(e){throw new lL(YP.InvalidParams,`Failed to list tasks: ${e instanceof Error?e.message:String(e)}`)}}),this.setRequestHandler(MF,async(e,t)=>{try{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new lL(YP.InvalidParams,`Task not found: ${e.params.taskId}`);if(Sz(n.status))throw new lL(YP.InvalidParams,`Cannot cancel task in terminal status: ${n.status}`);await this._taskStore.updateTaskStatus(e.params.taskId,`cancelled`,`Client cancelled task execution.`,t.sessionId),this._clearTaskQueue(e.params.taskId);let r=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!r)throw new lL(YP.InvalidParams,`Task not found after cancellation: ${e.params.taskId}`);return{_meta:{},...r}}catch(e){throw e instanceof lL?e:new lL(YP.InvalidRequest,`Failed to cancel task: ${e instanceof Error?e.message:String(e)}`)}}))}async _oncancel(e){e.params.requestId&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,n,r,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),lL.fromError(YP.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw Error(`Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.`);this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{t?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=e=>{n?.(e),this._onerror(e)};let r=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{r?.(e,t),JP(e)||ZP(e)?this._onresponse(e):WP(e)?this._onrequest(e,t):KP(e)?this._onnotification(e):this._onerror(Error(`Unknown message type: ${JSON.stringify(e)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let e of this._timeoutInfo.values())clearTimeout(e.timeoutId);this._timeoutInfo.clear();for(let e of this._requestHandlerAbortControllers.values())e.abort();this._requestHandlerAbortControllers.clear();let t=lL.fromError(YP.ConnectionClosed,`Connection closed`);this._transport=void 0,this.onclose?.();for(let n of e.values())n(t)}_onerror(e){this.onerror?.(e)}_onnotification(e){let t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;t!==void 0&&Promise.resolve().then(()=>t(e)).catch(e=>this._onerror(Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,r=this._transport,i=e.params?._meta?.[OP]?.taskId;if(n===void 0){let t={jsonrpc:`2.0`,id:e.id,error:{code:YP.MethodNotFound,message:`Method not found`}};i&&this._taskMessageQueue?this._enqueueTaskMessage(i,{type:`error`,message:t,timestamp:Date.now()},r?.sessionId).catch(e=>this._onerror(Error(`Failed to enqueue error response: ${e}`))):r?.send(t).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)));return}let a=new AbortController;this._requestHandlerAbortControllers.set(e.id,a);let o=LP(e.params)?e.params.task:void 0,s=this._taskStore?this.requestTaskStore(e,r?.sessionId):void 0,c={signal:a.signal,sessionId:r?.sessionId,_meta:e.params?._meta,sendNotification:async t=>{if(a.signal.aborted)return;let n={relatedRequestId:e.id};i&&(n.relatedTask={taskId:i}),await this.notification(t,n)},sendRequest:async(t,n,r)=>{if(a.signal.aborted)throw new lL(YP.ConnectionClosed,`Request was cancelled`);let o={...r,relatedRequestId:e.id};i&&!o.relatedTask&&(o.relatedTask={taskId:i});let c=o.relatedTask?.taskId??i;return c&&s&&await s.updateTaskStatus(c,`input_required`),await this.request(t,n,o)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:i,taskStore:s,taskRequestedTtl:o?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};Promise.resolve().then(()=>{o&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,c)).then(async t=>{if(a.signal.aborted)return;let n={result:t,jsonrpc:`2.0`,id:e.id};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`response`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)},async t=>{if(a.signal.aborted)return;let n={jsonrpc:`2.0`,id:e.id,error:{code:Number.isSafeInteger(t.code)?t.code:YP.InternalError,message:t.message??`Internal error`,...t.data!==void 0&&{data:t.data}}};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`error`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===a&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,r=Number(t),i=this._progressHandlers.get(r);if(!i){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(r),o=this._timeoutInfo.get(r);if(o&&a&&o.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(e){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),a(e);return}i(n)}_onresponse(e){let t=Number(e.id),n=this._requestResolvers.get(t);if(n){this._requestResolvers.delete(t),JP(e)?n(e):n(new lL(e.error.code,e.error.message,e.error.data));return}let r=this._responseHandlers.get(t);if(r===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t);let i=!1;if(JP(e)&&e.result&&typeof e.result==`object`){let n=e.result;if(n.task&&typeof n.task==`object`){let e=n.task;typeof e.taskId==`string`&&(i=!0,this._taskProgressTokens.set(e.taskId,t))}}i||this._progressHandlers.delete(t),JP(e)?r(e):r(lL.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,t,n){let{task:r}=n??{};if(!r){try{yield{type:`result`,result:await this.request(e,t,n)}}catch(e){yield{type:`error`,error:e instanceof lL?e:new lL(YP.InternalError,String(e))}}return}let i;try{let r=await this.request(e,wF,n);if(r.task)i=r.task.taskId,yield{type:`taskCreated`,task:r.task};else throw new lL(YP.InternalError,`Task creation did not return a task`);for(;;){let e=await this.getTask({taskId:i},n);if(yield{type:`taskStatus`,task:e},Sz(e.status)){e.status===`completed`?yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)}:e.status===`failed`?yield{type:`error`,error:new lL(YP.InternalError,`Task ${i} failed`)}:e.status===`cancelled`&&(yield{type:`error`,error:new lL(YP.InternalError,`Task ${i} was cancelled`)});return}if(e.status===`input_required`){yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)};return}let r=e.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(e=>setTimeout(e,r)),n?.signal?.throwIfAborted()}}catch(e){yield{type:`error`,error:e instanceof lL?e:new lL(YP.InternalError,String(e))}}}request(e,t,n){let{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a,task:o,relatedTask:s}=n??{};return new Promise((c,l)=>{let u=e=>{l(e)};if(!this._transport){u(Error(`Not connected`));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),o&&this.assertTaskCapability(e.method)}catch(e){u(e);return}n?.signal?.throwIfAborted();let d=this._requestMessageId++,f={...e,jsonrpc:`2.0`,id:d};n?.onprogress&&(this._progressHandlers.set(d,n.onprogress),f.params={...e.params,_meta:{...e.params?._meta||{},progressToken:d}}),o&&(f.params={...f.params,task:o}),s&&(f.params={...f.params,_meta:{...f.params?._meta||{},[OP]:s}});let p=e=>{this._responseHandlers.delete(d),this._progressHandlers.delete(d),this._cleanupTimeout(d),this._transport?.send({jsonrpc:`2.0`,method:`notifications/cancelled`,params:{requestId:d,reason:String(e)}},{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))),l(e instanceof lL?e:new lL(YP.RequestTimeout,String(e)))};this._responseHandlers.set(d,e=>{if(!n?.signal?.aborted){if(e instanceof Error)return l(e);try{let n=yz(t,e.result);n.success?c(n.data):l(n.error)}catch(e){l(e)}}}),n?.signal?.addEventListener(`abort`,()=>{p(n?.signal?.reason)});let m=n?.timeout??6e4;this._setupTimeout(d,m,n?.maxTotalTimeout,()=>p(lL.fromError(YP.RequestTimeout,`Request timed out`,{timeout:m})),n?.resetTimeoutOnProgress??!1);let h=s?.taskId;h?(this._requestResolvers.set(d,e=>{let t=this._responseHandlers.get(d);t?t(e):this._onerror(Error(`Response handler missing for side-channeled request ${d}`))}),this._enqueueTaskMessage(h,{type:`request`,message:f,timestamp:Date.now()}).catch(e=>{this._cleanupTimeout(d),l(e)})):this._transport.send(f,{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>{this._cleanupTimeout(d),l(e)})})}async getTask(e,t){return this.request({method:`tasks/get`,params:e},OF,t)}async getTaskResult(e,t,n){return this.request({method:`tasks/result`,params:e},t,n)}async listTasks(e,t){return this.request({method:`tasks/list`,params:e},jF,t)}async cancelTask(e,t){return this.request({method:`tasks/cancel`,params:e},NF,t)}async notification(e,t){if(!this._transport)throw Error(`Not connected`);this.assertNotificationCapability(e.method);let n=t?.relatedTask?.taskId;if(n){let r={...e,jsonrpc:`2.0`,params:{...e.params,_meta:{...e.params?._meta||{},[OP]:t.relatedTask}}};await this._enqueueTaskMessage(n,{type:`notification`,message:r,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!t?.relatedRequestId&&!t?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let n={...e,jsonrpc:`2.0`};t?.relatedTask&&(n={...n,params:{...n.params,_meta:{...n.params?._meta||{},[OP]:t.relatedTask}}}),this._transport?.send(n,t).catch(e=>this._onerror(e))});return}let r={...e,jsonrpc:`2.0`};t?.relatedTask&&(r={...r,params:{...r.params,_meta:{...r.params?._meta||{},[OP]:t.relatedTask}}}),await this._transport.send(r,t)}setRequestHandler(e,t){let n=Cz(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(n,r)=>{let i=wz(e,n);return Promise.resolve(t(i,r))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){let n=Cz(e);this._notificationHandlers.set(n,n=>{let r=wz(e,n);return Promise.resolve(t(r))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let t=this._taskProgressTokens.get(e);t!==void 0&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,n){if(!this._taskStore||!this._taskMessageQueue)throw Error(`Cannot enqueue task message: taskStore and taskMessageQueue are not configured`);let r=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,n,r)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,t);for(let t of n)if(t.type===`request`&&WP(t.message)){let n=t.message.id,r=this._requestResolvers.get(n);r?(r(new lL(YP.InternalError,`Task cancelled or completed`)),this._requestResolvers.delete(n)):this._onerror(Error(`Resolver missing for request ${n} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){let n=this._options?.defaultTaskPollInterval??1e3;try{let t=await this._taskStore?.getTask(e);t?.pollInterval&&(n=t.pollInterval)}catch{}return new Promise((e,r)=>{if(t.aborted){r(new lL(YP.InvalidRequest,`Request cancelled`));return}let i=setTimeout(e,n);t.addEventListener(`abort`,()=>{clearTimeout(i),r(new lL(YP.InvalidRequest,`Request cancelled`))},{once:!0})})}requestTaskStore(e,t){let n=this._taskStore;if(!n)throw Error(`No task store configured`);return{createTask:async r=>{if(!e)throw Error(`No request provided`);return await n.createTask(r,e.id,{method:e.method,params:e.params},t)},getTask:async e=>{let r=await n.getTask(e,t);if(!r)throw new lL(YP.InvalidParams,`Failed to retrieve task: Task not found`);return r},storeTaskResult:async(e,r,i)=>{await n.storeTaskResult(e,r,i,t);let a=await n.getTask(e,t);if(a){let t=EF.parse({method:`notifications/tasks/status`,params:a});await this.notification(t),Sz(a.status)&&this._cleanupTaskProgressHandler(e)}},getTaskResult:e=>n.getTaskResult(e,t),updateTaskStatus:async(e,r,i)=>{let a=await n.getTask(e,t);if(!a)throw new lL(YP.InvalidParams,`Task "${e}" not found - it may have been cleaned up`);if(Sz(a.status))throw new lL(YP.InvalidParams,`Cannot update task "${e}" from terminal status "${a.status}" to "${r}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(e,r,i,t);let o=await n.getTask(e,t);if(o){let t=EF.parse({method:`notifications/tasks/status`,params:o});await this.notification(t),Sz(o.status)&&this._cleanupTaskProgressHandler(e)}},listTasks:e=>n.listTasks(e,t)}}};function Ez(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Dz(e,t){let n={...e};for(let e in t){let r=e,i=t[r];if(i===void 0)continue;let a=n[r];n[r]=Ez(a)&&Ez(i)?{...a,...i}:i}return n}var Oz=s((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;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=n;var r=class extends t{constructor(e){super(),this._items=typeof e==`string`?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===``||e===`""`}get str(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};e._Code=r,e.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}e._=i;var a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}e.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}e.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}e.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}e.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}e.safeStringify=p;function m(t){return typeof t==`string`&&e.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}e.getProperty=m;function h(t){if(typeof t==`string`&&e.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(e){return new r(e.toString())}e.regexpCode=g})),kz=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;var t=Oz(),n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r||(e.UsedValueState=r={})),e.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var i=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};e.Scope=i;var a=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};e.ValueScopeName=a;var o=(0,t._)`\n`;e.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?e.varKinds.var:e.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),Az=s((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;var t=Oz(),n=kz(),r=Oz();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}});var i=kz();Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return i.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(`+`)};var a=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},o=class extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let r=e?n.varKinds.var:this.varKind,i=this.rhs===void 0?``:` = ${this.rhs}`;return`${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&=k(this.rhs,e,t),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},s=class extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof t.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=k(this.rhs,e,n),this}get names(){return O(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends s{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},l=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},u=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},d=class extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},f=class extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=k(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},p=class extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),``)}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let i=n[r];i.optimizeNames(e,t)||(A(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>D(e,t.names),{})}},m=class extends p{render(e){return`{`+e._n+super.render(e)+`}`+e._n}},h=class extends p{},g=class extends m{};g.kind=`else`;var _=class e extends m{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+=`else `+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let e=n.optimizeNodes();n=this.else=Array.isArray(e)?new g(e):e}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(j(t),n instanceof e?[n]:n.nodes);if(t!==!1&&this.nodes.length)return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=k(this.condition,e,t),this}get names(){let e=super.names;return O(e,this.condition),this.else&&D(e,this.else.names),e}};_.kind=`if`;var v=class extends m{};v.kind=`for`;var y=class extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=k(this.iteration,e,t),this}get names(){return D(super.names,this.iteration.names)}},b=class extends v{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?n.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return`for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){return O(O(super.names,this.from),this.to)}},x=class extends v{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=k(this.iterable,e,t),this}get names(){return D(super.names,this.iterable.names)}},S=class extends m{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?`async `:``}function ${this.name}(${this.args})`+super.render(e)}};S.kind=`func`;var C=class extends p{render(e){return`return `+super.render(e)}};C.kind=`return`;var w=class extends m{render(e){let t=`try`+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)==null||e.optimizeNodes(),(t=this.finally)==null||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)==null||n.optimizeNames(e,t),(r=this.finally)==null||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&D(e,this.catch.names),this.finally&&D(e,this.finally.names),e}},T=class extends m{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};T.kind=`catch`;var E=class extends m{render(e){return`finally`+super.render(e)}};E.kind=`finally`,e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
|
|
219
|
+
`:``},this._extScope=e,this._scope=new n.Scope({parent:e}),this._nodes=[new h]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,r){let i=this._scope.toName(t);return n!==void 0&&r&&(this._constants[i.str]=n),this._leafNode(new o(e,i,n)),i}const(e,t,r){return this._def(n.varKinds.const,e,t,r)}let(e,t,r){return this._def(n.varKinds.let,e,t,r)}var(e,t,r){return this._def(n.varKinds.var,e,t,r)}assign(e,t,n){return this._leafNode(new s(e,t,n))}add(t,n){return this._leafNode(new c(t,e.operators.ADD,n))}code(e){return typeof e==`function`?e():e!==t.nil&&this._leafNode(new f(e)),this}object(...e){let n=[`{`];for(let[r,i]of e)n.length>1&&n.push(`,`),n.push(r),(r!==i||this.opts.es5)&&(n.push(`:`),(0,t.addCodeArg)(n,i));return n.push(`}`),new t._Code(n)}if(e,t,n){if(this._blockNode(new _(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw Error(`CodeGen: "else" body without "then" body`);return this}elseIf(e){return this._elseNode(new _(e))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(_,g)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new y(e),t)}forRange(e,t,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.let){let o=this._scope.toName(e);return this._for(new b(a,o,t,r),()=>i(o))}forOf(e,r,i,a=n.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let e=r instanceof t.Name?r:this.var(`_arr`,r);return this.forRange(`_i`,0,(0,t._)`${e}.length`,n=>{this.var(o,(0,t._)`${e}[${n}]`),i(o)})}return this._for(new x(`of`,a,o,r),()=>i(o))}forIn(e,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,t._)`Object.keys(${r})`,i);let o=this._scope.toName(e);return this._for(new x(`in`,a,o,r),()=>i(o))}endFor(){return this._endBlockNode(v)}label(e){return this._leafNode(new l(e))}break(e){return this._leafNode(new u(e))}return(e){let t=new C;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw Error(`CodeGen: "return" should have one node`);return this._endBlockNode(C)}try(e,t,n){if(!t&&!n)throw Error(`CodeGen: "try" without "catch" and "finally"`);let r=new w;if(this._blockNode(r),this.code(e),t){let e=this.name(`e`);this._currNode=r.catch=new T(e),t(e)}return n&&(this._currNode=r.finally=new E,this.code(n)),this._endBlockNode(T,E)}throw(e){return this._leafNode(new d(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw Error(`CodeGen: not in self-balancing block`);let n=this._nodes.length-t;if(n<0||e!==void 0&&n!==e)throw Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,n=t.nil,r,i){return this._blockNode(new S(e,n,r)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(S)}optimize(e=1){for(;e-->0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){let n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof _))throw Error(`CodeGen: "else" without "if"`);return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e}};function D(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function O(e,n){return n instanceof t._CodeOrName?D(e,n.names):e}function k(e,n,r){if(e instanceof t.Name)return i(e);if(!a(e))return e;return new t._Code(e._items.reduce((e,n)=>(n instanceof t.Name&&(n=i(n)),n instanceof t._Code?e.push(...n._items):e.push(n),e),[]));function i(e){let t=r[e.str];return t===void 0||n[e.str]!==1?e:(delete n[e.str],t)}function a(e){return e instanceof t._Code&&e._items.some(e=>e instanceof t.Name&&n[e.str]===1&&r[e.str]!==void 0)}}function A(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function j(e){return typeof e==`boolean`||typeof e==`number`||e===null?!e:(0,t._)`!${L(e)}`}e.not=j;var M=I(e.operators.AND);function N(...e){return e.reduce(M)}e.and=N;var P=I(e.operators.OR);function F(...e){return e.reduce(P)}e.or=F;function I(e){return(n,r)=>n===t.nil?r:r===t.nil?n:(0,t._)`${L(n)} ${e} ${L(r)}`}function L(e){return e instanceof t.Name?e:(0,t._)`(${e})`}})),jz=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.checkStrictMode=e.getErrorPath=e.Type=e.useFunc=e.setEvaluated=e.evaluatedPropsToName=e.mergeEvaluated=e.eachItem=e.unescapeJsonPointer=e.escapeJsonPointer=e.escapeFragment=e.unescapeFragment=e.schemaRefOrVal=e.schemaHasRulesButRef=e.schemaHasRules=e.checkUnknownRules=e.alwaysValidSchema=e.toHash=void 0;var t=Az(),n=Oz();function r(e){let t={};for(let n of e)t[n]=!0;return t}e.toHash=r;function i(e,t){return typeof t==`boolean`?t:Object.keys(t).length===0||(a(e,t),!o(t,e.self.RULES.all))}e.alwaysValidSchema=i;function a(e,t=e.schema){let{opts:n,self:r}=e;if(!n.strictSchema||typeof t==`boolean`)return;let i=r.RULES.keywords;for(let n in t)i[n]||x(e,`unknown keyword: "${n}"`)}e.checkUnknownRules=a;function o(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(t[n])return!0;return!1}e.schemaHasRules=o;function s(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(n!==`$ref`&&t.all[n])return!0;return!1}e.schemaHasRulesButRef=s;function c({topSchemaRef:e,schemaPath:n},r,i,a){if(!a){if(typeof r==`number`||typeof r==`boolean`)return r;if(typeof r==`string`)return(0,t._)`${r}`}return(0,t._)`${e}${n}${(0,t.getProperty)(i)}`}e.schemaRefOrVal=c;function l(e){return f(decodeURIComponent(e))}e.unescapeFragment=l;function u(e){return encodeURIComponent(d(e))}e.escapeFragment=u;function d(e){return typeof e==`number`?`${e}`:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}e.escapeJsonPointer=d;function f(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}e.unescapeJsonPointer=f;function p(e,t){if(Array.isArray(e))for(let n of e)t(n);else t(e)}e.eachItem=p;function m({mergeNames:e,mergeToName:n,mergeValues:r,resultToName:i}){return(a,o,s,c)=>{let l=s===void 0?o:s instanceof t.Name?(o instanceof t.Name?e(a,o,s):n(a,o,s),s):o instanceof t.Name?(n(a,s,o),o):r(o,s);return c===t.Name&&!(l instanceof t.Name)?i(a,l):l}}e.mergeEvaluated={props:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>{e.if((0,t._)`${n} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,t._)`${r} || {}`).code((0,t._)`Object.assign(${r}, ${n})`))}),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>{n===!0?e.assign(r,!0):(e.assign(r,(0,t._)`${r} || {}`),g(e,r,n))}),mergeValues:(e,t)=>e===!0||{...e,...t},resultToName:h}),items:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>e.assign(r,(0,t._)`${n} === true ? true : ${r} > ${n} ? ${r} : ${n}`)),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>e.assign(r,n===!0||(0,t._)`${r} > ${n} ? ${r} : ${n}`)),mergeValues:(e,t)=>e===!0||Math.max(e,t),resultToName:(e,t)=>e.var(`items`,t)})};function h(e,n){if(n===!0)return e.var(`props`,!0);let r=e.var(`props`,(0,t._)`{}`);return n!==void 0&&g(e,r,n),r}e.evaluatedPropsToName=h;function g(e,n,r){Object.keys(r).forEach(r=>e.assign((0,t._)`${n}${(0,t.getProperty)(r)}`,!0))}e.setEvaluated=g;var _={};function v(e,t){return e.scopeValue(`func`,{ref:t,code:_[t.code]||(_[t.code]=new n._Code(t.code))})}e.useFunc=v;var y;(function(e){e[e.Num=0]=`Num`,e[e.Str=1]=`Str`})(y||(e.Type=y={}));function b(e,n,r){if(e instanceof t.Name){let i=n===y.Num;return r?i?(0,t._)`"[" + ${e} + "]"`:(0,t._)`"['" + ${e} + "']"`:i?(0,t._)`"/" + ${e}`:(0,t._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,t.getProperty)(e).toString():`/`+d(e)}e.getErrorPath=b;function x(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,n===!0)throw Error(t);e.self.logger.warn(t)}}e.checkStrictMode=x})),Mz=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Az();e.default={data:new t.Name(`data`),valCxt:new t.Name(`valCxt`),instancePath:new t.Name(`instancePath`),parentData:new t.Name(`parentData`),parentDataProperty:new t.Name(`parentDataProperty`),rootData:new t.Name(`rootData`),dynamicAnchors:new t.Name(`dynamicAnchors`),vErrors:new t.Name(`vErrors`),errors:new t.Name(`errors`),this:new t.Name(`this`),self:new t.Name(`self`),scope:new t.Name(`scope`),json:new t.Name(`json`),jsonPos:new t.Name(`jsonPos`),jsonLen:new t.Name(`jsonLen`),jsonPart:new t.Name(`jsonPart`)}})),Nz=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;var t=Az(),n=jz(),r=Mz();e.keywordError={message:({keyword:e})=>(0,t.str)`must pass "${e}" keyword validation`},e.keyword$DataError={message:({keyword:e,schemaType:n})=>n?(0,t.str)`"${e}" keyword must be ${n} ($data)`:(0,t.str)`"${e}" keyword is invalid ($data)`};function i(n,r=e.keywordError,i,a){let{it:o}=n,{gen:s,compositeRule:u,allErrors:f}=o,p=d(n,r,i);a??(u||f)?c(s,p):l(o,(0,t._)`[${p}]`)}e.reportError=i;function a(t,n=e.keywordError,i){let{it:a}=t,{gen:o,compositeRule:s,allErrors:u}=a;c(o,d(t,n,i)),s||u||l(a,r.default.vErrors)}e.reportExtraError=a;function o(e,n){e.assign(r.default.errors,n),e.if((0,t._)`${r.default.vErrors} !== null`,()=>e.if(n,()=>e.assign((0,t._)`${r.default.vErrors}.length`,n),()=>e.assign(r.default.vErrors,null)))}e.resetErrorsCount=o;function s({gen:e,keyword:n,schemaValue:i,data:a,errsCount:o,it:s}){if(o===void 0)throw Error(`ajv implementation error`);let c=e.name(`err`);e.forRange(`i`,o,r.default.errors,o=>{e.const(c,(0,t._)`${r.default.vErrors}[${o}]`),e.if((0,t._)`${c}.instancePath === undefined`,()=>e.assign((0,t._)`${c}.instancePath`,(0,t.strConcat)(r.default.instancePath,s.errorPath))),e.assign((0,t._)`${c}.schemaPath`,(0,t.str)`${s.errSchemaPath}/${n}`),s.opts.verbose&&(e.assign((0,t._)`${c}.schema`,i),e.assign((0,t._)`${c}.data`,a))})}e.extendErrors=s;function c(e,n){let i=e.const(`err`,n);e.if((0,t._)`${r.default.vErrors} === null`,()=>e.assign(r.default.vErrors,(0,t._)`[${i}]`),(0,t._)`${r.default.vErrors}.push(${i})`),e.code((0,t._)`${r.default.errors}++`)}function l(e,n){let{gen:r,validateName:i,schemaEnv:a}=e;a.$async?r.throw((0,t._)`new ${e.ValidationError}(${n})`):(r.assign((0,t._)`${i}.errors`,n),r.return(!1))}var u={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 d(e,n,r){let{createErrors:i}=e.it;return i===!1?(0,t._)`{}`:f(e,n,r)}function f(e,t,n={}){let{gen:r,it:i}=e,a=[p(i,n),m(e,n)];return h(e,t,a),r.object(...a)}function p({errorPath:e},{instancePath:i}){let a=i?(0,t.str)`${e}${(0,n.getErrorPath)(i,n.Type.Str)}`:e;return[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,a)]}function m({keyword:e,it:{errSchemaPath:r}},{schemaPath:i,parentSchema:a}){let o=a?r:(0,t.str)`${r}/${e}`;return i&&(o=(0,t.str)`${o}${(0,n.getErrorPath)(i,n.Type.Str)}`),[u.schemaPath,o]}function h(e,{params:n,message:i},a){let{keyword:o,data:s,schemaValue:c,it:l}=e,{opts:d,propertyName:f,topSchemaRef:p,schemaPath:m}=l;a.push([u.keyword,o],[u.params,typeof n==`function`?n(e):n||(0,t._)`{}`]),d.messages&&a.push([u.message,typeof i==`function`?i(e):i]),d.verbose&&a.push([u.schema,c],[u.parentSchema,(0,t._)`${p}${m}`],[r.default.data,s]),f&&a.push([u.propertyName,f])}})),Pz=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;var t=Nz(),n=Az(),r=Mz(),i={message:`boolean schema is false`};function a(e){let{gen:t,schema:i,validateName:a}=e;i===!1?s(e,!1):typeof i==`object`&&i.$async===!0?t.return(r.default.data):(t.assign((0,n._)`${a}.errors`,null),t.return(!0))}e.topBoolOrEmptySchema=a;function o(e,t){let{gen:n,schema:r}=e;r===!1?(n.var(t,!1),s(e)):n.var(t,!0)}e.boolOrEmptySchema=o;function s(e,n){let{gen:r,data:a}=e,o={gen:r,keyword:`false schema`,data:a,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,t.reportError)(o,i,void 0,n)}})),Fz=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getRules=e.isJSONType=void 0;var t=new Set([`string`,`number`,`integer`,`boolean`,`null`,`object`,`array`]);function n(e){return typeof e==`string`&&t.has(e)}e.isJSONType=n;function r(){let 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:{}}}e.getRules=r})),Iz=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.shouldUseRule=e.shouldUseGroup=e.schemaHasRulesForType=void 0;function t({schema:e,self:t},r){let i=t.RULES.types[r];return i&&i!==!0&&n(e,i)}e.schemaHasRulesForType=t;function n(e,t){return t.rules.some(t=>r(e,t))}e.shouldUseGroup=n;function r(e,t){return e[t.keyword]!==void 0||t.definition.implements?.some(t=>e[t]!==void 0)}e.shouldUseRule=r})),Lz=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.reportTypeError=e.checkDataTypes=e.checkDataType=e.coerceAndCheckDataType=e.getJSONTypes=e.getSchemaTypes=e.DataType=void 0;var t=Fz(),n=Iz(),r=Nz(),i=Az(),a=jz(),o;(function(e){e[e.Correct=0]=`Correct`,e[e.Wrong=1]=`Wrong`})(o||(e.DataType=o={}));function s(e){let t=c(e.type);if(t.includes(`null`)){if(e.nullable===!1)throw Error(`type: null contradicts nullable: false`)}else{if(!t.length&&e.nullable!==void 0)throw Error(`"nullable" cannot be used without "type"`);e.nullable===!0&&t.push(`null`)}return t}e.getSchemaTypes=s;function c(e){let n=Array.isArray(e)?e:e?[e]:[];if(n.every(t.isJSONType))return n;throw Error(`type must be JSONType or JSONType[]: `+n.join(`,`))}e.getJSONTypes=c;function l(e,t){let{gen:r,data:i,opts:a}=e,s=d(t,a.coerceTypes),c=t.length>0&&!(s.length===0&&t.length===1&&(0,n.schemaHasRulesForType)(e,t[0]));if(c){let n=h(t,i,a.strictNumbers,o.Wrong);r.if(n,()=>{s.length?f(e,t,s):_(e)})}return c}e.coerceAndCheckDataType=l;var u=new Set([`string`,`number`,`integer`,`boolean`,`null`]);function d(e,t){return t?e.filter(e=>u.has(e)||t===`array`&&e===`array`):[]}function f(e,t,n){let{gen:r,data:a,opts:o}=e,s=r.let(`dataType`,(0,i._)`typeof ${a}`),c=r.let(`coerced`,(0,i._)`undefined`);o.coerceTypes===`array`&&r.if((0,i._)`${s} == 'object' && Array.isArray(${a}) && ${a}.length == 1`,()=>r.assign(a,(0,i._)`${a}[0]`).assign(s,(0,i._)`typeof ${a}`).if(h(t,a,o.strictNumbers),()=>r.assign(c,a))),r.if((0,i._)`${c} !== undefined`);for(let e of n)(u.has(e)||e===`array`&&o.coerceTypes===`array`)&&l(e);r.else(),_(e),r.endIf(),r.if((0,i._)`${c} !== undefined`,()=>{r.assign(a,c),p(e,c)});function l(e){switch(e){case`string`:r.elseIf((0,i._)`${s} == "number" || ${s} == "boolean"`).assign(c,(0,i._)`"" + ${a}`).elseIf((0,i._)`${a} === null`).assign(c,(0,i._)`""`);return;case`number`:r.elseIf((0,i._)`${s} == "boolean" || ${a} === null
|
|
220
220
|
|| (${s} == "string" && ${a} && ${a} == +${a})`).assign(c,(0,i._)`+${a}`);return;case`integer`:r.elseIf((0,i._)`${s} === "boolean" || ${a} === null
|
|
221
221
|
|| (${s} === "string" && ${a} && ${a} == +${a} && !(${a} % 1))`).assign(c,(0,i._)`+${a}`);return;case`boolean`:r.elseIf((0,i._)`${a} === "false" || ${a} === 0 || ${a} === null`).assign(c,!1).elseIf((0,i._)`${a} === "true" || ${a} === 1`).assign(c,!0);return;case`null`:r.elseIf((0,i._)`${a} === "" || ${a} === 0 || ${a} === false`),r.assign(c,null);return;case`array`:r.elseIf((0,i._)`${s} === "string" || ${s} === "number"
|
|
222
|
-
|| ${s} === "boolean" || ${a} === null`).assign(c,(0,i._)`[${a}]`)}}}function p({gen:e,parentData:t,parentDataProperty:n},r){e.if((0,i._)`${t} !== undefined`,()=>e.assign((0,i._)`${t}[${n}]`,r))}function m(e,t,n,r=o.Correct){let a=r===o.Correct?i.operators.EQ:i.operators.NEQ,s;switch(e){case`null`:return(0,i._)`${t} ${a} null`;case`array`:s=(0,i._)`Array.isArray(${t})`;break;case`object`:s=(0,i._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case`integer`:s=c((0,i._)`!(${t} % 1) && !isNaN(${t})`);break;case`number`:s=c();break;default:return(0,i._)`typeof ${t} ${a} ${e}`}return r===o.Correct?s:(0,i.not)(s);function c(e=i.nil){return(0,i.and)((0,i._)`typeof ${t} == "number"`,e,n?(0,i._)`isFinite(${t})`:i.nil)}}e.checkDataType=m;function h(e,t,n,r){if(e.length===1)return m(e[0],t,n,r);let o,s=(0,a.toHash)(e);if(s.array&&s.object){let e=(0,i._)`typeof ${t} != "object"`;o=s.null?e:(0,i._)`!${t} || ${e}`,delete s.null,delete s.array,delete s.object}else o=i.nil;s.number&&delete s.integer;for(let e in s)o=(0,i.and)(o,m(e,t,n,r));return o}e.checkDataTypes=h;var g={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e==`string`?(0,i._)`{type: ${e}}`:(0,i._)`{type: ${t}}`};function _(e){let t=v(e);(0,r.reportError)(t,g)}e.reportTypeError=_;function v(e){let{gen:t,data:n,schema:r}=e,i=(0,a.schemaRefOrVal)(e,r,`type`);return{gen:t,keyword:`type`,data:n,schema:r.type,schemaCode:i,schemaValue:i,parentSchema:r,params:{},it:e}}})),Mz=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.assignDefaults=void 0;var t=wz(),n=Tz();function r(e,t){let{properties:n,items:r}=e.schema;if(t===`object`&&n)for(let t in n)i(e,t,n[t].default);else t===`array`&&Array.isArray(r)&&r.forEach((t,n)=>i(e,n,t.default))}e.assignDefaults=r;function i(e,r,i){let{gen:a,compositeRule:o,data:s,opts:c}=e;if(i===void 0)return;let l=(0,t._)`${s}${(0,t.getProperty)(r)}`;if(o){(0,n.checkStrictMode)(e,`default is ignored for: ${l}`);return}let u=(0,t._)`${l} === undefined`;c.useDefaults===`empty`&&(u=(0,t._)`${u} || ${l} === null || ${l} === ""`),a.if(u,(0,t._)`${l} = ${(0,t.stringify)(i)}`)}})),Nz=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateUnion=e.validateArray=e.usePattern=e.callValidateCode=e.schemaProperties=e.allSchemaProperties=e.noPropertyInData=e.propertyInData=e.isOwnProperty=e.hasPropFunc=e.reportMissingProp=e.checkMissingProp=e.checkReportMissingProp=void 0;var t=wz(),n=Tz(),r=Ez(),i=Tz();function a(e,n){let{gen:r,data:i,it:a}=e;r.if(d(r,i,n,a.opts.ownProperties),()=>{e.setParams({missingProperty:(0,t._)`${n}`},!0),e.error()})}e.checkReportMissingProp=a;function o({gen:e,data:n,it:{opts:r}},i,a){return(0,t.or)(...i.map(i=>(0,t.and)(d(e,n,i,r.ownProperties),(0,t._)`${a} = ${i}`)))}e.checkMissingProp=o;function s(e,t){e.setParams({missingProperty:t},!0),e.error()}e.reportMissingProp=s;function c(e){return e.scopeValue(`func`,{ref:Object.prototype.hasOwnProperty,code:(0,t._)`Object.prototype.hasOwnProperty`})}e.hasPropFunc=c;function l(e,n,r){return(0,t._)`${c(e)}.call(${n}, ${r})`}e.isOwnProperty=l;function u(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} !== undefined`;return i?(0,t._)`${a} && ${l(e,n,r)}`:a}e.propertyInData=u;function d(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} === undefined`;return i?(0,t.or)(a,(0,t.not)(l(e,n,r))):a}e.noPropertyInData=d;function f(e){return e?Object.keys(e).filter(e=>e!==`__proto__`):[]}e.allSchemaProperties=f;function p(e,t){return f(t).filter(r=>!(0,n.alwaysValidSchema)(e,t[r]))}e.schemaProperties=p;function m({schemaCode:e,data:n,it:{gen:i,topSchemaRef:a,schemaPath:o,errorPath:s},it:c},l,u,d){let f=d?(0,t._)`${e}, ${n}, ${a}${o}`:n,p=[[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,s)],[r.default.parentData,c.parentData],[r.default.parentDataProperty,c.parentDataProperty],[r.default.rootData,r.default.rootData]];c.opts.dynamicRef&&p.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);let m=(0,t._)`${f}, ${i.object(...p)}`;return u===t.nil?(0,t._)`${l}(${m})`:(0,t._)`${l}.call(${u}, ${m})`}e.callValidateCode=m;var h=(0,t._)`new RegExp`;function g({gen:e,it:{opts:n}},r){let a=n.unicodeRegExp?`u`:``,{regExp:o}=n.code,s=o(r,a);return e.scopeValue(`pattern`,{key:s.toString(),ref:s,code:(0,t._)`${o.code===`new RegExp`?h:(0,i.useFunc)(e,o)}(${r}, ${a})`})}e.usePattern=g;function _(e){let{gen:r,data:i,keyword:a,it:o}=e,s=r.name(`valid`);if(o.allErrors){let e=r.let(`valid`,!0);return c(()=>r.assign(e,!1)),e}return r.var(s,!0),c(()=>r.break()),s;function c(o){let c=r.const(`len`,(0,t._)`${i}.length`);r.forRange(`i`,0,c,i=>{e.subschema({keyword:a,dataProp:i,dataPropType:n.Type.Num},s),r.if((0,t.not)(s),o)})}}e.validateArray=_;function v(e){let{gen:r,schema:i,keyword:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(i.some(e=>(0,n.alwaysValidSchema)(o,e))&&!o.opts.unevaluated)return;let s=r.let(`valid`,!1),c=r.name(`_valid`);r.block(()=>i.forEach((n,i)=>{let o=e.subschema({keyword:a,schemaProp:i,compositeRule:!0},c);r.assign(s,(0,t._)`${s} || ${c}`),e.mergeValidEvaluated(o,c)||r.if((0,t.not)(s))})),e.result(s,()=>e.reset(),()=>e.error(!0))}e.validateUnion=v})),Pz=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0;var t=wz(),n=Ez(),r=Nz(),i=Dz();function a(e,n){let{gen:r,keyword:i,schema:a,parentSchema:o,it:s}=e,c=n.macro.call(s.self,a,o,s),l=u(r,i,c);s.opts.validateSchema!==!1&&s.self.validateSchema(c,!0);let d=r.name(`valid`);e.subschema({schema:c,schemaPath:t.nil,errSchemaPath:`${s.errSchemaPath}/${i}`,topSchemaRef:l,compositeRule:!0},d),e.pass(d,()=>e.error(!0))}e.macroKeywordCode=a;function o(e,i){let{gen:a,keyword:o,schema:d,parentSchema:f,$data:p,it:m}=e;l(m,i);let h=u(a,o,!p&&i.compile?i.compile.call(m.self,d,f,m):i.validate),g=a.let(`valid`);e.block$data(g,_),e.ok(i.valid??g);function _(){if(i.errors===!1)b(),i.modifying&&s(e),x(()=>e.error());else{let t=i.async?v():y();i.modifying&&s(e),x(()=>c(e,t))}}function v(){let e=a.let(`ruleErrs`,null);return a.try(()=>b((0,t._)`await `),n=>a.assign(g,!1).if((0,t._)`${n} instanceof ${m.ValidationError}`,()=>a.assign(e,(0,t._)`${n}.errors`),()=>a.throw(n))),e}function y(){let e=(0,t._)`${h}.errors`;return a.assign(e,null),b(t.nil),e}function b(o=i.async?(0,t._)`await `:t.nil){let s=m.opts.passContext?n.default.this:n.default.self,c=!(`compile`in i&&!p||i.schema===!1);a.assign(g,(0,t._)`${o}${(0,r.callValidateCode)(e,h,s,c)}`,i.modifying)}function x(e){a.if((0,t.not)(i.valid??g),e)}}e.funcKeywordCode=o;function s(e){let{gen:n,data:r,it:i}=e;n.if(i.parentData,()=>n.assign(r,(0,t._)`${i.parentData}[${i.parentDataProperty}]`))}function c(e,r){let{gen:a}=e;a.if((0,t._)`Array.isArray(${r})`,()=>{a.assign(n.default.vErrors,(0,t._)`${n.default.vErrors} === null ? ${r} : ${n.default.vErrors}.concat(${r})`).assign(n.default.errors,(0,t._)`${n.default.vErrors}.length`),(0,i.extendErrors)(e)},()=>e.error())}function l({schemaEnv:e},t){if(t.async&&!e.$async)throw Error(`async keyword in sync schema`)}function u(e,n,r){if(r===void 0)throw Error(`keyword "${n}" failed to compile`);return e.scopeValue(`keyword`,typeof r==`function`?{ref:r}:{ref:r,code:(0,t.stringify)(r)})}function d(e,t,n=!1){return!t.length||t.some(t=>t===`array`?Array.isArray(e):t===`object`?e&&typeof e==`object`&&!Array.isArray(e):typeof e==t||n&&e===void 0)}e.validSchemaType=d;function f({schema:e,opts:t,self:n,errSchemaPath:r},i,a){if(Array.isArray(i.keyword)?!i.keyword.includes(a):i.keyword!==a)throw Error(`ajv implementation error`);let o=i.dependencies;if(o?.some(t=>!Object.prototype.hasOwnProperty.call(e,t)))throw Error(`parent schema must have dependencies of ${a}: ${o.join(`,`)}`);if(i.validateSchema&&!i.validateSchema(e[a])){let e=`keyword "${a}" value is invalid at path "${r}": `+n.errorsText(i.validateSchema.errors);if(t.validateSchema===`log`)n.logger.error(e);else throw Error(e)}}e.validateKeywordUsage=f})),Fz=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.extendSubschemaMode=e.extendSubschemaData=e.getSubschema=void 0;var t=wz(),n=Tz();function r(e,{keyword:r,schemaProp:i,schema:a,schemaPath:o,errSchemaPath:s,topSchemaRef:c}){if(r!==void 0&&a!==void 0)throw Error(`both "keyword" and "schema" passed, only one allowed`);if(r!==void 0){let a=e.schema[r];return i===void 0?{schema:a,schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${r}`}:{schema:a[i],schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}${(0,t.getProperty)(i)}`,errSchemaPath:`${e.errSchemaPath}/${r}/${(0,n.escapeFragment)(i)}`}}if(a!==void 0){if(o===void 0||s===void 0||c===void 0)throw Error(`"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"`);return{schema:a,schemaPath:o,topSchemaRef:c,errSchemaPath:s}}throw Error(`either "keyword" or "schema" must be passed`)}e.getSubschema=r;function i(e,r,{dataProp:i,dataPropType:a,data:o,dataTypes:s,propertyName:c}){if(o!==void 0&&i!==void 0)throw Error(`both "data" and "dataProp" passed, only one allowed`);let{gen:l}=r;if(i!==void 0){let{errorPath:o,dataPathArr:s,opts:c}=r;u(l.let(`data`,(0,t._)`${r.data}${(0,t.getProperty)(i)}`,!0)),e.errorPath=(0,t.str)`${o}${(0,n.getErrorPath)(i,a,c.jsPropertySyntax)}`,e.parentDataProperty=(0,t._)`${i}`,e.dataPathArr=[...s,e.parentDataProperty]}o!==void 0&&(u(o instanceof t.Name?o:l.let(`data`,o,!0)),c!==void 0&&(e.propertyName=c)),s&&(e.dataTypes=s);function u(t){e.data=t,e.dataLevel=r.dataLevel+1,e.dataTypes=[],r.definedProperties=new Set,e.parentData=r.data,e.dataNames=[...r.dataNames,t]}}e.extendSubschemaData=i;function a(e,{jtdDiscriminator:t,jtdMetadata:n,compositeRule:r,createErrors:i,allErrors:a}){r!==void 0&&(e.compositeRule=r),i!==void 0&&(e.createErrors=i),a!==void 0&&(e.allErrors=a),e.jtdDiscriminator=t,e.jtdMetadata=n}e.extendSubschemaMode=a})),Iz=s(((e,t)=>{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),Lz=s(((e,t)=>{var n=t.exports=function(e,t,n){typeof t==`function`&&(n=t,t={}),n=t.cb||n;var i=typeof n==`function`?n:n.pre||function(){},a=n.post||function(){};r(t,i,a,e,``,e)};n.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},n.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},n.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},n.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 r(e,t,a,o,s,c,l,u,d,f){if(o&&typeof o==`object`&&!Array.isArray(o)){for(var p in t(o,s,c,l,u,d,f),o){var m=o[p];if(Array.isArray(m)){if(p in n.arrayKeywords)for(var h=0;h<m.length;h++)r(e,t,a,m[h],s+`/`+p+`/`+h,c,s,p,o,h)}else if(p in n.propsKeywords){if(m&&typeof m==`object`)for(var g in m)r(e,t,a,m[g],s+`/`+p+`/`+i(g),c,s,p,o,g)}else(p in n.keywords||e.allKeys&&!(p in n.skipKeywords))&&r(e,t,a,m,s+`/`+p,c,s,p,o)}a(o,s,c,l,u,d,f)}}function i(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}})),Rz=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getSchemaRefs=e.resolveUrl=e.normalizeId=e._getFullPath=e.getFullPath=e.inlineRef=void 0;var t=Tz(),n=Iz(),r=Lz(),i=new Set([`type`,`format`,`pattern`,`maxLength`,`minLength`,`maxProperties`,`minProperties`,`maxItems`,`minItems`,`maximum`,`minimum`,`uniqueItems`,`multipleOf`,`required`,`enum`,`const`]);function a(e,t=!0){return typeof e==`boolean`?!0:t===!0?!s(e):t?c(e)<=t:!1}e.inlineRef=a;var o=new Set([`$ref`,`$recursiveRef`,`$recursiveAnchor`,`$dynamicRef`,`$dynamicAnchor`]);function s(e){for(let t in e){if(o.has(t))return!0;let n=e[t];if(Array.isArray(n)&&n.some(s)||typeof n==`object`&&s(n))return!0}return!1}function c(e){let n=0;for(let r in e)if(r===`$ref`||(n++,!i.has(r)&&(typeof e[r]==`object`&&(0,t.eachItem)(e[r],e=>n+=c(e)),n===1/0)))return 1/0;return n}function l(e,t=``,n){return n!==!1&&(t=f(t)),u(e,e.parse(t))}e.getFullPath=l;function u(e,t){return e.serialize(t).split(`#`)[0]+`#`}e._getFullPath=u;var d=/#\/?$/;function f(e){return e?e.replace(d,``):``}e.normalizeId=f;function p(e,t,n){return n=f(n),e.resolve(t,n)}e.resolveUrl=p;var m=/^[a-z_][-a-z0-9._]*$/i;function h(e,t){if(typeof e==`boolean`)return{};let{schemaId:i,uriResolver:a}=this.opts,o=f(e[i]||t),s={"":o},c=l(a,o,!1),u={},d=new Set;return r(e,{allKeys:!0},(e,t,n,r)=>{if(r===void 0)return;let a=c+t,o=s[r];typeof e[i]==`string`&&(o=l.call(this,e[i])),g.call(this,e.$anchor),g.call(this,e.$dynamicAnchor),s[t]=o;function l(t){let n=this.opts.uriResolver.resolve;if(t=f(o?n(o,t):t),d.has(t))throw h(t);d.add(t);let r=this.refs[t];return typeof r==`string`&&(r=this.refs[r]),typeof r==`object`?p(e,r.schema,t):t!==f(a)&&(t[0]===`#`?(p(e,u[t],t),u[t]=e):this.refs[t]=a),t}function g(e){if(typeof e==`string`){if(!m.test(e))throw Error(`invalid anchor "${e}"`);l.call(this,`#${e}`)}}}),u;function p(e,t,r){if(t!==void 0&&!n(e,t))throw h(r)}function h(e){return Error(`reference "${e}" resolves to more than one schema`)}}e.getSchemaRefs=h})),zz=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;var t=Oz(),n=jz(),r=Az(),i=jz(),a=Mz(),o=Pz(),s=Fz(),c=wz(),l=Ez(),u=Rz(),d=Tz(),f=Dz();function p(e){if(S(e)&&(w(e),x(e))){_(e);return}m(e,()=>(0,t.topBoolOrEmptySchema)(e))}e.validateFunctionCode=p;function m({gen:e,validateName:t,schema:n,schemaEnv:r,opts:i},a){i.code.es5?e.func(t,(0,c._)`${l.default.data}, ${l.default.valCxt}`,r.$async,()=>{e.code((0,c._)`"use strict"; ${y(n,i)}`),g(e,i),e.code(a)}):e.func(t,(0,c._)`${l.default.data}, ${h(i)}`,r.$async,()=>e.code(y(n,i)).code(a))}function h(e){return(0,c._)`{${l.default.instancePath}="", ${l.default.parentData}, ${l.default.parentDataProperty}, ${l.default.rootData}=${l.default.data}${e.dynamicRef?(0,c._)`, ${l.default.dynamicAnchors}={}`:c.nil}}={}`}function g(e,t){e.if(l.default.valCxt,()=>{e.var(l.default.instancePath,(0,c._)`${l.default.valCxt}.${l.default.instancePath}`),e.var(l.default.parentData,(0,c._)`${l.default.valCxt}.${l.default.parentData}`),e.var(l.default.parentDataProperty,(0,c._)`${l.default.valCxt}.${l.default.parentDataProperty}`),e.var(l.default.rootData,(0,c._)`${l.default.valCxt}.${l.default.rootData}`),t.dynamicRef&&e.var(l.default.dynamicAnchors,(0,c._)`${l.default.valCxt}.${l.default.dynamicAnchors}`)},()=>{e.var(l.default.instancePath,(0,c._)`""`),e.var(l.default.parentData,(0,c._)`undefined`),e.var(l.default.parentDataProperty,(0,c._)`undefined`),e.var(l.default.rootData,l.default.data),t.dynamicRef&&e.var(l.default.dynamicAnchors,(0,c._)`{}`)})}function _(e){let{schema:t,opts:n,gen:r}=e;m(e,()=>{n.$comment&&t.$comment&&A(e),D(e),r.let(l.default.vErrors,null),r.let(l.default.errors,0),n.unevaluated&&v(e),T(e),j(e)})}function v(e){let{gen:t,validateName:n}=e;e.evaluated=t.const(`evaluated`,(0,c._)`${n}.evaluated`),t.if((0,c._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,c._)`${e.evaluated}.props`,(0,c._)`undefined`)),t.if((0,c._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,c._)`${e.evaluated}.items`,(0,c._)`undefined`))}function y(e,t){let n=typeof e==`object`&&e[t.schemaId];return n&&(t.code.source||t.code.process)?(0,c._)`/*# sourceURL=${n} */`:c.nil}function b(e,n){if(S(e)&&(w(e),x(e))){C(e,n);return}(0,t.boolOrEmptySchema)(e,n)}function x({schema:e,self:t}){if(typeof e==`boolean`)return!e;for(let n in e)if(t.RULES.all[n])return!0;return!1}function S(e){return typeof e.schema!=`boolean`}function C(e,t){let{schema:n,gen:r,opts:i}=e;i.$comment&&n.$comment&&A(e),O(e),k(e);let a=r.const(`_errs`,l.default.errors);T(e,a),r.var(t,(0,c._)`${a} === ${l.default.errors}`)}function w(e){(0,d.checkUnknownRules)(e),E(e)}function T(e,t){if(e.opts.jtd)return N(e,[],!1,t);let r=(0,n.getSchemaTypes)(e.schema);N(e,r,!(0,n.coerceAndCheckDataType)(e,r),t)}function E(e){let{schema:t,errSchemaPath:n,opts:r,self:i}=e;t.$ref&&r.ignoreKeywordsWithRef&&(0,d.schemaHasRulesButRef)(t,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${n}"`)}function D(e){let{schema:t,opts:n}=e;t.default!==void 0&&n.useDefaults&&n.strictSchema&&(0,d.checkStrictMode)(e,`default is ignored in the schema root`)}function O(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,u.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function k(e){if(e.schema.$async&&!e.schemaEnv.$async)throw Error(`async schema in sync schema`)}function A({gen:e,schemaEnv:t,schema:n,errSchemaPath:r,opts:i}){let a=n.$comment;if(i.$comment===!0)e.code((0,c._)`${l.default.self}.logger.log(${a})`);else if(typeof i.$comment==`function`){let n=(0,c.str)`${r}/$comment`,i=e.scopeValue(`root`,{ref:t.root});e.code((0,c._)`${l.default.self}.opts.$comment(${a}, ${n}, ${i}.schema)`)}}function j(e){let{gen:t,schemaEnv:n,validateName:r,ValidationError:i,opts:a}=e;n.$async?t.if((0,c._)`${l.default.errors} === 0`,()=>t.return(l.default.data),()=>t.throw((0,c._)`new ${i}(${l.default.vErrors})`)):(t.assign((0,c._)`${r}.errors`,l.default.vErrors),a.unevaluated&&M(e),t.return((0,c._)`${l.default.errors} === 0`))}function M({gen:e,evaluated:t,props:n,items:r}){n instanceof c.Name&&e.assign((0,c._)`${t}.props`,n),r instanceof c.Name&&e.assign((0,c._)`${t}.items`,r)}function N(e,t,n,a){let{gen:o,schema:s,data:u,allErrors:f,opts:p,self:m}=e,{RULES:h}=m;if(s.$ref&&(p.ignoreKeywordsWithRef||!(0,d.schemaHasRulesButRef)(s,h))){o.block(()=>re(e,`$ref`,h.all.$ref.definition));return}p.jtd||F(e,t),o.block(()=>{for(let e of h.rules)g(e);g(h.post)});function g(d){(0,r.shouldUseGroup)(s,d)&&(d.type?(o.if((0,i.checkDataType)(d.type,u,p.strictNumbers)),P(e,d),t.length===1&&t[0]===d.type&&n&&(o.else(),(0,i.reportTypeError)(e)),o.endIf()):P(e,d),f||o.if((0,c._)`${l.default.errors} === ${a||0}`))}}function P(e,t){let{gen:n,schema:i,opts:{useDefaults:o}}=e;o&&(0,a.assignDefaults)(e,t.type),n.block(()=>{for(let n of t.rules)(0,r.shouldUseRule)(i,n)&&re(e,n.keyword,n.definition,t.type)})}function F(e,t){!e.schemaEnv.meta&&e.opts.strictTypes&&(I(e,t),e.opts.allowUnionTypes||L(e,t),ee(e,e.dataTypes))}function I(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(t=>{ne(e.dataTypes,t)||z(e,`type "${t}" not allowed by context "${e.dataTypes.join(`,`)}"`)}),R(e,t)}}function L(e,t){t.length>1&&!(t.length===2&&t.includes(`null`))&&z(e,`use allowUnionTypes to allow union type keyword`)}function ee(e,t){let n=e.self.RULES.all;for(let i in n){let a=n[i];if(typeof a==`object`&&(0,r.shouldUseRule)(e.schema,a)){let{type:n}=a.definition;n.length&&!n.some(e=>te(t,e))&&z(e,`missing type "${n.join(`,`)}" for keyword "${i}"`)}}}function te(e,t){return e.includes(t)||t===`number`&&e.includes(`integer`)}function ne(e,t){return e.includes(t)||t===`integer`&&e.includes(`number`)}function R(e,t){let n=[];for(let r of e.dataTypes)ne(t,r)?n.push(r):t.includes(`integer`)&&r===`number`&&n.push(`integer`);e.dataTypes=n}function z(e,t){let n=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${n}" (strictTypes)`,(0,d.checkStrictMode)(e,t,e.opts.strictTypes)}var B=class{constructor(e,t,n){if((0,o.validateKeywordUsage)(e,t,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,d.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const(`vSchema`,oe(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,o.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw Error(`${n} value must be ${JSON.stringify(t.schemaType)}`);(`code`in t?t.trackErrors:t.errors!==!1)&&(this.errsCount=e.gen.const(`_errs`,l.default.errors))}result(e,t,n){this.failResult((0,c.not)(e),t,n)}failResult(e,t,n){this.gen.if(e),n?n():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,c.not)(e),void 0,t)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:t}=this;this.fail((0,c._)`${t} !== undefined && (${(0,c.or)(this.invalid$data(),e)})`)}error(e,t,n){if(t){this.setParams(t),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,t){(e?f.reportExtraError:f.reportError)(this,this.def.error,t)}$dataError(){(0,f.reportError)(this,this.def.$dataError||f.keyword$DataError)}reset(){if(this.errsCount===void 0)throw Error(`add "trackErrors" to keyword definition`);(0,f.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,n=c.nil){this.gen.block(()=>{this.check$data(e,n),t()})}check$data(e=c.nil,t=c.nil){if(!this.$data)return;let{gen:n,schemaCode:r,schemaType:i,def:a}=this;n.if((0,c.or)((0,c._)`${r} === undefined`,t)),e!==c.nil&&n.assign(e,!0),(i.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==c.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:t,schemaType:n,def:r,it:a}=this;return(0,c.or)(o(),s());function o(){if(n.length){if(!(t instanceof c.Name))throw Error(`ajv implementation error`);let e=Array.isArray(n)?n:[n];return(0,c._)`${(0,i.checkDataTypes)(e,t,a.opts.strictNumbers,i.DataType.Wrong)}`}return c.nil}function s(){if(r.validateSchema){let n=e.scopeValue(`validate$data`,{ref:r.validateSchema});return(0,c._)`!${n}(${t})`}return c.nil}}subschema(e,t){let n=(0,s.getSubschema)(this.it,e);(0,s.extendSubschemaData)(n,this.it,e),(0,s.extendSubschemaMode)(n,e);let r={...this.it,...n,items:void 0,props:void 0};return b(r,t),r}mergeEvaluated(e,t){let{it:n,gen:r}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=d.mergeEvaluated.props(r,e.props,n.props,t)),n.items!==!0&&e.items!==void 0&&(n.items=d.mergeEvaluated.items(r,e.items,n.items,t)))}mergeValidEvaluated(e,t){let{it:n,gen:r}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return r.if(t,()=>this.mergeEvaluated(e,c.Name)),!0}};e.KeywordCxt=B;function re(e,t,n,r){let i=new B(e,n,t);`code`in n?n.code(i,r):i.$data&&n.validate?(0,o.funcKeywordCode)(i,n):`macro`in n?(0,o.macroKeywordCode)(i,n):(n.compile||n.validate)&&(0,o.funcKeywordCode)(i,n)}var ie=/^\/(?:[^~]|~0|~1)*$/,ae=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function oe(e,{dataLevel:t,dataNames:n,dataPathArr:r}){let i,a;if(e===``)return l.default.rootData;if(e[0]===`/`){if(!ie.test(e))throw Error(`Invalid JSON-pointer: ${e}`);i=e,a=l.default.rootData}else{let o=ae.exec(e);if(!o)throw Error(`Invalid JSON-pointer: ${e}`);let s=+o[1];if(i=o[2],i===`#`){if(s>=t)throw Error(u(`property/index`,s));return r[t-s]}if(s>t)throw Error(u(`data`,s));if(a=n[t-s],!i)return a}let o=a,s=i.split(`/`);for(let e of s)e&&(a=(0,c._)`${a}${(0,c.getProperty)((0,d.unescapeJsonPointer)(e))}`,o=(0,c._)`${o} && ${a}`);return o;function u(e,n){return`Cannot access ${e} ${n} levels up, current level is ${t}`}}e.getData=oe})),Bz=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=class extends Error{constructor(e){super(`validation failed`),this.errors=e,this.ajv=this.validation=!0}}})),Vz=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Rz();e.default=class extends Error{constructor(e,n,r,i){super(i||`can't resolve reference ${r} from id ${n}`),this.missingRef=(0,t.resolveUrl)(e,n,r),this.missingSchema=(0,t.normalizeId)((0,t.getFullPath)(e,this.missingRef))}}})),Hz=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;var t=wz(),n=Bz(),r=Ez(),i=Rz(),a=Tz(),o=zz(),s=class{constructor(e){this.refs={},this.dynamicAnchors={};let t;typeof e.schema==`object`&&(t=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=e.baseId??(0,i.normalizeId)(t?.[e.schemaId||`$id`]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=t?.$async,this.refs={}}};e.SchemaEnv=s;function c(e){let a=d.call(this,e);if(a)return a;let s=(0,i.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:c,lines:l}=this.opts.code,{ownProperties:u}=this.opts,f=new t.CodeGen(this.scope,{es5:c,lines:l,ownProperties:u}),p;e.$async&&(p=f.scopeValue(`Error`,{ref:n.default,code:(0,t._)`require("ajv/dist/runtime/validation_error").default`}));let m=f.scopeName(`validate`);e.validateName=m;let h={gen:f,allErrors:this.opts.allErrors,data:r.default.data,parentData:r.default.parentData,parentDataProperty:r.default.parentDataProperty,dataNames:[r.default.data],dataPathArr:[t.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:f.scopeValue(`schema`,this.opts.code.source===!0?{ref:e.schema,code:(0,t.stringify)(e.schema)}:{ref:e.schema}),validateName:m,ValidationError:p,schema:e.schema,schemaEnv:e,rootId:s,baseId:e.baseId||s,schemaPath:t.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?``:`#`),errorPath:(0,t._)`""`,opts:this.opts,self:this},g;try{this._compilations.add(e),(0,o.validateFunctionCode)(h),f.optimize(this.opts.code.optimize);let n=f.toString();g=`${f.scopeRefs(r.default.scope)}return ${n}`,this.opts.code.process&&(g=this.opts.code.process(g,e));let i=Function(`${r.default.self}`,`${r.default.scope}`,g)(this,this.scope.get());if(this.scope.value(m,{ref:i}),i.errors=null,i.schema=e.schema,i.schemaEnv=e,e.$async&&(i.$async=!0),this.opts.code.source===!0&&(i.source={validateName:m,validateCode:n,scopeValues:f._values}),this.opts.unevaluated){let{props:e,items:n}=h;i.evaluated={props:e instanceof t.Name?void 0:e,items:n instanceof t.Name?void 0:n,dynamicProps:e instanceof t.Name,dynamicItems:n instanceof t.Name},i.source&&(i.source.evaluated=(0,t.stringify)(i.evaluated))}return e.validate=i,e}catch(t){throw delete e.validate,delete e.validateName,g&&this.logger.error(`Error compiling schema, function code:`,g),t}finally{this._compilations.delete(e)}}e.compileSchema=c;function l(e,t,n){n=(0,i.resolveUrl)(this.opts.uriResolver,t,n);let r=e.refs[n];if(r)return r;let a=p.call(this,e,n);if(a===void 0){let r=e.localRefs?.[n],{schemaId:i}=this.opts;r&&(a=new s({schema:r,schemaId:i,root:e,baseId:t}))}if(a!==void 0)return e.refs[n]=u.call(this,a)}e.resolveRef=l;function u(e){return(0,i.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:c.call(this,e)}function d(e){for(let t of this._compilations)if(f(t,e))return t}e.getCompilingSchema=d;function f(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function p(e,t){let n;for(;typeof(n=this.refs[t])==`string`;)t=n;return n||this.schemas[t]||m.call(this,e,t)}function m(e,t){let n=this.opts.uriResolver.parse(t),r=(0,i._getFullPath)(this.opts.uriResolver,n),a=(0,i.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&r===a)return g.call(this,n,e);let o=(0,i.normalizeId)(r),l=this.refs[o]||this.schemas[o];if(typeof l==`string`){let t=m.call(this,e,l);return typeof t?.schema==`object`?g.call(this,n,t):void 0}if(typeof l?.schema==`object`){if(l.validate||c.call(this,l),o===(0,i.normalizeId)(t)){let{schema:t}=l,{schemaId:n}=this.opts,r=t[n];return r&&(a=(0,i.resolveUrl)(this.opts.uriResolver,a,r)),new s({schema:t,schemaId:n,root:e,baseId:a})}return g.call(this,n,l)}}e.resolveSchema=m;var h=new Set([`properties`,`patternProperties`,`enum`,`dependencies`,`definitions`]);function g(e,{baseId:t,schema:n,root:r}){if(e.fragment?.[0]!==`/`)return;for(let r of e.fragment.slice(1).split(`/`)){if(typeof n==`boolean`)return;let e=n[(0,a.unescapeFragment)(r)];if(e===void 0)return;n=e;let o=typeof n==`object`&&n[this.opts.schemaId];!h.has(r)&&o&&(t=(0,i.resolveUrl)(this.opts.uriResolver,t,o))}let o;if(typeof n!=`boolean`&&n.$ref&&!(0,a.schemaHasRulesButRef)(n,this.RULES)){let e=(0,i.resolveUrl)(this.opts.uriResolver,t,n.$ref);o=m.call(this,r,e)}let{schemaId:c}=this.opts;if(o||=new s({schema:n,schemaId:c,root:r,baseId:t}),o.schema!==o.root.schema)return o}})),Uz=c({$id:()=>Wz,additionalProperties:()=>!1,default:()=>Yz,description:()=>Gz,properties:()=>Jz,required:()=>qz,type:()=>Kz}),Wz,Gz,Kz,qz,Jz,Yz,Xz=o((()=>{Wz=`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`,Gz=`Meta-schema for $data reference (JSON AnySchema extension proposal)`,Kz=`object`,qz=[`$data`],Jz={$data:{type:`string`,anyOf:[{format:`relative-json-pointer`},{format:`json-pointer`}]}},Yz={$id:Wz,description:Gz,type:Kz,required:qz,properties:Jz,additionalProperties:!1}})),Zz=s(((e,t)=>{var n=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),r=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),i=RegExp.prototype.test.bind(/^\d*$/u),a=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),o=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),s=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u),c=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u),l=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u),u=Array(256);{let e=`0123456789ABCDEF`;for(let t=0;t<256;t++)u[t]=`%`+e[t>>4]+e[t&15]}function d(e){return e<2048?u[192|e>>6]+u[128|e&63]:e<65536?u[224|e>>12]+u[128|e>>6&63]+u[128|e&63]:u[240|e>>18]+u[128|e>>12&63]+u[128|e>>6&63]+u[128|e&63]}function f(e){let t=``,n=0,r=0;for(r=0;r<e.length;r++)if(n=e[r].charCodeAt(0),n!==48){if(!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r];break}for(r+=1;r<e.length;r++){if(n=e[r].charCodeAt(0),!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r]}return t}var p=RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/),m=RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/),h=RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/),g=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function _(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++)if(!h(e[t])){if(e[t]===`%`&&t+2<e.length&&a(e.slice(t+1,t+3))){t+=2;continue}return!1}return!0}function v(e){let t=-1,n=0,r=-1,i=0;for(let a=0;a<e.length;a++)e[a]===`0`?(r===-1&&(r=a),i++,i>n&&(n=i,t=r)):(r=-1,i=0);if(n<2)return e.join(`:`);let a=e.slice(0,t).join(`:`),o=e.slice(t+n).join(`:`);return a+`::`+o}function y(e){let t=e.indexOf(`::`);if(t!==-1&&e.indexOf(`::`,t+1)!==-1)return;let n=t===-1?e.split(`:`):e.slice(0,t).split(`:`),i=t===-1?[]:e.slice(t+2).split(`:`);t!==-1&&(n.length===1&&n[0]===``&&(n.length=0),i.length===1&&i[0]===``&&(i.length=0));let a=n.concat(i),o=0;for(let e=0;e<a.length;e++){let n=a[e];if(n===``)return;if(n.indexOf(`.`)!==-1){if(e!==a.length-1||t!==-1&&i.length===0||!r(n))return;o+=2;continue}if(!p(n))return;a[e]=parseInt(n,16).toString(16),o++}if(t===-1)return o===8?v(a):void 0;if(o>=8)return;let s=a.slice(0,n.length);for(let e=o;e<8;e++)s.push(`0`);for(let e=n.length;e<a.length;e++)s.push(a[e]);return v(s)}function b(e){let t=e[0]===`[`&&e[e.length-1]===`]`;if((e[0]===`[`||e[e.length-1]===`]`)&&!t)return{host:e,isIPV6:!1,error:!0};let n=t?e.slice(1,-1):e;if(t&&m(n))return n=n.toLowerCase(),{host:`[${n}]`,escapedHost:n,isIPV6:!1,isIPVFuture:!0};if(x(n,`:`)<2)return{host:e,isIPV6:!1,error:t};let r=``,i=n.indexOf(`%`);if(i!==-1){let t=n.slice(i,i+3).toLowerCase()===`%25`?3:1;if(r=n.slice(i+t),!_(r))return{host:e,isIPV6:!1,error:!0};n=n.slice(0,i)}let a=y(n);return a===void 0?{host:e,isIPV6:!1,error:!0}:{host:a+(r?`%`+r:``),escapedHost:a+(r?`%25`+r:``),isIPV6:!0}}function x(e,t){let n=0;for(let r=0;r<e.length;r++)e[r]===t&&n++;return n}function S(e){let t=e,n=[],r=-1,i=0;for(;i=t.length;){if(i===1){if(t===`.`)break;if(t===`/`){n.push(`/`);break}n.push(t);break}if(i===2){if(t[0]===`.`){if(t[1]===`.`)break;if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&(t[1]===`.`||t[1]===`/`)){n.push(`/`);break}}else if(i===3&&t===`/..`){n.length!==0&&n.pop(),n.push(`/`);break}if(t[0]===`.`){if(t[1]===`.`){if(t[2]===`/`){t=t.slice(3);continue}}else if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&t[1]===`.`){if(t[2]===`/`){t=t.slice(2);continue}if(t[2]===`.`&&t[3]===`/`){t=t.slice(3),n.length!==0&&n.pop();continue}}if((r=t.indexOf(`/`,1))===-1){n.push(t);break}n.push(t.slice(0,r)),t=t.slice(r)}return n.join(``)}var C={"@":`%40`,"/":`%2F`,"?":`%3F`,"#":`%23`,":":`%3A`},w=/[@/?#:]/g,T=/[@/?#]/g;function E(e,t){let n=t?T:w;return n.lastIndex=0,e.replace(n,e=>C[e])}function D(e,t=!1){if(e.indexOf(`%`)===-1)return e;let n=``;for(let r=0;r<e.length;r++){if(e[r]===`%`&&r+2<e.length){let i=e.slice(r+1,r+3);if(a(i)){let e=i.toUpperCase(),a=String.fromCharCode(parseInt(e,16));t&&o(a)?n+=a:n+=`%`+e,r+=2;continue}}n+=e[r]}return n}function O(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(r===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(a(r)){let e=r.toUpperCase(),i=String.fromCharCode(parseInt(e,16));i!==`.`&&o(i)?t+=i:t+=`%`+e,n+=2;continue}}if(s(r))t+=r;else{let i=e.charCodeAt(n);if(i<128)t+=P(i)?r:u[i];else if(i<55296||i>57343)t+=d(i);else if(i<=56319&&n+1<e.length){let r=e.charCodeAt(n+1);r>=56320&&r<=57343?(t+=d(65536+(i-55296<<10)+(r-56320)),n++):t+=d(65533)}else t+=d(65533)}}return t}function k(e,t=!1){let n=``,r=t&&e[0]!==`/`;for(let t=0;t<e.length;t++){let i=e[t];if(i===`%`&&t+2<e.length){let r=e.slice(t+1,t+3);if(a(r)){n+=`%`+r.toUpperCase(),t+=2;continue}}if(i===`/`&&(r=!1),s(i)&&(i!==`:`||!r))n+=i;else{let r=e.charCodeAt(t);if(r<128)n+=u[r];else if(r<55296||r>57343)n+=d(r);else if(r<=56319&&t+1<e.length){let i=e.charCodeAt(t+1);i>=56320&&i<=57343?(n+=d(65536+(r-55296<<10)+(i-56320)),t++):n+=d(65533)}else n+=d(65533)}}return n}function A(e,t){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(i===`%`&&r+2<e.length){let t=e.slice(r+1,r+3);if(a(t)){n+=`%`+t.toUpperCase(),r+=2;continue}}if(t(i))n+=i;else{let t=e.charCodeAt(r);if(t<128)n+=u[t];else if(t<55296||t>57343)n+=d(t);else if(t<=56319&&r+1<e.length){let i=e.charCodeAt(r+1);i>=56320&&i<=57343?(n+=d(65536+(t-55296<<10)+(i-56320)),r++):n+=d(65533)}else n+=d(65533)}}return n}function j(e){return A(e,l)}function M(e){return A(e,c)}function N(e){return A(e,c)}function P(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===42||e===43||e===45||e===46||e===47||e===64||e===95}function F(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(r===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(a(r)){let e=r.toUpperCase(),i=String.fromCharCode(parseInt(e,16));o(i)?t+=i:t+=`%`+e,n+=2;continue}}if(c(r))t+=r;else{let i=e.charCodeAt(n);if(i<128)t+=P(i)?r:u[i];else if(i<55296||i>57343)t+=d(i);else if(i<=56319&&n+1<e.length){let r=e.charCodeAt(n+1);r>=56320&&r<=57343?(t+=d(65536+(i-55296<<10)+(r-56320)),n++):t+=d(65533)}else t+=d(65533)}}return t}function I(e){let t=``;for(let n=0;n<e.length;n++){if(e[n]===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(a(r)){t+=`%`+r.toUpperCase(),n+=2;continue}}t+=escape(e[n])}return t}function L(e){let t=[];if(e.userinfo!==void 0&&(t.push(j(e.userinfo)),t.push(`@`)),e.host!==void 0){let n=e.host;if(!r(n)){let e=b(n);e.isIPV6!==!0&&e.isIPVFuture!==!0&&(n=D(n,!0),e=b(n)),n=e.isIPV6===!0||e.isIPVFuture===!0?`[${e.escapedHost}]`:E(n,!1)}t.push(n)}if(typeof e.port==`number`||typeof e.port==`string`){let n=String(e.port);if(!i(n))throw TypeError(`URI port is malformed.`);t.push(`:`),t.push(n)}return t.length?t.join(``):void 0}t.exports={nonSimpleDomain:g,recomposeAuthority:L,reescapeHostDelimiters:E,normalizePercentEncoding:D,normalizePathEncoding:O,serializePathEncoding:k,normalizeQueryFragmentEncoding:F,encodeUserinfo:j,encodeQuery:M,encodeFragment:N,escapePreservingEscapes:I,removeDotSegments:S,isIPv4:r,isUUID:n,normalizeIPv6:b,stringArrayToHexStripped:f}})),Qz=s(((e,t)=>{var{isUUID:n}=Zz(),r=/^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu,i=[`http`,`https`,`ws`,`wss`,`urn`,`urn:uuid`];function a(e){return i.indexOf(e)!==-1}function o(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]===`w`||e.scheme[0]===`W`)&&(e.scheme[1]===`s`||e.scheme[1]===`S`)&&(e.scheme[2]===`s`||e.scheme[2]===`S`):!1}function s(e){return e.host||(e.error=e.error||`HTTP URIs must have a host.`),e}function c(e){let t=String(e.scheme).toLowerCase()===`https`;return(e.port===(t?443:80)||e.port===``)&&(e.port=void 0),e.path||=`/`,e}function l(e){return e.secure=o(e),e.resourceName=(e.path||`/`)+(e.query?`?`+e.query:``),e.path=void 0,e.query=void 0,e}function u(e){if((e.port===(o(e)?443:80)||e.port===``)&&(e.port=void 0),typeof e.secure==`boolean`&&(e.scheme=e.secure?`wss`:`ws`,e.secure=void 0),e.resourceName){let t=e.resourceName.indexOf(`?`),n=t===-1?e.resourceName:e.resourceName.slice(0,t);e.path=n&&n!==`/`?n:void 0,e.query=t===-1?void 0:e.resourceName.slice(t+1),e.resourceName=void 0}return e.fragment=void 0,e}function d(e,t){if(!e.path)return e.error=`URN can not be parsed`,e;let n=e.path.match(r);if(n&&n[0]===e.path){let r=t.scheme||e.scheme||`urn`;e.nid=n[1].toLowerCase(),e.nss=n[2];let i=y(`${r}:${t.nid||e.nid}`);e.path=void 0,i&&(e=i.parse(e,t))}else e.error=e.error||`URN can not be parsed.`;return e}function f(e,t){if(e.nid===void 0)throw Error(`URN without nid cannot be serialized`);let n=t.scheme||e.scheme||`urn`,r=e.nid.toLowerCase(),i=y(`${n}:${t.nid||r}`);i&&(e=i.serialize(e,t));let a=e,o=e.nss;return a.path=`${r||t.nid}:${o}`,t.skipEscape=!0,a}function p(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!n(r.uuid))&&(r.error=r.error||`UUID is not valid.`),r}function m(e){let t=e;return t.nss=(e.uuid||``).toLowerCase(),t}var h={scheme:`http`,domainHost:!0,parse:s,serialize:c},g={scheme:`https`,domainHost:h.domainHost,parse:s,serialize:c},_={scheme:`ws`,domainHost:!0,parse:l,serialize:u},v={http:h,https:g,ws:_,wss:{scheme:`wss`,domainHost:_.domainHost,parse:_.parse,serialize:_.serialize},urn:{scheme:`urn`,parse:d,serialize:f,skipNormalize:!0},"urn:uuid":{scheme:`urn:uuid`,parse:p,serialize:m,skipNormalize:!0}};Object.setPrototypeOf(v,null);function y(e){return e&&(v[e]||v[e.toLowerCase()])||void 0}t.exports={wsIsSecure:o,SCHEMES:v,isValidSchemeName:a,getSchemeHandler:y}})),$z=s(((e,t)=>{var{normalizeIPv6:n,removeDotSegments:r,recomposeAuthority:i,normalizePercentEncoding:a,normalizePathEncoding:o,serializePathEncoding:s,normalizeQueryFragmentEncoding:c,encodeQuery:l,encodeFragment:u,reescapeHostDelimiters:d,isIPv4:f,nonSimpleDomain:p}=Zz(),{SCHEMES:m,getSchemeHandler:h}=Qz(),g=/^[A-Za-z][A-Za-z0-9+.-]*$/u,_=`URI scheme is malformed.`;function v(e){let t=unescape(String(e));if(!g.test(t))throw TypeError(_);return t}function y(e,t){return typeof e==`string`?e=P(e,t):typeof e==`object`&&(e=N(C(e,t),t)),e}function b(e,t,r){let i=r?Object.assign({scheme:`null`},r):{scheme:`null`},{parsed:a,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:c,malformedHost:l,malformedScheme:u}=M(e,i),{parsed:d,malformedAuthorityOrPort:p,malformedPercentEncoding:m,malformedSchemeSpecific:g,malformedHost:_,malformedScheme:v}=M(t,i);if(o||p||s||m||c||g||l||_||u||v)throw Error(a.error||d.error||`URI is malformed.`);let y=x(a,d,i,!0),b=h(r&&r.scheme||y.scheme),S=y.host,w=S!==void 0&&S!==``&&(f(S)||n(S).isIPV6);j(y,r||{},b,w);let T=S&&S.indexOf(`%`)!==-1&&!/\P{ASCII}/u.test(S);if(y.error&&!T)throw Error(y.error);return i.skipEscape=!0,C(y,i)}function x(e,t,n,i){let a={};return i||(e=N(C(e,n),n),t=N(C(t,n),n)),n||={},!n.tolerant&&t.scheme?(a.scheme=t.scheme,a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.path?(t.path[0]===`/`?a.path=r(t.path):(a.path=(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?`/`+t.path:e.path?e.path.slice(0,e.path.lastIndexOf(`/`)+1)+t.path:t.path,a.path=r(a.path)),a.query=t.query):(a.path=e.path,a.query=t.query===void 0?e.query:t.query),a.userinfo=e.userinfo,a.host=e.host,a.port=e.port),a.scheme=e.scheme),a.fragment=t.fragment,a}function S(e,t,n){let r=I(e,n),i=I(t,n);return r!==void 0&&i!==void 0&&r===i}function C(e,t){let n={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:``},o=Object.assign({},t),c=[];n.scheme&&=v(n.scheme);let d=h(o.scheme||n.scheme);d&&d.serialize&&d.serialize(n,o);let f=n.userinfo!==void 0||n.host!==void 0||n.port!==void 0,p=!o.skipEscape&&n.scheme===void 0&&!f;n.path!==void 0&&(n.path=o.skipEscape?a(n.path):s(n.path,p)),o.reference!==`suffix`&&n.scheme&&(n.scheme=v(n.scheme),c.push(n.scheme,`:`));let m=i(n);if(m!==void 0&&(o.reference!==`suffix`&&c.push(`//`),c.push(m),n.path&&n.path[0]!==`/`&&c.push(`/`)),n.path!==void 0){let e=n.path;!o.absolutePath&&(!d||!d.absolutePath)&&(e=r(e)),p&&(e=s(e,!0)),m===void 0&&e[0]===`/`&&e[1]===`/`&&(e=`/%2F`+e.slice(2)),c.push(e)}return n.query!==void 0&&c.push(`?`,l(n.query)),n.fragment!==void 0&&c.push(`#`,u(n.fragment)),c.join(``)}var w=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,T=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,E=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function D(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!==`/`)return`URI path must start with "/" when authority is present.`;if(typeof e.port==`number`&&(e.port<0||e.port>65535))return`URI port is malformed.`}function O(e){if(e===void 0)return!1;let t=e.indexOf(`%`);for(;t!==-1;){if(t+2>=e.length||!/^[\da-f]{2}$/iu.test(e.slice(t+1,t+3)))return!0;t=e.indexOf(`%`,t+3)}return!1}function k(e){return e[0]===`[`&&e[e.length-1]===`]`}function A(e){let t=e[4];return O(e[3])||t!==void 0&&!k(t)&&O(t)||O(e[6])||O(e[7])||O(e[8])}function j(e,t,n,r){if(!t.unicodeSupport&&(!n||!n.unicodeSupport)&&e.host&&!k(e.host)&&(t.domainHost||n&&n.domainHost)&&r===!1&&p(e.host))try{e.host=new URL(`http://`+e.host).hostname}catch(t){return e.error=e.error||`Host's domain name can not be converted to ASCII: `+t,!0}return!1}function M(e,t){let r=Object.assign({},t),i={scheme:void 0,userinfo:void 0,host:``,port:void 0,path:``,query:void 0,fragment:void 0},s=!1,l=!1,u=!1,p=!1,v=!1,y=!1,b=!1;r.reference===`suffix`&&(e=r.scheme?r.scheme+`:`+e:`//`+e);let x=e.match(T);x!==null&&x[1].indexOf(`\\`)!==-1&&(i.error=`URI authority must not contain a literal backslash.`,s=!0);let S=e.match(E);if(S!==null){let e=S[1],t=e.replace(/[\t\n\r]/g,``);t.length>=2&&(t.slice(0,2)===`//`?e.length!==t.length&&(i.error=i.error||`URI authority introducer must not contain whitespace.`,s=!0):(i.error=i.error||`URI authority must not contain a literal backslash.`,s=!0))}let C=e.match(w);if(C){if(i.scheme=C[1],i.userinfo=C[3],i.host=C[4],i.port=parseInt(C[5],10),i.path=C[6]||``,i.query=C[7],i.fragment=C[8],i.scheme!==void 0){let e=unescape(i.scheme);g.test(e)?i.scheme=e.toLowerCase():(i.error=i.error||_,y=!0)}l=A(C),l&&(i.error=i.error||`URI contains malformed percent-encoding.`),isNaN(i.port)&&(i.port=C[5]);let t=D(i,C);if(t!==void 0&&(i.error=i.error||t,s=!0),i.host){if(f(i.host)===!1){let e=k(i.host),t=i.host.indexOf(`[`)!==-1||i.host.indexOf(`]`)!==-1,r=n(i.host);b=r.isIPV6||r.isIPVFuture===!0,v=t&&(!e||r.error===!0),i.host=b?r.host:r.host.toLowerCase(),v&&(i.error=i.error||`URI host is malformed.`,s=!0)}else b=!0}i.reference=i.scheme===void 0&&i.userinfo===void 0&&i.host===void 0&&i.port===void 0&&i.query===void 0&&!i.path?`same-document`:i.scheme===void 0?`relative`:i.fragment===void 0?`absolute`:`uri`,r.reference&&r.reference!==`suffix`&&r.reference!==i.reference&&(i.error=i.error||`URI is not a `+r.reference+` reference.`);let x=h(r.scheme||i.scheme);if(v||(p=j(i,r,x,b)),e.indexOf(`%`)!==-1&&i.host!==void 0&&!v){let e=b?i.host:a(i.host,!0);b||(e=a(e.toLowerCase())),i.host=d(e,b)}(!x||x&&!x.skipNormalize)&&(i.path&&=o(i.path),i.query&&=c(i.query),i.fragment&&=c(i.fragment)),x&&x.parse&&(x.parse(i,r),x===m.urn&&i.nid===void 0&&(u=!0))}else i.error=i.error||`URI can not be parsed.`;return{parsed:i,malformedAuthorityOrPort:s,malformedPercentEncoding:l,malformedSchemeSpecific:u,malformedHost:p,malformedScheme:y}}function N(e,t){return M(e,t).parsed}function P(e,t){return F(e,t).normalized}function F(e,t){let{parsed:n,malformedAuthorityOrPort:r,malformedPercentEncoding:i,malformedSchemeSpecific:a,malformedHost:o,malformedScheme:s}=M(e,t);return{normalized:r||i||a||o||s?e:C(n,t),malformedAuthorityOrPort:r,malformedPercentEncoding:i,malformedSchemeSpecific:a,malformedHost:o,malformedScheme:s}}function I(e,t){if(typeof e!=`string`&&typeof e!=`object`)return;let n;try{n=typeof e==`string`?e:C(e,t)}catch{return}let{normalized:r,malformedAuthorityOrPort:i,malformedPercentEncoding:a,malformedSchemeSpecific:o,malformedHost:s,malformedScheme:c}=F(n,t);return i||a||o||s||c?void 0:r}var L={SCHEMES:m,normalize:y,resolve:b,resolveComponent:x,equal:S,serialize:C,parse:N};t.exports=L,t.exports.default=L,t.exports.fastUri=L})),eB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=$z();t.code=`require("ajv/dist/runtime/uri").default`,e.default=t})),tB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=zz();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var n=wz();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return n.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return n.CodeGen}});var r=Bz(),i=Vz(),a=kz(),o=Hz(),s=wz(),c=Rz(),l=jz(),u=Tz(),f=(Xz(),d(Uz).default),p=eB(),m=(e,t)=>new RegExp(e,t);m.code=`new RegExp`;var h=[`removeAdditional`,`useDefaults`,`coerceTypes`],g=new Set([`validate`,`serialize`,`parse`,`wrapper`,`root`,`schema`,`keyword`,`pattern`,`formats`,`validate$data`,`func`,`obj`,`Error`]),_={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.`},v={ignoreKeywordsWithRef:``,jsPropertySyntax:``,unicode:`"minLength"/"maxLength" account for unicode characters by default.`},y=200;function b(e){let t=e.strict,n=e.code?.optimize,r=n===!0||n===void 0?1:n||0,i=e.code?.regExp??m,a=e.uriResolver??p.default;return{strictSchema:e.strictSchema??t??!0,strictNumbers:e.strictNumbers??t??!0,strictTypes:e.strictTypes??t??`log`,strictTuples:e.strictTuples??t??`log`,strictRequired:e.strictRequired??t??!1,code:e.code?{...e.code,optimize:r,regExp:i}:{optimize:r,regExp:i},loopRequired:e.loopRequired??y,loopEnum:e.loopEnum??y,meta:e.meta??!0,messages:e.messages??!0,inlineRefs:e.inlineRefs??!0,schemaId:e.schemaId??`$id`,addUsedSchema:e.addUsedSchema??!0,validateSchema:e.validateSchema??!0,validateFormats:e.validateFormats??!0,unicodeRegExp:e.unicodeRegExp??!0,int32range:e.int32range??!0,uriResolver:a}}var x=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...b(e)};let{es5:t,lines:n}=this.opts.code;this.scope=new s.ValueScope({scope:{},prefixes:g,es5:t,lines:n}),this.logger=k(e.logger);let r=e.validateFormats;e.validateFormats=!1,this.RULES=(0,a.getRules)(),S.call(this,_,e,`NOT SUPPORTED`),S.call(this,v,e,`DEPRECATED`,`warn`),this._metaOpts=D.call(this),e.formats&&T.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&E.call(this,e.keywords),typeof e.meta==`object`&&this.addMetaSchema(e.meta),w.call(this),e.validateFormats=r}_addVocabularies(){this.addKeyword(`$async`)}_addDefaultMetaSchema(){let{$data:e,meta:t,schemaId:n}=this.opts,r=f;n===`id`&&(r={...f},r.id=r.$id,delete r.$id),t&&e&&this.addMetaSchema(r,r[n],!1)}defaultMeta(){let{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta=typeof e==`object`?e[t]||e:void 0}validate(e,t){let n;if(typeof e==`string`){if(n=this.getSchema(e),!n)throw Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let r=n(t);return`$async`in n||(this.errors=n.errors),r}compile(e,t){let n=this._addSchema(e,t);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,t){if(typeof this.opts.loadSchema!=`function`)throw Error(`options.loadSchema should be a function`);let{loadSchema:n}=this.opts;return r.call(this,e,t);async function r(e,t){await a.call(this,e.$schema);let n=this._addSchema(e,t);return n.validate||o.call(this,n)}async function a(e){e&&!this.getSchema(e)&&await r.call(this,{$ref:e},!0)}async function o(e){try{return this._compileSchemaEnv(e)}catch(t){if(!(t instanceof i.default))throw t;return s.call(this,t),await c.call(this,t.missingSchema),o.call(this,e)}}function s({missingSchema:e,missingRef:t}){if(this.refs[e])throw Error(`AnySchema ${e} is loaded but ${t} cannot be resolved`)}async function c(e){let n=await l.call(this,e);this.refs[e]||await a.call(this,n.$schema),this.refs[e]||this.addSchema(n,e,t)}async function l(e){let t=this._loading[e];if(t)return t;try{return await(this._loading[e]=n(e))}finally{delete this._loading[e]}}}addSchema(e,t,n,r=this.opts.validateSchema){if(Array.isArray(e)){for(let t of e)this.addSchema(t,void 0,n,r);return this}let i;if(typeof e==`object`){let{schemaId:t}=this.opts;if(i=e[t],i!==void 0&&typeof i!=`string`)throw Error(`schema ${t} must be string`)}return t=(0,c.normalizeId)(t||i),this._checkUnique(t),this.schemas[t]=this._addSchema(e,n,t,r,!0),this}addMetaSchema(e,t,n=this.opts.validateSchema){return this.addSchema(e,t,!0,n),this}validateSchema(e,t){if(typeof e==`boolean`)return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!=`string`)throw Error(`$schema must be a string`);if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn(`meta-schema not available`),this.errors=null,!0;let r=this.validate(n,e);if(!r&&t){let e=`schema is invalid: `+this.errorsText();if(this.opts.validateSchema===`log`)this.logger.error(e);else throw Error(e)}return r}getSchema(e){let t;for(;typeof(t=C.call(this,e))==`string`;)e=t;if(t===void 0){let{schemaId:n}=this.opts,r=new o.SchemaEnv({schema:{},schemaId:n});if(t=o.resolveSchema.call(this,r,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case`undefined`:return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case`string`:{let t=C.call(this,e);return typeof t==`object`&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case`object`:{let t=e;this._cache.delete(t);let n=e[this.opts.schemaId];return n&&(n=(0,c.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw Error(`ajv.removeSchema: invalid parameter`)}}addVocabulary(e){for(let t of e)this.addKeyword(t);return this}addKeyword(e,t){let n;if(typeof e==`string`)n=e,typeof t==`object`&&(this.logger.warn(`these parameters are deprecated, see docs for addKeyword`),t.keyword=n);else if(typeof e==`object`&&t===void 0){if(t=e,n=t.keyword,Array.isArray(n)&&!n.length)throw Error(`addKeywords: keyword must be string or non-empty array`)}else throw Error(`invalid addKeywords parameters`);if(j.call(this,n,t),!t)return(0,u.eachItem)(n,e=>M.call(this,e)),this;P.call(this,t);let r={...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)};return(0,u.eachItem)(n,r.type.length===0?e=>M.call(this,e,r):e=>r.type.forEach(t=>M.call(this,e,r,t))),this}getKeyword(e){let t=this.RULES.all[e];return typeof t==`object`?t.definition:!!t}removeKeyword(e){let{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(let n of t.rules){let t=n.rules.findIndex(t=>t.keyword===e);t>=0&&n.rules.splice(t,1)}return this}addFormat(e,t){return typeof t==`string`&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=`, `,dataVar:n=`data`}={}){return!e||e.length===0?`No errors`:e.map(e=>`${n}${e.instancePath} ${e.message}`).reduce((e,n)=>e+t+n)}$dataMetaSchema(e,t){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let r of t){let t=r.split(`/`).slice(1),i=e;for(let e of t)i=i[e];for(let e in n){let t=n[e];if(typeof t!=`object`)continue;let{$data:r}=t.definition,a=i[e];r&&a&&(i[e]=I(a))}}return e}_removeAllSchemas(e,t){for(let n in e){let r=e[n];(!t||t.test(n))&&(typeof r==`string`?delete e[n]:r&&!r.meta&&(this._cache.delete(r.schema),delete e[n]))}}_addSchema(e,t,n,r=this.opts.validateSchema,i=this.opts.addUsedSchema){let a,{schemaId:s}=this.opts;if(typeof e==`object`)a=e[s];else if(this.opts.jtd)throw Error(`schema must be object`);else if(typeof e!=`boolean`)throw Error(`schema must be object or boolean`);let l=this._cache.get(e);if(l!==void 0)return l;n=(0,c.normalizeId)(a||n);let u=c.getSchemaRefs.call(this,e,n);return l=new o.SchemaEnv({schema:e,schemaId:s,meta:t,baseId:n,localRefs:u}),this._cache.set(l.schema,l),i&&!n.startsWith(`#`)&&(n&&this._checkUnique(n),this.refs[n]=l),r&&this.validateSchema(e,!0),l}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):o.compileSchema.call(this,e),!e.validate)throw Error(`ajv implementation error`);return e.validate}_compileMetaSchema(e){let t=this.opts;this.opts=this._metaOpts;try{o.compileSchema.call(this,e)}finally{this.opts=t}}};x.ValidationError=r.default,x.MissingRefError=i.default,e.default=x;function S(e,t,n,r=`error`){for(let i in e){let a=i;a in t&&this.logger[r](`${n}: option ${i}. ${e[a]}`)}}function C(e){return e=(0,c.normalizeId)(e),this.schemas[e]||this.refs[e]}function w(){let e=this.opts.schemas;if(e){if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}}function T(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function E(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn(`keywords option as map is deprecated, pass array`);for(let t in e){let n=e[t];n.keyword||=t,this.addKeyword(n)}}function D(){let e={...this.opts};for(let t of h)delete e[t];return e}var O={log(){},warn(){},error(){}};function k(e){if(e===!1)return O;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw Error(`logger must implement log, warn and error methods`)}var A=/^[a-z_$][a-z0-9_$:-]*$/i;function j(e,t){let{RULES:n}=this;if((0,u.eachItem)(e,e=>{if(n.keywords[e])throw Error(`Keyword ${e} is already defined`);if(!A.test(e))throw Error(`Keyword ${e} has invalid name`)}),t&&t.$data&&!(`code`in t||`validate`in t))throw Error(`$data keyword must have "code" or "validate" function`)}function M(e,t,n){var r;let i=t?.post;if(n&&i)throw Error(`keyword with "post" flag cannot have "type"`);let{RULES:a}=this,o=i?a.post:a.rules.find(({type:e})=>e===n);if(o||(o={type:n,rules:[]},a.rules.push(o)),a.keywords[e]=!0,!t)return;let s={keyword:e,definition:{...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)}};t.before?N.call(this,o,s,t.before):o.rules.push(s),a.all[e]=s,(r=t.implements)==null||r.forEach(e=>this.addKeyword(e))}function N(e,t,n){let r=e.rules.findIndex(e=>e.keyword===n);r>=0?e.rules.splice(r,0,t):(e.rules.push(t),this.logger.warn(`rule ${n} is not defined`))}function P(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=I(t)),e.validateSchema=this.compile(t,!0))}var F={$ref:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`};function I(e){return{anyOf:[e,F]}}})),nB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default={keyword:`id`,code(){throw Error(`NOT SUPPORTED: keyword "id", use "$id" for schema ID`)}}})),rB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.callRef=e.getValidate=void 0;var t=Vz(),n=Nz(),r=wz(),i=Ez(),a=Hz(),o=Tz(),s={keyword:`$ref`,schemaType:`string`,code(e){let{gen:n,schema:i,it:o}=e,{baseId:s,schemaEnv:u,validateName:d,opts:f,self:p}=o,{root:m}=u;if((i===`#`||i===`#/`)&&s===m.baseId)return g();let h=a.resolveRef.call(p,m,s,i);if(h===void 0)throw new t.default(o.opts.uriResolver,s,i);if(h instanceof a.SchemaEnv)return _(h);return v(h);function g(){if(u===m)return l(e,d,u,u.$async);let t=n.scopeValue(`root`,{ref:m});return l(e,(0,r._)`${t}.validate`,m,m.$async)}function _(t){l(e,c(e,t),t,t.$async)}function v(t){let a=n.scopeValue(`schema`,f.code.source===!0?{ref:t,code:(0,r.stringify)(t)}:{ref:t}),o=n.name(`valid`),s=e.subschema({schema:t,dataTypes:[],schemaPath:r.nil,topSchemaRef:a,errSchemaPath:i},o);e.mergeEvaluated(s),e.ok(o)}}};function c(e,t){let{gen:n}=e;return t.validate?n.scopeValue(`validate`,{ref:t.validate}):(0,r._)`${n.scopeValue(`wrapper`,{ref:t})}.validate`}e.getValidate=c;function l(e,t,a,s){let{gen:c,it:l}=e,{allErrors:u,schemaEnv:d,opts:f}=l,p=f.passContext?i.default.this:r.nil;s?m():h();function m(){if(!d.$async)throw Error(`async schema referenced by sync schema`);let i=c.let(`valid`);c.try(()=>{c.code((0,r._)`await ${(0,n.callValidateCode)(e,t,p)}`),_(t),u||c.assign(i,!0)},e=>{c.if((0,r._)`!(${e} instanceof ${l.ValidationError})`,()=>c.throw(e)),g(e),u||c.assign(i,!1)}),e.ok(i)}function h(){e.result((0,n.callValidateCode)(e,t,p),()=>_(t),()=>g(t))}function g(e){let t=(0,r._)`${e}.errors`;c.assign(i.default.vErrors,(0,r._)`${i.default.vErrors} === null ? ${t} : ${i.default.vErrors}.concat(${t})`),c.assign(i.default.errors,(0,r._)`${i.default.vErrors}.length`)}function _(e){if(!l.opts.unevaluated)return;let t=a?.validate?.evaluated;if(l.props!==!0){if(t&&!t.dynamicProps)t.props!==void 0&&(l.props=o.mergeEvaluated.props(c,t.props,l.props));else{let t=c.var(`props`,(0,r._)`${e}.evaluated.props`);l.props=o.mergeEvaluated.props(c,t,l.props,r.Name)}}if(l.items!==!0){if(t&&!t.dynamicItems)t.items!==void 0&&(l.items=o.mergeEvaluated.items(c,t.items,l.items));else{let t=c.var(`items`,(0,r._)`${e}.evaluated.items`);l.items=o.mergeEvaluated.items(c,t,l.items,r.Name)}}}}e.callRef=l,e.default=s})),iB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=nB(),n=rB();e.default=[`$schema`,`$id`,`$defs`,`$vocabulary`,{keyword:`$comment`},`definitions`,t.default,n.default]})),aB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=wz(),n=t.operators,r={maximum:{okStr:`<=`,ok:n.LTE,fail:n.GT},minimum:{okStr:`>=`,ok:n.GTE,fail:n.LT},exclusiveMaximum:{okStr:`<`,ok:n.LT,fail:n.GTE},exclusiveMinimum:{okStr:`>`,ok:n.GT,fail:n.LTE}};e.default={keyword:Object.keys(r),type:`number`,schemaType:`number`,$data:!0,error:{message:({keyword:e,schemaCode:n})=>(0,t.str)`must be ${r[e].okStr} ${n}`,params:({keyword:e,schemaCode:n})=>(0,t._)`{comparison: ${r[e].okStr}, limit: ${n}}`},code(e){let{keyword:n,data:i,schemaCode:a}=e;e.fail$data((0,t._)`${i} ${r[n].fail} ${a} || isNaN(${i})`)}}})),oB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=wz();e.default={keyword:`multipleOf`,type:`number`,schemaType:`number`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,t._)`{multipleOf: ${e}}`},code(e){let{gen:n,data:r,schemaCode:i,it:a}=e,o=a.opts.multipleOfPrecision,s=n.let(`res`),c=o?(0,t._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${o}`:(0,t._)`${s} !== parseInt(${s})`;e.fail$data((0,t._)`(${i} === 0 || (${s} = ${r}/${i}, ${c}))`)}}})),sB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r<t;)n++,i=e.charCodeAt(r++),i>=55296&&i<=56319&&r<t&&(i=e.charCodeAt(r),(i&64512)==56320&&r++);return n}e.default=t,t.code=`require("ajv/dist/runtime/ucs2length").default`})),cB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=wz(),n=Tz(),r=sB();e.default={keyword:[`maxLength`,`minLength`],type:`string`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxLength`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} characters`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:i,data:a,schemaCode:o,it:s}=e,c=i===`maxLength`?t.operators.GT:t.operators.LT,l=s.opts.unicode===!1?(0,t._)`${a}.length`:(0,t._)`${(0,n.useFunc)(e.gen,r.default)}(${a})`;e.fail$data((0,t._)`${l} ${c} ${o}`)}}})),lB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Nz(),n=Tz(),r=wz();e.default={keyword:`pattern`,type:`string`,schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,r.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,r._)`{pattern: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e,u=l.opts.unicodeRegExp?`u`:``;if(o){let{regExp:t}=l.opts.code,o=t.code===`new RegExp`?(0,r._)`new RegExp`:(0,n.useFunc)(i,t),s=i.let(`valid`);i.try(()=>i.assign(s,(0,r._)`${o}(${c}, ${u}).test(${a})`),()=>i.assign(s,!1)),e.fail$data((0,r._)`!${s}`)}else{let n=(0,t.usePattern)(e,s);e.fail$data((0,r._)`!${n}.test(${a})`)}}}})),uB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=wz();e.default={keyword:[`maxProperties`,`minProperties`],type:`object`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxProperties`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} properties`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxProperties`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`Object.keys(${r}).length ${a} ${i}`)}}})),dB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Nz(),n=wz(),r=Tz();e.default={keyword:`required`,type:`object`,schemaType:`array`,$data:!0,error:{message:({params:{missingProperty:e}})=>(0,n.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,n._)`{missingProperty: ${e}}`},code(e){let{gen:i,schema:a,schemaCode:o,data:s,$data:c,it:l}=e,{opts:u}=l;if(!c&&a.length===0)return;let d=a.length>=u.loopRequired;if(l.allErrors?f():p(),u.strictRequired){let t=e.parentSchema.properties,{definedProperties:n}=e.it;for(let e of a)if(t?.[e]===void 0&&!n.has(e)){let t=`required property "${e}" is not defined at "${l.schemaEnv.baseId+l.errSchemaPath}" (strictRequired)`;(0,r.checkStrictMode)(l,t,l.opts.strictRequired)}}function f(){if(d||c)e.block$data(n.nil,m);else for(let n of a)(0,t.checkReportMissingProp)(e,n)}function p(){let n=i.let(`missing`);if(d||c){let t=i.let(`valid`,!0);e.block$data(t,()=>h(n,t)),e.ok(t)}else i.if((0,t.checkMissingProp)(e,a,n)),(0,t.reportMissingProp)(e,n),i.else()}function m(){i.forOf(`prop`,o,n=>{e.setParams({missingProperty:n}),i.if((0,t.noPropertyInData)(i,s,n,u.ownProperties),()=>e.error())})}function h(r,a){e.setParams({missingProperty:r}),i.forOf(r,o,()=>{i.assign(a,(0,t.propertyInData)(i,s,r,u.ownProperties)),i.if((0,n.not)(a),()=>{e.error(),i.break()})},n.nil)}}}})),fB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=wz();e.default={keyword:[`maxItems`,`minItems`],type:`array`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxItems`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} items`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxItems`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`${r}.length ${a} ${i}`)}}})),pB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Iz();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t})),mB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=jz(),n=wz(),r=Tz(),i=pB();e.default={keyword:`uniqueItems`,type:`array`,schemaType:`boolean`,$data:!0,error:{message:({params:{i:e,j:t}})=>(0,n.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,n._)`{i: ${e}, j: ${t}}`},code(e){let{gen:a,data:o,$data:s,schema:c,parentSchema:l,schemaCode:u,it:d}=e;if(!s&&!c)return;let f=a.let(`valid`),p=l.items?(0,t.getSchemaTypes)(l.items):[];e.block$data(f,m,(0,n._)`${u} === false`),e.ok(f);function m(){let t=a.let(`i`,(0,n._)`${o}.length`),r=a.let(`j`);e.setParams({i:t,j:r}),a.assign(f,!0),a.if((0,n._)`${t} > 1`,()=>(h()?g:_)(t,r))}function h(){return p.length>0&&!p.some(e=>e===`object`||e===`array`)}function g(r,i){let s=a.name(`item`),c=(0,t.checkDataTypes)(p,s,d.opts.strictNumbers,t.DataType.Wrong),l=a.const(`indices`,(0,n._)`{}`);a.for((0,n._)`;${r}--;`,()=>{a.let(s,(0,n._)`${o}[${r}]`),a.if(c,(0,n._)`continue`),p.length>1&&a.if((0,n._)`typeof ${s} == "string"`,(0,n._)`${s} += "_"`),a.if((0,n._)`typeof ${l}[${s}] == "number"`,()=>{a.assign(i,(0,n._)`${l}[${s}]`),e.error(),a.assign(f,!1).break()}).code((0,n._)`${l}[${s}] = ${r}`)})}function _(t,s){let c=(0,r.useFunc)(a,i.default),l=a.name(`outer`);a.label(l).for((0,n._)`;${t}--;`,()=>a.for((0,n._)`${s} = ${t}; ${s}--;`,()=>a.if((0,n._)`${c}(${o}[${t}], ${o}[${s}])`,()=>{e.error(),a.assign(f,!1).break(l)})))}}}})),hB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=wz(),n=Tz(),r=pB();e.default={keyword:`const`,$data:!0,error:{message:`must be equal to constant`,params:({schemaCode:e})=>(0,t._)`{allowedValue: ${e}}`},code(e){let{gen:i,data:a,$data:o,schemaCode:s,schema:c}=e;o||c&&typeof c==`object`?e.fail$data((0,t._)`!${(0,n.useFunc)(i,r.default)}(${a}, ${s})`):e.fail((0,t._)`${c} !== ${a}`)}}})),gB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=wz(),n=Tz(),r=pB();e.default={keyword:`enum`,schemaType:`array`,$data:!0,error:{message:`must be equal to one of the allowed values`,params:({schemaCode:e})=>(0,t._)`{allowedValues: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e;if(!o&&s.length===0)throw Error(`enum must have non-empty array`);let u=s.length>=l.opts.loopEnum,d,f=()=>d??=(0,n.useFunc)(i,r.default),p;if(u||o)p=i.let(`valid`),e.block$data(p,m);else{if(!Array.isArray(s))throw Error(`ajv implementation error`);let e=i.const(`vSchema`,c);p=(0,t.or)(...s.map((t,n)=>h(e,n)))}e.pass(p);function m(){i.assign(p,!1),i.forOf(`v`,c,e=>i.if((0,t._)`${f()}(${a}, ${e})`,()=>i.assign(p,!0).break()))}function h(e,n){let r=s[n];return typeof r==`object`&&r?(0,t._)`${f()}(${a}, ${e}[${n}])`:(0,t._)`${a} === ${r}`}}}})),_B=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=aB(),n=oB(),r=cB(),i=lB(),a=uB(),o=dB(),s=fB(),c=mB(),l=hB(),u=gB();e.default=[t.default,n.default,r.default,i.default,a.default,o.default,s.default,c.default,{keyword:`type`,schemaType:[`string`,`array`]},{keyword:`nullable`,schemaType:`boolean`},l.default,u.default]})),vB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateAdditionalItems=void 0;var t=wz(),n=Tz(),r={keyword:`additionalItems`,type:`array`,schemaType:[`boolean`,`object`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{parentSchema:t,it:r}=e,{items:a}=t;if(!Array.isArray(a)){(0,n.checkStrictMode)(r,`"additionalItems" is ignored when "items" is not an array of schemas`);return}i(e,a)}};function i(e,r){let{gen:i,schema:a,data:o,keyword:s,it:c}=e;c.items=!0;let l=i.const(`len`,(0,t._)`${o}.length`);if(a===!1)e.setParams({len:r.length}),e.pass((0,t._)`${l} <= ${r.length}`);else if(typeof a==`object`&&!(0,n.alwaysValidSchema)(c,a)){let n=i.var(`valid`,(0,t._)`${l} <= ${r.length}`);i.if((0,t.not)(n),()=>u(n)),e.ok(n)}function u(a){i.forRange(`i`,r.length,l,r=>{e.subschema({keyword:s,dataProp:r,dataPropType:n.Type.Num},a),c.allErrors||i.if((0,t.not)(a),()=>i.break())})}}e.validateAdditionalItems=i,e.default=r})),yB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateTuple=void 0;var t=wz(),n=Tz(),r=Nz(),i={keyword:`items`,type:`array`,schemaType:[`object`,`array`,`boolean`],before:`uniqueItems`,code(e){let{schema:t,it:i}=e;if(Array.isArray(t))return a(e,`additionalItems`,t);i.items=!0,!(0,n.alwaysValidSchema)(i,t)&&e.ok((0,r.validateArray)(e))}};function a(e,r,i=e.schema){let{gen:a,parentSchema:o,data:s,keyword:c,it:l}=e;f(o),l.opts.unevaluated&&i.length&&l.items!==!0&&(l.items=n.mergeEvaluated.items(a,i.length,l.items));let u=a.name(`valid`),d=a.const(`len`,(0,t._)`${s}.length`);i.forEach((r,i)=>{(0,n.alwaysValidSchema)(l,r)||(a.if((0,t._)`${d} > ${i}`,()=>e.subschema({keyword:c,schemaProp:i,dataProp:i},u)),e.ok(u))});function f(e){let{opts:t,errSchemaPath:a}=l,o=i.length,s=o===e.minItems&&(o===e.maxItems||e[r]===!1);if(t.strictTuples&&!s){let e=`"${c}" is ${o}-tuple, but minItems or maxItems/${r} are not specified or different at path "${a}"`;(0,n.checkStrictMode)(l,e,t.strictTuples)}}}e.validateTuple=a,e.default=i})),bB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=yB();e.default={keyword:`prefixItems`,type:`array`,schemaType:[`array`],before:`uniqueItems`,code:e=>(0,t.validateTuple)(e,`items`)}})),xB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=wz(),n=Tz(),r=Nz(),i=vB();e.default={keyword:`items`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{schema:t,parentSchema:a,it:o}=e,{prefixItems:s}=a;o.items=!0,!(0,n.alwaysValidSchema)(o,t)&&(s?(0,i.validateAdditionalItems)(e,s):e.ok((0,r.validateArray)(e)))}}})),SB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=wz(),n=Tz();e.default={keyword:`contains`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,trackErrors:!0,error:{message:({params:{min:e,max:n}})=>n===void 0?(0,t.str)`must contain at least ${e} valid item(s)`:(0,t.str)`must contain at least ${e} and no more than ${n} valid item(s)`,params:({params:{min:e,max:n}})=>n===void 0?(0,t._)`{minContains: ${e}}`:(0,t._)`{minContains: ${e}, maxContains: ${n}}`},code(e){let{gen:r,schema:i,parentSchema:a,data:o,it:s}=e,c,l,{minContains:u,maxContains:d}=a;s.opts.next?(c=u===void 0?1:u,l=d):c=1;let f=r.const(`len`,(0,t._)`${o}.length`);if(e.setParams({min:c,max:l}),l===void 0&&c===0){(0,n.checkStrictMode)(s,`"minContains" == 0 without "maxContains": "contains" keyword ignored`);return}if(l!==void 0&&c>l){(0,n.checkStrictMode)(s,`"minContains" > "maxContains" is always invalid`),e.fail();return}if((0,n.alwaysValidSchema)(s,i)){let n=(0,t._)`${f} >= ${c}`;l!==void 0&&(n=(0,t._)`${n} && ${f} <= ${l}`),e.pass(n);return}s.items=!0;let p=r.name(`valid`);l===void 0&&c===1?h(p,()=>r.if(p,()=>r.break())):c===0?(r.let(p,!0),l!==void 0&&r.if((0,t._)`${o}.length > 0`,m)):(r.let(p,!1),m()),e.result(p,()=>e.reset());function m(){let e=r.name(`_valid`),t=r.let(`count`,0);h(e,()=>r.if(e,()=>g(t)))}function h(t,i){r.forRange(`i`,0,f,r=>{e.subschema({keyword:`contains`,dataProp:r,dataPropType:n.Type.Num,compositeRule:!0},t),i()})}function g(e){r.code((0,t._)`${e}++`),l===void 0?r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0).break()):(r.if((0,t._)`${e} > ${l}`,()=>r.assign(p,!1).break()),c===1?r.assign(p,!0):r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0)))}}}})),CB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;var t=wz(),n=Tz(),r=Nz();e.error={message:({params:{property:e,depsCount:n,deps:r}})=>{let i=n===1?`property`:`properties`;return(0,t.str)`must have ${i} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:n,deps:r,missingProperty:i}})=>(0,t._)`{property: ${e},
|
|
222
|
+
|| ${s} === "boolean" || ${a} === null`).assign(c,(0,i._)`[${a}]`)}}}function p({gen:e,parentData:t,parentDataProperty:n},r){e.if((0,i._)`${t} !== undefined`,()=>e.assign((0,i._)`${t}[${n}]`,r))}function m(e,t,n,r=o.Correct){let a=r===o.Correct?i.operators.EQ:i.operators.NEQ,s;switch(e){case`null`:return(0,i._)`${t} ${a} null`;case`array`:s=(0,i._)`Array.isArray(${t})`;break;case`object`:s=(0,i._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case`integer`:s=c((0,i._)`!(${t} % 1) && !isNaN(${t})`);break;case`number`:s=c();break;default:return(0,i._)`typeof ${t} ${a} ${e}`}return r===o.Correct?s:(0,i.not)(s);function c(e=i.nil){return(0,i.and)((0,i._)`typeof ${t} == "number"`,e,n?(0,i._)`isFinite(${t})`:i.nil)}}e.checkDataType=m;function h(e,t,n,r){if(e.length===1)return m(e[0],t,n,r);let o,s=(0,a.toHash)(e);if(s.array&&s.object){let e=(0,i._)`typeof ${t} != "object"`;o=s.null?e:(0,i._)`!${t} || ${e}`,delete s.null,delete s.array,delete s.object}else o=i.nil;s.number&&delete s.integer;for(let e in s)o=(0,i.and)(o,m(e,t,n,r));return o}e.checkDataTypes=h;var g={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e==`string`?(0,i._)`{type: ${e}}`:(0,i._)`{type: ${t}}`};function _(e){let t=v(e);(0,r.reportError)(t,g)}e.reportTypeError=_;function v(e){let{gen:t,data:n,schema:r}=e,i=(0,a.schemaRefOrVal)(e,r,`type`);return{gen:t,keyword:`type`,data:n,schema:r.type,schemaCode:i,schemaValue:i,parentSchema:r,params:{},it:e}}})),Rz=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.assignDefaults=void 0;var t=Az(),n=jz();function r(e,t){let{properties:n,items:r}=e.schema;if(t===`object`&&n)for(let t in n)i(e,t,n[t].default);else t===`array`&&Array.isArray(r)&&r.forEach((t,n)=>i(e,n,t.default))}e.assignDefaults=r;function i(e,r,i){let{gen:a,compositeRule:o,data:s,opts:c}=e;if(i===void 0)return;let l=(0,t._)`${s}${(0,t.getProperty)(r)}`;if(o){(0,n.checkStrictMode)(e,`default is ignored for: ${l}`);return}let u=(0,t._)`${l} === undefined`;c.useDefaults===`empty`&&(u=(0,t._)`${u} || ${l} === null || ${l} === ""`),a.if(u,(0,t._)`${l} = ${(0,t.stringify)(i)}`)}})),zz=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateUnion=e.validateArray=e.usePattern=e.callValidateCode=e.schemaProperties=e.allSchemaProperties=e.noPropertyInData=e.propertyInData=e.isOwnProperty=e.hasPropFunc=e.reportMissingProp=e.checkMissingProp=e.checkReportMissingProp=void 0;var t=Az(),n=jz(),r=Mz(),i=jz();function a(e,n){let{gen:r,data:i,it:a}=e;r.if(d(r,i,n,a.opts.ownProperties),()=>{e.setParams({missingProperty:(0,t._)`${n}`},!0),e.error()})}e.checkReportMissingProp=a;function o({gen:e,data:n,it:{opts:r}},i,a){return(0,t.or)(...i.map(i=>(0,t.and)(d(e,n,i,r.ownProperties),(0,t._)`${a} = ${i}`)))}e.checkMissingProp=o;function s(e,t){e.setParams({missingProperty:t},!0),e.error()}e.reportMissingProp=s;function c(e){return e.scopeValue(`func`,{ref:Object.prototype.hasOwnProperty,code:(0,t._)`Object.prototype.hasOwnProperty`})}e.hasPropFunc=c;function l(e,n,r){return(0,t._)`${c(e)}.call(${n}, ${r})`}e.isOwnProperty=l;function u(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} !== undefined`;return i?(0,t._)`${a} && ${l(e,n,r)}`:a}e.propertyInData=u;function d(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} === undefined`;return i?(0,t.or)(a,(0,t.not)(l(e,n,r))):a}e.noPropertyInData=d;function f(e){return e?Object.keys(e).filter(e=>e!==`__proto__`):[]}e.allSchemaProperties=f;function p(e,t){return f(t).filter(r=>!(0,n.alwaysValidSchema)(e,t[r]))}e.schemaProperties=p;function m({schemaCode:e,data:n,it:{gen:i,topSchemaRef:a,schemaPath:o,errorPath:s},it:c},l,u,d){let f=d?(0,t._)`${e}, ${n}, ${a}${o}`:n,p=[[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,s)],[r.default.parentData,c.parentData],[r.default.parentDataProperty,c.parentDataProperty],[r.default.rootData,r.default.rootData]];c.opts.dynamicRef&&p.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);let m=(0,t._)`${f}, ${i.object(...p)}`;return u===t.nil?(0,t._)`${l}(${m})`:(0,t._)`${l}.call(${u}, ${m})`}e.callValidateCode=m;var h=(0,t._)`new RegExp`;function g({gen:e,it:{opts:n}},r){let a=n.unicodeRegExp?`u`:``,{regExp:o}=n.code,s=o(r,a);return e.scopeValue(`pattern`,{key:s.toString(),ref:s,code:(0,t._)`${o.code===`new RegExp`?h:(0,i.useFunc)(e,o)}(${r}, ${a})`})}e.usePattern=g;function _(e){let{gen:r,data:i,keyword:a,it:o}=e,s=r.name(`valid`);if(o.allErrors){let e=r.let(`valid`,!0);return c(()=>r.assign(e,!1)),e}return r.var(s,!0),c(()=>r.break()),s;function c(o){let c=r.const(`len`,(0,t._)`${i}.length`);r.forRange(`i`,0,c,i=>{e.subschema({keyword:a,dataProp:i,dataPropType:n.Type.Num},s),r.if((0,t.not)(s),o)})}}e.validateArray=_;function v(e){let{gen:r,schema:i,keyword:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(i.some(e=>(0,n.alwaysValidSchema)(o,e))&&!o.opts.unevaluated)return;let s=r.let(`valid`,!1),c=r.name(`_valid`);r.block(()=>i.forEach((n,i)=>{let o=e.subschema({keyword:a,schemaProp:i,compositeRule:!0},c);r.assign(s,(0,t._)`${s} || ${c}`),e.mergeValidEvaluated(o,c)||r.if((0,t.not)(s))})),e.result(s,()=>e.reset(),()=>e.error(!0))}e.validateUnion=v})),Bz=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0;var t=Az(),n=Mz(),r=zz(),i=Nz();function a(e,n){let{gen:r,keyword:i,schema:a,parentSchema:o,it:s}=e,c=n.macro.call(s.self,a,o,s),l=u(r,i,c);s.opts.validateSchema!==!1&&s.self.validateSchema(c,!0);let d=r.name(`valid`);e.subschema({schema:c,schemaPath:t.nil,errSchemaPath:`${s.errSchemaPath}/${i}`,topSchemaRef:l,compositeRule:!0},d),e.pass(d,()=>e.error(!0))}e.macroKeywordCode=a;function o(e,i){let{gen:a,keyword:o,schema:d,parentSchema:f,$data:p,it:m}=e;l(m,i);let h=u(a,o,!p&&i.compile?i.compile.call(m.self,d,f,m):i.validate),g=a.let(`valid`);e.block$data(g,_),e.ok(i.valid??g);function _(){if(i.errors===!1)b(),i.modifying&&s(e),x(()=>e.error());else{let t=i.async?v():y();i.modifying&&s(e),x(()=>c(e,t))}}function v(){let e=a.let(`ruleErrs`,null);return a.try(()=>b((0,t._)`await `),n=>a.assign(g,!1).if((0,t._)`${n} instanceof ${m.ValidationError}`,()=>a.assign(e,(0,t._)`${n}.errors`),()=>a.throw(n))),e}function y(){let e=(0,t._)`${h}.errors`;return a.assign(e,null),b(t.nil),e}function b(o=i.async?(0,t._)`await `:t.nil){let s=m.opts.passContext?n.default.this:n.default.self,c=!(`compile`in i&&!p||i.schema===!1);a.assign(g,(0,t._)`${o}${(0,r.callValidateCode)(e,h,s,c)}`,i.modifying)}function x(e){a.if((0,t.not)(i.valid??g),e)}}e.funcKeywordCode=o;function s(e){let{gen:n,data:r,it:i}=e;n.if(i.parentData,()=>n.assign(r,(0,t._)`${i.parentData}[${i.parentDataProperty}]`))}function c(e,r){let{gen:a}=e;a.if((0,t._)`Array.isArray(${r})`,()=>{a.assign(n.default.vErrors,(0,t._)`${n.default.vErrors} === null ? ${r} : ${n.default.vErrors}.concat(${r})`).assign(n.default.errors,(0,t._)`${n.default.vErrors}.length`),(0,i.extendErrors)(e)},()=>e.error())}function l({schemaEnv:e},t){if(t.async&&!e.$async)throw Error(`async keyword in sync schema`)}function u(e,n,r){if(r===void 0)throw Error(`keyword "${n}" failed to compile`);return e.scopeValue(`keyword`,typeof r==`function`?{ref:r}:{ref:r,code:(0,t.stringify)(r)})}function d(e,t,n=!1){return!t.length||t.some(t=>t===`array`?Array.isArray(e):t===`object`?e&&typeof e==`object`&&!Array.isArray(e):typeof e==t||n&&e===void 0)}e.validSchemaType=d;function f({schema:e,opts:t,self:n,errSchemaPath:r},i,a){if(Array.isArray(i.keyword)?!i.keyword.includes(a):i.keyword!==a)throw Error(`ajv implementation error`);let o=i.dependencies;if(o?.some(t=>!Object.prototype.hasOwnProperty.call(e,t)))throw Error(`parent schema must have dependencies of ${a}: ${o.join(`,`)}`);if(i.validateSchema&&!i.validateSchema(e[a])){let e=`keyword "${a}" value is invalid at path "${r}": `+n.errorsText(i.validateSchema.errors);if(t.validateSchema===`log`)n.logger.error(e);else throw Error(e)}}e.validateKeywordUsage=f})),Vz=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.extendSubschemaMode=e.extendSubschemaData=e.getSubschema=void 0;var t=Az(),n=jz();function r(e,{keyword:r,schemaProp:i,schema:a,schemaPath:o,errSchemaPath:s,topSchemaRef:c}){if(r!==void 0&&a!==void 0)throw Error(`both "keyword" and "schema" passed, only one allowed`);if(r!==void 0){let a=e.schema[r];return i===void 0?{schema:a,schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${r}`}:{schema:a[i],schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}${(0,t.getProperty)(i)}`,errSchemaPath:`${e.errSchemaPath}/${r}/${(0,n.escapeFragment)(i)}`}}if(a!==void 0){if(o===void 0||s===void 0||c===void 0)throw Error(`"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"`);return{schema:a,schemaPath:o,topSchemaRef:c,errSchemaPath:s}}throw Error(`either "keyword" or "schema" must be passed`)}e.getSubschema=r;function i(e,r,{dataProp:i,dataPropType:a,data:o,dataTypes:s,propertyName:c}){if(o!==void 0&&i!==void 0)throw Error(`both "data" and "dataProp" passed, only one allowed`);let{gen:l}=r;if(i!==void 0){let{errorPath:o,dataPathArr:s,opts:c}=r;u(l.let(`data`,(0,t._)`${r.data}${(0,t.getProperty)(i)}`,!0)),e.errorPath=(0,t.str)`${o}${(0,n.getErrorPath)(i,a,c.jsPropertySyntax)}`,e.parentDataProperty=(0,t._)`${i}`,e.dataPathArr=[...s,e.parentDataProperty]}o!==void 0&&(u(o instanceof t.Name?o:l.let(`data`,o,!0)),c!==void 0&&(e.propertyName=c)),s&&(e.dataTypes=s);function u(t){e.data=t,e.dataLevel=r.dataLevel+1,e.dataTypes=[],r.definedProperties=new Set,e.parentData=r.data,e.dataNames=[...r.dataNames,t]}}e.extendSubschemaData=i;function a(e,{jtdDiscriminator:t,jtdMetadata:n,compositeRule:r,createErrors:i,allErrors:a}){r!==void 0&&(e.compositeRule=r),i!==void 0&&(e.createErrors=i),a!==void 0&&(e.allErrors=a),e.jtdDiscriminator=t,e.jtdMetadata=n}e.extendSubschemaMode=a})),Hz=s(((e,t)=>{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),Uz=s(((e,t)=>{var n=t.exports=function(e,t,n){typeof t==`function`&&(n=t,t={}),n=t.cb||n;var i=typeof n==`function`?n:n.pre||function(){},a=n.post||function(){};r(t,i,a,e,``,e)};n.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},n.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},n.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},n.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 r(e,t,a,o,s,c,l,u,d,f){if(o&&typeof o==`object`&&!Array.isArray(o)){for(var p in t(o,s,c,l,u,d,f),o){var m=o[p];if(Array.isArray(m)){if(p in n.arrayKeywords)for(var h=0;h<m.length;h++)r(e,t,a,m[h],s+`/`+p+`/`+h,c,s,p,o,h)}else if(p in n.propsKeywords){if(m&&typeof m==`object`)for(var g in m)r(e,t,a,m[g],s+`/`+p+`/`+i(g),c,s,p,o,g)}else(p in n.keywords||e.allKeys&&!(p in n.skipKeywords))&&r(e,t,a,m,s+`/`+p,c,s,p,o)}a(o,s,c,l,u,d,f)}}function i(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}})),Wz=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getSchemaRefs=e.resolveUrl=e.normalizeId=e._getFullPath=e.getFullPath=e.inlineRef=void 0;var t=jz(),n=Hz(),r=Uz(),i=new Set([`type`,`format`,`pattern`,`maxLength`,`minLength`,`maxProperties`,`minProperties`,`maxItems`,`minItems`,`maximum`,`minimum`,`uniqueItems`,`multipleOf`,`required`,`enum`,`const`]);function a(e,t=!0){return typeof e==`boolean`?!0:t===!0?!s(e):t?c(e)<=t:!1}e.inlineRef=a;var o=new Set([`$ref`,`$recursiveRef`,`$recursiveAnchor`,`$dynamicRef`,`$dynamicAnchor`]);function s(e){for(let t in e){if(o.has(t))return!0;let n=e[t];if(Array.isArray(n)&&n.some(s)||typeof n==`object`&&s(n))return!0}return!1}function c(e){let n=0;for(let r in e)if(r===`$ref`||(n++,!i.has(r)&&(typeof e[r]==`object`&&(0,t.eachItem)(e[r],e=>n+=c(e)),n===1/0)))return 1/0;return n}function l(e,t=``,n){return n!==!1&&(t=f(t)),u(e,e.parse(t))}e.getFullPath=l;function u(e,t){return e.serialize(t).split(`#`)[0]+`#`}e._getFullPath=u;var d=/#\/?$/;function f(e){return e?e.replace(d,``):``}e.normalizeId=f;function p(e,t,n){return n=f(n),e.resolve(t,n)}e.resolveUrl=p;var m=/^[a-z_][-a-z0-9._]*$/i;function h(e,t){if(typeof e==`boolean`)return{};let{schemaId:i,uriResolver:a}=this.opts,o=f(e[i]||t),s={"":o},c=l(a,o,!1),u={},d=new Set;return r(e,{allKeys:!0},(e,t,n,r)=>{if(r===void 0)return;let a=c+t,o=s[r];typeof e[i]==`string`&&(o=l.call(this,e[i])),g.call(this,e.$anchor),g.call(this,e.$dynamicAnchor),s[t]=o;function l(t){let n=this.opts.uriResolver.resolve;if(t=f(o?n(o,t):t),d.has(t))throw h(t);d.add(t);let r=this.refs[t];return typeof r==`string`&&(r=this.refs[r]),typeof r==`object`?p(e,r.schema,t):t!==f(a)&&(t[0]===`#`?(p(e,u[t],t),u[t]=e):this.refs[t]=a),t}function g(e){if(typeof e==`string`){if(!m.test(e))throw Error(`invalid anchor "${e}"`);l.call(this,`#${e}`)}}}),u;function p(e,t,r){if(t!==void 0&&!n(e,t))throw h(r)}function h(e){return Error(`reference "${e}" resolves to more than one schema`)}}e.getSchemaRefs=h})),Gz=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;var t=Pz(),n=Lz(),r=Iz(),i=Lz(),a=Rz(),o=Bz(),s=Vz(),c=Az(),l=Mz(),u=Wz(),d=jz(),f=Nz();function p(e){if(S(e)&&(w(e),x(e))){_(e);return}m(e,()=>(0,t.topBoolOrEmptySchema)(e))}e.validateFunctionCode=p;function m({gen:e,validateName:t,schema:n,schemaEnv:r,opts:i},a){i.code.es5?e.func(t,(0,c._)`${l.default.data}, ${l.default.valCxt}`,r.$async,()=>{e.code((0,c._)`"use strict"; ${y(n,i)}`),g(e,i),e.code(a)}):e.func(t,(0,c._)`${l.default.data}, ${h(i)}`,r.$async,()=>e.code(y(n,i)).code(a))}function h(e){return(0,c._)`{${l.default.instancePath}="", ${l.default.parentData}, ${l.default.parentDataProperty}, ${l.default.rootData}=${l.default.data}${e.dynamicRef?(0,c._)`, ${l.default.dynamicAnchors}={}`:c.nil}}={}`}function g(e,t){e.if(l.default.valCxt,()=>{e.var(l.default.instancePath,(0,c._)`${l.default.valCxt}.${l.default.instancePath}`),e.var(l.default.parentData,(0,c._)`${l.default.valCxt}.${l.default.parentData}`),e.var(l.default.parentDataProperty,(0,c._)`${l.default.valCxt}.${l.default.parentDataProperty}`),e.var(l.default.rootData,(0,c._)`${l.default.valCxt}.${l.default.rootData}`),t.dynamicRef&&e.var(l.default.dynamicAnchors,(0,c._)`${l.default.valCxt}.${l.default.dynamicAnchors}`)},()=>{e.var(l.default.instancePath,(0,c._)`""`),e.var(l.default.parentData,(0,c._)`undefined`),e.var(l.default.parentDataProperty,(0,c._)`undefined`),e.var(l.default.rootData,l.default.data),t.dynamicRef&&e.var(l.default.dynamicAnchors,(0,c._)`{}`)})}function _(e){let{schema:t,opts:n,gen:r}=e;m(e,()=>{n.$comment&&t.$comment&&A(e),D(e),r.let(l.default.vErrors,null),r.let(l.default.errors,0),n.unevaluated&&v(e),T(e),j(e)})}function v(e){let{gen:t,validateName:n}=e;e.evaluated=t.const(`evaluated`,(0,c._)`${n}.evaluated`),t.if((0,c._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,c._)`${e.evaluated}.props`,(0,c._)`undefined`)),t.if((0,c._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,c._)`${e.evaluated}.items`,(0,c._)`undefined`))}function y(e,t){let n=typeof e==`object`&&e[t.schemaId];return n&&(t.code.source||t.code.process)?(0,c._)`/*# sourceURL=${n} */`:c.nil}function b(e,n){if(S(e)&&(w(e),x(e))){C(e,n);return}(0,t.boolOrEmptySchema)(e,n)}function x({schema:e,self:t}){if(typeof e==`boolean`)return!e;for(let n in e)if(t.RULES.all[n])return!0;return!1}function S(e){return typeof e.schema!=`boolean`}function C(e,t){let{schema:n,gen:r,opts:i}=e;i.$comment&&n.$comment&&A(e),O(e),k(e);let a=r.const(`_errs`,l.default.errors);T(e,a),r.var(t,(0,c._)`${a} === ${l.default.errors}`)}function w(e){(0,d.checkUnknownRules)(e),E(e)}function T(e,t){if(e.opts.jtd)return N(e,[],!1,t);let r=(0,n.getSchemaTypes)(e.schema);N(e,r,!(0,n.coerceAndCheckDataType)(e,r),t)}function E(e){let{schema:t,errSchemaPath:n,opts:r,self:i}=e;t.$ref&&r.ignoreKeywordsWithRef&&(0,d.schemaHasRulesButRef)(t,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${n}"`)}function D(e){let{schema:t,opts:n}=e;t.default!==void 0&&n.useDefaults&&n.strictSchema&&(0,d.checkStrictMode)(e,`default is ignored in the schema root`)}function O(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,u.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function k(e){if(e.schema.$async&&!e.schemaEnv.$async)throw Error(`async schema in sync schema`)}function A({gen:e,schemaEnv:t,schema:n,errSchemaPath:r,opts:i}){let a=n.$comment;if(i.$comment===!0)e.code((0,c._)`${l.default.self}.logger.log(${a})`);else if(typeof i.$comment==`function`){let n=(0,c.str)`${r}/$comment`,i=e.scopeValue(`root`,{ref:t.root});e.code((0,c._)`${l.default.self}.opts.$comment(${a}, ${n}, ${i}.schema)`)}}function j(e){let{gen:t,schemaEnv:n,validateName:r,ValidationError:i,opts:a}=e;n.$async?t.if((0,c._)`${l.default.errors} === 0`,()=>t.return(l.default.data),()=>t.throw((0,c._)`new ${i}(${l.default.vErrors})`)):(t.assign((0,c._)`${r}.errors`,l.default.vErrors),a.unevaluated&&M(e),t.return((0,c._)`${l.default.errors} === 0`))}function M({gen:e,evaluated:t,props:n,items:r}){n instanceof c.Name&&e.assign((0,c._)`${t}.props`,n),r instanceof c.Name&&e.assign((0,c._)`${t}.items`,r)}function N(e,t,n,a){let{gen:o,schema:s,data:u,allErrors:f,opts:p,self:m}=e,{RULES:h}=m;if(s.$ref&&(p.ignoreKeywordsWithRef||!(0,d.schemaHasRulesButRef)(s,h))){o.block(()=>re(e,`$ref`,h.all.$ref.definition));return}p.jtd||F(e,t),o.block(()=>{for(let e of h.rules)g(e);g(h.post)});function g(d){(0,r.shouldUseGroup)(s,d)&&(d.type?(o.if((0,i.checkDataType)(d.type,u,p.strictNumbers)),P(e,d),t.length===1&&t[0]===d.type&&n&&(o.else(),(0,i.reportTypeError)(e)),o.endIf()):P(e,d),f||o.if((0,c._)`${l.default.errors} === ${a||0}`))}}function P(e,t){let{gen:n,schema:i,opts:{useDefaults:o}}=e;o&&(0,a.assignDefaults)(e,t.type),n.block(()=>{for(let n of t.rules)(0,r.shouldUseRule)(i,n)&&re(e,n.keyword,n.definition,t.type)})}function F(e,t){!e.schemaEnv.meta&&e.opts.strictTypes&&(I(e,t),e.opts.allowUnionTypes||L(e,t),ee(e,e.dataTypes))}function I(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(t=>{ne(e.dataTypes,t)||z(e,`type "${t}" not allowed by context "${e.dataTypes.join(`,`)}"`)}),R(e,t)}}function L(e,t){t.length>1&&!(t.length===2&&t.includes(`null`))&&z(e,`use allowUnionTypes to allow union type keyword`)}function ee(e,t){let n=e.self.RULES.all;for(let i in n){let a=n[i];if(typeof a==`object`&&(0,r.shouldUseRule)(e.schema,a)){let{type:n}=a.definition;n.length&&!n.some(e=>te(t,e))&&z(e,`missing type "${n.join(`,`)}" for keyword "${i}"`)}}}function te(e,t){return e.includes(t)||t===`number`&&e.includes(`integer`)}function ne(e,t){return e.includes(t)||t===`integer`&&e.includes(`number`)}function R(e,t){let n=[];for(let r of e.dataTypes)ne(t,r)?n.push(r):t.includes(`integer`)&&r===`number`&&n.push(`integer`);e.dataTypes=n}function z(e,t){let n=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${n}" (strictTypes)`,(0,d.checkStrictMode)(e,t,e.opts.strictTypes)}var B=class{constructor(e,t,n){if((0,o.validateKeywordUsage)(e,t,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,d.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const(`vSchema`,oe(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,o.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw Error(`${n} value must be ${JSON.stringify(t.schemaType)}`);(`code`in t?t.trackErrors:t.errors!==!1)&&(this.errsCount=e.gen.const(`_errs`,l.default.errors))}result(e,t,n){this.failResult((0,c.not)(e),t,n)}failResult(e,t,n){this.gen.if(e),n?n():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,c.not)(e),void 0,t)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:t}=this;this.fail((0,c._)`${t} !== undefined && (${(0,c.or)(this.invalid$data(),e)})`)}error(e,t,n){if(t){this.setParams(t),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,t){(e?f.reportExtraError:f.reportError)(this,this.def.error,t)}$dataError(){(0,f.reportError)(this,this.def.$dataError||f.keyword$DataError)}reset(){if(this.errsCount===void 0)throw Error(`add "trackErrors" to keyword definition`);(0,f.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,n=c.nil){this.gen.block(()=>{this.check$data(e,n),t()})}check$data(e=c.nil,t=c.nil){if(!this.$data)return;let{gen:n,schemaCode:r,schemaType:i,def:a}=this;n.if((0,c.or)((0,c._)`${r} === undefined`,t)),e!==c.nil&&n.assign(e,!0),(i.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==c.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:t,schemaType:n,def:r,it:a}=this;return(0,c.or)(o(),s());function o(){if(n.length){if(!(t instanceof c.Name))throw Error(`ajv implementation error`);let e=Array.isArray(n)?n:[n];return(0,c._)`${(0,i.checkDataTypes)(e,t,a.opts.strictNumbers,i.DataType.Wrong)}`}return c.nil}function s(){if(r.validateSchema){let n=e.scopeValue(`validate$data`,{ref:r.validateSchema});return(0,c._)`!${n}(${t})`}return c.nil}}subschema(e,t){let n=(0,s.getSubschema)(this.it,e);(0,s.extendSubschemaData)(n,this.it,e),(0,s.extendSubschemaMode)(n,e);let r={...this.it,...n,items:void 0,props:void 0};return b(r,t),r}mergeEvaluated(e,t){let{it:n,gen:r}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=d.mergeEvaluated.props(r,e.props,n.props,t)),n.items!==!0&&e.items!==void 0&&(n.items=d.mergeEvaluated.items(r,e.items,n.items,t)))}mergeValidEvaluated(e,t){let{it:n,gen:r}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return r.if(t,()=>this.mergeEvaluated(e,c.Name)),!0}};e.KeywordCxt=B;function re(e,t,n,r){let i=new B(e,n,t);`code`in n?n.code(i,r):i.$data&&n.validate?(0,o.funcKeywordCode)(i,n):`macro`in n?(0,o.macroKeywordCode)(i,n):(n.compile||n.validate)&&(0,o.funcKeywordCode)(i,n)}var ie=/^\/(?:[^~]|~0|~1)*$/,ae=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function oe(e,{dataLevel:t,dataNames:n,dataPathArr:r}){let i,a;if(e===``)return l.default.rootData;if(e[0]===`/`){if(!ie.test(e))throw Error(`Invalid JSON-pointer: ${e}`);i=e,a=l.default.rootData}else{let o=ae.exec(e);if(!o)throw Error(`Invalid JSON-pointer: ${e}`);let s=+o[1];if(i=o[2],i===`#`){if(s>=t)throw Error(u(`property/index`,s));return r[t-s]}if(s>t)throw Error(u(`data`,s));if(a=n[t-s],!i)return a}let o=a,s=i.split(`/`);for(let e of s)e&&(a=(0,c._)`${a}${(0,c.getProperty)((0,d.unescapeJsonPointer)(e))}`,o=(0,c._)`${o} && ${a}`);return o;function u(e,n){return`Cannot access ${e} ${n} levels up, current level is ${t}`}}e.getData=oe})),Kz=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=class extends Error{constructor(e){super(`validation failed`),this.errors=e,this.ajv=this.validation=!0}}})),qz=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Wz();e.default=class extends Error{constructor(e,n,r,i){super(i||`can't resolve reference ${r} from id ${n}`),this.missingRef=(0,t.resolveUrl)(e,n,r),this.missingSchema=(0,t.normalizeId)((0,t.getFullPath)(e,this.missingRef))}}})),Jz=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;var t=Az(),n=Kz(),r=Mz(),i=Wz(),a=jz(),o=Gz(),s=class{constructor(e){this.refs={},this.dynamicAnchors={};let t;typeof e.schema==`object`&&(t=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=e.baseId??(0,i.normalizeId)(t?.[e.schemaId||`$id`]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=t?.$async,this.refs={}}};e.SchemaEnv=s;function c(e){let a=d.call(this,e);if(a)return a;let s=(0,i.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:c,lines:l}=this.opts.code,{ownProperties:u}=this.opts,f=new t.CodeGen(this.scope,{es5:c,lines:l,ownProperties:u}),p;e.$async&&(p=f.scopeValue(`Error`,{ref:n.default,code:(0,t._)`require("ajv/dist/runtime/validation_error").default`}));let m=f.scopeName(`validate`);e.validateName=m;let h={gen:f,allErrors:this.opts.allErrors,data:r.default.data,parentData:r.default.parentData,parentDataProperty:r.default.parentDataProperty,dataNames:[r.default.data],dataPathArr:[t.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:f.scopeValue(`schema`,this.opts.code.source===!0?{ref:e.schema,code:(0,t.stringify)(e.schema)}:{ref:e.schema}),validateName:m,ValidationError:p,schema:e.schema,schemaEnv:e,rootId:s,baseId:e.baseId||s,schemaPath:t.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?``:`#`),errorPath:(0,t._)`""`,opts:this.opts,self:this},g;try{this._compilations.add(e),(0,o.validateFunctionCode)(h),f.optimize(this.opts.code.optimize);let n=f.toString();g=`${f.scopeRefs(r.default.scope)}return ${n}`,this.opts.code.process&&(g=this.opts.code.process(g,e));let i=Function(`${r.default.self}`,`${r.default.scope}`,g)(this,this.scope.get());if(this.scope.value(m,{ref:i}),i.errors=null,i.schema=e.schema,i.schemaEnv=e,e.$async&&(i.$async=!0),this.opts.code.source===!0&&(i.source={validateName:m,validateCode:n,scopeValues:f._values}),this.opts.unevaluated){let{props:e,items:n}=h;i.evaluated={props:e instanceof t.Name?void 0:e,items:n instanceof t.Name?void 0:n,dynamicProps:e instanceof t.Name,dynamicItems:n instanceof t.Name},i.source&&(i.source.evaluated=(0,t.stringify)(i.evaluated))}return e.validate=i,e}catch(t){throw delete e.validate,delete e.validateName,g&&this.logger.error(`Error compiling schema, function code:`,g),t}finally{this._compilations.delete(e)}}e.compileSchema=c;function l(e,t,n){n=(0,i.resolveUrl)(this.opts.uriResolver,t,n);let r=e.refs[n];if(r)return r;let a=p.call(this,e,n);if(a===void 0){let r=e.localRefs?.[n],{schemaId:i}=this.opts;r&&(a=new s({schema:r,schemaId:i,root:e,baseId:t}))}if(a!==void 0)return e.refs[n]=u.call(this,a)}e.resolveRef=l;function u(e){return(0,i.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:c.call(this,e)}function d(e){for(let t of this._compilations)if(f(t,e))return t}e.getCompilingSchema=d;function f(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function p(e,t){let n;for(;typeof(n=this.refs[t])==`string`;)t=n;return n||this.schemas[t]||m.call(this,e,t)}function m(e,t){let n=this.opts.uriResolver.parse(t),r=(0,i._getFullPath)(this.opts.uriResolver,n),a=(0,i.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&r===a)return g.call(this,n,e);let o=(0,i.normalizeId)(r),l=this.refs[o]||this.schemas[o];if(typeof l==`string`){let t=m.call(this,e,l);return typeof t?.schema==`object`?g.call(this,n,t):void 0}if(typeof l?.schema==`object`){if(l.validate||c.call(this,l),o===(0,i.normalizeId)(t)){let{schema:t}=l,{schemaId:n}=this.opts,r=t[n];return r&&(a=(0,i.resolveUrl)(this.opts.uriResolver,a,r)),new s({schema:t,schemaId:n,root:e,baseId:a})}return g.call(this,n,l)}}e.resolveSchema=m;var h=new Set([`properties`,`patternProperties`,`enum`,`dependencies`,`definitions`]);function g(e,{baseId:t,schema:n,root:r}){if(e.fragment?.[0]!==`/`)return;for(let r of e.fragment.slice(1).split(`/`)){if(typeof n==`boolean`)return;let e=n[(0,a.unescapeFragment)(r)];if(e===void 0)return;n=e;let o=typeof n==`object`&&n[this.opts.schemaId];!h.has(r)&&o&&(t=(0,i.resolveUrl)(this.opts.uriResolver,t,o))}let o;if(typeof n!=`boolean`&&n.$ref&&!(0,a.schemaHasRulesButRef)(n,this.RULES)){let e=(0,i.resolveUrl)(this.opts.uriResolver,t,n.$ref);o=m.call(this,r,e)}let{schemaId:c}=this.opts;if(o||=new s({schema:n,schemaId:c,root:r,baseId:t}),o.schema!==o.root.schema)return o}})),Yz=c({$id:()=>Xz,additionalProperties:()=>!1,default:()=>tB,description:()=>Zz,properties:()=>eB,required:()=>$z,type:()=>Qz}),Xz,Zz,Qz,$z,eB,tB,nB=o((()=>{Xz=`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`,Zz=`Meta-schema for $data reference (JSON AnySchema extension proposal)`,Qz=`object`,$z=[`$data`],eB={$data:{type:`string`,anyOf:[{format:`relative-json-pointer`},{format:`json-pointer`}]}},tB={$id:Xz,description:Zz,type:Qz,required:$z,properties:eB,additionalProperties:!1}})),rB=s(((e,t)=>{var n=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),r=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),i=RegExp.prototype.test.bind(/^\d*$/u),a=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),o=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),s=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u),c=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u),l=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u),u=Array(256);{let e=`0123456789ABCDEF`;for(let t=0;t<256;t++)u[t]=`%`+e[t>>4]+e[t&15]}function d(e){return e<2048?u[192|e>>6]+u[128|e&63]:e<65536?u[224|e>>12]+u[128|e>>6&63]+u[128|e&63]:u[240|e>>18]+u[128|e>>12&63]+u[128|e>>6&63]+u[128|e&63]}function f(e){let t=``,n=0,r=0;for(r=0;r<e.length;r++)if(n=e[r].charCodeAt(0),n!==48){if(!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r];break}for(r+=1;r<e.length;r++){if(n=e[r].charCodeAt(0),!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r]}return t}var p=RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/),m=RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/),h=RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/),g=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function _(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++)if(!h(e[t])){if(e[t]===`%`&&t+2<e.length&&a(e.slice(t+1,t+3))){t+=2;continue}return!1}return!0}function v(e){let t=-1,n=0,r=-1,i=0;for(let a=0;a<e.length;a++)e[a]===`0`?(r===-1&&(r=a),i++,i>n&&(n=i,t=r)):(r=-1,i=0);if(n<2)return e.join(`:`);let a=e.slice(0,t).join(`:`),o=e.slice(t+n).join(`:`);return a+`::`+o}function y(e){let t=e.indexOf(`::`);if(t!==-1&&e.indexOf(`::`,t+1)!==-1)return;let n=t===-1?e.split(`:`):e.slice(0,t).split(`:`),i=t===-1?[]:e.slice(t+2).split(`:`);t!==-1&&(n.length===1&&n[0]===``&&(n.length=0),i.length===1&&i[0]===``&&(i.length=0));let a=n.concat(i),o=0;for(let e=0;e<a.length;e++){let n=a[e];if(n===``)return;if(n.indexOf(`.`)!==-1){if(e!==a.length-1||t!==-1&&i.length===0||!r(n))return;o+=2;continue}if(!p(n))return;a[e]=parseInt(n,16).toString(16),o++}if(t===-1)return o===8?v(a):void 0;if(o>=8)return;let s=a.slice(0,n.length);for(let e=o;e<8;e++)s.push(`0`);for(let e=n.length;e<a.length;e++)s.push(a[e]);return v(s)}function b(e){let t=e[0]===`[`&&e[e.length-1]===`]`;if((e[0]===`[`||e[e.length-1]===`]`)&&!t)return{host:e,isIPV6:!1,error:!0};let n=t?e.slice(1,-1):e;if(t&&m(n))return n=n.toLowerCase(),{host:`[${n}]`,escapedHost:n,isIPV6:!1,isIPVFuture:!0};if(x(n,`:`)<2)return{host:e,isIPV6:!1,error:t};let r=``,i=n.indexOf(`%`);if(i!==-1){let t=n.slice(i,i+3).toLowerCase()===`%25`?3:1;if(r=n.slice(i+t),!_(r))return{host:e,isIPV6:!1,error:!0};n=n.slice(0,i)}let a=y(n);return a===void 0?{host:e,isIPV6:!1,error:!0}:{host:a+(r?`%`+r:``),escapedHost:a+(r?`%25`+r:``),isIPV6:!0}}function x(e,t){let n=0;for(let r=0;r<e.length;r++)e[r]===t&&n++;return n}function S(e){let t=e,n=[],r=-1,i=0;for(;i=t.length;){if(i===1){if(t===`.`)break;if(t===`/`){n.push(`/`);break}n.push(t);break}if(i===2){if(t[0]===`.`){if(t[1]===`.`)break;if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&(t[1]===`.`||t[1]===`/`)){n.push(`/`);break}}else if(i===3&&t===`/..`){n.length!==0&&n.pop(),n.push(`/`);break}if(t[0]===`.`){if(t[1]===`.`){if(t[2]===`/`){t=t.slice(3);continue}}else if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&t[1]===`.`){if(t[2]===`/`){t=t.slice(2);continue}if(t[2]===`.`&&t[3]===`/`){t=t.slice(3),n.length!==0&&n.pop();continue}}if((r=t.indexOf(`/`,1))===-1){n.push(t);break}n.push(t.slice(0,r)),t=t.slice(r)}return n.join(``)}var C={"@":`%40`,"/":`%2F`,"?":`%3F`,"#":`%23`,":":`%3A`},w=/[@/?#:]/g,T=/[@/?#]/g;function E(e,t){let n=t?T:w;return n.lastIndex=0,e.replace(n,e=>C[e])}function D(e,t=!1){if(e.indexOf(`%`)===-1)return e;let n=``;for(let r=0;r<e.length;r++){if(e[r]===`%`&&r+2<e.length){let i=e.slice(r+1,r+3);if(a(i)){let e=i.toUpperCase(),a=String.fromCharCode(parseInt(e,16));t&&o(a)?n+=a:n+=`%`+e,r+=2;continue}}n+=e[r]}return n}function O(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(r===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(a(r)){let e=r.toUpperCase(),i=String.fromCharCode(parseInt(e,16));i!==`.`&&o(i)?t+=i:t+=`%`+e,n+=2;continue}}if(s(r))t+=r;else{let i=e.charCodeAt(n);if(i<128)t+=P(i)?r:u[i];else if(i<55296||i>57343)t+=d(i);else if(i<=56319&&n+1<e.length){let r=e.charCodeAt(n+1);r>=56320&&r<=57343?(t+=d(65536+(i-55296<<10)+(r-56320)),n++):t+=d(65533)}else t+=d(65533)}}return t}function k(e,t=!1){let n=``,r=t&&e[0]!==`/`;for(let t=0;t<e.length;t++){let i=e[t];if(i===`%`&&t+2<e.length){let r=e.slice(t+1,t+3);if(a(r)){n+=`%`+r.toUpperCase(),t+=2;continue}}if(i===`/`&&(r=!1),s(i)&&(i!==`:`||!r))n+=i;else{let r=e.charCodeAt(t);if(r<128)n+=u[r];else if(r<55296||r>57343)n+=d(r);else if(r<=56319&&t+1<e.length){let i=e.charCodeAt(t+1);i>=56320&&i<=57343?(n+=d(65536+(r-55296<<10)+(i-56320)),t++):n+=d(65533)}else n+=d(65533)}}return n}function A(e,t){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(i===`%`&&r+2<e.length){let t=e.slice(r+1,r+3);if(a(t)){n+=`%`+t.toUpperCase(),r+=2;continue}}if(t(i))n+=i;else{let t=e.charCodeAt(r);if(t<128)n+=u[t];else if(t<55296||t>57343)n+=d(t);else if(t<=56319&&r+1<e.length){let i=e.charCodeAt(r+1);i>=56320&&i<=57343?(n+=d(65536+(t-55296<<10)+(i-56320)),r++):n+=d(65533)}else n+=d(65533)}}return n}function j(e){return A(e,l)}function M(e){return A(e,c)}function N(e){return A(e,c)}function P(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===42||e===43||e===45||e===46||e===47||e===64||e===95}function F(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(r===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(a(r)){let e=r.toUpperCase(),i=String.fromCharCode(parseInt(e,16));o(i)?t+=i:t+=`%`+e,n+=2;continue}}if(c(r))t+=r;else{let i=e.charCodeAt(n);if(i<128)t+=P(i)?r:u[i];else if(i<55296||i>57343)t+=d(i);else if(i<=56319&&n+1<e.length){let r=e.charCodeAt(n+1);r>=56320&&r<=57343?(t+=d(65536+(i-55296<<10)+(r-56320)),n++):t+=d(65533)}else t+=d(65533)}}return t}function I(e){let t=``;for(let n=0;n<e.length;n++){if(e[n]===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(a(r)){t+=`%`+r.toUpperCase(),n+=2;continue}}t+=escape(e[n])}return t}function L(e){let t=[];if(e.userinfo!==void 0&&(t.push(j(e.userinfo)),t.push(`@`)),e.host!==void 0){let n=e.host;if(!r(n)){let e=b(n);e.isIPV6!==!0&&e.isIPVFuture!==!0&&(n=D(n,!0),e=b(n)),n=e.isIPV6===!0||e.isIPVFuture===!0?`[${e.escapedHost}]`:E(n,!1)}t.push(n)}if(typeof e.port==`number`||typeof e.port==`string`){let n=String(e.port);if(!i(n))throw TypeError(`URI port is malformed.`);t.push(`:`),t.push(n)}return t.length?t.join(``):void 0}t.exports={nonSimpleDomain:g,recomposeAuthority:L,reescapeHostDelimiters:E,normalizePercentEncoding:D,normalizePathEncoding:O,serializePathEncoding:k,normalizeQueryFragmentEncoding:F,encodeUserinfo:j,encodeQuery:M,encodeFragment:N,escapePreservingEscapes:I,removeDotSegments:S,isIPv4:r,isUUID:n,normalizeIPv6:b,stringArrayToHexStripped:f}})),iB=s(((e,t)=>{var{isUUID:n}=rB(),r=/^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu,i=[`http`,`https`,`ws`,`wss`,`urn`,`urn:uuid`];function a(e){return i.indexOf(e)!==-1}function o(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]===`w`||e.scheme[0]===`W`)&&(e.scheme[1]===`s`||e.scheme[1]===`S`)&&(e.scheme[2]===`s`||e.scheme[2]===`S`):!1}function s(e){return e.host||(e.error=e.error||`HTTP URIs must have a host.`),e}function c(e){let t=String(e.scheme).toLowerCase()===`https`;return(e.port===(t?443:80)||e.port===``)&&(e.port=void 0),e.path||=`/`,e}function l(e){return e.secure=o(e),e.resourceName=(e.path||`/`)+(e.query?`?`+e.query:``),e.path=void 0,e.query=void 0,e}function u(e){if((e.port===(o(e)?443:80)||e.port===``)&&(e.port=void 0),typeof e.secure==`boolean`&&(e.scheme=e.secure?`wss`:`ws`,e.secure=void 0),e.resourceName){let t=e.resourceName.indexOf(`?`),n=t===-1?e.resourceName:e.resourceName.slice(0,t);e.path=n&&n!==`/`?n:void 0,e.query=t===-1?void 0:e.resourceName.slice(t+1),e.resourceName=void 0}return e.fragment=void 0,e}function d(e,t){if(!e.path)return e.error=`URN can not be parsed`,e;let n=e.path.match(r);if(n&&n[0]===e.path){let r=t.scheme||e.scheme||`urn`;e.nid=n[1].toLowerCase(),e.nss=n[2];let i=y(`${r}:${t.nid||e.nid}`);e.path=void 0,i&&(e=i.parse(e,t))}else e.error=e.error||`URN can not be parsed.`;return e}function f(e,t){if(e.nid===void 0)throw Error(`URN without nid cannot be serialized`);let n=t.scheme||e.scheme||`urn`,r=e.nid.toLowerCase(),i=y(`${n}:${t.nid||r}`);i&&(e=i.serialize(e,t));let a=e,o=e.nss;return a.path=`${r||t.nid}:${o}`,t.skipEscape=!0,a}function p(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!n(r.uuid))&&(r.error=r.error||`UUID is not valid.`),r}function m(e){let t=e;return t.nss=(e.uuid||``).toLowerCase(),t}var h={scheme:`http`,domainHost:!0,parse:s,serialize:c},g={scheme:`https`,domainHost:h.domainHost,parse:s,serialize:c},_={scheme:`ws`,domainHost:!0,parse:l,serialize:u},v={http:h,https:g,ws:_,wss:{scheme:`wss`,domainHost:_.domainHost,parse:_.parse,serialize:_.serialize},urn:{scheme:`urn`,parse:d,serialize:f,skipNormalize:!0},"urn:uuid":{scheme:`urn:uuid`,parse:p,serialize:m,skipNormalize:!0}};Object.setPrototypeOf(v,null);function y(e){return e&&(v[e]||v[e.toLowerCase()])||void 0}t.exports={wsIsSecure:o,SCHEMES:v,isValidSchemeName:a,getSchemeHandler:y}})),aB=s(((e,t)=>{var{normalizeIPv6:n,removeDotSegments:r,recomposeAuthority:i,normalizePercentEncoding:a,normalizePathEncoding:o,serializePathEncoding:s,normalizeQueryFragmentEncoding:c,encodeQuery:l,encodeFragment:u,reescapeHostDelimiters:d,isIPv4:f,nonSimpleDomain:p}=rB(),{SCHEMES:m,getSchemeHandler:h}=iB(),g=/^[A-Za-z][A-Za-z0-9+.-]*$/u,_=`URI scheme is malformed.`;function v(e){let t=unescape(String(e));if(!g.test(t))throw TypeError(_);return t}function y(e,t){return typeof e==`string`?e=P(e,t):typeof e==`object`&&(e=N(C(e,t),t)),e}function b(e,t,r){let i=r?Object.assign({scheme:`null`},r):{scheme:`null`},{parsed:a,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:c,malformedHost:l,malformedScheme:u}=M(e,i),{parsed:d,malformedAuthorityOrPort:p,malformedPercentEncoding:m,malformedSchemeSpecific:g,malformedHost:_,malformedScheme:v}=M(t,i);if(o||p||s||m||c||g||l||_||u||v)throw Error(a.error||d.error||`URI is malformed.`);let y=x(a,d,i,!0),b=h(r&&r.scheme||y.scheme),S=y.host,w=S!==void 0&&S!==``&&(f(S)||n(S).isIPV6);j(y,r||{},b,w);let T=S&&S.indexOf(`%`)!==-1&&!/\P{ASCII}/u.test(S);if(y.error&&!T)throw Error(y.error);return i.skipEscape=!0,C(y,i)}function x(e,t,n,i){let a={};return i||(e=N(C(e,n),n),t=N(C(t,n),n)),n||={},!n.tolerant&&t.scheme?(a.scheme=t.scheme,a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.path?(t.path[0]===`/`?a.path=r(t.path):(a.path=(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?`/`+t.path:e.path?e.path.slice(0,e.path.lastIndexOf(`/`)+1)+t.path:t.path,a.path=r(a.path)),a.query=t.query):(a.path=e.path,a.query=t.query===void 0?e.query:t.query),a.userinfo=e.userinfo,a.host=e.host,a.port=e.port),a.scheme=e.scheme),a.fragment=t.fragment,a}function S(e,t,n){let r=I(e,n),i=I(t,n);return r!==void 0&&i!==void 0&&r===i}function C(e,t){let n={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:``},o=Object.assign({},t),c=[];n.scheme&&=v(n.scheme);let d=h(o.scheme||n.scheme);d&&d.serialize&&d.serialize(n,o);let f=n.userinfo!==void 0||n.host!==void 0||n.port!==void 0,p=!o.skipEscape&&n.scheme===void 0&&!f;n.path!==void 0&&(n.path=o.skipEscape?a(n.path):s(n.path,p)),o.reference!==`suffix`&&n.scheme&&(n.scheme=v(n.scheme),c.push(n.scheme,`:`));let m=i(n);if(m!==void 0&&(o.reference!==`suffix`&&c.push(`//`),c.push(m),n.path&&n.path[0]!==`/`&&c.push(`/`)),n.path!==void 0){let e=n.path;!o.absolutePath&&(!d||!d.absolutePath)&&(e=r(e)),p&&(e=s(e,!0)),m===void 0&&e[0]===`/`&&e[1]===`/`&&(e=`/%2F`+e.slice(2)),c.push(e)}return n.query!==void 0&&c.push(`?`,l(n.query)),n.fragment!==void 0&&c.push(`#`,u(n.fragment)),c.join(``)}var w=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,T=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,E=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function D(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!==`/`)return`URI path must start with "/" when authority is present.`;if(typeof e.port==`number`&&(e.port<0||e.port>65535))return`URI port is malformed.`}function O(e){if(e===void 0)return!1;let t=e.indexOf(`%`);for(;t!==-1;){if(t+2>=e.length||!/^[\da-f]{2}$/iu.test(e.slice(t+1,t+3)))return!0;t=e.indexOf(`%`,t+3)}return!1}function k(e){return e[0]===`[`&&e[e.length-1]===`]`}function A(e){let t=e[4];return O(e[3])||t!==void 0&&!k(t)&&O(t)||O(e[6])||O(e[7])||O(e[8])}function j(e,t,n,r){if(!t.unicodeSupport&&(!n||!n.unicodeSupport)&&e.host&&!k(e.host)&&(t.domainHost||n&&n.domainHost)&&r===!1&&p(e.host))try{e.host=new URL(`http://`+e.host).hostname}catch(t){return e.error=e.error||`Host's domain name can not be converted to ASCII: `+t,!0}return!1}function M(e,t){let r=Object.assign({},t),i={scheme:void 0,userinfo:void 0,host:``,port:void 0,path:``,query:void 0,fragment:void 0},s=!1,l=!1,u=!1,p=!1,v=!1,y=!1,b=!1;r.reference===`suffix`&&(e=r.scheme?r.scheme+`:`+e:`//`+e);let x=e.match(T);x!==null&&x[1].indexOf(`\\`)!==-1&&(i.error=`URI authority must not contain a literal backslash.`,s=!0);let S=e.match(E);if(S!==null){let e=S[1],t=e.replace(/[\t\n\r]/g,``);t.length>=2&&(t.slice(0,2)===`//`?e.length!==t.length&&(i.error=i.error||`URI authority introducer must not contain whitespace.`,s=!0):(i.error=i.error||`URI authority must not contain a literal backslash.`,s=!0))}let C=e.match(w);if(C){if(i.scheme=C[1],i.userinfo=C[3],i.host=C[4],i.port=parseInt(C[5],10),i.path=C[6]||``,i.query=C[7],i.fragment=C[8],i.scheme!==void 0){let e=unescape(i.scheme);g.test(e)?i.scheme=e.toLowerCase():(i.error=i.error||_,y=!0)}l=A(C),l&&(i.error=i.error||`URI contains malformed percent-encoding.`),isNaN(i.port)&&(i.port=C[5]);let t=D(i,C);if(t!==void 0&&(i.error=i.error||t,s=!0),i.host){if(f(i.host)===!1){let e=k(i.host),t=i.host.indexOf(`[`)!==-1||i.host.indexOf(`]`)!==-1,r=n(i.host);b=r.isIPV6||r.isIPVFuture===!0,v=t&&(!e||r.error===!0),i.host=b?r.host:r.host.toLowerCase(),v&&(i.error=i.error||`URI host is malformed.`,s=!0)}else b=!0}i.reference=i.scheme===void 0&&i.userinfo===void 0&&i.host===void 0&&i.port===void 0&&i.query===void 0&&!i.path?`same-document`:i.scheme===void 0?`relative`:i.fragment===void 0?`absolute`:`uri`,r.reference&&r.reference!==`suffix`&&r.reference!==i.reference&&(i.error=i.error||`URI is not a `+r.reference+` reference.`);let x=h(r.scheme||i.scheme);if(v||(p=j(i,r,x,b)),e.indexOf(`%`)!==-1&&i.host!==void 0&&!v){let e=b?i.host:a(i.host,!0);b||(e=a(e.toLowerCase())),i.host=d(e,b)}(!x||x&&!x.skipNormalize)&&(i.path&&=o(i.path),i.query&&=c(i.query),i.fragment&&=c(i.fragment)),x&&x.parse&&(x.parse(i,r),x===m.urn&&i.nid===void 0&&(u=!0))}else i.error=i.error||`URI can not be parsed.`;return{parsed:i,malformedAuthorityOrPort:s,malformedPercentEncoding:l,malformedSchemeSpecific:u,malformedHost:p,malformedScheme:y}}function N(e,t){return M(e,t).parsed}function P(e,t){return F(e,t).normalized}function F(e,t){let{parsed:n,malformedAuthorityOrPort:r,malformedPercentEncoding:i,malformedSchemeSpecific:a,malformedHost:o,malformedScheme:s}=M(e,t);return{normalized:r||i||a||o||s?e:C(n,t),malformedAuthorityOrPort:r,malformedPercentEncoding:i,malformedSchemeSpecific:a,malformedHost:o,malformedScheme:s}}function I(e,t){if(typeof e!=`string`&&typeof e!=`object`)return;let n;try{n=typeof e==`string`?e:C(e,t)}catch{return}let{normalized:r,malformedAuthorityOrPort:i,malformedPercentEncoding:a,malformedSchemeSpecific:o,malformedHost:s,malformedScheme:c}=F(n,t);return i||a||o||s||c?void 0:r}var L={SCHEMES:m,normalize:y,resolve:b,resolveComponent:x,equal:S,serialize:C,parse:N};t.exports=L,t.exports.default=L,t.exports.fastUri=L})),oB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=aB();t.code=`require("ajv/dist/runtime/uri").default`,e.default=t})),sB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=Gz();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var n=Az();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return n.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return n.CodeGen}});var r=Kz(),i=qz(),a=Fz(),o=Jz(),s=Az(),c=Wz(),l=Lz(),u=jz(),f=(nB(),d(Yz).default),p=oB(),m=(e,t)=>new RegExp(e,t);m.code=`new RegExp`;var h=[`removeAdditional`,`useDefaults`,`coerceTypes`],g=new Set([`validate`,`serialize`,`parse`,`wrapper`,`root`,`schema`,`keyword`,`pattern`,`formats`,`validate$data`,`func`,`obj`,`Error`]),_={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.`},v={ignoreKeywordsWithRef:``,jsPropertySyntax:``,unicode:`"minLength"/"maxLength" account for unicode characters by default.`},y=200;function b(e){let t=e.strict,n=e.code?.optimize,r=n===!0||n===void 0?1:n||0,i=e.code?.regExp??m,a=e.uriResolver??p.default;return{strictSchema:e.strictSchema??t??!0,strictNumbers:e.strictNumbers??t??!0,strictTypes:e.strictTypes??t??`log`,strictTuples:e.strictTuples??t??`log`,strictRequired:e.strictRequired??t??!1,code:e.code?{...e.code,optimize:r,regExp:i}:{optimize:r,regExp:i},loopRequired:e.loopRequired??y,loopEnum:e.loopEnum??y,meta:e.meta??!0,messages:e.messages??!0,inlineRefs:e.inlineRefs??!0,schemaId:e.schemaId??`$id`,addUsedSchema:e.addUsedSchema??!0,validateSchema:e.validateSchema??!0,validateFormats:e.validateFormats??!0,unicodeRegExp:e.unicodeRegExp??!0,int32range:e.int32range??!0,uriResolver:a}}var x=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...b(e)};let{es5:t,lines:n}=this.opts.code;this.scope=new s.ValueScope({scope:{},prefixes:g,es5:t,lines:n}),this.logger=k(e.logger);let r=e.validateFormats;e.validateFormats=!1,this.RULES=(0,a.getRules)(),S.call(this,_,e,`NOT SUPPORTED`),S.call(this,v,e,`DEPRECATED`,`warn`),this._metaOpts=D.call(this),e.formats&&T.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&E.call(this,e.keywords),typeof e.meta==`object`&&this.addMetaSchema(e.meta),w.call(this),e.validateFormats=r}_addVocabularies(){this.addKeyword(`$async`)}_addDefaultMetaSchema(){let{$data:e,meta:t,schemaId:n}=this.opts,r=f;n===`id`&&(r={...f},r.id=r.$id,delete r.$id),t&&e&&this.addMetaSchema(r,r[n],!1)}defaultMeta(){let{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta=typeof e==`object`?e[t]||e:void 0}validate(e,t){let n;if(typeof e==`string`){if(n=this.getSchema(e),!n)throw Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let r=n(t);return`$async`in n||(this.errors=n.errors),r}compile(e,t){let n=this._addSchema(e,t);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,t){if(typeof this.opts.loadSchema!=`function`)throw Error(`options.loadSchema should be a function`);let{loadSchema:n}=this.opts;return r.call(this,e,t);async function r(e,t){await a.call(this,e.$schema);let n=this._addSchema(e,t);return n.validate||o.call(this,n)}async function a(e){e&&!this.getSchema(e)&&await r.call(this,{$ref:e},!0)}async function o(e){try{return this._compileSchemaEnv(e)}catch(t){if(!(t instanceof i.default))throw t;return s.call(this,t),await c.call(this,t.missingSchema),o.call(this,e)}}function s({missingSchema:e,missingRef:t}){if(this.refs[e])throw Error(`AnySchema ${e} is loaded but ${t} cannot be resolved`)}async function c(e){let n=await l.call(this,e);this.refs[e]||await a.call(this,n.$schema),this.refs[e]||this.addSchema(n,e,t)}async function l(e){let t=this._loading[e];if(t)return t;try{return await(this._loading[e]=n(e))}finally{delete this._loading[e]}}}addSchema(e,t,n,r=this.opts.validateSchema){if(Array.isArray(e)){for(let t of e)this.addSchema(t,void 0,n,r);return this}let i;if(typeof e==`object`){let{schemaId:t}=this.opts;if(i=e[t],i!==void 0&&typeof i!=`string`)throw Error(`schema ${t} must be string`)}return t=(0,c.normalizeId)(t||i),this._checkUnique(t),this.schemas[t]=this._addSchema(e,n,t,r,!0),this}addMetaSchema(e,t,n=this.opts.validateSchema){return this.addSchema(e,t,!0,n),this}validateSchema(e,t){if(typeof e==`boolean`)return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!=`string`)throw Error(`$schema must be a string`);if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn(`meta-schema not available`),this.errors=null,!0;let r=this.validate(n,e);if(!r&&t){let e=`schema is invalid: `+this.errorsText();if(this.opts.validateSchema===`log`)this.logger.error(e);else throw Error(e)}return r}getSchema(e){let t;for(;typeof(t=C.call(this,e))==`string`;)e=t;if(t===void 0){let{schemaId:n}=this.opts,r=new o.SchemaEnv({schema:{},schemaId:n});if(t=o.resolveSchema.call(this,r,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case`undefined`:return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case`string`:{let t=C.call(this,e);return typeof t==`object`&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case`object`:{let t=e;this._cache.delete(t);let n=e[this.opts.schemaId];return n&&(n=(0,c.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw Error(`ajv.removeSchema: invalid parameter`)}}addVocabulary(e){for(let t of e)this.addKeyword(t);return this}addKeyword(e,t){let n;if(typeof e==`string`)n=e,typeof t==`object`&&(this.logger.warn(`these parameters are deprecated, see docs for addKeyword`),t.keyword=n);else if(typeof e==`object`&&t===void 0){if(t=e,n=t.keyword,Array.isArray(n)&&!n.length)throw Error(`addKeywords: keyword must be string or non-empty array`)}else throw Error(`invalid addKeywords parameters`);if(j.call(this,n,t),!t)return(0,u.eachItem)(n,e=>M.call(this,e)),this;P.call(this,t);let r={...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)};return(0,u.eachItem)(n,r.type.length===0?e=>M.call(this,e,r):e=>r.type.forEach(t=>M.call(this,e,r,t))),this}getKeyword(e){let t=this.RULES.all[e];return typeof t==`object`?t.definition:!!t}removeKeyword(e){let{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(let n of t.rules){let t=n.rules.findIndex(t=>t.keyword===e);t>=0&&n.rules.splice(t,1)}return this}addFormat(e,t){return typeof t==`string`&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=`, `,dataVar:n=`data`}={}){return!e||e.length===0?`No errors`:e.map(e=>`${n}${e.instancePath} ${e.message}`).reduce((e,n)=>e+t+n)}$dataMetaSchema(e,t){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let r of t){let t=r.split(`/`).slice(1),i=e;for(let e of t)i=i[e];for(let e in n){let t=n[e];if(typeof t!=`object`)continue;let{$data:r}=t.definition,a=i[e];r&&a&&(i[e]=I(a))}}return e}_removeAllSchemas(e,t){for(let n in e){let r=e[n];(!t||t.test(n))&&(typeof r==`string`?delete e[n]:r&&!r.meta&&(this._cache.delete(r.schema),delete e[n]))}}_addSchema(e,t,n,r=this.opts.validateSchema,i=this.opts.addUsedSchema){let a,{schemaId:s}=this.opts;if(typeof e==`object`)a=e[s];else if(this.opts.jtd)throw Error(`schema must be object`);else if(typeof e!=`boolean`)throw Error(`schema must be object or boolean`);let l=this._cache.get(e);if(l!==void 0)return l;n=(0,c.normalizeId)(a||n);let u=c.getSchemaRefs.call(this,e,n);return l=new o.SchemaEnv({schema:e,schemaId:s,meta:t,baseId:n,localRefs:u}),this._cache.set(l.schema,l),i&&!n.startsWith(`#`)&&(n&&this._checkUnique(n),this.refs[n]=l),r&&this.validateSchema(e,!0),l}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):o.compileSchema.call(this,e),!e.validate)throw Error(`ajv implementation error`);return e.validate}_compileMetaSchema(e){let t=this.opts;this.opts=this._metaOpts;try{o.compileSchema.call(this,e)}finally{this.opts=t}}};x.ValidationError=r.default,x.MissingRefError=i.default,e.default=x;function S(e,t,n,r=`error`){for(let i in e){let a=i;a in t&&this.logger[r](`${n}: option ${i}. ${e[a]}`)}}function C(e){return e=(0,c.normalizeId)(e),this.schemas[e]||this.refs[e]}function w(){let e=this.opts.schemas;if(e){if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}}function T(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function E(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn(`keywords option as map is deprecated, pass array`);for(let t in e){let n=e[t];n.keyword||=t,this.addKeyword(n)}}function D(){let e={...this.opts};for(let t of h)delete e[t];return e}var O={log(){},warn(){},error(){}};function k(e){if(e===!1)return O;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw Error(`logger must implement log, warn and error methods`)}var A=/^[a-z_$][a-z0-9_$:-]*$/i;function j(e,t){let{RULES:n}=this;if((0,u.eachItem)(e,e=>{if(n.keywords[e])throw Error(`Keyword ${e} is already defined`);if(!A.test(e))throw Error(`Keyword ${e} has invalid name`)}),t&&t.$data&&!(`code`in t||`validate`in t))throw Error(`$data keyword must have "code" or "validate" function`)}function M(e,t,n){var r;let i=t?.post;if(n&&i)throw Error(`keyword with "post" flag cannot have "type"`);let{RULES:a}=this,o=i?a.post:a.rules.find(({type:e})=>e===n);if(o||(o={type:n,rules:[]},a.rules.push(o)),a.keywords[e]=!0,!t)return;let s={keyword:e,definition:{...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)}};t.before?N.call(this,o,s,t.before):o.rules.push(s),a.all[e]=s,(r=t.implements)==null||r.forEach(e=>this.addKeyword(e))}function N(e,t,n){let r=e.rules.findIndex(e=>e.keyword===n);r>=0?e.rules.splice(r,0,t):(e.rules.push(t),this.logger.warn(`rule ${n} is not defined`))}function P(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=I(t)),e.validateSchema=this.compile(t,!0))}var F={$ref:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`};function I(e){return{anyOf:[e,F]}}})),cB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default={keyword:`id`,code(){throw Error(`NOT SUPPORTED: keyword "id", use "$id" for schema ID`)}}})),lB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.callRef=e.getValidate=void 0;var t=qz(),n=zz(),r=Az(),i=Mz(),a=Jz(),o=jz(),s={keyword:`$ref`,schemaType:`string`,code(e){let{gen:n,schema:i,it:o}=e,{baseId:s,schemaEnv:u,validateName:d,opts:f,self:p}=o,{root:m}=u;if((i===`#`||i===`#/`)&&s===m.baseId)return g();let h=a.resolveRef.call(p,m,s,i);if(h===void 0)throw new t.default(o.opts.uriResolver,s,i);if(h instanceof a.SchemaEnv)return _(h);return v(h);function g(){if(u===m)return l(e,d,u,u.$async);let t=n.scopeValue(`root`,{ref:m});return l(e,(0,r._)`${t}.validate`,m,m.$async)}function _(t){l(e,c(e,t),t,t.$async)}function v(t){let a=n.scopeValue(`schema`,f.code.source===!0?{ref:t,code:(0,r.stringify)(t)}:{ref:t}),o=n.name(`valid`),s=e.subschema({schema:t,dataTypes:[],schemaPath:r.nil,topSchemaRef:a,errSchemaPath:i},o);e.mergeEvaluated(s),e.ok(o)}}};function c(e,t){let{gen:n}=e;return t.validate?n.scopeValue(`validate`,{ref:t.validate}):(0,r._)`${n.scopeValue(`wrapper`,{ref:t})}.validate`}e.getValidate=c;function l(e,t,a,s){let{gen:c,it:l}=e,{allErrors:u,schemaEnv:d,opts:f}=l,p=f.passContext?i.default.this:r.nil;s?m():h();function m(){if(!d.$async)throw Error(`async schema referenced by sync schema`);let i=c.let(`valid`);c.try(()=>{c.code((0,r._)`await ${(0,n.callValidateCode)(e,t,p)}`),_(t),u||c.assign(i,!0)},e=>{c.if((0,r._)`!(${e} instanceof ${l.ValidationError})`,()=>c.throw(e)),g(e),u||c.assign(i,!1)}),e.ok(i)}function h(){e.result((0,n.callValidateCode)(e,t,p),()=>_(t),()=>g(t))}function g(e){let t=(0,r._)`${e}.errors`;c.assign(i.default.vErrors,(0,r._)`${i.default.vErrors} === null ? ${t} : ${i.default.vErrors}.concat(${t})`),c.assign(i.default.errors,(0,r._)`${i.default.vErrors}.length`)}function _(e){if(!l.opts.unevaluated)return;let t=a?.validate?.evaluated;if(l.props!==!0){if(t&&!t.dynamicProps)t.props!==void 0&&(l.props=o.mergeEvaluated.props(c,t.props,l.props));else{let t=c.var(`props`,(0,r._)`${e}.evaluated.props`);l.props=o.mergeEvaluated.props(c,t,l.props,r.Name)}}if(l.items!==!0){if(t&&!t.dynamicItems)t.items!==void 0&&(l.items=o.mergeEvaluated.items(c,t.items,l.items));else{let t=c.var(`items`,(0,r._)`${e}.evaluated.items`);l.items=o.mergeEvaluated.items(c,t,l.items,r.Name)}}}}e.callRef=l,e.default=s})),uB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=cB(),n=lB();e.default=[`$schema`,`$id`,`$defs`,`$vocabulary`,{keyword:`$comment`},`definitions`,t.default,n.default]})),dB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Az(),n=t.operators,r={maximum:{okStr:`<=`,ok:n.LTE,fail:n.GT},minimum:{okStr:`>=`,ok:n.GTE,fail:n.LT},exclusiveMaximum:{okStr:`<`,ok:n.LT,fail:n.GTE},exclusiveMinimum:{okStr:`>`,ok:n.GT,fail:n.LTE}};e.default={keyword:Object.keys(r),type:`number`,schemaType:`number`,$data:!0,error:{message:({keyword:e,schemaCode:n})=>(0,t.str)`must be ${r[e].okStr} ${n}`,params:({keyword:e,schemaCode:n})=>(0,t._)`{comparison: ${r[e].okStr}, limit: ${n}}`},code(e){let{keyword:n,data:i,schemaCode:a}=e;e.fail$data((0,t._)`${i} ${r[n].fail} ${a} || isNaN(${i})`)}}})),fB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Az();e.default={keyword:`multipleOf`,type:`number`,schemaType:`number`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,t._)`{multipleOf: ${e}}`},code(e){let{gen:n,data:r,schemaCode:i,it:a}=e,o=a.opts.multipleOfPrecision,s=n.let(`res`),c=o?(0,t._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${o}`:(0,t._)`${s} !== parseInt(${s})`;e.fail$data((0,t._)`(${i} === 0 || (${s} = ${r}/${i}, ${c}))`)}}})),pB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r<t;)n++,i=e.charCodeAt(r++),i>=55296&&i<=56319&&r<t&&(i=e.charCodeAt(r),(i&64512)==56320&&r++);return n}e.default=t,t.code=`require("ajv/dist/runtime/ucs2length").default`})),mB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Az(),n=jz(),r=pB();e.default={keyword:[`maxLength`,`minLength`],type:`string`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxLength`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} characters`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:i,data:a,schemaCode:o,it:s}=e,c=i===`maxLength`?t.operators.GT:t.operators.LT,l=s.opts.unicode===!1?(0,t._)`${a}.length`:(0,t._)`${(0,n.useFunc)(e.gen,r.default)}(${a})`;e.fail$data((0,t._)`${l} ${c} ${o}`)}}})),hB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=zz(),n=jz(),r=Az();e.default={keyword:`pattern`,type:`string`,schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,r.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,r._)`{pattern: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e,u=l.opts.unicodeRegExp?`u`:``;if(o){let{regExp:t}=l.opts.code,o=t.code===`new RegExp`?(0,r._)`new RegExp`:(0,n.useFunc)(i,t),s=i.let(`valid`);i.try(()=>i.assign(s,(0,r._)`${o}(${c}, ${u}).test(${a})`),()=>i.assign(s,!1)),e.fail$data((0,r._)`!${s}`)}else{let n=(0,t.usePattern)(e,s);e.fail$data((0,r._)`!${n}.test(${a})`)}}}})),gB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Az();e.default={keyword:[`maxProperties`,`minProperties`],type:`object`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxProperties`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} properties`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxProperties`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`Object.keys(${r}).length ${a} ${i}`)}}})),_B=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=zz(),n=Az(),r=jz();e.default={keyword:`required`,type:`object`,schemaType:`array`,$data:!0,error:{message:({params:{missingProperty:e}})=>(0,n.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,n._)`{missingProperty: ${e}}`},code(e){let{gen:i,schema:a,schemaCode:o,data:s,$data:c,it:l}=e,{opts:u}=l;if(!c&&a.length===0)return;let d=a.length>=u.loopRequired;if(l.allErrors?f():p(),u.strictRequired){let t=e.parentSchema.properties,{definedProperties:n}=e.it;for(let e of a)if(t?.[e]===void 0&&!n.has(e)){let t=`required property "${e}" is not defined at "${l.schemaEnv.baseId+l.errSchemaPath}" (strictRequired)`;(0,r.checkStrictMode)(l,t,l.opts.strictRequired)}}function f(){if(d||c)e.block$data(n.nil,m);else for(let n of a)(0,t.checkReportMissingProp)(e,n)}function p(){let n=i.let(`missing`);if(d||c){let t=i.let(`valid`,!0);e.block$data(t,()=>h(n,t)),e.ok(t)}else i.if((0,t.checkMissingProp)(e,a,n)),(0,t.reportMissingProp)(e,n),i.else()}function m(){i.forOf(`prop`,o,n=>{e.setParams({missingProperty:n}),i.if((0,t.noPropertyInData)(i,s,n,u.ownProperties),()=>e.error())})}function h(r,a){e.setParams({missingProperty:r}),i.forOf(r,o,()=>{i.assign(a,(0,t.propertyInData)(i,s,r,u.ownProperties)),i.if((0,n.not)(a),()=>{e.error(),i.break()})},n.nil)}}}})),vB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Az();e.default={keyword:[`maxItems`,`minItems`],type:`array`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxItems`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} items`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxItems`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`${r}.length ${a} ${i}`)}}})),yB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Hz();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t})),bB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Lz(),n=Az(),r=jz(),i=yB();e.default={keyword:`uniqueItems`,type:`array`,schemaType:`boolean`,$data:!0,error:{message:({params:{i:e,j:t}})=>(0,n.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,n._)`{i: ${e}, j: ${t}}`},code(e){let{gen:a,data:o,$data:s,schema:c,parentSchema:l,schemaCode:u,it:d}=e;if(!s&&!c)return;let f=a.let(`valid`),p=l.items?(0,t.getSchemaTypes)(l.items):[];e.block$data(f,m,(0,n._)`${u} === false`),e.ok(f);function m(){let t=a.let(`i`,(0,n._)`${o}.length`),r=a.let(`j`);e.setParams({i:t,j:r}),a.assign(f,!0),a.if((0,n._)`${t} > 1`,()=>(h()?g:_)(t,r))}function h(){return p.length>0&&!p.some(e=>e===`object`||e===`array`)}function g(r,i){let s=a.name(`item`),c=(0,t.checkDataTypes)(p,s,d.opts.strictNumbers,t.DataType.Wrong),l=a.const(`indices`,(0,n._)`{}`);a.for((0,n._)`;${r}--;`,()=>{a.let(s,(0,n._)`${o}[${r}]`),a.if(c,(0,n._)`continue`),p.length>1&&a.if((0,n._)`typeof ${s} == "string"`,(0,n._)`${s} += "_"`),a.if((0,n._)`typeof ${l}[${s}] == "number"`,()=>{a.assign(i,(0,n._)`${l}[${s}]`),e.error(),a.assign(f,!1).break()}).code((0,n._)`${l}[${s}] = ${r}`)})}function _(t,s){let c=(0,r.useFunc)(a,i.default),l=a.name(`outer`);a.label(l).for((0,n._)`;${t}--;`,()=>a.for((0,n._)`${s} = ${t}; ${s}--;`,()=>a.if((0,n._)`${c}(${o}[${t}], ${o}[${s}])`,()=>{e.error(),a.assign(f,!1).break(l)})))}}}})),xB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Az(),n=jz(),r=yB();e.default={keyword:`const`,$data:!0,error:{message:`must be equal to constant`,params:({schemaCode:e})=>(0,t._)`{allowedValue: ${e}}`},code(e){let{gen:i,data:a,$data:o,schemaCode:s,schema:c}=e;o||c&&typeof c==`object`?e.fail$data((0,t._)`!${(0,n.useFunc)(i,r.default)}(${a}, ${s})`):e.fail((0,t._)`${c} !== ${a}`)}}})),SB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Az(),n=jz(),r=yB();e.default={keyword:`enum`,schemaType:`array`,$data:!0,error:{message:`must be equal to one of the allowed values`,params:({schemaCode:e})=>(0,t._)`{allowedValues: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e;if(!o&&s.length===0)throw Error(`enum must have non-empty array`);let u=s.length>=l.opts.loopEnum,d,f=()=>d??=(0,n.useFunc)(i,r.default),p;if(u||o)p=i.let(`valid`),e.block$data(p,m);else{if(!Array.isArray(s))throw Error(`ajv implementation error`);let e=i.const(`vSchema`,c);p=(0,t.or)(...s.map((t,n)=>h(e,n)))}e.pass(p);function m(){i.assign(p,!1),i.forOf(`v`,c,e=>i.if((0,t._)`${f()}(${a}, ${e})`,()=>i.assign(p,!0).break()))}function h(e,n){let r=s[n];return typeof r==`object`&&r?(0,t._)`${f()}(${a}, ${e}[${n}])`:(0,t._)`${a} === ${r}`}}}})),CB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=dB(),n=fB(),r=mB(),i=hB(),a=gB(),o=_B(),s=vB(),c=bB(),l=xB(),u=SB();e.default=[t.default,n.default,r.default,i.default,a.default,o.default,s.default,c.default,{keyword:`type`,schemaType:[`string`,`array`]},{keyword:`nullable`,schemaType:`boolean`},l.default,u.default]})),wB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateAdditionalItems=void 0;var t=Az(),n=jz(),r={keyword:`additionalItems`,type:`array`,schemaType:[`boolean`,`object`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{parentSchema:t,it:r}=e,{items:a}=t;if(!Array.isArray(a)){(0,n.checkStrictMode)(r,`"additionalItems" is ignored when "items" is not an array of schemas`);return}i(e,a)}};function i(e,r){let{gen:i,schema:a,data:o,keyword:s,it:c}=e;c.items=!0;let l=i.const(`len`,(0,t._)`${o}.length`);if(a===!1)e.setParams({len:r.length}),e.pass((0,t._)`${l} <= ${r.length}`);else if(typeof a==`object`&&!(0,n.alwaysValidSchema)(c,a)){let n=i.var(`valid`,(0,t._)`${l} <= ${r.length}`);i.if((0,t.not)(n),()=>u(n)),e.ok(n)}function u(a){i.forRange(`i`,r.length,l,r=>{e.subschema({keyword:s,dataProp:r,dataPropType:n.Type.Num},a),c.allErrors||i.if((0,t.not)(a),()=>i.break())})}}e.validateAdditionalItems=i,e.default=r})),TB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateTuple=void 0;var t=Az(),n=jz(),r=zz(),i={keyword:`items`,type:`array`,schemaType:[`object`,`array`,`boolean`],before:`uniqueItems`,code(e){let{schema:t,it:i}=e;if(Array.isArray(t))return a(e,`additionalItems`,t);i.items=!0,!(0,n.alwaysValidSchema)(i,t)&&e.ok((0,r.validateArray)(e))}};function a(e,r,i=e.schema){let{gen:a,parentSchema:o,data:s,keyword:c,it:l}=e;f(o),l.opts.unevaluated&&i.length&&l.items!==!0&&(l.items=n.mergeEvaluated.items(a,i.length,l.items));let u=a.name(`valid`),d=a.const(`len`,(0,t._)`${s}.length`);i.forEach((r,i)=>{(0,n.alwaysValidSchema)(l,r)||(a.if((0,t._)`${d} > ${i}`,()=>e.subschema({keyword:c,schemaProp:i,dataProp:i},u)),e.ok(u))});function f(e){let{opts:t,errSchemaPath:a}=l,o=i.length,s=o===e.minItems&&(o===e.maxItems||e[r]===!1);if(t.strictTuples&&!s){let e=`"${c}" is ${o}-tuple, but minItems or maxItems/${r} are not specified or different at path "${a}"`;(0,n.checkStrictMode)(l,e,t.strictTuples)}}}e.validateTuple=a,e.default=i})),EB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=TB();e.default={keyword:`prefixItems`,type:`array`,schemaType:[`array`],before:`uniqueItems`,code:e=>(0,t.validateTuple)(e,`items`)}})),DB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Az(),n=jz(),r=zz(),i=wB();e.default={keyword:`items`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{schema:t,parentSchema:a,it:o}=e,{prefixItems:s}=a;o.items=!0,!(0,n.alwaysValidSchema)(o,t)&&(s?(0,i.validateAdditionalItems)(e,s):e.ok((0,r.validateArray)(e)))}}})),OB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Az(),n=jz();e.default={keyword:`contains`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,trackErrors:!0,error:{message:({params:{min:e,max:n}})=>n===void 0?(0,t.str)`must contain at least ${e} valid item(s)`:(0,t.str)`must contain at least ${e} and no more than ${n} valid item(s)`,params:({params:{min:e,max:n}})=>n===void 0?(0,t._)`{minContains: ${e}}`:(0,t._)`{minContains: ${e}, maxContains: ${n}}`},code(e){let{gen:r,schema:i,parentSchema:a,data:o,it:s}=e,c,l,{minContains:u,maxContains:d}=a;s.opts.next?(c=u===void 0?1:u,l=d):c=1;let f=r.const(`len`,(0,t._)`${o}.length`);if(e.setParams({min:c,max:l}),l===void 0&&c===0){(0,n.checkStrictMode)(s,`"minContains" == 0 without "maxContains": "contains" keyword ignored`);return}if(l!==void 0&&c>l){(0,n.checkStrictMode)(s,`"minContains" > "maxContains" is always invalid`),e.fail();return}if((0,n.alwaysValidSchema)(s,i)){let n=(0,t._)`${f} >= ${c}`;l!==void 0&&(n=(0,t._)`${n} && ${f} <= ${l}`),e.pass(n);return}s.items=!0;let p=r.name(`valid`);l===void 0&&c===1?h(p,()=>r.if(p,()=>r.break())):c===0?(r.let(p,!0),l!==void 0&&r.if((0,t._)`${o}.length > 0`,m)):(r.let(p,!1),m()),e.result(p,()=>e.reset());function m(){let e=r.name(`_valid`),t=r.let(`count`,0);h(e,()=>r.if(e,()=>g(t)))}function h(t,i){r.forRange(`i`,0,f,r=>{e.subschema({keyword:`contains`,dataProp:r,dataPropType:n.Type.Num,compositeRule:!0},t),i()})}function g(e){r.code((0,t._)`${e}++`),l===void 0?r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0).break()):(r.if((0,t._)`${e} > ${l}`,()=>r.assign(p,!1).break()),c===1?r.assign(p,!0):r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0)))}}}})),kB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;var t=Az(),n=jz(),r=zz();e.error={message:({params:{property:e,depsCount:n,deps:r}})=>{let i=n===1?`property`:`properties`;return(0,t.str)`must have ${i} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:n,deps:r,missingProperty:i}})=>(0,t._)`{property: ${e},
|
|
223
223
|
missingProperty: ${i},
|
|
224
224
|
depsCount: ${n},
|
|
225
|
-
deps: ${r}}`};var i={keyword:`dependencies`,type:`object`,schemaType:`object`,error:e.error,code(e){let[t,n]=a(e);o(e,t),s(e,n)}};function a({schema:e}){let t={},n={};for(let r in e){if(r===`__proto__`)continue;let i=Array.isArray(e[r])?t:n;i[r]=e[r]}return[t,n]}function o(e,n=e.schema){let{gen:i,data:a,it:o}=e;if(Object.keys(n).length===0)return;let s=i.let(`missing`);for(let c in n){let l=n[c];if(l.length===0)continue;let u=(0,r.propertyInData)(i,a,c,o.opts.ownProperties);e.setParams({property:c,depsCount:l.length,deps:l.join(`, `)}),o.allErrors?i.if(u,()=>{for(let t of l)(0,r.checkReportMissingProp)(e,t)}):(i.if((0,t._)`${u} && (${(0,r.checkMissingProp)(e,l,s)})`),(0,r.reportMissingProp)(e,s),i.else())}}e.validatePropertyDeps=o;function s(e,t=e.schema){let{gen:i,data:a,keyword:o,it:s}=e,c=i.name(`valid`);for(let l in t)(0,n.alwaysValidSchema)(s,t[l])||(i.if((0,r.propertyInData)(i,a,l,s.opts.ownProperties),()=>{let t=e.subschema({keyword:o,schemaProp:l},c);e.mergeValidEvaluated(t,c)},()=>i.var(c,!0)),e.ok(c))}e.validateSchemaDeps=s,e.default=i})),wB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=wz(),n=Tz();e.default={keyword:`propertyNames`,type:`object`,schemaType:[`object`,`boolean`],error:{message:`property name must be valid`,params:({params:e})=>(0,t._)`{propertyName: ${e.propertyName}}`},code(e){let{gen:r,schema:i,data:a,it:o}=e;if((0,n.alwaysValidSchema)(o,i))return;let s=r.name(`valid`);r.forIn(`key`,a,n=>{e.setParams({propertyName:n}),e.subschema({keyword:`propertyNames`,data:n,dataTypes:[`string`],propertyName:n,compositeRule:!0},s),r.if((0,t.not)(s),()=>{e.error(!0),o.allErrors||r.break()})}),e.ok(s)}}})),TB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Nz(),n=wz(),r=Ez(),i=Tz();e.default={keyword:`additionalProperties`,type:[`object`],schemaType:[`boolean`,`object`],allowUndefined:!0,trackErrors:!0,error:{message:`must NOT have additional properties`,params:({params:e})=>(0,n._)`{additionalProperty: ${e.additionalProperty}}`},code(e){let{gen:a,schema:o,parentSchema:s,data:c,errsCount:l,it:u}=e;if(!l)throw Error(`ajv implementation error`);let{allErrors:d,opts:f}=u;if(u.props=!0,f.removeAdditional!==`all`&&(0,i.alwaysValidSchema)(u,o))return;let p=(0,t.allSchemaProperties)(s.properties),m=(0,t.allSchemaProperties)(s.patternProperties);h(),e.ok((0,n._)`${l} === ${r.default.errors}`);function h(){a.forIn(`key`,c,e=>{!p.length&&!m.length?v(e):a.if(g(e),()=>v(e))})}function g(r){let o;if(p.length>8){let e=(0,i.schemaRefOrVal)(u,s.properties,`properties`);o=(0,t.isOwnProperty)(a,e,r)}else o=p.length?(0,n.or)(...p.map(e=>(0,n._)`${r} === ${e}`)):n.nil;return m.length&&(o=(0,n.or)(o,...m.map(i=>(0,n._)`${(0,t.usePattern)(e,i)}.test(${r})`))),(0,n.not)(o)}function _(e){a.code((0,n._)`delete ${c}[${e}]`)}function v(t){if(f.removeAdditional===`all`||f.removeAdditional&&o===!1){_(t);return}if(o===!1){e.setParams({additionalProperty:t}),e.error(),d||a.break();return}if(typeof o==`object`&&!(0,i.alwaysValidSchema)(u,o)){let r=a.name(`valid`);f.removeAdditional===`failing`?(y(t,r,!1),a.if((0,n.not)(r),()=>{e.reset(),_(t)})):(y(t,r),d||a.if((0,n.not)(r),()=>a.break()))}}function y(t,n,r){let a={keyword:`additionalProperties`,dataProp:t,dataPropType:i.Type.Str};r===!1&&Object.assign(a,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(a,n)}}}})),EB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=zz(),n=Nz(),r=Tz(),i=TB();e.default={keyword:`properties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,parentSchema:s,data:c,it:l}=e;l.opts.removeAdditional===`all`&&s.additionalProperties===void 0&&i.default.code(new t.KeywordCxt(l,i.default,`additionalProperties`));let u=(0,n.allSchemaProperties)(o);for(let e of u)l.definedProperties.add(e);l.opts.unevaluated&&u.length&&l.props!==!0&&(l.props=r.mergeEvaluated.props(a,(0,r.toHash)(u),l.props));let d=u.filter(e=>!(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0)return;let f=a.name(`valid`);for(let t of d)p(t)?m(t):(a.if((0,n.propertyInData)(a,c,t,l.opts.ownProperties)),m(t),l.allErrors||a.else().var(f,!0),a.endIf()),e.it.definedProperties.add(t),e.ok(f);function p(e){return l.opts.useDefaults&&!l.compositeRule&&o[e].default!==void 0}function m(t){e.subschema({keyword:`properties`,schemaProp:t,dataProp:t},f)}}}})),DB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Nz(),n=wz(),r=Tz(),i=Tz();e.default={keyword:`patternProperties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,data:s,parentSchema:c,it:l}=e,{opts:u}=l,d=(0,t.allSchemaProperties)(o),f=d.filter(e=>(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0||f.length===d.length&&(!l.opts.unevaluated||l.props===!0))return;let p=u.strictSchema&&!u.allowMatchingProperties&&c.properties,m=a.name(`valid`);l.props!==!0&&!(l.props instanceof n.Name)&&(l.props=(0,i.evaluatedPropsToName)(a,l.props));let{props:h}=l;g();function g(){for(let e of d)p&&_(e),l.allErrors?v(e):(a.var(m,!0),v(e),a.if(m))}function _(e){for(let t in p)new RegExp(e).test(t)&&(0,r.checkStrictMode)(l,`property ${t} matches pattern ${e} (use allowMatchingProperties)`)}function v(r){a.forIn(`key`,s,o=>{a.if((0,n._)`${(0,t.usePattern)(e,r)}.test(${o})`,()=>{let t=f.includes(r);t||e.subschema({keyword:`patternProperties`,schemaProp:r,dataProp:o,dataPropType:i.Type.Str},m),l.opts.unevaluated&&h!==!0?a.assign((0,n._)`${h}[${o}]`,!0):!t&&!l.allErrors&&a.if((0,n.not)(m),()=>a.break())})})}}}})),OB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Tz();e.default={keyword:`not`,schemaType:[`object`,`boolean`],trackErrors:!0,code(e){let{gen:n,schema:r,it:i}=e;if((0,t.alwaysValidSchema)(i,r)){e.fail();return}let a=n.name(`valid`);e.subschema({keyword:`not`,compositeRule:!0,createErrors:!1,allErrors:!1},a),e.failResult(a,()=>e.reset(),()=>e.error())},error:{message:`must NOT be valid`}}})),kB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default={keyword:`anyOf`,schemaType:`array`,trackErrors:!0,code:Nz().validateUnion,error:{message:`must match a schema in anyOf`}}})),AB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=wz(),n=Tz();e.default={keyword:`oneOf`,schemaType:`array`,trackErrors:!0,error:{message:`must match exactly one schema in oneOf`,params:({params:e})=>(0,t._)`{passingSchemas: ${e.passing}}`},code(e){let{gen:r,schema:i,parentSchema:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(o.opts.discriminator&&a.discriminator)return;let s=i,c=r.let(`valid`,!1),l=r.let(`passing`,null),u=r.name(`_valid`);e.setParams({passing:l}),r.block(d),e.result(c,()=>e.reset(),()=>e.error(!0));function d(){s.forEach((i,a)=>{let s;(0,n.alwaysValidSchema)(o,i)?r.var(u,!0):s=e.subschema({keyword:`oneOf`,schemaProp:a,compositeRule:!0},u),a>0&&r.if((0,t._)`${u} && ${c}`).assign(c,!1).assign(l,(0,t._)`[${l}, ${a}]`).else(),r.if(u,()=>{r.assign(c,!0),r.assign(l,a),s&&e.mergeEvaluated(s,t.Name)})})}}}})),jB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Tz();e.default={keyword:`allOf`,schemaType:`array`,code(e){let{gen:n,schema:r,it:i}=e;if(!Array.isArray(r))throw Error(`ajv implementation error`);let a=n.name(`valid`);r.forEach((n,r)=>{if((0,t.alwaysValidSchema)(i,n))return;let o=e.subschema({keyword:`allOf`,schemaProp:r},a);e.ok(a),e.mergeEvaluated(o)})}}})),MB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=wz(),n=Tz(),r={keyword:`if`,schemaType:[`object`,`boolean`],trackErrors:!0,error:{message:({params:e})=>(0,t.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,t._)`{failingKeyword: ${e.ifClause}}`},code(e){let{gen:r,parentSchema:a,it:o}=e;a.then===void 0&&a.else===void 0&&(0,n.checkStrictMode)(o,`"if" without "then" and "else" is ignored`);let s=i(o,`then`),c=i(o,`else`);if(!s&&!c)return;let l=r.let(`valid`,!0),u=r.name(`_valid`);if(d(),e.reset(),s&&c){let t=r.let(`ifClause`);e.setParams({ifClause:t}),r.if(u,f(`then`,t),f(`else`,t))}else s?r.if(u,f(`then`)):r.if((0,t.not)(u),f(`else`));e.pass(l,()=>e.error(!0));function d(){let t=e.subschema({keyword:`if`,compositeRule:!0,createErrors:!1,allErrors:!1},u);e.mergeEvaluated(t)}function f(n,i){return()=>{let a=e.subschema({keyword:n},u);r.assign(l,u),e.mergeValidEvaluated(a,l),i?r.assign(i,(0,t._)`${n}`):e.setParams({ifClause:n})}}}};function i(e,t){let r=e.schema[t];return r!==void 0&&!(0,n.alwaysValidSchema)(e,r)}e.default=r})),NB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Tz();e.default={keyword:[`then`,`else`],schemaType:[`object`,`boolean`],code({keyword:e,parentSchema:n,it:r}){n.if===void 0&&(0,t.checkStrictMode)(r,`"${e}" without "if" is ignored`)}}})),PB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=vB(),n=bB(),r=yB(),i=xB(),a=SB(),o=CB(),s=wB(),c=TB(),l=EB(),u=DB(),d=OB(),f=kB(),p=AB(),m=jB(),h=MB(),g=NB();function _(e=!1){let _=[d.default,f.default,p.default,m.default,h.default,g.default,s.default,c.default,o.default,l.default,u.default];return e?_.push(n.default,i.default):_.push(t.default,r.default),_.push(a.default),_}e.default=_})),FB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=wz();e.default={keyword:`format`,type:[`number`,`string`],schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,t._)`{format: ${e}}`},code(e,n){let{gen:r,data:i,$data:a,schema:o,schemaCode:s,it:c}=e,{opts:l,errSchemaPath:u,schemaEnv:d,self:f}=c;if(!l.validateFormats)return;a?p():m();function p(){let a=r.scopeValue(`formats`,{ref:f.formats,code:l.code.formats}),o=r.const(`fDef`,(0,t._)`${a}[${s}]`),c=r.let(`fType`),u=r.let(`format`);r.if((0,t._)`typeof ${o} == "object" && !(${o} instanceof RegExp)`,()=>r.assign(c,(0,t._)`${o}.type || "string"`).assign(u,(0,t._)`${o}.validate`),()=>r.assign(c,(0,t._)`"string"`).assign(u,o)),e.fail$data((0,t.or)(p(),m()));function p(){return l.strictSchema===!1?t.nil:(0,t._)`${s} && !${u}`}function m(){let e=d.$async?(0,t._)`(${o}.async ? await ${u}(${i}) : ${u}(${i}))`:(0,t._)`${u}(${i})`,r=(0,t._)`(typeof ${u} == "function" ? ${e} : ${u}.test(${i}))`;return(0,t._)`${u} && ${u} !== true && ${c} === ${n} && !${r}`}}function m(){let a=f.formats[o];if(!a){m();return}if(a===!0)return;let[s,c,p]=h(a);s===n&&e.pass(g());function m(){if(l.strictSchema===!1){f.logger.warn(e());return}throw Error(e());function e(){return`unknown format "${o}" ignored in schema at path "${u}"`}}function h(e){let n=e instanceof RegExp?(0,t.regexpCode)(e):l.code.formats?(0,t._)`${l.code.formats}${(0,t.getProperty)(o)}`:void 0,i=r.scopeValue(`formats`,{key:o,ref:e,code:n});return typeof e==`object`&&!(e instanceof RegExp)?[e.type||`string`,e.validate,(0,t._)`${i}.validate`]:[`string`,e,i]}function g(){if(typeof a==`object`&&!(a instanceof RegExp)&&a.async){if(!d.$async)throw Error(`async format in sync schema`);return(0,t._)`await ${p}(${i})`}return typeof c==`function`?(0,t._)`${p}(${i})`:(0,t._)`${p}.test(${i})`}}}}})),IB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=[FB().default]})),LB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.contentVocabulary=e.metadataVocabulary=void 0,e.metadataVocabulary=[`title`,`description`,`default`,`deprecated`,`readOnly`,`writeOnly`,`examples`],e.contentVocabulary=[`contentMediaType`,`contentEncoding`,`contentSchema`]})),RB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=iB(),n=_B(),r=PB(),i=IB(),a=LB();e.default=[t.default,n.default,(0,r.default)(),i.default,a.metadataVocabulary,a.contentVocabulary]})),zB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DiscrError=void 0;var t;(function(e){e.Tag=`tag`,e.Mapping=`mapping`})(t||(e.DiscrError=t={}))})),BB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=wz(),n=zB(),r=Hz(),i=Vz(),a=Tz();e.default={keyword:`discriminator`,type:`object`,schemaType:`object`,error:{message:({params:{discrError:e,tagName:t}})=>e===n.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:n,tagName:r}})=>(0,t._)`{error: ${e}, tag: ${r}, tagValue: ${n}}`},code(e){let{gen:o,data:s,schema:c,parentSchema:l,it:u}=e,{oneOf:d}=l;if(!u.opts.discriminator)throw Error(`discriminator: requires discriminator option`);let f=c.propertyName;if(typeof f!=`string`)throw Error(`discriminator: requires propertyName`);if(c.mapping)throw Error(`discriminator: mapping is not supported`);if(!d)throw Error(`discriminator: requires oneOf keyword`);let p=o.let(`valid`,!1),m=o.const(`tag`,(0,t._)`${s}${(0,t.getProperty)(f)}`);o.if((0,t._)`typeof ${m} == "string"`,()=>h(),()=>e.error(!1,{discrError:n.DiscrError.Tag,tag:m,tagName:f})),e.ok(p);function h(){let r=_();o.if(!1);for(let e in r)o.elseIf((0,t._)`${m} === ${e}`),o.assign(p,g(r[e]));o.else(),e.error(!1,{discrError:n.DiscrError.Mapping,tag:m,tagName:f}),o.endIf()}function g(n){let r=o.name(`valid`),i=e.subschema({keyword:`oneOf`,schemaProp:n},r);return e.mergeEvaluated(i,t.Name),r}function _(){let e={},t=o(l),n=!0;for(let e=0;e<d.length;e++){let c=d[e];if(c?.$ref&&!(0,a.schemaHasRulesButRef)(c,u.self.RULES)){let e=c.$ref;if(c=r.resolveRef.call(u.self,u.schemaEnv.root,u.baseId,e),c instanceof r.SchemaEnv&&(c=c.schema),c===void 0)throw new i.default(u.opts.uriResolver,u.baseId,e)}let l=c?.properties?.[f];if(typeof l!=`object`)throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${f}"`);n&&=t||o(c),s(l,e)}if(!n)throw Error(`discriminator: "${f}" must be required`);return e;function o({required:e}){return Array.isArray(e)&&e.includes(f)}function s(e,t){if(e.const)c(e.const,t);else if(e.enum)for(let n of e.enum)c(n,t);else throw Error(`discriminator: "properties/${f}" must have "const" or "enum"`)}function c(t,n){if(typeof t!=`string`||t in e)throw Error(`discriminator: "${f}" values must be unique strings`);e[t]=n}}}}})),VB=c({$id:()=>UB,$schema:()=>HB,default:()=>JB,definitions:()=>GB,properties:()=>qB,title:()=>WB,type:()=>KB}),HB,UB,WB,GB,KB,qB,JB,YB=o((()=>{HB=`http://json-schema.org/draft-07/schema#`,UB=`http://json-schema.org/draft-07/schema#`,WB=`Core schema meta-schema`,GB={schemaArray:{type:`array`,minItems:1,items:{$ref:`#`}},nonNegativeInteger:{type:`integer`,minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:`#/definitions/nonNegativeInteger`},{default:0}]},simpleTypes:{enum:[`array`,`boolean`,`integer`,`null`,`number`,`object`,`string`]},stringArray:{type:`array`,items:{type:`string`},uniqueItems:!0,default:[]}},KB=[`object`,`boolean`],qB={$id:{type:`string`,format:`uri-reference`},$schema:{type:`string`,format:`uri`},$ref:{type:`string`,format:`uri-reference`},$comment:{type:`string`},title:{type:`string`},description:{type:`string`},default:!0,readOnly:{type:`boolean`,default:!1},examples:{type:`array`,items:!0},multipleOf:{type:`number`,exclusiveMinimum:0},maximum:{type:`number`},exclusiveMaximum:{type:`number`},minimum:{type:`number`},exclusiveMinimum:{type:`number`},maxLength:{$ref:`#/definitions/nonNegativeInteger`},minLength:{$ref:`#/definitions/nonNegativeIntegerDefault0`},pattern:{type:`string`,format:`regex`},additionalItems:{$ref:`#`},items:{anyOf:[{$ref:`#`},{$ref:`#/definitions/schemaArray`}],default:!0},maxItems:{$ref:`#/definitions/nonNegativeInteger`},minItems:{$ref:`#/definitions/nonNegativeIntegerDefault0`},uniqueItems:{type:`boolean`,default:!1},contains:{$ref:`#`},maxProperties:{$ref:`#/definitions/nonNegativeInteger`},minProperties:{$ref:`#/definitions/nonNegativeIntegerDefault0`},required:{$ref:`#/definitions/stringArray`},additionalProperties:{$ref:`#`},definitions:{type:`object`,additionalProperties:{$ref:`#`},default:{}},properties:{type:`object`,additionalProperties:{$ref:`#`},default:{}},patternProperties:{type:`object`,additionalProperties:{$ref:`#`},propertyNames:{format:`regex`},default:{}},dependencies:{type:`object`,additionalProperties:{anyOf:[{$ref:`#`},{$ref:`#/definitions/stringArray`}]}},propertyNames:{$ref:`#`},const:!0,enum:{type:`array`,items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:`#/definitions/simpleTypes`},{type:`array`,items:{$ref:`#/definitions/simpleTypes`},minItems:1,uniqueItems:!0}]},format:{type:`string`},contentMediaType:{type:`string`},contentEncoding:{type:`string`},if:{$ref:`#`},then:{$ref:`#`},else:{$ref:`#`},allOf:{$ref:`#/definitions/schemaArray`},anyOf:{$ref:`#/definitions/schemaArray`},oneOf:{$ref:`#/definitions/schemaArray`},not:{$ref:`#`}},JB={$schema:HB,$id:UB,title:WB,definitions:GB,type:KB,properties:qB,default:!0}})),XB=s(((e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv=void 0;var n=tB(),r=RB(),i=BB(),a=(YB(),d(VB).default),o=[`/properties`],s=`http://json-schema.org/draft-07/schema`,c=class extends n.default{_addVocabularies(){super._addVocabularies(),r.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(i.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(a,o):a;this.addMetaSchema(e,s,!1),this.refs[`http://json-schema.org/schema`]=s}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(s)?s:void 0)}};e.Ajv=c,t.exports=e=c,t.exports.Ajv=c,Object.defineProperty(e,"__esModule",{value:!0}),e.default=c;var l=zz();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return l.KeywordCxt}});var u=wz();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return u._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return u.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return u.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return u.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return u.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return u.CodeGen}});var f=Bz();Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return f.default}});var p=Vz();Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return p.default}})})),ZB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0;function t(e,t){return{validate:e,compare:t}}e.fullFormats={date:t(a,o),time:t(c(!0),l),"date-time":t(f(!0),p),"iso-time":t(c(),u),"iso-date-time":t(f(),m),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:_,"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:E,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:y,int32:{type:`number`,validate:S},int64:{type:`number`,validate:C},float:{type:`number`,validate:w},double:{type:`number`,validate:w},password:!0,binary:!0},e.fastFormats={...e.fullFormats,date:t(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,o),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,p),"iso-time":t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,u),"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,m),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 n(e){return e%4==0&&(e%100!=0||e%400==0)}var r=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,i=[0,31,28,31,30,31,30,31,31,30,31,30,31];function a(e){let t=r.exec(e);if(!t)return!1;let a=+t[1],o=+t[2],s=+t[3];return o>=1&&o<=12&&s>=1&&s<=(o===2&&n(a)?29:i[o])}function o(e,t){if(e&&t)return e>t?1:e<t?-1:0}var s=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function c(e){return function(t){let n=s.exec(t);if(!n)return!1;let r=+n[1],i=+n[2],a=+n[3],o=n[4],c=n[5]===`-`?-1:1,l=+(n[6]||0),u=+(n[7]||0);if(l>23||u>59||e&&!o)return!1;if(r<=23&&i<=59&&a<60)return!0;let d=i-u*c,f=r-l*c-+(d<0);return(f===23||f===-1)&&(d===59||d===-1)&&a<61}}function l(e,t){if(!(e&&t))return;let n=new Date(`2020-01-01T`+e).valueOf(),r=new Date(`2020-01-01T`+t).valueOf();if(n&&r)return n-r}function u(e,t){if(!(e&&t))return;let n=s.exec(e),r=s.exec(t);if(n&&r)return e=n[1]+n[2]+n[3],t=r[1]+r[2]+r[3],e>t?1:e<t?-1:0}var d=/t|\s/i;function f(e){let t=c(e);return function(e){let n=e.split(d);return n.length===2&&a(n[0])&&t(n[1])}}function p(e,t){if(!(e&&t))return;let n=new Date(e).valueOf(),r=new Date(t).valueOf();if(n&&r)return n-r}function m(e,t){if(!(e&&t))return;let[n,r]=e.split(d),[i,a]=t.split(d),s=o(n,i);if(s!==void 0)return s||l(r,a)}var h=/\/|:/,g=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function _(e){return h.test(e)&&g.test(e)}var v=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function y(e){return v.lastIndex=0,v.test(e)}var b=-(2**31),x=2**31-1;function S(e){return Number.isInteger(e)&&e<=x&&e>=b}function C(e){return Number.isInteger(e)}function w(){return!0}var T=/[^\\]\\Z/;function E(e){if(T.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}})),QB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatLimitDefinition=void 0;var t=XB(),n=wz(),r=n.operators,i={formatMaximum:{okStr:`<=`,ok:r.LTE,fail:r.GT},formatMinimum:{okStr:`>=`,ok:r.GTE,fail:r.LT},formatExclusiveMaximum:{okStr:`<`,ok:r.LT,fail:r.GTE},formatExclusiveMinimum:{okStr:`>`,ok:r.GT,fail:r.LTE}};e.formatLimitDefinition={keyword:Object.keys(i),type:`string`,schemaType:`string`,$data:!0,error:{message:({keyword:e,schemaCode:t})=>(0,n.str)`should be ${i[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,n._)`{comparison: ${i[e].okStr}, limit: ${t}}`},code(e){let{gen:r,data:a,schemaCode:o,keyword:s,it:c}=e,{opts:l,self:u}=c;if(!l.validateFormats)return;let d=new t.KeywordCxt(c,u.RULES.all.format.definition,`format`);d.$data?f():p();function f(){let t=r.scopeValue(`formats`,{ref:u.formats,code:l.code.formats}),i=r.const(`fmt`,(0,n._)`${t}[${d.schemaCode}]`);e.fail$data((0,n.or)((0,n._)`typeof ${i} != "object"`,(0,n._)`${i} instanceof RegExp`,(0,n._)`typeof ${i}.compare != "function"`,m(i)))}function p(){let t=d.schema,i=u.formats[t];if(!i||i===!0)return;if(typeof i!=`object`||i instanceof RegExp||typeof i.compare!=`function`)throw Error(`"${s}": format "${t}" does not define "compare" function`);let a=r.scopeValue(`formats`,{key:t,ref:i,code:l.code.formats?(0,n._)`${l.code.formats}${(0,n.getProperty)(t)}`:void 0});e.fail$data(m(a))}function m(e){return(0,n._)`${e}.compare(${a}, ${o}) ${i[s].fail} 0`}},dependencies:[`format`]},e.default=t=>(t.addKeyword(e.formatLimitDefinition),t)})),$B=s(((e,t)=>{Object.defineProperty(e,"__esModule",{value:!0});var n=ZB(),r=QB(),i=wz(),a=new i.Name(`fullFormats`),o=new i.Name(`fastFormats`),s=(e,t={keywords:!0})=>{if(Array.isArray(t))return c(e,t,n.fullFormats,a),e;let[i,s]=t.mode===`fast`?[n.fastFormats,o]:[n.fullFormats,a];return c(e,t.formats||n.formatNames,i,s),t.keywords&&(0,r.default)(e),e};s.get=(e,t=`full`)=>{let r=(t===`fast`?n.fastFormats:n.fullFormats)[e];if(!r)throw Error(`Unknown format "${e}"`);return r};function c(e,t,n,r){var a;(a=e.opts.code).formats??(a.formats=(0,i._)`require("ajv-formats/dist/formats").${r}`);for(let r of t)e.addFormat(r,n[r])}t.exports=e=s,Object.defineProperty(e,"__esModule",{value:!0}),e.default=s})),eV=u(XB(),1),tV=u($B(),1);function nV(){let e=new eV.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,tV.default)(e),e}var rV=class{constructor(e){this._ajv=e??nV()}getValidator(e){let t=`$id`in e&&typeof e.$id==`string`?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return e=>t(e)?{valid:!0,data:e,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(t.errors)}}},iV=class{constructor(e){this._client=e}async*callToolStream(e,t=_I,n){let r=this._client,i={...n,task:n?.task??(r.isToolTask(e.name)?{}:void 0)},a=r.requestStream({method:`tools/call`,params:e},t,i),o=r.getToolOutputValidator(e.name);for await(let t of a){if(t.type===`result`&&o){let n=t.result;if(!n.structuredContent&&!n.isError){yield{type:`error`,error:new rL(UP.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`)};return}if(n.structuredContent)try{let e=o(n.structuredContent);if(!e.valid){yield{type:`error`,error:new rL(UP.InvalidParams,`Structured content does not match the tool's output schema: ${e.errorMessage}`)};return}}catch(e){if(e instanceof rL){yield{type:`error`,error:e};return}yield{type:`error`,error:new rL(UP.InvalidParams,`Failed to validate structured content: ${e instanceof Error?e.message:String(e)}`)};return}}yield t}}async getTask(e,t){return this._client.getTask({taskId:e},t)}async getTaskResult(e,t,n){return this._client.getTaskResult({taskId:e},t,n)}async listTasks(e,t){return this._client.listTasks(e?{cursor:e}:void 0,t)}async cancelTask(e,t){return this._client.cancelTask({taskId:e},t)}requestStream(e,t,n){return this._client.requestStream(e,t,n)}};function aV(e,t,n){if(!e)throw Error(`${n} does not support task creation (required for ${t})`);if(t===`tools/call`&&!e.tools?.call)throw Error(`${n} does not support task creation for tools/call (required for ${t})`)}function oV(e,t,n){if(!e)throw Error(`${n} does not support task creation (required for ${t})`);switch(t){case`sampling/createMessage`:if(!e.sampling?.createMessage)throw Error(`${n} does not support task creation for sampling/createMessage (required for ${t})`);break;case`elicitation/create`:if(!e.elicitation?.create)throw Error(`${n} does not support task creation for elicitation/create (required for ${t})`)}}function sV(e,t){if(e&&typeof t==`object`&&t){if(e.type===`object`&&e.properties&&typeof e.properties==`object`){let n=t,r=e.properties;for(let e of Object.keys(r)){let t=r[e];n[e]===void 0&&Object.prototype.hasOwnProperty.call(t,`default`)&&(n[e]=t.default),n[e]!==void 0&&sV(t,n[e])}}if(Array.isArray(e.anyOf))for(let n of e.anyOf)typeof n!=`boolean`&&sV(n,t);if(Array.isArray(e.oneOf))for(let n of e.oneOf)typeof n!=`boolean`&&sV(n,t)}}function cV(e){if(!e)return{supportsFormMode:!1,supportsUrlMode:!1};let t=e.form!==void 0,n=e.url!==void 0;return{supportsFormMode:t||!t&&!n,supportsUrlMode:n}}var lV=class extends yz{constructor(e,t){super(t),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._cachedKnownTaskTools=new Set,this._cachedRequiredTaskTools=new Set,this._listChangedDebounceTimers=new Map,this._capabilities=t?.capabilities??{},this._jsonSchemaValidator=t?.jsonSchemaValidator??new rV,t?.listChanged&&(this._pendingListChangedConfig=t.listChanged)}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler(`tools`,bI,e.tools,async()=>(await this.listTools()).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler(`prompts`,dI,e.prompts,async()=>(await this.listPrompts()).prompts),e.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler(`resources`,WF,e.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||={tasks:new iV(this)},this._experimental}registerCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after connecting to transport`);this._capabilities=xz(this._capabilities,e)}setRequestHandler(e,t){let n=mz(e)?.method;if(!n)throw Error(`Schema is missing a method literal`);let r;if(fz(n)){let e=n;r=e._zod?.def?.value??e.value}else{let e=n;r=e._def?.value??e.value}if(typeof r!=`string`)throw Error(`Schema method literal must be a string`);let i=r;return i===`elicitation/create`?super.setRequestHandler(e,async(e,n)=>{let r=pz(WI,e);if(!r.success){let e=r.error instanceof Error?r.error.message:String(r.error);throw new rL(UP.InvalidParams,`Invalid elicitation request: ${e}`)}let{params:i}=r.data;i.mode=i.mode??`form`;let{supportsFormMode:a,supportsUrlMode:o}=cV(this._capabilities.elicitation);if(i.mode===`form`&&!a)throw new rL(UP.InvalidParams,`Client does not support form-mode elicitation requests`);if(i.mode===`url`&&!o)throw new rL(UP.InvalidParams,`Client does not support URL-mode elicitation requests`);let s=await Promise.resolve(t(e,n));if(i.task){let e=pz(vF,s);if(!e.success){let t=e.error instanceof Error?e.error.message:String(e.error);throw new rL(UP.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}let c=pz(qI,s);if(!c.success){let e=c.error instanceof Error?c.error.message:String(c.error);throw new rL(UP.InvalidParams,`Invalid elicitation result: ${e}`)}let l=c.data,u=i.mode===`form`?i.requestedSchema:void 0;if(i.mode===`form`&&l.action===`accept`&&l.content&&u&&this._capabilities.elicitation?.form?.applyDefaults)try{sV(u,l.content)}catch{}return l}):i===`sampling/createMessage`?super.setRequestHandler(e,async(e,n)=>{let r=pz(PI,e);if(!r.success){let e=r.error instanceof Error?r.error.message:String(r.error);throw new rL(UP.InvalidParams,`Invalid sampling request: ${e}`)}let{params:i}=r.data,a=await Promise.resolve(t(e,n));if(i.task){let e=pz(vF,a);if(!e.success){let t=e.error instanceof Error?e.error.message:String(e.error);throw new rL(UP.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}let o=pz(i.tools||i.toolChoice?II:FI,a);if(!o.success){let e=o.error instanceof Error?o.error.message:String(o.error);throw new rL(UP.InvalidParams,`Invalid sampling result: ${e}`)}return o.data}):super.setRequestHandler(e,t)}assertCapability(e,t){if(!this._serverCapabilities?.[e])throw Error(`Server does not support ${e} (required for ${t})`)}async connect(e,t){if(await super.connect(e),e.sessionId===void 0)try{let n=await this.request({method:`initialize`,params:{protocolVersion:bP,capabilities:this._capabilities,clientInfo:this._clientInfo}},oF,t);if(n===void 0)throw Error(`Server sent invalid initialize result: ${n}`);if(!xP.includes(n.protocolVersion))throw Error(`Server's protocol version is not supported: ${n.protocolVersion}`);this._serverCapabilities=n.capabilities,this._serverVersion=n.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(n.protocolVersion),this._instructions=n.instructions,await this.notification({method:`notifications/initialized`}),this._pendingListChangedConfig&&=(this._setupListChangedHandlers(this._pendingListChangedConfig),void 0)}catch(e){throw this.close(),e}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){switch(e){case`logging/setLevel`:if(!this._serverCapabilities?.logging)throw Error(`Server does not support logging (required for ${e})`);break;case`prompts/get`:case`prompts/list`:if(!this._serverCapabilities?.prompts)throw Error(`Server does not support prompts (required for ${e})`);break;case`resources/list`:case`resources/templates/list`:case`resources/read`:case`resources/subscribe`:case`resources/unsubscribe`:if(!this._serverCapabilities?.resources)throw Error(`Server does not support resources (required for ${e})`);if(e===`resources/subscribe`&&!this._serverCapabilities.resources.subscribe)throw Error(`Server does not support resource subscriptions (required for ${e})`);break;case`tools/call`:case`tools/list`:if(!this._serverCapabilities?.tools)throw Error(`Server does not support tools (required for ${e})`);break;case`completion/complete`:if(!this._serverCapabilities?.completions)throw Error(`Server does not support completions (required for ${e})`)}}assertNotificationCapability(e){if(e===`notifications/roots/list_changed`&&!this._capabilities.roots?.listChanged)throw Error(`Client does not support roots list changed notifications (required for ${e})`)}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case`sampling/createMessage`:if(!this._capabilities.sampling)throw Error(`Client does not support sampling capability (required for ${e})`);break;case`elicitation/create`:if(!this._capabilities.elicitation)throw Error(`Client does not support elicitation capability (required for ${e})`);break;case`roots/list`:if(!this._capabilities.roots)throw Error(`Client does not support roots capability (required for ${e})`);break;case`tasks/get`:case`tasks/list`:case`tasks/result`:case`tasks/cancel`:if(!this._capabilities.tasks)throw Error(`Client does not support tasks capability (required for ${e})`)}}assertTaskCapability(e){aV(this._serverCapabilities?.tasks?.requests,e,`Server`)}assertTaskHandlerCapability(e){this._capabilities&&oV(this._capabilities.tasks?.requests,e,`Client`)}async ping(e){return this.request({method:`ping`},qP,e)}async complete(e,t){return this.request({method:`completion/complete`,params:e},QI,t)}async setLoggingLevel(e,t){return this.request({method:`logging/setLevel`,params:{level:e}},qP,t)}async getPrompt(e,t){return this.request({method:`prompts/get`,params:e},uI,t)}async listPrompts(e,t){return this.request({method:`prompts/list`,params:e},eI,t)}async listResources(e,t){return this.request({method:`resources/list`,params:e},LF,t)}async listResourceTemplates(e,t){return this.request({method:`resources/templates/list`,params:e},zF,t)}async readResource(e,t){return this.request({method:`resources/read`,params:e},UF,t)}async subscribeResource(e,t){return this.request({method:`resources/subscribe`,params:e},qP,t)}async unsubscribeResource(e,t){return this.request({method:`resources/unsubscribe`,params:e},qP,t)}async callTool(e,t=_I,n){if(this.isToolTaskRequired(e.name))throw new rL(UP.InvalidRequest,`Tool "${e.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);let r=await this.request({method:`tools/call`,params:e},t,n),i=this.getToolOutputValidator(e.name);if(i){if(!r.structuredContent&&!r.isError)throw new rL(UP.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(r.structuredContent)try{let e=i(r.structuredContent);if(!e.valid)throw new rL(UP.InvalidParams,`Structured content does not match the tool's output schema: ${e.errorMessage}`)}catch(e){throw e instanceof rL?e:new rL(UP.InvalidParams,`Failed to validate structured content: ${e instanceof Error?e.message:String(e)}`)}}return r}isToolTask(e){return this._serverCapabilities?.tasks?.requests?.tools?.call?this._cachedKnownTaskTools.has(e):!1}isToolTaskRequired(e){return this._cachedRequiredTaskTools.has(e)}cacheToolMetadata(e){this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(let t of e){if(t.outputSchema){let e=this._jsonSchemaValidator.getValidator(t.outputSchema);this._cachedToolOutputValidators.set(t.name,e)}let e=t.execution?.taskSupport;(e===`required`||e===`optional`)&&this._cachedKnownTaskTools.add(t.name),e===`required`&&this._cachedRequiredTaskTools.add(t.name)}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,t){let n=await this.request({method:`tools/list`,params:e},gI,t);return this.cacheToolMetadata(n.tools),n}_setupListChangedHandler(e,t,n,r){let i=xI.safeParse(n);if(!i.success)throw Error(`Invalid ${e} listChanged options: ${i.error.message}`);if(typeof n.onChanged!=`function`)throw Error(`Invalid ${e} listChanged options: onChanged must be a function`);let{autoRefresh:a,debounceMs:o}=i.data,{onChanged:s}=n,c=async()=>{if(!a){s(null,null);return}try{let e=await r();s(null,e)}catch(e){let t=e instanceof Error?e:Error(String(e));s(t,null)}};this.setNotificationHandler(t,()=>{if(o){let t=this._listChangedDebounceTimers.get(e);t&&clearTimeout(t);let n=setTimeout(c,o);this._listChangedDebounceTimers.set(e,n)}else c()})}async sendRootsListChanged(){return this.notification({method:`notifications/roots/list_changed`})}};function uV(e,t){if(!e)throw Error(t)}var dV=3e3,fV=5e3,pV=3e5;function mV(e){let{url:t,clientName:n,clientUri:r,callbackUrl:i=typeof window<`u`?OO(new URL(`/oauth/callback`,window.location.origin).toString()):`/oauth/callback`,storageKeyPrefix:a=`mcp:auth`,clientConfig:o={},customHeaders:s={},debug:c=!1,autoRetry:l=!1,autoReconnect:u=dV,transportType:d=`auto`,preventAutoAuth:f=!1,onPopupWindow:p}=e,[m,h]=(0,b.useState)(`discovering`),[g,_]=(0,b.useState)([]),[v,y]=(0,b.useState)([]),[x,S]=(0,b.useState)([]),[C,w]=(0,b.useState)([]),[T,E]=(0,b.useState)(void 0),[D,O]=(0,b.useState)([]),[k,A]=(0,b.useState)(void 0),j=(0,b.useRef)(null),M=(0,b.useRef)(null),N=(0,b.useRef)(null),P=(0,b.useRef)(!1),F=(0,b.useRef)(!0),I=(0,b.useRef)(0),L=(0,b.useRef)(null),ee=(0,b.useRef)(m),te=(0,b.useRef)(u),ne=(0,b.useRef)(null);(0,b.useEffect)(()=>{ee.current=m,te.current=u},[m,u]);let R=(0,b.useCallback)((e,t,...n)=>{let r=n.length>0?`${t} ${n.map(e=>JSON.stringify(e)).join(` `)}`:t;console[e](`[useMcp] ${r}`),F.current&&O(t=>[...t.slice(-100),{level:e,message:r,timestamp:Date.now()}])},[]),z=(0,b.useCallback)(async(e=!1)=>{e||R(`info`,`Disconnecting...`),P.current=!1,L.current&&clearTimeout(L.current),L.current=null;let t=M.current;if(j.current=null,M.current=null,F.current&&!e&&(h(`discovering`),_([]),y([]),S([]),w([]),E(void 0),A(void 0)),t)try{await t.close(),e||R(`debug`,`Transport closed`)}catch(t){e||R(`warn`,`Error closing transport:`,t)}},[R]),B=(0,b.useCallback)((e,t)=>{if(R(`error`,e,t??``),F.current){h(`failed`),E(e);let t=N.current?.getLastAttemptedAuthUrl();t&&(A(t),R(`info`,`Manual authentication URL may be available.`,t))}P.current=!1},[R]),re=(0,b.useCallback)(async()=>{if(P.current){R(`debug`,`Connection attempt already in progress.`);return}if(!F.current){R(`debug`,`Connect called after unmount, aborting.`);return}P.current=!0,I.current+=1,E(void 0),A(void 0),ne.current=null,h(`discovering`),R(`info`,`Connecting attempt #${I.current} to ${t}...`),N.current||(N.current=new AO(t,{storageKeyPrefix:a,clientName:n,clientUri:r,callbackUrl:i,preventAutoAuth:f,onPopupWindow:p}),R(`debug`,`BrowserOAuthClientProvider initialized in connect.`)),j.current||(j.current=new lV({name:o.name||`use-mcp-react-client`,version:o.version||`0.1.0`},{capabilities:{}}),R(`debug`,`MCP Client initialized in connect.`));let e=async e=>{R(`info`,`Attempting connection with ${e.toUpperCase()} transport...`),ee.current!==`authenticating`&&h(`connecting`);let n;try{uV(N.current,`Auth Provider must be initialized`),uV(j.current,`Client must be initialized`),M.current&&=(await M.current.close().catch(e=>R(`warn`,`Error closing previous transport: ${e.message}`)),null);let r={authProvider:N.current,requestInit:{headers:{Accept:`application/json, text/event-stream`,...s}}},i=OO(t),a=new URL(i);R(`debug`,`Creating ${e.toUpperCase()} transport for URL: ${a.toString()}`),R(`debug`,`Transport options:`,{authProvider:!!N.current,headers:s,url:a.toString()}),e===`http`?(R(`debug`,`Creating StreamableHTTPClientTransport...`),n=new dz(a,r),R(`debug`,`StreamableHTTPClientTransport created successfully`)):(R(`debug`,`Creating SSEClientTransport...`),n=new sz(a,r),R(`debug`,`SSEClientTransport created successfully`)),M.current=n,R(`debug`,`${e.toUpperCase()} transport created and assigned to ref.`)}catch(t){return B(`Failed to create ${e.toUpperCase()} transport: ${t instanceof Error?t.message:String(t)}`,t instanceof Error?t:void 0),`failed`}n.onmessage=e=>{R(`debug`,`[Transport] Received: ${JSON.stringify(e)}`),j.current?.handleMessage?.(e)},n.onerror=t=>{R(`warn`,`Transport error event (${e.toUpperCase()}):`,t),R(`debug`,`Error details:`,{message:t.message,stack:t.stack,name:t.name,cause:t.cause}),B(`Transport error (${e.toUpperCase()}): ${t.message}`,t)},n.onclose=()=>{if(!F.current||P.current)return;R(`info`,`Transport connection closed (${ne.current||`unknown`} type).`);let e=ee.current,t=te.current;if(e===`ready`&&t){let e=typeof t==`number`?t:dV;R(`info`,`Attempting to reconnect in ${e}ms...`),h(`connecting`),setTimeout(()=>{F.current&&re()},e)}else e!==`failed`&&e!==`authenticating`&&B(`Connection closed unexpectedly.`)};try{R(`info`,`Connecting client via ${e.toUpperCase()}...`),R(`debug`,`About to call client.connect() with transport instance`),R(`debug`,`Transport instance type: ${n.constructor.name}`),await j.current.connect(n),R(`info`,`Client connected via ${e.toUpperCase()}. Loading tools, resources, and prompts...`),ne.current=e,h(`loading`);let t=await j.current.request({method:`tools/list`},gI),r={resources:[],resourceTemplates:[]};try{r=await j.current.request({method:`resources/list`},LF)}catch(e){R(`debug`,`Server does not support resources/list method`,e)}let i={prompts:[]};try{i=await j.current.request({method:`prompts/list`},eI)}catch(e){R(`debug`,`Server does not support prompts/list method`,e)}if(F.current){_(t.tools),y(r.resources),S(Array.isArray(r.resourceTemplates)?r.resourceTemplates:[]),w(i.prompts);let e=[`Loaded ${t.tools.length} tools`];return(r.resources.length>0||r.resourceTemplates&&r.resourceTemplates.length>0)&&(e.push(`${r.resources.length} resources`),Array.isArray(r.resourceTemplates)&&r.resourceTemplates.length>0&&e.push(`${r.resourceTemplates.length} resource templates`)),i.prompts.length>0&&e.push(`${i.prompts.length} prompts`),R(`info`,e.join(`, `)+`.`),h(`ready`),I.current=0,`success`}return`failed`}catch(n){R(`debug`,`Client connect error via ${e.toUpperCase()}:`,n),R(`debug`,`Connect error details:`,{message:n instanceof Error?n.message:String(n),stack:n instanceof Error?n.stack:`N/A`,name:n instanceof Error?n.name:`Unknown`,cause:n instanceof Error?n.cause:void 0});let r=n instanceof Error?n:Error(String(n)),i=r.message,a=i.includes(`404`)||i.includes(`Not Found`),o=i.includes(`405`)||i.includes(`Method Not Allowed`),s=i===`Failed to fetch`||i===`NetworkError when attempting to fetch resource.`||i===`Load failed`;if(e===`http`&&(a||o||s))return R(`warn`,`HTTP transport failed (${s?`CORS`:a?`404`:`405`}).`),`fallback`;if(r instanceof kR||i.includes(`Unauthorized`)||i.includes(`401`)){R(`info`,`Authentication required.`),uV(N.current,`Auth Provider not available for auth flow`);let e=await N.current.tokens();if(f&&!e)return R(`info`,`Authentication required but auto-auth prevented. User action needed.`),h(`pending_auth`),`auth_redirect`;ee.current!==`authenticating`&&ee.current!==`pending_auth`&&(h(`authenticating`),L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{},pV));try{let e=await zR(N.current,{serverUrl:t});if(!F.current)return`failed`;if(e===`AUTHORIZED`)return R(`info`,`Authentication successful via existing token or refresh. Re-attempting connection...`),L.current&&clearTimeout(L.current),P.current=!1,re(),`failed`;if(e===`REDIRECT`)return R(`info`,`Redirecting for authentication. Waiting for callback...`),`auth_redirect`}catch(e){return F.current?(L.current&&clearTimeout(L.current),B(`Failed to initiate authentication: ${e instanceof Error?e.message:String(e)}`,e instanceof Error?e:void 0),`failed`):`failed`}}return B(`Failed to connect via ${e.toUpperCase()}: ${i}`,r),`failed`}},c=`failed`;if(console.log({transportType:d}),d===`sse`)R(`debug`,`Using SSE-only transport mode`),c=await e(`sse`);else if(d===`http`)R(`debug`,`Using HTTP-only transport mode`),c=await e(`http`);else{R(`debug`,`Using auto transport mode (HTTP with SSE fallback)`);let t=await e(`http`);if(t===`fallback`&&F.current&&ee.current!==`authenticating`){R(`info`,`HTTP failed, attempting SSE fallback...`);let t=await e(`sse`);c=t,t===`failed`&&F.current}else c=t}(c===`success`||c===`failed`)&&(P.current=!1),R(`debug`,`Connection sequence finished with status: ${c}`)},[R,B,z,zR,t,a,n,r,i,o.name,o.version]),ie=(0,b.useCallback)(async(e,n)=>{if(ee.current!==`ready`||!j.current)throw Error(`MCP client is not ready (current state: ${m}). Cannot call tool "${e}".`);R(`info`,`Calling tool: ${e}`,n);try{let t=await j.current.request({method:`tools/call`,params:{name:e,arguments:n}},_I);return R(`info`,`Tool "${e}" call successful:`,t),t}catch(n){R(`error`,`Error calling tool "${e}": ${n instanceof Error?n.message:String(n)}`,n);let r=n instanceof Error?n:Error(String(n));if(r instanceof kR||r.message.includes(`Unauthorized`)||r.message.includes(`401`)){R(`warn`,`Tool call unauthorized, attempting re-authentication...`),h(`authenticating`),L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{},pV);try{uV(N.current,`Auth Provider not available for tool re-auth`);let e=await zR(N.current,{serverUrl:t});if(!F.current)return;e===`AUTHORIZED`?(R(`info`,`Re-authentication successful. Retrying tool call is recommended, or reconnecting.`),L.current&&clearTimeout(L.current),P.current=!1,re()):e===`REDIRECT`&&R(`info`,`Redirecting for re-authentication for tool call.`)}catch(e){if(!F.current)return;L.current&&clearTimeout(L.current),B(`Re-authentication failed: ${e instanceof Error?e.message:String(e)}`,e instanceof Error?e:void 0)}}if(ee.current!==`authenticating`)throw n;return}},[m,t,R,B,re]),ae=(0,b.useCallback)(()=>{ee.current===`failed`?(R(`info`,`Retry requested...`),re()):R(`warn`,`Retry called but state is not 'failed' (state: ${ee.current}). Ignoring.`)},[R,re]),oe=(0,b.useCallback)(async()=>{R(`info`,`Manual authentication requested...`);let e=ee.current;if(e===`failed`)R(`info`,`Attempting to reconnect and authenticate via retry...`),ae();else if(e===`pending_auth`){R(`info`,`Proceeding with authentication from pending state...`),h(`authenticating`),L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{},pV);try{uV(N.current,`Auth Provider not available for manual auth`);let e=await zR(N.current,{serverUrl:t});if(!F.current)return;e===`AUTHORIZED`?(R(`info`,`Manual authentication successful. Re-attempting connection...`),L.current&&clearTimeout(L.current),P.current=!1,re()):e===`REDIRECT`&&R(`info`,`Redirecting for manual authentication. Waiting for callback...`)}catch(e){if(!F.current)return;L.current&&clearTimeout(L.current),B(`Manual authentication failed: ${e instanceof Error?e.message:String(e)}`,e instanceof Error?e:void 0)}}else if(e===`authenticating`){R(`warn`,`Already attempting authentication. Check for blocked popups or wait for timeout.`);let e=N.current?.getLastAttemptedAuthUrl();e&&!k&&(A(e),R(`info`,`Manual authentication URL retrieved:`,e))}else R(`info`,`Client not in a state requiring manual authentication trigger (state: ${e}). If needed, try disconnecting and reconnecting.`)},[R,ae,k,t,B,re]),se=(0,b.useCallback)(()=>{if(N.current){let e=N.current.clearStorage();R(`info`,`Cleared ${e} item(s) from localStorage for ${t}.`),A(void 0),z()}else R(`warn`,`Auth provider not initialized, cannot clear storage.`)},[t,R,z]),ce=(0,b.useCallback)(async()=>{if(ee.current!==`ready`||!j.current)throw Error(`MCP client is not ready (current state: ${m}). Cannot list resources.`);R(`info`,`Listing resources...`);try{let e=await j.current.request({method:`resources/list`},LF);F.current&&(y(e.resources),S(Array.isArray(e.resourceTemplates)?e.resourceTemplates:[]),R(`info`,`Listed ${e.resources.length} resources, ${Array.isArray(e.resourceTemplates)?e.resourceTemplates.length:0} resource templates.`))}catch(e){throw R(`error`,`Error listing resources: ${e instanceof Error?e.message:String(e)}`,e),e}},[m,R]),le=(0,b.useCallback)(async e=>{if(ee.current!==`ready`||!j.current)throw Error(`MCP client is not ready (current state: ${m}). Cannot read resource "${e}".`);R(`info`,`Reading resource: ${e}`);try{let t=await j.current.request({method:`resources/read`,params:{uri:e}},UF);return R(`info`,`Resource "${e}" read successfully`),t}catch(t){throw R(`error`,`Error reading resource "${e}": ${t instanceof Error?t.message:String(t)}`,t),t}},[m,R]),ue=(0,b.useCallback)(async()=>{if(ee.current!==`ready`||!j.current)throw Error(`MCP client is not ready (current state: ${m}). Cannot list prompts.`);R(`info`,`Listing prompts...`);try{let e=await j.current.request({method:`prompts/list`},eI);F.current&&(w(e.prompts),R(`info`,`Listed ${e.prompts.length} prompts.`))}catch(e){throw R(`error`,`Error listing prompts: ${e instanceof Error?e.message:String(e)}`,e),e}},[m,R]),de=(0,b.useCallback)(async(e,t)=>{if(ee.current!==`ready`||!j.current)throw Error(`MCP client is not ready (current state: ${m}). Cannot get prompt "${e}".`);R(`info`,`Getting prompt: ${e}`,t);try{let n=await j.current.request({method:`prompts/get`,params:{name:e,arguments:t}},uI);return R(`info`,`Prompt "${e}" retrieved successfully`),n}catch(t){throw R(`error`,`Error getting prompt "${e}": ${t instanceof Error?t.message:String(t)}`,t),t}},[m,R]);return(0,b.useEffect)(()=>{let e=e=>{e.origin===window.location.origin&&e.data?.type===`mcp_auth_callback`&&(R(`info`,`Received auth callback message.`,e.data),L.current&&clearTimeout(L.current),e.data.success?(R(`info`,`Authentication successful via popup. Reconnecting client...`),P.current=!1,re()):B(`Authentication failed in callback: ${e.data.error||`Unknown reason.`}`))};return window.addEventListener(`message`,e),R(`debug`,`Auth callback message listener added.`),()=>{window.removeEventListener(`message`,e),R(`debug`,`Auth callback message listener removed.`),L.current&&clearTimeout(L.current)}},[R,B,re]),(0,b.useEffect)(()=>(F.current=!0,R(`debug`,`useMcp mounted, initiating connection.`),I.current=0,(!N.current||N.current.serverUrl!==t)&&(N.current=new AO(t,{storageKeyPrefix:a,clientName:n,clientUri:r,callbackUrl:i,preventAutoAuth:f,onPopupWindow:p}),R(`debug`,`BrowserOAuthClientProvider initialized/updated on mount/option change.`)),re(),()=>{F.current=!1,R(`debug`,`useMcp unmounting, disconnecting.`),z(!0)}),[t,a,i,n,r,o.name,o.version,re,z]),(0,b.useEffect)(()=>{let e=null;if(m===`failed`&&l&&I.current>0){let t=typeof l==`number`?l:fV;R(`info`,`Connection failed, auto-retrying in ${t}ms...`),e=setTimeout(()=>{F.current&&ee.current===`failed`&&ae()},t)}return()=>{e&&clearTimeout(e)}},[m,l,ae,R]),{state:m,tools:g,resources:v,resourceTemplates:x,prompts:C,error:T,log:D,authUrl:k,callTool:ie,listResources:ce,readResource:le,listPrompts:ue,getPrompt:de,retry:ae,disconnect:z,authenticate:oe,clearStorage:se}}function hV({service:e,autoConnect:t=!1,onConnected:n,onError:r}){let{toast:i}=on(),{state:a,tools:o,resources:s,prompts:c,error:l,authUrl:u,callTool:d,readResource:f,listResources:p,getPrompt:m,listPrompts:h,retry:g,disconnect:_,authenticate:v,clearStorage:y}=mV({url:e.url,clientName:`AgentDeck`,clientUri:window.location.origin,callbackUrl:`${window.location.origin}/oauth/callback`,storageKeyPrefix:`mcp:auth:${e.id}`,debug:!0,autoRetry:3,autoReconnect:5e3,transportType:`auto`,preventAutoAuth:!t}),x=a===`ready`,S=a===`connecting`||a===`loading`,C=a===`authenticating`||a===`pending_auth`,w=a===`failed`;return b.useEffect(()=>{x&&n&&(n(),i({title:`Connected to MCP service`,description:`Successfully connected to ${e.name}`}))},[x,n,e.name,i]),b.useEffect(()=>{w&&l&&r&&(r(l),i({title:`MCP connection failed`,description:l,variant:`destructive`}))},[w,l,r,i]),{isConnected:x,isConnecting:S,isAuthenticating:C,hasError:w,error:l,tools:o,resources:s,prompts:c,connect:()=>{g()},disconnect:_,retry:g,authenticate:v,callTool:async(e,t)=>{try{return await d(e,t)}catch(e){let t=e instanceof Error?e.message:`Unknown error`;throw i({title:`Tool call failed`,description:t,variant:`destructive`}),e}},readResource:async e=>{try{return await f(e)}catch(e){let t=e instanceof Error?e.message:`Unknown error`;throw i({title:`Resource read failed`,description:t,variant:`destructive`}),e}},listResources:async()=>{try{await p()}catch(e){let t=e instanceof Error?e.message:`Unknown error`;throw i({title:`Resource listing failed`,description:t,variant:`destructive`}),e}},getPrompt:async(e,t)=>{try{return await m(e,t)}catch(e){let t=e instanceof Error?e.message:`Unknown error`;throw i({title:`Prompt retrieval failed`,description:t,variant:`destructive`}),e}},listPrompts:async()=>{try{await h()}catch(e){let t=e instanceof Error?e.message:`Unknown error`;throw i({title:`Prompt listing failed`,description:t,variant:`destructive`}),e}},authUrl:u,clearStorage:y}}function gV(){let[e,t]=(0,b.useState)(`https://api.githubcopilot.com/mcp`),[n,r]=(0,b.useState)(`get_me`),[i,a]=(0,b.useState)(`{}`),[o,s]=(0,b.useState)(``),{isConnected:c,isConnecting:l,isAuthenticating:u,hasError:d,error:f,tools:p,resources:m,prompts:h,connect:g,disconnect:_,retry:v,authenticate:y,callTool:x,authUrl:S,clearStorage:C}=hV({service:{id:`test-mcp-service`,name:`Test MCP Service`,type:`mcp`,url:e,health:`unknown`,description:`Test service for use-mcp integration`,cardColor:`#7ed4da`,isConnected:!1,lastPing:void 0,registeredAt:new Date().toISOString(),updatedAt:new Date().toISOString()},autoConnect:!1,onConnected:()=>{console.log(`Connected to test MCP service`)},onError:e=>{console.error(`Test MCP service error:`,e)}}),w=l?{status:`connecting`,icon:Pi,color:`text-yellow-500`}:u?{status:`authenticating`,icon:ji,color:`text-blue-500`}:c?{status:`connected`,icon:xi,color:`text-green-500`}:d?{status:`error`,icon:Si,color:`text-red-500`}:{status:`disconnected`,icon:Si,color:`text-gray-500`};return(0,V.jsxs)(`div`,{className:`container mx-auto p-6 space-y-6`,children:[(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(`h1`,{className:`text-3xl font-bold mb-2`,children:`use-mcp Integration Test`}),(0,V.jsx)(`p`,{className:`text-muted-foreground`,children:`Testing the new use-mcp library integration with OAuth support`})]}),(0,V.jsxs)(bO,{children:[(0,V.jsxs)(xO,{children:[(0,V.jsxs)(SO,{className:`flex items-center gap-2`,children:[(0,V.jsx)(w.icon,{className:`w-5 h-5 ${w.color}`}),`Connection Status: `,w.status]}),(0,V.jsx)(CO,{children:`Current connection state and available actions`})]}),(0,V.jsxs)(wO,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsxs)(`div`,{className:`space-y-1`,children:[(0,V.jsx)(zp,{children:`Service URL`}),(0,V.jsx)(uu,{value:e,onChange:e=>t(e.target.value),placeholder:`Enter MCP service URL`})]}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[!c&&!l&&(0,V.jsx)(G,{onClick:g,children:`Connect`}),c&&(0,V.jsx)(G,{onClick:_,variant:`outline`,children:`Disconnect`}),d&&(0,V.jsxs)(G,{onClick:v,variant:`outline`,children:[(0,V.jsx)(Pi,{className:`w-4 h-4 mr-1`}),`Retry`]}),S&&!c&&(0,V.jsxs)(G,{onClick:y,variant:`outline`,children:[(0,V.jsx)(ji,{className:`w-4 h-4 mr-1`}),`Authenticate`]})]})]}),f&&(0,V.jsxs)(`div`,{className:`flex items-center gap-2 p-3 bg-destructive/10 border border-destructive/20 rounded-md`,children:[(0,V.jsx)(bi,{className:`w-4 h-4 text-destructive`}),(0,V.jsx)(`span`,{className:`text-sm text-destructive`,children:f})]})]})]}),(0,V.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[(0,V.jsxs)(bO,{children:[(0,V.jsx)(xO,{children:(0,V.jsxs)(SO,{className:`flex items-center gap-2`,children:[(0,V.jsx)(Ki,{className:`w-4 h-4`}),`Tools (`,p.length,`)`]})}),(0,V.jsx)(wO,{children:p.length===0?(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:c?`No tools available`:`Connect to see tools`}):(0,V.jsxs)(`div`,{className:`space-y-2`,children:[p.slice(0,5).map((e,t)=>(0,V.jsx)(`div`,{className:`text-sm`,children:(0,V.jsx)(fh,{variant:`outline`,className:`text-xs`,children:e.name})},t)),p.length>5&&(0,V.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`+`,p.length-5,` more tools`]})]})})]}),(0,V.jsxs)(bO,{children:[(0,V.jsx)(xO,{children:(0,V.jsxs)(SO,{children:[`Resources (`,m.length,`)`]})}),(0,V.jsx)(wO,{children:(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:c?`${m.length} resources available`:`Connect to see resources`})})]}),(0,V.jsxs)(bO,{children:[(0,V.jsx)(xO,{children:(0,V.jsxs)(SO,{children:[`Prompts (`,h.length,`)`]})}),(0,V.jsx)(wO,{children:(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:c?`${h.length} prompts available`:`Connect to see prompts`})})]})]}),c&&(0,V.jsxs)(bO,{children:[(0,V.jsxs)(xO,{children:[(0,V.jsx)(SO,{children:`Test Tool Call`}),(0,V.jsx)(CO,{children:`Test calling a tool on the connected MCP service`})]}),(0,V.jsxs)(wO,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(zp,{htmlFor:`toolName`,children:`Tool Name`}),(0,V.jsx)(uu,{id:`toolName`,value:n,onChange:e=>r(e.target.value),placeholder:`e.g., get_me`})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(zp,{htmlFor:`toolArgs`,children:`Arguments (JSON)`}),(0,V.jsx)(uu,{id:`toolArgs`,value:i,onChange:e=>a(e.target.value),placeholder:`{"key": "value"}`})]})]}),(0,V.jsxs)(G,{onClick:async()=>{try{let e={};i.trim()&&(e=JSON.parse(i));let t=await x(n,e);s(JSON.stringify(t,null,2))}catch(e){s(`Error: ${e instanceof Error?e.message:`Unknown error`}`)}},disabled:!c,children:[(0,V.jsx)(Fi,{className:`w-4 h-4 mr-1`}),`Call Tool`]}),o&&(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(zp,{children:`Result`}),(0,V.jsx)(Pp,{value:o,readOnly:!0,rows:10,className:`font-mono text-sm`})]})]})]}),S&&(0,V.jsxs)(bO,{children:[(0,V.jsxs)(xO,{children:[(0,V.jsxs)(SO,{className:`flex items-center gap-2`,children:[(0,V.jsx)(ji,{className:`w-4 h-4`}),`OAuth Authentication`]}),(0,V.jsx)(CO,{children:`This service requires OAuth authentication`})]}),(0,V.jsxs)(wO,{className:`space-y-4`,children:[(0,V.jsx)(`div`,{className:`p-3 bg-blue-50 border border-blue-200 rounded-md`,children:(0,V.jsx)(`p`,{className:`text-sm text-blue-800`,children:`This MCP service requires OAuth authentication. Click the "Authenticate" button above to start the OAuth flow.`})}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsxs)(G,{onClick:y,variant:`outline`,children:[(0,V.jsx)(ji,{className:`w-4 h-4 mr-1`}),`Start OAuth Flow`]}),(0,V.jsx)(G,{onClick:C,variant:`outline`,children:`Clear OAuth Data`})]})]})]})]})}function _V(e){return e.before.title!==e.after.title||e.before.body!==e.after.body||e.before.triggers.join(`
|
|
225
|
+
deps: ${r}}`};var i={keyword:`dependencies`,type:`object`,schemaType:`object`,error:e.error,code(e){let[t,n]=a(e);o(e,t),s(e,n)}};function a({schema:e}){let t={},n={};for(let r in e){if(r===`__proto__`)continue;let i=Array.isArray(e[r])?t:n;i[r]=e[r]}return[t,n]}function o(e,n=e.schema){let{gen:i,data:a,it:o}=e;if(Object.keys(n).length===0)return;let s=i.let(`missing`);for(let c in n){let l=n[c];if(l.length===0)continue;let u=(0,r.propertyInData)(i,a,c,o.opts.ownProperties);e.setParams({property:c,depsCount:l.length,deps:l.join(`, `)}),o.allErrors?i.if(u,()=>{for(let t of l)(0,r.checkReportMissingProp)(e,t)}):(i.if((0,t._)`${u} && (${(0,r.checkMissingProp)(e,l,s)})`),(0,r.reportMissingProp)(e,s),i.else())}}e.validatePropertyDeps=o;function s(e,t=e.schema){let{gen:i,data:a,keyword:o,it:s}=e,c=i.name(`valid`);for(let l in t)(0,n.alwaysValidSchema)(s,t[l])||(i.if((0,r.propertyInData)(i,a,l,s.opts.ownProperties),()=>{let t=e.subschema({keyword:o,schemaProp:l},c);e.mergeValidEvaluated(t,c)},()=>i.var(c,!0)),e.ok(c))}e.validateSchemaDeps=s,e.default=i})),AB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Az(),n=jz();e.default={keyword:`propertyNames`,type:`object`,schemaType:[`object`,`boolean`],error:{message:`property name must be valid`,params:({params:e})=>(0,t._)`{propertyName: ${e.propertyName}}`},code(e){let{gen:r,schema:i,data:a,it:o}=e;if((0,n.alwaysValidSchema)(o,i))return;let s=r.name(`valid`);r.forIn(`key`,a,n=>{e.setParams({propertyName:n}),e.subschema({keyword:`propertyNames`,data:n,dataTypes:[`string`],propertyName:n,compositeRule:!0},s),r.if((0,t.not)(s),()=>{e.error(!0),o.allErrors||r.break()})}),e.ok(s)}}})),jB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=zz(),n=Az(),r=Mz(),i=jz();e.default={keyword:`additionalProperties`,type:[`object`],schemaType:[`boolean`,`object`],allowUndefined:!0,trackErrors:!0,error:{message:`must NOT have additional properties`,params:({params:e})=>(0,n._)`{additionalProperty: ${e.additionalProperty}}`},code(e){let{gen:a,schema:o,parentSchema:s,data:c,errsCount:l,it:u}=e;if(!l)throw Error(`ajv implementation error`);let{allErrors:d,opts:f}=u;if(u.props=!0,f.removeAdditional!==`all`&&(0,i.alwaysValidSchema)(u,o))return;let p=(0,t.allSchemaProperties)(s.properties),m=(0,t.allSchemaProperties)(s.patternProperties);h(),e.ok((0,n._)`${l} === ${r.default.errors}`);function h(){a.forIn(`key`,c,e=>{!p.length&&!m.length?v(e):a.if(g(e),()=>v(e))})}function g(r){let o;if(p.length>8){let e=(0,i.schemaRefOrVal)(u,s.properties,`properties`);o=(0,t.isOwnProperty)(a,e,r)}else o=p.length?(0,n.or)(...p.map(e=>(0,n._)`${r} === ${e}`)):n.nil;return m.length&&(o=(0,n.or)(o,...m.map(i=>(0,n._)`${(0,t.usePattern)(e,i)}.test(${r})`))),(0,n.not)(o)}function _(e){a.code((0,n._)`delete ${c}[${e}]`)}function v(t){if(f.removeAdditional===`all`||f.removeAdditional&&o===!1){_(t);return}if(o===!1){e.setParams({additionalProperty:t}),e.error(),d||a.break();return}if(typeof o==`object`&&!(0,i.alwaysValidSchema)(u,o)){let r=a.name(`valid`);f.removeAdditional===`failing`?(y(t,r,!1),a.if((0,n.not)(r),()=>{e.reset(),_(t)})):(y(t,r),d||a.if((0,n.not)(r),()=>a.break()))}}function y(t,n,r){let a={keyword:`additionalProperties`,dataProp:t,dataPropType:i.Type.Str};r===!1&&Object.assign(a,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(a,n)}}}})),MB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Gz(),n=zz(),r=jz(),i=jB();e.default={keyword:`properties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,parentSchema:s,data:c,it:l}=e;l.opts.removeAdditional===`all`&&s.additionalProperties===void 0&&i.default.code(new t.KeywordCxt(l,i.default,`additionalProperties`));let u=(0,n.allSchemaProperties)(o);for(let e of u)l.definedProperties.add(e);l.opts.unevaluated&&u.length&&l.props!==!0&&(l.props=r.mergeEvaluated.props(a,(0,r.toHash)(u),l.props));let d=u.filter(e=>!(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0)return;let f=a.name(`valid`);for(let t of d)p(t)?m(t):(a.if((0,n.propertyInData)(a,c,t,l.opts.ownProperties)),m(t),l.allErrors||a.else().var(f,!0),a.endIf()),e.it.definedProperties.add(t),e.ok(f);function p(e){return l.opts.useDefaults&&!l.compositeRule&&o[e].default!==void 0}function m(t){e.subschema({keyword:`properties`,schemaProp:t,dataProp:t},f)}}}})),NB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=zz(),n=Az(),r=jz(),i=jz();e.default={keyword:`patternProperties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,data:s,parentSchema:c,it:l}=e,{opts:u}=l,d=(0,t.allSchemaProperties)(o),f=d.filter(e=>(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0||f.length===d.length&&(!l.opts.unevaluated||l.props===!0))return;let p=u.strictSchema&&!u.allowMatchingProperties&&c.properties,m=a.name(`valid`);l.props!==!0&&!(l.props instanceof n.Name)&&(l.props=(0,i.evaluatedPropsToName)(a,l.props));let{props:h}=l;g();function g(){for(let e of d)p&&_(e),l.allErrors?v(e):(a.var(m,!0),v(e),a.if(m))}function _(e){for(let t in p)new RegExp(e).test(t)&&(0,r.checkStrictMode)(l,`property ${t} matches pattern ${e} (use allowMatchingProperties)`)}function v(r){a.forIn(`key`,s,o=>{a.if((0,n._)`${(0,t.usePattern)(e,r)}.test(${o})`,()=>{let t=f.includes(r);t||e.subschema({keyword:`patternProperties`,schemaProp:r,dataProp:o,dataPropType:i.Type.Str},m),l.opts.unevaluated&&h!==!0?a.assign((0,n._)`${h}[${o}]`,!0):!t&&!l.allErrors&&a.if((0,n.not)(m),()=>a.break())})})}}}})),PB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=jz();e.default={keyword:`not`,schemaType:[`object`,`boolean`],trackErrors:!0,code(e){let{gen:n,schema:r,it:i}=e;if((0,t.alwaysValidSchema)(i,r)){e.fail();return}let a=n.name(`valid`);e.subschema({keyword:`not`,compositeRule:!0,createErrors:!1,allErrors:!1},a),e.failResult(a,()=>e.reset(),()=>e.error())},error:{message:`must NOT be valid`}}})),FB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default={keyword:`anyOf`,schemaType:`array`,trackErrors:!0,code:zz().validateUnion,error:{message:`must match a schema in anyOf`}}})),IB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Az(),n=jz();e.default={keyword:`oneOf`,schemaType:`array`,trackErrors:!0,error:{message:`must match exactly one schema in oneOf`,params:({params:e})=>(0,t._)`{passingSchemas: ${e.passing}}`},code(e){let{gen:r,schema:i,parentSchema:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(o.opts.discriminator&&a.discriminator)return;let s=i,c=r.let(`valid`,!1),l=r.let(`passing`,null),u=r.name(`_valid`);e.setParams({passing:l}),r.block(d),e.result(c,()=>e.reset(),()=>e.error(!0));function d(){s.forEach((i,a)=>{let s;(0,n.alwaysValidSchema)(o,i)?r.var(u,!0):s=e.subschema({keyword:`oneOf`,schemaProp:a,compositeRule:!0},u),a>0&&r.if((0,t._)`${u} && ${c}`).assign(c,!1).assign(l,(0,t._)`[${l}, ${a}]`).else(),r.if(u,()=>{r.assign(c,!0),r.assign(l,a),s&&e.mergeEvaluated(s,t.Name)})})}}}})),LB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=jz();e.default={keyword:`allOf`,schemaType:`array`,code(e){let{gen:n,schema:r,it:i}=e;if(!Array.isArray(r))throw Error(`ajv implementation error`);let a=n.name(`valid`);r.forEach((n,r)=>{if((0,t.alwaysValidSchema)(i,n))return;let o=e.subschema({keyword:`allOf`,schemaProp:r},a);e.ok(a),e.mergeEvaluated(o)})}}})),RB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Az(),n=jz(),r={keyword:`if`,schemaType:[`object`,`boolean`],trackErrors:!0,error:{message:({params:e})=>(0,t.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,t._)`{failingKeyword: ${e.ifClause}}`},code(e){let{gen:r,parentSchema:a,it:o}=e;a.then===void 0&&a.else===void 0&&(0,n.checkStrictMode)(o,`"if" without "then" and "else" is ignored`);let s=i(o,`then`),c=i(o,`else`);if(!s&&!c)return;let l=r.let(`valid`,!0),u=r.name(`_valid`);if(d(),e.reset(),s&&c){let t=r.let(`ifClause`);e.setParams({ifClause:t}),r.if(u,f(`then`,t),f(`else`,t))}else s?r.if(u,f(`then`)):r.if((0,t.not)(u),f(`else`));e.pass(l,()=>e.error(!0));function d(){let t=e.subschema({keyword:`if`,compositeRule:!0,createErrors:!1,allErrors:!1},u);e.mergeEvaluated(t)}function f(n,i){return()=>{let a=e.subschema({keyword:n},u);r.assign(l,u),e.mergeValidEvaluated(a,l),i?r.assign(i,(0,t._)`${n}`):e.setParams({ifClause:n})}}}};function i(e,t){let r=e.schema[t];return r!==void 0&&!(0,n.alwaysValidSchema)(e,r)}e.default=r})),zB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=jz();e.default={keyword:[`then`,`else`],schemaType:[`object`,`boolean`],code({keyword:e,parentSchema:n,it:r}){n.if===void 0&&(0,t.checkStrictMode)(r,`"${e}" without "if" is ignored`)}}})),BB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=wB(),n=EB(),r=TB(),i=DB(),a=OB(),o=kB(),s=AB(),c=jB(),l=MB(),u=NB(),d=PB(),f=FB(),p=IB(),m=LB(),h=RB(),g=zB();function _(e=!1){let _=[d.default,f.default,p.default,m.default,h.default,g.default,s.default,c.default,o.default,l.default,u.default];return e?_.push(n.default,i.default):_.push(t.default,r.default),_.push(a.default),_}e.default=_})),VB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Az();e.default={keyword:`format`,type:[`number`,`string`],schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,t._)`{format: ${e}}`},code(e,n){let{gen:r,data:i,$data:a,schema:o,schemaCode:s,it:c}=e,{opts:l,errSchemaPath:u,schemaEnv:d,self:f}=c;if(!l.validateFormats)return;a?p():m();function p(){let a=r.scopeValue(`formats`,{ref:f.formats,code:l.code.formats}),o=r.const(`fDef`,(0,t._)`${a}[${s}]`),c=r.let(`fType`),u=r.let(`format`);r.if((0,t._)`typeof ${o} == "object" && !(${o} instanceof RegExp)`,()=>r.assign(c,(0,t._)`${o}.type || "string"`).assign(u,(0,t._)`${o}.validate`),()=>r.assign(c,(0,t._)`"string"`).assign(u,o)),e.fail$data((0,t.or)(p(),m()));function p(){return l.strictSchema===!1?t.nil:(0,t._)`${s} && !${u}`}function m(){let e=d.$async?(0,t._)`(${o}.async ? await ${u}(${i}) : ${u}(${i}))`:(0,t._)`${u}(${i})`,r=(0,t._)`(typeof ${u} == "function" ? ${e} : ${u}.test(${i}))`;return(0,t._)`${u} && ${u} !== true && ${c} === ${n} && !${r}`}}function m(){let a=f.formats[o];if(!a){m();return}if(a===!0)return;let[s,c,p]=h(a);s===n&&e.pass(g());function m(){if(l.strictSchema===!1){f.logger.warn(e());return}throw Error(e());function e(){return`unknown format "${o}" ignored in schema at path "${u}"`}}function h(e){let n=e instanceof RegExp?(0,t.regexpCode)(e):l.code.formats?(0,t._)`${l.code.formats}${(0,t.getProperty)(o)}`:void 0,i=r.scopeValue(`formats`,{key:o,ref:e,code:n});return typeof e==`object`&&!(e instanceof RegExp)?[e.type||`string`,e.validate,(0,t._)`${i}.validate`]:[`string`,e,i]}function g(){if(typeof a==`object`&&!(a instanceof RegExp)&&a.async){if(!d.$async)throw Error(`async format in sync schema`);return(0,t._)`await ${p}(${i})`}return typeof c==`function`?(0,t._)`${p}(${i})`:(0,t._)`${p}.test(${i})`}}}}})),HB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=[VB().default]})),UB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.contentVocabulary=e.metadataVocabulary=void 0,e.metadataVocabulary=[`title`,`description`,`default`,`deprecated`,`readOnly`,`writeOnly`,`examples`],e.contentVocabulary=[`contentMediaType`,`contentEncoding`,`contentSchema`]})),WB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=uB(),n=CB(),r=BB(),i=HB(),a=UB();e.default=[t.default,n.default,(0,r.default)(),i.default,a.metadataVocabulary,a.contentVocabulary]})),GB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DiscrError=void 0;var t;(function(e){e.Tag=`tag`,e.Mapping=`mapping`})(t||(e.DiscrError=t={}))})),KB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Az(),n=GB(),r=Jz(),i=qz(),a=jz();e.default={keyword:`discriminator`,type:`object`,schemaType:`object`,error:{message:({params:{discrError:e,tagName:t}})=>e===n.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:n,tagName:r}})=>(0,t._)`{error: ${e}, tag: ${r}, tagValue: ${n}}`},code(e){let{gen:o,data:s,schema:c,parentSchema:l,it:u}=e,{oneOf:d}=l;if(!u.opts.discriminator)throw Error(`discriminator: requires discriminator option`);let f=c.propertyName;if(typeof f!=`string`)throw Error(`discriminator: requires propertyName`);if(c.mapping)throw Error(`discriminator: mapping is not supported`);if(!d)throw Error(`discriminator: requires oneOf keyword`);let p=o.let(`valid`,!1),m=o.const(`tag`,(0,t._)`${s}${(0,t.getProperty)(f)}`);o.if((0,t._)`typeof ${m} == "string"`,()=>h(),()=>e.error(!1,{discrError:n.DiscrError.Tag,tag:m,tagName:f})),e.ok(p);function h(){let r=_();o.if(!1);for(let e in r)o.elseIf((0,t._)`${m} === ${e}`),o.assign(p,g(r[e]));o.else(),e.error(!1,{discrError:n.DiscrError.Mapping,tag:m,tagName:f}),o.endIf()}function g(n){let r=o.name(`valid`),i=e.subschema({keyword:`oneOf`,schemaProp:n},r);return e.mergeEvaluated(i,t.Name),r}function _(){let e={},t=o(l),n=!0;for(let e=0;e<d.length;e++){let c=d[e];if(c?.$ref&&!(0,a.schemaHasRulesButRef)(c,u.self.RULES)){let e=c.$ref;if(c=r.resolveRef.call(u.self,u.schemaEnv.root,u.baseId,e),c instanceof r.SchemaEnv&&(c=c.schema),c===void 0)throw new i.default(u.opts.uriResolver,u.baseId,e)}let l=c?.properties?.[f];if(typeof l!=`object`)throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${f}"`);n&&=t||o(c),s(l,e)}if(!n)throw Error(`discriminator: "${f}" must be required`);return e;function o({required:e}){return Array.isArray(e)&&e.includes(f)}function s(e,t){if(e.const)c(e.const,t);else if(e.enum)for(let n of e.enum)c(n,t);else throw Error(`discriminator: "properties/${f}" must have "const" or "enum"`)}function c(t,n){if(typeof t!=`string`||t in e)throw Error(`discriminator: "${f}" values must be unique strings`);e[t]=n}}}}})),qB=c({$id:()=>YB,$schema:()=>JB,default:()=>eV,definitions:()=>ZB,properties:()=>$B,title:()=>XB,type:()=>QB}),JB,YB,XB,ZB,QB,$B,eV,tV=o((()=>{JB=`http://json-schema.org/draft-07/schema#`,YB=`http://json-schema.org/draft-07/schema#`,XB=`Core schema meta-schema`,ZB={schemaArray:{type:`array`,minItems:1,items:{$ref:`#`}},nonNegativeInteger:{type:`integer`,minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:`#/definitions/nonNegativeInteger`},{default:0}]},simpleTypes:{enum:[`array`,`boolean`,`integer`,`null`,`number`,`object`,`string`]},stringArray:{type:`array`,items:{type:`string`},uniqueItems:!0,default:[]}},QB=[`object`,`boolean`],$B={$id:{type:`string`,format:`uri-reference`},$schema:{type:`string`,format:`uri`},$ref:{type:`string`,format:`uri-reference`},$comment:{type:`string`},title:{type:`string`},description:{type:`string`},default:!0,readOnly:{type:`boolean`,default:!1},examples:{type:`array`,items:!0},multipleOf:{type:`number`,exclusiveMinimum:0},maximum:{type:`number`},exclusiveMaximum:{type:`number`},minimum:{type:`number`},exclusiveMinimum:{type:`number`},maxLength:{$ref:`#/definitions/nonNegativeInteger`},minLength:{$ref:`#/definitions/nonNegativeIntegerDefault0`},pattern:{type:`string`,format:`regex`},additionalItems:{$ref:`#`},items:{anyOf:[{$ref:`#`},{$ref:`#/definitions/schemaArray`}],default:!0},maxItems:{$ref:`#/definitions/nonNegativeInteger`},minItems:{$ref:`#/definitions/nonNegativeIntegerDefault0`},uniqueItems:{type:`boolean`,default:!1},contains:{$ref:`#`},maxProperties:{$ref:`#/definitions/nonNegativeInteger`},minProperties:{$ref:`#/definitions/nonNegativeIntegerDefault0`},required:{$ref:`#/definitions/stringArray`},additionalProperties:{$ref:`#`},definitions:{type:`object`,additionalProperties:{$ref:`#`},default:{}},properties:{type:`object`,additionalProperties:{$ref:`#`},default:{}},patternProperties:{type:`object`,additionalProperties:{$ref:`#`},propertyNames:{format:`regex`},default:{}},dependencies:{type:`object`,additionalProperties:{anyOf:[{$ref:`#`},{$ref:`#/definitions/stringArray`}]}},propertyNames:{$ref:`#`},const:!0,enum:{type:`array`,items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:`#/definitions/simpleTypes`},{type:`array`,items:{$ref:`#/definitions/simpleTypes`},minItems:1,uniqueItems:!0}]},format:{type:`string`},contentMediaType:{type:`string`},contentEncoding:{type:`string`},if:{$ref:`#`},then:{$ref:`#`},else:{$ref:`#`},allOf:{$ref:`#/definitions/schemaArray`},anyOf:{$ref:`#/definitions/schemaArray`},oneOf:{$ref:`#/definitions/schemaArray`},not:{$ref:`#`}},eV={$schema:JB,$id:YB,title:XB,definitions:ZB,type:QB,properties:$B,default:!0}})),nV=s(((e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv=void 0;var n=sB(),r=WB(),i=KB(),a=(tV(),d(qB).default),o=[`/properties`],s=`http://json-schema.org/draft-07/schema`,c=class extends n.default{_addVocabularies(){super._addVocabularies(),r.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(i.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(a,o):a;this.addMetaSchema(e,s,!1),this.refs[`http://json-schema.org/schema`]=s}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(s)?s:void 0)}};e.Ajv=c,t.exports=e=c,t.exports.Ajv=c,Object.defineProperty(e,"__esModule",{value:!0}),e.default=c;var l=Gz();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return l.KeywordCxt}});var u=Az();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return u._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return u.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return u.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return u.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return u.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return u.CodeGen}});var f=Kz();Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return f.default}});var p=qz();Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return p.default}})})),rV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0;function t(e,t){return{validate:e,compare:t}}e.fullFormats={date:t(a,o),time:t(c(!0),l),"date-time":t(f(!0),p),"iso-time":t(c(),u),"iso-date-time":t(f(),m),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:_,"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:E,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:y,int32:{type:`number`,validate:S},int64:{type:`number`,validate:C},float:{type:`number`,validate:w},double:{type:`number`,validate:w},password:!0,binary:!0},e.fastFormats={...e.fullFormats,date:t(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,o),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,p),"iso-time":t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,u),"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,m),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 n(e){return e%4==0&&(e%100!=0||e%400==0)}var r=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,i=[0,31,28,31,30,31,30,31,31,30,31,30,31];function a(e){let t=r.exec(e);if(!t)return!1;let a=+t[1],o=+t[2],s=+t[3];return o>=1&&o<=12&&s>=1&&s<=(o===2&&n(a)?29:i[o])}function o(e,t){if(e&&t)return e>t?1:e<t?-1:0}var s=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function c(e){return function(t){let n=s.exec(t);if(!n)return!1;let r=+n[1],i=+n[2],a=+n[3],o=n[4],c=n[5]===`-`?-1:1,l=+(n[6]||0),u=+(n[7]||0);if(l>23||u>59||e&&!o)return!1;if(r<=23&&i<=59&&a<60)return!0;let d=i-u*c,f=r-l*c-+(d<0);return(f===23||f===-1)&&(d===59||d===-1)&&a<61}}function l(e,t){if(!(e&&t))return;let n=new Date(`2020-01-01T`+e).valueOf(),r=new Date(`2020-01-01T`+t).valueOf();if(n&&r)return n-r}function u(e,t){if(!(e&&t))return;let n=s.exec(e),r=s.exec(t);if(n&&r)return e=n[1]+n[2]+n[3],t=r[1]+r[2]+r[3],e>t?1:e<t?-1:0}var d=/t|\s/i;function f(e){let t=c(e);return function(e){let n=e.split(d);return n.length===2&&a(n[0])&&t(n[1])}}function p(e,t){if(!(e&&t))return;let n=new Date(e).valueOf(),r=new Date(t).valueOf();if(n&&r)return n-r}function m(e,t){if(!(e&&t))return;let[n,r]=e.split(d),[i,a]=t.split(d),s=o(n,i);if(s!==void 0)return s||l(r,a)}var h=/\/|:/,g=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function _(e){return h.test(e)&&g.test(e)}var v=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function y(e){return v.lastIndex=0,v.test(e)}var b=-(2**31),x=2**31-1;function S(e){return Number.isInteger(e)&&e<=x&&e>=b}function C(e){return Number.isInteger(e)}function w(){return!0}var T=/[^\\]\\Z/;function E(e){if(T.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}})),iV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatLimitDefinition=void 0;var t=nV(),n=Az(),r=n.operators,i={formatMaximum:{okStr:`<=`,ok:r.LTE,fail:r.GT},formatMinimum:{okStr:`>=`,ok:r.GTE,fail:r.LT},formatExclusiveMaximum:{okStr:`<`,ok:r.LT,fail:r.GTE},formatExclusiveMinimum:{okStr:`>`,ok:r.GT,fail:r.LTE}};e.formatLimitDefinition={keyword:Object.keys(i),type:`string`,schemaType:`string`,$data:!0,error:{message:({keyword:e,schemaCode:t})=>(0,n.str)`should be ${i[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,n._)`{comparison: ${i[e].okStr}, limit: ${t}}`},code(e){let{gen:r,data:a,schemaCode:o,keyword:s,it:c}=e,{opts:l,self:u}=c;if(!l.validateFormats)return;let d=new t.KeywordCxt(c,u.RULES.all.format.definition,`format`);d.$data?f():p();function f(){let t=r.scopeValue(`formats`,{ref:u.formats,code:l.code.formats}),i=r.const(`fmt`,(0,n._)`${t}[${d.schemaCode}]`);e.fail$data((0,n.or)((0,n._)`typeof ${i} != "object"`,(0,n._)`${i} instanceof RegExp`,(0,n._)`typeof ${i}.compare != "function"`,m(i)))}function p(){let t=d.schema,i=u.formats[t];if(!i||i===!0)return;if(typeof i!=`object`||i instanceof RegExp||typeof i.compare!=`function`)throw Error(`"${s}": format "${t}" does not define "compare" function`);let a=r.scopeValue(`formats`,{key:t,ref:i,code:l.code.formats?(0,n._)`${l.code.formats}${(0,n.getProperty)(t)}`:void 0});e.fail$data(m(a))}function m(e){return(0,n._)`${e}.compare(${a}, ${o}) ${i[s].fail} 0`}},dependencies:[`format`]},e.default=t=>(t.addKeyword(e.formatLimitDefinition),t)})),aV=s(((e,t)=>{Object.defineProperty(e,"__esModule",{value:!0});var n=rV(),r=iV(),i=Az(),a=new i.Name(`fullFormats`),o=new i.Name(`fastFormats`),s=(e,t={keywords:!0})=>{if(Array.isArray(t))return c(e,t,n.fullFormats,a),e;let[i,s]=t.mode===`fast`?[n.fastFormats,o]:[n.fullFormats,a];return c(e,t.formats||n.formatNames,i,s),t.keywords&&(0,r.default)(e),e};s.get=(e,t=`full`)=>{let r=(t===`fast`?n.fastFormats:n.fullFormats)[e];if(!r)throw Error(`Unknown format "${e}"`);return r};function c(e,t,n,r){var a;(a=e.opts.code).formats??(a.formats=(0,i._)`require("ajv-formats/dist/formats").${r}`);for(let r of t)e.addFormat(r,n[r])}t.exports=e=s,Object.defineProperty(e,"__esModule",{value:!0}),e.default=s})),oV=u(nV(),1),sV=u(aV(),1);function cV(){let e=new oV.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,sV.default)(e),e}var lV=class{constructor(e){this._ajv=e??cV()}getValidator(e){let t=`$id`in e&&typeof e.$id==`string`?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return e=>t(e)?{valid:!0,data:e,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(t.errors)}}},uV=class{constructor(e){this._client=e}async*callToolStream(e,t=CI,n){let r=this._client,i={...n,task:n?.task??(r.isToolTask(e.name)?{}:void 0)},a=r.requestStream({method:`tools/call`,params:e},t,i),o=r.getToolOutputValidator(e.name);for await(let t of a){if(t.type===`result`&&o){let n=t.result;if(!n.structuredContent&&!n.isError){yield{type:`error`,error:new lL(YP.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`)};return}if(n.structuredContent)try{let e=o(n.structuredContent);if(!e.valid){yield{type:`error`,error:new lL(YP.InvalidParams,`Structured content does not match the tool's output schema: ${e.errorMessage}`)};return}}catch(e){if(e instanceof lL){yield{type:`error`,error:e};return}yield{type:`error`,error:new lL(YP.InvalidParams,`Failed to validate structured content: ${e instanceof Error?e.message:String(e)}`)};return}}yield t}}async getTask(e,t){return this._client.getTask({taskId:e},t)}async getTaskResult(e,t,n){return this._client.getTaskResult({taskId:e},t,n)}async listTasks(e,t){return this._client.listTasks(e?{cursor:e}:void 0,t)}async cancelTask(e,t){return this._client.cancelTask({taskId:e},t)}requestStream(e,t,n){return this._client.requestStream(e,t,n)}};function dV(e,t,n){if(!e)throw Error(`${n} does not support task creation (required for ${t})`);if(t===`tools/call`&&!e.tools?.call)throw Error(`${n} does not support task creation for tools/call (required for ${t})`)}function fV(e,t,n){if(!e)throw Error(`${n} does not support task creation (required for ${t})`);switch(t){case`sampling/createMessage`:if(!e.sampling?.createMessage)throw Error(`${n} does not support task creation for sampling/createMessage (required for ${t})`);break;case`elicitation/create`:if(!e.elicitation?.create)throw Error(`${n} does not support task creation for elicitation/create (required for ${t})`)}}function pV(e,t){if(e&&typeof t==`object`&&t){if(e.type===`object`&&e.properties&&typeof e.properties==`object`){let n=t,r=e.properties;for(let e of Object.keys(r)){let t=r[e];n[e]===void 0&&Object.prototype.hasOwnProperty.call(t,`default`)&&(n[e]=t.default),n[e]!==void 0&&pV(t,n[e])}}if(Array.isArray(e.anyOf))for(let n of e.anyOf)typeof n!=`boolean`&&pV(n,t);if(Array.isArray(e.oneOf))for(let n of e.oneOf)typeof n!=`boolean`&&pV(n,t)}}function mV(e){if(!e)return{supportsFormMode:!1,supportsUrlMode:!1};let t=e.form!==void 0,n=e.url!==void 0;return{supportsFormMode:t||!t&&!n,supportsUrlMode:n}}var hV=class extends Tz{constructor(e,t){super(t),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._cachedKnownTaskTools=new Set,this._cachedRequiredTaskTools=new Set,this._listChangedDebounceTimers=new Map,this._capabilities=t?.capabilities??{},this._jsonSchemaValidator=t?.jsonSchemaValidator??new lV,t?.listChanged&&(this._pendingListChangedConfig=t.listChanged)}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler(`tools`,EI,e.tools,async()=>(await this.listTools()).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler(`prompts`,_I,e.prompts,async()=>(await this.listPrompts()).prompts),e.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler(`resources`,XF,e.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||={tasks:new uV(this)},this._experimental}registerCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after connecting to transport`);this._capabilities=Dz(this._capabilities,e)}setRequestHandler(e,t){let n=bz(e)?.method;if(!n)throw Error(`Schema is missing a method literal`);let r;if(vz(n)){let e=n;r=e._zod?.def?.value??e.value}else{let e=n;r=e._def?.value??e.value}if(typeof r!=`string`)throw Error(`Schema method literal must be a string`);let i=r;return i===`elicitation/create`?super.setRequestHandler(e,async(e,n)=>{let r=yz(XI,e);if(!r.success){let e=r.error instanceof Error?r.error.message:String(r.error);throw new lL(YP.InvalidParams,`Invalid elicitation request: ${e}`)}let{params:i}=r.data;i.mode=i.mode??`form`;let{supportsFormMode:a,supportsUrlMode:o}=mV(this._capabilities.elicitation);if(i.mode===`form`&&!a)throw new lL(YP.InvalidParams,`Client does not support form-mode elicitation requests`);if(i.mode===`url`&&!o)throw new lL(YP.InvalidParams,`Client does not support URL-mode elicitation requests`);let s=await Promise.resolve(t(e,n));if(i.task){let e=yz(wF,s);if(!e.success){let t=e.error instanceof Error?e.error.message:String(e.error);throw new lL(YP.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}let c=yz($I,s);if(!c.success){let e=c.error instanceof Error?c.error.message:String(c.error);throw new lL(YP.InvalidParams,`Invalid elicitation result: ${e}`)}let l=c.data,u=i.mode===`form`?i.requestedSchema:void 0;if(i.mode===`form`&&l.action===`accept`&&l.content&&u&&this._capabilities.elicitation?.form?.applyDefaults)try{pV(u,l.content)}catch{}return l}):i===`sampling/createMessage`?super.setRequestHandler(e,async(e,n)=>{let r=yz(BI,e);if(!r.success){let e=r.error instanceof Error?r.error.message:String(r.error);throw new lL(YP.InvalidParams,`Invalid sampling request: ${e}`)}let{params:i}=r.data,a=await Promise.resolve(t(e,n));if(i.task){let e=yz(wF,a);if(!e.success){let t=e.error instanceof Error?e.error.message:String(e.error);throw new lL(YP.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}let o=yz(i.tools||i.toolChoice?HI:VI,a);if(!o.success){let e=o.error instanceof Error?o.error.message:String(o.error);throw new lL(YP.InvalidParams,`Invalid sampling result: ${e}`)}return o.data}):super.setRequestHandler(e,t)}assertCapability(e,t){if(!this._serverCapabilities?.[e])throw Error(`Server does not support ${e} (required for ${t})`)}async connect(e,t){if(await super.connect(e),e.sessionId===void 0)try{let n=await this.request({method:`initialize`,params:{protocolVersion:EP,capabilities:this._capabilities,clientInfo:this._clientInfo}},fF,t);if(n===void 0)throw Error(`Server sent invalid initialize result: ${n}`);if(!DP.includes(n.protocolVersion))throw Error(`Server's protocol version is not supported: ${n.protocolVersion}`);this._serverCapabilities=n.capabilities,this._serverVersion=n.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(n.protocolVersion),this._instructions=n.instructions,await this.notification({method:`notifications/initialized`}),this._pendingListChangedConfig&&=(this._setupListChangedHandlers(this._pendingListChangedConfig),void 0)}catch(e){throw this.close(),e}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){switch(e){case`logging/setLevel`:if(!this._serverCapabilities?.logging)throw Error(`Server does not support logging (required for ${e})`);break;case`prompts/get`:case`prompts/list`:if(!this._serverCapabilities?.prompts)throw Error(`Server does not support prompts (required for ${e})`);break;case`resources/list`:case`resources/templates/list`:case`resources/read`:case`resources/subscribe`:case`resources/unsubscribe`:if(!this._serverCapabilities?.resources)throw Error(`Server does not support resources (required for ${e})`);if(e===`resources/subscribe`&&!this._serverCapabilities.resources.subscribe)throw Error(`Server does not support resource subscriptions (required for ${e})`);break;case`tools/call`:case`tools/list`:if(!this._serverCapabilities?.tools)throw Error(`Server does not support tools (required for ${e})`);break;case`completion/complete`:if(!this._serverCapabilities?.completions)throw Error(`Server does not support completions (required for ${e})`)}}assertNotificationCapability(e){if(e===`notifications/roots/list_changed`&&!this._capabilities.roots?.listChanged)throw Error(`Client does not support roots list changed notifications (required for ${e})`)}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case`sampling/createMessage`:if(!this._capabilities.sampling)throw Error(`Client does not support sampling capability (required for ${e})`);break;case`elicitation/create`:if(!this._capabilities.elicitation)throw Error(`Client does not support elicitation capability (required for ${e})`);break;case`roots/list`:if(!this._capabilities.roots)throw Error(`Client does not support roots capability (required for ${e})`);break;case`tasks/get`:case`tasks/list`:case`tasks/result`:case`tasks/cancel`:if(!this._capabilities.tasks)throw Error(`Client does not support tasks capability (required for ${e})`)}}assertTaskCapability(e){dV(this._serverCapabilities?.tasks?.requests,e,`Server`)}assertTaskHandlerCapability(e){this._capabilities&&fV(this._capabilities.tasks?.requests,e,`Client`)}async ping(e){return this.request({method:`ping`},$P,e)}async complete(e,t){return this.request({method:`completion/complete`,params:e},iL,t)}async setLoggingLevel(e,t){return this.request({method:`logging/setLevel`,params:{level:e}},$P,t)}async getPrompt(e,t){return this.request({method:`prompts/get`,params:e},gI,t)}async listPrompts(e,t){return this.request({method:`prompts/list`,params:e},oI,t)}async listResources(e,t){return this.request({method:`resources/list`,params:e},UF,t)}async listResourceTemplates(e,t){return this.request({method:`resources/templates/list`,params:e},GF,t)}async readResource(e,t){return this.request({method:`resources/read`,params:e},YF,t)}async subscribeResource(e,t){return this.request({method:`resources/subscribe`,params:e},$P,t)}async unsubscribeResource(e,t){return this.request({method:`resources/unsubscribe`,params:e},$P,t)}async callTool(e,t=CI,n){if(this.isToolTaskRequired(e.name))throw new lL(YP.InvalidRequest,`Tool "${e.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);let r=await this.request({method:`tools/call`,params:e},t,n),i=this.getToolOutputValidator(e.name);if(i){if(!r.structuredContent&&!r.isError)throw new lL(YP.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(r.structuredContent)try{let e=i(r.structuredContent);if(!e.valid)throw new lL(YP.InvalidParams,`Structured content does not match the tool's output schema: ${e.errorMessage}`)}catch(e){throw e instanceof lL?e:new lL(YP.InvalidParams,`Failed to validate structured content: ${e instanceof Error?e.message:String(e)}`)}}return r}isToolTask(e){return this._serverCapabilities?.tasks?.requests?.tools?.call?this._cachedKnownTaskTools.has(e):!1}isToolTaskRequired(e){return this._cachedRequiredTaskTools.has(e)}cacheToolMetadata(e){this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(let t of e){if(t.outputSchema){let e=this._jsonSchemaValidator.getValidator(t.outputSchema);this._cachedToolOutputValidators.set(t.name,e)}let e=t.execution?.taskSupport;(e===`required`||e===`optional`)&&this._cachedKnownTaskTools.add(t.name),e===`required`&&this._cachedRequiredTaskTools.add(t.name)}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,t){let n=await this.request({method:`tools/list`,params:e},SI,t);return this.cacheToolMetadata(n.tools),n}_setupListChangedHandler(e,t,n,r){let i=DI.safeParse(n);if(!i.success)throw Error(`Invalid ${e} listChanged options: ${i.error.message}`);if(typeof n.onChanged!=`function`)throw Error(`Invalid ${e} listChanged options: onChanged must be a function`);let{autoRefresh:a,debounceMs:o}=i.data,{onChanged:s}=n,c=async()=>{if(!a){s(null,null);return}try{let e=await r();s(null,e)}catch(e){let t=e instanceof Error?e:Error(String(e));s(t,null)}};this.setNotificationHandler(t,()=>{if(o){let t=this._listChangedDebounceTimers.get(e);t&&clearTimeout(t);let n=setTimeout(c,o);this._listChangedDebounceTimers.set(e,n)}else c()})}async sendRootsListChanged(){return this.notification({method:`notifications/roots/list_changed`})}};function gV(e,t){if(!e)throw Error(t)}var _V=3e3,vV=5e3,yV=3e5;function bV(e){let{url:t,clientName:n,clientUri:r,callbackUrl:i=typeof window<`u`?PO(new URL(`/oauth/callback`,window.location.origin).toString()):`/oauth/callback`,storageKeyPrefix:a=`mcp:auth`,clientConfig:o={},customHeaders:s={},debug:c=!1,autoRetry:l=!1,autoReconnect:u=_V,transportType:d=`auto`,preventAutoAuth:f=!1,onPopupWindow:p}=e,[m,h]=(0,b.useState)(`discovering`),[g,_]=(0,b.useState)([]),[v,y]=(0,b.useState)([]),[x,S]=(0,b.useState)([]),[C,w]=(0,b.useState)([]),[T,E]=(0,b.useState)(void 0),[D,O]=(0,b.useState)([]),[k,A]=(0,b.useState)(void 0),j=(0,b.useRef)(null),M=(0,b.useRef)(null),N=(0,b.useRef)(null),P=(0,b.useRef)(!1),F=(0,b.useRef)(!0),I=(0,b.useRef)(0),L=(0,b.useRef)(null),ee=(0,b.useRef)(m),te=(0,b.useRef)(u),ne=(0,b.useRef)(null);(0,b.useEffect)(()=>{ee.current=m,te.current=u},[m,u]);let R=(0,b.useCallback)((e,t,...n)=>{let r=n.length>0?`${t} ${n.map(e=>JSON.stringify(e)).join(` `)}`:t;console[e](`[useMcp] ${r}`),F.current&&O(t=>[...t.slice(-100),{level:e,message:r,timestamp:Date.now()}])},[]),z=(0,b.useCallback)(async(e=!1)=>{e||R(`info`,`Disconnecting...`),P.current=!1,L.current&&clearTimeout(L.current),L.current=null;let t=M.current;if(j.current=null,M.current=null,F.current&&!e&&(h(`discovering`),_([]),y([]),S([]),w([]),E(void 0),A(void 0)),t)try{await t.close(),e||R(`debug`,`Transport closed`)}catch(t){e||R(`warn`,`Error closing transport:`,t)}},[R]),B=(0,b.useCallback)((e,t)=>{if(R(`error`,e,t??``),F.current){h(`failed`),E(e);let t=N.current?.getLastAttemptedAuthUrl();t&&(A(t),R(`info`,`Manual authentication URL may be available.`,t))}P.current=!1},[R]),re=(0,b.useCallback)(async()=>{if(P.current){R(`debug`,`Connection attempt already in progress.`);return}if(!F.current){R(`debug`,`Connect called after unmount, aborting.`);return}P.current=!0,I.current+=1,E(void 0),A(void 0),ne.current=null,h(`discovering`),R(`info`,`Connecting attempt #${I.current} to ${t}...`),N.current||(N.current=new IO(t,{storageKeyPrefix:a,clientName:n,clientUri:r,callbackUrl:i,preventAutoAuth:f,onPopupWindow:p}),R(`debug`,`BrowserOAuthClientProvider initialized in connect.`)),j.current||(j.current=new hV({name:o.name||`use-mcp-react-client`,version:o.version||`0.1.0`},{capabilities:{}}),R(`debug`,`MCP Client initialized in connect.`));let e=async e=>{R(`info`,`Attempting connection with ${e.toUpperCase()} transport...`),ee.current!==`authenticating`&&h(`connecting`);let n;try{gV(N.current,`Auth Provider must be initialized`),gV(j.current,`Client must be initialized`),M.current&&=(await M.current.close().catch(e=>R(`warn`,`Error closing previous transport: ${e.message}`)),null);let r={authProvider:N.current,requestInit:{headers:{Accept:`application/json, text/event-stream`,...s}}},i=PO(t),a=new URL(i);R(`debug`,`Creating ${e.toUpperCase()} transport for URL: ${a.toString()}`),R(`debug`,`Transport options:`,{authProvider:!!N.current,headers:s,url:a.toString()}),e===`http`?(R(`debug`,`Creating StreamableHTTPClientTransport...`),n=new _z(a,r),R(`debug`,`StreamableHTTPClientTransport created successfully`)):(R(`debug`,`Creating SSEClientTransport...`),n=new pz(a,r),R(`debug`,`SSEClientTransport created successfully`)),M.current=n,R(`debug`,`${e.toUpperCase()} transport created and assigned to ref.`)}catch(t){return B(`Failed to create ${e.toUpperCase()} transport: ${t instanceof Error?t.message:String(t)}`,t instanceof Error?t:void 0),`failed`}n.onmessage=e=>{R(`debug`,`[Transport] Received: ${JSON.stringify(e)}`),j.current?.handleMessage?.(e)},n.onerror=t=>{R(`warn`,`Transport error event (${e.toUpperCase()}):`,t),R(`debug`,`Error details:`,{message:t.message,stack:t.stack,name:t.name,cause:t.cause}),B(`Transport error (${e.toUpperCase()}): ${t.message}`,t)},n.onclose=()=>{if(!F.current||P.current)return;R(`info`,`Transport connection closed (${ne.current||`unknown`} type).`);let e=ee.current,t=te.current;if(e===`ready`&&t){let e=typeof t==`number`?t:_V;R(`info`,`Attempting to reconnect in ${e}ms...`),h(`connecting`),setTimeout(()=>{F.current&&re()},e)}else e!==`failed`&&e!==`authenticating`&&B(`Connection closed unexpectedly.`)};try{R(`info`,`Connecting client via ${e.toUpperCase()}...`),R(`debug`,`About to call client.connect() with transport instance`),R(`debug`,`Transport instance type: ${n.constructor.name}`),await j.current.connect(n),R(`info`,`Client connected via ${e.toUpperCase()}. Loading tools, resources, and prompts...`),ne.current=e,h(`loading`);let t=await j.current.request({method:`tools/list`},SI),r={resources:[],resourceTemplates:[]};try{r=await j.current.request({method:`resources/list`},UF)}catch(e){R(`debug`,`Server does not support resources/list method`,e)}let i={prompts:[]};try{i=await j.current.request({method:`prompts/list`},oI)}catch(e){R(`debug`,`Server does not support prompts/list method`,e)}if(F.current){_(t.tools),y(r.resources),S(Array.isArray(r.resourceTemplates)?r.resourceTemplates:[]),w(i.prompts);let e=[`Loaded ${t.tools.length} tools`];return(r.resources.length>0||r.resourceTemplates&&r.resourceTemplates.length>0)&&(e.push(`${r.resources.length} resources`),Array.isArray(r.resourceTemplates)&&r.resourceTemplates.length>0&&e.push(`${r.resourceTemplates.length} resource templates`)),i.prompts.length>0&&e.push(`${i.prompts.length} prompts`),R(`info`,e.join(`, `)+`.`),h(`ready`),I.current=0,`success`}return`failed`}catch(n){R(`debug`,`Client connect error via ${e.toUpperCase()}:`,n),R(`debug`,`Connect error details:`,{message:n instanceof Error?n.message:String(n),stack:n instanceof Error?n.stack:`N/A`,name:n instanceof Error?n.name:`Unknown`,cause:n instanceof Error?n.cause:void 0});let r=n instanceof Error?n:Error(String(n)),i=r.message,a=i.includes(`404`)||i.includes(`Not Found`),o=i.includes(`405`)||i.includes(`Method Not Allowed`),s=i===`Failed to fetch`||i===`NetworkError when attempting to fetch resource.`||i===`Load failed`;if(e===`http`&&(a||o||s))return R(`warn`,`HTTP transport failed (${s?`CORS`:a?`404`:`405`}).`),`fallback`;if(r instanceof FR||i.includes(`Unauthorized`)||i.includes(`401`)){R(`info`,`Authentication required.`),gV(N.current,`Auth Provider not available for auth flow`);let e=await N.current.tokens();if(f&&!e)return R(`info`,`Authentication required but auto-auth prevented. User action needed.`),h(`pending_auth`),`auth_redirect`;ee.current!==`authenticating`&&ee.current!==`pending_auth`&&(h(`authenticating`),L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{},yV));try{let e=await GR(N.current,{serverUrl:t});if(!F.current)return`failed`;if(e===`AUTHORIZED`)return R(`info`,`Authentication successful via existing token or refresh. Re-attempting connection...`),L.current&&clearTimeout(L.current),P.current=!1,re(),`failed`;if(e===`REDIRECT`)return R(`info`,`Redirecting for authentication. Waiting for callback...`),`auth_redirect`}catch(e){return F.current?(L.current&&clearTimeout(L.current),B(`Failed to initiate authentication: ${e instanceof Error?e.message:String(e)}`,e instanceof Error?e:void 0),`failed`):`failed`}}return B(`Failed to connect via ${e.toUpperCase()}: ${i}`,r),`failed`}},c=`failed`;if(console.log({transportType:d}),d===`sse`)R(`debug`,`Using SSE-only transport mode`),c=await e(`sse`);else if(d===`http`)R(`debug`,`Using HTTP-only transport mode`),c=await e(`http`);else{R(`debug`,`Using auto transport mode (HTTP with SSE fallback)`);let t=await e(`http`);if(t===`fallback`&&F.current&&ee.current!==`authenticating`){R(`info`,`HTTP failed, attempting SSE fallback...`);let t=await e(`sse`);c=t,t===`failed`&&F.current}else c=t}(c===`success`||c===`failed`)&&(P.current=!1),R(`debug`,`Connection sequence finished with status: ${c}`)},[R,B,z,GR,t,a,n,r,i,o.name,o.version]),ie=(0,b.useCallback)(async(e,n)=>{if(ee.current!==`ready`||!j.current)throw Error(`MCP client is not ready (current state: ${m}). Cannot call tool "${e}".`);R(`info`,`Calling tool: ${e}`,n);try{let t=await j.current.request({method:`tools/call`,params:{name:e,arguments:n}},CI);return R(`info`,`Tool "${e}" call successful:`,t),t}catch(n){R(`error`,`Error calling tool "${e}": ${n instanceof Error?n.message:String(n)}`,n);let r=n instanceof Error?n:Error(String(n));if(r instanceof FR||r.message.includes(`Unauthorized`)||r.message.includes(`401`)){R(`warn`,`Tool call unauthorized, attempting re-authentication...`),h(`authenticating`),L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{},yV);try{gV(N.current,`Auth Provider not available for tool re-auth`);let e=await GR(N.current,{serverUrl:t});if(!F.current)return;e===`AUTHORIZED`?(R(`info`,`Re-authentication successful. Retrying tool call is recommended, or reconnecting.`),L.current&&clearTimeout(L.current),P.current=!1,re()):e===`REDIRECT`&&R(`info`,`Redirecting for re-authentication for tool call.`)}catch(e){if(!F.current)return;L.current&&clearTimeout(L.current),B(`Re-authentication failed: ${e instanceof Error?e.message:String(e)}`,e instanceof Error?e:void 0)}}if(ee.current!==`authenticating`)throw n;return}},[m,t,R,B,re]),ae=(0,b.useCallback)(()=>{ee.current===`failed`?(R(`info`,`Retry requested...`),re()):R(`warn`,`Retry called but state is not 'failed' (state: ${ee.current}). Ignoring.`)},[R,re]),oe=(0,b.useCallback)(async()=>{R(`info`,`Manual authentication requested...`);let e=ee.current;if(e===`failed`)R(`info`,`Attempting to reconnect and authenticate via retry...`),ae();else if(e===`pending_auth`){R(`info`,`Proceeding with authentication from pending state...`),h(`authenticating`),L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{},yV);try{gV(N.current,`Auth Provider not available for manual auth`);let e=await GR(N.current,{serverUrl:t});if(!F.current)return;e===`AUTHORIZED`?(R(`info`,`Manual authentication successful. Re-attempting connection...`),L.current&&clearTimeout(L.current),P.current=!1,re()):e===`REDIRECT`&&R(`info`,`Redirecting for manual authentication. Waiting for callback...`)}catch(e){if(!F.current)return;L.current&&clearTimeout(L.current),B(`Manual authentication failed: ${e instanceof Error?e.message:String(e)}`,e instanceof Error?e:void 0)}}else if(e===`authenticating`){R(`warn`,`Already attempting authentication. Check for blocked popups or wait for timeout.`);let e=N.current?.getLastAttemptedAuthUrl();e&&!k&&(A(e),R(`info`,`Manual authentication URL retrieved:`,e))}else R(`info`,`Client not in a state requiring manual authentication trigger (state: ${e}). If needed, try disconnecting and reconnecting.`)},[R,ae,k,t,B,re]),se=(0,b.useCallback)(()=>{if(N.current){let e=N.current.clearStorage();R(`info`,`Cleared ${e} item(s) from localStorage for ${t}.`),A(void 0),z()}else R(`warn`,`Auth provider not initialized, cannot clear storage.`)},[t,R,z]),ce=(0,b.useCallback)(async()=>{if(ee.current!==`ready`||!j.current)throw Error(`MCP client is not ready (current state: ${m}). Cannot list resources.`);R(`info`,`Listing resources...`);try{let e=await j.current.request({method:`resources/list`},UF);F.current&&(y(e.resources),S(Array.isArray(e.resourceTemplates)?e.resourceTemplates:[]),R(`info`,`Listed ${e.resources.length} resources, ${Array.isArray(e.resourceTemplates)?e.resourceTemplates.length:0} resource templates.`))}catch(e){throw R(`error`,`Error listing resources: ${e instanceof Error?e.message:String(e)}`,e),e}},[m,R]),le=(0,b.useCallback)(async e=>{if(ee.current!==`ready`||!j.current)throw Error(`MCP client is not ready (current state: ${m}). Cannot read resource "${e}".`);R(`info`,`Reading resource: ${e}`);try{let t=await j.current.request({method:`resources/read`,params:{uri:e}},YF);return R(`info`,`Resource "${e}" read successfully`),t}catch(t){throw R(`error`,`Error reading resource "${e}": ${t instanceof Error?t.message:String(t)}`,t),t}},[m,R]),ue=(0,b.useCallback)(async()=>{if(ee.current!==`ready`||!j.current)throw Error(`MCP client is not ready (current state: ${m}). Cannot list prompts.`);R(`info`,`Listing prompts...`);try{let e=await j.current.request({method:`prompts/list`},oI);F.current&&(w(e.prompts),R(`info`,`Listed ${e.prompts.length} prompts.`))}catch(e){throw R(`error`,`Error listing prompts: ${e instanceof Error?e.message:String(e)}`,e),e}},[m,R]),de=(0,b.useCallback)(async(e,t)=>{if(ee.current!==`ready`||!j.current)throw Error(`MCP client is not ready (current state: ${m}). Cannot get prompt "${e}".`);R(`info`,`Getting prompt: ${e}`,t);try{let n=await j.current.request({method:`prompts/get`,params:{name:e,arguments:t}},gI);return R(`info`,`Prompt "${e}" retrieved successfully`),n}catch(t){throw R(`error`,`Error getting prompt "${e}": ${t instanceof Error?t.message:String(t)}`,t),t}},[m,R]);return(0,b.useEffect)(()=>{let e=e=>{e.origin===window.location.origin&&e.data?.type===`mcp_auth_callback`&&(R(`info`,`Received auth callback message.`,e.data),L.current&&clearTimeout(L.current),e.data.success?(R(`info`,`Authentication successful via popup. Reconnecting client...`),P.current=!1,re()):B(`Authentication failed in callback: ${e.data.error||`Unknown reason.`}`))};return window.addEventListener(`message`,e),R(`debug`,`Auth callback message listener added.`),()=>{window.removeEventListener(`message`,e),R(`debug`,`Auth callback message listener removed.`),L.current&&clearTimeout(L.current)}},[R,B,re]),(0,b.useEffect)(()=>(F.current=!0,R(`debug`,`useMcp mounted, initiating connection.`),I.current=0,(!N.current||N.current.serverUrl!==t)&&(N.current=new IO(t,{storageKeyPrefix:a,clientName:n,clientUri:r,callbackUrl:i,preventAutoAuth:f,onPopupWindow:p}),R(`debug`,`BrowserOAuthClientProvider initialized/updated on mount/option change.`)),re(),()=>{F.current=!1,R(`debug`,`useMcp unmounting, disconnecting.`),z(!0)}),[t,a,i,n,r,o.name,o.version,re,z]),(0,b.useEffect)(()=>{let e=null;if(m===`failed`&&l&&I.current>0){let t=typeof l==`number`?l:vV;R(`info`,`Connection failed, auto-retrying in ${t}ms...`),e=setTimeout(()=>{F.current&&ee.current===`failed`&&ae()},t)}return()=>{e&&clearTimeout(e)}},[m,l,ae,R]),{state:m,tools:g,resources:v,resourceTemplates:x,prompts:C,error:T,log:D,authUrl:k,callTool:ie,listResources:ce,readResource:le,listPrompts:ue,getPrompt:de,retry:ae,disconnect:z,authenticate:oe,clearStorage:se}}function xV({service:e,autoConnect:t=!1,onConnected:n,onError:r}){let{toast:i}=on(),{state:a,tools:o,resources:s,prompts:c,error:l,authUrl:u,callTool:d,readResource:f,listResources:p,getPrompt:m,listPrompts:h,retry:g,disconnect:_,authenticate:v,clearStorage:y}=bV({url:e.url,clientName:`AgentDeck`,clientUri:window.location.origin,callbackUrl:`${window.location.origin}/oauth/callback`,storageKeyPrefix:`mcp:auth:${e.id}`,debug:!0,autoRetry:3,autoReconnect:5e3,transportType:`auto`,preventAutoAuth:!t}),x=a===`ready`,S=a===`connecting`||a===`loading`,C=a===`authenticating`||a===`pending_auth`,w=a===`failed`;return b.useEffect(()=>{x&&n&&(n(),i({title:`Connected to MCP service`,description:`Successfully connected to ${e.name}`}))},[x,n,e.name,i]),b.useEffect(()=>{w&&l&&r&&(r(l),i({title:`MCP connection failed`,description:l,variant:`destructive`}))},[w,l,r,i]),{isConnected:x,isConnecting:S,isAuthenticating:C,hasError:w,error:l,tools:o,resources:s,prompts:c,connect:()=>{g()},disconnect:_,retry:g,authenticate:v,callTool:async(e,t)=>{try{return await d(e,t)}catch(e){let t=e instanceof Error?e.message:`Unknown error`;throw i({title:`Tool call failed`,description:t,variant:`destructive`}),e}},readResource:async e=>{try{return await f(e)}catch(e){let t=e instanceof Error?e.message:`Unknown error`;throw i({title:`Resource read failed`,description:t,variant:`destructive`}),e}},listResources:async()=>{try{await p()}catch(e){let t=e instanceof Error?e.message:`Unknown error`;throw i({title:`Resource listing failed`,description:t,variant:`destructive`}),e}},getPrompt:async(e,t)=>{try{return await m(e,t)}catch(e){let t=e instanceof Error?e.message:`Unknown error`;throw i({title:`Prompt retrieval failed`,description:t,variant:`destructive`}),e}},listPrompts:async()=>{try{await h()}catch(e){let t=e instanceof Error?e.message:`Unknown error`;throw i({title:`Prompt listing failed`,description:t,variant:`destructive`}),e}},authUrl:u,clearStorage:y}}function SV(){let[e,t]=(0,b.useState)(`https://api.githubcopilot.com/mcp`),[n,r]=(0,b.useState)(`get_me`),[i,a]=(0,b.useState)(`{}`),[o,s]=(0,b.useState)(``),{isConnected:c,isConnecting:l,isAuthenticating:u,hasError:d,error:f,tools:p,resources:m,prompts:h,connect:g,disconnect:_,retry:v,authenticate:y,callTool:x,authUrl:S,clearStorage:C}=xV({service:{id:`test-mcp-service`,name:`Test MCP Service`,type:`mcp`,url:e,health:`unknown`,description:`Test service for use-mcp integration`,cardColor:`#7ed4da`,isConnected:!1,lastPing:void 0,registeredAt:new Date().toISOString(),updatedAt:new Date().toISOString()},autoConnect:!1,onConnected:()=>{console.log(`Connected to test MCP service`)},onError:e=>{console.error(`Test MCP service error:`,e)}}),w=l?{status:`connecting`,icon:Pi,color:`text-yellow-500`}:u?{status:`authenticating`,icon:ji,color:`text-blue-500`}:c?{status:`connected`,icon:xi,color:`text-green-500`}:d?{status:`error`,icon:Si,color:`text-red-500`}:{status:`disconnected`,icon:Si,color:`text-gray-500`};return(0,V.jsxs)(`div`,{className:`container mx-auto p-6 space-y-6`,children:[(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(`h1`,{className:`text-3xl font-bold mb-2`,children:`use-mcp Integration Test`}),(0,V.jsx)(`p`,{className:`text-muted-foreground`,children:`Testing the new use-mcp library integration with OAuth support`})]}),(0,V.jsxs)(EO,{children:[(0,V.jsxs)(DO,{children:[(0,V.jsxs)(OO,{className:`flex items-center gap-2`,children:[(0,V.jsx)(w.icon,{className:`w-5 h-5 ${w.color}`}),`Connection Status: `,w.status]}),(0,V.jsx)(kO,{children:`Current connection state and available actions`})]}),(0,V.jsxs)(AO,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsxs)(`div`,{className:`space-y-1`,children:[(0,V.jsx)(zp,{children:`Service URL`}),(0,V.jsx)(uu,{value:e,onChange:e=>t(e.target.value),placeholder:`Enter MCP service URL`})]}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[!c&&!l&&(0,V.jsx)(G,{onClick:g,children:`Connect`}),c&&(0,V.jsx)(G,{onClick:_,variant:`outline`,children:`Disconnect`}),d&&(0,V.jsxs)(G,{onClick:v,variant:`outline`,children:[(0,V.jsx)(Pi,{className:`w-4 h-4 mr-1`}),`Retry`]}),S&&!c&&(0,V.jsxs)(G,{onClick:y,variant:`outline`,children:[(0,V.jsx)(ji,{className:`w-4 h-4 mr-1`}),`Authenticate`]})]})]}),f&&(0,V.jsxs)(`div`,{className:`flex items-center gap-2 p-3 bg-destructive/10 border border-destructive/20 rounded-md`,children:[(0,V.jsx)(bi,{className:`w-4 h-4 text-destructive`}),(0,V.jsx)(`span`,{className:`text-sm text-destructive`,children:f})]})]})]}),(0,V.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[(0,V.jsxs)(EO,{children:[(0,V.jsx)(DO,{children:(0,V.jsxs)(OO,{className:`flex items-center gap-2`,children:[(0,V.jsx)(Ki,{className:`w-4 h-4`}),`Tools (`,p.length,`)`]})}),(0,V.jsx)(AO,{children:p.length===0?(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:c?`No tools available`:`Connect to see tools`}):(0,V.jsxs)(`div`,{className:`space-y-2`,children:[p.slice(0,5).map((e,t)=>(0,V.jsx)(`div`,{className:`text-sm`,children:(0,V.jsx)(fh,{variant:`outline`,className:`text-xs`,children:e.name})},t)),p.length>5&&(0,V.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`+`,p.length-5,` more tools`]})]})})]}),(0,V.jsxs)(EO,{children:[(0,V.jsx)(DO,{children:(0,V.jsxs)(OO,{children:[`Resources (`,m.length,`)`]})}),(0,V.jsx)(AO,{children:(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:c?`${m.length} resources available`:`Connect to see resources`})})]}),(0,V.jsxs)(EO,{children:[(0,V.jsx)(DO,{children:(0,V.jsxs)(OO,{children:[`Prompts (`,h.length,`)`]})}),(0,V.jsx)(AO,{children:(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:c?`${h.length} prompts available`:`Connect to see prompts`})})]})]}),c&&(0,V.jsxs)(EO,{children:[(0,V.jsxs)(DO,{children:[(0,V.jsx)(OO,{children:`Test Tool Call`}),(0,V.jsx)(kO,{children:`Test calling a tool on the connected MCP service`})]}),(0,V.jsxs)(AO,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(zp,{htmlFor:`toolName`,children:`Tool Name`}),(0,V.jsx)(uu,{id:`toolName`,value:n,onChange:e=>r(e.target.value),placeholder:`e.g., get_me`})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(zp,{htmlFor:`toolArgs`,children:`Arguments (JSON)`}),(0,V.jsx)(uu,{id:`toolArgs`,value:i,onChange:e=>a(e.target.value),placeholder:`{"key": "value"}`})]})]}),(0,V.jsxs)(G,{onClick:async()=>{try{let e={};i.trim()&&(e=JSON.parse(i));let t=await x(n,e);s(JSON.stringify(t,null,2))}catch(e){s(`Error: ${e instanceof Error?e.message:`Unknown error`}`)}},disabled:!c,children:[(0,V.jsx)(Fi,{className:`w-4 h-4 mr-1`}),`Call Tool`]}),o&&(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(zp,{children:`Result`}),(0,V.jsx)(Pp,{value:o,readOnly:!0,rows:10,className:`font-mono text-sm`})]})]})]}),S&&(0,V.jsxs)(EO,{children:[(0,V.jsxs)(DO,{children:[(0,V.jsxs)(OO,{className:`flex items-center gap-2`,children:[(0,V.jsx)(ji,{className:`w-4 h-4`}),`OAuth Authentication`]}),(0,V.jsx)(kO,{children:`This service requires OAuth authentication`})]}),(0,V.jsxs)(AO,{className:`space-y-4`,children:[(0,V.jsx)(`div`,{className:`p-3 bg-blue-50 border border-blue-200 rounded-md`,children:(0,V.jsx)(`p`,{className:`text-sm text-blue-800`,children:`This MCP service requires OAuth authentication. Click the "Authenticate" button above to start the OAuth flow.`})}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsxs)(G,{onClick:y,variant:`outline`,children:[(0,V.jsx)(ji,{className:`w-4 h-4 mr-1`}),`Start OAuth Flow`]}),(0,V.jsx)(G,{onClick:C,variant:`outline`,children:`Clear OAuth Data`})]})]})]})]})}function CV(e){return e.before.title!==e.after.title||e.before.body!==e.after.body||e.before.triggers.join(`
|
|
226
226
|
`)!==e.after.triggers.join(`
|
|
227
|
-
`)}var
|
|
227
|
+
`)}var wV=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r){setTimeout(function(){r(e)},0);return}return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h){d[r]=void 0;continue}if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}};new class extends wV{};function TV(e,t){let n=0;for(;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function EV(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function DV(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function OV(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function kV(e,t){return DV(e,t,``)}function AV(e,t){return OV(e,t,``)}function jV(e,t){return t.slice(0,MV(e,t))}function MV(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function NV(e,t){let n=[];for(let r of Array.from(t.segment(e))){let e=r.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}return n}function PV(e,t){if(t)return IV(e,t)[1];let n;for(n=e.length-1;n>=0&&e[n].match(/\s/);n--);return e.substring(n+1)}function FV(e,t){if(t)return IV(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:``}function IV(e,t){if(!t)return[FV(e),PV(e)];if(t.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);let n=NV(e,t),r=n[0],i=n[n.length-1];return[/\s/.test(r)?r:``,/\s/.test(i)?i:``]}var LV=`a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,RV=RegExp(`[${LV}]+|\\s+|[^${LV}]`,`ug`);new class extends wV{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=NV(e,r)}else n=e.match(RV)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&zV(n,i,r,e,t.intlSegmenter),n=e,r=null,i=null)}),(r||i)&&zV(n,i,r,null,t.intlSegmenter),e}};function zV(e,t,n,r,i){if(t&&n){let[a,o]=IV(t.value,i),[s,c]=IV(n.value,i);if(e){let r=TV(a,s);e.value=OV(e.value,s,r),t.value=kV(t.value,r),n.value=kV(n.value,r)}if(r){let e=EV(o,c);r.value=DV(r.value,c,e),t.value=AV(t.value,e),n.value=AV(n.value,e)}}else if(n){if(e){let e=FV(n.value,i);n.value=n.value.substring(e.length)}if(r){let e=FV(r.value,i);r.value=r.value.substring(e.length)}}else if(e&&r){let n=FV(r.value,i),[a,o]=IV(t.value,i),s=TV(n,a);t.value=kV(t.value,s);let c=EV(kV(n,s),o);t.value=AV(t.value,c),r.value=DV(r.value,n,c),e.value=OV(e.value,n,n.slice(0,n.length-c.length))}else if(r){let e=FV(r.value,i),n=jV(PV(t.value,i),e);t.value=AV(t.value,n)}else if(e){let n=jV(PV(e.value,i),FV(t.value,i));t.value=kV(t.value,n)}}new class extends wV{tokenize(e){let t=RegExp(`(\\r?\\n)|[${LV}]+|[^\\S\\n\\r]+|[^${LV}]`,`ug`);return e.match(t)||[]}};var BV=new class extends wV{constructor(){super(...arguments),this.tokenize=HV}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
|
|
228
228
|
`))&&(e=e.trim()),(!n.newlineIsToken||!t.includes(`
|
|
229
229
|
`))&&(t=t.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(e.endsWith(`
|
|
230
230
|
`)&&(e=e.slice(0,-1)),t.endsWith(`
|
|
231
|
-
`)&&(t=t.slice(0,-1))),super.equals(e,t,n)}};function
|
|
232
|
-
`));let n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let e=0;e<r.length;e++){let i=r[e];e%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}function
|
|
233
|
-
`)}function
|
|
231
|
+
`)&&(t=t.slice(0,-1))),super.equals(e,t,n)}};function VV(e,t,n){return BV.diff(e,t,n)}function HV(e,t){t.stripTrailingCr&&(e=e.replace(/\r\n/g,`
|
|
232
|
+
`));let n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let e=0;e<r.length;e++){let i=r[e];e%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}function UV(e){return e==`.`||e==`!`||e==`?`}new class extends wV{tokenize(e){let t=[],n=0;for(let r=0;r<e.length;r++){if(r==e.length-1){t.push(e.slice(n));break}if(UV(e[r])&&e[r+1].match(/\s/)){for(t.push(e.slice(n,r+1)),r=n=r+1;e[r+1]?.match(/\s/);)r++;t.push(e.slice(n,r+1)),n=r+1}}return t}},new class extends wV{tokenize(e){return e.split(/([{}:;,]|\s+)/)}},new class extends wV{constructor(){super(...arguments),this.tokenize=HV}get useLongestToken(){return!0}castInput(e,t){let{undefinedReplacement:n,stringifyReplacer:r=(e,t)=>t===void 0?n:t}=t;return typeof e==`string`?e:JSON.stringify(WV(e,null,null,r),null,` `)}equals(e,t,n){return super.equals(e.replace(/,([\r\n])/g,`$1`),t.replace(/,([\r\n])/g,`$1`),n)}};function WV(e,t,n,r,i){t||=[],n||=[],r&&(e=r(i===void 0?``:i,e));let a=0;for(;a<t.length;a+=1)if(t[a]===e)return n[a];let o;if(Object.prototype.toString.call(e)===`[object Array]`){for(t.push(e),o=Array(e.length),n.push(o),a=0;a<e.length;a+=1)o[a]=WV(e[a],t,n,r,String(a));return t.pop(),n.pop(),o}if(e&&e.toJSON&&(e=e.toJSON()),typeof e==`object`&&e){t.push(e),o={},n.push(o);let i=[],s;for(s in e)Object.prototype.hasOwnProperty.call(e,s)&&i.push(s);for(i.sort(),a=0;a<i.length;a+=1)s=i[a],o[s]=WV(e[s],t,n,r,s);t.pop(),n.pop()}else o=e;return o}new class extends wV{tokenize(e){return e.slice()}join(e){return e}removeEmpty(e){return e}};var GV=3,KV=10;function qV(e){return e===``?[]:e.replace(/\n$/,``).split(`
|
|
233
|
+
`)}function JV(e,t){let n=VV(e,t),r=[],i=1,a=1;for(let e of n){let t=qV(e.value);if(!e.added&&!e.removed&&t.length>=KV){let e=t.slice(0,GV),n=t.slice(-3),o=t.length-6;for(let t of e)r.push({kind:`unchanged`,text:t,oldLine:i++,newLine:a++});o>0&&(r.push({kind:`ellipsis`,text:`${o} unchanged lines`}),i+=o,a+=o);for(let e of n)r.push({kind:`unchanged`,text:e,oldLine:i++,newLine:a++});continue}for(let n of t)e.added?r.push({kind:`added`,text:n,newLine:a++}):e.removed?r.push({kind:`removed`,text:n,oldLine:i++}):r.push({kind:`unchanged`,text:n,oldLine:i++,newLine:a++})}return r}function YV(e){return e.some(e=>e.kind===`added`||e.kind===`removed`)}var XV=`max-w-full overflow-x-auto rounded-md border border-gray-800 bg-gray-950 font-mono text-xs leading-5`;function ZV(e){switch(e){case`added`:return`bg-emerald-950/70 text-emerald-100`;case`removed`:return`bg-rose-950/70 text-rose-100`;case`ellipsis`:return`bg-gray-900 text-gray-500 italic`;default:return`bg-gray-950 text-gray-300`}}function QV(e){switch(e){case`added`:return`+`;case`removed`:return`-`;case`ellipsis`:return`…`;default:return` `}}function $V({rows:e,emptyLabel:t}){return e.length===0?(0,V.jsx)(`p`,{className:`text-sm text-gray-500`,children:t}):(0,V.jsx)(`div`,{className:XV,children:e.map((e,t)=>(0,V.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[3rem_3rem_minmax(0,1fr)] gap-0 ${ZV(e.kind)}`,children:[(0,V.jsx)(`span`,{className:`select-none border-r border-gray-800/80 px-2 py-0.5 text-right text-gray-600`,children:e.oldLine??``}),(0,V.jsx)(`span`,{className:`select-none border-r border-gray-800/80 px-2 py-0.5 text-right text-gray-600`,children:e.newLine??``}),(0,V.jsxs)(`div`,{className:`flex min-w-0 gap-2 px-2 py-0.5`,children:[(0,V.jsx)(`span`,{className:`w-3 shrink-0 select-none text-gray-500`,children:QV(e.kind)}),(0,V.jsx)(`span`,{className:`min-w-0 whitespace-pre-wrap break-words`,children:e.text||` `})]})]},`${e.kind}-${t}-${e.oldLine??``}-${e.newLine??``}`))})}function eH({before:e,after:t}){let n=e.filter(e=>!t.includes(e)),r=t.filter(t=>!e.includes(t));return n.length===0&&r.length===0?null:(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(`h4`,{className:`text-sm font-medium text-gray-400`,children:`Triggers`}),(0,V.jsxs)(`div`,{className:`${XV} p-0`,children:[n.map(e=>(0,V.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[3rem_3rem_minmax(0,1fr)] bg-rose-950/70 text-rose-100`,children:[(0,V.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,V.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,V.jsxs)(`div`,{className:`flex gap-2 px-2 py-0.5`,children:[(0,V.jsx)(`span`,{className:`w-3 shrink-0 text-gray-500`,children:`-`}),(0,V.jsx)(`span`,{children:e})]})]},`removed-${e}`)),r.map(e=>(0,V.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[3rem_3rem_minmax(0,1fr)] bg-emerald-950/70 text-emerald-100`,children:[(0,V.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,V.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,V.jsxs)(`div`,{className:`flex gap-2 px-2 py-0.5`,children:[(0,V.jsx)(`span`,{className:`w-3 shrink-0 text-gray-500`,children:`+`}),(0,V.jsx)(`span`,{children:e})]})]},`added-${e}`))]})]})}function tH({preview:e}){let t=CV(e),n=JV(e.before.body,e.after.body),r=e.before.body.trim()!==e.after.body.trim()&&e.after.body.length>0&&!e.after.body.includes(e.before.body.slice(0,40))&&YV(n),i=e.before.title!==e.after.title,a=e.before.triggers.join(`
|
|
234
234
|
`)!==e.after.triggers.join(`
|
|
235
|
-
`);return(0,V.jsxs)(`div`,{className:`min-w-0 space-y-4`,children:[!t&&(0,V.jsxs)(`div`,{className:`rounded-md border border-amber-500/50 bg-amber-500/10 p-3 text-sm text-amber-100`,children:[`No change detected — ops did not alter the playbook body or triggers. Reject this proposal and re-propose with a matching list anchor or `,(0,V.jsx)(`code`,{children:`rewrite_body`}),`.`]}),r&&(0,V.jsx)(`div`,{className:`rounded-md border border-amber-500/50 bg-amber-500/10 p-3 text-sm text-amber-100`,children:`Full-body rewrite proposed — review carefully.`}),i&&(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(`h4`,{className:`text-sm font-medium text-gray-400`,children:`Title`}),(0,V.jsxs)(`div`,{className:`${WV} p-0`,children:[e.before.title&&(0,V.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[3rem_3rem_minmax(0,1fr)] bg-rose-950/70 text-rose-100`,children:[(0,V.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,V.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,V.jsxs)(`div`,{className:`flex gap-2 px-2 py-0.5`,children:[(0,V.jsx)(`span`,{className:`w-3 shrink-0 text-gray-500`,children:`-`}),(0,V.jsx)(`span`,{children:e.before.title})]})]}),e.after.title&&(0,V.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[3rem_3rem_minmax(0,1fr)] bg-emerald-950/70 text-emerald-100`,children:[(0,V.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,V.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,V.jsxs)(`div`,{className:`flex gap-2 px-2 py-0.5`,children:[(0,V.jsx)(`span`,{className:`w-3 shrink-0 text-gray-500`,children:`+`}),(0,V.jsx)(`span`,{children:e.after.title})]})]})]})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(`h4`,{className:`text-sm font-medium text-gray-400`,children:`Body`}),(0,V.jsx)(qV,{rows:n,emptyLabel:`No body changes.`})]}),a&&(0,V.jsx)(JV,{before:e.before.triggers,after:e.after.triggers})]})}function XV(e){if(!e)return[];try{return JSON.parse(e)}catch{return[]}}function ZV({conflicts:e,title:t=`Trigger overlap warnings`}){return e.length===0?null:(0,V.jsxs)(`div`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 p-4 text-sm text-amber-50`,children:[(0,V.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-amber-200/90`,children:t}),(0,V.jsx)(`p`,{className:`mt-2 text-amber-100/90`,children:`These triggers overlap with other playbooks on the deck. Accept is still allowed — disambiguate triggers or propose a merge if the wrong playbook keeps firing.`}),(0,V.jsx)(`ul`,{className:`mt-3 space-y-2`,children:e.map(e=>(0,V.jsxs)(`li`,{className:`rounded border border-amber-500/20 bg-gray-950/60 p-3`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(fh,{variant:`outline`,className:`border-amber-400/40 text-amber-100`,children:e.level}),(0,V.jsx)(`span`,{className:`font-medium text-amber-50`,children:e.otherPlaybookTitle}),(0,V.jsx)(`span`,{className:`font-mono text-xs text-amber-200/70`,children:e.otherPlaybookId})]}),(0,V.jsxs)(`p`,{className:`mt-2 text-amber-100/90`,children:[(0,V.jsx)(`span`,{className:`text-amber-200/80`,children:`Candidate:`}),` `,e.trigger]}),(0,V.jsxs)(`p`,{className:`text-amber-100/80`,children:[(0,V.jsx)(`span`,{className:`text-amber-200/80`,children:`Other:`}),` `,e.otherTrigger]})]},`${e.trigger}-${e.otherPlaybookId}-${e.level}`))})]})}var QV=8,$V=[{value:`proposed`,label:`Waiting`},{value:`accepted`,label:`Accepted`},{value:`rejected`,label:`Rejected`},{value:`superseded`,label:`Superseded`},{value:`stale`,label:`Stale`},{value:`all`,label:`All`}];function eH(e){if(!e.evidenceJson)return null;try{return JSON.parse(e.evidenceJson)}catch{return null}}function tH(e){switch(e){case`proposed`:return`border-blue-500/40 text-blue-200`;case`accepted`:return`border-emerald-500/40 text-emerald-200`;case`rejected`:return`border-rose-500/40 text-rose-200`;case`superseded`:return`border-violet-500/40 text-violet-200`;case`stale`:return`border-amber-500/40 text-amber-200`}}function nH(){let[e,t]=(0,b.useState)(null),[n,r]=(0,b.useState)(`proposed`),[i,a]=(0,b.useState)(0),{toast:o}=on(),s=Et();function c(e){t(e)}function l(e){r(e),a(0),t(null)}let{data:u=[]}=Vt({queryKey:[`/api/playbook-patches`,`proposed`],queryFn:()=>Xm(`proposed`)}),d=n===`all`?void 0:n,{data:f=[],isLoading:p}=Vt({queryKey:[`/api/playbook-patches`,n],queryFn:()=>Xm(d)}),m=Math.max(1,Math.ceil(f.length/QV)),h=Math.min(i,m-1),g=(0,b.useMemo)(()=>{let e=h*QV;return f.slice(e,e+QV)},[f,h]);(0,b.useEffect)(()=>{i!==h&&a(h)},[i,h]);let{data:_,isLoading:v,isError:y,error:x}=Vt({queryKey:[`/api/playbook-patches`,e,`preview`],queryFn:()=>Zm(e),enabled:!!e}),S=_?_V(_):!1,C=f.find(t=>t.id===e)??null,w=C?.status===`proposed`,T=Ht({mutationFn:e=>Qm(e),onSuccess:()=>{o({title:`Patch accepted`}),t(null),s.invalidateQueries({queryKey:[`/api/playbook-patches`]}),s.invalidateQueries({queryKey:[`/api/playbooks`]}),s.invalidateQueries({queryKey:[`/api/feedback-signals`]})},onError:e=>{o({title:`Accept failed`,description:e.message,variant:`destructive`})}}),E=Ht({mutationFn:e=>$m(e),onSuccess:()=>{o({title:`Patch rejected`}),t(null),s.invalidateQueries({queryKey:[`/api/playbook-patches`]}),s.invalidateQueries({queryKey:[`/api/feedback-signals`]})},onError:e=>{o({title:`Reject failed`,description:e.message,variant:`destructive`})}}),D=n===`proposed`?`No proposals waiting for review.`:n===`all`?`No playbook patches yet.`:`No ${n} patches.`;return(0,V.jsxs)(`div`,{className:`flex h-dvh flex-col overflow-hidden bg-gray-950 text-gray-100`,children:[(0,V.jsx)(`header`,{className:`shrink-0 border-b border-gray-800 px-4 py-4 sm:px-6`,children:(0,V.jsxs)(`div`,{className:`mx-auto flex max-w-7xl flex-wrap items-center gap-3`,children:[(0,V.jsx)(ye,{href:`/`,children:(0,V.jsxs)(G,{variant:`ghost`,size:`sm`,className:`text-gray-300`,children:[(0,V.jsx)(ui,{className:`mr-1 h-4 w-4`}),(0,V.jsx)(`span`,{className:`font-ui-display`,children:`Deck`})]})}),(0,V.jsx)(`h1`,{className:`font-ui-display text-lg font-semibold`,children:`Playbook review queue`}),(0,V.jsxs)(fh,{variant:`secondary`,children:[u.length,` waiting`]}),(0,V.jsx)(ye,{href:`/feedback-signals`,className:`ml-auto text-sm hover:underline`,style:{color:`#92E4DD`},children:`Feedback data →`})]})}),(0,V.jsxs)(`main`,{className:`mx-auto grid w-full max-w-7xl min-h-0 flex-1 gap-6 overflow-hidden px-4 py-6 sm:px-6 lg:grid-cols-[minmax(18rem,20rem)_minmax(0,1fr)] lg:items-stretch`,children:[(0,V.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-col`,children:[(0,V.jsx)(`h2`,{className:`font-ui-display mb-3 shrink-0 text-sm font-medium text-gray-400`,children:`Proposals`}),(0,V.jsx)(`div`,{className:`mb-3 flex shrink-0 flex-wrap gap-1`,children:$V.map(({value:e,label:t})=>{let r=n===e;return(0,V.jsx)(G,{size:`sm`,variant:r?`gold`:`outline`,className:r?void 0:`border-gray-600 bg-transparent text-gray-300 hover:bg-gray-800 hover:text-gray-100`,"aria-pressed":r,onClick:()=>l(e),children:t},e)})}),(0,V.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[p&&(0,V.jsx)(`p`,{className:`text-sm text-gray-500`,children:`Loading…`}),!p&&f.length===0&&(0,V.jsx)(`p`,{className:`text-sm text-gray-500`,children:D}),(0,V.jsx)(`ul`,{className:`space-y-2`,children:g.map(t=>(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,onClick:()=>c(t.id),className:`w-full rounded-lg border p-3 text-left transition ${e===t.id?`border-blue-500 bg-gray-900`:`border-gray-800 bg-gray-900/50 hover:border-gray-700`}`,children:[(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`span`,{className:`block font-medium leading-snug`,children:t.kind===`create`?`New: ${t.displayTitle}`:t.displayTitle}),t.playbookId&&t.kind!==`create`&&(0,V.jsx)(`span`,{className:`mt-0.5 block truncate font-mono text-xs text-gray-600`,children:t.playbookId}),Ym(t.deckNames)&&(0,V.jsxs)(`span`,{className:`mt-1 block text-xs text-gray-500`,children:[`Decks: `,Ym(t.deckNames)]})]}),(0,V.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1`,children:[(0,V.jsx)(fh,{variant:`outline`,className:`shrink-0`,children:t.kind}),n!==`proposed`&&(0,V.jsx)(fh,{variant:`outline`,className:`shrink-0 ${tH(t.status)}`,children:t.status})]})]}),(0,V.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-gray-400`,children:t.rationale}),(0,V.jsxs)(`p`,{className:`mt-1 text-xs text-gray-600`,children:[t.source,` · `,new Date(t.createdAt).toLocaleString()]})]})},t.id))})]}),f.length>QV&&(0,V.jsxs)(`div`,{className:`mt-3 flex shrink-0 items-center justify-between gap-2 border-t border-gray-800 pt-3`,children:[(0,V.jsxs)(G,{type:`button`,size:`sm`,variant:`outline`,className:`border-gray-600 bg-transparent text-gray-300 hover:bg-gray-800`,disabled:h<=0,onClick:()=>a(e=>Math.max(0,e-1)),children:[(0,V.jsx)(_i,{className:`mr-1 h-4 w-4`}),`Newer`]}),(0,V.jsxs)(`span`,{className:`text-xs text-gray-500`,children:[h+1,` / `,m,(0,V.jsxs)(`span`,{className:`ml-1 text-gray-600`,children:[`(`,f.length,`)`]})]}),(0,V.jsxs)(G,{type:`button`,size:`sm`,variant:`outline`,className:`border-gray-600 bg-transparent text-gray-300 hover:bg-gray-800`,disabled:h>=m-1,onClick:()=>a(e=>Math.min(m-1,e+1)),children:[`Older`,(0,V.jsx)(vi,{className:`ml-1 h-4 w-4`})]})]})]}),(0,V.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-col overflow-hidden`,children:[(0,V.jsx)(`h2`,{className:`font-ui-display mb-3 shrink-0 text-sm font-medium text-gray-400`,children:`Detail`}),!C&&(0,V.jsx)(`p`,{className:`text-sm text-gray-500`,children:`Select a proposal to preview the diff.`}),C&&(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-lg border border-gray-800 bg-gray-900/50`,children:[(0,V.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4 sm:p-5`,children:(0,V.jsxs)(`div`,{className:`min-w-0 space-y-4`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(fh,{variant:`outline`,className:tH(C.status),children:C.status}),C.resolvedAt&&(0,V.jsxs)(`span`,{className:`text-xs text-gray-500`,children:[`Resolved `,new Date(C.resolvedAt).toLocaleString()]})]}),(0,V.jsx)(`p`,{className:`text-sm leading-relaxed text-gray-300`,children:C.rationale}),C.status===`rejected`&&C.rejectionReason&&(0,V.jsxs)(`div`,{className:`rounded-md border border-rose-500/40 bg-rose-500/10 p-3 text-sm text-rose-100`,children:[(0,V.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-rose-300/80`,children:`Rejection reason`}),(0,V.jsx)(`p`,{className:`mt-1`,children:C.rejectionReason})]}),C.status===`superseded`&&C.supersededBy&&(0,V.jsxs)(`div`,{className:`rounded-md border border-violet-500/40 bg-violet-500/10 p-3 text-sm text-violet-100`,children:[(0,V.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-violet-300/80`,children:`Superseded by`}),(0,V.jsx)(`button`,{type:`button`,className:`mt-1 font-mono text-sm underline-offset-2 hover:underline`,onClick:()=>{let e=C.supersededBy;r(`all`),a(0),c(e)},children:C.supersededBy})]}),(()=>{let e=eH(C);return e?(0,V.jsxs)(`div`,{className:`rounded-md border border-gray-700 bg-gray-950 p-4 text-sm`,children:[(0,V.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-gray-500`,children:`Your correction`}),(0,V.jsxs)(`p`,{className:`mt-2 italic text-gray-200`,children:[`“`,e.user_feedback_excerpt,`”`]}),e.failure_summary&&(0,V.jsx)(`p`,{className:`mt-2 text-gray-400`,children:e.failure_summary})]}):null})(),(()=>{let e=XV(C.conflictsJson),t=_?.trigger_conflicts??[],n=t.length>0?t:e;return(0,V.jsx)(ZV,{conflicts:n})})(),v&&(0,V.jsx)(`p`,{className:`text-sm text-gray-500`,children:`Loading preview…`}),y&&(0,V.jsxs)(`div`,{className:`rounded-md border border-rose-500/50 bg-rose-500/10 p-3 text-sm text-rose-100`,children:[`Preview failed —`,` `,x?.message??`could not apply ops to the current playbook.`,w?` Reject and re-propose with exact list anchors or rewrite_body.`:` Historical preview may be incomplete if the playbook changed.`]}),_&&(0,V.jsx)(YV,{preview:_}),C.status===`stale`&&(0,V.jsx)(`p`,{className:`text-sm text-amber-400`,children:`Stale — playbook changed since proposal. Re-propose from a fresh session.`})]})}),w?(0,V.jsxs)(`div`,{className:`relative z-10 shrink-0 space-y-3 border-t border-gray-800 bg-gray-950 p-4 shadow-[0_-16px_32px_rgba(0,0,0,0.55)] sm:p-5`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium text-gray-400`,children:`Your decision`}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,V.jsx)(G,{variant:`gold`,onClick:()=>T.mutate(C.id),disabled:T.isPending||y||!S,children:`Accept`}),(0,V.jsx)(G,{variant:`destructive`,onClick:()=>E.mutate(C.id),disabled:E.isPending,children:`Reject`})]})]}):(0,V.jsxs)(`div`,{className:`shrink-0 border-t border-gray-800 bg-gray-950 px-4 py-3 text-sm text-gray-500 sm:px-5`,children:[`Read-only — already `,C.status,`. Switch to Waiting to review open proposals.`]})]})]})]})]})}var rH=`border-[#C4B643] data-[state=checked]:bg-[#C4B643] data-[state=checked]:text-[#0A0A07] data-[state=indeterminate]:bg-[#C4B643] data-[state=indeterminate]:text-[#0A0A07]`;function iH(){let{toast:e}=on(),t=Et(),[n,r]=(0,b.useState)(`open`),[i,a]=(0,b.useState)(``),[o,s]=(0,b.useState)(!1),[c,l]=(0,b.useState)(new Set),{data:u}=Vt({queryKey:[`/api/playbooks/vault`]}),d=u?.data??[],f=(0,b.useMemo)(()=>{let e=new Map;for(let t of d)e.set(t.id,t.title);return e},[d]),p={status:n===`all`?void 0:n,playbookId:i||void 0,excludeInProposal:n===`open`?!o:void 0},{data:m=[],isLoading:h}=Vt({queryKey:[`/api/feedback-signals`,p],queryFn:()=>rh(p)}),g=Ht({mutationFn:e=>ih(e),onSuccess:n=>{e({title:`Discarded ${n.discarded} signal(s)`}),l(new Set),t.invalidateQueries({queryKey:[`/api/feedback-signals`]})},onError:t=>{e({title:`Discard failed`,description:t.message,variant:`destructive`})}}),_=e=>{l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},v=async()=>{let t=c.size>0?m.filter(e=>c.has(e.id)):m;if(t.length!==0){if(t.some(e=>!e.id)){e({title:`Copy blocked`,description:`Every signal must include an id for tracking.`,variant:`destructive`});return}try{await navigator.clipboard.writeText(ch(t)),e({title:`Copied curation prompt`,description:`${t.length} signal id(s) included — paste into your IDE agent.`})}catch(t){e({title:`Copy failed`,description:t instanceof Error?t.message:`Clipboard unavailable`,variant:`destructive`})}}},y=[...c].filter(e=>m.find(t=>t.id===e)?.status===`open`),x=m.length>0&&m.every(e=>c.has(e.id)),S=m.some(e=>c.has(e.id));return(0,V.jsxs)(`div`,{className:`flex min-h-dvh flex-col bg-gray-950 text-gray-100`,children:[(0,V.jsx)(`header`,{className:`shrink-0 border-b border-gray-800 px-4 py-4 sm:px-6`,children:(0,V.jsxs)(`div`,{className:`mx-auto flex max-w-7xl flex-wrap items-center gap-3`,children:[(0,V.jsx)(ye,{href:`/`,children:(0,V.jsxs)(G,{variant:`ghost`,size:`sm`,className:`text-gray-300`,children:[(0,V.jsx)(ui,{className:`mr-1 h-4 w-4`}),`Home`]})}),(0,V.jsx)(`h1`,{className:`font-ui-display text-lg font-semibold`,children:`Feedback`}),(0,V.jsx)(fh,{variant:`outline`,children:m.length}),(0,V.jsx)(ye,{href:`/playbook-patches`,className:`ml-auto text-sm hover:underline`,style:{color:`#92E4DD`},children:`Playbook proposals →`})]})}),(0,V.jsxs)(`main`,{className:`mx-auto w-full max-w-7xl flex-1 space-y-4 px-4 py-6 sm:px-6`,children:[(0,V.jsx)(`p`,{className:`text-sm text-gray-400`,children:`Durable correction data for playbook enhancement. Filter by playbook, copy rows (with ids) for an IDE agent to propose, then accept the proposal to mark feedback solved.`}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3 rounded-lg border border-gray-800 bg-gray-900/40 p-3`,children:[(0,V.jsxs)(`label`,{className:`text-xs text-gray-500`,children:[(0,V.jsx)(`span`,{className:`font-ui-display`,children:`Playbook`}),(0,V.jsxs)(`select`,{className:`mt-1 block min-w-[12rem] rounded border border-gray-700 bg-gray-950 px-2 py-1.5 text-sm text-gray-100`,value:i,onChange:e=>{a(e.target.value),l(new Set)},children:[(0,V.jsx)(`option`,{value:``,children:`All`}),d.map(e=>(0,V.jsx)(`option`,{value:e.id,children:e.title},e.id))]})]}),(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:[[`open`,`Open`],[`actioned`,`Actioned`],[`discarded`,`Discarded`],[`all`,`All`]].map(([e,t])=>{let i=n===e;return(0,V.jsx)(G,{size:`sm`,variant:i?`gold`:`outline`,className:i?void 0:`border-gray-600 bg-transparent text-gray-300 hover:bg-gray-800 hover:text-gray-100`,"aria-pressed":i,onClick:()=>{r(e),l(new Set)},children:t},e)})}),n===`open`&&(0,V.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-gray-400`,children:[(0,V.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`Include already in an open proposal`]}),(0,V.jsxs)(`div`,{className:`ml-auto flex flex-wrap gap-2`,children:[(0,V.jsxs)(G,{size:`sm`,variant:`outline`,disabled:m.length===0,onClick:()=>void v(),children:[(0,V.jsx)(wi,{className:`mr-1 h-3.5 w-3.5`}),(0,V.jsx)(`span`,{className:`font-ui-display`,children:`Copy for agent`}),c.size>0?` (${c.size})`:``]}),(0,V.jsxs)(G,{size:`sm`,variant:`destructive`,disabled:y.length===0||g.isPending,onClick:()=>g.mutate(y),children:[(0,V.jsx)(Hi,{className:`mr-1 h-3.5 w-3.5`}),`Discard selected`]})]})]}),h&&(0,V.jsx)(`p`,{className:`text-sm text-gray-500`,children:`Loading…`}),!h&&m.length===0&&(0,V.jsx)(`p`,{className:`text-sm text-gray-500`,children:`No signals match these filters.`}),!h&&m.length>0&&(0,V.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-gray-800`,children:(0,V.jsxs)(`table`,{className:`w-full min-w-[48rem] text-left text-sm`,children:[(0,V.jsx)(`thead`,{className:`border-b border-gray-800 bg-gray-900/80 text-xs uppercase text-gray-500`,children:(0,V.jsxs)(`tr`,{children:[(0,V.jsx)(`th`,{className:`w-10 px-3 py-2`,children:(0,V.jsx)(cg,{checked:x?!0:S?`indeterminate`:!1,onCheckedChange:()=>{if(x){l(new Set);return}l(new Set(m.map(e=>e.id)))},"aria-label":`Select all visible signals`,disabled:m.length===0,className:rH})}),(0,V.jsx)(`th`,{className:`px-3 py-2`,children:`Excerpt`}),(0,V.jsx)(`th`,{className:`px-3 py-2`,children:`Failure`}),(0,V.jsx)(`th`,{className:`px-3 py-2`,children:`Playbook`}),(0,V.jsx)(`th`,{className:`px-3 py-2`,children:`Source`}),(0,V.jsx)(`th`,{className:`px-3 py-2`,children:`When`})]})}),(0,V.jsx)(`tbody`,{children:m.map(e=>{let t=ah(e);return(0,V.jsxs)(`tr`,{className:`border-b border-gray-800/80 align-top`,children:[(0,V.jsx)(`td`,{className:`px-3 py-2`,children:(0,V.jsx)(cg,{checked:c.has(e.id),onCheckedChange:()=>_(e.id),"aria-label":`Select ${e.id}`,className:rH})}),(0,V.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,V.jsx)(`p`,{className:`font-mono text-[11px] text-gray-600`,children:e.id}),(0,V.jsxs)(`p`,{className:`text-gray-200`,children:[`“`,e.userFeedbackExcerpt,`”`]}),t&&(0,V.jsx)(fh,{variant:`outline`,className:`mt-1 text-[10px]`,children:`In proposal`})]}),(0,V.jsx)(`td`,{className:`px-3 py-2 text-gray-400`,children:e.failureSummary}),(0,V.jsx)(`td`,{className:`px-3 py-2 text-gray-300`,children:e.candidatePlaybookId?f.get(e.candidatePlaybookId)??e.candidatePlaybookId:`—`}),(0,V.jsx)(`td`,{className:`px-3 py-2 text-gray-500`,children:e.source}),(0,V.jsx)(`td`,{className:`px-3 py-2 whitespace-nowrap text-gray-500`,children:new Date(e.createdAt).toLocaleString()})]},e.id)})})]})})]})]})}function aH(e){return e instanceof Ut?e.errorCode===`GRANT_REQUIRED`||e.errorCode===`DASHBOARD_REQUIRED`?{message:`This browser is not signed in to the Agent Deck dashboard. Run agent-deck open, then open this approval link again.`,retryable:!0}:e.errorCode===`ADMIN_CHALLENGE_EXPIRED`?{message:`This approval request expired or was already used. Ask the agent to request admin elevation again.`,retryable:!1}:e.errorCode===`SESSION_INVALID`?{message:`The agent session for this request is gone. Ask the agent to reconnect and request admin elevation again.`,retryable:!1}:{message:e.message||`Approval failed`,retryable:!0}:e instanceof TypeError?{message:`Could not reach Agent Deck. Check that it is running (agent-deck status) and try again.`,retryable:!0}:{message:e instanceof Error&&e.message?e.message:`Approval failed`,retryable:!0}}function oH(){let e=new URLSearchParams(window.location.search),t=e.get(`challenge`)??``,n=e.get(`session`)??``,[r,i]=(0,b.useState)(`idle`),[a,o]=(0,b.useState)(``),[s,c]=(0,b.useState)(!0);(0,b.useEffect)(()=>{(!t||!n)&&(i(`error`),c(!1),o(`This link is incomplete. Ask the agent to request admin elevation again.`))},[t,n]);async function l(){if(t&&n){i(`loading`);try{await H(`POST`,`/api/trusted-session/admin/approve`,{challengeId:t,runtimeSessionId:n}),i(`success`),o(`Admin elevation approved for this MCP session. Return to the agent.`)}catch(e){let t=aH(e);i(`error`),c(t.retryable),o(t.message)}}}return(0,V.jsx)(`div`,{className:`min-h-screen flex items-center justify-center p-6 bg-muted/30`,children:(0,V.jsxs)(bO,{className:`w-full max-w-md`,children:[(0,V.jsxs)(xO,{children:[(0,V.jsx)(SO,{children:`Approve agent-admin elevation`}),(0,V.jsx)(CO,{children:`Grants ephemeral deck-admin mode to one MCP session (30-minute lease). This does not change the folder's deck assignment.`})]}),(0,V.jsxs)(wO,{className:`space-y-4`,children:[t&&n?(0,V.jsxs)(`dl`,{className:`text-sm space-y-1 text-muted-foreground`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`inline font-medium text-foreground`,children:`Session `}),(0,V.jsx)(`dd`,{className:`inline font-mono text-xs`,children:n})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`inline font-medium text-foreground`,children:`Challenge `}),(0,V.jsx)(`dd`,{className:`inline font-mono text-xs`,children:t})]})]}):null,r===`success`?(0,V.jsx)(`p`,{role:`status`,className:`text-sm text-green-700 dark:text-green-400`,children:a}):r===`error`?(0,V.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:a}):null,r!==`success`&&t&&n&&(r!==`error`||s)?(0,V.jsx)(G,{onClick:()=>void l(),disabled:r===`loading`,className:`w-full`,children:r===`loading`?`Approving…`:`Approve elevation`}):null]})]})})}function sH(e){return e instanceof Ut?e.errorCode===`GRANT_REQUIRED`||e.errorCode===`DASHBOARD_REQUIRED`?{message:`This browser is not signed in to the Agent Deck dashboard. Run agent-deck open, then open this approval link again.`,retryable:!0}:e.errorCode===`DECK_SWITCH_EXPIRED`||e.status===410?{message:`This deck-switch request expired. The session and workspace default were not changed. Ask the agent to request the switch again.`,retryable:!1}:e.errorCode===`DECK_SWITCH_CONSUMED`||e.status===409?{message:`This deck-switch request was already resolved. The switch was not applied twice — check the current deck before requesting again.`,retryable:!1}:e.errorCode===`RESOURCE_OUT_OF_SCOPE`?{message:`This approval link does not match the requesting session. Only the matching session's request can be approved here — ask the agent for a fresh link if needed.`,retryable:!1}:e.errorCode===`SESSION_INVALID`?{message:`The agent session for this request is gone. Ask the agent to reconnect and request the deck switch again.`,retryable:!1}:e.status===404?{message:`This deck-switch request was not found. It may have been cleaned up. Ask the agent to request the switch again.`,retryable:!1}:{message:e.message||`Approval failed`,retryable:!0}:e instanceof TypeError?{message:`Could not reach Agent Deck. Check that it is running (agent-deck status) and try again.`,retryable:!0}:{message:e instanceof Error&&e.message?e.message:`Approval failed`,retryable:!0}}function cH(){let e=new URLSearchParams(window.location.search);return{requestId:(e.get(`request`)??e.get(`requestId`)??``).trim(),runtimeSessionId:(e.get(`session`)??e.get(`runtimeSessionId`)??``).trim()}}function lH(e){return e===`expired`?`This deck-switch request expired. The session and workspace default were not changed. Ask the agent to request the switch again.`:e===`declined`?`This deck-switch request was already declined. Nothing was changed.`:`This deck-switch request was already resolved. The switch was not applied twice — check the current deck before requesting again.`}function uH(e){let t=e.deckName?` “${e.deckName}”`:``;return e.decision===`session`?`Approved for this session only. This session now uses${t}. The workspace default was not changed.`:e.decision===`workspace-default`?`Approved. Future sessions${e.workspaceRoot?` in ${e.workspaceRoot}`:``} will use${t} as the new default. This session was switched too.`:`Declined. Nothing was changed — the session and workspace default are untouched.`}function dH(){let[{requestId:e,runtimeSessionId:t}]=(0,b.useState)(cH),[n,r]=(0,b.useState)(`loading`),[i,a]=(0,b.useState)(null),[o,s]=(0,b.useState)(``),[c,l]=(0,b.useState)(!0),[u,d]=(0,b.useState)(null),f=(0,b.useRef)(!1),p=(0,b.useCallback)(async()=>{if(!e){r(`error`),l(!1),s(`This link is incomplete. Ask the agent to request the deck switch again.`);return}r(`loading`),s(``);try{let t=(await(await H(`GET`,`/api/trusted-session/deck-switch/${e}`)).json()).data;if(!t||t.requestId!==e)throw Error(`Approval lookup returned an unexpected response`);a(t),t.status===`pending`?r(`pending`):(r(`error`),l(!1),s(lH(t.status)))}catch(e){let t=sH(e);r(`error`),l(t.retryable),s(t.message)}},[e]);(0,b.useEffect)(()=>{p()},[p]);async function m(n){if(f.current)return;let a=t||i?.runtimeSessionId||``;if(!e||!a){r(`error`),l(!1),s(`This link is incomplete. Ask the agent to request the deck switch again.`);return}f.current=!0,d(n),r(`submitting`);try{let t=await(await H(`POST`,`/api/trusted-session/deck-switch/${e}/resolve`,{runtimeSessionId:a,decision:n})).json(),o={decision:n,deckName:t.data?.deckName??i?.requestedDeckName,workspaceRoot:t.data?.workspaceRoot??i?.workspaceRoot};s(uH(o)),r(`success`)}catch(e){let t=sH(e);l(t.retryable),s(t.message),t.retryable&&i?r(`pending`):r(`error`)}finally{f.current=!1,d(null)}}function h(){s(``),i&&c?r(`pending`):p()}let g=n===`loading`||n===`submitting`,_=i?.currentDeckName??i?.currentDeckId,v=i?.requestedDeckName??i?.requestedDeckId,y=t||i?.runtimeSessionId;return(0,V.jsx)(`div`,{className:`min-h-screen flex items-center justify-center p-6 bg-muted/30`,children:(0,V.jsxs)(bO,{className:`w-full max-w-md`,children:[(0,V.jsxs)(xO,{children:[(0,V.jsx)(SO,{children:`Approve deck switch`}),(0,V.jsx)(CO,{children:`Choose whether the requested deck applies to this session only or becomes the workspace default. Declining leaves everything unchanged.`})]}),(0,V.jsxs)(wO,{className:`space-y-4`,children:[i&&(_||v)?(0,V.jsxs)(`dl`,{className:`text-sm space-y-1 text-muted-foreground`,children:[_?(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`inline font-medium text-foreground`,children:`Current deck `}),(0,V.jsx)(`dd`,{className:`inline`,children:_})]}):null,v?(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`inline font-medium text-foreground`,children:`Requested deck `}),(0,V.jsx)(`dd`,{className:`inline`,children:v})]}):null,i.workspaceRoot?(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`inline font-medium text-foreground`,children:`Workspace `}),(0,V.jsx)(`dd`,{className:`inline font-mono text-xs`,children:i.workspaceRoot})]}):null,y?(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`inline font-medium text-foreground`,children:`Session `}),(0,V.jsx)(`dd`,{className:`inline font-mono text-xs`,children:y})]}):null]}):e?(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Request `,(0,V.jsx)(`span`,{className:`font-mono text-xs`,children:e})]}):null,n===`loading`?(0,V.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Loading the deck-switch request…`}):null,n===`success`?(0,V.jsx)(`p`,{role:`status`,className:`text-sm text-green-700 dark:text-green-400`,children:o}):null,(n===`error`||n===`pending`)&&o?(0,V.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:o}):null,(n===`pending`||n===`submitting`)&&i?(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(G,{onClick:()=>void m(`session`),disabled:g,className:`w-full`,children:u===`session`?`Approving…`:`This session only`}),(0,V.jsx)(G,{onClick:()=>void m(`workspace-default`),disabled:g,variant:`secondary`,className:`w-full`,children:u===`workspace-default`?`Approving…`:`This workspace by default`}),(0,V.jsx)(G,{onClick:()=>void m(`decline`),disabled:g,variant:`outline`,className:`w-full`,children:u===`decline`?`Declining…`:`Decline`})]}):null,n===`error`?c?(0,V.jsx)(G,{onClick:h,variant:`outline`,className:`w-full`,children:`Try again`}):(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No further action is possible on this link. You can close this tab.`}):null,n===`success`?(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`You can close this tab and return to the agent.`}):null]})]})})}function fH(){return(0,V.jsxs)(xe,{children:[(0,V.jsx)(ve,{path:`/`,component:yO}),(0,V.jsx)(ve,{path:`/oauth/callback`,component:DO}),(0,V.jsx)(ve,{path:`/playbook-patches`,component:nH}),(0,V.jsx)(ve,{path:`/feedback-signals`,component:iH}),(0,V.jsx)(ve,{path:`/admin/approve`,component:oH}),(0,V.jsx)(ve,{path:`/deck-switch/approve`,component:dH}),(0,V.jsx)(ve,{path:`/mcp-test`,component:gV}),(0,V.jsx)(ve,{component:EO})]})}function pH(){let[e,t]=(0,b.useState)(!1);return(0,b.useEffect)(()=>{let e=!1;return qt().finally(()=>{e||t(!0)}),()=>{e=!0}},[]),e?(0,V.jsx)(Dt,{client:Kt,children:(0,V.jsxs)(Tl,{children:[(0,V.jsx)(Qa,{}),(0,V.jsx)(fH,{})]})}):(0,V.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-[#0B1220] text-sm text-gray-300`,children:`Loading AgentDeck...`})}(0,x.createRoot)(document.getElementById(`root`)).render((0,V.jsx)(b.StrictMode,{children:(0,V.jsx)(pH,{})}));
|
|
235
|
+
`);return(0,V.jsxs)(`div`,{className:`min-w-0 space-y-4`,children:[!t&&(0,V.jsxs)(`div`,{className:`rounded-md border border-amber-500/50 bg-amber-500/10 p-3 text-sm text-amber-100`,children:[`No change detected — ops did not alter the playbook body or triggers. Reject this proposal and re-propose with a matching list anchor or `,(0,V.jsx)(`code`,{children:`rewrite_body`}),`.`]}),r&&(0,V.jsx)(`div`,{className:`rounded-md border border-amber-500/50 bg-amber-500/10 p-3 text-sm text-amber-100`,children:`Full-body rewrite proposed — review carefully.`}),i&&(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(`h4`,{className:`text-sm font-medium text-gray-400`,children:`Title`}),(0,V.jsxs)(`div`,{className:`${XV} p-0`,children:[e.before.title&&(0,V.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[3rem_3rem_minmax(0,1fr)] bg-rose-950/70 text-rose-100`,children:[(0,V.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,V.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,V.jsxs)(`div`,{className:`flex gap-2 px-2 py-0.5`,children:[(0,V.jsx)(`span`,{className:`w-3 shrink-0 text-gray-500`,children:`-`}),(0,V.jsx)(`span`,{children:e.before.title})]})]}),e.after.title&&(0,V.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[3rem_3rem_minmax(0,1fr)] bg-emerald-950/70 text-emerald-100`,children:[(0,V.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,V.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,V.jsxs)(`div`,{className:`flex gap-2 px-2 py-0.5`,children:[(0,V.jsx)(`span`,{className:`w-3 shrink-0 text-gray-500`,children:`+`}),(0,V.jsx)(`span`,{children:e.after.title})]})]})]})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(`h4`,{className:`text-sm font-medium text-gray-400`,children:`Body`}),(0,V.jsx)($V,{rows:n,emptyLabel:`No body changes.`})]}),a&&(0,V.jsx)(eH,{before:e.before.triggers,after:e.after.triggers})]})}function nH(e){if(!e)return[];try{return JSON.parse(e)}catch{return[]}}function rH({conflicts:e,title:t=`Trigger overlap warnings`}){return e.length===0?null:(0,V.jsxs)(`div`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 p-4 text-sm text-amber-50`,children:[(0,V.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-amber-200/90`,children:t}),(0,V.jsx)(`p`,{className:`mt-2 text-amber-100/90`,children:`These triggers overlap with other playbooks on the deck. Accept is still allowed — disambiguate triggers or propose a merge if the wrong playbook keeps firing.`}),(0,V.jsx)(`ul`,{className:`mt-3 space-y-2`,children:e.map(e=>(0,V.jsxs)(`li`,{className:`rounded border border-amber-500/20 bg-gray-950/60 p-3`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(fh,{variant:`outline`,className:`border-amber-400/40 text-amber-100`,children:e.level}),(0,V.jsx)(`span`,{className:`font-medium text-amber-50`,children:e.otherPlaybookTitle}),(0,V.jsx)(`span`,{className:`font-mono text-xs text-amber-200/70`,children:e.otherPlaybookId})]}),(0,V.jsxs)(`p`,{className:`mt-2 text-amber-100/90`,children:[(0,V.jsx)(`span`,{className:`text-amber-200/80`,children:`Candidate:`}),` `,e.trigger]}),(0,V.jsxs)(`p`,{className:`text-amber-100/80`,children:[(0,V.jsx)(`span`,{className:`text-amber-200/80`,children:`Other:`}),` `,e.otherTrigger]})]},`${e.trigger}-${e.otherPlaybookId}-${e.level}`))})]})}var iH=8,aH=[{value:`proposed`,label:`Waiting`},{value:`accepted`,label:`Accepted`},{value:`rejected`,label:`Rejected`},{value:`superseded`,label:`Superseded`},{value:`stale`,label:`Stale`},{value:`all`,label:`All`}];function oH(e){if(!e.evidenceJson)return null;try{return JSON.parse(e.evidenceJson)}catch{return null}}function sH(e){switch(e){case`proposed`:return`border-blue-500/40 text-blue-200`;case`accepted`:return`border-emerald-500/40 text-emerald-200`;case`rejected`:return`border-rose-500/40 text-rose-200`;case`superseded`:return`border-violet-500/40 text-violet-200`;case`stale`:return`border-amber-500/40 text-amber-200`}}function cH(){let[e,t]=(0,b.useState)(null),[n,r]=(0,b.useState)(`proposed`),[i,a]=(0,b.useState)(0),{toast:o}=on(),s=Et();function c(e){t(e)}function l(e){r(e),a(0),t(null)}let{data:u=[]}=Vt({queryKey:[`/api/playbook-patches`,`proposed`],queryFn:()=>Xm(`proposed`)}),d=n===`all`?void 0:n,{data:f=[],isLoading:p}=Vt({queryKey:[`/api/playbook-patches`,n],queryFn:()=>Xm(d)}),m=Math.max(1,Math.ceil(f.length/iH)),h=Math.min(i,m-1),g=(0,b.useMemo)(()=>{let e=h*iH;return f.slice(e,e+iH)},[f,h]);(0,b.useEffect)(()=>{i!==h&&a(h)},[i,h]);let{data:_,isLoading:v,isError:y,error:x}=Vt({queryKey:[`/api/playbook-patches`,e,`preview`],queryFn:()=>Zm(e),enabled:!!e}),S=_?CV(_):!1,C=f.find(t=>t.id===e)??null,w=C?.status===`proposed`,T=Ht({mutationFn:e=>Qm(e),onSuccess:()=>{o({title:`Patch accepted`}),t(null),s.invalidateQueries({queryKey:[`/api/playbook-patches`]}),s.invalidateQueries({queryKey:[`/api/playbooks`]}),s.invalidateQueries({queryKey:[`/api/feedback-signals`]})},onError:e=>{o({title:`Accept failed`,description:e.message,variant:`destructive`})}}),E=Ht({mutationFn:e=>$m(e),onSuccess:()=>{o({title:`Patch rejected`}),t(null),s.invalidateQueries({queryKey:[`/api/playbook-patches`]}),s.invalidateQueries({queryKey:[`/api/feedback-signals`]})},onError:e=>{o({title:`Reject failed`,description:e.message,variant:`destructive`})}}),D=n===`proposed`?`No proposals waiting for review.`:n===`all`?`No playbook patches yet.`:`No ${n} patches.`;return(0,V.jsxs)(`div`,{className:`flex h-dvh flex-col overflow-hidden bg-gray-950 text-gray-100`,children:[(0,V.jsx)(`header`,{className:`shrink-0 border-b border-gray-800 px-4 py-4 sm:px-6`,children:(0,V.jsxs)(`div`,{className:`mx-auto flex max-w-7xl flex-wrap items-center gap-3`,children:[(0,V.jsx)(ye,{href:`/`,children:(0,V.jsxs)(G,{variant:`ghost`,size:`sm`,className:`text-gray-300`,children:[(0,V.jsx)(ui,{className:`mr-1 h-4 w-4`}),(0,V.jsx)(`span`,{className:`font-ui-display`,children:`Deck`})]})}),(0,V.jsx)(`h1`,{className:`font-ui-display text-lg font-semibold`,children:`Playbook review queue`}),(0,V.jsxs)(fh,{variant:`secondary`,children:[u.length,` waiting`]}),(0,V.jsx)(ye,{href:`/feedback-signals`,className:`ml-auto text-sm hover:underline`,style:{color:`#92E4DD`},children:`Feedback data →`})]})}),(0,V.jsxs)(`main`,{className:`mx-auto grid w-full max-w-7xl min-h-0 flex-1 gap-6 overflow-hidden px-4 py-6 sm:px-6 lg:grid-cols-[minmax(18rem,20rem)_minmax(0,1fr)] lg:items-stretch`,children:[(0,V.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-col`,children:[(0,V.jsx)(`h2`,{className:`font-ui-display mb-3 shrink-0 text-sm font-medium text-gray-400`,children:`Proposals`}),(0,V.jsx)(`div`,{className:`mb-3 flex shrink-0 flex-wrap gap-1`,children:aH.map(({value:e,label:t})=>{let r=n===e;return(0,V.jsx)(G,{size:`sm`,variant:r?`gold`:`outline`,className:r?void 0:`border-gray-600 bg-transparent text-gray-300 hover:bg-gray-800 hover:text-gray-100`,"aria-pressed":r,onClick:()=>l(e),children:t},e)})}),(0,V.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[p&&(0,V.jsx)(`p`,{className:`text-sm text-gray-500`,children:`Loading…`}),!p&&f.length===0&&(0,V.jsx)(`p`,{className:`text-sm text-gray-500`,children:D}),(0,V.jsx)(`ul`,{className:`space-y-2`,children:g.map(t=>(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,onClick:()=>c(t.id),className:`w-full rounded-lg border p-3 text-left transition ${e===t.id?`border-blue-500 bg-gray-900`:`border-gray-800 bg-gray-900/50 hover:border-gray-700`}`,children:[(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`span`,{className:`block font-medium leading-snug`,children:t.kind===`create`?`New: ${t.displayTitle}`:t.displayTitle}),t.playbookId&&t.kind!==`create`&&(0,V.jsx)(`span`,{className:`mt-0.5 block truncate font-mono text-xs text-gray-600`,children:t.playbookId}),Ym(t.deckNames)&&(0,V.jsxs)(`span`,{className:`mt-1 block text-xs text-gray-500`,children:[`Decks: `,Ym(t.deckNames)]})]}),(0,V.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1`,children:[(0,V.jsx)(fh,{variant:`outline`,className:`shrink-0`,children:t.kind}),n!==`proposed`&&(0,V.jsx)(fh,{variant:`outline`,className:`shrink-0 ${sH(t.status)}`,children:t.status})]})]}),(0,V.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-gray-400`,children:t.rationale}),(0,V.jsxs)(`p`,{className:`mt-1 text-xs text-gray-600`,children:[t.source,` · `,new Date(t.createdAt).toLocaleString()]})]})},t.id))})]}),f.length>iH&&(0,V.jsxs)(`div`,{className:`mt-3 flex shrink-0 items-center justify-between gap-2 border-t border-gray-800 pt-3`,children:[(0,V.jsxs)(G,{type:`button`,size:`sm`,variant:`outline`,className:`border-gray-600 bg-transparent text-gray-300 hover:bg-gray-800`,disabled:h<=0,onClick:()=>a(e=>Math.max(0,e-1)),children:[(0,V.jsx)(_i,{className:`mr-1 h-4 w-4`}),`Newer`]}),(0,V.jsxs)(`span`,{className:`text-xs text-gray-500`,children:[h+1,` / `,m,(0,V.jsxs)(`span`,{className:`ml-1 text-gray-600`,children:[`(`,f.length,`)`]})]}),(0,V.jsxs)(G,{type:`button`,size:`sm`,variant:`outline`,className:`border-gray-600 bg-transparent text-gray-300 hover:bg-gray-800`,disabled:h>=m-1,onClick:()=>a(e=>Math.min(m-1,e+1)),children:[`Older`,(0,V.jsx)(vi,{className:`ml-1 h-4 w-4`})]})]})]}),(0,V.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-col overflow-hidden`,children:[(0,V.jsx)(`h2`,{className:`font-ui-display mb-3 shrink-0 text-sm font-medium text-gray-400`,children:`Detail`}),!C&&(0,V.jsx)(`p`,{className:`text-sm text-gray-500`,children:`Select a proposal to preview the diff.`}),C&&(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-lg border border-gray-800 bg-gray-900/50`,children:[(0,V.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4 sm:p-5`,children:(0,V.jsxs)(`div`,{className:`min-w-0 space-y-4`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(fh,{variant:`outline`,className:sH(C.status),children:C.status}),C.resolvedAt&&(0,V.jsxs)(`span`,{className:`text-xs text-gray-500`,children:[`Resolved `,new Date(C.resolvedAt).toLocaleString()]})]}),(0,V.jsx)(`p`,{className:`text-sm leading-relaxed text-gray-300`,children:C.rationale}),C.status===`rejected`&&C.rejectionReason&&(0,V.jsxs)(`div`,{className:`rounded-md border border-rose-500/40 bg-rose-500/10 p-3 text-sm text-rose-100`,children:[(0,V.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-rose-300/80`,children:`Rejection reason`}),(0,V.jsx)(`p`,{className:`mt-1`,children:C.rejectionReason})]}),C.status===`superseded`&&C.supersededBy&&(0,V.jsxs)(`div`,{className:`rounded-md border border-violet-500/40 bg-violet-500/10 p-3 text-sm text-violet-100`,children:[(0,V.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-violet-300/80`,children:`Superseded by`}),(0,V.jsx)(`button`,{type:`button`,className:`mt-1 font-mono text-sm underline-offset-2 hover:underline`,onClick:()=>{let e=C.supersededBy;r(`all`),a(0),c(e)},children:C.supersededBy})]}),(()=>{let e=oH(C);return e?(0,V.jsxs)(`div`,{className:`rounded-md border border-gray-700 bg-gray-950 p-4 text-sm`,children:[(0,V.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-gray-500`,children:`Your correction`}),(0,V.jsxs)(`p`,{className:`mt-2 italic text-gray-200`,children:[`“`,e.user_feedback_excerpt,`”`]}),e.failure_summary&&(0,V.jsx)(`p`,{className:`mt-2 text-gray-400`,children:e.failure_summary})]}):null})(),(()=>{let e=nH(C.conflictsJson),t=_?.trigger_conflicts??[],n=t.length>0?t:e;return(0,V.jsx)(rH,{conflicts:n})})(),v&&(0,V.jsx)(`p`,{className:`text-sm text-gray-500`,children:`Loading preview…`}),y&&(0,V.jsxs)(`div`,{className:`rounded-md border border-rose-500/50 bg-rose-500/10 p-3 text-sm text-rose-100`,children:[`Preview failed —`,` `,x?.message??`could not apply ops to the current playbook.`,w?` Reject and re-propose with exact list anchors or rewrite_body.`:` Historical preview may be incomplete if the playbook changed.`]}),_&&(0,V.jsx)(tH,{preview:_}),C.status===`stale`&&(0,V.jsx)(`p`,{className:`text-sm text-amber-400`,children:`Stale — playbook changed since proposal. Re-propose from a fresh session.`})]})}),w?(0,V.jsxs)(`div`,{className:`relative z-10 shrink-0 space-y-3 border-t border-gray-800 bg-gray-950 p-4 shadow-[0_-16px_32px_rgba(0,0,0,0.55)] sm:p-5`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium text-gray-400`,children:`Your decision`}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,V.jsx)(G,{variant:`gold`,onClick:()=>T.mutate(C.id),disabled:T.isPending||y||!S,children:`Accept`}),(0,V.jsx)(G,{variant:`destructive`,onClick:()=>E.mutate(C.id),disabled:E.isPending,children:`Reject`})]})]}):(0,V.jsxs)(`div`,{className:`shrink-0 border-t border-gray-800 bg-gray-950 px-4 py-3 text-sm text-gray-500 sm:px-5`,children:[`Read-only — already `,C.status,`. Switch to Waiting to review open proposals.`]})]})]})]})]})}var lH=`border-[#C4B643] data-[state=checked]:bg-[#C4B643] data-[state=checked]:text-[#0A0A07] data-[state=indeterminate]:bg-[#C4B643] data-[state=indeterminate]:text-[#0A0A07]`;function uH(){let{toast:e}=on(),t=Et(),[n,r]=(0,b.useState)(`open`),[i,a]=(0,b.useState)(``),[o,s]=(0,b.useState)(!1),[c,l]=(0,b.useState)(new Set),{data:u}=Vt({queryKey:[`/api/playbooks/vault`]}),d=u?.data??[],f=(0,b.useMemo)(()=>{let e=new Map;for(let t of d)e.set(t.id,t.title);return e},[d]),p={status:n===`all`?void 0:n,playbookId:i||void 0,excludeInProposal:n===`open`?!o:void 0},{data:m=[],isLoading:h}=Vt({queryKey:[`/api/feedback-signals`,p],queryFn:()=>rh(p)}),g=Ht({mutationFn:e=>ih(e),onSuccess:n=>{e({title:`Discarded ${n.discarded} signal(s)`}),l(new Set),t.invalidateQueries({queryKey:[`/api/feedback-signals`]})},onError:t=>{e({title:`Discard failed`,description:t.message,variant:`destructive`})}}),_=e=>{l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},v=async()=>{let t=c.size>0?m.filter(e=>c.has(e.id)):m;if(t.length!==0){if(t.some(e=>!e.id)){e({title:`Copy blocked`,description:`Every signal must include an id for tracking.`,variant:`destructive`});return}try{await navigator.clipboard.writeText(ch(t)),e({title:`Copied curation prompt`,description:`${t.length} signal id(s) included — paste into your IDE agent.`})}catch(t){e({title:`Copy failed`,description:t instanceof Error?t.message:`Clipboard unavailable`,variant:`destructive`})}}},y=[...c].filter(e=>m.find(t=>t.id===e)?.status===`open`),x=m.length>0&&m.every(e=>c.has(e.id)),S=m.some(e=>c.has(e.id));return(0,V.jsxs)(`div`,{className:`flex min-h-dvh flex-col bg-gray-950 text-gray-100`,children:[(0,V.jsx)(`header`,{className:`shrink-0 border-b border-gray-800 px-4 py-4 sm:px-6`,children:(0,V.jsxs)(`div`,{className:`mx-auto flex max-w-7xl flex-wrap items-center gap-3`,children:[(0,V.jsx)(ye,{href:`/`,children:(0,V.jsxs)(G,{variant:`ghost`,size:`sm`,className:`text-gray-300`,children:[(0,V.jsx)(ui,{className:`mr-1 h-4 w-4`}),`Home`]})}),(0,V.jsx)(`h1`,{className:`font-ui-display text-lg font-semibold`,children:`Feedback`}),(0,V.jsx)(fh,{variant:`outline`,children:m.length}),(0,V.jsx)(ye,{href:`/playbook-patches`,className:`ml-auto text-sm hover:underline`,style:{color:`#92E4DD`},children:`Playbook proposals →`})]})}),(0,V.jsxs)(`main`,{className:`mx-auto w-full max-w-7xl flex-1 space-y-4 px-4 py-6 sm:px-6`,children:[(0,V.jsx)(`p`,{className:`text-sm text-gray-400`,children:`Durable correction data for playbook enhancement. Filter by playbook, copy rows (with ids) for an IDE agent to propose, then accept the proposal to mark feedback solved.`}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3 rounded-lg border border-gray-800 bg-gray-900/40 p-3`,children:[(0,V.jsxs)(`label`,{className:`text-xs text-gray-500`,children:[(0,V.jsx)(`span`,{className:`font-ui-display`,children:`Playbook`}),(0,V.jsxs)(`select`,{className:`mt-1 block min-w-[12rem] rounded border border-gray-700 bg-gray-950 px-2 py-1.5 text-sm text-gray-100`,value:i,onChange:e=>{a(e.target.value),l(new Set)},children:[(0,V.jsx)(`option`,{value:``,children:`All`}),d.map(e=>(0,V.jsx)(`option`,{value:e.id,children:e.title},e.id))]})]}),(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:[[`open`,`Open`],[`actioned`,`Actioned`],[`discarded`,`Discarded`],[`all`,`All`]].map(([e,t])=>{let i=n===e;return(0,V.jsx)(G,{size:`sm`,variant:i?`gold`:`outline`,className:i?void 0:`border-gray-600 bg-transparent text-gray-300 hover:bg-gray-800 hover:text-gray-100`,"aria-pressed":i,onClick:()=>{r(e),l(new Set)},children:t},e)})}),n===`open`&&(0,V.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-gray-400`,children:[(0,V.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`Include already in an open proposal`]}),(0,V.jsxs)(`div`,{className:`ml-auto flex flex-wrap gap-2`,children:[(0,V.jsxs)(G,{size:`sm`,variant:`outline`,disabled:m.length===0,onClick:()=>void v(),children:[(0,V.jsx)(wi,{className:`mr-1 h-3.5 w-3.5`}),(0,V.jsx)(`span`,{className:`font-ui-display`,children:`Copy for agent`}),c.size>0?` (${c.size})`:``]}),(0,V.jsxs)(G,{size:`sm`,variant:`destructive`,disabled:y.length===0||g.isPending,onClick:()=>g.mutate(y),children:[(0,V.jsx)(Hi,{className:`mr-1 h-3.5 w-3.5`}),`Discard selected`]})]})]}),h&&(0,V.jsx)(`p`,{className:`text-sm text-gray-500`,children:`Loading…`}),!h&&m.length===0&&(0,V.jsx)(`p`,{className:`text-sm text-gray-500`,children:`No signals match these filters.`}),!h&&m.length>0&&(0,V.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-gray-800`,children:(0,V.jsxs)(`table`,{className:`w-full min-w-[48rem] text-left text-sm`,children:[(0,V.jsx)(`thead`,{className:`border-b border-gray-800 bg-gray-900/80 text-xs uppercase text-gray-500`,children:(0,V.jsxs)(`tr`,{children:[(0,V.jsx)(`th`,{className:`w-10 px-3 py-2`,children:(0,V.jsx)(cg,{checked:x?!0:S?`indeterminate`:!1,onCheckedChange:()=>{if(x){l(new Set);return}l(new Set(m.map(e=>e.id)))},"aria-label":`Select all visible signals`,disabled:m.length===0,className:lH})}),(0,V.jsx)(`th`,{className:`px-3 py-2`,children:`Excerpt`}),(0,V.jsx)(`th`,{className:`px-3 py-2`,children:`Failure`}),(0,V.jsx)(`th`,{className:`px-3 py-2`,children:`Playbook`}),(0,V.jsx)(`th`,{className:`px-3 py-2`,children:`Source`}),(0,V.jsx)(`th`,{className:`px-3 py-2`,children:`When`})]})}),(0,V.jsx)(`tbody`,{children:m.map(e=>{let t=ah(e);return(0,V.jsxs)(`tr`,{className:`border-b border-gray-800/80 align-top`,children:[(0,V.jsx)(`td`,{className:`px-3 py-2`,children:(0,V.jsx)(cg,{checked:c.has(e.id),onCheckedChange:()=>_(e.id),"aria-label":`Select ${e.id}`,className:lH})}),(0,V.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,V.jsx)(`p`,{className:`font-mono text-[11px] text-gray-600`,children:e.id}),(0,V.jsxs)(`p`,{className:`text-gray-200`,children:[`“`,e.userFeedbackExcerpt,`”`]}),t&&(0,V.jsx)(fh,{variant:`outline`,className:`mt-1 text-[10px]`,children:`In proposal`})]}),(0,V.jsx)(`td`,{className:`px-3 py-2 text-gray-400`,children:e.failureSummary}),(0,V.jsx)(`td`,{className:`px-3 py-2 text-gray-300`,children:e.candidatePlaybookId?f.get(e.candidatePlaybookId)??e.candidatePlaybookId:`—`}),(0,V.jsx)(`td`,{className:`px-3 py-2 text-gray-500`,children:e.source}),(0,V.jsx)(`td`,{className:`px-3 py-2 whitespace-nowrap text-gray-500`,children:new Date(e.createdAt).toLocaleString()})]},e.id)})})]})})]})]})}function dH(e){return e instanceof Ut?e.errorCode===`GRANT_REQUIRED`||e.errorCode===`DASHBOARD_REQUIRED`?{message:`This browser is not signed in to the Agent Deck dashboard. Run agent-deck open, then open this approval link again.`,retryable:!0}:e.errorCode===`ADMIN_CHALLENGE_EXPIRED`?{message:`This approval request expired or was already used. Ask the agent to request admin elevation again.`,retryable:!1}:e.errorCode===`SESSION_INVALID`?{message:`The agent session for this request is gone. Ask the agent to reconnect and request admin elevation again.`,retryable:!1}:{message:e.message||`Approval failed`,retryable:!0}:e instanceof TypeError?{message:`Could not reach Agent Deck. Check that it is running (agent-deck status) and try again.`,retryable:!0}:{message:e instanceof Error&&e.message?e.message:`Approval failed`,retryable:!0}}function fH(){let e=new URLSearchParams(window.location.search),t=e.get(`challenge`)??``,n=e.get(`session`)??``,[r,i]=(0,b.useState)(`idle`),[a,o]=(0,b.useState)(``),[s,c]=(0,b.useState)(!0);(0,b.useEffect)(()=>{(!t||!n)&&(i(`error`),c(!1),o(`This link is incomplete. Ask the agent to request admin elevation again.`))},[t,n]);async function l(){if(t&&n){i(`loading`);try{await H(`POST`,`/api/trusted-session/admin/approve`,{challengeId:t,runtimeSessionId:n}),i(`success`),o(`Admin elevation approved for this MCP session. Return to the agent.`)}catch(e){let t=dH(e);i(`error`),c(t.retryable),o(t.message)}}}return(0,V.jsx)(`div`,{className:`min-h-screen flex items-center justify-center p-6 bg-muted/30`,children:(0,V.jsxs)(EO,{className:`w-full max-w-md`,children:[(0,V.jsxs)(DO,{children:[(0,V.jsx)(OO,{children:`Approve agent-admin elevation`}),(0,V.jsx)(kO,{children:`Grants ephemeral deck-admin mode to one MCP session (30-minute lease). This does not change the folder's deck assignment.`})]}),(0,V.jsxs)(AO,{className:`space-y-4`,children:[t&&n?(0,V.jsxs)(`dl`,{className:`text-sm space-y-1 text-muted-foreground`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`inline font-medium text-foreground`,children:`Session `}),(0,V.jsx)(`dd`,{className:`inline font-mono text-xs`,children:n})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`inline font-medium text-foreground`,children:`Challenge `}),(0,V.jsx)(`dd`,{className:`inline font-mono text-xs`,children:t})]})]}):null,r===`success`?(0,V.jsx)(`p`,{role:`status`,className:`text-sm text-green-700 dark:text-green-400`,children:a}):r===`error`?(0,V.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:a}):null,r!==`success`&&t&&n&&(r!==`error`||s)?(0,V.jsx)(G,{onClick:()=>void l(),disabled:r===`loading`,className:`w-full`,children:r===`loading`?`Approving…`:`Approve elevation`}):null]})]})})}function pH(e){return e instanceof Ut?e.errorCode===`GRANT_REQUIRED`||e.errorCode===`DASHBOARD_REQUIRED`?{message:`This browser is not signed in to the Agent Deck dashboard. Run agent-deck open, then open this approval link again.`,retryable:!0}:e.errorCode===`DECK_SWITCH_EXPIRED`||e.status===410?{message:`This deck-switch request expired. The session and workspace default were not changed. Ask the agent to request the switch again.`,retryable:!1}:e.errorCode===`DECK_SWITCH_CONSUMED`||e.status===409?{message:`This deck-switch request was already resolved. The switch was not applied twice — check the current deck before requesting again.`,retryable:!1}:e.errorCode===`RESOURCE_OUT_OF_SCOPE`?{message:`This approval link does not match the requesting session. Only the matching session's request can be approved here — ask the agent for a fresh link if needed.`,retryable:!1}:e.errorCode===`SESSION_INVALID`?{message:`The agent session for this request is gone. Ask the agent to reconnect and request the deck switch again.`,retryable:!1}:e.status===404?{message:`This deck-switch request was not found. It may have been cleaned up. Ask the agent to request the switch again.`,retryable:!1}:{message:e.message||`Approval failed`,retryable:!0}:e instanceof TypeError?{message:`Could not reach Agent Deck. Check that it is running (agent-deck status) and try again.`,retryable:!0}:{message:e instanceof Error&&e.message?e.message:`Approval failed`,retryable:!0}}function mH(){let e=new URLSearchParams(window.location.search);return{requestId:(e.get(`request`)??e.get(`requestId`)??``).trim(),runtimeSessionId:(e.get(`session`)??e.get(`runtimeSessionId`)??``).trim()}}function hH(e){return e===`expired`?`This deck-switch request expired. The session and workspace default were not changed. Ask the agent to request the switch again.`:e===`declined`?`This deck-switch request was already declined. Nothing was changed.`:`This deck-switch request was already resolved. The switch was not applied twice — check the current deck before requesting again.`}function gH(e){let t=e.deckName?` “${e.deckName}”`:``;return e.decision===`session`?`Approved for this session only. This session now uses${t}. The workspace default was not changed.`:e.decision===`workspace-default`?`Approved. Future sessions${e.workspaceRoot?` in ${e.workspaceRoot}`:``} will use${t} as the new default. This session was switched too.`:`Declined. Nothing was changed — the session and workspace default are untouched.`}function _H(){let[{requestId:e,runtimeSessionId:t}]=(0,b.useState)(mH),[n,r]=(0,b.useState)(`loading`),[i,a]=(0,b.useState)(null),[o,s]=(0,b.useState)(``),[c,l]=(0,b.useState)(!0),[u,d]=(0,b.useState)(null),f=(0,b.useRef)(!1),p=(0,b.useCallback)(async()=>{if(!e){r(`error`),l(!1),s(`This link is incomplete. Ask the agent to request the deck switch again.`);return}r(`loading`),s(``);try{let t=(await(await H(`GET`,`/api/trusted-session/deck-switch/${e}`)).json()).data;if(!t||t.requestId!==e)throw Error(`Approval lookup returned an unexpected response`);a(t),t.status===`pending`?r(`pending`):(r(`error`),l(!1),s(hH(t.status)))}catch(e){let t=pH(e);r(`error`),l(t.retryable),s(t.message)}},[e]);(0,b.useEffect)(()=>{p()},[p]);async function m(n){if(f.current)return;let a=t||i?.runtimeSessionId||``;if(!e||!a){r(`error`),l(!1),s(`This link is incomplete. Ask the agent to request the deck switch again.`);return}f.current=!0,d(n),r(`submitting`);try{let t=await(await H(`POST`,`/api/trusted-session/deck-switch/${e}/resolve`,{runtimeSessionId:a,decision:n})).json(),o={decision:n,deckName:t.data?.deckName??i?.requestedDeckName,workspaceRoot:t.data?.workspaceRoot??i?.workspaceRoot};s(gH(o)),r(`success`)}catch(e){let t=pH(e);l(t.retryable),s(t.message),t.retryable&&i?r(`pending`):r(`error`)}finally{f.current=!1,d(null)}}function h(){s(``),i&&c?r(`pending`):p()}let g=n===`loading`||n===`submitting`,_=i?.currentDeckName??i?.currentDeckId,v=i?.requestedDeckName??i?.requestedDeckId,y=t||i?.runtimeSessionId;return(0,V.jsx)(`div`,{className:`min-h-screen flex items-center justify-center p-6 bg-muted/30`,children:(0,V.jsxs)(EO,{className:`w-full max-w-md`,children:[(0,V.jsxs)(DO,{children:[(0,V.jsx)(OO,{children:`Approve deck switch`}),(0,V.jsx)(kO,{children:`Choose whether the requested deck applies to this session only or becomes the workspace default. Declining leaves everything unchanged.`})]}),(0,V.jsxs)(AO,{className:`space-y-4`,children:[i&&(_||v)?(0,V.jsxs)(`dl`,{className:`text-sm space-y-1 text-muted-foreground`,children:[_?(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`inline font-medium text-foreground`,children:`Current deck `}),(0,V.jsx)(`dd`,{className:`inline`,children:_})]}):null,v?(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`inline font-medium text-foreground`,children:`Requested deck `}),(0,V.jsx)(`dd`,{className:`inline`,children:v})]}):null,i.workspaceRoot?(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`inline font-medium text-foreground`,children:`Workspace `}),(0,V.jsx)(`dd`,{className:`inline font-mono text-xs`,children:i.workspaceRoot})]}):null,y?(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`inline font-medium text-foreground`,children:`Session `}),(0,V.jsx)(`dd`,{className:`inline font-mono text-xs`,children:y})]}):null]}):e?(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Request `,(0,V.jsx)(`span`,{className:`font-mono text-xs`,children:e})]}):null,n===`loading`?(0,V.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Loading the deck-switch request…`}):null,n===`success`?(0,V.jsx)(`p`,{role:`status`,className:`text-sm text-green-700 dark:text-green-400`,children:o}):null,(n===`error`||n===`pending`)&&o?(0,V.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:o}):null,(n===`pending`||n===`submitting`)&&i?(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(G,{onClick:()=>void m(`session`),disabled:g,className:`w-full`,children:u===`session`?`Approving…`:`This session only`}),(0,V.jsx)(G,{onClick:()=>void m(`workspace-default`),disabled:g,variant:`secondary`,className:`w-full`,children:u===`workspace-default`?`Approving…`:`This workspace by default`}),(0,V.jsx)(G,{onClick:()=>void m(`decline`),disabled:g,variant:`outline`,className:`w-full`,children:u===`decline`?`Declining…`:`Decline`})]}):null,n===`error`?c?(0,V.jsx)(G,{onClick:h,variant:`outline`,className:`w-full`,children:`Try again`}):(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No further action is possible on this link. You can close this tab.`}):null,n===`success`?(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`You can close this tab and return to the agent.`}):null]})]})})}function vH(){return(0,V.jsxs)(xe,{children:[(0,V.jsx)(ve,{path:`/`,component:TO}),(0,V.jsx)(ve,{path:`/oauth/callback`,component:NO}),(0,V.jsx)(ve,{path:`/playbook-patches`,component:cH}),(0,V.jsx)(ve,{path:`/feedback-signals`,component:uH}),(0,V.jsx)(ve,{path:`/admin/approve`,component:fH}),(0,V.jsx)(ve,{path:`/deck-switch/approve`,component:_H}),(0,V.jsx)(ve,{path:`/mcp-test`,component:SV}),(0,V.jsx)(ve,{component:MO})]})}function yH(){let[e,t]=(0,b.useState)(!1);return(0,b.useEffect)(()=>{let e=!1;return qt().finally(()=>{e||t(!0)}),()=>{e=!0}},[]),e?(0,V.jsx)(Dt,{client:Kt,children:(0,V.jsxs)(Tl,{children:[(0,V.jsx)(Qa,{}),(0,V.jsx)(vH,{})]})}):(0,V.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-[#0B1220] text-sm text-gray-300`,children:`Loading AgentDeck...`})}(0,x.createRoot)(document.getElementById(`root`)).render((0,V.jsx)(b.StrictMode,{children:(0,V.jsx)(yH,{})}));
|