@nathanstephenson/flow 0.1.10-beta.7 → 0.1.10-beta.8
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.
- package/dist/build-id +1 -1
- package/dist/cli/bootstrap.js +1 -1
- package/dist/client/reduce.js +1 -0
- package/dist/daemon/host.js +15 -5
- package/dist/daemon/pull-request.js +3 -10
- package/dist/daemon/repository.js +11 -0
- package/dist/daemon/stack.js +37 -3
- package/dist/protocol/stack.js +14 -1
- package/package.json +1 -1
- package/web/dist/assets/index-Cf28Ke0f.js +51 -0
- package/web/dist/assets/index-DBl7acBx.css +2 -0
- package/web/dist/assets/{settings-mcp-CBXZt_cf.js → settings-mcp-DEU2AgQP.js} +1 -1
- package/web/dist/assets/{settings-workflows-CE11fxNj.js → settings-workflows-CS_5CtP9.js} +2 -2
- package/web/dist/assets/{workflows-DdogjBu3.js → workflows-DOxarXng.js} +13 -13
- package/web/dist/assets/{workflows-pane-B0dyuSuz.js → workflows-pane-DlaP2y8m.js} +1 -1
- package/web/dist/index.html +3 -3
- package/web/dist/assets/index-5E7qbtVD.js +0 -51
- package/web/dist/assets/index-BvkM2cWL.css +0 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import{a as e,i as t,n,r,t as i}from"./rolldown-runtime-B0Z9INg1.js";import{$n as a,$t as o,A as s,An as c,Bn as l,C as u,E as d,En as f,Er as p,Gn as m,Hn as h,In as g,J as _,Jn as v,K as y,Kn as b,Kt as x,Mn as S,N as C,Nn as w,O as T,Or as E,P as D,Pn as O,Q as k,Qn as A,Rn as j,S as M,T as N,Tn as P,U as F,Un as I,Vn as L,Wn as R,Xn as ee,Y as z,Yn as B,Z as te,Zn as V,_ as ne,an as re,bn as ie,cr as ae,ct as oe,dr as se,et as ce,fr as le,ft as ue,g as de,gn as fe,gt as pe,ht as me,i as he,in as ge,j as _e,jn as ve,kn as ye,kr as be,l as xe,mn as Se,mt as Ce,nt as we,on as Te,ot as Ee,q as De,rn as Oe,rt as ke,sn as Ae,sr as je,st as Me,tn as Ne,tt as Pe,ur as Fe,v as Ie,wn as Le,wr as Re,x as ze,xn as Be,y as Ve,yn as He,yr as Ue,z as We}from"./workflow-api-DkUjAZ4w.js";import{$ as Ge,A as Ke,At as qe,Ct as Je,D as Ye,Dt as Xe,E as Ze,Et as Qe,J as $e,K as et,M as tt,N as nt,Nt as rt,O as it,Ot as at,Q as ot,R as st,St as ct,T as lt,Tt as ut,U as dt,X as ft,Y as pt,Z as mt,at as ht,bt as gt,ct as _t,dt as vt,et as yt,ft as bt,gt as xt,ht as St,i as Ct,it as wt,j as Tt,k as Et,kt as Dt,lt as Ot,mt as kt,n as At,o as jt,ot as Mt,pt as Nt,q as Pt,rt as Ft,s as It,st as Lt,t as Rt,tt as zt,ut as Bt,vt as Vt,wt as Ht,xt as Ut,yt as Wt}from"./select-C-BND5Jn.js";function Gt(e){if(!e)return;let{used:t,window:n}=e;return n>0?`context ${Math.round(t/n*100)}%`:`${t} tokens`}function Kt(e){if(!e||e.window<=0)return;let{used:t,window:n,spend:r}=e,i=[{label:`Context`,value:`${Math.round(t/n*100)}% · ${Jt(t)}/${Jt(n)} tokens`}];if(!r)return i;if(i.push({label:`Spent`,value:`${Jt(r.tokens)} tokens · ${qt(r.costUSD)}`}),i.push({label:`Cache reads`,value:`${Jt(r.cached)} of ${Jt(r.tokens)}`}),r.models.length>1)for(let e of r.models)i.push({label:e.id,value:`${Jt(e.tokens)} · ${qt(e.costUSD)}`,model:!0});return i}function qt(e){return e>=.01?`$${e.toFixed(2)}`:e===0?`$0.00`:`$${e.toFixed(4)}`}function Jt(e){return e>=1e6?`${Math.round(e/1e5)/10}M`:e>=1e3?`${Math.round(e/1e3)}k`:`${e}`}function Yt(e){return e.lifecycle===`live`?e.awaiting?`awaiting`:e.turnInFlight?`running`:`idle`:e.lifecycle}function Xt(e){return e===`running`||e===`awaiting`}function Zt(e){return e.status===`settled`||e.status===`ended`?`filed-away`:e.attention?.group===`needs-input`?`needs-input`:e.attention?.group===`unread`?`unread`:e.status===`running`||e.status===`awaiting`||$t(e)?`working`:e.status===`idle`?`idle`:`dormant`}function Qt(e){switch(e){case`needs-input`:return`Needs input`;case`unread`:return`Unread`;case`working`:return`Working`;case`idle`:return`Idle`;case`dormant`:return`Dormant`;case`filed-away`:return`Filed away`}}function $t(e){return e.status===`idle`&&e.activeSubagents+e.activeBackgroundCalls+(e.activeWorkflows??0)>0}function en(e){return e!==`settled`&&e!==`ended`}function tn(e){return e===`dormant`||e===`settled`}function nn(e){let t={tokens:0,cached:0,costUSD:0,models:[]};for(let n of e){t.tokens+=n.tokens,t.cached+=n.cached,t.costUSD+=n.costUSD;for(let e of n.models){let n=t.models.find(t=>t.id===e.id);n?(n.tokens+=e.tokens,n.cached+=e.cached,n.costUSD+=e.costUSD):t.models.push({...e})}}return t}function rn(){return{status:`idle`,lifecycle:`live`,turnInFlight:!1,entries:[],queue:[],activeSubagents:0,activeBackgroundCalls:0,lastSeq:0}}function an(e){return e===`running`||e===`waiting`}function on(e,t=rn()){let n=t;for(let t of e)n=cn(n,t);return n}function sn(e,t){for(let n=e.length-1;n>=0;n--){let r=e[n];if(r.kind===`user`&&r.producer===void 0)return e;if(r.kind===`assistant`&&r.producer===void 0){if(r.endedAt===t)return e;let i=e.slice();return i[n]={...r,endedAt:t},i}}return e}function cn(e,t){let n=ln(e,t.event,t.at);return n===void 0?{...e,lastSeq:t.seq}:n===e?e:{...n,status:Yt({lifecycle:n.lifecycle,turnInFlight:n.turnInFlight,awaiting:n.asking!==void 0&&n.asking.producer===void 0||n.authorising!==void 0&&n.authorising.producer===void 0}),lastSeq:t.seq}}function ln(e,t,n){switch(t.type){case`session_started`:return{...e,backend:t.backend,scope:t.scope,capabilities:t.capabilities,...t.permissionMode?{permissionMode:t.permissionMode}:{},...t.worktree===void 0?{}:{worktree:t.worktree}};case`capabilities_changed`:return{...e,capabilities:t.capabilities};case`user_message`:return{...e,spoken:!0,entries:hn(e.entries,{kind:`user`,id:t.id,...t.fromSessionId===void 0?{text:t.text}:{text:t.text.slice(t.text.indexOf(`
|
|
2
|
-
`)+1),fromSessionId:t.fromSessionId},...t.attachments===void 0?{}:{attachments:t.attachments},at:n})};case`subagent_instruction`:return{...e,entries:hn(e.entries,{kind:`user`,id:t.id,text:t.text,producer:t.producer,at:n})};case`turn_started`:return{...e,turnInFlight:!0};case`message`:return{...e,entries:hn(e.entries,{kind:`assistant`,id:t.id,text:t.text,final:t.final,...mn(t)})};case`thinking`:return{...e,entries:hn(e.entries,{kind:`thinking`,id:t.id,text:t.text,final:t.final,...mn(t)})};case`tool_started`:return{...e,entries:hn(e.entries,{kind:`tool`,id:t.callId,name:t.name,input:t.input,status:`running`,...mn(t)})};case`tool_updated`:return{...e,entries:gn(e.entries,t.callId,e=>({...e,update:t.update}))};case`tool_ended`:return{...e,entries:gn(e.entries,t.callId,e=>({...e,result:t.result,status:t.isError?`error`:`complete`}))};case`subagent`:{let r=e.entries.find(e=>e.kind===`subagent`&&e.id===t.subagentId),i=r!==void 0&&an(r.status),a=an(t.state),o=a?void 0:r?.endedAt??n;return{...e,activeSubagents:e.activeSubagents+ +!!a-+!!i,entries:hn(e.entries,{kind:`subagent`,id:t.subagentId,name:t.name,...t.description===void 0?{}:{description:t.description},...t.model===void 0?{}:{model:t.model},...t.effort===void 0?{}:{effort:t.effort},...t.producer===void 0?{}:{producer:t.producer},status:t.state,...t.state===`waiting`?{waitingOn:t.on}:{},startedAt:r?.startedAt??n,...o===void 0?{}:{endedAt:o}})}}case`background_call`:{let r=e.entries.find(e=>e.kind===`background_call`&&e.id===t.callId),i=r?.status===`running`,a=t.state===`running`,o=a?void 0:r?.endedAt??n;return{...e,activeBackgroundCalls:e.activeBackgroundCalls+ +!!a-+!!i,entries:hn(e.entries,{kind:`background_call`,id:t.callId,tool:t.tool,status:t.state,...mn(t),startedAt:r?.startedAt??n,...o===void 0?{}:{endedAt:o}})}}case`enquiry`:{let n=t.state===`asked`,r=n&&e.asking?.askId===t.askId?e.asking:n?{askId:t.askId,questions:t.questions,...t.context===void 0?{}:{context:t.context},...t.producer===void 0?{}:{producer:t.producer}}:e.asking?.askId===t.askId?void 0:e.asking;return{...e,...r===void 0?{asking:void 0}:{asking:r},entries:hn(e.entries,{kind:`enquiry`,id:t.askId,questions:t.questions,status:t.state,...t.state===`answered`?{answers:t.answers}:{},...t.context===void 0?{}:{context:t.context},...t.producer===void 0?{}:{producer:t.producer}})}}case`permission`:{let n=t.state===`asked`?e.authorising??{callId:t.callId,tool:t.tool,...t.context===void 0?{}:{context:t.context},...t.allowAlways===void 0?{}:{allowAlways:t.allowAlways},...t.authorizationScope===void 0?{}:{authorizationScope:t.authorizationScope},...t.producer===void 0?{}:{producer:t.producer}}:e.authorising?.callId===t.callId?pn(e.entries,t.callId):e.authorising;return{...e,...n===void 0?{authorising:void 0}:{authorising:n},entries:gn(e.entries,t.callId,e=>({...e,authorisation:fn(t),...t.context===void 0?{}:{permissionContext:t.context},...t.allowAlways===void 0?{}:{allowAlways:t.allowAlways},...t.authorizationScope===void 0?{}:{authorizationScope:t.authorizationScope}}))}}case`turn_ended`:return{...e,entries:sn(e.entries,n),turnInFlight:!1,asking:e.asking?.producer===void 0?void 0:e.asking,authorising:e.authorising?.producer===void 0?void 0:e.authorising};case`queue_changed`:return{...e,queue:[...t.pending],queuedMessages:e.queuedMessages?.length===t.pending.length&&e.queuedMessages.every((e,n)=>e.text===t.pending[n]&&e.id===t.ids?.[n]&&(e.attachments?.length??0)===(t.attachments?.[n]?.length??0)&&(e.attachments??[]).every((e,r)=>e===t.attachments?.[n]?.[r]))?e.queuedMessages:t.pending.map((e,n)=>({id:t.ids?.[n],text:e,...t.attachments?.[n]?.length?{attachments:t.attachments[n]}:{}}))};case`workflow_spend`:{let n={...e.workflowSpend,[t.executionId]:t.spend},r=nn([...e.parentSpend?[e.parentSpend]:[],...Object.values(n)]);return{...e,workflowSpend:n,spend:r,...e.contextUsage?{contextUsage:{...e.contextUsage,spend:r}}:{}}}case`context_usage`:{let n=t.spend||e.workflowSpend?nn([...t.spend?[t.spend]:[],...Object.values(e.workflowSpend??{})]):void 0;return{...e,...t.spend?{parentSpend:t.spend}:{},...n?{spend:n}:{},contextUsage:{used:t.used,window:t.window,...n===void 0?{}:{spend:n}}}}case`model_changed`:return{...e,model:t.model};case`permission_mode_changed`:return{...e,permissionMode:t.mode};case`effort_changed`:return{...e,effort:t.effort};case`branch_changed`:return{...e,branch:t.branch};case`notice`:return{...e,entries:[...e.entries,{kind:`notice`,id:`notice-${e.entries.length}`,level:t.level,text:t.text,...t.sessionId===void 0?{}:{sessionId:t.sessionId}}]};case`compacting`:return t.active?{...e,compacting:!0}:un(e);case`compacted`:return{...un(e),entries:[...e.entries,{kind:`marker`,id:`compacted-${e.entries.length}`,marker:`compacted`,text:dn(t.trigger,t.before,t.after)}]};case`session_dormant`:return{...e,lifecycle:`dormant`,turnInFlight:!1,queue:[],queuedMessages:[],asking:void 0,authorising:void 0,entries:[...e.entries,{kind:`marker`,id:`dormant-${e.entries.length}`,marker:`dormant`,text:`Dormant: ${t.reason}`}]};case`session_settled`:return{...e,lifecycle:`settled`,turnInFlight:!1,queue:[],queuedMessages:[],asking:void 0,authorising:void 0,entries:[...e.entries,{kind:`marker`,id:`settled-${e.entries.length}`,marker:`settled`,text:`Settled`}]};case`rewound`:{let n=e.entries.findIndex(e=>e.kind===`user`&&e.id===t.userMessageId),r=t.restore===`files`?`Files rewound`:t.restore===`both`?`Rewound conversation and files`:`Rewound conversation`;return{...e,entries:[...n<0||t.restore===`files`?e.entries:e.entries.map((e,t)=>t<n||e.rewound?e:{...e,rewound:!0}),{kind:`marker`,id:`rewound-${e.entries.length}`,marker:`rewound`,text:r}]}}case`forked`:return{...e,entries:[...e.entries,{kind:`marker`,id:`forked-${e.entries.length}`,marker:`forked`,text:`Forked`,fromSessionId:t.fromSessionId}]};case`revived`:return{...e,...t.scope===void 0?{}:{scope:t.scope},lifecycle:`live`,turnInFlight:!1,entries:[...e.entries,{kind:`marker`,id:`revived-${t.fromSeq}`,marker:`revived`,text:`Revived from seq ${t.fromSeq}`}]};case`session_ended`:return{...e,lifecycle:`ended`,turnInFlight:!1,endedReason:t.reason,asking:void 0,authorising:void 0}}}function un(e){if(!e.compacting)return e;let{compacting:t,...n}=e;return n}function dn(e,t,n){let r=e===`auto`?`Compacted automatically`:`Compacted`;return n===void 0?`${r}, from ${Jt(t)} tokens`:`${r}, ${Jt(t)} → ${Jt(n)} tokens`}function fn(e){return e.state===`asked`?`asked`:e.state===`aborted`||e.decision===`deny`?`denied`:e.decision===`always`?`always`:`allowed`}function pn(e,t){let n=e.find(e=>e.kind===`tool`&&e.id!==t&&e.authorisation===`asked`);return n?.kind===`tool`?{callId:n.id,tool:n.name,...n.permissionContext===void 0?{}:{context:n.permissionContext},...n.allowAlways===void 0?{}:{allowAlways:n.allowAlways},...n.authorizationScope===void 0?{}:{authorizationScope:n.authorizationScope},...n.producer===void 0?{}:{producer:n.producer}}:void 0}function mn(e){return e.producer===void 0?{}:{producer:e.producer}}function hn(e,t){let n=e.findIndex(e=>e.kind===t.kind&&e.id===t.id);if(n<0)return[...e,t];let r=[...e];return r[n]=t,r}function gn(e,t,n){let r=e.findIndex(e=>e.kind===`tool`&&e.id===t);if(r<0)return e;let i=e[r];if(!i||i.kind!==`tool`)return e;let a=[...e];return a[r]=n(i),a}var H=e(be(),1),_n=e(E(),1);function vn(e){return`${e.kind}:${e.id}`}var U=Re();function yn(e,t){let n=/\/worktrees\/([^/]+)\/[^/]+$/.exec(e)?.[1];return n===void 0?void 0:t.find(e=>e.name===n)?.path}var bn=rt(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),xn=rt(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),Sn=rt(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),Cn=rt(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),wn=rt(`file-pen`,[[`path`,{d:`M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34`,key:`o6klzx`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z`,key:`zhnas1`}]]),Tn=rt(`file-plus`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M9 15h6`,key:`cctwl0`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}]]),En=rt(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Dn=rt(`folder-search`,[[`path`,{d:`M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1`,key:`1bw5m7`}],[`path`,{d:`m21 21-1.9-1.9`,key:`1g2n9r`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}]]),On=rt(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),kn=rt(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),An=rt(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),jn=rt(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),Mn=rt(`message-circle-question-mark`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Nn=rt(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),Pn=rt(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Fn=rt(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),In=rt(`square-terminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),Ln=rt(`undo-2`,[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]),Rn=rt(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),zn=rt(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);function Bn(e){let t=e.trim();return t.startsWith(`/`)||t.startsWith(`~`)?`completion`:`search`}function Vn(e){return e.trim()!==``}function Hn(e){let t=[];for(let n of e){let e=t[t.length-1];if(e&&e.group===n.group){e.items.push(n);continue}t.push({group:n.group,items:[n]})}return t}function Un(e,t){if(t===void 0||t===``)return e;let n=t.endsWith(`/`)?t:`${t}/`;if(!e.startsWith(n))return e;let r=e.slice(n.length);return r===``?e:r}function Wn(e,t){return t!=null&&!x(t)?0:typeof e==`function`?e():e}function Gn(e,t,n){let r=Wn(e,n);return typeof r==`number`?r:r?.[t]}function Kn(e){return typeof e==`function`?e():e}function qn(e,t){return t||e===`click`||e===`mousedown`}function Jn(e){return e?.includes(`mouse`)&&e!==`mousedown`}var Yn=H.createContext({hasProvider:!1,timeoutMs:0,delayRef:{current:0},initialDelayRef:{current:0},timeout:new ie,currentIdRef:{current:null},currentContextRef:{current:null}});function Xn(e,t){e.current=t.current}function Zn(e){let{children:t,delay:n,timeoutMs:r=0}=e,i=H.useRef(n),a=H.useRef(n),o=H.useRef(null),s=H.useRef(null),c=Be();return V(()=>{if(a.current=n,!o.current){i.current=n;return}i.current={open:Gn(i.current,`open`),close:Gn(n,`close`)}},[n,o,i,a]),(0,U.jsx)(Yn.Provider,{value:H.useMemo(()=>({hasProvider:!0,delayRef:i,initialDelayRef:a,currentIdRef:o,timeoutMs:r,currentContextRef:s,timeout:c}),[r,c]),children:t})}function Qn(e,t={open:!1}){let{open:n}=t,r=`rootStore`in e?e.rootStore:e,i=r.useState(`floatingId`),{currentIdRef:a,delayRef:o,timeoutMs:s,initialDelayRef:c,currentContextRef:l,hasProvider:u,timeout:f}=H.useContext(Yn),[p,m]=H.useState(!1),h=H.useRef(n);return V(()=>{h.current=n},[n]),V(()=>{function e(){l.current?.setIsInstantPhase(!1),a.current=null,l.current=null,o.current=c.current,f.clear()}if(a.current&&!n&&a.current===i){if(m(!1),s){let t=i;return f.start(s,()=>{r.select(`open`)||a.current&&a.current!==t||e()}),()=>{(h.current||a.current!==t)&&f.clear()}}e()}},[n,i,a,o,s,c,l,f,r]),V(()=>{if(!n)return;let e=l.current,t=a.current;f.clear(),l.current={onOpenChange:r.setOpen,setIsInstantPhase:m},a.current=i,o.current={open:0,close:Gn(c.current,`close`)},t!==null&&t!==i?(m(!0),e?.setIsInstantPhase(!0),e?.onOpenChange(!1,d(F))):(m(!1),e?.setIsInstantPhase(!1))},[n,i,r,a,o,c,l,f]),V(()=>()=>{if(a.current===i){if(l.current=null,!h.current)return;a.current=null,Xn(o,c),f.clear()}},[l,a,o,i,c,f]),H.useMemo(()=>({hasProvider:u,delayRef:o,isInstantPhase:p}),[u,o,p])}function $n(e,t){let n=null,r=null,i=!1;return{contextElement:e||void 0,getBoundingClientRect(){let a=e?.getBoundingClientRect()||{width:0,height:0,x:0,y:0},o=t.axis===`x`||t.axis===`both`,s=t.axis===`y`||t.axis===`both`,c=[`mouseenter`,`mousemove`].includes(t.dataRef.current.openEvent?.type||``)&&t.pointerType!==`touch`,l=a.width,u=a.height,d=a.x,f=a.y;return n==null&&t.x&&o&&(n=a.x-t.x),r==null&&t.y&&s&&(r=a.y-t.y),d-=n||0,f-=r||0,l=0,u=0,!i||c?(l=t.axis===`y`?a.width:0,u=t.axis===`x`?a.height:0,d=o&&t.x!=null?t.x:d,f=s&&t.y!=null?t.y:f):i&&!c&&(u=t.axis===`x`?a.height:u,l=t.axis===`y`?a.width:l),i=!0,{width:l,height:u,x:d,y:f,top:f,right:d+l,bottom:f+u,left:d}}}}function er(e){return e!=null&&e.clientX!=null}function tr(e,t={}){let{enabled:n=!0,axis:r=`both`}=t,i=`rootStore`in e?e.rootStore:e,a=i.useState(`open`),o=i.useState(`floatingElement`),s=i.useState(`domReferenceElement`),c=i.context.dataRef,l=H.useRef(!1),u=H.useRef(null),[d,f]=H.useState(),[p,m]=H.useState([]),h=A(e=>{i.set(`positionReference`,e)}),g=A((e,t,n)=>{l.current||c.current.openEvent&&!er(c.current.openEvent)||i.set(`positionReference`,$n(n??s,{x:e,y:t,axis:r,dataRef:c,pointerType:d}))}),_=A(e=>{a?u.current||(g(e.clientX,e.clientY,e.currentTarget),m([])):g(e.clientX,e.clientY,e.currentTarget)}),v=x(d)?o:a;H.useEffect(()=>{if(!n){h(s);return}if(!v)return;function e(){u.current?.(),u.current=null}let t=ae(o);function r(t){let n=Ae(t);Te(o,n)?e():g(t.clientX,t.clientY)}return!c.current.openEvent||er(c.current.openEvent)?u.current=Le(t,`mousemove`,r):h(s),e},[v,n,o,c,s,i,g,h,p]),H.useEffect(()=>()=>{i.set(`positionReference`,null)},[i]),H.useEffect(()=>{n&&!o&&(l.current=!1)},[n,o]),H.useEffect(()=>{!n&&a&&(l.current=!0)},[n,a]);let y=H.useMemo(()=>{function e(e){f(e.pointerType)}return{onPointerDown:e,onPointerEnter:e,onMouseMove:_,onMouseEnter:_}},[_]);return H.useMemo(()=>n?{reference:y,trigger:y}:{},[n,y])}function nr(){return new Wt({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:new Ft,floatingId:void 0,syncOnly:!1,nested:!1,onOpenChange:void 0})}function rr(){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:nr(),floatingId:void 0,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:L,inactiveTriggerProps:L,popupProps:L}}function ir(e,t,n=!1){return new Wt({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:n,onOpenChange:void 0})}var ar=e=>e.triggerIdProp??e.activeTriggerId,or=e=>e.openProp??e.open,sr=e=>(e.popupElement?.id??e.floatingId)||void 0;function cr(e,t){return t!==void 0&&or(e)&&ar(e)===t}function lr(e,t){return cr(e,t)?!0:t!==void 0&&or(e)&&ar(e)==null&&e.triggerCount===1}var ur={open:or,mounted:e=>e.mounted,transitionStatus:e=>e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:ar,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:sr,isTriggerActive:(e,t)=>t!==void 0&&ar(e)===t,isOpenedByTrigger:(e,t)=>cr(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&ar(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>lr(e,t)?sr(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement},dr=S();function fr(e){let t=H.useCallback(t=>e===void 0?h:e.subscribeStore(t),[e]),n=H.useCallback(()=>e===void 0?void 0:e.store,[e]);return(0,dr.useSyncExternalStore)(t,n,()=>e?.serverStore)}var pr=He&&fe;function mr(e,t={}){let{enabled:n=!0,delay:r}=t,i=`rootStore`in e?e.rootStore:e,{events:a,dataRef:o}=i.context,s=H.useRef(!1),c=H.useRef(null),l=H.useRef(!0),u=Be();H.useEffect(()=>{let e=i.select(`domReferenceElement`);if(!n)return;let t=ae(e);function r(){let e=i.select(`domReferenceElement`);!i.select(`open`)&&se(e)&&e===re(b(e))&&(s.current=!0)}function a(){l.current=!0}function o(){l.current=!1}return P(Le(t,`blur`,r),pr&&Le(t,`keydown`,a,!0),pr&&Le(t,`pointerdown`,o,!0))},[i,n]),H.useEffect(()=>{if(!n)return;function e(e){if(e.reason===`trigger-press`||e.reason===`escape-key`){let e=i.select(`domReferenceElement`);Fe(e)&&(c.current=e,s.current=!0)}}return a.on(`openchange`,e),()=>{a.off(`openchange`,e)}},[a,n,i]);let f=H.useMemo(()=>{function e(){s.current=!1,c.current=null}return{onMouseLeave(){e()},onFocus(t){let n=t.currentTarget;if(s.current){if(c.current===n)return;e()}let a=Ae(t.nativeEvent);if(Fe(a)){if(pr&&!t.relatedTarget){if(!l.current&&!Oe(a))return}else if(!ge(a))return}let o=Ne(t.relatedTarget,i.context.triggerElements),{nativeEvent:f,currentTarget:p}=t,m=typeof r==`function`?r():r;if(i.select(`open`)&&o||m===0||m===void 0){i.setOpen(!0,d(De,f,p));return}u.start(m,()=>{s.current||i.setOpen(!0,d(De,f,p))})},onBlur(t){e();let n=t.relatedTarget,r=t.nativeEvent,a=Fe(n)&&n.hasAttribute(N(`focus-guard`))&&n.getAttribute(`data-type`)===`outside`;u.start(0,()=>{let e=i.select(`domReferenceElement`),t=re(b(e));!n&&t===e||Te(o.current.floatingContext?.refs.floating.current,t)||Te(e,t)||a||Ne(n??t,i.context.triggerElements)||i.setOpen(!1,d(De,r))})}}},[o,r,i,u]);return H.useMemo(()=>n?{reference:f,trigger:f}:{},[n,f])}var hr=class e{constructor(){this.pointerType=void 0,this.interactedInside=!1,this.handler=void 0,this.blockMouseMove=!0,this.performedPointerEventsMutation=!1,this.pointerEventsScopeElement=null,this.pointerEventsReferenceElement=null,this.pointerEventsFloatingElement=null,this.restTimeoutPending=!1,this.openChangeTimeout=new ie,this.restTimeout=new ie,this.handleCloseOptions=void 0}static create(){return new e}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose},gr=new WeakMap;function _r(e){if(!e.performedPointerEventsMutation)return;let t=e.pointerEventsScopeElement;t&&gr.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty(`pointer-events`),e.pointerEventsReferenceElement?.style.removeProperty(`pointer-events`),e.pointerEventsFloatingElement?.style.removeProperty(`pointer-events`),gr.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function vr(e,t){let{scopeElement:n,referenceElement:r,floatingElement:i}=t,a=gr.get(n);a&&a!==e&&_r(a),_r(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=i,gr.set(n,e),n.style.pointerEvents=`none`,r.style.pointerEvents=`auto`,i.style.pointerEvents=`auto`}function yr(e){let t=e.context.dataRef.current,n=a(()=>t.hoverInteractionState??hr.create()).current;return t.hoverInteractionState||=n,w(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function br(e,t={}){let{enabled:n=!0,closeDelay:r=0,nodeId:i}=t,a=`rootStore`in e?e.rootStore:e,s=a.useState(`open`),c=a.useState(`floatingElement`),l=a.useState(`domReferenceElement`),{dataRef:u}=a.context,f=Xe(),p=Qe(),m=yr(a),h=Be(),g=A(()=>qn(u.current.openEvent?.type,m.interactedInside)),v=A(()=>Jn(u.current.openEvent?.type)),y=A(()=>{_r(m)});V(()=>{s||(m.pointerType=void 0,m.restTimeoutPending=!1,m.interactedInside=!1,y())},[s,m,y]),H.useEffect(()=>y,[y]),V(()=>{if(n&&s&&m.handleCloseOptions?.blockPointerEvents&&v()&&Fe(l)&&c){let e=l,t=c,n=b(c),r=f?.nodesRef.current.find(e=>e.id===p)?.context?.elements.floating;r&&(r.style.pointerEvents=``);let i=m.pointerEventsScopeElement===t?null:m.pointerEventsScopeElement,a=r===t?null:r,o=m.handleCloseOptions?.getScope?.()??i??a??e.closest(`[data-rootownerid]`)??n.body;return vr(m,{scopeElement:o,referenceElement:e,floatingElement:t}),()=>{y()}}},[n,s,l,c,m,v,f,p,y]),H.useEffect(()=>{if(!n)return;function e(){return!!(f&&p&&qe(f.nodesRef.current,p).length>0)}function t(e){let t=Gn(r,`close`,m.pointerType),n=()=>{a.setOpen(!1,d(_,e)),f?.events.emit(`floating.closed`,e)};t?m.openChangeTimeout.start(t,n):(m.openChangeTimeout.clear(),n())}function s(e){let t=Ae(e);if(!o(t)){m.interactedInside=!1;return}m.interactedInside=t?.closest(`[aria-haspopup]`)!=null}function l(){m.openChangeTimeout.clear(),h.clear(),f?.events.off(`floating.closed`,x),y()}function b(n){if(e()&&f){f.events.on(`floating.closed`,x);return}if(Ne(n.relatedTarget,a.context.triggerElements))return;let r=u.current.floatingContext?.nodeId??i,o=n.relatedTarget;if(!(f&&r&&Fe(o)&&qe(f.nodesRef.current,r,!1).some(e=>Te(e.context?.elements.floating,o)))){if(m.handler){m.handler(n);return}y(),v()&&!g()&&t(n)}}function x(t){!f||!p||e()||h.start(0,()=>{f.events.off(`floating.closed`,x),a.setOpen(!1,d(_,t)),f.events.emit(`floating.closed`,t)})}let S=c;return P(S&&Le(S,`mouseenter`,l),S&&Le(S,`mouseleave`,b),S&&Le(S,`pointerdown`,s,!0),()=>{f?.events.off(`floating.closed`,x)})},[n,c,a,u,r,i,v,g,y,m,f,p,h])}var xr={current:null};function Sr(e,t={}){let{enabled:n=!0,delay:r=0,handleClose:i=null,mouseOnly:a=!1,restMs:o=0,move:s=!0,triggerElementRef:c=xr,externalTree:l,isActiveTrigger:u=!0,getHandleCloseContext:f,isClosing:p,shouldOpen:m,guardStaleOpen:h=!1}=t,g=`rootStore`in e?e.rootStore:e,{dataRef:v,events:y}=g.context,S=Xe(l),C=yr(g),w=H.useRef(!1),T=Dt(i),E=Dt(r),D=Dt(o),O=Dt(n),k=Dt(m),j=Dt(p),M=A(()=>qn(v.current.openEvent?.type,C.interactedInside)),N=A(()=>k.current?.()!==!1),F=A((e,t,n)=>{let r=g.context.triggerElements;if(r.hasElement(t))return!e||!Te(e,t);if(!Fe(n))return!1;let i=n;return r.hasMatchingElement(e=>Te(e,i))&&(!e||!Te(e,i))}),I=A(()=>{C.handler&&=(b(g.select(`domReferenceElement`)).removeEventListener(`mousemove`,C.handler),void 0)}),L=A(()=>{_r(C)});return u&&(C.handleCloseOptions=T.current?.__options),H.useEffect(()=>I,[I]),H.useEffect(()=>{if(!n)return;function e(e){e.open?w.current=!1:(w.current=e.reason===_,I(),C.openChangeTimeout.clear(),C.restTimeout.clear(),C.blockMouseMove=!0,C.restTimeoutPending=!1)}return y.on(`openchange`,e),()=>{y.off(`openchange`,e)}},[n,y,C,I]),H.useEffect(()=>{if(!n)return;function e(e,t=!0){let n=Gn(E.current,`close`,C.pointerType);n?C.openChangeTimeout.start(n,()=>{g.setOpen(!1,d(_,e)),S?.events.emit(`floating.closed`,e)}):t&&(C.openChangeTimeout.clear(),g.setOpen(!1,d(_,e)),S?.events.emit(`floating.closed`,e))}let t=c.current??(u?g.select(`domReferenceElement`):null);if(!Fe(t))return;function r(e){if(C.openChangeTimeout.clear(),C.blockMouseMove=!1,a&&!x(C.pointerType))return;let t=Kn(D.current),n=Gn(E.current,`open`,C.pointerType),r=Ae(e),i=e.currentTarget??null,o=g.select(`domReferenceElement`),s=i;if(Fe(r)&&!g.context.triggerElements.hasElement(r)){for(let e of g.context.triggerElements.elements())if(Te(e,r)){s=e;break}}Fe(i)&&Fe(o)&&!g.context.triggerElements.hasElement(i)&&Te(i,o)&&(s=o);let c=s!=null&&F(o,s,r),l=g.select(`open`),u=j.current?.()??g.select(`transitionStatus`)===`ending`,f=!l&&u&&w.current,p=!c&&Fe(s)&&Fe(o)&&Te(o,s)&&f,m=t>0&&!n,h=c&&(l||f)||p,v=!l||c;if(h){N()&&g.setOpen(!0,d(_,e,s));return}m||(n?C.openChangeTimeout.start(n,()=>{v&&N()&&g.setOpen(!0,d(_,e,s))}):v&&N()&&g.setOpen(!0,d(_,e,s)))}function i(t){if(M()){L();return}I();let n=g.select(`domReferenceElement`),r=b(n);C.restTimeout.clear(),C.restTimeoutPending=!1;let i=v.current.floatingContext??f?.();if(!Ne(t.relatedTarget,g.context.triggerElements)){if(T.current&&i){g.select(`open`)||C.openChangeTimeout.clear();let n=c.current;C.handler=T.current({...i,tree:S,x:t.clientX,y:t.clientY,onClose(){L(),I(),O.current&&!M()&&n===g.select(`domReferenceElement`)&&e(t,!0)}}),r.addEventListener(`mousemove`,C.handler),C.handler(t);return}(C.pointerType!==`touch`||!Te(g.select(`floatingElement`),t.relatedTarget))&&e(t)}}function o(e){Te(t,e.relatedTarget)||(C.openChangeTimeout.clear(),C.restTimeout.clear(),C.restTimeoutPending=!1)}let l=h?Le(t,`mouseout`,o):void 0;return s?P(Le(t,`mousemove`,r,{once:!0}),Le(t,`mouseenter`,r),Le(t,`mouseleave`,i),l):P(Le(t,`mouseenter`,r),Le(t,`mouseleave`,i),l)},[I,L,v,E,g,n,T,C,u,F,M,a,s,D,c,S,O,f,j,N,h]),H.useMemo(()=>{if(!n)return;function e(e){C.pointerType=e.pointerType}return{onPointerDown:e,onPointerEnter:e,onMouseMove(e){let{nativeEvent:t}=e,n=e.currentTarget,r=g.select(`domReferenceElement`),i=g.select(`open`),o=F(r,n,e.target);if(a&&!x(C.pointerType))return;if(i&&o&&C.handleCloseOptions?.blockPointerEvents){let e=g.select(`floatingElement`);if(e){let t=C.handleCloseOptions?.getScope?.()??n.ownerDocument.body;vr(C,{scopeElement:t,referenceElement:n,floatingElement:e})}}let s=Kn(D.current);if(i&&!o||s===0||!o&&C.restTimeoutPending&&e.movementX**2+e.movementY**2<2)return;C.restTimeout.clear();function c(){if(C.restTimeoutPending=!1,M())return;let e=g.select(`open`);!C.blockMouseMove&&(!e||o)&&N()&&g.setOpen(!0,d(_,t,n))}C.pointerType===`touch`?_n.flushSync(()=>{c()}):o&&i?c():(C.restTimeoutPending=!0,C.restTimeout.start(s,c))}}},[n,C,M,F,a,g,D,N])}var Cr=.1,wr=Cr*Cr,Tr=.5;function Er(e,t,n,r,i,a){return r>=t!=a>=t&&e<=(i-n)*(t-r)/(a-r)+n}function Dr(e,t,n,r,i,a,o,s,c,l){let u=!1;return Er(e,t,n,r,i,a)&&(u=!u),Er(e,t,i,a,o,s)&&(u=!u),Er(e,t,o,s,c,l)&&(u=!u),Er(e,t,c,l,n,r)&&(u=!u),u}function Or(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function kr(e,t,n,r,i,a){return e>=Math.min(n,i)&&e<=Math.max(n,i)&&t>=Math.min(r,a)&&t<=Math.max(r,a)}function Ar(e={}){let{blockPointerEvents:t=!1}=e,n=new ie,r=({x:e,y:t,placement:r,elements:i,onClose:a,nodeId:o,tree:s})=>{let c=r?.split(`-`)[0],l=!1,u=null,d=null,f=typeof performance<`u`?performance.now():0;function p(e,t){let n=performance.now(),r=n-f;if(u===null||d===null||r===0)return u=e,d=t,f=n,!1;let i=e-u,a=t-d,o=i*i+a*a,s=r*r*wr;return u=e,d=t,f=n,o<s}function m(){n.clear(),a()}return function(r){n.clear();let a=i.domReference,u=i.floating;if(!a||!u||c==null||e==null||t==null)return;let{clientX:d,clientY:f}=r,h=Ae(r),g=r.type===`mouseleave`,_=Te(u,h),v=Te(a,h);if(_&&(l=!0,!g))return;if(v&&(l=!1,!g)){l=!0;return}if(g&&Fe(r.relatedTarget)&&Te(u,r.relatedTarget))return;function y(){return!!(s&&qe(s.nodesRef.current,o).length>0)}function b(){y()||m()}if(y())return;let x=a.getBoundingClientRect(),S=u.getBoundingClientRect(),C=e>S.right-S.width/2,w=t>S.bottom-S.height/2,T=S.width>x.width,E=S.height>x.height,D=(T?x:S).left,O=(T?x:S).right,k=(E?x:S).top,A=(E?x:S).bottom;if(c===`top`&&t>=x.bottom-1||c===`bottom`&&t<=x.top+1||c===`left`&&e>=x.right-1||c===`right`&&e<=x.left+1){b();return}let j=!1;switch(c){case`top`:j=kr(d,f,D,x.top+1,O,S.bottom-1);break;case`bottom`:j=kr(d,f,D,S.top+1,O,x.bottom-1);break;case`left`:j=kr(d,f,S.right-1,A,x.left+1,k);break;case`right`:j=kr(d,f,x.right-1,A,S.left+1,k)}if(j)return;if(l&&!Or(d,f,x)){b();return}if(!g&&p(d,f)){b();return}let M=!1;switch(c){case`top`:{let n=T?Tr/2:Tr*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t+Tr+1,o=C||T?S.bottom-Tr:S.top,s=C?T?S.bottom-Tr:S.top:S.bottom-Tr;M=Dr(d,f,r,a,i,a,S.left,o,S.right,s);break}case`bottom`:{let n=T?Tr/2:Tr*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t-Tr,o=C||T?S.top+Tr:S.bottom,s=C?T?S.top+Tr:S.bottom:S.top+Tr;M=Dr(d,f,r,a,i,a,S.left,o,S.right,s);break}case`left`:{let n=E?Tr/2:Tr*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e+Tr+1,o=w||E?S.right-Tr:S.left,s=w?E?S.right-Tr:S.left:S.right-Tr;M=Dr(d,f,o,S.top,s,S.bottom,a,r,a,i);break}case`right`:{let n=E?Tr/2:Tr*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e-Tr,o=w||E?S.left+Tr:S.right,s=w?E?S.left+Tr:S.right:S.left+Tr;M=Dr(d,f,a,r,a,i,o,S.top,s,S.bottom);break}}M?l||n.start(40,b):b()}};return r.__options={...e,blockPointerEvents:t},r}function jr(){let{config:e,refresh:t}=Ue(),{save:n,saving:r}=Ve(),i=e.projectList??[],a=e.projectCandidates??[],o=e.projects?.root??``,s=e.projects?.include??[],c=(0,H.useCallback)((e,r)=>{(async()=>{await n({projects:{include:e}},r)&&await t()})()},[n,t]),l=t=>{let n=Un(t,e.projects?.root===void 0?void 0:e.scope);s.includes(n)||c([...s,n],`Project added.`)};return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Mr,{included:i,onRemove:e=>c(s.filter((t,n)=>n!==e),`Project removed.`)}),(0,U.jsx)(Nr,{candidates:a,hasRoot:e.projects?.root!==void 0,onAdd:l}),(0,U.jsx)(Fr,{onAdd:l}),(0,U.jsx)(Ir,{current:o,saving:r,onSave:n,onSaved:t}),(0,U.jsxs)(Ie,{title:`Worktrees`,description:`Machine-wide.`,children:[(0,U.jsxs)(`label`,{className:`flex items-center justify-between gap-4`,children:[(0,U.jsx)(`span`,{className:`text-sm`,children:`Always start new Agent Sessions in a Worktree`}),(0,U.jsx)(dt,{checked:e.worktrees?.always===!0,disabled:r,onCheckedChange:e=>void n({worktrees:{always:e}},e?`New Agent Sessions start in a Worktree.`:`New Agent Sessions start in the Project.`)})]}),(0,U.jsxs)(`label`,{className:`flex items-center justify-between gap-4`,children:[(0,U.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-sm`,children:`Update the Source Branch before cutting a Worktree`}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Fast-forwards the branch from its upstream in the Project. If this fails, the Worktree is cut from the local branch and a warning is shown.`})]}),(0,U.jsx)(dt,{checked:e.worktrees?.updateSource===!0,disabled:r,onCheckedChange:e=>void n({worktrees:{updateSource:e}},e?`Source Branches are updated before a Worktree is cut.`:`Worktrees are cut from the local branch.`)})]})]})]})}function Mr({included:e,onRemove:t}){return(0,U.jsx)(Ie,{title:`Projects · ${e.length}`,description:e.length===0?`Nothing yet. A Project is one you have opted into — add one below, and it becomes an option in the New Agent Session view.`:`What the New Agent Session view offers, in this order.`,children:e.length===0?null:(0,U.jsx)(`div`,{className:`flex flex-col`,children:e.map((e,n)=>(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 border-b py-1.5 last:border-b-0`,children:[(0,U.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,U.jsx)(`span`,{className:`font-mono text-xs`,children:e.group===void 0?e.name:`${e.group}/${e.name}`}),e.missing?(0,U.jsx)(`span`,{className:`text-xs text-destructive`,children:`directory is gone`}):null]}),(0,U.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-muted-foreground`,children:e.path}),(0,U.jsx)(O,{variant:`ghost`,size:`icon-sm`,"aria-label":`Remove ${e.name}`,onClick:()=>t(n),children:(0,U.jsx)(zn,{"aria-hidden":!0})})]})]},e.path))})})}function Nr({candidates:e,hasRoot:t,onAdd:n}){return t?(0,U.jsx)(Ie,{title:`Found beneath the Project Root · ${e.length}`,description:`Repositories Flow can see but is not offering. Add the ones you work in.`,children:e.length===0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Nothing left to add. Either everything found is already a Project, or the Project Root holds no git repositories within three levels.`}):(0,U.jsx)(`div`,{className:`flex flex-col gap-2`,children:Hn(e).map(e=>(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e.group===void 0?null:(0,U.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:e.group}),(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.items.map(e=>(0,U.jsxs)(O,{variant:`outline`,size:`sm`,className:`font-mono text-xs font-normal`,onClick:()=>n(e.path),children:[(0,U.jsx)(Pn,{"aria-hidden":!0}),e.name]},e.path))})]},e.group??``))})}):null}function Pr(e){let[t,n]=(0,H.useState)(void 0),r=(0,H.useRef)(``);return(0,H.useEffect)(()=>{if(r.current=e,!Vn(e)){n(void 0);return}let t=new AbortController,i=setTimeout(()=>{(async()=>{try{let i=await p(`/api/directories?q=${encodeURIComponent(e)}`,{signal:t.signal});if(!i.ok)return;let a=await i.json();a.query===r.current&&n(a)}catch{}})()},150);return()=>{t.abort(),clearTimeout(i)}},[e]),t}function Fr({onAdd:e}){let[t,n]=(0,H.useState)(``),r=Pr(t),i=Bn(t);return(0,U.jsxs)(Ie,{title:`Add any directory`,description:(0,U.jsxs)(U.Fragment,{children:[`Type a name to search beneath the Project Root — repositories included, so`,` `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`packages/api`}),` inside a monorepo is reachable. Start with `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`/`}),` or`,` `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`~`}),` to complete a path anywhere on this machine instead.`]}),children:[(0,U.jsx)(he,{className:`font-mono`,value:t,onChange:e=>n(e.target.value),placeholder:`api, or /home/you/elsewhere`,spellCheck:!1}),r===void 0?null:r.paths.length===0?(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i===`completion`?`No directory there.`:`Nothing beneath the Project Root matches.`}):(0,U.jsxs)(`div`,{className:`flex flex-col`,children:[(0,U.jsxs)(`span`,{className:`pb-1 text-xs text-muted-foreground`,children:[i===`completion`?`Directories here`:`Found beneath the Project Root`,r.truncated?` — showing the first few, keep typing`:null]}),r.paths.map(t=>(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b py-1 last:border-b-0`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:t}),(0,U.jsxs)(O,{variant:`ghost`,size:`sm`,onClick:()=>{e(t),n(``)},children:[(0,U.jsx)(Pn,{"aria-hidden":!0}),`Add`]})]},t))]})]})}function Ir({current:e,saving:t,onSave:n,onSaved:r}){let[i,a]=(0,H.useState)(e);return(0,H.useEffect)(()=>a(e),[e]),(0,U.jsxs)(Ie,{title:`Project Root`,description:(0,U.jsxs)(U.Fragment,{children:[`The directory Flow looks beneath for candidates, and the one it reports as its default Scope. Absolute, or starting with`,` `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`~`}),`. A Project outside it can still be added by path.`]}),children:[(0,U.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:`Where your repositories live`}),(0,U.jsx)(he,{className:`font-mono`,value:i,onChange:e=>a(e.target.value),placeholder:`~/workspace`,spellCheck:!1})]}),(0,U.jsx)(de,{dirty:i.trim()!==e,saving:t,onSave:()=>{(async()=>{let e=i.trim()===``?`Project Root cleared.`:`Project Root saved.`;await n({projects:{root:i.trim()}},e)&&await r()})()},onReset:()=>a(e)})]})}var Lr=H.createContext(void 0);function Rr(e){let t=H.useContext(Lr);if(!e&&t===void 0)throw Error(B(27));return t}var zr=H.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,s=Rr(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`),d={open:c,transitionStatus:s.useState(`transitionStatus`)};return j(`div`,e,{state:d,ref:[s.context.backdropRef,t],stateAttributesMapping:pt,props:[{role:`presentation`,hidden:!u,style:{userSelect:`none`,WebkitUserSelect:`none`}},o],enabled:a||!l})}),Br=H.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,...c}=e,l=Rr(),u=l.useState(`open`),{getButtonProps:f,buttonRef:p}=R({disabled:a,native:o}),m={disabled:a};function h(e){u&&l.setOpen(!1,d(s,e.nativeEvent))}return j(`button`,e,{state:m,ref:[t,p],props:[{onClick:h},c,f]})}),Vr=H.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=Rr(),c=xe(a);return s.useSyncedValueWithCleanup(`descriptionElementId`,c),j(`p`,e,{ref:t,props:[{id:c},o]})}),Hr=H.createContext(void 0);function Ur(){let e=H.useContext(Hr);if(e===void 0)throw Error(B(26));return e}var Wr={...$e,...Ee,nestedDialogOpen(e){return e?{"data-nested-dialog-open":``}:null}},Gr=H.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,initialFocus:o,...s}=e,c=Rr(),l=c.useState(`descriptionElementId`),u=c.useState(`disablePointerDismissal`),d=c.useState(`floatingRootContext`),f=c.useState(`popupProps`),p=c.useState(`modal`),m=c.useState(`mounted`),h=c.useState(`nested`),g=c.useState(`nestedOpenDialogCount`),_=c.useState(`open`),v=c.useState(`openMethod`),y=c.useState(`titleElementId`),b=c.useState(`transitionStatus`),x=c.useState(`role`),S=d.useState(`floatingId`);Ur(),we({open:_,ref:c.context.popupRef,onComplete(){_&&c.context.onOpenChangeComplete?.(!0)}});let C=o===void 0?_t(c.context.popupRef):o,w=g>0,T=c.useStateSetter(`popupElement`),E=j(`div`,e,{state:{open:_,nested:h,transitionStatus:b,nestedDialogOpen:w},props:[f,{id:S,"aria-labelledby":y,"aria-describedby":l,role:x,...wt,hidden:!m,onKeyDown(e){st.has(e.key)&&e.stopPropagation()},style:{"--nested-dialogs":g}},s],ref:[t,c.context.popupRef,T],stateAttributesMapping:Wr});return(0,U.jsx)(ct,{context:d,openInteractionType:v,disabled:!m,closeOnFocusOut:!u,initialFocus:C,returnFocus:a,modal:p!==!1,restoreFocus:`popup`,children:E})}),Kr=H.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=Rr(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,U.jsx)(Hr.Provider,{value:n,children:(0,U.jsxs)(u,{ref:t,...r,children:[a&&o===!0&&(0,U.jsx)(nt,{ref:i.context.internalBackdropRef,inert:Me(!s)}),e.children]})}):null});function qr({store:e,parentContext:t,isDrawer:n}){let r=e.useState(`open`),i=e.useState(`disablePointerDismissal`),a=e.useState(`modal`),o=e.useState(`popupElement`),s=e.useState(`floatingRootContext`),[c,l]=H.useState(0),[u,d]=H.useState(0),f=c===0,p=gt(s,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?`intentional`:{mouse:a===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(t){if(!e.context.outsidePressEnabledRef.current||`button`in t&&t.button!==0)return!1;if(`touches`in t){if(t.type===`touchend`){if(t.changedTouches.length!==1||t.touches.length!==0)return!1}else if(t.touches.length!==1)return!1}let n=Ae(t);if(f&&!i){if(a){let t=e.context.internalBackdropRef.current,r=e.context.backdropRef.current;return t||r?t===n||r===n||Te(n,o)&&!n?.hasAttribute(`data-base-ui-portal`):!0}return!0}return!1},escapeKey:f});return tt(r&&a===!0,o),e.useContextCallback(`onNestedDialogOpen`,(e,t)=>{l(e),d(t)}),V(()=>(t?.onNestedDialogOpen&&(r?t.onNestedDialogOpen(c+1,u+ +!!n):t.onNestedDialogOpen(0,0)),()=>{t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(0,0)}),[n,r,c,u,t]),bt(e,{activeTriggerProps:p.reference,inactiveTriggerProps:p.trigger,popupProps:p.floating,nestedOpenDialogCount:c,nestedOpenDrawerCount:u}),null}var Jr={...ur,modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role},Yr=class extends f{constructor(e,t,n){let r=new Ft,i=Xr(e,r,t,n);super(i,Zr(r),Jr)}setOpen=(e,t)=>{if(t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let n={open:e};Ot(n,e,t.trigger),this.update(n)}};function Xr(e,t,n,r=!1){let i={...rr(),modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:`dialog`,...e};return i.floatingRootContext=ir(t,n,r),i}function Zr(e){return{popupRef:H.createRef(),backdropRef:H.createRef(),internalBackdropRef:H.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}function Qr(e,t){let{children:n,open:r,defaultOpen:i=!1,onOpenChange:a,onOpenChangeComplete:o,disablePointerDismissal:s=!1,modal:c=!0,actionsRef:l,handle:u,triggerId:f,defaultTriggerId:p=null}=t,m=e===`drawer`,h=e===`alert-dialog`,g=h?!0:c,_=h||s,v=h?`alertdialog`:`dialog`,y=Rr(!0),b={modal:g,disablePointerDismissal:_,nested:y!=null,role:v},x=Nt((e,t)=>new Yr({open:i,openProp:r,activeTriggerId:p,triggerIdProp:f,...b},e,t),!0);x.useControlledProp(`openProp`,r),x.useControlledProp(`triggerIdProp`,f),x.useSyncedValues(b),x.useContextCallback(`onOpenChange`,a),x.useContextCallback(`onOpenChangeComplete`,o);let S=x.useState(`open`),C=x.useState(`mounted`),w=x.useState(`payload`);kt(x,S),Bt(x);let{forceUnmount:T}=vt(S,x);H.useImperativeHandle(l,()=>({unmount:T,close:()=>x.setOpen(!1,d(D))}),[T,x]);let E=S||C;return(0,U.jsxs)(Lr.Provider,{value:x,children:[u&&(0,U.jsx)(ht,{handle:u,store:x}),E&&(0,U.jsx)(qr,{store:x,parentContext:y?.context,isDrawer:m}),typeof n==`function`?n({payload:w}):n]})}function $r(e){return Qr(`dialog`,e)}var ei=H.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=Rr(),c=xe(a);return s.useSyncedValueWithCleanup(`titleElementId`,c),j(`h2`,e,{ref:t,props:[{id:c},o]})}),ti=H.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,payload:c,handle:l,...u}=e,d=Rr(!0),f=fr(l)??d;if(!f)throw Error(B(79));let p=xe(s),m=f.useState(`floatingRootContext`),h=f.useState(`isOpenedByTrigger`,p),g=f.useState(`triggerPopupId`,p),_=H.useRef(null),{registerTrigger:v,isMountedByThisTrigger:y}=St(p,_,f,{payload:c}),{getButtonProps:b,buttonRef:x}=R({disabled:a,native:o}),S=Ut(m),C=Tt(()=>f.select(`open`),e=>{f.set(`openMethod`,e)}),w={disabled:a,open:h},T=f.useState(`triggerProps`,y);return j(`button`,e,{state:w,ref:[x,t,v,_],props:[S.reference,T,C,{[k]:``,id:p,"aria-haspopup":`dialog`,"aria-expanded":h,"aria-controls":g},u,b],stateAttributesMapping:mt})});function ni({...e}){return(0,U.jsx)($r,{"data-slot":`dialog`,...e})}function ri({...e}){return(0,U.jsx)(ti,{"data-slot":`dialog-trigger`,...e})}function ii({...e}){return(0,U.jsx)(Kr,{"data-slot":`dialog-portal`,...e})}function ai({className:e,...t}){return(0,U.jsx)(zr,{"data-slot":`dialog-overlay`,className:g(`fixed inset-0 isolate z-50 bg-black/30 duration-100 supports-backdrop-filter:backdrop-blur-sm data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function oi({className:e,children:t,showCloseButton:n=!0,...r}){return(0,U.jsxs)(ii,{children:[(0,U.jsx)(ai,{}),(0,U.jsxs)(Gr,{"data-slot":`dialog-content`,className:g(`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-6 rounded-[min(var(--radius-4xl),24px)] bg-popover p-6 text-sm text-popover-foreground shadow-xl ring-1 ring-foreground/5 duration-100 outline-none sm:max-w-md dark:ring-foreground/10 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r,children:[t,n&&(0,U.jsxs)(Br,{"data-slot":`dialog-close`,render:(0,U.jsx)(O,{variant:`ghost`,className:`absolute top-4 right-4 bg-secondary`,size:`icon-sm`}),children:[(0,U.jsx)(zn,{}),(0,U.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function si({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`dialog-header`,className:g(`flex flex-col gap-1.5`,e),...t})}function ci({className:e,showCloseButton:t=!1,children:n,...r}){return(0,U.jsxs)(`div`,{"data-slot":`dialog-footer`,className:g(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...r,children:[n,t&&(0,U.jsx)(Br,{render:(0,U.jsx)(O,{variant:`outline`}),children:`Close`})]})}function li({className:e,...t}){return(0,U.jsx)(ei,{"data-slot":`dialog-title`,className:g(`font-heading text-base leading-none font-medium`,e),...t})}function ui({className:e,...t}){return(0,U.jsx)(Vr,{"data-slot":`dialog-description`,className:g(`text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}function di({session:e,onClose:t}){let{connection:n,config:r}=Ue(),[i,a]=(0,H.useState)(e.suggestedScope??``),[o,s]=(0,H.useState)(()=>yn(e.scope,r.projectList??[])??``),[c,l]=(0,H.useState)(void 0),[u,d]=(0,H.useState)(!1),f=i.trim()!==``&&(!e.worktree||o.trim()!==``),p=async()=>{d(!0),l(void 0);try{await n.command({type:`relocate`,sessionId:e.id,scope:i.trim(),...e.worktree?{repo:o.trim()}:{}}),await n.command({type:`revive`,sessionId:e.id}),t()}catch(e){l(e instanceof Error?e.message:String(e))}finally{d(!1)}};return(0,U.jsx)(ni,{open:!0,onOpenChange:e=>e?void 0:t(),children:(0,U.jsxs)(oi,{className:`sm:max-w-lg`,children:[(0,U.jsxs)(si,{children:[(0,U.jsx)(li,{children:`Relocate Agent Session`}),(0,U.jsx)(ui,{children:`Its Scope no longer exists. Choose where its files are now.`})]}),(0,U.jsx)(ne,{label:`Old Scope`,children:e.scope}),(0,U.jsx)(fi,{label:`Scope`,value:i,onChange:a}),e.worktree?(0,U.jsx)(fi,{label:`Repository`,value:o,onChange:s}):null,c===void 0?null:(0,U.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:c}),(0,U.jsxs)(ci,{children:[(0,U.jsx)(O,{variant:`outline`,onClick:t,children:`Cancel`}),(0,U.jsx)(O,{disabled:!f||u,onClick:()=>void p(),children:`Relocate and revive`})]})]})})}function fi({label:e,value:t,onChange:n}){let r=Pr(t),i=(0,H.useId)();return(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(`label`,{htmlFor:i,className:`text-sm font-medium`,children:e}),(0,U.jsx)(he,{id:i,className:`font-mono`,value:t,onChange:e=>n(e.target.value),placeholder:`/path/to/folder`,spellCheck:!1}),r?.paths.filter(e=>e!==t).slice(0,5).map(e=>(0,U.jsx)(O,{variant:`ghost`,size:`sm`,className:`justify-start font-mono text-xs`,onClick:()=>n(e),children:e},e))]})}var pi=new Map;function mi(e,t){pi.set(e,structuredClone(t))}function hi(e){let t=pi.get(e);return t&&structuredClone(t)}function gi(e){pi.delete(e)}function _i(e){for(let t of pi.keys())e.has(t)||pi.delete(t)}var vi=2e3,yi=3e4,bi=(0,H.createContext)(void 0);function xi(){let e=(0,H.useContext)(bi);if(!e)throw Error(`useAgentSessions outside SessionsProvider`);return e}function Si({children:e}){let{connection:t}=Ue(),[n,r]=(0,H.useState)([]),[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(void 0),c=(0,H.useRef)(()=>{});(0,H.useEffect)(()=>{let e=!1,n,i,o=0,s=0,l=0,u=e=>{n&&clearTimeout(n),n=setTimeout(()=>void d(),e)},d=async()=>{if(e||document.hidden)return;i?.abort(),i=new AbortController;let n=++o;try{let i=await t.listSessions();if(e||n<=s)return;s=n,l=0,_i(new Set(i.map(e=>e.id))),r(i),a(!0),u(vi)}catch{if(e)return;a(!0),l+=1,u(Math.min(yi,vi*2**l))}},f=()=>{document.hidden||d()};return c.current=()=>void d(),d(),document.addEventListener(`visibilitychange`,f),()=>{e=!0,c.current=()=>{},n&&clearTimeout(n),i?.abort(),document.removeEventListener(`visibilitychange`,f)}},[t]);let l=(0,H.useCallback)(()=>c.current(),[]),u=n.find(e=>e.id===o);return(0,U.jsxs)(bi.Provider,{value:{sessions:n,loaded:i,nudge:l,relocate:s},children:[e,u?(0,U.jsx)(di,{session:u,onClose:()=>{s(void 0),l()}}):null]})}function Ci(){let{connection:e}=Ue(),{nudge:t,relocate:n}=xi();return(0,H.useCallback)(async r=>{try{let n=await e.command(r);return t(),n}catch(e){if(e.code===`scope_missing`&&`sessionId`in r){n(r.sessionId),t();return}ze.error(`${r.type} failed`,e instanceof Error?e.message:String(e)),t();return}},[e,t,n])}var wi=[`general`,`projects`,`permissions`,`providers`,`appearance`,`keyboard`,`workflows`,`secrets`,`mcp`],Ti={sessionId:void 0};function Ei(e){let[t=``,n=``]=e.replace(/^#\/?/,``).split(`?`,2),r=t.split(`/`).filter(e=>e!==``);if(r[0]===`settings`)return{sessionId:void 0,settings:ki(r[1])};let i=Di(r),a=new URLSearchParams(n).get(`settings`);return a===null?i:{...i,settings:ki(a)}}function Di(e){if(e[0]===`spend`)return{sessionId:void 0,spend:!0};if(e[0]===`schedules`){let t={sessionId:void 0,schedules:!0};if(e[1]===`occurrences`){let n=Ai(e[2]??``);return n?{...t,occurrenceId:n}:t}let n=Ai(e[1]??``);return n?{...t,scheduleId:n}:t}if(e[0]===`new`&&e[1])return{sessionId:void 0,backend:Ai(e[1])};if(e[0]!==`s`||e[1]===void 0)return Ti;let t=Ai(e[1]);return{sessionId:t===``?void 0:t}}function Oi(e){let t=e.spend?`#/spend`:e.schedules?`#/schedules${e.occurrenceId?`/occurrences/${encodeURIComponent(e.occurrenceId)}`:e.scheduleId?`/${encodeURIComponent(e.scheduleId)}`:``}`:e.sessionId===void 0?e.backend?`#/new/${encodeURIComponent(e.backend)}`:``:`#/s/${encodeURIComponent(e.sessionId)}`;return e.settings===void 0?t:`${t||`#/`}?settings=${e.settings}`}function ki(e){return wi.find(t=>t===Ai(e??``))??wi[0]}function Ai(e){try{return decodeURIComponent(e)}catch{return``}}function ji(e){return e.title||e.id}var Mi=60,Ni=[{key:`description`,shape:`text`},{key:`command`,shape:`text`},{key:`questions`,shape:`questions`},{key:`file_path`,shape:`path`},{key:`notebook_path`,shape:`path`},{key:`pattern`,shape:`text`},{key:`url`,shape:`text`},{key:`query`,shape:`text`},{key:`path`,shape:`path`},{key:`prompt`,shape:`text`}],Pi=Ni.filter(({key:e})=>e!==`description`);function Fi(e){return Li(e,Mi)}function Ii(e){return Li(e,1/0,Pi)}function Li(e,t,n=Ni){if(!e||typeof e!=`object`)return;let r=e;for(let e of n){let n=r[e.key];if(e.shape===`questions`){let e=Ri(n,t);if(e!==void 0)return e;continue}if(typeof n==`string`&&n.trim()!==``)return e.shape===`path`?Bi(n.trim(),t):zi(n,t)}let i=Object.values(r).filter(e=>typeof e==`string`),a=i.length===1?i[0]:void 0;return a&&a.trim()!==``?zi(a,t):void 0}function Ri(e,t){if(!Array.isArray(e)||e.length===0)return;let n=e[0];if(!n||typeof n!=`object`)return;let r=n.question;if(typeof r!=`string`||r.trim()===``)return;let i=e.length-1;return zi(i>0?`${r} (+${i} more)`:r,t)}function zi(e,t){let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}function Bi(e,t){return e.length<=t?e:`…${e.slice(-(t-1))}`}var Vi=H.createContext(void 0);function Hi(e){let t=H.useContext(Vi);if(t===void 0&&!e)throw Error(B(72));return t}var Ui={...ur,disabled:e=>e.disabled,instantType:e=>e.instantType,isInstantPhase:e=>e.isInstantPhase,trackCursorAxis:e=>e.trackCursorAxis,disableHoverablePopup:e=>e.disableHoverablePopup,lastOpenChangeReason:e=>e.openChangeReason,closeOnClick:e=>e.closeOnClick,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},Wi=class extends f{constructor(e,t,n){let r=new Ft;super(Gi(e,r,t,n),Ki(r),Ui)}setOpen=(e,t)=>{Mt(this,e,t,{extraState:{openChangeReason:t.reason}})};cancelPendingOpen(e){this.state.floatingRootContext.dispatchOpenChange(!1,d(z,e))}};function Gi(e,t,n,r=!1){let i={...rr(),disabled:!1,instantType:void 0,isInstantPhase:!1,trackCursorAxis:`none`,disableHoverablePopup:!1,openChangeReason:null,closeOnClick:!0,closeDelay:0,adaptiveOrigin:void 0,...e};return i.floatingRootContext=ir(t,n,r),i}function Ki(e){return{popupRef:H.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e}}var qi=ye(function(e){let{disabled:t=!1,defaultOpen:n=!1,open:r,disableHoverablePopup:i=!1,trackCursorAxis:a=`none`,actionsRef:o,onOpenChange:s,onOpenChangeComplete:c,handle:l,triggerId:u,defaultTriggerId:f=null,children:p}=e,m=Nt((e,t)=>new Wi({open:n,openProp:r,activeTriggerId:f,triggerIdProp:u},e,t));m.useControlledProp(`openProp`,r),m.useControlledProp(`triggerIdProp`,u),m.useContextCallback(`onOpenChange`,s),m.useContextCallback(`onOpenChangeComplete`,c);let h=m.useState(`open`),g=!t&&h,_=m.useState(`activeTriggerId`),v=m.useState(`mounted`),y=m.useState(`payload`);m.useSyncedValues({trackCursorAxis:a,disableHoverablePopup:i,disabled:t}),Bt(m,{closeOnActiveTriggerUnmount:!0});let{forceUnmount:b,transitionStatus:x}=vt(g,m),S=m.useState(`isInstantPhase`),C=m.useState(`instantType`),w=m.useState(`lastOpenChangeReason`),T=H.useRef(null);V(()=>{h&&t&&m.setOpen(!1,d(_e))},[h,t,m]),V(()=>{x===`ending`&&w===`none`||x!==`ending`&&S?(C!==`delay`&&(T.current=C),m.set(`instantType`,`delay`)):T.current!==null&&(m.set(`instantType`,T.current),T.current=null)},[x,S,w,C,m]),V(()=>{g&&(_??m.set(`payload`,void 0))},[m,_,g]),H.useImperativeHandle(o,()=>({unmount:b,close:()=>m.setOpen(!1,d(D))}),[b,m]);let E=g||v||!t&&a!==`none`;return(0,U.jsxs)(Vi.Provider,{value:m,children:[l&&(0,U.jsx)(ht,{handle:l,store:m}),E&&(0,U.jsx)(Ji,{store:m,disabled:t,trackCursorAxis:a}),typeof p==`function`?p({payload:y}):p]})});function Ji({store:e,disabled:t,trackCursorAxis:n}){let r=e.useState(`floatingRootContext`),i=gt(r,{enabled:!t,referencePress:()=>e.select(`closeOnClick`)}),a=tr(r,{enabled:!t&&n!==`none`,axis:n===`none`?void 0:n}),o=H.useMemo(()=>ee(a.reference,i.reference),[a.reference,i.reference]);return bt(e,{activeTriggerProps:o,inactiveTriggerProps:o,popupProps:i.floating??L}),null}var Yi=H.createContext(void 0);function Xi(){return H.useContext(Yi)}var Zi=`data-base-ui-tooltip-trigger`;function Qi(e){if(`composedPath`in e){let t=e.composedPath();for(let e=0;e<t.length;e+=1){let n=t[e];if(Fe(n))return n}}let t=e.target;return Fe(t)?t:null}function $i(e){let t=e;for(;t;){let e=t.closest(`[${Zi}]`);if(e)return e;let n=t.getRootNode();t=`host`in n&&Fe(n.host)?n.host:null}return null}var ea=c(function(e,t){let{render:n,className:r,style:i,handle:a,payload:o,disabled:s,delay:c,closeOnClick:l=!0,closeDelay:u,id:f,...p}=e,m=Hi(!0),h=fr(a)??m;if(!h)throw Error(B(82));let g=xe(f),v=h.useState(`isTriggerActive`,g),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`floatingRootContext`),S=H.useRef(null),C=c??600,w=u??0,{registerTrigger:T,isMountedByThisTrigger:E}=St(g,S,h,{payload:o,closeOnClick:l,closeDelay:w}),D=Xi(),{delayRef:O,isInstantPhase:k,hasProvider:A}=Qn(b,{open:y}),M=yr(b);h.useSyncedValue(`isInstantPhase`,k);let N=h.useState(`disabled`),P=s??N,F=Dt(P),I=h.useState(`trackCursorAxis`),L=h.useState(`disableHoverablePopup`),R=H.useRef(!1),ee=Be(),z=H.useRef(void 0);function te(){return A?Gn(O.current,`open`)===0?0:c??D??600:C}function V(e){let t=S.current;if(!t||!e)return!1;let n=$i(e);return n!==null&&n!==t&&Te(t,n)}function ne(e){let t=V(e);return R.current=t,t&&(M.openChangeTimeout.clear(),M.restTimeout.clear(),M.restTimeoutPending=!1,ee.clear()),t}let re=Sr(b,{enabled:!P,mouseOnly:!0,move:!1,handleClose:!L&&I!==`both`?Ar():null,restMs:te,delay(){return u==null&&A?{close:Gn(O.current,`close`)}:{close:w}},triggerElementRef:S,isActiveTrigger:v,isClosing:()=>h.select(`transitionStatus`)===`ending`,shouldOpen(){return!R.current}}),ie=mr(b,{enabled:!P}).reference,ae=e=>{let t=R.current,n=Qi(e),r=ne(n),i=S.current,a=i&&n&&Te(i,n);if(r&&h.select(`open`)&&h.select(`lastOpenChangeReason`)===`trigger-hover`){h.setOpen(!1,d(_,e));return}if(t&&!r&&a&&!F.current&&!h.select(`open`)&&i&&x(z.current)){let t=()=>{!R.current&&!F.current&&!h.select(`open`)&&h.setOpen(!0,d(_,e,i))},n=te();n===0?(ee.clear(),t()):ee.start(n,t)}},oe=h.useState(`triggerProps`,E);return j(`button`,e,{state:{open:y},ref:[t,T,S],props:[re,ie,E||I!==`none`?oe:void 0,{onMouseOver(e){ae(e.nativeEvent)},onFocus(e){V(Qi(e.nativeEvent))&&e.preventBaseUIHandler()},onMouseLeave(){R.current=!1,ee.clear(),z.current=void 0},onPointerEnter(e){z.current=e.pointerType},onPointerDown(e){z.current=e.pointerType,h.set(`closeOnClick`,l),l&&!h.select(`open`)&&h.cancelPendingOpen(e.nativeEvent)},onClick(e){l&&!h.select(`open`)&&h.cancelPendingOpen(e.nativeEvent)},id:g,"data-trigger-disabled":P?``:void 0,[Zi]:P?void 0:``},p],stateAttributesMapping:mt})}),ta=H.createContext(void 0);function na(){let e=H.useContext(ta);if(e===void 0)throw Error(B(70));return e}var ra=H.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return Hi().useState(`mounted`)||n?(0,U.jsx)(ta.Provider,{value:n,children:(0,U.jsx)(M,{ref:t,...r})}):null}),ia=H.createContext(void 0);function aa(){let e=H.useContext(ia);if(e===void 0)throw Error(B(71));return e}var oa=H.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a=`absolute`,side:o=`top`,align:s=`center`,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=Pe,style:g,..._}=e,v=Hi(),y=na(),b=v.useState(`open`),x=v.useState(`mounted`),S=v.useState(`trackCursorAxis`),C=v.useState(`disableHoverablePopup`),w=v.useState(`floatingRootContext`),T=v.useState(`instantType`),E=v.useState(`transitionStatus`),D=v.useState(`adaptiveOrigin`),O=ot({anchor:i,positionMethod:a,floatingRootContext:w,mounted:x,side:o,sideOffset:c,align:s,alignOffset:l,collisionBoundary:u,collisionPadding:d,sticky:p,arrowPadding:f,disableAnchorTracking:m,keepMounted:y,collisionAvoidance:h,adaptiveOrigin:D}),k=H.useMemo(()=>({open:b,side:O.side,align:O.align,anchorHidden:O.anchorHidden,instant:S===`none`?T:`tracking-cursor`}),[b,O.side,O.align,O.anchorHidden,S,T]),A=et(e,k,{styles:O.positionerStyles,transitionStatus:E,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!x,inert:!b||S===`both`||C});return(0,U.jsx)(ia.Provider,{value:O,children:A})}),sa=H.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Hi(),{side:s,align:c}=aa(),l=o.useState(`open`),u=o.useState(`instantType`),d=o.useState(`transitionStatus`),f=o.useState(`popupProps`),p=o.useState(`floatingRootContext`),m=o.useState(`disabled`),h=o.useState(`closeDelay`);we({open:l,ref:o.context.popupRef,onComplete(){l&&o.context.onOpenChangeComplete?.(!0)}}),br(p,{enabled:!m,closeDelay:h});let g=o.useStateSetter(`popupElement`);return j(`div`,e,{state:{open:l,side:s,align:c,instant:u,transitionStatus:d},ref:[t,o.context.popupRef,g],props:[wt,f,Pt(d),a],stateAttributesMapping:pt})}),ca=H.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Hi(),{arrowRef:s,side:c,align:l,arrowUncentered:u,arrowStyles:d}=aa(),f={open:o.useState(`open`),side:c,align:l,uncentered:u,instant:o.useState(`instantType`)};return j(`div`,e,{state:f,ref:[t,s],props:[{style:d,"aria-hidden":!0},a],stateAttributesMapping:$e})}),la=function(e){let{delay:t,closeDelay:n,timeout:r=400}=e,i=H.useMemo(()=>({open:t,close:n}),[t,n]);return(0,U.jsx)(Yi.Provider,{value:t,children:(0,U.jsx)(Zn,{delay:i,timeoutMs:r,children:e.children})})};function ua({delay:e=0,...t}){return(0,U.jsx)(la,{"data-slot":`tooltip-provider`,delay:e,...t})}function da({...e}){return(0,U.jsx)(qi,{"data-slot":`tooltip`,...e})}function fa({...e}){return(0,U.jsx)(ea,{"data-slot":`tooltip-trigger`,...e})}function pa({className:e,side:t=`top`,sideOffset:n=4,align:r=`center`,alignOffset:i=0,children:a,...o}){return(0,U.jsx)(ra,{children:(0,U.jsx)(oa,{align:r,alignOffset:i,side:t,sideOffset:n,className:`isolate z-50`,children:(0,U.jsxs)(sa,{"data-slot":`tooltip-content`,className:g(`z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-xl bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-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 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-lg data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...o,children:[a,(0,U.jsx)(ca,{className:`z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:translate-x-[1.5px] data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:translate-x-[-1.5px] data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:translate-x-[-1.5px] data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:translate-x-[1.5px] data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5`})]})})})}var ma=H.createContext(void 0);function ha(e){let t=H.useContext(ma);if(t===void 0&&!e)throw Error(B(33));return t}var ga=H.createContext(void 0);function _a(e){let t=H.useContext(ga);if(t===void 0&&!e)throw Error(B(36));return t}var va=H.createContext(void 0);function ya(e=!0){let t=H.useContext(va);if(t===void 0&&!e)throw Error(B(25));return t}function ba(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,{events:l}=a.useState(`floatingTreeRoot`),u=a.useState(`open`),d=ya(!0),f=d!==void 0;return H.useMemo(()=>({id:r,role:`menuitem`,tabIndex:u&&n?0:-1,onKeyDown(e){e.key===` `&&o?.current&&e.preventDefault()},onMouseMove(e){i&&l.emit(`itemhover`,{nodeId:i,target:e.currentTarget})},onClick(e){t&&l.emit(`close`,{domEvent:e,reason:We})},onMouseUp(e){if(d){let t=d.initialCursorPointRef.current;if(d.initialCursorPointRef.current=null,f&&t&&Math.abs(e.clientX-t.x)<=1&&Math.abs(e.clientY-t.y)<=1||f&&!He&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!f||e.button===2)&&c.type===`regular-item`&&m(s.current,e,{detail:1})}}),[t,n,r,l,i,u,a,o,s,d,f,c])}var xa={type:`regular-item`};function Sa(e){let{closeOnClick:t,disabled:n,highlighted:r,id:i,store:a,typingRef:o=a.context.typingRef,nativeButton:s,itemMetadata:c,nodeId:l}=e,u=H.useRef(null),{getButtonProps:d,buttonRef:f}=R({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=ba({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=H.useCallback(e=>ee(p,{onMouseEnter(){c.type===`submenu-trigger`&&c.setActive()}},e,d),[p,d,c]),h=I(u,f);return H.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var Ca=H.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!0,style:l,...u}=e,d=Et({guess:!0,label:a}),f=ha(!0),p=xe(i),{store:m}=_a(),h=m.useState(`disabled`),g=s||h,_=m.useState(`isActive`,d.index),v=m.useState(`itemProps`),{getItemProps:y,itemRef:b}=Sa({closeOnClick:c,disabled:g,highlighted:_,id:p,store:m,nativeButton:o,nodeId:f?.context.nodeId,itemMetadata:xa});return j(`div`,e,{state:{disabled:g,highlighted:_},props:[v,u,y],ref:[b,t,d.ref]})}),wa=H.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,{store:s}=_a(),{side:c,align:l}=ha(),u=it(!0)!=null,f=s.useState(`open`),p=s.useState(`transitionStatus`),m=s.useState(`popupProps`),h=s.useState(`mounted`),g=s.useState(`instantType`),_=s.useState(`activeTriggerElement`),v=s.useState(`parent`),y=s.useState(`lastOpenChangeReason`),b=s.useState(`rootId`),x=s.useState(`floatingRootContext`),S=s.useState(`floatingTreeRoot`),C=s.useState(`closeDelay`),w=s.useState(`hoverEnabled`),T=s.useState(`disabled`),E=s.useState(`openMethod`),D=v.type===`context-menu`;we({open:f,ref:s.context.popupRef,onComplete(){f&&s.context.onOpenChangeComplete?.(!0)}}),H.useEffect(()=>{function e(e){s.setOpen(!1,d(e.reason,e.domEvent))}return S.events.on(`close`,e),()=>{S.events.off(`close`,e)}},[S.events,s]),br(x,{enabled:w&&!T&&!D&&v.type!==`menubar`,closeDelay:C});let O=s.useStateSetter(`popupElement`),k={transitionStatus:p,side:c,align:l,open:f,nested:v.type===`menu`,instant:g},A=j(`div`,e,{state:k,ref:[t,s.context.popupRef,O],stateAttributesMapping:pt,props:[m,{onKeyDown(e){u&&st.has(e.key)&&e.stopPropagation()}},Pt(p),o,{"data-rootownerid":b}]}),M=v.type===void 0||D;return(_||v.type===`menubar`&&y!==`outside-press`)&&(M=!0),(0,U.jsx)(ct,{context:x,openInteractionType:E,modal:D,disabled:!h,returnFocus:a===void 0?M:a,initialFocus:v.type!==`menu`,restoreFocus:!0,externalTree:v.type===`menubar`?void 0:S,previousFocusableElement:_,nextFocusableElement:v.type===void 0?s.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:v.type===void 0?s.context.beforeContentFocusGuardRef:void 0,children:A})}),Ta=H.createContext(void 0);function Ea(){let e=H.useContext(Ta);if(e===void 0)throw Error(B(32));return e}var Da=H.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i}=_a();return i.useState(`mounted`)||n?(0,U.jsx)(Ta.Provider,{value:n,children:(0,U.jsx)(u,{ref:t,...r})}):null}),Oa=H.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o,align:s,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:f=5,arrowPadding:p=5,sticky:m=!1,disableAnchorTracking:h=!1,collisionAvoidance:g=ce,style:_,...v}=e,{store:b}=_a(),x=Ea(),S=ya(!0),C=b.useState(`parent`),w=b.useState(`floatingRootContext`),T=b.useState(`floatingTreeRoot`),E=b.useState(`mounted`),D=b.useState(`open`),O=b.useState(`modal`),k=b.useState(`openMethod`),A=b.useState(`activeTriggerElement`),j=b.useState(`transitionStatus`),M=b.useState(`positionerElement`),N=b.useState(`instantType`),P=b.useState(`adaptiveOrigin`),F=b.useState(`lastOpenChangeReason`),I=b.useState(`floatingNodeId`),L=b.useState(`floatingParentNodeId`),R=w.useState(`domReferenceElement`),ee=H.useRef(null),z=ke(M),B=n,te=c,ne=l,re=s,ie=g;C.type===`context-menu`&&(B=n??C.context?.anchor,re??=`start`,!o&&re!==`center`&&(ne=e.alignOffset??2,te=e.sideOffset??-5));let ae=o,oe=re;C.type===`menu`?(ae??=`inline-end`,oe??=`start`,ie=e.collisionAvoidance??Pe):C.type===`menubar`&&(ae??=C.context.orientation===`vertical`?`inline-end`:`bottom`,oe??=`start`);let se=C.type===`context-menu`,le=ot({anchor:B,floatingRootContext:w,positionMethod:S?`fixed`:r,mounted:E,side:ae,sideOffset:te,align:oe,alignOffset:ne,arrowPadding:se?0:p,collisionBoundary:u,collisionPadding:f,sticky:m,nodeId:I,keepMounted:x,disableAnchorTracking:h,collisionAvoidance:ie,shift:se?{crossAxis:!(`side`in ie&&ie.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:T,adaptiveOrigin:P});H.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===I&&b.set(`hoverEnabled`,!1),e.nodeId!==I&&e.parentNodeId===b.select(`floatingParentNodeId`)&&b.setOpen(!1,d(y)))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[b,T.events,I]),H.useEffect(()=>{if(b.select(`floatingParentNodeId`)==null)return;function e(e){if(e.open||e.nodeId!==b.select(`floatingParentNodeId`))return;let t=e.reason??`sibling-open`;b.setOpen(!1,d(t))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[T.events,b]);let ue=Be();H.useEffect(()=>{D||ue.clear()},[D,ue]),H.useEffect(()=>{function e(e){if(!(!D||e.nodeId!==b.select(`floatingParentNodeId`))){if(e.target&&A&&A!==e.target){let e=b.select(`closeDelay`);e>0?ue.isStarted()||ue.start(e,()=>{b.setOpen(!1,d(y))}):b.setOpen(!1,d(y))}else ue.clear()}}return T.events.on(`itemhover`,e),()=>{T.events.off(`itemhover`,e)}},[T.events,D,A,b,ue]),H.useEffect(()=>{let e={open:D,nodeId:I,parentNodeId:L,reason:b.select(`lastOpenChangeReason`)};T.events.emit(`menuopenchange`,e)},[T.events,D,b,I,L]),V(()=>{let e=R,t=ee.current;if(e&&(ee.current=e),t&&e&&e!==t){b.set(`instantType`,void 0);let e=new AbortController;return z(()=>{b.set(`instantType`,`trigger-change`)},e.signal),()=>{e.abort()}}},[R,z,b]);let de={open:D,side:le.side,align:le.align,anchorHidden:le.anchorHidden,nested:C.type===`menu`,instant:N},fe=C.type===`menubar`&&C.context.modal;Ze(D&&(fe||O&&F!==`trigger-hover`),k===`touch`,M,A);let pe=et(e,de,{styles:le.positionerStyles,transitionStatus:j,props:v,refs:[t,b.useStateSetter(`positionerElement`)],hidden:!E,inert:!D}),me=E&&C.type!==`menu`&&(C.type!==`menubar`&&O&&F!==`trigger-hover`||C.type===`menubar`&&C.context.modal),he=null;return C.type===`menubar`?he=C.context.contentElement:C.type===void 0&&(he=A),(0,U.jsxs)(ma.Provider,{value:le,children:[me&&(0,U.jsx)(nt,{ref:C.type===`context-menu`||C.type===`nested-context-menu`?C.context.internalBackdropRef:null,inert:Me(!D),cutout:he}),(0,U.jsx)(Je,{id:I,children:(0,U.jsx)(Ye,{elementsRef:b.context.itemDomElements,labelsRef:b.context.itemLabels,children:pe})})]})}),ka=H.createContext(null);function Aa(e){let t=H.useContext(ka);if(t===null&&!e)throw Error(B(5));return t}var ja={...ur,disabled:e=>e.parent.type===`menubar`&&e.parent.context.disabled||e.disabled,modal:e=>(e.parent.type===void 0||e.parent.type===`context-menu`)&&(e.modal??!0),openMethod:e=>e.openMethod,allowMouseEnter:e=>e.allowMouseEnter,highlightItemOnHover:e=>e.highlightItemOnHover,parent:e=>e.parent,rootId:e=>e.parent.type===`menu`?e.parent.store.select(`rootId`):e.parent.type===void 0?e.rootId:e.parent.context.rootId,activeIndex:e=>e.activeIndex,isActive:(e,t)=>e.activeIndex===t,hoverEnabled:e=>e.hoverEnabled,instantType:e=>e.instantType,lastOpenChangeReason:e=>e.openChangeReason,floatingTreeRoot:e=>e.parent.type===`menu`?e.parent.store.select(`floatingTreeRoot`):e.floatingTreeRoot,floatingNodeId:e=>e.floatingNodeId,floatingParentNodeId:e=>e.floatingParentNodeId,itemProps:e=>e.itemProps,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin,keyboardEventRelay:e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type===`menu`)return e.parent.store.select(`keyboardEventRelay`)}},Ma=class extends f{constructor(e){super({...Pa(),...e},Na(),ja),this.unsubscribeParentListener=this.observe(`parent`,e=>{if(this.unsubscribeParentListener?.(),e.type===`menu`){let t=e.store.select(`rootId`),n=e.store.select(`floatingTreeRoot`),r=e.store.select(`keyboardEventRelay`);this.unsubscribeParentListener=e.store.subscribe(()=>{let i=e.store.select(`rootId`),a=e.store.select(`floatingTreeRoot`),o=e.store.select(`keyboardEventRelay`);(t!==i||n!==a||r!==o)&&(t=i,n=a,r=o,this.notifyAll())}),this.context.allowMouseUpTriggerRef=e.store.context.allowMouseUpTriggerRef;return}e.type!==void 0&&(this.context.allowMouseUpTriggerRef=e.context.allowMouseUpTriggerRef),this.unsubscribeParentListener=null})}setOpen(e,t){this.state.floatingRootContext.context.events.emit(`setOpen`,{open:e,eventDetails:t})}unsubscribeParentListener=null};function Na(){return{positionerRef:H.createRef(),popupRef:H.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:H.createRef(),beforeContentFocusGuardRef:H.createRef(),onOpenChangeComplete:void 0,triggerElements:new Ft}}function Pa(){return{...rr(),disabled:!1,modal:!0,openMethod:null,allowMouseEnter:!1,highlightItemOnHover:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new at,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:L,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0}}var Fa=H.createContext(void 0);function Ia(){return H.useContext(Fa)}var La=ye(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,defaultOpen:a=!1,disabled:o=!1,modal:s,loopFocus:c=!0,orientation:u=`vertical`,actionsRef:f,closeParentOnEsc:p=!1,handle:m,triggerId:h,defaultTriggerId:g=null,highlightItemOnHover:_=!0}=e,v=ya(!0),y=_a(!0),b=Aa(!0),x=Ia(),S=H.useMemo(()=>x&&y?{type:`menu`,store:y.store}:b?{type:`menubar`,context:b}:v&&!y?{type:`context-menu`,context:v}:{type:void 0},[v,y,b,x]),C=Ra({open:a,openProp:n,activeTriggerId:g,triggerIdProp:h,parent:S});C.useControlledProp(`openProp`,n),C.useControlledProp(`triggerIdProp`,h),C.useContextCallback(`onOpenChangeComplete`,i);let w=te(),T=te(),E=C.useState(`floatingTreeRoot`),O=ut(E),k=Qe(),j=C.useState(`open`),M=C.useState(`activeTriggerElement`),N=C.useState(`positionerElement`),P=C.useState(`hoverEnabled`),F=C.useState(`disabled`),I=C.useState(`lastOpenChangeReason`),R=C.useState(`parent`),z=C.useState(`activeIndex`),B=C.useState(`payload`),ne=C.useState(`floatingParentNodeId`),re=H.useRef(null),ie=H.useRef(R.type!==`context-menu`),ae=Be(),oe=H.useRef(!0),se=Be(),ce=ne!=null,{openMethod:le,triggerProps:ue}=Ke(j);C.useSyncedValues({disabled:o,highlightItemOnHover:_,modal:R.type===void 0?s:void 0,openMethod:le,rootId:w}),Bt(C);let{forceUnmount:de}=vt(j,C,()=>{C.set(`allowMouseEnter`,!1)});V(()=>{v&&!y?C.update({parent:{type:`context-menu`,context:v},floatingNodeId:O,floatingParentNodeId:k}):y&&C.update({floatingNodeId:O,floatingParentNodeId:k})},[v,y,O,k,C]),H.useEffect(()=>{if(j||(re.current=null),R.type===`context-menu`){if(!j){ae.clear(),ie.current=!1;return}ae.start(500,()=>{ie.current=!0})}},[ae,j,R.type]),V(()=>{!j&&!P&&C.set(`hoverEnabled`,!0)},[j,P,C]);let fe=A((e,t)=>{let n=t.reason;if(!e&&!C.select(`open`)||j===e&&t.trigger===M&&I===n)return;let i=Lt(t);if(!e&&t.trigger==null&&(t.trigger=M??void 0),r?.(e,t),t.isCanceled)return;C.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&a?.type===`click`&&a.pointerType===`touch`&&!oe.current)return;e&&n===`trigger-focus`?(oe.current=!1,se.start(300,()=>{oe.current=!0})):(oe.current=!0,se.clear());let o=(n===`trigger-press`||n===`item-press`)&&a.detail===0,s=!e&&(n===`escape-key`||n==null),c={open:e,openChangeReason:n};re.current=t.event,Ot(c,e,t.trigger,i()),C.update(c),R.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?C.set(`instantType`,`group`):o||s?C.set(`instantType`,o?`click`:`dismiss`):C.set(`instantType`,void 0)}),pe=Vt({popupStore:C,floatingId:T,nested:k!=null,onOpenChange:fe}),me=pe.context.events;V(()=>{let e=({open:e,eventDetails:t})=>fe(e,t);return me.on(`setOpen`,e),()=>{me?.off(`setOpen`,e)}},[me,fe]);let he=H.useCallback(()=>{C.setOpen(!1,d(D))},[C]);H.useImperativeHandle(f,()=>({unmount:de,close:he}),[de,he]);let ge;R.type===`context-menu`&&(ge=R.context),H.useImperativeHandle(ge?.positionerRef,()=>N,[N]),H.useImperativeHandle(ge?.actionsRef,()=>({setOpen:fe}),[fe]);let _e=gt(pe,{enabled:!F,bubbles:{escapeKey:p&&R.type===`menu`},outsidePress(){return R.type!==`context-menu`||re.current?.type===`contextmenu`||ie.current},externalTree:ce?E:void 0}),ve=Ge(),ye=H.useCallback(e=>{C.select(`activeIndex`)!==e&&C.set(`activeIndex`,e)},[C]),be=zt(pe,{enabled:!F,listRef:C.context.itemDomElements,activeIndex:z,nested:R.type!==void 0,loopFocus:c,orientation:u,parentOrientation:R.type===`menubar`?R.context.orientation:void 0,rtl:ve===`rtl`,disabledIndices:l,onNavigate:ye,openOnArrowKeyDown:R.type!==`context-menu`,externalTree:ce?E:void 0,focusItemOnHover:_}),xe=H.useCallback(e=>{C.context.typingRef.current=e},[C]),Se=yt(pe,{enabled:!F,listRef:C.context.itemLabels,elementsRef:C.context.itemDomElements,activeIndex:z,resetMs:500,onMatch:e=>{j&&e!==z&&C.set(`activeIndex`,e)},onTyping:xe}),Ce=H.useMemo(()=>{let e=ee(Se.reference,be.reference,_e.reference,{onMouseMove(){C.set(`allowMouseEnter`,!0)}},ue);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=j,e},[C,Se.reference,be.reference,_e.reference,ue,j]),we=H.useMemo(()=>{let e=ee(be.trigger,_e.trigger,ue);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[be.trigger,_e.trigger,ue]),Te=H.useMemo(()=>ee(wt,{id:T,role:`menu`,"aria-labelledby":M?.id,onMouseMove(){C.set(`allowMouseEnter`,!0),R.type===`menu`&&C.set(`hoverEnabled`,!1)},onClick(){C.select(`hoverEnabled`)&&C.set(`hoverEnabled`,!1)},onKeyDown(e){let t=C.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},Se.floating,be.floating,_e.floating),[M,T,R.type,C,Se.floating,be.floating,_e.floating]),Ee=be.item??L;bt(C,{floatingRootContext:pe,activeTriggerProps:Ce,inactiveTriggerProps:we,popupProps:Te,itemProps:Ee});let De=H.useMemo(()=>({store:C,parent:S}),[C,S]),Oe=(0,U.jsxs)(ga.Provider,{value:De,children:[m&&(0,U.jsx)(ht,{handle:m,store:C}),typeof t==`function`?t({payload:B}):t]});return R.type===void 0||R.type===`context-menu`?(0,U.jsx)(Ht,{externalTree:E,children:Oe}):Oe});function Ra(e){return a(()=>new Ma(e)).current}function za(e){let t=_a().store,n=H.useMemo(()=>({parentMenu:t}),[t]);return(0,U.jsx)(Fa.Provider,{value:n,children:(0,U.jsx)(La,{...e})})}function Ba(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=v(),{ref:i,index:a}=Et(e),o=n===a,s=H.useRef(null),c=I(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:c,index:a}}function Va(e){let{render:t,className:n,style:r,state:i=L,props:a=l,refs:o=l,metadata:s,stateAttributesMapping:c,tag:u=`div`,...d}=e,{compositeProps:f,compositeRef:p}=Ba({metadata:s});return j(u,e,{state:i,ref:[p,...o],props:[f,...a,d],stateAttributesMapping:c})}function Ha(e){if(se(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!le(e))return Ha(je(e))}function Ua(e,t){let n=H.useRef(null);function r(t){_n.flushSync(()=>{e.setOpen(!1,d(C,t.nativeEvent,t.currentTarget))}),me(n.current)?.focus()}function i(n){let r=e.select(`positionerElement`);if(r&&pe(n,r))e.context.beforeContentFocusGuardRef.current?.focus();else{_n.flushSync(()=>{e.setOpen(!1,d(C,n.nativeEvent,n.currentTarget))});let i=Ce(e.context.triggerFocusTargetRef.current||t.current);for(;i!==null&&Te(r,i);){let e=i;if(i=ue(i),i===e)break}i?.focus()}}return{preFocusGuardRef:n,handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function Wa(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=H.useRef(!1);return H.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,b(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:L,[t,n,r])}var Ga=c(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,openOnHover:c,delay:l=100,closeDelay:u=0,handle:d,payload:f,...p}=e,m=_a(!0),h=fr(d)??m?.store;if(!h)throw Error(B(85));let g=xe(s),_=h.useState(`isTriggerActive`,g),y=h.useState(`floatingRootContext`),x=h.useState(`isOpenedByTrigger`,g),S=h.useState(`triggerPopupId`,g),C=H.useRef(null),w=qa(),E=v(!0),D=Xe(),O=H.useMemo(()=>D??new at,[D]),k=ut(O),M=Qe(),{registerTrigger:N,isMountedByThisTrigger:P}=St(g,C,h,{payload:f,closeDelay:u,parent:w,floatingTreeRoot:O,floatingNodeId:k,floatingParentNodeId:M,keyboardEventRelay:E?.relayKeyboardEvent}),F=w.type===`menubar`,I=h.useState(`disabled`),z=a||I||F&&w.context.disabled,{getButtonProps:te,buttonRef:V}=R({disabled:z,native:o});H.useEffect(()=>{!x&&w.type===void 0&&(h.context.allowMouseUpTriggerRef.current=!1)},[h,x,w.type]);let ne=H.useRef(null),re=Be(),ie=A(e=>{if(!ne.current)return;re.clear(),h.context.allowMouseUpTriggerRef.current=!1;let t=e.target;Te(ne.current,t)||Te(h.select(`positionerElement`),t)||t===ne.current||(t==null||Ha(t)!==h.select(`rootId`))&&(lt(e,ne.current)||O.events.emit(`close`,{domEvent:e,reason:T}))});H.useEffect(()=>{x&&h.select(`lastOpenChangeReason`)===`trigger-hover`&&b(ne.current).addEventListener(`mouseup`,ie,{once:!0})},[x,ie,h]);let ae=F&&w.context.hasSubmenuOpen,se=Sr(y,{enabled:(c??ae)&&!z&&(!F||ae&&!P),handleClose:Ar({blockPointerEvents:!F}),mouseOnly:!0,move:!1,restMs:w.type===void 0?l:void 0,delay:{close:u},triggerElementRef:C,externalTree:O,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),ce=Ka(x,h.select(`lastOpenChangeReason`)),le=Ut(y,{enabled:!z,event:x&&F?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:w.type===void 0&&ce}),ue=mr(y,{enabled:!z&&ae}),de=Wa({open:x,enabled:F,mouseDownAction:`open`}),fe=H.useMemo(()=>ee(ue.reference,le.reference),[ue.reference,le.reference]),pe=h.useState(`triggerProps`,P),{preFocusGuardRef:me,handlePreFocusGuardFocus:he,handleFocusTargetFocus:ge}=Ua(h,C),_e={disabled:z,open:x},ve=[ne,t,V,N,C],ye=[fe,se??L,pe,{"aria-haspopup":`menu`,"aria-controls":S,id:g,onMouseDown:e=>{h.select(`open`)||(re.start(200,()=>{h.context.allowMouseUpTriggerRef.current=!0}),b(e.currentTarget).addEventListener(`mouseup`,ie,{once:!0}))}},F?{role:`menuitem`}:{},de,p,te],be=j(`button`,e,{enabled:!F,stateAttributesMapping:ft,state:_e,ref:ve,props:ye});return F?(0,U.jsx)(Va,{tag:`button`,render:n,className:r,style:i,state:_e,refs:ve,props:ye,stateAttributesMapping:ft}):x?(0,U.jsxs)(H.Fragment,{children:[(0,U.jsx)(oe,{ref:me,onFocus:he},`${g}-pre-focus-guard`),(0,U.jsx)(H.Fragment,{children:be},g),(0,U.jsx)(oe,{ref:h.context.triggerFocusTargetRef,onFocus:ge},`${g}-post-focus-guard`)]}):(0,U.jsx)(H.Fragment,{children:be},g)});function Ka(e,t){let n=Be(),[r,i]=H.useState(!1);return V(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function qa(){let e=Aa(!0);return H.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}var Ja=H.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return j(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})}),Ya={"aria-expanded":void 0},Xa=H.forwardRef(function(e,t){let{render:n,className:r,style:i,label:a,id:o,nativeButton:s=!1,openOnHover:c=!0,delay:l=100,closeDelay:u=0,disabled:d=!1,...f}=e,p=Ia();if(!p?.parentMenu)throw Error(B(37));let m=Et({guess:!0,label:a}),h=ha(),{store:g}=_a(),_=xe(o),v=g.useState(`open`),y=g.useState(`floatingRootContext`),b=g.useState(`floatingTreeRoot`),x=g.useState(`triggerPopupId`,_),S=xt(_,g),C=H.useCallback(e=>{let t=S(e);return e!==null&&g.select(`open`)&&g.select(`activeTriggerId`)==null&&g.update({activeTriggerId:_,activeTriggerElement:e,closeDelay:u}),t},[S,u,g,_]),w=H.useRef(null),T=H.useCallback(e=>{w.current=e,g.set(`activeTriggerElement`,e)},[g]);g.useSyncedValue(`closeDelay`,u);let E=p.parentMenu,D=g.useState(`disabled`),O=E.useState(`disabled`),k=d||D||O,A=E.useState(`itemProps`),M=E.useState(`isActive`,m.index),N=H.useMemo(()=>({type:`submenu-trigger`,setActive(){E.select(`highlightItemOnHover`)&&E.set(`activeIndex`,m.index)}}),[E,m.index]),{getItemProps:P,itemRef:F}=Sa({closeOnClick:!1,disabled:k,highlighted:M,id:_,store:g,typingRef:E.context.typingRef,nativeButton:s,itemMetadata:N,nodeId:h?.context.nodeId}),I=Sr(y,{enabled:g.useState(`hoverEnabled`)&&c&&!k,handleClose:Ar({blockPointerEvents:!0}),mouseOnly:!0,move:!0,restMs:l,delay:{open:l,close:u},shouldOpen:l>0?()=>E.select(`allowMouseEnter`):void 0,triggerElementRef:w,externalTree:b,isClosing:()=>g.select(`transitionStatus`)===`ending`,guardStaleOpen:!0}),R=Ut(y,{enabled:!k,event:`mousedown`,toggle:!c,ignoreMouse:c,stickIfOpen:!1}).reference??L,ee=g.useState(`triggerProps`,!0);delete ee.id;let z={disabled:k,highlighted:M,open:v},te=g.useState(`openMethod`),V=g.useState(`lastOpenChangeReason`)===`list-navigation`||te===`keyboard`;return j(`div`,e,{state:z,stateAttributesMapping:mt,props:[R,I,ee,A,v&&V&&Se?Ya:void 0,{"aria-controls":x,tabIndex:v||M?0:-1,onBlur(){M&&E.set(`activeIndex`,null)}},f,P],ref:[t,m.ref,F,C,T]})});function Za({...e}){return(0,U.jsx)(La,{"data-slot":`dropdown-menu`,...e})}function Qa({className:e,...t}){return(0,U.jsx)(Ga,{"data-slot":`dropdown-menu-trigger`,className:e,...t})}function $a({align:e=`start`,alignOffset:t=0,side:n=`bottom`,sideOffset:r=4,className:i,...a}){return(0,U.jsx)(Da,{children:(0,U.jsx)(Oa,{className:`isolate z-50 outline-none`,align:e,alignOffset:t,side:n,sideOffset:r,children:(0,U.jsx)(wa,{"data-slot":`dropdown-menu-content`,className:g(`z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-2xl bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/5 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-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 dark:ring-foreground/10 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95`,i),...a})})})}function eo({className:e,inset:t,variant:n=`default`,...r}){return(0,U.jsx)(Ca,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:g(`group/dropdown-menu-item relative flex min-h-7 cursor-default items-center gap-2 rounded-xl px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive`,e),...r})}function to({...e}){return(0,U.jsx)(za,{"data-slot":`dropdown-menu-sub`,...e})}function no({className:e,inset:t,children:n,...r}){return(0,U.jsxs)(Xa,{"data-slot":`dropdown-menu-sub-trigger`,"data-inset":t,className:g(`relative flex min-h-7 cursor-default items-center gap-2 rounded-xl px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[n,(0,U.jsx)(Cn,{className:`ml-auto`})]})}function ro({align:e=`start`,alignOffset:t=-3,side:n=`right`,sideOffset:r=0,className:i,...a}){return(0,U.jsx)($a,{"data-slot":`dropdown-menu-sub-content`,className:g(`w-auto min-w-[96px] rounded-2xl bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/5 duration-100 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 dark:ring-foreground/10 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,i),align:e,alignOffset:t,side:n,sideOffset:r,...a})}function io({className:e,...t}){return(0,U.jsx)(Ja,{"data-slot":`dropdown-menu-separator`,className:g(`-mx-1 my-1 h-px bg-border/50`,e),...t})}var ao=6e4,oo=60*ao,so=24*oo;function co(e,t=Date.now()){if(!e)return``;let n=Date.parse(e);if(Number.isNaN(n))return``;let r=Math.max(0,t-n);return r<ao?`just now`:r<oo?`${Math.floor(r/ao)}m`:r<so?`${Math.floor(r/oo)}h`:new Date(n).toISOString().slice(0,10)}function lo(e){if(!e||typeof e!=`object`)return;let t=e,n=typeof t.old_string==`string`?t.old_string:void 0,r=typeof t.new_string==`string`?t.new_string:typeof t.content==`string`?t.content:void 0;if(n!==void 0||r!==void 0)return{...typeof t.file_path==`string`?{path:t.file_path}:{},removed:fo(n),added:fo(r)}}function uo(e,t){let n=!!t?.trim();if(!n){let t=/^--- [^\n]*\n\+\+\+ [^\n]*\n/m.test(e),n=/^@@ -\d+(?:,\d+)? \+\d+(?:,\d+)? @@/m.test(e);if(!t||!n)return}let r=0,i=0;return(e.match(/[^\n]*\n|[^\n]+$/g)??[]).map(e=>{let t=/^@@ -\d+(?:,(\d+))? \+\d+(?:,(\d+))? @@/.exec(e);if(t)return r=Number(t[1]??1),i=Number(t[2]??1),{text:e,kind:`context`};let a=r>0||i>0,o=`context`;return(a||n)&&(e.startsWith(`-`)&&(a||!e.startsWith(`--- `))&&(o=`removed`),e.startsWith(`+`)&&(a||!e.startsWith(`+++ `))&&(o=`added`)),a&&((o===`removed`||e.startsWith(` `))&&(r=Math.max(0,r-1)),(o===`added`||e.startsWith(` `))&&(i=Math.max(0,i-1))),{text:e,kind:o}})}function fo(e){if(!e)return[];let t=e.split(`
|
|
2
|
+
`)+1),fromSessionId:t.fromSessionId},...t.note===void 0?{}:{note:t.note},...t.attachments===void 0?{}:{attachments:t.attachments},at:n})};case`subagent_instruction`:return{...e,entries:hn(e.entries,{kind:`user`,id:t.id,text:t.text,producer:t.producer,at:n})};case`turn_started`:return{...e,turnInFlight:!0};case`message`:return{...e,entries:hn(e.entries,{kind:`assistant`,id:t.id,text:t.text,final:t.final,...mn(t)})};case`thinking`:return{...e,entries:hn(e.entries,{kind:`thinking`,id:t.id,text:t.text,final:t.final,...mn(t)})};case`tool_started`:return{...e,entries:hn(e.entries,{kind:`tool`,id:t.callId,name:t.name,input:t.input,status:`running`,...mn(t)})};case`tool_updated`:return{...e,entries:gn(e.entries,t.callId,e=>({...e,update:t.update}))};case`tool_ended`:return{...e,entries:gn(e.entries,t.callId,e=>({...e,result:t.result,status:t.isError?`error`:`complete`}))};case`subagent`:{let r=e.entries.find(e=>e.kind===`subagent`&&e.id===t.subagentId),i=r!==void 0&&an(r.status),a=an(t.state),o=a?void 0:r?.endedAt??n;return{...e,activeSubagents:e.activeSubagents+ +!!a-+!!i,entries:hn(e.entries,{kind:`subagent`,id:t.subagentId,name:t.name,...t.description===void 0?{}:{description:t.description},...t.model===void 0?{}:{model:t.model},...t.effort===void 0?{}:{effort:t.effort},...t.producer===void 0?{}:{producer:t.producer},status:t.state,...t.state===`waiting`?{waitingOn:t.on}:{},startedAt:r?.startedAt??n,...o===void 0?{}:{endedAt:o}})}}case`background_call`:{let r=e.entries.find(e=>e.kind===`background_call`&&e.id===t.callId),i=r?.status===`running`,a=t.state===`running`,o=a?void 0:r?.endedAt??n;return{...e,activeBackgroundCalls:e.activeBackgroundCalls+ +!!a-+!!i,entries:hn(e.entries,{kind:`background_call`,id:t.callId,tool:t.tool,status:t.state,...mn(t),startedAt:r?.startedAt??n,...o===void 0?{}:{endedAt:o}})}}case`enquiry`:{let n=t.state===`asked`,r=n&&e.asking?.askId===t.askId?e.asking:n?{askId:t.askId,questions:t.questions,...t.context===void 0?{}:{context:t.context},...t.producer===void 0?{}:{producer:t.producer}}:e.asking?.askId===t.askId?void 0:e.asking;return{...e,...r===void 0?{asking:void 0}:{asking:r},entries:hn(e.entries,{kind:`enquiry`,id:t.askId,questions:t.questions,status:t.state,...t.state===`answered`?{answers:t.answers}:{},...t.context===void 0?{}:{context:t.context},...t.producer===void 0?{}:{producer:t.producer}})}}case`permission`:{let n=t.state===`asked`?e.authorising??{callId:t.callId,tool:t.tool,...t.context===void 0?{}:{context:t.context},...t.allowAlways===void 0?{}:{allowAlways:t.allowAlways},...t.authorizationScope===void 0?{}:{authorizationScope:t.authorizationScope},...t.producer===void 0?{}:{producer:t.producer}}:e.authorising?.callId===t.callId?pn(e.entries,t.callId):e.authorising;return{...e,...n===void 0?{authorising:void 0}:{authorising:n},entries:gn(e.entries,t.callId,e=>({...e,authorisation:fn(t),...t.context===void 0?{}:{permissionContext:t.context},...t.allowAlways===void 0?{}:{allowAlways:t.allowAlways},...t.authorizationScope===void 0?{}:{authorizationScope:t.authorizationScope}}))}}case`turn_ended`:return{...e,entries:sn(e.entries,n),turnInFlight:!1,asking:e.asking?.producer===void 0?void 0:e.asking,authorising:e.authorising?.producer===void 0?void 0:e.authorising};case`queue_changed`:return{...e,queue:[...t.pending],queuedMessages:e.queuedMessages?.length===t.pending.length&&e.queuedMessages.every((e,n)=>e.text===t.pending[n]&&e.id===t.ids?.[n]&&(e.attachments?.length??0)===(t.attachments?.[n]?.length??0)&&(e.attachments??[]).every((e,r)=>e===t.attachments?.[n]?.[r]))?e.queuedMessages:t.pending.map((e,n)=>({id:t.ids?.[n],text:e,...t.attachments?.[n]?.length?{attachments:t.attachments[n]}:{}}))};case`workflow_spend`:{let n={...e.workflowSpend,[t.executionId]:t.spend},r=nn([...e.parentSpend?[e.parentSpend]:[],...Object.values(n)]);return{...e,workflowSpend:n,spend:r,...e.contextUsage?{contextUsage:{...e.contextUsage,spend:r}}:{}}}case`context_usage`:{let n=t.spend||e.workflowSpend?nn([...t.spend?[t.spend]:[],...Object.values(e.workflowSpend??{})]):void 0;return{...e,...t.spend?{parentSpend:t.spend}:{},...n?{spend:n}:{},contextUsage:{used:t.used,window:t.window,...n===void 0?{}:{spend:n}}}}case`model_changed`:return{...e,model:t.model};case`permission_mode_changed`:return{...e,permissionMode:t.mode};case`effort_changed`:return{...e,effort:t.effort};case`branch_changed`:return{...e,branch:t.branch};case`notice`:return{...e,entries:[...e.entries,{kind:`notice`,id:`notice-${e.entries.length}`,level:t.level,text:t.text,...t.sessionId===void 0?{}:{sessionId:t.sessionId}}]};case`compacting`:return t.active?{...e,compacting:!0}:un(e);case`compacted`:return{...un(e),entries:[...e.entries,{kind:`marker`,id:`compacted-${e.entries.length}`,marker:`compacted`,text:dn(t.trigger,t.before,t.after)}]};case`session_dormant`:return{...e,lifecycle:`dormant`,turnInFlight:!1,queue:[],queuedMessages:[],asking:void 0,authorising:void 0,entries:[...e.entries,{kind:`marker`,id:`dormant-${e.entries.length}`,marker:`dormant`,text:`Dormant: ${t.reason}`}]};case`session_settled`:return{...e,lifecycle:`settled`,turnInFlight:!1,queue:[],queuedMessages:[],asking:void 0,authorising:void 0,entries:[...e.entries,{kind:`marker`,id:`settled-${e.entries.length}`,marker:`settled`,text:`Settled`}]};case`rewound`:{let n=e.entries.findIndex(e=>e.kind===`user`&&e.id===t.userMessageId),r=t.restore===`files`?`Files rewound`:t.restore===`both`?`Rewound conversation and files`:`Rewound conversation`;return{...e,entries:[...n<0||t.restore===`files`?e.entries:e.entries.map((e,t)=>t<n||e.rewound?e:{...e,rewound:!0}),{kind:`marker`,id:`rewound-${e.entries.length}`,marker:`rewound`,text:r}]}}case`forked`:return{...e,entries:[...e.entries,{kind:`marker`,id:`forked-${e.entries.length}`,marker:`forked`,text:`Forked`,fromSessionId:t.fromSessionId}]};case`revived`:return{...e,...t.scope===void 0?{}:{scope:t.scope},lifecycle:`live`,turnInFlight:!1,entries:[...e.entries,{kind:`marker`,id:`revived-${t.fromSeq}`,marker:`revived`,text:`Revived from seq ${t.fromSeq}`}]};case`session_ended`:return{...e,lifecycle:`ended`,turnInFlight:!1,endedReason:t.reason,asking:void 0,authorising:void 0}}}function un(e){if(!e.compacting)return e;let{compacting:t,...n}=e;return n}function dn(e,t,n){let r=e===`auto`?`Compacted automatically`:`Compacted`;return n===void 0?`${r}, from ${Jt(t)} tokens`:`${r}, ${Jt(t)} → ${Jt(n)} tokens`}function fn(e){return e.state===`asked`?`asked`:e.state===`aborted`||e.decision===`deny`?`denied`:e.decision===`always`?`always`:`allowed`}function pn(e,t){let n=e.find(e=>e.kind===`tool`&&e.id!==t&&e.authorisation===`asked`);return n?.kind===`tool`?{callId:n.id,tool:n.name,...n.permissionContext===void 0?{}:{context:n.permissionContext},...n.allowAlways===void 0?{}:{allowAlways:n.allowAlways},...n.authorizationScope===void 0?{}:{authorizationScope:n.authorizationScope},...n.producer===void 0?{}:{producer:n.producer}}:void 0}function mn(e){return e.producer===void 0?{}:{producer:e.producer}}function hn(e,t){let n=e.findIndex(e=>e.kind===t.kind&&e.id===t.id);if(n<0)return[...e,t];let r=[...e];return r[n]=t,r}function gn(e,t,n){let r=e.findIndex(e=>e.kind===`tool`&&e.id===t);if(r<0)return e;let i=e[r];if(!i||i.kind!==`tool`)return e;let a=[...e];return a[r]=n(i),a}var H=e(be(),1),_n=e(E(),1);function vn(e){return`${e.kind}:${e.id}`}var U=Re();function yn(e,t){let n=/\/worktrees\/([^/]+)\/[^/]+$/.exec(e)?.[1];return n===void 0?void 0:t.find(e=>e.name===n)?.path}var bn=rt(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),xn=rt(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),Sn=rt(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),Cn=rt(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),wn=rt(`file-pen`,[[`path`,{d:`M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34`,key:`o6klzx`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z`,key:`zhnas1`}]]),Tn=rt(`file-plus`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M9 15h6`,key:`cctwl0`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}]]),En=rt(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Dn=rt(`folder-search`,[[`path`,{d:`M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1`,key:`1bw5m7`}],[`path`,{d:`m21 21-1.9-1.9`,key:`1g2n9r`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}]]),On=rt(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),kn=rt(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),An=rt(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),jn=rt(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),Mn=rt(`message-circle-question-mark`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Nn=rt(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),Pn=rt(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Fn=rt(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),In=rt(`square-terminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),Ln=rt(`undo-2`,[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]),Rn=rt(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),zn=rt(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);function Bn(e){let t=e.trim();return t.startsWith(`/`)||t.startsWith(`~`)?`completion`:`search`}function Vn(e){return e.trim()!==``}function Hn(e){let t=[];for(let n of e){let e=t[t.length-1];if(e&&e.group===n.group){e.items.push(n);continue}t.push({group:n.group,items:[n]})}return t}function Un(e,t){if(t===void 0||t===``)return e;let n=t.endsWith(`/`)?t:`${t}/`;if(!e.startsWith(n))return e;let r=e.slice(n.length);return r===``?e:r}function Wn(e,t){return t!=null&&!x(t)?0:typeof e==`function`?e():e}function Gn(e,t,n){let r=Wn(e,n);return typeof r==`number`?r:r?.[t]}function Kn(e){return typeof e==`function`?e():e}function qn(e,t){return t||e===`click`||e===`mousedown`}function Jn(e){return e?.includes(`mouse`)&&e!==`mousedown`}var Yn=H.createContext({hasProvider:!1,timeoutMs:0,delayRef:{current:0},initialDelayRef:{current:0},timeout:new ie,currentIdRef:{current:null},currentContextRef:{current:null}});function Xn(e,t){e.current=t.current}function Zn(e){let{children:t,delay:n,timeoutMs:r=0}=e,i=H.useRef(n),a=H.useRef(n),o=H.useRef(null),s=H.useRef(null),c=Be();return V(()=>{if(a.current=n,!o.current){i.current=n;return}i.current={open:Gn(i.current,`open`),close:Gn(n,`close`)}},[n,o,i,a]),(0,U.jsx)(Yn.Provider,{value:H.useMemo(()=>({hasProvider:!0,delayRef:i,initialDelayRef:a,currentIdRef:o,timeoutMs:r,currentContextRef:s,timeout:c}),[r,c]),children:t})}function Qn(e,t={open:!1}){let{open:n}=t,r=`rootStore`in e?e.rootStore:e,i=r.useState(`floatingId`),{currentIdRef:a,delayRef:o,timeoutMs:s,initialDelayRef:c,currentContextRef:l,hasProvider:u,timeout:f}=H.useContext(Yn),[p,m]=H.useState(!1),h=H.useRef(n);return V(()=>{h.current=n},[n]),V(()=>{function e(){l.current?.setIsInstantPhase(!1),a.current=null,l.current=null,o.current=c.current,f.clear()}if(a.current&&!n&&a.current===i){if(m(!1),s){let t=i;return f.start(s,()=>{r.select(`open`)||a.current&&a.current!==t||e()}),()=>{(h.current||a.current!==t)&&f.clear()}}e()}},[n,i,a,o,s,c,l,f,r]),V(()=>{if(!n)return;let e=l.current,t=a.current;f.clear(),l.current={onOpenChange:r.setOpen,setIsInstantPhase:m},a.current=i,o.current={open:0,close:Gn(c.current,`close`)},t!==null&&t!==i?(m(!0),e?.setIsInstantPhase(!0),e?.onOpenChange(!1,d(F))):(m(!1),e?.setIsInstantPhase(!1))},[n,i,r,a,o,c,l,f]),V(()=>()=>{if(a.current===i){if(l.current=null,!h.current)return;a.current=null,Xn(o,c),f.clear()}},[l,a,o,i,c,f]),H.useMemo(()=>({hasProvider:u,delayRef:o,isInstantPhase:p}),[u,o,p])}function $n(e,t){let n=null,r=null,i=!1;return{contextElement:e||void 0,getBoundingClientRect(){let a=e?.getBoundingClientRect()||{width:0,height:0,x:0,y:0},o=t.axis===`x`||t.axis===`both`,s=t.axis===`y`||t.axis===`both`,c=[`mouseenter`,`mousemove`].includes(t.dataRef.current.openEvent?.type||``)&&t.pointerType!==`touch`,l=a.width,u=a.height,d=a.x,f=a.y;return n==null&&t.x&&o&&(n=a.x-t.x),r==null&&t.y&&s&&(r=a.y-t.y),d-=n||0,f-=r||0,l=0,u=0,!i||c?(l=t.axis===`y`?a.width:0,u=t.axis===`x`?a.height:0,d=o&&t.x!=null?t.x:d,f=s&&t.y!=null?t.y:f):i&&!c&&(u=t.axis===`x`?a.height:u,l=t.axis===`y`?a.width:l),i=!0,{width:l,height:u,x:d,y:f,top:f,right:d+l,bottom:f+u,left:d}}}}function er(e){return e!=null&&e.clientX!=null}function tr(e,t={}){let{enabled:n=!0,axis:r=`both`}=t,i=`rootStore`in e?e.rootStore:e,a=i.useState(`open`),o=i.useState(`floatingElement`),s=i.useState(`domReferenceElement`),c=i.context.dataRef,l=H.useRef(!1),u=H.useRef(null),[d,f]=H.useState(),[p,m]=H.useState([]),h=A(e=>{i.set(`positionReference`,e)}),g=A((e,t,n)=>{l.current||c.current.openEvent&&!er(c.current.openEvent)||i.set(`positionReference`,$n(n??s,{x:e,y:t,axis:r,dataRef:c,pointerType:d}))}),_=A(e=>{a?u.current||(g(e.clientX,e.clientY,e.currentTarget),m([])):g(e.clientX,e.clientY,e.currentTarget)}),v=x(d)?o:a;H.useEffect(()=>{if(!n){h(s);return}if(!v)return;function e(){u.current?.(),u.current=null}let t=ae(o);function r(t){let n=Ae(t);Te(o,n)?e():g(t.clientX,t.clientY)}return!c.current.openEvent||er(c.current.openEvent)?u.current=Le(t,`mousemove`,r):h(s),e},[v,n,o,c,s,i,g,h,p]),H.useEffect(()=>()=>{i.set(`positionReference`,null)},[i]),H.useEffect(()=>{n&&!o&&(l.current=!1)},[n,o]),H.useEffect(()=>{!n&&a&&(l.current=!0)},[n,a]);let y=H.useMemo(()=>{function e(e){f(e.pointerType)}return{onPointerDown:e,onPointerEnter:e,onMouseMove:_,onMouseEnter:_}},[_]);return H.useMemo(()=>n?{reference:y,trigger:y}:{},[n,y])}function nr(){return new Wt({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:new Ft,floatingId:void 0,syncOnly:!1,nested:!1,onOpenChange:void 0})}function rr(){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:nr(),floatingId:void 0,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:L,inactiveTriggerProps:L,popupProps:L}}function ir(e,t,n=!1){return new Wt({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:n,onOpenChange:void 0})}var ar=e=>e.triggerIdProp??e.activeTriggerId,or=e=>e.openProp??e.open,sr=e=>(e.popupElement?.id??e.floatingId)||void 0;function cr(e,t){return t!==void 0&&or(e)&&ar(e)===t}function lr(e,t){return cr(e,t)?!0:t!==void 0&&or(e)&&ar(e)==null&&e.triggerCount===1}var ur={open:or,mounted:e=>e.mounted,transitionStatus:e=>e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:ar,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:sr,isTriggerActive:(e,t)=>t!==void 0&&ar(e)===t,isOpenedByTrigger:(e,t)=>cr(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&ar(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>lr(e,t)?sr(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement},dr=S();function fr(e){let t=H.useCallback(t=>e===void 0?h:e.subscribeStore(t),[e]),n=H.useCallback(()=>e===void 0?void 0:e.store,[e]);return(0,dr.useSyncExternalStore)(t,n,()=>e?.serverStore)}var pr=He&&fe;function mr(e,t={}){let{enabled:n=!0,delay:r}=t,i=`rootStore`in e?e.rootStore:e,{events:a,dataRef:o}=i.context,s=H.useRef(!1),c=H.useRef(null),l=H.useRef(!0),u=Be();H.useEffect(()=>{let e=i.select(`domReferenceElement`);if(!n)return;let t=ae(e);function r(){let e=i.select(`domReferenceElement`);!i.select(`open`)&&se(e)&&e===re(b(e))&&(s.current=!0)}function a(){l.current=!0}function o(){l.current=!1}return P(Le(t,`blur`,r),pr&&Le(t,`keydown`,a,!0),pr&&Le(t,`pointerdown`,o,!0))},[i,n]),H.useEffect(()=>{if(!n)return;function e(e){if(e.reason===`trigger-press`||e.reason===`escape-key`){let e=i.select(`domReferenceElement`);Fe(e)&&(c.current=e,s.current=!0)}}return a.on(`openchange`,e),()=>{a.off(`openchange`,e)}},[a,n,i]);let f=H.useMemo(()=>{function e(){s.current=!1,c.current=null}return{onMouseLeave(){e()},onFocus(t){let n=t.currentTarget;if(s.current){if(c.current===n)return;e()}let a=Ae(t.nativeEvent);if(Fe(a)){if(pr&&!t.relatedTarget){if(!l.current&&!Oe(a))return}else if(!ge(a))return}let o=Ne(t.relatedTarget,i.context.triggerElements),{nativeEvent:f,currentTarget:p}=t,m=typeof r==`function`?r():r;if(i.select(`open`)&&o||m===0||m===void 0){i.setOpen(!0,d(De,f,p));return}u.start(m,()=>{s.current||i.setOpen(!0,d(De,f,p))})},onBlur(t){e();let n=t.relatedTarget,r=t.nativeEvent,a=Fe(n)&&n.hasAttribute(N(`focus-guard`))&&n.getAttribute(`data-type`)===`outside`;u.start(0,()=>{let e=i.select(`domReferenceElement`),t=re(b(e));!n&&t===e||Te(o.current.floatingContext?.refs.floating.current,t)||Te(e,t)||a||Ne(n??t,i.context.triggerElements)||i.setOpen(!1,d(De,r))})}}},[o,r,i,u]);return H.useMemo(()=>n?{reference:f,trigger:f}:{},[n,f])}var hr=class e{constructor(){this.pointerType=void 0,this.interactedInside=!1,this.handler=void 0,this.blockMouseMove=!0,this.performedPointerEventsMutation=!1,this.pointerEventsScopeElement=null,this.pointerEventsReferenceElement=null,this.pointerEventsFloatingElement=null,this.restTimeoutPending=!1,this.openChangeTimeout=new ie,this.restTimeout=new ie,this.handleCloseOptions=void 0}static create(){return new e}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose},gr=new WeakMap;function _r(e){if(!e.performedPointerEventsMutation)return;let t=e.pointerEventsScopeElement;t&&gr.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty(`pointer-events`),e.pointerEventsReferenceElement?.style.removeProperty(`pointer-events`),e.pointerEventsFloatingElement?.style.removeProperty(`pointer-events`),gr.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function vr(e,t){let{scopeElement:n,referenceElement:r,floatingElement:i}=t,a=gr.get(n);a&&a!==e&&_r(a),_r(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=i,gr.set(n,e),n.style.pointerEvents=`none`,r.style.pointerEvents=`auto`,i.style.pointerEvents=`auto`}function yr(e){let t=e.context.dataRef.current,n=a(()=>t.hoverInteractionState??hr.create()).current;return t.hoverInteractionState||=n,w(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function br(e,t={}){let{enabled:n=!0,closeDelay:r=0,nodeId:i}=t,a=`rootStore`in e?e.rootStore:e,s=a.useState(`open`),c=a.useState(`floatingElement`),l=a.useState(`domReferenceElement`),{dataRef:u}=a.context,f=Xe(),p=Qe(),m=yr(a),h=Be(),g=A(()=>qn(u.current.openEvent?.type,m.interactedInside)),v=A(()=>Jn(u.current.openEvent?.type)),y=A(()=>{_r(m)});V(()=>{s||(m.pointerType=void 0,m.restTimeoutPending=!1,m.interactedInside=!1,y())},[s,m,y]),H.useEffect(()=>y,[y]),V(()=>{if(n&&s&&m.handleCloseOptions?.blockPointerEvents&&v()&&Fe(l)&&c){let e=l,t=c,n=b(c),r=f?.nodesRef.current.find(e=>e.id===p)?.context?.elements.floating;r&&(r.style.pointerEvents=``);let i=m.pointerEventsScopeElement===t?null:m.pointerEventsScopeElement,a=r===t?null:r,o=m.handleCloseOptions?.getScope?.()??i??a??e.closest(`[data-rootownerid]`)??n.body;return vr(m,{scopeElement:o,referenceElement:e,floatingElement:t}),()=>{y()}}},[n,s,l,c,m,v,f,p,y]),H.useEffect(()=>{if(!n)return;function e(){return!!(f&&p&&qe(f.nodesRef.current,p).length>0)}function t(e){let t=Gn(r,`close`,m.pointerType),n=()=>{a.setOpen(!1,d(_,e)),f?.events.emit(`floating.closed`,e)};t?m.openChangeTimeout.start(t,n):(m.openChangeTimeout.clear(),n())}function s(e){let t=Ae(e);if(!o(t)){m.interactedInside=!1;return}m.interactedInside=t?.closest(`[aria-haspopup]`)!=null}function l(){m.openChangeTimeout.clear(),h.clear(),f?.events.off(`floating.closed`,x),y()}function b(n){if(e()&&f){f.events.on(`floating.closed`,x);return}if(Ne(n.relatedTarget,a.context.triggerElements))return;let r=u.current.floatingContext?.nodeId??i,o=n.relatedTarget;if(!(f&&r&&Fe(o)&&qe(f.nodesRef.current,r,!1).some(e=>Te(e.context?.elements.floating,o)))){if(m.handler){m.handler(n);return}y(),v()&&!g()&&t(n)}}function x(t){!f||!p||e()||h.start(0,()=>{f.events.off(`floating.closed`,x),a.setOpen(!1,d(_,t)),f.events.emit(`floating.closed`,t)})}let S=c;return P(S&&Le(S,`mouseenter`,l),S&&Le(S,`mouseleave`,b),S&&Le(S,`pointerdown`,s,!0),()=>{f?.events.off(`floating.closed`,x)})},[n,c,a,u,r,i,v,g,y,m,f,p,h])}var xr={current:null};function Sr(e,t={}){let{enabled:n=!0,delay:r=0,handleClose:i=null,mouseOnly:a=!1,restMs:o=0,move:s=!0,triggerElementRef:c=xr,externalTree:l,isActiveTrigger:u=!0,getHandleCloseContext:f,isClosing:p,shouldOpen:m,guardStaleOpen:h=!1}=t,g=`rootStore`in e?e.rootStore:e,{dataRef:v,events:y}=g.context,S=Xe(l),C=yr(g),w=H.useRef(!1),T=Dt(i),E=Dt(r),D=Dt(o),O=Dt(n),k=Dt(m),j=Dt(p),M=A(()=>qn(v.current.openEvent?.type,C.interactedInside)),N=A(()=>k.current?.()!==!1),F=A((e,t,n)=>{let r=g.context.triggerElements;if(r.hasElement(t))return!e||!Te(e,t);if(!Fe(n))return!1;let i=n;return r.hasMatchingElement(e=>Te(e,i))&&(!e||!Te(e,i))}),I=A(()=>{C.handler&&=(b(g.select(`domReferenceElement`)).removeEventListener(`mousemove`,C.handler),void 0)}),L=A(()=>{_r(C)});return u&&(C.handleCloseOptions=T.current?.__options),H.useEffect(()=>I,[I]),H.useEffect(()=>{if(!n)return;function e(e){e.open?w.current=!1:(w.current=e.reason===_,I(),C.openChangeTimeout.clear(),C.restTimeout.clear(),C.blockMouseMove=!0,C.restTimeoutPending=!1)}return y.on(`openchange`,e),()=>{y.off(`openchange`,e)}},[n,y,C,I]),H.useEffect(()=>{if(!n)return;function e(e,t=!0){let n=Gn(E.current,`close`,C.pointerType);n?C.openChangeTimeout.start(n,()=>{g.setOpen(!1,d(_,e)),S?.events.emit(`floating.closed`,e)}):t&&(C.openChangeTimeout.clear(),g.setOpen(!1,d(_,e)),S?.events.emit(`floating.closed`,e))}let t=c.current??(u?g.select(`domReferenceElement`):null);if(!Fe(t))return;function r(e){if(C.openChangeTimeout.clear(),C.blockMouseMove=!1,a&&!x(C.pointerType))return;let t=Kn(D.current),n=Gn(E.current,`open`,C.pointerType),r=Ae(e),i=e.currentTarget??null,o=g.select(`domReferenceElement`),s=i;if(Fe(r)&&!g.context.triggerElements.hasElement(r)){for(let e of g.context.triggerElements.elements())if(Te(e,r)){s=e;break}}Fe(i)&&Fe(o)&&!g.context.triggerElements.hasElement(i)&&Te(i,o)&&(s=o);let c=s!=null&&F(o,s,r),l=g.select(`open`),u=j.current?.()??g.select(`transitionStatus`)===`ending`,f=!l&&u&&w.current,p=!c&&Fe(s)&&Fe(o)&&Te(o,s)&&f,m=t>0&&!n,h=c&&(l||f)||p,v=!l||c;if(h){N()&&g.setOpen(!0,d(_,e,s));return}m||(n?C.openChangeTimeout.start(n,()=>{v&&N()&&g.setOpen(!0,d(_,e,s))}):v&&N()&&g.setOpen(!0,d(_,e,s)))}function i(t){if(M()){L();return}I();let n=g.select(`domReferenceElement`),r=b(n);C.restTimeout.clear(),C.restTimeoutPending=!1;let i=v.current.floatingContext??f?.();if(!Ne(t.relatedTarget,g.context.triggerElements)){if(T.current&&i){g.select(`open`)||C.openChangeTimeout.clear();let n=c.current;C.handler=T.current({...i,tree:S,x:t.clientX,y:t.clientY,onClose(){L(),I(),O.current&&!M()&&n===g.select(`domReferenceElement`)&&e(t,!0)}}),r.addEventListener(`mousemove`,C.handler),C.handler(t);return}(C.pointerType!==`touch`||!Te(g.select(`floatingElement`),t.relatedTarget))&&e(t)}}function o(e){Te(t,e.relatedTarget)||(C.openChangeTimeout.clear(),C.restTimeout.clear(),C.restTimeoutPending=!1)}let l=h?Le(t,`mouseout`,o):void 0;return s?P(Le(t,`mousemove`,r,{once:!0}),Le(t,`mouseenter`,r),Le(t,`mouseleave`,i),l):P(Le(t,`mouseenter`,r),Le(t,`mouseleave`,i),l)},[I,L,v,E,g,n,T,C,u,F,M,a,s,D,c,S,O,f,j,N,h]),H.useMemo(()=>{if(!n)return;function e(e){C.pointerType=e.pointerType}return{onPointerDown:e,onPointerEnter:e,onMouseMove(e){let{nativeEvent:t}=e,n=e.currentTarget,r=g.select(`domReferenceElement`),i=g.select(`open`),o=F(r,n,e.target);if(a&&!x(C.pointerType))return;if(i&&o&&C.handleCloseOptions?.blockPointerEvents){let e=g.select(`floatingElement`);if(e){let t=C.handleCloseOptions?.getScope?.()??n.ownerDocument.body;vr(C,{scopeElement:t,referenceElement:n,floatingElement:e})}}let s=Kn(D.current);if(i&&!o||s===0||!o&&C.restTimeoutPending&&e.movementX**2+e.movementY**2<2)return;C.restTimeout.clear();function c(){if(C.restTimeoutPending=!1,M())return;let e=g.select(`open`);!C.blockMouseMove&&(!e||o)&&N()&&g.setOpen(!0,d(_,t,n))}C.pointerType===`touch`?_n.flushSync(()=>{c()}):o&&i?c():(C.restTimeoutPending=!0,C.restTimeout.start(s,c))}}},[n,C,M,F,a,g,D,N])}var Cr=.1,wr=Cr*Cr,Tr=.5;function Er(e,t,n,r,i,a){return r>=t!=a>=t&&e<=(i-n)*(t-r)/(a-r)+n}function Dr(e,t,n,r,i,a,o,s,c,l){let u=!1;return Er(e,t,n,r,i,a)&&(u=!u),Er(e,t,i,a,o,s)&&(u=!u),Er(e,t,o,s,c,l)&&(u=!u),Er(e,t,c,l,n,r)&&(u=!u),u}function Or(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function kr(e,t,n,r,i,a){return e>=Math.min(n,i)&&e<=Math.max(n,i)&&t>=Math.min(r,a)&&t<=Math.max(r,a)}function Ar(e={}){let{blockPointerEvents:t=!1}=e,n=new ie,r=({x:e,y:t,placement:r,elements:i,onClose:a,nodeId:o,tree:s})=>{let c=r?.split(`-`)[0],l=!1,u=null,d=null,f=typeof performance<`u`?performance.now():0;function p(e,t){let n=performance.now(),r=n-f;if(u===null||d===null||r===0)return u=e,d=t,f=n,!1;let i=e-u,a=t-d,o=i*i+a*a,s=r*r*wr;return u=e,d=t,f=n,o<s}function m(){n.clear(),a()}return function(r){n.clear();let a=i.domReference,u=i.floating;if(!a||!u||c==null||e==null||t==null)return;let{clientX:d,clientY:f}=r,h=Ae(r),g=r.type===`mouseleave`,_=Te(u,h),v=Te(a,h);if(_&&(l=!0,!g))return;if(v&&(l=!1,!g)){l=!0;return}if(g&&Fe(r.relatedTarget)&&Te(u,r.relatedTarget))return;function y(){return!!(s&&qe(s.nodesRef.current,o).length>0)}function b(){y()||m()}if(y())return;let x=a.getBoundingClientRect(),S=u.getBoundingClientRect(),C=e>S.right-S.width/2,w=t>S.bottom-S.height/2,T=S.width>x.width,E=S.height>x.height,D=(T?x:S).left,O=(T?x:S).right,k=(E?x:S).top,A=(E?x:S).bottom;if(c===`top`&&t>=x.bottom-1||c===`bottom`&&t<=x.top+1||c===`left`&&e>=x.right-1||c===`right`&&e<=x.left+1){b();return}let j=!1;switch(c){case`top`:j=kr(d,f,D,x.top+1,O,S.bottom-1);break;case`bottom`:j=kr(d,f,D,S.top+1,O,x.bottom-1);break;case`left`:j=kr(d,f,S.right-1,A,x.left+1,k);break;case`right`:j=kr(d,f,x.right-1,A,S.left+1,k)}if(j)return;if(l&&!Or(d,f,x)){b();return}if(!g&&p(d,f)){b();return}let M=!1;switch(c){case`top`:{let n=T?Tr/2:Tr*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t+Tr+1,o=C||T?S.bottom-Tr:S.top,s=C?T?S.bottom-Tr:S.top:S.bottom-Tr;M=Dr(d,f,r,a,i,a,S.left,o,S.right,s);break}case`bottom`:{let n=T?Tr/2:Tr*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t-Tr,o=C||T?S.top+Tr:S.bottom,s=C?T?S.top+Tr:S.bottom:S.top+Tr;M=Dr(d,f,r,a,i,a,S.left,o,S.right,s);break}case`left`:{let n=E?Tr/2:Tr*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e+Tr+1,o=w||E?S.right-Tr:S.left,s=w?E?S.right-Tr:S.left:S.right-Tr;M=Dr(d,f,o,S.top,s,S.bottom,a,r,a,i);break}case`right`:{let n=E?Tr/2:Tr*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e-Tr,o=w||E?S.left+Tr:S.right,s=w?E?S.left+Tr:S.right:S.left+Tr;M=Dr(d,f,a,r,a,i,o,S.top,s,S.bottom);break}}M?l||n.start(40,b):b()}};return r.__options={...e,blockPointerEvents:t},r}function jr(){let{config:e,refresh:t}=Ue(),{save:n,saving:r}=Ve(),i=e.projectList??[],a=e.projectCandidates??[],o=e.projects?.root??``,s=e.projects?.include??[],c=(0,H.useCallback)((e,r)=>{(async()=>{await n({projects:{include:e}},r)&&await t()})()},[n,t]),l=t=>{let n=Un(t,e.projects?.root===void 0?void 0:e.scope);s.includes(n)||c([...s,n],`Project added.`)};return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Mr,{included:i,onRemove:e=>c(s.filter((t,n)=>n!==e),`Project removed.`)}),(0,U.jsx)(Nr,{candidates:a,hasRoot:e.projects?.root!==void 0,onAdd:l}),(0,U.jsx)(Fr,{onAdd:l}),(0,U.jsx)(Ir,{current:o,saving:r,onSave:n,onSaved:t}),(0,U.jsxs)(Ie,{title:`Worktrees`,description:`Machine-wide.`,children:[(0,U.jsxs)(`label`,{className:`flex items-center justify-between gap-4`,children:[(0,U.jsx)(`span`,{className:`text-sm`,children:`Always start new Agent Sessions in a Worktree`}),(0,U.jsx)(dt,{checked:e.worktrees?.always===!0,disabled:r,onCheckedChange:e=>void n({worktrees:{always:e}},e?`New Agent Sessions start in a Worktree.`:`New Agent Sessions start in the Project.`)})]}),(0,U.jsxs)(`label`,{className:`flex items-center justify-between gap-4`,children:[(0,U.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-sm`,children:`Update the Source Branch before cutting a Worktree`}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Fast-forwards the branch from its upstream in the Project. If this fails, the Worktree is cut from the local branch and a warning is shown.`})]}),(0,U.jsx)(dt,{checked:e.worktrees?.updateSource===!0,disabled:r,onCheckedChange:e=>void n({worktrees:{updateSource:e}},e?`Source Branches are updated before a Worktree is cut.`:`Worktrees are cut from the local branch.`)})]})]})]})}function Mr({included:e,onRemove:t}){return(0,U.jsx)(Ie,{title:`Projects · ${e.length}`,description:e.length===0?`Nothing yet. A Project is one you have opted into — add one below, and it becomes an option in the New Agent Session view.`:`What the New Agent Session view offers, in this order.`,children:e.length===0?null:(0,U.jsx)(`div`,{className:`flex flex-col`,children:e.map((e,n)=>(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 border-b py-1.5 last:border-b-0`,children:[(0,U.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,U.jsx)(`span`,{className:`font-mono text-xs`,children:e.group===void 0?e.name:`${e.group}/${e.name}`}),e.missing?(0,U.jsx)(`span`,{className:`text-xs text-destructive`,children:`directory is gone`}):null]}),(0,U.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-muted-foreground`,children:e.path}),(0,U.jsx)(O,{variant:`ghost`,size:`icon-sm`,"aria-label":`Remove ${e.name}`,onClick:()=>t(n),children:(0,U.jsx)(zn,{"aria-hidden":!0})})]})]},e.path))})})}function Nr({candidates:e,hasRoot:t,onAdd:n}){return t?(0,U.jsx)(Ie,{title:`Found beneath the Project Root · ${e.length}`,description:`Repositories Flow can see but is not offering. Add the ones you work in.`,children:e.length===0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Nothing left to add. Either everything found is already a Project, or the Project Root holds no git repositories within three levels.`}):(0,U.jsx)(`div`,{className:`flex flex-col gap-2`,children:Hn(e).map(e=>(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e.group===void 0?null:(0,U.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:e.group}),(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.items.map(e=>(0,U.jsxs)(O,{variant:`outline`,size:`sm`,className:`font-mono text-xs font-normal`,onClick:()=>n(e.path),children:[(0,U.jsx)(Pn,{"aria-hidden":!0}),e.name]},e.path))})]},e.group??``))})}):null}function Pr(e){let[t,n]=(0,H.useState)(void 0),r=(0,H.useRef)(``);return(0,H.useEffect)(()=>{if(r.current=e,!Vn(e)){n(void 0);return}let t=new AbortController,i=setTimeout(()=>{(async()=>{try{let i=await p(`/api/directories?q=${encodeURIComponent(e)}`,{signal:t.signal});if(!i.ok)return;let a=await i.json();a.query===r.current&&n(a)}catch{}})()},150);return()=>{t.abort(),clearTimeout(i)}},[e]),t}function Fr({onAdd:e}){let[t,n]=(0,H.useState)(``),r=Pr(t),i=Bn(t);return(0,U.jsxs)(Ie,{title:`Add any directory`,description:(0,U.jsxs)(U.Fragment,{children:[`Type a name to search beneath the Project Root — repositories included, so`,` `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`packages/api`}),` inside a monorepo is reachable. Start with `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`/`}),` or`,` `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`~`}),` to complete a path anywhere on this machine instead.`]}),children:[(0,U.jsx)(he,{className:`font-mono`,value:t,onChange:e=>n(e.target.value),placeholder:`api, or /home/you/elsewhere`,spellCheck:!1}),r===void 0?null:r.paths.length===0?(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i===`completion`?`No directory there.`:`Nothing beneath the Project Root matches.`}):(0,U.jsxs)(`div`,{className:`flex flex-col`,children:[(0,U.jsxs)(`span`,{className:`pb-1 text-xs text-muted-foreground`,children:[i===`completion`?`Directories here`:`Found beneath the Project Root`,r.truncated?` — showing the first few, keep typing`:null]}),r.paths.map(t=>(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b py-1 last:border-b-0`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs`,children:t}),(0,U.jsxs)(O,{variant:`ghost`,size:`sm`,onClick:()=>{e(t),n(``)},children:[(0,U.jsx)(Pn,{"aria-hidden":!0}),`Add`]})]},t))]})]})}function Ir({current:e,saving:t,onSave:n,onSaved:r}){let[i,a]=(0,H.useState)(e);return(0,H.useEffect)(()=>a(e),[e]),(0,U.jsxs)(Ie,{title:`Project Root`,description:(0,U.jsxs)(U.Fragment,{children:[`The directory Flow looks beneath for candidates, and the one it reports as its default Scope. Absolute, or starting with`,` `,(0,U.jsx)(`code`,{className:`font-mono text-xs`,children:`~`}),`. A Project outside it can still be added by path.`]}),children:[(0,U.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:`Where your repositories live`}),(0,U.jsx)(he,{className:`font-mono`,value:i,onChange:e=>a(e.target.value),placeholder:`~/workspace`,spellCheck:!1})]}),(0,U.jsx)(de,{dirty:i.trim()!==e,saving:t,onSave:()=>{(async()=>{let e=i.trim()===``?`Project Root cleared.`:`Project Root saved.`;await n({projects:{root:i.trim()}},e)&&await r()})()},onReset:()=>a(e)})]})}var Lr=H.createContext(void 0);function Rr(e){let t=H.useContext(Lr);if(!e&&t===void 0)throw Error(B(27));return t}var zr=H.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,s=Rr(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`),d={open:c,transitionStatus:s.useState(`transitionStatus`)};return j(`div`,e,{state:d,ref:[s.context.backdropRef,t],stateAttributesMapping:pt,props:[{role:`presentation`,hidden:!u,style:{userSelect:`none`,WebkitUserSelect:`none`}},o],enabled:a||!l})}),Br=H.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,...c}=e,l=Rr(),u=l.useState(`open`),{getButtonProps:f,buttonRef:p}=R({disabled:a,native:o}),m={disabled:a};function h(e){u&&l.setOpen(!1,d(s,e.nativeEvent))}return j(`button`,e,{state:m,ref:[t,p],props:[{onClick:h},c,f]})}),Vr=H.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=Rr(),c=xe(a);return s.useSyncedValueWithCleanup(`descriptionElementId`,c),j(`p`,e,{ref:t,props:[{id:c},o]})}),Hr=H.createContext(void 0);function Ur(){let e=H.useContext(Hr);if(e===void 0)throw Error(B(26));return e}var Wr={...$e,...Ee,nestedDialogOpen(e){return e?{"data-nested-dialog-open":``}:null}},Gr=H.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,initialFocus:o,...s}=e,c=Rr(),l=c.useState(`descriptionElementId`),u=c.useState(`disablePointerDismissal`),d=c.useState(`floatingRootContext`),f=c.useState(`popupProps`),p=c.useState(`modal`),m=c.useState(`mounted`),h=c.useState(`nested`),g=c.useState(`nestedOpenDialogCount`),_=c.useState(`open`),v=c.useState(`openMethod`),y=c.useState(`titleElementId`),b=c.useState(`transitionStatus`),x=c.useState(`role`),S=d.useState(`floatingId`);Ur(),we({open:_,ref:c.context.popupRef,onComplete(){_&&c.context.onOpenChangeComplete?.(!0)}});let C=o===void 0?_t(c.context.popupRef):o,w=g>0,T=c.useStateSetter(`popupElement`),E=j(`div`,e,{state:{open:_,nested:h,transitionStatus:b,nestedDialogOpen:w},props:[f,{id:S,"aria-labelledby":y,"aria-describedby":l,role:x,...wt,hidden:!m,onKeyDown(e){st.has(e.key)&&e.stopPropagation()},style:{"--nested-dialogs":g}},s],ref:[t,c.context.popupRef,T],stateAttributesMapping:Wr});return(0,U.jsx)(ct,{context:d,openInteractionType:v,disabled:!m,closeOnFocusOut:!u,initialFocus:C,returnFocus:a,modal:p!==!1,restoreFocus:`popup`,children:E})}),Kr=H.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=Rr(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,U.jsx)(Hr.Provider,{value:n,children:(0,U.jsxs)(u,{ref:t,...r,children:[a&&o===!0&&(0,U.jsx)(nt,{ref:i.context.internalBackdropRef,inert:Me(!s)}),e.children]})}):null});function qr({store:e,parentContext:t,isDrawer:n}){let r=e.useState(`open`),i=e.useState(`disablePointerDismissal`),a=e.useState(`modal`),o=e.useState(`popupElement`),s=e.useState(`floatingRootContext`),[c,l]=H.useState(0),[u,d]=H.useState(0),f=c===0,p=gt(s,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?`intentional`:{mouse:a===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(t){if(!e.context.outsidePressEnabledRef.current||`button`in t&&t.button!==0)return!1;if(`touches`in t){if(t.type===`touchend`){if(t.changedTouches.length!==1||t.touches.length!==0)return!1}else if(t.touches.length!==1)return!1}let n=Ae(t);if(f&&!i){if(a){let t=e.context.internalBackdropRef.current,r=e.context.backdropRef.current;return t||r?t===n||r===n||Te(n,o)&&!n?.hasAttribute(`data-base-ui-portal`):!0}return!0}return!1},escapeKey:f});return tt(r&&a===!0,o),e.useContextCallback(`onNestedDialogOpen`,(e,t)=>{l(e),d(t)}),V(()=>(t?.onNestedDialogOpen&&(r?t.onNestedDialogOpen(c+1,u+ +!!n):t.onNestedDialogOpen(0,0)),()=>{t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(0,0)}),[n,r,c,u,t]),bt(e,{activeTriggerProps:p.reference,inactiveTriggerProps:p.trigger,popupProps:p.floating,nestedOpenDialogCount:c,nestedOpenDrawerCount:u}),null}var Jr={...ur,modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role},Yr=class extends f{constructor(e,t,n){let r=new Ft,i=Xr(e,r,t,n);super(i,Zr(r),Jr)}setOpen=(e,t)=>{if(t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let n={open:e};Ot(n,e,t.trigger),this.update(n)}};function Xr(e,t,n,r=!1){let i={...rr(),modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:`dialog`,...e};return i.floatingRootContext=ir(t,n,r),i}function Zr(e){return{popupRef:H.createRef(),backdropRef:H.createRef(),internalBackdropRef:H.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}function Qr(e,t){let{children:n,open:r,defaultOpen:i=!1,onOpenChange:a,onOpenChangeComplete:o,disablePointerDismissal:s=!1,modal:c=!0,actionsRef:l,handle:u,triggerId:f,defaultTriggerId:p=null}=t,m=e===`drawer`,h=e===`alert-dialog`,g=h?!0:c,_=h||s,v=h?`alertdialog`:`dialog`,y=Rr(!0),b={modal:g,disablePointerDismissal:_,nested:y!=null,role:v},x=Nt((e,t)=>new Yr({open:i,openProp:r,activeTriggerId:p,triggerIdProp:f,...b},e,t),!0);x.useControlledProp(`openProp`,r),x.useControlledProp(`triggerIdProp`,f),x.useSyncedValues(b),x.useContextCallback(`onOpenChange`,a),x.useContextCallback(`onOpenChangeComplete`,o);let S=x.useState(`open`),C=x.useState(`mounted`),w=x.useState(`payload`);kt(x,S),Bt(x);let{forceUnmount:T}=vt(S,x);H.useImperativeHandle(l,()=>({unmount:T,close:()=>x.setOpen(!1,d(D))}),[T,x]);let E=S||C;return(0,U.jsxs)(Lr.Provider,{value:x,children:[u&&(0,U.jsx)(ht,{handle:u,store:x}),E&&(0,U.jsx)(qr,{store:x,parentContext:y?.context,isDrawer:m}),typeof n==`function`?n({payload:w}):n]})}function $r(e){return Qr(`dialog`,e)}var ei=H.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=Rr(),c=xe(a);return s.useSyncedValueWithCleanup(`titleElementId`,c),j(`h2`,e,{ref:t,props:[{id:c},o]})}),ti=H.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,payload:c,handle:l,...u}=e,d=Rr(!0),f=fr(l)??d;if(!f)throw Error(B(79));let p=xe(s),m=f.useState(`floatingRootContext`),h=f.useState(`isOpenedByTrigger`,p),g=f.useState(`triggerPopupId`,p),_=H.useRef(null),{registerTrigger:v,isMountedByThisTrigger:y}=St(p,_,f,{payload:c}),{getButtonProps:b,buttonRef:x}=R({disabled:a,native:o}),S=Ut(m),C=Tt(()=>f.select(`open`),e=>{f.set(`openMethod`,e)}),w={disabled:a,open:h},T=f.useState(`triggerProps`,y);return j(`button`,e,{state:w,ref:[x,t,v,_],props:[S.reference,T,C,{[k]:``,id:p,"aria-haspopup":`dialog`,"aria-expanded":h,"aria-controls":g},u,b],stateAttributesMapping:mt})});function ni({...e}){return(0,U.jsx)($r,{"data-slot":`dialog`,...e})}function ri({...e}){return(0,U.jsx)(ti,{"data-slot":`dialog-trigger`,...e})}function ii({...e}){return(0,U.jsx)(Kr,{"data-slot":`dialog-portal`,...e})}function ai({className:e,...t}){return(0,U.jsx)(zr,{"data-slot":`dialog-overlay`,className:g(`fixed inset-0 isolate z-50 bg-black/30 duration-100 supports-backdrop-filter:backdrop-blur-sm data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function oi({className:e,children:t,showCloseButton:n=!0,...r}){return(0,U.jsxs)(ii,{children:[(0,U.jsx)(ai,{}),(0,U.jsxs)(Gr,{"data-slot":`dialog-content`,className:g(`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-6 rounded-[min(var(--radius-4xl),24px)] bg-popover p-6 text-sm text-popover-foreground shadow-xl ring-1 ring-foreground/5 duration-100 outline-none sm:max-w-md dark:ring-foreground/10 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r,children:[t,n&&(0,U.jsxs)(Br,{"data-slot":`dialog-close`,render:(0,U.jsx)(O,{variant:`ghost`,className:`absolute top-4 right-4 bg-secondary`,size:`icon-sm`}),children:[(0,U.jsx)(zn,{}),(0,U.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function si({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`dialog-header`,className:g(`flex flex-col gap-1.5`,e),...t})}function ci({className:e,showCloseButton:t=!1,children:n,...r}){return(0,U.jsxs)(`div`,{"data-slot":`dialog-footer`,className:g(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...r,children:[n,t&&(0,U.jsx)(Br,{render:(0,U.jsx)(O,{variant:`outline`}),children:`Close`})]})}function li({className:e,...t}){return(0,U.jsx)(ei,{"data-slot":`dialog-title`,className:g(`font-heading text-base leading-none font-medium`,e),...t})}function ui({className:e,...t}){return(0,U.jsx)(Vr,{"data-slot":`dialog-description`,className:g(`text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}function di({session:e,onClose:t}){let{connection:n,config:r}=Ue(),[i,a]=(0,H.useState)(e.suggestedScope??``),[o,s]=(0,H.useState)(()=>yn(e.scope,r.projectList??[])??``),[c,l]=(0,H.useState)(void 0),[u,d]=(0,H.useState)(!1),f=i.trim()!==``&&(!e.worktree||o.trim()!==``),p=async()=>{d(!0),l(void 0);try{await n.command({type:`relocate`,sessionId:e.id,scope:i.trim(),...e.worktree?{repo:o.trim()}:{}}),await n.command({type:`revive`,sessionId:e.id}),t()}catch(e){l(e instanceof Error?e.message:String(e))}finally{d(!1)}};return(0,U.jsx)(ni,{open:!0,onOpenChange:e=>e?void 0:t(),children:(0,U.jsxs)(oi,{className:`sm:max-w-lg`,children:[(0,U.jsxs)(si,{children:[(0,U.jsx)(li,{children:`Relocate Agent Session`}),(0,U.jsx)(ui,{children:`Its Scope no longer exists. Choose where its files are now.`})]}),(0,U.jsx)(ne,{label:`Old Scope`,children:e.scope}),(0,U.jsx)(fi,{label:`Scope`,value:i,onChange:a}),e.worktree?(0,U.jsx)(fi,{label:`Repository`,value:o,onChange:s}):null,c===void 0?null:(0,U.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:c}),(0,U.jsxs)(ci,{children:[(0,U.jsx)(O,{variant:`outline`,onClick:t,children:`Cancel`}),(0,U.jsx)(O,{disabled:!f||u,onClick:()=>void p(),children:`Relocate and revive`})]})]})})}function fi({label:e,value:t,onChange:n}){let r=Pr(t),i=(0,H.useId)();return(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(`label`,{htmlFor:i,className:`text-sm font-medium`,children:e}),(0,U.jsx)(he,{id:i,className:`font-mono`,value:t,onChange:e=>n(e.target.value),placeholder:`/path/to/folder`,spellCheck:!1}),r?.paths.filter(e=>e!==t).slice(0,5).map(e=>(0,U.jsx)(O,{variant:`ghost`,size:`sm`,className:`justify-start font-mono text-xs`,onClick:()=>n(e),children:e},e))]})}var pi=new Map;function mi(e,t){pi.set(e,structuredClone(t))}function hi(e){let t=pi.get(e);return t&&structuredClone(t)}function gi(e){pi.delete(e)}function _i(e){for(let t of pi.keys())e.has(t)||pi.delete(t)}var vi=2e3,yi=3e4,bi=(0,H.createContext)(void 0);function xi(){let e=(0,H.useContext)(bi);if(!e)throw Error(`useAgentSessions outside SessionsProvider`);return e}function Si({children:e}){let{connection:t}=Ue(),[n,r]=(0,H.useState)([]),[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(void 0),c=(0,H.useRef)(()=>{});(0,H.useEffect)(()=>{let e=!1,n,i,o=0,s=0,l=0,u=e=>{n&&clearTimeout(n),n=setTimeout(()=>void d(),e)},d=async()=>{if(e||document.hidden)return;i?.abort(),i=new AbortController;let n=++o;try{let i=await t.listSessions();if(e||n<=s)return;s=n,l=0,_i(new Set(i.map(e=>e.id))),r(i),a(!0),u(vi)}catch{if(e)return;a(!0),l+=1,u(Math.min(yi,vi*2**l))}},f=()=>{document.hidden||d()};return c.current=()=>void d(),d(),document.addEventListener(`visibilitychange`,f),()=>{e=!0,c.current=()=>{},n&&clearTimeout(n),i?.abort(),document.removeEventListener(`visibilitychange`,f)}},[t]);let l=(0,H.useCallback)(()=>c.current(),[]),u=n.find(e=>e.id===o);return(0,U.jsxs)(bi.Provider,{value:{sessions:n,loaded:i,nudge:l,relocate:s},children:[e,u?(0,U.jsx)(di,{session:u,onClose:()=>{s(void 0),l()}}):null]})}function Ci(){let{connection:e}=Ue(),{nudge:t,relocate:n}=xi();return(0,H.useCallback)(async r=>{try{let n=await e.command(r);return t(),n}catch(e){if(e.code===`scope_missing`&&`sessionId`in r){n(r.sessionId),t();return}ze.error(`${r.type} failed`,e instanceof Error?e.message:String(e)),t();return}},[e,t,n])}var wi=[`general`,`projects`,`permissions`,`providers`,`appearance`,`keyboard`,`workflows`,`secrets`,`mcp`],Ti={sessionId:void 0};function Ei(e){let[t=``,n=``]=e.replace(/^#\/?/,``).split(`?`,2),r=t.split(`/`).filter(e=>e!==``);if(r[0]===`settings`)return{sessionId:void 0,settings:ki(r[1])};let i=Di(r),a=new URLSearchParams(n).get(`settings`);return a===null?i:{...i,settings:ki(a)}}function Di(e){if(e[0]===`spend`)return{sessionId:void 0,spend:!0};if(e[0]===`schedules`){let t={sessionId:void 0,schedules:!0};if(e[1]===`occurrences`){let n=Ai(e[2]??``);return n?{...t,occurrenceId:n}:t}let n=Ai(e[1]??``);return n?{...t,scheduleId:n}:t}if(e[0]===`new`&&e[1])return{sessionId:void 0,backend:Ai(e[1])};if(e[0]!==`s`||e[1]===void 0)return Ti;let t=Ai(e[1]);return{sessionId:t===``?void 0:t}}function Oi(e){let t=e.spend?`#/spend`:e.schedules?`#/schedules${e.occurrenceId?`/occurrences/${encodeURIComponent(e.occurrenceId)}`:e.scheduleId?`/${encodeURIComponent(e.scheduleId)}`:``}`:e.sessionId===void 0?e.backend?`#/new/${encodeURIComponent(e.backend)}`:``:`#/s/${encodeURIComponent(e.sessionId)}`;return e.settings===void 0?t:`${t||`#/`}?settings=${e.settings}`}function ki(e){return wi.find(t=>t===Ai(e??``))??wi[0]}function Ai(e){try{return decodeURIComponent(e)}catch{return``}}function ji(e){return e.title||e.id}var Mi=60,Ni=[{key:`description`,shape:`text`},{key:`command`,shape:`text`},{key:`questions`,shape:`questions`},{key:`file_path`,shape:`path`},{key:`notebook_path`,shape:`path`},{key:`pattern`,shape:`text`},{key:`url`,shape:`text`},{key:`query`,shape:`text`},{key:`path`,shape:`path`},{key:`prompt`,shape:`text`}],Pi=Ni.filter(({key:e})=>e!==`description`);function Fi(e){return Li(e,Mi)}function Ii(e){return Li(e,1/0,Pi)}function Li(e,t,n=Ni){if(!e||typeof e!=`object`)return;let r=e;for(let e of n){let n=r[e.key];if(e.shape===`questions`){let e=Ri(n,t);if(e!==void 0)return e;continue}if(typeof n==`string`&&n.trim()!==``)return e.shape===`path`?Bi(n.trim(),t):zi(n,t)}let i=Object.values(r).filter(e=>typeof e==`string`),a=i.length===1?i[0]:void 0;return a&&a.trim()!==``?zi(a,t):void 0}function Ri(e,t){if(!Array.isArray(e)||e.length===0)return;let n=e[0];if(!n||typeof n!=`object`)return;let r=n.question;if(typeof r!=`string`||r.trim()===``)return;let i=e.length-1;return zi(i>0?`${r} (+${i} more)`:r,t)}function zi(e,t){let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}function Bi(e,t){return e.length<=t?e:`…${e.slice(-(t-1))}`}var Vi=H.createContext(void 0);function Hi(e){let t=H.useContext(Vi);if(t===void 0&&!e)throw Error(B(72));return t}var Ui={...ur,disabled:e=>e.disabled,instantType:e=>e.instantType,isInstantPhase:e=>e.isInstantPhase,trackCursorAxis:e=>e.trackCursorAxis,disableHoverablePopup:e=>e.disableHoverablePopup,lastOpenChangeReason:e=>e.openChangeReason,closeOnClick:e=>e.closeOnClick,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},Wi=class extends f{constructor(e,t,n){let r=new Ft;super(Gi(e,r,t,n),Ki(r),Ui)}setOpen=(e,t)=>{Mt(this,e,t,{extraState:{openChangeReason:t.reason}})};cancelPendingOpen(e){this.state.floatingRootContext.dispatchOpenChange(!1,d(z,e))}};function Gi(e,t,n,r=!1){let i={...rr(),disabled:!1,instantType:void 0,isInstantPhase:!1,trackCursorAxis:`none`,disableHoverablePopup:!1,openChangeReason:null,closeOnClick:!0,closeDelay:0,adaptiveOrigin:void 0,...e};return i.floatingRootContext=ir(t,n,r),i}function Ki(e){return{popupRef:H.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e}}var qi=ye(function(e){let{disabled:t=!1,defaultOpen:n=!1,open:r,disableHoverablePopup:i=!1,trackCursorAxis:a=`none`,actionsRef:o,onOpenChange:s,onOpenChangeComplete:c,handle:l,triggerId:u,defaultTriggerId:f=null,children:p}=e,m=Nt((e,t)=>new Wi({open:n,openProp:r,activeTriggerId:f,triggerIdProp:u},e,t));m.useControlledProp(`openProp`,r),m.useControlledProp(`triggerIdProp`,u),m.useContextCallback(`onOpenChange`,s),m.useContextCallback(`onOpenChangeComplete`,c);let h=m.useState(`open`),g=!t&&h,_=m.useState(`activeTriggerId`),v=m.useState(`mounted`),y=m.useState(`payload`);m.useSyncedValues({trackCursorAxis:a,disableHoverablePopup:i,disabled:t}),Bt(m,{closeOnActiveTriggerUnmount:!0});let{forceUnmount:b,transitionStatus:x}=vt(g,m),S=m.useState(`isInstantPhase`),C=m.useState(`instantType`),w=m.useState(`lastOpenChangeReason`),T=H.useRef(null);V(()=>{h&&t&&m.setOpen(!1,d(_e))},[h,t,m]),V(()=>{x===`ending`&&w===`none`||x!==`ending`&&S?(C!==`delay`&&(T.current=C),m.set(`instantType`,`delay`)):T.current!==null&&(m.set(`instantType`,T.current),T.current=null)},[x,S,w,C,m]),V(()=>{g&&(_??m.set(`payload`,void 0))},[m,_,g]),H.useImperativeHandle(o,()=>({unmount:b,close:()=>m.setOpen(!1,d(D))}),[b,m]);let E=g||v||!t&&a!==`none`;return(0,U.jsxs)(Vi.Provider,{value:m,children:[l&&(0,U.jsx)(ht,{handle:l,store:m}),E&&(0,U.jsx)(Ji,{store:m,disabled:t,trackCursorAxis:a}),typeof p==`function`?p({payload:y}):p]})});function Ji({store:e,disabled:t,trackCursorAxis:n}){let r=e.useState(`floatingRootContext`),i=gt(r,{enabled:!t,referencePress:()=>e.select(`closeOnClick`)}),a=tr(r,{enabled:!t&&n!==`none`,axis:n===`none`?void 0:n}),o=H.useMemo(()=>ee(a.reference,i.reference),[a.reference,i.reference]);return bt(e,{activeTriggerProps:o,inactiveTriggerProps:o,popupProps:i.floating??L}),null}var Yi=H.createContext(void 0);function Xi(){return H.useContext(Yi)}var Zi=`data-base-ui-tooltip-trigger`;function Qi(e){if(`composedPath`in e){let t=e.composedPath();for(let e=0;e<t.length;e+=1){let n=t[e];if(Fe(n))return n}}let t=e.target;return Fe(t)?t:null}function $i(e){let t=e;for(;t;){let e=t.closest(`[${Zi}]`);if(e)return e;let n=t.getRootNode();t=`host`in n&&Fe(n.host)?n.host:null}return null}var ea=c(function(e,t){let{render:n,className:r,style:i,handle:a,payload:o,disabled:s,delay:c,closeOnClick:l=!0,closeDelay:u,id:f,...p}=e,m=Hi(!0),h=fr(a)??m;if(!h)throw Error(B(82));let g=xe(f),v=h.useState(`isTriggerActive`,g),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`floatingRootContext`),S=H.useRef(null),C=c??600,w=u??0,{registerTrigger:T,isMountedByThisTrigger:E}=St(g,S,h,{payload:o,closeOnClick:l,closeDelay:w}),D=Xi(),{delayRef:O,isInstantPhase:k,hasProvider:A}=Qn(b,{open:y}),M=yr(b);h.useSyncedValue(`isInstantPhase`,k);let N=h.useState(`disabled`),P=s??N,F=Dt(P),I=h.useState(`trackCursorAxis`),L=h.useState(`disableHoverablePopup`),R=H.useRef(!1),ee=Be(),z=H.useRef(void 0);function te(){return A?Gn(O.current,`open`)===0?0:c??D??600:C}function V(e){let t=S.current;if(!t||!e)return!1;let n=$i(e);return n!==null&&n!==t&&Te(t,n)}function ne(e){let t=V(e);return R.current=t,t&&(M.openChangeTimeout.clear(),M.restTimeout.clear(),M.restTimeoutPending=!1,ee.clear()),t}let re=Sr(b,{enabled:!P,mouseOnly:!0,move:!1,handleClose:!L&&I!==`both`?Ar():null,restMs:te,delay(){return u==null&&A?{close:Gn(O.current,`close`)}:{close:w}},triggerElementRef:S,isActiveTrigger:v,isClosing:()=>h.select(`transitionStatus`)===`ending`,shouldOpen(){return!R.current}}),ie=mr(b,{enabled:!P}).reference,ae=e=>{let t=R.current,n=Qi(e),r=ne(n),i=S.current,a=i&&n&&Te(i,n);if(r&&h.select(`open`)&&h.select(`lastOpenChangeReason`)===`trigger-hover`){h.setOpen(!1,d(_,e));return}if(t&&!r&&a&&!F.current&&!h.select(`open`)&&i&&x(z.current)){let t=()=>{!R.current&&!F.current&&!h.select(`open`)&&h.setOpen(!0,d(_,e,i))},n=te();n===0?(ee.clear(),t()):ee.start(n,t)}},oe=h.useState(`triggerProps`,E);return j(`button`,e,{state:{open:y},ref:[t,T,S],props:[re,ie,E||I!==`none`?oe:void 0,{onMouseOver(e){ae(e.nativeEvent)},onFocus(e){V(Qi(e.nativeEvent))&&e.preventBaseUIHandler()},onMouseLeave(){R.current=!1,ee.clear(),z.current=void 0},onPointerEnter(e){z.current=e.pointerType},onPointerDown(e){z.current=e.pointerType,h.set(`closeOnClick`,l),l&&!h.select(`open`)&&h.cancelPendingOpen(e.nativeEvent)},onClick(e){l&&!h.select(`open`)&&h.cancelPendingOpen(e.nativeEvent)},id:g,"data-trigger-disabled":P?``:void 0,[Zi]:P?void 0:``},p],stateAttributesMapping:mt})}),ta=H.createContext(void 0);function na(){let e=H.useContext(ta);if(e===void 0)throw Error(B(70));return e}var ra=H.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return Hi().useState(`mounted`)||n?(0,U.jsx)(ta.Provider,{value:n,children:(0,U.jsx)(M,{ref:t,...r})}):null}),ia=H.createContext(void 0);function aa(){let e=H.useContext(ia);if(e===void 0)throw Error(B(71));return e}var oa=H.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a=`absolute`,side:o=`top`,align:s=`center`,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=Pe,style:g,..._}=e,v=Hi(),y=na(),b=v.useState(`open`),x=v.useState(`mounted`),S=v.useState(`trackCursorAxis`),C=v.useState(`disableHoverablePopup`),w=v.useState(`floatingRootContext`),T=v.useState(`instantType`),E=v.useState(`transitionStatus`),D=v.useState(`adaptiveOrigin`),O=ot({anchor:i,positionMethod:a,floatingRootContext:w,mounted:x,side:o,sideOffset:c,align:s,alignOffset:l,collisionBoundary:u,collisionPadding:d,sticky:p,arrowPadding:f,disableAnchorTracking:m,keepMounted:y,collisionAvoidance:h,adaptiveOrigin:D}),k=H.useMemo(()=>({open:b,side:O.side,align:O.align,anchorHidden:O.anchorHidden,instant:S===`none`?T:`tracking-cursor`}),[b,O.side,O.align,O.anchorHidden,S,T]),A=et(e,k,{styles:O.positionerStyles,transitionStatus:E,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!x,inert:!b||S===`both`||C});return(0,U.jsx)(ia.Provider,{value:O,children:A})}),sa=H.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Hi(),{side:s,align:c}=aa(),l=o.useState(`open`),u=o.useState(`instantType`),d=o.useState(`transitionStatus`),f=o.useState(`popupProps`),p=o.useState(`floatingRootContext`),m=o.useState(`disabled`),h=o.useState(`closeDelay`);we({open:l,ref:o.context.popupRef,onComplete(){l&&o.context.onOpenChangeComplete?.(!0)}}),br(p,{enabled:!m,closeDelay:h});let g=o.useStateSetter(`popupElement`);return j(`div`,e,{state:{open:l,side:s,align:c,instant:u,transitionStatus:d},ref:[t,o.context.popupRef,g],props:[wt,f,Pt(d),a],stateAttributesMapping:pt})}),ca=H.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Hi(),{arrowRef:s,side:c,align:l,arrowUncentered:u,arrowStyles:d}=aa(),f={open:o.useState(`open`),side:c,align:l,uncentered:u,instant:o.useState(`instantType`)};return j(`div`,e,{state:f,ref:[t,s],props:[{style:d,"aria-hidden":!0},a],stateAttributesMapping:$e})}),la=function(e){let{delay:t,closeDelay:n,timeout:r=400}=e,i=H.useMemo(()=>({open:t,close:n}),[t,n]);return(0,U.jsx)(Yi.Provider,{value:t,children:(0,U.jsx)(Zn,{delay:i,timeoutMs:r,children:e.children})})};function ua({delay:e=0,...t}){return(0,U.jsx)(la,{"data-slot":`tooltip-provider`,delay:e,...t})}function da({...e}){return(0,U.jsx)(qi,{"data-slot":`tooltip`,...e})}function fa({...e}){return(0,U.jsx)(ea,{"data-slot":`tooltip-trigger`,...e})}function pa({className:e,side:t=`top`,sideOffset:n=4,align:r=`center`,alignOffset:i=0,children:a,...o}){return(0,U.jsx)(ra,{children:(0,U.jsx)(oa,{align:r,alignOffset:i,side:t,sideOffset:n,className:`isolate z-50`,children:(0,U.jsxs)(sa,{"data-slot":`tooltip-content`,className:g(`z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-xl bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-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 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-lg data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...o,children:[a,(0,U.jsx)(ca,{className:`z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:translate-x-[1.5px] data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:translate-x-[-1.5px] data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:translate-x-[-1.5px] data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:translate-x-[1.5px] data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5`})]})})})}var ma=H.createContext(void 0);function ha(e){let t=H.useContext(ma);if(t===void 0&&!e)throw Error(B(33));return t}var ga=H.createContext(void 0);function _a(e){let t=H.useContext(ga);if(t===void 0&&!e)throw Error(B(36));return t}var va=H.createContext(void 0);function ya(e=!0){let t=H.useContext(va);if(t===void 0&&!e)throw Error(B(25));return t}function ba(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,{events:l}=a.useState(`floatingTreeRoot`),u=a.useState(`open`),d=ya(!0),f=d!==void 0;return H.useMemo(()=>({id:r,role:`menuitem`,tabIndex:u&&n?0:-1,onKeyDown(e){e.key===` `&&o?.current&&e.preventDefault()},onMouseMove(e){i&&l.emit(`itemhover`,{nodeId:i,target:e.currentTarget})},onClick(e){t&&l.emit(`close`,{domEvent:e,reason:We})},onMouseUp(e){if(d){let t=d.initialCursorPointRef.current;if(d.initialCursorPointRef.current=null,f&&t&&Math.abs(e.clientX-t.x)<=1&&Math.abs(e.clientY-t.y)<=1||f&&!He&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!f||e.button===2)&&c.type===`regular-item`&&m(s.current,e,{detail:1})}}),[t,n,r,l,i,u,a,o,s,d,f,c])}var xa={type:`regular-item`};function Sa(e){let{closeOnClick:t,disabled:n,highlighted:r,id:i,store:a,typingRef:o=a.context.typingRef,nativeButton:s,itemMetadata:c,nodeId:l}=e,u=H.useRef(null),{getButtonProps:d,buttonRef:f}=R({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=ba({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=H.useCallback(e=>ee(p,{onMouseEnter(){c.type===`submenu-trigger`&&c.setActive()}},e,d),[p,d,c]),h=I(u,f);return H.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var Ca=H.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!0,style:l,...u}=e,d=Et({guess:!0,label:a}),f=ha(!0),p=xe(i),{store:m}=_a(),h=m.useState(`disabled`),g=s||h,_=m.useState(`isActive`,d.index),v=m.useState(`itemProps`),{getItemProps:y,itemRef:b}=Sa({closeOnClick:c,disabled:g,highlighted:_,id:p,store:m,nativeButton:o,nodeId:f?.context.nodeId,itemMetadata:xa});return j(`div`,e,{state:{disabled:g,highlighted:_},props:[v,u,y],ref:[b,t,d.ref]})}),wa=H.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,{store:s}=_a(),{side:c,align:l}=ha(),u=it(!0)!=null,f=s.useState(`open`),p=s.useState(`transitionStatus`),m=s.useState(`popupProps`),h=s.useState(`mounted`),g=s.useState(`instantType`),_=s.useState(`activeTriggerElement`),v=s.useState(`parent`),y=s.useState(`lastOpenChangeReason`),b=s.useState(`rootId`),x=s.useState(`floatingRootContext`),S=s.useState(`floatingTreeRoot`),C=s.useState(`closeDelay`),w=s.useState(`hoverEnabled`),T=s.useState(`disabled`),E=s.useState(`openMethod`),D=v.type===`context-menu`;we({open:f,ref:s.context.popupRef,onComplete(){f&&s.context.onOpenChangeComplete?.(!0)}}),H.useEffect(()=>{function e(e){s.setOpen(!1,d(e.reason,e.domEvent))}return S.events.on(`close`,e),()=>{S.events.off(`close`,e)}},[S.events,s]),br(x,{enabled:w&&!T&&!D&&v.type!==`menubar`,closeDelay:C});let O=s.useStateSetter(`popupElement`),k={transitionStatus:p,side:c,align:l,open:f,nested:v.type===`menu`,instant:g},A=j(`div`,e,{state:k,ref:[t,s.context.popupRef,O],stateAttributesMapping:pt,props:[m,{onKeyDown(e){u&&st.has(e.key)&&e.stopPropagation()}},Pt(p),o,{"data-rootownerid":b}]}),M=v.type===void 0||D;return(_||v.type===`menubar`&&y!==`outside-press`)&&(M=!0),(0,U.jsx)(ct,{context:x,openInteractionType:E,modal:D,disabled:!h,returnFocus:a===void 0?M:a,initialFocus:v.type!==`menu`,restoreFocus:!0,externalTree:v.type===`menubar`?void 0:S,previousFocusableElement:_,nextFocusableElement:v.type===void 0?s.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:v.type===void 0?s.context.beforeContentFocusGuardRef:void 0,children:A})}),Ta=H.createContext(void 0);function Ea(){let e=H.useContext(Ta);if(e===void 0)throw Error(B(32));return e}var Da=H.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i}=_a();return i.useState(`mounted`)||n?(0,U.jsx)(Ta.Provider,{value:n,children:(0,U.jsx)(u,{ref:t,...r})}):null}),Oa=H.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o,align:s,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:f=5,arrowPadding:p=5,sticky:m=!1,disableAnchorTracking:h=!1,collisionAvoidance:g=ce,style:_,...v}=e,{store:b}=_a(),x=Ea(),S=ya(!0),C=b.useState(`parent`),w=b.useState(`floatingRootContext`),T=b.useState(`floatingTreeRoot`),E=b.useState(`mounted`),D=b.useState(`open`),O=b.useState(`modal`),k=b.useState(`openMethod`),A=b.useState(`activeTriggerElement`),j=b.useState(`transitionStatus`),M=b.useState(`positionerElement`),N=b.useState(`instantType`),P=b.useState(`adaptiveOrigin`),F=b.useState(`lastOpenChangeReason`),I=b.useState(`floatingNodeId`),L=b.useState(`floatingParentNodeId`),R=w.useState(`domReferenceElement`),ee=H.useRef(null),z=ke(M),B=n,te=c,ne=l,re=s,ie=g;C.type===`context-menu`&&(B=n??C.context?.anchor,re??=`start`,!o&&re!==`center`&&(ne=e.alignOffset??2,te=e.sideOffset??-5));let ae=o,oe=re;C.type===`menu`?(ae??=`inline-end`,oe??=`start`,ie=e.collisionAvoidance??Pe):C.type===`menubar`&&(ae??=C.context.orientation===`vertical`?`inline-end`:`bottom`,oe??=`start`);let se=C.type===`context-menu`,le=ot({anchor:B,floatingRootContext:w,positionMethod:S?`fixed`:r,mounted:E,side:ae,sideOffset:te,align:oe,alignOffset:ne,arrowPadding:se?0:p,collisionBoundary:u,collisionPadding:f,sticky:m,nodeId:I,keepMounted:x,disableAnchorTracking:h,collisionAvoidance:ie,shift:se?{crossAxis:!(`side`in ie&&ie.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:T,adaptiveOrigin:P});H.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===I&&b.set(`hoverEnabled`,!1),e.nodeId!==I&&e.parentNodeId===b.select(`floatingParentNodeId`)&&b.setOpen(!1,d(y)))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[b,T.events,I]),H.useEffect(()=>{if(b.select(`floatingParentNodeId`)==null)return;function e(e){if(e.open||e.nodeId!==b.select(`floatingParentNodeId`))return;let t=e.reason??`sibling-open`;b.setOpen(!1,d(t))}return T.events.on(`menuopenchange`,e),()=>{T.events.off(`menuopenchange`,e)}},[T.events,b]);let ue=Be();H.useEffect(()=>{D||ue.clear()},[D,ue]),H.useEffect(()=>{function e(e){if(!(!D||e.nodeId!==b.select(`floatingParentNodeId`))){if(e.target&&A&&A!==e.target){let e=b.select(`closeDelay`);e>0?ue.isStarted()||ue.start(e,()=>{b.setOpen(!1,d(y))}):b.setOpen(!1,d(y))}else ue.clear()}}return T.events.on(`itemhover`,e),()=>{T.events.off(`itemhover`,e)}},[T.events,D,A,b,ue]),H.useEffect(()=>{let e={open:D,nodeId:I,parentNodeId:L,reason:b.select(`lastOpenChangeReason`)};T.events.emit(`menuopenchange`,e)},[T.events,D,b,I,L]),V(()=>{let e=R,t=ee.current;if(e&&(ee.current=e),t&&e&&e!==t){b.set(`instantType`,void 0);let e=new AbortController;return z(()=>{b.set(`instantType`,`trigger-change`)},e.signal),()=>{e.abort()}}},[R,z,b]);let de={open:D,side:le.side,align:le.align,anchorHidden:le.anchorHidden,nested:C.type===`menu`,instant:N},fe=C.type===`menubar`&&C.context.modal;Ze(D&&(fe||O&&F!==`trigger-hover`),k===`touch`,M,A);let pe=et(e,de,{styles:le.positionerStyles,transitionStatus:j,props:v,refs:[t,b.useStateSetter(`positionerElement`)],hidden:!E,inert:!D}),me=E&&C.type!==`menu`&&(C.type!==`menubar`&&O&&F!==`trigger-hover`||C.type===`menubar`&&C.context.modal),he=null;return C.type===`menubar`?he=C.context.contentElement:C.type===void 0&&(he=A),(0,U.jsxs)(ma.Provider,{value:le,children:[me&&(0,U.jsx)(nt,{ref:C.type===`context-menu`||C.type===`nested-context-menu`?C.context.internalBackdropRef:null,inert:Me(!D),cutout:he}),(0,U.jsx)(Je,{id:I,children:(0,U.jsx)(Ye,{elementsRef:b.context.itemDomElements,labelsRef:b.context.itemLabels,children:pe})})]})}),ka=H.createContext(null);function Aa(e){let t=H.useContext(ka);if(t===null&&!e)throw Error(B(5));return t}var ja={...ur,disabled:e=>e.parent.type===`menubar`&&e.parent.context.disabled||e.disabled,modal:e=>(e.parent.type===void 0||e.parent.type===`context-menu`)&&(e.modal??!0),openMethod:e=>e.openMethod,allowMouseEnter:e=>e.allowMouseEnter,highlightItemOnHover:e=>e.highlightItemOnHover,parent:e=>e.parent,rootId:e=>e.parent.type===`menu`?e.parent.store.select(`rootId`):e.parent.type===void 0?e.rootId:e.parent.context.rootId,activeIndex:e=>e.activeIndex,isActive:(e,t)=>e.activeIndex===t,hoverEnabled:e=>e.hoverEnabled,instantType:e=>e.instantType,lastOpenChangeReason:e=>e.openChangeReason,floatingTreeRoot:e=>e.parent.type===`menu`?e.parent.store.select(`floatingTreeRoot`):e.floatingTreeRoot,floatingNodeId:e=>e.floatingNodeId,floatingParentNodeId:e=>e.floatingParentNodeId,itemProps:e=>e.itemProps,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin,keyboardEventRelay:e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type===`menu`)return e.parent.store.select(`keyboardEventRelay`)}},Ma=class extends f{constructor(e){super({...Pa(),...e},Na(),ja),this.unsubscribeParentListener=this.observe(`parent`,e=>{if(this.unsubscribeParentListener?.(),e.type===`menu`){let t=e.store.select(`rootId`),n=e.store.select(`floatingTreeRoot`),r=e.store.select(`keyboardEventRelay`);this.unsubscribeParentListener=e.store.subscribe(()=>{let i=e.store.select(`rootId`),a=e.store.select(`floatingTreeRoot`),o=e.store.select(`keyboardEventRelay`);(t!==i||n!==a||r!==o)&&(t=i,n=a,r=o,this.notifyAll())}),this.context.allowMouseUpTriggerRef=e.store.context.allowMouseUpTriggerRef;return}e.type!==void 0&&(this.context.allowMouseUpTriggerRef=e.context.allowMouseUpTriggerRef),this.unsubscribeParentListener=null})}setOpen(e,t){this.state.floatingRootContext.context.events.emit(`setOpen`,{open:e,eventDetails:t})}unsubscribeParentListener=null};function Na(){return{positionerRef:H.createRef(),popupRef:H.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:H.createRef(),beforeContentFocusGuardRef:H.createRef(),onOpenChangeComplete:void 0,triggerElements:new Ft}}function Pa(){return{...rr(),disabled:!1,modal:!0,openMethod:null,allowMouseEnter:!1,highlightItemOnHover:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new at,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:L,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0}}var Fa=H.createContext(void 0);function Ia(){return H.useContext(Fa)}var La=ye(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,defaultOpen:a=!1,disabled:o=!1,modal:s,loopFocus:c=!0,orientation:u=`vertical`,actionsRef:f,closeParentOnEsc:p=!1,handle:m,triggerId:h,defaultTriggerId:g=null,highlightItemOnHover:_=!0}=e,v=ya(!0),y=_a(!0),b=Aa(!0),x=Ia(),S=H.useMemo(()=>x&&y?{type:`menu`,store:y.store}:b?{type:`menubar`,context:b}:v&&!y?{type:`context-menu`,context:v}:{type:void 0},[v,y,b,x]),C=Ra({open:a,openProp:n,activeTriggerId:g,triggerIdProp:h,parent:S});C.useControlledProp(`openProp`,n),C.useControlledProp(`triggerIdProp`,h),C.useContextCallback(`onOpenChangeComplete`,i);let w=te(),T=te(),E=C.useState(`floatingTreeRoot`),O=ut(E),k=Qe(),j=C.useState(`open`),M=C.useState(`activeTriggerElement`),N=C.useState(`positionerElement`),P=C.useState(`hoverEnabled`),F=C.useState(`disabled`),I=C.useState(`lastOpenChangeReason`),R=C.useState(`parent`),z=C.useState(`activeIndex`),B=C.useState(`payload`),ne=C.useState(`floatingParentNodeId`),re=H.useRef(null),ie=H.useRef(R.type!==`context-menu`),ae=Be(),oe=H.useRef(!0),se=Be(),ce=ne!=null,{openMethod:le,triggerProps:ue}=Ke(j);C.useSyncedValues({disabled:o,highlightItemOnHover:_,modal:R.type===void 0?s:void 0,openMethod:le,rootId:w}),Bt(C);let{forceUnmount:de}=vt(j,C,()=>{C.set(`allowMouseEnter`,!1)});V(()=>{v&&!y?C.update({parent:{type:`context-menu`,context:v},floatingNodeId:O,floatingParentNodeId:k}):y&&C.update({floatingNodeId:O,floatingParentNodeId:k})},[v,y,O,k,C]),H.useEffect(()=>{if(j||(re.current=null),R.type===`context-menu`){if(!j){ae.clear(),ie.current=!1;return}ae.start(500,()=>{ie.current=!0})}},[ae,j,R.type]),V(()=>{!j&&!P&&C.set(`hoverEnabled`,!0)},[j,P,C]);let fe=A((e,t)=>{let n=t.reason;if(!e&&!C.select(`open`)||j===e&&t.trigger===M&&I===n)return;let i=Lt(t);if(!e&&t.trigger==null&&(t.trigger=M??void 0),r?.(e,t),t.isCanceled)return;C.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&a?.type===`click`&&a.pointerType===`touch`&&!oe.current)return;e&&n===`trigger-focus`?(oe.current=!1,se.start(300,()=>{oe.current=!0})):(oe.current=!0,se.clear());let o=(n===`trigger-press`||n===`item-press`)&&a.detail===0,s=!e&&(n===`escape-key`||n==null),c={open:e,openChangeReason:n};re.current=t.event,Ot(c,e,t.trigger,i()),C.update(c),R.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?C.set(`instantType`,`group`):o||s?C.set(`instantType`,o?`click`:`dismiss`):C.set(`instantType`,void 0)}),pe=Vt({popupStore:C,floatingId:T,nested:k!=null,onOpenChange:fe}),me=pe.context.events;V(()=>{let e=({open:e,eventDetails:t})=>fe(e,t);return me.on(`setOpen`,e),()=>{me?.off(`setOpen`,e)}},[me,fe]);let he=H.useCallback(()=>{C.setOpen(!1,d(D))},[C]);H.useImperativeHandle(f,()=>({unmount:de,close:he}),[de,he]);let ge;R.type===`context-menu`&&(ge=R.context),H.useImperativeHandle(ge?.positionerRef,()=>N,[N]),H.useImperativeHandle(ge?.actionsRef,()=>({setOpen:fe}),[fe]);let _e=gt(pe,{enabled:!F,bubbles:{escapeKey:p&&R.type===`menu`},outsidePress(){return R.type!==`context-menu`||re.current?.type===`contextmenu`||ie.current},externalTree:ce?E:void 0}),ve=Ge(),ye=H.useCallback(e=>{C.select(`activeIndex`)!==e&&C.set(`activeIndex`,e)},[C]),be=zt(pe,{enabled:!F,listRef:C.context.itemDomElements,activeIndex:z,nested:R.type!==void 0,loopFocus:c,orientation:u,parentOrientation:R.type===`menubar`?R.context.orientation:void 0,rtl:ve===`rtl`,disabledIndices:l,onNavigate:ye,openOnArrowKeyDown:R.type!==`context-menu`,externalTree:ce?E:void 0,focusItemOnHover:_}),xe=H.useCallback(e=>{C.context.typingRef.current=e},[C]),Se=yt(pe,{enabled:!F,listRef:C.context.itemLabels,elementsRef:C.context.itemDomElements,activeIndex:z,resetMs:500,onMatch:e=>{j&&e!==z&&C.set(`activeIndex`,e)},onTyping:xe}),Ce=H.useMemo(()=>{let e=ee(Se.reference,be.reference,_e.reference,{onMouseMove(){C.set(`allowMouseEnter`,!0)}},ue);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=j,e},[C,Se.reference,be.reference,_e.reference,ue,j]),we=H.useMemo(()=>{let e=ee(be.trigger,_e.trigger,ue);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[be.trigger,_e.trigger,ue]),Te=H.useMemo(()=>ee(wt,{id:T,role:`menu`,"aria-labelledby":M?.id,onMouseMove(){C.set(`allowMouseEnter`,!0),R.type===`menu`&&C.set(`hoverEnabled`,!1)},onClick(){C.select(`hoverEnabled`)&&C.set(`hoverEnabled`,!1)},onKeyDown(e){let t=C.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},Se.floating,be.floating,_e.floating),[M,T,R.type,C,Se.floating,be.floating,_e.floating]),Ee=be.item??L;bt(C,{floatingRootContext:pe,activeTriggerProps:Ce,inactiveTriggerProps:we,popupProps:Te,itemProps:Ee});let De=H.useMemo(()=>({store:C,parent:S}),[C,S]),Oe=(0,U.jsxs)(ga.Provider,{value:De,children:[m&&(0,U.jsx)(ht,{handle:m,store:C}),typeof t==`function`?t({payload:B}):t]});return R.type===void 0||R.type===`context-menu`?(0,U.jsx)(Ht,{externalTree:E,children:Oe}):Oe});function Ra(e){return a(()=>new Ma(e)).current}function za(e){let t=_a().store,n=H.useMemo(()=>({parentMenu:t}),[t]);return(0,U.jsx)(Fa.Provider,{value:n,children:(0,U.jsx)(La,{...e})})}function Ba(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=v(),{ref:i,index:a}=Et(e),o=n===a,s=H.useRef(null),c=I(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:c,index:a}}function Va(e){let{render:t,className:n,style:r,state:i=L,props:a=l,refs:o=l,metadata:s,stateAttributesMapping:c,tag:u=`div`,...d}=e,{compositeProps:f,compositeRef:p}=Ba({metadata:s});return j(u,e,{state:i,ref:[p,...o],props:[f,...a,d],stateAttributesMapping:c})}function Ha(e){if(se(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!le(e))return Ha(je(e))}function Ua(e,t){let n=H.useRef(null);function r(t){_n.flushSync(()=>{e.setOpen(!1,d(C,t.nativeEvent,t.currentTarget))}),me(n.current)?.focus()}function i(n){let r=e.select(`positionerElement`);if(r&&pe(n,r))e.context.beforeContentFocusGuardRef.current?.focus();else{_n.flushSync(()=>{e.setOpen(!1,d(C,n.nativeEvent,n.currentTarget))});let i=Ce(e.context.triggerFocusTargetRef.current||t.current);for(;i!==null&&Te(r,i);){let e=i;if(i=ue(i),i===e)break}i?.focus()}}return{preFocusGuardRef:n,handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function Wa(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=H.useRef(!1);return H.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,b(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:L,[t,n,r])}var Ga=c(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,openOnHover:c,delay:l=100,closeDelay:u=0,handle:d,payload:f,...p}=e,m=_a(!0),h=fr(d)??m?.store;if(!h)throw Error(B(85));let g=xe(s),_=h.useState(`isTriggerActive`,g),y=h.useState(`floatingRootContext`),x=h.useState(`isOpenedByTrigger`,g),S=h.useState(`triggerPopupId`,g),C=H.useRef(null),w=qa(),E=v(!0),D=Xe(),O=H.useMemo(()=>D??new at,[D]),k=ut(O),M=Qe(),{registerTrigger:N,isMountedByThisTrigger:P}=St(g,C,h,{payload:f,closeDelay:u,parent:w,floatingTreeRoot:O,floatingNodeId:k,floatingParentNodeId:M,keyboardEventRelay:E?.relayKeyboardEvent}),F=w.type===`menubar`,I=h.useState(`disabled`),z=a||I||F&&w.context.disabled,{getButtonProps:te,buttonRef:V}=R({disabled:z,native:o});H.useEffect(()=>{!x&&w.type===void 0&&(h.context.allowMouseUpTriggerRef.current=!1)},[h,x,w.type]);let ne=H.useRef(null),re=Be(),ie=A(e=>{if(!ne.current)return;re.clear(),h.context.allowMouseUpTriggerRef.current=!1;let t=e.target;Te(ne.current,t)||Te(h.select(`positionerElement`),t)||t===ne.current||(t==null||Ha(t)!==h.select(`rootId`))&&(lt(e,ne.current)||O.events.emit(`close`,{domEvent:e,reason:T}))});H.useEffect(()=>{x&&h.select(`lastOpenChangeReason`)===`trigger-hover`&&b(ne.current).addEventListener(`mouseup`,ie,{once:!0})},[x,ie,h]);let ae=F&&w.context.hasSubmenuOpen,se=Sr(y,{enabled:(c??ae)&&!z&&(!F||ae&&!P),handleClose:Ar({blockPointerEvents:!F}),mouseOnly:!0,move:!1,restMs:w.type===void 0?l:void 0,delay:{close:u},triggerElementRef:C,externalTree:O,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),ce=Ka(x,h.select(`lastOpenChangeReason`)),le=Ut(y,{enabled:!z,event:x&&F?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:w.type===void 0&&ce}),ue=mr(y,{enabled:!z&&ae}),de=Wa({open:x,enabled:F,mouseDownAction:`open`}),fe=H.useMemo(()=>ee(ue.reference,le.reference),[ue.reference,le.reference]),pe=h.useState(`triggerProps`,P),{preFocusGuardRef:me,handlePreFocusGuardFocus:he,handleFocusTargetFocus:ge}=Ua(h,C),_e={disabled:z,open:x},ve=[ne,t,V,N,C],ye=[fe,se??L,pe,{"aria-haspopup":`menu`,"aria-controls":S,id:g,onMouseDown:e=>{h.select(`open`)||(re.start(200,()=>{h.context.allowMouseUpTriggerRef.current=!0}),b(e.currentTarget).addEventListener(`mouseup`,ie,{once:!0}))}},F?{role:`menuitem`}:{},de,p,te],be=j(`button`,e,{enabled:!F,stateAttributesMapping:ft,state:_e,ref:ve,props:ye});return F?(0,U.jsx)(Va,{tag:`button`,render:n,className:r,style:i,state:_e,refs:ve,props:ye,stateAttributesMapping:ft}):x?(0,U.jsxs)(H.Fragment,{children:[(0,U.jsx)(oe,{ref:me,onFocus:he},`${g}-pre-focus-guard`),(0,U.jsx)(H.Fragment,{children:be},g),(0,U.jsx)(oe,{ref:h.context.triggerFocusTargetRef,onFocus:ge},`${g}-post-focus-guard`)]}):(0,U.jsx)(H.Fragment,{children:be},g)});function Ka(e,t){let n=Be(),[r,i]=H.useState(!1);return V(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function qa(){let e=Aa(!0);return H.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}var Ja=H.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return j(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})}),Ya={"aria-expanded":void 0},Xa=H.forwardRef(function(e,t){let{render:n,className:r,style:i,label:a,id:o,nativeButton:s=!1,openOnHover:c=!0,delay:l=100,closeDelay:u=0,disabled:d=!1,...f}=e,p=Ia();if(!p?.parentMenu)throw Error(B(37));let m=Et({guess:!0,label:a}),h=ha(),{store:g}=_a(),_=xe(o),v=g.useState(`open`),y=g.useState(`floatingRootContext`),b=g.useState(`floatingTreeRoot`),x=g.useState(`triggerPopupId`,_),S=xt(_,g),C=H.useCallback(e=>{let t=S(e);return e!==null&&g.select(`open`)&&g.select(`activeTriggerId`)==null&&g.update({activeTriggerId:_,activeTriggerElement:e,closeDelay:u}),t},[S,u,g,_]),w=H.useRef(null),T=H.useCallback(e=>{w.current=e,g.set(`activeTriggerElement`,e)},[g]);g.useSyncedValue(`closeDelay`,u);let E=p.parentMenu,D=g.useState(`disabled`),O=E.useState(`disabled`),k=d||D||O,A=E.useState(`itemProps`),M=E.useState(`isActive`,m.index),N=H.useMemo(()=>({type:`submenu-trigger`,setActive(){E.select(`highlightItemOnHover`)&&E.set(`activeIndex`,m.index)}}),[E,m.index]),{getItemProps:P,itemRef:F}=Sa({closeOnClick:!1,disabled:k,highlighted:M,id:_,store:g,typingRef:E.context.typingRef,nativeButton:s,itemMetadata:N,nodeId:h?.context.nodeId}),I=Sr(y,{enabled:g.useState(`hoverEnabled`)&&c&&!k,handleClose:Ar({blockPointerEvents:!0}),mouseOnly:!0,move:!0,restMs:l,delay:{open:l,close:u},shouldOpen:l>0?()=>E.select(`allowMouseEnter`):void 0,triggerElementRef:w,externalTree:b,isClosing:()=>g.select(`transitionStatus`)===`ending`,guardStaleOpen:!0}),R=Ut(y,{enabled:!k,event:`mousedown`,toggle:!c,ignoreMouse:c,stickIfOpen:!1}).reference??L,ee=g.useState(`triggerProps`,!0);delete ee.id;let z={disabled:k,highlighted:M,open:v},te=g.useState(`openMethod`),V=g.useState(`lastOpenChangeReason`)===`list-navigation`||te===`keyboard`;return j(`div`,e,{state:z,stateAttributesMapping:mt,props:[R,I,ee,A,v&&V&&Se?Ya:void 0,{"aria-controls":x,tabIndex:v||M?0:-1,onBlur(){M&&E.set(`activeIndex`,null)}},f,P],ref:[t,m.ref,F,C,T]})});function Za({...e}){return(0,U.jsx)(La,{"data-slot":`dropdown-menu`,...e})}function Qa({className:e,...t}){return(0,U.jsx)(Ga,{"data-slot":`dropdown-menu-trigger`,className:e,...t})}function $a({align:e=`start`,alignOffset:t=0,side:n=`bottom`,sideOffset:r=4,className:i,...a}){return(0,U.jsx)(Da,{children:(0,U.jsx)(Oa,{className:`isolate z-50 outline-none`,align:e,alignOffset:t,side:n,sideOffset:r,children:(0,U.jsx)(wa,{"data-slot":`dropdown-menu-content`,className:g(`z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-2xl bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/5 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-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 dark:ring-foreground/10 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95`,i),...a})})})}function eo({className:e,inset:t,variant:n=`default`,...r}){return(0,U.jsx)(Ca,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:g(`group/dropdown-menu-item relative flex min-h-7 cursor-default items-center gap-2 rounded-xl px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive`,e),...r})}function to({...e}){return(0,U.jsx)(za,{"data-slot":`dropdown-menu-sub`,...e})}function no({className:e,inset:t,children:n,...r}){return(0,U.jsxs)(Xa,{"data-slot":`dropdown-menu-sub-trigger`,"data-inset":t,className:g(`relative flex min-h-7 cursor-default items-center gap-2 rounded-xl px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r,children:[n,(0,U.jsx)(Cn,{className:`ml-auto`})]})}function ro({align:e=`start`,alignOffset:t=-3,side:n=`right`,sideOffset:r=0,className:i,...a}){return(0,U.jsx)($a,{"data-slot":`dropdown-menu-sub-content`,className:g(`w-auto min-w-[96px] rounded-2xl bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/5 duration-100 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 dark:ring-foreground/10 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,i),align:e,alignOffset:t,side:n,sideOffset:r,...a})}function io({className:e,...t}){return(0,U.jsx)(Ja,{"data-slot":`dropdown-menu-separator`,className:g(`-mx-1 my-1 h-px bg-border/50`,e),...t})}var ao=6e4,oo=60*ao,so=24*oo;function co(e,t=Date.now()){if(!e)return``;let n=Date.parse(e);if(Number.isNaN(n))return``;let r=Math.max(0,t-n);return r<ao?`just now`:r<oo?`${Math.floor(r/ao)}m`:r<so?`${Math.floor(r/oo)}h`:new Date(n).toISOString().slice(0,10)}function lo(e){if(!e||typeof e!=`object`)return;let t=e,n=typeof t.old_string==`string`?t.old_string:void 0,r=typeof t.new_string==`string`?t.new_string:typeof t.content==`string`?t.content:void 0;if(n!==void 0||r!==void 0)return{...typeof t.file_path==`string`?{path:t.file_path}:{},removed:fo(n),added:fo(r)}}function uo(e,t){let n=!!t?.trim();if(!n){let t=/^--- [^\n]*\n\+\+\+ [^\n]*\n/m.test(e),n=/^@@ -\d+(?:,\d+)? \+\d+(?:,\d+)? @@/m.test(e);if(!t||!n)return}let r=0,i=0;return(e.match(/[^\n]*\n|[^\n]+$/g)??[]).map(e=>{let t=/^@@ -\d+(?:,(\d+))? \+\d+(?:,(\d+))? @@/.exec(e);if(t)return r=Number(t[1]??1),i=Number(t[2]??1),{text:e,kind:`context`};let a=r>0||i>0,o=`context`;return(a||n)&&(e.startsWith(`-`)&&(a||!e.startsWith(`--- `))&&(o=`removed`),e.startsWith(`+`)&&(a||!e.startsWith(`+++ `))&&(o=`added`)),a&&((o===`removed`||e.startsWith(` `))&&(r=Math.max(0,r-1)),(o===`added`||e.startsWith(` `))&&(i=Math.max(0,i-1))),{text:e,kind:o}})}function fo(e){if(!e)return[];let t=e.split(`
|
|
3
3
|
`);for(;t.length>0&&t[t.length-1]===``;)t.pop();return t}var po=[[/^mcp__/,`mcp`],[/^(bash|shell|exec|run_?command)$/,`shell`],[/^(read|read_?file|view|notebookread)$/,`read`],[/^(write|write_?file|create_?file|notebookedit)$/,`write`],[/^(edit|multi_?edit|str_replace(_based_edit_tool|_editor)?|apply_?patch)$/,`edit`],[/^(grep|search|ripgrep)$/,`search`],[/^(glob|ls|list|find|list_?directory)$/,`list`],[/^(web_?fetch|web_?search|fetch)$/,`web`],[/^(task|agent)$/,`agent`],[/^todo_?write$/,`todo`]];function mo(e){let t=e.toLowerCase();return po.find(([e])=>e.test(t))?.[1]??`other`}function ho(e){if(typeof e==`string`)return e;let t=Array.isArray(e)?e:typeof e==`object`&&e&&Array.isArray(e.content)?e.content:void 0;if(!t)return;let n=t.flatMap(e=>typeof e==`object`&&e&&typeof e.text==`string`?[e.text]:[]);return n.length>0?n.join(`
|
|
4
4
|
`):void 0}function go(e){if(e!==void 0)return e.split(`
|
|
5
|
-
`).filter(e=>e.trim()!==``).length}function _o(e,t){return`${e} ${t}${e===1?``:`s`}`}function vo(e){if(e.status===`error`)return`failed`;if(e.status!==`complete`)return;let t=lo(e.input);if(t)return`+${t.added.length} −${t.removed.length}`;let n=go(ho(e.result));if(n!==void 0)switch(mo(e.name)){case`read`:return _o(n,`line`);case`list`:return _o(n,`file`);case`search`:return _o(n,`result`);default:return}}var yo={shell:In,read:En,write:Tn,edit:wn,search:Fn,list:Dn,web:kn,agent:xn,todo:An,mcp:Nn,other:Rn};function bo({name:e,className:t}){let n=yo[mo(e)];return(0,U.jsx)(n,{"aria-hidden":!0,className:g(`size-3.5 shrink-0`,t)})}var xo={scale:1,x:0,y:0};function So(e,t,n){let r=Math.min(8,Math.max(1,e.scale));return{scale:r,x:Math.min(0,Math.max(t-t*r,e.x)),y:Math.min(0,Math.max(n-n*r,e.y))}}function Co(e,t,n,r,i,a){let o=Math.min(8,Math.max(1,e.scale*t)),s=o/e.scale;return So({scale:o,x:n-(n-e.x)*s,y:r-(r-e.y)*s},i,a)}function wo(e,t,n,r,i){return So({...e,x:e.x+t,y:e.y+n},r,i)}function To({src:e,alt:t,className:n}){return(0,U.jsxs)(ni,{children:[(0,U.jsx)(ri,{render:(0,U.jsx)(`button`,{type:`button`,"aria-label":t?`Open ${t}`:`Open image`,className:`cursor-zoom-in rounded-md outline-none focus-visible:ring-3 focus-visible:ring-ring/30`}),children:(0,U.jsx)(`img`,{src:e,alt:t,className:g(`block`,n)})}),(0,U.jsxs)(oi,{className:`w-auto max-w-[80vw] gap-0 p-2 sm:max-w-[80vw]`,children:[(0,U.jsx)(li,{className:`sr-only`,children:t||`Image`}),(0,U.jsx)(Eo,{src:e,alt:t})]})]})}function Eo({src:e,alt:t}){let
|
|
5
|
+
`).filter(e=>e.trim()!==``).length}function _o(e,t){return`${e} ${t}${e===1?``:`s`}`}function vo(e){if(e.status===`error`)return`failed`;if(e.status!==`complete`)return;let t=lo(e.input);if(t)return`+${t.added.length} −${t.removed.length}`;let n=go(ho(e.result));if(n!==void 0)switch(mo(e.name)){case`read`:return _o(n,`line`);case`list`:return _o(n,`file`);case`search`:return _o(n,`result`);default:return}}var yo={shell:In,read:En,write:Tn,edit:wn,search:Fn,list:Dn,web:kn,agent:xn,todo:An,mcp:Nn,other:Rn};function bo({name:e,className:t}){let n=yo[mo(e)];return(0,U.jsx)(n,{"aria-hidden":!0,className:g(`size-3.5 shrink-0`,t)})}var xo={scale:1,x:0,y:0};function So(e,t,n){let r=Math.min(8,Math.max(1,e.scale));return{scale:r,x:Math.min(0,Math.max(t-t*r,e.x)),y:Math.min(0,Math.max(n-n*r,e.y))}}function Co(e,t,n,r,i,a){let o=Math.min(8,Math.max(1,e.scale*t)),s=o/e.scale;return So({scale:o,x:n-(n-e.x)*s,y:r-(r-e.y)*s},i,a)}function wo(e,t,n,r,i){return So({...e,x:e.x+t,y:e.y+n},r,i)}function To({src:e,alt:t,className:n,referrerPolicy:r,onError:i}){return(0,U.jsxs)(ni,{children:[(0,U.jsx)(ri,{render:(0,U.jsx)(`button`,{type:`button`,"aria-label":t?`Open ${t}`:`Open image`,className:`cursor-zoom-in rounded-md outline-none focus-visible:ring-3 focus-visible:ring-ring/30`}),children:(0,U.jsx)(`img`,{src:e,alt:t,loading:`lazy`,decoding:`async`,referrerPolicy:r,onError:i,className:g(`block`,n)})}),(0,U.jsxs)(oi,{className:`w-auto max-w-[80vw] gap-0 p-2 sm:max-w-[80vw]`,children:[(0,U.jsx)(li,{className:`sr-only`,children:t||`Image`}),(0,U.jsx)(Eo,{src:e,alt:t,referrerPolicy:r})]})]})}function Eo({src:e,alt:t,referrerPolicy:n}){let r=(0,H.useRef)(null),i=(0,H.useRef)(void 0),[a,o]=(0,H.useState)(xo);(0,H.useEffect)(()=>{let e=r.current;if(!e)return;let t=t=>{t.preventDefault();let n=e.getBoundingClientRect(),r=t.deltaMode===WheelEvent.DOM_DELTA_LINE?16:1,i=t.deltaX*r,a=t.deltaY*r;o(e=>t.ctrlKey?Co(e,Math.exp(-Math.max(-50,Math.min(50,a))*.01),t.clientX-n.left,t.clientY-n.top,n.width,n.height):wo(e,-i,-a,n.width,n.height))};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[]);let s=()=>r.current.getBoundingClientRect(),c=()=>{i.current=void 0};return(0,U.jsx)(`div`,{ref:r,className:g(`relative touch-none overflow-hidden rounded-md select-none`,a.scale>1?`cursor-grab active:cursor-grabbing`:`cursor-zoom-in`),onPointerDown:e=>{e.button===0&&(e.currentTarget.setPointerCapture(e.pointerId),i.current={x:e.clientX,y:e.clientY})},onPointerMove:e=>{let t=i.current;if(!t)return;let{width:n,height:r}=s(),a=e.clientX-t.x,c=e.clientY-t.y;i.current={x:e.clientX,y:e.clientY},o(e=>wo(e,a,c,n,r))},onPointerUp:c,onPointerCancel:c,onDoubleClick:e=>{let{left:t,top:n,width:r,height:i}=s(),a=e.clientX-t,c=e.clientY-n;o(e=>e.scale>1?xo:Co(e,2,a,c,r,i))},children:(0,U.jsx)(`img`,{src:e,alt:t,referrerPolicy:n,draggable:!1,className:`block max-h-[calc(80dvh-1rem)] max-w-[calc(80vw-1rem)] origin-top-left will-change-transform`,style:{transform:`translate(${a.x}px, ${a.y}px) scale(${a.scale})`}})})}function Do(e){if(!e.startsWith(`/`))return;let t=/^\/([A-Za-z0-9][\w-]*(?::(?:[A-Za-z0-9][\w-]*)?)?)?/.exec(e)?.[1]??``;return{name:t,to:t.length+1}}function Oo(e){let t=Do(e);if(!t||t.name===``||t.name.endsWith(`:`))return;let n=e[t.to];if(n===void 0||n===` `||n===`
|
|
6
6
|
`)return{...t,rest:e.slice(t.to)}}function ko(e,t){let n=(t??[]).filter(t=>e.startsWith(`mcp__${t.id}__`)).sort((e,t)=>t.id.length-e.id.length)[0];return n&&{connection:n.name,tool:e.slice(`mcp__${n.id}__`.length)}}function Ao({name:e}){let t=ko(e,Ue().config.mcp);return t?(0,U.jsxs)(da,{children:[(0,U.jsxs)(fa,{render:(0,U.jsx)(`span`,{}),children:[t.connection,` › `,t.tool]}),(0,U.jsx)(pa,{children:e})]}):e}var jo=[{decision:`allow`,label:`Allow once`,description:`Run it this time, and ask again next time.`},{decision:`deny`,label:`Deny`,description:`Refuse it, and stop asking for the rest of this turn.`},{decision:`always`,label:`Always allow on this machine`,description:`Run it, and never ask again in any Agent Session. Revocable in Settings.`}],Mo=jo.slice(0,2);function No(e){return e===!1?Mo:jo}function Po(e){switch(e){case void 0:return;case`asked`:return`waiting to be authorised`;case`allowed`:return`authorised`;case`always`:return`always authorised on this machine`;case`denied`:return`refused`}}function Fo({className:e,...t}){return(0,U.jsx)(`textarea`,{"data-slot":`textarea`,className:g(`flex field-sizing-content min-h-16 w-full resize-none rounded-2xl border border-transparent bg-input/50 px-2.5 py-2 text-base transition-[color,box-shadow] duration-200 outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,e),...t})}function Io(e){if(e.kind===`subagent`)return[e.name,e.description].filter(e=>e!==void 0&&e!==``).join(`
|
|
7
7
|
`);if(e.kind===`enquiry`)return e.questions.flatMap((t,n)=>[t.header,t.question,...t.options.map(e=>e.label),...e.answers?.[n]??[]]).filter(e=>e!==``).join(`
|
|
8
8
|
`);if(e.kind===`background_call`)return e.tool;if(e.kind!==`tool`)return e.text;let t=lo(e.input);return[e.name,zo(e.input),zo(e.result),t?.path].filter(e=>e!==void 0&&e!==``).join(`
|
|
@@ -74,9 +74,9 @@ ${this.parser.parse(e)}</blockquote>
|
|
|
74
74
|
${e}</tr>
|
|
75
75
|
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
76
76
|
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${lc(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=uc(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+lc(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=uc(e);if(i===null)return lc(n);e=i;let a=`<img src="${e}" alt="${lc(n)}"`;return t&&(a+=` title="${lc(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:lc(e.text)}},xc=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},Sc=class e{options;renderer;textRenderer;constructor(e){this.options=e||Wo,this.options.renderer=this.options.renderer||new bc,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new xc}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`checkbox`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`checkbox`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},Cc=class{options;block;constructor(e){this.options=e||Wo}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?yc.lex:yc.lexInline}provideParser(e=this.block){return e?Sc.parse:Sc.parseInline}},wc=new class{defaults=Uo();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Sc;Renderer=bc;TextRenderer=xc;Lexer=yc;Tokenizer=vc;Hooks=Cc;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new bc(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new vc(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new Cc;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];t[r]=Cc.passThroughHooks.has(n)?e=>{if(this.defaults.async&&Cc.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return yc.lex(e,t??this.defaults)}parser(e,t){return Sc.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?yc.lex:yc.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?Sc.parse:Sc.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?yc.lex:yc.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?Sc.parse:Sc.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
|
|
77
|
-
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+lc(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function Tc(e,t){return wc.parse(e,t)}Tc.options=Tc.setOptions=function(e){return wc.setOptions(e),Tc.defaults=wc.defaults,Go(Tc.defaults),Tc},Tc.getDefaults=Uo,Tc.defaults=Wo;function Ec(...e){return wc.use(...e),Tc.defaults=wc.defaults,Go(Tc.defaults),Tc}Tc.use=Ec,Tc.walkTokens=function(e,t){return wc.walkTokens(e,t)},Tc.parseInline=wc.parseInline,Tc.Parser=Sc,Tc.parser=Sc.parse,Tc.Renderer=bc,Tc.TextRenderer=xc,Tc.Lexer=yc,Tc.lexer=yc.lex,Tc.Tokenizer=vc,Tc.Hooks=Cc,Tc.parse=Tc,Tc.options,Tc.setOptions,Tc.walkTokens,Tc.parseInline,Sc.parse,yc.lex;function Dc(e,t={}){if(e===``)return[];try{return jc(Tc.lexer(e),t)}catch{return[{kind:`paragraph`,inlines:[{kind:`text`,text:e}]}]}}var Oc=new Set([`http:`,`https:`,`mailto:`]);function kc(e){try{return Oc.has(new URL(e).protocol)?e:void 0}catch{return}}var Ac=[1,2,3,4,5,6];function jc(e,t){return e.flatMap(e=>Mc(e,t))}function Mc(e,t){switch(e.type){case`space`:return[];case`heading`:return[{kind:`heading`,level:Ac[e.depth-1]??6,inlines:Ic(e.tokens,t)??[]}];case`paragraph`:return[{kind:`paragraph`,inlines:Ic(e.tokens,t)??[]}];case`text`:return[{kind:`paragraph`,inlines:Ic(e.tokens,t)??Uc(e)}];case`code`:return[{kind:`code`,text:e.text,...e.lang?{lang:e.lang}:{}}];case`blockquote`:return[{kind:`quote`,blocks:jc(e.tokens??[],t)}];case`hr`:return[{kind:`rule`}];case`list`:return[Nc(e,t)];case`table`:return[Fc(e,t)];case`html`:return[{kind:`paragraph`,inlines:Vc(e.raw,t)}];default:return[{kind:`paragraph`,inlines:Uc(e)}]}}function Nc(e,t){let n=e.ordered&&typeof e.start==`number`&&e.start!==1?e.start:void 0;return{kind:`list`,ordered:e.ordered,items:e.items.map(e=>Pc(e,t)),...n===void 0?{}:{start:n}}}function Pc(e,t){let n=jc(e.tokens.filter(e=>e.type!==`checkbox`),t);if(!e.task)return n;let r={kind:`text`,text:e.checked?`[x] `:`[ ] `},[i,...a]=n;return i?.kind===`paragraph`?[{kind:`paragraph`,inlines:[r,...i.inlines]},...a]:[{kind:`paragraph`,inlines:[r]},...n]}function Fc(e,t){let n=e=>e.map(e=>Ic(e.tokens,t)??[]);return{kind:`table`,header:n(e.header),rows:e.rows.map(n),align:e.align.map(e=>e??void 0)}}function Ic(e,t){return e?.flatMap(e=>Lc(e,t))}function Lc(e,t){switch(e.type){case`text`:return Ic(e.tokens,t)??[{kind:`text`,text:e.text}];case`escape`:return[{kind:`text`,text:e.text}];case`strong`:case`em`:case`del`:return[{kind:e.type,inlines:Ic(e.tokens,t)??[]}];case`codespan`:return[{kind:`code`,text:e.text}];case`br`:return[{kind:`break`}];case`link`:return[Rc(e,t)];case`image`:return[Bc(e.href,e.text,e.raw,t)];case`html`:return Vc(e.text,t);default:return Uc(e)}}function Rc(e,t){let n=zc(e.href,t.linkBase);return n===void 0?{kind:`text`,text:e.raw}:{kind:`link`,href:n,inlines:Ic(e.tokens,t)??[{kind:`text`,text:e.text}]}}function zc(e,t){if(!t)return kc(e);try{return kc(new URL(e,t).href)}catch{return}}function Bc(e,t,n,r){let i=r.images&&e.trim()?zc(e,r.imageBase):void 0;if(!i||!/^https?:\/\//i.test(i))return{kind:`text`,text:n};let a=new URL(i),o=/^\/([^/]+)\/([^/]+)\/(?:blob|raw)\/(.+)$/.exec(a.pathname);a.hostname===`github.com`&&o&&(a.hostname=`raw.githubusercontent.com`,a.pathname=`/${o[1]}/${o[2]}/${o[3]}`);let s=a.hostname===`raw.githubusercontent.com`||a.hostname===`github.com`&&a.pathname.startsWith(`/user-attachments/assets/`);return{kind:`image`,src:r.imageProxy&&s?`${r.imageProxy}${encodeURIComponent(a.href)}`:a.href,alt:t}}function Vc(e,t){let n=e.match(/<img\b(?:[^"'<>]|"[^"]*"|'[^']*')*\/?>/gi);return!t.images||!n||n.join(``).replace(/\s/g,``)!==e.replace(/\s/g,``)?[{kind:`text`,text:e}]:n.map(e=>{let n=new Map;for(let t of e.slice(4,-1).matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g)){let e=t[1].toLowerCase();n.has(e)||n.set(e,Hc(t[2]??t[3]??t[4]??``))}return Bc(n.get(`src`)??``,n.get(`alt`)??`Screenshot`,e,t)})}function Hc(e){let t={amp:`&`,quot:`"`,apos:`'`,lt:`<`,gt:`>`};return e.replace(/&(#x[0-9a-f]+|#\d+|amp|quot|apos|lt|gt);/gi,(e,n)=>{if(!n.startsWith(`#`))return t[n.toLowerCase()]??e;let r=n[1]?.toLowerCase()===`x`?parseInt(n.slice(2),16):parseInt(n.slice(1),10);return r>0&&r<=1114111?String.fromCodePoint(r):e})}function Uc(e){return[{kind:`text`,text:e.raw}]}function Wc({blocks:e,query:t,trailing:n}){return(0,U.jsx)(`div`,{className:`space-y-3 text-sm leading-relaxed`,children:(0,U.jsx)(Gc,{blocks:e,query:t,trailing:n})})}function Gc({blocks:e,query:t,trailing:n}){return(0,U.jsx)(U.Fragment,{children:e.map((r,i)=>(0,U.jsx)(qc,{block:r,query:t,trailing:i===e.length-1?n:void 0},i))})}var Kc={1:`text-lg`,2:`text-base`};function qc({block:e,query:t,trailing:n}){switch(e.kind){case`paragraph`:return(0,U.jsxs)(`p`,{className:`m-0 [overflow-wrap:anywhere]`,children:[(0,U.jsx)(Zc,{inlines:e.inlines,query:t}),n]});case`heading`:{let r=`h${e.level}`;return(0,U.jsxs)(r,{className:g(Kc[e.level]??`text-sm`,`m-0 pt-1 font-heading font-semibold tracking-tight [overflow-wrap:anywhere]`),children:[(0,U.jsx)(Zc,{inlines:e.inlines,query:t}),n]})}case`code`:return(0,U.jsxs)(`div`,{className:`overflow-hidden rounded-lg border bg-muted`,children:[e.lang===void 0?null:(0,U.jsx)(`div`,{className:`border-b px-3 py-1 font-mono text-xs text-muted-foreground`,children:e.lang}),(0,U.jsx)(`pre`,{className:`overflow-x-auto p-3`,children:(0,U.jsx)(`code`,{className:`font-mono text-sm`,children:(0,U.jsx)(Ho,{text:e.text,lang:e.lang,query:t,trailing:n})})})]});case`list`:{let r=e.ordered?`ol`:`ul`;return(0,U.jsx)(r,{className:g(`m-0 space-y-1 pl-5 marker:text-muted-foreground`,e.ordered?`list-decimal`:`list-disc`),...e.start===void 0?{}:{start:e.start},children:e.items.map((r,i)=>(0,U.jsx)(`li`,{className:`space-y-2 [overflow-wrap:anywhere]`,children:(0,U.jsx)(Gc,{blocks:r,query:t,trailing:i===e.items.length-1?n:void 0})},i))})}case`quote`:return(0,U.jsx)(`blockquote`,{className:`space-y-2 border-l-2 border-border pl-3 text-muted-foreground`,children:(0,U.jsx)(Gc,{blocks:e.blocks,query:t,trailing:n})});case`table`:return(0,U.jsx)(Xc,{block:e,query:t,trailing:n});case`rule`:return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`hr`,{className:`border-border`}),n]})}}var Jc={left:`text-left`,center:`text-center`,right:`text-right`},Yc=e=>e===void 0?`text-left`:Jc[e]??`text-left`;function Xc({block:e,query:t,trailing:n}){return(0,U.jsxs)(`div`,{className:`overflow-x-auto`,children:[(0,U.jsxs)(`table`,{className:`border-collapse text-sm tabular-nums`,children:[(0,U.jsx)(`thead`,{children:(0,U.jsx)(`tr`,{children:e.header.map((n,r)=>(0,U.jsx)(`th`,{className:g(`border-b px-2 py-1 font-semibold`,Yc(e.align[r])),children:(0,U.jsx)(Zc,{inlines:n,query:t})},r))})}),(0,U.jsx)(`tbody`,{children:e.rows.map((n,r)=>(0,U.jsx)(`tr`,{children:n.map((n,r)=>(0,U.jsx)(`td`,{className:g(`border-b border-border/50 px-2 py-1`,Yc(e.align[r])),children:(0,U.jsx)(Zc,{inlines:n,query:t})},r))},r))})]}),n]})}function Zc({inlines:e,query:t}){return(0,U.jsx)(U.Fragment,{children:e.map((e,n)=>(0,U.jsx)(Qc,{inline:e,query:t},n))})}function Qc({inline:e,query:t}){switch(e.kind){case`text`:return(0,U.jsx)(Bo,{text:e.text,query:t});case`strong`:return(0,U.jsx)(`strong`,{className:`font-semibold`,children:(0,U.jsx)(Zc,{inlines:e.inlines,query:t})});case`em`:return(0,U.jsx)(`em`,{children:(0,U.jsx)(Zc,{inlines:e.inlines,query:t})});case`del`:return(0,U.jsx)(`del`,{className:`text-muted-foreground`,children:(0,U.jsx)(Zc,{inlines:e.inlines,query:t})});case`code`:return(0,U.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono text-[0.9em] [overflow-wrap:anywhere]`,children:(0,U.jsx)(Bo,{text:e.text,query:t})});case`link`:return(0,U.jsx)(`a`,{href:e.href,target:`_blank`,rel:`noreferrer noopener`,className:`underline decoration-muted-foreground underline-offset-2 hover:decoration-foreground`,children:(0,U.jsx)(Zc,{inlines:e.inlines,query:t})});case`image`:return(0,U.jsx)($c,{src:e.src,alt:e.alt},e.src);case`break`:return(0,U.jsx)(`br`,{})}}function $c({src:e,alt:t}){let[n,r]=(0,H.useState)(!1);return n?(0,U.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Image unavailable`,t?`: ${t}`:``,`. Open the pull request on GitHub to view it.`]}):(0,U.jsx)(`img`,{src:e,alt:t,loading:`lazy`,decoding:`async`,referrerPolicy:`no-referrer`,onError:()=>r(!0),className:`my-2 max-h-[36rem] max-w-full rounded border object-contain`})}var el=(0,H.createContext)(void 0),tl=el.Provider;function nl(){return(0,H.useContext)(el)}function rl(e){let t=Math.max(0,e.activeSubagents),n=Math.max(0,e.activeBackgroundCalls),r=Math.max(0,e.activeWorkflows??0),i=[t>0?`${t} agent${t===1?``:`s`}`:void 0,n>0?`${n} background call${n===1?``:`s`}`:void 0,r>0?`${r} workflow${r===1?``:`s`}`:void 0].filter(e=>e!==void 0);if(i.length!==0)return`${i.length<3?i.join(` and `):`${i.slice(0,-1).join(`, `)} and ${i.at(-1)}`} running`}function il(e){let t=rl(e);return t===void 0?e.status:`${e.status}, ${t}`}function al(e,t){switch(e.status){case`running`:return{label:`started`,at:co(e.startedAt,t)};case`complete`:return{label:`finished`,at:co(e.endedAt??e.startedAt,t)};case`aborted`:return{label:`stopped`,at:co(e.endedAt??e.startedAt,t)};case`error`:return{label:`failed`,at:co(e.endedAt??e.startedAt,t)}}}function ol(e=3e4){let[t,n]=(0,H.useState)(()=>Date.now());return(0,H.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function sl({input:e,query:t}){let n=lo(e);return n?(0,U.jsxs)(`div`,{className:`overflow-hidden rounded-md border bg-muted`,children:[n.path===void 0?null:(0,U.jsx)(cl,{path:n.path}),(0,U.jsxs)(`div`,{className:`overflow-x-auto`,children:[n.removed.map((e,n)=>(0,U.jsx)(ll,{sign:`-`,line:e,query:t,kind:`removed`},`-${n}`)),n.added.map((e,n)=>(0,U.jsx)(ll,{sign:`+`,line:e,query:t,kind:`added`},`+${n}`))]})]}):null}function cl({path:e}){let t=e.lastIndexOf(`/`);return(0,U.jsxs)(`p`,{className:`m-0 truncate border-b px-2 py-1 font-mono text-xs`,children:[(0,U.jsx)(`span`,{className:`text-muted-foreground/70`,children:t<0?``:`${e.slice(0,t)}/`}),(0,U.jsx)(`span`,{className:`text-foreground`,children:t<0?e:e.slice(t+1)})]})}function ll({sign:e,line:t,query:n,kind:r}){return(0,U.jsxs)(`div`,{className:g(`grid grid-cols-[1.25rem_minmax(0,1fr)] font-mono text-xs whitespace-pre`,Vo(r)),children:[(0,U.jsx)(`span`,{className:`pl-2 select-none`,"aria-hidden":!0,children:e}),(0,U.jsx)(`span`,{children:(0,U.jsx)(Bo,{text:t,query:n})})]})}function ul({entry:e,query:t}){let n=lo(e.input)!==void 0;return(0,U.jsxs)(U.Fragment,{children:[n?null:(0,U.jsx)(fl,{label:`input`,value:e.input,query:t}),(0,U.jsx)(fl,{label:`update`,value:e.update,query:t}),(0,U.jsx)(fl,{label:`result`,value:e.result,query:t})]})}var dl=2e4;function fl({label:e,value:t,query:n}){if(t==null||t===``)return null;let r=typeof t==`string`?t:ml(t);if(r===``)return null;let i=e!==`input`&&r.length<=dl?pl(t):void 0;return(0,U.jsxs)(`div`,{className:`mt-1.5 first:mt-0`,children:[(0,U.jsx)(`p`,{className:`m-0 mb-1 text-xs text-muted-foreground`,children:e}),i?i.map(e=>(0,U.jsx)(fl,{label:e.label,value:e.text,query:n},e.label)):(0,U.jsx)(`pre`,{className:`m-0 max-h-72 overflow-auto rounded-md border bg-muted p-2 font-mono text-xs whitespace-pre-wrap text-foreground [overflow-wrap:anywhere]`,children:r.length>dl?r:(0,U.jsx)(Ho,{text:r,query:n})})]})}function pl(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e,n=t.content;if(!Array.isArray(n))return;let r=e=>{if(!e||typeof e!=`object`)return;let t=e;return t.type===`text`&&typeof t.text==`string`&&uo(t.text)?t.text:void 0};if(!n.some(e=>r(e)!==void 0))return;let i=n.flatMap((e,t)=>{let n=r(e),i=`content ${t+1}`;if(n===void 0)return[{label:i,text:ml(e)}];let{type:a,text:o,...s}=e,c=[{label:`${i} (text)`,text:n}];return Object.keys(s).length>0&&c.push({label:`${i} metadata`,text:ml(s)}),c}),{content:a,...o}=t;return Object.keys(o).length>0&&i.push({label:`metadata`,text:ml(o)}),i}function ml(e){try{return JSON.stringify(e,null,2)??``}catch{return String(e)}}function hl(e,t){let n=new Date(e),r=n.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`});return n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()&&n.getDate()===t.getDate()?r:`${n.toLocaleDateString(void 0,{day:`numeric`,month:`short`,...n.getFullYear()===t.getFullYear()?{}:{year:`numeric`}})}, ${r}`}var gl=(0,H.createContext)({}),_l=gl.Provider;function vl(){return(0,H.useContext)(gl).openSession}function yl({userMessageId:e}){let{rewind:t,fork:n}=(0,H.useContext)(gl);return(0,U.jsxs)(U.Fragment,{children:[t?(0,U.jsxs)(bl,{icon:(0,U.jsx)(Ln,{"aria-hidden":!0}),label:t.blocked??`Rewind to before this message`,disabled:t.blocked!==void 0,children:[(0,U.jsx)(eo,{onClick:()=>t.run(e,`conversation`),children:`Conversation`}),t.files?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(eo,{onClick:()=>t.run(e,`files`),children:`Code`}),(0,U.jsx)(eo,{onClick:()=>t.run(e,`both`),children:`Both`})]}):null]}):null,n?(0,U.jsxs)(bl,{icon:(0,U.jsx)(On,{"aria-hidden":!0}),label:`Fork from before this message`,children:[(0,U.jsx)(eo,{onClick:()=>n.run(e,!1),children:`Same Scope`}),n.worktree?(0,U.jsx)(eo,{onClick:()=>n.run(e,!0),children:`New Worktree`}):null]}):null]})}function bl({icon:e,label:t,disabled:n=!1,children:r}){return(0,U.jsxs)(Za,{children:[(0,U.jsxs)(da,{children:[(0,U.jsx)(fa,{render:(0,U.jsx)(Qa,{disabled:n,render:(0,U.jsx)(O,{variant:`ghost`,size:`icon-xs`,"aria-label":t,children:e})})}),(0,U.jsx)(pa,{children:t})]}),(0,U.jsx)($a,{className:`min-w-40`,children:r})]})}var xl=(0,H.memo)(function(e){return e.entry.rewound?(0,U.jsx)(`div`,{className:`opacity-50`,children:Sl(e)}):Sl(e)});function Sl({entry:e,query:t,sessionId:n,background:r}){switch(e.kind){case`user`:return(0,U.jsx)(Cl,{entry:e,query:t,sessionId:n});case`assistant`:return(0,U.jsx)(Tl,{entry:e,query:t});case`thinking`:return(0,U.jsx)(Ol,{entry:e,query:t});case`tool`:return(0,U.jsx)(kl,{entry:e,query:t,background:r});case`subagent`:return(0,U.jsx)(Ml,{entry:e,query:t});case`background_call`:return(0,U.jsx)(Pl,{entry:e});case`enquiry`:return(0,U.jsx)(Al,{entry:e,query:t});case`notice`:return(0,U.jsx)(zl,{entry:e,query:t});case`marker`:return(0,U.jsx)(Vl,{entry:e});default:return null}}function Cl({entry:e,query:t,sessionId:n}){let r=(0,H.useMemo)(()=>Dc(e.text),[e.text]);return(0,U.jsxs)(`div`,{className:`group/message relative flex flex-col items-end py-3 before:absolute before:inset-y-0 before:-right-[100vw] before:-left-[100vw] before:content-['']`,children:[(0,U.jsxs)(`div`,{className:g(`relative min-w-0 max-w-[90%] rounded-2xl rounded-br-sm px-4 py-3 sm:max-w-[80%]`,e.fromSessionId===void 0&&e.producer===void 0?`bg-muted`:`border border-border bg-muted/40 text-muted-foreground`),children:[e.fromSessionId===void 0?null:(0,U.jsxs)(`p`,{className:`m-0 mb-2 text-xs text-muted-foreground`,children:[`From `,(0,U.jsx)(Rl,{sessionId:e.fromSessionId,query:t}),` · not human authorization`]}),e.producer===void 0?null:(0,U.jsx)(`p`,{className:`m-0 mb-2 text-xs text-muted-foreground`,children:`From the parent agent · not human authorization`}),e.attachments?.length?(0,U.jsx)(wl,{ids:e.attachments,sessionId:n}):null,(0,U.jsx)(Wc,{blocks:r,query:t})]}),e.at?(0,U.jsx)(El,{at:e.at,side:`right`,children:e.rewound||e.producer?null:(0,U.jsx)(`span`,{className:`inline-flex [@media(hover:hover)]:opacity-0 [@media(hover:hover)]:group-hover/message:opacity-100 focus-within:opacity-100 has-[[aria-expanded=true]]:opacity-100`,children:(0,U.jsx)(yl,{userMessageId:e.id})})}):null]})}function wl({ids:e,sessionId:t}){return(0,U.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:e.map(e=>(0,U.jsx)(To,{src:`/api/sessions/${encodeURIComponent(t)}/attachments/${encodeURIComponent(e)}`,alt:``,className:`max-h-64 max-w-full rounded-md border border-border`},e))})}function Tl({entry:e,query:t}){let n=(0,H.useMemo)(()=>Dc(e.text),[e.text]);return(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(Hl,{children:(0,U.jsx)(Wc,{blocks:n,query:t,trailing:e.final?void 0:(0,U.jsx)(Dl,{})})}),e.endedAt?(0,U.jsx)(El,{at:e.endedAt,side:`left`}):null]})}function El({at:e,side:t,children:n}){return(0,U.jsxs)(`div`,{className:g(`relative mt-1 flex items-center gap-1 text-xs whitespace-nowrap text-muted-foreground/70`,t===`right`&&`flex-row-reverse @min-[68rem]/transcript:flex-row`,`@min-[68rem]/transcript:absolute @min-[68rem]/transcript:mt-0 @min-[68rem]/transcript:leading-[1.375rem]`,t===`right`?`text-right @min-[68rem]/transcript:bottom-6 @min-[68rem]/transcript:left-full @min-[68rem]/transcript:ml-4`:`@min-[68rem]/transcript:right-full @min-[68rem]/transcript:bottom-1 @min-[68rem]/transcript:mr-4`),children:[(0,U.jsx)(`time`,{dateTime:e,title:new Date(e).toLocaleString(),children:hl(e,new Date)}),n]})}function Dl(){return(0,U.jsx)(`span`,{className:`animate-caret-blink ml-px inline-block w-[1ch] text-primary`,"aria-hidden":!0,children:`▍`})}function Ol({entry:e,query:t}){let[n,r]=(0,H.useState)(!1),[i,a]=(0,H.useState)(!1),o=(0,H.useRef)(null),s=(0,H.useMemo)(()=>Dc(e.text),[e.text]),c=e.final&&!n,l=e.text.trim()===``;return(0,H.useLayoutEffect)(()=>{let e=o.current;if(!e||!c)return;let t=new ResizeObserver(()=>a(e.scrollHeight>e.clientHeight+1));return t.observe(e),()=>t.disconnect()},[c,l]),l?null:(0,U.jsxs)(Hl,{children:[(0,U.jsx)(`div`,{ref:o,className:g(`text-muted-foreground italic`,c&&`max-h-[4.5rem] overflow-hidden`),children:(0,U.jsx)(Wc,{blocks:s,query:t,trailing:e.final?void 0:(0,U.jsx)(Dl,{})})}),e.final&&(n||i)?(0,U.jsx)(`button`,{type:`button`,onClick:()=>r(!n),className:`mt-0.5 text-xs text-muted-foreground hover:text-foreground`,children:n?`less`:`more`}):null]})}function kl({entry:e,query:t,background:n}){let[r,i]=(0,H.useState)(void 0),a=r??e.status===`error`,o=Fi(e.input),s=Po(e.authorisation),c=vo(e);return(0,U.jsxs)(`details`,{open:a,onToggle:e=>i(e.currentTarget.open),className:`group/tool text-foreground`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-default items-center gap-2 rounded-md px-1.5 py-1 select-none hover:bg-muted/50 cursor-tilt relative [--tilt-angle-x:10deg] [--tilt-angle-y:1.5deg] [--tilt-lift:1.005]`,children:[(0,U.jsx)(bo,{name:e.name,className:e.status===`error`||n?.status===`error`?`text-destructive`:`text-muted-foreground`}),(0,U.jsx)(`span`,{className:`min-w-0 shrink-0 text-sm text-muted-foreground [overflow-wrap:anywhere]`,children:(0,U.jsx)(Ao,{name:e.name})}),o===void 0?null:(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-muted-foreground/80`,children:o}),s?(0,U.jsx)(`span`,{className:g(`ml-auto shrink-0 text-xs`,e.authorisation===`denied`?`text-destructive`:e.authorisation===`asked`?`text-status-awaiting`:`text-muted-foreground`),children:s}):e.status===`running`?(0,U.jsx)(jn,{"aria-label":`running`,className:`ml-auto size-3.5 shrink-0 animate-spin text-muted-foreground motion-reduce:animate-none`}):n?(0,U.jsx)(Fl,{entry:n}):c?(0,U.jsx)(`span`,{className:g(`ml-auto shrink-0 font-mono text-xs`,e.status===`error`?`text-destructive`:`text-muted-foreground`),children:c}):null]}),(0,U.jsxs)(`div`,{className:`my-1 ml-6 rounded-lg border p-3`,children:[(0,U.jsx)(sl,{input:e.input,query:t}),(0,U.jsx)(ul,{entry:e,query:t})]})]})}function Al({entry:e,query:t}){return(0,U.jsx)(`div`,{className:`text-foreground`,children:e.questions.map((n,r)=>(0,U.jsx)(jl,{entry:e,index:r,query:t},n.question))})}function jl({entry:e,index:t,query:n}){let r=e.questions[t],i=e.answers?.[t]??[],a=r.options.filter(e=>!i.includes(e.label)).map(e=>e.label);return(0,U.jsxs)(`details`,{className:`group/question`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-default items-center gap-2 rounded-md px-1.5 py-1 text-sm select-none hover:bg-muted/50 cursor-tilt relative [--tilt-angle-x:10deg] [--tilt-angle-y:1.5deg] [--tilt-lift:1.005]`,children:[(0,U.jsx)(Mn,{"aria-hidden":!0,className:g(`size-3.5 shrink-0 text-muted-foreground`,t>0&&`invisible`)}),(0,U.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,U.jsxs)(`span`,{className:`text-muted-foreground`,children:[r.header,` `]}),i.length===0?(0,U.jsx)(`span`,{className:`text-muted-foreground italic`,children:e.status===`asked`?`waiting…`:`no answer`}):(0,U.jsx)(Bo,{text:i.join(`, `),query:n})]}),(0,U.jsx)(Cn,{"aria-hidden":!0,className:`ml-auto size-3.5 shrink-0 text-muted-foreground transition-transform group-open/question:rotate-90`})]}),(0,U.jsxs)(`div`,{className:`mt-0.5 mb-1.5 ml-7 space-y-1 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,U.jsx)(`p`,{children:(0,U.jsx)(Bo,{text:r.question,query:n})}),a.length===0?null:(0,U.jsxs)(`p`,{className:`text-muted-foreground/70`,children:[i.length===0?`Options: `:`Other options: `,(0,U.jsx)(Bo,{text:a.join(` · `),query:n})]})]})]})}function Ml({entry:e,query:t}){let n=e.waitingOn?`waiting on ${e.waitingOn}`:e.status,r=e.status===`running`||e.status===`waiting`,i=nl(),a=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(xn,{"aria-hidden":!0,className:g(`size-3.5 shrink-0`,Nl(e.status)===`error`?`text-destructive`:`text-muted-foreground`)}),(0,U.jsx)(`span`,{className:`min-w-0 text-sm text-muted-foreground [overflow-wrap:anywhere] max-sm:col-start-2 max-sm:row-start-1 max-sm:truncate`,children:e.name}),e.description===void 0?null:(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-muted-foreground/80 max-sm:col-start-2 max-sm:col-end-4 max-sm:row-start-2`,children:(0,U.jsx)(Bo,{text:e.description,query:t})}),(0,U.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1.5 text-xs text-muted-foreground max-sm:col-start-3 max-sm:row-start-1`,children:[r?(0,U.jsx)(jn,{"aria-hidden":!0,className:`size-3.5 animate-spin motion-reduce:animate-none`}):null,n]})]}),o=`flex w-full items-center gap-2 rounded-md px-1.5 py-1 text-foreground max-sm:grid max-sm:grid-cols-[14px_minmax(0,1fr)_auto] max-sm:gap-y-1`;return i===void 0?(0,U.jsx)(`div`,{className:o,children:a}):(0,U.jsx)(`button`,{type:`button`,onClick:()=>i(vn(e)),className:g(o,`text-left hover:bg-muted/50 cursor-tilt relative [--tilt-angle-x:10deg] [--tilt-angle-y:1.5deg] [--tilt-lift:1.005]`),children:a})}function Nl(e){return e===`error`?`error`:e===`running`?`running`:`complete`}function Pl({entry:e}){let t=al(e,ol());return(0,U.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md px-1.5 py-1 text-foreground`,children:[(0,U.jsx)(bo,{name:e.tool,className:Il(e.status)===`error`?`text-destructive`:`text-muted-foreground`}),(0,U.jsx)(`span`,{className:`min-w-0 text-sm text-muted-foreground [overflow-wrap:anywhere]`,children:e.tool}),(0,U.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground/70`,children:`in background`}),(0,U.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[e.status===`running`?(0,U.jsx)(jn,{"aria-hidden":!0,className:`size-3.5 animate-spin motion-reduce:animate-none`}):null,t.label,` `,t.at]})]})}function Fl({entry:e}){let t=al(e,ol());return(0,U.jsxs)(`span`,{className:g(`ml-auto flex shrink-0 items-center gap-1.5 text-xs`,e.status===`error`?`text-destructive`:`text-muted-foreground`),children:[e.status===`running`?(0,U.jsx)(jn,{"aria-hidden":!0,className:`size-3.5 animate-spin motion-reduce:animate-none`}):null,(0,U.jsx)(`span`,{className:`sr-only`,children:`in background,`}),t.label,` `,t.at]})}function Il(e){return e===`error`?`error`:e===`running`?`running`:`complete`}var Ll={info:`text-muted-foreground`,warn:`text-foreground`,error:`text-destructive`};function Rl({sessionId:e,query:t}){let{sessions:n}=xi(),r=n.find(t=>t.id===e);return r?(0,U.jsx)(`a`,{href:Oi({sessionId:r.id}),className:`rounded-sm font-sans font-medium text-foreground outline-none transition-[text-shadow] duration-150 hover:[text-shadow:0_0_8px_color-mix(in_srgb,currentColor_60%,transparent)] focus-visible:ring-3 focus-visible:ring-ring/30`,children:(0,U.jsx)(Bo,{text:ji(r),query:t})}):(0,U.jsx)(`span`,{className:`text-foreground`,children:(0,U.jsx)(Bo,{text:e,query:t})})}function zl({entry:e,query:t}){let n=Ll[e.level],r=e.sessionId===void 0?-1:e.text.indexOf(e.sessionId);return(0,U.jsx)(Hl,{gutter:`!`,gutterClassName:n,children:(0,U.jsx)(`p`,{className:g(`m-0 font-mono text-sm whitespace-pre-wrap [overflow-wrap:anywhere]`,n),children:r===-1||e.sessionId===void 0?(0,U.jsx)(Bo,{text:e.text,query:t}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Bo,{text:e.text.slice(0,r),query:t}),(0,U.jsx)(Rl,{sessionId:e.sessionId,query:t}),(0,U.jsx)(Bo,{text:e.text.slice(r+e.sessionId.length),query:t})]})})})}var Bl={revived:`text-primary`,settled:`text-muted-foreground`,dormant:`text-muted-foreground`,compacted:`text-muted-foreground`,rewound:`text-muted-foreground`,forked:`text-muted-foreground`};function Vl({entry:e}){let t=Bl[e.marker],n=vl();return(0,U.jsxs)(`div`,{className:g(`flex items-center gap-2 py-2`,t),role:`separator`,"aria-label":e.text,children:[(0,U.jsx)(`span`,{className:`h-px flex-1 bg-current opacity-50`,"aria-hidden":!0}),e.fromSessionId&&n?(0,U.jsx)(O,{variant:`link`,size:`xs`,className:`h-auto p-0 text-xs text-current`,onClick:()=>n(e.fromSessionId),children:`Forked from another Agent Session`}):(0,U.jsx)(`span`,{className:`text-xs`,children:e.text}),(0,U.jsx)(`span`,{className:`h-px flex-1 bg-current opacity-50`,"aria-hidden":!0})]})}function Hl({gutter:e,gutterClassName:t,children:n}){return(0,U.jsxs)(`div`,{className:g(`py-1`,e&&`grid grid-cols-[2ch_minmax(0,1fr)] gap-0`),children:[e?(0,U.jsx)(`span`,{"aria-hidden":!0,className:g(`font-mono text-sm select-none`,t),children:e}):null,n]})}function Ul(e,t=40){return e.scrollHeight-e.scrollTop-e.clientHeight<t}function Wl(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 Gl(e,t=`|`){return e.map(e=>vu(e)).join(t)}function Kl(e,t){return typeof t==`bigint`?t.toString():t}var ql=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function Jl(e){return new ql(e)}function Yl(e){return e==null}function Xl(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Zl(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var Ql=Symbol(`evaluating`);function $l(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Ql)return r===void 0&&(r=Ql,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function eu(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function tu(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function nu(e){return tu(e._zod.def)??e._zod.def.shape}function ru(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return eu(this,t,e),e},enumerable:!0,configurable:!0})}function iu(e,t,n){t in e?eu(e,t,n):e[t]=n}function au(e,t,n,r){let i=nu(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?ru(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):iu(e,a,r?r(n.value,a):n.value))}}function ou(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?ru(e,n,()=>t[n]):iu(e,n,r.value))}}function su(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function cu(e){return JSON.stringify(e)}function lu(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var uu=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function du(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var fu=Jl(()=>{if(od.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function pu(e){if(du(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return du(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function mu(e){return pu(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var hu=new Set([`string`,`number`,`symbol`]);function gu(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function _u(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function G(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 vu(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function yu(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}var bu={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},xu={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function Su(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return au(i,e,Cu(e,t)),_u(e,su(n,{shape:i,checks:[]}))}function Cu(e,t){let n=nu(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function wu(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(Cu(e,t)),a={};return au(a,e,Reflect.ownKeys(nu(e)).filter(e=>!i.has(e))),_u(e,su(n,{shape:a,checks:[]}))}function Tu(e,t){if(!pu(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=nu(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return _u(e,su(e._zod.def,{shape:Eu(e,t)}))}function Eu(e,t){let n={};return au(n,e,Reflect.ownKeys(nu(e))),ou(n,t),n}function Du(e,t){if(!pu(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return _u(e,su(e._zod.def,{shape:Eu(e,t)}))}function Ou(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return au(n,e,Reflect.ownKeys(nu(e))),au(n,t,Reflect.ownKeys(nu(t))),_u(e,su(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function ku(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(Cu(t,n)):void 0,o={};return au(o,t,Reflect.ownKeys(nu(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),_u(t,su(t._zod.def,{shape:o,checks:[]}))}function Au(e,t,n){let r=n?new Set(Cu(t,n)):void 0,i={};return au(i,t,Reflect.ownKeys(nu(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),_u(t,su(t._zod.def,{shape:i}))}function ju(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Mu(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Nu(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Pu(e){return typeof e==`string`?e:e?.message}function Fu(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function Iu(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:Pu(e.inst?._zod.def?.error?.(e))??Pu(a?.(e))??Pu(t?.error?.(e))??Pu(n.customError?.(e))??Pu(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}var Lu=/[\uD800-\uDBFF]/;function Ru(e){let t=e.length;if(!Lu.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function zu(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Bu(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function Vu(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function Hu(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):Ku(e,n,r.value)}}function Uu(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Wu(e,t,n){return Uu(e,t,n,!1)}function Gu(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Uu(this,n,r(this))},set(e){Uu(this,n,e)}})}return t}function Ku(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Uu(this,t,n.bind(this))},set(e){Uu(this,t,e)}})}function qu(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var Ju,Yu=!1,Xu={configurable:!0,get(){Yu=!0}};function K(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&Ju!==e._zod){Ju=void 0;return}Ju=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Xu);let e=Yu;Yu=!1;try{let r=n(this);return Yu?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),Yu||=e,r}catch(n){throw delete this[t],Yu||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}function Zu(e,t,n,r){let i=qu(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}var Qu=`~constantCatch`;function $u(e){let t=()=>e;return t[Qu]=!0,t}var ed,td={value:void 0,enumerable:!1},nd=`captureStackTrace`in Error?Error:null;function rd(e){let t=nd;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return nd=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function q(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){td.value=new a(r);try{Object.defineProperty(n,"_zod",td)}finally{td.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),Hu(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?rd(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var id=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},ad=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(ed=globalThis).__zod_globalConfig??(ed.__zod_globalConfig={});var od=globalThis.__zod_globalConfig;function sd(e){return e&&Object.assign(od,e),od}function cd(){let e=this._zod;return e.message??=JSON.stringify(e.def,Kl,2),e.message}function ld(e){this._zod.message=e}var ud={get:cd,set:ld,enumerable:!0,configurable:!0},dd={value:void 0,enumerable:!1},fd=new WeakSet([Object.prototype,Error.prototype]),pd=(e,t)=>{e.name=`$ZodError`,dd.value=t,Object.defineProperty(e,"issues",dd),dd.value=void 0,Object.defineProperty(e,"message",ud);let n=Object.getPrototypeOf(e);fd.has(n)||(fd.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},md=q(`$ZodError`,pd);q(`$ZodError`,pd,void 0,{Parent:Error});function hd(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function gd(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?hd(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function _d(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function vd(e,t){return{callee:t?.callee??e,Err:t?.Err}}var yd=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new id;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>Iu(e,o,sd())));throw uu(n,a?.callee??t),n}return s.value};return t},bd=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>Iu(e,o,sd())));throw uu(n,a?.callee??t),n}return s.value};return t},xd=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 id;return a.issues.length?Sd(e,a.issues,i):{success:!0,data:a.value}};function Sd(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>Iu(e,n,sd()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}var Cd=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?Sd(e,a.issues,i):{success:!0,data:a.value}},wd=Symbol.for(`zod.compile.invalid`),Td=Symbol.for(`zod.compile.fallback`),Ed=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==wd)return!0;if(r.definite===!0&&n===void 0)return!1}return Dd(e,t,n)});function Dd(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[Td]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new id;return a.issues.length===0}var Od=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},kd=e=>{let t=yd(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,vd(n,a))};return n},Ad=e=>{let t=yd(e),n=(e,r,i,a)=>t(e,r,i,vd(n,a));return n},jd=e=>{let t=bd(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,vd(n,a))};return n},Md=e=>{let t=bd(e),n=async(e,r,i,a)=>await t(e,r,i,vd(n,a));return n},Nd=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return xd(e)(t,n,i)},Pd=e=>(t,n,r)=>xd(e)(t,n,r),Fd=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Cd(e)(t,n,i)},Id=e=>async(t,n,r)=>Cd(e)(t,n,r),Ld=/^[cC][0-9a-z]{6,}$/,Rd=/^[0-9a-z]+$/,zd=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Bd=/^[0-9a-vA-V]{20}$/,Vd=/^[A-Za-z0-9]{27}$/,Hd=/^[a-zA-Z0-9_-]{21}$/;function Ud(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var Wd=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Gd=/^([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})$/,Kd=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,qd=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Jd=`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;function Yd(){return new RegExp(Jd,`u`)}var Xd=/^(?:(?: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])$/,Zd=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Qd=/^((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])$/,$d=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ef=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,tf=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,nf=/^https?$/,rf=/^\+[1-9]\d{6,14}$/,af=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;function of(e){return RegExp(`^${e}$`)}var sf=of(af);function cf(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function lf(e){return RegExp(`^${cf(e)}$`)}function uf(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${cf({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${cf({precision:e.precision})}`:n;return RegExp(`^${af}T(?:${r})$`)}var df=/^[\s\S]{0,}$/,ff=/^-?\d+$/,pf=/^-?\d+(?:\.\d+)?$/,mf=/^(?:true|false)$/i,hf=/^null$/i,gf=/^[^A-Z]*$/,_f=/^[^a-z]*$/,vf=q(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),yf=e=>{let t=e.value;return!Yl(t)&&t.length!==void 0},bf={number:`number`,bigint:`bigint`,object:`date`},xf=q(`$ZodCheckLessThan`,(e,t)=>{vf.init(e,t);let n=bf[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:bf[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Sf=q(`$ZodCheckGreaterThan`,(e,t)=>{vf.init(e,t);let n=bf[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:bf[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Cf=q(`$ZodCheckMultipleOf`,(e,t)=>{vf.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Zl(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})}}),wf=q(`$ZodCheckNumberFormat`,(e,t)=>{vf.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=bu[t.format];e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),Tf=q(`$ZodCheckMaxLength`,(e,t)=>{var n;vf.init(e,t),(n=e._zod.def).when??(n.when=yf),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?Ru(r):i)<=t.maximum)return;let a=zu(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Ef=q(`$ZodCheckMinLength`,(e,t)=>{var n;vf.init(e,t),(n=e._zod.def).when??(n.when=yf),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?Ru(r):i)>=t.minimum)return;let a=zu(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Df=q(`$ZodCheckLengthEquals`,(e,t)=>{var n;vf.init(e,t),(n=e._zod.def).when??(n.when=yf),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?Ru(r):i;if(a===t.length)return;let o=zu(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Of=q(`$ZodCheckStringFormat`,(e,t)=>{var n,r;vf.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),kf=q(`$ZodCheckRegex`,(e,t)=>{Of.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})}}),Af=q(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=gf,Of.init(e,t)}),jf=q(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=_f,Of.init(e,t)}),Mf=q(`$ZodCheckIncludes`,(e,t)=>{vf.init(e,t);let n=gu(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Nf=q(`$ZodCheckStartsWith`,(e,t)=>{vf.init(e,t);let n=RegExp(`^${gu(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Pf=q(`$ZodCheckEndsWith`,(e,t)=>{vf.init(e,t);let n=RegExp(`.*${gu(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Ff=q(`$ZodCheckOverwrite`,(e,t)=>{vf.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),If=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
77
|
+
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+lc(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function Tc(e,t){return wc.parse(e,t)}Tc.options=Tc.setOptions=function(e){return wc.setOptions(e),Tc.defaults=wc.defaults,Go(Tc.defaults),Tc},Tc.getDefaults=Uo,Tc.defaults=Wo;function Ec(...e){return wc.use(...e),Tc.defaults=wc.defaults,Go(Tc.defaults),Tc}Tc.use=Ec,Tc.walkTokens=function(e,t){return wc.walkTokens(e,t)},Tc.parseInline=wc.parseInline,Tc.Parser=Sc,Tc.parser=Sc.parse,Tc.Renderer=bc,Tc.TextRenderer=xc,Tc.Lexer=yc,Tc.lexer=yc.lex,Tc.Tokenizer=vc,Tc.Hooks=Cc,Tc.parse=Tc,Tc.options,Tc.setOptions,Tc.walkTokens,Tc.parseInline,Sc.parse,yc.lex;function Dc(e,t={}){if(e===``)return[];try{return jc(Tc.lexer(e),t)}catch{return[{kind:`paragraph`,inlines:[{kind:`text`,text:e}]}]}}var Oc=new Set([`http:`,`https:`,`mailto:`]);function kc(e){try{return Oc.has(new URL(e).protocol)?e:void 0}catch{return}}var Ac=[1,2,3,4,5,6];function jc(e,t){return e.flatMap(e=>Mc(e,t))}function Mc(e,t){switch(e.type){case`space`:return[];case`heading`:return[{kind:`heading`,level:Ac[e.depth-1]??6,inlines:Ic(e.tokens,t)??[]}];case`paragraph`:return[{kind:`paragraph`,inlines:Ic(e.tokens,t)??[]}];case`text`:return[{kind:`paragraph`,inlines:Ic(e.tokens,t)??Uc(e)}];case`code`:return[{kind:`code`,text:e.text,...e.lang?{lang:e.lang}:{}}];case`blockquote`:return[{kind:`quote`,blocks:jc(e.tokens??[],t)}];case`hr`:return[{kind:`rule`}];case`list`:return[Nc(e,t)];case`table`:return[Fc(e,t)];case`html`:return[{kind:`paragraph`,inlines:Vc(e.raw,t)}];default:return[{kind:`paragraph`,inlines:Uc(e)}]}}function Nc(e,t){let n=e.ordered&&typeof e.start==`number`&&e.start!==1?e.start:void 0;return{kind:`list`,ordered:e.ordered,items:e.items.map(e=>Pc(e,t)),...n===void 0?{}:{start:n}}}function Pc(e,t){let n=jc(e.tokens.filter(e=>e.type!==`checkbox`),t);if(!e.task)return n;let r={kind:`text`,text:e.checked?`[x] `:`[ ] `},[i,...a]=n;return i?.kind===`paragraph`?[{kind:`paragraph`,inlines:[r,...i.inlines]},...a]:[{kind:`paragraph`,inlines:[r]},...n]}function Fc(e,t){let n=e=>e.map(e=>Ic(e.tokens,t)??[]);return{kind:`table`,header:n(e.header),rows:e.rows.map(n),align:e.align.map(e=>e??void 0)}}function Ic(e,t){return e?.flatMap(e=>Lc(e,t))}function Lc(e,t){switch(e.type){case`text`:return Ic(e.tokens,t)??[{kind:`text`,text:e.text}];case`escape`:return[{kind:`text`,text:e.text}];case`strong`:case`em`:case`del`:return[{kind:e.type,inlines:Ic(e.tokens,t)??[]}];case`codespan`:return[{kind:`code`,text:e.text}];case`br`:return[{kind:`break`}];case`link`:return[Rc(e,t)];case`image`:return[Bc(e.href,e.text,e.raw,t)];case`html`:return Vc(e.text,t);default:return Uc(e)}}function Rc(e,t){let n=zc(e.href,t.linkBase);return n===void 0?{kind:`text`,text:e.raw}:{kind:`link`,href:n,inlines:Ic(e.tokens,t)??[{kind:`text`,text:e.text}]}}function zc(e,t){if(!t)return kc(e);try{return kc(new URL(e,t).href)}catch{return}}function Bc(e,t,n,r){let i=r.images&&e.trim()?zc(e,r.imageBase):void 0;if(!i||!/^https?:\/\//i.test(i))return{kind:`text`,text:n};let a=new URL(i),o=/^\/([^/]+)\/([^/]+)\/(?:blob|raw)\/(.+)$/.exec(a.pathname);a.hostname===`github.com`&&o&&(a.hostname=`raw.githubusercontent.com`,a.pathname=`/${o[1]}/${o[2]}/${o[3]}`);let s=a.hostname===`raw.githubusercontent.com`||a.hostname===`github.com`&&a.pathname.startsWith(`/user-attachments/assets/`);return{kind:`image`,src:r.imageProxy&&s?`${r.imageProxy}${encodeURIComponent(a.href)}`:a.href,alt:t}}function Vc(e,t){let n=e.match(/<img\b(?:[^"'<>]|"[^"]*"|'[^']*')*\/?>/gi);return!t.images||!n||n.join(``).replace(/\s/g,``)!==e.replace(/\s/g,``)?[{kind:`text`,text:e}]:n.map(e=>{let n=new Map;for(let t of e.slice(4,-1).matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g)){let e=t[1].toLowerCase();n.has(e)||n.set(e,Hc(t[2]??t[3]??t[4]??``))}return Bc(n.get(`src`)??``,n.get(`alt`)??`Screenshot`,e,t)})}function Hc(e){let t={amp:`&`,quot:`"`,apos:`'`,lt:`<`,gt:`>`};return e.replace(/&(#x[0-9a-f]+|#\d+|amp|quot|apos|lt|gt);/gi,(e,n)=>{if(!n.startsWith(`#`))return t[n.toLowerCase()]??e;let r=n[1]?.toLowerCase()===`x`?parseInt(n.slice(2),16):parseInt(n.slice(1),10);return r>0&&r<=1114111?String.fromCodePoint(r):e})}function Uc(e){return[{kind:`text`,text:e.raw}]}var Wc=(0,H.createContext)(void 0),Gc=Wc.Provider;function Kc(){return(0,H.useContext)(Wc)}function qc(e){let t=Xc(e);if(t===void 0)return;let[n,r,i,a]=t;return n?r?(i===`pull`||i===`issues`)&&a?`${n}/${r}#${a}`:i===`commit`&&a?`${n}/${r}@${a.slice(0,7)}`:t.join(`/`):n:`github.com`}function Jc(e,t){let n=Yc(e);return n!==void 0&&n===Yc(t)}function Yc(e){let[t,n,r,i]=Xc(e)??[];return r===`pull`&&i?`${t}/${n}/${i}`.toLowerCase():void 0}function Xc(e){let t;try{t=new URL(e)}catch{return}if(t.hostname===`github.com`||t.hostname===`www.github.com`)return t.pathname.split(`/`).filter(Boolean)}function Zc({blocks:e,query:t,trailing:n}){return(0,U.jsx)(`div`,{className:`space-y-3 text-sm leading-relaxed`,children:(0,U.jsx)(Qc,{blocks:e,query:t,trailing:n})})}function Qc({blocks:e,query:t,trailing:n}){return(0,U.jsx)(U.Fragment,{children:e.map((r,i)=>(0,U.jsx)(el,{block:r,query:t,trailing:i===e.length-1?n:void 0},i))})}var $c={1:`text-lg`,2:`text-base`};function el({block:e,query:t,trailing:n}){switch(e.kind){case`paragraph`:return(0,U.jsxs)(`p`,{className:`m-0 [overflow-wrap:anywhere]`,children:[(0,U.jsx)(il,{inlines:e.inlines,query:t}),n]});case`heading`:{let r=`h${e.level}`;return(0,U.jsxs)(r,{className:g($c[e.level]??`text-sm`,`m-0 pt-1 font-heading font-semibold tracking-tight [overflow-wrap:anywhere]`),children:[(0,U.jsx)(il,{inlines:e.inlines,query:t}),n]})}case`code`:return(0,U.jsxs)(`div`,{className:`overflow-hidden rounded-lg border bg-muted`,children:[e.lang===void 0?null:(0,U.jsx)(`div`,{className:`border-b px-3 py-1 font-mono text-xs text-muted-foreground`,children:e.lang}),(0,U.jsx)(`pre`,{className:`overflow-x-auto p-3`,children:(0,U.jsx)(`code`,{className:`font-mono text-sm`,children:(0,U.jsx)(Ho,{text:e.text,lang:e.lang,query:t,trailing:n})})})]});case`list`:{let r=e.ordered?`ol`:`ul`;return(0,U.jsx)(r,{className:g(`m-0 space-y-1 pl-5 marker:text-muted-foreground`,e.ordered?`list-decimal`:`list-disc`),...e.start===void 0?{}:{start:e.start},children:e.items.map((r,i)=>(0,U.jsx)(`li`,{className:`space-y-2 [overflow-wrap:anywhere]`,children:(0,U.jsx)(Qc,{blocks:r,query:t,trailing:i===e.items.length-1?n:void 0})},i))})}case`quote`:return(0,U.jsx)(`blockquote`,{className:`space-y-2 border-l-2 border-border pl-3 text-muted-foreground`,children:(0,U.jsx)(Qc,{blocks:e.blocks,query:t,trailing:n})});case`table`:return(0,U.jsx)(rl,{block:e,query:t,trailing:n});case`rule`:return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`hr`,{className:`border-border`}),n]})}}var tl={left:`text-left`,center:`text-center`,right:`text-right`},nl=e=>e===void 0?`text-left`:tl[e]??`text-left`;function rl({block:e,query:t,trailing:n}){return(0,U.jsxs)(`div`,{className:`overflow-x-auto`,children:[(0,U.jsxs)(`table`,{className:`border-collapse text-sm tabular-nums`,children:[(0,U.jsx)(`thead`,{children:(0,U.jsx)(`tr`,{children:e.header.map((n,r)=>(0,U.jsx)(`th`,{className:g(`border-b px-2 py-1 font-semibold`,nl(e.align[r])),children:(0,U.jsx)(il,{inlines:n,query:t})},r))})}),(0,U.jsx)(`tbody`,{children:e.rows.map((n,r)=>(0,U.jsx)(`tr`,{children:n.map((n,r)=>(0,U.jsx)(`td`,{className:g(`border-b border-border/50 px-2 py-1`,nl(e.align[r])),children:(0,U.jsx)(il,{inlines:n,query:t})},r))},r))})]}),n]})}function il({inlines:e,query:t}){return(0,U.jsx)(U.Fragment,{children:e.map((e,n)=>(0,U.jsx)(al,{inline:e,query:t},n))})}function al({inline:e,query:t}){switch(e.kind){case`text`:return(0,U.jsx)(Bo,{text:e.text,query:t});case`strong`:return(0,U.jsx)(`strong`,{className:`font-semibold`,children:(0,U.jsx)(il,{inlines:e.inlines,query:t})});case`em`:return(0,U.jsx)(`em`,{children:(0,U.jsx)(il,{inlines:e.inlines,query:t})});case`del`:return(0,U.jsx)(`del`,{className:`text-muted-foreground`,children:(0,U.jsx)(il,{inlines:e.inlines,query:t})});case`code`:return(0,U.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono text-[0.9em] [overflow-wrap:anywhere]`,children:(0,U.jsx)(Bo,{text:e.text,query:t})});case`link`:{let n=qc(e.href);return n===void 0?(0,U.jsx)(`a`,{href:e.href,target:`_blank`,rel:`noreferrer noopener`,className:`underline decoration-muted-foreground underline-offset-2 hover:decoration-foreground`,children:(0,U.jsx)(il,{inlines:e.inlines,query:t})}):(0,U.jsx)(ol,{inline:e,label:n,query:t})}case`image`:return(0,U.jsx)(cl,{src:e.src,alt:e.alt},e.src);case`break`:return(0,U.jsx)(`br`,{})}}function ol({inline:e,label:t,query:n}){let[r,...i]=e.inlines,a=i.length===0&&r?.kind===`text`&&r.text===e.href,o=Kc();return(0,U.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noreferrer noopener`,onClick:t=>{t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||o?.(e.href)&&t.preventDefault()},className:`inline-flex items-baseline gap-1 rounded-md bg-foreground/8 px-1 py-px align-baseline font-medium hover:bg-foreground/12 [overflow-wrap:anywhere]`,children:[(0,U.jsx)(sl,{className:`size-3 shrink-0 self-center`}),(0,U.jsx)(`span`,{children:a?(0,U.jsx)(Bo,{text:t,query:n}):(0,U.jsx)(il,{inlines:e.inlines,query:n})})]})}function sl({className:e}){return(0,U.jsx)(`svg`,{"aria-hidden":!0,viewBox:`0 0 24 24`,fill:`currentColor`,className:e,children:(0,U.jsx)(`path`,{d:`M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12`})})}function cl({src:e,alt:t}){let[n,r]=(0,H.useState)(!1);return n?(0,U.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Image unavailable`,t?`: ${t}`:``,`. Open the pull request on GitHub to view it.`]}):(0,U.jsx)(To,{src:e,alt:t,referrerPolicy:`no-referrer`,onError:()=>r(!0),className:`my-2 max-h-[36rem] max-w-full rounded border object-contain`})}var ll=(0,H.createContext)(void 0),ul=ll.Provider;function dl(){return(0,H.useContext)(ll)}function fl(e){let t=Math.max(0,e.activeSubagents),n=Math.max(0,e.activeBackgroundCalls),r=Math.max(0,e.activeWorkflows??0),i=[t>0?`${t} agent${t===1?``:`s`}`:void 0,n>0?`${n} background call${n===1?``:`s`}`:void 0,r>0?`${r} workflow${r===1?``:`s`}`:void 0].filter(e=>e!==void 0);if(i.length!==0)return`${i.length<3?i.join(` and `):`${i.slice(0,-1).join(`, `)} and ${i.at(-1)}`} running`}function pl(e){let t=fl(e);return t===void 0?e.status:`${e.status}, ${t}`}function ml(e,t){switch(e.status){case`running`:return{label:`started`,at:co(e.startedAt,t)};case`complete`:return{label:`finished`,at:co(e.endedAt??e.startedAt,t)};case`aborted`:return{label:`stopped`,at:co(e.endedAt??e.startedAt,t)};case`error`:return{label:`failed`,at:co(e.endedAt??e.startedAt,t)}}}function hl(e=3e4){let[t,n]=(0,H.useState)(()=>Date.now());return(0,H.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function gl({input:e,query:t}){let n=lo(e);return n?(0,U.jsxs)(`div`,{className:`overflow-hidden rounded-md border bg-muted`,children:[n.path===void 0?null:(0,U.jsx)(_l,{path:n.path}),(0,U.jsxs)(`div`,{className:`overflow-x-auto`,children:[n.removed.map((e,n)=>(0,U.jsx)(vl,{sign:`-`,line:e,query:t,kind:`removed`},`-${n}`)),n.added.map((e,n)=>(0,U.jsx)(vl,{sign:`+`,line:e,query:t,kind:`added`},`+${n}`))]})]}):null}function _l({path:e}){let t=e.lastIndexOf(`/`);return(0,U.jsxs)(`p`,{className:`m-0 truncate border-b px-2 py-1 font-mono text-xs`,children:[(0,U.jsx)(`span`,{className:`text-muted-foreground/70`,children:t<0?``:`${e.slice(0,t)}/`}),(0,U.jsx)(`span`,{className:`text-foreground`,children:t<0?e:e.slice(t+1)})]})}function vl({sign:e,line:t,query:n,kind:r}){return(0,U.jsxs)(`div`,{className:g(`grid grid-cols-[1.25rem_minmax(0,1fr)] font-mono text-xs whitespace-pre`,Vo(r)),children:[(0,U.jsx)(`span`,{className:`pl-2 select-none`,"aria-hidden":!0,children:e}),(0,U.jsx)(`span`,{children:(0,U.jsx)(Bo,{text:t,query:n})})]})}function yl({entry:e,query:t}){let n=lo(e.input)!==void 0;return(0,U.jsxs)(U.Fragment,{children:[n?null:(0,U.jsx)(xl,{label:`input`,value:e.input,query:t}),(0,U.jsx)(xl,{label:`update`,value:e.update,query:t}),(0,U.jsx)(xl,{label:`result`,value:e.result,query:t})]})}var bl=2e4;function xl({label:e,value:t,query:n}){if(t==null||t===``)return null;let r=typeof t==`string`?t:Cl(t);if(r===``)return null;let i=e!==`input`&&r.length<=bl?Sl(t):void 0;return(0,U.jsxs)(`div`,{className:`mt-1.5 first:mt-0`,children:[(0,U.jsx)(`p`,{className:`m-0 mb-1 text-xs text-muted-foreground`,children:e}),i?i.map(e=>(0,U.jsx)(xl,{label:e.label,value:e.text,query:n},e.label)):(0,U.jsx)(`pre`,{className:`m-0 max-h-72 overflow-auto rounded-md border bg-muted p-2 font-mono text-xs whitespace-pre-wrap text-foreground [overflow-wrap:anywhere]`,children:r.length>bl?r:(0,U.jsx)(Ho,{text:r,query:n})})]})}function Sl(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e,n=t.content;if(!Array.isArray(n))return;let r=e=>{if(!e||typeof e!=`object`)return;let t=e;return t.type===`text`&&typeof t.text==`string`&&uo(t.text)?t.text:void 0};if(!n.some(e=>r(e)!==void 0))return;let i=n.flatMap((e,t)=>{let n=r(e),i=`content ${t+1}`;if(n===void 0)return[{label:i,text:Cl(e)}];let{type:a,text:o,...s}=e,c=[{label:`${i} (text)`,text:n}];return Object.keys(s).length>0&&c.push({label:`${i} metadata`,text:Cl(s)}),c}),{content:a,...o}=t;return Object.keys(o).length>0&&i.push({label:`metadata`,text:Cl(o)}),i}function Cl(e){try{return JSON.stringify(e,null,2)??``}catch{return String(e)}}function wl(e,t){let n=new Date(e),r=n.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`});return n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()&&n.getDate()===t.getDate()?r:`${n.toLocaleDateString(void 0,{day:`numeric`,month:`short`,...n.getFullYear()===t.getFullYear()?{}:{year:`numeric`}})}, ${r}`}var Tl=(0,H.createContext)({}),El=Tl.Provider;function Dl(){return(0,H.useContext)(Tl).openSession}function Ol({userMessageId:e}){let{rewind:t,fork:n}=(0,H.useContext)(Tl);return(0,U.jsxs)(U.Fragment,{children:[t?(0,U.jsxs)(kl,{icon:(0,U.jsx)(Ln,{"aria-hidden":!0}),label:t.blocked??`Rewind to before this message`,disabled:t.blocked!==void 0,children:[(0,U.jsx)(eo,{onClick:()=>t.run(e,`conversation`),children:`Conversation`}),t.files?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(eo,{onClick:()=>t.run(e,`files`),children:`Code`}),(0,U.jsx)(eo,{onClick:()=>t.run(e,`both`),children:`Both`})]}):null]}):null,n?(0,U.jsxs)(kl,{icon:(0,U.jsx)(On,{"aria-hidden":!0}),label:`Fork from before this message`,children:[(0,U.jsx)(eo,{onClick:()=>n.run(e,!1),children:`Same Scope`}),n.worktree?(0,U.jsx)(eo,{onClick:()=>n.run(e,!0),children:`New Worktree`}):null]}):null]})}function kl({icon:e,label:t,disabled:n=!1,children:r}){return(0,U.jsxs)(Za,{children:[(0,U.jsxs)(da,{children:[(0,U.jsx)(fa,{render:(0,U.jsx)(Qa,{disabled:n,render:(0,U.jsx)(O,{variant:`ghost`,size:`icon-xs`,"aria-label":t,children:e})})}),(0,U.jsx)(pa,{children:t})]}),(0,U.jsx)($a,{className:`min-w-40`,children:r})]})}var Al=(0,H.memo)(function(e){return e.entry.rewound?(0,U.jsx)(`div`,{className:`opacity-50`,children:jl(e)}):jl(e)});function jl({entry:e,query:t,sessionId:n,background:r}){switch(e.kind){case`user`:return(0,U.jsx)(Ml,{entry:e,query:t,sessionId:n});case`assistant`:return(0,U.jsx)(Pl,{entry:e,query:t});case`thinking`:return(0,U.jsx)(Ll,{entry:e,query:t});case`tool`:return(0,U.jsx)(Rl,{entry:e,query:t,background:r});case`subagent`:return(0,U.jsx)(Vl,{entry:e,query:t});case`background_call`:return(0,U.jsx)(Ul,{entry:e});case`enquiry`:return(0,U.jsx)(zl,{entry:e,query:t});case`notice`:return(0,U.jsx)(Jl,{entry:e,query:t});case`marker`:return(0,U.jsx)(Xl,{entry:e});default:return null}}function Ml({entry:e,query:t,sessionId:n}){let r=(0,H.useMemo)(()=>Dc(e.text),[e.text]);return(0,U.jsxs)(`div`,{className:`group/message relative flex flex-col items-end py-3 before:absolute before:inset-y-0 before:-right-[100vw] before:-left-[100vw] before:content-['']`,children:[(0,U.jsxs)(`div`,{className:g(`relative min-w-0 max-w-[90%] rounded-2xl rounded-br-sm px-4 py-3 sm:max-w-[80%]`,e.fromSessionId===void 0&&e.producer===void 0?`bg-muted`:`border border-border bg-muted/40 text-muted-foreground`),children:[e.fromSessionId===void 0?null:(0,U.jsxs)(`p`,{className:`m-0 mb-2 text-xs text-muted-foreground`,children:[`From `,(0,U.jsx)(ql,{sessionId:e.fromSessionId,query:t})]}),e.producer===void 0?null:(0,U.jsx)(`p`,{className:`m-0 mb-2 text-xs text-muted-foreground`,children:`From the parent agent`}),e.attachments?.length?(0,U.jsx)(Nl,{ids:e.attachments,sessionId:n}):null,(0,U.jsx)(Zc,{blocks:r,query:t}),e.note===void 0?null:(0,U.jsx)(`p`,{className:`-mx-4 -mb-3 mt-3 rounded-b-2xl rounded-br-sm border-t border-border bg-background/60 px-4 py-2 text-xs text-muted-foreground`,children:e.note.replace(/^\[Flow\] /,``)})]}),e.at?(0,U.jsx)(Fl,{at:e.at,side:`right`,children:e.rewound||e.producer?null:(0,U.jsx)(`span`,{className:`inline-flex [@media(hover:hover)]:opacity-0 [@media(hover:hover)]:group-hover/message:opacity-100 focus-within:opacity-100 has-[[aria-expanded=true]]:opacity-100`,children:(0,U.jsx)(Ol,{userMessageId:e.id})})}):null]})}function Nl({ids:e,sessionId:t}){return(0,U.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:e.map(e=>(0,U.jsx)(To,{src:`/api/sessions/${encodeURIComponent(t)}/attachments/${encodeURIComponent(e)}`,alt:``,className:`max-h-64 max-w-full rounded-md border border-border`},e))})}function Pl({entry:e,query:t}){let n=(0,H.useMemo)(()=>Dc(e.text),[e.text]);return(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(Zl,{children:(0,U.jsx)(Zc,{blocks:n,query:t,trailing:e.final?void 0:(0,U.jsx)(Il,{})})}),e.endedAt?(0,U.jsx)(Fl,{at:e.endedAt,side:`left`}):null]})}function Fl({at:e,side:t,children:n}){return(0,U.jsxs)(`div`,{className:g(`relative mt-1 flex items-center gap-1 text-xs whitespace-nowrap text-muted-foreground/70`,t===`right`&&`flex-row-reverse @min-[68rem]/transcript:flex-row`,`@min-[68rem]/transcript:absolute @min-[68rem]/transcript:mt-0 @min-[68rem]/transcript:leading-[1.375rem]`,t===`right`?`text-right @min-[68rem]/transcript:bottom-6 @min-[68rem]/transcript:left-full @min-[68rem]/transcript:ml-4`:`@min-[68rem]/transcript:right-full @min-[68rem]/transcript:bottom-1 @min-[68rem]/transcript:mr-4`),children:[(0,U.jsx)(`time`,{dateTime:e,title:new Date(e).toLocaleString(),children:wl(e,new Date)}),n]})}function Il(){return(0,U.jsx)(`span`,{className:`animate-caret-blink ml-px inline-block w-[1ch] text-primary`,"aria-hidden":!0,children:`▍`})}function Ll({entry:e,query:t}){let[n,r]=(0,H.useState)(!1),[i,a]=(0,H.useState)(!1),o=(0,H.useRef)(null),s=(0,H.useMemo)(()=>Dc(e.text),[e.text]),c=e.final&&!n,l=e.text.trim()===``;return(0,H.useLayoutEffect)(()=>{let e=o.current;if(!e||!c)return;let t=new ResizeObserver(()=>a(e.scrollHeight>e.clientHeight+1));return t.observe(e),()=>t.disconnect()},[c,l]),l?null:(0,U.jsxs)(Zl,{children:[(0,U.jsx)(`div`,{ref:o,className:g(`text-muted-foreground italic`,c&&`max-h-[4.5rem] overflow-hidden`),children:(0,U.jsx)(Zc,{blocks:s,query:t,trailing:e.final?void 0:(0,U.jsx)(Il,{})})}),e.final&&(n||i)?(0,U.jsx)(`button`,{type:`button`,onClick:()=>r(!n),className:`mt-0.5 text-xs text-muted-foreground hover:text-foreground`,children:n?`less`:`more`}):null]})}function Rl({entry:e,query:t,background:n}){let[r,i]=(0,H.useState)(void 0),a=r??e.status===`error`,o=Fi(e.input),s=Po(e.authorisation),c=vo(e);return(0,U.jsxs)(`details`,{open:a,onToggle:e=>i(e.currentTarget.open),className:`group/tool text-foreground`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-default items-center gap-2 rounded-md px-1.5 py-1 select-none hover:bg-muted/50 cursor-tilt relative [--tilt-angle-x:10deg] [--tilt-angle-y:1.5deg] [--tilt-lift:1.005]`,children:[(0,U.jsx)(bo,{name:e.name,className:e.status===`error`||n?.status===`error`?`text-destructive`:`text-muted-foreground`}),(0,U.jsx)(`span`,{className:`min-w-0 shrink-0 text-sm text-muted-foreground [overflow-wrap:anywhere]`,children:(0,U.jsx)(Ao,{name:e.name})}),o===void 0?null:(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-muted-foreground/80`,children:o}),s?(0,U.jsx)(`span`,{className:g(`ml-auto shrink-0 text-xs`,e.authorisation===`denied`?`text-destructive`:e.authorisation===`asked`?`text-status-awaiting`:`text-muted-foreground`),children:s}):e.status===`running`?(0,U.jsx)(jn,{"aria-label":`running`,className:`ml-auto size-3.5 shrink-0 animate-spin text-muted-foreground motion-reduce:animate-none`}):n?(0,U.jsx)(Wl,{entry:n}):c?(0,U.jsx)(`span`,{className:g(`ml-auto shrink-0 font-mono text-xs`,e.status===`error`?`text-destructive`:`text-muted-foreground`),children:c}):null]}),(0,U.jsxs)(`div`,{className:`my-1 ml-6 rounded-lg border p-3`,children:[(0,U.jsx)(gl,{input:e.input,query:t}),(0,U.jsx)(yl,{entry:e,query:t})]})]})}function zl({entry:e,query:t}){return(0,U.jsx)(`div`,{className:`text-foreground`,children:e.questions.map((n,r)=>(0,U.jsx)(Bl,{entry:e,index:r,query:t},n.question))})}function Bl({entry:e,index:t,query:n}){let r=e.questions[t],i=e.answers?.[t]??[],a=r.options.filter(e=>!i.includes(e.label)).map(e=>e.label);return(0,U.jsxs)(`details`,{className:`group/question`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-default items-center gap-2 rounded-md px-1.5 py-1 text-sm select-none hover:bg-muted/50 cursor-tilt relative [--tilt-angle-x:10deg] [--tilt-angle-y:1.5deg] [--tilt-lift:1.005]`,children:[(0,U.jsx)(Mn,{"aria-hidden":!0,className:g(`size-3.5 shrink-0 text-muted-foreground`,t>0&&`invisible`)}),(0,U.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,U.jsxs)(`span`,{className:`text-muted-foreground`,children:[r.header,` `]}),i.length===0?(0,U.jsx)(`span`,{className:`text-muted-foreground italic`,children:e.status===`asked`?`waiting…`:`no answer`}):(0,U.jsx)(Bo,{text:i.join(`, `),query:n})]}),(0,U.jsx)(Cn,{"aria-hidden":!0,className:`ml-auto size-3.5 shrink-0 text-muted-foreground transition-transform group-open/question:rotate-90`})]}),(0,U.jsxs)(`div`,{className:`mt-0.5 mb-1.5 ml-7 space-y-1 text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:[(0,U.jsx)(`p`,{children:(0,U.jsx)(Bo,{text:r.question,query:n})}),a.length===0?null:(0,U.jsxs)(`p`,{className:`text-muted-foreground/70`,children:[i.length===0?`Options: `:`Other options: `,(0,U.jsx)(Bo,{text:a.join(` · `),query:n})]})]})]})}function Vl({entry:e,query:t}){let n=e.waitingOn?`waiting on ${e.waitingOn}`:e.status,r=e.status===`running`||e.status===`waiting`,i=dl(),a=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(xn,{"aria-hidden":!0,className:g(`size-3.5 shrink-0`,Hl(e.status)===`error`?`text-destructive`:`text-muted-foreground`)}),(0,U.jsx)(`span`,{className:`min-w-0 text-sm text-muted-foreground [overflow-wrap:anywhere] max-sm:col-start-2 max-sm:row-start-1 max-sm:truncate`,children:e.name}),e.description===void 0?null:(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-muted-foreground/80 max-sm:col-start-2 max-sm:col-end-4 max-sm:row-start-2`,children:(0,U.jsx)(Bo,{text:e.description,query:t})}),(0,U.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1.5 text-xs text-muted-foreground max-sm:col-start-3 max-sm:row-start-1`,children:[r?(0,U.jsx)(jn,{"aria-hidden":!0,className:`size-3.5 animate-spin motion-reduce:animate-none`}):null,n]})]}),o=`flex w-full items-center gap-2 rounded-md px-1.5 py-1 text-foreground max-sm:grid max-sm:grid-cols-[14px_minmax(0,1fr)_auto] max-sm:gap-y-1`;return i===void 0?(0,U.jsx)(`div`,{className:o,children:a}):(0,U.jsx)(`button`,{type:`button`,onClick:()=>i(vn(e)),className:g(o,`text-left hover:bg-muted/50 cursor-tilt relative [--tilt-angle-x:10deg] [--tilt-angle-y:1.5deg] [--tilt-lift:1.005]`),children:a})}function Hl(e){return e===`error`?`error`:e===`running`?`running`:`complete`}function Ul({entry:e}){let t=ml(e,hl());return(0,U.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md px-1.5 py-1 text-foreground`,children:[(0,U.jsx)(bo,{name:e.tool,className:Gl(e.status)===`error`?`text-destructive`:`text-muted-foreground`}),(0,U.jsx)(`span`,{className:`min-w-0 text-sm text-muted-foreground [overflow-wrap:anywhere]`,children:e.tool}),(0,U.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground/70`,children:`in background`}),(0,U.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[e.status===`running`?(0,U.jsx)(jn,{"aria-hidden":!0,className:`size-3.5 animate-spin motion-reduce:animate-none`}):null,t.label,` `,t.at]})]})}function Wl({entry:e}){let t=ml(e,hl());return(0,U.jsxs)(`span`,{className:g(`ml-auto flex shrink-0 items-center gap-1.5 text-xs`,e.status===`error`?`text-destructive`:`text-muted-foreground`),children:[e.status===`running`?(0,U.jsx)(jn,{"aria-hidden":!0,className:`size-3.5 animate-spin motion-reduce:animate-none`}):null,(0,U.jsx)(`span`,{className:`sr-only`,children:`in background,`}),t.label,` `,t.at]})}function Gl(e){return e===`error`?`error`:e===`running`?`running`:`complete`}var Kl={info:`text-muted-foreground`,warn:`text-foreground`,error:`text-destructive`};function ql({sessionId:e,query:t}){let{sessions:n}=xi(),r=n.find(t=>t.id===e);return r?(0,U.jsx)(`a`,{href:Oi({sessionId:r.id}),className:`rounded-sm font-sans font-medium text-foreground outline-none transition-[text-shadow] duration-150 hover:[text-shadow:0_0_8px_color-mix(in_srgb,currentColor_60%,transparent)] focus-visible:ring-3 focus-visible:ring-ring/30`,children:(0,U.jsx)(Bo,{text:ji(r),query:t})}):(0,U.jsx)(`span`,{className:`text-foreground`,children:(0,U.jsx)(Bo,{text:e,query:t})})}function Jl({entry:e,query:t}){let n=Kl[e.level],r=e.sessionId===void 0?-1:e.text.indexOf(e.sessionId);return(0,U.jsx)(Zl,{gutter:`!`,gutterClassName:n,children:(0,U.jsx)(`p`,{className:g(`m-0 font-mono text-sm whitespace-pre-wrap [overflow-wrap:anywhere]`,n),children:r===-1||e.sessionId===void 0?(0,U.jsx)(Bo,{text:e.text,query:t}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Bo,{text:e.text.slice(0,r),query:t}),(0,U.jsx)(ql,{sessionId:e.sessionId,query:t}),(0,U.jsx)(Bo,{text:e.text.slice(r+e.sessionId.length),query:t})]})})})}var Yl={revived:`text-primary`,settled:`text-muted-foreground`,dormant:`text-muted-foreground`,compacted:`text-muted-foreground`,rewound:`text-muted-foreground`,forked:`text-muted-foreground`};function Xl({entry:e}){let t=Yl[e.marker],n=Dl();return(0,U.jsxs)(`div`,{className:g(`flex items-center gap-2 py-2`,t),role:`separator`,"aria-label":e.text,children:[(0,U.jsx)(`span`,{className:`h-px flex-1 bg-current opacity-50`,"aria-hidden":!0}),e.fromSessionId&&n?(0,U.jsx)(O,{variant:`link`,size:`xs`,className:`h-auto p-0 text-xs text-current`,onClick:()=>n(e.fromSessionId),children:`Forked from another Agent Session`}):(0,U.jsx)(`span`,{className:`text-xs`,children:e.text}),(0,U.jsx)(`span`,{className:`h-px flex-1 bg-current opacity-50`,"aria-hidden":!0})]})}function Zl({gutter:e,gutterClassName:t,children:n}){return(0,U.jsxs)(`div`,{className:g(`py-1`,e&&`grid grid-cols-[2ch_minmax(0,1fr)] gap-0`),children:[e?(0,U.jsx)(`span`,{"aria-hidden":!0,className:g(`font-mono text-sm select-none`,t),children:e}):null,n]})}function Ql(e,t=40){return e.scrollHeight-e.scrollTop-e.clientHeight<t}function $l(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 eu(e,t=`|`){return e.map(e=>Du(e)).join(t)}function tu(e,t){return typeof t==`bigint`?t.toString():t}var nu=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function ru(e){return new nu(e)}function iu(e){return e==null}function au(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function ou(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var su=Symbol(`evaluating`);function cu(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==su)return r===void 0&&(r=su,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function lu(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function uu(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function du(e){return uu(e._zod.def)??e._zod.def.shape}function fu(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return lu(this,t,e),e},enumerable:!0,configurable:!0})}function pu(e,t,n){t in e?lu(e,t,n):e[t]=n}function mu(e,t,n,r){let i=du(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?fu(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):pu(e,a,r?r(n.value,a):n.value))}}function hu(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?fu(e,n,()=>t[n]):pu(e,n,r.value))}}function gu(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function _u(e){return JSON.stringify(e)}function vu(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var yu=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function bu(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var xu=ru(()=>{if(hd.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Su(e){if(bu(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return bu(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Cu(e){return Su(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var wu=new Set([`string`,`number`,`symbol`]);function Tu(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Eu(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function G(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 Du(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function Ou(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}var ku={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Au={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function ju(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return mu(i,e,Mu(e,t)),Eu(e,gu(n,{shape:i,checks:[]}))}function Mu(e,t){let n=du(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function Nu(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(Mu(e,t)),a={};return mu(a,e,Reflect.ownKeys(du(e)).filter(e=>!i.has(e))),Eu(e,gu(n,{shape:a,checks:[]}))}function Pu(e,t){if(!Su(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=du(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Eu(e,gu(e._zod.def,{shape:Fu(e,t)}))}function Fu(e,t){let n={};return mu(n,e,Reflect.ownKeys(du(e))),hu(n,t),n}function Iu(e,t){if(!Su(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Eu(e,gu(e._zod.def,{shape:Fu(e,t)}))}function Lu(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return mu(n,e,Reflect.ownKeys(du(e))),mu(n,t,Reflect.ownKeys(du(t))),Eu(e,gu(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Ru(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(Mu(t,n)):void 0,o={};return mu(o,t,Reflect.ownKeys(du(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),Eu(t,gu(t._zod.def,{shape:o,checks:[]}))}function zu(e,t,n){let r=n?new Set(Mu(t,n)):void 0,i={};return mu(i,t,Reflect.ownKeys(du(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),Eu(t,gu(t._zod.def,{shape:i}))}function Bu(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Vu(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Hu(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Uu(e){return typeof e==`string`?e:e?.message}function Wu(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function Gu(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:Uu(e.inst?._zod.def?.error?.(e))??Uu(a?.(e))??Uu(t?.error?.(e))??Uu(n.customError?.(e))??Uu(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}var Ku=/[\uD800-\uDBFF]/;function qu(e){let t=e.length;if(!Ku.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function Ju(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Yu(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function Xu(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function Zu(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):td(e,n,r.value)}}function Qu(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function $u(e,t,n){return Qu(e,t,n,!1)}function ed(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Qu(this,n,r(this))},set(e){Qu(this,n,e)}})}return t}function td(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Qu(this,t,n.bind(this))},set(e){Qu(this,t,e)}})}function nd(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var rd,id=!1,ad={configurable:!0,get(){id=!0}};function K(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&rd!==e._zod){rd=void 0;return}rd=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,ad);let e=id;id=!1;try{let r=n(this);return id?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),id||=e,r}catch(n){throw delete this[t],id||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}function od(e,t,n,r){let i=nd(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}var sd=`~constantCatch`;function cd(e){let t=()=>e;return t[sd]=!0,t}var ld,ud={value:void 0,enumerable:!1},dd=`captureStackTrace`in Error?Error:null;function fd(e){let t=dd;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return dd=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function q(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){ud.value=new a(r);try{Object.defineProperty(n,"_zod",ud)}finally{ud.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),Zu(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?fd(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var pd=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},md=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(ld=globalThis).__zod_globalConfig??(ld.__zod_globalConfig={});var hd=globalThis.__zod_globalConfig;function gd(e){return e&&Object.assign(hd,e),hd}function _d(){let e=this._zod;return e.message??=JSON.stringify(e.def,tu,2),e.message}function vd(e){this._zod.message=e}var yd={get:_d,set:vd,enumerable:!0,configurable:!0},bd={value:void 0,enumerable:!1},xd=new WeakSet([Object.prototype,Error.prototype]),Sd=(e,t)=>{e.name=`$ZodError`,bd.value=t,Object.defineProperty(e,"issues",bd),bd.value=void 0,Object.defineProperty(e,"message",yd);let n=Object.getPrototypeOf(e);xd.has(n)||(xd.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},Cd=q(`$ZodError`,Sd);q(`$ZodError`,Sd,void 0,{Parent:Error});function wd(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function Td(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?wd(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Ed(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function Dd(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Od=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new pd;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>Gu(e,o,gd())));throw yu(n,a?.callee??t),n}return s.value};return t},kd=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>Gu(e,o,gd())));throw yu(n,a?.callee??t),n}return s.value};return t},Ad=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 pd;return a.issues.length?jd(e,a.issues,i):{success:!0,data:a.value}};function jd(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>Gu(e,n,gd()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}var Md=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?jd(e,a.issues,i):{success:!0,data:a.value}},Nd=Symbol.for(`zod.compile.invalid`),Pd=Symbol.for(`zod.compile.fallback`),Fd=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==Nd)return!0;if(r.definite===!0&&n===void 0)return!1}return Id(e,t,n)});function Id(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[Pd]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new pd;return a.issues.length===0}var Ld=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},Rd=e=>{let t=Od(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,Dd(n,a))};return n},zd=e=>{let t=Od(e),n=(e,r,i,a)=>t(e,r,i,Dd(n,a));return n},Bd=e=>{let t=kd(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,Dd(n,a))};return n},Vd=e=>{let t=kd(e),n=async(e,r,i,a)=>await t(e,r,i,Dd(n,a));return n},Hd=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Ad(e)(t,n,i)},Ud=e=>(t,n,r)=>Ad(e)(t,n,r),Wd=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Md(e)(t,n,i)},Gd=e=>async(t,n,r)=>Md(e)(t,n,r),Kd=/^[cC][0-9a-z]{6,}$/,qd=/^[0-9a-z]+$/,Jd=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Yd=/^[0-9a-vA-V]{20}$/,Xd=/^[A-Za-z0-9]{27}$/,Zd=/^[a-zA-Z0-9_-]{21}$/;function Qd(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var $d=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ef=/^([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})$/,tf=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,nf=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,rf=`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;function af(){return new RegExp(rf,`u`)}var of=/^(?:(?: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])$/,sf=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,cf=/^((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])$/,lf=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,uf=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,df=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,ff=/^https?$/,pf=/^\+[1-9]\d{6,14}$/,mf=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;function hf(e){return RegExp(`^${e}$`)}var gf=hf(mf);function _f(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function vf(e){return RegExp(`^${_f(e)}$`)}function yf(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${_f({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${_f({precision:e.precision})}`:n;return RegExp(`^${mf}T(?:${r})$`)}var bf=/^[\s\S]{0,}$/,xf=/^-?\d+$/,Sf=/^-?\d+(?:\.\d+)?$/,Cf=/^(?:true|false)$/i,wf=/^null$/i,Tf=/^[^A-Z]*$/,Ef=/^[^a-z]*$/,Df=q(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Of=e=>{let t=e.value;return!iu(t)&&t.length!==void 0},kf={number:`number`,bigint:`bigint`,object:`date`},Af=q(`$ZodCheckLessThan`,(e,t)=>{Df.init(e,t);let n=kf[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:kf[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),jf=q(`$ZodCheckGreaterThan`,(e,t)=>{Df.init(e,t);let n=kf[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:kf[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Mf=q(`$ZodCheckMultipleOf`,(e,t)=>{Df.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):ou(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})}}),Nf=q(`$ZodCheckNumberFormat`,(e,t)=>{Df.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=ku[t.format];e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),Pf=q(`$ZodCheckMaxLength`,(e,t)=>{var n;Df.init(e,t),(n=e._zod.def).when??(n.when=Of),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?qu(r):i)<=t.maximum)return;let a=Ju(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Ff=q(`$ZodCheckMinLength`,(e,t)=>{var n;Df.init(e,t),(n=e._zod.def).when??(n.when=Of),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?qu(r):i)>=t.minimum)return;let a=Ju(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),If=q(`$ZodCheckLengthEquals`,(e,t)=>{var n;Df.init(e,t),(n=e._zod.def).when??(n.when=Of),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?qu(r):i;if(a===t.length)return;let o=Ju(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Lf=q(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Df.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Rf=q(`$ZodCheckRegex`,(e,t)=>{Lf.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})}}),zf=q(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Tf,Lf.init(e,t)}),Bf=q(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Ef,Lf.init(e,t)}),Vf=q(`$ZodCheckIncludes`,(e,t)=>{Df.init(e,t);let n=Tu(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Hf=q(`$ZodCheckStartsWith`,(e,t)=>{Df.init(e,t);let n=RegExp(`^${Tu(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Uf=q(`$ZodCheckEndsWith`,(e,t)=>{Df.init(e,t);let n=RegExp(`.*${Tu(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Wf=q(`$ZodCheckOverwrite`,(e,t)=>{Df.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Gf=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
78
78
|
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${t.join(`
|
|
79
|
-
`)}\n};`)(...Object.values(this.closed))}},Lf={major:4,minor:6,patch:5},Rf=q(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Lf;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=ju(t),a;for(let o of n){if(o._zod.def.when){if(Mu(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new id;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(Fu(t.issues,n,e),i||=ju(t,n))});else{if(t.issues.length===n)continue;Fu(t.issues,n,e),i||=ju(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(ju(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new id;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new id;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return Wu(this,`~standard`,Vf(this))},set"~standard"(e){Uu(this,`~standard`,e)}}),zf=(e,t)=>e.issues.length?{issues:e.issues.map(e=>Iu(e,t,sd()))}:{value:e.value};async function Bf(e,t){let n={async:!0};return zf(await e._zod.run({value:t,issues:[]},n),n)}function Vf(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return zf(r,n)}catch{}return Bf(e,t)},vendor:`zod`,version:1}}var Hf=q(`$ZodString`,(e,t)=>{Rf.init(e,t),e._zod.pattern=t.pattern??df,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}}),Uf=q(`$ZodStringFormat`,(e,t)=>{Of.init(e,t),Hf.init(e,t)}),Wf=q(`$ZodGUID`,(e,t)=>{t.pattern??=Gd,Uf.init(e,t)}),Gf=q(`$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??=Kd(e)}else t.pattern??=Kd();Uf.init(e,t)}),Kf=q(`$ZodEmail`,(e,t)=>{t.pattern??=qd,Uf.init(e,t)});function qf(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Jf(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?qf(e)||2:Yf(e,t)}function Yf(e,t){if(!t.normalize&&t.protocol?.source===nf.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}var Xf=/[\t\n\r]/g;function Zf(e){return e.replace(Xf,``)}function Qf(e,t){return t.lastIndex=0,t.test(e.hostname)}function $f(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}var ep=q(`$ZodURL`,(e,t)=>{Uf.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=Jf(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=Zf(r);return}t.hostname&&!Qf(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!$f(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:Zf(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),tp=q(`$ZodEmoji`,(e,t)=>{t.pattern??=Yd(),Uf.init(e,t)}),np=q(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?Hd:Ud(t.length),Uf.init(e,t)}),rp=q(`$ZodCUID`,(e,t)=>{t.pattern??=Ld,Uf.init(e,t)}),ip=q(`$ZodCUID2`,(e,t)=>{t.pattern??=Rd,Uf.init(e,t)}),ap=q(`$ZodULID`,(e,t)=>{t.pattern??=zd,Uf.init(e,t)}),op=q(`$ZodXID`,(e,t)=>{t.pattern??=Bd,Uf.init(e,t)}),sp=q(`$ZodKSUID`,(e,t)=>{t.pattern??=Vd,Uf.init(e,t)}),cp=q(`$ZodISODateTime`,(e,t)=>{t.pattern??=uf(t),Uf.init(e,t)}),lp=q(`$ZodISODate`,(e,t)=>{t.pattern??=sf,Uf.init(e,t)}),up=q(`$ZodISOTime`,(e,t)=>{t.pattern??=lf(t),Uf.init(e,t)}),dp=q(`$ZodISODuration`,(e,t)=>{t.pattern??=Wd,Uf.init(e,t)}),fp=q(`$ZodIPv4`,(e,t)=>{t.pattern??=Xd,Uf.init(e,t)}),pp=/^[0-9a-fA-F:.]+$/;function mp(e){return pp.test(e)?qf(`http://[${e}]`):!1}var hp=q(`$ZodIPv6`,(e,t)=>{t.pattern??=Zd,Uf.init(e,t),e._zod.check=n=>{mp(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),gp=q(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Qd,Uf.init(e,t)});function _p(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:mp(n)}var vp=q(`$ZodCIDRv6`,(e,t)=>{t.pattern??=$d,Uf.init(e,t),e._zod.check=n=>{_p(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function yp(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var bp=/^[0-9a-zA-Z+/]*={0,2}$/,xp=q(`$ZodBase64`,(e,t)=>{t.pattern??=bp,Uf.init(e,t),e._zod.check=n=>{yp(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),Sp=/^[A-Za-z0-9_-]*$/;function Cp(e){if(!Sp.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return yp(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var wp=q(`$ZodBase64URL`,(e,t)=>{t.pattern??=Sp,Uf.init(e,t),e._zod.check=n=>{Cp(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Tp=q(`$ZodE164`,(e,t)=>{t.pattern??=rf,Uf.init(e,t)});function Ep(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 Dp=q(`$ZodJWT`,(e,t)=>{Uf.init(e,t),e._zod.check=n=>{Ep(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Op=q(`$ZodNumber`,(e,t)=>{Rf.init(e,t),e._zod.pattern=pf,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),kp=q(`$ZodNumberFormat`,(e,t)=>{wf.init(e,t),Op.init(e,t)}),Ap=q(`$ZodBoolean`,(e,t)=>{Rf.init(e,t),e._zod.pattern=mf,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}}),jp=q(`$ZodNull`,(e,t)=>{Rf.init(e,t),e._zod.pattern=hf,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}}),Mp=q(`$ZodUnknown`,(e,t)=>{Rf.init(e,t),e._zod.parse=e=>e}),Np=q(`$ZodNever`,(e,t)=>{Rf.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Pp(e,t,n){e.issues.length&&t.issues.push(...Nu(n,e.issues)),t.value[n]=e.value}var Fp=q(`$ZodArray`,(e,t)=>{Rf.init(e,t);let n=od.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>Pp(t,r,e)));else if(Pp(c,r,e),s&&c.issues.length!==0&&ju(c))break}return o.length?Promise.all(o).then(()=>r):r}});function Ip(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(!(!o&&s&&i===`optional`)){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...Nu(n,e.issues))}if(!o&&i===void 0){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}var Lp=[];function Rp(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:Lp,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=yu(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function zp(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(ju(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Ip(e,n,i,t,d,f))):Ip(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}var Bp=q(`$ZodObject`,(e,t)=>{Rf.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let i=Jl(()=>Rp(t));K(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||eu(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=du,o=t.catchall,s,c=od.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(ju(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>Ip(n,t,e,r,a,o))):Ip(s,t,e,r,a,o)}return o?zp(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),Vp=q(`$ZodObjectJIT`,(e,t)=>{Bp.init(e,t);let n=e._zod.parse,r=Jl(()=>Rp(t)),i=od.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new If([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
|
|
79
|
+
`)}\n};`)(...Object.values(this.closed))}},Kf={major:4,minor:6,patch:5},qf=q(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Kf;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=Bu(t),a;for(let o of n){if(o._zod.def.when){if(Vu(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new pd;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(Wu(t.issues,n,e),i||=Bu(t,n))});else{if(t.issues.length===n)continue;Wu(t.issues,n,e),i||=Bu(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(Bu(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new pd;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new pd;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return $u(this,`~standard`,Xf(this))},set"~standard"(e){Qu(this,`~standard`,e)}}),Jf=(e,t)=>e.issues.length?{issues:e.issues.map(e=>Gu(e,t,gd()))}:{value:e.value};async function Yf(e,t){let n={async:!0};return Jf(await e._zod.run({value:t,issues:[]},n),n)}function Xf(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Jf(r,n)}catch{}return Yf(e,t)},vendor:`zod`,version:1}}var Zf=q(`$ZodString`,(e,t)=>{qf.init(e,t),e._zod.pattern=t.pattern??bf,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}}),Qf=q(`$ZodStringFormat`,(e,t)=>{Lf.init(e,t),Zf.init(e,t)}),$f=q(`$ZodGUID`,(e,t)=>{t.pattern??=ef,Qf.init(e,t)}),ep=q(`$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??=tf(e)}else t.pattern??=tf();Qf.init(e,t)}),tp=q(`$ZodEmail`,(e,t)=>{t.pattern??=nf,Qf.init(e,t)});function np(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function rp(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?np(e)||2:ip(e,t)}function ip(e,t){if(!t.normalize&&t.protocol?.source===ff.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}var ap=/[\t\n\r]/g;function op(e){return e.replace(ap,``)}function sp(e,t){return t.lastIndex=0,t.test(e.hostname)}function cp(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}var lp=q(`$ZodURL`,(e,t)=>{Qf.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=rp(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=op(r);return}t.hostname&&!sp(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!cp(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:op(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),up=q(`$ZodEmoji`,(e,t)=>{t.pattern??=af(),Qf.init(e,t)}),dp=q(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?Zd:Qd(t.length),Qf.init(e,t)}),fp=q(`$ZodCUID`,(e,t)=>{t.pattern??=Kd,Qf.init(e,t)}),pp=q(`$ZodCUID2`,(e,t)=>{t.pattern??=qd,Qf.init(e,t)}),mp=q(`$ZodULID`,(e,t)=>{t.pattern??=Jd,Qf.init(e,t)}),hp=q(`$ZodXID`,(e,t)=>{t.pattern??=Yd,Qf.init(e,t)}),gp=q(`$ZodKSUID`,(e,t)=>{t.pattern??=Xd,Qf.init(e,t)}),_p=q(`$ZodISODateTime`,(e,t)=>{t.pattern??=yf(t),Qf.init(e,t)}),vp=q(`$ZodISODate`,(e,t)=>{t.pattern??=gf,Qf.init(e,t)}),yp=q(`$ZodISOTime`,(e,t)=>{t.pattern??=vf(t),Qf.init(e,t)}),bp=q(`$ZodISODuration`,(e,t)=>{t.pattern??=$d,Qf.init(e,t)}),xp=q(`$ZodIPv4`,(e,t)=>{t.pattern??=of,Qf.init(e,t)}),Sp=/^[0-9a-fA-F:.]+$/;function Cp(e){return Sp.test(e)?np(`http://[${e}]`):!1}var wp=q(`$ZodIPv6`,(e,t)=>{t.pattern??=sf,Qf.init(e,t),e._zod.check=n=>{Cp(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),Tp=q(`$ZodCIDRv4`,(e,t)=>{t.pattern??=cf,Qf.init(e,t)});function Ep(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:Cp(n)}var Dp=q(`$ZodCIDRv6`,(e,t)=>{t.pattern??=lf,Qf.init(e,t),e._zod.check=n=>{Ep(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function Op(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var kp=/^[0-9a-zA-Z+/]*={0,2}$/,Ap=q(`$ZodBase64`,(e,t)=>{t.pattern??=kp,Qf.init(e,t),e._zod.check=n=>{Op(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),jp=/^[A-Za-z0-9_-]*$/;function Mp(e){if(!jp.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Op(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var Np=q(`$ZodBase64URL`,(e,t)=>{t.pattern??=jp,Qf.init(e,t),e._zod.check=n=>{Mp(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Pp=q(`$ZodE164`,(e,t)=>{t.pattern??=pf,Qf.init(e,t)});function Fp(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 Ip=q(`$ZodJWT`,(e,t)=>{Qf.init(e,t),e._zod.check=n=>{Fp(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Lp=q(`$ZodNumber`,(e,t)=>{qf.init(e,t),e._zod.pattern=Sf,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Rp=q(`$ZodNumberFormat`,(e,t)=>{Nf.init(e,t),Lp.init(e,t)}),zp=q(`$ZodBoolean`,(e,t)=>{qf.init(e,t),e._zod.pattern=Cf,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}}),Bp=q(`$ZodNull`,(e,t)=>{qf.init(e,t),e._zod.pattern=wf,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}}),Vp=q(`$ZodUnknown`,(e,t)=>{qf.init(e,t),e._zod.parse=e=>e}),Hp=q(`$ZodNever`,(e,t)=>{qf.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Up(e,t,n){e.issues.length&&t.issues.push(...Hu(n,e.issues)),t.value[n]=e.value}var Wp=q(`$ZodArray`,(e,t)=>{qf.init(e,t);let n=hd.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>Up(t,r,e)));else if(Up(c,r,e),s&&c.issues.length!==0&&Bu(c))break}return o.length?Promise.all(o).then(()=>r):r}});function Gp(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(!(!o&&s&&i===`optional`)){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...Hu(n,e.issues))}if(!o&&i===void 0){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}var Kp=[];function qp(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:Kp,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=Ou(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function Jp(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(Bu(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Gp(e,n,i,t,d,f))):Gp(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}var Yp=q(`$ZodObject`,(e,t)=>{qf.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let i=ru(()=>qp(t));K(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||lu(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=bu,o=t.catchall,s,c=hd.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(Bu(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>Gp(n,t,e,r,a,o))):Gp(s,t,e,r,a,o)}return o?Jp(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),Xp=q(`$ZodObjectJIT`,(e,t)=>{Yp.init(e,t);let n=e._zod.parse,r=ru(()=>qp(t)),i=hd.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new Gf([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
|
|
80
80
|
let ${e}_ab = false;
|
|
81
81
|
for (let i = 0; i < ${e}.issues.length; i++) {
|
|
82
82
|
const iss = ${e}.issues[i];
|
|
@@ -87,7 +87,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
87
87
|
if (${e}_ab && ctx && ctx.abortEarly) {
|
|
88
88
|
payload.value = newResult;
|
|
89
89
|
return payload;
|
|
90
|
-
}`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:
|
|
90
|
+
}`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:_u(e),i=`${r} in input`,u=t[e],d=u?._zod?.optin,f=d!==void 0,p=u?._zod?.optout===`optional`;if(o.write(`const ${n} = ${s(r)};`),f&&p){let e=d===`optional`?`${n}_present`:`${n}.value !== undefined || ${n}_present`;o.write(`
|
|
91
91
|
const ${n}_present = ${i};
|
|
92
92
|
if (!${n}.issues.length || ${n}_present) {
|
|
93
93
|
if (${n}.issues.length) {${c(n,r)}
|
|
@@ -126,21 +126,21 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
126
126
|
newResult[${r}] = ${n}.value;
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
`)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=du,c=!od.jitless,l=c&&fu.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?zp([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function Hp(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!ju(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Iu(e,r,sd())))}),t)}var Up=q(`$ZodUnion`,(e,t)=>{Rf.init(e,t),K(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),K(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),K(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),K(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>Xl(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Hp(t,r,e,i)):Hp(o,r,e,i)}});function Wp(e){let t=new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let e of r)if(t.has(e)){if(e!==void 0)throw Error(`Duplicate discriminator value "${String(e)}"`);t.set(e,null)}else t.set(e,n)}return t}var Gp=q(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Up.init(e,t);let n=e._zod.parse;K(e,`propValues`,e=>{let t={},n=0;for(let r of e.def.options){let i=r._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(r)}"`);i[e.def.discriminator]?.has(void 0)&&n++;for(let[e,n]of Object.entries(i)){Object.prototype.hasOwnProperty.call(t,e)||eu(t,e,new Set);for(let r of n)t[e].add(r)}}return!e.def.unionFallback&&n>1&&t[e.def.discriminator]?.delete(void 0),t}),t.options.forEach((e,n)=>{let r=tu(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=Jl(()=>Wp(t));e._zod.parse=(i,a)=>{let o=i.value;if(!du(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=o?.[t.discriminator],c=r.value.get(s);return c&&(s!==void 0||a.direction!==`backward`)?c._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(e=>r.value.get(e)!==null),input:o,path:[t.discriminator],inst:e}),i)}}),Kp=q(`$ZodIntersection`,(e,t)=>{Rf.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])=>Jp(e,t,n)):Jp(e,i,a)}});function qp(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(pu(e)&&pu(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=qp(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=qp(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 Jp(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=qp(t.value,n.value);if(!c.valid){if(ju(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Yp=q(`$ZodRecord`,(e,t)=>{Rf.init(e,t);let n=od.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!pu(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>Iu(e,i,sd())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(...Nu(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...Nu(n,u.issues)),r.value[l]=u.value)}let l;for(let e in a)if(!c.has(e)){if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=a[e]}else l??=[],l.push(e)}l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let n of Reflect.ownKeys(a)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(a,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&pf.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>Iu(e,i,sd())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(...Nu(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...Nu(n,d.issues)),r.value[u]=d.value)}c&&c.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>r):r}}),Xp=q(`$ZodEnum`,(e,t)=>{Rf.init(e,t);let n=Wl(t.entries),r=new Set(n);e._zod.values=r,K(e,`pattern`,e=>{let t=Wl(e.def.entries).filter(e=>hu.has(typeof e));return RegExp(t.length?`^(${t.map(e=>gu(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Zp=q(`$ZodLiteral`,(e,t)=>{Rf.init(e,t);let n=new Set(t.values);e._zod.values=n,K(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?gu(e):e?gu(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),Qp=q(`$ZodTransform`,(e,t)=>{Rf.init(e,t),e._zod.optin=`optional`,od.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ad(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new id;return n.value=i,n}});function $p(e,t){return e.value=t.issues.length?void 0:t.value,e}var em=q(`$ZodOptional`,(e,t)=>{Rf.init(e,t),K(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,K(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),K(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Xl(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>$p(e,t)):$p(e,r)}return t.innerType._zod.run(e,n)}}),tm=q(`$ZodExactOptional`,(e,t)=>{em.init(e,t),K(e,`values`,e=>e.def.innerType._zod.values),K(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),nm=q(`$ZodNullable`,(e,t)=>{Rf.init(e,t),K(e,`optin`,e=>e.def.innerType._zod.optin),K(e,`optout`,e=>e.def.innerType._zod.optout),K(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Xl(t.source)}|null)$`):void 0}),K(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),rm=q(`$ZodDefault`,(e,t)=>{Rf.init(e,t),e._zod.optin=`defaulted`,K(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>im(e,t)):im(r,t)}});function im(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var am=q(`$ZodPrefault`,(e,t)=>{Rf.init(e,t),e._zod.optin=`defaulted`,K(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),om=q(`$ZodNonOptional`,(e,t)=>{Rf.init(e,t),K(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>sm(t,e)):sm(i,e)}});function sm(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function cm(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>Iu(e,r,sd()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var lm=q(`$ZodCatch`,(e,t)=>{Rf.init(e,t),K(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),K(e,`optout`,e=>e.def.innerType._zod.optout),K(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>cm(e,r,t,n)):cm(e,r,t,n)}}),um=q(`$ZodPipe`,(e,t)=>{Rf.init(e,t),K(e,`values`,e=>e.def.in._zod.values),K(e,`optin`,e=>e.def.in._zod.optin),K(e,`optout`,e=>e.def.out._zod.optout),K(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>dm(e,t.in,n)):dm(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>dm(e,t.out,n)):dm(r,t.out,n)}});function dm(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var fm=q(`$ZodReadonly`,(e,t)=>{Rf.init(e,t),K(e,`propValues`,e=>e.def.innerType._zod.propValues),K(e,`values`,e=>e.def.innerType._zod.values),K(e,`optin`,e=>e.def.innerType?._zod?.optin),K(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(pm):pm(r)}});function pm(e){return e.memo||(e.value=Object.freeze(e.value)),e}var mm=q(`$ZodLazy`,(e,t)=>{Rf.init(e,t),$l(e._zod,`innerType`,()=>{let e=t;return e._cachedInner||=t.getter(),e._cachedInner}),K(e,`pattern`,e=>e.innerType?._zod?.pattern),K(e,`propValues`,e=>e.innerType?._zod?.propValues),K(e,`optin`,e=>e.innerType?._zod?.optin??void 0),K(e,`optout`,e=>e.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),hm=q(`$ZodCustom`,(e,t)=>{vf.init(e,t),Rf.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=>gm(t,n,r,e));gm(i,n,r,e)}});function gm(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(Vu(e))}}var _m=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},vm=`~memo`,ym=[];function bm(e){return typeof e==`object`&&!!e}function xm(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var Sm=new WeakMap,Cm=0,wm=1,Tm=2;function Em(e,t,n){let r=Sm.get(e);if(r!==void 0)return r?Tm:Cm;if(t.has(e))return Tm;t.add(e);let i=Cm,a=e=>{if(i!==Tm&&e?._zod){let r=Em(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=Cm;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?wm:o.value?._zod?Em(o.value,t,n):Cm;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=tu(c);s(e?o(e,!0):wm),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?Em(r,t,!1):wm);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(!(!n||typeof n!=`object`)){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),Dm(e,i)}function Dm(e,t){return t!==wm&&Sm.set(e,t===Tm),t}function Om(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}var km,Am=[],jm={alloc(e,t,n){let r=km;if(!r)return n;km=void 0;let i={value:n,issues:null};return r.set(t.value,i),Am.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&Nm(n,e.value))throw new _m;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=Em(e,new Set,!1);if(i===Cm)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===Tm||r?n=!0:r=!0}let l=s.value;if(!bm(l))return t(s,c);let u=c[vm];u||(u={buckets:new WeakMap,backEdges:void 0},c[vm]=u);let d;i===c?d=a:(d=Om(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...xm(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;km=d;let p=Am.length,m=t(s,c);km=void 0;let h=Am.length>p?Am.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?xm(e.issues):ym),e)):(h&&(h.issues=m.issues.length?xm(m.issues):ym),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function Mm(){return jm}function Nm(e,t){let n=e[vm]?.backEdges;return n!==void 0&&bm(t)&&n.has(t)}var Pm=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(Bu(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${vu(e.values[0])}`:`Invalid option: expected one of ${Gl(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${Gl(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function Fm(){return{localeError:Pm()}}var Im,Lm=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Rm(){return new Lm}(Im=globalThis).__zod_globalRegistry??(Im.__zod_globalRegistry=Rm());var zm=globalThis.__zod_globalRegistry;function Bm(e){return e.checks&&=[...e.checks],e}function Vm(e,t){return new e(Bm({type:`string`,...G(t)}))}function Hm(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...G(t)})}function Um(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...G(t)})}function Wm(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...G(t)})}function Gm(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...G(t)})}function Km(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...G(t)})}function qm(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...G(t)})}function Jm(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...G(t)})}function Ym(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...G(t)})}function Xm(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...G(t)})}function Zm(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...G(t)})}function Qm(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...G(t)})}function $m(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...G(t)})}function eh(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...G(t)})}function th(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...G(t)})}function nh(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...G(t)})}function rh(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...G(t)})}function ih(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...G(t)})}function ah(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...G(t)})}function oh(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...G(t)})}function sh(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...G(t)})}function ch(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...G(t)})}function lh(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...G(t)})}function uh(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...G(t)})}function dh(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...G(t)})}function fh(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...G(t)})}function ph(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...G(t)})}function mh(e,t){return new e(Bm({type:`number`,checks:[],...G(t)}))}function hh(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...G(t)})}function gh(e,t){return new e({type:`boolean`,...G(t)})}function _h(e,t){return new e({type:`null`,...G(t)})}function vh(e){return new e({type:`unknown`})}function yh(e,t){return new e({type:`never`,...G(t)})}function bh(e,t){return new xf({check:`less_than`,...G(t),value:e,inclusive:!1})}function xh(e,t){return new xf({check:`less_than`,...G(t),value:e,inclusive:!0})}function Sh(e,t){return new Sf({check:`greater_than`,...G(t),value:e,inclusive:!1})}function Ch(e,t){return new Sf({check:`greater_than`,...G(t),value:e,inclusive:!0})}function wh(e,t){return new Cf({check:`multiple_of`,...G(t),value:e})}function Th(e,t){return new Tf({check:`max_length`,...G(t),maximum:e})}function Eh(e,t){return new Ef({check:`min_length`,...G(t),minimum:e})}function Dh(e,t){return new Df({check:`length_equals`,...G(t),length:e})}function Oh(e,t){return new kf({check:`string_format`,format:`regex`,...G(t),pattern:e})}function kh(e){return new Af({check:`string_format`,format:`lowercase`,...G(e)})}function Ah(e){return new jf({check:`string_format`,format:`uppercase`,...G(e)})}function jh(e,t){return new Mf({check:`string_format`,format:`includes`,...G(t),includes:e})}function Mh(e,t){return new Nf({check:`string_format`,format:`starts_with`,...G(t),prefix:e})}function Nh(e,t){return new Pf({check:`string_format`,format:`ends_with`,...G(t),suffix:e})}function Ph(e){return new Ff({check:`overwrite`,tx:e})}function Fh(e){return Ph(t=>t.normalize(e))}function Ih(){return Ph(e=>e.trim())}function Lh(){return Ph(e=>e.toLowerCase())}function Rh(){return Ph(e=>e.toUpperCase())}function zh(){return Ph(e=>lu(e))}function Bh(e,t,n){return new e({type:`array`,element:t,...G(n)})}function Vh(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...G(n)})}function Hh(e,t){let n=Uh(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Vu(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Vu(r))}},e(t.value,t)),t);return n}function Uh(e,t){let n=new vf({check:`custom`,...G(t)});return n._zod.check=e,n}function Wh(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&eu(e,t,n[t]);return e}function Gh(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??zm,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function Kh(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function qh(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,qh(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Wh(o.schema,c),t.io===`input`&&rg(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Jh(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Yh(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${Jh(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+Jh(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
129
|
+
`)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=bu,c=!hd.jitless,l=c&&xu.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?Jp([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function Zp(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Bu(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Gu(e,r,gd())))}),t)}var Qp=q(`$ZodUnion`,(e,t)=>{qf.init(e,t),K(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),K(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),K(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),K(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>au(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Zp(t,r,e,i)):Zp(o,r,e,i)}});function $p(e){let t=new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let e of r)if(t.has(e)){if(e!==void 0)throw Error(`Duplicate discriminator value "${String(e)}"`);t.set(e,null)}else t.set(e,n)}return t}var em=q(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Qp.init(e,t);let n=e._zod.parse;K(e,`propValues`,e=>{let t={},n=0;for(let r of e.def.options){let i=r._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(r)}"`);i[e.def.discriminator]?.has(void 0)&&n++;for(let[e,n]of Object.entries(i)){Object.prototype.hasOwnProperty.call(t,e)||lu(t,e,new Set);for(let r of n)t[e].add(r)}}return!e.def.unionFallback&&n>1&&t[e.def.discriminator]?.delete(void 0),t}),t.options.forEach((e,n)=>{let r=uu(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=ru(()=>$p(t));e._zod.parse=(i,a)=>{let o=i.value;if(!bu(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=o?.[t.discriminator],c=r.value.get(s);return c&&(s!==void 0||a.direction!==`backward`)?c._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(e=>r.value.get(e)!==null),input:o,path:[t.discriminator],inst:e}),i)}}),tm=q(`$ZodIntersection`,(e,t)=>{qf.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])=>rm(e,t,n)):rm(e,i,a)}});function nm(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Su(e)&&Su(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=nm(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=nm(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 rm(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=nm(t.value,n.value);if(!c.valid){if(Bu(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var im=q(`$ZodRecord`,(e,t)=>{qf.init(e,t);let n=hd.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Su(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>Gu(e,i,gd())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(...Hu(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...Hu(n,u.issues)),r.value[l]=u.value)}let l;for(let e in a)if(!c.has(e)){if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=a[e]}else l??=[],l.push(e)}l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let n of Reflect.ownKeys(a)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(a,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&Sf.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>Gu(e,i,gd())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(...Hu(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...Hu(n,d.issues)),r.value[u]=d.value)}c&&c.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>r):r}}),am=q(`$ZodEnum`,(e,t)=>{qf.init(e,t);let n=$l(t.entries),r=new Set(n);e._zod.values=r,K(e,`pattern`,e=>{let t=$l(e.def.entries).filter(e=>wu.has(typeof e));return RegExp(t.length?`^(${t.map(e=>Tu(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),om=q(`$ZodLiteral`,(e,t)=>{qf.init(e,t);let n=new Set(t.values);e._zod.values=n,K(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?Tu(e):e?Tu(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),sm=q(`$ZodTransform`,(e,t)=>{qf.init(e,t),e._zod.optin=`optional`,hd.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new md(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new pd;return n.value=i,n}});function cm(e,t){return e.value=t.issues.length?void 0:t.value,e}var lm=q(`$ZodOptional`,(e,t)=>{qf.init(e,t),K(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,K(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),K(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${au(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>cm(e,t)):cm(e,r)}return t.innerType._zod.run(e,n)}}),um=q(`$ZodExactOptional`,(e,t)=>{lm.init(e,t),K(e,`values`,e=>e.def.innerType._zod.values),K(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),dm=q(`$ZodNullable`,(e,t)=>{qf.init(e,t),K(e,`optin`,e=>e.def.innerType._zod.optin),K(e,`optout`,e=>e.def.innerType._zod.optout),K(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${au(t.source)}|null)$`):void 0}),K(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),fm=q(`$ZodDefault`,(e,t)=>{qf.init(e,t),e._zod.optin=`defaulted`,K(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>pm(e,t)):pm(r,t)}});function pm(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var mm=q(`$ZodPrefault`,(e,t)=>{qf.init(e,t),e._zod.optin=`defaulted`,K(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),hm=q(`$ZodNonOptional`,(e,t)=>{qf.init(e,t),K(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>gm(t,e)):gm(i,e)}});function gm(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function _m(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>Gu(e,r,gd()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var vm=q(`$ZodCatch`,(e,t)=>{qf.init(e,t),K(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),K(e,`optout`,e=>e.def.innerType._zod.optout),K(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>_m(e,r,t,n)):_m(e,r,t,n)}}),ym=q(`$ZodPipe`,(e,t)=>{qf.init(e,t),K(e,`values`,e=>e.def.in._zod.values),K(e,`optin`,e=>e.def.in._zod.optin),K(e,`optout`,e=>e.def.out._zod.optout),K(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>bm(e,t.in,n)):bm(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>bm(e,t.out,n)):bm(r,t.out,n)}});function bm(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var xm=q(`$ZodReadonly`,(e,t)=>{qf.init(e,t),K(e,`propValues`,e=>e.def.innerType._zod.propValues),K(e,`values`,e=>e.def.innerType._zod.values),K(e,`optin`,e=>e.def.innerType?._zod?.optin),K(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Sm):Sm(r)}});function Sm(e){return e.memo||(e.value=Object.freeze(e.value)),e}var Cm=q(`$ZodLazy`,(e,t)=>{qf.init(e,t),cu(e._zod,`innerType`,()=>{let e=t;return e._cachedInner||=t.getter(),e._cachedInner}),K(e,`pattern`,e=>e.innerType?._zod?.pattern),K(e,`propValues`,e=>e.innerType?._zod?.propValues),K(e,`optin`,e=>e.innerType?._zod?.optin??void 0),K(e,`optout`,e=>e.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),wm=q(`$ZodCustom`,(e,t)=>{Df.init(e,t),qf.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=>Tm(t,n,r,e));Tm(i,n,r,e)}});function Tm(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(Xu(e))}}var Em=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},Dm=`~memo`,Om=[];function km(e){return typeof e==`object`&&!!e}function Am(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var jm=new WeakMap,Mm=0,Nm=1,Pm=2;function Fm(e,t,n){let r=jm.get(e);if(r!==void 0)return r?Pm:Mm;if(t.has(e))return Pm;t.add(e);let i=Mm,a=e=>{if(i!==Pm&&e?._zod){let r=Fm(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=Mm;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?Nm:o.value?._zod?Fm(o.value,t,n):Mm;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=uu(c);s(e?o(e,!0):Nm),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?Fm(r,t,!1):Nm);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(!(!n||typeof n!=`object`)){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),Im(e,i)}function Im(e,t){return t!==Nm&&jm.set(e,t===Pm),t}function Lm(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}var Rm,zm=[],Bm={alloc(e,t,n){let r=Rm;if(!r)return n;Rm=void 0;let i={value:n,issues:null};return r.set(t.value,i),zm.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&Hm(n,e.value))throw new Em;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=Fm(e,new Set,!1);if(i===Mm)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===Pm||r?n=!0:r=!0}let l=s.value;if(!km(l))return t(s,c);let u=c[Dm];u||(u={buckets:new WeakMap,backEdges:void 0},c[Dm]=u);let d;i===c?d=a:(d=Lm(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...Am(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;Rm=d;let p=zm.length,m=t(s,c);Rm=void 0;let h=zm.length>p?zm.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?Am(e.issues):Om),e)):(h&&(h.issues=m.issues.length?Am(m.issues):Om),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function Vm(){return Bm}function Hm(e,t){let n=e[Dm]?.backEdges;return n!==void 0&&km(t)&&n.has(t)}var Um=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(Yu(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${Du(e.values[0])}`:`Invalid option: expected one of ${eu(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${eu(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function Wm(){return{localeError:Um()}}var Gm,Km=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function qm(){return new Km}(Gm=globalThis).__zod_globalRegistry??(Gm.__zod_globalRegistry=qm());var Jm=globalThis.__zod_globalRegistry;function Ym(e){return e.checks&&=[...e.checks],e}function Xm(e,t){return new e(Ym({type:`string`,...G(t)}))}function Zm(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...G(t)})}function Qm(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...G(t)})}function $m(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...G(t)})}function eh(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...G(t)})}function th(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...G(t)})}function nh(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...G(t)})}function rh(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...G(t)})}function ih(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...G(t)})}function ah(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...G(t)})}function oh(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...G(t)})}function sh(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...G(t)})}function ch(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...G(t)})}function lh(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...G(t)})}function uh(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...G(t)})}function dh(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...G(t)})}function fh(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...G(t)})}function ph(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...G(t)})}function mh(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...G(t)})}function hh(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...G(t)})}function gh(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...G(t)})}function _h(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...G(t)})}function vh(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...G(t)})}function yh(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...G(t)})}function bh(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...G(t)})}function xh(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...G(t)})}function Sh(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...G(t)})}function Ch(e,t){return new e(Ym({type:`number`,checks:[],...G(t)}))}function wh(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...G(t)})}function Th(e,t){return new e({type:`boolean`,...G(t)})}function Eh(e,t){return new e({type:`null`,...G(t)})}function Dh(e){return new e({type:`unknown`})}function Oh(e,t){return new e({type:`never`,...G(t)})}function kh(e,t){return new Af({check:`less_than`,...G(t),value:e,inclusive:!1})}function Ah(e,t){return new Af({check:`less_than`,...G(t),value:e,inclusive:!0})}function jh(e,t){return new jf({check:`greater_than`,...G(t),value:e,inclusive:!1})}function Mh(e,t){return new jf({check:`greater_than`,...G(t),value:e,inclusive:!0})}function Nh(e,t){return new Mf({check:`multiple_of`,...G(t),value:e})}function Ph(e,t){return new Pf({check:`max_length`,...G(t),maximum:e})}function Fh(e,t){return new Ff({check:`min_length`,...G(t),minimum:e})}function Ih(e,t){return new If({check:`length_equals`,...G(t),length:e})}function Lh(e,t){return new Rf({check:`string_format`,format:`regex`,...G(t),pattern:e})}function Rh(e){return new zf({check:`string_format`,format:`lowercase`,...G(e)})}function zh(e){return new Bf({check:`string_format`,format:`uppercase`,...G(e)})}function Bh(e,t){return new Vf({check:`string_format`,format:`includes`,...G(t),includes:e})}function Vh(e,t){return new Hf({check:`string_format`,format:`starts_with`,...G(t),prefix:e})}function Hh(e,t){return new Uf({check:`string_format`,format:`ends_with`,...G(t),suffix:e})}function Uh(e){return new Wf({check:`overwrite`,tx:e})}function Wh(e){return Uh(t=>t.normalize(e))}function Gh(){return Uh(e=>e.trim())}function Kh(){return Uh(e=>e.toLowerCase())}function qh(){return Uh(e=>e.toUpperCase())}function Jh(){return Uh(e=>vu(e))}function Yh(e,t,n){return new e({type:`array`,element:t,...G(n)})}function Xh(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...G(n)})}function Zh(e,t){let n=Qh(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Xu(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Xu(r))}},e(t.value,t)),t);return n}function Qh(e,t){let n=new Df({check:`custom`,...G(t)});return n._zod.check=e,n}function $h(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&lu(e,t,n[t]);return e}function eg(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Jm,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function tg(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function ng(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,ng(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&$h(o.schema,c),t.io===`input`&&fg(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function rg(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function ig(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${rg(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+rg(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
130
130
|
|
|
131
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}r.count>1&&e.reused===`ref`&&a(n)}e.external&&(e.sharedDefsExtractedFor=e.external)}function Xh(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;Xh(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var Zh=new Set([`type`,`properties`,`required`,`additionalProperties`]),Qh=[`oneOf`,`anyOf`];function $h(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function eg(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Zh.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??$h(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}eu(n,r,e.length===1?e[0]:eg(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=$h(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function tg(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Zh)if(t in e)return;let n=t.filter(e=>Qh.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=eg(t);else{let e=n[0],i=Qh.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>eg([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Wh(e,r))}function ng(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Wh(i,s),Wh(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())Xh(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])tg(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Wh(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,eu(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:ag(t,`input`,e.processors),output:ag(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function rg(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return rg(r.element,n);if(r.type===`set`)return rg(r.valueType,n);if(r.type===`lazy`)return rg(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return rg(r.innerType,n);if(r.type===`intersection`)return rg(r.left,n)||rg(r.right,n);if(r.type===`record`||r.type===`map`)return rg(r.keyType,n)||rg(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:rg(r.in,n)||rg(r.out,n);if(r.type===`object`){for(let e in r.shape)if(rg(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(rg(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(rg(e,n))return!0;return!!(r.rest&&rg(r.rest,n))}return!1}var ig=(e,t={})=>n=>{let r=Gh({...n,processors:t});return qh(e,r),Yh(r,e),ng(r,e)},ag=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Gh({...i??{},target:a,io:t,processors:n});return qh(e,o),Yh(o,e),ng(o,e)},og=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},sg=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},cg=(e,t)=>{og(e,`minimum`,t),sg(e,`maximum`,t)},lg=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},ug=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},dg=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},fg=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},pg=(e,t)=>og(e,`minimum`,t.minimum),mg=(e,t)=>sg(e,`maximum`,t.maximum),hg=e=>(t,n)=>{fg(t,n.format);let[r,i]=e[n.format];og(t,`minimum`,r),sg(t,`maximum`,i)},gg={greater_than:(e,t)=>og(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>sg(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>lg(e,t.value),number_format:hg(bu),bigint_format:hg(xu),min_length:pg,max_length:mg,length_equals:(e,t)=>cg(e,t.length),min_size:pg,max_size:mg,size_equals:(e,t)=>cg(e,t.size),string_format:(e,t)=>{fg(e,t.format),t.pattern&&ug(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>dg(e,t.mime)};function _g(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)gg[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&og(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&og(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&sg(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&sg(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&lg(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&dg(t,i.mime);for(let e of i.patterns??[])ug(t,e);return t}var vg={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},yg=new Map([[bp,ef],[Sp,tf]]),bg=e=>yg.get(e)??e,xg=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=_g(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=vg[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(bg);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Sg=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=_g(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):Kh(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},Cg=(e,t,n,r)=>{n.type=`boolean`},wg=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},Tg=(e,t,n,r)=>{n.not={}},Eg=(e,t,n,r)=>{let i=e._zod.def,a=Wl(i.entries);if(a.length===0){n.not={};return}a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Dg=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(Kh(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(Kh(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},Og=(e,t,n,r)=>{Kh(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},kg=(e,t,n,r)=>{Kh(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},Ag=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=_g(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=qh(a.element,t,{...r,path:[...r.path,`items`]})};function jg(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?jg(t.out):t.type===`catch`?jg(t.innerType):e._zod.optin}var Mg=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&Kh(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)eu(i.properties,e,qh(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?jg(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=qh(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Ng=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>qh(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Pg=(e,t,n,r)=>{let i=e._zod.def,a=qh(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=qh(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)};function Fg(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=Fg(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>Fg(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i?(p.type=`string`,a||(p.pattern=(r.includes(`number`)?pf:ff).source),p):p}var Ig=new WeakMap;function Lg(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=new Map;for(let r of Ig.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=Fg(t,a,new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}var Rg=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=_g(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=qh(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)eu(i.patternProperties,bg(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=qh(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=Ig.get(t);n||(n=[],Ig.set(t,n),t.deferred.push(()=>Lg(t))),n.push(e)}i.additionalProperties=qh(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&jg(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},zg=(e,t,n,r)=>{let i=e._zod.def,a=qh(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Bg=(e,t,n,r)=>{let i=e._zod.def;qh(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Vg=Symbol();function Hg(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(Kh(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),Vg):JSON.parse(o)}var Ug=(e,t,n,r)=>{let i=e._zod.def;qh(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=Hg(i.defaultValue,e,t,n,r);o!==Vg&&(n.default=o)},Wg=(e,t,n,r)=>{let i=e._zod.def;qh(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=Hg(i.defaultValue,e,t,n,r);o!==Vg&&(n._prefault=o)},Gg=(e,t,n,r)=>{let i=e._zod.def;qh(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{Kh(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},Kg=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;qh(o,t,r);let s=t.seen.get(e);s.ref=o},qg=(e,t,n,r)=>{let i=e._zod.def;qh(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Jg=(e,t,n,r)=>{let i=e._zod.def;qh(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Yg=(e,t,n,r)=>{let i=e._zod.innerType;qh(i,t,r);let a=t.seen.get(e);a.ref=i},Xg=new WeakSet([Object.prototype,Error.prototype]);function Zg(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var Qg=q(`ZodError`,(e,t)=>{md.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);Xg.has(n)||(Xg.add(n),Zg(n,`format`,e=>t=>_d(e,t)),Zg(n,`flatten`,e=>t=>gd(e,t)),Zg(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Kl,2)}),Zg(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Kl,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),$g=yd(Qg),e_=bd(Qg),t_=xd(Qg),n_=Cd(Qg),r_=kd(Qg),i_=Ad(Qg),a_=jd(Qg),o_=Md(Qg),s_=Nd(Qg),c_=Pd(Qg),l_=Fd(Qg),u_=Id(Qg);function d_(){od.localeError||sd(Fm())}function f_(){od.memoizer||sd({memoizer:Mm()})}var p_=q(`ZodType`,(e,t)=>(d_(),Rf.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(su(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return _u(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Iv(e,t))},superRefine(e,t){return this.check(Lv(e,t))},overwrite(e){return this.check(Ph(e))},optional(){return gv(this)},exactOptional(){return vv(this)},nullable(){return bv(this)},nullish(){return gv(bv(this))},nonoptional(e){return Ev(this,e)},array(){return $_(this)},or(e){return nv([this,e])},and(e){return ov(this,e)},transform(e){return Av(this,mv(e))},default(e){return Sv(this,e)},prefault(e){return wv(this,e)},catch(e){return Ov(this,e)},pipe(e){return Av(this,e)},readonly(){return Mv(this)},describe(e){let t=this.clone();return zm.add(t,{description:e}),t},meta(...e){if(e.length===0)return zm.get(this);let t=this.clone();return zm.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return Wu(this,`~standard`,{...Vf(this),jsonSchema:{input:ag(this,`input`),output:ag(this,`output`)}})},set"~standard"(e){Uu(this,`~standard`,e)},parse:function e(t,n){return $g(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await e_(this,t,n,{callee:e})},safeParse(e,t){return t_(this,e,t)},async safeParseAsync(e,t){return n_(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Uu(this,`spa`,e)},validate(e,t){return Ed(this,e,t)},validateAsync(e,t){return Od(this,e,t)},encode:function e(t,n){return r_(this,t,n,{callee:e})},decode:function e(t,n){return i_(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await a_(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await o_(this,t,n,{callee:e})},safeEncode(e,t){return s_(this,e,t)},safeDecode(e,t){return c_(this,e,t)},async safeEncodeAsync(e,t){return l_(this,e,t)},async safeDecodeAsync(e,t){return u_(this,e,t)},toJSONSchema(e){return ig(this,{})(e)},get description(){return zm.get(this)?.description},get _def(){return this._zod.def}}),m_=q(`_ZodString`,(e,t)=>{Hf.init(e,t),p_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xg(e,t,n,r)},Gu({format:e=>_g(e).format??null,minLength:e=>_g(e).minimum??null,maxLength:e=>_g(e).maximum??null},{regex(...e){return this.check(Oh(...e))},includes(...e){return this.check(jh(...e))},startsWith(...e){return this.check(Mh(...e))},endsWith(...e){return this.check(Nh(...e))},min(...e){return this.check(Eh(...e))},max(...e){return this.check(Th(...e))},length(...e){return this.check(Dh(...e))},nonempty(...e){return this.check(Eh(1,...e))},lowercase(e){return this.check(kh(e))},uppercase(e){return this.check(Ah(e))},trim(){return this.check(Ih())},normalize(...e){return this.check(Fh(...e))},toLowerCase(){return this.check(Lh())},toUpperCase(){return this.check(Rh())},slugify(){return this.check(zh())}})),h_=q(`ZodString`,(e,t)=>{Hf.init(e,t),m_.init(e,t)},{email(e){return this.check(Hm(x_,e))},url(e){return this.check(Jm(w_,e))},jwt(e){return this.check(lh(z_,e))},emoji(e){return this.check(Ym(T_,e))},guid(e){return this.check(Um(S_,e))},uuid(e){return this.check(Wm(C_,e))},uuidv4(e){return this.check(Gm(C_,e))},uuidv6(e){return this.check(Km(C_,e))},uuidv7(e){return this.check(qm(C_,e))},nanoid(e){return this.check(Xm(E_,e))},cuid(e){return this.check(Zm(D_,e))},cuid2(e){return this.check(Qm(O_,e))},ulid(e){return this.check($m(k_,e))},base64(e){return this.check(oh(I_,e))},base64url(e){return this.check(sh(L_,e))},xid(e){return this.check(eh(A_,e))},ksuid(e){return this.check(th(j_,e))},ipv4(e){return this.check(nh(M_,e))},ipv6(e){return this.check(rh(N_,e))},cidrv4(e){return this.check(ih(P_,e))},cidrv6(e){return this.check(ah(F_,e))},e164(e){return this.check(ch(R_,e))},datetime(e){return this.check(uh(__,e))},date(e){return this.check(dh(v_,e))},time(e){return this.check(fh(y_,e))},duration(e){return this.check(ph(b_,e))}});function J(e){return Vm(h_,e)}var g_=q(`ZodStringFormat`,(e,t)=>{Uf.init(e,t),m_.init(e,t)}),__=q(`ZodISODateTime`,(e,t)=>{cp.init(e,t),g_.init(e,t)}),v_=q(`ZodISODate`,(e,t)=>{lp.init(e,t),g_.init(e,t)}),y_=q(`ZodISOTime`,(e,t)=>{up.init(e,t),g_.init(e,t)}),b_=q(`ZodISODuration`,(e,t)=>{dp.init(e,t),g_.init(e,t)}),x_=q(`ZodEmail`,(e,t)=>{Kf.init(e,t),g_.init(e,t)}),S_=q(`ZodGUID`,(e,t)=>{Wf.init(e,t),g_.init(e,t)}),C_=q(`ZodUUID`,(e,t)=>{Gf.init(e,t),g_.init(e,t)}),w_=q(`ZodURL`,(e,t)=>{ep.init(e,t),g_.init(e,t)}),T_=q(`ZodEmoji`,(e,t)=>{tp.init(e,t),g_.init(e,t)}),E_=q(`ZodNanoID`,(e,t)=>{np.init(e,t),g_.init(e,t)}),D_=q(`ZodCUID`,(e,t)=>{rp.init(e,t),g_.init(e,t)}),O_=q(`ZodCUID2`,(e,t)=>{ip.init(e,t),g_.init(e,t)}),k_=q(`ZodULID`,(e,t)=>{ap.init(e,t),g_.init(e,t)}),A_=q(`ZodXID`,(e,t)=>{op.init(e,t),g_.init(e,t)}),j_=q(`ZodKSUID`,(e,t)=>{sp.init(e,t),g_.init(e,t)}),M_=q(`ZodIPv4`,(e,t)=>{fp.init(e,t),g_.init(e,t)}),N_=q(`ZodIPv6`,(e,t)=>{hp.init(e,t),g_.init(e,t)}),P_=q(`ZodCIDRv4`,(e,t)=>{gp.init(e,t),g_.init(e,t)}),F_=q(`ZodCIDRv6`,(e,t)=>{vp.init(e,t),g_.init(e,t)}),I_=q(`ZodBase64`,(e,t)=>{xp.init(e,t),g_.init(e,t)}),L_=q(`ZodBase64URL`,(e,t)=>{wp.init(e,t),g_.init(e,t)}),R_=q(`ZodE164`,(e,t)=>{Tp.init(e,t),g_.init(e,t)}),z_=q(`ZodJWT`,(e,t)=>{Dp.init(e,t),g_.init(e,t)}),B_=q(`ZodNumber`,(e,t)=>{Op.init(e,t),p_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Sg(e,t,n,r),e.isFinite=!0},Gu({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=_g(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=_g(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=_g(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>_g(e).format??null},{gt(e,t){return this.check(Sh(e,t))},gte(e,t){return this.check(Ch(e,t))},min(e,t){return this.check(Ch(e,t))},lt(e,t){return this.check(bh(e,t))},lte(e,t){return this.check(xh(e,t))},max(e,t){return this.check(xh(e,t))},int(e){return this.check(U_(e))},safe(e){return this.check(U_(e))},positive(e){return this.check(Sh(0,e))},nonnegative(e){return this.check(Ch(0,e))},negative(e){return this.check(bh(0,e))},nonpositive(e){return this.check(xh(0,e))},multipleOf(e,t){return this.check(wh(e,t))},step(e,t){return this.check(wh(e,t))},finite(){return this}}));function V_(e){return mh(B_,e)}var H_=q(`ZodNumberFormat`,(e,t)=>{kp.init(e,t),B_.init(e,t)});function U_(e){return hh(H_,e)}var W_=q(`ZodBoolean`,(e,t)=>{Ap.init(e,t),p_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cg(e,t,n,r)});function G_(e){return gh(W_,e)}var K_=q(`ZodNull`,(e,t)=>{jp.init(e,t),p_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wg(e,t,n,r)});function q_(e){return _h(K_,e)}var J_=q(`ZodUnknown`,(e,t)=>{Mp.init(e,t),p_.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Y_(){return vh(J_)}var X_=q(`ZodNever`,(e,t)=>{Np.init(e,t),p_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Tg(e,t,n,r)});function Z_(e){return yh(X_,e)}var Q_=q(`ZodArray`,(e,t)=>{f_(),Fp.init(e,t),p_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ag(e,t,n,r),e.element=t.element},{min(e,t){return this.check(Eh(e,t))},nonempty(e){return this.check(Eh(1,e))},max(e,t){return this.check(Th(e,t))},length(e,t){return this.check(Dh(e,t))},unwrap(){return this.element}});function $_(e,t){return Bh(Q_,e,t)}var ev=q(`ZodObject`,(e,t)=>{f_(),Vp.init(e,t),p_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mg(e,t,n,r),Zu(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return uv(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(su(this._zod.def,{catchall:e}))},passthrough(){return this.clone(su(this._zod.def,{catchall:Y_()}))},loose(){return this.clone(su(this._zod.def,{catchall:Y_()}))},strict(){return this.clone(su(this._zod.def,{catchall:Z_()}))},strip(){return this.clone(su(this._zod.def,{catchall:void 0}))},extend(e){return Tu(this,e)},safeExtend(e){return Du(this,e)},merge(e){return Ou(this,e)},pick(e){return Su(this,e)},omit(e){return wu(this,e)},partial(...e){return ku(hv,this,e[0])},exactPartial(...e){return ku(_v,this,e[0],`exactPartial`)},required(...e){return Au(Tv,this,e[0])}});function Y(e,t){return new ev({type:`object`,shape:e??{},...G(t)})}var tv=q(`ZodUnion`,(e,t)=>{Up.init(e,t),p_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ng(e,t,n,r),e.options=t.options});function nv(e,t){return new tv({type:`union`,options:e,...G(t)})}var rv=q(`ZodDiscriminatedUnion`,(e,t)=>{tv.init(e,t),Gp.init(e,t)});function iv(e,t,n){return new rv({type:`union`,options:t,discriminator:e,...G(n)})}var av=q(`ZodIntersection`,(e,t)=>{Kp.init(e,t),p_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pg(e,t,n,r)});function ov(e,t){return new av({type:`intersection`,left:e,right:t})}var sv=q(`ZodRecord`,(e,t)=>{f_(),Yp.init(e,t),p_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Rg(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function cv(e,t,n){return!t||!t._zod?new sv({type:`record`,keyType:J(),valueType:e,...G(t)}):new sv({type:`record`,keyType:e,valueType:t,...G(n)})}var lv=q(`ZodEnum`,(e,t)=>{Xp.init(e,t),p_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eg(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new lv({...t,checks:[],...G(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 lv({...t,checks:[],...G(r),entries:i})}});function uv(e,t){return new lv({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...G(t)})}var dv=q(`ZodLiteral`,(e,t)=>{Zp.init(e,t),p_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Dg(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function fv(e,t){return new dv({type:`literal`,values:Array.isArray(e)?e:[e],...G(t)})}var pv=q(`ZodTransform`,(e,t)=>{f_(),Qp.init(e,t),p_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>kg(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ad(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Vu(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(Vu(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function mv(e){return new pv({type:`transform`,transform:e})}var hv=q(`ZodOptional`,(e,t)=>{em.init(e,t),p_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function gv(e){return new hv({type:`optional`,innerType:e})}var _v=q(`ZodExactOptional`,(e,t)=>{tm.init(e,t),p_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function vv(e){return new _v({type:`optional`,innerType:e})}var yv=q(`ZodNullable`,(e,t)=>{nm.init(e,t),p_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function bv(e){return new yv({type:`nullable`,innerType:e})}var xv=q(`ZodDefault`,(e,t)=>{rm.init(e,t),p_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ug(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Sv(e,t){return new xv({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():mu(t)}})}var Cv=q(`ZodPrefault`,(e,t)=>{am.init(e,t),p_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function wv(e,t){return new Cv({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():mu(t)}})}var Tv=q(`ZodNonOptional`,(e,t)=>{om.init(e,t),p_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ev(e,t){return new Tv({type:`nonoptional`,innerType:e,...G(t)})}var Dv=q(`ZodCatch`,(e,t)=>{lm.init(e,t),p_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Ov(e,t){return new Dv({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:$u(t)})}var kv=q(`ZodPipe`,(e,t)=>{um.init(e,t),p_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Kg(e,t,n,r),e.in=t.in,e.out=t.out});function Av(e,t){return new kv({type:`pipe`,in:e,out:t})}var jv=q(`ZodReadonly`,(e,t)=>{fm.init(e,t),p_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Mv(e){return new jv({type:`readonly`,innerType:e})}var Nv=q(`ZodLazy`,(e,t)=>{mm.init(e,t),p_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yg(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function Pv(e){return new Nv({type:`lazy`,getter:e})}var Fv=q(`ZodCustom`,(e,t)=>{hm.init(e,t),p_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Og(e,t,n,r)});function Iv(e,t={}){return Vh(Fv,e,t)}function Lv(e,t){return Hh(e,t)}function Rv(e){let t=Pv(()=>nv([J(e),V_(),G_(),q_(),$_(t),cv(J(),t)]));return t}var zv=i((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})),Bv=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;var t=zv(),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}}})),X=i((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=zv(),n=Bv(),r=zv();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=Bv();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?`
|
|
132
|
-
`:``},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})`}})),Z=i((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=X(),n=zv();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})),Vv=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X();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`)}})),Hv=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;var t=X(),n=Z(),r=Vv();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])}})),Uv=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;var t=Hv(),n=X(),r=Vv(),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)}})),Wv=i((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})),Gv=i((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})),Kv=i((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=Wv(),n=Gv(),r=Hv(),i=X(),a=Z(),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
|
|
131
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}r.count>1&&e.reused===`ref`&&a(n)}e.external&&(e.sharedDefsExtractedFor=e.external)}function ag(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;ag(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var og=new Set([`type`,`properties`,`required`,`additionalProperties`]),sg=[`oneOf`,`anyOf`];function cg(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function lg(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!og.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??cg(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}lu(n,r,e.length===1?e[0]:lg(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=cg(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function ug(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of og)if(t in e)return;let n=t.filter(e=>sg.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=lg(t);else{let e=n[0],i=sg.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>lg([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,$h(e,r))}function dg(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):$h(i,s),$h(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())ag(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])ug(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}$h(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,lu(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:mg(t,`input`,e.processors),output:mg(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function fg(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return fg(r.element,n);if(r.type===`set`)return fg(r.valueType,n);if(r.type===`lazy`)return fg(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return fg(r.innerType,n);if(r.type===`intersection`)return fg(r.left,n)||fg(r.right,n);if(r.type===`record`||r.type===`map`)return fg(r.keyType,n)||fg(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:fg(r.in,n)||fg(r.out,n);if(r.type===`object`){for(let e in r.shape)if(fg(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(fg(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(fg(e,n))return!0;return!!(r.rest&&fg(r.rest,n))}return!1}var pg=(e,t={})=>n=>{let r=eg({...n,processors:t});return ng(e,r),ig(r,e),dg(r,e)},mg=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=eg({...i??{},target:a,io:t,processors:n});return ng(e,o),ig(o,e),dg(o,e)},hg=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},gg=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},_g=(e,t)=>{hg(e,`minimum`,t),gg(e,`maximum`,t)},vg=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},yg=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},bg=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},xg=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},Sg=(e,t)=>hg(e,`minimum`,t.minimum),Cg=(e,t)=>gg(e,`maximum`,t.maximum),wg=e=>(t,n)=>{xg(t,n.format);let[r,i]=e[n.format];hg(t,`minimum`,r),gg(t,`maximum`,i)},Tg={greater_than:(e,t)=>hg(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>gg(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>vg(e,t.value),number_format:wg(ku),bigint_format:wg(Au),min_length:Sg,max_length:Cg,length_equals:(e,t)=>_g(e,t.length),min_size:Sg,max_size:Cg,size_equals:(e,t)=>_g(e,t.size),string_format:(e,t)=>{xg(e,t.format),t.pattern&&yg(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>bg(e,t.mime)};function Eg(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Tg[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&hg(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&hg(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&gg(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&gg(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&vg(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&bg(t,i.mime);for(let e of i.patterns??[])yg(t,e);return t}var Dg={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Og=new Map([[kp,uf],[jp,df]]),kg=e=>Og.get(e)??e,Ag=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=Eg(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Dg[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(kg);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},jg=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Eg(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):tg(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},Mg=(e,t,n,r)=>{n.type=`boolean`},Ng=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},Pg=(e,t,n,r)=>{n.not={}},Fg=(e,t,n,r)=>{let i=e._zod.def,a=$l(i.entries);if(a.length===0){n.not={};return}a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Ig=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(tg(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(tg(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},Lg=(e,t,n,r)=>{tg(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},Rg=(e,t,n,r)=>{tg(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},zg=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=Eg(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=ng(a.element,t,{...r,path:[...r.path,`items`]})};function Bg(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?Bg(t.out):t.type===`catch`?Bg(t.innerType):e._zod.optin}var Vg=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&tg(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)lu(i.properties,e,ng(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?Bg(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=ng(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Hg=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>ng(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Ug=(e,t,n,r)=>{let i=e._zod.def,a=ng(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=ng(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)};function Wg(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=Wg(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>Wg(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i?(p.type=`string`,a||(p.pattern=(r.includes(`number`)?Sf:xf).source),p):p}var Gg=new WeakMap;function Kg(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=new Map;for(let r of Gg.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=Wg(t,a,new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}var qg=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=Eg(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=ng(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)lu(i.patternProperties,kg(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=ng(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=Gg.get(t);n||(n=[],Gg.set(t,n),t.deferred.push(()=>Kg(t))),n.push(e)}i.additionalProperties=ng(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&Bg(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},Jg=(e,t,n,r)=>{let i=e._zod.def,a=ng(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Yg=(e,t,n,r)=>{let i=e._zod.def;ng(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Xg=Symbol();function Zg(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(tg(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),Xg):JSON.parse(o)}var Qg=(e,t,n,r)=>{let i=e._zod.def;ng(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=Zg(i.defaultValue,e,t,n,r);o!==Xg&&(n.default=o)},$g=(e,t,n,r)=>{let i=e._zod.def;ng(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=Zg(i.defaultValue,e,t,n,r);o!==Xg&&(n._prefault=o)},e_=(e,t,n,r)=>{let i=e._zod.def;ng(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{tg(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},t_=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;ng(o,t,r);let s=t.seen.get(e);s.ref=o},n_=(e,t,n,r)=>{let i=e._zod.def;ng(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},r_=(e,t,n,r)=>{let i=e._zod.def;ng(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},i_=(e,t,n,r)=>{let i=e._zod.innerType;ng(i,t,r);let a=t.seen.get(e);a.ref=i},a_=new WeakSet([Object.prototype,Error.prototype]);function o_(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var s_=q(`ZodError`,(e,t)=>{Cd.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);a_.has(n)||(a_.add(n),o_(n,`format`,e=>t=>Ed(e,t)),o_(n,`flatten`,e=>t=>Td(e,t)),o_(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,tu,2)}),o_(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,tu,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),c_=Od(s_),l_=kd(s_),u_=Ad(s_),d_=Md(s_),f_=Rd(s_),p_=zd(s_),m_=Bd(s_),h_=Vd(s_),g_=Hd(s_),__=Ud(s_),v_=Wd(s_),y_=Gd(s_);function b_(){hd.localeError||gd(Wm())}function x_(){hd.memoizer||gd({memoizer:Vm()})}var S_=q(`ZodType`,(e,t)=>(b_(),qf.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(gu(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Eu(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Gv(e,t))},superRefine(e,t){return this.check(Kv(e,t))},overwrite(e){return this.check(Uh(e))},optional(){return Tv(this)},exactOptional(){return Dv(this)},nullable(){return kv(this)},nullish(){return Tv(kv(this))},nonoptional(e){return Fv(this,e)},array(){return cv(this)},or(e){return dv([this,e])},and(e){return hv(this,e)},transform(e){return zv(this,Cv(e))},default(e){return jv(this,e)},prefault(e){return Nv(this,e)},catch(e){return Lv(this,e)},pipe(e){return zv(this,e)},readonly(){return Vv(this)},describe(e){let t=this.clone();return Jm.add(t,{description:e}),t},meta(...e){if(e.length===0)return Jm.get(this);let t=this.clone();return Jm.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return $u(this,`~standard`,{...Xf(this),jsonSchema:{input:mg(this,`input`),output:mg(this,`output`)}})},set"~standard"(e){Qu(this,`~standard`,e)},parse:function e(t,n){return c_(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await l_(this,t,n,{callee:e})},safeParse(e,t){return u_(this,e,t)},async safeParseAsync(e,t){return d_(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Qu(this,`spa`,e)},validate(e,t){return Fd(this,e,t)},validateAsync(e,t){return Ld(this,e,t)},encode:function e(t,n){return f_(this,t,n,{callee:e})},decode:function e(t,n){return p_(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await m_(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await h_(this,t,n,{callee:e})},safeEncode(e,t){return g_(this,e,t)},safeDecode(e,t){return __(this,e,t)},async safeEncodeAsync(e,t){return v_(this,e,t)},async safeDecodeAsync(e,t){return y_(this,e,t)},toJSONSchema(e){return pg(this,{})(e)},get description(){return Jm.get(this)?.description},get _def(){return this._zod.def}}),C_=q(`_ZodString`,(e,t)=>{Zf.init(e,t),S_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ag(e,t,n,r)},ed({format:e=>Eg(e).format??null,minLength:e=>Eg(e).minimum??null,maxLength:e=>Eg(e).maximum??null},{regex(...e){return this.check(Lh(...e))},includes(...e){return this.check(Bh(...e))},startsWith(...e){return this.check(Vh(...e))},endsWith(...e){return this.check(Hh(...e))},min(...e){return this.check(Fh(...e))},max(...e){return this.check(Ph(...e))},length(...e){return this.check(Ih(...e))},nonempty(...e){return this.check(Fh(1,...e))},lowercase(e){return this.check(Rh(e))},uppercase(e){return this.check(zh(e))},trim(){return this.check(Gh())},normalize(...e){return this.check(Wh(...e))},toLowerCase(){return this.check(Kh())},toUpperCase(){return this.check(qh())},slugify(){return this.check(Jh())}})),w_=q(`ZodString`,(e,t)=>{Zf.init(e,t),C_.init(e,t)},{email(e){return this.check(Zm(A_,e))},url(e){return this.check(rh(N_,e))},jwt(e){return this.check(vh(J_,e))},emoji(e){return this.check(ih(P_,e))},guid(e){return this.check(Qm(j_,e))},uuid(e){return this.check($m(M_,e))},uuidv4(e){return this.check(eh(M_,e))},uuidv6(e){return this.check(th(M_,e))},uuidv7(e){return this.check(nh(M_,e))},nanoid(e){return this.check(ah(F_,e))},cuid(e){return this.check(oh(I_,e))},cuid2(e){return this.check(sh(L_,e))},ulid(e){return this.check(ch(R_,e))},base64(e){return this.check(hh(G_,e))},base64url(e){return this.check(gh(K_,e))},xid(e){return this.check(lh(z_,e))},ksuid(e){return this.check(uh(B_,e))},ipv4(e){return this.check(dh(V_,e))},ipv6(e){return this.check(fh(H_,e))},cidrv4(e){return this.check(ph(U_,e))},cidrv6(e){return this.check(mh(W_,e))},e164(e){return this.check(_h(q_,e))},datetime(e){return this.check(yh(E_,e))},date(e){return this.check(bh(D_,e))},time(e){return this.check(xh(O_,e))},duration(e){return this.check(Sh(k_,e))}});function J(e){return Xm(w_,e)}var T_=q(`ZodStringFormat`,(e,t)=>{Qf.init(e,t),C_.init(e,t)}),E_=q(`ZodISODateTime`,(e,t)=>{_p.init(e,t),T_.init(e,t)}),D_=q(`ZodISODate`,(e,t)=>{vp.init(e,t),T_.init(e,t)}),O_=q(`ZodISOTime`,(e,t)=>{yp.init(e,t),T_.init(e,t)}),k_=q(`ZodISODuration`,(e,t)=>{bp.init(e,t),T_.init(e,t)}),A_=q(`ZodEmail`,(e,t)=>{tp.init(e,t),T_.init(e,t)}),j_=q(`ZodGUID`,(e,t)=>{$f.init(e,t),T_.init(e,t)}),M_=q(`ZodUUID`,(e,t)=>{ep.init(e,t),T_.init(e,t)}),N_=q(`ZodURL`,(e,t)=>{lp.init(e,t),T_.init(e,t)}),P_=q(`ZodEmoji`,(e,t)=>{up.init(e,t),T_.init(e,t)}),F_=q(`ZodNanoID`,(e,t)=>{dp.init(e,t),T_.init(e,t)}),I_=q(`ZodCUID`,(e,t)=>{fp.init(e,t),T_.init(e,t)}),L_=q(`ZodCUID2`,(e,t)=>{pp.init(e,t),T_.init(e,t)}),R_=q(`ZodULID`,(e,t)=>{mp.init(e,t),T_.init(e,t)}),z_=q(`ZodXID`,(e,t)=>{hp.init(e,t),T_.init(e,t)}),B_=q(`ZodKSUID`,(e,t)=>{gp.init(e,t),T_.init(e,t)}),V_=q(`ZodIPv4`,(e,t)=>{xp.init(e,t),T_.init(e,t)}),H_=q(`ZodIPv6`,(e,t)=>{wp.init(e,t),T_.init(e,t)}),U_=q(`ZodCIDRv4`,(e,t)=>{Tp.init(e,t),T_.init(e,t)}),W_=q(`ZodCIDRv6`,(e,t)=>{Dp.init(e,t),T_.init(e,t)}),G_=q(`ZodBase64`,(e,t)=>{Ap.init(e,t),T_.init(e,t)}),K_=q(`ZodBase64URL`,(e,t)=>{Np.init(e,t),T_.init(e,t)}),q_=q(`ZodE164`,(e,t)=>{Pp.init(e,t),T_.init(e,t)}),J_=q(`ZodJWT`,(e,t)=>{Ip.init(e,t),T_.init(e,t)}),Y_=q(`ZodNumber`,(e,t)=>{Lp.init(e,t),S_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jg(e,t,n,r),e.isFinite=!0},ed({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=Eg(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=Eg(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=Eg(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>Eg(e).format??null},{gt(e,t){return this.check(jh(e,t))},gte(e,t){return this.check(Mh(e,t))},min(e,t){return this.check(Mh(e,t))},lt(e,t){return this.check(kh(e,t))},lte(e,t){return this.check(Ah(e,t))},max(e,t){return this.check(Ah(e,t))},int(e){return this.check(Q_(e))},safe(e){return this.check(Q_(e))},positive(e){return this.check(jh(0,e))},nonnegative(e){return this.check(Mh(0,e))},negative(e){return this.check(kh(0,e))},nonpositive(e){return this.check(Ah(0,e))},multipleOf(e,t){return this.check(Nh(e,t))},step(e,t){return this.check(Nh(e,t))},finite(){return this}}));function X_(e){return Ch(Y_,e)}var Z_=q(`ZodNumberFormat`,(e,t)=>{Rp.init(e,t),Y_.init(e,t)});function Q_(e){return wh(Z_,e)}var $_=q(`ZodBoolean`,(e,t)=>{zp.init(e,t),S_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mg(e,t,n,r)});function ev(e){return Th($_,e)}var tv=q(`ZodNull`,(e,t)=>{Bp.init(e,t),S_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ng(e,t,n,r)});function nv(e){return Eh(tv,e)}var rv=q(`ZodUnknown`,(e,t)=>{Vp.init(e,t),S_.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function iv(){return Dh(rv)}var av=q(`ZodNever`,(e,t)=>{Hp.init(e,t),S_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pg(e,t,n,r)});function ov(e){return Oh(av,e)}var sv=q(`ZodArray`,(e,t)=>{x_(),Wp.init(e,t),S_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zg(e,t,n,r),e.element=t.element},{min(e,t){return this.check(Fh(e,t))},nonempty(e){return this.check(Fh(1,e))},max(e,t){return this.check(Ph(e,t))},length(e,t){return this.check(Ih(e,t))},unwrap(){return this.element}});function cv(e,t){return Yh(sv,e,t)}var lv=q(`ZodObject`,(e,t)=>{x_(),Xp.init(e,t),S_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vg(e,t,n,r),od(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return yv(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(gu(this._zod.def,{catchall:e}))},passthrough(){return this.clone(gu(this._zod.def,{catchall:iv()}))},loose(){return this.clone(gu(this._zod.def,{catchall:iv()}))},strict(){return this.clone(gu(this._zod.def,{catchall:ov()}))},strip(){return this.clone(gu(this._zod.def,{catchall:void 0}))},extend(e){return Pu(this,e)},safeExtend(e){return Iu(this,e)},merge(e){return Lu(this,e)},pick(e){return ju(this,e)},omit(e){return Nu(this,e)},partial(...e){return Ru(wv,this,e[0])},exactPartial(...e){return Ru(Ev,this,e[0],`exactPartial`)},required(...e){return zu(Pv,this,e[0])}});function Y(e,t){return new lv({type:`object`,shape:e??{},...G(t)})}var uv=q(`ZodUnion`,(e,t)=>{Qp.init(e,t),S_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hg(e,t,n,r),e.options=t.options});function dv(e,t){return new uv({type:`union`,options:e,...G(t)})}var fv=q(`ZodDiscriminatedUnion`,(e,t)=>{uv.init(e,t),em.init(e,t)});function pv(e,t,n){return new fv({type:`union`,options:t,discriminator:e,...G(n)})}var mv=q(`ZodIntersection`,(e,t)=>{tm.init(e,t),S_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ug(e,t,n,r)});function hv(e,t){return new mv({type:`intersection`,left:e,right:t})}var gv=q(`ZodRecord`,(e,t)=>{x_(),im.init(e,t),S_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qg(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function _v(e,t,n){return!t||!t._zod?new gv({type:`record`,keyType:J(),valueType:e,...G(t)}):new gv({type:`record`,keyType:e,valueType:t,...G(n)})}var vv=q(`ZodEnum`,(e,t)=>{am.init(e,t),S_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fg(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new vv({...t,checks:[],...G(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 vv({...t,checks:[],...G(r),entries:i})}});function yv(e,t){return new vv({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...G(t)})}var bv=q(`ZodLiteral`,(e,t)=>{om.init(e,t),S_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ig(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function xv(e,t){return new bv({type:`literal`,values:Array.isArray(e)?e:[e],...G(t)})}var Sv=q(`ZodTransform`,(e,t)=>{x_(),sm.init(e,t),S_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Rg(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new md(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Xu(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(Xu(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Cv(e){return new Sv({type:`transform`,transform:e})}var wv=q(`ZodOptional`,(e,t)=>{lm.init(e,t),S_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>r_(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Tv(e){return new wv({type:`optional`,innerType:e})}var Ev=q(`ZodExactOptional`,(e,t)=>{um.init(e,t),S_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>r_(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Dv(e){return new Ev({type:`optional`,innerType:e})}var Ov=q(`ZodNullable`,(e,t)=>{dm.init(e,t),S_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function kv(e){return new Ov({type:`nullable`,innerType:e})}var Av=q(`ZodDefault`,(e,t)=>{fm.init(e,t),S_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function jv(e,t){return new Av({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Cu(t)}})}var Mv=q(`ZodPrefault`,(e,t)=>{mm.init(e,t),S_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$g(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Nv(e,t){return new Mv({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Cu(t)}})}var Pv=q(`ZodNonOptional`,(e,t)=>{hm.init(e,t),S_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yg(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Fv(e,t){return new Pv({type:`nonoptional`,innerType:e,...G(t)})}var Iv=q(`ZodCatch`,(e,t)=>{vm.init(e,t),S_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>e_(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Lv(e,t){return new Iv({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:cd(t)})}var Rv=q(`ZodPipe`,(e,t)=>{ym.init(e,t),S_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>t_(e,t,n,r),e.in=t.in,e.out=t.out});function zv(e,t){return new Rv({type:`pipe`,in:e,out:t})}var Bv=q(`ZodReadonly`,(e,t)=>{xm.init(e,t),S_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>n_(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Vv(e){return new Bv({type:`readonly`,innerType:e})}var Hv=q(`ZodLazy`,(e,t)=>{Cm.init(e,t),S_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>i_(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function Uv(e){return new Hv({type:`lazy`,getter:e})}var Wv=q(`ZodCustom`,(e,t)=>{wm.init(e,t),S_.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lg(e,t,n,r)});function Gv(e,t={}){return Xh(Wv,e,t)}function Kv(e,t){return Zh(e,t)}function qv(e){let t=Uv(()=>dv([J(e),X_(),ev(),nv(),cv(t),_v(J(),t)]));return t}var Jv=i((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})),Yv=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;var t=Jv(),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}}})),X=i((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=Jv(),n=Yv(),r=Jv();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=Yv();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?`
|
|
132
|
+
`:``},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})`}})),Z=i((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=X(),n=Jv();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})),Xv=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X();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`)}})),Zv=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;var t=X(),n=Z(),r=Xv();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])}})),Qv=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;var t=Zv(),n=X(),r=Xv(),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)}})),$v=i((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})),ey=i((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})),ty=i((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=$v(),n=ey(),r=Zv(),i=X(),a=Z(),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
|
|
133
133
|
|| (${s} == "string" && ${a} && ${a} == +${a})`).assign(c,(0,i._)`+${a}`);return;case`integer`:r.elseIf((0,i._)`${s} === "boolean" || ${a} === null
|
|
134
134
|
|| (${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"
|
|
135
|
-
|| ${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}}})),qv=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.assignDefaults=void 0;var t=X(),n=Z();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)}`)}})),Jv=i((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=X(),n=Z(),r=Vv(),i=Z();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})),Yv=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0;var t=X(),n=Vv(),r=Jv(),i=Hv();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})),Xv=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.extendSubschemaMode=e.extendSubschemaData=e.getSubschema=void 0;var t=X(),n=Z();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})),Zv=i(((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}})),Qv=i(((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`)}})),$v=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getSchemaRefs=e.resolveUrl=e.normalizeId=e._getFullPath=e.getFullPath=e.inlineRef=void 0;var t=Z(),n=Zv(),r=Qv(),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})),ey=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;var t=Uv(),n=Kv(),r=Gv(),i=Kv(),a=qv(),o=Yv(),s=Xv(),c=X(),l=Vv(),u=$v(),d=Z(),f=Hv();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(()=>ne(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)&&ne(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),R(e,e.dataTypes))}function I(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(t=>{z(e.dataTypes,t)||te(e,`type "${t}" not allowed by context "${e.dataTypes.join(`,`)}"`)}),B(e,t)}}function L(e,t){t.length>1&&!(t.length===2&&t.includes(`null`))&&te(e,`use allowUnionTypes to allow union type keyword`)}function R(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=>ee(t,e))&&te(e,`missing type "${n.join(`,`)}" for keyword "${i}"`)}}}function ee(e,t){return e.includes(t)||t===`number`&&e.includes(`integer`)}function z(e,t){return e.includes(t)||t===`integer`&&e.includes(`number`)}function B(e,t){let n=[];for(let r of e.dataTypes)z(t,r)?n.push(r):t.includes(`integer`)&&r===`number`&&n.push(`integer`);e.dataTypes=n}function te(e,t){let n=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${n}" (strictTypes)`,(0,d.checkStrictMode)(e,t,e.opts.strictTypes)}var V=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`,ae(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=V;function ne(e,t,n,r){let i=new V(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 re=/^\/(?:[^~]|~0|~1)*$/,ie=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function ae(e,{dataLevel:t,dataNames:n,dataPathArr:r}){let i,a;if(e===``)return l.default.rootData;if(e[0]===`/`){if(!re.test(e))throw Error(`Invalid JSON-pointer: ${e}`);i=e,a=l.default.rootData}else{let o=ie.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=ae})),ty=i((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}}})),ny=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=$v();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))}}})),ry=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;var t=X(),n=ty(),r=Vv(),i=$v(),a=Z(),o=ey(),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}})),iy=r({$id:()=>ay,additionalProperties:()=>!1,default:()=>uy,description:()=>oy,properties:()=>ly,required:()=>cy,type:()=>sy}),ay,oy,sy,cy,ly,uy,dy=n((()=>{ay=`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`,oy=`Meta-schema for $data reference (JSON AnySchema extension proposal)`,sy=`object`,cy=[`$data`],ly={$data:{type:`string`,anyOf:[{format:`relative-json-pointer`},{format:`json-pointer`}]}},uy={$id:ay,description:oy,type:sy,required:cy,properties:ly,additionalProperties:!1}})),fy=i(((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(/^[\da-f]{2}$/iu),a=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),o=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u),s=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u),c=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u),l=Array(256);{let e=`0123456789ABCDEF`;for(let t=0;t<256;t++)l[t]=`%`+e[t>>4]+e[t&15]}function u(e){return e<2048?l[192|e>>6]+l[128|e&63]:e<65536?l[224|e>>12]+l[128|e>>6&63]+l[128|e&63]:l[240|e>>18]+l[128|e>>12&63]+l[128|e>>6&63]+l[128|e&63]}function d(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 f=RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/),p=RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/),m=RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/),h=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function g(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++)if(!m(e[t])){if(e[t]===`%`&&t+2<e.length&&i(e.slice(t+1,t+3))){t+=2;continue}return!1}return!0}function _(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 v(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(!f(n))return;a[e]=parseInt(n,16).toString(16),o++}if(t===-1)return o===8?_(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 _(s)}function y(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&&p(n))return n=n.toLowerCase(),{host:`[${n}]`,escapedHost:n,isIPV6:!1,isIPVFuture:!0};if(b(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),!g(r))return{host:e,isIPV6:!1,error:!0};n=n.slice(0,i)}let a=v(n);return a===void 0?{host:e,isIPV6:!1,error:!0}:{host:a+(r?`%`+r:``),escapedHost:a+(r?`%25`+r:``),isIPV6:!0}}function b(e,t){let n=0;for(let r=0;r<e.length;r++)e[r]===t&&n++;return n}function x(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 S={"@":`%40`,"/":`%2F`,"?":`%3F`,"#":`%23`,":":`%3A`},C=/[@/?#:]/g,w=/[@/?#]/g;function T(e,t){let n=t?w:C;return n.lastIndex=0,e.replace(n,e=>S[e])}function E(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 o=e.slice(r+1,r+3);if(i(o)){let e=o.toUpperCase(),i=String.fromCharCode(parseInt(e,16));t&&a(i)?n+=i:n+=`%`+e,r+=2;continue}}n+=e[r]}return n}function D(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(i(r)){let e=r.toUpperCase(),i=String.fromCharCode(parseInt(e,16));i!==`.`&&a(i)?t+=i:t+=`%`+e,n+=2;continue}}if(o(r))t+=r;else{let i=e.charCodeAt(n);if(i<128)t+=N(i)?r:l[i];else if(i<55296||i>57343)t+=u(i);else if(i<=56319&&n+1<e.length){let r=e.charCodeAt(n+1);r>=56320&&r<=57343?(t+=u(65536+(i-55296<<10)+(r-56320)),n++):t+=u(65533)}else t+=u(65533)}}return t}function O(e,t=!1){let n=``,r=t&&e[0]!==`/`;for(let t=0;t<e.length;t++){let a=e[t];if(a===`%`&&t+2<e.length){let r=e.slice(t+1,t+3);if(i(r)){n+=`%`+r.toUpperCase(),t+=2;continue}}if(a===`/`&&(r=!1),o(a)&&(a!==`:`||!r))n+=a;else{let r=e.charCodeAt(t);if(r<128)n+=l[r];else if(r<55296||r>57343)n+=u(r);else if(r<=56319&&t+1<e.length){let i=e.charCodeAt(t+1);i>=56320&&i<=57343?(n+=u(65536+(r-55296<<10)+(i-56320)),t++):n+=u(65533)}else n+=u(65533)}}return n}function k(e,t){let n=``;for(let r=0;r<e.length;r++){let a=e[r];if(a===`%`&&r+2<e.length){let t=e.slice(r+1,r+3);if(i(t)){n+=`%`+t.toUpperCase(),r+=2;continue}}if(t(a))n+=a;else{let t=e.charCodeAt(r);if(t<128)n+=l[t];else if(t<55296||t>57343)n+=u(t);else if(t<=56319&&r+1<e.length){let i=e.charCodeAt(r+1);i>=56320&&i<=57343?(n+=u(65536+(t-55296<<10)+(i-56320)),r++):n+=u(65533)}else n+=u(65533)}}return n}function A(e){return k(e,c)}function j(e){return k(e,s)}function M(e){return k(e,s)}function N(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 P(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(i(r)){let e=r.toUpperCase(),i=String.fromCharCode(parseInt(e,16));a(i)?t+=i:t+=`%`+e,n+=2;continue}}if(s(r))t+=r;else{let i=e.charCodeAt(n);if(i<128)t+=N(i)?r:l[i];else if(i<55296||i>57343)t+=u(i);else if(i<=56319&&n+1<e.length){let r=e.charCodeAt(n+1);r>=56320&&r<=57343?(t+=u(65536+(i-55296<<10)+(r-56320)),n++):t+=u(65533)}else t+=u(65533)}}return t}function F(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(i(r)){t+=`%`+r.toUpperCase(),n+=2;continue}}t+=escape(e[n])}return t}function I(e){let t=[];if(e.userinfo!==void 0&&(t.push(A(e.userinfo)),t.push(`@`)),e.host!==void 0){let n=e.host;if(!r(n)){let e=y(n);e.isIPV6!==!0&&e.isIPVFuture!==!0&&(n=E(n,!0),e=y(n)),n=e.isIPV6===!0||e.isIPVFuture===!0?`[${e.escapedHost}]`:T(n,!1)}t.push(n)}return(typeof e.port==`number`||typeof e.port==`string`)&&(t.push(`:`),t.push(String(e.port))),t.length?t.join(``):void 0}t.exports={nonSimpleDomain:h,recomposeAuthority:I,reescapeHostDelimiters:T,normalizePercentEncoding:E,normalizePathEncoding:D,serializePathEncoding:O,normalizeQueryFragmentEncoding:P,encodeUserinfo:A,encodeQuery:j,encodeFragment:M,escapePreservingEscapes:F,removeDotSegments:x,isIPv4:r,isUUID:n,normalizeIPv6:y,stringArrayToHexStripped:d}})),py=i(((e,t)=>{var{isUUID:n}=fy(),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}})),my=i(((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}=fy(),{SCHEMES:m,getSchemeHandler:h}=py(),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=N(e,t):typeof e==`object`&&(e=M(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}=j(e,i),{parsed:d,malformedAuthorityOrPort:p,malformedPercentEncoding:m,malformedSchemeSpecific:g,malformedHost:_,malformedScheme:v}=j(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);A(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=M(C(e,n),n),t=M(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=F(e,n),i=F(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){let t=e[4];return O(e[3])||t!==void 0&&(t[0]!==`[`||t[t.length-1]!==`]`)&&O(t)||O(e[6])||O(e[7])||O(e[8])}function A(e,t,n,r){if(!t.unicodeSupport&&(!n||!n.unicodeSupport)&&e.host&&e.host[0]!==`[`&&(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 j(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=k(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=i.host[0]===`[`&&i.host[i.host.length-1]===`]`,t=n(i.host);b=t.isIPV6||t.isIPVFuture===!0,v=e&&t.error===!0,i.host=b?t.host:t.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);p=A(i,r,x,b),(!x||x&&!x.skipNormalize)&&(e.indexOf(`%`)!==-1&&i.host!==void 0&&!v&&(i.host=d(b?i.host:a(i.host,!0),b)),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 M(e,t){return j(e,t).parsed}function N(e,t){return P(e,t).normalized}function P(e,t){let{parsed:n,malformedAuthorityOrPort:r,malformedPercentEncoding:i,malformedSchemeSpecific:a,malformedHost:o,malformedScheme:s}=j(e,t);return{normalized:r||i||a||o||s?e:C(n,t),malformedAuthorityOrPort:r,malformedPercentEncoding:i,malformedSchemeSpecific:a,malformedHost:o,malformedScheme:s}}function F(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}=P(n,t);return i||a||o||s||c?void 0:r}var I={SCHEMES:m,normalize:y,resolve:b,resolveComponent:x,equal:S,serialize:C,parse:M};t.exports=I,t.exports.default=I,t.exports.fastUri=I})),hy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=my();t.code=`require("ajv/dist/runtime/uri").default`,e.default=t})),gy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var n=ey();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return n.KeywordCxt}});var r=X();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return r.CodeGen}});var i=ty(),a=ny(),o=Wv(),s=ry(),c=X(),l=$v(),u=Kv(),d=Z(),f=(dy(),t(iy).default),p=hy(),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 c.ValueScope({scope:{},prefixes:g,es5:t,lines:n}),this.logger=k(e.logger);let r=e.validateFormats;e.validateFormats=!1,this.RULES=(0,o.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 i.call(this,e.$schema);let n=this._addSchema(e,t);return n.validate||o.call(this,n)}async function i(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 a.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 i.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,l.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 s.SchemaEnv({schema:{},schemaId:n});if(t=s.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,l.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,d.eachItem)(n,e=>M.call(this,e)),this;P.call(this,t);let r={...t,type:(0,u.getJSONTypes)(t.type),schemaType:(0,u.getJSONTypes)(t.schemaType)};return(0,d.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:o}=this.opts;if(typeof e==`object`)a=e[o];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 c=this._cache.get(e);if(c!==void 0)return c;n=(0,l.normalizeId)(a||n);let u=l.getSchemaRefs.call(this,e,n);return c=new s.SchemaEnv({schema:e,schemaId:o,meta:t,baseId:n,localRefs:u}),this._cache.set(c.schema,c),i&&!n.startsWith(`#`)&&(n&&this._checkUnique(n),this.refs[n]=c),r&&this.validateSchema(e,!0),c}_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):s.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{s.compileSchema.call(this,e)}finally{this.opts=t}}};x.ValidationError=i.default,x.MissingRefError=a.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,l.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,d.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,u.getJSONTypes)(t.type),schemaType:(0,u.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]}}})),_y=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default={keyword:`id`,code(){throw Error(`NOT SUPPORTED: keyword "id", use "$id" for schema ID`)}}})),vy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.callRef=e.getValidate=void 0;var t=ny(),n=Jv(),r=X(),i=Vv(),a=ry(),o=Z(),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})),yy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=_y(),n=vy();e.default=[`$schema`,`$id`,`$defs`,`$vocabulary`,{keyword:`$comment`},`definitions`,t.default,n.default]})),by=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),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})`)}}})),xy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X();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}))`)}}})),Sy=i((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`})),Cy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),n=Z(),r=Sy();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}`)}}})),wy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Jv(),n=Z(),r=X();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})`)}}}})),Ty=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X();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}`)}}})),Ey=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Jv(),n=X(),r=Z();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)}}}})),Dy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X();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}`)}}})),Oy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Zv();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t})),ky=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Kv(),n=X(),r=Z(),i=Oy();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)})))}}}})),Ay=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),n=Z(),r=Oy();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}`)}}})),jy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),n=Z(),r=Oy();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}`}}}})),My=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=by(),n=xy(),r=Cy(),i=wy(),a=Ty(),o=Ey(),s=Dy(),c=ky(),l=Ay(),u=jy();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]})),Ny=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateAdditionalItems=void 0;var t=X(),n=Z(),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})),Py=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateTuple=void 0;var t=X(),n=Z(),r=Jv(),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})),Fy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Py();e.default={keyword:`prefixItems`,type:`array`,schemaType:[`array`],before:`uniqueItems`,code:e=>(0,t.validateTuple)(e,`items`)}})),Iy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),n=Z(),r=Jv(),i=Ny();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)))}}})),Ly=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),n=Z();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)))}}}})),Ry=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;var t=X(),n=Z(),r=Jv();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},
|
|
135
|
+
|| ${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}}})),ny=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.assignDefaults=void 0;var t=X(),n=Z();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)}`)}})),ry=i((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=X(),n=Z(),r=Xv(),i=Z();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})),iy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0;var t=X(),n=Xv(),r=ry(),i=Zv();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})),ay=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.extendSubschemaMode=e.extendSubschemaData=e.getSubschema=void 0;var t=X(),n=Z();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})),oy=i(((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}})),sy=i(((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`)}})),cy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getSchemaRefs=e.resolveUrl=e.normalizeId=e._getFullPath=e.getFullPath=e.inlineRef=void 0;var t=Z(),n=oy(),r=sy(),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})),ly=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;var t=Qv(),n=ty(),r=ey(),i=ty(),a=ny(),o=iy(),s=ay(),c=X(),l=Xv(),u=cy(),d=Z(),f=Zv();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(()=>ne(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)&&ne(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),R(e,e.dataTypes))}function I(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(t=>{z(e.dataTypes,t)||te(e,`type "${t}" not allowed by context "${e.dataTypes.join(`,`)}"`)}),B(e,t)}}function L(e,t){t.length>1&&!(t.length===2&&t.includes(`null`))&&te(e,`use allowUnionTypes to allow union type keyword`)}function R(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=>ee(t,e))&&te(e,`missing type "${n.join(`,`)}" for keyword "${i}"`)}}}function ee(e,t){return e.includes(t)||t===`number`&&e.includes(`integer`)}function z(e,t){return e.includes(t)||t===`integer`&&e.includes(`number`)}function B(e,t){let n=[];for(let r of e.dataTypes)z(t,r)?n.push(r):t.includes(`integer`)&&r===`number`&&n.push(`integer`);e.dataTypes=n}function te(e,t){let n=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${n}" (strictTypes)`,(0,d.checkStrictMode)(e,t,e.opts.strictTypes)}var V=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`,ae(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=V;function ne(e,t,n,r){let i=new V(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 re=/^\/(?:[^~]|~0|~1)*$/,ie=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function ae(e,{dataLevel:t,dataNames:n,dataPathArr:r}){let i,a;if(e===``)return l.default.rootData;if(e[0]===`/`){if(!re.test(e))throw Error(`Invalid JSON-pointer: ${e}`);i=e,a=l.default.rootData}else{let o=ie.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=ae})),uy=i((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}}})),dy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=cy();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))}}})),fy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;var t=X(),n=uy(),r=Xv(),i=cy(),a=Z(),o=ly(),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}})),py=r({$id:()=>my,additionalProperties:()=>!1,default:()=>yy,description:()=>hy,properties:()=>vy,required:()=>_y,type:()=>gy}),my,hy,gy,_y,vy,yy,by=n((()=>{my=`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`,hy=`Meta-schema for $data reference (JSON AnySchema extension proposal)`,gy=`object`,_y=[`$data`],vy={$data:{type:`string`,anyOf:[{format:`relative-json-pointer`},{format:`json-pointer`}]}},yy={$id:my,description:hy,type:gy,required:_y,properties:vy,additionalProperties:!1}})),xy=i(((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(/^[\da-f]{2}$/iu),a=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),o=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u),s=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u),c=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u),l=Array(256);{let e=`0123456789ABCDEF`;for(let t=0;t<256;t++)l[t]=`%`+e[t>>4]+e[t&15]}function u(e){return e<2048?l[192|e>>6]+l[128|e&63]:e<65536?l[224|e>>12]+l[128|e>>6&63]+l[128|e&63]:l[240|e>>18]+l[128|e>>12&63]+l[128|e>>6&63]+l[128|e&63]}function d(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 f=RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/),p=RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/),m=RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/),h=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function g(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++)if(!m(e[t])){if(e[t]===`%`&&t+2<e.length&&i(e.slice(t+1,t+3))){t+=2;continue}return!1}return!0}function _(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 v(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(!f(n))return;a[e]=parseInt(n,16).toString(16),o++}if(t===-1)return o===8?_(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 _(s)}function y(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&&p(n))return n=n.toLowerCase(),{host:`[${n}]`,escapedHost:n,isIPV6:!1,isIPVFuture:!0};if(b(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),!g(r))return{host:e,isIPV6:!1,error:!0};n=n.slice(0,i)}let a=v(n);return a===void 0?{host:e,isIPV6:!1,error:!0}:{host:a+(r?`%`+r:``),escapedHost:a+(r?`%25`+r:``),isIPV6:!0}}function b(e,t){let n=0;for(let r=0;r<e.length;r++)e[r]===t&&n++;return n}function x(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 S={"@":`%40`,"/":`%2F`,"?":`%3F`,"#":`%23`,":":`%3A`},C=/[@/?#:]/g,w=/[@/?#]/g;function T(e,t){let n=t?w:C;return n.lastIndex=0,e.replace(n,e=>S[e])}function E(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 o=e.slice(r+1,r+3);if(i(o)){let e=o.toUpperCase(),i=String.fromCharCode(parseInt(e,16));t&&a(i)?n+=i:n+=`%`+e,r+=2;continue}}n+=e[r]}return n}function D(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(i(r)){let e=r.toUpperCase(),i=String.fromCharCode(parseInt(e,16));i!==`.`&&a(i)?t+=i:t+=`%`+e,n+=2;continue}}if(o(r))t+=r;else{let i=e.charCodeAt(n);if(i<128)t+=N(i)?r:l[i];else if(i<55296||i>57343)t+=u(i);else if(i<=56319&&n+1<e.length){let r=e.charCodeAt(n+1);r>=56320&&r<=57343?(t+=u(65536+(i-55296<<10)+(r-56320)),n++):t+=u(65533)}else t+=u(65533)}}return t}function O(e,t=!1){let n=``,r=t&&e[0]!==`/`;for(let t=0;t<e.length;t++){let a=e[t];if(a===`%`&&t+2<e.length){let r=e.slice(t+1,t+3);if(i(r)){n+=`%`+r.toUpperCase(),t+=2;continue}}if(a===`/`&&(r=!1),o(a)&&(a!==`:`||!r))n+=a;else{let r=e.charCodeAt(t);if(r<128)n+=l[r];else if(r<55296||r>57343)n+=u(r);else if(r<=56319&&t+1<e.length){let i=e.charCodeAt(t+1);i>=56320&&i<=57343?(n+=u(65536+(r-55296<<10)+(i-56320)),t++):n+=u(65533)}else n+=u(65533)}}return n}function k(e,t){let n=``;for(let r=0;r<e.length;r++){let a=e[r];if(a===`%`&&r+2<e.length){let t=e.slice(r+1,r+3);if(i(t)){n+=`%`+t.toUpperCase(),r+=2;continue}}if(t(a))n+=a;else{let t=e.charCodeAt(r);if(t<128)n+=l[t];else if(t<55296||t>57343)n+=u(t);else if(t<=56319&&r+1<e.length){let i=e.charCodeAt(r+1);i>=56320&&i<=57343?(n+=u(65536+(t-55296<<10)+(i-56320)),r++):n+=u(65533)}else n+=u(65533)}}return n}function A(e){return k(e,c)}function j(e){return k(e,s)}function M(e){return k(e,s)}function N(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 P(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(i(r)){let e=r.toUpperCase(),i=String.fromCharCode(parseInt(e,16));a(i)?t+=i:t+=`%`+e,n+=2;continue}}if(s(r))t+=r;else{let i=e.charCodeAt(n);if(i<128)t+=N(i)?r:l[i];else if(i<55296||i>57343)t+=u(i);else if(i<=56319&&n+1<e.length){let r=e.charCodeAt(n+1);r>=56320&&r<=57343?(t+=u(65536+(i-55296<<10)+(r-56320)),n++):t+=u(65533)}else t+=u(65533)}}return t}function F(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(i(r)){t+=`%`+r.toUpperCase(),n+=2;continue}}t+=escape(e[n])}return t}function I(e){let t=[];if(e.userinfo!==void 0&&(t.push(A(e.userinfo)),t.push(`@`)),e.host!==void 0){let n=e.host;if(!r(n)){let e=y(n);e.isIPV6!==!0&&e.isIPVFuture!==!0&&(n=E(n,!0),e=y(n)),n=e.isIPV6===!0||e.isIPVFuture===!0?`[${e.escapedHost}]`:T(n,!1)}t.push(n)}return(typeof e.port==`number`||typeof e.port==`string`)&&(t.push(`:`),t.push(String(e.port))),t.length?t.join(``):void 0}t.exports={nonSimpleDomain:h,recomposeAuthority:I,reescapeHostDelimiters:T,normalizePercentEncoding:E,normalizePathEncoding:D,serializePathEncoding:O,normalizeQueryFragmentEncoding:P,encodeUserinfo:A,encodeQuery:j,encodeFragment:M,escapePreservingEscapes:F,removeDotSegments:x,isIPv4:r,isUUID:n,normalizeIPv6:y,stringArrayToHexStripped:d}})),Sy=i(((e,t)=>{var{isUUID:n}=xy(),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}})),Cy=i(((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}=xy(),{SCHEMES:m,getSchemeHandler:h}=Sy(),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=N(e,t):typeof e==`object`&&(e=M(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}=j(e,i),{parsed:d,malformedAuthorityOrPort:p,malformedPercentEncoding:m,malformedSchemeSpecific:g,malformedHost:_,malformedScheme:v}=j(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);A(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=M(C(e,n),n),t=M(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=F(e,n),i=F(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){let t=e[4];return O(e[3])||t!==void 0&&(t[0]!==`[`||t[t.length-1]!==`]`)&&O(t)||O(e[6])||O(e[7])||O(e[8])}function A(e,t,n,r){if(!t.unicodeSupport&&(!n||!n.unicodeSupport)&&e.host&&e.host[0]!==`[`&&(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 j(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=k(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=i.host[0]===`[`&&i.host[i.host.length-1]===`]`,t=n(i.host);b=t.isIPV6||t.isIPVFuture===!0,v=e&&t.error===!0,i.host=b?t.host:t.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);p=A(i,r,x,b),(!x||x&&!x.skipNormalize)&&(e.indexOf(`%`)!==-1&&i.host!==void 0&&!v&&(i.host=d(b?i.host:a(i.host,!0),b)),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 M(e,t){return j(e,t).parsed}function N(e,t){return P(e,t).normalized}function P(e,t){let{parsed:n,malformedAuthorityOrPort:r,malformedPercentEncoding:i,malformedSchemeSpecific:a,malformedHost:o,malformedScheme:s}=j(e,t);return{normalized:r||i||a||o||s?e:C(n,t),malformedAuthorityOrPort:r,malformedPercentEncoding:i,malformedSchemeSpecific:a,malformedHost:o,malformedScheme:s}}function F(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}=P(n,t);return i||a||o||s||c?void 0:r}var I={SCHEMES:m,normalize:y,resolve:b,resolveComponent:x,equal:S,serialize:C,parse:M};t.exports=I,t.exports.default=I,t.exports.fastUri=I})),wy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Cy();t.code=`require("ajv/dist/runtime/uri").default`,e.default=t})),Ty=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var n=ly();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return n.KeywordCxt}});var r=X();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return r.CodeGen}});var i=uy(),a=dy(),o=$v(),s=fy(),c=X(),l=cy(),u=ty(),d=Z(),f=(by(),t(py).default),p=wy(),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 c.ValueScope({scope:{},prefixes:g,es5:t,lines:n}),this.logger=k(e.logger);let r=e.validateFormats;e.validateFormats=!1,this.RULES=(0,o.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 i.call(this,e.$schema);let n=this._addSchema(e,t);return n.validate||o.call(this,n)}async function i(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 a.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 i.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,l.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 s.SchemaEnv({schema:{},schemaId:n});if(t=s.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,l.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,d.eachItem)(n,e=>M.call(this,e)),this;P.call(this,t);let r={...t,type:(0,u.getJSONTypes)(t.type),schemaType:(0,u.getJSONTypes)(t.schemaType)};return(0,d.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:o}=this.opts;if(typeof e==`object`)a=e[o];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 c=this._cache.get(e);if(c!==void 0)return c;n=(0,l.normalizeId)(a||n);let u=l.getSchemaRefs.call(this,e,n);return c=new s.SchemaEnv({schema:e,schemaId:o,meta:t,baseId:n,localRefs:u}),this._cache.set(c.schema,c),i&&!n.startsWith(`#`)&&(n&&this._checkUnique(n),this.refs[n]=c),r&&this.validateSchema(e,!0),c}_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):s.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{s.compileSchema.call(this,e)}finally{this.opts=t}}};x.ValidationError=i.default,x.MissingRefError=a.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,l.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,d.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,u.getJSONTypes)(t.type),schemaType:(0,u.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]}}})),Ey=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default={keyword:`id`,code(){throw Error(`NOT SUPPORTED: keyword "id", use "$id" for schema ID`)}}})),Dy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.callRef=e.getValidate=void 0;var t=dy(),n=ry(),r=X(),i=Xv(),a=fy(),o=Z(),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})),Oy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Ey(),n=Dy();e.default=[`$schema`,`$id`,`$defs`,`$vocabulary`,{keyword:`$comment`},`definitions`,t.default,n.default]})),ky=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),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})`)}}})),Ay=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X();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}))`)}}})),jy=i((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`})),My=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),n=Z(),r=jy();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}`)}}})),Ny=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=ry(),n=Z(),r=X();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})`)}}}})),Py=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X();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}`)}}})),Fy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=ry(),n=X(),r=Z();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)}}}})),Iy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X();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}`)}}})),Ly=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=oy();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t})),Ry=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=ty(),n=X(),r=Z(),i=Ly();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)})))}}}})),zy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),n=Z(),r=Ly();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}`)}}})),By=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),n=Z(),r=Ly();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}`}}}})),Vy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=ky(),n=Ay(),r=My(),i=Ny(),a=Py(),o=Fy(),s=Iy(),c=Ry(),l=zy(),u=By();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]})),Hy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateAdditionalItems=void 0;var t=X(),n=Z(),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})),Uy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateTuple=void 0;var t=X(),n=Z(),r=ry(),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})),Wy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Uy();e.default={keyword:`prefixItems`,type:`array`,schemaType:[`array`],before:`uniqueItems`,code:e=>(0,t.validateTuple)(e,`items`)}})),Gy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),n=Z(),r=ry(),i=Hy();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)))}}})),Ky=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),n=Z();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)))}}}})),qy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;var t=X(),n=Z(),r=ry();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},
|
|
136
136
|
missingProperty: ${i},
|
|
137
137
|
depsCount: ${n},
|
|
138
|
-
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})),zy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),n=Z();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)}}})),By=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Jv(),n=X(),r=Vv(),i=Z();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)}}}})),Vy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=ey(),n=Jv(),r=Z(),i=By();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)}}}})),Hy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Jv(),n=X(),r=Z(),i=Z();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())})})}}}})),Uy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Z();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`}}})),Wy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default={keyword:`anyOf`,schemaType:`array`,trackErrors:!0,code:Jv().validateUnion,error:{message:`must match a schema in anyOf`}}})),Gy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),n=Z();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)})})}}}})),Ky=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Z();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)})}}})),qy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),n=Z(),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})),Jy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Z();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`)}}})),Yy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Ny(),n=Fy(),r=Py(),i=Iy(),a=Ly(),o=Ry(),s=zy(),c=By(),l=Vy(),u=Hy(),d=Uy(),f=Wy(),p=Gy(),m=Ky(),h=qy(),g=Jy();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=_})),Xy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X();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})`}}}}})),Zy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=[Xy().default]})),Qy=i((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`]})),$y=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=yy(),n=My(),r=Yy(),i=Zy(),a=Qy();e.default=[t.default,n.default,(0,r.default)(),i.default,a.metadataVocabulary,a.contentVocabulary]})),eb=i((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={}))})),tb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),n=eb(),r=ry(),i=ny(),a=Z();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}}}}})),nb=r({$id:()=>ib,$schema:()=>rb,default:()=>lb,definitions:()=>ob,properties:()=>cb,title:()=>ab,type:()=>sb}),rb,ib,ab,ob,sb,cb,lb,ub=n((()=>{rb=`http://json-schema.org/draft-07/schema#`,ib=`http://json-schema.org/draft-07/schema#`,ab=`Core schema meta-schema`,ob={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:[]}},sb=[`object`,`boolean`],cb={$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:`#`}},lb={$schema:rb,$id:ib,title:ab,definitions:ob,type:sb,properties:cb,default:!0}})),db=i(((e,n)=>{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 r=gy(),i=$y(),a=tb(),o=(ub(),t(nb).default),s=[`/properties`],c=`http://json-schema.org/draft-07/schema`,l=class extends r.default{_addVocabularies(){super._addVocabularies(),i.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(a.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(o,s):o;this.addMetaSchema(e,c,!1),this.refs[`http://json-schema.org/schema`]=c}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(c)?c:void 0)}};e.Ajv=l,n.exports=e=l,n.exports.Ajv=l,Object.defineProperty(e,"__esModule",{value:!0}),e.default=l;var u=ey();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return u.KeywordCxt}});var d=X();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return d._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return d.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return d.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return d.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return d.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return d.CodeGen}});var f=ty();Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return f.default}});var p=ny();Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return p.default}})})),fb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.dynamicAnchor=void 0;var t=X(),n=Vv(),r=ry(),i=vy(),a={keyword:`$dynamicAnchor`,schemaType:`string`,code:e=>o(e,e.schema)};function o(e,r){let{gen:i,it:a}=e;a.schemaEnv.root.dynamicAnchors[r]=!0;let o=(0,t._)`${n.default.dynamicAnchors}${(0,t.getProperty)(r)}`,c=a.errSchemaPath===`#`?a.validateName:s(e);i.if((0,t._)`!${o}`,()=>i.assign(o,c))}e.dynamicAnchor=o;function s(e){let{schemaEnv:t,schema:n,self:a}=e.it,{root:o,baseId:s,localRefs:c,meta:l}=t.root,{schemaId:u}=a.opts,d=new r.SchemaEnv({schema:n,schemaId:u,root:o,baseId:s,localRefs:c,meta:l});return r.compileSchema.call(a,d),(0,i.getValidate)(e,d)}e.default=a})),pb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.dynamicRef=void 0;var t=X(),n=Vv(),r=vy(),i={keyword:`$dynamicRef`,schemaType:`string`,code:e=>a(e,e.schema)};function a(e,i){let{gen:a,keyword:o,it:s}=e;if(i[0]!==`#`)throw Error(`"${o}" only supports hash fragment reference`);let c=i.slice(1);if(s.allErrors)l();else{let t=a.let(`valid`,!1);l(t),e.ok(t)}function l(e){if(s.schemaEnv.root.dynamicAnchors[c]){let r=a.let(`_v`,(0,t._)`${n.default.dynamicAnchors}${(0,t.getProperty)(c)}`);a.if(r,u(r,e),u(s.validateName,e))}else u(s.validateName,e)()}function u(t,n){return n?()=>a.block(()=>{(0,r.callRef)(e,t),a.let(n,!0)}):()=>(0,r.callRef)(e,t)}}e.dynamicRef=a,e.default=i})),mb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=fb(),n=Z();e.default={keyword:`$recursiveAnchor`,schemaType:`boolean`,code(e){e.schema?(0,t.dynamicAnchor)(e,``):(0,n.checkStrictMode)(e.it,`$recursiveAnchor: false is ignored`)}}})),hb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=pb();e.default={keyword:`$recursiveRef`,schemaType:`string`,code:e=>(0,t.dynamicRef)(e,e.schema)}})),gb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=fb(),n=pb(),r=mb(),i=hb();e.default=[t.default,n.default,r.default,i.default]})),_b=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Ry();e.default={keyword:`dependentRequired`,type:`object`,schemaType:`object`,error:t.error,code:e=>(0,t.validatePropertyDeps)(e)}})),vb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Ry();e.default={keyword:`dependentSchemas`,type:`object`,schemaType:`object`,code:e=>(0,t.validateSchemaDeps)(e)}})),yb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Z();e.default={keyword:[`maxContains`,`minContains`],type:`array`,schemaType:`number`,code({keyword:e,parentSchema:n,it:r}){n.contains===void 0&&(0,t.checkStrictMode)(r,`"${e}" without "contains" is ignored`)}}})),bb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=_b(),n=vb(),r=yb();e.default=[t.default,n.default,r.default]})),xb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),n=Z(),r=Vv();e.default={keyword:`unevaluatedProperties`,type:`object`,schemaType:[`boolean`,`object`],trackErrors:!0,error:{message:`must NOT have unevaluated properties`,params:({params:e})=>(0,t._)`{unevaluatedProperty: ${e.unevaluatedProperty}}`},code(e){let{gen:i,schema:a,data:o,errsCount:s,it:c}=e;if(!s)throw Error(`ajv implementation error`);let{allErrors:l,props:u}=c;u instanceof t.Name?i.if((0,t._)`${u} !== true`,()=>i.forIn(`key`,o,e=>i.if(f(u,e),()=>d(e)))):u!==!0&&i.forIn(`key`,o,e=>u===void 0?d(e):i.if(p(u,e),()=>d(e))),c.props=!0,e.ok((0,t._)`${s} === ${r.default.errors}`);function d(r){if(a===!1){e.setParams({unevaluatedProperty:r}),e.error(),l||i.break();return}if(!(0,n.alwaysValidSchema)(c,a)){let a=i.name(`valid`);e.subschema({keyword:`unevaluatedProperties`,dataProp:r,dataPropType:n.Type.Str},a),l||i.if((0,t.not)(a),()=>i.break())}}function f(e,n){return(0,t._)`!${e} || !${e}[${n}]`}function p(e,n){let r=[];for(let i in e)e[i]===!0&&r.push((0,t._)`${n} !== ${i}`);return(0,t.and)(...r)}}}})),Sb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),n=Z();e.default={keyword:`unevaluatedItems`,type:`array`,schemaType:[`boolean`,`object`],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{gen:r,schema:i,data:a,it:o}=e,s=o.items||0;if(s===!0)return;let c=r.const(`len`,(0,t._)`${a}.length`);if(i===!1)e.setParams({len:s}),e.fail((0,t._)`${c} > ${s}`);else if(typeof i==`object`&&!(0,n.alwaysValidSchema)(o,i)){let n=r.var(`valid`,(0,t._)`${c} <= ${s}`);r.if((0,t.not)(n),()=>l(n,s)),e.ok(n)}o.items=!0;function l(i,a){r.forRange(`i`,a,c,a=>{e.subschema({keyword:`unevaluatedItems`,dataProp:a,dataPropType:n.Type.Num},i),o.allErrors||r.if((0,t.not)(i),()=>r.break())})}}}})),Cb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=xb(),n=Sb();e.default=[t.default,n.default]})),wb=r({$id:()=>Eb,$recursiveAnchor:()=>!0,$schema:()=>Tb,$vocabulary:()=>Db,allOf:()=>kb,default:()=>Mb,properties:()=>jb,title:()=>Ob,type:()=>Ab}),Tb,Eb,Db,Ob,kb,Ab,jb,Mb,Nb=n((()=>{Tb=`https://json-schema.org/draft/2019-09/schema`,Eb=`https://json-schema.org/draft/2019-09/schema`,Db={"https://json-schema.org/draft/2019-09/vocab/core":!0,"https://json-schema.org/draft/2019-09/vocab/applicator":!0,"https://json-schema.org/draft/2019-09/vocab/validation":!0,"https://json-schema.org/draft/2019-09/vocab/meta-data":!0,"https://json-schema.org/draft/2019-09/vocab/format":!1,"https://json-schema.org/draft/2019-09/vocab/content":!0},Ob=`Core and Validation specifications meta-schema`,kb=[{$ref:`meta/core`},{$ref:`meta/applicator`},{$ref:`meta/validation`},{$ref:`meta/meta-data`},{$ref:`meta/format`},{$ref:`meta/content`}],Ab=[`object`,`boolean`],jb={definitions:{$comment:`While no longer an official keyword as it is replaced by $defs, this keyword is retained in the meta-schema to prevent incompatible extensions as it remains in common use.`,type:`object`,additionalProperties:{$recursiveRef:`#`},default:{}},dependencies:{$comment:`"dependencies" is no longer a keyword, but schema authors should avoid redefining it to facilitate a smooth transition to "dependentSchemas" and "dependentRequired"`,type:`object`,additionalProperties:{anyOf:[{$recursiveRef:`#`},{$ref:`meta/validation#/$defs/stringArray`}]}}},Mb={$schema:Tb,$id:Eb,$vocabulary:Db,$recursiveAnchor:!0,title:Ob,allOf:kb,type:Ab,properties:jb}})),Pb=r({$defs:()=>Vb,$id:()=>Ib,$recursiveAnchor:()=>!0,$schema:()=>Fb,$vocabulary:()=>Lb,default:()=>Hb,properties:()=>Bb,title:()=>Rb,type:()=>zb}),Fb,Ib,Lb,Rb,zb,Bb,Vb,Hb,Ub=n((()=>{Fb=`https://json-schema.org/draft/2019-09/schema`,Ib=`https://json-schema.org/draft/2019-09/meta/applicator`,Lb={"https://json-schema.org/draft/2019-09/vocab/applicator":!0},Rb=`Applicator vocabulary meta-schema`,zb=[`object`,`boolean`],Bb={additionalItems:{$recursiveRef:`#`},unevaluatedItems:{$recursiveRef:`#`},items:{anyOf:[{$recursiveRef:`#`},{$ref:`#/$defs/schemaArray`}]},contains:{$recursiveRef:`#`},additionalProperties:{$recursiveRef:`#`},unevaluatedProperties:{$recursiveRef:`#`},properties:{type:`object`,additionalProperties:{$recursiveRef:`#`},default:{}},patternProperties:{type:`object`,additionalProperties:{$recursiveRef:`#`},propertyNames:{format:`regex`},default:{}},dependentSchemas:{type:`object`,additionalProperties:{$recursiveRef:`#`}},propertyNames:{$recursiveRef:`#`},if:{$recursiveRef:`#`},then:{$recursiveRef:`#`},else:{$recursiveRef:`#`},allOf:{$ref:`#/$defs/schemaArray`},anyOf:{$ref:`#/$defs/schemaArray`},oneOf:{$ref:`#/$defs/schemaArray`},not:{$recursiveRef:`#`}},Vb={schemaArray:{type:`array`,minItems:1,items:{$recursiveRef:`#`}}},Hb={$schema:Fb,$id:Ib,$vocabulary:Lb,$recursiveAnchor:!0,title:Rb,type:zb,properties:Bb,$defs:Vb}})),Wb=r({$id:()=>Kb,$recursiveAnchor:()=>!0,$schema:()=>Gb,$vocabulary:()=>qb,default:()=>Zb,properties:()=>Xb,title:()=>Jb,type:()=>Yb}),Gb,Kb,qb,Jb,Yb,Xb,Zb,Qb=n((()=>{Gb=`https://json-schema.org/draft/2019-09/schema`,Kb=`https://json-schema.org/draft/2019-09/meta/content`,qb={"https://json-schema.org/draft/2019-09/vocab/content":!0},Jb=`Content vocabulary meta-schema`,Yb=[`object`,`boolean`],Xb={contentMediaType:{type:`string`},contentEncoding:{type:`string`},contentSchema:{$recursiveRef:`#`}},Zb={$schema:Gb,$id:Kb,$vocabulary:qb,$recursiveAnchor:!0,title:Jb,type:Yb,properties:Xb}})),$b=r({$id:()=>tx,$recursiveAnchor:()=>!0,$schema:()=>ex,$vocabulary:()=>nx,default:()=>ox,properties:()=>ax,title:()=>rx,type:()=>ix}),ex,tx,nx,rx,ix,ax,ox,sx=n((()=>{ex=`https://json-schema.org/draft/2019-09/schema`,tx=`https://json-schema.org/draft/2019-09/meta/core`,nx={"https://json-schema.org/draft/2019-09/vocab/core":!0},rx=`Core vocabulary meta-schema`,ix=[`object`,`boolean`],ax={$id:{type:`string`,format:`uri-reference`,$comment:`Non-empty fragments not allowed.`,pattern:`^[^#]*#?$`},$schema:{type:`string`,format:`uri`},$anchor:{type:`string`,pattern:`^[A-Za-z][-A-Za-z0-9.:_]*$`},$ref:{type:`string`,format:`uri-reference`},$recursiveRef:{type:`string`,format:`uri-reference`},$recursiveAnchor:{type:`boolean`,default:!1},$vocabulary:{type:`object`,propertyNames:{type:`string`,format:`uri`},additionalProperties:{type:`boolean`}},$comment:{type:`string`},$defs:{type:`object`,additionalProperties:{$recursiveRef:`#`},default:{}}},ox={$schema:ex,$id:tx,$vocabulary:nx,$recursiveAnchor:!0,title:rx,type:ix,properties:ax}})),cx=r({$id:()=>ux,$recursiveAnchor:()=>!0,$schema:()=>lx,$vocabulary:()=>dx,default:()=>hx,properties:()=>mx,title:()=>fx,type:()=>px}),lx,ux,dx,fx,px,mx,hx,gx=n((()=>{lx=`https://json-schema.org/draft/2019-09/schema`,ux=`https://json-schema.org/draft/2019-09/meta/format`,dx={"https://json-schema.org/draft/2019-09/vocab/format":!0},fx=`Format vocabulary meta-schema`,px=[`object`,`boolean`],mx={format:{type:`string`}},hx={$schema:lx,$id:ux,$vocabulary:dx,$recursiveAnchor:!0,title:fx,type:px,properties:mx}})),_x=r({$id:()=>yx,$recursiveAnchor:()=>!0,$schema:()=>vx,$vocabulary:()=>bx,default:()=>wx,properties:()=>Cx,title:()=>xx,type:()=>Sx}),vx,yx,bx,xx,Sx,Cx,wx,Tx=n((()=>{vx=`https://json-schema.org/draft/2019-09/schema`,yx=`https://json-schema.org/draft/2019-09/meta/meta-data`,bx={"https://json-schema.org/draft/2019-09/vocab/meta-data":!0},xx=`Meta-data vocabulary meta-schema`,Sx=[`object`,`boolean`],Cx={title:{type:`string`},description:{type:`string`},default:!0,deprecated:{type:`boolean`,default:!1},readOnly:{type:`boolean`,default:!1},writeOnly:{type:`boolean`,default:!1},examples:{type:`array`,items:!0}},wx={$schema:vx,$id:yx,$vocabulary:bx,$recursiveAnchor:!0,title:xx,type:Sx,properties:Cx}})),Ex=r({$defs:()=>Nx,$id:()=>Ox,$recursiveAnchor:()=>!0,$schema:()=>Dx,$vocabulary:()=>kx,default:()=>Px,properties:()=>Mx,title:()=>Ax,type:()=>jx}),Dx,Ox,kx,Ax,jx,Mx,Nx,Px,Fx=n((()=>{Dx=`https://json-schema.org/draft/2019-09/schema`,Ox=`https://json-schema.org/draft/2019-09/meta/validation`,kx={"https://json-schema.org/draft/2019-09/vocab/validation":!0},Ax=`Validation vocabulary meta-schema`,jx=[`object`,`boolean`],Mx={multipleOf:{type:`number`,exclusiveMinimum:0},maximum:{type:`number`},exclusiveMaximum:{type:`number`},minimum:{type:`number`},exclusiveMinimum:{type:`number`},maxLength:{$ref:`#/$defs/nonNegativeInteger`},minLength:{$ref:`#/$defs/nonNegativeIntegerDefault0`},pattern:{type:`string`,format:`regex`},maxItems:{$ref:`#/$defs/nonNegativeInteger`},minItems:{$ref:`#/$defs/nonNegativeIntegerDefault0`},uniqueItems:{type:`boolean`,default:!1},maxContains:{$ref:`#/$defs/nonNegativeInteger`},minContains:{$ref:`#/$defs/nonNegativeInteger`,default:1},maxProperties:{$ref:`#/$defs/nonNegativeInteger`},minProperties:{$ref:`#/$defs/nonNegativeIntegerDefault0`},required:{$ref:`#/$defs/stringArray`},dependentRequired:{type:`object`,additionalProperties:{$ref:`#/$defs/stringArray`}},const:!0,enum:{type:`array`,items:!0},type:{anyOf:[{$ref:`#/$defs/simpleTypes`},{type:`array`,items:{$ref:`#/$defs/simpleTypes`},minItems:1,uniqueItems:!0}]}},Nx={nonNegativeInteger:{type:`integer`,minimum:0},nonNegativeIntegerDefault0:{$ref:`#/$defs/nonNegativeInteger`,default:0},simpleTypes:{enum:[`array`,`boolean`,`integer`,`null`,`number`,`object`,`string`]},stringArray:{type:`array`,items:{type:`string`},uniqueItems:!0,default:[]}},Px={$schema:Dx,$id:Ox,$vocabulary:kx,$recursiveAnchor:!0,title:Ax,type:jx,properties:Mx,$defs:Nx}})),Ix=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var n=(Nb(),t(wb).default),r=(Ub(),t(Pb).default),i=(Qb(),t(Wb).default),a=(sx(),t($b).default),o=(gx(),t(cx).default),s=(Tx(),t(_x).default),c=(Fx(),t(Ex).default),l=[`/properties`];function u(e){return[n,r,i,a,t(this,o),s,t(this,c)].forEach(e=>this.addMetaSchema(e,void 0,!1)),this;function t(t,n){return e?t.$dataMetaSchema(n,l):n}}e.default=u})),Lx=i(((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.Ajv2019=void 0;var n=gy(),r=$y(),i=gb(),a=bb(),o=Cb(),s=tb(),c=Ix(),l=`https://json-schema.org/draft/2019-09/schema`,u=class extends n.default{constructor(e={}){super({...e,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),this.addVocabulary(i.default),r.default.forEach(e=>this.addVocabulary(e)),this.addVocabulary(a.default),this.addVocabulary(o.default),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:e,meta:t}=this.opts;t&&(c.default.call(this,e),this.refs[`http://json-schema.org/schema`]=l)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(l)?l:void 0)}};e.Ajv2019=u,t.exports=e=u,t.exports.Ajv2019=u,Object.defineProperty(e,"__esModule",{value:!0}),e.default=u;var d=ey();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return d.KeywordCxt}});var f=X();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return f._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return f.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return f.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return f.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return f.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return f.CodeGen}});var p=ty();Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return p.default}});var m=ny();Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return m.default}})})),Rx=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=yy(),n=My(),r=Yy(),i=gb(),a=bb(),o=Cb(),s=Zy(),c=Qy();e.default=[i.default,t.default,n.default,(0,r.default)(!0),s.default,c.metadataVocabulary,c.contentVocabulary,a.default,o.default]})),zx=r({$comment:()=>qx,$dynamicAnchor:()=>Ux,$id:()=>Vx,$schema:()=>Bx,$vocabulary:()=>Hx,allOf:()=>Gx,default:()=>Yx,properties:()=>Jx,title:()=>Wx,type:()=>Kx}),Bx,Vx,Hx,Ux,Wx,Gx,Kx,qx,Jx,Yx,Xx=n((()=>{Bx=`https://json-schema.org/draft/2020-12/schema`,Vx=`https://json-schema.org/draft/2020-12/schema`,Hx={"https://json-schema.org/draft/2020-12/vocab/core":!0,"https://json-schema.org/draft/2020-12/vocab/applicator":!0,"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0,"https://json-schema.org/draft/2020-12/vocab/validation":!0,"https://json-schema.org/draft/2020-12/vocab/meta-data":!0,"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0,"https://json-schema.org/draft/2020-12/vocab/content":!0},Ux=`meta`,Wx=`Core and Validation specifications meta-schema`,Gx=[{$ref:`meta/core`},{$ref:`meta/applicator`},{$ref:`meta/unevaluated`},{$ref:`meta/validation`},{$ref:`meta/meta-data`},{$ref:`meta/format-annotation`},{$ref:`meta/content`}],Kx=[`object`,`boolean`],qx=`This meta-schema also defines keywords that have appeared in previous drafts in order to prevent incompatible extensions as they remain in common use.`,Jx={definitions:{$comment:`"definitions" has been replaced by "$defs".`,type:`object`,additionalProperties:{$dynamicRef:`#meta`},deprecated:!0,default:{}},dependencies:{$comment:`"dependencies" has been split and replaced by "dependentSchemas" and "dependentRequired" in order to serve their differing semantics.`,type:`object`,additionalProperties:{anyOf:[{$dynamicRef:`#meta`},{$ref:`meta/validation#/$defs/stringArray`}]},deprecated:!0,default:{}},$recursiveAnchor:{$comment:`"$recursiveAnchor" has been replaced by "$dynamicAnchor".`,$ref:`meta/core#/$defs/anchorString`,deprecated:!0},$recursiveRef:{$comment:`"$recursiveRef" has been replaced by "$dynamicRef".`,$ref:`meta/core#/$defs/uriReferenceString`,deprecated:!0}},Yx={$schema:Bx,$id:Vx,$vocabulary:Hx,$dynamicAnchor:Ux,title:Wx,allOf:Gx,type:Kx,$comment:qx,properties:Jx}})),Zx=r({$defs:()=>aS,$dynamicAnchor:()=>tS,$id:()=>$x,$schema:()=>Qx,$vocabulary:()=>eS,default:()=>oS,properties:()=>iS,title:()=>nS,type:()=>rS}),Qx,$x,eS,tS,nS,rS,iS,aS,oS,sS=n((()=>{Qx=`https://json-schema.org/draft/2020-12/schema`,$x=`https://json-schema.org/draft/2020-12/meta/applicator`,eS={"https://json-schema.org/draft/2020-12/vocab/applicator":!0},tS=`meta`,nS=`Applicator vocabulary meta-schema`,rS=[`object`,`boolean`],iS={prefixItems:{$ref:`#/$defs/schemaArray`},items:{$dynamicRef:`#meta`},contains:{$dynamicRef:`#meta`},additionalProperties:{$dynamicRef:`#meta`},properties:{type:`object`,additionalProperties:{$dynamicRef:`#meta`},default:{}},patternProperties:{type:`object`,additionalProperties:{$dynamicRef:`#meta`},propertyNames:{format:`regex`},default:{}},dependentSchemas:{type:`object`,additionalProperties:{$dynamicRef:`#meta`},default:{}},propertyNames:{$dynamicRef:`#meta`},if:{$dynamicRef:`#meta`},then:{$dynamicRef:`#meta`},else:{$dynamicRef:`#meta`},allOf:{$ref:`#/$defs/schemaArray`},anyOf:{$ref:`#/$defs/schemaArray`},oneOf:{$ref:`#/$defs/schemaArray`},not:{$dynamicRef:`#meta`}},aS={schemaArray:{type:`array`,minItems:1,items:{$dynamicRef:`#meta`}}},oS={$schema:Qx,$id:$x,$vocabulary:eS,$dynamicAnchor:tS,title:nS,type:rS,properties:iS,$defs:aS}})),cS=r({$dynamicAnchor:()=>fS,$id:()=>uS,$schema:()=>lS,$vocabulary:()=>dS,default:()=>gS,properties:()=>hS,title:()=>pS,type:()=>mS}),lS,uS,dS,fS,pS,mS,hS,gS,_S=n((()=>{lS=`https://json-schema.org/draft/2020-12/schema`,uS=`https://json-schema.org/draft/2020-12/meta/unevaluated`,dS={"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0},fS=`meta`,pS=`Unevaluated applicator vocabulary meta-schema`,mS=[`object`,`boolean`],hS={unevaluatedItems:{$dynamicRef:`#meta`},unevaluatedProperties:{$dynamicRef:`#meta`}},gS={$schema:lS,$id:uS,$vocabulary:dS,$dynamicAnchor:fS,title:pS,type:mS,properties:hS}})),vS=r({$dynamicAnchor:()=>SS,$id:()=>bS,$schema:()=>yS,$vocabulary:()=>xS,default:()=>ES,properties:()=>TS,title:()=>CS,type:()=>wS}),yS,bS,xS,SS,CS,wS,TS,ES,DS=n((()=>{yS=`https://json-schema.org/draft/2020-12/schema`,bS=`https://json-schema.org/draft/2020-12/meta/content`,xS={"https://json-schema.org/draft/2020-12/vocab/content":!0},SS=`meta`,CS=`Content vocabulary meta-schema`,wS=[`object`,`boolean`],TS={contentEncoding:{type:`string`},contentMediaType:{type:`string`},contentSchema:{$dynamicRef:`#meta`}},ES={$schema:yS,$id:bS,$vocabulary:xS,$dynamicAnchor:SS,title:CS,type:wS,properties:TS}})),OS=r({$defs:()=>IS,$dynamicAnchor:()=>MS,$id:()=>AS,$schema:()=>kS,$vocabulary:()=>jS,default:()=>LS,properties:()=>FS,title:()=>NS,type:()=>PS}),kS,AS,jS,MS,NS,PS,FS,IS,LS,RS=n((()=>{kS=`https://json-schema.org/draft/2020-12/schema`,AS=`https://json-schema.org/draft/2020-12/meta/core`,jS={"https://json-schema.org/draft/2020-12/vocab/core":!0},MS=`meta`,NS=`Core vocabulary meta-schema`,PS=[`object`,`boolean`],FS={$id:{$ref:`#/$defs/uriReferenceString`,$comment:`Non-empty fragments not allowed.`,pattern:`^[^#]*#?$`},$schema:{$ref:`#/$defs/uriString`},$ref:{$ref:`#/$defs/uriReferenceString`},$anchor:{$ref:`#/$defs/anchorString`},$dynamicRef:{$ref:`#/$defs/uriReferenceString`},$dynamicAnchor:{$ref:`#/$defs/anchorString`},$vocabulary:{type:`object`,propertyNames:{$ref:`#/$defs/uriString`},additionalProperties:{type:`boolean`}},$comment:{type:`string`},$defs:{type:`object`,additionalProperties:{$dynamicRef:`#meta`}}},IS={anchorString:{type:`string`,pattern:`^[A-Za-z_][-A-Za-z0-9._]*$`},uriString:{type:`string`,format:`uri`},uriReferenceString:{type:`string`,format:`uri-reference`}},LS={$schema:kS,$id:AS,$vocabulary:jS,$dynamicAnchor:MS,title:NS,type:PS,properties:FS,$defs:IS}})),zS=r({$dynamicAnchor:()=>US,$id:()=>VS,$schema:()=>BS,$vocabulary:()=>HS,default:()=>qS,properties:()=>KS,title:()=>WS,type:()=>GS}),BS,VS,HS,US,WS,GS,KS,qS,JS=n((()=>{BS=`https://json-schema.org/draft/2020-12/schema`,VS=`https://json-schema.org/draft/2020-12/meta/format-annotation`,HS={"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0},US=`meta`,WS=`Format vocabulary meta-schema for annotation results`,GS=[`object`,`boolean`],KS={format:{type:`string`}},qS={$schema:BS,$id:VS,$vocabulary:HS,$dynamicAnchor:US,title:WS,type:GS,properties:KS}})),YS=r({$dynamicAnchor:()=>$S,$id:()=>ZS,$schema:()=>XS,$vocabulary:()=>QS,default:()=>rC,properties:()=>nC,title:()=>eC,type:()=>tC}),XS,ZS,QS,$S,eC,tC,nC,rC,iC=n((()=>{XS=`https://json-schema.org/draft/2020-12/schema`,ZS=`https://json-schema.org/draft/2020-12/meta/meta-data`,QS={"https://json-schema.org/draft/2020-12/vocab/meta-data":!0},$S=`meta`,eC=`Meta-data vocabulary meta-schema`,tC=[`object`,`boolean`],nC={title:{type:`string`},description:{type:`string`},default:!0,deprecated:{type:`boolean`,default:!1},readOnly:{type:`boolean`,default:!1},writeOnly:{type:`boolean`,default:!1},examples:{type:`array`,items:!0}},rC={$schema:XS,$id:ZS,$vocabulary:QS,$dynamicAnchor:$S,title:eC,type:tC,properties:nC}})),aC=r({$defs:()=>pC,$dynamicAnchor:()=>lC,$id:()=>sC,$schema:()=>oC,$vocabulary:()=>cC,default:()=>mC,properties:()=>fC,title:()=>uC,type:()=>dC}),oC,sC,cC,lC,uC,dC,fC,pC,mC,hC=n((()=>{oC=`https://json-schema.org/draft/2020-12/schema`,sC=`https://json-schema.org/draft/2020-12/meta/validation`,cC={"https://json-schema.org/draft/2020-12/vocab/validation":!0},lC=`meta`,uC=`Validation vocabulary meta-schema`,dC=[`object`,`boolean`],fC={type:{anyOf:[{$ref:`#/$defs/simpleTypes`},{type:`array`,items:{$ref:`#/$defs/simpleTypes`},minItems:1,uniqueItems:!0}]},const:!0,enum:{type:`array`,items:!0},multipleOf:{type:`number`,exclusiveMinimum:0},maximum:{type:`number`},exclusiveMaximum:{type:`number`},minimum:{type:`number`},exclusiveMinimum:{type:`number`},maxLength:{$ref:`#/$defs/nonNegativeInteger`},minLength:{$ref:`#/$defs/nonNegativeIntegerDefault0`},pattern:{type:`string`,format:`regex`},maxItems:{$ref:`#/$defs/nonNegativeInteger`},minItems:{$ref:`#/$defs/nonNegativeIntegerDefault0`},uniqueItems:{type:`boolean`,default:!1},maxContains:{$ref:`#/$defs/nonNegativeInteger`},minContains:{$ref:`#/$defs/nonNegativeInteger`,default:1},maxProperties:{$ref:`#/$defs/nonNegativeInteger`},minProperties:{$ref:`#/$defs/nonNegativeIntegerDefault0`},required:{$ref:`#/$defs/stringArray`},dependentRequired:{type:`object`,additionalProperties:{$ref:`#/$defs/stringArray`}}},pC={nonNegativeInteger:{type:`integer`,minimum:0},nonNegativeIntegerDefault0:{$ref:`#/$defs/nonNegativeInteger`,default:0},simpleTypes:{enum:[`array`,`boolean`,`integer`,`null`,`number`,`object`,`string`]},stringArray:{type:`array`,items:{type:`string`},uniqueItems:!0,default:[]}},mC={$schema:oC,$id:sC,$vocabulary:cC,$dynamicAnchor:lC,title:uC,type:dC,properties:fC,$defs:pC}})),gC=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var n=(Xx(),t(zx).default),r=(sS(),t(Zx).default),i=(_S(),t(cS).default),a=(DS(),t(vS).default),o=(RS(),t(OS).default),s=(JS(),t(zS).default),c=(iC(),t(YS).default),l=(hC(),t(aC).default),u=[`/properties`];function d(e){return[n,r,i,a,o,t(this,s),c,t(this,l)].forEach(e=>this.addMetaSchema(e,void 0,!1)),this;function t(t,n){return e?t.$dataMetaSchema(n,u):n}}e.default=d})),_C=i(((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.Ajv2020=void 0;var n=gy(),r=Rx(),i=tb(),a=gC(),o=`https://json-schema.org/draft/2020-12/schema`,s=class extends n.default{constructor(e={}){super({...e,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),r.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(i.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:e,meta:t}=this.opts;t&&(a.default.call(this,e),this.refs[`http://json-schema.org/schema`]=o)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(o)?o:void 0)}};e.Ajv2020=s,t.exports=e=s,t.exports.Ajv2020=s,Object.defineProperty(e,"__esModule",{value:!0}),e.default=s;var c=ey();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return c.KeywordCxt}});var l=X();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return l._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return l.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return l.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return l.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return l.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return l.CodeGen}});var u=ty();Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return u.default}});var d=ny();Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return d.default}})})),vC=i((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}}})),yC=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatLimitDefinition=void 0;var t=db(),n=X(),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)})),bC=i(((e,t)=>{Object.defineProperty(e,"__esModule",{value:!0});var n=vC(),r=yC(),i=X(),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})),xC=db(),SC=Lx(),CC=_C(),wC=e(bC(),1),TC=[`example`,`externalDocs`,`xml`,`markdownDescription`,`enumDescriptions`,`enumNames`,`enumTitles`];function EC(e,t=new Set){if(e&&typeof e==`object`)for(let[n,r]of Object.entries(e))n.startsWith(`x-`)&&t.add(n),EC(r,t);return t}function DC(e,t){let n=new e({strict:!0,strictTypes:!1,strictTuples:!1,strictRequired:!1,allowUnionTypes:!0,allErrors:!0});(0,wC.default)(n);for(let e of[...TC,...EC(t)])n.addKeyword({keyword:e,valid:!0});return n}var OC=new Map;function kC(e){let t=JSON.stringify(e),n=OC.get(t);if(n)return n;let r=typeof e==`object`?e.$schema:void 0,i=DC(typeof r==`string`&&r.includes(`draft-07`)?xC.Ajv:typeof r==`string`&&r.includes(`2019-09`)?SC.Ajv2019:CC.Ajv2020,e);try{let n=i.compile(e);if(`$async`in n)throw Error(`Asynchronous schemas are not supported`);return OC.size>=200&&OC.clear(),OC.set(t,n),n}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`MCP JSON Schema cannot be validated: ${t}. Reconfigure the tool schema (supported dialects: draft-07, 2019-09, 2020-12). No validation was skipped.`)}}function AC(e,t){let n=kC(e);if(!n(t))throw Error(`MCP schema validation failed: `+(n.errors??[]).map(e=>`${e.instancePath||`/`} ${e.keyword}`).join(`; `))}function jC(e,t){if(!t.length||typeof e==`boolean`)return e;let[n,...r]=t,i=e.properties,a=i&&typeof i==`object`&&!Array.isArray(i)?i[n]:void 0;return a!==void 0&&(typeof a==`boolean`||a&&typeof a==`object`&&!Array.isArray(a))?jC(a,r):!0}function MC(e){for(let t of[`inputSchema`,`outputSchema`]){let n=e[t];if(n!==void 0)try{kC(n)}catch(n){throw Error(`MCP tool ${JSON.stringify(e.toolName)} ${t}: ${n instanceof Error?n.message:String(n)}`)}}}var NC=Rv();Y({structuredContent:NC,content:$_(Y({type:J()}).catchall(NC))}).strict();function PC(e){return typeof e==`string`&&/^[A-Za-z_][A-Za-z0-9_-]{0,127}$/.test(e)&&![`__proto__`,`constructor`,`prototype`].includes(e)}var FC=class{nodes=[{variable:1/0,choices:[]},{variable:1/0,choices:[]}];unique=new Map;cache=new Map;outcome(e,t){return this.node(e,Array.from({length:5},(e,n)=>Number(n===t)))}and(e,t){return this.apply(`and`,e,t)}or(e,t){return this.apply(`or`,e,t)}not(e){if(e<2)return 1-e;let t=`not:${e}`,n=this.cache.get(t);if(n!==void 0)return n;let r=this.nodes[e],i=this.node(r.variable,r.choices.map(e=>this.not(e)));return this.cache.set(t,i),i}implies(e,t){return this.and(e,this.not(t))===0}node(e,t){if(t.every(e=>e===t[0]))return t[0];let n=`${e}:${t.join(`,`)}`,r=this.unique.get(n);if(r!==void 0)return r;let i=this.nodes.length;return this.nodes.push({variable:e,choices:t}),this.unique.set(n,i),i}apply(e,t,n){if(t===n)return t;if(e===`and`){if(t===0||n===0)return 0;if(t===1)return n;if(n===1)return t}else{if(t===1||n===1)return 1;if(t===0)return n;if(n===0)return t}let r=`${e}:${Math.min(t,n)}:${Math.max(t,n)}`,i=this.cache.get(r);if(i!==void 0)return i;let a=this.nodes[t],o=this.nodes[n],s=Math.min(a.variable,o.variable),c=this.node(s,Array.from({length:5},(r,i)=>this.apply(e,a.variable===s?a.choices[i]:t,o.variable===s?o.choices[i]:n)));return this.cache.set(r,c),c}};function IC(e){let t=e.steps.map(e=>e.id),n=new Set(t);if(n.size!==t.length)throw Error(`Step IDs must be unique`);if(new Set(e.edges.map(e=>e.id)).size!==e.edges.length)throw Error(`Edge IDs must be unique`);let r=new Map(t.map(e=>[e,[]])),i=new Map(t.map(e=>[e,[]]));for(let t of e.edges){if(!n.has(t.from)||!n.has(t.to))throw Error(`Unknown edge endpoint`);r.get(t.to).push(t),i.get(t.from).push(t)}let a=t.filter(e=>!r.get(e).length),o=new Set(a),s=[...a];for(let e=0;e<s.length;e++)for(let t of i.get(s[e]))o.has(t.to)||(o.add(t.to),s.push(t.to));if(o.size!==n.size)throw Error(`Workflow cycle has no entry from a root`);let c=new Map(t.map(e=>[e,new Set(a.includes(e)?[e]:t)])),l=!0;for(;l;){l=!1;for(let e of s){let t=r.get(e);if(!t.length)continue;let n=new Set([...c.get(t[0].from)].filter(e=>t.every(t=>c.get(t.from).has(e))));n.add(e);let i=c.get(e);(n.size!==i.size||[...n].some(e=>!i.has(e)))&&(c.set(e,n),l=!0)}}let u=e.edges.filter(e=>c.get(e.from).has(e.to)),d=new Set(u.map(e=>e.id)),f=new Map;for(let e of u){let t=f.get(e.to)??new Set([e.to]),n=[e.from];for(;n.length;){let e=n.pop();t.has(e)||(t.add(e),n.push(...r.get(e).map(e=>e.from)))}f.set(e.to,t)}let p=[...f].map(([n,r])=>({headerId:n,memberIds:t.filter(e=>r.has(e)),backEdgeIds:u.filter(e=>e.to===n).map(e=>e.id),entryEdgeIds:e.edges.filter(e=>!r.has(e.from)&&r.has(e.to)).map(e=>e.id),exitEdgeIds:e.edges.filter(e=>r.has(e.from)&&!r.has(e.to)).map(e=>e.id)}));for(let t of p){let n=f.get(t.headerId);if(e.edges.some(e=>!n.has(e.from)&&n.has(e.to)&&e.to!==t.headerId))throw Error(`Workflow loop has multiple entry steps`);let r=[];for(let e of p){if(e===t)continue;let i=f.get(e.headerId),a=t.memberIds.filter(e=>i.has(e)).length;if(a){if(a===n.size&&n.size<i.size)r.push(e);else if(a!==i.size||n.size===i.size)throw Error(`Workflow loops overlap without strict nesting`)}}r.sort((e,t)=>e.memberIds.length-t.memberIds.length),r[0]&&(t.parentHeaderId=r[0].headerId)}let m=[],h=new Set(t);for(;h.size;){let e=[...h].filter(e=>r.get(e).every(e=>d.has(e.id)||!h.has(e.from)));if(!e.length)throw Error(`Workflow contains an irreducible or multiple-entry cycle`);for(let t of e)m.push(t),h.delete(t)}return p.sort((e,n)=>n.memberIds.length-e.memberIds.length||t.indexOf(e.headerId)-t.indexOf(n.headerId)),{loops:p,order:m}}var LC=J().refine(e=>![`__proto__`,`constructor`,`prototype`].includes(e),`Reserved dictionary key`);function RC(e){return Y_().superRefine((e,t)=>{if(e&&typeof e==`object`)for(let n of Object.keys(e))LC.safeParse(n).success||t.addIssue({code:`custom`,message:`Reserved dictionary key`,path:[n]})}).pipe(cv(LC,e))}var zC=Pv(()=>nv([q_(),G_(),V_(),J(),$_(zC),cv(J(),zC)])),BC=Pv(()=>iv(`type`,[Y({type:fv(`null`)}).strict(),Y({type:fv(`json`),schema:nv([G_(),cv(J(),zC)]).optional()}).strict(),Y({type:fv(`string`)}).strict(),Y({type:fv(`number`),integer:G_().optional()}).strict(),Y({type:fv(`boolean`)}).strict(),Y({type:fv(`enum`),values:$_(J()).min(1).refine(e=>new Set(e).size===e.length)}).strict(),Y({type:fv(`array`),items:BC}).strict(),Y({type:fv(`union`),variants:$_(BC).min(2)}).strict(),Y({type:fv(`object`),fields:RC(Y({schema:BC,required:G_().optional(),default:zC.optional()}).strict())}).strict()]));function VC(e){switch(e.type){case`null`:return q_();case`json`:return e.schema!==void 0&&kC(e.schema),zC.superRefine((t,n)=>{try{e.schema!==void 0&&AC(e.schema,t)}catch(e){n.addIssue({code:`custom`,message:e.message})}});case`string`:return J();case`number`:return e.integer?V_().int():V_();case`boolean`:return G_();case`enum`:return uv(e.values);case`array`:return $_(VC(e.items));case`union`:return nv(e.variants.map(VC));case`object`:return Y(Object.fromEntries(Object.entries(e.fields).map(([e,t])=>{let n=VC(t.schema);return t.default===void 0?t.required||(n=n.optional()):n=n.default(HC(t.schema,t.default)),[e,n]}))).strict()}}function HC(e,t){return zC.parse(VC(e).parse(t))}function UC(e){BC.parse(e),VC(e)}function WC(e){switch(e.type){case`json`:return`unknown`;case`enum`:return e.values.map(e=>JSON.stringify(e)).join(` | `);case`array`:return`Array<${WC(e.items)}>`;case`union`:return e.variants.map(WC).join(` | `);case`object`:return`{ ${Object.entries(e.fields).map(([e,t])=>`${JSON.stringify(e)}${t.required||t.default!==void 0?``:`?`}: ${WC(t.schema)}`).join(`; `)} }`;default:return e.type}}var GC={type:`object`,fields:{exitCode:{schema:{type:`number`,integer:!0},required:!0},stdout:{schema:{type:`string`},required:!0},stderr:{schema:{type:`string`},required:!0}}};function KC(e){if(e.kind===`workflow`)return e.contract.outputSchema;if(e.kind===`mcp`)return{type:`object`,fields:{structuredContent:{required:!0,schema:{type:`json`,...e.tool.outputSchema===void 0?{}:{schema:e.tool.outputSchema}}},content:{required:!0,schema:{type:`array`,items:{type:`json`}}}}};if(e.kind===`shell`)return GC;if(e.kind===`branch`)return{type:`boolean`};if(e.kind!==`join`)return e.outputSchema}function qC(e,t){if(!t.length)return{schema:e,optional:!1};if(e.type===`json`)return{schema:{type:`json`,schema:jC(e.schema??!0,t)},optional:!1};if(e.type===`null`)return{schema:{type:`json`},optional:!1};if(e.type===`union`){let n=e.variants.map(e=>qC(e,t));return{schema:XC(n.map(e=>e.schema)),optional:n.some(e=>e.optional)}}let[n,...r]=t;if(e.type===`object`){let t=Object.hasOwn(e.fields,n)?e.fields[n]:void 0;if(!t)throw Error(`Unknown field: ${n}`);let i=qC(t.schema,r);return{schema:i.schema,optional:i.optional||!t.required&&t.default===void 0}}if(e.type===`array`&&/^(0|[1-9]\d*)$/.test(n))return{schema:qC(e.items,r).schema,optional:!0};throw Error(`Invalid field path: ${n}`)}function JC(e,t){return t.type===`json`||e.type===`json`?!0:e.type===`union`?e.variants.every(e=>JC(e,t)):t.type===`union`?t.variants.some(t=>JC(e,t)):e.type===`enum`?t.type===`string`||t.type===`enum`&&e.values.every(e=>t.values.includes(e)):e.type===t.type?e.type===`number`&&t.type===`number`?!t.integer||!!e.integer:e.type===`array`&&t.type===`array`?JC(e.items,t.items):e.type===`object`&&t.type===`object`?Object.keys(e.fields).every(e=>Object.hasOwn(t.fields,e))&&Object.entries(t.fields).every(([t,n])=>{let r=Object.hasOwn(e.fields,t)?e.fields[t]:void 0,i=n.required&&n.default===void 0;return r?(!i||r.required||r.default!==void 0)&&JC(r.schema,n.schema):!i}):!0:!1}function YC(e){return e.type===`object`?{type:`object`,fields:Object.fromEntries(Object.entries(e.fields).map(([e,t])=>[e,{schema:YC(t.schema)}]))}:e.type===`array`?{type:`array`,items:YC(e.items)}:e.type===`union`?XC(e.variants.map(YC)):e}function XC(e){let t=[...new Map(e.map(e=>[JSON.stringify(e),e])).values()];return t.length===1?t[0]:{type:`union`,variants:t}}var ZC=iv(`source`,[Y({source:fv(`input`),path:$_(J())}).strict(),Y({source:fv(`step`),stepId:J(),path:$_(J())}).strict()]),QC=Pv(()=>iv(`kind`,[Y({kind:fv(`literal`),value:Rv()}).strict(),Y({kind:fv(`reference`),reference:ZC}).strict(),Y({kind:fv(`object`),fields:RC(QC)}).strict(),Y({kind:fv(`array`),items:$_(QC)}).strict()])),$C=nv([G_(),cv(J(),Rv())]),ew=iv(`kind`,[Y({kind:fv(`template`),template:QC}).strict(),Y({kind:fv(`reference`),reference:ZC}).strict(),Y({kind:fv(`object`),fields:RC(ZC)}).strict()]),tw={id:LC.min(1),name:LC.min(1),inputSchema:BC.optional(),mapping:ew.optional(),repeatMapping:ew.optional(),permission:uv([`ask`,`auto-accept`]).optional(),timeoutMs:V_().int().positive().max(2147483647).optional(),secrets:RC(J().refine(PC,`Invalid secret reference`)).optional(),position:Y({x:V_(),y:V_()}).strict().optional()},nw=iv(`operator`,[Y({operator:fv(`truthy`),path:$_(J())}).strict(),Y({operator:uv([`equals`,`not-equals`]),path:$_(J()),value:Rv()}).strict(),Y({operator:uv([`greater-than`,`less-than`]),path:$_(J()),value:V_()}).strict()]),rw=Y({version:fv(1),id:J().regex(/^[a-zA-Z0-9_-]{1,128}$/),name:J().min(1),backend:J().min(1),projectId:J().optional(),permission:uv([`ask`,`auto-accept`]).optional(),inputSchema:BC.refine(e=>e.type===`object`),steps:$_(iv(`kind`,[Y({...tw,kind:fv(`agent`),instructions:J(),model:J().min(1),effort:uv([`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`]),outputSchema:BC}).strict(),Y({...tw,kind:fv(`shell`),command:J(),acceptedExitCodes:$_(V_().int()).min(1).optional()}).strict(),Y({...tw,kind:fv(`typescript`),code:J(),outputSchema:BC}).strict(),Y({...tw,kind:fv(`branch`),condition:nw}).strict(),Y({...tw,kind:fv(`join`)}).strict(),Y({...tw,kind:fv(`workflow`),workflowId:J().regex(/^[a-zA-Z0-9_-]{1,128}$/),contract:Y({inputSchema:BC.refine(e=>e.type===`object`),outputSchema:BC}).strict()}).strict(),Y({...tw,kind:fv(`mcp`),tool:Y({connectionId:J().min(1),connectionName:J(),identity:J().regex(/^[a-f0-9]{64}$/),serverIdentity:J().regex(/^[a-f0-9]{64}$/),toolName:J().min(1),inputSchema:$C,outputSchema:$C.optional()}).strict()}).strict()])).min(1),loopSettings:RC(Y({maxTries:V_().int().min(1).max(100)}).strict()).optional(),edges:$_(Y({id:J().min(1),from:J(),to:J(),outcome:uv([`success`,`failure`,`timeout`,`true`,`false`])}).strict())}).strict();function iw(e){return ow(e)}function aw(e){return ow(e,!0)}function ow(e,t=!1){let n=rw.parse(e),r=n.steps.find(e=>e.kind===`agent`&&Oo(e.instructions));if(r&&!n.projectId)throw Error(`Workflow Step ${JSON.stringify(r.name)} invokes a Skill and requires a Project binding`);UC(n.inputSchema);let i=new Map(n.steps.map(e=>[e.id,e]));if(i.size!==n.steps.length||new Set(n.steps.map(e=>e.name)).size!==i.size)throw Error(`Step IDs and names must be unique`);if(new Set(n.edges.map(e=>e.id)).size!==n.edges.length)throw Error(`Edge IDs must be unique`);let a=new Map(n.steps.map(e=>[e.id,[]])),o=new Map(n.steps.map(e=>[e.id,[]])),s=new Set;for(let e of n.edges){let t=i.get(e.from);if(!t||!i.has(e.to))throw Error(`Unknown edge endpoint`);let n=JSON.stringify([e.from,e.to,e.outcome]);if(s.has(n))throw Error(`Duplicate connection`);if(s.add(n),t.kind===`branch`?![`true`,`false`,`failure`,`timeout`].includes(e.outcome):[`true`,`false`].includes(e.outcome))throw Error(`Invalid edge outcome`);a.get(e.to).push(e),o.get(e.from).push(e)}let c=IC(n),l=c.loops.map(e=>({...e,maxTries:n.loopSettings?.[e.headerId]?.maxTries??3})),u=new Map(l.map(e=>[e.headerId,e]));for(let e of Object.keys(n.loopSettings??{}))if(!u.has(e))throw Error(`Loop settings require a loop header`);for(let e of i.values())if(e.repeatMapping&&!u.has(e.id))throw Error(`Repeat mapping requires a loop header`);let d=new Set(l.flatMap(e=>e.backEdgeIds)),f=new Map([...a].map(([e,t])=>[e,t.filter(e=>!d.has(e.id))])),p=c.order.map(e=>i.get(e)),m=new FC,h=new Map,g=new Map,_=new Map,v=new Map,y=e=>e.reduce((e,t)=>m.or(e,t),0),b=new Map,x=new Map,S=new Map,C=new Map,w=new Map,T=new Map,E={definition:n,order:p,incoming:a,outgoing:o,forwardIncoming:f,loops:l,outputSchemas:x,inputSchemas:S,firstInputSchemas:C,repeatInputSchemas:w};for(let e of p){let t=f.get(e.id),n=y(t.map(e=>v.get(e.id))),r=m.and(t.length?y(t.map(e=>_.get(e.id))):1,m.not(n)),i=m.or(y(t.map(e=>m.and(_.get(e.id),e.outcome===`failure`||e.outcome===`timeout`?1:g.get(e.from)))),u.has(e.id)?m.and(r,m.outcome(p.length+p.indexOf(e),1)):0);T.set(e.id,r),g.set(e.id,i);let a=p.indexOf(e),s=m.outcome(a,1),c=m.outcome(a,2),l=m.not(m.or(s,c));h.set(e.id,m.and(r,l));let d={success:l,failure:s,timeout:c,true:y([m.outcome(a,0),m.outcome(a,3)]),false:m.outcome(a,4)},x=o.get(e.id),S=m.or(m.and(s,x.some(e=>e.outcome===`failure`)?i:1),m.and(c,x.some(e=>e.outcome===`timeout`)?i:1));for(let e of x){let t=e.outcome===`failure`||e.outcome===`timeout`;_.set(e.id,m.and(r,m.and(d[e.outcome],t?m.not(i):1))),v.set(e.id,m.or(n,t?0:m.and(r,S)))}b.set(e.id,new Set(t.flatMap(e=>[e.from,...b.get(e.from)])))}for(let e of l){let t=y(e.backEdgeIds.map(e=>_.get(e))),n=e.memberIds.map(e=>{let t=y(o.get(e).map(e=>_.get(e.id)));return m.and(h.get(e),m.not(t))}),r=y([...e.exitEdgeIds.map(e=>_.get(e)),...n]);if(m.and(t,r)!==0)throw Error(`Loop ${e.headerId} can select exit and repeat together`)}let D=new Set,O=e=>{let t=x.get(e);if(t)return t;let n=i.get(e),r=KC(n)??n.inputSchema??A(e);return UC(r),x.set(e,r),r},k=(e,r)=>{let o=u.get(e.id),s=r?a.get(e.id).filter(e=>o.backEdgeIds.includes(e.id)):f.get(e.id),c=r?y(s.map(e=>_.get(e.id))):T.get(e.id),l=r?new Set(s.flatMap(e=>[e.from,...b.get(e.from)])):b.get(e.id),d=r?e.repeatMapping:e.mapping,p=e=>{if(e.source===`input`)return qC(n.inputSchema,e.path);let t=i.get(e.stepId);if(!t||!l.has(e.stepId))throw Error(`Mapping must reference an earlier step`);if(!m.implies(c,h.get(t.id)))throw Error(`Output is not guaranteed: ${t.name}`);return qC(O(t.id),e.path)};if(e.kind===`join`&&d)throw Error(`Joins collect selected incoming outputs without mappings`);let g;if(d?.kind===`template`){let n=e=>{e.kind===`reference`&&p(e.reference),e.kind===`object`&&Object.values(e.fields).forEach(n),e.kind===`array`&&e.items.forEach(n)};n(d.template);let r=e=>{if(e.kind===`reference`)return p(e.reference).schema;if(e.kind===`object`)return{type:`object`,fields:Object.fromEntries(Object.entries(e.fields).map(([e,t])=>[e,{schema:r(t),required:!0}]))};if(e.kind===`array`)return{type:`array`,items:e.items.length?XC(e.items.map(r)):{type:`json`}};let t=e=>e===null?{type:`null`}:typeof e==`string`?{type:`enum`,values:[e]}:typeof e==`number`?{type:`number`,integer:Number.isInteger(e)}:typeof e==`boolean`?{type:`boolean`}:Array.isArray(e)?{type:`array`,items:e.length?XC(e.map(t)):{type:`json`}}:{type:`object`,fields:Object.fromEntries(Object.entries(e).map(([e,n])=>[e,{schema:t(n),required:!0}]))};return t(e.value)};g=e.kind===`workflow`?r(d.template):{type:`json`},e.kind===`workflow`&&!t&&d.template.kind===`literal`&&HC(e.contract.inputSchema,d.template.value)}else if(d?.kind===`reference`){let e=p(d.reference);if(e.optional)throw Error(`A direct input reference must be required or have a default`);g=e.schema}else if(d?.kind===`object`)g={type:`object`,fields:Object.fromEntries(Object.entries(d.fields).map(([e,t])=>{let n=p(t);return[e,{schema:n.schema,required:!n.optional}]}))};else if(!s.length)g=n.inputSchema;else{let t=[...new Set(s.map(e=>e.from))],n=Object.fromEntries(t.map(e=>{let t=i.get(e),n=s.filter(t=>t.from===e),r=XC(n.map(t=>t.outcome===`failure`||t.outcome===`timeout`?sw(i.get(e).inputSchema??A(e),O(e)):O(e)));return[t.name,{schema:r,required:m.implies(c,y(n.map(e=>_.get(e.id))))}]})),r={type:`object`,fields:n},a=Object.values(n).filter(e=>e.required).length;g=e.kind===`join`||a>1?r:XC([...Object.values(n).map(e=>e.schema),...t.length>1?[r]:[]])}if(e.inputSchema&&(UC(e.inputSchema),!(t&&e.kind===`workflow`)&&!JC(g,e.inputSchema)))throw Error(`Input does not match the declared input schema`);if(e.kind===`workflow`){if(UC(e.contract.inputSchema),UC(e.contract.outputSchema),!t&&(!JC(g,e.contract.inputSchema)||e.inputSchema&&!JC(e.inputSchema,e.contract.inputSchema)))throw Error(`Input does not match the Workflow call input contract`);return e.contract.inputSchema}return e.inputSchema??g},A=e=>{let t=S.get(e);if(t)return t;if(D.has(e))throw Error(`Cyclic input schema at ${e}; declare a loop header inputSchema`);D.add(e);let n=i.get(e),r=k(n,!1);C.set(e,r);let a=r;if(u.has(e)){let t=k(n,!0);w.set(e,t),a=XC([r,t])}return S.set(e,a),D.delete(e),a};for(let e of p){e.kind===`mcp`&&MC(e.tool);let t=A(e.id);if(e.kind===`branch`){let n=qC(e.inputSchema??t,e.condition.path),r=e.condition.operator===`truthy`?`boolean`:[`greater-than`,`less-than`].includes(e.condition.operator)?`number`:void 0;if(r&&(n.optional||!JC(n.schema,{type:r})))throw Error(`Branch condition requires a required ${r}`)}O(e.id)}let j=p.map(e=>m.and(h.get(e.id),m.not(y(o.get(e.id).map(e=>_.get(e.id)))))),M=1;for(let e of p){let t=y(o.get(e.id).filter(e=>e.outcome===`failure`||e.outcome===`timeout`).map(e=>_.get(e.id)));M=m.and(M,m.or(m.not(T.get(e.id)),m.or(h.get(e.id),t))),l.length&&(M=m.and(M,m.not(y(o.get(e.id).filter(e=>d.has(e.id)).map(e=>_.get(e.id))))))}let N=p.map((e,t)=>({step:e,condition:j[t]})).filter(({condition:e})=>m.and(M,e)!==0),P=[],F=1,I=0,L=0;for(let{condition:e}of N)L=m.or(L,m.and(I,e)),I=m.or(m.and(I,m.not(e)),m.and(F,e)),F=m.and(F,m.not(e));if(l.length||n.edges.some(e=>e.outcome===`failure`||e.outcome===`timeout`)){let e=p.filter(e=>e.kind===`branch`?[`true`,`false`].some(t=>!o.get(e.id).some(e=>e.outcome===t)):!o.get(e.id).some(e=>e.outcome===`success`));P.push(...e.map(e=>O(e.id))),e.length>1&&P.push({type:`object`,fields:Object.fromEntries(e.map(e=>[e.name,{schema:O(e.id)}]))})}else{for(let{step:e,condition:t}of N)m.and(M,m.and(I,t))!==0&&P.push(O(e.id));let e=m.and(M,L);e!==0&&P.push({type:`object`,fields:Object.fromEntries(N.filter(({condition:t})=>m.and(e,t)!==0).map(({step:t,condition:n})=>[t.name,{schema:O(t.id),required:m.implies(e,n)}]))}),m.and(M,F)!==0&&P.push({type:`object`,fields:{}})}return{...E,resultSchema:P.length?XC(P):{type:`json`}}}function sw(e,t){return{type:`object`,fields:{input:{schema:e,required:!0},error:{required:!0,schema:{type:`object`,fields:{message:{schema:{type:`string`},required:!0},kind:{schema:{type:`enum`,values:[`failure`,`timeout`,`interrupted`]},required:!0}}}},partialOutput:{schema:YC(t)}}}}function cw(e,t){let n=1;for(;e.steps.some(e=>e.name===`${t}_${n}`);)n++;return`${t}_${n}`}function lw(e){return e&&typeof e==`object`&&`issues`in e&&Array.isArray(e.issues)?e.issues.map(e=>`${e.path?.map(String).join(`.`)||`Workflow`}: ${e.message}`).join(`; `):e instanceof Error?e.message:String(e)}function uw(e,t=[]){return[t,...e.type===`json`&&typeof e.schema==`object`&&e.schema.properties&&typeof e.schema.properties==`object`&&!Array.isArray(e.schema.properties)?Object.entries(e.schema.properties).flatMap(([e,n])=>uw({type:`json`,schema:n},[...t,e])):[],...e.type===`object`?Object.entries(e.fields).flatMap(([e,n])=>uw(n.schema,[...t,e])):[]]}function dw(e,t,n=`reference`,r=`mapping`){if(!e.steps.find(e=>e.id===t))return[];let i={...e,steps:e.steps.map(e=>{if(e.id!==t)return e;let n={...e};return delete n[r],delete n.inputSchema,n})},a;try{a=aw(i)}catch{let t=new Set(IC(e).loops.map(e=>e.headerId));i={...e,loopSettings:{},steps:e.steps.map(e=>{let n={...e};return delete n.inputSchema,n.mapping={kind:`reference`,reference:{source:`input`,path:[]}},t.has(e.id)?n.repeatMapping=n.mapping:delete n.repeatMapping,n.kind===`branch`&&(n.condition={operator:`equals`,path:[],value:null}),n.kind===`agent`&&!n.model&&(n.model=`unselected`),n.kind===`join`&&(delete n.mapping,delete n.repeatMapping),n})},a=aw(i)}let o=uw(e.inputSchema).map(e=>({label:`Workflow input${e.length?`.`+e.join(`.`):``}`,reference:{source:`input`,path:e}})),s=o.splice(0);for(let n of e.steps){if(n.id===t&&r===`mapping`)continue;let e=a.outputSchemas.get(n.id);if(e)for(let t of uw(e)){let e={source:`step`,stepId:n.id,path:t};s.push({label:`${n.name}${t.length?`.`+t.join(`.`):``}`,reference:e})}}for(let e of s){let{reference:a}=e;try{aw({...i,steps:i.steps.map(e=>e.id===t?{...e,[r]:n===`object`?{kind:`object`,fields:{value:a}}:{kind:`reference`,reference:a}}:e)}),o.push(e)}catch{}}return o}function fw(e,t,n){let r=e.steps.find(e=>e.id===t),i=iw(e),a=r?.kind===`mcp`?{type:`json`,schema:r.tool.inputSchema}:i.inputSchemas.get(t);if(!a)throw Error(`Select a step`);return HC(a,n)}function pw(e,t,n){if(n)return`The workflow slot is occupied`;if(e.backend!==t)return`Requires Backend Adapter ${e.backend}`;try{iw(e)}catch(e){return lw(e)}}function mw(e,t,n){if(!t||[`__proto__`,`constructor`,`prototype`].includes(t))throw Error(`Invalid field name`);return{...e,mapping:{kind:`object`,fields:{...e.mapping?.kind===`object`?e.mapping.fields:{},[t]:n}}}}var hw=e=>typeof e==`boolean`||typeof e==`object`&&e&&!Array.isArray(e)?e:!0;function gw(e,t,n=new Set){if(typeof e==`boolean`)return{};let r={...e};if(typeof e.$ref==`string`&&e.$ref.startsWith(`#/`)&&!n.has(e.$ref)){n.add(e.$ref);let i=t;for(let t of e.$ref.slice(2).split(`/`).map(e=>e.replace(/~1/g,`/`).replace(/~0/g,`~`)))i=i&&typeof i==`object`&&!Array.isArray(i)?i[t]??!0:!0;r={...gw(hw(i),t,n),...r}}for(let i of Array.isArray(e.allOf)?e.allOf:[]){let e=gw(hw(i),t,new Set(n));r={...e,...r,properties:{..._w(e),..._w(r)},required:[...new Set([...Array.isArray(e.required)?e.required:[],...Array.isArray(r.required)?r.required:[]])]}}return r}function _w(e){return e.properties&&typeof e.properties==`object`&&!Array.isArray(e.properties)?e.properties:{}}function vw(e){if(e.kind===`reference`)return;if(e.kind===`literal`)return e.value;if(e.kind===`array`){let t=e.items.map(vw);return t.some(e=>e===void 0)?void 0:t}let t=Object.entries(e.fields).map(([e,t])=>[e,vw(t)]);return t.some(([,e])=>e===void 0)?void 0:Object.fromEntries(t)}function yw(e){return Array.isArray(e)?{kind:`array`,items:e.map(yw)}:e&&typeof e==`object`?{kind:`object`,fields:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,yw(t)]))}:{kind:`literal`,value:e}}function bw(e,t=e){let n=gw(e,t);return n.default!==void 0||n.const!==void 0?yw(n.default??n.const??null):Array.isArray(n.enum)&&n.enum.length?yw(n.enum[0]):n.type===`object`||n.properties?{kind:`object`,fields:{}}:n.type===`array`?{kind:`array`,items:[]}:{kind:`literal`,value:n.type===`null`?null:n.type===`boolean`?!1:n.type===`number`||n.type===`integer`?0:``}}function xw(e,t,n){let r=[],i=n&&typeof n==`object`&&!Array.isArray(n)?n:{};if(e.if!==void 0&&n!==void 0){let i=!1;try{let r=hw(e.if);AC(typeof r==`boolean`?r:{...typeof t==`object`&&t.$defs?{$defs:t.$defs}:{},...typeof t==`object`&&t.definitions?{definitions:t.definitions}:{},...r},n),i=!0}catch{}r.push(hw(i?e.then:e.else))}for(let t of[`dependentSchemas`,`dependencies`]){let n=e[t];if(n&&typeof n==`object`&&!Array.isArray(n))for(let[e,t]of Object.entries(n))Object.hasOwn(i,e)&&!Array.isArray(t)&&r.push(hw(t))}return r.reduce((e,n)=>{let r=gw(n,t);return{...e,...r,properties:{..._w(e),..._w(r)},required:[...new Set([...Array.isArray(e.required)?e.required:[],...Array.isArray(r.required)?r.required:[]])]}},e)}function Sw(e,t){return hw(Array.isArray(e.prefixItems)?e.prefixItems[t]??e.items:Array.isArray(e.items)?e.items[t]??e.additionalItems:e.items)}function Cw({schema:e,root:t=e,template:n,onChange:r,choices:i=[],label:a=`Arguments`,depth:o=0}){let[s,c]=(0,H.useState)(``),[l,u]=(0,H.useState)(0),d=xw(gw(e,t),t,vw(n)),f=Array.isArray(d.oneOf)?d.oneOf:Array.isArray(d.anyOf)?d.anyOf:Array.isArray(d.type)?d.type.map(e=>({type:e})):[],p=f.length?gw(hw(f[l]),t):{},m={...d,...p,properties:{..._w(d),..._w(p)}},h=_w(m),g=vw(n),_=n.kind===`object`?`object`:n.kind===`array`?`array`:g===null?`null`:typeof g,v=(e,n,r,a)=>(0,U.jsx)(Cw,{schema:e,root:t,template:n,onChange:r,choices:i,label:a,depth:o+1});return(0,U.jsxs)(`fieldset`,{className:`grid min-w-0 gap-3 rounded-lg border p-3`,children:[(0,U.jsx)(`legend`,{className:`px-1 text-sm font-medium`,children:a}),typeof m.description==`string`&&(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:m.description}),i.length>0&&(0,U.jsxs)(Rt,{value:n.kind===`reference`?JSON.stringify(n.reference):`literal`,onValueChange:n=>{if(n===`literal`)r(bw(e,t));else{let e=i.find(e=>JSON.stringify(e.reference)===n);e&&r({kind:`reference`,reference:e.reference})}},children:[(0,U.jsx)(jt,{"aria-label":`${a} source`,children:(0,U.jsx)(It,{children:n.kind===`reference`?i.find(e=>JSON.stringify(e.reference)===JSON.stringify(n.reference))?.label??`Unavailable reference`:`Literal value`})}),(0,U.jsxs)(At,{children:[(0,U.jsx)(Ct,{value:`literal`,children:`Literal value`}),i.map(e=>(0,U.jsx)(Ct,{value:JSON.stringify(e.reference),children:e.label},e.label))]})]}),n.kind!==`reference`&&(0,U.jsxs)(U.Fragment,{children:[f.length>0&&(0,U.jsxs)(Rt,{value:l,onValueChange:e=>{e!==null&&(u(e),r(bw(hw(f[e]),t)))},children:[(0,U.jsx)(jt,{"aria-label":`${a} variant`,children:(0,U.jsxs)(It,{children:[`Variant `,l+1]})}),(0,U.jsx)(At,{children:f.map((e,t)=>(0,U.jsxs)(Ct,{value:t,children:[`Variant `,t+1]},t))})]}),(0,U.jsxs)(Rt,{value:_,onValueChange:e=>{e&&r(bw({type:e}))},children:[(0,U.jsx)(jt,{"aria-label":`${a} JSON type`,children:(0,U.jsx)(It,{children:_})}),(0,U.jsx)(At,{children:[`object`,`array`,`string`,`number`,`boolean`,`null`].map(e=>(0,U.jsx)(Ct,{value:e,children:e},e))})]}),Array.isArray(m.enum)&&(0,U.jsxs)(Rt,{value:JSON.stringify(g),onValueChange:e=>{e&&r(yw(JSON.parse(e)))},children:[(0,U.jsx)(jt,{"aria-label":`${a} enum`,children:(0,U.jsx)(It,{children:JSON.stringify(g)})}),(0,U.jsx)(At,{children:m.enum.map((e,t)=>(0,U.jsx)(Ct,{value:JSON.stringify(e),children:JSON.stringify(e)},t))})]}),n.kind===`object`&&(0,U.jsxs)(U.Fragment,{children:[[...new Set([...Object.keys(h),...Object.keys(n.fields)])].map(e=>{let i=Object.hasOwn(n.fields,e)?n.fields[e]:void 0,o=m.patternProperties&&typeof m.patternProperties==`object`&&!Array.isArray(m.patternProperties)?Object.entries(m.patternProperties).filter(([t])=>{try{return new RegExp(t).test(e)}catch{return!1}}).map(([,e])=>e):[],s=hw(Object.hasOwn(h,e)?h[e]:o.length?{allOf:o}:m.additionalProperties);return(0,U.jsxs)(`div`,{className:`grid gap-2`,children:[(0,U.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,U.jsx)(dt,{"aria-label":`Include ${a}.${e}`,checked:!!i,onCheckedChange:i=>{let a={...n.fields};i?a[e]=bw(s,t):delete a[e],r({kind:`object`,fields:a})}}),e,Array.isArray(m.required)&&m.required.includes(e)?` *`:``]}),i&&v(s,i,t=>r({kind:`object`,fields:{...n.fields,[e]:t}}),`${a}.${e}`)]},e)}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(he,{"aria-label":`${a} new property`,placeholder:`Additional property name`,value:s,onChange:e=>c(e.target.value)}),(0,U.jsx)(O,{variant:`outline`,size:`sm`,disabled:!s||[`__proto__`,`constructor`,`prototype`].includes(s),onClick:()=>{r({kind:`object`,fields:{...n.fields,[s]:bw(hw(m.additionalProperties),t)}}),c(``)},children:`Add property`})]})]}),n.kind===`array`&&(0,U.jsxs)(U.Fragment,{children:[n.items.map((e,t)=>(0,U.jsxs)(`div`,{className:`grid gap-2`,children:[v(Sw(m,t),e,e=>r({kind:`array`,items:n.items.map((n,r)=>r===t?e:n)}),`${a}[${t}]`),(0,U.jsx)(O,{size:`sm`,variant:`outline`,onClick:()=>r({kind:`array`,items:n.items.filter((e,n)=>n!==t)}),children:`Remove item`})]},t)),(0,U.jsx)(O,{size:`sm`,variant:`outline`,onClick:()=>{let e=n.items.length;r({kind:`array`,items:[...n.items,bw(Sw(m,e),t)]})},children:`Add item`})]}),n.kind===`literal`&&_===`boolean`&&(0,U.jsx)(dt,{"aria-label":a,checked:g===!0,onCheckedChange:e=>r({kind:`literal`,value:e})}),n.kind===`literal`&&(_===`string`||_===`number`)&&(0,U.jsx)(he,{"aria-label":a,type:_===`number`?`number`:`text`,value:g,onChange:e=>r({kind:`literal`,value:_===`number`?Number(e.target.value):e.target.value})})]}),(0,U.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,U.jsx)(`summary`,{children:`Original schema and constraints`}),(0,U.jsx)(`pre`,{className:`overflow-auto whitespace-pre-wrap`,children:JSON.stringify(e,null,2)})]})]})}function ww({schema:e,value:t,onChange:n,label:r}){return(0,U.jsx)(Cw,{schema:e,template:yw(t),label:r,onChange:e=>{let t=vw(e);t!==void 0&&n(t)}})}function Tw(e){return e===`object`?{type:e,fields:{}}:e===`array`?{type:e,items:{type:`string`}}:e===`enum`?{type:e,values:[`value`]}:e===`union`?{type:e,variants:[{type:`string`}]}:{type:e}}function Ew(e){switch(e.type){case`json`:return{};case`null`:return null;case`object`:return Object.fromEntries(Object.entries(e.fields).filter(([,e])=>e.required||e.default!==void 0).map(([e,t])=>[e,t.default??Ew(t.schema)]));case`array`:return[];case`number`:return 0;case`boolean`:return!1;case`enum`:return e.values[0]??``;case`union`:return Ew(e.variants[0]);default:return``}}function Dw({schema:e,value:t,onChange:n,onClear:r,label:i=`Value`}){let[a,o]=(0,H.useState)(0);if(e.type===`json`)return(0,U.jsx)(ww,{schema:e.schema??!0,value:t??null,label:i,onChange:n});if(e.type===`null`)return(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`null`});if(e.type===`object`){let r=t&&typeof t==`object`&&!Array.isArray(t)?t:{};return(0,U.jsx)(`div`,{className:`grid gap-3`,children:Object.entries(e.fields).map(([e,t])=>(0,U.jsxs)(`div`,{className:`grid gap-2`,children:[(0,U.jsxs)(`span`,{className:`text-sm font-medium`,children:[e,t.required?` *`:``]}),!t.required&&(0,U.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,U.jsx)(dt,{"aria-label":`Include ${e}`,checked:Object.hasOwn(r,e),onCheckedChange:i=>{let a={...r};i?a[e]=t.default??Ew(t.schema):delete a[e],n(a)}}),`Include`]}),(0,U.jsx)(Dw,{schema:t.schema,label:i===`Value`?e:`${i}.${e}`,value:r[e]??t.default,onClear:()=>{let t={...r};delete t[e],n(t)},onChange:t=>n({...r,[e]:t})})]},e))})}return e.type===`array`?(0,U.jsxs)(`div`,{className:`grid gap-2`,children:[(Array.isArray(t)?t:[]).map((r,a)=>(0,U.jsxs)(`div`,{className:`grid gap-2 rounded-lg border p-3`,children:[(0,U.jsx)(Dw,{schema:e.items,label:`${i} item ${a+1}`,value:r,onChange:e=>n(t.map((t,n)=>n===a?e:t))}),(0,U.jsx)(O,{size:`sm`,variant:`destructive`,className:`justify-self-start`,onClick:()=>n(t.filter((e,t)=>t!==a)),children:`Remove item`})]},a)),(0,U.jsx)(O,{size:`sm`,variant:`outline`,className:`justify-self-start`,onClick:()=>n([...Array.isArray(t)?t:[],Ew(e.items)]),children:`Add item`})]}):e.type===`union`?(0,U.jsxs)(`div`,{className:`grid gap-2`,children:[(0,U.jsxs)(Rt,{value:a,onValueChange:t=>{t!==null&&(o(t),n(Ew(e.variants[t])))},children:[(0,U.jsx)(jt,{className:`w-full`,"aria-label":i===`Value`?`Input variant`:`${i} variant`,children:(0,U.jsx)(It,{children:`Variant ${a+1}: ${e.variants[a]?.type??``}`})}),(0,U.jsx)(At,{children:e.variants.map((e,t)=>(0,U.jsxs)(Ct,{value:t,children:[`Variant `,t+1,`: `,e.type]},t))})]}),(0,U.jsx)(Dw,{schema:e.variants[a]??e.variants[0],label:i,value:t,onChange:n})]}):e.type===`boolean`?(0,U.jsx)(dt,{"aria-label":i,checked:t===!0,onCheckedChange:n}):e.type===`enum`?(0,U.jsxs)(Rt,{value:typeof t==`string`?t:``,onValueChange:e=>{e!==null&&n(e)},children:[(0,U.jsx)(jt,{className:`w-full`,"aria-label":i,children:(0,U.jsx)(It,{children:typeof t==`string`&&t?t:`Select`})}),(0,U.jsxs)(At,{children:[!e.values.includes(``)&&(0,U.jsx)(Ct,{value:``,children:`Select`}),e.values.map(e=>(0,U.jsx)(Ct,{value:e,children:e||`Empty string`},e))]})]}):(0,U.jsx)(he,{"aria-label":i,type:e.type===`number`?`number`:`text`,value:typeof t==`string`||typeof t==`number`?t:``,onChange:t=>e.type===`number`&&t.target.value===``&&r?r():n(e.type===`number`?t.target.value===``?null:Number(t.target.value):t.target.value)})}function Ow({schema:e,onChange:t,root:n=!1}){return(0,U.jsxs)(`fieldset`,{className:`grid min-w-0 gap-3 rounded-lg border p-3`,children:[(0,U.jsx)(`legend`,{className:`px-1 text-sm font-medium`,children:`Schema`}),!n&&(0,U.jsxs)(Rt,{value:e.type,onValueChange:e=>{e!==null&&t(Tw(e))},children:[(0,U.jsx)(jt,{className:`w-full`,"aria-label":`Schema type`,children:(0,U.jsx)(It,{children:e.type})}),(0,U.jsx)(At,{children:[`object`,`array`,`string`,`number`,`boolean`,`enum`,`json`,`null`].map(e=>(0,U.jsx)(Ct,{value:e,children:e},e))})]}),e.type===`enum`&&(0,U.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,U.jsx)(`span`,{className:`font-medium`,children:`Values (one per line)`}),(0,U.jsx)(Fo,{value:e.values.join(`
|
|
138
|
+
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})),Jy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),n=Z();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)}}})),Yy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=ry(),n=X(),r=Xv(),i=Z();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)}}}})),Xy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=ly(),n=ry(),r=Z(),i=Yy();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)}}}})),Zy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=ry(),n=X(),r=Z(),i=Z();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())})})}}}})),Qy=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Z();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`}}})),$y=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default={keyword:`anyOf`,schemaType:`array`,trackErrors:!0,code:ry().validateUnion,error:{message:`must match a schema in anyOf`}}})),eb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),n=Z();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)})})}}}})),tb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Z();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)})}}})),nb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),n=Z(),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})),rb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Z();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`)}}})),ib=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Hy(),n=Wy(),r=Uy(),i=Gy(),a=Ky(),o=qy(),s=Jy(),c=Yy(),l=Xy(),u=Zy(),d=Qy(),f=$y(),p=eb(),m=tb(),h=nb(),g=rb();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=_})),ab=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X();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})`}}}}})),ob=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=[ab().default]})),sb=i((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`]})),cb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Oy(),n=Vy(),r=ib(),i=ob(),a=sb();e.default=[t.default,n.default,(0,r.default)(),i.default,a.metadataVocabulary,a.contentVocabulary]})),lb=i((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={}))})),ub=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),n=lb(),r=fy(),i=dy(),a=Z();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}}}}})),db=r({$id:()=>pb,$schema:()=>fb,default:()=>vb,definitions:()=>hb,properties:()=>_b,title:()=>mb,type:()=>gb}),fb,pb,mb,hb,gb,_b,vb,yb=n((()=>{fb=`http://json-schema.org/draft-07/schema#`,pb=`http://json-schema.org/draft-07/schema#`,mb=`Core schema meta-schema`,hb={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:[]}},gb=[`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:`#`}},vb={$schema:fb,$id:pb,title:mb,definitions:hb,type:gb,properties:_b,default:!0}})),bb=i(((e,n)=>{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 r=Ty(),i=cb(),a=ub(),o=(yb(),t(db).default),s=[`/properties`],c=`http://json-schema.org/draft-07/schema`,l=class extends r.default{_addVocabularies(){super._addVocabularies(),i.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(a.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(o,s):o;this.addMetaSchema(e,c,!1),this.refs[`http://json-schema.org/schema`]=c}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(c)?c:void 0)}};e.Ajv=l,n.exports=e=l,n.exports.Ajv=l,Object.defineProperty(e,"__esModule",{value:!0}),e.default=l;var u=ly();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return u.KeywordCxt}});var d=X();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return d._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return d.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return d.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return d.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return d.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return d.CodeGen}});var f=uy();Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return f.default}});var p=dy();Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return p.default}})})),xb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.dynamicAnchor=void 0;var t=X(),n=Xv(),r=fy(),i=Dy(),a={keyword:`$dynamicAnchor`,schemaType:`string`,code:e=>o(e,e.schema)};function o(e,r){let{gen:i,it:a}=e;a.schemaEnv.root.dynamicAnchors[r]=!0;let o=(0,t._)`${n.default.dynamicAnchors}${(0,t.getProperty)(r)}`,c=a.errSchemaPath===`#`?a.validateName:s(e);i.if((0,t._)`!${o}`,()=>i.assign(o,c))}e.dynamicAnchor=o;function s(e){let{schemaEnv:t,schema:n,self:a}=e.it,{root:o,baseId:s,localRefs:c,meta:l}=t.root,{schemaId:u}=a.opts,d=new r.SchemaEnv({schema:n,schemaId:u,root:o,baseId:s,localRefs:c,meta:l});return r.compileSchema.call(a,d),(0,i.getValidate)(e,d)}e.default=a})),Sb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.dynamicRef=void 0;var t=X(),n=Xv(),r=Dy(),i={keyword:`$dynamicRef`,schemaType:`string`,code:e=>a(e,e.schema)};function a(e,i){let{gen:a,keyword:o,it:s}=e;if(i[0]!==`#`)throw Error(`"${o}" only supports hash fragment reference`);let c=i.slice(1);if(s.allErrors)l();else{let t=a.let(`valid`,!1);l(t),e.ok(t)}function l(e){if(s.schemaEnv.root.dynamicAnchors[c]){let r=a.let(`_v`,(0,t._)`${n.default.dynamicAnchors}${(0,t.getProperty)(c)}`);a.if(r,u(r,e),u(s.validateName,e))}else u(s.validateName,e)()}function u(t,n){return n?()=>a.block(()=>{(0,r.callRef)(e,t),a.let(n,!0)}):()=>(0,r.callRef)(e,t)}}e.dynamicRef=a,e.default=i})),Cb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=xb(),n=Z();e.default={keyword:`$recursiveAnchor`,schemaType:`boolean`,code(e){e.schema?(0,t.dynamicAnchor)(e,``):(0,n.checkStrictMode)(e.it,`$recursiveAnchor: false is ignored`)}}})),wb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Sb();e.default={keyword:`$recursiveRef`,schemaType:`string`,code:e=>(0,t.dynamicRef)(e,e.schema)}})),Tb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=xb(),n=Sb(),r=Cb(),i=wb();e.default=[t.default,n.default,r.default,i.default]})),Eb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=qy();e.default={keyword:`dependentRequired`,type:`object`,schemaType:`object`,error:t.error,code:e=>(0,t.validatePropertyDeps)(e)}})),Db=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=qy();e.default={keyword:`dependentSchemas`,type:`object`,schemaType:`object`,code:e=>(0,t.validateSchemaDeps)(e)}})),Ob=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Z();e.default={keyword:[`maxContains`,`minContains`],type:`array`,schemaType:`number`,code({keyword:e,parentSchema:n,it:r}){n.contains===void 0&&(0,t.checkStrictMode)(r,`"${e}" without "contains" is ignored`)}}})),kb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Eb(),n=Db(),r=Ob();e.default=[t.default,n.default,r.default]})),Ab=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),n=Z(),r=Xv();e.default={keyword:`unevaluatedProperties`,type:`object`,schemaType:[`boolean`,`object`],trackErrors:!0,error:{message:`must NOT have unevaluated properties`,params:({params:e})=>(0,t._)`{unevaluatedProperty: ${e.unevaluatedProperty}}`},code(e){let{gen:i,schema:a,data:o,errsCount:s,it:c}=e;if(!s)throw Error(`ajv implementation error`);let{allErrors:l,props:u}=c;u instanceof t.Name?i.if((0,t._)`${u} !== true`,()=>i.forIn(`key`,o,e=>i.if(f(u,e),()=>d(e)))):u!==!0&&i.forIn(`key`,o,e=>u===void 0?d(e):i.if(p(u,e),()=>d(e))),c.props=!0,e.ok((0,t._)`${s} === ${r.default.errors}`);function d(r){if(a===!1){e.setParams({unevaluatedProperty:r}),e.error(),l||i.break();return}if(!(0,n.alwaysValidSchema)(c,a)){let a=i.name(`valid`);e.subschema({keyword:`unevaluatedProperties`,dataProp:r,dataPropType:n.Type.Str},a),l||i.if((0,t.not)(a),()=>i.break())}}function f(e,n){return(0,t._)`!${e} || !${e}[${n}]`}function p(e,n){let r=[];for(let i in e)e[i]===!0&&r.push((0,t._)`${n} !== ${i}`);return(0,t.and)(...r)}}}})),jb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=X(),n=Z();e.default={keyword:`unevaluatedItems`,type:`array`,schemaType:[`boolean`,`object`],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{gen:r,schema:i,data:a,it:o}=e,s=o.items||0;if(s===!0)return;let c=r.const(`len`,(0,t._)`${a}.length`);if(i===!1)e.setParams({len:s}),e.fail((0,t._)`${c} > ${s}`);else if(typeof i==`object`&&!(0,n.alwaysValidSchema)(o,i)){let n=r.var(`valid`,(0,t._)`${c} <= ${s}`);r.if((0,t.not)(n),()=>l(n,s)),e.ok(n)}o.items=!0;function l(i,a){r.forRange(`i`,a,c,a=>{e.subschema({keyword:`unevaluatedItems`,dataProp:a,dataPropType:n.Type.Num},i),o.allErrors||r.if((0,t.not)(i),()=>r.break())})}}}})),Mb=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Ab(),n=jb();e.default=[t.default,n.default]})),Nb=r({$id:()=>Fb,$recursiveAnchor:()=>!0,$schema:()=>Pb,$vocabulary:()=>Ib,allOf:()=>Rb,default:()=>Vb,properties:()=>Bb,title:()=>Lb,type:()=>zb}),Pb,Fb,Ib,Lb,Rb,zb,Bb,Vb,Hb=n((()=>{Pb=`https://json-schema.org/draft/2019-09/schema`,Fb=`https://json-schema.org/draft/2019-09/schema`,Ib={"https://json-schema.org/draft/2019-09/vocab/core":!0,"https://json-schema.org/draft/2019-09/vocab/applicator":!0,"https://json-schema.org/draft/2019-09/vocab/validation":!0,"https://json-schema.org/draft/2019-09/vocab/meta-data":!0,"https://json-schema.org/draft/2019-09/vocab/format":!1,"https://json-schema.org/draft/2019-09/vocab/content":!0},Lb=`Core and Validation specifications meta-schema`,Rb=[{$ref:`meta/core`},{$ref:`meta/applicator`},{$ref:`meta/validation`},{$ref:`meta/meta-data`},{$ref:`meta/format`},{$ref:`meta/content`}],zb=[`object`,`boolean`],Bb={definitions:{$comment:`While no longer an official keyword as it is replaced by $defs, this keyword is retained in the meta-schema to prevent incompatible extensions as it remains in common use.`,type:`object`,additionalProperties:{$recursiveRef:`#`},default:{}},dependencies:{$comment:`"dependencies" is no longer a keyword, but schema authors should avoid redefining it to facilitate a smooth transition to "dependentSchemas" and "dependentRequired"`,type:`object`,additionalProperties:{anyOf:[{$recursiveRef:`#`},{$ref:`meta/validation#/$defs/stringArray`}]}}},Vb={$schema:Pb,$id:Fb,$vocabulary:Ib,$recursiveAnchor:!0,title:Lb,allOf:Rb,type:zb,properties:Bb}})),Ub=r({$defs:()=>Xb,$id:()=>Gb,$recursiveAnchor:()=>!0,$schema:()=>Wb,$vocabulary:()=>Kb,default:()=>Zb,properties:()=>Yb,title:()=>qb,type:()=>Jb}),Wb,Gb,Kb,qb,Jb,Yb,Xb,Zb,Qb=n((()=>{Wb=`https://json-schema.org/draft/2019-09/schema`,Gb=`https://json-schema.org/draft/2019-09/meta/applicator`,Kb={"https://json-schema.org/draft/2019-09/vocab/applicator":!0},qb=`Applicator vocabulary meta-schema`,Jb=[`object`,`boolean`],Yb={additionalItems:{$recursiveRef:`#`},unevaluatedItems:{$recursiveRef:`#`},items:{anyOf:[{$recursiveRef:`#`},{$ref:`#/$defs/schemaArray`}]},contains:{$recursiveRef:`#`},additionalProperties:{$recursiveRef:`#`},unevaluatedProperties:{$recursiveRef:`#`},properties:{type:`object`,additionalProperties:{$recursiveRef:`#`},default:{}},patternProperties:{type:`object`,additionalProperties:{$recursiveRef:`#`},propertyNames:{format:`regex`},default:{}},dependentSchemas:{type:`object`,additionalProperties:{$recursiveRef:`#`}},propertyNames:{$recursiveRef:`#`},if:{$recursiveRef:`#`},then:{$recursiveRef:`#`},else:{$recursiveRef:`#`},allOf:{$ref:`#/$defs/schemaArray`},anyOf:{$ref:`#/$defs/schemaArray`},oneOf:{$ref:`#/$defs/schemaArray`},not:{$recursiveRef:`#`}},Xb={schemaArray:{type:`array`,minItems:1,items:{$recursiveRef:`#`}}},Zb={$schema:Wb,$id:Gb,$vocabulary:Kb,$recursiveAnchor:!0,title:qb,type:Jb,properties:Yb,$defs:Xb}})),$b=r({$id:()=>tx,$recursiveAnchor:()=>!0,$schema:()=>ex,$vocabulary:()=>nx,default:()=>ox,properties:()=>ax,title:()=>rx,type:()=>ix}),ex,tx,nx,rx,ix,ax,ox,sx=n((()=>{ex=`https://json-schema.org/draft/2019-09/schema`,tx=`https://json-schema.org/draft/2019-09/meta/content`,nx={"https://json-schema.org/draft/2019-09/vocab/content":!0},rx=`Content vocabulary meta-schema`,ix=[`object`,`boolean`],ax={contentMediaType:{type:`string`},contentEncoding:{type:`string`},contentSchema:{$recursiveRef:`#`}},ox={$schema:ex,$id:tx,$vocabulary:nx,$recursiveAnchor:!0,title:rx,type:ix,properties:ax}})),cx=r({$id:()=>ux,$recursiveAnchor:()=>!0,$schema:()=>lx,$vocabulary:()=>dx,default:()=>hx,properties:()=>mx,title:()=>fx,type:()=>px}),lx,ux,dx,fx,px,mx,hx,gx=n((()=>{lx=`https://json-schema.org/draft/2019-09/schema`,ux=`https://json-schema.org/draft/2019-09/meta/core`,dx={"https://json-schema.org/draft/2019-09/vocab/core":!0},fx=`Core vocabulary meta-schema`,px=[`object`,`boolean`],mx={$id:{type:`string`,format:`uri-reference`,$comment:`Non-empty fragments not allowed.`,pattern:`^[^#]*#?$`},$schema:{type:`string`,format:`uri`},$anchor:{type:`string`,pattern:`^[A-Za-z][-A-Za-z0-9.:_]*$`},$ref:{type:`string`,format:`uri-reference`},$recursiveRef:{type:`string`,format:`uri-reference`},$recursiveAnchor:{type:`boolean`,default:!1},$vocabulary:{type:`object`,propertyNames:{type:`string`,format:`uri`},additionalProperties:{type:`boolean`}},$comment:{type:`string`},$defs:{type:`object`,additionalProperties:{$recursiveRef:`#`},default:{}}},hx={$schema:lx,$id:ux,$vocabulary:dx,$recursiveAnchor:!0,title:fx,type:px,properties:mx}})),_x=r({$id:()=>yx,$recursiveAnchor:()=>!0,$schema:()=>vx,$vocabulary:()=>bx,default:()=>wx,properties:()=>Cx,title:()=>xx,type:()=>Sx}),vx,yx,bx,xx,Sx,Cx,wx,Tx=n((()=>{vx=`https://json-schema.org/draft/2019-09/schema`,yx=`https://json-schema.org/draft/2019-09/meta/format`,bx={"https://json-schema.org/draft/2019-09/vocab/format":!0},xx=`Format vocabulary meta-schema`,Sx=[`object`,`boolean`],Cx={format:{type:`string`}},wx={$schema:vx,$id:yx,$vocabulary:bx,$recursiveAnchor:!0,title:xx,type:Sx,properties:Cx}})),Ex=r({$id:()=>Ox,$recursiveAnchor:()=>!0,$schema:()=>Dx,$vocabulary:()=>kx,default:()=>Nx,properties:()=>Mx,title:()=>Ax,type:()=>jx}),Dx,Ox,kx,Ax,jx,Mx,Nx,Px=n((()=>{Dx=`https://json-schema.org/draft/2019-09/schema`,Ox=`https://json-schema.org/draft/2019-09/meta/meta-data`,kx={"https://json-schema.org/draft/2019-09/vocab/meta-data":!0},Ax=`Meta-data vocabulary meta-schema`,jx=[`object`,`boolean`],Mx={title:{type:`string`},description:{type:`string`},default:!0,deprecated:{type:`boolean`,default:!1},readOnly:{type:`boolean`,default:!1},writeOnly:{type:`boolean`,default:!1},examples:{type:`array`,items:!0}},Nx={$schema:Dx,$id:Ox,$vocabulary:kx,$recursiveAnchor:!0,title:Ax,type:jx,properties:Mx}})),Fx=r({$defs:()=>Hx,$id:()=>Lx,$recursiveAnchor:()=>!0,$schema:()=>Ix,$vocabulary:()=>Rx,default:()=>Ux,properties:()=>Vx,title:()=>zx,type:()=>Bx}),Ix,Lx,Rx,zx,Bx,Vx,Hx,Ux,Wx=n((()=>{Ix=`https://json-schema.org/draft/2019-09/schema`,Lx=`https://json-schema.org/draft/2019-09/meta/validation`,Rx={"https://json-schema.org/draft/2019-09/vocab/validation":!0},zx=`Validation vocabulary meta-schema`,Bx=[`object`,`boolean`],Vx={multipleOf:{type:`number`,exclusiveMinimum:0},maximum:{type:`number`},exclusiveMaximum:{type:`number`},minimum:{type:`number`},exclusiveMinimum:{type:`number`},maxLength:{$ref:`#/$defs/nonNegativeInteger`},minLength:{$ref:`#/$defs/nonNegativeIntegerDefault0`},pattern:{type:`string`,format:`regex`},maxItems:{$ref:`#/$defs/nonNegativeInteger`},minItems:{$ref:`#/$defs/nonNegativeIntegerDefault0`},uniqueItems:{type:`boolean`,default:!1},maxContains:{$ref:`#/$defs/nonNegativeInteger`},minContains:{$ref:`#/$defs/nonNegativeInteger`,default:1},maxProperties:{$ref:`#/$defs/nonNegativeInteger`},minProperties:{$ref:`#/$defs/nonNegativeIntegerDefault0`},required:{$ref:`#/$defs/stringArray`},dependentRequired:{type:`object`,additionalProperties:{$ref:`#/$defs/stringArray`}},const:!0,enum:{type:`array`,items:!0},type:{anyOf:[{$ref:`#/$defs/simpleTypes`},{type:`array`,items:{$ref:`#/$defs/simpleTypes`},minItems:1,uniqueItems:!0}]}},Hx={nonNegativeInteger:{type:`integer`,minimum:0},nonNegativeIntegerDefault0:{$ref:`#/$defs/nonNegativeInteger`,default:0},simpleTypes:{enum:[`array`,`boolean`,`integer`,`null`,`number`,`object`,`string`]},stringArray:{type:`array`,items:{type:`string`},uniqueItems:!0,default:[]}},Ux={$schema:Ix,$id:Lx,$vocabulary:Rx,$recursiveAnchor:!0,title:zx,type:Bx,properties:Vx,$defs:Hx}})),Gx=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var n=(Hb(),t(Nb).default),r=(Qb(),t(Ub).default),i=(sx(),t($b).default),a=(gx(),t(cx).default),o=(Tx(),t(_x).default),s=(Px(),t(Ex).default),c=(Wx(),t(Fx).default),l=[`/properties`];function u(e){return[n,r,i,a,t(this,o),s,t(this,c)].forEach(e=>this.addMetaSchema(e,void 0,!1)),this;function t(t,n){return e?t.$dataMetaSchema(n,l):n}}e.default=u})),Kx=i(((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.Ajv2019=void 0;var n=Ty(),r=cb(),i=Tb(),a=kb(),o=Mb(),s=ub(),c=Gx(),l=`https://json-schema.org/draft/2019-09/schema`,u=class extends n.default{constructor(e={}){super({...e,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),this.addVocabulary(i.default),r.default.forEach(e=>this.addVocabulary(e)),this.addVocabulary(a.default),this.addVocabulary(o.default),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:e,meta:t}=this.opts;t&&(c.default.call(this,e),this.refs[`http://json-schema.org/schema`]=l)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(l)?l:void 0)}};e.Ajv2019=u,t.exports=e=u,t.exports.Ajv2019=u,Object.defineProperty(e,"__esModule",{value:!0}),e.default=u;var d=ly();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return d.KeywordCxt}});var f=X();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return f._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return f.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return f.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return f.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return f.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return f.CodeGen}});var p=uy();Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return p.default}});var m=dy();Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return m.default}})})),qx=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Oy(),n=Vy(),r=ib(),i=Tb(),a=kb(),o=Mb(),s=ob(),c=sb();e.default=[i.default,t.default,n.default,(0,r.default)(!0),s.default,c.metadataVocabulary,c.contentVocabulary,a.default,o.default]})),Jx=r({$comment:()=>nS,$dynamicAnchor:()=>Qx,$id:()=>Xx,$schema:()=>Yx,$vocabulary:()=>Zx,allOf:()=>eS,default:()=>iS,properties:()=>rS,title:()=>$x,type:()=>tS}),Yx,Xx,Zx,Qx,$x,eS,tS,nS,rS,iS,aS=n((()=>{Yx=`https://json-schema.org/draft/2020-12/schema`,Xx=`https://json-schema.org/draft/2020-12/schema`,Zx={"https://json-schema.org/draft/2020-12/vocab/core":!0,"https://json-schema.org/draft/2020-12/vocab/applicator":!0,"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0,"https://json-schema.org/draft/2020-12/vocab/validation":!0,"https://json-schema.org/draft/2020-12/vocab/meta-data":!0,"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0,"https://json-schema.org/draft/2020-12/vocab/content":!0},Qx=`meta`,$x=`Core and Validation specifications meta-schema`,eS=[{$ref:`meta/core`},{$ref:`meta/applicator`},{$ref:`meta/unevaluated`},{$ref:`meta/validation`},{$ref:`meta/meta-data`},{$ref:`meta/format-annotation`},{$ref:`meta/content`}],tS=[`object`,`boolean`],nS=`This meta-schema also defines keywords that have appeared in previous drafts in order to prevent incompatible extensions as they remain in common use.`,rS={definitions:{$comment:`"definitions" has been replaced by "$defs".`,type:`object`,additionalProperties:{$dynamicRef:`#meta`},deprecated:!0,default:{}},dependencies:{$comment:`"dependencies" has been split and replaced by "dependentSchemas" and "dependentRequired" in order to serve their differing semantics.`,type:`object`,additionalProperties:{anyOf:[{$dynamicRef:`#meta`},{$ref:`meta/validation#/$defs/stringArray`}]},deprecated:!0,default:{}},$recursiveAnchor:{$comment:`"$recursiveAnchor" has been replaced by "$dynamicAnchor".`,$ref:`meta/core#/$defs/anchorString`,deprecated:!0},$recursiveRef:{$comment:`"$recursiveRef" has been replaced by "$dynamicRef".`,$ref:`meta/core#/$defs/uriReferenceString`,deprecated:!0}},iS={$schema:Yx,$id:Xx,$vocabulary:Zx,$dynamicAnchor:Qx,title:$x,allOf:eS,type:tS,$comment:nS,properties:rS}})),oS=r({$defs:()=>mS,$dynamicAnchor:()=>uS,$id:()=>cS,$schema:()=>sS,$vocabulary:()=>lS,default:()=>hS,properties:()=>pS,title:()=>dS,type:()=>fS}),sS,cS,lS,uS,dS,fS,pS,mS,hS,gS=n((()=>{sS=`https://json-schema.org/draft/2020-12/schema`,cS=`https://json-schema.org/draft/2020-12/meta/applicator`,lS={"https://json-schema.org/draft/2020-12/vocab/applicator":!0},uS=`meta`,dS=`Applicator vocabulary meta-schema`,fS=[`object`,`boolean`],pS={prefixItems:{$ref:`#/$defs/schemaArray`},items:{$dynamicRef:`#meta`},contains:{$dynamicRef:`#meta`},additionalProperties:{$dynamicRef:`#meta`},properties:{type:`object`,additionalProperties:{$dynamicRef:`#meta`},default:{}},patternProperties:{type:`object`,additionalProperties:{$dynamicRef:`#meta`},propertyNames:{format:`regex`},default:{}},dependentSchemas:{type:`object`,additionalProperties:{$dynamicRef:`#meta`},default:{}},propertyNames:{$dynamicRef:`#meta`},if:{$dynamicRef:`#meta`},then:{$dynamicRef:`#meta`},else:{$dynamicRef:`#meta`},allOf:{$ref:`#/$defs/schemaArray`},anyOf:{$ref:`#/$defs/schemaArray`},oneOf:{$ref:`#/$defs/schemaArray`},not:{$dynamicRef:`#meta`}},mS={schemaArray:{type:`array`,minItems:1,items:{$dynamicRef:`#meta`}}},hS={$schema:sS,$id:cS,$vocabulary:lS,$dynamicAnchor:uS,title:dS,type:fS,properties:pS,$defs:mS}})),_S=r({$dynamicAnchor:()=>xS,$id:()=>yS,$schema:()=>vS,$vocabulary:()=>bS,default:()=>TS,properties:()=>wS,title:()=>SS,type:()=>CS}),vS,yS,bS,xS,SS,CS,wS,TS,ES=n((()=>{vS=`https://json-schema.org/draft/2020-12/schema`,yS=`https://json-schema.org/draft/2020-12/meta/unevaluated`,bS={"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0},xS=`meta`,SS=`Unevaluated applicator vocabulary meta-schema`,CS=[`object`,`boolean`],wS={unevaluatedItems:{$dynamicRef:`#meta`},unevaluatedProperties:{$dynamicRef:`#meta`}},TS={$schema:vS,$id:yS,$vocabulary:bS,$dynamicAnchor:xS,title:SS,type:CS,properties:wS}})),DS=r({$dynamicAnchor:()=>jS,$id:()=>kS,$schema:()=>OS,$vocabulary:()=>AS,default:()=>FS,properties:()=>PS,title:()=>MS,type:()=>NS}),OS,kS,AS,jS,MS,NS,PS,FS,IS=n((()=>{OS=`https://json-schema.org/draft/2020-12/schema`,kS=`https://json-schema.org/draft/2020-12/meta/content`,AS={"https://json-schema.org/draft/2020-12/vocab/content":!0},jS=`meta`,MS=`Content vocabulary meta-schema`,NS=[`object`,`boolean`],PS={contentEncoding:{type:`string`},contentMediaType:{type:`string`},contentSchema:{$dynamicRef:`#meta`}},FS={$schema:OS,$id:kS,$vocabulary:AS,$dynamicAnchor:jS,title:MS,type:NS,properties:PS}})),LS=r({$defs:()=>GS,$dynamicAnchor:()=>VS,$id:()=>zS,$schema:()=>RS,$vocabulary:()=>BS,default:()=>KS,properties:()=>WS,title:()=>HS,type:()=>US}),RS,zS,BS,VS,HS,US,WS,GS,KS,qS=n((()=>{RS=`https://json-schema.org/draft/2020-12/schema`,zS=`https://json-schema.org/draft/2020-12/meta/core`,BS={"https://json-schema.org/draft/2020-12/vocab/core":!0},VS=`meta`,HS=`Core vocabulary meta-schema`,US=[`object`,`boolean`],WS={$id:{$ref:`#/$defs/uriReferenceString`,$comment:`Non-empty fragments not allowed.`,pattern:`^[^#]*#?$`},$schema:{$ref:`#/$defs/uriString`},$ref:{$ref:`#/$defs/uriReferenceString`},$anchor:{$ref:`#/$defs/anchorString`},$dynamicRef:{$ref:`#/$defs/uriReferenceString`},$dynamicAnchor:{$ref:`#/$defs/anchorString`},$vocabulary:{type:`object`,propertyNames:{$ref:`#/$defs/uriString`},additionalProperties:{type:`boolean`}},$comment:{type:`string`},$defs:{type:`object`,additionalProperties:{$dynamicRef:`#meta`}}},GS={anchorString:{type:`string`,pattern:`^[A-Za-z_][-A-Za-z0-9._]*$`},uriString:{type:`string`,format:`uri`},uriReferenceString:{type:`string`,format:`uri-reference`}},KS={$schema:RS,$id:zS,$vocabulary:BS,$dynamicAnchor:VS,title:HS,type:US,properties:WS,$defs:GS}})),JS=r({$dynamicAnchor:()=>QS,$id:()=>XS,$schema:()=>YS,$vocabulary:()=>ZS,default:()=>nC,properties:()=>tC,title:()=>$S,type:()=>eC}),YS,XS,ZS,QS,$S,eC,tC,nC,rC=n((()=>{YS=`https://json-schema.org/draft/2020-12/schema`,XS=`https://json-schema.org/draft/2020-12/meta/format-annotation`,ZS={"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0},QS=`meta`,$S=`Format vocabulary meta-schema for annotation results`,eC=[`object`,`boolean`],tC={format:{type:`string`}},nC={$schema:YS,$id:XS,$vocabulary:ZS,$dynamicAnchor:QS,title:$S,type:eC,properties:tC}})),iC=r({$dynamicAnchor:()=>cC,$id:()=>oC,$schema:()=>aC,$vocabulary:()=>sC,default:()=>fC,properties:()=>dC,title:()=>lC,type:()=>uC}),aC,oC,sC,cC,lC,uC,dC,fC,pC=n((()=>{aC=`https://json-schema.org/draft/2020-12/schema`,oC=`https://json-schema.org/draft/2020-12/meta/meta-data`,sC={"https://json-schema.org/draft/2020-12/vocab/meta-data":!0},cC=`meta`,lC=`Meta-data vocabulary meta-schema`,uC=[`object`,`boolean`],dC={title:{type:`string`},description:{type:`string`},default:!0,deprecated:{type:`boolean`,default:!1},readOnly:{type:`boolean`,default:!1},writeOnly:{type:`boolean`,default:!1},examples:{type:`array`,items:!0}},fC={$schema:aC,$id:oC,$vocabulary:sC,$dynamicAnchor:cC,title:lC,type:uC,properties:dC}})),mC=r({$defs:()=>SC,$dynamicAnchor:()=>vC,$id:()=>gC,$schema:()=>hC,$vocabulary:()=>_C,default:()=>CC,properties:()=>xC,title:()=>yC,type:()=>bC}),hC,gC,_C,vC,yC,bC,xC,SC,CC,wC=n((()=>{hC=`https://json-schema.org/draft/2020-12/schema`,gC=`https://json-schema.org/draft/2020-12/meta/validation`,_C={"https://json-schema.org/draft/2020-12/vocab/validation":!0},vC=`meta`,yC=`Validation vocabulary meta-schema`,bC=[`object`,`boolean`],xC={type:{anyOf:[{$ref:`#/$defs/simpleTypes`},{type:`array`,items:{$ref:`#/$defs/simpleTypes`},minItems:1,uniqueItems:!0}]},const:!0,enum:{type:`array`,items:!0},multipleOf:{type:`number`,exclusiveMinimum:0},maximum:{type:`number`},exclusiveMaximum:{type:`number`},minimum:{type:`number`},exclusiveMinimum:{type:`number`},maxLength:{$ref:`#/$defs/nonNegativeInteger`},minLength:{$ref:`#/$defs/nonNegativeIntegerDefault0`},pattern:{type:`string`,format:`regex`},maxItems:{$ref:`#/$defs/nonNegativeInteger`},minItems:{$ref:`#/$defs/nonNegativeIntegerDefault0`},uniqueItems:{type:`boolean`,default:!1},maxContains:{$ref:`#/$defs/nonNegativeInteger`},minContains:{$ref:`#/$defs/nonNegativeInteger`,default:1},maxProperties:{$ref:`#/$defs/nonNegativeInteger`},minProperties:{$ref:`#/$defs/nonNegativeIntegerDefault0`},required:{$ref:`#/$defs/stringArray`},dependentRequired:{type:`object`,additionalProperties:{$ref:`#/$defs/stringArray`}}},SC={nonNegativeInteger:{type:`integer`,minimum:0},nonNegativeIntegerDefault0:{$ref:`#/$defs/nonNegativeInteger`,default:0},simpleTypes:{enum:[`array`,`boolean`,`integer`,`null`,`number`,`object`,`string`]},stringArray:{type:`array`,items:{type:`string`},uniqueItems:!0,default:[]}},CC={$schema:hC,$id:gC,$vocabulary:_C,$dynamicAnchor:vC,title:yC,type:bC,properties:xC,$defs:SC}})),TC=i((e=>{Object.defineProperty(e,"__esModule",{value:!0});var n=(aS(),t(Jx).default),r=(gS(),t(oS).default),i=(ES(),t(_S).default),a=(IS(),t(DS).default),o=(qS(),t(LS).default),s=(rC(),t(JS).default),c=(pC(),t(iC).default),l=(wC(),t(mC).default),u=[`/properties`];function d(e){return[n,r,i,a,o,t(this,s),c,t(this,l)].forEach(e=>this.addMetaSchema(e,void 0,!1)),this;function t(t,n){return e?t.$dataMetaSchema(n,u):n}}e.default=d})),EC=i(((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.Ajv2020=void 0;var n=Ty(),r=qx(),i=ub(),a=TC(),o=`https://json-schema.org/draft/2020-12/schema`,s=class extends n.default{constructor(e={}){super({...e,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),r.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(i.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:e,meta:t}=this.opts;t&&(a.default.call(this,e),this.refs[`http://json-schema.org/schema`]=o)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(o)?o:void 0)}};e.Ajv2020=s,t.exports=e=s,t.exports.Ajv2020=s,Object.defineProperty(e,"__esModule",{value:!0}),e.default=s;var c=ly();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return c.KeywordCxt}});var l=X();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return l._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return l.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return l.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return l.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return l.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return l.CodeGen}});var u=uy();Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return u.default}});var d=dy();Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return d.default}})})),DC=i((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}}})),OC=i((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatLimitDefinition=void 0;var t=bb(),n=X(),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)})),kC=i(((e,t)=>{Object.defineProperty(e,"__esModule",{value:!0});var n=DC(),r=OC(),i=X(),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})),AC=bb(),jC=Kx(),MC=EC(),NC=e(kC(),1),PC=[`example`,`externalDocs`,`xml`,`markdownDescription`,`enumDescriptions`,`enumNames`,`enumTitles`];function FC(e,t=new Set){if(e&&typeof e==`object`)for(let[n,r]of Object.entries(e))n.startsWith(`x-`)&&t.add(n),FC(r,t);return t}function IC(e,t){let n=new e({strict:!0,strictTypes:!1,strictTuples:!1,strictRequired:!1,allowUnionTypes:!0,allErrors:!0});(0,NC.default)(n);for(let e of[...PC,...FC(t)])n.addKeyword({keyword:e,valid:!0});return n}var LC=new Map;function RC(e){let t=JSON.stringify(e),n=LC.get(t);if(n)return n;let r=typeof e==`object`?e.$schema:void 0,i=IC(typeof r==`string`&&r.includes(`draft-07`)?AC.Ajv:typeof r==`string`&&r.includes(`2019-09`)?jC.Ajv2019:MC.Ajv2020,e);try{let n=i.compile(e);if(`$async`in n)throw Error(`Asynchronous schemas are not supported`);return LC.size>=200&&LC.clear(),LC.set(t,n),n}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`MCP JSON Schema cannot be validated: ${t}. Reconfigure the tool schema (supported dialects: draft-07, 2019-09, 2020-12). No validation was skipped.`)}}function zC(e,t){let n=RC(e);if(!n(t))throw Error(`MCP schema validation failed: `+(n.errors??[]).map(e=>`${e.instancePath||`/`} ${e.keyword}`).join(`; `))}function BC(e,t){if(!t.length||typeof e==`boolean`)return e;let[n,...r]=t,i=e.properties,a=i&&typeof i==`object`&&!Array.isArray(i)?i[n]:void 0;return a!==void 0&&(typeof a==`boolean`||a&&typeof a==`object`&&!Array.isArray(a))?BC(a,r):!0}function VC(e){for(let t of[`inputSchema`,`outputSchema`]){let n=e[t];if(n!==void 0)try{RC(n)}catch(n){throw Error(`MCP tool ${JSON.stringify(e.toolName)} ${t}: ${n instanceof Error?n.message:String(n)}`)}}}var HC=qv();Y({structuredContent:HC,content:cv(Y({type:J()}).catchall(HC))}).strict();function UC(e){return typeof e==`string`&&/^[A-Za-z_][A-Za-z0-9_-]{0,127}$/.test(e)&&![`__proto__`,`constructor`,`prototype`].includes(e)}var WC=class{nodes=[{variable:1/0,choices:[]},{variable:1/0,choices:[]}];unique=new Map;cache=new Map;outcome(e,t){return this.node(e,Array.from({length:5},(e,n)=>Number(n===t)))}and(e,t){return this.apply(`and`,e,t)}or(e,t){return this.apply(`or`,e,t)}not(e){if(e<2)return 1-e;let t=`not:${e}`,n=this.cache.get(t);if(n!==void 0)return n;let r=this.nodes[e],i=this.node(r.variable,r.choices.map(e=>this.not(e)));return this.cache.set(t,i),i}implies(e,t){return this.and(e,this.not(t))===0}node(e,t){if(t.every(e=>e===t[0]))return t[0];let n=`${e}:${t.join(`,`)}`,r=this.unique.get(n);if(r!==void 0)return r;let i=this.nodes.length;return this.nodes.push({variable:e,choices:t}),this.unique.set(n,i),i}apply(e,t,n){if(t===n)return t;if(e===`and`){if(t===0||n===0)return 0;if(t===1)return n;if(n===1)return t}else{if(t===1||n===1)return 1;if(t===0)return n;if(n===0)return t}let r=`${e}:${Math.min(t,n)}:${Math.max(t,n)}`,i=this.cache.get(r);if(i!==void 0)return i;let a=this.nodes[t],o=this.nodes[n],s=Math.min(a.variable,o.variable),c=this.node(s,Array.from({length:5},(r,i)=>this.apply(e,a.variable===s?a.choices[i]:t,o.variable===s?o.choices[i]:n)));return this.cache.set(r,c),c}};function GC(e){let t=e.steps.map(e=>e.id),n=new Set(t);if(n.size!==t.length)throw Error(`Step IDs must be unique`);if(new Set(e.edges.map(e=>e.id)).size!==e.edges.length)throw Error(`Edge IDs must be unique`);let r=new Map(t.map(e=>[e,[]])),i=new Map(t.map(e=>[e,[]]));for(let t of e.edges){if(!n.has(t.from)||!n.has(t.to))throw Error(`Unknown edge endpoint`);r.get(t.to).push(t),i.get(t.from).push(t)}let a=t.filter(e=>!r.get(e).length),o=new Set(a),s=[...a];for(let e=0;e<s.length;e++)for(let t of i.get(s[e]))o.has(t.to)||(o.add(t.to),s.push(t.to));if(o.size!==n.size)throw Error(`Workflow cycle has no entry from a root`);let c=new Map(t.map(e=>[e,new Set(a.includes(e)?[e]:t)])),l=!0;for(;l;){l=!1;for(let e of s){let t=r.get(e);if(!t.length)continue;let n=new Set([...c.get(t[0].from)].filter(e=>t.every(t=>c.get(t.from).has(e))));n.add(e);let i=c.get(e);(n.size!==i.size||[...n].some(e=>!i.has(e)))&&(c.set(e,n),l=!0)}}let u=e.edges.filter(e=>c.get(e.from).has(e.to)),d=new Set(u.map(e=>e.id)),f=new Map;for(let e of u){let t=f.get(e.to)??new Set([e.to]),n=[e.from];for(;n.length;){let e=n.pop();t.has(e)||(t.add(e),n.push(...r.get(e).map(e=>e.from)))}f.set(e.to,t)}let p=[...f].map(([n,r])=>({headerId:n,memberIds:t.filter(e=>r.has(e)),backEdgeIds:u.filter(e=>e.to===n).map(e=>e.id),entryEdgeIds:e.edges.filter(e=>!r.has(e.from)&&r.has(e.to)).map(e=>e.id),exitEdgeIds:e.edges.filter(e=>r.has(e.from)&&!r.has(e.to)).map(e=>e.id)}));for(let t of p){let n=f.get(t.headerId);if(e.edges.some(e=>!n.has(e.from)&&n.has(e.to)&&e.to!==t.headerId))throw Error(`Workflow loop has multiple entry steps`);let r=[];for(let e of p){if(e===t)continue;let i=f.get(e.headerId),a=t.memberIds.filter(e=>i.has(e)).length;if(a){if(a===n.size&&n.size<i.size)r.push(e);else if(a!==i.size||n.size===i.size)throw Error(`Workflow loops overlap without strict nesting`)}}r.sort((e,t)=>e.memberIds.length-t.memberIds.length),r[0]&&(t.parentHeaderId=r[0].headerId)}let m=[],h=new Set(t);for(;h.size;){let e=[...h].filter(e=>r.get(e).every(e=>d.has(e.id)||!h.has(e.from)));if(!e.length)throw Error(`Workflow contains an irreducible or multiple-entry cycle`);for(let t of e)m.push(t),h.delete(t)}return p.sort((e,n)=>n.memberIds.length-e.memberIds.length||t.indexOf(e.headerId)-t.indexOf(n.headerId)),{loops:p,order:m}}var KC=J().refine(e=>![`__proto__`,`constructor`,`prototype`].includes(e),`Reserved dictionary key`);function qC(e){return iv().superRefine((e,t)=>{if(e&&typeof e==`object`)for(let n of Object.keys(e))KC.safeParse(n).success||t.addIssue({code:`custom`,message:`Reserved dictionary key`,path:[n]})}).pipe(_v(KC,e))}var JC=Uv(()=>dv([nv(),ev(),X_(),J(),cv(JC),_v(J(),JC)])),YC=Uv(()=>pv(`type`,[Y({type:xv(`null`)}).strict(),Y({type:xv(`json`),schema:dv([ev(),_v(J(),JC)]).optional()}).strict(),Y({type:xv(`string`)}).strict(),Y({type:xv(`number`),integer:ev().optional()}).strict(),Y({type:xv(`boolean`)}).strict(),Y({type:xv(`enum`),values:cv(J()).min(1).refine(e=>new Set(e).size===e.length)}).strict(),Y({type:xv(`array`),items:YC}).strict(),Y({type:xv(`union`),variants:cv(YC).min(2)}).strict(),Y({type:xv(`object`),fields:qC(Y({schema:YC,required:ev().optional(),default:JC.optional()}).strict())}).strict()]));function XC(e){switch(e.type){case`null`:return nv();case`json`:return e.schema!==void 0&&RC(e.schema),JC.superRefine((t,n)=>{try{e.schema!==void 0&&zC(e.schema,t)}catch(e){n.addIssue({code:`custom`,message:e.message})}});case`string`:return J();case`number`:return e.integer?X_().int():X_();case`boolean`:return ev();case`enum`:return yv(e.values);case`array`:return cv(XC(e.items));case`union`:return dv(e.variants.map(XC));case`object`:return Y(Object.fromEntries(Object.entries(e.fields).map(([e,t])=>{let n=XC(t.schema);return t.default===void 0?t.required||(n=n.optional()):n=n.default(ZC(t.schema,t.default)),[e,n]}))).strict()}}function ZC(e,t){return JC.parse(XC(e).parse(t))}function QC(e){YC.parse(e),XC(e)}function $C(e){switch(e.type){case`json`:return`unknown`;case`enum`:return e.values.map(e=>JSON.stringify(e)).join(` | `);case`array`:return`Array<${$C(e.items)}>`;case`union`:return e.variants.map($C).join(` | `);case`object`:return`{ ${Object.entries(e.fields).map(([e,t])=>`${JSON.stringify(e)}${t.required||t.default!==void 0?``:`?`}: ${$C(t.schema)}`).join(`; `)} }`;default:return e.type}}var ew={type:`object`,fields:{exitCode:{schema:{type:`number`,integer:!0},required:!0},stdout:{schema:{type:`string`},required:!0},stderr:{schema:{type:`string`},required:!0}}};function tw(e){if(e.kind===`workflow`)return e.contract.outputSchema;if(e.kind===`mcp`)return{type:`object`,fields:{structuredContent:{required:!0,schema:{type:`json`,...e.tool.outputSchema===void 0?{}:{schema:e.tool.outputSchema}}},content:{required:!0,schema:{type:`array`,items:{type:`json`}}}}};if(e.kind===`shell`)return ew;if(e.kind===`branch`)return{type:`boolean`};if(e.kind!==`join`)return e.outputSchema}function nw(e,t){if(!t.length)return{schema:e,optional:!1};if(e.type===`json`)return{schema:{type:`json`,schema:BC(e.schema??!0,t)},optional:!1};if(e.type===`null`)return{schema:{type:`json`},optional:!1};if(e.type===`union`){let n=e.variants.map(e=>nw(e,t));return{schema:aw(n.map(e=>e.schema)),optional:n.some(e=>e.optional)}}let[n,...r]=t;if(e.type===`object`){let t=Object.hasOwn(e.fields,n)?e.fields[n]:void 0;if(!t)throw Error(`Unknown field: ${n}`);let i=nw(t.schema,r);return{schema:i.schema,optional:i.optional||!t.required&&t.default===void 0}}if(e.type===`array`&&/^(0|[1-9]\d*)$/.test(n))return{schema:nw(e.items,r).schema,optional:!0};throw Error(`Invalid field path: ${n}`)}function rw(e,t){return t.type===`json`||e.type===`json`?!0:e.type===`union`?e.variants.every(e=>rw(e,t)):t.type===`union`?t.variants.some(t=>rw(e,t)):e.type===`enum`?t.type===`string`||t.type===`enum`&&e.values.every(e=>t.values.includes(e)):e.type===t.type?e.type===`number`&&t.type===`number`?!t.integer||!!e.integer:e.type===`array`&&t.type===`array`?rw(e.items,t.items):e.type===`object`&&t.type===`object`?Object.keys(e.fields).every(e=>Object.hasOwn(t.fields,e))&&Object.entries(t.fields).every(([t,n])=>{let r=Object.hasOwn(e.fields,t)?e.fields[t]:void 0,i=n.required&&n.default===void 0;return r?(!i||r.required||r.default!==void 0)&&rw(r.schema,n.schema):!i}):!0:!1}function iw(e){return e.type===`object`?{type:`object`,fields:Object.fromEntries(Object.entries(e.fields).map(([e,t])=>[e,{schema:iw(t.schema)}]))}:e.type===`array`?{type:`array`,items:iw(e.items)}:e.type===`union`?aw(e.variants.map(iw)):e}function aw(e){let t=[...new Map(e.map(e=>[JSON.stringify(e),e])).values()];return t.length===1?t[0]:{type:`union`,variants:t}}var ow=pv(`source`,[Y({source:xv(`input`),path:cv(J())}).strict(),Y({source:xv(`step`),stepId:J(),path:cv(J())}).strict()]),sw=Uv(()=>pv(`kind`,[Y({kind:xv(`literal`),value:qv()}).strict(),Y({kind:xv(`reference`),reference:ow}).strict(),Y({kind:xv(`object`),fields:qC(sw)}).strict(),Y({kind:xv(`array`),items:cv(sw)}).strict()])),cw=dv([ev(),_v(J(),qv())]),lw=pv(`kind`,[Y({kind:xv(`template`),template:sw}).strict(),Y({kind:xv(`reference`),reference:ow}).strict(),Y({kind:xv(`object`),fields:qC(ow)}).strict()]),uw={id:KC.min(1),name:KC.min(1),inputSchema:YC.optional(),mapping:lw.optional(),repeatMapping:lw.optional(),permission:yv([`ask`,`auto-accept`]).optional(),timeoutMs:X_().int().positive().max(2147483647).optional(),secrets:qC(J().refine(UC,`Invalid secret reference`)).optional(),position:Y({x:X_(),y:X_()}).strict().optional()},dw=pv(`operator`,[Y({operator:xv(`truthy`),path:cv(J())}).strict(),Y({operator:yv([`equals`,`not-equals`]),path:cv(J()),value:qv()}).strict(),Y({operator:yv([`greater-than`,`less-than`]),path:cv(J()),value:X_()}).strict()]),fw=Y({version:xv(1),id:J().regex(/^[a-zA-Z0-9_-]{1,128}$/),name:J().min(1),backend:J().min(1),projectId:J().optional(),permission:yv([`ask`,`auto-accept`]).optional(),inputSchema:YC.refine(e=>e.type===`object`),steps:cv(pv(`kind`,[Y({...uw,kind:xv(`agent`),instructions:J(),model:J().min(1),effort:yv([`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`]),outputSchema:YC}).strict(),Y({...uw,kind:xv(`shell`),command:J(),acceptedExitCodes:cv(X_().int()).min(1).optional()}).strict(),Y({...uw,kind:xv(`typescript`),code:J(),outputSchema:YC}).strict(),Y({...uw,kind:xv(`branch`),condition:dw}).strict(),Y({...uw,kind:xv(`join`)}).strict(),Y({...uw,kind:xv(`workflow`),workflowId:J().regex(/^[a-zA-Z0-9_-]{1,128}$/),contract:Y({inputSchema:YC.refine(e=>e.type===`object`),outputSchema:YC}).strict()}).strict(),Y({...uw,kind:xv(`mcp`),tool:Y({connectionId:J().min(1),connectionName:J(),identity:J().regex(/^[a-f0-9]{64}$/),serverIdentity:J().regex(/^[a-f0-9]{64}$/),toolName:J().min(1),inputSchema:cw,outputSchema:cw.optional()}).strict()}).strict()])).min(1),loopSettings:qC(Y({maxTries:X_().int().min(1).max(100)}).strict()).optional(),edges:cv(Y({id:J().min(1),from:J(),to:J(),outcome:yv([`success`,`failure`,`timeout`,`true`,`false`])}).strict())}).strict();function pw(e){return hw(e)}function mw(e){return hw(e,!0)}function hw(e,t=!1){let n=fw.parse(e),r=n.steps.find(e=>e.kind===`agent`&&Oo(e.instructions));if(r&&!n.projectId)throw Error(`Workflow Step ${JSON.stringify(r.name)} invokes a Skill and requires a Project binding`);QC(n.inputSchema);let i=new Map(n.steps.map(e=>[e.id,e]));if(i.size!==n.steps.length||new Set(n.steps.map(e=>e.name)).size!==i.size)throw Error(`Step IDs and names must be unique`);if(new Set(n.edges.map(e=>e.id)).size!==n.edges.length)throw Error(`Edge IDs must be unique`);let a=new Map(n.steps.map(e=>[e.id,[]])),o=new Map(n.steps.map(e=>[e.id,[]])),s=new Set;for(let e of n.edges){let t=i.get(e.from);if(!t||!i.has(e.to))throw Error(`Unknown edge endpoint`);let n=JSON.stringify([e.from,e.to,e.outcome]);if(s.has(n))throw Error(`Duplicate connection`);if(s.add(n),t.kind===`branch`?![`true`,`false`,`failure`,`timeout`].includes(e.outcome):[`true`,`false`].includes(e.outcome))throw Error(`Invalid edge outcome`);a.get(e.to).push(e),o.get(e.from).push(e)}let c=GC(n),l=c.loops.map(e=>({...e,maxTries:n.loopSettings?.[e.headerId]?.maxTries??3})),u=new Map(l.map(e=>[e.headerId,e]));for(let e of Object.keys(n.loopSettings??{}))if(!u.has(e))throw Error(`Loop settings require a loop header`);for(let e of i.values())if(e.repeatMapping&&!u.has(e.id))throw Error(`Repeat mapping requires a loop header`);let d=new Set(l.flatMap(e=>e.backEdgeIds)),f=new Map([...a].map(([e,t])=>[e,t.filter(e=>!d.has(e.id))])),p=c.order.map(e=>i.get(e)),m=new WC,h=new Map,g=new Map,_=new Map,v=new Map,y=e=>e.reduce((e,t)=>m.or(e,t),0),b=new Map,x=new Map,S=new Map,C=new Map,w=new Map,T=new Map,E={definition:n,order:p,incoming:a,outgoing:o,forwardIncoming:f,loops:l,outputSchemas:x,inputSchemas:S,firstInputSchemas:C,repeatInputSchemas:w};for(let e of p){let t=f.get(e.id),n=y(t.map(e=>v.get(e.id))),r=m.and(t.length?y(t.map(e=>_.get(e.id))):1,m.not(n)),i=m.or(y(t.map(e=>m.and(_.get(e.id),e.outcome===`failure`||e.outcome===`timeout`?1:g.get(e.from)))),u.has(e.id)?m.and(r,m.outcome(p.length+p.indexOf(e),1)):0);T.set(e.id,r),g.set(e.id,i);let a=p.indexOf(e),s=m.outcome(a,1),c=m.outcome(a,2),l=m.not(m.or(s,c));h.set(e.id,m.and(r,l));let d={success:l,failure:s,timeout:c,true:y([m.outcome(a,0),m.outcome(a,3)]),false:m.outcome(a,4)},x=o.get(e.id),S=m.or(m.and(s,x.some(e=>e.outcome===`failure`)?i:1),m.and(c,x.some(e=>e.outcome===`timeout`)?i:1));for(let e of x){let t=e.outcome===`failure`||e.outcome===`timeout`;_.set(e.id,m.and(r,m.and(d[e.outcome],t?m.not(i):1))),v.set(e.id,m.or(n,t?0:m.and(r,S)))}b.set(e.id,new Set(t.flatMap(e=>[e.from,...b.get(e.from)])))}for(let e of l){let t=y(e.backEdgeIds.map(e=>_.get(e))),n=e.memberIds.map(e=>{let t=y(o.get(e).map(e=>_.get(e.id)));return m.and(h.get(e),m.not(t))}),r=y([...e.exitEdgeIds.map(e=>_.get(e)),...n]);if(m.and(t,r)!==0)throw Error(`Loop ${e.headerId} can select exit and repeat together`)}let D=new Set,O=e=>{let t=x.get(e);if(t)return t;let n=i.get(e),r=tw(n)??n.inputSchema??A(e);return QC(r),x.set(e,r),r},k=(e,r)=>{let o=u.get(e.id),s=r?a.get(e.id).filter(e=>o.backEdgeIds.includes(e.id)):f.get(e.id),c=r?y(s.map(e=>_.get(e.id))):T.get(e.id),l=r?new Set(s.flatMap(e=>[e.from,...b.get(e.from)])):b.get(e.id),d=r?e.repeatMapping:e.mapping,p=e=>{if(e.source===`input`)return nw(n.inputSchema,e.path);let t=i.get(e.stepId);if(!t||!l.has(e.stepId))throw Error(`Mapping must reference an earlier step`);if(!m.implies(c,h.get(t.id)))throw Error(`Output is not guaranteed: ${t.name}`);return nw(O(t.id),e.path)};if(e.kind===`join`&&d)throw Error(`Joins collect selected incoming outputs without mappings`);let g;if(d?.kind===`template`){let n=e=>{e.kind===`reference`&&p(e.reference),e.kind===`object`&&Object.values(e.fields).forEach(n),e.kind===`array`&&e.items.forEach(n)};n(d.template);let r=e=>{if(e.kind===`reference`)return p(e.reference).schema;if(e.kind===`object`)return{type:`object`,fields:Object.fromEntries(Object.entries(e.fields).map(([e,t])=>[e,{schema:r(t),required:!0}]))};if(e.kind===`array`)return{type:`array`,items:e.items.length?aw(e.items.map(r)):{type:`json`}};let t=e=>e===null?{type:`null`}:typeof e==`string`?{type:`enum`,values:[e]}:typeof e==`number`?{type:`number`,integer:Number.isInteger(e)}:typeof e==`boolean`?{type:`boolean`}:Array.isArray(e)?{type:`array`,items:e.length?aw(e.map(t)):{type:`json`}}:{type:`object`,fields:Object.fromEntries(Object.entries(e).map(([e,n])=>[e,{schema:t(n),required:!0}]))};return t(e.value)};g=e.kind===`workflow`?r(d.template):{type:`json`},e.kind===`workflow`&&!t&&d.template.kind===`literal`&&ZC(e.contract.inputSchema,d.template.value)}else if(d?.kind===`reference`){let e=p(d.reference);if(e.optional)throw Error(`A direct input reference must be required or have a default`);g=e.schema}else if(d?.kind===`object`)g={type:`object`,fields:Object.fromEntries(Object.entries(d.fields).map(([e,t])=>{let n=p(t);return[e,{schema:n.schema,required:!n.optional}]}))};else if(!s.length)g=n.inputSchema;else{let t=[...new Set(s.map(e=>e.from))],n=Object.fromEntries(t.map(e=>{let t=i.get(e),n=s.filter(t=>t.from===e),r=aw(n.map(t=>t.outcome===`failure`||t.outcome===`timeout`?gw(i.get(e).inputSchema??A(e),O(e)):O(e)));return[t.name,{schema:r,required:m.implies(c,y(n.map(e=>_.get(e.id))))}]})),r={type:`object`,fields:n},a=Object.values(n).filter(e=>e.required).length;g=e.kind===`join`||a>1?r:aw([...Object.values(n).map(e=>e.schema),...t.length>1?[r]:[]])}if(e.inputSchema&&(QC(e.inputSchema),!(t&&e.kind===`workflow`)&&!rw(g,e.inputSchema)))throw Error(`Input does not match the declared input schema`);if(e.kind===`workflow`){if(QC(e.contract.inputSchema),QC(e.contract.outputSchema),!t&&(!rw(g,e.contract.inputSchema)||e.inputSchema&&!rw(e.inputSchema,e.contract.inputSchema)))throw Error(`Input does not match the Workflow call input contract`);return e.contract.inputSchema}return e.inputSchema??g},A=e=>{let t=S.get(e);if(t)return t;if(D.has(e))throw Error(`Cyclic input schema at ${e}; declare a loop header inputSchema`);D.add(e);let n=i.get(e),r=k(n,!1);C.set(e,r);let a=r;if(u.has(e)){let t=k(n,!0);w.set(e,t),a=aw([r,t])}return S.set(e,a),D.delete(e),a};for(let e of p){e.kind===`mcp`&&VC(e.tool);let t=A(e.id);if(e.kind===`branch`){let n=nw(e.inputSchema??t,e.condition.path),r=e.condition.operator===`truthy`?`boolean`:[`greater-than`,`less-than`].includes(e.condition.operator)?`number`:void 0;if(r&&(n.optional||!rw(n.schema,{type:r})))throw Error(`Branch condition requires a required ${r}`)}O(e.id)}let j=p.map(e=>m.and(h.get(e.id),m.not(y(o.get(e.id).map(e=>_.get(e.id)))))),M=1;for(let e of p){let t=y(o.get(e.id).filter(e=>e.outcome===`failure`||e.outcome===`timeout`).map(e=>_.get(e.id)));M=m.and(M,m.or(m.not(T.get(e.id)),m.or(h.get(e.id),t))),l.length&&(M=m.and(M,m.not(y(o.get(e.id).filter(e=>d.has(e.id)).map(e=>_.get(e.id))))))}let N=p.map((e,t)=>({step:e,condition:j[t]})).filter(({condition:e})=>m.and(M,e)!==0),P=[],F=1,I=0,L=0;for(let{condition:e}of N)L=m.or(L,m.and(I,e)),I=m.or(m.and(I,m.not(e)),m.and(F,e)),F=m.and(F,m.not(e));if(l.length||n.edges.some(e=>e.outcome===`failure`||e.outcome===`timeout`)){let e=p.filter(e=>e.kind===`branch`?[`true`,`false`].some(t=>!o.get(e.id).some(e=>e.outcome===t)):!o.get(e.id).some(e=>e.outcome===`success`));P.push(...e.map(e=>O(e.id))),e.length>1&&P.push({type:`object`,fields:Object.fromEntries(e.map(e=>[e.name,{schema:O(e.id)}]))})}else{for(let{step:e,condition:t}of N)m.and(M,m.and(I,t))!==0&&P.push(O(e.id));let e=m.and(M,L);e!==0&&P.push({type:`object`,fields:Object.fromEntries(N.filter(({condition:t})=>m.and(e,t)!==0).map(({step:t,condition:n})=>[t.name,{schema:O(t.id),required:m.implies(e,n)}]))}),m.and(M,F)!==0&&P.push({type:`object`,fields:{}})}return{...E,resultSchema:P.length?aw(P):{type:`json`}}}function gw(e,t){return{type:`object`,fields:{input:{schema:e,required:!0},error:{required:!0,schema:{type:`object`,fields:{message:{schema:{type:`string`},required:!0},kind:{schema:{type:`enum`,values:[`failure`,`timeout`,`interrupted`]},required:!0}}}},partialOutput:{schema:iw(t)}}}}function _w(e,t){let n=1;for(;e.steps.some(e=>e.name===`${t}_${n}`);)n++;return`${t}_${n}`}function vw(e){return e&&typeof e==`object`&&`issues`in e&&Array.isArray(e.issues)?e.issues.map(e=>`${e.path?.map(String).join(`.`)||`Workflow`}: ${e.message}`).join(`; `):e instanceof Error?e.message:String(e)}function yw(e,t=[]){return[t,...e.type===`json`&&typeof e.schema==`object`&&e.schema.properties&&typeof e.schema.properties==`object`&&!Array.isArray(e.schema.properties)?Object.entries(e.schema.properties).flatMap(([e,n])=>yw({type:`json`,schema:n},[...t,e])):[],...e.type===`object`?Object.entries(e.fields).flatMap(([e,n])=>yw(n.schema,[...t,e])):[]]}function bw(e,t,n=`reference`,r=`mapping`){if(!e.steps.find(e=>e.id===t))return[];let i={...e,steps:e.steps.map(e=>{if(e.id!==t)return e;let n={...e};return delete n[r],delete n.inputSchema,n})},a;try{a=mw(i)}catch{let t=new Set(GC(e).loops.map(e=>e.headerId));i={...e,loopSettings:{},steps:e.steps.map(e=>{let n={...e};return delete n.inputSchema,n.mapping={kind:`reference`,reference:{source:`input`,path:[]}},t.has(e.id)?n.repeatMapping=n.mapping:delete n.repeatMapping,n.kind===`branch`&&(n.condition={operator:`equals`,path:[],value:null}),n.kind===`agent`&&!n.model&&(n.model=`unselected`),n.kind===`join`&&(delete n.mapping,delete n.repeatMapping),n})},a=mw(i)}let o=yw(e.inputSchema).map(e=>({label:`Workflow input${e.length?`.`+e.join(`.`):``}`,reference:{source:`input`,path:e}})),s=o.splice(0);for(let n of e.steps){if(n.id===t&&r===`mapping`)continue;let e=a.outputSchemas.get(n.id);if(e)for(let t of yw(e)){let e={source:`step`,stepId:n.id,path:t};s.push({label:`${n.name}${t.length?`.`+t.join(`.`):``}`,reference:e})}}for(let e of s){let{reference:a}=e;try{mw({...i,steps:i.steps.map(e=>e.id===t?{...e,[r]:n===`object`?{kind:`object`,fields:{value:a}}:{kind:`reference`,reference:a}}:e)}),o.push(e)}catch{}}return o}function xw(e,t,n){let r=e.steps.find(e=>e.id===t),i=pw(e),a=r?.kind===`mcp`?{type:`json`,schema:r.tool.inputSchema}:i.inputSchemas.get(t);if(!a)throw Error(`Select a step`);return ZC(a,n)}function Sw(e,t,n){if(n)return`The workflow slot is occupied`;if(e.backend!==t)return`Requires Backend Adapter ${e.backend}`;try{pw(e)}catch(e){return vw(e)}}function Cw(e,t,n){if(!t||[`__proto__`,`constructor`,`prototype`].includes(t))throw Error(`Invalid field name`);return{...e,mapping:{kind:`object`,fields:{...e.mapping?.kind===`object`?e.mapping.fields:{},[t]:n}}}}var ww=e=>typeof e==`boolean`||typeof e==`object`&&e&&!Array.isArray(e)?e:!0;function Tw(e,t,n=new Set){if(typeof e==`boolean`)return{};let r={...e};if(typeof e.$ref==`string`&&e.$ref.startsWith(`#/`)&&!n.has(e.$ref)){n.add(e.$ref);let i=t;for(let t of e.$ref.slice(2).split(`/`).map(e=>e.replace(/~1/g,`/`).replace(/~0/g,`~`)))i=i&&typeof i==`object`&&!Array.isArray(i)?i[t]??!0:!0;r={...Tw(ww(i),t,n),...r}}for(let i of Array.isArray(e.allOf)?e.allOf:[]){let e=Tw(ww(i),t,new Set(n));r={...e,...r,properties:{...Ew(e),...Ew(r)},required:[...new Set([...Array.isArray(e.required)?e.required:[],...Array.isArray(r.required)?r.required:[]])]}}return r}function Ew(e){return e.properties&&typeof e.properties==`object`&&!Array.isArray(e.properties)?e.properties:{}}function Dw(e){if(e.kind===`reference`)return;if(e.kind===`literal`)return e.value;if(e.kind===`array`){let t=e.items.map(Dw);return t.some(e=>e===void 0)?void 0:t}let t=Object.entries(e.fields).map(([e,t])=>[e,Dw(t)]);return t.some(([,e])=>e===void 0)?void 0:Object.fromEntries(t)}function Ow(e){return Array.isArray(e)?{kind:`array`,items:e.map(Ow)}:e&&typeof e==`object`?{kind:`object`,fields:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,Ow(t)]))}:{kind:`literal`,value:e}}function kw(e,t=e){let n=Tw(e,t);return n.default!==void 0||n.const!==void 0?Ow(n.default??n.const??null):Array.isArray(n.enum)&&n.enum.length?Ow(n.enum[0]):n.type===`object`||n.properties?{kind:`object`,fields:{}}:n.type===`array`?{kind:`array`,items:[]}:{kind:`literal`,value:n.type===`null`?null:n.type===`boolean`?!1:n.type===`number`||n.type===`integer`?0:``}}function Aw(e,t,n){let r=[],i=n&&typeof n==`object`&&!Array.isArray(n)?n:{};if(e.if!==void 0&&n!==void 0){let i=!1;try{let r=ww(e.if);zC(typeof r==`boolean`?r:{...typeof t==`object`&&t.$defs?{$defs:t.$defs}:{},...typeof t==`object`&&t.definitions?{definitions:t.definitions}:{},...r},n),i=!0}catch{}r.push(ww(i?e.then:e.else))}for(let t of[`dependentSchemas`,`dependencies`]){let n=e[t];if(n&&typeof n==`object`&&!Array.isArray(n))for(let[e,t]of Object.entries(n))Object.hasOwn(i,e)&&!Array.isArray(t)&&r.push(ww(t))}return r.reduce((e,n)=>{let r=Tw(n,t);return{...e,...r,properties:{...Ew(e),...Ew(r)},required:[...new Set([...Array.isArray(e.required)?e.required:[],...Array.isArray(r.required)?r.required:[]])]}},e)}function jw(e,t){return ww(Array.isArray(e.prefixItems)?e.prefixItems[t]??e.items:Array.isArray(e.items)?e.items[t]??e.additionalItems:e.items)}function Mw({schema:e,root:t=e,template:n,onChange:r,choices:i=[],label:a=`Arguments`,depth:o=0}){let[s,c]=(0,H.useState)(``),[l,u]=(0,H.useState)(0),d=Aw(Tw(e,t),t,Dw(n)),f=Array.isArray(d.oneOf)?d.oneOf:Array.isArray(d.anyOf)?d.anyOf:Array.isArray(d.type)?d.type.map(e=>({type:e})):[],p=f.length?Tw(ww(f[l]),t):{},m={...d,...p,properties:{...Ew(d),...Ew(p)}},h=Ew(m),g=Dw(n),_=n.kind===`object`?`object`:n.kind===`array`?`array`:g===null?`null`:typeof g,v=(e,n,r,a)=>(0,U.jsx)(Mw,{schema:e,root:t,template:n,onChange:r,choices:i,label:a,depth:o+1});return(0,U.jsxs)(`fieldset`,{className:`grid min-w-0 gap-3 rounded-lg border p-3`,children:[(0,U.jsx)(`legend`,{className:`px-1 text-sm font-medium`,children:a}),typeof m.description==`string`&&(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:m.description}),i.length>0&&(0,U.jsxs)(Rt,{value:n.kind===`reference`?JSON.stringify(n.reference):`literal`,onValueChange:n=>{if(n===`literal`)r(kw(e,t));else{let e=i.find(e=>JSON.stringify(e.reference)===n);e&&r({kind:`reference`,reference:e.reference})}},children:[(0,U.jsx)(jt,{"aria-label":`${a} source`,children:(0,U.jsx)(It,{children:n.kind===`reference`?i.find(e=>JSON.stringify(e.reference)===JSON.stringify(n.reference))?.label??`Unavailable reference`:`Literal value`})}),(0,U.jsxs)(At,{children:[(0,U.jsx)(Ct,{value:`literal`,children:`Literal value`}),i.map(e=>(0,U.jsx)(Ct,{value:JSON.stringify(e.reference),children:e.label},e.label))]})]}),n.kind!==`reference`&&(0,U.jsxs)(U.Fragment,{children:[f.length>0&&(0,U.jsxs)(Rt,{value:l,onValueChange:e=>{e!==null&&(u(e),r(kw(ww(f[e]),t)))},children:[(0,U.jsx)(jt,{"aria-label":`${a} variant`,children:(0,U.jsxs)(It,{children:[`Variant `,l+1]})}),(0,U.jsx)(At,{children:f.map((e,t)=>(0,U.jsxs)(Ct,{value:t,children:[`Variant `,t+1]},t))})]}),(0,U.jsxs)(Rt,{value:_,onValueChange:e=>{e&&r(kw({type:e}))},children:[(0,U.jsx)(jt,{"aria-label":`${a} JSON type`,children:(0,U.jsx)(It,{children:_})}),(0,U.jsx)(At,{children:[`object`,`array`,`string`,`number`,`boolean`,`null`].map(e=>(0,U.jsx)(Ct,{value:e,children:e},e))})]}),Array.isArray(m.enum)&&(0,U.jsxs)(Rt,{value:JSON.stringify(g),onValueChange:e=>{e&&r(Ow(JSON.parse(e)))},children:[(0,U.jsx)(jt,{"aria-label":`${a} enum`,children:(0,U.jsx)(It,{children:JSON.stringify(g)})}),(0,U.jsx)(At,{children:m.enum.map((e,t)=>(0,U.jsx)(Ct,{value:JSON.stringify(e),children:JSON.stringify(e)},t))})]}),n.kind===`object`&&(0,U.jsxs)(U.Fragment,{children:[[...new Set([...Object.keys(h),...Object.keys(n.fields)])].map(e=>{let i=Object.hasOwn(n.fields,e)?n.fields[e]:void 0,o=m.patternProperties&&typeof m.patternProperties==`object`&&!Array.isArray(m.patternProperties)?Object.entries(m.patternProperties).filter(([t])=>{try{return new RegExp(t).test(e)}catch{return!1}}).map(([,e])=>e):[],s=ww(Object.hasOwn(h,e)?h[e]:o.length?{allOf:o}:m.additionalProperties);return(0,U.jsxs)(`div`,{className:`grid gap-2`,children:[(0,U.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,U.jsx)(dt,{"aria-label":`Include ${a}.${e}`,checked:!!i,onCheckedChange:i=>{let a={...n.fields};i?a[e]=kw(s,t):delete a[e],r({kind:`object`,fields:a})}}),e,Array.isArray(m.required)&&m.required.includes(e)?` *`:``]}),i&&v(s,i,t=>r({kind:`object`,fields:{...n.fields,[e]:t}}),`${a}.${e}`)]},e)}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(he,{"aria-label":`${a} new property`,placeholder:`Additional property name`,value:s,onChange:e=>c(e.target.value)}),(0,U.jsx)(O,{variant:`outline`,size:`sm`,disabled:!s||[`__proto__`,`constructor`,`prototype`].includes(s),onClick:()=>{r({kind:`object`,fields:{...n.fields,[s]:kw(ww(m.additionalProperties),t)}}),c(``)},children:`Add property`})]})]}),n.kind===`array`&&(0,U.jsxs)(U.Fragment,{children:[n.items.map((e,t)=>(0,U.jsxs)(`div`,{className:`grid gap-2`,children:[v(jw(m,t),e,e=>r({kind:`array`,items:n.items.map((n,r)=>r===t?e:n)}),`${a}[${t}]`),(0,U.jsx)(O,{size:`sm`,variant:`outline`,onClick:()=>r({kind:`array`,items:n.items.filter((e,n)=>n!==t)}),children:`Remove item`})]},t)),(0,U.jsx)(O,{size:`sm`,variant:`outline`,onClick:()=>{let e=n.items.length;r({kind:`array`,items:[...n.items,kw(jw(m,e),t)]})},children:`Add item`})]}),n.kind===`literal`&&_===`boolean`&&(0,U.jsx)(dt,{"aria-label":a,checked:g===!0,onCheckedChange:e=>r({kind:`literal`,value:e})}),n.kind===`literal`&&(_===`string`||_===`number`)&&(0,U.jsx)(he,{"aria-label":a,type:_===`number`?`number`:`text`,value:g,onChange:e=>r({kind:`literal`,value:_===`number`?Number(e.target.value):e.target.value})})]}),(0,U.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,U.jsx)(`summary`,{children:`Original schema and constraints`}),(0,U.jsx)(`pre`,{className:`overflow-auto whitespace-pre-wrap`,children:JSON.stringify(e,null,2)})]})]})}function Nw({schema:e,value:t,onChange:n,label:r}){return(0,U.jsx)(Mw,{schema:e,template:Ow(t),label:r,onChange:e=>{let t=Dw(e);t!==void 0&&n(t)}})}function Pw(e){return e===`object`?{type:e,fields:{}}:e===`array`?{type:e,items:{type:`string`}}:e===`enum`?{type:e,values:[`value`]}:e===`union`?{type:e,variants:[{type:`string`}]}:{type:e}}function Fw(e){switch(e.type){case`json`:return{};case`null`:return null;case`object`:return Object.fromEntries(Object.entries(e.fields).filter(([,e])=>e.required||e.default!==void 0).map(([e,t])=>[e,t.default??Fw(t.schema)]));case`array`:return[];case`number`:return 0;case`boolean`:return!1;case`enum`:return e.values[0]??``;case`union`:return Fw(e.variants[0]);default:return``}}function Iw({schema:e,value:t,onChange:n,onClear:r,label:i=`Value`}){let[a,o]=(0,H.useState)(0);if(e.type===`json`)return(0,U.jsx)(Nw,{schema:e.schema??!0,value:t??null,label:i,onChange:n});if(e.type===`null`)return(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`null`});if(e.type===`object`){let r=t&&typeof t==`object`&&!Array.isArray(t)?t:{};return(0,U.jsx)(`div`,{className:`grid gap-3`,children:Object.entries(e.fields).map(([e,t])=>(0,U.jsxs)(`div`,{className:`grid gap-2`,children:[(0,U.jsxs)(`span`,{className:`text-sm font-medium`,children:[e,t.required?` *`:``]}),!t.required&&(0,U.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,U.jsx)(dt,{"aria-label":`Include ${e}`,checked:Object.hasOwn(r,e),onCheckedChange:i=>{let a={...r};i?a[e]=t.default??Fw(t.schema):delete a[e],n(a)}}),`Include`]}),(0,U.jsx)(Iw,{schema:t.schema,label:i===`Value`?e:`${i}.${e}`,value:r[e]??t.default,onClear:()=>{let t={...r};delete t[e],n(t)},onChange:t=>n({...r,[e]:t})})]},e))})}return e.type===`array`?(0,U.jsxs)(`div`,{className:`grid gap-2`,children:[(Array.isArray(t)?t:[]).map((r,a)=>(0,U.jsxs)(`div`,{className:`grid gap-2 rounded-lg border p-3`,children:[(0,U.jsx)(Iw,{schema:e.items,label:`${i} item ${a+1}`,value:r,onChange:e=>n(t.map((t,n)=>n===a?e:t))}),(0,U.jsx)(O,{size:`sm`,variant:`destructive`,className:`justify-self-start`,onClick:()=>n(t.filter((e,t)=>t!==a)),children:`Remove item`})]},a)),(0,U.jsx)(O,{size:`sm`,variant:`outline`,className:`justify-self-start`,onClick:()=>n([...Array.isArray(t)?t:[],Fw(e.items)]),children:`Add item`})]}):e.type===`union`?(0,U.jsxs)(`div`,{className:`grid gap-2`,children:[(0,U.jsxs)(Rt,{value:a,onValueChange:t=>{t!==null&&(o(t),n(Fw(e.variants[t])))},children:[(0,U.jsx)(jt,{className:`w-full`,"aria-label":i===`Value`?`Input variant`:`${i} variant`,children:(0,U.jsx)(It,{children:`Variant ${a+1}: ${e.variants[a]?.type??``}`})}),(0,U.jsx)(At,{children:e.variants.map((e,t)=>(0,U.jsxs)(Ct,{value:t,children:[`Variant `,t+1,`: `,e.type]},t))})]}),(0,U.jsx)(Iw,{schema:e.variants[a]??e.variants[0],label:i,value:t,onChange:n})]}):e.type===`boolean`?(0,U.jsx)(dt,{"aria-label":i,checked:t===!0,onCheckedChange:n}):e.type===`enum`?(0,U.jsxs)(Rt,{value:typeof t==`string`?t:``,onValueChange:e=>{e!==null&&n(e)},children:[(0,U.jsx)(jt,{className:`w-full`,"aria-label":i,children:(0,U.jsx)(It,{children:typeof t==`string`&&t?t:`Select`})}),(0,U.jsxs)(At,{children:[!e.values.includes(``)&&(0,U.jsx)(Ct,{value:``,children:`Select`}),e.values.map(e=>(0,U.jsx)(Ct,{value:e,children:e||`Empty string`},e))]})]}):(0,U.jsx)(he,{"aria-label":i,type:e.type===`number`?`number`:`text`,value:typeof t==`string`||typeof t==`number`?t:``,onChange:t=>e.type===`number`&&t.target.value===``&&r?r():n(e.type===`number`?t.target.value===``?null:Number(t.target.value):t.target.value)})}function Lw({schema:e,onChange:t,root:n=!1}){return(0,U.jsxs)(`fieldset`,{className:`grid min-w-0 gap-3 rounded-lg border p-3`,children:[(0,U.jsx)(`legend`,{className:`px-1 text-sm font-medium`,children:`Schema`}),!n&&(0,U.jsxs)(Rt,{value:e.type,onValueChange:e=>{e!==null&&t(Pw(e))},children:[(0,U.jsx)(jt,{className:`w-full`,"aria-label":`Schema type`,children:(0,U.jsx)(It,{children:e.type})}),(0,U.jsx)(At,{children:[`object`,`array`,`string`,`number`,`boolean`,`enum`,`json`,`null`].map(e=>(0,U.jsx)(Ct,{value:e,children:e},e))})]}),e.type===`enum`&&(0,U.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,U.jsx)(`span`,{className:`font-medium`,children:`Values (one per line)`}),(0,U.jsx)(Fo,{value:e.values.join(`
|
|
139
139
|
`),onChange:n=>t({...e,values:n.target.value.split(`
|
|
140
|
-
`)})})]}),e.type===`array`&&(0,U.jsx)(Ow,{schema:e.items,onChange:n=>t({...e,items:n})}),e.type===`object`&&(0,U.jsxs)(U.Fragment,{children:[Object.entries(e.fields).map(([n,r])=>(0,U.jsxs)(`fieldset`,{className:`grid min-w-0 gap-3 rounded-lg border p-3`,children:[(0,U.jsx)(`legend`,{className:`px-1 text-sm font-medium`,children:n}),(0,U.jsx)(O,{size:`sm`,variant:`destructive`,className:`justify-self-start`,onClick:()=>t({...e,fields:Object.fromEntries(Object.entries(e.fields).filter(([e])=>e!==n))}),children:`Remove field`}),(0,U.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,U.jsx)(dt,{checked:!!r.required,onCheckedChange:i=>t({...e,fields:{...e.fields,[n]:{...r,required:i}}})}),`Required`]}),(0,U.jsx)(Ow,{schema:r.schema,onChange:i=>t({...e,fields:{...e.fields,[n]:{...r,schema:i}}})}),(0,U.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,U.jsx)(dt,{checked:r.default!==void 0,onCheckedChange:i=>{let a={...r};i?a.default=Ew(r.schema):delete a.default,t({...e,fields:{...e.fields,[n]:a}})}}),`Default`]}),r.default!==void 0&&(0,U.jsx)(Dw,{schema:r.schema,value:r.default,onChange:i=>t({...e,fields:{...e.fields,[n]:{...r,default:i}}})})]},n)),(0,U.jsxs)(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:n=>{n.preventDefault();let r=n.currentTarget,i=String(new FormData(r).get(`field`));i&&![`__proto__`,`constructor`,`prototype`].includes(i)&&!e.fields[i]&&(t({...e,fields:{...e.fields,[i]:{schema:{type:`string`}}}}),r.reset())},children:[(0,U.jsx)(he,{className:`min-w-0 flex-1`,name:`field`,"aria-label":`New field name`,placeholder:`Field name`,required:!0}),(0,U.jsx)(O,{type:`submit`,size:`sm`,variant:`outline`,children:`Add field`})]})]})]})}function kw(e,t){return{...e,workflowId:t.id,contract:structuredClone(t.contract)}}function Aw(e,t){let n=[],r=new Set;for(let i=t||void 0;i!==void 0;){let t=e.invocations?.[i];if(!t||r.has(i))break;r.add(i);let a=t.parentInvocationId?e.invocations?.[t.parentInvocationId]:void 0,o=a?e.retainedDefinitions?.[a.definitionId]:e.definition;n.unshift({id:i,name:e.retainedDefinitions?.[t.definitionId]?.name??t.definitionId,call:o?.steps.find(e=>e.id===t.callStepId)?.name??t.callStepId,attempt:t.callAttempt}),i=t.parentInvocationId}return n}function jw(e,t,n,r){return`stepId=${encodeURIComponent(e)}${n?``:`&attempt=${t}`}${r?`&invocationId=${encodeURIComponent(r)}`:``}`}var Mw=e(ve(),1);function Nw(e){return{x:e%3*286,y:Math.floor(e/3)*270}}function Pw(e){let t;try{t=new Set(IC(e).loops.map(e=>e.headerId))}catch{t=new Set(e.steps.filter(t=>{let n=e.edges.filter(e=>e.from===t.id).map(e=>e.to),r=new Set;for(;n.length;){let i=n.pop();if(i===t.id)return!0;r.has(i)||(r.add(i),n.push(...e.edges.filter(e=>e.from===i).map(e=>e.to)))}return!1}).map(e=>e.id))}return{...e,loopSettings:Object.fromEntries(Object.entries(e.loopSettings??{}).filter(([e])=>t.has(e))),steps:e.steps.map(e=>{if(t.has(e.id)||!e.repeatMapping)return e;let n={...e};return delete n.repeatMapping,n})}}function Fw(e,{orientation:t=`horizontal`}={}){let n=IC(e).loops,r=new Map(e.steps.map((e,t)=>[e.id,e.position??Nw(t)])),i=new Map;for(let e of[...n].reverse()){let a=n.filter(t=>t.parentHeaderId===e.headerId),o=[...e.memberIds.filter(e=>!a.some(t=>t.memberIds.includes(e))).map(e=>({...r.get(e),width:208,height:192})),...a.map(e=>i.get(e.headerId))],s=Math.min(...o.map(e=>e.x)),c=Math.min(...o.map(e=>e.y)),l=Math.max(...o.map(e=>e.x+e.width)),u=Math.max(...o.map(e=>e.y+e.height)),d=t===`vertical`,f=s-(d?264:24),p=c-(d?24:112);i.set(e.headerId,{x:f,y:p,width:d?l+24-f:Math.max(360,l+24-f),height:u+24-p})}let a=`loop:`;for(;e.steps.some(e=>e.id.startsWith(a));)a+=`:`;let o=e=>`${a}${e}`,s=(e,t)=>{let n=t?i.get(t):{x:0,y:0};return{x:e.x-n.x,y:e.y-n.y}};return[...n.map(e=>({id:o(e.headerId),type:`loop`,...e.parentHeaderId?{parentId:o(e.parentHeaderId)}:{},position:s(i.get(e.headerId),e.parentHeaderId),style:{width:i.get(e.headerId).width,height:i.get(e.headerId).height},selectable:!1,deletable:!1,draggable:!1,connectable:!1,zIndex:1,data:{headerId:e.headerId,orientation:t}})),...e.steps.map(e=>{let t=[...n].reverse().find(t=>t.memberIds.includes(e.id));return{id:e.id,type:`workflow`,...t?{parentId:o(t.headerId)}:{},position:s(r.get(e.id),t?.headerId),zIndex:2,data:{step:e}}})]}function Iw(e,t){let n=t.find(t=>t.id===e.parentId),r=n?Iw(n,t):{x:0,y:0};return{x:e.position.x+r.x,y:e.position.y+r.y}}function Lw(e,t){let n=t+e.grants.filter(t=>t.activation===e.activation).length,r=e.try;return`${e.phase===`inactive`?`Not started`:`Try ${r} of ${n}`} · ${e.phase===`limit`?`Loop limit reached`:e.phase}`}function Rw(e){return Object.entries(e.loops??{}).filter(([,e])=>e.phase===`limit`)}function zw(e,t){if(t===void 0)return`In progress`;let n=Math.max(0,Math.floor((t-e)/1e3));return[[Math.floor(n/3600),`h`],[Math.floor(n/60)%60,`m`],[n%60,`s`]].filter(([e])=>e!==0).map(([e,t])=>`${e}${t}`).join(` `)||`0s`}var Bw=.1,Vw=.05;function Hw(e,t){let n=IC(e),r=new Set(n.loops.flatMap(e=>e.backEdgeIds)),i=new Map(e.steps.map(e=>[e.id,[]]));for(let t of e.edges)r.has(t.id)||i.get(t.to).push(t.from);let a=new Map,o=new Map(e.edges.map(e=>[e.id,e]));for(let e of n.loops)for(let t of e.exitEdgeIds){if(r.has(t))continue;let n=o.get(t)?.to;n&&a.set(n,[...a.get(n)??[],e])}let s=new Map,c=!0;for(;c;){c=!1;for(let e of n.order){let t=Math.max(-1,...i.get(e).map(e=>s.get(e)??-1),...(a.get(e)??[]).flatMap(e=>e.memberIds.map(e=>s.get(e)??-1)))+1;(s.get(e)??-1)<t&&(s.set(e,t),c=!0)}}let l=new Map(n.loops.map(e=>[e.headerId,e])),u=e=>{let t=0,r=[...n.loops].reverse().find(t=>t.memberIds.includes(e));for(;r;)t++,r=r.parentHeaderId?l.get(r.parentHeaderId):void 0;return t},d=Math.max(0,...e.steps.map(e=>u(e.id))),f=new Map,p=(t,r)=>{let i=n.loops.filter(e=>e.parentHeaderId===t),a=new Set(i.flatMap(e=>e.memberIds)),o=t?l.get(t):void 0,c=e.steps.filter(e=>(o?o.memberIds.includes(e.id):u(e.id)===0)&&!a.has(e.id)),d=new Map;for(let e of c){let t=s.get(e.id)??0,n=d.get(t)??0;f.set(e.id,r+n),d.set(t,n+1)}let m=r+Math.max(1,...d.values());for(let e of i)m+=p(e.headerId,m);return m-r};p(void 0,0);let m=t?310+d*288:270+d*136,h=t?220+d*2*24:350+d*2*24;return{...e,steps:e.steps.map(e=>{let n=s.get(e.id)??0,r=f.get(e.id)??0;return{...e,position:t?{x:r*m,y:n*h}:{x:n*h,y:r*m}}})}}function Uw(e){if(typeof e==`string`||typeof e==`number`)return``+e;let t=``;if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=Uw(e[n]))!==``&&(t+=(t&&` `)+r);else for(let n in e)e[n]&&(t+=(t&&` `)+n);return t}var Ww={value:()=>{}};function Gw(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+``)||r in n||/[\s.]/.test(r))throw Error(`illegal type: `+r);n[r]=[]}return new Kw(n)}function Kw(e){this._=e}function qw(e,t){return e.trim().split(/^|\s+/).map(function(e){var n=``,r=e.indexOf(`.`);if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}Kw.prototype=Gw.prototype={constructor:Kw,on:function(e,t){var n=this._,r=qw(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=Jw(n[i],e.name)))return i;return}if(t!=null&&typeof t!=`function`)throw Error(`invalid callback: `+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=Yw(n[i],e.name,t);else if(t==null)for(i in n)n[i]=Yw(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Kw(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function Jw(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function Yw(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=Ww,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Xw={svg:`http://www.w3.org/2000/svg`,xhtml:`http://www.w3.org/1999/xhtml`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function Zw(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),Xw.hasOwnProperty(t)?{space:Xw[t],local:e}:e}function Qw(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function $w(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function eT(e){var t=Zw(e);return(t.local?$w:Qw)(t)}function tT(){}function nT(e){return e==null?tT:function(){return this.querySelector(e)}}function rT(e){typeof e!=`function`&&(e=nT(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=Array(o),c,l,u=0;u<o;++u)(c=a[u])&&(l=e.call(c,c.__data__,u,a))&&(`__data__`in c&&(l.__data__=c.__data__),s[u]=l);return new GE(r,this._parents)}function iT(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function aT(){return[]}function oT(e){return e==null?aT:function(){return this.querySelectorAll(e)}}function sT(e){return function(){return iT(e.apply(this,arguments))}}function cT(e){e=typeof e==`function`?sT(e):oT(e);for(var t=this._groups,n=t.length,r=[],i=[],a=0;a<n;++a)for(var o=t[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),i.push(c));return new GE(r,i)}function lT(e){return function(){return this.matches(e)}}function uT(e){return function(t){return t.matches(e)}}var dT=Array.prototype.find;function fT(e){return function(){return dT.call(this.children,e)}}function pT(){return this.firstElementChild}function mT(e){return this.select(e==null?pT:fT(typeof e==`function`?e:uT(e)))}var hT=Array.prototype.filter;function gT(){return Array.from(this.children)}function _T(e){return function(){return hT.call(this.children,e)}}function vT(e){return this.selectAll(e==null?gT:_T(typeof e==`function`?e:uT(e)))}function yT(e){typeof e!=`function`&&(e=lT(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new GE(r,this._parents)}function bT(e){return Array(e.length)}function xT(){return new GE(this._enter||this._groups.map(bT),this._parents)}function ST(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}ST.prototype={constructor:ST,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function CT(e){return function(){return e}}function wT(e,t,n,r,i,a){for(var o=0,s,c=t.length,l=a.length;o<l;++o)(s=t[o])?(s.__data__=a[o],r[o]=s):n[o]=new ST(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function TT(e,t,n,r,i,a,o){var s,c,l=new Map,u=t.length,d=a.length,f=Array(u),p;for(s=0;s<u;++s)(c=t[s])&&(f[s]=p=o.call(c,c.__data__,s,t)+``,l.has(p)?i[s]=c:l.set(p,c));for(s=0;s<d;++s)p=o.call(e,a[s],s,a)+``,(c=l.get(p))?(r[s]=c,c.__data__=a[s],l.delete(p)):n[s]=new ST(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function ET(e){return e.__data__}function DT(e,t){if(!arguments.length)return Array.from(this,ET);var n=t?TT:wT,r=this._parents,i=this._groups;typeof e!=`function`&&(e=CT(e));for(var a=i.length,o=Array(a),s=Array(a),c=Array(a),l=0;l<a;++l){var u=r[l],d=i[l],f=d.length,p=OT(e.call(u,u&&u.__data__,l,r)),m=p.length,h=s[l]=Array(m),g=o[l]=Array(m);n(u,d,h,g,c[l]=Array(f),p,t);for(var _=0,v=0,y,b;_<m;++_)if(y=h[_]){for(_>=v&&(v=_+1);!(b=g[v])&&++v<m;);y._next=b||null}}return o=new GE(o,r),o._enter=s,o._exit=c,o}function OT(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function kT(){return new GE(this._exit||this._groups.map(bT),this._parents)}function AT(e,t,n){var r=this.enter(),i=this,a=this.exit();return typeof e==`function`?(r=e(r),r&&=r.selection()):r=r.append(e+``),t!=null&&(i=t(i),i&&=i.selection()),n==null?a.remove():n(a),r&&i?r.merge(i).order():i}function jT(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,a=r.length,o=Math.min(i,a),s=Array(i),c=0;c<o;++c)for(var l=n[c],u=r[c],d=l.length,f=s[c]=Array(d),p,m=0;m<d;++m)(p=l[m]||u[m])&&(f[m]=p);for(;c<i;++c)s[c]=n[c];return new GE(s,this._parents)}function MT(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,a=r[i],o;--i>=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function NT(e){e||=PT;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;a<r;++a){for(var o=n[a],s=o.length,c=i[a]=Array(s),l,u=0;u<s;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new GE(i,this._parents).order()}function PT(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function FT(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function IT(){return Array.from(this)}function LT(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null}function RT(){let e=0;for(let t of this)++e;return e}function zT(){return!this.node()}function BT(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],a=0,o=i.length,s;a<o;++a)(s=i[a])&&e.call(s,s.__data__,a,i);return this}function VT(e){return function(){this.removeAttribute(e)}}function HT(e){return function(){this.removeAttributeNS(e.space,e.local)}}function UT(e,t){return function(){this.setAttribute(e,t)}}function WT(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function GT(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function KT(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function qT(e,t){var n=Zw(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?HT:VT:typeof t==`function`?n.local?KT:GT:n.local?WT:UT)(n,t))}function JT(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function YT(e){return function(){this.style.removeProperty(e)}}function XT(e,t,n){return function(){this.style.setProperty(e,t,n)}}function ZT(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function QT(e,t,n){return arguments.length>1?this.each((t==null?YT:typeof t==`function`?ZT:XT)(e,t,n??``)):$T(this.node(),e)}function $T(e,t){return e.style.getPropertyValue(t)||JT(e).getComputedStyle(e,null).getPropertyValue(t)}function eE(e){return function(){delete this[e]}}function tE(e,t){return function(){this[e]=t}}function nE(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function rE(e,t){return arguments.length>1?this.each((t==null?eE:typeof t==`function`?nE:tE)(e,t)):this.node()[e]}function iE(e){return e.trim().split(/^|\s+/)}function aE(e){return e.classList||new oE(e)}function oE(e){this._node=e,this._names=iE(e.getAttribute(`class`)||``)}oE.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function sE(e,t){for(var n=aE(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function cE(e,t){for(var n=aE(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function lE(e){return function(){sE(this,e)}}function uE(e){return function(){cE(this,e)}}function dE(e,t){return function(){(t.apply(this,arguments)?sE:cE)(this,e)}}function fE(e,t){var n=iE(e+``);if(arguments.length<2){for(var r=aE(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?dE:t?lE:uE)(n,t))}function pE(){this.textContent=``}function mE(e){return function(){this.textContent=e}}function hE(e){return function(){var t=e.apply(this,arguments);this.textContent=t??``}}function gE(e){return arguments.length?this.each(e==null?pE:(typeof e==`function`?hE:mE)(e)):this.node().textContent}function _E(){this.innerHTML=``}function vE(e){return function(){this.innerHTML=e}}function yE(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??``}}function bE(e){return arguments.length?this.each(e==null?_E:(typeof e==`function`?yE:vE)(e)):this.node().innerHTML}function xE(){this.nextSibling&&this.parentNode.appendChild(this)}function SE(){return this.each(xE)}function CE(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function wE(){return this.each(CE)}function TE(e){var t=typeof e==`function`?e:eT(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function EE(){return null}function DE(e,t){var n=typeof e==`function`?e:eT(e),r=t==null?EE:typeof t==`function`?t:nT(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function OE(){var e=this.parentNode;e&&e.removeChild(this)}function kE(){return this.each(OE)}function AE(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function jE(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function ME(e){return this.select(e?jE:AE)}function NE(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function PE(e){return function(t){e.call(this,t,this.__data__)}}function FE(e){return e.trim().split(/^|\s+/).map(function(e){var t=``,n=e.indexOf(`.`);return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function IE(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n<i;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function LE(e,t,n){return function(){var r=this.__on,i,a=PE(t);if(r){for(var o=0,s=r.length;o<s;++o)if((i=r[o]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=n),i.value=t;return}}this.addEventListener(e.type,a,n),i={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(i):this.__on=[i]}}function RE(e,t,n){var r=FE(e+``),i,a=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,l=s.length,u;c<l;++c)for(i=0,u=s[c];i<a;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}return}for(s=t?LE:IE,i=0;i<a;++i)this.each(s(r[i],t,n));return this}function zE(e,t,n){var r=JT(e),i=r.CustomEvent;typeof i==`function`?i=new i(t,n):(i=r.document.createEvent(`Event`),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function BE(e,t){return function(){return zE(this,e,t)}}function VE(e,t){return function(){return zE(this,e,t.apply(this,arguments))}}function HE(e,t){return this.each((typeof t==`function`?VE:BE)(e,t))}function*UE(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length,o;i<a;++i)(o=r[i])&&(yield o)}var WE=[null];function GE(e,t){this._groups=e,this._parents=t}function KE(){return new GE([[document.documentElement]],WE)}function qE(){return this}GE.prototype=KE.prototype={constructor:GE,select:rT,selectAll:cT,selectChild:mT,selectChildren:vT,filter:yT,data:DT,enter:xT,exit:kT,join:AT,merge:jT,selection:qE,order:MT,sort:NT,call:FT,nodes:IT,node:LT,size:RT,empty:zT,each:BT,attr:qT,style:QT,property:rE,classed:fE,text:gE,html:bE,raise:SE,lower:wE,append:TE,insert:DE,remove:kE,clone:ME,datum:NE,on:RE,dispatch:HE,[Symbol.iterator]:UE};function JE(e){return typeof e==`string`?new GE([[document.querySelector(e)]],[document.documentElement]):new GE([[e]],WE)}function YE(e){let t;for(;t=e.sourceEvent;)e=t;return e}function XE(e,t){if(e=YE(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}var ZE={passive:!1},QE={capture:!0,passive:!1};function $E(e){e.stopImmediatePropagation()}function eD(e){e.preventDefault(),e.stopImmediatePropagation()}function tD(e){var t=e.document.documentElement,n=JE(e).on(`dragstart.drag`,eD,QE);`onselectstart`in t?n.on(`selectstart.drag`,eD,QE):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect=`none`)}function nD(e,t){var n=e.document.documentElement,r=JE(e).on(`dragstart.drag`,null);t&&(r.on(`click.drag`,eD,QE),setTimeout(function(){r.on(`click.drag`,null)},0)),`onselectstart`in n?r.on(`selectstart.drag`,null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var rD=e=>()=>e;function iD(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}iD.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function aD(e){return!e.ctrlKey&&!e.button}function oD(){return this.parentNode}function sD(e,t){return t??{x:e.x,y:e.y}}function cD(){return navigator.maxTouchPoints||`ontouchstart`in this}function lD(){var e=aD,t=oD,n=sD,r=cD,i={},a=Gw(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,g).on(`touchmove.drag`,_,ZE).on(`touchend.drag touchcancel.drag`,v).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!(u||!e.call(this,n,r))){var i=y(this,t.call(this,n,r),n,r,`mouse`);i&&(JE(n.view).on(`mousemove.drag`,m,QE).on(`mouseup.drag`,h,QE),tD(n.view),$E(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(eD(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){JE(e.view).on(`mousemove.drag mouseup.drag`,null),nD(e.view,l),eD(e),i.mouse(`end`,e)}function g(n,r){if(e.call(this,n,r)){var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s,c;for(s=0;s<o;++s)(c=y(this,a,n,r,i[s].identifier,i[s]))&&($E(n),c(`start`,n,i[s]))}}function _(e){var t=e.changedTouches,n=t.length,r,a;for(r=0;r<n;++r)(a=i[t[r].identifier])&&(eD(e),a(`drag`,e,t[r]))}function v(e){var t=e.changedTouches,n=t.length,r,a;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),r=0;r<n;++r)(a=i[t[r].identifier])&&($E(e),a(`end`,e,t[r]))}function y(e,t,r,s,c,l){var u=a.copy(),d=XE(l||r,t),p,m,h;if((h=n.call(e,new iD(`beforestart`,{sourceEvent:r,target:f,identifier:c,active:o,x:d[0],y:d[1],dx:0,dy:0,dispatch:u}),s))!=null)return p=h.x-d[0]||0,m=h.y-d[1]||0,function n(r,a,l){var g=d,_;switch(r){case`start`:i[c]=n,_=o++;break;case`end`:delete i[c],--o;case`drag`:d=XE(l||a,t),_=o}u.call(r,e,new iD(r,{sourceEvent:a,subject:h,target:f,identifier:c,active:_,x:d[0]+p,y:d[1]+m,dx:d[0]-g[0],dy:d[1]-g[1],dispatch:u}),s)}}return f.filter=function(t){return arguments.length?(e=typeof t==`function`?t:rD(!!t),f):e},f.container=function(e){return arguments.length?(t=typeof e==`function`?e:rD(e),f):t},f.subject=function(e){return arguments.length?(n=typeof e==`function`?e:rD(e),f):n},f.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:rD(!!e),f):r},f.on=function(){var e=a.on.apply(a,arguments);return e===a?f:e},f.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,f):Math.sqrt(d)},f}function uD(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function dD(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function fD(){}var pD=.7,mD=1/pD,hD=`\\s*([+-]?\\d+)\\s*`,gD=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,_D=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,vD=/^#([0-9a-f]{3,8})$/,yD=RegExp(`^rgb\\(${hD},${hD},${hD}\\)$`),bD=RegExp(`^rgb\\(${_D},${_D},${_D}\\)$`),xD=RegExp(`^rgba\\(${hD},${hD},${hD},${gD}\\)$`),SD=RegExp(`^rgba\\(${_D},${_D},${_D},${gD}\\)$`),CD=RegExp(`^hsl\\(${gD},${_D},${_D}\\)$`),wD=RegExp(`^hsla\\(${gD},${_D},${_D},${gD}\\)$`),TD={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};uD(fD,AD,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:ED,formatHex:ED,formatHex8:DD,formatHsl:OD,formatRgb:kD,toString:kD});function ED(){return this.rgb().formatHex()}function DD(){return this.rgb().formatHex8()}function OD(){return UD(this).formatHsl()}function kD(){return this.rgb().formatRgb()}function AD(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=vD.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?jD(t):n===3?new FD(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?MD(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?MD(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=yD.exec(e))?new FD(t[1],t[2],t[3],1):(t=bD.exec(e))?new FD(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=xD.exec(e))?MD(t[1],t[2],t[3],t[4]):(t=SD.exec(e))?MD(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=CD.exec(e))?HD(t[1],t[2]/100,t[3]/100,1):(t=wD.exec(e))?HD(t[1],t[2]/100,t[3]/100,t[4]):TD.hasOwnProperty(e)?jD(TD[e]):e===`transparent`?new FD(NaN,NaN,NaN,0):null}function jD(e){return new FD(e>>16&255,e>>8&255,e&255,1)}function MD(e,t,n,r){return r<=0&&(e=t=n=NaN),new FD(e,t,n,r)}function ND(e){return e instanceof fD||(e=AD(e)),e?(e=e.rgb(),new FD(e.r,e.g,e.b,e.opacity)):new FD}function PD(e,t,n,r){return arguments.length===1?ND(e):new FD(e,t,n,r??1)}function FD(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}uD(FD,PD,dD(fD,{brighter(e){return e=e==null?mD:mD**+e,new FD(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?pD:pD**+e,new FD(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new FD(BD(this.r),BD(this.g),BD(this.b),zD(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:ID,formatHex:ID,formatHex8:LD,formatRgb:RD,toString:RD}));function ID(){return`#${VD(this.r)}${VD(this.g)}${VD(this.b)}`}function LD(){return`#${VD(this.r)}${VD(this.g)}${VD(this.b)}${VD((isNaN(this.opacity)?1:this.opacity)*255)}`}function RD(){let e=zD(this.opacity);return`${e===1?`rgb(`:`rgba(`}${BD(this.r)}, ${BD(this.g)}, ${BD(this.b)}${e===1?`)`:`, ${e})`}`}function zD(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function BD(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function VD(e){return e=BD(e),(e<16?`0`:``)+e.toString(16)}function HD(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new GD(e,t,n,r)}function UD(e){if(e instanceof GD)return new GD(e.h,e.s,e.l,e.opacity);if(e instanceof fD||(e=AD(e)),!e)return new GD;if(e instanceof GD)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new GD(o,s,c,e.opacity)}function WD(e,t,n,r){return arguments.length===1?UD(e):new GD(e,t,n,r??1)}function GD(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}uD(GD,WD,dD(fD,{brighter(e){return e=e==null?mD:mD**+e,new GD(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?pD:pD**+e,new GD(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new FD(JD(e>=240?e-240:e+120,i,r),JD(e,i,r),JD(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new GD(KD(this.h),qD(this.s),qD(this.l),zD(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=zD(this.opacity);return`${e===1?`hsl(`:`hsla(`}${KD(this.h)}, ${qD(this.s)*100}%, ${qD(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function KD(e){return e=(e||0)%360,e<0?e+360:e}function qD(e){return Math.max(0,Math.min(1,e||0))}function JD(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var YD=e=>()=>e;function XD(e,t){return function(n){return e+n*t}}function ZD(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function QD(e){return(e=+e)==1?$D:function(t,n){return n-t?ZD(t,n,e):YD(isNaN(t)?n:t)}}function $D(e,t){var n=t-e;return n?XD(e,n):YD(isNaN(e)?t:e)}var eO=(function e(t){var n=QD(t);function r(e,t){var r=n((e=PD(e)).r,(t=PD(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=$D(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function tO(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=e[i]*(1-a)+t[i]*a;return r}}function nO(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function rO(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=Array(r),a=Array(n),o;for(o=0;o<r;++o)i[o]=fO(e[o],t[o]);for(;o<n;++o)a[o]=t[o];return function(e){for(o=0;o<r;++o)a[o]=i[o](e);return a}}function iO(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function aO(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function oO(e,t){var n={},r={},i;for(i in(typeof e!=`object`||!e)&&(e={}),(typeof t!=`object`||!t)&&(t={}),t)i in e?n[i]=fO(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var sO=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,cO=new RegExp(sO.source,`g`);function lO(e){return function(){return e}}function uO(e){return function(t){return e(t)+``}}function dO(e,t){var n=sO.lastIndex=cO.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=sO.exec(e))&&(i=cO.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:aO(r,i)})),n=cO.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?uO(c[0].x):lO(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}function fO(e,t){var n=typeof t,r;return t==null||n===`boolean`?YD(t):(n===`number`?aO:n===`string`?(r=AD(t))?(t=r,eO):dO:t instanceof AD?eO:t instanceof Date?iO:nO(t)?tO:Array.isArray(t)?rO:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?oO:aO)(e,t)}var pO=180/Math.PI,mO={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function hO(e,t,n,r,i,a){var o,s,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*pO,skewX:Math.atan(c)*pO,scaleX:o,scaleY:s}}var gO;function _O(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?mO:hO(t.a,t.b,t.c,t.d,t.e,t.f)}function vO(e){return e==null||(gO||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),gO.setAttribute(`transform`,e),!(e=gO.transform.baseVal.consolidate()))?mO:(e=e.matrix,hO(e.a,e.b,e.c,e.d,e.e,e.f))}function yO(e,t,n,r){function i(e){return e.length?e.pop()+` `:``}function a(e,r,i,a,o,s){if(e!==i||r!==a){var c=o.push(`translate(`,null,t,null,n);s.push({i:c-4,x:aO(e,i)},{i:c-2,x:aO(r,a)})}else(i||a)&&o.push(`translate(`+i+t+a+n)}function o(e,t,n,a){e===t?t&&n.push(i(n)+`rotate(`+t+r):(e-t>180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:aO(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:aO(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:aO(e,n)},{i:s-2,x:aO(t,r)})}else(n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t<n;)r[(a=i[t]).i]=a.x(e);return r.join(``)}}}var bO=yO(_O,`px, `,`px)`,`deg)`),xO=yO(vO,`, `,`)`,`)`),SO=1e-12;function CO(e){return((e=Math.exp(e))+1/e)/2}function wO(e){return((e=Math.exp(e))-1/e)/2}function TO(e){return((e=Math.exp(2*e))-1)/(e+1)}var EO=(function e(t,n,r){function i(e,i){var a=e[0],o=e[1],s=e[2],c=i[0],l=i[1],u=i[2],d=c-a,f=l-o,p=d*d+f*f,m,h;if(p<SO)h=Math.log(u/s)/t,m=function(e){return[a+e*d,o+e*f,s*Math.exp(t*e*h)]};else{var g=Math.sqrt(p),_=(u*u-s*s+r*p)/(2*s*n*g),v=(u*u-s*s-r*p)/(2*u*n*g),y=Math.log(Math.sqrt(_*_+1)-_);h=(Math.log(Math.sqrt(v*v+1)-v)-y)/t,m=function(e){var r=e*h,i=CO(y),c=s/(n*g)*(i*TO(t*r+y)-wO(y));return[a+c*d,o+c*f,s*i/CO(t*r+y)]}}return m.duration=h*1e3*t/Math.SQRT2,m}return i.rho=function(t){var n=Math.max(.001,+t),r=n*n;return e(n,r,r*r)},i})(Math.SQRT2,2,4),DO=0,OO=0,kO=0,AO=1e3,jO,MO,NO=0,PO=0,FO=0,IO=typeof performance==`object`&&performance.now?performance:Date,LO=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function RO(){return PO||=(LO(zO),IO.now()+FO)}function zO(){PO=0}function BO(){this._call=this._time=this._next=null}BO.prototype=VO.prototype={constructor:BO,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?RO():+n)+(t==null?0:+t),!this._next&&MO!==this&&(MO?MO._next=this:jO=this,MO=this),this._call=e,this._time=n,KO()},stop:function(){this._call&&(this._call=null,this._time=1/0,KO())}};function VO(e,t,n){var r=new BO;return r.restart(e,t,n),r}function HO(){RO(),++DO;for(var e=jO,t;e;)(t=PO-e._time)>=0&&e._call.call(void 0,t),e=e._next;--DO}function UO(){PO=(NO=IO.now())+FO,DO=OO=0;try{HO()}finally{DO=0,GO(),PO=0}}function WO(){var e=IO.now(),t=e-NO;t>AO&&(FO-=t,NO=e)}function GO(){for(var e,t=jO,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:jO=n);MO=e,KO(r)}function KO(e){DO||(OO&&=clearTimeout(OO),e-PO>24?(e<1/0&&(OO=setTimeout(UO,e-IO.now()-FO)),kO&&=clearInterval(kO)):(kO||=(NO=IO.now(),setInterval(WO,AO)),DO=1,LO(UO)))}function qO(e,t,n){var r=new BO;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var JO=Gw(`start`,`end`,`cancel`,`interrupt`),YO=[];function XO(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;ek(e,n,{name:t,index:r,group:i,on:JO,tween:YO,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function ZO(e,t){var n=$O(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function QO(e,t){var n=$O(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function $O(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function ek(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=VO(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return qO(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l<t&&(f.state=6,f.timer.stop(),f.on.call(`cancel`,e,e.__data__,f.index,f.group),delete r[l])}if(qO(function(){n.state===3&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))}),n.state=2,n.on.call(`start`,e,e.__data__,n.index,n.group),n.state===2){for(n.state=3,i=Array(d=n.tween.length),l=0,u=-1;l<d;++l)(f=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(i[++u]=f);i.length=u+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(c),n.state=5,1),a=-1,o=i.length;++a<o;)i[a].call(e,r);n.state===5&&(n.on.call(`end`,e,e.__data__,n.index,n.group),c())}function c(){for(var i in n.state=6,n.timer.stop(),delete r[t],r)return;delete e.__transition}}function tk(e,t){var n=e.__transition,r,i,a=!0,o;if(n){for(o in t=t==null?null:t+``,n){if((r=n[o]).name!==t){a=!1;continue}i=r.state>2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]}a&&delete e.__transition}}function nk(e){return this.each(function(){tk(this,e)})}function rk(e,t){var n,r;return function(){var i=QO(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o<s;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function ik(e,t,n){var r,i;if(typeof n!=`function`)throw Error();return function(){var a=QO(this,e),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:t,value:n},c=0,l=i.length;c<l;++c)if(i[c].name===t){i[c]=s;break}c===l&&i.push(s)}a.tween=i}}function ak(e,t){var n=this._id;if(e+=``,arguments.length<2){for(var r=$O(this.node(),n).tween,i=0,a=r.length,o;i<a;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((t==null?rk:ik)(n,e,t))}function ok(e,t,n){var r=e._id;return e.each(function(){var e=QO(this,r);(e.value||={})[t]=n.apply(this,arguments)}),function(e){return $O(e,r).value[t]}}function sk(e,t){var n;return(typeof t==`number`?aO:t instanceof AD?eO:(n=AD(t))?(t=n,eO):dO)(e,t)}function ck(e){return function(){this.removeAttribute(e)}}function lk(e){return function(){this.removeAttributeNS(e.space,e.local)}}function uk(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttribute(e);return o===i?null:o===r?a:a=t(r=o,n)}}function dk(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttributeNS(e.space,e.local);return o===i?null:o===r?a:a=t(r=o,n)}}function fk(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function pk(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function mk(e,t){var n=Zw(e),r=n===`transform`?xO:sk;return this.attrTween(e,typeof t==`function`?(n.local?pk:fk)(n,r,ok(this,`attr.`+e,t)):t==null?(n.local?lk:ck)(n):(n.local?dk:uk)(n,r,t))}function hk(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function gk(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function _k(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&gk(e,i)),n}return i._value=t,i}function vk(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&hk(e,i)),n}return i._value=t,i}function yk(e,t){var n=`attr.`+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!=`function`)throw Error();var r=Zw(e);return this.tween(n,(r.local?_k:vk)(r,t))}function bk(e,t){return function(){ZO(this,e).delay=+t.apply(this,arguments)}}function xk(e,t){return t=+t,function(){ZO(this,e).delay=t}}function Sk(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?bk:xk)(t,e)):$O(this.node(),t).delay}function Ck(e,t){return function(){QO(this,e).duration=+t.apply(this,arguments)}}function wk(e,t){return t=+t,function(){QO(this,e).duration=t}}function Tk(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?Ck:wk)(t,e)):$O(this.node(),t).duration}function Ek(e,t){if(typeof t!=`function`)throw Error();return function(){QO(this,e).ease=t}}function Dk(e){var t=this._id;return arguments.length?this.each(Ek(t,e)):$O(this.node(),t).ease}function Ok(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();QO(this,e).ease=n}}function kk(e){if(typeof e!=`function`)throw Error();return this.each(Ok(this._id,e))}function Ak(e){typeof e!=`function`&&(e=lT(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new aA(r,this._parents,this._name,this._id)}function jk(e){if(e._id!==this._id)throw Error();for(var t=this._groups,n=e._groups,r=t.length,i=n.length,a=Math.min(r,i),o=Array(r),s=0;s<a;++s)for(var c=t[s],l=n[s],u=c.length,d=o[s]=Array(u),f,p=0;p<u;++p)(f=c[p]||l[p])&&(d[p]=f);for(;s<r;++s)o[s]=t[s];return new aA(o,this._parents,this._name,this._id)}function Mk(e){return(e+``).trim().split(/^|\s+/).every(function(e){var t=e.indexOf(`.`);return t>=0&&(e=e.slice(0,t)),!e||e===`start`})}function Nk(e,t,n){var r,i,a=Mk(t)?ZO:QO;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function Pk(e,t){var n=this._id;return arguments.length<2?$O(this.node(),n).on.on(e):this.each(Nk(n,e,t))}function Fk(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Ik(){return this.on(`end.remove`,Fk(this._id))}function Lk(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=nT(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o<i;++o)for(var s=r[o],c=s.length,l=a[o]=Array(c),u,d,f=0;f<c;++f)(u=s[f])&&(d=e.call(u,u.__data__,f,s))&&(`__data__`in u&&(d.__data__=u.__data__),l[f]=d,XO(l[f],t,n,f,l,$O(u,n)));return new aA(a,this._parents,t,n)}function Rk(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=oT(e));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var c=r[s],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),p,m=$O(u,n),h=0,g=f.length;h<g;++h)(p=f[h])&&XO(p,t,n,h,f,m);a.push(f),o.push(u)}return new aA(a,o,t,n)}var zk=KE.prototype.constructor;function Bk(){return new zk(this._groups,this._parents)}function Vk(e,t){var n,r,i;return function(){var a=$T(this,e),o=(this.style.removeProperty(e),$T(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function Hk(e){return function(){this.style.removeProperty(e)}}function Uk(e,t,n){var r,i=n+``,a;return function(){var o=$T(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function Wk(e,t,n){var r,i,a;return function(){var o=$T(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),$T(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function Gk(e,t){var n,r,i,a=`style.`+t,o=`end.`+a,s;return function(){var c=QO(this,e),l=c.on,u=c.value[a]==null?s||=Hk(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function Kk(e,t,n){var r=(e+=``)==`transform`?bO:sk;return t==null?this.styleTween(e,Vk(e,r)).on(`end.style.`+e,Hk(e)):typeof t==`function`?this.styleTween(e,Wk(e,r,ok(this,`style.`+e,t))).each(Gk(this._id,e)):this.styleTween(e,Uk(e,r,t),n).on(`end.style.`+e,null)}function qk(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function Jk(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&qk(e,a,n)),r}return a._value=t,a}function Yk(e,t,n){var r=`style.`+(e+=``);if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!=`function`)throw Error();return this.tween(r,Jk(e,t,n??``))}function Xk(e){return function(){this.textContent=e}}function Zk(e){return function(){var t=e(this);this.textContent=t??``}}function Qk(e){return this.tween(`text`,typeof e==`function`?Zk(ok(this,`text`,e)):Xk(e==null?``:e+``))}function $k(e){return function(t){this.textContent=e.call(this,t)}}function eA(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&$k(r)),t}return r._value=e,r}function tA(e){var t=`text`;if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!=`function`)throw Error();return this.tween(t,eA(e))}function nA(){for(var e=this._name,t=this._id,n=oA(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)if(c=o[l]){var u=$O(c,t);XO(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new aA(r,this._parents,e,n)}function rA(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},c={value:function(){--i===0&&a()}};n.each(function(){var n=QO(this,r),i=n.on;i!==e&&(t=(e=i).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(c)),n.on=t}),i===0&&a()})}var iA=0;function aA(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function oA(){return++iA}var sA=KE.prototype;aA.prototype={constructor:aA,select:Lk,selectAll:Rk,selectChild:sA.selectChild,selectChildren:sA.selectChildren,filter:Ak,merge:jk,selection:Bk,transition:nA,call:sA.call,nodes:sA.nodes,node:sA.node,size:sA.size,empty:sA.empty,each:sA.each,on:Pk,attr:mk,attrTween:yk,style:Kk,styleTween:Yk,text:Qk,textTween:tA,remove:Ik,tween:ak,delay:Sk,duration:Tk,ease:Dk,easeVarying:kk,end:rA,[Symbol.iterator]:sA[Symbol.iterator]};function cA(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var lA={time:null,delay:0,duration:250,ease:cA};function uA(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}function dA(e){var t,n;e instanceof aA?(t=e._id,e=e._name):(t=oA(),(n=lA).time=RO(),e=e==null?null:e+``);for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&XO(c,e,t,l,o,n||uA(c,t));return new aA(r,this._parents,e,t)}KE.prototype.interrupt=nk,KE.prototype.transition=dA;var fA=e=>()=>e;function pA(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function mA(e,t,n){this.k=e,this.x=t,this.y=n}mA.prototype={constructor:mA,scale:function(e){return e===1?this:new mA(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new mA(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return`translate(`+this.x+`,`+this.y+`) scale(`+this.k+`)`}};var hA=new mA(1,0,0);gA.prototype=mA.prototype;function gA(e){for(;!e.__zoom;)if(!(e=e.parentNode))return hA;return e.__zoom}function _A(e){e.stopImmediatePropagation()}function vA(e){e.preventDefault(),e.stopImmediatePropagation()}function yA(e){return(!e.ctrlKey||e.type===`wheel`)&&!e.button}function bA(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute(`viewBox`)?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function xA(){return this.__zoom||hA}function SA(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function CA(){return navigator.maxTouchPoints||`ontouchstart`in this}function wA(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function TA(){var e=yA,t=bA,n=wA,r=SA,i=CA,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=EO,l=Gw(`start`,`zoom`,`end`),u,d,f,p=500,m=150,h=0,g=10;function _(e){e.property(`__zoom`,xA).on(`wheel.zoom`,w,{passive:!1}).on(`mousedown.zoom`,T).on(`dblclick.zoom`,E).filter(i).on(`touchstart.zoom`,D).on(`touchmove.zoom`,O).on(`touchend.zoom touchcancel.zoom`,k).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}_.transform=function(e,t,n,r){var i=e.selection?e.selection():e;i.property(`__zoom`,xA),e===i?i.interrupt().each(function(){S(this,arguments).event(r).start().zoom(null,typeof t==`function`?t.apply(this,arguments):t).end()}):x(e,t,n,r)},_.scaleBy=function(e,t,n,r){_.scaleTo(e,function(){return this.__zoom.k*(typeof t==`function`?t.apply(this,arguments):t)},n,r)},_.scaleTo=function(e,r,i,a){_.transform(e,function(){var e=t.apply(this,arguments),a=this.__zoom,s=i==null?b(e):typeof i==`function`?i.apply(this,arguments):i,c=a.invert(s),l=typeof r==`function`?r.apply(this,arguments):r;return n(y(v(a,l),s,c),e,o)},i,a)},_.translateBy=function(e,r,i,a){_.transform(e,function(){return n(this.__zoom.translate(typeof r==`function`?r.apply(this,arguments):r,typeof i==`function`?i.apply(this,arguments):i),t.apply(this,arguments),o)},null,a)},_.translateTo=function(e,r,i,a,s){_.transform(e,function(){var e=t.apply(this,arguments),s=this.__zoom,c=a==null?b(e):typeof a==`function`?a.apply(this,arguments):a;return n(hA.translate(c[0],c[1]).scale(s.k).translate(typeof r==`function`?-r.apply(this,arguments):-r,typeof i==`function`?-i.apply(this,arguments):-i),e,o)},a,s)};function v(e,t){return t=Math.max(a[0],Math.min(a[1],t)),t===e.k?e:new mA(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,i=t[1]-n[1]*e.k;return r===e.x&&i===e.y?e:new mA(e.k,r,i)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,n,r,i){e.on(`start.zoom`,function(){S(this,arguments).event(i).start()}).on(`interrupt.zoom end.zoom`,function(){S(this,arguments).event(i).end()}).tween(`zoom`,function(){var e=this,a=arguments,o=S(e,a).event(i),s=t.apply(e,a),l=r==null?b(s):typeof r==`function`?r.apply(e,a):r,u=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),d=e.__zoom,f=typeof n==`function`?n.apply(e,a):n,p=c(d.invert(l).concat(u/d.k),f.invert(l).concat(u/f.k));return function(e){if(e===1)e=f;else{var t=p(e),n=u/t[2];e=new mA(n,l[0]-t[0]*n,l[1]-t[1]*n)}o.zoom(null,e)}})}function S(e,t,n){return!n&&e.__zooming||new C(e,t)}function C(e,n){this.that=e,this.args=n,this.active=0,this.sourceEvent=null,this.extent=t.apply(e,n),this.taps=0}C.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit(`start`)),this},zoom:function(e,t){return this.mouse&&e!==`mouse`&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&e!==`touch`&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&e!==`touch`&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit(`zoom`),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit(`end`)),this},emit:function(e){var t=JE(this.that).datum();l.call(e,this.that,new pA(e,{sourceEvent:this.sourceEvent,target:_,type:e,transform:this.that.__zoom,dispatch:l}),t)}};function w(t,...i){if(!e.apply(this,arguments))return;var s=S(this,i).event(t),c=this.__zoom,l=Math.max(a[0],Math.min(a[1],c.k*2**r.apply(this,arguments))),u=XE(t);if(s.wheel)(s.mouse[0][0]!==u[0]||s.mouse[0][1]!==u[1])&&(s.mouse[1]=c.invert(s.mouse[0]=u)),clearTimeout(s.wheel);else if(c.k===l)return;else s.mouse=[u,c.invert(u)],tk(this),s.start();vA(t),s.wheel=setTimeout(d,m),s.zoom(`mouse`,n(y(v(c,l),s.mouse[0],s.mouse[1]),s.extent,o));function d(){s.wheel=null,s.end()}}function T(t,...r){if(f||!e.apply(this,arguments))return;var i=t.currentTarget,a=S(this,r,!0).event(t),s=JE(t.view).on(`mousemove.zoom`,d,!0).on(`mouseup.zoom`,p,!0),c=XE(t,i),l=t.clientX,u=t.clientY;tD(t.view),_A(t),a.mouse=[c,this.__zoom.invert(c)],tk(this),a.start();function d(e){if(vA(e),!a.moved){var t=e.clientX-l,r=e.clientY-u;a.moved=t*t+r*r>h}a.event(e).zoom(`mouse`,n(y(a.that.__zoom,a.mouse[0]=XE(e,i),a.mouse[1]),a.extent,o))}function p(e){s.on(`mousemove.zoom mouseup.zoom`,null),nD(e.view,a.moved),vA(e),a.event(e).end()}}function E(r,...i){if(e.apply(this,arguments)){var a=this.__zoom,c=XE(r.changedTouches?r.changedTouches[0]:r,this),l=a.invert(c),u=a.k*(r.shiftKey?.5:2),d=n(y(v(a,u),c,l),t.apply(this,i),o);vA(r),s>0?JE(this).transition().duration(s).call(x,d,c,r):JE(this).call(_.transform,d,c,r)}}function D(t,...n){if(e.apply(this,arguments)){var r=t.touches,i=r.length,a=S(this,n,t.changedTouches.length===i).event(t),o,s,c,l;for(_A(t),s=0;s<i;++s)c=r[s],l=XE(c,this),l=[l,this.__zoom.invert(l),c.identifier],a.touch0?!a.touch1&&a.touch0[2]!==l[2]&&(a.touch1=l,a.taps=0):(a.touch0=l,o=!0,a.taps=1+!!u);u&&=clearTimeout(u),o&&(a.taps<2&&(d=l[0],u=setTimeout(function(){u=null},p)),tk(this),a.start())}}function O(e,...t){if(this.__zooming){var r=S(this,t).event(e),i=e.changedTouches,a=i.length,s,c,l,u;for(vA(e),s=0;s<a;++s)c=i[s],l=XE(c,this),r.touch0&&r.touch0[2]===c.identifier?r.touch0[0]=l:r.touch1&&r.touch1[2]===c.identifier&&(r.touch1[0]=l);if(c=r.that.__zoom,r.touch1){var d=r.touch0[0],f=r.touch0[1],p=r.touch1[0],m=r.touch1[1],h=(h=p[0]-d[0])*h+(h=p[1]-d[1])*h,g=(g=m[0]-f[0])*g+(g=m[1]-f[1])*g;c=v(c,Math.sqrt(h/g)),l=[(d[0]+p[0])/2,(d[1]+p[1])/2],u=[(f[0]+m[0])/2,(f[1]+m[1])/2]}else if(r.touch0)l=r.touch0[0],u=r.touch0[1];else return;r.zoom(`touch`,n(y(c,l,u),r.extent,o))}}function k(e,...t){if(this.__zooming){var n=S(this,t).event(e),r=e.changedTouches,i=r.length,a,o;for(_A(e),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),a=0;a<i;++a)o=r[a],n.touch0&&n.touch0[2]===o.identifier?delete n.touch0:n.touch1&&n.touch1[2]===o.identifier&&delete n.touch1;if(n.touch1&&!n.touch0&&(n.touch0=n.touch1,delete n.touch1),n.touch0)n.touch0[1]=this.__zoom.invert(n.touch0[0]);else if(n.end(),n.taps===2&&(o=XE(o,this),Math.hypot(d[0]-o[0],d[1]-o[1])<g)){var s=JE(this).on(`dblclick.zoom`);s&&s.apply(this,arguments)}}}return _.wheelDelta=function(e){return arguments.length?(r=typeof e==`function`?e:fA(+e),_):r},_.filter=function(t){return arguments.length?(e=typeof t==`function`?t:fA(!!t),_):e},_.touchable=function(e){return arguments.length?(i=typeof e==`function`?e:fA(!!e),_):i},_.extent=function(e){return arguments.length?(t=typeof e==`function`?e:fA([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),_):t},_.scaleExtent=function(e){return arguments.length?(a[0]=+e[0],a[1]=+e[1],_):[a[0],a[1]]},_.translateExtent=function(e){return arguments.length?(o[0][0]=+e[0][0],o[1][0]=+e[1][0],o[0][1]=+e[0][1],o[1][1]=+e[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(e){return arguments.length?(n=e,_):n},_.duration=function(e){return arguments.length?(s=+e,_):s},_.interpolate=function(e){return arguments.length?(c=e,_):c},_.on=function(){var e=l.on.apply(l,arguments);return e===l?_:e},_.clickDistance=function(e){return arguments.length?(h=(e=+e)*e,_):Math.sqrt(h)},_.tapDistance=function(e){return arguments.length?(g=+e,_):g},_}var EA={error001:(e=`react`)=>`Seems like you have not used ${e===`svelte`?`SvelteFlowProvider`:`ReactFlowProvider`} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>`It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.`,error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>`The parent container needs a width and a height to render the graph.`,error005:()=>`Only child nodes can use a parent extent.`,error006:()=>`Can't create edge. An edge needs a source and a target.`,error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e===`source`?n:r}", edge id: ${t}.`,error010:()=>`Handle: No node id found. Make sure to only use a Handle inside a custom Node.`,error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e=`react`)=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>`useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.`,error015:()=>`It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.`,error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},DA=[[-1/0,-1/0],[1/0,1/0]],OA=[`Enter`,` `,`Escape`],kA={"node.a11yDescription.default":`Press enter or space to select a node. Press delete to remove it and escape to cancel.`,"node.a11yDescription.keyboardDisabled":`Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.`,"node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":`Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.`,"controls.ariaLabel":`Control Panel`,"controls.zoomIn.ariaLabel":`Zoom In`,"controls.zoomOut.ariaLabel":`Zoom Out`,"controls.fitView.ariaLabel":`Fit View`,"controls.interactive.ariaLabel":`Toggle Interactivity`,"minimap.ariaLabel":`Mini Map`,"handle.ariaLabel":`Handle`},AA;(function(e){e.Strict=`strict`,e.Loose=`loose`})(AA||={});var jA;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(jA||={});var MA;(function(e){e.Partial=`partial`,e.Full=`full`})(MA||={});var NA={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},PA;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(PA||={});var FA;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(FA||={});var Q;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})(Q||={});var IA={[Q.Left]:Q.Right,[Q.Right]:Q.Left,[Q.Top]:Q.Bottom,[Q.Bottom]:Q.Top},LA=e=>!!e&&typeof e==`object`&&`id`in e&&`source`in e&&`target`in e,RA=e=>!!e&&typeof e==`object`&&`id`in e&&`position`in e&&!(`source`in e)&&!(`target`in e),zA=e=>!!e&&typeof e==`object`&&`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),BA=(e,t=[0,0])=>{let{width:n,height:r}=bj(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},VA=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=!1,r=e.reduce((e,r)=>{let i=typeof r==`string`,a=!t.nodeLookup&&!i?r:void 0;return t.nodeLookup&&(a=i?t.nodeLookup.get(r):zA(r)?r:t.nodeLookup.get(r.id)),a?(n=!0,ej(e,ij(a,t.nodeOrigin))):e},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?nj(r):{x:0,y:0,width:0,height:0}},HA=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(e=>{(t.filter===void 0||t.filter(e))&&(n=ej(n,ij(e)),r=!0)}),r?nj(n):{x:0,y:0,width:0,height:0}},UA=(e,t,[n,r,i]=[0,0,1],a=!1,o=!1)=>{let s=(t.x-n)/i,c=(t.y-r)/i,l=t.width/i,u=t.height/i,d=[];for(let t of e.values()){let{measured:e,selectable:n=!0,hidden:r=!1}=t;if(o&&!n||r)continue;let i=e.width??t.width??t.initialWidth??0,f=e.height??t.height??t.initialHeight??0,{x:p,y:m}=t.internals.positionAbsolute,h=oj(s,c,l,u,p,m,i,f),g=i*f,_=a&&h>0;(!t.internals.handleBounds||_||h>=g||t.dragging)&&d.push(t)}return d},WA=(e,t)=>{let n=new Set;return e.forEach(e=>{n.add(e.id)}),t.filter(e=>n.has(e.source)||n.has(e.target))};function GA(e,t){let n=new Map,r=t?.nodes?new Set(t.nodes.map(e=>e.id)):null;return e.forEach(e=>{let i;if(t?.includeHiddenNodes){let{width:t,height:n}=bj(e);i=t>0&&n>0}else i=!!(e.measured.width&&e.measured.height&&!e.hidden);i&&(!r||r.has(e.id))&&n.set(e.id,e)}),n}async function KA({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return!0;let s=_j(HA(GA(e,o)),t,n,o?.minZoom??i,o?.maxZoom??a,o?.padding??.1);return await r.setViewport(s,{duration:o?.duration,ease:o?.ease,interpolate:o?.interpolate}),!0}function qA({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:a}){let o=n.get(e),s=o.parentId?n.get(o.parentId):void 0,{x:c,y:l}=s?s.internals.positionAbsolute:{x:0,y:0},u=o.origin??r,d=o.extent||i;if(o.extent===`parent`&&!o.expandParent){if(!s)a?.(`005`,EA.error005());else{let{width:e,height:t}=bj(s);e&&t&&(d=[[c,l],[c+e,l+t]])}}else s&&yj(o.extent)&&(d=[[o.extent[0][0]+c,o.extent[0][1]+l],[o.extent[1][0]+c,o.extent[1][1]+l]]);let f=yj(d)?XA(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,EA.error015()),{position:{x:f.x-c+(o.measured.width??0)*u[0],y:f.y-l+(o.measured.height??0)*u[1]},positionAbsolute:f}}async function JA({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:i}){let a=new Set(e.map(e=>e.id)),o=[];for(let e of n){if(e.deletable===!1)continue;let t=a.has(e.id),n=!t&&e.parentId&&o.find(t=>t.id===e.parentId);(t||n)&&o.push(e)}let s=new Set(t.map(e=>e.id)),c=r.filter(e=>e.deletable!==!1),l=WA(o,c);for(let e of c)s.has(e.id)&&!l.find(t=>t.id===e.id)&&l.push(e);if(!i)return{edges:l,nodes:o};let u=await i({nodes:o,edges:l});return typeof u==`boolean`?u?{edges:l,nodes:o}:{edges:[],nodes:[]}:u}var YA=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),XA=(e={x:0,y:0},t,n)=>({x:YA(e.x,t[0][0],t[1][0]-(n?.width??0)),y:YA(e.y,t[0][1],t[1][1]-(n?.height??0))});function ZA(e,t,n){let{width:r,height:i}=bj(n),{x:a,y:o}=n.internals.positionAbsolute;return XA(e,[[a,o],[a+r,o+i]],t)}var QA=(e,t,n)=>e<t?YA(Math.abs(e-t),1,t)/t:e>n?-YA(Math.abs(e-n),1,t)/t:0,$A=(e,t,n=15,r=40)=>[QA(e.x,r,t.width-r)*n,QA(e.y,r,t.height-r)*n],ej=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),tj=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),nj=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),rj=(e,t=[0,0])=>{let{x:n,y:r}=zA(e)?e.internals.positionAbsolute:BA(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},ij=(e,t=[0,0])=>{let{x:n,y:r}=zA(e)?e.internals.positionAbsolute:BA(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},aj=(e,t)=>nj(ej(tj(e),tj(t))),oj=(e,t,n,r,i,a,o,s)=>{let c=Math.max(0,Math.min(e+n,i+o)-Math.max(e,i)),l=Math.max(0,Math.min(t+r,a+s)-Math.max(t,a));return Math.ceil(c*l)},sj=(e,t)=>oj(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),cj=e=>lj(e.width)&&lj(e.height)&&lj(e.x)&&lj(e.y),lj=e=>!isNaN(e)&&isFinite(e),uj=(e,t)=>(e,t)=>{},dj=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),fj=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?dj(s,o):s},pj=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function mj(e,t){if(typeof e==`number`)return Math.floor((t-t/(1+e))*.5);if(typeof e==`string`&&e.endsWith(`px`)){let t=parseFloat(e);if(!Number.isNaN(t))return Math.floor(t)}if(typeof e==`string`&&e.endsWith(`%`)){let n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function hj(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=mj(e,n),i=mj(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=mj(e.top??e.y??0,n),i=mj(e.bottom??e.y??0,n),a=mj(e.left??e.x??0,t),o=mj(e.right??e.x??0,t);return{top:r,right:o,bottom:i,left:a,x:a+o,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function gj(e,t,n,r,i,a){let{x:o,y:s}=pj(e,[t,n,r]),{x:c,y:l}=pj({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=i-c,d=a-l;return{left:Math.floor(o),top:Math.floor(s),right:Math.floor(u),bottom:Math.floor(d)}}var _j=(e,t,n,r,i,a)=>{let o=hj(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=YA(Math.min(s,c),r,i),u=e.x+e.width/2,d=e.y+e.height/2,f=t/2-u*l,p=n/2-d*l,m=gj(e,f,p,l,t,n),h={left:Math.min(m.left-o.left,0),top:Math.min(m.top-o.top,0),right:Math.min(m.right-o.right,0),bottom:Math.min(m.bottom-o.bottom,0)};return{x:f-h.left+h.right,y:p-h.top+h.bottom,zoom:l}},vj=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function yj(e){return e!=null&&e!==`parent`}function bj(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function xj(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Sj(e,t={width:0,height:0},n,r,i){let a={...e},o=r.get(n);if(o){let e=o.origin||i;a.x+=o.internals.positionAbsolute.x-(t.width??0)*e[0],a.y+=o.internals.positionAbsolute.y-(t.height??0)*e[1]}return a}function Cj(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function wj(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function Tj(e){return{...kA,...e||{}}}function Ej(e){return e===null?null:e?`valid`:`invalid`}function Dj(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=Nj(e),s=fj({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?dj(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var Oj=e=>({width:e.offsetWidth,height:e.offsetHeight}),kj=e=>e?.getRootNode?.()||window?.document,Aj=[`INPUT`,`SELECT`,`TEXTAREA`];function jj(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?Aj.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var Mj=e=>`clientX`in e,Nj=(e,t)=>{let n=Mj(e),r=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:i-(t?.top??0)}},Pj=(e,t,n,r,i)=>{let a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...Oj(t)}})};function Fj({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:o,targetControlY:s}){let c=e*.125+i*.375+o*.375+n*.125,l=t*.125+a*.375+s*.375+r*.125;return[c,l,Math.abs(c-e),Math.abs(l-t)]}function Ij(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Lj({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case Q.Left:return[t-Ij(t-r,a),n];case Q.Right:return[t+Ij(r-t,a),n];case Q.Top:return[t,n-Ij(n-i,a)];case Q.Bottom:return[t,n+Ij(i-n,a)]}}function Rj({sourceX:e,sourceY:t,sourcePosition:n=Q.Bottom,targetX:r,targetY:i,targetPosition:a=Q.Top,curvature:o=.25}){let[s,c]=Lj({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=Lj({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=Fj({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:s,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${s},${c} ${l},${u} ${r},${i}`,d,f,p,m]}function zj({sourceX:e,sourceY:t,targetX:n,targetY:r}){let i=Math.abs(n-e)/2,a=n<e?n+i:n-i,o=Math.abs(r-t)/2;return[a,r<t?r+o:r-o,i,o]}function Bj({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:i=!1,zIndexMode:a=`basic`}){return a===`manual`?r:(i&&n?r+1e3:r)+Math.max(e.parentId||i&&e.selected?e.internals.z:0,t.parentId||i&&t.selected?t.internals.z:0)}function Vj({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){let a=ej(ij(e),ij(t));return a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1),sj({x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]},nj(a))>0}var Hj=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,Uj=(e,t)=>t.some(t=>t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle)),Wj=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.(`006`,EA.error006()),t;let r=n.getEdgeId||Hj,i;return i=LA(e)?{...e}:{...e,id:r(e)},Uj(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function Gj({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=zj({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var Kj={[Q.Left]:{x:-1,y:0},[Q.Right]:{x:1,y:0},[Q.Top]:{x:0,y:-1},[Q.Bottom]:{x:0,y:1}},qj=({source:e,sourcePosition:t=Q.Bottom,target:n})=>t===Q.Left||t===Q.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},Jj=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2);function Yj({source:e,sourcePosition:t=Q.Bottom,target:n,targetPosition:r=Q.Top,center:i,offset:a,stepPosition:o}){let s=Kj[t],c=Kj[r],l={x:e.x+s.x*a,y:e.y+s.y*a},u={x:n.x+c.x*a,y:n.y+c.y*a},d=qj({source:l,sourcePosition:t,target:u}),f=d.x===0?`y`:`x`,p=d[f],m=[],h,g,_={x:0,y:0},v={x:0,y:0},[,,y,b]=zj({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(s[f]*c[f]===-1){f===`x`?(h=i.x??l.x+(u.x-l.x)*o,g=i.y??(l.y+u.y)/2):(h=i.x??(l.x+u.x)/2,g=i.y??l.y+(u.y-l.y)*o);let e=[{x:h,y:l.y},{x:h,y:u.y}],t=[{x:l.x,y:g},{x:u.x,y:g}];m=s[f]===p?f===`x`?e:t:f===`x`?t:e}else{let i=[{x:l.x,y:u.y}],o=[{x:u.x,y:l.y}];if(m=f===`x`?s.x===p?o:i:s.y===p?i:o,t===r){let t=Math.abs(e[f]-n[f]);if(t<=a){let r=Math.min(a-1,a-t);s[f]===p?_[f]=(l[f]>e[f]?-1:1)*r:v[f]=(u[f]>n[f]?-1:1)*r}}if(t!==r){let e=f===`x`?`y`:`x`,t=s[f]===c[e],n=l[e]>u[e],r=l[e]<u[e];(s[f]===1&&(!t&&n||t&&r)||s[f]!==1&&(!t&&r||t&&n))&&(m=f===`x`?i:o)}let d={x:l.x+_.x,y:l.y+_.y},y={x:u.x+v.x,y:u.y+v.y};Math.max(Math.abs(d.x-m[0].x),Math.abs(y.x-m[0].x))>=Math.max(Math.abs(d.y-m[0].y),Math.abs(y.y-m[0].y))?(h=(d.x+y.x)/2,g=m[0].y):(h=m[0].x,g=(d.y+y.y)/2)}let x={x:l.x+_.x,y:l.y+_.y},S={x:u.x+v.x,y:u.y+v.y};return[[e,...x.x!==m[0].x||x.y!==m[0].y?[x]:[],...m,...S.x!==m[m.length-1].x||S.y!==m[m.length-1].y?[S]:[],n],h,g,y,b]}function Xj(e,t,n,r){let i=Math.min(Jj(e,t)/2,Jj(t,n)/2,r),{x:a,y:o}=t;if(e.x===a&&a===n.x||e.y===o&&o===n.y)return`L${a} ${o}`;if(e.y===o){let t=e.x<n.x?-1:1,r=e.y<n.y?1:-1;return`L ${a+i*t},${o}Q ${a},${o} ${a},${o+i*r}`}let s=e.x<n.x?1:-1;return`L ${a},${o+i*(e.y<n.y?-1:1)}Q ${a},${o} ${a+i*s},${o}`}function Zj({sourceX:e,sourceY:t,sourcePosition:n=Q.Bottom,targetX:r,targetY:i,targetPosition:a=Q.Top,borderRadius:o=5,centerX:s,centerY:c,offset:l=20,stepPosition:u=.5}){let[d,f,p,m,h]=Yj({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:i},targetPosition:a,center:{x:s,y:c},offset:l,stepPosition:u}),g=`M${d[0].x} ${d[0].y}`;for(let e=1;e<d.length-1;e++)g+=Xj(d[e-1],d[e],d[e+1],o);return g+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[g,f,p,m,h]}function Qj(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function $j(e){let{sourceNode:t,targetNode:n}=e;if(!Qj(t)||!Qj(n))return null;let r=t.internals.handleBounds||eM(t.handles),i=n.internals.handleBounds||eM(n.handles),a=nM(r?.source??[],e.sourceHandle),o=nM(e.connectionMode===AA.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!a||!o)return e.onError?.(`008`,EA.error008(a?`target`:`source`,{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;let s=a?.position||Q.Bottom,c=o?.position||Q.Top,l=tM(t,a,s),u=tM(n,o,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:s,targetPosition:c}}function eM(e){if(!e)return null;let t=[],n=[];for(let r of e)r.width=r.width??1,r.height=r.height??1,r.type===`source`?t.push(r):r.type===`target`&&n.push(r);return{source:t,target:n}}function tM(e,t,n=Q.Left,r=!1){let i=(t?.x??0)+e.internals.positionAbsolute.x,a=(t?.y??0)+e.internals.positionAbsolute.y,{width:o,height:s}=t??bj(e);if(r)return{x:i+o/2,y:a+s/2};switch(t?.position??n){case Q.Top:return{x:i+o/2,y:a};case Q.Right:return{x:i+o,y:a+s/2};case Q.Bottom:return{x:i+o/2,y:a+s};case Q.Left:return{x:i,y:a+s/2}}}function nM(e,t){return e&&(t?e.find(e=>e.id===t):e[0])||null}function rM(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function iM(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){let a=new Set;return e.reduce((e,o)=>([o.markerStart||r,o.markerEnd||i].forEach(r=>{if(r&&typeof r==`object`){let i=rM(r,t);a.has(i)||(e.push({id:i,color:r.color||n,...r}),a.add(i))}}),e),[]).sort((e,t)=>e.id.localeCompare(t.id))}var aM=1e3,oM=10,sM={nodeOrigin:[0,0],nodeExtent:DA,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},cM={...sM,checkEquality:!0};function lM(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function uM(e,t,n){let r=lM(sM,n);for(let n of e.values())if(n.parentId)hM(n,e,t,r);else{let e=XA(BA(n,r.nodeOrigin),yj(n.extent)?n.extent:r.nodeExtent,bj(n));n.internals.positionAbsolute=e}}function dM(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;let n=[],r=[];for(let t of e.handles){let i={id:t.id,width:t.width??1,height:t.height??1,nodeId:e.id,x:t.x,y:t.y,position:t.position,type:t.type};t.type===`source`?n.push(i):t.type===`target`&&r.push(i)}return{source:n,target:r}}function fM(e){return e===`manual`}function pM(e,t,n,r={}){let i=lM(cM,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!fM(i.zIndexMode)?aM:0,c=e.length>0,l=!1;t.clear(),n.clear();for(let u of e){let e=o.get(u.id);if(i.checkEquality&&u===e?.internals.userNode)t.set(u.id,e);else{let n=XA(BA(u,i.nodeOrigin),yj(u.extent)?u.extent:i.nodeExtent,bj(u));e={...i.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:dM(u,e),z:gM(u,s,i.zIndexMode),userNode:u}},t.set(u.id,e)}(e.measured===void 0||e.measured.width===void 0||e.measured.height===void 0)&&!e.hidden&&(c=!1),u.parentId&&hM(e,t,n,r,a),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function mM(e,t){if(!e.parentId)return;let n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function hM(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=lM(sM,r),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}mM(e,n),i&&!u.parentId&&u.internals.rootParentIndex===void 0&&c===`auto`&&(u.internals.rootParentIndex=++i.i,u.internals.z=u.internals.z+i.i*oM),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=_M(e,u,o,s,a&&!fM(c)?aM:0,c),{positionAbsolute:m}=e.internals,h=d!==m.x||f!==m.y;(h||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:h?{x:d,y:f}:m,z:p}})}function gM(e,t,n){let r=lj(e.zIndex)?e.zIndex:0;return fM(n)?r:r+(e.selected?t:0)}function _M(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=bj(e),l=BA(e,n),u=yj(e.extent)?XA(l,e.extent,c):l,d=XA({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=ZA(d,c,t));let f=gM(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function vM(e,t,n,r=[0,0]){let i=[],a=new Map;for(let n of e){let e=t.get(n.parentId);if(!e)continue;let r=aj(a.get(n.parentId)?.expandedRect??rj(e),n.rect);a.set(n.parentId,{expandedRect:r,parent:e})}return a.size>0&&a.forEach(({expandedRect:t,parent:a},o)=>{let s=a.internals.positionAbsolute,c=bj(a),l=a.origin??r,u=t.x<s.x?Math.round(Math.abs(s.x-t.x)):0,d=t.y<s.y?Math.round(Math.abs(s.y-t.y)):0,f=Math.max(c.width,Math.round(t.width)),p=Math.max(c.height,Math.round(t.height)),m=(f-c.width)*l[0],h=(p-c.height)*l[1];(u>0||d>0||m||h)&&(i.push({id:o,type:`position`,position:{x:a.position.x-u+m,y:a.position.y-d+h}}),n.get(o)?.forEach(t=>{e.some(e=>e.id===t.id)||i.push({id:t.id,type:`position`,position:{x:t.position.x+u,y:t.position.y+d}})})),(c.width<t.width||c.height<t.height||u||d)&&i.push({id:o,type:`dimensions`,setAttributes:!0,dimensions:{width:f+(u?l[0]*u-m:0),height:p+(d?l[1]*d-h:0)}})}),i}function yM(e,t,n,r,i,a,o){let s=r?.querySelector(`.xyflow__viewport`),c=!1;if(!s)return{changes:[],updatedInternals:c};let l=[],u=window.getComputedStyle(s),{m22:d}=new window.DOMMatrixReadOnly(u.transform),f=[];for(let r of e.values()){let e=t.get(r.id);if(!e)continue;if(e.hidden){t.set(e.id,{...e,internals:{...e.internals,handleBounds:void 0}}),c=!0;continue}let s=Oj(r.nodeElement),u=e.measured.width!==s.width||e.measured.height!==s.height;if(s.width&&s.height&&(u||!e.internals.handleBounds||r.force)){let p=r.nodeElement.getBoundingClientRect(),m=yj(e.extent)?e.extent:a,{positionAbsolute:h}=e.internals;if(e.parentId&&e.extent===`parent`){let n=t.get(e.parentId);n&&(h=ZA(h,s,n))}else m&&(h=XA(h,m,s));let g={...e,measured:s,internals:{...e.internals,positionAbsolute:h,handleBounds:{source:Pj(`source`,r.nodeElement,p,d,e.id),target:Pj(`target`,r.nodeElement,p,d,e.id)}}};t.set(e.id,g),e.parentId&&hM(g,t,n,{nodeOrigin:i,zIndexMode:o}),c=!0,u&&(l.push({id:e.id,type:`dimensions`,dimensions:s}),e.expandParent&&e.parentId&&f.push({id:e.id,parentId:e.parentId,rect:rj(g,i)}))}}if(f.length>0){let e=vM(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function bM({delta:e,panZoom:t,transform:n,translateExtent:r,width:i,height:a}){if(!t||!e.x&&!e.y)return!1;let o=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,a]],r);return!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2])}function xM(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function SM(e,t,n){e.clear(),t.clear();for(let r of n){let{source:n,target:i,sourceHandle:a=null,targetHandle:o=null}=r,s={edgeId:r.id,source:n,target:i,sourceHandle:a,targetHandle:o},c=`${n}-${a}--${i}-${o}`;xM(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),xM(`target`,s,c,e,i,o),t.set(r.id,r)}}function CM(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:CM(n,t):!1}function wM(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)return!1;r=r?.parentElement}while(r);return!1}function TM(e,t,n,r){let i=new Map;for(let[a,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!CM(o,e))&&(o.draggable||t&&o.draggable===void 0)){let t=e.get(a);t&&i.set(a,{id:a,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return i}function EM({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){let i=[];for(let[e,a]of t){let t=n.get(e)?.internals.userNode;t&&i.push({...t,position:a.position,dragging:r})}if(!e)return[i[0],i];let a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:r}:i[0],i]}function DM({dragItems:e,snapGrid:t,x:n,y:r}){let i=e.values().next().value;if(!i)return null;let a={x:n-i.distance.x,y:r-i.distance.y},o=dj(a,t);return{x:o.x-a.x,y:o.y-a.y}}function OM({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let a={x:null,y:null},o=0,s=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,p=!1,m=!1,h=null;function g({noDragClassName:g,handleSelector:_,domNode:v,isSelectable:y,nodeId:b,nodeClickDistance:x=0}){f=JE(v);function S({x:e,y:n}){let{nodeLookup:i,nodeExtent:o,snapGrid:c,snapToGrid:l,nodeOrigin:u,onNodeDrag:d,onSelectionDrag:f,onError:p,updateNodePositions:g}=t();a={x:e,y:n};let _=!1,v=s.size>1,y=v&&o?tj(HA(s)):null,x=v&&l?DM({dragItems:s,snapGrid:c,x:e,y:n}):null;for(let[t,r]of s){if(!i.has(t))continue;let a={x:e-r.distance.x,y:n-r.distance.y};l&&(a=x?{x:Math.round(a.x+x.x),y:Math.round(a.y+x.y)}:dj(a,c));let s=null;if(v&&o&&!r.extent&&y){let{positionAbsolute:e}=r.internals,t=e.x-y.x+o[0][0],n=e.x+r.measured.width-y.x2+o[1][0],i=e.y-y.y+o[0][1],a=e.y+r.measured.height-y.y2+o[1][1];s=[[t,i],[n,a]]}let{position:d,positionAbsolute:f}=qA({nodeId:t,nextPosition:a,nodeLookup:i,nodeExtent:s||o,nodeOrigin:u,onError:p});_=_||r.position.x!==d.x||r.position.y!==d.y,r.position=d,r.internals.positionAbsolute=f}if(m||=_,_&&(g(s,!0),h&&(r||d||!b&&f))){let[e,t]=EM({nodeId:b,dragItems:s,nodeLookup:i});r?.(h,s,e,t),d?.(h,e,t),b||f?.(h,t)}}async function C(){if(!u)return;let{transform:e,panBy:n,autoPanSpeed:r,autoPanOnNodeDrag:i}=t();if(!i){c=!1,cancelAnimationFrame(o);return}let[s,d]=$A(l,u,r);(s!==0||d!==0)&&(a.x=(a.x??0)-s/e[2],a.y=(a.y??0)-d/e[2],await n({x:s,y:d})&&S(a)),o=requestAnimationFrame(C)}function w(r){let{nodeLookup:i,multiSelectionActive:o,nodesDraggable:c,transform:l,snapGrid:f,snapToGrid:p,selectNodesOnDrag:m,onNodeDragStart:h,onSelectionDragStart:g,unselectNodesAndEdges:_}=t();d=!0,(!m||!y)&&!o&&b&&(i.get(b)?.selected||_()),y&&m&&b&&e?.(b);let v=Dj(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=v,s=TM(i,c,v,b),s.size>0&&(n||h||!b&&g)){let[e,t]=EM({nodeId:b,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}let T=lD().clickDistance(x).on(`start`,e=>{let{domNode:n,nodeDragThreshold:r,transform:i,snapGrid:o,snapToGrid:s}=t();u=n?.getBoundingClientRect()||null,p=!1,m=!1,h=e.sourceEvent,r===0&&w(e),a=Dj(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=Nj(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=Dj(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:o,containerBounds:u});if(h=e.sourceEvent,(e.sourceEvent.type===`touchmove`&&e.sourceEvent.touches.length>1||b&&!m.has(b))&&(p=!0),!p){if(!c&&n&&d&&(c=!0,C()),!d){let t=Nj(e.sourceEvent,u),n=t.x-l.x,r=t.y-l.y;Math.sqrt(n*n+r*r)>f&&w(e)}(a.x!==g.xSnapped||a.y!==g.ySnapped)&&s&&d&&(l=Nj(e.sourceEvent,u),S(g))}}).on(`end`,e=>{if(!d||p){p&&s.size>0&&t().updateNodePositions(s,!1);return}if(c=!1,d=!1,cancelAnimationFrame(o),s.size>0){let{nodeLookup:n,updateNodePositions:r,onNodeDragStop:a,onSelectionDragStop:o}=t();if(m&&=(r(s,!1),!1),i||a||!b&&o){let[t,r]=EM({nodeId:b,dragItems:s,nodeLookup:n,dragging:!1});i?.(e.sourceEvent,s,t,r),a?.(e.sourceEvent,t,r),b||o?.(e.sourceEvent,r)}}}).filter(e=>{let t=e.target;return!e.button&&(!g||!wM(t,`.${g}`,v))&&(!_||wM(t,_,v))});f.call(T)}function _(){f?.on(`.drag`,null)}return{update:g,destroy:_}}function kM(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())sj(i,rj(e))>0&&r.push(e);return r}var AM=250;function jM(e,t,n,r){let i=[],a=1/0,o=kM(e,n,t+AM);for(let n of o){let o=[...n.internals.handleBounds?.source??[],...n.internals.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=tM(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l<a?(i=[{...s,x:o,y:c}],a=l):l===a&&i.push({...s,x:o,y:c}))}}if(!i.length)return null;if(i.length>1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function MM(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===`strict`?o.internals.handleBounds?.[t]:[...o.internals.handleBounds?.source??[],...o.internals.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...tM(o,c,c.position,!0)}:c}function NM(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function PM(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var FM=()=>!0;function IM(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:a,isTarget:o,domNode:s,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:d,panBy:f,cancelConnection:p,onConnectStart:m,onConnect:h,onConnectEnd:g,isValidConnection:_=FM,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=kj(e.target),E=0,D,{x:O,y:k}=Nj(e),A=NM(a,w),j=s?.getBoundingClientRect(),M=!1;if(!j||!A)return;let N=MM(i,A,r,c,t);if(!N)return;let P=Nj(e,j),F=!1,I=null,L=!1,R=null;function ee(){if(!u||!j)return;let[e,t]=$A(P,j,S);f({x:e,y:t}),E=requestAnimationFrame(ee)}let z={...N,nodeId:i,type:A,position:N.position},B=c.get(i),te={inProgress:!0,isValid:null,from:tM(B,z,Q.Left,!0),fromHandle:z,fromPosition:z.position,fromNode:B,to:P,toHandle:null,toPosition:IA[z.position],toNode:null,pointer:P};function V(){M=!0,y(te),m?.(e,{nodeId:i,handleId:r,handleType:A})}C===0&&V();function ne(e){if(!M){let{x:t,y:n}=Nj(e),r=t-O,i=n-k;if(!(r*r+i*i>C*C))return;V()}if(!x()||!z){re(e);return}let a=b();P=Nj(e,j),D=jM(fj(P,a,!1,[1,1]),n,c,z),F||=(ee(),!0);let s=LM(e,{handle:D,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:o?`target`:`source`,isValidConnection:_,doc:T,lib:l,flowId:d,nodeLookup:c});R=s.handleDomNode,I=s.connection,L=PM(!!D,s.isValid);let u=c.get(i),f=u?tM(u,z,Q.Left,!0):te.from,p={...te,from:f,isValid:L,to:s.toHandle&&L?pj({x:s.toHandle.x,y:s.toHandle.y},a):P,toHandle:s.toHandle,toPosition:L&&s.toHandle?s.toHandle.position:IA[z.position],toNode:s.toHandle?c.get(s.toHandle.nodeId):null,pointer:P};y(p),te=p}function re(e){if(!(`touches`in e&&e.touches.length>0)){if(M){(D||R)&&I&&L&&h?.(I);let{inProgress:t,...n}=te,r={...n,toPosition:te.toHandle?te.toPosition:null};g?.(e,r),a&&v?.(e,r)}p(),cancelAnimationFrame(E),F=!1,L=!1,I=null,R=null,T.removeEventListener(`mousemove`,ne),T.removeEventListener(`mouseup`,re),T.removeEventListener(`touchmove`,ne),T.removeEventListener(`touchend`,re)}}T.addEventListener(`mousemove`,ne),T.addEventListener(`mouseup`,re),T.addEventListener(`touchmove`,ne),T.addEventListener(`touchend`,re)}function LM(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=FM,nodeLookup:u}){let d=a===`target`,f=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:p,y:m}=Nj(e),h=o.elementFromPoint(p,m),g=h?.classList.contains(`${s}-flow__handle`)?h:f,_={handleDomNode:g,isValid:!1,connection:null,toHandle:null};if(g){let e=NM(void 0,g),t=g.getAttribute(`data-nodeid`),a=g.getAttribute(`data-handleid`),o=g.classList.contains(`connectable`),s=g.classList.contains(`connectableend`);if(!t||!e)return _;let c={source:d?t:r,sourceHandle:d?a:i,target:d?r:t,targetHandle:d?i:a};_.connection=c,_.isValid=o&&s&&(n===AA.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=MM(t,e,a,u,n,!0)}return _}var RM={onPointerDown:IM,isValid:LM};function zM({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=JE(e);function a({translateExtent:e,width:a,height:o,zoomStep:s=1,pannable:c=!0,zoomable:l=!0,inversePan:u=!1}){let d=e=>{if(e.sourceEvent.type!==`wheel`||!t)return;let r=n(),i=e.sourceEvent.ctrlKey&&vj()?10:1,a=-e.sourceEvent.deltaY*(e.sourceEvent.deltaMode===1?.05:e.sourceEvent.deltaMode?1:.002)*s,o=r[2]*2**(a*i);t.scaleTo(o)},f=[0,0],p=TA().on(`start`,e=>{(e.sourceEvent.type===`mousedown`||e.sourceEvent.type===`touchstart`)&&(f=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])}).on(`zoom`,c?i=>{let s=n();if(i.sourceEvent.type!==`mousemove`&&i.sourceEvent.type!==`touchmove`||!t)return;let c=[i.sourceEvent.clientX??i.sourceEvent.touches[0].clientX,i.sourceEvent.clientY??i.sourceEvent.touches[0].clientY],l=[c[0]-f[0],c[1]-f[1]];f=c;let d=r()*Math.max(s[2],Math.log(s[2]))*(u?-1:1),p={x:s[0]-l[0]*d,y:s[1]-l[1]*d},m=[[0,0],[a,o]];t.setViewportConstrained({x:p.x,y:p.y,zoom:s[2]},m,e)}:null).on(`zoom.wheel`,l?d:null);i.call(p,{})}function o(){i.on(`zoom`,null)}return{update:a,destroy:o,pointer:XE}}var BM=e=>({x:e.x,y:e.y,zoom:e.k}),VM=({x:e,y:t,zoom:n})=>hA.translate(e,t).scale(n),HM=(e,t)=>e.target.closest(`.${t}`),UM=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),WM=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,GM=(e,t=0,n=WM,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},KM=e=>{let t=e.ctrlKey&&vj()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function qM({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(HM(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();let d=n.property(`__zoom`).k||1;if(u.ctrlKey&&o){let e=XE(u),t=d*2**KM(u);r.scaleTo(n,t,e,u);return}let f=u.deltaMode===1?20:1,p=i===jA.Vertical?0:u.deltaX*f,m=i===jA.Horizontal?0:u.deltaY*f;!vj()&&u.shiftKey&&i!==jA.Vertical&&(p=u.deltaY*f,m=0),r.translateBy(n,-(p/d)*a,-(m/d)*a,{internal:!0});let h=BM(n.property(`__zoom`));clearTimeout(e.panScrollTimeout),e.isPanScrolling?c?.(u,h):(e.isPanScrolling=!0,s?.(u,h)),e.panScrollTimeout=setTimeout(()=>{l?.(u,h),e.isPanScrolling=!1},150)}}function JM({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){let a=r.type===`wheel`,o=!t&&a&&!r.ctrlKey,s=HM(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function YM({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=BM(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=i,r.sourceEvent?.type===`mousedown`&&t(!0),n&&n?.(r.sourceEvent,i)}}function XM({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&UM(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,BM(a.transform))}}function ZM({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&UM(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=BM(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function QM({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:r,panOnDrag:i,panOnScroll:a,zoomOnDoubleClick:o,userSelectionActive:s,noWheelClassName:c,noPanClassName:l,lib:u,connectionInProgress:d}){return f=>{let p=t||n,m=r&&f.ctrlKey,h=f.type===`wheel`;if(f.button===1&&f.type===`mousedown`&&(HM(f,`${u}-flow__node`)||HM(f,`${u}-flow__edge`)||HM(f,`${u}-flow__selection`)||HM(f,`${u}-flow__nodesselection`)))return!0;if(!i&&!p&&!a&&!o&&!r||s||d&&!h||HM(f,c)&&h||HM(f,l)&&(!h||a&&h&&!t)||!r&&f.ctrlKey&&h)return!1;if(!r&&f.type===`touchstart`&&f.touches?.length>1)return f.preventDefault(),!1;if(!p&&!a&&!m&&h||!i&&(f.type===`mousedown`||f.type===`touchstart`)||Array.isArray(i)&&!i.includes(f.button)&&f.type===`mousedown`)return!1;let g=Array.isArray(i)&&i.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||h||e)&&g}}function $M({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:a,onPanZoomStart:o,onPanZoomEnd:s,onDraggingChange:c}){let l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect(),d=[[0,0],[u.width,u.height]];(typeof ResizeObserver<`u`?new ResizeObserver(e=>{let t=e[0];t&&(d=[[0,0],[t.contentRect.width,t.contentRect.height]])}):null)?.observe(e);let f=TA().extent(()=>d).scaleExtent([t,n]).translateExtent(r),p=JE(e).call(f);y({x:i.x,y:i.y,zoom:YA(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let m=p.on(`wheel.zoom`),h=p.on(`dblclick.zoom`);f.wheelDelta(KM);async function g(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?fO:EO).transform(GM(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function _({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:r,panOnScroll:i,panOnDrag:u,panOnScrollMode:d,panOnScrollSpeed:g,preventScrolling:_,zoomOnPinch:y,zoomOnScroll:b,zoomOnDoubleClick:x,panActivationKeyPressed:S=!1,zoomActivationKeyPressed:C,lib:w,onTransformChange:T,connectionInProgress:E,paneClickDistance:D,selectionOnDrag:O}){r&&!l.isZoomingOrPanning&&v();let k=i&&!C&&!r;f.clickDistance(O?1/0:!lj(D)||D<0?0:D);let A=k?qM({zoomPanValues:l,noWheelClassName:e,d3Selection:p,d3Zoom:f,panOnScrollMode:d,panOnScrollSpeed:g,zoomOnPinch:y,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):JM({noWheelClassName:e,preventScrolling:_,d3ZoomHandler:m});p.on(`wheel.zoom`,A,{passive:!1});let j=YM({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});f.on(`start`,j);let M=XM({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:T});f.on(`zoom`,M);let N=ZM({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});f.on(`end`,N);let P=QM({panActivationKeyPressed:S,zoomActivationKeyPressed:C,panOnDrag:u,zoomOnScroll:b,panOnScroll:i,zoomOnDoubleClick:x,zoomOnPinch:y,userSelectionActive:r,noPanClassName:t,noWheelClassName:e,lib:w,connectionInProgress:E});f.filter(P),x?p.on(`dblclick.zoom`,h):p.on(`dblclick.zoom`,null)}function v(){f.on(`zoom`,null)}async function y(e,t,n){let r=VM(e),i=f?.constrain()(r,t,n);return i&&await g(i),i}async function b(e,t){let n=VM(e);return await g(n,t),n}function x(e){if(p){let t=VM(e),n=p.property(`__zoom`);(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&f?.transform(p,t,null,{sync:!0})}}function S(){let e=p?gA(p.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}}async function C(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?fO:EO).scaleTo(GM(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}async function w(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?fO:EO).scaleBy(GM(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function T(e){f?.scaleExtent(e)}function E(e){f?.translateExtent(e)}function D(e){let t=!lj(e)||e<0?0:e;f?.clickDistance(t)}return{update:_,destroy:v,setViewport:b,setViewportConstrained:y,getViewport:S,scaleTo:C,scaleBy:w,setScaleExtent:T,setTranslateExtent:E,syncViewport:x,setClickDistance:D}}var eN;(function(e){e.Line=`line`,e.Handle=`handle`})(eN||={});function tN({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:i,affectsY:a}){let o=e-t,s=n-r,c=[o>0?1:o<0?-1:0,s>0?1:s<0?-1:0];return o&&i&&(c[0]*=-1),s&&a&&(c[1]*=-1),c}function nN(e){return{isHorizontal:e.includes(`right`)||e.includes(`left`),isVertical:e.includes(`bottom`)||e.includes(`top`),affectsX:e.includes(`left`),affectsY:e.includes(`top`)}}function rN(e,t){return Math.max(0,t-e)}function iN(e,t){return Math.max(0,e-t)}function aN(e,t,n){return Math.max(0,t-e,e-n)}function oN(e,t){return e?!t:t}function sN(e,t,n,r,i,a,o,s){let{affectsX:c,affectsY:l}=t,{isHorizontal:u,isVertical:d}=t,f=u&&d,{xSnapped:p,ySnapped:m}=n,{minWidth:h,maxWidth:g,minHeight:_,maxHeight:v}=r,{x:y,y:b,width:x,height:S,aspectRatio:C}=e,w=Math.floor(u?p-e.pointerX:0),T=Math.floor(d?m-e.pointerY:0),E=x+(c?-w:w),D=S+(l?-T:T),O=-a[0]*x,k=-a[1]*S,A=aN(E,h,g),j=aN(D,_,v);if(o){let e=0,t=0;c&&w<0?e=rN(y+w+O,o[0][0]):!c&&w>0&&(e=iN(y+E+O,o[1][0])),l&&T<0?t=rN(b+T+k,o[0][1]):!l&&T>0&&(t=iN(b+D+k,o[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(s){let e=0,t=0;c&&w>0?e=iN(y+w,s[0][0]):!c&&w<0&&(e=rN(y+E,s[1][0])),l&&T>0?t=iN(b+T,s[0][1]):!l&&T<0&&(t=rN(b+D,s[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(i){if(u){let e=aN(E/C,_,v)*C;if(A=Math.max(A,e),o){let e=0;e=!c&&!l||c&&!l&&f?iN(b+k+E/C,o[1][1])*C:rN(b+k+(c?w:-w)/C,o[0][1])*C,A=Math.max(A,e)}if(s){let e=0;e=!c&&!l||c&&!l&&f?rN(b+E/C,s[1][1])*C:iN(b+(c?w:-w)/C,s[0][1])*C,A=Math.max(A,e)}}if(d){let e=aN(D*C,h,g)/C;if(j=Math.max(j,e),o){let e=0;e=!c&&!l||l&&!c&&f?iN(y+D*C+O,o[1][0])/C:rN(y+(l?T:-T)*C+O,o[0][0])/C,j=Math.max(j,e)}if(s){let e=0;e=!c&&!l||l&&!c&&f?rN(y+D*C,s[1][0])/C:iN(y+(l?T:-T)*C,s[0][0])/C,j=Math.max(j,e)}}}T+=T<0?j:-j,w+=w<0?A:-A,i&&(f?E>D*C?T=(oN(c,l)?-w:w)/C:w=(oN(c,l)?-T:T)*C:u?(T=w/C,l=c):(w=T*C,c=l));let M=c?y+w:y,N=l?b+T:b;return{width:x+(c?-w:w),height:S+(l?-T:T),x:a[0]*w*(c?-1:1)+M,y:a[1]*T*(l?-1:1)+N}}var cN={width:0,height:0,x:0,y:0},lN={...cN,pointerX:0,pointerY:0,aspectRatio:1};function uN(e,t,n){let r=t.position.x+e.position.x,i=t.position.y+e.position.y,a=e.measured.width??0,o=e.measured.height??0,s=n[0]*a,c=n[1]*o;return[[r-s,i-c],[r+a-s,i+o-c]]}function dN({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=JE(e),o={controlDirection:nN(`bottom-right`),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function s({controlPosition:e,boundaries:s,keepAspectRatio:c,resizeDirection:l,onResizeStart:u,onResize:d,onResizeEnd:f,shouldResize:p}){let m={...cN},h={...lN};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:nN(e)};let g,_=null,v=[],y,b,x,S=!1,C=lD().on(`start`,e=>{let{nodeLookup:r,transform:i,snapGrid:a,snapToGrid:o,nodeOrigin:s,paneDomNode:c}=n();if(g=r.get(t),!g)return;_=c?.getBoundingClientRect()??null;let{xSnapped:l,ySnapped:d}=Dj(e.sourceEvent,{transform:i,snapGrid:a,snapToGrid:o,containerBounds:_});m={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},h={...m,pointerX:l,pointerY:d,aspectRatio:m.width/m.height},y=void 0,b=yj(g.extent)?g.extent:void 0,g.parentId&&(g.extent===`parent`||g.expandParent)&&(y=r.get(g.parentId)),y&&g.extent===`parent`&&(b=[[0,0],[y.measured.width,y.measured.height]]),v=[],x=void 0;for(let[e,n]of r)if(n.parentId===t&&(v.push({id:e,position:{...n.position},extent:n.extent}),n.extent===`parent`||n.expandParent)){let e=uN(n,g,n.origin??s);x=x?[[Math.min(e[0][0],x[0][0]),Math.min(e[0][1],x[0][1])],[Math.max(e[1][0],x[1][0]),Math.max(e[1][1],x[1][1])]]:e}u?.(e,{...m})}).on(`drag`,e=>{let{transform:t,snapGrid:i,snapToGrid:a,nodeOrigin:s}=n(),c=Dj(e.sourceEvent,{transform:t,snapGrid:i,snapToGrid:a,containerBounds:_}),l=[];if(!g)return;let{x:u,y:f,width:C,height:w}=m,T={},E=g.origin??s,{width:D,height:O,x:k,y:A}=sN(h,o.controlDirection,c,o.boundaries,o.keepAspectRatio,E,b,x),j=D!==C,M=O!==w,N=k!==u&&j,P=A!==f&&M;if(!N&&!P&&!j&&!M)return;if((N||P||E[0]===1||E[1]===1)&&(T.x=N?k:m.x,T.y=P?A:m.y,m.x=T.x,m.y=T.y,v.length>0)){let e=k-u,t=A-f;for(let n of v)n.position={x:n.position.x-e+E[0]*(D-C),y:n.position.y-t+E[1]*(O-w)},l.push(n)}if((j||M)&&(T.width=j&&(!o.resizeDirection||o.resizeDirection===`horizontal`)?D:m.width,T.height=M&&(!o.resizeDirection||o.resizeDirection===`vertical`)?O:m.height,m.width=T.width,m.height=T.height),y&&g.expandParent){let e=E[0]*(T.width??0);T.x&&T.x<e&&(m.x=e,h.x-=T.x-e);let t=E[1]*(T.height??0);T.y&&T.y<t&&(m.y=t,h.y-=T.y-t)}let F=tN({width:m.width,prevWidth:C,height:m.height,prevHeight:w,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),I={...m,direction:F};p?.(e,I)!==!1&&(S=!0,d?.(e,I),r(T,l))}).on(`end`,e=>{S&&=(f?.(e,{...m}),i?.({...m}),!1)});a.call(C)}function c(){a.on(`.drag`,null)}return{update:s,destroy:c}}var fN=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},o=t=e(r,i,a);return a},pN=e=>e?fN(e):fN,{useDebugValue:mN}=H.default,{useSyncExternalStoreWithSelector:hN}=Mw.default,gN=e=>e;function _N(e,t=gN,n){let r=hN(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return mN(r),r}var vN=(e,t)=>{let n=pN(e),r=(e,r=t)=>_N(n,e,r);return Object.assign(r,n),r},yN=(e,t)=>e?vN(e,t):vN;function bN(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var xN=(0,H.createContext)(null),SN=xN.Provider,CN=EA.error001(`react`);function $(e,t){let n=(0,H.useContext)(xN);if(n===null)throw Error(CN);return _N(n,e,t)}function wN(){let e=(0,H.useContext)(xN);if(e===null)throw Error(CN);return(0,H.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var TN={display:`none`},EN={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},DN=`react-flow__node-desc`,ON=`react-flow__edge-desc`,kN=`react-flow__aria-live`,AN=e=>e.ariaLiveMessage,jN=e=>e.ariaLabelConfig;function MN({rfId:e}){let t=$(AN);return(0,U.jsx)(`div`,{id:`${kN}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:EN,children:t})}function NN({rfId:e,disableKeyboardA11y:t}){let n=$(jN);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{id:`${DN}-${e}`,style:TN,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,U.jsx)(`div`,{id:`${ON}-${e}`,style:TN,children:n[`edge.a11yDescription.default`]}),!t&&(0,U.jsx)(MN,{rfId:e})]})}var PN=(0,H.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>{let o=`${e}`.split(`-`);return(0,U.jsx)(`div`,{className:Uw([`react-flow__panel`,n,...o]),style:r,ref:a,...i,children:t})});PN.displayName=`Panel`;var FN=`https://reactflow.dev?utm_source=attribution`;function IN({proOptions:e,position:t=`bottom-right`}){return(0,H.useEffect)(()=>{},[]),e?.hideAttribution?null:(0,U.jsx)(PN,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${FN}`,children:(0,U.jsx)(`a`,{href:FN,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`,children:`React Flow`})})}var LN=e=>{let t=[],n=[];for(let[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(let[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},RN=e=>e.id;function zN(e,t){return bN(e.selectedNodes.map(RN),t.selectedNodes.map(RN))&&bN(e.selectedEdges.map(RN),t.selectedEdges.map(RN))}function BN({onSelectionChange:e}){let t=wN(),{selectedNodes:n,selectedEdges:r}=$(LN,zN);return(0,H.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChangeHandlers.forEach(e=>e(i))},[n,r,e]),null}var VN=e=>!!e.onSelectionChangeHandlers;function HN({onSelectionChange:e}){let t=$(VN);return e||t?(0,U.jsx)(BN,{onSelectionChange:e}):null}var UN=[0,0],WN={x:0,y:0,zoom:1},GN=[...`nodes.edges.defaultNodes.defaultEdges.onConnect.onConnectStart.onConnectEnd.onClickConnectStart.onClickConnectEnd.nodesDraggable.autoPanOnNodeFocus.nodesConnectable.nodesFocusable.edgesFocusable.edgesReconnectable.elevateNodesOnSelect.elevateEdgesOnSelect.minZoom.maxZoom.nodeExtent.onNodesChange.onEdgesChange.elementsSelectable.connectionMode.snapGrid.snapToGrid.translateExtent.connectOnClick.defaultEdgeOptions.fitView.fitViewOptions.onNodesDelete.onEdgesDelete.onDelete.onNodeDrag.onNodeDragStart.onNodeDragStop.onSelectionDrag.onSelectionDragStart.onSelectionDragStop.onMoveStart.onMove.onMoveEnd.noPanClassName.nodeOrigin.autoPanOnConnect.autoPanOnNodeDrag.onError.connectionRadius.isValidConnection.selectNodesOnDrag.nodeDragThreshold.connectionDragThreshold.onBeforeDelete.debug.autoPanSpeed.ariaLabelConfig.zIndexMode`.split(`.`),`rfId`],KN=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),qN={translateExtent:DA,nodeOrigin:UN,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function JN(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=$(KN,bN),l=wN();(0,H.useEffect)(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=qN,s()}),[]);let u=(0,H.useRef)(qN);return(0,H.useEffect)(()=>{for(let s of GN){let c=e[s];c!==u.current[s]&&e[s]!==void 0&&(s===`nodes`?t(c):s===`edges`?n(c):s===`minZoom`?r(c):s===`maxZoom`?i(c):s===`translateExtent`?a(c):s===`nodeExtent`?o(c):s===`ariaLabelConfig`?l.setState({ariaLabelConfig:Tj(c)}):s===`fitView`?l.setState({fitViewQueued:c}):s===`fitViewOptions`?l.setState({fitViewOptions:c}):l.setState({[s]:c}))}u.current=e},GN.map(t=>e[t])),null}function YN(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function XN(e){let[t,n]=(0,H.useState)(e===`system`?null:e);return(0,H.useEffect)(()=>{if(e!==`system`){n(e);return}let t=YN(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?YN()?.matches?`dark`:`light`:t}var ZN=typeof document<`u`?document:null;function QN(e=null,t={target:ZN,actInsideInputWithModifier:!0}){let[n,r]=(0,H.useState)(!1),i=(0,H.useRef)(!1),a=(0,H.useRef)(new Set([])),[o,s]=(0,H.useMemo)(()=>{if(e!==null){let t=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).map(e=>e.replace(/\+/g,`
|
|
140
|
+
`)})})]}),e.type===`array`&&(0,U.jsx)(Lw,{schema:e.items,onChange:n=>t({...e,items:n})}),e.type===`object`&&(0,U.jsxs)(U.Fragment,{children:[Object.entries(e.fields).map(([n,r])=>(0,U.jsxs)(`fieldset`,{className:`grid min-w-0 gap-3 rounded-lg border p-3`,children:[(0,U.jsx)(`legend`,{className:`px-1 text-sm font-medium`,children:n}),(0,U.jsx)(O,{size:`sm`,variant:`destructive`,className:`justify-self-start`,onClick:()=>t({...e,fields:Object.fromEntries(Object.entries(e.fields).filter(([e])=>e!==n))}),children:`Remove field`}),(0,U.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,U.jsx)(dt,{checked:!!r.required,onCheckedChange:i=>t({...e,fields:{...e.fields,[n]:{...r,required:i}}})}),`Required`]}),(0,U.jsx)(Lw,{schema:r.schema,onChange:i=>t({...e,fields:{...e.fields,[n]:{...r,schema:i}}})}),(0,U.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,U.jsx)(dt,{checked:r.default!==void 0,onCheckedChange:i=>{let a={...r};i?a.default=Fw(r.schema):delete a.default,t({...e,fields:{...e.fields,[n]:a}})}}),`Default`]}),r.default!==void 0&&(0,U.jsx)(Iw,{schema:r.schema,value:r.default,onChange:i=>t({...e,fields:{...e.fields,[n]:{...r,default:i}}})})]},n)),(0,U.jsxs)(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:n=>{n.preventDefault();let r=n.currentTarget,i=String(new FormData(r).get(`field`));i&&![`__proto__`,`constructor`,`prototype`].includes(i)&&!e.fields[i]&&(t({...e,fields:{...e.fields,[i]:{schema:{type:`string`}}}}),r.reset())},children:[(0,U.jsx)(he,{className:`min-w-0 flex-1`,name:`field`,"aria-label":`New field name`,placeholder:`Field name`,required:!0}),(0,U.jsx)(O,{type:`submit`,size:`sm`,variant:`outline`,children:`Add field`})]})]})]})}function Rw(e,t){return{...e,workflowId:t.id,contract:structuredClone(t.contract)}}function zw(e,t){let n=[],r=new Set;for(let i=t||void 0;i!==void 0;){let t=e.invocations?.[i];if(!t||r.has(i))break;r.add(i);let a=t.parentInvocationId?e.invocations?.[t.parentInvocationId]:void 0,o=a?e.retainedDefinitions?.[a.definitionId]:e.definition;n.unshift({id:i,name:e.retainedDefinitions?.[t.definitionId]?.name??t.definitionId,call:o?.steps.find(e=>e.id===t.callStepId)?.name??t.callStepId,attempt:t.callAttempt}),i=t.parentInvocationId}return n}function Bw(e,t,n,r){return`stepId=${encodeURIComponent(e)}${n?``:`&attempt=${t}`}${r?`&invocationId=${encodeURIComponent(r)}`:``}`}var Vw=e(ve(),1);function Hw(e){return{x:e%3*286,y:Math.floor(e/3)*270}}function Uw(e){let t;try{t=new Set(GC(e).loops.map(e=>e.headerId))}catch{t=new Set(e.steps.filter(t=>{let n=e.edges.filter(e=>e.from===t.id).map(e=>e.to),r=new Set;for(;n.length;){let i=n.pop();if(i===t.id)return!0;r.has(i)||(r.add(i),n.push(...e.edges.filter(e=>e.from===i).map(e=>e.to)))}return!1}).map(e=>e.id))}return{...e,loopSettings:Object.fromEntries(Object.entries(e.loopSettings??{}).filter(([e])=>t.has(e))),steps:e.steps.map(e=>{if(t.has(e.id)||!e.repeatMapping)return e;let n={...e};return delete n.repeatMapping,n})}}function Ww(e,{orientation:t=`horizontal`}={}){let n=GC(e).loops,r=new Map(e.steps.map((e,t)=>[e.id,e.position??Hw(t)])),i=new Map;for(let e of[...n].reverse()){let a=n.filter(t=>t.parentHeaderId===e.headerId),o=[...e.memberIds.filter(e=>!a.some(t=>t.memberIds.includes(e))).map(e=>({...r.get(e),width:208,height:192})),...a.map(e=>i.get(e.headerId))],s=Math.min(...o.map(e=>e.x)),c=Math.min(...o.map(e=>e.y)),l=Math.max(...o.map(e=>e.x+e.width)),u=Math.max(...o.map(e=>e.y+e.height)),d=t===`vertical`,f=s-(d?264:24),p=c-(d?24:112);i.set(e.headerId,{x:f,y:p,width:d?l+24-f:Math.max(360,l+24-f),height:u+24-p})}let a=`loop:`;for(;e.steps.some(e=>e.id.startsWith(a));)a+=`:`;let o=e=>`${a}${e}`,s=(e,t)=>{let n=t?i.get(t):{x:0,y:0};return{x:e.x-n.x,y:e.y-n.y}};return[...n.map(e=>({id:o(e.headerId),type:`loop`,...e.parentHeaderId?{parentId:o(e.parentHeaderId)}:{},position:s(i.get(e.headerId),e.parentHeaderId),style:{width:i.get(e.headerId).width,height:i.get(e.headerId).height},selectable:!1,deletable:!1,draggable:!1,connectable:!1,zIndex:1,data:{headerId:e.headerId,orientation:t}})),...e.steps.map(e=>{let t=[...n].reverse().find(t=>t.memberIds.includes(e.id));return{id:e.id,type:`workflow`,...t?{parentId:o(t.headerId)}:{},position:s(r.get(e.id),t?.headerId),zIndex:2,data:{step:e}}})]}function Gw(e,t){let n=t.find(t=>t.id===e.parentId),r=n?Gw(n,t):{x:0,y:0};return{x:e.position.x+r.x,y:e.position.y+r.y}}function Kw(e,t){let n=t+e.grants.filter(t=>t.activation===e.activation).length,r=e.try;return`${e.phase===`inactive`?`Not started`:`Try ${r} of ${n}`} · ${e.phase===`limit`?`Loop limit reached`:e.phase}`}function qw(e){return Object.entries(e.loops??{}).filter(([,e])=>e.phase===`limit`)}function Jw(e,t){if(t===void 0)return`In progress`;let n=Math.max(0,Math.floor((t-e)/1e3));return[[Math.floor(n/3600),`h`],[Math.floor(n/60)%60,`m`],[n%60,`s`]].filter(([e])=>e!==0).map(([e,t])=>`${e}${t}`).join(` `)||`0s`}var Yw=.1,Xw=.05;function Zw(e,t){let n=GC(e),r=new Set(n.loops.flatMap(e=>e.backEdgeIds)),i=new Map(e.steps.map(e=>[e.id,[]]));for(let t of e.edges)r.has(t.id)||i.get(t.to).push(t.from);let a=new Map,o=new Map(e.edges.map(e=>[e.id,e]));for(let e of n.loops)for(let t of e.exitEdgeIds){if(r.has(t))continue;let n=o.get(t)?.to;n&&a.set(n,[...a.get(n)??[],e])}let s=new Map,c=!0;for(;c;){c=!1;for(let e of n.order){let t=Math.max(-1,...i.get(e).map(e=>s.get(e)??-1),...(a.get(e)??[]).flatMap(e=>e.memberIds.map(e=>s.get(e)??-1)))+1;(s.get(e)??-1)<t&&(s.set(e,t),c=!0)}}let l=new Map(n.loops.map(e=>[e.headerId,e])),u=e=>{let t=0,r=[...n.loops].reverse().find(t=>t.memberIds.includes(e));for(;r;)t++,r=r.parentHeaderId?l.get(r.parentHeaderId):void 0;return t},d=Math.max(0,...e.steps.map(e=>u(e.id))),f=new Map,p=(t,r)=>{let i=n.loops.filter(e=>e.parentHeaderId===t),a=new Set(i.flatMap(e=>e.memberIds)),o=t?l.get(t):void 0,c=e.steps.filter(e=>(o?o.memberIds.includes(e.id):u(e.id)===0)&&!a.has(e.id)),d=new Map;for(let e of c){let t=s.get(e.id)??0,n=d.get(t)??0;f.set(e.id,r+n),d.set(t,n+1)}let m=r+Math.max(1,...d.values());for(let e of i)m+=p(e.headerId,m);return m-r};p(void 0,0);let m=t?310+d*288:270+d*136,h=t?220+d*2*24:350+d*2*24;return{...e,steps:e.steps.map(e=>{let n=s.get(e.id)??0,r=f.get(e.id)??0;return{...e,position:t?{x:r*m,y:n*h}:{x:n*h,y:r*m}}})}}function Qw(e){if(typeof e==`string`||typeof e==`number`)return``+e;let t=``;if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=Qw(e[n]))!==``&&(t+=(t&&` `)+r);else for(let n in e)e[n]&&(t+=(t&&` `)+n);return t}var $w={value:()=>{}};function eT(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+``)||r in n||/[\s.]/.test(r))throw Error(`illegal type: `+r);n[r]=[]}return new tT(n)}function tT(e){this._=e}function nT(e,t){return e.trim().split(/^|\s+/).map(function(e){var n=``,r=e.indexOf(`.`);if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}tT.prototype=eT.prototype={constructor:tT,on:function(e,t){var n=this._,r=nT(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=rT(n[i],e.name)))return i;return}if(t!=null&&typeof t!=`function`)throw Error(`invalid callback: `+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=iT(n[i],e.name,t);else if(t==null)for(i in n)n[i]=iT(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new tT(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function rT(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function iT(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=$w,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var aT={svg:`http://www.w3.org/2000/svg`,xhtml:`http://www.w3.org/1999/xhtml`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function oT(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),aT.hasOwnProperty(t)?{space:aT[t],local:e}:e}function sT(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function cT(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function lT(e){var t=oT(e);return(t.local?cT:sT)(t)}function uT(){}function dT(e){return e==null?uT:function(){return this.querySelector(e)}}function fT(e){typeof e!=`function`&&(e=dT(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=Array(o),c,l,u=0;u<o;++u)(c=a[u])&&(l=e.call(c,c.__data__,u,a))&&(`__data__`in c&&(l.__data__=c.__data__),s[u]=l);return new eD(r,this._parents)}function pT(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function mT(){return[]}function hT(e){return e==null?mT:function(){return this.querySelectorAll(e)}}function gT(e){return function(){return pT(e.apply(this,arguments))}}function _T(e){e=typeof e==`function`?gT(e):hT(e);for(var t=this._groups,n=t.length,r=[],i=[],a=0;a<n;++a)for(var o=t[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),i.push(c));return new eD(r,i)}function vT(e){return function(){return this.matches(e)}}function yT(e){return function(t){return t.matches(e)}}var bT=Array.prototype.find;function xT(e){return function(){return bT.call(this.children,e)}}function ST(){return this.firstElementChild}function CT(e){return this.select(e==null?ST:xT(typeof e==`function`?e:yT(e)))}var wT=Array.prototype.filter;function TT(){return Array.from(this.children)}function ET(e){return function(){return wT.call(this.children,e)}}function DT(e){return this.selectAll(e==null?TT:ET(typeof e==`function`?e:yT(e)))}function OT(e){typeof e!=`function`&&(e=vT(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new eD(r,this._parents)}function kT(e){return Array(e.length)}function AT(){return new eD(this._enter||this._groups.map(kT),this._parents)}function jT(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}jT.prototype={constructor:jT,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function MT(e){return function(){return e}}function NT(e,t,n,r,i,a){for(var o=0,s,c=t.length,l=a.length;o<l;++o)(s=t[o])?(s.__data__=a[o],r[o]=s):n[o]=new jT(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function PT(e,t,n,r,i,a,o){var s,c,l=new Map,u=t.length,d=a.length,f=Array(u),p;for(s=0;s<u;++s)(c=t[s])&&(f[s]=p=o.call(c,c.__data__,s,t)+``,l.has(p)?i[s]=c:l.set(p,c));for(s=0;s<d;++s)p=o.call(e,a[s],s,a)+``,(c=l.get(p))?(r[s]=c,c.__data__=a[s],l.delete(p)):n[s]=new jT(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function FT(e){return e.__data__}function IT(e,t){if(!arguments.length)return Array.from(this,FT);var n=t?PT:NT,r=this._parents,i=this._groups;typeof e!=`function`&&(e=MT(e));for(var a=i.length,o=Array(a),s=Array(a),c=Array(a),l=0;l<a;++l){var u=r[l],d=i[l],f=d.length,p=LT(e.call(u,u&&u.__data__,l,r)),m=p.length,h=s[l]=Array(m),g=o[l]=Array(m);n(u,d,h,g,c[l]=Array(f),p,t);for(var _=0,v=0,y,b;_<m;++_)if(y=h[_]){for(_>=v&&(v=_+1);!(b=g[v])&&++v<m;);y._next=b||null}}return o=new eD(o,r),o._enter=s,o._exit=c,o}function LT(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function RT(){return new eD(this._exit||this._groups.map(kT),this._parents)}function zT(e,t,n){var r=this.enter(),i=this,a=this.exit();return typeof e==`function`?(r=e(r),r&&=r.selection()):r=r.append(e+``),t!=null&&(i=t(i),i&&=i.selection()),n==null?a.remove():n(a),r&&i?r.merge(i).order():i}function BT(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,a=r.length,o=Math.min(i,a),s=Array(i),c=0;c<o;++c)for(var l=n[c],u=r[c],d=l.length,f=s[c]=Array(d),p,m=0;m<d;++m)(p=l[m]||u[m])&&(f[m]=p);for(;c<i;++c)s[c]=n[c];return new eD(s,this._parents)}function VT(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,a=r[i],o;--i>=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function HT(e){e||=UT;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;a<r;++a){for(var o=n[a],s=o.length,c=i[a]=Array(s),l,u=0;u<s;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new eD(i,this._parents).order()}function UT(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function WT(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function GT(){return Array.from(this)}function KT(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null}function qT(){let e=0;for(let t of this)++e;return e}function JT(){return!this.node()}function YT(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],a=0,o=i.length,s;a<o;++a)(s=i[a])&&e.call(s,s.__data__,a,i);return this}function XT(e){return function(){this.removeAttribute(e)}}function ZT(e){return function(){this.removeAttributeNS(e.space,e.local)}}function QT(e,t){return function(){this.setAttribute(e,t)}}function $T(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function eE(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function tE(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function nE(e,t){var n=oT(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?ZT:XT:typeof t==`function`?n.local?tE:eE:n.local?$T:QT)(n,t))}function rE(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function iE(e){return function(){this.style.removeProperty(e)}}function aE(e,t,n){return function(){this.style.setProperty(e,t,n)}}function oE(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function sE(e,t,n){return arguments.length>1?this.each((t==null?iE:typeof t==`function`?oE:aE)(e,t,n??``)):cE(this.node(),e)}function cE(e,t){return e.style.getPropertyValue(t)||rE(e).getComputedStyle(e,null).getPropertyValue(t)}function lE(e){return function(){delete this[e]}}function uE(e,t){return function(){this[e]=t}}function dE(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function fE(e,t){return arguments.length>1?this.each((t==null?lE:typeof t==`function`?dE:uE)(e,t)):this.node()[e]}function pE(e){return e.trim().split(/^|\s+/)}function mE(e){return e.classList||new hE(e)}function hE(e){this._node=e,this._names=pE(e.getAttribute(`class`)||``)}hE.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function gE(e,t){for(var n=mE(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function _E(e,t){for(var n=mE(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function vE(e){return function(){gE(this,e)}}function yE(e){return function(){_E(this,e)}}function bE(e,t){return function(){(t.apply(this,arguments)?gE:_E)(this,e)}}function xE(e,t){var n=pE(e+``);if(arguments.length<2){for(var r=mE(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?bE:t?vE:yE)(n,t))}function SE(){this.textContent=``}function CE(e){return function(){this.textContent=e}}function wE(e){return function(){var t=e.apply(this,arguments);this.textContent=t??``}}function TE(e){return arguments.length?this.each(e==null?SE:(typeof e==`function`?wE:CE)(e)):this.node().textContent}function EE(){this.innerHTML=``}function DE(e){return function(){this.innerHTML=e}}function OE(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??``}}function kE(e){return arguments.length?this.each(e==null?EE:(typeof e==`function`?OE:DE)(e)):this.node().innerHTML}function AE(){this.nextSibling&&this.parentNode.appendChild(this)}function jE(){return this.each(AE)}function ME(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function NE(){return this.each(ME)}function PE(e){var t=typeof e==`function`?e:lT(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function FE(){return null}function IE(e,t){var n=typeof e==`function`?e:lT(e),r=t==null?FE:typeof t==`function`?t:dT(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function LE(){var e=this.parentNode;e&&e.removeChild(this)}function RE(){return this.each(LE)}function zE(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function BE(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function VE(e){return this.select(e?BE:zE)}function HE(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function UE(e){return function(t){e.call(this,t,this.__data__)}}function WE(e){return e.trim().split(/^|\s+/).map(function(e){var t=``,n=e.indexOf(`.`);return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function GE(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n<i;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function KE(e,t,n){return function(){var r=this.__on,i,a=UE(t);if(r){for(var o=0,s=r.length;o<s;++o)if((i=r[o]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=n),i.value=t;return}}this.addEventListener(e.type,a,n),i={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(i):this.__on=[i]}}function qE(e,t,n){var r=WE(e+``),i,a=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,l=s.length,u;c<l;++c)for(i=0,u=s[c];i<a;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}return}for(s=t?KE:GE,i=0;i<a;++i)this.each(s(r[i],t,n));return this}function JE(e,t,n){var r=rE(e),i=r.CustomEvent;typeof i==`function`?i=new i(t,n):(i=r.document.createEvent(`Event`),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function YE(e,t){return function(){return JE(this,e,t)}}function XE(e,t){return function(){return JE(this,e,t.apply(this,arguments))}}function ZE(e,t){return this.each((typeof t==`function`?XE:YE)(e,t))}function*QE(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length,o;i<a;++i)(o=r[i])&&(yield o)}var $E=[null];function eD(e,t){this._groups=e,this._parents=t}function tD(){return new eD([[document.documentElement]],$E)}function nD(){return this}eD.prototype=tD.prototype={constructor:eD,select:fT,selectAll:_T,selectChild:CT,selectChildren:DT,filter:OT,data:IT,enter:AT,exit:RT,join:zT,merge:BT,selection:nD,order:VT,sort:HT,call:WT,nodes:GT,node:KT,size:qT,empty:JT,each:YT,attr:nE,style:sE,property:fE,classed:xE,text:TE,html:kE,raise:jE,lower:NE,append:PE,insert:IE,remove:RE,clone:VE,datum:HE,on:qE,dispatch:ZE,[Symbol.iterator]:QE};function rD(e){return typeof e==`string`?new eD([[document.querySelector(e)]],[document.documentElement]):new eD([[e]],$E)}function iD(e){let t;for(;t=e.sourceEvent;)e=t;return e}function aD(e,t){if(e=iD(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}var oD={passive:!1},sD={capture:!0,passive:!1};function cD(e){e.stopImmediatePropagation()}function lD(e){e.preventDefault(),e.stopImmediatePropagation()}function uD(e){var t=e.document.documentElement,n=rD(e).on(`dragstart.drag`,lD,sD);`onselectstart`in t?n.on(`selectstart.drag`,lD,sD):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect=`none`)}function dD(e,t){var n=e.document.documentElement,r=rD(e).on(`dragstart.drag`,null);t&&(r.on(`click.drag`,lD,sD),setTimeout(function(){r.on(`click.drag`,null)},0)),`onselectstart`in n?r.on(`selectstart.drag`,null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var fD=e=>()=>e;function pD(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}pD.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function mD(e){return!e.ctrlKey&&!e.button}function hD(){return this.parentNode}function gD(e,t){return t??{x:e.x,y:e.y}}function _D(){return navigator.maxTouchPoints||`ontouchstart`in this}function vD(){var e=mD,t=hD,n=gD,r=_D,i={},a=eT(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,g).on(`touchmove.drag`,_,oD).on(`touchend.drag touchcancel.drag`,v).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!(u||!e.call(this,n,r))){var i=y(this,t.call(this,n,r),n,r,`mouse`);i&&(rD(n.view).on(`mousemove.drag`,m,sD).on(`mouseup.drag`,h,sD),uD(n.view),cD(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(lD(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){rD(e.view).on(`mousemove.drag mouseup.drag`,null),dD(e.view,l),lD(e),i.mouse(`end`,e)}function g(n,r){if(e.call(this,n,r)){var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s,c;for(s=0;s<o;++s)(c=y(this,a,n,r,i[s].identifier,i[s]))&&(cD(n),c(`start`,n,i[s]))}}function _(e){var t=e.changedTouches,n=t.length,r,a;for(r=0;r<n;++r)(a=i[t[r].identifier])&&(lD(e),a(`drag`,e,t[r]))}function v(e){var t=e.changedTouches,n=t.length,r,a;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),r=0;r<n;++r)(a=i[t[r].identifier])&&(cD(e),a(`end`,e,t[r]))}function y(e,t,r,s,c,l){var u=a.copy(),d=aD(l||r,t),p,m,h;if((h=n.call(e,new pD(`beforestart`,{sourceEvent:r,target:f,identifier:c,active:o,x:d[0],y:d[1],dx:0,dy:0,dispatch:u}),s))!=null)return p=h.x-d[0]||0,m=h.y-d[1]||0,function n(r,a,l){var g=d,_;switch(r){case`start`:i[c]=n,_=o++;break;case`end`:delete i[c],--o;case`drag`:d=aD(l||a,t),_=o}u.call(r,e,new pD(r,{sourceEvent:a,subject:h,target:f,identifier:c,active:_,x:d[0]+p,y:d[1]+m,dx:d[0]-g[0],dy:d[1]-g[1],dispatch:u}),s)}}return f.filter=function(t){return arguments.length?(e=typeof t==`function`?t:fD(!!t),f):e},f.container=function(e){return arguments.length?(t=typeof e==`function`?e:fD(e),f):t},f.subject=function(e){return arguments.length?(n=typeof e==`function`?e:fD(e),f):n},f.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:fD(!!e),f):r},f.on=function(){var e=a.on.apply(a,arguments);return e===a?f:e},f.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,f):Math.sqrt(d)},f}function yD(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function bD(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function xD(){}var SD=.7,CD=1/SD,wD=`\\s*([+-]?\\d+)\\s*`,TD=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,ED=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,DD=/^#([0-9a-f]{3,8})$/,OD=RegExp(`^rgb\\(${wD},${wD},${wD}\\)$`),kD=RegExp(`^rgb\\(${ED},${ED},${ED}\\)$`),AD=RegExp(`^rgba\\(${wD},${wD},${wD},${TD}\\)$`),jD=RegExp(`^rgba\\(${ED},${ED},${ED},${TD}\\)$`),MD=RegExp(`^hsl\\(${TD},${ED},${ED}\\)$`),ND=RegExp(`^hsla\\(${TD},${ED},${ED},${TD}\\)$`),PD={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};yD(xD,zD,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:FD,formatHex:FD,formatHex8:ID,formatHsl:LD,formatRgb:RD,toString:RD});function FD(){return this.rgb().formatHex()}function ID(){return this.rgb().formatHex8()}function LD(){return QD(this).formatHsl()}function RD(){return this.rgb().formatRgb()}function zD(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=DD.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?BD(t):n===3?new WD(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?VD(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?VD(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=OD.exec(e))?new WD(t[1],t[2],t[3],1):(t=kD.exec(e))?new WD(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=AD.exec(e))?VD(t[1],t[2],t[3],t[4]):(t=jD.exec(e))?VD(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=MD.exec(e))?ZD(t[1],t[2]/100,t[3]/100,1):(t=ND.exec(e))?ZD(t[1],t[2]/100,t[3]/100,t[4]):PD.hasOwnProperty(e)?BD(PD[e]):e===`transparent`?new WD(NaN,NaN,NaN,0):null}function BD(e){return new WD(e>>16&255,e>>8&255,e&255,1)}function VD(e,t,n,r){return r<=0&&(e=t=n=NaN),new WD(e,t,n,r)}function HD(e){return e instanceof xD||(e=zD(e)),e?(e=e.rgb(),new WD(e.r,e.g,e.b,e.opacity)):new WD}function UD(e,t,n,r){return arguments.length===1?HD(e):new WD(e,t,n,r??1)}function WD(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}yD(WD,UD,bD(xD,{brighter(e){return e=e==null?CD:CD**+e,new WD(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?SD:SD**+e,new WD(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new WD(YD(this.r),YD(this.g),YD(this.b),JD(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:GD,formatHex:GD,formatHex8:KD,formatRgb:qD,toString:qD}));function GD(){return`#${XD(this.r)}${XD(this.g)}${XD(this.b)}`}function KD(){return`#${XD(this.r)}${XD(this.g)}${XD(this.b)}${XD((isNaN(this.opacity)?1:this.opacity)*255)}`}function qD(){let e=JD(this.opacity);return`${e===1?`rgb(`:`rgba(`}${YD(this.r)}, ${YD(this.g)}, ${YD(this.b)}${e===1?`)`:`, ${e})`}`}function JD(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function YD(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function XD(e){return e=YD(e),(e<16?`0`:``)+e.toString(16)}function ZD(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new eO(e,t,n,r)}function QD(e){if(e instanceof eO)return new eO(e.h,e.s,e.l,e.opacity);if(e instanceof xD||(e=zD(e)),!e)return new eO;if(e instanceof eO)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new eO(o,s,c,e.opacity)}function $D(e,t,n,r){return arguments.length===1?QD(e):new eO(e,t,n,r??1)}function eO(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}yD(eO,$D,bD(xD,{brighter(e){return e=e==null?CD:CD**+e,new eO(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?SD:SD**+e,new eO(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new WD(rO(e>=240?e-240:e+120,i,r),rO(e,i,r),rO(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new eO(tO(this.h),nO(this.s),nO(this.l),JD(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=JD(this.opacity);return`${e===1?`hsl(`:`hsla(`}${tO(this.h)}, ${nO(this.s)*100}%, ${nO(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function tO(e){return e=(e||0)%360,e<0?e+360:e}function nO(e){return Math.max(0,Math.min(1,e||0))}function rO(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var iO=e=>()=>e;function aO(e,t){return function(n){return e+n*t}}function oO(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function sO(e){return(e=+e)==1?cO:function(t,n){return n-t?oO(t,n,e):iO(isNaN(t)?n:t)}}function cO(e,t){var n=t-e;return n?aO(e,n):iO(isNaN(e)?t:e)}var lO=(function e(t){var n=sO(t);function r(e,t){var r=n((e=UD(e)).r,(t=UD(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=cO(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function uO(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=e[i]*(1-a)+t[i]*a;return r}}function dO(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function fO(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=Array(r),a=Array(n),o;for(o=0;o<r;++o)i[o]=xO(e[o],t[o]);for(;o<n;++o)a[o]=t[o];return function(e){for(o=0;o<r;++o)a[o]=i[o](e);return a}}function pO(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function mO(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function hO(e,t){var n={},r={},i;for(i in(typeof e!=`object`||!e)&&(e={}),(typeof t!=`object`||!t)&&(t={}),t)i in e?n[i]=xO(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var gO=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,_O=new RegExp(gO.source,`g`);function vO(e){return function(){return e}}function yO(e){return function(t){return e(t)+``}}function bO(e,t){var n=gO.lastIndex=_O.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=gO.exec(e))&&(i=_O.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:mO(r,i)})),n=_O.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?yO(c[0].x):vO(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}function xO(e,t){var n=typeof t,r;return t==null||n===`boolean`?iO(t):(n===`number`?mO:n===`string`?(r=zD(t))?(t=r,lO):bO:t instanceof zD?lO:t instanceof Date?pO:dO(t)?uO:Array.isArray(t)?fO:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?hO:mO)(e,t)}var SO=180/Math.PI,CO={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function wO(e,t,n,r,i,a){var o,s,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*SO,skewX:Math.atan(c)*SO,scaleX:o,scaleY:s}}var TO;function EO(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?CO:wO(t.a,t.b,t.c,t.d,t.e,t.f)}function DO(e){return e==null||(TO||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),TO.setAttribute(`transform`,e),!(e=TO.transform.baseVal.consolidate()))?CO:(e=e.matrix,wO(e.a,e.b,e.c,e.d,e.e,e.f))}function OO(e,t,n,r){function i(e){return e.length?e.pop()+` `:``}function a(e,r,i,a,o,s){if(e!==i||r!==a){var c=o.push(`translate(`,null,t,null,n);s.push({i:c-4,x:mO(e,i)},{i:c-2,x:mO(r,a)})}else(i||a)&&o.push(`translate(`+i+t+a+n)}function o(e,t,n,a){e===t?t&&n.push(i(n)+`rotate(`+t+r):(e-t>180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:mO(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:mO(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:mO(e,n)},{i:s-2,x:mO(t,r)})}else(n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t<n;)r[(a=i[t]).i]=a.x(e);return r.join(``)}}}var kO=OO(EO,`px, `,`px)`,`deg)`),AO=OO(DO,`, `,`)`,`)`),jO=1e-12;function MO(e){return((e=Math.exp(e))+1/e)/2}function NO(e){return((e=Math.exp(e))-1/e)/2}function PO(e){return((e=Math.exp(2*e))-1)/(e+1)}var FO=(function e(t,n,r){function i(e,i){var a=e[0],o=e[1],s=e[2],c=i[0],l=i[1],u=i[2],d=c-a,f=l-o,p=d*d+f*f,m,h;if(p<jO)h=Math.log(u/s)/t,m=function(e){return[a+e*d,o+e*f,s*Math.exp(t*e*h)]};else{var g=Math.sqrt(p),_=(u*u-s*s+r*p)/(2*s*n*g),v=(u*u-s*s-r*p)/(2*u*n*g),y=Math.log(Math.sqrt(_*_+1)-_);h=(Math.log(Math.sqrt(v*v+1)-v)-y)/t,m=function(e){var r=e*h,i=MO(y),c=s/(n*g)*(i*PO(t*r+y)-NO(y));return[a+c*d,o+c*f,s*i/MO(t*r+y)]}}return m.duration=h*1e3*t/Math.SQRT2,m}return i.rho=function(t){var n=Math.max(.001,+t),r=n*n;return e(n,r,r*r)},i})(Math.SQRT2,2,4),IO=0,LO=0,RO=0,zO=1e3,BO,VO,HO=0,UO=0,WO=0,GO=typeof performance==`object`&&performance.now?performance:Date,KO=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function qO(){return UO||=(KO(JO),GO.now()+WO)}function JO(){UO=0}function YO(){this._call=this._time=this._next=null}YO.prototype=XO.prototype={constructor:YO,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?qO():+n)+(t==null?0:+t),!this._next&&VO!==this&&(VO?VO._next=this:BO=this,VO=this),this._call=e,this._time=n,tk()},stop:function(){this._call&&(this._call=null,this._time=1/0,tk())}};function XO(e,t,n){var r=new YO;return r.restart(e,t,n),r}function ZO(){qO(),++IO;for(var e=BO,t;e;)(t=UO-e._time)>=0&&e._call.call(void 0,t),e=e._next;--IO}function QO(){UO=(HO=GO.now())+WO,IO=LO=0;try{ZO()}finally{IO=0,ek(),UO=0}}function $O(){var e=GO.now(),t=e-HO;t>zO&&(WO-=t,HO=e)}function ek(){for(var e,t=BO,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:BO=n);VO=e,tk(r)}function tk(e){IO||(LO&&=clearTimeout(LO),e-UO>24?(e<1/0&&(LO=setTimeout(QO,e-GO.now()-WO)),RO&&=clearInterval(RO)):(RO||=(HO=GO.now(),setInterval($O,zO)),IO=1,KO(QO)))}function nk(e,t,n){var r=new YO;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var rk=eT(`start`,`end`,`cancel`,`interrupt`),ik=[];function ak(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;lk(e,n,{name:t,index:r,group:i,on:rk,tween:ik,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function ok(e,t){var n=ck(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function sk(e,t){var n=ck(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function ck(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function lk(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=XO(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return nk(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l<t&&(f.state=6,f.timer.stop(),f.on.call(`cancel`,e,e.__data__,f.index,f.group),delete r[l])}if(nk(function(){n.state===3&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))}),n.state=2,n.on.call(`start`,e,e.__data__,n.index,n.group),n.state===2){for(n.state=3,i=Array(d=n.tween.length),l=0,u=-1;l<d;++l)(f=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(i[++u]=f);i.length=u+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(c),n.state=5,1),a=-1,o=i.length;++a<o;)i[a].call(e,r);n.state===5&&(n.on.call(`end`,e,e.__data__,n.index,n.group),c())}function c(){for(var i in n.state=6,n.timer.stop(),delete r[t],r)return;delete e.__transition}}function uk(e,t){var n=e.__transition,r,i,a=!0,o;if(n){for(o in t=t==null?null:t+``,n){if((r=n[o]).name!==t){a=!1;continue}i=r.state>2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]}a&&delete e.__transition}}function dk(e){return this.each(function(){uk(this,e)})}function fk(e,t){var n,r;return function(){var i=sk(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o<s;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function pk(e,t,n){var r,i;if(typeof n!=`function`)throw Error();return function(){var a=sk(this,e),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:t,value:n},c=0,l=i.length;c<l;++c)if(i[c].name===t){i[c]=s;break}c===l&&i.push(s)}a.tween=i}}function mk(e,t){var n=this._id;if(e+=``,arguments.length<2){for(var r=ck(this.node(),n).tween,i=0,a=r.length,o;i<a;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((t==null?fk:pk)(n,e,t))}function hk(e,t,n){var r=e._id;return e.each(function(){var e=sk(this,r);(e.value||={})[t]=n.apply(this,arguments)}),function(e){return ck(e,r).value[t]}}function gk(e,t){var n;return(typeof t==`number`?mO:t instanceof zD?lO:(n=zD(t))?(t=n,lO):bO)(e,t)}function _k(e){return function(){this.removeAttribute(e)}}function vk(e){return function(){this.removeAttributeNS(e.space,e.local)}}function yk(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttribute(e);return o===i?null:o===r?a:a=t(r=o,n)}}function bk(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttributeNS(e.space,e.local);return o===i?null:o===r?a:a=t(r=o,n)}}function xk(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function Sk(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function Ck(e,t){var n=oT(e),r=n===`transform`?AO:gk;return this.attrTween(e,typeof t==`function`?(n.local?Sk:xk)(n,r,hk(this,`attr.`+e,t)):t==null?(n.local?vk:_k)(n):(n.local?bk:yk)(n,r,t))}function wk(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Tk(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Ek(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Tk(e,i)),n}return i._value=t,i}function Dk(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&wk(e,i)),n}return i._value=t,i}function Ok(e,t){var n=`attr.`+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!=`function`)throw Error();var r=oT(e);return this.tween(n,(r.local?Ek:Dk)(r,t))}function kk(e,t){return function(){ok(this,e).delay=+t.apply(this,arguments)}}function Ak(e,t){return t=+t,function(){ok(this,e).delay=t}}function jk(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?kk:Ak)(t,e)):ck(this.node(),t).delay}function Mk(e,t){return function(){sk(this,e).duration=+t.apply(this,arguments)}}function Nk(e,t){return t=+t,function(){sk(this,e).duration=t}}function Pk(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?Mk:Nk)(t,e)):ck(this.node(),t).duration}function Fk(e,t){if(typeof t!=`function`)throw Error();return function(){sk(this,e).ease=t}}function Ik(e){var t=this._id;return arguments.length?this.each(Fk(t,e)):ck(this.node(),t).ease}function Lk(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();sk(this,e).ease=n}}function Rk(e){if(typeof e!=`function`)throw Error();return this.each(Lk(this._id,e))}function zk(e){typeof e!=`function`&&(e=vT(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new mA(r,this._parents,this._name,this._id)}function Bk(e){if(e._id!==this._id)throw Error();for(var t=this._groups,n=e._groups,r=t.length,i=n.length,a=Math.min(r,i),o=Array(r),s=0;s<a;++s)for(var c=t[s],l=n[s],u=c.length,d=o[s]=Array(u),f,p=0;p<u;++p)(f=c[p]||l[p])&&(d[p]=f);for(;s<r;++s)o[s]=t[s];return new mA(o,this._parents,this._name,this._id)}function Vk(e){return(e+``).trim().split(/^|\s+/).every(function(e){var t=e.indexOf(`.`);return t>=0&&(e=e.slice(0,t)),!e||e===`start`})}function Hk(e,t,n){var r,i,a=Vk(t)?ok:sk;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function Uk(e,t){var n=this._id;return arguments.length<2?ck(this.node(),n).on.on(e):this.each(Hk(n,e,t))}function Wk(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Gk(){return this.on(`end.remove`,Wk(this._id))}function Kk(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=dT(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o<i;++o)for(var s=r[o],c=s.length,l=a[o]=Array(c),u,d,f=0;f<c;++f)(u=s[f])&&(d=e.call(u,u.__data__,f,s))&&(`__data__`in u&&(d.__data__=u.__data__),l[f]=d,ak(l[f],t,n,f,l,ck(u,n)));return new mA(a,this._parents,t,n)}function qk(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=hT(e));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var c=r[s],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),p,m=ck(u,n),h=0,g=f.length;h<g;++h)(p=f[h])&&ak(p,t,n,h,f,m);a.push(f),o.push(u)}return new mA(a,o,t,n)}var Jk=tD.prototype.constructor;function Yk(){return new Jk(this._groups,this._parents)}function Xk(e,t){var n,r,i;return function(){var a=cE(this,e),o=(this.style.removeProperty(e),cE(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function Zk(e){return function(){this.style.removeProperty(e)}}function Qk(e,t,n){var r,i=n+``,a;return function(){var o=cE(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function $k(e,t,n){var r,i,a;return function(){var o=cE(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),cE(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function eA(e,t){var n,r,i,a=`style.`+t,o=`end.`+a,s;return function(){var c=sk(this,e),l=c.on,u=c.value[a]==null?s||=Zk(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function tA(e,t,n){var r=(e+=``)==`transform`?kO:gk;return t==null?this.styleTween(e,Xk(e,r)).on(`end.style.`+e,Zk(e)):typeof t==`function`?this.styleTween(e,$k(e,r,hk(this,`style.`+e,t))).each(eA(this._id,e)):this.styleTween(e,Qk(e,r,t),n).on(`end.style.`+e,null)}function nA(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function rA(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&nA(e,a,n)),r}return a._value=t,a}function iA(e,t,n){var r=`style.`+(e+=``);if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!=`function`)throw Error();return this.tween(r,rA(e,t,n??``))}function aA(e){return function(){this.textContent=e}}function oA(e){return function(){var t=e(this);this.textContent=t??``}}function sA(e){return this.tween(`text`,typeof e==`function`?oA(hk(this,`text`,e)):aA(e==null?``:e+``))}function cA(e){return function(t){this.textContent=e.call(this,t)}}function lA(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&cA(r)),t}return r._value=e,r}function uA(e){var t=`text`;if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!=`function`)throw Error();return this.tween(t,lA(e))}function dA(){for(var e=this._name,t=this._id,n=hA(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)if(c=o[l]){var u=ck(c,t);ak(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new mA(r,this._parents,e,n)}function fA(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},c={value:function(){--i===0&&a()}};n.each(function(){var n=sk(this,r),i=n.on;i!==e&&(t=(e=i).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(c)),n.on=t}),i===0&&a()})}var pA=0;function mA(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function hA(){return++pA}var gA=tD.prototype;mA.prototype={constructor:mA,select:Kk,selectAll:qk,selectChild:gA.selectChild,selectChildren:gA.selectChildren,filter:zk,merge:Bk,selection:Yk,transition:dA,call:gA.call,nodes:gA.nodes,node:gA.node,size:gA.size,empty:gA.empty,each:gA.each,on:Uk,attr:Ck,attrTween:Ok,style:tA,styleTween:iA,text:sA,textTween:uA,remove:Gk,tween:mk,delay:jk,duration:Pk,ease:Ik,easeVarying:Rk,end:fA,[Symbol.iterator]:gA[Symbol.iterator]};function _A(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var vA={time:null,delay:0,duration:250,ease:_A};function yA(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}function bA(e){var t,n;e instanceof mA?(t=e._id,e=e._name):(t=hA(),(n=vA).time=qO(),e=e==null?null:e+``);for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&ak(c,e,t,l,o,n||yA(c,t));return new mA(r,this._parents,e,t)}tD.prototype.interrupt=dk,tD.prototype.transition=bA;var xA=e=>()=>e;function SA(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function CA(e,t,n){this.k=e,this.x=t,this.y=n}CA.prototype={constructor:CA,scale:function(e){return e===1?this:new CA(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new CA(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return`translate(`+this.x+`,`+this.y+`) scale(`+this.k+`)`}};var wA=new CA(1,0,0);TA.prototype=CA.prototype;function TA(e){for(;!e.__zoom;)if(!(e=e.parentNode))return wA;return e.__zoom}function EA(e){e.stopImmediatePropagation()}function DA(e){e.preventDefault(),e.stopImmediatePropagation()}function OA(e){return(!e.ctrlKey||e.type===`wheel`)&&!e.button}function kA(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute(`viewBox`)?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function AA(){return this.__zoom||wA}function jA(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function MA(){return navigator.maxTouchPoints||`ontouchstart`in this}function NA(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function PA(){var e=OA,t=kA,n=NA,r=jA,i=MA,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=FO,l=eT(`start`,`zoom`,`end`),u,d,f,p=500,m=150,h=0,g=10;function _(e){e.property(`__zoom`,AA).on(`wheel.zoom`,w,{passive:!1}).on(`mousedown.zoom`,T).on(`dblclick.zoom`,E).filter(i).on(`touchstart.zoom`,D).on(`touchmove.zoom`,O).on(`touchend.zoom touchcancel.zoom`,k).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}_.transform=function(e,t,n,r){var i=e.selection?e.selection():e;i.property(`__zoom`,AA),e===i?i.interrupt().each(function(){S(this,arguments).event(r).start().zoom(null,typeof t==`function`?t.apply(this,arguments):t).end()}):x(e,t,n,r)},_.scaleBy=function(e,t,n,r){_.scaleTo(e,function(){return this.__zoom.k*(typeof t==`function`?t.apply(this,arguments):t)},n,r)},_.scaleTo=function(e,r,i,a){_.transform(e,function(){var e=t.apply(this,arguments),a=this.__zoom,s=i==null?b(e):typeof i==`function`?i.apply(this,arguments):i,c=a.invert(s),l=typeof r==`function`?r.apply(this,arguments):r;return n(y(v(a,l),s,c),e,o)},i,a)},_.translateBy=function(e,r,i,a){_.transform(e,function(){return n(this.__zoom.translate(typeof r==`function`?r.apply(this,arguments):r,typeof i==`function`?i.apply(this,arguments):i),t.apply(this,arguments),o)},null,a)},_.translateTo=function(e,r,i,a,s){_.transform(e,function(){var e=t.apply(this,arguments),s=this.__zoom,c=a==null?b(e):typeof a==`function`?a.apply(this,arguments):a;return n(wA.translate(c[0],c[1]).scale(s.k).translate(typeof r==`function`?-r.apply(this,arguments):-r,typeof i==`function`?-i.apply(this,arguments):-i),e,o)},a,s)};function v(e,t){return t=Math.max(a[0],Math.min(a[1],t)),t===e.k?e:new CA(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,i=t[1]-n[1]*e.k;return r===e.x&&i===e.y?e:new CA(e.k,r,i)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,n,r,i){e.on(`start.zoom`,function(){S(this,arguments).event(i).start()}).on(`interrupt.zoom end.zoom`,function(){S(this,arguments).event(i).end()}).tween(`zoom`,function(){var e=this,a=arguments,o=S(e,a).event(i),s=t.apply(e,a),l=r==null?b(s):typeof r==`function`?r.apply(e,a):r,u=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),d=e.__zoom,f=typeof n==`function`?n.apply(e,a):n,p=c(d.invert(l).concat(u/d.k),f.invert(l).concat(u/f.k));return function(e){if(e===1)e=f;else{var t=p(e),n=u/t[2];e=new CA(n,l[0]-t[0]*n,l[1]-t[1]*n)}o.zoom(null,e)}})}function S(e,t,n){return!n&&e.__zooming||new C(e,t)}function C(e,n){this.that=e,this.args=n,this.active=0,this.sourceEvent=null,this.extent=t.apply(e,n),this.taps=0}C.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit(`start`)),this},zoom:function(e,t){return this.mouse&&e!==`mouse`&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&e!==`touch`&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&e!==`touch`&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit(`zoom`),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit(`end`)),this},emit:function(e){var t=rD(this.that).datum();l.call(e,this.that,new SA(e,{sourceEvent:this.sourceEvent,target:_,type:e,transform:this.that.__zoom,dispatch:l}),t)}};function w(t,...i){if(!e.apply(this,arguments))return;var s=S(this,i).event(t),c=this.__zoom,l=Math.max(a[0],Math.min(a[1],c.k*2**r.apply(this,arguments))),u=aD(t);if(s.wheel)(s.mouse[0][0]!==u[0]||s.mouse[0][1]!==u[1])&&(s.mouse[1]=c.invert(s.mouse[0]=u)),clearTimeout(s.wheel);else if(c.k===l)return;else s.mouse=[u,c.invert(u)],uk(this),s.start();DA(t),s.wheel=setTimeout(d,m),s.zoom(`mouse`,n(y(v(c,l),s.mouse[0],s.mouse[1]),s.extent,o));function d(){s.wheel=null,s.end()}}function T(t,...r){if(f||!e.apply(this,arguments))return;var i=t.currentTarget,a=S(this,r,!0).event(t),s=rD(t.view).on(`mousemove.zoom`,d,!0).on(`mouseup.zoom`,p,!0),c=aD(t,i),l=t.clientX,u=t.clientY;uD(t.view),EA(t),a.mouse=[c,this.__zoom.invert(c)],uk(this),a.start();function d(e){if(DA(e),!a.moved){var t=e.clientX-l,r=e.clientY-u;a.moved=t*t+r*r>h}a.event(e).zoom(`mouse`,n(y(a.that.__zoom,a.mouse[0]=aD(e,i),a.mouse[1]),a.extent,o))}function p(e){s.on(`mousemove.zoom mouseup.zoom`,null),dD(e.view,a.moved),DA(e),a.event(e).end()}}function E(r,...i){if(e.apply(this,arguments)){var a=this.__zoom,c=aD(r.changedTouches?r.changedTouches[0]:r,this),l=a.invert(c),u=a.k*(r.shiftKey?.5:2),d=n(y(v(a,u),c,l),t.apply(this,i),o);DA(r),s>0?rD(this).transition().duration(s).call(x,d,c,r):rD(this).call(_.transform,d,c,r)}}function D(t,...n){if(e.apply(this,arguments)){var r=t.touches,i=r.length,a=S(this,n,t.changedTouches.length===i).event(t),o,s,c,l;for(EA(t),s=0;s<i;++s)c=r[s],l=aD(c,this),l=[l,this.__zoom.invert(l),c.identifier],a.touch0?!a.touch1&&a.touch0[2]!==l[2]&&(a.touch1=l,a.taps=0):(a.touch0=l,o=!0,a.taps=1+!!u);u&&=clearTimeout(u),o&&(a.taps<2&&(d=l[0],u=setTimeout(function(){u=null},p)),uk(this),a.start())}}function O(e,...t){if(this.__zooming){var r=S(this,t).event(e),i=e.changedTouches,a=i.length,s,c,l,u;for(DA(e),s=0;s<a;++s)c=i[s],l=aD(c,this),r.touch0&&r.touch0[2]===c.identifier?r.touch0[0]=l:r.touch1&&r.touch1[2]===c.identifier&&(r.touch1[0]=l);if(c=r.that.__zoom,r.touch1){var d=r.touch0[0],f=r.touch0[1],p=r.touch1[0],m=r.touch1[1],h=(h=p[0]-d[0])*h+(h=p[1]-d[1])*h,g=(g=m[0]-f[0])*g+(g=m[1]-f[1])*g;c=v(c,Math.sqrt(h/g)),l=[(d[0]+p[0])/2,(d[1]+p[1])/2],u=[(f[0]+m[0])/2,(f[1]+m[1])/2]}else if(r.touch0)l=r.touch0[0],u=r.touch0[1];else return;r.zoom(`touch`,n(y(c,l,u),r.extent,o))}}function k(e,...t){if(this.__zooming){var n=S(this,t).event(e),r=e.changedTouches,i=r.length,a,o;for(EA(e),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),a=0;a<i;++a)o=r[a],n.touch0&&n.touch0[2]===o.identifier?delete n.touch0:n.touch1&&n.touch1[2]===o.identifier&&delete n.touch1;if(n.touch1&&!n.touch0&&(n.touch0=n.touch1,delete n.touch1),n.touch0)n.touch0[1]=this.__zoom.invert(n.touch0[0]);else if(n.end(),n.taps===2&&(o=aD(o,this),Math.hypot(d[0]-o[0],d[1]-o[1])<g)){var s=rD(this).on(`dblclick.zoom`);s&&s.apply(this,arguments)}}}return _.wheelDelta=function(e){return arguments.length?(r=typeof e==`function`?e:xA(+e),_):r},_.filter=function(t){return arguments.length?(e=typeof t==`function`?t:xA(!!t),_):e},_.touchable=function(e){return arguments.length?(i=typeof e==`function`?e:xA(!!e),_):i},_.extent=function(e){return arguments.length?(t=typeof e==`function`?e:xA([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),_):t},_.scaleExtent=function(e){return arguments.length?(a[0]=+e[0],a[1]=+e[1],_):[a[0],a[1]]},_.translateExtent=function(e){return arguments.length?(o[0][0]=+e[0][0],o[1][0]=+e[1][0],o[0][1]=+e[0][1],o[1][1]=+e[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(e){return arguments.length?(n=e,_):n},_.duration=function(e){return arguments.length?(s=+e,_):s},_.interpolate=function(e){return arguments.length?(c=e,_):c},_.on=function(){var e=l.on.apply(l,arguments);return e===l?_:e},_.clickDistance=function(e){return arguments.length?(h=(e=+e)*e,_):Math.sqrt(h)},_.tapDistance=function(e){return arguments.length?(g=+e,_):g},_}var FA={error001:(e=`react`)=>`Seems like you have not used ${e===`svelte`?`SvelteFlowProvider`:`ReactFlowProvider`} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>`It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.`,error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>`The parent container needs a width and a height to render the graph.`,error005:()=>`Only child nodes can use a parent extent.`,error006:()=>`Can't create edge. An edge needs a source and a target.`,error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e===`source`?n:r}", edge id: ${t}.`,error010:()=>`Handle: No node id found. Make sure to only use a Handle inside a custom Node.`,error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e=`react`)=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>`useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.`,error015:()=>`It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.`,error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},IA=[[-1/0,-1/0],[1/0,1/0]],LA=[`Enter`,` `,`Escape`],RA={"node.a11yDescription.default":`Press enter or space to select a node. Press delete to remove it and escape to cancel.`,"node.a11yDescription.keyboardDisabled":`Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.`,"node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":`Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.`,"controls.ariaLabel":`Control Panel`,"controls.zoomIn.ariaLabel":`Zoom In`,"controls.zoomOut.ariaLabel":`Zoom Out`,"controls.fitView.ariaLabel":`Fit View`,"controls.interactive.ariaLabel":`Toggle Interactivity`,"minimap.ariaLabel":`Mini Map`,"handle.ariaLabel":`Handle`},zA;(function(e){e.Strict=`strict`,e.Loose=`loose`})(zA||={});var BA;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(BA||={});var VA;(function(e){e.Partial=`partial`,e.Full=`full`})(VA||={});var HA={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},UA;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(UA||={});var WA;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(WA||={});var Q;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})(Q||={});var GA={[Q.Left]:Q.Right,[Q.Right]:Q.Left,[Q.Top]:Q.Bottom,[Q.Bottom]:Q.Top},KA=e=>!!e&&typeof e==`object`&&`id`in e&&`source`in e&&`target`in e,qA=e=>!!e&&typeof e==`object`&&`id`in e&&`position`in e&&!(`source`in e)&&!(`target`in e),JA=e=>!!e&&typeof e==`object`&&`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),YA=(e,t=[0,0])=>{let{width:n,height:r}=kj(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},XA=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=!1,r=e.reduce((e,r)=>{let i=typeof r==`string`,a=!t.nodeLookup&&!i?r:void 0;return t.nodeLookup&&(a=i?t.nodeLookup.get(r):JA(r)?r:t.nodeLookup.get(r.id)),a?(n=!0,lj(e,pj(a,t.nodeOrigin))):e},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?dj(r):{x:0,y:0,width:0,height:0}},ZA=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(e=>{(t.filter===void 0||t.filter(e))&&(n=lj(n,pj(e)),r=!0)}),r?dj(n):{x:0,y:0,width:0,height:0}},QA=(e,t,[n,r,i]=[0,0,1],a=!1,o=!1)=>{let s=(t.x-n)/i,c=(t.y-r)/i,l=t.width/i,u=t.height/i,d=[];for(let t of e.values()){let{measured:e,selectable:n=!0,hidden:r=!1}=t;if(o&&!n||r)continue;let i=e.width??t.width??t.initialWidth??0,f=e.height??t.height??t.initialHeight??0,{x:p,y:m}=t.internals.positionAbsolute,h=hj(s,c,l,u,p,m,i,f),g=i*f,_=a&&h>0;(!t.internals.handleBounds||_||h>=g||t.dragging)&&d.push(t)}return d},$A=(e,t)=>{let n=new Set;return e.forEach(e=>{n.add(e.id)}),t.filter(e=>n.has(e.source)||n.has(e.target))};function ej(e,t){let n=new Map,r=t?.nodes?new Set(t.nodes.map(e=>e.id)):null;return e.forEach(e=>{let i;if(t?.includeHiddenNodes){let{width:t,height:n}=kj(e);i=t>0&&n>0}else i=!!(e.measured.width&&e.measured.height&&!e.hidden);i&&(!r||r.has(e.id))&&n.set(e.id,e)}),n}async function tj({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return!0;let s=Ej(ZA(ej(e,o)),t,n,o?.minZoom??i,o?.maxZoom??a,o?.padding??.1);return await r.setViewport(s,{duration:o?.duration,ease:o?.ease,interpolate:o?.interpolate}),!0}function nj({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:a}){let o=n.get(e),s=o.parentId?n.get(o.parentId):void 0,{x:c,y:l}=s?s.internals.positionAbsolute:{x:0,y:0},u=o.origin??r,d=o.extent||i;if(o.extent===`parent`&&!o.expandParent){if(!s)a?.(`005`,FA.error005());else{let{width:e,height:t}=kj(s);e&&t&&(d=[[c,l],[c+e,l+t]])}}else s&&Oj(o.extent)&&(d=[[o.extent[0][0]+c,o.extent[0][1]+l],[o.extent[1][0]+c,o.extent[1][1]+l]]);let f=Oj(d)?aj(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,FA.error015()),{position:{x:f.x-c+(o.measured.width??0)*u[0],y:f.y-l+(o.measured.height??0)*u[1]},positionAbsolute:f}}async function rj({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:i}){let a=new Set(e.map(e=>e.id)),o=[];for(let e of n){if(e.deletable===!1)continue;let t=a.has(e.id),n=!t&&e.parentId&&o.find(t=>t.id===e.parentId);(t||n)&&o.push(e)}let s=new Set(t.map(e=>e.id)),c=r.filter(e=>e.deletable!==!1),l=$A(o,c);for(let e of c)s.has(e.id)&&!l.find(t=>t.id===e.id)&&l.push(e);if(!i)return{edges:l,nodes:o};let u=await i({nodes:o,edges:l});return typeof u==`boolean`?u?{edges:l,nodes:o}:{edges:[],nodes:[]}:u}var ij=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),aj=(e={x:0,y:0},t,n)=>({x:ij(e.x,t[0][0],t[1][0]-(n?.width??0)),y:ij(e.y,t[0][1],t[1][1]-(n?.height??0))});function oj(e,t,n){let{width:r,height:i}=kj(n),{x:a,y:o}=n.internals.positionAbsolute;return aj(e,[[a,o],[a+r,o+i]],t)}var sj=(e,t,n)=>e<t?ij(Math.abs(e-t),1,t)/t:e>n?-ij(Math.abs(e-n),1,t)/t:0,cj=(e,t,n=15,r=40)=>[sj(e.x,r,t.width-r)*n,sj(e.y,r,t.height-r)*n],lj=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),uj=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),dj=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),fj=(e,t=[0,0])=>{let{x:n,y:r}=JA(e)?e.internals.positionAbsolute:YA(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},pj=(e,t=[0,0])=>{let{x:n,y:r}=JA(e)?e.internals.positionAbsolute:YA(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},mj=(e,t)=>dj(lj(uj(e),uj(t))),hj=(e,t,n,r,i,a,o,s)=>{let c=Math.max(0,Math.min(e+n,i+o)-Math.max(e,i)),l=Math.max(0,Math.min(t+r,a+s)-Math.max(t,a));return Math.ceil(c*l)},gj=(e,t)=>hj(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),_j=e=>vj(e.width)&&vj(e.height)&&vj(e.x)&&vj(e.y),vj=e=>!isNaN(e)&&isFinite(e),yj=(e,t)=>(e,t)=>{},bj=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),xj=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?bj(s,o):s},Sj=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function Cj(e,t){if(typeof e==`number`)return Math.floor((t-t/(1+e))*.5);if(typeof e==`string`&&e.endsWith(`px`)){let t=parseFloat(e);if(!Number.isNaN(t))return Math.floor(t)}if(typeof e==`string`&&e.endsWith(`%`)){let n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function wj(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=Cj(e,n),i=Cj(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=Cj(e.top??e.y??0,n),i=Cj(e.bottom??e.y??0,n),a=Cj(e.left??e.x??0,t),o=Cj(e.right??e.x??0,t);return{top:r,right:o,bottom:i,left:a,x:a+o,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Tj(e,t,n,r,i,a){let{x:o,y:s}=Sj(e,[t,n,r]),{x:c,y:l}=Sj({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=i-c,d=a-l;return{left:Math.floor(o),top:Math.floor(s),right:Math.floor(u),bottom:Math.floor(d)}}var Ej=(e,t,n,r,i,a)=>{let o=wj(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=ij(Math.min(s,c),r,i),u=e.x+e.width/2,d=e.y+e.height/2,f=t/2-u*l,p=n/2-d*l,m=Tj(e,f,p,l,t,n),h={left:Math.min(m.left-o.left,0),top:Math.min(m.top-o.top,0),right:Math.min(m.right-o.right,0),bottom:Math.min(m.bottom-o.bottom,0)};return{x:f-h.left+h.right,y:p-h.top+h.bottom,zoom:l}},Dj=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function Oj(e){return e!=null&&e!==`parent`}function kj(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Aj(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function jj(e,t={width:0,height:0},n,r,i){let a={...e},o=r.get(n);if(o){let e=o.origin||i;a.x+=o.internals.positionAbsolute.x-(t.width??0)*e[0],a.y+=o.internals.positionAbsolute.y-(t.height??0)*e[1]}return a}function Mj(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function Nj(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function Pj(e){return{...RA,...e||{}}}function Fj(e){return e===null?null:e?`valid`:`invalid`}function Ij(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=Hj(e),s=xj({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?bj(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var Lj=e=>({width:e.offsetWidth,height:e.offsetHeight}),Rj=e=>e?.getRootNode?.()||window?.document,zj=[`INPUT`,`SELECT`,`TEXTAREA`];function Bj(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?zj.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var Vj=e=>`clientX`in e,Hj=(e,t)=>{let n=Vj(e),r=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:i-(t?.top??0)}},Uj=(e,t,n,r,i)=>{let a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...Lj(t)}})};function Wj({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:o,targetControlY:s}){let c=e*.125+i*.375+o*.375+n*.125,l=t*.125+a*.375+s*.375+r*.125;return[c,l,Math.abs(c-e),Math.abs(l-t)]}function Gj(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Kj({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case Q.Left:return[t-Gj(t-r,a),n];case Q.Right:return[t+Gj(r-t,a),n];case Q.Top:return[t,n-Gj(n-i,a)];case Q.Bottom:return[t,n+Gj(i-n,a)]}}function qj({sourceX:e,sourceY:t,sourcePosition:n=Q.Bottom,targetX:r,targetY:i,targetPosition:a=Q.Top,curvature:o=.25}){let[s,c]=Kj({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=Kj({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=Wj({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:s,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${s},${c} ${l},${u} ${r},${i}`,d,f,p,m]}function Jj({sourceX:e,sourceY:t,targetX:n,targetY:r}){let i=Math.abs(n-e)/2,a=n<e?n+i:n-i,o=Math.abs(r-t)/2;return[a,r<t?r+o:r-o,i,o]}function Yj({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:i=!1,zIndexMode:a=`basic`}){return a===`manual`?r:(i&&n?r+1e3:r)+Math.max(e.parentId||i&&e.selected?e.internals.z:0,t.parentId||i&&t.selected?t.internals.z:0)}function Xj({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){let a=lj(pj(e),pj(t));return a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1),gj({x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]},dj(a))>0}var Zj=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,Qj=(e,t)=>t.some(t=>t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle)),$j=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.(`006`,FA.error006()),t;let r=n.getEdgeId||Zj,i;return i=KA(e)?{...e}:{...e,id:r(e)},Qj(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function eM({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=Jj({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var tM={[Q.Left]:{x:-1,y:0},[Q.Right]:{x:1,y:0},[Q.Top]:{x:0,y:-1},[Q.Bottom]:{x:0,y:1}},nM=({source:e,sourcePosition:t=Q.Bottom,target:n})=>t===Q.Left||t===Q.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},rM=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2);function iM({source:e,sourcePosition:t=Q.Bottom,target:n,targetPosition:r=Q.Top,center:i,offset:a,stepPosition:o}){let s=tM[t],c=tM[r],l={x:e.x+s.x*a,y:e.y+s.y*a},u={x:n.x+c.x*a,y:n.y+c.y*a},d=nM({source:l,sourcePosition:t,target:u}),f=d.x===0?`y`:`x`,p=d[f],m=[],h,g,_={x:0,y:0},v={x:0,y:0},[,,y,b]=Jj({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(s[f]*c[f]===-1){f===`x`?(h=i.x??l.x+(u.x-l.x)*o,g=i.y??(l.y+u.y)/2):(h=i.x??(l.x+u.x)/2,g=i.y??l.y+(u.y-l.y)*o);let e=[{x:h,y:l.y},{x:h,y:u.y}],t=[{x:l.x,y:g},{x:u.x,y:g}];m=s[f]===p?f===`x`?e:t:f===`x`?t:e}else{let i=[{x:l.x,y:u.y}],o=[{x:u.x,y:l.y}];if(m=f===`x`?s.x===p?o:i:s.y===p?i:o,t===r){let t=Math.abs(e[f]-n[f]);if(t<=a){let r=Math.min(a-1,a-t);s[f]===p?_[f]=(l[f]>e[f]?-1:1)*r:v[f]=(u[f]>n[f]?-1:1)*r}}if(t!==r){let e=f===`x`?`y`:`x`,t=s[f]===c[e],n=l[e]>u[e],r=l[e]<u[e];(s[f]===1&&(!t&&n||t&&r)||s[f]!==1&&(!t&&r||t&&n))&&(m=f===`x`?i:o)}let d={x:l.x+_.x,y:l.y+_.y},y={x:u.x+v.x,y:u.y+v.y};Math.max(Math.abs(d.x-m[0].x),Math.abs(y.x-m[0].x))>=Math.max(Math.abs(d.y-m[0].y),Math.abs(y.y-m[0].y))?(h=(d.x+y.x)/2,g=m[0].y):(h=m[0].x,g=(d.y+y.y)/2)}let x={x:l.x+_.x,y:l.y+_.y},S={x:u.x+v.x,y:u.y+v.y};return[[e,...x.x!==m[0].x||x.y!==m[0].y?[x]:[],...m,...S.x!==m[m.length-1].x||S.y!==m[m.length-1].y?[S]:[],n],h,g,y,b]}function aM(e,t,n,r){let i=Math.min(rM(e,t)/2,rM(t,n)/2,r),{x:a,y:o}=t;if(e.x===a&&a===n.x||e.y===o&&o===n.y)return`L${a} ${o}`;if(e.y===o){let t=e.x<n.x?-1:1,r=e.y<n.y?1:-1;return`L ${a+i*t},${o}Q ${a},${o} ${a},${o+i*r}`}let s=e.x<n.x?1:-1;return`L ${a},${o+i*(e.y<n.y?-1:1)}Q ${a},${o} ${a+i*s},${o}`}function oM({sourceX:e,sourceY:t,sourcePosition:n=Q.Bottom,targetX:r,targetY:i,targetPosition:a=Q.Top,borderRadius:o=5,centerX:s,centerY:c,offset:l=20,stepPosition:u=.5}){let[d,f,p,m,h]=iM({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:i},targetPosition:a,center:{x:s,y:c},offset:l,stepPosition:u}),g=`M${d[0].x} ${d[0].y}`;for(let e=1;e<d.length-1;e++)g+=aM(d[e-1],d[e],d[e+1],o);return g+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[g,f,p,m,h]}function sM(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function cM(e){let{sourceNode:t,targetNode:n}=e;if(!sM(t)||!sM(n))return null;let r=t.internals.handleBounds||lM(t.handles),i=n.internals.handleBounds||lM(n.handles),a=dM(r?.source??[],e.sourceHandle),o=dM(e.connectionMode===zA.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!a||!o)return e.onError?.(`008`,FA.error008(a?`target`:`source`,{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;let s=a?.position||Q.Bottom,c=o?.position||Q.Top,l=uM(t,a,s),u=uM(n,o,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:s,targetPosition:c}}function lM(e){if(!e)return null;let t=[],n=[];for(let r of e)r.width=r.width??1,r.height=r.height??1,r.type===`source`?t.push(r):r.type===`target`&&n.push(r);return{source:t,target:n}}function uM(e,t,n=Q.Left,r=!1){let i=(t?.x??0)+e.internals.positionAbsolute.x,a=(t?.y??0)+e.internals.positionAbsolute.y,{width:o,height:s}=t??kj(e);if(r)return{x:i+o/2,y:a+s/2};switch(t?.position??n){case Q.Top:return{x:i+o/2,y:a};case Q.Right:return{x:i+o,y:a+s/2};case Q.Bottom:return{x:i+o/2,y:a+s};case Q.Left:return{x:i,y:a+s/2}}}function dM(e,t){return e&&(t?e.find(e=>e.id===t):e[0])||null}function fM(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function pM(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){let a=new Set;return e.reduce((e,o)=>([o.markerStart||r,o.markerEnd||i].forEach(r=>{if(r&&typeof r==`object`){let i=fM(r,t);a.has(i)||(e.push({id:i,color:r.color||n,...r}),a.add(i))}}),e),[]).sort((e,t)=>e.id.localeCompare(t.id))}var mM=1e3,hM=10,gM={nodeOrigin:[0,0],nodeExtent:IA,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},_M={...gM,checkEquality:!0};function vM(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function yM(e,t,n){let r=vM(gM,n);for(let n of e.values())if(n.parentId)wM(n,e,t,r);else{let e=aj(YA(n,r.nodeOrigin),Oj(n.extent)?n.extent:r.nodeExtent,kj(n));n.internals.positionAbsolute=e}}function bM(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;let n=[],r=[];for(let t of e.handles){let i={id:t.id,width:t.width??1,height:t.height??1,nodeId:e.id,x:t.x,y:t.y,position:t.position,type:t.type};t.type===`source`?n.push(i):t.type===`target`&&r.push(i)}return{source:n,target:r}}function xM(e){return e===`manual`}function SM(e,t,n,r={}){let i=vM(_M,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!xM(i.zIndexMode)?mM:0,c=e.length>0,l=!1;t.clear(),n.clear();for(let u of e){let e=o.get(u.id);if(i.checkEquality&&u===e?.internals.userNode)t.set(u.id,e);else{let n=aj(YA(u,i.nodeOrigin),Oj(u.extent)?u.extent:i.nodeExtent,kj(u));e={...i.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:bM(u,e),z:TM(u,s,i.zIndexMode),userNode:u}},t.set(u.id,e)}(e.measured===void 0||e.measured.width===void 0||e.measured.height===void 0)&&!e.hidden&&(c=!1),u.parentId&&wM(e,t,n,r,a),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function CM(e,t){if(!e.parentId)return;let n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function wM(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=vM(gM,r),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}CM(e,n),i&&!u.parentId&&u.internals.rootParentIndex===void 0&&c===`auto`&&(u.internals.rootParentIndex=++i.i,u.internals.z=u.internals.z+i.i*hM),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=EM(e,u,o,s,a&&!xM(c)?mM:0,c),{positionAbsolute:m}=e.internals,h=d!==m.x||f!==m.y;(h||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:h?{x:d,y:f}:m,z:p}})}function TM(e,t,n){let r=vj(e.zIndex)?e.zIndex:0;return xM(n)?r:r+(e.selected?t:0)}function EM(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=kj(e),l=YA(e,n),u=Oj(e.extent)?aj(l,e.extent,c):l,d=aj({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=oj(d,c,t));let f=TM(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function DM(e,t,n,r=[0,0]){let i=[],a=new Map;for(let n of e){let e=t.get(n.parentId);if(!e)continue;let r=mj(a.get(n.parentId)?.expandedRect??fj(e),n.rect);a.set(n.parentId,{expandedRect:r,parent:e})}return a.size>0&&a.forEach(({expandedRect:t,parent:a},o)=>{let s=a.internals.positionAbsolute,c=kj(a),l=a.origin??r,u=t.x<s.x?Math.round(Math.abs(s.x-t.x)):0,d=t.y<s.y?Math.round(Math.abs(s.y-t.y)):0,f=Math.max(c.width,Math.round(t.width)),p=Math.max(c.height,Math.round(t.height)),m=(f-c.width)*l[0],h=(p-c.height)*l[1];(u>0||d>0||m||h)&&(i.push({id:o,type:`position`,position:{x:a.position.x-u+m,y:a.position.y-d+h}}),n.get(o)?.forEach(t=>{e.some(e=>e.id===t.id)||i.push({id:t.id,type:`position`,position:{x:t.position.x+u,y:t.position.y+d}})})),(c.width<t.width||c.height<t.height||u||d)&&i.push({id:o,type:`dimensions`,setAttributes:!0,dimensions:{width:f+(u?l[0]*u-m:0),height:p+(d?l[1]*d-h:0)}})}),i}function OM(e,t,n,r,i,a,o){let s=r?.querySelector(`.xyflow__viewport`),c=!1;if(!s)return{changes:[],updatedInternals:c};let l=[],u=window.getComputedStyle(s),{m22:d}=new window.DOMMatrixReadOnly(u.transform),f=[];for(let r of e.values()){let e=t.get(r.id);if(!e)continue;if(e.hidden){t.set(e.id,{...e,internals:{...e.internals,handleBounds:void 0}}),c=!0;continue}let s=Lj(r.nodeElement),u=e.measured.width!==s.width||e.measured.height!==s.height;if(s.width&&s.height&&(u||!e.internals.handleBounds||r.force)){let p=r.nodeElement.getBoundingClientRect(),m=Oj(e.extent)?e.extent:a,{positionAbsolute:h}=e.internals;if(e.parentId&&e.extent===`parent`){let n=t.get(e.parentId);n&&(h=oj(h,s,n))}else m&&(h=aj(h,m,s));let g={...e,measured:s,internals:{...e.internals,positionAbsolute:h,handleBounds:{source:Uj(`source`,r.nodeElement,p,d,e.id),target:Uj(`target`,r.nodeElement,p,d,e.id)}}};t.set(e.id,g),e.parentId&&wM(g,t,n,{nodeOrigin:i,zIndexMode:o}),c=!0,u&&(l.push({id:e.id,type:`dimensions`,dimensions:s}),e.expandParent&&e.parentId&&f.push({id:e.id,parentId:e.parentId,rect:fj(g,i)}))}}if(f.length>0){let e=DM(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function kM({delta:e,panZoom:t,transform:n,translateExtent:r,width:i,height:a}){if(!t||!e.x&&!e.y)return!1;let o=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,a]],r);return!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2])}function AM(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function jM(e,t,n){e.clear(),t.clear();for(let r of n){let{source:n,target:i,sourceHandle:a=null,targetHandle:o=null}=r,s={edgeId:r.id,source:n,target:i,sourceHandle:a,targetHandle:o},c=`${n}-${a}--${i}-${o}`;AM(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),AM(`target`,s,c,e,i,o),t.set(r.id,r)}}function MM(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:MM(n,t):!1}function NM(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)return!1;r=r?.parentElement}while(r);return!1}function PM(e,t,n,r){let i=new Map;for(let[a,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!MM(o,e))&&(o.draggable||t&&o.draggable===void 0)){let t=e.get(a);t&&i.set(a,{id:a,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return i}function FM({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){let i=[];for(let[e,a]of t){let t=n.get(e)?.internals.userNode;t&&i.push({...t,position:a.position,dragging:r})}if(!e)return[i[0],i];let a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:r}:i[0],i]}function IM({dragItems:e,snapGrid:t,x:n,y:r}){let i=e.values().next().value;if(!i)return null;let a={x:n-i.distance.x,y:r-i.distance.y},o=bj(a,t);return{x:o.x-a.x,y:o.y-a.y}}function LM({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let a={x:null,y:null},o=0,s=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,p=!1,m=!1,h=null;function g({noDragClassName:g,handleSelector:_,domNode:v,isSelectable:y,nodeId:b,nodeClickDistance:x=0}){f=rD(v);function S({x:e,y:n}){let{nodeLookup:i,nodeExtent:o,snapGrid:c,snapToGrid:l,nodeOrigin:u,onNodeDrag:d,onSelectionDrag:f,onError:p,updateNodePositions:g}=t();a={x:e,y:n};let _=!1,v=s.size>1,y=v&&o?uj(ZA(s)):null,x=v&&l?IM({dragItems:s,snapGrid:c,x:e,y:n}):null;for(let[t,r]of s){if(!i.has(t))continue;let a={x:e-r.distance.x,y:n-r.distance.y};l&&(a=x?{x:Math.round(a.x+x.x),y:Math.round(a.y+x.y)}:bj(a,c));let s=null;if(v&&o&&!r.extent&&y){let{positionAbsolute:e}=r.internals,t=e.x-y.x+o[0][0],n=e.x+r.measured.width-y.x2+o[1][0],i=e.y-y.y+o[0][1],a=e.y+r.measured.height-y.y2+o[1][1];s=[[t,i],[n,a]]}let{position:d,positionAbsolute:f}=nj({nodeId:t,nextPosition:a,nodeLookup:i,nodeExtent:s||o,nodeOrigin:u,onError:p});_=_||r.position.x!==d.x||r.position.y!==d.y,r.position=d,r.internals.positionAbsolute=f}if(m||=_,_&&(g(s,!0),h&&(r||d||!b&&f))){let[e,t]=FM({nodeId:b,dragItems:s,nodeLookup:i});r?.(h,s,e,t),d?.(h,e,t),b||f?.(h,t)}}async function C(){if(!u)return;let{transform:e,panBy:n,autoPanSpeed:r,autoPanOnNodeDrag:i}=t();if(!i){c=!1,cancelAnimationFrame(o);return}let[s,d]=cj(l,u,r);(s!==0||d!==0)&&(a.x=(a.x??0)-s/e[2],a.y=(a.y??0)-d/e[2],await n({x:s,y:d})&&S(a)),o=requestAnimationFrame(C)}function w(r){let{nodeLookup:i,multiSelectionActive:o,nodesDraggable:c,transform:l,snapGrid:f,snapToGrid:p,selectNodesOnDrag:m,onNodeDragStart:h,onSelectionDragStart:g,unselectNodesAndEdges:_}=t();d=!0,(!m||!y)&&!o&&b&&(i.get(b)?.selected||_()),y&&m&&b&&e?.(b);let v=Ij(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=v,s=PM(i,c,v,b),s.size>0&&(n||h||!b&&g)){let[e,t]=FM({nodeId:b,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}let T=vD().clickDistance(x).on(`start`,e=>{let{domNode:n,nodeDragThreshold:r,transform:i,snapGrid:o,snapToGrid:s}=t();u=n?.getBoundingClientRect()||null,p=!1,m=!1,h=e.sourceEvent,r===0&&w(e),a=Ij(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=Hj(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=Ij(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:o,containerBounds:u});if(h=e.sourceEvent,(e.sourceEvent.type===`touchmove`&&e.sourceEvent.touches.length>1||b&&!m.has(b))&&(p=!0),!p){if(!c&&n&&d&&(c=!0,C()),!d){let t=Hj(e.sourceEvent,u),n=t.x-l.x,r=t.y-l.y;Math.sqrt(n*n+r*r)>f&&w(e)}(a.x!==g.xSnapped||a.y!==g.ySnapped)&&s&&d&&(l=Hj(e.sourceEvent,u),S(g))}}).on(`end`,e=>{if(!d||p){p&&s.size>0&&t().updateNodePositions(s,!1);return}if(c=!1,d=!1,cancelAnimationFrame(o),s.size>0){let{nodeLookup:n,updateNodePositions:r,onNodeDragStop:a,onSelectionDragStop:o}=t();if(m&&=(r(s,!1),!1),i||a||!b&&o){let[t,r]=FM({nodeId:b,dragItems:s,nodeLookup:n,dragging:!1});i?.(e.sourceEvent,s,t,r),a?.(e.sourceEvent,t,r),b||o?.(e.sourceEvent,r)}}}).filter(e=>{let t=e.target;return!e.button&&(!g||!NM(t,`.${g}`,v))&&(!_||NM(t,_,v))});f.call(T)}function _(){f?.on(`.drag`,null)}return{update:g,destroy:_}}function RM(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())gj(i,fj(e))>0&&r.push(e);return r}var zM=250;function BM(e,t,n,r){let i=[],a=1/0,o=RM(e,n,t+zM);for(let n of o){let o=[...n.internals.handleBounds?.source??[],...n.internals.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=uM(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l<a?(i=[{...s,x:o,y:c}],a=l):l===a&&i.push({...s,x:o,y:c}))}}if(!i.length)return null;if(i.length>1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function VM(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===`strict`?o.internals.handleBounds?.[t]:[...o.internals.handleBounds?.source??[],...o.internals.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...uM(o,c,c.position,!0)}:c}function HM(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function UM(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var WM=()=>!0;function GM(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:a,isTarget:o,domNode:s,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:d,panBy:f,cancelConnection:p,onConnectStart:m,onConnect:h,onConnectEnd:g,isValidConnection:_=WM,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=Rj(e.target),E=0,D,{x:O,y:k}=Hj(e),A=HM(a,w),j=s?.getBoundingClientRect(),M=!1;if(!j||!A)return;let N=VM(i,A,r,c,t);if(!N)return;let P=Hj(e,j),F=!1,I=null,L=!1,R=null;function ee(){if(!u||!j)return;let[e,t]=cj(P,j,S);f({x:e,y:t}),E=requestAnimationFrame(ee)}let z={...N,nodeId:i,type:A,position:N.position},B=c.get(i),te={inProgress:!0,isValid:null,from:uM(B,z,Q.Left,!0),fromHandle:z,fromPosition:z.position,fromNode:B,to:P,toHandle:null,toPosition:GA[z.position],toNode:null,pointer:P};function V(){M=!0,y(te),m?.(e,{nodeId:i,handleId:r,handleType:A})}C===0&&V();function ne(e){if(!M){let{x:t,y:n}=Hj(e),r=t-O,i=n-k;if(!(r*r+i*i>C*C))return;V()}if(!x()||!z){re(e);return}let a=b();P=Hj(e,j),D=BM(xj(P,a,!1,[1,1]),n,c,z),F||=(ee(),!0);let s=KM(e,{handle:D,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:o?`target`:`source`,isValidConnection:_,doc:T,lib:l,flowId:d,nodeLookup:c});R=s.handleDomNode,I=s.connection,L=UM(!!D,s.isValid);let u=c.get(i),f=u?uM(u,z,Q.Left,!0):te.from,p={...te,from:f,isValid:L,to:s.toHandle&&L?Sj({x:s.toHandle.x,y:s.toHandle.y},a):P,toHandle:s.toHandle,toPosition:L&&s.toHandle?s.toHandle.position:GA[z.position],toNode:s.toHandle?c.get(s.toHandle.nodeId):null,pointer:P};y(p),te=p}function re(e){if(!(`touches`in e&&e.touches.length>0)){if(M){(D||R)&&I&&L&&h?.(I);let{inProgress:t,...n}=te,r={...n,toPosition:te.toHandle?te.toPosition:null};g?.(e,r),a&&v?.(e,r)}p(),cancelAnimationFrame(E),F=!1,L=!1,I=null,R=null,T.removeEventListener(`mousemove`,ne),T.removeEventListener(`mouseup`,re),T.removeEventListener(`touchmove`,ne),T.removeEventListener(`touchend`,re)}}T.addEventListener(`mousemove`,ne),T.addEventListener(`mouseup`,re),T.addEventListener(`touchmove`,ne),T.addEventListener(`touchend`,re)}function KM(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=WM,nodeLookup:u}){let d=a===`target`,f=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:p,y:m}=Hj(e),h=o.elementFromPoint(p,m),g=h?.classList.contains(`${s}-flow__handle`)?h:f,_={handleDomNode:g,isValid:!1,connection:null,toHandle:null};if(g){let e=HM(void 0,g),t=g.getAttribute(`data-nodeid`),a=g.getAttribute(`data-handleid`),o=g.classList.contains(`connectable`),s=g.classList.contains(`connectableend`);if(!t||!e)return _;let c={source:d?t:r,sourceHandle:d?a:i,target:d?r:t,targetHandle:d?i:a};_.connection=c,_.isValid=o&&s&&(n===zA.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=VM(t,e,a,u,n,!0)}return _}var qM={onPointerDown:GM,isValid:KM};function JM({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=rD(e);function a({translateExtent:e,width:a,height:o,zoomStep:s=1,pannable:c=!0,zoomable:l=!0,inversePan:u=!1}){let d=e=>{if(e.sourceEvent.type!==`wheel`||!t)return;let r=n(),i=e.sourceEvent.ctrlKey&&Dj()?10:1,a=-e.sourceEvent.deltaY*(e.sourceEvent.deltaMode===1?.05:e.sourceEvent.deltaMode?1:.002)*s,o=r[2]*2**(a*i);t.scaleTo(o)},f=[0,0],p=PA().on(`start`,e=>{(e.sourceEvent.type===`mousedown`||e.sourceEvent.type===`touchstart`)&&(f=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])}).on(`zoom`,c?i=>{let s=n();if(i.sourceEvent.type!==`mousemove`&&i.sourceEvent.type!==`touchmove`||!t)return;let c=[i.sourceEvent.clientX??i.sourceEvent.touches[0].clientX,i.sourceEvent.clientY??i.sourceEvent.touches[0].clientY],l=[c[0]-f[0],c[1]-f[1]];f=c;let d=r()*Math.max(s[2],Math.log(s[2]))*(u?-1:1),p={x:s[0]-l[0]*d,y:s[1]-l[1]*d},m=[[0,0],[a,o]];t.setViewportConstrained({x:p.x,y:p.y,zoom:s[2]},m,e)}:null).on(`zoom.wheel`,l?d:null);i.call(p,{})}function o(){i.on(`zoom`,null)}return{update:a,destroy:o,pointer:aD}}var YM=e=>({x:e.x,y:e.y,zoom:e.k}),XM=({x:e,y:t,zoom:n})=>wA.translate(e,t).scale(n),ZM=(e,t)=>e.target.closest(`.${t}`),QM=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),$M=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,eN=(e,t=0,n=$M,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},tN=e=>{let t=e.ctrlKey&&Dj()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function nN({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(ZM(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();let d=n.property(`__zoom`).k||1;if(u.ctrlKey&&o){let e=aD(u),t=d*2**tN(u);r.scaleTo(n,t,e,u);return}let f=u.deltaMode===1?20:1,p=i===BA.Vertical?0:u.deltaX*f,m=i===BA.Horizontal?0:u.deltaY*f;!Dj()&&u.shiftKey&&i!==BA.Vertical&&(p=u.deltaY*f,m=0),r.translateBy(n,-(p/d)*a,-(m/d)*a,{internal:!0});let h=YM(n.property(`__zoom`));clearTimeout(e.panScrollTimeout),e.isPanScrolling?c?.(u,h):(e.isPanScrolling=!0,s?.(u,h)),e.panScrollTimeout=setTimeout(()=>{l?.(u,h),e.isPanScrolling=!1},150)}}function rN({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){let a=r.type===`wheel`,o=!t&&a&&!r.ctrlKey,s=ZM(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function iN({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=YM(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=i,r.sourceEvent?.type===`mousedown`&&t(!0),n&&n?.(r.sourceEvent,i)}}function aN({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&QM(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,YM(a.transform))}}function oN({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&QM(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=YM(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function sN({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:r,panOnDrag:i,panOnScroll:a,zoomOnDoubleClick:o,userSelectionActive:s,noWheelClassName:c,noPanClassName:l,lib:u,connectionInProgress:d}){return f=>{let p=t||n,m=r&&f.ctrlKey,h=f.type===`wheel`;if(f.button===1&&f.type===`mousedown`&&(ZM(f,`${u}-flow__node`)||ZM(f,`${u}-flow__edge`)||ZM(f,`${u}-flow__selection`)||ZM(f,`${u}-flow__nodesselection`)))return!0;if(!i&&!p&&!a&&!o&&!r||s||d&&!h||ZM(f,c)&&h||ZM(f,l)&&(!h||a&&h&&!t)||!r&&f.ctrlKey&&h)return!1;if(!r&&f.type===`touchstart`&&f.touches?.length>1)return f.preventDefault(),!1;if(!p&&!a&&!m&&h||!i&&(f.type===`mousedown`||f.type===`touchstart`)||Array.isArray(i)&&!i.includes(f.button)&&f.type===`mousedown`)return!1;let g=Array.isArray(i)&&i.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||h||e)&&g}}function cN({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:a,onPanZoomStart:o,onPanZoomEnd:s,onDraggingChange:c}){let l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect(),d=[[0,0],[u.width,u.height]];(typeof ResizeObserver<`u`?new ResizeObserver(e=>{let t=e[0];t&&(d=[[0,0],[t.contentRect.width,t.contentRect.height]])}):null)?.observe(e);let f=PA().extent(()=>d).scaleExtent([t,n]).translateExtent(r),p=rD(e).call(f);y({x:i.x,y:i.y,zoom:ij(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let m=p.on(`wheel.zoom`),h=p.on(`dblclick.zoom`);f.wheelDelta(tN);async function g(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?xO:FO).transform(eN(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function _({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:r,panOnScroll:i,panOnDrag:u,panOnScrollMode:d,panOnScrollSpeed:g,preventScrolling:_,zoomOnPinch:y,zoomOnScroll:b,zoomOnDoubleClick:x,panActivationKeyPressed:S=!1,zoomActivationKeyPressed:C,lib:w,onTransformChange:T,connectionInProgress:E,paneClickDistance:D,selectionOnDrag:O}){r&&!l.isZoomingOrPanning&&v();let k=i&&!C&&!r;f.clickDistance(O?1/0:!vj(D)||D<0?0:D);let A=k?nN({zoomPanValues:l,noWheelClassName:e,d3Selection:p,d3Zoom:f,panOnScrollMode:d,panOnScrollSpeed:g,zoomOnPinch:y,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):rN({noWheelClassName:e,preventScrolling:_,d3ZoomHandler:m});p.on(`wheel.zoom`,A,{passive:!1});let j=iN({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});f.on(`start`,j);let M=aN({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:T});f.on(`zoom`,M);let N=oN({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});f.on(`end`,N);let P=sN({panActivationKeyPressed:S,zoomActivationKeyPressed:C,panOnDrag:u,zoomOnScroll:b,panOnScroll:i,zoomOnDoubleClick:x,zoomOnPinch:y,userSelectionActive:r,noPanClassName:t,noWheelClassName:e,lib:w,connectionInProgress:E});f.filter(P),x?p.on(`dblclick.zoom`,h):p.on(`dblclick.zoom`,null)}function v(){f.on(`zoom`,null)}async function y(e,t,n){let r=XM(e),i=f?.constrain()(r,t,n);return i&&await g(i),i}async function b(e,t){let n=XM(e);return await g(n,t),n}function x(e){if(p){let t=XM(e),n=p.property(`__zoom`);(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&f?.transform(p,t,null,{sync:!0})}}function S(){let e=p?TA(p.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}}async function C(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?xO:FO).scaleTo(eN(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}async function w(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?xO:FO).scaleBy(eN(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function T(e){f?.scaleExtent(e)}function E(e){f?.translateExtent(e)}function D(e){let t=!vj(e)||e<0?0:e;f?.clickDistance(t)}return{update:_,destroy:v,setViewport:b,setViewportConstrained:y,getViewport:S,scaleTo:C,scaleBy:w,setScaleExtent:T,setTranslateExtent:E,syncViewport:x,setClickDistance:D}}var lN;(function(e){e.Line=`line`,e.Handle=`handle`})(lN||={});function uN({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:i,affectsY:a}){let o=e-t,s=n-r,c=[o>0?1:o<0?-1:0,s>0?1:s<0?-1:0];return o&&i&&(c[0]*=-1),s&&a&&(c[1]*=-1),c}function dN(e){return{isHorizontal:e.includes(`right`)||e.includes(`left`),isVertical:e.includes(`bottom`)||e.includes(`top`),affectsX:e.includes(`left`),affectsY:e.includes(`top`)}}function fN(e,t){return Math.max(0,t-e)}function pN(e,t){return Math.max(0,e-t)}function mN(e,t,n){return Math.max(0,t-e,e-n)}function hN(e,t){return e?!t:t}function gN(e,t,n,r,i,a,o,s){let{affectsX:c,affectsY:l}=t,{isHorizontal:u,isVertical:d}=t,f=u&&d,{xSnapped:p,ySnapped:m}=n,{minWidth:h,maxWidth:g,minHeight:_,maxHeight:v}=r,{x:y,y:b,width:x,height:S,aspectRatio:C}=e,w=Math.floor(u?p-e.pointerX:0),T=Math.floor(d?m-e.pointerY:0),E=x+(c?-w:w),D=S+(l?-T:T),O=-a[0]*x,k=-a[1]*S,A=mN(E,h,g),j=mN(D,_,v);if(o){let e=0,t=0;c&&w<0?e=fN(y+w+O,o[0][0]):!c&&w>0&&(e=pN(y+E+O,o[1][0])),l&&T<0?t=fN(b+T+k,o[0][1]):!l&&T>0&&(t=pN(b+D+k,o[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(s){let e=0,t=0;c&&w>0?e=pN(y+w,s[0][0]):!c&&w<0&&(e=fN(y+E,s[1][0])),l&&T>0?t=pN(b+T,s[0][1]):!l&&T<0&&(t=fN(b+D,s[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(i){if(u){let e=mN(E/C,_,v)*C;if(A=Math.max(A,e),o){let e=0;e=!c&&!l||c&&!l&&f?pN(b+k+E/C,o[1][1])*C:fN(b+k+(c?w:-w)/C,o[0][1])*C,A=Math.max(A,e)}if(s){let e=0;e=!c&&!l||c&&!l&&f?fN(b+E/C,s[1][1])*C:pN(b+(c?w:-w)/C,s[0][1])*C,A=Math.max(A,e)}}if(d){let e=mN(D*C,h,g)/C;if(j=Math.max(j,e),o){let e=0;e=!c&&!l||l&&!c&&f?pN(y+D*C+O,o[1][0])/C:fN(y+(l?T:-T)*C+O,o[0][0])/C,j=Math.max(j,e)}if(s){let e=0;e=!c&&!l||l&&!c&&f?fN(y+D*C,s[1][0])/C:pN(y+(l?T:-T)*C,s[0][0])/C,j=Math.max(j,e)}}}T+=T<0?j:-j,w+=w<0?A:-A,i&&(f?E>D*C?T=(hN(c,l)?-w:w)/C:w=(hN(c,l)?-T:T)*C:u?(T=w/C,l=c):(w=T*C,c=l));let M=c?y+w:y,N=l?b+T:b;return{width:x+(c?-w:w),height:S+(l?-T:T),x:a[0]*w*(c?-1:1)+M,y:a[1]*T*(l?-1:1)+N}}var _N={width:0,height:0,x:0,y:0},vN={..._N,pointerX:0,pointerY:0,aspectRatio:1};function yN(e,t,n){let r=t.position.x+e.position.x,i=t.position.y+e.position.y,a=e.measured.width??0,o=e.measured.height??0,s=n[0]*a,c=n[1]*o;return[[r-s,i-c],[r+a-s,i+o-c]]}function bN({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=rD(e),o={controlDirection:dN(`bottom-right`),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function s({controlPosition:e,boundaries:s,keepAspectRatio:c,resizeDirection:l,onResizeStart:u,onResize:d,onResizeEnd:f,shouldResize:p}){let m={..._N},h={...vN};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:dN(e)};let g,_=null,v=[],y,b,x,S=!1,C=vD().on(`start`,e=>{let{nodeLookup:r,transform:i,snapGrid:a,snapToGrid:o,nodeOrigin:s,paneDomNode:c}=n();if(g=r.get(t),!g)return;_=c?.getBoundingClientRect()??null;let{xSnapped:l,ySnapped:d}=Ij(e.sourceEvent,{transform:i,snapGrid:a,snapToGrid:o,containerBounds:_});m={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},h={...m,pointerX:l,pointerY:d,aspectRatio:m.width/m.height},y=void 0,b=Oj(g.extent)?g.extent:void 0,g.parentId&&(g.extent===`parent`||g.expandParent)&&(y=r.get(g.parentId)),y&&g.extent===`parent`&&(b=[[0,0],[y.measured.width,y.measured.height]]),v=[],x=void 0;for(let[e,n]of r)if(n.parentId===t&&(v.push({id:e,position:{...n.position},extent:n.extent}),n.extent===`parent`||n.expandParent)){let e=yN(n,g,n.origin??s);x=x?[[Math.min(e[0][0],x[0][0]),Math.min(e[0][1],x[0][1])],[Math.max(e[1][0],x[1][0]),Math.max(e[1][1],x[1][1])]]:e}u?.(e,{...m})}).on(`drag`,e=>{let{transform:t,snapGrid:i,snapToGrid:a,nodeOrigin:s}=n(),c=Ij(e.sourceEvent,{transform:t,snapGrid:i,snapToGrid:a,containerBounds:_}),l=[];if(!g)return;let{x:u,y:f,width:C,height:w}=m,T={},E=g.origin??s,{width:D,height:O,x:k,y:A}=gN(h,o.controlDirection,c,o.boundaries,o.keepAspectRatio,E,b,x),j=D!==C,M=O!==w,N=k!==u&&j,P=A!==f&&M;if(!N&&!P&&!j&&!M)return;if((N||P||E[0]===1||E[1]===1)&&(T.x=N?k:m.x,T.y=P?A:m.y,m.x=T.x,m.y=T.y,v.length>0)){let e=k-u,t=A-f;for(let n of v)n.position={x:n.position.x-e+E[0]*(D-C),y:n.position.y-t+E[1]*(O-w)},l.push(n)}if((j||M)&&(T.width=j&&(!o.resizeDirection||o.resizeDirection===`horizontal`)?D:m.width,T.height=M&&(!o.resizeDirection||o.resizeDirection===`vertical`)?O:m.height,m.width=T.width,m.height=T.height),y&&g.expandParent){let e=E[0]*(T.width??0);T.x&&T.x<e&&(m.x=e,h.x-=T.x-e);let t=E[1]*(T.height??0);T.y&&T.y<t&&(m.y=t,h.y-=T.y-t)}let F=uN({width:m.width,prevWidth:C,height:m.height,prevHeight:w,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),I={...m,direction:F};p?.(e,I)!==!1&&(S=!0,d?.(e,I),r(T,l))}).on(`end`,e=>{S&&=(f?.(e,{...m}),i?.({...m}),!1)});a.call(C)}function c(){a.on(`.drag`,null)}return{update:s,destroy:c}}var xN=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},o=t=e(r,i,a);return a},SN=e=>e?xN(e):xN,{useDebugValue:CN}=H.default,{useSyncExternalStoreWithSelector:wN}=Vw.default,TN=e=>e;function EN(e,t=TN,n){let r=wN(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return CN(r),r}var DN=(e,t)=>{let n=SN(e),r=(e,r=t)=>EN(n,e,r);return Object.assign(r,n),r},ON=(e,t)=>e?DN(e,t):DN;function kN(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var AN=(0,H.createContext)(null),jN=AN.Provider,MN=FA.error001(`react`);function $(e,t){let n=(0,H.useContext)(AN);if(n===null)throw Error(MN);return EN(n,e,t)}function NN(){let e=(0,H.useContext)(AN);if(e===null)throw Error(MN);return(0,H.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var PN={display:`none`},FN={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},IN=`react-flow__node-desc`,LN=`react-flow__edge-desc`,RN=`react-flow__aria-live`,zN=e=>e.ariaLiveMessage,BN=e=>e.ariaLabelConfig;function VN({rfId:e}){let t=$(zN);return(0,U.jsx)(`div`,{id:`${RN}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:FN,children:t})}function HN({rfId:e,disableKeyboardA11y:t}){let n=$(BN);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{id:`${IN}-${e}`,style:PN,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,U.jsx)(`div`,{id:`${LN}-${e}`,style:PN,children:n[`edge.a11yDescription.default`]}),!t&&(0,U.jsx)(VN,{rfId:e})]})}var UN=(0,H.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>{let o=`${e}`.split(`-`);return(0,U.jsx)(`div`,{className:Qw([`react-flow__panel`,n,...o]),style:r,ref:a,...i,children:t})});UN.displayName=`Panel`;var WN=`https://reactflow.dev?utm_source=attribution`;function GN({proOptions:e,position:t=`bottom-right`}){return(0,H.useEffect)(()=>{},[]),e?.hideAttribution?null:(0,U.jsx)(UN,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${WN}`,children:(0,U.jsx)(`a`,{href:WN,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`,children:`React Flow`})})}var KN=e=>{let t=[],n=[];for(let[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(let[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},qN=e=>e.id;function JN(e,t){return kN(e.selectedNodes.map(qN),t.selectedNodes.map(qN))&&kN(e.selectedEdges.map(qN),t.selectedEdges.map(qN))}function YN({onSelectionChange:e}){let t=NN(),{selectedNodes:n,selectedEdges:r}=$(KN,JN);return(0,H.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChangeHandlers.forEach(e=>e(i))},[n,r,e]),null}var XN=e=>!!e.onSelectionChangeHandlers;function ZN({onSelectionChange:e}){let t=$(XN);return e||t?(0,U.jsx)(YN,{onSelectionChange:e}):null}var QN=[0,0],$N={x:0,y:0,zoom:1},eP=[...`nodes.edges.defaultNodes.defaultEdges.onConnect.onConnectStart.onConnectEnd.onClickConnectStart.onClickConnectEnd.nodesDraggable.autoPanOnNodeFocus.nodesConnectable.nodesFocusable.edgesFocusable.edgesReconnectable.elevateNodesOnSelect.elevateEdgesOnSelect.minZoom.maxZoom.nodeExtent.onNodesChange.onEdgesChange.elementsSelectable.connectionMode.snapGrid.snapToGrid.translateExtent.connectOnClick.defaultEdgeOptions.fitView.fitViewOptions.onNodesDelete.onEdgesDelete.onDelete.onNodeDrag.onNodeDragStart.onNodeDragStop.onSelectionDrag.onSelectionDragStart.onSelectionDragStop.onMoveStart.onMove.onMoveEnd.noPanClassName.nodeOrigin.autoPanOnConnect.autoPanOnNodeDrag.onError.connectionRadius.isValidConnection.selectNodesOnDrag.nodeDragThreshold.connectionDragThreshold.onBeforeDelete.debug.autoPanSpeed.ariaLabelConfig.zIndexMode`.split(`.`),`rfId`],tP=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),nP={translateExtent:IA,nodeOrigin:QN,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function rP(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=$(tP,kN),l=NN();(0,H.useEffect)(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=nP,s()}),[]);let u=(0,H.useRef)(nP);return(0,H.useEffect)(()=>{for(let s of eP){let c=e[s];c!==u.current[s]&&e[s]!==void 0&&(s===`nodes`?t(c):s===`edges`?n(c):s===`minZoom`?r(c):s===`maxZoom`?i(c):s===`translateExtent`?a(c):s===`nodeExtent`?o(c):s===`ariaLabelConfig`?l.setState({ariaLabelConfig:Pj(c)}):s===`fitView`?l.setState({fitViewQueued:c}):s===`fitViewOptions`?l.setState({fitViewOptions:c}):l.setState({[s]:c}))}u.current=e},eP.map(t=>e[t])),null}function iP(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function aP(e){let[t,n]=(0,H.useState)(e===`system`?null:e);return(0,H.useEffect)(()=>{if(e!==`system`){n(e);return}let t=iP(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?iP()?.matches?`dark`:`light`:t}var oP=typeof document<`u`?document:null;function sP(e=null,t={target:oP,actInsideInputWithModifier:!0}){let[n,r]=(0,H.useState)(!1),i=(0,H.useRef)(!1),a=(0,H.useRef)(new Set([])),[o,s]=(0,H.useMemo)(()=>{if(e!==null){let t=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).map(e=>e.replace(/\+/g,`
|
|
141
141
|
`).replace(`
|
|
142
142
|
|
|
143
143
|
`,`
|
|
144
144
|
+`).split(`
|
|
145
|
-
`));return[t,t.reduce((e,t)=>e.concat(...t),[])]}return[[],[]]},[e]);return(0,H.useEffect)(()=>{let n=t?.target??ZN,c=t?.actInsideInputWithModifier??!0;if(e!==null){let e=e=>{if(i.current=e.ctrlKey||e.metaKey||e.shiftKey||e.altKey,(!i.current||i.current&&!c)&&jj(e))return!1;let n=eP(e.code,s);if(a.current.add(e[n]),$N(o,a.current,!1)){let n=e.composedPath?.()?.[0]||e.target,a=n?.nodeName===`BUTTON`||n?.nodeName===`A`;t.preventDefault!==!1&&(i.current||!a)&&e.preventDefault(),r(!0)}},l=e=>{let t=eP(e.code,s);$N(o,a.current,!0)?(r(!1),a.current.clear()):a.current.delete(e[t]),e.key===`Meta`&&a.current.clear(),i.current=!1},u=()=>{a.current.clear(),r(!1)};return n?.addEventListener(`keydown`,e),n?.addEventListener(`keyup`,l),window.addEventListener(`blur`,u),window.addEventListener(`contextmenu`,u),()=>{n?.removeEventListener(`keydown`,e),n?.removeEventListener(`keyup`,l),window.removeEventListener(`blur`,u),window.removeEventListener(`contextmenu`,u)}}},[e,r]),n}function $N(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function eP(e,t){return t.includes(e)?`code`:`key`}var tP=()=>{let e=wN();return(0,H.useMemo)(()=>({zoomIn:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{let{panZoom:r}=e.getState();return r?r.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{let{transform:[r,i,a],panZoom:o}=e.getState();return o?(await o.setViewport({x:t.x??r,y:t.y??i,zoom:t.zoom??a},n),!0):!1},getViewport:()=>{let[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{let{width:r,height:i,minZoom:a,maxZoom:o,panZoom:s}=e.getState(),c=_j(t,r,i,a,o,n?.padding??.1);return s?(await s.setViewport(c,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{let{transform:r,snapGrid:i,snapToGrid:a,domNode:o}=e.getState();if(!o)return t;let{x:s,y:c}=o.getBoundingClientRect(),l={x:t.x-s,y:t.y-c},u=n.snapGrid??i;return fj(l,r,n.snapToGrid??a,u)},flowToScreenPosition:t=>{let{transform:n,domNode:r}=e.getState();if(!r)return t;let{x:i,y:a}=r.getBoundingClientRect(),o=pj(t,n);return{x:o.x+i,y:o.y+a}}}),[])};function nP(e,t){let n=[],r=new Map,i=[];for(let t of e)if(t.type===`add`){i.push(t);continue}else if(t.type===`remove`||t.type===`replace`)r.set(t.id,[t]);else{let e=r.get(t.id);e?e.push(t):r.set(t.id,[t])}for(let e of t){let t=r.get(e.id);if(!t){n.push(e);continue}if(t[0].type===`remove`)continue;if(t[0].type===`replace`){n.push({...t[0].item});continue}let i={...e};for(let e of t)rP(e,i);n.push(i)}return i.length&&i.forEach(e=>{e.index===void 0?n.push({...e.item}):n.splice(e.index,0,{...e.item})}),n}function rP(e,t){switch(e.type){case`select`:t.selected=e.selected;break;case`position`:e.position!==void 0&&(t.position=e.position),e.dragging!==void 0&&(t.dragging=e.dragging);break;case`dimensions`:e.dimensions!==void 0&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes===`width`)&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes===`height`)&&(t.height=e.dimensions.height))),typeof e.resizing==`boolean`&&(t.resizing=e.resizing)}}function iP(e,t){return nP(e,t)}function aP(e,t){return nP(e,t)}function oP(e,t){return{id:e,type:`select`,selected:t}}function sP(e,t=new Set,n=!1){let r=[];for(let[i,a]of e){let e=t.has(i);!(a.selected===void 0&&!e)&&a.selected!==e&&(n&&(a.selected=e),r.push(oP(a.id,e)))}return r}function cP({items:e=[],lookup:t}){let n=[],r=new Map(e.map(e=>[e.id,e]));for(let[r,i]of e.entries()){let e=t.get(i.id),a=e?.internals?.userNode??e;a!==void 0&&a!==i&&n.push({id:i.id,item:i,type:`replace`}),a===void 0&&n.push({item:i,type:`add`,index:r})}for(let[e]of t)r.get(e)===void 0&&n.push({id:e,type:`remove`});return n}function lP(e){return{id:e.id,type:`remove`}}var uP=uj(`React Flow`,`https://reactflow.dev/`);function dP(e,t,n={}){return Wj(e,t,{...n,onError:n.onError??uP})}var fP=e=>RA(e),pP=e=>LA(e);function mP(e){return(0,H.forwardRef)(e)}var hP=typeof window<`u`?H.useLayoutEffect:H.useEffect;function gP(e){let[t,n]=(0,H.useState)(BigInt(0)),[r]=(0,H.useState)(()=>_P(()=>n(e=>e+BigInt(1))));return hP(()=>{let t=r.get();t.length&&(e(t),r.reset())},[t]),r}function _P(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}var vP=(0,H.createContext)(null);function yP({children:e}){let t=wN(),n=gP((0,H.useCallback)(e=>{let{nodes:n=[],setNodes:r,hasDefaultNodes:i,onNodesChange:a,nodeLookup:o,fitViewQueued:s,onNodesChangeMiddlewareMap:c}=t.getState(),l=n;for(let t of e)l=typeof t==`function`?t(l):t;let u=cP({items:l,lookup:o});for(let e of c.values())u=e(u);i&&r(l),u.length>0?a?.(u):s&&window.requestAnimationFrame(()=>{let{fitViewQueued:e,nodes:n,setNodes:r}=t.getState();e&&r(n)})},[])),r=gP((0,H.useCallback)(e=>{let{edges:n=[],setEdges:r,hasDefaultEdges:i,onEdgesChange:a,edgeLookup:o}=t.getState(),s=n;for(let t of e)s=typeof t==`function`?t(s):t;i?r(s):a&&a(cP({items:s,lookup:o}))},[])),i=(0,H.useMemo)(()=>({nodeQueue:n,edgeQueue:r}),[]);return(0,U.jsx)(vP.Provider,{value:i,children:e})}function bP(){let e=(0,H.useContext)(vP);if(!e)throw Error(`useBatchContext must be used within a BatchProvider`);return e}var xP=e=>!!e.panZoom;function SP(){let e=tP(),t=wN(),n=bP(),r=$(xP),i=(0,H.useMemo)(()=>{let e=e=>t.getState().nodeLookup.get(e),r=e=>{n.nodeQueue.push(e)},i=e=>{n.edgeQueue.push(e)},a=e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState(),i=fP(e)?e:n.get(e.id),a=i.parentId?Sj(i.position,i.measured,i.parentId,n,r):i.position;return rj({...i,position:a,width:i.measured?.width??i.width,height:i.measured?.height??i.height})},o=(e,t,n={replace:!1})=>{r(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&fP(e)?e:{...r,...e}}return r}))},s=(e,t,n={replace:!1})=>{i(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&pP(e)?e:{...r,...e}}return r}))};return{getNodes:()=>t.getState().nodes.map(e=>({...e})),getNode:t=>e(t)?.internals.userNode,getInternalNode:e,getEdges:()=>{let{edges:e=[]}=t.getState();return e.map(e=>({...e}))},getEdge:e=>t.getState().edgeLookup.get(e),setNodes:r,setEdges:i,addNodes:e=>{let t=Array.isArray(e)?e:[e];n.nodeQueue.push(e=>[...e,...t])},addEdges:e=>{let t=Array.isArray(e)?e:[e];n.edgeQueue.push(e=>[...e,...t])},toObject:()=>{let{nodes:e=[],edges:n=[],transform:r}=t.getState(),[i,a,o]=r;return{nodes:e.map(e=>({...e})),edges:n.map(e=>({...e})),viewport:{x:i,y:a,zoom:o}}},deleteElements:async({nodes:e=[],edges:n=[]})=>{let{nodes:r,edges:i,onNodesDelete:a,onEdgesDelete:o,triggerNodeChanges:s,triggerEdgeChanges:c,onDelete:l,onBeforeDelete:u}=t.getState(),{nodes:d,edges:f}=await JA({nodesToRemove:e,edgesToRemove:n,nodes:r,edges:i,onBeforeDelete:u}),p=f.length>0,m=d.length>0;if(p){let e=f.map(lP);o?.(f),c(e)}if(m){let e=d.map(lP);a?.(d),s(e)}return(m||p)&&l?.({nodes:d,edges:f}),{deletedNodes:d,deletedEdges:f}},getIntersectingNodes:(e,n=!0,r)=>{let i=cj(e),o=i?e:a(e),s=r!==void 0;return o?(r||t.getState().nodes).filter(r=>{let a=t.getState().nodeLookup.get(r.id);if(a&&!i&&(r.id===e.id||!a.internals.positionAbsolute))return!1;let c=rj(s?r:a),l=sj(c,o);return n&&l>0||l>=c.width*c.height||l>=o.width*o.height}):[]},isNodeIntersecting:(e,t,n=!0)=>{let r=cj(e)?e:a(e);if(!r)return!1;let i=sj(r,t);return n&&i>0||i>=t.width*t.height||i>=r.width*r.height},updateNode:o,updateNodeData:(e,t,n={replace:!1})=>{o(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},updateEdge:s,updateEdgeData:(e,t,n={replace:!1})=>{s(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},getNodesBounds:e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState();return VA(e,{nodeLookup:n,nodeOrigin:r})},getHandleConnections:({type:e,id:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}-${e}${n?`-${n}`:``}`)?.values()??[]),getNodeConnections:({type:e,handleId:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}${e?n?`-${e}-${n}`:`-${e}`:``}`)?.values()??[]),fitView:async e=>{let r=t.getState().fitViewResolver??wj();return t.setState({fitViewQueued:!0,fitViewOptions:e,fitViewResolver:r}),n.nodeQueue.push(e=>[...e]),r.promise}}},[]);return(0,H.useMemo)(()=>({...i,...e,viewportInitialized:r}),[r])}var CP=e=>e.selected,wP=typeof window<`u`?window:void 0;function TP({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=wN(),{deleteElements:r}=SP(),i=QN(e,{actInsideInputWithModifier:!1}),a=QN(t,{target:wP});(0,H.useEffect)(()=>{if(i){let{edges:e,nodes:t}=n.getState();r({nodes:t.filter(CP),edges:e.filter(CP)}),n.setState({nodesSelectionActive:!1})}},[i]),(0,H.useEffect)(()=>{n.setState({multiSelectionActive:a})},[a])}function EP(e){let t=wN();(0,H.useEffect)(()=>{let n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;let n=Oj(e.current);(n.height===0||n.width===0)&&t.getState().onError?.(`004`,EA.error004()),t.setState({width:n.width||500,height:n.height||500})};if(e.current){n(),window.addEventListener(`resize`,n);let t=new ResizeObserver(()=>n());return t.observe(e.current),()=>{window.removeEventListener(`resize`,n),t&&e.current&&t.unobserve(e.current)}}},[])}var DP={position:`absolute`,width:`100%`,height:`100%`,top:0,left:0},OP=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function kP({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panActivationKeyPressed:i,panOnScrollSpeed:a=.5,panOnScrollMode:o=jA.Free,zoomOnDoubleClick:s=!0,panOnDrag:c=!0,defaultViewport:l,translateExtent:u,minZoom:d,maxZoom:f,zoomActivationKeyCode:p,preventScrolling:m=!0,children:h,noWheelClassName:g,noPanClassName:_,onViewportChange:v,isControlledViewport:y,paneClickDistance:b,selectionOnDrag:x}){let S=wN(),C=(0,H.useRef)(null),{userSelectionActive:w,lib:T,connectionInProgress:E}=$(OP,bN),D=QN(p),O=(0,H.useRef)();EP(C);let k=(0,H.useCallback)(e=>{v?.({x:e[0],y:e[1],zoom:e[2]}),y||S.setState({transform:e})},[v,y]);return(0,H.useEffect)(()=>{if(C.current){O.current=$M({domNode:C.current,minZoom:d,maxZoom:f,translateExtent:u,viewport:l,onDraggingChange:e=>S.setState(t=>t.paneDragging===e?t:{paneDragging:e}),onPanZoomStart:(e,t)=>{let{onViewportChangeStart:n,onMoveStart:r}=S.getState();r?.(e,t),n?.(t)},onPanZoom:(e,t)=>{let{onViewportChange:n,onMove:r}=S.getState();r?.(e,t),n?.(t)},onPanZoomEnd:(e,t)=>{let{onViewportChangeEnd:n,onMoveEnd:r}=S.getState();r?.(e,t),n?.(t)}});let{x:e,y:t,zoom:n}=O.current.getViewport();return S.setState({panZoom:O.current,transform:[e,t,n],domNode:C.current.closest(`.react-flow`)}),()=>{O.current?.destroy()}}},[]),(0,H.useEffect)(()=>{O.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panActivationKeyPressed:i,panOnScrollSpeed:a,panOnScrollMode:o,zoomOnDoubleClick:s,panOnDrag:c,zoomActivationKeyPressed:D,preventScrolling:m,noPanClassName:_,userSelectionActive:w,noWheelClassName:g,lib:T,onTransformChange:k,connectionInProgress:E,selectionOnDrag:x,paneClickDistance:b})},[e,t,n,r,i,a,o,s,c,D,m,_,w,g,T,k,E,x,b]),(0,U.jsx)(`div`,{className:`react-flow__renderer`,ref:C,style:DP,children:h})}var AP=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function jP(){let{userSelectionActive:e,userSelectionRect:t}=$(AP,bN);return e&&t?(0,U.jsx)(`div`,{className:`react-flow__selection react-flow__container`,style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}var MP=(e,t)=>n=>{n.target===t.current&&e?.(n)},NP=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function PP({isSelecting:e,selectionKeyPressed:t,selectionMode:n=MA.Full,panOnDrag:r,autoPanOnSelection:i,paneClickDistance:a,selectionOnDrag:o,onSelectionStart:s,onSelectionEnd:c,onPaneClick:l,onPaneContextMenu:u,onPaneScroll:d,onPaneMouseEnter:f,onPaneMouseMove:p,onPaneMouseLeave:m,children:h}){let g=(0,H.useRef)(0),_=wN(),{userSelectionActive:v,elementsSelectable:y,dragging:b,panBy:x,autoPanSpeed:S}=$(NP,bN),C=y&&(e||v),w=(0,H.useRef)(null),T=(0,H.useRef)(),E=(0,H.useRef)(new Set),D=(0,H.useRef)(new Set),O=(0,H.useRef)(!1),k=(0,H.useRef)(!1),A=(0,H.useRef)({x:0,y:0}),j=(0,H.useRef)(!1),M=e=>{if(k.current||O.current||_.getState().connection.inProgress){k.current=!1,O.current=!1;return}l?.(e),_.getState().resetSelectedElements(),_.setState({nodesSelectionActive:!1})},N=e=>{if(Array.isArray(r)&&r?.includes(2)){e.preventDefault();return}u?.(e)},P=d?e=>d(e):void 0,F=e=>{k.current&&=(e.stopPropagation(),!1)},I=n=>{if(n.pointerType===`touch`&&r!==!1&&!t)return;let{domNode:i,transform:a}=_.getState();if(T.current=i?.getBoundingClientRect(),!T.current)return;let s=n.target===w.current;if(!s&&n.target.closest(`.nokey`)||!e||!(o&&s||t)||n.button!==0||!n.isPrimary)return;n.target?.setPointerCapture?.(n.pointerId),k.current=!1;let{x:c,y:l}=Nj(n.nativeEvent,T.current),u=fj({x:c,y:l},a);_.setState({userSelectionRect:{width:0,height:0,startX:u.x,startY:u.y,x:c,y:l}}),s||(n.stopPropagation(),n.preventDefault())};function L(e,t){let{userSelectionRect:r}=_.getState();if(!r)return;let{transform:i,nodeLookup:a,edgeLookup:o,connectionLookup:s,triggerNodeChanges:c,triggerEdgeChanges:l,defaultEdgeOptions:u}=_.getState(),d={x:r.startX,y:r.startY},{x:f,y:p}=pj(d,i),m={startX:d.x,startY:d.y,x:e<f?e:f,y:t<p?t:p,width:Math.abs(e-f),height:Math.abs(t-p)},h=E.current,g=D.current;E.current=new Set(UA(a,m,i,n===MA.Partial,!0).map(e=>e.id)),D.current=new Set;let v=u?.selectable??!0;for(let e of E.current){let t=s.get(e);if(t)for(let{edgeId:e}of t.values()){let t=o.get(e);t&&(t.selectable??v)&&D.current.add(e)}}Cj(h,E.current)||c(sP(a,E.current,!0)),Cj(g,D.current)||l(sP(o,D.current)),_.setState({userSelectionRect:m,userSelectionActive:!0,nodesSelectionActive:!1})}function R(){if(!i||!T.current)return;let[e,t]=$A(A.current,T.current,S);x({x:e,y:t}).then(e=>{if(!k.current||!e){g.current=requestAnimationFrame(R);return}let{x:t,y:n}=A.current;L(t,n),g.current=requestAnimationFrame(R)})}let ee=()=>{cancelAnimationFrame(g.current),g.current=0,j.current=!1};(0,H.useEffect)(()=>()=>ee(),[]);let z=e=>{let{userSelectionRect:n,transform:r,resetSelectedElements:i}=_.getState();if(!T.current||!n)return;let{x:o,y:c}=Nj(e.nativeEvent,T.current);A.current={x:o,y:c};let l=pj({x:n.startX,y:n.startY},r);if(!k.current){let n=t?0:a;if(Math.hypot(o-l.x,c-l.y)<=n)return;i(),s?.(e)}k.current=!0,j.current||=(R(),!0),L(o,c)},B=e=>{if(!C){e.target===w.current&&_.getState().connection.inProgress&&(O.current=!0);return}e.button===0&&(e.target?.releasePointerCapture?.(e.pointerId),!v&&e.target===w.current&&_.getState().userSelectionRect&&M?.(e),_.setState({userSelectionActive:!1,userSelectionRect:null}),k.current&&(c?.(e),_.setState({nodesSelectionActive:E.current.size>0})),ee())},te=e=>{e.target?.releasePointerCapture?.(e.pointerId),ee()},V=r===!0||Array.isArray(r)&&r.includes(0);return(0,U.jsxs)(`div`,{className:Uw([`react-flow__pane`,{draggable:V,dragging:b,selection:e}]),onClick:C?void 0:MP(M,w),onContextMenu:MP(N,w),onWheel:MP(P,w),onPointerEnter:C?void 0:f,onPointerMove:C?z:p,onPointerUp:B,onPointerCancel:C?te:void 0,onPointerDownCapture:C?I:void 0,onClickCapture:C?F:void 0,onPointerLeave:m,ref:w,style:DP,children:[h,(0,U.jsx)(jP,{})]})}function FP({id:e,store:t,unselect:n=!1,nodeRef:r}){let{addSelectedNodes:i,unselectNodesAndEdges:a,multiSelectionActive:o,nodeLookup:s,onError:c}=t.getState(),l=s.get(e);if(!l){c?.(`012`,EA.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&o)&&(a({nodes:[l],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])}function IP({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:a,nodeClickDistance:o}){let s=wN(),[c,l]=(0,H.useState)(!1),u=(0,H.useRef)();return(0,H.useEffect)(()=>{if(!t)return u.current=OM({getStoreItems:()=>s.getState(),onNodeMouseDown:t=>{FP({id:t,store:s,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}}),()=>{u.current?.destroy(),u.current=void 0}},[t,s,e]),(0,H.useEffect)(()=>{t||!e.current||!u.current||u.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:a,nodeId:i,nodeClickDistance:o})},[n,r,t,a,e,i,o]),c}var LP=e=>t=>t.selected&&(t.draggable||e&&t.draggable===void 0);function RP(){let e=wN();return(0,H.useCallback)(t=>{let{nodeExtent:n,snapToGrid:r,snapGrid:i,nodesDraggable:a,onError:o,updateNodePositions:s,nodeLookup:c,nodeOrigin:l}=e.getState(),u=new Map,d=LP(a),f=r?i[0]:5,p=r?i[1]:5,m=t.direction.x*f*t.factor,h=t.direction.y*p*t.factor;for(let[,e]of c){if(!d(e))continue;let t={x:e.internals.positionAbsolute.x+m,y:e.internals.positionAbsolute.y+h};r&&(t=dj(t,i));let{position:a,positionAbsolute:s}=qA({nodeId:e.id,nextPosition:t,nodeLookup:c,nodeExtent:n,nodeOrigin:l,onError:o});e.position=a,e.internals.positionAbsolute=s,u.set(e.id,e)}s(u)},[])}var zP=(0,H.createContext)(null),BP=zP.Provider;zP.Consumer;var VP=()=>(0,H.useContext)(zP),HP=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),UP=(0,H.createContext)(null);function WP({children:e}){let t=$(HP,bN);return(0,U.jsx)(UP.Provider,{value:t,children:e})}function GP(){let e=(0,H.useContext)(UP);if(!e)throw Error(`useHandleConfig must be used within a HandleConfigProvider`);return e}var KP={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},qP=(e,t,n)=>r=>{let{connectionClickStartHandle:i,connectionMode:a,connection:o}=r,{fromHandle:s,toHandle:c,isValid:l}=o;if(!s&&!i)return KP;let u=c?.nodeId===e&&c?.id===t&&c?.type===n;return{connectingFrom:s?.nodeId===e&&s?.id===t&&s?.type===n,connectingTo:u,clickConnecting:i?.nodeId===e&&i?.id===t&&i?.type===n,isPossibleEndHandle:a===AA.Strict?s?.type!==n:e!==s?.nodeId||t!==s?.id,connectionInProcess:!!s,clickConnectionInProcess:!!i,valid:u&&l}};function JP({type:e=`source`,position:t=Q.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:a=!0,id:o,onConnect:s,children:c,className:l,onMouseDown:u,onTouchStart:d,...f},p){let m=o||null,h=e===`target`,g=wN(),_=VP(),{connectOnClick:v,noPanClassName:y,rfId:b}=GP(),{connectingFrom:x,connectingTo:S,clickConnecting:C,isPossibleEndHandle:w,connectionInProcess:T,clickConnectionInProcess:E,valid:D}=$(qP(_,m,e),bN);_||g.getState().onError?.(`010`,EA.error010());let O=e=>{let{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:r}=g.getState(),i={...t,...e};if(r){let{edges:e,setEdges:t,onError:n}=g.getState();t(dP(i,e,{onError:n}))}n?.(i),s?.(i)},k=e=>{if(!_)return;let t=Mj(e.nativeEvent);if(i&&(t&&e.button===0||!t)){let t=g.getState();RM.onPointerDown(e.nativeEvent,{handleDomNode:e.currentTarget,autoPanOnConnect:t.autoPanOnConnect,connectionMode:t.connectionMode,connectionRadius:t.connectionRadius,domNode:t.domNode,nodeLookup:t.nodeLookup,lib:t.lib,isTarget:h,handleId:m,nodeId:_,flowId:t.rfId,panBy:t.panBy,cancelConnection:t.cancelConnection,onConnectStart:t.onConnectStart,onConnectEnd:(...e)=>g.getState().onConnectEnd?.(...e),updateConnection:t.updateConnection,onConnect:O,isValidConnection:n||((...e)=>g.getState().isValidConnection?.(...e)??!0),getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,autoPanSpeed:t.autoPanSpeed,dragThreshold:t.connectionDragThreshold})}t?u?.(e):d?.(e)};return(0,U.jsx)(`div`,{"data-handleid":m,"data-nodeid":_,"data-handlepos":t,"data-id":`${b}-${_}-${m}-${e}`,className:Uw([`react-flow__handle`,`react-flow__handle-${t}`,`nodrag`,y,l,{source:!h,target:h,connectable:r,connectablestart:i,connectableend:a,clickconnecting:C,connectingfrom:x,connectingto:S,valid:D,connectionindicator:r&&(!T||w)&&(T||E?a:i)}]),onMouseDown:k,onTouchStart:k,onClick:v?t=>{let{onClickConnectStart:r,onClickConnectEnd:a,connectionClickStartHandle:o,connectionMode:s,isValidConnection:c,lib:l,rfId:u,nodeLookup:d,connection:f}=g.getState();if(!_||!o&&!i)return;if(!o){r?.(t.nativeEvent,{nodeId:_,handleId:m,handleType:e}),g.setState({connectionClickStartHandle:{nodeId:_,type:e,id:m}});return}let p=kj(t.target),h=n||c,{connection:v,isValid:y}=RM.isValid(t.nativeEvent,{handle:{nodeId:_,id:m,type:e},connectionMode:s,fromNodeId:o.nodeId,fromHandleId:o.id||null,fromType:o.type,isValidConnection:h,flowId:u,doc:p,lib:l,nodeLookup:d});y&&v&&O(v);let b=structuredClone(f);delete b.inProgress,b.toPosition=b.toHandle?b.toHandle.position:null,a?.(t,b),g.setState({connectionClickStartHandle:null})}:void 0,ref:p,...f,children:c})}var YP=(0,H.memo)(mP(JP));function XP({data:e,isConnectable:t,sourcePosition:n=Q.Bottom}){return(0,U.jsxs)(U.Fragment,{children:[e?.label,(0,U.jsx)(YP,{type:`source`,position:n,isConnectable:t})]})}function ZP({data:e,isConnectable:t,targetPosition:n=Q.Top,sourcePosition:r=Q.Bottom}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(YP,{type:`target`,position:n,isConnectable:t}),e?.label,(0,U.jsx)(YP,{type:`source`,position:r,isConnectable:t})]})}function QP(){return null}function $P({data:e,isConnectable:t,targetPosition:n=Q.Top}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(YP,{type:`target`,position:n,isConnectable:t}),e?.label]})}var eF={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},tF={input:XP,default:ZP,output:$P,group:QP};function nF(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}var rF=e=>{let{width:t,height:n,x:r,y:i}=HA(e.nodeLookup,{filter:e=>!!e.selected});return{width:lj(t)?t:null,height:lj(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${i}px)`}};function iF({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let r=wN(),{width:i,height:a,transformString:o,userSelectionActive:s}=$(rF,bN),c=RP(),l=(0,H.useRef)(null);(0,H.useEffect)(()=>{n||l.current?.focus({preventScroll:!0})},[n]);let u=!s&&i!==null&&a!==null;if(IP({nodeRef:l,disabled:!u}),!u)return null;let d=e?t=>{e(t,r.getState().nodes.filter(e=>e.selected))}:void 0;return(0,U.jsx)(`div`,{className:Uw([`react-flow__nodesselection`,`react-flow__container`,t]),style:{transform:o},children:(0,U.jsx)(`div`,{ref:l,className:`react-flow__nodesselection-rect`,onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(eF,e.key)&&(e.preventDefault(),c({direction:eF[e.key],factor:e.shiftKey?4:1}))},style:{width:i,height:a}})})}var aF=typeof window<`u`?window:void 0,oF=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function sF({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,paneClickDistance:s,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:u,selectionMode:d,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:m,panActivationKeyCode:h,zoomActivationKeyCode:g,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:b,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:w,autoPanOnSelection:T,defaultViewport:E,translateExtent:D,minZoom:O,maxZoom:k,preventScrolling:A,onSelectionContextMenu:j,noWheelClassName:M,noPanClassName:N,disableKeyboardA11y:P,onViewportChange:F,isControlledViewport:I}){let{nodesSelectionActive:L,userSelectionActive:R}=$(oF,bN),ee=QN(l,{target:aF}),z=QN(h,{target:aF}),B=z||w,te=z||b,V=u&&B!==!0,ne=ee||R||V;return TP({deleteKeyCode:c,multiSelectionKeyCode:m}),(0,U.jsx)(kP,{onPaneContextMenu:a,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:te,panActivationKeyPressed:z,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:!ee&&B,defaultViewport:E,translateExtent:D,minZoom:O,maxZoom:k,zoomActivationKeyCode:g,preventScrolling:A,noWheelClassName:M,noPanClassName:N,onViewportChange:F,isControlledViewport:I,paneClickDistance:s,selectionOnDrag:V,children:(0,U.jsxs)(PP,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,panOnDrag:B,autoPanOnSelection:T,isSelecting:!!ne,selectionMode:d,selectionKeyPressed:ee,paneClickDistance:s,selectionOnDrag:V,children:[e,L&&(0,U.jsx)(iF,{onSelectionContextMenu:j,noPanClassName:N,disableKeyboardA11y:P})]})})}sF.displayName=`FlowRenderer`;var cF=(0,H.memo)(sF),lF=e=>t=>e?UA(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(e=>e.id):Array.from(t.nodeLookup.keys());function uF(e){return $((0,H.useCallback)(lF(e),[e]),bN)}var dF=e=>e.updateNodeInternals;function fF(){let e=$(dF),[t]=(0,H.useState)(()=>typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{let n=new Map;t.forEach(e=>{let t=e.target.getAttribute(`data-id`);n.set(t,{id:t,nodeElement:e.target,force:!0})}),e(n)}));return(0,H.useEffect)(()=>()=>{t?.disconnect()},[t]),t}function pF({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){let i=wN(),a=(0,H.useRef)(null),o=(0,H.useRef)(null),s=(0,H.useRef)(e.sourcePosition),c=(0,H.useRef)(e.targetPosition),l=(0,H.useRef)(t),u=n&&!!e.internals.handleBounds;return(0,H.useEffect)(()=>{a.current&&!e.hidden&&(!u||o.current!==a.current)&&(o.current&&r?.unobserve(o.current),r?.observe(a.current),o.current=a.current)},[u,e.hidden]),(0,H.useEffect)(()=>()=>{o.current&&=(r?.unobserve(o.current),null)},[]),(0,H.useEffect)(()=>{if(a.current){let n=l.current!==t,r=s.current!==e.sourcePosition,o=c.current!==e.targetPosition;(n||r||o)&&(l.current=t,s.current=e.sourcePosition,c.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),a}function mF({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:i,onContextMenu:a,onDoubleClick:o,nodesDraggable:s,elementsSelectable:c,nodesConnectable:l,nodesFocusable:u,resizeObserver:d,noDragClassName:f,noPanClassName:p,disableKeyboardA11y:m,rfId:h,nodeTypes:g,nodeClickDistance:_,onError:v}){let{node:y,internals:b,isParent:x}=$(t=>{let n=t.nodeLookup.get(e),r=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:r}},bN),S=y.type||`default`,C=g?.[S]||tF[S];C===void 0&&(v?.(`003`,EA.error003(S)),S=`default`,C=g?.default||tF.default);let w=!!(y.draggable||s&&y.draggable===void 0),T=!!(y.selectable||c&&y.selectable===void 0),E=!!(y.connectable||l&&y.connectable===void 0),D=!!(y.focusable||u&&y.focusable===void 0),O=wN(),k=xj(y),A=pF({node:y,nodeType:S,hasDimensions:k,resizeObserver:d}),j=IP({nodeRef:A,disabled:y.hidden||!w,noDragClassName:f,handleSelector:y.dragHandle,nodeId:e,isSelectable:T,nodeClickDistance:_}),M=RP();if(y.hidden)return null;let N=bj(y),P=nF(y),F=T||w||t||n||r||i,I=n?e=>n(e,{...b.userNode}):void 0,L=r?e=>r(e,{...b.userNode}):void 0,R=i?e=>i(e,{...b.userNode}):void 0,ee=a?e=>a(e,{...b.userNode}):void 0,z=o?e=>o(e,{...b.userNode}):void 0,B=n=>{let{selectNodesOnDrag:r,nodeDragThreshold:i}=O.getState();T&&(!r||!w||i>0)&&FP({id:e,store:O,nodeRef:A}),t&&t(n,{...b.userNode})},te=t=>{if(!(jj(t.nativeEvent)||m)){if(OA.includes(t.key)&&T){let n=t.key===`Escape`;FP({id:e,store:O,unselect:n,nodeRef:A})}else if(w&&y.selected&&Object.prototype.hasOwnProperty.call(eF,t.key)){t.preventDefault();let{ariaLabelConfig:e}=O.getState();O.setState({ariaLiveMessage:e[`node.a11yDescription.ariaLiveMessage`]({direction:t.key.replace(`Arrow`,``).toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),M({direction:eF[t.key],factor:t.shiftKey?4:1})}}},V=()=>{if(m||!A.current?.matches(`:focus-visible`))return;let{transform:t,width:n,height:r,autoPanOnNodeFocus:i,setCenter:a}=O.getState();i&&(UA(new Map([[e,y]]),{x:0,y:0,width:n,height:r},t,!0).length>0||a(y.position.x+N.width/2,y.position.y+N.height/2,{zoom:t[2]}))};return(0,U.jsx)(`div`,{className:Uw([`react-flow__node`,`react-flow__node-${S}`,{[p]:w},y.className,{selected:y.selected,selectable:T,parent:x,draggable:w,dragging:j}]),ref:A,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:F?`all`:`none`,visibility:k?`visible`:`hidden`,...y.style,...P},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:I,onMouseMove:L,onMouseLeave:R,onContextMenu:ee,onClick:B,onDoubleClick:z,onKeyDown:D?te:void 0,tabIndex:D?0:void 0,onFocus:D?V:void 0,role:y.ariaRole??(D?`group`:void 0),"aria-roledescription":`node`,"aria-describedby":m?void 0:`${DN}-${h}`,"aria-label":y.ariaLabel,...y.domAttributes,children:(0,U.jsx)(BP,{value:e,children:(0,U.jsx)(C,{id:e,data:y.data,type:S,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:y.selected??!1,selectable:T,draggable:w,deletable:y.deletable??!0,isConnectable:E,sourcePosition:y.sourcePosition,targetPosition:y.targetPosition,dragging:j,dragHandle:y.dragHandle,zIndex:b.z,parentId:y.parentId,...N})})})}var hF=(0,H.memo)(mF),gF=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function _F(e){let{nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,onError:i}=$(gF,bN),a=uF(e.onlyRenderVisibleElements),o=fF();return(0,U.jsx)(`div`,{className:`react-flow__nodes`,style:DP,children:a.map(a=>(0,U.jsx)(hF,{id:a,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:o,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:i},a))})}_F.displayName=`NodeRenderer`;var vF=(0,H.memo)(_F);function yF(e){return $((0,H.useCallback)(t=>{if(!e)return t.edges.map(e=>e.id);let n=[];if(t.width&&t.height)for(let e of t.edges){let r=t.nodeLookup.get(e.source),i=t.nodeLookup.get(e.target);r&&i&&Vj({sourceNode:r,targetNode:i,width:t.width,height:t.height,transform:t.transform})&&n.push(e.id)}return n},[e]),bN)}var bF=({color:e=`none`,strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e}};return(0,U.jsx)(`polyline`,{className:`arrow`,style:n,strokeLinecap:`round`,fill:`none`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4`})},xF=({color:e=`none`,strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e,fill:e}};return(0,U.jsx)(`polyline`,{className:`arrowclosed`,style:n,strokeLinecap:`round`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4 -5,-4`})},SF={[FA.Arrow]:bF,[FA.ArrowClosed]:xF};function CF(e){let t=wN();return(0,H.useMemo)(()=>Object.prototype.hasOwnProperty.call(SF,e)?SF[e]:(t.getState().onError?.(`009`,EA.error009(e)),null),[e])}var wF=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:a=`strokeWidth`,strokeWidth:o,orient:s=`auto-start-reverse`})=>{let c=CF(t);return c?(0,U.jsx)(`marker`,{className:`react-flow__arrowhead`,id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:`-10 -10 20 20`,markerUnits:a,orient:s,refX:`0`,refY:`0`,children:(0,U.jsx)(c,{color:n,strokeWidth:o})}):null},TF=({defaultColor:e,rfId:t})=>{let n=$(e=>e.edges),r=$(e=>e.defaultEdgeOptions),i=(0,H.useMemo)(()=>iM(n,{id:t,defaultColor:e,defaultMarkerStart:r?.markerStart,defaultMarkerEnd:r?.markerEnd}),[n,r,t,e]);return i.length?(0,U.jsx)(`svg`,{className:`react-flow__marker`,"aria-hidden":`true`,children:(0,U.jsx)(`defs`,{children:i.map(e=>(0,U.jsx)(wF,{id:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient},e.id))})}):null};TF.displayName=`MarkerDefinitions`;var EF=(0,H.memo)(TF);function DF({x:e,y:t,label:n,labelStyle:r,labelShowBg:i=!0,labelBgStyle:a,labelBgPadding:o=[2,4],labelBgBorderRadius:s=2,children:c,className:l,...u}){let[d,f]=(0,H.useState)({x:1,y:0,width:0,height:0}),p=Uw([`react-flow__edge-textwrapper`,l]),m=(0,H.useRef)(null);return(0,H.useEffect)(()=>{if(m.current){let e=m.current.getBBox();f({x:e.x,y:e.y,width:e.width,height:e.height})}},[n]),n?(0,U.jsxs)(`g`,{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:p,visibility:d.width?`visible`:`hidden`,...u,children:[i&&(0,U.jsx)(`rect`,{width:d.width+2*o[0],x:-o[0],y:-o[1],height:d.height+2*o[1],className:`react-flow__edge-textbg`,style:a,rx:s,ry:s}),(0,U.jsx)(`text`,{className:`react-flow__edge-text`,y:d.height/2,dy:`0.3em`,ref:m,style:r,children:n}),c]}):null}DF.displayName=`EdgeText`;var OF=(0,H.memo)(DF);function kF({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{...u,d:e,fill:`none`,className:Uw([`react-flow__edge-path`,u.className])}),l?(0,U.jsx)(`path`,{d:e,fill:`none`,strokeOpacity:0,strokeWidth:l,className:`react-flow__edge-interaction`}):null,r&&lj(t)&&lj(n)?(0,U.jsx)(OF,{x:t,y:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c}):null]})}function AF({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===Q.Left||e===Q.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function jF({sourceX:e,sourceY:t,sourcePosition:n=Q.Bottom,targetX:r,targetY:i,targetPosition:a=Q.Top}){let[o,s]=AF({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,l]=AF({pos:a,x1:r,y1:i,x2:e,y2:t}),[u,d,f,p]=Fj({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:o,sourceControlY:s,targetControlX:c,targetControlY:l});return[`M${e},${t} C${o},${s} ${c},${l} ${r},${i}`,u,d,f,p]}function MF(e){return(0,H.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o,targetPosition:s,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})=>{let[v,y,b]=jF({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s}),x=e.isInternal?void 0:t;return(0,U.jsx)(kF,{id:x,path:v,labelX:y,labelY:b,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})})}var NF=MF({isInternal:!1}),PF=MF({isInternal:!0});NF.displayName=`SimpleBezierEdge`,PF.displayName=`SimpleBezierEdgeInternal`;function FF(e){return(0,H.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,sourcePosition:p=Q.Bottom,targetPosition:m=Q.Top,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=Zj({sourceX:n,sourceY:r,sourcePosition:p,targetX:i,targetY:a,targetPosition:m,borderRadius:_?.borderRadius,offset:_?.offset,stepPosition:_?.stepPosition}),S=e.isInternal?void 0:t;return(0,U.jsx)(kF,{id:S,path:y,labelX:b,labelY:x,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,interactionWidth:v})})}var IF=FF({isInternal:!1}),LF=FF({isInternal:!0});IF.displayName=`SmoothStepEdge`,LF.displayName=`SmoothStepEdgeInternal`;function RF(e){return(0,H.memo)(({id:t,...n})=>{let r=e.isInternal?void 0:t;return(0,U.jsx)(IF,{...n,id:r,pathOptions:(0,H.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}var zF=RF({isInternal:!1}),BF=RF({isInternal:!0});zF.displayName=`StepEdge`,BF.displayName=`StepEdgeInternal`;function VF(e){return(0,H.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})=>{let[g,_,v]=Gj({sourceX:n,sourceY:r,targetX:i,targetY:a}),y=e.isInternal?void 0:t;return(0,U.jsx)(kF,{id:y,path:g,labelX:_,labelY:v,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})})}var HF=VF({isInternal:!1}),UF=VF({isInternal:!0});HF.displayName=`StraightEdge`,UF.displayName=`StraightEdgeInternal`;function WF(e){return(0,H.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o=Q.Bottom,targetPosition:s=Q.Top,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=Rj({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s,curvature:_?.curvature}),S=e.isInternal?void 0:t;return(0,U.jsx)(kF,{id:S,path:y,labelX:b,labelY:x,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:v})})}var GF=WF({isInternal:!1}),KF=WF({isInternal:!0});GF.displayName=`BezierEdge`,KF.displayName=`BezierEdgeInternal`;var qF={default:KF,straight:UF,step:BF,smoothstep:LF,simplebezier:PF},JF={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},YF=(e,t,n)=>n===Q.Left?e-t:n===Q.Right?e+t:e,XF=(e,t,n)=>n===Q.Top?e-t:n===Q.Bottom?e+t:e,ZF=`react-flow__edgeupdater`;function QF({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:a,onMouseOut:o,type:s}){return(0,U.jsx)(`circle`,{onMouseDown:i,onMouseEnter:a,onMouseOut:o,className:Uw([ZF,`${ZF}-${s}`]),cx:YF(t,r,e),cy:XF(n,r,e),r,stroke:`transparent`,fill:`transparent`})}function $F({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:i,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,onReconnect:l,onReconnectStart:u,onReconnectEnd:d,setReconnecting:f,setUpdateHover:p}){let m=wN(),h=(e,t)=>{if(e.button!==0)return;let{autoPanOnConnect:r,domNode:i,connectionMode:a,connectionRadius:o,lib:s,onConnectStart:c,cancelConnection:p,nodeLookup:h,rfId:g,panBy:_,updateConnection:v}=m.getState(),y=t.type===`target`;RM.onPointerDown(e.nativeEvent,{autoPanOnConnect:r,connectionMode:a,connectionRadius:o,domNode:i,handleId:t.id,nodeId:t.nodeId,nodeLookup:h,isTarget:y,edgeUpdaterType:t.type,lib:s,flowId:g,cancelConnection:p,panBy:_,isValidConnection:(...e)=>m.getState().isValidConnection?.(...e)??!0,onConnect:e=>l?.(n,e),onConnectStart:(r,i)=>{f(!0),u?.(e,n,t.type),c?.(r,i)},onConnectEnd:(...e)=>m.getState().onConnectEnd?.(...e),onReconnectEnd:(e,r)=>{f(!1),d?.(e,n,t.type,r)},updateConnection:v,getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,dragThreshold:m.getState().connectionDragThreshold,handleDomNode:e.currentTarget})},g=e=>h(e,{nodeId:n.target,id:n.targetHandle??null,type:`target`}),_=e=>h(e,{nodeId:n.source,id:n.sourceHandle??null,type:`source`}),v=()=>p(!0),y=()=>p(!1);return(0,U.jsxs)(U.Fragment,{children:[(e===!0||e===`source`)&&(0,U.jsx)(QF,{position:s,centerX:r,centerY:i,radius:t,onMouseDown:g,onMouseEnter:v,onMouseOut:y,type:`source`}),(e===!0||e===`target`)&&(0,U.jsx)(QF,{position:c,centerX:a,centerY:o,radius:t,onMouseDown:_,onMouseEnter:v,onMouseOut:y,type:`target`})]})}function eI({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:i,onDoubleClick:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,rfId:m,edgeTypes:h,noPanClassName:g,onError:_,disableKeyboardA11y:v}){let y=$(t=>t.edgeLookup.get(e)),b=$(e=>e.defaultEdgeOptions);y=b?{...b,...y}:y;let x=y.type||`default`,S=h?.[x]||qF[x];S===void 0&&(_?.(`011`,EA.error011(x)),x=`default`,S=h?.default||qF.default);let C=!!(y.focusable||t&&y.focusable===void 0),w=d!==void 0&&(y.reconnectable||n&&y.reconnectable===void 0),T=!!(y.selectable||r&&y.selectable===void 0),E=(0,H.useRef)(null),[D,O]=(0,H.useState)(!1),[k,A]=(0,H.useState)(!1),j=wN(),{zIndex:M=y.zIndex,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R}=$((0,H.useCallback)(t=>{let n=t.nodeLookup.get(y.source),r=t.nodeLookup.get(y.target);if(!n||!r)return JF;let i=$j({id:e,sourceNode:n,targetNode:r,sourceHandle:y.sourceHandle||null,targetHandle:y.targetHandle||null,connectionMode:t.connectionMode,onError:_}),a=Bj({selected:y.selected,zIndex:y.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect,zIndexMode:t.zIndexMode});return{...i||JF,zIndex:a}},[y.source,y.target,y.sourceHandle,y.targetHandle,y.selected,y.zIndex,_]),bN),ee=(0,H.useMemo)(()=>y.markerStart?`url('#${rM(y.markerStart,m)}')`:void 0,[y.markerStart,m]),z=(0,H.useMemo)(()=>y.markerEnd?`url('#${rM(y.markerEnd,m)}')`:void 0,[y.markerEnd,m]);if(y.hidden||N===null||P===null||F===null||I===null)return null;let B=t=>{let{addSelectedEdges:n,unselectNodesAndEdges:r,multiSelectionActive:a}=j.getState();T&&(j.setState({nodesSelectionActive:!1}),y.selected&&a?(r({nodes:[],edges:[y]}),E.current?.blur()):n([e])),i&&i(t,y)},te=a?e=>{a(e,{...y})}:void 0,V=o?e=>{o(e,{...y})}:void 0,ne=s?e=>{s(e,{...y})}:void 0,re=c?e=>{c(e,{...y})}:void 0,ie=l?e=>{l(e,{...y})}:void 0;return(0,U.jsx)(`svg`,{style:{zIndex:M},children:(0,U.jsxs)(`g`,{className:Uw([`react-flow__edge`,`react-flow__edge-${x}`,y.className,g,{selected:y.selected,animated:y.animated,inactive:!T&&!i,updating:D,selectable:T}]),onClick:B,onDoubleClick:te,onContextMenu:V,onMouseEnter:ne,onMouseMove:re,onMouseLeave:ie,onKeyDown:C?t=>{if(!v&&OA.includes(t.key)&&T){let{unselectNodesAndEdges:n,addSelectedEdges:r}=j.getState();t.key===`Escape`?(E.current?.blur(),n({edges:[y]})):r([e])}}:void 0,tabIndex:C?0:void 0,role:y.ariaRole??(C?`group`:`img`),"aria-roledescription":`edge`,"data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":y.ariaLabel===null?void 0:y.ariaLabel||`Edge from ${y.source} to ${y.target}`,"aria-describedby":C?`${ON}-${m}`:void 0,ref:E,...y.domAttributes,children:[!k&&(0,U.jsx)(S,{id:e,source:y.source,target:y.target,type:y.type,selected:y.selected,animated:y.animated,selectable:T,deletable:y.deletable??!0,label:y.label,labelStyle:y.labelStyle,labelShowBg:y.labelShowBg,labelBgStyle:y.labelBgStyle,labelBgPadding:y.labelBgPadding,labelBgBorderRadius:y.labelBgBorderRadius,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R,data:y.data,style:y.style,sourceHandleId:y.sourceHandle,targetHandleId:y.targetHandle,markerStart:ee,markerEnd:z,pathOptions:`pathOptions`in y?y.pathOptions:void 0,interactionWidth:y.interactionWidth}),w&&(0,U.jsx)($F,{edge:y,isReconnectable:w,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R,setUpdateHover:O,setReconnecting:A})]})})}var tI=(0,H.memo)(eI),nI=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function rI({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:i,onReconnect:a,onEdgeContextMenu:o,onEdgeMouseEnter:s,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,reconnectRadius:d,onEdgeDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,disableKeyboardA11y:h}){let{edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,onError:y}=$(nI,bN),b=yF(t);return(0,U.jsxs)(`div`,{className:`react-flow__edges`,children:[(0,U.jsx)(EF,{defaultColor:e,rfId:n}),b.map(e=>(0,U.jsx)(tI,{id:e,edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,noPanClassName:i,onReconnect:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,onClick:u,reconnectRadius:d,onDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,rfId:n,onError:y,edgeTypes:r,disableKeyboardA11y:h},e))]})}rI.displayName=`EdgeRenderer`;var iI=(0,H.memo)(rI),aI=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function oI({children:e}){let t=wN(),n=(0,H.useRef)(null),[r]=(0,H.useState)(()=>t.getState().transform);return hP(()=>{let e=null,r=()=>{let r=t.getState().transform;e&&r[0]===e[0]&&r[1]===e[1]&&r[2]===e[2]||(e=r,n.current&&(n.current.style.transform=aI(r)))};return r(),t.subscribe(r)},[t]),(0,U.jsx)(`div`,{ref:n,className:`react-flow__viewport xyflow__viewport react-flow__container`,style:{transform:aI(r)},children:e})}function sI(e){let t=SP(),n=(0,H.useRef)(!1);(0,H.useEffect)(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}var cI=e=>e.panZoom?.syncViewport;function lI(e){let t=$(cI),n=wN();return(0,H.useEffect)(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function uI(e){return e.connection.inProgress?{...e.connection,to:fj(e.connection.to,e.transform)}:{...e.connection}}function dI(e){return e?t=>e(uI(t)):uI}function fI(e){return $(dI(e),bN)}var pI=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function mI({containerStyle:e,style:t,type:n,component:r}){let{nodesConnectable:i,width:a,height:o,isValid:s,inProgress:c}=$(pI,bN);return a&&i&&c?(0,U.jsx)(`svg`,{style:e,width:a,height:o,className:`react-flow__connectionline react-flow__container`,children:(0,U.jsx)(`g`,{className:Uw([`react-flow__connection`,Ej(s)]),children:(0,U.jsx)(hI,{style:t,type:n,CustomComponent:r,isValid:s})})}):null}var hI=({style:e,type:t=PA.Bezier,CustomComponent:n,isValid:r})=>{let{inProgress:i,from:a,fromNode:o,fromHandle:s,fromPosition:c,to:l,toNode:u,toHandle:d,toPosition:f,pointer:p}=fI();if(!i)return;if(n)return(0,U.jsx)(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:s,fromX:a.x,fromY:a.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:f,connectionStatus:Ej(r),toNode:u,toHandle:d,pointer:p});let m=``,h={sourceX:a.x,sourceY:a.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:f};switch(t){case PA.Bezier:[m]=Rj(h);break;case PA.SimpleBezier:[m]=jF(h);break;case PA.Step:[m]=Zj({...h,borderRadius:0});break;case PA.SmoothStep:[m]=Zj(h);break;default:[m]=Gj(h)}return(0,U.jsx)(`path`,{d:m,fill:`none`,className:`react-flow__connection-path`,style:e})};hI.displayName=`ConnectionLine`;var gI={};function _I(e=gI){(0,H.useRef)(e),wN(),(0,H.useEffect)(()=>{},[e])}function vI(){wN(),(0,H.useRef)(!1),(0,H.useEffect)(()=>{},[])}function yI({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:i,onNodeDoubleClick:a,onEdgeDoubleClick:o,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,onSelectionContextMenu:d,onSelectionStart:f,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:h,connectionLineComponent:g,connectionLineContainerStyle:_,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,deleteKeyCode:w,onlyRenderVisibleElements:T,elementsSelectable:E,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,preventScrolling:j,defaultMarkerColor:M,zoomOnScroll:N,zoomOnPinch:P,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,zoomOnDoubleClick:R,panOnDrag:ee,autoPanOnSelection:z,onPaneClick:B,onPaneMouseEnter:te,onPaneMouseMove:V,onPaneMouseLeave:ne,onPaneScroll:re,onPaneContextMenu:ie,paneClickDistance:ae,nodeClickDistance:oe,onEdgeContextMenu:se,onEdgeMouseEnter:ce,onEdgeMouseMove:le,onEdgeMouseLeave:ue,reconnectRadius:de,onReconnect:fe,onReconnectStart:pe,onReconnectEnd:me,noDragClassName:he,noWheelClassName:ge,noPanClassName:_e,disableKeyboardA11y:ve,nodeExtent:ye,rfId:be,viewport:xe,onViewportChange:Se,nodesDraggable:Ce}){return _I(e),_I(t),vI(),sI(n),lI(xe),(0,U.jsx)(cF,{onPaneClick:B,onPaneMouseEnter:te,onPaneMouseMove:V,onPaneMouseLeave:ne,onPaneContextMenu:ie,onPaneScroll:re,paneClickDistance:ae,deleteKeyCode:w,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,elementsSelectable:E,zoomOnScroll:N,zoomOnPinch:P,zoomOnDoubleClick:R,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,panOnDrag:ee,autoPanOnSelection:z,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,onSelectionContextMenu:d,preventScrolling:j,noDragClassName:he,noWheelClassName:ge,noPanClassName:_e,disableKeyboardA11y:ve,onViewportChange:Se,isControlledViewport:!!xe,children:(0,U.jsxs)(oI,{children:[(0,U.jsx)(iI,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:o,onReconnect:fe,onReconnectStart:pe,onReconnectEnd:me,onlyRenderVisibleElements:T,onEdgeContextMenu:se,onEdgeMouseEnter:ce,onEdgeMouseMove:le,onEdgeMouseLeave:ue,reconnectRadius:de,defaultMarkerColor:M,noPanClassName:_e,disableKeyboardA11y:ve,rfId:be}),(0,U.jsx)(mI,{style:h,type:m,component:g,containerStyle:_}),(0,U.jsx)(`div`,{className:`react-flow__edgelabel-renderer`}),(0,U.jsx)(vF,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:a,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,nodeClickDistance:oe,onlyRenderVisibleElements:T,noPanClassName:_e,noDragClassName:he,disableKeyboardA11y:ve,nodeExtent:ye,rfId:be,nodesDraggable:Ce}),(0,U.jsx)(`div`,{className:`react-flow__viewport-portal`})]})})}yI.displayName=`GraphView`;var bI=(0,H.memo)(yI),xI=uj(`React Flow`,`https://reactflow.dev/`),SI=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c=.5,maxZoom:l=2,nodeOrigin:u,nodeExtent:d,zIndexMode:f=`basic`}={})=>{let p=new Map,m=new Map,h=new Map,g=new Map,_=r??t??[],v=n??e??[],y=u??[0,0],b=d??DA;SM(h,g,_);let{nodesInitialized:x}=pM(v,p,m,{nodeOrigin:y,nodeExtent:b,zIndexMode:f}),S=[0,0,1];if(o&&i&&a){let{x:e,y:t,zoom:n}=_j(HA(p,{filter:e=>!!((e.width||e.initialWidth)&&(e.height||e.initialHeight))}),i,a,c,l,s?.padding??.1);S=[e,t,n]}return{rfId:`1`,width:i??0,height:a??0,transform:S,nodes:v,nodesInitialized:x,nodeLookup:p,parentLookup:m,edges:_,edgeLookup:g,connectionLookup:h,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:DA,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:AA.Strict,domNode:null,paneDragging:!1,noPanClassName:`nopan`,nodeOrigin:y,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:o??!1,fitViewOptions:s,fitViewResolver:null,connection:{...NA},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:``,autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:xI,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:`react`,debug:!1,ariaLabelConfig:kA,zIndexMode:f,defaultEdgeOptions:void 0,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map,onNodesDelete:void 0,onEdgesDelete:void 0,onDelete:void 0,onBeforeDelete:void 0,onViewportChangeStart:void 0,onViewportChange:void 0,onViewportChangeEnd:void 0,onNodeDragStart:void 0,onNodeDrag:void 0,onNodeDragStop:void 0,onSelectionDragStart:void 0,onSelectionDrag:void 0,onSelectionDragStop:void 0,onMoveStart:void 0,onMove:void 0,onMoveEnd:void 0,onConnect:void 0,onConnectStart:void 0,onConnectEnd:void 0,onClickConnectStart:void 0,onClickConnectEnd:void 0}},CI=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f})=>yN((p,m)=>{async function h(){let{nodeLookup:e,panZoom:t,fitViewOptions:n,fitViewResolver:r,width:i,height:a,minZoom:o,maxZoom:s}=m();t&&(await KA({nodes:e,width:i,height:a,panZoom:t,minZoom:o,maxZoom:s},n),r?.resolve(!0),p({fitViewResolver:null}))}return{...SI({nodes:e,edges:t,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:e=>{let{nodeLookup:t,parentLookup:n,nodeOrigin:r,nodeExtent:i,elevateNodesOnSelect:a,fitViewQueued:o,zIndexMode:s,nodesSelectionActive:c}=m(),{nodesInitialized:l,hasSelectedNodes:u}=pM(e,t,n,{nodeOrigin:r,nodeExtent:i,elevateNodesOnSelect:a,checkEquality:!0,zIndexMode:s}),d=c&&u;o&&l?(h(),p({nodes:e,nodesInitialized:l,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:d})):p({nodes:e,nodesInitialized:l,nodesSelectionActive:d})},setEdges:e=>{let{connectionLookup:t,edgeLookup:n}=m();SM(t,n,e),p({edges:e})},setDefaultNodesAndEdges:(e,t)=>{if(e){let{setNodes:t}=m();t(e),p({hasDefaultNodes:!0})}if(t){let{setEdges:e}=m();e(t),p({hasDefaultEdges:!0})}},updateNodeInternals:e=>{let{triggerNodeChanges:t,nodeLookup:n,parentLookup:r,domNode:i,nodeOrigin:a,nodeExtent:o,debug:s,fitViewQueued:c,zIndexMode:l}=m(),{changes:u,updatedInternals:d}=yM(e,n,r,i,a,o,l);d&&(uM(n,r,{nodeOrigin:a,nodeExtent:o,zIndexMode:l}),c?(h(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),u?.length>0&&(s&&console.log(`React Flow: trigger node changes`,u),t?.(u)))},updateNodePositions:(e,t=!1)=>{let n=[],r=[],{nodeLookup:i,triggerNodeChanges:a,connection:o,updateConnection:s,onNodesChangeMiddlewareMap:c}=m();for(let[a,c]of e){let e=i.get(a),l=!!(e?.expandParent&&e?.parentId&&c?.position),u={id:a,type:`position`,position:l?{x:Math.max(0,c.position.x),y:Math.max(0,c.position.y)}:c.position,dragging:t};if(e&&o.inProgress&&o.fromNode.id===e.id){let t=tM(e,o.fromHandle,Q.Left,!0);s({...o,from:t})}l&&e.parentId&&n.push({id:a,parentId:e.parentId,rect:{...c.internals.positionAbsolute,width:c.measured.width??0,height:c.measured.height??0}}),r.push(u)}if(n.length>0){let{parentLookup:e,nodeOrigin:t}=m(),a=vM(n,i,e,t);r.push(...a)}for(let e of c.values())r=e(r);a(r)},triggerNodeChanges:e=>{let{onNodesChange:t,setNodes:n,nodes:r,hasDefaultNodes:i,debug:a}=m();e?.length&&(i&&n(iP(e,r)),a&&console.log(`React Flow: trigger node changes`,e),t?.(e))},triggerEdgeChanges:e=>{let{onEdgesChange:t,setEdges:n,edges:r,hasDefaultEdges:i,debug:a}=m();e?.length&&(i&&n(aP(e,r)),a&&console.log(`React Flow: trigger edge changes`,e),t?.(e))},addSelectedNodes:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){i(e.map(e=>oP(e,!0)));return}i(sP(r,new Set([...e]),!0)),a(sP(n))},addSelectedEdges:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){a(e.map(e=>oP(e,!0)));return}a(sP(n,new Set([...e]))),i(sP(r,new Set,!0))},unselectNodesAndEdges:({nodes:e,edges:t}={})=>{let{edges:n,nodes:r,nodeLookup:i,triggerNodeChanges:a,triggerEdgeChanges:o}=m(),s=e||r,c=t||n,l=[];for(let e of s){if(!e.selected)continue;let t=i.get(e.id);t&&(t.selected=!1),l.push(oP(e.id,!1))}let u=[];for(let e of c)e.selected&&u.push(oP(e.id,!1));a(l),o(u)},setMinZoom:e=>{let{panZoom:t,maxZoom:n}=m();t?.setScaleExtent([e,n]),p({minZoom:e})},setMaxZoom:e=>{let{panZoom:t,minZoom:n}=m();t?.setScaleExtent([n,e]),p({maxZoom:e})},setTranslateExtent:e=>{m().panZoom?.setTranslateExtent(e),p({translateExtent:e})},resetSelectedElements:()=>{let{edges:e,nodes:t,triggerNodeChanges:n,triggerEdgeChanges:r,elementsSelectable:i}=m();if(!i)return;let a=t.reduce((e,t)=>t.selected?[...e,oP(t.id,!1)]:e,[]),o=e.reduce((e,t)=>t.selected?[...e,oP(t.id,!1)]:e,[]);n(a),r(o)},setNodeExtent:e=>{let{nodes:t,nodeLookup:n,parentLookup:r,nodeOrigin:i,elevateNodesOnSelect:a,nodeExtent:o,zIndexMode:s}=m();(e[0][0]!==o[0][0]||e[0][1]!==o[0][1]||e[1][0]!==o[1][0]||e[1][1]!==o[1][1])&&(pM(t,n,r,{nodeOrigin:i,nodeExtent:e,elevateNodesOnSelect:a,checkEquality:!1,zIndexMode:s}),p({nodeExtent:e}))},panBy:e=>{let{transform:t,width:n,height:r,panZoom:i,translateExtent:a}=m();return bM({delta:e,panZoom:i,transform:t,translateExtent:a,width:n,height:r})},setCenter:async(e,t,n)=>{let{width:r,height:i,maxZoom:a,panZoom:o}=m();if(!o)return!1;let s=n?.zoom===void 0?a:n.zoom;return await o.setViewport({x:r/2-e*s,y:i/2-t*s,zoom:s},{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0},cancelConnection:()=>{p({connection:{...NA}})},updateConnection:e=>{p({connection:e})},reset:()=>p({...SI()})}},Object.is);function wI({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:i,initialHeight:a,initialMinZoom:o,initialMaxZoom:s,initialFitViewOptions:c,fitView:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f,children:p}){let[m]=(0,H.useState)(()=>CI({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:l,minZoom:o,maxZoom:s,fitViewOptions:c,nodeOrigin:u,nodeExtent:d,zIndexMode:f}));return(0,U.jsx)(SN,{value:m,children:(0,U.jsx)(yP,{children:(0,U.jsx)(WP,{children:p})})})}function TI({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:i,width:a,height:o,fitView:s,fitViewOptions:c,minZoom:l,maxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p}){return(0,H.useContext)(xN)?(0,U.jsx)(U.Fragment,{children:e}):(0,U.jsx)(wI,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:i,initialWidth:a,initialHeight:o,fitView:s,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p,children:e})}var EI={width:`100%`,height:`100%`,overflow:`hidden`,position:`relative`,zIndex:0};function DI({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:a,edgeTypes:o,onNodeClick:s,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:d,onMoveEnd:f,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onSelectionChange:k,onSelectionDragStart:A,onSelectionDrag:j,onSelectionDragStop:M,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:F,onBeforeDelete:I,connectionMode:L,connectionLineType:R=PA.Bezier,connectionLineStyle:ee,connectionLineComponent:z,connectionLineContainerStyle:B,deleteKeyCode:te=`Backspace`,selectionKeyCode:V=`Shift`,selectionOnDrag:ne=!1,selectionMode:re=MA.Full,panActivationKeyCode:ie=`Space`,multiSelectionKeyCode:ae=vj()?`Meta`:`Control`,zoomActivationKeyCode:oe=vj()?`Meta`:`Control`,snapToGrid:se,snapGrid:ce,onlyRenderVisibleElements:le=!1,selectNodesOnDrag:ue,nodesDraggable:de,autoPanOnNodeFocus:fe,nodesConnectable:pe,nodesFocusable:me,nodeOrigin:he=UN,edgesFocusable:ge,edgesReconnectable:_e,elementsSelectable:ve=!0,defaultViewport:ye=WN,minZoom:be=.5,maxZoom:xe=2,translateExtent:Se=DA,preventScrolling:Ce=!0,nodeExtent:we,defaultMarkerColor:Te=`#b1b1b7`,zoomOnScroll:Ee=!0,zoomOnPinch:De=!0,panOnScroll:Oe=!1,panOnScrollSpeed:ke=.5,panOnScrollMode:Ae=jA.Free,zoomOnDoubleClick:je=!0,panOnDrag:Me=!0,onPaneClick:Ne,onPaneMouseEnter:Pe,onPaneMouseMove:Fe,onPaneMouseLeave:Ie,onPaneScroll:Le,onPaneContextMenu:Re,paneClickDistance:ze=1,nodeClickDistance:Be=0,children:Ve,onReconnect:He,onReconnectStart:Ue,onReconnectEnd:We,onEdgeContextMenu:Ge,onEdgeDoubleClick:Ke,onEdgeMouseEnter:qe,onEdgeMouseMove:Je,onEdgeMouseLeave:Ye,reconnectRadius:Xe=10,onNodesChange:Ze,onEdgesChange:Qe,noDragClassName:$e=`nodrag`,noWheelClassName:et=`nowheel`,noPanClassName:tt=`nopan`,fitView:nt,fitViewOptions:rt,connectOnClick:it,attributionPosition:at,proOptions:ot,defaultEdgeOptions:st,elevateNodesOnSelect:ct=!0,elevateEdgesOnSelect:lt=!1,disableKeyboardA11y:ut=!1,autoPanOnConnect:dt,autoPanOnNodeDrag:ft,autoPanOnSelection:pt=!0,autoPanSpeed:mt,connectionRadius:ht,isValidConnection:gt,onError:_t,style:vt,id:yt,nodeDragThreshold:bt,connectionDragThreshold:xt,viewport:St,onViewportChange:Ct,width:wt,height:Tt,colorMode:Et=`light`,debug:Dt,onScroll:Ot,ariaLabelConfig:kt,zIndexMode:At=`basic`,...jt},Mt){let Nt=yt||`1`,Pt=XN(Et),Ft=(0,H.useCallback)(e=>{e.currentTarget.scrollTo({top:0,left:0,behavior:`instant`}),Ot?.(e)},[Ot]);return(0,U.jsx)(`div`,{"data-testid":`rf__wrapper`,...jt,onScroll:Ft,style:{...vt,...EI},ref:Mt,className:Uw([`react-flow`,i,Pt]),id:yt,role:`application`,children:(0,U.jsxs)(TI,{nodes:e,edges:t,width:wt,height:Tt,fitView:nt,fitViewOptions:rt,minZoom:be,maxZoom:xe,nodeOrigin:he,nodeExtent:we,zIndexMode:At,children:[(0,U.jsx)(JN,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,nodesDraggable:de,autoPanOnNodeFocus:fe,nodesConnectable:pe,nodesFocusable:me,edgesFocusable:ge,edgesReconnectable:_e,elementsSelectable:ve,elevateNodesOnSelect:ct,elevateEdgesOnSelect:lt,minZoom:be,maxZoom:xe,nodeExtent:we,onNodesChange:Ze,onEdgesChange:Qe,snapToGrid:se,snapGrid:ce,connectionMode:L,translateExtent:Se,connectOnClick:it,defaultEdgeOptions:st,fitView:nt,fitViewOptions:rt,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onSelectionDrag:j,onSelectionDragStart:A,onSelectionDragStop:M,onMove:u,onMoveStart:d,onMoveEnd:f,noPanClassName:tt,nodeOrigin:he,rfId:Nt,autoPanOnConnect:dt,autoPanOnNodeDrag:ft,autoPanSpeed:mt,onError:_t,connectionRadius:ht,isValidConnection:gt,selectNodesOnDrag:ue,nodeDragThreshold:bt,connectionDragThreshold:xt,onBeforeDelete:I,debug:Dt,ariaLabelConfig:kt,zIndexMode:At}),(0,U.jsx)(bI,{onInit:l,onNodeClick:s,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,nodeTypes:a,edgeTypes:o,connectionLineType:R,connectionLineStyle:ee,connectionLineComponent:z,connectionLineContainerStyle:B,selectionKeyCode:V,selectionOnDrag:ne,selectionMode:re,deleteKeyCode:te,multiSelectionKeyCode:ae,panActivationKeyCode:ie,zoomActivationKeyCode:oe,onlyRenderVisibleElements:le,defaultViewport:ye,translateExtent:Se,minZoom:be,maxZoom:xe,preventScrolling:Ce,zoomOnScroll:Ee,zoomOnPinch:De,zoomOnDoubleClick:je,panOnScroll:Oe,panOnScrollSpeed:ke,panOnScrollMode:Ae,panOnDrag:Me,autoPanOnSelection:pt,onPaneClick:Ne,onPaneMouseEnter:Pe,onPaneMouseMove:Fe,onPaneMouseLeave:Ie,onPaneScroll:Le,onPaneContextMenu:Re,paneClickDistance:ze,nodeClickDistance:Be,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:F,onReconnect:He,onReconnectStart:Ue,onReconnectEnd:We,onEdgeContextMenu:Ge,onEdgeDoubleClick:Ke,onEdgeMouseEnter:qe,onEdgeMouseMove:Je,onEdgeMouseLeave:Ye,reconnectRadius:Xe,defaultMarkerColor:Te,noDragClassName:$e,noWheelClassName:et,noPanClassName:tt,rfId:Nt,disableKeyboardA11y:ut,nodeExtent:we,viewport:St,onViewportChange:Ct,nodesDraggable:de}),(0,U.jsx)(HN,{onSelectionChange:k}),Ve,(0,U.jsx)(IN,{proOptions:ot,position:at}),(0,U.jsx)(NN,{rfId:Nt,disableKeyboardA11y:ut})]})})}var OI=mP(DI);EA.error014();function kI({dimensions:e,lineWidth:t,variant:n,className:r}){return(0,U.jsx)(`path`,{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Uw([`react-flow__background-pattern`,n,r])})}function AI({radius:e,className:t}){return(0,U.jsx)(`circle`,{cx:e,cy:e,r:e,className:Uw([`react-flow__background-pattern`,`dots`,t])})}var jI;(function(e){e.Lines=`lines`,e.Dots=`dots`,e.Cross=`cross`})(jI||={});var MI={[jI.Dots]:1,[jI.Lines]:1,[jI.Cross]:6},NI=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function PI({id:e,variant:t=jI.Dots,gap:n=20,size:r,lineWidth:i=1,offset:a=0,color:o,bgColor:s,style:c,className:l,patternClassName:u}){let d=(0,H.useRef)(null),{transform:f,patternId:p}=$(NI,bN),m=r||MI[t],h=t===jI.Dots,g=t===jI.Cross,_=Array.isArray(n)?n:[n,n],v=[_[0]*f[2]||1,_[1]*f[2]||1],y=m*f[2],b=Array.isArray(a)?a:[a,a],x=g?[y,y]:v,S=[b[0]*f[2]+x[0]/2,b[1]*f[2]+x[1]/2],C=`${p}${e||``}`;return(0,U.jsxs)(`svg`,{className:Uw([`react-flow__background`,l]),style:{...c,...DP,"--xy-background-color-props":s,"--xy-background-pattern-color-props":o},ref:d,"data-testid":`rf__background`,children:[(0,U.jsx)(`pattern`,{id:C,x:f[0]%v[0],y:f[1]%v[1],width:v[0],height:v[1],patternUnits:`userSpaceOnUse`,patternTransform:`translate(-${S[0]},-${S[1]})`,children:h?(0,U.jsx)(AI,{radius:y/2,className:u}):(0,U.jsx)(kI,{dimensions:x,lineWidth:i,variant:t,className:u})}),(0,U.jsx)(`rect`,{x:`0`,y:`0`,width:`100%`,height:`100%`,fill:`url(#${C})`})]})}PI.displayName=`Background`;var FI=(0,H.memo)(PI);function II(){return(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,children:(0,U.jsx)(`path`,{d:`M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z`})})}function LI(){return(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 5`,children:(0,U.jsx)(`path`,{d:`M0 0h32v4.2H0z`})})}function RI(){return(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 30`,children:(0,U.jsx)(`path`,{d:`M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z`})})}function zI(){return(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,U.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z`})})}function BI(){return(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,U.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z`})})}function VI({children:e,className:t,...n}){return(0,U.jsx)(`button`,{type:`button`,className:Uw([`react-flow__controls-button`,t]),...n,children:e})}var HI=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function UI({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:a,onZoomOut:o,onFitView:s,onInteractiveChange:c,className:l,children:u,position:d=`bottom-left`,orientation:f=`vertical`,"aria-label":p}){let m=wN(),{isInteractive:h,minZoomReached:g,maxZoomReached:_,ariaLabelConfig:v}=$(HI,bN),{zoomIn:y,zoomOut:b,fitView:x}=SP();return(0,U.jsxs)(PN,{className:Uw([`react-flow__controls`,f===`horizontal`?`horizontal`:`vertical`,l]),position:d,style:e,"data-testid":`rf__controls`,"aria-label":p??v[`controls.ariaLabel`],children:[t&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(VI,{onClick:()=>{y(),a?.()},className:`react-flow__controls-zoomin`,title:v[`controls.zoomIn.ariaLabel`],"aria-label":v[`controls.zoomIn.ariaLabel`],disabled:_,children:(0,U.jsx)(II,{})}),(0,U.jsx)(VI,{onClick:()=>{b(),o?.()},className:`react-flow__controls-zoomout`,title:v[`controls.zoomOut.ariaLabel`],"aria-label":v[`controls.zoomOut.ariaLabel`],disabled:g,children:(0,U.jsx)(LI,{})})]}),n&&(0,U.jsx)(VI,{className:`react-flow__controls-fitview`,onClick:()=>{x(i),s?.()},title:v[`controls.fitView.ariaLabel`],"aria-label":v[`controls.fitView.ariaLabel`],children:(0,U.jsx)(RI,{})}),r&&(0,U.jsx)(VI,{className:`react-flow__controls-interactive`,onClick:()=>{m.setState({nodesDraggable:!h,nodesConnectable:!h,elementsSelectable:!h}),c?.(!h)},title:v[`controls.interactive.ariaLabel`],"aria-label":v[`controls.interactive.ariaLabel`],children:h?(0,U.jsx)(BI,{}):(0,U.jsx)(zI,{})}),u]})}UI.displayName=`Controls`;var WI=(0,H.memo)(UI);function GI({id:e,x:t,y:n,width:r,height:i,style:a,color:o,strokeColor:s,strokeWidth:c,className:l,borderRadius:u,shapeRendering:d,selected:f,onClick:p}){let{background:m,backgroundColor:h}=a||{},g=o||m||h;return(0,U.jsx)(`rect`,{className:Uw([`react-flow__minimap-node`,{selected:f},l]),x:t,y:n,rx:u,ry:u,width:r,height:i,style:{fill:g,stroke:s,strokeWidth:c},shapeRendering:d,onClick:p?t=>p(t,e):void 0})}var KI=(0,H.memo)(GI),qI=e=>e.nodes.map(e=>e.id),JI=e=>e instanceof Function?e:()=>e;function YI({nodeStrokeColor:e,nodeColor:t,nodeClassName:n=``,nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:a=KI,onClick:o}){let s=$(qI,bN),c=JI(t),l=JI(e),u=JI(n),d=typeof window>`u`||window.chrome?`crispEdges`:`geometricPrecision`;return(0,U.jsx)(U.Fragment,{children:s.map(e=>(0,U.jsx)(ZI,{id:e,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:a,onClick:o,shapeRendering:d},e))})}function XI({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:i,nodeStrokeWidth:a,shapeRendering:o,NodeComponent:s,onClick:c}){let{node:l,x:u,y:d,width:f,height:p}=$(t=>{let n=t.nodeLookup.get(e);if(!n)return{node:void 0,x:0,y:0,width:0,height:0};let r=n.internals.userNode,{x:i,y:a}=n.internals.positionAbsolute,{width:o,height:s}=bj(r);return{node:r,x:i,y:a,width:o,height:s}},bN);return!l||l.hidden||!xj(l)?null:(0,U.jsx)(s,{x:u,y:d,width:f,height:p,style:l.style,selected:!!l.selected,className:r(l),color:t(l),borderRadius:i,strokeColor:n(l),strokeWidth:a,shapeRendering:o,onClick:c,id:l.id})}var ZI=(0,H.memo)(XI),QI=(0,H.memo)(YI),$I=200,eL=150,tL=e=>!e.hidden,nL=e=>{let t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]},n=!1;for(let t of e.nodeLookup.values())if(!t.hidden){n=!0;break}return{viewBB:t,boundingRect:n?aj(HA(e.nodeLookup,{filter:tL}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},rL=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,iL=(e,t)=>rL(e.viewBB,t.viewBB)&&rL(e.boundingRect,t.boundingRect)&&e.rfId===t.rfId&&e.panZoom===t.panZoom&&e.translateExtent===t.translateExtent&&e.flowWidth===t.flowWidth&&e.flowHeight===t.flowHeight&&e.ariaLabelConfig===t.ariaLabelConfig,aL=`react-flow__minimap-desc`;function oL({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:i=``,nodeBorderRadius:a=5,nodeStrokeWidth:o,nodeComponent:s,bgColor:c,maskColor:l,maskStrokeColor:u,maskStrokeWidth:d,position:f=`bottom-right`,onClick:p,onNodeClick:m,pannable:h=!1,zoomable:g=!1,ariaLabel:_,inversePan:v,zoomStep:y=1,offsetScale:b=5}){let x=wN(),S=(0,H.useRef)(null),{boundingRect:C,panZoom:w,viewBB:T,rfId:E,translateExtent:D,flowWidth:O,flowHeight:k,ariaLabelConfig:A}=$(nL,iL),j=e?.width??$I,M=e?.height??eL,N=C.width/j,P=C.height/M,F=Math.max(N,P),I=F*j,L=F*M,R=b*F,ee=C.x-(I-C.width)/2-R,z=C.y-(L-C.height)/2-R,B=I+R*2,te=L+R*2,V=`${aL}-${E}`,ne=(0,H.useRef)(0),re=(0,H.useRef)();ne.current=F,(0,H.useEffect)(()=>{let e=x.getState().panZoom;if(S.current&&e)return re.current=zM({domNode:S.current,panZoom:e,getTransform:()=>x.getState().transform,getViewScale:()=>ne.current}),()=>{re.current?.destroy()}},[w]),(0,H.useEffect)(()=>{re.current?.update({translateExtent:D,width:O,height:k,inversePan:v,pannable:h,zoomStep:y,zoomable:g})},[h,g,v,y,D,O,k]);let ie=p?e=>{let[t,n]=re.current?.pointer(e)||[0,0];p(e,{x:t,y:n})}:void 0,ae=(0,H.useCallback)((e,t)=>{let n=x.getState().nodeLookup.get(t).internals.userNode;m?.(e,n)},[m]),oe=m?ae:void 0,se=_??A[`minimap.ariaLabel`];return(0,U.jsx)(PN,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c==`string`?c:void 0,"--xy-minimap-mask-background-color-props":typeof l==`string`?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof u==`string`?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof d==`number`?d*F:void 0,"--xy-minimap-node-background-color-props":typeof r==`string`?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n==`string`?n:void 0,"--xy-minimap-node-stroke-width-props":typeof o==`number`?o:void 0},className:Uw([`react-flow__minimap`,t]),"data-testid":`rf__minimap`,children:(0,U.jsxs)(`svg`,{width:j,height:M,viewBox:`${ee} ${z} ${B} ${te}`,className:`react-flow__minimap-svg`,role:`img`,"aria-labelledby":V,ref:S,onClick:ie,children:[se&&(0,U.jsx)(`title`,{id:V,children:se}),(0,U.jsx)(QI,{onClick:oe,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:i,nodeStrokeWidth:o,nodeComponent:s}),(0,U.jsx)(`path`,{className:`react-flow__minimap-mask`,d:`M${ee-R},${z-R}h${B+R*2}v${te+R*2}h${-B-R*2}z
|
|
146
|
-
M${T.x},${T.y}h${T.width}v${T.height}h${-T.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}
|
|
145
|
+
`));return[t,t.reduce((e,t)=>e.concat(...t),[])]}return[[],[]]},[e]);return(0,H.useEffect)(()=>{let n=t?.target??oP,c=t?.actInsideInputWithModifier??!0;if(e!==null){let e=e=>{if(i.current=e.ctrlKey||e.metaKey||e.shiftKey||e.altKey,(!i.current||i.current&&!c)&&Bj(e))return!1;let n=lP(e.code,s);if(a.current.add(e[n]),cP(o,a.current,!1)){let n=e.composedPath?.()?.[0]||e.target,a=n?.nodeName===`BUTTON`||n?.nodeName===`A`;t.preventDefault!==!1&&(i.current||!a)&&e.preventDefault(),r(!0)}},l=e=>{let t=lP(e.code,s);cP(o,a.current,!0)?(r(!1),a.current.clear()):a.current.delete(e[t]),e.key===`Meta`&&a.current.clear(),i.current=!1},u=()=>{a.current.clear(),r(!1)};return n?.addEventListener(`keydown`,e),n?.addEventListener(`keyup`,l),window.addEventListener(`blur`,u),window.addEventListener(`contextmenu`,u),()=>{n?.removeEventListener(`keydown`,e),n?.removeEventListener(`keyup`,l),window.removeEventListener(`blur`,u),window.removeEventListener(`contextmenu`,u)}}},[e,r]),n}function cP(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function lP(e,t){return t.includes(e)?`code`:`key`}var uP=()=>{let e=NN();return(0,H.useMemo)(()=>({zoomIn:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{let{panZoom:r}=e.getState();return r?r.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{let{transform:[r,i,a],panZoom:o}=e.getState();return o?(await o.setViewport({x:t.x??r,y:t.y??i,zoom:t.zoom??a},n),!0):!1},getViewport:()=>{let[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{let{width:r,height:i,minZoom:a,maxZoom:o,panZoom:s}=e.getState(),c=Ej(t,r,i,a,o,n?.padding??.1);return s?(await s.setViewport(c,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{let{transform:r,snapGrid:i,snapToGrid:a,domNode:o}=e.getState();if(!o)return t;let{x:s,y:c}=o.getBoundingClientRect(),l={x:t.x-s,y:t.y-c},u=n.snapGrid??i;return xj(l,r,n.snapToGrid??a,u)},flowToScreenPosition:t=>{let{transform:n,domNode:r}=e.getState();if(!r)return t;let{x:i,y:a}=r.getBoundingClientRect(),o=Sj(t,n);return{x:o.x+i,y:o.y+a}}}),[])};function dP(e,t){let n=[],r=new Map,i=[];for(let t of e)if(t.type===`add`){i.push(t);continue}else if(t.type===`remove`||t.type===`replace`)r.set(t.id,[t]);else{let e=r.get(t.id);e?e.push(t):r.set(t.id,[t])}for(let e of t){let t=r.get(e.id);if(!t){n.push(e);continue}if(t[0].type===`remove`)continue;if(t[0].type===`replace`){n.push({...t[0].item});continue}let i={...e};for(let e of t)fP(e,i);n.push(i)}return i.length&&i.forEach(e=>{e.index===void 0?n.push({...e.item}):n.splice(e.index,0,{...e.item})}),n}function fP(e,t){switch(e.type){case`select`:t.selected=e.selected;break;case`position`:e.position!==void 0&&(t.position=e.position),e.dragging!==void 0&&(t.dragging=e.dragging);break;case`dimensions`:e.dimensions!==void 0&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes===`width`)&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes===`height`)&&(t.height=e.dimensions.height))),typeof e.resizing==`boolean`&&(t.resizing=e.resizing)}}function pP(e,t){return dP(e,t)}function mP(e,t){return dP(e,t)}function hP(e,t){return{id:e,type:`select`,selected:t}}function gP(e,t=new Set,n=!1){let r=[];for(let[i,a]of e){let e=t.has(i);!(a.selected===void 0&&!e)&&a.selected!==e&&(n&&(a.selected=e),r.push(hP(a.id,e)))}return r}function _P({items:e=[],lookup:t}){let n=[],r=new Map(e.map(e=>[e.id,e]));for(let[r,i]of e.entries()){let e=t.get(i.id),a=e?.internals?.userNode??e;a!==void 0&&a!==i&&n.push({id:i.id,item:i,type:`replace`}),a===void 0&&n.push({item:i,type:`add`,index:r})}for(let[e]of t)r.get(e)===void 0&&n.push({id:e,type:`remove`});return n}function vP(e){return{id:e.id,type:`remove`}}var yP=yj(`React Flow`,`https://reactflow.dev/`);function bP(e,t,n={}){return $j(e,t,{...n,onError:n.onError??yP})}var xP=e=>qA(e),SP=e=>KA(e);function CP(e){return(0,H.forwardRef)(e)}var wP=typeof window<`u`?H.useLayoutEffect:H.useEffect;function TP(e){let[t,n]=(0,H.useState)(BigInt(0)),[r]=(0,H.useState)(()=>EP(()=>n(e=>e+BigInt(1))));return wP(()=>{let t=r.get();t.length&&(e(t),r.reset())},[t]),r}function EP(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}var DP=(0,H.createContext)(null);function OP({children:e}){let t=NN(),n=TP((0,H.useCallback)(e=>{let{nodes:n=[],setNodes:r,hasDefaultNodes:i,onNodesChange:a,nodeLookup:o,fitViewQueued:s,onNodesChangeMiddlewareMap:c}=t.getState(),l=n;for(let t of e)l=typeof t==`function`?t(l):t;let u=_P({items:l,lookup:o});for(let e of c.values())u=e(u);i&&r(l),u.length>0?a?.(u):s&&window.requestAnimationFrame(()=>{let{fitViewQueued:e,nodes:n,setNodes:r}=t.getState();e&&r(n)})},[])),r=TP((0,H.useCallback)(e=>{let{edges:n=[],setEdges:r,hasDefaultEdges:i,onEdgesChange:a,edgeLookup:o}=t.getState(),s=n;for(let t of e)s=typeof t==`function`?t(s):t;i?r(s):a&&a(_P({items:s,lookup:o}))},[])),i=(0,H.useMemo)(()=>({nodeQueue:n,edgeQueue:r}),[]);return(0,U.jsx)(DP.Provider,{value:i,children:e})}function kP(){let e=(0,H.useContext)(DP);if(!e)throw Error(`useBatchContext must be used within a BatchProvider`);return e}var AP=e=>!!e.panZoom;function jP(){let e=uP(),t=NN(),n=kP(),r=$(AP),i=(0,H.useMemo)(()=>{let e=e=>t.getState().nodeLookup.get(e),r=e=>{n.nodeQueue.push(e)},i=e=>{n.edgeQueue.push(e)},a=e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState(),i=xP(e)?e:n.get(e.id),a=i.parentId?jj(i.position,i.measured,i.parentId,n,r):i.position;return fj({...i,position:a,width:i.measured?.width??i.width,height:i.measured?.height??i.height})},o=(e,t,n={replace:!1})=>{r(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&xP(e)?e:{...r,...e}}return r}))},s=(e,t,n={replace:!1})=>{i(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&SP(e)?e:{...r,...e}}return r}))};return{getNodes:()=>t.getState().nodes.map(e=>({...e})),getNode:t=>e(t)?.internals.userNode,getInternalNode:e,getEdges:()=>{let{edges:e=[]}=t.getState();return e.map(e=>({...e}))},getEdge:e=>t.getState().edgeLookup.get(e),setNodes:r,setEdges:i,addNodes:e=>{let t=Array.isArray(e)?e:[e];n.nodeQueue.push(e=>[...e,...t])},addEdges:e=>{let t=Array.isArray(e)?e:[e];n.edgeQueue.push(e=>[...e,...t])},toObject:()=>{let{nodes:e=[],edges:n=[],transform:r}=t.getState(),[i,a,o]=r;return{nodes:e.map(e=>({...e})),edges:n.map(e=>({...e})),viewport:{x:i,y:a,zoom:o}}},deleteElements:async({nodes:e=[],edges:n=[]})=>{let{nodes:r,edges:i,onNodesDelete:a,onEdgesDelete:o,triggerNodeChanges:s,triggerEdgeChanges:c,onDelete:l,onBeforeDelete:u}=t.getState(),{nodes:d,edges:f}=await rj({nodesToRemove:e,edgesToRemove:n,nodes:r,edges:i,onBeforeDelete:u}),p=f.length>0,m=d.length>0;if(p){let e=f.map(vP);o?.(f),c(e)}if(m){let e=d.map(vP);a?.(d),s(e)}return(m||p)&&l?.({nodes:d,edges:f}),{deletedNodes:d,deletedEdges:f}},getIntersectingNodes:(e,n=!0,r)=>{let i=_j(e),o=i?e:a(e),s=r!==void 0;return o?(r||t.getState().nodes).filter(r=>{let a=t.getState().nodeLookup.get(r.id);if(a&&!i&&(r.id===e.id||!a.internals.positionAbsolute))return!1;let c=fj(s?r:a),l=gj(c,o);return n&&l>0||l>=c.width*c.height||l>=o.width*o.height}):[]},isNodeIntersecting:(e,t,n=!0)=>{let r=_j(e)?e:a(e);if(!r)return!1;let i=gj(r,t);return n&&i>0||i>=t.width*t.height||i>=r.width*r.height},updateNode:o,updateNodeData:(e,t,n={replace:!1})=>{o(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},updateEdge:s,updateEdgeData:(e,t,n={replace:!1})=>{s(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},getNodesBounds:e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState();return XA(e,{nodeLookup:n,nodeOrigin:r})},getHandleConnections:({type:e,id:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}-${e}${n?`-${n}`:``}`)?.values()??[]),getNodeConnections:({type:e,handleId:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}${e?n?`-${e}-${n}`:`-${e}`:``}`)?.values()??[]),fitView:async e=>{let r=t.getState().fitViewResolver??Nj();return t.setState({fitViewQueued:!0,fitViewOptions:e,fitViewResolver:r}),n.nodeQueue.push(e=>[...e]),r.promise}}},[]);return(0,H.useMemo)(()=>({...i,...e,viewportInitialized:r}),[r])}var MP=e=>e.selected,NP=typeof window<`u`?window:void 0;function PP({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=NN(),{deleteElements:r}=jP(),i=sP(e,{actInsideInputWithModifier:!1}),a=sP(t,{target:NP});(0,H.useEffect)(()=>{if(i){let{edges:e,nodes:t}=n.getState();r({nodes:t.filter(MP),edges:e.filter(MP)}),n.setState({nodesSelectionActive:!1})}},[i]),(0,H.useEffect)(()=>{n.setState({multiSelectionActive:a})},[a])}function FP(e){let t=NN();(0,H.useEffect)(()=>{let n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;let n=Lj(e.current);(n.height===0||n.width===0)&&t.getState().onError?.(`004`,FA.error004()),t.setState({width:n.width||500,height:n.height||500})};if(e.current){n(),window.addEventListener(`resize`,n);let t=new ResizeObserver(()=>n());return t.observe(e.current),()=>{window.removeEventListener(`resize`,n),t&&e.current&&t.unobserve(e.current)}}},[])}var IP={position:`absolute`,width:`100%`,height:`100%`,top:0,left:0},LP=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function RP({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panActivationKeyPressed:i,panOnScrollSpeed:a=.5,panOnScrollMode:o=BA.Free,zoomOnDoubleClick:s=!0,panOnDrag:c=!0,defaultViewport:l,translateExtent:u,minZoom:d,maxZoom:f,zoomActivationKeyCode:p,preventScrolling:m=!0,children:h,noWheelClassName:g,noPanClassName:_,onViewportChange:v,isControlledViewport:y,paneClickDistance:b,selectionOnDrag:x}){let S=NN(),C=(0,H.useRef)(null),{userSelectionActive:w,lib:T,connectionInProgress:E}=$(LP,kN),D=sP(p),O=(0,H.useRef)();FP(C);let k=(0,H.useCallback)(e=>{v?.({x:e[0],y:e[1],zoom:e[2]}),y||S.setState({transform:e})},[v,y]);return(0,H.useEffect)(()=>{if(C.current){O.current=cN({domNode:C.current,minZoom:d,maxZoom:f,translateExtent:u,viewport:l,onDraggingChange:e=>S.setState(t=>t.paneDragging===e?t:{paneDragging:e}),onPanZoomStart:(e,t)=>{let{onViewportChangeStart:n,onMoveStart:r}=S.getState();r?.(e,t),n?.(t)},onPanZoom:(e,t)=>{let{onViewportChange:n,onMove:r}=S.getState();r?.(e,t),n?.(t)},onPanZoomEnd:(e,t)=>{let{onViewportChangeEnd:n,onMoveEnd:r}=S.getState();r?.(e,t),n?.(t)}});let{x:e,y:t,zoom:n}=O.current.getViewport();return S.setState({panZoom:O.current,transform:[e,t,n],domNode:C.current.closest(`.react-flow`)}),()=>{O.current?.destroy()}}},[]),(0,H.useEffect)(()=>{O.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panActivationKeyPressed:i,panOnScrollSpeed:a,panOnScrollMode:o,zoomOnDoubleClick:s,panOnDrag:c,zoomActivationKeyPressed:D,preventScrolling:m,noPanClassName:_,userSelectionActive:w,noWheelClassName:g,lib:T,onTransformChange:k,connectionInProgress:E,selectionOnDrag:x,paneClickDistance:b})},[e,t,n,r,i,a,o,s,c,D,m,_,w,g,T,k,E,x,b]),(0,U.jsx)(`div`,{className:`react-flow__renderer`,ref:C,style:IP,children:h})}var zP=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function BP(){let{userSelectionActive:e,userSelectionRect:t}=$(zP,kN);return e&&t?(0,U.jsx)(`div`,{className:`react-flow__selection react-flow__container`,style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}var VP=(e,t)=>n=>{n.target===t.current&&e?.(n)},HP=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function UP({isSelecting:e,selectionKeyPressed:t,selectionMode:n=VA.Full,panOnDrag:r,autoPanOnSelection:i,paneClickDistance:a,selectionOnDrag:o,onSelectionStart:s,onSelectionEnd:c,onPaneClick:l,onPaneContextMenu:u,onPaneScroll:d,onPaneMouseEnter:f,onPaneMouseMove:p,onPaneMouseLeave:m,children:h}){let g=(0,H.useRef)(0),_=NN(),{userSelectionActive:v,elementsSelectable:y,dragging:b,panBy:x,autoPanSpeed:S}=$(HP,kN),C=y&&(e||v),w=(0,H.useRef)(null),T=(0,H.useRef)(),E=(0,H.useRef)(new Set),D=(0,H.useRef)(new Set),O=(0,H.useRef)(!1),k=(0,H.useRef)(!1),A=(0,H.useRef)({x:0,y:0}),j=(0,H.useRef)(!1),M=e=>{if(k.current||O.current||_.getState().connection.inProgress){k.current=!1,O.current=!1;return}l?.(e),_.getState().resetSelectedElements(),_.setState({nodesSelectionActive:!1})},N=e=>{if(Array.isArray(r)&&r?.includes(2)){e.preventDefault();return}u?.(e)},P=d?e=>d(e):void 0,F=e=>{k.current&&=(e.stopPropagation(),!1)},I=n=>{if(n.pointerType===`touch`&&r!==!1&&!t)return;let{domNode:i,transform:a}=_.getState();if(T.current=i?.getBoundingClientRect(),!T.current)return;let s=n.target===w.current;if(!s&&n.target.closest(`.nokey`)||!e||!(o&&s||t)||n.button!==0||!n.isPrimary)return;n.target?.setPointerCapture?.(n.pointerId),k.current=!1;let{x:c,y:l}=Hj(n.nativeEvent,T.current),u=xj({x:c,y:l},a);_.setState({userSelectionRect:{width:0,height:0,startX:u.x,startY:u.y,x:c,y:l}}),s||(n.stopPropagation(),n.preventDefault())};function L(e,t){let{userSelectionRect:r}=_.getState();if(!r)return;let{transform:i,nodeLookup:a,edgeLookup:o,connectionLookup:s,triggerNodeChanges:c,triggerEdgeChanges:l,defaultEdgeOptions:u}=_.getState(),d={x:r.startX,y:r.startY},{x:f,y:p}=Sj(d,i),m={startX:d.x,startY:d.y,x:e<f?e:f,y:t<p?t:p,width:Math.abs(e-f),height:Math.abs(t-p)},h=E.current,g=D.current;E.current=new Set(QA(a,m,i,n===VA.Partial,!0).map(e=>e.id)),D.current=new Set;let v=u?.selectable??!0;for(let e of E.current){let t=s.get(e);if(t)for(let{edgeId:e}of t.values()){let t=o.get(e);t&&(t.selectable??v)&&D.current.add(e)}}Mj(h,E.current)||c(gP(a,E.current,!0)),Mj(g,D.current)||l(gP(o,D.current)),_.setState({userSelectionRect:m,userSelectionActive:!0,nodesSelectionActive:!1})}function R(){if(!i||!T.current)return;let[e,t]=cj(A.current,T.current,S);x({x:e,y:t}).then(e=>{if(!k.current||!e){g.current=requestAnimationFrame(R);return}let{x:t,y:n}=A.current;L(t,n),g.current=requestAnimationFrame(R)})}let ee=()=>{cancelAnimationFrame(g.current),g.current=0,j.current=!1};(0,H.useEffect)(()=>()=>ee(),[]);let z=e=>{let{userSelectionRect:n,transform:r,resetSelectedElements:i}=_.getState();if(!T.current||!n)return;let{x:o,y:c}=Hj(e.nativeEvent,T.current);A.current={x:o,y:c};let l=Sj({x:n.startX,y:n.startY},r);if(!k.current){let n=t?0:a;if(Math.hypot(o-l.x,c-l.y)<=n)return;i(),s?.(e)}k.current=!0,j.current||=(R(),!0),L(o,c)},B=e=>{if(!C){e.target===w.current&&_.getState().connection.inProgress&&(O.current=!0);return}e.button===0&&(e.target?.releasePointerCapture?.(e.pointerId),!v&&e.target===w.current&&_.getState().userSelectionRect&&M?.(e),_.setState({userSelectionActive:!1,userSelectionRect:null}),k.current&&(c?.(e),_.setState({nodesSelectionActive:E.current.size>0})),ee())},te=e=>{e.target?.releasePointerCapture?.(e.pointerId),ee()},V=r===!0||Array.isArray(r)&&r.includes(0);return(0,U.jsxs)(`div`,{className:Qw([`react-flow__pane`,{draggable:V,dragging:b,selection:e}]),onClick:C?void 0:VP(M,w),onContextMenu:VP(N,w),onWheel:VP(P,w),onPointerEnter:C?void 0:f,onPointerMove:C?z:p,onPointerUp:B,onPointerCancel:C?te:void 0,onPointerDownCapture:C?I:void 0,onClickCapture:C?F:void 0,onPointerLeave:m,ref:w,style:IP,children:[h,(0,U.jsx)(BP,{})]})}function WP({id:e,store:t,unselect:n=!1,nodeRef:r}){let{addSelectedNodes:i,unselectNodesAndEdges:a,multiSelectionActive:o,nodeLookup:s,onError:c}=t.getState(),l=s.get(e);if(!l){c?.(`012`,FA.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&o)&&(a({nodes:[l],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])}function GP({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:a,nodeClickDistance:o}){let s=NN(),[c,l]=(0,H.useState)(!1),u=(0,H.useRef)();return(0,H.useEffect)(()=>{if(!t)return u.current=LM({getStoreItems:()=>s.getState(),onNodeMouseDown:t=>{WP({id:t,store:s,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}}),()=>{u.current?.destroy(),u.current=void 0}},[t,s,e]),(0,H.useEffect)(()=>{t||!e.current||!u.current||u.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:a,nodeId:i,nodeClickDistance:o})},[n,r,t,a,e,i,o]),c}var KP=e=>t=>t.selected&&(t.draggable||e&&t.draggable===void 0);function qP(){let e=NN();return(0,H.useCallback)(t=>{let{nodeExtent:n,snapToGrid:r,snapGrid:i,nodesDraggable:a,onError:o,updateNodePositions:s,nodeLookup:c,nodeOrigin:l}=e.getState(),u=new Map,d=KP(a),f=r?i[0]:5,p=r?i[1]:5,m=t.direction.x*f*t.factor,h=t.direction.y*p*t.factor;for(let[,e]of c){if(!d(e))continue;let t={x:e.internals.positionAbsolute.x+m,y:e.internals.positionAbsolute.y+h};r&&(t=bj(t,i));let{position:a,positionAbsolute:s}=nj({nodeId:e.id,nextPosition:t,nodeLookup:c,nodeExtent:n,nodeOrigin:l,onError:o});e.position=a,e.internals.positionAbsolute=s,u.set(e.id,e)}s(u)},[])}var JP=(0,H.createContext)(null),YP=JP.Provider;JP.Consumer;var XP=()=>(0,H.useContext)(JP),ZP=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),QP=(0,H.createContext)(null);function $P({children:e}){let t=$(ZP,kN);return(0,U.jsx)(QP.Provider,{value:t,children:e})}function eF(){let e=(0,H.useContext)(QP);if(!e)throw Error(`useHandleConfig must be used within a HandleConfigProvider`);return e}var tF={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},nF=(e,t,n)=>r=>{let{connectionClickStartHandle:i,connectionMode:a,connection:o}=r,{fromHandle:s,toHandle:c,isValid:l}=o;if(!s&&!i)return tF;let u=c?.nodeId===e&&c?.id===t&&c?.type===n;return{connectingFrom:s?.nodeId===e&&s?.id===t&&s?.type===n,connectingTo:u,clickConnecting:i?.nodeId===e&&i?.id===t&&i?.type===n,isPossibleEndHandle:a===zA.Strict?s?.type!==n:e!==s?.nodeId||t!==s?.id,connectionInProcess:!!s,clickConnectionInProcess:!!i,valid:u&&l}};function rF({type:e=`source`,position:t=Q.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:a=!0,id:o,onConnect:s,children:c,className:l,onMouseDown:u,onTouchStart:d,...f},p){let m=o||null,h=e===`target`,g=NN(),_=XP(),{connectOnClick:v,noPanClassName:y,rfId:b}=eF(),{connectingFrom:x,connectingTo:S,clickConnecting:C,isPossibleEndHandle:w,connectionInProcess:T,clickConnectionInProcess:E,valid:D}=$(nF(_,m,e),kN);_||g.getState().onError?.(`010`,FA.error010());let O=e=>{let{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:r}=g.getState(),i={...t,...e};if(r){let{edges:e,setEdges:t,onError:n}=g.getState();t(bP(i,e,{onError:n}))}n?.(i),s?.(i)},k=e=>{if(!_)return;let t=Vj(e.nativeEvent);if(i&&(t&&e.button===0||!t)){let t=g.getState();qM.onPointerDown(e.nativeEvent,{handleDomNode:e.currentTarget,autoPanOnConnect:t.autoPanOnConnect,connectionMode:t.connectionMode,connectionRadius:t.connectionRadius,domNode:t.domNode,nodeLookup:t.nodeLookup,lib:t.lib,isTarget:h,handleId:m,nodeId:_,flowId:t.rfId,panBy:t.panBy,cancelConnection:t.cancelConnection,onConnectStart:t.onConnectStart,onConnectEnd:(...e)=>g.getState().onConnectEnd?.(...e),updateConnection:t.updateConnection,onConnect:O,isValidConnection:n||((...e)=>g.getState().isValidConnection?.(...e)??!0),getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,autoPanSpeed:t.autoPanSpeed,dragThreshold:t.connectionDragThreshold})}t?u?.(e):d?.(e)};return(0,U.jsx)(`div`,{"data-handleid":m,"data-nodeid":_,"data-handlepos":t,"data-id":`${b}-${_}-${m}-${e}`,className:Qw([`react-flow__handle`,`react-flow__handle-${t}`,`nodrag`,y,l,{source:!h,target:h,connectable:r,connectablestart:i,connectableend:a,clickconnecting:C,connectingfrom:x,connectingto:S,valid:D,connectionindicator:r&&(!T||w)&&(T||E?a:i)}]),onMouseDown:k,onTouchStart:k,onClick:v?t=>{let{onClickConnectStart:r,onClickConnectEnd:a,connectionClickStartHandle:o,connectionMode:s,isValidConnection:c,lib:l,rfId:u,nodeLookup:d,connection:f}=g.getState();if(!_||!o&&!i)return;if(!o){r?.(t.nativeEvent,{nodeId:_,handleId:m,handleType:e}),g.setState({connectionClickStartHandle:{nodeId:_,type:e,id:m}});return}let p=Rj(t.target),h=n||c,{connection:v,isValid:y}=qM.isValid(t.nativeEvent,{handle:{nodeId:_,id:m,type:e},connectionMode:s,fromNodeId:o.nodeId,fromHandleId:o.id||null,fromType:o.type,isValidConnection:h,flowId:u,doc:p,lib:l,nodeLookup:d});y&&v&&O(v);let b=structuredClone(f);delete b.inProgress,b.toPosition=b.toHandle?b.toHandle.position:null,a?.(t,b),g.setState({connectionClickStartHandle:null})}:void 0,ref:p,...f,children:c})}var iF=(0,H.memo)(CP(rF));function aF({data:e,isConnectable:t,sourcePosition:n=Q.Bottom}){return(0,U.jsxs)(U.Fragment,{children:[e?.label,(0,U.jsx)(iF,{type:`source`,position:n,isConnectable:t})]})}function oF({data:e,isConnectable:t,targetPosition:n=Q.Top,sourcePosition:r=Q.Bottom}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(iF,{type:`target`,position:n,isConnectable:t}),e?.label,(0,U.jsx)(iF,{type:`source`,position:r,isConnectable:t})]})}function sF(){return null}function cF({data:e,isConnectable:t,targetPosition:n=Q.Top}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(iF,{type:`target`,position:n,isConnectable:t}),e?.label]})}var lF={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},uF={input:aF,default:oF,output:cF,group:sF};function dF(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}var fF=e=>{let{width:t,height:n,x:r,y:i}=ZA(e.nodeLookup,{filter:e=>!!e.selected});return{width:vj(t)?t:null,height:vj(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${i}px)`}};function pF({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let r=NN(),{width:i,height:a,transformString:o,userSelectionActive:s}=$(fF,kN),c=qP(),l=(0,H.useRef)(null);(0,H.useEffect)(()=>{n||l.current?.focus({preventScroll:!0})},[n]);let u=!s&&i!==null&&a!==null;if(GP({nodeRef:l,disabled:!u}),!u)return null;let d=e?t=>{e(t,r.getState().nodes.filter(e=>e.selected))}:void 0;return(0,U.jsx)(`div`,{className:Qw([`react-flow__nodesselection`,`react-flow__container`,t]),style:{transform:o},children:(0,U.jsx)(`div`,{ref:l,className:`react-flow__nodesselection-rect`,onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(lF,e.key)&&(e.preventDefault(),c({direction:lF[e.key],factor:e.shiftKey?4:1}))},style:{width:i,height:a}})})}var mF=typeof window<`u`?window:void 0,hF=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function gF({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,paneClickDistance:s,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:u,selectionMode:d,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:m,panActivationKeyCode:h,zoomActivationKeyCode:g,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:b,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:w,autoPanOnSelection:T,defaultViewport:E,translateExtent:D,minZoom:O,maxZoom:k,preventScrolling:A,onSelectionContextMenu:j,noWheelClassName:M,noPanClassName:N,disableKeyboardA11y:P,onViewportChange:F,isControlledViewport:I}){let{nodesSelectionActive:L,userSelectionActive:R}=$(hF,kN),ee=sP(l,{target:mF}),z=sP(h,{target:mF}),B=z||w,te=z||b,V=u&&B!==!0,ne=ee||R||V;return PP({deleteKeyCode:c,multiSelectionKeyCode:m}),(0,U.jsx)(RP,{onPaneContextMenu:a,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:te,panActivationKeyPressed:z,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:!ee&&B,defaultViewport:E,translateExtent:D,minZoom:O,maxZoom:k,zoomActivationKeyCode:g,preventScrolling:A,noWheelClassName:M,noPanClassName:N,onViewportChange:F,isControlledViewport:I,paneClickDistance:s,selectionOnDrag:V,children:(0,U.jsxs)(UP,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,panOnDrag:B,autoPanOnSelection:T,isSelecting:!!ne,selectionMode:d,selectionKeyPressed:ee,paneClickDistance:s,selectionOnDrag:V,children:[e,L&&(0,U.jsx)(pF,{onSelectionContextMenu:j,noPanClassName:N,disableKeyboardA11y:P})]})})}gF.displayName=`FlowRenderer`;var _F=(0,H.memo)(gF),vF=e=>t=>e?QA(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(e=>e.id):Array.from(t.nodeLookup.keys());function yF(e){return $((0,H.useCallback)(vF(e),[e]),kN)}var bF=e=>e.updateNodeInternals;function xF(){let e=$(bF),[t]=(0,H.useState)(()=>typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{let n=new Map;t.forEach(e=>{let t=e.target.getAttribute(`data-id`);n.set(t,{id:t,nodeElement:e.target,force:!0})}),e(n)}));return(0,H.useEffect)(()=>()=>{t?.disconnect()},[t]),t}function SF({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){let i=NN(),a=(0,H.useRef)(null),o=(0,H.useRef)(null),s=(0,H.useRef)(e.sourcePosition),c=(0,H.useRef)(e.targetPosition),l=(0,H.useRef)(t),u=n&&!!e.internals.handleBounds;return(0,H.useEffect)(()=>{a.current&&!e.hidden&&(!u||o.current!==a.current)&&(o.current&&r?.unobserve(o.current),r?.observe(a.current),o.current=a.current)},[u,e.hidden]),(0,H.useEffect)(()=>()=>{o.current&&=(r?.unobserve(o.current),null)},[]),(0,H.useEffect)(()=>{if(a.current){let n=l.current!==t,r=s.current!==e.sourcePosition,o=c.current!==e.targetPosition;(n||r||o)&&(l.current=t,s.current=e.sourcePosition,c.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),a}function CF({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:i,onContextMenu:a,onDoubleClick:o,nodesDraggable:s,elementsSelectable:c,nodesConnectable:l,nodesFocusable:u,resizeObserver:d,noDragClassName:f,noPanClassName:p,disableKeyboardA11y:m,rfId:h,nodeTypes:g,nodeClickDistance:_,onError:v}){let{node:y,internals:b,isParent:x}=$(t=>{let n=t.nodeLookup.get(e),r=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:r}},kN),S=y.type||`default`,C=g?.[S]||uF[S];C===void 0&&(v?.(`003`,FA.error003(S)),S=`default`,C=g?.default||uF.default);let w=!!(y.draggable||s&&y.draggable===void 0),T=!!(y.selectable||c&&y.selectable===void 0),E=!!(y.connectable||l&&y.connectable===void 0),D=!!(y.focusable||u&&y.focusable===void 0),O=NN(),k=Aj(y),A=SF({node:y,nodeType:S,hasDimensions:k,resizeObserver:d}),j=GP({nodeRef:A,disabled:y.hidden||!w,noDragClassName:f,handleSelector:y.dragHandle,nodeId:e,isSelectable:T,nodeClickDistance:_}),M=qP();if(y.hidden)return null;let N=kj(y),P=dF(y),F=T||w||t||n||r||i,I=n?e=>n(e,{...b.userNode}):void 0,L=r?e=>r(e,{...b.userNode}):void 0,R=i?e=>i(e,{...b.userNode}):void 0,ee=a?e=>a(e,{...b.userNode}):void 0,z=o?e=>o(e,{...b.userNode}):void 0,B=n=>{let{selectNodesOnDrag:r,nodeDragThreshold:i}=O.getState();T&&(!r||!w||i>0)&&WP({id:e,store:O,nodeRef:A}),t&&t(n,{...b.userNode})},te=t=>{if(!(Bj(t.nativeEvent)||m)){if(LA.includes(t.key)&&T){let n=t.key===`Escape`;WP({id:e,store:O,unselect:n,nodeRef:A})}else if(w&&y.selected&&Object.prototype.hasOwnProperty.call(lF,t.key)){t.preventDefault();let{ariaLabelConfig:e}=O.getState();O.setState({ariaLiveMessage:e[`node.a11yDescription.ariaLiveMessage`]({direction:t.key.replace(`Arrow`,``).toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),M({direction:lF[t.key],factor:t.shiftKey?4:1})}}},V=()=>{if(m||!A.current?.matches(`:focus-visible`))return;let{transform:t,width:n,height:r,autoPanOnNodeFocus:i,setCenter:a}=O.getState();i&&(QA(new Map([[e,y]]),{x:0,y:0,width:n,height:r},t,!0).length>0||a(y.position.x+N.width/2,y.position.y+N.height/2,{zoom:t[2]}))};return(0,U.jsx)(`div`,{className:Qw([`react-flow__node`,`react-flow__node-${S}`,{[p]:w},y.className,{selected:y.selected,selectable:T,parent:x,draggable:w,dragging:j}]),ref:A,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:F?`all`:`none`,visibility:k?`visible`:`hidden`,...y.style,...P},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:I,onMouseMove:L,onMouseLeave:R,onContextMenu:ee,onClick:B,onDoubleClick:z,onKeyDown:D?te:void 0,tabIndex:D?0:void 0,onFocus:D?V:void 0,role:y.ariaRole??(D?`group`:void 0),"aria-roledescription":`node`,"aria-describedby":m?void 0:`${IN}-${h}`,"aria-label":y.ariaLabel,...y.domAttributes,children:(0,U.jsx)(YP,{value:e,children:(0,U.jsx)(C,{id:e,data:y.data,type:S,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:y.selected??!1,selectable:T,draggable:w,deletable:y.deletable??!0,isConnectable:E,sourcePosition:y.sourcePosition,targetPosition:y.targetPosition,dragging:j,dragHandle:y.dragHandle,zIndex:b.z,parentId:y.parentId,...N})})})}var wF=(0,H.memo)(CF),TF=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function EF(e){let{nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,onError:i}=$(TF,kN),a=yF(e.onlyRenderVisibleElements),o=xF();return(0,U.jsx)(`div`,{className:`react-flow__nodes`,style:IP,children:a.map(a=>(0,U.jsx)(wF,{id:a,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:o,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:i},a))})}EF.displayName=`NodeRenderer`;var DF=(0,H.memo)(EF);function OF(e){return $((0,H.useCallback)(t=>{if(!e)return t.edges.map(e=>e.id);let n=[];if(t.width&&t.height)for(let e of t.edges){let r=t.nodeLookup.get(e.source),i=t.nodeLookup.get(e.target);r&&i&&Xj({sourceNode:r,targetNode:i,width:t.width,height:t.height,transform:t.transform})&&n.push(e.id)}return n},[e]),kN)}var kF=({color:e=`none`,strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e}};return(0,U.jsx)(`polyline`,{className:`arrow`,style:n,strokeLinecap:`round`,fill:`none`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4`})},AF=({color:e=`none`,strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e,fill:e}};return(0,U.jsx)(`polyline`,{className:`arrowclosed`,style:n,strokeLinecap:`round`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4 -5,-4`})},jF={[WA.Arrow]:kF,[WA.ArrowClosed]:AF};function MF(e){let t=NN();return(0,H.useMemo)(()=>Object.prototype.hasOwnProperty.call(jF,e)?jF[e]:(t.getState().onError?.(`009`,FA.error009(e)),null),[e])}var NF=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:a=`strokeWidth`,strokeWidth:o,orient:s=`auto-start-reverse`})=>{let c=MF(t);return c?(0,U.jsx)(`marker`,{className:`react-flow__arrowhead`,id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:`-10 -10 20 20`,markerUnits:a,orient:s,refX:`0`,refY:`0`,children:(0,U.jsx)(c,{color:n,strokeWidth:o})}):null},PF=({defaultColor:e,rfId:t})=>{let n=$(e=>e.edges),r=$(e=>e.defaultEdgeOptions),i=(0,H.useMemo)(()=>pM(n,{id:t,defaultColor:e,defaultMarkerStart:r?.markerStart,defaultMarkerEnd:r?.markerEnd}),[n,r,t,e]);return i.length?(0,U.jsx)(`svg`,{className:`react-flow__marker`,"aria-hidden":`true`,children:(0,U.jsx)(`defs`,{children:i.map(e=>(0,U.jsx)(NF,{id:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient},e.id))})}):null};PF.displayName=`MarkerDefinitions`;var FF=(0,H.memo)(PF);function IF({x:e,y:t,label:n,labelStyle:r,labelShowBg:i=!0,labelBgStyle:a,labelBgPadding:o=[2,4],labelBgBorderRadius:s=2,children:c,className:l,...u}){let[d,f]=(0,H.useState)({x:1,y:0,width:0,height:0}),p=Qw([`react-flow__edge-textwrapper`,l]),m=(0,H.useRef)(null);return(0,H.useEffect)(()=>{if(m.current){let e=m.current.getBBox();f({x:e.x,y:e.y,width:e.width,height:e.height})}},[n]),n?(0,U.jsxs)(`g`,{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:p,visibility:d.width?`visible`:`hidden`,...u,children:[i&&(0,U.jsx)(`rect`,{width:d.width+2*o[0],x:-o[0],y:-o[1],height:d.height+2*o[1],className:`react-flow__edge-textbg`,style:a,rx:s,ry:s}),(0,U.jsx)(`text`,{className:`react-flow__edge-text`,y:d.height/2,dy:`0.3em`,ref:m,style:r,children:n}),c]}):null}IF.displayName=`EdgeText`;var LF=(0,H.memo)(IF);function RF({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{...u,d:e,fill:`none`,className:Qw([`react-flow__edge-path`,u.className])}),l?(0,U.jsx)(`path`,{d:e,fill:`none`,strokeOpacity:0,strokeWidth:l,className:`react-flow__edge-interaction`}):null,r&&vj(t)&&vj(n)?(0,U.jsx)(LF,{x:t,y:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c}):null]})}function zF({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===Q.Left||e===Q.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function BF({sourceX:e,sourceY:t,sourcePosition:n=Q.Bottom,targetX:r,targetY:i,targetPosition:a=Q.Top}){let[o,s]=zF({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,l]=zF({pos:a,x1:r,y1:i,x2:e,y2:t}),[u,d,f,p]=Wj({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:o,sourceControlY:s,targetControlX:c,targetControlY:l});return[`M${e},${t} C${o},${s} ${c},${l} ${r},${i}`,u,d,f,p]}function VF(e){return(0,H.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o,targetPosition:s,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})=>{let[v,y,b]=BF({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s}),x=e.isInternal?void 0:t;return(0,U.jsx)(RF,{id:x,path:v,labelX:y,labelY:b,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})})}var HF=VF({isInternal:!1}),UF=VF({isInternal:!0});HF.displayName=`SimpleBezierEdge`,UF.displayName=`SimpleBezierEdgeInternal`;function WF(e){return(0,H.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,sourcePosition:p=Q.Bottom,targetPosition:m=Q.Top,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=oM({sourceX:n,sourceY:r,sourcePosition:p,targetX:i,targetY:a,targetPosition:m,borderRadius:_?.borderRadius,offset:_?.offset,stepPosition:_?.stepPosition}),S=e.isInternal?void 0:t;return(0,U.jsx)(RF,{id:S,path:y,labelX:b,labelY:x,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,interactionWidth:v})})}var GF=WF({isInternal:!1}),KF=WF({isInternal:!0});GF.displayName=`SmoothStepEdge`,KF.displayName=`SmoothStepEdgeInternal`;function qF(e){return(0,H.memo)(({id:t,...n})=>{let r=e.isInternal?void 0:t;return(0,U.jsx)(GF,{...n,id:r,pathOptions:(0,H.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}var JF=qF({isInternal:!1}),YF=qF({isInternal:!0});JF.displayName=`StepEdge`,YF.displayName=`StepEdgeInternal`;function XF(e){return(0,H.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})=>{let[g,_,v]=eM({sourceX:n,sourceY:r,targetX:i,targetY:a}),y=e.isInternal?void 0:t;return(0,U.jsx)(RF,{id:y,path:g,labelX:_,labelY:v,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})})}var ZF=XF({isInternal:!1}),QF=XF({isInternal:!0});ZF.displayName=`StraightEdge`,QF.displayName=`StraightEdgeInternal`;function $F(e){return(0,H.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o=Q.Bottom,targetPosition:s=Q.Top,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=qj({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s,curvature:_?.curvature}),S=e.isInternal?void 0:t;return(0,U.jsx)(RF,{id:S,path:y,labelX:b,labelY:x,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:v})})}var eI=$F({isInternal:!1}),tI=$F({isInternal:!0});eI.displayName=`BezierEdge`,tI.displayName=`BezierEdgeInternal`;var nI={default:tI,straight:QF,step:YF,smoothstep:KF,simplebezier:UF},rI={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},iI=(e,t,n)=>n===Q.Left?e-t:n===Q.Right?e+t:e,aI=(e,t,n)=>n===Q.Top?e-t:n===Q.Bottom?e+t:e,oI=`react-flow__edgeupdater`;function sI({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:a,onMouseOut:o,type:s}){return(0,U.jsx)(`circle`,{onMouseDown:i,onMouseEnter:a,onMouseOut:o,className:Qw([oI,`${oI}-${s}`]),cx:iI(t,r,e),cy:aI(n,r,e),r,stroke:`transparent`,fill:`transparent`})}function cI({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:i,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,onReconnect:l,onReconnectStart:u,onReconnectEnd:d,setReconnecting:f,setUpdateHover:p}){let m=NN(),h=(e,t)=>{if(e.button!==0)return;let{autoPanOnConnect:r,domNode:i,connectionMode:a,connectionRadius:o,lib:s,onConnectStart:c,cancelConnection:p,nodeLookup:h,rfId:g,panBy:_,updateConnection:v}=m.getState(),y=t.type===`target`;qM.onPointerDown(e.nativeEvent,{autoPanOnConnect:r,connectionMode:a,connectionRadius:o,domNode:i,handleId:t.id,nodeId:t.nodeId,nodeLookup:h,isTarget:y,edgeUpdaterType:t.type,lib:s,flowId:g,cancelConnection:p,panBy:_,isValidConnection:(...e)=>m.getState().isValidConnection?.(...e)??!0,onConnect:e=>l?.(n,e),onConnectStart:(r,i)=>{f(!0),u?.(e,n,t.type),c?.(r,i)},onConnectEnd:(...e)=>m.getState().onConnectEnd?.(...e),onReconnectEnd:(e,r)=>{f(!1),d?.(e,n,t.type,r)},updateConnection:v,getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,dragThreshold:m.getState().connectionDragThreshold,handleDomNode:e.currentTarget})},g=e=>h(e,{nodeId:n.target,id:n.targetHandle??null,type:`target`}),_=e=>h(e,{nodeId:n.source,id:n.sourceHandle??null,type:`source`}),v=()=>p(!0),y=()=>p(!1);return(0,U.jsxs)(U.Fragment,{children:[(e===!0||e===`source`)&&(0,U.jsx)(sI,{position:s,centerX:r,centerY:i,radius:t,onMouseDown:g,onMouseEnter:v,onMouseOut:y,type:`source`}),(e===!0||e===`target`)&&(0,U.jsx)(sI,{position:c,centerX:a,centerY:o,radius:t,onMouseDown:_,onMouseEnter:v,onMouseOut:y,type:`target`})]})}function lI({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:i,onDoubleClick:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,rfId:m,edgeTypes:h,noPanClassName:g,onError:_,disableKeyboardA11y:v}){let y=$(t=>t.edgeLookup.get(e)),b=$(e=>e.defaultEdgeOptions);y=b?{...b,...y}:y;let x=y.type||`default`,S=h?.[x]||nI[x];S===void 0&&(_?.(`011`,FA.error011(x)),x=`default`,S=h?.default||nI.default);let C=!!(y.focusable||t&&y.focusable===void 0),w=d!==void 0&&(y.reconnectable||n&&y.reconnectable===void 0),T=!!(y.selectable||r&&y.selectable===void 0),E=(0,H.useRef)(null),[D,O]=(0,H.useState)(!1),[k,A]=(0,H.useState)(!1),j=NN(),{zIndex:M=y.zIndex,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R}=$((0,H.useCallback)(t=>{let n=t.nodeLookup.get(y.source),r=t.nodeLookup.get(y.target);if(!n||!r)return rI;let i=cM({id:e,sourceNode:n,targetNode:r,sourceHandle:y.sourceHandle||null,targetHandle:y.targetHandle||null,connectionMode:t.connectionMode,onError:_}),a=Yj({selected:y.selected,zIndex:y.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect,zIndexMode:t.zIndexMode});return{...i||rI,zIndex:a}},[y.source,y.target,y.sourceHandle,y.targetHandle,y.selected,y.zIndex,_]),kN),ee=(0,H.useMemo)(()=>y.markerStart?`url('#${fM(y.markerStart,m)}')`:void 0,[y.markerStart,m]),z=(0,H.useMemo)(()=>y.markerEnd?`url('#${fM(y.markerEnd,m)}')`:void 0,[y.markerEnd,m]);if(y.hidden||N===null||P===null||F===null||I===null)return null;let B=t=>{let{addSelectedEdges:n,unselectNodesAndEdges:r,multiSelectionActive:a}=j.getState();T&&(j.setState({nodesSelectionActive:!1}),y.selected&&a?(r({nodes:[],edges:[y]}),E.current?.blur()):n([e])),i&&i(t,y)},te=a?e=>{a(e,{...y})}:void 0,V=o?e=>{o(e,{...y})}:void 0,ne=s?e=>{s(e,{...y})}:void 0,re=c?e=>{c(e,{...y})}:void 0,ie=l?e=>{l(e,{...y})}:void 0;return(0,U.jsx)(`svg`,{style:{zIndex:M},children:(0,U.jsxs)(`g`,{className:Qw([`react-flow__edge`,`react-flow__edge-${x}`,y.className,g,{selected:y.selected,animated:y.animated,inactive:!T&&!i,updating:D,selectable:T}]),onClick:B,onDoubleClick:te,onContextMenu:V,onMouseEnter:ne,onMouseMove:re,onMouseLeave:ie,onKeyDown:C?t=>{if(!v&&LA.includes(t.key)&&T){let{unselectNodesAndEdges:n,addSelectedEdges:r}=j.getState();t.key===`Escape`?(E.current?.blur(),n({edges:[y]})):r([e])}}:void 0,tabIndex:C?0:void 0,role:y.ariaRole??(C?`group`:`img`),"aria-roledescription":`edge`,"data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":y.ariaLabel===null?void 0:y.ariaLabel||`Edge from ${y.source} to ${y.target}`,"aria-describedby":C?`${LN}-${m}`:void 0,ref:E,...y.domAttributes,children:[!k&&(0,U.jsx)(S,{id:e,source:y.source,target:y.target,type:y.type,selected:y.selected,animated:y.animated,selectable:T,deletable:y.deletable??!0,label:y.label,labelStyle:y.labelStyle,labelShowBg:y.labelShowBg,labelBgStyle:y.labelBgStyle,labelBgPadding:y.labelBgPadding,labelBgBorderRadius:y.labelBgBorderRadius,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R,data:y.data,style:y.style,sourceHandleId:y.sourceHandle,targetHandleId:y.targetHandle,markerStart:ee,markerEnd:z,pathOptions:`pathOptions`in y?y.pathOptions:void 0,interactionWidth:y.interactionWidth}),w&&(0,U.jsx)(cI,{edge:y,isReconnectable:w,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R,setUpdateHover:O,setReconnecting:A})]})})}var uI=(0,H.memo)(lI),dI=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function fI({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:i,onReconnect:a,onEdgeContextMenu:o,onEdgeMouseEnter:s,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,reconnectRadius:d,onEdgeDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,disableKeyboardA11y:h}){let{edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,onError:y}=$(dI,kN),b=OF(t);return(0,U.jsxs)(`div`,{className:`react-flow__edges`,children:[(0,U.jsx)(FF,{defaultColor:e,rfId:n}),b.map(e=>(0,U.jsx)(uI,{id:e,edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,noPanClassName:i,onReconnect:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,onClick:u,reconnectRadius:d,onDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,rfId:n,onError:y,edgeTypes:r,disableKeyboardA11y:h},e))]})}fI.displayName=`EdgeRenderer`;var pI=(0,H.memo)(fI),mI=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function hI({children:e}){let t=NN(),n=(0,H.useRef)(null),[r]=(0,H.useState)(()=>t.getState().transform);return wP(()=>{let e=null,r=()=>{let r=t.getState().transform;e&&r[0]===e[0]&&r[1]===e[1]&&r[2]===e[2]||(e=r,n.current&&(n.current.style.transform=mI(r)))};return r(),t.subscribe(r)},[t]),(0,U.jsx)(`div`,{ref:n,className:`react-flow__viewport xyflow__viewport react-flow__container`,style:{transform:mI(r)},children:e})}function gI(e){let t=jP(),n=(0,H.useRef)(!1);(0,H.useEffect)(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}var _I=e=>e.panZoom?.syncViewport;function vI(e){let t=$(_I),n=NN();return(0,H.useEffect)(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function yI(e){return e.connection.inProgress?{...e.connection,to:xj(e.connection.to,e.transform)}:{...e.connection}}function bI(e){return e?t=>e(yI(t)):yI}function xI(e){return $(bI(e),kN)}var SI=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function CI({containerStyle:e,style:t,type:n,component:r}){let{nodesConnectable:i,width:a,height:o,isValid:s,inProgress:c}=$(SI,kN);return a&&i&&c?(0,U.jsx)(`svg`,{style:e,width:a,height:o,className:`react-flow__connectionline react-flow__container`,children:(0,U.jsx)(`g`,{className:Qw([`react-flow__connection`,Fj(s)]),children:(0,U.jsx)(wI,{style:t,type:n,CustomComponent:r,isValid:s})})}):null}var wI=({style:e,type:t=UA.Bezier,CustomComponent:n,isValid:r})=>{let{inProgress:i,from:a,fromNode:o,fromHandle:s,fromPosition:c,to:l,toNode:u,toHandle:d,toPosition:f,pointer:p}=xI();if(!i)return;if(n)return(0,U.jsx)(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:s,fromX:a.x,fromY:a.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:f,connectionStatus:Fj(r),toNode:u,toHandle:d,pointer:p});let m=``,h={sourceX:a.x,sourceY:a.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:f};switch(t){case UA.Bezier:[m]=qj(h);break;case UA.SimpleBezier:[m]=BF(h);break;case UA.Step:[m]=oM({...h,borderRadius:0});break;case UA.SmoothStep:[m]=oM(h);break;default:[m]=eM(h)}return(0,U.jsx)(`path`,{d:m,fill:`none`,className:`react-flow__connection-path`,style:e})};wI.displayName=`ConnectionLine`;var TI={};function EI(e=TI){(0,H.useRef)(e),NN(),(0,H.useEffect)(()=>{},[e])}function DI(){NN(),(0,H.useRef)(!1),(0,H.useEffect)(()=>{},[])}function OI({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:i,onNodeDoubleClick:a,onEdgeDoubleClick:o,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,onSelectionContextMenu:d,onSelectionStart:f,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:h,connectionLineComponent:g,connectionLineContainerStyle:_,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,deleteKeyCode:w,onlyRenderVisibleElements:T,elementsSelectable:E,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,preventScrolling:j,defaultMarkerColor:M,zoomOnScroll:N,zoomOnPinch:P,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,zoomOnDoubleClick:R,panOnDrag:ee,autoPanOnSelection:z,onPaneClick:B,onPaneMouseEnter:te,onPaneMouseMove:V,onPaneMouseLeave:ne,onPaneScroll:re,onPaneContextMenu:ie,paneClickDistance:ae,nodeClickDistance:oe,onEdgeContextMenu:se,onEdgeMouseEnter:ce,onEdgeMouseMove:le,onEdgeMouseLeave:ue,reconnectRadius:de,onReconnect:fe,onReconnectStart:pe,onReconnectEnd:me,noDragClassName:he,noWheelClassName:ge,noPanClassName:_e,disableKeyboardA11y:ve,nodeExtent:ye,rfId:be,viewport:xe,onViewportChange:Se,nodesDraggable:Ce}){return EI(e),EI(t),DI(),gI(n),vI(xe),(0,U.jsx)(_F,{onPaneClick:B,onPaneMouseEnter:te,onPaneMouseMove:V,onPaneMouseLeave:ne,onPaneContextMenu:ie,onPaneScroll:re,paneClickDistance:ae,deleteKeyCode:w,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,elementsSelectable:E,zoomOnScroll:N,zoomOnPinch:P,zoomOnDoubleClick:R,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,panOnDrag:ee,autoPanOnSelection:z,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,onSelectionContextMenu:d,preventScrolling:j,noDragClassName:he,noWheelClassName:ge,noPanClassName:_e,disableKeyboardA11y:ve,onViewportChange:Se,isControlledViewport:!!xe,children:(0,U.jsxs)(hI,{children:[(0,U.jsx)(pI,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:o,onReconnect:fe,onReconnectStart:pe,onReconnectEnd:me,onlyRenderVisibleElements:T,onEdgeContextMenu:se,onEdgeMouseEnter:ce,onEdgeMouseMove:le,onEdgeMouseLeave:ue,reconnectRadius:de,defaultMarkerColor:M,noPanClassName:_e,disableKeyboardA11y:ve,rfId:be}),(0,U.jsx)(CI,{style:h,type:m,component:g,containerStyle:_}),(0,U.jsx)(`div`,{className:`react-flow__edgelabel-renderer`}),(0,U.jsx)(DF,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:a,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,nodeClickDistance:oe,onlyRenderVisibleElements:T,noPanClassName:_e,noDragClassName:he,disableKeyboardA11y:ve,nodeExtent:ye,rfId:be,nodesDraggable:Ce}),(0,U.jsx)(`div`,{className:`react-flow__viewport-portal`})]})})}OI.displayName=`GraphView`;var kI=(0,H.memo)(OI),AI=yj(`React Flow`,`https://reactflow.dev/`),jI=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c=.5,maxZoom:l=2,nodeOrigin:u,nodeExtent:d,zIndexMode:f=`basic`}={})=>{let p=new Map,m=new Map,h=new Map,g=new Map,_=r??t??[],v=n??e??[],y=u??[0,0],b=d??IA;jM(h,g,_);let{nodesInitialized:x}=SM(v,p,m,{nodeOrigin:y,nodeExtent:b,zIndexMode:f}),S=[0,0,1];if(o&&i&&a){let{x:e,y:t,zoom:n}=Ej(ZA(p,{filter:e=>!!((e.width||e.initialWidth)&&(e.height||e.initialHeight))}),i,a,c,l,s?.padding??.1);S=[e,t,n]}return{rfId:`1`,width:i??0,height:a??0,transform:S,nodes:v,nodesInitialized:x,nodeLookup:p,parentLookup:m,edges:_,edgeLookup:g,connectionLookup:h,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:IA,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:zA.Strict,domNode:null,paneDragging:!1,noPanClassName:`nopan`,nodeOrigin:y,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:o??!1,fitViewOptions:s,fitViewResolver:null,connection:{...HA},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:``,autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:AI,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:`react`,debug:!1,ariaLabelConfig:RA,zIndexMode:f,defaultEdgeOptions:void 0,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map,onNodesDelete:void 0,onEdgesDelete:void 0,onDelete:void 0,onBeforeDelete:void 0,onViewportChangeStart:void 0,onViewportChange:void 0,onViewportChangeEnd:void 0,onNodeDragStart:void 0,onNodeDrag:void 0,onNodeDragStop:void 0,onSelectionDragStart:void 0,onSelectionDrag:void 0,onSelectionDragStop:void 0,onMoveStart:void 0,onMove:void 0,onMoveEnd:void 0,onConnect:void 0,onConnectStart:void 0,onConnectEnd:void 0,onClickConnectStart:void 0,onClickConnectEnd:void 0}},MI=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f})=>ON((p,m)=>{async function h(){let{nodeLookup:e,panZoom:t,fitViewOptions:n,fitViewResolver:r,width:i,height:a,minZoom:o,maxZoom:s}=m();t&&(await tj({nodes:e,width:i,height:a,panZoom:t,minZoom:o,maxZoom:s},n),r?.resolve(!0),p({fitViewResolver:null}))}return{...jI({nodes:e,edges:t,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:e=>{let{nodeLookup:t,parentLookup:n,nodeOrigin:r,nodeExtent:i,elevateNodesOnSelect:a,fitViewQueued:o,zIndexMode:s,nodesSelectionActive:c}=m(),{nodesInitialized:l,hasSelectedNodes:u}=SM(e,t,n,{nodeOrigin:r,nodeExtent:i,elevateNodesOnSelect:a,checkEquality:!0,zIndexMode:s}),d=c&&u;o&&l?(h(),p({nodes:e,nodesInitialized:l,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:d})):p({nodes:e,nodesInitialized:l,nodesSelectionActive:d})},setEdges:e=>{let{connectionLookup:t,edgeLookup:n}=m();jM(t,n,e),p({edges:e})},setDefaultNodesAndEdges:(e,t)=>{if(e){let{setNodes:t}=m();t(e),p({hasDefaultNodes:!0})}if(t){let{setEdges:e}=m();e(t),p({hasDefaultEdges:!0})}},updateNodeInternals:e=>{let{triggerNodeChanges:t,nodeLookup:n,parentLookup:r,domNode:i,nodeOrigin:a,nodeExtent:o,debug:s,fitViewQueued:c,zIndexMode:l}=m(),{changes:u,updatedInternals:d}=OM(e,n,r,i,a,o,l);d&&(yM(n,r,{nodeOrigin:a,nodeExtent:o,zIndexMode:l}),c?(h(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),u?.length>0&&(s&&console.log(`React Flow: trigger node changes`,u),t?.(u)))},updateNodePositions:(e,t=!1)=>{let n=[],r=[],{nodeLookup:i,triggerNodeChanges:a,connection:o,updateConnection:s,onNodesChangeMiddlewareMap:c}=m();for(let[a,c]of e){let e=i.get(a),l=!!(e?.expandParent&&e?.parentId&&c?.position),u={id:a,type:`position`,position:l?{x:Math.max(0,c.position.x),y:Math.max(0,c.position.y)}:c.position,dragging:t};if(e&&o.inProgress&&o.fromNode.id===e.id){let t=uM(e,o.fromHandle,Q.Left,!0);s({...o,from:t})}l&&e.parentId&&n.push({id:a,parentId:e.parentId,rect:{...c.internals.positionAbsolute,width:c.measured.width??0,height:c.measured.height??0}}),r.push(u)}if(n.length>0){let{parentLookup:e,nodeOrigin:t}=m(),a=DM(n,i,e,t);r.push(...a)}for(let e of c.values())r=e(r);a(r)},triggerNodeChanges:e=>{let{onNodesChange:t,setNodes:n,nodes:r,hasDefaultNodes:i,debug:a}=m();e?.length&&(i&&n(pP(e,r)),a&&console.log(`React Flow: trigger node changes`,e),t?.(e))},triggerEdgeChanges:e=>{let{onEdgesChange:t,setEdges:n,edges:r,hasDefaultEdges:i,debug:a}=m();e?.length&&(i&&n(mP(e,r)),a&&console.log(`React Flow: trigger edge changes`,e),t?.(e))},addSelectedNodes:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){i(e.map(e=>hP(e,!0)));return}i(gP(r,new Set([...e]),!0)),a(gP(n))},addSelectedEdges:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){a(e.map(e=>hP(e,!0)));return}a(gP(n,new Set([...e]))),i(gP(r,new Set,!0))},unselectNodesAndEdges:({nodes:e,edges:t}={})=>{let{edges:n,nodes:r,nodeLookup:i,triggerNodeChanges:a,triggerEdgeChanges:o}=m(),s=e||r,c=t||n,l=[];for(let e of s){if(!e.selected)continue;let t=i.get(e.id);t&&(t.selected=!1),l.push(hP(e.id,!1))}let u=[];for(let e of c)e.selected&&u.push(hP(e.id,!1));a(l),o(u)},setMinZoom:e=>{let{panZoom:t,maxZoom:n}=m();t?.setScaleExtent([e,n]),p({minZoom:e})},setMaxZoom:e=>{let{panZoom:t,minZoom:n}=m();t?.setScaleExtent([n,e]),p({maxZoom:e})},setTranslateExtent:e=>{m().panZoom?.setTranslateExtent(e),p({translateExtent:e})},resetSelectedElements:()=>{let{edges:e,nodes:t,triggerNodeChanges:n,triggerEdgeChanges:r,elementsSelectable:i}=m();if(!i)return;let a=t.reduce((e,t)=>t.selected?[...e,hP(t.id,!1)]:e,[]),o=e.reduce((e,t)=>t.selected?[...e,hP(t.id,!1)]:e,[]);n(a),r(o)},setNodeExtent:e=>{let{nodes:t,nodeLookup:n,parentLookup:r,nodeOrigin:i,elevateNodesOnSelect:a,nodeExtent:o,zIndexMode:s}=m();(e[0][0]!==o[0][0]||e[0][1]!==o[0][1]||e[1][0]!==o[1][0]||e[1][1]!==o[1][1])&&(SM(t,n,r,{nodeOrigin:i,nodeExtent:e,elevateNodesOnSelect:a,checkEquality:!1,zIndexMode:s}),p({nodeExtent:e}))},panBy:e=>{let{transform:t,width:n,height:r,panZoom:i,translateExtent:a}=m();return kM({delta:e,panZoom:i,transform:t,translateExtent:a,width:n,height:r})},setCenter:async(e,t,n)=>{let{width:r,height:i,maxZoom:a,panZoom:o}=m();if(!o)return!1;let s=n?.zoom===void 0?a:n.zoom;return await o.setViewport({x:r/2-e*s,y:i/2-t*s,zoom:s},{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0},cancelConnection:()=>{p({connection:{...HA}})},updateConnection:e=>{p({connection:e})},reset:()=>p({...jI()})}},Object.is);function NI({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:i,initialHeight:a,initialMinZoom:o,initialMaxZoom:s,initialFitViewOptions:c,fitView:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f,children:p}){let[m]=(0,H.useState)(()=>MI({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:l,minZoom:o,maxZoom:s,fitViewOptions:c,nodeOrigin:u,nodeExtent:d,zIndexMode:f}));return(0,U.jsx)(jN,{value:m,children:(0,U.jsx)(OP,{children:(0,U.jsx)($P,{children:p})})})}function PI({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:i,width:a,height:o,fitView:s,fitViewOptions:c,minZoom:l,maxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p}){return(0,H.useContext)(AN)?(0,U.jsx)(U.Fragment,{children:e}):(0,U.jsx)(NI,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:i,initialWidth:a,initialHeight:o,fitView:s,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p,children:e})}var FI={width:`100%`,height:`100%`,overflow:`hidden`,position:`relative`,zIndex:0};function II({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:a,edgeTypes:o,onNodeClick:s,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:d,onMoveEnd:f,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onSelectionChange:k,onSelectionDragStart:A,onSelectionDrag:j,onSelectionDragStop:M,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:F,onBeforeDelete:I,connectionMode:L,connectionLineType:R=UA.Bezier,connectionLineStyle:ee,connectionLineComponent:z,connectionLineContainerStyle:B,deleteKeyCode:te=`Backspace`,selectionKeyCode:V=`Shift`,selectionOnDrag:ne=!1,selectionMode:re=VA.Full,panActivationKeyCode:ie=`Space`,multiSelectionKeyCode:ae=Dj()?`Meta`:`Control`,zoomActivationKeyCode:oe=Dj()?`Meta`:`Control`,snapToGrid:se,snapGrid:ce,onlyRenderVisibleElements:le=!1,selectNodesOnDrag:ue,nodesDraggable:de,autoPanOnNodeFocus:fe,nodesConnectable:pe,nodesFocusable:me,nodeOrigin:he=QN,edgesFocusable:ge,edgesReconnectable:_e,elementsSelectable:ve=!0,defaultViewport:ye=$N,minZoom:be=.5,maxZoom:xe=2,translateExtent:Se=IA,preventScrolling:Ce=!0,nodeExtent:we,defaultMarkerColor:Te=`#b1b1b7`,zoomOnScroll:Ee=!0,zoomOnPinch:De=!0,panOnScroll:Oe=!1,panOnScrollSpeed:ke=.5,panOnScrollMode:Ae=BA.Free,zoomOnDoubleClick:je=!0,panOnDrag:Me=!0,onPaneClick:Ne,onPaneMouseEnter:Pe,onPaneMouseMove:Fe,onPaneMouseLeave:Ie,onPaneScroll:Le,onPaneContextMenu:Re,paneClickDistance:ze=1,nodeClickDistance:Be=0,children:Ve,onReconnect:He,onReconnectStart:Ue,onReconnectEnd:We,onEdgeContextMenu:Ge,onEdgeDoubleClick:Ke,onEdgeMouseEnter:qe,onEdgeMouseMove:Je,onEdgeMouseLeave:Ye,reconnectRadius:Xe=10,onNodesChange:Ze,onEdgesChange:Qe,noDragClassName:$e=`nodrag`,noWheelClassName:et=`nowheel`,noPanClassName:tt=`nopan`,fitView:nt,fitViewOptions:rt,connectOnClick:it,attributionPosition:at,proOptions:ot,defaultEdgeOptions:st,elevateNodesOnSelect:ct=!0,elevateEdgesOnSelect:lt=!1,disableKeyboardA11y:ut=!1,autoPanOnConnect:dt,autoPanOnNodeDrag:ft,autoPanOnSelection:pt=!0,autoPanSpeed:mt,connectionRadius:ht,isValidConnection:gt,onError:_t,style:vt,id:yt,nodeDragThreshold:bt,connectionDragThreshold:xt,viewport:St,onViewportChange:Ct,width:wt,height:Tt,colorMode:Et=`light`,debug:Dt,onScroll:Ot,ariaLabelConfig:kt,zIndexMode:At=`basic`,...jt},Mt){let Nt=yt||`1`,Pt=aP(Et),Ft=(0,H.useCallback)(e=>{e.currentTarget.scrollTo({top:0,left:0,behavior:`instant`}),Ot?.(e)},[Ot]);return(0,U.jsx)(`div`,{"data-testid":`rf__wrapper`,...jt,onScroll:Ft,style:{...vt,...FI},ref:Mt,className:Qw([`react-flow`,i,Pt]),id:yt,role:`application`,children:(0,U.jsxs)(PI,{nodes:e,edges:t,width:wt,height:Tt,fitView:nt,fitViewOptions:rt,minZoom:be,maxZoom:xe,nodeOrigin:he,nodeExtent:we,zIndexMode:At,children:[(0,U.jsx)(rP,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,nodesDraggable:de,autoPanOnNodeFocus:fe,nodesConnectable:pe,nodesFocusable:me,edgesFocusable:ge,edgesReconnectable:_e,elementsSelectable:ve,elevateNodesOnSelect:ct,elevateEdgesOnSelect:lt,minZoom:be,maxZoom:xe,nodeExtent:we,onNodesChange:Ze,onEdgesChange:Qe,snapToGrid:se,snapGrid:ce,connectionMode:L,translateExtent:Se,connectOnClick:it,defaultEdgeOptions:st,fitView:nt,fitViewOptions:rt,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onSelectionDrag:j,onSelectionDragStart:A,onSelectionDragStop:M,onMove:u,onMoveStart:d,onMoveEnd:f,noPanClassName:tt,nodeOrigin:he,rfId:Nt,autoPanOnConnect:dt,autoPanOnNodeDrag:ft,autoPanSpeed:mt,onError:_t,connectionRadius:ht,isValidConnection:gt,selectNodesOnDrag:ue,nodeDragThreshold:bt,connectionDragThreshold:xt,onBeforeDelete:I,debug:Dt,ariaLabelConfig:kt,zIndexMode:At}),(0,U.jsx)(kI,{onInit:l,onNodeClick:s,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,nodeTypes:a,edgeTypes:o,connectionLineType:R,connectionLineStyle:ee,connectionLineComponent:z,connectionLineContainerStyle:B,selectionKeyCode:V,selectionOnDrag:ne,selectionMode:re,deleteKeyCode:te,multiSelectionKeyCode:ae,panActivationKeyCode:ie,zoomActivationKeyCode:oe,onlyRenderVisibleElements:le,defaultViewport:ye,translateExtent:Se,minZoom:be,maxZoom:xe,preventScrolling:Ce,zoomOnScroll:Ee,zoomOnPinch:De,zoomOnDoubleClick:je,panOnScroll:Oe,panOnScrollSpeed:ke,panOnScrollMode:Ae,panOnDrag:Me,autoPanOnSelection:pt,onPaneClick:Ne,onPaneMouseEnter:Pe,onPaneMouseMove:Fe,onPaneMouseLeave:Ie,onPaneScroll:Le,onPaneContextMenu:Re,paneClickDistance:ze,nodeClickDistance:Be,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:F,onReconnect:He,onReconnectStart:Ue,onReconnectEnd:We,onEdgeContextMenu:Ge,onEdgeDoubleClick:Ke,onEdgeMouseEnter:qe,onEdgeMouseMove:Je,onEdgeMouseLeave:Ye,reconnectRadius:Xe,defaultMarkerColor:Te,noDragClassName:$e,noWheelClassName:et,noPanClassName:tt,rfId:Nt,disableKeyboardA11y:ut,nodeExtent:we,viewport:St,onViewportChange:Ct,nodesDraggable:de}),(0,U.jsx)(ZN,{onSelectionChange:k}),Ve,(0,U.jsx)(GN,{proOptions:ot,position:at}),(0,U.jsx)(HN,{rfId:Nt,disableKeyboardA11y:ut})]})})}var LI=CP(II);FA.error014();function RI({dimensions:e,lineWidth:t,variant:n,className:r}){return(0,U.jsx)(`path`,{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Qw([`react-flow__background-pattern`,n,r])})}function zI({radius:e,className:t}){return(0,U.jsx)(`circle`,{cx:e,cy:e,r:e,className:Qw([`react-flow__background-pattern`,`dots`,t])})}var BI;(function(e){e.Lines=`lines`,e.Dots=`dots`,e.Cross=`cross`})(BI||={});var VI={[BI.Dots]:1,[BI.Lines]:1,[BI.Cross]:6},HI=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function UI({id:e,variant:t=BI.Dots,gap:n=20,size:r,lineWidth:i=1,offset:a=0,color:o,bgColor:s,style:c,className:l,patternClassName:u}){let d=(0,H.useRef)(null),{transform:f,patternId:p}=$(HI,kN),m=r||VI[t],h=t===BI.Dots,g=t===BI.Cross,_=Array.isArray(n)?n:[n,n],v=[_[0]*f[2]||1,_[1]*f[2]||1],y=m*f[2],b=Array.isArray(a)?a:[a,a],x=g?[y,y]:v,S=[b[0]*f[2]+x[0]/2,b[1]*f[2]+x[1]/2],C=`${p}${e||``}`;return(0,U.jsxs)(`svg`,{className:Qw([`react-flow__background`,l]),style:{...c,...IP,"--xy-background-color-props":s,"--xy-background-pattern-color-props":o},ref:d,"data-testid":`rf__background`,children:[(0,U.jsx)(`pattern`,{id:C,x:f[0]%v[0],y:f[1]%v[1],width:v[0],height:v[1],patternUnits:`userSpaceOnUse`,patternTransform:`translate(-${S[0]},-${S[1]})`,children:h?(0,U.jsx)(zI,{radius:y/2,className:u}):(0,U.jsx)(RI,{dimensions:x,lineWidth:i,variant:t,className:u})}),(0,U.jsx)(`rect`,{x:`0`,y:`0`,width:`100%`,height:`100%`,fill:`url(#${C})`})]})}UI.displayName=`Background`;var WI=(0,H.memo)(UI);function GI(){return(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,children:(0,U.jsx)(`path`,{d:`M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z`})})}function KI(){return(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 5`,children:(0,U.jsx)(`path`,{d:`M0 0h32v4.2H0z`})})}function qI(){return(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 30`,children:(0,U.jsx)(`path`,{d:`M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z`})})}function JI(){return(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,U.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z`})})}function YI(){return(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,U.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z`})})}function XI({children:e,className:t,...n}){return(0,U.jsx)(`button`,{type:`button`,className:Qw([`react-flow__controls-button`,t]),...n,children:e})}var ZI=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function QI({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:a,onZoomOut:o,onFitView:s,onInteractiveChange:c,className:l,children:u,position:d=`bottom-left`,orientation:f=`vertical`,"aria-label":p}){let m=NN(),{isInteractive:h,minZoomReached:g,maxZoomReached:_,ariaLabelConfig:v}=$(ZI,kN),{zoomIn:y,zoomOut:b,fitView:x}=jP();return(0,U.jsxs)(UN,{className:Qw([`react-flow__controls`,f===`horizontal`?`horizontal`:`vertical`,l]),position:d,style:e,"data-testid":`rf__controls`,"aria-label":p??v[`controls.ariaLabel`],children:[t&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(XI,{onClick:()=>{y(),a?.()},className:`react-flow__controls-zoomin`,title:v[`controls.zoomIn.ariaLabel`],"aria-label":v[`controls.zoomIn.ariaLabel`],disabled:_,children:(0,U.jsx)(GI,{})}),(0,U.jsx)(XI,{onClick:()=>{b(),o?.()},className:`react-flow__controls-zoomout`,title:v[`controls.zoomOut.ariaLabel`],"aria-label":v[`controls.zoomOut.ariaLabel`],disabled:g,children:(0,U.jsx)(KI,{})})]}),n&&(0,U.jsx)(XI,{className:`react-flow__controls-fitview`,onClick:()=>{x(i),s?.()},title:v[`controls.fitView.ariaLabel`],"aria-label":v[`controls.fitView.ariaLabel`],children:(0,U.jsx)(qI,{})}),r&&(0,U.jsx)(XI,{className:`react-flow__controls-interactive`,onClick:()=>{m.setState({nodesDraggable:!h,nodesConnectable:!h,elementsSelectable:!h}),c?.(!h)},title:v[`controls.interactive.ariaLabel`],"aria-label":v[`controls.interactive.ariaLabel`],children:h?(0,U.jsx)(YI,{}):(0,U.jsx)(JI,{})}),u]})}QI.displayName=`Controls`;var $I=(0,H.memo)(QI);function eL({id:e,x:t,y:n,width:r,height:i,style:a,color:o,strokeColor:s,strokeWidth:c,className:l,borderRadius:u,shapeRendering:d,selected:f,onClick:p}){let{background:m,backgroundColor:h}=a||{},g=o||m||h;return(0,U.jsx)(`rect`,{className:Qw([`react-flow__minimap-node`,{selected:f},l]),x:t,y:n,rx:u,ry:u,width:r,height:i,style:{fill:g,stroke:s,strokeWidth:c},shapeRendering:d,onClick:p?t=>p(t,e):void 0})}var tL=(0,H.memo)(eL),nL=e=>e.nodes.map(e=>e.id),rL=e=>e instanceof Function?e:()=>e;function iL({nodeStrokeColor:e,nodeColor:t,nodeClassName:n=``,nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:a=tL,onClick:o}){let s=$(nL,kN),c=rL(t),l=rL(e),u=rL(n),d=typeof window>`u`||window.chrome?`crispEdges`:`geometricPrecision`;return(0,U.jsx)(U.Fragment,{children:s.map(e=>(0,U.jsx)(oL,{id:e,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:a,onClick:o,shapeRendering:d},e))})}function aL({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:i,nodeStrokeWidth:a,shapeRendering:o,NodeComponent:s,onClick:c}){let{node:l,x:u,y:d,width:f,height:p}=$(t=>{let n=t.nodeLookup.get(e);if(!n)return{node:void 0,x:0,y:0,width:0,height:0};let r=n.internals.userNode,{x:i,y:a}=n.internals.positionAbsolute,{width:o,height:s}=kj(r);return{node:r,x:i,y:a,width:o,height:s}},kN);return!l||l.hidden||!Aj(l)?null:(0,U.jsx)(s,{x:u,y:d,width:f,height:p,style:l.style,selected:!!l.selected,className:r(l),color:t(l),borderRadius:i,strokeColor:n(l),strokeWidth:a,shapeRendering:o,onClick:c,id:l.id})}var oL=(0,H.memo)(aL),sL=(0,H.memo)(iL),cL=200,lL=150,uL=e=>!e.hidden,dL=e=>{let t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]},n=!1;for(let t of e.nodeLookup.values())if(!t.hidden){n=!0;break}return{viewBB:t,boundingRect:n?mj(ZA(e.nodeLookup,{filter:uL}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},fL=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,pL=(e,t)=>fL(e.viewBB,t.viewBB)&&fL(e.boundingRect,t.boundingRect)&&e.rfId===t.rfId&&e.panZoom===t.panZoom&&e.translateExtent===t.translateExtent&&e.flowWidth===t.flowWidth&&e.flowHeight===t.flowHeight&&e.ariaLabelConfig===t.ariaLabelConfig,mL=`react-flow__minimap-desc`;function hL({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:i=``,nodeBorderRadius:a=5,nodeStrokeWidth:o,nodeComponent:s,bgColor:c,maskColor:l,maskStrokeColor:u,maskStrokeWidth:d,position:f=`bottom-right`,onClick:p,onNodeClick:m,pannable:h=!1,zoomable:g=!1,ariaLabel:_,inversePan:v,zoomStep:y=1,offsetScale:b=5}){let x=NN(),S=(0,H.useRef)(null),{boundingRect:C,panZoom:w,viewBB:T,rfId:E,translateExtent:D,flowWidth:O,flowHeight:k,ariaLabelConfig:A}=$(dL,pL),j=e?.width??cL,M=e?.height??lL,N=C.width/j,P=C.height/M,F=Math.max(N,P),I=F*j,L=F*M,R=b*F,ee=C.x-(I-C.width)/2-R,z=C.y-(L-C.height)/2-R,B=I+R*2,te=L+R*2,V=`${mL}-${E}`,ne=(0,H.useRef)(0),re=(0,H.useRef)();ne.current=F,(0,H.useEffect)(()=>{let e=x.getState().panZoom;if(S.current&&e)return re.current=JM({domNode:S.current,panZoom:e,getTransform:()=>x.getState().transform,getViewScale:()=>ne.current}),()=>{re.current?.destroy()}},[w]),(0,H.useEffect)(()=>{re.current?.update({translateExtent:D,width:O,height:k,inversePan:v,pannable:h,zoomStep:y,zoomable:g})},[h,g,v,y,D,O,k]);let ie=p?e=>{let[t,n]=re.current?.pointer(e)||[0,0];p(e,{x:t,y:n})}:void 0,ae=(0,H.useCallback)((e,t)=>{let n=x.getState().nodeLookup.get(t).internals.userNode;m?.(e,n)},[m]),oe=m?ae:void 0,se=_??A[`minimap.ariaLabel`];return(0,U.jsx)(UN,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c==`string`?c:void 0,"--xy-minimap-mask-background-color-props":typeof l==`string`?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof u==`string`?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof d==`number`?d*F:void 0,"--xy-minimap-node-background-color-props":typeof r==`string`?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n==`string`?n:void 0,"--xy-minimap-node-stroke-width-props":typeof o==`number`?o:void 0},className:Qw([`react-flow__minimap`,t]),"data-testid":`rf__minimap`,children:(0,U.jsxs)(`svg`,{width:j,height:M,viewBox:`${ee} ${z} ${B} ${te}`,className:`react-flow__minimap-svg`,role:`img`,"aria-labelledby":V,ref:S,onClick:ie,children:[se&&(0,U.jsx)(`title`,{id:V,children:se}),(0,U.jsx)(sL,{onClick:oe,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:i,nodeStrokeWidth:o,nodeComponent:s}),(0,U.jsx)(`path`,{className:`react-flow__minimap-mask`,d:`M${ee-R},${z-R}h${B+R*2}v${te+R*2}h${-B-R*2}z
|
|
146
|
+
M${T.x},${T.y}h${T.width}v${T.height}h${-T.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}hL.displayName=`MiniMap`,(0,H.memo)(hL);var gL=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,_L={[lN.Line]:`right`,[lN.Handle]:`bottom-right`};function vL({nodeId:e,position:t,variant:n=lN.Handle,className:r,style:i=void 0,children:a,color:o,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:f,autoScale:p=!0,shouldResize:m,onResizeStart:h,onResize:g,onResizeEnd:_}){let v=XP(),y=typeof e==`string`?e:v,b=NN(),x=(0,H.useRef)(null),S=n===lN.Handle,C=$((0,H.useCallback)(gL(S&&p),[S,p]),kN),w=(0,H.useRef)(null),T=t??_L[n];(0,H.useEffect)(()=>{if(!(!x.current||!y))return w.current||=bN({domNode:x.current,nodeId:y,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,domNode:a}=b.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,paneDomNode:a}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:r,parentLookup:i,nodeOrigin:a}=b.getState(),o=[],s={x:e.x,y:e.y},c=r.get(y);if(c&&c.expandParent&&c.parentId){let t=c.origin??a,n=e.width??c.measured.width??0,l=e.height??c.measured.height??0,u=DM([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...jj({x:e.x??c.position.x,y:e.y??c.position.y},{width:n,height:l},c.parentId,r,t)}}],r,i,a);o.push(...u),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*l,e.y):void 0}if(s.x!==void 0&&s.y!==void 0){let e={id:y,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:y,type:`dimensions`,resizing:!0,setAttributes:f?f===`horizontal`?`width`:`height`:!0,dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:`position`};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{let n={id:y,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};b.getState().triggerNodeChanges([n])}}),w.current.update({controlPosition:T,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:_,shouldResize:m}),()=>{w.current?.destroy()}},[T,s,c,l,u,d,h,g,_,m]);let E=T.split(`-`);return(0,U.jsx)(`div`,{className:Qw([`react-flow__resize-control`,`nodrag`,...E,n,r]),ref:x,style:{...i,scale:C,...o&&{[S?`backgroundColor`:`borderColor`]:o}},children:a})}(0,H.memo)(vL);var yL={workflow:TL,loop:wL},bL=[],xL={padding:.08,maxZoom:1},SL=[`true`,`false`,`failure`,`timeout`],CL=[`success`,`failure`,`timeout`];function wL({data:e}){return(0,U.jsx)(`div`,{className:`workflow-loop h-full rounded-lg border border-primary/40 bg-primary/5 p-3 text-xs`,"data-orientation":e.orientation,children:(0,U.jsxs)(`div`,{className:`workflow-loop__summary`,children:[(0,U.jsxs)(`div`,{className:`workflow-loop__heading nodrag nopan`,children:[(0,U.jsxs)(`strong`,{title:e.title,className:`line-clamp-2 min-w-0 text-sm`,children:[`Loop · `,e.title]}),(0,U.jsx)(`span`,{className:`shrink-0`,children:`Max tries`}),(0,U.jsxs)(Rt,{value:e.maxTries,disabled:!e.change,onValueChange:t=>t!==null&&e.change?.(t),children:[(0,U.jsx)(jt,{size:`sm`,"aria-label":`Max tries · ${e.title}`,children:(0,U.jsx)(It,{children:e.maxTries})}),(0,U.jsx)(At,{children:Array.from({length:100},(e,t)=>(0,U.jsx)(Ct,{value:t+1,children:t+1},t+1))})]})]}),(0,U.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:e.progress??`First check included. Inner limits reset on each outer try.`})]})})}function TL({data:e}){let{step:t}=e,n=t.kind===`branch`?SL:CL,r=e.vertical?Q.Bottom:Q.Right;return(0,U.jsxs)(`div`,{"data-status":e.status,"data-orientation":e.vertical?`vertical`:`horizontal`,className:`workflow-step relative rounded-lg border bg-card p-3 text-xs text-card-foreground`,style:{width:208,height:192},children:[(0,U.jsx)(iF,{type:`target`,position:e.vertical?Q.Top:Q.Left}),(0,U.jsx)(`strong`,{title:t.name,className:`block text-sm font-semibold ${e.execution?`line-clamp-2 whitespace-normal`:`truncate`}`,children:t.name}),(0,U.jsxs)(`div`,{className:`text-muted-foreground`,children:[t.kind,` · `,e.permission]}),e.status&&(0,U.jsx)(`div`,{children:e.status.replaceAll(`-`,` `)}),(0,U.jsx)(`div`,{className:`workflow-step__outcomes ${e.vertical?`workflow-step__outcomes--vertical`:`workflow-step__outcomes--horizontal`}`,children:n.map(e=>(0,U.jsxs)(`div`,{className:`workflow-step__outcome`,"data-outcome":e,children:[(0,U.jsx)(`span`,{children:e}),(0,U.jsx)(iF,{id:e,type:`source`,position:r})]},e))})]})}function EL({definition:e,onChange:t,onSelect:n,execution:r,awaitingSteps:i=bL,selectedStepId:a,orientation:o=`horizontal`}){let[s,c]=(0,H.useState)([]),[l,u]=(0,H.useState)([]),d=a!==void 0,f=(0,H.useCallback)(({nodes:e})=>{let t=e.find(e=>e.type===`workflow`);t?n(t.id):d||n(``)},[n,d]),p=r?.id??e,m=(0,H.useMemo)(()=>{let t;try{t=Ww(r?Zw(e,o===`vertical`):e,{orientation:o})}catch{t=e.steps.map((e,t)=>({id:e.id,type:`workflow`,position:e.position??Hw(t),data:{step:e}}))}return{layout:t,edges:e.edges.map(e=>({id:e.id,source:e.from,target:e.to,sourceHandle:e.outcome,label:e.outcome,zIndex:0})),steps:new Map(e.steps.map(e=>[e.id,e]))}},[p,e.id,o]);return(0,H.useEffect)(()=>{let n=new Set(i);c(i=>{let s=new Map(i.map(e=>[e.id,e]));return m.layout.map(i=>{if(i.type===`loop`){let n=i.data.headerId,a=e.loopSettings?.[n]?.maxTries??3;return{...i,data:{title:m.steps.get(n).name,maxTries:a,orientation:o,progress:r?.loops?.[n]?Kw(r.loops[n],a):void 0,change:t?r=>t({...e,loopSettings:{...e.loopSettings,[n]:{maxTries:r}}}):void 0}}}let c=i.data.step;return{...i,selected:a===void 0?s.get(c.id)?.selected:a===c.id,data:{step:c,vertical:!!r&&o===`vertical`,execution:!!r,permission:c.permission??e.permission??`auto-accept`,status:n.has(c.id)?`awaiting-input`:r?.steps[c.id]?.status}}})})},[m,r,a,i,e,t,o]),(0,H.useEffect)(()=>{u(e=>{let t=new Set(e.filter(e=>e.selected).map(e=>e.id));return m.edges.map(e=>({...e,selected:t.has(e.id)}))})},[m]),(0,U.jsx)(`div`,{className:`workflow-canvas overflow-hidden rounded-lg border`,children:(0,U.jsxs)(LI,{nodes:s,edges:l,nodeTypes:yL,onNodesChange:e=>c(t=>pP(e,t)),onEdgesChange:e=>u(t=>mP(e,t)),onConnect:n=>{n.source&&n.target&&t?.({...e,edges:[...e.edges,{id:crypto.randomUUID(),from:n.source,to:n.target,outcome:n.sourceHandle??`success`}]})},onNodeClick:(e,t)=>t.type===`workflow`&&n(t.id),onPaneClick:t&&d?()=>n(``):void 0,onSelectionChange:r||d?void 0:f,onNodeDragStop:(n,r,i)=>t?.({...e,steps:e.steps.map(e=>{let t=(i.length?i:[r]).find(t=>t.id===e.id);return t?{...e,position:Gw(t,s)}:e})}),onDelete:({nodes:n,edges:r})=>t?.(Uw({...e,steps:e.steps.filter(e=>!n.some(t=>t.type===`workflow`&&t.id===e.id)),edges:e.edges.filter(e=>!r.some(t=>t.id===e.id)&&!n.some(t=>t.type===`workflow`&&(t.id===e.from||t.id===e.to)))})),nodesDraggable:!!t,nodesConnectable:!!t,deleteKeyCode:t?[`Backspace`,`Delete`]:null,defaultViewport:{x:32,y:e.loopSettings&&Object.keys(e.loopSettings).length?120:24,zoom:1},minZoom:r?Xw:Yw,fitView:!0,fitViewOptions:xL,zIndexMode:`manual`,children:[(0,U.jsx)(WI,{}),(0,U.jsx)($I,{fitViewOptions:xL})]})})}export{ro as $,Jt as $t,El as A,Br as At,Fo as B,Sn as Bt,ZC as C,ti as Ct,zC as D,Kr as Dt,GC as E,Qr as Et,Jc as F,In as Ft,To as G,cn as Gt,Ao as H,bn as Ht,Gc as I,Fn as It,Za as J,en as Jt,bo as K,on as Kt,Dc as L,Pn as Lt,pl as M,jr as Mt,ul as N,Hn as Nt,Ql as O,Gr as Ot,Zc as P,zn as Pt,to as Q,$t as Qt,Ho as R,jn as Rt,pw as S,li as St,$C as T,$r as Tt,Oo as U,vn as Ut,No as V,xn as Vt,Do as W,rn as Wt,eo as X,Zt as Xt,$a as Y,Xt as Yt,io as Z,Qt as Zt,yw as _,gi as _t,Kw as a,ua as at,Cw as b,ni as bt,Bw as c,Fi as ct,Fw as d,wi as dt,Kt as en,no as et,Mw as f,Oi as ft,_w as g,Ci as gt,bw as h,xi as ht,qw as i,pa as it,hl as j,zr as jt,Al as k,Vr as kt,Lw as l,ji as lt,Dw as m,Si as mt,Jw as n,qt as nn,Ba as nt,zw as o,fa as ot,kw as p,Ei as pt,co as q,tn as qt,Uw as r,da as rt,Rw as s,Ii as st,EL as t,Gt as tn,Qa as tt,Iw as u,Ti as ut,Sw as v,mi as vt,nw as w,ei as wt,vw as x,oi as xt,xw as y,hi as yt,Ro as z,On as zt};
|