@llman-sdd/cli 0.11.0 → 0.12.0
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/package.json +13 -5
- package/src/cli-shared.ts +85 -43
- package/src/commands/archive.ts +0 -9
- package/src/commands/change.ts +71 -33
- package/src/commands/init.ts +9 -11
- package/src/commands/list.ts +0 -2
- package/src/commands/project.ts +0 -6
- package/src/commands/review.ts +0 -1
- package/src/commands/self.ts +3 -1
- package/src/commands/show.ts +8 -46
- package/src/commands/spec.ts +4 -6
- package/src/commands/studio.ts +1315 -0
- package/src/commands/studioMcp.ts +862 -0
- package/src/commands/studioShared.ts +87 -0
- package/src/commands/theorem-write.ts +608 -0
- package/src/commands/theorem.ts +479 -0
- package/src/commands/validate.ts +108 -47
- package/src/io.ts +0 -1
- package/src/main.ts +3 -18
- package/src/program.ts +16 -12
- package/src/progress.ts +1 -3
- package/src/studio-server/changeScope.ts +295 -0
- package/src/studio-server/hub.ts +98 -0
- package/src/studio-server/negotiate.ts +60 -0
- package/src/studio-server/security.ts +71 -0
- package/src/studio-server/server.ts +1694 -0
- package/src/studio-server/static.ts +184 -0
- package/src/studio-server/syncDisk.ts +116 -0
- package/src/theorems/base.ts +53 -0
- package/src/theorems/diagnose.ts +90 -0
- package/src/theorems/draft.ts +252 -0
- package/src/theorems/os-lock.ts +364 -0
- package/src/theorems/paths.ts +11 -0
- package/src/theorems/prompts.ts +79 -0
- package/src/theorems/quiet.ts +21 -0
- package/src/theorems/runner.ts +48 -0
- package/src/theorems/transaction.ts +272 -0
- package/src/theorems/workspace.ts +103 -0
- package/studio-dist/index.html +14 -0
- package/studio-dist/static/css/index.00cf48cf.css +1 -0
- package/studio-dist/static/js/610.51883f69.js +218 -0
- package/studio-dist/static/js/610.51883f69.js.LICENSE.txt +26 -0
- package/studio-dist/static/js/index.c5f7c530.js +13 -0
- package/studio-dist/static/js/lib-react.a4b07007.js +2 -0
- package/studio-dist/static/js/lib-react.a4b07007.js.LICENSE.txt +49 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/*! For license information please see 610.51883f69.js.LICENSE.txt */
|
|
2
|
+
"use strict";(self.webpackChunk_llman_sdd_studio=self.webpackChunk_llman_sdd_studio||[]).push([["610"],{6328(t,r,n){n.d(r,{Ln:()=>tC,PI:()=>k,kW:()=>tL,of:()=>t9,VS:()=>tH,h7:()=>eO,_0:()=>Q,rV:()=>tD,JY:()=>tz,Gc:()=>tN,VH:()=>eh,Pj:()=>$});var i,a,s=n(7462),o=n(7014);function l(t){if("string"==typeof t||"number"==typeof t)return""+t;let r="";if(Array.isArray(t))for(let n=0,i;n<t.length;n++)""!==(i=l(t[n]))&&(r+=(r&&" ")+i);else for(let n in t)t[n]&&(r+=(r&&" ")+n);return r}var c=n(2697),d=n(7863);let u=t=>{let r,n=new Set,i=(t,i)=>{let a="function"==typeof t?t(r):t;if(!Object.is(a,r)){let t=r;r=(null!=i?i:"object"!=typeof a||null===a)?a:Object.assign({},r,a),n.forEach(n=>n(r,t))}},a=()=>r,s={setState:i,getState:a,getInitialState:()=>o,subscribe:t=>(n.add(t),()=>n.delete(t)),destroy:()=>{n.clear()}},o=r=t(i,a,s);return s},{useDebugValue:h}=o,{useSyncExternalStoreWithSelector:f}=d,p=t=>t;function g(t,r=p,n){let i=f(t.subscribe,t.getState,t.getServerState||t.getInitialState,r,n);return h(i),i}let m=(t,r)=>{let n=t?u(t):u,i=(t,i=r)=>g(n,t,i);return Object.assign(i,n),i};function y(t,r){if(Object.is(t,r))return!0;if("object"!=typeof t||null===t||"object"!=typeof r||null===r)return!1;if(t instanceof Map&&r instanceof Map){if(t.size!==r.size)return!1;for(let[n,i]of t)if(!Object.is(i,r.get(n)))return!1;return!0}if(t instanceof Set&&r instanceof Set){if(t.size!==r.size)return!1;for(let n of t)if(!r.has(n))return!1;return!0}let n=Object.keys(t);if(n.length!==Object.keys(r).length)return!1;for(let i of n)if(!Object.prototype.hasOwnProperty.call(r,i)||!Object.is(t[i],r[i]))return!1;return!0}var v=n(6049);let b=(0,o.createContext)(null),x=b.Provider,w=c.xc.error001("react");function $(t,r){let n=(0,o.useContext)(b);if(null===n)throw Error(w);return g(n,t,r)}function k(){let t=(0,o.useContext)(b);if(null===t)throw Error(w);return(0,o.useMemo)(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}let M={display:"none"},_={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},A="react-flow__node-desc",E="react-flow__edge-desc",S=t=>t.ariaLiveMessage,C=t=>t.ariaLabelConfig;function T({rfId:t}){let r=$(S);return(0,s.jsx)("div",{id:`react-flow__aria-live-${t}`,"aria-live":"assertive","aria-atomic":"true",style:_,children:r})}function I({rfId:t,disableKeyboardA11y:r}){let n=$(C);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{id:`${A}-${t}`,style:M,children:r?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),(0,s.jsx)("div",{id:`${E}-${t}`,style:M,children:n["edge.a11yDescription.default"]}),!r&&(0,s.jsx)(T,{rfId:t})]})}let N=(0,o.forwardRef)(({position:t="top-left",children:r,className:n,style:i,...a},o)=>{let c=`${t}`.split("-");return(0,s.jsx)("div",{className:l(["react-flow__panel",n,...c]),style:i,ref:o,...a,children:r})});N.displayName="Panel";let O="https://reactflow.dev?utm_source=attribution";function D({proOptions:t,position:r="bottom-right"}){return((0,o.useEffect)(()=>{},[]),t?.hideAttribution)?null:(0,s.jsx)(N,{position:r,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${O}`,children:(0,s.jsx)("a",{href:O,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}let R=t=>{let r=[],n=[];for(let[,n]of t.nodeLookup)n.selected&&r.push(n.internals.userNode);for(let[,r]of t.edgeLookup)r.selected&&n.push(r);return{selectedNodes:r,selectedEdges:n}},L=t=>t.id;function z(t,r){return y(t.selectedNodes.map(L),r.selectedNodes.map(L))&&y(t.selectedEdges.map(L),r.selectedEdges.map(L))}function P({onSelectionChange:t}){let r=k(),{selectedNodes:n,selectedEdges:i}=$(R,z);return(0,o.useEffect)(()=>{let a={nodes:n,edges:i};t?.(a),r.getState().onSelectionChangeHandlers.forEach(t=>t(a))},[n,i,t]),null}let j=t=>!!t.onSelectionChangeHandlers;function F({onSelectionChange:t}){let r=$(j);return t||r?(0,s.jsx)(P,{onSelectionChange:t}):null}let B=[0,0],W={x:0,y:0,zoom:1},H=["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","rfId"],U=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges}),q={translateExtent:c.ZO,nodeOrigin:B,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function V(t){let{setNodes:r,setEdges:n,setMinZoom:i,setMaxZoom:a,setTranslateExtent:s,setNodeExtent:l,reset:d,setDefaultNodesAndEdges:u}=$(U,y),h=k();(0,o.useEffect)(()=>(u(t.defaultNodes,t.defaultEdges),()=>{f.current=q,d()}),[]);let f=(0,o.useRef)(q);return(0,o.useEffect)(()=>{for(let o of H){let d=t[o];d!==f.current[o]&&void 0!==t[o]&&("nodes"===o?r(d):"edges"===o?n(d):"minZoom"===o?i(d):"maxZoom"===o?a(d):"translateExtent"===o?s(d):"nodeExtent"===o?l(d):"ariaLabelConfig"===o?h.setState({ariaLabelConfig:(0,c.Q6)(d)}):"fitView"===o?h.setState({fitViewQueued:d}):"fitViewOptions"===o?h.setState({fitViewOptions:d}):h.setState({[o]:d}))}f.current=t},H.map(r=>t[r])),null}function Y(){return"u"<typeof window||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}let G="u">typeof document?document:null;function Z(t=null,r={target:G,actInsideInputWithModifier:!0}){let[n,i]=(0,o.useState)(!1),a=(0,o.useRef)(!1),s=(0,o.useRef)(new Set([])),[l,d]=(0,o.useMemo)(()=>{if(null!==t){let r=(Array.isArray(t)?t:[t]).filter(t=>"string"==typeof t).map(t=>t.replace(/\+/g,"\n").replace("\n\n","\n+").split("\n")),n=r.reduce((t,r)=>t.concat(...r),[]);return[r,n]}return[[],[]]},[t]);return(0,o.useEffect)(()=>{let n=r?.target??G,o=r?.actInsideInputWithModifier??!0;if(null!==t){let t=t=>{if(a.current=t.ctrlKey||t.metaKey||t.shiftKey||t.altKey,(!a.current||a.current&&!o)&&(0,c.v5)(t))return!1;let n=K(t.code,d);if(s.current.add(t[n]),X(l,s.current,!1)){let n=t.composedPath?.()?.[0]||t.target,s=n?.nodeName==="BUTTON"||n?.nodeName==="A";!1!==r.preventDefault&&(a.current||!s)&&t.preventDefault(),i(!0)}},u=t=>{let r=K(t.code,d);X(l,s.current,!0)?(i(!1),s.current.clear()):s.current.delete(t[r]),"Meta"===t.key&&s.current.clear(),a.current=!1},h=()=>{s.current.clear(),i(!1)};return n?.addEventListener("keydown",t),n?.addEventListener("keyup",u),window.addEventListener("blur",h),window.addEventListener("contextmenu",h),()=>{n?.removeEventListener("keydown",t),n?.removeEventListener("keyup",u),window.removeEventListener("blur",h),window.removeEventListener("contextmenu",h)}}},[t,i]),n}function X(t,r,n){return t.filter(t=>n||t.length===r.size).some(t=>t.every(t=>r.has(t)))}function K(t,r){return r.includes(t)?"code":"key"}function J(t,r){let n=[],i=new Map,a=[];for(let r of t)if("add"===r.type){a.push(r);continue}else if("remove"===r.type||"replace"===r.type)i.set(r.id,[r]);else{let t=i.get(r.id);t?t.push(r):i.set(r.id,[r])}for(let t of r){let r=i.get(t.id);if(!r){n.push(t);continue}if("remove"===r[0].type)continue;if("replace"===r[0].type){n.push({...r[0].item});continue}let a={...t};for(let t of r){var s=t,o=a;switch(s.type){case"select":o.selected=s.selected;break;case"position":void 0!==s.position&&(o.position=s.position),void 0!==s.dragging&&(o.dragging=s.dragging);break;case"dimensions":void 0!==s.dimensions&&(o.measured={...s.dimensions},s.setAttributes&&((!0===s.setAttributes||"width"===s.setAttributes)&&(o.width=s.dimensions.width),(!0===s.setAttributes||"height"===s.setAttributes)&&(o.height=s.dimensions.height))),"boolean"==typeof s.resizing&&(o.resizing=s.resizing)}}n.push(a)}return a.length&&a.forEach(t=>{void 0!==t.index?n.splice(t.index,0,{...t.item}):n.push({...t.item})}),n}function Q(t,r){return J(t,r)}function ee(t,r){return{id:t,type:"select",selected:r}}function et(t,r=new Set){let n=[];for(let[i,a]of t){let t=r.has(i);(void 0!==a.selected||t)&&a.selected!==t&&n.push(ee(a.id,t))}return n}function er({items:t=[],lookup:r}){let n=[],i=new Map(t.map(t=>[t.id,t]));for(let[i,a]of t.entries()){let t=r.get(a.id),s=t?.internals?.userNode??t;void 0!==s&&s!==a&&n.push({id:a.id,item:a,type:"replace"}),void 0===s&&n.push({item:a,type:"add",index:i})}for(let[t]of r)void 0===i.get(t)&&n.push({id:t,type:"remove"});return n}function en(t){return{id:t.id,type:"remove"}}let ei=(0,c.kr)("React Flow","https://reactflow.dev/"),ea=t=>(0,c.oB)(t);function es(t){return(0,o.forwardRef)(t)}let eo="u">typeof window?o.useLayoutEffect:o.useEffect;function el(t){let[r,n]=(0,o.useState)(BigInt(0)),[i]=(0,o.useState)(()=>{var t;let r;return t=()=>n(t=>t+BigInt(1)),r=[],{get:()=>r,reset:()=>{r=[]},push:n=>{r.push(n),t()}}});return eo(()=>{let r=i.get();r.length&&(t(r),i.reset())},[r]),i}let ec=(0,o.createContext)(null);function ed({children:t}){let r=k(),n=el((0,o.useCallback)(t=>{let{nodes:n=[],setNodes:i,hasDefaultNodes:a,onNodesChange:s,nodeLookup:o,fitViewQueued:l,onNodesChangeMiddlewareMap:c}=r.getState(),d=n;for(let r of t)d="function"==typeof r?r(d):r;let u=er({items:d,lookup:o});for(let t of c.values())u=t(u);a&&i(d),u.length>0?s?.(u):l&&window.requestAnimationFrame(()=>{let{fitViewQueued:t,nodes:n,setNodes:i}=r.getState();t&&i(n)})},[])),i=el((0,o.useCallback)(t=>{let{edges:n=[],setEdges:i,hasDefaultEdges:a,onEdgesChange:s,edgeLookup:o}=r.getState(),l=n;for(let r of t)l="function"==typeof r?r(l):r;a?i(l):s&&s(er({items:l,lookup:o}))},[])),a=(0,o.useMemo)(()=>({nodeQueue:n,edgeQueue:i}),[]);return(0,s.jsx)(ec.Provider,{value:a,children:t})}let eu=t=>!!t.panZoom;function eh(){let t,r=(t=k(),(0,o.useMemo)(()=>({zoomIn:async r=>{let{panZoom:n}=t.getState();return!!n&&n.scaleBy(1.2,r)},zoomOut:async r=>{let{panZoom:n}=t.getState();return!!n&&n.scaleBy(1/1.2,r)},zoomTo:async(r,n)=>{let{panZoom:i}=t.getState();return!!i&&i.scaleTo(r,n)},getZoom:()=>t.getState().transform[2],setViewport:async(r,n)=>{let{transform:[i,a,s],panZoom:o}=t.getState();return!!o&&(await o.setViewport({x:r.x??i,y:r.y??a,zoom:r.zoom??s},n),!0)},getViewport:()=>{let[r,n,i]=t.getState().transform;return{x:r,y:n,zoom:i}},setCenter:async(r,n,i)=>t.getState().setCenter(r,n,i),fitBounds:async(r,n)=>{let{width:i,height:a,minZoom:s,maxZoom:o,panZoom:l}=t.getState(),d=(0,c.R4)(r,i,a,s,o,n?.padding??.1);return!!l&&(await l.setViewport(d,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0)},screenToFlowPosition:(r,n={})=>{let{transform:i,snapGrid:a,snapToGrid:s,domNode:o}=t.getState();if(!o)return r;let{x:l,y:d}=o.getBoundingClientRect(),u={x:r.x-l,y:r.y-d},h=n.snapGrid??a,f=n.snapToGrid??s;return(0,c.Ff)(u,i,f,h)},flowToScreenPosition:r=>{let{transform:n,domNode:i}=t.getState();if(!i)return r;let{x:a,y:s}=i.getBoundingClientRect(),o=(0,c.zj)(r,n);return{x:o.x+a,y:o.y+s}}}),[])),n=k(),i=function(){let t=(0,o.useContext)(ec);if(!t)throw Error("useBatchContext must be used within a BatchProvider");return t}(),a=$(eu),s=(0,o.useMemo)(()=>{let t=t=>n.getState().nodeLookup.get(t),r=t=>{i.nodeQueue.push(t)},a=t=>{i.edgeQueue.push(t)},s=t=>{let{nodeLookup:r,nodeOrigin:i}=n.getState(),a=ea(t)?t:r.get(t.id),s=a.parentId?(0,c.us)(a.position,a.measured,a.parentId,r,i):a.position,o={...a,position:s,width:a.measured?.width??a.width,height:a.measured?.height??a.height};return(0,c.kM)(o,a.parentId?void 0:i)},o=(t,n,i={replace:!1})=>{r(r=>r.map(r=>{if(r.id===t){let t="function"==typeof n?n(r):n;return i.replace&&ea(t)?t:{...r,...t}}return r}))},l=(t,r,n={replace:!1})=>{a(i=>i.map(i=>{if(i.id===t){let t="function"==typeof r?r(i):r;return n.replace&&(0,c.b$)(t)?t:{...i,...t}}return i}))};return{getNodes:()=>n.getState().nodes.map(t=>({...t})),getNode:r=>t(r)?.internals.userNode,getInternalNode:t,getEdges:()=>{let{edges:t=[]}=n.getState();return t.map(t=>({...t}))},getEdge:t=>n.getState().edgeLookup.get(t),setNodes:r,setEdges:a,addNodes:t=>{let r=Array.isArray(t)?t:[t];i.nodeQueue.push(t=>[...t,...r])},addEdges:t=>{let r=Array.isArray(t)?t:[t];i.edgeQueue.push(t=>[...t,...r])},toObject:()=>{let{nodes:t=[],edges:r=[],transform:i}=n.getState(),[a,s,o]=i;return{nodes:t.map(t=>({...t})),edges:r.map(t=>({...t})),viewport:{x:a,y:s,zoom:o}}},deleteElements:async({nodes:t=[],edges:r=[]})=>{let{nodes:i,edges:a,onNodesDelete:s,onEdgesDelete:o,triggerNodeChanges:l,triggerEdgeChanges:d,onDelete:u,onBeforeDelete:h}=n.getState(),{nodes:f,edges:p}=await (0,c.Tq)({nodesToRemove:t,edgesToRemove:r,nodes:i,edges:a,onBeforeDelete:h}),g=p.length>0,m=f.length>0;if(g){let t=p.map(en);o?.(p),d(t)}if(m){let t=f.map(en);s?.(f),l(t)}return(m||g)&&u?.({nodes:f,edges:p}),{deletedNodes:f,deletedEdges:p}},getIntersectingNodes:(t,r=!0,i)=>{let a=(0,c.mW)(t),o=a?t:s(t),l=void 0!==i;if(!o)return[];let{nodeOrigin:d}=n.getState();return(i||n.getState().nodes).filter(i=>{let s=n.getState().nodeLookup.get(i.id);if(s&&!a&&(i.id===t.id||!s.internals.positionAbsolute))return!1;let u=(0,c.kM)(l?i:s,d),h=(0,c.X6)(u,o);return r&&h>0||h>=u.width*u.height||h>=o.width*o.height})},isNodeIntersecting:(t,r,n=!0)=>{let i=(0,c.mW)(t)?t:s(t);if(!i)return!1;let a=(0,c.X6)(i,r);return n&&a>0||a>=r.width*r.height||a>=i.width*i.height},updateNode:o,updateNodeData:(t,r,n={replace:!1})=>{o(t,t=>{let i="function"==typeof r?r(t):r;return n.replace?{...t,data:i}:{...t,data:{...t.data,...i}}},n)},updateEdge:l,updateEdgeData:(t,r,n={replace:!1})=>{l(t,t=>{let i="function"==typeof r?r(t):r;return n.replace?{...t,data:i}:{...t,data:{...t.data,...i}}},n)},getNodesBounds:t=>{let{nodeLookup:r,nodeOrigin:i}=n.getState();return(0,c.Jo)(t,{nodeLookup:r,nodeOrigin:i})},getHandleConnections:({type:t,id:r,nodeId:i})=>Array.from(n.getState().connectionLookup.get(`${i}-${t}${r?`-${r}`:""}`)?.values()??[]),getNodeConnections:({type:t,handleId:r,nodeId:i})=>Array.from(n.getState().connectionLookup.get(`${i}${t?r?`-${t}-${r}`:`-${t}`:""}`)?.values()??[]),fitView:async t=>{let r=n.getState().fitViewResolver??(0,c.YN)();return n.setState({fitViewQueued:!0,fitViewOptions:t,fitViewResolver:r}),i.nodeQueue.push(t=>[...t]),r.promise}}},[]);return(0,o.useMemo)(()=>({...s,...r,viewportInitialized:a}),[a])}let ef=t=>t.selected,ep="u">typeof window?window:void 0,eg={position:"absolute",width:"100%",height:"100%",top:0,left:0},em=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function ey({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:n=!0,panOnScroll:i=!1,panActivationKeyPressed:a,panOnScrollSpeed:l=.5,panOnScrollMode:d=c.ny.Free,zoomOnDoubleClick:u=!0,panOnDrag:h=!0,defaultViewport:f,translateExtent:p,minZoom:g,maxZoom:m,zoomActivationKeyCode:v,preventScrolling:b=!0,children:x,noWheelClassName:w,noPanClassName:M,onViewportChange:_,isControlledViewport:A,paneClickDistance:E,selectionOnDrag:S}){let C,T=k(),I=(0,o.useRef)(null),{userSelectionActive:N,lib:O,connectionInProgress:D}=$(em,y),R=Z(v),L=(0,o.useRef)();C=k(),(0,o.useEffect)(()=>{let t=()=>{if(!I.current||!(I.current.checkVisibility?.()??!0))return!1;let t=(0,c.Eo)(I.current);(0===t.height||0===t.width)&&C.getState().onError?.("004",c.xc.error004()),C.setState({width:t.width||500,height:t.height||500})};if(I.current){t(),window.addEventListener("resize",t);let r=new ResizeObserver(()=>t());return r.observe(I.current),()=>{window.removeEventListener("resize",t),r.disconnect()}}},[]);let z=(0,o.useCallback)(t=>{_?.({x:t[0],y:t[1],zoom:t[2]}),A||T.setState({transform:t})},[_,A]);return(0,o.useEffect)(()=>{if(I.current){L.current=(0,c.kO)({domNode:I.current,minZoom:g,maxZoom:m,translateExtent:p,viewport:f,onDraggingChange:t=>T.setState(r=>r.paneDragging===t?r:{paneDragging:t}),onPanZoomStart:(t,r)=>{let{onViewportChangeStart:n,onMoveStart:i}=T.getState();i?.(t,r),n?.(r)},onPanZoom:(t,r)=>{let{onViewportChange:n,onMove:i}=T.getState();i?.(t,r),n?.(r)},onPanZoomEnd:(t,r)=>{let{onViewportChangeEnd:n,onMoveEnd:i}=T.getState();i?.(t,r),n?.(r)}});let{x:t,y:r,zoom:n}=L.current.getViewport();return T.setState({panZoom:L.current,transform:[t,r,n],domNode:I.current.closest(".react-flow")}),()=>{L.current?.destroy()}}},[]),(0,o.useEffect)(()=>{L.current?.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:n,panOnScroll:i,panActivationKeyPressed:a,panOnScrollSpeed:l,panOnScrollMode:d,zoomOnDoubleClick:u,panOnDrag:h,zoomActivationKeyPressed:R,preventScrolling:b,noPanClassName:M,userSelectionActive:N,noWheelClassName:w,lib:O,onTransformChange:z,connectionInProgress:D,selectionOnDrag:S,paneClickDistance:E})},[t,r,n,i,a,l,d,u,h,R,b,M,N,w,O,z,D,S,E]),(0,s.jsx)("div",{className:"react-flow__renderer",ref:I,style:eg,children:x})}let ev=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function eb(){let{userSelectionActive:t,userSelectionRect:r}=$(ev,y);return t&&r?(0,s.jsx)("div",{className:"react-flow__selection react-flow__container",style:{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}):null}let ex=(t,r)=>n=>{n.target===r.current&&t?.(n)},ew=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function e$({isSelecting:t,selectionKeyPressed:r,selectionMode:n=c.Qc.Full,panOnDrag:i,autoPanOnSelection:a,paneClickDistance:d,selectionOnDrag:u,onSelectionStart:h,onSelectionEnd:f,onPaneClick:p,onPaneContextMenu:g,onPaneScroll:m,onPaneMouseEnter:v,onPaneMouseMove:b,onPaneMouseLeave:x,children:w}){let M=(0,o.useRef)(0),_=k(),{userSelectionActive:A,elementsSelectable:E,dragging:S,panBy:C,autoPanSpeed:T}=$(ew,y),I=E&&(t||A),N=(0,o.useRef)(null),O=(0,o.useRef)(),D=(0,o.useRef)(new Set),R=(0,o.useRef)(new Set),L=(0,o.useRef)(!1),z=(0,o.useRef)(!1),P=(0,o.useRef)({x:0,y:0}),j=(0,o.useRef)(!1),F=t=>{if(z.current||L.current||_.getState().connection.inProgress){z.current=!1,L.current=!1;return}let{connectionClickStartHandle:r,connection:n,onClickConnectEnd:i,resetSelectedElements:a}=_.getState();if(r){let r=structuredClone(n);delete r.inProgress,r.toPosition=r.toHandle?r.toHandle.position:null,i?.(t.nativeEvent,r),_.setState({connectionClickStartHandle:null})}p?.(t),a(),_.setState({nodesSelectionActive:!1})};function B(t,r){let{userSelectionRect:i}=_.getState();if(!i)return;let{transform:a,nodeLookup:s,edgeLookup:o,connectionLookup:l,triggerNodeChanges:d,triggerEdgeChanges:u,defaultEdgeOptions:h}=_.getState(),f={x:i.startX,y:i.startY},{x:p,y:g}=(0,c.zj)(f,a),m={startX:f.x,startY:f.y,x:t<p?t:p,y:r<g?r:g,width:Math.abs(t-p),height:Math.abs(r-g)},y=D.current,v=R.current;D.current=new Set((0,c.U$)(s,m,a,n===c.Qc.Partial,!0).map(t=>t.id)),R.current=new Set;let b=h?.selectable??!0;for(let t of D.current){let r=l.get(t);if(r)for(let{edgeId:t}of r.values()){let r=o.get(t);r&&(r.selectable??b)&&R.current.add(t)}}(0,c._s)(y,D.current)||d(et(s,D.current)),(0,c._s)(v,R.current)||u(et(o,R.current)),_.setState({userSelectionRect:m,userSelectionActive:!0,nodesSelectionActive:!1})}let W=()=>{cancelAnimationFrame(M.current),M.current=0,j.current=!1};(0,o.useEffect)(()=>()=>W(),[]);let H=!0===i||Array.isArray(i)&&i.includes(0);return(0,s.jsxs)("div",{className:l(["react-flow__pane",{draggable:H,dragging:S,selection:t}]),onClick:I?void 0:ex(F,N),onContextMenu:ex(t=>{Array.isArray(i)&&i?.includes(2)?t.preventDefault():g?.(t)},N),onWheel:ex(m?t=>m(t):void 0,N),onPointerEnter:I?void 0:v,onPointerMove:I?t=>{let{userSelectionRect:n,transform:i,resetSelectedElements:s}=_.getState();if(!O.current||!n)return;let{x:o,y:l}=(0,c.q1)(t.nativeEvent,O.current);P.current={x:o,y:l};let u=(0,c.zj)({x:n.startX,y:n.startY},i);if(!z.current){if(Math.hypot(o-u.x,l-u.y)<=(r?0:d))return;s(),h?.(t)}z.current=!0,j.current||(!function t(){if(!a||!O.current)return;let[r,n]=(0,c._7)(P.current,O.current,T);C({x:r,y:n}).then(r=>{if(!z.current||!r){M.current=requestAnimationFrame(t);return}let{x:n,y:i}=P.current;B(n,i),M.current=requestAnimationFrame(t)})}(),j.current=!0),B(o,l)}:b,onPointerUp:t=>{if(!I){t.target===N.current&&_.getState().connection.inProgress&&(L.current=!0);return}0===t.button&&(t.target?.releasePointerCapture?.(t.pointerId),!A&&t.target===N.current&&_.getState().userSelectionRect&&F?.(t),_.setState({userSelectionActive:!1,userSelectionRect:null}),z.current&&(f?.(t),_.setState({nodesSelectionActive:D.current.size>0})),W())},onPointerCancel:I?t=>{t.target?.releasePointerCapture?.(t.pointerId),W()}:void 0,onPointerDownCapture:I?n=>{if("touch"===n.pointerType&&!1!==i&&!r)return;let{domNode:a,transform:s}=_.getState();if(O.current=a?.getBoundingClientRect(),!O.current)return;let o=n.target===N.current;if(!o&&n.target.closest(".nokey")||!t||!(u&&o||r)||0!==n.button||!n.isPrimary)return;n.target?.setPointerCapture?.(n.pointerId),z.current=!1;let{x:l,y:d}=(0,c.q1)(n.nativeEvent,O.current),h=(0,c.Ff)({x:l,y:d},s);_.setState({userSelectionRect:{width:0,height:0,startX:h.x,startY:h.y,x:l,y:d}}),o||(n.stopPropagation(),n.preventDefault())}:void 0,onClickCapture:I?t=>{z.current&&(t.stopPropagation(),z.current=!1)}:void 0,onPointerLeave:x,ref:N,style:eg,children:[w,(0,s.jsx)(eb,{})]})}function ek({id:t,store:r,unselect:n=!1,nodeRef:i}){let{addSelectedNodes:a,unselectNodesAndEdges:s,multiSelectionActive:o,nodeLookup:l,onError:d}=r.getState(),u=l.get(t);u?(r.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&o)&&(s({nodes:[u],edges:[]}),requestAnimationFrame(()=>i?.current?.blur())):a([t])):d?.("012",c.xc.error012(t))}function eM({nodeRef:t,disabled:r=!1,noDragClassName:n,handleSelector:i,nodeId:a,isSelectable:s,nodeClickDistance:l}){let d=k(),[u,h]=(0,o.useState)(!1),f=(0,o.useRef)();return(0,o.useEffect)(()=>{if(!r)return f.current=(0,c.I$)({getStoreItems:()=>d.getState(),onNodeMouseDown:r=>{ek({id:r,store:d,nodeRef:t})},onDragStart:()=>{h(!0)},onDragStop:()=>{h(!1)}}),()=>{f.current?.destroy(),f.current=void 0}},[r,d,t]),(0,o.useEffect)(()=>{!r&&t.current&&f.current&&f.current.update({noDragClassName:n,handleSelector:i,domNode:t.current,isSelectable:s,nodeId:a,nodeClickDistance:l})},[n,i,r,s,t,a,l]),u}function e_(){let t=k();return(0,o.useCallback)(r=>{let{nodeExtent:n,snapToGrid:i,snapGrid:a,nodesDraggable:s,onError:o,updateNodePositions:l,nodeLookup:d,nodeOrigin:u}=t.getState(),h=new Map,f=t=>t.selected&&(t.draggable||s&&void 0===t.draggable),p=i?a[0]:5,g=i?a[1]:5,m=r.direction.x*p*r.factor,y=r.direction.y*g*r.factor;for(let[,t]of d){if(!f(t))continue;let r={x:t.internals.positionAbsolute.x+m,y:t.internals.positionAbsolute.y+y};i&&(r=(0,c.s_)(r,a));let{position:s,positionAbsolute:l}=(0,c.aE)({nodeId:t.id,nextPosition:r,nodeLookup:d,nodeExtent:n,nodeOrigin:u,onError:o});t.position=s,t.internals.positionAbsolute=l,h.set(t.id,t)}l(h)},[])}let eA=(0,o.createContext)(null),eE=eA.Provider;eA.Consumer;let eS=()=>(0,o.useContext)(eA),eC=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),eT=(0,o.createContext)(null);function eI({children:t}){let r=$(eC,y);return(0,s.jsx)(eT.Provider,{value:r,children:t})}let eN={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},eO=(0,o.memo)(es(function({type:t="source",position:r=c.yX.Top,isValidConnection:n,isConnectable:i=!0,isConnectableStart:a=!0,isConnectableEnd:d=!0,id:u,onConnect:h,children:f,className:p,onMouseDown:g,onTouchStart:m,...v},b){let x=u||null,w="target"===t,M=k(),_=eS(),{connectOnClick:A,noPanClassName:E,rfId:S}=function(){let t=(0,o.useContext)(eT);if(!t)throw Error("useHandleConfig must be used within a HandleConfigProvider");return t}(),{connectingFrom:C,connectingTo:T,clickConnecting:I,isPossibleEndHandle:N,connectionInProcess:O,clickConnectionInProcess:D,valid:R}=$(r=>{let{connectionClickStartHandle:n,connectionMode:i,connection:a}=r,{fromHandle:s,toHandle:o,isValid:l}=a;if(!s&&!n)return eN;let d=o?.nodeId===_&&o?.id===x&&o?.type===t;return{connectingFrom:s?.nodeId===_&&s?.id===x&&s?.type===t,connectingTo:d,clickConnecting:n?.nodeId===_&&n?.id===x&&n?.type===t,isPossibleEndHandle:i===c.WZ.Strict?s?.type!==t:_!==s?.nodeId||x!==s?.id,connectionInProcess:!!s,clickConnectionInProcess:!!n,valid:d&&l}},y);_||M.getState().onError?.("010",c.xc.error010());let L=t=>{let{defaultEdgeOptions:r,onConnect:n,hasDefaultEdges:i}=M.getState(),a={...r,...t};if(i){let{edges:t,setEdges:r,onError:n}=M.getState();r(function(t,r,n={}){return(0,c.rN)(t,r,{...n,onError:n.onError??ei})}(a,t,{onError:n}))}n?.(a),h?.(a)},z=t=>{if(!_)return;let r=(0,c.Er)(t.nativeEvent);if(a&&(r&&0===t.button||!r)){let r=M.getState();c.aQ.onPointerDown(t.nativeEvent,{handleDomNode:t.currentTarget,autoPanOnConnect:r.autoPanOnConnect,connectionMode:r.connectionMode,connectionRadius:r.connectionRadius,domNode:r.domNode,nodeLookup:r.nodeLookup,lib:r.lib,isTarget:w,handleId:x,nodeId:_,flowId:r.rfId,panBy:r.panBy,cancelConnection:r.cancelConnection,onConnectStart:r.onConnectStart,onConnectEnd:(...t)=>M.getState().onConnectEnd?.(...t),updateConnection:r.updateConnection,onConnect:L,isValidConnection:n||((...t)=>M.getState().isValidConnection?.(...t)??!0),getTransform:()=>M.getState().transform,getFromHandle:()=>M.getState().connection.fromHandle,autoPanSpeed:r.autoPanSpeed,dragThreshold:r.connectionDragThreshold})}r?g?.(t):m?.(t)};return(0,s.jsx)("div",{"data-handleid":x,"data-nodeid":_,"data-handlepos":r,"data-id":`${S}-${_}-${x}-${t}`,className:l(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",E,p,{source:!w,target:w,connectable:i,connectablestart:a,connectableend:d,clickconnecting:I,connectingfrom:C,connectingto:T,valid:R,connectionindicator:i&&(!O||N)&&(O||D?d:a)}]),onMouseDown:z,onTouchStart:z,onClick:A?r=>{let{onClickConnectStart:i,onClickConnectEnd:s,connectionClickStartHandle:o,connectionMode:l,isValidConnection:d,lib:u,rfId:h,nodeLookup:f,connection:p}=M.getState();if(!_||!o&&!a)return;if(!o){i?.(r.nativeEvent,{nodeId:_,handleId:x,handleType:t}),M.setState({connectionClickStartHandle:{nodeId:_,type:t,id:x}});return}let g=(0,c.oj)(r.target),m=n||d,{connection:y,isValid:v}=c.aQ.isValid(r.nativeEvent,{handle:{nodeId:_,id:x,type:t},connectionMode:l,fromNodeId:o.nodeId,fromHandleId:o.id||null,fromType:o.type,isValidConnection:m,flowId:h,doc:g,lib:u,nodeLookup:f});v&&y&&L(y);let b=structuredClone(p);delete b.inProgress,b.toPosition=b.toHandle?b.toHandle.position:null,s?.(r,b),M.setState({connectionClickStartHandle:null})}:void 0,ref:b,...v,children:f})})),eD={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},eR={input:function({data:t,isConnectable:r,sourcePosition:n=c.yX.Bottom}){return(0,s.jsxs)(s.Fragment,{children:[t?.label,(0,s.jsx)(eO,{type:"source",position:n,isConnectable:r})]})},default:function({data:t,isConnectable:r,targetPosition:n=c.yX.Top,sourcePosition:i=c.yX.Bottom}){return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(eO,{type:"target",position:n,isConnectable:r}),t?.label,(0,s.jsx)(eO,{type:"source",position:i,isConnectable:r})]})},output:function({data:t,isConnectable:r,targetPosition:n=c.yX.Top}){return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(eO,{type:"target",position:n,isConnectable:r}),t?.label]})},group:function(){return null}},eL=t=>{let{width:r,height:n,x:i,y:a}=(0,c.aZ)(t.nodeLookup,{filter:t=>!!t.selected});return{width:(0,c.kf)(r)?r:null,height:(0,c.kf)(n)?n:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${i}px,${a}px)`}};function ez({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:n}){let i=k(),{width:a,height:c,transformString:d,userSelectionActive:u}=$(eL,y),h=e_(),f=(0,o.useRef)(null);(0,o.useEffect)(()=>{n||f.current?.focus({preventScroll:!0})},[n]);let p=!u&&null!==a&&null!==c;if(eM({nodeRef:f,disabled:!p}),!p)return null;let g=t?r=>{t(r,i.getState().nodes.filter(t=>t.selected))}:void 0;return(0,s.jsx)("div",{className:l(["react-flow__nodesselection","react-flow__container",r]),style:{transform:d},children:(0,s.jsx)("div",{ref:f,className:"react-flow__nodesselection-rect",onContextMenu:g,tabIndex:n?void 0:-1,onKeyDown:n?void 0:t=>{Object.prototype.hasOwnProperty.call(eD,t.key)&&(t.preventDefault(),h({direction:eD[t.key],factor:t.shiftKey?4:1}))},style:{width:a,height:c}})})}let eP="u">typeof window?window:void 0,ej=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function eF({children:t,onPaneClick:r,onPaneMouseEnter:n,onPaneMouseMove:i,onPaneMouseLeave:a,onPaneContextMenu:l,onPaneScroll:c,paneClickDistance:d,deleteKeyCode:u,selectionKeyCode:h,selectionOnDrag:f,selectionMode:p,onSelectionStart:g,onSelectionEnd:m,multiSelectionKeyCode:v,panActivationKeyCode:b,zoomActivationKeyCode:x,elementsSelectable:w,zoomOnScroll:M,zoomOnPinch:_,panOnScroll:A,panOnScrollSpeed:E,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:T,autoPanOnSelection:I,defaultViewport:N,translateExtent:O,minZoom:D,maxZoom:R,preventScrolling:L,onSelectionContextMenu:z,noWheelClassName:P,noPanClassName:j,disableKeyboardA11y:F,onViewportChange:B,isControlledViewport:W}){let{nodesSelectionActive:H,userSelectionActive:U}=$(ej,y),q=Z(h,{target:eP}),V=Z(b,{target:eP}),Y=V||T,G=V||A,X=f&&!0!==Y,K=q||U||X;return!function({deleteKeyCode:t,multiSelectionKeyCode:r}){let n=k(),{deleteElements:i}=eh(),a=Z(t,{actInsideInputWithModifier:!1}),s=Z(r,{target:ep});(0,o.useEffect)(()=>{if(a){let{edges:t,nodes:r}=n.getState();i({nodes:r.filter(ef),edges:t.filter(ef)}),n.setState({nodesSelectionActive:!1})}},[a]),(0,o.useEffect)(()=>{n.setState({multiSelectionActive:s})},[s])}({deleteKeyCode:u,multiSelectionKeyCode:v}),(0,s.jsx)(ey,{onPaneContextMenu:l,elementsSelectable:w,zoomOnScroll:M,zoomOnPinch:_,panOnScroll:G,panActivationKeyPressed:V,panOnScrollSpeed:E,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:!q&&Y,defaultViewport:N,translateExtent:O,minZoom:D,maxZoom:R,zoomActivationKeyCode:x,preventScrolling:L,noWheelClassName:P,noPanClassName:j,onViewportChange:B,isControlledViewport:W,paneClickDistance:d,selectionOnDrag:X,children:(0,s.jsxs)(e$,{onSelectionStart:g,onSelectionEnd:m,onPaneClick:r,onPaneMouseEnter:n,onPaneMouseMove:i,onPaneMouseLeave:a,onPaneContextMenu:l,onPaneScroll:c,panOnDrag:Y,autoPanOnSelection:I,isSelecting:!!K,selectionMode:p,selectionKeyPressed:q,paneClickDistance:d,selectionOnDrag:X,children:[t,H&&(0,s.jsx)(ez,{onSelectionContextMenu:z,noPanClassName:j,disableKeyboardA11y:F})]})})}eF.displayName="FlowRenderer";let eB=(0,o.memo)(eF),eW=t=>t.updateNodeInternals;var eH=(0,o.memo)(function({id:t,onClick:r,onMouseEnter:n,onMouseMove:i,onMouseLeave:a,onContextMenu:d,onDoubleClick:u,nodesDraggable:h,elementsSelectable:f,nodesConnectable:p,nodesFocusable:g,resizeObserver:m,noDragClassName:v,noPanClassName:b,disableKeyboardA11y:x,rfId:w,nodeTypes:M,nodeClickDistance:_,onError:E}){let{node:S,internals:C,isParent:T}=$(r=>{let n=r.nodeLookup.get(t),i=r.parentLookup.has(t);return{node:n,internals:n.internals,isParent:i}},y),I=S.type||"default",N=M?.[I]||eR[I];void 0===N&&(E?.("003",c.xc.error003(I)),I="default",N=M?.default||eR.default);let O=!!(S.draggable||h&&void 0===S.draggable),D=!!(S.selectable||f&&void 0===S.selectable),R=!!(S.connectable||p&&void 0===S.connectable),L=!!(S.focusable||g&&void 0===S.focusable),z=k(),P=(0,c.QE)(S),j=function({node:t,nodeType:r,hasDimensions:n,resizeObserver:i}){let a=k(),s=(0,o.useRef)(null),l=(0,o.useRef)(null),c=(0,o.useRef)(t.sourcePosition),d=(0,o.useRef)(t.targetPosition),u=(0,o.useRef)(r),h=n&&!!t.internals.handleBounds;return(0,o.useEffect)(()=>{!s.current||t.hidden||h&&l.current===s.current||(l.current&&i?.unobserve(l.current),i?.observe(s.current),l.current=s.current)},[h,t.hidden]),(0,o.useEffect)(()=>()=>{l.current&&(i?.unobserve(l.current),l.current=null)},[]),(0,o.useEffect)(()=>{if(s.current){let n=u.current!==r,i=c.current!==t.sourcePosition,o=d.current!==t.targetPosition;(n||i||o)&&(u.current=r,c.current=t.sourcePosition,d.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:s.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),s}({node:S,nodeType:I,hasDimensions:P,resizeObserver:m}),F=eM({nodeRef:j,disabled:S.hidden||!O,noDragClassName:v,handleSelector:S.dragHandle,nodeId:t,isSelectable:D,nodeClickDistance:_}),B=e_();if(S.hidden)return null;let W=(0,c.uD)(S),H=void 0===S.internals.handleBounds?{width:S.width??S.initialWidth??S.style?.width,height:S.height??S.initialHeight??S.style?.height}:{width:S.width??S.style?.width,height:S.height??S.style?.height},U=D||O||r||n||i||a,q=n?t=>n(t,{...C.userNode}):void 0,V=i?t=>i(t,{...C.userNode}):void 0,Y=a?t=>a(t,{...C.userNode}):void 0,G=d?t=>d(t,{...C.userNode}):void 0,Z=u?t=>u(t,{...C.userNode}):void 0;return(0,s.jsx)("div",{className:l(["react-flow__node",`react-flow__node-${I}`,{[b]:O},S.className,{selected:S.selected,selectable:D,parent:T,draggable:O,dragging:F}]),ref:j,style:{zIndex:C.z,transform:`translate(${C.positionAbsolute.x}px,${C.positionAbsolute.y}px)`,pointerEvents:U?"all":"none",visibility:P?"visible":"hidden",...S.style,...H},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:q,onMouseMove:V,onMouseLeave:Y,onContextMenu:G,onClick:n=>{let{selectNodesOnDrag:i,nodeDragThreshold:a}=z.getState();D&&(!i||!O||a>0)&&ek({id:t,store:z,nodeRef:j}),r&&r(n,{...C.userNode})},onDoubleClick:Z,onKeyDown:L?r=>{if(!(0,c.v5)(r.nativeEvent)&&!x){if(c.tn.includes(r.key)&&D)ek({id:t,store:z,unselect:"Escape"===r.key,nodeRef:j});else if(O&&S.selected&&Object.prototype.hasOwnProperty.call(eD,r.key)){r.preventDefault();let{ariaLabelConfig:t}=z.getState();z.setState({ariaLiveMessage:t["node.a11yDescription.ariaLiveMessage"]({direction:r.key.replace("Arrow","").toLowerCase(),x:~~C.positionAbsolute.x,y:~~C.positionAbsolute.y})}),B({direction:eD[r.key],factor:r.shiftKey?4:1})}}}:void 0,tabIndex:L?0:void 0,onFocus:L?()=>{if(x||!j.current?.matches(":focus-visible"))return;let{transform:r,width:n,height:i,autoPanOnNodeFocus:a,setCenter:s}=z.getState();!a||(0,c.U$)(new Map([[t,S]]),{x:0,y:0,width:n,height:i},r,!0).length>0||s(S.position.x+W.width/2,S.position.y+W.height/2,{zoom:r[2]})}:void 0,role:S.ariaRole??(L?"group":void 0),"aria-roledescription":"node","aria-describedby":x?void 0:`${A}-${w}`,"aria-label":S.ariaLabel,...S.domAttributes,children:(0,s.jsx)(eE,{value:t,children:(0,s.jsx)(N,{id:t,data:S.data,type:I,positionAbsoluteX:C.positionAbsolute.x,positionAbsoluteY:C.positionAbsolute.y,selected:S.selected??!1,selectable:D,draggable:O,deletable:S.deletable??!0,isConnectable:R,sourcePosition:S.sourcePosition,targetPosition:S.targetPosition,dragging:F,dragHandle:S.dragHandle,zIndex:C.z,parentId:S.parentId,...W})})})});let eU=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function eq(t){var r;let{nodesConnectable:n,nodesFocusable:i,elementsSelectable:a,onError:l}=$(eU,y),d=(r=t.onlyRenderVisibleElements,$((0,o.useCallback)(t=>r?(0,c.U$)(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(t=>t.id):Array.from(t.nodeLookup.keys()),[r]),y)),u=function(){let t=$(eW),[r]=(0,o.useState)(()=>"u"<typeof ResizeObserver?null:new ResizeObserver(r=>{let n=new Map;r.forEach(t=>{let r=t.target.getAttribute("data-id");n.set(r,{id:r,nodeElement:t.target,force:!0})}),t(n)}));return(0,o.useEffect)(()=>()=>{r?.disconnect()},[r]),r}();return(0,s.jsx)("div",{className:"react-flow__nodes",style:eg,children:d.map(r=>(0,s.jsx)(eH,{id:r,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:u,nodesDraggable:t.nodesDraggable??!0,nodesConnectable:n,nodesFocusable:i,elementsSelectable:a,nodeClickDistance:t.nodeClickDistance,onError:l},r))})}eq.displayName="NodeRenderer";let eV=(0,o.memo)(eq),eY={[c.TG.Arrow]:({color:t="none",strokeWidth:r=1})=>{let n={strokeWidth:r,...t&&{stroke:t}};return(0,s.jsx)("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},[c.TG.ArrowClosed]:({color:t="none",strokeWidth:r=1})=>{let n={strokeWidth:r,...t&&{stroke:t,fill:t}};return(0,s.jsx)("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})}},eG=({id:t,type:r,color:n,width:i=12.5,height:a=12.5,markerUnits:l="strokeWidth",strokeWidth:d,orient:u="auto-start-reverse"})=>{let h,f=(h=k(),(0,o.useMemo)(()=>Object.prototype.hasOwnProperty.call(eY,r)?eY[r]:(h.getState().onError?.("009",c.xc.error009(r)),null),[r]));return f?(0,s.jsx)("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${i}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:l,orient:u,refX:"0",refY:"0",children:(0,s.jsx)(f,{color:n,strokeWidth:d})}):null},eZ=({defaultColor:t,rfId:r})=>{let n=$(t=>t.edges),i=$(t=>t.defaultEdgeOptions),a=(0,o.useMemo)(()=>(0,c.Hm)(n,{id:r,defaultColor:t,defaultMarkerStart:i?.markerStart,defaultMarkerEnd:i?.markerEnd}),[n,i,r,t]);return a.length?(0,s.jsx)("svg",{className:"react-flow__marker","aria-hidden":"true",children:(0,s.jsx)("defs",{children:a.map(t=>(0,s.jsx)(eG,{id:t.id,type:t.type,color:t.color,width:t.width,height:t.height,markerUnits:t.markerUnits,strokeWidth:t.strokeWidth,orient:t.orient},t.id))})}):null};eZ.displayName="MarkerDefinitions";var eX=(0,o.memo)(eZ);function eK({x:t,y:r,label:n,labelStyle:i,labelShowBg:a=!0,labelBgStyle:c,labelBgPadding:d=[2,4],labelBgBorderRadius:u=2,children:h,className:f,...p}){let[g,m]=(0,o.useState)({x:1,y:0,width:0,height:0}),y=l(["react-flow__edge-textwrapper",f]),v=(0,o.useRef)(null);return((0,o.useEffect)(()=>{if(v.current){let t=v.current.getBBox();m({x:t.x,y:t.y,width:t.width,height:t.height})}},[n]),n)?(0,s.jsxs)("g",{transform:`translate(${t-g.width/2} ${r-g.height/2})`,className:y,visibility:g.width?"visible":"hidden",...p,children:[a&&(0,s.jsx)("rect",{width:g.width+2*d[0],x:-d[0],y:-d[1],height:g.height+2*d[1],className:"react-flow__edge-textbg",style:c,rx:u,ry:u}),(0,s.jsx)("text",{className:"react-flow__edge-text",y:g.height/2,dy:"0.3em",ref:v,style:i,children:n}),h]}):null}eK.displayName="EdgeText";let eJ=(0,o.memo)(eK);function eQ({path:t,labelX:r,labelY:n,label:i,labelStyle:a,labelShowBg:o,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:h,interactionWidth:f=20,...p}){return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("path",{...p,d:t,fill:"none",className:l(["react-flow__edge-path",p.className])}),f?(0,s.jsx)("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:f,className:"react-flow__edge-interaction"}):null,i&&(0,c.kf)(r)&&(0,c.kf)(n)?(0,s.jsx)(eJ,{x:r,y:n,label:i,labelStyle:a,labelShowBg:o,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:h}):null]})}function e0({pos:t,x1:r,y1:n,x2:i,y2:a}){return t===c.yX.Left||t===c.yX.Right?[.5*(r+i),n]:[r,.5*(n+a)]}function e1({sourceX:t,sourceY:r,sourcePosition:n=c.yX.Bottom,targetX:i,targetY:a,targetPosition:s=c.yX.Top}){let[o,l]=e0({pos:n,x1:t,y1:r,x2:i,y2:a}),[d,u]=e0({pos:s,x1:i,y1:a,x2:t,y2:r}),[h,f,p,g]=(0,c.e_)({sourceX:t,sourceY:r,targetX:i,targetY:a,sourceControlX:o,sourceControlY:l,targetControlX:d,targetControlY:u});return[`M${t},${r} C${o},${l} ${d},${u} ${i},${a}`,h,f,p,g]}function e2(t){return(0,o.memo)(({id:r,sourceX:n,sourceY:i,targetX:a,targetY:o,sourcePosition:l,targetPosition:c,label:d,labelStyle:u,labelShowBg:h,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:g,style:m,markerEnd:y,markerStart:v,interactionWidth:b})=>{let[x,w,$]=e1({sourceX:n,sourceY:i,sourcePosition:l,targetX:a,targetY:o,targetPosition:c}),k=t.isInternal?void 0:r;return(0,s.jsx)(eQ,{id:k,path:x,labelX:w,labelY:$,label:d,labelStyle:u,labelShowBg:h,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:g,style:m,markerEnd:y,markerStart:v,interactionWidth:b})})}let e4=e2({isInternal:!1}),e3=e2({isInternal:!0});function e5(t){return(0,o.memo)(({id:r,sourceX:n,sourceY:i,targetX:a,targetY:o,label:l,labelStyle:d,labelShowBg:u,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:g,sourcePosition:m=c.yX.Bottom,targetPosition:y=c.yX.Top,markerEnd:v,markerStart:b,pathOptions:x,interactionWidth:w})=>{let[$,k,M]=(0,c.oN)({sourceX:n,sourceY:i,sourcePosition:m,targetX:a,targetY:o,targetPosition:y,borderRadius:x?.borderRadius,offset:x?.offset,stepPosition:x?.stepPosition}),_=t.isInternal?void 0:r;return(0,s.jsx)(eQ,{id:_,path:$,labelX:k,labelY:M,label:l,labelStyle:d,labelShowBg:u,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:g,markerEnd:v,markerStart:b,interactionWidth:w})})}e4.displayName="SimpleBezierEdge",e3.displayName="SimpleBezierEdgeInternal";let e6=e5({isInternal:!1}),e8=e5({isInternal:!0});function e9(t){return(0,o.memo)(({id:r,...n})=>{let i=t.isInternal?void 0:r;return(0,s.jsx)(e6,{...n,id:i,pathOptions:(0,o.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}e6.displayName="SmoothStepEdge",e8.displayName="SmoothStepEdgeInternal";let e7=e9({isInternal:!1}),te=e9({isInternal:!0});function tt(t){return(0,o.memo)(({id:r,sourceX:n,sourceY:i,targetX:a,targetY:o,label:l,labelStyle:d,labelShowBg:u,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:g,markerEnd:m,markerStart:y,interactionWidth:v})=>{let[b,x,w]=(0,c.ah)({sourceX:n,sourceY:i,targetX:a,targetY:o}),$=t.isInternal?void 0:r;return(0,s.jsx)(eQ,{id:$,path:b,labelX:x,labelY:w,label:l,labelStyle:d,labelShowBg:u,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:g,markerEnd:m,markerStart:y,interactionWidth:v})})}e7.displayName="StepEdge",te.displayName="StepEdgeInternal";let tr=tt({isInternal:!1}),tn=tt({isInternal:!0});function ti(t){return(0,o.memo)(({id:r,sourceX:n,sourceY:i,targetX:a,targetY:o,sourcePosition:l=c.yX.Bottom,targetPosition:d=c.yX.Top,label:u,labelStyle:h,labelShowBg:f,labelBgStyle:p,labelBgPadding:g,labelBgBorderRadius:m,style:y,markerEnd:v,markerStart:b,pathOptions:x,interactionWidth:w})=>{let[$,k,M]=(0,c.Fp)({sourceX:n,sourceY:i,sourcePosition:l,targetX:a,targetY:o,targetPosition:d,curvature:x?.curvature}),_=t.isInternal?void 0:r;return(0,s.jsx)(eQ,{id:_,path:$,labelX:k,labelY:M,label:u,labelStyle:h,labelShowBg:f,labelBgStyle:p,labelBgPadding:g,labelBgBorderRadius:m,style:y,markerEnd:v,markerStart:b,interactionWidth:w})})}tr.displayName="StraightEdge",tn.displayName="StraightEdgeInternal";let ta=ti({isInternal:!1}),ts=ti({isInternal:!0});ta.displayName="BezierEdge",ts.displayName="BezierEdgeInternal";let to={default:ts,straight:tn,step:te,smoothstep:e8,simplebezier:e3},tl={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},tc="react-flow__edgeupdater";function td({position:t,centerX:r,centerY:n,radius:i=10,onMouseDown:a,onMouseEnter:o,onMouseOut:d,type:u}){return(0,s.jsx)("circle",{onMouseDown:a,onMouseEnter:o,onMouseOut:d,className:l([tc,`${tc}-${u}`]),cx:t===c.yX.Left?r-i:t===c.yX.Right?r+i:r,cy:t===c.yX.Top?n-i:t===c.yX.Bottom?n+i:n,r:i,stroke:"transparent",fill:"transparent"})}function tu({isReconnectable:t,reconnectRadius:r,edge:n,sourceX:i,sourceY:a,targetX:o,targetY:l,sourcePosition:d,targetPosition:u,onReconnect:h,onReconnectStart:f,onReconnectEnd:p,setReconnecting:g,setUpdateHover:m}){let y=k(),v=(t,r)=>{if(0!==t.button)return;let{autoPanOnConnect:i,domNode:a,connectionMode:s,connectionRadius:o,lib:l,onConnectStart:d,cancelConnection:u,nodeLookup:m,rfId:v,panBy:b,updateConnection:x}=y.getState(),w="target"===r.type;c.aQ.onPointerDown(t.nativeEvent,{autoPanOnConnect:i,connectionMode:s,connectionRadius:o,domNode:a,handleId:r.id,nodeId:r.nodeId,nodeLookup:m,isTarget:w,edgeUpdaterType:r.type,lib:l,flowId:v,cancelConnection:u,panBy:b,isValidConnection:(...t)=>y.getState().isValidConnection?.(...t)??!0,onConnect:t=>h?.(n,t),onConnectStart:(i,a)=>{g(!0),f?.(t,n,r.type),d?.(i,a)},onConnectEnd:(...t)=>y.getState().onConnectEnd?.(...t),onReconnectEnd:(t,i)=>{g(!1),p?.(t,n,r.type,i)},updateConnection:x,getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,dragThreshold:y.getState().connectionDragThreshold,handleDomNode:t.currentTarget})},b=()=>m(!0),x=()=>m(!1);return(0,s.jsxs)(s.Fragment,{children:[(!0===t||"source"===t)&&(0,s.jsx)(td,{position:d,centerX:i,centerY:a,radius:r,onMouseDown:t=>v(t,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),onMouseEnter:b,onMouseOut:x,type:"source"}),(!0===t||"target"===t)&&(0,s.jsx)(td,{position:u,centerX:o,centerY:l,radius:r,onMouseDown:t=>v(t,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),onMouseEnter:b,onMouseOut:x,type:"target"})]})}var th=(0,o.memo)(function({id:t,edgesFocusable:r,edgesReconnectable:n,elementsSelectable:i,onClick:a,onDoubleClick:d,onContextMenu:u,onMouseEnter:h,onMouseMove:f,onMouseLeave:p,reconnectRadius:g,onReconnect:m,onReconnectStart:v,onReconnectEnd:b,rfId:x,edgeTypes:w,noPanClassName:M,onError:_,disableKeyboardA11y:A}){let S=$(r=>r.edgeLookup.get(t)),C=$(t=>t.defaultEdgeOptions),T=(S=C?{...C,...S}:S).type||"default",I=w?.[T]||to[T];void 0===I&&(_?.("011",c.xc.error011(T)),T="default",I=w?.default||to.default);let N=!!(S.focusable||r&&void 0===S.focusable),O=void 0!==m&&(S.reconnectable||n&&void 0===S.reconnectable),D=!!(S.selectable||i&&void 0===S.selectable),R=(0,o.useRef)(null),[L,z]=(0,o.useState)(!1),[P,j]=(0,o.useState)(!1),F=k(),{zIndex:B=S.zIndex,sourceX:W,sourceY:H,targetX:U,targetY:q,sourcePosition:V,targetPosition:Y}=$((0,o.useCallback)(r=>{let n=r.nodeLookup.get(S.source),i=r.nodeLookup.get(S.target);if(!n||!i)return tl;let a=(0,c.b5)({id:t,sourceNode:n,targetNode:i,sourceHandle:S.sourceHandle||null,targetHandle:S.targetHandle||null,connectionMode:r.connectionMode,onError:_}),s=(0,c.qX)({selected:S.selected,zIndex:S.zIndex,sourceNode:n,targetNode:i,elevateOnSelect:r.elevateEdgesOnSelect,zIndexMode:r.zIndexMode});return{...a||tl,zIndex:s}},[S.source,S.target,S.sourceHandle,S.targetHandle,S.selected,S.zIndex,_]),y),G=(0,o.useMemo)(()=>S.markerStart?`url('#${(0,c.aW)(S.markerStart,x)}')`:void 0,[S.markerStart,x]),Z=(0,o.useMemo)(()=>S.markerEnd?`url('#${(0,c.aW)(S.markerEnd,x)}')`:void 0,[S.markerEnd,x]);if(S.hidden||null===W||null===H||null===U||null===q)return null;let X=d?t=>{d(t,{...S})}:void 0,K=u?t=>{u(t,{...S})}:void 0,J=h?t=>{h(t,{...S})}:void 0,Q=f?t=>{f(t,{...S})}:void 0,ee=p?t=>{p(t,{...S})}:void 0;return(0,s.jsx)("svg",{style:{zIndex:B},children:(0,s.jsxs)("g",{className:l(["react-flow__edge",`react-flow__edge-${T}`,S.className,M,{selected:S.selected,animated:S.animated,inactive:!D&&!a,updating:L,selectable:D}]),onClick:r=>{let{addSelectedEdges:n,unselectNodesAndEdges:i,multiSelectionActive:s}=F.getState();D&&(F.setState({nodesSelectionActive:!1}),S.selected&&s?(i({nodes:[],edges:[S]}),R.current?.blur()):n([t])),a&&a(r,S)},onDoubleClick:X,onContextMenu:K,onMouseEnter:J,onMouseMove:Q,onMouseLeave:ee,onKeyDown:N?r=>{if(!A&&c.tn.includes(r.key)&&D){let{unselectNodesAndEdges:n,addSelectedEdges:i}=F.getState();"Escape"===r.key?(R.current?.blur(),n({edges:[S]})):i([t])}}:void 0,tabIndex:N?0:void 0,role:S.ariaRole??(N?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":null===S.ariaLabel?void 0:S.ariaLabel||`Edge from ${S.source} to ${S.target}`,"aria-describedby":N?`${E}-${x}`:void 0,ref:R,...S.domAttributes,children:[!P&&(0,s.jsx)(I,{id:t,source:S.source,target:S.target,type:S.type,selected:S.selected,animated:S.animated,selectable:D,deletable:S.deletable??!0,label:S.label,labelStyle:S.labelStyle,labelShowBg:S.labelShowBg,labelBgStyle:S.labelBgStyle,labelBgPadding:S.labelBgPadding,labelBgBorderRadius:S.labelBgBorderRadius,sourceX:W,sourceY:H,targetX:U,targetY:q,sourcePosition:V,targetPosition:Y,data:S.data,style:S.style,sourceHandleId:S.sourceHandle,targetHandleId:S.targetHandle,markerStart:G,markerEnd:Z,pathOptions:"pathOptions"in S?S.pathOptions:void 0,interactionWidth:S.interactionWidth}),O&&(0,s.jsx)(tu,{edge:S,isReconnectable:O,reconnectRadius:g,onReconnect:m,onReconnectStart:v,onReconnectEnd:b,sourceX:W,sourceY:H,targetX:U,targetY:q,sourcePosition:V,targetPosition:Y,setUpdateHover:z,setReconnecting:j})]})})});let tf=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function tp({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:n,edgeTypes:i,noPanClassName:a,onReconnect:l,onEdgeContextMenu:d,onEdgeMouseEnter:u,onEdgeMouseMove:h,onEdgeMouseLeave:f,onEdgeClick:p,reconnectRadius:g,onEdgeDoubleClick:m,onReconnectStart:v,onReconnectEnd:b,disableKeyboardA11y:x}){let{edgesFocusable:w,edgesReconnectable:k,elementsSelectable:M,onError:_}=$(tf,y),A=$((0,o.useCallback)(t=>{if(!r)return t.edges.map(t=>t.id);let n=[];if(t.width&&t.height)for(let r of t.edges){let i=t.nodeLookup.get(r.source),a=t.nodeLookup.get(r.target);i&&a&&(0,c.uj)({sourceNode:i,targetNode:a,width:t.width,height:t.height,transform:t.transform})&&n.push(r.id)}return n},[r]),y);return(0,s.jsxs)("div",{className:"react-flow__edges",children:[(0,s.jsx)(eX,{defaultColor:t,rfId:n}),A.map(t=>(0,s.jsx)(th,{id:t,edgesFocusable:w,edgesReconnectable:k,elementsSelectable:M,noPanClassName:a,onReconnect:l,onContextMenu:d,onMouseEnter:u,onMouseMove:h,onMouseLeave:f,onClick:p,reconnectRadius:g,onDoubleClick:m,onReconnectStart:v,onReconnectEnd:b,rfId:n,onError:_,edgeTypes:i,disableKeyboardA11y:x},t))]})}tp.displayName="EdgeRenderer";let tg=(0,o.memo)(tp),tm=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function ty({children:t}){let r=k(),n=(0,o.useRef)(null),[i]=(0,o.useState)(()=>r.getState().transform);return eo(()=>{let t=null,i=()=>{let i=r.getState().transform;(!t||i[0]!==t[0]||i[1]!==t[1]||i[2]!==t[2])&&(t=i,n.current&&(n.current.style.transform=tm(i)))};return i(),r.subscribe(i)},[r]),(0,s.jsx)("div",{ref:n,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:tm(i)},children:t})}let tv=t=>t.panZoom?.syncViewport;function tb(t){return t.connection.inProgress?{...t.connection,to:(0,c.Ff)(t.connection.to,t.transform)}:{...t.connection}}let tx=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function tw({containerStyle:t,style:r,type:n,component:i}){let{nodesConnectable:a,width:o,height:d,isValid:u,inProgress:h}=$(tx,y);return o&&a&&h?(0,s.jsx)("svg",{style:t,width:o,height:d,className:"react-flow__connectionline react-flow__container",children:(0,s.jsx)("g",{className:l(["react-flow__connection",(0,c.HF)(u)]),children:(0,s.jsx)(t$,{style:r,type:n,CustomComponent:i,isValid:u})})}):null}let t$=({style:t,type:r=c.Do.Bezier,CustomComponent:n,isValid:i})=>{let{inProgress:a,from:o,fromNode:l,fromHandle:d,fromPosition:u,to:h,toNode:f,toHandle:p,toPosition:g,pointer:m}=$(tb,y);if(!a)return;if(n)return(0,s.jsx)(n,{connectionLineType:r,connectionLineStyle:t,fromNode:l,fromHandle:d,fromX:o.x,fromY:o.y,toX:h.x,toY:h.y,fromPosition:u,toPosition:g,connectionStatus:(0,c.HF)(i),toNode:f,toHandle:p,pointer:m});let v="",b={sourceX:o.x,sourceY:o.y,sourcePosition:u,targetX:h.x,targetY:h.y,targetPosition:g};switch(r){case c.Do.Bezier:[v]=(0,c.Fp)(b);break;case c.Do.SimpleBezier:[v]=e1(b);break;case c.Do.Step:[v]=(0,c.oN)({...b,borderRadius:0});break;case c.Do.SmoothStep:[v]=(0,c.oN)(b);break;default:[v]=(0,c.ah)(b)}return(0,s.jsx)("path",{d:v,fill:"none",className:"react-flow__connection-path",style:t})};t$.displayName="ConnectionLine";let tk={};function tM(t=tk){(0,o.useRef)(t),k(),(0,o.useEffect)(()=>{},[t])}function t_({nodeTypes:t,edgeTypes:r,onInit:n,onNodeClick:i,onEdgeClick:a,onNodeDoubleClick:l,onEdgeDoubleClick:c,onNodeMouseEnter:d,onNodeMouseMove:u,onNodeMouseLeave:h,onNodeContextMenu:f,onSelectionContextMenu:p,onSelectionStart:g,onSelectionEnd:m,connectionLineType:y,connectionLineStyle:v,connectionLineComponent:b,connectionLineContainerStyle:x,selectionKeyCode:w,selectionOnDrag:M,selectionMode:_,multiSelectionKeyCode:A,panActivationKeyCode:E,zoomActivationKeyCode:S,deleteKeyCode:C,onlyRenderVisibleElements:T,elementsSelectable:I,defaultViewport:N,translateExtent:O,minZoom:D,maxZoom:R,preventScrolling:L,defaultMarkerColor:z,zoomOnScroll:P,zoomOnPinch:j,panOnScroll:F,panOnScrollSpeed:B,panOnScrollMode:W,zoomOnDoubleClick:H,panOnDrag:U,autoPanOnSelection:q,onPaneClick:V,onPaneMouseEnter:Y,onPaneMouseMove:G,onPaneMouseLeave:Z,onPaneScroll:X,onPaneContextMenu:K,paneClickDistance:J,nodeClickDistance:Q,onEdgeContextMenu:ee,onEdgeMouseEnter:et,onEdgeMouseMove:er,onEdgeMouseLeave:en,reconnectRadius:ei,onReconnect:ea,onReconnectStart:es,onReconnectEnd:eo,noDragClassName:el,noWheelClassName:ec,noPanClassName:ed,disableKeyboardA11y:eu,nodeExtent:ef,rfId:ep,viewport:eg,onViewportChange:em,nodesDraggable:ey}){let ev,eb,ex,ew;return tM(t),tM(r),k(),(0,o.useRef)(!1),(0,o.useEffect)(()=>{},[]),ev=eh(),eb=(0,o.useRef)(!1),(0,o.useEffect)(()=>{!eb.current&&ev.viewportInitialized&&n&&(setTimeout(()=>n(ev),1),eb.current=!0)},[n,ev.viewportInitialized]),ex=$(tv),ew=k(),(0,o.useEffect)(()=>{eg&&(ex?.(eg),ew.setState({transform:[eg.x,eg.y,eg.zoom]}))},[eg,ex]),(0,s.jsx)(eB,{onPaneClick:V,onPaneMouseEnter:Y,onPaneMouseMove:G,onPaneMouseLeave:Z,onPaneContextMenu:K,onPaneScroll:X,paneClickDistance:J,deleteKeyCode:C,selectionKeyCode:w,selectionOnDrag:M,selectionMode:_,onSelectionStart:g,onSelectionEnd:m,multiSelectionKeyCode:A,panActivationKeyCode:E,zoomActivationKeyCode:S,elementsSelectable:I,zoomOnScroll:P,zoomOnPinch:j,zoomOnDoubleClick:H,panOnScroll:F,panOnScrollSpeed:B,panOnScrollMode:W,panOnDrag:U,autoPanOnSelection:q,defaultViewport:N,translateExtent:O,minZoom:D,maxZoom:R,onSelectionContextMenu:p,preventScrolling:L,noDragClassName:el,noWheelClassName:ec,noPanClassName:ed,disableKeyboardA11y:eu,onViewportChange:em,isControlledViewport:!!eg,children:(0,s.jsxs)(ty,{children:[(0,s.jsx)(tg,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:c,onReconnect:ea,onReconnectStart:es,onReconnectEnd:eo,onlyRenderVisibleElements:T,onEdgeContextMenu:ee,onEdgeMouseEnter:et,onEdgeMouseMove:er,onEdgeMouseLeave:en,reconnectRadius:ei,defaultMarkerColor:z,noPanClassName:ed,disableKeyboardA11y:eu,rfId:ep}),(0,s.jsx)(tw,{style:v,type:y,component:b,containerStyle:x}),(0,s.jsx)("div",{className:"react-flow__edgelabel-renderer"}),(0,s.jsx)(eV,{nodeTypes:t,onNodeClick:i,onNodeDoubleClick:l,onNodeMouseEnter:d,onNodeMouseMove:u,onNodeMouseLeave:h,onNodeContextMenu:f,nodeClickDistance:Q,onlyRenderVisibleElements:T,noPanClassName:ed,noDragClassName:el,disableKeyboardA11y:eu,nodeExtent:ef,rfId:ep,nodesDraggable:ey}),(0,s.jsx)("div",{className:"react-flow__viewport-portal"})]})})}t_.displayName="GraphView";let tA=(0,o.memo)(t_),tE=(0,c.kr)("React Flow","https://reactflow.dev/"),tS=({nodes:t,edges:r,defaultNodes:n,defaultEdges:i,width:a,height:s,fitView:o,fitViewOptions:l,minZoom:d=.5,maxZoom:u=2,nodeOrigin:h,nodeExtent:f,zIndexMode:p="basic"}={})=>{let g=new Map,m=new Map,y=new Map,v=new Map,b=i??r??[],x=n??t??[],w=h??[0,0],$=f??c.ZO;(0,c.qn)(y,v,b);let{nodesInitialized:k}=(0,c.bi)(x,g,m,{nodeOrigin:w,nodeExtent:$,zIndexMode:p}),M=[0,0,1];if(o&&a&&s){let t=(0,c.aZ)(g,{filter:t=>!!((t.width||t.initialWidth)&&(t.height||t.initialHeight))}),{x:r,y:n,zoom:i}=(0,c.R4)(t,a,s,d,u,l?.padding??.1);M=[r,n,i]}return{rfId:"1",width:a??0,height:s??0,transform:M,nodes:x,nodesInitialized:k,nodeLookup:g,parentLookup:m,edges:b,edgeLookup:v,connectionLookup:y,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:void 0!==n,hasDefaultEdges:void 0!==i,panZoom:null,minZoom:d,maxZoom:u,translateExtent:c.ZO,nodeExtent:$,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:c.WZ.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:w,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:l,fitViewResolver:null,connection:{...c.bK},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:tE,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:c.tM,zIndexMode:p,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}};function tC({initialNodes:t,initialEdges:r,defaultNodes:n,defaultEdges:i,initialWidth:a,initialHeight:l,initialMinZoom:d,initialMaxZoom:u,initialFitViewOptions:h,fitView:f,nodeOrigin:p,nodeExtent:g,zIndexMode:y,children:v}){let[b]=(0,o.useState)(()=>(({nodes:t,edges:r,defaultNodes:n,defaultEdges:i,width:a,height:s,fitView:o,fitViewOptions:l,minZoom:d,maxZoom:u,nodeOrigin:h,nodeExtent:f,zIndexMode:p})=>{let g,y;return g=(g,m)=>{async function y(){let{nodeLookup:t,panZoom:r,fitViewOptions:n,fitViewResolver:i,width:a,height:s,minZoom:o,maxZoom:l}=m();r&&(await (0,c.IO)({nodes:t,width:a,height:s,panZoom:r,minZoom:o,maxZoom:l},n),i?.resolve(!0),g({fitViewResolver:null}))}return{...tS({nodes:t,edges:r,width:a,height:s,fitView:o,fitViewOptions:l,minZoom:d,maxZoom:u,nodeOrigin:h,nodeExtent:f,defaultNodes:n,defaultEdges:i,zIndexMode:p}),setNodes:t=>{let{nodeLookup:r,parentLookup:n,nodeOrigin:i,nodeExtent:a,elevateNodesOnSelect:s,fitViewQueued:o,zIndexMode:l,nodesSelectionActive:d}=m(),{nodesInitialized:u,hasSelectedNodes:h}=(0,c.bi)(t,r,n,{nodeOrigin:i,nodeExtent:a,elevateNodesOnSelect:s,checkEquality:!0,zIndexMode:l}),f=d&&h;o&&u?(y(),g({nodes:t,nodesInitialized:u,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:f})):g({nodes:t,nodesInitialized:u,nodesSelectionActive:f})},setEdges:t=>{let{connectionLookup:r,edgeLookup:n}=m();(0,c.qn)(r,n,t),g({edges:t})},setDefaultNodesAndEdges:(t,r)=>{if(t){let{setNodes:r}=m();r(t),g({hasDefaultNodes:!0})}if(r){let{setEdges:t}=m();t(r),g({hasDefaultEdges:!0})}},updateNodeInternals:t=>{let{triggerNodeChanges:r,nodeLookup:n,parentLookup:i,domNode:a,nodeOrigin:s,nodeExtent:o,debug:l,fitViewQueued:d,zIndexMode:u}=m(),{changes:h,updatedInternals:f}=(0,c.uL)(t,n,i,a,s,o,u);f&&((0,c.vS)(n,i,{nodeOrigin:s,nodeExtent:o,zIndexMode:u}),d?(y(),g({fitViewQueued:!1,fitViewOptions:void 0})):g({}),h?.length>0&&(l&&console.log("React Flow: trigger node changes",h),r?.(h)))},updateNodePositions:(t,r=!1)=>{let n=[],i=[],{nodeLookup:a,triggerNodeChanges:s,connection:o,updateConnection:l,onNodesChangeMiddlewareMap:d}=m();for(let[s,d]of t){let t=a.get(s),u=!!(t?.expandParent&&t?.parentId&&d?.position),h={id:s,type:"position",position:u?{x:Math.max(0,d.position.x),y:Math.max(0,d.position.y)}:d.position,dragging:r};if(t&&o.inProgress&&o.fromNode.id===t.id){let r=(0,c.M_)(t,o.fromHandle,c.yX.Left,!0);l({...o,from:r})}u&&t.parentId&&n.push({id:s,parentId:t.parentId,rect:{...d.internals.positionAbsolute,width:d.measured.width??0,height:d.measured.height??0}}),i.push(h)}if(n.length>0){let{parentLookup:t,nodeOrigin:r}=m(),s=(0,c.r8)(n,a,t,r);i.push(...s)}for(let t of d.values())i=t(i);s(i)},triggerNodeChanges:t=>{let{onNodesChange:r,setNodes:n,nodes:i,hasDefaultNodes:a,debug:s}=m();t?.length&&(a&&n(J(t,i)),s&&console.log("React Flow: trigger node changes",t),r?.(t))},triggerEdgeChanges:t=>{let{onEdgesChange:r,setEdges:n,edges:i,hasDefaultEdges:a,debug:s}=m();t?.length&&(a&&n(J(t,i)),s&&console.log("React Flow: trigger edge changes",t),r?.(t))},addSelectedNodes:t=>{let{multiSelectionActive:r,edgeLookup:n,nodeLookup:i,triggerNodeChanges:a,triggerEdgeChanges:s}=m();r?a(t.map(t=>ee(t,!0))):(a(et(i,new Set([...t]))),s(et(n)))},addSelectedEdges:t=>{let{multiSelectionActive:r,edgeLookup:n,nodeLookup:i,triggerNodeChanges:a,triggerEdgeChanges:s}=m();r?s(t.map(t=>ee(t,!0))):(s(et(n,new Set([...t]))),a(et(i,new Set)))},unselectNodesAndEdges:({nodes:t,edges:r}={})=>{let{edges:n,nodes:i,nodeLookup:a,triggerNodeChanges:s,triggerEdgeChanges:o}=m(),l=[];for(let r of t||i)r.selected&&l.push(ee(r.id,!1));let c=[];for(let t of r||n)t.selected&&c.push(ee(t.id,!1));s(l),o(c)},setMinZoom:t=>{let{panZoom:r,maxZoom:n}=m();r?.setScaleExtent([t,n]),g({minZoom:t})},setMaxZoom:t=>{let{panZoom:r,minZoom:n}=m();r?.setScaleExtent([n,t]),g({maxZoom:t})},setTranslateExtent:t=>{m().panZoom?.setTranslateExtent(t),g({translateExtent:t})},resetSelectedElements:()=>{let{edges:t,nodes:r,triggerNodeChanges:n,triggerEdgeChanges:i,elementsSelectable:a}=m();if(!a)return;let s=r.reduce((t,r)=>r.selected?[...t,ee(r.id,!1)]:t,[]),o=t.reduce((t,r)=>r.selected?[...t,ee(r.id,!1)]:t,[]);n(s),i(o)},setNodeExtent:t=>{let{nodes:r,nodeLookup:n,parentLookup:i,nodeOrigin:a,elevateNodesOnSelect:s,nodeExtent:o,zIndexMode:l}=m();(t[0][0]!==o[0][0]||t[0][1]!==o[0][1]||t[1][0]!==o[1][0]||t[1][1]!==o[1][1])&&((0,c.bi)(r,n,i,{nodeOrigin:a,nodeExtent:t,elevateNodesOnSelect:s,checkEquality:!1,zIndexMode:l}),g({nodeExtent:t}))},panBy:t=>{let{transform:r,width:n,height:i,panZoom:a,translateExtent:s}=m();return(0,c.No)({delta:t,panZoom:a,transform:r,translateExtent:s,width:n,height:i})},setCenter:async(t,r,n)=>{let{width:i,height:a,maxZoom:s,panZoom:o}=m();if(!o)return!1;let l=void 0!==n?.zoom?n.zoom:s;return await o.setViewport({x:i/2-t*l,y:a/2-r*l,zoom:l},{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0},cancelConnection:()=>{g({connection:{...c.bK}})},updateConnection:t=>{g({connection:t})},reset:()=>g({...tS()})}},y=Object.is,g?m(g,y):m})({nodes:t,edges:r,defaultNodes:n,defaultEdges:i,width:a,height:l,fitView:f,minZoom:d,maxZoom:u,fitViewOptions:h,nodeOrigin:p,nodeExtent:g,zIndexMode:y}));return(0,s.jsx)(x,{value:b,children:(0,s.jsx)(ed,{children:(0,s.jsx)(eI,{children:v})})})}function tT({children:t,nodes:r,edges:n,defaultNodes:i,defaultEdges:a,width:l,height:c,fitView:d,fitViewOptions:u,minZoom:h,maxZoom:f,nodeOrigin:p,nodeExtent:g,zIndexMode:m}){return(0,o.useContext)(b)?(0,s.jsx)(s.Fragment,{children:t}):(0,s.jsx)(tC,{initialNodes:r,initialEdges:n,defaultNodes:i,defaultEdges:a,initialWidth:l,initialHeight:c,fitView:d,initialFitViewOptions:u,initialMinZoom:h,initialMaxZoom:f,nodeOrigin:p,nodeExtent:g,zIndexMode:m,children:t})}let tI={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};var tN=es(function({nodes:t,edges:r,defaultNodes:n,defaultEdges:i,className:a,nodeTypes:d,edgeTypes:u,onNodeClick:h,onEdgeClick:f,onInit:p,onMove:g,onMoveStart:m,onMoveEnd:y,onConnect:v,onConnectStart:b,onConnectEnd:x,onClickConnectStart:w,onClickConnectEnd:$,onNodeMouseEnter:k,onNodeMouseMove:M,onNodeMouseLeave:_,onNodeContextMenu:A,onNodeDoubleClick:E,onNodeDragStart:S,onNodeDrag:C,onNodeDragStop:T,onNodesDelete:N,onEdgesDelete:O,onDelete:R,onSelectionChange:L,onSelectionDragStart:z,onSelectionDrag:P,onSelectionDragStop:j,onSelectionContextMenu:H,onSelectionStart:U,onSelectionEnd:q,onBeforeDelete:G,connectionMode:Z,connectionLineType:X=c.Do.Bezier,connectionLineStyle:K,connectionLineComponent:J,connectionLineContainerStyle:Q,deleteKeyCode:ee="Backspace",selectionKeyCode:et="Shift",selectionOnDrag:er=!1,selectionMode:en=c.Qc.Full,panActivationKeyCode:ei="Space",multiSelectionKeyCode:ea=(0,c.Ue)()?"Meta":"Control",zoomActivationKeyCode:es=(0,c.Ue)()?"Meta":"Control",snapToGrid:eo,snapGrid:el,onlyRenderVisibleElements:ec=!1,selectNodesOnDrag:ed,nodesDraggable:eu,autoPanOnNodeFocus:eh,nodesConnectable:ef,nodesFocusable:ep,nodeOrigin:eg=B,edgesFocusable:em,edgesReconnectable:ey,elementsSelectable:ev=!0,defaultViewport:eb=W,minZoom:ex=.5,maxZoom:ew=2,translateExtent:e$=c.ZO,preventScrolling:ek=!0,nodeExtent:eM,defaultMarkerColor:e_="#b1b1b7",zoomOnScroll:eA=!0,zoomOnPinch:eE=!0,panOnScroll:eS=!1,panOnScrollSpeed:eC=.5,panOnScrollMode:eT=c.ny.Free,zoomOnDoubleClick:eI=!0,panOnDrag:eN=!0,onPaneClick:eO,onPaneMouseEnter:eD,onPaneMouseMove:eR,onPaneMouseLeave:eL,onPaneScroll:ez,onPaneContextMenu:eP,paneClickDistance:ej=1,nodeClickDistance:eF=0,children:eB,onReconnect:eW,onReconnectStart:eH,onReconnectEnd:eU,onEdgeContextMenu:eq,onEdgeDoubleClick:eV,onEdgeMouseEnter:eY,onEdgeMouseMove:eG,onEdgeMouseLeave:eZ,reconnectRadius:eX=10,onNodesChange:eK,onEdgesChange:eJ,noDragClassName:eQ="nodrag",noWheelClassName:e0="nowheel",noPanClassName:e1="nopan",fitView:e2,fitViewOptions:e4,connectOnClick:e3,attributionPosition:e5,proOptions:e6,defaultEdgeOptions:e8,elevateNodesOnSelect:e9=!0,elevateEdgesOnSelect:e7=!1,disableKeyboardA11y:te=!1,autoPanOnConnect:tt,autoPanOnNodeDrag:tr,autoPanOnSelection:tn=!0,autoPanSpeed:ti,connectionRadius:ta,isValidConnection:ts,onError:to,style:tl,id:tc,nodeDragThreshold:td,connectionDragThreshold:tu,viewport:th,onViewportChange:tf,width:tp,height:tg,colorMode:tm="light",debug:ty,onScroll:tv,ariaLabelConfig:tb,zIndexMode:tx="basic",...tw},t$){let tk=tc||"1",tM=function(t){let[r,n]=(0,o.useState)("system"===t?null:t);return(0,o.useEffect)(()=>{if("system"!==t)return void n(t);let r=Y(),i=()=>n(r?.matches?"dark":"light");return i(),r?.addEventListener("change",i),()=>{r?.removeEventListener("change",i)}},[t]),null!==r?r:Y()?.matches?"dark":"light"}(tm),t_=(0,o.useCallback)(t=>{t.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),tv?.(t)},[tv]);return(0,s.jsx)("div",{"data-testid":"rf__wrapper",...tw,onScroll:t_,style:{...tl,...tI},ref:t$,className:l(["react-flow",a,tM]),id:tc,role:"application",children:(0,s.jsxs)(tT,{nodes:t,edges:r,width:tp,height:tg,fitView:e2,fitViewOptions:e4,minZoom:ex,maxZoom:ew,nodeOrigin:eg,nodeExtent:eM,zIndexMode:tx,children:[(0,s.jsx)(V,{nodes:t,edges:r,defaultNodes:n,defaultEdges:i,onConnect:v,onConnectStart:b,onConnectEnd:x,onClickConnectStart:w,onClickConnectEnd:$,nodesDraggable:eu,autoPanOnNodeFocus:eh,nodesConnectable:ef,nodesFocusable:ep,edgesFocusable:em,edgesReconnectable:ey,elementsSelectable:ev,elevateNodesOnSelect:e9,elevateEdgesOnSelect:e7,minZoom:ex,maxZoom:ew,nodeExtent:eM,onNodesChange:eK,onEdgesChange:eJ,snapToGrid:eo,snapGrid:el,connectionMode:Z,translateExtent:e$,connectOnClick:e3,defaultEdgeOptions:e8,fitView:e2,fitViewOptions:e4,onNodesDelete:N,onEdgesDelete:O,onDelete:R,onNodeDragStart:S,onNodeDrag:C,onNodeDragStop:T,onSelectionDrag:P,onSelectionDragStart:z,onSelectionDragStop:j,onMove:g,onMoveStart:m,onMoveEnd:y,noPanClassName:e1,nodeOrigin:eg,rfId:tk,autoPanOnConnect:tt,autoPanOnNodeDrag:tr,autoPanSpeed:ti,onError:to,connectionRadius:ta,isValidConnection:ts,selectNodesOnDrag:ed,nodeDragThreshold:td,connectionDragThreshold:tu,onBeforeDelete:G,debug:ty,ariaLabelConfig:tb,zIndexMode:tx}),(0,s.jsx)(tA,{onInit:p,onNodeClick:h,onEdgeClick:f,onNodeMouseEnter:k,onNodeMouseMove:M,onNodeMouseLeave:_,onNodeContextMenu:A,onNodeDoubleClick:E,nodeTypes:d,edgeTypes:u,connectionLineType:X,connectionLineStyle:K,connectionLineComponent:J,connectionLineContainerStyle:Q,selectionKeyCode:et,selectionOnDrag:er,selectionMode:en,deleteKeyCode:ee,multiSelectionKeyCode:ea,panActivationKeyCode:ei,zoomActivationKeyCode:es,onlyRenderVisibleElements:ec,defaultViewport:eb,translateExtent:e$,minZoom:ex,maxZoom:ew,preventScrolling:ek,zoomOnScroll:eA,zoomOnPinch:eE,zoomOnDoubleClick:eI,panOnScroll:eS,panOnScrollSpeed:eC,panOnScrollMode:eT,panOnDrag:eN,autoPanOnSelection:tn,onPaneClick:eO,onPaneMouseEnter:eD,onPaneMouseMove:eR,onPaneMouseLeave:eL,onPaneScroll:ez,onPaneContextMenu:eP,paneClickDistance:ej,nodeClickDistance:eF,onSelectionContextMenu:H,onSelectionStart:U,onSelectionEnd:q,onReconnect:eW,onReconnectStart:eH,onReconnectEnd:eU,onEdgeContextMenu:eq,onEdgeDoubleClick:eV,onEdgeMouseEnter:eY,onEdgeMouseMove:eG,onEdgeMouseLeave:eZ,reconnectRadius:eX,defaultMarkerColor:e_,noDragClassName:eQ,noWheelClassName:e0,noPanClassName:e1,rfId:tk,disableKeyboardA11y:te,nodeExtent:eM,viewport:th,onViewportChange:tf,nodesDraggable:eu}),(0,s.jsx)(F,{onSelectionChange:L}),eB,(0,s.jsx)(D,{proOptions:e6,position:e5}),(0,s.jsx)(I,{rfId:tk,disableKeyboardA11y:te})]})})});let tO=t=>t.domNode?.querySelector(".react-flow__edgelabel-renderer");function tD({children:t}){let r=$(tO);return r?(0,v.createPortal)(t,r):null}let tR=t=>({x:t.transform[0],y:t.transform[1],zoom:t.transform[2]});function tL(){return $(tR,y)}function tz(t){return $((0,o.useCallback)(r=>r.nodeLookup.get(t),[t]),y)}function tP({dimensions:t,lineWidth:r,variant:n,className:i}){return(0,s.jsx)("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:l(["react-flow__background-pattern",n,i])})}function tj({radius:t,className:r}){return(0,s.jsx)("circle",{cx:t,cy:t,r:t,className:l(["react-flow__background-pattern","dots",r])})}c.xc.error014(),(i=a||(a={})).Lines="lines",i.Dots="dots",i.Cross="cross";let tF={[a.Dots]:1,[a.Lines]:1,[a.Cross]:6},tB=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function tW({id:t,variant:r=a.Dots,gap:n=20,size:i,lineWidth:c=1,offset:d=0,color:u,bgColor:h,style:f,className:p,patternClassName:g}){let m=(0,o.useRef)(null),{transform:v,patternId:b}=$(tB,y),x=i||tF[r],w=r===a.Dots,k=r===a.Cross,M=Array.isArray(n)?n:[n,n],_=[M[0]*v[2]||1,M[1]*v[2]||1],A=x*v[2],E=Array.isArray(d)?d:[d,d],S=k?[A,A]:_,C=[E[0]*v[2]+S[0]/2,E[1]*v[2]+S[1]/2],T=`${b}${t||""}`;return(0,s.jsxs)("svg",{className:l(["react-flow__background",p]),style:{...f,...eg,"--xy-background-color-props":h,"--xy-background-pattern-color-props":u},ref:m,"data-testid":"rf__background",children:[(0,s.jsx)("pattern",{id:T,x:v[0]%_[0],y:v[1]%_[1],width:_[0],height:_[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${C[0]},-${C[1]})`,children:w?(0,s.jsx)(tj,{radius:A/2,className:g}):(0,s.jsx)(tP,{dimensions:S,lineWidth:c,variant:r,className:g})}),(0,s.jsx)("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${T})`})]})}tW.displayName="Background";let tH=(0,o.memo)(tW);function tU(){return(0,s.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:(0,s.jsx)("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function tq(){return(0,s.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:(0,s.jsx)("path",{d:"M0 0h32v4.2H0z"})})}function tV(){return(0,s.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:(0,s.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 tY(){return(0,s.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:(0,s.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 tG(){return(0,s.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:(0,s.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 tZ({children:t,className:r,...n}){return(0,s.jsx)("button",{type:"button",className:l(["react-flow__controls-button",r]),...n,children:t})}let tX=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function tK({style:t,showZoom:r=!0,showFitView:n=!0,showInteractive:i=!0,fitViewOptions:a,onZoomIn:o,onZoomOut:c,onFitView:d,onInteractiveChange:u,className:h,children:f,position:p="bottom-left",orientation:g="vertical","aria-label":m}){let v=k(),{isInteractive:b,minZoomReached:x,maxZoomReached:w,ariaLabelConfig:M}=$(tX,y),{zoomIn:_,zoomOut:A,fitView:E}=eh();return(0,s.jsxs)(N,{className:l(["react-flow__controls","horizontal"===g?"horizontal":"vertical",h]),position:p,style:t,"data-testid":"rf__controls","aria-label":m??M["controls.ariaLabel"],children:[r&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(tZ,{onClick:()=>{_(),o?.()},className:"react-flow__controls-zoomin",title:M["controls.zoomIn.ariaLabel"],"aria-label":M["controls.zoomIn.ariaLabel"],disabled:w,children:(0,s.jsx)(tU,{})}),(0,s.jsx)(tZ,{onClick:()=>{A(),c?.()},className:"react-flow__controls-zoomout",title:M["controls.zoomOut.ariaLabel"],"aria-label":M["controls.zoomOut.ariaLabel"],disabled:x,children:(0,s.jsx)(tq,{})})]}),n&&(0,s.jsx)(tZ,{className:"react-flow__controls-fitview",onClick:()=>{E(a),d?.()},title:M["controls.fitView.ariaLabel"],"aria-label":M["controls.fitView.ariaLabel"],children:(0,s.jsx)(tV,{})}),i&&(0,s.jsx)(tZ,{className:"react-flow__controls-interactive",onClick:()=>{v.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),u?.(!b)},title:M["controls.interactive.ariaLabel"],"aria-label":M["controls.interactive.ariaLabel"],children:b?(0,s.jsx)(tG,{}):(0,s.jsx)(tY,{})}),f]})}tK.displayName="Controls",(0,o.memo)(tK);let tJ=(0,o.memo)(function({id:t,x:r,y:n,width:i,height:a,style:o,color:c,strokeColor:d,strokeWidth:u,className:h,borderRadius:f,shapeRendering:p,selected:g,onClick:m}){let{background:y,backgroundColor:v}=o||{};return(0,s.jsx)("rect",{className:l(["react-flow__minimap-node",{selected:g},h]),x:r,y:n,rx:f,ry:f,width:i,height:a,style:{fill:c||y||v,stroke:d,strokeWidth:u},shapeRendering:p,onClick:m?r=>m(r,t):void 0})}),tQ=t=>t.nodes.map(t=>t.id),t0=t=>t instanceof Function?t:()=>t,t1=(0,o.memo)(function({id:t,nodeColorFunc:r,nodeStrokeColorFunc:n,nodeClassNameFunc:i,nodeBorderRadius:a,nodeStrokeWidth:o,shapeRendering:l,NodeComponent:d,onClick:u}){let{node:h,x:f,y:p,width:g,height:m}=$(r=>{let n=r.nodeLookup.get(t);if(!n)return{node:void 0,x:0,y:0,width:0,height:0};let i=n.internals.userNode,{x:a,y:s}=n.internals.positionAbsolute,{width:o,height:l}=(0,c.uD)(i);return{node:i,x:a,y:s,width:o,height:l}},y);return h&&!h.hidden&&(0,c.QE)(h)?(0,s.jsx)(d,{x:f,y:p,width:g,height:m,style:h.style,selected:!!h.selected,className:i(h),color:r(h),borderRadius:a,strokeColor:n(h),strokeWidth:o,shapeRendering:l,onClick:u,id:h.id}):null});var t2=(0,o.memo)(function({nodeStrokeColor:t,nodeColor:r,nodeClassName:n="",nodeBorderRadius:i=5,nodeStrokeWidth:a,nodeComponent:o=tJ,onClick:l}){let c=$(tQ,y),d=t0(r),u=t0(t),h=t0(n),f="u"<typeof window||window.chrome?"crispEdges":"geometricPrecision";return(0,s.jsx)(s.Fragment,{children:c.map(t=>(0,s.jsx)(t1,{id:t,nodeColorFunc:d,nodeStrokeColorFunc:u,nodeClassNameFunc:h,nodeBorderRadius:i,nodeStrokeWidth:a,NodeComponent:o,onClick:l,shapeRendering:f},t))})});let t4=t=>!t.hidden,t3=t=>{let r={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]},n=!1;for(let r of t.nodeLookup.values())if(!r.hidden){n=!0;break}return{viewBB:r,boundingRect:n?(0,c.Mi)((0,c.aZ)(t.nodeLookup,{filter:t4}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},t5=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,t6=(t,r)=>t5(t.viewBB,r.viewBB)&&t5(t.boundingRect,r.boundingRect)&&t.rfId===r.rfId&&t.panZoom===r.panZoom&&t.translateExtent===r.translateExtent&&t.flowWidth===r.flowWidth&&t.flowHeight===r.flowHeight&&t.ariaLabelConfig===r.ariaLabelConfig;function t8({style:t,className:r,nodeStrokeColor:n,nodeColor:i,nodeClassName:a="",nodeBorderRadius:d=5,nodeStrokeWidth:u,nodeComponent:h,bgColor:f,maskColor:p,maskStrokeColor:g,maskStrokeWidth:m,position:y="bottom-right",onClick:v,onNodeClick:b,pannable:x=!1,zoomable:w=!1,ariaLabel:M,inversePan:_,zoomStep:A=1,offsetScale:E=5}){let S=k(),C=(0,o.useRef)(null),{boundingRect:T,panZoom:I,viewBB:O,rfId:D,translateExtent:R,flowWidth:L,flowHeight:z,ariaLabelConfig:P}=$(t3,t6),j=t?.width??200,F=t?.height??150,B=Math.max(T.width/j,T.height/F),W=B*j,H=B*F,U=E*B,q=T.x-(W-T.width)/2-U,V=T.y-(H-T.height)/2-U,Y=W+2*U,G=H+2*U,Z=`react-flow__minimap-desc-${D}`,X=(0,o.useRef)(0),K=(0,o.useRef)();X.current=B,(0,o.useEffect)(()=>{let t=S.getState().panZoom;if(C.current&&t)return K.current=(0,c.di)({domNode:C.current,panZoom:t,getTransform:()=>S.getState().transform,getViewScale:()=>X.current}),()=>{K.current?.destroy()}},[I]),(0,o.useEffect)(()=>{K.current?.update({translateExtent:R,width:L,height:z,inversePan:_,pannable:x,zoomStep:A,zoomable:w})},[x,w,_,A,R,L,z]);let J=v?t=>{let[r,n]=K.current?.pointer(t)||[0,0];v(t,{x:r,y:n})}:void 0,Q=(0,o.useCallback)((t,r)=>{let n=S.getState().nodeLookup.get(r).internals.userNode;b?.(t,n)},[b]),ee=M??P["minimap.ariaLabel"];return(0,s.jsx)(N,{position:y,style:{...t,"--xy-minimap-background-color-props":"string"==typeof f?f:void 0,"--xy-minimap-mask-background-color-props":"string"==typeof p?p:void 0,"--xy-minimap-mask-stroke-color-props":"string"==typeof g?g:void 0,"--xy-minimap-mask-stroke-width-props":"number"==typeof m?m*B:void 0,"--xy-minimap-node-background-color-props":"string"==typeof i?i:void 0,"--xy-minimap-node-stroke-color-props":"string"==typeof n?n:void 0,"--xy-minimap-node-stroke-width-props":"number"==typeof u?u:void 0},className:l(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:(0,s.jsxs)("svg",{width:j,height:F,viewBox:`${q} ${V} ${Y} ${G}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":Z,ref:C,onClick:J,children:[ee&&(0,s.jsx)("title",{id:Z,children:ee}),(0,s.jsx)(t2,{onClick:b?Q:void 0,nodeColor:i,nodeStrokeColor:n,nodeBorderRadius:d,nodeClassName:a,nodeStrokeWidth:u,nodeComponent:h}),(0,s.jsx)("path",{className:"react-flow__minimap-mask",d:`M${q-U},${V-U}h${Y+2*U}v${G+2*U}h${-Y-2*U}z
|
|
3
|
+
M${O.x},${O.y}h${O.width}v${O.height}h${-O.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}t8.displayName="MiniMap";let t9=(0,o.memo)(t8),t7={[c.xN.Line]:"right",[c.xN.Handle]:"bottom-right"};(0,o.memo)(function({nodeId:t,position:r,variant:n=c.xN.Handle,className:i,style:a,children:d,color:u,minWidth:h=10,minHeight:f=10,maxWidth:p=Number.MAX_VALUE,maxHeight:g=Number.MAX_VALUE,keepAspectRatio:m=!1,resizeDirection:v,autoScale:b=!0,shouldResize:x,onResizeStart:w,onResize:M,onResizeEnd:_}){let A,E=eS(),S="string"==typeof t?t:E,C=k(),T=(0,o.useRef)(null),I=n===c.xN.Handle,N=$((0,o.useCallback)((A=I&&b,t=>A?`${Math.max(1/t.transform[2],1)}`:void 0),[I,b]),y),O=(0,o.useRef)(null),D=r??t7[n];(0,o.useEffect)(()=>{if(T.current&&S)return O.current||(O.current=(0,c.ET)({domNode:T.current,nodeId:S,getStoreItems:()=>{let{nodeLookup:t,transform:r,snapGrid:n,snapToGrid:i,nodeOrigin:a,domNode:s}=C.getState();return{nodeLookup:t,transform:r,snapGrid:n,snapToGrid:i,nodeOrigin:a,paneDomNode:s}},onChange:(t,r)=>{let{triggerNodeChanges:n,nodeLookup:i,parentLookup:a,nodeOrigin:s}=C.getState(),o=[],l={x:t.x,y:t.y},d=i.get(S);if(d&&d.expandParent&&d.parentId){let r=d.origin??s,n=t.width??d.measured.width??0,u=t.height??d.measured.height??0,h={id:d.id,parentId:d.parentId,rect:{width:n,height:u,...(0,c.us)({x:t.x??d.position.x,y:t.y??d.position.y},{width:n,height:u},d.parentId,i,r)}},f=(0,c.r8)([h],i,a,s);o.push(...f),l.x=t.x?Math.max(r[0]*n,t.x):void 0,l.y=t.y?Math.max(r[1]*u,t.y):void 0}if(void 0!==l.x&&void 0!==l.y){let t={id:S,type:"position",position:{...l}};o.push(t)}if(void 0!==t.width&&void 0!==t.height){let r={id:S,type:"dimensions",resizing:!0,setAttributes:!v||("horizontal"===v?"width":"height"),dimensions:{width:t.width,height:t.height}};o.push(r)}for(let t of r){let r={...t,type:"position"};o.push(r)}n(o)},onEnd:({width:t,height:r})=>{C.getState().triggerNodeChanges([{id:S,type:"dimensions",resizing:!1,dimensions:{width:t,height:r}}])}})),O.current.update({controlPosition:D,boundaries:{minWidth:h,minHeight:f,maxWidth:p,maxHeight:g},keepAspectRatio:m,resizeDirection:v,onResizeStart:w,onResize:M,onResizeEnd:_,shouldResize:x}),()=>{O.current?.destroy()}},[D,h,f,p,g,m,w,M,_,x]);let R=D.split("-");return(0,s.jsx)("div",{className:l(["react-flow__resize-control","nodrag",...R,n,i]),ref:T,style:{...a,scale:N,...u&&{[I?"backgroundColor":"borderColor"]:u}},children:d})})},2697(t,r,n){n.d(r,{aQ:()=>n2,Qc:()=>f,X6:()=>rK,kr:()=>r0,s_:()=>r1,aZ:()=>rD,rN:()=>n$,tn:()=>r_,b$:()=>rC,HF:()=>na,bi:()=>nB,oN:()=>nS,ny:()=>h,v5:()=>nd,I$:()=>nK,qn:()=>nG,uL:()=>nq,YN:()=>nr,Jo:()=>rO,r8:()=>nU,Ue:()=>r6,R4:()=>r5,zj:()=>r4,qX:()=>nb,tM:()=>rA,Tq:()=>rP,Do:()=>p,kO:()=>it,ah:()=>nk,Fp:()=>ny,TG:()=>g,kM:()=>rY,xc:()=>rk,Mi:()=>rZ,ET:()=>ic,No:()=>nV,IO:()=>rL,mW:()=>rJ,uD:()=>r9,QE:()=>r7,e_:()=>np,Eo:()=>no,vS:()=>nj,uj:()=>nx,aE:()=>rz,bK:()=>rE,Hm:()=>nR,kf:()=>rQ,_s:()=>nt,us:()=>ne,_7:()=>rH,oj:()=>nl,aW:()=>nD,q1:()=>nh,oB:()=>rT,b5:()=>nT,di:()=>n4,Q6:()=>nn,yX:()=>m,WQ:()=>ni,Ff:()=>r2,WZ:()=>u,ZO:()=>rM,Er:()=>nu,M_:()=>nN,U$:()=>rR,xN:()=>y});var i,a,s,o,l,c,d,u,h,f,p,g,m,y,v={value:()=>{}};function b(){for(var t,r=0,n=arguments.length,i={};r<n;++r){if(!(t=arguments[r]+"")||t in i||/[\s.]/.test(t))throw Error("illegal type: "+t);i[t]=[]}return new x(i)}function x(t){this._=t}function w(t,r,n){for(var i=0,a=t.length;i<a;++i)if(t[i].name===r){t[i]=v,t=t.slice(0,i).concat(t.slice(i+1));break}return null!=n&&t.push({name:r,value:n}),t}x.prototype=b.prototype={constructor:x,on:function(t,r){var n,i=this._,a=(t+"").trim().split(/^|\s+/).map(function(t){var r="",n=t.indexOf(".");if(n>=0&&(r=t.slice(n+1),t=t.slice(0,n)),t&&!i.hasOwnProperty(t))throw Error("unknown type: "+t);return{type:t,name:r}}),s=-1,o=a.length;if(arguments.length<2){for(;++s<o;)if((n=(t=a[s]).type)&&(n=function(t,r){for(var n,i=0,a=t.length;i<a;++i)if((n=t[i]).name===r)return n.value}(i[n],t.name)))return n;return}if(null!=r&&"function"!=typeof r)throw Error("invalid callback: "+r);for(;++s<o;)if(n=(t=a[s]).type)i[n]=w(i[n],t.name,r);else if(null==r)for(n in i)i[n]=w(i[n],t.name,null);return this},copy:function(){var t={},r=this._;for(var n in r)t[n]=r[n].slice();return new x(t)},call:function(t,r){if((n=arguments.length-2)>0)for(var n,i,a=Array(n),s=0;s<n;++s)a[s]=arguments[s+2];if(!this._.hasOwnProperty(t))throw Error("unknown type: "+t);for(i=this._[t],s=0,n=i.length;s<n;++s)i[s].value.apply(r,a)},apply:function(t,r,n){if(!this._.hasOwnProperty(t))throw Error("unknown type: "+t);for(var i=this._[t],a=0,s=i.length;a<s;++a)i[a].value.apply(r,n)}};var $="http://www.w3.org/1999/xhtml",k={svg:"http://www.w3.org/2000/svg",xhtml:$,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function M(t){var r=t+="",n=r.indexOf(":");return n>=0&&"xmlns"!==(r=t.slice(0,n))&&(t=t.slice(n+1)),k.hasOwnProperty(r)?{space:k[r],local:t}:t}function _(t){var r=M(t);return(r.local?function(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}:function(t){return function(){var r=this.ownerDocument,n=this.namespaceURI;return n===$&&r.documentElement.namespaceURI===$?r.createElement(t):r.createElementNS(n,t)}})(r)}function A(){}function E(t){return null==t?A:function(){return this.querySelector(t)}}function S(){return[]}function C(t){return null==t?S:function(){return this.querySelectorAll(t)}}function T(t){return function(){return this.matches(t)}}function I(t){return function(r){return r.matches(t)}}var N=Array.prototype.find;function O(){return this.firstElementChild}var D=Array.prototype.filter;function R(){return Array.from(this.children)}function L(t){return Array(t.length)}function z(t,r){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=r}function P(t,r,n,i,a,s){for(var o,l=0,c=r.length,d=s.length;l<d;++l)(o=r[l])?(o.__data__=s[l],i[l]=o):n[l]=new z(t,s[l]);for(;l<c;++l)(o=r[l])&&(a[l]=o)}function j(t,r,n,i,a,s,o){var l,c,d,u=new Map,h=r.length,f=s.length,p=Array(h);for(l=0;l<h;++l)(c=r[l])&&(p[l]=d=o.call(c,c.__data__,l,r)+"",u.has(d)?a[l]=c:u.set(d,c));for(l=0;l<f;++l)d=o.call(t,s[l],l,s)+"",(c=u.get(d))?(i[l]=c,c.__data__=s[l],u.delete(d)):n[l]=new z(t,s[l]);for(l=0;l<h;++l)(c=r[l])&&u.get(p[l])===c&&(a[l]=c)}function F(t){return t.__data__}function B(t,r){return t<r?-1:t>r?1:t>=r?0:NaN}function W(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function H(t,r){return t.style.getPropertyValue(r)||W(t).getComputedStyle(t,null).getPropertyValue(r)}function U(t){return t.trim().split(/^|\s+/)}function q(t){return t.classList||new V(t)}function V(t){this._node=t,this._names=U(t.getAttribute("class")||"")}function Y(t,r){for(var n=q(t),i=-1,a=r.length;++i<a;)n.add(r[i])}function G(t,r){for(var n=q(t),i=-1,a=r.length;++i<a;)n.remove(r[i])}function Z(){this.textContent=""}function X(){this.innerHTML=""}function K(){this.nextSibling&&this.parentNode.appendChild(this)}function J(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Q(){return null}function ee(){var t=this.parentNode;t&&t.removeChild(this)}function et(){var t=this.cloneNode(!1),r=this.parentNode;return r?r.insertBefore(t,this.nextSibling):t}function er(){var t=this.cloneNode(!0),r=this.parentNode;return r?r.insertBefore(t,this.nextSibling):t}function en(t){return function(){var r=this.__on;if(r){for(var n,i=0,a=-1,s=r.length;i<s;++i)(n=r[i],t.type&&n.type!==t.type||n.name!==t.name)?r[++a]=n:this.removeEventListener(n.type,n.listener,n.options);++a?r.length=a:delete this.__on}}}function ei(t,r,n){return function(){var i,a=this.__on,s=function(t){r.call(this,t,this.__data__)};if(a){for(var o=0,l=a.length;o<l;++o)if((i=a[o]).type===t.type&&i.name===t.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=s,i.options=n),i.value=r;return}}this.addEventListener(t.type,s,n),i={type:t.type,name:t.name,value:r,listener:s,options:n},a?a.push(i):this.__on=[i]}}function ea(t,r,n){var i=W(t),a=i.CustomEvent;"function"==typeof a?a=new a(r,n):(a=i.document.createEvent("Event"),n?(a.initEvent(r,n.bubbles,n.cancelable),a.detail=n.detail):a.initEvent(r,!1,!1)),t.dispatchEvent(a)}z.prototype={constructor:z,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,r){return this._parent.insertBefore(t,r)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}},V.prototype={add:function(t){0>this._names.indexOf(t)&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var r=this._names.indexOf(t);r>=0&&(this._names.splice(r,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var es=[null];function eo(t,r){this._groups=t,this._parents=r}function el(){return new eo([[document.documentElement]],es)}function ec(t){return"string"==typeof t?new eo([[document.querySelector(t)]],[document.documentElement]):new eo([[t]],es)}eo.prototype=el.prototype={constructor:eo,select:function(t){"function"!=typeof t&&(t=E(t));for(var r=this._groups,n=r.length,i=Array(n),a=0;a<n;++a)for(var s,o,l=r[a],c=l.length,d=i[a]=Array(c),u=0;u<c;++u)(s=l[u])&&(o=t.call(s,s.__data__,u,l))&&("__data__"in s&&(o.__data__=s.__data__),d[u]=o);return new eo(i,this._parents)},selectAll:function(t){if("function"==typeof t){var r;r=t,t=function(){var t;return t=r.apply(this,arguments),null==t?[]:Array.isArray(t)?t:Array.from(t)}}else t=C(t);for(var n=this._groups,i=n.length,a=[],s=[],o=0;o<i;++o)for(var l,c=n[o],d=c.length,u=0;u<d;++u)(l=c[u])&&(a.push(t.call(l,l.__data__,u,c)),s.push(l));return new eo(a,s)},selectChild:function(t){var r;return this.select(null==t?O:(r="function"==typeof t?t:I(t),function(){return N.call(this.children,r)}))},selectChildren:function(t){var r;return this.selectAll(null==t?R:(r="function"==typeof t?t:I(t),function(){return D.call(this.children,r)}))},filter:function(t){"function"!=typeof t&&(t=T(t));for(var r=this._groups,n=r.length,i=Array(n),a=0;a<n;++a)for(var s,o=r[a],l=o.length,c=i[a]=[],d=0;d<l;++d)(s=o[d])&&t.call(s,s.__data__,d,o)&&c.push(s);return new eo(i,this._parents)},data:function(t,r){if(!arguments.length)return Array.from(this,F);var n=r?j:P,i=this._parents,a=this._groups;"function"!=typeof t&&(b=t,t=function(){return b});for(var s=a.length,o=Array(s),l=Array(s),c=Array(s),d=0;d<s;++d){var u=i[d],h=a[d],f=h.length,p="object"==typeof(v=t.call(u,u&&u.__data__,d,i))&&"length"in v?v:Array.from(v),g=p.length,m=l[d]=Array(g),y=o[d]=Array(g);n(u,h,m,y,c[d]=Array(f),p,r);for(var v,b,x,w,$=0,k=0;$<g;++$)if(x=m[$]){for($>=k&&(k=$+1);!(w=y[k])&&++k<g;);x._next=w||null}}return(o=new eo(o,i))._enter=l,o._exit=c,o},enter:function(){return new eo(this._enter||this._groups.map(L),this._parents)},exit:function(){return new eo(this._exit||this._groups.map(L),this._parents)},join:function(t,r,n){var i=this.enter(),a=this,s=this.exit();return"function"==typeof t?(i=t(i))&&(i=i.selection()):i=i.append(t+""),null!=r&&(a=r(a))&&(a=a.selection()),null==n?s.remove():n(s),i&&a?i.merge(a).order():a},merge:function(t){for(var r=t.selection?t.selection():t,n=this._groups,i=r._groups,a=n.length,s=i.length,o=Math.min(a,s),l=Array(a),c=0;c<o;++c)for(var d,u=n[c],h=i[c],f=u.length,p=l[c]=Array(f),g=0;g<f;++g)(d=u[g]||h[g])&&(p[g]=d);for(;c<a;++c)l[c]=n[c];return new eo(l,this._parents)},selection:function(){return this},order:function(){for(var t=this._groups,r=-1,n=t.length;++r<n;)for(var i,a=t[r],s=a.length-1,o=a[s];--s>=0;)(i=a[s])&&(o&&4^i.compareDocumentPosition(o)&&o.parentNode.insertBefore(i,o),o=i);return this},sort:function(t){function r(r,n){return r&&n?t(r.__data__,n.__data__):!r-!n}t||(t=B);for(var n=this._groups,i=n.length,a=Array(i),s=0;s<i;++s){for(var o,l=n[s],c=l.length,d=a[s]=Array(c),u=0;u<c;++u)(o=l[u])&&(d[u]=o);d.sort(r)}return new eo(a,this._parents).order()},call:function(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this},nodes:function(){return Array.from(this)},node:function(){for(var t=this._groups,r=0,n=t.length;r<n;++r)for(var i=t[r],a=0,s=i.length;a<s;++a){var o=i[a];if(o)return o}return null},size:function(){let t=0;for(let r of this)++t;return t},empty:function(){return!this.node()},each:function(t){for(var r=this._groups,n=0,i=r.length;n<i;++n)for(var a,s=r[n],o=0,l=s.length;o<l;++o)(a=s[o])&&t.call(a,a.__data__,o,s);return this},attr:function(t,r){var n=M(t);if(arguments.length<2){var i=this.node();return n.local?i.getAttributeNS(n.space,n.local):i.getAttribute(n)}return this.each((null==r?n.local?function(t){return function(){this.removeAttributeNS(t.space,t.local)}}:function(t){return function(){this.removeAttribute(t)}}:"function"==typeof r?n.local?function(t,r){return function(){var n=r.apply(this,arguments);null==n?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}:function(t,r){return function(){var n=r.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}:n.local?function(t,r){return function(){this.setAttributeNS(t.space,t.local,r)}}:function(t,r){return function(){this.setAttribute(t,r)}})(n,r))},style:function(t,r,n){return arguments.length>1?this.each((null==r?function(t){return function(){this.style.removeProperty(t)}}:"function"==typeof r?function(t,r,n){return function(){var i=r.apply(this,arguments);null==i?this.style.removeProperty(t):this.style.setProperty(t,i,n)}}:function(t,r,n){return function(){this.style.setProperty(t,r,n)}})(t,r,null==n?"":n)):H(this.node(),t)},property:function(t,r){return arguments.length>1?this.each((null==r?function(t){return function(){delete this[t]}}:"function"==typeof r?function(t,r){return function(){var n=r.apply(this,arguments);null==n?delete this[t]:this[t]=n}}:function(t,r){return function(){this[t]=r}})(t,r)):this.node()[t]},classed:function(t,r){var n=U(t+"");if(arguments.length<2){for(var i=q(this.node()),a=-1,s=n.length;++a<s;)if(!i.contains(n[a]))return!1;return!0}return this.each(("function"==typeof r?function(t,r){return function(){(r.apply(this,arguments)?Y:G)(this,t)}}:r?function(t){return function(){Y(this,t)}}:function(t){return function(){G(this,t)}})(n,r))},text:function(t){return arguments.length?this.each(null==t?Z:("function"==typeof t?function(t){return function(){var r=t.apply(this,arguments);this.textContent=null==r?"":r}}:function(t){return function(){this.textContent=t}})(t)):this.node().textContent},html:function(t){return arguments.length?this.each(null==t?X:("function"==typeof t?function(t){return function(){var r=t.apply(this,arguments);this.innerHTML=null==r?"":r}}:function(t){return function(){this.innerHTML=t}})(t)):this.node().innerHTML},raise:function(){return this.each(K)},lower:function(){return this.each(J)},append:function(t){var r="function"==typeof t?t:_(t);return this.select(function(){return this.appendChild(r.apply(this,arguments))})},insert:function(t,r){var n="function"==typeof t?t:_(t),i=null==r?Q:"function"==typeof r?r:E(r);return this.select(function(){return this.insertBefore(n.apply(this,arguments),i.apply(this,arguments)||null)})},remove:function(){return this.each(ee)},clone:function(t){return this.select(t?er:et)},datum:function(t){return arguments.length?this.property("__data__",t):this.node().__data__},on:function(t,r,n){var i,a,s=(t+"").trim().split(/^|\s+/).map(function(t){var r="",n=t.indexOf(".");return n>=0&&(r=t.slice(n+1),t=t.slice(0,n)),{type:t,name:r}}),o=s.length;if(arguments.length<2){var l=this.node().__on;if(l){for(var c,d=0,u=l.length;d<u;++d)for(i=0,c=l[d];i<o;++i)if((a=s[i]).type===c.type&&a.name===c.name)return c.value}return}for(i=0,l=r?ei:en;i<o;++i)this.each(l(s[i],r,n));return this},dispatch:function(t,r){return this.each(("function"==typeof r?function(t,r){return function(){return ea(this,t,r.apply(this,arguments))}}:function(t,r){return function(){return ea(this,t,r)}})(t,r))},[Symbol.iterator]:function*(){for(var t=this._groups,r=0,n=t.length;r<n;++r)for(var i,a=t[r],s=0,o=a.length;s<o;++s)(i=a[s])&&(yield i)}};var ed=0;function eu(){this._="@"+(++ed).toString(36)}function eh(t,r){if(t=function(t){let r;for(;r=t.sourceEvent;)t=r;return t}(t),void 0===r&&(r=t.currentTarget),r){var n=r.ownerSVGElement||r;if(n.createSVGPoint){var i=n.createSVGPoint();return i.x=t.clientX,i.y=t.clientY,[(i=i.matrixTransform(r.getScreenCTM().inverse())).x,i.y]}if(r.getBoundingClientRect){var a=r.getBoundingClientRect();return[t.clientX-a.left-r.clientLeft,t.clientY-a.top-r.clientTop]}}return[t.pageX,t.pageY]}eu.prototype=(function(){return new eu}).prototype={constructor:eu,get:function(t){for(var r=this._;!(r in t);)if(!(t=t.parentNode))return;return t[r]},set:function(t,r){return t[this._]=r},remove:function(t){return this._ in t&&delete t[this._]},toString:function(){return this._}};let ef={passive:!1},ep={capture:!0,passive:!1};function eg(t){t.stopImmediatePropagation()}function em(t){t.preventDefault(),t.stopImmediatePropagation()}function ey(t){var r=t.document.documentElement,n=ec(t).on("dragstart.drag",em,ep);"onselectstart"in r?n.on("selectstart.drag",em,ep):(r.__noselect=r.style.MozUserSelect,r.style.MozUserSelect="none")}function ev(t,r){var n=t.document.documentElement,i=ec(t).on("dragstart.drag",null);r&&(i.on("click.drag",em,ep),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in n?i.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var eb=t=>()=>t;function ex(t,{sourceEvent:r,subject:n,target:i,identifier:a,active:s,x:o,y:l,dx:c,dy:d,dispatch:u}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:d,enumerable:!0,configurable:!0},_:{value:u}})}function ew(t){return!t.ctrlKey&&!t.button}function e$(){return this.parentNode}function ek(t,r){return null==r?{x:t.x,y:t.y}:r}function eM(){return navigator.maxTouchPoints||"ontouchstart"in this}function e_(){var t,r,n,i,a=ew,s=e$,o=ek,l=eM,c={},d=b("start","drag","end"),u=0,h=0;function f(t){t.on("mousedown.drag",p).filter(l).on("touchstart.drag",y).on("touchmove.drag",v,ef).on("touchend.drag touchcancel.drag",x).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(o,l){if(!i&&a.call(this,o,l)){var c=w(this,s.call(this,o,l),o,l,"mouse");c&&(ec(o.view).on("mousemove.drag",g,ep).on("mouseup.drag",m,ep),ey(o.view),eg(o),n=!1,t=o.clientX,r=o.clientY,c("start",o))}}function g(i){if(em(i),!n){var a=i.clientX-t,s=i.clientY-r;n=a*a+s*s>h}c.mouse("drag",i)}function m(t){ec(t.view).on("mousemove.drag mouseup.drag",null),ev(t.view,n),em(t),c.mouse("end",t)}function y(t,r){if(a.call(this,t,r)){var n,i,o=t.changedTouches,l=s.call(this,t,r),c=o.length;for(n=0;n<c;++n)(i=w(this,l,t,r,o[n].identifier,o[n]))&&(eg(t),i("start",t,o[n]))}}function v(t){var r,n,i=t.changedTouches,a=i.length;for(r=0;r<a;++r)(n=c[i[r].identifier])&&(em(t),n("drag",t,i[r]))}function x(t){var r,n,a=t.changedTouches,s=a.length;for(i&&clearTimeout(i),i=setTimeout(function(){i=null},500),r=0;r<s;++r)(n=c[a[r].identifier])&&(eg(t),n("end",t,a[r]))}function w(t,r,n,i,a,s){var l,h,p,g=d.copy(),m=eh(s||n,r);if(null!=(p=o.call(t,new ex("beforestart",{sourceEvent:n,target:f,identifier:a,active:u,x:m[0],y:m[1],dx:0,dy:0,dispatch:g}),i)))return l=p.x-m[0]||0,h=p.y-m[1]||0,function n(s,o,d){var y,v=m;switch(s){case"start":c[a]=n,y=u++;break;case"end":delete c[a],--u;case"drag":m=eh(d||o,r),y=u}g.call(s,t,new ex(s,{sourceEvent:o,subject:p,target:f,identifier:a,active:y,x:m[0]+l,y:m[1]+h,dx:m[0]-v[0],dy:m[1]-v[1],dispatch:g}),i)}}return f.filter=function(t){return arguments.length?(a="function"==typeof t?t:eb(!!t),f):a},f.container=function(t){return arguments.length?(s="function"==typeof t?t:eb(t),f):s},f.subject=function(t){return arguments.length?(o="function"==typeof t?t:eb(t),f):o},f.touchable=function(t){return arguments.length?(l="function"==typeof t?t:eb(!!t),f):l},f.on=function(){var t=d.on.apply(d,arguments);return t===d?f:t},f.clickDistance=function(t){return arguments.length?(h=(t*=1)*t,f):Math.sqrt(h)},f}function eA(t,r,n){t.prototype=r.prototype=n,n.constructor=t}function eE(t,r){var n=Object.create(t.prototype);for(var i in r)n[i]=r[i];return n}function eS(){}ex.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};var eC="\\s*([+-]?\\d+)\\s*",eT="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",eI="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",eN=/^#([0-9a-f]{3,8})$/,eO=RegExp(`^rgb\\(${eC},${eC},${eC}\\)$`),eD=RegExp(`^rgb\\(${eI},${eI},${eI}\\)$`),eR=RegExp(`^rgba\\(${eC},${eC},${eC},${eT}\\)$`),eL=RegExp(`^rgba\\(${eI},${eI},${eI},${eT}\\)$`),ez=RegExp(`^hsl\\(${eT},${eI},${eI}\\)$`),eP=RegExp(`^hsla\\(${eT},${eI},${eI},${eT}\\)$`),ej={aliceblue:0xf0f8ff,antiquewhite:0xfaebd7,aqua:65535,aquamarine:8388564,azure:0xf0ffff,beige:0xf5f5dc,bisque:0xffe4c4,black:0,blanchedalmond:0xffebcd,blue:255,blueviolet:9055202,brown:0xa52a2a,burlywood:0xdeb887,cadetblue:6266528,chartreuse:8388352,chocolate:0xd2691e,coral:0xff7f50,cornflowerblue:6591981,cornsilk:0xfff8dc,crimson:0xdc143c,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:0xb8860b,darkgray:0xa9a9a9,darkgreen:25600,darkgrey:0xa9a9a9,darkkhaki:0xbdb76b,darkmagenta:9109643,darkolivegreen:5597999,darkorange:0xff8c00,darkorchid:0x9932cc,darkred:9109504,darksalmon:0xe9967a,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:0xff1493,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:0xb22222,floralwhite:0xfffaf0,forestgreen:2263842,fuchsia:0xff00ff,gainsboro:0xdcdcdc,ghostwhite:0xf8f8ff,gold:0xffd700,goldenrod:0xdaa520,gray:8421504,green:32768,greenyellow:0xadff2f,grey:8421504,honeydew:0xf0fff0,hotpink:0xff69b4,indianred:0xcd5c5c,indigo:4915330,ivory:0xfffff0,khaki:0xf0e68c,lavender:0xe6e6fa,lavenderblush:0xfff0f5,lawngreen:8190976,lemonchiffon:0xfffacd,lightblue:0xadd8e6,lightcoral:0xf08080,lightcyan:0xe0ffff,lightgoldenrodyellow:0xfafad2,lightgray:0xd3d3d3,lightgreen:9498256,lightgrey:0xd3d3d3,lightpink:0xffb6c1,lightsalmon:0xffa07a,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:0xb0c4de,lightyellow:0xffffe0,lime:65280,limegreen:3329330,linen:0xfaf0e6,magenta:0xff00ff,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:0xba55d3,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:0xc71585,midnightblue:1644912,mintcream:0xf5fffa,mistyrose:0xffe4e1,moccasin:0xffe4b5,navajowhite:0xffdead,navy:128,oldlace:0xfdf5e6,olive:8421376,olivedrab:7048739,orange:0xffa500,orangered:0xff4500,orchid:0xda70d6,palegoldenrod:0xeee8aa,palegreen:0x98fb98,paleturquoise:0xafeeee,palevioletred:0xdb7093,papayawhip:0xffefd5,peachpuff:0xffdab9,peru:0xcd853f,pink:0xffc0cb,plum:0xdda0dd,powderblue:0xb0e0e6,purple:8388736,rebeccapurple:6697881,red:0xff0000,rosybrown:0xbc8f8f,royalblue:4286945,saddlebrown:9127187,salmon:0xfa8072,sandybrown:0xf4a460,seagreen:3050327,seashell:0xfff5ee,sienna:0xa0522d,silver:0xc0c0c0,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:0xfffafa,springgreen:65407,steelblue:4620980,tan:0xd2b48c,teal:32896,thistle:0xd8bfd8,tomato:0xff6347,turquoise:4251856,violet:0xee82ee,wheat:0xf5deb3,white:0xffffff,whitesmoke:0xf5f5f5,yellow:0xffff00,yellowgreen:0x9acd32};function eF(){return this.rgb().formatHex()}function eB(){return this.rgb().formatRgb()}function eW(t){var r,n;return t=(t+"").trim().toLowerCase(),(r=eN.exec(t))?(n=r[1].length,r=parseInt(r[1],16),6===n?eH(r):3===n?new eY(r>>8&15|r>>4&240,r>>4&15|240&r,(15&r)<<4|15&r,1):8===n?eU(r>>24&255,r>>16&255,r>>8&255,(255&r)/255):4===n?eU(r>>12&15|r>>8&240,r>>8&15|r>>4&240,r>>4&15|240&r,((15&r)<<4|15&r)/255):null):(r=eO.exec(t))?new eY(r[1],r[2],r[3],1):(r=eD.exec(t))?new eY(255*r[1]/100,255*r[2]/100,255*r[3]/100,1):(r=eR.exec(t))?eU(r[1],r[2],r[3],r[4]):(r=eL.exec(t))?eU(255*r[1]/100,255*r[2]/100,255*r[3]/100,r[4]):(r=ez.exec(t))?eQ(r[1],r[2]/100,r[3]/100,1):(r=eP.exec(t))?eQ(r[1],r[2]/100,r[3]/100,r[4]):ej.hasOwnProperty(t)?eH(ej[t]):"transparent"===t?new eY(NaN,NaN,NaN,0):null}function eH(t){return new eY(t>>16&255,t>>8&255,255&t,1)}function eU(t,r,n,i){return i<=0&&(t=r=n=NaN),new eY(t,r,n,i)}function eq(t){return(t instanceof eS||(t=eW(t)),t)?new eY((t=t.rgb()).r,t.g,t.b,t.opacity):new eY}function eV(t,r,n,i){return 1==arguments.length?eq(t):new eY(t,r,n,null==i?1:i)}function eY(t,r,n,i){this.r=+t,this.g=+r,this.b=+n,this.opacity=+i}function eG(){return`#${eJ(this.r)}${eJ(this.g)}${eJ(this.b)}`}function eZ(){let t=eX(this.opacity);return`${1===t?"rgb(":"rgba("}${eK(this.r)}, ${eK(this.g)}, ${eK(this.b)}${1===t?")":`, ${t})`}`}function eX(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function eK(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function eJ(t){return((t=eK(t))<16?"0":"")+t.toString(16)}function eQ(t,r,n,i){return i<=0?t=r=n=NaN:n<=0||n>=1?t=r=NaN:r<=0&&(t=NaN),new e2(t,r,n,i)}function e0(t){if(t instanceof e2)return new e2(t.h,t.s,t.l,t.opacity);if(t instanceof eS||(t=eW(t)),!t)return new e2;if(t instanceof e2)return t;var r=(t=t.rgb()).r/255,n=t.g/255,i=t.b/255,a=Math.min(r,n,i),s=Math.max(r,n,i),o=NaN,l=s-a,c=(s+a)/2;return l?(o=r===s?(n-i)/l+(n<i)*6:n===s?(i-r)/l+2:(r-n)/l+4,l/=c<.5?s+a:2-s-a,o*=60):l=c>0&&c<1?0:o,new e2(o,l,c,t.opacity)}function e1(t,r,n,i){return 1==arguments.length?e0(t):new e2(t,r,n,null==i?1:i)}function e2(t,r,n,i){this.h=+t,this.s=+r,this.l=+n,this.opacity=+i}function e4(t){return(t=(t||0)%360)<0?t+360:t}function e3(t){return Math.max(0,Math.min(1,t||0))}function e5(t,r,n){return(t<60?r+(n-r)*t/60:t<180?n:t<240?r+(n-r)*(240-t)/60:r)*255}eA(eS,eW,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:eF,formatHex:eF,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return e0(this).formatHsl()},formatRgb:eB,toString:eB}),eA(eY,eV,eE(eS,{brighter(t){return t=null==t?1.4285714285714286:Math.pow(1.4285714285714286,t),new eY(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?.7:Math.pow(.7,t),new eY(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new eY(eK(this.r),eK(this.g),eK(this.b),eX(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:eG,formatHex:eG,formatHex8:function(){return`#${eJ(this.r)}${eJ(this.g)}${eJ(this.b)}${eJ((isNaN(this.opacity)?1:this.opacity)*255)}`},formatRgb:eZ,toString:eZ})),eA(e2,e1,eE(eS,{brighter(t){return t=null==t?1.4285714285714286:Math.pow(1.4285714285714286,t),new e2(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?.7:Math.pow(.7,t),new e2(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,r=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,i=n+(n<.5?n:1-n)*r,a=2*n-i;return new eY(e5(t>=240?t-240:t+120,a,i),e5(t,a,i),e5(t<120?t+240:t-120,a,i),this.opacity)},clamp(){return new e2(e4(this.h),e3(this.s),e3(this.l),eX(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 t=eX(this.opacity);return`${1===t?"hsl(":"hsla("}${e4(this.h)}, ${100*e3(this.s)}%, ${100*e3(this.l)}%${1===t?")":`, ${t})`}`}}));let e6=Math.PI/180,e8=180/Math.PI,e9=4/29,e7=6/29,te=6/29*3*(6/29),tt=6/29*(6/29)*(6/29);function tr(t){if(t instanceof tn)return new tn(t.l,t.a,t.b,t.opacity);if(t instanceof tc)return td(t);t instanceof eY||(t=eq(t));var r,n,i=to(t.r),a=to(t.g),s=to(t.b),o=ti((.2225045*i+.7168786*a+.0606169*s)/1);return i===a&&a===s?r=n=o:(r=ti((.4360747*i+.3850649*a+.1430804*s)/.96422),n=ti((.0139322*i+.0971045*a+.7141733*s)/.82521)),new tn(116*o-16,500*(r-o),200*(o-n),t.opacity)}function tn(t,r,n,i){this.l=+t,this.a=+r,this.b=+n,this.opacity=+i}function ti(t){return t>tt?Math.pow(t,1/3):t/te+e9}function ta(t){return t>e7?t*t*t:te*(t-e9)}function ts(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function to(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function tl(t,r,n,i){return 1==arguments.length?function(t){if(t instanceof tc)return new tc(t.h,t.c,t.l,t.opacity);if(t instanceof tn||(t=tr(t)),0===t.a&&0===t.b)return new tc(NaN,0<t.l&&t.l<100?0:NaN,t.l,t.opacity);var r=Math.atan2(t.b,t.a)*e8;return new tc(r<0?r+360:r,Math.sqrt(t.a*t.a+t.b*t.b),t.l,t.opacity)}(t):new tc(t,r,n,null==i?1:i)}function tc(t,r,n,i){this.h=+t,this.c=+r,this.l=+n,this.opacity=+i}function td(t){if(isNaN(t.h))return new tn(t.l,0,0,t.opacity);var r=t.h*e6;return new tn(t.l,Math.cos(r)*t.c,Math.sin(r)*t.c,t.opacity)}eA(tn,function(t,r,n,i){return 1==arguments.length?tr(t):new tn(t,r,n,null==i?1:i)},eE(eS,{brighter(t){return new tn(this.l+18*(null==t?1:t),this.a,this.b,this.opacity)},darker(t){return new tn(this.l-18*(null==t?1:t),this.a,this.b,this.opacity)},rgb(){var t=(this.l+16)/116,r=isNaN(this.a)?t:t+this.a/500,n=isNaN(this.b)?t:t-this.b/200;return r=.96422*ta(r),new eY(ts(3.1338561*r-1.6168667*(t=+ta(t))-.4906146*(n=.82521*ta(n))),ts(-.9787684*r+1.9161415*t+.033454*n),ts(.0719453*r-.2289914*t+1.4052427*n),this.opacity)}})),eA(tc,tl,eE(eS,{brighter(t){return new tc(this.h,this.c,this.l+18*(null==t?1:t),this.opacity)},darker(t){return new tc(this.h,this.c,this.l-18*(null==t?1:t),this.opacity)},rgb(){return td(this).rgb()}}));var tu=-1.78277*.29227-.1347134789;function th(t,r,n,i){return 1==arguments.length?function(t){if(t instanceof tf)return new tf(t.h,t.s,t.l,t.opacity);t instanceof eY||(t=eq(t));var r=t.r/255,n=t.g/255,i=t.b/255,a=(tu*i+-1.7884503806*r-3.5172982438*n)/(tu+-1.7884503806-3.5172982438),s=i-a,o=-((1.97294*(n-a)- -.29227*s)/.90649),l=Math.sqrt(o*o+s*s)/(1.97294*a*(1-a)),c=l?Math.atan2(o,s)*e8-120:NaN;return new tf(c<0?c+360:c,l,a,t.opacity)}(t):new tf(t,r,n,null==i?1:i)}function tf(t,r,n,i){this.h=+t,this.s=+r,this.l=+n,this.opacity=+i}function tp(t,r,n,i,a){var s=t*t,o=s*t;return((1-3*t+3*s-o)*r+(4-6*s+3*o)*n+(1+3*t+3*s-3*o)*i+o*a)/6}eA(tf,th,eE(eS,{brighter(t){return t=null==t?1.4285714285714286:Math.pow(1.4285714285714286,t),new tf(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?.7:Math.pow(.7,t),new tf(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=isNaN(this.h)?0:(this.h+120)*e6,r=+this.l,n=isNaN(this.s)?0:this.s*r*(1-r),i=Math.cos(t),a=Math.sin(t);return new eY(255*(r+n*(-.14861*i+1.78277*a)),255*(r+n*(-.29227*i+-.90649*a)),255*(r+1.97294*i*n),this.opacity)}}));var tg=t=>()=>t;function tm(t,r){return function(n){return t+n*r}}function ty(t,r){var n=r-t;return n?tm(t,n>180||n<-180?n-360*Math.round(n/360):n):tg(isNaN(t)?r:t)}function tv(t,r){var n=r-t;return n?tm(t,n):tg(isNaN(t)?r:t)}var tb=function t(r){var n,i=1==(n=+r)?tv:function(t,r){var i,a,s;return r-t?(i=t,a=r,i=Math.pow(i,s=n),a=Math.pow(a,s)-i,s=1/s,function(t){return Math.pow(i+t*a,s)}):tg(isNaN(t)?r:t)};function a(t,r){var n=i((t=eV(t)).r,(r=eV(r)).r),a=i(t.g,r.g),s=i(t.b,r.b),o=tv(t.opacity,r.opacity);return function(r){return t.r=n(r),t.g=a(r),t.b=s(r),t.opacity=o(r),t+""}}return a.gamma=t,a}(1);function tx(t){return function(r){var n,i,a=r.length,s=Array(a),o=Array(a),l=Array(a);for(n=0;n<a;++n)i=eV(r[n]),s[n]=i.r||0,o[n]=i.g||0,l[n]=i.b||0;return s=t(s),o=t(o),l=t(l),i.opacity=1,function(t){return i.r=s(t),i.g=o(t),i.b=l(t),i+""}}}function tw(t,r){return t*=1,r*=1,function(n){return t*(1-n)+r*n}}tx(function(t){var r=t.length-1;return function(n){var i=n<=0?n=0:n>=1?(n=1,r-1):Math.floor(n*r),a=t[i],s=t[i+1],o=i>0?t[i-1]:2*a-s,l=i<r-1?t[i+2]:2*s-a;return tp((n-i/r)*r,o,a,s,l)}}),tx(function(t){var r=t.length;return function(n){var i=Math.floor(((n%=1)<0?++n:n)*r),a=t[(i+r-1)%r],s=t[i%r],o=t[(i+1)%r],l=t[(i+2)%r];return tp((n-i/r)*r,a,s,o,l)}});var t$=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,tk=RegExp(t$.source,"g");function tM(t,r){var n,i,a,s,o,l=t$.lastIndex=tk.lastIndex=0,c=-1,d=[],u=[];for(t+="",r+="";(a=t$.exec(t))&&(s=tk.exec(r));)(o=s.index)>l&&(o=r.slice(l,o),d[c]?d[c]+=o:d[++c]=o),(a=a[0])===(s=s[0])?d[c]?d[c]+=s:d[++c]=s:(d[++c]=null,u.push({i:c,x:tw(a,s)})),l=tk.lastIndex;return l<r.length&&(o=r.slice(l),d[c]?d[c]+=o:d[++c]=o),d.length<2?u[0]?(n=u[0].x,function(t){return n(t)+""}):(i=r,function(){return i}):(r=u.length,function(t){for(var n,i=0;i<r;++i)d[(n=u[i]).i]=n.x(t);return d.join("")})}function t_(t,r){var n,i,a=typeof r;return null==r||"boolean"===a?tg(r):("number"===a?tw:"string"===a?(i=eW(r))?(r=i,tb):tM:r instanceof eW?tb:r instanceof Date?function(t,r){var n=new Date;return t*=1,r*=1,function(i){return n.setTime(t*(1-i)+r*i),n}}:!ArrayBuffer.isView(n=r)||n instanceof DataView?Array.isArray(r)?function(t,r){var n,i=r?r.length:0,a=t?Math.min(i,t.length):0,s=Array(a),o=Array(i);for(n=0;n<a;++n)s[n]=t_(t[n],r[n]);for(;n<i;++n)o[n]=r[n];return function(t){for(n=0;n<a;++n)o[n]=s[n](t);return o}}:"function"!=typeof r.valueOf&&"function"!=typeof r.toString||isNaN(r)?function(t,r){var n,i={},a={};for(n in(null===t||"object"!=typeof t)&&(t={}),(null===r||"object"!=typeof r)&&(r={}),r)n in t?i[n]=t_(t[n],r[n]):a[n]=r[n];return function(t){for(n in i)a[n]=i[n](t);return a}}:tw:function(t,r){r||(r=[]);var n,i=t?Math.min(r.length,t.length):0,a=r.slice();return function(s){for(n=0;n<i;++n)a[n]=t[n]*(1-s)+r[n]*s;return a}})(t,r)}var tA=180/Math.PI,tE={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function tS(t,r,n,i,a,s){var o,l,c;return(o=Math.sqrt(t*t+r*r))&&(t/=o,r/=o),(c=t*n+r*i)&&(n-=t*c,i-=r*c),(l=Math.sqrt(n*n+i*i))&&(n/=l,i/=l,c/=l),t*i<r*n&&(t=-t,r=-r,c=-c,o=-o),{translateX:a,translateY:s,rotate:Math.atan2(r,t)*tA,skewX:Math.atan(c)*tA,scaleX:o,scaleY:l}}function tC(t,r,n,i){function a(t){return t.length?t.pop()+" ":""}return function(s,o){var l,c,d,u,h=[],f=[];return s=t(s),o=t(o),!function(t,i,a,s,o,l){if(t!==a||i!==s){var c=o.push("translate(",null,r,null,n);l.push({i:c-4,x:tw(t,a)},{i:c-2,x:tw(i,s)})}else(a||s)&&o.push("translate("+a+r+s+n)}(s.translateX,s.translateY,o.translateX,o.translateY,h,f),l=s.rotate,c=o.rotate,l!==c?(l-c>180?c+=360:c-l>180&&(l+=360),f.push({i:h.push(a(h)+"rotate(",null,i)-2,x:tw(l,c)})):c&&h.push(a(h)+"rotate("+c+i),d=s.skewX,u=o.skewX,d!==u?f.push({i:h.push(a(h)+"skewX(",null,i)-2,x:tw(d,u)}):u&&h.push(a(h)+"skewX("+u+i),!function(t,r,n,i,s,o){if(t!==n||r!==i){var l=s.push(a(s)+"scale(",null,",",null,")");o.push({i:l-4,x:tw(t,n)},{i:l-2,x:tw(r,i)})}else(1!==n||1!==i)&&s.push(a(s)+"scale("+n+","+i+")")}(s.scaleX,s.scaleY,o.scaleX,o.scaleY,h,f),s=o=null,function(t){for(var r,n=-1,i=f.length;++n<i;)h[(r=f[n]).i]=r.x(t);return h.join("")}}}var tT=tC(function(t){let r=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(t+"");return r.isIdentity?tE:tS(r.a,r.b,r.c,r.d,r.e,r.f)},"px, ","px)","deg)"),tI=tC(function(t){return null==t?tE:(tz||(tz=document.createElementNS("http://www.w3.org/2000/svg","g")),tz.setAttribute("transform",t),t=tz.transform.baseVal.consolidate())?tS((t=t.matrix).a,t.b,t.c,t.d,t.e,t.f):tE},", ",")",")");function tN(t){return((t=Math.exp(t))+1/t)/2}var tO=function t(r,n,i){function a(t,a){var s,o,l=t[0],c=t[1],d=t[2],u=a[0],h=a[1],f=a[2],p=u-l,g=h-c,m=p*p+g*g;if(m<1e-12)o=Math.log(f/d)/r,s=function(t){return[l+t*p,c+t*g,d*Math.exp(r*t*o)]};else{var y=Math.sqrt(m),v=(f*f-d*d+i*m)/(2*d*n*y),b=(f*f-d*d-i*m)/(2*f*n*y),x=Math.log(Math.sqrt(v*v+1)-v);o=(Math.log(Math.sqrt(b*b+1)-b)-x)/r,s=function(t){var i,a,s=t*o,u=tN(x),h=d/(n*y)*(u*(((i=Math.exp(2*(i=r*s+x)))-1)/(i+1))-((a=Math.exp(a=x))-1/a)/2);return[l+h*p,c+h*g,d*u/tN(r*s+x)]}}return s.duration=1e3*Math.abs(o)*r/Math.SQRT2,s}return a.rho=function(r){var n=Math.max(.001,+r),i=n*n;return t(n,i,i*i)},a}(Math.SQRT2,2,4);function tD(t){return function(r,n){var i=t((r=e1(r)).h,(n=e1(n)).h),a=tv(r.s,n.s),s=tv(r.l,n.l),o=tv(r.opacity,n.opacity);return function(t){return r.h=i(t),r.s=a(t),r.l=s(t),r.opacity=o(t),r+""}}}function tR(t){return function(r,n){var i=t((r=tl(r)).h,(n=tl(n)).h),a=tv(r.c,n.c),s=tv(r.l,n.l),o=tv(r.opacity,n.opacity);return function(t){return r.h=i(t),r.c=a(t),r.l=s(t),r.opacity=o(t),r+""}}}function tL(t){return function r(n){function i(r,i){var a=t((r=th(r)).h,(i=th(i)).h),s=tv(r.s,i.s),o=tv(r.l,i.l),l=tv(r.opacity,i.opacity);return function(t){return r.h=a(t),r.s=s(t),r.l=o(Math.pow(t,n)),r.opacity=l(t),r+""}}return n*=1,i.gamma=r,i}(1)}tD(ty),tD(tv),tR(ty),tR(tv),tL(ty),tL(tv);var tz,tP,tj,tF=0,tB=0,tW=0,tH=0,tU=0,tq=0,tV="object"==typeof performance&&performance.now?performance:Date,tY="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function tG(){return tU||(tY(tZ),tU=tV.now()+tq)}function tZ(){tU=0}function tX(){this._call=this._time=this._next=null}function tK(t,r,n){var i=new tX;return i.restart(t,r,n),i}function tJ(){tU=(tH=tV.now())+tq,tF=tB=0;try{tG(),++tF;for(var t,r=tP;r;)(t=tU-r._time)>=0&&r._call.call(void 0,t),r=r._next;--tF}finally{tF=0,function(){for(var t,r,n=tP,i=1/0;n;)n._call?(i>n._time&&(i=n._time),t=n,n=n._next):(r=n._next,n._next=null,n=t?t._next=r:tP=r);tj=t,t0(i)}(),tU=0}}function tQ(){var t=tV.now(),r=t-tH;r>1e3&&(tq-=r,tH=t)}function t0(t){!tF&&(tB&&(tB=clearTimeout(tB)),t-tU>24?(t<1/0&&(tB=setTimeout(tJ,Math.ceil(t-tV.now()-tq)+1)),tW&&(tW=clearInterval(tW))):(tW||(tH=tV.now(),tW=setInterval(tQ,1e3)),tF=1,tY(tJ)))}function t1(t,r,n){var i=new tX;return r=null==r?0:+r,i.restart(n=>{i.stop(),t(n+r)},r,n),i}function t2(t){return(Math.pow(2,-10*t)-9765625e-10)*1.0009775171065494}tX.prototype=tK.prototype={constructor:tX,restart:function(t,r,n){if("function"!=typeof t)throw TypeError("callback is not a function");n=(null==n?tG():+n)+(null==r?0:+r),this._next||tj===this||(tj?tj._next=this:tP=this,tj=this),this._call=t,this._time=n,t0()},stop:function(){this._call&&(this._call=null,this._time=1/0,t0())}},!function t(r){function n(t){return Math.pow(t,r)}return r*=1,n.exponent=t,n}(3),function t(r){function n(t){return 1-Math.pow(1-t,r)}return r*=1,n.exponent=t,n}(3),function t(r){function n(t){return((t*=2)<=1?Math.pow(t,r):2-Math.pow(2-t,r))/2}return r*=1,n.exponent=t,n}(3),!function t(r){function n(t){return(t*=1)*t*(r*(t-1)+t)}return r*=1,n.overshoot=t,n}(1.70158),function t(r){function n(t){return--t*t*((t+1)*r+t)+1}return r*=1,n.overshoot=t,n}(1.70158),function t(r){function n(t){return((t*=2)<1?t*t*((r+1)*t-r):(t-=2)*t*((r+1)*t+r)+2)/2}return r*=1,n.overshoot=t,n}(1.70158);var t4=2*Math.PI;!function t(r,n){var i=Math.asin(1/(r=Math.max(1,r)))*(n/=t4);function a(t){return r*t2(- --t)*Math.sin((i-t)/n)}return a.amplitude=function(r){return t(r,n*t4)},a.period=function(n){return t(r,n)},a}(1,.3),function t(r,n){var i=Math.asin(1/(r=Math.max(1,r)))*(n/=t4);function a(t){return 1-r*t2(t*=1)*Math.sin((t+i)/n)}return a.amplitude=function(r){return t(r,n*t4)},a.period=function(n){return t(r,n)},a}(1,.3),function t(r,n){var i=Math.asin(1/(r=Math.max(1,r)))*(n/=t4);function a(t){return((t=2*t-1)<0?r*t2(-t)*Math.sin((i-t)/n):2-r*t2(t)*Math.sin((i+t)/n))/2}return a.amplitude=function(r){return t(r,n*t4)},a.period=function(n){return t(r,n)},a}(1,.3);var t3=b("start","end","cancel","interrupt"),t5=[];function t6(t,r,n,i,a,s){var o=t.__transition;if(o){if(n in o)return}else t.__transition={};!function(t,r,n){var i,a=t.__transition;function s(c){var d,u,h,f;if(1!==n.state)return l();for(d in a)if((f=a[d]).name===n.name){if(3===f.state)return t1(s);4===f.state?(f.state=6,f.timer.stop(),f.on.call("interrupt",t,t.__data__,f.index,f.group),delete a[d]):+d<r&&(f.state=6,f.timer.stop(),f.on.call("cancel",t,t.__data__,f.index,f.group),delete a[d])}if(t1(function(){3===n.state&&(n.state=4,n.timer.restart(o,n.delay,n.time),o(c))}),n.state=2,n.on.call("start",t,t.__data__,n.index,n.group),2===n.state){for(d=0,n.state=3,i=Array(h=n.tween.length),u=-1;d<h;++d)(f=n.tween[d].value.call(t,t.__data__,n.index,n.group))&&(i[++u]=f);i.length=u+1}}function o(r){for(var a=r<n.duration?n.ease.call(null,r/n.duration):(n.timer.restart(l),n.state=5,1),s=-1,o=i.length;++s<o;)i[s].call(t,a);5===n.state&&(n.on.call("end",t,t.__data__,n.index,n.group),l())}function l(){for(var i in n.state=6,n.timer.stop(),delete a[r],a)return;delete t.__transition}a[r]=n,n.timer=tK(function(t){n.state=1,n.timer.restart(s,n.delay,n.time),n.delay<=t&&s(t-n.delay)},0,n.time)}(t,n,{name:r,index:i,group:a,on:t3,tween:t5,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:0})}function t8(t,r){var n=t7(t,r);if(n.state>0)throw Error("too late; already scheduled");return n}function t9(t,r){var n=t7(t,r);if(n.state>3)throw Error("too late; already running");return n}function t7(t,r){var n=t.__transition;if(!n||!(n=n[r]))throw Error("transition not found");return n}function re(t,r){var n,i,a,s=t.__transition,o=!0;if(s){for(a in r=null==r?null:r+"",s){if((n=s[a]).name!==r){o=!1;continue}i=n.state>2&&n.state<5,n.state=6,n.timer.stop(),n.on.call(i?"interrupt":"cancel",t,t.__data__,n.index,n.group),delete s[a]}o&&delete t.__transition}}function rt(t,r,n){var i=t._id;return t.each(function(){var t=t9(this,i);(t.value||(t.value={}))[r]=n.apply(this,arguments)}),function(t){return t7(t,i).value[r]}}function rr(t,r){var n;return("number"==typeof r?tw:r instanceof eW?tb:(n=eW(r))?(r=n,tb):tM)(t,r)}var rn=el.prototype.constructor;function ri(t){return function(){this.style.removeProperty(t)}}var ra=0;function rs(t,r,n,i){this._groups=t,this._parents=r,this._name=n,this._id=i}var ro=el.prototype;rs.prototype=(function(t){return el().transition(t)}).prototype={constructor:rs,select:function(t){var r=this._name,n=this._id;"function"!=typeof t&&(t=E(t));for(var i=this._groups,a=i.length,s=Array(a),o=0;o<a;++o)for(var l,c,d=i[o],u=d.length,h=s[o]=Array(u),f=0;f<u;++f)(l=d[f])&&(c=t.call(l,l.__data__,f,d))&&("__data__"in l&&(c.__data__=l.__data__),h[f]=c,t6(h[f],r,n,f,h,t7(l,n)));return new rs(s,this._parents,r,n)},selectAll:function(t){var r=this._name,n=this._id;"function"!=typeof t&&(t=C(t));for(var i=this._groups,a=i.length,s=[],o=[],l=0;l<a;++l)for(var c,d=i[l],u=d.length,h=0;h<u;++h)if(c=d[h]){for(var f,p=t.call(c,c.__data__,h,d),g=t7(c,n),m=0,y=p.length;m<y;++m)(f=p[m])&&t6(f,r,n,m,p,g);s.push(p),o.push(c)}return new rs(s,o,r,n)},selectChild:ro.selectChild,selectChildren:ro.selectChildren,filter:function(t){"function"!=typeof t&&(t=T(t));for(var r=this._groups,n=r.length,i=Array(n),a=0;a<n;++a)for(var s,o=r[a],l=o.length,c=i[a]=[],d=0;d<l;++d)(s=o[d])&&t.call(s,s.__data__,d,o)&&c.push(s);return new rs(i,this._parents,this._name,this._id)},merge:function(t){if(t._id!==this._id)throw Error();for(var r=this._groups,n=t._groups,i=r.length,a=n.length,s=Math.min(i,a),o=Array(i),l=0;l<s;++l)for(var c,d=r[l],u=n[l],h=d.length,f=o[l]=Array(h),p=0;p<h;++p)(c=d[p]||u[p])&&(f[p]=c);for(;l<i;++l)o[l]=r[l];return new rs(o,this._parents,this._name,this._id)},selection:function(){return new rn(this._groups,this._parents)},transition:function(){for(var t=this._name,r=this._id,n=++ra,i=this._groups,a=i.length,s=0;s<a;++s)for(var o,l=i[s],c=l.length,d=0;d<c;++d)if(o=l[d]){var u=t7(o,r);t6(o,t,n,d,l,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new rs(i,this._parents,t,n)},call:ro.call,nodes:ro.nodes,node:ro.node,size:ro.size,empty:ro.empty,each:ro.each,on:function(t,r){var n,i,a,s,o,l,c=this._id;return arguments.length<2?t7(this.node(),c).on.on(t):this.each((n=c,i=t,a=r,l=(i+"").trim().split(/^|\s+/).every(function(t){var r=t.indexOf(".");return r>=0&&(t=t.slice(0,r)),!t||"start"===t})?t8:t9,function(){var t=l(this,n),r=t.on;r!==s&&(o=(s=r).copy()).on(i,a),t.on=o}))},attr:function(t,r){var n=M(t),i="transform"===n?tI:rr;return this.attrTween(t,"function"==typeof r?(n.local?function(t,r,n){var i,a,s;return function(){var o,l,c=n(this);return null==c?void this.removeAttributeNS(t.space,t.local):(o=this.getAttributeNS(t.space,t.local))===(l=c+"")?null:o===i&&l===a?s:(a=l,s=r(i=o,c))}}:function(t,r,n){var i,a,s;return function(){var o,l,c=n(this);return null==c?void this.removeAttribute(t):(o=this.getAttribute(t))===(l=c+"")?null:o===i&&l===a?s:(a=l,s=r(i=o,c))}})(n,i,rt(this,"attr."+t,r)):null==r?(n.local?function(t){return function(){this.removeAttributeNS(t.space,t.local)}}:function(t){return function(){this.removeAttribute(t)}})(n):(n.local?function(t,r,n){var i,a,s=n+"";return function(){var o=this.getAttributeNS(t.space,t.local);return o===s?null:o===i?a:a=r(i=o,n)}}:function(t,r,n){var i,a,s=n+"";return function(){var o=this.getAttribute(t);return o===s?null:o===i?a:a=r(i=o,n)}})(n,i,r))},attrTween:function(t,r){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==r)return this.tween(n,null);if("function"!=typeof r)throw Error();var i=M(t);return this.tween(n,(i.local?function(t,r){var n,i;function a(){var a=r.apply(this,arguments);return a!==i&&(n=(i=a)&&function(r){this.setAttributeNS(t.space,t.local,a.call(this,r))}),n}return a._value=r,a}:function(t,r){var n,i;function a(){var a=r.apply(this,arguments);return a!==i&&(n=(i=a)&&function(r){this.setAttribute(t,a.call(this,r))}),n}return a._value=r,a})(i,r))},style:function(t,r,n){var i,a,s,o,l,c,d,u,h,f,p,g,m,y,v,b,x,w,$,k,M,_="transform"==(t+="")?tT:rr;return null==r?this.styleTween(t,(i=t,function(){var t=H(this,i),r=(this.style.removeProperty(i),H(this,i));return t===r?null:t===a&&r===s?o:o=_(a=t,s=r)})).on("end.style."+t,ri(t)):"function"==typeof r?this.styleTween(t,(l=t,c=rt(this,"style."+t,r),function(){var t=H(this,l),r=c(this),n=r+"";return null==r&&(this.style.removeProperty(l),n=r=H(this,l)),t===n?null:t===d&&n===u?h:(u=n,h=_(d=t,r))})).each((f=this._id,x="end."+(b="style."+(p=t)),function(){var t=t9(this,f),r=t.on,n=null==t.value[b]?v||(v=ri(p)):void 0;(r!==g||y!==n)&&(m=(g=r).copy()).on(x,y=n),t.on=m})):this.styleTween(t,(w=t,M=r+"",function(){var t=H(this,w);return t===M?null:t===$?k:k=_($=t,r)}),n).on("end.style."+t,null)},styleTween:function(t,r,n){var i="style."+(t+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(null==r)return this.tween(i,null);if("function"!=typeof r)throw Error();return this.tween(i,function(t,r,n){var i,a;function s(){var s=r.apply(this,arguments);return s!==a&&(i=(a=s)&&function(r){this.style.setProperty(t,s.call(this,r),n)}),i}return s._value=r,s}(t,r,null==n?"":n))},text:function(t){var r,n;return this.tween("text","function"==typeof t?(r=rt(this,"text",t),function(){var t=r(this);this.textContent=null==t?"":t}):(n=null==t?"":t+"",function(){this.textContent=n}))},textTween:function(t){var r="text";if(arguments.length<1)return(r=this.tween(r))&&r._value;if(null==t)return this.tween(r,null);if("function"!=typeof t)throw Error();return this.tween(r,function(t){var r,n;function i(){var i=t.apply(this,arguments);return i!==n&&(r=(n=i)&&function(t){this.textContent=i.call(this,t)}),r}return i._value=t,i}(t))},remove:function(){var t;return this.on("end.remove",(t=this._id,function(){var r=this.parentNode;for(var n in this.__transition)if(+n!==t)return;r&&r.removeChild(this)}))},tween:function(t,r){var n=this._id;if(t+="",arguments.length<2){for(var i,a=t7(this.node(),n).tween,s=0,o=a.length;s<o;++s)if((i=a[s]).name===t)return i.value;return null}return this.each((null==r?function(t,r){var n,i;return function(){var a=t9(this,t),s=a.tween;if(s!==n){i=n=s;for(var o=0,l=i.length;o<l;++o)if(i[o].name===r){(i=i.slice()).splice(o,1);break}}a.tween=i}}:function(t,r,n){var i,a;if("function"!=typeof n)throw Error();return function(){var s=t9(this,t),o=s.tween;if(o!==i){a=(i=o).slice();for(var l={name:r,value:n},c=0,d=a.length;c<d;++c)if(a[c].name===r){a[c]=l;break}c===d&&a.push(l)}s.tween=a}})(n,t,r))},delay:function(t){var r=this._id;return arguments.length?this.each(("function"==typeof t?function(t,r){return function(){t8(this,t).delay=+r.apply(this,arguments)}}:function(t,r){return r*=1,function(){t8(this,t).delay=r}})(r,t)):t7(this.node(),r).delay},duration:function(t){var r=this._id;return arguments.length?this.each(("function"==typeof t?function(t,r){return function(){t9(this,t).duration=+r.apply(this,arguments)}}:function(t,r){return r*=1,function(){t9(this,t).duration=r}})(r,t)):t7(this.node(),r).duration},ease:function(t){var r=this._id;return arguments.length?this.each(function(t,r){if("function"!=typeof r)throw Error();return function(){t9(this,t).ease=r}}(r,t)):t7(this.node(),r).ease},easeVarying:function(t){var r;if("function"!=typeof t)throw Error();return this.each((r=this._id,function(){var n=t.apply(this,arguments);if("function"!=typeof n)throw Error();t9(this,r).ease=n}))},end:function(){var t,r,n=this,i=n._id,a=n.size();return new Promise(function(s,o){var l={value:o},c={value:function(){0==--a&&s()}};n.each(function(){var n=t9(this,i),a=n.on;a!==t&&((r=(t=a).copy())._.cancel.push(l),r._.interrupt.push(l),r._.end.push(c)),n.on=r}),0===a&&s()})},[Symbol.iterator]:ro[Symbol.iterator]};var rl={time:null,delay:0,duration:250,ease:function(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}};el.prototype.interrupt=function(t){return this.each(function(){re(this,t)})},el.prototype.transition=function(t){var r,n;t instanceof rs?(r=t._id,t=t._name):(r=++ra,(n=rl).time=tG(),t=null==t?null:t+"");for(var i=this._groups,a=i.length,s=0;s<a;++s)for(var o,l=i[s],c=l.length,d=0;d<c;++d)(o=l[d])&&t6(o,t,r,d,l,n||function(t,r){for(var n;!(n=t.__transition)||!(n=n[r]);)if(!(t=t.parentNode))throw Error(`transition ${r} not found`);return n}(o,r));return new rs(i,this._parents,t,r)};var rc=t=>()=>t;function rd(t,{sourceEvent:r,target:n,transform:i,dispatch:a}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:a}})}function ru(t,r,n){this.k=t,this.x=r,this.y=n}ru.prototype={constructor:ru,scale:function(t){return 1===t?this:new ru(this.k*t,this.x,this.y)},translate:function(t,r){return 0===t&0===r?this:new ru(this.k,this.x+this.k*t,this.y+this.k*r)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var rh=new ru(1,0,0);function rf(t){for(;!t.__zoom;)if(!(t=t.parentNode))return rh;return t.__zoom}function rp(t){t.stopImmediatePropagation()}function rg(t){t.preventDefault(),t.stopImmediatePropagation()}function rm(t){return(!t.ctrlKey||"wheel"===t.type)&&!t.button}function ry(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t).hasAttribute("viewBox")?[[(t=t.viewBox.baseVal).x,t.y],[t.x+t.width,t.y+t.height]]:[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]:[[0,0],[t.clientWidth,t.clientHeight]]}function rv(){return this.__zoom||rh}function rb(t){return-t.deltaY*(1===t.deltaMode?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function rx(){return navigator.maxTouchPoints||"ontouchstart"in this}function rw(t,r,n){var i=t.invertX(r[0][0])-n[0][0],a=t.invertX(r[1][0])-n[1][0],s=t.invertY(r[0][1])-n[0][1],o=t.invertY(r[1][1])-n[1][1];return t.translate(a>i?(i+a)/2:Math.min(0,i)||Math.max(0,a),o>s?(s+o)/2:Math.min(0,s)||Math.max(0,o))}function r$(){var t,r,n,i=rm,a=ry,s=rw,o=rb,l=rx,c=[0,1/0],d=[[-1/0,-1/0],[1/0,1/0]],u=250,h=tO,f=b("start","zoom","end"),p=0,g=10;function m(t){t.property("__zoom",rv).on("wheel.zoom",M,{passive:!1}).on("mousedown.zoom",_).on("dblclick.zoom",A).filter(l).on("touchstart.zoom",E).on("touchmove.zoom",S).on("touchend.zoom touchcancel.zoom",C).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function y(t,r){return(r=Math.max(c[0],Math.min(c[1],r)))===t.k?t:new ru(r,t.x,t.y)}function v(t,r,n){var i=r[0]-n[0]*t.k,a=r[1]-n[1]*t.k;return i===t.x&&a===t.y?t:new ru(t.k,i,a)}function x(t){return[(+t[0][0]+ +t[1][0])/2,(+t[0][1]+ +t[1][1])/2]}function w(t,r,n,i){t.on("start.zoom",function(){$(this,arguments).event(i).start()}).on("interrupt.zoom end.zoom",function(){$(this,arguments).event(i).end()}).tween("zoom",function(){var t=arguments,s=$(this,t).event(i),o=a.apply(this,t),l=null==n?x(o):"function"==typeof n?n.apply(this,t):n,c=Math.max(o[1][0]-o[0][0],o[1][1]-o[0][1]),d=this.__zoom,u="function"==typeof r?r.apply(this,t):r,f=h(d.invert(l).concat(c/d.k),u.invert(l).concat(c/u.k));return function(t){if(1===t)t=u;else{var r=f(t),n=c/r[2];t=new ru(n,l[0]-r[0]*n,l[1]-r[1]*n)}s.zoom(null,t)}})}function $(t,r,n){return!n&&t.__zooming||new k(t,r)}function k(t,r){this.that=t,this.args=r,this.active=0,this.sourceEvent=null,this.extent=a.apply(t,r),this.taps=0}function M(t,...r){if(i.apply(this,arguments)){var n=$(this,r).event(t),a=this.__zoom,l=Math.max(c[0],Math.min(c[1],a.k*Math.pow(2,o.apply(this,arguments)))),u=eh(t);if(n.wheel)(n.mouse[0][0]!==u[0]||n.mouse[0][1]!==u[1])&&(n.mouse[1]=a.invert(n.mouse[0]=u)),clearTimeout(n.wheel);else{if(a.k===l)return;n.mouse=[u,a.invert(u)],re(this),n.start()}rg(t),n.wheel=setTimeout(function(){n.wheel=null,n.end()},150),n.zoom("mouse",s(v(y(a,l),n.mouse[0],n.mouse[1]),n.extent,d))}}function _(t,...r){if(!n&&i.apply(this,arguments)){var a=t.currentTarget,o=$(this,r,!0).event(t),l=ec(t.view).on("mousemove.zoom",function(t){if(rg(t),!o.moved){var r=t.clientX-u,n=t.clientY-h;o.moved=r*r+n*n>p}o.event(t).zoom("mouse",s(v(o.that.__zoom,o.mouse[0]=eh(t,a),o.mouse[1]),o.extent,d))},!0).on("mouseup.zoom",function(t){l.on("mousemove.zoom mouseup.zoom",null),ev(t.view,o.moved),rg(t),o.event(t).end()},!0),c=eh(t,a),u=t.clientX,h=t.clientY;ey(t.view),rp(t),o.mouse=[c,this.__zoom.invert(c)],re(this),o.start()}}function A(t,...r){if(i.apply(this,arguments)){var n=this.__zoom,o=eh(t.changedTouches?t.changedTouches[0]:t,this),l=n.invert(o),c=n.k*(t.shiftKey?.5:2),h=s(v(y(n,c),o,l),a.apply(this,r),d);rg(t),u>0?ec(this).transition().duration(u).call(w,h,o,t):ec(this).call(m.transform,h,o,t)}}function E(n,...a){if(i.apply(this,arguments)){var s,o,l,c,d=n.touches,u=d.length,h=$(this,a,n.changedTouches.length===u).event(n);for(rp(n),o=0;o<u;++o)c=[c=eh(l=d[o],this),this.__zoom.invert(c),l.identifier],h.touch0?h.touch1||h.touch0[2]===c[2]||(h.touch1=c,h.taps=0):(h.touch0=c,s=!0,h.taps=1+!!t);t&&(t=clearTimeout(t)),s&&(h.taps<2&&(r=c[0],t=setTimeout(function(){t=null},500)),re(this),h.start())}}function S(t,...r){if(this.__zooming){var n,i,a,o,l=$(this,r).event(t),c=t.changedTouches,u=c.length;for(rg(t),n=0;n<u;++n)a=eh(i=c[n],this),l.touch0&&l.touch0[2]===i.identifier?l.touch0[0]=a:l.touch1&&l.touch1[2]===i.identifier&&(l.touch1[0]=a);if(i=l.that.__zoom,l.touch1){var h=l.touch0[0],f=l.touch0[1],p=l.touch1[0],g=l.touch1[1],m=(m=p[0]-h[0])*m+(m=p[1]-h[1])*m,b=(b=g[0]-f[0])*b+(b=g[1]-f[1])*b;i=y(i,Math.sqrt(m/b)),a=[(h[0]+p[0])/2,(h[1]+p[1])/2],o=[(f[0]+g[0])/2,(f[1]+g[1])/2]}else{if(!l.touch0)return;a=l.touch0[0],o=l.touch0[1]}l.zoom("touch",s(v(i,a,o),l.extent,d))}}function C(t,...i){if(this.__zooming){var a,s,o=$(this,i).event(t),l=t.changedTouches,c=l.length;for(rp(t),n&&clearTimeout(n),n=setTimeout(function(){n=null},500),a=0;a<c;++a)s=l[a],o.touch0&&o.touch0[2]===s.identifier?delete o.touch0:o.touch1&&o.touch1[2]===s.identifier&&delete o.touch1;if(o.touch1&&!o.touch0&&(o.touch0=o.touch1,delete o.touch1),o.touch0)o.touch0[1]=this.__zoom.invert(o.touch0[0]);else if(o.end(),2===o.taps&&(s=eh(s,this),Math.hypot(r[0]-s[0],r[1]-s[1])<g)){var d=ec(this).on("dblclick.zoom");d&&d.apply(this,arguments)}}}return m.transform=function(t,r,n,i){var a=t.selection?t.selection():t;a.property("__zoom",rv),t!==a?w(t,r,n,i):a.interrupt().each(function(){$(this,arguments).event(i).start().zoom(null,"function"==typeof r?r.apply(this,arguments):r).end()})},m.scaleBy=function(t,r,n,i){m.scaleTo(t,function(){var t=this.__zoom.k,n="function"==typeof r?r.apply(this,arguments):r;return t*n},n,i)},m.scaleTo=function(t,r,n,i){m.transform(t,function(){var t=a.apply(this,arguments),i=this.__zoom,o=null==n?x(t):"function"==typeof n?n.apply(this,arguments):n,l=i.invert(o),c="function"==typeof r?r.apply(this,arguments):r;return s(v(y(i,c),o,l),t,d)},n,i)},m.translateBy=function(t,r,n,i){m.transform(t,function(){return s(this.__zoom.translate("function"==typeof r?r.apply(this,arguments):r,"function"==typeof n?n.apply(this,arguments):n),a.apply(this,arguments),d)},null,i)},m.translateTo=function(t,r,n,i,o){m.transform(t,function(){var t=a.apply(this,arguments),o=this.__zoom,l=null==i?x(t):"function"==typeof i?i.apply(this,arguments):i;return s(rh.translate(l[0],l[1]).scale(o.k).translate("function"==typeof r?-r.apply(this,arguments):-r,"function"==typeof n?-n.apply(this,arguments):-n),t,d)},i,o)},k.prototype={event:function(t){return t&&(this.sourceEvent=t),this},start:function(){return 1==++this.active&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(t,r){return this.mouse&&"mouse"!==t&&(this.mouse[1]=r.invert(this.mouse[0])),this.touch0&&"touch"!==t&&(this.touch0[1]=r.invert(this.touch0[0])),this.touch1&&"touch"!==t&&(this.touch1[1]=r.invert(this.touch1[0])),this.that.__zoom=r,this.emit("zoom"),this},end:function(){return 0==--this.active&&(delete this.that.__zooming,this.emit("end")),this},emit:function(t){var r=ec(this.that).datum();f.call(t,this.that,new rd(t,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:f}),r)}},m.wheelDelta=function(t){return arguments.length?(o="function"==typeof t?t:rc(+t),m):o},m.filter=function(t){return arguments.length?(i="function"==typeof t?t:rc(!!t),m):i},m.touchable=function(t){return arguments.length?(l="function"==typeof t?t:rc(!!t),m):l},m.extent=function(t){return arguments.length?(a="function"==typeof t?t:rc([[+t[0][0],+t[0][1]],[+t[1][0],+t[1][1]]]),m):a},m.scaleExtent=function(t){return arguments.length?(c[0]=+t[0],c[1]=+t[1],m):[c[0],c[1]]},m.translateExtent=function(t){return arguments.length?(d[0][0]=+t[0][0],d[1][0]=+t[1][0],d[0][1]=+t[0][1],d[1][1]=+t[1][1],m):[[d[0][0],d[0][1]],[d[1][0],d[1][1]]]},m.constrain=function(t){return arguments.length?(s=t,m):s},m.duration=function(t){return arguments.length?(u=+t,m):u},m.interpolate=function(t){return arguments.length?(h=t,m):h},m.on=function(){var t=f.on.apply(f,arguments);return t===f?m:t},m.clickDistance=function(t){return arguments.length?(p=(t*=1)*t,m):Math.sqrt(p)},m.tapDistance=function(t){return arguments.length?(g=+t,m):g},m}rf.prototype=ru.prototype;let rk={error001:(t="react")=>`Seems like you have not used ${"svelte"===t?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${t}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:t=>`Node type "${t}" 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:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:r,sourceHandle:n,targetHandle:i})=>`Couldn't create edge for ${t} handle id: "${"source"===t?n:i}", edge id: ${r}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(t="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${t}/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:t=>`Edge with id "${t}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},rM=[[-1/0,-1/0],[1/0,1/0]],r_=["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:t,x:r,y:n})=>`Moved selected node ${t}. New position, x: ${r}, 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"};(i=u||(u={})).Strict="strict",i.Loose="loose",(a=h||(h={})).Free="free",a.Vertical="vertical",a.Horizontal="horizontal",(s=f||(f={})).Partial="partial",s.Full="full";let rE={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};(o=p||(p={})).Bezier="default",o.Straight="straight",o.Step="step",o.SmoothStep="smoothstep",o.SimpleBezier="simplebezier",(l=g||(g={})).Arrow="arrow",l.ArrowClosed="arrowclosed",(c=m||(m={})).Left="left",c.Top="top",c.Right="right",c.Bottom="bottom";let rS={[m.Left]:m.Right,[m.Right]:m.Left,[m.Top]:m.Bottom,[m.Bottom]:m.Top},rC=t=>!!t&&"object"==typeof t&&"id"in t&&"source"in t&&"target"in t,rT=t=>!!t&&"object"==typeof t&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),rI=t=>!!t&&"object"==typeof t&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),rN=(t,r=[0,0])=>{let{width:n,height:i}=r9(t),a=t.origin??r,s=n*a[0],o=i*a[1];return{x:t.position.x-s,y:t.position.y-o}},rO=(t,r={nodeOrigin:[0,0]})=>{if(0===t.length)return{x:0,y:0,width:0,height:0};let n=!1,i=t.reduce((t,i)=>{let a="string"==typeof i,s=r.nodeLookup||a?void 0:i;return(r.nodeLookup&&(s=a?r.nodeLookup.get(i):rI(i)?i:r.nodeLookup.get(i.id)),s)?(n=!0,rU(t,rG(s,r.nodeOrigin))):t},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?rV(i):{x:0,y:0,width:0,height:0}},rD=(t,r={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},i=!1;return t.forEach(t=>{(void 0===r.filter||r.filter(t))&&(n=rU(n,rG(t)),i=!0)}),i?rV(n):{x:0,y:0,width:0,height:0}},rR=(t,r,[n,i,a]=[0,0,1],s=!1,o=!1)=>{let l=(r.x-n)/a,c=(r.y-i)/a,d=r.width/a,u=r.height/a,h=[];for(let r of t.values()){let{measured:t,selectable:n=!0,hidden:i=!1}=r;if(o&&!n||i)continue;let a=t.width??r.width??r.initialWidth??0,f=t.height??r.height??r.initialHeight??0,{x:p,y:g}=r.internals.positionAbsolute,m=rX(l,c,d,u,p,g,a,f),y=a*f,v=s&&m>0;(!r.internals.handleBounds||v||m>=y||r.dragging)&&h.push(r)}return h};async function rL({nodes:t,width:r,height:n,panZoom:i,minZoom:a,maxZoom:s},o){let l,c;if(0===t.size)return!0;let d=r5(rD((l=new Map,c=o?.nodes?new Set(o.nodes.map(t=>t.id)):null,t.forEach(t=>{let r;if(o?.includeHiddenNodes){let{width:n,height:i}=r9(t);r=n>0&&i>0}else r=!!(t.measured.width&&t.measured.height&&!t.hidden);r&&(!c||c.has(t.id))&&l.set(t.id,t)}),l)),r,n,o?.minZoom??a,o?.maxZoom??s,o?.padding??.1);return await i.setViewport(d,{duration:o?.duration,ease:o?.ease,interpolate:o?.interpolate}),!0}function rz({nodeId:t,nextPosition:r,nodeLookup:n,nodeOrigin:i=[0,0],nodeExtent:a,onError:s}){let o=n.get(t),l=o.parentId?n.get(o.parentId):void 0,{x:c,y:d}=l?l.internals.positionAbsolute:{x:0,y:0},u=o.origin??i,h=o.extent||a;if("parent"!==o.extent||o.expandParent)l&&r8(o.extent)&&(h=[[o.extent[0][0]+c,o.extent[0][1]+d],[o.extent[1][0]+c,o.extent[1][1]+d]]);else if(l){let{width:t,height:r}=r9(l);t&&r&&(h=[[c,d],[c+t,d+r]])}else s?.("005",rk.error005());let f=r8(h)?rF(r,h,o.measured):r;return(void 0===o.measured.width||void 0===o.measured.height)&&s?.("015",rk.error015()),{position:{x:f.x-c+(o.measured.width??0)*u[0],y:f.y-d+(o.measured.height??0)*u[1]},positionAbsolute:f}}async function rP({nodesToRemove:t=[],edgesToRemove:r=[],nodes:n,edges:i,onBeforeDelete:a}){let s,o=new Set(t.map(t=>t.id)),l=[];for(let t of n){if(!1===t.deletable)continue;let r=o.has(t.id),n=!r&&t.parentId&&l.find(r=>r.id===t.parentId);(r||n)&&l.push(t)}let c=new Set(r.map(t=>t.id)),d=i.filter(t=>!1!==t.deletable),u=(s=new Set,l.forEach(t=>{s.add(t.id)}),d.filter(t=>s.has(t.source)||s.has(t.target)));for(let t of d)c.has(t.id)&&!u.find(r=>r.id===t.id)&&u.push(t);if(!a)return{edges:u,nodes:l};let h=await a({nodes:l,edges:u});return"boolean"==typeof h?h?{edges:u,nodes:l}:{edges:[],nodes:[]}:h}let rj=(t,r=0,n=1)=>Math.min(Math.max(t,r),n),rF=(t={x:0,y:0},r,n)=>({x:rj(t.x,r[0][0],r[1][0]-(n?.width??0)),y:rj(t.y,r[0][1],r[1][1]-(n?.height??0))});function rB(t,r,n){let{width:i,height:a}=r9(n),{x:s,y:o}=n.internals.positionAbsolute;return rF(t,[[s,o],[s+i,o+a]],r)}let rW=(t,r,n)=>t<r?rj(Math.abs(t-r),1,r)/r:t>n?-rj(Math.abs(t-n),1,r)/r:0,rH=(t,r,n=15,i=40)=>[rW(t.x,i,r.width-i)*n,rW(t.y,i,r.height-i)*n],rU=(t,r)=>({x:Math.min(t.x,r.x),y:Math.min(t.y,r.y),x2:Math.max(t.x2,r.x2),y2:Math.max(t.y2,r.y2)}),rq=({x:t,y:r,width:n,height:i})=>({x:t,y:r,x2:t+n,y2:r+i}),rV=({x:t,y:r,x2:n,y2:i})=>({x:t,y:r,width:n-t,height:i-r}),rY=(t,r=[0,0])=>{let{x:n,y:i}=rI(t)?t.internals.positionAbsolute:rN(t,r);return{x:n,y:i,width:t.measured?.width??t.width??t.initialWidth??0,height:t.measured?.height??t.height??t.initialHeight??0}},rG=(t,r=[0,0])=>{let{x:n,y:i}=rI(t)?t.internals.positionAbsolute:rN(t,r);return{x:n,y:i,x2:n+(t.measured?.width??t.width??t.initialWidth??0),y2:i+(t.measured?.height??t.height??t.initialHeight??0)}},rZ=(t,r)=>rV(rU(rq(t),rq(r))),rX=(t,r,n,i,a,s,o,l)=>Math.ceil(Math.max(0,Math.min(t+n,a+o)-Math.max(t,a))*Math.max(0,Math.min(r+i,s+l)-Math.max(r,s))),rK=(t,r)=>rX(t.x,t.y,t.width,t.height,r.x,r.y,r.width,r.height),rJ=t=>rQ(t.width)&&rQ(t.height)&&rQ(t.x)&&rQ(t.y),rQ=t=>!isNaN(t)&&isFinite(t),r0=(t,r)=>(t,r)=>{},r1=(t,r=[1,1])=>({x:r[0]*Math.round(t.x/r[0]),y:r[1]*Math.round(t.y/r[1])}),r2=({x:t,y:r},[n,i,a],s=!1,o=[1,1])=>{let l={x:(t-n)/a,y:(r-i)/a};return s?r1(l,o):l},r4=({x:t,y:r},[n,i,a])=>({x:t*a+n,y:r*a+i});function r3(t,r){if("number"==typeof t)return Math.floor((r-r/(1+t))*.5);if("string"==typeof t&&t.endsWith("px")){let r=parseFloat(t);if(!Number.isNaN(r))return Math.floor(r)}if("string"==typeof t&&t.endsWith("%")){let n=parseFloat(t);if(!Number.isNaN(n))return Math.floor(r*n*.01)}return console.error(`The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}let r5=(t,r,n,i,a,s)=>{let o=function(t,r,n){if("string"==typeof t||"number"==typeof t){let i=r3(t,n),a=r3(t,r);return{top:i,right:a,bottom:i,left:a,x:2*a,y:2*i}}if("object"==typeof t){let i=r3(t.top??t.y??0,n),a=r3(t.bottom??t.y??0,n),s=r3(t.left??t.x??0,r),o=r3(t.right??t.x??0,r);return{top:i,right:o,bottom:a,left:s,x:s+o,y:i+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}(s,r,n),l=rj(Math.min((r-o.x)/t.width,(n-o.y)/t.height),i,a),c=t.x+t.width/2,d=t.y+t.height/2,u=r/2-c*l,h=n/2-d*l,f=function(t,r,n,i,a,s){let{x:o,y:l}=r4(t,[r,n,i]),{x:c,y:d}=r4({x:t.x+t.width,y:t.y+t.height},[r,n,i]);return{left:Math.floor(o),top:Math.floor(l),right:Math.floor(a-c),bottom:Math.floor(s-d)}}(t,u,h,l,r,n),p={left:Math.min(f.left-o.left,0),top:Math.min(f.top-o.top,0),right:Math.min(f.right-o.right,0),bottom:Math.min(f.bottom-o.bottom,0)};return{x:u-p.left+p.right,y:h-p.top+p.bottom,zoom:l}},r6=()=>"u">typeof navigator&&navigator?.userAgent?.indexOf("Mac")>=0;function r8(t){return null!=t&&"parent"!==t}function r9(t){return{width:t.measured?.width??t.width??t.initialWidth??0,height:t.measured?.height??t.height??t.initialHeight??0}}function r7(t){return(t.measured?.width??t.width??t.initialWidth)!==void 0&&(t.measured?.height??t.height??t.initialHeight)!==void 0}function ne(t,r={width:0,height:0},n,i,a){let s={...t},o=i.get(n);if(o){let t=o.origin||a;s.x+=o.internals.positionAbsolute.x-(r.width??0)*t[0],s.y+=o.internals.positionAbsolute.y-(r.height??0)*t[1]}return s}function nt(t,r){if(t.size!==r.size)return!1;for(let n of t)if(!r.has(n))return!1;return!0}function nr(){let t,r;return{promise:new Promise((n,i)=>{t=n,r=i}),resolve:t,reject:r}}function nn(t){return{...rA,...t||{}}}function ni(t){}function na(t){return null===t?null:t?"valid":"invalid"}function ns(t,{snapGrid:r=[0,0],snapToGrid:n=!1,transform:i,containerBounds:a}){let{x:s,y:o}=nh(t),l=r2({x:s-(a?.left??0),y:o-(a?.top??0)},i),{x:c,y:d}=n?r1(l,r):l;return{xSnapped:c,ySnapped:d,...l}}let no=t=>({width:t.offsetWidth,height:t.offsetHeight}),nl=t=>t?.getRootNode?.()||window?.document,nc=["INPUT","SELECT","TEXTAREA"];function nd(t){let r=t.composedPath?.()?.[0]||t.target;return r?.nodeType===1&&(nc.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey"))}let nu=t=>"clientX"in t,nh=(t,r)=>{let n=nu(t),i=n?t.clientX:t.touches?.[0].clientX,a=n?t.clientY:t.touches?.[0].clientY;return{x:i-(r?.left??0),y:a-(r?.top??0)}},nf=(t,r,n,i,a)=>{let s=r.querySelectorAll(`.${t}`);return s&&s.length?Array.from(s).map(r=>{let s=r.getBoundingClientRect();return{id:r.getAttribute("data-handleid"),type:t,nodeId:a,position:r.getAttribute("data-handlepos"),x:(s.left-n.left)/i,y:(s.top-n.top)/i,...no(r)}}):null};function np({sourceX:t,sourceY:r,targetX:n,targetY:i,sourceControlX:a,sourceControlY:s,targetControlX:o,targetControlY:l}){let c=.125*t+.375*a+.375*o+.125*n,d=.125*r+.375*s+.375*l+.125*i,u=Math.abs(c-t),h=Math.abs(d-r);return[c,d,u,h]}function ng(t,r){return t>=0?.5*t:25*r*Math.sqrt(-t)}function nm({pos:t,x1:r,y1:n,x2:i,y2:a,c:s}){switch(t){case m.Left:return[r-ng(r-i,s),n];case m.Right:return[r+ng(i-r,s),n];case m.Top:return[r,n-ng(n-a,s)];case m.Bottom:return[r,n+ng(a-n,s)]}}function ny({sourceX:t,sourceY:r,sourcePosition:n=m.Bottom,targetX:i,targetY:a,targetPosition:s=m.Top,curvature:o=.25}){let[l,c]=nm({pos:n,x1:t,y1:r,x2:i,y2:a,c:o}),[d,u]=nm({pos:s,x1:i,y1:a,x2:t,y2:r,c:o}),[h,f,p,g]=np({sourceX:t,sourceY:r,targetX:i,targetY:a,sourceControlX:l,sourceControlY:c,targetControlX:d,targetControlY:u});return[`M${t},${r} C${l},${c} ${d},${u} ${i},${a}`,h,f,p,g]}function nv({sourceX:t,sourceY:r,targetX:n,targetY:i}){let a=Math.abs(n-t)/2,s=Math.abs(i-r)/2;return[n<t?n+a:n-a,i<r?i+s:i-s,a,s]}function nb({sourceNode:t,targetNode:r,selected:n=!1,zIndex:i=0,elevateOnSelect:a=!1,zIndexMode:s="basic"}){if("manual"===s)return i;let o=Math.max(t.parentId||a&&t.selected?t.internals.z:0,r.parentId||a&&r.selected?r.internals.z:0);return(a&&n?i+1e3:i)+o}function nx({sourceNode:t,targetNode:r,width:n,height:i,transform:a}){let s=rU(rG(t),rG(r));return s.x===s.x2&&(s.x2+=1),s.y===s.y2&&(s.y2+=1),rK({x:-a[0]/a[2],y:-a[1]/a[2],width:n/a[2],height:i/a[2]},rV(s))>0}let nw=({source:t,sourceHandle:r,target:n,targetHandle:i})=>`xy-edge__${t}${r||""}-${n}${i||""}`,n$=(t,r,n={})=>{let i,a;if(!t.source||!t.target)return n.onError?.("006",rk.error006()),r;let s=n.getEdgeId||nw;return(a=i=rC(t)?{...t}:{...t,id:s(t)},r.some(t=>t.source===a.source&&t.target===a.target&&(t.sourceHandle===a.sourceHandle||!t.sourceHandle&&!a.sourceHandle)&&(t.targetHandle===a.targetHandle||!t.targetHandle&&!a.targetHandle)))?r:(null===i.sourceHandle&&delete i.sourceHandle,null===i.targetHandle&&delete i.targetHandle,r.concat(i))};function nk({sourceX:t,sourceY:r,targetX:n,targetY:i}){let[a,s,o,l]=nv({sourceX:t,sourceY:r,targetX:n,targetY:i});return[`M ${t},${r}L ${n},${i}`,a,s,o,l]}let nM={[m.Left]:{x:-1,y:0},[m.Right]:{x:1,y:0},[m.Top]:{x:0,y:-1},[m.Bottom]:{x:0,y:1}},n_=({source:t,sourcePosition:r=m.Bottom,target:n})=>r===m.Left||r===m.Right?t.x<n.x?{x:1,y:0}:{x:-1,y:0}:t.y<n.y?{x:0,y:1}:{x:0,y:-1},nA=(t,r)=>Math.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2)),nE=(t,r,n)=>t.x===r.x&&r.x===n.x&&(r.y-t.y)*(n.y-r.y)>=0||t.y===r.y&&r.y===n.y&&(r.x-t.x)*(n.x-r.x)>=0;function nS({sourceX:t,sourceY:r,sourcePosition:n=m.Bottom,targetX:i,targetY:a,targetPosition:s=m.Top,borderRadius:o=5,centerX:l,centerY:c,offset:d=20,stepPosition:u=.5}){let[h,f,p,g,y]=function({source:t,sourcePosition:r=m.Bottom,target:n,targetPosition:i=m.Top,center:a,offset:s,stepPosition:o}){let l,c,d=nM[r],u=nM[i],h={x:t.x+d.x*s,y:t.y+d.y*s},f={x:n.x+u.x*s,y:n.y+u.y*s},p=n_({source:h,sourcePosition:r,target:f}),g=0!==p.x?"x":"y",y=p[g],v=[],b={x:0,y:0},x={x:0,y:0},[,,w,$]=nv({sourceX:t.x,sourceY:t.y,targetX:n.x,targetY:n.y});if(d[g]*u[g]==-1){"x"===g?(l=a.x??h.x+(f.x-h.x)*o,c=a.y??(h.y+f.y)/2):(l=a.x??(h.x+f.x)/2,c=a.y??h.y+(f.y-h.y)*o);let t=[{x:l,y:h.y},{x:l,y:f.y}],r=[{x:h.x,y:c},{x:f.x,y:c}];v=d[g]===y?"x"===g?t:r:"x"===g?r:t}else{let a=[{x:h.x,y:f.y}],o=[{x:f.x,y:h.y}];if(v="x"===g?d.x===y?o:a:d.y===y?a:o,r===i){let r=Math.abs(t[g]-n[g]);if(r<=s){let i=Math.min(s-1,s-r);d[g]===y?b[g]=(h[g]>t[g]?-1:1)*i:x[g]=(f[g]>n[g]?-1:1)*i}}if(r!==i){let t="x"===g?"y":"x",r=d[g]===u[t],n=h[t]>f[t],i=h[t]<f[t];(1===d[g]&&(!r&&n||r&&i)||1!==d[g]&&(!r&&i||r&&n))&&(v="x"===g?a:o)}let p={x:h.x+b.x,y:h.y+b.y},m={x:f.x+x.x,y:f.y+x.y};Math.max(Math.abs(p.x-v[0].x),Math.abs(m.x-v[0].x))>=Math.max(Math.abs(p.y-v[0].y),Math.abs(m.y-v[0].y))?(l=(p.x+m.x)/2,c=v[0].y):(l=v[0].x,c=(p.y+m.y)/2)}let k={x:h.x+b.x,y:h.y+b.y},M={x:f.x+x.x,y:f.y+x.y},_=[];for(let r of[t,k,...v,M,n]){let[t,n]=_.slice(-2);n&&nE(t,n,r)&&_.pop(),_.push(r)}return[_,l,c,w,$]}({source:{x:t,y:r},sourcePosition:n,target:{x:i,y:a},targetPosition:s,center:{x:l,y:c},offset:d,stepPosition:u}),v=`M${h[0].x} ${h[0].y}`;for(let t=1;t<h.length-1;t++)v+=function(t,r,n,i){let a=Math.min(nA(t,r)/2,nA(r,n)/2,i),{x:s,y:o}=r;if(t.x===s&&s===n.x||t.y===o&&o===n.y)return`L${s} ${o}`;if(t.y===o){let r=t.x<n.x?-1:1,i=t.y<n.y?1:-1;return`L ${s+a*r},${o}Q ${s},${o} ${s},${o+a*i}`}let l=t.x<n.x?1:-1,c=t.y<n.y?-1:1;return`L ${s},${o+a*c}Q ${s},${o} ${s+a*l},${o}`}(h[t-1],h[t],h[t+1],o);return[v+=`L${h[h.length-1].x} ${h[h.length-1].y}`,f,p,g,y]}function nC(t){return t&&!!(t.internals.handleBounds||t.handles?.length)&&!!(t.measured.width||t.width||t.initialWidth)}function nT(t){let{sourceNode:r,targetNode:n}=t;if(!nC(r)||!nC(n))return null;let i=r.internals.handleBounds||nI(r.handles),a=n.internals.handleBounds||nI(n.handles),s=nO(i?.source??[],t.sourceHandle),o=nO(t.connectionMode===u.Strict?a?.target??[]:(a?.target??[]).concat(a?.source??[]),t.targetHandle);if(!s||!o)return t.onError?.("008",rk.error008(!s?"source":"target",{id:t.id,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle})),null;let l=s?.position||m.Bottom,c=o?.position||m.Top,d=nN(r,s,l),h=nN(n,o,c);return{sourceX:d.x,sourceY:d.y,targetX:h.x,targetY:h.y,sourcePosition:l,targetPosition:c}}function nI(t){if(!t)return null;let r=[],n=[];for(let i of t)i.width=i.width??1,i.height=i.height??1,"source"===i.type?r.push(i):"target"===i.type&&n.push(i);return{source:r,target:n}}function nN(t,r,n=m.Left,i=!1){let a=(r?.x??0)+t.internals.positionAbsolute.x,s=(r?.y??0)+t.internals.positionAbsolute.y,{width:o,height:l}=r??r9(t);if(i)return{x:a+o/2,y:s+l/2};switch(r?.position??n){case m.Top:return{x:a+o/2,y:s};case m.Right:return{x:a+o,y:s+l/2};case m.Bottom:return{x:a+o/2,y:s+l};case m.Left:return{x:a,y:s+l/2}}}function nO(t,r){return t&&(r?t.find(t=>t.id===r):t[0])||null}function nD(t,r){if(!t)return"";if("string"==typeof t)return t;let n=r?`${r}__`:"";return`${n}${Object.keys(t).sort().map(r=>`${r}=${t[r]}`).join("&")}`}function nR(t,{id:r,defaultColor:n,defaultMarkerStart:i,defaultMarkerEnd:a}){let s=new Set;return t.reduce((t,o)=>([o.markerStart||i,o.markerEnd||a].forEach(i=>{if(i&&"object"==typeof i){let a=nD(i,r);s.has(a)||(t.push({id:a,color:i.color||n,...i}),s.add(a))}}),t),[]).sort((t,r)=>t.id.localeCompare(r.id))}let nL={nodeOrigin:[0,0],nodeExtent:rM,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},nz={...nL,checkEquality:!0};function nP(t,r){let n={...t};for(let t in r)void 0!==r[t]&&(n[t]=r[t]);return n}function nj(t,r,n){let i=nP(nL,n);for(let n of t.values())if(n.parentId)nW(n,t,r,i);else{let t=rF(rN(n,i.nodeOrigin),r8(n.extent)?n.extent:i.nodeExtent,r9(n));n.internals.positionAbsolute=t}}function nF(t){return"manual"===t}function nB(t,r,n,i={}){let a=nP(nz,i),s={i:0},o=new Map(r),l=a?.elevateNodesOnSelect&&!nF(a.zIndexMode)?1e3:0,c=t.length>0,d=!1;for(let u of(r.clear(),n.clear(),t)){let t=o.get(u.id);if(a.checkEquality&&u===t?.internals.userNode)r.set(u.id,t);else{let n=rF(rN(u,a.nodeOrigin),r8(u.extent)?u.extent:a.nodeExtent,r9(u));t={...a.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:function(t,r){if(!t.handles)return t.measured?r?.internals.handleBounds:void 0;let n=[],i=[];for(let r of t.handles){let a={id:r.id,width:r.width??1,height:r.height??1,nodeId:t.id,x:r.x,y:r.y,position:r.position,type:r.type};"source"===r.type?n.push(a):"target"===r.type&&i.push(a)}return{source:n,target:i}}(u,t),z:nH(u,l,a.zIndexMode),userNode:u}},r.set(u.id,t)}void 0!==t.measured&&void 0!==t.measured.width&&void 0!==t.measured.height||t.hidden||(c=!1),u.parentId&&nW(t,r,n,i,s),d||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:d}}function nW(t,r,n,i,a){let{elevateNodesOnSelect:s,nodeOrigin:o,nodeExtent:l,zIndexMode:c}=nP(nL,i),d=t.parentId,u=r.get(d);if(!u)return void console.warn(`Parent node ${d} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);!function(t,r){if(!t.parentId)return;let n=r.get(t.parentId);n?n.set(t.id,t):r.set(t.parentId,new Map([[t.id,t]]))}(t,n),a&&!u.parentId&&void 0===u.internals.rootParentIndex&&"auto"===c&&(u.internals.rootParentIndex=++a.i,u.internals.z=u.internals.z+10*a.i),a&&void 0!==u.internals.rootParentIndex&&(a.i=u.internals.rootParentIndex);let{x:h,y:f,z:p}=function(t,r,n,i,a,s){let{x:o,y:l}=r.internals.positionAbsolute,c=r9(t),d=rN(t,n),u=r8(t.extent)?rF(d,t.extent,c):d,h=rF({x:o+u.x,y:l+u.y},i,c);"parent"===t.extent&&(h=rB(h,c,r));let f=nH(t,a,s),p=r.internals.z??0;return{x:h.x,y:h.y,z:p>=f?p+1:f}}(t,u,o,l,s&&!nF(c)?1e3:0,c),{positionAbsolute:g}=t.internals,m=h!==g.x||f!==g.y;(m||p!==t.internals.z)&&r.set(t.id,{...t,internals:{...t.internals,positionAbsolute:m?{x:h,y:f}:g,z:p}})}function nH(t,r,n){let i=rQ(t.zIndex)?t.zIndex:0;return nF(n)?i:i+(t.selected?r:0)}function nU(t,r,n,i=[0,0]){let a=[],s=new Map;for(let n of t){let t=r.get(n.parentId);if(!t)continue;let i=rZ(s.get(n.parentId)?.expandedRect??rY(t),n.rect);s.set(n.parentId,{expandedRect:i,parent:t})}return s.size>0&&s.forEach(({expandedRect:r,parent:s},o)=>{let l=s.internals.positionAbsolute,c=r9(s),d=s.origin??i,u=r.x<l.x?Math.round(Math.abs(l.x-r.x)):0,h=r.y<l.y?Math.round(Math.abs(l.y-r.y)):0,f=Math.max(c.width,Math.round(r.width)),p=Math.max(c.height,Math.round(r.height)),g=(f-c.width)*d[0],m=(p-c.height)*d[1];(u>0||h>0||g||m)&&(a.push({id:o,type:"position",position:{x:s.position.x-u+g,y:s.position.y-h+m}}),n.get(o)?.forEach(r=>{t.some(t=>t.id===r.id)||a.push({id:r.id,type:"position",position:{x:r.position.x+u,y:r.position.y+h}})})),(c.width<r.width||c.height<r.height||u||h)&&a.push({id:o,type:"dimensions",setAttributes:!0,dimensions:{width:f+(u?d[0]*u-g:0),height:p+(h?d[1]*h-m:0)}})}),a}function nq(t,r,n,i,a,s,o){let l=i?.querySelector(".xyflow__viewport"),c=!1;if(!l)return{changes:[],updatedInternals:c};let d=[],u=window.getComputedStyle(l),{m22:h}=new window.DOMMatrixReadOnly(u.transform),f=[];for(let i of t.values()){let t=r.get(i.id);if(!t)continue;if(t.hidden){r.set(t.id,{...t,internals:{...t.internals,handleBounds:void 0}}),c=!0;continue}let l=no(i.nodeElement),u=t.measured.width!==l.width||t.measured.height!==l.height;if(l.width&&l.height&&(u||!t.internals.handleBounds||i.force)){let p=i.nodeElement.getBoundingClientRect(),g=r8(t.extent)?t.extent:s,{positionAbsolute:m}=t.internals;if(t.parentId&&"parent"===t.extent){let n=r.get(t.parentId);n&&(m=rB(m,l,n))}else g&&(m=rF(m,g,l));let y={...t,measured:l,internals:{...t.internals,positionAbsolute:m,handleBounds:{source:nf("source",i.nodeElement,p,h,t.id),target:nf("target",i.nodeElement,p,h,t.id)}}};r.set(t.id,y),t.parentId&&nW(y,r,n,{nodeOrigin:a,zIndexMode:o}),c=!0,u&&(d.push({id:t.id,type:"dimensions",dimensions:l}),t.expandParent&&t.parentId&&f.push({id:t.id,parentId:t.parentId,rect:rY(y,a)}))}}if(f.length>0){let t=nU(f,r,n,a);d.push(...t)}return{changes:d,updatedInternals:c}}async function nV({delta:t,panZoom:r,transform:n,translateExtent:i,width:a,height:s}){if(!r||!t.x&&!t.y)return!1;let o=await r.setViewportConstrained({x:n[0]+t.x,y:n[1]+t.y,zoom:n[2]},[[0,0],[a,s]],i);return!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2])}function nY(t,r,n,i,a,s){let o=a,l=i.get(o)||new Map;i.set(o,l.set(n,r)),o=`${a}-${t}`;let c=i.get(o)||new Map;if(i.set(o,c.set(n,r)),s){o=`${a}-${t}-${s}`;let l=i.get(o)||new Map;i.set(o,l.set(n,r))}}function nG(t,r,n){for(let i of(t.clear(),r.clear(),n)){let{source:n,target:a,sourceHandle:s=null,targetHandle:o=null}=i,l={edgeId:i.id,source:n,target:a,sourceHandle:s,targetHandle:o},c=`${n}-${s}--${a}-${o}`;nY("source",l,`${a}-${o}--${n}-${s}`,t,n,s),nY("target",l,c,t,a,o),r.set(i.id,i)}}function nZ(t,r,n){let i=t;do{if(i?.matches?.(r))return!0;if(i===n)break;i=i?.parentElement}while(i);return!1}function nX({nodeId:t,dragItems:r,nodeLookup:n,dragging:i=!0}){let a=[];for(let[t,s]of r){let r=n.get(t)?.internals.userNode;r&&a.push({...r,position:s.position,dragging:i})}if(!t)return[a[0],a];let s=n.get(t)?.internals.userNode;return[s?{...s,position:r.get(t)?.position||s.position,dragging:i}:a[0],a]}function nK({onNodeMouseDown:t,getStoreItems:r,onDragStart:n,onDrag:i,onDragStop:a}){let s={x:null,y:null},o=0,l=new Map,c=!1,d={x:0,y:0},u=null,h=!1,f=null,p=!1,g=!1,m=null;return{update:function({noDragClassName:y,handleSelector:v,domNode:b,isSelectable:x,nodeId:w,nodeClickDistance:$=0}){function k({x:t,y:n}){let{nodeLookup:a,nodeExtent:o,snapGrid:c,snapToGrid:d,nodeOrigin:u,onNodeDrag:h,onSelectionDrag:f,onError:p,updateNodePositions:y}=r();s={x:t,y:n};let v=!1,b=l.size>1,x=b&&o?rq(rD(l)):null,$=b&&d?function({dragItems:t,snapGrid:r,x:n,y:i}){let a=t.values().next().value;if(!a)return null;let s={x:n-a.distance.x,y:i-a.distance.y},o=r1(s,r);return{x:o.x-s.x,y:o.y-s.y}}({dragItems:l,snapGrid:c,x:t,y:n}):null;for(let[r,i]of l){if(!a.has(r))continue;let s={x:t-i.distance.x,y:n-i.distance.y};d&&(s=$?{x:Math.round(s.x+$.x),y:Math.round(s.y+$.y)}:r1(s,c));let l=null;if(b&&o&&!i.extent&&x){let{positionAbsolute:t}=i.internals,r=t.x-x.x+o[0][0],n=t.x+i.measured.width-x.x2+o[1][0];l=[[r,t.y-x.y+o[0][1]],[n,t.y+i.measured.height-x.y2+o[1][1]]]}let{position:h,positionAbsolute:f}=rz({nodeId:r,nextPosition:s,nodeLookup:a,nodeExtent:l||o,nodeOrigin:u,onError:p});v=v||i.position.x!==h.x||i.position.y!==h.y,i.position=h,i.internals.positionAbsolute=f}if(g=g||v,v&&(y(l,!0),m&&(i||h||!w&&f))){let[t,r]=nX({nodeId:w,dragItems:l,nodeLookup:a});i?.(m,l,t,r),h?.(m,t,r),w||f?.(m,r)}}async function M(){if(!u)return;let{transform:t,panBy:n,autoPanSpeed:i,autoPanOnNodeDrag:a}=r();if(!a){c=!1,cancelAnimationFrame(o);return}let[l,h]=rH(d,u,i);(0!==l||0!==h)&&(s.x=(s.x??0)-l/t[2],s.y=(s.y??0)-h/t[2],await n({x:l,y:h})&&k(s)),o=requestAnimationFrame(M)}function _(i){let{nodeLookup:a,multiSelectionActive:o,nodesDraggable:c,transform:d,snapGrid:f,snapToGrid:p,selectNodesOnDrag:g,onNodeDragStart:m,onSelectionDragStart:y,unselectNodesAndEdges:v}=r();h=!0;let b=!!w&&!o&&!a.get(w)?.selected;g&&x||o||!w||a.get(w)?.selected||v(),x&&g&&w&&t?.(w);let $=ns(i.sourceEvent,{transform:d,snapGrid:f,snapToGrid:p,containerBounds:u});if(s=$,(l=function(t,r,n,i,a){let s=new Map;for(let[o,l]of t)if((a?l.id===i:l.selected||l.id===i)&&(a||!l.parentId||!function t(r,n){if(!r.parentId)return!1;let i=n.get(r.parentId);return!!i&&(!!i.selected||t(i,n))}(l,t))&&(l.draggable||r&&void 0===l.draggable)){let r=t.get(o);r&&s.set(o,{id:o,position:r.position||{x:0,y:0},distance:{x:n.x-r.internals.positionAbsolute.x,y:n.y-r.internals.positionAbsolute.y},extent:r.extent,parentId:r.parentId,origin:r.origin,expandParent:r.expandParent,internals:{positionAbsolute:r.internals.positionAbsolute||{x:0,y:0}},measured:{width:r.measured.width??0,height:r.measured.height??0}})}return s}(a,c,$,w,b)).size>0&&(n||m||!w&&y)){let[t,r]=nX({nodeId:w,dragItems:l,nodeLookup:a});n?.(i.sourceEvent,l,t,r),m?.(i.sourceEvent,t,r),w||y?.(i.sourceEvent,r)}}f=ec(b);let A=e_().clickDistance($).on("start",t=>{let{domNode:n,nodeDragThreshold:i,transform:a,snapGrid:o,snapToGrid:l}=r();u=n?.getBoundingClientRect()||null,p=!1,g=!1,m=t.sourceEvent,0===i&&_(t),s=ns(t.sourceEvent,{transform:a,snapGrid:o,snapToGrid:l,containerBounds:u}),d=nh(t.sourceEvent,u)}).on("drag",t=>{let{autoPanOnNodeDrag:n,transform:i,snapGrid:a,snapToGrid:o,nodeDragThreshold:f,nodeLookup:g}=r(),y=ns(t.sourceEvent,{transform:i,snapGrid:a,snapToGrid:o,containerBounds:u});if(m=t.sourceEvent,("touchmove"===t.sourceEvent.type&&t.sourceEvent.touches.length>1||w&&!g.has(w))&&(p=!0),!p){if(!c&&n&&h&&(c=!0,M()),!h){let r=nh(t.sourceEvent,u),n=r.x-d.x,i=r.y-d.y;Math.sqrt(n*n+i*i)>f&&_(t)}(s.x!==y.xSnapped||s.y!==y.ySnapped)&&l&&h&&(d=nh(t.sourceEvent,u),k(y))}}).on("end",t=>{if(!h||p){p&&l.size>0&&r().updateNodePositions(l,!1);return}if(c=!1,h=!1,cancelAnimationFrame(o),l.size>0){let{nodeLookup:n,updateNodePositions:i,onNodeDragStop:s,onSelectionDragStop:o}=r();if(g&&(i(l,!1),g=!1),a||s||!w&&o){let[r,i]=nX({nodeId:w,dragItems:l,nodeLookup:n,dragging:!1});a?.(t.sourceEvent,l,r,i),s?.(t.sourceEvent,r,i),w||o?.(t.sourceEvent,i)}}}).filter(t=>{let r=t.target;return!t.button&&(!y||!nZ(r,`.${y}`,b))&&(!v||nZ(r,v,b))});f.call(A)},destroy:function(){f?.on(".drag",null)}}}function nJ(t,r,n,i,a,s=!1){let o=i.get(t);if(!o)return null;let l="strict"===a?o.internals.handleBounds?.[r]:[...o.internals.handleBounds?.source??[],...o.internals.handleBounds?.target??[]],c=(n?l?.find(t=>t.id===n):l?.[0])??null;return c&&s?{...c,...nN(o,c,c.position,!0)}:c}function nQ(t,r){return t?t:r?.classList.contains("target")?"target":r?.classList.contains("source")?"source":null}let n0=()=>!0;function n1(t,{handle:r,connectionMode:n,fromNodeId:i,fromHandleId:a,fromType:s,doc:o,lib:l,flowId:c,isValidConnection:d=n0,nodeLookup:h}){let f="target"===s,p=r?o.querySelector(`.${l}-flow__handle[data-id="${c}-${r?.nodeId}-${r?.id}-${r?.type}"]`):null,{x:g,y:m}=nh(t),y=o.elementFromPoint(g,m),v=y?.classList.contains(`${l}-flow__handle`)?y:p,b={handleDomNode:v,isValid:!1,connection:null,toHandle:null};if(v){let t=nQ(void 0,v),r=v.getAttribute("data-nodeid"),s=v.getAttribute("data-handleid"),o=v.classList.contains("connectable"),l=v.classList.contains("connectableend");if(!r||!t)return b;let c={source:f?r:i,sourceHandle:f?s:a,target:f?i:r,targetHandle:f?a:s};b.connection=c,b.isValid=o&&l&&(n===u.Strict?f&&"source"===t||!f&&"target"===t:r!==i||s!==a)&&d(c),b.toHandle=nJ(r,t,s,h,n,!0)}return b}let n2={onPointerDown:function(t,{connectionMode:r,connectionRadius:n,handleId:i,nodeId:a,edgeUpdaterType:s,isTarget:o,domNode:l,nodeLookup:c,lib:d,autoPanOnConnect:u,flowId:h,panBy:f,cancelConnection:p,onConnectStart:g,onConnect:y,onConnectEnd:v,isValidConnection:b=n0,onReconnectEnd:x,updateConnection:w,getTransform:$,getFromHandle:k,autoPanSpeed:M,dragThreshold:_=1,handleDomNode:A}){let E,S=nl(t.target),C=0,{x:T,y:I}=nh(t),N=nQ(s,A),O=l?.getBoundingClientRect(),D=!1;if(!O||!N)return;let R=nJ(a,N,i,c,r);if(!R)return;let L=nh(t,O),z=!1,P=null,j=!1,F=null,B={...R,nodeId:a,type:N,position:R.position},W=c.get(a),H={inProgress:!0,isValid:null,from:nN(W,B,m.Left,!0),fromHandle:B,fromPosition:B.position,fromNode:W,to:L,toHandle:null,toPosition:rS[B.position],toNode:null,pointer:L};function U(){D=!0,w(H),g?.(t,{nodeId:a,handleId:i,handleType:N})}function q(t){var s,l;let p;if(!D){let{x:r,y:n}=nh(t),i=r-T,a=n-I;if(!(i*i+a*a>_*_))return;U()}if(!k()||!B)return void V(t);let g=$();E=function(t,r,n,i){let a=[],s=1/0;for(let o of function(t,r,n){let i=[],a={x:t.x-n,y:t.y-n,width:2*n,height:2*n};for(let t of r.values())rK(a,rY(t))>0&&i.push(t);return i}(t,n,r+250))for(let n of[...o.internals.handleBounds?.source??[],...o.internals.handleBounds?.target??[]]){if(i.nodeId===n.nodeId&&i.type===n.type&&i.id===n.id)continue;let{x:l,y:c}=nN(o,n,n.position,!0),d=Math.sqrt(Math.pow(l-t.x,2)+Math.pow(c-t.y,2));d>r||(d<s?(a=[{...n,x:l,y:c}],s=d):d===s&&a.push({...n,x:l,y:c}))}if(!a.length)return null;if(a.length>1){let t="source"===i.type?"target":"source";return a.find(r=>r.type===t)??a[0]}return a[0]}(r2(L=nh(t,O),g,!1,[1,1]),n,c,B),z||(!function t(){if(!u||!O)return;let[r,n]=rH(L,O,M);f({x:r,y:n}),C=requestAnimationFrame(t)}(),z=!0);let y=n1(t,{handle:E,connectionMode:r,fromNodeId:a,fromHandleId:i,fromType:o?"target":"source",isValidConnection:b,doc:S,lib:d,flowId:h,nodeLookup:c});F=y.handleDomNode,P=y.connection,s=!!E,l=y.isValid,p=null,l?p=!0:s&&!l&&(p=!1),j=p;let v=c.get(a),x=v?nN(v,B,m.Left,!0):H.from,A={...H,from:x,isValid:j,to:y.toHandle&&j?r4({x:y.toHandle.x,y:y.toHandle.y},g):L,toHandle:y.toHandle,toPosition:j&&y.toHandle?y.toHandle.position:rS[B.position],toNode:y.toHandle?c.get(y.toHandle.nodeId):null,pointer:L};w(A),H=A}function V(t){if(!("touches"in t)||!(t.touches.length>0)){if(D){(E||F)&&P&&j&&y?.(P);let{inProgress:r,...n}=H,i={...n,toPosition:H.toHandle?H.toPosition:null};v?.(t,i),s&&x?.(t,i)}p(),cancelAnimationFrame(C),z=!1,j=!1,P=null,F=null,S.removeEventListener("mousemove",q),S.removeEventListener("mouseup",V),S.removeEventListener("touchmove",q),S.removeEventListener("touchend",V)}}0===_&&U(),S.addEventListener("mousemove",q),S.addEventListener("mouseup",V),S.addEventListener("touchmove",q),S.addEventListener("touchend",V)},isValid:n1};function n4({domNode:t,panZoom:r,getTransform:n,getViewScale:i}){let a=ec(t);return{update:function({translateExtent:t,width:s,height:o,zoomStep:l=1,pannable:c=!0,zoomable:d=!0,inversePan:u=!1}){let h=[0,0],f=r$().on("start",t=>{("mousedown"===t.sourceEvent.type||"touchstart"===t.sourceEvent.type)&&(h=[t.sourceEvent.clientX??t.sourceEvent.touches[0].clientX,t.sourceEvent.clientY??t.sourceEvent.touches[0].clientY])}).on("zoom",c?a=>{let l=n();if("mousemove"!==a.sourceEvent.type&&"touchmove"!==a.sourceEvent.type||!r)return;let c=[a.sourceEvent.clientX??a.sourceEvent.touches[0].clientX,a.sourceEvent.clientY??a.sourceEvent.touches[0].clientY],d=[c[0]-h[0],c[1]-h[1]];h=c;let f=i()*Math.max(l[2],Math.log(l[2]))*(u?-1:1),p={x:l[0]-d[0]*f,y:l[1]-d[1]*f};r.setViewportConstrained({x:p.x,y:p.y,zoom:l[2]},[[0,0],[s,o]],t)}:null).on("zoom.wheel",d?t=>{if("wheel"!==t.sourceEvent.type||!r)return;let i=n(),a=t.sourceEvent.ctrlKey&&r6()?10:1,s=-t.sourceEvent.deltaY*(1===t.sourceEvent.deltaMode?.05:t.sourceEvent.deltaMode?1:.002)*l,o=i[2]*Math.pow(2,s*a);r.scaleTo(o)}:null);a.call(f,{})},destroy:function(){a.on("zoom",null)},pointer:eh}}let n3=t=>({x:t.x,y:t.y,zoom:t.k}),n5=({x:t,y:r,zoom:n})=>rh.translate(t,r).scale(n),n6=(t,r)=>t.target.closest(`.${r}`),n8=(t,r)=>2===r&&Array.isArray(t)&&t.includes(2),n9=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,n7=(t,r=0,n=n9,i=()=>{})=>{let a="number"==typeof r&&r>0;return a||i(),a?t.transition().duration(r).ease(n).on("end",i):t},ie=t=>{let r=t.ctrlKey&&r6()?10:1;return-t.deltaY*(1===t.deltaMode?.05:t.deltaMode?1:.002)*r};function it({domNode:t,minZoom:r,maxZoom:n,translateExtent:i,viewport:a,onPanZoom:s,onPanZoomStart:o,onPanZoomEnd:l,onDraggingChange:c}){let d={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=t.getBoundingClientRect(),f=[[0,0],[u.width,u.height]],p="u">typeof ResizeObserver?new ResizeObserver(t=>{let r=t[0];r?.contentRect&&(f=[[0,0],[r.contentRect.width,r.contentRect.height]])}):null;p?.observe(t);let g=r$().extent(()=>f).scaleExtent([r,n]).translateExtent(i),m=ec(t).call(g);x({x:a.x,y:a.y,zoom:rj(a.zoom,r,n)},[[0,0],[u.width,u.height]],i);let y=m.on("wheel.zoom"),v=m.on("dblclick.zoom");async function b(t,r){return!!m&&new Promise(n=>{g?.interpolate(r?.interpolate==="linear"?t_:tO).transform(n7(m,r?.duration,r?.ease,()=>n(!0)),t)})}async function x(t,r,n){let i=n5(t),a=g?.constrain()(i,r,n);return a&&await b(a),a}return g.wheelDelta(ie),{update:function({noWheelClassName:t,noPanClassName:r,onPaneContextMenu:n,userSelectionActive:i,panOnScroll:a,panOnDrag:u,panOnScrollMode:f,panOnScrollSpeed:p,preventScrolling:b,zoomOnPinch:x,zoomOnScroll:w,zoomOnDoubleClick:$,panActivationKeyPressed:k=!1,zoomActivationKeyPressed:M,lib:_,onTransformChange:A,connectionInProgress:E,paneClickDistance:S,selectionOnDrag:C}){i&&!d.isZoomingOrPanning&&g.on("zoom",null);let T=a&&!M&&!i;g.clickDistance(C?1/0:!rQ(S)||S<0?0:S);let I=T?function({zoomPanValues:t,noWheelClassName:r,d3Selection:n,d3Zoom:i,panOnScrollMode:a,panOnScrollSpeed:s,zoomOnPinch:o,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:d}){return u=>{if(n6(u,r))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();let f=n.property("__zoom").k||1;if(u.ctrlKey&&o){let t=eh(u),r=f*Math.pow(2,ie(u));i.scaleTo(n,r,t,u);return}let p=1===u.deltaMode?20:1,g=a===h.Vertical?0:u.deltaX*p,m=a===h.Horizontal?0:u.deltaY*p;!r6()&&u.shiftKey&&a!==h.Vertical&&(g=u.deltaY*p,m=0),i.translateBy(n,-(g/f)*s,-(m/f)*s,{internal:!0});let y=n3(n.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?c?.(u,y):(t.isPanScrolling=!0,l?.(u,y)),t.panScrollTimeout=setTimeout(()=>{d?.(u,y),t.isPanScrolling=!1},150)}}({zoomPanValues:d,noWheelClassName:t,d3Selection:m,d3Zoom:g,panOnScrollMode:f,panOnScrollSpeed:p,zoomOnPinch:x,onPanZoomStart:o,onPanZoom:s,onPanZoomEnd:l}):function({noWheelClassName:t,preventScrolling:r,d3ZoomHandler:n}){return function(i,a){let s="wheel"===i.type,o=!r&&s&&!i.ctrlKey,l=n6(i,t);if(i.ctrlKey&&s&&l&&i.preventDefault(),o||l)return null;i.preventDefault(),n.call(this,i,a)}}({noWheelClassName:t,preventScrolling:b,d3ZoomHandler:y});m.on("wheel.zoom",I,{passive:!1});let N=function({zoomPanValues:t,onDraggingChange:r,onPanZoomStart:n}){return i=>{if(i.sourceEvent?.internal)return;let a=n3(i.transform);t.mouseButton=i.sourceEvent?.button||0,t.isZoomingOrPanning=!0,t.prevViewport=a,i.sourceEvent?.type==="mousedown"&&r(!0),n&&n?.(i.sourceEvent,a)}}({zoomPanValues:d,onDraggingChange:c,onPanZoomStart:o});g.on("start",N);let O=function({zoomPanValues:t,panOnDrag:r,onPaneContextMenu:n,onTransformChange:i,onPanZoom:a}){return s=>{t.usedRightMouseButton=!!(n&&n8(r,t.mouseButton??0)),s.sourceEvent?.sync||i([s.transform.x,s.transform.y,s.transform.k]),a&&!s.sourceEvent?.internal&&a?.(s.sourceEvent,n3(s.transform))}}({zoomPanValues:d,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:s,onTransformChange:A});g.on("zoom",O);let D=function({zoomPanValues:t,panOnDrag:r,panOnScroll:n,onDraggingChange:i,onPanZoomEnd:a,onPaneContextMenu:s}){return o=>{if(!o.sourceEvent?.internal&&(t.isZoomingOrPanning=!1,s&&n8(r,t.mouseButton??0)&&!t.usedRightMouseButton&&o.sourceEvent&&s(o.sourceEvent),t.usedRightMouseButton=!1,i(!1),a)){let r=n3(o.transform);t.prevViewport=r,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{a?.(o.sourceEvent,r)},150*!!n)}}}({zoomPanValues:d,panOnDrag:u,panOnScroll:a,onPaneContextMenu:n,onPanZoomEnd:l,onDraggingChange:c});g.on("end",D);let R=function({panActivationKeyPressed:t,zoomActivationKeyPressed:r,zoomOnScroll:n,zoomOnPinch:i,panOnDrag:a,panOnScroll:s,zoomOnDoubleClick:o,userSelectionActive:l,noWheelClassName:c,noPanClassName:d,lib:u,connectionInProgress:h}){return f=>{let p=r||n,g=i&&f.ctrlKey,m="wheel"===f.type;if(1===f.button&&"mousedown"===f.type&&(n6(f,`${u}-flow__node`)||n6(f,`${u}-flow__edge`)||n6(f,`${u}-flow__selection`)||n6(f,`${u}-flow__nodesselection`)))return!0;if(!a&&!p&&!s&&!o&&!i||l||h&&!m||n6(f,c)&&m||n6(f,d)&&(!m||s&&m&&!r)||!i&&f.ctrlKey&&m)return!1;if(!i&&"touchstart"===f.type&&f.touches?.length>1)return f.preventDefault(),!1;if(!p&&!s&&!g&&m||!a&&("mousedown"===f.type||"touchstart"===f.type)||Array.isArray(a)&&!a.includes(f.button)&&"mousedown"===f.type)return!1;let y=Array.isArray(a)&&a.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||m||t)&&y}}({panActivationKeyPressed:k,zoomActivationKeyPressed:M,panOnDrag:u,zoomOnScroll:w,panOnScroll:a,zoomOnDoubleClick:$,zoomOnPinch:x,userSelectionActive:i,noPanClassName:r,noWheelClassName:t,lib:_,connectionInProgress:E});g.filter(R),$?m.on("dblclick.zoom",v):m.on("dblclick.zoom",null)},destroy:function(){g.on("zoom",null),p?.disconnect()},setViewport:async function t(t,r){let n=n5(t);return await b(n,r),n},setViewportConstrained:x,getViewport:function(){let t=m?rf(m.node()):{x:0,y:0,k:1};return{x:t.x,y:t.y,zoom:t.k}},scaleTo:async function t(t,r){return!!m&&new Promise(n=>{g?.interpolate(r?.interpolate==="linear"?t_:tO).scaleTo(n7(m,r?.duration,r?.ease,()=>n(!0)),t)})},scaleBy:async function t(t,r){return!!m&&new Promise(n=>{g?.interpolate(r?.interpolate==="linear"?t_:tO).scaleBy(n7(m,r?.duration,r?.ease,()=>n(!0)),t)})},setScaleExtent:function(t){g?.scaleExtent(t)},setTranslateExtent:function(t){g?.translateExtent(t)},syncViewport:function(t){if(m){let r=n5(t),n=m.property("__zoom");(n.k!==t.zoom||n.x!==t.x||n.y!==t.y)&&g?.transform(m,r,null,{sync:!0})}},setClickDistance:function(t){let r=!rQ(t)||t<0?0:t;g?.clickDistance(r)}}}function ir(t){let r=t.includes("right")||t.includes("left"),n=t.includes("bottom")||t.includes("top");return{isHorizontal:r,isVertical:n,affectsX:t.includes("left"),affectsY:t.includes("top")}}function ii(t,r){return Math.max(0,r-t)}function ia(t,r){return Math.max(0,t-r)}function is(t,r,n){return Math.max(0,r-t,t-n)}(d=y||(y={})).Line="line",d.Handle="handle";let io={width:0,height:0,x:0,y:0},il={...io,pointerX:0,pointerY:0,aspectRatio:1};function ic({domNode:t,nodeId:r,getStoreItems:n,onChange:i,onEnd:a}){let s=ec(t),o={controlDirection:ir("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};return{update:function({controlPosition:t,boundaries:l,keepAspectRatio:c,resizeDirection:d,onResizeStart:u,onResize:h,onResizeEnd:f,shouldResize:p}){let g,m,y,v,b={...io},x={...il};o={boundaries:l,resizeDirection:d,keepAspectRatio:c,controlDirection:ir(t)};let w=null,$=[],k=e_().on("start",t=>{let{nodeLookup:i,transform:a,snapGrid:s,snapToGrid:o,nodeOrigin:l,paneDomNode:c}=n();if(!(g=i.get(r)))return;w=c?.getBoundingClientRect()??null;let{xSnapped:d,ySnapped:h}=ns(t.sourceEvent,{transform:a,snapGrid:s,snapToGrid:o,containerBounds:w});for(let[t,n]of(x={...b={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},pointerX:d,pointerY:h,aspectRatio:b.width/b.height},m=void 0,y=r8(g.extent)?g.extent:void 0,g.parentId&&("parent"===g.extent||g.expandParent)&&(m=i.get(g.parentId)),m&&"parent"===g.extent&&(y=[[0,0],[m.measured.width,m.measured.height]]),$=[],v=void 0,i))if(n.parentId===r&&($.push({id:t,position:{...n.position},extent:n.extent}),"parent"===n.extent||n.expandParent)){let t=function(t,r,n){let i=r.position.x+t.position.x,a=r.position.y+t.position.y,s=t.measured.width??0,o=t.measured.height??0,l=n[0]*s,c=n[1]*o;return[[i-l,a-c],[i+s-l,a+o-c]]}(n,g,n.origin??l);v=v?[[Math.min(t[0][0],v[0][0]),Math.min(t[0][1],v[0][1])],[Math.max(t[1][0],v[1][0]),Math.max(t[1][1],v[1][1])]]:t}u?.(t,{...b})}).on("drag",t=>{let{transform:r,snapGrid:a,snapToGrid:s,nodeOrigin:l}=n(),c=ns(t.sourceEvent,{transform:r,snapGrid:a,snapToGrid:s,containerBounds:w}),d=[];if(!g)return;let{x:u,y:f,width:k,height:M}=b,_={},A=g.origin??l,{width:E,height:S,x:C,y:T}=function(t,r,n,i,a,s,o,l){var c,d,u,h;let{affectsX:f,affectsY:p}=r,{isHorizontal:g,isVertical:m}=r,y=g&&m,{xSnapped:v,ySnapped:b}=n,{minWidth:x,maxWidth:w,minHeight:$,maxHeight:k}=i,{x:M,y:_,width:A,height:E,aspectRatio:S}=t,C=Math.floor(g?v-t.pointerX:0),T=Math.floor(m?b-t.pointerY:0),I=A+(f?-C:C),N=E+(p?-T:T),O=-s[0]*A,D=-s[1]*E,R=is(I,x,w),L=is(N,$,k);if(o){let t=0,r=0;f&&C<0?t=ii(M+C+O,o[0][0]):!f&&C>0&&(t=ia(M+I+O,o[1][0])),p&&T<0?r=ii(_+T+D,o[0][1]):!p&&T>0&&(r=ia(_+N+D,o[1][1])),R=Math.max(R,t),L=Math.max(L,r)}if(l){let t=0,r=0;f&&C>0?t=ia(M+C,l[0][0]):!f&&C<0&&(t=ii(M+I,l[1][0])),p&&T>0?r=ia(_+T,l[0][1]):!p&&T<0&&(r=ii(_+N,l[1][1])),R=Math.max(R,t),L=Math.max(L,r)}if(a){if(g){(R=Math.max(R,is(I/S,$,k)*S),o)&&(R=Math.max(R,(f||p)&&(!f||p||!y)?ii(_+D+(f?C:-C)/S,o[0][1])*S:ia(_+D+I/S,o[1][1])*S));l&&(R=Math.max(R,(f||p)&&(!f||p||!y)?ia(_+(f?C:-C)/S,l[0][1])*S:ii(_+I/S,l[1][1])*S))}if(m){(L=Math.max(L,is(N*S,x,w)/S),o)&&(L=Math.max(L,(f||p)&&(!p||f||!y)?ii(M+(p?T:-T)*S+O,o[0][0])/S:ia(M+N*S+O,o[1][0])/S));l&&(L=Math.max(L,(f||p)&&(!p||f||!y)?ia(M+(p?T:-T)*S,l[0][0])/S:ii(M+N*S,l[1][0])/S))}}T+=T<0?L:-L,C+=C<0?R:-R,a&&(y?I>N*S?T=((c=f,d=p,c?!d:d)?-C:C)/S:C=((u=f,h=p,u?!h:h)?-T:T)*S:g?(T=C/S,p=f):(C=T*S,f=p));let z=f?M+C:M,P=p?_+T:_;return{width:A+(f?-C:C),height:E+(p?-T:T),x:s[0]*C*(f?-1:1)+z,y:s[1]*T*(p?-1:1)+P}}(x,o.controlDirection,c,o.boundaries,o.keepAspectRatio,A,y,v),I=E!==k,N=S!==M,O=C!==u&&I,D=T!==f&&N;if(!O&&!D&&!I&&!N)return;let R={prevValues:{...b},startX:x.x,startY:x.y,childNodes:$.map(t=>({...t,position:{...t.position}}))};if((O||D||1===A[0]||1===A[1])&&(_.x=O?C:b.x,_.y=D?T:b.y,b.x=_.x,b.y=_.y,$.length>0)){let t=C-u,r=T-f;for(let n of $)n.position={x:n.position.x-t+A[0]*(E-k),y:n.position.y-r+A[1]*(S-M)},d.push(n)}if((I||N)&&(_.width=I&&(!o.resizeDirection||"horizontal"===o.resizeDirection)?E:b.width,_.height=N&&(!o.resizeDirection||"vertical"===o.resizeDirection)?S:b.height,b.width=_.width,b.height=_.height),m&&g.expandParent){let t=A[0]*(_.width??0);_.x&&_.x<t&&(b.x=t,x.x=x.x-(_.x-t));let r=A[1]*(_.height??0);_.y&&_.y<r&&(b.y=r,x.y=x.y-(_.y-r))}let L=function({width:t,prevWidth:r,height:n,prevHeight:i,affectsX:a,affectsY:s}){let o=t-r,l=n-i,c=[o>0?1:o<0?-1:0,l>0?1:l<0?-1:0];return o&&a&&(c[0]=-1*c[0]),l&&s&&(c[1]=-1*c[1]),c}({width:b.width,prevWidth:k,height:b.height,prevHeight:M,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),z={...b,direction:L};if(!1===p?.(t,z)){b=R.prevValues,x.x=R.startX,x.y=R.startY,$.forEach((t,r)=>{t.position=R.childNodes[r].position});return}h?.(t,z),i(_,d)}).on("end",t=>{f?.(t,{...b}),a?.({...b})});s.call(k)},destroy:function(){s.on(".drag",null)}}}},7846(t,r,n){let i;n.d(r,{$E:()=>et,YI:()=>Q});let a=(i=0,()=>(i+=1,`u${`0000${(1679616*Math.random()|0).toString(36)}`.slice(-4)}${i}`));function s(t){let r=[];for(let n=0,i=t.length;n<i;n++)r.push(t[n]);return r}let o=null;function l(t={}){return o||(o=t.includeStyleProperties?t.includeStyleProperties:s(window.getComputedStyle(document.documentElement)))}function c(t,r){let n=(t.ownerDocument.defaultView||window).getComputedStyle(t).getPropertyValue(r);return n?parseFloat(n.replace("px","")):0}function d(t,r={}){let n,i,a,s;return{width:r.width||(n=c(t,"border-left-width"),i=c(t,"border-right-width"),t.clientWidth+n+i),height:r.height||(a=c(t,"border-top-width"),s=c(t,"border-bottom-width"),t.clientHeight+a+s)}}function u(t){return new Promise((r,n)=>{let i=new Image;i.onload=()=>{i.decode().then(()=>{requestAnimationFrame(()=>r(i))})},i.onerror=n,i.crossOrigin="anonymous",i.decoding="async",i.src=t})}async function h(t){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(t)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function f(t,r,n){let i="http://www.w3.org/2000/svg",a=document.createElementNS(i,"svg"),s=document.createElementNS(i,"foreignObject");return a.setAttribute("width",`${r}`),a.setAttribute("height",`${n}`),a.setAttribute("viewBox",`0 0 ${r} ${n}`),s.setAttribute("width","100%"),s.setAttribute("height","100%"),s.setAttribute("x","0"),s.setAttribute("y","0"),s.setAttribute("externalResourcesRequired","true"),a.appendChild(s),s.appendChild(t),h(a)}let p=(t,r)=>{if(t instanceof r)return!0;let n=Object.getPrototypeOf(t);return null!==n&&(n.constructor.name===r.name||p(n,r))};function g(t,r,n,i){let s,o,c,d=window.getComputedStyle(t,n),u=d.getPropertyValue("content");if(""===u||"none"===u)return;let h=a();try{r.className=`${r.className} ${h}`}catch(t){return}let f=document.createElement("style");f.appendChild((s=`.${h}:${n}`,c=d.cssText?(o=d.getPropertyValue("content"),`${d.cssText} content: '${o.replace(/'|"/g,"")}';`):l(i).map(t=>{let r=d.getPropertyValue(t),n=d.getPropertyPriority(t);return`${t}: ${r}${n?" !important":""};`}).join(" "),document.createTextNode(`${s}{${c}}`))),r.appendChild(f)}let m="application/font-woff",y="image/jpeg",v={woff:m,woff2:m,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:y,jpeg:y,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function b(t){let r;return v[((r=/\.([^./]*?)$/g.exec(t))?r[1]:"").toLowerCase()]||""}function x(t){return -1!==t.search(/^(data:)/)}function w(t,r){return`data:${r};base64,${t}`}async function $(t,r,n){let i=await fetch(t,r);if(404===i.status)throw Error(`Resource "${i.url}" not found`);let a=await i.blob();return new Promise((t,r)=>{let s=new FileReader;s.onerror=r,s.onloadend=()=>{try{t(n({res:i,result:s.result}))}catch(t){r(t)}},s.readAsDataURL(a)})}let k={};async function M(t,r,n){var i,a,s;let o,l,c=(i=t,a=r,s=n.includeQueryParams,l=i.replace(/\?.*/,""),s&&(l=i),/ttf|otf|eot|woff2?/i.test(l)&&(l=l.replace(/.*\//,"")),a?`[${a}]${l}`:l);if(null!=k[c])return k[c];n.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+new Date().getTime());try{let i=await $(t,n.fetchRequestInit,({res:t,result:n})=>(r||(r=t.headers.get("Content-Type")||""),n.split(/,/)[1]));o=w(i,r)}catch(i){o=n.imagePlaceholder||"";let r=`Failed to fetch resource: ${t}`;i&&(r="string"==typeof i?i:i.message),r&&console.warn(r)}return k[c]=o,o}async function _(t){let r=t.toDataURL();return"data:,"===r?t.cloneNode(!1):u(r)}async function A(t,r){if(t.currentSrc){let r=document.createElement("canvas"),n=r.getContext("2d");return r.width=t.clientWidth,r.height=t.clientHeight,null==n||n.drawImage(t,0,0,r.width,r.height),u(r.toDataURL())}let n=t.poster,i=b(n);return u(await M(n,i,r))}async function E(t,r){var n;try{if(null==(n=null==t?void 0:t.contentDocument)?void 0:n.body)return await N(t.contentDocument.body,r,!0)}catch(t){}return t.cloneNode(!1)}async function S(t,r){return p(t,HTMLCanvasElement)?_(t):p(t,HTMLVideoElement)?A(t,r):p(t,HTMLIFrameElement)?E(t,r):t.cloneNode(C(t))}let C=t=>null!=t.tagName&&"SVG"===t.tagName.toUpperCase();async function T(t,r,n){var i,a;if(C(r))return r;let o=[];return 0===(o=null!=t.tagName&&"SLOT"===t.tagName.toUpperCase()&&t.assignedNodes?s(t.assignedNodes()):p(t,HTMLIFrameElement)&&(null==(i=t.contentDocument)?void 0:i.body)?s(t.contentDocument.body.childNodes):s((null!=(a=t.shadowRoot)?a:t).childNodes)).length||p(t,HTMLVideoElement)||await o.reduce((t,i)=>t.then(()=>N(i,n)).then(t=>{t&&r.appendChild(t)}),Promise.resolve()),r}async function I(t,r){let n=t.querySelectorAll?t.querySelectorAll("use"):[];if(0===n.length)return t;let i={};for(let a=0;a<n.length;a++){let s=n[a].getAttribute("xlink:href");if(s){let n=t.querySelector(s),a=document.querySelector(s);n||!a||i[s]||(i[s]=await N(a,r,!0))}}let a=Object.values(i);if(a.length){let r="http://www.w3.org/1999/xhtml",n=document.createElementNS(r,"svg");n.setAttribute("xmlns",r),n.style.position="absolute",n.style.width="0",n.style.height="0",n.style.overflow="hidden",n.style.display="none";let i=document.createElementNS(r,"defs");n.appendChild(i);for(let t=0;t<a.length;t++)i.appendChild(a[t]);t.appendChild(n)}return t}async function N(t,r,n){return n||!r.filter||r.filter(t)?Promise.resolve(t).then(t=>S(t,r)).then(n=>T(t,n,r)).then(n=>(function(t,r,n){if(p(r,Element)&&(!function(t,r,n){let i=r.style;if(!i)return;let a=window.getComputedStyle(t);a.cssText?(i.cssText=a.cssText,i.transformOrigin=a.transformOrigin):l(n).forEach(n=>{let s=a.getPropertyValue(n);if("font-size"===n&&s.endsWith("px")){let t=Math.floor(parseFloat(s.substring(0,s.length-2)))-.1;s=`${t}px`}p(t,HTMLIFrameElement)&&"display"===n&&"inline"===s&&(s="block"),"d"===n&&r.getAttribute("d")&&(s=`path(${r.getAttribute("d")})`),i.setProperty(n,s,a.getPropertyPriority(n))})}(t,r,n),g(t,r,":before",n),g(t,r,":after",n),p(t,HTMLTextAreaElement)&&(r.innerHTML=t.value),p(t,HTMLInputElement)&&r.setAttribute("value",t.value),p(t,HTMLSelectElement))){let n=Array.from(r.children).find(r=>t.value===r.getAttribute("value"));n&&n.setAttribute("selected","")}return r})(t,n,r)).then(t=>I(t,r)):null}let O=/url\((['"]?)([^'"]+?)\1\)/g,D=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,R=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;async function L(t,r,n,i,a){try{let s,o,l=n?function(t,r){if(t.match(/^[a-z]+:\/\//i))return t;if(t.match(/^\/\//))return window.location.protocol+t;if(t.match(/^[a-z]+:/i))return t;let n=document.implementation.createHTMLDocument(),i=n.createElement("base"),a=n.createElement("a");return n.head.appendChild(i),n.body.appendChild(a),r&&(i.href=r),a.href=t,a.href}(r,n):r,c=b(r);if(a){let t=await a(l);s=w(t,c)}else s=await M(l,c,i);return t.replace((o=r.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1"),RegExp(`(url\\(['"]?)(${o})(['"]?\\))`,"g")),`$1${s}$3`)}catch(t){}return t}function z(t){return -1!==t.search(O)}async function P(t,r,n){let i;if(!z(t))return t;let a=function(t,{preferredFontFormat:r}){return r?t.replace(R,t=>{for(;;){let[n,,i]=D.exec(t)||[];if(!i)return"";if(i===r)return`src: ${n};`}}):t}(t,n);return(i=[],a.replace(O,(t,r,n)=>(i.push(n),t)),i.filter(t=>!x(t))).reduce((t,i)=>t.then(t=>L(t,i,r,n)),Promise.resolve(a))}async function j(t,r,n){var i;let a=null==(i=r.style)?void 0:i.getPropertyValue(t);if(a){let i=await P(a,null,n);return r.style.setProperty(t,i,r.style.getPropertyPriority(t)),!0}return!1}async function F(t,r){await j("background",t,r)||await j("background-image",t,r),await j("mask",t,r)||await j("-webkit-mask",t,r)||await j("mask-image",t,r)||await j("-webkit-mask-image",t,r)}async function B(t,r){let n=p(t,HTMLImageElement);if(!(n&&!x(t.src))&&!(p(t,SVGImageElement)&&!x(t.href.baseVal)))return;let i=n?t.src:t.href.baseVal,a=await M(i,b(i),r);await new Promise((i,s)=>{t.onload=i,t.onerror=r.onImageErrorHandler?(...t)=>{try{i(r.onImageErrorHandler(...t))}catch(t){s(t)}}:s,t.decode&&(t.decode=i),"lazy"===t.loading&&(t.loading="eager"),n?(t.srcset="",t.src=a):t.href.baseVal=a})}async function W(t,r){let n=s(t.childNodes).map(t=>H(t,r));await Promise.all(n).then(()=>t)}async function H(t,r){p(t,Element)&&(await F(t,r),await B(t,r),await W(t,r))}let U={};async function q(t){let r=U[t];if(null!=r)return r;let n=await fetch(t);return r={url:t,cssText:await n.text()},U[t]=r,r}async function V(t,r){let n=t.cssText,i=/url\(["']?([^"')]+)["']?\)/g;return Promise.all((n.match(/url\([^)]+\)/g)||[]).map(async a=>{let s=a.replace(i,"$1");return s.startsWith("https://")||(s=new URL(s,t.url).href),$(s,r.fetchRequestInit,({result:t})=>(n=n.replace(a,`url(${t})`),[a,t]))})).then(()=>n)}function Y(t){if(null==t)return[];let r=[],n=t.replace(/(\/\*[\s\S]*?\*\/)/gi,""),i=RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){let t=i.exec(n);if(null===t)break;r.push(t[0])}n=n.replace(i,"");let a=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,s=RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})","gi");for(;;){let t=a.exec(n);if(null===t){if(null===(t=s.exec(n)))break;a.lastIndex=s.lastIndex}else s.lastIndex=a.lastIndex;r.push(t[0])}return r}async function G(t,r){let n=[],i=[];return t.forEach(n=>{if("cssRules"in n)try{s(n.cssRules||[]).forEach((t,a)=>{if(t.type===CSSRule.IMPORT_RULE){let s=a+1,o=t.href,l=q(o).then(t=>V(t,r)).then(t=>Y(t).forEach(t=>{try{n.insertRule(t,t.startsWith("@import")?s+=1:n.cssRules.length)}catch(r){console.error("Error inserting rule from remote css",{rule:t,error:r})}})).catch(t=>{console.error("Error loading remote css",t.toString())});i.push(l)}})}catch(s){let a=t.find(t=>null==t.href)||document.styleSheets[0];null!=n.href&&i.push(q(n.href).then(t=>V(t,r)).then(t=>Y(t).forEach(t=>{a.insertRule(t,a.cssRules.length)})).catch(t=>{console.error("Error loading remote stylesheet",t)})),console.error("Error inlining remote css file",s)}}),Promise.all(i).then(()=>(t.forEach(t=>{if("cssRules"in t)try{s(t.cssRules||[]).forEach(t=>{n.push(t)})}catch(r){console.error(`Error while reading CSS rules from ${t.href}`,r)}}),n))}async function Z(t,r){if(null==t.ownerDocument)throw Error("Provided element is not within a Document");let n=s(t.ownerDocument.styleSheets);return(await G(n,r)).filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>z(t.style.getPropertyValue("src")))}function X(t){return t.trim().replace(/["']/g,"")}async function K(t,r){let n,i=await Z(t,r),a=(n=new Set,!function t(r){(r.style.fontFamily||getComputedStyle(r).fontFamily).split(",").forEach(t=>{n.add(X(t))}),Array.from(r.children).forEach(r=>{r instanceof HTMLElement&&t(r)})}(t),n);return(await Promise.all(i.filter(t=>a.has(X(t.style.fontFamily))).map(t=>{let n=t.parentStyleSheet?t.parentStyleSheet.href:null;return P(t.cssText,n,r)}))).join("\n")}async function J(t,r){let n=null!=r.fontEmbedCSS?r.fontEmbedCSS:r.skipFonts?null:await K(t,r);if(n){let r=document.createElement("style"),i=document.createTextNode(n);r.appendChild(i),t.firstChild?t.insertBefore(r,t.firstChild):t.appendChild(r)}}async function Q(t,r={}){let{width:n,height:i}=d(t,r),a=await N(t,r,!0);return await J(a,r),await H(a,r),!function(t,r){let{style:n}=t;r.backgroundColor&&(n.backgroundColor=r.backgroundColor),r.width&&(n.width=`${r.width}px`),r.height&&(n.height=`${r.height}px`);let i=r.style;null!=i&&Object.keys(i).forEach(t=>{n[t]=i[t]})}(a,r),await f(a,n,i)}async function ee(t,r={}){let{width:n,height:i}=d(t,r),a=await Q(t,r),s=await u(a),o=document.createElement("canvas"),l=o.getContext("2d"),c=r.pixelRatio||function(){let t,r;try{r=process}catch(t){}let n=r&&r.env?r.env.devicePixelRatio:null;return n&&Number.isNaN(t=parseInt(n,10))&&(t=1),t||window.devicePixelRatio||1}(),h=r.canvasWidth||n,f=r.canvasHeight||i;return o.width=h*c,o.height=f*c,!r.skipAutoScale&&(o.width>16384||o.height>16384)&&(o.width>16384&&o.height>16384?o.width>o.height?(o.height*=16384/o.width,o.width=16384):(o.width*=16384/o.height,o.height=16384):o.width>16384?(o.height*=16384/o.width,o.width=16384):(o.width*=16384/o.height,o.height=16384)),o.style.width=`${h}`,o.style.height=`${f}`,r.backgroundColor&&(l.fillStyle=r.backgroundColor,l.fillRect(0,0,o.width,o.height)),l.drawImage(s,0,0,o.width,o.height),o}async function et(t,r={}){return(await ee(t,r)).toDataURL()}},4094(t,r,n){n.d(r,{A:()=>c});var i=n(7014);let a=t=>{let r=t.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,n)=>n?n.toUpperCase():r.toLowerCase());return r.charAt(0).toUpperCase()+r.slice(1)},s=(...t)=>t.filter((t,r,n)=>!!t&&""!==t.trim()&&n.indexOf(t)===r).join(" ").trim();var o={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let l=(0,i.forwardRef)(({color:t="currentColor",size:r=24,strokeWidth:n=2,absoluteStrokeWidth:a,className:l="",children:c,iconNode:d,...u},h)=>(0,i.createElement)("svg",{ref:h,...o,width:r,height:r,stroke:t,strokeWidth:a?24*Number(n)/Number(r):n,className:s("lucide",l),...!c&&!(t=>{for(let r in t)if(r.startsWith("aria-")||"role"===r||"title"===r)return!0})(u)&&{"aria-hidden":"true"},...u},[...d.map(([t,r])=>(0,i.createElement)(t,r)),...Array.isArray(c)?c:[c]])),c=(t,r)=>{let n=(0,i.forwardRef)(({className:n,...o},c)=>(0,i.createElement)(l,{ref:c,iconNode:r,className:s(`lucide-${a(t).replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${t}`,n),...o}));return n.displayName=a(t),n}},2278(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("arrow-left-right",[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]])},1685(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]])},8548(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]])},363(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("ban",[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]])},9114(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]])},1750(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]])},5039(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]])},3598(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]])},1015(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]])},5449(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]])},9398(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("circle-dot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]])},5896(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("clock",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]])},262(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("compass",[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]])},2385(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]])},9674(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("crosshair",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]])},5838(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("diamond",[["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z",key:"1f1r0c"}]])},9672(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]])},3780(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]])},5911(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]])},7837(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("file-code-2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]])},8840(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]])},2370(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("flag",[["path",{d:"M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528",key:"1jaruq"}]])},2504(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]])},8823(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("git-branch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]])},4427(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("git-merge",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]])},2032(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("git-pull-request",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]])},8973(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("grip-horizontal",[["circle",{cx:"12",cy:"9",r:"1",key:"124mty"}],["circle",{cx:"19",cy:"9",r:"1",key:"1ruzo2"}],["circle",{cx:"5",cy:"9",r:"1",key:"1a8b28"}],["circle",{cx:"12",cy:"15",r:"1",key:"1e56xg"}],["circle",{cx:"19",cy:"15",r:"1",key:"1a92ep"}],["circle",{cx:"5",cy:"15",r:"1",key:"5r1jwy"}]])},6225(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]])},2274(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("layers",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]])},8737(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("maximize-2",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]])},5205(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]])},1595(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("minimize-2",[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]])},2966(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]])},6500(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]])},2850(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("octagon-alert",[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]])},4063(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("pen-line",[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]])},3001(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]])},7073(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]])},5062(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]])},5816(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},9279(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("redo-2",[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]])},7501(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]])},4205(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]])},6692(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]])},6874(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]])},2632(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("shield-check",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]])},2161(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]])},1893(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("sliders-horizontal",[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]])},3147(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("sparkles",[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]])},8070(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("split",[["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"M8 3H3v5",key:"15dfkv"}],["path",{d:"M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3",key:"1qrqzj"}],["path",{d:"m15 9 6-6",key:"ko1vev"}]])},5367(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]])},5276(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("sticky-note",[["path",{d:"M16 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8Z",key:"qazsjp"}],["path",{d:"M15 3v4a2 2 0 0 0 2 2h4",key:"40519r"}]])},4509(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("table-2",[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]])},4853(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]])},615(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]])},4447(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},9621(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("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"}]])},113(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]])},5433(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("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"}]])},7374(t,r,n){n.d(r,{A:()=>i});let i=(0,n(4094).A)("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},5486(t,r,n){var i=n(7014),a="function"==typeof Object.is?Object.is:function(t,r){return t===r&&(0!==t||1/t==1/r)||t!=t&&r!=r},s=i.useState,o=i.useEffect,l=i.useLayoutEffect,c=i.useDebugValue;function d(t){var r=t.getSnapshot;t=t.value;try{var n=r();return!a(t,n)}catch(t){return!0}}var u="u"<typeof window||void 0===window.document||void 0===window.document.createElement?function(t,r){return r()}:function(t,r){var n=r(),i=s({inst:{value:n,getSnapshot:r}}),a=i[0].inst,u=i[1];return l(function(){a.value=n,a.getSnapshot=r,d(a)&&u({inst:a})},[t,n,r]),o(function(){return d(a)&&u({inst:a}),t(function(){d(a)&&u({inst:a})})},[t]),c(n),n};r.useSyncExternalStore=void 0!==i.useSyncExternalStore?i.useSyncExternalStore:u},3873(t,r,n){var i=n(7014),a=n(4649),s="function"==typeof Object.is?Object.is:function(t,r){return t===r&&(0!==t||1/t==1/r)||t!=t&&r!=r},o=a.useSyncExternalStore,l=i.useRef,c=i.useEffect,d=i.useMemo,u=i.useDebugValue;r.useSyncExternalStoreWithSelector=function(t,r,n,i,a){var h=l(null);if(null===h.current){var f={hasValue:!1,value:null};h.current=f}else f=h.current;var p=o(t,(h=d(function(){function t(t){if(!c){if(c=!0,o=t,t=i(t),void 0!==a&&f.hasValue){var r=f.value;if(a(r,t))return l=r}return l=t}if(r=l,s(o,t))return r;var n=i(t);return void 0!==a&&a(r,n)?(o=t,r):(o=t,l=n)}var o,l,c=!1,d=void 0===n?null:n;return[function(){return t(r())},null===d?void 0:function(){return t(d())}]},[r,n,i,a]))[0],h[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}},4649(t,r,n){t.exports=n(5486)},7863(t,r,n){t.exports=n(3873)},172(t,r,n){var i;let a,s,o,l,c;function d(t,...r){return`XState error E${t}${r.length?` (${r.map(t=>"string"==typeof t?JSON.stringify(t):String(t)).join(", ")})`:""}. See https://github.com/statelyai/xstate/blob/next/docs/errors.md#e${t}`}n.d(r,{$:()=>tS,O:()=>P,S:()=>ee,T:()=>rZ,U:()=>e6,V:()=>e8,W:()=>A,Y:()=>M,Z:()=>_,_:()=>e3,a:()=>et,a0:()=>b,a1:()=>L,a2:()=>e$,a3:()=>tm,a4:()=>ty,a5:()=>tb,a6:()=>er,a8:()=>ea,a9:()=>ef,aA:()=>Q,aB:()=>tF,aC:()=>tN,aD:()=>tx,aE:()=>to,aF:()=>tE,aG:()=>rw,aH:()=>tA,aI:()=>t5,aJ:()=>rY,aK:()=>tw,aa:()=>t9,ab:()=>t8,ac:()=>rN,ad:()=>t7,af:()=>ed,ag:()=>t6,aj:()=>rn,ak:()=>rA,al:()=>t3,am:()=>tK,an:()=>tW,ao:()=>th,ap:()=>tU,aq:()=>r_,ar:()=>tH,as:()=>eV,at:()=>rV,au:()=>ru,av:()=>Z,aw:()=>k,ax:()=>rp,ay:()=>rk,az:()=>rE,b:()=>rd,d:()=>m,f:()=>rq,g:()=>t2,h:()=>y,j:()=>r8,m:()=>ep,n:()=>tT,p:()=>tz,r:()=>G,s:()=>ek,t:()=>es,w:()=>w,x:()=>d});let u=["types","tsTypes","schema","internalEvents","services","devTools"],h=["onDone","onError","onTimeout","always"],f=["onDone","onError","onSnapshot","onTimeout"],p=/^xstate\.(done\.actor|error\.actor|snapshot|done\.state|after)\.(.+)$/;function g(t,r,n){if(t){for(let i of Array.isArray(t)?t:[t])if(i&&"object"==typeof i){if(void 0!==i.cond)throw Error(d(4,r,n,"cond"));if(void 0!==i.guard)throw Error(d(4,r,n,"guard"));if(void 0!==i.actions)throw Error(d(4,r,n,"actions"))}}}function m(t){if(t&&"object"==typeof t){for(let r of u)if(void 0!==t[r])throw Error(d(1,r));!function t(r,n){var i=r.initial;if(i&&"object"==typeof i){if(void 0!==i.cond)throw Error(d(5,n,"cond"));if(void 0!==i.guard)throw Error(d(5,n,"guard"));if(void 0!==i.actions)throw Error(d(5,n,"actions"))}if(void 0!==r.activities)throw Error(d(6,n));for(let t of["entry","exit"]){let i=r[t];if(void 0!==i&&"function"!=typeof i)throw Error(d(7,n,t))}if(r.on)for(let t of Object.keys(r.on))!function(t,r){let n=p.exec(t);if(n&&"*"!==n[2]&&("snapshot"!==n[1]||"actor"!==n[2]&&"actor.*"!==n[2]))throw Error(d(3,t,r))}(t,n),g(r.on[t],t,n);if(r.after)for(let t of Object.keys(r.after))g(r.after[t],`after.${t}`,n);for(let t of h)g(r[t],t,n);if(r.invoke){for(let t of Array.isArray(r.invoke)?r.invoke:[r.invoke])if(t&&"object"==typeof t)for(let r of f)g(t[r],`invoke.${r}`,n)}if(r.states)for(let i of Object.keys(r.states)){let a=r.states[i];a&&"object"==typeof a&&t(a,a.id??(n?`${n}.${i}`:i))}}(t,t.id??"")}}function y(t){if(t&&"object"==typeof t&&void 0!==t.internalEvents)throw Error(d(2))}let v=new Set(["clock","logger","syncSnapshot","id","registryKey","input","simulate","src","inspect","onRejectedEvent","onUnhandledEvent","_systemRef","_sessionId","_inert","_restore"]),b="xstate.init",x="@xstate.spawn",w="xstate.stop",$="@xstate.terminate",k="xstate.timer",M="xstate.logic.effect.resolve",_="xstate.logic.effect.reject",A="xstate.logic.effect.start",E={unsubscribe(){}};function S(t){return!0===t._remote}function C(t){if("object"!=typeof t||null===t||Array.isArray(t)||"string"!=typeof t["@actor"])return!1;for(let r in t)if("@actor"!==r&&"incarnation"!==r)return!1;let r=t.incarnation;return void 0===r||"string"==typeof r}function T(t){let r=t.slice(t.lastIndexOf("/")+1);return r.includes("%")?r.replaceAll("%2F","/").replaceAll("%25","%"):r}function I(t){return Error(d(50,...void 0===t.incarnation?[t["@actor"]]:[t["@actor"],t.incarnation]))}function N(t,r){let n=t._getByAddress?.(r["@actor"]);return n&&(void 0===r.incarnation||n.sessionId===r.incarnation)?n:void 0}let O=Object.freeze({status:"active",output:void 0,error:void 0}),D=new WeakMap;function R(t,r,n){return D.set(Object.freeze(n),{source:t,target:r}),t.system._relay(t,r,n)}function L(t,r,n){return t.system._notifyEmitted(t,r),n.emitEvent(t,r)}let z=new WeakMap;async function P(t,r,n,i=r=>void t.system.sendEvent(t,t,r)){let a,s,o,l,c=(l=t.getSnapshot().effects)&&Object.prototype.hasOwnProperty.call(l,r)?l[r]:void 0;if(c?.status==="done")return c.output;if(c?.status==="error")throw c.error;let u=z.get(t)?.get(r);if(u)return u;if("active"!==t.getSnapshot().status)throw Error(d(72,r));let h=new Promise((t,r)=>{a=t,s=r}),f=z.get(t);f||(f=new Map,z.set(t,f)),f.set(r,h);let p=()=>{o?.unsubscribe(),f.delete(r),f.size||z.delete(t)};return h.then(p,p),o=t.subscribe({error:s,complete:()=>s(Error(d(72,r)))}),(async()=>{try{i({type:A,key:r});let s=await n();"active"===t.getSnapshot().status&&(i({type:M,key:r,output:s}),a(s))}catch(n){"active"===t.getSnapshot().status&&i({type:_,key:r,error:n}),s(n)}})().catch(s),h}function j(t,r){return Error(d(80,t,r))}function F(t,r,n,i=!1){let a=function(t,r,n,i){switch(n.type){case"xstate.done.actor":case"xstate.error.actor":case"xstate.snapshot.actor":{let a=D.get(n);if(a&&a.source===t&&a.target===r){i&&D.delete(n);return}if(i&&t&&S(t)&&t._parent===r&&t.id===n.actorId&&"string"==typeof n.sessionId&&(void 0===t.sessionId||t.sessionId===n.sessionId)&&r.getSnapshot().children?.[t.id]===t)return;return j(n.type,r.id)}case"xstate.done.state":case"xstate.error.execution":return j(n.type,r.id)}if(t!==r&&r.logic?.isInternalEventType?.(n.type))return Error(d(73,n.type,r.id))}(t,r,n,i);return!!a&&(r.system.deadLetter(t,r,n,"internalEvent",{error:a}),!0)}class B{constructor(t){this._process=t,this._active=!1,this._current=null,this._last=null,this._deferred=void 0,this._processing=!1,this._flushingDeferred=!1}start(){this._active=!0,this.flush()}clear(){this._current&&this._processing?(this._current.next=null,this._last=this._current):(this._current=null,this._last=null)}enqueue(t){let r={value:t,next:null};if(this._current){this._last.next=r,this._last=r;return}this._current=r,this._last=r,this._active&&this.flush()}defer(t){this._processing||this._flushingDeferred?(this._deferred??=[]).push(t):t()}flush(){for(;this._current;){let t=this._current;this._processing=!0;try{this._process(t.value)}finally{this._processing=!1}if(this._current=t.next,this._current||(this._last=null),!this._flushingDeferred&&this._deferred){this._flushingDeferred=!0;try{for(let t=0;t<this._deferred.length;t++)this._deferred[t]()}finally{this._deferred=void 0,this._flushingDeferred=!1}}}this._last=null}}let W=new WeakMap;function H(t){let{stateId:r,delay:n,actorId:i}=t;switch(t.type){case"xstate.after":return{type:t.type,delay:n,stateId:r};case"xstate.timeout.state":return{type:t.type,stateId:r};case"xstate.timeout.actor":return{type:t.type,actorId:i}}}function U(t){return void 0!==t.id?{id:t.id}:void 0!==t.seq?{seq:t.seq}:{event:H(t.event)??t.event}}function q(t){return"string"==typeof t.id?{id:t.id}:"number"==typeof t.seq?{seq:t.seq}:t.event&&"object"==typeof t.event&&"string"==typeof t.event.type?{event:t.event}:void 0}function V(t,r){if("id"in r)return t.id===r.id;if(void 0!==t.id)return!1;if("seq"in r)return t.seq===r.seq;if(void 0!==t.seq)return!1;let n=t.event,i=r.event;for(let t in i)if(n[t]!==i[t])return!1;return!0}function Y(t,r){return`${t.sessionId}|${"id"in r?JSON.stringify(["id",r.id]):"seq"in r?JSON.stringify(["seq",r.seq]):JSON.stringify(["event",H(r.event)??r.event])}`}function G(t){if(!Array.isArray(t))throw Error("reject(...) requires a nonempty array of rejection objects with a string type.");let r=[];for(let n of t){if(!(n&&"object"==typeof n&&"type"in n&&"string"==typeof n.type))throw Error("reject(...) requires a nonempty array of rejection objects with a string type.");r.push(n)}let[n,...i]=r;if(!n)throw Error("reject(...) requires a nonempty array of rejection objects with a string type.");return{reject:[n,...i]}}function Z(t){return!!t&&"object"==typeof t&&"reject"in t}function X(t,r){if(G(t.reject),["target","context","input","reenter"].some(r=>r in t))throw Error("A rejection cannot include a target, context, input, or reenter.");if(r)for(let n of t.reject){let t=r[n.type];if(!t)throw Error(`Unknown rejection type "${n.type}".`);let{type:i,...a}=n,s=t["~standard"].validate(a);if("then"in s)throw Promise.resolve(s).catch(()=>{}),Error("Rejection schemas must be synchronous.");if(s.issues)throw Error(`Invalid rejection "${n.type}": ${s.issues.map(t=>t.message).join(", ")}`)}}function K(t,r){return{type:"xstate.timeout.actor",actorId:t,sessionId:r}}function J(t,r){return{type:"xstate.done.state",stateId:t,output:r}}function Q(t,r){return{type:`xstate.error.${t}`,error:r}}function ee(t){return{type:b,input:t}}function et(t,r){if(r.startsWith("xstate.")||r.startsWith("@xstate."))throw Error(d(37,t,r))}function er(t){for(let r=0;r<t.length;r++)if("\\"===t[r])r++;else if("."===t[r])return!0;return!1}function en(t){if(ec(t))return t;let r=[],n="";for(let i=0;i<t.length;i++){switch(t.charCodeAt(i)){case 92:n+="."===t[i+1]?"\\.":t[i+1],i++;continue;case 46:r.push(n),n="";continue}n+=t[i]}return r.push(n),r}function ei(t){return rz(t)?t.value:"string"!=typeof t?t:function(t){if(1===t.length)return t[0];let r={},n=r;for(let r=0;r<t.length-1;r++)if(r===t.length-2)n[t[r]]=t[r+1];else{let i=n;n={},i[t[r]]=n}return r}(en(t))}function ea(t,r){let n={},i=Object.keys(t);for(let a=0;a<i.length;a++){let s=i[a],o=r(t[s],s,t,a);"__proto__"===s?Object.defineProperty(n,s,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[s]=o}return n}function es(t){var r;return void 0===t?[]:ec(r=t)?r:[r]}function eo(t,r,n,i,a){return"function"==typeof t?t({context:r,event:n,output:el(n),self:i,input:a}):t}function el(t){var r;if("xstate.done.actor"===(r=t).type||"xstate.done.state"===r.type)return t.output}function ec(t){return Array.isArray(t)}function ed(t,r,n){var i;return(ec(i=t)?i:[i]).map(t=>{if("string"==typeof t)throw Error(d(38,r,n,t));return void 0===t?{target:void 0}:"function"==typeof t?{to:t}:t})}function eu(t){if(void 0!==t&&""!==t)return es(t)}function eh(t,r,n){let i="object"==typeof t,a=i?t:void 0;return{next:(i?t.next:t)?.bind(a),error:(i?t.error:r)?.bind(a),complete:(i?t.complete:n)?.bind(a),...i&&t.passive?{passive:!0}:{}}}function ef(t,r){return`${t}:${r}`}function ep(t,r){if(r===t||"*"===r)return!0;if(!r.endsWith(".*"))return!1;let n=r.split("."),i=t.split(".");for(let t=0;t<n.length;t++){let r=n[t],a=i[t];if("*"===r)return t===n.length-1;if(r!==a)return!1}return!0}function eg(t){if("string"==typeof t)throw Error(d(70,t))}let em=t=>t.system.spawnActor(t._parent,t),ey=(t,r,n)=>t.system.scheduleTimer(t.self,U({id:n.id,seq:n.seq,event:r}),n?.delay??0),ev=(t,r,n,i)=>(eg(n),i?.delay!==void 0)?t.system.scheduleTimer(t.self,U({id:i.id,seq:i.seq,event:n}),i?.delay??0):t.system._relay(t.self,r,n),eb=(t,r)=>t.system.cancelTimer(t.self,r),ex=(t,r)=>t.system.stopActor(r),ew=new WeakMap;function e$(t,r){let n=ew.get(t);if(!n){for(let r of(n=new Map,Object.keys(t))){let i=t[r];n.has(i)||n.set(i,r)}ew.set(t,n)}return n.get(r)}let ek=Symbol("xstate.systemLogicMetadata"),eM=new WeakMap,e_="xstate.attached.forward";function eA(t,r){let n=(t,r)=>[{status:"active",output:void 0,error:void 0,input:t},[]],i={id:r,start:(r,{self:n,system:i})=>{let a,s=r.input.actor;if(!s||"stopped"===s.getSnapshot().status)return;let o=t(r.input,{self:n,system:i});if(!o)return;let l=!1,c=()=>{l||(l=!0,o.unsubscribe(),a?.unsubscribe())},d=n._parent;d&&(a=d.subscribe({complete:c,error:c})),eM.set(n,{unsubscribe:c})},transition:(t,r,n)=>{let i=n.self;return r.type===e_?[t,"active"===t.status&&i._parent?[tS(n,i._parent,r.event)]:[]]:r.type===w?(eM.get(i)?.unsubscribe(),eM.delete(i),[{...t,status:"stopped",error:void 0},[]]):[t,[]]},initialTransition:n,getInitialSnapshot:(t,r)=>n(r)[0],getPersistedSnapshot:t=>t,restoreSnapshot:t=>t,isInternalEventType:t=>t===e_};return Object.defineProperty(i,ek,{value:{kind:r}}),i}function eE(t,r,n){"stopped"!==t.getSnapshot().status&&t._parent&&r._relay(t,t,{type:e_,event:n()})}let eS=eA(({actor:t,eventType:r,mapper:n},{self:i,system:a})=>{let s="*"!==r&&r.endsWith(".*");return t.on(s?"*":r,t=>{(!s||ep(t.type,r))&&eE(i,a,()=>n(t))})},"@xstate.listener"),eC=eA(({actor:t,mappers:r},{self:n,system:i})=>{let{done:a,error:s,snapshot:o}=r;return t.subscribe({next:t=>{"done"===t.status&&a?eE(n,i,()=>a(t.output)):"error"===t.status&&s?eE(n,i,()=>s(t.error)):"active"===t.status&&o&&eE(n,i,()=>o(t))},error:t=>{s&&eE(n,i,()=>s(t))},complete:()=>{}})},"@xstate.subscription"),eT=[],eI=Error("Transition effect");function eN(t){let r=!1,n=!1;for(let i of eT)i.parent===t&&(i.requiresReevaluation=!0,r=!0,n||="abort"===i.mode);if(n)throw eI;return r}function eO(t,r="abort"){let n={mode:r,parent:t,requiresReevaluation:!1};return eT.push(n),{frame:n,close(){eT.pop()}}}function eD(t){setTimeout(()=>{throw t})}let eR=new WeakMap,eL=["runtime","_timerMap","_rejectionListeners","_inspectionObservers","_emissionListeners"],ez=new WeakMap,eP=new WeakMap,ej=new WeakMap,eF=new Map;function eB(t){let r=t._peekKeyedActors;return r?r.call(t)??eF:t.keyedActors}function eW(t){t._snapshotVersion++}function eH(t){return t._snapshotVersion}function eU(t){let r=eP.get(t);if(r)return r;let n=ej.get(t);if(!n)return;let i=n();return eP.set(t,i),ej.delete(t),i}function eq(t,r){let n=eP.get(t);if(n)return eP.set(r,n),!0;let i=ej.get(t);return!!i&&(ej.set(r,i),!0)}function eV(t,r,n=r.system,i){ej.delete(t);let a=eH(n),s=i?eU(i):void 0,o=s?.actor===r?s:eU(t);if(o?.actor===r&&o.systemState.sourceSystem===n&&o.systemState.sourceVersion===a)return void eP.set(t,o);let l=function(t){let r=t._getRootActor?.(),n=t._peekChildren?.();if(!r&&!n){if(t._getRootActor&&t._peekChildren)return{};let r=new Map(t.children);return r.size?{children:r}:{}}return n?.size?{children:new Map(t.children)}:r?{root:r}:{}}(n),c=l.children,d=eB(n),u=d.size?new Map(d):eF;for(let r of Object.values("children"in t&&t.children?t.children:{})){if(!r)continue;r.sessionId&&(c??=new Map).set(r.sessionId,r);let t=r.registryKey;t&&(u===eF&&(u=new Map),u.set(t,r))}eP.set(t,{actor:r,systemState:{...l,children:c,keyedActors:u,snapshot:{...n._snapshot},sourceSystem:n,sourceVersion:a}})}let eY=0;function eG(t){if("string"==typeof t)return t;let r=t?.id;return"string"==typeof r&&r.length?r:"x"}function eZ(t){return t.includes("/")||t.includes("%")?t.replaceAll("%","%25").replaceAll("/","%2F"):t}function eX(t){let r=t.lastIndexOf(":");if(r<=0||r===t.length-1)return;let n=Number(t.slice(r+1));return Number.isSafeInteger(n)&&n>=0?{prefix:t.slice(0,r),index:n}:void 0}function eK(t,r){return`${t?t.address:""}|${r}`}function eJ(t,r,n){let i=t._snapshot._nextActorIds;(i[r]??0)>=n||(t._snapshot._nextActorIds={...i,[r]:n},eW(t))}let eQ=Object.freeze({});function e0(t,r){return t.getSnapshot()?.timers?.find(t=>V(t,r))}class e1{get children(){let t=this._children??=new Map;return this._getRootActor()&&t.set(this._rootActor.sessionId,this._rootActor),t}set children(t){this._children=t}_getRootActor(){return this._rootActor._isRunning()?this._rootActor:void 0}_peekChildren(){return this._children}get keyedActors(){return this._keyedActors??=new Map}set keyedActors(t){this._keyedActors=t}get reverseKeyedActors(){return this._reverseKeyedActors??=new WeakMap}set reverseKeyedActors(t){this._reverseKeyedActors=t}_peekKeyedActors(){return this._keyedActors}constructor(t,r){this._rootActor=t,this._identity=l??{executionId:(o??=function(){let t;try{t=globalThis.crypto}catch{}if(t?.getRandomValues)try{let r=new Uint32Array(4);return t.getRandomValues(r),Array.from(r,t=>t.toString(36).padStart(7,"0")).join("")}catch{}if(t?.randomUUID)try{return t.randomUUID().replaceAll("-","")}catch{}return`xstate-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}(),`${o}:${(eY++).toString(36)}`),nextSessionId:0},this._snapshot=void 0,this._snapshotVersion=0,this.scheduler=this,this._clock=void 0,this._logger=void 0,this.createActorRef=void 0,this.initializeActorRef=void 0,this.discardActorRef=void 0,this._clock=r.clock,this._logger=r.logger,this.createActorRef=r.createActorRef,this.initializeActorRef=r.initializeActorRef,this.discardActorRef=r.discardActorRef,function(t){a?.isActive()&&a.attach(t)}(this),this._snapshot={_scheduledTimers:eQ,_nextActorIds:{}}}_recordSent(t,r,n,i,a){this._inspectionObservers?.size&&t&&t._inTransition&&(t._collectedSent??=[]).push({targetRef:r,targetId:r.id,event:n,delay:i,id:a})}schedule(t,r,n){let i=Y(t,r);this._timerMap?.[i]!==void 0&&this.cancel(t,r);let a=e0(t,r);if(a){let r="self"===a.target?t:a.target;this._recordSent(t,r,a.event,n,a.id)}let s=this._clock.now?.()??Date.now();this._snapshot._scheduledTimers===eQ&&(this._snapshot._scheduledTimers={}),this._snapshot._scheduledTimers[i]={source:t,delay:n,key:r,scheduledAt:s,dueAt:s+n},eW(this);let o=this._clock.setTimeout(()=>{this._timerMap&&delete this._timerMap[i],delete this._snapshot._scheduledTimers[i],eW(this),this._deliver(t,t,{type:k,...r})},n);(this._timerMap??={})[i]=o}cancel(t,r){let n=Y(t,r),i=this._timerMap?.[n];this._timerMap&&delete this._timerMap[n],this._snapshot._scheduledTimers!==eQ&&delete this._snapshot._scheduledTimers[n],eW(this),void 0!==i&&this._clock.clearTimeout(i)}cancelAll(t){for(let r in this._snapshot._scheduledTimers){let n=this._snapshot._scheduledTimers[r];n.source===t&&this.cancel(t,n.key)}}_deliver(t,r,n){!function(t,r,n){if(C(r)){let i=r,a=t?.system,s=a&&N(a,i);if(!s){let r=I(i);if(!a)throw r;a.deadLetter(t,void 0,n,"missingTarget",{targetId:T(i["@actor"]),error:r});return}r=s}F(t,r,n,!0)||r._send(n,t)}(t,r,n)}_register(t,r){return r===this._rootActor?this._children?.set(t,r):(this._children??=new Map).set(t,r),eW(this),t}_getByAddress(t){let r=this._getRootActor();if(r?.address===t)return r;for(let r of this._children?.values()??[])if(r.address===t&&r._isRunning())return r}_unregister(t){let r;t===this._rootActor?(r=void 0!==this._getRootActor(),r=void 0!==t.sessionId&&(this._children?.delete(t.sessionId)??!1)||r):r=void 0!==t.sessionId&&(this._children?.delete(t.sessionId)??!1);let n=this._reverseKeyedActors?.get(t);void 0!==n&&(this._keyedActors?.get(n)===t&&(this._keyedActors.delete(n),r=!0),this._reverseKeyedActors?.delete(t)),r&&eW(this)}get(t){return this._keyedActors?.get(t)}getAll(){return Object.fromEntries(this._keyedActors?.entries()??[])}_set(t,r){let n=this._keyedActors?.get(t);if(n&&n!==r)throw Error(d(45,String(t)));(this._keyedActors??=new Map).set(t,r),(this._reverseKeyedActors??=new WeakMap).set(r,t),n!==r&&eW(this)}inspect(t){let r=eh(t);return(this._inspectionObservers??=new Set).add(r),{unsubscribe:()=>{this._inspectionObservers?.delete(r)}}}onRejectedEvent(t){let r=r=>t(r);return(this._rejectionListeners??=new Set).add(r),{unsubscribe:()=>{this._rejectionListeners?.delete(r)}}}onEmitted(t){let r=r=>t(r);return(this._emissionListeners??=new Set).add(r),{unsubscribe:()=>{this._emissionListeners?.delete(r)}}}_notifyEmitted(t,r){let n=this._emissionListeners;if(!n?.size)return;let i={actorRef:t,event:r};for(let t of Array.from(n))try{t(i)}catch(t){eD(t)}}_hasInspectionObservers(){return!!this._inspectionObservers?.size}_sendInspectionEvent(t){if(!this._inspectionObservers?.size)return;let r={...t,rootId:this._rootActor.sessionId};this._inspectionObservers.forEach(t=>{try{t.next?.(r)}catch(t){eD(t)}})}spawnActor(t,r){return this.runtime?.spawnActor?.(t,r)}startActor(t){let r=this.runtime?.startActor;if(r)return r(t);t.start()}stopActor(t){let r=this.runtime?.stopActor;if(r)return r(t);t._stop()}terminateActor(t,r){let n=this.runtime?.terminateActor;if(n)return n(t,r);t._terminate(r)}sendEvent(t,r,n){if(C(r)){let i=N(this,r);if(i)r=i;else if(this._getByAddress(r["@actor"])||!this.runtime?.sendEvent)return this.deadLetter(t,void 0,n,"missingTarget",{targetId:T(r["@actor"]),error:I(r)})}if(F(t,r,n))return;this._recordSent(t,r,n);let i=this.runtime?.sendEvent;return i?i(t,r,n):t&&r===t._parent&&"_deferDelivery"in t&&"function"==typeof t._deferDelivery?void t._deferDelivery(()=>this._deliver(t,r,n)):void this._deliver(t,r,n)}emitEvent(t,r){let n=this.runtime?.emitEvent;if(n)return n(t,r);t._emit(r)}deadLetter(t,r,n,i,a){let s=this._rejectionListeners;if(s?.size){let o={event:n,targetRef:r,targetId:r?.id??a?.targetId,sourceRef:t,eventOrigin:t?"actor":"external",reason:i,issues:a?.issues,error:a?.error};for(let t of[...s])try{t(o)}catch(t){eD(t)}}let o=this.runtime?.deadLetter;if(o)return o(t,r,n,i,a)}runStep(t,r,n){let i=this.runtime?.runStep;return i?i(t,r,n):P(t,r,n)}runLogic(t,r){let n=this.runtime?.runLogic;return n?n(t,r):r()}scheduleTimer(t,r,n){let i=this.runtime?.scheduleTimer;if(i){let a=e0(t,r);if(a){let r="self"===a.target?t:a.target;this._recordSent(t,r,a.event,n,a.id)}return i(t,r,n)}this.schedule(t,r,n)}cancelTimer(t,r){let n=this.runtime?.cancelTimer;if(n)return n(t,r);this.cancel(t,r)}cancelAllTimers(t){let r=this.runtime?.cancelAllTimers;if(r)return r(t);this.cancelAll(t)}_relay(t,r,n){if(!eN(r))return this.sendEvent(t,r,n)}getSnapshot(){return{_scheduledTimers:{...this._snapshot._scheduledTimers}}}start(){let t=this._snapshot._scheduledTimers,r=!0;for(let n in t){r&&(this._snapshot._scheduledTimers={},r=!1);let{source:i,dueAt:a,key:s}=t[n];this.scheduleTimer(i,s,Math.max(0,a-(this._clock.now?.()??Date.now())))}}}function e2(){return this.action?.(...this.args)}function e4(t=this.source.system){return L(this.source,this.event,t)}function e3(t,r){return{kind:"emit",exec:e4,type:r.type,source:t.self,event:r,params:void 0,args:[]}}function e5(t=(this.target??this.source).system){return t.deadLetter(this.source,this.target,this.event,this.reason,this.detail)}function e6(t,r,n,i,a){return{kind:"builtin",type:"@xstate.deadLetter",exec:e5,source:r,target:t.self,event:n,reason:i,detail:a,params:void 0,args:[]}}function e8(t,r,n){return{kind:"action",exec:r,type:t,action:r,params:n,args:[]}}function e9(t=this.actor.system){return t.spawnActor(this.source,this.actor)}function e7(t=this.actor.system){if(2!==this.actor._processingStatus)return t.startActor(this.actor)}function te(t=this.source.system){return t.stopActor(this.actor)}function tt(t=this.actor.system){let r="done"===this.status?{status:"done",output:this.output,error:void 0}:{status:"error",output:void 0,error:this.error};return t.terminateActor(this.actor,r)}function tr(t=this.source.system){return t.scheduleTimer(this.source,{...U(this),occurrence:this.occurrence},this.delay??0)}function tn(t=this.source.system){return(eg(this.event),void 0!==this.delay)?t.scheduleTimer(this.source,{...U(this),occurrence:this.occurrence},this.delay):t.sendEvent(this.source,this.target,this.event)}function ti(t=this.source.system){return t.cancelTimer(this.source,q(this))}function ta(t,r){return{...t,...r}}function ts(t,r,...n){let i={action:r,args:n};return t.push(i),i}function to(t,r){let n={...t};for(let t of Object.keys(r))n[t]=Math.max(n[t]??0,r[t]);return n}function tl(t,r,n,i){let a=td.get(t)??i;try{let i=t.system.createActorRef(r,n);return a?.actors.push(i),i}catch(t){throw void 0!==n.id&&a?.explicitIds.delete(n.id),t}}function tc(t){for(let r of td.get(t)?.actors.splice(0)??[])t.system.discardActorRef(r),tv(t,r)}let td=new WeakMap,tu=()=>({actors:[],counters:new Map,explicitIds:new Set,stoppedIds:new Set});function th(t){td.set(t,tu())}function tf(t){return t.self._snapshot}function tp(t,r,n){return Math.max(r.counters.get(n)??0,tf(t)?._nextActorIds?.[n]??0)}function tg(t,r,n){let i=tp(t,r,n),a=tf(t)?.children;for(;r.explicitIds.has(`${n}:${i}`)||a?.[`${n}:${i}`];)i++;return i}function tm(t,r,n){let i=td.get(t)??n??tu(),a=eG(r),s=tg(t,i,a);return i.counters.set(a,s+1),{id:`${a}:${s}`,counters:{[a]:s+1}}}function ty(t,r,n){let i=td.get(t)??n??tu(),a=tf(t)?.children?.[r],s=void 0!==a&&!i.stoppedIds.has(r)&&"active"===a.getSnapshot().status;if(i.explicitIds.has(r)||s)throw Error(d(67,r,t.self.id));i.explicitIds.add(r)}function tv(t,r){let n=td.get(t);n&&(n.stoppedIds.add(r.id),n.explicitIds.delete(r.id))}function tb(t,r,n){let i=eX(r);if(!i)return;i.prefix;let a=td.get(t)??n??tu(),s=Math.max(tp(t,a,i.prefix),i.index+1);return a.counters.set(i.prefix,s),{[i.prefix]:s}}function tx(t){let r=td.get(t)?.counters;if(r?.size)return Object.fromEntries(r)}let tw=new WeakSet;function t$(t){if("string"==typeof t)throw Error(d(68,t))}function tk(t,r,n,{registeredActors:i,actorSubscriptions:a=!1,createActors:s=!0,onRefProducingCall:o}={}){let l=td.get(t)??tu(),c={cancel:n=>{ts(r,eb,t,"string"==typeof n?{id:n}:n)},emit:t=>{r.push(t)},log:(...n)=>{ts(r,t.logger,...n)},raise:(i,a)=>{t$(i),a?.delay!==void 0?ts(r,ey,t,i,a):n.push(i)},spawn:(n,a)=>{var c,u;let h,{logic:f,src:p}=function(t,r){if("string"==typeof r){let n=t?.[r];if(!n)throw Error(d(66,r));return{logic:n,src:r}}return t?{logic:r,src:e$(t,r)}:{logic:r,src:void 0}}(i,n);if(!s){o?.();let r=eG(p??f),n=a?.id??`${r}:${tg(t,td.get(t)??l,r)}`;return function(t){let{id:r,address:n}=t,i={ref:void 0,id:r,address:n,src:t.src,sessionId:void 0,send(){},getSnapshot:()=>O,subscribe:()=>E,on:()=>E,toJSON(){if(void 0===n)throw Error(d(51,r));return{"@actor":n}}};return i.ref=i,i}({id:n,address:tw.has(t)?void 0:`${t.self.address}/${eZ(n)}`,src:p})}let g=a?.id;void 0===g?{id:g,counters:h}=tm(t,p??f,l):(ty(t,g,l),h=tb(t,g,l));let m=tl(t,f,{...a,...void 0!==p&&{src:p},id:g,parent:t.self},l);return c=g,u=h,ts(r,em,m).childUpdate={type:"add",actor:m,id:c,counters:u},m},sendTo:(n,i,a)=>{ts(r,ev,t,n,i,a)},stop:n=>{n&&(ts(r,ex,t,n).childUpdate={type:"remove",actor:n},tv(t,n))}};a&&Object.assign(c,{listen:(n,i,a)=>{if(!s)return o?.(),{id:void 0};let l=tl(t,eS,{input:{actor:n,eventType:i,mapper:a},parent:t.self});return ts(r,em,l),l},subscribeTo:(n,i)=>{if(!s)return o?.(),{id:void 0};let a=tl(t,eC,{input:{actor:n,mappers:"function"==typeof i?{snapshot:i}:i},parent:t.self});return ts(r,em,a),a}});let u=!1,h=t=>(...r)=>u?t_():t(...r);for(let t of Object.keys(c))c[t]=h(c[t]);let f=tO(c,h((t,...n)=>{"function"==typeof t&&ts(r,t,...n)}));return tM.set(f,()=>{u=!0}),f}let tM=new WeakMap;function t_(){}function tA(t){let r=[t];return{kind:"builtin",exec:e7,type:"@xstate.start",source:t._parent,params:void 0,args:r,actor:t,id:t.id}}function tE(t){let r=[t];return{kind:"builtin",exec:e9,type:x,source:t._parent,params:void 0,args:r,actor:t,id:t.id,logic:t.logic,src:t.src,input:t.options?.input}}function tS(t,r,n){let i=[t,r,n,{}];return{kind:"builtin",exec:tn,type:"@xstate.sendTo",source:t.self,target:r,event:n,id:void 0,delay:void 0,params:void 0,args:i}}function tC(t,r){if("done"!==r.status&&"error"!==r.status)throw Error(d(69,t.self.id,r.status));let n="done"===r.status?{status:"done",output:r.output,error:void 0}:{status:"error",output:void 0,error:r.error},i=[t.self,n];return{kind:"builtin",exec:tt,type:$,source:t.self,actor:t.self,id:t.self.id,...n,params:void 0,args:i}}function tT(t,r,[n,i]){let a="done"===n.status||"error"===n.status,s=r?.status==="done"||r?.status==="error",o=i.some(t=>"object"==typeof t&&null!==t&&"type"in t&&t.type===$);return!a||s||o?[n,i]:[n,[...i,tC(t,n)]]}function tI(t){return"builtin"===t.kind}function tN(t,r,n,i){let a=t,s=[];for(let t of i){let r,i="function"==typeof t,l=function(t){if("object"==typeof t&&null!==t&&"action"in t&&"function"==typeof t.action)return t}(t),c=l?.args;if(l?.action===ev&&(void 0===l.args[1]||"string"==typeof l.args[1])){let t=l.args[1],r=void 0!==t&&Object.hasOwn(a.children,t)?a.children[t]:void 0;if(!r){var o;s.push((o=l.args[2],{kind:"builtin",type:"@xstate.deadLetter",exec:e5,source:n.self,target:void 0,event:o,reason:"missingTarget",detail:{targetId:t,error:Error(d(65,t))},params:void 0,args:[]}));continue}c=[l.args[0],r,...l.args.slice(2)]}let u=i?t:!!l&&l.action.bind(null,...c);if("object"==typeof t&&null!==t){let{type:n,childUpdate:i,...a}=t;r=a}if(l?.childUpdate&&(a=function(t,r,n){if("add"===r.type)return{...t,children:{...t.children,[r.id]:r.actor},...r.counters&&{_nextActorIds:to(t._nextActorIds,r.counters)}};let i={...t.children},a=r.actor._parent===n.self;for(let t of Object.keys(i))i[t]===r.actor&&(a=!0,delete i[t]);if(!a)throw Error(d(47,r.actor.id,n.self.id));return n.system._unregister(r.actor),{...t,children:i}}(a,l.childUpdate,n)),!u||!("resolve"in u)){let o="object"==typeof t&&null!==t&&"action"in t&&"function"==typeof t.action?function(t,r){switch(t){case em:{let[t]=r;return{type:"@xstate.spawn",kind:"builtin",exec:e9,source:t._parent,actor:t,id:t.id,logic:t.logic,src:t.src,input:t.options?.input}}case ey:{let[,t,n]=r;return{type:"@xstate.raise",kind:"builtin",exec:tr,source:r[0].self,event:t,id:n?.id,delay:n?.delay}}case ev:{let[,t,n,i]=r;return{type:"@xstate.sendTo",kind:"builtin",exec:tn,source:r[0].self,target:t,event:n,id:i?.id,delay:i?.delay}}case eb:{let[,t]=r;return{type:"@xstate.cancel",kind:"builtin",exec:ti,source:r[0].self,...t}}case ex:{let[,t]=r;return{type:"@xstate.stop",kind:"builtin",exec:te,source:r[0].self,actor:t,id:t.id}}default:return}}(t.action,c):void 0,d="object"==typeof t&&null!==t&&!l,u={kind:o?"builtin":d?"emit":"action",type:"object"==typeof t?"action"in t&&"function"==typeof t.action?t.action.name??"(anonymous)":t.type:t.name||"(anonymous)",params:o?void 0:r,args:"object"==typeof t&&"action"in t?c:[],...o?{}:d?{source:n.self,event:t}:{action:l?.action??(i?t:void 0)},...!o?{exec:d?e4:e2}:{},...o};a=function(t,r,n){if(!tI(r))return t;if("@xstate.cancel"===r.type){let n=q(r);return t.timers?.some(t=>V(t,n))?{...t,timers:t.timers.filter(t=>!V(t,n))}:t}if("@xstate.raise"!==r.type&&"@xstate.sendTo"!==r.type||void 0===r.delay)return t;let i=t._nextTimerId??0;if(void 0===r.id&&!H(r.event)){r.seq=i++;let t=r.args;t[t.length-1]={...t[t.length-1],seq:r.seq}}let a=t._nextTimerOccurrence??0;r.occurrence=a;let s="@xstate.raise"===r.type||r.target===n.self?"self":r.target,o={occurrence:a,...void 0!==r.id&&{id:r.id},...void 0!==r.seq&&{seq:r.seq},delay:r.delay,type:r.type,event:r.event,target:s},l=U(o),c=t.timers??[],d=c.findIndex(t=>V(t,l));return{...t,timers:-1===d?[...c,o]:c.map((t,r)=>r===d?o:t),_nextTimerId:i,_nextTimerOccurrence:a+1}}(a,u,n),s.push(u);continue}}return[a,s]}function tO(t,r){let n=(t,...n)=>{r(t,...n)};return Object.assign(n,{cancel:tD,emit:tD,log:tD,raise:tD,spawn:tR,sendTo:tD,stop:tD,listen:tR,subscribeTo:tR,...t}),n}let tD=()=>{},tR=()=>({});function tL(t){let r=t.trim(),n=r.match(/^(\d+)ms$/i);if(n)return parseInt(n[1],10);let i=r.match(/^(\d*)(\.?)(\d*)s$/i);if(i&&(i[1]||i[3])){let t=i[1]?parseInt(i[1],10):0,r=!!i[2],n=i[3]?parseInt(i[3].padEnd(3,"0").slice(0,3),10):0;return 1e3*t+(r?n:0)}let a=r.match(/^P(?:(?<weeks>\d+(?:[.,]\d+)?)W)?(?:(?<days>\d+(?:[.,]\d+)?)D)?(?:T(?:(?<hours>\d+(?:[.,]\d+)?)H)?(?:(?<minutes>\d+(?:[.,]\d+)?)M)?(?:(?<seconds>\d+(?:[.,]\d+)?)S)?)?$/i);if(!a?.groups)return;let{weeks:s,days:o,hours:l,minutes:c,seconds:d}=a.groups;if(!s&&!o&&!l&&!c&&!d)return;let u=t=>t?Number(t.replace(",",".")):0;return 7*u(s)*864e5+24*u(o)*36e5+60*u(l)*6e4+60*u(c)*1e3+1e3*u(d)}function tz(t){if(void 0!==t)return"number"==typeof t?t:tL(t)}let tP=Symbol();function tj(t){return t[tP]?t._parent:t.self._parent}function tF(t,r){return r[tP]?(Object.defineProperty(t,"self",{enumerable:!0,get:()=>r.self}),t):Object.assign(t,{self:r.self})}function tB(t,r){if(!r[tP]){let n=r.self;return t.self=n,t.system=r.system,t.parent=n._parent,t}return Object.defineProperties(t,{self:{enumerable:!0,get:()=>r.self},system:{enumerable:!0,get:()=>r.system},parent:{enumerable:!0,get:()=>tj(r)}}),t}function tW(t,r,n=!0){let i=t[tV];if(i){i.snapshot=r;let t=i.materialized??i.identityScope;t&&(t.self._snapshot=r)}else t.self._snapshot=r;return n&&r&&"object"==typeof r&&eV(r,t.self),r}function tH(t){return!!t[tV]||!!t.self.options?._inert}function tU(t,r){tW(t,r,!1);let n=t[tV];tY.set(r,t);let i=()=>(eV(r,t.self,t.system),eU(r));return n&&(n.materialized?n.identityProvider=i:n.identityProvider??=i),eP.delete(r),ej.set(r,i),r}function tq(t,r){return t.sourceRef=void 0,t.sourceChildren={},t.materialized=r,t.materialize=()=>r,r}let tV=Symbol(),tY=new WeakMap;function tG(t){return t[tV].materialize()}let tZ={[tP]:!0,get _parent(){let t=this[tV];return t.parentKnown?t.parent:tG(this).self._parent},get self(){return tG(this).self},get defer(){return tG(this).defer},get id(){return tG(this).id},get logger(){return tG(this).logger},get sessionId(){return tG(this).sessionId},get stopChild(){return tG(this).stopChild},get system(){return tG(this).system},get emit(){return tG(this).emit},get actionExecutor(){return tG(this).actionExecutor}};function tX(t,r,n,i,s,o){c?.();let l=r?.(i),u=s??l?.actor,h=u?.system,f=u&&h?function(t,r,n,i){let s=eR.get(t),o=s?.executionSystem??t,l=s?.rootSystem??t,c=void 0!==i&&ez.get(o)!==i,u=i?.inspection??(a&&(s?s.inspection:a)),h=function(t,r){if(r){let t=new Map(r.children);return r.root?.sessionId&&t.set(r.root.sessionId,r.root),t}return new Map(t.children)}(t,n),f=new Map(n?.keyedActors??eB(t)),p=new WeakMap,g=()=>eR.get(y).executionSystem,m=()=>{let t=eR.get(y).inspection;return void 0!==t&&(a!==t||t.isActive())},y=Object.assign(Object.create(o),{children:h,keyedActors:f,reverseKeyedActors:p,_snapshot:{...n?.snapshot??t._snapshot},_snapshotVersion:n?.sourceVersion??t._snapshotVersion,_register:(t,r)=>(h.set(t,r),eW(y),t),_unregister:t=>{t.sessionId&&h.delete(t.sessionId);let r=p.get(t);void 0!==r&&f.get(r)===t&&f.delete(r),p.delete(t),eW(y)},_set:(t,r)=>{let n=f.get(t);if(n&&n!==r)throw Error(d(45,String(t)));f.set(t,r),p.set(r,t),eW(y)},get:t=>f.get(t),getAll:()=>Object.fromEntries(f),onEmitted:t=>l.onEmitted.call(g(),t),_notifyEmitted:(t,r)=>l._notifyEmitted.call(g(),t,r),_hasInspectionObservers:()=>m()&&(l._hasInspectionObservers?.call(g())??!1),_sendInspectionEvent:t=>{m()&&l._sendInspectionEvent.call(g(),t)}}),v=c?y:o;if(c){var b=y,x=o,w=i;let t=x._timerMap;for(let r of eL)Object.defineProperty(b,r,{configurable:!0,writable:!0,value:"runtime"===r?w.runtime:"_timerMap"===r&&t?{...t}:void 0});ez.set(b,w)}else for(let t of eL)Object.defineProperty(y,t,{configurable:!0,get:()=>g()[t],set:r=>{g()[t]=r}});for(let[t,r]of(eR.set(y,{executionSystem:v,rootSystem:l,inspection:u}),c&&i.inspection.attach(y),f))r&&p.set(r,t);for(let t of Object.values(r)){if(!t)continue;t.sessionId&&h.set(t.sessionId,t);let r=t.registryKey;r&&(f.set(r,t),p.set(t,r))}return y}(h,n,s?void 0:l?.systemState,o):void 0,p=r8(t,{_inert:!0,...u?{id:u.id,_sessionId:u.sessionId}:{},...f?{_systemRef:{current:f}}:{}});u?._parent&&(p._parent=u._parent,p._address=void 0);let g=Object.create(p._actorScope,{defer:{value:()=>{}},stopChild:{value:t=>t._stop()},actionExecutor:{value:()=>{}},_snapshot:{enumerable:!0,configurable:!0,get:()=>p._snapshot,set:t=>{p._snapshot=t}}});return i&&(g._snapshot=i),g}function tK(t,r,n,i){var o;let l,c,d=i??(r&&"object"==typeof r?tY.get(r):void 0),u=d?d[tV]:void 0,h=r&&"object"==typeof r?eP.get(r):void 0,f=u?.identityProvider??(r&&"object"==typeof r?(l=eP.get(r))?()=>l:ej.get(r):void 0),p={snapshot:r,sourceRef:f,sourceChildren:rz(r)?r.children:{},identityProvider:u?.identityProvider??f,parent:n?._parent??u?.parent??h?.actor._parent,owner:i?u?.owner:(c=s,s=void 0,c),parentKnown:!!n||!!u?.parentKnown||!!h||!r};if(p.materialize=()=>{let r=tX(t,p.sourceRef,p.sourceChildren,p.snapshot,n,p.owner);return tq(p,r)},!p.identityProvider&&!r){let r,i,s,l,c,d,u=(o=p.owner,s={},l={},c=t=>{l.snapshot=t&&"object"==typeof t?new WeakRef(t):void 0},d=()=>(l.scope||(l.scope=tX(t,void 0,{},void 0,n,o),Object.defineProperty(Object.getPrototypeOf(l.scope).self,"_snapshot",{configurable:!0,enumerable:!0,...a?.isActive()?{writable:!0,value:l.snapshot?.deref()}:{get:()=>l.snapshot?.deref(),set:c}})),l.scope),{setSnapshot:c,getScope:d,peekScope:()=>l.scope,getRef:t=>{if(l.snapshot?.deref()||void 0===t||c(t),i)return i;let r=d();return eV(s,r.self,r.system),i=eU(s)}});Object.defineProperty(p,"snapshot",{configurable:!0,get:()=>r,set:t=>{r=t,u.setSnapshot(t)}}),Object.defineProperty(p,"identityScope",{configurable:!0,get:()=>u.peekScope()}),p.materialize=()=>{let t=u.getScope();return Object.defineProperty(Object.getPrototypeOf(t).self,"_snapshot",{configurable:!0,enumerable:!0,writable:!0,value:p.snapshot}),tq(p,t)},p.identityProvider=u.getRef}let g=Object.create(tZ);return g[tV]=p,g}function tJ(t,r){return t._stateInputs?.[r]}function tQ(t){return"atomic"===t.type||"final"===t.type||"choice"===t.type}function t0(t){return Object.values(t.states).filter(t=>"history"!==t.type)}function t1(t,r){let n=[];if(r===t)return n;let i=t.parent;for(;i&&i!==r;)n.push(i),i=i.parent;return n}function t2(t){let r=new Set(t),n=new Set;for(let t of r)t.parent&&n.add(t.parent);for(let t of r){if("compound"===t.type&&!n.has(t)){for(let n of ro(t))r.add(n);continue}if("parallel"===t.type){for(let n of t0(t))if(!r.has(n))for(let t of ro(n))r.add(t)}}for(let t of r){let n=t.parent;for(;n&&!r.has(n);)r.add(n),n=n.parent}return r}function t4(t,r){let n=t2(r),i=new Map;for(let t of n)i.has(t)||i.set(t,[]),t.parent&&(i.has(t.parent)||i.set(t.parent,[]),i.get(t.parent).push(t));let a=t=>{let r=i.get(t);if(!r)return{};if("compound"===t.type){let t=r[0];if(!t)return{};if(tQ(t))return t.key}let n={};for(let t of r)n[t.key]=a(t);return n};return a(t)}function t3(t,r){return"compound"===r.type?t0(r).some(r=>"final"===r.type&&t.has(r)):"parallel"===r.type?t0(r).every(r=>t3(t,r)):"final"===r.type}let t5=t=>"#"===t[0];function t6(t,r,n){let i=r.children[n];return!i||!("sessionId"in t)||void 0===i.sessionId||i.sessionId===t.sessionId}function t8(t,r){let n=t.transitions.get(r.type)??[],i=[...t.transitions.keys()].filter(t=>t!==r.type&&ep(r.type,t)).sort((t,r)=>r.length-t.length).flatMap(r=>t.transitions.get(r));return n.length?[...n,...i]:i}function t9(t){let r=t.config.after,n=t.config.timeout,i=t.config.onTimeout,a=t.invoke.filter(t=>void 0!==t.timeout);if(!r&&void 0===n&&0===a.length)return[];let s=[];if(r)for(let n of Object.keys(r)){let i=Number.isNaN(+n)?n:+n;s.push({event:{type:"xstate.after",delay:i,stateId:t.id},delay:i,transitions:r[n],fromDelaysMap:!0,name:`after.${n}`})}for(let r of(void 0!==n&&i&&s.push({event:{type:"xstate.timeout.state",stateId:t.id},delay:n,transitions:i,fromDelaysMap:!0,name:"onTimeout"}),a))s.push({event:K(r.id),resolveEvent:({children:t})=>K(r.id,t[r.id]?.sessionId),eventMatcher:(t,n)=>t6(t,n,r.id),delay:r.timeout,transitions:r.onTimeout,fromDelaysMap:!1,name:"invoke.onTimeout"});let o=[];for(let{event:r,resolveEvent:n,eventMatcher:i,delay:a,transitions:l,fromDelaysMap:c,name:u}of s){!function(t,r,n,i){let a=t.entry;t.entry=(t,r)=>{let s="function"==typeof a?a(t,r):void 0,o=s?.context!==void 0?ta(t.context,s.context):t.context;return r.raise(n(t),{delay:i({context:o,event:t.event,delays:t.delays,input:t.input})}),s};let s=t.exit;t.exit=(t,n)=>(n.cancel({event:H(r)}),"function"==typeof s?s(t,n):void 0)}(t,r,n??(()=>r),r=>(function(t,r,n){if("function"==typeof t)return t(n);let i=function(t,r){if("string"!=typeof t)return t;let n=r[t];if(void 0!==n)return n;let i=tL(t);if(void 0===i)throw Error(d(9,t));return i}(t,r);return"function"==typeof i?i(n):i})(a,c?r.delays:{},{context:r.context,event:r.event,stateNode:t,input:r.input}));let{type:s,...h}=r;for(let r of ed(l,u,t.id))o.push({...r,matches:{...r.matches,...Object.fromEntries(Object.entries(h).filter(([,t])=>void 0!==t))},event:s,delay:a,_eventMatcher:i})}return o.map(r=>({...t7(t,r.event,r),delay:r.delay}))}function t7(t,r,n){let i=function(t){let{cond:r,actions:n,guard:i}=t;return void 0!==r?'"cond"':void 0!==n?'"actions"':void 0!==i&&"function"!=typeof i?'an object-form "guard"':void 0}(n);if(i)throw Error(d(10,r||"always",t.id,i));let a=eu(n.target),s=n.reenter??!1,o=ri(t,a);rr(t,o);let l={...n,target:o,source:t,reenter:s,eventType:r,toJSON:()=>re(l)};return l}function re(t){let{definition:r,...n}=t;return{...n,source:`#${t.source.id}`,target:t.target?.map(t=>`#${t.id}`)}}function rt(t,r){for(let n=t.parent;n;n=n.parent)if(n===r)return!0;return!1}function rr(t,r){if(r&&!(r.length<2))for(let n=0;n<r.length;n++)for(let i=n+1;i<r.length;i++){let a=r[n],s=r[i],o=function(t,r){let n=new Set;for(let r=t;r;r=r.parent)n.add(r);for(let t=r;t;t=t.parent)if(n.has(t))return t}(a,s);if(a===s||rt(a,s)||rt(s,a)||o?.type!=="parallel")throw Error(d(11,t.id))}}function rn(t){let r=[],n=i=>{Object.values(i).forEach(i=>{if(i.config.route&&i.config.id){let a=i.config.id,s=i.config.route,o=({event:t})=>t.to===`#${a}`;if("function"==typeof s){r.push(t7(t,"xstate.route",{guard:o,to:t=>{let r=s(t);if(r)return{...!0===r?{}:r,target:`#${a}`}}})),i.states&&n(i.states);return}let{guard:l,...c}=s,d={...c,guard:o,target:`#${a}`};r.push(t7(t,"xstate.route",d))}i.states&&n(i.states)})};n(t.states),r.length>0&&t.transitions.set("xstate.route",r)}function ri(t,r){if(void 0!==r)return r.map(r=>{if("string"!=typeof r)return r;if(t5(r))return t.machine.getStateNodeById(r);let n="."===r[0];if(n&&!t.parent)return rc(t,r.slice(1));let i=n?t.key+r:r;if(t.parent)try{return rc(t.parent,i)}catch(r){throw Error(d(12,t.id,r.message))}throw Error(d(13,r))})}function ra(t){let r=eu(t.config.target);if(!r)return"parallel"===t.parent.type?{target:[t.parent],source:t,reenter:!1,eventType:""}:t.parent.initial;let n=r.map(r=>"string"==typeof r?rc(t.parent,r):r);return rr(t,n),{target:n,source:t,reenter:!1,eventType:"",to:t.config._historyDefaultTransition}}function rs(t){return"history"===t.type}function ro(t){let r=new Set;for(let n of(!function t(n){if(!r.has(n)){if(r.add(n),"compound"===n.type)for(let r of n.initial.target??[])t(r);else if("parallel"===n.type)for(let r of t0(n))t(r)}}(t),r))for(let i of t1(n,t))r.add(i);return r}function rl(t,r){let n=t.states?.[r];if(!n)throw Error(d(14,r,t.id));return n}function rc(t,r){if("string"==typeof r&&t5(r))return t.machine.getStateNodeById(r);let n=en(r).slice(),i=t;for(;n.length;){let t=n.shift();if(!t.length)break;i=rl(i,t)}return i}function rd(t,r){if("string"==typeof r){let n=t.states[r];if(!n)throw Error(d(14,r,t.id));return[t,n]}let n=Object.keys(r),i=Array(n.length),a=[t.machine.root,t];for(let r=0;r<n.length;r++){let s=rl(t,n[r]);i[r]=s,a.push(s)}for(let t=0;t<n.length;t++)a.push(...rd(i[t],r[n[t]]));return a}function ru(t,r,n,i,a){let s,o=[];function l(t){for(let l=t;l&&!s?.has(l);l=l.parent){s?.add(l);let t=l.next(r,n,i,a);if(t?.length){o.push(...t);break}}}return!function t(r,n){if("string"==typeof n)return void l(rl(r,n));let i=Object.keys(n);if(0===i.length)return void l(r);for(let a of(i.length>1&&(s??=new Set,i.sort((t,n)=>rl(r,t).order-rl(r,n).order)),i))t(rl(r,a),n[a])}(t,r.value),o}function rh(t,r){let n=t;for(;n.parent&&n.parent!==r;)n=n.parent;return n.parent===r}function rf(t,r){for(let n of t)if(rh(n,r))return!0;return!1}function rp(t,r,n,i,a){return rg(t,new Set(r.nodes),r,rm(r,n,i,!1,a))}function rg(t,r,n,i){let a=new Set,s=new Map,o=t=>{let a=s.get(t);return a||(a=rx([t],r,n,i),s.set(t,a)),a};for(let r of t){let t=!1,n=new Set;for(let i of a)if(function(t,r){let n=t instanceof Set?t.size:Array.isArray(t)?t.length:void 0,i=r instanceof Set?r.size:Array.isArray(r)?r.length:void 0;void 0!==n&&void 0!==i&&i<n&&([t,r]=[r,t]);let a=t instanceof Set?t:new Set(t);for(let t of r)if(a.has(t))return!0;return!1}(o(r),o(i)))if(rh(r.source,i.source))n.add(i);else{t=!0;break}if(!t){for(let t of n)a.delete(t);a.add(r)}}return Array.from(a)}function rm(t,r,n,i,a){let s;return(o,l)=>{if(!o.to&&!l)return{targets:o.target,context:void 0,reenter:o.reenter,actions:void 0,internalEvents:void 0,input:void 0};let c=s?.get(o);return c||(c=rk(o,t,r,n,{resolveActions:i,selectionResult:a?.get(o)}),(s??=new Map).set(o,c)),c}}function ry(t,r,n){let{targets:i}=n(t);if(!i)return[];let a=new Set;for(let t of i)if(rs(t))if(r[t.id])for(let n of r[t.id])a.add(n);else for(let i of ry(ra(t),r,n))a.add(i);else a.add(t);return[...a]}function rv(t,r){let n=t;for(;"parallel"===n.type;){let t=t0(n).find(t=>r.every(r=>r===t||rh(r,t)));if(!t)break;n=t}return n}function rb(t,r,n){let i=ry(t,r.historyValue,n),{targets:a,reenter:s}=n(t);if(t._transitionDomain){if("internal"===t._transitionDomain&&"compound"===t.source.type&&i.every(r=>rh(r,t.source)))return t.source;let[r,...n]=i.concat(t.source);for(let t of t1(r,void 0))if("compound"===t.type&&n.every(r=>rh(r,t)))return t;return}if(!(a?.some(rs)&&i.some(r=>r===t.source))&&i.every(r=>r===t.source||rh(r,t.source)))return s?t.source:rv(t.source,i);let o=i.concat(t.source),[l,...c]=o;for(let t of t1(l,void 0))if(c.every(r=>rh(r,t))){if("parallel"===t.type&&rv(t,o)===t)return t1(t,void 0).find(t=>"compound"===t.type);return s?t:rv(t,i)}if(!s)return rv(t.source.machine.root,i)}function rx(t,r,n,i){let a=new Set;for(let s of t){let{targets:t,reenter:o}=i(s);if(t?.length){let t=rb(s,n,i);for(let n of(o&&s.source===t&&a.add(t),r))rh(n,t)&&a.add(n)}}return[...a]}function rw(t,r,n,i,a){t.machine._microstepHooks?.begin(n.self);let s=[...ro(t)],o=new Set,l=t=>{if("compound"===t.type)for(let r of(o.add(t),t.initial.target??[]))l(r);else if("parallel"===t.type)for(let r of t0(t))l(r)};return l(t),r$([{target:s.filter(t=>!s.some(r=>r!==t&&rh(r,t))),source:t,reenter:!0,eventType:null,toJSON:null,_statesForDefaultEntry:[...o]}],r,n,i,!0,a)}function r$(t,r,n,i,a,s,o){let l=[],c=r.machine._microstepHooks?.drain(n.self);if(c?.length&&s.push(...c),!t.length)return[r,l];{let c=new Set(r.nodes),u=r.historyValue,h=r.context,f=1===t.length?t:rg(t,c,r,rm(r,i,n,!1,o)),p=rm(r,i,n,!0,o),g=f.some(t=>{let{targets:r,reenter:n}=p(t);return!!r?.length||!!n}),m=(t,a,s,o,l,c)=>{let d,u=[],h=[],f=tk(n,u,h,{registeredActors:r.machine.sources.actors,actorSubscriptions:!0}),p=n[tP]?tB({context:a,event:i,output:el(i),children:s,actions:r.machine.sources.actions,actors:r.machine.sources.actors,guards:r.machine.sources.guards,delays:r.machine.sources.delays,input:o,stateNode:c},n):{context:a,event:i,output:el(i),parent:n.self._parent,self:n.self,children:s,system:n.system,actions:r.machine.sources.actions,actors:r.machine.sources.actors,guards:r.machine.sources.guards,delays:r.machine.sources.delays,input:o,stateNode:c};try{let r=t(p,f);return rS(r,i,c.id,l),r?.context!==void 0&&(d=ta(a,r.context)),[u,d,h,r?.children]}catch(t){throw tc(n),t}finally{tM.get(f)?.()}},y=r,v=(t,r)=>{let i=[],a=tk(n,i,[]);for(let n of t.invoke){let t=r[n.id];t&&a.stop(t)}return i};!a&&g&&(()=>{let t,a=rx(f,c,r,p);a.sort((t,r)=>r.order-t.order);let o=[...c];for(let r of a)for(let n of Object.values(r.states)){if("history"!==n.type)continue;let i="deep"===n.history?t=>tQ(t)&&rh(t,r):t=>t.parent===r;(t??={...u})[n.id]=o.filter(i)}for(let t of a){let a=tJ(r,t.id),[o,d,u,h]=t.exit?m(t.exit,y.context,y.children,a,"exit",t):[[],void 0,void 0,void 0];u?.length&&s.push(...u),(d||h)&&(y=rV(y,{...d?{context:d}:{},...h?{children:h}:{}}));let[f,p]=tN(y,i,n,o);y=f,l.push(...p);let g=v(t,y.children);if(g.length){let[t,r]=tN(y,i,n,g);y=t,l.push(...r)}c.delete(t)}u=t||u})();let b=y.context,x=[],w=[],$=[];for(let t of f){let r=p(t,!0);if(t.to){let n={...t,target:r.targets,definition:t};n.toJSON=()=>re(n),$.push(n)}else $.push(t);void 0!==r.context&&(b=ta(b,r.context)),r.actions&&x.push(...r.actions),r.internalEvents&&w.push(...r.internalEvents)}w.length&&s.push(...w);let[k,M]=tN(y,i,n,x);y=k,l.push(...M),b&&b!==r.context&&(y=rV(y,{context:b}));let _=y.machine._microstepHooks?.transitionContent?.(f,[...c]);if(_){let t=f[0].source,[r,a,o,c]=m(_,y.context,y.children,tJ(y,t.id),"transition",t);o?.length&&s.push(...o),(a||c)&&(y=rV(y,{...a?{context:a}:{},...c?{children:c}:{}}));let[d,u]=tN(y,i,n,r);y=d,l.push(...u)}(a||g)&&(()=>{let t=t=>{let r,a=y.machine.root;if(void 0!==t.output&&t.parent){let o=s.find(t=>"xstate.done.state"===t.type&&t.stateId===a.id);r=o&&t.parent===a?o.output:eo(t.output,y.context,i,n.self,w[t.id])}else if("parallel"===t.type){let n=s.find(r=>"xstate.done.state"===r.type&&r.stateId===t.id);r=n?.output}return void 0===a.output?t.parent===a?r:void 0:eo(a.output,y.context,J(t.id,r),n.self)},o=new Set,h=new Set,g=new Map,v=(t,r)=>{for(let n of t)if((!r||rh(n,r))&&o.add(n),"parallel"===n.type)for(let t of t0(n))rf(o,t)||(o.add(t),b(t))},b=t=>{if(rs(t)){if(u[t.id]){let r=u[t.id];for(let t of r)o.add(t),b(t);for(let n of r)v(t1(n,t.parent),void 0)}else{let r=ra(t),n=t.parent;if(r===n.initial)h.add(n);else{let t=g.get(n)??[];t.push(r),g.set(n,t)}let{targets:i}=p(r);for(let t of i??[])o.add(t),b(t);for(let r of i??[])v(t1(r,t.parent),void 0)}return}if("compound"===t.type){let r=p(t.initial).targets??[];for(let t of r)rs(t)||o.add(t);for(let n of(h.add(t),r))b(n);for(let n of r)v(t1(n,t),void 0);return}if("parallel"===t.type)for(let r of t0(t))rf(o,r)||(o.add(r),h.add(r),b(r))},x=new Map;for(let t of f){let n=rb(t,r,p),{targets:i,reenter:a}=p(t),s=new Set;for(let r of(x.set(t,s),i??[]))rs(r)||t.source===r&&t.source===n&&!a||r===n&&!r.parent&&c.has(r)||(s.add(r),o.add(r),h.add(r)),b(r);for(let r of ry(t,u,p)){let i=t1(r,n);n?.type==="parallel"&&i.push(n),v(i,!t.source.parent&&a?void 0:n)}i?.length&&a&&n===t.source&&o.add(t.source)}if(a)for(let t of f[0]._statesForDefaultEntry??[r.machine.root])h.add(t);let w={},$=!1,k=new Set([...c].map(t=>t.id));for(let[t,n]of Object.entries(r._stateInputs??{}))k.has(t)?w[t]=n:$=!0;for(let t of f){let{targets:r,input:n}=p(t,!0);if(n&&r)for(let i of r.filter(r=>x.get(t)?.has(r)))w[i.id]=n,$=!0}let M=new Set,_=r.machine.root,A=(h.has(_)||g.has(_))&&!o.has(_);for(let a of[...o,...A?[_]:[]].sort((t,r)=>t.order-r.order)){let u=o.has(a);c.add(a);let f=[],p=y.children,v=[],b=w[a.id];try{for(let t of u&&"final"!==a.type?a.invoke:[]){let a=t.logic;"function"==typeof a&&(a=a({actors:r.machine.sources.actors,context:y.context,event:i,self:n.self}));let s="string"==typeof a?r.machine.sources.actors[a]:a;if(!s)throw Error(d(15,"string"==typeof a?a:"inline"));ty(n,t.id);let o=tl(n,s,{...t,src:"string"==typeof a?a:void 0,input:void 0,_deferInitialization:!0,parent:n.self,syncSnapshot:!!t.onSnapshot});o._invoked=!0,v.push({actor:o,input:t.input}),f.push({action:em,args:[o]}),t.id&&(p={...p,[t.id]:o})}v.length&&(y=rV(y,{children:p}));let t=y.context,o=!1;if(u&&a.entry){let[r,n,i,l]=m(a.entry,t,p,b,"entry",a);f.push(...r),i?.length&&s.push(...i),n&&(t=n,o=!0),l&&(y=rV(y,{children:l}))}for(let{actor:r,input:a}of(o&&(y=rV(y,{context:t})),v))n.system.initializeActorRef(r,"function"==typeof a?a({self:n.self,context:y.context,event:i,input:b,output:el(i)}):a)}catch(t){throw tc(n),t}let x=g.get(a),k=h.has(a)?[a.initial,...x??[]]:x;if(k)for(let t of k){let{actions:r,context:a,input:o,internalEvents:l}=rk(t,y,i,n);if(r&&f.push(...r),l?.length&&s.push(...l),void 0!==a&&(y=rV(y,{context:ta(y.context,a)})),o&&t.target)for(let r of t.target)w[r.id]=o,$=!0}let[_,A]=tN(y,i,n,f);if(y=_,f.length=0,l.push(...A),"final"!==a.type)continue;let E=a.parent,S=E?.type==="parallel"?E:E?.parent,C=S||a;for(E?.type==="compound"&&s.push(J(E.id,void 0!==a.output?eo(a.output,y.context,i,n.self,b):void 0));S?.type==="parallel"&&!M.has(S)&&t3(c,S);){M.add(S);let t={};for(let r of t0(S)){if("final"===r.type){t[r.key]=void 0!==r.output?eo(r.output,y.context,i,n.self,w[r.id]):void 0;continue}if("parallel"===r.type){let n=s.find(t=>"xstate.done.state"===t.type&&t.stateId===r.id);t[r.key]=n?.output;continue}let a=t0(r).find(t=>"final"===t.type&&c.has(t));t[r.key]=a?.output!==void 0?eo(a.output,y.context,i,n.self,w[a.id]):void 0}s.push(J(S.id,t)),C=S,S=S.parent}S||(y=rV(y,{status:"done",output:t(C)}))}$&&(y=rV(y,{_stateInputs:w}))})();let A=[...c];if("done"===y.status){let t=[];A.sort((t,r)=>r.order-t.order).forEach(r=>{if(r.exit){let n=tJ(y,r.id),[i,a,o,l]=m(r.exit,y.context,y.children,n,"exit",r);(a||l)&&(y=rV(y,{...a?{context:a}:{},...l?{children:l}:{}})),t.push(...i),o?.length&&s.push(...o)}});let[r,a]=tN(y,i,n,t);y=r,l.push(...a);let[o,c]=rT(y,i,n);y=o,l.push(...c);let[d,u]=rI(y,i,n);y=d,l.push(...u)}return u===r.historyValue&&r.nodes.length===c.size&&r.nodes.every(t=>c.has(t))?y.context!==h?[y===r?rV(y):y,l,$]:[y,l,$]:[rV(y,{_nodes:A,historyValue:u}),l,$]}}function rk(t,r,n,i,a){let s,o=()=>s??=i[tP]?tB({context:r.context,event:n,output:el(n),value:r.value,children:r.children,actions:r.machine.sources.actions,actors:r.machine.sources.actors,guards:r.machine.sources.guards,delays:r.machine.sources.delays,reject:G,input:tJ(r,t.source.id)},i):{context:r.context,event:n,output:el(n),value:r.value,children:r.children,system:i.system,parent:i.self._parent,self:i.self,actions:r.machine.sources.actions,actors:r.machine.sources.actors,guards:r.machine.sources.guards,delays:r.machine.sources.delays,reject:G,input:tJ(r,t.source.id)};if(t.to){let s,l=[],c=[],d=!1;if(a?.selectionResult?.reusable&&(!1===a.resolveActions||0===a.selectionResult.operations.length))s=a.selectionResult.result;else{let u=tk(i,l,c,{registeredActors:r.machine.sources.actors,actorSubscriptions:!0,createActors:a?.resolveActions??!0,onRefProducingCall:()=>{d=!0}}),h=a?.resolveActions===!1?eO(tj(i),"suppress"):void 0;try{if(a?.selectionResult?.reusable)for(let t of(s=a.selectionResult.result,a.selectionResult.operations))t(u);else s=t.to(o(),u),rS(s,n,t.source.id)}finally{h?.close(),tM.get(u)?.()}}if(Z(s)){if(X(s,r.machine.schemas?.rejections),l.length||c.length||d)throw Error("A rejecting transition cannot enqueue effects. Check rejection conditions before calling enq.");return{targets:void 0,context:void 0,actions:void 0,internalEvents:void 0,input:void 0}}let u=s?.target?ri(t.source,es(s.target)):void 0,h=s?.input??("function"==typeof t.input?t.input({context:r.context,event:n,output:el(n)}):t.input);return{targets:u,context:s?.context,reenter:s?.reenter,actions:l,internalEvents:c,input:h}}let l="function"==typeof t.input?t.input({context:r.context,event:n,output:el(n)}):t.input,c="function"==typeof t.context?t.context(o()):t.context;return{targets:t.target,context:c,reenter:t.reenter,actions:void 0,internalEvents:void 0,input:l}}class rM extends Error{constructor(t,r,n,i){super(d(16,t,r.type,n)),this.actorId=void 0,this.event=void 0,this.maxIterations=void 0,this.states=void 0,this.name="InfiniteTransitionError",this.actorId=t,this.event=r,this.maxIterations=n,this.states=i.slice()}}function r_(t,r,n,i,a=[]){if("active"!==t.status&&!a.length)return{snapshot:t,microsteps:[[t,[],[]]]};let s=t,o=a.slice(),l=!1;function c(t){if("xstate.done.actor"!==t.type&&"xstate.error.actor"!==t.type)return;let{actorId:r,sessionId:i}=t;if(!r)return;let a=s.children[r];if(!a||void 0!==a.sessionId&&a.sessionId!==i)return;let l={...s.children};if(delete l[r],n.system._unregister(a),s=rV(s,{children:l}),o.length){let[,t,r]=o.at(-1);o[o.length-1]=[s,t,r]}else o.push([s,[],[]])}function d(){let r;if(l&&s===t&&(s=rV(t,{}),o.at(-1)?.[0]===t)){let[,t,r]=o.at(-1);o[o.length-1]=[s,t,r]}let i=function(t){let r=[],n=[];for(let i of t){if(!tI(i)||i.type!==x)continue;let{actor:t,logic:a}=i,s=tA(t);a===eS||a===eC?r.push(s):n.push(s)}return[...r,...n]}(o.flatMap(([,t])=>t)),c=("active"===t.status||a.length>0)&&("done"===s.status||"error"===s.status);if(i.length||c){let t=c?[...i,tC(n,s)]:i;if(o.length){let[r,n,i]=o.at(-1);o[o.length-1]=[r,[...n,...t],i]}else o.push([s,t,[]])}return(r=td.get(n))&&(r.actors.length=0),{snapshot:s,microsteps:o}}function u(t,i){if(i=t[2]??i,!tH(n)&&(r.type===b||(n.system._hasInspectionObservers?.()??!0))){let t=n.self._collectedMicrosteps||[];t.push(...i),n.self._collectedMicrosteps=t}o.push([t[0],t[1],i])}if(r.type===w){let[t,i]=rT(s,r,n),[a,o]=rI(t,r,n);return u([s=rV(a,{status:"stopped"}),[...i,...o]],[]),d()}let h=r;if(r.type===k){let t=q(r),a=t?s.timers.findIndex(n=>V(n,t)&&(!("occurrence"in r)||n.occurrence===r.occurrence)):-1;if(-1===a)return d();let o=s.timers[a],l=s.timers.filter((t,r)=>r!==a);if(s=rV(s,{timers:l}),"@xstate.raise"===o.type)i.push(o.event),u([s,[]],[]);else{let t="self"===o.target?n.self:o.target;u([s,[tS(n,t,o.event)]],[])}}if(h.type!==b&&h.type!==k){let r=h,a=r.type.startsWith("xstate.error."),o=new Map,f=s.machine.getTransitionData(s,r,n,o),p=[...o.values()].some(t=>Z(t.result));if(a&&!f.length&&!p)return("xstate.error.actor"!==r.type||t6(r,s,r.actorId))&&(u([s=rV(t,{status:"error",error:r.error}),[]],[]),c(r)),d();l=f.length>0||p;let g=r$(f,t,n,h,!1,i,o);s=g[0],u(g,f),c(r)}if(!i.length&&!1===t.machine._hasEventlessTransitions)return d();let f=r.type!==k,p=t.machine.options?.maxIterations??1/0,g=0,m=[];for(;"active"===s.status;){let t;if(++g>p)throw new rM(n.self?.id,r,p,m);m.push(s.value),m.length>5&&m.shift();let a=[];f&&(t=new Map,a=function(t,r,n,i){t.machine._microstepHooks?.begin(n.self),i??=new Map;let a=new Set;for(let s of t.nodes.filter(tQ).sort((t,r)=>t.order-r.order))e:for(let o=s;o;o=o.parent)if(o.always){for(let s of o.always)if(rN(s,r,t,o,n,i)){let t=i?.get(s);Z(t?.result)||a.add(s);break e}}return rg(Array.from(a),new Set(t.nodes),t,rm(t,r,n,!1,i))}(s,h,n,t));let o=a.length?s:void 0,l=s.machine._microstepHooks?.drain(n.self);if(l?.length&&i.push(...l),!a.length){if(!i.length)break;h=i.shift(),t=new Map,a=s.machine.getTransitionData(s,h,n,t)}let d=r$(a,s,n,h,!1,i,t);f=(s=d[0])!==o,u(d,a),c(h)}return d()}function rA(t,r){let n=t2(rd(t,r));return t4(t,n)}function rE(t,r,n,i,a){return!!t.to&&rC(t.to,r,n,i,a,i.machine.sources,t.source.id).enabled}function rS(t,r,n,i){if(t&&"function"==typeof t.then)throw Promise.resolve(t).catch(()=>{}),Error(d(17,i??"transition",n,r.type))}function rC(t,r,n,i,a,s,o){let l,c=function(t){let r=eO(t),{frame:n}=r,i=[],a=!1,s=t=>{if(a)return t_();i.push(t)},o=()=>{if(a)return t_();throw n.requiresReevaluation=!0,eI};return{frame:n,enqueue:tO({cancel:(...t)=>s(r=>r.cancel(...t)),emit:(...t)=>s(r=>r.emit(...t)),log:(...t)=>s(r=>r.log(...t)),raise:(t,r)=>{if(a)return t_();t$(t),s(n=>n.raise(t,r))},sendTo:(...t)=>s(r=>r.sendTo(...t)),stop:(...t)=>s(r=>r.stop(...t)),spawn:o,listen:o,subscribeTo:o},(...t)=>s(r=>r(...t))),operations:i,close(){a=!0,r.close()}}}(tj(a));try{l=t(tB({context:r,event:n,output:el(n),value:i.value,children:i.children,actions:s.actions,actors:s.actors,guards:s.guards,delays:s.delays,reject:G,input:tJ(i,o)},a),c.enqueue)}catch(t){if(t===eI)return{enabled:!0,result:void 0,reusable:!1};throw t}finally{c.close()}if(rS(l,n,o),Z(l)&&(X(l,i.machine.schemas?.rejections),c.operations.length||c.frame.requiresReevaluation))throw Error("A rejecting transition cannot enqueue effects. Check rejection conditions before calling enq.");return c.frame.requiresReevaluation?{enabled:!0,result:void 0,reusable:!1}:{enabled:void 0!==l||c.operations.length>0,result:l,reusable:!0,operations:c.operations}}function rT(t,r,n){let i;if(!t.children||0===(i=Object.values(t.children).filter(Boolean)).length)return[t,[]];let a=[],s=tk(n,a,[]);for(let t of i)s.stop(t);return tN(t,r,n,a)}function rI(t,r,n){if(!t.timers.length)return[t,[]];let i=[],a=tk(n,i,[]);for(let r of t.timers)a.cancel(U(r));return tN(t,r,n,i)}function rN(t,r,n,i,a,s){if(t.matches&&!Object.entries(t.matches).every(([t,n])=>Object.is(r[t],n))||t._eventMatcher&&!t._eventMatcher(r,n))return!1;if(t.guard){let s=function(t,r){if(!r[tP]){let n=r.self;return Object.assign(t,{self:n,parent:n._parent})}return Object.defineProperties(t,{self:{enumerable:!0,get:()=>r.self},parent:{enumerable:!0,get:()=>tj(r)}}),t}({context:n.context,event:r,output:el(r),children:n.children,actions:i.machine.sources.actions,actors:i.machine.sources.actors,guards:i.machine.sources.guards,delays:i.machine.sources.delays,_snapshot:n},a);if(!t.guard(s))return!1}if(t.to){let o=s?.get(t);if(o)return o.enabled;let l=rC(t.to,n.context,r,n,a,i.machine.sources,t.source.id);return s?.set(t,l),l.enabled}return!0}let rO=Object.freeze({}),rD=Object.freeze([]);function rR(t){return t?.length?t:rD}function rL(t){return t===rO||t&&Object.keys(t).length?t:rO}function rz(t){return!!t&&"object"==typeof t&&"machine"in t&&"value"in t}let rP=function(t){if("string"==typeof t&&t5(t)){let r=this.machine.getStateNodeById(t);return this.nodes.includes(r)}return function t(r,n){let i=ei(r),a=ei(n);return"string"==typeof a?"string"==typeof i&&a===i:"string"==typeof i?i in a:Object.keys(i).every(r=>r in a&&t(i[r],a[r]))}(t,this.value)},rj=function(t){return this.tags.has(t)},rF=function(t){return this.machine?._canTransition(this,t)??!1},rB=function(t){return this.machine?._checkTransition(this,t)??{status:"unhandled"}},rW=function(){let{nodes:t,_stateInputs:r,_nextTimerId:n,_nextTimerOccurrence:i,_nextActorIds:a,tags:s,machine:o,getMeta:l,getInputs:c,toJSON:d,can:u,check:h,hasTag:f,matches:p,...g}=this;return{...g,tags:Array.from(s)}},rH=function(){let t={};for(let r of this.nodes)void 0!==r.meta&&(t[r.id]=r.meta);return t},rU=function(){return this._stateInputs};function rq(t,r,n){let i={status:t.status,output:t.output,error:t.error,machine:r,context:t.context,nodes:t._nodes,value:t.value??t4(r.root,t._nodes),tags:function(t){let r=new Set;for(let n of t)for(let t of n.tags)r.add(t);return r}(t._nodes),children:rL(t.children),timers:rR(t.timers),historyValue:rL(t.historyValue),_stateInputs:rL(t._stateInputs),_nextTimerId:t._nextTimerId??0,_nextTimerOccurrence:t._nextTimerOccurrence??0,_nextActorIds:t._nextActorIds,matches:rP,hasTag:rj,can:rF,check:rB,getMeta:rH,getInputs:rU,toJSON:rW};return n&&eV(i,n),i}function rV(t,r={}){let n={...t,...r};if((r._nodes??t.nodes)===t.nodes){let r={status:n.status,output:n.output,error:n.error,machine:t.machine,context:n.context,nodes:t.nodes,value:t.value,tags:t.tags,children:rL(n.children),timers:rR(n.timers),historyValue:rL(n.historyValue),_stateInputs:rL(n._stateInputs),_nextTimerId:n._nextTimerId??0,_nextTimerOccurrence:n._nextTimerOccurrence??0,_nextActorIds:n._nextActorIds,matches:rP,hasTag:rj,can:rF,check:rB,getMeta:rH,getInputs:rU,toJSON:rW};return eq(t,r),r}let i=rq({...n,value:void 0},t.machine);return eq(t,i),i}function rY(t,r){let{nodes:n,_stateInputs:i,_nextTimerId:a,_nextTimerOccurrence:s,_nextActorIds:o,tags:l,machine:c,children:u,timers:h,context:f,can:p,check:g,hasTag:m,matches:y,getMeta:v,getInputs:b,toJSON:x,...w}=t,$={},k=[],M=eU(t)?.actor,_=M&&"simulate"in M&&!!M.simulate,A=r?.embedChildren!==!1;for(let t in u){let i=u[t],a="string"==typeof i.src?i.src:void 0,s=void 0===a&&!0===i._invoked&&n.some(r=>r.invoke.some(r=>r.id===t));if(void 0===a&&!s&&(!r||!("__unsafeAllowInlineActors"in r)))throw Error(d(41,t));let o=A&&!S(i);if(!o&&void 0===a)throw Error(d(42,t));$[t]={address:i.address,...o?{snapshot:i.getPersistedSnapshot(r)}:{remote:!0,incarnation:S(i)?i.sessionId:void 0},...s?{}:{src:i.src},..._&&o&&!s&&!0===i._invoked?{invoked:!0}:{},registryKey:i.registryKey,syncSnapshot:i._syncSnapshot}}let E=M?.system?._clock?.now?void 0:M?.system?._snapshot?._scheduledTimers;for(let r of h){let n,i=r.event;if("xstate.timeout.actor"===i.type&&(i={...i},delete i.sessionId),"self"===r.target)n="self";else if(C(r.target))n={...r.target};else{let i=Object.entries(u).find(([,t])=>t===r.target)?.[0];if(i)n=i;else if(r.target===eU(t)?.actor._parent)n={type:"parent"};else throw Error(d(43,r.target.id))}let a=E?.[Y(M,U(r))],s=a?a.dueAt-r.delay:W.get(r)??r.scheduledAt;k.push({...void 0!==r.occurrence&&{occurrence:r.occurrence},...void 0!==r.id&&{id:r.id},...void 0!==r.seq&&{seq:r.seq},delay:r.delay,type:r.type,event:i,target:n,...void 0!==s&&{scheduledAt:s}})}let T={...w,context:function t(r,n,i="context",a=[]){let s;for(let o in a.push(r),r){let l=r[o];if(l&&"object"==typeof l)if("sessionId"in l&&"send"in l&&"ref"in l)(s??=Array.isArray(r)?r.slice():{...r})[o]={"@actor":l.address};else{let c=Array.isArray(r)?`${i}[${o}]`:`${i}.${o}`;if(a.includes(l))throw Error(d(44,n(),c));let u=t(l,n,c,a);u!==l&&((s??=Array.isArray(r)?r.slice():{...r})[o]=u)}}return a.pop(),s??r}(f,()=>eU(t)?.actor.id??c.id),children:$,timers:k,historyValue:function(t){let r={};for(let n in t){let i=t[n];Array.isArray(i)&&(r[n]=i.map(t=>({id:t.id})))}return r}(w.historyValue)};return i&&Object.keys(i).length>0&&(T.stateInputs=i),T.nextTimerId=a,s>0&&(T.nextTimerOccurrence=s),o&&Object.keys(o).length>0&&(T.nextActorIds=o),void 0!==c.version&&(T.machine={id:c.id,version:c.version}),T}let rG="function"==typeof Symbol&&Symbol.observable||"@@observable";function rZ(t,r){let n=t.check(r);if(n)throw n}let rX=!1,rK=Object.freeze([]),rJ={"xstate.done.actor":!0,"xstate.error.actor":!0,"xstate.error.execution":!0,"xstate.snapshot.actor":!0,"xstate.done.state":!0,"xstate.after":!0,"xstate.timeout.state":!0,"xstate.timeout.actor":!0,[k]:!0},rQ=((i={})[i.NotStarted=0]="NotStarted",i[i.Running=1]="Running",i[i.Stopped=2]="Stopped",i),r0=Object.freeze({clock:{setTimeout:(t,r)=>setTimeout(t,r),clearTimeout:t=>clearTimeout(t)},logger:console.log.bind(console)});function r1(t,r){try{t?.(r)}catch(t){eD(t)}}function r2(t,r){if(t?.length)for(let n of t)r.actionExecutor(n)}function r4(t,r){return new r6(t,r)}function r3(t,r){t._initialize(r)}function r5(t){t._discard()}class r6{get address(){return this._address??=this._parent?`${this._parent.address}/${eZ(this.id)}`:eZ(this.id)}get trigger(){return this._trigger??=new Proxy({},{get:(t,r)=>t=>{this.send({...t,type:r})}})}get send(){return this._boundSend??=this._sendPublic.bind(this)}constructor(t,r){this.logic=t,this._snapshot=void 0,this.clock=void 0,this.options=void 0,this.id=void 0,this._boundProcess=void 0,this.mailbox=void 0,this._processingMailbox=void 0,this._mailboxStarted=!1,this.observers=void 0,this._errorObserved=!1,this.eventListeners=void 0,this.logger=void 0,this._processingStatus=rQ.NotStarted,this._forceDeferredActions=!1,this._parent=void 0,this._syncSnapshot=void 0,this.ref=void 0,this._actorScope=void 0,this._lastSourceRef=void 0,this._collectedMicrosteps=void 0,this._collectedActions=void 0,this._collectedSent=void 0,this._inTransition=!1,this._initialEffects=void 0,this.registryKey=void 0,this.sessionId=void 0,this._address=void 0,this.system=void 0,this.simulate=void 0,this._trigger=void 0,this._boundSend=void 0,this.src=void 0,this._deferred=void 0,this._restored=!1,this._warnedUnhandledTypes=void 0;const n=r?{...r0,...r}:r0,{clock:i,logger:a,parent:s,syncSnapshot:o,id:l,registryKey:c,inspect:d}=n;this.system=s?s.system:n._systemRef?.current??function(t,r){return new e1(t,r)}(this,{clock:i,logger:a,createActorRef:r4,initializeActorRef:r3,discardActorRef:r5}),s||!n._systemRef||n._systemRef.current||(n._systemRef.current=this.system,n._systemRef.initialize?.()),d&&!s&&this.system.inspect(eh(d)),n.onRejectedEvent&&!s&&this.system.onRejectedEvent(n.onRejectedEvent),this.sessionId=n._sessionId??function(t){return`${t._identity.executionId}:${t._identity.nextSessionId++}`}(this.system),this.id=function(t,r,n){if(void 0!==r){let i=eX(r);return i?eJ(t,eK(n?.parent,i.prefix),i.index+1):n?.parent||eJ(t,eK(void 0,r),1),r}let i=eG(n?.src),a=eK(n?.parent,i),s=t._snapshot._nextActorIds[a]??0;return eJ(t,a,s+1),n?.parent||"x"===i||0!==s?`${i}:${s}`:i}(this.system,l,{parent:s,src:n.src??t}),this.logger=r?.logger??this.system._logger,this.clock=r?.clock??this.system._clock,this._parent=s,this._syncSnapshot=o,this.options=n,this.src=n.src??t,!0===n.simulate&&(this.simulate={childDone:({id:t,output:r})=>this._simulateChildDone(t,r)}),this.ref=this,this._actorScope=this,c&&(this.registryKey=c,this.system._set(c,this)),this._collectedMicrosteps=void 0,n._deferInitialization||this._initialize()}_initialize(t=this.options.input){t!==this.options.input&&(this.options={...this.options,input:t});let r=this.options,n=this.registryKey,i=r._restore;this._restored=void 0!==i;try{if(i)this._setSnapshot(i.restore(this._actorScope));else if(r?._inert);else{this._inTransition=!0;try{let[t,r]=tT(this._actorScope,void 0,this.logic.initialTransition(this.options?.input,this._actorScope));this._setSnapshot(t),this._initialEffects=r.length?r:void 0}finally{this._inTransition=!1}}}catch(t){this._setSnapshot(i?.error?.(t)??{status:"error",output:void 0,error:t}),this._deferred&&(this._deferred.length=0)}n&&"active"!==this._snapshot.status&&this.system._unregister(this),(this.system._hasInspectionObservers?.()??!0)&&this.system._sendInspectionEvent({type:"@xstate.actor",actorRef:this,parentRef:this._parent,id:this.id,src:this.src,snapshot:this._snapshot})}_getLogger(){return this.logger}get self(){return this}get defer(){let t=t=>this._defer(t);return Object.defineProperty(this,"defer",{value:t}),t}get stopChild(){let t=t=>this._stopChild(t);return Object.defineProperty(this,"stopChild",{value:t}),t}get emit(){let t=t=>L(this,t,this.system);return Object.defineProperty(this,"emit",{value:t}),t}get actionExecutor(){let t=t=>this._executeAction(t);return Object.defineProperty(this,"actionExecutor",{value:t}),t}_isRunning(){return this._processingStatus===rQ.Running}_defer(t){(this._deferred??=[]).push(t)}_stopChild(t){if(t._parent!==this)throw Error(d(47,t.id,this.id));t._stop()}_executeAction(t){let r=()=>{(this.system._hasInspectionObservers?.()??!0)&&(this._collectedActions??=[]).push({type:t.type,params:t.params});let r=rX;try{rX=!0;let r=t.exec();r&&"function"==typeof r.then&&Promise.resolve(r).catch(t=>{this._processingStatus!==rQ.Stopped&&this._recoverOrError(t)})}finally{rX=r}};this._processingStatus!==rQ.Running||this._forceDeferredActions?(this._deferred??=[]).push(r):r()}_setSnapshot(t){let r=this._snapshot;this._snapshot=t,eV(t,this,this.system,r)}_setErrorSnapshot(t,r=this._snapshot){this._setSnapshot({...r,status:"error",error:t})}_recoverOrError(t,r,n){return!!this._tryHandleExecutionError(t,r)||(this._setErrorSnapshot(t),this._error(t,n),!1)}_tryHandleExecutionError(t,r=this._snapshot){let n=this.logic.getExecutionErrorEvent?.(r,t);if(!n)return!1;let i=this._inTransition;this._inTransition=!0;try{let[t,i]=tT(this._actorScope,r,this.logic.transition(r,n,this._actorScope));return this._setSnapshot(t),r2(i,this._actorScope),this.update(t,n),!0}catch{return!1}finally{this._inTransition=i}}_next(t){for(let r of this.observers??rK)r1(r.next,t)}update(t,r){this._setSnapshot(t);let n=this._deferred;for(let r=0;r<(n?.length??0);r++){let i=n[r];try{i()}catch(r){if(n.length=0,this._tryHandleExecutionError(r,t))return;this._setErrorSnapshot(r,t),this._error(r);break}}n&&(n.length=0),"active"===this._snapshot.status&&this._next(t),this._inspectTransition(this._snapshot,r)}_inspectTransition(t,r){(this.system._hasInspectionObservers?.()??!0)&&this.system._sendInspectionEvent({type:"@xstate.transition",actorRef:this,event:r,sourceRef:this._lastSourceRef,targetRef:this,snapshot:t,microsteps:this._collectedMicrosteps??rK,actions:this._collectedActions??rK,sent:this._collectedSent??rK,eventType:r.type}),this._collectedMicrosteps=void 0,this._collectedActions=void 0,this._collectedSent=void 0}_flushInitialEffects(){if(!this._initialEffects?.length)return!0;this._forceDeferredActions=!0;try{return r2(this._initialEffects,this._actorScope),this._initialEffects=void 0,!0}catch(t){return this._initialEffects=void 0,this._deferred&&(this._deferred.length=0),this._recoverOrError(t),"active"===this._snapshot.status}finally{this._forceDeferredActions=!1}}subscribe(t,r,n){let i=eh(t,r,n);if(this._processingStatus!==rQ.Stopped)(this.observers??=new Set).add(i);else switch(this._snapshot.status){case"done":r1(i.complete);break;case"error":{let t=this._snapshot.error;i.error?(i.passive||(this._errorObserved=!0),r1(i.error,t)):eD(t)}}return{unsubscribe:()=>{this.observers?.delete(i)}}}on(t,r){let n=this.eventListeners?.get(t);return n||(n=new Set,(this.eventListeners??=new Map).set(t,n)),n.add(r),{unsubscribe:()=>{n.delete(r)}}}select(t,r=Object.is){return{subscribe:(n,i,a)=>{let s=eh(n,i,a),o=t(this.getSnapshot());return this.subscribe({next:n=>{let i=t(n);r(o,i)||(o=i,s.next?.(i))},error:s.error,complete:s.complete})},get:()=>t(this.getSnapshot())}}start(){let t=this._inTransition;this._inTransition=!0;try{return this._start()}finally{this._inTransition=t}}_start(){if(this._processingStatus===rQ.Running)return this;if(this._processingStatus===rQ.Stopped){let t=this._snapshot.status;if("done"===t||"error"===t)return this;throw Error(d(48,this.id))}switch(this._syncSnapshot&&this.subscribe({next:t=>{"active"===t.status&&R(this,this._parent,{type:"xstate.snapshot.actor",actorId:this.id,sessionId:this.sessionId,snapshot:t})},error:()=>{}}),this.system._register(this.sessionId,this),this.registryKey&&this.system._set(this.registryKey,this),this._processingStatus=rQ.Running,this._lastSourceRef=this._parent,this._snapshot.status){case"done":if(this._restored)return this._next(this._snapshot),this._stopProcedure(),this._complete(),this;if(!this._flushInitialEffects())return this;return this.update(this._snapshot,ee(this.options.input)),this;case"error":return this._error(this._snapshot.error),this;case"stopped":return this._stopProcedure(),this._complete(),this}if(this._parent||this.system.start(),!this._flushInitialEffects())return this;if(this.logic.start)try{this.logic.start(this._snapshot,this._actorScope,{restored:this._restored})}catch(t){return this._setErrorSnapshot(t),this._error(t),this}if(this._restored||this._deferred?.length||this.observers?.size||(this.system._hasInspectionObservers?.()??!0))this.update(this._snapshot,ee(this.options.input));else{var t,r;let n,i;t=this._snapshot,r=this.system,n=eP.get(t),i=eH(r),(n?.actor!==this||n.systemState.sourceSystem!==r||n.systemState.sourceVersion+1!==i||r._getRootActor?.()!==this||r._peekChildren?.()||(n.systemState.root=this,n.systemState.sourceVersion=i,0))&&this._setSnapshot(this._snapshot),this._collectedMicrosteps=void 0,this._collectedActions=void 0,this._collectedSent=void 0}if(this._restored){let t=this._snapshot.timers??[],r=!this.system._clock.now,n=Date.now();for(let i of t){let t=r&&void 0!==i.scheduledAt?Math.min(i.delay,Math.max(0,i.scheduledAt+i.delay-n)):i.delay;this.system.scheduleTimer(this,{...U(i),occurrence:i.occurrence},t)}this._restored=!1}return this._mailboxStarted=!0,this.mailbox?.start(),this}_process(t){let r=this._inTransition,n=this._processingMailbox;this._processingMailbox=this.mailbox,this._inTransition=!0;try{this._processEvent(t)}finally{this._inTransition=r,this._processingMailbox=n}}_processEvent({event:t,sourceRef:r,simulatedCompletion:n}){let i,a;this._lastSourceRef=r;let s=this._snapshot;try{i=tT(this._actorScope,s,n?this._prepareSimulatedCompletion(t,n.output):this.logic.transition(s,t,this._actorScope))}catch(t){a={err:t}}if(a){if(this._collectedMicrosteps=void 0,this._collectedActions=void 0,this._collectedSent=void 0,n){n.failure={error:a.err};return}this._recoverOrError(a.err)||this._inspectTransition(this._snapshot,t);return}if(!i)return;let o=this._snapshot;try{let[n,a]=i;n===s&&!a.length&&"machine"in s&&t.type!==w&&(!r||!Object.hasOwn(rJ,t.type))&&this._reportUnhandledEvent(t),o=n,this._setSnapshot(o),r2(a,this._actorScope),this.update(o,t)}catch(r){this._recoverOrError(r,o,s)||this._inspectTransition(this._snapshot,t);return}t.type!==w||n||(this._stopProcedure(),this._complete())}_simulateChildDone(t,r){if(eN(this))return;let n=this.getSnapshot(),i=rz(n)&&n.nodes.some(r=>r.invoke.some(r=>r.id===t))?n.children[t]:void 0;if(!this._isRunning()||!(i instanceof r6)||i._parent!==this||!0!==i._invoked||!i._isRunning()||"active"!==i.getSnapshot().status)throw Error(d(77,t,this.id));if(!i._mailboxStarted||i._inTransition)throw Error(d(78,t));let a={output:r};if(i._enqueue({event:{type:w},sourceRef:void 0,simulatedCompletion:a}),a.failure)throw a.failure.error}_prepareSimulatedCompletion(t,r){let[n,i]=this.logic.transition(this._snapshot,t,this._actorScope);if("done"===n.status||"error"===n.status)return[n,i];let a=this.logic[ek]?.simulationCompletionEvent?.(r);if(a){this._lastSourceRef=this;try{let[t,r]=this.logic.transition(this._snapshot,a,this._actorScope);if("done"!==t.status)throw Error(d(79,this.id));return[t,[...i,...r]]}finally{this._lastSourceRef=void 0}}let s={...n,status:"done",output:r,error:void 0};return this.logic.validator&&rZ(this.logic.validator,{kind:"result",logic:this.logic,snapshot:s,effects:i}),[s,i]}_reportUnhandledEvent(t){r1(()=>this.options.onUnhandledEvent?.(t,this._snapshot))}_emit(t){for(let r of[this.eventListeners?.get(t.type),this.eventListeners?.get("*")])if(r)for(let n of r)r1(n,t)}_terminate(t){if("done"===t.status){var r;this._next(this._snapshot),this._stopProcedure(),this._complete(),this._parent&&R(this,this._parent,(r=this.id,{type:"xstate.done.actor",output:t.output,actorId:r,sessionId:this.sessionId}));return}"error"===t.status&&this._error(t.error)}_discard(){if(this._processingStatus===rQ.NotStarted){for(let t of(this._stop(),Object.values(this._snapshot?.children??{})))t?._parent===this&&this.system.discardActorRef(t);for(let t of this._initialEffects??[])tI(t)&&t.type===x&&t.actor._parent===this&&this.system.discardActorRef(t.actor);this._initialEffects=void 0,this._deferred=void 0}}_stop(){return this._processingStatus===rQ.Stopped||((this.mailbox?.clear(),this._processingStatus===rQ.NotStarted)?this._processingStatus=rQ.Stopped:this._send({type:w}),this.system._unregister(this)),this}stop(){if(this._parent)throw Error(d(49,this.id));return this._stop()}_complete(){for(let t of this.observers??rK)r1(t.complete);this.observers?.clear(),this.eventListeners?.clear()}_reportUnlessObserved(t){setTimeout(()=>{this._errorObserved||eD(t)})}_error(t,r){var n;this._stopProcedure();let i=new Set;for(let t of[this._snapshot,r])for(let r of Object.values(t?.children??{}))r?._parent===this&&"function"==typeof r.getSnapshot&&i.add(r);for(let t of this.system._peekChildren?.()?.values()??[])t._parent===this&&i.add(t);for(let t of i)try{if("active"!==t.getSnapshot().status)continue;let r=this.system.stopActor(t);r&&Promise.resolve(r).catch(eD)}catch(t){eD(t)}if(this.observers?.size){let r=!1,n=!1;for(let i of this.observers){let a=i.error;i.passive||(r||=!a,n||=!!a),r1(a,t)}r||=!n,this.observers.clear(),r&&this._reportUnlessObserved(t)}else this._parent||this._reportUnlessObserved(t);this.eventListeners?.clear(),this._parent&&R(this,this._parent,(n=this.id,{type:"xstate.error.actor",error:t,actorId:n,sessionId:this.sessionId}))}_stopProcedure(){this._processingStatus===rQ.Running&&(this.system.cancelAllTimers(this),this.mailbox?.clear(),this.mailbox=void 0,this._boundProcess=void 0,this._mailboxStarted=!1,this._processingStatus=rQ.Stopped,this.system._unregister(this))}_deferDelivery(t){let r=this._processingMailbox??this.mailbox;r?r.defer(t):t()}_send(t,r){this._processingStatus===rQ.Stopped?this.system.deadLetter(r,this,t,"stopped"):this._enqueue({event:t,sourceRef:r})}_enqueue(t){let r=this.mailbox;!r&&(this._boundProcess??=this._process.bind(this),r=this.mailbox=new B(this._boundProcess),this._mailboxStarted&&r.start()),r.enqueue(t)}_sendPublic(t){this.system._relay(void 0,this,t)}toJSON(){return{"@actor":this.address}}getPersistedSnapshot(t){return this.logic.getPersistedSnapshot(this._snapshot,t)}[rG](){return this}getSnapshot(){return this._snapshot}}function r8(t,...[r]){if(r&&"object"==typeof r){for(let t of Object.keys(r))if(!v.has(t))throw Error(d(8,t))}return new r6(t,r)}},4585(t,r,n){n.d(r,{t:()=>i});function i(){return{"~standard":{version:1,vendor:"xstate.types",validate:t=>({value:t})}}}},3470(t,r,n){n.d(r,{Tg:()=>d});var i=n(172);let a=new WeakMap;function s(t,r,n){let i,s=((i=a.get(t))||(i=new Map,a.set(t,i)),i);if(void 0!==r&&s.has(r))return;let o=n();s.set(r??Symbol(),{cleanup:"function"==typeof o?o:void 0})}let o="xstate.async.resolve",l="xstate.async.reject";class c extends Error{constructor(t){super(`Async logic timed out after ${t}.`),this.name="TimeoutError"}}function d(t){var r;let n,d,u=(r={id:t.id,validator:t.validator,schemas:t.schemas,context:void 0,run:({event:r,input:n,self:a,system:s},d)=>{switch(r.type){case o:{let t="data"in r?r.data:r.output;return{status:"done",output:t,input:void 0,effects:{async:{status:"done",output:t}}}}case l:{let t="data"in r?r.data:r.error;return{status:"error",error:t,input:void 0,effects:{async:{status:"error",error:t}}}}}if(r.type===i.a0)return d.effect((r=s)=>{let d=t=>void r.sendEvent(a,a,t),u=new AbortController,h=t.timeout,f=(0,i.p)(h);if(void 0!==h&&void 0===f)return void d({type:l,data:Error("Unable to resolve async actor timeout.")});let p=void 0===f?void 0:s._clock.setTimeout(()=>{"active"===a.getSnapshot().status&&(u.abort(),d({type:l,data:new c(h)}))},f),g=()=>{void 0!==p&&s._clock.clearTimeout(p)},m=()=>{try{return Promise.resolve(t.run({input:n,system:s,self:a,signal:u.signal},{emit:t=>void(0,i.a1)(a,t,r),step:(t,n)=>r.runStep?Promise.resolve(r.runStep(a,t,n)):(0,i.O)(a,t,n,d)}))}catch(t){return Promise.reject(t)}};return(r.runLogic?Promise.resolve(r.runLogic(a,m)):m()).then(t=>{g(),"active"===a.getSnapshot().status&&d({type:o,data:t})},t=>{g(),"active"===a.getSnapshot().status&&d({type:l,data:t})}),()=>{u.abort(),g()}}),{effects:{async:{status:"active"}}}}},n=(t,n,o)=>{if(r.validator){let a=o.self._lastSourceRef,s=r.validator.check({kind:"event",logic:d,event:n,eventOrigin:a?"actor":"external"});if(s)return[t,[(0,i.U)(o,a,n,"invalidEvent",{issues:s.issues,error:s})]]}let l=((t,n,o)=>{if("active"!==t.status)return[t,[]];if(n.type===i.w)return[{...t,status:"stopped",input:void 0},[(0,i.V)("@xstate.cleanup",()=>(function(t){let r,n=a.get(t);if(n){for(let{cleanup:i}of(a.delete(t),n.values()))try{i?.()}catch(t){r??={error:t}}if(r)throw r.error}})(o.self))]];if(n.type===i.W)return[{...t,effects:{...t.effects,[n.key]:{status:"active"}}},[]];if(n.type===i.Y)return[{...t,effects:{...t.effects,[n.key]:{status:"done",output:n.output}}},[]];if(n.type===i.Z)return[{...t,effects:{...t.effects,[n.key]:{status:"error",error:n.error}}},[]];let l=[],c=Object.create(null),d=r.run({context:t.context,event:n,input:t.input,system:o.system,self:o.self,emit:o.emit},{emit:t=>{l.push((0,i._)(o,t))},sendBack:t=>{let r=o.self._parent;r&&l.push((0,i.$)(o,r,t))},raise:t=>{l.push((0,i.$)(o,o.self,t))},effect:(r,a)=>{if("string"==typeof r){let d;return void((!(d=t.effects&&Object.prototype.hasOwnProperty.call(t.effects,r)?t.effects[r]:void 0)||n.type===i.a0&&"active"===d.status)&&(l.push((0,i.V)("@xstate.effect",(t=o.self.system)=>s(o.self,r,()=>a(t)),{key:r})),c[r]={status:"active"}))}l.push((0,i.V)("@xstate.effect",(t=o.self.system)=>s(o.self,void 0,()=>r(t))))}}),u={...t,...d||{}};return("context"in t||d?.context!==void 0)&&(u.context=d?.context??t.context),(d?.effects||Object.keys(c).length)&&(u.effects={...t.effects,...d?.effects,...c}),(0,i.n)(o,t,[u,l])})(t,n,o);return r.validator&&(0,i.T)(r.validator,{kind:"result",logic:d,snapshot:l[0],effects:l[1]}),l},d={id:r.id,config:r,validator:r.validator,transition:n,start:(t,r,a)=>{if(!a?.restored)return;let[s,o]=n(t,(0,i.S)(t.input),r);for(let n of(Object.assign(t,s),o))r.actionExecutor(n)},initialTransition:(t,a)=>{var s;r.validator&&(0,i.T)(r.validator,{kind:"input",logic:d,input:t});let o=(s=r.context,"function"==typeof s?s({input:t}):s),l={status:"active",output:void 0,error:void 0,input:t};return void 0!==o&&(l.context=o),n({...l},(0,i.S)(t),a)},getInitialSnapshot:(t,r)=>d.initialTransition(r,t)[0],getPersistedSnapshot:t=>t,restoreSnapshot:t=>t});return Object.defineProperty(u,i.s,{value:{kind:"async",timeout:t.timeout,simulationCompletionEvent:t=>({type:o,data:t})}}),u}},4032(t,r,n){let i,a;n.d(r,{wb:()=>k,mj:()=>M});var s=n(3470),o=n(172);let l=new WeakMap,c={};class d{constructor(t,r){if(this.config=t,this.key=void 0,this.id=void 0,this.type=void 0,this.path=void 0,this.states=void 0,this.history=void 0,this.entry=void 0,this.exit=void 0,this.parent=void 0,this.machine=void 0,this.meta=void 0,this.output=void 0,this.order=-1,this.description=void 0,this.schemas=void 0,this.tags=[],this.transitions=void 0,this.always=void 0,this.invoke=void 0,this.on=void 0,this.after=void 0,this.events=void 0,this.ownEvents=void 0,this._candidateCache=void 0,this.parent=r._parent,this.key=r._key,this.machine=r._machine,this.parent&&(0,o.a6)(this.key))throw Error((0,o.x)(57,this.key));this.path=this.parent?this.parent.path.concat(this.key):[];const n=this.config.states?Object.keys(this.config.states)[0]:void 0;if(this.id=this.config.id||(this.machine.id?[this.machine.id,...this.path]:this.path).join("."),this.type=this.config.type||(void 0!==n?"compound":this.config.history?"history":"atomic"),this.description=this.config.description,this.schemas=this.config.schemas,function(t){let r=t.config;if("history"===t.type&&!("string"==typeof r.target&&r.target.trim().length>0||Array.isArray(r.target)&&r.target.length>0&&r.target.every(t=>"string"==typeof t&&t.trim().length>0)))throw Error((0,o.x)(60,t.id));if("choice"===t.type&&"function"!=typeof r.choice)throw Error((0,o.x)(61,t.id))}(this),this.machine.idMap.get(this.id))throw Error((0,o.x)(58,this.id));if(this.order=this.machine.idMap.size,this.machine.idMap.set(this.id,this),this.states=this.config.states?(0,o.a8)(this.config.states,(t,r)=>new d(t,{_parent:this,_key:r,_machine:this.machine})):c,"compound"===this.type&&!this.config.initial)throw Error((0,o.x)(59,this.id));this.history=!0===this.config.history?"shallow":this.config.history||!1,this.entry=this.config.entry,this.exit=this.config.exit,this.meta=this.config.meta,this.output="final"!==this.type&&this.parent?void 0:this.config.output,this.tags=(0,o.t)(t.tags).slice(),this.invoke=(0,o.t)(this.config.invoke).map((t,r)=>{let{src:n,registryKey:i}=t,a=(0,o.a9)(this.id,r),s=t.id??a;return{...t,src:"string"==typeof n?n:void 0,logic:n,id:s,registryKey:i}})}_initialize(){var t;let r;for(let n of(this.after=(0,o.aa)(this),this.transitions=function(t){let r=new Map,n=(t,n)=>{r.set(t,[...r.get(t)??[],...n])};if(t.config.on)for(let n of Object.keys(t.config.on)){if(""===n)throw Error((0,o.x)(63,t.id));let i=t.config.on[n];r.set(n,u(t,n,i,r=>(0,o.ad)(t,n,r)))}if(t.config.onDone){let r="xstate.done.state";n(r,u(t,"onDone",t.config.onDone,n=>(0,o.ad)(t,r,{...n,matches:{...n.matches,stateId:t.id}})))}if(t.config.onError){let n="xstate.error.*";r.set(n,u(t,"onError",t.config.onError,r=>(0,o.ad)(t,n,r)))}let i=(r,n,i)=>(0,o.ad)(t,r,{matches:{actorId:i},_eventMatcher:(t,r)=>(0,o.ag)(t,r,i),to:(t,r)=>(r.cancel(n),{})}),a=(r,n,i)=>{let{target:a,to:s,reenter:l,...c}=n;return(0,o.ad)(t,r,{...c,reenter:l,to:(t,r)=>{if(s){let n=!1,a=s(t,new Proxy(r,{apply:(t,r,i)=>(n=!0,Reflect.apply(t,r,i)),get(t,r,i){let a=Reflect.get(t,r,i);return"function"!=typeof a?a:(...r)=>(n=!0,a.apply(t,r))}}));return(void 0!==a||n)&&r.cancel(i),a}return r.cancel(i),{target:a,reenter:l}}})};for(let r of t.invoke){let s=t=>({...t,matches:{...t.matches,actorId:r.id},_eventMatcher:(t,n)=>(0,o.ag)(t,n,r.id)}),l=void 0!==r.timeout?{event:{type:"xstate.timeout.actor",actorId:r.id}}:void 0;if(r.onDone){let c="xstate.done.actor",d=u(t,"invoke.onDone",r.onDone,r=>{let n=s(r);return l?a(c,n,l):(0,o.ad)(t,c,n)});l&&d.push(i(c,l,r.id)),n(c,d)}else if(l){let t="xstate.done.actor";n(t,[i(t,l,r.id)])}if(r.onError){let i="xstate.error.actor";n(i,u(t,"invoke.onError",r.onError,r=>{let n=s(r);return l?a(i,n,l):(0,o.ad)(t,i,n)}))}if(r.onSnapshot){let i="xstate.snapshot.actor";n(i,u(t,"invoke.onSnapshot",r.onSnapshot,r=>(0,o.ad)(t,i,s(r))))}}for(let n of t.after){let t=r.get(n.eventType);t||(t=[],r.set(n.eventType,t)),t.push(n)}return r}(this),"choice"===this.type?this.always=(t=this,r=t.config.choice,[(0,o.ad)(t,"",{to:n=>(r=>{if(!r||void 0===r.target)throw Error((0,o.x)(62,t.id));return r})(r(n))})]):this.config.always&&(this.always=u(this,"always",this.config.always,t=>(0,o.ad)(this,"",t))),Object.keys(this.states)))this.states[n]._initialize();this._refreshEventMetadata()}_refreshEventMetadata(){let t={},r=[];for(let[n,i]of this.transitions)t[n]=i.slice(),i.some(t=>t.target||t.reenter||t.to)&&r.push(n);this.on=t,this.ownEvents=r;let n=new Set(r);for(let t of Object.values(this.states))for(let r of t.events)n.add(r);this.events=Array.from(n)}get initial(){var t,r;let n;return t="initial",r=()=>(function(t,r){let n="object"==typeof r&&null!==r?r.target:r,i="object"==typeof r&&null!==r?r.input:void 0,a="object"==typeof r&&null!==r?r.to:void 0,s="object"==typeof r&&null!==r?r.meta:void 0,l="object"==typeof r&&null!==r?r.description:void 0,c=Array.isArray(n)?n:n?[n]:[],d=c.map(r=>r.startsWith("#")?t.machine.getStateNodeById(r.slice(1)):t.states[r]);if(d.some(t=>!t))throw Error((0,o.x)(64,c.find((t,r)=>!d[r]),t.id));return{source:t,target:d.length?d:void 0,input:i,to:a,meta:s,description:l}})(this,this.config.initial),(n=l.get(this))?t in n||(n[t]=r()):(n={[t]:r()},l.set(this,n)),n[t]}next(t,r,n,i){if("final"===this.type)return;let a=this._candidateCache?.get(r.type);for(let s of(a||(a=(0,o.ab)(this,r),(this._candidateCache??=new Map).set(r.type,a)),a))if((0,o.ac)(s,r,t,this,n,i))return[s]}}function u(t,r,n,i){let a=(0,o.af)(n,r,t.id),s=Array(a.length);for(let t=0;t<a.length;t++)s[t]=i(a[t]);return s}class h{constructor(t,r,n){if(this.config=t,this.validator=n,this._internalEventType=void 0,this._transitionMetaType=void 0,this._inputType=void 0,this._actionMap=void 0,this._actorMap=void 0,this._stateSchema=void 0,this.version=void 0,this.schemas=void 0,this.sources=void 0,this.options=void 0,this.idMap=new Map,this.root=void 0,this._raw=()=>this,this.id=void 0,this.states=void 0,this.events=void 0,this.internalEventDescriptors=void 0,this._hasEventlessTransitions=void 0,this._microstepHooks=void 0,this._json=void 0,void 0!==t.version&&!t.id)throw Error((0,o.x)(18,t.version));this.id=t.id??"",this.sources={actors:t.actors??{},actions:t.actions??{},delays:t.delays??{},guards:t.guards??{},...r},this.version=this.config.version,this.schemas=this.config.schemas,this.internalEventDescriptors=Object.keys(this.schemas?.internalEvents??{}),this.options={...this.config.options},this.transition=this.transition.bind(this),this.initialTransition=this.initialTransition.bind(this),this.getInitialSnapshot=this.getInitialSnapshot.bind(this),this.getPersistedSnapshot=this.getPersistedSnapshot.bind(this),this.start=this.start.bind(this),this.root=new d(t,{_key:this.id,_machine:this}),this.root._initialize(),(0,o.aj)(this.root),this.root._refreshEventMetadata(),this._hasEventlessTransitions=Array.from(this.idMap.values()).some(t=>!!t.always?.length),this.states=this.root.states,this.events=this.root.events}provide(t){let{actions:r,guards:n,actors:i,delays:a}=this.sources,s=new h(this.config,{actions:{...r,...t.actions},guards:{...n,...t.guards},actors:{...i,...t.actors},delays:{...a,...t.delays}},this.validator);return s._json=this._json,s.internalEventDescriptors=this.internalEventDescriptors,s._microstepHooks=this._microstepHooks,s}resolveState(t){let r=(0,o.ak)(this.root,t.value),n=(0,o.g)((0,o.b)(this.root,r)),i=[...n];return(0,o.f)({_nodes:i,value:r,context:t.context||{},children:{},status:(0,o.al)(n,this.root)?"done":t.status||"active",output:t.output,error:t.error,historyValue:t.historyValue},this)}transition(t,r,n){let i=!n,a=n??(0,o.am)(this,t);if(i&&(0,o.an)(a,t,!1),this.validator){let i=n&&n.self._lastSourceRef,s=this.validator.check({kind:"event",logic:this,event:r,eventOrigin:i?"actor":"external"});if(s)return[t,[(0,o.U)(a,i,r,"invalidEvent",{issues:s.issues,error:s})]]}(0,o.ao)(a);let s=this._transitionFast(t,r,a);if(s){i&&(0,o.an)(a,s,!1);let r=i&&s!==t?(0,o.ap)(a,s):this._attachPureActorRef(s,a);return this.validator&&(0,o.T)(this.validator,{kind:"result",logic:this,snapshot:r,effects:[]}),[r,[]]}let{snapshot:l,microsteps:c}=(0,o.aq)(t,r,a,[]);i&&(0,o.an)(a,l,!1);let d=i?l===t?l:(0,o.ap)(a,l):this._attachPureActorRef(l,a),u=this._collectEffects(c);return this.validator&&(0,o.T)(this.validator,{kind:"result",logic:this,snapshot:d,effects:u}),[d,u]}_collectEffects(t){return t.flatMap(([,t])=>t)}_attachPureActorRef(t,r,n=!1){return(0,o.ar)(r)||n&&r.self._actorScope===r&&void 0===r.self._snapshot||(0,o.as)(t,r.self,r.system),t}_transitionFast(t,r,n){if("active"!==t.status||"string"!=typeof t.value||this.root.always?.length)return;let i=this.root.states[t.value];if(!i||"atomic"!==i.type||i.exit||i.invoke.length||i.always?.length||i.after?.length)return;let a=i.transitions.get(r.type);if(a?.length!==1)return;let s=a[0];if(s.guard||s.actions||s.to||s.reenter||s.input||"function"==typeof s.context||s.target&&1!==s.target.length)return;let l=s.target?.[0]??i,c=l!==i;if(l.parent!==this.root||"atomic"!==l.type||c&&(l.entry||l.invoke.length||l.always?.length||l.after?.length))return;let d=void 0!==s.context?{...t.context,...s.context}:t.context;if(!(0,o.ar)(n)&&(n.system._hasInspectionObservers?.()??!0)){let t=n.self._collectedMicrosteps||[];t.push(s),n.self._collectedMicrosteps=t}let u=t._stateInputs[this.root.id];return(0,o.at)(t,{...d!==t.context?{context:d}:{},...c?{_nodes:[this.root,l],_stateInputs:u?{[this.root.id]:u}:{}}:{}})}microstep(t,r,n){let{microsteps:i}=(0,o.aq)(t,r,n,[]),a=Array(i.length);for(let t=0;t<i.length;t++)a[t]=i[t][0];return a}getTransitionData(t,r,n,i=new Map,a=!1){this._microstepHooks?.begin(n.self);let s=(0,o.au)(this.root,t,r,n,i);return a?s:s.filter(t=>!(0,o.av)(i.get(t)?.result))}isInternalEventType(t){if(t===o.aw)return!0;for(let r of this.internalEventDescriptors)if((0,o.m)(t,r))return!0;return!1}_canTransition(t,r){let{status:n}=this._checkTransition(t,r);return"accepted"===n||"partial"===n}_checkTransition(t,r){if("active"!==t.status)return{status:"unhandled"};let n=function(){if(a)return a;let t=i??=(0,o.j)({transition:t=>[t,[]],initialTransition:()=>[{status:"active",output:void 0,error:void 0},[]],getInitialSnapshot:()=>({status:"active",output:void 0,error:void 0}),getPersistedSnapshot:t=>t});return a={self:t,logger:()=>{},id:"",sessionId:"",defer:()=>{},system:t.system,stopChild:()=>{},emit:()=>{},actionExecutor:()=>{}},o.aK.add(a),a}(),s=new Map,l=(0,o.ax)(this.getTransitionData(t,r,n,s,!0),t,r,n,s),c=[],d=!1;for(let i of l){let a=s.get(i);if((0,o.av)(a?.result)){c.push({source:i.source.id,reasons:a.result.reject});continue}if(void 0!==i.target||a?.reusable&&a.enabled){d=!0;continue}let l=(0,o.ay)(i,t,r,n,{resolveActions:!1,selectionResult:a});(l.targets?.length||l.context||!a?.reusable&&(0,o.az)(i,t.context,r,t,n))&&(d=!0)}let[u,...h]=c;return u?{status:d?"partial":"rejected",rejections:[u,...h]}:{status:d?"accepted":"unhandled"}}getExecutionErrorEvent(t,r){if(t?.status==="active"&&t.nodes?.some(t=>t.config.onError))return(0,o.aA)("execution",r)}_getPreInitialState(t,r){let{context:n}=this.config,i=(0,o.f)({context:"function"!=typeof n&&n?n:{},_nodes:[this.root],children:{},status:"active"},this);if("function"==typeof n){var a;let s={},l=(a=this.sources.actors,(r,n)=>{let i=(0,o.a2)(a,r),l=n?.id??(0,o.a3)(t,i??r).id;n?.id!==void 0&&((0,o.a4)(t,n.id),(0,o.a5)(t,n.id));let c=t.system.createActorRef(r,{id:l,parent:t.self,syncSnapshot:n?.syncSnapshot,input:n?.input,src:i??r,registryKey:n?.registryKey});return s[c.id]=c,c}),c=n((0,o.aB)({spawn:l,input:r.input,actors:this.sources.actors},t)),[d]=(0,o.aC)(i,r,t,[]);if(c&&(d.context=c),Object.keys(s).length>0){d.children={...d.children,...s};let r=(0,o.aD)(t);r&&(d._nextActorIds=(0,o.aE)(d._nextActorIds,r))}return d}return i}getInitialSnapshot(t,r){return this.initialTransition(r,t)[0]}initialTransition(t,r){let n;this.validator&&(0,o.T)(this.validator,{kind:"input",logic:this,input:t});let i=!r,a=r??(0,o.am)(this);(0,o.ao)(a);let s=(0,o.S)(t),l=[],c=(t,r)=>{i&&(0,o.an)(a,t,!1);let n=i?(0,o.ap)(a,t):this._attachPureActorRef(t,a,!0),s=this._collectEffects(r);return this.validator&&"error"!==t.status&&(0,o.T)(this.validator,{kind:"result",logic:this,snapshot:n,effects:s}),[n,s]};try{n=this._getPreInitialState(a,s)}catch(t){return c((0,o.at)((0,o.f)({context:"function"!=typeof this.config.context&&this.config.context?this.config.context:{},_nodes:[this.root],children:{},status:"active"},this),{status:"error",error:t}),[])}let d=Object.values(n.children).filter(Boolean).map(t=>(0,o.aF)(t));try{let[t,r]=(0,o.aG)(this.root,n,a,s,l),{snapshot:i,microsteps:u}=(0,o.aq)(t,s,a,l,[[t,[...d,...r]]]);return c(i,u)}catch(i){if(!this.root.config.onError)throw i;let t=(0,o.aA)("execution",i),r=(0,o.aq)(n,t,a,[],[[n,d]]);return c(r.snapshot,r.microsteps)}}start(t,r){if(!t?.children)return;let n=t.children;for(let t in n){if(!Object.hasOwn(n,t))continue;let i=n[t];i._rehydrated&&i.getSnapshot?.().status==="active"&&(r?r.actionExecutor((0,o.aH)(i)):i.system.startActor(i))}}getStateNodeById(t){let r=(0,o.aI)(t),n=r?t.slice(1):t;if(""===n&&r)throw Error((0,o.x)(19,this.id));let i=this.idMap.get(n);if(i)return i;throw Error((0,o.x)(20,n))}getPersistedSnapshot(t,r){return(0,o.aJ)(t,r)}}function f(t){let r=(0,o.p)(t);return void 0!==r?r:"string"==typeof t?parseFloat(t)||0:t}function p(t){return!!t&&"object"==typeof t&&"string"==typeof t["@expr"]}function g(t){return p(t)||!!t&&"object"==typeof t&&"string"==typeof t["@code"]}function m(t,r){return"number"==typeof r?`${t}[${r}]`:`${t}.${r}`}function y(t){return void 0===t?[]:Array.isArray(t)?t:[t]}function v(t,r){Array.isArray(t)&&t.forEach((n,i)=>{if(void 0===n.when&&i!==t.length-1)throw Error(`Choice fallback branch at ${r}[${i}] must be last.`)})}new WeakMap,new WeakMap,new WeakMap;let b=["reject","target","matches","context","actions","guard","description","reenter","meta","input"],x=["id","key","type","initial","states","on","onError","after","always","choice","route","invoke","entry","exit","meta","description","tags","input","timeout","onTimeout","history","target","output","context"],w=["@exprLang","version","actions","guards","actors","delays","schemas","internalEvents"];function $(t,r,n){for(let i of Object.keys(t))if(!r.includes(i))throw Error(`Unknown key "${i}" at ${n}`)}function k(t,r={}){var n;let i=(n=t=function t(r){return Array.isArray(r)?r.map(t):null===r||"object"!=typeof r||Object.getPrototypeOf(r)!==Object.prototype&&null!==Object.getPrototypeOf(r)?r:Object.fromEntries(Object.entries(r).map(([r,n])=>[r,t(n)]))}(t),{actions:r.actions??{},guards:r.guards??{},actors:r.actors??{},delays:{...function(t){let r={};if(!t)return r;for(let n of Object.keys(t)){let i=t[n];"number"==typeof i?r[n]=i:i&&"object"==typeof i&&"number"==typeof i.duration&&(r[n]=i.duration)}return r}(n.delays),...r.delays??{}},evaluators:r.evaluators??{}}),a=function(t,r){function n(n,i){let a=n["@lang"]??t;if(!a)throw Error(`Missing @exprLang for expression at ${i}`);let s=r.evaluators[a];if(!s)throw Error(`Missing evaluator for @lang '${a}' at ${i}`);return s}function i(t,r,i,a){let s=p(t)?"expr":"code",o=p(t)?t["@expr"]:t["@code"];return n(t,a)({source:o,kind:s,slot:r,scope:i,path:a})}function a(t,r,n,s){if(g(t))return i(t,r,n,s);if(Array.isArray(t))return t.map((t,i)=>a(t,r,n,m(s,i)));if(!t||"object"!=typeof t)return t;let o={};for(let i of Object.keys(t))o[i]=a(t[i],r,n,m(s,i));return o}function s(t,r){return{context:t.context,event:t.event,input:t.input,self:t.self,children:t.children,params:t.params,actions:t.actions,actors:t.actors,guards:t.guards,delays:t.delays,reject:t.reject,...r}}return{evaluateResolvable:i,resolveValue:a,makeScope:s,getDurationConfig:function(t,r){return g(t)?n=>f(a(t,"delay",s(n),r)):t},assertResolvable:function t(r,i){if(g(r))return void n(r,i);if(Array.isArray(r))return void r.forEach((r,n)=>t(r,m(i,n)));if(r&&"object"==typeof r)for(let n of Object.keys(r))t(r[n],m(i,n))}}}(t["@exprLang"],i),{evaluateResolvable:s,resolveValue:l,makeScope:c,getDurationConfig:d}=a;function u(r,n,i){if(r){if(g(r))return t=>!!s(r,n,c(t),i);if("@xstate.not"===r.type){let t=u(r.params?.guard,n,`${i}.params.guard`);return r=>!t?.(r)}return"@xstate.stateIn"===r.type?t=>{let a=l(r.params,n,c(t),`${i}.params`),s=a?.stateId;return"string"==typeof s&&!!t._snapshot?.matches(`#${s.replace(/^#/,"")}`)}:a=>{let s=l(r.params,n,c(a),`${i}.params`),o=t.guards?.[r.type];if(o){let t=u(o.when,"guard",`$.guards.${r.type}.when`);return!!t?.({...a,params:s})}let d=a.guards?.[r.type];if(!d){var h,f;throw Error((h=r.type,f=a.guards??{},`Guard '${h}' is not implemented in ${t.id?`machine '${t.id}'`:"the machine"}. Available guards: ${Object.keys(f).map(t=>`'${t}'`).join(", ")||"(none)"}.`))}return d(a,s)}}}function M(r,n,i,a,o=[]){let d,u=()=>d?{...n,context:{...n.context,...d}}:n;for(let f=0;f<r.length;f++){var h;let p=r[f],m=`${a}[${f}]`;if(g(p)){let t=s(p,"action",c(u(),{params:n.params,enq:i}),m);t&&"object"==typeof t&&"context"in t&&t.context&&Object.assign(d??={},t.context);continue}if(!g(h=p)&&h.type.startsWith("@xstate.")){switch(p.type){case"@xstate.raise":i.raise(l(p.event,"actionParams",c(u(),{params:n.params}),`${m}.event`),{id:p.id,delay:p.delay});break;case"@xstate.cancel":i.cancel(p.id);break;case"@xstate.log":i.log(...p.args);break;case"@xstate.emit":i.emit(l(p.event,"actionParams",c(u(),{params:n.params}),`${m}.event`));break;case"@xstate.assign":Object.assign(d??={},l(p.context,"transitionContext",c(u(),{params:n.params}),`${m}.context`))}continue}let y=l(p.params,"actionParams",c(u(),{params:n.params}),`${m}.params`),v=t.actions?.[p.type];if(!v){i(n.actions[p.type],y);continue}if(o.includes(p.type))throw Error(`Circular action reference: ${o.concat(p.type).join(" -> ")}`);let b=M(Array.isArray(v)?v:[v],{...n,context:{...n.context,...d},params:y},i,`${m}.actions.${p.type}`,o.concat(p.type));b.context&&Object.assign(d??={},b.context)}return{context:d}}function _(t,r){let n=y(t);return(t,i)=>M(n,t,i,r)}function A(t,r){return(Array.isArray(t)?t:[t]).map((n,i)=>{let a=Array.isArray(t)?`${r}[${i}]`:r;if(g(n))return(t,r)=>s(n,"transition",c(t,{enq:r}),a);if(void 0!==n.reject)return{description:n.description,meta:n.meta,matches:n.matches,guard:u(n.guard,"guard",`${a}.guard`),to:t=>(0,o.r)(l(n.reject,"transition",c(t),`${a}.reject`))};let d=n.context?t=>l(n.context,"transitionContext",c(t),`${a}.context`):void 0,h=void 0!==n.input?t=>l(n.input,"input",c(t),`${a}.input`):void 0,f=!!d||!!n.actions?.length;return{matches:n.matches,target:f?void 0:n.target,to:f?(t,r)=>{let i=d?.(t),s=n.actions?.length?M(n.actions,i?{...t,context:{...t.context,...i}}:t,r,`${a}.actions`).context:void 0;return{target:n.target,context:s?{...i,...s}:i,reenter:n.reenter}}:void 0,guard:u(n.guard,"guard",`${a}.guard`),description:n.description,reenter:n.reenter,meta:n.meta,input:h}})}if(t.delays)for(let[r,n]of Object.entries(t.delays))"number"==typeof n?i.delays[r]=n:"string"==typeof n?i.delays[r]=f(n):n&&"object"==typeof n&&(i.delays[r]=t=>f(l(n.duration,"delay",c(t),`$.delays.${r}.duration`)));let E=function(t,r,n){let{assertResolvable:i}=n,a=[];function s(n,o,l=[]){if(!n)return;if(g(n))return void i(n,o);if(i(n.params,`${o}.params`),t.guards?.[n.type]){if(l.includes(n.type))throw Error(`Circular guard reference: ${l.concat(n.type).join(" -> ")}`);s(t.guards[n.type].when,`$.guards.${n.type}.when`,l.concat(n.type));return}if(r.guards[n.type])return;let c=n.params;if("@xstate.not"===n.type){if(!c?.guard)throw Error(`Missing guard at ${o}.params.guard`);s(c.guard,`${o}.params.guard`,l);return}if("@xstate.stateIn"===n.type){if("string"==typeof c?.stateId)a.push({stateId:c.stateId,path:`${o}.params.stateId`});else if(!g(c?.stateId))throw Error(`Missing state ID at ${o}.params.stateId`);return}throw Error(`Missing guard source "${n.type}"`)}function l(n,a,s=[]){if(g(n))return void i(n,a);if(!n||"string"!=typeof n.type)throw Error(`Invalid action at ${a}`);if(i(n.params,`${a}.params`),n.type.startsWith("@xstate."))return void i(n,a);let o=t.actions?.[n.type];if(o){if(s.includes(n.type))throw Error(`Circular action reference: ${s.concat(n.type).join(" -> ")}`);let t=Array.isArray(o)?o:[o];t.forEach((r,i)=>l(r,`${a}.actions.${n.type}${t.length>1?`[${i}]`:""}`,s.concat(n.type)));return}if(!r.actions[n.type])throw Error(`Missing action source "${n.type}"`)}function c(t,r){y(t).forEach((t,n)=>l(t,`${r}[${n}]`))}function d(t,r){(Array.isArray(t)?t:t?[t]:[]).forEach((n,a)=>{let l=Array.isArray(t)?`${r}[${a}]`:r;if(g(n))return void i(n,l);if(!n||"object"!=typeof n)throw Error("string"==typeof n?`Invalid transition at ${l}: use { "target": ${JSON.stringify(n)} } instead of a string`:`Invalid transition at ${l}`);if($(n,b,l),void 0!==n.reject){if((0,o.r)(n.reject),void 0!==n.target||void 0!==n.context||void 0!==n.actions||void 0!==n.input||void 0!==n.reenter)throw Error(`Rejecting transition at ${l} cannot have target, context, actions, input, or reenter.`);i(n.reject,`${l}.reject`)}s(n.guard,`${l}.guard`),c(n.actions,`${l}.actions`),i(n.context,`${l}.context`),i(n.input,`${l}.input`)})}for(let r of["actions","guards","delays"])for(let n of Object.keys(t[r]??{}))(0,o.a)(r,n);if(t.actions)for(let r of Object.keys(t.actions)){let n=Array.isArray(t.actions[r])?t.actions[r]:[t.actions[r]];n.forEach((t,i)=>l(t,`$.actions.${r}${n.length>1?`[${i}]`:""}`,[r]))}if(t.guards)for(let r of Object.keys(t.guards))s(t.guards[r].when,`$.guards.${r}.when`,[r]);if(t.delays)for(let r of Object.keys(t.delays)){let n=t.delays[r];i(n&&"object"==typeof n&&"duration"in n?n.duration:n,`$.delays.${r}`)}return!function n(a,l){if($(a,"$"===l?[...x,...w]:x,l),("history"===a.type||void 0!==a.history)&&!("string"==typeof a.target&&a.target.trim().length>0||Array.isArray(a.target)&&a.target.length>0&&a.target.every(t=>t.trim().length>0)))throw Error(`History state at ${l} must declare a non-empty target.`);if(i(a.context,`${l}.context`),i(a.input,`${l}.input`),i(a.output,`${l}.output`),i(a.timeout,`${l}.timeout`),c(a.entry,`${l}.entry`),c(a.exit,`${l}.exit`),"choice"===a.type){if(!a.choice)throw Error(`Choice state at ${l} must declare choice.`);Array.isArray(a.choice)?(v(a.choice,`${l}.choice`),a.choice.forEach((t,r)=>{s(t.when,`${l}.choice[${r}].when`),i(t.context,`${l}.choice[${r}].context`),i(t.input,`${l}.choice[${r}].input`)})):i(a.choice,`${l}.choice`)}if(g(a.route)&&i(a.route,`${l}.route`),a.invoke&&(Array.isArray(a.invoke)?a.invoke:[a.invoke]).forEach((t,n)=>{let s=`${l}.invoke${Array.isArray(a.invoke)?`[${n}]`:""}`;if(!r.actors[t.src])throw Error(`Missing actor source "${t.src}"`);i(t.input,`${s}.input`),i(t.timeout,`${s}.timeout`),d(t.onDone,`${s}.onDone`),d(t.onError,`${s}.onError`),d(t.onSnapshot,`${s}.onSnapshot`),d(t.onTimeout,`${s}.onTimeout`)}),a.on)for(let t of Object.keys(a.on))d(a.on[t],`${l}.on.${t}`);if(a.after)for(let n of Object.keys(a.after)){if(Number.isNaN(Number(n))&&void 0===(0,o.p)(n)&&!t.delays?.[n]&&!r.delays[n]&&t.delays?.[n]!==0&&(t.delays?.[n]!==void 0||0!==r.delays[n]))throw Error(`Missing delay source "${n}"`);d(a.after[n],`${l}.after.${n}`)}if(d(a.always,`${l}.always`),d(a.onError,`${l}.onError`),d(a.onTimeout,`${l}.onTimeout`),a.states)for(let t of Object.keys(a.states))n(a.states[t],`${l}.states.${t}`)}(t,"$"),a}(t,i,a),S=t.context?{context:r=>l(t.context,"context",r,"$.context")}:{},C=new h({...function t(r,n){var i;return{id:r.id,initial:r.initial,type:r.type,history:r.history,target:r.target,description:r.description,tags:r.tags,input:r.input,timeout:d(r.timeout,`${n}.timeout`),states:r.states?Object.fromEntries(Object.entries(r.states).map(([r,i])=>[r,t(i,`${n}.states.${r}`)])):void 0,on:r.on?Object.fromEntries(Object.entries(r.on).map(([t,r])=>[t,A(r,`${n}.on.${t}`)])):void 0,always:r.always?A(r.always,`${n}.always`):void 0,onError:r.onError?A(r.onError,`${n}.onError`):void 0,choice:function(t,r){if(t)return g(t)?n=>s(t,"choice",c(n),r):(v(t,r),n=>{for(let i=0;i<t.length;i++){let a=t[i],s=u(a.when,"choice",`${r}[${i}].when`);if(!s||s(n))return{target:a.target,context:a.context?l(a.context,"transitionContext",c(n),`${r}[${i}].context`):void 0,input:void 0!==a.input?l(a.input,"input",c(n),`${r}[${i}].input`):void 0,description:a.description,reenter:a.reenter,meta:a.meta}}throw Error(`Choice state at ${r} did not match any branch.`)})}(r.choice,`${n}.choice`),route:function(t,r){if(!t||"function"==typeof t)return t;if(g(t))return n=>s(t,"transition",c(n),r);let{guard:n,...i}=t;if(!n)return i;let a=u({type:n},"guard",r);return t=>a(t)?i:void 0}(r.route,`${n}.route`),after:r.after?Object.fromEntries(Object.entries(r.after).map(([t,r])=>[t,A(r,`${n}.after.${t}`)])):void 0,onTimeout:r.onTimeout?A(r.onTimeout,`${n}.onTimeout`):void 0,entry:r.entry?_(r.entry,`${n}.entry`):void 0,exit:r.exit?_(r.exit,`${n}.exit`):void 0,invoke:r.invoke?(i=r.invoke,(Array.isArray(i)?i:[i]).map((t,r)=>{let a=`${n}.invoke${Array.isArray(i)?`[${r}]`:""}`;return{src:t.src,id:t.id,registryKey:t.registryKey,input:void 0!==t.input?r=>l(t.input,"input",c(r),`${a}.input`):void 0,onDone:t.onDone?A(t.onDone,`${a}.onDone`):void 0,onError:t.onError?A(t.onError,`${a}.onError`):void 0,onSnapshot:t.onSnapshot?A(t.onSnapshot,`${a}.onSnapshot`):void 0,timeout:d(t.timeout,`${a}.timeout`),onTimeout:t.onTimeout?A(t.onTimeout,`${a}.onTimeout`):void 0}})):void 0,meta:r.meta,output:!function t(r){return g(r)||!!r&&"object"==typeof r&&Object.values(r).some(t)}(r.output)?r.output:({context:t,event:i,self:a,input:s})=>l(r.output,"output",{context:t,event:i,self:a,input:s},`${n}.output`)}}(t,"$"),...S,version:t.version,...r.schemas&&{schemas:r.schemas}},void 0,r.validator);for(let{stateId:t,path:r}of(function t(r,n){if("compound"===r.type)try{r.initial}catch(t){throw Error(`Invalid initial state at ${n}.initial: ${t.message}`)}for(let i of Object.keys(r.states))t(r.states[i],`${n}.states.${i}`)}(C.root,"$"),E))if(!C.idMap.has(t.replace(/^#/,"")))throw Error(`Unknown state ID "${t}" at ${r}`);t.internalEvents?.length&&(C.internalEventDescriptors=[...C.internalEventDescriptors,...t.internalEvents]);let T=C.provide({actions:i.actions,actors:i.actors,guards:i.guards,delays:i.delays});return T._json=t,T}let M=function(t={}){(0,o.h)(t);let{validator:r,states:n={},schemas:i,actions:a,actors:l,guards:c,delays:d}=t;return{extend:r=>{var n,i;return M((n=t,i=r,{...n,...i,schemas:A(n.schemas,i.schemas),states:function t(r,n){if(r||n)return r?n?Object.fromEntries(Array.from(new Set([...Object.keys(r),...Object.keys(n)])).map(i=>{let a=r[i],s=n[i];if(!a)return[i,s];if(!s)return[i,a];let o=A(a.schemas,s.schemas),l=t(a.states,s.states);return[i,{...a,...s,...o?{schemas:o}:void 0,...l?{states:l}:void 0}]})):r:n}(n.states,i.states),actions:_(n.actions,i.actions),actors:_(n.actors,i.actors),guards:_(n.guards,i.guards),delays:_(n.delays,i.delays)}))},createMachine(t,...s){if(void 0!==s[0])throw Error((0,o.x)(71));let u=A(t.schemas,i),f=function t(r,n){return r&&n?Object.fromEntries(Object.entries(r).map(([r,i])=>{let a=n[r];if(!a)return[r,i];let s=_(i.schemas,a.schemas),o=t(i.states,a.states),l=Object.fromEntries(["type","id","initial","history","target","route"].flatMap(t=>void 0===i[t]&&void 0!==a[t]?[[t,a[t]]]:[]));return[r,{...i,...l,...s?{schemas:s}:void 0,...o?{states:o}:void 0}]})):r}(t.states,n),p=_(a,t.actions),g=_(l,t.actors),m=_(c,t.guards),y=_(d,t.delays),v={...t,...u?{schemas:u}:void 0,...f?{states:f}:void 0,...p?{actions:p}:void 0,...g?{actors:g}:void 0,...m?{guards:m}:void 0,...y?{delays:y}:void 0};return(0,o.d)(v),new h(v,void 0,r)},createInvoke:(t,...r)=>"function"==typeof t.src?{...t,src:(0,s.Tg)({schemas:t.schemas,run:t.src})}:t,createStateConfig:(...t)=>t.length>1?t[1]:t[0],states:n,schemas:i??{}}};function _(t,r){return t||r?{...t,...r}:void 0}function A(t,r){if(t||r)return{...t,...r,events:_(t?.events,r?.events),internalEvents:_(t?.internalEvents,r?.internalEvents),actions:_(t?.actions,r?.actions),guards:_(t?.guards,r?.guards),emitted:_(t?.emitted,r?.emitted),rejections:_(t?.rejections,r?.rejections),children:_(t?.children,r?.children)}}Symbol("xstate.systemActorHandle")},1964(t,r,n){n.d(r,{Q:()=>u,at:()=>h});var i=n(5541);let a=new WeakMap;function s(t){let r=(0,i.n)(t),n=a.get(r);if(n&&n.version===r.version&&n.mode===t.mode)return n.csr;let s=function(t){let r=t.nodes.length,n=t.edges.length,i=t.nodes.slice(),a=Array(r),s=new Map;for(let t=0;t<r;t++)a[t]=i[t].id,s.set(a[t],t);let o=new Int32Array(n),l=new Int32Array(n),c=new Uint8Array(n),d=new Int32Array(r),u=new Int32Array(r),h=-1,f=-1,p=!1;for(let r=0;r<n;r++){let n=t.edges[r],i=n.weight??1;-1!==f||Number.isFinite(i)||(f=r),-1===h&&i<0&&(h=r);let a=+("directed"!==(n.mode??t.mode));a&&(p=!0);let g=s.get(n.sourceId),m=s.get(n.targetId);if(void 0===g||void 0===m){o[r]=-1,l[r]=-1;continue}o[r]=g,l[r]=m,c[r]=a,d[g]++,u[m]++,a&&(d[m]++,u[g]++)}let g=new Int32Array(r+1),m=new Int32Array(r+1);for(let t=0;t<r;t++)g[t+1]=g[t]+d[t],m[t+1]=m[t]+u[t];let y=new Int32Array(g[r]),v=new Int32Array(g[r]),b=new Int32Array(m[r]),x=new Int32Array(m[r]),w=g.slice(0,r),$=m.slice(0,r);for(let t=0;t<n;t++){let r=o[t],n=l[t];!(r<0)&&(y[w[r]]=n,v[w[r]++]=t,b[$[n]]=r,x[$[n]++]=t,c[t]&&(y[w[n]]=r,v[w[n]++]=t,b[$[r]]=n,x[$[r]++]=t))}return{nodes:i,ids:a,indexOf:s,outOffsets:g,outTargets:y,outEdgeIndex:v,inOffsets:m,inOrigins:b,inEdgeIndex:x,firstNegativeEdge:h,firstNonFiniteWeightEdge:f,hasNonDirected:p}}(t);return a.set(r,{version:r.version,mode:t.mode,csr:s}),s}(0,i.l)((t,r,n)=>{let i=a.get(t);if(void 0===i)return;let s=i.csr.nodes;r<s.length&&s[r].id===n.id&&(s[r]=n)});let o=globalThis.Iterator??class{},l={value:void 0,done:!0};var c=class extends o{started=!1;finished=!1;csr;nodes;direction;radius;starts;useOut=!0;useIn=!1;outOffsets;outTargets;inOffsets;inOrigins;constructor(t,r){super(),this.graph=t,this.startOrOptions=r}ensureStarted(){this.started=!0;try{this.setup()}catch(t){throw this.finished=!0,t}}setup(){this.csr=s(this.graph),this.nodes=s(this.graph).nodes;let t=function(t){let r="string"==typeof t?{from:t}:t,n=r.radius??1/0;if(Number.isNaN(n)||n<0||Number.isFinite(n)&&!Number.isInteger(n))throw RangeError("Traversal radius must be a non-negative integer or Infinity");return{from:r.from,direction:r.direction??"outgoing",radius:n}}(this.startOrOptions);this.direction=t.direction,this.radius=t.radius,this.starts=function(t,r){let n=[],i=new Set;for(let a of"string"==typeof r?[r]:r){let r=t.get(a);void 0===r||i.has(r)||(i.add(r),n.push(r))}return n}(this.csr.indexOf,t.from),this.useOut="incoming"!==t.direction,this.useIn="outgoing"!==t.direction,this.outOffsets=this.csr.outOffsets,this.outTargets=this.csr.outTargets,this.inOffsets=this.csr.inOffsets,this.inOrigins=this.csr.inOrigins,this.onSetup()}close(){}return(t){return this.close(),this.finished=!0,{value:t,done:!0}}throw(t){throw this.close(),this.finished=!0,t}[Symbol.iterator](){return this}},d=class extends c{visited;queue;depths;head=0;tail=0;expandCursor=0;chunk=8;onSetup(){let t=this.csr.ids.length;for(let r of(this.visited=new Uint8Array(t),this.queue=new Int32Array(t),this.depths=this.radius===1/0?void 0:new Int32Array(t),this.starts))this.visited[r]=1,this.queue[this.tail++]=r}expandChunk(){let t=this.visited,r=this.queue,n=this.depths,i=this.outOffsets,a=this.outTargets,s=this.inOffsets,o=this.inOrigins,l=this.useOut,c=this.useIn,d=this.radius,u=this.expandCursor,h=this.tail,f=Math.min(u+this.chunk,h);for(this.chunk<1024&&(this.chunk*=2);u<f;){let f=r[u++],p=0;if(void 0!==n){if(n[f]>=d)continue;p=n[f]+1}if(l)for(let s=i[f];s<i[f+1];s++){let i=a[s];t[i]||(t[i]=1,void 0!==n&&(n[i]=p),r[h++]=i)}if(c)for(let i=s[f];i<s[f+1];i++){let a=o[i];t[a]||(t[a]=1,void 0!==n&&(n[a]=p),r[h++]=a)}}this.expandCursor=u,this.tail=h}next(){let t=this.head;return t<this.expandCursor?(this.head=t+1,{value:this.nodes[this.queue[t]],done:!1}):this.nextSlow()}nextSlow(){if(this.finished)return l;for(this.started||this.ensureStarted();this.expandCursor<=this.head&&this.expandCursor<this.tail;)this.expandChunk();return this.head>=this.tail?(this.finished=!0,l):{value:this.nodes[this.queue[this.head++]],done:!1}}close(){this.head=0,this.expandCursor=0,this.tail=0}};function u(t,r){return new d(t,r)}function h(t,r,n,i){let a=s(t),o=a.indexOf.get(r),l=a.indexOf.get(n);if(void 0===o||void 0===l)return!1;if(o===l)return!0;let c=i?.direction??"outgoing",d=new Uint8Array(a.ids.length),u=new Int32Array(a.ids.length);d[o]=1,u[0]=o;let h=0,f=1;for(;h<f;){let t=u[h++];if("incoming"!==c)for(let r=a.outOffsets[t];r<a.outOffsets[t+1];r++){let t=a.outTargets[r];if(t===l)return!0;d[t]||(d[t]=1,u[f++]=t)}if("outgoing"!==c)for(let r=a.inOffsets[t];r<a.inOffsets[t+1];r++){let t=a.inOrigins[r];if(t===l)return!0;d[t]||(d[t]=1,u[f++]=t)}}return!1}},5192(t,r,n){n.d(r,{a:()=>l,i:()=>c,n:()=>d});var i=n(5541);function a(t){if(!t.name)throw Error("Port name must be a non-empty string");let r={name:t.name,direction:t.direction??"inout",data:t.data??null};return void 0!==t.label&&(r.label=t.label),void 0!==t.x&&(r.x=t.x),void 0!==t.y&&(r.y=t.y),void 0!==t.width&&(r.width=t.width),void 0!==t.height&&(r.height=t.height),void 0!==t.style&&(r.style=t.style),r}function s(t){if(!t.id)throw Error("Node id must be a non-empty string");if(""===t.parentId)throw Error("Node parentId must be a non-empty string");let r={type:"node",id:t.id,...void 0!==t.parentId&&{parentId:t.parentId??null},...void 0!==t.initialNodeId&&{initialNodeId:t.initialNodeId??null},label:t.label??null,data:t.data??null};if(void 0!==t.ports&&t.ports.length>0){var n=t.ports;let i=new Set;for(let t of n){if(i.has(t.name))throw Error(`Duplicate port name "${t.name}" on node`);i.add(t.name)}r.ports=t.ports.map(a)}return void 0!==t.x&&(r.x=t.x),void 0!==t.y&&(r.y=t.y),void 0!==t.width&&(r.width=t.width),void 0!==t.height&&(r.height=t.height),void 0!==t.shape&&(r.shape=t.shape),void 0!==t.color&&(r.color=t.color),void 0!==t.style&&(r.style=t.style),r}function o(t){if(!t.id)throw Error("Edge id must be a non-empty string");if(!t.sourceId)throw Error("Edge sourceId must be a non-empty string");if(!t.targetId)throw Error("Edge targetId must be a non-empty string");let r={type:"edge",id:t.id,sourceId:t.sourceId,targetId:t.targetId,label:t.label??null,data:t.data??null};return void 0!==t.sourcePort&&(r.sourcePort=t.sourcePort),void 0!==t.targetPort&&(r.targetPort=t.targetPort),void 0!==t.mode&&(r.mode=t.mode),void 0!==t.weight&&(r.weight=t.weight),void 0!==t.points&&(r.points=t.points.map(t=>({...t}))),void 0!==t.routing&&(r.routing=t.routing),void 0!==t.x&&(r.x=t.x),void 0!==t.y&&(r.y=t.y),void 0!==t.width&&(r.width=t.width),void 0!==t.height&&(r.height=t.height),void 0!==t.color&&(r.color=t.color),void 0!==t.style&&(r.style=t.style),r}function l(t){let r={id:t?.id??"",mode:t?.mode??"directed",initialNodeId:t?.initialNodeId??null,nodes:(t?.nodes??[]).map(s),edges:(t?.edges??[]).map(o),data:t?.data??null};return t?.direction!==void 0&&(r.direction=t.direction),t?.style!==void 0&&(r.style=t.style),r}function c(t,r){let n=s(r),a=(0,i.n)(t);if(a.nodeById.has(r.id))throw Error(`Node "${r.id}" already exists`);if(r.parentId&&!a.nodeById.has(r.parentId))throw Error(`Parent node "${r.parentId}" does not exist`);return!function(t,r,n){if(null!=r&&!t.has(r))throw Error(n(r))}(new Set([...a.nodeById.keys(),r.id]),r.initialNodeId,t=>`Initial node "${t}" does not exist`),(0,i.i)(a,n,t.nodes.push(n)-1),n}function d(t,r){let n=o(r),a=(0,i.n)(t);if(a.edgeById.has(r.id))throw Error(`Edge "${r.id}" already exists`);if(!a.nodeById.has(r.sourceId))throw Error(`Source node "${r.sourceId}" does not exist`);if(!a.nodeById.has(r.targetId))throw Error(`Target node "${r.targetId}" does not exist`);if(void 0!==r.sourcePort&&!t.nodes[a.nodeById.get(r.sourceId)].ports?.some(t=>t.name===r.sourcePort))throw Error(`Port "${r.sourcePort}" does not exist on source node "${r.sourceId}"`);if(void 0!==r.targetPort&&!t.nodes[a.nodeById.get(r.targetId)].ports?.some(t=>t.name===r.targetPort))throw Error(`Port "${r.targetPort}" does not exist on target node "${r.targetId}"`);return(0,i.r)(a,n,t.edges.push(n)-1),n}},5541(t,r,n){n.d(r,{i:()=>l,l:()=>o,n:()=>a,r:()=>c});let i=new WeakMap;function a(t){let r=i.get(t);return r&&r.nodesRef===t.nodes&&r.edgesRef===t.edges&&r.nodeCount===t.nodes.length&&r.edgeCount===t.edges.length||(r=function(t){let r=new Map,n=new Map,i=new Map,a=new Map,s=new Map;for(let n=0;n<t.nodes.length;n++){let o=t.nodes[n];r.set(o.id,n),i.set(o.id,[]),a.set(o.id,[]);let l=o.parentId??null;s.has(l)||s.set(l,[]),s.get(l).push(o.id)}for(let r=0;r<t.edges.length;r++){let s=t.edges[r];n.set(s.id,r),i.get(s.sourceId)?.push(s.id),a.get(s.targetId)?.push(s.id)}return{nodeById:r,edgeById:n,outEdges:i,inEdges:a,childNodes:s,nodeCount:t.nodes.length,edgeCount:t.edges.length,nodesRef:t.nodes,edgesRef:t.edges,version:0}}(t),i.set(t,r)),r}let s=[];function o(t){s.push(t)}function l(t,r,n){t.nodeById.set(r.id,n),t.outEdges.set(r.id,[]),t.inEdges.set(r.id,[]);let i=r.parentId??null;t.childNodes.has(i)||t.childNodes.set(i,[]),t.childNodes.get(i).push(r.id),t.nodeCount++,t.version++}function c(t,r,n){t.edgeById.set(r.id,n),t.outEdges.get(r.sourceId)?.push(r.id),t.inEdges.get(r.targetId)?.push(r.id),t.edgeCount++,t.version++}},9174(t,r,n){n.d(r,{_:()=>i});function i(t,r,n){return r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}},4543(t,r,n){n.d(r,{uB:()=>rA});var i,a,s,o,l,c,d,u,h=/[\\\/_+.#"@\[\(\{&]/,f=/[\\\/_+.#"@\[\(\{&]/g,p=/[\s-]/,g=/[\s-]/g;function m(t){return t.toLowerCase().replace(g," ")}var y=n(7014),v=n.t(y,2),b=Object.defineProperty,x=(t,r)=>b(t,"name",{value:r,configurable:!0}),w=!!("u">typeof window&&window.document&&window.document.createElement);function $(t,r,{checkForDefaultPrevented:n=!0}={}){return x(function(i){if(t?.(i),!1===n||!i||!i.defaultPrevented)return r?.(i)},"handleEvent")}function k(t){if(!w)throw Error("Cannot access document outside of the DOM");return t?.ownerDocument??document}function M(t){return"IFRAME"===t.tagName}x($,"composeEventHandlers"),x(function(t){if(!w)throw Error("Cannot access window outside of the DOM");return t?.ownerDocument?.defaultView??window},"getOwnerWindow"),x(k,"getOwnerDocument"),x(function t(r,n=!1){let{activeElement:i}=k(r);if(!i?.nodeName)return null;if(M(i)&&i.contentDocument)return t(i.contentDocument.body,n);if(n){let t=i.getAttribute("aria-activedescendant");if(t){let r=k(i).getElementById(t);if(r)return r}}return i},"getActiveElement"),x(M,"isFrame");var _=Object.defineProperty,A=(t,r)=>_(t,"name",{value:r,configurable:!0});function E(t,r){if("function"==typeof t)return t(r);null!=t&&(t.current=r)}function S(...t){return r=>{let n=!1,i=t.map(t=>{let i=E(t,r);return n||"function"!=typeof i||(n=!0),i});if(n)return()=>{for(let r=0;r<i.length;r++){let n=i[r];"function"==typeof n?n():E(t[r],null)}}}}function C(...t){return y.useCallback(S(...t),t)}A(E,"setRef"),A(S,"composeRefs"),A(C,"useComposedRefs");var T=n(7462),I=Object.defineProperty,N=(t,r)=>I(t,"name",{value:r,configurable:!0});function O(t,r=[]){let n=[];function i(r,i){let a=y.createContext(i);a.displayName=r+"Context";let s=n.length;n=[...n,i];let o=N(r=>{let{scope:n,children:i,...o}=r,l=n?.[t]?.[s]||a,c=y.useMemo(()=>o,Object.values(o));return(0,T.jsx)(l.Provider,{value:c,children:i})},"Provider");function l(n,o,c={}){let{optional:d=!1}=c,u=o?.[t]?.[s]||a,h=y.useContext(u);if(h)return h;if(void 0!==i)return i;if(!d)throw Error(`\`${n}\` must be used within \`${r}\``)}return o.displayName=r+"Provider",N(l,"useContext"),[o,l]}N(i,"createContext");let a=N(()=>{let r=n.map(t=>y.createContext(t));return N(function(n){let i=n?.[t]||r;return y.useMemo(()=>({[`__scope${t}`]:{...n,[t]:i}}),[n,i])},"useScope")},"createScope");return a.scopeName=t,[i,D(a,...r)]}function D(...t){let r=t[0];if(1===t.length)return r;let n=N(()=>{let n=t.map(t=>({useScope:t(),scopeName:t.scopeName}));return N(function(t){let i=n.reduce((r,{useScope:n,scopeName:i})=>{let a=n(t)[`__scope${i}`];return{...r,...a}},{});return y.useMemo(()=>({[`__scope${r.scopeName}`]:i}),[i])},"useComposedScopes")},"createScope");return n.scopeName=r.scopeName,n}N(function(t,r){let n=y.createContext(r);n.displayName=t+"Context";let i=N(t=>{let{children:r,...i}=t,a=y.useMemo(()=>i,Object.values(i));return(0,T.jsx)(n.Provider,{value:a,children:r})},"Provider");function a(i,s={}){let{optional:o=!1}=s,l=y.useContext(n);if(l)return l;if(void 0!==r)return r;if(!o)throw Error(`\`${i}\` must be used within \`${t}\``)}return i.displayName=t+"Provider",N(a,"useContext"),[i,a]},"createContext"),N(O,"createContextScope"),N(D,"composeContextScopes");var R=globalThis?.document?y.useLayoutEffect:()=>{},L=Object.defineProperty,z=v[" useId ".trim().toString()]||(()=>void 0),P=0;function j(t){let[r,n]=y.useState(z());return R(()=>{t||n(t=>t??String(P++))},[t]),t||(r?`radix-${r}`:"")}L(j,"name",{value:"useId",configurable:!0});var F=Object.defineProperty,B=v[" useEffectEvent ".trim().toString()],W=v[" useInsertionEffect ".trim().toString()];function H(t){if("function"==typeof B)return B(t);let r=y.useRef(()=>{throw Error("Cannot call an event handler while rendering.")});return"function"==typeof W?W(()=>{r.current=t}):R(()=>{r.current=t}),y.useMemo(()=>(...t)=>r.current?.(...t),[])}F(H,"name",{value:"useEffectEvent",configurable:!0});var U=Object.defineProperty,q=(t,r)=>U(t,"name",{value:r,configurable:!0}),V=v[" useInsertionEffect ".trim().toString()]||R;function Y({prop:t,defaultProp:r,onChange:n=q(()=>{},"onChange"),caller:i}){let[a,s,o]=G({defaultProp:r,onChange:n}),l=void 0!==t,c=l?t:a;return[c,y.useCallback(r=>{if(l){let n=Z(r)?r(t):r;n!==t&&o.current?.(n)}else s(r)},[l,t,s,o])]}function G({defaultProp:t,onChange:r}){let[n,i]=y.useState(t),a=y.useRef(n),s=y.useRef(r);return V(()=>{s.current=r},[r]),y.useEffect(()=>{a.current!==n&&(s.current?.(n),a.current=n)},[n,a]),[n,i,s]}function Z(t){return"function"==typeof t}q(Y,"useControllableState"),q(G,"useUncontrolledState"),q(Z,"isFunction");var X=Symbol("RADIX:SYNC_STATE");q(function(t,r,n,i){let{prop:a,defaultProp:s,onChange:o,caller:l}=r,c=void 0!==a,d=H(o),u=[{...n,state:s}];i&&u.push(i);let[h,f]=y.useReducer((r,n)=>{if(n.type===X)return{...r,state:n.state};let i=t(r,n);return c&&!Object.is(i.state,r.state)&&d(i.state),i},...u),p=h.state,g=y.useRef(p);y.useEffect(()=>{g.current!==p&&(g.current=p,c||d(p))},[p,g,c]);let m=y.useMemo(()=>void 0!==a?{...h,state:a}:h,[h,a]);return y.useEffect(()=>{c&&!Object.is(a,h.state)&&f({type:X,state:a})},[a,h.state,c]),[m,f]},"useControllableStateReducer");var K=n(6049),J=Object.defineProperty,Q=(t,r)=>J(t,"name",{value:r,configurable:!0});function ee(t){let r=y.forwardRef((r,n)=>{let{children:i,...a}=r,s=null,o=!1,l=[];i=ec(i),y.Children.forEach(i,t=>{if(ea(t)){o=!0;let r="child"in t.props?t.props.child:t.props.children;for(;eo(r)&&"function"==typeof ef;)r=ef(r._payload);s=er(t,r),l.push(s?.props?.children)}else l.push(t)}),s?s=y.cloneElement(s,void 0,l):!o&&1===y.Children.count(i)&&y.isValidElement(i)&&(s=i);let c=s?ei(s):void 0,d=C(n,c);if(!s){if(i||0===i)throw Error(o?eh(t):eu(t));return i}let u=en(a,s.props??{});return s.type!==y.Fragment&&(u.ref=n?d:c),y.cloneElement(s,u)});return r.displayName=`${t}.Slot`,r}Q(ee,"createSlot");var et=Symbol.for("radix.slottable");Q(function(t){let r=Q(t=>"child"in t?t.children(t.child):t.children,"Slottable");return r.displayName=`${t}.Slottable`,r.__radixId=et,r},"createSlottable");var er=Q((t,r)=>"child"in t.props?y.isValidElement(r)?y.cloneElement(r,void 0,t.props.children(r.props.children)):null:y.isValidElement(r)?r:null,"getSlottableElementFromSlottable");function en(t,r){let n={...r};for(let i in r){let a=t[i],s=r[i];/^on[A-Z]/.test(i)?a&&s?n[i]=(...t)=>{let r=s(...t);return a(...t),r}:a&&(n[i]=a):"style"===i?n[i]={...a,...s}:"className"===i?n[i]=[a,s].filter(Boolean).join(" "):"aria-describedby"===i&&(n[i]=ed(s,a))}return{...t,...n}}function ei(t){let r=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=r&&"isReactWarning"in r&&r.isReactWarning;return n?t.ref:(n=(r=Object.getOwnPropertyDescriptor(t,"ref")?.get)&&"isReactWarning"in r&&r.isReactWarning)?t.props.ref:t.props.ref||t.ref}function ea(t){return y.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===et}Q(en,"mergeProps"),Q(ei,"getElementRef"),Q(ea,"isSlottable");var es=Symbol.for("react.lazy");function eo(t){return null!=t&&"object"==typeof t&&"$$typeof"in t&&t.$$typeof===es&&"_payload"in t&&el(t._payload)}function el(t){return"object"==typeof t&&null!==t&&"then"in t}function ec(t){let r=t;for(;eo(r)&&"function"==typeof ef;)r=ef(r._payload);return r}function ed(...t){let r=new Set;for(let n of t)if("string"==typeof n)for(let t of String(n).trim().split(/\s+/))t&&r.add(t);return r.size>0?Array.from(r).join(" "):void 0}Q(eo,"isLazyComponent"),Q(el,"isPromiseLike"),Q(ec,"useUnwrappedLazy"),Q(ed,"concatAriaDescribedby");var eu=Q(t=>`${t} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),eh=Q(t=>`${t} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),ef=v[" use ".trim().toString()],ep=Object.defineProperty,eg=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,r)=>{let n=ee(`Primitive.${r}`),i=y.forwardRef((t,i)=>{let{asChild:a,...s}=t;return"u">typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,T.jsx)(a?n:r,{...s,ref:i})});return i.displayName=`Primitive.${r}`,{...t,[r]:i}},{});function em(t,r){t&&K.flushSync(()=>t.dispatchEvent(r))}ep(em,"name",{value:"dispatchDiscreteCustomEvent",configurable:!0});var ey=Object.defineProperty,ev=v[" useInsertionEffect ".trim().toString()];function eb(t){let r=y.useRef(t);return"function"==typeof ev?ev(()=>{r.current=t}):R(()=>{r.current=t}),y.useMemo(()=>(...t)=>r.current?.(...t),[])}ey(eb,"name",{value:"useCallbackRef",configurable:!0});var ex=Object.defineProperty,ew=(t,r)=>ex(t,"name",{value:r,configurable:!0}),e$="dismissableLayer.update",ek=y.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),eM=y.forwardRef(ew(function(t,r){let{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:a=!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:l,onInteractOutside:c,onDismiss:d,...u}=t,h=y.useContext(ek),[f,p]=y.useState(null),g=f?.ownerDocument??globalThis?.document,[,m]=y.useState({}),v=C(r,p),b=Array.from(h.layers),[x]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),w=x?b.indexOf(x):-1,k=f?b.indexOf(f):-1,M=h.layersWithOutsidePointerEventsDisabled.size>0,_=k>=w,A=y.useRef(!1),E=eE(t=>{o?.(t),c?.(t),t.defaultPrevented||d?.()},{ownerDocument:g,deferPointerDownOutside:a,isDeferredPointerDownOutsideRef:A,dismissableSurfaces:h.dismissableSurfaces,shouldHandlePointerDownOutside:y.useCallback(t=>{if(!(t instanceof Node))return!1;let r=[...h.branches].some(r=>r.contains(t));return _&&!r},[h.branches,_])}),S=eS(t=>{if(a&&A.current)return;let r=t.target;![...h.branches].some(t=>t.contains(r))&&(l?.(t),c?.(t),t.defaultPrevented||d?.())},g),I=!!f&&k===b.length-1,N=eb(t=>{"Escape"===t.key&&(s?.(t),!t.defaultPrevented&&d&&(t.preventDefault(),d()))});return y.useEffect(()=>{if(I)return g.addEventListener("keydown",N,{capture:!0}),()=>g.removeEventListener("keydown",N,{capture:!0})},[g,I,N]),y.useEffect(()=>{if(f)return n&&(0===h.layersWithOutsidePointerEventsDisabled.size&&(i=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(f)),h.layers.add(f),eC(),()=>{n&&(h.layersWithOutsidePointerEventsDisabled.delete(f),0===h.layersWithOutsidePointerEventsDisabled.size&&(g.body.style.pointerEvents=i))}},[f,g,n,h]),y.useEffect(()=>()=>{f&&(h.layers.delete(f),h.layersWithOutsidePointerEventsDisabled.delete(f),eC())},[f,h]),y.useEffect(()=>{let t=ew(()=>m({}),"handleUpdate");return document.addEventListener(e$,t),()=>document.removeEventListener(e$,t)},[]),(0,T.jsx)(eg.div,{...u,ref:v,style:{pointerEvents:M?_?"auto":"none":void 0,...t.style},onFocusCapture:$(t.onFocusCapture,S.onFocusCapture),onBlurCapture:$(t.onBlurCapture,S.onBlurCapture),onPointerDownCapture:$(t.onPointerDownCapture,E.onPointerDownCapture)})},"DismissableLayer"));function e_(){let t=y.useContext(ek),[r,n]=y.useState(null);return y.useEffect(()=>{if(r)return t.dismissableSurfaces.add(r),()=>{t.dismissableSurfaces.delete(r)}},[r,t.dismissableSurfaces]),n}ew(e_,"useDismissableLayerSurface");var eA=ew(()=>!0,"IS_TRUE");function eE(t,r){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:i=!1,isDeferredPointerDownOutsideRef:a,dismissableSurfaces:s,shouldHandlePointerDownOutside:o=eA}=r,l=eb(t),c=y.useRef(!1),d=y.useRef(!1),u=y.useRef(new Map),h=y.useRef(()=>{});return y.useEffect(()=>{function t(){d.current=!1,a.current=!1,u.current.clear()}function r(){return Array.from(u.current.values()).some(Boolean)}function f(t){if(!d.current)return;let r=t.target;r instanceof Node&&[...s].some(t=>t.contains(r))||u.current.set(t.type,!0),"click"===t.type&&window.setTimeout(()=>{d.current&&h.current()},0)}function p(t){d.current&&u.current.set(t.type,!1)}ew(t,"resetOutsideInteraction"),ew(r,"isOutsideInteractionIntercepted"),ew(f,"handleInteractionCapture"),ew(p,"handleInteractionBubble");let g=ew(s=>{if(s.target&&!c.current){let f=function(){n.removeEventListener("click",h.current);let i=r();t(),i||eT("dismissableLayer.pointerDownOutside",l,p,{discrete:!0})};if(ew(f,"handleAndDispatchPointerDownOutsideEvent"),!o(s.target)){n.removeEventListener("click",h.current),t(),c.current=!1;return}let p={originalEvent:s};d.current=!0,a.current=i&&0===s.button,u.current.clear(),i&&0===s.button?(n.removeEventListener("click",h.current),h.current=f,n.addEventListener("click",h.current,{once:!0})):f()}else n.removeEventListener("click",h.current),t();c.current=!1},"handlePointerDown"),m=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(let t of m)n.addEventListener(t,f,!0),n.addEventListener(t,p);let y=window.setTimeout(()=>{n.addEventListener("pointerdown",g)},0);return()=>{for(let t of(window.clearTimeout(y),n.removeEventListener("pointerdown",g),n.removeEventListener("click",h.current),m))n.removeEventListener(t,f,!0),n.removeEventListener(t,p)}},[n,l,i,a,s,o]),{onPointerDownCapture:ew(()=>c.current=!0,"onPointerDownCapture")}}function eS(t,r=globalThis?.document){let n=eb(t),i=y.useRef(!1);return y.useEffect(()=>{let t=ew(t=>{t.target&&!i.current&&eT("dismissableLayer.focusOutside",n,{originalEvent:t},{discrete:!1})},"handleFocus");return r.addEventListener("focusin",t),()=>r.removeEventListener("focusin",t)},[r,n]),{onFocusCapture:ew(()=>i.current=!0,"onFocusCapture"),onBlurCapture:ew(()=>i.current=!1,"onBlurCapture")}}function eC(){let t=new CustomEvent(e$);document.dispatchEvent(t)}function eT(t,r,n,{discrete:i}){let a=n.originalEvent.target,s=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});r&&a.addEventListener(t,r,{once:!0}),i?em(a,s):a.dispatchEvent(s)}ew(eE,"usePointerDownOutside"),ew(eS,"useFocusOutside"),ew(eC,"dispatchUpdate"),ew(eT,"handleAndDispatchCustomEvent");var eI=Object.defineProperty,eN=(t,r)=>eI(t,"name",{value:r,configurable:!0}),eO="focusScope.autoFocusOnMount",eD="focusScope.autoFocusOnUnmount",eR={bubbles:!1,cancelable:!0},eL=y.forwardRef(eN(function(t,r){let{loop:n=!1,trapped:i=!1,branches:a,onMountAutoFocus:s,onUnmountAutoFocus:o,...l}=t,[c,d]=y.useState(null),u=eb(s),h=eb(o),f=y.useRef(null),p=C(r,d),g=y.useRef(a);y.useEffect(()=>{g.current=a});let m=y.useCallback(t=>!!t&&(!!c?.contains(t)||!!g.current?.some(r=>r.contains(t))),[c]),v=y.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;y.useEffect(()=>{if(i){let t=function(t){if(v.paused||!c)return;let r=t.target;m(r)?f.current=r:eV(f.current,{select:!0})},r=function(t){if(v.paused||!c)return;let r=t.relatedTarget;null!==r&&(m(r)||eV(f.current,{select:!0}))},n=function(t){if(document.activeElement===document.body)for(let r of t)r.removedNodes.length>0&&eV(c)};eN(t,"handleFocusIn"),eN(r,"handleFocusOut"),eN(n,"handleMutations"),document.addEventListener("focusin",t),document.addEventListener("focusout",r);let i=new MutationObserver(n);return c&&i.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",t),document.removeEventListener("focusout",r),i.disconnect()}}},[i,c,v.paused,m]),y.useEffect(()=>{if(c){eY.add(v);let t=document.activeElement;if(!c.contains(t)){let r=new CustomEvent(eO,eR);c.addEventListener(eO,u),c.dispatchEvent(r),r.defaultPrevented||(eF(eX(eW(c)),{select:!0}),document.activeElement===t&&eV(c))}return()=>{c.removeEventListener(eO,u);let r=c.ownerDocument,n=CustomEvent;setTimeout(()=>{let i=new n(eD,eR);c.addEventListener(eD,h),c.dispatchEvent(i),i.defaultPrevented||eV(t??r.body,{select:!0}),c.removeEventListener(eD,h),eY.remove(v)},0)}}},[c,u,h,v]);let b=y.useCallback(t=>{if(!n&&!i||v.paused)return;let r="Tab"===t.key&&!t.altKey&&!t.ctrlKey&&!t.metaKey,a=document.activeElement;if(r&&a){let r=t.currentTarget,[i,s]=eB(r);i&&s?t.shiftKey||a!==s?t.shiftKey&&a===i&&(t.preventDefault(),n&&eV(s,{select:!0})):(t.preventDefault(),n&&eV(i,{select:!0})):a===r&&t.preventDefault()}},[n,i,v.paused]);return(0,T.jsx)(eg.div,{tabIndex:-1,...l,ref:p,onKeyDown:b})},"FocusScope")),ez=y.createContext(null);function eP({registry:t,children:r}){return t?(0,T.jsx)(ez.Provider,{value:t,children:r}):r}function ej(){let[t,r]=y.useState([]);return{nodes:t,registry:y.useMemo(()=>({add:eN(t=>r(r=>r.includes(t)?r:[...r,t]),"add"),remove:eN(t=>r(r=>r.filter(r=>r!==t)),"remove")}),[])}}function eF(t,{select:r=!1}={}){let n=document.activeElement;for(let i of t)if(eV(i,{select:r}),document.activeElement!==n)return}function eB(t){let r=eW(t);return[eH(r,t),eH(r.reverse(),t)]}function eW(t){let r=[],n=t.ownerDocument.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:eN(t=>{let r="INPUT"===t.tagName&&"hidden"===t.type;return t.disabled||t.hidden||r?NodeFilter.FILTER_SKIP:t.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;n.nextNode();)r.push(n.currentNode);return r}function eH(t,r){let n="function"==typeof r.checkVisibility&&r.checkVisibility({checkVisibilityCSS:!0});for(let i of t)if(!(n?!i.checkVisibility({checkVisibilityCSS:!0}):eU(i,{upTo:r})))return i}function eU(t,{upTo:r}){if("hidden"===getComputedStyle(t).visibility)return!0;for(;t&&(void 0===r||t!==r);){if("none"===getComputedStyle(t).display)return!0;t=t.parentElement}return!1}function eq(t){return"INPUT"===t.tagName&&"function"==typeof t.select}function eV(t,{select:r=!1}={}){if(t&&t.focus){let n=(t.ownerDocument??document).activeElement;t.focus({preventScroll:!0}),t!==n&&eq(t)&&r&&t.select()}}eN(eP,"FocusScopeBranchProvider"),eN(ej,"useFocusScopeBranchRegistry"),eN(function(t){let r=y.useContext(ez);y.useEffect(()=>{if(t&&r)return r.add(t),()=>r.remove(t)},[t,r])},"useFocusScopeBranch"),eN(eF,"focusFirst"),eN(eB,"getTabbableEdges"),eN(eW,"getTabbableCandidates"),eN(eH,"findVisible"),eN(eU,"isHidden"),eN(eq,"isSelectableInput"),eN(eV,"focus");var eY=eG();function eG(){let t=[];return{add(r){let n=t[0];r!==n&&n?.pause(),(t=eZ(t,r)).unshift(r)},remove(r){t=eZ(t,r),t[0]?.resume()}}}function eZ(t,r){let n=[...t],i=n.indexOf(r);return -1!==i&&n.splice(i,1),n}function eX(t){return t.filter(t=>"A"!==t.tagName)}eN(eG,"createFocusScopesStack"),eN(eZ,"arrayRemove"),eN(eX,"removeLinks");var eK=Object.defineProperty,eJ=y.forwardRef(eK(function(t,r){let{container:n,...i}=t,[a,s]=y.useState(!1);R(()=>s(!0),[]);let o=n||a&&globalThis?.document?.body;return o?K.createPortal((0,T.jsx)(eg.div,{...i,ref:r}),o):null},"name",{value:"Portal",configurable:!0})),eQ=Object.defineProperty,e0=(t,r)=>eQ(t,"name",{value:r,configurable:!0});function e1(t,r){return y.useReducer((t,n)=>r[t][n]??t,t)}e0(e1,"useStateMachine");var e2=e0(t=>{let{present:r,children:n}=t,i=e4(r),a="function"==typeof n?n({present:i.isPresent}):y.Children.only(n),s=e5(i.ref,e8(a));return"function"==typeof n||i.isPresent?y.cloneElement(a,{ref:s}):null},"Presence");function e4(t){let[r,n]=y.useState(),i=y.useRef(null),a=y.useRef(t),s=y.useRef("none"),o=y.useRef(void 0),[l,c]=e1(t?"mounted":"unmounted",{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return y.useEffect(()=>{"mounted"===l?(s.current=o.current??e6(i.current),o.current=void 0):s.current="none"},[l]),R(()=>{let r=i.current,n=a.current;if(n!==t){let i=s.current,l=e6(r);t?(o.current=l,c("MOUNT")):"none"===l||r?.display==="none"?c("UNMOUNT"):n&&i!==l?c("ANIMATION_OUT"):c("UNMOUNT"),a.current=t}},[t,c]),R(()=>{if(r){let t,n=r.ownerDocument.defaultView??window,o=e0(s=>{let o=e6(i.current).includes(CSS.escape(s.animationName));if(s.target===r&&o&&(c("ANIMATION_END"),!a.current)){let i=r.style.animationFillMode;r.style.animationFillMode="forwards",t=n.setTimeout(()=>{"forwards"===r.style.animationFillMode&&(r.style.animationFillMode=i)})}},"handleAnimationEnd"),l=e0(t=>{t.target===r&&(s.current=e6(i.current))},"handleAnimationStart");return r.addEventListener("animationstart",l),r.addEventListener("animationcancel",o),r.addEventListener("animationend",o),()=>{n.clearTimeout(t),r.removeEventListener("animationstart",l),r.removeEventListener("animationcancel",o),r.removeEventListener("animationend",o)}}c("ANIMATION_END")},[r,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:y.useCallback(t=>{if(t){let r=getComputedStyle(t);i.current=r,o.current=e6(r)}else i.current=null;n(t)},[])}}function e3(t,r){if("function"==typeof t)return t(r);null!=t&&(t.current=r)}function e5(...t){let r=y.useRef(t);return r.current=t,y.useCallback(t=>{let n=r.current,i=!1,a=n.map(r=>{let n=e3(r,t);return i||"function"!=typeof n||(i=!0),n});if(i)return()=>{for(let t=0;t<a.length;t++){let r=a[t];"function"==typeof r?r():e3(n[t],null)}}},[])}function e6(t){return t?.animationName||"none"}function e8(t){let r=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=r&&"isReactWarning"in r&&r.isReactWarning;return n?t.ref:(n=(r=Object.getOwnPropertyDescriptor(t,"ref")?.get)&&"isReactWarning"in r&&r.isReactWarning)?t.props.ref:t.props.ref||t.ref}e0(e4,"usePresence"),e0(e3,"setRef"),e0(e5,"useStableComposedRefs"),e0(e6,"getAnimationName"),e0(e8,"getElementRef");var e9=Object.defineProperty,e7=(t,r)=>e9(t,"name",{value:r,configurable:!0}),te=0,tt=null;function tr(){y.useEffect(()=>{tt||(tt={start:tn(),end:tn()});let{start:t,end:r}=tt;return document.body.firstElementChild!==t&&document.body.insertAdjacentElement("afterbegin",t),document.body.lastElementChild!==r&&document.body.insertAdjacentElement("beforeend",r),te++,()=>{1===te&&(tt?.start.remove(),tt?.end.remove(),tt=null),te=Math.max(0,te-1)}},[])}function tn(){let t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}e7(function(t){return tr(),t.children},"FocusGuards"),e7(tr,"useFocusGuards"),e7(tn,"createFocusGuard");var ti=function(){return(ti=Object.assign||function(t){for(var r,n=1,i=arguments.length;n<i;n++)for(var a in r=arguments[n])Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a]);return t}).apply(this,arguments)};function ta(t,r){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&0>r.indexOf(i)&&(n[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols)for(var a=0,i=Object.getOwnPropertySymbols(t);a<i.length;a++)0>r.indexOf(i[a])&&Object.prototype.propertyIsEnumerable.call(t,i[a])&&(n[i[a]]=t[i[a]]);return n}var ts="right-scroll-bar-position",to="width-before-scroll-bar";function tl(t,r){return"function"==typeof t?t(r):t&&(t.current=r),t}var tc="u">typeof window?y.useLayoutEffect:y.useEffect,td=new WeakMap,tu=(void 0===s&&(s={}),(void 0===o&&(o=function(t){return t}),l=[],c=!1,d={read:function(){if(c)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return l.length?l[l.length-1]:null},useMedium:function(t){var r=o(t,c);return l.push(r),function(){l=l.filter(function(t){return t!==r})}},assignSyncMedium:function(t){for(c=!0;l.length;){var r=l;l=[],r.forEach(t)}l={push:function(r){return t(r)},filter:function(){return l}}},assignMedium:function(t){c=!0;var r=[];if(l.length){var n=l;l=[],n.forEach(t),r=l}var i=function(){var n=r;r=[],n.forEach(t)},a=function(){return Promise.resolve().then(i)};a(),l={push:function(t){r.push(t),a()},filter:function(t){return r=r.filter(t),l}}}}).options=ti({async:!0,ssr:!1},s),d),th=function(){},tf=y.forwardRef(function(t,r){var n,i,a,s,o=y.useRef(null),l=y.useState({onScrollCapture:th,onWheelCapture:th,onTouchMoveCapture:th}),c=l[0],d=l[1],u=t.forwardProps,h=t.children,f=t.className,p=t.removeScrollBar,g=t.enabled,m=t.shards,v=t.sideCar,b=t.noRelative,x=t.noIsolation,w=t.inert,$=t.allowPinchZoom,k=t.as,M=t.gapMode,_=ta(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),A=(n=[o,r],i=function(t){return n.forEach(function(r){return tl(r,t)})},(a=(0,y.useState)(function(){return{value:null,callback:i,facade:{get current(){return a.value},set current(value){var t=a.value;t!==value&&(a.value=value,a.callback(value,t))}}}})[0]).callback=i,s=a.facade,tc(function(){var t=td.get(s);if(t){var r=new Set(t),i=new Set(n),a=s.current;r.forEach(function(t){i.has(t)||tl(t,null)}),i.forEach(function(t){r.has(t)||tl(t,a)})}td.set(s,n)},[n]),s),E=ti(ti({},_),c);return y.createElement(y.Fragment,null,g&&y.createElement(v,{sideCar:tu,removeScrollBar:p,shards:m,noRelative:b,noIsolation:x,inert:w,setCallbacks:d,allowPinchZoom:!!$,lockRef:o,gapMode:M}),u?y.cloneElement(y.Children.only(h),ti(ti({},E),{ref:A})):y.createElement(void 0===k?"div":k,ti({},E,{className:f,ref:A}),h))});tf.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},tf.classNames={fullWidth:to,zeroRight:ts};var tp=function(t){var r=t.sideCar,n=ta(t,["sideCar"]);if(!r)throw Error("Sidecar: please provide `sideCar` property to import the right car");var i=r.read();if(!i)throw Error("Sidecar medium not found");return y.createElement(i,ti({},n))};tp.isSideCarExport=!0;var tg=function(){var t=0,r=null;return{add:function(i){if(0==t&&(r=function(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var r=a||n.nc;return r&&t.setAttribute("nonce",r),t}())){var s,o;(s=r).styleSheet?s.styleSheet.cssText=i:s.appendChild(document.createTextNode(i)),o=r,(document.head||document.getElementsByTagName("head")[0]).appendChild(o)}t++},remove:function(){--t||!r||(r.parentNode&&r.parentNode.removeChild(r),r=null)}}},tm=function(){var t=tg();return function(r,n){y.useEffect(function(){return t.add(r),function(){t.remove()}},[r&&n])}},ty=function(){var t=tm();return function(r){return t(r.styles,r.dynamic),null}},tv={left:0,top:0,right:0,gap:0},tb=function(t){return parseInt(t||"",10)||0},tx=function(t){var r=window.getComputedStyle(document.body),n=r["padding"===t?"paddingLeft":"marginLeft"],i=r["padding"===t?"paddingTop":"marginTop"],a=r["padding"===t?"paddingRight":"marginRight"];return[tb(n),tb(i),tb(a)]},tw=function(t){if(void 0===t&&(t="margin"),"u"<typeof window)return tv;var r=tx(t),n=document.documentElement.clientWidth,i=window.innerWidth;return{left:r[0],top:r[1],right:r[2],gap:Math.max(0,i-n+r[2]-r[0])}},t$=ty(),tk="data-scroll-locked",tM=function(t,r,n,i){var a=t.left,s=t.top,o=t.right,l=t.gap;return void 0===n&&(n="margin"),"\n .".concat("with-scroll-bars-hidden"," {\n overflow: hidden ").concat(i,";\n padding-right: ").concat(l,"px ").concat(i,";\n }\n body[").concat(tk,"] {\n overflow: hidden ").concat(i,";\n overscroll-behavior: contain;\n ").concat([r&&"position: relative ".concat(i,";"),"margin"===n&&"\n padding-left: ".concat(a,"px;\n padding-top: ").concat(s,"px;\n padding-right: ").concat(o,"px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(l,"px ").concat(i,";\n "),"padding"===n&&"padding-right: ".concat(l,"px ").concat(i,";")].filter(Boolean).join(""),"\n }\n \n .").concat(ts," {\n right: ").concat(l,"px ").concat(i,";\n }\n \n .").concat(to," {\n margin-right: ").concat(l,"px ").concat(i,";\n }\n \n .").concat(ts," .").concat(ts," {\n right: 0 ").concat(i,";\n }\n \n .").concat(to," .").concat(to," {\n margin-right: 0 ").concat(i,";\n }\n \n body[").concat(tk,"] {\n ").concat("--removed-body-scroll-bar-size",": ").concat(l,"px;\n }\n")},t_=function(){var t=parseInt(document.body.getAttribute(tk)||"0",10);return isFinite(t)?t:0},tA=function(){y.useEffect(function(){return document.body.setAttribute(tk,(t_()+1).toString()),function(){var t=t_()-1;t<=0?document.body.removeAttribute(tk):document.body.setAttribute(tk,t.toString())}},[])},tE=function(t){var r=t.noRelative,n=t.noImportant,i=t.gapMode,a=void 0===i?"margin":i;tA();var s=y.useMemo(function(){return tw(a)},[a]);return y.createElement(t$,{styles:tM(s,!r,a,n?"":"!important")})},tS=!1;if("u">typeof window)try{var tC=Object.defineProperty({},"passive",{get:function(){return tS=!0,!0}});window.addEventListener("test",tC,tC),window.removeEventListener("test",tC,tC)}catch(t){tS=!1}var tT=!!tS&&{passive:!1},tI=function(t,r){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return"hidden"!==n[r]&&(n.overflowY!==n.overflowX||"TEXTAREA"===t.tagName||"visible"!==n[r])},tN=function(t,r){var n=r.ownerDocument,i=r;do{if("u">typeof ShadowRoot&&i instanceof ShadowRoot&&(i=i.host),tO(t,i)){var a=tD(t,i);if(a[1]>a[2])return!0}i=i.parentNode}while(i&&i!==n.body);return!1},tO=function(t,r){return"v"===t?tI(r,"overflowY"):tI(r,"overflowX")},tD=function(t,r){return"v"===t?[r.scrollTop,r.scrollHeight,r.clientHeight]:[r.scrollLeft,r.scrollWidth,r.clientWidth]},tR=function(t,r,n,i,a){var s,o=(s=window.getComputedStyle(r).direction,"h"===t&&"rtl"===s?-1:1),l=o*i,c=n.target,d=r.contains(c),u=!1,h=l>0,f=0,p=0;do{if(!c)break;var g=tD(t,c),m=g[0],y=g[1]-g[2]-o*m;(m||y)&&tO(t,c)&&(f+=y,p+=m);var v=c.parentNode;c=v&&v.nodeType===Node.DOCUMENT_FRAGMENT_NODE?v.host:v}while(!d&&c!==document.body||d&&(r.contains(c)||r===c));return h&&(a&&1>Math.abs(f)||!a&&l>f)?u=!0:!h&&(a&&1>Math.abs(p)||!a&&-l>p)&&(u=!0),u},tL=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},tz=function(t){return[t.deltaX,t.deltaY]},tP=function(t){return t&&"current"in t?t.current:t},tj=0,tF=[];let tB=(u=function(t){var r=y.useRef([]),n=y.useRef([0,0]),i=y.useRef(),a=y.useState(tj++)[0],s=y.useState(ty)[0],o=y.useRef(t);y.useEffect(function(){o.current=t},[t]),y.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(a));var r=(function(t,r,n){if(n||2==arguments.length)for(var i,a=0,s=r.length;a<s;a++)!i&&a in r||(i||(i=Array.prototype.slice.call(r,0,a)),i[a]=r[a]);return t.concat(i||Array.prototype.slice.call(r))})([t.lockRef.current],(t.shards||[]).map(tP),!0).filter(Boolean);return r.forEach(function(t){return t.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),r.forEach(function(t){return t.classList.remove("allow-interactivity-".concat(a))})}}},[t.inert,t.lockRef.current,t.shards]);var l=y.useCallback(function(t,r){if("touches"in t&&2===t.touches.length||"wheel"===t.type&&t.ctrlKey)return!o.current.allowPinchZoom;var a,s=tL(t),l=n.current,c="deltaX"in t?t.deltaX:l[0]-s[0],d="deltaY"in t?t.deltaY:l[1]-s[1],u=t.target,h=Math.abs(c)>Math.abs(d)?"h":"v";if("touches"in t&&"h"===h&&"range"===u.type)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var g=tN(h,u);if(!g)return!0;if(g?a=h:(a="v"===h?"h":"v",g=tN(h,u)),!g)return!1;if(!i.current&&"changedTouches"in t&&(c||d)&&(i.current=a),!a)return!0;var m=i.current||a;return tR(m,r,t,"h"===m?c:d,!0)},[]),c=y.useCallback(function(t){if(tF.length&&tF[tF.length-1]===s){var n="deltaY"in t?tz(t):tL(t),i=r.current.filter(function(r){var i;return r.name===t.type&&(r.target===t.target||t.target===r.shadowParent)&&(i=r.delta,i[0]===n[0]&&i[1]===n[1])})[0];if(i&&i.should){t.cancelable&&t.preventDefault();return}if(!i){var a=(o.current.shards||[]).map(tP).filter(Boolean).filter(function(r){return r.contains(t.target)});(a.length>0?l(t,a[0]):!o.current.noIsolation)&&t.cancelable&&t.preventDefault()}}},[]),d=y.useCallback(function(t,n,i,a){var s={name:t,delta:n,target:i,should:a,shadowParent:function(t){for(var r=null;null!==t;)t instanceof ShadowRoot&&(r=t.host,t=t.host),t=t.parentNode;return r}(i)};r.current.push(s),setTimeout(function(){r.current=r.current.filter(function(t){return t!==s})},1)},[]),u=y.useCallback(function(t){n.current=tL(t),i.current=void 0},[]),h=y.useCallback(function(r){d(r.type,tz(r),r.target,l(r,t.lockRef.current))},[]),f=y.useCallback(function(r){d(r.type,tL(r),r.target,l(r,t.lockRef.current))},[]);y.useEffect(function(){return tF.push(s),t.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:f}),document.addEventListener("wheel",c,tT),document.addEventListener("touchmove",c,tT),document.addEventListener("touchstart",u,tT),function(){tF=tF.filter(function(t){return t!==s}),document.removeEventListener("wheel",c,tT),document.removeEventListener("touchmove",c,tT),document.removeEventListener("touchstart",u,tT)}},[]);var p=t.removeScrollBar,g=t.inert;return y.createElement(y.Fragment,null,g?y.createElement(s,{styles:"\n .block-interactivity-".concat(a," {pointer-events: none;}\n .allow-interactivity-").concat(a," {pointer-events: all;}\n")}):null,p?y.createElement(tE,{noRelative:t.noRelative,gapMode:t.gapMode}):null)},tu.useMedium(u),tp);var tW=y.forwardRef(function(t,r){return y.createElement(tf,ti({},t,{ref:r,sideCar:tB}))});tW.classNames=tf.classNames;var tH=new WeakMap,tU=new WeakMap,tq={},tV=0,tY=function(t){return t&&(t.host||tY(t.parentNode))},tG=function(t,r,n,i){var a=(Array.isArray(t)?t:[t]).map(function(t){if(r.contains(t))return t;var n=tY(t);return n&&r.contains(n)?n:(console.error("aria-hidden",t,"in not contained inside",r,". Doing nothing"),null)}).filter(function(t){return!!t});tq[n]||(tq[n]=new WeakMap);var s=tq[n],o=[],l=new Set,c=new Set(a),d=function(t){!t||l.has(t)||(l.add(t),d(t.parentNode))};a.forEach(d);var u=function(t){!t||c.has(t)||Array.prototype.forEach.call(t.children,function(t){if(l.has(t))u(t);else try{var r=t.getAttribute(i),a=null!==r&&"false"!==r,c=(tH.get(t)||0)+1,d=(s.get(t)||0)+1;tH.set(t,c),s.set(t,d),o.push(t),1===c&&a&&tU.set(t,!0),1===d&&t.setAttribute(n,"true"),a||t.setAttribute(i,"true")}catch(r){console.error("aria-hidden: cannot operate on ",t,r)}})};return u(r),l.clear(),tV++,function(){o.forEach(function(t){var r=tH.get(t)-1,a=s.get(t)-1;tH.set(t,r),s.set(t,a),r||(tU.has(t)||t.removeAttribute(i),tU.delete(t)),a||t.removeAttribute(n)}),--tV||(tH=new WeakMap,tH=new WeakMap,tU=new WeakMap,tq={})}},tZ=function(t,r,n){void 0===n&&(n="data-aria-hidden");var i=Array.from(Array.isArray(t)?t:[t]),a=r||("u"<typeof document?null:(Array.isArray(t)?t[0]:t).ownerDocument.body);return a?(i.push.apply(i,Array.from(a.querySelectorAll("[aria-live], script"))),tG(i,a,n,"aria-hidden")):function(){return null}},tX=Object.defineProperty,tK=(t,r)=>tX(t,"name",{value:r,configurable:!0}),tJ="Dialog",[tQ,t0]=O(tJ),[t1,t2]=tQ(tJ),t4=tK(t=>{let{__scopeDialog:r,children:n,open:i,defaultOpen:a,onOpenChange:s,modal:o=!0}=t,l=y.useRef(null),c=y.useRef(null),{nodes:d,registry:u}=ej(),[h,f]=Y({prop:i,defaultProp:a??!1,onChange:s,caller:tJ}),[p,g]=y.useState(0),[m,v]=y.useState(0);return(0,T.jsx)(t1,{scope:r,triggerRef:l,contentRef:c,contentId:j(),titleId:j(),descriptionId:j(),titlePresent:p>0,descriptionPresent:m>0,setTitleCount:g,setDescriptionCount:v,open:h,onOpenChange:f,onOpenToggle:y.useCallback(()=>f(t=>!t),[f]),modal:o,branchNodes:d,branchRegistry:u,children:n})},"Dialog"),t3="DialogPortal",[t5,t6]=tQ(t3,{forceMount:void 0}),t8=tK(t=>{let{__scopeDialog:r,forceMount:n,children:i,container:a}=t,s=t2(t3,r);return(0,T.jsx)(t5,{scope:r,forceMount:n,children:y.Children.map(i,t=>(0,T.jsx)(e2,{present:n||s.open,children:(0,T.jsx)(eJ,{asChild:!0,container:a,children:t})}))})},"DialogPortal"),t9="DialogOverlay",t7=y.forwardRef(tK(function(t,r){let n=t6(t9,t.__scopeDialog),{forceMount:i=n.forceMount,...a}=t,s=t2(t9,t.__scopeDialog);return s.modal?(0,T.jsx)(e2,{present:i||s.open,children:(0,T.jsx)(rt,{...a,ref:r})}):null},"DialogOverlay")),re=ee("DialogOverlay.RemoveScroll"),rt=y.forwardRef(tK(function(t,r){let{__scopeDialog:n,...i}=t,a=t2(t9,n),s=C(r,e_());return(0,T.jsx)(tW,{as:re,allowPinchZoom:!0,shards:y.useMemo(()=>[a.contentRef,...a.branchNodes.map(t=>({current:t}))],[a.contentRef,a.branchNodes]),children:(0,T.jsx)(eg.div,{"data-state":rl(a.open),...i,ref:s,style:{pointerEvents:"auto",...i.style}})})},"DialogOverlayImpl")),rr="DialogContent",rn=y.forwardRef(tK(function(t,r){let n=t6(rr,t.__scopeDialog),{forceMount:i=n.forceMount,...a}=t,s=t2(rr,t.__scopeDialog);return(0,T.jsx)(e2,{present:i||s.open,children:s.modal?(0,T.jsx)(ri,{...a,ref:r}):(0,T.jsx)(ra,{...a,ref:r})})},"DialogContent")),ri=y.forwardRef(tK(function(t,r){let n=t2(rr,t.__scopeDialog),i=y.useRef(null),a=C(r,n.contentRef,i);return y.useEffect(()=>{let t=i.current;if(t)return tZ(t)},[]),(0,T.jsx)(rs,{...t,ref:a,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:$(t.onCloseAutoFocus,t=>{t.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:$(t.onPointerDownOutside,t=>{let r=t.detail.originalEvent,n=0===r.button&&!0===r.ctrlKey;(2===r.button||n)&&t.preventDefault()}),onFocusOutside:$(t.onFocusOutside,t=>t.preventDefault())})},"DialogContentModal")),ra=y.forwardRef(tK(function(t,r){let n=t2(rr,t.__scopeDialog),i=y.useRef(!1),a=y.useRef(!1);return(0,T.jsx)(rs,{...t,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:r=>{t.onCloseAutoFocus?.(r),r.defaultPrevented||(i.current||n.triggerRef.current?.focus(),r.preventDefault()),i.current=!1,a.current=!1},onInteractOutside:r=>{t.onInteractOutside?.(r),r.defaultPrevented||(i.current=!0,"pointerdown"===r.detail.originalEvent.type&&(a.current=!0));let s=r.target;n.triggerRef.current?.contains(s)&&r.preventDefault(),"focusin"===r.detail.originalEvent.type&&a.current&&r.preventDefault()}})},"DialogContentNonModal")),rs=y.forwardRef(tK(function(t,r){let{__scopeDialog:n,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:s,"aria-describedby":o,children:l,...c}=t,d=t2(rr,n);return tr(),(0,T.jsx)(eP,{registry:d.branchRegistry,children:(0,T.jsx)(eL,{asChild:!0,loop:!0,trapped:i,branches:d.branchNodes,onMountAutoFocus:a,onUnmountAutoFocus:s,children:(0,T.jsx)(eM,{role:"dialog",id:d.contentId,"aria-labelledby":d.titlePresent?d.titleId:void 0,"aria-describedby":d.descriptionPresent?ro(o,d.descriptionId):o,"data-state":rl(d.open),...c,ref:r,deferPointerDownOutside:!0,onDismiss:()=>d.onOpenChange(!1),children:l})})})},"DialogContentImpl"));function ro(...t){let r=new Set;for(let n of t)if("string"==typeof n)for(let t of String(n).trim().split(/\s+/))t&&r.add(t);return r.size>0?Array.from(r).join(" "):void 0}function rl(t){return t?"open":"closed"}tK(ro,"concatAriaDescribedby"),tK(rl,"getState");var rc='[cmdk-group=""]',rd='[cmdk-group-items=""]',ru='[cmdk-item=""]',rh=`${ru}:not([aria-disabled="true"])`,rf="cmdk-item-select",rp="data-value",rg=(t,r,n)=>{var i;return i=t,function t(r,n,i,a,s,o,l){if(o===n.length)return s===r.length?1:.99;var c=`${s},${o}`;if(void 0!==l[c])return l[c];for(var d,u,m,y,v=a.charAt(o),b=i.indexOf(v,s),x=0;b>=0;)(d=t(r,n,i,a,b+1,o+1,l))>x&&(b===s?d*=1:h.test(r.charAt(b-1))?(d*=.8,(m=r.slice(s,b-1).match(f))&&s>0&&(d*=Math.pow(.999,m.length))):p.test(r.charAt(b-1))?(d*=.9,(y=r.slice(s,b-1).match(g))&&s>0&&(d*=Math.pow(.999,y.length))):(d*=.17,s>0&&(d*=Math.pow(.999,b-s))),r.charAt(b)!==n.charAt(o)&&(d*=.9999)),(d<.1&&i.charAt(b-1)===a.charAt(o+1)||a.charAt(o+1)===a.charAt(o)&&i.charAt(b-1)!==a.charAt(o))&&.1*(u=t(r,n,i,a,b+1,o+2,l))>d&&(d=.1*u),d>x&&(x=d),b=i.indexOf(v,b+1);return l[c]=x,x}(i=n&&n.length>0?`${i+" "+n.join(" ")}`:i,r,m(i),m(r),0,0,{})},rm=y.createContext(void 0),ry=y.createContext(void 0),rv=y.createContext(void 0),rb=y.forwardRef((t,r)=>{let n=rC(()=>{var r,n;return{search:"",value:null!=(n=null!=(r=t.value)?r:t.defaultValue)?n:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),i=rC(()=>new Set),a=rC(()=>new Map),s=rC(()=>new Map),o=rC(()=>new Set),l=rE(t),{label:c,children:d,value:u,onValueChange:h,filter:f,shouldFilter:p,loop:g,disablePointerSelection:m=!1,vimBindings:v=!0,...b}=t,x=j(),w=j(),$=j(),k=y.useRef(null),M=rN();rS(()=>{if(void 0!==u){let t=u.trim();n.current.value=t,_.emit()}},[u]),rS(()=>{M(6,I)},[]);let _=y.useMemo(()=>({subscribe:t=>(o.current.add(t),()=>o.current.delete(t)),snapshot:()=>n.current,setState:(t,r,i)=>{var a,s,o,c;if(!Object.is(n.current[t],r)){if(n.current[t]=r,"search"===t)T(),S(),M(1,C);else if("value"===t){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let t=document.getElementById($);t?t.focus():null==(a=document.getElementById(x))||a.focus()}if(M(7,()=>{var t;n.current.selectedItemId=null==(t=N())?void 0:t.id,_.emit()}),i||M(5,I),(null==(s=l.current)?void 0:s.value)!==void 0){null==(c=(o=l.current).onValueChange)||c.call(o,null!=r?r:"");return}}_.emit()}},emit:()=>{o.current.forEach(t=>t())}}),[]),A=y.useMemo(()=>({value:(t,r,i)=>{var a;r!==(null==(a=s.current.get(t))?void 0:a.value)&&(s.current.set(t,{value:r,keywords:i}),n.current.filtered.items.set(t,E(r,i)),M(2,()=>{S(),_.emit()}))},item:(t,r)=>(i.current.add(t),r&&(a.current.has(r)?a.current.get(r).add(t):a.current.set(r,new Set([t]))),M(3,()=>{T(),S(),n.current.value||C(),_.emit()}),()=>{s.current.delete(t),i.current.delete(t),n.current.filtered.items.delete(t);let r=N();M(4,()=>{T(),(null==r?void 0:r.getAttribute("id"))===t&&C(),_.emit()})}),group:t=>(a.current.has(t)||a.current.set(t,new Set),()=>{s.current.delete(t),a.current.delete(t)}),filter:()=>l.current.shouldFilter,label:c||t["aria-label"],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:x,inputId:$,labelId:w,listInnerRef:k}),[]);function E(t,r){var i,a;let s=null!=(a=null==(i=l.current)?void 0:i.filter)?a:rg;return t?s(t,n.current.search,r):0}function S(){if(!n.current.search||!1===l.current.shouldFilter)return;let t=n.current.filtered.items,r=[];n.current.filtered.groups.forEach(n=>{let i=a.current.get(n),s=0;i.forEach(r=>{s=Math.max(t.get(r),s)}),r.push([n,s])});let i=k.current;O().sort((r,n)=>{var i,a;let s=r.getAttribute("id"),o=n.getAttribute("id");return(null!=(i=t.get(o))?i:0)-(null!=(a=t.get(s))?a:0)}).forEach(t=>{let r=t.closest(rd);r?r.appendChild(t.parentElement===r?t:t.closest(`${rd} > *`)):i.appendChild(t.parentElement===i?t:t.closest(`${rd} > *`))}),r.sort((t,r)=>r[1]-t[1]).forEach(t=>{var r;let n=null==(r=k.current)?void 0:r.querySelector(`${rc}[${rp}="${encodeURIComponent(t[0])}"]`);null==n||n.parentElement.appendChild(n)})}function C(){let t=O().find(t=>"true"!==t.getAttribute("aria-disabled")),r=null==t?void 0:t.getAttribute(rp);_.setState("value",r||void 0)}function T(){var t,r,o,c;if(!n.current.search||!1===l.current.shouldFilter){n.current.filtered.count=i.current.size;return}n.current.filtered.groups=new Set;let d=0;for(let a of i.current){let i=E(null!=(r=null==(t=s.current.get(a))?void 0:t.value)?r:"",null!=(c=null==(o=s.current.get(a))?void 0:o.keywords)?c:[]);n.current.filtered.items.set(a,i),i>0&&d++}for(let[t,r]of a.current)for(let i of r)if(n.current.filtered.items.get(i)>0){n.current.filtered.groups.add(t);break}n.current.filtered.count=d}function I(){var t,r,n;let i=N();i&&((null==(t=i.parentElement)?void 0:t.firstChild)===i&&(null==(n=null==(r=i.closest(rc))?void 0:r.querySelector('[cmdk-group-heading=""]'))||n.scrollIntoView({block:"nearest"})),i.scrollIntoView({block:"nearest"}))}function N(){var t;return null==(t=k.current)?void 0:t.querySelector(`${ru}[aria-selected="true"]`)}function O(){var t;return Array.from((null==(t=k.current)?void 0:t.querySelectorAll(rh))||[])}function D(t){let r=O()[t];r&&_.setState("value",r.getAttribute(rp))}function R(t){var r;let n=N(),i=O(),a=i.findIndex(t=>t===n),s=i[a+t];null!=(r=l.current)&&r.loop&&(s=a+t<0?i[i.length-1]:a+t===i.length?i[0]:i[a+t]),s&&_.setState("value",s.getAttribute(rp))}function L(t){let r=N(),n=null==r?void 0:r.closest(rc),i;for(;n&&!i;)i=null==(n=t>0?function(t,r){let n=t.nextElementSibling;for(;n;){if(n.matches(r))return n;n=n.nextElementSibling}}(n,rc):function(t,r){let n=t.previousElementSibling;for(;n;){if(n.matches(r))return n;n=n.previousElementSibling}}(n,rc))?void 0:n.querySelector(rh);i?_.setState("value",i.getAttribute(rp)):R(t)}let z=()=>D(O().length-1),P=t=>{t.preventDefault(),t.metaKey?z():t.altKey?L(1):R(1)},F=t=>{t.preventDefault(),t.metaKey?D(0):t.altKey?L(-1):R(-1)};return y.createElement(eg.div,{ref:r,tabIndex:-1,...b,"cmdk-root":"",onKeyDown:t=>{var r;null==(r=b.onKeyDown)||r.call(b,t);let n=t.nativeEvent.isComposing||229===t.keyCode;if(!(t.defaultPrevented||n))switch(t.key){case"n":case"j":v&&t.ctrlKey&&P(t);break;case"ArrowDown":P(t);break;case"p":case"k":v&&t.ctrlKey&&F(t);break;case"ArrowUp":F(t);break;case"Home":t.preventDefault(),D(0);break;case"End":t.preventDefault(),z();break;case"Enter":{t.preventDefault();let r=N();if(r){let t=new Event(rf);r.dispatchEvent(t)}}}}},y.createElement("label",{"cmdk-label":"",htmlFor:A.inputId,id:A.labelId,style:rD},c),rO(t,t=>y.createElement(ry.Provider,{value:_},y.createElement(rm.Provider,{value:A},t))))}),rx=y.forwardRef((t,r)=>{var n,i;let a=j(),s=y.useRef(null),o=y.useContext(rv),l=y.useContext(rm),c=rE(t),d=null!=(i=null==(n=c.current)?void 0:n.forceMount)?i:null==o?void 0:o.forceMount;rS(()=>{if(!d)return l.item(a,null==o?void 0:o.id)},[d]);let u=rI(a,s,[t.value,t.children,s],t.keywords),h=y.useContext(ry),f=rT(t=>t.value&&t.value===u.current),p=rT(t=>!!d||!1===l.filter()||!t.search||t.filtered.items.get(a)>0);function g(){var t,r;m(),null==(r=(t=c.current).onSelect)||r.call(t,u.current)}function m(){h.setState("value",u.current,!0)}if(y.useEffect(()=>{let r=s.current;if(!(!r||t.disabled))return r.addEventListener(rf,g),()=>r.removeEventListener(rf,g)},[p,t.onSelect,t.disabled]),!p)return null;let{disabled:v,value:b,onSelect:x,forceMount:w,keywords:$,...k}=t;return y.createElement(eg.div,{ref:S(s,r),...k,id:a,"cmdk-item":"",role:"option","aria-disabled":!!v,"aria-selected":!!f,"data-disabled":!!v,"data-selected":!!f,onPointerMove:v||l.getDisablePointerSelection()?void 0:m,onClick:v?void 0:g},t.children)}),rw=y.forwardRef((t,r)=>{let{heading:n,children:i,forceMount:a,...s}=t,o=j(),l=y.useRef(null),c=y.useRef(null),d=j(),u=y.useContext(rm),h=rT(t=>!!a||!1===u.filter()||!t.search||t.filtered.groups.has(o));rS(()=>u.group(o),[]),rI(o,l,[t.value,t.heading,c]);let f=y.useMemo(()=>({id:o,forceMount:a}),[a]);return y.createElement(eg.div,{ref:S(l,r),...s,"cmdk-group":"",role:"presentation",hidden:!h||void 0},n&&y.createElement("div",{ref:c,"cmdk-group-heading":"","aria-hidden":!0,id:d},n),rO(t,t=>y.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?d:void 0},y.createElement(rv.Provider,{value:f},t))))}),r$=y.forwardRef((t,r)=>{let{alwaysRender:n,...i}=t,a=y.useRef(null),s=rT(t=>!t.search);return n||s?y.createElement(eg.div,{ref:S(a,r),...i,"cmdk-separator":"",role:"separator"}):null}),rk=y.forwardRef((t,r)=>{let{onValueChange:n,...i}=t,a=null!=t.value,s=y.useContext(ry),o=rT(t=>t.search),l=rT(t=>t.selectedItemId),c=y.useContext(rm);return y.useEffect(()=>{null!=t.value&&s.setState("search",t.value)},[t.value]),y.createElement(eg.input,{ref:r,...i,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":l,id:c.inputId,type:"text",value:a?t.value:o,onChange:t=>{a||s.setState("search",t.target.value),null==n||n(t.target.value)}})}),rM=y.forwardRef((t,r)=>{let{children:n,label:i="Suggestions",...a}=t,s=y.useRef(null),o=y.useRef(null),l=rT(t=>t.selectedItemId),c=y.useContext(rm);return y.useEffect(()=>{if(o.current&&s.current){let t=o.current,r=s.current,n,i=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=t.offsetHeight;r.style.setProperty("--cmdk-list-height",n.toFixed(1)+"px")})});return i.observe(t),()=>{cancelAnimationFrame(n),i.unobserve(t)}}},[]),y.createElement(eg.div,{ref:S(s,r),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":l,"aria-label":i,id:c.listId},rO(t,t=>y.createElement("div",{ref:S(o,c.listInnerRef),"cmdk-list-sizer":""},t)))}),r_=y.forwardRef((t,r)=>{let{open:n,onOpenChange:i,overlayClassName:a,contentClassName:s,container:o,...l}=t;return y.createElement(t4,{open:n,onOpenChange:i},y.createElement(t8,{container:o},y.createElement(t7,{"cmdk-overlay":"",className:a}),y.createElement(rn,{"aria-label":t.label,"cmdk-dialog":"",className:s},y.createElement(rb,{ref:r,...l}))))}),rA=Object.assign(rb,{List:rM,Item:rx,Input:rk,Group:rw,Separator:r$,Dialog:r_,Empty:y.forwardRef((t,r)=>rT(t=>0===t.filtered.count)?y.createElement(eg.div,{ref:r,...t,"cmdk-empty":"",role:"presentation"}):null),Loading:y.forwardRef((t,r)=>{let{progress:n,children:i,label:a="Loading...",...s}=t;return y.createElement(eg.div,{ref:r,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},rO(t,t=>y.createElement("div",{"aria-hidden":!0},t)))})});function rE(t){let r=y.useRef(t);return rS(()=>{r.current=t}),r}var rS="u"<typeof window?y.useEffect:y.useLayoutEffect;function rC(t){let r=y.useRef();return void 0===r.current&&(r.current=t()),r}function rT(t){let r=y.useContext(ry),n=()=>t(r.snapshot());return y.useSyncExternalStore(r.subscribe,n,n)}function rI(t,r,n,i=[]){let a=y.useRef(),s=y.useContext(rm);return rS(()=>{var o;let l=(()=>{var t;for(let r of n){if("string"==typeof r)return r.trim();if("object"==typeof r&&"current"in r)return r.current?null==(t=r.current.textContent)?void 0:t.trim():a.current}})(),c=i.map(t=>t.trim());s.value(t,l,c),null==(o=r.current)||o.setAttribute(rp,l),a.current=l}),a}var rN=()=>{let[t,r]=y.useState(),n=rC(()=>new Map);return rS(()=>{n.current.forEach(t=>t()),n.current=new Map},[t]),(t,i)=>{n.current.set(t,i),r({})}};function rO({asChild:t,children:r},n){let i;return t&&y.isValidElement(r)?y.cloneElement("function"==typeof(i=r.type)?i(r.props):"render"in i?i.render(r.props):r,{ref:r.ref},n(r.props.children)):n(r)}var rD={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"}},1431(t,r,n){n.d(r,{XX:()=>td});var i=[["flowchart","flowchart-elk",/^\s*flowchart-elk/],["mindmap","mindmap",/^\s*mindmap/],["architecture","architecture",/^\s*architecture/],["agentflow","agentflow",/^\s*agentflow-beta\b/],["c4","c4",/^\s*(?:C4Context|C4Container|C4Component|C4Dynamic|C4Deployment)/],["kanban","kanban",/^\s*kanban/],["class","classDiagram",/^\s*classDiagram/],["er","er",/^\s*erDiagram/],["gantt","gantt",/^\s*gantt/],["info","info",/^\s*info/],["pie","pie",/^\s*pie/],["requirement","requirement",/^\s*requirement(Diagram)?/],["sequence","sequence",/^\s*sequenceDiagram/],["swimlane","swimlane",/^\s*swimlane-beta\b/],["flowchart","flowchart-v2",/^\s*(graph|flowchart)/],["timeline","timeline",/^\s*timeline/],["gitGraph","gitGraph",/^\s*gitGraph/],["state","stateDiagram",/^\s*stateDiagram/],["journey","journey",/^\s*journey/],["quadrantChart","quadrantChart",/^\s*quadrantChart/],["sankey","sankey",/^\s*sankey(-beta)?/],["packet","packet",/^\s*packet(-beta)?/],["xychart","xychart",/^\s*xychart(-beta)?/],["block","block",/^\s*block(-beta)?/],["eventmodeling","eventmodeling",/^\s*eventmodeling/],["treeView","treeView",/^\s*treeView-beta/],["radar","radar",/^\s*radar-beta/],["ishikawa","ishikawa",/^\s*ishikawa(-beta)?\b/i],["treemap","treemap",/^\s*treemap/],["railroad","railroad",/^\s*railroad-beta/i],["railroad","railroadEbnf",/^\s*railroad-ebnf-beta/i],["railroad","railroadAbnf",/^\s*railroad-abnf-beta/i],["railroad","railroadPeg",/^\s*railroad-peg-beta/i],["venn","venn",/^\s*venn-beta/],["wardley","wardley",/^\s*wardley-beta/i],["cynefin","cynefin",/^\s*cynefin-beta(?:[\s:]|$)/],["usecase","usecase",/^\s*usecase-beta(?:\s|$)/]],a=class extends Error{code;type;mermaidType;line;column;snippet;constructor(t,r="syntax",n={}){super(t),this.name="PeleError",this.code=r,this.type=n.type??null,this.mermaidType=n.mermaidType??null,this.line=n.line??0,this.column=n.column??0,this.snippet=n.snippet??""}};function s(t,r,n){return Array.from(t.matchAll(r),t=>[t.index,t.index+t[0].length,n])}function o(t,r){for(let n=t.length-1;n>=0;n--)r=function(t,r){let n=0;for(let[i,a,s]of t){let t=i-n;if(r<t)break;if(r<t+s)return i+Math.min(r-t,a-i-1);n+=a-i-s}return r+n}(t[n],r);return r}function l(t,r){return void 0!==v&&t===v.parsed?v.find(r):[t,r]}function c(t,r){let n=t.trimEnd().length;n>0&&r>=n?([t,r]=l(t,n-1),r++):[t,r]=l(t,r);let i=1,a=0;for(let n=t.indexOf(`
|
|
4
|
+
`);-1!==n&&n<r;n=t.indexOf(`
|
|
5
|
+
`,n+1))i++,a=n+1;let s=t.indexOf(`
|
|
6
|
+
`,r);-1===s&&(s=t.length);let o=r-a+1;return{line:i,column:o,snippet:t.slice(a,s)+`
|
|
7
|
+
`+"-".repeat(o-1)+"^"}}function d(t,r,n,i,s=!1){let o=c(r,n),l=s?`Lexical error on line ${o.line}. Unrecognized text.`:`Parse error on line ${o.line}:`;return new a(s?`${l}
|
|
8
|
+
${o.snippet}`:`${l}
|
|
9
|
+
${o.snippet}
|
|
10
|
+
${i}`,"syntax",{type:t,...o})}function u(t,r){return t>0&&t<=1114111&&(t<55296||t>57343)?String.fromCodePoint(t):r}var h=/&(?:#(\d+)|#[xX]([0-9a-fA-F]+)|(\w+));/g,f="fl\xb0",p="\xb6\xdf",g=/fl°°?(\w+)¶ß/g;function m(t){return t.includes(p)?t.replace(g,"#$1;"):t}function y(t){return t.includes(p)&&(t=function(t){let r="",n=0,i=t.indexOf(f);for(;-1!==i;){let a=t.indexOf("\xb6",i+2);if(-1===a)break;if("\xdf"===t[a+1]){let s="\xb0"===t[i+2];r+=t.slice(n,i)+(s?"&#":"&")+t.slice(i+(s?3:2),a)+";",n=a+2}i=t.indexOf(f,a+1)}return 0===n?t:r+t.slice(n)}(t)),t.includes("&")&&(t=t.replace(h,(t,r,n,i)=>r?u(Number(r),t):n?u(parseInt(n,16),t):function(t){if(!b)for(let t of(b=new Map,"amp:38,lt:60,gt:62,quot:34,apos:39,nbsp:160,shy:173,iexcl:161,cent:162,pound:163,curren:164,yen:165,sect:167,copy:169,laquo:171,not:172,reg:174,deg:176,plusmn:177,sup2:178,sup3:179,micro:181,para:182,middot:183,sup1:185,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,euro:8364,trade:8482,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,radic:8730,infin:8734,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830,check:10003,cross:10007,AMP:38,LT:60,GT:62,QUOT:34,lsqb:91,rsqb:93,lcub:123,rcub:125,verbar:124,VerticalLine:124,midast:42,DiacriticalGrave:96,Hat:94,UnderBar:95,equals:61,colon:58,semi:59,num:35,percnt:37,lpar:40,rpar:41,lbrack:91,rbrack:93,lbrace:123,rbrace:125,vert:124,sol:47,bsol:92,quest:63,excl:33,ast:42,plus:43,comma:44,period:46,dollar:36,commat:64,grave:96,hat:94,lowbar:95,tilde:126,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969".split(","))){let r=t.indexOf(":");b.set(t.slice(0,r),String.fromCodePoint(Number(t.slice(r+1))))}return b.get(t)}(i)??t)),t}var v,b,x,w=new Map;function $(t){if(void 0===x)return"";let r=w.get(t);return void 0===r&&(r=x(t)??"",w.set(t,r)),r}var k,M=new Map;function _(t){return Number.isFinite(t)&&t>0}var A=class{constructor(t){this.message=t}message};function E(t,r,n){"__proto__"===r?Object.defineProperty(t,r,{value:n,enumerable:!0,writable:!0,configurable:!0}):t[r]=n}var S=class{lines;i=0;constructor(t){this.lines=(t.includes("\r")?t.replace(/\r\n?/g,`
|
|
11
|
+
`):t).split(`
|
|
12
|
+
`)}skipBlank(){for(;this.i<this.lines.length;){let t=this.lines[this.i].trim();if(""!==t&&"#"!==t[0]&&"---"!==t)break;this.i++}}indent(){let t=this.lines[this.i],r=0;for(;r<t.length&&" "===t[r];)r++;if(" "===t[r])throw Error("YAML: tabs are not allowed for indentation");return r}},C=/^[-+]?(?:0|[1-9][0-9]*)$/,T=/^[-+]?0x[0-9a-fA-F]+$/,I=/^[-+]?0o[0-7]+$/,N=/^[-+]?0b[01]+$/,O=/^[-+]?(?:[0-9][0-9]*(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][-+]?[0-9]+)?$/,D=/[\s#:,[\]{}&*!|>'"%@`]/;function R(t){return" "===t||" "===t||t===`
|
|
13
|
+
`||"\r"===t}function L(t){let r=t[0],n,i;if('"'===r||"'"===r){let a=1;for(;;){if(a>=t.length)return null;let n=t[a];if('"'===r&&"\\"===n)a+=2;else if(n===r){if('"'===r||"'"!==t[a+1])break;a+=2}else a++}for(i=n=a+1;R(t[i]);)i++;if(":"!==t[i])return null}else{if(void 0===r||D.test(r)||"-"===r&&(t.length<2||R(t[1])||":"===t[1]||"#"===t[1]))return null;for(i=1;i<t.length&&":"!==t[i]&&"#"!==t[i];)i++;if(":"!==t[i])return null;for(n=i;R(t[n-1]);)n--}let a=i+1;if(a<t.length&&!R(t[a]))return null;for(;R(t[a]);)a++;return{key:t.slice(0,n),length:a}}function z(t){let r=t.trim();if(""===r||"~"===r||"null"===r||"Null"===r||"NULL"===r)return null;if("true"===r||"True"===r||"TRUE"===r)return!0;if("false"===r||"False"===r||"FALSE"===r)return!1;let n=r[0];if("-"!==n&&"+"!==n&&"."!==n&&(n<"0"||n>"9"))return r;if(C.test(r)||O.test(r))return Number(r);if(T.test(r)||I.test(r)||N.test(r)){let t="-"===r[0],n=Number(t||"+"===r[0]?r.slice(1):r);return t?-n:n}return/^[-+]?\.(?:inf|Inf|INF)$/.test(r)?"-"===r[0]?-1/0:1/0:/^\.(?:nan|NaN|NAN)$/.test(r)?NaN:r}var P={0:"\0",a:"\x07",b:"\b",t:" ",n:`
|
|
14
|
+
`,v:"\v",f:"\f",r:"\r",e:"\x1b"," ":" ",'"':'"',"/":"/","\\":"\\",N:"\x85",_:"\xa0",L:"\u2028",P:"\u2029"};function j(t){if(!t.includes(`
|
|
15
|
+
`))return t;let r=t.split(`
|
|
16
|
+
`),n=r.length-1;for(let t=0;t<=n;t++){let i=r[t],a=0,s=i.length;if(t>0)for(;a<s&&(32===i.charCodeAt(a)||9===i.charCodeAt(a));)a++;if(t<n)for(;s>a&&(32===i.charCodeAt(s-1)||9===i.charCodeAt(s-1));)s--;r[t]=i.slice(a,s)}return r.join(`
|
|
17
|
+
`).replace(/\n+/g,t=>1===t.length?" ":`
|
|
18
|
+
`.repeat(t.length-1))}function F(t,r,n){for(;r<t.length;){let i=t[r];if(" "===i||i===`
|
|
19
|
+
`||" "===i||"\r"===i||n&&","===i)r++;else if("#"===i&&(0===r||/\s/.test(t[r-1]))){let n=t.indexOf(`
|
|
20
|
+
`,r);r=-1===n?t.length:n}else break}return r}function B(t,r){if(!r)throw Error("YAML: missed comma between flow collection entries");if(","===t)throw Error("YAML: expected the node content, but found ','")}function W(t,r,n,i=0){if(i>64)throw Error("YAML: nesting is too deep");r=F(t,r,!1);let a=t[r];if("{"===a){let n={};r++;let a=!0;for(;;){let s;if((r=F(t,r,!1))>=t.length)throw new A("YAML: unexpected end of the stream within a flow collection");if("}"===t[r])return[n,r+1];B(t[r],a),[s,r]=W(t,r,":,}",i+1),r=F(t,r,!1);let o=null;":"===t[r]&&([o,r]=W(t,r+1,",}",i+1)),E(n,String(s),o),r=F(t,r,!1),(a=","===t[r])&&r++}}if("["===a){let n=[];r++;let a=!0;for(;;){let s;if((r=F(t,r,!1))>=t.length)throw new A("YAML: unexpected end of the stream within a flow collection");if("]"===t[r])return[n,r+1];B(t[r],a),[s,r]=W(t,r,",]",i+1),n.push(s),r=F(t,r,!1),(a=","===t[r])&&r++}}if('"'===a){let n=r+1;for(;n<t.length&&'"'!==t[n];)n+="\\"===t[n]?2:1;if(n>=t.length)throw new A("YAML: unexpected end of the stream within a double quoted scalar");return[function(t){if(!t.includes("\\"))return j(t);let r="",n=j(t.replace(/\\\n[ \t]*/g,""));for(let t=0;t<n.length;t++){let i=n[t];if("\\"!==i){r+=i;continue}let a=n[++t];if("x"===a||"u"===a||"U"===a){let i="x"===a?2:"u"===a?4:8;r+=String.fromCodePoint(parseInt(n.slice(t+1,t+1+i),16)),t+=i}else if(a in P)r+=P[a];else throw Error("YAML: unknown escape sequence")}return r}(t.slice(r+1,n)),n+1]}if("'"===a){let n=r+1;for(;n<t.length;){if("'"===t[n]){if("'"!==t[n+1])break;n++}n++}if(n>=t.length)throw new A("YAML: unexpected end of the stream within a single quoted scalar");return[j(t.slice(r+1,n)).replace(/''/g,"'"),n+1]}let s=r;for(;s<t.length;){let i=t[s];if(n.includes(i)&&(":"!==i||s+1>=t.length||/[\s,[\]{}]/.test(t[s+1])))break;if("#"===i&&s>r&&/\s/.test(t[s-1])){let n=t.indexOf(`
|
|
21
|
+
`,s);return[z(j(t.slice(r,s).trim())),-1===n?t.length:n]}s++}return[z(j(t.slice(r,s).trim())),s]}function H(t){let r="";for(let n=0;n<t.length;n++){let i=t[n];if(r)"\\"===i&&'"'===r?n++:i===r&&(r="");else if('"'===i||"'"===i)r=i;else if("#"===i&&(0===n||" "===t[n-1]||" "===t[n-1]))return t.slice(0,n)}return t}function U(t,r,n){let i=r[0];if(("|"===i||">"===i)&&/^[|>][-+0-9]*\s*(?:#.*)?$/.test(r))return function(t,r,n){let i,a=">"===r[0],s=r.includes("-")?"-":r.includes("+")?"+":"",o=/[1-9]/.exec(r),l=o?n+Number(o[0]):-1,c=[];for(;t.i<t.lines.length;){let r=t.lines[t.i];if(""===r.trim()){c.push(""),t.i++;continue}let i=r.length-r.trimStart().length;if(-1===l){if(i<=n)break;l=i}if(i<l)break;c.push(r.slice(l)),t.i++}let d=0;for(;c.length>0&&""===c[c.length-1];)c.pop(),d++;if(a){i="";for(let t=0;t<c.length;t++){let r=c[t];if(t>0){let n=c[t-1];""===r?i+=`
|
|
22
|
+
`:""!==n&&(i+=/^[ \t]/.test(n)||/^[ \t]/.test(r)?`
|
|
23
|
+
`:" ")}i+=r}}else i=c.join(`
|
|
24
|
+
`);return 0===c.length?"+"===s?`
|
|
25
|
+
`.repeat(d):"":"-"===s?i:"+"===s?i+`
|
|
26
|
+
`.repeat(d+1):i+`
|
|
27
|
+
`}(t,r,n);if("{"===i||"["===i||'"'===i||"'"===i){let n=t.i,i=r,a=0,s=1;for(;;)try{let[r,a]=W(i,0,""),s=0;for(let t=i.indexOf(`
|
|
28
|
+
`);-1!==t&&t<a;t=i.indexOf(`
|
|
29
|
+
`,t+1))s++;let o=i.indexOf(`
|
|
30
|
+
`,a);if(""!==H(i.slice(a,-1===o?i.length:o)).trim())throw Error("YAML: unexpected content after a value");return t.i=n+s,r}catch(o){if(!(o instanceof A))throw o;if(n+a>=t.lines.length)throw Error(o.message);let r=t.lines.slice(n+a,n+a+s);i+=`
|
|
31
|
+
`+r.join(`
|
|
32
|
+
`),a+=r.length,s*=2}}let a=H(r).trim();for(;t.i<t.lines.length;){let r=t.lines[t.i];if(""===r.trim()){let r=t.i;for(;r<t.lines.length&&""===t.lines[r].trim();)r++;if(r>=t.lines.length||t.lines[r].length-t.lines[r].trimStart().length<=n)break;a+=`
|
|
33
|
+
`.repeat(r-t.i),t.i=r;continue}if(r.length-r.trimStart().length<=n)break;let i=H(r).trim();a+=(a.endsWith(`
|
|
34
|
+
`)?"":" ")+i,t.i++}return z(a)}function q(t){let r=t.trim();if("{"===r[0]||"["===r[0])try{let[t,n]=W(r,0,"");if(F(r,n,!1)===r.length)return t}catch(t){throw t instanceof A?Error(t.message):t}let n=new S(t),i=function t(r,n,i=0){if(i>64)throw Error("YAML: nesting is too deep");if(r.skipBlank(),r.i>=r.lines.length)return null;let a=r.indent();if(a<n)return null;let s=r.lines[r.i].slice(a);if("-"===s||s.startsWith("- ")){let n=[];for(;r.i<r.lines.length&&(r.skipBlank(),!(r.i>=r.lines.length||r.indent()!==a));){let s=r.lines[r.i].slice(a);if("-"!==s&&!s.startsWith("- "))break;let o=s.slice(1),l=o.length-o.trimStart().length+1,c=H(o).trim();""===c?(r.i++,n.push(t(r,a+1,i+1))):null!==L(c)?(r.lines[r.i]=" ".repeat(a+l)+o.trimStart(),n.push(t(r,a+l,i+1))):(r.i++,n.push(U(r,o.trim(),a)))}return n}if(null===L(s))return r.i++,U(r,s.trim(),a-1);let o={};for(;r.i<r.lines.length&&(r.skipBlank(),!(r.i>=r.lines.length));){let n=r.indent();if(n<a)break;if(n>a)throw Error("YAML: bad indentation of a mapping entry");let s=r.lines[r.i].slice(a),l=L(s);if(!l)throw Error("YAML: can not read a block mapping entry");let c=String(W(l.key,0,"")[0]),d=s.slice(l.length);if(r.i++,""===H(d).trim())if(r.skipBlank(),r.i<r.lines.length){let n=r.indent(),s=r.lines[r.i].slice(n),l="-"===s||s.startsWith("- ");E(o,c,n>a||l&&n===a?t(r,l?a:a+1,i+1):null)}else E(o,c,null);else E(o,c,U(r,d.trim(),a))}return o}(n,0);if(n.skipBlank(),n.i<n.lines.length&&"..."!==n.lines[n.i].trim())throw Error("YAML: end of the stream or a document separator is expected");return i}function V(t){return t<128?32===t||t>=9&&t<=13:160===t||5760===t||t>=8192&&t<=8202||8232===t||8233===t||8239===t||8287===t||12288===t||65279===t}function Y(t){return 32===t||9===t}function G(t){return 10===t||13===t||8232===t||8233===t}function Z(t){return t>=48&&t<=57}function X(t){return t>=65&&t<=90||t>=97&&t<=122}function K(t){return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function J(t){return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||95===t}var Q=/^\s*%%(?!{)[^\n]+\n?/gm,ee=/%{2}{\s*(?:(\w+)\s*:|(\w+))\s*(?:(\w+)|((?:(?!}%{2}).|\r?\n)*))?\s*(?:}%{2})?/gi,et=/<(\w+)([^>]*)>/g,er=/="([^"]*)"/g,en=new Set(["__proto__","constructor","prototype"]);function ei(t,r,n){return n?.push(s(t,r,0)),t.replace(r,"")}function ea(t,r){t.includes("%%")&&(t=ei(t,Q,r));let n=t.trimStart();return r?.push([[0,t.length-n.length,0]]),n}function es(t){return t.includes("\r")?t.replace(/\r\n?/g,`
|
|
35
|
+
`):t}function eo(t){return t===`
|
|
36
|
+
`||"\r"===t}function el(t){return void 0!==t&&/\s/.test(t)}function ec(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function ed(t,r){for(let n of Object.keys(r)){if(en.has(n))continue;let i=r[n],a=t[n];ec(i)&&ec(a)?ed(a,i):ec(i)?t[n]=ed({},i):t[n]=i}return t}function eu(t,r){let n=es(t),i=n.includes("<")?n.lastIndexOf(">"):-1;i>0&&(n=n.slice(0,i+1).replace(et,(t,r,n)=>"<"+r+n.replace(er,"='$1'")+">")+n.slice(i+1));let s={},o,l=0,c=n.includes("---")?function(t){let r=0;for(;r<t.length&&el(t[r])&&!eo(t[r]);)r++;let n=t.slice(0,r);if(!t.startsWith("---",r))return;let i=[];for(let n=r+3;n<t.length&&el(t[n]);n++)eo(t[n])&&i.push(n);if(0===i.length)return;let a=n+"---",s=r=>{if(!eo(t[r])||!t.startsWith(a,r+1))return -1;let n=-1;for(let i=r+1+a.length;i<t.length&&el(t[i]);i++)eo(t[i])&&(n=i);return n},o=`
|
|
37
|
+
`+a,l=-1;for(let r=t.lastIndexOf(o);r>i[0];r=t.lastIndexOf(o,r-1))if(-1!==s(r)){l=r;break}if(-1===l)return;let c=i[0];for(let t of i)t<l&&(c=t);let d=c+1,u=d>0?d-1:0;for(let r=t.indexOf(o,u);-1!==r&&r<=l;r=t.indexOf(o,r+1)){if(r<d)continue;let i=s(r);if(-1!==i)return{indent:n,body:t.slice(d,r),length:i+1}}}(n):void 0;if(c){let t=c.indent?c.body.split(`
|
|
38
|
+
`).map(t=>t.startsWith(c.indent)?t.slice(c.indent.length):t).join(`
|
|
39
|
+
`):c.body,i;try{i=q(t)}catch(t){throw new a(`Front matter is not valid YAML. ${t.message}`,"syntax")}ec(i)&&(i.title&&(o=String(i.title)),ec(i.config)&&ed(s,i.config),i.displayMode)&&((ec(s.gantt)?s.gantt:s.gantt={}).displayMode=String(i.displayMode));for(let t=n.indexOf(`
|
|
40
|
+
`);-1!==t&&t<c.length;t=n.indexOf(`
|
|
41
|
+
`,t+1))l++;n=n.slice(c.length),r?.push([[0,c.length,0]])}return{text:ea(n=function(t,r,n){let i;if(!t.includes("%%{"))return t;let a=t.trim().replace(/'/g,'"');for(ee.lastIndex=0;null!==(i=ee.exec(a));){i.index===ee.lastIndex&&ee.lastIndex++;let t=i[1]??i[2];if("wrap"===t)r.wrap=!0;else if(("init"===t||"initialize"===t)&&i[4])try{let t=JSON.parse(i[4].trim());ec(t)&&ed(r,t)}catch{}}return ee.lastIndex=0,ei(t,ee,n)}(n,s,r)),title:o,config:s,withComments:n,lineOffset:l}}var eh=/#\w+;/g,ef=/^\+?\d+$/,ep=RegExp("[\\n\\r\u2028\u2029]","g");function eg(t){if(void 0===t)return;let r=[];return t.push(r),r}function em(t,r,n){let i=eg(n),a=t.indexOf(r);if(-1===a)return t;let s="",o=0;for(;-1!==a;){ep.lastIndex=a;let n=ep.test(t)?ep.lastIndex-1:t.length,l=!1,c=-1;for(let i=a+r.length;i<n;i++){let r=t.charCodeAt(i);if(58===r)l=!0;else if(35===r){if(l){c=i;break}}else V(r)&&(l=!1)}if(-1!==c){let r=t.lastIndexOf(";",n-1);r>c&&(i?.push([r,r+1,0]),s+=t.slice(o,r),o=r+1)}a=n>=t.length?-1:t.indexOf(r,n+1)}return 0===o?t:s+t.slice(o)}function ey(t,r){if(!t.includes("#"))return t;t=em(em(t,"style",r),"classDef",r);let n=eg(r);return t.replace(eh,(t,r)=>{let i=t.substring(1,t.length-1),a=(ef.test(i)?"fl\xb0\xb0":"fl\xb0")+i+"\xb6\xdf";return n?.push([r,r+t.length,a.length]),a})}function ev(t){let r=new Uint16Array(95);for(let n=0;n<95;n++)r[n]=parseInt(t.substr(2*n,2),36);return r}var eb={width(t,r,n){let i=(4&n)!=0,a=1&n?nF??=ev("7q99d6fgfgopk26m9999atg87q997q7qfgfgfgfgfgfgfgfgfgfg9999g8g8g8gzr3k2k2k2k2ijgzlmk27qfgk2gzn5k2lmijlmk2ijgzk2ijq8ijijgz997q99g8fg99fggzfggzfg99gzgz7q7qfg7qopgzgzgzgzatfg99gzfglmfgfgdwat7satg8"):nj??=ev("7q7q9vfgfgopij5b9999atg87q997q7qfgfgfgfgfgfgfgfgfgfg7q7qg8g8g8fgs7ijijk2k2ijgzlmk27qdwijfgn5k2lmijlmk2ijgzk2ijq8ijijgz7q7q7qd1fg99fgfgdwfgfg7qfgfg6666dw66n5fgfgfgfg99dw7qfgdwk2dwdwdw9a789ag8"),s=0;for(let r=0;r<t.length;r++){let n=t.charCodeAt(r);if(!(n<32))if(n<127)s+=i?600:a[n-32];else{if(173===n||n>=768&&n<=879||n>=8203&&n<=8207||n>=56320&&n<=57343||n>=65024&&n<=65039||65279===n)continue;n>=4352&&n<=4447||n>=11904&&n<=42191||n>=44032&&n<=55203||n>=63744&&n<=64255||n>=65072&&n<=65103||n>=65280&&n<=65376||n>=65504&&n<=65510||n>=55296&&n<=56319?s+=i?1200:1e3:s+=i?600:580}}return s*(24&n?r/1.2:r)/1e3}};function ex(){let t=globalThis;return t.document?.fonts??t.fonts}var ew=new Map;function e$(t="sans-serif",r="monospace"){let n=t+`
|
|
42
|
+
`+r,i=ew.get(n);return i||(i=function(t,r="monospace"){let n=function(){let t=globalThis;try{if(t.OffscreenCanvas)return new t.OffscreenCanvas(1,1).getContext("2d");if(t.document)return t.document.createElement("canvas").getContext("2d")}catch{}return null}();if(!n)return null;let i=new Map,a="",s=ex()?.size;return{width(o,l,c){let d=ex();d?.size!==s&&(s=d?.size,i.clear());let u=(2&c?"italic ":"")+(1&c?"bold ":"")+(24&c?l/1.2:l)+"px "+(4&c?r:t),h=i.get(u);h||i.set(u,h=new Map);let f=h.get(o);return void 0===f&&(u!==a&&(n.font=a=u),f=n.measureText(o).width,function(t,r,n){try{return t?.check(r,n)??!0}catch{return!0}}(d,u,o)&&(h.size>=2e4&&h.clear(),h.set(o,f))),f}}}(t,r)??eb,ew.set(n,i)),i}var ek=/[&<>"\x00-\x08\x0b\x0c\x0e-\x1f\x7f\ud800-\udfff\ufffe\uffff]/u,eM=/[&<>"]|[\x00-\x08\x0b\x0c\x0e-\x1f\x7f\ud800-\udfff\ufffe\uffff]+/gu,e_={"&":"&","<":"<",">":">",'"':"""},eA=/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f\ud800-\udfff\ufffe\uffff]/u;function eE(t){return ek.test(t)?t.replace(eM,t=>e_[t]??""):t}function eS(t){return eE(y(t))}var eC=[];for(let t=0;t<100;t++)eC.push(0===t?"":t%10==0?"."+t/10:"."+(t<10?"0"+t:t));function eT(t){let r=Math.round(100*t);if(0===r)return"0";if(r>0){if(r<1e11){let t=Math.floor(r/100);return t+eC[r-100*t]}}else if(r>-1e11){let t=-r,n=Math.floor(t/100);return"-"+n+eC[t-100*n]}return String(r/100)}function eI(t,r,n,i,a){let s=t.lines;if(0===s.length)return"";let o=t.lineHeight,l=t.heights,c=.35*t.size,d=n-t.height/2,u=1===s.length&&1===s[0].length?s[0][0]:void 0;if(u&&void 0===u.icon&&void 0===u.math&&0===u.style)return`<text${i} x="${eT(r)}" y="${eT(d+o/2+c)}" text-anchor="middle">${eE(u.text)}</text>`;let h=eB(t),f=i,p;i=eW(i,h);let g="",m="";for(let n=0;n<s.length;n++){let i=s[n],u=l?l[n]:o,w=d+u/2,$=w+c,k=!1;for(let t of i)(void 0!==t.icon||t.math)&&(k=!0);if(k){let s=r-t.widths[n]/2;for(let r of i){if(r.math){var y,v,b,x;let n=`x="${eT(s)}" y="${eT(w-r.math.height/2)}" width="${eT(r.math.width)}" height="${eT(r.math.height)}"`;p??=function(t){let r=eD.exec(t)?.[1]??"",n=(eR.exec(r)?.[1]??eN.exec(t)?.[1]??"").trim();if("none"===n)return{attrs:"",halo:eO.exec(t)?.[1]??"none"};let i=eL.exec(r)?.[1].trim();return{attrs:(""===n?"":` color="${n}"`)+(i?` opacity="${i}"`:"")}}(f),m+=void 0===p.halo?(y=r.math,v=n,b=t.size,x=p.attrs,"svg"in y?`<svg class="pele-math" ${v} overflow="visible"${x}>${y.svg}</svg>`:`<foreignObject class="pele-math" ${v} overflow="visible"${x}><div xmlns="http://www.w3.org/1999/xhtml" style="display:flex;align-items:center;justify-content:center;width:100%;height:100%;font-size:${eT(b)}px;line-height:normal;white-space:nowrap">${y.html}</div></foreignObject>`):`<rect ${n} rx="2" fill="${p.halo}"/>`}else if(void 0!==r.icon){let n=1.1*t.size,i=a?.(r.icon)??"";m+=`<svg class="pele-icon" data-icon="${eS(r.icon)}" x="${eT(s)}" y="${eT(w-n/2)}" width="${eT(n)}" height="${eT(n)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${i}</svg>`}else""!==r.text&&(g+=`<tspan x="${eT(s)}" y="${eT($)}" text-anchor="start"${eF(r.style&~h)}>${eE(r.text)}</tspan>`);s+=r.width}}else{for(let t=0;t<i.length;t++){let n=i[t],a=0===t?` x="${eT(r)}" y="${eT($)}"`:"";g+=`<tspan${a}${eF(n.style&~h)}>${eE(n.text)}</tspan>`}0===i.length&&(g+=`<tspan x="${eT(r)}" y="${eT($)}"> </tspan>`)}d+=u}return`<text${i} text-anchor="middle" xml:space="preserve">${g}</text>${m}`}var eN=/ fill="([^"]*)"/,eO=/ stroke="([^"]*)"/,eD=/ style="([^"]*)"/,eR=/(?:^|;)\s*fill:([^;]*)/,eL=/(?:^|;)\s*opacity:([^;]*)/,ez=' font-weight="var(--_w)"',eP=' font-style="italic"',ej=' font-family="var(--_fm)"';function eF(t){return(1&t?ez:"")+(2&t?eP:"")+(4&t?ej:"")+(32&t?' text-decoration="underline"':"")+(8&t?' baseline-shift="sub" font-size="smaller"':16&t?' baseline-shift="super" font-size="smaller"':"")}function eB(t){let r=7,n=!1;for(let i of t.lines)for(let t of i)void 0!==t.icon||""===t.text||(r&=t.style,n=!0);return n?r:0}function eW(t,r){return t+(1&r&&!t.includes(' font-weight="')?ez:"")+(2&r&&!t.includes(' font-style="')?eP:"")+(4&r&&!t.includes(' font-family="')?ej:"")}var eH=new Set("black blue blueviolet brown crimson darkblue darkcyan darkgreen darkmagenta darkolivegreen darkorchid darkred darkslateblue darkslategray darkviolet dimgray firebrick forestgreen green indigo maroon mediumblue mediumslateblue mediumvioletred midnightblue navy olive purple rebeccapurple royalblue saddlebrown seagreen sienna slateblue steelblue teal".split(" ")),eU=new Set("aliceblue antiquewhite aqua aquamarine azure beige bisque blanchedalmond burlywood cadetblue chartreuse chocolate coral cornflowerblue cornsilk cyan darkgoldenrod darkgray darkkhaki darkorange darksalmon darkseagreen darkturquoise deeppink deepskyblue dodgerblue floralwhite fuchsia gainsboro ghostwhite gold goldenrod gray greenyellow honeydew hotpink indianred ivory khaki lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgray lightgreen lightpink lightsalmon lightseagreen lightskyblue lightslategray lightsteelblue lightyellow lime limegreen linen magenta mediumaquamarine mediumorchid mediumpurple mediumseagreen mediumspringgreen mediumturquoise mintcream mistyrose moccasin navajowhite oldlace olivedrab orange orangered orchid palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum powderblue red rosybrown salmon sandybrown seashell silver skyblue slategray snow springgreen tan thistle tomato turquoise violet wheat white whitesmoke yellow yellowgreen".split(" ")),eq="var(--pele-fg-on-light,#1f1f1f)",eV="var(--pele-fg-on-dark,#fff)",eY=/[";]fill:([^;"]*)/,eG=/[";](?:fill-)?opacity:([^;"]*)/g,eZ=/^#(?:[\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i,eX=/^(rgba?|hsla?)\(([^()]*)\)$/i,eK=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?(%|deg|grad|rad|turn)?$/i,eJ=t=>t<=.04045?t/12.92:((t+.055)/1.055)**2.4,eQ=(t,r,n)=>.2126*eJ(t)+.7152*eJ(r)+.0722*eJ(n),e0=Math.sqrt(1.05*(eQ(31/255,31/255,31/255)+.05))-.05;function e1(t,r){let n=eK.exec(t);return!n||n[1]&&"%"!==n[1]?NaN:Math.min(Math.max(parseFloat(t)/(n[1]?100:r),0),1)}function e2(t){let r=t.trim().toLowerCase(),n=r.replace("grey","gray");if(eH.has(n))return[0,1];if(eU.has(n))return[1,1];if(eZ.test(r)){let t=r.length<6?r.slice(1).replace(/./g,"$&$&"):r.slice(1),n=r=>parseInt(t.slice(2*r,2*r+2),16)/255;return[eQ(n(0),n(1),n(2)),8===t.length?n(3):1]}let i=eX.exec(r),a=i?.[1].startsWith("hsl")??!1,s=i&&function(t,r){let n=t.includes(","),[i,a,s]=n?[t]:t.split("/");if(void 0!==s)return;let o=i.trim().split(n?/\s*,\s*/:/\s+/);if(n?o.length<3||o.length>4:3!==o.length)return;if(void 0!==a&&o.push(a.trim()),!n)return o.map(t=>"none"===t?"0":t);let l=o.slice(+!!r,3).filter(t=>t.endsWith("%")).length;return l!==(r?2:3)&&(r||0!==l)?void 0:o}(i[2],a);if(!s)return;let o=4===s.length?e1(s[3],1):1,l;if(a){let t=(function(t){let r=eK.exec(t);if(!r||"%"===r[1])return NaN;let n=r[1]?.toLowerCase(),i=parseFloat(t);return"turn"===n?360*i:"rad"===n?180*i/Math.PI:"grad"===n?.9*i:i}(s[0])%360+360)%360/30,r=e1(s[1],100),n=e1(s[2],100),i=r*Math.min(n,1-n);l=[0,8,4].map(r=>{let a=(r+t)%12;return n-i*Math.max(-1,Math.min(a-3,9-a,1))})}else l=s.slice(0,3).map(t=>e1(t,255));let c=eQ(l[0],l[1],l[2]);return Number.isNaN(c+o)?void 0:[c,o]}function e4(t){let r=1;for(let[,n]of t.matchAll(eG))r*=e1(n.trim(),1);return r}var e3=new Map;function e5(t,r=""){let n=`${t}\0${r}`;if(e3.has(n))return e3.get(n);e3.size>1e3&&e3.clear();let i=function(t,r){let n=eY.exec(t),i=n&&!eY.test(r)?e2(n[1]):void 0;if(i&&i[1]*e4(t)>=.5)return i[0]>e0?eq:eV}(t,r);return e3.set(n,i),i}function e6(t){let r=eY.exec(t)?.[1].trim().toLowerCase();if(!r||"none"===r||"transparent"===r)return!1;let n=e4(t);return(e2(r)?.[1]??1)*(Number.isNaN(n)?1:n)>0}function e8(t,r){let n=e5(t.shape,t.text)??r;return n?` fill="${n}"`:""}var e9={pie:{prefix:"pie",first:1},gitGraph:{prefix:"git",first:0},timeline:{prefix:"cScale",first:0},radar:{prefix:"cScale",first:0},treemap:{prefix:"cScale",first:0},mindmap:{prefix:"cScale",first:1},venn:{prefix:"venn",first:1,repeat:!0}},e7=/^[\w\s#%.,+\-/()]{1,200}$/,te=/([\w-]*)\s*\(/g,tt=/var\(\s*([\w-]*)/gi,tr=new Set(["rgb","rgba","hsl","hsla","hwb","lab","lch","oklab","oklch","color","color-mix","light-dark","var"]),tn=t=>ec(t)?t:{},ti={style:"",inks:[]},ta=ti;function ts(t){let r=ta.inks[(t%8+8)%8];return r?` fill="${r}"`:""}new WeakMap,new WeakMap,new WeakMap,Math.random().toString(36).slice(2,7);var to=new Map;function tl(t,r){try{return r()}catch(r){if(r instanceof RangeError)throw new a("Diagram is nested too deeply.","limit",t);if(r instanceof a){r.type??=t.type,r.mermaidType??=t.mermaidType;let n=m(r.message);n!==r.message&&(r.stack=r.stack?.replace(r.message,()=>n),r.message=n),r.snippet=m(r.snippet)}throw r}}var tc=new WeakMap;function td(t,r={}){try{return(()=>{let{type:n,mermaidType:s,diagram:l,model:c,config:d}=function(t,r){if("string"==typeof t)return function(t,r=5e4,n=5e3,s){if(t.length>r)throw new a(`Diagram source is longer than the limit of ${r} characters.`,"limit");let l=eu(t),c=function(t){for(let[r,n,a]of i)if(a.test(t))return{type:r,mermaidType:n};return null}(l.text);if(null===c)throw new a("No diagram type detected for the given text.","unsupported-diagram");let d=to.get(c.type);if(void 0===d)throw new a(`Diagram type "${c.type}" is not supported yet.`,"unsupported-diagram",c);let u=s?{...s,...l.config}:l.config,h=!0===d.keepComments,f=ey(h?l.withComments:l.text)+`
|
|
43
|
+
`,p=tl(c,()=>{var r,i;let a,s;return function(t,r){let n=v;v=t;try{return r()}finally{v=n}}({parsed:f,find:(r=t,i=h,s="",t=>{if(void 0===a){let t=eu(r,a=[]);ey(i?t.withComments:ea(t.withComments,a),a),s=es(r)+`
|
|
44
|
+
`}return[s,o(a,t)]})},()=>d.parse(f,u,l.title,l.lineOffset,{maxEdges:n}))});return{...c,diagram:d,model:p,config:u}}(t,r.limit,r.maxEdges,r.config);let n=tc.get(t);if(void 0===n)throw TypeError("render() takes diagram text or a model that parse() returned.");return n}(t,r),u=d[l.section??n],h="object"==typeof u&&null!==u&&!Array.isArray(u)&&!1===u.useMaxWidth,f=r.responsive??!h,p=r.icons,g=p&&(t=>p(y(t))),m=tl({type:n,mermaidType:s},()=>(function(t,r){let n=ta;ta=t;try{return r()}finally{ta=n}})(function(t,r){let n=function(t,r){if("xychart"===t){let t=tn(r.xyChart).plotColorPalette;return"string"==typeof t?{list:function(t){let r=[],n=0,i=0;for(let a=0;a<t.length;a++){let s=t[a];"("===s?n++:")"===s?n--:","===s&&0===n&&(r.push(t.slice(i,a)),i=a+1)}return r.push(t.slice(i)),r.map(t=>t.trim())}(t),repeat:!0}:void 0}let n=e9[t];if(void 0===n)return;let i=[];for(let t=0;t<8;t++)i.push(r[n.prefix+(n.first+t)]);return n.repeat&&(i=i.filter(t=>null!=t&&""!==t)),{list:i,repeat:!0===n.repeat}}(t,tn(r.themeVariables));if(void 0===n||0===n.list.length)return ti;let{list:i,repeat:a}=n,s="",o=[];for(let t=0;t<8&&!(!a&&t>=i.length);t++){let r=function(t){if("string"!=typeof t)return;let r=t.trim();if(!e7.test(r))return;if(!r.includes("(")){let t,n;return(n=(t=r.trim().toLowerCase()).replace("grey","gray"),eZ.test(t)||eH.has(n)||eU.has(n)||"transparent"===t||"currentcolor"===t)?r:void 0}let n=0;for(let t of r)if("("===t)n++;else if(")"===t&&--n<0)return;if(0===n){for(let[,t]of r.matchAll(te))if(!tr.has(t.toLowerCase()))return;for(let[,t]of r.matchAll(tt))if(!t.startsWith("--pele-"))return;return r}}(i[t%i.length]);void 0!==r&&(s+=`;--pele-series-${t+1}:${r}`,o[t]=e5(`;fill:${r}`))}return""===s?ti:{style:eE(s),inks:o}}(n,d),()=>(function(t,r){let n=k,i=M;k=t,M=new Map;try{return r()}finally{k=n,M=i}})(l.math?r.math:void 0,()=>(function(t,r){let n=x,i=w;x=t,w=new Map;try{return r()}finally{x=n,w=i}})(g,()=>l.render(c,d,{...r,responsive:f,icons:g}))))),b=r.outputLimit??4e6;if(m.svg.length>b)throw new a(`Diagram output is longer than the limit of ${b} characters.`,"limit",{type:n,mermaidType:s});for(let t of m.links)t.id=y(t.id);return{type:n,mermaidType:s,...m}})()}catch(t){throw t instanceof RangeError?new a("Diagram is nested too deeply.","limit"):t}}var tu="about:blank",th=/^([^\w]*)(javascript|data|vbscript)/im,tf=/&#(\w+)(^\w|;)?/g,tp=/&(newline|tab);/gi,tg=/[\u0000-\u001F\u007F-\u009F -\uD800-\uDFFF\uFFFE\uFFFF]/gimu,tm=/^.+(:|:)/gim,ty=/(\\|%5[cC])((%(6[eE]|72|74))|[nrt])/g;function tv(t){try{return decodeURIComponent(t)}catch{return t}}function tb(t,r){let n=r?tv(t.trim()):t.trim(),i,a=0;do{if(++a>32)return;n=n.replace(tg,"").replace(tf,(t,r)=>String.fromCharCode(r)).replace(tp,"").replace(tg,"").replace(ty,"").trim(),r&&(n=tv(n)),i=n.match(tg)||n.match(tf)||n.match(tp)||n.match(ty)}while(i&&i.length>0);return n}function tx(t){if(!t)return tu;let r=tb(t,!0),n=tb(t,!1);if(!r||!n)return tu;if("."===r[0]||"/"===r[0])return n;let i=r.trimStart().match(tm);if(!i)return n;let a=i[0].toLowerCase().trim();if(th.test(a))return tu;let s=n.trimStart().replace(/\\/g,"/");if("mailto:"===a||a.includes("://"))return s;if("http:"===a||"https:"===a){let t;try{t=new URL(s)}catch{return tu}return t.protocol=t.protocol.toLowerCase(),t.hostname=t.hostname.toLowerCase(),t.toString()}return s}function tw(t){return tx(y(t))}var t$=["http","https","mailto","tel"],tk=["http","https"],tM=/^([a-z][a-z0-9+.-]*):/i,t_=/^[\\/]{2}/;function tA(t,r){if(t_.test(t))return!1;let n=tM.exec(t);return!n||r.includes(n[1].toLowerCase())}function tE(t,r){let n=tb(t,!0);return void 0!==n&&tA(t,r)&&tA(n,r)?t:void 0}function tS(t,r){return!1===r.links?void 0:tE(t,r.linkSchemes??t$)}var tC=RegExp(eA.source,"gu");function tT(t,r){let n=tx(t);return n!==tu&&void 0!==tS(n,r)&&void 0!==tS(t.replace(tC,"").replace(/[\t\n\r]/g,"").replace(/^[\x00-\x20]+/,""),r)}function tI(t,r,n,i,a,s=""){let o=tS(r,a);return void 0===o?t:(i.push({id:n,href:o,internal:!1}),`<a href="${eE(o)}"${s}${tN(a)}>${t}</a>`)}function tN(t){let r=t.linkRel??"noopener";return r?` rel="${eE(r)}"`:""}var tO=new Map([["square","rect"],["round","rounded"],["ellipse","ellipse"],["hexagon","hex"],["diamond","diam"]]),tD=new Map;for(let t of[["rect","proc","process","rectangle","squareRect"],["rounded","event","roundedRect"],["stadium","terminal","pill"],["fr-rect","subprocess","subproc","framed-rectangle","subroutine"],["cyl","db","database","cylinder"],["datastore","data-store"],["folder","directory"],["bucket"],["console"],["browser"],["person"],["circle","circ"],["bang"],["cloud"],["diam","decision","diamond","question"],["hex","hexagon","prepare"],["lean-r","lean-right","in-out","lean_right"],["lean-l","lean-left","out-in","lean_left"],["trap-b","priority","trapezoid-bottom","trapezoid"],["trap-t","manual","trapezoid-top","inv-trapezoid","inv_trapezoid"],["dbl-circ","double-circle","doublecircle"],["text"],["notch-rect","card","notched-rectangle"],["lin-rect","lined-rectangle","lined-process","lin-proc","shaded-process"],["sm-circ","start","small-circle","stateStart"],["fr-circ","stop","framed-circle","stateEnd"],["fork","join","forkJoin"],["hourglass","collate"],["brace","comment","brace-l"],["brace-r"],["braces"],["bolt","com-link","lightning-bolt"],["doc","document"],["delay","half-rounded-rectangle"],["h-cyl","das","horizontal-cylinder"],["lin-cyl","disk","lined-cylinder"],["curv-trap","curved-trapezoid","display"],["div-rect","div-proc","divided-rectangle","divided-process"],["tri","extract","triangle"],["win-pane","internal-storage","window-pane"],["f-circ","junction","filled-circle"],["notch-pent","loop-limit","notched-pentagon"],["flip-tri","manual-file","flipped-triangle"],["sl-rect","manual-input","sloped-rectangle"],["docs","documents","st-doc","stacked-document"],["st-rect","procs","processes","stacked-rectangle"],["bow-rect","stored-data","bow-tie-rectangle"],["cross-circ","summary","crossed-circle"],["tag-doc","tagged-document"],["tag-rect","tagged-rectangle","tag-proc","tagged-process"],["flag","paper-tape"],["odd","rect_left_inv_arrow"],["lin-doc","lined-document"]])for(let r of t)tD.set(r,t[0]);for(let t of["state","choice","note","composite","rectWithTitle","labelRect","block_arrow","collapsedGroup","iconSquare","iconCircle","icon","iconRounded","imageSquare","anchor","kanbanItem","mindmapCircle","defaultMindmapNode","classBox","erBox","requirementBox","usecaseActor","usecaseActorHollow","usecaseActorAwesome","usecaseActorIcon","usecaseBusiness","usecaseEllipse","usecaseJsonTable"])tD.set(t,t);function tR(t){return void 0===t?"rect":tO.get(t)??tD.get(t)??"rect"}var tL=new Map([["task","roundedRect"],["tool","subroutine"],["input","lean-right"],["decision","diamond"],["refdoc","lin-doc"],["action","hexagon"],["round","rect"]]),tz=new Set(["doc","stadium","terminal","circle","trapezoid","inv_trapezoid","inv-trapezoid","doublecircle","double-circle","typeDeclaration","procs","lean_left","lean-left","in-out","cylinder","ellipse","odd","tag-rect","tagged-rectangle","delay","half-rounded-rectangle","lin-rect","lined-rectangle","win-pane","window-pane","curv-trap","curved-trapezoid"]),tP=new Set(["roundedRect","subroutine","subprocess","subproc","framed-rectangle","lean-right","diamond","lin-doc","lined-document","hexagon","hex","connector","collapsedGroup"]),tj="roundedRect";function tF(t){return t&&(tL.get(t)??t)}var tB=new Set(["shape","view","icon","img","form","pos","w","h","class","style","labelType"]),tW=new Set(["subroutine","subprocess","subproc","framed-rectangle","tool"]);function tH(t){return"markdown"===t||"string"===t||"text"===t?t:"markdown"}function tU(t){return t.startsWith('"')&&t.endsWith('"')?t.substring(1,t.length-1):t}function tq(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function tV(t,r){return Object.assign(t??{},r)}var tY=/:\s*[>|][\d+-]*\s*$/,tG=/,([\t ]*)$/;function tZ(t){if(!t)return;let r={},n=!1;for(let i of Object.keys(t))tB.has(i)||(r[i]=t[i],n=!0);return n?r:void 0}var tX=class{type="agentflow";direction;nodes=new Map;edges=[];subgraphs=[];connectors=new Map;classes=new Map;tooltips=new Map;defaultEdgeStyle;defaultInterpolate;mappings=[];diagnostics=[];title;accTitle;accDescr;lineOffset;subgraphLookup=new Map;globalNodes=new Set;members=new Set;edgeById=new Map;pairCount=new Map;subCount=0;bareMappings=new Set;firstMapping=new Map;reported=new Map;options;constructor(t={}){this.options=t,this.lineOffset=t.lineOffset??0}metadata(t,r,n){let i=r.includes(`
|
|
45
|
+
`),s;try{s=q(i?r+`
|
|
46
|
+
`:`{
|
|
47
|
+
`+r+`
|
|
48
|
+
}`)}catch(c){let o=i?function(t){let r=!1,n=!1,i=0,a,s=[];for(let o of t.split(`
|
|
49
|
+
`)){if(void 0!==a){let t=o.length-o.trimStart().length;if(""===o.trim()||t>a){s.push(o);continue}a=void 0}let t=-1;for(let a=0;a<o.length;a++){let s=o[a];if(n)"\\"===s?a++:'"'===s&&(n=!1);else if(r)"'"===s&&(r=!1);else if('"'===s)n=!0;else if("'"===s)r=!0;else if("#"===s&&(0===a||" "===o[a-1]||" "===o[a-1])){t=a;break}else"["===s||"{"===s?i++:("]"===s||"}"===s)&&(i=Math.max(0,i-1))}if(r||n||i>0){s.push(o);continue}let l=t>=0?o.slice(0,t):o,c=t>=0?o.slice(t):"";if(tY.test(l)){a=o.length-o.trimStart().length,s.push(o);continue}s.push(l.replace(tG,"$1")+c)}return s.join(`
|
|
50
|
+
`)}(r):r,l;if(o!==r)try{l=q(o+`
|
|
51
|
+
`)}catch{l=void 0}if(void 0===l){let{line:r,column:i}=this.errorAt(n),s=n?` (${r}:${i})`:"";throw new a(`Metadata of "${t}" is not valid YAML. ${c.message}${s}`,"syntax",{type:"agentflow",line:r,column:i})}s=l}return function(t){let r=t=>Array.isArray(t)?[]:tq(t)?{}:t,n=r(t),i=[[t,n]];for(;i.length>0;){let[t,n]=i.pop();if(Array.isArray(t))for(let a of t){let t=r(a);n.push(t),"object"==typeof a&&null!==a&&i.push([a,t])}else if(tq(t))for(let a of Object.keys(t)){if("__proto__"===a||"constructor"===a||"prototype"===a)continue;let s=t[a],o=r(s);n[a]=o,"object"==typeof s&&null!==s&&i.push([s,o])}}return n}(s??{})}errorAt(t){if(void 0===t)return{line:0,column:0};let r=this.options.source;if(void 0===r)return{line:t.first_line+this.lineOffset,column:t.first_column+1};let n=0;for(let i=1;i<t.first_line;i++)n=r.indexOf(`
|
|
52
|
+
`,n)+1;let{line:i,column:a}=c(r,n+t.first_column);return{line:i,column:a}}shapeError(t,r){return new a(t,"semantic",{type:"agentflow",...this.errorAt(r)})}addVertex(t,r,n,i,a,s,o={},l,c){let d,u,h;if(!t||0===t.trim().length)return;void 0!==l&&tq(d=this.metadata(t,l,c))&&(u=d,"string"==typeof d.shape&&(h=d.shape,d.shape=tF(d.shape)));let f=this.subgraphLookup.get(t);if(f&&d){f.metadata=tV(f.metadata,d);return}let p=this.connectors.get(t);if(p&&d){p.metadata=tV(p.metadata,d);return}if("connectors"===t)return;let g=this.edgeById.get(t);if(g){u?.animate!==void 0&&(g.animate=u.animate),u?.animation!==void 0&&(g.animation=u.animation),u?.curve!==void 0&&(g.interpolate=u.curve),d&&(g.metadata=tV(g.metadata,d));return}let m=this.nodes.get(t);if(void 0===m&&(m={id:t,labelType:"text",styles:[],classes:[]},this.nodes.set(t,m)),void 0!==r?(m.labelType=r.type,m.text=tU(r.text.trim())):void 0===m.text&&(m.text=t),void 0!==n&&(m.type=n),null!=i)for(let t of i)m.styles.push(t);if(null!=a)for(let t of a)m.classes.push(t);if(void 0!==s&&(m.dir=s),void 0===m.props?m.props=o:void 0!==o&&Object.assign(m.props,o),d&&(m.metadata=tV(m.metadata,d),void 0!==u)){if(u.shape){let t=h??u.shape;if("string"!=typeof t)throw this.shapeError(`No such shape: ${JSON.stringify(t)}.`,c);if(t!==t.toLowerCase()||t.includes("_"))throw this.shapeError(`No such shape: ${t}. Shape names should be lowercase.`,c);let r=u.shape;if(!tD.has(r)&&"constructor"!==r)throw this.shapeError(`No such shape: ${r}.`,c);m.type=r}u.label&&(m.text=String(u.label),m.labelType=tH(u.labelType))}}addSingleLink(t,r,n,i){let s={start:t,end:r,type:void 0,text:"",labelType:"text",classes:[],isUserDefinedId:!1,interpolate:this.defaultInterpolate},o=n?.text;void 0!==o&&(s.text=tU(o.text.trim()),s.labelType=tH(o.type)),void 0!==n&&(s.type=n.type,s.stroke=n.stroke,s.length=n.length>10?10:n.length,n.edgeSemantic&&(s.edgeSemantic=n.edgeSemantic));let l=t+"\0"+r,c=this.pairCount.get(l)??0;i&&!this.edgeById.has(i)?(s.id=i,s.isUserDefinedId=!0):s.id=`L_${t}_${r}_${0===c?0:c+1}`;let d=this.options.maxEdges;if(void 0!==d&&this.edges.length>=d)throw new a(`Edge limit exceeded. The limit is ${d}.`,"limit",{type:"agentflow"});this.edges.push(s),this.pairCount.set(l,c+1),this.edgeById.has(s.id)||this.edgeById.set(s.id,s)}addLink(t,r,n){let i="string"==typeof n?.id?n.id.replace("@",""):void 0,a=t[t.length-1],s=r[0];for(let o of t)for(let t of r)this.addSingleLink(o,t,n,o===a&&t===s?i:void 0)}updateLinkInterpolate(t,r){for(let n of t)"default"===n?this.defaultInterpolate=r:this.edgeAt(n).interpolate=r}updateLink(t,r){for(let n of t){if("default"===n){this.defaultEdgeStyle=r;continue}this.edgeAt(n).style=r,r.length>0&&!r.some(t=>t?.startsWith("fill"))&&r.push("fill:none")}}edgeAt(t){let r=this.edges[Number(t)];if(void 0===r)throw new a(`The index ${t} for linkStyle is out of bounds. Valid indices for linkStyle are between 0 and ${this.edges.length-1}. (Help: Ensure that the index is within the range of existing edges.)`,"semantic",{type:"agentflow"});return r}addClass(t,r){let n=r.join().replace(/\\,/g,"\xa7\xa7\xa7").replace(/,/g,";").replace(/§§§/g,",").split(";");for(let r of t.split(",")){let t=this.classes.get(r);for(let i of(void 0===t&&(t={id:r,styles:[],textStyles:[]},this.classes.set(r,t)),n))i.includes("color")&&t.textStyles.push(i.replace("fill","bgFill")),t.styles.push(i)}}setDirection(t){let r=t.trim();r.includes("<")&&(r="RL"),r.includes("^")&&(r="BT"),r.includes(">")&&(r="LR"),r.includes("v")&&(r="TB"),"TD"===r&&(r="TB"),this.direction=r}setClass(t,r){for(let n of t.split(","))this.nodes.get(n)?.classes.push(r),this.edgeById.get(n)?.classes.push(r),this.subgraphLookup.get(n)?.classes.push(r)}setTooltip(t,r){if(void 0!==r)for(let n of t.split(","))this.tooltips.set(n,r)}setLink(t,r,n){let i=r.trim();for(let r of t.split(",")){let t=this.nodes.get(r);void 0!==t&&(t.link=i?tw(i):void 0,t.linkTarget=n)}this.setClass(t,"clickable")}setClickEvent(t,r,n){this.setClass(t,"clickable")}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
|
|
53
|
+
`)}addSubGraph(t,r,n,i){let a=t?.text?.trim(),s=n?.text||"";void 0!==t&&t===n&&/\s/.test(s)&&(a=void 0);let o=new Set,l=[],c;for(let t of r)if("string"==typeof t)""===t.trim()||o.has(t)||(o.add(t),l.push(t));else if(Array.isArray(t))for(let r of t)""===r.trim()||o.has(r)||(o.add(r),l.push(r));else c=t.value;c??=this.options.inheritDir?this.direction??this.options.direction:void 0,a??="subGraph"+this.subCount,this.subCount++;let d=this.members,u=l.filter(t=>t!==a&&!this.globalNodes.has(t)&&!d.has(t));for(let t of u)d.add(t);let h=this.subgraphLookup.get(a);if(h){for(let t of u)h.nodes.push(t);return s.trim()&&(h.title=s.trim()),c&&(h.dir=c),a}let f={id:a,nodes:u,title:s.trim(),classes:[],dir:c,labelType:tH(n?.type),type:"flow"};return this.subgraphs.push(f),this.subgraphLookup.set(a,f),a}addGlobal(t){let r=!1,n=t=>{let n=t.trim();""!==n&&(this.globalNodes.add(n),this.members.delete(n)&&(r=!0))};for(let r of t)if("string"==typeof r)n(r);else if(Array.isArray(r))for(let t of r)n(t);if(r)for(let t of this.subgraphs)t.nodes=t.nodes.filter(t=>!this.globalNodes.has(t))}addConnector(t,r){let n=t?.text?.trim();if(!n)return"";let i=r?.text?.trim()??"",a=this.connectors.get(n);if(a)i.length>0&&(a.text=i);else{let t={id:n,labelType:"text",styles:[],classes:[],isConnector:!0,text:i.length>0?i:n};this.connectors.set(n,t),this.nodes.set(n,t)}return n}destructLink(t,r){var n,i;let a=function(t){let r=t.trim(),n=r.slice(0,-1),i="arrow_open";switch(r.slice(-1)){case"x":i="arrow_cross";break;case">":i="arrow_point";break;case"-":case".":n=r}let a="normal",s=n.length-1,o=0;for(let t=0;t<n.length;t++)"."===n[t]&&o++;return o>0&&(a="dotted",s=o),{type:i,stroke:a,length:s}}(t);return r&&(r.includes(".")?"dotted":"normal")!==a.stroke?{type:"INVALID",stroke:"INVALID"}:{...a,edgeSemantic:(n=a.type,i=a.stroke,"arrow_point"===n&&"normal"===i?"sequence":"arrow_cross"===n&&"normal"===i?"failure":"arrow_open"===n&&"dotted"===i?"reference":void 0)}}subgraph(t){return this.subgraphLookup.get(t)}vertexKind(t){if(tW.has(t.type))return"tool";let r=tF(t.type);return"hexagon"===r||"hex"===r?"action":"lean-right"===r||"lean_right"===r?"input":"lin-doc"===r||"lined-document"===r?"refdoc":"diamond"===r?"decision":"task"}semanticModel(){let t=[],r=[];for(let[n,i]of this.nodes){if(this.subgraphLookup.has(n))continue;let a=tZ(i.metadata);if(i.isConnector){let t={id:n};void 0!==i.text&&i.text!==n&&(t.title=i.text),a&&(t.metadata=a),r.push(t);continue}let s={id:n};void 0!==i.text&&(s.label=i.text);let o=tF(i.type);void 0!==o&&(s.shape=o),s.vertexKind=this.vertexKind(i),a&&(s.metadata=a),t.push(s)}let n={vertices:t,edges:this.edges.map(t=>{let r={start:t.start,end:t.end};return void 0!==t.id&&(r.id=t.id),t.text.length>0&&(r.label=t.text),void 0!==t.type&&(r.type=t.type),void 0!==t.stroke&&(r.stroke=t.stroke),void 0!==t.edgeSemantic&&(r.edgeSemantic=t.edgeSemantic),void 0!==t.length&&(r.length=t.length),t.metadata&&Object.keys(t.metadata).length>0&&(r.metadata={...t.metadata}),r}),subGraphs:this.subgraphs.map(t=>{let r={id:t.id,nodes:[...t.nodes],type:t.type,title:t.title};void 0!==t.dir&&(r.direction=t.dir);let n=tZ(t.metadata);return n&&(r.metadata=n),r}),connectors:r,diagnostics:this.diagnostics};return void 0!==this.direction&&(n.direction=this.direction),n}position(t){let r=t?.first_line??0,n=t?.first_column??0;return{startLine:r+this.lineOffset,startColumn:n,endLine:(t?.last_line??r)+this.lineOffset,endColumn:t?.last_column??n,startIndex:0,endIndex:0}}pushMapping(t,r,n){let i={id:t,type:r,position:n};return this.mappings.push(i),this.firstMapping.has(t)||this.firstMapping.set(t,i),i}addVertexMapping(t,r,n,i){if(!t)return;let a=this.pushMapping(t,"vertex",this.position(i));null==n&&this.bareMappings.add(a)}extendVertexMapping(t,r){if(!t||!r)return;let n=this.position(r);for(let r=this.mappings.length-1;r>=0;r--){let i=this.mappings[r];if("vertex"!==i.type||i.id!==t)continue;this.bareMappings.delete(i)&&(i.type="attachment");let a=i.position;(n.endLine>a.endLine||n.endLine===a.endLine&&n.endColumn>a.endColumn)&&(a.endLine=n.endLine,a.endColumn=n.endColumn);return}this.pushMapping(t,"attachment",n)}addEdgeMapping(t,r,n,i){let a=Array.isArray(r)?r.filter(t=>"string"==typeof t&&""!==t):[];this.pushMapping(a.length>0?a.join(">"):"edge","edge",this.position(i))}blockMapping(t,r,n,i){if(!t)return;let a=this.position(n),s=i?this.position(i):a;this.pushMapping(t,r,{startLine:a.startLine,startColumn:a.startColumn,endLine:s.endLine,endColumn:s.endColumn,startIndex:0,endIndex:0})}addSubgraphMapping(t,r,n,i){let a="string"==typeof t?t:t?.text;this.blockMapping(a??"","subgraph",n,i)}addConnectorMapping(t,r,n,i){this.blockMapping(t?.text?.trim()??"","connector",n,i)}emit(t,r,n,i){let a=i?.nodeId??i?.edgeId,s={id:t,severity:r,message:n};i?.nodeId?s.nodeId=i.nodeId:i?.edgeId&&(s.edgeId=i.edgeId);let o=a?this.firstMapping.get(a):void 0;o&&(s.position=o.position);let l=a??"",c=this.reported.get(l);if(void 0===c)this.reported.set(l,[s]);else{for(let i of c)if(i.id===t&&i.severity===r&&i.message===n&&i.nodeId===s.nodeId&&i.edgeId===s.edgeId)return;c.push(s)}this.diagnostics.push(s),this.options.log?.(r,`agentflow[${t}]: ${n}`)}emitWarning(t,r,n){this.emit(t,"warning",r,n)}emitError(t,r,n){this.emit(t,"error",r,n)}};function tK(t){if(t<170||t>65500)return!1;let r=nB??=function(){let t="4q 0 b 0 5 0 6 m 2 u 2 cp 5 b f 4 8 0 2 0 3m 4 2 1 3 3 9 0 2 2 2 0 2 j 2 2a 2 3u 9 4d a 11 3 0 8 12 21 q 6 2 1a 16 10 1 2 2q 2 0 g 1 8 1 b 2 3 0 h 0 2 t u 2g c 0 p w a 1 5 0 6 l 5 0 a 0 4 0 o o 20 0 2 a 2g 1h 4 0 j 0 8 9 g 6 2 6 6 7 3 1 3 l 2 6 2 0 4 3 4 0 h 0 e 1 2 2 f 1 k 5 5 1 3 l 2 6 2 1 2 1 2 1 w 3 2 0 k 2 h 8 2 2 2 l 2 6 2 1 2 4 4 0 j 0 g 1 10 7 3 1 3 l 2 6 2 1 2 4 4 0 v 1 2 2 g 0 i 0 2 5 4 2 2 3 4 1 2 0 2 1 4 1 4 2 4 b n 0 1h 7 2 2 2 m 2 9 2 4 4 0 r 1 7 1 10 7 2 2 2 m 2 9 2 4 4 0 x 0 2 1 g 1 j 7 2 2 2 14 3 0 h 0 i 1 p 5 6 h 4 n 2 8 2 0 3 6 1n 1b 2 1 d 6 1n 1 2 0 3 1 2 0 3 0 7 3 2 6 2 2 2 0 2 0 3 1 2 3 2 1 a 0 3 4 2 0 m 3 x 0 1s 7 2 z s 4 38 16 l 0 h 5 5 3 4 0 4 1 8 2 5 c d 0 i 11 2 0 6 0 3 16 2 98 2 3 3 6 2 0 2 3 3 14 2 3 3 w 2 3 3 6 2 0 2 3 3 e 2 1k 2 3 3 1u 12 f h 2c d h7 3 g 2 p 6 22 m c 2 3 f h f h f c 2 2 g 1f 10 0 5 0 1w 2f 9 14 2 0 6 1x b s 1g t 3 4 c 17 m 6 1l m a 1g 2b 0 2m 1a i 6 1k t e 1 b 17 r z 16 2 b z 30 3 2 3 4 1 a 5b 1t 7p 3 5 3 11 3 5 3 7 2 0 2 0 2 0 2 u 3 1g 2 6 2 0 4 2 2 6 4 3 3 5 5 c 6 2 2 6 39 0 e 0 h c 2u 0 5 0 3 9 2 0 4 4 7 0 2 0 2 0 2 3 2 a 3 3 6 4 5 0 1h 1 22k 1a 2 1a 2 3o 7 3 4 1 d 11 2 0 6 0 3 1j 8 0 h m a 6 2 6 2 6 2 6 2 6 2 6 2 6 2 6 29 0 d2 1 17 4 6 1 5 2d 7 2 2 2h 2 3 6 14 4 2l i q 1i f e9 52t 23 g5o 1g wc 1w 19 3 7g 4 f b 1 l 1a h o 9 1x 1e 8 3 2u 3 3 2 3 d a 26 9 2 2 2 3 2 m u 1f f 1d 1r 5 4 0 f r b m q s 8 1a t 0 1d 14 o 2 2 7 l m 4 0 6 1b 2 0 4 1 3 4 3 0 2 0 p 2 3 a 8 2 d 5 3 5 3 5 a 6 2 6 42 y u 8mb d m 5 1c 6it a5 3 2x 13 6 d 4 6 0 2 9 2 c 2 4 2 0 2 1 2 1 2 2z y a2 j 1r 3 1h 15 b 39 4 2 3q 11 p 7 p c 2g 4 5 3 5 3 5 3 2".split(" "),r=new Uint16Array(t.length),n=0;for(let i=0;i<t.length;i+=2){let a=n+parseInt(t[i],36);n=a+parseInt(t[i+1],36),r[i]=a,r[i+1]=n}return r}(),n=0,i=(r.length>>1)-1;for(;n<=i;){let a=n+i>>1;if(t<r[2*a])i=a-1;else{if(!(t>r[2*a+1]))return!0;n=a+1}}return!1}var tJ=["$end","INVALID","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","SHAPE_DATA","CALLBACKNAME","CALLBACKARGS","MD_STR","STR","STYLE","DEFAULT","LINKSTYLE","INTERPOLATE","CLASSDEF","CLASS","HREF","CLICK","GRAPH","flow","connector","global","end","LINK_TARGET","NODIR","DIR","direction_tb","direction_bt","direction_rl","direction_lr","direction_td","LINK_ID","NUM","BRKT","STYLE_SEPARATOR","COLON","AMP","SEMI","COMMA","MULT","LINK","START_LINK","EDGE_TEXT","-)","TEXT","(-","STADIUMEND","STADIUMSTART","SUBROUTINEEND","SUBROUTINESTART","VERTEX_WITH_PROPS_START","TAGEND","CYLINDEREND","CYLINDERSTART","DOUBLECIRCLEEND","DOUBLECIRCLESTART","TRAPEND","INVTRAPEND","TRAPSTART","INVTRAPSTART","TAGSTART","UP","SEP","DOWN","COMMENT","NODE_STRING","MINUS","UNICODE_TEXT","PIPE","PE","PS","SQE","SQS","DIAMOND_STOP","DIAMOND_START","NEWLINE","SPACE","EOF"],tQ=new Uint8Array(128);for(let t of"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"#$%&'*+.`?\\_/")tQ[t.charCodeAt(0)]=1;var t0=/accTitle\s*:\s*/y,t1=/accDescr\s*:\s*/y,t2=/accDescr\s*\{\s*/y,t4=/call\s+/y,t3=/click\s+/y,t5=/(?:\r?\n)*\s*\n/y,t6=/\s*(?:LR|RL|TB|BT|TD|BR)\b/y,t8=/\s*[<>^]/y,t9=/\s*v\b/y,t7=[/.*direction\s+TB[^\n]*/y,/.*direction\s+BT[^\n]*/y,/.*direction\s+RL[^\n]*/y,/.*direction\s+LR[^\n]*/y,/.*direction\s+TD[^\n]*/y],re=/[\n\r\u2028\u2029]/g,rt=/\(\s*\)/y,rr=/\n\s*/g,rn=new Uint8Array(80);for(let t of[34,67,65,68,13,40,37,38,35,41,69])rn[t]=1;var ri=new Uint8Array(80);for(let t of[34,69,67,27,65,68,40,37,38,35,41])ri[t]=1;var ra=new Uint8Array(80);for(let t of[34,67,78,68,38,69,37,41,35,12,14,16,17,19,20,27,21,22,23,24,65,63,43])ra[t]=1;var rs=new Uint8Array(80);for(let t of[34,67,37,78,35,12])rs[t]=1;var ro=new Uint8Array(80);for(let t of[77,39,79,66])ro[t]=1;var rl="'UNICODE_TEXT', 'TEXT', 'TAGSTART'",rc="'COMMENT', 'SEMI', 'NEWLINE', 'EOF'",rd=new Uint8Array(80);for(let t of[66,77,78,79])rd[t]=1;var ru=[],rh=/}[^\S\n]*\n/g,rf=["TB","BT","RL","LR","TD"],rp="'COMMENT', 'SEMI', 'NEWLINE', 'SPACE', 'EOF', 'flow', 'global', 'connector', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'STYLE', 'LINKSTYLE', 'CLASSDEF', 'CLASS', 'CLICK', 'NODE_STRING'";function rg(t,r,n=0){return{w:t,h:r,kind:n,pin:0,hint:NaN,key:NaN,span:0,x:0,y:0,rank:0}}function rm(t,r,n=1,i=0,a=0){return{tail:t,head:r,minlen:n,labelW:i,labelH:a,tailDx:0,headDx:0,tailFixed:!1,headFixed:!1,reversed:!1,points:[],labelX:0,labelY:0}}var ry=new Float64Array(34),rv=new Float64Array(34);function rb(t){return 1===t||2===t}function rx(t,r,n,i){for(let a=r+1;a<n;a++){let n=t[a],s=i[n],o=a-1;for(;o>=r&&(i[t[o]]>s||i[t[o]]===s&&t[o]>n);)t[o+1]=t[o],o--;t[o+1]=n}}function rw(t,r,n){let i,a=t.length;if(0===a)return{width:0,height:0};let s=r.length;if(1===a&&0===s&&0===t[0].kind){let r=t[0];return r.rank=0,r.x=r.w/2,r.y=r.h/2,{width:r.w,height:r.h}}let o=1;if(s>0){let t=new Set;for(let n of r){let r=Math.min(n.tail,n.head)*a+Math.max(n.tail,n.head);if(n.labelW>0||t.has(r)){o=2;break}t.add(r)}}r$(t,r),rk(t,r,o);let l=new Int32Array(s),c=0;for(let n=0;n<s;n++){let i=r[n];l[n]=Math.abs(t[i.head].rank-t[i.tail].rank),l[n]>1&&(c+=l[n]-1)}let d=new Uint8Array(s);if(c>2e4){let t=[];for(let r=0;r<s;r++)l[r]>1&&t.push(r);for(let r of(t.sort((t,r)=>l[r]-l[t]||t-r),t)){if(c<=2e4)break;d[r]=1,c-=l[r]-1}}let u=a+c,h=new Float64Array(u),f=new Float64Array(u),p=new Uint8Array(u),g=new Int32Array(u),m=0;for(let r=0;r<a;r++){let n=t[r];h[r]=n.w,f[r]=n.h,p[r]=n.kind,g[r]=n.rank,n.rank>m&&(m=n.rank)}let y=0;for(let t=0;t<s;t++)d[t]||(y+=l[t]);let v=new Int32Array(y),b=new Int32Array(y),x=new Float64Array(y),w=new Float64Array(y),$=new Int32Array(s).fill(-1),k=new Uint8Array(m+1),M=new Int32Array(s).fill(-1),_=!1;for(let r=0;r<a;r++)t[r].span>0&&0===t[r].kind&&(_=!0);let A=_?new Uint8Array(y):void 0,E=_?new Uint8Array(y):void 0,S=new Int32Array(s).fill(-1),C=new Int32Array(s).fill(-1),T=new Float64Array(u).fill(NaN);for(let r=0;r<a;r++)T[r]=t[r].key;let I=!1;{let t=a,n=0;for(let i=0;i<s;i++){if(d[i])continue;let a=r[i],s=a.reversed?a.head:a.tail,l=a.reversed?a.tail:a.head,c=a.reversed?a.headDx:a.tailDx,u=a.reversed?a.tailDx:a.headDx;(0!==c||0!==u)&&(I=!0);let m=g[s],y=g[l],_=-1;a.labelW>0&&(_=m+(y-m>>1),2===o&&y-m>=4?(1&_)==1&&(_+=a.reversed?1:-1):2===o&&(1&_)==0&&(_+=a.reversed?1:-1));let N=s;y-m>1&&($[i]=t),S[i]=n,!A||(a.reversed?a.headFixed:a.tailFixed)||(A[n]=a.reversed?2:1);for(let r=m+1;r<y;r++){let o=t++;g[o]=r,T[o]=T[s]+(T[l]-T[s])*(r-m)/(y-m),r===_?(h[o]=a.labelW,f[o]=a.labelH,p[o]=2,M[i]=o,k[r]|=a.reversed?2:1):p[o]=1,v[n]=N,b[n]=o,x[n]=N===s?c:0,n++,N=o}v[n]=N,b[n]=l,x[n]=N===s?c:0,w[n]=u,!E||(a.reversed?a.tailFixed:a.headFixed)||(E[n]=a.reversed?1:2),C[i]=n,n++}}if(n.groups){let{of:t,parent:o}=n.groups;i=new Int32Array(u);for(let r=0;r<a;r++)i[r]=t[r];let c=t=>{let r=0;for(;t>=0;t=o[t])r++;return r},d=(t,r)=>{let n=c(t),i=c(r);for(;n>i;n--)t=o[t];for(;i>n;i--)r=o[r];for(;t!==r;)t=o[t],r=o[r];return t};for(let n=0;n<s;n++){if($[n]<0)continue;let a=r[n],s=d(t[a.tail],t[a.head]);for(let t=$[n],r=t+l[n]-1;t<r;t++)i[t]=s}}let N=new Int32Array(u+1),O=new Int32Array(u+1);for(let t=0;t<y;t++)N[v[t]+1]++,O[b[t]+1]++;for(let t=0;t<u;t++)N[t+1]+=N[t],O[t+1]+=O[t];let D=new Int32Array(y),R=new Int32Array(y);{let t=N.slice(0,u),r=O.slice(0,u);for(let n=0;n<y;n++)D[t[v[n]]++]=n,R[r[b[n]]++]=n}let L=new Int32Array(m+2);for(let t=0;t<u;t++)L[g[t]+1]++;for(let t=0;t<=m;t++)L[t+1]+=L[t];let z=new Int32Array(u),P=new Int32Array(u);{let t=new Int32Array(u),r=L.slice(0,m+1);for(let n=0;n<u;n++)t[r[g[n]]++]=n;for(let t=0;t<=m;t++)r[t]=L[t];let n=new Uint8Array(u),i=[];for(let a=0;a<u;a++)if(!n[t[a]])for(i.push(t[a]);i.length>0;){let t=i.pop();if(!n[t]){n[t]=1,z[r[g[t]]++]=t;for(let r=N[t+1]-1;r>=N[t];r--){let t=b[D[r]];n[t]||i.push(t)}}}}let j=(t,r)=>{let n=L[t],i=L[t+1];if(i-n<2)return!1;for(let t=n;t<i;t++)if(Number.isNaN(r(z[t])))return!1;let a=Array.from(z.subarray(n,i)),s=new Map;return a.forEach((t,r)=>s.set(t,r)),a.sort((t,n)=>r(t)-r(n)||s.get(t)-s.get(n)),z.set(a,n),!0};for(let t=0;t<=m;t++)j(t,t=>T[t]);let F=!1;for(let r=0;r<a;r++)0!==t[r].pin&&(F=!0);if(F)for(let r=0;r<=m;r++){let n=Array.from(z.subarray(L[r],L[r+1])),i=new Map;n.forEach((t,r)=>i.set(t,r));let s=r=>r<a?t[r].pin:0;n.sort((t,r)=>s(t)-s(r)||i.get(t)-i.get(r)),z.set(n,L[r])}let B=new Uint8Array(m+1),W=r=>r<a&&(3===t[r].kind||4===t[r].kind)?t[r].hint:NaN;for(let t of[0,m])j(t,W)&&(B[t]=1);let H=()=>{for(let t=0;t<=m;t++){let r=L[t];for(let n=r,i=L[t+1];n<i;n++)P[z[n]]=n-r}};H();let U={n:u,real:a,maxRank:m,W:h,KIND:p,RANK:g,EF:v,ET:b,EFD:x,ETD:w,succStart:N,succE:D,predStart:O,predE:R,layerStart:L,order:z,pos:P,offsets:I,fixed:B,GRP:i,groupParent:n.groups?.parent},q=0,V=0;if(y>0&&m>0&&([q,V]=function(t,r){let{n,real:i,maxRank:a,W:s,EF:o,ET:l,EFD:c,ETD:d,succStart:u,succE:h,predStart:f,predE:p,layerStart:g,order:m,pos:y,offsets:v,fixed:b,GRP:x,groupParent:w}=t,$=0;for(let t=0;t<=a;t++)$=Math.max($,g[t+1]-g[t]);if($<2)return[0,0];let k=v?new Int32Array(o.length):void 0,M=new Int32Array(k?o.length:0),_=new Int32Array(k?n:0),A=k?h.slice():h,E=new Uint8Array(k?n:0);if(k){let t=p.slice(),r=(t,r,n,i)=>{for(let a=r+1;a<n;a++)if(i[t[a]]!==i[t[r]])return t.subarray(r,n).sort((t,r)=>i[t]-i[r]),!0;return!1};for(let i=0;i<n;i++){if(_[i]=1,r(t,f[i],f[i+1],d))for(let r=f[i]+1;r<f[i+1];r++)d[t[r]]!==d[t[r-1]]&&_[i]++,M[t[r]]=_[i]-1;r(A,u[i],u[i+1],c)&&(E[i]=1)}}let S=1;for(;S<(k?$+o.length:$);)S<<=1;let C=new Int32Array(2*S),T=new Int32Array(o.length),I=()=>{let t=0;for(let r=0;r<a;r++){let n=g[r+2]-g[r+1];if(k){let t=0;for(let n=g[r+1];n<g[r+2];n++){let r=m[n];for(let n=f[r];n<f[r+1];n++)k[p[n]]=t+M[p[n]];t+=_[r]}n=t}if(n<2)continue;let i=0;for(let t=g[r];t<g[r+1];t++){let r=m[t],n=u[r],a=u[r+1],s=i;for(let t=n;t<a;t++)T[i++]=k?k[A[t]]:y[l[h[t]]];let o=i-s;if(!(o<2))if(k&&E[r])for(let t=s+1;t<i;t++){let r=T[t],i=c[A[n+t-s]],a=t-1;for(;a>=s&&c[A[n+a-s]]===i&&T[a]>r;)T[a+1]=T[a],a--;T[a+1]=r}else if(o<=12)for(let t=s+1;t<i;t++){let r=T[t],n=t-1;for(;n>=s&&T[n]>r;)T[n+1]=T[n],n--;T[n+1]=r}else T.subarray(s,i).sort()}if(i<2)continue;let a=1;for(;a<n;)a<<=1;C.fill(0,0,2*a);for(let r=0;r<i;r++){let n=T[r]+a;for(C[n]++;n>1;)(1&n)==0&&(t+=C[n+1]),n>>=1,C[n]++}}return t},N=I(),O=new Float64Array(n),D=new Int32Array($),R=new Int32Array($),L=w?w.length:0,z=new Int32Array(L);for(let t=0;t<L;t++)for(let r=t;r>=0;r=w[r])z[t]++;let P=new Float64Array(L),j=new Int32Array(L),F=new Int32Array(L),B=(t,r)=>{let i=g[t],a=g[t+1];for(let t=i;t<a;t++)for(let r=x[m[t]];r>=0;r=w[r])P[r]=0,j[r]=0;for(let t=i;t<a;t++){let n=m[t];for(let i=x[n];i>=0;i=w[i])0===j[i]&&(F[i]=t),P[i]+=r[n],j[i]++}let s=t=>t>=n?P[t-n]/j[t-n]:r[t],o=t=>t>=n?F[t-n]:i+y[t],l=Array.from(m.subarray(i,a)).sort((t,r)=>{let i=t,a=r,l=x[t],c=x[r],d=l<0?0:z[l],u=c<0?0:z[c];for(;d>u;d--)i=n+l,l=w[l];for(;u>d;u--)a=n+c,c=w[c];for(;l!==c;)i=n+l,l=w[l],a=n+c,c=w[c];return s(i)-s(a)||o(i)-o(a)});m.set(l,i);for(let t=i;t<a;t++)y[m[t]]=t-i};if(x){let t=new Float64Array(n);for(let r=0;r<=a;r++){for(let n=g[r];n<g[r+1];n++)t[m[n]]=n-g[r];B(r,t)}}let W=x?I():N;if(0===W)return[0,N];let H=m.slice(),U=Math.min(W,N),q=(t,n)=>{let w=t?f:u,$=t?p:h,k=t?o:l,M=t?c:d;for(let o=1;o<=a;o++){let l=t?o:a-o;if(b[l])continue;let c=g[l],d=g[l+1],u=0;for(let n=c;n<d;n++){let a=m[n],o=a<i?r[a].pin:0;if(0!==o){O[a]=1e9*o,D[u++]=a;continue}let h=w[a],f=w[a+1];if(h===f){if(x){let r=t?g[l]-g[l-1]:g[l+2]-g[l+1];O[a]=(n-c)*r/(d-c);continue}O[a]=-1;continue}let p=0;for(let t=h;t<f;t++){let r=k[$[t]];p+=y[r],v&&s[r]>0&&(p+=M[$[t]]/s[r])}O[a]=p/(f-h),D[u++]=a}if(x){B(l,O);continue}if(u<2)continue;!function(t,r,n,i,a,s){let o=(t,r)=>n[t]<n[r]||n[t]===n[r]&&(a?i[t]>i[r]:i[t]<i[r]);for(let n=0;n<r;n+=8)for(let i=n+1,a=Math.min(r,n+8);i<a;i++){let r=t[i],a=i-1;for(;a>=n&&o(r,t[a]);)t[a+1]=t[a],a--;t[a+1]=r}let l=t,c=s;for(let t=8;t<r;t*=2){for(let n=0;n<r;n+=2*t){let i=Math.min(r,n+t),a=Math.min(r,n+2*t),s=n,d=i,u=n;for(;s<i&&d<a;)c[u++]=o(l[d],l[s])?l[d++]:l[s++];for(;s<i;)c[u++]=l[s++];for(;d<a;)c[u++]=l[d++]}let n=l;l=c,c=n}if(l!==t)for(let n=0;n<r;n++)t[n]=l[n]}(D,u,O,y,n,R);let h=0;for(let t=c;t<d;t++)-1!==O[m[t]]&&(m[t]=D[h++]);for(let t=c;t<d;t++)y[m[t]]=t-c}},V=()=>{let t=0;for(let r=0;r<=a;r++)for(let n=g[r];n<g[r+1];n++)if(!(m[n]>=i))for(let i=n+1;i<g[r+1];i++)m[i]<m[n]&&t++;return t},Y=()=>{for(let t=0;t<=a;t++)for(let r=g[t];r<g[t+1];r++)y[m[r]]=r-g[t]},G=t=>t<i?r[t].pin:0,Z=(t,r)=>{let n=r?o[t]:l[t];return v&&s[n]>0?y[n]+(r?c[t]:d[t])/s[n]:y[n]},X=(t,r)=>{let n=0;for(let i=f[t];i<f[t+1];i++){let t=Z(p[i],!0);for(let i=f[r];i<f[r+1];i++)t>Z(p[i],!0)&&n++}for(let i=u[t];i<u[t+1];i++){let t=Z(h[i],!1);for(let i=u[r];i<u[r+1];i++)t>Z(h[i],!1)&&n++}return n},K=()=>{for(let t=0;t<8;t++){let t=!1;for(let r=0;r<=a;r++){if(b[r])continue;let n=g[r];for(let i=n;i+1<g[r+1];i++){let r=m[i],a=m[i+1];G(r)!==G(a)||x&&x[r]!==x[a]||X(a,r)>=X(r,a)||(m[i]=a,m[i+1]=r,y[a]=i-n,y[r]=i+1-n,t=!0)}}if(!t)break}},J=m.slice(),Q=n<=600,ee=H,et=1/0;for(let t=0;t<(Q?2:1);t++){t>0&&(m.set(J),Y());let r=U,n=J.slice();for(let i=0,a=0;a<4&&i<24;i++,a++){q((i+t)%2==0,i%4>=2);let s=I();if(s<r&&(r=s,n.set(m),a=0,0===s))break}if(m.set(n),Q&&r>0){Y(),K();let t=I();t<r&&(r=t,n.set(m))}let i=Q?V():0;(0===t||r<W||r===W&&i<et)&&(W=r,ee=n,et=i)}if(m.set(ee),Y(),H.set(ee),x&&(W=I()),!Q)return[W,N];for(let t=0;t<i;t++)if(0!==r[t].pin)return[W,N];if(0===et||b[0]||b[a])return[W,N];for(let t=0;t<=a;t++)m.subarray(g[t],g[t+1]).reverse();return Y(),(I()>W||V()>=et)&&m.set(H),[W,N]}(U,t),H()),n.orderOnly){let i=rS(U,n);for(let r=0;r<a;r++)t[r].x=i[r];for(let t=0;t<s;t++){let n=r[t],a=n.reversed?n.head:n.tail,s=n.reversed?n.tail:n.head,o=[g[a],i[a]];if(!d[t]&&$[t]>=0)for(let r=$[t],n=r+l[t]-1;r<n;r++)o.push(g[r],i[r]);o.push(g[s],i[s]),n.points=o}return{width:0,height:0,crossings:q,declared:V}}A&&E&&function(t,r,n,i){let{real:a,W:s,EFD:o,ETD:l}=t;for(let c=0;c<a;c++){let a=Math.min(r[c].span,s[c]);if(!(a<=0||0!==r[c].kind))for(let r=0;r<2;r++){let s=[],d=[],u=rM(t,c,r,a,0===r?i:n,s,d);if(0===u)continue;let h=0===r?l:o,f=-u/2;for(let t=0;t<s.length;t++)f+=d[t],h[s[t]]=f}}}(U,t,A,E);let Y=rS(U,n),G=function(t){let{maxRank:r,KIND:n,layerStart:i,order:a}=t,s=new Uint8Array(r+1),o=!1;for(let t=1;t<r;t++){let r=i[t+1]>i[t];for(let s=i[t];r&&s<i[t+1];s++)1!==n[a[s]]&&(r=!1);r&&(s[t]=1,o=!0)}return o?s:void 0}(U);if(A&&E){let i=function(t,r,n){let i=[new Int32Array(t.n),new Int32Array(t.n)];for(let a=0;a<t.EF.length;a++)0!==n[a]&&i[0][t.ET[a]]++,0!==r[a]&&i[1][t.EF[a]]++;return i}(U,A,E);(function(t,r,n,i,a,s){let o=a.edgeSep,{n:l,real:c,maxRank:d,KIND:u,RANK:h,W:f,EF:p,ET:g,EFD:m,ETD:y,succStart:v,succE:b,predStart:x,predE:w,layerStart:$,order:k,pos:M}=t,_=t=>2===u[t]||1===u[t]&&(void 0===s||1!==s[h[t]]),A=(t,a)=>{let s=0===a?p[t]:g[t];return[0===a?n[s]+m[t]:n[s]+y[t],s<c&&0===r[s].kind?i[1-a][s]:0]},E=t=>{let r=$[h[t]],i=r+M[t],s=r=>f[r]/2+f[t]/2+(0===u[r]?a.nodeSep/2+o/2:u[r]===u[t]?o:o/2);return[i>r?n[k[i-1]]+s(k[i-1]):-1/0,i+1<$[h[t]+1]?n[k[i+1]]-s(k[i+1]):1/0]},S=(t,r,n,i,a)=>{let s=(r[1]!==n[1]?r[1]<n[1]:Math.abs(r[0]-t)<=Math.abs(n[0]-t))?[r[0],n[0]]:[n[0],r[0]];return s.find(t=>t>=i&&t<=a)??Math.max(i,Math.min(a,s[0]))},C=new Uint8Array(l),T=[];for(let r=1;r<d;r++)for(let i=$[r];i<$[r+1];i++){if(!_(k[i])||C[k[i]])continue;let r=k[i];for(;rb(u[p[w[x[r]]]]);)r=p[w[x[r]]];let a=r,o=-1/0,l=1/0;T.length=0;for(let t=r;rb(u[t]);t=g[b[v[t]]]){if(a=t,!_(t))continue;C[t]=1,T.push(t);let[r,n]=E(t);r>o&&(o=r),n<l&&(l=n)}if(o<=l){let t=S(n[T[0]],A(w[x[r]],0),A(b[v[a]],1),o,l);for(let r of T)n[r]=t;continue}for(let r of T){let[i,a]=E(r);i>a||(n[r]=S(n[r],A(r_(t,s,w[x[r]],0),0),A(r_(t,s,b[v[r]],1),1),i,a))}}})(U,t,Y,i,n,G),function(t,r,n,i,a,s,o){let{real:l,W:c,EF:d,ET:u,EFD:h,ETD:f,succStart:p,succE:g,predStart:m,predE:y,pos:v}=t,b=(p,g,m,y,v)=>{if(s[g][m]<2)return 0;p=r_(t,o,p,g);let b=0===g?d[p]:u[p],x=0===g?n[b]+h[p]:n[b]+f[p];if(v&&Math.abs(x-n[m])<=y/2+.5)return Math.max(-y/2,Math.min(y/2,x-n[m]));let w=x,$=0;b<l&&0===r[b].kind&&0!==(0===g?i:a)[p]&&s[1-g][b]>=2&&($=Math.max(0,Math.min(r[b].span,c[b])))>0&&(w=n[b]);let k=Math.max(n[m]-y/2,w-$/2),M=Math.min(n[m]+y/2,w+$/2);if(k>M+.5){let t=Math.max(0,y/2-40);return Math.max(-t,Math.min(t,x-n[m]))}return Math.max(k,Math.min(M,(n[m]*$+w*y)/($+y)))-n[m]},x=[];for(let n=0;n<l;n++){let s=Math.min(r[n].span,c[n]);if(!(s<=0||0!==r[n].kind))for(let r=0;r<2;r++){let o=0===r?d:u,l=0===r?m:p,c=0===r?y:g,h=[],f=[];if(rM(t,n,r,s,0===r?a:i,h,f),0===h.length)continue;1===h.length&&(f[0]=0);let b=[];for(let t=l[n];t<l[n+1];t++)b.push(c[t]);b.sort((t,r)=>v[o[t]]-v[o[r]]||t-r),x.push({v:n,side:r,span:s,ids:h,room:f,all:b})}}for(let t=0,r=!0;r&&t<6;t++)for(let{v:n,side:s,span:o,ids:l,room:c,all:d}of(r=!1,x)){let u=0===s?a:i,p=0===s?f:h,g=0,m=-o/2;for(let i=0;i<=d.length;i++){let a=i<d.length&&0===u[d[i]];if(i<d.length&&!a)continue;let h=0;for(let t=i-1;t>=0&&0!==u[d[t]];t--)h++;let f=a?p[d[i]]-16:o/2;if(h>0){let i=[],a=[],d=0;for(let r=0;r<h;r++){r>0&&(d+=c[g+r]),i.push(b(l[g+r],s,n,o,t>0)-d),a.push(1);let u=r>0&&0===c[g+r];for(;i.length>1&&(u||i[i.length-2]/a[a.length-2]>i[i.length-1]/a[a.length-1]);){u=!1;let t=i.pop(),r=a.pop();i[i.length-1]+=t,a[a.length-1]+=r}}let u=d,y=0;d=0;for(let t=0;t<i.length;t++){let n=f-u<m?(m+f-u)/2:Math.max(m,Math.min(f-u,i[t]/a[t]));for(let i=0;i<a[t];i++,y++)y>0&&(d+=c[g+y]),Math.abs(p[l[g+y]]-n-d)>.01&&(r=!0),p[l[g+y]]=n+d}g+=h}a&&(m=p[d[i]]+16)}}}(U,t,Y,A,E,i,G),function(t,r,n,i){let{n:a,KIND:s,RANK:o,EF:l,ET:c,EFD:d,ETD:u,layerStart:h,order:f,pos:p}=t,g=t=>void 0!==n&&1===s[t]&&1===n[o[t]],m=[],y=[],v=[],b=[];for(let r=0;r<l.length;r++){if(g(l[r]))continue;let i=r_(t,n,r,1);m.push(l[r]),y.push(c[i]),v.push(d[r]),b.push(u[i])}let x=t=>r[y[t]]+b[t]-r[m[t]]-v[t],w=new Int32Array(a),$=[];for(let t=0;t<a;t++)w[t]=t,$.push([t]);let k=(t,r)=>{let n=w[t],i=w[r];if(n!==i){for(let t of($[n].length<$[i].length&&([n,i]=[i,n]),$[i]))w[t]=n,$[n].push(t);$[i]=[]}},M=[];for(let t=0;t<m.length;t++){let r=Math.abs(x(t));r<.01?k(m[t],y[t]):r<=24&&M.push(t)}if(0===M.length)return;M.sort((t,r)=>Math.abs(x(t))-Math.abs(x(r))||t-r);let _=r=>rE(t,i,r),A=(t,n)=>{for(let i of $[t]){let a=h[o[i]],s=h[o[i]+1],l=a+p[i];if(l>a&&w[f[l-1]]!==t&&r[i]+n-r[f[l-1]]<_(i)+_(f[l-1])-.01||l+1<s&&w[f[l+1]]!==t&&r[f[l+1]]-r[i]-n<_(i)+_(f[l+1])-.01)return!1}return!0};for(let t of M){let n=x(t);if(.01>Math.abs(n)){k(m[t],y[t]);continue}if(Math.abs(n)>24||w[m[t]]===w[y[t]])continue;let i=w[m[t]],a=w[y[t]],o=$[i].length<=$[a].length?i:a;for(let l of[o,o===i?a:i]){let a=l===i?n:-n;if(!(Math.abs(n)>12&&!$[l].every(t=>1===s[t]))&&A(l,a)){for(let t of $[l])r[t]+=a;k(m[t],y[t]);break}}}}(U,Y,G,n);for(let t=0;t<s;t++){if(d[t])continue;let n=r[t],i=x[S[t]],a=w[C[t]];n.tailDx=n.reversed?a:i,n.headDx=n.reversed?i:a}}!function(t,r,n){let{maxRank:i,KIND:a,EF:s,ET:o,EFD:l,ETD:c,succStart:d,succE:u,predStart:h,predE:f,layerStart:p,order:g}=t;for(let[m,y]of[[0,3],[i,4]]){let i=p[m],v=p[m+1],b=[];for(let p=i;p<v;p++){let i=g[p],m=3===y;if(a[i]!==y||(m?d[i+1]-d[i]:h[i+1]-h[i])!=1)break;let v=r_(t,n,m?u[d[i]]:f[h[i]],+!!m),x=m?r[o[v]]+c[v]:r[s[v]]+l[v];if(b.length>0&&x<b[b.length-1]+1)break;b.push(x)}if(0!==b.length&&b.length===v-i)for(let t=i;t<v;t++)r[g[t]]=b[t-i]}}(U,Y,G);let Z=new Uint8Array(u);G&&!n.tracks&&function(t,r,n,i,a,s,o){let{maxRank:l,EF:c,ET:d,EFD:u,ETD:h,succStart:f,succE:p,predStart:g,predE:m,layerStart:y,order:v}=t,b=new Float64Array(r.length),x=new Float64Array(r.length),w=new Float64Array(r.length);for(let s=0;s<i.length;s++){let o=i[s];if(o<0)continue;let l=o+a[s]-1,y=t.RANK[o];for(let t=o;t<l;t++){if(!n[y+t-o])continue;let i=t;for(;i+1<l&&n[y+i+1-o];)i++;let a=m[g[t]],s=p[f[i]],v=r[c[a]]+u[a],$=r[d[s]]+h[s],k=i-t+2;for(let r=t;r<=i;r++)b[r]=v+($-v)*(r-t+1)/k,x[r]=v,w[r]=$;t=i}}let $=[];for(let i=1;i<l;i++){if(!n[i])continue;let a=y[i],l=y[i+1],c=Array.from(v.subarray(a,l)).sort((t,r)=>x[t]-x[r]||w[t]-w[r]||t-r);for(let n=0;n<c.length;){$.length=0;let i=n;for(;i<c.length&&1>Math.abs(x[c[i]]-x[c[n]])&&1>Math.abs(w[c[i]]-w[c[n]]);i++)$.push(c[i]);$.sort((r,n)=>t.pos[r]-t.pos[n]);for(let t=0;t<$.length;t++){let n=$[t];r[n]=b[n]+(t-($.length-1)/2)*s,(1===$.length||0===s)&&(o[n]=1)}n=i}}}(U,Y,G,$,l,n.apart?0:n.edgeSep,Z),n.tracks||function(t,r,n,i,a,s){let{maxRank:o,W:l,KIND:c,RANK:d,EF:u,ET:h,EFD:f,ETD:p,succStart:g,succE:m,predStart:y,predE:v,layerStart:b,order:x}=t,w=new Uint8Array(o+1),$=!1;for(let t=1;t<o;t++){let r=!1,n=!1;for(let i=b[t];i<b[t+1];i++){let t=c[x[i]];2===t?r=!0:1!==t&&(n=!0)}r&&!n&&(w[t]=1,$=!0)}if($)for(let t=0;t<n.length;t++){let o=n[t];if(!(o<0))for(let n=o,$=o+i[t]-1;n<$;n++){if(1!==c[n]||!w[d[n]])continue;let t=n,i=n;for(;t>o&&s[t-1];)t--;for(;i+1<$&&s[i+1];)i++;let k=v[y[t]],M=m[g[i]],_=r[u[k]]+f[k],A=r[h[M]]+p[M],E=Math.min(_,A)-a,S=Math.max(_,A)+a,C=!0,T=d[n];for(let t=b[T];C&&t<b[T+1];t++){let n=x[t];2===c[n]&&r[n]+l[n]/2>E&&r[n]-l[n]/2<S&&(C=!1)}if(!C)continue;s[n]=1;let I=i-t+2;for(let n=t;n<=i;n++)r[n]=_+(A-_)*(n-t+1)/I}}}(U,Y,$,l,n.edgeSep,Z);let X=new Int32Array(s+1),K=n.tracks||A&&!n.straight?{from:[],to:[],rank:[],lower:[],track:[],levels:[],wide:[]}:void 0,J=new Int32Array(m+1);if(K){for(let t=0;t<s;t++){if(X[t]=K.from.length,d[t])continue;let r=$[t],i=!1;for(let a=r,s=r<0?r:r+l[t]-1;a<s;a++){let t=void 0!==G&&1===G[g[a]];n.tracks||t===(1===Z[a])||(i=!0)}if(i)continue;let a=Y[v[S[t]]]+x[S[t]],s=g[v[S[t]]];for(let n=r,i=r<0?r:r+l[t]-1;n<i;n++)G&&G[g[n]]||(K.from.push(a),K.to.push(Y[n]),K.rank.push(s),K.lower.push(n),a=Y[n],s=g[n]);K.from.push(a),K.to.push(Y[b[C[t]]]+w[C[t]]),K.rank.push(s),K.lower.push(-1)}X[s]=K.from.length}let Q=(t,r)=>{let n=!1;for(let i=L[t];i<L[t+1];i++){let t=p[z[i]];if(t===r)n=!0;else if(1!==t)return!1}return n},ee=Q(0,3)?o:0,et=Q(m,4)?o:0,er=new Float64Array(m+1);for(let t=0;t<y;t++){let r=Math.abs(Y[v[t]]+x[t]-Y[b[t]]-w[t]);r>er[g[v[t]]]&&(er[g[v[t]]]=r)}let en=new Float64Array(m+1),ei=new Float64Array(m+1),ea=t=>(t<ee||t>=m-et?n.portSep:n.rankSep)/o,es=new Float64Array(m+1);for(let t=0;t<m;t++)es[t]=K?ea(t):Math.max(ea(t),Math.min(3*n.rankSep/o,.125*er[t]));let eo=new Uint8Array(m+1).fill(1);for(let t=0;t<a;t++)eo[g[t]]=0;for(let t=1;t<m;t++){if(n.tracks||!eo[t]||1!==k[t]&&2!==k[t])continue;let r=Math.min((n.headRoom??0)/2,es[1===k[t]?t-1:t]/2);es[t-1]+=1===k[t]?-r:r,es[t]+=1===k[t]?r:-r}let el=t=>1===p[t]&&eo[g[t]]&&!n.tracks?(ei[g[t]]-en[g[t]])/4:0,ec=n.tracks?18:28,ed=n.tracks?10:12,eu=n.tracks?14:12,eh=new Int32Array(m+1);if(K){let t=new Float64Array(m+1);for(let r=0;r<m;r++){if(G&&G[r])continue;let n=r+1;for(t[r]=es[r];n<m&&G&&G[n];)t[r]+=es[n++];eh[r]=n}for(let r=0;r<K.from.length;r++)K.wide.push(+(Math.abs(K.from[r]-K.to[r])>2*t[K.rank[r]]));let r=new Float64Array(m+1);!function(t,r,n,i,a){let{from:s,to:o,rank:l,track:c,levels:d,wide:u}=t,h=s.length,f=new Map;for(let t=0;t<h;t++){if(c.push(-1),d.push(0),.5>Math.abs(s[t]-o[t]))continue;let r=f.get(l[t]);r?r.push(t):f.set(l[t],[t])}if(0===f.size)return;let p=new Float64Array(h),g=new Float64Array(h);for(let t=0;t<h;t++)p[t]=Math.min(s[t],o[t]),g[t]=Math.max(s[t],o[t]);let m=(t,r)=>+(t>=p[r]-.5&&t<=g[r]+.5),y=(t,r)=>.5>Math.abs(s[t]-s[r])||.5>Math.abs(o[t]-o[r]),v=(t,r)=>p[t]<g[r]-.5&&p[r]<g[t]-.5,b=(t,r)=>v(t,r)&&!y(t,r),x=(t,r)=>v(t,r)||m(o[t],r)+m(s[r],t)+m(o[r],t)+m(s[t],r)>0,w=(t,r)=>m(o[t],r)+m(s[r],t),$=t=>{let r=t.map((t,r)=>r).sort((r,n)=>p[t[r]]-p[t[n]]),n=[];for(let i=0;i<r.length;i++){let a=r[i],s=g[t[a]]+2;for(let o=i+1;o<r.length&&p[t[r[o]]]<=s;o++){let t=r[o];n.push(Math.min(a,t),Math.max(a,t))}}return n},k=t=>{t.sort((t,r)=>g[r]-p[r]-(g[t]-p[t])||p[t]-p[r]||t-r);let r=t.length,i=[],a=t.map((t,r)=>r),s=t=>{for(;a[t]!==t;)t=a[t]=a[a[t]];return t},o=r<=400,l=o?$(t):[],u=o?t.map(()=>[]):[];for(let r=0;r<l.length;r+=2){let n=l[r],i=l[r+1];b(t[n],t[i])&&(u[n].push(i),u[i].push(n))}let h=t.map((t,r)=>r);if(o){let n=new Int32Array(r),o=[];for(let t=0;t<r;t++)i.push([]),o.push([]);for(let r=0;r<l.length;r+=2){let c=l[r],d=l[r+1],u=t[c],h=t[d];if(!x(u,h))continue;a[s(c)]=s(d);let f=w(u,h),p=w(h,u);if(f===p)continue;let g=f<p?c:d,m=f<p?d:c;i[m].push(g),o[g].push(m),n[m]++}let c=new Uint8Array(r);h=[];for(let t=0;t<r;t++){let t=-1;for(let i=0;i<r&&!(!c[i]&&((t<0||n[i]<n[t])&&(t=i),0===n[i]));i++);for(let r of(c[t]=1,h.push(t),o[t]))n[r]--}}let f=new Set,m=[],y=0;for(let r of h){let n=t[r],a=0;for(let n of i[r]??[])c[t[n]]>=a&&(a=c[t[n]]+1);if(o){for(let n of(f.clear(),u[r]))f.add(c[t[n]]);for(;f.has(a);)a++}else{for(;m[a]?.some(t=>b(n,t));)a++;(m[a]??=[]).push(n)}c[n]=a,a>=y&&(y=a+1)}let v=new Int32Array(r).fill(y),k=new Int32Array(r).fill(-1);for(let n=0;n<r;n++){let r=s(n);v[r]=Math.min(v[r],c[t[n]]),k[r]=Math.max(k[r],c[t[n]])}for(let i=0;i<r;i++){let r=s(i);d[t[i]]=k[r]-v[r]+1,n&&(c[t[i]]-=v[r])}return y},M=(t,r,n)=>{let i=rA(o[t]-s[t],r);for(let a=0;a<=16;a++){let l=a/16,c=1-l;n[2*a]=s[t]+(o[t]-s[t])*l*l*(3-2*l),n[2*a+1]=r*(3*i*l*c*c+3*(1-i)*l*l*c+l*l*l)}},_=(t,r,n)=>{let i=n*n*1.000000001;for(let a=0;a<=16;a++){let s=t[2*a],o=t[2*a+1];for(let t=0;t<16;t++){let a=r[2*t+2]-r[2*t],l=r[2*t+3]-r[2*t+1],c=Math.max(0,Math.min(1,((s-r[2*t])*a+(o-r[2*t+1])*l)/(a*a+l*l||1))),d=s-r[2*t]-c*a,u=o-r[2*t+1]-c*l;if(d*d+u*u<i&&Math.hypot(d,u)<n)return!0}}return!1},A=(t,r,n,i)=>{let a=Math.max(n/2,n-24);return M(t,a,ry),M(r,a,rv),_(ry,rv,i)||_(rv,ry,i)};for(let[t,l]of f){if(!n){r[t]=k(l);continue}if(l.length>400)continue;let h=l.filter(t=>1===u[t]);k(h);let f=new Set(h.filter(t=>d[t]>1)),m=$(l);for(let r=0;r<m.length;r+=2){let n=l[m[r]],a=l[m[r+1]];f.has(n)&&f.has(a)||!b(n,a)||s[n]<o[n]!=s[a]<o[a]||A(n,a,i[t],1===u[n]||1===u[a]?8:4)&&f.add(n).add(a)}for(let t of h)c[t]=-1,d[t]=0;if(0===f.size)continue;let w=0,M=0,_=new Set;for(let t=0;t<m.length;t+=2){let r=l[m[t]],n=l[m[t+1]];if(f.has(r)&&f.has(n)){if(!v(r,n))continue;s[r]<o[r]!=s[n]<o[n]?w++:y(r,n)||M++}else(f.has(r)||f.has(n))&&x(r,n)&&_.add(r).add(n)}if(w>M){for(let r of l)(g[r]-p[r])*.5>a[t]&&(a[t]=(g[r]-p[r])*.5);continue}let E=l.filter(t=>f.has(t)||1!==u[t]&&_.has(t));k(E);let S=0;for(let t of E)d[t]>S&&(S=d[t]);r[t]=S}}(K,J,!n.tracks,t,r);for(let i=0;i<m;i++)J[i]>0?es[i]+=Math.max(0,2*ec+(J[i]-1)*ed-t[i]):r[i]>0&&(es[i]+=Math.max(0,Math.min(3*n.rankSep,r[i])-t[i]))}let ef=0;for(let t=0;t<=m;t++){let r=0;for(let n=L[t];n<L[t+1];n++)f[z[n]]>r&&(r=f[z[n]]);en[t]=ef,ei[t]=ef+r,ef+=r+es[t]}let ep=ef,eg=(t,r=K.track[t])=>{let i=K.rank[t],a=ei[i],s=en[eh[i]],o=n.tracks?J[i]:K.levels[t],l=o>1?Math.min(eu,(s-a-2*ec)/(o-1)):0;return(a+s)/2+(r-(o-1)/2)*l},em=1/0,ey=-1/0;for(let t=0;t<u;t++){let r=h[t]/2;Y[t]-r<em&&(em=Y[t]-r),Y[t]+r>ey&&(ey=Y[t]+r)}let ev=new Uint8Array(m+1),eb=new Uint8Array(m+1);for(let t=0;t<a;t++)0!==p[t]||!A||(O[t+1]>O[t]&&(ev[g[t]]=1),N[t+1]>N[t]&&(eb[g[t]]=1));for(let r=0;r<a;r++){let n=t[r],i=n.rank;n.x=Y[r]-em,0===p[r]&&eb[i]&&!ev[i]?n.y=ei[i]-n.h/2:0===p[r]&&ev[i]&&!eb[i]?n.y=en[i]+n.h/2:n.y=(en[i]+ei[i])/2}for(let i=0;i<s;i++){let a=r[i],s=t[a.reversed?a.head:a.tail],o=t[a.reversed?a.tail:a.head],c=[s.x+(a.reversed?a.headDx:a.tailDx),s.y+s.h/2],d=$[i];if(K&&X[i+1]>X[i])for(let t=X[i];t<X[i+1];t++){if(K.track[t]>=0&&(n.tracks||1===K.wide[t])){let r=eg(t);c.push(K.from[t]-em,r,K.to[t]-em,r)}else K.track[t]>0&&c.push(K.from[t]-em,eg(t,K.track[t]-1));let r=K.lower[t];r<0||(c.push(Y[r]-em,en[g[r]]+el(r)),ei[g[r]]>en[g[r]]&&c.push(Y[r]-em,ei[g[r]]-el(r)))}else if(d>=0)for(let t=d,r=d+l[i]-1;t<r;t++){if(Z[t])continue;let r=Y[t]-em,n=en[g[t]],i=ei[g[t]];c.push(r,n+el(t)),i>n&&c.push(r,i-el(t))}if(c.push(o.x+(a.reversed?a.tailDx:a.headDx),o.y-o.h/2),a.reversed)for(let t=0,r=c.length-2;t<r;t+=2,r-=2){let n=c[t],i=c[t+1];c[t]=c[r],c[t+1]=c[r+1],c[r]=n,c[r+1]=i}a.points=c;let u=M[i];u>=0?(a.labelX=Y[u]-em,a.labelY=(en[g[u]]+ei[g[u]])/2):a.labelW>0&&(a.labelX=(c[0]+c[c.length-2])/2,a.labelY=(c[1]+c[c.length-1])/2)}return{width:ey-em,height:ep}}function r$(t,r){let n=t.length,i=r.length,a=new Int32Array(n+1);for(let n=0;n<i;n++){let i=r[n];i.reversed=3===t[i.head].kind||4===t[i.tail].kind,i.reversed||a[i.tail+1]++}for(let t=0;t<n;t++)a[t+1]+=a[t];let s=new Int32Array(a[n]);{let t=a.slice(0,n);for(let n=0;n<i;n++)r[n].reversed||(s[t[r[n].tail]++]=n)}let o=new Uint8Array(n),l=a.slice(0,n),c=[];for(let t=0;t<n;t++)if(0===o[t])for(c.push(t),o[t]=1;c.length>0;){let t=c[c.length-1];if(l[t]<a[t+1]){let n=r[s[l[t]++]],i=n.head;1===o[i]?n.reversed=!0:0===o[i]&&(o[i]=1,c.push(i))}else o[t]=2,c.pop()}}function rk(t,r,n){let i=t.length,a=r.length,s=new Int32Array(a),o=new Int32Array(a),l=new Int32Array(a),c=new Int32Array(i+1),d=new Int32Array(i+1);for(let t=0;t<a;t++){let i=r[t],a=i.reversed?i.head:i.tail,u=i.reversed?i.tail:i.head;s[t]=a,o[t]=u,l[t]=Math.max(1,i.minlen)*n,c[a+1]++,d[u+1]++}for(let t=0;t<i;t++)c[t+1]+=c[t],d[t+1]+=d[t];let u=new Int32Array(a),h=new Int32Array(a);{let t=c.slice(0,i),r=d.slice(0,i);for(let n=0;n<a;n++)u[t[s[n]]++]=n,h[r[o[n]]++]=n}let f=new Int32Array(i);for(let r=0;r<i;r++)3===t[r].kind&&(f[r]=-n);let p=new Int32Array(i);for(let t=0;t<i;t++)p[t]=d[t+1]-d[t];let g=new Int32Array(i),m=0;for(let t=0;t<i;t++)0===p[t]&&(g[m++]=t);for(let t=0;t<m;t++){let r=g[t];for(let t=c[r];t<c[r+1];t++){let n=u[t],i=o[n];f[r]+l[n]>f[i]&&(f[i]=f[r]+l[n]),0==--p[i]&&(g[m++]=i)}}for(let t=0;t<8;t++){let t=!1;for(let r=m-1;r>=0;r--){let n=g[r],i=d[n+1]-d[n],a=c[n+1]-c[n];if(0===i&&0===a)continue;let p=-1/0,m=1/0;for(let t=d[n];t<d[n+1];t++){let r=h[t];p=Math.max(p,f[s[r]]+l[r])}for(let t=c[n];t<c[n+1];t++){let r=u[t];m=Math.min(m,f[o[r]]-l[r])}let y=f[n];a>i&&m!==1/0?y=m:i>a&&p!==-1/0&&(y=p),y!==f[n]&&(f[n]=y,t=!0)}if(!t)break}let y=1/0,v=-1/0,b=!1;for(let r=0;r<i;r++){let n=t[r].kind;3===n&&(b=!0),3!==n&&4!==n&&(f[r]<y&&(y=f[r]),f[r]>v&&(v=f[r]))}y===1/0&&(y=0,v=0);for(let r=0;r<i;r++)3===t[r].kind?f[r]=y-n:4===t[r].kind&&(f[r]=v+n);b&&(y-=n);for(let r=0;r<i;r++)t[r].rank=f[r]-y}function rM(t,r,n,i,a,s,o){let l=0===n?t.predStart:t.succStart,c=0===n?t.predE:t.succE,d=0===n?t.EF:t.ET,u=t.pos;for(let t=l[r];t<l[r+1];t++)0!==a[c[t]]&&s.push(c[t]);if(s.length<2)return 0;s.sort((t,r)=>u[d[t]]-u[d[r]]||t-r);let h=t=>{let r=0;o[0]=0;for(let n=1;n<s.length;n++){let i=a[s[n]]===a[s[n-1]];o[n]=t(i&&1===a[s[n]],i),r+=o[n]}return r},f=h(()=>1);if(i/f<8&&(f=h(t=>t?.5:1)),i/f<8&&(f=h((t,r)=>+!r)),0===f)return 0;let p=Math.min(16,i/f);for(let t=1;t<s.length;t++)o[t]*=p;return f*p}function r_(t,r,n,i){if(!r)return n;let{KIND:a,RANK:s,EF:o,ET:l,succStart:c,succE:d,predStart:u,predE:h}=t;for(let t=0;t<1e5;t++){let t=0===i?o[n]:l[n];if(1!==a[t]||!r[s[t]])break;n=0===i?h[u[t]]:d[c[t]]}return n}function rA(t,r){return Math.max(.25,Math.min(.5,4*Math.abs(r)/(Math.abs(t)||1)))}function rE(t,r,n){return t.W[n]/2+(0===t.KIND[n]?r.nodeSep:r.edgeSep)/2}function rS(t,r){let{n,maxRank:i,W:a,KIND:s,EF:o,ET:l,EFD:c,ETD:d,succStart:u,succE:h,predStart:f,predE:p,layerStart:g,order:m,pos:y}=t,v=o.length,b=new Float64Array(n);for(let i=0;i<n;i++)b[i]=rE(t,r,i);let x=new Int32Array(v);for(let t=0;t<v;t++)x[t]=y[l[t]];for(let t=0;t<n;t++)u[t+1]-u[t]>1&&rx(h,u[t],u[t+1],x);for(let t=0;t<v;t++)x[t]=y[o[t]];for(let t=0;t<n;t++)f[t+1]-f[t]>1&&rx(p,f[t],f[t+1],x);let w=new Uint8Array(v);for(let t=1;t<=i;t++){let r=g[t]-g[t-1],n=g[t],i=g[t+1],a=0,l=n;for(let t=n;t<i;t++){let n=m[t],c=-1;if(rb(s[n])){let t=o[p[f[n]]];rb(s[t])&&(c=t)}let d=c>=0?y[c]:r;if(c>=0||t===i-1){for(let r=l;r<=t;r++){let t=m[r],n=rb(s[t]);for(let r=f[t];r<f[t+1];r++){let t=p[r],i=y[o[t]];(i<a||d<i)&&!(n&&rb(s[o[t]]))&&(w[t]=1)}}l=t+1,a=d}}}let $=[],k=new Int32Array(n),M=new Int32Array(n),_=new Float64Array(n),A=new Int32Array(n),E=new Int32Array(n),S=new Float64Array(n),C=new Int32Array(n),T=new Int32Array(n+1),I=new Int32Array(n),N=new Int32Array(n),O=new Int32Array(n),D=new Float64Array(n);for(let t=0;t<4;t++){let r=t<2,a=(1&t)==1,s=r?f:u,v=r?p:h,x=r?o:l,R=r?d:c,L=r?c:d;for(let t=0;t<n;t++)k[t]=t,M[t]=t,_[t]=0,C[t]=0,T[t+1]=0,D[t]=0;for(let t=0;t<=i;t++){let n=r?t:i-t,o=g[n],l=g[n+1],c=r?n-1:n+1,d=c>=0&&c<=i?g[c+1]-g[c]-1:0,u=-1;for(let t=a?l-1:o;a?t>=o:t<l;a?t--:t++){let r=m[t],n=s[r],i=s[r+1]-n;if(0===i)continue;let o=n+(i-1>>1),l=n+(i>>1);for(let t=0;t<2&&(1!==t||o!==l);t++){let n=v[0===t!==a?o:l],i=x[n],s=a?d-y[i]:y[i];M[r]===r&&u<s&&0===w[n]&&(M[i]=r,M[r]=k[r]=k[i],_[r]=_[i]+L[n]-R[n],u=s)}}}let z=0;for(let t=0;t<=i;t++){let r=g[t],n=g[t+1];for(let t=r+1;t<n;t++){let r=a?m[t]:m[t-1],n=a?m[t-1]:m[t],i=b[r]+b[n];A[z]=k[r],E[z]=k[n],S[z]=a?i-_[r]+_[n]:i+_[r]-_[n],C[k[n]]++,T[k[r]+1]++,z++}}for(let t=0;t<n;t++)T[t+1]+=T[t];for(let t=0;t<n;t++)N[t]=T[t];for(let t=0;t<z;t++)I[N[A[t]]++]=t;let P=0;for(let t=0;t<n;t++)k[t]===t&&0===C[t]&&(O[P++]=t);for(let t=0;t<P;t++){let r=O[t];for(let t=T[r];t<T[r+1];t++){let n=I[t],i=E[n];D[r]+S[n]>D[i]&&(D[i]=D[r]+S[n]),0==--C[i]&&(O[P++]=i)}}for(let t=P-1;t>=0;t--){let r=O[t],n=1/0;for(let t=T[r];t<T[r+1];t++){let r=I[t],i=D[E[r]]-S[r];i<n&&(n=i)}n!==1/0&&n>D[r]&&(D[r]=n)}let j=new Float64Array(n);for(let t=0;t<n;t++)j[t]=(a?-D[k[t]]:D[k[t]])+_[t];$.push(j)}let R=0,L=1/0,z=[],P=[];for(let t=0;t<4;t++){let r=1/0,i=-1/0,s=$[t];for(let t=0;t<n;t++){let n=a[t]/2;s[t]-n<r&&(r=s[t]-n),s[t]+n>i&&(i=s[t]+n)}z.push(r),P.push(i),i-r<L&&(L=i-r,R=t)}for(let t=0;t<4;t++){let r=(1&t)==0?z[R]-z[t]:P[R]-P[t];if(0!==r){let i=$[t];for(let t=0;t<n;t++)i[t]+=r}}let j=new Float64Array(n);for(let t=0;t<n;t++){let r=$[0][t],n=$[1][t],i=$[2][t],a=$[3][t],s;r>n&&(s=r,r=n,n=s),i>a&&(s=i,i=a,a=s),r>i&&(s=r,r=i,i=s),n>a&&(s=n,n=a,a=s),n>i&&(s=n,n=i,i=s),j[t]=(n+i)/2}return j}function rC(t){return"BT"===t||"LR"===t||"RL"===t?t:"TB"}function rT(t,r,n,i){let a=[];for(let r of t)a.push(r.x,r.y,r.w,r.h);let s=[];for(let t of r)s.push(t.labelX,t.labelY);let o=[];for(let t of n)for(let r of(o.push(t.x,t.y),t.ports))o.push(r.px,r.py);return{nodes:a,routes:r.map(t=>t.route),labels:s,levels:o,total:i}}function rI(t,r,n,i){r.forEach((r,n)=>{r.x=t.nodes[4*n],r.y=t.nodes[4*n+1],r.w=t.nodes[4*n+2],r.h=t.nodes[4*n+3]}),n.forEach((r,n)=>{r.route=t.routes[n],r.labelX=t.labels[2*n],r.labelY=t.labels[2*n+1]});let a=0;for(let r of i)for(let n of(r.x=t.levels[a++],r.y=t.levels[a++],r.ports))n.px=t.levels[a++],n.py=t.levels[a++];return t.total}function rN(t,r,n=0){let i=0;for(let t of r)t.src!==t.dst&&t.route.length>3&&(i+=(t.route.length/3-1)*3);let a=new Float64Array(i),s=new Float64Array(i),o=new Float64Array(i),l=new Float64Array(i),c=new Float64Array(i),d=new Float64Array(i),u=new Int32Array(i),h=new Uint8Array(i),f=0,p=1/0,g=-1/0,m=NaN,y=NaN,v=NaN,b=NaN,x=(t,r,n,i,x,w)=>{let $=f-1;n===v&&i===b&&(w===i&&y===i||x===n&&m===n)&&u[$]===t&&h[$]===r&&(n-m)*(x-n)+(i-y)*(w-i)>0&&(f--,n=m,i=y),m=n,y=i,v=x,b=w,h[f]=r,a[f]=Math.min(n,x),o[f]=Math.max(n,x),s[f]=n<=x?i:w,l[f]=n<=x?w:i,c[f]=Math.min(i,w),d[f]=Math.max(i,w),c[f]<p&&(p=c[f]),d[f]>g&&(g=d[f]),u[f++]=t};for(let t=0;t<r.length;t++){let i=r[t];if(i.src===i.dst)continue;let a=i.route,s=t=>.01>Math.abs(a[t]-a[t-3])||.01>Math.abs(a[t+1]-a[t-2]),o=t=>Math.abs(a[t]-a[t-3])+Math.abs(a[t+1]-a[t-2]),l=t=>0===n&&t>0&&t<a.length-3&&s(t)&&s(t+3)&&o(t)>=.01&&o(t+3)>=.01&&.01>Math.abs(a[t]-a[t-3])!=.01>Math.abs(a[t+3]-a[t]),c=a[0],d=a[1];for(let r=3;r<a.length;r+=3){let i=3===r|2*(r===a.length-3),u=c,h=d,f=a[r],p=a[r+1];if(c=f,d=p,s(r)||2===n){if(!l(r)){x(t,i,u,h,f,p);continue}let n=l(r-3)?o(r)/2:o(r),s=l(r+3)?o(r+3)/2:o(r+3),g=(f-a[r-3])/o(r),m=(p-a[r-2])/o(r),y=(a[r+3]-f)/o(r+3),v=(a[r+4]-p)/o(r+3),b=f-g*n,w=p-m*n;x(t,i,u,h,b,w);let $=f-g*n*.38,k=p-m*n*.38,M=f+y*s*.38,_=p+v*s*.38;c=f+y*s,d=p+v*s;let A=i|2*(r+3===a.length-3),E=b,S=w;for(let r=1;r<=2;r++){let n=r/2,i=1-n,a=i*i*i*b+3*i*i*n*$+3*i*n*n*M+n*n*n*c,s=i*i*i*w+3*i*i*n*k+3*i*n*n*_+n*n*n*d;x(t,A,E,S,a,s),E=a,S=s}continue}if(1===n){let n=0===a[r+2],s=n?u:(u+f)/2,o=n?(h+p)/2:h;x(t,i,u,h,s,o),x(t,i,s,o,n?f:s,n?o:p),x(t,i,n?f:s,n?o:p,f,p);continue}let g=0===a[r+2],m=g?rA(f-u,p-h):rA(p-h,f-u),y=u,v=h;for(let r=1;r<=3;r++){let n=r/3,a=1-n,s=n*n*(3-2*n),o=3*m*n*a*a+3*(1-m)*n*n*a+n*n*n,l=u+(f-u)*(g?s:o),c=h+(p-h)*(g?o:s);x(t,i,y,v,l,c),y=l,v=c}}}let w=g>p?Math.round(Math.sqrt(f)):1,$=g>p?w/(g-p):0,k=t=>Math.min(w-1,Math.floor((t-p)*$)),M=new Int32Array(f),_=new Int32Array(w+1);for(let t=0;t<f;t++){M[t]=k(c[t]);for(let r=M[t],n=k(d[t]);r<=n;r++)_[r+1]++}for(let t=0;t<w;t++)_[t+1]+=_[t];let A=_.slice(0,w),E=new Int32Array(_[w]);for(let t=0;t<f;t++)for(let r=M[t],n=k(d[t]);r<=n;r++)E[A[r]++]=t;let S=new Float64Array(8*r.length),C=(t,r,n,i)=>.5>Math.abs(t[r]-t[n])&&.5>Math.abs(t[r]-t[i])||.5>Math.abs(t[r+1]-t[n+1])&&.5>Math.abs(t[r+1]-t[i+1]);for(let t=0;t<r.length;t++){let n=r[t].route;if(n.length<6)continue;let i=3;for(;i+3<n.length&&C(n,0,i,i+3);)i+=3;let a=n.length-3,s=a-3;for(;s>=3&&C(n,a,s,s-3);)s-=3;S.set([n[0],n[1],n[i],n[i+1],n[s],n[s+1],n[a],n[a+1]],8*t)}let T=(t,r,n,i)=>{let a=8*t+4*(1!==r),s=S[a],o=S[a+1],l=S[a+2]-s,c=S[a+3]-o,d=l*l+c*c,u=d>0?Math.max(0,Math.min(1,((n-s)*l+(i-o)*c)/d)):0;return .5>Math.hypot(n-s-u*l,i-o-u*c)},I=0;for(let n=0;n<w;n++){let i=_[n+1];if(i-_[n]>128)E.subarray(_[n],i).sort((t,r)=>a[t]-a[r]||t-r);else for(let t=_[n]+1;t<i;t++){let r=E[t],i=t;for(;i>_[n]&&a[E[i-1]]>a[r];i--)E[i]=E[i-1];E[i]=r}for(let f=_[n];f<i;f++){let p=E[f],g=o[p]-a[p],m=l[p]-s[p],y=M[p]===n;for(let v=f+1;v<i;v++){let i=E[v];if(a[i]>o[p])break;if(d[i]<c[p]||c[i]>d[p]||u[p]===u[i]||!y&&M[i]!==n||g*(s[i]-s[p])-m*(a[i]-a[p])>0==g*(l[i]-s[p])-m*(o[i]-a[p])>0)continue;let f=o[i]-a[i],b=l[i]-s[i],x=f*(s[p]-s[i])-b*(a[p]-a[i]),w=f*(l[p]-s[i])-b*(o[p]-a[i]);if(x>0==w>0)continue;let $=r[u[p]],k=r[u[i]],_=x/(x-w),A=a[p]+_*g,S=s[p]+_*m,C=(r,n,a)=>(h[p]&n)!=0&&(h[i]&a)!=0||Math.abs(A-t[r].x)<t[r].w/2+24&&Math.abs(S-t[r].y)<t[r].h/2+24||T(u[p],n,A,S)&&T(u[i],a,A,S);$.src===k.src&&C($.src,1,1)||$.src===k.dst&&C($.src,1,2)||$.dst===k.src&&C($.dst,2,1)||$.dst===k.dst&&C($.dst,2,2)||I++}}}return I}function rO(t,r){let n=r=>{let n=new Set;for(let i=t[r].parent;i>=0&&!n.has(i);i=t[i].parent)n.add(i);return n};for(let[i,a]of r){if(i<0||a<0||i===a)continue;let r=n(i),s=n(a);for(let n of r)s.has(n)||(t[n].dir=void 0);for(let n of s)r.has(n)||(t[n].dir=void 0)}}function rD(t,r,n,i){for(let r of t)r.x+=n,r.y+=i;for(let t of r){for(let r=0;r<t.route.length;r+=3)t.route[r]+=n,t.route[r+1]+=i;t.labelX+=n,t.labelY+=i}}function rR(t,r,n=-1){return{w:t,h:r,parent:n,isGroup:!1,dir:void 0,padX:0,padTop:0,padBottom:0,minW:0,seq:0,span:0,x:0,y:0}}function rL(t){return"TB"===t?0:"BT"===t?2:"LR"===t?3:1}function rz(t){return t+2&3}function rP(t,r,n,i){let a=t.length,s=new Map,o=[],l=(t,r)=>{let n={id:t,dir:r,items:[],edges:[],ports:[],portOf:new Map,routes:new Map,x:0,y:0};return s.set(t,n),n},c=l(-1,n),d=[];for(let t=0;t<a;t++)d.push([]);let u=[];for(let r=0;r<a;r++){let n=t[r].parent;n>=0&&n<a&&n!==r&&t[n].isGroup?d[n].push(r):(t[r].parent=-1,u.push(r))}c.items=u,o.push(c);let h=new Int32Array(a),f=new Uint8Array(a),p=r=>{for(let n=r;n<o.length;n++){let r=o[n];for(let n of r.items)if(f[n]=1,h[n]=r.id<0?0:h[r.id]+1,t[n].isGroup){let i=l(n,t[n].dir??r.dir);i.items=d[n],o.push(i)}}};p(0);for(let r=0;r<a;r++){if(f[r])continue;let i=t[r].parent;if(d[i]=d[i].filter(t=>t!==r),t[r].parent=-1,c.items.push(r),f[r]=1,h[r]=0,t[r].isGroup){let i=o.length,a=l(r,t[r].dir??n);a.items=d[r],o.push(a),p(i)}}for(let r=o.length-1;r>0;r--){let n=o[r],i=1/0;for(let r of n.items)t[r].seq<i&&(i=t[r].seq);i!==1/0&&(t[n.id].seq=i)}for(let r of o)r.items.sort((r,n)=>t[r].seq-t[n].seq||r-n);let g=0;for(let n of r){let r=n.src,i=n.dst,a=0;for(;h[r]>h[i];a++)r=t[r].parent;for(;h[i]>h[r];a++)i=t[i].parent;for(;r!==i&&t[r].parent!==t[i].parent;a+=2)r=t[r].parent,i=t[i].parent;r!==i&&(g+a>4e4?(n.src=r,n.dst=i):g+=a)}let m=[],y=[];for(let n=0;n<r.length;n++){let i=r[n];if(i.route=[],i.src===i.dst){m.push(n);continue}let a=i.src,o=i.dst,l=[],c=[];for(;h[a]>h[o];)l.push(a),a=t[a].parent;for(;h[o]>h[a];)c.push(o),o=t[o].parent;if(a===o){y.push(n);continue}for(;t[a].parent!==t[o].parent;)l.push(a),c.push(o),a=t[a].parent,o=t[o].parent;for(let[r,i]of(s.get(t[a].parent).edges.push({e:n,a:a,b:o}),[[l,!0],[c,!1]]))for(let a of r){let r=s.get(t[a].parent),o={e:n,inner:a,out:i,side:0,hint:NaN,px:0,py:0,route:[]};r.ports.push(o),r.portOf.set(2*n+ +!i,o)}}let v=new Int32Array(a),b=(t,r,n)=>(n?r.src:r.dst)!==t,x=(n,i)=>{let a="TB"===n.dir||"BT"===n.dir,o=rL(n.dir),l=[],c=[];n.items.forEach((r,n)=>{v[r]=n;let s=t[r],o=i?rg(a?s.w:s.h,a?s.h:s.w):rg(0,0);o.span=s.isGroup?Math.min(s.span,o.w-2*s.padX):s.span,o.key=k?$[r]:NaN,l.push(o)});let d=(n,i,a)=>t[n].isGroup&&b(n,r[i],a),u=(n,o,l)=>{if(!i||!t[n].isGroup||!b(n,r[o],l))return 0;let c=s.get(n).portOf.get(2*o+ +!l);return a?c.px-t[n].w/2:c.py-t[n].h/2};for(let t of n.edges){let n=r[t.e],s=rm(v[t.a],v[t.b],n.minlen);i&&(s.labelW=a?n.labelW:n.labelH,s.labelH=a?n.labelH:n.labelW,s.tailDx=u(t.a,t.e,!0),s.headDx=u(t.b,t.e,!1),s.tailFixed=d(t.a,t.e,!0),s.headFixed=d(t.b,t.e,!1)),c.push(s)}let h=new Int32Array(n.ports.length).fill(-1);return n.ports.forEach((t,i)=>{if(t.side===o||t.side===rz(o)){let a=l.length,s=rg(0,0,t.side===o?3:4);s.key=k?$[t.out?r[t.e].dst:r[t.e].src]:NaN,s.hint=Number.isNaN(t.hint)&&k&&_?_(n,t):t.hint,l.push(s),h[i]=a;let f=t.out?rm(v[t.inner],a):rm(a,v[t.inner]);t.out?(f.tailDx=u(t.inner,t.e,!0),f.tailFixed=d(t.inner,t.e,!0)):(f.headDx=u(t.inner,t.e,!1),f.headFixed=d(t.inner,t.e,!1)),c.push(f)}else l[v[t.inner]].pin=0===t.side||3===t.side?-1:1}),{lnodes:l,ledges:c,dummies:h}},w=g>1&&g<=400&&r.length<=500,$=new Float64Array(a).fill(NaN),k=!1,M=0,_,A=o.length>1&&w;for(let t of o)t.dir!==n&&(A=!1);if(A){let s="TB"===n||"BT"===n,o=new Int32Array(a).fill(-1),l=new Int32Array(a).fill(-1),c=[],d=[],u=[];for(let r=0;r<a;r++)t[r].isGroup&&(l[r]=u.length,u.push(-1));for(let r=0;r<a;r++){let n=t[r].parent;t[r].isGroup?u[l[r]]=n>=0?l[n]:-1:(o[r]=c.length,c.push(rg(s?t[r].w:t[r].h,s?t[r].h:t[r].w)),d.push(n>=0?l[n]:-1))}let h=[],f=new Int32Array(r.length).fill(-1);r.forEach((t,r)=>{t.src===t.dst||o[t.src]<0||o[t.dst]<0||(f[r]=h.length,h.push(rm(o[t.src],o[t.dst],t.minlen,s?t.labelW:t.labelH,s?t.labelH:t.labelW)))});let p=rw(c,h,{...i,groups:{of:Int32Array.from(d),parent:Int32Array.from(u)},orderOnly:!0});M=Math.min(p.crossings??0,p.declared??0);let g=new Float64Array(a),m=new Int32Array(a),y=new Int32Array(a).fill(-1);for(let r=0;r<a;r++)if(!(o[r]<0)){$[r]=c[o[r]].x;for(let n=t[r].parent;n>=0;n=t[n].parent)g[n]+=$[r],m[n]++,y[n]=Math.max(y[n],c[o[r]].rank)}for(let t=0;t<a;t++)m[t]>0&&($[t]=g[t]/m[t]);_=(t,n)=>{let i=f[n.e];if(i<0||t.id<0||!n.out||n.side!==rz(rL(t.dir)))return NaN;let a=h[i].points,s=$[r[n.e].src],o=0;for(let r=0;r<a.length;r+=2)a[r]===y[t.id]&&(s=a[r+1]),a[r]===y[t.id]+1&&(o=a[r+1]);return s+1e-6*o}}let E=new Map,S=(t,r,n)=>{if(!w)return{lnodes:r,ledges:n,size:rw(r,n,i)};let a=[];for(let t of r)a.push(t.w,t.h,t.kind,t.pin,t.hint,t.key,t.span);for(let t of n)a.push(t.tail,t.head,t.minlen,t.labelW,t.labelH,t.tailDx,t.headDx,+t.tailFixed,+t.headFixed);let s=E.get(t.id);for(let r of(s||E.set(t.id,s=[]),s)){let t=r.given.length===a.length;for(let n=0;t&&n<a.length;n++)t=Object.is(r.given[n],a[n]);if(t)return r}let o={given:a,lnodes:r,ledges:n,size:rw(r,n,i)};return s.push(o),o},C={width:0,height:0},T=()=>{for(let n of o){for(let i of n.ports)t[i.inner].isGroup&&b(i.inner,r[i.e],i.out)&&(s.get(i.inner).portOf.get(2*i.e+ +!i.out).side=i.side);if(0===n.edges.length)continue;let i=!1;for(let a of n.edges){let n=r[a.e];(t[a.a].isGroup&&n.src!==a.a||t[a.b].isGroup&&n.dst!==a.b)&&(i=!0)}if(!i)continue;let{lnodes:a,ledges:o}=x(n,!1);r$(a,o),rk(a,o,1);let l=rL(n.dir);n.edges.forEach((n,i)=>{let a=r[n.e],c=!o[i].reversed;t[n.a].isGroup&&a.src!==n.a&&(s.get(n.a).portOf.get(2*n.e).side=c?rz(l):l),t[n.b].isGroup&&a.dst!==n.b&&(s.get(n.b).portOf.get(2*n.e+1).side=c?l:rz(l))})}for(let n=o.length-1;n>=0;n--){let i=o[n],a=i.id>=0?t[i.id]:void 0,l="TB"===i.dir||"BT"===i.dir,c="BT"===i.dir||"RL"===i.dir,d=x(i,!0),{lnodes:u,ledges:h,size:f}=S(i,d.lnodes,d.ledges),p=d.dummies,g=l?f.width:f.height,m=l?f.height:f.width,y=a?a.padX:0,v=a?a.padTop:0,w=Math.max(g+2*y,a?a.minW:0),$=m+v+(a?a.padBottom:0),k=(w-g)/2,M=(t,r)=>k+(l?t:c?f.height-r:r),_=(t,r)=>v+(l?c?f.height-r:r:t),A=+!l,E=t=>{let r=[];for(let n=0;n<t.length;n+=2)r.push(M(t[n],t[n+1]),_(t[n],t[n+1]),A);return r};i.items.forEach((r,n)=>{t[r].x=M(u[n].x,u[n].y),t[r].y=_(u[n].x,u[n].y)}),i.edges.forEach((t,n)=>{let a=h[n];i.routes.set(t.e,E(a.points));let s=r[t.e];s.labelW>0&&(s.labelX=M(a.labelX,a.labelY),s.labelY=_(a.labelX,a.labelY))});let T=i.edges.length;i.ports.forEach((n,i)=>{let a=t[n.inner];if(p[i]>=0){let t=E(h[T++].points),r=n.out?t.length-3:0,i=t[r],a=t[r+1];0===n.side?a=0:2===n.side?a=$:i=3===n.side?0:w,n.out?t.push(i,a,A):t.unshift(i,a,A),n.px=i,n.py=a,n.route=t;return}let o=a.x,l=a.y;if(a.isGroup&&b(n.inner,r[n.e],n.out)){let t=s.get(n.inner).portOf.get(2*n.e+ +!n.out);o+=t.px-a.w/2,l+=t.py-a.h/2}else 0===n.side?l-=a.h/2:2===n.side?l+=a.h/2:3===n.side?o-=a.w/2:o+=a.w/2;let c=o,d=l;0===n.side?d=0:2===n.side?d=$:c=3===n.side?0:w;let u=+(0!==n.side&&2!==n.side);n.px=c,n.py=d,n.route=n.out?[o,l,u,c,d,u]:[c,d,u,o,l,u]}),a?(a.w=w,a.h=$):C={width:w,height:$}}for(let r of o){let n=r.x,i=r.y;for(let a of r.items){let r=t[a];if(r.x+=n,r.y+=i,r.isGroup){let t=s.get(a);t.x=r.x-r.w/2,t.y=r.y-r.h/2}}}let n=(t,r,n,i)=>{for(let a=0;a<r.length;a+=3){let s=r[a]+n,o=r[a+1]+i,l=t.length;l>=3&&.01>Math.abs(t[l-3]-s)&&.01>Math.abs(t[l-2]-o)||t.push(s,o,r[a+2])}};for(let i of o)for(let a of i.edges){let o=r[a.e],l=[],c=[];for(let r=o.src;t[r].parent!==i.id;r=t[r].parent)c.push(s.get(t[r].parent));for(let t of c)n(l,t.portOf.get(2*a.e).route,t.x,t.y);n(l,i.routes.get(a.e),i.x,i.y);let d=[];for(let r=o.dst;t[r].parent!==i.id;r=t[r].parent)d.push(s.get(t[r].parent));for(let t=d.length-1;t>=0;t--)n(l,d[t].portOf.get(2*a.e+1).route,d[t].x,d[t].y);o.route=l,o.labelW>0&&(o.labelX+=i.x,o.labelY+=i.y)}},I=i.tracks?1:2*!!i.straight;k=A,T();let N=-1;if(A&&(N=rN(t,r,I))>1.5*M+4){let n=rT(t,r,o,C);k=!1,T();let i=rN(t,r,I);i>=N?(k=!0,C=rI(n,t,r,o)):N=i}if(k===A&&w){let n=!1;for(let i of o){if(i.id<0)continue;let a=t[i.id],s="TB"===i.dir||"BT"===i.dir,o=rz(rL(i.dir)),l=[];for(let t of i.ports){if(t.side!==o)continue;let n=r[t.e].route,c=i.x+t.px,d=i.y+t.py,u=-1;for(let r=0;r<n.length&&(u<0||t.out);r+=3).01>Math.abs(n[r]-c)&&.01>Math.abs(n[r+1]-d)&&(u=r);if(u<0)continue;let h=+!s,f=t.out?u+3:u-3;for(;f>=0&&f<n.length&&.5>Math.abs(n[f+h]-n[u+h]);)f+=t.out?3:-3;f<0||f>=n.length||(t.hint=n[f+h]-(s?a.x-a.w/2:a.y-a.h/2),l.push([s?t.px:t.py,t.hint]))}l.sort((t,r)=>t[0]-r[0]);for(let t=1;t<l.length;t++)l[t-1][1]>l[t][1]&&(n=!0)}if(n){let n=N>=0?N:rN(t,r,I),i=n>0?rT(t,r,o,C):void 0;i&&(T(),rN(t,r,I)>=n&&(C=rI(i,t,r,o)))}}for(let n of y){let i=r[n],a=t[i.src],s=t[i.dst];i.route=[a.x,a.y,0,s.x,s.y,0],i.labelX=(a.x+s.x)/2,i.labelY=(a.y+s.y)/2}for(let n of m){let i=r[n],a=t[i.src];i.labelX=a.x+a.w/2+28+i.labelW/2,i.labelY=a.y}return C}function rj(t,r){for(let n=0;n<r.length;n+=3){let i=Math.round(r[n+1]),a=t.get(i);a?a.push(r[n]):t.set(i,[r[n]])}}function rF(t,r,n,i){if(0===r)return t.x;let a=t.y-t.h/2,s=t.x-t.w/2,o=r/2,l=[s+i-6+o,t.x,s+t.w-i+6-o],c=n.get(Math.round(a));if(void 0===c)return l[0];let d=l[0],u=-1;for(let r of l){let n=1/0;for(let i of c)i>s&&i<s+t.w&&(n=Math.min(n,Math.abs(i-r)-o));if(n>=6)return r;n>u+.5&&(u=n,d=r)}return d}function rB(t,r,n,i){let a=r>0?i.get(Math.round(t.y-t.h/2)):void 0;if(void 0===a)return!1;let s=t.x-t.w/2;for(let i of a)if(i>s&&i<s+t.w&&Math.abs(i-n)<r/2+4)return!0;return!1}function rW(t,r,n,i,a,s,o,l){let c=1;for(let t=s[o].parent;t>=0&&c<8;t=s[t].parent)c++;let d=`color-mix(in srgb,var(--_a) ${eT(100*(1-.5**c))}%,var(--_bg))`;return`<g class="pele-cluster-title" data-id="${a}">`+eI(t,r,n,` fill="none" stroke="${d}" stroke-width="5" stroke-linejoin="round"`,l)+eI(t,r,n,i,l)+"</g>"}function rH(){let t=new Map;return{add(r,n,i){let a=rq(i);n>=0&&a>0&&a+6>(t.get(4*r+n)??0)&&t.set(4*r+n,a+6)},of:(r,n)=>n>=0?t.get(4*r+n)??0:0}}function rU(t,r,n,i,a=n>0?n+6:0,s=i>0?i+6:0){let o="linear"===r,l="step"===r||"stepBefore"===r||"stepAfter"===r,c=[],d=[],u=[],h=(t,r,n,i)=>.01>Math.abs(t-n)&&.01>Math.abs(r-i);for(let n=0;n<t.length;n+=3){let i=t[n],a=t[n+1],s=t[n+2],o=c.length-1;if(l&&o>=0&&Math.abs(i-c[o])>=.01&&Math.abs(a-d[o])>=.01){let t=c[o],n=d[o],l="stepBefore"===r?n:"stepAfter"===r?a:(n+a)/2,f="stepBefore"===r?t:"stepAfter"===r?i:(t+i)/2,p=0===s?[t,l,i,l]:[f,n,f,a];for(let r=0;r<4;r+=2)h(p[r],p[r+1],t,n)||h(p[r],p[r+1],i,a)||(c.push(p[r]),d.push(p[r+1]),u.push(s))}c.push(i),d.push(a),u.push(s)}let f=c.length-1,p=t=>.01>Math.abs(c[t]-c[t-1])||.01>Math.abs(d[t]-d[t-1]),g=t=>o||p(t),m=(t,r,n)=>{if(!g(Math.max(t,r)))return 0===n?[0,Math.sign(d[r]-d[t])||1]:[Math.sign(c[r]-c[t])||1,0];let i=c[r]-c[t],a=d[r]-d[t],s=Math.hypot(i,a)||1;return[i/s,a/s]},[y,v]=m(0,1,u[1]),[b,x]=m(f-1,f,u[f]),w=c[0],$=d[0],k=c[f],M=d[f];c[0]+=y*n,d[0]+=v*n,c[f]-=b*i,d[f]-=x*i;let _=t=>Math.abs(c[t]-c[t-1])+Math.abs(d[t]-d[t-1]),A=t=>!o&&t>0&&t<f&&p(t)&&p(t+1)&&_(t)>=.01&&_(t+1)>=.01&&.01>Math.abs(c[t]-c[t-1])!=.01>Math.abs(c[t+1]-c[t]),E=(t,r,n)=>Math.abs(c[t]-c[t-1])*Math.abs(r)+Math.abs(d[t]-d[t-1])*Math.abs(n),S=(t,r,n)=>{let i=Math.min(Math.max(0,t-6-r),n/4);return i+Math.min(t-r-i,(n-i)/4)},C=s>i&&(!g(f)||A(f-1))?S(s,i,E(f,b,x)):0,T=a>n&&(!g(1)||A(1))?S(a,n,E(1,y,v)):0;C>=1&&(c.splice(f,0,c[f]-b*C),d.splice(f,0,d[f]-x*C),u.splice(f,0,u[f]),f++),T>=1&&(c.splice(1,0,c[0]+y*T),d.splice(1,0,d[0]+v*T),u.splice(1,0,u[1]),f++);let I=[],N=t=>{let r;return I.push(0===(r=Math.round(100*t))?0:r/100),eT(t)};I.push(77,2);let O=`M${N(c[0])},${N(d[0])}`,D=c[0],R=d[0],L=(t,r)=>{h(t,r,D,R)||(I.push(76,2),O+=`L${N(t)},${N(r)}`,D=t,R=r)};for(let t=1;t<=f;t++){let r=c[t],n=d[t];if(!g(t)){let i=0===u[t],a=i?n-R:r-D,s=Math.abs(a)*rA(i?r-D:n-R,a),o=i?0:Math.sign(a)*s,l=i?Math.sign(a)*s:0;I.push(67,6),O+=`C${N(D+o)},${N(R+l)} ${N(r-o)},${N(n-l)} ${N(r)},${N(n)}`,D=r,R=n;continue}if(!A(t)){if(t<f&&p(t)&&p(t+1)&&(r-c[t-1])*(c[t+1]-r)+(n-d[t-1])*(d[t+1]-n)>0)continue;L(r,n);continue}let i=A(t-1)?_(t)/2:_(t),a=A(t+1)?_(t+1)/2:_(t+1);l&&(i=a=Math.min(12,i,a));let[s,o]=m(t-1,t,u[t]),[h,y]=m(t,t+1,u[t+1]);L(r-s*i,n-o*i),D=r+h*a,R=n+y*a,l?(I.push(81,4),O+=`Q${N(r)},${N(n)} ${N(D)},${N(R)}`):(I.push(67,6),O+=`C${N(r-s*i*.38)},${N(n-o*i*.38)} ${N(r+h*a*.38)},${N(n+y*a*.38)} ${N(D)},${N(R)}`)}return{d:O,tokens:I,sx:w,sy:$,sdx:-y,sdy:-v,ex:k,ey:M,edx:b,edy:x}}function rq(t){return"arrow_point"===t?7:"arrow_circle"===t?8:4*("arrow_cross"===t)}function rV(t,r,n,i,a,s,o="none"){let l=-a;if("arrow_point"===t){let t=r-8*i,c=n-8*a;return`<path class="pele-marker" d="M${eT(r)},${eT(n)}L${eT(t+3.36*l)},${eT(c+3.36*i)}L${eT(t-3.36*l)},${eT(c-3.36*i)}Z" fill="${s}" stroke="${o}"/>`}if("arrow_circle"===t)return`<circle class="pele-marker" cx="${eT(r-4*i)}" cy="${eT(n-4*a)}" r="3.5" fill="${s}" stroke="${o}"/>`;if("arrow_cross"===t){let t=r-4*i,s=n-4*a,o=(i+l)*3.5,c=(a+i)*3.5,d=(i-l)*3.5,u=(a-i)*3.5;return`<path class="pele-marker" d="M${eT(t-o)},${eT(s-c)}L${eT(t+o)},${eT(s+c)}M${eT(t-d)},${eT(s-u)}L${eT(t+d)},${eT(s+u)}"/>`}return""}var rY=Array.from({length:23},(t,r)=>+`1e${r}`);function rG(t){let r=[],n=0,i=0;for(let a=0;a<t.length;){let s=t[a],o=t[a+1],l=a+2,c=l+o;if(a=c,72===s||86===s)for(let a=l;a<c;a++)72===s?n=t[a]:i=t[a],r.push(n,i);else if(67===s||81===s){let a=67===s,o=a?6:4;for(let s=l;s+o<=c;s+=o){let o=t[s],l=t[s+1],c=t[s+2],d=t[s+3],u=a?t[s+4]:c,h=a?t[s+5]:d;for(let t=.125;t<=1;t+=.125){let s=n+(o-n)*t,f=i+(l-i)*t,p=o+(c-o)*t,g=l+(d-l)*t;if(a){let r=c+(u-c)*t,n=d+(h-d)*t;s+=(p-s)*t,f+=(g-f)*t,p+=(r-p)*t,g+=(n-g)*t}r.push(s+(p-s)*t,f+(g-f)*t)}n=u,i=h}}else if(65===s)for(let a=l;a+7<=c;a+=7)(function(t,r,n,i,a,s,o,l,c){let d=(r-l)/2,u=(n-c)/2;if(0===i||0===a||0===d&&0===u)return t.push(l,c);let h=Math.max(1,Math.sqrt(d*d/(i*i)+u*u/(a*a))),f=(s===o?-1:1)*Math.sqrt(Math.max(0,((i*=h)*i*(a*=h)*a-i*i*u*u-a*a*d*d)/(i*i*u*u+a*a*d*d))),p=f*i*u/a+(r+l)/2,g=-f*a*d/i+(n+c)/2,m=Math.atan2((n-g)/a,(r-p)/i),y=Math.atan2((c-g)/a,(l-p)/i)-m;o&&y<0?y+=2*Math.PI:!o&&y>0&&(y-=2*Math.PI);for(let r=1;r<=8;r++)t.push(p+i*Math.cos(m+y*r/8),g+a*Math.sin(m+y*r/8))})(r,n,i,t[a],t[a+1],t[a+3],t[a+4],t[a+5],t[a+6]),n=t[a+5],i=t[a+6];else for(let a=l;a+2<=c;a+=2)77===s&&a===l&&r.length>0&&r.push(NaN,NaN),n=t[a],i=t[a+1],r.push(n,i)}return r}function rZ(t,r,n,i){if(0===n.length)return;let a=i?rG(i):rG(function(t){let r=[],n=-1;for(let i=0;i<t.length;){let a=t.charCodeAt(i);if(a>=65&&a<=90&&69!==a)n=r.length+1,r.push(a,0),i++;else if(45===a||46===a||a>=48&&a<=57){let s,o=45===a?i+1:i,l=0,c=-1;for(let r=t.charCodeAt(o);r>=48&&r<=57||46===r&&c<0;r=t.charCodeAt(++o))46===r?c=0:(l=10*l+r-48,c>=0&&c++);if((32|t.charCodeAt(o))==101||l>Number.MAX_SAFE_INTEGER||c>22){for(let r=t.charCodeAt(o);46===r||101===r||69===r||r>=48&&r<=57||(45===r||43===r)&&(32|t.charCodeAt(o-1))==101;r=t.charCodeAt(++o));s=Number(t.slice(i,o))}else s=c>0?l/rY[c]:l,45===a&&(s=-s);n>=0&&(r.push(s),r[n]++),i=o}else i++}return r}(t)),s=1/0,o=1/0,l=-1/0,c=-1/0;for(let t=0;t<a.length+r.length;t+=2){let n=t<a.length?a[t]:r[t-a.length],i=t<a.length?a[t+1]:r[t+1-a.length];n<s&&(s=n),n>l&&(l=n),i<o&&(o=i),i>c&&(c=i)}let d,u=1/0;for(let t of n){let[n,i,h,f]=t.box;if(l<n+.5||s>h-.5||c<i+.5||o>f-.5)continue;let p=function(t,r,n,i,a){for(let s=0;s+2<t.length;s+=2){let o=t[s],l=t[s+1],c=t[s+2],d=t[s+3];if(!(o<r&&c<r||o>i&&c>i||l<n&&d<n||l>a&&d>a)&&function(t,r,n,i,a,s,o,l){let c=0,d=1;for(let u=0;u<4;u++){let h=0===u?-n:1===u?n:2===u?-i:i,f=0===u?t-a:1===u?o-t:2===u?r-s:l-r;0===h?f<0&&(d=-1):h<0?c=Math.max(c,f/h):d=Math.min(d,f/h)}return c<d}(o,l,c-o,d-l,r,n,i,a))return!0}return!1}(a,n+.5,i+.5,h-.5,f-.5);for(let t=0;t<r.length&&!p;t+=2)p=r[t]>n+.5&&r[t]<h-.5&&r[t+1]>i+.5&&r[t+1]<f-.5;if(!p)continue;if(s<n||l>h||o<i||c>f)return"";let g=(h-n)*(f-i);g<u&&(u=g,d=t)}return d}function rX(t,r=""){return(/[";]stroke:/.test(r)?void 0:e5(t.shape))??""}function rK(t,r){let n=/[";]fill:([^;"]*)/.exec(r.shape)?.[1].trim();return n?t.replace(/ fill="var\(--_bg\)"/g,` fill="${n}"`):t}function rJ(t,r,n,i="",a){let s=rZ(t,r,n,a);return s&&rX(s,i)}function rQ(t,r,n="",i=!1){let a=t=>n.includes(t)?RegExp(`[";]${t}:([^;"]+);`).exec(n)?.[1].trim():void 0,s=a("stroke");if("none"===s||"transparent"===s)return"";let o=i?"2.5":a("stroke-width"),l="",c="";for(let t of(void 0!==o&&/^[\d.]+(?:px)?$/.test(o)?1!==parseFloat(o)&&(l=` stroke-width="${eT(parseFloat(o)+4)}"`):void 0!==o&&(c+=`stroke-width:calc(${o} + 4px);`),["opacity","stroke-opacity"])){let r=a(t);void 0!==r&&(c+=`${t}:${r};`)}let d=`<path d="${t}"/>`+r.replace(/ class="pele-marker"/g,"");return l||c?`<g${l}${c?` style="${c}"`:""}>${d}</g>`:d}function r0(t,r,n,i="",a=!1){return rQ(t.d,rV(r,t.sx,t.sy,t.sdx,t.sdy,"var(--_bg)","var(--_bg)")+rV(n,t.ex,t.ey,t.edx,t.edy,"var(--_bg)","var(--_bg)"),i,a)}function r1(t){return t?`<g class="pele-casings" fill="none" stroke="var(--_bg)" stroke-width="5" stroke-linecap="round" stroke-linejoin="round" pointer-events="none">${t}</g>`:""}function r2(t,r,n,i,a,s){let o=r.width+8,l=r.height;return`<g class="pele-edge-label" data-id="${eS(t)}"><rect x="${eT(n-o/2)}" y="${eT(i-l/2)}" width="${eT(o)}" height="${eT(l)}" rx="3" fill="var(--_bg)"/>`+eI(r,n,i,a,s)+"</g>"}function r4(t,r,n,i,a,s,o,l){let c=Math.min((a?r:n)/2-4,8+6*i),d=s+8*i,u=Math.hypot(d,c)||1,h=(i,s)=>a?`${eT(t.x+s)},${eT(t.y+n/2+i)}`:`${eT(t.x+r/2+i)},${eT(t.y+s)}`,f=d/u*o;return a?(l.labelX=t.x,l.labelY=t.y+n/2+d+4+l.labelH/2):(l.labelX=t.x+r/2+d+4+l.labelW/2,l.labelY=t.y),{d:`M${h(0,-c)}C${h(d,-(2*c))} ${h(d,2*c)} ${h(f,c+c/u*o)}`,sx:a?t.x-c:t.x+r/2,sy:a?t.y+n/2:t.y-c,sdx:a?0:-1,sdy:a?-1:0,ex:a?t.x+c:t.x+r/2,ey:a?t.y+n/2:t.y+c,edx:a?-c/u:-d/u,edy:a?-d/u:-c/u}}var r3="var(--_fm)",r5=' style="rx:var(--_r)"',r6=/[";]fill:/,r8=t=>r6.test(t);function r9(t){let r=t.indexOf(' style="');return r<0?t+r5:`${t.slice(0,r+8)}rx:var(--_r);${t.slice(r+8)}`}var r7="var(--pele-critical,#e45756)",ne=String.raw`(?:"[^"'\\\n<>{}();:@]*"|'[^"'\\\n<>{}();:@]*'|[\p{L}\p{N}_-][\p{L}\p{N}_ .-]*)`,nt=RegExp(String.raw`^\s*${ne}(?:\s*,\s*${ne})*\s*$`,"u");function nr(t,r){return t&&nt.test(t)?t:r}var nn=new Set(["fill","fill-opacity","stroke","stroke-width","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-opacity","opacity","rx","ry"]),ni=new Set(["color","font-size","font-family","font-weight","font-style","text-decoration","letter-spacing","word-spacing","opacity"]),na=/url\s*\(|expression\s*\(|javascript:|[<>{};\\]|@import|image-set|\/\*/i,ns={shape:"",line:"",text:"",stroke:void 0,bold:!1,italic:!1,fontSize:void 0};function no(t){if(0===t.length)return ns;let r=new Map,n=new Map;for(let i of t){let t=i.indexOf(":");if(t<=0)continue;let a=i.slice(0,t).trim().toLowerCase(),s=i.slice(t+1).replace(/!important/gi,"").trim();""===s||na.test(s)||eA.test(s)||(nn.has(a)&&r.set(a,s),ni.has(a)&&n.set("color"===a?"fill":a,s))}if(0===r.size&&0===n.size)return ns;let i="",a="";for(let[t,n]of r)i+=`${t}:${n};`,"fill"!==t&&"fill-opacity"!==t&&(a+=`${t}:${n};`);let s="";for(let[t,r]of n)s+=`${t}:${r};`;let o=n.get("font-weight"),l=n.get("font-size"),c=l&&/^[\d.]+(px)?$/.test(l)?parseFloat(l):void 0;return{shape:i?` style="${eE(i)}"`:"",line:a?` style="${eE(a)}"`:"",text:s?` style="${eE(s)}"`:"",stroke:r.get("stroke"),bold:"bold"===o||"bolder"===o||Number(o)>=600,italic:"italic"===n.get("font-style"),fontSize:void 0!==c&&c>0&&c<=200?c:void 0}}var nl=/[^\w-]+/g;function nc(t){let r=t.replace(nl," ").trim();return""===r?"":" "+r}var nd=["#4c78a8","#f58518","#54a24b","#e45756","#72b7b2","#eeca3b","#b279a2","#9d755d"];function nu(t){let r=(t%8+8)%8;return`var(--pele-series-${r+1},${nd[r]})`}var nh=[["tw","title"],["hw","heading"],["w","bold"]],nf=/var\(--_(r|tw|hw|w)\)/g;function np(t,r,n,i,a,s,o){var l,c;let d=eE(a.idPrefix??"pele"),u="",h="";s.accTitle&&(u+=`<title id="${d}-title">${eS(s.accTitle)}</title>`,h+=` aria-labelledby="${d}-title"`),s.accDescr&&(u+=`<desc id="${d}-desc">${eS(s.accDescr)}</desc>`,h+=` aria-describedby="${d}-desc"`);let f=!1===a.responsive?"":"max-width:100%;height:auto;",p=new Set;for(let[,t]of o.matchAll(nf))if(p.add(t),4===p.size)break;let g=p.has("r")?";--_r:var(--pele-radius,4px)":"";for(let[t,r]of nh)p.has(t)&&(g+=`;--_${t}:var(--pele-${r}-weight,bold)`);return`<svg xmlns="http://www.w3.org/2000/svg" class="pele pele-${t}" viewBox="0 0 ${r} ${n}" width="${r}" height="${n}" style="${f}--_bg:var(--pele-bg,#fff);--_fg:var(--pele-fg,#1f1f1f);--_m:var(--pele-muted,#6e6e6e);--_l:var(--pele-line,#1f1f1f);--_s:var(--pele-surface,#f3f3f3);--_a:var(--pele-surface-alt,#e6e6e6);--_b:var(--pele-border,#8a8a8a);--_c:var(--pele-accent,#5b7bd5);color:var(--_fg)${g}${eE((l=a.fontFamily,c=a.fontFamilyMono,`;--_fm:var(--pele-font-mono,${nr(c,"monospace")});font:${i}px sans-serif;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;font-family:var(--pele-font,${nr(l,"sans-serif")})`))}${ta.style}" fill="var(--_fg)" role="graphics-document document" aria-roledescription="${t}"${h}>`+u+o+"</svg>"}var ng=(t,r,n)=>(n?r:t)-24,nm=t=>(r,n,i)=>i?0:r-2*t(n)-24;function ny(t,r,n){let i=Math.min(1,Math.abs(t)/r);return n*(1-Math.sqrt(1-i*i))}var nv=(t,r,n,i)=>1&n?ny(i,r/2,t/2):ny(i,t/2,r/2),nb=(t,r,n)=>(n?r:t)*.6,nx=(t,r,n,i)=>1&n?0:ny(i,t/2,Math.min(12,Math.max(6,t/14))),nw=(t,r)=>()=>({w:t,h:r,dy:0});function n$(t,r,n){let i=Math.max(1.6*t+40,80),a=(r+10)/(1-(t+8)/i),s=a/2-10-r/2;return{w:i,h:a,dy:n?-s:s}}function nk(t,r){return`<path d="${t}"${r}/>`}var nM=(t,r,n)=>1&n?r/8:0,n_=(t,r)=>({w:Math.max(t+36,48),h:r+24,dy:0});function nA(t,r){let n="";for(let r=0;r<t.length;r+=2)n+=(r?" ":"")+eT(t[r])+","+eT(t[r+1]);return`<polygon points="${n}"${r}/>`}function nE(t,r,n,i=""){return`<rect x="${eT(-t/2)}" y="${eT(-r/2)}" width="${eT(t)}" height="${eT(r)}"${i}${n}/>`}var nS={rect:{size:n_,span:ng,draw:(t,r,n)=>nE(t,r,r9(n))},rounded:{size:n_,span:ng,draw:(t,r,n)=>nE(t,r,n,` rx="${eT(Math.min(12,r/2))}"`)},stadium:{inset:(t,r,n,i)=>1&n?ny(i,r/2,r/2):0,span:(t,r,n)=>n?.6*r:t-r,size:(t,r)=>{let n=r+24;return{w:t+.5*n+36-8,h:n,dy:0}},draw:(t,r,n)=>nE(t,r,n,` rx="${eT(r/2)}"`)},"fr-rect":{span:ng,size:(t,r)=>({w:t+36+16,h:r+24,dy:0}),draw:(t,r,n,i)=>{let a=t/2-8;return nE(t,r,r9(n))+`<path d="M${eT(-a)},${eT(-r/2)}V${eT(r/2)}M${eT(a)},${eT(-r/2)}V${eT(r/2)}" fill="none"${i}/>`}},cyl:{inset:nx,span:(t,r,n)=>n?r-24-12:.6*t,size:(t,r)=>{let n=Math.max(t+36,56),i=Math.min(12,Math.max(6,n/14));return{w:n,h:r+24+2*i,dy:i/2}},draw:(t,r,n,i)=>{let a=t/2,s=Math.min(12,Math.max(6,t/14)),o=-r/2+s,l=r/2-s;return`<path d="M${eT(-a)},${eT(o)}A${eT(a)},${eT(s)} 0 0 1 ${eT(a)},${eT(o)}V${eT(l)}A${eT(a)},${eT(s)} 0 0 1 ${eT(-a)},${eT(l)}Z"${n}/><path d="M${eT(-a)},${eT(o)}A${eT(a)},${eT(s)} 0 0 0 ${eT(a)},${eT(o)}" fill="none"${i}/>`}},circle:{inset:nv,span:nb,size:(t,r)=>{let n=Math.max(Math.sqrt(t*t+r*r)+16,44);return{w:n,h:n,dy:0}},draw:(t,r,n)=>`<circle r="${eT(t/2)}"${n}/>`},"dbl-circ":{inset:nv,span:nb,size:(t,r)=>{let n=Math.max(Math.sqrt(t*t+r*r)+26,54);return{w:n,h:n,dy:0}},draw:(t,r,n,i)=>`<circle r="${eT(t/2)}"${n}/><circle r="${eT(t/2-5)}" fill="none"${i}/>`},ellipse:{inset:nv,span:nb,size:(t,r)=>({w:1.3*t+36,h:1.2*r+24,dy:0}),draw:(t,r,n)=>`<ellipse rx="${eT(t/2)}" ry="${eT(r/2)}"${n}/>`},diam:{inset:(t,r,n,i)=>1&n?Math.abs(i)*t/r:Math.abs(i)*r/t,span:(t,r,n)=>(n?r:t)*.6,size:(t,r)=>{let n=t+16,i=r+8;return{w:n+1.6*i,h:n/1.6+i,dy:0}},draw:(t,r,n)=>nA([0,-r/2,t/2,0,0,r/2,-t/2,0],n)},hex:{inset:(t,r,n,i)=>1&n?Math.abs(i)/2:0,span:(t,r,n)=>n?.5*r:t-r/2-12,size:(t,r)=>{let n=r+24;return{w:t+36+n/2,h:n,dy:0}},draw:(t,r,n)=>{let i=r/4;return nA([-t/2+i,-r/2,t/2-i,-r/2,t/2,0,t/2-i,r/2,-t/2+i,r/2,-t/2,0],n)}},odd:{inset:(t,r,n)=>3===n?r/4:0,span:nm(()=>0),size:(t,r)=>{let n=r+24;return{w:t+36+n/4,h:n,dy:0}},draw:(t,r,n)=>nA([-t/2,-r/2,t/2,-r/2,t/2,r/2,-t/2,r/2,-t/2+r/4,0],n)},"lean-r":{inset:nM,span:nm(t=>t/4),size:(t,r)=>{let n=r+24;return{w:t+36+n/2,h:n,dy:0}},draw:(t,r,n)=>{let i=r/4;return nA([-t/2+i,-r/2,t/2,-r/2,t/2-i,r/2,-t/2,r/2],n)}},"lean-l":{inset:nM,span:nm(t=>t/4),size:(t,r)=>{let n=r+24;return{w:t+36+n/2,h:n,dy:0}},draw:(t,r,n)=>{let i=r/4;return nA([-t/2,-r/2,t/2-i,-r/2,t/2,r/2,-t/2+i,r/2],n)}},"trap-b":{inset:nM,span:nm(t=>t/4),size:(t,r)=>{let n=r+24;return{w:t+36+n/2,h:n,dy:0}},draw:(t,r,n)=>{let i=r/4;return nA([-t/2+i,-r/2,t/2-i,-r/2,t/2,r/2,-t/2,r/2],n)}},"trap-t":{inset:nM,span:nm(t=>t/4),size:(t,r)=>{let n=r+24;return{w:t+36+n/2,h:n,dy:0}},draw:(t,r,n)=>{let i=r/4;return nA([-t/2,-r/2,t/2,-r/2,t/2-i,r/2,-t/2+i,r/2],n)}},text:{bare:!0,span:ng,size:(t,r)=>({w:t+8,h:r+8,dy:0}),draw:(t,r)=>nE(t,r,' fill="none" stroke="none"')},"sm-circ":{noLabel:!0,inset:nv,span:nb,size:nw(14,14),draw:(t,r,n)=>`<circle r="${eT(t/2)}"${n}/>`},"f-circ":{noLabel:!0,inset:nv,span:nb,size:nw(14,14),draw:(t,r,n,i)=>`<circle r="${eT(t/2)}" fill="var(--_l)"${i}/>`},"fr-circ":{noLabel:!0,inset:nv,span:nb,size:nw(18,18),draw:(t,r,n,i)=>`<circle r="${eT(t/2)}"${n}/><circle r="${eT(t/2-4)}" fill="var(--_l)"${i}/>`},fork:{noLabel:!0,span:(t,r,n)=>(n?r:t)-8,size:nw(72,8),draw:(t,r,n,i)=>nE(t,r,` fill="var(--_l)"${i}`,' rx="2"')},"notch-rect":{size:n_,span:ng,draw:(t,r,n)=>nA([-t/2+10,-r/2,t/2,-r/2,t/2,r/2,-t/2,r/2,-t/2,-r/2+10],n)},"lin-rect":{span:ng,size:(t,r)=>({w:t+36+8,h:r+24,dy:0}),draw:(t,r,n,i)=>nE(t,r,r9(n))+`<path d="M${eT(-t/2+8)},${eT(-r/2)}V${eT(r/2)}" fill="none"${i}/>`},"div-rect":{span:ng,size:(t,r)=>({w:t+36,h:r+24+8,dy:4}),draw:(t,r,n,i)=>nE(t,r,r9(n))+`<path d="M${eT(-t/2)},${eT(-r/2+8)}H${eT(t/2)}" fill="none"${i}/>`},"win-pane":{span:ng,size:(t,r)=>({w:t+36+8,h:r+24+8,dy:4}),draw:(t,r,n,i)=>nE(t,r,r9(n))+`<path d="M${eT(-t/2+8)},${eT(-r/2)}V${eT(r/2)}M${eT(-t/2)},${eT(-r/2+8)}H${eT(t/2)}" fill="none"${i}/>`},tri:{inset:(t,r,n)=>1&n?t/4:0,size:(t,r)=>n$(t,r,!1),draw:(t,r,n)=>nA([0,-r/2,t/2,r/2,-t/2,r/2],n)},"flip-tri":{inset:(t,r,n)=>1&n?t/4:0,size:(t,r)=>n$(t,r,!0),draw:(t,r,n)=>nA([-t/2,-r/2,t/2,-r/2,0,r/2],n)},"sl-rect":{inset:(t,r,n)=>5*(0===n),size:(t,r)=>({w:t+36,h:r+24+10,dy:5}),draw:(t,r,n)=>nA([-t/2,-r/2+10,t/2,-r/2,t/2,r/2,-t/2,r/2],n)},"notch-pent":{span:ng,size:(t,r)=>({w:t+36,h:r+24,dy:0}),draw:(t,r,n)=>nA([-t/2+10,-r/2,t/2-10,-r/2,t/2,-r/2+10,t/2,r/2,-t/2,r/2,-t/2,-r/2+10],n)},hourglass:{noLabel:!0,inset:(t,r,n)=>1&n?t/2:0,size:nw(32,40),draw:(t,r,n)=>nA([-t/2,-r/2,t/2,-r/2,-t/2,r/2,t/2,r/2],n)},delay:{size:(t,r)=>{let n=r+24;return{w:t+36+n/4,h:n,dy:0}},draw:(t,r,n)=>{let i=r/2;return`<path d="M${eT(-t/2)},${eT(-i)}H${eT(t/2-i)}A${eT(i)},${eT(i)} 0 0 1 ${eT(t/2-i)},${eT(i)}H${eT(-t/2)}Z"${n}/>`}},"h-cyl":{size:(t,r)=>{let n=r+24;return{w:t+36+2*Math.min(12,n/4),h:n,dy:0}},draw:(t,r,n,i)=>{let a=r/2,s=Math.min(12,r/4),o=-t/2+s,l=t/2-s;return`<path d="M${eT(o)},${eT(-a)}H${eT(l)}A${eT(s)},${eT(a)} 0 0 1 ${eT(l)},${eT(a)}H${eT(o)}A${eT(s)},${eT(a)} 0 0 1 ${eT(o)},${eT(-a)}Z"${n}/><path d="M${eT(l)},${eT(-a)}A${eT(s)},${eT(a)} 0 0 0 ${eT(l)},${eT(a)}" fill="none"${i}/>`}},"cross-circ":{noLabel:!0,inset:nv,span:nb,size:nw(44,44),draw:(t,r,n,i)=>{let a=t/2,s=a*Math.SQRT1_2;return`<circle r="${eT(a)}"${n}/><path d="M${eT(-s)},${eT(-s)}L${eT(s)},${eT(s)}M${eT(s)},${eT(-s)}L${eT(-s)},${eT(s)}" fill="none"${i}/>`}},"st-rect":{span:(t,r,n)=>(n?r:t)-24-8,size:(t,r)=>({w:t+36+8,h:r+24+8,dy:4}),draw:(t,r,n)=>{let i=t-8,a=r-8,s="";for(let o=0;o<3;o++){let l=-t/2+(2-o)*4,c=-r/2+4*o;s+=`<rect x="${eT(l)}" y="${eT(c)}" width="${eT(i)}" height="${eT(a)}"${r9(n)}/>`}return s}},doc:{inset:(t,r,n)=>10*(2===n),size:(t,r)=>({w:t+36,h:r+24+10,dy:-5}),draw:(t,r,n)=>nT(t,r,n)},flag:{inset:(t,r,n)=>1&n?0:8,size:(t,r)=>({w:t+36,h:r+24+16,dy:0}),draw:(t,r,n)=>{let i=r/2-8,a=t/4;return`<path d="M${eT(-(t/2))},${eT(-i)}q${eT(a)},-10 ${eT(2*a)},0t${eT(2*a)},0V${eT(i)}q${eT(-a)},10 ${eT(-2*a)},0t${eT(-2*a)},0Z"${n}/>`}},datastore:{size:n_,span:ng,draw:(t,r,n,i)=>nE(t,r,n.replace('stroke="var(--_b)"','stroke="none"'))+`<path d="M${eT(-t/2)},${eT(-r/2)}H${eT(t/2)}M${eT(-t/2)},${eT(r/2)}H${eT(t/2)}" fill="none"${i}/>`},folder:{size:(t,r)=>({w:Math.max(t+36,64),h:r+24+8,dy:4}),draw:(t,r,n)=>{let i=t/2,a=r/2,s=Math.min(.4*t,48);return nk(`M${eT(-i)},${eT(-a)}H${eT(-i+s)}L${eT(-i+s+8)},${eT(-a+8)}H${eT(i)}V${eT(a)}H${eT(-i)}Z`,n)}},bucket:{size:(t,r)=>({w:t+36+20,h:r+24+10,dy:3}),inset:(t,r,n)=>1&n?r/12:0,draw:(t,r,n,i)=>{let a=t/2,s=r/2,o=r/6;return nk(`M${eT(-a)},${eT(-s+5)}A${eT(a)},${eT(5)} 0 0 1 ${eT(a)},${eT(-s+5)}L${eT(a-o)},${eT(s-5)}A${eT(a-o)},${eT(5)} 0 0 1 ${eT(-a+o)},${eT(s-5)}Z`,n)+`<path d="M${eT(-a)},${eT(-s+5)}A${eT(a)},${eT(5)} 0 0 0 ${eT(a)},${eT(-s+5)}" fill="none"${i}/>`}},console:{span:ng,size:(t,r)=>({w:Math.max(t+36,72),h:r+24+12,dy:6}),draw:(t,r,n,i)=>nE(t,r,r9(n))+`<path d="M${eT(-t/2)},${eT(-r/2+12)}H${eT(t/2)}M${eT(-t/2+7)},${eT(-r/2+4)}l3,2.5l-3,2.5M${eT(-t/2+13)},${eT(-r/2+9)}h4" fill="none"${i}/>`},browser:{span:ng,size:(t,r)=>({w:Math.max(t+36,72),h:r+24+12,dy:6}),draw:(t,r,n,i)=>{let a="";for(let n=0;n<3;n++)a+=`<circle cx="${eT(-t/2+8+7*n)}" cy="${eT(-r/2+6)}" r="1.5" fill="none"${i}/>`;return nE(t,r,r9(n))+`<path d="M${eT(-t/2)},${eT(-r/2+12)}H${eT(t/2)}" fill="none"${i}/>`+a}},person:{size:(t,r)=>({w:Math.max(t+36,56),h:r+24+26,dy:13}),draw:(t,r,n)=>{let i=-r/2;return`<rect x="${eT(-t/2)}" y="${eT(i+26)}" width="${eT(t)}" height="${eT(r-26)}" rx="12"${n}/><circle cy="${eT(i+14)}" r="13"${n}/>`}},bang:{size:(t,r)=>({w:t+36+28,h:r+24+24,dy:0}),inset:()=>3,draw:(t,r,n)=>{let i=[];for(let n=0;n<28;n++){let a=Math.PI*n/14-Math.PI/2,s=n%2==0?1:.82;i.push(t/2*Math.cos(a)*s,r/2*Math.sin(a)*s)}return nA(i,n)}},cloud:{size:(t,r)=>({w:t+36+32,h:r+24+24,dy:0}),inset:(t,r,n)=>1&n?2:1,draw:(t,r,n)=>{let i=t/2,a=r/2,s=.55*a;return nk(`M${eT(-i+s)},${eT(a)}A${eT(s)},${eT(s)} 0 0 1 ${eT(-i+.6*s)},${eT(-(.1*a))}A${eT(.42*i)},${eT(.7*a)} 0 0 1 ${eT(-(.1*i))},${eT(-(.72*a))}A${eT(.4*i)},${eT(.62*a)} 0 0 1 ${eT(.62*i)},${eT(-(.42*a))}A${eT(1.05*s)},${eT(1.05*s)} 0 0 1 ${eT(i-s)},${eT(a)}Z`,n)}},brace:{bare:!0,size:(t,r)=>({w:t+36+12,h:r+24,dy:0}),draw:(t,r,n,i)=>nE(t,r,' fill="none" stroke="none"')+nC(-t/2+12,r,-1,i)},"brace-r":{bare:!0,size:(t,r)=>({w:t+36+12,h:r+24,dy:0}),draw:(t,r,n,i)=>nE(t,r,' fill="none" stroke="none"')+nC(t/2-12,r,1,i)},braces:{bare:!0,size:(t,r)=>({w:t+36+24,h:r+24,dy:0}),draw:(t,r,n,i)=>nE(t,r,' fill="none" stroke="none"')+nC(-t/2+12,r,-1,i)+nC(t/2-12,r,1,i)},bolt:{noLabel:!0,size:nw(36,56),inset:(t,r,n)=>1&n?t/4:0,draw:(t,r,n)=>nA([.15*t,-r/2,-t/2,.08*r,-(.05*t),.08*r,-(.15*t),r/2,t/2,-(.08*r),.05*t,-(.08*r)],n)},"lin-cyl":{inset:nx,span:(t,r,n)=>n?r-24-20:.6*t,size:(t,r)=>{let n=Math.max(t+36,56),i=Math.min(12,Math.max(6,n/14));return{w:n,h:r+24+2*i+8,dy:i/2+4}},draw:(t,r,n,i)=>{let a=t/2,s=Math.min(12,Math.max(6,t/14)),o=-r/2+s,l=r/2-s,c=t=>`M${eT(-a)},${eT(t)}A${eT(a)},${eT(s)} 0 0 0 ${eT(a)},${eT(t)}`;return nk(`M${eT(-a)},${eT(o)}A${eT(a)},${eT(s)} 0 0 1 ${eT(a)},${eT(o)}V${eT(l)}A${eT(a)},${eT(s)} 0 0 1 ${eT(-a)},${eT(l)}Z`,n)+`<path d="${c(o)}${c(o+8)}" fill="none"${i}/>`}},"curv-trap":{size:(t,r)=>{let n=r+24;return{w:t+36+.6*n,h:n,dy:0}},draw:(t,r,n)=>{let i=t/2,a=r/2,s=.3*r;return nk(`M${eT(-i+s)},${eT(-a)}H${eT(i-s)}A${eT(s)},${eT(a)} 0 0 1 ${eT(i-s)},${eT(a)}H${eT(-i+s)}L${eT(-i)},0Z`,n)}},docs:{size:(t,r)=>({w:t+36+8,h:r+24+18,dy:-1}),inset:(t,r,n)=>10*(2===n),draw:(t,r,n)=>{let i="";for(let a=0;a<3;a++)i+=`<g transform="translate(${(1-a)*4},${(a-1)*4})">${nT(t-8,r-8,n)}</g>`;return i}},"bow-rect":{size:(t,r)=>{let n=r+24;return{w:t+36+.4*n,h:n,dy:0}},inset:(t,r,n)=>1===n?.2*r:0,draw:(t,r,n)=>{let i=t/2,a=r/2,s=.2*r;return nk(`M${eT(-i+s)},${eT(-a)}H${eT(i)}A${eT(s)},${eT(a)} 0 0 0 ${eT(i)},${eT(a)}H${eT(-i+s)}A${eT(s)},${eT(a)} 0 0 1 ${eT(-i+s)},${eT(-a)}Z`,n)}},"tag-rect":{size:n_,span:ng,draw:(t,r,n,i)=>nE(t,r,r9(n))+`<path d="M${eT(t/2-12)},${eT(r/2)}L${eT(t/2)},${eT(r/2-12)}" fill="none"${i}/>`},"tag-doc":{size:(t,r)=>({w:t+36,h:r+24+10,dy:-5}),inset:(t,r,n)=>10*(2===n),draw:(t,r,n,i)=>nT(t,r,n)+`<path d="M${eT(t/2-12)},${eT(r/2-14)}L${eT(t/2)},${eT(r/2-26)}" fill="none"${i}/>`},"lin-doc":{size:(t,r)=>({w:t+36+8,h:r+24+10,dy:-5}),inset:(t,r,n)=>10*(2===n),draw:(t,r,n,i)=>nT(t,r,n)+`<path d="M${eT(-t/2+8)},${eT(-r/2)}V${eT(r/2-6)}" fill="none"${i}/>`},collapsedGroup:{size:(t,r)=>({w:t+36+8,h:r+24+8,dy:-2}),draw:(t,r,n)=>`<rect x="${eT(-t/2+6)}" y="${eT(-r/2+8)}" width="${eT(t-12)}" height="${eT(r-8)}"${r9(n)}/><rect x="${eT(-t/2)}" y="${eT(-r/2)}" width="${eT(t)}" height="${eT(r-4)}"${r9(n)}/>`}};function nC(t,r,n,i){let a=r/2,s=6*n;return`<path d="M${eT(t)},${eT(-a)}q${eT(s)},0 ${eT(s)},6V-6q0,6 ${eT(s)},6q${eT(-s)},0 ${eT(-s)},6V${eT(a-6)}q0,6 ${eT(-s)},6" fill="none"${i}/>`}function nT(t,r,n){let i=t/2,a=t/4;return`<path d="M${eT(-i)},${eT(-r/2)}H${eT(i)}V${eT(r/2-10)}q${eT(-a)},-12 ${eT(-2*a)},0t${eT(-2*a)},0Z"${n}/>`}var nI=nS.rect,nN=new Map(Object.entries(nS));function nO(t,r,n){return(nN.get(t)??nI).size(r,n)}function nD(t,r,n,i,a){return(nN.get(t)??nI).draw(r,n,i,a)}function nR(t,r,n,i,a=0){return nN.get(t)?.inset?.(r,n,i,a)??0}function nL(t){return!0!==(nN.get(t)??nI).bare}function nz(t,r,n){let i=t[r]-n.x,a=t[r+1]-n.y;return .5>Math.abs(Math.abs(a)-n.h/2)?a<0?0:2:.5>Math.abs(Math.abs(i)-n.w/2)?i<0?3:1:-1}function nP(t,r,n,i){if(i.isGroup)return;let a=nz(t,r,i);if(0===a||2===a){let s=nR(n.shape,n.w,n.h,a,t[r]-i.x)+(i.h-n.h)/2;t[r+1]+=0===a?s:-s}else if(a>=0){let s=nR(n.shape,n.w,n.h,a,t[r+1]-i.y)+(i.w-n.w)/2;t[r]+=3===a?s:-s}}var nj,nF,nB,nW,nH=/<br\s*\/?>|\\n|\n/gi,nU=/<\/?([a-zA-Z][\w-]*)(?:\s[^<>]*)?\/?>/y,nq=/(fa[bklrs]?):fa-([\w-]+)/g,nV=/[<\\\n*_]|fa[bklrs]?:fa-/,nY=new Map([["b",1],["strong",1],["i",2],["em",2],["cite",2],["dfn",2],["var",2],["code",4],["kbd",4],["samp",4],["tt",4],["sub",8],["sup",16],["u",32],["ins",32]]),nG=new Set("a abbr address article aside audio b bdi bdo big blockquote body br button caption center cite code col colgroup data dd del details dfn dialog div dl dt em embed fieldset figcaption figure font footer form h1 h2 h3 h4 h5 h6 head header hr html i iframe img input ins kbd label legend li link main map mark meta meter nav noscript object ol optgroup option output p picture pre progress q rp rt ruby s samp script section select small source span strike strong style sub summary sup table tbody td template textarea tfoot th thead time title tr track tt u ul var video wbr".split(" ")),nZ="\\u2e80-\\u9fff\\uf900-\\ufaff\\uff00-\\uff60",nX="、。,.:;!?)]}」』】〕〉》〙〗ー…‥・ゝゞぁぃぅぇぉっゃゅょゎァィゥェォッャュョヮ,.:;!?)\\]}",nK=RegExp(`[${nZ}]`),nJ="\\u200b\\u00ad",nQ=RegExp(`[${nJ}]`),n0=RegExp(`\\s*(?:[([{「『【〔〈《〘〖([{]*[${nZ}][${nX}]*|[^\\s${nZ}${nJ}]+[${nJ}]*[${nX}]*|[${nJ}]+)\\s*|\\s+`,"g"),n1=/\$\$(.+?)\$\$/g,n2=/[\ue000-\uf8ff]/,n4=/([\ue000-\uf8ff])/,n3={lines:[],widths:[],width:0,height:0,size:0,lineHeight:0};function n5(t){return void 0!==t&&void 0===t.icon&&void 0===t.math}function n6(t,r,n){if(""!==r){if(void 0!==nW&&n2.test(r)){let i=nW,a=r.split(n4);for(let r=0;r<a.length;r++){if(r%2==0){""!==a[r]&&n8(t,a[r],n);continue}let s=a[r].charCodeAt(0)-57344,o=i.math[s];o?t.push({text:"",style:n,math:o,width:o.width}):n8(t,`$$${i.tex[s]}$$`,n)}return}n8(t,r,n)}}function n8(t,r,n){let i=y(r),a=t[t.length-1];n5(a)&&a.style===n?a.text+=i:t.push({text:i,style:n,width:0})}function n9(t,r,n,i,a,s){let o=[],l=0,c=(t=!1)=>{let i=o[o.length-1];if(n5(i)){let a=i.text.trimEnd();if(t&&i.text.endsWith("\xad")&&(a=a.slice(0,-1)+"-"),a!==i.text){i.text=a;let t=r.width(a,n,i.style);l+=t-i.width,i.width=t}}a.push(o),s.push(l),o=[],l=0};for(let a of t){if(void 0!==a.icon||a.math){let t=a.math?a.math.width:1.25*n;l>0&&l+t>i&&c(),o.push({...a,width:t}),l+=t;continue}let s=a.text.match(n0)??[],d=a.text.includes("\xad"),u=d?s.length:0,h=new Float64Array(u),f=new Float64Array(u+1);for(let i=u-1;i>=0;i--){let o=s[i].endsWith("\xad"),l=s[i].trimEnd();h[i]=r.width(o?l.slice(0,-1):l,n,a.style),f[i]=o?i===u-1?a===t[t.length-1]?h[i]:1/0:h[i]+f[i+1]:h[i]}for(let t=0;t<s.length;t++){let u=s[t],p=d?h[t]:r.width(u.trimEnd(),n,a.style),g=d&&u.endsWith("\xad")?l+r.width(u.slice(0,-1)+"-",n,a.style)<=i||l+f[t]<=i:l+p<=i;l>0&&!g&&(c(u.trimStart()===u),u=u.trimStart());let m=o[o.length-1];if(n5(m)&&m.style===a.style){if(m.text+=u,p>0||u.trimEnd()!==u){let t=m.width;m.width=r.width(m.text,n,m.style),l+=m.width-t}}else{let t=r.width(u,n,a.style);o.push({text:u,style:a.style,width:t}),l+=t}}}(o.length>0||0===a.length)&&c()}function n7(t,r,n,i,a,s=0){if(void 0===t||""===t)return n3;let o=Math.round(1.5*i);if(void 0!==k&&t.includes("$$")&&!n2.test(t)){let l={tex:[],math:[]},c=t.replace(n1,(t,r)=>6400===l.tex.length?t:(l.tex.push(r),String.fromCharCode(57344+l.tex.length-1)));if(l.tex.length>0){for(let t of l.tex)l.math.push(function(t,r){if(void 0===k)return;let n=r+`
|
|
54
|
+
`+t;if(M.has(n))return M.get(n);let i=k(t,r)??void 0,a=i&&_(i.width)&&_(i.height)&&"string"==typeof("svg"in i?i.svg:i.html)?i:void 0;return M.set(n,a),a}(y(t),i));return ie(c,r,n,i,a,s,o,l)}}if(!nV.test(t)&&!t.includes("&")&&!t.includes("fl")){let r=t.trim(),l=n.width(r,i,s);if(l<=a||!(r.includes(" ")||nK.test(r)||nQ.test(r)))return{lines:[[{text:r,style:s,width:l}]],widths:[l],width:l,height:o,size:i,lineHeight:o};let c=[],d=[];n9([{text:r,style:s,width:l}],n,i,a,c,d);let u=0;for(let t of d)t>u&&(u=t);let h=c.length>1?Math.round(1.3*i):o;return{lines:c,widths:d,width:u,height:c.length*h,size:i,lineHeight:h}}return ie(t,r,n,i,a,s,o)}function ie(t,r,n,i,a,s,o,l){let c=nW;nW=l;try{let c=function(t,r,n,i,a,s,o){let l=r?(function(t){let r=t.split(`
|
|
55
|
+
`),n=1/0;for(let t of r){if(""===t.trim())continue;let r=t.length-t.trimStart().length;r<n&&(n=r)}return n===1/0||0===n?t:r.map(t=>t.slice(Math.min(n,t.length-t.trimStart().length))).join(`
|
|
56
|
+
`)})(t.replace(/\r\n?/g,`
|
|
57
|
+
`)).trim():t.trim(),c=[],d=[],u=0,h={style:s,shifts:[]};for(let t of l.split(nH)){let o=[];!function(t,r,n,i,a){let s=a.style,o=0,l="",c=0,d=r.length,u=()=>{(function(t,r,n){let i;if(!r.includes(":fa-"))return n6(t,r,n);let a=0;for(nq.lastIndex=0;null!==(i=nq.exec(r));){let s=`${i[1]}:fa-${i[2]}`;if(n6(t,r.slice(a,i.index),n),a=i.index+i[0].length,""!==$(s))t.push({text:"",style:n,icon:s,width:0});else if(" "===r[a])a++;else if(a===r.length){let r=t[t.length-1];n5(r)&&(r.text=r.text.trimEnd())}}n6(t,r.slice(a),n)})(t,l,s|(a.shifts[a.shifts.length-1]??0)),l=""};for(;c<d;){let t=r[c];if("<"===t){nU.lastIndex=c;let t=nU.exec(r);if(t&&t.index===c){let n=t[1].toLowerCase(),o="/"===r[c+1],l=nY.get(n)??0;if(24&l){u();let t=a.shifts.lastIndexOf(l);o?-1!==t&&a.shifts.splice(t,1):a.shifts.push(l)}else l&&(u(),a.style=o?a.style&~l|i&l:a.style|l,s=o?s&~l|i&l:s|l);if(l||nG.has(n)){c+=t[0].length;continue}}}else if(n&&("*"===t||"_"===t)){let n=r[c+1]===t,a=n?1:2,l=n?2:1,h=(o&a)==0,f=c>0?r[c-1]:" ",p=c+l<d?r[c+l]:" ",g=h&&""!==p.trim()&&-1!==r.indexOf(n?t+t:t,c+l),m=!h&&""!==f.trim(),y="_"===t&&/\w/.test(f)&&/\w/.test(p);if((g||m)&&!y){u(),o=g?o|a:o&~a,s=g?s|a:s&~a|i&a,c+=l;continue}}l+=t,c++}u()}(o,t.trim(),r,s,h);let l=function(t,r,n){let i=0;for(let a of t)a.width=void 0!==a.icon?1.25*n:a.math?a.math.width:r.width(a.text,n,a.style),i+=a.width;return i}(o,n,i);l>a?n9(o,n,i,a,c,d):(c.push(o),d.push(l))}for(let t of d)t>u&&(u=t);let f=c.length>1?Math.round(1.3*i):o;return{lines:c,widths:d,width:u,height:c.length*f,size:i,lineHeight:f}}(t,r,n,i,a,s,o);return l?it(c):c}finally{nW=c}}function it(t){let r;for(let n=0;n<t.lines.length;n++){let i=t.lineHeight;for(let r of t.lines[n])r.math&&(i=Math.max(i,Math.ceil(r.math.height+t.size/4)));i!==t.lineHeight&&void 0===r&&(r=t.lines.map(()=>t.lineHeight)),r&&(r[n]=i)}if(void 0===r)return void 0===t.heights?t:{...t,heights:void 0,height:t.lines.length*t.lineHeight};let n=0;for(let t of r)n+=t;return{...t,heights:r,height:n}}function ir(t){for(let r of t)if(r.math)return!0;return!1}function ii(t,r){let n=t.heights;if(!n)return(r+.5)*t.lineHeight;let i=0;for(let t=0;t<r;t++)i+=n[t];return i+n[r]/2}function ia(t,r){let n=t.widths[r],i=t.heights?t.heights[r]:t.lineHeight,a={lines:[t.lines[r]],widths:[n],width:n,height:i,size:t.size,lineHeight:t.lineHeight};return i!==t.lineHeight&&(a.heights=[i]),a}function is(t,r,n,i){let a=i(r,!1),s=t.maxWidth;if(void 0===s||!(s>0)||a.width<=s)return a;let o=Math.min(n,r),l=r;a=i(l,!0);for(let t=0;t<3&&a.width>s&&l>o;t++)a=i(l=Math.max(o,l-(a.width-s)),!0);return a}function io(t){let r=t.maxWidth;return void 0!==r&&r>0?Math.max(80,r-2*(t.padding??8)):4e3}function il(t,r,n,i=0){let a=t.maxWidth;return void 0!==a&&a>0?Math.max(Math.min(n,r),Math.min(r,a-i)):r}function ic(t,r){let n=r(!1),i=t.maxWidth;if(!1===t.autoDirection||void 0===i||!(i>0)||n.width<=i)return n;let a=t.directionBreakpoint;if(i>=(void 0!==a&&a>0?a:640))return n;let s=r(!0);return s.width<n.width?s:n}function id(t){return"LR"===t||"RL"===t}function iu(t,r){let n=r(!1),i=t.maxWidth;if(void 0===i||!(i>0)||n.width<=i)return n;let a=r(!0);return a.width<n.width?a:n}var ih=new Map([["tool",0],["task",1],["decision",2],["input",3],["refdoc",4],["connector",5],["action",6]]),ip=ih.size,ig=(t,r)=>{let n=ip+t%Math.max(1,r-ip);return r>0?n%r:n},im="collapsed",iy={TB:2,RL:3,BT:0,LR:1},iv=new WeakMap;function ib(t,r){let n=iv.get(t);if(void 0===n){let i=r.flowchart?.curve;n=function(t,r){let n=[],i=[],a=t.subgraphs,s=r=>{let n=[];for(let i of r){let r=t.classes.get(i);r?.styles&&(n=[...n,...r.styles].map(t=>t.trim())),r?.textStyles&&(n=[...n,...r.textStyles].map(t=>t.trim()))}return n},o=new Set,l=new Map,c=new Set;for(let r of a){if(r.metadata?.view!=="collapsed"||o.has(r.id))continue;let n=[r.id];for(;n.length>0;){let i=t.subgraph(n.pop())?.nodes;if(void 0!==i)for(let t of i)t===r.id||o.has(t)||(o.add(t),l.set(t,r.id),c.has(t)||n.push(t))}c.add(r.id)}let d=new Map;for(let t of o){let r=[t],n=l.get(t);for(;;){let t=d.get(n),i=t??l.get(n);if(void 0===i||(void 0===t&&r.push(n),n=i,void 0!==t))break}for(let t of r)d.set(t,n)}let u=new Map;a.forEach((t,r)=>u.set(t.id,r));let h=new Map,f=(t,r,n)=>{let i=u.get(t);if(void 0===i||i<n)return!1;let s=r;for(let r=0;void 0!==s&&r<=a.length;r++){if(s===t)return!0;s=h.get(s)}return!1};for(let r=a.length-1;r>=0;r--){let n=a[r];if(!o.has(n.id))for(let i of n.nodes){if(f(i,n.id,r)){t.emitWarning("CONTAINMENT_VIOLATION",`Container "${n.id}" cannot contain "${i}" because "${i}" already contains it. The nesting that would close the loop is dropped.`,{nodeId:i});continue}h.set(i,n.id)}}let p=new Map;for(let t=a.length-1;t>=0;t--){let r=a[t];if(o.has(r.id))continue;let i=r.metadata?.view==="collapsed",l={id:r.id,label:r.title,labelType:r.labelType,parentId:h.get(r.id),cssStyles:[],cssCompiledStyles:s(r.classes),cssClasses:r.classes.join(" "),shape:i?"collapsedGroup":"flowGroup",dir:r.dir,isGroup:!i,metadata:i?{...r.metadata,containerType:r.type}:r.metadata};n.push(l),p.set(r.id,l)}for(let r of t.nodes.values()){if(o.has(r.id))continue;let i=p.get(r.id);if(i){i.cssStyles=r.styles,i.cssCompiledStyles=s(r.classes),i.cssClasses=r.classes.join(" ");continue}let a=tF(r.type),l={id:r.id,label:r.text,labelType:r.labelType,parentId:h.get(r.id),cssStyles:r.styles,cssCompiledStyles:s(["default","node",...r.classes]),cssClasses:"default "+r.classes.join(" "),dir:r.dir,link:r.link,linkTarget:r.linkTarget,tooltip:t.tooltips.get(r.id),metadata:r.metadata,isGroup:!1,shape:"square"===a||void 0===a?"squareRect":a};n.push(l),p.set(r.id,l)}t.edges.forEach((n,a)=>{let o=d.get(n.start)??n.start,l=d.get(n.end)??n.end;if(o===l&&n.start!==n.end)return;let c=[...t.defaultEdgeStyle??[]];n.style&&c.push(...n.style);let u="arrow_open"===n.type?"none":"arrow_cross"===n.type||"arrow_point"===n.type?n.type:"arrow_point";i.push({id:n.id||`L_${o}_${l}_${a}`,isUserDefinedId:n.isUserDefinedId,start:o,end:l,type:n.type??"normal",label:n.text,labelType:n.labelType,thickness:n.stroke,pattern:n.stroke,minlen:n.length,classes:"edge-thickness-normal edge-pattern-solid flowchart-link",arrowTypeStart:"none",arrowTypeEnd:u,cssCompiledStyles:s(n.classes),style:c,animate:n.animate,animation:n.animation,curve:n.interpolate||t.defaultInterpolate||r,metadata:n.metadata})}),function(t,r){for(let n of t)n.isGroup||(n.shape&&"squareRect"!==n.shape&&"rect"!==n.shape||(n.shape=tj),tz.has(n.shape)?(r.emitError("SHAPE_REMOVED",`shape "${n.shape}" was removed in v0.8.1, using "${tj}"`,{nodeId:n.id}),n.shape=tj):tP.has(n.shape)||(r.emitWarning("SHAPE_UNSUPPORTED",`shape "${n.shape}" is not supported, using "${tj}"`,{nodeId:n.id}),n.shape=tj))}(n,t);let g=new Map;for(let t of a){let r=h.get(t.id);if(void 0===r)continue;let n=g.get(r);n?n.push(t.id):g.set(r,[t.id])}let m=new Map;for(let t of a){if(void 0!==h.get(t.id))continue;let r=[t.id];for(;r.length>0;){let t=r.pop();if(m.has(t))continue;m.set(t,m.size);let n=g.get(t);if(n)for(let t=n.length-1;t>=0;t--)r.push(n[t])}}return function(t,r,n){let i=n.size;for(let a of t){if(a.isGroup||"collapsedGroup"===a.shape){a.colorIndex=ig(n.get(a.id)??i++,8);continue}let t=r(a.id);t&&ih.has(t)&&(a.kind=t)}}(n,r=>{if(t.connectors.has(r))return"connector";let n=t.nodes.get(r);return n?t.vertexKind(n):void 0},m),{nodes:n,edges:i}}(t,"string"==typeof i?i:void 0),iv.set(t,n)}return n}function ix(t,r,n){let i=t.agentflow?.[r];return"number"==typeof i&&i>0?Math.min(i,2e3):n}function iw(t,r,n){let i=nu(t);return` fill="${i}"${r8(n.shape)?"":` fill-opacity="${r}"`} stroke="${i}"`}function i$(t,r,n,i){let a=ib(t,r),s=n.fontSize??16,o=Math.round(.875*s),l=n.measurer??e$(n.fontFamily,n.fontFamilyMono),c=ix(r,"wrappingWidth",120),d=ix(r,"minNodeWidth",120),u=n.padding??8,h=n.icons,f=new Map,p=[],g=[];for(let t of(a.nodes.forEach((t,r)=>f.set(t.id,r)),a.nodes)){let r=no(t.cssStyles.length>0?t.cssCompiledStyles.concat(t.cssStyles):t.cssCompiledStyles),n=!!r.bold|2*!!r.italic,i="markdown"===t.labelType,a=r.fontSize??s,o,u;if(t.isGroup){let s=n7(t.label,i,l,a,4e3,n);o={node:t,style:r,label:s,shape:"group",w:0,h:0,dy:0,loops:0},(u=rR(0,0)).isGroup=!0,u.dir=t.dir?rC(t.dir):void 0,u.padX=20,u.padTop=s.height>0?s.height+16:20,u.padBottom=20,u.minW=s.width+40-12}else if("collapsedGroup"===t.shape){let s=n7(t.label,i,l,a,c,n),h=Math.max(s.width,d)+36,f=s.height+24+14;o={node:t,style:r,label:s,shape:im,w:h,h:f,dy:-7,loops:0},u=rR(h,f)}else{let s=tR(t.shape),h=n7(t.label,i,l,a,c,n),f=nO(s,"diam"===s?h.width:Math.max(h.width,d),h.height);o={node:t,style:r,label:h,shape:s,w:f.w,h:f.h,dy:f.dy,loops:0},u=rR(f.w,f.h)}u.seq=p.length,p.push(o),g.push(u)}a.nodes.forEach((t,r)=>{g[r].parent=void 0!==t.parentId?f.get(t.parentId)??-1:-1}),rO(g,a.edges.map(t=>[f.get(t.start)??-1,f.get(t.end)??-1]));let m=i?"TB":rC(t.direction),v=t=>{let r;for(let n=g[t].parent,i=0;n>=0&&void 0===r&&i<1e4;n=g[n].parent,i++)r=g[n].dir;return r??m},b=t=>{let r=v(t);return"LR"===r||"RL"===r},x=new Int32Array(g.length).fill(-1);for(let t=0;t<g.length;t++){let r=[],n=t;for(;n>=0&&x[n]<0&&r.length<=g.length;)r.push(n),n=g[n].parent;let i=n>=0?x[n]+1:0;for(let t=r.length-1;t>=0;t--)x[r[t]]=i++}let w=(t,r)=>{let n=r;for(let i=x[r];i>x[t];i--)n=g[n].parent;return n===t&&r!==t},$=[],k=[],M=[],_=[];for(let t of a.edges){let r=f.get(t.start),n=f.get(t.end);if(void 0===r||void 0===n)continue;let i=n7(t.label,"markdown"===t.labelType,l,o,c);if(w(r,n)||w(n,r)){_.push({edge:t,label:i,src:r,dst:n});continue}r===n&&(p[r].loops++,b(r)?g[r].h+=2*(26+(i.height>0?i.height+8:0)):g[r].w+=2*(26+(i.width>0?i.width+12:0))),M.push(t),k.push(i),$.push({src:r,dst:n,minlen:t.minlen??1,labelW:i.width>0?i.width+12:0,labelH:i.height>0?i.height+4:0,route:[],labelX:0,labelY:0})}let A=rP(g,$,m,{nodeSep:ix(r,"nodeSpacing",40),edgeSep:16,rankSep:ix(r,"rankSpacing",48),portSep:20}),E=n7(t.title,!1,l,s,4e3,1),S=E.height>0?E.height+12:0,C=Math.max(A.width,E.width);rD(g,$,u+(C-A.width)/2,u+S);let T=Math.ceil(C+2*u),I=Math.ceil(A.height+S+2*u),N=[],O=[],D=[],R=[],L=_.length*g.length<2e6;for(let{edge:t,src:r,dst:n}of _){let i=w(n,r),a=i?n:r,s=i?r:n,o=g[a],l=g[s],c=iy[o.dir??v(a)],d=i?c:c+2&3,u=t=>{let r=(1&t)==0,n=0===t||3===t?-1:1,a=r?l.x:l.x+n*l.w/2,s=r?l.y+n*l.h/2:l.y,c=r?l.x:o.x+n*o.w/2,d=r?o.y+n*o.h/2:l.y,u=+!r;return i?[a,s,u,c,d,u]:[c,d,u,a,s,u]},h=t=>{for(let r=0;r<g.length;r++){let n=g[r];if(r!==s&&!n.isGroup&&n.x+n.w/2>Math.min(t[0],t[3])-1&&n.x-n.w/2<Math.max(t[0],t[3])+1&&n.y+n.h/2>Math.min(t[1],t[4])-1&&n.y-n.h/2<Math.max(t[1],t[4])+1)return!0}return!1},f=u(d);if(L&&h(f))for(let t of[d+1&3,d+3&3,d+2&3]){let r=u(t);if(!h(r)){f=r;break}}R.push(f),D.push((f[0]+f[3])/2,(f[1]+f[4])/2);let m=f.slice();nP(m,3*!i,p[s],l),O.push(rU(m,"linear",0,rq(t.arrowTypeEnd)))}let z=new Map,P=!1;for(let t of g)t.isGroup&&(P=!0);if(P){for(let t of $)rj(z,t.route);for(let t of R)rj(z,t)}let j="",F="",B=[];for(let t=0;t<p.length;t++){let r=p[t],i=g[t],a=r.node,s=i.x,o=i.y,l=nc(a.cssClasses.replace(/^default\s?/,"")),c=eS(a.id);if(i.isGroup){e6(r.style.shape)&&B.push({box:[s-i.w/2,o-i.h/2,s+i.w/2,o+i.h/2],shape:r.style.shape});let t=rF(i,r.label.width,z,20);j+=`<g class="pele-cluster pele-flow${l}" data-id="${c}"><rect x="${eT(s-i.w/2)}" y="${eT(o-i.h/2)}" width="${eT(i.w)}" height="${eT(i.h)}"${r9(iw(a.colorIndex??ih.size,"0.06",r.style)+r.style.shape)}/>`+eI(r.label,t,o-i.h/2+8+r.label.height/2,` class="pele-cluster-label"${e8(r.style,"var(--_m)")}${r.style.text}`,h)+"</g>";continue}let d=r.w,u=r.h,f="",m;if(r.shape===im){let t=nu(a.colorIndex??ih.size),n=u/2-14-2,i=n+8;m=`<rect x="${eT(-d/2)}" y="${eT(-u/2)}" width="${eT(d)}" height="${eT(u)}"${r9(iw(a.colorIndex??ih.size,"0.06",r.style)+r.style.shape)}/><path d="M${eT(-d/2+10)},${eT(n)}H${eT(d/2-10)}" fill="none" stroke="${t}" stroke-dasharray="3 3"${r.style.line}/><path class="pele-collapsed-mark" d="${ik(-9,i)}${ik(0,i)}${ik(9,i)}" fill="${t}" stroke="none"/>`}else{let t=ih.get(a.kind??"task")??1;f=` pele-kind-${a.kind??"task"}`,m=nD(r.shape,d,u,iw(t,"0.14",r.style)+r.style.shape,` stroke="${nu(t)}"`+r.style.line)}let v=r.shape===im||nL(r.shape)?e8(r.style):"",b=eI(r.label,0,r.dy,` class="pele-label"${v}${r.style.text}`,h);if(/ internal-link(?: |$)/.test(l+" ")&&a.label&&!1!==n.links){let t=y(a.label),r=tT(t,n),i=eE(t);b=`<a class="internal-link"${r?` href="${i}"${tN(n)}`:""} data-href="${i}">${b}</a>`,N.push({id:a.id,href:t,internal:!0})}let x=m+b;a.tooltip&&(x=`<title>${eS(a.tooltip)}</title>`+x),a.link&&(x=tI(x,a.link,a.id,N,n,a.linkTarget?` target="${eE(a.linkTarget)}"`:"")),F+=`<g class="pele-node pele-shape-${r.shape}${f}${l}" data-id="${c}" transform="translate(${eT(s)},${eT(o)})">${x}</g>`}let W="",H="",U="",q=(t,r,n,i,a)=>{let s=t.style.length>0||t.cssCompiledStyles.length>0?no(t.cssCompiledStyles.concat(t.style)):void 0,o=t.arrowTypeEnd,l=rJ(n.d,[n.ex,n.ey],B,s?.line,n.tokens),c=l||(s?.stroke?eE(s.stroke):"var(--_l)"),d="dotted"===t.thickness?"reference":"arrow_cross"===o?"failure":"sequence",u=nc(t.classes.replace(/edge-thickness-normal|edge-pattern-solid|flowchart-link/g,""));""===l&&(W+=r0(n,"none",o,s?.line)),H+=`<g class="pele-edge pele-edge-${d}${u}" data-id="${eS(t.id)}"${l?` stroke="${l}"`:""}${s?.line??""}><path d="${n.d}"${"dotted"===t.thickness?' stroke-dasharray="3 4"':""}/>`+rV(o,n.ex,n.ey,n.edx,n.edy,c)+"</g>",r.width>0&&(U+=r2(t.id,r,i,a,s?.text??"",h))},V=new Map;for(let t=0;t<$.length;t++){let r=$[t],n=M[t],i=k[t],a=n.arrowTypeEnd,s;if(r.src===r.dst){let t=p[r.src],n=V.get(r.src)??0;V.set(r.src,n+1),s=r4(g[r.src],t.w,t.h,n,b(r.src),26,rq(a),r)}else{let t=r.route.slice();nP(t,0,p[r.src],g[r.src]),nP(t,t.length-3,p[r.dst],g[r.dst]),s=rU(t,n.curve,0,rq(a))}q(n,i,s,r.labelX,r.labelY)}return _.forEach((t,r)=>q(t.edge,t.label,O[r],D[2*r],D[2*r+1])),{svg:np("agentflow",T,I,s,n,t,eI(E,T/2,u+E.height/2,' class="pele-title" font-weight="var(--_tw)"')+(j?`<g class="pele-clusters">${j}</g>`:"")+r1(W)+(H?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${H}</g>`:"")+(U?`<g class="pele-edge-labels" font-size="${o}">${U}</g>`:"")+`<g class="pele-nodes">${F}</g>`),width:T,height:I,links:N}}function ik(t,r){return`M${eT(t-1.75)},${eT(r)}a1.75,1.75 0 1 0 3.5,0a1.75,1.75 0 1 0 -3.5,0Z`}function iM(t){throw new a(t,"semantic",{type:"architecture"})}var i_=class{type="architecture";title;accTitle;accDescr;nodes=new Map;groups=new Map;edges=[];layoutHints=[];registered=new Map;register(t,r,n){this.registered.has(r)&&iM(`The ${t} id [${r}] is already in use by another ${this.registered.get(r)}`),void 0!==n&&(r===n&&iM(`The ${t} [${r}] cannot be placed within itself`),this.registered.has(n)||iM(`The ${t} [${r}]'s parent does not exist. Please make sure the parent is created before this ${t}`),"node"===this.registered.get(n)&&iM(`The ${t} [${r}]'s parent is not a group`)),this.registered.set(r,"group"===t?"group":"node")}addService({id:t,icon:r,iconText:n,title:i,in:a}){this.register("service",t,a),this.nodes.set(t,{id:t,type:"service",icon:r,iconText:n,title:i,in:a})}addJunction({id:t,in:r}){this.register("junction",t,r),this.nodes.set(t,{id:t,type:"junction",in:r})}addGroup({id:t,icon:r,title:n,in:i}){this.register("group",t,i),this.groups.set(t,{id:t,icon:r,title:n,in:i})}addEdge({lhsId:t,rhsId:r,lhsDir:n,rhsDir:i,lhsInto:a,rhsInto:s,lhsGroup:o,rhsGroup:l,title:c}){let d=[["left",t,o],["right",r,l]];for(let[t,r]of d)this.registered.has(r)||iM(`The ${t}-hand id [${r}] does not yet exist. Please create the service/group before declaring an edge to it.`);for(let[t,r]of d)this.nodes.has(r)||iM(`The ${t}-hand id [${r}] is a group. Add {group} to a service inside it instead.`);let u=this.nodes.get(t).in;if(void 0!==u&&u===this.nodes.get(r).in)for(let[t,r,n]of d)n&&iM(`The ${t}-hand id [${r}] is modified to traverse the group boundary, but the edge does not pass through two groups.`);this.edges.push({lhsId:t,lhsDir:n,lhsInto:a,lhsGroup:o,rhsId:r,rhsDir:i,rhsInto:s,rhsGroup:l,title:c})}addLayoutHint(t){t.members.length<2&&iM(`An align directive requires at least two members; got ${t.members.length}`);let r=new Set;for(let n of t.members)"node"!==this.registered.get(n)&&iM(`align ${t.direction} references [${n}], which is not a service or junction`),r.has(n)&&iM(`align ${t.direction} lists [${n}] more than once`),r.add(n);this.layoutHints.push(t)}},iA=new WeakMap;function iE(t,r,n){let i=[],a=[],s=[],o=new Uint8Array(r.length),{starting:l,every:c,longer:u}=iA.get(r)??function(t){let r=t.map((t,r)=>r),n=[];for(let i=0;i<128;i++){let a=String.fromCharCode(i);n.push(r.filter(r=>{let{pattern:n,first:i}=t[r];return"string"==typeof n?n[0]===a:void 0===i||i.includes(a)}))}let i={starting:n,every:r,longer:t.map(r=>r.longer?.map(r=>t.indexOf(r)))};return iA.set(t,i),i}(r),h=[],f=t.length,p=(n,a)=>{if(o[n])return -1;let s=r[n];if(void 0!==s.match)return s.match(t,a,i[i.length-1]??-1);if(void 0!==s.scanner)return(h[n]??=s.scanner())(t,a,i[i.length-1]??-1);let l=s.pattern;return"string"==typeof l?t.startsWith(l,a)?a+l.length:-1:(l.lastIndex=a,l.test(t)?l.lastIndex:(void 0!==s.opener&&(s.opener.lastIndex=a,s.opener.test(t)&&(o[n]=1)),-1))},g=0;t:for(;g<f;){let o=t.charCodeAt(g);for(let t of o<128?l[o]:c){let n=p(t,g);if(n<=g)continue;let o=t,l=u[t];if(void 0!==l)for(let t of l){let r=p(t,g);if(r>n){o=t,n=r;break}}r[o].hidden||(i.push(o),a.push(g),s.push(n)),g=n;continue t}throw d(n,t,g,"",!0)}return i.push(-1),a.push(f),s.push(f),{kinds:i,starts:a,ends:s,src:t}}var iS={name:"ACC_DESCR",pattern:/[\t ]*accDescr(?:[\t ]*:([^\n\r]*?(?=%%)|[^\n\r]*)|\s*{([^}]*)})/y,first:" a"},iC={name:"ACC_TITLE",pattern:/[\t ]*accTitle[\t ]*:(?:[^\n\r]*?(?=%%)|[^\n\r]*)/y,first:" a"},iT={name:"TITLE",pattern:/[\t ]*title(?:[\t ][^\n\r]*?(?=%%)|[\t ][^\n\r]*|)/y,first:" t"};function iI(t){return{...iT,pattern:RegExp(String.raw`[\t ]*title(?:[\t ][^\n\r]*?(?=%%)|[\t ][^\n\r]*|(?!${t}))`,"y")}}var iN={name:"STRING",pattern:/"([^"\\]|\\.)*"|'([^'\\]|\\.)*'/y,first:"\"'"},iO={name:"NEWLINE",pattern:/\r?\n/y,first:`\r
|
|
58
|
+
`},iD={name:"WHITESPACE",pattern:/[\t ]+/y,hidden:!0,first:" "},iR={name:"YAML",pattern:/---[\t ]*\r?\n(?:[\S\s]*?\r?\n)?---(?:\r?\n|(?!\S))/y,hidden:!0,opener:/---[\t ]*\r?\n/y,first:"-"},iL={name:"DIRECTIVE",pattern:/[\t ]*%%{[\S\s]*?}%%(?:\r?\n|(?!\S))/y,hidden:!0,opener:/[\t ]*%%{/y,first:" %"},iz={name:"SINGLE_LINE_COMMENT",pattern:/[\t ]*%%[^\n\r]*/y,first:" %",hidden:!0};function iP(t){return{name:t,pattern:RegExp(t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"(?:(?=%%)|(?!\\S))","y"),first:t[0]}}var ij=/accDescr(?:[\t ]*:([^\n\r]*)|\s*{([^}]*)})/,iF=/accTitle[\t ]*:([^\n\r]*)/,iB=/title([\t ][^\n\r]*|)/;function iW(t){return t.trim().replace(/[\t ]{2,}/gm," ")}function iH(t){return iW(iB.exec(t)[1])}function iU(t){return iW(iF.exec(t)[1])}function iq(t){let r=ij.exec(t);return void 0!==r[1]?iW(r[1]):r[2].replace(/^\s*/gm,"").replace(/\s+$/gm,"").replace(/[\t ]{2,}/gm," ").replace(/[\n\r]{2,}/gm,`
|
|
59
|
+
`)}var iV=new Map([["b","\b"],["f","\f"],["n",`
|
|
60
|
+
`],["r","\r"],["t"," "],["v","\v"],["0","\0"]]);function iY(t){if(!t.includes("\\"))return t.slice(1,-1);let r="";for(let n=1;n<t.length-1;n++){let i=t[n];if("\\"===i){let i=t[++n];r+=iV.get(i)??i}else r+=i}return r}var iG=class{constructor(t,r,n){this.tokens=t,this.types=r,this.diagram=n,this.kinds=t.kinds}tokens;types;diagram;i=0;kinds;get kind(){return this.kinds[this.i]}text(t=this.i){return this.tokens.src.slice(this.tokens.starts[t],this.tokens.ends[t])}take(){return this.text(this.i++)}accept(t){return this.kinds[this.i]===t&&(this.i++,!0)}expect(t){return this.kinds[this.i]!==t&&this.fail(`token of type '${this.types[t].name}'`),this.take()}fail(t){let r=-1===this.kind?"end of input":`\`${this.text()}\``,{src:n,starts:i,ends:a}=this.tokens,s=i[this.i];if(-1===this.kind){let t=this.i;for(;t>0&&""===n.slice(i[t-1],a[t-1]).trim();)t--;t>0&&(s=a[t-1])}throw d(this.diagram,n,s,`Expecting ${t} but found ${r}.`)}},iZ={name:"ID",pattern:/[\w]([-\w]*\w)?/y};function iX(t){return{name:t,pattern:t,longer:[iZ]}}var iK=[iX("architecture-beta"),iX("junction"),iX("service"),iX("column"),iX("group"),iX("align"),iX("row"),{name:"--",pattern:"--",longer:[iR]},iX("in"),{name:":",pattern:":"},{name:"-",pattern:"-",longer:[iR]},{name:"ARROW_DIRECTION",pattern:/L|R|T|B/y},{name:"ARROW_GROUP",pattern:/\{group\}/y},{name:"ARROW_INTO",pattern:/<|>/y},iS,iC,iI(String.raw`[-\w]*\w`),iN,iZ,iO,iD,iR,iL,iz,{name:"ARCH_ICON",pattern:/\([\w-:]+\)/y},{name:"ARCH_TITLE",pattern:/\[(?:"([^"\\]|\\.)*"|'([^'\\]|\\.)*'|[^\[\]\r\n]+)\]/y}];function iJ(t){let r=t.slice(1,-1).trim();return(r.startsWith('"')&&r.endsWith('"')||r.startsWith("'")&&r.endsWith("'"))&&(r=r.slice(1,-1).replace(/\\"/g,'"').replace(/\\'/g,"'")),r.trim()}var iQ=new Map([["database","M4 6a8 3 0 1 0 16 0a8 3 0 1 0-16 0M4 6v12a8 3 0 0 0 16 0V6M4 12a8 3 0 0 0 16 0"],["server","M3 4h18v7H3zM3 13h18v7H3zM7 7.5h.01M7 16.5h.01M11 7.5h6M11 16.5h6"],["disk","M5 3h14v18H5zM12 6.5a4 4 0 1 0 0 8a4 4 0 1 0 0-8M12 10.5h.01M8 18h3"],["internet","M3 12a9 9 0 1 0 18 0a9 9 0 1 0-18 0M3 12h18M12 3a13 13 0 0 0 0 18M12 3a13 13 0 0 1 0 18"],["cloud","M7 18a4 4 0 0 1-.5-7.97A6 6 0 0 1 18 9.5a4.25 4.25 0 0 1-.5 8.5z"]]),i0=[-1,1,0,0],i1=[0,0,-1,1];function i2(t){return"L"===t?0:"R"===t?1:"T"===t?2:3}var i4=[-1,1,0,0],i3=[0,0,-1,1];function i5(t,r,n,i,a){let s=t.architecture,o=null===s||"object"!=typeof s||Array.isArray(s)?void 0:s[r];return"number"==typeof o&&Number.isFinite(o)?Math.min(a,Math.max(i,o)):n}function i6(t){let r=new Map;for(let n of t.sort((t,r)=>t-r))r.has(n)||r.set(n,r.size);return r}function i8(t,r,n,i,a){let s;return`<svg class="pele-icon" data-icon="${eS(t)}" x="${eT(r)}" y="${eT(n)}" width="${eT(i)}" height="${eT(i)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${a?.(t)??(void 0===(s=iQ.get(t))?"":`<path d="${s}" stroke="var(--_fg)" stroke-width="1.5"/>`)}</svg>`}function i9(t){switch(t){case"[]":return"square";case"()":return"round";case"(())":return"circle";case">]":return"rect_left_inv_arrow";case"{}":return"diamond";case"{{}}":return"hexagon";case"([])":return"stadium";case"[[]]":return"subroutine";case"[()]":return"cylinder";case"((()))":return"doublecircle";case"[//]":return"lean_right";case"[\\\\]":return"lean_left";case"[/\\]":return"trapezoid";case"[\\/]":return"inv_trapezoid";case"<[]>":return"block_arrow";default:return"na"}}function i7(t){switch(t.trim().slice(-1)){case"x":return"arrow_cross";case"o":return"arrow_circle";case">":return"arrow_point";default:return""}}function ae(t){switch(t.trim().charAt(0)){case"x":return"arrow_cross";case"o":return"arrow_circle";case"<":return"arrow_point";default:return"arrow_open"}}function at(t){return t.includes("==")?"thick":"normal"}function ar(t){return t.includes(".-")?"dotted":"solid"}function an(t,r){let n=t.flat(),i=-1;for(let t of n)if("column-setting"===t.type){i=t.columns??-1;break}return{list:n,at:0,parent:r,children:[],columns:i}}var ai=class{type="block";title;root={id:"root",type:"composite",children:[],columns:-1};blocks=[];edges=[];classes=new Map;byId=new Map;typeStr2Type=i9;edgeStrToEdgeData=i7;edgeStrToEdgeStartData=ae;edgeStrToThickness=at;edgeStrToPattern=ar;warn;pending=new Set;edgeCount=new Map;ids=0;colors=0;spaces=0;constructor(t={}){this.warn=t.warn}generateId(){return"id-"+ ++this.ids}addStyleClass(t,r=""){let n=this.classes.get(t);for(let i of(n||(n={id:t,styles:[],textStyles:[]},this.classes.set(t,n)),r.split(","))){let t=i.indexOf(";"),r=(-1===t?i:i.slice(0,t)+i.slice(t+1)).trim();i.includes("color")&&n.textStyles.push(r.replace("fill","bgFill").replace("color","fill")),n.styles.push(r)}}addStyle2Node(t,r=""){this.named(t).styles=r.split(",")}setCssClass(t,r){for(let n of t.split(","))(this.named(n.trim()).classes??=[]).push(r)}named(t){let r=this.byId.get(t);return void 0===r&&(r={id:t,type:"na",children:[]},this.byId.set(t,r),this.pending.add(t)),r}setHierarchy(t){let r=[an(t,this.root)];for(;r.length>0;){let t=r[r.length-1];if(t.at===t.list.length){t.parent.children=t.children,r.pop();continue}let n=t.list[t.at++];switch(t.columns>0&&"column-setting"!==n.type&&"number"==typeof n.widthInColumns&&n.widthInColumns>t.columns&&this.warn?.(`Block ${n.id} width ${n.widthInColumns} exceeds configured column width ${t.columns}`),n.type){case"classDef":this.addStyleClass(n.id,n.css);continue;case"applyClass":this.setCssClass(n.id,n.styleClass??"");continue;case"applyStyles":n.stylesStr&&this.addStyle2Node(n.id,n.stylesStr);continue;case"column-setting":t.parent.columns=n.columns??-1;continue;case"edge":{let t=(this.edgeCount.get(n.id)??0)+1;this.edgeCount.set(n.id,t),n.id=t+"-"+n.id,this.edges.push(n);continue}}n.id??=this.generateId(),n.label||(n.label="composite"===n.type?"":n.id);let i=this.byId.get(n.id),s=void 0===i||this.pending.delete(n.id);s?(i&&(n.classes=i.classes,n.styles=i.styles),"composite"===n.type&&(n.colorIndex=this.colors++),this.byId.set(n.id,n)):("na"!==n.type&&(i.type=n.type),n.label!==n.id&&(i.label=n.label));let o=n.children;if(n.children=[],"space"===n.type){let r=n.width??1;if(!(r<=1e5-this.spaces))throw new a("A block diagram can hold at most 100000 space blocks.","limit",{type:"block"});this.spaces+=Math.max(r,0);for(let i=0;i<r;i++){let r={...n,id:n.id+"-"+i,children:[]};this.byId.set(r.id,r),t.children.push(r)}}else s&&t.children.push(n);o&&o.length>0&&r.push(an(o,n))}this.blocks=this.root.children??[]}},aa=["$end","INVALID","BLOCK_DIAGRAM_KEY","id-block","COLUMNS","MD_STR","STR","SPACE_BLOCK","DEFAULT","LINKSTYLE","INTERPOLATE","classDef","DEFAULT_CLASSDEF_ID","CLASSDEF_ID","CLASSDEF_STYLEOPTS","class","CLASSENTITY_IDS","STYLECLASS","style","STYLE_ENTITY_IDS","STYLE_DEFINITION_DATA","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","end","NODE_DSTART","NODE_DEND","BLOCK_ARROW_START","BLOCK_ARROW_END","DIR","NODE_ID","LINK","START_LINK","LINK_LABEL","SIZE","EOF"],as=["right","left","x","y","up","down"],ao=new Uint8Array(128);for(let t of[9,10,11,12,13,32,40,41,45,58,60,61,62,91,123,125])ao[t]=1;var al="'NODE_ID', 'COLUMNS', 'SPACE_BLOCK', 'BLOCK_DIAGRAM_KEY', 'id-block', 'classDef', 'class', 'style'";function ac(t){let r=t[t.length-1];return Array.isArray(r)?(t.pop(),t.concat(r)):t}function ad(t,r,n,i){var a=()=>n7(t,!1,r,n,i,1);if(void 0===k)return a();let s=k;k=void 0;try{return a()}finally{k=s}}function au(t,r,n,i,a,s,o){let l=ad(t,r,n,4e3);if(0===l.height)return{width:a,height:s,content:o};let c=l.height+12,d=Math.max(a,Math.ceil(l.width+2*i));return{width:d,height:Math.ceil(s+c),content:eI(l,d/2,i+l.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${eT((d-a)/2)},${eT(c)})">${o}</g>`}}var ah=(t,r)=>t&r?1:0;function af(t){return 0!==t&&(12&t)==0?"x":0!==t&&(3&t)==0?"y":""}function ap(t,r,n){let i=af(t),a=ah(t,2)-ah(t,1),s=ah(t,4)-ah(t,8);if("x"===i){let i=Math.max(n+8,14)+14,s=Math.min(i/2,20);return{w:Math.max(r+12,16)+s*(3===t?2:1),h:i,dx:a*s/2,dy:0}}if("y"===i){let i=Math.max(r+16,14)+14,a=Math.min(i/2,20);return{w:i,h:Math.max(n+8,16)+a*(12===t?2:1),dx:0,dy:s*a/2}}return{w:Math.max(r+16,24)+12*(ah(t,2)+ah(t,1)),h:Math.max(n+8,24)+12*(ah(t,4)+ah(t,8)),dx:12*a/2,dy:12*s/2}}function ag(t){let r=0;for(let n of t)r+=n??0;return r}var am=' fill="var(--_s)" stroke="var(--_b)"',ay=[],av=[],ab=[],ax=[],aw=["default"],a$=new Map([["square","rect"],["round","rounded"],["circle","circle"],["doublecircle","dbl-circ"],["diamond","diam"],["hexagon","hex"],["stadium","stadium"],["subroutine","fr-rect"],["cylinder","cyl"],["rect_left_inv_arrow","odd"],["lean_right","lean-r"],["lean_left","lean-l"],["trapezoid","trap-b"],["inv_trapezoid","trap-t"]]),ak=new Set(["circle","dbl-circ","diam"]),aM=new Set(["stadium","hex","odd","lean-r","lean-l","trap-b","trap-t"]);function a_(t){return 0===t.kind&&("circle"===t.shape||"dbl-circ"===t.shape)}function aA(t,r,n){let i=t.bw/2,a=t.bh/2,s=Math.abs(r-t.x),o=a;return a_(t)?o=Math.sqrt(Math.max(i*i-s*s,0)):0===t.kind&&"diam"===t.shape?o=a*Math.max(1-s/i,0):0===t.kind?o=a-nR(t.shape,t.bw,t.bh,2*(n>0)):1===t.kind&&"x"===af(t.mask)&&(o=a-7),t.y+n*o}function aE(t,r,n){let i=t.bw/2,a=t.bh/2,s=Math.abs(r-t.y),o=i;return a_(t)?o=Math.sqrt(Math.max(a*a-s*s,0)):0===t.kind&&"diam"===t.shape?o=i*Math.max(1-s/a,0):0===t.kind?o=i-nR(t.shape,t.bw,t.bh,n>0?1:3):1===t.kind&&"y"===af(t.mask)&&(o=i-7),t.x+n*o}function aS(t,r,n,i){let a=r-t.x,s=n-t.y,o=t.bw/2,l=t.bh/2,c;(c=a_(t)?o/(Math.hypot(a,s)||1):0===t.kind&&"diam"===t.shape?1/(Math.abs(a)/o+Math.abs(s)/l||1):Math.min(0===a?1/0:o/Math.abs(a),0===s?1/0:l/Math.abs(s)))===1/0&&(c=0),i.push(t.x+a*c,t.y+s*c)}function aC(t,r,n,i){let a=0;for(let s of i)if(s!==r&&s!==n){for(let r=0;r+3<t.length;r+=2)if(function(t,r,n,i,a){let s=a.x-a.bw/2+1,o=a.x+a.bw/2-1,l=a.y-a.bh/2+1,c=a.y+a.bh/2-1;if(t<s&&n<s||t>o&&n>o||r<l&&i<l||r>c&&i>c)return!1;if(t===n||r===i)return!0;let d=n-t,u=i-r,h=(n,i)=>Math.sign(d*(i-r)-u*(n-t)),f=h(s,l);return 0===f||h(o,l)!==f||h(o,c)!==f||h(s,c)!==f}(t[r],t[r+1],t[r+2],t[r+3],s)){a++;break}}return a}function aT(t,r){let n=t.bw/2,i=t.bh/2,a=Math.max(1,Math.min(10+5*(r-1),n,i));if(a_(t)){let r=t.x+n*Math.SQRT1_2,i=t.y-n*Math.SQRT1_2,s=2*Math.asin(Math.min(1,a/(2*n))),o=a=>Math.atan2(t.y-n*Math.sin(a)-i,t.x+n*Math.cos(a)-r);return[r,i,a,o(Math.PI/4+s),o(Math.PI/4-s)]}if(0===t.kind&&"diam"===t.shape){let r=Math.atan2(i,n);return[t.x+n/2,t.y-i/2,a,r+Math.PI,r]}return[t.x+n,t.y-i,a,Math.PI,Math.PI/2]}var aI=[.5,.3,.7,.15,.85];function aN(t,r,n,i,a,s,o){if(void 0===o)return!1;for(let l of o)if(l!==a&&l!==s&&Math.abs(t-l.x)<(n+l.bw)/2&&Math.abs(r-l.y)<(i+l.bh)/2)return!0;return!1}var aO=new Set(["label","type","descr","techn","sprite","tags","link","bgColor","fontColor","borderColor","shadowing","shape","legendText","legendSprite"]),aD=new Set(["label","descr","techn","sprite","tags","link","textColor","lineColor"]);function aR(t,r){let{key:n,value:i}=r;"from"in t&&("offsetX"===n||"offsetY"===n)?t[n]=parseInt(i):("from"in t?aD:aO).has(n)?t[n]=i:(t.extra??=new Map).set(n,i)}function aL(t,r,n){void 0!==n&&("string"==typeof n?t[r]=n:aR(t,n))}function az(t,r,n){void 0===n?t[r]??="":aL(t,r,n)}function aP(t,r){t.labelAttr=void 0,"object"==typeof r?(t.label="",t.labelAttr=r,aR(t,r)):t.label=r??""}var aj=class{type="c4";c4Type;title;accTitle;accDescr;shapes=[];boundaries=[{alias:"global",label:"global",type:"global",parent:void 0}];rels=[];shapeInRow=4;boundaryInRow=2;shapeIndex=new Map;boundaryIndex=new Map;relIndex=new Map;current=this.boundaries[0];stack=[];setC4Type(t){this.c4Type=t}setTitle(t){this.title=t}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
|
|
61
|
+
`)}element(t,r,n,i){let a="string"==typeof n?r.get(n):void 0;return void 0===a&&(a={alias:"",label:"",parent:void 0},t.push(a),"string"==typeof n?(a.alias=n,r.set(n,a)):(a.aliasAttr=n,aR(a,n))),aP(a,i),a}addPersonOrSystem(t,r){let n=this.element(this.shapes,this.shapeIndex,r[0],r[1]);az(n,"descr",r[2]),this.finishShape(n,t,r,3)}addContainer(t,r){let n=this.element(this.shapes,this.shapeIndex,r[0],r[1]);az(n,"techn",r[2]),az(n,"descr",r[3]),this.finishShape(n,t,r,4)}addComponent(t,r){this.addContainer(t,r)}finishShape(t,r,n,i){aL(t,"sprite",n[i]),aL(t,"tags",n[i+1]),aL(t,"link",n[i+2]),t.kind=r,t.parent=this.current}boundary(t,r){let n=this.element(this.boundaries,this.boundaryIndex,t[0],t[1]);return void 0===t[2]?n.type=r:aL(n,"type",t[2]),n}open(t){t.parent=this.current,this.stack.push(this.current),this.current=t}addPersonOrSystemBoundary(t,r="system"){let n=this.boundary(t,r);aL(n,"tags",t[3]),aL(n,"link",t[4]),this.open(n)}addContainerBoundary(t){this.addPersonOrSystemBoundary(t,"container")}addDeploymentNode(t,r){let n=this.boundary(r,"node");az(n,"descr",r[3]),aL(n,"sprite",r[4]),aL(n,"tags",r[5]),aL(n,"link",r[6]),n.nodeType=t,this.open(n)}popBoundaryParseStack(){this.current=this.stack.pop()??this.boundaries[0]}addRel(t,r){let n=r[0],i=r[1];if(void 0===n||void 0===i||void 0===r[2])return;let a="string"==typeof n&&"string"==typeof i,s=a?this.relIndex.get(n)?.get(i):void 0;if(void 0===s){if(s={type:t,from:"",to:"",label:""},this.rels.push(s),a){let t=this.relIndex.get(n);void 0===t&&this.relIndex.set(n,t=new Map),t.set(i,s)}"string"==typeof n?s.from=n:s.fromAttr=n,"string"==typeof i?s.to=i:s.toAttr=i}s.type=t,aP(s,r[2]),az(s,"techn",r[3]),az(s,"descr",r[4]),aL(s,"sprite",r[5]),aL(s,"tags",r[6]),aL(s,"link",r[7])}getC4Shape(t){return this.shapeIndex.get(t)??this.boundaryIndex.get(t)}updateElStyle(t,r){let n="string"==typeof r[0]?this.getC4Shape(r[0]):void 0;void 0!==n&&(aL(n,"bgColor",r[1]),aL(n,"fontColor",r[2]),aL(n,"borderColor",r[3]),aL(n,"shadowing",r[4]),aL(n,"shape",r[5]),aL(n,"sprite",r[6]),aL(n,"techn",r[7]),aL(n,"legendText",r[8]),aL(n,"legendSprite",r[9]))}updateRelStyle(t,r){let n=r[0],i=r[1],a="string"==typeof n&&"string"==typeof i?this.relIndex.get(n)?.get(i):void 0;if(void 0===a)return;aL(a,"textColor",r[2]),aL(a,"lineColor",r[3]);let s=r[4],o=r[5];"string"==typeof s?a.offsetX=parseInt(s):void 0!==s&&aR(a,s),"string"==typeof o?a.offsetY=parseInt(o):void 0!==o&&aR(a,o)}updateLayoutConfig(t,r){let n=t=>void 0===t?NaN:parseInt("string"==typeof t?t:t.value),i=n(r[0]),a=n(r[1]);i>=1&&(this.shapeInRow=i),a>=1&&(this.boundaryInRow=a)}},aF=["$end","INVALID","direction_tb","direction_bt","direction_rl","direction_lr","title","accDescription","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","NEWLINE","C4_CONTEXT","C4_CONTAINER","C4_COMPONENT","C4_DYNAMIC","C4_DEPLOYMENT","PERSON","PERSON_EXT","SYSTEM","SYSTEM_DB","SYSTEM_QUEUE","SYSTEM_EXT","SYSTEM_EXT_DB","SYSTEM_EXT_QUEUE","CONTAINER","CONTAINER_DB","CONTAINER_QUEUE","CONTAINER_EXT","CONTAINER_EXT_DB","CONTAINER_EXT_QUEUE","COMPONENT","COMPONENT_DB","COMPONENT_QUEUE","COMPONENT_EXT","COMPONENT_EXT_DB","COMPONENT_EXT_QUEUE","ENTERPRISE_BOUNDARY","SYSTEM_BOUNDARY","BOUNDARY","CONTAINER_BOUNDARY","NODE","NODE_L","NODE_R","REL","BIREL","REL_U","REL_D","REL_L","REL_R","REL_B","REL_INDEX","UPDATE_EL_STYLE","UPDATE_REL_STYLE","UPDATE_LAYOUT_CONFIG","EOF_IN_STRUCT","ATTRIBUTE_EMPTY","STR","STR_KEY","STR_VALUE","LBRACE","RBRACE","EOF"],aB=new Map([["C4Context",14],["C4Container",15],["C4Component",16],["C4Dynamic",17],["C4Deployment",18],["Person",19],["Person_Ext",20],["System",21],["SystemDb",22],["SystemQueue",23],["System_Ext",24],["SystemDb_Ext",25],["SystemQueue_Ext",26],["Container",27],["ContainerDb",28],["ContainerQueue",29],["Container_Ext",30],["ContainerDb_Ext",31],["ContainerQueue_Ext",32],["Component",33],["ComponentDb",34],["ComponentQueue",35],["Component_Ext",36],["ComponentDb_Ext",37],["ComponentQueue_Ext",38],["Enterprise_Boundary",39],["System_Boundary",40],["Boundary",41],["Container_Boundary",42],["Deployment_Node",43],["Node",43],["Node_L",44],["Node_R",45],["Rel",46],["BiRel",47],["Rel_Up",48],["Rel_U",48],["Rel_Down",49],["Rel_D",49],["Rel_Left",50],["Rel_L",50],["Rel_Right",51],["Rel_R",51],["Rel_Back",52],["RelIndex",53],["UpdateElementStyle",54],["UpdateRelStyle",55],["UpdateLayoutConfig",56]]),aW=[/.*direction\s+TB[^\n]*/y,/.*direction\s+BT[^\n]*/y,/.*direction\s+RL[^\n]*/y,/.*direction\s+LR[^\n]*/y],aH=/[\n\r\u2028\u2029]/g,aU=/title[^\S\r\n]*(?=[\r\n]|$)\s*/y,aq=["person","external_person","system","system_db","system_queue","external_system","external_system_db","external_system_queue","container","container_db","container_queue","external_container","external_container_db","external_container_queue","component","component_db","component_queue","external_component","external_component_db","external_component_queue"],aV=["rel","birel","rel_u","rel_d","rel_l","rel_r","rel_b","rel"],aY=["node","nodeL","nodeR"];function aG(t){return t>=19&&t<=56}var aZ=/\s/;function aX(t,r,n,i,a=0){let s=[];for(let o of t.split(`
|
|
62
|
+
`)){let t=Array.from(o);0===t.length&&s.push("");let l=0;for(;l<t.length;){let o=s=>r.width(t.slice(l,l+s).join(""),n,a)<=i,c=1;for(;c<t.length-l&&o(c);)c=Math.min(t.length-l,2*c);let d=1;for(;d<c;){let t=Math.ceil((d+c)/2);o(t)?d=t:c=t-1}let u=d,h=l+u<t.length;if(h&&!aZ.test(t[l+u])){for(let r=u-1;r>0;r--)if(aZ.test(t[l+r])){u=r+1;break}}let f=t.slice(l,l+u).join("");for(s.push(h&&f.trimEnd()||f),l+=u;h&&l<t.length&&aZ.test(t[l]);)l++}}""===t&&(s.length=0);let o=s.map(t=>r.width(t,n,a)),l=0;for(let t of o)l=Math.max(l,t);let c=Math.round(1.5*n);return{lines:s.map((t,r)=>[{text:t,style:a,width:o[r]}]),widths:o,width:l,height:s.length*c,size:n,lineHeight:c}}function aK(t,r,n){if(t.width<=n)return t;let i=[],a=[];for(let s=0;s<t.lines.length;s++){if(t.widths[s]<=n){i.push(t.lines[s]),a.push(t.widths[s]);continue}let o=[],l=0,c=()=>{i.push(o),a.push(l),o=[],l=0};for(let i of t.lines[s]){if(void 0!==i.icon||i.math){o.length&&l+i.width>n&&c(),o.push(i),l+=i.width;continue}for(let a of Array.from(i.text)){let s=o[o.length-1],d=s&&void 0===s.icon&&void 0===s.math&&s.style===i.style,u=r.width(d?s.text+a:a,t.size,i.style)-(d?s.width:0);o.length&&l+u>n&&(c(),s=void 0,u=r.width(a,t.size,i.style)),s&&void 0===s.icon&&void 0===s.math&&s.style===i.style?(s.text+=a,s.width+=u):o.push({text:a,style:i.style,width:u}),l+=u}}(o.length||!t.lines[s].length)&&c()}let s=0;for(let t of a)s=Math.max(s,t);let o={...t,lines:i,widths:a,width:s,height:i.length*t.lineHeight};return t.heights?it(o):o}function aJ(t,r,n,i){let a=eB(t),s="<text"+eW(i,a),o="";for(let l=0;l<t.lines.length;l++){let c=t.lines[l],d=n+(l+.5)*t.lineHeight;if(c.some(t=>void 0!==t.icon)){let n=t.widths[l];o+=eI({...t,lines:[c],widths:[n],width:n,height:t.lineHeight},r+n/2,d,i);continue}let u="";for(let t of c){let r=eF(t.style&~a);u+=r?`<tspan${r}>${eE(t.text)}</tspan>`:eE(t.text)}""!==u&&(o+=`${s} x="${eT(r)}" y="${eT(d+.35*t.size)}" text-anchor="start" xml:space="preserve">${u}</text>`)}return o}var aQ=t=>Math.min(12,Math.max(6,t/14)),a0=t=>Math.min(12,t/4);function a1(t,r,n,i,a,s,o,l){let c=0,d=1;if(0===o){if(a<t||a>n)return 1/0}else{let r=(t-a)/o,i=(n-a)/o;c=Math.max(c,Math.min(r,i)),d=Math.min(d,Math.max(r,i))}if(0===l){if(s<r||s>i)return 1/0}else{let t=(r-s)/l,n=(i-s)/l;c=Math.max(c,Math.min(t,n)),d=Math.min(d,Math.max(t,n))}return c<=d?c:1/0}function a2(t,r,n,i,a,s,o,l){let c=o/n,d=l/i,u=(a-t)/n,h=(s-r)/i,f=c*c+d*d,p=2*(c*u+d*h),g=u*u+h*h-1,m=p*p-4*f*g;if(0===f||m<0)return 1/0;let y=(-p-Math.sqrt(m))/(2*f);return y>=0&&y<=1?y:g<=0?0:1/0}function a4(t,r,n,i,a){let{x:s,y:o,w:l,h:c}=t,d=i-r,u=a-n;if("person"===t.form)return Math.min(a1(s,o+26,s+l,o+c,r,n,d,u),a2(s+l/2,o+14,13,13,r,n,d,u));if("cyl"===t.form){let t=aQ(l);return Math.min(a1(s,o+t,s+l,o+c-t,r,n,d,u),a2(s+l/2,o+t,l/2,t,r,n,d,u),a2(s+l/2,o+c-t,l/2,t,r,n,d,u))}if("h-cyl"===t.form){let t=a0(c);return Math.min(a1(s+t,o,s+l-t,o+c,r,n,d,u),a2(s+t,o+c/2,t,c/2,r,n,d,u),a2(s+l-t,o+c/2,t,c/2,r,n,d,u))}return a1(s,o,s+l,o+c,r,n,d,u)}function a3(t,r,n,i,a){for(let s=2;s<t.length;s+=2){let o=t[s-2],l=t[s-1];if(1>=a1(r,n,i,a,o,l,t[s]-o,t[s+1]-l))return!0}return!1}function a5(t,r){return t.x<=r.x&&t.y<=r.y&&t.x+t.w>=r.x+r.w&&t.y+t.h>=r.y+r.h}var a6=class{upright=[];level=[];frames=[[],[]];taken=new Map;squeezed=0;free(t,r,n,i){let a=Math.min(n,i),s=Math.max(n,i),o=(t,n)=>{for(let i=0;i<t.length;i+=3)if(Math.abs(t[i]-r)<n&&t[i+1]<s&&t[i+2]>a)return!0;return!1};return!o(t?this.upright:this.level,6)&&!o(this.frames[+!t],3)}crossings(t){let r=0;for(let n=2;n<t.length;n+=2){let i=t[n]===t[n-2],a=i?t[n]:t[n+1],s=Math.min(i?t[n-1]:t[n-2],i?t[n+1]:t[n]),o=Math.max(i?t[n-1]:t[n-2],i?t[n+1]:t[n]),l=i?this.level:this.upright;for(let t=0;t<l.length;t+=3)l[t]>s&&l[t]<o&&l[t+1]<a&&l[t+2]>a&&r++}return r}frame(t){this.frames[0].push(t.x,t.y,t.y+t.h,t.x+t.w,t.y,t.y+t.h),this.frames[1].push(t.y,t.x,t.x+t.w,t.y+t.h,t.x,t.x+t.w)}take(t){for(let r=2;r<t.length;r+=2)t[r]===t[r-2]?this.upright.push(t[r],Math.min(t[r-1],t[r+1]),Math.max(t[r-1],t[r+1])):t[r+1]===t[r-1]&&this.level.push(t[r+1],Math.min(t[r-2],t[r]),Math.max(t[r-2],t[r]))}ports(t,r,n,i,a){let s=this.taken.get(t)??[],o=[];for(let t=0;t<9&&o.length<4;t++){let l=n+(1&t?1:-1)*Math.ceil(t/2)*12;if(l<i||l>a)continue;let c=!0;for(let t=0;t<s.length;t+=2)s[t]===r&&12>Math.abs(s[t+1]-l)&&(c=!1);c&&o.push(l)}return o.length?o:[n]}claim(t,r,n){let i=this.taken.get(t);i?i.push(r,n):this.taken.set(t,[r,n])}};function a8(t,r,n,i){for(let a of r)if(a!==n&&a!==i&&a3(t,a.x,a.y,a.x+a.w,a.y+a.h))return!1;return!0}function a9(t,r,n,i,a){let s=t.length;return{d:function(t,r,n){let i=t.length,a=Math.sign(t[2]-t[0]),s=Math.sign(t[3]-t[1]),o=`M${eT(t[0]+a*r)},${eT(t[1]+s*r)}`;for(let r=2;r<i-2;r+=2){let n=t[r],i=t[r+1],a=Math.sign(n-t[r-2]),s=Math.sign(i-t[r-1]),l=Math.sign(t[r+2]-n),c=Math.sign(t[r+3]-i),d=Math.min(8,Math.abs(n-t[r-2]+i-t[r-1])/2,Math.abs(t[r+2]-n+t[r+3]-i)/2);o+=`${a?"H"+eT(n-a*d):"V"+eT(i-s*d)}Q${eT(n)},${eT(i)} ${eT(n+l*d)},${eT(i+c*d)}`}let l=Math.sign(t[i-2]-t[i-4]),c=Math.sign(t[i-1]-t[i-3]);return o+(l?"H"+eT(t[i-2]-l*n):"V"+eT(t[i-1]-c*n))}(t,n,i),sx:t[0],sy:t[1],sdx:-Math.sign(t[2]-t[0]),sdy:-Math.sign(t[3]-t[1]),ex:t[s-2],ey:t[s-1],edx:Math.sign(t[s-2]-t[s-4]),edy:Math.sign(t[s-1]-t[s-3]),x0:t[r],y0:t[r+1],x1:t[r+2],y1:t[r+3],nx:0,ny:0,lean:0,room:160,...a,points:t}}function a7(t,r){let n=[],i=(t+r)/2,a=Math.max(7,(r-t)/4);for(let s=0;s<9;s++){let o=i+(1&s?1:-1)*Math.ceil(s/2)*a;o>=t+6&&o<=r-6&&n.push(o)}return n}var se=new Map([["person","person"],["box","rect"],["rounded","rect"],["component","rect"],["cylinder","cyl"],["database","cyl"],["db","cyl"],["queue","h-cyl"],["pipe","h-cyl"]]);function st(t,r,n,i,a){let s=0,o=0;for(let l=0;l<t.length;l+=r){let c=Math.min(t.length,l+r),d=0,u=0;for(let r=l;r<c;r++)u=Math.max(u,t[r].h);for(let r=l;r<c;r++){let i=t[r];i.x=d,i.y=o,a&&(i.h=u),d+=i.w+n}s=Math.max(s,d-n),o+=u+i}return[s,t.length>0?o-i:0]}var sr=[.5,.4,.6,.3,.7,.2,.8];function sn(t,r,n){let i=[];return t&&i.push("fill:"+t),r&&i.push("stroke:"+r),n&&i.push("color:"+n),no(i)}function si(t,r,n,i,a){return r?tI(t,tx(r.includes("\xb6\xdf")?r.replace(/\ufb02\u00b0\u00b0?/g,"#").replace(/\u00b6\u00df/g,";"):r),n,i,a):t}function sa(t,r,n,i,s=36){let o=n.fontSize??16,l=Math.round(.8125*o),c=n.measurer??e$(n.fontFamily,n.fontFamilyMono),d=n.padding??8,u=[],{order:h,boxes:f}=function(t,r,n,i,a,s){let o=void 0===a?28:12,l=new Map;for(let s of t.boundaries){let t=void 0===a?4e3:Math.max(80,a-32-112),c=s.parent?[n7(s.label,!1,r,n,t,1),n7(s.type?`[${s.type}]`:void 0,!1,r,i,t),n7(s.descr,!1,r,i,t)]:[],d=0,u=0;for(let t of c)d+=t.height,u=Math.max(u,t.width);l.set(s,{boundary:s,kids:[],nodes:[],labels:c,head:d>0?d+10+6+20:o,headW:u,headX:16,x:0,y:0,w:0,h:0,form:"rect"})}let c=l.get(t.boundaries[0]);for(let t of l.values()){let r=t.boundary.parent;r&&l.get(r)?.kids.push(t)}let d=[c],u=new Map([[c.boundary,0]]);for(let t=0;t<d.length;t++)for(let r of d[t].kids)u.set(r.boundary,u.get(d[t].boundary)+1),d.push(r);for(let s of t.shapes)if(s.parent){let t=u.get(s.parent)??0,c=void 0===a?216:Math.max(100,Math.min(216,a-2*t*o-32));l.get(s.parent)?.nodes.push(function(t,r,n,i,a=216){let s=function(t){let r=se.get((t.shape??"").toLowerCase())??se.get((t.sprite??"").toLowerCase());if(r)return r;if(t.tags)for(let r of t.tags.split(",")){let t=se.get(r.trim().toLowerCase());if(t)return t}let n=t.kind;return n.endsWith("person")?"person":n.endsWith("_db")?"cyl":n.endsWith("_queue")?"h-cyl":"rect"}(t),o=36*("h-cyl"===s),l=a-28-o,c=[n7("\xab"+t.kind.replace(/_/g," ")+"\xbb",!1,r,i-1,l),n7(t.label,!1,r,n,l,1),n7(t.techn?`[${t.techn}]`:void 0,!1,r,i,l),n7(t.descr,!1,r,i,l)],d=0,u=4*(c[3].height>0);for(let t of c)d=Math.max(d,t.width),u+=t.height;return{shape:t,form:s,labels:c,textH:u,x:0,y:0,w:Math.max(a,d+28+o),h:Math.max(64,u+24+("person"===s?26:24*("cyl"===s)))}}(s,r,n,i,c))}let h=Math.max(1,t.shapeInRow),f=Math.max(1,t.boundaryInRow),p=new Map;for(let t=d.length-1;t>=0;t--){let r=d[t],n=void 0===a?120:s,i=(t,r,n)=>{if(void 0===a)return r;let i=1;for(let r of t)i=Math.max(i,r.w);return Math.max(1,Math.min(r,Math.floor((a+n-2*o)/(i+n))))},[l,u]=st(r.nodes,i(r.nodes,h,n),n,88,!0),[g,m]=st(r.kids,i(r.kids,f,48),48,48,!1),y=48*(u>0&&m>0),v=r===c?0:o;p.set(r,u+y),r.w=Math.max(l,g,r.headW+32-2*v)+2*v,r.h=(v&&r.head)+u+y+m+v}let g=new Map;for(let t of d){let r=t.x+(t===c?0:o),n=t.y+(t===c?0:t.head);for(let i of t.nodes)i.x+=r,i.y+=n,g.set(i.shape,i);for(let i of t.kids)i.x+=r,i.y+=n+p.get(t);t!==c&&g.set(t.boundary,t)}return{order:d,boxes:g}}(t,c,o,l,i?Math.max(80,(n.maxWidth??320)-2*d):void 0,s),p=h[0],g=0,m=0,y=p.w,v=p.h,b=(t,r,n,i)=>{g=Math.min(g,t),m=Math.min(m,r),y=Math.max(y,n),v=Math.max(v,i)},x=[],w=new Map;for(let r of t.rels){let n=r.fromAttr?void 0:t.getC4Shape(r.from),i=r.toAttr?void 0:t.getC4Shape(r.to),s=n&&f.get(n),o=i&&f.get(i);if(!s||!o)throw new a(`C4 rel "${r.from}" -> "${r.to}" references an unknown shape or boundary`,"semantic",{type:"c4"});x.push(s,o);let l=w.get(s);l||w.set(s,l=new Set),l.add(o)}let $=[],k=[];for(let t of h)for(let r of t.nodes)$.push(r),k.push(r.x+8,r.y+8,r.x+r.w-8,r.y+r.h-8);let M=t.rels.length*($.length+h.length+3*t.rels.length)<=2e6,_=(t,r,n,i)=>{let a=0;for(let s=0;s<k.length;s+=4){let o=Math.min(n,k[s+2])-Math.max(t,k[s]);if(o<=0)continue;let l=Math.min(i,k[s+3])-Math.max(r,k[s+1]);l>0&&(a+=o*l)}return a},A=t=>t?Math.max(-2e3,Math.min(2e3,t)):0,E="",S="",C=rq("arrow_point"),T=[];for(let t of h){if(t===p)continue;let r=sn(t.boundary.bgColor,void 0,void 0).shape;e6(r)&&T.push({box:[t.x,t.y,t.x+t.w,t.y+t.h],shape:r})}let I=new a6;for(let t of h)t!==p&&I.frame(t);let N=t.rels.map((t,r)=>{let n=x[2*r],i=x[2*r+1],a=sn(void 0,t.lineColor,void 0),s="birel"===t.type||"rel_b"===t.type,o="rel_b"!==t.type,l=n!==i&&w.get(i)?.has(n)===!0,c=function(t,r,n,i,a,s,o){if(t===r){let r=Math.min(t.h/2-4,10),n=Math.hypot(28,r),i=t.x+t.w,a=t.y+t.h/2,l=28/n,c=r/n;return{d:`M${eT(i+l*s)},${eT(a-r-c*s)}C${eT(i+28)},${eT(a-2*r)} ${eT(i+28)},${eT(a+2*r)} ${eT(i+l*o)},${eT(a+r+c*o)}`,sx:i,sy:a-r,sdx:-l,sdy:c,ex:i,ey:a+r,edx:-l,edy:-c,x0:i+28+4,y0:a,x1:i+28+4,y1:a,nx:1,ny:0,lean:0,room:64,points:[]}}let[l,c,d,u]=function(t,r,n){let i=t.x+t.w/2,a=t.y+t.h/2,s=r.x+r.w/2,o=r.y+r.h/2,l=a5(t,r);if(l||a5(r,t)){let n=l?t:r,i=l?r:t,a=i.x+i.w/2,s=i.y+i.h/2,o=i.x-n.x,c=n.x+n.w-i.x-i.w,d=i.y-n.y,u=n.y+n.h-i.y-i.h,h=Math.min(o,c,d,u),f=h===o?n.x:h===c?n.x+n.w:a,p=h===o||h===c?s:h===u?n.y+n.h:n.y,g=Math.min(a4(i,f,p,a,s),1),m=f+(a-f)*g,y=p+(s-p)*g;return l?[f,p,m,y]:[m,y,f,p]}let c=i,d=a,u=s,h=o,f=Math.max(t.x,r.x),p=Math.min(t.x+t.w,r.x+r.w),g=Math.max(t.y,r.y),m=Math.min(t.y+t.h,r.y+r.h);f<p?c=u=(f+p)/2:g<m&&(d=h=(g+m)/2);let y=Math.hypot(u-c,h-d)||1,v=-(h-d)/y*n,b=(u-c)/y*n,x=a4(t,u+v,h+b,c+v,d+b),w=a4(r,c+v,d+b,u+v,h+b);return x<=1&&w<=1?(c+=v,d+=b,u+=v,h+=b):(c=i,d=a,x=Math.min(a4(t,u=s,h=o,c,d),1),w=Math.min(a4(r,c,d,u,h),1)),[u+(c-u)*x,h+(d-h)*x,c+(u-c)*w,d+(h-d)*w]}(t,r,n),h=l===d,f=!1;if(i&&!a5(t,r)&&!a5(r,t))for(let n of i)n!==t&&n!==r&&1>=a1(n.x,n.y,n.x+n.w,n.y+n.h,l,c,d-l,u-c)&&(f=!0);if(i&&f&&!h&&c!==u){let n=function(t,r,n,i,a,s){let o=t.x+t.w/2,l=t.y+t.h/2,c=r.x+r.w/2,d=r.y+r.h/2,u,h=(a,s,o)=>{if(!a8(a,n,t,r))return;for(let t=2;t<a.length;t+=2){let r=a[t]===a[t-2];if(!i.free(r,r?a[t]:a[t+1],r?a[t-1]:a[t-2],r?a[t+1]:a[t]))return}let l=1e6*i.crossings(a);for(let t=2;t<a.length;t+=2)l+=Math.abs(a[t]-a[t-2])+Math.abs(a[t+1]-a[t-1]);(!u||l<u.cost)&&(u={points:a,cost:l,upright:s,sides:o})};if(t.x+t.w<=r.x||r.x+r.w<=t.x){let n=c>o,a=Math.sign(d-l),s=n?[1,0]:[0,1],f=a7(n?t.x+t.w:r.x+r.w,n?r.x:t.x);t:for(let n of i.ports(t,s[0],l+a*t.h/4,t.y+8,t.y+t.h-8))for(let l of i.ports(r,s[1],d-a*r.h/4,r.y+8,r.y+r.h-8))for(let i of f){let a=i+(o-i)*Math.min(a4(t,i,n,o,n),1),d=i+(c-i)*Math.min(a4(r,i,l,c,l),1),f=u;if(h([a,n,i,n,i,l,d,l],!0,s),u!==f)break t}}if(t.y+t.h<=r.y||r.y+r.h<=t.y){let n=d>l,a=Math.sign(c-o),s=n?[3,2]:[2,3],f=a7(n?t.y+t.h:r.y+r.h,n?r.y:t.y);t:for(let n of i.ports(t,s[0],o+a*t.w/4,t.x+8,t.x+t.w-8))for(let o of i.ports(r,s[1],c-a*r.w/4,r.x+8,r.x+r.w-8))for(let i of f){let a=i+(l-i)*Math.min(a4(t,n,i,n,l),1),c=i+(d-i)*Math.min(a4(r,o,i,o,d),1),f=u;if(h([n,a,n,i,o,i,o,c],!1,s),u!==f)break t}}if(!u)return;let{points:f,upright:p,sides:g}=u;return i.take(f),i.claim(t,g[0],p?f[1]:f[0]),i.claim(r,g[1],p?f[7]:f[6]),a9(f,2,a,s,{room:p?88:160})}(t,r,i,a,s,o);if(n)return n;a.squeezed++}if(i&&f&&(h||c===u)){let n=n=>{let a=n?-1/0:1/0,s=t=>{let r=h?t.x:t.y;a=n?Math.max(a,r+(h?t.w:t.h)):Math.min(a,r)};for(let n of(s(t),s(r),i))n!==t&&n!==r&&1>=a1(n.x,n.y,n.x+n.w,n.y+n.h,l,c,d-l,u-c)&&s(n);return a},f=h?Math.min(t.y,r.y):Math.min(t.x,r.x),p=h?Math.max(t.y+t.h,r.y+r.h):Math.max(t.x+t.w,r.x+r.w),g=(n,a)=>{for(let s of i){if(s===t||s===r)continue;let i=h?s.y<p&&s.y+s.h>f:s.x<p&&s.x+s.w>f,o=h?s.x:s.y,l=o+(h?s.w:s.h);if(i&&(n?l>a:o<a))return!1}return!0},m=t.x+t.w/2,y=t.y+t.h/2,v=r.x+r.w/2,b=r.y+r.h/2,x=Math.sign(h?b-y:v-m),w=s=>{let o=n(s),l=s?1:-1,c=h?+!!s:s?3:2,d=h?a.ports(t,c,y+x*t.h/4,t.y+8,t.y+t.h-8)[0]:a.ports(t,c,m+x*t.w/4,t.x+8,t.x+t.w-8)[0],u=h?a.ports(r,c,b-x*r.h/4,r.y+8,r.y+r.h-8)[0]:a.ports(r,c,v-x*r.w/4,r.x+8,r.x+r.w-8)[0],f=n=>{if(h){let i=n+(m-n)*Math.min(a4(t,n,d,m,d),1),a=n+(v-n)*Math.min(a4(r,n,u,v,u),1);return[i,d,n,d,n,u,a,u]}let i=n+(y-n)*Math.min(a4(t,d,n,d,y),1),a=n+(b-n)*Math.min(a4(r,u,n,u,b),1);return[d,i,d,n,u,n,u,a]},p=f(o+20*l);for(let n=0;n<=4;n++){let s=o+l*(20+7*n),g=f(s);if(a8(g,i,t,r)&&(p=g,a.free(h,s,d,u)))return{points:p,side:c,p0:d,p1:u,step:n}}return{points:p,side:c,p0:d,p1:u,step:5}},$=h?u>c:d<l,k=g($,n($)),M=g(!$,n(!$)),_=w($),A=k===M?w(!$):void 0,E=t=>8*a.crossings(t.points)+t.step,S=M&&!k||A&&E(A)<E(_)?!$:$,{points:C,side:T,p0:I,p1:N,step:O}=S===$?_:A??w(!$);return O>4&&a.squeezed++,a.take(C),a.claim(t,T,I),a.claim(r,T,N),a9(C,2,s,o,h?{nx:S?1:-1,lean:30,room:88}:{room:160})}let p=Math.hypot(d-l,u-c)||1,g=(d-l)/p,m=(u-c)/p;return(h||c===u)&&a.take([l,c,d,u]),{d:`M${eT(l+g*s)},${eT(c+m*s)}L${eT(d-g*o)},${eT(u-m*o)}`,sx:l,sy:c,sdx:-g,sdy:-m,ex:d,ey:u,edx:g,edy:m,x0:l,y0:c,x1:d,y1:u,nx:n?-m:0,ny:n?g:0,lean:0,room:Math.abs(g)>Math.abs(m)?88:160,points:[l,c,d,u]}}(n,i,7*!!l,M?$:void 0,I,s?C:0,o?C:0);b(Math.min(c.x0,c.x1),Math.min(c.y0,c.y1),Math.max(c.x0,c.x1),Math.max(c.y0,c.y1)),s&&M&&k.push(c.sx-8,c.sy-8,c.sx+8,c.sy+8),o&&M&&k.push(c.ex-8,c.ey-8,c.ex+8,c.ey+8);let d=rJ(c.d,[c.sx,c.sy,c.ex,c.ey],T,a.line),u=d||(a.stroke?eE(a.stroke):"var(--_l)");return""===d&&(E+=r0(c,s?"arrow_point":"none",o?"arrow_point":"none",a.line)),S+=`<g class="pele-edge" data-id="${eS(t.from+"-"+t.to)}"${d?` stroke="${d}"`:""}${a.line}><path d="${c.d}"/>`+(s?rV("arrow_point",c.sx,c.sy,c.sdx,c.sdy,u):"")+(o?rV("arrow_point",c.ex,c.ey,c.edx,c.edy,u):"")+"</g>",c});for(let t of h){if(!M||0===t.headW)continue;let r=t.y+10,n=t.y+t.head-20,i=1/0;for(let a of[16,(t.w-t.headW)/2,t.w-16-t.headW]){let s=0;for(let i of N)a3(i.points,t.x+a-4,r,t.x+a+t.headW+4,n)&&s++;if(s<i&&(i=s,t.headX=a),0===s)break}k.push(t.x+t.headX-4,r,t.x+t.headX+t.headW+4,n)}let O="";t.rels.forEach((r,a)=>{let s=N[a],o=r.from+"-"+r.to,d=sn(void 0,void 0,r.textColor),h=n7(("C4Dynamic"===t.c4Type?a+1+": ":"")+r.label,!1,c,l,s.room),f=n7(r.techn?`[${r.techn}]`:void 0,!1,c,l,s.room,2),p=Math.max(h.width,f.width)+8,g=h.height+f.height;if(0===g)return;let m=Math.abs(s.nx)*(p/2)+Math.abs(s.ny)*(g/2)+2,y=s.lean?Math.max(0,Math.min(s.lean,m-14)):m,v=s.nx*y+(i?0:A(r.offsetX)),x=s.ny*y+(i?0:A(r.offsetY)),w=.5;if(M){let t=1/0,r=v!==s.nx*y||x!==s.ny*y;for(let n=0;n<(r?2:1)&&t>0;n++){let r=n?s.nx*y:v,i=n?s.ny*y:x;for(let n of sr){let a=s.x0+(s.x1-s.x0)*n+r,o=s.y0+(s.y1-s.y0)*n+i,l=_(a-p/2,o-g/2,a+p/2,o+g/2);if(l<t&&(t=l,w=n,v=r,x=i),0===l)break}}}let $=s.x0+(s.x1-s.x0)*w+v,E=s.y0+(s.y1-s.y0)*w+x-g/2;M&&k.push($-p/2,E,$+p/2,E+g),b($-p/2,E,$+p/2,E+g),O+=`<g class="pele-edge-label" data-id="${eS(o)}">`+(r.descr?`<title>${eS(r.descr)}</title>`:"")+`<rect x="${eT($-p/2)}" y="${eT(E)}" width="${eT(p)}" height="${eT(g)}" rx="3" fill="var(--_bg)"/>`+si(eI(h,$,E+h.height/2,d.text)+eI(f,$,E+h.height+f.height/2,` class="pele-c4-techn" fill="var(--_m)"${d.text}`),r.link,o,u,n)+"</g>"});let D="",R="";for(let t of h){if(t!==p){let r=t.boundary,i=sn(r.bgColor,r.borderColor,r.fontColor),a=t.x+t.headX,s=t.y+10,o=e8(i)+i.text,c=e8(i,"var(--_m)")+i.text,d=aJ(t.labels[0],a,s,` class="pele-cluster-label" font-weight="var(--_hw)"${o}`);s+=t.labels[0].height,d+=aJ(t.labels[1],a,s,` class="pele-c4-type" font-size="${l}"${c}`),s+=t.labels[1].height,d+=aJ(t.labels[2],a,s,` class="pele-c4-descr" font-size="${l}"${c}`),D+=`<g class="pele-cluster pele-c4-${r.nodeType?"node":"boundary"}" data-id="${eS(r.alias)}"><rect x="${eT(t.x)}" y="${eT(t.y)}" width="${eT(t.w)}" height="${eT(t.h)}" fill="none" stroke="var(--_b)"${r.nodeType?"":' stroke-dasharray="6 4"'}${r9(i.shape)}/>`+si(d,r.link,r.alias,u,n)+"</g>"}for(let r of t.nodes){let t=r.shape,i=t.kind.startsWith("external"),a=sn(t.bgColor,t.borderColor,t.fontColor),s=' stroke="var(--_b)"'+(i?' stroke-dasharray="4 3"':""),{w:o,h:c,form:d,labels:h}=r,f="h-cyl"===d?-a0(c)/2:0,p="person"===d?13:"cyl"===d?aQ(o)/2:0,g=e8(a)+a.text,m=e8(a,"var(--_m)")+a.text,y=p-r.textH/2,v=eI(h[0],f,y+h[0].height/2,` class="pele-c4-type" font-size="${l-1}"${m}`);y+=h[0].height,v+=eI(h[1],f,y+h[1].height/2,` class="pele-label" font-weight="var(--_hw)"${g}`),y+=h[1].height,v+=eI(h[2],f,y+h[2].height/2,` class="pele-c4-techn" font-size="${l}"${m}`),y+=h[2].height+4,v+=eI(h[3],f,y+h[3].height/2,` class="pele-c4-descr" font-size="${l}"${g}`),R+=`<g class="pele-node pele-shape-${d} pele-c4-${t.kind}${i?" pele-c4-external":""}" data-id="${eS(t.alias)}" transform="translate(${eT(r.x+o/2)},${eT(r.y+c/2)})">`+si(nD(d,o,c,` fill="var(${i?"--_bg":"--_s"})"${s}${a.shape}`,s+a.line)+v,t.link,t.alias,u,n)+"</g>"}}let L=n7(t.title,!1,c,o,i?io(n):4e3,1),z=L.height>0?L.height+12:0,P=Math.max(y-g,L.width),j=Math.ceil(P+2*d),F=Math.ceil(v-m+z+2*d),B=d-g+(P-(y-g))/2,W=d+z-m;return[{svg:np("c4",j,F,o,n,t,eI(L,j/2,d+L.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${eT(B)},${eT(W)})">`+(D?`<g class="pele-clusters">${D}</g>`:"")+r1(E)+(S?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${S}</g>`:"")+(R?`<g class="pele-nodes">${R}</g>`:"")+(O?`<g class="pele-edge-labels" font-size="${l}">${O}</g>`:"")+"</g>"),width:j,height:F,links:u},I.squeezed]}function ss(t){let r=0;for(let n=t.indexOf("~");-1!==n;n=t.indexOf("~",n+1))r++;return r}function so(t){if(!t.includes("~"))return t;let r=t.split(/(,)/),n=[];for(let t=0;t<r.length;t++){let i=r[t];","===i&&t>0&&t+1<r.length&&1===ss(r[t-1])&&1===ss(r[t+1])&&(i=r[t-1]+","+r[t+1],t++,n.pop()),n.push(function(t){let r=ss(t);if(r<=1)return t;let n=r%2!=0&&t.startsWith("~"),i=t.split(""),a=[];for(let t=+!!n;t<i.length;t++)"~"===i[t]&&a.push(t);for(let t=0,r=a.length-1;t<r;t++,r--)i[a[t]]="<",i[a[r]]=">";return i.join("")}(i))}return n.join("")}function sl(t){return"#"===t||"+"===t||"~"===t||"-"===t}var sc=class{id="";memberType;visibility="";classifier="";parameters="";returnType="";constructor(t,r){this.memberType=r,"method"===r&&this.parseMethod(t)||this.parseAttribute(t),this.id=this.id.startsWith(" ")?" "+this.id.trim():this.id.trim()}parseMethod(t){let r=t.length;for(let n=0;n<r;){let i=n;for(;i<r&&!G(t.charCodeAt(i));)i++;let a=i-1;for(;a>n&&41!==t.charCodeAt(a);)a--;let s=a-1;for(;s>n&&40!==t.charCodeAt(s);)s--;if(s>n){let i=t[n],o=sl(i)&&s>n+1;o&&(this.visibility=i),this.id=t.slice(o?n+1:n,s),this.parameters=t.slice(s+1,a).trim();let l=a+1,c="";if(l<r){let r=t[l];("$"===r||"*"===r||""===r.trim())&&(c=r.trim(),l++)}let d=l;for(;d<r&&!G(t.charCodeAt(d));)d++;if(this.returnType=t.slice(l,d).trim(),""===c){let t=this.returnType.slice(-1);("$"===t||"*"===t)&&(c=t,this.returnType=this.returnType.slice(0,-1))}return this.classifier=c,!0}n=i+1}return this.memberType="attribute",!1}parseAttribute(t){let r=t.slice(0,1),n=t.slice(-1);sl(r)&&(this.visibility=r),("$"===n||"*"===n)&&(this.classifier=n),this.id=t.substring(+(""!==this.visibility),""===this.classifier?t.length:t.length-1)}getDisplayDetails(){let t=this.visibility+so(this.id);return"method"===this.memberType&&(t+=`(${so(this.parameters.trim())})`,this.returnType&&(t+=" : "+so(this.returnType))),{displayText:t.trim(),cssStyle:this.parseClassifier()}}parseClassifier(){return"*"===this.classifier?"font-style:italic;":"$"===this.classifier?"text-decoration:underline;":""}},sd={LINE:0,DOTTED_LINE:1},su={AGGREGATION:0,EXTENSION:1,COMPOSITION:2,DEPENDENCY:3,LOLLIPOP:4};function sh(t){let r=t.indexOf("~");if(r<=0)return{className:t,type:""};let n=t.indexOf("~",r+1);return{className:t.slice(0,r),type:t.slice(r+1,-1===n?t.length:n)}}function sf(t){let r=t.charCodeAt(0);return sh(r>=48&&r<=57?"classId-"+t:t).className}var sp=class{type="class";lineType=sd;relationType=su;direction="TB";classes=new Map;relations=[];notes=new Map;namespaces=new Map;interfaces=[];styleClasses=new Map;title;accTitle;accDescr;namespaceStack=[];withCssClass=new Map;addClass(t){let{className:r,type:n}=sh(t);if(this.classes.has(r))return;let i={id:r,type:n,label:r,cssClasses:"default",methods:[],members:[],annotations:[],styles:[]};this.classes.set(r,i),this.tag(i,"default")}tag(t,r){let n=this.withCssClass.get(r);n?n.add(t):this.withCssClass.set(r,new Set([t]))}ensure(t){return this.addClass(t),this.classes.get(sh(t).className)}setClassLabel(t,r){this.ensure(t).label=r}addRelation(t){let{type1:r,type2:n}=t.relation;r===su.LOLLIPOP&&"none"===n?(this.addClass(t.id2),t.id1=this.addInterface(t.id1,t.id2)):n===su.LOLLIPOP&&"none"===r?(this.addClass(t.id1),t.id2=this.addInterface(t.id2,t.id1)):(this.addClass(t.id1),this.addClass(t.id2)),t.id1=sh(t.id1).className,t.id2=sh(t.id2).className,t.relationTitle1=t.relationTitle1.trim(),t.relationTitle2=t.relationTitle2.trim(),this.relations.push(t)}addInterface(t,r){let n=`interface${this.interfaces.length}`;return this.interfaces.push({id:n,label:t,classId:r}),n}addAnnotation(t,r){this.ensure(t).annotations.push(r)}addMember(t,r){let n=this.ensure(t);if("string"!=typeof r)return;let i=r.trim();if(i.startsWith("<<")&&i.endsWith(">>"))n.annotations.push(i.substring(2,i.length-2));else if(i.indexOf(")")>0){let t=new sc(i,"method");("method"===t.memberType?n.methods:n.members).push(t)}else i&&n.members.push(new sc(i,"attribute"))}addMembers(t,r){if(Array.isArray(r))for(let n of(r.reverse(),r))this.addMember(t,n)}addNote(t,r){let n=this.notes.size,i=`note${n}`;return this.notes.set(i,{id:i,class:r,text:t,index:n}),i}cleanupLabel(t){return(t.startsWith(":")?t.substring(1):t).trim()}setCssClass(t,r){for(let n of t.split(",")){let t=this.classes.get(sf(n));if(void 0!==t)for(let n of(t.cssClasses+=" "+r,r.split(" ")))this.tag(t,n)}}defineClass(t,r){for(let n of t){let t=this.styleClasses.get(n);if(void 0===t&&(t={id:n,styles:[],textStyles:[]},this.styleClasses.set(n,t)),!r)continue;for(let n of r)n.includes("color")&&t.textStyles.push(n.replace("fill","bgFill")),t.styles.push(n);let i=this.withCssClass.get(n);if(void 0===i)continue;let a=r.flatMap(t=>t.split(","));for(let t of i)for(let r of a)t.styles.push(r)}}setTooltip(t,r){if(void 0!==r)for(let n of t.split(",")){let t=this.classes.get(sh(n).className);t&&(t.tooltip=r)}}setLink(t,r,n){let i=y(r).trim();for(let r of t.split(",")){let t=this.classes.get(sf(r));t&&(t.link=i?tx(i):void 0,t.linkTarget="string"==typeof n?n:"_blank")}this.setCssClass(t,"clickable")}setClickEvent(t,r,n){for(let r of t.split(",")){let t=this.classes.get(sh(r).className);t&&(t.haveCallback=!0)}this.setCssClass(t,"clickable")}setDirection(t){this.direction=t}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
|
|
63
|
+
`)}addNamespace(t,r){let n=this.namespaceStack[this.namespaceStack.length-1],i=n?`${n}.${t}`:t;this.namespaceStack.push(i);let a=this.namespaces.get(i);if(a)return a.explicit=!0,r&&(a.label=r),i;let s=n||void 0,o=n?n.length+1:0;for(;;){let t=i.indexOf(".",o),n=-1===t,a=n?i:i.slice(0,t),l=this.namespaces.get(a);if(void 0===l){let c=i.slice(o,n?i.length:t);l={id:a,label:n&&r?r:c,classes:new Map,notes:new Map,children:new Map,parent:s,explicit:n},this.namespaces.set(a,l)}else n&&(l.explicit=!0);let c=s?this.namespaces.get(s):void 0;if(c&&(c.children.has(a)||c.children.set(a,l),l.parent??=s),n)return i;s=a,o=t+1}}popNamespace(){this.namespaceStack.pop()}addClassesToNamespace(t,r,n){let i=this.namespaces.get(t);if(void 0!==i){for(let n of r){let{className:r}=sh(n),a=this.classes.get(r);void 0!==a&&(a.parent=t,i.classes.set(r,a))}for(let r of n){let n=this.notes.get(r);void 0!==n&&(n.parent=t,i.notes.set(r,n))}}}setCssStyle(t,r){let n=this.classes.get(t);if(!(!r||!n))for(let t of r)for(let r of t.split(","))n.styles.push(r)}},sg=["$end","INVALID","CLASS_DIAGRAM","NEWLINE","EOF","SQS","STR","SQE","DOT","GENERICTYPE","LABEL","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","STRUCT_START","STRUCT_STOP","NAMESPACE","STYLE_SEPARATOR","ANNOTATION_START","ANNOTATION_END","CLASS","MEMBER","NOTE_FOR","NOTE","CLASSDEF","ALPHA","COMMA","direction_tb","direction_bt","direction_rl","direction_lr","AGGREGATION","EXTENSION","COMPOSITION","DEPENDENCY","LOLLIPOP","LINE","DOTTED_LINE","CALLBACK","LINK","LINK_TARGET","CLICK","CALLBACK_NAME","CALLBACK_ARGS","HREF","STYLE","CSSCLASS","COLON","BRKT","PCT","MINUS","UNICODE_TEXT","BQUOTE_STR","EDGE_STATE","EOF_IN_STRUCT","OPEN_IN_STRUCT","PLUS","EQUALS","PUNCTUATION"],sm=[4,6,4,9,44,45,12,14,15,4,56,4,56],sy=[/.*direction\s+TB[^\n]*/y,/.*direction\s+BT[^\n]*/y,/.*direction\s+RL[^\n]*/y,/.*direction\s+LR[^\n]*/y],sv=/[\n\r\u2028\u2029]/g,sb=new Uint8Array(61);for(let t of[53,27,52])sb[t]=1;var sx=new Uint8Array(61);for(let t of[27,49,50,47,51,10])sx[t]=1;var sw=new Uint8Array(61);sw[33]=1,sw[34]=2,sw[35]=3,sw[36]=4,sw[37]=5;var s$=["aggregation","extension","composition","dependency","lollipop"];function sk(t){return"number"==typeof t&&s$[t]||"none"}function sM(t){switch(t){case"extension":return 12;case"composition":case"aggregation":return 16;case"lollipop":return 10;case"dependency":return rq("arrow_point")}return 0}function s_(t,r,n,i,a,s){let o=-a;switch(t){case"extension":{let t=r-12*i,s=n-12*a;return`<path class="pele-marker" d="M${eT(r)},${eT(n)}L${eT(t+6*o)},${eT(s+6*i)}L${eT(t-6*o)},${eT(s-6*i)}Z" stroke-linejoin="round"/>`}case"composition":case"aggregation":{let l=r-16*i/2,c=n-16*a/2;return`<path class="pele-marker" d="M${eT(r)},${eT(n)}L${eT(l+5*o)},${eT(c+5*i)}L${eT(r-16*i)},${eT(n-16*a)}L${eT(l-5*o)},${eT(c-5*i)}Z" stroke-linejoin="round"${"composition"===t?` fill="${s}"`:""}/>`}case"lollipop":return`<circle class="pele-marker" cx="${eT(r-5*i)}" cy="${eT(n-5*a)}" r="5"/>`;case"dependency":return rV("arrow_point",r,n,i,a,s)}return""}var sA="var(--_l)",sE=new Set(["_self","_blank","_parent","_top"]);function sS(t,r,n){let i=t[r];return"number"==typeof i&&i>0?Math.min(i,2e3):n}var sC=[],sT=[];function sI(t,r,n,i){let a=y(t.getDisplayDetails().displayText).trim(),s=2*("*"===t.classifier)|4*!!i;return{text:a,width:r.width(a,n,s),classifier:t.classifier}}var sN=class{domains=new Map;transitions=[];setDomains(t){if(t)for(let r of t){let t=r.domain;this.domains.set(t,{name:t,items:(r.items??[]).map(t=>({label:t.label}))})}}setTransitions(t){t&&(this.transitions=t.filter(t=>t.from!==t.to).map(t=>({from:t.from,to:t.to,label:t.label||void 0})))}},sO=[{name:"cynefin-beta:",pattern:"cynefin-beta:"},iP("cynefin-beta"),{name:"--\x3e",pattern:"--\x3e"},{name:":",pattern:":"},{name:"DOMAIN_NAME",pattern:/complex|complicated|clear|chaotic|confusion/y},iS,iC,iT,iN,iO,iD,iR,iL,iz];function sD(t){let r=t+0x6d2b79f5|0;return r=Math.imul(r^r>>>15,1|r),(((r^=r+Math.imul(r^r>>>7,61|r))^r>>>14)>>>0)/0x100000000}var sR={segments:7,vertical:!0,pointStep:17,controlStep:31,controlShift:7},sL={segments:7,vertical:!1,pointStep:23,controlStep:37,controlShift:11};function sz(t,r,n,i,a,s){let o=(r-t)/s.segments,l=[],c=[];for(let r=0;r<=s.segments;r++){let d=0===r&&s.pinStart||r===s.segments&&s.pinEnd;l.push(t+r*o),c.push(d?n:n+sD(i+r*s.pointStep)*a*2-a)}let d=s.vertical?[c[0],l[0]]:[l[0],c[0]];for(let t=0;t<s.segments;t++){let r=(l[t]+l[t+1])/2,n=1.5*a*(t%2==0?1:-1)*sD(i+t*s.controlStep+s.controlShift);s.vertical?d.push(c[t]+n,r,c[t+1]-n,r,c[t+1],l[t+1]):d.push(r,c[t]+n,r,c[t+1]-n,l[t+1],c[t+1])}return d}function sP(t){let r="";for(let n=2;n<t.length;n+=6)r+=`C${eT(t[n])},${eT(t[n+1])} ${eT(t[n+2])},${eT(t[n+3])} ${eT(t[n+4])},${eT(t[n+5])}`;return r}function sj(t){let r="";for(let n=t.length-6;n>=2;n-=6)r+=`C${eT(t[n+2])},${eT(t[n+3])} ${eT(t[n])},${eT(t[n+1])} ${eT(t[n-2])},${eT(t[n-1])}`;return r}function sF(t){return`M${eT(t[0])},${eT(t[1])}${sP(t)}`}var sB=[["complex",0,0,0],["complicated",1,0,1],["chaotic",0,1,3],["clear",1,1,2]],sW=new Map([["complex",["Complex","Probe → Sense → Respond","Emergent Practices"]],["complicated",["Complicated","Sense → Analyse → Respond","Good Practices"]],["clear",["Clear","Sense → Categorise → Respond","Best Practices"]],["chaotic",["Chaotic","Act → Sense → Respond","Novel Practices"]],["confusion",["Confusion","","Disorder"]]]);function sH(t,r,n,i,a){let s=t.cynefin?.[r];return"number"==typeof s&&s>=i&&s<=a?s:n}var sU=class{type="er";direction="TB";entities=new Map;relationships=[];classes=new Map;subgraphs=[];title;accTitle;accDescr;subgraphLookup=new Map;claimed=new Set;addEntity(t,r=""){let n=this.entities.get(t);return void 0===n?(n={id:`entity-${t}-${this.entities.size}`,label:t,alias:r,attributes:[],cssClasses:"default",cssStyles:[]},this.entities.set(t,n)):!n.alias&&r&&(n.alias=r),n}addAttributes(t,r){let n=this.addEntity(t);for(let t=r.length-1;t>=0;t--){let i=r[t];i.keys??=[],i.comment??="",n.attributes.push(i)}}addRelationship(t,r,n,i){let a=this.subgraphLookup.has(t)?t:this.addEntity(t).id,s=this.subgraphLookup.has(n)?n:this.addEntity(n).id;this.relationships.push({entityA:a,roleA:r,entityB:s,relSpec:i})}setDirection(t){this.direction=t}addCssStyles(t,r){if(r)for(let n of t){let t=this.entities.get(n);if(t)for(let n of r)t.cssStyles.push(n);let i=this.subgraphLookup.get(n);if(i)for(let t of r)i.cssStyles.push(t)}}addClass(t,r){for(let n of t){let t=this.classes.get(n);if(void 0===t&&(t={id:n,styles:[],textStyles:[]},this.classes.set(n,t)),r)for(let n of r)n.includes("color")&&t.textStyles.push(n.replace("fill","bgFill")),t.styles.push(n)}}setClass(t,r){for(let n of t){let t=this.entities.get(n);if(t)for(let n of r)t.cssClasses+=" "+n;let i=this.subgraphLookup.get(n);if(i)for(let t of r)i.classes.push(t)}}addSubGraph(t,r,n){var i;let a=t.text.trim(),s=new Set,o=[],l;for(let t of r.flat()){if("string"!=typeof t){t?.stmt==="dir"&&(l=t.value);continue}let r=t.trim();""===r||s.has(r)||(s.add(r),this.claimed.has(t)||o.push(t))}for(let t of o)this.claimed.add(t);let c={id:a,nodes:o,title:(n.text||"").trim(),classes:[],cssStyles:[],dir:l,labelType:"markdown"===(i=n.type)||"string"===i||"text"===i?i:"markdown"};return this.subgraphs.push(c),this.subgraphLookup.set(a,c),a}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
|
|
64
|
+
`)}},sq=["$end","INVALID","ER_DIAGRAM","EOF","NEWLINE","COLON","STYLE_SEPARATOR","BLOCK_START","BLOCK_STOP","SQS","SQE","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","END","SUBGRAPH","direction_tb","direction_bt","direction_rl","direction_lr","CLASSDEF","UNICODE_TEXT","STYLE_TEXT","COMMA","CLASS","STYLE","SEMI","NUM","BRKT","ENTITY_NAME","DECIMAL_NUM","ENTITY_ONE","ATTRIBUTE_WORD","ATTRIBUTE_KEY","COMMENT","ZERO_OR_ONE","ZERO_OR_MORE","ONE_OR_MORE","ONLY_ONE","MD_PARENT","NON_IDENTIFYING","IDENTIFYING","WORD","CHAR"],sV=new Uint8Array(128);for(let t=0;t<128;t++){let r=t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||95===t,n=r&&(t<48||t>57);r&&(sV[t]|=11),n&&(sV[t]|=4)}for(let t of"-*")sV[t.charCodeAt(0)]|=11;for(let t of(sV[46]|=9,sV[42]|=4,"[](),"))sV[t.charCodeAt(0)]|=8;var sY=/accTitle\s*:\s*/iy,sG=/accDescr\s*:\s*/iy,sZ=/accDescr\s*\{\s*/iy,sX=[/.*direction\s+TB[^\n]*/iy,/.*direction\s+BT[^\n]*/iy,/.*direction\s+RL[^\n]*/iy,/.*direction\s+LR[^\n]*/iy],sK=/direction/gi,sJ=/[\n\r\u2028\u2029]/g;function sQ(t,r){return t<128?(sV[t]&r)!=0:t>=192||181===t}var s0=new Map([[37,"ZERO_OR_ONE"],[38,"ZERO_OR_MORE"],[39,"ONE_OR_MORE"],[40,"ONLY_ONE"],[41,"MD_PARENT"]]),s1=["TB","BT","RL","LR"],s2="'UNICODE_TEXT', 'NUM', 'ENTITY_NAME', 'DECIMAL_NUM', 'ENTITY_ONE'",s4="'EOF', 'NEWLINE', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'SUBGRAPH', 'direction_tb', 'direction_bt', 'direction_rl', 'direction_lr', 'CLASSDEF', 'CLASS', 'STYLE', "+s2,s3=[];function s5(t,r,n,i,a){let s=(t,s)=>eT(r-i*t-a*s)+","+eT(n-a*t+i*s),o=t=>`M${s(t,-5)}L${s(t,5)}`,l=`M${s(0,-6)}L${s(10,0)}L${s(0,6)}`,c=t=>`<circle class="pele-marker" cx="${eT(r-i*t)}" cy="${eT(n-a*t)}" r="3.5" fill="var(--_bg)"/>`,d=t=>`<path class="pele-marker" d="${t}"/>`;switch(t){case"only_one":return d(o(6)+o(10));case"zero_or_one":return d(o(6))+c(13.5);case"one_or_more":return d(l+o(13.5));case"zero_or_more":return d(l)+c(14);case"md_parent":return`<path class="pele-marker" d="M${s(0,0)}L${s(6,4)}L${s(12,0)}L${s(6,-4)}Z" fill="var(--_bg)"/>`}return""}var s6=[],s8=' fill="var(--_s)" stroke="var(--_b)"';function s9(t,r,n){let i=t.er?.[r];return"number"==typeof i&&i>0?Math.min(i,2e3):n}function s7(t,r,n,i,a,s=0){let o=t.lines;if(0===o.length)return"";let l=1===o.length&&1===o[0].length?o[0][0]:void 0;if(l&&void 0===l.icon&&void 0===l.math&&l.style===s&&!(s&&l.text.includes(" ")))return`<text${eW(i,s)} x="${eT(r)}" y="${eT(n)}">${eE(l.text)}</text>`;let c=eB(t),d=.35*t.size,u=n-d-t.lineHeight/2,h="",f="";for(let s=0;s<o.length;s++){let l=o[s],p=u+ii(t,s);if(ir(l)){f+=eI(ia(t,s),r+t.widths[s]/2,p,i,a);continue}n=p+d;let g=!1;for(let t of l)void 0!==t.icon&&(g=!0);let m=r,y=!1;for(let r of l){if(void 0!==r.icon){let i=1.1*t.size;f+=`<svg class="pele-icon" data-icon="${eS(r.icon)}" x="${eT(m)}" y="${eT(n-.35*t.size-i/2)}" width="${eT(i)}" height="${eT(i)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${a?.(r.icon)??""}</svg>`}else if(""!==r.text){let t=g||!y?` x="${eT(m)}" y="${eT(n)}"`:"";h+=`<tspan${t}${eF(r.style&~c)}>${eE(r.text)}</tspan>`,y=!0}m+=r.width}}return`<text${eW(i,c)} xml:space="preserve">${h}</text>${f}`}function oe(t){let r=so(t);return r===t?t:r.replace(/</g,"<").replace(/>/g,">")}function ot(t,r,n,i){let a=function(t){let r=[],n=[],i=t.subgraphs,a=r=>{let n=[];for(let i of r){let r=t.classes.get(i);if(void 0!==r){for(let t of r.styles)n.push(t.trim());for(let t of r.textStyles)n.push(t.trim())}}return n},s=new Map,o=new Set;for(let t=i.length-1;t>=0;t--){let r=i[t];for(let t of(o.add(r.id),r.nodes))s.set(t,r.id)}for(let t=i.length-1;t>=0;t--){let n=i[t];r.push({id:n.id,label:n.title,alias:"",attributes:s3,isGroup:!0,parentId:s.get(n.id),cssStyles:n.cssStyles,cssCompiledStyles:a(n.classes),cssClasses:n.classes.join(" "),dir:n.dir,labelType:n.labelType})}let l=new Map;for(let[n,i]of t.entities){if(o.has(n)){l.set(i.id,n);continue}r.push({id:i.id,label:i.label,alias:i.alias,attributes:i.attributes,isGroup:!1,parentId:s.get(n),cssStyles:i.cssStyles,cssCompiledStyles:a(i.cssClasses.split(" ")),cssClasses:i.cssClasses,dir:void 0,labelType:"markdown"})}return t.relationships.forEach((t,r)=>{n.push({id:`id_${t.entityA}_${t.entityB}_${r}`,start:l.get(t.entityA)??t.entityA,end:l.get(t.entityB)??t.entityB,label:t.roleA,arrowTypeStart:t.relSpec.cardB.toLowerCase(),arrowTypeEnd:t.relSpec.cardA.toLowerCase(),pattern:"IDENTIFYING"===t.relSpec.relType?"solid":"dashed"})}),{nodes:r,edges:n}}(t),s=Array.isArray(n.monospace)&&n.monospace.includes("attributes"),o=n.fontSize??16,l=Math.round(.875*o),c=n.measurer??e$(n.fontFamily,n.fontFamilyMono),d=n.padding??8,u=n.icons,h=new Map,f=[],p=[];a.nodes.forEach((t,r)=>h.set(t.id,r));let g=[],m=[],v=[],b=new Map,x=[];for(let t of a.edges){let r=h.get(t.start),n=h.get(t.end);if(void 0===r||void 0===n)continue;let i=n7(t.label,!0,c,l,200),a;if(r===n){a={label:i,band:0,at:0};let t=b.get(r);t?t.push(a):b.set(r,[a])}x.push(a),v.push(t),m.push(i),g.push({src:r,dst:n,minlen:1,labelW:i.width>0?i.width+12:0,labelH:i.height>0?i.height+4:0,route:[],labelX:0,labelY:0})}let w=r=>{let n=r;for(let t=0;t<a.nodes.length;t++){let t=a.nodes[n].parentId,r=void 0===t?void 0:h.get(t);if(void 0===r)break;let i=a.nodes[r].dir;if(i)return"LR"===i||"RL"===i;n=r}return"LR"===t.direction||"RL"===t.direction};for(let t=0;t<a.nodes.length;t++){let r=a.nodes[t],n=no(r.cssStyles.length>0?r.cssCompiledStyles.concat(r.cssStyles):r.cssCompiledStyles),i=!!n.bold|2*!!n.italic,d=s&&!/[";]font-family:/.test(n.text)?4:0,u=n.fontSize??o,h=n.fontSize??l,g=n.fontSize??Math.round(.75*o),m=r.isGroup?n7(r.label,!0,c,u,4e3,i):n7(r.alias||r.label,!0,c,u,240,i),y=b.get(t)??s6,v=y.length>0&&!r.isGroup&&w(t),x={node:r,style:n,label:m,w:0,h:0,headH:0,rows:[],cols:[],rowSize:h,keySize:g,mono:d,below:v},$=0,k=0;for(let t of y)t.band=Math.max(38,v?t.label.width+12:t.label.height+6),k+=t.band,$=Math.max($,v?t.label.height:t.label.width);let M=Math.max(96,v?k+8:0),_;if(r.isGroup)(_=rR(0,0)).isGroup=!0,_.dir=r.dir?rC(r.dir):void 0,_.padX=20,_.padTop=x.label.height>0?x.label.height+16:20,_.padBottom=20,_.minW=Math.max(x.label.width+40-12,96);else{let t=Math.max(m.height,Math.round(1.5*u));if(0===r.attributes.length)x.w=Math.max(m.width+36,M),x.h=Math.max(t+24,v?0:k+8);else{let n=Math.round(1.5*h),a=[0,0,0,0];for(let t of r.attributes){let r=[n7(oe(t.type),!0,c,h,1e6,i|d),n7(oe(t.name),!0,c,h,1e6,i|d),n7(t.keys.join(", "),!1,c,g,1e6,i|d),n7(oe(t.comment),!0,c,h,260,i)],s=n;for(let t=0;t<4;t++)r[t].width>a[t]&&(a[t]=r[t].width),r[t].height>s&&(s=r[t].height);x.rows.push({cells:r,h:s+9}),x.h+=s+9}let s=0,o=0;for(let t of a)0!==t&&(o+=t+16*(s>0),s++);x.w=Math.max(o+24,m.width+36,M);let l=s>0?(x.w-o-24)/s:0,u=12;for(let t of a)x.cols.push(u),t>0&&(u+=t+l+16);x.headH=t+18,x.h+=x.headH}let n=y.length>0?2*(49+$):0;_=v?rR(x.w,x.h+n):rR(x.w+n,x.h)}_.seq=f.length,f.push(x),p.push(_)}a.nodes.forEach((t,r)=>{p[r].parent=void 0!==t.parentId?h.get(t.parentId)??-1:-1});let $=rP(p,g,i?"TB":rC(t.direction),{nodeSep:s9(r,"nodeSpacing",48),edgeSep:20,rankSep:s9(r,"rankSpacing",64),portSep:24});!function(t,r,n){let i=new Map,a=(t,n,a,s)=>{let o=r[t],l=n[a]-o.x,c=n[a+1]-o.y,d;if(.5>Math.abs(Math.abs(c)-o.h/2))d=c<0?0:2;else{if(!(.5>Math.abs(Math.abs(l)-o.w/2)))return;d=l<0?3:1}let u=4*t+d,h={route:n,at:a,toward:n[s+(1&d?1:0)]},f=i.get(u);f?f.push(h):i.set(u,[h])};for(let r of t){let t=r.route.length-3;r.src===r.dst||t<3||(a(r.src,r.route,0,3),a(r.dst,r.route,t,t-3))}for(let[t,a]of i){if(a.length<2)continue;let i=t>>2,s=(1&t)==1,o=r[i].isGroup?r[i]:n[i],l=Math.max(Math.min(18,((s?o.h:o.w)-28)/(a.length-1)),0),c=s?r[i].y:r[i].x;a.sort((t,r)=>t.toward-r.toward);for(let t=0;t<a.length;t++)a[t].route[a[t].at+ +!!s]=c+(t-(a.length-1)/2)*l}}(g,p,f);let k=$.width;for(let[t,r]of b){let n=p[t];if(!n.isGroup)continue;let i=0;for(let t of r)i=Math.max(i,t.label.width);k=Math.max(k,n.x+n.w/2+18+21+10+i)}let M=ad(t.title,c,o,4e3),_=M.height>0?M.height+12:0,A=Math.max(k,M.width);rD(p,g,d+(A-k)/2,d+_);let E=Math.ceil(A+2*d),S=Math.ceil($.height+_+2*d),C=[],T=new Map,I=!1;for(let t of p)t.isGroup&&(I=!0);if(I)for(let t of g)rj(T,t.route);let N="",O=[],D="";for(let t=0;t<f.length;t++){let r,i=f[t],a=p[t],s=i.node,o=nc(s.cssClasses.replace(/^default\s?/,""));if(a.isGroup){i.w=a.w,i.h=a.h;let t=a.x-a.w/2,r=a.y-a.h/2,n=rF(a,i.label.width,T,20);e6(i.style.shape)&&O.push({box:[t,r,t+a.w,r+a.h],shape:i.style.shape}),N+=`<g class="pele-cluster${o}" data-id="${eS(s.id)}"><rect x="${eT(t)}" y="${eT(r)}" width="${eT(a.w)}" height="${eT(a.h)}" fill="var(--_a)"${r8(i.style.shape)?"":' fill-opacity="0.5"'} stroke="var(--_b)"${r9(i.style.shape)}/>`+eI(i.label,n,r+8+i.label.height/2,` class="pele-cluster-label"${e8(i.style,"var(--_m)")}${i.style.text}`,u)+"</g>";continue}let l=i.w,c=i.h,d=-l/2,h=-c/2,g=i.style.text,m=e8(i.style),v=m||' fill="var(--_m)"',b=`x="${eT(d)}" y="${eT(h)}" width="${eT(l)}" height="${eT(c)}"`,x=eI(i.label,0,i.rows.length>0?h+i.headH/2:0,` class="pele-label"${m}${g}`,u),w=y(s.alias||s.label);if(/ internal-link(?: |$)/.test(o+" ")&&""!==x&&!1!==n.links){let t=tT(w,n),r=eE(w);x=`<a class="internal-link"${t?` href="${r}"${tN(n)}`:""} data-href="${r}">${x}</a>`,C.push({id:s.label,href:w,internal:!0})}if(0===i.rows.length)r=`<rect ${b}${r9(s8+i.style.shape)}/>`+x;else{let t=Math.round(1.5*i.rowSize),n=i.style.stroke?eE(i.style.stroke):"var(--_b)",a="",s="",o=h+i.headH;for(let r=0;r<i.rows.length;r++){let n=i.rows[r];if(r%2==0){let t=`x="${eT(d)}" width="${eT(l)}"`;r===i.rows.length-1?a+=`<rect ${t} y="${eT(o)}" height="${eT(n.h)}"${r5}/><rect ${t} y="${eT(o)}" height="${eT(n.h/2)}"/>`:a+=`<rect ${t} y="${eT(o)}" height="${eT(n.h)}"/>`}let c=o+4.5+t/2+.35*i.rowSize,[h,f,p,y]=n.cells;s+=s7(h,d+i.cols[0],c,` class="pele-er-type"${v}${g}`,u,i.mono)+s7(f,d+i.cols[1],c,` class="pele-er-name"${m}${g}`,u,i.mono)+s7(p,d+i.cols[2],c,` class="pele-er-keys" font-size="${i.keySize}"${v}${g}`,u,i.mono)+s7(y,d+i.cols[3],c,` class="pele-er-comment"${v}${g}`,u),o+=n.h}let c=eT(h+i.headH),f=e5(i.style.shape),p=f===eq?eV:f===eV?eq:"var(--_bg)";r=`<rect ${b}${r9(s8+i.style.shape)}/><g class="pele-er-stripes" fill="${p}"${i.style.shape.includes("fill:")?' opacity="0.6"':""}>${a}</g><path class="pele-er-divider" d="M${eT(d)},${c}H${eT(d+l)}" stroke="${n}"/><rect ${b} fill="none" stroke="var(--_b)"${r9(i.style.line)}/>`+x+`<g class="pele-er-attributes" font-size="${i.rowSize}">${s}</g>`}D+=`<g class="pele-node pele-entity${o}" data-id="${eS(s.label)}" transform="translate(${eT(a.x)},${eT(a.y)})">${r}</g>`}for(let[t,r]of b){let n=f[t],i=0;for(let t of r)i+=t.band;let a=Math.min(1,Math.max((n.below?n.w:n.h)-8,0)/i),s=-i*a/2;for(let t of r)t.band*=a,t.at=s+t.band/2,s+=t.band}let R="",L="",z="";for(let t=0;t<g.length;t++){let r=g[t],n=v[t],i=m[t],a,s,o,l=x[t];if(l){let t=p[r.src],c=f[r.src],d=Math.max(Math.min(l.band/2-6,13),1);if(c.below){let u=t.x+l.at,h=t.y+c.h/2,f=eT(h+18),p=eT(h+18+28);a=`M${eT(u-d)},${eT(h)}V${f}C${eT(u-d)},${p} ${eT(u+d)},${p} ${eT(u+d)},${f}V${eT(h)}`,s=s5(n.arrowTypeStart,u-d,h,0,-1),o=s5(n.arrowTypeEnd,u+d,h,0,-1),r.labelX=u,r.labelY=h+45+i.height/2}else{let u=t.x+c.w/2,h=t.y+l.at,f=eT(u+18),p=eT(u+18+28);a=`M${eT(u)},${eT(h-d)}H${f}C${p},${eT(h-d)} ${p},${eT(h+d)} ${f},${eT(h+d)}H${eT(u)}`,s=s5(n.arrowTypeStart,u,h-d,-1,0),o=s5(n.arrowTypeEnd,u,h+d,-1,0),r.labelX=u+45+i.width/2,r.labelY=h}}else{let t=function(t){let r=t.slice(0,3);for(let n=3;n<t.length;n+=3){let i=r.length-3,a=a=>.01>Math.abs(r[i+a]-t[n+a])&&.01>Math.abs(t[n+a]-t[n+3+a]);n+3<t.length&&(a(0)||a(1))||r.push(t[n],t[n+1],t[n+2])}return r}(r.route);if(t.length<6)continue;or(t,0,f[r.src],p[r.src]),or(t,t.length-3,f[r.dst],p[r.dst]);let i=Math.abs(t[t.length-3]-t[0]),l=Math.abs(t[t.length-2]-t[1]),c=6===t.length&&(i<.01||l<.01||54>=Math.hypot(i,l))?0:18,d=rU(t,void 0,c,c);a=c>0?`M${eT(d.sx)},${eT(d.sy)}L${d.d.slice(1)}L${eT(d.ex)},${eT(d.ey)}`:d.d,s=s5(n.arrowTypeStart,d.sx,d.sy,d.sdx,d.sdy),o=s5(n.arrowTypeEnd,d.ex,d.ey,d.edx,d.edy)}let c=rZ(a,[],O),d=c&&rX(c);""===d&&(L+=rQ(a,s+o)),c&&d&&(s=rK(s,c),o=rK(o,c));let h="dashed"===n.pattern;if(R+=`<g class="pele-edge pele-er-${h?"non-identifying":"identifying"}" data-id="${eS(n.id)}"${d?` stroke="${d}"`:""}><path d="${a}"${h?' stroke-dasharray="4 3"':""}/>`+s+o+"</g>",i.width>0){let t=r.labelX,a=r.labelY;z+=r2(n.id,i,t,a,"",u)}}return{svg:np("er",E,S,o,n,t,eI(M,E/2,d+M.height/2,' class="pele-title" font-weight="var(--_tw)"')+(N?`<g class="pele-clusters">${N}</g>`:"")+r1(L)+(R?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${R}</g>`:"")+(z?`<g class="pele-edge-labels" font-size="${l}">${z}</g>`:"")+`<g class="pele-nodes">${D}</g>`),width:E,height:S,links:C}}function or(t,r,n,i){if(i.isGroup)return;let a=t[r]-i.x,s=t[r+1]-i.y;i.w!==n.w&&.5>Math.abs(Math.abs(a)-i.w/2)&&(t[r]-=Math.sign(a)*(i.w-n.w)/2),i.h!==n.h&&.5>Math.abs(Math.abs(s)-i.h/2)&&(t[r+1]-=Math.sign(s)*(i.h-n.h)/2)}var on=new Map([["ui","ui"],["pcr","processor"],["processor","processor"],["rmo","readmodel"],["readmodel","readmodel"],["cmd","command"],["command","command"],["evt","event"],["event","event"]]),oi=new Map([["trigger",[0,"UI/Automation","UI/A: "]],["state",[100,"Command/Read Model","C/RM: "]],["stream",[200,"Events","Stream: "]]]);function oa(t){let r=t.indexOf("{"),n=t.lastIndexOf("}"),i=(-1!==r&&n>r?t.slice(r+1,n):-1===r&&t.length>=2?t.slice(1,-1):"").replace(/\r/g,"").split(`
|
|
65
|
+
`);for(;i.length>0&&""===i[0].trim();)i.shift();for(;i.length>0&&""===i[i.length-1].trim();)i.pop();let a=1/0;for(let t of i)""!==t.trim()&&(a=Math.min(a,t.length-t.trimStart().length));return i.map(t=>t.slice(Math.min(a,t.length)).trimEnd()).join(`
|
|
66
|
+
`)}var os=/[\t ]*accDescr(?:[\t ]*:(?:[^\n\r]*?(?=%%)|[^\n\r]*)|\s*({))/y;function oo(){let t=!1;return(r,n)=>{os.lastIndex=n;let i=os.exec(r);if(null===i)return -1;let a=os.lastIndex;if(void 0===i[1])return a;if(t)return -1;let s=r.indexOf("}",a);return t=-1===s,s+1||-1}}function ol(t="ACC_DESCR"){return{...iS,name:t,scanner:oo}}var oc={name:"EM_ID",pattern:/[_a-zA-Z][\w_]*/y},od=t=>({name:t,pattern:t,longer:[oc]}),ou=t=>({name:t,pattern:t}),oh=[{...iP("eventmodeling"),longer:[oc]},...["resetframe","readmodel","processor","timeframe","command","entity","event","jsobj","figma","given","json","salt","html","text","data","note","when","then","rmo","cmd","evt","pcr","uri"].map(od),ou("->>"),od("gwt"),od("ui"),od("md"),od("tf"),ou("[["),ou("]]"),od("rf"),ou("`"),ou("."),oc,{name:"EM_FID",pattern:/\d{1,3}/y},{name:"EM_DATA_INLINE",pattern:/\{(.*)\}|"(.*)"|'(.*)'/y},{name:"EM_DATA_BLOCK",pattern:/\{[\t ]*\r?\n(?:[\S\s]*?\r?\n)?\}(?:\r?\n|(?!\S))/y},ol("EM_ACC_DESCR"),{...iC,name:"EM_ACC_TITLE"},{...iI(String.raw`\w`),name:"EM_TITLE"},{name:"EM_WS",pattern:/\s+/y,hidden:!0},{...iR,name:"EM_YAML"},{...iL,name:"EM_DIRECTIVE"},{...iz,name:"EM_SINGLE_LINE_COMMENT"},{name:"EM_ML_COMMENT",pattern:/\/\*[\s\S]*?\*\//y,hidden:!0},{name:"EM_SL_COMMENT",pattern:/\/\/[^\n\r]*/y,hidden:!0}],of=t=>oh.findIndex(r=>r.name===t),op=t=>new Set(t.map(of)),og={keyword:0,arrow:of("->>"),open:of("[["),close:of("]]"),tick:of("`"),dot:of("."),id:of("EM_ID"),frameId:of("EM_FID"),inline:of("EM_DATA_INLINE"),block:of("EM_DATA_BLOCK"),accDescr:of("EM_ACC_DESCR"),accTitle:of("EM_ACC_TITLE"),title:of("EM_TITLE"),entity:of("entity"),data:of("data"),note:of("note"),gwt:of("gwt"),given:of("given"),when:of("when"),then:of("then")},om=op(["tf","timeframe"]),oy=op(["rf","resetframe"]),ov=op(["rmo","readmodel","ui","cmd","command","evt","event","pcr","processor"]),ob=op(["json","jsobj","figma","salt","uri","md","html","text"]),ox=new Map([["command",0],["event",1],["readmodel",2],["processor",6]]);function ow(t,r){let n=[];for(let i of y(t).split(`
|
|
67
|
+
`)){let t=i.length<=r?void 0:Array.from(i);if(void 0===t||t.length<=r){n.push(i);continue}for(let i=0;i<t.length;i+=r)n.push(t.slice(i,i+r).join(""))}return n}function o$(t,r,n,i,a){let s="";for(let a=0;a<t.length;a++)""!==t[a]&&(s+=`<tspan x="${eT(r)}" y="${eT(n+a*i)}">${eE(t[a])}</tspan>`);return""===s?"":`<text${a} xml:space="preserve">${s}</text>`}function ok(t){return"markdown"===t||"string"===t||"text"===t?t:"markdown"}function oM(t){return t.startsWith('"')&&t.endsWith('"')?t.substring(1,t.length-1):t}var o_=class{type="flowchart";direction;nodes=new Map;edges=[];subgraphs=[];classes=new Map;tooltips=new Map;defaultEdgeStyle;defaultInterpolate;title;accTitle;accDescr;subgraphLookup=new Map;members=new Set;edgeById=new Map;pairCount=new Map;subCount=0;options;constructor(t={}){this.options=t}addVertex(t,r,n,i,s,o,l,c){let d;if(!t||0===t.trim().length)return;if(void 0!==c){let r=c.includes(`
|
|
68
|
+
`)?c+`
|
|
69
|
+
`:`{
|
|
70
|
+
`+c+`
|
|
71
|
+
}`,n;try{n=q(r)}catch(r){throw new a(`Metadata of "${t}" is not valid YAML. ${r.message}`,"syntax",{type:"flowchart"})}d=null===n||"object"!=typeof n||Array.isArray(n)?void 0:n}let u=this.subgraphLookup.get(t);if(u&&d){u.metadata={...u.metadata,...d};return}let h=this.edgeById.get(t);if(h){d?.animate!==void 0&&(h.animate=d.animate),d?.animation!==void 0&&(h.animation=d.animation),d?.curve!==void 0&&(h.interpolate=d.curve);return}let f=this.nodes.get(t);if(void 0===f&&(void 0===r&&void 0===n&&null!=i&&this.options.warn?.(`Style applied to unknown node "${t}". This may indicate a typo. The node will be created automatically.`),f={id:t,labelType:"text",styles:[],classes:[]},this.nodes.set(t,f)),void 0!==r?(f.labelType=r.type,f.text=oM(r.text.trim())):void 0===f.text&&(f.text=t),void 0!==n&&(f.type=n),null!=i)for(let t of i)f.styles.push(t);if(null!=s)for(let t of s)f.classes.push(t);if(void 0!==o&&(f.dir=o),void 0===f.props?f.props=l??{}:void 0!==l&&Object.assign(f.props,l),void 0===d)return;if(d.shape){let t=String(d.shape);if(t!==t.toLowerCase()||t.includes("_"))throw new a(`No such shape: ${t}. Shape names should be lowercase.`,"semantic",{type:"flowchart"});if(!tD.has(t))throw new a(`No such shape: ${t}.`,"semantic",{type:"flowchart"});f.type=t}let p="string"==typeof d.label?d.label:void 0;d.label&&(f.text=String(d.label),f.labelType=ok(d.labelType)),d.icon&&(f.icon=String(d.icon),p?.trim()||f.text!==t||(f.text="")),d.form&&(f.form=String(d.form)),d.pos&&(f.pos=String(d.pos)),d.img&&(f.img=String(d.img),p?.trim()||f.text!==t||(f.text="")),d.constraint&&(f.constraint=String(d.constraint)),d.w&&(f.assetWidth=Number(d.w)),d.h&&(f.assetHeight=Number(d.h))}addSingleLink(t,r,n,i){let s={start:t,end:r,type:void 0,text:"",labelType:"text",classes:[],isUserDefinedId:!1,interpolate:this.defaultInterpolate},o=n?.text;void 0!==o&&(s.text=oM(o.text.trim()),s.labelType=ok(o.type)),void 0!==n&&(s.type=n.type,s.stroke=n.stroke,s.length=n.length>10?10:n.length);let l=t+"\0"+r,c=this.pairCount.get(l)??0;i&&!this.edgeById.has(i)?(s.id=i,s.isUserDefinedId=!0):s.id=`L_${t}_${r}_${0===c?0:c+1}`;let d=this.options.maxEdges;if(void 0!==d&&this.edges.length>=d)throw new a(`Edge limit exceeded. The limit is ${d}.`,"limit",{type:"flowchart"});this.edges.push(s),this.pairCount.set(l,c+1),this.edgeById.has(s.id)||this.edgeById.set(s.id,s)}addLink(t,r,n){let i="string"==typeof n?.id?n.id.replace("@",""):void 0,a=t[t.length-1],s=r[0];for(let o of t)for(let t of r)this.addSingleLink(o,t,n,o===a&&t===s?i:void 0)}updateLinkInterpolate(t,r){for(let n of t)"default"===n?this.defaultInterpolate=r:this.edgeAt(n).interpolate=r}updateLink(t,r){for(let n of t){if("default"===n){this.defaultEdgeStyle=r;continue}this.edgeAt(n).style=r,r.length>0&&!r.some(t=>t?.startsWith("fill"))&&r.push("fill:none")}}edgeAt(t){let r=this.edges[Number(t)];if(void 0===r)throw new a(`The index ${t} for linkStyle is out of bounds. Valid indices for linkStyle are between 0 and ${this.edges.length-1}. (Help: Ensure that the index is within the range of existing edges.)`,"semantic",{type:"flowchart"});return r}addClass(t,r){let n=r.join().replace(/\\,/g,"\xa7\xa7\xa7").replace(/,/g,";").replace(/§§§/g,",").split(";");for(let r of t.split(",")){let t=this.classes.get(r);for(let i of(void 0===t&&(t={id:r,styles:[],textStyles:[]},this.classes.set(r,t)),n))i.includes("color")&&t.textStyles.push(i.replace("fill","bgFill")),t.styles.push(i)}}setDirection(t){let r=t.trim();r.includes("<")&&(r="RL"),r.includes("^")&&(r="BT"),r.includes(">")&&(r="LR"),r.includes("v")&&(r="TB"),"TD"===r&&(r="TB"),this.direction=r}setClass(t,r){for(let n of t.split(","))this.nodes.get(n)?.classes.push(r),this.edgeById.get(n)?.classes.push(r),this.subgraphLookup.get(n)?.classes.push(r)}setTooltip(t,r){if(void 0!==r)for(let n of t.split(","))this.tooltips.set(n,r)}setLink(t,r,n){let i=r.trim();for(let r of t.split(",")){let t=this.nodes.get(r);void 0!==t&&(t.link=i?tw(i):void 0,t.linkTarget=n)}this.setClass(t,"clickable")}setClickEvent(t,r,n){this.setClass(t,"clickable")}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
|
|
72
|
+
`)}addSubGraph(t,r,n){let i=t?.text.trim(),a=n?.text??"";void 0!==t&&t===n&&/\s/.test(a)&&(i=void 0);let s=new Set,o=[],l;for(let t of r)if("string"==typeof t)""===t.trim()||s.has(t)||(s.add(t),o.push(t));else if(Array.isArray(t))for(let r of t)""===r.trim()||s.has(r)||(s.add(r),o.push(r));else l=t.value;l??=this.options.inheritDir?this.direction??this.options.direction:void 0,i??="subGraph"+this.subCount,a=a||"",this.subCount++;let c={id:i,nodes:o,title:a.trim(),classes:[],dir:l,labelType:ok(n?.type)},d=this.members;for(let t of(c.nodes=o.filter(t=>!d.has(t)&&t!==i),c.nodes))d.add(t);let u=this.subgraphLookup.get(i);if(u)for(let t of c.nodes)u.nodes.push(t);else this.subgraphs.push(c);return this.subgraphLookup.set(i,u??c),i}exists(t,r){for(let n of t)if(n.nodes.includes(r))return!0;return!1}makeUniq(t,r){let n=new Set;for(let t of r)for(let r of t.nodes)n.add(r);return{nodes:t.nodes.filter(t=>!n.has(t))}}destructLink(t,r){let n=function(t){let r=t.trim(),n=r.slice(0,-1),i="arrow_open";switch(r.slice(-1)){case"x":i="arrow_cross",r.startsWith("x")&&(i="double_"+i,n=n.slice(1));break;case">":i="arrow_point",r.startsWith("<")&&(i="double_"+i,n=n.slice(1));break;case"o":i="arrow_circle",r.startsWith("o")&&(i="double_"+i,n=n.slice(1))}let a="normal",s=n.length-1;n.startsWith("=")&&(a="thick"),n.startsWith("~")&&(a="invisible");let o=function(t){let r=0;for(let n=0;n<t.length;n++)"."===t[n]&&r++;return r}(n);return o&&(a="dotted",s=o),{type:i,stroke:a,length:s}}(t);if(!r)return n;let i=function(t){let r=t.trim(),n="arrow_open";switch(r[0]){case"<":n="arrow_point",r=r.slice(1);break;case"x":n="arrow_cross",r=r.slice(1);break;case"o":n="arrow_circle",r=r.slice(1)}let i="normal";return r.includes("=")&&(i="thick"),r.includes(".")&&(i="dotted"),{type:n,stroke:i}}(r);if(i.stroke!==n.stroke)return{type:"INVALID",stroke:"INVALID"};if("arrow_open"===i.type)i.type=n.type;else{if(i.type!==n.type)return{type:"INVALID",stroke:"INVALID"};i.type="double_"+i.type}return"double_arrow"===i.type&&(i.type="double_arrow_point"),i.length=n.length,i}subgraph(t){return this.subgraphLookup.get(t)}},oA=["$end","INVALID","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","SHAPE_DATA","CALLBACKNAME","CALLBACKARGS","MD_STR","STR","STYLE","DEFAULT","LINKSTYLE","INTERPOLATE","CLASSDEF","CLASS","HREF","CLICK","GRAPH","subgraph","end","LINK_TARGET","NODIR","DIR","direction_tb","direction_bt","direction_rl","direction_lr","direction_td","LINK_ID","NUM","BRKT","STYLE_SEPARATOR","COLON","AMP","SEMI","COMMA","MULT","LINK","START_LINK","EDGE_TEXT","-)","TEXT","(-","STADIUMEND","STADIUMSTART","SUBROUTINEEND","SUBROUTINESTART","VERTEX_WITH_PROPS_START","TAGEND","CYLINDEREND","CYLINDERSTART","DOUBLECIRCLEEND","DOUBLECIRCLESTART","TRAPEND","INVTRAPEND","TRAPSTART","INVTRAPSTART","TAGSTART","UP","SEP","DOWN","NODE_STRING","MINUS","UNICODE_TEXT","PIPE","PE","PS","SQE","SQS","DIAMOND_STOP","DIAMOND_START","NEWLINE","SPACE","EOF"],oE=new Uint8Array(128);for(let t of"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"#$%&'*+.`?\\_/")oE[t.charCodeAt(0)]=1;var oS=/accTitle\s*:\s*/y,oC=/accDescr\s*:\s*/y,oT=/accDescr\s*\{\s*/y,oI=/call\s+/y,oN=/click\s+/y,oO=/(?:\r?\n)*\s*\n/y,oD=/\s*(?:LR|RL|TB|BT|TD|BR)\b/y,oR=/\s*[<>^]/y,oL=/\s*v\b/y,oz=[/.*direction\s+TB[^\n]*/y,/.*direction\s+BT[^\n]*/y,/.*direction\s+RL[^\n]*/y,/.*direction\s+LR[^\n]*/y,/.*direction\s+TD[^\n]*/y],oP=/[\n\r\u2028\u2029]/g,oj=/\s*[xo<]?--+[-xo>]\s*/y,oF=/\s*[xo<]?--\s*/y,oB=/\s*[xo<]?==+[=xo>]\s*/y,oW=/\s*[xo<]?==\s*/y,oH=/\s*[xo<]?-?\.+-[xo>]?\s*/y,oU=/\s*[xo<]?-\.\s*/y,oq=/\s*~~~+\s*/y,oV=/(?:\r?\n)+/y,oY=/[^\S\n\r]+/y,oG=/\(\s*\)/y,oZ=/\n\s*/g,oX=new Uint8Array(77);for(let t of[32,64,63,65,13,38,35,36,33,39,66])oX[t]=1;var oK=new Uint8Array(77);for(let t of[32,66,64,25,63,65,38,35,36,33,39])oK[t]=1;var oJ=new Uint8Array(77);for(let t of[32,64,75,65,36,66,35,39,33,12,14,16,17,19,20,25,21,22,63,61,41])oJ[t]=1;var oQ=new Uint8Array(77);for(let t of[32,64,35,75,33,12])oQ[t]=1;var o0="'UNICODE_TEXT', 'TEXT', 'TAGSTART'",o1=[],o2=/}\s*\n/g,o4=["TB","BT","RL","LR","TD"],o3="'SEMI', 'NEWLINE', 'SPACE', 'EOF', 'subgraph', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'STYLE', 'LINKSTYLE', 'CLASSDEF', 'CLASS', 'CLICK', 'NODE_STRING'",o5=' fill="var(--_s)" stroke="var(--_b)"';function o6(t,r,n){let i=t[r];return"number"==typeof i&&i>0?Math.min(i,2e3):n}function o8(t,r){return void 0!==t&&t>0&&t<=4e3?t:r}function o9(t,r,n,i){let a=a=>iu(n,s=>(function(t,r,n,i,a,s){var o;let l=s?12:20,c=i?r[i.type]:void 0,d="object"!=typeof c||null===c||Array.isArray(c)?r.flowchart??{}:c,u=function(t,r){let n=[],i=[],a=t.subgraphs,s=r=>{let n=[];for(let i of r){let r=t.classes.get(i);if(void 0!==r){for(let t of r.styles)n.push(t.trim());for(let t of r.textStyles)n.push(t.trim())}}return n},o=new Map;for(let r of a)for(let n of r.nodes)t.subgraph(n)&&o.set(n,r.id);let l=new Map,c=new Map;for(let t of a){let r=o.get(t.id);if(void 0===r)continue;let n=c.get(r);n?n.push(t.id):c.set(r,[t.id])}let d=0;for(let t of a){if(o.has(t.id))continue;let r=[t.id];for(;r.length>0;){let t=r.pop();if(l.has(t))continue;l.set(t,d++);let n=c.get(t);if(n)for(let t=n.length-1;t>=0;t--)r.push(n[t])}}let u=r=>t.subgraph(r)?.metadata?.view==="collapsed",h=!1;for(let t of a)t.metadata?.view==="collapsed"&&(h=!0);let f=new Map,p=t=>{let r=[],n=new Set,i=t;for(;void 0!==i&&!f.has(i)&&!n.has(i);)n.add(i),r.push(i),i=o.get(i);let a=void 0!==i?f.get(i):void 0;for(let t=r.length-1;t>=0;t--)void 0===a&&u(r[t])&&(a=r[t]),f.set(r[t],a);return a},g=new Set,m=new Map;for(let t of h?a:[]){let r=p(t.id);if(void 0!==r)for(let n of(t.id!==r&&(g.add(t.id),m.set(t.id,r)),t.nodes))n!==r&&(g.add(n),m.set(n,r))}let y=new Map,v=new Set;for(let t=a.length-1;t>=0;t--){let r=a[t];if(!g.has(r.id))for(let t of(r.nodes.length>0&&v.add(r.id),r.nodes))y.set(t,r.id)}let b=new Map;for(let t=a.length-1;t>=0;t--){let r=a[t];if(g.has(r.id))continue;let i=r.metadata?.view==="collapsed",o={id:r.id,label:r.title,labelType:r.labelType,parentId:y.get(r.id),cssStyles:[],cssCompiledStyles:s(r.classes),cssClasses:r.classes.join(" "),shape:i?"collapsedGroup":"rect",dir:r.dir,isGroup:!i,colorIndex:l.get(r.id)};i||(o.metadata=r.metadata),n.push(o),b.set(r.id,o)}for(let r of t.nodes.values()){if(g.has(r.id))continue;let i=b.get(r.id);if(i){i.cssStyles=r.styles,i.cssCompiledStyles=s(r.classes),i.cssClasses=r.classes.join(" ");continue}let a=v.has(r.id),o={id:r.id,label:r.text,labelType:r.labelType,parentId:y.get(r.id),cssStyles:r.styles,cssCompiledStyles:s(["default","node",...r.classes]),cssClasses:"default "+r.classes.join(" "),dir:r.dir,link:r.link,linkTarget:r.linkTarget,tooltip:t.tooltips.get(r.id),icon:r.icon,pos:r.pos,img:r.img,assetWidth:r.assetWidth,assetHeight:r.assetHeight,constraint:r.constraint,isGroup:a,shape:a?"rect":function(t){if(t.img)return"imageSquare";if(t.icon)return"circle"===t.form?"iconCircle":"square"===t.form?"iconSquare":"rounded"===t.form?"iconRounded":"icon";switch(t.type){case"square":case void 0:return"squareRect";case"round":return"roundedRect";default:return t.type}}(r)};n.push(o)}return t.edges.forEach((n,a)=>{let o=m.get(n.start)??n.start,l=m.get(n.end)??n.end;if(o===l&&(m.has(n.start)||m.has(n.end)))return;let[c,d]=function(t){switch(t){case"arrow_point":case"arrow_circle":case"arrow_cross":return["none",t];case"double_arrow_point":case"double_arrow_circle":case"double_arrow_cross":{let r=t.replace("double_","");return[r,r]}}return["none","arrow_point"]}(n.type),u=[...t.defaultEdgeStyle??[]];n.style&&u.push(...n.style);let h="invisible"===n.stroke||"arrow_open"===n.type;i.push({id:n.id||`L_${o}_${l}_${a}`,isUserDefinedId:n.isUserDefinedId,start:o,end:l,type:n.type??"normal",label:n.text,labelType:n.labelType,thickness:n.stroke,pattern:n.stroke,minlen:n.length,classes:"invisible"===n.stroke?"":"edge-thickness-normal edge-pattern-solid flowchart-link",arrowTypeStart:h?"none":c,arrowTypeEnd:h?"none":d,cssCompiledStyles:s(n.classes),style:u,animate:n.animate,animation:n.animation,curve:n.interpolate||t.defaultInterpolate||r})}),{nodes:n,edges:i}}(t,"string"==typeof d.curve?d.curve:void 0);i?.prepare(u);let h=n.fontSize??16,f=Math.round(.875*h),p=n.measurer??e$(n.fontFamily,n.fontFamilyMono),g=Math.min(o6(d,"wrappingWidth",200),i&&s?100:1/0),m=n.padding??8,v=n.icons,b=new Map,x=[],w=[];for(let t of(u.nodes.forEach((t,r)=>b.set(t.id,r)),u.nodes)){let r=no(t.cssStyles.length>0?t.cssCompiledStyles.concat(t.cssStyles):t.cssCompiledStyles),a=!!r.bold|2*!!r.italic,o="markdown"===t.labelType,c=r.fontSize??h,d,u;if(t.isGroup){let h=n7(t.label,o,p,c,i&&s?Math.max(80,io(n)/2):4e3,a);d={node:t,style:r,label:h,shape:"group",w:0,h:0,dy:0,loops:0},(u=rR(0,0)).isGroup=!0,u.dir=t.dir?rC(t.dir):void 0,u.padX=l,u.padTop=h.height>0?h.height+16:20,u.padBottom=l,u.minW=h.width+2*l-12}else{let n=tR(t.shape),i=n7(t.img||t.icon||nN.get(n)?.noLabel!==!0?t.label:void 0,o,p,c,g,a),s,l,h=0;if(t.img||t.icon){let r=t.img?80:48,n=o8(t.assetWidth,r),a=o8(t.assetHeight,r);s=Math.max(n,i.width+8),l=a+(i.height>0?i.height+6:0),h="t"===t.pos?-a/2:a/2,0===i.height&&(h=0)}else{let t=nO(n,i.width,i.height);s=t.w,l=t.h,h=t.dy}d={node:t,style:r,label:i,shape:n,w:s,h:l,dy:h,loops:0},u=rR(s,l)}u.seq=x.length,x.push(d),w.push(u)}u.nodes.forEach((t,r)=>{w[r].parent=void 0!==t.parentId?b.get(t.parentId)??-1:-1}),rO(w,u.edges.map(t=>[b.get(t.start)??-1,b.get(t.end)??-1]));let $=a?"TB":rC(t.direction),k=t=>{let r;for(let n=w[t].parent,i=0;n>=0&&void 0===r&&i<1e4;n=w[n].parent,i++)r=w[n].dir;return"LR"===(r??=$)||"RL"===r};x.forEach((t,r)=>{var n,i,a,s;t.node.isGroup?w[r].span=1/0:t.node.img||t.node.icon||(w[r].span=(n=t.shape,i=t.w,a=t.h,s=k(r),Math.max(0,nN.get(n)?.span?.(i,a,s)??0)))});let M=[],_=[],A=[];for(let t of u.edges){let r=b.get(t.start),n=b.get(t.end);if(void 0===r||void 0===n)continue;let i=n7(t.label,"markdown"===t.labelType,p,f,g);r===n&&(x[r].loops++,k(r)?w[r].h+=2*(26+(i.height>0?i.height+8:0)):w[r].w+=2*(26+(i.width>0?i.width+12:0))),A.push(t),_.push(i),M.push({src:r,dst:n,minlen:t.minlen??1,labelW:i.width>0?i.width+12:0,labelH:i.height>0?i.height+4:0,route:[],labelX:0,labelY:0})}let E={nodeSep:o6(d,"nodeSpacing",40)*(s?.5:1),edgeSep:16,rankSep:o6(d,"rankSpacing",48)*(s?.75:1),portSep:20,tracks:"string"==typeof d.curve&&/^step/.test(d.curve),straight:"linear"===d.curve,headRoom:rq("arrow_point")},S=i?i.layout(w,M,$,E,s):rP(w,M,$,E),C=ad(t.title,p,h,s?io(n):4e3),T=C.height>0?C.height+12:0,I=Math.max(S.width,C.width);rD(w,M,m+(I-S.width)/2,m+T);let N=Math.ceil(I+2*m),O=Math.ceil(S.height+T+2*m),D=[],R=new Map,L=!1;for(let t of w)t.isGroup&&(L=!0);if(L)for(let t of M)rj(R,t.route);let z="",P="",j="",F=[];for(let t=0;t<x.length;t++){let r=x[t],a=w[t],s=r.node,c=a.x,d=a.y,u=nc(s.cssClasses.replace(/^default\s?/,"")),h=eS(s.id);if(a.isGroup&&i?.drawGroup&&a.parent<0){e6(r.style.shape)&&i.filledBox&&F.push({box:i.filledBox(a,$),shape:r.style.shape}),z+=i.drawGroup(a,r.label,r.style,u,h,$,v);continue}if(a.isGroup){e6(r.style.shape)&&F.push({box:[c-a.w/2,d-a.h/2,c+a.w/2,d+a.h/2],shape:r.style.shape});let n=rF(a,r.label.width,R,l),i=d-a.h/2+8+r.label.height/2,s=rB(a,r.label.width,n,R),o=` class="pele-cluster-label"${s?' fill="var(--_m)"':e8(r.style,"var(--_m)")}${r.style.text}`;s&&(P+=rW(r.label,n,i,o,h,w,t,v)),z+=`<g class="pele-cluster${u}" data-id="${h}"><rect x="${eT(c-a.w/2)}" y="${eT(d-a.h/2)}" width="${eT(a.w)}" height="${eT(a.h)}" fill="var(--_a)"${r8(r.style.shape)?"":' fill-opacity="0.5"'} stroke="var(--_b)"${r9(r.style.shape)}/>`+(s?"":eI(r.label,n,i,o,v))+"</g>";continue}let f=r.w,p=r.h,g,m="";if(s.img){let t=o8(s.assetWidth,80),i=o8(s.assetHeight,80),a=r.label.height>0?"t"===s.pos?p/2-i:-p/2:-i/2,l=(o=tw(s.img),!1===n.images?void 0:tE(o,n.imageSchemes??tk));g=void 0===l?"":`<image href="${eE(l)}" x="${eT(-t/2)}" y="${eT(a)}" width="${eT(t)}" height="${eT(i)}" preserveAspectRatio="${"on"===s.constraint?"xMidYMid meet":"none"}"/>`}else if(s.icon){let t=o8(s.assetHeight,48),n=r.label.height>0?"t"===s.pos?p/2-t:-p/2:-t/2,i="icon"===s.shape?"":"iconCircle"===s.shape?`<circle cy="${eT(n+t/2)}" r="${eT(t/2)}"${o5}${r.style.shape}/>`:`<rect x="${eT(-t/2)}" y="${eT(n)}" width="${eT(t)}" height="${eT(t)}" rx="${8*("iconRounded"===s.shape)}"${o5}${r.style.shape}/>`,a=.6*t;g=i+`<svg class="pele-icon" data-icon="${eS(s.icon)}" x="${eT(-a/2)}" y="${eT(n+(t-a)/2)}" width="${eT(a)}" height="${eT(a)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${v?.(s.icon)??""}</svg>`}else g=nD(r.shape,f,p,o5+r.style.shape,' stroke="var(--_b)"'+r.style.line),nL(r.shape)&&(m=e8(r.style));let b=eI(r.label,0,r.dy,` class="pele-label"${m}${r.style.text}`,v);if(/ internal-link(?: |$)/.test(u+" ")&&s.label&&!1!==n.links){let t=y(s.label),r=tT(t,n),i=eE(t);b=`<a class="internal-link"${r?` href="${i}"${tN(n)}`:""} data-href="${i}">${b}</a>`,D.push({id:s.id,href:t,internal:!0})}let k=g+b;s.tooltip&&(k=`<title>${eS(s.tooltip)}</title>`+k),s.link&&(k=tI(k,s.link,s.id,D,n,s.linkTarget?` target="${eE(s.linkTarget)}"`:"")),j+=`<g class="pele-node pele-shape-${r.shape}${u}" data-id="${h}" transform="translate(${eT(c)},${eT(d)})">${k}</g>`}let B=rH();for(let t=0;t<M.length;t++){let r=M[t];r.src===r.dst||"invisible"===A[t].thickness||r.route.length<6||(B.add(r.src,nz(r.route,0,w[r.src]),A[t].arrowTypeStart),B.add(r.dst,nz(r.route,r.route.length-3,w[r.dst]),A[t].arrowTypeEnd))}let W="",H="",U="",q=new Map;for(let t=0;t<M.length;t++){let r=M[t],n=A[t],i=_[t],a=n.style.length>0||n.cssCompiledStyles.length>0?no(n.cssCompiledStyles.concat(n.style)):void 0;if("invisible"!==n.thickness){let t=n.arrowTypeStart,i=n.arrowTypeEnd,s;if(r.src===r.dst){let t=x[r.src],n=q.get(r.src)??0;q.set(r.src,n+1),s=r4(w[r.src],t.w,t.h,n,k(r.src),26,rq(i),r)}else{let a=r.route.slice(),o=B.of(r.src,nz(a,0,w[r.src])),l=B.of(r.dst,nz(a,a.length-3,w[r.dst]));nP(a,0,x[r.src],w[r.src]),nP(a,a.length-3,x[r.dst],w[r.dst]),s=rU(a,n.curve,rq(t),rq(i),o,l)}let o=rJ(s.d,[s.sx,s.sy,s.ex,s.ey],F,a?.line,s.tokens),l=o||(a?.stroke&&"invisible"!==n.thickness?eE(a.stroke):"var(--_l)"),c="";"thick"===n.thickness?c+=' stroke-width="2.5"':"dotted"===n.thickness&&(c+=' stroke-dasharray="3 4"');let d=nc(n.classes.replace(/edge-thickness-normal|edge-pattern-solid|flowchart-link/g,""));""===o&&(W+=r0(s,t,i,a?.line,"thick"===n.thickness)),H+=`<g class="pele-edge${d}" data-id="${eS(n.id)}"${o?` stroke="${o}"`:""}${a?.line??""}><path d="${s.d}"${c}/>`+rV(t,s.sx,s.sy,s.sdx,s.sdy,l)+rV(i,s.ex,s.ey,s.edx,s.edy,l)+"</g>"}if(i.width>0){let t=r.labelX,s=r.labelY;U+=r2(n.id,i,t,s,a?.text??"",v)}}return{svg:np(i?.type??"flowchart",N,O,h,n,t,eI(C,N/2,m+C.height/2,' class="pele-title" font-weight="var(--_tw)"')+(z?`<g class="pele-clusters">${z}</g>`:"")+r1(W)+(H?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${H}</g>`:"")+(P?`<g class="pele-cluster-titles">${P}</g>`:"")+(U?`<g class="pele-edge-labels" font-size="${f}">${U}</g>`:"")+`<g class="pele-nodes">${j}</g>`),width:N,height:O,links:D}})(t,r,n,i,a,s));return id(t.direction)?ic(n,a):a(!1)}var o7={type:"flowchart",math:!0,parse(t,r,n,i,a){let l=new o_({inheritDir:!0===(r.flowchart??{}).inheritDir,maxEdges:a.maxEdges});return n&&(l.title=n),function(t,r){let n=t.includes("}")?t.replace(o2,`}
|
|
73
|
+
`):t,{types:i,texts:a,starts:l}=function(t){let r=t.length,n=[],i=[],a=[],s=[],o=0,l=0,c=!0,d=t.indexOf("direction"),u=t.indexOf("@"),h=-1,f=0,p=0,g=-1,m=-1,y=-1,v=(r,s,o)=>{n.push(r),i.push(t.slice(s,o)),a.push(s),l=o},b=t=>{s.push(o),o=t},x=()=>{s.length>0&&(o=s.pop())},w=(r,n)=>(r.lastIndex=n,r.test(t)?r.lastIndex:-1),$=r=>t.startsWith(r,l)&&!J(t.charCodeAt(l+r.length)),k=n=>{let i=n;if(n>=m&&n<=y)i=y;else if(V(t.charCodeAt(n))){for(;i<r&&V(t.charCodeAt(i));)i++;m=n,y=i}let a=t.charCodeAt(i);return 120===a||111===a||60===a?t.charCodeAt(i+1):a},M=n=>{let i=n;if(n>=m&&n<=y)i=y;else if(V(t.charCodeAt(n))){for(;i<r&&V(t.charCodeAt(i));)i++;m=n,y=i}return 126===t.charCodeAt(i)},_=()=>{96===t.charCodeAt(l+1)?(b(2),l+=2):(b(1),l++)},A=()=>{if(!M(l))return!1;let t=w(oq,l);return!(t<0)&&(v(40,l,t),!0)},E=r=>{let n=t.charCodeAt(l+1);return 40===r?(45===n?(b(8),v(45,l,l+2)):91===n?(b(7),v(47,l,l+2)):40===n&&40===t.charCodeAt(l+2)?(b(7),v(55,l,l+3)):(b(7),v(69,l,l+1)),!0):91===r?(91===n?(b(7),v(49,l,l+2)):40===n?(b(7),v(53,l,l+2)):47===n?(b(9),v(58,l,l+2)):92===n?(b(9),v(59,l,l+2)):(b(7),v(71,l,l+1)),!0):124===r?(b(7),v(67,l,l+1),!0):123===r&&(b(7),v(73,l,l+1),!0)},S=t=>{c&&(c=!1,b(6)),v(20,l,l+t)},C=()=>{let n=l;for(;n<r;){let i=t.charCodeAt(n);if(i<128&&1===oE[i])n++;else if(45===i&&n+1<r){let r=t.charCodeAt(n+1);if(62===r||45===r||46===r)break;n++}else break}return n!==l&&(v(64,l,n),!0)},T=t=>{let r=k(l),n;if(45===r){if((n=w(oj,l))>=0)return v(40,l,n),!0;if((n=w(oF,l))>=0)return b(10),v(41,l,n),!0;if((n=w(oH,l))>=0)return v(40,l,n),!0;if((n=w(oU,l))>=0)return b(12),v(41,l,n),!0}else if(61===r){if((n=w(oB,l))>=0)return v(40,l,n),!0;if((n=w(oW,l))>=0)return b(11),v(41,l,n),!0}else if(46===r&&(n=w(oH,l))>=0)return v(40,l,n),!0;return 45!==t&&61!==t&&46!==t&&A()},I=s=>{let o;switch(s){case 97:if(t.startsWith("acc",l)){if((o=w(oS,l))>=0)return b(3),v(2,l,o),!0;if((o=w(oC,l))>=0)return b(4),v(4,l,o),!0;if((o=w(oT,l))>=0)return b(5),l=o,!0}break;case 64:if(123===t.charCodeAt(l+1))return b(16),n.push(7),i.push(""),a.push(l),l+=2,!0;break;case 99:if((o=w(oI,l))>=0)return b(14),l=o,!0;if($("classDef"))return v(16,l,l+8),!0;if($("class"))return v(17,l,l+5),!0;if((o=w(oN,l))>=0)return b(13),l=o,!0;break;case 34:return _(),!0;case 115:if($("style"))return v(12,l,l+5),!0;if($("swimlane-beta"))return S(13),!0;if($("subgraph"))return v(21,l,l+8),!0;break;case 100:if($("default"))return v(13,l,l+7),!0;break;case 108:if($("linkStyle"))return v(14,l,l+9),!0;break;case 105:if($("interpolate"))return v(15,l,l+11),!0;break;case 104:if(t.startsWith("href",l)&&V(t.charCodeAt(l+4)))return v(18,l,l+5),!0;break;case 102:if($("flowchart-elk"))return S(13),!0;if($("flowchart"))return S(9),!0;break;case 103:if($("graph"))return S(5),!0;break;case 101:if($("end")){for(o=l+3;o<r&&V(t.charCodeAt(o));)o++;return v(22,l,o),!0}break;case 95:if($("_self"))return v(23,l,l+5),!0;if($("_blank"))return v(23,l,l+6),!0;if($("_parent"))return v(23,l,l+7),!0;if($("_top"))return v(23,l,l+4),!0}if(-1!==d&&l>=f&&(d<l&&(d=t.indexOf("direction",l)),-1!==d&&(h<l&&(oP.lastIndex=l,h=oP.test(t)?oP.lastIndex-1:r),d<h))){for(let t=0;t<5;t++)if((o=w(oz[t],l))>=0)return v(26+t,l,o),!0;f=h}if(-1!==u&&34!==s&&!V(s)){if(l>=p){u<l&&(u=t.indexOf("@",l));let n=l;for(;n<r;){let r=t.charCodeAt(n);if(34===r||V(r))break;n++}if(p=n,g=-1,-1!==u&&u<n)for(let i=Math.min(n,r-1)-1;i>=u;i--){if(64!==t.charCodeAt(i))continue;let r=t.charCodeAt(i+1);if(123!==r&&34!==r){g=i;break}}}if(g>l)return v(31,l,g+1),!0}if(s>=48&&s<=57){let n=l+1;for(;n<r;){let r=t.charCodeAt(n);if(r<48||r>57)break;n++}return v(32,l,n),!0}switch(s){case 35:return v(33,l,l+1),!0;case 58:return 58===t.charCodeAt(l+1)&&58===t.charCodeAt(l+2)?v(34,l,l+3):v(35,l,l+1),!0;case 38:return v(36,l,l+1),!0;case 59:return v(37,l,l+1),!0;case 44:return v(38,l,l+1),!0;case 42:return v(39,l,l+1),!0;case 120:case 111:case 46:return T(s)||C();case 60:return T(s)||v(60,l,l+1),!0;case 45:return T(s)||C()||v(65,l,l+1),!0;case 61:return T(s);case 126:return A();case 40:case 124:case 123:return E(s);case 91:return 124===t.charCodeAt(l+1)?(v(50,l,l+2),!0):E(s);case 62:return b(7),v(51,l,l+1),!0;case 94:return v(61,l,l+1),!0;case 92:return 124===t.charCodeAt(l+1)?(v(62,l,l+2),!0):C();case 118:return J(t.charCodeAt(l+1))?C():(v(63,l,l+1),!0)}return V(s)?!!T(s)||((o=w(oV,l))>=0?(v(74,l,o),!0):(o=w(oY,l))>=0&&(v(75,l,o),!0)):s<128?C():!!tK(s)&&(v(66,l,l+1),!0)},N=(n,i,a,s)=>{if(34===n)return _(),!0;let o=k(l);if(o===a||o===s){let t=w(i,l);if(t>=0)return x(),v(40,l,t),!0}if(n===a&&(45!==a||45===t.charCodeAt(l+1)))return!1;let c=l+1;for(;c<r;){let r=t.charCodeAt(c);if(34===r)break;if(r===a){if(45!==a||45===t.charCodeAt(c+1))break}else if(120===r||111===r||60===r||r===s||V(r)){let t=k(c);if((t===a||t===s)&&w(i,c)>=0)break}c++}return v(42,l,c),!0};for(;;){if(l>=r){let t=-1;switch(o){case 0:t=76;break;case 3:t=3;break;case 4:t=5;break;case 5:t=6;break;case 13:t=19;break;case 14:t=8;break;case 15:t=9}-1!==t&&v(t,r,r);break}let s=t.charCodeAt(l),c=!0;switch(o){case 0:c=I(s);break;case 1:if(34===s)96===t.charCodeAt(l+1)?(b(2),l+=2):(x(),l++);else{let n=t.indexOf('"',l);v(11,l,-1===n?r:n)}break;case 2:if(96===s)34===t.charCodeAt(l+1)?(x(),l+=2):c=!1;else if(34===s)_();else{let n=l+1;for(;n<r;){let r=t.charCodeAt(n);if(96===r||34===r)break;n++}v(10,l,n)}break;case 3:case 4:{let n=t.indexOf(`
|
|
74
|
+
`,l);-1===n&&(n=r);let i=3===o?3:5;x(),v(i,l,n);break}case 5:if(125===s)x(),l++;else{let n=t.indexOf("}",l);-1===n&&(n=r),v(6,l,n)}break;case 6:{let t;34===s?_():(t=w(oO,l))>=0?(x(),v(24,l,t)):(t=w(oD,l))>=0||(t=w(oR,l))>=0||(t=w(oL,l))>=0?(x(),v(25,l,t)):c=A()||E(s);break}case 7:{let n=t.charCodeAt(l+1);switch(s){case 34:_();break;case 40:case 91:case 123:E(s);break;case 93:x(),41===n?v(46,l,l+2):93===n?v(48,l,l+2):v(70,l,l+1);break;case 41:x(),93===n?v(52,l,l+2):41===n&&41===t.charCodeAt(l+2)?v(54,l,l+3):v(68,l,l+1);break;case 124:x(),v(67,l,l+1);break;case 125:x(),v(72,l,l+1);break;default:{if((126===s||V(s))&&A())break;let n=l+1;for(;n<r;){let r=t.charCodeAt(n);if(91===r||93===r||40===r||41===r||123===r||125===r||124===r||34===r)break;n++}v(44,l,n)}}break}case 8:{let n=t.charCodeAt(l+1);if(34===s)_();else{if((126===s||V(s))&&A())break;if((45===s||47===s||41===s)&&41===n)x(),v(43,l,l+2);else if(40===s||91===s||123===s)E(s);else if(41===s||93===s||125===s)c=!1;else{let n=l+1;for(;n<r;){let r=t.charCodeAt(n);if(34===r||40===r||41===r||91===r||93===r||123===r||125===r||(45===r||47===r)&&41===t.charCodeAt(n+1)||(126===r||V(r))&&M(n)&&w(oq,n)>=0)break;n++}v(44,l,n)}}break}case 9:{let n=t.charCodeAt(l+1);if(34===s){_();break}if((126===s||V(s))&&A())break;switch(s){case 40:45===n||91===n||40===n&&40===t.charCodeAt(l+2)?E(s):93===n?(x(),v(56,l,l+2)):E(s);break;case 91:case 123:E(s);break;case 92:93===n?(x(),v(56,l,l+2)):v(44,l,l+1);break;case 47:93===n?(x(),v(57,l,l+2)):v(44,l,l+1);break;case 93:case 41:93===n?(x(),v(56,l,l+2)):c=!1;break;case 125:c=!1;break;default:{if((63===s||61===s)&&93===n){x(),v(56,l,l+2);break}let i=l+1;for(;i<r;){let r=t.charCodeAt(i);if(92===r||91===r||93===r||40===r||41===r||123===r||125===r||47===r)break;i++}v(44,l,i)}}break}case 10:c=N(s,oj,45,-1);break;case 11:c=N(s,oB,61,-1);break;case 12:c=N(s,oH,46,45);break;case 13:if(34===s)_();else if(V(s))x(),l++;else{let n=l+1;for(;n<r&&!V(t.charCodeAt(n));)n++;v(19,l,n)}break;case 14:if(40===s){let t=w(oG,l);x(),t>=0?l=t:(b(15),l++)}else{let n=t.indexOf("(",l);-1===n&&(n=r),v(8,l,n)}break;case 15:if(41===s)x(),l++;else{let n=t.indexOf(")",l);-1===n&&(n=r),v(9,l,n)}break;case 16:if(34===s)b(17),v(7,l,l+1);else if(125===s)x(),l++;else if(94===s)c=!1;else{let n=l+1;for(;n<r;){let r=t.charCodeAt(n);if(125===r||94===r||34===r)break;n++}v(7,l,n)}break;case 17:if(34===s)x(),v(7,l,l+1);else{let s=t.indexOf('"',l);-1===s&&(s=r),n.push(7),i.push(t.slice(l,s).replace(oZ,"<br/>")),a.push(l),l=s}}if(!c)return n.push(1),i.push(""),a.push(l),{types:n,texts:i,starts:a}}return n.push(0),i.push(""),a.push(r),{types:n,texts:i,starts:a}}(n),c=0,u,h=r=>{let a=i[c],u=n===t?l[c]:o([s(t,o2,2)],l[c]);throw 1===a?d("flowchart",t,u,"",!0):d("flowchart",t,u,`Expecting ${r}, got '${oA[a]}'`)},f=(t,r="")=>(i[c]!==t&&h(`'${oA[t]}'${r?", "+r:""}`),a[c++]),p=()=>{let t=i[c];74!==t&&37!==t&&76!==t&&h("'SEMI', 'NEWLINE', 'EOF'"),c++},g=()=>{0===oX[i[c]]&&h("'NODE_STRING'");let t=a[c++];for(;1===oX[i[c]];)t+=a[c++];return t},m=()=>{0===oK[i[c]]&&h("'NODE_STRING'");let t=a[c++];for(;1===oK[i[c]];)t+=a[c++];return t},y=()=>{let t=i[c],r;if(11===t)r="string";else if(10===t)r="markdown";else{if(44!==t&&60!==t&&51!==t&&66!==t)return h(`${o0}, 'TAGEND', 'STR', 'MD_STR'`);r="text"}let n=a[c++];for(;;){let t=i[c];if(44!==t&&60!==t&&51!==t&&66!==t)break;n+=a[c++]}return{text:n,type:r}},v=t=>{f(t,o0)},b=()=>{let t=a[c++];for(;7===i[c];)t+=a[c++];return t},x=()=>{let t=(()=>{let t=g(),n;switch(i[c]){case 71:c++,n=y(),v(70),r.addVertex(t,n,"square");break;case 55:c++,n=y(),v(54),r.addVertex(t,n,"doublecircle");break;case 69:69===i[++c]?(c++,n=y(),v(68),f(68),r.addVertex(t,n,"circle")):(n=y(),v(68),r.addVertex(t,n,"round"));break;case 45:c++,n=y(),v(43),r.addVertex(t,n,"ellipse");break;case 47:c++,n=y(),v(46),r.addVertex(t,n,"stadium");break;case 49:c++,n=y(),v(48),r.addVertex(t,n,"subroutine");break;case 50:{c++;let i=f(64);f(35);let a=f(64);f(67),n=y(),v(70),r.addVertex(t,n,"rect",void 0,void 0,void 0,{[i]:a});break}case 53:c++,n=y(),v(52),r.addVertex(t,n,"cylinder");break;case 73:73===i[++c]?(c++,n=y(),v(72),f(72),r.addVertex(t,n,"hexagon")):(n=y(),v(72),r.addVertex(t,n,"diamond"));break;case 51:c++,n=y(),v(70),r.addVertex(t,n,"odd");break;case 58:c++,n=y(),57===i[c]?(c++,r.addVertex(t,n,"lean_right")):(v(56),r.addVertex(t,n,"trapezoid"));break;case 59:c++,n=y(),56===i[c]?(c++,r.addVertex(t,n,"lean_left")):(v(57),r.addVertex(t,n,"inv_trapezoid"));break;default:r.addVertex(t)}return t})();return 34===i[c]&&(c++,r.setClass(t,g())),t},w=()=>{let t=[x()];for(u=void 0;;){let n=7===i[c]?b():void 0;if(75!==i[c])return u=n,t;do c++;while(75===i[c]);if(36!==i[c])return void 0!==n&&h("'AMP'"),t;75!==i[++c]&&h("'SPACE'");do c++;while(75===i[c]);let a=x();void 0!==n&&r.addVertex(t[t.length-1],void 0,void 0,void 0,void 0,void 0,void 0,n),t.push(a)}},$=()=>{let t;if(31===i[c]&&(t=a[c++]),40===i[c]){let n=r.destructLink(a[c++]);return void 0!==t&&(n.id=t),67===i[c]&&(c++,n.text=y(),v(67),75===i[c]&&c++),n}if(41===i[c]){let n=a[c++],s=(()=>{let t=i[c],r;if(11===t)r="string";else if(10===t)r="markdown";else{if(42!==t&&66!==t)return h("'EDGE_TEXT', 'STR', 'MD_STR'");r="text"}let n=a[c++];for(;42===i[c]||66===i[c];)n+=a[c++];return{text:n,type:r}})(),o=f(40,"'EDGE_TEXT'"),l=r.destructLink(o,n);return l.text=s,void 0!==t&&(l.id=t),l}return h("'LINK', 'START_LINK'")},k=()=>{0===oQ[i[c]]&&h("'NODE_STRING', 'NUM', 'COLON', 'BRKT'");let t=a[c++];for(;1===oQ[i[c]];)t+=a[c++];return t},M=()=>{let t=[k()];for(;38===i[c];)c++,t.push(k());return t},_=(t,n)=>{if(75!==i[c])return void r.setLink(t,n);if(23===i[++c])return void r.setLink(t,n,a[c++]);let s=f(11,"'LINK_TARGET'");75===i[c]?(c++,r.setLink(t,n,f(23))):r.setLink(t,n),r.setTooltip(t,s)},A=()=>{let t=i[++c];if(74===t||37===t||76===t)return c++,{id:void 0,title:void 0,list:[],collect:!1};f(75,"'SEMI', 'NEWLINE', 'EOF'");let r=(()=>{let t=i[c],r;if(11===t)r="text";else if(10===t)r="markdown";else{if(1!==oJ[t])return h("'NODE_STRING', 'STR', 'MD_STR'");r="text"}let n=a[c++];for(;1===oJ[i[c]];)n+=a[c++];return{text:n,type:r}})(),n=r;return 71===i[c]&&(c++,n=y(),v(70)),74!==(t=i[c])&&37!==t&&76!==t&&h("'SEMI', 'NEWLINE', 'EOF', 'SQS'"),c++,{id:r,title:n,list:[],collect:!1}},E=t=>{let n=i[c];switch(n){case 12:{c++,f(75);let t=g();return f(75),r.addVertex(t,void 0,void 0,M()),p(),o1}case 14:return(()=>{let t;if(c++,f(75),13===i[c])t=[a[c++]];else for(t=[f(32,"'DEFAULT'")];38===i[c];)c++,t.push(f(32));if(f(75),15!==i[c])return r.updateLink(t,M());c++,f(75);let n=m();if(75===i[c]){c++;let i=M();r.updateLinkInterpolate(t,n),r.updateLink(t,i)}else r.updateLinkInterpolate(t,n)})(),p(),o1;case 16:{c++,f(75);let t=g();return f(75),r.addClass(t,M()),p(),o1}case 17:{c++,f(75);let t=g();return f(75),r.setClass(t,g()),p(),o1}case 19:return(()=>{let t=a[c++];switch(i[c]){case 8:{let n=a[c++],s=9===i[c],o=s?a[c++]:void 0,l;75===i[c]&&(c++,l=f(11)),s?r.setClickEvent(t,n,o):r.setClickEvent(t,n),void 0!==l&&r.setTooltip(t,l);return}case 18:c++,_(t,f(11));return;case 11:_(t,a[c++]);return;default:{let n=m();if(75===i[c]){c++;let i=f(11);r.setClickEvent(t,n),r.setTooltip(t,i)}else r.setClickEvent(t,n)}}})(),p(),o1;case 26:case 27:case 28:case 29:case 30:return c++,{stmt:"dir",value:o4[n-26]};case 2:{c++;let t=f(3).trim();return r.setAccTitle(t),t}case 4:{c++;let t=f(5).trim();return r.setAccDescription(t),t}case 6:{let t=a[c++].trim();return r.setAccDescription(t),t}default:{0===oX[n]&&h(o3);let a=(t=>{let n=w();void 0!==u&&r.addVertex(n[n.length-1],void 0,void 0,void 0,void 0,void 0,void 0,u);let a=n;for(;;){let s=i[c];if(40!==s&&41!==s&&31!==s)return a;let o=$(),l=w();void 0!==u&&r.addVertex(l[l.length-1],void 0,void 0,void 0,void 0,void 0,void 0,u),r.addLink(n,l,o),t&&(a=l.concat(a)),n=l}})(t);return p(),a}}};for(;75===i[c]||74===i[c];)c++;if(f(20,"'SPACE', 'NEWLINE'"),24===i[c])c++,r.setDirection("TB");else{let t=f(25,"'NODIR'"),n=i[c];if(75===n){do c++;while(75===i[c]);74!==(n=i[c])&&h("'NEWLINE', 'SPACE'")}else 37!==n&&74!==n&&h("'SEMI', 'NEWLINE', 'SPACE'");c++,r.setDirection(t)}(()=>{let t=[],n=[],s=!1;for(;;){let o=i[c];if(0===o)break;if(22===o){let i=t.pop();if(void 0===i)break;c++;let a=r.addSubGraph(i.id,n,i.title);n=i.list,(s=i.collect)&&n.push(a)}else if(37===o||74===o||75===o||76===o)s&&n.push(a[c]),c++;else if(21===o){let r=A();r.list=n,r.collect=s,t.push(r),n=[],s=!0}else{let t=E(s);s&&(!Array.isArray(t)||t.length>0)&&n.push(t)}}t.length>0&&h("'end'")})(),0!==i[c]&&h(o3)}(t,l),l},render:o9},le=["January","February","March","April","May","June","July","August","September","October","November","December"],lt=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function lr(t){return!Number.isNaN(t.getTime())}function ln(t,r){let n=String(t);return n.length>=r?n:"0".repeat(r-n.length)+n}function li(t){let r=["th","st","nd","rd"],n=t%100;return t+(r[(n-20)%10]||r[n]||r[0])}function la(t){let r=-(15*Math.round(t.getTimezoneOffset()/15));return 0===r?0:r}function ls(t){let r=la(t),n=Math.abs(r);return(r>=0?"+":"-")+ln(Math.floor(n/60),2)+":"+ln(n%60,2)}function lo(t){return t.getDay()||7}function ll(t,r){let n=new Date(t);return n.setDate(n.getDate()+r),n}function lc(t,r){let n,i=new Date(t);return i.setDate(1),r(i),i.setDate(Math.min(t.getDate(),((n=new Date(i.getFullYear(),i.getMonth()+1,0)).setHours(23,59,59,999),n.getDate()))),i}function ld(t,r,n){switch(n){case"M":return lc(t,n=>n.setMonth(t.getMonth()+r));case"y":return lc(t,n=>n.setFullYear(t.getFullYear()+r));case"d":return ll(t,Math.round(r));case"w":return ll(t,Math.round(7*r));case"h":return new Date(t.getTime()+36e5*r);case"m":return new Date(t.getTime()+6e4*r);case"s":return new Date(t.getTime()+1e3*r);default:return new Date(t.getTime()+r)}}function lu(t){return ll(t,4-lo(t))}function lh(t){let r=lu(t),n=new Date(r.getFullYear(),0,1),i=lo(n),a=ll(n,4-i+7*(i>4)),s=(la(a)-la(r))*6e4,o=(r.getTime()-a.getTime()-s)/6048e5;return(o<0?Math.ceil(o)||0:Math.floor(o))+1}var lf=/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g,lp=/\[([^\]]+)]|YYYY|YY|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g;function lg(t,r){if(!lr(t))return"Invalid Date";let n=r||"YYYY-MM-DDTHH:mm:ssZ";if("YYYY-MM-DD"===n)return lm(t);let i=!1,a=n.replace(lf,r=>{switch(r){case"Q":return String(Math.ceil((t.getMonth()+1)/3));case"Do":return"["+li(t.getDate())+"]";case"GGGG":return String(lu(t).getFullYear());case"W":return String(lh(t));case"WW":return ln(lh(t),2);case"k":return String(t.getHours()||24);case"kk":return ln(t.getHours()||24,2);case"X":return String(Math.floor(t.getTime()/1e3));case"x":return String(t.getTime());case"gggg":case"wo":case"w":case"ww":case"z":case"zzz":return i=!0,r;default:return r}});if(i)return;let s=t.getHours();return a.replace(lp,(r,n)=>{if(n)return n;switch(r){case"YY":return String(t.getFullYear()).slice(-2);case"YYYY":return ln(t.getFullYear(),4);case"M":return String(t.getMonth()+1);case"MM":return ln(t.getMonth()+1,2);case"MMM":return le[t.getMonth()].slice(0,3);case"MMMM":return le[t.getMonth()];case"D":return String(t.getDate());case"DD":return ln(t.getDate(),2);case"d":return String(t.getDay());case"dd":return lt[t.getDay()].slice(0,2);case"ddd":return lt[t.getDay()].slice(0,3);case"dddd":return lt[t.getDay()];case"H":return String(s);case"HH":return ln(s,2);case"h":return String(s%12||12);case"hh":return ln(s%12||12,2);case"a":return s<12?"am":"pm";case"A":return s<12?"AM":"PM";case"m":return String(t.getMinutes());case"mm":return ln(t.getMinutes(),2);case"s":return String(t.getSeconds());case"ss":return ln(t.getSeconds(),2);case"SSS":return ln(t.getMilliseconds(),3);case"Z":return ls(t);default:return ls(t).replace(":","")}})}function lm(t){let r=t.getFullYear(),n=t.getMonth()+1,i=t.getDate();return(r>=1e3&&r<=9999?r:ln(r,4))+(n<10?"-0":"-")+n+(i<10?"-0":"-")+i}var ly=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,lv=/\[[^\]]+]/g,lb=/\d/,lx=/\d\d/,lw=/\d\d?/,l$=/[+-]\d\d:?(\d\d)?|Z/,lk=/\d*[^-_:/,()\s\d]+/;function lM(t){return(r,n)=>(r[t]=+n,!0)}var l_=(t,r)=>{if("Z"===r)return t.offset=0,!0;let n=r.match(/([+-]|\d\d)/g),i=60*n[1]+(+n[2]||0);return t.offset=0===i?0:"+"===n[0]?-i:i,!0};function lA(t){return(r,n)=>{let i=t.indexOf(n)+1;return!(i<1)&&(r.month=i%12||i,!0)}}var lE,lS=new Map([["A",{re:lk,read:(t,r)=>(t.afternoon="PM"===r,!0)}],["a",{re:lk,read:(t,r)=>(t.afternoon="pm"===r,!0)}],["Q",{re:lb,read:(t,r)=>(t.month=(r-1)*3+1,!0)}],["S",{re:lb,read:(t,r)=>(t.milliseconds=100*r,!0)}],["SS",{re:lx,read:(t,r)=>(t.milliseconds=10*r,!0)}],["SSS",{re:/\d{3}/,read:(t,r)=>(t.milliseconds=+r,!0)}],["s",{re:lw,read:lM("seconds")}],["ss",{re:lw,read:lM("seconds")}],["m",{re:lw,read:lM("minutes")}],["mm",{re:lw,read:lM("minutes")}],["H",{re:lw,read:lM("hours")}],["h",{re:lw,read:lM("hours")}],["HH",{re:lw,read:lM("hours")}],["hh",{re:lw,read:lM("hours")}],["D",{re:lw,read:lM("day")}],["DD",{re:lx,read:lM("day")}],["Do",{re:lk,read:(t,r)=>{let n=r.match(/\d+/);if(!n)return!1;t.day=+n[0],t.dayGiven=!0;for(let n=1;n<=31;n++)li(n)===r&&(t.day=n);return!0}}],["w",{re:lw,read:lM("week")}],["ww",{re:lx,read:lM("week")}],["M",{re:lw,read:lM("month")}],["MM",{re:lx,read:lM("month")}],["MMM",{re:lk,read:lA(le.map(t=>t.slice(0,3)))}],["MMMM",{re:lk,read:lA(le)}],["Y",{re:/[+-]?\d+/,read:lM("year")}],["YY",{re:lx,read:(t,r)=>(t.year=+r+(+r>68?1900:2e3),!0)}],["YYYY",{re:/\d{4}/,read:lM("year")}],["Z",{re:l$,read:l_}],["ZZ",{re:l$,read:l_}]]),lC=null,lT=/^[YMDHhmsSZXx\-/.:, T]*$/,lI=/^\s*(active|done|crit|milestone|vert)\s*$/,lN=/^after\s+([\d\w- ]+)/,lO=/^until\s+([\d\w- ]+)/,lD=/^(\d+(?:\.\d+)?)([Mdhmswy]|ms)$/,lR=/[\s,]+/,lL=/^\d+$/,lz=new Set(lt.map(t=>t.toLowerCase()));function lP(t){let r=void 0===t?NaN:+t;return Number.isFinite(r)?r:Date.now()}function lj(t,r){let n=new Set(t);for(let t of r.toLowerCase().split(lR))""!==t&&n.add(t);return[...n]}var lF=class{type="gantt";title;accTitle;accDescr;dateFormat="";axisFormat="";tickInterval;todayMarker="";includes=[];excludes=[];inclusiveEndDates=!1;topAxis=!1;displayMode="";weekday;weekend="saturday";sections=[];links=new Map;tasks=[];byId=new Map;currentSection="";taskCount=0;lastOrder=0;lastTaskId;options;now=0;work=0;includeSet=new Set;excludeSet=new Set;excludedDays=[];datedTokens=!1;constructor(t={}){this.options=t}setDateFormat(t){this.dateFormat=t}enableInclusiveEndDates(){this.inclusiveEndDates=!0}TopAxis(){this.topAxis=!0}setAxisFormat(t){this.axisFormat=t}setTickInterval(t){this.tickInterval=t}setTodayMarker(t){this.todayMarker=t}setIncludes(t){this.includes=lj(this.includes,t)}setExcludes(t){this.excludes=lj(this.excludes,t)}setWeekday(t){this.weekday=t}setWeekend(t){this.weekend=t}setDiagramTitle(t){this.title=t}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
|
|
75
|
+
`)}addSection(t){this.currentSection=t,this.sections.push(t)}addTask(t,r){let n=(r.startsWith(":")?r.slice(1):r).split(","),i={id:"",task:t,section:this.currentSection,startTime:void 0,endTime:void 0,renderEndTime:null,manualEndTime:!1,processed:!1,active:!1,done:!1,crit:!1,milestone:!1,vert:!1,order:-1,classes:[],prevTaskId:this.lastTaskId,raw:{data:r,start:void 0,end:""}},s;for(;n.length>0&&null!==(s=lI.exec(n[0]));)i[s[1]]=!0,n.shift();if(0===n.length)throw new a(`Task "${t.trim()}" needs a duration or an end date.`,"semantic",{type:"gantt"});if(n.length>3)throw new a(`Task "${t.trim()}" has too many fields. A task takes an id, a start, and an end or duration.`,"semantic",{type:"gantt"});for(let t=0;t<n.length;t++)n[t]=n[t].trim();3===n.length?i.id=n[0]:(this.taskCount++,i.id="task"+this.taskCount),n.length>1&&(i.raw.start=n[n.length-2]),i.raw.end=n[n.length-1],i.vert||(i.order=this.lastOrder++),this.tasks.push(i),this.lastTaskId=i.id,this.byId.set(i.id,i)}setLink(t,r){let n=tw(r);for(let r of t.split(","))this.byId.has(r)&&this.links.set(r,n);this.setClass(t,"clickable")}setClickEvent(t,r,n){this.setClass(t,"clickable")}setClass(t,r){for(let n of t.split(","))this.byId.get(n)?.classes.push(r)}getTasks(t){this.now=lP(t),this.work=0,this.includeSet=new Set(this.includes),this.excludeSet=new Set(this.excludes);let r="friday"===this.weekend?5:"saturday"===this.weekend?6:NaN,n=this.excludeSet.has("weekends");for(let t of(this.excludedDays=lt.map((t,i)=>{let a=i||7;return n&&(a===r||a===r+1)||this.excludeSet.has(t.toLowerCase())}),this.datedTokens=this.includes.length>0||!lT.test(this.dateFormat.trim()),this.excludes))"weekends"===t||lz.has(t)||(this.datedTokens=!0);for(let t of this.tasks)t.startTime=t.endTime=void 0,t.renderEndTime=null,t.processed=t.manualEndTime=!1;let i=this.compileTasks();for(let t=0;!i&&t<10;t++)i=this.compileTasks();return this.tasks}isInvalidDate(t){let r=this.excludedDays[t.getDay()];if(!this.datedTokens)return r;let n=this.dateFormat.trim(),i=lm(t),a=i;this.spend(200),"YYYY-MM-DD"!==n&&(this.spend(400+8*n.length),a=lg(t,n));let s=t=>t.has(i)||void 0!==a&&t.has(a);return!s(this.includeSet)&&(r||s(this.excludeSet))}spend(t){if(this.work+=t,this.work>4e8)throw new a("The gantt chart takes too much work to schedule.","limit",{type:"gantt"})}parse(t,r){let n;return this.spend((r.length+1)*(t.length+1)),(n=function(t,r,n){if("x"===r||"X"===r)return new Date(("X"===r?1e3:1)*Number(t));let i=function(t){if(t===lE)return lC;if(lE=t,lC=null,/[Ll]/.test(t.replace(lv,"")))return null;let r=t.match(ly);return r?lC=r.map(t=>lS.get(t)??t.replace(/^\[|\]$/g,"")):null}(r);if(!i)return;let a={},s=t,o=0;for(let t of i){if("string"==typeof t){o+=t.length;continue}let r=t.re.exec(s.slice(o));if(!r||!t.read(a,r[0]))return;s=s.replace(r[0],"")}void 0!==a.afternoon&&void 0!==a.hours&&(a.afternoon?a.hours<12&&(a.hours+=12):12===a.hours&&(a.hours=0));let l=a.dayGiven||a.day?a.day:a.year||a.month?1:n.getDate(),c=a.year||n.getFullYear(),d=0;a.year&&!a.month||(d=a.month>0?a.month-1:n.getMonth());let u=a.hours||0,h=a.minutes||0,f=a.seconds||0,p=a.milliseconds||0;return void 0!==a.offset?new Date(Date.UTC(c,d,l,u,h,f,p+6e4*a.offset)):a.week?void 0:new Date(c,d,l,u,h,f,p)}(t,r,new Date(this.now)))&&lr(n)&&lg(n,r)===t?n:void 0}today(){let t=new Date(this.now);return t.setHours(0,0,0,0),t}warn(t){this.options.warn&&this.options.warn(t())}compileTasks(){let t=!0;for(let r of this.tasks)this.compileTask(r),t=t&&r.processed;return t}compileTask(t){let r=t.raw.start;if(void 0===r){let r=void 0===t.prevTaskId?void 0:this.byId.get(t.prevTaskId);t.startTime=r?r.endTime:this.today()}else{let n=this.getStartDate(r);n&&(t.startTime=n)}t.startTime&&(t.endTime=this.getEndDate(t.startTime,t.raw.end),t.endTime&&(t.processed=!0,t.manualEndTime=void 0!==this.parse(t.raw.end,"YYYY-MM-DD"),this.checkTaskDates(t)))}references(t,r){let n=[],i;for(let t of r.split(" ")){if(""===t)continue;let r=this.byId.get(t);r?n.push(r):(i??=[]).push(t)}return i&&this.warn(()=>`Gantt: "${t}" refers to task ids that do not exist: ${i.join(", ")}.`),n}getStartDate(t){let r=t.trim(),n=this.dateFormat.trim();if(("x"===n||"X"===n)&&lL.test(r))return this.checked(new Date(Number(r)),r);let i=lN.exec(r);if(null!==i){let t;for(let r of this.references("after",i[1]))(!t||r.endTime>t.endTime)&&(t=r);return t?t.endTime:this.today()}let s=this.parse(r,n);if(s)return s;let o=new Date(r);if(!lr(o)||-1e4>o.getFullYear()||o.getFullYear()>1e4)throw new a("Invalid date:"+r,"semantic",{type:"gantt"});return o}checked(t,r){if(!lr(t))throw new a("Invalid date:"+r,"semantic",{type:"gantt"});return t}getEndDate(t,r){let n,i=r.trim(),a=lO.exec(i);if(null!==a){let t;for(let r of this.references("until",a[1]))(!t||r.startTime<t.startTime)&&(t=r);return t?t.startTime:this.today()}let s=this.dateFormat.trim(),o=this.parse(i,s);if(o)return this.inclusiveEndDates?ll(o,1):o;let[l,c]=(n=lD.exec(i.trim()))?[Number.parseFloat(n[1]),n[2]]:[NaN,"ms"];if(Number.isNaN(l))return this.warn(()=>`Gantt: "${i}" is neither a date in the "${s}" format nor a duration such as "3d", so the task gets no duration.`),new Date(t);let d=ld(t,l,c);return lr(d)?d:new Date(t)}checkTaskDates(t){if(0===this.excludes.length||t.manualEndTime)return;let r=ll(t.startTime,1),n=new Date(t.endTime),i=+ll(n,1e4),s=!1,o=null;for(;+r<=+n;){if(this.spend(400),s||(o=+n),(s=this.isInvalidDate(r))&&(n.setDate(n.getDate()+1),+n>i))throw new a("Failed to find a valid date that was not excluded by `excludes` after 10,000 iterations.","semantic",{type:"gantt"});r.setDate(r.getDate()+1)}t.endTime=n,t.renderEndTime=null===o?null:new Date(o)}},lB=["$end","INVALID","open_directive","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","NL","href","callbackname","callbackargs","click","gantt","dateFormat","inclusiveEndDates","topAxis","axisFormat","tickInterval","includes","excludes","todayMarker","weekday_monday","weekday_tuesday","weekday_wednesday","weekday_thursday","weekday_friday","weekday_saturday","weekday_sunday","weekend_friday","weekend_saturday","date","title","accDescription","section","taskTxt","taskData",":","EOF"],lW=/accTitle\s*:\s*/iy,lH=/accDescr\s*:\s*/iy,lU=/accDescr\s*\{\s*/iy,lq=/href\s+"/iy,lV=/call\s+/iy,lY=/click\s+/iy,lG=/\(\s*\)/y,lZ=/weekday\s+(monday|tuesday|wednesday|thursday|friday|saturday|sunday)\b/iy,lX=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],lK=/weekend\s+(?:(friday)|saturday)\b/iy,lJ=/\d\d\d\d-\d\d-\d\d\b/y,lQ=/title[^\S\r\n]*(?=[\r\n]|$)/iy,l0=new Map([[97,[[/axisFormat\s[^#\n;]+/iy,17],[/accDescription\s[^#\n;]+/iy,33]]],[103,[[/gantt\b/iy,13]]],[100,[[/dateFormat\s[^#\n;]+/iy,14]]],[105,[[/inclusiveEndDates\b/iy,15],[/includes\s[^#\n;]+/iy,19]]],[116,[[/topAxis\b/iy,16],[/tickInterval\s[^#\n;]+/iy,18],[/todayMarker\s[^\n;]+/iy,21],[/title[^\S\r\n][^\n]+/iy,32]]],[101,[[/excludes\s[^#\n;]+/iy,20]]],[115,[[/section\s[^\n]+/iy,34]]]]),l1=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],l2="'EOF', 'SPACE', 'NL', 'weekday_monday', 'weekday_tuesday', 'weekday_wednesday', 'weekday_thursday', 'weekday_friday', 'weekday_saturday', 'weekday_sunday', 'weekend_friday', 'weekend_saturday', 'dateFormat', 'inclusiveEndDates', 'topAxis', 'axisFormat', 'tickInterval', 'excludes', 'includes', 'todayMarker', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'section', 'taskTxt', 'click'",l4=new Uint8Array(39);for(let t=22;t<=30;t++)l4[t]=1;for(let t of[38,8,14,15,16,17,18,20,19,21,32,3,5,7,34,35,12])l4[t]=1;function l3(t){t.setHours(0,0,0,0)}function l5(t){return{floor(r){r.setDate(r.getDate()-(r.getDay()+7-t)%7),l3(r)},offset:(t,r)=>t.setDate(t.getDate()+7*r),cycle:1/0,ms:6048e5}}var l6={millisecond:{floor:()=>{},offset:(t,r)=>t.setTime(+t+r),cycle:1/0,ms:1},second:{floor:t=>t.setTime(t-t.getMilliseconds()),offset:(t,r)=>t.setTime(+t+1e3*r),field:t=>t.getUTCSeconds(),cycle:60,ms:1e3},minute:{floor:t=>t.setTime(t-t.getMilliseconds()-1e3*t.getSeconds()),offset:(t,r)=>t.setTime(+t+6e4*r),field:t=>t.getMinutes(),cycle:60,ms:6e4},hour:{floor:t=>t.setTime(t-t.getMilliseconds()-1e3*t.getSeconds()-6e4*t.getMinutes()),offset:(t,r)=>t.setTime(+t+36e5*r),field:t=>t.getHours(),cycle:24,ms:36e5},day:{floor:l3,offset:(t,r)=>t.setDate(t.getDate()+r),field:t=>t.getDate()-1,cycle:31,ms:864e5},month:{floor(t){t.setDate(1),l3(t)},offset:(t,r)=>t.setMonth(t.getMonth()+r),field:t=>t.getMonth(),cycle:12,ms:2592e6},year:{floor(t){t.setMonth(0,1),l3(t)},offset:(t,r)=>t.setFullYear(t.getFullYear()+r),cycle:1/0,ms:31536e6}};function l8(t,r,n){return Math.floor((r-t-(r.getTimezoneOffset()-t.getTimezoneOffset())*6e4)/n)}function l9(t,r,n){let i="week"===t?l5(n):l6[t];if(r<=1)return i;if("millisecond"===t)return{...i,floor:t=>t.setTime(Math.floor(t/r)*r),offset:(t,n)=>t.setTime(+t+n*r)};if("year"===t)return{...i,floor(t){t.setFullYear(Math.floor(t.getFullYear()/r)*r),i.floor(t)},offset:(t,n)=>t.setFullYear(t.getFullYear()+n*r)};if("week"===t){let t=new Date(0);return i.floor(t),{...i,floor(n){i.floor(n),i.offset(n,-((l8(t,n,6048e5)%r+r)%r))},offset:(t,n)=>i.offset(t,n*r)}}let a=i.field,s=t=>a(t)%r==0;return{...i,floor(t){for(i.floor(t);Number.isFinite(+t)&&!s(t);i.floor(t))t.setTime(t-1)},offset(t,r){for(let n=0;n<r&&Number.isFinite(+t);n++)do i.offset(t,1);while(Number.isFinite(+t)&&!s(t))}}}function l7(t,r,n,i){let a=new Date(r-1);t.floor(a),t.offset(a,1),t.floor(a);let s=[],o=-1/0;for(;+a<=n&&+a>o;){if(s.length>=i)return;o=+a,s.push(o),t.offset(a,1),t.floor(a)}return s}function ce(t,r,n){let i=(r-t)/Math.max(0,n),a=Math.floor(Math.log10(i)),s=i/Math.pow(10,a);return Math.pow(10,a)*(s>=Math.sqrt(50)?10:s>=Math.sqrt(10)?5:s>=Math.SQRT2?2:1)}var ct=[["second",1,1e3],["second",5,5e3],["second",15,15e3],["second",30,3e4],["minute",1,6e4],["minute",5,3e5],["minute",15,9e5],["minute",30,18e5],["hour",1,36e5],["hour",3,108e5],["hour",6,216e5],["hour",12,432e5],["day",1,864e5],["day",2,1728e5],["week",1,6048e5],["month",1,2592e6],["month",3,7776e6],["year",1,31536e6]],cr=/^([1-9]\d*)(millisecond|second|minute|hour|day|week|month)$/,cn=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function ci(t,r,n){let i=t<0?"-":"",a=String(i?-t:t);return i+(a.length<n?r.repeat(n-a.length)+a:a)}function ca(t,r){let n=new Date(+t);return r.floor(n),n}function cs(t,r){let n=l5(r),i=ca(t,l6.year);return l8(ca(new Date(i-1),n),ca(t,n),6048e5)}function co(t){let r=l5(4),n=t.getDay(),i=ca(n>=4||0===n?t:new Date(t-1),r);return n>=4||0===n||(r.offset(i,1),r.floor(i)),i}var cl=new Map([["-",""],["_"," "],["0","0"]]),cc=/<br\s*\/?>/gi;function cd(t,r,n,i){let a=t.gantt?.[r];return"number"==typeof a&&Number.isFinite(a)?Math.min(i,Math.max(n,a)):void 0}function cu(t,r){let n=t.gantt?.[r];return"string"==typeof n?n:void 0}function ch(t,r,n){let i=n7(t.replace(cc," "),!1,r,n,4e3);return i.lines.length<=1?i:{...i,lines:[i.lines[0]],widths:[i.widths[0]],width:i.widths[0],height:i.lineHeight}}function cf(t){return Number.isFinite(+t.startTime)&&Number.isFinite(+t.endTime)}function cp(t){throw new a(t,"semantic",{type:"gitGraph"})}function cg(t){return"REVERSE"===t?1:2*("HIGHLIGHT"===t)}var cm={name:"REFERENCE",pattern:/\w([-\./\w]*[-\w])?/y},cy=[cm];function cv(t){return{name:t,pattern:t,longer:cy}}var cb=[cv("cherry-pick"),{name:"gitGraph:",pattern:"gitGraph:"},cv("HIGHLIGHT"),{...iP("gitGraph"),longer:cy},cv("checkout"),cv("REVERSE"),{name:"parent:",pattern:"parent:"},cv("commit"),cv("NORMAL"),cv("branch"),{name:"order:",pattern:"order:"},cv("switch"),{name:"type:",pattern:"type:"},cv("merge"),{name:"msg:",pattern:"msg:"},{name:"tag:",pattern:"tag:"},{name:"id:",pattern:"id:"},cv("LR"),cv("TB"),cv("BT"),{name:":",pattern:":"},{...iS,opener:/[\t ]*accDescr\s*{/y},iC,iI(String.raw`[-./\w]*[-\w]`),{name:"INT",pattern:/0|[1-9][0-9]*(?!\.)/y},iN,iO,iD,iR,iL,iz,cm],cx=/<(?!br\s*\/?>)/gi,cw=/:fa-/g,c$=/<br\s*\/?>|fl°°?\w+¶ß|&#?\w+;|[\ud800-\udbff][\udc00-\udfff]|[\s\S]/gi;function ck(t,r,n,i,a=0){let s=t;return void 0!==s&&(s.includes("<")&&(s=s.replace(cx,"<")),s.includes(":fa-")&&(s=s.replace(cw,":fa-"))),n7(s,!1,r,n,i,a)}function cM(t,r,n,i,a=0){let s=ck(t,r,n,i,a);if(void 0===t||s.width<=i)return s;let o="",l=0;for(let s of t.match(c$)??[]){if(""===s.trim()||s.length>2&&"<"===s[0])l=0;else{let t=r.width(s.length>2?"x":s,n,a);l>0&&l+t>i&&(o+=`
|
|
76
|
+
`,l=0),l+=t}o+=s}return ck(o,r,n,i,a)}var c_=Math.SQRT1_2,cA=["normal","reverse","highlight","merge","cherry-pick"];function cE(t,r,n){let i=t.gitGraph?.[r];return"boolean"==typeof i?i:n}function cS(t){return 11+t.width+6}function cC(t,r,n,i){let a=n.fontSize??16,s=Math.round(.75*a),o=n.measurer??e$(n.fontFamily,n.fontFamilyMono),l=n.padding??8,c=cE(r,"showBranches",!0),d=cE(r,"showCommitLabel",!0),u=cE(r,"rotateCommitLabel",!0),h=cE(r,"parallelCommits",!1),f="LR"!==i,p="BT"===i,g=new Map;t.lanes.forEach((t,r)=>g.set(t,r));let m=t.lanes.length,y=Math.round(.875*a),v=t.lanes.map(t=>ck(c?t:"",o,y,4e3)),b=[],x=new Map;for(let r of[...t.commits.values()].sort((t,r)=>t.seq-r.seq)){let t=d&&4!==r.type&&(3!==r.type||!0===r.customId),n=[];for(let t of r.tags){let r=ck(t,o,s,4e3);r.lines.length>0&&n.push(r)}let i={commit:r,index:b.length,lane:g.get(r.branch)??0,m:0,label:t?ck(r.id,o,s,4e3):void 0,tags:n};b.push(i),x.set(r.id,i)}let w=new Float64Array(b.length),$=new Float64Array(b.length),k=new Float64Array(m).fill(7),M=new Float64Array(m).fill(7);b.forEach((t,r)=>{let{label:n,tags:i}=t,a=0,s=0;for(let t of i){let r=cS(t);f?(a=Math.max(a,t.height),s+=r+4):(a=Math.max(a,r),s+=t.height+3)}let o=0,l=0;void 0!==n&&n.lines.length>0&&(u?l=3+c_*(n.width+n.height):(o=f?n.height:n.width,l=6+(f?n.width:n.height))),w[r]=Math.max(7,a/2,o/2),$[r]=a/2;let c=7+(i.length>0?6+s:0),d=7+l,h=t.lane;k[h]=Math.max(k[h],f?d:c),M[h]=Math.max(M[h],f?c:d)});let _=new Float64Array(b.length);f||b.forEach((t,r)=>{if(0!==$[r])for(let n of t.commit.parents){let i=x.get(n);void 0!==i&&i.lane<t.lane&&(_[r]=$[r]+4)}});let A=(t,r)=>Math.max(44,w[t]+w[r]+8,_[r]>0?w[t]+36+_[r]:0);b.forEach((t,r)=>{if(!h){t.m=0===r?0:b[r-1].m+A(r-1,r);return}let n=0;for(let i of t.commit.parents){let t=x.get(i);void 0===t||t.index>=r||(n=Math.max(n,t.m+A(t.index,r)))}t.m=n});let E=0;for(let t of b)E=Math.max(E,t.m);let S=new Float64Array(m);for(let t=0;t<m;t++){let r=v[t],n=0===r.lines.length?0:f?r.width/2+8:r.height/2+2;k[t]=Math.max(k[t],n),M[t]=Math.max(M[t],n),t>0&&(S[t]=S[t-1]+Math.max(44,M[t-1]+k[t]+8))}let C=(t,r)=>f?r:t,T=(t,r)=>f?p?-t:t:r,I=(t,r)=>`${eT(C(t,r))},${eT(T(t,r))}`,N=1/0,O=1/0,D=-1/0,R=-1/0,L=(t,r,n,i)=>{t<N&&(N=t),r<O&&(O=r),n>D&&(D=n),i>R&&(R=i)},z="";if(c)for(let r=0;r<m;r++){let n=v[r],i=nu(r),a=S[r],s=n.width+16,o=n.height+4,l=0===n.lines.length?-20:-20-(f?o:s),c=C(l+(f?o:s)/2,a),d=T(l+(f?o:s)/2,a);L(C(-20,a),T(-20,a),C(-20,a),T(-20,a)),L(C(E+20,a),T(E+20,a),C(E+20,a),T(E+20,a)),z+=`<g class="pele-branch" data-id="${eS(t.lanes[r])}"><path class="pele-lane" d="M${I(-20,a)}L${I(E+20,a)}" stroke="${i}" stroke-dasharray="2 4"/>`,n.lines.length>0&&(L(c-s/2,d-o/2,c+s/2,d+o/2),z+=`<rect x="${eT(c-s/2)}" y="${eT(d-o/2)}" width="${eT(s)}" height="${eT(o)}" fill="${i}"${r5}/>`+eI(n,c,d,' class="pele-label"'+(ts(r)||' fill="var(--_bg)"'))),z+="</g>"}let P=Array.from({length:m},()=>[]);for(let t of b)P[t.lane].push(t.m);if(h)for(let t of P)t.sort((t,r)=>t-r);let j=(t,r,n)=>{let i=P[t],a=0,s=i.length;for(;a<s;){let t=a+s>>1;i[t]<=r?a=t+1:s=t}return a<i.length&&i[a]<n},F="",B="";for(let t of b){let{commit:r}=t,n=S[t.lane],i=t.m;for(let a=0;a<r.parents.length;a++){let s=x.get(r.parents[a]);if(void 0===s||s===t)continue;let o=S[s.lane],l=s.m;if(s.lane===t.lane){B+=`<path class="pele-edge" d="M${I(l,o)}L${I(i,n)}" stroke="${nu(t.lane)}"/>`;continue}let c=a>0&&3===r.type,d=a>0&&!c,u=`M${I(l,o)}`;if(i<=l){let t=(l+i)/2;u+=`C${I(t,o)} ${I(t,n)} ${I(i,n)}`}else if(c||j(t.lane,l,i)){let r=s.lane<t.lane&&i-_[t.index]>l?i-_[t.index]:i,a=Math.min(36,r-l),d=o;(!c||j(s.lane,l,i))&&(d=o>n?n+M[t.lane]+4:n-k[t.lane]-4,a=Math.min(36,(r-l)/2),u+=`C${I(l+a/2,o)} ${I(l+a/2,d)} ${I(l+a,d)}`),u+=`L${I(r-a,d)}C${I(r-a/2,d)} ${I(r-a/2,n)} ${I(r,n)}`,r<i&&(u+=`L${I(i,n)}`)}else{let t=Math.min(36,i-l);u+=`C${I(l+t/2,o)} ${I(l+t/2,n)} ${I(l+t,n)}L${I(i,n)}`}F+=`<path class="pele-edge${c?" pele-edge-merge":d?" pele-edge-cherry-pick":""}" d="${u}" stroke="${nu(c?s.lane:t.lane)}"${d?' stroke-dasharray="4 3"':""}/>`}}let W="";for(let t of b){let{commit:r,label:n,tags:i}=t,a=C(t.m,S[t.lane]),s=T(t.m,S[t.lane]),o=r.customType??r.type;L(a-7-1,s-7-1,a+7+1,s+7+1);let l=r.type<3&&""!==r.message?`<title>${eS(r.message)}</title>`:"";if(l+=function(t,r,n,i){let a=`cx="${eT(r)}" cy="${eT(n)}"`;if(2===t)return`<rect x="${eT(r-7-1)}" y="${eT(n-7-1)}" width="16" height="16" rx="2" fill="${i}"/>`;if(3===t)return`<circle ${a} r="6" fill="var(--_bg)" stroke="${i}" stroke-width="2"/><circle ${a} r="2.5" fill="${i}"/>`;let s=`<circle ${a} r="7" fill="${i}"/>`;return 1===t?s+`<path d="M${eT(r-3)},${eT(n-3)}l6,6M${eT(r-3)},${eT(n+3)}l6,-6" fill="none" stroke="var(--_bg)" stroke-width="1.5" stroke-linecap="round"/>`:4===t?s+`<path d="M${eT(r-2.6)},${eT(n+1)}L${eT(r+.8)},${eT(n-4.2)}L${eT(r+2.6)},${eT(n+1)}" fill="none" stroke="var(--_bg)" stroke-linejoin="round"/><circle cx="${eT(r-2.6)}" cy="${eT(n+2.2)}" r="1.8" fill="var(--_bg)"/><circle cx="${eT(r+2.6)}" cy="${eT(n+2.2)}" r="1.8" fill="var(--_bg)"/>`:s}(o,a,s,nu(t.lane)),void 0!==n&&n.lines.length>0){let t=n.width,r=n.height,i=(n,i)=>`<rect x="${eT(n-t/2-2)}" y="${eT(i-r/2+2)}" width="${eT(t+4)}" height="${eT(r-4)}" rx="3" fill="var(--_bg)"/>`;if(u){let o=c_*r/2,c=f?a-7-3-o:a+3,d=f?s:s+7+3+o,u=c_*t+o;L(c-u,p?d-u:d-o,c+o,p?d+o:d+u),l+=`<g class="pele-commit-label" transform="rotate(${p?45:-45} ${eT(c)} ${eT(d)})">`+i(c-t/2,d)+eI(n,c-t/2,d,"")+"</g>"}else{let o=f?a-7-6-t/2:a,c=f?s:s+7+6+r/2;L(o-t/2,c-r/2,o+t/2,c+r/2),l+=`<g class="pele-commit-label">${i(o,c)}${eI(n,o,c,"")}</g>`}}let c=13;for(let t=f?0:i.length-1;t>=0&&t<i.length;t+=f?1:-1){let r=i[t],n=cS(r),o=r.height,d=f?a+c:a-n/2,u=f?s:s-c-o/2;c+=f?n+4:o+3,L(d,u-o/2,d+n,u+o/2),l+=`<g class="pele-tag"><path d="M${eT(d)},${eT(u)}L${eT(d+7)},${eT(u-o/2)}H${eT(d+n)}V${eT(u+o/2)}H${eT(d+7)}Z" fill="var(--_s)" stroke="var(--_b)" stroke-linejoin="round"/><circle cx="${eT(d+7)}" cy="${eT(u)}" r="1.5" fill="var(--_b)"/>`+eI(r,d+7+4+r.width/2,u,' fill="var(--_fg)"')+"</g>"}let d=3===r.type&&3!==o?" pele-commit-merge":"";W+=`<g class="pele-commit pele-commit-${cA[o]??cA[0]}${d}" data-id="${eS(r.id)}">${l}</g>`}N>D&&L(0,0,0,0);let H=n7(t.title,!1,o,a,4e3,1),U=H.height>0?H.height+16:0,q=Math.max(D-N,H.width),V=Math.ceil(q+2*l),Y=Math.ceil(R-O+U+2*l),G=l-N+(q-(D-N))/2,Z=l+U-O,X=eI(H,V/2,l+H.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${eT(G)},${eT(Z)})">`+(z?`<g class="pele-branches" fill="none" font-size="${y}">${z}</g>`:"")+(F||B?`<g class="pele-edges" fill="none" stroke-width="2" stroke-linecap="round">${F}${B}</g>`:"")+(W?`<g class="pele-commits" font-size="${s}" fill="var(--_m)">${W}</g>`:"")+"</g>";return{svg:np("gitGraph",V,Y,a,n,t,X),width:V,height:Y,links:[]}}var cT=[iP("showInfo"),iP("info"),iS,iC,iT,iO,iD,iR,iL,iz],cI=class{type="ishikawa";title;root;stack=[];baseLevel;addNode(t,r){let n={text:r,children:[]};if(!this.root){this.root=n,this.stack=[{level:0,node:n}];return}this.baseLevel??=t;let i=Math.max(t-this.baseLevel+1,1),a=this.stack;for(;a.length>1&&a[a.length-1].level>=i;)a.pop();a[a.length-1].node.children.push(n),a.push({level:i,node:n})}},cN=["$end","EOF","SPACELINE","NL","ISHIKAWA","SPACELIST","TEXT"],cO="'SPACELINE', 'NL', 'EOF'",cD=Math.hypot(.5,1);function cR(t){let r=new Set;for(let n of t)for(let t of n.people)r.add(t);return[...r].sort()}var cL=class{type="journey";title;accTitle;accDescr;sections=[];tasks=[];currentSection="";setDiagramTitle(t){this.title=t}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
|
|
77
|
+
`)}addSection(t){this.currentSection=t,this.sections.push(t)}addTask(t,r){let n=r.substring(1).split(":"),i=1===n.length?[]:n[1].split(",").map(t=>t.trim());this.tasks.push({task:t,score:Number(n[0]),people:i,section:this.currentSection})}getActors(){return cR(this.tasks)}};function cz(t,r){let n=t.indexOf(`
|
|
78
|
+
`,r);return -1===n?t.length:n}function cP(t,r,n){for(let i=0;i<n.length;i++)if((32|t.charCodeAt(r+i))!==n.charCodeAt(i))return!1;return!0}function cj(t,r){let n=t.length,i=r;for(;i<n;){let r=t.charCodeAt(i);if(37===r&&123!==t.charCodeAt(i+1))i=cz(t,i);else{if(10===r)return i;if(V(r))do i++;while(i<n&&V(t.charCodeAt(i)));else if(35===r)i=cz(t,i);else break}}return i}function cF(t,r){let n=r;for(;V(t.charCodeAt(n));)n++;return n}function cB(t,r,n,i){let a=cP(t,r,"accdescr");if(!a&&!cP(t,r,"acctitle"))return r;let s=t.length,o=cF(t,r+8),l=t.charCodeAt(o),c=(r,i,a)=>{n.types.push(r),n.texts.push(t.slice(i,a)),n.starts.push(i)};if(58===l){o=cF(t,o+1);let n=cz(t,o);return c(a?i+2:i,r,o),c(a?i+3:i+1,o,n),n}if(!a||123!==l)return r;for(o=cF(t,o+1);125!==t.charCodeAt(o);){let r=t.indexOf("}",o);if(-1===r&&(r=s),c(i+4,o,r),o===s)return s;o=r}return o+1}var cW=["$end","EOF","INVALID","NEWLINE","journey","title","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","section","taskName","taskData",":"];function cH(t,r,n){let i=t.length,a=r;for(;a<i;a++){let r=t.charCodeAt(a);if(35===r||10===r||59===r||n&&58===r)break}return a}var cU={happy:"M-5,2A6,6 0 0 0 5,2",neutral:"M-4.5,4.5H4.5",sad:"M-5,6.5A6,6 0 0 1 5,6.5"};function cq(t,r,n){return`<g class="pele-face pele-face-${n}" transform="translate(${eT(t)},${eT(r)})"><circle r="11" fill="var(--_bg)" stroke="var(--_l)"/><g fill="var(--_l)"><circle cx="-3.6" cy="-2.8" r="1.3"/><circle cx="3.6" cy="-2.8" r="1.3"/></g><path d="${cU[n]}" fill="none" stroke="var(--_l)" stroke-linecap="round"/></g>`}var cV=["1","INVALID","SPACELINE","NL","EOF","","SPACELIST","ICON","CLASS","NODE_DSTART","NODE_ID","NODE_DESCR","NODE_DEND","SHAPE_DATA"];function cY(t,r){return 5===t?r?"KANBAN":"MINDMAP":cV[t]}function cG(t,r){switch(t){case"[":return 2;case"(":return")"===r?1:4;case"((":return 3;case")":return 4;case"))":return 5;case"{{":return 6;default:return 0}}var cZ=/\s+/y,cX=/.+/y,cK=/[^([\n){}]+/y,cJ=/[^([\n){}@]+/y,cQ=/[^)\](}]+/y,c0=/[^`"]+/y,c1=/[^}^"]+/y,c2=/\n\s*/g;function c4(t,r,n){for(let i=0;i<n.length;i++)if((32|t.charCodeAt(r+i))!==n.charCodeAt(i))return!1;return!0}var c3="'SPACELINE', 'NL', 'EOF'",c5=new Uint8Array(14);for(let t of[2,6,7,8,9,10])c5[t]=1;function c6(t){return 2===t||3===t||4===t}function c8(t,r,n){let i=n?"kanban":"mindmap",{types:a,texts:s,starts:o}=function(t,r){let n=t.length,i=[],a=[],s=[],o=r?"kanban":"mindmap",l=r?cJ:cK,c=0,d=0,u=-1,h=(t,r,n)=>{i.push(t),a.push(r),s.push(d),d=n},f=(r,n,i)=>{h(r,t.slice(d,n),n),c=i},p=(r,n)=>(r.lastIndex=n,r.test(t)?r.lastIndex:-1),g=r=>{let i=t.indexOf(r,d);return -1===i?n:i};for(;d<n;){let n=t.charCodeAt(d),i=t.charCodeAt(d+1),a;if(0===c){let s=n<=32||n>=160?Math.max(p(cZ,d),d):d;if(r&&64===n&&123===i)h(13,"",d+2),c=6;else if(37===t.charCodeAt(s)&&37===t.charCodeAt(s+1))f(2,p(cX,s),0);else if(s>d)u<d&&(u=g(`
|
|
79
|
+
`)),u>=s?f(6,s,0):(a=t.lastIndexOf(`
|
|
80
|
+
`,s-1))>d?f(2,a+1,0):f(3,d+1,0);else if(c4(t,d,o)&&!J(t.charCodeAt(d+o.length)))f(5,d+o.length,0);else if(58===n&&58===i&&58===t.charCodeAt(d+2))d+=3,c=1;else if(58===n&&58===i&&c4(t,d+2,"icon")&&40===t.charCodeAt(d+6))d+=7,c=2;else if(45===n&&41===i||40===n&&(45===i||40===i)||(41===n||123===n)&&i===n)f(9,d+2,3);else if(41===n||40===n||91===n)f(9,d+1,3);else if(-1!==(a=p(l,d)))f(10,a,0);else break}else if(3===c)34===n?(c=96===i?5:4,d+=96===i?2:1):41===n||40===n?f(12,i===n||40===n&&45===i?d+2:d+1,0):93===n?f(12,d+1,0):125===n&&125===i||45===n&&41===i?f(12,d+2,0):f(11,p(125===n?cX:cQ,d),3);else if(4===c)34===n?(d++,c=3):f(11,g('"'),4);else if(5===c)if(96===n&&34===i)d+=2,c=3;else if(-1!==(a=p(c0,d)))f(11,a,5);else break;else if(1===c)if(-1!==(a=p(cX,d)))f(8,a,0);else if(10===n)d++,c=0;else break;else if(2===c)41===n?(d++,c=0):f(7,g(")"),2);else if(6===c)if(34===n)f(13,d+1,7);else if(125===n)d++,c=0;else if(-1!==(a=p(c1,d)))f(13,a,6);else break;else 34===n?f(13,d+1,6):(a=g('"'),h(13,t.slice(d,a).replace(c2,"<br/>"),a))}return d<n?h(1,"",d):(0===c&&h(4,"",n),h(0,"",n)),{types:i,texts:a,starts:s}}(t,n),l=n?", 'SHAPE_DATA'":"",c=0,u=r=>{let s=a[c];throw 1===s?d(i,t,o[c],"",!0):d(i,t,o[c],`Expecting ${r}, got '${cY(s,n)}'`)},h=`'${cY(5,n)}'`;if(2===a[c]){for(c++;2===a[c]||3===a[c];)c++;5!==a[c]&&u(`'SPACELINE', 'NL', ${h}`)}else 5!==a[c]&&u(`'SPACELINE', ${h}`);let f="'SPACELINE', 'NL', 'SPACELIST', 'ICON', 'CLASS', 'NODE_DSTART', 'NODE_ID'";for(3===a[++c]&&(c++,f="'SPACELINE', 'SPACELIST', 'ICON', 'CLASS', 'NODE_DSTART', 'NODE_ID'");;){let t=a[c],n=0,i=6===t;if(i&&(n=s[c++].length,t=a[c]),10===t||9===t){let i,o,d=0;if(10===t&&(i=s[c++]),9===a[c]){let t=s[c++];11!==a[c]&&u("'NODE_DESCR'"),o=s[c++],12!==a[c]&&u("'NODE_DEND'");let n=s[c++];c6(a[c])||13===a[c]||u(c3+l),d=r.getType(t,n)}else c6(a[c])||13===a[c]||u(c3+", 'NODE_DSTART'"+l),o=i;if(13===a[c]){let t=s[c++];for(;13===a[c];)t+=s[c++];c6(a[c])||u(c3+l),r.addNode(n,i??o,o,d,t)}else r.addNode(n,i??o,o,d)}else if(7===t||8===t){let n=s[c++];c6(a[c])||u(c3),r.decorateNode(7===t?{icon:n}:{class:n})}else i?c6(t)||u(c3+", 'ICON', 'CLASS', 'NODE_DSTART', 'NODE_ID'"):2===t?c6(a[++c])||u(c3):u(f);for(c++;3===a[c]||4===a[c];)c++;if(0===a[c])return;0===c5[a[c]]&&u(c3+", 'SPACELIST', 'ICON', 'CLASS', 'NODE_DSTART', 'NODE_ID'")}}var c9=class{type="kanban";title;sections=[];getType=cG;last;sectionLevel=0;misplaced;addNode(t,r,n,i,s){let o={id:r,level:t,label:n};if(void 0!==s){let t=s.includes(`
|
|
81
|
+
`)?s+`
|
|
82
|
+
`:`{
|
|
83
|
+
`+s+`
|
|
84
|
+
}`,r;try{r=q(t)}catch(t){throw new a(`Metadata of "${o.id}" is not valid YAML. ${t.message}`,"syntax",{type:"kanban"})}if(null!==r&&"object"==typeof r&&!Array.isArray(r)){let t=r.shape?String(r.shape):"";if(t!==t.toLowerCase()||t.includes("_"))throw new a(`No such shape: ${t}. Shape names should be lowercase.`,"semantic",{type:"kanban"});r.label&&(o.label=String(r.label)),r.icon&&(o.icon=String(r.icon)),r.assigned&&(o.assigned=String(r.assigned)),r.ticket&&(o.ticket=String(r.ticket)),r.priority&&(o.priority=String(r.priority))}}if(this.misplaced)throw new a(`Items without section detected, found section ("${this.misplaced.label}")`,"semantic",{type:"kanban"});let l=this.sections;(0===l.length&&(this.sectionLevel=t),this.last=o,t===this.sectionLevel)?(o.items=[],l.push(o)):(l[l.length-1].items.push(o),t<this.sectionLevel&&(this.misplaced=o))}decorateNode(t){let r=this.last;t&&r&&(t.icon&&(r.icon=t.icon),t.class&&(r.cssClasses=t.class))}};function c7(t,r,n,i,a){return`<svg class="pele-icon" data-icon="${eS(t)}" x="${eT(r)}" y="${eT(n)}" width="${eT(i)}" height="${eT(i)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${a?.(t)??""}</svg>`}var de=new Map([["very high",`stroke="${r7}"`],["high",`stroke="${r7}" opacity="0.5"`],["low",'stroke="var(--_m)" opacity="0.5"'],["very low",'stroke="var(--_m)"']]);function dt(t,r,n,i,a,s=0){let o=n7(t,r,n,i,a,s);if(o.width<=a)return o;let l=[],c=[],d=0,u=[],h=0,f=()=>{l.push(u),c.push(h),d=Math.max(d,h),u=[],h=0};for(let t=0;t<o.lines.length;t++){if(o.widths[t]<=a){u=o.lines[t],h=o.widths[t],f();continue}for(let r of o.lines[t]){if(void 0!==r.icon||r.math){h>0&&h+r.width>a&&f(),u.push(r),h+=r.width;continue}let t="",s=h;for(let o of r.text){let l=n.width(o,i,r.style);h>0&&h+l>a&&(t&&u.push({text:t,style:r.style,width:h-s}),f(),t="",s=0),t+=o,h+=l}t&&u.push({text:t,style:r.style,width:h-s})}f()}let p={...o,lines:l,widths:c,width:d,height:l.length*o.lineHeight};return o.heights?it(p):p}function dr(t,r,n,i,a,s=!1){let o="";for(let l=0;l<t.lines.length;l++){let c=t.lines[l],d=n+ii(t,l);if(1===c.length&&void 0===c[0].icon&&void 0===c[0].math&&(56&c[0].style)==0)o+=`<text${eW(i,c[0].style)} x="${eT(r)}" y="${eT(d+.35*t.size)}"${s?' text-anchor="end"':""}>${eE(c[0].text)}</text>`;else{let n=t.widths[l];o+=eI(ia(t,l),r+(s?-n:n)/2,d,i,a)}}return o}var dn=t=>!!t&&""!==$(t),di=class{type="mindmap";title;nodes=[];getType=cG;baseLevel=0;open=[];addNode(t,r,n,i){let s=0===this.nodes.length;s&&(this.baseLevel=t),t-=this.baseLevel;let o=this.open,l=o.length;for(;l>0&&o[l-1].level>=t;)l--;let c=o[l-1];if(!c&&!s)throw new a(`There can be only one root. No parent could be found for ("${n}")`,"semantic",{type:"mindmap"});let d={id:this.nodes.length,nodeId:r,level:t,descr:n,type:i,children:[],isRoot:s};c&&(d.section=c.isRoot?c.children.length%11:c.section,c.children.push(d)),o.length=l,o.push(d),this.nodes.push(d)}decorateNode(t){let r=this.nodes[this.nodes.length-1];t&&r&&(t.icon&&(r.icon=t.icon),t.class&&(r.class=t.class))}},da=["","rounded","rect","circle","cloud","bang","hex"],ds="stadium";function dl(t,r,n,i,a){let s=t.packet?.[r];return"number"==typeof s&&s>=i?Math.min(s,a):n}function dc(t){return new a(t,"semantic",{type:"packet"})}var dd=[{name:"packet-beta",pattern:"packet-beta"},iP("packet"),{name:"-",pattern:"-",longer:[iR]},{name:"+",pattern:"+"},{name:":",pattern:":"},iS,iC,iT,{name:"INT",pattern:/0|[1-9][0-9]*(?!\.)/y},iN,iO,iD,iR,iL,iz];function du(t,r,n,i,a,s=0){if(""===t||r<=0)return;let o=a.width(t,n,s);if(o<=r)return{text:t,size:n,width:o};let l=Math.max(i,Math.floor(n*r/o));for(;l>=i;){if((o=a.width(t,l,s))<=r)return{text:t,size:l,width:o};l--}let c=Array.from(t),d=0,u=c.length-1;for(;d<u;){let t=d+u+1>>1;a.width(c.slice(0,t).join("").trimEnd()+"…",i,s)<=r?d=t:u=t-1}if(0===d)return;let h=c.slice(0,d).join("").trimEnd()+"…";return(o=a.width(h,i,s))<=r?{text:h,size:i,width:o}:void 0}function dh(t,r){let n=r;for(let r=t.charCodeAt(n);r>=48&&r<=57;r=t.charCodeAt(n))n++;return n}var df=[iP("showData"),iP("pie"),{name:":",pattern:":"},{name:"NUMBER_PIE",pattern:/(?:-?[0-9]+\.[0-9]+(?!\.))|(?:-?(0|[1-9][0-9]*)(?!\.))/y,scanner:function(){let t=0,r=0,n=-1;return(i,a)=>{let s=45===i.charCodeAt(a)?a+1:a;if((s<t||s>=r)&&(t=s,r=dh(i,s),n=-1,r>s&&46===i.charCodeAt(r))){let t=dh(i,r+1),a=t-r-1;a>0&&46!==i.charCodeAt(t)?n=t:a>1&&(n=t-1)}return r===s?-1:n>=0?n:48===i.charCodeAt(s)?46===i.charCodeAt(s+1)?-1:s+1:46!==i.charCodeAt(r)?r:r-1>s?r-1:-1}},first:"-0123456789"},iS,iC,iT,iN,iO,iD,iR,iL,iz];function dp(t,r){return`${eT(Math.sin(t)*r)},${eT(-Math.cos(t)*r)}`}var dg=/^\d+$/,dm=/^#?([\dA-Fa-f]{6}|[\dA-Fa-f]{3})$/,dy=/^\d+px$/;function dv(t,r,n){return new a(`value for ${t} ${r} is invalid, please use a valid ${n}`,"semantic",{type:"quadrantChart"})}function db(t){let r={};for(let n of t){let[t,i]=function(t){let r=t.trim(),n=r.indexOf(":");if(-1===n)return[r,"undefined"];let i=r.slice(n+1).trimStart(),a=i.indexOf(":");return[r.slice(0,n).trimEnd(),-1===a?i:i.slice(0,a).trimEnd()]}(n);if("radius"===t){if(!dg.test(i))throw dv(t,i,"number");r.radius=parseInt(i)}else if("color"===t){if(!dm.test(i))throw dv(t,i,"hex code");r.color=i}else if("stroke-color"===t){if(!dm.test(i))throw dv(t,i,"hex code");r.strokeColor=i}else if("stroke-width"===t){if(!dy.test(i))throw dv(t,i,"number of pixels (eg. 10px)");r.strokeWidth=i}else throw new a(`style named ${t} is not supported.`,"semantic",{type:"quadrantChart"})}return r}function dx(t){return{text:t.text.trim(),type:t.type}}var dw=class{type="quadrantChart";title;accTitle;accDescr;quadrants=[void 0,void 0,void 0,void 0];xAxisLeft;xAxisRight;yAxisBottom;yAxisTop;points=[];classes=new Map;setQuadrant1Text(t){this.quadrants[0]=dx(t)}setQuadrant2Text(t){this.quadrants[1]=dx(t)}setQuadrant3Text(t){this.quadrants[2]=dx(t)}setQuadrant4Text(t){this.quadrants[3]=dx(t)}setXAxisLeftText(t){this.xAxisLeft=dx(t)}setXAxisRightText(t){this.xAxisRight=dx(t)}setYAxisBottomText(t){this.yAxisBottom=dx(t)}setYAxisTopText(t){this.yAxisTop=dx(t)}addPoint(t,r,n,i,a){this.points.push({x:Number(n),y:Number(i),text:dx(t),className:r,...db(a)})}addClass(t,r){this.classes.set(t,db(r))}setDiagramTitle(t){this.title=t}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
|
|
85
|
+
`)}};function d$(t,r,n){for(let i=0;i<n.length;i++){let a=t.charCodeAt(r+i),s=n.charCodeAt(i);if(a!==s&&!(s>=97&&s<=122&&a===s-32))return!1}return!0}var dk=["$end","INVALID","NEWLINE","title","title_value","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","X-AXIS","Y-AXIS","AXIS-TEXT-DELIMITER","QUADRANT_1","QUADRANT_2","QUADRANT_3","QUADRANT_4","CLASSDEF","MD_STR","STR","class_name","point_start","point_x","point_y","QUADRANT","ALPHA","UNICODE_TEXT","COLON","PLUS","COMMA","EQUALS","MULT","BRKT","UNDERSCORE","DOT","AMP","MINUS","NUM","SPACE","SEMI","PUNCTUATION","EOF"],dM=[41,4,6,8,9,19],d_=new Uint8Array(128);for(let[t,r]of[[":",27],["+",28],[",",29],["=",30],["*",31],["#",32],["_",33],[".",34],["&",35],["-",36],[" \v\f",38],[";",39],["!$%'`?\\/",40]])for(let n=0;n<t.length;n++)d_[t.charCodeAt(n)]=r;function dA(...t){let r=new Uint8Array(42);for(let n of t)r[n]=1;return r}var dE=dA(40,35,37,25,29,28,30,31,34,32,33,26),dS=dA(25,37,36,29,27,35,32,31,26),dC=dA(25,37,27,38,32,36),dT=dA(2,39,41),dI=["setQuadrant1Text","setQuadrant2Text","setQuadrant3Text","setQuadrant4Text"];function dN(t,r){return t.quadrantChart?.[r]}function dO(t,r,n,i){let a=dN(t,r);return"number"==typeof a&&a>=0?Math.min(a,i):n}function dD(t,r,n){let i=dN(t,r);return"number"==typeof i&&Number.isFinite(i)?Math.min(72,Math.max(4,i)):n}function dR(t){return t.startsWith("#")?t:"#"+t}function dL(t){return new a(t,"semantic",{type:"radar"})}var dz=0,dP=0;function dj(t,r){let n=r;for(let r=t.charCodeAt(n);r>=48&&r<=57;r=t.charCodeAt(n))n++;return n}var dF=iS.pattern,dB=/[\t ]*accDescr\s*{/y,dW=-2,dH={name:"ID",pattern:/[\w]([-\w]*\w)?/y},dU=/[-\w]*\w/y;function dq(t,r){return(n,i,a)=>{if(t.lastIndex=i,!t.test(n))return -1;let s=t.lastIndex;return a===r?s:(dU.lastIndex=s,dU.test(n)?-1:s)}}var dV=t=>({name:t,pattern:t,longer:[dH]}),dY=t=>({name:t,pattern:t}),dG=[dY("radar-beta:"),{...iP("radar-beta"),longer:[dH]},dV("showLegend"),dV("graticule"),dV("curve"),dV("ticks"),dV("axis"),dV("max"),dV("min"),dY(":"),dY(","),dY("["),dY("]"),dY("{"),dY("}"),{name:"GRATICULE",pattern:/circle|polygon/y,match:dq(/circle|polygon/y,3)},{name:"BOOLEAN",pattern:/true|false/y,match:dq(/true|false/y,2)},{...iS,match:function(t,r){return dB.lastIndex=r,dB.test(t)&&(-2===dW&&(dW=t.lastIndexOf("}")),dB.lastIndex>dW)?-1:(dF.lastIndex=r,dF.test(t)?dF.lastIndex:-1)}},iC,iI(String.raw`[-\w]*\w`),{name:"NUMBER",pattern:/(?:[0-9]+\.[0-9]+(?!\.))|(?:0|[1-9][0-9]*(?!\.))/y,match:function(t,r){(r<dz||r>=dP)&&(dz=r,dP=dj(t,r));let n=dP;if(n===r)return -1;let i=46===t.charCodeAt(n);if(i){let r=dj(t,n+1),i=r-n-1;if(i>0&&46!==t.charCodeAt(r))return r;if(i>1)return r-1}return 48===t.charCodeAt(r)?r+1:i?n-1>r?n-1:-1:n}},iN,dH,iO,iD,iR,iL,iz];function dZ(t,r,n,i,a){let s=t.radar?.[r];return"number"==typeof s&&s>=i?Math.min(s,a):n}function dX(t){let r="";for(let n of t)r+=(r?" ":"")+eT(n.x)+","+eT(n.y);return r}function dK(t){return 32===t||t>=9&&t<=13||t>127&&/\s/.test(String.fromCharCode(t))}var dJ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function dQ(t){return{name:"TITLE",pattern:RegExp(String.raw`title(?:[\t ][^\n\r]*?(?=%%)|[\t ][^\n\r]*|(?!${t}))`,"y"),first:"t"}}var d0={name:"ACC_TITLE",pattern:/accTitle[\t ]*:(?:[^\n\r]*?(?=%%)|[^\n\r]*)/y,first:"a"},d1={name:"ACC_DESCR",pattern:/accDescr(?:[\t ]*:([^\n\r]*?(?=%%)|[^\n\r]*)|\s*{([^}]*)})/y,first:"a",scanner:function(){let t=1/0;return(r,n)=>{if(!r.startsWith("accDescr",n))return -1;let i=r.length,a=n+8;for(;a<i&&(32===r.charCodeAt(a)||9===r.charCodeAt(a));)a++;if(58===r.charCodeAt(a)){for(a++;a<i;a++){let t=r.charCodeAt(a);if(10===t||13===t||37===t&&37===r.charCodeAt(a+1))break}return a}for(;a<i&&dK(r.charCodeAt(a));)a++;if(123!==r.charCodeAt(a)||a>=t)return -1;let s=r.indexOf("}",a+1);return -1===s&&(t=a),s+1||-1}}};function d2(t,r){return{name:t,pattern:t,longer:r}}function d4(t,r){return{...iP(t),longer:[r]}}function d3(t){return{name:t,pattern:/[A-Z_a-z][\w-]*/y,first:dJ+"_"}}function d5(t){return{name:t,pattern:/"([^"\\]|\\.)*"|'([^'\\]|\\.)*'/y,first:"\"'"}}function d6(t){return[{name:t+"_WHITESPACE",pattern:/[\t \r\n]+/y,hidden:!0,first:` \r
|
|
86
|
+
`},{...iR,name:t+"_YAML",first:"-"},{...iL,name:t+"_DIRECTIVE",first:" %"},{...iz,name:t+"_SINGLE_LINE_COMMENT",first:" %"}]}function d8(t){if(!t.includes("\\"))return t.slice(1,-1);let r=t.length-1,n="";for(let i=1;i<r;i++){let a=t[i];"\\"===a&&i+1<r?n+="n"===(a=t[++i])?`
|
|
87
|
+
`:"r"===a?"\r":"t"===a?" ":a:n+=a}return n}function d9(t,r,n,i,a,s){let o=new iG(iE(t,r,"railroad"),r,"railroad"),l={$type:n,rules:[]};for(o.expect(0);;){let t=o.kind;if(t===i){let t=iH(o.take()),r=t[0];l.title=('"'===r||"'"===r)&&t.endsWith(r)?a(t):t}else if(t===i+1)l.accTitle=iU(o.take());else if(t===i+2)l.accDescr=iq(o.take());else break}for(;-1!==o.kind;)l.rules.push(s(o));return l}var d7=[];function ue(t){let r=t.element??t.primary??t.suffix,n=t.alternatives??t.elements??(r?[r]:d7);if(t.base)for(let r of(n=[t.base],t.postfixes))r.except&&n.push(r.except);return n}var ut=t=>({type:"terminal",value:t}),ur=t=>({type:"nonterminal",name:t}),un=t=>({type:"special",text:t}),ui=t=>({type:"optional",element:t}),ua=(t,r,n=1/0)=>({type:"repetition",element:t,min:r,max:n});function us(t){return 1===t.length?t[0]:{type:"sequence",elements:t}}function uo(t){return 1===t.length?t[0]:{type:"choice",alternatives:t}}function ul(t,r){return t.rules.map(t=>({name:t.name,definition:uc(t.definition,ue,r)}))}function uc(t,r,n){let i=[t],a=[r(t)],s=[[]];for(;;){let t=i.length-1,o=s[t];if(o.length<a[t].length){let n=a[t][o.length];i.push(n),a.push(r(n)),s.push([])}else{let r=n(i[t],o);if(0===t)return r;i.pop(),a.pop(),s.pop(),s[t-1].push(r)}}}var ud="0123456789",uu={name:"ABNF_RULENAME",pattern:/[A-Za-z][A-Za-z0-9-]*/y,first:dJ},uh={name:"ABNF_COMMENT",pattern:/;[^\n\r]*/y,hidden:!0,first:";"},uf=[d4("railroad-abnf-beta",uu),d2("="),d2(";",[uh]),d2("/"),d2("("),d2(")"),d2("["),d2("]"),dQ(String.raw`[A-Za-z0-9-]`),d0,d1,uu,{name:"ABNF_STRING",pattern:/"[^"]*"/y,first:'"'},{name:"ABNF_NUMVAL",pattern:/%[xXdDbB][0-9A-Fa-f]+(?:-[0-9A-Fa-f]+|\.[0-9A-Fa-f]+)*/y,first:"%"},{name:"ABNF_REPEAT",pattern:/[0-9]*\*[0-9]*/y,first:ud+"*"},{name:"ABNF_EXACT_REPEAT",pattern:/[0-9]+/y,first:ud},...d6("ABNF"),uh];function up(t,r,n,i){let a={$type:"AbnfConcatenation",elements:[]};return r.alternatives.push(a),{alternation:r,concatenation:a,node:t,close:n,repeat:i}}function ug(t,r){switch(t.$type){case"AbnfAlternation":return uo(r);case"AbnfConcatenation":return us(r);case"AbnfElement":{let n=t.repeat;if(!n)return r[0];let i=n.indexOf("*"),a=-1===i,s=i>0||a?parseInt(n,10):0,o=a?s:i<n.length-1?parseInt(n.slice(i+1),10):1/0;return 0===s&&1===o?ui(r[0]):ua(r[0],s,o)}case"AbnfStringLiteral":case"AbnfNumVal":return ut(t.value);case"AbnfRuleName":return ur(t.name);case"AbnfGroup":return r[0];case"AbnfOptionalGroup":return ui(r[0])}}function um(t,r){if(63!==t.charCodeAt(r))return -1;let n=!1;for(let i=r+1;i<t.length;i++){let r=t.charCodeAt(i);if(63===r)return n?i+1:-1;if(59===r)break;n||=!dK(r)}return -1}var uy=d3("EBNF_ID"),uv={name:"EBNF_SPECIAL_SEQUENCE",pattern:/\?(?=[^?;]*[^?\s;][^?;]*\?)[^?;]*\?/y,first:"?",scanner:()=>um},ub=d6("EBNF"),ux={name:"EBNF_ISO_COMMENT",pattern:/\(\*[\s\S]*?\*\)/y,hidden:!0,first:"(",opener:/\(\*/y},uw=[d4("railroad-ebnf-beta",uy),d2("::="),d2("="),d2(";"),d2("|"),d2(","),d2("(",[ux]),d2(")"),d2("["),d2("]"),d2("{"),d2("}"),d2("?",[uv]),d2("*"),d2("+"),d2("-",[ub[1]]),dQ(String.raw`[\w-]`),d0,d1,uy,d5("EBNF_STRING"),uv,...ub,{name:"EBNF_BLOCK_COMMENT",pattern:/\/\*[\s\S]*?\*\//y,hidden:!0,first:"/",opener:/\/\*/y},ux];function u$(t,r,n,i){let a={$type:"EbnfSequence",elements:[]};return r.alternatives.push(a),{choice:r,sequence:a,term:void 0,node:t,close:n,except:i}}var uk=["EbnfGroup","EbnfOptional","EbnfRepetition"];function uM(t,r){switch(t.$type){case"EbnfChoice":return uo(r);case"EbnfSequence":return us(r);case"EbnfTerm":{let n=r[0],i=1;for(let a of t.postfixes)n="EbnfOptionalPostfix"===a.$type?ui(n):"EbnfExceptionPostfix"===a.$type?{type:"sequence",elements:[n,ut("-"),r[i++]]}:ua(n,+("EbnfOneOrMorePostfix"===a.$type));return n}case"EbnfTerminal":return ut(t.value);case"EbnfNonTerminal":return ur(t.name);case"EbnfSpecial":return un(t.text);case"EbnfGroup":return r[0];case"EbnfOptional":return ui(r[0]);case"EbnfRepetition":return ua(r[0],0)}}var u_=d3("RR_ID"),uA=t=>d2(t,[u_]),uE=[d4("railroad-beta",u_),uA("nonterminal"),uA("zeroOrMore"),uA("oneOrMore"),uA("sequence"),uA("optional"),uA("terminal"),uA("special"),uA("choice"),d2("="),d2(";"),d2("("),d2(","),d2(")"),dQ(String.raw`[\w-]`),d0,d1,u_,d5("RR_STRING"),...d6("RR"),{name:"RR_BLOCK_COMMENT",pattern:/\/\*[\s\S]*?\*\//y,hidden:!0,first:"/",opener:/\/\*/y}];function uS(t){t.i++,t.expect(11);let r=d8(t.expect(18));return t.expect(13),r}function uC(t){return{$type:t,element:void 0}}function uT(t,r){switch(t.$type){case"RailroadTerminalExpr":return ut(t.value);case"RailroadNonTerminalExpr":return ur(t.name);case"RailroadSpecialExpr":return un(t.text);case"RailroadSequenceExpr":return us(r);case"RailroadChoiceExpr":return uo(r);case"RailroadOptionalExpr":return ui(r[0]);default:return ua(r[0],+("RailroadOneOrMoreExpr"===t.$type))}}var uI=d3("PEG_ID"),uN=[d4("railroad-peg-beta",uI),d2("<-"),d2(";"),d2("/"),d2("&"),d2("!"),d2("?"),d2("*"),d2("+"),d2("("),d2(")"),d2("."),dQ(String.raw`[\w-]`),d0,d1,uI,d5("PEG_STRING"),...d6("PEG"),{name:"PEG_LINE_COMMENT",pattern:/#[^\n\r]*/y,hidden:!0,first:"#"}];function uO(t,r,n){let i={$type:"PegSequence",elements:[]};return r.alternatives.push(i),{choice:r,sequence:i,node:t,operator:n}}function uD(t,r){let n=r[0];switch(t.$type){case"PegOrderedChoice":return uo(r);case"PegSequence":return us(r);case"PegPrefix":return t.operator?un(t.operator+function(t){switch(t.type){case"terminal":return`"${t.value}"`;case"nonterminal":return t.name;case"special":return t.text;default:return"(...)"}}(n)):n;case"PegSuffix":return t.operator?"?"===t.operator?ui(n):ua(n,+("+"===t.operator)):n;case"PegLiteral":return ut(t.value);case"PegIdentifier":return ur(t.name);case"PegAny":return un(t.dot);case"PegGroup":return n}}var uR=class{type="railroad";notation="railroad";title;accTitle;accDescr;rules=[];byName=new Map;setTitle(t){this.title=t}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
|
|
88
|
+
`)}addRule(t){this.rules.push(t),this.byName.set(t.name,t)}getRule(t){return this.byName.get(t)}},uL=/^\s*railroad-(ebnf-|abnf-|peg-)?beta/i;function uz(t,r,n,i){let a=t.railroad?.[r];return"number"==typeof a&&a>=0?Math.min(a,i):n}var uP=/[\n\r\t]/g;function uj(t){return(t.includes("\xb6\xdf")?y(t.replace(/&/g,"&")):t).replace(uP,t=>t===`
|
|
89
|
+
`?"\\n":"\r"===t?"\\r":"\\t")}function uF(t,r){for(let n=r,i=t.length-1;n<i;n++,i--){let r=t[n];t[n]=t[i],t[i]=r}}function uB(t){return 2*Math.ceil(t/2)}function uW(t,r,n,i,a){let s=a.height/2;return{kind:t,width:Math.max(uB(a.measurer.width(r,a.size,i)+2*a.padding),a.height),up:s,down:s,kids:d7,text:r,id:n,reach:0}}function uH(t,r,n,i){return Math.max(t+r.down+i.sep+n.up,2*i.arc)}function uU(t,r){let n=Math.max(t.up+r.sep,2*r.arc);return{kind:5,width:t.width+4*r.arc,up:n,down:t.down,kids:[t],text:"",id:"",reach:n}}var uq="contains",uV=class{type="requirement";direction="TB";requirements=new Map;elements=new Map;relations=[];classes=new Map;title;accTitle;accDescr;newId="";newText="";newRisk="";newVerifyMethod="";newElementType="";newDocRef="";styleCopies=0;copy(t,r){if(this.styleCopies+=r.length,this.styleCopies>1e6)throw new a("Requirement diagram applies too many style declarations.","limit",{type:"requirement"});for(let n of r)t.push(n)}setDirection(t){this.direction=t}addRequirement(t,r){let n=this.requirements.get(t);return void 0===n&&(n={name:t,type:r,requirementId:this.newId,text:this.newText,risk:this.newRisk,verifyMethod:this.newVerifyMethod,cssStyles:[],classes:["default"]},this.requirements.set(t,n)),this.newId=this.newText=this.newRisk=this.newVerifyMethod="",n}setNewReqId(t){this.newId=t}setNewReqText(t){this.newText=t}setNewReqRisk(t){this.newRisk=t}setNewReqVerifyMethod(t){this.newVerifyMethod=t}addElement(t){let r=this.elements.get(t);return void 0===r&&(r={name:t,type:this.newElementType,docRef:this.newDocRef,cssStyles:[],classes:["default"]},this.elements.set(t,r)),this.newElementType=this.newDocRef="",r}setNewElementType(t){this.newElementType=t}setNewElementDocRef(t){this.newDocRef=t}addRelationship(t,r,n){this.relations.push({type:t,src:r,dst:n})}node(t){return this.requirements.get(t)??this.elements.get(t)}setCssStyle(t,r){for(let n of t){let t=this.node(n);if(!r||!t)return;for(let n of r)this.copy(t.cssStyles,n.includes(",")?n.split(","):[n])}}setClass(t,r){for(let n of t){let t=this.node(n);if(t)for(let n of r){t.classes.push(n);let r=this.classes.get(n)?.styles;r&&this.copy(t.cssStyles,r)}}}defineClass(t,r){for(let n of t){let t=this.classes.get(n);for(let i of(void 0===t&&(t={id:n,styles:[],textStyles:[]},this.classes.set(n,t)),r))i.includes("color")&&t.textStyles.push(i.replace("fill","bgFill")),t.styles.push(i);let i=r.flatMap(t=>t.split(","));for(let t of this.requirements.values())t.classes.includes(n)&&this.copy(t.cssStyles,i);for(let t of this.elements.values())t.classes.includes(n)&&this.copy(t.cssStyles,i)}}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
|
|
90
|
+
`)}},uY=["$end","INVALID","title","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","direction_tb","direction_bt","direction_rl","direction_lr","NEWLINE","EOF","RD","STRUCT_START","STRUCT_STOP","STYLE_SEPARATOR","COLONSEP","ID","TEXT","RISK","VERIFYMTHD","REQUIREMENT","FUNCTIONAL_REQUIREMENT","INTERFACE_REQUIREMENT","PERFORMANCE_REQUIREMENT","PHYSICAL_REQUIREMENT","DESIGN_CONSTRAINT","LOW_RISK","MED_RISK","HIGH_RISK","VERIFY_ANALYSIS","VERIFY_DEMONSTRATION","VERIFY_INSPECTION","VERIFY_TEST","ELEMENT","CONTAINS","COPIES","DERIVES","SATISFIES","VERIFIES","REFINES","TRACES","TYPE","DOCREF","STYLE","CLASSDEF","CLASS","ALPHA","COLON","SEMICOLON","PERCENT","MINUS","BRKT","END_ARROW_L","END_ARROW_R","LINE","qString","unqString","COMMA"],uG=new Map([["requirementdiagram",14],["id",19],["text",20],["risk",21],["verifymethod",22],["requirement",23],["functionalrequirement",24],["interfacerequirement",25],["performancerequirement",26],["physicalrequirement",27],["designconstraint",28],["low",29],["medium",30],["high",31],["analysis",32],["demonstration",33],["inspection",34],["test",35],["element",36],["contains",37],["copies",38],["derives",39],["satisfies",40],["verifies",41],["refines",42],["traces",43],["type",44],["docref",45],["style",46],["classdef",47],["class",48]]),uZ=/accTitle\s*:\s*/iy,uX=/accDescr\s*:\s*/iy,uK=/accDescr\s*\{\s*/iy,uJ=/direction\s+(?:(TB)|(BT)|(RL)|LR)/gi,uQ=/[\n\r\u2028\u2029]/g,u0=new Uint8Array(128);for(let t of`:,\r
|
|
91
|
+
{<>-=`)u0[t.charCodeAt(0)]=1;var u1=["Requirement","Functional Requirement","Interface Requirement","Performance Requirement","Physical Requirement","Design Constraint","Low","Medium","High","Analysis","Demonstration","Inspection","Test","",uq,"copies","derives","satisfies","verifies","refines","traces"];function u2(t){return 49===t||50===t||54===t||53===t||51===t}function u4(t,r,n){if(0===r||0===t.lines.length)return t;let i=0,a=[],s=t.lines.map(s=>{let o=0,l=s.map(i=>{let a=i.style|r,s=void 0!==i.icon||i.math?i.width:n.width(i.text,t.size,a);return o+=s,{...i,style:a,width:s}});return a.push(o),o>i&&(i=o),l});return{...t,lines:s,widths:a,width:i}}function u3(t,r,n,i){let a=eB(t),s="",o="";for(let l=0;l<t.lines.length;l++){let c=t.lines[l],d=n+ii(t,l);if(ir(c)){o+=eI(ia(t,l),r+t.widths[l]/2,d,i);continue}let u=d+.35*t.size,h=!0;for(let t of c)void 0!==t.icon||""===t.text||(s+=`<tspan${h?` x="${eT(r)}" y="${eT(u)}"`:""}${eF(t.style&~a)}>${eE(t.text)}</tspan>`,h=!1)}return(""===s?"":`<text${eW(i,a)} text-anchor="start" xml:space="preserve">${s}</text>`)+o}function u5(t,r,n,i){let a=function(t){let r=[];for(let n of t.requirements.values())r.push({id:n.name,requirement:n,element:void 0,cssStyles:n.cssStyles,cssClasses:n.classes.join(" ")});for(let n of t.elements.values())r.push({id:n.name,requirement:void 0,element:n,cssStyles:n.cssStyles,cssClasses:n.classes.join(" ")});let n=r=>t.requirements.has(r)||t.elements.has(r)?r:void 0;return{nodes:r,edges:t.relations.map((t,r)=>({id:`${t.src}-${t.dst}-${r}`,start:n(t.src),end:n(t.dst),type:t.type,contains:t.type===uq})),direction:t.direction}}(t),s=n.fontSize??16,o=Math.round(.875*s),l=n.measurer??e$(n.fontFamily,n.fontFamilyMono),c=n.padding??8,d=new Map,u=[],h=[];for(let t of a.nodes){let r=no(t.cssStyles),n=!!r.bold|2*!!r.italic,i=r.fontSize??s,a=r.fontSize??o,c=t.requirement,f=t.element,p=u4(n7(`\xab${c?c.type:"Element"}\xbb`,!1,l,a,4e3),n,l),g=u4(n7(t.id,!0,l,i,280),1|n,l),m=c?[["ID",c.requirementId],["Text",c.text],["Risk",c.risk],["Verification",c.verifyMethod]]:[["Type",f.type],["Doc Ref",f.docRef]],y=[],v=0,b=0,x=0;for(let[t,r]of m){if(!r)continue;let i=u4(n7(t,!1,l,a,4e3),n,l),s=u4(n7(r,!0,l,a,240),n,l),o=Math.max(i.height,s.height);y.push({key:i,value:s,height:o}),v=Math.max(v,i.width),b=Math.max(b,s.width),x+=o+2}y.length>0&&(x+=18);let w=20+p.height+g.height,$=Math.max(120,Math.max(p.width,g.width)+28,y.length>0?v+12+b+28:0);d.has(t.id)||d.set(t.id,u.length);let k=rR($,w+x);k.seq=u.length,u.push({node:t,style:r,kind:p,name:g,rows:y,keyWidth:v,headHeight:w,w:$,h:w+x}),h.push(k)}let f=i?"TB":rC(a.direction),p="LR"===f||"RL"===f,g=[],m=[],y=[];for(let t of a.edges){let r=void 0===t.start?void 0:d.get(t.start),n=void 0===t.end?void 0:d.get(t.end);if(void 0===r||void 0===n)continue;let i=n7(`\xab${t.type}\xbb`,!1,l,o,4e3);r===n&&(p?h[r].h+=2*(26+i.height+8):h[r].w+=2*(26+i.width+12)),y.push(t),m.push(i),g.push({src:r,dst:n,minlen:1,labelW:i.width+12,labelH:i.height+4,route:[],labelX:0,labelY:0})}let v=rP(h,g,f,{nodeSep:40,edgeSep:16,rankSep:56,portSep:20});!function(t,r,n){let i=new Map;for(let n of r){let r=n.route;if(!(n.src===n.dst||r.length<6))for(let a of[0,r.length-3]){let s=0===a?n.src:n.dst,o=t[s],l=r[a]-o.x,c=r[a+1]-o.y,d=0===a?3:a-3,u;if(.5>Math.abs(Math.abs(c)-o.h/2))u=c<0?0:2;else{if(!(.5>Math.abs(Math.abs(l)-o.w/2)))continue;u=l<0?3:1}let h=4*s+u,f={route:r,at:a,toward:r[u%2==0?d:d+1]},p=i.get(h);p?p.push(f):i.set(h,[f])}}for(let[r,a]of i){if(a.length<2)continue;let i=r>>2,s=r%2==1,o=Math.max(0,Math.min(28,((s?n[i].h:n[i].w)-28)/(a.length-1)));a.sort((t,r)=>t.toward-r.toward);for(let r=0;r<a.length;r++){let n=(r-(a.length-1)/2)*o;s?a[r].route[a[r].at+1]=t[i].y+n:a[r].route[a[r].at]=t[i].x+n}}}(h,g,u);let b=ad(t.title,l,s,4e3),x=b.height>0?b.height+12:0,w=Math.max(v.width,b.width),$=c+(w-v.width)/2,k=c+x,M=Math.ceil(w+2*c),_=Math.ceil(v.height+x+2*c),A="";for(let t=0;t<u.length;t++){let r=u[t],{w:n,h:i,style:a}=r,s=e8(a),o=s||' fill="var(--_m)"',l=-n/2,c=-i/2,d=`<rect x="${eT(l)}" y="${eT(c)}" width="${eT(n)}" height="${eT(i)}" fill="var(--_s)" stroke="var(--_b)"${r9(a.shape)}/>`+eI(r.kind,0,c+10+r.kind.height/2,` class="pele-stereotype" font-size="${r.kind.size}"${o}${a.text}`)+eI(r.name,0,c+10+r.kind.height+r.name.height/2,` class="pele-label" font-size="${r.name.size}" font-weight="var(--_hw)"${s}${a.text}`);if(r.rows.length>0){let t=c+r.headHeight;d+=`<path class="pele-divider" d="M${eT(l)},${eT(t)}H${eT(-l)}" stroke="var(--_b)"${a.line}/>`;let n=t+10,i="";for(let t of r.rows)i+=u3(t.key,l+14,n,` class="pele-field"${o}${a.text}`)+u3(t.value,l+14+r.keyWidth+12,n,` class="pele-value"${s}${a.text}`),n+=t.height+2;d+=`<g class="pele-fields" font-size="${r.rows[0].key.size}">${i}</g>`}A+=`<g class="pele-node ${r.node.requirement?"pele-requirement":"pele-element"}${nc(r.node.cssClasses.replace(/^default\s?/,""))}" data-id="${eS(r.node.id)}" transform="translate(${eT(h[t].x+$)},${eT(h[t].y+k)})">${d}</g>`}let E="",S="",C=new Map;for(let t=0;t<g.length;t++){let r=g[t],n=y[t],i=m[t],a=12*!!n.contains,s,o=r.labelX+$,l=r.labelY+k;if(r.src===r.dst){let t=u[r.src],n=h[r.src].x+$,i=h[r.src].y+k,c=C.get(r.src)??0;C.set(r.src,c+1);let d=Math.min((p?t.w:t.h)/2-4,12+6*c),f=26+8*c,g=(r,a)=>p?`${eT(n+a)},${eT(i+t.h/2+r)}`:`${eT(n+t.w/2+r)},${eT(i+a)}`,m=f/.75;s={d:`M${g(a,-d)}C${g(m,-d)} ${g(m,d)} ${g(0,d)}`,sx:p?n-d:n+t.w/2,sy:p?i+t.h/2:i-d,sdx:p?0:-1,sdy:p?-1:0,ex:p?n+d:n+t.w/2,ey:p?i+t.h/2:i+d,edx:p?0:-1,edy:p?-1:0},p?(o=n,l=i+t.h/2+f+4+r.labelH/2):(o=n+t.w/2+f+4+r.labelW/2,l=i)}else{let t=r.route.slice();for(let r=0;r<t.length;r+=3)t[r]+=$,t[r+1]+=k;s=rU(t,void 0,a,0)}E+=`<g class="pele-edge pele-relationship-${n.contains?"contains":"arrow"}" data-id="${eS(n.id)}"><path d="${s.d}"${n.contains?"":' stroke-dasharray="5 4"'}/>`+(n.contains?function(t,r,n,i){let a=t-6*n,s=r-6*i;return`<circle class="pele-marker" cx="${eT(a)}" cy="${eT(s)}" r="6"/><path class="pele-marker" d="M${eT(a-6*n)},${eT(s-6*i)}L${eT(a+6*n)},${eT(s+6*i)}M${eT(a+6*i)},${eT(s-6*n)}L${eT(a-6*i)},${eT(s+6*n)}"/>`}(s.sx,s.sy,s.sdx,s.sdy):function(t,r,n,i){let a=t-9*n,s=r-9*i;return`<path class="pele-marker" d="M${eT(a-4.5*i)},${eT(s+4.5*n)}L${eT(t)},${eT(r)}L${eT(a+4.5*i)},${eT(s-4.5*n)}" stroke-linejoin="round"/>`}(s.ex,s.ey,s.edx,s.edy))+"</g>",S+=r2(n.id,i,o,l,"")}return{svg:np("requirement",M,_,s,n,t,eI(b,M/2,c+b.height/2,' class="pele-title" font-weight="var(--_tw)"')+(E?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${E}</g>`:"")+(S?`<g class="pele-edge-labels" font-size="${o}" fill="var(--_m)">${S}</g>`:"")+`<g class="pele-nodes">${A}</g>`),width:M,height:_,links:[]}}var u6=class{type="sankey";nodes=[];links=[];title;accTitle;accDescr;lookup=new Map;findOrCreateNode(t){let r=this.lookup.get(t);return void 0===r&&(r={id:t,index:this.nodes.length},this.lookup.set(t,r),this.nodes.push(r)),r}addLink(t,r,n){this.links.push({source:t,target:r,value:n})}},u8=["$end","STUCK","SANKEY","NEWLINE","COMMA","DQUOTE","NON_ESCAPED_TEXT","ESCAPED_TEXT","EOF"];function u9(t){return t>=32&&t<=126&&34!==t&&44!==t||t>=160&&t<=55295||t>=57344&&t<=65533||t>=65536&&t<=1114111}var u7=/[\n\r]+/g,he=/[\x00-\x08\x0b\x0c\x0e-\x1f\ud800-\udfff\ufffe\uffff]/u;function ht(t){return 10!==t&&13!==t&&(t<128?32===t||9===t||11===t||12===t:160===t||5760===t||t>=8192&&t<=8202||8232===t||8233===t||8239===t||8287===t||12288===t||65279===t)}function hr(t,r){let n=[],i=function(t,r){let n=t.length;for(;n>0&&ht(t.charCodeAt(n-1));)n--;let i="",a=0,s=!1;for(let o=0;o<n;){let n=t.charCodeAt(o);if(s)34===n&&(34===t.charCodeAt(o+1)?o++:s=!1),o++;else if(34===n)s=!0,o++;else if(ht(n)){let n=o+1;for(;ht(t.charCodeAt(n));)n++;let s=t.charCodeAt(o-1),l=t.charCodeAt(n);(0===o||10===l||13===l||(10===s||13===s)&&44!==l)&&(i+=t.slice(a,o),r.push([o,n,0]),a=n),o=n}else o++}return n<t.length&&r.push([n,t.length,0]),i+t.slice(a,n)}(t,n),a=i.replace(u7,`
|
|
92
|
+
`),o=a.trim();if(void 0!==r){let t=a.length-a.trimStart().length;r.push(n,s(i,u7,1),[[0,t,0],[t+o.length,a.length,0]])}return o}function hn(t,r){if(t.length>8)return void t.sort(r);for(let n=1;n<t.length;n++){let i=t[n],a=n-1;for(;a>=0&&r(t[a],i)>0;)t[a+1]=t[a],a--;t[a+1]=i}}function hi(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function ha(t,r,n,i,a){let s=t[r];return"number"==typeof s&&s>=i?Math.min(s,a):n}function hs(t,r){let n=t[r];return"string"==typeof n||"number"==typeof n&&Number.isFinite(n)?String(n):""}function ho(t){return 1e15>Math.abs(t)?Math.round(100*t)/100:t}function hl(t){return"string"==typeof t?no([`fill:${t}`]).shape:""}var hc,hd=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?(%|deg|grad|rad|turn)?$/i;function hu(t){if("none"===t.toLowerCase())return 4;let r=hd.exec(t);return r?void 0===r[1]?1:"%"===r[1]?2:3:0}var hh=/^:?wrap:/,hf=/^:?nowrap:/,hp=/^:?(?:no)?wrap:/,hg=/^(?:rgba?|hsla?)\s*\(/,hm=/[\r\u2028\u2029]/,hy=/^\w*/;function hv(t){throw new a(t,"semantic",{type:"sequence"})}function hb(t){let r=t.trim(),n=!!hh.test(r)||!hf.test(r)&&void 0;return{text:(void 0===n?r:r.replace(hp,"")).trim(),wrap:n}}function hx(t){return"string"==typeof t?[...t].map((t,r)=>[String(r),t]):null!==t&&"object"==typeof t?Object.entries(t):[]}var hw=class{type="sequence";actors=new Map;createdActors=new Map;destroyedActors=new Map;boxes=[];messages=[];notes=[];title;accTitle;accDescr;prevActor;currentBox;lastCreated;lastDestroyed;wrapEnabled;sequenceWrap;active=new Map;constructor(t={}){this.wrapEnabled=t.wrap,this.sequenceWrap=t.sequenceWrap??!1}autoWrap(){return this.wrapEnabled??this.sequenceWrap}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
|
|
93
|
+
`)}setDiagramTitle(t){this.title=t}parseMessage(t){return hb(t)}parseBoxData(t){var r;let n=function(t){let r=hg.exec(t);if(r){let n=t.lastIndexOf(")");if(n>=r[0].length)return hm.test(t.slice(r[0].length))?void 0:[t.slice(0,n+1),t.slice(n+1)]}if(hm.test(t))return;let n=hy.exec(t)[0];return[n,t.slice(n.length)]}(t),i=n?.[0]?n[0].trim():"transparent",a=n?.[1]?n[1].trim():void 0;if(((r=i).includes("(")?function(t){var r,n;let i,a=t.startsWith("hsl"),s=t.indexOf("("),o=t.slice(0,s);if("rgb"!==o&&"rgba"!==o&&"hsl"!==o&&"hsla"!==o||t.length>120||t.indexOf(")")!==t.length-1)return!1;let l=t.slice(s+1,-1).trim(),c,d,u=l.includes(",");if(u)4===(c=l.split(",").map(t=>t.trim())).length&&(d=c.pop());else{let t=l.split("/");if(t.length>2)return!1;c=t[0].trim().split(/\s+/),2===t.length&&(d=t[1].trim())}if(3!==c.length||void 0!==d&&(r=d,n=!u,1!==(i=hu(r))&&2!==i&&(!n||4!==i)))return!1;let h=c.map(hu);if(u)return a?(1===h[0]||3===h[0])&&2===h[1]&&2===h[2]:(1===h[0]||2===h[0])&&h[1]===h[0]&&h[2]===h[0];for(let t=0;t<3;t++){let r=h[t];if(!(1===r||4===r||(a&&0===t?3===r:2===r)))return!1}return!0}(r):(hc??=new Set("aliceblue antiquewhite aqua aquamarine azure beige bisque black blanchedalmond blue blueviolet brown burlywood cadetblue chartreuse chocolate coral cornflowerblue cornsilk crimson cyan darkblue darkcyan darkgoldenrod darkgray darkgreen darkgrey darkkhaki darkmagenta darkolivegreen darkorange darkorchid darkred darksalmon darkseagreen darkslateblue darkslategray darkslategrey darkturquoise darkviolet deeppink deepskyblue dimgray dimgrey dodgerblue firebrick floralwhite forestgreen fuchsia gainsboro ghostwhite gold goldenrod gray green greenyellow grey honeydew hotpink indianred indigo ivory khaki lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgray lightgreen lightgrey lightpink lightsalmon lightseagreen lightskyblue lightslategray lightslategrey lightsteelblue lightyellow lime limegreen linen magenta maroon mediumaquamarine mediumblue mediumorchid mediumpurple mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumvioletred midnightblue mintcream mistyrose moccasin navajowhite navy oldlace olive olivedrab orange orangered orchid palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum powderblue purple rebeccapurple red rosybrown royalblue saddlebrown salmon sandybrown seagreen seashell sienna silver skyblue slateblue slategray slategrey snow springgreen steelblue tan teal thistle tomato turquoise violet wheat white whitesmoke yellow yellowgreen transparent currentcolor inherit initial unset revert accentcolor accentcolortext activetext buttonborder buttonface buttontext canvas canvastext field fieldtext graytext highlight highlighttext linktext mark marktext selecteditem selecteditemtext visitedtext activeborder activecaption appworkspace background buttonhighlight buttonshadow captiontext inactiveborder inactivecaption inactivecaptiontext infobackground infotext menu menutext scrollbar threeddarkshadow threedface threedhighlight threedlightshadow threedshadow window windowframe windowtext".split(" "))).has(r.toLowerCase()))||(i="transparent",a=t.trim()),void 0===a)return{text:void 0,color:i,wrap:void 0};let{text:s,wrap:o}=hb(a);return{text:s||void 0,color:i,wrap:o}}addBox(t){this.currentBox={name:t.text,wrap:t.wrap??this.autoWrap(),fill:t.color,actorKeys:[]},this.boxes.push(this.currentBox)}addActor(t,r,n,i,s){let o=this.currentBox,l;if(void 0!==s){let r;try{r=q(s.includes(`
|
|
94
|
+
`)?s+`
|
|
95
|
+
`:`{
|
|
96
|
+
`+s+`
|
|
97
|
+
}`)}catch(r){throw new a(`Config of participant "${t}" is not valid YAML. ${r.message}`,"syntax",{type:"sequence"})}null===r||"object"!=typeof r||Array.isArray(r)||(l=r)}let c=l&&Object.prototype.hasOwnProperty.call(l,"type")?l.type:void 0,d=l&&Object.prototype.hasOwnProperty.call(l,"alias")?l.alias:void 0;null!=c&&(i=String(c)),d&&(!n||n.text===r)&&(n={text:String(d),wrap:n?.wrap,type:i});let u=this.actors.get(t);if(!(u&&(this.currentBox&&u.box&&this.currentBox!==u.box&&hv(`A same participant should only be defined in one Box: ${u.name} can't be in '${u.box.name}' and in '${this.currentBox.name}' at the same time.`),o=u.box?u.box:this.currentBox,u.box=o,r===u.name&&null==n))){if((n?.text==null||null==i)&&(n={text:r,type:i}),this.actors.set(t,{box:o,name:r,description:n.text,wrap:n.wrap??this.autoWrap(),prevActor:this.prevActor,links:new Map,properties:new Map,type:i??"participant"}),this.prevActor){let r=this.actors.get(this.prevActor);r&&(r.nextActor=t)}this.currentBox&&this.currentBox.actorKeys.push(t),this.prevActor=t}}addMessage(t,r,n,i){this.messages.push({id:String(this.messages.length),from:t,to:r,message:n.text,wrap:n.wrap??this.autoWrap(),answer:i})}addSignal(t,r,n,i,a=!1,s){if(18===i){let r=t?this.active.get(t)??0:0;r<1&&hv(`Trying to inactivate an inactive participant (${t})`),this.active.set(t,r-1)}else 17===i&&t&&this.active.set(t,(this.active.get(t)??0)+1);return this.messages.push({id:String(this.messages.length),from:t,to:r,message:n?.text??"",wrap:n?.wrap??this.autoWrap(),type:i,activate:a,centralConnection:s??0}),!0}addNote(t,r,n){let i=n.wrap??this.autoWrap(),a={actor:t,placement:r,message:n.text,wrap:i},s="string"==typeof t?[t,t]:t;this.notes.push(a),this.messages.push({id:String(this.messages.length),from:s[0],to:s[1],message:n.text,wrap:i,type:2,placement:r})}addLinks(t,r){let n=this.actors.get(t);if(n)try{let t=JSON.parse(r.text);for(let[r,i]of hx(t))n.links.set(r,i)}catch{return}}addALink(t,r){let n=this.actors.get(t);if(!n)return;let i=r.text.indexOf("@");n.links.set(r.text.slice(0,i-1).trim(),r.text.slice(i+1).trim())}addProperties(t,r){let n=this.actors.get(t);if(n)try{let t=JSON.parse(r.text);for(let[r,i]of hx(t))n.properties.set(r,i)}catch{return}}addDetails(t,r){let n=this.actors.get(t);n&&(n.details=r.text)}apply(t){let r=[],n=[],i=t;for(;;){void 0!==i&&(Array.isArray(i)?(r.push(i),n.push(0)):"string"!=typeof i&&this.applyOne(i));let t=r.length-1;if(t<0)return;let a=r[t];n[t]<a.length?i=a[n[t]++]:(r.pop(),n.pop(),i=void 0)}}applyOne(t){let r=t.actor;switch(t.type){case"sequenceIndex":this.messages.push({id:String(this.messages.length),from:void 0,to:void 0,message:{start:t.sequenceIndex,step:t.sequenceIndexStep,visible:!0===t.sequenceVisible},wrap:!1,type:t.signalType});break;case"addParticipant":this.addActor(r,r,t.description,t.draw,t.config);break;case"createParticipant":this.actors.has(r)&&hv("It is not possible to have actors with the same id, even if one is destroyed before the next is created. Use 'AS' aliases to simulate the behavior"),this.lastCreated=r,this.addActor(r,r,t.description,t.draw,t.config),this.createdActors.set(r,this.messages.length);break;case"destroyParticipant":this.lastDestroyed=r,this.destroyedActors.set(r,this.messages.length);break;case"activeStart":case"activeEnd":case"centralConnection":case"centralConnectionReverse":this.addSignal(r,void 0,void 0,t.signalType);break;case"addNote":this.addNote(t.actor,t.placement,t.text);break;case"addLinks":this.addLinks(r,t.text);break;case"addALink":this.addALink(r,t.text);break;case"addProperties":this.addProperties(r,t.text);break;case"addDetails":this.addDetails(r,t.text);break;case"addMessage":this.lastCreated?(t.to!==this.lastCreated&&hv(`The created participant ${this.lastCreated} does not have an associated creating message after its declaration. Please check the sequence diagram.`),this.lastCreated=void 0):this.lastDestroyed&&(t.to!==this.lastDestroyed&&t.from!==this.lastDestroyed&&hv(`The destroyed participant ${this.lastDestroyed} does not have an associated destroying message after its declaration. Please check the sequence diagram.`),this.lastDestroyed=void 0),this.addSignal(t.from,t.to,t.msg,t.signalType,t.activate,t.centralConnection);break;case"boxStart":this.addBox(t.boxData);break;case"boxEnd":this.currentBox=void 0;break;case"loopStart":this.addSignal(void 0,void 0,t.loopText,t.signalType);break;case"rectStart":this.addSignal(void 0,void 0,t.color,t.signalType);break;case"optStart":this.addSignal(void 0,void 0,t.optText,t.signalType);break;case"altStart":case"else":this.addSignal(void 0,void 0,t.altText,t.signalType);break;case"parStart":case"and":this.addSignal(void 0,void 0,t.parText,t.signalType);break;case"criticalStart":this.addSignal(void 0,void 0,t.criticalText,t.signalType);break;case"option":this.addSignal(void 0,void 0,t.optionText,t.signalType);break;case"breakStart":this.addSignal(void 0,void 0,t.breakText,t.signalType);break;case"loopEnd":case"rectEnd":case"optEnd":case"altEnd":case"parEnd":case"criticalEnd":case"breakEnd":this.addSignal(void 0,void 0,void 0,t.signalType)}}},h$=["$end","INVALID","INVALID","NEWLINE","SD","create","box","restOfLine","end","autonumber","NUM","off","activate","deactivate","title","legacy_title","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","loop","rect","opt","alt","par","par_over","critical","break","option","and","else","participant","AS","participant_actor","destroy","note","over","links","link","properties","details",",","left_of","right_of","+","-","()","ACTOR","CONFIG_START","CONFIG_CONTENT","CONFIG_END","TXT","SOLID_OPEN_ARROW","DOTTED_OPEN_ARROW","SOLID_ARROW","BIDIRECTIONAL_SOLID_ARROW","DOTTED_ARROW","BIDIRECTIONAL_DOTTED_ARROW","SOLID_CROSS","DOTTED_CROSS","SOLID_POINT","DOTTED_POINT","SOLID_ARROW_TOP","SOLID_ARROW_BOTTOM","STICK_ARROW_TOP","STICK_ARROW_BOTTOM","SOLID_ARROW_TOP_DOTTED","SOLID_ARROW_BOTTOM_DOTTED","STICK_ARROW_TOP_DOTTED","STICK_ARROW_BOTTOM_DOTTED","SOLID_ARROW_TOP_REVERSE","SOLID_ARROW_BOTTOM_REVERSE","STICK_ARROW_TOP_REVERSE","STICK_ARROW_BOTTOM_REVERSE","SOLID_ARROW_TOP_REVERSE_DOTTED","SOLID_ARROW_BOTTOM_REVERSE_DOTTED","STICK_ARROW_TOP_REVERSE_DOTTED","STICK_ARROW_BOTTOM_REVERSE_DOTTED"],hk=new Uint8Array(128);for(let t=0;t<128;t++){let r=String.fromCharCode(t),n=32===t||t>=9&&t<=13,i=0;`/\\+()<->:
|
|
98
|
+
,;`.includes(r)||(i|=1),`+<->:
|
|
99
|
+
,;`.includes(r)||(i|=2),`<>:
|
|
100
|
+
,;@`.includes(r)||(i|=8|4*!n),`#
|
|
101
|
+
;`.includes(r)||(i|=16),`/\\+()<>:
|
|
102
|
+
,;-`.includes(r)||n||(i|=32),hk[t]=i}var hM=new Int8Array(79).fill(-1);hM[53]=5,hM[54]=6,hM[55]=0,hM[57]=1,hM[56]=33,hM[58]=34,hM[59]=3,hM[60]=4,hM[61]=24,hM[62]=25,hM[63]=41,hM[64]=42,hM[65]=43,hM[66]=44,hM[67]=51,hM[68]=52,hM[69]=53,hM[70]=54,hM[71]=45,hM[72]=46,hM[73]=47,hM[74]=48,hM[75]=55,hM[76]=56,hM[77]=57,hM[78]=58;var h_=new Int8Array(79).fill(-1);h_[21]=2,h_[22]=3,h_[23]=4,h_[28]=5,h_[24]=6,h_[25]=7,h_[26]=7,h_[27]=8,h_[6]=1;var hA=' fill="var(--_s)" stroke="var(--_b)"',hE=' fill="none" stroke="var(--_b)"',hS=new Set(["participant","actor","boundary","control","entity","database","collections","queue"]),hC=new Set(["actor","boundary","control","entity","database"]);function hT(t){return hC.has(t)}var hI=[];function hN(t,r,n,i=1,a=!1){hI[t]={dotted:r,head:n,atStart:1!==i,atEnd:0!==i,bottom:a}}for(let t of(hN(0,!1,1),hN(1,!0,1),hN(3,!1,2),hN(4,!0,2),hN(5,!1,0),hN(6,!0,0),hN(24,!1,3),hN(25,!0,3),hN(33,!1,1,2),hN(34,!0,1,2),[!1,!0])){let r=10*!!t;hN(41+r,t,4),hN(42+r,t,4,1,!0),hN(43+r,t,5),hN(44+r,t,5,1,!0),hN(45+r,t,4,0),hN(46+r,t,4,0,!0),hN(47+r,t,5,0),hN(48+r,t,5,0,!0)}var hO=new Map([[10,"loop"],[12,"alt"],[15,"opt"],[19,"par"],[32,"par"],[27,"critical"],[30,"break"],[22,"rect"]]),hD=' stroke-dasharray="4 4"';function hR(t){return void 0!==t&&void 0!==hI[t]}var hL={lines:[],widths:[],width:0,height:0,size:0,lineHeight:0};function hz(t,r,n){let i=t[r];return"number"==typeof i&&i>=0&&i<=2e3?i:n}function hP(t,r,n,i,a,s){let o=eT(t-8*n);return a?`<path class="pele-marker" d="M${eT(t)},${eT(r)}L${o},${eT(r+5*i)}"/>`:`<path class="pele-marker" d="M${eT(t)},${eT(r)}L${o},${eT(r+4.5*i)}V${eT(r)}Z" fill="${s}" stroke="none"/>`}function hj(t,r,n,i,a,s){switch(t){case 1:return rV("arrow_point",r,n,i,0,s);case 2:return rV("arrow_cross",r,n,i,0,s);case 3:return`<path class="pele-marker" d="M${eT(r-8*i)},${eT(n-4.5)}L${eT(r)},${eT(n)}L${eT(r-8*i)},${eT(n+4.5)}" stroke-linejoin="round"/>`;case 4:return hP(r,n,i,a,!1,s);case 5:return hP(r,n,i,a,!0,s);default:return""}}var hF=class{type="state";rootDoc=[];states=new Map;relations=[];classes=new Map;links=new Map;graph={nodes:[],edges:[]};title;accTitle;accDescr;dividerCount=0;get direction(){let t="TB";for(let r of this.rootDoc)"string"!=typeof r&&"dir"===r.stmt&&(t=r.value);return t}setRootDoc(t){this.rootDoc=t,this.translate(),this.extract(t)}extract(t){this.states=new Map,this.relations=[],this.classes=new Map;let r=Array.isArray(t)?t:t.doc;for(let t of r)if("string"!=typeof t)switch(t.stmt){case"state":this.addState(t.id.trim(),t.type,t.doc,t.description,t.note);break;case"relation":this.addRelation(t.state1,t.state2,t.description);break;case"classDef":this.addStyleClass(t.id.trim(),t.classes);break;case"style":{let r=t.styleClass.split(",").map(t=>t.replace(/;/g,"").trim());for(let n of this.named(t.id.trim()))n.styles=r.slice();break}case"applyClass":this.setCssClass(t.id.trim(),t.styleClass);break;case"click":this.addLink("string"==typeof t.id?t.id:t.id.id,t.url,t.tooltip)}this.graph=function(t,r,n){let i=[],s=[],o=new Map,l=new Map,c=new Map,d=0,u=0,h=t=>{if(!t.id||"</join></fork>"===t.id||"</choice>"===t.id)return;if(t.cssClasses){let r;for(let i of t.cssClasses.split(" ")){let a=n.get(i);if(a)for(let n of(r??=t.cssCompiledStyles.slice(),a.styles))r.push(n)}r&&(t.cssCompiledStyles=r)}let r=o.get(t.id);if(r){let n=t.parentId??r.parentId;Object.assign(r,t),void 0!==n&&(r.parentId=n)}else o.set(t.id,t),i.push(t)},f=(t,n,i)=>{let a=n.id;if("root"===a)return;let o=r.get(a),f=o?.classes?.join(" ")??"",p=o?.styles??[],g=l.get(a);if(!g){let t="rect";!0===n.start?t="stateStart":!1===n.start&&(t="stateEnd"),"default"!==n.type&&(t=n.type),g={shape:t,description:a,cssClasses:`${f} statediagram-state`,cssStyles:p,type:void 0,dir:void 0,colorIndex:void 0},l.set(a,g)}if(n.description&&(Array.isArray(g.description)?(g.shape="rectWithTitle",g.description=g.description.concat(n.description)):g.description.length>0?(g.shape="rectWithTitle",g.description=g.description===a?[n.description].flat():[g.description,n.description].flat()):(g.shape="rect",g.description=Array.isArray(n.description)?n.description.slice():n.description)),1===g.description.length&&"rectWithTitle"===g.shape&&(g.shape="group"===g.type?"roundedWithTitle":"rect"),!g.type&&n.doc){if(g.type="group",g.dir=function(t){let r="TB";for(let n of t)"string"!=typeof n&&"dir"===n.stmt&&(r=n.value);return r}(n.doc),g.shape="divider"===n.type?"divider":"roundedWithTitle","divider"===g.shape&&t?.id!==void 0&&c.has(t.id))g.colorIndex=c.get(t.id);else{let t=u++;g.colorIndex=""!==f.trim()||p.length>0?void 0:t}c.set(a,g.colorIndex),g.cssClasses=`${g.cssClasses} statediagram-cluster ${i?"statediagram-cluster-alt":""}`}let m=g.description,y={id:a,shape:g.shape,label:Array.isArray(m)?m[0]:m,description:Array.isArray(m)?m.slice(1):[],cssClasses:g.cssClasses,cssCompiledStyles:[],cssStyles:g.cssStyles,type:g.type,isGroup:"group"===g.type,dir:g.dir,colorIndex:g.colorIndex};"divider"===y.shape&&(y.label=""),t&&"root"!==t.id&&(y.parentId=t.id);let v=n.note;if(!v)return void h(y);let b=(t,r,n,i)=>({id:t,shape:r,label:v.text,description:[],cssClasses:n,cssCompiledStyles:[],cssStyles:[],type:i?"group":"node",isGroup:i,dir:void 0,position:v.position}),x=b(`${a}----note-${d++}`,"note","statediagram-note",!1);x.parentId=`${a}----parent`,x.noteFor=a,h(b(x.parentId,"noteGroup",g.cssClasses,!0)),h(x),h(y);let w="left of"===v.position,$=w?x.id:a,k=w?a:x.id;s.push({id:`${$}-${k}`,start:$,end:k,label:"",classes:"transition note-edge",pattern:"dashed"})},p=[{item:void 0,doc:t,at:0,alt:!0}];for(;p.length>0;){let t=p[p.length-1];if(t.at>=t.doc.length){p.pop();continue}let r=t.doc[t.at++];"string"!=typeof r&&("state"===r.stmt?(f(t.item,r,t.alt),r.doc&&p.push({item:r,doc:r.doc,at:0,alt:!t.alt})):"relation"===r.stmt&&(f(t.item,r.state1,t.alt),f(t.item,r.state2,t.alt),s.push({id:`edge${d++}`,start:r.state1.id,end:r.state2.id,label:r.description??"",classes:"transition"})))}for(let t of i)if(t.isGroup&&t.description.length>0)throw new a(`Group nodes can only have label. Remove the additional description for node [${t.id}]`,"semantic",{type:"state"});return{nodes:i,edges:s}}(r,this.states,this.classes)}translate(){let t=[["root",{stmt:"root",id:"root",doc:this.rootDoc},!0]];for(;t.length>0;){let[r,n,i]=t.pop();if("string"==typeof n)continue;if("relation"===n.stmt){t.push([r,n.state2,!1],[r,n.state1,!0]);continue}if("state"===n.stmt)"[*]"===n.id?(n.id=r+(i?"_start":"_end"),n.start=i):n.id=n.id.trim();else if("root"!==n.stmt)continue;if(!n.doc)continue;let a=[],s=[];for(let t of n.doc)"string"==typeof t||"state"!==t.stmt||"divider"!==t.type||t.doc?s.push(t):(a.push({...t,doc:s}),s=[]);a.length>0&&(s.length>0&&a.push({stmt:"state",id:this.getDividerId(),type:"divider",doc:s}),n.doc=a);for(let r=n.doc.length-1;r>=0;r--)t.push([n.id,n.doc[r],!0])}}addState(t,r="default",n,i,a,s){let o=t.trim(),l=this.states.get(o);if(l?(l.doc||(l.doc=n),l.type||(l.type=r)):(l={stmt:"state",id:o,descriptions:[],type:r,doc:n,note:a,classes:[],styles:[],textStyles:[]},this.states.set(o,l)),i)for(let t of Array.isArray(i)?i:[i])this.addDescription(o,t.trim());if(a&&(l.note=a),s)for(let t of s)this.setCssClass(o,t.trim())}getState(t){return this.states.get(t)}addLink(t,r,n){this.links.set(t,{url:r,tooltip:n})}addRelation(t,r,n=""){for(let n of[t,r])this.addState(n.id,n.type,n.doc,n.description,n.note,n.classes);this.relations.push({id1:t.id.trim(),id2:r.id.trim(),relationTitle:n})}addDescription(t,r){this.states.get(t)?.descriptions?.push(r.startsWith(":")?r.replace(":","").trim():r)}getDividerId(){return`divider-id-${++this.dividerCount}`}addStyleClass(t,r=""){let n=this.classes.get(t);if(n||(n={id:t,styles:[],textStyles:[]},this.classes.set(t,n)),r)for(let t of r.split(",")){let r=t.replace(";","").trim();t.includes("color")&&n.textStyles.push(r.replace("fill","bgFill").replace("color","fill")),n.styles.push(r)}}setCssClass(t,r){for(let n of this.named(t))n.classes?.push(r)}getDirection(){for(let t of this.rootDoc)if("string"!=typeof t&&"dir"===t.stmt)return t.value;return"TB"}setDirection(t){for(let r of this.rootDoc)if("string"!=typeof r&&"dir"===r.stmt){r.value=t;return}this.rootDoc.unshift({stmt:"dir",value:t})}trimColon(t){return t.startsWith(":")?t.slice(1).trim():t.trim()}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
|
|
103
|
+
`)}named(t){let r=[];for(let n of t.split(",")){let t=this.states.get(n);t||(this.addState(n),t=this.states.get(n.trim())),t&&r.push(t)}return r}},hB=["$end","INVALID","NL","SD","DESCR","--\x3e","HIDE_EMPTY","scale","WIDTH","COMPOSIT_STATE","STRUCT_START","STRUCT_STOP","STATE_DESCR","AS","ID","FORK","JOIN","CHOICE","CONCURRENT","note","NOTE_TEXT","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","CLICK","STRING","HREF","classDef","CLASSDEF_ID","DEFAULT_CLASSDEF_ID","CLASSDEF_STYLEOPTS","DEFAULT","style","STYLE_IDS","STYLEDEF_STYLEOPTS","class","CLASSENTITY_IDS","STYLECLASS","direction_tb","direction_bt","direction_rl","direction_lr","EDGE_STATE","STYLE_SEPARATOR","left_of","right_of","INVALID"],hW=/direction/gi,hH=/<<(?:fork|join|choice)>>|\[\[(?:fork|join|choice)\]\]/gi,hU=/[\n\r\u2028\u2029]/g,hq=/%%/g,hV=/\{/g;function hY(t,r){let n=0,i=-2;return a=>{if(-2===i||a<n||-1!==i&&a>i){t.lastIndex=a;let s=t.exec(r);i=s?s.index:-1,n=a}return i}}var hG=["TB","BT","RL","LR"],hZ="'NL', 'ID', 'HIDE_EMPTY', 'scale', 'COMPOSIT_STATE', 'STATE_DESCR', 'FORK', 'JOIN', 'CHOICE', 'CONCURRENT', 'note', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'CLICK', 'classDef', 'style', 'class', 'direction_tb', 'direction_bt', 'direction_rl', 'direction_lr', 'EDGE_STATE'",hX=' fill="var(--_s)" stroke="var(--_b)"',hK=' fill="none" stroke="var(--_b)"',hJ=/(?:^| )statediagram-(?:state|cluster-alt|cluster|note)(?= |$)/g,hQ=new Map([["rectWithTitle",1],["stateStart",2],["stateEnd",3],["choice",4],["fork",5],["join",6],["note",7],["divider",10]]),h0=["pele-node pele-state","pele-node pele-state","pele-node pele-state-start","pele-node pele-state-end","pele-node pele-state-choice","pele-node pele-state-fork","pele-node pele-state-join","pele-note","pele-cluster pele-state-composite"];function h1(t){return"TB"===t||"BT"===t}function h2(t,r,n){let i=t.state?.[r];return"number"==typeof i&&i>0?Math.min(i,2e3):n}function h4(t){let r=0,n=t.length;for(;r<n&&34===t.charCodeAt(r);)r++;for(;n>r&&34===t.charCodeAt(n-1);)n--;return t.slice(r,n)}function h3(t,r,n,i,a){return`<rect x="${eT(t)}" y="${eT(r)}" width="${eT(n)}" height="${eT(i)}"${a}/>`}function h5(t,r,n,i){let a=rR(0,0);return a.isGroup=!0,a.dir=t,a.padX=r,a.padTop=n,a.padBottom=i,a}function h6(t,r,n,i){let a=t.graph,s=r.flowchart?.curve,o=n.fontSize??16,l=Math.round(.875*o),c=n.measurer??e$(n.fontFamily,n.fontFamilyMono),d=h2(r,"wrappingWidth",200),u=n.padding??8,h=n.icons,f=i?"TB":rC(t.direction),p=n7(void 0,!1,c,o,0),g=(t,r,n,i=0)=>n7(t,!0,c,r,n,i),m=new Map,v=[],b=[],x=(t,r,n)=>(v.push({node:t,kind:r,style:void 0,label:p,lines:[],w:0,h:0,titleH:0}),n&&b.push(n),v.length-1);for(let t of a.nodes){if("noteGroup"===t.shape)continue;let r=t.isGroup?"divider"===t.shape?9:8:hQ.get(t.shape)??0;m.set(t.id,x(t,r,void 0))}let w=v.length,$=[];for(let t=0;t<w;t++){let r=v[t].node.parentId,n=void 0===r?void 0:m.get(r);$.push(void 0!==n&&n!==t&&v[n].node.isGroup?n:-1)}{let t=[];for(let r=0;r<w;r++)t.push([]);let r=[],n=new Uint8Array(w);for(let i=0;i<w;i++)-1===$[i]?(n[i]=1,r.push(i)):t[$[i]].push(i);let i=0,a=()=>{for(;i<r.length;i++)for(let a of t[r[i]])n[a]||(n[a]=1,r.push(a))};a();let s=new Int32Array(w).fill(-1);for(let t=0;t<w;t++){if(n[t])continue;let i=t;for(;s[i]!==t;)s[i]=t,i=$[i];$[i]=-1,n[i]=1,r.push(i),a()}}let k=new Int32Array(w).fill(-1);for(let t=0;t<w;t++){let r=v[t].node.noteFor,n=void 0===r?void 0:m.get(r);void 0!==n&&(k[t]=n,$[t]=$[n])}let M=t=>rC(v[t].node.dir),_=t=>h1(-1===$[t]?f:M($[t])),A=new Int32Array(w),E=new Uint8Array(w),S=Array(w).fill(1/0),C=0,T=new Int32Array(2*w);for(let t of a.edges){let r=m.get(t.start),n=m.get(t.end);if(void 0!==r&&void 0!==n){if("dashed"===t.pattern){E[7===v[r].kind?n:r]=1;continue}A[r]=Math.max(A[r],++T[2*r]),A[n]=Math.max(A[n],++T[2*n+1]),S[r]===1/0&&(S[r]=C++),S[n]===1/0&&(S[n]=C++)}}for(let t=0;t<w;t++){let r,n=v[t],i=n.node,a=no(i.cssStyles.length>0?i.cssCompiledStyles.concat(i.cssStyles):i.cssCompiledStyles),s=!!a.bold|2*!!a.italic,c=a.fontSize??o;switch(n.style=a,n.kind){case 8:n.label=g(i.label,c,4e3,s),n.titleH=n.label.height>0?n.label.height+12:0,(r=h5(M(t),16,n.titleH+16,16)).minW=n.label.width+32;break;case 9:r=h5(M(t),10,10,10);break;case 2:n.w=n.h=14;break;case 3:n.w=n.h=18;break;case 4:n.w=n.h=30;break;case 5:case 6:{var I;let r=(I=40*A[t]+16)<72?72:I>320?320:I;n.w=_(t)?r:8,n.h=_(t)?8:r;break}case 10:break;case 7:n.label=g(i.label,l,Math.max(d,320)),n.w=n.label.width+24,n.h=n.label.height+16;break;default:{n.label=g(i.label,c,d,s);let t=n.label.width,r=n.label.height+20;if(1===n.kind)for(let a of(r+=14,i.description)){let i=g(""===a?" ":a,l,d,s);n.lines.push(i),i.width>t&&(t=i.width),r+=i.height}n.w=Math.max(t+32,56),n.h=r}}r??=rR(n.w,n.h),(0===n.kind||1===n.kind)&&(r.span=(_(t)?n.w:n.h)-24),b.push(r)}let N=[],O=[],D=[],R=new Int32Array(w),L=new Float64Array(w),z=new Float64Array(w),P=new Map,j=(t,r)=>{if(!b[t].isGroup)return!1;for(let n=$[r];-1!==n;n=$[n])if(n===t)return!0;return!1},F=(t,r)=>(P.set(N.length,t),S.push(r?-1:1/0),x(void 0,10,rR(0,0,t)));for(let t of a.edges){let r=m.get(t.start),n=m.get(t.end);if(void 0===r||void 0===n)continue;let i=g(t.label,l,d),a=i.width>0?i.width+12:0;r===n?(R[r]++,L[r]=Math.max(L[r],a),z[r]+=i.height):j(r,n)?r=F(r,!0):j(n,r)&&(n=F(n,!1)),D.push(t),O.push(i),N.push({src:r,dst:n,minlen:1,labelW:a,labelH:i.height>0?i.height+4:0,route:[],labelX:0,labelY:0})}for(let t=0;t<w;t++){if(-1!==k[t])continue;let r=b[t],n=0;if(R[t]>0){let i=26+(R[t]-1)*8;n=_(t)?i+L[t]:.75*i+4+z[t],r.isGroup||(_(t)?(r.w+=2*n,r.h=Math.max(r.h,z[t])):(r.h+=2*n,r.w=Math.max(r.w,L[t])),n=0)}if(!E[t]&&0===n){r.parent=$[t];continue}let i=_(t)?h5("LR",n,0,0):h5("TB",0,n,n);i.parent=$[t],S.push(S[t]),b[t].parent=x(void 0,10,i)}for(let t=0;t<w;t++)-1!==k[t]&&(b[t].parent=b[k[t]].parent);{let t=[];for(let r=0;r<b.length;r++)t.push([]);let r=[];for(let n=0;n<b.length;n++){let i=b[n].parent;i>=0?t[i].push(n):r.push(n)}let n=t=>+(2!==v[t].kind),i=(t,r)=>n(t)-n(r)||(S[t]===S[r]?0:S[t]<S[r]?-1:1)||t-r,a=0,s=r.sort(i).reverse();for(;s.length>0;){let r=s.pop();b[r].seq=a++;let n=t[r].sort(i);for(let t=n.length-1;t>=0;t--)s.push(n[t])}}let B=rP(b,N,f,{nodeSep:h2(r,"nodeSpacing",40),edgeSep:16,rankSep:h2(r,"rankSpacing",44),portSep:20,tracks:"step"===s||"stepBefore"===s||"stepAfter"===s,straight:"linear"===s,headRoom:rq("arrow_point")}),W=Math.ceil(B.width+2*u),H=Math.ceil(B.height+2*u),U=[],q=new Map;for(let t of N){let r=t.route;for(let t=3;t<r.length-3;t+=3){let n=Math.round(r[t+1]),i=q.get(n);i?i.push(r[t]):q.set(n,[r[t]])}}let V=[];for(let t=0;t<b.length;t++)V.push([]);let Y=[];for(let t=0;t<b.length;t++){let r=b[t].parent;r>=0?V[r].push(t):Y.push(t)}let G=Y.slice();for(let t=0;t<Y.length;t++)for(let r of V[Y[t]])Y.push(r);let Z="",X=[],K="",J="",Q="",ee=(t,r,n,i,a)=>{let s=t.filter(t=>9===v[t].kind);if(s.length<2)return;let o=(t,r)=>r?b[t].x-b[t].w/2:b[t].y-b[t].h/2,l=(t,r)=>r?b[t].x+b[t].w/2:b[t].y+b[t].h/2;for(let t of[!0,!1]){let c=s.slice().sort((r,n)=>o(r,t)-o(n,t)||r-n),d=!0;for(let r=1;r<c.length;r++)l(c[r-1],t)>o(c[r],t)+.5&&(d=!1);if(d){for(let s=1;s<c.length;s++){let d=eT((l(c[s-1],t)+o(c[s],t))/2+u);K+=`<path class="pele-divider" d="M${t?`${d},${eT(n)}V${eT(a)}`:`${eT(r)},${d}H${eT(i)}`}"/>`}return}}for(let t of s){let r=b[t];K+=h3(r.x-r.w/2+u,r.y-r.h/2+u,r.w,r.h,' class="pele-divider" rx="10"')}};for(let r of(ee(G,u/2,u/2,W-u/2,H-u/2),Y)){let i=v[r],a=i.node,s=i.style;if(void 0===a||void 0===s||i.kind>=9)continue;let o=b[r],c=o.x+u,d=o.y+u,f=i.w,p=i.h,g=e8(s),m=` class="pele-label"${g}${s.text}`,x;switch(i.kind){case 8:{let t=c-o.w/2,n=d-o.h/2;e6(s.shape)&&X.push({box:[t,n,t+o.w,n+o.h],shape:s.shape}),x=h3(t,n,o.w,o.h,` rx="10" fill="var(--_a)"${r8(s.shape)?"":' fill-opacity="0.5"'} stroke="var(--_b)"${s.shape}`),i.titleH>0&&(x+=`<path d="M${eT(t)},${eT(n+i.titleH)}H${eT(t+o.w)}"${hK}${s.line}/>`+eI(i.label,function(t,r,n){let i=n.get(Math.round(t.y-t.h/2));if(void 0===i||0===r)return t.x;let a=t.x-t.w/2,s=r/2,o=t.x,l=-1;for(let r of[t.x,a+16+s,a+t.w-16-s]){let n=1/0;for(let o of i)o>a&&o<a+t.w&&(n=Math.min(n,Math.abs(o-r)-s));if(n>=6)return r;n>l+.5&&(l=n,o=r)}return o}(o,i.label.width,q)+u,n+i.titleH/2,` class="pele-cluster-label"${g}${s.text}`,h)),ee(V[r],t,n+i.titleH,t+o.w,n+o.h);break}case 2:x=`<circle r="7" fill="var(--_l)"${s.shape}/>`;break;case 3:x=`<circle r="8.5" fill="var(--_bg)" stroke="var(--_l)"${s.line}/><circle r="5" fill="var(--_l)"${s.shape}/>`;break;case 4:x=`<polygon points="0,${eT(-p/2)} ${eT(f/2)},0 0,${eT(p/2)} ${eT(-f/2)},0"${hX}${s.shape}/>`;break;case 5:case 6:x=h3(-f/2,-p/2,f,p,` rx="2" fill="var(--_l)"${s.shape}`);break;case 7:{let t=eT(f/2),r=eT(p/2),n=eT(f/2-8),a=eT(8-p/2);x=`<path d="M-${t},-${r}H${n}L${t},${a}V${r}H-${t}Z" fill="var(--_bg)" stroke="var(--_b)"/><path d="M${n},-${r}V${a}H${t}"${hK}/>`+eI(i.label,0,0,` class="pele-label" font-size="${l}" fill="var(--_m)"`,h);break}default:{if(x=h3(-f/2,-p/2,f,p,` rx="${eT(Math.min(10,p/2))}"${hX}${s.shape}`),0===i.kind){x+=eI(i.label,0,0,m,h);break}let t=10-p/2+i.label.height;for(let r of(x+=`<path d="M${eT(-f/2)},${eT(t+6)}H${eT(f/2)}"${hK}${s.line}/>`+eI(i.label,0,t-i.label.height/2,m,h),t+=14,i.lines))x+=eI(r,0,t+r.height/2,` class="pele-state-description" font-size="${l}"${g}${s.text}`,h),t+=r.height}}let w=t.links.get(a.id);if(w){let t=y(h4(w.tooltip));t&&(x=`<title>${eE(t)}</title>`+x),x=tI(x,tw(h4(w.url)),a.id,U,n,' target="_blank"')}let $=`<g class="${h0[i.kind]}${nc(a.cssClasses.replace(hJ,""))}" data-id="${eS(a.id)}"`;8===i.kind?Z+=`${$}>${x}</g>`:7===i.kind?Q+=`${$} transform="translate(${eT(c)},${eT(d)})">${x}</g>`:J+=`${$} transform="translate(${eT(c)},${eT(d)})">${x}</g>`}let et=(t,r,n)=>{let i=b[n];if(i.isGroup)return;let a=v[n],s=5===a.kind||6===a.kind,o=0===r?3:r-3;for(let n of[1,0]){let h=n?i.h:i.w,f=n?a.h:a.w,p=n?a.w:a.h,g=(n?i.y:i.x)+u,m=(n?i.x:i.y)+u,y=t[r+n]-g;if(!(Math.abs(Math.abs(y)-h/2)>=.5)){var l,c,d;t[r+n]-=Math.sign(y)*(h-f)/2,s&&p>f&&(t[r+1-n]=(l=t[o+1-n],c=m-p/2+6,d=m+p/2-6,l<c?c:l>d?d:l));return}}},er=rH();for(let t=0;t<N.length;t++){let r=N[t];r.src===r.dst||r.route.length<6||"dashed"===D[t].pattern||er.add(r.dst,nz(r.route,r.route.length-3,b[r.dst]),"arrow_point")}let en="",ei="",ea="",es=new Int32Array(w),eo=new Float64Array(w);for(let t=0;t<N.length;t++){let r=N[t],n=D[t],i=O[t],a="dashed"===n.pattern,o=a?"none":"arrow_point",l;if(r.src===r.dst){let t=b[r.src],n=v[r.src],a=es[r.src]++,s=_(r.src),c=t.isGroup?t.w:n.w,d=t.isGroup?t.h:n.h,h=(s?c:d)/2,f=Math.max(Math.min((s?d:c)/2-4,8+6*a),2),p=26+8*a,g=rq(o)/(Math.hypot(p,f)||1),m=(r,n)=>t.x+u+(s?h+r:-n),y=(r,n)=>t.y+u+(s?n:h+r),x=(t,r)=>`${eT(m(t,r))},${eT(y(t,r))}`,w=Math.hypot((l={d:`M${x(0,-f)}C${x(p,-2*f)} ${x(p,2*f)} ${x(p*g,f+f*g)}`,sx:0,sy:0,sdx:0,sdy:0,ex:m(0,f),ey:y(0,f),edx:m(-p,-f)-m(0,0),edy:y(-p,-f)-y(0,0)}).edx,l.edy)||1;l.edx/=w,l.edy/=w;let $=26+(R[r.src]-1)*8,k=eo[r.src]+i.height/2;eo[r.src]+=i.height,r.labelX=s?t.x+h+$+4+r.labelW/2:t.x,r.labelY=s?t.y-z[r.src]/2+k:t.y+h+.75*$+4+k}else{let n=r.route.slice(),i=er.of(r.src,nz(n,0,b[r.src])),a=er.of(r.dst,nz(n,n.length-3,b[r.dst]));for(let t=0;t<n.length;t+=3)n[t]+=u,n[t+1]+=u;et(n,0,r.src),et(n,n.length-3,r.dst);let c=P.get(t);if(void 0!==c&&n.length>=6){let t=b[c],i=10===v[r.src].kind,a=i?0:n.length-3,s=("TB"===t.dir||"LR"===t.dir)===i,o=h1(t.dir)?[n[a],t.y+u+(s?v[c].titleH-t.h/2:t.h/2),0]:[t.x+u+(s?-t.w/2:t.w/2),n[a+1],1];n=i?o.concat(n):n.concat(o)}l=rU(n,"string"==typeof s?s:void 0,0,rq(o),i,a)}let c=rJ(l.d,[l.ex,l.ey],X,"",l.tokens);""===c&&(en+=r0(l,"none",o));let d=a?`pele-note-edge" stroke="${c||"var(--_b)"}" stroke-dasharray="3 4`:c?`pele-transition" stroke="${c}`:"pele-transition";if(ei+=`<g class="pele-edge ${d}" data-id="${eS(n.id)}"><path d="${l.d}"/>`+rV(o,l.ex,l.ey,l.edx,l.edy,c||"var(--_l)")+"</g>",i.width>0){let t=r.labelX+u,a=r.labelY+u;ea+=r2(n.id,i,t,a,"",h)}}let el=au(t.title,c,o,u,W,H,(Z?`<g class="pele-clusters">${Z}</g>`:"")+(K?`<g class="pele-dividers" stroke-dasharray="4 4"${hK}>${K}</g>`:"")+r1(en)+(ei?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${ei}</g>`:"")+(ea?`<g class="pele-edge-labels" font-size="${l}">${ea}</g>`:"")+`<g class="pele-nodes">${J}${Q}</g>`);return{svg:np("state",el.width,el.height,o,n,t,el.content),width:el.width,height:el.height,links:U}}function h8(t,r){let n=r.x-t.x,i=r.y-t.y,a=Math.max(t.w/2,.5),s=Math.max(t.h/2,.5);if(Math.abs(n)<a&&Math.abs(i)<s)return a-Math.abs(n)<s-Math.abs(i)?[t.x+(n<0?-a:a),r.y]:[r.x,t.y+(i<0?-s:s)];let o=Math.min(0!==n?a/Math.abs(n):1/0,0!==i?s/Math.abs(i):1/0);return[t.x+n*o,t.y+i*o]}var h9="__swimlane_default__",h7={type:"swimlane",prepare:function(t){let r=!1;for(let n of t.nodes)n.isGroup?n.dir=void 0:void 0===n.parentId&&(r=!0);if(r){for(let r of t.nodes)r.isGroup||void 0!==r.parentId||(r.parentId=h9);t.nodes.push({id:h9,label:void 0,labelType:"text",shape:"rect",isGroup:!0,parentId:void 0,cssStyles:[],cssCompiledStyles:[],cssClasses:"",dir:void 0})}},layout:(t,r,n,i,a)=>(function(t,r,n,i,a=24){let s=t.length;if(0===s)return{width:0,height:0};let o="LR"===n||"RL"===n,l="BT"===n||"RL"===n,c=[];for(let r=s-1;r>=0;r--)t[r].parent<0&&t[r].isGroup&&c.push(r);let d=Math.max(1,c.length),u=new Int32Array(s).fill(-1);c.forEach((t,r)=>u[t]=r);let h=new Uint8Array(s);for(let r=0;r<s;r++)t[r].parent>=0&&(h[t[r].parent]=1);let f=new Float64Array(d).fill(a),p=a,g=new Int32Array(s).fill(-1),m=[];for(let r=0;r<s;r++)u[r]>=0||t[r].isGroup&&h[r]||(g[r]=m.length,m.push(r));let y=m.map(r=>{let n,i;return rg((n=t[r],o?n.h:n.w),(i=t[r],o?i.w:i.h))}),v=[],b=[],x=1;{let t=new Set;for(let n=0;n<r.length;n++){let i=r[n],a=g[i.src],s=g[i.dst];if(a<0||s<0||a===s)continue;let l=Math.min(a,s)*m.length+Math.max(a,s);(i.labelW>0||t.has(l))&&(x=2),t.add(l),v.push(rm(a,s,i.minlen,o?i.labelH:i.labelW,o?i.labelW:i.labelH)),b.push(n)}}r$(y,v),rk(y,v,x);let w=v.length,$=Int32Array.from(m,r=>{let n=r,i=a;for(let r=0;t[n].parent>=0&&r<1e4;r++)u[n=t[n].parent]<0&&(i+=Math.max(t[n].padX,t[n].padTop,t[n].padBottom));let s=Math.max(0,u[n]);return i>f[s]&&(f[s]=i),i>p&&(p=i),s}),k=(n,a)=>{let h=f.map((t,r)=>a[r]?Math.max(t,20):t),k=new Uint8Array(d),M=0,_=new Int32Array(w);for(let t=0;t<w;t++)_[t]=Math.abs(y[v[t].head].rank-y[v[t].tail].rank),n[t]||(M+=_[t]-1);let A=M>2e4,E=m.length+(A?0:M),S=new Int32Array(E),C=new Int32Array(E),T=new Float64Array(E),I=new Float64Array(E),N=new Uint8Array(E),O=0;for(let t=0;t<m.length;t++)S[t]=y[t].rank,C[t]=$[t],T[t]=y[t].w,I[t]=y[t].h,S[t]>O&&(O=S[t]);let D=new Int32Array(w).fill(-1),R=new Int32Array(w).fill(-1),L=[];{let t=m.length;for(let r=0;r<w;r++){let i=v[r],a=i.reversed?i.head:i.tail,s=i.reversed?i.tail:i.head;if(A||_[r]<2||n[r]){L.push(a,s);continue}let o=S[a],l=S[s],c=-1;i.labelW>0&&(c=o+(l-o>>1),2===x&&(1&c)==0&&c--),D[r]=t;let d=a;for(let n=o+1;n<l;n++){let u=t++;S[u]=n,C[u]=C[a]+Math.round((C[s]-C[a])*(n-o)/(l-o)),N[u]=1,n===c&&(T[u]=i.labelW,I[u]=i.labelH,R[r]=u),L.push(d,u),d=u}L.push(d,s)}}let z=new Int32Array(E+1),P=new Int32Array(E+1);for(let t=0;t<L.length;t+=2)P[L[t]+1]++,z[L[t+1]+1]++;for(let t=0;t<E;t++)z[t+1]+=z[t],P[t+1]+=P[t];let j=new Int32Array(L.length/2),F=new Int32Array(L.length/2);{let t=z.slice(0,E),r=P.slice(0,E);for(let n=0;n<L.length;n+=2)F[r[L[n]]++]=L[n+1],j[t[L[n+1]]++]=L[n]}let B=[];for(let t=0;t<=O;t++)B.push([]);for(let t=0;t<E;t++)B[S[t]].push(t);let W=new Float64Array(E),H=new Float64Array(E),U=t=>{t.sort((t,r)=>C[t]-C[r]||H[t]-H[r]||t-r);for(let r=0;r<t.length;r++)W[t[r]]=r};for(let t of B){for(let r=0;r<t.length;r++)H[t[r]]=r;U(t)}for(let t=0;t<8&&O>0;t++){let r=(1&t)==0;for(let t=1;t<=O;t++){let n=B[r?t:O-t],i=r?z:P,a=r?j:F;for(let t of n){let r=0,n=i[t+1]-i[t];for(let n=i[t];n<i[t+1];n++)r+=W[a[n]];H[t]=n>0?r/n:W[t]}U(n)}}let q=(t,r)=>N[t]||N[r]?i.edgeSep:i.nodeSep,V=(t,r)=>{let n=0;for(;n<t.length;){let i=n;for(;i+1<t.length&&C[t[i+1]]===C[t[n]];)i++;r(t,n,i),n=i+1}},Y=(t,r,n)=>{let i=T[t[r]];for(let a=r;a<n;a++)i+=q(t[a],t[a+1])+T[t[a+1]];return i},G=new Float64Array(d),Z=34*(c.length>0);for(let r=0;r<c.length;r++){let n=t[c[r]];G[r]=Math.max(0,n.minW-2*h[r]),n.padTop>Z&&(Z=n.padTop)}for(let t of B)V(t,(r,n,i)=>{let a=Y(t,n,i);a>G[C[t[n]]]&&(G[C[t[n]]]=a)});let X=new Float64Array(d+1);for(let t=0;t<d;t++)X[t+1]=X[t]+G[t]+2*h[t];let K=new Float64Array(E),J=new Float64Array(E),Q=(t,r,n)=>{let i=C[t[r]],a=(X[i]+h[i]+(X[i+1]-h[i])-Y(t,r,n))/2;for(let i=r;i<=n;i++)K[t[i]]=a+T[t[i]]/2,i<n&&(a+=T[t[i]]+q(t[i],t[i+1]))},ee=(t,r,n)=>{let i=C[t[r]],a=X[i]+h[i];for(let i=r;i<=n;i++){let r=t[i];K[r]=Math.max(J[r],a+T[r]/2),i<n&&(a=K[r]+T[r]/2+q(r,t[i+1]))}let s=X[i+1]-h[i];for(let i=n;i>=r;i--){let n=t[i];K[n]=Math.min(K[n],s-T[n]/2),i>r&&(s=K[n]-T[n]/2-q(t[i-1],n))}};for(let t of B)V(t,Q);for(let t=0;t<4&&O>0;t++){let r=(1&t)==0;for(let t=1;t<=O;t++){let n=B[r?t:O-t],i=r?z:P,a=r?j:F;for(let t of n){let r=0,n=0;for(let s=i[t];s<i[t+1];s++)C[a[s]]===C[t]&&(r+=K[a[s]],n++);J[t]=n>0?r/n:K[t]}V(n,ee)}}let et=new Float64Array(O+1),er=new Float64Array(O+1),en=new Float64Array(O+1).fill(i.rankSep/x);if(n.some(t=>1===t)){let t=i.rankSep/x;en.fill(t/3);for(let r=0;r<w;r++){let i=v[r],a=i.reversed?i.head:i.tail,s=i.reversed?i.tail:i.head;if(n[r]){if(i.labelH<=0||_[r]>x)continue;let n=Math.min(t,(i.labelH+40-Math.min(I[a],I[s])/2)/_[r]);for(let t=S[a];t<S[s];t++)n>en[t]&&(en[t]=n);continue}let o=D[r];if(o<0||_[r]<=x*i.minlen){for(let r=S[a];r<S[s];r++)en[r]=t;continue}for(let n=o-1;n<o+_[r]-1;n++){let i=n<o?a:n,l=n+1<o+_[r]-1?n+1:s;(C[i]!==C[l]||Math.abs(K[i]-K[l])>=.5)&&(en[S[i]]=t)}}}let ei=Z+p;for(let t=0;t<=O;t++){let r=0;for(let n of B[t])I[n]>r&&(r=I[n]);et[t]=ei,er[t]=ei+r,ei+=r+(t===O?0:en[t])}let ea=ei+p,es=X[d],eo=t=>l?Z+ea-t:t,el=(t,r)=>o?eo(r):t,ec=(t,r)=>o?t:eo(r),ed=+!!o;for(let r=0;r<m.length;r++){let n=t[m[r]],i=(et[S[r]]+er[S[r]])/2;n.x=el(K[r],i),n.y=ec(K[r],i)}for(let r=0;r<c.length;r++){let n=t[c[r]],i=(X[r]+X[r+1])/2,a=X[r+1]-X[r];n.x=o?ea/2:i,n.y=o?i:ea/2,n.w=o?ea:a,n.h=o?a:ea,n.padTop=Z}let eu=new Int32Array(s),eh=[];for(let r=0;r<s;r++){if(!t[r].isGroup||u[r]>=0||g[r]>=0)continue;let n=0;for(let i=t[r].parent;i>=0&&n<1e4;i=t[i].parent)n++;eu[r]=n,eh.push(r)}eh.sort((t,r)=>eu[r]-eu[t]||t-r);let ef=new Float64Array(4*s);for(let t=0;t<s;t++)ef[4*t]=1/0,ef[4*t+1]=1/0,ef[4*t+2]=-1/0,ef[4*t+3]=-1/0;let ep=(t,r)=>{r.x-r.w/2<ef[4*t]&&(ef[4*t]=r.x-r.w/2),r.y-r.h/2<ef[4*t+1]&&(ef[4*t+1]=r.y-r.h/2),r.x+r.w/2>ef[4*t+2]&&(ef[4*t+2]=r.x+r.w/2),r.y+r.h/2>ef[4*t+3]&&(ef[4*t+3]=r.y+r.h/2)};for(let r of m)t[r].parent>=0&&u[t[r].parent]<0&&ep(t[r].parent,t[r]);for(let r of eh){let n=t[r];if(ef[4*r]===1/0)continue;let i=Math.max(ef[4*r+2]-ef[4*r]+2*n.padX,n.minW);n.x=(ef[4*r]+ef[4*r+2])/2,n.w=i,n.y=(ef[4*r+1]-n.padTop+ef[4*r+3]+n.padBottom)/2,n.h=ef[4*r+3]-ef[4*r+1]+n.padTop+n.padBottom,n.parent>=0&&u[n.parent]<0&&ep(n.parent,n)}for(let t of r)t.route=[];for(let t=0;t<w;t++){let n=v[t],i=r[b[t]],a=n.reversed?n.head:n.tail,s=n.reversed?n.tail:n.head,o=[K[a],er[S[a]]-(er[S[a]]-et[S[a]]-I[a])/2],l=D[t];if(l>=0)for(let r=l;r<l+_[t]-1;r++)o.push(K[r],et[S[r]]),er[S[r]]>et[S[r]]&&o.push(K[r],er[S[r]]);o.push(K[s],et[S[s]]+(er[S[s]]-et[S[s]]-I[s])/2);let c=[];for(let t=0;t<o.length;t+=2)c.push(el(o[t],o[t+1]),ec(o[t],o[t+1]),ed);if(n.reversed)for(let t=0,r=c.length-3;t<r;t+=3,r-=3)for(let n=0;n<2;n++){let i=c[t+n];c[t+n]=c[r+n],c[r+n]=i}i.route=c;let d=R[t];if(d>=0){let t=(et[S[d]]+er[S[d]])/2;i.labelX=el(K[d],t),i.labelY=ec(K[d],t)}else i.labelX=(c[0]+c[c.length-3])/2,i.labelY=(c[1]+c[c.length-2])/2}for(let n of r){if(n.route.length>0||n.src===n.dst)continue;let r=t[n.src],i=t[n.dst],[a,s]=h8(r,i),[o,l]=h8(i,r),c=+(Math.abs(o-a)>Math.abs(l-s));n.route=[a,s,c,o,l,c],n.labelX=(a+o)/2,n.labelY=(s+l)/2}let eg=new Uint8Array(w),em=r.reduce((t,r)=>t+r.route.length/3,0),ey=w*(m.length+r.length+em);if(ey<=2e6){let t=t=>(et[S[t]]+er[S[t]])/2,n=r.map(t=>[o?t.labelY:t.labelX,eo(o?t.labelX:t.labelY)]),i=(t,r,n,i,a,s,o,l)=>n>a-o/2&&t<a+o/2&&i>s-l/2&&r<s+l/2,a=(a,s,l,c,d,u,h)=>{for(let r=0;r<m.length;r++)if(r!==d&&r!==u&&i(a,s,l,c,K[r],t(r),T[r]+8,I[r]+8))return!1;for(let t=0;t<r.length;t++){let d=r[t];if(t!==h&&d.labelW>0&&d.src!==d.dst&&i(a,s,l,c,n[t][0],n[t][1],o?d.labelH:d.labelW,o?d.labelW:d.labelH))return!1}return!0},s=(t,n,i,a,s)=>{let o=0;for(let l=0;l<r.length;l++){if(l===s)continue;let c=r[l].route;for(let r=3;r<c.length;r+=3)if(Math.max(c[r-3],c[r])>t&&Math.min(c[r-3],c[r])<i&&Math.max(c[r-2],c[r+1])>n&&Math.min(c[r-2],c[r+1])<a){o++;break}}return o},l=(t,n,i)=>{let a=0;for(let s=0;s<r.length;s++){let o=r[s].route;if(s===i||0===o.length)continue;let l=o.length-3;(1>Math.abs(o[0]-t)&&1>Math.abs(o[1]-n)||1>Math.abs(o[l]-t)&&1>Math.abs(o[l+1]-n))&&a++}return a},c=(t,n,i,a,s)=>{let o=.5>Math.abs(i-t),l=o?Math.min(n,a):Math.min(t,i),c=o?Math.max(n,a):Math.max(t,i),d=o?t:n;for(let t=0;t<r.length;t++){let n=r[t];if(t===s||n.src===r[s].src||n.dst===r[s].dst)continue;let i=n.route;for(let t=3;t<i.length;t+=3){let r=i[t-3+ +!o],n=i[t+ +!o];if(Math.abs(r-d)>=4||Math.abs(n-d)>=4)continue;let a=i[t-3+ +!!o],s=i[t+ +!!o];if(Math.min(c,Math.max(a,s))-Math.max(l,Math.min(a,s))>1)return!0}}return!1};for(let i=0;i<w;i++){let o=v[i],d=b[i],u=r[d],f=o.tail,p=o.head;if(C[f]===C[p]||1>Math.abs(K[p]-K[f]))continue;let g=K[f],m=K[p],y=t(f),x=t(p),w=Math.sign(m-g),$=Math.sign(x-y),M=(t,r)=>{for(let n=2;n<t.length;n+=2)if(!a(Math.min(t[n-2],t[n])-r,Math.min(t[n-1],t[n+1])-r,Math.max(t[n-2],t[n])+r,Math.max(t[n-1],t[n+1])+r,f,p,d)||c(el(t[n-2],t[n-1]),ec(t[n-2],t[n-1]),el(t[n],t[n+1]),ec(t[n],t[n+1]),d))return!1;let l=0,h=0,g=-1;if(u.labelW>0){let r=o.labelW,n=o.labelH;for(let i=2;i<t.length;i+=2){let o=(t[i-2]+t[i])/2,c=(t[i-1]+t[i+1])/2,f=Math.abs(t[i]-t[i-2]),p=Math.abs(t[i+1]-t[i-1]),m=f+p;if(m<=g||(f>0?f<r+8:p<n+8)||o-r/2<0||o+r/2>es||c-n/2<0||c+n/2>ea||!a(o-r/2,c-n/2,o+r/2,c+n/2,-1,-1,d))continue;let y=el(o,c),v=ec(o,c);s(y-u.labelW/2,v-u.labelH/2,y+u.labelW/2,v+u.labelH/2,d)>0||(l=o,h=c,g=m)}if(g<0)return!1}let m=[t[0],t[1]];for(let r=2;r<t.length;r+=2){let n=t[r]-t[r-2],i=t[r+1]-t[r-1],a=Math.abs(n)+Math.abs(i),s=20*(r>2),o=20*(r+2<t.length);a>s+o+1&&(s&&m.push(t[r-2]+n/a*s,t[r-1]+i/a*s),o&&m.push(t[r]-n/a*o,t[r+1]-i/a*o)),m.push(t[r],t[r+1])}u.route=[];for(let t=0;t<m.length;t+=2){let r=0===t?m[0]!==m[2]:m[t]!==m[t-2];u.route.push(el(m[t],m[t+1]),ec(m[t],m[t+1]),r?1-ed:ed)}return u.labelW>0&&(u.labelX=el(l,h),u.labelY=ec(l,h),n[d]=[l,h]),eg[i]=1,!0};if(M([g+w*T[f]/2,y,m,y,m,x-$*I[p]/2],2)||M([g,y+$*I[f]/2,g,x,m-w*T[p]/2,x],2)||ey>2e6/8)continue;let _=[];for(let t of C[f]<C[p]?[C[p],C[f]]:[C[f],C[p]]){let r=Math.max(h[t]-14,Math.min(h[t]/2,6));for(let n of[X[t]+r,X[t+1]-r]){if(Math.abs(n-g)<T[f]/2+4||Math.abs(n-m)<T[p]/2+4)continue;let r=[g+Math.sign(n-g)*T[f]/2,y,n,y,n,x,m+Math.sign(n-m)*T[p]/2,x],i=(l(el(r[0],r[1]),ec(r[0],r[1]),d)+l(el(r[6],r[7]),ec(r[6],r[7]),d))*1e6;for(let t=2;t<r.length;t+=2){let n=el(r[t-2],r[t-1]),a=ec(r[t-2],r[t-1]),o=el(r[t],r[t+1]),l=ec(r[t],r[t+1]);i+=1e6*s(Math.min(n,o),Math.min(a,l),Math.max(n,o),Math.max(a,l),d)+Math.abs(o-n)+Math.abs(l-a)}_.push({pts:r,cost:i,lane:t})}}for(let t of(_.sort((t,r)=>t.cost-r.cost),_))if(M(t.pts,1)){k[t.lane]=1;break}}}return{width:o?ea:es,height:o?es:ea,routed:eg,margins:k,work:ey}},M=new Uint8Array(w),_=new Uint8Array(d),A=k(M,_);for(let t=0;t<3&&A.work<=2e6/8;t++){let r=0===t?A.routed:M.map((t,r)=>t&A.routed[r]);if(r.every((t,r)=>t===M[r])&&A.margins.every((t,r)=>t===_[r]))break;M=r,_=A.margins,A=k(M,_)}return M.some((t,r)=>t&&!A.routed[r])&&(A=k(new Uint8Array(w),new Uint8Array(d))),{width:A.width,height:A.height}})(t,r,n,i,a?12:void 0),drawGroup:function(t,r,n,i,a,s,o){let l=t.x-t.w/2,c=t.y-t.h/2,d="LR"===s||"RL"===s,u=d?l+t.padTop/2:t.x,h=d?t.y:c+t.padTop/2,f=eI(r,u,h,` class="pele-cluster-label"${e8(n,"var(--_m)")}${n.text}`,o);return`<g class="pele-cluster pele-lane${i}" data-id="${a}"><rect x="${eT(l)}" y="${eT(c)}" width="${eT(t.w)}" height="${eT(t.h)}" fill="none" stroke="var(--_b)"/><rect x="${eT(l)}" y="${eT(c)}" width="${eT(d?t.padTop:t.w)}" height="${eT(d?t.h:t.padTop)}" fill="var(--_a)" stroke="var(--_b)"${n.shape}/>`+(d&&f?`<g transform="rotate(-90 ${eT(u)} ${eT(h)})">${f}</g>`:f)+"</g>"},filledBox:function(t,r){let n=t.x-t.w/2,i=t.y-t.h/2;return"LR"===r||"RL"===r?[n,i,n+t.padTop,i+t.h]:[n,i,n+t.w,i+t.padTop]}},fe={type:"swimlane",math:!0,parse:o7.parse,render:(t,r,n)=>o9(t,r,n,h7)},ft=class{type="timeline";title;accTitle;accDescr;direction="LR";sections=[];periods=[];currentSection="";getCommonDb(){return this}setDiagramTitle(t){this.title=t}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
|
|
104
|
+
`)}setDirection(t){this.direction=t}addSection(t){this.currentSection=t,this.sections.push(t)}addTask(t,r,n){this.periods.push({text:t,events:n?[n]:[],section:this.currentSection,sectionIndex:this.sections.length-1})}addEvent(t){let r=this.periods[this.periods.length-1];if(!r)throw new a("An event needs a time period before it.","semantic",{type:"timeline"});r.events.push(t)}},fr=["$end","EOF","INVALID","NEWLINE","timeline","timeline_lr","timeline_td","title","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","section","period","event"],fn=' fill="none" stroke="var(--_b)"';function fi(t,r,n,i,a){return`<rect x="${eT(t)}" y="${eT(r)}" width="${eT(n)}" height="${eT(i)}"${r9(a)}/>`}function fa(t,r,n,i){let a=n.fontSize??16,s=Math.round(.875*a),o=n.measurer??e$(n.fontFamily,n.fontFamilyMono),l=n.padding??8,c=r.timeline?.disableMulticolor!==!0,d=t.periods,u=t.sections.length>0,h=t.sections.map((t,r)=>({section:r,periods:[]})),f={section:-1,periods:[]};d.forEach((t,r)=>(h[t.sectionIndex]??f).periods.push(r)),f.periods.length>0&&h.unshift(f);let p=i&&void 0!==n.maxWidth&&n.maxWidth>0?n.maxWidth-2*l:1/0,g=Math.min(152,Math.max(80,Math.round((p-96)*.38))),m=Math.min(264,Math.max(110,p-96-g)),y=g,v=()=>i?m:y,b=d.map(t=>ck(t.text,o,a,y)),x=d.map(t=>t.events.map(t=>ck(t,o,s,v()))),w=0;for(let t of b)w=Math.max(w,t.width);if(!i)for(let t of x)for(let r of t)w=Math.max(w,r.width);let $=w>y;if(i)for(let t of x)for(let r of t)$||=r.width>m;$&&(y=Math.min(Math.max(Math.ceil(w),g),p===1/0?216:g),b=d.map(t=>cM(t.text,o,a,y)),x=d.map(t=>t.events.map(t=>cM(t,o,s,v()))));let k=Math.round(1.5*a),M=y+24,_=v()+24,A=t=>Math.max(t.height,k)+16,E=t=>Math.max(t.height,Math.round(1.5*s))+16,S=(t,r)=>t.section>=0?t.section:u?void 0:c?r:0,C=(t,r)=>{let n=S(t,r);return void 0===n?"var(--_m)":nu(n)},T=t=>(void 0===t?"":ts(t))||' fill="var(--_bg)"',I=!1;for(let t of x)t.length>0&&(I=!0);let N=0;for(let t of h)N+=Math.max(t.periods.length,1);let O=M+20,D=d.length>0,R=i?M+(I?48+_:32*!!D):N>0?N*O-20+20*!!D:0,L=cM(t.title,o,a,Math.max(R,320),1),z=L.height>0?L.height+16:0,P=Math.max(R,L.width),j=l+(P-R)/2,F=l+z,B=(r,n)=>cM(t.sections[r.section],o,a,n-24,1),W=(t,r,n,i,a,s)=>fi(n,i,a,s,` fill="${nu(t.section)}"`)+eI(r,n+a/2,i+s/2,' font-weight="var(--_hw)"'+T(t.section)),H=(t,r,n,i,a,s)=>fi(i,a,M,s,` fill="${n}"`)+eI(b[t],i+M/2,a+s/2,T(S(r,t))),U=(t,r,n,i,a)=>'<g class="pele-node pele-event">'+fi(n,i,_,a,` fill="${r}" fill-opacity="0.16"`)+eI(t,n+_/2,i+a/2,` font-size="${s}"`)+"</g>",q=(t,r,n)=>`<circle class="pele-dot" cx="${eT(t)}" cy="${eT(r)}" r="4" fill="${n}" stroke="var(--_bg)" stroke-width="2"/>`,V=r=>r.section>=0?`<g class="pele-cluster pele-section" data-id="${eS(t.sections[r.section].trim())}">`:"",Y=t=>`<g class="pele-node pele-period" data-id="${eS(d[t].text.trim())}">`,G="",Z;if(i){let t=j+M+20,r=t+14,n=r+14,i=F;for(let a of h){if(G+=V(a),a.section>=0){let t=B(a,R),r=A(t);G+=W(a,t,j,i,R,r),i+=r+8+4}for(let s of a.periods){let o=C(a,s),l=A(b[s]),c=x[s].length>0?E(x[s][0]):l,d=i+Math.max(l,c)/2,u=`M${eT(j+M)},${eT(d)}H${eT(t)}`,h="",f=d-c/2,p=d;for(let t of x[s]){let i=E(t);p=f+i/2,u+=`M${eT(r)},${eT(p)}H${eT(n)}`,h+=U(t,o,n,f,i),f+=i+8}h&&(u+=`M${eT(t)},${eT(d)}H${eT(r)}V${eT(p)}`),G+=Y(s)+H(s,a,o,j,d-l/2,l)+`<path class="pele-edge" d="${u}"${fn}/>`+q(t,d,o)+h+"</g>",i=Math.max(d+l/2,f-8)+20}0===a.periods.length&&(i+=8),a.section>=0&&(G+="</g>")}if(h.length>0&&(i-=20),D){let r=i+12+8;G=`<path class="pele-axis" d="M${eT(t)},${eT(F)}V${eT(r-8+1)}" fill="none" stroke="var(--_l)"/>`+rV("arrow_point",t,r,0,1,"var(--_l)")+G,i=r}Z=i+l}else{let t=0,r=h.map(r=>{if(r.section<0)return;let n=B(r,Math.max(r.periods.length,1)*O-20);return t=Math.max(t,A(n)),n}),n=0;for(let t of b)n=Math.max(n,A(t));let i=F+(u?t+8:0),a=i+n+20*(n>0),s=a+20,o=D?a+12:F+t,c=0;if(h.forEach((l,d)=>{let u=Math.max(l.periods.length,1),h=j+c*O;G+=V(l);let f=r[d];f&&(G+=W(l,f,h,F,u*O-20,t)),l.periods.forEach((t,r)=>{let c=C(l,t),d=h+r*O,u=d+M/2,f=`M${eT(u)},${eT(i+n)}V${eT(x[t].length>0?s:a)}`,p="",g=s;for(let r of x[t]){let t=E(r);g>s&&(f+=`M${eT(u)},${eT(g-8)}V${eT(g)}`),p+=U(r,c,d,g,t),g+=t+8}o=Math.max(o,g-8),G+=Y(t)+H(t,l,c,d,i,n)+`<path class="pele-edge" d="${f}"${fn}/>`+q(u,a,c)+p+"</g>"}),l.section>=0&&(G+="</g>"),c+=u}),D){let t=j+R;G=`<path class="pele-axis" d="M${eT(j)},${eT(a)}H${eT(t-8+1)}" fill="none" stroke="var(--_l)"/>`+rV("arrow_point",t,a,1,0,"var(--_l)")+G}Z=o+l}let X=Math.ceil(P+2*l),K=Math.ceil(Math.max(Z,2*l)),J=eI(L,X/2,l+L.height/2,' class="pele-title" font-weight="var(--_tw)"')+G;return{svg:np("timeline",X,K,a,n,t,J),width:X,height:K,links:[]}}var fs=/[─━│┃└┗├┣]/,fo=/[└┗├┣]/,fl=/[─━]/,fc=/^[\s│┃]+$/,fd=/^[\s─━│┃└┗├┣]+$/,fu=/^\s*(title[\t ]|accTitle[\t ]*:|accDescr[\t ]*[:{])/,fh=/^\s*%%/;function ff(t,r){let n=0;for(let i=1;i<r;i++)n=t.indexOf(`
|
|
105
|
+
`,n)+1;return n}function fp(t,r,n){let{line:i}=c(t,ff(t,r+1));throw new a(`Line ${i}: ${n}`,"syntax",{type:"treeView",line:i})}var fg={name:"BARE_NAME",pattern:/(?!:::|icon\(|##)[^ \t\n\r"'](?:(?![ \t]+:::[ \t]*[A-Za-z_]|[ \t]+icon\(|[ \t]+##)[^\n\r])*/y,match:function(t,r){let n=t.charCodeAt(r);if(Y(n)||10===n||13===n||34===n||39===n||t.startsWith(":::",r)||t.startsWith("icon(",r)||t.startsWith("##",r))return -1;let i=t.length,a=r+1;for(;a<i;){let r=t.charCodeAt(a);if(10===r||13===r)break;if(Y(r)){let r=a+1;for(;Y(t.charCodeAt(r));)r++;if(function(t,r){if(t.startsWith("##",r)||t.startsWith("icon(",r))return!0;if(!t.startsWith(":::",r))return!1;let n=r+3;for(;Y(t.charCodeAt(n));)n++;let i=t.charCodeAt(n);return i>=65&&i<=90||i>=97&&i<=122||95===i}(t,r))break;a=r}else a++}return a}},fm=[{...iP("treeView-beta"),longer:[fg]},ol(),iC,iI(String.raw`(?!%%)[^\n\r]`),{name:"CLASS_ANNOTATION",pattern:/[ \t]+:::[ \t]*[A-Za-z_][\w-]*/y},{name:"ICON_ANNOTATION",pattern:/[ \t]+icon\([\w-]*(?::[\w-]+)?\)/y},{name:"DESC_ANNOTATION",pattern:/[ \t]+##[^\n\r]*/y},{name:"INDENTATION",pattern:/[ \t]{1,}/y},{name:"QUOTED_NAME",pattern:/"[^"]*"|'[^']*'/y},{name:"WS",pattern:/[ \t]+/y,hidden:!0},{name:"ML_COMMENT",pattern:/\%\%[^\n]*/y,hidden:!0},{name:"NL",pattern:/\r?\n/y,hidden:!0},fg];function fy(t){let r=t.length;for(;r>0&&Y(t.charCodeAt(r-1));)r--;return r===t.length?t:t.slice(0,r)}function fv(t,r){switch(t){case"INDENTATION":return r?.length||0;case"QUOTED_NAME":return r.substring(1,r.length-1);case"BARE_NAME":return fy(r);case"CLASS_ANNOTATION":return r.trim().substring(3).trim();case"ICON_ANNOTATION":{let t=r.trim();return t.substring(5,t.length-1)}case"DESC_ANNOTATION":return r.trim().substring(2).trim();default:return}}var fb=class{count=1;root={id:0,level:-1,name:"/",nodeType:"directory",children:[]};stack=[this.root];addNode(t,r,n,i,a,s){let o=this.stack;for(;t<=o[o.length-1].level;)o.pop();let l={id:this.count++,level:t,name:r,nodeType:n,icon:a,cssClass:i,description:s,children:[]};o[o.length-1].children.push(l),o.push(l)}},fx="mermaid-treeview",fw=new Map([["folder","M3 6.5A1.5 1.5 0 0 1 4.5 5h4.6l2.4 2.5h8A1.5 1.5 0 0 1 21 9v9a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 3 18z"],["file","M6.5 3h7L19 8.5v11a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 5 19.5v-15A1.5 1.5 0 0 1 6.5 3zM13.5 3v5.5H19"]]);function f$(t,r){if(void 0===t||!Object.prototype.hasOwnProperty.call(t,r))return;let n=t[r];return"string"==typeof n?n:void 0}function fk(t,r){return t.includes(":")?t:fw.has(t)||!r?`${fx}:${t}`:`${r}:${t}`}function fM(t,r){if("none"!==t.icon){if(t.icon)return fk(t.icon,r.defaultIconPack);if(r.showIcons){if("file"===t.nodeType){let n=function(t,r){let n=f$(r?.filenameIcons,t);if(n)return n;let i=t.lastIndexOf(".");if(i>0){let n=t.substring(i).toLowerCase();return f$(r?.extensionIcons,n)??f$(r?.extensionIcons,n.slice(1))}}(t.name,r);if("none"===n)return;if(n)return fk(n,r.defaultIconPack)}return`${fx}:${"directory"===t.nodeType?"folder":"file"}`}}}function f_(t,r,n,i,a){let s=t.treeView?.[r];return"number"==typeof s&&s>=i&&s<=a?s:n}var fA=[iS,iC,iI(String.raw`\w`),{name:"TREEMAP_KEYWORD",pattern:/treemap-beta|treemap/y},{name:"CLASS_DEF",pattern:/classDef\s+([a-zA-Z_][a-zA-Z0-9_]+)(?:\s+([^;\r\n]*))?(?:;)?/y},{name:"STYLE_SEPARATOR",pattern:/:::/y},{name:"SEPARATOR",pattern:/:/y},{name:"COMMA",pattern:/,/y},{name:"INDENTATION",pattern:/[ \t]{1,}/y},{name:"WS",pattern:/[ \t]+/y,hidden:!0},{name:"ML_COMMENT",pattern:/\%\%[^\n]*/y,hidden:!0},{name:"NL",pattern:/\r?\n/y,hidden:!0},{name:"ID2",pattern:/[a-zA-Z_][a-zA-Z0-9_]*/y},{name:"NUMBER2",pattern:/[0-9_\.\,]+/y},{name:"STRING2",pattern:/"[^"]*"|'[^']*'/y}],fE=/classDef\s+([A-Z_a-z]\w+)(?:\s+([^\n\r;]*))?;?/,fS=/^(?:.?[<>=^])?([-+( ])?(\$)?0?\d*(,)?(?:\.(\d+))?(~)?([a-zA-Z%])?$/;function fC(t){let r="";for(let n=t.length;n>0;n-=3)r=t.slice(Math.max(0,n-3),n)+(r?","+r:"");return r}function fT(t,r,n){let i=void 0===t.children&&Number.isFinite(t.value)&&t.value>0?t.value:0;return{node:t,parent:r,series:n,value:i,children:[],headed:!1,header:0,x:0,y:0,w:0,h:0}}var fI=(t,r,n)=>t>=r?Math.min(t,n):r,fN=t=>eE(y(t).trim()).trim();function fO(t,r){let n=Math.min(r.w,r.h)/4;return n<4?r9(t).replace("rx:var(--_r)",`rx:min(var(--_r),${eT(n)}px)`):r9(t)}function fD(t,r,n,i,a){let s=t.treemap?.[r];return"number"==typeof s&&s>=i?Math.min(s,a):n}var fR="EOF USECASE ACTOR SYSTEM_BOUNDARY END DIRECTION TD TB BT LR RL NOTE FOR JSON CLASS_DEF CLASS STYLE INCLUDE EXTEND TRUE FALSE IDENTIFIER NUMBER AT COMMA COLON HASH_COLOR CSS_IDENTIFIER CSS_ESCAPED_COMMA DASH DOT PERCENT CSS_PUNCTUATION LABEL_PUNCTUATION LABEL_SYMBOL PLAIN_STRING MARKDOWN_STRING UNCLOSED_MARKDOWN_STRING COMMENT NEWLINE ACC_DESCR_BLOCK ACC_TITLE_LINE ACC_DESCR_LINE JSON_DECLARATION_START JSON_OBJECT_LITERAL UNCLOSED_JSON_OBJECT_LITERAL GENERALIZATION DEPENDENCY_ARROW STEREOTYPE_START STEREOTYPE_END STEREOTYPE_TEXT UNCLOSED_STEREOTYPE_TEXT CLASS_SEPARATOR FORWARD_SOLID BACKWARD_SOLID FORWARD_CIRCLE BACKWARD_CIRCLE FORWARD_CROSS BACKWARD_CROSS MARKERLESS_SOLID METADATA_START LBRACE RBRACE LBRACKET RBRACKET LPAREN RPAREN".split(" "),fL=new Uint8Array(128);for(let t=48;t<=57;t++)fL[t]=1;for(let t=65;t<=90;t++)fL[t]=fL[t+32]=1;for(let t of(fL[95]=1,"!#$&*+/=?^|~"))fL[t.charCodeAt(0)]=2;var fz=[0,12,5,14,3,9,2,2,2,2,2,4,3,4,8,5,5,7,6,4,5];function fP(t){return t<128&&(1&fL[t])!=0}function fj(t,r,n){for(let i=0;i<n.length;i++)if((32|t.charCodeAt(r+i))!==n.charCodeAt(i))return!1;return!0}function fF(t,r){[t,r]=l(t,r);let n=1,i=0;for(let a=0;a<r;a++){let s=t.charCodeAt(a);10!==s&&13!==s||(13===s&&a+1<r&&10===t.charCodeAt(a+1)&&a++,n++,i=a+1)}return[n,r-i+1]}function fB(t,r,n){let[i,a]=fF(t,r);return`line ${i}, column ${a} [${l(t,r)[1]},${l(t,n)[1]})`}function fW(t,r,n){for(let i=r+1;i<t.length;i++){let r=t.charCodeAt(i);if(r===n)return i+1;if(10===r||13===r)break}return -1}function fH(t,r,n){let[i,s]=fF(t,r),[o,c]=[l(t,r)[1],l(t,r+n)[1]];return new a(`Error lexing usecase diagram: unexpected character: ->${t.charAt(r)}<- at offset: ${o}, skipped ${c-o} characters. at line ${i}, column ${s} [${o},${c})`,"syntax",{type:"usecase",line:i,column:s})}function fU(t,r){if(0===r.length)return;let n=new Set(t);for(let i of r)n.has(i)||(n.add(i),t.push(i))}var fq=class extends Error{constructor(t){super("Invalid JSON token"),this.offset=t}offset};function fV(t){let r=new Map,n=[],i=[],a=t.length,s=0,o="",l=0,c=()=>{for(;s<a;){let r=t.charCodeAt(s);if(32!==r&&9!==r&&10!==r&&13!==r)return;s++}},d=r=>{s++;let n="";for(;s<a;){let i=s,a=t[s++];if('"'===a)return n;if(32>a.charCodeAt(0))throw new fq(i);if("\\"!==a){r&&(n+=a);continue}let o=s,l=t[s++],c;if('"'===l||"\\"===l||"/"===l)c=l;else if("b"===l)c="\b";else if("f"===l)c="\f";else if("n"===l)c=`
|
|
106
|
+
`;else if("r"===l)c="\r";else if("t"===l)c=" ";else if("u"===l){let r=t.slice(s,s+4);if(!/^[\dA-Fa-f]{4}$/.test(r))throw new fq(s);c=String.fromCharCode(parseInt(r,16)),s+=4}else throw new fq(o);r&&(n+=c)}throw new fq(s)},u=r=>{for(let n=0;n<r.length;n++)if(t[s+n]!==r[n])throw new fq(s+n);s+=r.length},h=()=>{if(45===t.charCodeAt(s)&&s++,48===t.charCodeAt(s))s++;else if(Z(t.charCodeAt(s)))for(;Z(t.charCodeAt(s));)s++;else throw new fq(s);if(46===t.charCodeAt(s)){if(s++,!Z(t.charCodeAt(s)))throw new fq(s);for(;Z(t.charCodeAt(s));)s++}if((32|t.charCodeAt(s))==101){if(s++,(43===t.charCodeAt(s)||45===t.charCodeAt(s))&&s++,!Z(t.charCodeAt(s)))throw new fq(s);for(;Z(t.charCodeAt(s));)s++}};for(c();;)if(0===l){c();let a=t.charCodeAt(s);if(l=2,123===a){s++;let a=[];r.set(o,a),n.push(o),c(),125===t.charCodeAt(s)?s++:(i.push({object:!0,pointer:o,keys:a,ranges:new Map,key:"",from:0,index:0}),l=1)}else if(91===a)s++,c(),93===t.charCodeAt(s)?s++:(i.push({object:!1,pointer:o,keys:[],ranges:new Map,key:"",from:0,index:0}),o+="/0",l=0);else if(34===a)d(!1);else if(116===a)u("true");else if(102===a)u("false");else if(110===a)u("null");else if(45===a||Z(a))h();else throw new fq(s)}else if(1===l){let a=i[i.length-1];if(34!==t.charCodeAt(s))throw new fq(s);let u=d(!0),h=a.ranges.get(u);if(void 0===h)a.keys.push(u);else for(let t=h[0];t<h[1];t++)r.delete(n[t]);if(a.key=u,a.from=n.length,c(),58!==t.charCodeAt(s))throw new fq(s);s++,o=`${a.pointer}/${u.replaceAll("~","~0").replaceAll("/","~1")}`,l=0}else{let r=i[i.length-1];if(void 0===r)break;r.object?r.ranges.set(r.key,[r.from,n.length]):r.index++,c();let a=t.charCodeAt(s);if(a===(r.object?125:93))s++,i.pop();else{if(44!==a)throw new fq(s);s++,c(),o=`${r.pointer}/${r.index}`,l=+!!r.object}}if(c(),s!==a)throw new fq(s);return r}function fY(t,r,n,i){let a=Math.min(Math.max(r,0),t.length);for(let r=0;r<a;r++){let a=t.charCodeAt(r);13===a?(n++,i=1):10===a?(0===r||13!==t.charCodeAt(r-1))&&(n++,i=1):i++}return[n,i]}function fG(t,r,n){return new a(`${t} (line ${r}, column ${n})`,"syntax",{type:"usecase",line:r,column:n})}var fZ="DEPENDENCY_ARROW|GENERALIZATION|FORWARD_SOLID|BACKWARD_SOLID|MARKERLESS_SOLID|FORWARD_CIRCLE|BACKWARD_CIRCLE|FORWARD_CROSS|BACKWARD_CROSS",fX="IDENTIFIER|PLAIN_STRING|MARKDOWN_STRING",fK="ACC_TITLE_LINE|ACC_DESCR_LINE|ACC_DESCR_BLOCK|DIRECTION|ACTOR|SYSTEM_BOUNDARY|NOTE|JSON_DECLARATION_START|CLASS_DEF|CLASS|STYLE",fJ="WORD|PLAIN_STRING|NUMBER|HASH_COLOR|CSS_IDENTIFIER|CSS_ESCAPED_COMMA|DASH|DOT|PERCENT|CSS_PUNCTUATION|COLON|LPAREN|RPAREN|LBRACKET|RBRACKET|LBRACE|RBRACE|AT|MARKERLESS_SOLID",fQ=new Uint8Array(67);function f0(t,r){for(let n of t.split("|"))if("WORD"===n)for(let t=1;t<=21;t++)fQ[t]|=r;else fQ[fR.indexOf(n)]|=r}f0(`NEWLINE|COMMENT|${fK}|${fX}`,1),f0(`IDENTIFIER|${fZ}`,2),f0(fJ,4),f0(`STEREOTYPE_START|CLASS_SEPARATOR|IDENTIFIER|${fZ}|NEWLINE|EOF`,8),f0(`NEWLINE|COMMENT|ACTOR|${fX}`,16),f0("FORWARD_SOLID|MARKERLESS_SOLID|FORWARD_CIRCLE|FORWARD_CROSS",32),f0("NEWLINE|IDENTIFIER|PLAIN_STRING|RBRACE",64);var f1,f2,f4=new Set(["allowmixing","newpage","package","rectangle","skinparam"]),f3="",f5=[],f6=[],f8=[],f9=0,f7=0,pe=[],pt=0,pr=0;function pn(t){return f3.slice(f6[t],f8[t])}function pi(t){return[f6[t],f8[t]]}function pa(t){let[r,n]=fF(f3,f6[f9]);throw new a(`Error parsing usecase diagram: ${t} at ${fB(f3,f6[f9],f8[f9])}`,"syntax",{type:"usecase",line:r,column:n})}function ps(t){pa(`Expecting token of type --> ${t} <-- but found --> '${pn(f9)}' <--`)}function po(t){return f5[f9]!==t&&ps(fR[t]),f9++}function pl(t){let r=t.split("|").map((t,r)=>` ${r+1}. [${t}]`);pa(`Expecting: one of these possible Token sequences:
|
|
107
|
+
${r.join(`
|
|
108
|
+
`)}
|
|
109
|
+
but found: '${pn(f9)}'`)}function pc(){let t=fX.split("|"),r=t.flatMap(t=>["NEWLINE","IDENTIFIER","PLAIN_STRING","RBRACE"].map(r=>`${t}, METADATA_START, ${r}`)),n=`STEREOTYPE_START|CLASS_SEPARATOR|IDENTIFIER|${fZ}|NEWLINE|EOF`.split("|");return[fK,...r,...t.flatMap((t,r)=>(0===r?["LPAREN","LBRACKET",...n]:n).map(r=>`${t}, ${r}`)),...r].join("|")}function pd(t){return t>=1&&t<=21}function pu(t){return t>=1&&t<=34}function ph(){f7=f8[f9-1],39===f5[f9]?f9++:0!==f5[f9]&&pl("NEWLINE|EOF")}function pf(t){let r=36===f5[t]?2:+(35===f5[t]);return[f6[t]+r,f8[t]-r]}function pp(t){let r=pf(t);return{text:f3.slice(r[0],r[1]),type:36===f5[t]?"markdown":"text",span:r}}function pg(t){return t.replace(/\W/g,"_")}function pm(){let t=f5[f9];if(35===t||36===t)return pp(f9++);pu(t)||pl("PLAIN_STRING|MARKDOWN_STRING|LABEL_TEXT");let r=f9;for(;pu(f5[f9]);)f9++;let n=[f6[r],f8[f9-1]];return{text:f3.slice(n[0],n[1]),type:"text",span:n}}function py(t){return 21===t||35===t}function pv(){let t=f9;py(f5[f9])||pl("IDENTIFIER|PLAIN_STRING"),f9++,po(25);let r=f9,n=f5[f9];py(n)||19===n||20===n||pl("IDENTIFIER|PLAIN_STRING|TRUE|FALSE"),f9++;let i=pf(t),a=pf(r);return{key:f3.slice(i[0],i[1]),value:19===n||20!==n&&f3.slice(a[0],a[1]),span:[f6[t],f8[r]],keySpan:i,valueSpan:a}}function pb(){po(60);let t=[];for(;39===f5[f9];)f9++;if(py(f5[f9])){let r,n,i;for(t.push(pv());r=f5[f9],n=f5[f9+1],i=f5[f9+2],24===r?py(n)||39===n&&(39===i||py(i)):39===r&&(24===n||py(n)||39===n&&(39===i||24===i||py(i)));){if(24===f5[f9])f9++;else{for(;39===f5[f9];)f9++;24===f5[f9]&&f9++}for(;39===f5[f9];)f9++;t.push(pv())}for(24===f5[f9]&&f9++;39===f5[f9];)f9++}return po(62),t}function px(t){return t.map(({key:t,span:r,keySpan:n,valueSpan:i})=>({key:t,span:r,keySpan:n,valueSpan:i}))}function pw(t,r){do{f9++;let n=po(21);t.push(pn(n)),r.push(pi(n))}while(24===f5[f9])}function p$(t){let r=f9,n=f5[f9],i={id:"",label:void 0,span:pf(r),generated:21!==n,classes:[],classSpans:[],explicit:!1,nodeSpan:[0,0]};if(21===n){f9++,i.id=pn(r);let n=f5[f9];65===n||t&&63===n?(f9++,i.label=pm(),po(65===n?66:64),i.shape=65===n?"ellipse":"rect"):i.label=pp(r)}else 35===n||36===n?(f9++,i.label=pp(r),i.id=pg(i.label.text)):pl(fX);return i}function pk(t){let r=f9,n=p$(!t);if(t&&(n.shape=void 0),60===f5[f9]&&(n.metadata=pb()),48===f5[f9]){f9++;let t=po(50);po(49),n.stereotype=pn(t).trim(),n.stereotypeSpan=pi(t)}return 52===f5[f9]&&pw(n.classes,n.classSpans),n.explicit=!!(n.shape||n.metadata||n.stereotype),n.nodeSpan=[f6[r],f8[f9-1]],n}function pM(t,r){return{id:t.id,kind:r,label:t.label,span:t.span,generated:t.generated,parent:f2,shape:t.shape,metadata:t.metadata,stereotype:t.stereotype,classes:t.classes}}function p_(t,r){return{id:t.id,label:t.label,span:t.span,generated:t.generated,declares:r,classed:t.classes.length>0}}function pA(t,r){let n={id:t.id,span:t.nodeSpan,idSpan:t.span,labelSpan:t.label.span};return r&&(n.defines=!0),t.stereotypeSpan&&(n.stereotypeSpan=t.stereotypeSpan),t.metadata&&(n.metadata=px(t.metadata)),t.classSpans.length>0&&(n.classSpans=t.classSpans),n}function pE(t){if(f5[f9]<1||f5[f9]>36)return!1;for(let r=f9+1;;r++){let n=f5[r];if(59===n||(fQ[n]&t)!=0)return!0;if(n<1||n>36)return!1}}function pS(t){return Math.max(1,f8[t]-f6[t]-(59!==f5[t])-1)}function pC(){let t=f9,r={type:"association",arrowType:0,minlen:1,target:void 0,span:[0,0]};21===f5[f9]&&23===f5[f9+1]&&(r.explicitId=pn(f9),r.explicitIdSpan=pi(f9),f9+=2);let n=f9,i=f5[f9++];if(47===i)po(25),17!==f5[f9]&&18!==f5[f9]&&pl("INCLUDE|EXTEND"),r.type=17===f5[f9]?"include":"extend",r.label={text:r.type,type:"text",span:pi(f9)},f9++;else if(46===i)r.type="generalization";else if(53===i)r.minlen=pS(n);else if(54===i)r.arrowType=1,f8[n]-f6[n]==3&&pE(0)?(r.label=pm(),r.minlen=pS(po(59))):r.minlen=pS(n);else if(59===i)if(r.arrowType=2,f8[n]-f6[n]==2&&pE(32)){r.label=pm();let t=f5[f9];53===t?r.arrowType=0:55===t?r.arrowType=3:57===t?r.arrowType=4:59!==t&&pl("FORWARD_SOLID|MARKERLESS_SOLID|FORWARD_CIRCLE|FORWARD_CROSS"),(0===r.arrowType||2===r.arrowType)&&(r.minlen=pS(f9)),f9++}else r.minlen=pS(n);else 55===i?r.arrowType=3:57===i?r.arrowType=4:56===i||58===i?(r.arrowType=56===i?5:6,pE(0)&&(r.label=pm(),po(59))):(f9--,pl(fZ));return r.target=pk(!1),r.span=[f6[t],f8[f9-1]],r}function pT(t){return{kind:t,span:[0,0]}}function pI(t,r,n,i){let a=n.target;a.explicit&&f1.elements.push(pM(a,"usecase")),f1.relationships.push({source:p_(t,r),target:p_(a,a.explicit),span:n.span,id:n.explicitId,idSpan:n.explicitIdSpan,type:n.type,arrowType:n.arrowType,label:n.label,minlen:n.minlen}),i.push(pA(a,a.explicit));let s=pT("edge");return s.nodes=i,s.edges=[{id:n.explicitId??`edge-${pt++}`,span:s.span}],n.explicitIdSpan&&(s.edges[0].idSpan=n.explicitIdSpan),n.label&&(s.edges[0].labelSpan=n.label.span),s}function pN(t){let r=pT("node");return r.nodes=t,r}function pO(t){f9++;let r=[pk(!0)],n;if(24===f5[f9])do f9++,r.push(pk(!0));while(24===f5[f9]);else t&&(2&fQ[f5[f9]])!=0&&(n=pC());for(let t of(ph(),r))f1.elements.push(pM(t,"actor"));let i=r.map(t=>pA(t,!0));return n?pI(r[0],!0,n,i):pN(i)}function pD(t){let r=pk(!1),n=t&&(2&fQ[f5[f9]])!=0?pC():void 0;ph(),n||(r.explicit=!0,r.shape??="ellipse"),r.explicit&&f1.elements.push(pM(r,"usecase"));let i=[pA(r,r.explicit)];return n?pI(r,r.explicit,n,i):pN(i)}function pR(){let t=f9,r=f5[f9];for(pd(r)||27===r?f9++:59===r?(pd(f5[++f9])||ps("WORD"),f9++):pl("WORD|CSS_IDENTIFIER|MARKERLESS_SOLID"),po(25),(4&fQ[f5[f9]])==0&&pa(`Expecting: expecting at least one iteration which starts with one of these possible Token sequences::
|
|
110
|
+
<[${fJ.replaceAll("|","] ,[")}]>
|
|
111
|
+
but found: '${pn(f9)}'`);(4&fQ[f5[f9]])!=0;)f9++;return f3.slice(f6[t],f8[f9-1]).replaceAll("\\,",",")}function pL(){let t=[pR()];for(;24===f5[f9];)f9++,t.push(pR());return t}function pz(){let t=[po(21)];for(;24===f5[f9];)f9++,t.push(po(21));return t}function pP(t){let r=pf(t);return{id:pn(t),span:r,idSpan:r}}var pj={normal:"usecaseActor",hollow:"usecaseActorHollow",awesome:"usecaseActorAwesome",icon:"usecaseActorIcon"},pF=[["none","arrow_point"],["arrow_point","none"],["none","none"],["none","arrow_circle"],["none","arrow_cross"],["arrow_circle","none"],["arrow_cross","none"]];function pB(t){return"string"==typeof t?t:null===t?"null":String(t)}function pW(...t){return t.filter(Boolean).join(" ")}var pH=' fill="var(--_s)" stroke="var(--_b)"';function pU(t,r,n){let i=t.usecase?.[r];return"number"==typeof i&&i>0?Math.min(i,2e3):n}function pq(t,r,n,i,a,s=0){return n7(t&&!r?t.replace(/[&<>\\]/g,t=>`&#${t.charCodeAt(0)};`):t,r,n,i,a,s)}function pV(t,r,n,i){let a=1===n||2===n?1:-1,s=1===n||3===n,o=(s?t.w:t.h)/2,l=0;return 0===t.kind?s?(o=23,l=(60-t.h)/2):o+=2:1===t.kind&&(o*=Math.sqrt(Math.max(1-(i/((s?t.h:t.w)/2))**2,0))),s?[r.x+a*o,r.y+l+i]:[r.x+i,r.y+a*o]}function pY(t,r){let n=1===r||3===r;if(0===t.kind)return n?30:24;let i=n?t.h:t.w;return 1===t.kind?.6*i:i-16}function pG(t){return"extension"===t?12:rq(t)}function pZ(t,r,n,i,a,s,o){let l,c;return"extension"===t?(l=r-12*i,c=n-12*a,`<path class="pele-marker" d="M${eT(r)},${eT(n)}L${eT(l-6*a)},${eT(c+6*i)}L${eT(l+6*a)},${eT(c-6*i)}Z" fill="var(--_bg)" stroke="${s}" stroke-linejoin="round"/>`):rV(t,r,n,i,a,s,o)}function pX(t,r,n,i){let a=function(t){let r=[],n=[],i=r=>{let n=new Map;for(let i of["default",...r]){let r=t.classDefs.get(i);if(r)for(let t of r.styles){let r=t.trim(),i=r.indexOf(":"),a=(-1===i?r:r.slice(0,i)).trim();a&&n.set(a,r)}}return[...n.values()]};for(let n of t.actors.values())r.push({id:n.id,label:n.label,labelType:n.labelType,shape:pj[n.type],isGroup:!1,padding:10,cssClasses:pW("default","usecase-actor",`usecase-actor-${n.type}`,n.business&&"usecase-business",...n.classes),cssStyles:[...n.styles],cssCompiledStyles:i(n.classes),actorType:n.type,business:n.business,icon:n.icon||void 0,stereotype:n.stereotype||void 0,parentId:n.parentId||void 0});for(let n of t.useCases.values()){let t="ellipse"===n.shape;r.push({id:n.id,label:n.label,labelType:n.labelType,shape:t?n.business?"usecaseBusiness":"usecaseEllipse":"rect",isGroup:!1,padding:t?20:10,cssClasses:pW("default","usecase-element",`usecase-${n.shape}`,n.business&&"usecase-business",...n.classes),cssStyles:[...n.styles],cssCompiledStyles:i(n.classes),business:n.business,stereotype:n.stereotype||void 0,parentId:n.parentId||void 0})}for(let n of t.notes.values())r.push({id:n.id,label:n.label,labelType:n.labelType,shape:"note",isGroup:!1,padding:10,cssClasses:"default usecase-note",cssStyles:[],cssCompiledStyles:i([]),noteTarget:n.target});for(let n of t.jsonNodes.values())r.push({id:n.id,label:n.id,labelType:"text",shape:"usecaseJsonTable",isGroup:!1,padding:10,cssClasses:pW("default","usecase-json-table",...n.classes),cssStyles:[...n.styles],cssCompiledStyles:i(n.classes),jsonRows:function(t){let r=[],n=[[t.value,"",""]],i=[];for(;n.length>0;){let[a,s,o]=n.pop();if(i.length=0,Array.isArray(a))0===a.length?r.push({key:s,accessibleKey:s,value:"[]"}):a.every(t=>null===t||"object"!=typeof t)?a.forEach((t,n)=>r.push({key:0===n?s:"",accessibleKey:s,value:pB(t)})):a.forEach((t,r)=>i.push([t,`${s}[${r}]`,`${o}/${r}`]));else if(null!==a&&"object"==typeof a){let n=t.propertyOrder.get(o)??Object.keys(a);for(let t of(0===n.length&&r.push({key:s,accessibleKey:s,value:"{}"}),n))i.push([Object.prototype.hasOwnProperty.call(a,t)?a[t]:void 0,s?`${s}.${t}`:t,`${o}/${t.replaceAll("~","~0").replaceAll("/","~1")}`])}else r.push({key:s,accessibleKey:s,value:pB(a)});for(let t=i.length-1;t>=0;t--)n.push(i[t])}return r}(n)});for(let n of t.systemBoundaries.values())r.push({id:n.id,label:n.label,labelType:n.labelType,shape:"usecaseSystemBoundary",isGroup:!0,padding:20,cssClasses:pW("default","system-boundary",`system-boundary-${n.type}`,...n.classes),cssStyles:[...n.styles],cssCompiledStyles:i(n.classes),boundaryType:n.type});for(let r of t.relationships){let t="include"===r.type||"extend"===r.type,[a,s]="generalization"===r.type?["none","extension"]:"association"!==r.type?pF[0]:pF[r.arrowType]??pF[2],o=r.animate||void 0!==r.animation,l={id:r.id,start:r.source,end:r.target,relationshipType:r.type,pattern:t?"dotted":"solid",arrowTypeStart:a,arrowTypeEnd:s,classes:pW("default","relationship",`relationship-${r.type}`,...r.classes,o&&`edge-animation-${r.animation??"fast"}`),style:[...r.styles],cssCompiledStyles:i(r.classes),animate:r.animate,animation:r.animation,minlen:r.minlen,explicitId:r.explicitId,internal:!1};t?(l.label=r.type,l.labelType="text"):"association"===r.type&&(r.label&&(l.label=r.label),r.labelType&&(l.labelType=r.labelType)),n.push(l)}for(let r of t.notes.values())n.push({id:`${r.id}-edge`,start:r.id,end:r.target,relationshipType:"note",pattern:"dotted",arrowTypeStart:"none",arrowTypeEnd:"none",classes:"default relationship relationship-note",style:[],cssCompiledStyles:i([]),animate:!1,minlen:1,explicitId:!1,internal:!0});return{nodes:r,edges:n}}(t),s=n.fontSize??16,o=Math.round(.875*s),l=Math.round(.8125*s),c=n.measurer??e$(n.fontFamily,n.fontFamilyMono),d=n.padding??8,u=n.icons,h=i?"TB":rC(t.direction),f="LR"===h||"RL"===h,p=new Map,g=[],m=[];for(let t of(a.nodes.forEach((t,r)=>p.set(t.id,r)),a.nodes)){let r=no(t.cssStyles.length>0?t.cssCompiledStyles.concat(t.cssStyles):t.cssCompiledStyles),n=!!r.bold|2*!!r.italic,i=r.fontSize??s,a="markdown"===t.labelType,d=pq(t.stereotype&&`\xab${t.stereotype}\xbb`,!1,c,l,200,n),u={node:t,kind:2,style:r,label:d,stereotype:d,w:0,h:0,rows:[],keyW:0,headH:0,loops:0},h;if(t.isGroup){u.kind=4,u.label=pq(t.label,a,c,i,4e3,n);let r=u.label.height;(h=rR(0,0)).isGroup=!0,h.padX=20,h.padBottom=20,h.padTop="package"===t.boundaryType?r+12+16:r>0?r+16:20,h.minW=u.label.width+40}else{if(t.jsonRows){u.kind=3,u.label=pq(t.label,!1,c,i,4e3,1|n);let r=0;for(let i of t.jsonRows){let t=pq(i.key,!1,c,o,4e3,n),a=pq(i.value,!1,c,o,260,n);u.rows.push([t,a]),u.keyW=Math.max(u.keyW,t.width),r=Math.max(r,a.width),u.h+=Math.max(t.height,a.height,Math.round(1.5*o))+8}u.keyW>0&&(u.keyW+=20),u.headH=Math.max(u.label.height,Math.round(1.5*i))+8,u.w=Math.max(u.label.width+20,u.rows.length>0?u.keyW+r+20:0,72),u.h+=u.headH}else if(t.actorType)u.kind=0,u.label=pq(t.label,a,c,i,140,n),u.w=Math.max(40,u.label.width,d.width),u.h=66+d.height+u.label.height;else{u.label=pq(t.label,a,c,"note"===t.shape?o:i,180,n);let r=Math.max(u.label.width,d.width),s=u.label.height+d.height;"usecaseEllipse"===t.shape||"usecaseBusiness"===t.shape?(u.kind=1,u.w=Math.max(r+2*t.padding+(t.business?16:4),88),u.h=Math.max(s+28,48)):"note"===t.shape?(u.w=r+2*t.padding+6,u.h=s+18):(u.w=Math.max(r+2*t.padding+12,80),u.h=Math.max(s+24,44))}h=rR(u.w,u.h)}h.seq=g.length,g.push(u),m.push(h)}a.nodes.forEach((t,r)=>{m[r].parent=void 0!==t.parentId?p.get(t.parentId)??-1:-1});let y=[],v=[],b=[];for(let t of a.edges){let r=p.get(t.start),n=p.get(t.end);if(void 0===r||void 0===n)continue;let i=pq("include"===t.relationshipType||"extend"===t.relationshipType?`\xab${t.label}\xbb`:t.label,"markdown"===t.labelType,c,o,200);r===n&&(g[r].loops++,f?m[r].h+=2*(26+(i.height>0?i.height+8:0)):m[r].w+=2*(26+(i.width>0?i.width+12:0))),b.push(t),v.push(i),y.push({src:r,dst:n,minlen:t.minlen,labelW:i.width>0?i.width+12:0,labelH:i.height>0?i.height+4:0,route:[],labelX:0,labelY:0})}let x=rP(m,y,h,{nodeSep:pU(r,"nodeSpacing",32),edgeSep:16,rankSep:pU(r,"rankSpacing",72),portSep:20}),w=ad(t.title,c,s,4e3),$=w.height>0?w.height+12:0,k=Math.max(x.width,w.width);rD(m,y,d+(k-x.width)/2,d+$);let M=Math.ceil(k+2*d),_=Math.ceil(x.height+$+2*d),A=new Map;for(let t of y)rj(A,t.route);!function(t,r,n){let i=new Map,a=(t,n,a,s)=>{let o=r[t];if(o.isGroup)return;let l=n[a]-o.x,c=n[a+1]-o.y,d;if(.5>Math.abs(Math.abs(c)-o.h/2))d=c<0?0:2;else{if(!(.5>Math.abs(Math.abs(l)-o.w/2)))return;d=l<0?3:1}let u=4*t+d,h={route:n,at:a,toward:n[s+(1&d?1:0)]},f=i.get(u);f?f.push(h):i.set(u,[h])};for(let r of t){let t=r.route.length-3;r.src===r.dst||t<3||(a(r.src,r.route,0,3),a(r.dst,r.route,t,t-3))}for(let[t,a]of i){let i=t>>2,s=3&t,o=n[i],l=a.length>1?Math.min(14,pY(o,s)/(a.length-1)):0;a.sort((t,r)=>t.toward-r.toward);for(let t=0;t<a.length;t++){let[n,c]=pV(o,r[i],s,(t-(a.length-1)/2)*l);a[t].route[a[t].at]=n,a[t].route[a[t].at+1]=c}}}(y,m,g);let E="",S=[],C="";for(let t=0;t<g.length;t++){let r,n,i=g[t],a=m[t],s=i.node,c=nc(s.cssClasses.replace(/^default\s?/,"")),d=eS(s.id),h=i.style.text,f=i.style.shape,p=e8(i.style),y=p||' fill="var(--_m)"',v=i.w,b=i.h;if(4===i.kind){let t=a.x-a.w/2,r=a.y-a.h/2;e6(f)&&S.push({box:[t,r,t+a.w,r+a.h],shape:f});let n=` fill="var(--_a)"${r8(f)?"":' fill-opacity="0.5"'} stroke="var(--_b)"${f}`,o=` class="pele-cluster-label"${y}${h}`,l;if("package"===s.boundaryType){let s=Math.min(i.label.width+12+8,a.w),c=i.label.height+12;l=`<rect class="pele-boundary-tab" x="${eT(t)}" y="${eT(r)}" width="${eT(s)}" height="${eT(c)}"${n}/><rect x="${eT(t)}" y="${eT(r+c)}" width="${eT(a.w)}" height="${eT(a.h-c)}"${n}/>`+eI(i.label,t+s/2,r+c/2,o,u)}else l=`<rect x="${eT(t)}" y="${eT(r)}" width="${eT(a.w)}" height="${eT(a.h)}"${r9(n)}/>`+eI(i.label,function(t,r,n){let i=n.get(Math.round(t.y-t.h/2));if(0===r||void 0===i)return t.x;let a=t.x-t.w/2+6,s=t.x+t.w/2-6,o=i.filter(t=>t>a&&t<s).sort((t,r)=>t-r);o.push(s);let l=r/2+6,c=t.x,d=1/0,u=0,h=a;for(let r of o){if(r-h>=2*l){let n=Math.min(Math.max(t.x,h+l),r-l);Math.abs(n-t.x)<d&&(d=Math.abs(n-t.x),c=n)}else d===1/0&&r-h>u&&(u=r-h,c=(h+r)/2);h=r}return c}(a,i.label.width,A),r+8+i.label.height/2,o,u);E+=`<g class="pele-cluster pele-boundary${c}" data-id="${d}">${l}</g>`;continue}if(0===i.kind){n="pele-actor";let t=-b/2,a=t+60+6+i.stereotype.height/2;r=`<g class="pele-actor-figure" transform="translate(0,${eT(t+30)})">${function(t,r){let n=t.node,i=t.style.shape,a=` fill="none" stroke="var(--_b)"${t.style.line}`,s=-21,o=9,l;return"hollow"===n.actorType?(o=8,l=`<circle cy="-21" r="8" fill="var(--_bg)" stroke="var(--_b)"${i}/><path d="M-20,-9H20V0H5.5L20,15.5L12,25.5L0,12L-12,25.5L-20,15.5L-5.5,0H-20Z" fill="var(--_bg)" stroke="var(--_b)" stroke-linejoin="round"${i}/>`):"awesome"===n.actorType?l=`<path d="M0,-30A11,11 0 1 1 0,-8A11,11 0 1 1 0,-30ZM-20,25C-20,9 -12,-3 0,-3C12,-3 20,9 20,25C20,28 18,30 15,30H-15C-18,30 -20,28 -20,25Z" fill="var(--_b)"${i}/>`:"icon"===n.actorType?(s=-14,o=12,l=`<rect x="-22" y="-26" width="44" height="44"${r9(pH+i)}/><svg class="pele-icon" data-icon="${eS(n.icon??"")}" x="-14" y="-18" width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${r?.(n.icon??"")??""}</svg>`):l=`<circle cy="-21" r="9"${pH}${i}/><path d="M0,-12V10M-14,-3H14M0,10L-12,30M0,10L12,30"${a}/>`,n.business&&(l+=`<path class="pele-business" d="M${eT(.12*o)},${eT(s+.99*o)}L${eT(.92*o)},${eT(s-.39*o)}"${a}/>`),l}(i,u)}</g>`+eI(i.stereotype,0,a,` class="pele-stereotype" font-size="${l}" fill="var(--_m)"`,u)+eI(i.label,0,b/2-i.label.height/2,` class="pele-label"${h}`,u)}else if(3===i.kind){n="pele-json";let t=-v/2,a=-b/2+i.headH,s="",l=`M${eT(t)},${eT(a)}H${eT(t+v)}`;for(let[r,n]of(i.keyW>0&&(l+=`M${eT(t+i.keyW)},${eT(a)}V${eT(b/2)}`),i.rows)){let l=Math.max(r.height,n.height,Math.round(1.5*o))+8;s+=eI(r,t+10+r.width/2,a+l/2,` class="pele-json-key"${y}`,u)+function(t,r,n,i,a){if(t.lines.length<2)return eI(t,r+t.width/2,n,i,a);let s="";for(let o=0;o<t.lines.length;o++)s+=eI(ia(t,o),r+t.widths[o]/2,n-t.height/2+ii(t,o),i,a);return s}(n,t+i.keyW+10,a+l/2,` class="pele-json-value"${p}${h}`,u),a+=l}r=`<rect x="${eT(t)}" y="${eT(-b/2)}" width="${eT(v)}" height="${eT(b)}"${r9(pH+f)}/><path class="pele-json-lines" d="${l}" fill="none" stroke="var(--_b)"${i.style.line}/>`+eI(i.label,0,-b/2+i.headH/2,` class="pele-label" font-weight="var(--_hw)"${p}${h}`,u)+`<g font-size="${o}">${s}</g>`}else{let t=i.stereotype.height/2,a;if(1===i.kind){if(n="pele-usecase",a=`<ellipse rx="${eT(v/2)}" ry="${eT(b/2)}"${pH}${f}/>`,s.business){let t=v/2-15,r=v/2-5,n=t=>b/2*Math.sqrt(1-(t/(v/2))**2);a+=`<path class="pele-business" d="M${eT(t)},${eT(n(t))}L${eT(r)},${eT(-n(r))}" fill="none" stroke="var(--_b)"${i.style.line}/>`}}else if("note"===s.shape){n="pele-note";let t=v/2,r=b/2;a=`<path d="M${eT(-t)},${eT(-r)}H${eT(t-9)}L${eT(t)},${eT(9-r)}V${eT(r)}H${eT(-t)}Z" fill="var(--_a)" stroke="var(--_b)" stroke-linejoin="round"${f}/><path d="M${eT(t-9)},${eT(-r)}V${eT(9-r)}H${eT(t)}" fill="none" stroke="var(--_b)" stroke-linejoin="round"${i.style.line}/>`}else n="pele-usecase",a=`<rect x="${eT(-v/2)}" y="${eT(-b/2)}" width="${eT(v)}" height="${eT(b)}"${r9(pH+f)}/>`;r=a+eI(i.stereotype,0,-i.label.height/2,` class="pele-stereotype" font-size="${l}"${y}`,u)+eI(i.label,0,t,` class="pele-label"${"note"===s.shape?` font-size="${o}"`:""}${p}${h}`,u)}C+=`<g class="pele-node ${n}${c}" data-id="${d}" transform="translate(${eT(a.x)},${eT(a.y)})">${r}</g>`}let T="",I="",N="",O=new Map;for(let t=0;t<y.length;t++){let r=y[t],n=b[t],i=v[t],a=n.style.length>0||n.cssCompiledStyles.length>0?no(n.cssCompiledStyles.concat(n.style)):void 0,s=n.arrowTypeStart,o=n.arrowTypeEnd,l;if(r.src===r.dst){let t=m[r.src],n=g[r.src],a=O.get(r.src)??0;O.set(r.src,a+1);let c=f?2:1,d=Math.min(pY(n,c)/2,8+6*a),u=26+8*a,[h,p]=pV(n,t,c,-d),[y,v]=pV(n,t,c,d),b=Math.hypot(u,d)||1,x=f?d/b:u/b,w=f?u/b:d/b,$=pG(s),k=pG(o),M=(t,r,n,i)=>f?`${eT(t+n*d*!!i)},${eT(r+i)}`:`${eT(t+i)},${eT(r+n*d*!!i)}`,_=f?h-x*$:h+x*$,A=f?p+w*$:p-w*$,E=y+x*k,S=v+w*k;l={d:`M${eT(_)},${eT(A)}C${M(h,p,-1,u)} ${M(y,v,1,u)} ${eT(E)},${eT(S)}`,sx:h,sy:p,sdx:f?x:-x,sdy:f?-w:w,ex:y,ey:v,edx:-x,edy:-w},f?(r.labelX=t.x,r.labelY=Math.max(p,v)+.75*u+6+i.height/2):(r.labelX=Math.max(h,y)+.75*u+8+i.width/2,r.labelY=t.y)}else{if(r.route.length<6)continue;l=rU(r.route,void 0,pG(s),pG(o))}let c=rZ(l.d,[l.sx,l.sy,l.ex,l.ey],S,l.tokens),d=c&&rX(c,a?.line),h=d||(a?.stroke?eE(a.stroke):"var(--_l)");if(""===d){let t="var(--_bg)";T+=rQ(l.d,pZ(s,l.sx,l.sy,l.sdx,l.sdy,t,t)+pZ(o,l.ex,l.ey,l.edx,l.edy,t,t),a?.line)}let p=n.internal?"2 3":"dotted"===n.pattern?"5 4":n.animate?"9 5":"",x=pZ(s,l.sx,l.sy,l.sdx,l.sdy,h)+pZ(o,l.ex,l.ey,l.edx,l.edy,h);if(I+=`<g class="pele-edge pele-${n.relationshipType}${nc(n.classes.replace(/^default relationship relationship-\S+\s?/,""))}" data-id="${eS(n.id)}"${d?` stroke="${d}"`:""}${a?.line??""}><path d="${l.d}"${p?` stroke-dasharray="${p}"`:""}/>`+(c&&d?rK(x,c):x)+"</g>",i.width>0){let t=r.labelX,s=r.labelY,o="include"===n.relationshipType||"extend"===n.relationshipType;N+=r2(n.id,i,t,s,(o?' fill="var(--_m)"':"")+(a?.text??""),u)}}return{svg:np("usecase",M,_,s,n,t,eI(w,M/2,d+w.height/2,' class="pele-title" font-weight="var(--_tw)"')+(E?`<g class="pele-clusters">${E}</g>`:"")+r1(T)+(I?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${I}</g>`:"")+(N?`<g class="pele-edge-labels" font-size="${o}">${N}</g>`:"")+`<g class="pele-nodes">${C}</g>`),width:M,height:_,links:[]}}function pK(t){let r=t.trim();return r.length>=2&&r.startsWith('"')&&r.endsWith('"')?r.slice(1,-1):r}function pJ(t){return t.map(pK).sort()}var pQ=class{type="venn";title;subsets=[];textNodes=[];styles=[];known=new Set;current;indent=!1;setDiagramTitle(t){this.title=t}addSubsetData(t,r,n){let i=pJ(t);this.current=i,1===i.length&&this.known.add(i[0]),this.subsets.push({sets:i,size:n??10/t.length**2,label:r?pK(r):void 0})}addTextData(t,r,n){this.textNodes.push({sets:pJ(t),id:pK(r),label:n?pK(n):void 0})}addStyleData(t,r){let n=new Map;for(let[t,i]of r)n.set(t,i&&pK(i));this.styles.push({targets:pJ(t),styles:n})}validateUnionIdentifiers(t){let r=t.map(pK).filter(t=>!this.known.has(t));if(r.length>0)throw new a(`unknown set identifier: ${r.join(", ")}`,"semantic",{type:"venn"})}getCurrentSets(){return this.current}getIndentMode(){return this.indent}setIndentMode(t){this.indent=t}},p0=["$end","INVALID","EOF","NEWLINE","VENN","TITLE","SET","UNION","TEXT","INDENT_TEXT","STYLE","BRACKET_LABEL","NUMERIC","HEXCOLOR","RGBCOLOR","RGBACOLOR","IDENTIFIER","STRING","COMMA","COLON"],p1=[["venn-beta",4],["set",6],["union",7],["text",8],["style",10]],p2=class{constructor(t,r){this.src=t,this.host=r}src;host;text="";start=0;at=0;lineStart=!1;ended=!1;word(t,r){let n=this.src;for(let i=0;i<r.length;i++){let a=n.charCodeAt(t+i),s=r.charCodeAt(i);if(a!==s&&(a+32!==s||a<65||a>90))return!1}return!0}keyword(t,r){return this.word(t,r)&&!J(this.src.charCodeAt(t+r.length))}color(t,r){let n=this.src,i=t+1;for(let t=0;t<r;t++){for(;V(n.charCodeAt(i));)i++;let a=i;for(;Z(n.charCodeAt(i))||46===n.charCodeAt(i);)i++;if(i===a)return -1;for(;V(n.charCodeAt(i));)i++;if(n.charCodeAt(i)!==(t===r-1?41:44))return -1;i++}return i}afterLineFeed(t){let r=t-1;for(;32===this.src.charCodeAt(r)||9===this.src.charCodeAt(r);)r--;return 10===this.src.charCodeAt(r)}lineEnd(t){let r=this.src.indexOf(`
|
|
112
|
+
`,t);return -1===r?this.src.length:r}next(){let t=this.src,r=t.length;for(;;){let n=this.at;if(this.start=n,this.text="",n>=r)return this.ended?0:(this.ended=!0,2);let i=t.charCodeAt(n);if(37===i&&37===t.charCodeAt(n+1)&&123!==t.charCodeAt(n+2)){this.at=this.lineEnd(n+2);continue}if(this.lineStart&&this.word(n,"title")&&this.afterLineFeed(n)&&""===t.slice(n+5,this.lineEnd(n+5)).trim()){let r=this.lineEnd(n+5);for(;10===t.charCodeAt(r)||13===t.charCodeAt(r);)r++;this.at=r;continue}if(this.lineStart){if(32===i||9===i){let r=n+1;for(;32===t.charCodeAt(r)||9===t.charCodeAt(r);)r++;if(this.at=r,this.keyword(r,"text")&&this.host.getIndentMode())return this.at=r+4,this.lineStart=!1,this.text=t.slice(n,r),9;continue}10!==i&&13!==i&&(this.host.setIndentMode(!1),this.lineStart=!1)}if(10===i||13===i){for(n++;10===t.charCodeAt(n)||13===t.charCodeAt(n);)n++;return this.lineStart=!0,this.token(3,n)}if(37===i&&37===t.charCodeAt(n+1)){this.at=this.lineEnd(n);continue}if(32===i||9===i){for(n++;32===t.charCodeAt(n)||9===t.charCodeAt(n);)n++;this.at=n;continue}if((32|i)>=97&&(32|i)<=122||95===i){let i=t.charCodeAt(n+5);if(this.word(n,"title")&&V(i)&&10!==i&&13!==i){let i=n+6;for(;i<r;){let r=t.charCodeAt(i);if(35===r||10===r||59===r)break;i++}if(i>n+6)return this.token(5,i)}for(let[r,i]of p1)if(this.keyword(n,r)&&45!==t.charCodeAt(n+r.length))return this.token(i,n+r.length);if(this.word(n,"rgb")){let r=(32|t.charCodeAt(n+3))==97,i=n+(r?4:3),a=40===t.charCodeAt(i)?this.color(i,r?4:3):-1;if(-1!==a)return this.token(r?15:14,a)}for(n++;J(t.charCodeAt(n))||45===t.charCodeAt(n);)n++;return this.token(16,n)}if(91===i){if(34===t.charCodeAt(n+1)){let r=t.indexOf('"',n+2);return -1===r||93!==t.charCodeAt(r+1)?1:(this.at=r+2,this.text=t.slice(n+2,r),11)}let i=n+1;for(;i<r&&93!==t.charCodeAt(i)&&34!==t.charCodeAt(i);)i++;return i===n+1||93!==t.charCodeAt(i)?1:(this.at=i+1,this.text=t.slice(n+1,i).trim(),11)}if(Z(i)||46===i||43===i||45===i){(43===i||45===i)&&n++;let r=n;for(;Z(t.charCodeAt(n));)n++;if(n>r){if(46===t.charCodeAt(n)&&Z(t.charCodeAt(n+1)))for(n+=2;Z(t.charCodeAt(n));)n++}else if(!(46===t.charCodeAt(n)&&Z(t.charCodeAt(n+1))))return 1;else for(n+=2;Z(t.charCodeAt(n));)n++;return this.token(12,n)}if(35===i){let r=n+1;for(;r<n+9&&K(t.charCodeAt(r));)r++;return r>=n+4?this.token(13,r):1}if(34===i){let r=t.indexOf('"',n+1);return -1===r?1:this.token(17,r+1)}return 44===i?this.token(18,n+1):58===i?this.token(19,n+1):1}}token(t,r){return this.text=this.src.slice(this.at,r),this.at=r,t}},p4=2*Math.PI;function p3(t,r,n,i,a,s){let o=1/0;for(let n of r){let r=t[n],l=i-r.x,c=a-r.y,d=r.r-Math.sqrt(l*l+c*c);if(d<o){if(d<s)return d;o=d}}for(let r of n){let n=t[r],l=i-n.x,c=a-n.y,d=Math.sqrt(l*l+c*c)-n.r;if(d<o){if(d<s)return d;o=d}}return o}function p5(t,r,n){let i=0,a=0,s=t[r[0]];for(let n of r){let o=t[n];i+=o.x/r.length,a+=o.y/r.length,o.r<s.r&&(s=o)}let o=s.r,l=i,c=a,d=p3(t,r,n,l,c,-1/0),u=0,h=(s,h)=>{let f=p3(t,r,n,s,h,d-1e-9*o);if(!(f>d-1e-9*o))return!1;let p=Math.hypot(s-i,h-a);return(f>d+1e-9*o||p<u-1e-9*o)&&(d=f,u=p,l=s,c=h,!0)};for(let t=-10;t<=10;t++)for(let r=-10;r<=10;r++)r*r+t*t<=100&&h(s.x+r*o/10,s.y+t*o/10);let f=o/10;for(let t=0;t<40&&f>1e-6*o;t++){let t=!1;for(let r=0;r<8;r++){let n=r*p4/8;h(l+Math.cos(n)*f,c+Math.sin(n)*f)&&(t=!0)}t||(f/=2)}return{x:l,y:c,margin:d}}var p6=no([]);function p8(t){return 1===t.length?t[0]:JSON.stringify(t)}var p9=class{nodes=new Map;labels;links=[];trends=new Map;pipelines=new Map;annotations=[];notes=[];accelerators=[];deaccelerators=[];annotationsBox;axes={};size;addNode(t){let r=this.nodes.get(t.id)??{id:t.id,label:t.label};this.nodes.set(t.id,{...r,...t,className:t.className??r.className,labelOffsetX:t.labelOffsetX??r.labelOffsetX,labelOffsetY:t.labelOffsetY??r.labelOffsetY}),this.labels=void 0}addLink(t){this.links.push(t)}addTrend(t){this.trends.set(t.nodeId,t)}startPipeline(t){this.pipelines.set(t,{nodeId:t,componentIds:[]});let r=this.nodes.get(t);r&&(r.isPipelineParent=!0)}addPipelineComponent(t,r){this.pipelines.get(t)?.componentIds.push(r);let n=this.nodes.get(r);n&&(n.inPipeline=!0)}addAnnotation(t){this.annotations.push(t)}addNote(t){this.notes.push(t)}addAccelerator(t){this.accelerators.push(t)}addDeaccelerator(t){this.deaccelerators.push(t)}setAnnotationsBox(t,r){this.annotationsBox={x:t,y:r}}setAxes(t){this.axes={...this.axes,...t}}setSize(t,r){this.size={width:t,height:r}}getNode(t){return this.nodes.get(t)}resolveNodeId(t){if(this.nodes.has(t))return t;if(!this.labels)for(let[t,r]of(this.labels=new Map,this.nodes))this.labels.has(r.label)||this.labels.set(r.label,t);return this.labels.get(t)??t}build(){let t=[];for(let r of this.nodes.values()){if("number"!=typeof r.x||"number"!=typeof r.y)throw new a(`Node "${r.label}" is missing coordinates`,"semantic",{type:"wardley"});t.push(r)}return{nodes:t,links:[...this.links],trends:[...this.trends.values()],pipelines:[...this.pipelines.values()],annotations:[...this.annotations],notes:[...this.notes],accelerators:[...this.accelerators],deaccelerators:[...this.deaccelerators],annotationsBox:this.annotationsBox,axes:{...this.axes},size:this.size}}};function p7(t,r){let n=t<=1?100*t:t;if(n<0||n>100)throw new a(`${r} must be between 0-1 (decimal) or 0-100 (percentage). Received: ${t}`,"semantic",{type:"wardley"});return n}function ge(t,r,n){return{x:p7(r,`${n} evolution`),y:p7(t,`${n} visibility`)}}function gt(t){return"+<>"===t?"bidirectional":"+<"===t?"backward":"+>"===t?"forward":void 0}function gr(t){return t?[(t.negX?-1:1)*t.offsetX,(t.negY?-1:1)*t.offsetY]:[void 0,void 0]}function gn(t,r){let n=r;for(let r=t.charCodeAt(n);r>=48&&r<=57;r=t.charCodeAt(n))n++;return n}var gi={name:"ARROW",pattern:/->/y,first:"-"},ga={name:"LINK_ARROW",pattern:/-->|-\.->|>|\+'[^']*'<>|\+'[^']*'<|\+'[^']*'>/y,first:"->+"},gs=(t,r)=>({name:t,pattern:RegExp(r,"y"),first:r[0]}),go=[{name:"[",pattern:"["},{name:",",pattern:","},{name:"]",pattern:"]"},{name:"@",pattern:"@"},{name:"/",pattern:"/"},{name:"(",pattern:"("},{name:")",pattern:")"},{name:"-",pattern:"-",longer:[gi,ga,iR]},{name:"{",pattern:"{"},{name:"}",pattern:"}"},{name:"WARDLEY_NUMBER",pattern:/[0-9]+\.[0-9]+/y,first:"0123456789",scanner:function(){let t=0,r=0;return(n,i)=>{if((i<t||i>=r)&&(t=i,r=gn(n,i)),r===i||46!==n.charCodeAt(r))return -1;let a=gn(n,r+1);return a>r+1?a:-1}}},gi,{name:"LINK_PORT",pattern:/\+<>|\+>|\+</y,first:"+"},ga,{name:"LINK_LABEL",pattern:/;[^\n\r]+/y,first:";"},{name:"STRATEGY",pattern:/build|buy|outsource|market/y,first:"bom"},gs("KW_WARDLEY","wardley-beta"),gs("KW_SIZE","size"),gs("KW_EVOLUTION","evolution"),gs("KW_ANCHOR","anchor"),gs("KW_COMPONENT","component"),gs("KW_LABEL","label"),gs("KW_INERTIA","inertia"),gs("KW_EVOLVE","evolve"),gs("KW_PIPELINE","pipeline"),gs("KW_NOTE","note"),gs("KW_ANNOTATIONS","annotations"),gs("KW_ANNOTATION","annotation"),gs("KW_ACCELERATOR","accelerator"),gs("KW_DEACCELERATOR","deaccelerator"),{name:"NAME_WITH_SPACES",pattern:/(?!title\s|accTitle|accDescr)[A-Za-z](?:[A-Za-z0-9_()&]|-(?!>))*(?:[ \t]+[A-Za-z(](?:[A-Za-z0-9_()&]|-(?!>))*)*/y,first:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"},{name:"WS",pattern:/[ \t]+/y,hidden:!0,first:" "},ol(),iC,iT,{name:"INT",pattern:/0|[1-9][0-9]*(?!\.)/y,first:"0123456789"},iN,{name:"ID",pattern:/[\w]([-\w]*\w)?/y,first:"_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"},iO,iD,iR,iL,iz],gl=["Genesis","Custom Built","Product","Commodity"],gc="var(--_c)",gd="var(--_l)";function gu(t,r,n){return t<r?r:t>n?n:t}function gh(t,r,n,i){let a=eB(t),s="",o=n;for(let n of t.lines){let i=!0;for(let t of n){if(void 0!==t.icon)continue;let n=eF(t.style&~a);s+=`<tspan${i?` x="${eT(r)}" y="${eT(o)}"`:""}${n}>${eE(t.text)}</tspan>`,i=!1}o+=t.lineHeight}return""===s?"":`<text${eW(i,a)} xml:space="preserve">${s}</text>`}function gf(t,r,n,i){let a;return gu("number"==typeof r&&Number.isFinite(r)?r:"number"==typeof(a=t["wardley-beta"]?.[n])&&a>=1&&a<=1e6?a:i,200,1e4)-96}var gp=class{type="xychart";title;accTitle;accDescr;orientation;xAxis={type:"band",title:"",categories:[]};yAxis={type:"linear",title:"",min:1/0,max:-1/0};hasSetXAxis=!1;hasSetYAxis=!1;plots=[];setOrientation(t){this.orientation="horizontal"===t?"horizontal":"vertical"}setXAxisTitle(t){this.xAxis.title=t.text.trim()}setXAxisRangeData(t,r){this.xAxis={type:"linear",title:this.xAxis.title,min:t,max:r},this.hasSetXAxis=!0}setXAxisBand(t){this.xAxis={type:"band",title:this.xAxis.title,categories:t.map(t=>t.text.trim())},this.hasSetXAxis=!0}setYAxisTitle(t){this.yAxis.title=t.text.trim()}setYAxisRangeData(t,r){this.yAxis={type:"linear",title:this.yAxis.title,min:t,max:r},this.hasSetYAxis=!0}plotData(t){if(0===t.length)return[];this.hasSetXAxis||this.setXAxisRangeData(1,t.length);let r=this.xAxis;if("band"===r.type&&t.length>r.categories.length&&(t=t.slice(0,r.categories.length)),!this.hasSetYAxis){let{min:r,max:n}=this.yAxis;for(let i of t)i<r&&(r=i),i>n&&(n=i);this.yAxis={type:"linear",title:this.yAxis.title,min:r,max:n}}if("band"===r.type)return r.categories.map((r,n)=>[r,t[n]]);if(1===t.length)return[[`${r.min}`,t[0]]];let n=(r.max-r.min)/(t.length-1);return t.map((t,i)=>[`${r.min+i*n}`,t])}addPlot(t,r,n){let i={type:t,title:r.text.trim(),data:this.plotData(n.map(t=>t.value))};"line"===t&&n.some(t=>""!==t.label.trim())&&(i.pointLabels=n.map(t=>t.label.trim())),this.plots.push(i)}setLineData(t,r){this.addPlot("line",t,r)}setBarData(t,r){this.addPlot("bar",t,r)}setDiagramTitle(t){this.title=t}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
|
|
113
|
+
`)}},gg=["$end","INVALID","NEWLINE","title","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","XYCHART","CHART_ORIENTATION","X_AXIS","Y_AXIS","ARROW_DELIMITER","LINE","BAR","NUMBER_WITH_DECIMAL","SQUARE_BRACES_START","SQUARE_BRACES_END","STR","ALPHA","COLON","PLUS","COMMA","EQUALS","MULT","BRKT","UNDERSCORE","DOT","AMP","MINUS","NUM","SEMI","EOF"],gm=[33,33,33,33,33,19,5,7,8],gy="`)"+" ".repeat(36)+'{ this.pushstate(md_string); }\n<md_string>(?:(?!`").)+'+" ".repeat(18)+"{ return md_str; }\n<md_string>(?:`",gv=new Uint8Array(128);for(let[t,r]of[[":",21],["+",22],[",",23],["=",24],["*",25],["#",26],["_",27],[".",28],["&",29],["-",30],[";",32]])gv[t.charCodeAt(0)]=r;function gb(...t){let r=new Uint8Array(34);for(let n of t)r[n]=1;return r}var gx=gb(29,31,20,22,24,25,28,26,30,27),gw=gb(2,32,33);function g$(t,r){let n=t/Math.max(r,1),i=Math.floor(Math.log10(n)),a=n/10**i,s=a>=7.07?10:a>=3.16?5:a>=1.41?2:1;return i<0?-(10**-i)/s:s*10**i}function gk(t,r){return t>0?r/t:-(r*t)}function gM(t,r){return t>0?r*t:-(r/t)}function g_(t,r,n){let i=Math.round(gk(n,t));gM(n,i)<t&&i++;let a=Math.round(gk(n,r));gM(n,a)>r&&a--;let s=[];for(let t=i;t<=a&&s.length<100;t++)s.push(gM(n,t));return s}function gA(t){return"object"!=typeof t||null===t||Array.isArray(t)?{}:t}function gE(t,r,n=!0){let i=t[r];return"boolean"==typeof i?i:n}function gS(t,r){return"number"==typeof t&&t>0?Math.round(Math.min(Math.max(t,100),4e3)):r}function gC(t){return"number"==typeof t&&isFinite(t)?Math.min(Math.max(t,-1e300),1e300):void 0}function gT(t,r,n,i){let a=1===t.lines.length?t.lines[0]:void 0;return a&&1===a.length&&void 0===a[0].icon&&0===a[0].style?`<text x="${eT(r)}" y="${eT(n+.35*t.size)}" text-anchor="${i}">${eE(a[0].text)}</text>`:eI(t,r+("start"===i?t.width/2:"end"===i?-t.width/2:0),n,"")}!function(...t){for(let r of t)to.set(r.type,r)}(o7,{type:"pie",parse:(t,r,n)=>(function(t,r){let n=new Map;for(let{label:r,value:i}of t.sections){if(i<0)throw new a(`"${r}" has invalid value: ${i}. Negative values are not allowed in pie charts. All slice values must be >= 0.`,"semantic",{type:"pie"});n.has(r)||n.set(r,i)}return{type:"pie",title:t.title||r,accTitle:t.accTitle?t.accTitle.replace(/^\s+/g,""):void 0,accDescr:t.accDescr?t.accDescr.replace(/\n\s+/g,`
|
|
114
|
+
`):void 0,showData:t.showData,sections:n}})(function(t){let r=new iG(iE(t,df,"pie"),df,"pie"),n={$type:"Pie",showData:!1,sections:[]},i=()=>{if(-1!==r.kind)for(8!==r.kind&&r.fail("a line break or the end of input");8===r.kind;)r.i++};for(;8===r.kind;)r.i++;for(r.expect(1),n.showData=r.accept(0);-1!==r.kind;)switch(r.kind){case 8:r.i++;break;case 4:n.accDescr=iq(r.take()),i();break;case 5:n.accTitle=iU(r.take()),i();break;case 6:n.title=iH(r.take()),i();break;case 7:{let t=iY(r.take());r.expect(2);let a=Number(r.expect(3));n.sections.push({$type:"PieSection",label:t,value:a}),i();break}default:r.fail("a section, a title, or a line break")}return n}(t),n),render:function(t,r,n){return is(n,240,140,(i,a)=>(function(t,r,n,i,a){let s=n.fontSize??16,o=Math.round(.875*s),l=n.measurer??e$(n.fontFamily,n.fontFamilyMono),c=n.padding??8,d=r.pie?.textPosition,u="number"==typeof d&&d>=0&&d<=1?d:.75,h=r.pie?.donutHole,f="number"==typeof h&&h>0&&h<=.9?h*i:0,p=String(r.pie?.legendPosition??"right"),g=a&&("left"===p||"right"===p)?"bottom":p,m=[...t.sections],y=0;for(let[,t]of m)y+=t;let v=m.map(([r,n])=>n7(t.showData?`${r} [${n}]`:r,!1,l,o,4e3)),b=0;for(let t of v)b=Math.max(b,t.width);b+=20*(v.length>0);let x=26*v.length,w=n7(t.title,!1,l,s,io(n),1),$=w.height>0?w.height+16:0,k=m.map(([,t])=>{let r=y>0?t/y:0;return 100*r>=1&&"0"!==(100*r).toFixed(0)?r:0}),M=k.map(t=>0!==t&&!(t>=.5)&&2*i*u*Math.sin(t*Math.PI)<l.width((100*t).toFixed(0)+"%",o,0)+6),_=28*!!M.includes(!0),A="left"===g||"right"===g||"center"===g?g:"",E="top"===g||"bottom"===g,S=(i+_)*2,C=S,T=S;"left"===A||"right"===A?(C+=b>0?32+b:0,T=Math.max(T,x)):E&&(C=Math.max(C,b),T+=x>0?20+x:0),C=Math.max(C,w.width);let I=c+("left"===A?b+32+S/2:"right"===A?S/2:C/2),N=c+$,O=N+("top"===g?x+20+S/2:E?S/2:T/2),D="",R="",L="",z=0,P=i+14,j=[],F=(t,r,n)=>j.every(i=>Math.abs(t-i.x)>=(n+i.width)/2+2||Math.abs(r-i.y)>=o+2);m.forEach(([t],r)=>{let n=k[r];if(0===n)return;let a=z+n*Math.PI*2;D+=`<path class="pele-slice" data-id="${eS(t)}" d="${function(t,r,n,i){if(r-t>=2*Math.PI-1e-9){let t=(t,r)=>`M0,${eT(-t)}A${eT(t)},${eT(t)} 0 1 ${r} 0,${eT(t)}A${eT(t)},${eT(t)} 0 1 ${r} 0,${eT(-t)}Z`;return t(n,1)+(i>0?t(i,0):"")}let a=+(r-t>Math.PI);return i<=0?`M0,0L${dp(t,n)}A${eT(n)},${eT(n)} 0 ${a} 1 ${dp(r,n)}Z`:`M${dp(t,n)}A${eT(n)},${eT(n)} 0 ${a} 1 ${dp(r,n)}L${dp(r,i)}A${eT(i)},${eT(i)} 0 ${a} 0 ${dp(t,i)}Z`}(z,a,i,f)}" fill="${nu(r)}"/>`;let s=(z+a)/2,c=(100*n).toFixed(0)+"%";if(M[r]){let t=l.width(c,o,0),r=s;for(let n=0;n<360&&!F(Math.sin(r)*P,-Math.cos(r)*P,t);n++)r+=2/P;let n=Math.sin(r)*P,i=-Math.cos(r)*P;j.push({x:n,y:i,width:t}),L+=`<text x="${eT(n)}" y="${eT(i+.35*o)}">${c}</text>`}else{let t=i*u;R+=`<text x="${eT(Math.sin(s)*t)}" y="${eT(-Math.cos(s)*t+.35*o)}"${ts(r)}>${c}</text>`}z=a}),""===D&&(D=`<circle class="pele-slice" r="${i}" fill="none" stroke="var(--_b)"/>`);let B="",W,H;"right"===A?(W=I+S/2+32,H=N+(T-x)/2):"left"===A?(W=c,H=N+(T-x)/2):"center"===A?(W=I-b/2,H=O-x/2):(W=c+(C-b)/2,H="top"===g?N:N+S+20),v.forEach((t,r)=>{let n=H+26*r+13;B+=`<g class="pele-legend-item" data-id="${eS(m[r][0])}"><rect x="${eT(W)}" y="${eT(n-6)}" width="12" height="12" rx="2" fill="${nu(r)}"/>`+eI(t,W+12+8+t.width/2,n,"")+"</g>"});let U=Math.ceil(C+2*c),q=Math.ceil(T+$+2*c),V=eI(w,U/2,c+w.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g class="pele-slices" transform="translate(${eT(I)},${eT(O)})" stroke="var(--_bg)" stroke-width="1" stroke-linejoin="round">${D}</g>`+(R?`<g class="pele-slice-labels" transform="translate(${eT(I)},${eT(O)})" font-size="${o}" text-anchor="middle" fill="var(--_bg)">${R}</g>`:"")+(L?`<g class="pele-slice-labels" transform="translate(${eT(I)},${eT(O)})" font-size="${o}" text-anchor="middle">${L}</g>`:"")+(B?`<g class="pele-legend" font-size="${o}">${B}</g>`:"");return{svg:np("pie",U,q,s,n,t,V),width:U,height:q,links:[]}})(t,r,n,i/2,a))}},{type:"er",math:!0,parse(t,r,n){let i=new sU;return n&&(i.title=n),function(t,r){let{types:n,texts:i,starts:a}=function(t){let r=t.length,n=[],i=[],a=[],s=0,o=0,l=-2,c=0,d=-1,u=-2,h=-1,f=-1,p=-1,g=(r,s,l)=>{n.push(r),i.push(t.slice(s,l)),a.push(s),o=l},m=(r,n)=>(r.lastIndex=n,r.test(t)?r.lastIndex:-1),y=r=>{for(let n=0;n<r.length;n++){let i=r.charCodeAt(n),a=t.charCodeAt(o+n);if(a!==i&&(i<97||i>122||(32|a)!==i))return!1}return!0},v=r=>y(r)&&!J(t.charCodeAt(o+r.length)),b=r=>{let n=t.charCodeAt(r);return n>=65&&n<=90?n+32:n},x=n=>(sJ.lastIndex=n,sJ.test(t)?sJ.lastIndex-1:r),w=r=>{for(;Z(t.charCodeAt(r));)r++;return r},$=r=>{let n;if((97===r||65===r)&&y("acc")){if((n=m(sY,o))>=0){s=3,g(11,o,n);return}if((n=m(sG,o))>=0){s=4,g(13,o,n);return}if((n=m(sZ,o))>=0){s=5,o=n;return}}if(!(()=>{if(-1===l||l<o&&(sK.lastIndex=o,-1==(l=sK.test(t)?sK.lastIndex-9:-1))||o<c||(d<o&&(d=x(o)),l>=d))return!1;for(let t=0;t<4;t++){let r=m(sX[t],o);if(r>=0)return g(18+t,o,r),!0}return c=d,!1})()){switch(r){case 32:case 9:case 13:n=o+1;for(let r=t.charCodeAt(n);32===r||9===r||13===r;r=t.charCodeAt(n))n++;o=n;return;case 10:for(n=o+1;10===t.charCodeAt(n);)n++;g(4,o,n);return;case 34:(()=>{let r=t.indexOf('"',o+1);if(-1===r)return g(45,o,o+1);let n=r>o+1;for(let i=o+1;n&&i<r;i++){let r=t.charCodeAt(i);(37===r||92===r||13===r||10===r||11===r||8===r)&&(n=!1)}g(n?31:44,o,r+1)})();return;case 123:s=1,g(7,o,o+1);return;case 35:g(30,o,o+1);return;case 44:g(25,o,o+1);return;case 58:58===t.charCodeAt(o+1)&&58===t.charCodeAt(o+2)?g(6,o,o+3):g(5,o,o+1);return;case 91:g(9,o,o+1);return;case 93:g(10,o,o+1);return}if(Z(r))return void(r=>{let n=t.charCodeAt(o+1);if(43===n&&(49===r||48===r))return g(49===r?39:38,o,o+2);let i=w(o+1);if(46===t.charCodeAt(i)&&Z(t.charCodeAt(i+1)))return g(32,o,w(i+2));if(49===r){if(V(n)){let r=o+2;for(;V(t.charCodeAt(r));)r++;let n=t.charCodeAt(r);if(J(n)||34===n||39===n)return g(40,o,o+1)}else if(45===n||46===n){let r=t.charCodeAt(o+2);if(45===r||46===r)return g(40,o,o+1)}if(!J(n))return g(33,o,o+1)}g(29,o,i)})(r);if(!(r=>{let n=t.charCodeAt(o+1);switch(r){case 101:if(v("erdiagram"))g(2,o,o+9);else if(v("end")){let r=o+3;for(;V(t.charCodeAt(r));)r++;g(16,o,r)}else break;return!0;case 115:if(v("style"))s=6,g(27,o,o+5);else if(v("subgraph"))g(17,o,o+8);else break;return!0;case 99:if(v("classdef"))s=6,g(22,o,o+8);else if(v("class"))g(26,o,o+5);else break;return!0;case 111:if(v("one or zero"))g(37,o,o+11);else if(v("one or more")||v("one or many"))g(39,o,o+11);else if(v("one"))g(40,o,o+3);else if(v("only one"))g(40,o,o+8);else if(124===n)g(37,o,o+2);else if(123===n)g(38,o,o+2);else if(v("optionally to"))g(42,o,o+13);else break;return!0;case 122:if(v("zero or one"))g(37,o,o+11);else if(v("zero or more")||v("zero or many"))g(38,o,o+12);else break;return!0;case 109:if(y("many(0)"))g(38,o,o+7);else if(y("many(1)"))g(39,o,o+7);else if(v("many"))g(38,o,o+4);else break;return!0;case 116:return!!v("to")&&(g(43,o,o+2),!0);case 117:return(46===n||45===n||124===n)&&(g(41,o,o+1),!0);case 124:if(111!==b(o+1)||J(t.charCodeAt(o+2)))if(124===n)g(40,o,o+2);else if(123===n)g(39,o,o+2);else break;else g(37,o,o+2);return!0;case 125:if(111!==b(o+1)||J(t.charCodeAt(o+2)))if(124===n)g(39,o,o+2);else break;else g(38,o,o+2);return!0;case 46:return(46===n||45===n)&&(g(42,o,o+2),!0);case 45:if(45===n)g(43,o,o+2);else if(46===n)g(42,o,o+2);else break;return!0}return!1})(r>=65&&r<=90?r+32:r)){if(r>=128||(1&sV[r])!=0){n=o+1;for(let r=t.charCodeAt(n);r>=128||(1&sV[r])!=0;r=t.charCodeAt(n))n++;g(23,o,n);return}g(45,o,o+1)}}},k=n=>{if(V(n)){for(o++;V(t.charCodeAt(o));)o++;return}let i=32|n;if((112===i||102===i||117===i)&&(32|t.charCodeAt(o+1))==107&&!J(t.charCodeAt(o+2)))return void g(35,o,o+2);if(!(()=>{if(-1===u||u<o&&-1===(u=t.indexOf("~",o)))return!1;if(p<o){let n=o;for(;n<r&&!V(t.charCodeAt(n));)n++;p=n}if(u>=p||(h<o&&(h=x(o),f=t.lastIndexOf("~",h-1)),f<=u))return!1;let n=f+1;for(;n<r&&!V(t.charCodeAt(n));)n++;return g(34,o,n),!0})()){if(sQ(n,4)){let n=o+1;for(;n<r&&sQ(t.charCodeAt(n),8);)n++;g(34,o,n);return}if(96===n){s=2,o++;return}if(34===n){let r=t.indexOf('"',o+1);if(-1!==r)return void g(36,o,r+1)}else if(125===n){s=0,g(8,o,o+1);return}g(45,o,o+1)}};for(;o<r;){let l=t.charCodeAt(o),c;switch(s){case 0:$(l);break;case 1:k(l);break;case 2:96===l?(s=1,o++):(c=t.indexOf("`",o),g(34,o,-1===c?r:c));break;case 3:case 4:c=t.indexOf(`
|
|
115
|
+
`,o),g(3===s?12:14,o,-1===c?r:c),s=0;break;case 5:125===l?(s=0,o++):(c=t.indexOf("}",o),g(15,o,-1===c?r:c));break;case 6:if(10===l){for(c=o+1;10===t.charCodeAt(c);)c++;s=0,g(4,o,c)}else if(V(l))for(o++;V(t.charCodeAt(o));)o++;else if(58===l)g(5,o,o+1);else if(44===l)g(25,o,o+1);else if(35===l)g(30,o,o+1);else if(59===l)g(28,o,o+1);else{if(!(l>=128)&&(2&sV[l])==0)return n.push(1),i.push(""),a.push(o),{types:n,texts:i,starts:a};c=o+1;for(let r=t.charCodeAt(c);r>=128||(2&sV[r])!=0;r=t.charCodeAt(c))c++;g(24,o,c)}}}let M=0===s?3:3===s?12:4===s?14:5===s?15:-1;return -1!==M&&(n.push(M),i.push(""),a.push(r)),n.push(0),i.push(""),a.push(r),{types:n,texts:i,starts:a}}(t),s=0,o=r=>{let o=n[s];throw 1===o?d("er",t,a[s],"",!0):d("er",t,a[s],`Expecting ${r}, got '${45===o?i[s]:sq[o]}'`)},l=t=>(n[s]!==t&&o(`'${sq[t]}'`),i[s++]),c=()=>{let t=n[s];4!==t&&28!==t&&3!==t&&o("'EOF', 'NEWLINE', 'SEMI'"),s++},u=t=>23===t||31===t||29===t||32===t||33===t,h=()=>{let t=n[s];u(t)||o(s2);let r=i[s++];return 31===t?r.slice(1,-1):r},f=()=>{let t=[];for(;;){let r=n[s];if(23!==r&&24!==r&&o("'UNICODE_TEXT', 'STYLE_TEXT'"),t.push(i[s++]),25!==n[s])return t;s++}},p=t=>24===t||29===t||5===t||30===t,g=()=>{let t=[];for(;;){p(n[s])||o("'STYLE_TEXT', 'COLON', 'NUM', 'BRKT'");let r=i[s++];for(;p(n[s]);)r+=i[s++];if(t.push(r),25!==n[s])return t;s++}},m=t=>45===n[s]&&i[s]===t,y=()=>{if(7!==n[s])return;if(8===n[++s])return void s++;let t=(()=>{let t=[];do{let r=l(34);m("?")&&(r+=i[s++]),34!==n[s]&&o(r.endsWith("?")?"'ATTRIBUTE_WORD'":"'ATTRIBUTE_WORD', '?'");let a={type:r,name:i[s++]};if(35===n[s]){let t=[i[s++]];for(;m(",");)s++,t.push(l(35));a.keys=t}36===n[s]&&(a.comment=i[s++].slice(1,-1)),t.push(a)}while(8!==n[s]);return t.reverse()})();return s++,t},v=()=>{let t,a=h(),c=n[s];if(9===c){let t;s++;let i=h();l(10),6===n[s]&&(s++,t=f());let o=y();return r.addEntity(a,i),o&&r.addAttributes(a,o),t&&r.setClass([a],t),[a]}if(6===c&&(s++,t=f(),c=n[s]),s0.has(c)){let c,d,u,p,g,m=(c=s0.get(n[s++]),43!==(d=n[s])&&42!==d&&o("'NON_IDENTIFYING', 'IDENTIFYING'"),s++,void 0===(u=s0.get(n[s]))?o("'ZERO_OR_ONE', 'ZERO_OR_MORE', 'ONE_OR_MORE', 'ONLY_ONE', 'MD_PARENT'"):(s++,{cardA:u,relType:43===d?"IDENTIFYING":"NON_IDENTIFYING",cardB:c})),y=h(),v;6===n[s]&&(s++,v=f()),l(5);let b=(44!==(p=n[s])&&31!==p&&23!==p&&o("'UNICODE_TEXT', 'ENTITY_NAME', 'WORD'"),g=i[s++],23===p?g:g.slice(1,-1));return r.addEntity(a),r.addEntity(y),r.addRelationship(a,b,y,m),t&&r.setClass([a],t),v&&r.setClass([y],v),[a,y]}let d=y();return r.addEntity(a),d&&r.addAttributes(a,d),t&&r.setClass([a],t),[a]};l(2);let b=[{id:"",title:"",list:[]}],x=b[0],w=!1;for(;;){let t=n[s];switch(t){case 4:s++;break;case 3:s++,w&&o(`'END', ${s4}`);return;case 16:{w||o(s4),s++;let t=r.addSubGraph({text:x.id},x.list,{text:x.title});b.pop(),x=b[b.length-1],(w=b.length>1)&&x.list.push(t);break}case 17:{s++;let t=h(),r=t;if(9===n[s]){for(s++,r=h();u(n[s]);)r+=" "+h();l(10)}c(),x={id:t,title:r,list:[]},b.push(x),w=!0;break}case 11:{s++;let t=l(12).trim();r.setAccTitle(t),w&&x.list.push(t);break}case 13:{s++;let t=l(14).trim();r.setAccDescription(t),w&&x.list.push(t);break}case 15:{let t=i[s++].trim();r.setAccDescription(t),w&&x.list.push(t);break}case 18:case 19:case 20:case 21:{s++;let n=s1[t-18];w?x.list.push({stmt:"dir",value:n}):r.setDirection(n);break}case 22:{let t=i[s++],n=f(),a=g();c(),r.addClass(n,a),w&&x.list.push(t);break}case 26:{let t=i[s++],n=f();r.setClass(n,f()),w&&x.list.push(t);break}case 27:{let t=i[s++],n=f(),a=g();c(),r.addCssStyles(n,a),w&&x.list.push(t);break}default:{u(t)||o(w?`'END', ${s4}`:s4);let r=v();if(w)for(let t of r)x.list.push(t)}}}}(t,i),i},render:function(t,r,n){return id(t.direction)?ic(n,i=>ot(t,r,n,i)):ot(t,r,n,!1)}},{type:"mindmap",math:!0,parse(t,r,n){let i=new di;return i.title=n,c8(t,i,!1),i},render:function(t,r,n){return ic(n,i=>(function(t,r,n,i){let a=n.fontSize??16,s=n.measurer??e$(n.fontFamily,n.fontFamilyMono),o=n.padding??8,l=n.icons,c=r.mindmap?.maxNodeWidth,d="number"==typeof c&&c>0?Math.min(c,2e3):200,u=1.25*a,h=t.nodes,f=h.length,p=new Int32Array(f),g=new Int32Array(f);for(let t=0;t<f;t++)for(let r of h[t].children)p[r.id]=t,g[r.id]=g[t]+1;let m=i&&void 0!==n.maxWidth&&n.maxWidth>0?n.maxWidth-2*o:1/0,y=Array(f),v=Array(f),b=new Float64Array(f),x=new Float64Array(f),w=new Float64Array(f),k=new Float64Array(f),M=new Uint8Array(f);for(let t=0;t<f;t++){let r=h[t];M[t]=+(void 0!==r.icon&&""!==$(r.icon));let n=Math.min(d,Math.max(72,m-28*g[t]-12-(M[t]?u+6:0))),o=y[t]=n7(r.descr,!0,s,a,n),l=o.width+(M[t]?u+6*(o.width>0):0),c=Math.max(o.height,Math.round(1.5*a)),f=da[r.type]||(0===t?ds:"");if(i&&0===t&&"rect"!==f&&"rounded"!==f&&(f=ds),v[t]=f,""===f){let n=r.children.length>0;b[t]=l+2*(n?12:6),x[t]=c+6*!!n,k[t]=x[t]/2}else{let r=nO(f,l,c);b[t]=r.w,x[t]=r.h,w[t]=r.dy,k[t]=r.h/2}}let _=new Float64Array(f),A=new Float64Array(f),E=new Float64Array(f),S=new Float64Array(f),C=0,T=(t,r,n,i)=>{let a=0,s=0;for(let o=r;o<n;o++){let r=t[o].id;A[r]=a,s=t[o].children.length>0||o+1<n&&t[o+1].children.length>0?Math.max(i,18):i,a+=_[r]+s}C=a-s;let o=t[r].id,l=t[n-1].id;return(A[o]+E[o]+k[o]+A[l]+E[l]+k[l])/2};for(let t=f-1;t>0;t--){let r=h[t].children;if(0===r.length){_[t]=x[t];continue}let n=T(r,0,r.length,8)-k[t],i=Math.min(0,n);_[t]=Math.max(C,n+x[t])-i,E[t]=n-i,S[t]=-i}let I=new Float64Array(f),N=new Float64Array(f),O=new Float64Array(f),D=new Int8Array(f),R=new Float64Array(f);if(i){let t=0;for(let r=0;r<f;r++)r>0&&0===p[r]&&(t+=10),I[r]=28*g[r]+b[r]/2,N[r]=t,t+=x[r]+10}else if(f>0){let t=h[0].children,r=t.length,n=0;for(let r of t)n+=_[r.id];let i=r,a=1/0,s=0;for(let o=1;o<r;o++){let l=Math.abs(2*(s+=_[t[o-1].id])-n+(2*o-r)*28);l<a&&(a=l,i=o)}for(let n=0,a=i,s=1;n<r;n=a,a=r,s=-1){let r=T(t,n,a,28);for(let i=n;i<a;i++){let n=t[i].id;O[n]=A[n]-r,D[n]=s}}N[0]=-x[0]/2;for(let t=0;t<f;t++)for(let r of(t>0&&(N[t]=O[t]+E[t]),h[t].children)){let n=r.id;t>0&&(D[n]=D[t],O[n]=O[t]+S[t]+A[n]),I[n]=I[t]+D[n]*(b[t]/2+(t>0?36:52)+b[n]/2)}}let L=0,z=0,P=0,j=0,F="",B="",W="",H="",U=t=>{""!==W&&(F+=`<g class="pele-branch pele-section-${t??0}"><g class="pele-edges" fill="none" stroke="${H}" stroke-width="1.5">${B}</g>${W}</g>`,B=W="")};for(let t=1;t<=f;t++){let r=t%f,n=h[r],a=v[r],s=y[r],o=I[r],c=N[r];if(L=Math.min(L,o-b[r]/2),z=Math.max(z,o+b[r]/2),P=Math.min(P,c),j=Math.max(j,c+x[r]),(0===r||0===p[r])&&U(h[t-1].section),r>0&&i){0===p[r]&&(H=nu(n.section??0));let t=p[r],i=0===t?Math.min(Math.max(12,x[0]/2),20):12,s=I[t]-b[t]/2+Math.min(i,b[t]/2),l=R[t]||N[t]+x[t],d=o-b[r]/2+(a?nR(a,b[r],x[r],3):0),u=c+k[r],h=Math.max(0,Math.min(8,d-s,u-l));R[t]=u-h,B+=`<path class="pele-edge" d="M${eT(s)},${eT(l)}V${eT(u-h)}Q${eT(s)},${eT(u)} ${eT(s+h)},${eT(u)}H${eT(d)}"/>`}else if(r>0){0===p[r]&&(H=nu(n.section??0));let t=p[r],i=D[r],s=i>0?1:3,l=I[t]+i*(b[t]/2-(v[t]?nR(v[t],b[t],x[t],s):0)),d=N[t]+k[t],u=o-i*b[r]/2+(a?i*nR(a,b[r],x[r],4-s):0),h=c+k[r],f=eT((l+u)/2);B+=`<path class="pele-edge" d="M${eT(l)},${eT(d)}C${f},${eT(d)} ${f},${eT(h)} ${eT(u)},${eT(h)}"/>`}let d=!a&&n.children.length>0,g=` fill="${H}" fill-opacity="0.22" stroke="${H}"`,m="";a?m=r>0?nD(a,b[r],x[r],g,` stroke="${H}"`):nD(a,b[r],x[r],' fill="var(--_s)" stroke="var(--_b)"',' stroke="var(--_b)"'):d&&(m=`<rect x="${eT(-b[r]/2)}" y="${eT(-x[r]/2)}" width="${eT(b[r])}" height="${eT(x[r])}" rx="${eT(x[r]/2)}"${g}/>`);let $=0;n.icon&&M[r]&&($=(u+6*(s.width>0))/2,m+=c7(n.icon,-$-s.width/2,w[r]-u/2,u,l));let _=`<g class="pele-node pele-shape-${a||(d?"branch":"text")}${r>0?"":" pele-root"}${nc(n.class??"")}" data-id="${eS(n.nodeId)}" transform="translate(${eT(o)},${eT(c+x[r]/2)})">`+m+(i&&!a?function(t,r,n,i){if(t.lines.length<2)return eI(t,r+t.width/2,n,' class="pele-label"',i);let a="",s=n-t.height/2;for(let n=0;n<t.lines.length;n++)a+=eI(ia(t,n),r+t.widths[n]/2,s+ii(t,n),' class="pele-label"',i);return a}(s,$-s.width/2,w[r],l):eI(s,$,w[r],' class="pele-label"',l))+"</g>";r>0?W+=_:F+=_}let q=ad(t.title,s,a,io(n)),V=q.height>0?q.height+16:0,Y=Math.max(z-L,q.width),G=Math.ceil(Y+2*o),Z=Math.ceil(j-P+V+2*o),X=eI(q,G/2,o+q.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${eT(o-L+(Y-z+L)/2)},${eT(o+V-P)})">${F}</g>`;return{svg:np("mindmap",G,Z,a,n,{},X),width:G,height:Z,links:[]}})(t,r,n,i))}},{type:"kanban",math:!0,parse(t,r,n){let i=new c9;return i.title=n,c8(t,i,!0),i},render:function(t,r,n){let i=n.fontSize??16,a=Math.round(.875*i),s=Math.round(1.5*i),o=Math.round(1.5*a),l=n.measurer??e$(n.fontFamily,n.fontFamilyMono),c=n.padding??8,d=n.icons,u=r.kanban??{},h=u.sectionWidth,f=1.25*a,p=0,g=(t,r,n)=>{if(!(!t||!t.includes("$$")))for(let i of n7(t,!0,l,r,1/0).lines)for(let t of i)t.math&&(p=Math.max(p,t.math.width+n))};for(let r of t.sections){let t=l.width(String(r.items.length),a,0);for(let n of(g(r.label,i,24+t+12+(dn(r.icon)?f+6:0)),r.items))g(n.label,a,36+(dn(n.icon)?f+6:0)),g(n.ticket,a,36),g(n.assigned,a,36)}let m=Math.max("number"==typeof h&&h>0?Math.min(Math.max(h,80),2e3):200,Math.ceil(p)),y=void 0!==n.maxWidth&&n.maxWidth>0?n.maxWidth-2*c:1/0,v=t.sections.length,b=v*(m+12)-12<=y,x=b?Math.max(v,1):Math.max(1,Math.floor((y+12)/(m+12))),w=b?m:Math.max(Math.min(m,y),Math.min(Math.floor((y+12)/x)-12,2*m),Math.ceil(p)),$="string"==typeof u.ticketBaseUrl?u.ticketBaseUrl:"",k=w-16,M=k-20,_=[],A=t.sections,E=[],S=[],C=[],T=s,I=[];for(let t of A){let r=l.width(String(t.items.length),a,0),n=r+12+(dn(t.icon)?f+6:0),s=dt(t.label,!0,l,i,k-8-n,1);T=Math.max(T,s.height),S.push(r),E.push(s);let c=[],d=0;for(let r of t.items){let t=dt(r.label,!0,l,a,M-(dn(r.icon)?f+6:0)),n=dt(r.ticket,!1,l,a,M),i=dt(r.assigned,!1,l,a,M),s=n.width+i.width+8>M?n.height+i.height:Math.max(n.height,i.height),u=20+Math.max(t.height,o)+(s?4+s:0);c.push({item:r,label:t,ticket:n,assigned:i,meta:s,height:u}),d+=u+8}C.push(c),I.push(d)}T+=16;let N=[],O=[];for(let t=0,r=0;t<A.length;t+=x){let n=8;for(let r=t;r<Math.min(t+x,A.length);r++)n=Math.max(n,I[r]);O.push(r),N.push(T+n),r+=T+n+12}let D=N.length>0?O[O.length-1]+N[N.length-1]:0,R=ad(t.title,l,i,io(n)),L=R.height>0?R.height+16:0,z=Math.max(Math.min(A.length,x)*(w+12)-12,0),P=Math.max(z,R.width),j=c+(P-z)/2,F=w-8-4,B="";for(let t=0;t<A.length;t++){let r=A[t],i=Math.floor(t/x),l=`<rect width="${w}" height="${eT(N[i])}" fill="var(--_s)"${r5}/>`+dr(E[t],12,8,' class="pele-cluster-label" font-weight="var(--_hw)"',d)+`<text class="pele-count" x="${F}" y="${eT(8+s/2+.35*a)}" text-anchor="end" font-size="${a}" fill="var(--_m)">${r.items.length}</text>`;dn(r.icon)&&(l+=c7(r.icon,F-S[t]-6-f,8+(s-f)/2,f,d));let u=T;for(let r of C[t]){let t=r.item,i=(t.priority??"").trim().toLowerCase(),s=de.get(i),c=`<rect width="${k}" height="${eT(r.height)}" fill="var(--_bg)" stroke="var(--_b)"${r5}/>`;void 0!==s&&(c+=`<path class="pele-priority" d="M2.5,5V${eT(r.height-5)}" fill="none" ${s} stroke-width="3" stroke-linecap="round"/>`),c+=dr(r.label,10,10,' class="pele-label"',d),dn(t.icon)&&(c+=c7(t.icon,k-10-f,10+(o-f)/2,f,d));let h=r.height-10;if(t.ticket){let i=h-r.meta,a=$?tS(tw($.replace("#TICKET#",()=>t.ticket)),n):void 0;void 0===a?c+=dr(r.ticket,10,i,' class="pele-ticket" fill="var(--_m)"',d):(c+=`<a href="${eE(a)}" target="_blank"${tN(n)}>`+dr(r.ticket,10,i,' class="pele-ticket" fill="var(--_c)"',d)+"</a>",_.push({id:t.id,href:a,internal:!1}))}t.assigned&&(c+=dr(r.assigned,k-10,h-r.assigned.height,' class="pele-assigned" fill="var(--_m)"',d,!0)),l+=`<g class="pele-node pele-card${void 0===s?"":" pele-priority-"+i.replace(" ","-")}${nc(t.cssClasses??"")}" data-id="${eS(t.id)}" transform="translate(8,${eT(u)})" font-size="${a}">${c}</g>`,u+=r.height+8}B+=`<g class="pele-cluster pele-column${nc(r.cssClasses??"")}" data-id="${eS(r.id)}" transform="translate(${eT(j+t%x*(w+12))},${eT(c+L+O[i])})">${l}</g>`}let W=Math.ceil(P+2*c),H=Math.ceil(D+L+2*c),U=eI(R,W/2,c+R.height/2,' class="pele-title" font-weight="var(--_tw)"')+B;return{svg:np("kanban",W,H,i,n,{},U),width:W,height:H,links:_}}},{type:"timeline",parse(t,r,n){let i=new ft;return i.title=n,function(t,r){let{types:n,texts:i,starts:a}=function(t){let r=t.length,n=[],i=[],a=[],s={types:n,texts:i,starts:a},o=0,l=(r,s)=>{n.push(r),i.push(t.slice(o,s)),a.push(o),o=s};for(;!((o=cj(t,o))>=r);){let n=t.charCodeAt(o),i=o+1;if(10===n){for(;10===t.charCodeAt(i);)i++;l(3,i);continue}if(cP(t,o,"timeline")){for(i=o+8;32===t.charCodeAt(i)||9===t.charCodeAt(i);)i++;let r=cP(t,i,"lr");if(i>o+8&&(r||cP(t,i,"td"))&&!J(t.charCodeAt(i+2))){l(r?5:6,i+2);continue}if(!J(t.charCodeAt(o+8))){l(4,o+8);continue}}if(cP(t,o,"title")){for(i=o+5;10!==t.charCodeAt(i)&&V(t.charCodeAt(i));)i++;if(i===r||10===t.charCodeAt(i)){o=i;continue}let n=t.charCodeAt(o+5);if(13!==n&&V(n)){l(7,cz(t,o+6));continue}}if((i=cB(t,o,s,8))!==o){o=i;continue}if(cP(t,o,"section")&&V(t.charCodeAt(o+7))){for(i=o+8;i<r&&58!==t.charCodeAt(i)&&10!==t.charCodeAt(i);)i++;if(i>o+8){l(13,i);continue}}if(58!==n){i=o+1;for(let n=t.charCodeAt(i);i<r&&35!==n&&58!==n&&10!==n;n=t.charCodeAt(++i));l(14,i);continue}if(V(t.charCodeAt(o+1))){for(i=o+2;i<r;i++){let r=t.charCodeAt(i);if(10===r||58===r&&V(t.charCodeAt(i+1)))break}if(i>o+2){l(15,i);continue}}l(2,o+1)}return(0===a.length||a[a.length-1]<r)&&l(1,r),l(0,r),s}(t),s=(r,i)=>{let s=0===n[r]?"1":fr[n[r]];throw d("timeline",t,a[r],`Expecting ${i}, got '${s}'`)},o=n[0];4!==o&&5!==o&&6!==o&&s(0,"'timeline', 'timeline_lr', 'timeline_td'"),4!==o&&r.setDirection(5===o?"LR":"TD");for(let t=1;;t++){let a=i[t];switch(n[t]){case 3:break;case 7:r.getCommonDb().setDiagramTitle(a.substring(6));break;case 8:r.getCommonDb().setAccTitle(i[++t].trim());break;case 10:r.getCommonDb().setAccDescription(i[++t].trim());break;case 12:r.getCommonDb().setAccDescription(a.trim());break;case 13:r.addSection(a.substring(8));break;case 14:r.addTask(a,0,"");break;case 15:r.addEvent(a.substring(2));break;case 1:return;default:s(t,"'EOF', 'SPACE', 'NEWLINE', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'section', 'period', 'event'")}}}(t,i),i},render:function(t,r,n){return"TD"===t.direction?fa(t,r,n,!0):ic(n,i=>fa(t,r,n,i))}},{type:"journey",parse(t,r,n){let i=new cL;return i.title=n,function(t,r){let{types:n,texts:i,starts:a}=function(t){let r=t.length,n=[],i=[],a=[],s={types:n,texts:i,starts:a},o=0,l=(r,s)=>{n.push(r),i.push(t.slice(o,s)),a.push(o),o=s};for(;!((o=cj(t,o))>=r);){let n=t.charCodeAt(o),i=o+1;if(10===n){for(;10===t.charCodeAt(i);)i++;l(3,i);continue}if(cP(t,o,"journey")&&!J(t.charCodeAt(o+7))){l(4,o+7);continue}if(cP(t,o,"title")){for(i=o+5;10!==t.charCodeAt(i)&&V(t.charCodeAt(i));)i++;if(i===r||10===t.charCodeAt(i)){o=i;continue}let n=t.charCodeAt(o+5);if(13!==n&&V(n)&&(i=cH(t,o+6,!1))>o+6){l(5,i);continue}}if((i=cB(t,o,s,6))!==o){o=i;continue}if(cP(t,o,"section")&&V(t.charCodeAt(o+7))&&(i=cH(t,o+8,!0))>o+8){l(11,i);continue}58===n?l((i=cH(t,o+1,!1))>o+1?13:14,i>o+1?i:o+1):59===n?l(2,o+1):l(12,cH(t,o+1,!0))}return(0===a.length||a[a.length-1]<r)&&l(1,r),l(0,r),s}(t),s=(r,i)=>{let s=0===n[r]?"1":cW[n[r]];throw d("journey",t,a[r],`Expecting ${i}, got '${s}'`)};4!==n[0]&&s(0,"'journey'");for(let t=1;;t++){let a=i[t];switch(n[t]){case 3:break;case 5:r.setDiagramTitle(a.substring(6));break;case 6:r.setAccTitle(i[++t].trim());break;case 8:r.setAccDescription(i[++t].trim());break;case 10:r.setAccDescription(a.trim());break;case 11:r.addSection(a.substring(8));break;case 12:13!==n[++t]&&s(t,"'taskData'"),r.addTask(a,i[t]);break;case 1:return;default:s(t,"'EOF', 'SPACE', 'NEWLINE', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'section', 'taskName'")}}}(t,i),i},render:function(t,r,n){return ic(n,r=>(function(t,r,n){let i=r.fontSize??16,a=Math.round(.875*i),s=Math.round(.75*i),o=r.measurer??e$(r.fontFamily,r.fontFamilyMono),l=r.padding??8;if(n){var c,d;let n,i,a,s,o,l,u,h,f,p,g,m,y,v;return c=t,i=Math.round(.875*(n=(d=r).fontSize??16)),a=d.measurer??e$(d.fontFamily,d.fontFamilyMono),s=d.padding??8,o=Math.max(140,(d.maxWidth??320)-2*s),l=cM(c.title,a,n,o,1),u=new Map(cR(c.tasks).filter(t=>""!==t).map((t,r)=>[t,r])),h=s+(l.height?l.height+16:0),p="",g=l.width,c.tasks.forEach((t,r)=>{if(t.section!==f){let r=cM(f=t.section,a,n,o-16,1);r.height&&(p+=eI(r,s+8+r.width/2,h+r.height/2,' class="pele-cluster-label" font-weight="var(--_hw)"'),g=Math.max(g,r.width+16),h+=r.height+8)}let l=cM(t.task,a,i,o-72),d=t.people.filter(t=>""!==t).map(t=>({name:t,label:cM(t,a,i,o-44)})),m=Math.max(l.height,42),y=16+m;for(let t of d)y+=Math.max(16,t.label.height)+4;let v=Math.max(o,l.width+72);p+=`<g class="pele-node pele-journey-step" data-id="${r}"><rect x="${eT(s)}" y="${eT(h)}" width="${eT(v)}" height="${eT(y)}" fill="var(--_s)" stroke="var(--_b)"${r5}/>`,p+=eI(l,s+10+l.width/2,h+8+l.height/2,' class="pele-label"');let b=s+v-28;p+=cq(b,h+8+11,t.score>3?"happy":t.score<3?"sad":"neutral"),Number.isNaN(t.score)||(p+=`<text class="pele-journey-score" x="${eT(b)}" y="${eT(h+8+22+i)}" font-size="${i}" text-anchor="middle">${eT(Math.min(5,Math.max(1,t.score)))}</text>`);let x=h+8+m+4;for(let t of d){let r=Math.max(16,t.label.height);p+=`<circle class="pele-actor" cx="${eT(s+16)}" cy="${eT(x+r/2)}" r="5" fill="${nu(u.get(t.name))}"/>`+eI(t.label,s+28+t.label.width/2,x+r/2,` class="pele-journey-actor" font-size="${i}"`),x+=r+4}p+="</g>",h+=y,r+1<c.tasks.length&&(p+=`<path class="pele-edge" d="M${eT(s+v/2)},${eT(h)}v16" fill="none" stroke="var(--_l)"/>`),h+=16,g=Math.max(g,v)}),m=Math.ceil(g+2*s),y=Math.ceil(Math.max(s+l.height,h-16*!!c.tasks.length)+s),v=eI(l,m/2,s+l.height/2,' class="pele-title" font-weight="var(--_tw)"')+p,{svg:np("journey",m,y,n,d,c,v),width:m,height:y,links:[]}}let u=t.tasks,h=u.length,f=cR(u).filter(t=>""!==t),p=new Map;f.forEach((t,r)=>p.set(t,r));let g=124,m=u.map(t=>ck(t.task,o,a,g)),y=0;for(let t of m)y=Math.max(y,t.width);y>g&&(g=Math.min(Math.ceil(y),200),m=u.map(t=>cM(t.task,o,a,g)));let v=g+20,b=v+12,x=h>0?h*b-12:0,w=Math.round(1.5*a),$=Math.max(x,240),k=[],M=0,_=0,A=0;for(let t of f){let r=cM(t,o,a,$-10-6),n=16+r.width;A>0&&A+n>$&&(A=0,_+=4);let i=A>0?k[k.length-1].y:_,s=Math.max(r.height,w);k.push({name:t,label:r,x:A,y:i,h:s}),A+=n,M=Math.max(M,A),_=Math.max(_,i+s),A+=20}let E=h>0?24+x:0,S=cM(t.title,o,i,Math.max(E,320),1),C=S.height>0?S.height+16:0,T=Math.max(E,S.width,h>0?24+M:0),I=l+(T-E)/2+24,N=l+C,O=[],D=0;for(let t=0;t<h;){let r,n=t+1;for(;n<h&&u[n].section===u[t].section;)n++;""!==u[t].section&&(D=Math.max(D,Math.max((r=cM(u[t].section,o,a,(n-t)*b-12-20,1)).height,w)+12)),O.push({start:t,count:n-t,label:r}),t=n}let R=w;for(let t of m)R=Math.max(R,t.height);let L=16*(f.length>0),z=R+L+16,P=N+(D>0?D+6:0),j=P+z+11+16,F=I+x,B="",W=N;if(h>0){let t="",r="";for(let n=5;n>=1;n--){let i=j+(5-n)*26;t+=`M${eT(I-6)},${eT(i)}H${eT(F)}`,r+=`<text x="${eT(I-12)}" y="${eT(i+.35*s)}">${n}</text>`}B+=`<path class="pele-grid" d="${t}" fill="none" stroke="var(--_a)"/><g class="pele-scale" font-size="${s}" text-anchor="end" fill="var(--_m)">${r}</g>`;let n="",i="",o="",l=[];for(let t of(u.forEach((t,r)=>{let s=I+r*b,c=s+v/2,d=t.score,u=j+(5-(Number.isNaN(d)?3:Math.min(5,Math.max(1,d))))*26;n+=`${0===r?"M":"L"}${eT(c)},${eT(u)}`,i+=`M${eT(c)},${eT(P+z)}V${eT(u-11)}`,o+=cq(c,u,d>3?"happy":d<3?"sad":"neutral");let h="",f=t.people.filter(t=>""!==t),g=Math.min(13,(v-20-10)/Math.max(f.length-1,1));f.forEach((t,r)=>{h+=`<circle class="pele-actor" cx="${eT(c+(r-(f.length-1)/2)*g)}" cy="${eT(P+z-8-5)}" r="5" fill="${nu(p.get(t)??0)}" stroke="var(--_s)"><title>${eS(t)}</title></circle>`}),l.push(`<g class="pele-node pele-task" data-id="${eS(t.task.trim())}"><rect x="${eT(s)}" y="${eT(P)}" width="${eT(v)}" height="${eT(z)}" fill="var(--_s)" stroke="var(--_b)"${r5}/>`+eI(m[r],c,P+8+R/2,` font-size="${a}"`)+h+"</g>")}),B+=`<path class="pele-stems" d="${i}" fill="none" stroke="var(--_b)" stroke-dasharray="2 3"/>`+(h>1?`<path class="pele-edge" d="${n}" fill="none" stroke="var(--_l)" stroke-linejoin="round"/>`:"")+o,O)){let r=l.slice(t.start,t.start+t.count).join("");if(!t.label){B+=r;continue}let n=I+t.start*b,i=t.count*b-12;B+=`<g class="pele-cluster pele-section" data-id="${eS(u[t.start].section.trim())}"><rect x="${eT(n)}" y="${eT(N)}" width="${eT(i)}" height="${eT(D)}" fill="var(--_a)"${r5}/>`+eI(t.label,n+i/2,N+D/2,` font-size="${a}" font-weight="var(--_hw)"`)+r+"</g>"}if(W=j+104+11,k.length>0){let t=I+(x-M)/2,r=W+16,n="";for(let i of k){let a=r+i.y+i.h/2;n+=`<g class="pele-legend-item" data-id="${eS(i.name)}"><circle cx="${eT(t+i.x+5)}" cy="${eT(a)}" r="5" fill="${nu(p.get(i.name)??0)}"/>`+eI(i.label,t+i.x+10+6+i.label.width/2,a,"")+"</g>"}B+=`<g class="pele-legend" font-size="${a}">${n}</g>`,W=r+_}}let H=Math.ceil(T+2*l),U=Math.ceil(Math.max(W,l)+l);return{svg:np("journey",H,U,i,r,t,eI(S,l+T/2,l+S.height/2,' class="pele-title" font-weight="var(--_tw)"')+B),width:H,height:U,links:[]}})(t,n,r))}},{type:"class",math:!0,parse(t,r,n){let i=new sp;return n&&(i.title=n),function(t,r){let{types:n,texts:i,starts:a}=function(t){let r=t.length,n=[],i=[],a=[],s=[],o=0,l=0,c=t.indexOf("direction"),d=-1,u=0,h=(r,s,o)=>(n.push(r),i.push(t.slice(s,o)),a.push(s),l=o,!0),f=t=>{s.push(o),o=t},p=()=>{s.length>0&&(o=s.pop())},g=r=>t.startsWith(r,l)&&!J(t.charCodeAt(l+r.length)),m=n=>{for(;n<r&&V(t.charCodeAt(n));)n++;return n},y=n=>{let i=t.indexOf(n,l);return -1===i?r:i},v=n=>{let i=l,a=-1;for(let n=t.charCodeAt(i);i<r&&V(n);n=t.charCodeAt(++i))10===n&&(a=i);if(a<0){l=i;return}n&&p(),h(3,l,a+1)},b=r=>{switch(r){case 99:if(g("cssClass"))return h(48,l,l+8);if(g("callback"))return h(40,l,l+8);if(g("click"))return h(43,l,l+5);break;case 108:if(g("link"))return h(41,l,l+4);break;case 110:if(g("note for"))return h(24,l,l+8);if(g("note"))return h(25,l,l+4);break;case 60:if(60===t.charCodeAt(l+1))return h(20,l,l+2);break;case 62:if(62===t.charCodeAt(l+1))return h(21,l,l+2);break;case 104:if(g("href"))return h(46,l,l+4)}return!1},x=n=>{if(b(n))return!0;let i=t.charCodeAt(l+1);switch(n){case 34:return f(1),l++,!0;case 126:return f(3),l++,!0;case 96:return f(2),l++,!0;case 95:if(g("_self"))return h(42,l,l+5);if(g("_blank"))return h(42,l,l+6);if(g("_parent"))return h(42,l,l+7);if(g("_top"))return h(42,l,l+4);break;case 60:return 124===i?h(34,l,l+2):h(36,l,l+1);case 124:return 62===i&&h(34,l,l+2);case 62:return h(36,l,l+1);case 42:return h(35,l,l+1);case 111:if(!J(i))return h(33,l,l+1);break;case 40:return 41===i&&h(37,l,l+2);case 45:return 45===i?h(38,l,l+2):h(52,l,l+1);case 46:return 46===i?h(39,l,l+2):h(8,l,l+1);case 58:{let n=l+1;for(;n<r;){let r=t.charCodeAt(n);if(58===r||10===r||59===r)break;n++}return n>l+1?h(10,l,n):58===i&&58===t.charCodeAt(l+2)&&h(19,l,l+3)}case 43:return h(58,l,l+1);case 37:return h(51,l,l+1);case 61:return h(59,l,l+1);case 91:return h(5,l,l+1);case 93:return h(7,l,l+1);case 33:case 35:case 36:case 38:case 39:case 44:case 63:case 92:case 47:return h(60,l,l+1)}if(J(n)){let r=l+1;for(;J(t.charCodeAt(r));)r++;return h(27,l,r)}return tK(n)&&h(53,l,l+1)},w=n=>{if((()=>{if(-1===c||l<u||(c<l&&(c=t.indexOf("direction",l)),-1===c)||(d<l&&(sv.lastIndex=l,d=sv.test(t)?sv.lastIndex-1:r),c>=d))return!1;for(let r=0;r<4;r++){let n=sy[r];if(n.lastIndex=l,n.test(t))return h(29+r,l,n.lastIndex)}return u=d,!1})())return!0;if(V(n))return v(!1),!0;switch(n){case 37:if(37===t.charCodeAt(l+1)){let n=y(`
|
|
116
|
+
`);for(;n<r&&(10===t.charCodeAt(n)||13===t.charCodeAt(n));)n++;return l=n,!0}break;case 97:{let r=t.startsWith("accTitle",l);if(!r&&!t.startsWith("accDescr",l))break;let n=m(l+8),i=t.charCodeAt(n);if(58===i)return h(r?11:13,l,m(n+1)),f(r?6:7),!0;if(123===i&&!r)return l=m(n+1),f(8),!0;break}case 99:if(g("classDiagram-v2"))return h(2,l,l+15);if(g("classDiagram"))return h(2,l,l+12);if(t.startsWith("call",l)&&V(t.charCodeAt(l+4)))return l=m(l+4),f(4),!0;if(g("classDef"))return h(26,l,l+8);if(g("class"))return f(9),h(22,l,l+5);break;case 91:if(t.startsWith("*]",l+1))return h(55,l,l+3);break;case 115:if(g("style"))return h(47,l,l+5);break;case 110:if(g("namespace"))return f(11),h(18,l,l+9);break;case 44:return h(28,l,l+1);case 35:return h(50,l,l+1)}return x(n)||58===n&&h(49,l,l+1)};for(;;){if(l>=r){n.push(sm[o]),i.push(""),a.push(r);break}let s=t.charCodeAt(l),c=!0;switch(o){case 0:c=w(s);break;case 9:V(s)?v(!0):125===s?(p(),p(),h(17,l,l+1)):123===s?(f(10),h(16,l,l+1)):c=x(s);break;case 10:if(34===s)f(1),l++;else if(125===s)p(),h(17,l,l+1);else if(91===s&&t.startsWith("*]",l+1))h(55,l,l+3);else if(123===s)h(57,l,l+1);else if(10===s)l++;else{let n=l+1;for(;n<r;){let r=t.charCodeAt(n);if(123===r||125===r||10===r)break;n++}h(23,l,n)}break;case 11:V(s)?v(!0):123===s?(f(12),h(16,l,l+1)):125===s?p():110===s&&g("namespace")?(f(11),h(18,l,l+9)):c=x(s);break;case 12:V(s)?v(!1):125===s?(p(),h(17,l,l+1)):110===s&&g("namespace")?(f(11),h(18,l,l+9)):91===s&&t.startsWith("*]",l+1)?h(55,l,l+3):99===s&&g("class")?(f(9),h(22,l,l+5)):c=x(s);break;case 1:34===s?(p(),l++):h(6,l,y('"'));break;case 3:if(34===s)f(1),l++;else{if(b(s))break;126===s?(p(),l++):h(9,l,y("~"))}break;case 2:if(34===s)f(1),l++;else{if(b(s))break;126===s?(f(3),l++):96===s?(p(),l++):h(54,l,y("`"))}break;case 4:if(40===s){let r=m(l+1);p(),41===t.charCodeAt(r)?l=r+1:(f(5),l++)}else h(44,l,y("("));break;case 5:41===s?(p(),l++):h(45,l,y(")"));break;case 6:case 7:h(6===o?12:14,l,y(`
|
|
117
|
+
`)),p();break;case 8:125===s?(p(),l++):h(15,l,y("}"))}if(!c)return n.push(1),i.push(""),a.push(l),{types:n,texts:i,starts:a}}return n.push(0),i.push(""),a.push(r),{types:n,texts:i,starts:a}}(t),s=0,o=r=>{let i=n[s];throw 1===i?d("class",t,a[s],"",!0):d("class",t,a[s],`Expecting ${r}, got '${sg[i]}'`)},l=t=>(n[s]!==t&&o(`'${sg[t]}'`),i[s++]),c=()=>(0===sb[n[s]]&&o("'UNICODE_TEXT', 'NUM', 'ALPHA', 'MINUS'"),i[s++]),u=t=>{let r="";for(;;){if(54===n[s]){r+=i[s++];break}0===sb[n[s]]&&o("'UNICODE_TEXT', 'NUM', 'ALPHA', 'MINUS', 'BQUOTE_STR'"),r+=i[s++];let t=n[s];if(8===t)r+=".",s++;else if(0===sb[t]&&54!==t)break}return t&&9===n[s]&&(r+="~"+i[s++]+"~"),r},h=()=>{s++;let t=l(6);return l(7),t},f=()=>{23!==n[s]&&o("'STRUCT_STOP', 'MEMBER'");let t=[];for(;23===n[s];)t.push(i[s++]);return l(17),t.reverse()},p=()=>{s++;let t=u(!0);switch(r.addClass(t),5===n[s]&&r.setClassLabel(t,h()),n[s]){case 19:{s++;let i=c();r.setCssClass(t,i),16===n[s]&&(s++,r.addMembers(t,f()));break}case 16:17===n[++s]?s++:r.addMembers(t,f());break;case 20:{s++;let i=c();l(21),r.addAnnotation(t,i),16===n[s]&&(17===n[++s]?s++:r.addMembers(t,f()))}}return t},g=()=>{if(25===n[s++])return r.addNote(l(6));let t=u(!0);return r.addNote(l(6),t)},m=()=>{let t=sw[n[s]];return 0===t?"none":(s++,t-1)},y=()=>{let t=[];for(;;){0===sx[n[s]]&&o("'ALPHA', 'NUM', 'COLON', 'UNIT', 'SPACE', 'BRKT', 'STYLE', 'PCT', 'LABEL'");let r=i[s++];for(;1===sx[n[s]];)r+=i[s++];if(t.push(r),28!==n[s])return t;s++}},v=t=>{6===n[s]&&r.setTooltip(t,i[s++])},b=t=>{let a=l(6),o=6===n[s]?i[s++]:void 0;42===n[s]?r.setLink(t,a,i[s++]):r.setLink(t,a),void 0!==o&&r.setTooltip(t,o)},x=()=>{let t=n[s];switch(t){case 53:case 27:case 52:case 54:(()=>{let t=u(!0),a=n[s];if(10===a)return r.addMember(t,r.cleanupLabel(i[s++]));let l="none";if(6===a)l=i[s++],a=n[s];else if(0===sw[a]&&38!==a&&39!==a)return;let c=m();38!==(a=n[s])&&39!==a&&o("'AGGREGATION', 'EXTENSION', 'COMPOSITION', 'DEPENDENCY', 'LOLLIPOP', 'LINE', 'DOTTED_LINE'"),s++;let d=m(),h=6===n[s]?i[s++]:"none",f={id1:t,id2:u(!0),relation:{type1:c,type2:d,lineType:+(38!==a)},relationTitle1:l,relationTitle2:h};10===n[s]&&(f.title=r.cleanupLabel(i[s++])),r.addRelation(f)})();return;case 18:(()=>{let t=[];for(;;){s++;let i=u(!1),a=5===n[s]?r.addNamespace(i,h()):r.addNamespace(i);l(16),3===n[s]&&s++,t.push({id:a,classes:[],notes:[]});let c=!0;for(;c;){let i=t[t.length-1],a=n[s];if(18===a)break;for(22===a?i.classes.push(p()):25===a||24===a?i.notes.push(g()):o("'NAMESPACE', 'CLASS', 'NOTE_FOR', 'NOTE'");;){if(3===n[s]){let t=n[s+1];if(18===t||22===t||25===t||24===t){s++;break}s++}l(17);let i=t.pop();if(r.addClassesToNamespace(i.id,i.classes,i.notes),r.popNamespace(),0===t.length){c=!1;break}}}if(0===t.length)return}})();return;case 22:p();return;case 23:s++;return;case 20:{s++;let t=c();l(21),r.addAnnotation(u(!0),t);return}case 40:{s++;let t=u(!0);r.setClickEvent(t,l(6)),v(t);return}case 41:s++,b(u(!0));return;case 43:{s++;let t=u(!0);if(46===n[s]){s++,b(t);return}let a=l(44);45===n[s]?r.setClickEvent(t,a,i[s++]):r.setClickEvent(t,a),v(t);return}case 47:{s++;let t=l(27);r.setCssStyle(t,y());return}case 48:{s++;let t=l(6);r.setCssClass(t,l(27));return}case 25:case 24:g();return;case 26:{s++;let t=[l(27)];for(;28===n[s];)s++,t.push(l(27));r.defineClass(t,y());return}case 29:case 30:case 31:case 32:s++,r.setDirection(29===t?"TB":30===t?"BT":31===t?"RL":"LR");return;case 11:s++,r.setAccTitle(l(12).trim());return;case 13:s++,r.setAccDescription(l(14).trim());return;case 15:r.setAccDescription(i[s++].trim());return}o("'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'NAMESPACE', 'ANNOTATION_START', 'CLASS', 'MEMBER', 'NOTE_FOR', 'NOTE', 'CLASSDEF', 'direction_tb', 'CALLBACK', 'LINK', 'CLICK', 'STYLE', 'CSSCLASS', 'ALPHA', 'MINUS', 'BQUOTE_STR'")},w=2===n[s];for(w&&(s++,l(3));x(),3===n[s]&&4!==n[++s]&&0!==n[s];);w&&l(4),l(0)}(t,i),i},render:function(t,r,n){let i=i=>iu(n,a=>(function(t,r,n,i,a){let s=r.class??{},o=function(t,r=!0){let n=[],i=[],a=new Map,s=new Map,o=new Map,l=new Map,c=n=>{if(r||void 0===n)return n;let i=[],a=n,s;for(;a;){if(l.has(a)){s=l.get(a);break}let r=t.namespaces.get(a);if(void 0===r)break;if(r.explicit){s=a;break}i.push(a),a=r.parent}for(let t of i)l.set(t,s);return s},d=t=>void 0===t?-1:a.get(t)??-1;for(let i of t.namespaces.values())(r||i.explicit)&&(a.set(i.id,n.length),n.push({id:i.id,label:r?i.label:i.id,isGroup:!0,shape:"rect",parentId:r?i.parent:void 0,parent:-1}));for(let t of n)t.parent=d(t.parentId);let u=0;for(let r of t.classes.values()){let t=c(r.parent);s.set(r.id,n.length),n.push({id:r.id,label:r.label,isGroup:!1,shape:"classBox",parentId:t,parent:d(t),classNode:r,colorIndex:u++})}for(let r of t.notes.values()){let t=c(r.parent),a=void 0===r.class?void 0:s.get(r.class);void 0!==a&&i.push({id:`edgeNote${r.index}`,start:r.id,end:n[a].id,source:n.length,target:a,label:void 0,arrowTypeStart:"none",arrowTypeEnd:"none",startLabelRight:"",endLabelLeft:"",pattern:"dotted",classes:"relation"}),n.push({id:r.id,label:r.text,isGroup:!1,shape:"note",parentId:t,parent:d(t)})}for(let r of t.interfaces){let t=s.get(r.classId);o.set(r.id,n.length),n.push({id:r.id,label:r.label,isGroup:!1,shape:"interface",parentId:void 0,parent:void 0===t?-1:n[t].parent})}let h=0;for(let r of t.relations){h++;let{type1:t,type2:n}=r.relation,a=t===su.LOLLIPOP&&"none"===n?o:s,l=a===s&&n===su.LOLLIPOP&&"none"===t?o:s;i.push({id:`id_${r.id1}_${r.id2}_${h}`,start:r.id1,end:r.id2,source:a.get(r.id1)??-1,target:l.get(r.id2)??-1,label:r.title,arrowTypeStart:sk(t),arrowTypeEnd:sk(n),startLabelRight:"none"===r.relationTitle1?"":r.relationTitle1,endLabelLeft:"none"===r.relationTitle2?"":r.relationTitle2,pattern:1===r.relation.lineType?"dashed":"solid",classes:"relation"})}return{nodes:n,edges:i}}(t,!1!==s.hierarchicalNamespaces),l=!0===s.hideEmptyMembersBox,c=Array.isArray(n.monospace)&&n.monospace.includes("members"),d=t=>c&&!/[";]font-family:/.test(t.text),u=n.fontSize??16,h=Math.round(.875*u),f=Math.round(.8*u),p=Math.round(1.4*f),g=n.measurer??e$(n.fontFamily,n.fontFamilyMono),m=n.padding??8,v=(t,r)=>{if(!t.includes("$$"))return;let n=n7(t,!1,g,r,4e3);return n.lines.some(ir)?n:void 0},b=t=>t?v(t,f)?.width??g.width(y(t),f,0):0,x=i?"TB":rC(t.direction),w=new Map,$=new Map,k=new Map,M=t=>{let r=w.get(t);if(void 0===r){let n=no([t]);r=""===n.shape&&""===n.text?"":t.slice(0,t.indexOf(":")).trim().toLowerCase(),w.set(t,r)}""!==r&&k.set(r,t)},_=new Int32Array(o.nodes.length);for(let t of o.nodes)t.parent>=0&&_[t.parent]++;let A=new Uint8Array(o.nodes.length);for(let t of o.edges){if(t.source<0||t.target<0)continue;let r=o.nodes[t.source].parent,n=o.nodes[t.target].parent;if(r!==n){for(let t=r;t>=0&&0===A[t];t=o.nodes[t].parent)A[t]=1;for(let t=n;t>=0&&0===A[t];t=o.nodes[t].parent)A[t]=1}}let E=[],S=[];function C(t,r,n,i,a){return{node:t,style:no(sT),label:r,w:n,h:i,loops:0,annotations:sT,attributes:sC,methods:sC,titleH:0,attributesH:0,fontSize:a}}o.nodes.forEach((r,n)=>{let i,s;if(r.isGroup){let t=n7(r.label,!1,g,u,4e3);i=C(r,t,0,0,u),_[n]>0?((s=rR(0,0)).isGroup=!0,s.padX=20,s.padTop=t.height>0?t.height+16:20,s.padBottom=20,s.minW=t.width+40-12+(1!==A[n]||a?0:Math.min(t.width+24,240))):(i.w=Math.max(t.width+40,80),i.h=t.height+40,s=rR(i.w,i.h))}else if(r.classNode)s=rR((i=function(r,n){let i=(r=>{k.clear();let n=$.get(r.cssClasses);if(void 0===n){for(let n of r.cssClasses.split(" ")){let r=t.styleClasses.get(n);if(r)for(let t of r.styles)for(let r of t.split(","))M(r)}n=[...k],$.set(r.cssClasses,n)}else for(let[t,r]of n)k.set(t,r);for(let t of r.styles)M(t);return no(0===k.size?sT:[...k.values()])})(n),a=i.fontSize??u,s=Math.round(.875*a),o=Math.round(1.5*s),c=n.type?"<"+so(n.type).replace(/</g,"<").replace(/>/g,">")+">":"",h=n7(n.label+c,!1,g,a,4e3,1|2*!!i.italic),m=n.annotations.length>0?n.annotations.map(t=>v(`\xab${t.trim()}\xbb`,f)??`\xab${y(t).trim()}\xbb`):sT,b=n.members.length>0?n.members.map(t=>sI(t,g,s,d(i))):sC,x=n.methods.length>0?n.methods.map(t=>sI(t,g,s,d(i))):sC,w=h.width,_=0;for(let t of m)w=Math.max(w,"string"==typeof t?g.width(t,f,0):t.width),_+="string"==typeof t?p:Math.max(p,t.height);for(let t of b)w=Math.max(w,t.width);for(let t of x)w=Math.max(w,t.width);let A=!(l&&0===b.length&&0===x.length),E=t=>A?t>0?12+t*o:10:0,S=16+_+Math.max(h.height,Math.round(1.5*a)),C=E(b.length);return{node:r,style:i,label:h,w:Math.max(w+24,64),h:S+C+E(x.length),loops:0,annotations:m,attributes:b,methods:x,titleH:S,attributesH:C,fontSize:a}}(r,r.classNode)).w,i.h);else if("note"===r.shape){let t=n7(r.label,!0,g,h,260);s=rR((i=C(r,t,Math.max(t.width+24,40),t.height+16,h)).w,i.h)}else{let t=n7(r.label,!1,g,h,200);s=rR((i=C(r,t,Math.max(t.width,12)+4,Math.max(t.height,12),h)).w,i.h)}s.parent=r.parent,s.seq=n,E.push(i),S.push(s)});let T=[],I=[],N=[],O=[],D=[],R=new Float64Array(4*E.length),L=(t,r,n)=>{R[4*t+r]++,n>R[4*t+r+1]&&(R[4*t+r+1]=n)};for(let t of o.edges){if(t.source<0||t.target<0)continue;let r=n7(t.label,!0,g,h,200),n=b(t.startLabelRight),i=b(t.endLabelLeft);t.source===t.target?(E[t.source].loops++,S[t.source].w+=2*(26+(r.width>0?r.width+12:0))):(L(t.source,0,n),L(t.target,2,i)),O.push(n),D.push(i),I.push(t),N.push(r),T.push({src:t.source,dst:t.target,minlen:1,labelW:r.width>0?r.width+12:0,labelH:r.height>0?r.height+4:0,route:[],labelX:0,labelY:0})}if("TB"===x||"BT"===x)for(let t=0;t<E.length;t++){if(!E[t].node.classNode)continue;let r=0;for(let n=0;n<4;n+=2){let i=R[4*t+n],a=R[4*t+n+1];i>1&&(r=Math.max(r,(i-1)*(a>0?a+24:14)+24))}(r=Math.min(r,480))>E[t].w&&(S[t].w+=r-E[t].w,E[t].w=r)}let z=!1;for(let t=0;t<I.length&&!z;t++)z=O[t]>0||D[t]>0;let P=0;if("TB"===x||"BT"===x){let t=t=>t?Math.max(p,v(t,f)?.height??0):0;for(let r of I)P=Math.max(P,t(r.startLabelRight)+t(r.endLabelLeft)-2*p)}let j=rP(S,T,x,{nodeSep:sS(s,"nodeSpacing",40),edgeSep:16,rankSep:sS(s,"rankSpacing",z?72:56)+P,portSep:20,apart:!0}),F=new Map,B=[],W=(t,r,n,i,a)=>{let s=t.route,o=S[n],l=nz(s,r,o);if(l<0)return;let c=(o.w-E[n].w)/2;1===l?s[r]-=c:3===l&&(s[r]+=c);let d=1&l,u=s[(0===r?3:r-3)+d],h=u-s[r+d],f={route:s,at:r,toward:u,order:a,room:i,side:l,after:d?h>0:h>=0},p=4*n+l,g=F.get(p);return g?g.push(f):F.set(p,[f]),f},H=[],U=[];for(let t=0;t<T.length;t++){let r=T[t],n=r.src!==r.dst&&r.route.length>=6;H.push(n?W(r,0,r.src,O[t],t):void 0),U.push(n?W(r,r.route.length-3,r.dst,D[t],t):void 0)}let q=(t,r,n)=>{for(let i=S[t].parent,a=0;i>=0&&a<1e4;i=S[i].parent,a++){let t=S[i],a=Math.abs(r-t.x),s=Math.abs(n-t.y);if(.5>Math.abs(s-t.h/2)&&a<=t.w/2+.5||.5>Math.abs(a-t.w/2)&&s<=t.h/2+.5)return!0}return!1},V=[];for(let[t,r]of F){if(r.length<2)continue;let n=t>>2,i=1&t,a=i?E[n].h:E[n].w;r.sort((t,r)=>t.toward-r.toward||t.order-r.order);let s=0;for(let t=0;t+1<r.length;t++){let n=r[t],a=r[t+1],o=i?20:24;n.room>0&&n.after&&(o+=i?p+6:n.room),a.room>0&&!a.after&&(o+=i?p+6:a.room),V[t]=o,s+=o}let o=Math.min(1,(a-24)/s);if(o<=0)continue;let l=(i?S[n].y:S[n].x)-s*o/2;for(let t=0;t<r.length;t++){let{route:a,at:s}=r[t],c=0===s?3:-3,d=s+c,u=-1;for(let t=d;t>=0&&t<a.length&&.5>Math.abs(a[t+i]-a[d+i]);t+=c)if(q(n,a[t],a[t+1])){u=t;break}if(u>=0&&24>=Math.abs(a[d+i]-l))for(let t=d;t!==u+c;t+=c)a[t+i]=l;a[s+i]=l,l+=V[t]*o}}let Y=(t,r,n,i)=>{if(void 0===r||n<=0)return;let a=1&r.side,s=i?0:t.length-3,o=s+1-a,l=Math.abs(t[(i?3:s-3)+1-a]-t[o]),c=Math.min(a?n+10:p+6,.35*l);if(c<4)return;let d=[t[s],t[s+1],t[s+2]];d[1-a]+=(0===r.side||3===r.side?-1:1)*c,t.splice(i?3:s,0,d[0],d[1],d[2])};for(let t=0;t<T.length;t++)Y(T[t].route,H[t],O[t],!0),Y(T[t].route,U[t],D[t],!1);let G=0,Z=0,X=j.width,K=j.height,J=(t,r,n,i,a,s,o)=>{if(!r)return;let l=v(r,f),c=l?Math.max(p,l.height):p,d=i,u=a;1&s?(d+=(3===s?-1:1)*(5+n/2),u+=(o?1:-1)*(7+c/2)):(d+=(o?1:-1)*(9+n/2),u+=(0===s?-1:1)*(3+c/2)),B.push({text:y(r),math:l,x:d,y:u,w:n,h:c,parent:t}),G=Math.min(G,d-n/2),X=Math.max(X,d+n/2),Z=Math.min(Z,u-c/2),K=Math.max(K,u+c/2)},Q=new Map,ee=new Int32Array(T.length);for(let t=0;t<T.length;t++){let r=T[t],n=I[t],i=r.route;if(r.src===r.dst){let i=Q.get(r.src)??0;Q.set(r.src,i+1),ee[t]=i;let a=S[r.src],s=E[r.src],o=a.x+s.w/2,l=Math.min(s.h/2-4,8+6*i);J(r.src,n.startLabelRight,O[t],o,a.y-l,1,!1),J(r.dst,n.endLabelLeft,D[t],o,a.y+l,1,!0),r.labelX=a.x+s.w/2+26+8*i+4+r.labelW/2,r.labelY=a.y}else if(i.length>=6){let a=i.length-3,s=H[t],o=U[t];J(r.src,n.startLabelRight,O[t],i[0],i[1],s?s.side:2,!s||s.after),J(r.dst,n.endLabelLeft,D[t],i[a],i[a+1],o?o.side:0,!o||o.after)}}let et=n.maxWidth;if(void 0!==et&&et>0&&X-G+2*m>et){let t=B.map(t=>({...rR(t.w,t.h,t.parent),x:t.x,y:t.y})),r=function(t,r,n,i){let a=Int32Array.from(t,(t,r)=>r),s=t=>{for(;a[t]!==t;)a[t]=a[a[t]],t=a[t];return t},o=(t,r)=>{a[s(t)]=s(r)};for(let r=0;r<t.length;r++)t[r].parent>=0&&o(r,t[r].parent);for(let t of r)o(t.src,t.dst);let l=new Map,c=(t,r,n,i=0,a=0)=>{t.left=Math.min(t.left,r-i/2),t.top=Math.min(t.top,n-a/2),t.right=Math.max(t.right,r+i/2),t.bottom=Math.max(t.bottom,n+a/2)};for(let r=0;r<t.length;r++){let n=s(r),i=l.get(n);i||(i={nodes:[],edges:[],left:1/0,top:1/0,right:-1/0,bottom:-1/0},l.set(n,i));let a=t[r];i.nodes.push(a),c(i,a.x,a.y,a.w,a.h)}if(l.size<2)return;for(let t of r){let r=l.get(s(t.src));r.edges.push(t);for(let n=0;n<t.route.length;n+=3)c(r,t.route[n],t.route[n+1]);t.labelW>0&&c(r,t.labelX,t.labelY,t.labelW,t.labelH)}let d=0,u=0,h=0,f=0,p=1/0,g=-1/0,m=[];for(let t of l.values()){let r=t.right-t.left,a=t.bottom-t.top;d>0&&d+r>n&&(u+=h+i,d=0,h=0),m.push(d-t.left,u-t.top),p=Math.min(p,t.left),g=Math.max(g,t.right),f=Math.max(f,d+r),h=Math.max(h,a),d+=r+i}if(f>=g-p)return;let y=0;for(let t of l.values())rD(t.nodes,t.edges,m[y++],m[y++]);return{width:f,height:u+h}}(S.concat(t),T,Math.max(1,et-2*m),sS(s,"nodeSpacing",40));r&&(B.forEach((r,n)=>{r.x=t[n].x,r.y=t[n].y}),G=Z=0,X=r.width,K=r.height)}let er=m-G,en=m-Z,ei=Math.ceil(X-G+2*m),ea=Math.ceil(K-Z+2*m),es=[],eo=new Map;if(o.nodes.length>0&&o.nodes[0].isGroup)for(let t of T)rj(eo,t.route);let el="",ec="",ed="";for(let t=0;t<E.length;t++){let r=E[t],i=S[t],a=r.node,s=i.x+er,l=i.y+en,c=eS(a.id),g=i.isGroup?i.w:r.w,m=i.isGroup?i.h:r.h;if(a.isGroup){let n=i.isGroup?rF(i,r.label.width,eo,20):i.x,a=l-m/2+8+r.label.height/2,d=' class="pele-cluster-label" fill="var(--_m)"',u=i.isGroup&&rB(i,r.label.width,n,eo);u&&(ec+=rW(r.label,n+er,a,d,c,o.nodes,t)),el+=`<g class="pele-cluster pele-namespace" data-id="${c}"><rect x="${eT(s-g/2)}" y="${eT(l-m/2)}" width="${eT(g)}" height="${eT(m)}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${r5}/>`+(u?"":eI(r.label,n+er,a,d))+"</g>";continue}let y=` transform="translate(${eT(s)},${eT(l)})"`;if(a.classNode)ed+=function(t,r,i,a){let{w:s,h:o,style:l}=t,c=-s/2,h=-o/2,g=Math.round(.875*t.fontSize),m=Math.round(1.5*g),y=`<rect x="${eT(c)}" y="${eT(h)}" width="${eT(s)}" height="${eT(o)}" fill="var(--_s)" stroke="var(--_b)"${r9(l.shape)}/>`,v=e8(l),b=h+t.titleH,x=b+t.attributesH;if(o>t.titleH){let t=l.stroke?` style="stroke:${eE(l.stroke)}"`:"";y+=`<path class="pele-divider" d="M${eT(c)},${eT(b)}H${eT(-c)}M${eT(c)},${eT(x)}H${eT(-c)}" fill="none" stroke="var(--_b)"${t}/>`}let w=h+8;for(let r of t.annotations)if("string"==typeof r)y+=`<text class="pele-annotation" x="0" y="${eT(w+p/2+.35*f)}" text-anchor="middle" font-size="${f}"${v||' fill="var(--_m)"'}>${eE(r)}</text>`,w+=p;else{let t=Math.max(p,r.height);y+=eI(r,0,w+t/2,` class="pele-annotation" font-size="${f}"${v||' fill="var(--_m)"'}`,n.icons),w+=t}let $=t.fontSize===u?"":` font-size="${eT(t.fontSize)}"`;y+=eI(t.label,0,(w+b-8)/2,` class="pele-label"${$} font-weight="var(--_hw)"${v}${l.text}`,n.icons);let k=(t,r,n)=>{let i="",a=n+6+m/2+.35*g;for(let n of t){let t="$"===n.classifier?` pele-static"${l.text?l.text.slice(0,-1)+'text-decoration:underline"':' style="text-decoration:underline"'}`:"*"===n.classifier?` pele-abstract" font-style="italic"${l.text}`:`"${l.text}`;i+=`<text class="pele-member pele-${r}${t} x="${eT(c+12)}" y="${eT(a)}">${eE(n.text)}</text>`,a+=m}return i};return(t.attributes.length>0||t.methods.length>0)&&(y+=`<g class="pele-members" font-size="${g}"${v}${d(l)?` font-family="${r3}"`:""}>${k(t.attributes,"attribute",b)}${k(t.methods,"method",x)}</g>`),r.tooltip&&(y=`<title>${eS(r.tooltip)}</title>`+y),r.link&&(y=tI(y,r.link,r.id,es,n,r.linkTarget&&sE.has(r.linkTarget)?` target="${r.linkTarget}"`:"")),`<g class="pele-node pele-class${nc(r.cssClasses.replace(/^default\s?/,""))}" data-id="${i}"${a}>${y}</g>`}(r,a.classNode,c,y);else if("note"===a.shape){let t=g/2,i=-m/2;ed+=`<g class="pele-node pele-note" data-id="${c}"${y}><path d="M${eT(-t)},${eT(i)}H${eT(t-8)}L${eT(t)},${eT(i+8)}V${eT(-i)}H${eT(-t)}Z" fill="var(--_a)" stroke="var(--_b)" stroke-linejoin="round"/><path d="M${eT(t-8)},${eT(i)}V${eT(i+8)}H${eT(t)}" fill="none" stroke="var(--_b)" stroke-linejoin="round"/>`+eI(r.label,0,0,` class="pele-label" font-size="${h}"`,n.icons)+"</g>"}else ed+=`<g class="pele-node pele-interface" data-id="${c}"${y}>`+eI(r.label,0,0,` class="pele-label" font-size="${h}"`,n.icons)+"</g>"}let eu="",eh="";for(let t=0;t<T.length;t++){let r=T[t],i=I[t],a=N[t],s=i.arrowTypeStart,o=i.arrowTypeEnd,l=sM(s),c=sM(o),d;if(r.src===r.dst){let n=S[r.src],i=E[r.src],a=ee[t],s=n.x+er+i.w/2,o=n.y+en,u=Math.min(i.h/2-4,8+6*a),h=26+8*a;d={d:`M${eT(s+l)},${eT(o-u)}C${eT(s+h+l)},${eT(o-u)} ${eT(s+h+c)},${eT(o+u)} ${eT(s+c)},${eT(o+u)}`,sx:s,sy:o-u,sdx:-1,sdy:0,ex:s,ey:o+u,edx:-1,edy:0}}else{let t=r.route;for(let r=0;r<t.length;r+=3)t[r]+=er,t[r+1]+=en;d=rU(t,void 0,l,c)}let u="dashed"===i.pattern?' stroke-dasharray="6 4"':"dotted"===i.pattern?' stroke-dasharray="2 4"':"";if(eu+=`<g class="pele-edge${"dotted"===i.pattern?" pele-note-edge":" pele-relation"}" data-id="${eS(i.id)}"><path d="${d.d}"${u}/>`+s_(s,d.sx,d.sy,d.sdx,d.sdy,sA)+s_(o,d.ex,d.ey,d.edx,d.edy,sA)+"</g>",a.width>0){let t=r.labelX+er,s=r.labelY+en;eh+=r2(i.id,a,t,s,"",n.icons)}}let ef="";for(let t of B)ef+=t.math?eI(t.math,t.x+er,t.y+en,' class="pele-cardinality"',n.icons):`<text class="pele-cardinality" x="${eT(t.x+er)}" y="${eT(t.y+en+.35*f)}" text-anchor="middle">${eE(t.text)}</text>`;let ep=au(t.title,g,u,m,ei,ea,(el?`<g class="pele-clusters">${el}</g>`:"")+(eu?`<g class="pele-edges" fill="none" stroke="${sA}" stroke-linecap="round">${eu}</g>`:"")+(ec?`<g class="pele-cluster-titles">${ec}</g>`:"")+(eh?`<g class="pele-edge-labels" font-size="${h}">${eh}</g>`:"")+(ef?`<g class="pele-cardinalities" font-size="${f}" fill="var(--_m)">${ef}</g>`:"")+`<g class="pele-nodes">${ed}</g>`);return{svg:np("class",ep.width,ep.height,u,n,t,ep.content),width:ep.width,height:ep.height,links:es}})(t,r,n,i,a));return id(t.direction)?ic(n,i):i(!1)}},{type:"quadrantChart",parse(t,r,n){let i=new dw;return i.title=n,function(t,r){let{types:n,texts:i,starts:a}=function(t){let r=t.length,n=[],i=[],a=[],s=[],o=0,l=0,c=0,d=0,u=0,h=0,f=0,p=0,g=0,m=0,y=(r,s,o)=>{n.push(r),i.push(t.slice(s,o)),a.push(s),l=o},v=t=>{s.push(o),o=t},b=()=>{s.length>0&&(o=s.pop())},x=n=>{let i=t.indexOf(`
|
|
118
|
+
`,n);return -1===i?r:i},w=r=>{for(;32===t.charCodeAt(r);)r++;return r},$=n=>{for(;n<r&&V(t.charCodeAt(n));)n++;return n},k=n=>{let i=t.charCodeAt(n);if(49===i)return n+1;if(48!==i)return -1;let a=n+1;if(a<r&&!G(t.charCodeAt(a))&&Z(t.charCodeAt(a+1)))for(a+=2;Z(t.charCodeAt(a));)a++;return a};t:for(;l<r;){let n=t.charCodeAt(l),i=t.charCodeAt(l+1);switch(o){case 0:break;case 1:case 2:case 3:y(dM[o],l,x(l)),b();continue;case 4:if(125===n)l++,b();else{let n=t.indexOf("}",l);y(9,l,-1===n?r:n)}continue;case 5:if(34===n)l++,b();else{let n=t.indexOf('"',l);y(19,l,-1===n?r:n)}continue;case 6:if(96===n&&34===i){l+=2,b();continue}if(96!==n&&34!==n){let n=l+1;for(let i=t.charCodeAt(n);n<r&&96!==i&&34!==i;i=t.charCodeAt(++n));y(18,l,n);continue}break t;case 7:if(J(n)){let r=l+1;for(;J(t.charCodeAt(r));)r++;y(20,l,r),b();continue}break t;case 8:{let r=k(l);if(-1!==r){y(22,l,r),v(9);continue}let n=$(l);if(93===t.charCodeAt(n)){l=w(n+1),b();continue}break t}case 9:{let r=$(l);if(44===t.charCodeAt(r)){l=$(r+1),o=10;continue}break t}case 10:{let t=k(l);if(-1!==t){y(23,l,t),b();continue}break t}}if(37===n&&37===i){l=x(l+2);continue}if(10===n||13===n){let r=l+1;for(let n=t.charCodeAt(r);10===n||13===n;n=t.charCodeAt(++r));y(2,l,r);continue}let a=32|n;if(116===a&&d$(t,l,"title")&&!J(t.charCodeAt(l+5))){y(3,l,l+5),v(1);continue}if(97===a&&d$(t,l,"acc")){let r=d$(t,l+3,"descr");if(r||d$(t,l+3,"title")){let n=$(l+8),i=t.charCodeAt(n);if(58===i){y(r?7:5,l,$(n+1)),v(r?3:2);continue}if(123===i&&r){l=$(n+1),v(4);continue}}}let s=l;32===n&&((l<c||l>=d)&&(c=l,d=w(l)),s=d);let M=t.charCodeAt(s),_=32|M,A=0,E=0;if(120===_&&d$(t,s,"x-axis"))A=10,E=s+6;else if(121===_&&d$(t,s,"y-axis"))A=11,E=s+6;else if(45===M){if(s<u||s>=h)for(u=s,h=s;45===t.charCodeAt(h);)h++;h-s>=2&&62===t.charCodeAt(h)&&(A=12,E=h+1)}else if(113===_&&d$(t,s,"quadrant")){let r=t.charCodeAt(s+9);45===t.charCodeAt(s+8)&&r>=49&&r<=52?(A=13+r-49,E=s+10):d$(t,s+8,"chart")&&(A=24,E=s+13)}if(0!==A){y(A,l,w(E));continue}if(99===a&&d$(t,l,"classdef")&&!J(t.charCodeAt(l+8))){y(17,l,l+8);continue}if(34===n){96===i?(l+=2,v(6)):(l++,v(5));continue}if(58===n&&58===i&&58===t.charCodeAt(l+2)){l+=3,v(7);continue}if(58===n||V(n)){let r=l;if(58!==n&&((l<f||l>=p)&&(f=l,p=$(l)),r=p),58===t.charCodeAt(r)&&((r+1<g||r+1>=m)&&(g=r+1,m=$(r+1)),91===t.charCodeAt(m))){y(21,l,$(m+1)),v(8);continue}}if(X(n)){let r=l+1;for(;X(t.charCodeAt(r));)r++;y(25,l,r);continue}if(n>=128){let r=l+1;for(;t.charCodeAt(r)>=128;)r++;y(26,l,r);continue}if(Z(n)){let r=l+1;for(;Z(t.charCodeAt(r));)r++;y(37,l,r);continue}if(0!==d_[n]){y(d_[n],l,l+1);continue}break}return l<r?(n.push(1),i.push(""),a.push(l)):(o<dM.length&&(n.push(dM[o]),i.push(""),a.push(r)),n.push(0),i.push(""),a.push(r)),{types:n,texts:i,starts:a}}(t),s=0,o=r=>{let i=n[s];throw 1===i?d("quadrantChart",t,a[s],"",!0):d("quadrantChart",t,a[s],`Expecting ${r}, got '${dk[i]}'`)},l=t=>(n[s]!==t&&o(`'${dk[t]}'`),i[s++]),c=t=>19===t||18===t||1===dE[t],u=()=>{let t=n[s];c(t)||o("'STR', 'MD_STR', 'ALPHA', 'NUM', 'UNICODE_TEXT', 'PUNCTUATION'");let r=i[s++];for(;1===dE[n[s]]||38===n[s]||36===n[s];)r+=i[s++];return{text:r,type:18===t?"markdown":"text"}},h=()=>{let t=[];for(;;){0===dC[n[s]]&&o("'ALPHA', 'NUM', 'COLON', 'SPACE', 'BRKT', 'MINUS'");let r=i[s++];for(;1===dC[n[s]];)r+=i[s++];if(t.push(r.trim()),29!==n[s])return t;s++}};for(;1===dT[n[s]]||38===n[s];)s++;for(l(24);0!==n[s];){for(;38===n[s];)s++;let t=n[s];switch(t){case 17:{s++,l(38),0===dS[n[s]]&&o("'ALPHA', 'NUM', 'UNICODE_TEXT'");let t=i[s++];for(;1===dS[n[s]];)t+=i[s++];l(38),r.addClass(t,h());break}case 10:case 11:{s++;let i=u(),a;12===n[s]&&(c(n[++s])?a=u():i.text+=" ⟶ "),10===t?(r.setXAxisLeftText(i),a&&r.setXAxisRightText(a)):(r.setYAxisBottomText(i),a&&r.setYAxisTopText(a));break}case 13:case 14:case 15:case 16:s++,r[dI[t-13]](u());break;case 3:s++,r.setDiagramTitle(l(4).trim());break;case 5:s++,r.setAccTitle(l(6).trim());break;case 7:s++,r.setAccDescription(l(8).trim());break;case 9:r.setAccDescription(i[s++].trim());break;default:if(c(t)){let t=u(),a=20===n[s]?i[s++]:"";l(21);let o=l(22),c=l(23);r.addPoint(t,a,o,c,1===dC[n[s]]?h():[])}}0===dT[n[s]]&&o("'NEWLINE', 'SEMI', 'EOF'"),s++}}(t,i),i},render:function(t,r,n){let i=n.fontSize??16,a=dD(r,"titleFontSize",i),s=dD(r,"quadrantLabelFontSize",i),o=dD(r,"xAxisLabelFontSize",Math.round(.875*i)),l=dD(r,"yAxisLabelFontSize",Math.round(.875*i)),c=dD(r,"pointLabelFontSize",Math.round(.75*i)),d=(t,r)=>t===r?"":` font-size="${t}"`,u=n.measurer??e$(n.fontFamily,n.fontFamilyMono),h=Math.round(Math.max(100,dO(r,"chartWidth",500,4e3))),f=Math.round(il(n,h,280)),p=Math.round(Math.max(100,dO(r,"chartHeight",500,4e3))*f/h),g=dO(r,"quadrantPadding",n.padding??8,200),m=dO(r,"xAxisLabelPadding",5,200),y=dO(r,"yAxisLabelPadding",5,200),v=t.points.length>0,b=(t,r,n)=>n7(t?.text,t?.type==="markdown",u,r,Math.max(n,40)),x=n7(t.title,!1,u,a,Math.max(f-2*g,40),1),w=dO(r,"titlePadding",10,200),$=x.height>0?x.height+w:0,k=!!(t.xAxisLeft?.text||t.xAxisRight?.text),M=!!(t.yAxisBottom?.text||t.yAxisTop?.text),_=v||"bottom"===dN(r,"xAxisPosition"),A="right"===dN(r,"yAxisPosition"),E=f-2*g,S=b(t.xAxisLeft,o,t.xAxisRight?E/2-16:E),C=b(t.xAxisRight,o,E/2-16),T=Math.max(S.height,C.height),I=k?T+m:0,N=p-2*g-$-I,O=b(t.yAxisBottom,l,t.yAxisTop?N/2-16:N),D=b(t.yAxisTop,l,N/2-16),R=Math.max(O.height,D.height),L=M?R+y:0,z=g+(A?0:L),P=g+$+(_?0:I),j=Math.max(0,E-L),F=Math.max(0,N),B=Math.max(0,(j-4)/2),W=Math.max(0,(F-4)/2),H=[z+B,P,z+j-B,P+F,z,P+W,z+j,P+F-W],U=(t,r,n,i,a)=>{for(let s=t;s<H.length;s+=4)if(!(H[s]>=H[s+2]||H[s+1]>=H[s+3])&&r<H[s+2]&&i>H[s]&&n<H[s+3]&&a>H[s+1])return!1;return!0},q=dO(r,"quadrantTextTopPadding",5,200),V="";for(let r=0;r<4;r++){let n=0===r||3===r?z+j-B:z,a=r<2?P:P+F-W,o=b(t.quadrants[r],s,B-16),l=n+B/2,c=v?a+q+o.height/2:a+W/2;H.push(l-o.width/2,c-o.height/2,l+o.width/2,c+o.height/2),V+=`<g class="pele-quadrant" data-id="${r+1}"><rect x="${eT(n)}" y="${eT(a)}" width="${eT(B)}" height="${eT(W)}"${r5}/>`+eI(o,l,c,` class="pele-label"${d(s,i)} fill="var(--_fg)" stroke="none"`)+"</g>"}let Y="";if(k){let t=_?P+F+m+T/2:P-m-T/2;Y+=eI(S,C.height>0?z+j/4:z+S.width/2,t,"")+eI(C,z+3*j/4,t,"")}if(M){let t=A?z+j+y+R/2:z-y-R/2,r=(r,n)=>r.height>0?`<g transform="translate(${eT(t)},${eT(n)}) rotate(-90)"${d(l,o)}>${eI(r,0,0,"")}</g>`:"";Y+=r(O,D.height>0?P+3*F/4:P+F-O.width/2)+r(D,P+F/4)}let G=dO(r,"pointRadius",5,200),Z=dO(r,"pointTextPadding",5,200),X=nu(0),K=[],J=[];for(let r of t.points){if(!(r.x>=0&&r.x<=1&&r.y>=0&&r.y<=1))continue;let n=t.classes.get(r.className),i=Math.min(r.radius??n?.radius??G,2e3),a=r.color??n?.color,s=r.strokeColor??n?.strokeColor,o=r.strokeWidth??n?.strokeWidth,l=[];a&&l.push("fill:"+dR(a)),o&&(s&&l.push("stroke:"+dR(s)),l.push("stroke-width:"+o));let d=z+r.x*j,u=P+(1-r.y)*F;K.push({cx:d,cy:u,reach:i+(o?Math.min(parseInt(o),400)/2:0),text:b(r.text,c,j)}),J.push(`<circle class="pele-point${nc(r.className)}" data-id="${eS(r.text.text)}" cx="${eT(d)}" cy="${eT(u)}" r="${eT(i)}"${o&&!s?` stroke="${X}"`:""}${no(l).shape}/>`)}let Q=K.length<=300;if(Q)for(let{cx:t,cy:r,reach:n}of K)H.push(t-n,r-n,t+n,r+n);let ee="";for(let{cx:t,cy:r,reach:n,text:i}of K){let a=i.width/2,s=.6*i.size+(i.height-i.lineHeight)/2,o=n+Z,l=Math.min(o,Math.max(0,(B-i.width)/2)),c=8+4*(t<z+j/2?r<P+F/2?1:2:r<P+F/2?0:3),d=Math.max(r+o,H[c+3]+Z)+s,u=[t,r+o+s,t,r-o-s,t+o+a,r,t-o-a,r,t,d],h=t,f=u[1],p=!1;for(let t=0;t<20;t+=2){let r=t%10,n=8===r?l:0,o=(r<4||8===r)&&i.width<j?Math.min(Math.max(u[r],z+a+n),z+j-a-n):u[r],c=u[r+1];if(o-a<z||o+a>z+j||c-s<P||c+s>P+F)continue;let d=!Q||U(t<10?0:8,o-a,c-s,o+a,c+s);if((!p||d)&&(h=o,f=c,p=!0),d)break}Q&&H.push(h-a,f-s,h+a,f+s),ee+=eI(i,h,f,' class="pele-label"')}let et=eI(x,f/2,w/2+x.height/2,` class="pele-title"${d(a,i)} font-weight="var(--_tw)"`)+`<g class="pele-quadrants" fill="var(--_s)" stroke="var(--_b)">${V}</g>`+(Y?`<g class="pele-axis-labels" font-size="${o}" fill="var(--_m)">${Y}</g>`:"")+(K.length>0?`<g class="pele-points" fill="${X}">${J.reverse().join("")}</g><g class="pele-point-labels" font-size="${c}">${ee}</g>`:"");return{svg:np("quadrantChart",f,p,i,n,t,et),width:f,height:p,links:[]}}},{type:"xychart",section:"xyChart",parse(t,r,n){let i=new gp;return i.title=n,function(t,r){let{types:n,texts:i,starts:a}=function(t){let r=t.length,n=[],i=[],a=[],s=[],o=0,l=0,c=(r,s,o)=>{n.push(r),i.push(t.slice(s,o)),a.push(s),l=o},d=t=>{s.push(o),o=t},u=()=>{s.length>0&&(o=s.pop())},h=n=>{let i=t.indexOf(`
|
|
119
|
+
`,n);return -1===i?r:i},f=n=>{for(;n<r&&V(t.charCodeAt(n));)n++;return n},p=r=>{for(;Z(t.charCodeAt(r));)r++;return r},g=r=>d$(t,l,r)&&!J(t.charCodeAt(l+r.length));for(;l<r;){let n=t.charCodeAt(l);if(5===o){if(34===n)l++,u();else{let n=t.indexOf('"',l);c(19,l,-1===n?r:n)}continue}if(6===o||7===o){c(gm[o],l,h(l)),u();continue}if(8===o){if(125===n)l++,u();else{let n=t.indexOf("}",l);c(8,l,-1===n?r:n)}continue}let i=t.charCodeAt(l+1);if(37===n&&37===i){l=h(l+2);continue}if(10===n||13===n){if((1===o||3===o)&&(10===n||10===i)){c(2,l,10===n?l+1:l+2),u();continue}let r=l+1;for(let n=t.charCodeAt(r);10===n||13===n;n=t.charCodeAt(++r));c(2,l,r);continue}switch(32|n){case 116:if(g("title")){c(3,l,l+5);continue}break;case 97:if(d$(t,l,"acc")){let r=d$(t,l+3,"descr");if(r||d$(t,l+3,"title")){let n=f(l+8),i=t.charCodeAt(n);if(58===i){c(r?6:4,l,f(n+1)),d(r?7:6);continue}if(123===i&&r){l=f(n+1),d(8);continue}}}break;case 120:if(g("xychart-beta")){c(9,l,l+12);continue}if(g("xychart")){c(9,l,l+7);continue}if(g("x-axis")){c(11,l,l+6),d(1);continue}break;case 121:if(g("y-axis")){c(12,l,l+6),d(1);continue}break;case 118:if(d$(t,l,"vertical")){c(10,l,l+8);continue}break;case 104:if(d$(t,l,"horizontal")){c(10,l,l+10);continue}break;case 108:if(g("line")){c(14,l,l+4),d(3);continue}break;case 98:if(g("bar")){c(15,l,l+3),d(3);continue}}if(91===n){1===o?d(2):3===o&&d(4),c(17,l,l+1);continue}if(93===n){(4===o||2===o)&&u(),c(18,l,l+1);continue}if(1===o&&45===n&&45===i&&62===t.charCodeAt(l+2)){c(13,l,l+3);continue}if(1===o||4===o){let r=43===n||45===n?l+1:l,i=t.charCodeAt(r),a=-1;if(Z(i)?(a=p(r+1),46===t.charCodeAt(a)&&Z(t.charCodeAt(a+1))&&(a=p(a+2))):46===i&&Z(t.charCodeAt(r+1))&&(a=p(r+2)),-1!==a){c(16,l,a);continue}}if(96===n&&d$(t,l,gy)){l+=gy.length,u();continue}if(34===n){l++,d(5);continue}if(X(n)){let r=l+1;for(;X(t.charCodeAt(r));)r++;c(20,l,r);continue}if(Z(n)){c(31,l,p(l+1));continue}if(V(n)){l=f(l+1);continue}if(n<128&&0!==gv[n]){c(gv[n],l,l+1);continue}break}return l<r?(n.push(1),i.push(""),a.push(l)):(n.push(gm[o]),i.push(""),a.push(r),n.push(0),i.push(""),a.push(r)),{types:n,texts:i,starts:a}}(t),s=0,o=r=>{let i=n[s];throw 1===i?d("xychart",t,a[s],"",!0):d("xychart",t,a[s],`Expecting ${r}, got '${gg[i]}'`)},l=t=>(n[s]!==t&&o(`'${gg[t]}'`),i[s++]),c=t=>19===t||1===gx[t],u=()=>{c(n[s])||o("'STR', 'ALPHA', 'NUM'");let t=i[s++];if(19!==n[s-1])for(;1===gx[n[s]];)t+=i[s++];return{text:t,type:"text"}},h=()=>{let t=Number(l(16));return l(13),[t,Number(l(16))]},f=()=>{let t=[];for(l(17);;){let r=Number(l(16));if(t.push({value:r,label:19===n[s]?i[s++]:""}),23!==n[s])break;s++}return l(18),t};for(;;)if(1===gw[n[s]])s++;else{if(9!==n[s])break;10===n[++s]&&r.setOrientation(i[s++])}for(;0!==n[s];){let t=n[s++];switch(t){case 3:r.setDiagramTitle(u().text.trim());break;case 11:case 12:{let i=c(n[s])?u():void 0;if(11===t&&17===n[s]){let t=[];do s++,t.push(u());while(23===n[s]);l(18),r.setXAxisBand(t)}else if(16===n[s]||void 0===i){let[n,i]=h();11===t?r.setXAxisRangeData(n,i):r.setYAxisRangeData(n,i)}11===t?r.setXAxisTitle(i??{type:"text",text:""}):r.setYAxisTitle(i??{type:"text",text:""});break}case 14:case 15:{let i=17===n[s]?{text:"",type:"text"}:u(),a=f();14===t?r.setLineData(i,a):r.setBarData(i,a);break}case 4:r.setAccTitle(l(5).trim());break;case 6:r.setAccDescription(l(7).trim());break;case 8:r.setAccDescription(i[s-1].trim());break;default:s--,o("'title', 'X_AXIS', 'Y_AXIS', 'LINE', 'BAR', 'acc_title', 'acc_descr', 'acc_descr_multiline_value'")}for(;1===gw[n[s]];)s++}}(t,i),i},render:function(t,r,n){if(0===t.plots.length)throw new a("No Plot to render, please provide a plot with some data","semantic",{type:"xychart"});let i=gA(r.xyChart),s=n.fontSize??16,o=Math.round(.875*s),l=Math.round(.75*s),c=n.measurer??e$(n.fontFamily,n.fontFamilyMono),d=n.padding??8,u=gS(i.width,700),h=il(n,u,240),f=Math.round(gS(i.height,500)*Math.max(.6,h/u)),p=(t.orientation??i.chartOrientation)==="horizontal",g=gE(i,"showDataLabel",!1),m=t.xAxis,y=t.plots,v=(t,r,n)=>n7(t,!1,c,r,n),b=v("0",o,4e3).height,x=v("0",l,4e3).height,w=n7(gE(i,"showTitle")?t.title:void 0,!1,c,s,h-2*d,1),$=w.height>0?w.height+12:0,k=[],M=0;gE(i,"showLegend")&&y.forEach((t,r)=>{if(""===t.title)return;let n=v(t.title,o,.3*h);k.push({index:r,label:n}),M=Math.max(M,n.width+12+8)});let _=k.length>0?M+24:0,A=y.filter(t=>"bar"===t.type).length,E=gC(t.yAxis.min)??1/0,S=gC(t.yAxis.max)??-1/0,C=t.hasSetYAxis&&isFinite(E)&&isFinite(S)&&E!==S;if(!C){for(let t of(E=1/0,S=-1/0,y))for(let[,r]of t.data){let t=gC(r);void 0!==t&&(t<E&&(E=t),t>S&&(S=t))}E>S&&(E=S=0),A>0&&(E=Math.min(E,0),S=Math.max(S,0)),E===S&&(0===E?S=1:(E-=Math.abs(E)/2,S+=Math.abs(S)/2))}let T=(t,r)=>{let n=g$(Math.abs(S-E),Math.max(2,Math.min(10,Math.floor(t/r))));return C||(E=gM(n,Math.floor(gk(n,E)+1e-9)),S=gM(n,Math.ceil(gk(n,S)-1e-9))),g_(Math.min(E,S),Math.max(E,S),n).map(t=>({at:(t-E)/(S-E),label:v(String(t),o,4e3)}))},I=1;if("band"===m.type)I=Math.max(m.categories.length,1);else for(let t of y)I=Math.max(I,t.data.length);let N=1/I,O="band"===m.type||A>0?N/2:0,D=gC("linear"===m.type?m.min:void 0),R=gC("linear"===m.type?m.max:void 0),L=void 0!==D&&void 0!==R&&D!==R,z=(t,r)=>"band"===m.type?(t+.5)*N:O+(r>1?t/(r-1):.5*!L)*(1-2*O),P=gA(i.xAxis),j=gA(i.yAxis),F=p?P:j,B=p?j:P,W=v(gE(F,"showTitle")?p?m.title:t.yAxis.title:void 0,o,.8*f),H=v(gE(B,"showTitle")?p?t.yAxis.title:m.title:void 0,o,.8*h),U=4*!!gE(F,"showTick"),q=4*!!gE(B,"showTick"),V=gE(F,"showLabel"),Y=gE(B,"showLabel"),G=p?.3*h:Math.max(48,(h-2*d-64-_)*N-8),Z="band"===m.type&&gE(P,"showLabel")?m.categories.map(t=>v(t,o,G)):[],X=0,K=0;for(let t of Z)X=Math.max(X,t.width),K=Math.max(K,t.height);let J=t=>{let r=[];if("band"===m.type){let n=Math.max(1,Math.ceil((0===Z.length?8:p?K:X+12)/(t*N)));for(let t=0;t<m.categories.length;t+=n)r.push({at:(t+.5)*N,label:Z[t]??v(void 0,o,0)})}else if(L){let n=g$(Math.abs(R-D),Math.max(2,Math.min(10,Math.floor(t/(p?32:80)))));for(let t of g_(Math.min(D,R),Math.max(D,R),n))r.push({at:O+(t-D)/(R-D)*(1-2*O),label:v(String(t),o,4e3)})}else void 0!==D&&r.push({at:.5,label:v(String(D),o,4e3)});return r},Q=0,ee=0;for(let t of y){for(let r of t.pointLabels??[])Q=Math.max(Q,c.width(r,l,0));if(g&&p&&"bar"===t.type)for(let[,r]of t.data)ee=Math.max(ee,c.width(String(gC(r)??""),l,0))}let et=Y?p||"band"!==m.type?b:K:0,er=q+(et>0?et+4:0)+(H.height>0?H.height+4:0),en=d+$+(p?0:Q>0||g?x+4:V?b/2:0),ei=Math.max(1,f-d-er-en),ea=en+ei,es=p?J(ei):T(ei,56),eo=V?function(t){let r=0;for(let n of t)r=Math.max(r,n.label.width);return r}(es):0,el=d+(W.height>0?W.height+6:0)+(eo>0?eo+6:0)+U,ec=Math.max(Q>0?Q+12:0,ee>0?ee+8:0),ed=p?Math.min(.25*h,ec):0,eu=Math.max(1,h-d-el-_-ed),eh=p?T(eu,80):J(eu);if(Y&&_+ed===0){let t=0;for(let r of eh)t=Math.max(t,r.at*eu+r.label.width/2-eu);eu=Math.max(1,eu-t)}let ef=el+eu,ep=(t,r)=>p?el+r*eu:el+t*eu,eg=(t,r)=>p?en+t*ei:ea-r*ei,em=t=>(t-E)/(S-E),ey=t=>Math.min(Math.max(t,0),1),ev=t=>p?`M${eT(ep(0,t))},${eT(en)}V${eT(ea)}`:`M${eT(el)},${eT(eg(0,t))}H${eT(ef)}`,eb="";for(let t of p?eh:es)eb+=ev(t.at);let ex="",ew="";for(let t of(gE(F,"showAxisLine")&&(ex+=`M${eT(el)},${eT(en)}V${eT(ea)}`),gE(B,"showAxisLine")&&(ex+=`M${eT(el)},${eT(ea)}H${eT(ef)}`),es)){let r=p?en+t.at*ei:ea-t.at*ei;U&&(ex+=`M${eT(el)},${eT(r)}h${-U}`),V&&(ew+=gT(t.label,el-U-6,r,"end"))}for(let t of eh){let r=el+t.at*eu;q&&(ex+=`M${eT(r)},${eT(ea)}v${q}`),Y&&(ew+=gT(t.label,r,ea+q+4+t.label.height/2,"middle"))}let ek=(p?ei:eu)*N,eM=.7*ek/Math.max(A,1),e_=A>1?Math.min(2,.2*eM):0,eA=ey(em(0));A>0&&eA>0&&eA<1&&(ex+=ev(eA));let eE="",eC="",eN="",eO="",eD=0;y.forEach((t,r)=>{let n=nu(r),i=t.title?` data-id="${eS(t.title)}"`:"",a="band"===m.type?Math.min(t.data.length,I):t.data.length;if("bar"===t.type){let r=(eD++-(A-1)/2)*eM-(eM-e_)/2,s="";for(let n=0;n<a;n++){let i=gC(t.data[n][1]);if(void 0===i)continue;let o=z(n,a),d=ey(em(i)),u=Math.min(eA,d),h=Math.max(eA,d),f=p?ep(o,u):ep(o,0)+r,m=p?eg(o,0)+r:eg(o,h),y=p?(h-u)*eu:eM-e_,v=p?eM-e_:(h-u)*ei;if(s+=`<rect x="${eT(f)}" y="${eT(m)}" width="${eT(y)}" height="${eT(v)}"/>`,!g)continue;let b=String(i),w=c.width(b,l,0),$=d>=eA?1:-1,k=f+y/2,M=m+v/2,_="middle";if(p){if(v<l)continue;k=($>0?f+y:f)+6*$,_=$>0?"start":"end"}else{if(w+2>ek/A)continue;M=($>0?m:m+v)-$*(x/2+2)}eN+=`<text x="${eT(k)}" y="${eT(M+.35*l)}" text-anchor="${_}">${b}</text>`}eE+=`<g class="pele-series pele-bars"${i} fill="${n}">${s}</g>`;return}let s="",o="",d=!1,u=0,h=NaN;for(let r=0;r<a;r++){let n=gC(t.data[r][1]);if(void 0===n){h=NaN;continue}let i=z(r,a),c=em(n),f=c>=0&&c<=1;if(h!=h)f&&(s+=`M${eT(ep(i,c))},${eT(eg(i,c))}`),d=f;else{let t=c-h,r=0,n=1;if(0!==t){let i=-h/t,a=(1-h)/t;r=Math.max(r,Math.min(i,a)),n=Math.min(n,Math.max(i,a))}else f||(r=2);if(r<=n){let a=u+(i-u)*r,o=h+t*r,l=u+(i-u)*n,c=h+t*n;(!d||r>0)&&(s+=`M${eT(ep(a,o))},${eT(eg(a,o))}`),s+=`L${eT(ep(l,c))},${eT(eg(l,c))}`}d=f}if(u=i,h=c,!f)continue;let g=ep(i,c),m=eg(i,c);ek>=12&&(o+=`<circle cx="${eT(g)}" cy="${eT(m)}" r="3"/>`);let y=v(t.pointLabels?.[r],l,4e3);if(y.height>0){let t=y.width/2;eO+=p?gT(y,g+10,m,"start"):gT(y,Math.max(Math.min(g,ef-t),el+t),m-6-y.height/2,"middle")}}eC+=`<g class="pele-series pele-line"${i} fill="${n}">`+(s?`<path d="${s}" fill="none" stroke="${n}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>`:"")+o+"</g>"});let eR="";W.height>0&&(eR+=`<g transform="translate(${eT(d+W.height/2)},${eT(en+ei/2)}) rotate(-90)">${eI(W,0,0,"")}</g>`),eR+=eI(H,el+eu/2,f-d-H.height/2,"");let eL="",ez=0;for(let t of k)ez+=Math.max(26,t.label.height+6);let eP=en+Math.max(0,(ei-ez)/2),ej=ef+ed+24;for(let{index:t,label:r}of k){let n=Math.max(26,r.height+6);if(eP+n>f)break;let i=eP+n/2,a=nu(t);eL+=`<g class="pele-legend-item" data-id="${eS(y[t].title)}">`+("bar"===y[t].type?`<rect x="${eT(ej)}" y="${eT(i-6)}" width="12" height="12" rx="2" fill="${a}"/>`:`<path d="M${eT(ej)},${eT(i)}h12" stroke="${a}" stroke-width="2" stroke-linecap="round"/>`)+eI(r,ej+12+8+r.width/2,i,"")+"</g>",eP+=n}let eF=eI(w,h/2,d+w.height/2,' class="pele-title" font-weight="var(--_tw)"')+(eb?`<path class="pele-grid" d="${eb}" stroke="var(--_a)"/>`:"")+`<g class="pele-plot">${eE}${eC}</g>`+(ex?`<path class="pele-axis" d="${ex}" fill="none" stroke="var(--_b)"/>`:"")+(ew?`<g class="pele-axis-labels" font-size="${o}" fill="var(--_m)">${ew}</g>`:"")+(eR?`<g class="pele-axis-titles" font-size="${o}">${eR}</g>`:"")+(eN?`<g class="pele-data-labels" font-size="${l}">${eN}</g>`:"")+(eO?`<g class="pele-point-labels" font-size="${l}">${eO}</g>`:"")+(eL?`<g class="pele-legend" font-size="${o}">${eL}</g>`:"");return{svg:np("xychart",h,f,s,n,t,eF),width:h,height:f,links:[]}}},{type:"state",math:!0,parse(t,r,n){let i=new hF;return n&&(i.title=n),function(t,r){let{types:n,texts:i,starts:s,error:o}=function(t){let r=t.length,n=[],i=[],a=[],s=[],o=0,l=0,c,d=hY(hW,t),u=hY(hH,t),h=hY(hU,t),f=hY(hq,t),p=hY(hV,t),g=-1,m=-1,y=[-1,-1,-1,-1],v=[0,0,0,0],b=-1,x=-1,w=[-1,-1,-1,-1,-1,-1],$=(r,s,o)=>{n.push(r),i.push(t.slice(s,o)),a.push(s),l=o},k=(t,r,s,o)=>{n.push(t),i.push(r),a.push(s),l=o},M=t=>{s.push(o),o=t},_=()=>{s.length>0&&(o=s.pop())},A=(r,n)=>{for(let i=0;i<r.length;i++){let a=r.charCodeAt(i),s=t.charCodeAt(n+i);if(s!==a&&!(a>=97&&a<=122&&s===a-32))return!1}return!0},E=n=>{let i=n;for(;i<r&&V(t.charCodeAt(i));)i++;return i},S=n=>{let i=n;for(;i<r&&J(t.charCodeAt(i));)i++;return i},C=n=>{let i=t.indexOf(`
|
|
120
|
+
`,n);return -1===i?r:i},T=t=>{let n=h(t);return -1===n?r:n},I=t=>{if(t<g||t>m){let n=d(t),i=-1===n?r:T(t);g=t,m=i,y[0]=y[1]=y[2]=y[3]=-1;for(let t=n;-1!==t&&t<i;t=d(t+1)){let r=E(t+9);if(r===t+9)continue;let n=A("tb",r)?0:A("bt",r)?1:A("rl",r)?2:A("lr",r)?3:-1;-1!==n&&(y[n]=t,v[n]=r+2)}}for(let r=0;r<4;r++)if(y[r]>=t)return r;return -1},N=n=>{if(n<b||n>x){let i=u(n),a=-1===i?r:T(n);b=n,x=a,w.fill(-1);for(let r=i;-1!==r&&r<a;r=u(r+1)){let n=32|t.charCodeAt(r+2);w[3*(60!==t.charCodeAt(r))+(102===n?0:106===n?1:2)]=r}}for(let t=0;t<6;t++)if(w[t]>=n)return t;return -1},O=(t,r)=>{let n=f(t);return -1===n||n+2>r?($(14,t,r),!0):n===t?(l=r,!1):($(14,t,n),!0)},D=t=>(n.push(t),i.push(""),a.push(l),{types:n,texts:i,starts:a,error:c});for(;;){if(l>=r){switch(o){case 0:$(2,r,r);break;case 6:$(22,r,r);break;case 7:$(24,r,r);break;case 8:$(25,r,r);break;case 10:$(32,r,r);break;case 12:$(39,r,r);break;case 14:$(36,r,r);break;case 3:$(12,r,r);break;case 18:$(20,r,r);break;case 4:case 19:$(14,r,r)}return D(0)}let n=t.charCodeAt(l);switch(o){case 0:case 1:{let i=0===o,a=32|n;if(i){if(99===a&&A("click",l)&&!J(t.charCodeAt(l+5))){$(26,l,l+5);continue}if(104===a&&A("href",l)&&!J(t.charCodeAt(l+4))){$(28,l,l+4);continue}if(34===n){let r=t.indexOf('"',l+1);if(-1!==r){$(27,l,r+1);continue}}if(100===a&&A("default",l)&&!J(t.charCodeAt(l+7))){$(33,l,l+7);continue}let r=I(l);if(-1!==r){$(40+r,l,C(v[r]));continue}if(10===n){let r=l+1;for(;10===t.charCodeAt(r);)r++;$(2,l,r);continue}if(V(n)){l=E(l);continue}}else if(10!==n&&V(n)){let n=l+1;for(;n<r&&10!==t.charCodeAt(n)&&V(t.charCodeAt(n));)n++;l=n;continue}if(35===n||37===n&&37===t.charCodeAt(l+1)&&123!==t.charCodeAt(l+2)){l=C(l);continue}if(115===a){if(i&&A("scale",l)){let t=E(l+5);if(t>l+5){$(7,l,t),M(5);continue}}if(A("style",l)){let t=E(l+5);if(t>l+5){$(34,l,t),M(13);continue}}if(A("state",l)){let t=E(l+5);if(t>l+5){l=t,M(2);continue}if(i&&A("diagram",l+5)){let r=A("-v2",l+12)?l+15:l+12;if((t=E(r))>r){$(3,l,t);continue}}}}else if(99===a){if(A("class",l)){let t=A("def",l+5),r=t?l+8:l+5,n=E(r);if(n>r){$(t?29:37,l,n),M(t?9:11);continue}}}else if(97===a&&i&&(A("acctitle",l)||A("accdescr",l))){let r=(32|t.charCodeAt(l+3))==116,n=E(l+8),i=t.charCodeAt(n);if(58===i){$(r?21:23,l,E(n+1)),M(r?6:7);continue}if(123===i&&!r){l=E(n+1),M(8);continue}}if(i){if(123===n){$(10,l,l+1),M(1);continue}}else{let t=I(l);if(-1!==t){$(40+t,l,C(v[t]));continue}if(125===n){$(11,l,l+1),_();continue}if(10===n){l++;continue}}if(110===a&&A("note",l)){let t=E(l+4);if(t>l+4){$(19,l,t),M(15);continue}}if(i&&104===a&&A("hide empty description",l)&&!J(t.charCodeAt(l+22))){$(6,l,l+22);continue}if(91===n&&42===t.charCodeAt(l+1)&&93===t.charCodeAt(l+2)){$(44,l,l+3);continue}let s=l;for(;s<r;){let r=t.charCodeAt(s);if(58===r||45===r||123===r||V(r))break;s++}if(s>l){O(l,s);continue}if(58===n){for(s=l+1;s<r;){let n=t.charCodeAt(s);if(10===n||59===n)break;if(58===n){let n=t.charCodeAt(s+1);if(s+1>=r||58===n||10===n||59===n)break;s++}s++}if(s>l+1){k(4,t.slice(l,s).trim(),l,s);continue}if(58===t.charCodeAt(l+1)&&58===t.charCodeAt(l+2)){$(45,l,l+3);continue}}else if(45===n&&45===t.charCodeAt(l+1)){if(62===t.charCodeAt(l+2)){$(5,l,l+3);continue}if(!i){$(18,l,l+2);continue}}if(!i)return D(1);$(48,l,l+1);continue}case 2:{if(10!==n&&V(n)){let n=l+1;for(;n<r&&10!==t.charCodeAt(n)&&V(t.charCodeAt(n));)n++;l=n;continue}if(35===n||37===n&&37===t.charCodeAt(l+1)&&123!==t.charCodeAt(l+2)){l=C(l);continue}let i=N(l);if(-1!==i){let r=w[i],n=2===i||5===i;k(n?17:i%3==0?15:16,t.slice(l,r).trim(),l,r+(n?10:8)),_();continue}if(34===n){l++,M(3);continue}let a=10===n?E(l):l;if(A("as",a)){let t=E(a+2);if(t>a+2){$(13,l,t),M(4);continue}}if(10===n){l++,_();continue}if(123===n){$(10,l,l+1),_(),M(1);continue}if(J(n)){let r=S(l),n=E(r);if(n>r&&J(t.charCodeAt(n))){let r=p(n+1);if(-1!==r&&r<T(n))return c=`Error: State name must be a single word. Found: "${t.slice(l,r+1).trim()}"`,D(1)}}let s=l+1;for(;s<r;){let r=t.charCodeAt(s);if(123===r||V(r))break;s++}$(9,l,s);continue}case 3:{if(34===n){l++,_();continue}let i=t.indexOf('"',l);$(12,l,-1===i?r:i);continue}case 4:{let n=l;for(;n<r;){let r=t.charCodeAt(n);if(10===r||123===r)break;n++}O(l,n)&&_();continue}case 5:{if(n>=48&&n<=57){let n=l+1;for(;n<r&&t.charCodeAt(n)>=48&&57>=t.charCodeAt(n);)n++;$(8,l,n);continue}let i=E(l);if(i>l&&A("width",i)&&!J(t.charCodeAt(i+5))){l=i+5,_();continue}return D(1)}case 6:$(22,l,C(l)),_();continue;case 7:$(24,l,C(l)),_();continue;case 8:{if(125===n){l++,_();continue}let i=t.indexOf("}",l);$(25,l,-1===i?r:i);continue}case 9:{let t=A("default",l)&&E(l+7)>l+7,r=t?l+7:S(l),n=E(r);if(r===l||n===r)return D(1);$(t?31:30,l,n),_(),M(10);continue}case 10:$(32,l,C(l)),_();continue;case 11:{let r=S(l);if(r===l)return D(1);for(;44===t.charCodeAt(r);){let t=E(r+1),n=S(t);if(n===t)break;r=n}$(38,l,r),_(),M(12);continue}case 12:$(39,l,C(l)),_();continue;case 13:{let n=l;for(;n<r&&(J(t.charCodeAt(n))||44===t.charCodeAt(n));)n++;let i=E(n);if(n===l||i===n)return D(1);$(35,l,i),_(),M(14);continue}case 14:$(36,l,C(l)),_();continue;case 15:if(A("left of",l)&&!J(t.charCodeAt(l+7))){$(46,l,l+7),_(),M(16);continue}if(A("right of",l)&&!J(t.charCodeAt(l+8))){$(47,l,l+8),_(),M(16);continue}if(34===n){l++,_(),M(18);continue}return D(1);case 16:{let n=E(l),i=n;for(;i<r;){let r=t.charCodeAt(i);if(58===r||45===r||V(r))break;i++}if(i===n)return D(1);O(l,i)&&(_(),M(17));continue}case 17:{let n=E(l);if(58===t.charCodeAt(n)){let i=n+1;for(;i<r;){let r=t.charCodeAt(i);if(58===r||10===r||59===r)break;i++}if(i>n+1){k(20,t.slice(l+2,i).trim(),l,i),_();continue}}let i=t.indexOf(`
|
|
121
|
+
`,l),a=-1;for(;-1!==i&&!(A("end note",a=E(i))&&!J(t.charCodeAt(a+8)));)i=t.indexOf(`
|
|
122
|
+
`,a);if(-1===i)return D(1);k(20,t.slice(l,a).trim(),l,a+8),_();continue}case 18:{let i=E(l);if(A("as",i)){$(13,l,E(i+2)),_(),M(19);continue}if(34===n){l++;continue}let a=t.indexOf('"',l);$(20,l,-1===a?r:a);continue}case 19:O(l,C(l))&&_();continue}}}(t),l=0,u=r=>{let i=n[l];throw 1===i?void 0!==o?new a(o,"syntax",{type:"state",...c(t,s[l])}):d("state",t,s[l],"",!0):d("state",t,s[l],`Expecting ${r}, got '${hB[i]}'`)},h=t=>(n[l]!==t&&u(`'${hB[t]}'`),i[l++]),f=()=>{let t=n[l];14!==t&&44!==t&&u("'ID', 'EDGE_STATE'");let r=i[l++].trim();return 45!==n[l]?{stmt:"state",id:r,type:"default",description:""}:(l++,{stmt:"state",id:r,classes:[h(14).trim()],type:"default",description:""})};for(;2===n[l];)l++;3!==n[l]&&u("'NL', 'SD'"),l++;let p=[],g=[],m=t=>{"nl"!==t&&p.push(t)},y=(t,r)=>{l++;let n=[];p.push({stmt:"state",id:t,type:"default",description:r,doc:n}),g.push(p),p=n};for(;;){let t=n[l];switch(t){case 2:l++;break;case 14:case 44:{let t=f();if(4===n[l])t.description=r.trimColon(i[l++]),m(t);else if(5===n[l]){l++;let a=f();m(4===n[l]?{stmt:"relation",state1:t,state2:a,description:r.trimColon(i[l++])}:{stmt:"relation",state1:t,state2:a})}else m(t);break}case 6:m(i[l++]);break;case 7:l++,h(8),m(i[l-2]);break;case 9:10===n[l+1]?y(i[l++],""):m(i[l++]);break;case 12:{let t=i[l++];h(13);let r=h(14);if(10===n[l])y(r,t);else if(r.includes(":")){let n=r.split(":");m({stmt:"state",id:n[0],type:"default",description:[t.trim(),n[1]]})}else m({stmt:"state",id:r,type:"default",description:t.trim()});break}case 15:m({stmt:"state",id:i[l++],type:"fork"});break;case 16:m({stmt:"state",id:i[l++],type:"join"});break;case 17:m({stmt:"state",id:i[l++],type:"choice"});break;case 18:l++,m({stmt:"state",id:r.getDividerId(),type:"divider"});break;case 19:{let t=i[l++];if(46===n[l]||47===n[l]){let t=i[l++].trim();m({stmt:"state",id:h(14).trim(),note:{position:t,text:h(20).trim()}})}else 20!==n[l]&&u("'NOTE_TEXT', 'left_of', 'right_of'"),l++,h(13),h(14),m(t);break}case 40:case 41:case 42:case 43:{let n=hG[t-40];l++,r.setDirection(n),m({stmt:"dir",value:n});break}case 21:{l++;let t=h(22).trim();r.setAccTitle(t),m(t);break}case 23:{l++;let t=h(24).trim();r.setAccDescription(t),m(t);break}case 25:{let t=i[l++].trim();r.setAccDescription(t),m(t);break}case 26:{l++;let t=f(),r,a="";28===n[l]?(l++,r=h(27)):(27!==n[l]&&u("'STRING', 'HREF'"),r=i[l++],a=h(27)),h(2),m({stmt:"click",id:t,url:r,tooltip:a});break}case 29:l++,m({stmt:"classDef",id:h(30).trim(),classes:h(32).trim()});break;case 34:l++,m({stmt:"style",id:h(35).trim(),styleClass:h(36).trim()});break;case 37:l++,m({stmt:"applyClass",id:h(38).trim(),styleClass:h(39).trim()});break;case 11:0===g.length&&u(`'$end', ${hZ}`),l++,p=g.pop();break;case 0:return g.length>0&&u(`'STRUCT_STOP', ${hZ}`),r.setRootDoc(p),p;default:u(g.length>0?`'STRUCT_STOP', ${hZ}`:`'$end', ${hZ}`)}}}(t,i),i},render:function(t,r,n){return id(t.direction)?ic(n,i=>h6(t,r,n,i)):h6(t,r,n,!1)}},{type:"gantt",parse(t,r,n){let i=new lF;n&&(i.title=n);let a=r.gantt?.displayMode;return"string"==typeof a&&(i.displayMode=a),function(t,r){let{types:n,texts:i,starts:a}=function(t){let r=t.length,n=[],i=[],a=[],s=0,o=0,l=(r,s,l)=>{n.push(r),i.push(t.slice(s,l)),a.push(s),o=l},c=r=>(r.lastIndex=o,r.test(t)?r.lastIndex:-1),d=(n,i)=>{let a=t.indexOf(n,i);return -1===a?r:a},u=r=>{let n;switch(32|r){case 97:if((n=c(lW))>=0)return s=1,l(3,o,n),!0;if((n=c(lH))>=0)return s=2,l(5,o,n),!0;if((n=c(lU))>=0)return s=3,o=n,!0;break;case 104:if((n=c(lq))>=0)return s=4,o=n,!0;break;case 99:if((n=c(lV))>=0)return s=5,o=n,!0;if((n=c(lY))>=0)return s=7,o=n,!0;break;case 116:if((n=c(lQ))>=0)return o=n,!0;break;case 119:{lZ.lastIndex=o;let r=lZ.exec(t);if(r)return l(22+lX.indexOf(r[1].toLowerCase()),o,lZ.lastIndex),!0;if(lK.lastIndex=o,r=lK.exec(t))return l(void 0!==r[1]?29:30,o,lK.lastIndex),!0}}let i=l0.get(32|r);if(i){for(let[t,r]of i)if((n=c(t))>=0)return l(r,o,n),!0}return!1};for(;;){if(o>=r){let t=38;switch(s){case 1:t=4;break;case 2:t=6;break;case 3:t=7;break;case 4:t=9;break;case 5:t=10;break;case 6:t=11;break;case 7:t=12}l(t,r,r);break}let h=t.charCodeAt(o);switch(s){case 0:{let s=t.charCodeAt(o+1);if(37===h)if(37!==s){let r=d(`
|
|
123
|
+
`,o+1);for(;10===t.charCodeAt(r);)r++;o=r}else{if(123===t.charCodeAt(o+2))return l(2,o,o+3),l(1,o,o),{types:n,texts:i,starts:a};o=d(`
|
|
124
|
+
`,o+2)}else if(10===h){let r=o+1;for(;10===t.charCodeAt(r);)r++;l(8,o,r)}else if(V(h))for(o++;o<r&&V(t.charCodeAt(o));)o++;else{if(u(h))break;if(h>=48&&h<=57&&c(lJ)>=0)l(31,o,o+10);else if(58!==h){let n=o+1;for(;n<r;){let r=t.charCodeAt(n);if(58===r||10===r)break;n++}l(35,o,n)}else{let n=o+1;for(;n<r;){let r=t.charCodeAt(n);if(35===r||10===r||59===r)break;n++}l(n>o+1?36:37,o,n)}}break}case 1:case 2:{let t=1===s?4:6;s=0,l(t,o,d(`
|
|
125
|
+
`,o));break}case 3:125===h?(s=0,o++):l(7,o,d("}",o));break;case 4:34===h?(s=0,o++):l(9,o,d('"',o));break;case 5:if(40===h){let t=c(lG);t>=0?(s=0,o=t):(s=6,o++)}else l(10,o,d("(",o));break;case 6:41===h?(s=0,o++):l(11,o,d(")",o));break;case 7:if(V(h))s=0,o++;else{let n=o+1;for(;n<r&&!V(t.charCodeAt(n));)n++;l(12,o,n)}}}return n.push(0),i.push(""),a.push(r),{types:n,texts:i,starts:a}}(t),s=0,o=r=>{let i=n[s];throw d("gantt",t,a[s],`Expecting ${r}, got '${0===i?"1":lB[i]}'`)},l=(t="")=>{1!==l4[n[s]]&&o(l2+t)};for(13!==n[s]&&o("'gantt'"),s++;;){let t=n[s],a=i[s];switch(1!==l4[t]&&o(l2),s++,t){case 38:if(0===n[s])return;l();break;case 8:break;case 14:l(),r.setDateFormat(a.slice(11));break;case 15:l(),r.enableInclusiveEndDates();break;case 16:l(),r.TopAxis();break;case 17:l(),r.setAxisFormat(a.slice(11));break;case 18:l(),r.setTickInterval(a.slice(13));break;case 20:l(),r.setExcludes(a.slice(9));break;case 19:l(),r.setIncludes(a.slice(9));break;case 21:l(),r.setTodayMarker(a.slice(12));break;case 29:l(),r.setWeekend("friday");break;case 30:l(),r.setWeekend("saturday");break;case 32:l(),r.setDiagramTitle(a.slice(6));break;case 3:{4!==n[s]&&o("'acc_title_value'");let t=i[s++];l(),r.setAccTitle(t.trim());break}case 5:{6!==n[s]&&o("'acc_descr_value'");let t=i[s++];l(),r.setAccDescription(t.trim());break}case 7:l(),r.setAccDescription(a.trim());break;case 34:l(),r.addSection(a.slice(8));break;case 35:{36!==n[s]&&o("'taskData'");let t=i[s++];l(),r.addTask(a,t);break}case 12:{let t,c=null,d;10===n[s]?(t=i[s++],11===n[s]&&(c=i[s++]),9===n[s]?(d=i[s++],l()):l(null===c?", 'callbackargs', 'href'":", 'href'")):9===n[s]?(d=i[s++],10===n[s]?(t=i[s++],11===n[s]?(c=i[s++],l()):l(", 'callbackargs'")):l(", 'callbackname'")):o("'callbackname', 'href'"),void 0!==t&&r.setClickEvent(a,t,c),void 0!==d&&r.setLink(a,d);break}default:l(),r.setWeekday(l1[t-22])}}}(t,i),i},render:function(t,r,n){let i=n.fontSize??16,a=n.measurer??e$(n.fontFamily,n.fontFamilyMono),s=n.padding??8,o=lP(n.now),l=cd(r,"fontSize",4,72)??Math.round(.8125*i),c=cd(r,"sectionFontSize",4,72)??l,d=Math.round(.75*i),u=cd(r,"barHeight",4,400)??Math.round(1.85*l),h=cd(r,"barGap",0,400)??Math.round(u/4),f=u+h,p=Math.round(cd(r,"numberSectionStyles",1,1e3)??4),g="compact"===t.displayMode,m=t.topAxis||r.gantt?.topAxis===!0,y=t.getTasks(o),v=y.filter(t=>!t.vert),b=y.filter(t=>t.vert&&cf(t)),x=new Map;for(let t of v)x.has(t.section)||x.set(t.section,x.size);let w=new Map,$=[];if(g){let t=new Map;for(let r of v){let n=t.get(r.section);n?n.push(r):t.set(r.section,[r])}for(let[r,n]of t){let t=function(t,r,n){let i=t.filter(cf).sort((t,r)=>t.startTime-r.startTime||t.order-r.order),a=[];for(let t of i){let i=+t.startTime,s=0;for(;s<a.length&&i<a[s];)s++;a[s]=+t.endTime,n.set(t,r+s)}let s=a.length;for(let i of t)n.has(i)||n.set(i,r+s++);return Math.max(s,1)}(n,$.length,w);for(let n=0;n<t;n++)$.push(r)}}else for(let t of v)w.set(t,$.length),$.push(t.section);let k=$.length,M=1/0,_=-1/0;for(let t of y)cf(t)&&(M=Math.min(M,+t.startTime),_=Math.max(_,+t.endTime));let A=M<=_,E=n7(t.title,!1,a,i,4e3,1),S=E.height>0?E.height+16:0;if(!A){let r=Math.ceil(Math.max(E.width,1)+2*s),a=Math.ceil(Math.max(E.height,1)+2*s),o=eI(E,r/2,s+E.height/2,' class="pele-title" font-weight="var(--_tw)"');return{svg:np("gantt",r,a,i,n,t,o),width:r,height:a,links:[]}}let C=new Map,T=0;for(let t of x.keys()){let r=n7(t,!1,a,c,180);C.set(t,r),T=Math.max(T,r.width)}let I=t.axisFormat||("D"===t.dateFormat?"%d":cu(r,"axisFormat")??"%Y-%m-%d"),N=t=>(function t(r,n){let i="",a=0,s=r.length;for(let o=0;o<s;o++){if(37!==r.charCodeAt(o))continue;i+=r.slice(a,o);let s=r.charAt(++o),l=cl.get(s);void 0!==l?s=r.charAt(++o):l="e"===s?" ":"0",i+=function(r,n,i){switch(r){case"a":return lt[n.getDay()].slice(0,3);case"A":return lt[n.getDay()];case"b":return le[n.getMonth()].slice(0,3);case"B":return le[n.getMonth()];case"c":return t("%x, %X",n);case"d":case"e":return ci(n.getDate(),i,2);case"f":return ci(n.getMilliseconds(),i,3)+"000";case"g":return ci(co(n).getFullYear()%100,i,2);case"G":return ci(co(n).getFullYear()%1e4,i,4);case"H":return ci(n.getHours(),i,2);case"I":return ci(n.getHours()%12||12,i,2);case"j":return ci(1+l8(ca(n,l6.year),ca(n,l6.day),864e5),i,3);case"L":return ci(n.getMilliseconds(),i,3);case"m":return ci(n.getMonth()+1,i,2);case"M":return ci(n.getMinutes(),i,2);case"p":return n.getHours()>=12?"PM":"AM";case"q":return String(1+Math.floor(n.getMonth()/3));case"Q":return String(+n);case"s":return String(Math.floor(n/1e3));case"S":return ci(n.getSeconds(),i,2);case"u":return String(n.getDay()||7);case"U":return ci(cs(n,0),i,2);case"V":{let t=co(n),r=ca(t,l6.year);return ci(l8(ca(r,l5(4)),t,6048e5)+ +(4===r.getDay()),i,2)}case"w":return String(n.getDay());case"W":return ci(cs(n,1),i,2);case"x":return t("%-m/%-d/%Y",n);case"X":return t("%-I:%M:%S %p",n);case"y":return ci(n.getFullYear()%100,i,2);case"Y":return ci(n.getFullYear()%1e4,i,4);case"Z":{let t=n.getTimezoneOffset(),r=Math.abs(t);return(t>0?"-":"+")+ci(Math.floor(r/60),"0",2)+ci(r%60,"0",2)}case"%":return"%";default:return r}}(s,n,l),a=o+1}return i+r.slice(a)})(I,new Date(t)),O=Math.max(a.width(N(M),d,0),a.width(N(_),d,0)),D=s+(cd(r,"leftPadding",0,2e3)??Math.max(T>0?T+24:0,O/2)),R=cd(r,"rightPadding",0,2e3)??Math.max(16,O/2),L=Math.max(240,il(n,cd(r,"useWidth",100,2e4)??800,280)-D-R-s),z=D+L,P=_>M?L/(_-M):0,j=t=>0===P?D+L/2:D+(t-M)*P,F=Math.round(1.75*d),B=cd(r,"topPadding",0,2e3),W=cd(r,"gridLineStartPadding",0,2e3),H=s+S+(m?F:0),U=Math.max(H,B??0),q=void 0!==B&&void 0!==W?Math.max(0,Math.min(B-W,U-H)):0,V=Math.max(k,1)*f,Y=U+V,G=[],Z=z+R;for(let t of v){let r=ch(t.task,a,l),n=w.get(t);if(!cf(t)){let i=D+8+r.width/2;Z=Math.max(Z,i+r.width/2),G.push({task:t,label:r,row:n,x0:NaN,x1:NaN,labelX:i,inside:!1});continue}let i=j(+t.startTime),s=Math.max(j(+(t.renderEndTime??t.endTime)),i+2*!t.milestone);if(t.milestone){let r=i+(j(+t.endTime)-i)/2;i=r-u/2,s=r+u/2}let o=!t.milestone&&r.width+16<=s-i,c=(i+s)/2;if(!o){let t=s+8+r.width<=z+R,n=i-8-r.width>=D;Z=Math.max(Z,(c=t||!n?s+8+r.width/2:i-8-r.width/2)+r.width/2)}G.push({task:t,label:r,row:n,x0:i,x1:s,labelX:c,inside:o})}let X=t.tickInterval||cu(r,"tickInterval")||"",K=t.weekday??cu(r,"weekday")??"sunday",J=Math.max(2,Math.min(10,Math.floor(L/(O+24)))),Q=function(t,r,n,i,a){let s=cr.exec(t);if(!s)return;let o=parseInt(s[1],10),l=l9(s[2],o,Math.max(0,cn.indexOf(r)));if(!((i-n)/(Math.min(o,l.cycle)*l.ms)>a))return l7(l,n,i,a)}(X,K,M,_,Math.ceil(L/3))??function(t,r,n){let i,a=(r-t)/n,s=0;for(;s<ct.length&&ct[s][2]<=a;)s++;if(s===ct.length)i=l9("year",Math.max(1,ce(t/31536e6,r/31536e6,n)),0);else if(0===s)i=l9("millisecond",Math.max(ce(t,r,n),1),0);else{let[t,r]=ct[a/ct[s-1][2]<ct[s][2]/a?s-1:s];i=l9(t,r,0)}return l7(i,t,r,4*n+8)??[]}(M,_,J),ee="",et="",er="",en=-1/0,ei="",ea=Y+F/2+2,es=U-q-F/2-2;for(let t of Q){let r=j(t);ee+=`M${eT(r)},${eT(U-q)}V${eT(Y)}`;let n=N(t),i=a.width(n,d,0);if(r-i/2<en+8||n===ei)continue;en=r+i/2,ei=n,Z=Math.max(Z,en);let s=`text-anchor="middle">${eE(n)}</text>`;et+=`<text x="${eT(r)}" y="${eT(ea+.35*d)}" ${s}`,m&&(er+=`<text x="${eT(r)}" y="${eT(es+.35*d)}" ${s}`)}let eo="",el="",ec=[],ed=Y+F+4,eu=Math.round(1.5*l);for(let t of[...b].sort((t,r)=>t.startTime-r.startTime)){let r=j(+t.startTime),n=ch(t.task,a,l),i=Math.max(s+n.width/2,r),o=0;for(;o<ec.length&&i-n.width/2<ec[o]+8;)o++;ec[o]=i+n.width/2,Z=Math.max(Z,ec[o]),eo+=`<path class="pele-vert" data-id="${eS(t.id)}" d="M${eT(r)},${eT(U-q)}V${eT(Y)}"/>`,el+=eI(n,i,ed+o*eu+eu/2,` class="pele-vert-label" data-id="${eS(t.id)}"`)}let eh=Math.ceil(Math.max(Z,s+E.width)+s),ef=Math.ceil(Y+F+(ec.length>0?4+ec.length*eu:0)+s),ep="",eg="";for(let t=0;t<k;){let r=$[t],i=t+1;for(;i<k&&$[i]===r;)i++;let a=x.get(r)%p,o=U+t*f,l=(i-t)*f;(x.size>1||""!==r)&&(ep+=`<rect class="pele-section pele-section-${a}" x="0" y="${eT(o)}" width="${eh}" height="${eT(l)}" fill="${a%2==0?"var(--_s)":"none"}"/>`);let c=C.get(r);eg+=eI(c,s+8+c.width/2,o+l/2,` class="pele-section-label" data-id="${eS(r)}"`,n.icons),t=i}let em="";if((t.excludes.length>0||t.includes.length>0)&&+ld(new Date(M),6,"y")>_){let r,n,i=()=>{if(!r||!n)return;let t=new Date(r);t.setHours(0,0,0,0);let i=new Date(n);i.setHours(23,59,59,999);let a=Math.max(D,j(+t)),s=Math.min(z,j(+i));s>a&&(em+=`<rect x="${eT(a)}" y="${eT(U)}" width="${eT(s-a)}" height="${eT(V)}"/>`),r=n=void 0};for(let a=new Date(M);+a<=_;a=ll(a,1))t.isInvalidDate(a)?(r??=a,n=a):i();i()}let ey=[],ev="";for(let r of G){let i=r.task,a=U+r.row*f+f/2,s=i.active?"active":i.done?"done":"",o="pele-task";s&&(o+=" pele-"+s),i.crit&&(o+=" pele-crit"),i.milestone&&(o+=" pele-milestone"),i.classes.includes("clickable")&&(o+=" pele-clickable");let l="",c="";if(Number.isNaN(r.x0))o+=" pele-unscheduled",c=' fill="var(--_m)"';else{let t=i.crit?r7:"var(--_c)",n="done"===s?'fill="var(--_a)"':"active"===s?`fill="${t}" fill-opacity="0.25"`:`fill="${t}"`,o=`stroke="${"done"===s&&!i.crit?"var(--_b)":t}"`;if(i.milestone){let t=(r.x0+r.x1)/2,i=u/2;l=`<path d="M${eT(t)},${eT(a-i)}L${eT(t+i)},${eT(a)}L${eT(t)},${eT(a+i)}L${eT(t-i)},${eT(a)}Z" ${n} ${o} stroke-linejoin="round"/>`}else l=`<rect x="${eT(r.x0)}" y="${eT(a-u/2)}" width="${eT(r.x1-r.x0)}" height="${eT(u)}" ${n} ${o}${r5}/>`;r.inside?c=""===s?' fill="var(--_bg)"':"":"done"===s&&(c=' fill="var(--_m)"')}let d=l+eI(r.label,r.labelX,a,` class="pele-label"${c}`),h=t.links.get(i.id);void 0!==h&&(d=tI(d,h,i.id,ey,n)),ev+=`<g class="${o}" data-id="${eS(i.id)}">${d}</g>`}let eb="";if("off"!==t.todayMarker&&o>=M&&o<=_&&_>M){let r=j(o),n=U-q,i=t.todayMarker?no(t.todayMarker.split(",")).line:"";eb=`<g class="pele-today"><path d="M${eT(r)},${eT(n)}V${eT(Y)}" fill="none" stroke="var(--_c)" stroke-width="2"${i}/>`+(i?"":`<path d="M${eT(r-4)},${eT(n-5)}H${eT(r+4)}L${eT(r)},${eT(n+1)}Z" fill="var(--_c)"/>`)+"</g>"}let ex=`M${eT(D)},${eT(Y)}H${eT(z)}`+(m?`M${eT(D)},${eT(U-q)}H${eT(z)}`:""),ew=eI(E,eh/2,s+E.height/2,' class="pele-title" font-weight="var(--_tw)"')+(ep?`<g class="pele-sections">${ep}</g>`:"")+(em?`<g class="pele-excluded" fill="var(--_a)">${em}</g>`:"")+`<g class="pele-grid" fill="none"><path d="${ee}" stroke="var(--_b)" stroke-dasharray="1 3"/><path d="${ex}" stroke="var(--_b)"/></g>`+(eo?`<g class="pele-verts" fill="none" stroke="var(--_l)" stroke-width="1.5" stroke-dasharray="4 3">${eo}</g>`:"")+eb+`<g class="pele-tasks" font-size="${eT(l)}">${ev}</g><g class="pele-section-labels" font-size="${eT(c)}">${eg}</g><g class="pele-axis" font-size="${d}" fill="var(--_m)">${et}${er}</g>`+(el?`<g class="pele-vert-labels" font-size="${eT(l)}">${el}</g>`:"");return{svg:np("gantt",eh,ef,i,n,t,ew),width:eh,height:ef,links:ey}}},{type:"architecture",parse(t,r,n){let i=new i_;return n&&(i.title=n),function(t,r){for(let n of(t.accDescr&&(r.accDescr=t.accDescr.replace(/\n\s+/g,`
|
|
126
|
+
`)),t.accTitle&&(r.accTitle=t.accTitle.replace(/^\s+/g,"")),t.title&&(r.title=t.title),t.groups))r.addGroup(n);for(let n of t.services)r.addService(n);for(let n of t.junctions)r.addJunction(n);for(let n of t.edges)r.addEdge(n);for(let n of t.alignments)r.addLayoutHint({direction:n.direction,members:[...n.members]})}(function(t){let r=new iG(iE(t,iK,"architecture"),iK,"architecture"),n={$type:"Architecture",groups:[],services:[],junctions:[],edges:[],alignments:[]},i=t=>r.kinds[r.i]===t,a=()=>{if(-1!==r.kind)for(19!==r.kind&&r.fail("a line break or the end of input");19===r.kind;)r.i++};for(;19===r.kind;)r.i++;for(r.expect(0);-1!==r.kind;){switch(r.kind){case 19:r.i++;continue;case 14:n.accDescr=iq(r.take());break;case 15:n.accTitle=iU(r.take());break;case 16:n.title=iH(r.take());break;case 4:{r.i++;let t={$type:"Group",id:r.expect(18)};i(24)&&(t.icon=r.take().slice(1,-1)),i(25)&&(t.title=iJ(r.take())),r.accept(8)&&(t.in=r.expect(18)),n.groups.push(t);break}case 2:{r.i++;let t={$type:"Service",id:r.expect(18)};i(17)?t.iconText=iY(r.take()):i(24)&&(t.icon=r.take().slice(1,-1)),i(25)&&(t.title=iJ(r.take())),r.accept(8)&&(t.in=r.expect(18)),n.services.push(t);break}case 1:{r.i++;let t={$type:"Junction",id:r.expect(18)};r.accept(8)&&(t.in=r.expect(18)),n.junctions.push(t);break}case 18:{let t=r.take(),a=r.accept(12);r.expect(9);let s=r.expect(11),o=r.accept(13),l;r.accept(7)||(i(10)||r.fail("'--' or '-'"),r.i++,l=iJ(r.expect(25)),r.expect(10));let c=r.accept(13),d=r.expect(11);r.expect(9);let u=r.expect(18),h=r.accept(12);n.edges.push({$type:"Edge",lhsId:t,lhsGroup:a,lhsDir:s,lhsInto:o,title:l,rhsInto:c,rhsDir:d,rhsId:u,rhsGroup:h});break}case 5:{r.i++,i(6)||i(3)||r.fail("'row' or 'column'");let t=r.take(),a=[r.expect(18),r.expect(18)];for(;i(18);)a.push(r.take());n.alignments.push({$type:"Alignment",direction:t,members:a});break}default:r.fail("a group, a service, a junction, an edge, an alignment, a title, or a line break")}a()}return n}(t),i),i},render:function(t,r,n){return iu(n,i=>(function(t,r,n,i){let a=i5(r,"iconSize",48,8,512),s=i5(r,"fontSize",n.fontSize??16,4,128),o=Math.min(i5(r,"padding",20,0,256),i?12:1/0),l=Math.round(.875*s),c=n.measurer??e$(n.fontFamily,n.fontFamilyMono),d=n.padding??8,u=n.icons,h=a/2,f=[...t.nodes.values()],p=[...t.groups.values()],g=f.length,m=p.length,y=function(t,r,n,i){let a=t.length,s=r.length,o=new Map,l=new Map,c=new Int32Array(a+s).fill(s),d=new Int32Array(s+1),u=[];for(let t=0;t<=s;t++)u.push([]);r.forEach((t,r)=>{l.set(t.id,r);let n=void 0===t.in?void 0:l.get(t.in);void 0!==n&&n!==r?(c[a+r]=n,d[r]=d[n]+1):d[r]=1}),t.forEach((t,r)=>{o.set(t.id,r);let n=void 0===t.in?void 0:l.get(t.in);void 0!==n&&(c[r]=n),u[c[r]].push(r)});for(let t=0;t<s;t++)u[c[a+t]].push(a+t);let h=[],f=[],p=[],g=[],m=[],y=[],v=Array(a+s),b=Array(a+s),x=(t,r,n,i,s)=>{if(t===r)return;let o=t,l=r,u=c[t],v=c[r];for(;u!==v;)d[u]>=d[v]?u=c[o=a+u]:v=c[l=a+v];let b=h.length;h.push(t),f.push(r),p.push(n),g.push(i),m.push(o),y.push(l),(s[o]??=[]).push(b),(s[l]??=[]).push(b)};for(let t of i){let r="row"===t.direction;for(let n=1;n<t.members.length;n++){let i=o.get(t.members[n-1]),a=o.get(t.members[n]);void 0!==i&&void 0!==a&&x(i,a,r?1:3,2*!r,v)}}for(let t of[!1,!0])for(let r of n){if(r.lhsDir===r.rhsDir!==t)continue;let n=o.get(r.lhsId),i=o.get(r.rhsId);void 0!==n&&void 0!==i&&x(n,i,i2(r.lhsDir),i2(r.rhsDir),b)}let w=new Int32Array(a+s),$=new Int32Array(a+s),k=new Int32Array(a+s).fill(1),M=new Int32Array(a+s).fill(1),_=new Uint8Array(a+s),A=[],E=new Map,S=[],C=new Map,T=0,I=0,N=0,O=(t,r)=>{I=0,N=0;for(let n=t;n!==r;n=a+c[n])I+=w[n],N+=$[n]},D=(t,r,n)=>{if(w[t]=r,$[t]=n,_[t]=1,A.push(t),k[t]*M[t]>64)return void S.push(t);for(let i=n;i<n+M[t];i++)for(let n=r;n<r+k[t];n++)E.set((n+0x2000000)*0x4000000+i+0x2000000,t)},R=(t,r,n,i,a)=>w[t]<r+i&&r<w[t]+k[t]&&$[t]<n+a&&n<$[t]+M[t],L=(t,r,n,i)=>{if(n*i>64){for(let a=T;a<A.length;a++)if(R(A[a],t,r,n,i))return A[a];return -1}for(let a=r;a<r+i;a++)for(let r=t;r<t+n;r++){let t=E.get((r+0x2000000)*0x4000000+a+0x2000000);if(void 0!==t)return t}for(let a of S)if(R(a,t,r,n,i))return a;return -1},z=(t,r,n,i,a,s)=>{let o=`${t},${r},${n},${i},${a},${s}`,l=C.get(o)??0;for(;;){let o=L(t+l*a,r+l*s,n,i);if(o<0)break;l=a>0?w[o]+k[o]-t:a<0?t+n-w[o]:s>0?$[o]+M[o]-r:r+i-$[o]}return C.set(o,l),l},P=(t,r)=>{let n,i,a=m[r]===t,s=a?y[r]:m[r];if(_[s])return;let o=a?p[r]:g[r],l=a?g[r]:p[r];O(a?h[r]:f[r],t);let c=I,d=N;O(a?f[r]:h[r],s);let u=i0[o],v=i1[o],x=0,A=0,E=i0[o]+i0[l]===0&&i1[o]+i1[l]===0;if(o===l?v=1-(u=+(0===i0[o])):E||(x=-i0[l],A=-i1[l]),0!==u?(n=u>0?w[t]+k[t]:w[t]-k[s],i=$[t]+d+A-N):(i=v>0?$[t]+M[t]:$[t]-M[s],n=w[t]+c+x-I),E){let t=b[s];if(void 0!==t&&t.length>1){let r=[];for(let n of t){let t=y[n]===s,i=t?m[n]:y[n];if(!_[i]||(t?p[n]:g[n])!==o||(t?g[n]:p[n])!==l)continue;O(t?h[n]:f[n],i);let a=0!==u?$[i]+N:w[i]+I;O(t?f[n]:h[n],s),r.push(a-(0!==u?N:I))}r.length>1&&(r.sort((t,r)=>t-r),0!==u?i=r[r.length-1>>1]:n=r[r.length-1>>1])}let r=+(0===u),a=1-r,c=z(n,i,k[s],M[s],r,a),d=0===c?0:z(n,i,k[s],M[s],-r,-a),v=c<=d?c:-d;n+=r*v,i+=a*v}else{let t=z(n,i,k[s],M[s],u,v);n+=u*t,i+=v*t}D(s,n,i)},j=t=>{let r=u[t];if(0===r.length)return;A.length=0;let n=[];for(let t of r){if(_[t])continue;T=A.length,n.push(T),E.clear(),S.length=0,C.clear(),D(t,0,0);let r=T,i=T,a=0;for(;;){if(r<A.length){let t=A[r++],n=v[t];if(void 0!==n)for(let r of n)P(t,r);continue}if(i>=A.length)break;let t=b[A[i]];if(void 0===t||a>=t.length){i++,a=0;continue}P(A[i],t[a++])}}n.push(A.length);let i=n.length-1,o=Array(i),l=Array(i),c=Array(i),d=Array(i),h=0,f=0;for(let t=0;t<i;t++){let r=1/0,i=1/0,a=-1/0,s=-1/0;for(let o=n[t];o<n[t+1];o++){let t=A[o];r=Math.min(r,w[t]),i=Math.min(i,$[t]),a=Math.max(a,w[t]+k[t]),s=Math.max(s,$[t]+M[t])}o[t]=r,l[t]=i,c[t]=a-r,d[t]=s-i,h+=c[t]*d[t],f=Math.max(f,c[t])}let p=Math.max(f,Math.ceil(Math.sqrt(2*h))),g=0,m=0,y=0,x=0;for(let t=0;t<i;t++){g>0&&g+c[t]>p&&(m+=y,g=0,y=0);for(let r=n[t];r<n[t+1];r++)w[A[r]]+=g-o[t],$[A[r]]+=m-l[t];g+=c[t],y=Math.max(y,d[t]),x=Math.max(x,g)}t<s&&(k[a+t]=x,M[a+t]=m+y)};for(let t=s-1;t>=0;t--)j(t);j(s);let F=new Int32Array(s),B=new Int32Array(s),W=new Int32Array(s),H=new Uint8Array(s);for(let t=0;t<s;t++){let r=c[a+t];W[t]=r===s?-1:r,F[t]=w[a+t]+(r===s?0:F[r]),B[t]=$[a+t]+(r===s?0:B[r]),0===u[t].length&&(H[t]=1)}let U=new Int32Array(a),q=new Int32Array(a),V=new Int32Array(a);for(let t=0;t<a;t++){let r=c[t];V[t]=r===s?-1:r,U[t]=w[t]+(r===s?0:F[r]),q[t]=$[t]+(r===s?0:B[r])}return{col:U,row:q,groupCol:F,groupRow:B,groupCols:k.slice(a),groupRows:M.slice(a),groupParent:W,groupEmpty:H,nodeParent:V}}(f,p,t.edges,t.layoutHints),v=new Map;f.forEach((t,r)=>v.set(t.id,r));let b=Array(g),x=new Float64Array(g),w=new Float64Array(g),$=i?Math.max(a,64):Math.max(2.25*a,96);for(let t=0;t<g;t++){let r=f[t],n=n7("service"===r.type?r.title:void 0,!0,c,s,$);b[t]=n,x[t]=Math.max(a,2*Math.ceil(n.width/2)),w[t]=a+(n.height>0?4+n.height:0)}let k=[],M=[];for(let t=0;t<g;t++)k.push(y.col[t]),M.push(y.row[t]);for(let t=0;t<m;t++)y.groupEmpty[t]&&(k.push(y.groupCol[t]),M.push(y.groupRow[t]));let _=i6(k),A=i6(M),E=_.size,S=A.size,C=new Float64Array(E),T=new Float64Array(S),I=i?24:Math.max(40,Math.round(.75*a)),N=new Float64Array(E).fill(I),O=new Float64Array(S).fill(I),D=new Int32Array(g),R=new Int32Array(g);for(let t=0;t<g;t++){let r=D[t]=_.get(y.col[t]),n=R[t]=A.get(y.row[t]);C[r]=Math.max(C[r],x[t]),T[n]=Math.max(T[n],w[t])}for(let t=0;t<m;t++){if(!y.groupEmpty[t])continue;let r=_.get(y.groupCol[t]),n=A.get(y.groupRow[t]);C[r]=Math.max(C[r],a),T[n]=Math.max(T[n],h)}let L=t.edges.length,z=Array(L),P=new Int32Array(2*L);for(let r=0;r<L;r++){let n=t.edges[r],i=P[2*r]=v.get(n.lhsId)??-1,a=P[2*r+1]=v.get(n.rhsId)??-1,s=n7(n.title,!0,c,l,160);if(z[r]=s,!(0===s.width||i<0||a<0)){if(D[i]!==D[a]){let t=Math.min(D[i],D[a]);N[t]=Math.max(N[t],Math.ceil(s.width)+28)}else if(C[D[i]]=Math.max(C[D[i]],2*Math.ceil(s.width/2)+8),R[i]!==R[a]){let t=Math.min(R[i],R[a]);O[t]=Math.max(O[t],Math.ceil(s.height)+24)}}}let j=Array(m),F=new Int32Array(m),B=new Int32Array(m),W=new Int32Array(m),H=new Int32Array(m),U=new Float64Array(m),q=new Float64Array(m),V=new Float64Array(m),Y=new Float64Array(m),G=new Float64Array(m),Z=new Float64Array(m),X=new Float64Array(E),K=new Float64Array(E),J=new Float64Array(S),Q=new Float64Array(S),ee=Math.round(1.25*s);for(let t=0;t<m;t++){F[t]=_.get(y.groupCol[t]),B[t]=_.get(y.groupCol[t]+y.groupCols[t]-1),W[t]=A.get(y.groupRow[t]),H[t]=A.get(y.groupRow[t]+y.groupRows[t]-1);let r=n7(p[t].title,!0,c,s,i?Math.max(80,io(n)/2):320);j[t]=r;let a=p[t].icon?ee:0;G[t]=r.width+a+6*(r.width>0&&a>0),Z[t]=Math.max(r.height,a)}for(let t=m-1;t>=0;t--){let r=o+U[t],n=o+q[t],i=(Z[t]>0?Math.max(o,Z[t]+12):o)+V[t],a=o+Y[t];if(G[t]>0){let i=r+n;for(let r=F[t];r<=B[t];r++)i+=C[r]+(r<B[t]?K[r]+N[r]+X[r+1]:0);G[t]+20>i&&(n+=Math.ceil(G[t]+20-i))}U[t]=r,q[t]=n,V[t]=i,Y[t]=a,X[F[t]]=Math.max(X[F[t]],r),K[B[t]]=Math.max(K[B[t]],n),J[W[t]]=Math.max(J[W[t]],i),Q[H[t]]=Math.max(Q[H[t]],a);let s=y.groupParent[t];s<0||(F[s]===F[t]&&(U[s]=Math.max(U[s],r)),B[s]===B[t]&&(q[s]=Math.max(q[s],n)),W[s]===W[t]&&(V[s]=Math.max(V[s],i)),H[s]===H[t]&&(Y[s]=Math.max(Y[s],a)))}let et=new Float64Array(E),er=new Float64Array(S),en=0;for(let t=0;t<E;t++)et[t]=en+X[t],en=et[t]+C[t]+K[t]+(t<E-1?N[t]:0);let ei=0;for(let t=0;t<S;t++)er[t]=ei+J[t],ei=er[t]+T[t]+Q[t]+(t<S-1?O[t]:0);let ea=0,es=0,eo=en,el=ei,ec=t=>et[F[t]]-U[t],ed=t=>et[B[t]]+C[B[t]]+q[t],eu=t=>er[W[t]]-V[t],eh=t=>er[H[t]]+T[H[t]]+Y[t],ef=t=>et[D[t]]+C[D[t]]/2,ep=(t,r,n)=>{let i=i4[r],a=i3[r],s=ef(t),o=er[R[t]],l={x:s,y:o+h,dx:i,dy:a,x0:s-x[t]/2,y0:o,x1:s+x[t]/2,y1:o+w[t],gap:0,wire:!1};"junction"===f[t].type?(l.x0=l.x1=s,l.y0=l.y1=l.y,l.gap=3):0!==i?l.x=s+i*h:l.y=a<0?o:o+w[t]+2*(b[t].height>0);let c=n?y.nodeParent[t]:-1;return c>=0&&(l.x0=ec(c),l.x1=ed(c),l.y0=eu(c),l.y1=eh(c),l.gap=0,l.wire="junction"===f[t].type,0!==i?l.x=i<0?l.x0:l.x1:l.y=a<0?l.y0:l.y1),l},eg="",em="",ey=[],ev=rq("arrow_point");for(let r=0;r<L;r++){let n=t.edges[r],i=P[2*r],a=P[2*r+1];if(i<0||a<0)continue;let s=ep(i,i2(n.lhsDir),n.lhsGroup),o=ep(a,i2(n.rhsDir),n.rhsGroup);s.x===o.x&&s.y===o.y&&s.dx===o.dx&&(s.x-=8*Math.abs(s.dy),s.y-=8*Math.abs(s.dx),o.x+=8*Math.abs(s.dy),o.y+=8*Math.abs(s.dx));let l=function(t,r){let{x:n,y:i,dx:a,dy:s}=t,{x:o,y:l,dx:c,dy:d}=r,u=n+12*a,h=i+12*s,f=o+12*c,p=l+12*d;if(a*c+s*d==0){let t=0!==a?o:n,r=0!==a?i:l;return(t-n)*a+(r-i)*s>0&&(t-o)*c+(r-l)*d>0?[n,i,t,r,o,l]:0!==a?[n,i,u,h,u,p,f,p,o,l]:[n,i,u,h,f,h,f,p,o,l]}let g=0!==a,m=g?l-i:o-n;if(a===-c&&s===-d){if((o-n)*a+(l-i)*s>0){if(.5>Math.abs(m))return[n,i,o,l];if(g){let s=a>0?t.x1:r.x1,c=a>0?r.x0:t.x0,d=s<c?(s+c)/2:(n+o)/2;return[n,i,d,i,d,l,o,l]}let c=s>0?t.y1:r.y1,d=s>0?r.y0:t.y0,u=c<d?(c+d)/2:(i+l)/2;return[n,i,n,u,o,u,o,l]}}else if(Math.abs(m)>=1){if(g){let t=a>0?Math.max(n,o)+12:Math.min(n,o)-12;return[n,i,t,i,t,l,o,l]}let t=s>0?Math.max(i,l)+12:Math.min(i,l)-12;return[n,i,n,t,o,t,o,l]}if(g){let a=t.y1+12<=r.y0?(t.y1+r.y0)/2:r.y1+12<=t.y0?(r.y1+t.y0)/2:Math.max(t.y1,r.y1)+12;return[n,i,u,i,u,a,f,a,f,l,o,l]}let y=t.x1+12<=r.x0?(t.x1+r.x0)/2:r.x1+12<=t.x0?(r.x1+t.x0)/2:Math.max(t.x1,r.x1)+12;return[n,i,n,h,y,h,y,p,o,p,o,l]}(s,o);s.wire&&l.unshift(ef(i),er[R[i]]+h),o.wire&&l.push(ef(a),er[R[a]]+h);let c=function(t){let r=[t[0],t[1]];for(let n=2;n<t.length;n+=2){let i=t[n],a=t[n+1],s=r.length,o=.01>Math.abs(i-r[s-2]),l=.01>Math.abs(a-r[s-1]);o&&l||(s>=4&&(o&&.01>Math.abs(r[s-4]-r[s-2])||l&&.01>Math.abs(r[s-3]-r[s-1]))?(r[s-2]=i,r[s-1]=a):r.push(i,a))}return r}(l);if(c.length<4)continue;let d=eS(`${n.lhsId}-${n.rhsId}`);eg+=`<g class="pele-edge" data-id="${d}"><path d="${function(t,r,n){let i=t.length/2,a=Array(i),s=Array(i);for(let r=0;r<i;r++)a[r]=t[2*r],s[r]=t[2*r+1];let o=(t,r,n)=>{let i=Math.hypot(a[r]-a[t],s[r]-s[t]),o=Math.min(n,Math.max(0,i-1));i>0&&o>0&&(a[t]+=(a[r]-a[t])/i*o,s[t]+=(s[r]-s[t])/i*o)};o(0,1,r),o(i-1,i-2,n);let l=`M${eT(a[0])},${eT(s[0])}`;for(let t=1;t<i-1;t++){let r=Math.hypot(a[t]-a[t-1],s[t]-s[t-1]),n=Math.hypot(a[t+1]-a[t],s[t+1]-s[t]),i=Math.min(6,r/2,n/2);if(i<.5){l+=`L${eT(a[t])},${eT(s[t])}`;continue}let o=a[t]-(a[t]-a[t-1])/r*i,c=s[t]-(s[t]-s[t-1])/r*i,d=a[t]+(a[t+1]-a[t])/n*i,u=s[t]+(s[t+1]-s[t])/n*i;l+=`L${eT(o)},${eT(c)}Q${eT(a[t])},${eT(s[t])} ${eT(d)},${eT(u)}`}return l+`L${eT(a[i-1])},${eT(s[i-1])}`}(c,n.lhsInto&&!s.wire?ev+s.gap:0,n.rhsInto&&!o.wire?ev+o.gap:0)}"/>`+(n.lhsInto?rV("arrow_point",s.x+s.dx*s.gap,s.y+s.dy*s.gap,-s.dx,-s.dy,"var(--_l)"):"")+(n.rhsInto?rV("arrow_point",o.x+o.dx*o.gap,o.y+o.dy*o.gap,-o.dx,-o.dy,"var(--_l)"):"")+"</g>";let f=-1,p=-1,g=-1,m=-1,y=z[r];for(let t=0;t<c.length;t+=2)ea=Math.min(ea,c[t]-4),eo=Math.max(eo,c[t]+4),es=Math.min(es,c[t+1]-4),el=Math.max(el,c[t+1]+4);for(let t=0;t+3<c.length;t+=2){let r=.01>Math.abs(c[t+1]-c[t+3]),n=Math.abs(c[t]-c[t+2])+Math.abs(c[t+1]-c[t+3]);r||ey.push(c[t],Math.min(c[t+1],c[t+3]),Math.max(c[t+1],c[t+3])),n>p&&(f=t,p=n),r&&n>m&&(g=t,m=n)}if(y.width>0){let t=m>=y.width+8?g:f,r=(c[t]+c[t+2])/2,i=(c[t+1]+c[t+3])/2,a=y.width+8,l=.01>Math.abs(c[t]-c[t+2]);for(let t of[s,o])r+a/2<=t.x0||r-a/2>=t.x1||i+y.height/2<=t.y0||i-y.height/2>=t.y1||(l?r=r>=(t.x0+t.x1)/2?t.x1+a/2+4:t.x0-a/2-4:i=i>=(t.y0+t.y1)/2?t.y1+y.height/2+4:t.y0-y.height/2-4);ea=Math.min(ea,r-a/2),eo=Math.max(eo,r+a/2),es=Math.min(es,i-y.height/2),el=Math.max(el,i+y.height/2),em+=r2(`${n.lhsId}-${n.rhsId}`,y,r,i,"",u)}}let eb="";for(let t=0;t<m;t++){let r=p[t],n=ec(t),i=eu(t),a=ed(t)-n,s=j[t],o="";if(G[t]>0){let l=i+Z[t]+12,c=[];for(let t=0;t<ey.length;t+=3)ey[t+1]<l&&ey[t+2]>i&&ey[t]>n&&ey[t]<n+a&&c.push(ey[t]);c.sort((t,r)=>t-r),c.push(n+a-4);let d=n+10;for(let r of c){if(r-6-d>=G[t])break;d=Math.max(d,r+6)}d+G[t]>n+a-4&&(d=n+10);let h=i+6+Z[t]/2,f=d;r.icon&&(o+=i8(r.icon,d,h-ee/2,ee,u),f+=ee+6),o+=eI(s,f+s.width/2,h,' class="pele-cluster-label" fill="var(--_m)"',u)}eb+=`<g class="pele-cluster" data-id="${eS(r.id)}"><rect x="${eT(n)}" y="${eT(i)}" width="${eT(a)}" height="${eT(eh(t)-i)}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${r5}/>`+o+"</g>"}let ex="",ew=.5*a,ek=Math.max(6,Math.round(.75*s));for(let t=0;t<g;t++){let r=f[t],n=`data-id="${eS(r.id)}" transform="translate(${eT(ef(t))},${eT(er[R[t]])})"`;if("junction"===r.type){ex+=`<g class="pele-node pele-junction" ${n}><circle cy="${eT(h)}" r="3" fill="var(--_l)"/></g>`;continue}let i="";if(r.icon)i=i8(r.icon,-ew/2,(a-ew)/2,ew,u);else if(r.iconText){let t=n7(r.iconText,!1,c,ek,a-8),n=Math.max(1,Math.floor((a-4)/(t.lineHeight||1)));i=eI(function(t,r,n,i){let a=t.lines.length>n;if(!a&&t.width<=r)return t;let s=i.width("…",t.size,0),o=[],l=[],c=0;for(let d=0;d<Math.min(n,t.lines.length);d++){let u=t.lines[d].map(t=>({...t})),h=t.widths[d];if(h>r||a&&d===n-1)for(;;){let n=u[u.length-1];if(void 0===n){u.push({text:"…",style:0,width:s}),h=s;break}let a=h-n.width;if(void 0===n.icon&&a+s<r){let o=0,l=n.text.length;for(;o<l;){let c=o+l+1>>1;a+i.width(n.text.slice(0,c),t.size,n.style)+s<=r?o=c:l=c-1}let c=o>0?n.text.charCodeAt(o-1):0;c>=55296&&c<=56319&&o--,n.text=n.text.slice(0,o).trimEnd()+"…",n.width=i.width(n.text,t.size,n.style),h=a+n.width;break}u.pop(),h=a}o.push(u),l.push(h),c=Math.max(c,h)}return{...t,lines:o,widths:l,width:c,height:o.length*t.lineHeight}}(t,a-8,n,c),0,h,` class="pele-icon-text" font-size="${ek}"`,u)}ex+=`<g class="pele-node pele-service" ${n}><rect x="${eT(-h)}" width="${eT(a)}" height="${eT(a)}" fill="var(--_s)" stroke="var(--_b)"${r5}/>`+i+eI(b[t],0,a+4+b[t].height/2,' class="pele-label"',u)+"</g>"}let eM=n7(t.title,!1,c,s,i?io(n):4e3,1),e_=eM.height>0?eM.height+12:0,eA=Math.ceil(Math.max(eo-ea,eM.width)+2*d),eE=Math.ceil(el-es+e_+2*d),eC=Math.round((eA-(eo-ea))/2-ea),eN=Math.round(d+e_-es),eO=(eb?`<g class="pele-clusters">${eb}</g>`:"")+(eg?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round" stroke-linejoin="round">${eg}</g>`:"")+(em?`<g class="pele-edge-labels" font-size="${l}">${em}</g>`:"")+(ex?`<g class="pele-nodes">${ex}</g>`:"");return{svg:np("architecture",eA,eE,s,n,t,eI(eM,eA/2,d+eM.height/2,' class="pele-title" font-weight="var(--_tw)"')+(eO?`<g transform="translate(${eC},${eN})">${eO}</g>`:"")),width:eA,height:eE,links:[]}})(t,r,n,i))}},{type:"requirement",math:!0,parse(t,r,n){let i=new uV;return n&&(i.title=n),function(t,r){let{types:n,texts:i,starts:a}=function(t){let r=t.length,n=[],i=[],a=[],s=[],o=0,l=0,c=[[],[],[],[]],d=[[],[],[],[]],u=[0,0,0,0],h=!1,f=-1;uJ.lastIndex=0;for(let r=uJ.exec(t);null!==r;r=uJ.exec(t)){let t=void 0!==r[1]?0:void 0!==r[2]?1:void 0!==r[3]?2:3;c[t].push(r.index),d[t].push(uJ.lastIndex),h=!0}let p=(r,s,o)=>{n.push(r),i.push(t.slice(s,o)),a.push(s),l=o},g=t=>{s.push(o),o=t},m=()=>{s.length>0&&(o=s.pop())},y=(r,n)=>(r.lastIndex=n,r.test(t)?r.lastIndex:-1),v=n=>{let i=t.indexOf(`
|
|
127
|
+
`,n);return -1===i?r:i},b=s=>{let o=32|s;if(116===o&&"itle"===t.slice(l+1,l+5).toLowerCase()&&V(t.charCodeAt(l+5))){let n=l+6;for(;n<r;){let r=t.charCodeAt(n);if(35===r||10===r||59===r)break;n++}if(n>l+6)return p(2,l,n),!0}if(97===o&&(32|t.charCodeAt(l+1))==99&&(32|t.charCodeAt(l+2))==99){let t;if((t=y(uZ,l))>=0)return g(3),p(3,l,t),!0;if((t=y(uX,l))>=0)return g(4),p(5,l,t),!0;if((t=y(uK,l))>=0)return g(5),l=t,!0}if(h&&!G(s)&&(()=>{if(f<l){uQ.lastIndex=l,f=uQ.test(t)?uQ.lastIndex-1:r;for(let t=0;t<4;t++){let r=c[t],n=u[t];for(;n<r.length&&r[n]<=f;)n++;u[t]=n}}for(let t=0;t<4;t++){let r=u[t]-1;if(r>=0&&c[t][r]>=l)return p(8+t,l,v(d[t][r])),!0}return!1})())return!0;if(10===s||13===s&&10===t.charCodeAt(l+1)){let n=l;for(;n<r;){let r=t.charCodeAt(n);if(10===r)n++;else if(13===r&&10===t.charCodeAt(n+1))n+=2;else break}return p(12,l,n),!0}if(V(s)){for(l++;l<r&&V(t.charCodeAt(l));)l++;return!0}if(35===s||37===s)return l=v(l),!0;if(J(s)){let s=l+1;for(;s<r&&J(t.charCodeAt(s));)s++;if(s-l<=22){let r=uG.get(t.slice(l,s).toLowerCase());if(void 0!==r)return(46===r||47===r||48===r)&&g(2),p(r,l,s),!0}for(;s<r;){let r=t.charCodeAt(s);if(r<128&&1===u0[r])break;s++}return n.push(59),i.push(t.slice(l,s).trim()),a.push(l),l=s,!0}switch(s){case 123:return p(15,l,l+1),!0;case 125:return p(16,l,l+1),!0;case 58:return 58===t.charCodeAt(l+1)&&58===t.charCodeAt(l+2)?p(17,l,l+3):p(18,l,l+1),!0;case 60:return 45===t.charCodeAt(l+1)&&(p(55,l,l+2),!0);case 45:return 62===t.charCodeAt(l+1)?p(56,l,l+2):p(57,l,l+1),!0;case 34:return g(1),l++,!0;case 44:return p(60,l,l+1),!0}return!1},x=n=>{if(J(n)){let n=l+1;for(;n<r&&J(t.charCodeAt(n));)n++;return p(49,l,n),!0}switch(n){case 58:return p(50,l,l+1),!0;case 59:return p(51,l,l+1),!0;case 37:return p(52,l,l+1),!0;case 45:return p(53,l,l+1),!0;case 35:return p(54,l,l+1),!0;case 32:return l++,!0;case 34:return g(1),l++,!0;case 10:return m(),l++,!0;case 44:return p(60,l,l+1),!0}return!1};for(;l<r;){let s=t.charCodeAt(l),c=!0;switch(o){case 0:c=b(s);break;case 2:c=x(s);break;case 1:if(34===s)m(),l++;else{let n=t.indexOf('"',l);p(58,l,-1===n?r:n)}break;case 3:m(),p(4,l,v(l));break;case 4:m(),p(6,l,v(l));break;case 5:if(125===s)m(),l++;else{let n=t.indexOf("}",l);p(7,l,-1===n?r:n)}}if(!c)return n.push(1),i.push(""),a.push(l),{types:n,texts:i,starts:a}}let w=0===o?13:1===o?58:3===o?4:4===o?6:5===o?7:-1;return -1!==w&&p(w,r,r),p(0,r,r),{types:n,texts:i,starts:a}}(t),s=0,o=[],l=[],c=(r,i=r,...o)=>{let l=n[s];if(1===l)throw d("requirement",t,a[s],"",!0);for(let t=i;t>=r;t--)o.unshift(t);let c=o.map(t=>`'${uY[t]}'`).join(", ");throw d("requirement",t,a[s],`Expecting ${c}, got '${uY[l]}'`)},u=t=>(n[s]!==t&&c(t),i[s++]),h=(t,r)=>{let i=n[s];return(i<t||i>r)&&c(t,r),s++,u1[i-23]},f=()=>{let t=n[s];return 59!==t&&58!==t&&c(58,59),i[s++]},p=()=>{let t=n[s];if(3===t)s++,r.setAccTitle(u(4).trim());else if(5===t)s++,r.setAccDescription(u(6).trim());else{if(7!==t)return!1;r.setAccDescription(i[s++].trim())}return!0},g=()=>{let t=[];for(;;){let r=n[s];if(49!==r&&59!==r&&58!==r&&c(58,59,49),t.push(i[s++]),60!==n[s])return t;s++}},m=()=>{let t=[];for(;;){u2(n[s])||c(49,51,53,54);let r=i[s++];for(;u2(n[s]);)r+=i[s++];if(t.push(r),60!==n[s])return t;s++}},y=()=>{let t;return 17===n[s]?(s++,t=g(),u(15)):15===n[s]?s++:c(15,15,17),u(12),t},v=t=>{for(o.length=0,l.length=0;;){let r=n[s];if(16===r){s++;break}if(12===r){s++;continue}(t?r<19||r>22:44!==r&&45!==r)&&(t&&c(19,22,12,16),c(44,45,12,16)),s++,u(18),l.push(21===r?h(29,31):22===r?h(32,35):f()),o.push(r),u(12)}for(let t=o.length-1;t>=0;t--){let n=l[t];switch(o[t]){case 19:r.setNewReqId(n);break;case 20:r.setNewReqText(n);break;case 21:r.setNewReqRisk(n);break;case 22:r.setNewReqVerifyMethod(n);break;case 44:r.setNewElementType(n);break;default:r.setNewElementDocRef(n)}}};for(;p();)12===n[s]&&s++;for(14!==n[s]&&c(14,14,3,5,7),s++,u(12);;){let t=n[s];if(13===t)return;if(12===t)s++;else{if(p())continue;if(t>=8&&t<=11)s++,r.setDirection(8===t?"TB":9===t?"BT":10===t?"RL":"LR");else if(t>=23&&t<=28){let t=h(23,28),n=f(),i=y();v(!0),r.addRequirement(n,t),i&&r.setClass([n],i)}else if(36===t){s++;let t=f(),n=y();v(!1),r.addElement(t),n&&r.setClass([t],n)}else if(46===t){s++;let t=g();r.setCssStyle(t,m())}else if(47===t){s++;let t=g();r.defineClass(t,m())}else if(48===t){s++;let t=g();r.setClass(t,g())}else if(59===t||58===t){let t=i[s++],a=n[s];if(17===a)s++,r.setClass([t],g());else if(55===a||57===a){s++;let n=h(37,43);u(57===a?56:57);let i=f();57===a?r.addRelationship(n,t,i):r.addRelationship(n,i,t)}else c(17,17,55,57)}else c(12,13,3,5,7,8,9,10,11,23,24,25,26,27,28,36,47,48,46,59,58)}}}(t,i),i},render:function(t,r,n){return id(t.direction)?ic(n,i=>u5(t,r,n,i)):u5(t,r,n,!1)}},{type:"sankey",parse(t,r,n){let i=new u6;return n&&(i.title=n),function(t,r,n=t){let{types:i,texts:a,starts:s}=function(t){let r=t.length,n=[],i=[],a=[],s=[],o=0,l=0,c=(r,s,o)=>{n.push(r),i.push(t.slice(s,o)),a.push(s),l=o},d=r=>t.slice(l,l+r.length).toLowerCase()===r&&!J(t.charCodeAt(l+r.length));for(;l<r;){let u=t.charCodeAt(l),h=l,f=l;if(2===o){if(34===u&&34!==t.charCodeAt(l+1)){s.length>0&&(o=s.pop()),c(5,l,l+1);continue}for(;f<r;){let r=t.codePointAt(f);if(u9(r)||44===r||13===r||10===r)f+=r>65535?2:1;else if(34===r&&34===t.charCodeAt(f+1))f+=2;else break}c(7,l,f)}else{if(0===o&&(32|u)==115){let t=d("sankey-beta")?11:6*!!d("sankey");if(t>0){s.push(o),o=1,c(2,l,l+t);continue}}if(10===u||13===u&&10===t.charCodeAt(l+1)){c(3,l,10===u?l+1:l+2);continue}if(44===u){c(4,l,l+1);continue}if(34===u){s.push(o),o=2,c(5,l,l+1);continue}for(;f<r;){let r=t.codePointAt(f);if(!u9(r))break;f+=r>65535?2:1}c(6,l,f)}if(f===h)return c(1,l,l),{types:n,texts:i,starts:a}}return c(2===o?7:8,r,r),c(0,r,r),{types:n,texts:i,starts:a}}(t),l=0,c=(r,i)=>{let a=[];return n!==t&&hr(n,a),d("sankey",n,r>0&&r>=t.length?o(a,t.length-1)+1:o(a,r),i)},u=t=>{let r=i[l],n=1===r?u8[i[l-1]]:u8[r];throw c(s[l],`Expecting ${t}, got '${n}'`)},h=(t,r="")=>{i[l]!==t&&u(`'${u8[t]}'${r}`),l++},f=()=>{if(6===i[l])return a[l++];5!==i[l]&&u("'DQUOTE', 'NON_ESCAPED_TEXT'"),7!==i[++l]&&u("'ESCAPED_TEXT'");let t=a[l++];return h(5),t},p=()=>{let t=s[l],r=f().trim().replaceAll('""','"');if(he.test(y(r)))throw c(t,"Invalid XML character in node name");return r};for(h(2),h(3);;){let t=p();h(4,", 'NEWLINE', 'EOF'");let n=p();h(4,", 'NEWLINE', 'EOF'");let a=s[l],o=parseFloat(f());if(!Number.isFinite(o))throw c(a,"Expecting a number");let d=r.findOrCreateNode(t),u=r.findOrCreateNode(n);if(r.addLink(d,u,o),3!==i[l])break;l++}8===i[l]&&l++,0!==i[l]&&u("'NEWLINE', 'EOF'")}(hr(t),i,t),i},render:function(t,r,n){let i=hi(r.sankey)?r.sankey:{},s=ha(i,"width",600,1,1e4);return is(n,s,160,r=>(function(t,r,n,i,s){let o=n.fontSize??16,l=Math.round(.625*o),c=Math.max(l,Math.round(.875*o*Math.min(1,i/s))),d=n.measurer??e$(n.fontFamily,n.fontFamilyMono),u=n.padding??8,h=ha(r,"height",400,1,1e4),f=Math.min(ha(r,"nodeWidth",10,1,200),i),p=!1!==r.showValues,g=y(hs(r,"prefix")),m=y(hs(r,"suffix")),v="outlined"===r.labelStyle,b="left"===r.nodeAlignment||"right"===r.nodeAlignment||"center"===r.nodeAlignment?r.nodeAlignment:"justify",x="string"==typeof r.linkColor?r.linkColor:"gradient",w=n=>(function(t,r){let n=t.nodes.length,i=t.links.map(t=>({source:t.source.index,target:t.target.index,value:Number.isFinite(t.value)&&t.value>0?t.value:0,thickness:0,sourceY:0,targetY:0})),s=[],o=[];for(let t=0;t<n;t++)s.push([]),o.push([]);i.forEach((t,r)=>{s[t.source].push(r),o[t.target].push(r)});let l=new Int32Array(n),c=new Int32Array(n),d=[];for(let t=0;t<n;t++)c[t]=o[t].length,0===c[t]&&d.push(t);for(let t=0;t<d.length;t++){let r=d[t];for(let t of s[r]){let n=i[t].target;l[n]<l[r]+1&&(l[n]=l[r]+1),0==--c[n]&&d.push(n)}}if(d.length<n){let r=0;for(;0===c[r];)r++;let s=new Uint8Array(n);for(;0===s[r];)for(let t of(s[r]=1,o[r]))if(c[i[t].source]>0){r=i[t].source;break}throw new a(`Sankey diagrams cannot have circular links, and "${t.nodes[r].id}" is part of one.`,"semantic",{type:"sankey"})}let u=1;for(let t=0;t<n;t++)l[t]+1>u&&(u=l[t]+1);let h=new Int32Array(n);for(let t=n-1;t>=0;t--){let r=d[t];for(let t of s[r])h[r]<h[i[t].target]+1&&(h[r]=h[i[t].target]+1)}let f=0;for(let t of i)t.value>f&&(f=t.value);let p=f>0?1/f:0,g=[],m=new Float64Array(n),y=[];for(let t=0;t<u;t++)y.push([]);let v=u>1?(r.width-r.nodeWidth)/(u-1):0;for(let t=0;t<n;t++){let n;if("left"===r.alignment)n=l[t];else if("right"===r.alignment)n=u-1-h[t];else if("center"===r.alignment){if(n=l[t],0===o[t].length&&s[t].length>0)for(let r of(n=u,s[t]))l[i[r].target]-1<n&&(n=l[i[r].target]-1)}else n=s[t].length>0?l[t]:u-1;let a=0,c=0,d=0,f=0;for(let r of o[t])a+=i[r].value*p,d+=i[r].value;for(let r of s[t])c+=i[r].value*p,f+=i[r].value;m[t]=Math.max(a,c),g.push({layer:n,value:Math.max(d,f),x:n*v,y:0,height:0}),y[n].push(t)}let b=1;for(let t of y)t.length>b&&(b=t.length);let x=b>1?Math.min(r.nodePadding,r.height/(b-1)):r.nodePadding,w=1/0;for(let t of y){let n=0;for(let r of t)n+=m[r];n>0&&(w=Math.min(w,(r.height-(t.length-1)*x)/n))}(!Number.isFinite(w)||w<0)&&(w=0);let $=Math.max(0,r.labelHeight-x),k=t=>{for(let n of y){let i=(n.length-1)*x;for(let r of n)i+=Math.max(m[r]*t,$);if(i>r.height+1e-6)return!1}return!0};if($>0&&!k(w))if(k(0)){let t=0;for(let r=0;r<40;r++){let r=(t+w)/2;k(r)?t=r:w=r}w=t}else $=0;let M=new Float64Array(n);for(let t of i)t.thickness=t.value*p*w;for(let t of y){let n=0;for(let r of t)g[r].height=m[r]*w,M[r]=Math.max(0,$-g[r].height)/2,g[r].y=n+M[r],n+=g[r].height+2*M[r]+x;let i=(r.height-n+x)/(t.length+1);t.forEach((t,r)=>g[t].y+=i*(r+1))}let _=t=>g[t].y+g[t].height/2,A=new Float64Array(i.length),E=new Float64Array(i.length),S=(t,r)=>_(i[t].target)-_(i[r].target)||t-r,C=(t,r)=>_(i[t].source)-_(i[r].source)||t-r,T=(t,r)=>_(t)-_(r)||t-r,I=t=>{let r=0;for(let n of(hn(s[t],S),s[t]))A[n]=r+i[n].thickness/2,r+=i[n].thickness},N=t=>{let r=0;for(let n of(hn(o[t],C),o[t]))E[n]=r+i[n].thickness/2,r+=i[n].thickness},O=()=>{for(let t=0;t<n;t++)I(t),N(t)},D=(t,n,a)=>{for(let r of t){let t=a?o[r]:s[r];if(0===t.length)continue;a?N(r):I(r);let l=0,c=0,d=0;for(let n of t)l+=(a?g[i[n].source].y+A[n]-E[n]:g[i[n].target].y+E[n]-A[n])*i[n].thickness,c+=i[n].thickness,d+=_(a?i[n].source:i[n].target)-g[r].height/2;let u=c>0?l/c:d/t.length;g[r].y+=(u-g[r].y)*n}hn(t,T);let l=0;for(let r of t)g[r].y-M[r]<l&&(g[r].y=l+M[r]),l=g[r].y+g[r].height+M[r]+x;l=r.height;for(let r=t.length-1;r>=0;r--){let n=t[r];g[n].y+g[n].height+M[n]>l&&(g[n].y=l-g[n].height-M[n]),l=g[n].y-M[n]-x}};O();for(let t=0;t<6;t++){let r=Math.pow(.99,t);for(let t=u-2;t>=0;t--)D(y[t],r,!1);O();for(let t=1;t<u;t++)D(y[t],r,!0);O()}for(let t=0;t<i.length;t++)i[t].sourceY=g[i[t].source].y+A[t],i[t].targetY=g[i[t].target].y+E[t];return{nodes:g,links:i}})(t,{width:i,height:h,nodeWidth:f,nodePadding:ha(r,"nodePadding",12,0,200)+15*!!p,labelHeight:1.15*n,alignment:b}),$=w(c),k=new Map,M=1;for(let t of $.nodes){let r=(k.get(t.layer)??0)+1;k.set(t.layer,r),r>M&&(M=r)}let _=Math.max(l,Math.round(h/M/1.8));_<c&&($=w(c=_));let{nodes:A,links:E}=$,S=1.5*c,C=new Map;if(hi(r.nodeColors))for(let[t,n]of Object.entries(r.nodeColors)){let r=hl(n);r&&C.set(t,r)}let T=r=>C.get(t.nodes[r].id)??"",I=t=>/^ style="fill:(.*);"$/.exec(T(t))?.[1]??nu(t),N=0,O=0;A.forEach(t=>{t.value>O&&(O=t.value,N=t.layer)});let D=0,R=i,L=0,z=h,P=A.map((r,n)=>{let a=y(t.nodes[n].id),s=p?`${g}${ho(r.value)}${m}`:"",o=d.width(s?`${a} ${s}`:a,c,0),l=v?r.layer>=N:r.x<i/2,u=l?r.x+f+6:r.x-6,h=r.y+r.height/2;return D=Math.min(D,l?u:u-o),R=Math.max(R,l?u+o:u),L=Math.min(L,h-.75*c),z=Math.max(z,h+.75*c),{value:s,width:o,after:l,left:l?u:u-o,y:h}}),j=new Map;if(A.length<=300)for(let t of P){let r=Math.floor(t.y/S);for(let n of[r-2,r-1,r,r+1,r+2]){let r=j.get(n);r?r.push(t):j.set(n,[t])}}let F="",B="";A.forEach((r,n)=>{let i=t.nodes[n].id,a=y(i),s=Math.max(r.height,1);B+=`<rect class="pele-sankey-node" data-id="${eS(i)}" x="${eT(r.x)}" y="${eT(r.y)}" width="${eT(f)}" height="${eT(s)}" rx="${eT(Math.min(2,s/2))}" fill="${nu(n)}"${T(n)}/>`;let o=P[n],l=(t,r)=>(j.get(Math.floor(r/S))??[]).some(n=>n!==o&&Math.abs(n.y-r)<S&&t<n.left+n.width+6&&t+o.width>n.left-6);if(A.length<=300&&l(o.left,o.y))t:for(let t of[0,-S,S])for(let i of[o.after,!o.after]){let a=i?r.x+f+6:r.x-6-o.width,s=o.y+t;if(l(a,s)||a<D||a+o.width>R||s-.75*c<L||s+.75*c>z||A.some((t,r)=>r!==n&&a<t.x+f+6&&a+o.width>t.x-6&&s-.75*c<t.y+t.height&&s+.75*c>t.y))continue;let d=Math.max(0,r.y-s,s-r.y-r.height);if(!A.some((t,i)=>i!==n&&t.x===r.x&&Math.max(0,t.y-s,s-t.y-t.height)<=d)){o.left=a,o.y=s,o.after=i;break t}}let{value:d,after:u,y:h}=o,p=u?r.x+f+6:r.x-6,g=` x="${eT(p)}" y="${eT(h+.35*c)}" text-anchor="${u?"start":"end"}"`,m=eE(a)+(d?` <tspan class="pele-sankey-value" fill="var(--_m)">${eE(d)}</tspan>`:"");F+=`<g class="pele-label" data-id="${eS(i)}">`+(v?`<text${g} fill="none" stroke="var(--_bg)" stroke-width="3" stroke-linejoin="round">${eE(a)}${d?" "+eE(d):""}</text>`:"")+`<text${g}>${m}</text></g>`});let W="gradient"===x||"source"===x||"target"===x?"":hl(x),H=n.idPrefix??"",U="gradient"===x&&/^[\w-]+$/.test(H),q=new Map,V="";for(let r of E){let n="target"===x?r.target:r.source,i=Math.max(r.thickness,1)/2,a=A[r.source].x+f,s=A[r.target].x,o=`fill="${nu(n)}"${W||T(n)}`;if(U){let t=`x1="${eT(a)}" x2="${eT(s)}"><stop offset="0" stop-color="${I(r.source)}"/><stop offset="1" stop-color="${I(r.target)}"/>`,n=`${H}-sankey-${function(t){let r=0x811c9dc5,n=5381;for(let i=0;i<t.length;i++){let a=t.charCodeAt(i);r=Math.imul(r^a,0x1000193),n=Math.imul(n,33)+a|0}return(r>>>0).toString(36)+(n>>>0).toString(36)}(t)}`;q.set(n,`<linearGradient id="${n}" gradientUnits="userSpaceOnUse" ${t}</linearGradient>`),o=`fill="url(#${n}) ${I(r.source)}"`}let l=eT((a+s)/2),c=eS(t.nodes[r.source].id),d=eS(t.nodes[r.target].id);V+=`<path class="pele-sankey-link" data-id="${c}->${d}" d="M${eT(a)},${eT(r.sourceY-i)}C${l},${eT(r.sourceY-i)} ${l},${eT(r.targetY-i)} ${eT(s)},${eT(r.targetY-i)}L${eT(s)},${eT(r.targetY+i)}C${l},${eT(r.targetY+i)} ${l},${eT(r.sourceY+i)} ${eT(a)},${eT(r.sourceY+i)}Z" ${o}><title>${c} → ${d}: ${eE(g)}${ho(r.value)}${eE(m)}</title></path>`}let Y=n7(t.title,!1,d,o,io(n),1),G=Y.height>0?Y.height+12:0,Z=Math.max(R-D,Y.width),X=u-D+(Z-(R-D))/2,K=u+G-L,J=Math.ceil(Z+2*u),Q=Math.ceil(z-L+G+2*u);return{svg:np("sankey",J,Q,o,n,t,eI(Y,J/2,u+Y.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${eT(X)},${eT(K)})">`+(q.size>0?`<defs>${[...q.values()].join("")}</defs>`:"")+`<g class="pele-sankey-links" fill-opacity="0.4">${V}</g><g class="pele-sankey-nodes">${B}</g><g class="pele-labels" font-size="${c}">${F}</g></g>`),width:J,height:Q,links:[]}})(t,i,n,r,s))}},{type:"packet",parse:(t,r,n)=>(function(t,r,n){let i=Math.floor(dl(r,"bitsPerRow",32,1,4096)),a=[],s=-1,o=[],l=1;for(let r of t.blocks){let{start:t,end:n,bits:c}=r;if(void 0!==t&&void 0!==n&&n<t)throw dc(`Packet block ${t} - ${n} is invalid. End must be greater than start.`);if((t??=s+1)!==s+1)throw dc(`Packet block ${t} - ${n??t} is not contiguous. It should start from ${s+1}.`);if(0===c)throw dc(`Packet block ${t} is invalid. Cannot have a zero bit field.`);for(n??=t+(c??1)-1,c??=n-t+1,s=n;o.length<=i+1&&a.length<1e4;){let s=l*i-1;if(n<=s){o.push({start:t,end:n,bits:c,label:r.label}),n===s&&(a.push(o),o=[],l++);break}o.push({start:t,end:s,bits:s-t,label:r.label}),a.push(o),o=[],l++,c=n-(t=s+1)}}return o.length>0&&a.push(o),{type:"packet",title:t.title||n,accTitle:t.accTitle?t.accTitle.replace(/^\s+/g,""):void 0,accDescr:t.accDescr?t.accDescr.replace(/\n\s+/g,`
|
|
128
|
+
`):void 0,bitsPerRow:i,rows:a}})(function(t){let r=new iG(iE(t,dd,"packet"),dd,"packet"),n={$type:"Packet",blocks:[]},i=()=>{if(-1!==r.kind)for(10!==r.kind&&r.fail("a line break or the end of input");10===r.kind;)r.i++};for(;10===r.kind;)r.i++;for(r.accept(0)||r.expect(1);-1!==r.kind;)switch(r.kind){case 10:r.i++;break;case 5:n.accDescr=iq(r.take()),i();break;case 6:n.accTitle=iU(r.take()),i();break;case 7:n.title=iH(r.take()),i();break;case 8:case 3:{let t={$type:"PacketBlock",label:""};r.accept(3)?t.bits=Number(r.expect(8)):(t.start=Number(r.take()),r.accept(2)&&(t.end=Number(r.expect(8)))),r.expect(4),t.label=iY(r.expect(9)),n.blocks.push(t),i();break}default:r.fail("a field, a title, or a line break")}return n}(t),r,n),render:function(t,r,n){return ic(n,i=>(function(t,r,n,i){let a=n.fontSize??16,s=Math.round(.875*a),o=Math.round(.625*a),l=n.measurer??e$(n.fontFamily,n.fontFamilyMono),c=n.padding??8,d=r.packet??{},u=dl(r,"rowHeight",32,1,400),h=dl(r,"bitWidth",32,1,400),f=dl(r,"paddingX",5,0,400),p=dl(r,"paddingY",5,0,400),g=!1!==d.showBits,m="descending"===d.bitOrder,v=t.bitsPerRow,b=t.rows;if(i){let r=Math.max(1,Math.floor(((n.maxWidth??320)-2*c)/Math.min(h,18)));v=Math.min(v,Math.max(8,2**Math.floor(Math.log2(r))));let i=t.rows[t.rows.length-1];Math.ceil(((i?.[i.length-1]?.end??0)+1)/v)>1e4&&(v=t.bitsPerRow),h=Math.min(h,Math.max(18,((n.maxWidth??320)-2*c)/v));let a=t=>t.bits===t.end-t.start,s=[];for(let r of t.rows)for(let n of r){let r=s[s.length-1];r&&a(r)&&a(n)&&r.label===n.label&&n.start===r.end+1&&n.start%t.bitsPerRow==0?(r.end=n.end,r.bits=r.end-r.start):s.push({...n})}for(let t of(b=[],s))for(let r=t.start;r<=t.end;){let n=Math.min(t.end,(Math.floor(r/v)+1)*v-1),i=Math.floor(r/v);(b[i]??(b[i]=[])).push({...t,start:r,end:n}),r=n+1}}let x=new Map;if(i)for(let t of b)for(let r of t){let t=Math.max(1,(r.end-r.start+1)*h-Math.min(f,h-1)-6),n=aX(y(r.label).trim(),l,s,t);x.set(r,n)}let w=g?o+4:0,$=b.map(t=>{let r=u;if(i)for(let n of t)r=Math.max(r,x.get(n).height+10);return r}),k=[],M=0;for(let t of $)k.push(M),M+=w+t+p;b.length&&(M-=p);let _=Math.min(f,h-1),A=b.length>0?v*h-_:0,E=n7(t.title,!1,l,a,i?io(n):4e3,1),S=E.height>0?E.height+12*(M>0):0,C=new Map,T=(t,r)=>{let n=C.get(t);return n||C.set(t,n=new Map),n.has(r)||n.set(r,du(y(t).trim(),r,s,Math.round(.5*a),l)),n.get(r)},I=c+Math.max(0,(E.width-A)/2),N="",O="";b.forEach((t,r)=>{let n=c+k[r]+w,a=$[r];for(let r of t){let t=r.end-r.start+1,o=r.start%v,l=I+(m?v-o-t:o)*h,c=t*h-_,d=i?void 0:T(r.label,c-6);if(N+=`<g class="pele-node" data-id="${r.start}-${r.end}"><rect x="${eT(l)}" y="${eT(n)}" width="${eT(c)}" height="${eT(a)}" fill="var(--_s)" stroke="var(--_b)"${r5}/>`+(i?eI(x.get(r),l+c/2,n+a/2,""):d&&d.size<=a?`<text x="${eT(l+c/2)}" y="${eT(n+a/2+.35*d.size)}"${d.size===s?"":` font-size="${eT(d.size)}"`}>${eE(d.text)}</text>`:"")+"</g>",!g)continue;let u=m?r.end:r.start,f=m?r.start:r.end;1===t?O+=`<text x="${eT(l+c/2)}" y="${eT(n-4)}" text-anchor="middle">${u}</text>`:O+=`<text x="${eT(l)}" y="${eT(n-4)}">${u}</text><text x="${eT(l+c)}" y="${eT(n-4)}" text-anchor="end">${f}</text>`}});let D=Math.ceil(Math.max(A,E.width)+2*c),R=Math.ceil(M+S+2*c),L=(N?`<g class="pele-packet-fields" font-size="${s}" text-anchor="middle">${N}</g>`:"")+(O?`<g class="pele-packet-bits" font-size="${o}" fill="var(--_m)">${O}</g>`:"")+eI(E,D/2,R-c-E.height/2,' class="pele-title" font-weight="var(--_tw)"');return{svg:np("packet",D,R,a,n,t,L),width:D,height:R,links:[]}})(t,r,n,i))}},{type:"radar",parse:(t,r,n)=>(function(t,r){let n=t.axes.map(t=>({name:t.name,label:t.label??t.name})),i=t.curves.map(t=>{let r;if(void 0===t.entries[0].axis)r=t.entries.map(t=>t.value);else{if(0===n.length)throw dL("Axes must be populated before curves for reference entries");let i=new Map;for(let r of t.entries)void 0===r.axis||i.has(r.axis.$refText)||i.set(r.axis.$refText,r.value);r=n.map(t=>{let r=i.get(t.name);if(void 0===r)throw dL("Missing entry for axis "+t.label);return r})}return{name:t.name,label:t.label??t.name,entries:r}}),a={showLegend:!0,ticks:5,max:null,min:0,graticule:"circle"};for(let r of t.options)"showLegend"===r.name?a.showLegend=r.value:"graticule"===r.name?a.graticule=r.value:a[r.name]=r.value;return a.ticks>32&&(a.ticks=32),{type:"radar",title:t.title||r,accTitle:t.accTitle?t.accTitle.replace(/^\s+/g,""):void 0,accDescr:t.accDescr?t.accDescr.replace(/\n\s+/g,`
|
|
129
|
+
`):void 0,axes:n,curves:i,options:a}})(function(t){let r=new iG((dz=dP=0,dW=-2,iE(t,dG,"radar")),dG,"radar"),n={$type:"Radar",axes:[],curves:[],options:[]},i=()=>{for(;23===r.kind;)r.i++},a=()=>{-1!==r.kind&&(23!==r.kind&&r.fail("a line break or the end of input"),i())},s=()=>{if(!r.accept(11))return;let t=iY(r.expect(21));return r.expect(12),t},o=t=>{if(!t)return{$type:"Entry",value:Number(r.expect(20))};let n={$refText:r.expect(22)};return r.accept(9),{$type:"Entry",axis:n,value:Number(r.expect(20))}},l=()=>{let t=r.expect(22),n=s(),a={$type:"Curve",name:t,entries:[]};void 0!==n&&(a.label=n),r.expect(13),i(),20!==r.kind&&22!==r.kind&&r.fail("a number or an axis name");let l=22===r.kind;for(a.entries.push(o(l));r.accept(10);)i(),a.entries.push(o(l));return i(),r.expect(14),a},c=()=>{let t={$type:"Axis",name:r.expect(22)},n=s();return void 0!==n&&(t.label=n),t},d=()=>{let t=r.kind;return{$type:"Option",name:r.take(),value:2===t?"true"===r.expect(16):3===t?r.expect(15):Number(r.expect(20))}},u=()=>2===r.kind||5===r.kind||7===r.kind||8===r.kind||3===r.kind;for(i(),r.accept(0)||(r.expect(1),r.accept(9)),i();-1!==r.kind;)switch(r.kind){case 23:r.i++;break;case 17:n.accDescr=iq(r.take()),a();break;case 18:n.accTitle=iU(r.take()),a();break;case 19:n.title=iH(r.take()),a();break;case 6:r.i++;do n.axes.push(c());while(r.accept(10));break;case 4:r.i++;do n.curves.push(l());while(r.accept(10));break;default:for(u()||r.fail("an axis, a curve, an option, a title, or a line break"),n.options.push(d());r.accept(10);)u()||r.fail("an option"),n.options.push(d())}return n}(t),n),render:function(t,r,n){let i=dZ(r,"width",320,1,4e3);return is(n,i,160,(a,s)=>(function(t,r,n,i,a,s){let o=n.fontSize??16,l=Math.round(.875*o),c=n.measurer??e$(n.fontFamily,n.fontFamilyMono),d=n.padding??8,u=dZ(r,"axisScaleFactor",1,0,10),h=dZ(r,"axisLabelFactor",1.05,0,10),f=dZ(r,"curveTension",.17,0,1),p=Math.min(i,a)/2,{axes:g,curves:m}=t,{ticks:y,graticule:v,min:b}=t.options,x=g.length,w=g.map((t,r)=>{let n=2*Math.PI*r/x-Math.PI/2;return{x:Math.cos(n),y:Math.sin(n)}}),$=t.options.max;if(null===$)for(let t of($=-1/0,m))for(let r of t.entries)r>$&&($=r);let k=-i/2-dZ(r,"marginLeft",16,0,2e3),M=i/2+dZ(r,"marginRight",16,0,2e3),_=-a/2-dZ(r,"marginTop",16,0,2e3),A=a/2+dZ(r,"marginBottom",16,0,2e3),E="";for(let t=0;t<y;t++){let r=Math.min(p,p*(t+1)/y);"circle"===v?E+=`<circle r="${eT(r)}"/>`:E+=`<polygon points="${dX(w.map(t=>({x:t.x*r,y:t.y*r})))}"/>`}let S="",C="";w.forEach((t,r)=>{let n=p*u;S+=`M0,0L${eT(t.x*n)},${eT(t.y*n)}`;let i=n7(g[r].label,!1,c,l,4e3),a=p*h+6,s=t.x*a+(t.x>.01?i.width/2:t.x<-.01?-i.width/2:0),o=t.y*a+(t.y>.01?i.height/2:t.y<-.01?-i.height/2:0);C+=`<g class="pele-axis-label" data-id="${eS(g[r].name)}">${eI(i,s,o,"")}</g>`,k=Math.min(k,s-i.width/2),M=Math.max(M,s+i.width/2),_=Math.min(_,o-i.height/2),A=Math.max(A,o+i.height/2)});let T="";m.forEach((t,r)=>{if(t.entries.length!==x)return;let n=t.entries.map((t,r)=>{var n;let i,a,s=Number.isFinite(a=p*((i=Math.min(Math.max(t,b),n=$))-b))?a/(n-b):(i-b)/(n-b)*p,o=Number.isFinite(s)?s:0;return{x:w[r].x*o,y:w[r].y*o}}),i=nu(r),a=` class="pele-curve" data-id="${eS(t.name)}" fill="${i}" stroke="${i}"`;T+="circle"===v?`<path${a} d="${function(t,r){let n=t.length,i=`M${eT(t[0].x)},${eT(t[0].y)}`;for(let a=0;a<n;a++){let s=t[(a-1+n)%n],o=t[a],l=t[(a+1)%n],c=t[(a+2)%n];i+=` C${eT(o.x+(l.x-s.x)*r)},${eT(o.y+(l.y-s.y)*r)} ${eT(l.x-(c.x-o.x)*r)},${eT(l.y-(c.y-o.y)*r)} ${eT(l.x)},${eT(l.y)}`}return i+" Z"}(n,f)}"/>`:`<polygon${a} points="${dX(n)}"/>`});let I=t.options.showLegend?m.map(t=>n7(t.label,!1,c,l,4e3)):[],N=0;for(let t of I)N=Math.max(N,t.width);let O=26*I.length,D=s?-(20+N)/2:M+24,R=s?A+12:-O/2;I.length>0&&s?(k=Math.min(k,D),M=Math.max(M,-D),A=R+O):I.length>0&&(M=D+12+8+N,_=Math.min(_,-O/2),A=Math.max(A,O/2));let L="";I.forEach((t,r)=>{let n=R+26*r+13,i=nu(r);L+=`<g class="pele-legend-item" data-id="${eS(m[r].name)}"><rect x="${eT(D)}" y="${eT(n-6)}" width="12" height="12" rx="2" fill="${i}" fill-opacity="0.4" stroke="${i}"/>`+eI(t,D+12+8+t.width/2,n,"")+"</g>"});let z=n7(t.title,!1,c,o,io(n),1),P=z.height>0?z.height+8:0,j=Math.max(M-k,z.width),F=Math.ceil(j+2*d),B=Math.ceil(A-_+P+2*d),W=`translate(${eT(d+(j-(M-k))/2-k)},${eT(d+P-_)})`,H=eI(z,F/2,d+z.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="${W}">`+(E?`<g class="pele-graticule" fill="none" stroke="var(--_a)">${E}</g>`:"")+(S?`<path class="pele-axes" d="${S}" fill="none" stroke="var(--_b)"/>`:"")+(T?`<g class="pele-curves" fill-opacity="0.2" stroke-width="1.5" stroke-linejoin="round">${T}</g>`:"")+(C?`<g class="pele-axis-labels" font-size="${l}">${C}</g>`:"")+(L?`<g class="pele-legend" font-size="${l}">${L}</g>`:"")+"</g>";return{svg:np("radar",F,B,o,n,t,H),width:F,height:B,links:[]}})(t,r,n,a,dZ(r,"height",320,1,4e3)*a/i,s))}},{type:"treemap",parse:(t,r,n)=>(function(t,r){let n=new Map;for(let r of t.TreemapRows){if("ClassDefStatement"!==r.$type)continue;let t=n.get(r.className);for(let i of(t||n.set(r.className,t=[]),(r.styleText??"").replace(/\\,/g,"\xa7\xa7\xa7").replace(/,/g,";").replace(/§§§/g,",").split(";")))t.push(i)}let i=[];for(let r of t.TreemapRows){if("TreemapRow"!==r.$type)continue;let t=r.item,a=t.classSelector?n.get(t.classSelector):void 0;i.push({level:r.indent??0,name:t.name,type:t.$type,value:"Leaf"===t.$type?t.value:void 0,classSelector:t.classSelector,cssCompiledStyles:a&&a.length>0?a:void 0})}return{type:"treemap",title:t.title||r,accTitle:t.accTitle?t.accTitle.replace(/^\s+/g,""):void 0,accDescr:t.accDescr?t.accDescr.replace(/\n\s+/g,`
|
|
130
|
+
`):void 0,roots:function(t){let r=[],n=[];for(let i of t){let t="Leaf"===i.type,a={name:i.name,children:t?void 0:[]};for(a.classSelector=i.classSelector,i.cssCompiledStyles&&(a.cssCompiledStyles=i.cssCompiledStyles),t&&void 0!==i.value&&(a.value=i.value);n.length>0&&n[n.length-1].level>=i.level;)n.pop();0===n.length?r.push(a):n[n.length-1].node.children.push(a),t||n.push({node:a,level:i.level})}return r}(i),classes:n}})(function(t){let r=new iG(iE(t,fA,"treemap"),fA,"treemap"),n=r.kinds,i={$type:"Treemap",TreemapRows:[]},a=()=>r.accept(5)?r.expect(12):void 0;for(r.expect(3);-1!==r.kind;){let t=r.kind;if(0===t){i.accDescr=iq(r.take());continue}if(1===t){i.accTitle=iU(r.take());continue}if(2===t){i.title=iH(r.take());continue}8!==t&&14!==t&&4!==t&&r.fail("a node, a class definition, or a title");let s=8===t?r.take().length:void 0;if(4===r.kind){let t=fE.exec(r.take()),n={$type:"ClassDefStatement",className:t[1]};t[2]&&(n.styleText=t[2]),void 0!==s&&(n.indent=s),i.TreemapRows.push(n);continue}let o=r.expect(14).slice(1,-1),l=8===n[r.i]?r.i+1:r.i,c;6===n[l]||7===n[l]?(r.i=l+1,r.accept(8),c={$type:"Leaf",name:o,value:parseFloat(r.expect(13).replace(/,/g,""))}):c={$type:"Section",name:o};let d=a();void 0!==d&&(c.classSelector=d);let u={$type:"TreemapRow",item:c};void 0!==s&&(u.indent=s),i.TreemapRows.push(u)}return i}(t),n),render:function(t,r,n){var i;let a,s,o,l,c,d=n.fontSize??16,u=Math.round(.875*d),h=Math.round(.75*d),f=Math.round(.5625*d),p=n.measurer??e$(n.fontFamily,n.fontFamilyMono),g=r.treemap??{},m=n.padding??fD(r,"diagramPadding",8,0,2e3),v=Math.round(il(n,10*fD(r,"nodeWidth",64,1,400),200,2*m)),b=Math.round(10*fD(r,"nodeHeight",40,1,400)),x=!1!==g.showValues,w=(i="string"==typeof g.valueFormat?g.valueFormat:",",s="+"===(a=fS.exec("$0,0"===i?"$,":i)??fS.exec(","))[1],o=void 0!==a[3],l=void 0===a[4]?void 0:Math.min(Number(a[4]),20),c=a[6]??"",t=>{let r=Math.abs(t),n,i="";if("f"===c?n=r.toFixed(l??6):"%"===c?(n=(100*r).toFixed(l??6),i="%"):n="d"===c?Math.round(r).toFixed(0):"e"===c?r.toExponential(l??6):String(Number(r.toPrecision(Math.max(1,l??12)))),a[5]&&n.includes(".")&&!n.includes("e")&&(n=n.replace(/\.?0+$/,"")),o&&!n.includes("e")){let t=n.indexOf(".");n=-1===t?fC(n):fC(n.slice(0,t))+n.slice(t)}return(t<0?"-":s?"+":"")+(a[2]??"")+n+i}),$=Math.min(1,Math.max(0,Math.log10(v*b/Math.max(1,function(t){let r=0,n=t.slice();for(;n.length>0;){let t=n.pop();void 0!==t.children?n.push(...t.children):Number.isFinite(t.value)&&t.value>0&&r++}return r}(t.roots))/800))),k=function(t,r,n,i){let a=t.map((t,r)=>fT(t,void 0,r)),s=a.slice();for(let t=0;t<s.length;t++){let r=s[t];for(let t of r.node.children??[]){let n=fT(t,r,r.series);r.children.push(n),s.push(n)}}for(let t=s.length-1;t>=0;t--){let r=s[t];r.parent&&(r.parent.value+=r.value)}let{gap:o,header:l,short:c,side:d}=i,u=[],h=(t,r,n,i,a)=>{let s=t.filter(t=>t.value>0).sort((t,r)=>r.value-t.value),l=0;for(let t of s)l+=t.value;if(!(0===s.length||!Number.isFinite(l)))for(let t of(i=Math.max(0,i),a=Math.max(0,a),i>0&&a>0&&function(t,r,n,i,a,s,o){let l=r,c=0;for(;c<t.length;){let r=a*s/l,d=Math.min(a,s),u=t[c].value*r,h=u,f=Math.max(d*d*h/(u*u),u*u/(d*d*h)),p=c+1;for(;p<t.length;){let n=t[p].value*r,i=u+n,a=Math.max(d*d*h/(i*i),i*i/(d*d*n));if(a>f)break;f=a,u=i,p++}let g=u/d,m=0;for(let u=c;u<p;u++){let c=t[u],h=u===p-1?d-m:c.value*r/g,f=a>=s?n:n+m,y=a>=s?i+m:i,v=a>=s?g:h,b=a>=s?h:g,x=Math.round(f+v-o/2)>Math.round(f+o/2)?o/2:0,w=Math.round(y+b-o/2)>Math.round(y+o/2)?o/2:0;c.x=Math.round(f+x),c.y=Math.round(y+w),c.w=Math.round(f+v-x)-c.x,c.h=Math.round(y+b-w)-c.y,m+=h,l-=c.value}a>=s?(n+=g,a-=g):(i+=g,s-=g),c=p}}(s,l,r-o/2,n-o/2,i+o,a+o,o),s)){let s=fI(t.x,r,r+i),o=fI(t.y,n,n+a);t.w=fI(t.x+t.w,s,r+i)-s,t.h=fI(t.y+t.h,o,n+a)-o,t.x=s,t.y=o,u.push(t)}};h(a,0,0,r,n);for(let t=0;t<u.length;t++){let r=u[t];if(0===r.children.length)continue;let n=r.h-l-d>=12?l:c;r.headed=r.w>Math.max(24,2*d)&&r.h-n-d>=8,r.header=r.headed?n:0,r.headed?h(r.children,r.x+d,r.y+n,r.w-2*d,r.h-n-d):h(r.children,r.x,r.y,r.w,r.h)}return u}(t.roots,v,b,{gap:fD(r,"padding",Math.round(2+2*$),0,200),header:28,short:18,side:Math.round(3+3*$)}),M=n7(t.title,!1,p,d,io(n),1),_=M.height>0?M.height+8:0,A=m+Math.max(0,(M.width-v)/2),E=m+_,S="",C="";for(let t of k){let r=t.node,n=no(r.cssCompiledStyles??[]),i=nu(t.series),a=A+t.x,s=E+t.y,o=y(r.name).trim(),l=x?w(t.value):"",c=`data-id="${eS(r.name)}">`,g=fN(r.name),m=""===g?[]:[g];for(let r=t.parent;void 0!==r&&!r.headed;r=r.parent){let t=fN(r.node.name);""!==t&&m.unshift(t)}let v=m.join(" › "),b=t=>""===v||t===o&&v===g?"":`<title>${v}</title>`,$=`<rect x="${eT(a)}" y="${eT(s)}" width="${eT(t.w)}" height="${eT(t.h)}" fill="${i}"`,k=n.fontSize,M=!!n.bold|2*!!n.italic,_=r8(n.shape)?e8(n):ts(t.series);if(void 0!==r.children){let d="",f;if(t.headed){let r=t.header<28,i=k??(r?h:u),c=k??h,g=t.w-12-4,m=l?p.width(l,c,M):0,y=!r&&m>0&&g-m-12>=3*i,v=1.25*i<t.header?du(o,y?g-m-12:g,i,i,p,1|M):void 0,b=s+t.header/2+1;f=v?.text,v&&(d+=`<text x="${eT(a+6+2)}" y="${eT(b+.35*i)}" font-weight="var(--_hw)"${r?` font-size="${i}"`:""}${_}${n.text}>${eE(v.text)}</text>`),y&&1.25*c<=28&&(d+=`<text class="pele-value" x="${eT(a+t.w-6-2)}" y="${eT(b+.35*c)}" font-size="${h}" text-anchor="end"${_||' fill="var(--_m)"'}${n.text}>${eE(l)}</text>`)}let g=/[";]fill:/.test(n.shape)?"":' fill-opacity="0.12"',m=t.headed?`${$}${fO(`${g} stroke="${i}"${n.shape}`,t)}/>`:`<rect x="${eT(a)}" y="${eT(s)}" width="${eT(t.w)}" height="${eT(t.h)}" fill="none"/>`;S+=`<g class="pele-node pele-section${nc(r.classSelector??"")}" ${c}${b(f)}${m}${d}</g>`;continue}let T="",I=t.w-8,N=k??f,O=void 0===k?Math.min(d,Math.floor((t.h-4)/1.25)):1.25*k<=t.h-4?k:0,D=O>=N?du(o,I,O,N,p,M):void 0;if(D){let r=eT(a+t.w/2),i=s+t.h/2,o=k??Math.max(f,Math.round(.8*D.size)),c=(D.size+o)*1.25;if(l&&c<=t.h-4&&p.width(l,o,M)<=I){let t=i-c/2+1.25*D.size/2,a=i+c/2-1.25*o/2;T=`<text x="${r}" y="${eT(t+.35*D.size)}" font-size="${eT(D.size)}"${_}${n.text}>${eE(D.text)}</text><text class="pele-value" x="${r}" y="${eT(a+.35*o)}" font-size="${eT(o)}"${_}${n.text}>${eE(l)}</text>`}else T=`<text x="${r}" y="${eT(i+.35*D.size)}" font-size="${eT(D.size)}"${_}${n.text}>${eE(D.text)}</text>`}C+=`<g class="pele-node pele-leaf${nc(r.classSelector??"")}" ${c}${b(D?.text)}${$}${fO(n.shape,t)}/>${T}</g>`}let T=Math.ceil(Math.max(v,M.width)+2*m),I=Math.ceil(b+_+2*m),N=eI(M,T/2,m+M.height/2,' class="pele-title" font-weight="var(--_tw)"')+(S?`<g class="pele-sections" font-size="${u}">${S}</g>`:"")+(C?`<g class="pele-leaves" text-anchor="middle" fill="var(--_bg)">${C}</g>`:"");return{svg:np("treemap",T,I,d,n,t,N),width:T,height:I,links:[]}}},{type:"info",parse:(t,r,n)=>{var i;return i=function(t){let r=new iG(iE(t,cT,"info"),cT,"info"),n={$type:"Info"};for(;5===r.kind;)r.i++;for(r.expect(1);5===r.kind;)r.i++;if(r.accept(0))for(;5===r.kind;)r.i++;for(;-1!==r.kind;){let t=r.kind;if(2===t?n.accDescr=iq(r.take()):3===t?n.accTitle=iU(r.take()):4===t?n.title=iH(r.take()):r.fail("a title or the end of input"),-1===r.kind)break;for(5!==r.kind&&r.fail("a line break or the end of input");5===r.kind;)r.i++}return n}(t),{type:"info",title:i.title||n,accTitle:i.accTitle?i.accTitle.replace(/^\s+/g,""):void 0,accDescr:i.accDescr?i.accDescr.replace(/\n\s+/g,`
|
|
131
|
+
`):void 0}},render:function(t,r,n){let i=n.fontSize??16,a=n.measurer??e$(n.fontFamily,n.fontFamilyMono),s=n.padding??8,o=n7(t.title,!1,a,i,4e3,1),l=o.height>0?o.height+8:0,c=n7("Pele v1.13.0",!1,a,i,4e3),d=Math.ceil(Math.max(o.width,c.width)+2*s),u=Math.ceil(l+c.height+2*s),h=eI(o,d/2,s+o.height/2,' class="pele-title" font-weight="var(--_tw)"')+eI(c,d/2,s+l+c.height/2,' class="pele-version" fill="var(--_m)"');return{svg:np("info",d,u,i,n,t,h),width:d,height:u,links:[]}}},{type:"sequence",math:!0,parse(t,r,n){let i=r.sequence??{},a=new hw({wrap:"boolean"==typeof r.wrap?r.wrap:void 0,sequenceWrap:!0===i.wrap});return n&&a.setDiagramTitle(n),function(t,r){let{types:n,texts:i,starts:a}=function(t){let r=t.length,n=[],i=[],a=[],s=[],o=0,l=0,c=-1,d=(r,s,o)=>{n.push(r),i.push(t.slice(s,o)),a.push(s),l=o},u=(t,r,s,o)=>{n.push(t),i.push(o),a.push(r),l=s},h=t=>{s.push(o),o=t},f=()=>{s.length>0&&(o=s.pop())},p=n=>(c<n&&-1===(c=t.indexOf(`
|
|
132
|
+
`,n))&&(c=r),c),g=(r,n)=>{let i=t.charCodeAt(r);return i<128?(hk[i]&n)!=0:4!==n&&32!==n||!V(i)},m=(r,n)=>{for(let i=0;i<n.length;i++){let a=n.charCodeAt(i),s=t.charCodeAt(r+i);if(a>=97&&a<=122?(32|s)!==a:s!==a)return!1}return!0},y=r=>m(l,r)&&!J(t.charCodeAt(l+r.length)),v=n=>{for(;n<r&&V(t.charCodeAt(n));)n++;return n},b=()=>{let n=l;for(;n<r;){let r=t.charCodeAt(n);if(10===r||!V(r))break;n++}return n!==l&&(l=n,!0)},x=t=>{for(;t<r&&g(t,16);)t++;return t},w=(t,r,n)=>{d(t,l,l+r),h(n)},$=(t,r,n=-1)=>!!y(t)&&(d(r,l,l+t.length),n>=0&&h(n),!0),k=(n,i)=>{if(!m(l,n))return!1;let a=l+n.length,s=t.charCodeAt(a);if(32!==s&&9!==s)return!1;for(;32===s||9===s;)s=t.charCodeAt(++a);return!(a>=r)&&!!g(a,32)&&(d(i,l,l+n.length),!0)},M=r=>{let n=t.charCodeAt(r),i=t.charCodeAt(r+1);if(45===n){if(120===i||88===i||41===i||92===i||47===i||45===i)return!0;let n=t.charCodeAt(r+2);return 124===i&&(92===n||47===n)}return 47===n||92===n?(124===i||i===n)&&45===t.charCodeAt(r+2):40===n&&41===i},_=()=>{switch(o){case 0:return(()=>{let n=t.charCodeAt(l);if(10===n){let r=l+1;for(;10===t.charCodeAt(r);)r++;d(3,l,r);return}if(V(n)){l=v(l+1);return}if(35===n||37===n&&123!==t.charCodeAt(l+1)){l=p(l);return}if(!((Z(n)||46===n)&&(()=>{let r=l;for(;Z(t.charCodeAt(r));)r++;let n=r>l;if(46===t.charCodeAt(r)&&Z(t.charCodeAt(r+1))){let n=Z(t.charCodeAt(r+2))?r+3:r+2,i=t.charCodeAt(n);if(32===i||10===i)return d(10,l,n),!0}let i=t.charCodeAt(r);return!!n&&(32===i||10===i)&&(d(10,l,r),!0)})())&&!(n<128&&(32|n)>=97&&(32|n)<=122&&(n=>{switch(32|n){case 97:return $("actor",34,1)||$("alt",24,3)||$("and",30,3)||$("activate",12,1)||(()=>{let r=m(l,"accdescr");if(!r&&!m(l,"acctitle"))return!1;let n=v(l+8),i=t.charCodeAt(n);return 58===i?(d(r?18:16,l,v(n+1)),h(r?6:5),!0):!!r&&123===i&&(l=v(n+1),h(7),!0)})()||$("autonumber",9);case 98:return $("box",6,3)||$("break",28,3);case 99:return $("create",5)||$("critical",27,3);case 100:return $("destroy",35,1)||k("details",41)||$("deactivate",13,1);case 101:return $("else",31,3)||$("end",8);case 108:return $("loop",21,3)||$("left of",43)||k("links",38)||k("link",39);case 110:return $("note",36);case 111:return $("opt",23,3)||$("option",29,3)||$("over",37)||$("off",11);case 112:return $("participant",32,1)||$("par",25,3)||$("par_over",26,3)||k("properties",40);case 114:return $("rect",22,3)||$("right of",44);case 115:return $("sequencediagram",4);case 116:if(!m(l,"title"))return!1;let i=l+5,a=58===t.charCodeAt(i);a&&i++;let s=i;for(;s<r&&10!==t.charCodeAt(s)&&V(t.charCodeAt(s));)s++;if(s===r||10===t.charCodeAt(s))return l=s,!0;let o=t.charCodeAt(i);return!!V(o)&&13!==o&&!!g(i+1,16)&&(d(a?15:14,l,x(i+1)),!0);default:return!1}})(n)))if(44===n)d(42,l,l+1);else if(59===n)d(3,l,l+1);else if(g(l,1)){let n=l+1;for(;n<r&&g(n,1);)n++;for(;n<r&&!M(n);){let i=n;for(;45===t.charCodeAt(i);)i++;if(i>=r||!g(i,2))break;for(i++;i<r&&g(i,2);)i++;n=i}u(48,l,n,t.slice(l,n).trim())}else if(45===n){let r=t.charCodeAt(l+1),n=t.charCodeAt(l+2);if(62===r)d(62===n?55:53,l,l+(62===n?3:2));else if(120===r||88===r)d(59,l,l+2);else if(41===r)d(61,l,l+2);else if(124===r&&92===n)d(63,l,l+3);else if(124===r&&47===n)d(64,l,l+3);else if(92===r&&92===n)d(65,l,l+3);else if(47===r&&47===n)d(66,l,l+3);else if(45===r){let r=t.charCodeAt(l+3);62===n?d(62===r?57:54,l,l+(62===r?4:3)):120===n||88===n?d(60,l,l+3):41===n?d(62,l,l+3):124===n&&92===r?d(67,l,l+4):124===n&&47===r?d(68,l,l+4):92===n&&92===r?d(69,l,l+4):47===n&&47===r?d(70,l,l+4):d(46,l,l+1)}else d(46,l,l+1)}else if(60===n&&t.startsWith("<<->>",l))d(56,l,l+5);else if(60===n&&t.startsWith("<<--\x3e>",l))d(58,l,l+6);else{if((47===n||92===n)&&(r=>{let n=t.charCodeAt(l+1);if(124!==n&&n!==r||45!==t.charCodeAt(l+2))return!1;let i=45===t.charCodeAt(l+3),a=47===r;return d(124===n?i?a?75:76:a?71:72:i?a?77:78:a?73:74,l,l+(i?4:3)),!0})(n))return;58===n?d(52,l,x(l+1)):43===n?d(45,l,l+1):40===n&&41===t.charCodeAt(l+1)?d(47,l,l+2):d(2,l,l+1)}})(),!0;case 1:return(()=>{if(b())return!0;let n=t.charCodeAt(l);if(35===n)return l=p(l),!0;if(64===n&&123===t.charCodeAt(l+1))return w(49,2,4),!0;let i=l;for(;i<r&&g(i,4);)i++;if(i>l){let r=v(i);if(64===t.charCodeAt(r)&&123===t.charCodeAt(r+1))return d(48,l,i),!0;if(r>i&&m(r,"as")&&V(t.charCodeAt(r+2)))return d(48,l,i),h(2),!0}let a=i;for(;a<r&&g(a,8);)a++;if(a>l){let n=t.charCodeAt(a),i=a;if(a<r&&10!==n&&59!==n)for(i--;i>l&&35!==t.charCodeAt(i);)i--;if(i>l)return u(48,l,i,t.slice(l,i).trim()),f(),!0}if(60===t.charCodeAt(a))return d(2,l,p(l)),f(),!0;if(10!==n){let r=p(l);return u(2,l,r,t.slice(l,r).trim()),f(),!0}return!1})();case 2:return!!b()||(35===t.charCodeAt(l)?l=p(l):(f(),f(),y("as")?w(33,2,3):d(3,l,l)),!0);case 3:return!!b()||(35===t.charCodeAt(l)?l=p(l):(d(7,l,x(l)),f()),!0);case 4:if(125!==t.charCodeAt(l)){let n=t.indexOf("}",l);return -1===n&&(n=r),d(50,l,n),!0}{let r=v(l+1),n=r>l+1&&m(r,"as")&&V(t.charCodeAt(r+2));return d(51,l,l+1),f(),n?h(2):f(),!0}case 5:case 6:return d(5===o?17:19,l,p(l)),f(),!0;default:if(125===t.charCodeAt(l))l++,f();else{let n=t.indexOf("}",l);-1===n&&(n=r),d(20,l,n)}return!0}};for(;l<r;)if(!_())return n.push(1),i.push(""),a.push(l),{types:n,texts:i,starts:a};return 0===o||2===o?d(3,r,r):3===o?d(7,r,r):5===o?d(17,r,r):6===o?d(19,r,r):7===o&&d(20,r,r),n.push(0),i.push(""),a.push(r),{types:n,texts:i,starts:a}}(t),s=0,o=r=>{let i=n[s];throw 1===i?d("sequence",t,a[s],"",!0):d("sequence",t,a[s],`Expecting ${r}, got '${h$[i]}'`)},l=t=>(n[s]!==t&&o(`'${h$[t]}'`),i[s++]),c=()=>{let t=n[s];return 48!==t&&39!==t&&o("'ACTOR'"),{type:"addParticipant",actor:i[s++]}},u=()=>r.parseMessage(l(52).trim().substring(1)),h=()=>{let t=n[s++];if(35===t){let t=c();return l(3),t.type="destroyParticipant",t}let i=c();if(49===n[s]&&48===n[s-1]){s++;let t=l(50);l(51),i.config=t.trim()}if(i.draw=32===t?"participant":"actor",33===n[s]){s++;let t=l(7);l(3),i.description=r.parseMessage(t)}else 3===n[s]?s++:o("'AS', 'NEWLINE'");return i},f=t=>{let r=!1;47===n[s]&&(r=!0,s++);let i=hM[n[s]];i<0&&o("'SOLID_OPEN_ARROW', 'DOTTED_OPEN_ARROW', 'SOLID_ARROW', 'DOTTED_ARROW', 'SOLID_CROSS', 'DOTTED_CROSS', 'SOLID_POINT', 'DOTTED_POINT'");let a=n[++s];(47===a||!r&&(45===a||46===a))&&s++;let l=c(),d=u(),h={type:"addMessage",from:t.actor,to:l.actor,signalType:i,msg:d},f=[t,l,h];if(r){let r=47===a;h.activate=r,h.centralConnection=r?61:60,r&&f.push({type:"centralConnection",signalType:59,actor:l.actor}),f.push({type:"centralConnectionReverse",signalType:60,actor:t.actor})}else 45===a?(h.activate=!0,f.push({type:"activeStart",signalType:17,actor:l.actor})):46===a?f.push({type:"activeEnd",signalType:18,actor:t.actor}):47===a&&(h.activate=!0,h.centralConnection=59,f.push({type:"centralConnection",signalType:59,actor:l.actor}));return f},p=t=>{s++;let r=c();return[r,{type:t,actor:r.actor,text:u()}]},g=()=>{let t=n[++s];if(37===t){s++;let t=c(),r=t,i=[t.actor,t.actor];if(42===n[s]){s++;let n=c();r=[t,n],i=[t.actor,n.actor]}return[r,{type:"addNote",placement:2,actor:i,text:u()}]}43!==t&&44!==t&&o("'over', 'left_of', 'right_of'"),s++;let r=c();return[r,{type:"addNote",placement:+(43!==t),actor:r.actor,text:u()}]},m=()=>{let t={type:"sequenceIndex",sequenceVisible:!0,signalType:26};return 10===n[++s]?(t.sequenceIndex=Number(i[s++]),t.sequenceIndexStep=10===n[s]?Number(i[s++]):1):11===n[s]&&(s++,t.sequenceVisible=!1),3!==n[s]&&o("'NEWLINE', 'NUM', 'off'"),s++,t},y=(t,n,i,a)=>{let s=t.list,o=t.sections;if(o)for(let t=o.length-2;t>=0;t-=2){let l={type:n,signalType:a};l[i]=r.parseMessage(o[t+1]),s=o[t].concat([l,s])}return s},v=t=>{let n=t.text,i=t.list;switch(t.kind){case 1:i[0]={type:"boxStart",boxData:r.parseBoxData(n)},i.push({type:"boxEnd",boxText:n});break;case 2:i[0]={type:"loopStart",loopText:r.parseMessage(n),signalType:10},i.push({type:"loopEnd",loopText:n,signalType:11});break;case 3:i[0]={type:"rectStart",color:r.parseMessage(n),signalType:22},i.push({type:"rectEnd",color:r.parseMessage(n),signalType:23});break;case 4:i[0]={type:"optStart",optText:r.parseMessage(n),signalType:15},i.push({type:"optEnd",optText:r.parseMessage(n),signalType:16});break;case 5:i[0]={type:"breakStart",breakText:r.parseMessage(n),signalType:30},i.push({type:"breakEnd",optText:r.parseMessage(n),signalType:31});break;case 6:(i=y(t,"else","altText",13))[0]={type:"altStart",altText:r.parseMessage(n),signalType:12},i.push({type:"altEnd",signalType:14});break;case 7:(i=y(t,"and","parText",20))[0]={type:"parStart",parText:r.parseMessage(n),signalType:t.startType},i.push({type:"parEnd",signalType:21});break;default:(i=y(t,"option","optionText",28))[0]={type:"criticalStart",criticalText:r.parseMessage(n),signalType:27},i.push({type:"criticalEnd",signalType:29})}return i};for(;3===n[s];)s++;l(4);let b=[],x={kind:0,text:"",startType:0,list:[],sections:void 0};for(;;){let t=n[s],a=x.list;if(1===x.kind){if(32===t||34===t||35===t)a.push(h());else if(3===t)a.push([]),s++;else if(8===t){s++;let t=v(x);(x=b.pop()).list.push(t)}else o("'end', 'NEWLINE', 'participant', 'participant_actor', 'destroy'");continue}switch(t){case 3:case 2:a.push([]),s++;break;case 32:case 34:case 35:a.push(h());break;case 5:{let t=n[++s];32!==t&&34!==t&&35!==t&&o("'participant', 'participant_actor', 'destroy'");let r=h();r.type="createParticipant",a.push(r);break}case 48:a.push(f(c())),l(3);break;case 39:{let t=n[s+1];a.push(48===t||39===t?p("addALink"):f(c())),l(3);break}case 38:a.push(p("addLinks")),l(3);break;case 40:a.push(p("addProperties")),l(3);break;case 41:a.push(p("addDetails")),l(3);break;case 36:a.push(g()),l(3);break;case 9:a.push(m());break;case 12:case 13:{s++;let r=c();l(3),a.push(12===t?{type:"activeStart",signalType:17,actor:r.actor}:{type:"activeEnd",signalType:18,actor:r.actor});break}case 14:case 15:{let n=i[s++].substring(14===t?6:7);r.setDiagramTitle(n),a.push(n);break}case 16:{s++;let t=l(17).trim();r.setAccTitle(t),a.push(t);break}case 18:{s++;let t=l(19).trim();r.setAccDescription(t),a.push(t);break}case 20:{let t=i[s++].trim();r.setAccDescription(t),a.push(t);break}case 21:case 22:case 23:case 28:case 24:case 25:case 26:case 27:case 6:{s++;let r=l(7);b.push(x),x={kind:h_[t],text:r,startType:26===t?32:19,list:[[]],sections:void 0};break}case 31:case 30:case 29:{x.kind!==(31===t?6:30===t?7:8)&&o("'end'"),s++;let r=l(7);(x.sections??=[]).push(a,r),x.list=[];break}case 8:{0===x.kind&&o("'NEWLINE', 'EOF'"),s++;let t=v(x);(x=b.pop()).list.push(t);break}case 0:0!==x.kind&&o("'end'"),r.apply(a);return;default:o("'NEWLINE', 'ACTOR', 'participant', 'note', 'end'")}}}(t,a),a},render:function(t,r,n){return iu(n,i=>(function t(r,n,i,a,s=0,o=!0){var l,c;let d=n.sequence??{},u=i.fontSize??16,h=Math.round(.875*u),f=Math.round(.75*u),p=i.measurer??e$(i.fontFamily,i.fontFamilyMono),g=Array.isArray(i.monospace)&&i.monospace.includes("messages"),m=g?{width:(t,r,n)=>p.width(t,r,4|n)}:p,y=i.icons,v=i.padding??8,b=!1!==d.mirrorActors,x=!0===d.rightAngles,w=Math.min(hz(d,"actorMargin",40),a?8:1/0),$=Math.min(hz(d,"width",64),a?48:1/0),k=hz(d,"height",Math.round(1.5*u)+20),M=Math.min(hz(d,"width",160),a?Math.max(32,((i.maxWidth??320)-2*v)/Math.max(1,r.actors.size)-w-24):1/0),_=Math.max(4,14+hz(d,"messageMargin",35)-35),A=Math.min(hz(d,"noteMargin",10),a?6:1/0),E=Math.min(hz(d,"boxMargin",10),a?6:1/0),S="left"===d.messageAlign?-1:+("right"===d.messageAlign),C=a?6:12,T=a?8:16,I=a?12:20,N=a?6:10,O=r.messages,D=O.length,R=function(t,r){let n=Array(t.length),i=Array(t.length),a=1,s=1,o=!1;for(let l=0;l<t.length;l++){let c=t[l];if(n[l]=NaN,i[l]=!1,26===c.type){let t=c.message;a=t.start||a,s=t.step||s,o=t.visible}else hR(c.type)&&(n[l]=a,i[l]=o||r,a=Math.round((a+s)*100)/100)}return{index:n,shown:i,visible:o}}(O,!0===d.showSequenceNumbers),L=(t,r,n,i=M,s=p)=>{let o=n7(t,!1,s,r,a||n?i:1/0);return a?aK(o,s,Math.max(120,i)):o},z=(t,r,n=M)=>L(t,h,r,n,m),P;if(!0===d.hideUnusedParticipants)for(let t of(P=new Set,O))P.add(t.from).add(t.to);let j=new Int32Array(D+1);j[D]=-1;for(let t=D-1;t>=0;t--)j[t]=hR(O[t].type)?t:j[t+1];let F=[],B=new Map;for(let[t,n]of r.actors){if(P&&!P.has(t))continue;let i=(l=n.type,hS.has(l)?l:"participant"),s=L(n.description,u,n.wrap),o=r.createdActors.get(t),c=r.destroyedActors.get(t),d=void 0===o?-1:j[Math.min(o,D)];d>=0&&O[d].to!==t&&(d=-1);let h=void 0===c?-1:j[Math.min(c,D)];h>=0&&O[h].to!==t&&O[h].from!==t&&(h=-1),B.set(t,F.length),F.push({id:t,actor:n,kind:i,label:s,size:function(t,r,n,i,a=16){if(hT(t))return{w:Math.max(40,r.width+8),h:34+(r.height>0?4+r.height:0)};let s="collections"===t?5:12*("queue"===t);return{w:Math.max(n,r.width+2*a)+s,h:Math.max(i,r.height+20)+5*("collections"===t)}}(i,s,$,k,a?8:void 0),x:0,createAt:d,destroyAt:h,top:0,lifeStart:0,lifeEnd:-1,activations:[]})}let W=F.length-1,H=new Map,U=(t,r,n)=>{if(t<0||r>W)return;let i=t*F.length+r;(H.get(i)??0)<n&&H.set(i,n)},q=t=>R.shown[t]?Math.max(16,p.width(String(R.index[t]),f,0)+8):0,V=Array(D),Y=Array(D),G=(t,r)=>{let n=Y[t];if(!n){if(r===M)return V[t].label;Y[t]=n=new Map([[M,V[t].label]])}let i=n.get(r);return i||n.set(r,i=z(O[t].message,!0,r)),i};for(let t=0;t<D;t++){let r=O[t],n=void 0===r.from?void 0:B.get(r.from),i=void 0===r.to?void 0:B.get(r.to);if(void 0!==n&&void 0!==i&&"string"==typeof r.message){if(2===r.type){let a=L(r.message,h,r.wrap),s=a.width+2*A;0===r.placement?U(n-1,n,s+20+10):1===r.placement?U(n,n+1,s+20+10):n===i?(U(n-1,n,s/2+10),U(n,n+1,s/2+10)):U(Math.min(n,i),Math.max(n,i),s-2*T),V[t]={kind:2,a:n,b:i,label:a,x:0,w:s}}else if(hR(r.type)){let s=z(r.message,r.wrap),o=q(t);if(n===i)U(n,n+1,36+s.width+16+10+o),V[t]={kind:1,a:n,b:i,label:s,x:0,w:0};else{let l=F[i].createAt===t?F[i].size.w/2:0,c=16*!!r.centralConnection;U(Math.min(n,i),Math.max(n,i),(a?Math.min(s.width,Math.max(16,M-16)):s.width)+2*C+10+o+l+c),V[t]={kind:0,a:n,b:i,label:s,x:0,w:0}}}}}let Z=[];for(let t=0;t<=W;t++){let r=F[t].actor.box,n=Z[Z.length-1];r&&n&&n.box===r&&n.last===t-1?n.last=t:r&&Z.push({box:r,first:t,last:t,title:L(r.name,h,r.wrap),grow:0})}let X=Array(Math.max(W,0));for(let t=0;t<W;t++){let r=F[t],n=F[t+1],i=r.actor.box!==n.actor.box?(r.actor.box?E:0)+(n.actor.box?E:0):0;X[t]=Math.max(r.size.w/2+n.size.w/2+w+i,H.get(t*F.length+t+1)??0)}let K=[];for(let[t,r]of H){let n=Math.floor(t/F.length),i=t%F.length;i-n>1&&K.push([n,i,r])}for(let[t,r,n]of(K.sort((t,r)=>t[1]-t[0]-(r[1]-r[0])||t[0]-r[0]),K)){let i=0;for(let n=t;n<r;n++)i+=X[n];if(i>=n)continue;let a=(n-i)/(r-t);for(let n=t;n<r;n++)X[n]+=a}let J=()=>{for(let t=1;t<=W;t++)F[t].x=F[t-1].x+X[t-1]};for(let t of(J(),Z)){let r=F[t.last].x+F[t.last].size.w/2-(F[t.first].x-F[t.first].size.w/2);t.grow=Math.max(0,(t.title.width-r)/2),0!==t.grow&&(t.first>0&&(X[t.first-1]+=t.grow),t.last<W&&(X[t.last]+=t.grow))}let Q=1/0,ee=-1/0,et=(t,r)=>{t<Q&&(Q=t),r>ee&&(ee=r)},er=t=>[F[t.first].x-F[t.first].size.w/2-E-t.grow,F[t.last].x+F[t.last].size.w/2+E+t.grow],en=Array(D),ei=()=>{for(let t of(J(),Q=1/0,ee=-1/0,F))et(t.x-t.size.w/2,t.x+t.size.w/2);for(let t of Z)et(...er(t));let t=[],r=()=>W<0?[0,120]:[F[0].x-I,F[W].x+I];for(let n=0;n<D;n++){let i=O[n],s=i.type,o=void 0===s?void 0:hO.get(s),l=V[n];if(void 0!==o){let r={kind:o,x0:1/0,x1:-1/0,top:0,title:hL,tabW:0,fill:"rect"===o&&"string"==typeof i.message?i.message:"",dividers:[n],dividerY:[],dividerLabels:[]};en[n]=r,t.push(r)}else if(13===s||20===s||28===s)t[t.length-1]?.dividers.push(n);else if(11===s||14===s||16===s||21===s||29===s||31===s||23===s){let i=t.pop();if(!i)continue;if(en[n]=i,i.x0>i.x1&&([i.x0,i.x1]=r()),"rect"!==i.kind){i.tabW=p.width(i.kind,f,1)+14;for(let t=0;t<i.dividers.length;t++){let r=O[i.dividers[t]].message,n=0===t?i.tabW+8:0,s=i.x1-i.x0-16-n,o=r?L(`[${r}]`,h,!0,Math.max(s,a?Math.min(240,M):240)):hL;o.width>s&&(i.x1+=o.width-s),0===t?i.title=o:i.dividerLabels.push(o)}}et(i.x0,i.x1);let s=t[t.length-1];s&&(s.x0=Math.min(s.x0,i.x0-N),s.x1=Math.max(s.x1,i.x1+N))}else if(l){let r=F[l.a],s=F[l.b],o,c;if(2===l.kind){if(0===i.placement)l.x=r.x-10-l.w;else if(1===i.placement)l.x=r.x+10;else if(l.a===l.b)l.x=r.x-l.w/2;else{let t=Math.min(r.x,s.x)-T,n=Math.max(r.x,s.x)+T;(a||i.wrap)&&(l.label=L(i.message,h,!0,Math.max(M,n-t-2*A))),l.w=Math.max(n-t,l.label.width+2*A),l.x=(t+n-l.w)/2}o=l.x,c=l.x+l.w}else 1===l.kind?(o=r.x,c=r.x+10+28+8+l.label.width+q(n)):(o=Math.min(r.x,s.x),c=Math.max(r.x,s.x),(a||i.wrap)&&(l.label=G(n,Math.max(M,c-o-2*C-10))),s.createAt===n&&(s.x>r.x?c+=s.size.w/2:o-=s.size.w/2));et(o,c);let d=t[t.length-1];d&&(d.x0=Math.min(d.x0,o-I),d.x1=Math.max(d.x1,c+I))}}};ei();let ea=!1,es=!1;if(a&&void 0!==i.maxWidth){let t=Math.floor(i.maxWidth)-Math.ceil(ee-Q+2*v)-s,r=new Int32Array(F.length),n=Array(X.length).fill(0),a=[],l=0;for(let i=0;t>0&&i<V.length;i++){let t=V[i];if(t?.kind!==0)continue;let s=z(O[i].message,!1,1/0);if(t.label.lines.length<=s.lines.length)continue;a.push(i),l+=t.label.lines.length;let o=Math.min(t.a,t.b),c=Math.max(t.a,t.b);r[o]++,r[c]--;let d=(s.width-(F[c].x-F[o].x-2*C-10))/(c-o);for(let t=o;t<c;t++)n[t]=Math.max(n[t],d)}let c=0,d=0;for(let t=0;t<X.length;t++)c+=r[t],r[t]=+(c>0),d+=r[t];if(d>0){let i=X.slice(),s=t=>{for(let r=0;r<X.length;r++)X[r]=i[r]+t(r);return ei(),a.map(t=>V[t].label.lines.length)},c=t=>t.reduce((t,r)=>t+r,0),u=n=>r[n]*t/d,h=s(u),f=c(n),p=r=>n[r]*(t-.01)/f;if(o&&d>1&&f>0&&X.some((t,r)=>p(r)>u(r))){let t=h;(es=c(h=s(p))<c(t)&&h.every((r,n)=>r<=t[n]))||(h=s(u))}(ea=c(h)<l)||(X.splice(0,X.length,...i),ei())}}let eo=0;for(let t of Z)eo=Math.max(eo,t.title.height);let el=Z.length>0?E+(eo>0?eo+4:0):0,ec=0;for(let t of F)t.createAt<0&&(ec=Math.max(ec,t.size.h));let ed=el+ec;for(let t of F)t.top=ed-t.size.h,t.lifeStart=ed;let eu=F.map(t=>t.x),eh=[],ef=new Map,ep=t=>{if(t)return ef.has(t)||ef.set(t,e5(no([`fill:${t}`]).shape)),ef.get(t)},eg=t=>{let r=ep(t);return r?` fill="${r}"`:""},em=(t,r)=>{for(let t=eh.length-1;t>=0;t--)if("rect"===eh[t].kind)return eh[t].fill;for(let n of Z){let[i,a]=er(n);if(t>=i&&r<=a)return n.box.fill}},ey=(t,r)=>eg(em(t,r)),ev=(t,r,n,i=!1)=>{if(0===t.width)return"";let a=r-t.width/2,s=((t,r)=>{let n=0,i=eu.length;for(;n<i;){let r=n+i>>1;eu[r]<=t?n=r+1:i=r}return n<eu.length&&eu[n]<r})(a,a+t.width),o=s?`<rect x="${eT(a-3)}" y="${eT(n-t.height/2+2)}" width="${eT(t.width+6)}" height="${eT(t.height-4)}" rx="3" fill="var(--_bg)" stroke="none"/>`:"",l=s?"":ey(a,a+t.width);return o+eI(t,r,n,i?` class="pele-frame-label"${l||' fill="var(--_m)"'} stroke="none"`:l,y)},eb=(t,r=0)=>t.activations.length+r>0?t.x-5:t.x,ex=(t,r=0)=>{let n=t.activations.length+r;return n>0?t.x+5+(n-1)*4:t.x},ew=[],ek=[],eM="",e_="",eA="",eC="",eN="",eO="",eD=(t,r)=>{let n=t.activations.pop(),i=Math.max(r,n+14),a=t.x-5+4*t.activations.length;return et(a,a+10),ek.push(`<rect class="pele-activation" data-id="${eS(t.id)}" x="${eT(a)}" y="${eT(n)}" width="10" height="${eT(i-n)}" rx="2"/>`),i},eR=(t,r)=>{let n=t.x,i=r+16;return t.lifeEnd=i,eO+=`<path class="pele-destroy" data-id="${eS(t.id)}" d="M${eT(n-6)},${eT(i-6)}L${eT(n+6)},${eT(i+6)}M${eT(n+6)},${eT(i-6)}L${eT(n-6)},${eT(i+6)}"/>`,i+6},eL=(t,r,n)=>{let i=t.actor.properties.get("class");return`<g class="pele-node pele-actor pele-actor-${t.kind}${n?" pele-actor-footer":""}${"string"==typeof i?nc(i):""}" data-id="${eS(t.id)}">`+function(t,r,n,i,a,s,o=""){let{w:l,h:c}=i,d=' class="pele-label"';if(hT(t))return function(t,r,n){let i=eT(r);switch(t){case"actor":return`<circle cx="${i}" cy="${eT(n+7)}" r="6"${hA}/><path d="M${i},${eT(n+13)}V${eT(n+24)}M${eT(r-10)},${eT(n+17)}H${eT(r+10)}M${eT(r-8)},${eT(n+34)}L${i},${eT(n+24)}L${eT(r+8)},${eT(n+34)}"${hE}/>`;case"boundary":return`<path d="M${eT(r-19)},${eT(n+6)}V${eT(n+28)}M${eT(r-19)},${eT(n+17)}H${eT(r-8)}"${hE}/><circle cx="${eT(r+3)}" cy="${eT(n+17)}" r="11"${hA}/>`;case"control":return`<circle cx="${i}" cy="${eT(n+21)}" r="11"${hA}/><path d="M${eT(r+5)},${eT(n+5)}L${eT(r-1)},${eT(n+10)}L${eT(r+5)},${eT(n+15)}"${hE}/>`;case"entity":return`<circle cx="${i}" cy="${eT(n+15)}" r="11"${hA}/><path d="M${eT(r-11)},${eT(n+30)}H${eT(r+11)}"${hE}/>`;default:{let t=eT(r-14),i=eT(r+14);return`<path d="M${t},${eT(n+7)}V${eT(n+27)}A14,5 0 0 0 ${i},${eT(n+27)}V${eT(n+7)}A14,5 0 0 0 ${t},${eT(n+7)}Z"${hA}/><path d="M${t},${eT(n+7)}A14,5 0 0 0 ${i},${eT(n+7)}"${hE}/>`}}}(t,r,n)+eI(a,r,n+34+4+a.height/2,d+o,s);let u=r-l/2;if("collections"===t){let t=l-5,r=c-5;return`<rect x="${eT(u+5)}" y="${eT(n)}" width="${eT(t)}" height="${eT(r)}"${hA}${r5}/><rect x="${eT(u)}" y="${eT(n+5)}" width="${eT(t)}" height="${eT(r)}"${hA}${r5}/>`+eI(a,u+t/2,n+5+r/2,d,s)}if("queue"===t){let t=eT(u+6),i=eT(u+l-6),o=eT(n+c),h=eT(c/2);return`<path d="M${t},${eT(n)}H${i}A6,${h} 0 0 1 ${i},${o}H${t}A6,${h} 0 0 1 ${t},${eT(n)}Z"${hA}/><path d="M${i},${eT(n)}A6,${h} 0 0 0 ${i},${o}"${hE}/>`+eI(a,r-3,n+c/2,d,s)}return`<rect x="${eT(u)}" y="${eT(n)}" width="${eT(l)}" height="${eT(c)}"${hA}${r5}/>`+eI(a,r,n+c/2,d,s)}(t.kind,t.x,r,t.size,t.label,y,hT(t.kind)?eg(t.actor.box?.fill):"")+"</g>"},ez=(t,r,n,i)=>`<g class="pele-sequence-number"><rect x="${eT(r-i/2)}" y="${eT(n-8)}" width="${eT(i)}" height="16" rx="8" fill="var(--_l)" stroke="none"/><text x="${eT(r)}" y="${eT(n+.35*f)}" text-anchor="middle" font-size="${f}" fill="var(--_bg)" stroke="none">${eE(String(R.index[t]))}</text></g>`,eP=ed+6;for(let t=0;t<D;t++){let r=O[t],n=r.type,i=V[t],a=en[t];if(17===n){let t=void 0===r.from?void 0:B.get(r.from);void 0!==t&&F[t].activations.push(eP)}else if(18===n){let t=void 0===r.from?void 0:B.get(r.from);void 0!==t&&F[t].activations.length>0&&(eP=Math.max(eP,eD(F[t],eP)))}else if(a&&a.dividers[0]===t)eh.push(a),"rect"===a.kind?(a.top=eP+8,eP=a.top):(a.top=eP+12,eP=a.top+Math.max(20,a.title.height+2));else if(a){eh.pop();let t=eP+12,r=eT(a.x0),n=eT(a.x1-a.x0);if("rect"===a.kind){let i=a.fill?no([`fill:${a.fill}`]).shape:"";ew.push(`<rect class="pele-rect" x="${r}" y="${eT(a.top)}" width="${n}" height="${eT(t-a.top)}"${r9((i?"":' fill-opacity="0.5"')+i)}/>`)}else{let i=`<rect x="${r}" y="${eT(a.top)}" width="${n}" height="${eT(t-a.top)}" fill="none"${r5}/>`;for(let t=0;t<a.dividerY.length;t++){let n=a.dividerY[t],s=a.dividerLabels[t];i+=`<path d="M${r},${eT(n)}H${eT(a.x1)}"${hD}/>`+ev(s,a.x0+8+s.width/2,n+2+s.height/2,!0)}i+=`<rect x="${r}" y="${eT(a.top)}" width="${eT(a.tabW)}" height="20" fill="var(--_s)"${r5}/><text class="pele-frame-kind" x="${eT(a.x0+a.tabW/2)}" y="${eT(a.top+10+.35*f)}" text-anchor="middle" font-size="${f}" font-weight="var(--_hw)" fill="var(--_m)" stroke="none">${a.kind}</text>`+ev(a.title,a.x0+a.tabW+8+a.title.width/2,a.top+Math.max(20,a.title.height)/2,!0),eM+=`<g class="pele-frame pele-frame-${a.kind}">${i}</g>`}eP=t}else if(13===n||20===n||28===n){let t=eh[eh.length-1];if(t){let r=t.dividerLabels[t.dividerY.length];t.dividerY.push(eP+12),eP+=12+(r.height>0?r.height:0)}}else if(i&&2===i.kind){let t=F[i.a],n=i.label.height+2*Math.max(4,A-4),a=eP+10,s=i.x;1===r.placement?s+=ex(t)-t.x:0===r.placement&&(s+=eb(t)-t.x),et(s,s+i.w),eC+=`<g class="pele-note" data-id="i${eS(r.id)}"><rect x="${eT(s)}" y="${eT(a)}" width="${eT(i.w)}" height="${eT(n)}"${r5}/>`+eI(i.label,s+i.w/2,a+n/2,' class="pele-label" stroke="none" fill="var(--_fg)"',y)+"</g>",eP=a+n}else if(i){let a=hI[n],s=F[i.a],o=F[i.b],l=i.label,d=q(t),u=0;for(let n=t+1;n<D;n++){let t=O[n].type;if(17===t)O[n].from===r.to&&u++;else if(18!==t&&59!==t&&60!==t)break}let h=a.bottom?1:-1,f=a.dotted?hD:"",p=r.centralConnection,g=59===p||61===p,m=60===p||61===p,v,b="var(--_l)",w=(t,r)=>`<circle class="pele-central" cx="${eT(t)}" cy="${eT(r)}" r="4" fill="${b}" stroke="none"/>`,$=a.atStart&&!a.atEnd,k=1===(c=a.head)?7:4*(2===c),M="",A;if(1===i.kind){let n=eP+_+Math.max(0,(l.height-22)/2),i=n+22,o=m?s.x+4:ex(s),c=g?s.x+4:ex(s,u),p=Math.max(o,c)+28+d/2;b=(v=ep(em(s.x,p)))??b,m&&(M+=w(s.x,n)),g&&(M+=w(s.x,i)),d>0&&(M+=ez(t,$?c:o,$?i:n,d),$?c+=d/2:o+=d/2);let E=(a.atStart?hj(a.head,o,n,-1,h,b):"")+(a.atEnd?hj(a.head,c,i,-1,-h,b):""),S=eT(o+(a.atStart?k:0)),C=eT(c+(a.atEnd?k:0));M=`<path d="${x?`M${S},${eT(n)}H${eT(p)}V${eT(i)}H${C}`:`M${S},${eT(n)}H${eT(p-6)}A6,6 0 0 1 ${eT(p)},${eT(n+6)}V${eT(i-6)}A6,6 0 0 1 ${eT(p-6)},${eT(i)}H${C}`}"${f}/>`+E+M,et(s.x,p+8+l.width),l.width>0&&(eA+=`<g class="pele-edge-label" data-id="i${eS(r.id)}">${eI(l,p+8+l.width/2,(n+i)/2,ey(p+8,p+8+l.width),y)}</g>`),A=Math.max(i,(n+i)/2+l.height/2)}else{let n=o.x>s.x?1:-1,i=o.createAt===t;b=(v=ep(em(Math.min(s.x,o.x),Math.max(s.x,o.x))))??b,A=eP+_+Math.max(l.height>0?l.height+2:6,i?o.size.h/2-_+6:0);let c=n>0?ex(s):eb(s),p=n>0?eb(o,u):ex(o,u);if(i&&(o.top=A-o.size.h/2,o.lifeStart=o.top+o.size.h,p=o.x-n*(hT(o.kind)?18:o.size.w/2+1)),m&&(M+=w(s.x,A),c=s.x+4*n),g&&(M+=w(o.x,A),p=o.x-4*n),d>0)if($){let r=g?p-n*(d/2+2):p;M+=ez(t,r,A,d),p=r-n*d/2}else{let r=m?c+n*(d/2+2):c;M+=ez(t,r,A,d),c=r+n*d/2}let y=(a.atStart?hj(a.head,c,A,-n,h*n,b):"")+(a.atEnd?hj(a.head,p,A,n,h*n,b):""),x=c+(a.atStart?n*k:0),E=p-(a.atEnd?n*k:0);if(M=`<path d="M${eT(x)},${eT(A)}H${eT(E)}"${f}/>`+y+M,l.width>0){let t=Math.min(c,p),n=Math.max(c,p),i=S<0?t+C+l.width/2:S>0?n-C-l.width/2:(t+n)/2;et(i-l.width/2,i+l.width/2),eA+=`<g class="pele-edge-label" data-id="i${eS(r.id)}">${ev(l,i,A-4-l.height/2)}</g>`}i&&(eP=A+o.size.h/2-6)}e_+=`<g class="pele-edge pele-message" data-id="i${eS(r.id)}"${v?` stroke="${v}"`:""}>${M}</g>`,eP=Math.max(eP,A),s.destroyAt===t&&(eP=Math.max(eP,eR(s,A))),o.destroyAt===t&&o!==s&&(eP=Math.max(eP,eR(o,A)))}}for(let t of(eP+=20,F))for(;t.activations.length>0;)eD(t,eP);let ej=eP;if(b){let t=0;for(let r of F)r.lifeEnd>=0||(t=Math.max(t,r.size.h),eN+=eL(r,eP,!0));ej=eP+t}let eF="";for(let t of F){eN+=eL(t,t.top,!1);let r=t.lifeEnd>=0?t.lifeEnd:eP;r>t.lifeStart&&(eF+=`<path class="pele-lifeline" data-id="${eS(t.id)}" d="M${eT(t.x)},${eT(t.lifeStart)}V${eT(r)}"/>`)}let eB="";for(let t of Z){let[r,n]=er(t),i="transparent"===t.box.fill?"":no([`fill:${t.box.fill}`]).shape;eB+=`<g class="pele-cluster pele-box"${t.box.name?` data-id="${eS(t.box.name)}"`:""}><rect x="${eT(r)}" y="0" width="${eT(n-r)}" height="${eT(ej+E)}" fill="var(--_a)" stroke="var(--_b)"${r9((i?"":' fill-opacity="0.5"')+i)}/>`+eI(t.title,(r+n)/2,E/2+2+t.title.height/2,` class="pele-cluster-label"${eg(t.box.fill)||' fill="var(--_m)"'}`,y)+"</g>"}Z.length>0&&(ej+=E);let eW=0,eH="",eU=io(i),eq=ad(r.title,p,u,a?eU:1/0),eV=a?aK(eq,p,Math.max(120,eU)):eq;if(Q>ee&&et(0,Math.max(eV.width,40)),eV.width>0){let t=(Q+ee)/2;et(t-eV.width/2,t+eV.width/2),eW=-eV.height-12,eH=eI(eV,t,eW+eV.height/2,' class="pele-title" font-weight="var(--_tw)"',y)}let eY=Math.ceil(ee-Q+2*v);if(ea&&eY>i.maxWidth)return t(r,n,i,a,es?s:s>0?1/0:eY-Math.floor(i.maxWidth),!1);let eG=Math.ceil(ej-eW+2*v);return{svg:np("sequence",eY,eG,u,i,r,`<g transform="translate(${eT(v-Q)},${eT(v-eW)})">`+eH+(eB?`<g class="pele-boxes" font-size="${h}">${eB}</g>`:"")+(ew.length>0?`<g class="pele-rects" fill="var(--_a)">${ew.reverse().join("")}</g>`:"")+(eF?`<g class="pele-lifelines" fill="none" stroke="var(--_b)">${eF}</g>`:"")+(ek.length>0?`<g class="pele-activations" fill="var(--_s)" stroke="var(--_b)">${ek.reverse().join("")}</g>`:"")+(eM?`<g class="pele-frames" font-size="${h}" stroke="var(--_b)">${eM}</g>`:"")+(e_?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${e_}</g>`:"")+(eO?`<g class="pele-destroys" fill="none" stroke="var(--_l)" stroke-width="1.5" stroke-linecap="round">${eO}</g>`:"")+(eA?`<g class="pele-edge-labels" font-size="${h}"${g?` font-family="${r3}"`:""}>${eA}</g>`:"")+(eC?`<g class="pele-notes" font-size="${h}" fill="var(--_a)" stroke="var(--_b)">${eC}</g>`:"")+(eN?`<g class="pele-nodes">${eN}</g>`:"")+"</g>"),width:eY,height:eG,links:[]}})(t,r,n,i))}},{type:"gitGraph",parse:(t,r,n)=>(function(t,r,n){let i=r.gitGraph,a="string"==typeof i?.mainBranchName?i.mainBranchName:"main",s="number"==typeof i?.mainBranchOrder?i.mainBranchOrder:0,o=new Map,l=new Map([[a,null]]),c=new Map([[a,s]]),d=[],u=null,h=a,f="LR",p=0,g=()=>{for(let t=p+1;;t+=0x9e3779b1){let r=`${p}-${(Math.imul(t,0x9e3779b1)>>>0).toString(16).padStart(8,"0").slice(0,7)}`;if(!o.has(r))return r}},m=t=>{u=t,o.set(t.id,t),l.set(h,t.id)},y=t=>{l.has(t)||cp(`Trying to checkout branch which is not yet created. (Help try using "branch ${t}")`),h=t;let r=l.get(t);u=r?o.get(r)??null:null};var v={setDirection(t){f=t},commit({msg:t,id:r,type:n,tags:i}){let a={id:r||g(),message:t,seq:p++,type:n??0,tags:i?[...i]:[],parents:null===u?[]:[u.id],branch:h};o.has(a.id)&&d.push(`Commit ID ${a.id} already exists`),m(a)},branch({name:t,order:r}){l.has(t)&&cp(`Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ${t}")`),l.set(t,null!==u?u.id:null),c.set(t,r),y(t)},merge({branch:t,id:r,type:n,tags:i}){let a=l.get(h),s=l.get(t),c=a?o.get(a):void 0,d=s?o.get(s):void 0;c&&d&&c.branch===t&&cp(`Cannot merge branch '${t}' into itself.`),h===t&&cp('Incorrect usage of "merge". Cannot merge a branch to itself'),void 0===c&&cp(`Incorrect usage of "merge". Current branch (${h})has no commits`),l.has(t)||cp(`Incorrect usage of "merge". Branch to be merged (${t}) does not exist`),void 0===d&&cp(`Incorrect usage of "merge". Branch to be merged (${t}) has no commits`),c===d&&cp('Incorrect usage of "merge". Both branches have same head'),r&&o.has(r)&&cp(`Incorrect usage of "merge". Commit with id:${r} already exists, use different custom id`),m({id:r||g(),message:`merged branch ${t} into ${h}`,seq:p++,parents:null===u?[]:[u.id,s||""],branch:h,type:3,customType:n,customId:!!r,tags:i?[...i]:[]})},cherryPick({id:t,targetId:r,tags:n,parent:i}){let a=t?o.get(t):void 0;if(void 0===a&&cp('Incorrect usage of "cherryPick". Source commit id should exist and provided'),i&&!a.parents.includes(i)&&cp("Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit."),3!==a.type||i||cp("Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified."),r&&o.has(r))return;a.branch===h&&cp('Incorrect usage of "cherryPick". Source commit is already on current branch');let s=l.get(h);s&&o.has(s)||cp(`Incorrect usage of "cherry-pick". Current branch (${h})has no commits`),m({id:g(),message:`cherry-picked ${a.message} into ${h}`,seq:p++,parents:null===u?[]:[u.id,a.id],branch:h,type:4,tags:n?n.filter(Boolean):[`cherry-pick:${a.id}${3===a.type?`|parent:${i}`:""}`]})},checkout:y};for(let r of(t.dir&&v.setDirection(t.dir),t.statements)){var b=r,x=v;switch(b.$type){case"Commit":x.commit({id:b.id,msg:b.message??"",type:void 0!==b.type?cg(b.type):0,tags:b.tags??void 0});break;case"Branch":x.branch({name:b.name,order:b.order??0});break;case"Merge":x.merge({branch:b.branch,id:b.id??"",type:void 0!==b.type?cg(b.type):void 0,tags:b.tags??void 0});break;case"Checkout":x.checkout(b.branch);break;case"CherryPicking":x.cherryPick({id:b.id,targetId:"",tags:b.tags?.length===0?void 0:b.tags,parent:b.parent})}}let w=[...c].map(([t,r],n)=>({name:t,order:r??parseFloat(`0.${n}`)})).sort((t,r)=>t.order-r.order).map(t=>t.name);return{type:"gitGraph",title:t.title||n,accTitle:t.accTitle?t.accTitle.replace(/^\s+/g,""):void 0,accDescr:t.accDescr?t.accDescr.replace(/\n\s+/g,`
|
|
133
|
+
`):void 0,direction:f,commits:o,branches:l,lanes:w,currentBranch:h,head:u,warnings:d}})(function(t){let r=new iG(iE(t,cb,"gitGraph"),cb,"gitGraph"),n={$type:"GitGraph",statements:[]},i=()=>{if(-1!==r.kind)for(26!==r.kind&&r.fail("a line break or the end of input");26===r.kind;)r.i++},a=()=>31===r.kind?r.take():25===r.kind?iY(r.take()):r.fail("a branch name"),s=()=>iY(r.expect(25)),o=()=>(8!==r.kind&&5!==r.kind&&2!==r.kind&&r.fail("NORMAL, REVERSE, or HIGHLIGHT"),r.take());for(;26===r.kind;)r.i++;if(!r.accept(1)){r.expect(3);let t=r.kinds[r.i+1];(17===r.kind||18===r.kind||19===r.kind)&&20===t?(n.$type="Direction",n.dir=r.take(),r.i++):r.accept(20)}for(;-1!==r.kind;)switch(r.kind){case 26:r.i++;break;case 21:n.accDescr=iq(r.take()),i();break;case 22:n.accTitle=iU(r.take()),i();break;case 23:n.title=iH(r.take()),i();break;case 7:{r.i++;let t={$type:"Commit",tags:[]};for(;;)if(r.accept(16))t.id=s();else if(r.accept(15))t.tags.push(s());else if(r.accept(12))t.type=o();else if(r.accept(14)||25===r.kinds[r.i])t.message=s();else break;i(),n.statements.push(t);break}case 9:{r.i++;let t={$type:"Branch",name:a()};r.accept(10)&&(t.order=parseInt(r.expect(24))),i(),n.statements.push(t);break}case 13:{r.i++;let t={$type:"Merge",branch:a(),tags:[]};for(;;)if(r.accept(16))t.id=s();else if(r.accept(15))t.tags.push(s());else if(r.accept(12))t.type=o();else break;i(),n.statements.push(t);break}case 4:case 11:{r.i++;let t={$type:"Checkout",branch:a()};i(),n.statements.push(t);break}case 0:{r.i++;let t={$type:"CherryPicking",tags:[]};for(;;)if(r.accept(16))t.id=s();else if(r.accept(15))t.tags.push(s());else if(r.accept(6))t.parent=s();else break;i(),n.statements.push(t);break}default:r.fail("a statement, a title, or a line break")}return n}(t),r,n),render:function(t,r,n){return"LR"!==t.direction?cC(t,r,n,t.direction):ic(n,i=>cC(t,r,n,i?"TB":"LR"))}},{type:"c4",parse(t,r,n){let i=new aj;return n&&(i.title=n),function(t,r){let{types:n,starts:i,ends:a}=function(t){let r=t.length,n=[],i=[],a=[],s=0,o=9,l=0,c=!1,d=-2,u=-1,h=0,f=(t,r,s)=>{n.push(t),i.push(r),a.push(s),l=s},p=n=>{for(;n<r&&V(t.charCodeAt(n));)n++;return n},g=(n,i)=>{let a=t.indexOf(n,i);return -1===a?r:a},m=(n,i)=>{let a=l+n.length;if(!t.startsWith(n,l)||!V(t.charCodeAt(a)))return!1;let s=++a;for(;a<r;){let r=t.charCodeAt(a);if(35===r||10===r||59===r)break;a++}return a!==s&&(f(i,l,a),!0)};for(;;){if(c){f(0,r,r);break}l>=r&&(c=!0);let n=t.charCodeAt(l);if(0===s){if(l>=r){f(64,r,r);continue}if(-1!==d&&l>=h&&(d<l&&(d=t.indexOf("direction",l)),-1!==d&&(u<l&&(aH.lastIndex=l,u=aH.test(t)?aH.lastIndex-1:r),d<u))){let r=!1;for(let n=0;n<4&&!r;n++)aW[n].lastIndex=l,aW[n].test(t)&&(f(2+n,l,aW[n].lastIndex),r=!0);if(r)continue;h=u}if(116===n){if(aU.lastIndex=l,aU.test(t)){l=aU.lastIndex;continue}if(m("title",6))continue}if(97===n){if(m("accDescription",7))continue;let r=t.startsWith("accTitle",l);if(r||t.startsWith("accDescr",l)){let n=p(l+8),i=t.charCodeAt(n);if(58===i){f(r?8:10,l,p(n+1)),o=r?9:11,s=7;continue}if(123===i&&!r){l=p(n+1),s=8;continue}}}if(37===n&&37===t.charCodeAt(l+1)){let n=g(`
|
|
134
|
+
`,l+2);for(;n<r&&(10===t.charCodeAt(n)||13===t.charCodeAt(n));)n++;l=n;continue}if(V(n)){let n=l,i=-1;for(;n<r;){let r=t.charCodeAt(n);if(!V(r))break;10===r&&(i=n),n++}-1!==i?f(13,l,i+1):l=n;continue}if(123===n){f(62,l,l+1);continue}if(125===n){f(63,l,l+1);continue}if(J(n)){let n=l+1;for(;n<r&&J(t.charCodeAt(n));)n++;let i=n-l<=19?aB.get(t.slice(l,n)):void 0;if(void 0!==i){i>18&&(s=1),f(i,l,n);continue}}f(1,l,l);break}if(1===s){if(l>=r)f(57,r,r);else if(40===n){let r=l+1;for(;32===t.charCodeAt(r);)r++;44===t.charCodeAt(r)?f(58,l,r+1):l++,s=2}else if(41===n)l++,s=0;else{f(1,l,l);break}continue}if(2===s){if(l>=r)continue;if(41===n)l++,s=0;else if(44===n)44===t.charCodeAt(l+1)?f(58,l,l+2):l++;else{let r=l;for(;32===t.charCodeAt(r);)r++;let n=t.charCodeAt(r);34===n?34===t.charCodeAt(r+1)?f(58,l,r+2):(l=r+1,s=3):36===n?(l=r+1,s=4):f(59,l,g(",",l))}continue}if(3===s){34===n?(l++,s=2):f(59,l,g('"',l));continue}if(4===s){f(60,l,g("=",l)),s=5;continue}if(5===s){if(l>=r)continue;let i=l+1;if(61===n)for(;32===t.charCodeAt(i);)i++;if(61!==n||34!==t.charCodeAt(i)){f(1,l,l);break}l=i+1,s=6;continue}if(6===s){if(l>=r)continue;34===n?(l++,s=2):f(61,l,g('"',l));continue}if(7===s){f(o,l,g(`
|
|
135
|
+
`,l)),s=0;continue}125===n?(l++,s=0):f(12,l,g("}",l))}return{types:n,starts:i,ends:a}}(t),s=0,o=r=>t.slice(i[r],a[r]),l=r=>{let a=n[s];throw 1===a?d("c4",t,i[s],"",!0):d("c4",t,i[s],`Expecting ${r}, got '${aF[a]}'`)},c=t=>{n[s]!==t&&l(`'${aF[t]}'`),s++},u=t=>{6===t?r.setTitle(o(s++).substring(6)):7===t?r.setAccDescription(o(s++).substring(15)):12===t?r.setAccDescription(o(s++).trim()):(s++,8===t?(9!==n[s]&&l("'acc_title_value'"),r.setTitle(o(s++).trim())):(11!==n[s]&&l("'acc_descr_value'"),r.setAccDescription(o(s++).trim())))},h=t=>{s++;let i=(()=>{let t=[];for(;;){let r=n[s];if(59===r)t.push(o(s++).trim());else if(58===r)t.push(""),s++;else if(60===r)61!==n[++s]&&l("'STR_VALUE'"),t.push({key:o(s-1).trim(),value:o(s).trim()}),s++;else break}return 0===t.length&&l("'STR', 'STR_KEY', 'ATTRIBUTE', 'ATTRIBUTE_EMPTY'"),t})();if(t<=26)r.addPersonOrSystem(aq[t-19],i);else if(t<=32)r.addContainer(aq[t-19],i);else if(t<=38)r.addComponent(aq[t-19],i);else{if(t<=45)return 39===t?i.splice(2,0,"ENTERPRISE"):40===t?i.splice(2,0,"SYSTEM"):42===t&&i.splice(2,0,"CONTAINER"),t>=43?r.addDeploymentNode(aY[t-43],i):42===t?r.addContainerBoundary(i):r.addPersonOrSystemBoundary(i),62===n[s]?(s++,c(13)):13===n[s]?(s++,c(62),13===n[s]&&s++):l("'NEWLINE', 'LBRACE'"),!0;t<=53?(53===t&&i.splice(0,1),r.addRel(aV[t-46],i)):54===t?r.updateElStyle("update_el_style",i):55===t?r.updateRelStyle("update_rel_style",i):r.updateLayoutConfig("update_layout_config",i)}return!1},f=n[s];(f<14||f>18)&&l("'direction_tb', 'direction_bt', 'direction_rl', 'direction_lr', 'C4_CONTEXT', 'C4_CONTAINER', 'C4_COMPONENT', 'C4_DYNAMIC', 'C4_DEPLOYMENT'"),s++,c(13);let p=0,g=0;for(;;){let t=n[s];if(3===g||4===g){if(13===t){s++,g=2;continue}if(3===g&&aG(t)){g=1;continue}}else if(aG(t)){h(t)?(p++,g=1):g=4;continue}else{if((6===t||7===t||8===t||10===t||12===t)&&1!==g){u(t),g=3;continue}2!==g&&l("'title', 'accDescription', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'PERSON', 'REL'")}if(p>0)63!==t&&l("'NEWLINE', 'RBRACE'"),s++,r.popBoundaryParseStack(),p--,g=4;else{64!==t&&l("'NEWLINE', 'EOF'"),s++,c(0),r.setC4Type(o(0));return}}}(t,i),i},render:function(t,r,n){return iu(n,i=>{if(!i)return sa(t,r,n,!1)[0];let[a,s]=sa(t,r,n,!0,36);for(let i=60;s>0&&i<=108;i+=24){let[o,l]=sa(t,r,n,!0,i);l<s&&([a,s]=[o,l])}return a})}},{type:"block",math:!0,parse(t,r,n){let i=new ai;return i.title=n,function(t,r){let{types:n,texts:i,starts:a}=function(t){let r=t.length,n=[],i=[],a=[],s=[],o=0,l=0,c=(t,r,s)=>(n.push(t),i.push(r),a.push(l),l=s,!0),d=(r,n)=>c(r,t.slice(l,n),n),u=t=>{s.push(o),o=t},h=()=>{s.length>0&&(o=s.pop())},f=n=>{for(;n<r&&V(t.charCodeAt(n));)n++;return n},p=n=>{for(;n<r;){let r=t.charCodeAt(n);if(r<48||r>57)break;n++}return n},g=n=>{for(;n<r&&J(t.charCodeAt(n));)n++;return n},m=r=>t.startsWith(r,l)&&!J(t.charCodeAt(l+r.length)),y=()=>(96===t.charCodeAt(l+1)?(u(2),l+=2):(u(1),l++),!0),v=r=>{if(46!==t.charCodeAt(r))return -1;do r++;while(46===t.charCodeAt(r));if(45!==t.charCodeAt(r))return -1;let n=t.charCodeAt(r+1);return 120===n||111===n||62===n?r+2:r+1},b=r=>{let n=t.charCodeAt(r);(120===n||111===n||60===n)&&r++;let i=t.charCodeAt(r);if(46===i)return v(r);if(45!==i&&61!==i)return -1;let a=r+1;for(;t.charCodeAt(a)===i;)a++;if(a-r==1)return 45===i?v(a):-1;let s=t.charCodeAt(a);return 120===s||111===s||62===s?a+1:a-r>=3?a:-1},x=()=>{let r=b(l);if(r>=0)return d(33,f(r));let n=60===t.charCodeAt(l)?l+1:l,i=t.charCodeAt(n),a=t.charCodeAt(n+1);return(45===i&&(45===a||46===a)||61===i&&61===a)&&(u(6),d(34,f(n+2)))},w=n=>{let i=t.indexOf(`
|
|
136
|
+
`,l);return -1===i&&(i=r),h(),d(n,i)},$=(r,n)=>{let i=g(l);if(i===l)return!1;for(;44===t.charCodeAt(i);){let t=f(i+1),r=g(t);if(r===t)break;i=r}return o=n,d(r,i)},k=n=>{let i;if(V(n))return l=f(l+1),!0;switch(n){case 98:if(t.startsWith("block",l)){if(m("block-beta"))return d(2,l+10);if(58===t.charCodeAt(l+5))return d(3,l+6);if(!J(t.charCodeAt(l+5)))return d(2,l+5)}break;case 99:if(t.startsWith("columns",l)){if((i=f(l+7))>l+7){if(t.startsWith("auto",i)&&!J(t.charCodeAt(i+4)))return c(4,"-1",i+4);let r=p(i);if(r>i)return c(4,t.slice(i,r),r)}}else if(t.startsWith("class",l)){let r=t.startsWith("Def",l+5),n=r?l+8:l+5;if((i=f(n))>n)return u(r?7:9),d(r?11:15,i)}break;case 34:return y();case 115:if(t.startsWith("space",l)){if(58===t.charCodeAt(l+5)){let r=p(l+6);if(r>l+6)return c(7,t.slice(l+6,r),r)}if(!J(t.charCodeAt(l+5)))return c(7,"1",l+5)}else if(t.startsWith("style",l)&&(i=f(l+5))>l+5)return u(11),d(18,i);break;case 100:if(m("default"))return d(8,l+7);break;case 108:if(m("linkStyle"))return d(9,l+9);break;case 105:if(m("interpolate"))return d(10,l+11);break;case 97:if(t.startsWith("accTitle",l)){if(i=f(l+8),58===t.charCodeAt(i))return u(13),d(21,f(i+1))}else if(t.startsWith("accDescr",l)){i=f(l+8);let r=t.charCodeAt(i);if(58===r)return u(14),d(23,f(i+1));if(123===r)return u(15),l=f(i+1),!0}break;case 101:if(m("end"))return d(26,f(l+3));break;case 45:return 41===t.charCodeAt(l+1)?(u(3),d(27,l+2)):x();case 61:return x();case 60:return 91===t.charCodeAt(l+1)?(u(4),d(29,l+2)):x();case 40:{let r=t.charCodeAt(l+1),n=45===r||91===r?2:40===r?40===t.charCodeAt(l+2)?3:2:1;return u(3),d(27,l+n)}case 41:case 123:return u(3),d(27,t.charCodeAt(l+1)===n?l+2:l+1);case 62:return u(3),d(27,l+1);case 91:{let r=t.charCodeAt(l+1);return u(3),d(27,91===r||124===r||40===r||92===r||47===r?l+2:l+1)}case 58:{let r=p(l+1);return r>l+1&&c(36,t.slice(l+1,r),r)}}for(i=l;i<r;){let r=t.charCodeAt(i);if(r<128?1===ao[r]:V(r))break;i++}return i>l&&d(32,i)},M=r=>{let n=t.charCodeAt(l+1),i=0;switch(r){case 34:return y();case 40:i=45===n?2:40===n?40===t.charCodeAt(l+2)?3:2:1;break;case 41:i=41===n?41===t.charCodeAt(l+2)?3:2:93===n?2:1;break;case 125:i=125===n?2:1;break;case 45:i=2*(41===n);break;case 93:i=93===n||41===n||62===n?2:1;break;case 92:case 47:i=2*(93===n)}return 0!==i&&(h(),d(28,l+i))},_=r=>{if(41===r)return h(),h(),c(30,"]>",f(l+1));let n=f(44===r?l+1:l);for(let i of as)if(t.startsWith(i,n)){let a=f(n+i.length);return c(31,t.slice(44===r?n:l,a),a)}return!1};for(;;){if(l>=r){let t=-1;switch(o){case 0:t=37;break;case 1:t=6;break;case 8:t=14;break;case 10:t=17;break;case 12:t=20;break;case 13:t=22;break;case 14:t=24;break;case 15:t=25}l=r,-1!==t&&c(t,"",r);break}let s=t.charCodeAt(l),p=!0;switch(o){case 0:p=k(s);break;case 1:if(34===s)h(),l++;else{let n=t.indexOf('"',l);d(6,-1===n?r:n)}break;case 2:if(96===s)(p=34===t.charCodeAt(l+1))&&(h(),l+=2);else if(34===s)p=!1;else{let n=l+1;for(;n<r;){let r=t.charCodeAt(n);if(96===r||34===r)break;n++}d(5,n)}break;case 3:p=M(s);break;case 4:if(34===s)y();else if(93===s&&62===t.charCodeAt(l+1)){let r=f(l+2);(p=40===t.charCodeAt(r))&&(u(5),l=r+1)}else p=!1;break;case 5:p=_(s);break;case 6:if(34===s)96===t.charCodeAt(l+1)?y():(d(35,l+1),u(1));else{let t=b(f(l));(p=t>=0)&&(h(),d(33,f(t)))}break;case 7:{let r=12,n=t.startsWith("DEFAULT",l)?l+7:l,i=f(n);(n===l||i===n)&&(r=13,i=f(n=g(l))),(p=n>l&&i>n)&&(o=8,d(r,i));break}case 8:w(14);break;case 9:p=$(16,10);break;case 10:w(17);break;case 11:p=$(19,12);break;case 12:w(20);break;case 13:w(22);break;case 14:w(24);break;case 15:if(125===s)h(),l++;else{let n=t.indexOf("}",l);d(25,-1===n?r:n)}}if(!p)return n.push(1),i.push(""),a.push(l),{types:n,texts:i,starts:a}}return n.push(0),i.push(""),a.push(r),{types:n,texts:i,starts:a}}(t),s=0,o=r=>{let i=n[s];throw 1===i?d("block",t,a[s],"",!0):d("block",t,a[s],`Expecting ${r}, got '${aa[i]}'`)},l=t=>(n[s]!==t&&o(`'${aa[t]}'`),i[s++]),c=()=>{let t=l(32);if(27===n[s]){let r=i[s++];return{id:t,label:l(6),typeStr:r+l(28)}}if(29===n[s]){let r=i[s++],a=l(6),o=[l(31)];for(;31===n[s];)o.push(i[s++]);return{id:t,label:a,typeStr:r+l(30),directions:o}}return{id:t}},u=()=>{let t=c(),a=36===n[s]?parseInt(i[s++],10):1,o={id:t.id,label:t.label,type:r.typeStr2Type(t.typeStr),directions:t.directions,widthInColumns:a},d;for(;33===n[s]||34===n[s];){let t="";34===n[s++]&&(l(35),t=l(6),l(33));let a=i[s-1],u=c(),h=r.edgeStrToEdgeData(a),f=r.edgeStrToEdgeStartData(a),p=r.edgeStrToThickness(a),g=r.edgeStrToPattern(a);d??=[{id:o.id,label:o.label,type:o.type,directions:o.directions}],o={id:u.id,label:u.label,type:r.typeStr2Type(u.typeStr),directions:u.directions},d.push({id:d[d.length-1].id+"-"+u.id,start:d[d.length-1].id,end:u.id,label:t,type:"edge",thickness:p,pattern:g,directions:u.directions,arrowTypeEnd:h,arrowTypeStart:f},o)}return d??o};l(2);let h=[],f=[];for(;;)switch(n[s]){case 32:f.push(u());break;case 4:f.push({type:"column-setting",columns:parseInt(i[s++],10)});break;case 7:{let t=parseInt(i[s++],10);f.push({id:r.generateId(),type:"space",label:"",width:t,children:[]});break}case 2:s++,h.push({list:f,header:void 0}),f=[];break;case 3:32!==n[++s]&&o("'NODE_ID'"),h.push({list:f,header:u()}),f=[];break;case 26:{let t=h.pop();if(void 0===t||0===f.length)return o(al);s++;let n=r.generateId(),i=ac(f);(f=t.list).push(void 0===t.header?{id:n,type:"composite",label:"",children:i}:{...t.header,type:"composite",children:i});break}case 11:{s++;let t=l(13).trim();f.push({type:"classDef",id:t,css:l(14).trim()});break}case 15:{s++;let t=l(16).trim();f.push({type:"applyClass",id:t,styleClass:l(17).trim()});break}case 18:{s++;let t=l(19).trim();f.push({type:"applyStyles",id:t,stylesStr:l(20).trim()});break}case 37:h.length>0&&o(al+", 'end'"),0===f.length&&o(al),r.setHierarchy(ac(f));return;default:o(0===f.length?al:al+(h.length>0?", 'end'":", 'EOF'"))}}(t,i),i},render:function(t,r,n){return iu(n,i=>(function(t,r,n,i){let s=n.fontSize??16,o=Math.round(.875*s),l=n.measurer??e$(n.fontFamily,n.fontFamilyMono),c=n.padding??8,d=n.icons,u=r.block?.padding,h=Math.min("number"==typeof u&&u>=0?Math.min(u,200):12,i?6:1/0),f=i?80:200,p=(r,a)=>{let o=r.type,c="space"===o?no(ay):(r=>{let n=[],i=t=>{for(let r of t)for(let t of r.split(";"))n.push(t)};for(let n of r.classes&&r.classes.length>0?r.classes:aw){let r=t.classes.get(n);r&&i(r.styles)}return r.styles&&i(r.styles),no(n)})(r),d=!!c.bold|2*!!c.italic,u=c.fontSize??s,p=0,g="",m,y=0,v=0,b=0,x=0,w=0,$=0;if("space"===o)p=3,m=n7(void 0,!1,l,u,f);else if("composite"===o)p=2,b=(m=n7(r.label,!1,l,u,i?io(n):4e3,d)).height>0?m.height+4:0,y=m.width+2*h,v=b+2*h;else if("block_arrow"===o){p=1;let t=!0;for(let n of(m=n7(r.label,!1,l,u,f,d)).lines)for(let r of n)(void 0!==r.icon||""!==r.text.trim())&&(t=!1);x=function(t){let r=0;if(t)for(let n of t)switch(n.trim()){case"right":r|=1;break;case"left":r|=2;break;case"up":r|=4;break;case"down":r|=8;break;case"x":r|=3;break;case"y":r|=12}return r}(r.directions);let n=t?ap(x,0,0):ap(x,m.width,m.height);y=n.w,v=n.h,w=n.dx,$=n.dy}else{let t=nO(g=a$.get(o??"")??"rect",(m=n7(r.label,!1,l,u,f,d)).width,m.height);y=t.w,v="cyl"===g?Math.max(t.h,m.height+40):t.h,$=t.dy}return{children:[],columns:2===p?r.columns??-1:-1,span:3===p?1:r.widthInColumns??1,space:3===p,head:b,nw:y,nh:v,col:0,row:0,cols:0,heights:ab,rowGaps:ax,colGaps:ax,x:0,y:0,w:0,h:0,block:r,kind:p,index:a,shape:g,label:m,style:c,mask:x,dx:w,dy:$,bw:0,bh:0}},g=p(t.root,0);g.nw=0,g.nh=0;let m=[g],y=[],v=new Map;for(let t=0;t<m.length;t++){let r=m[t];if(2===r.kind)for(let t of r.block.children??av){let n=p(t,m.length);r.children.push(n),y[n.index]=r,m.push(n),3!==n.kind&&v.set(t.id,n)}}let b=[],x=[],w=m.map(t=>t.nw),$=()=>{for(let t of m)t.nw=w[t.index];let t=function(t,r){let n=[t];for(let t=0;t<n.length;t++)for(let r of n[t].children)n.push(r);for(let t=n.length-1;t>=0;t--){let i=n[t];i.children.length>0&&function(t,r,n){let i=t.columns,s=[],o=0,l=0,c=0,d=0;for(let n of t.children){let{px:t,py:u}=function(t,r){if(0===t||!Number.isInteger(t))throw new a("Columns must be an integer !== 0.","semantic",{type:"block"});if(r<0||!Number.isInteger(r))throw new a("Position must be a non-negative integer."+r,"semantic",{type:"block"});return t<0?{px:r,py:0}:{px:r%t,py:Math.floor(r/t)}}(i,o),h=n.span>=1?Math.min(n.span,1e3):1;if(i>0&&h>i-t&&(h=i-t),n.span=h,n.col=t,n.row=u,o+=h,t+h>l&&(l=t+h),u===s.length&&s.push(0),0===n.children.length?s[u]=-1:s[u]>=0&&n.nh>s[u]&&(s[u]=n.nh),n.space)continue;let f=(n.nw-r*(h-1))/h;f>c&&(c=f),n.nh>d&&(d=n.nh)}let u=(s.length-1)*r+ag(t.rowGaps);for(let t=0;t<s.length;t++)s[t]<0&&(s[t]=d),u+=s[t];t.cols=l,t.heights=s,t.nw=Math.max(t.nw,l*c+(l-1)*r+ag(t.colGaps)+2*n),t.nh=u+2*n+t.head}(i,r,0===t?0:r)}t.w=t.nw,t.h=t.nh,t.x=t.w/2,t.y=t.h/2;for(let t=0;t<n.length;t++){let i=n[t];i.children.length>0&&function(t,r,n){let{cols:i,heights:a,rowGaps:s,colGaps:o}=t,l=a.length,c=(t.w-2*n-(i-1)*r-ag(o))/i,d=t.h-2*n-t.head-(l-1)*r-ag(s),u=[];if(o.length>0){let t=0;for(let r=0;r<i;r++)u.push(t),t+=o[r]??0}let h=0;for(let t of a)h+=t;let f=h>0?d/h:0,p=h>0?0:d/l,g=t.x-t.w/2+n,m=t.y-t.h/2+n+t.head,y=0;for(let n of t.children){for(;y<n.row;y++)m+=a[y]*f+p+r+(s[y]??0);let t=u[n.col]??0;n.w=c*n.span+r*(n.span-1)+(u[n.col+n.span-1]??0)-t,n.h=a[y]*f+p,n.x=g+n.col*(c+r)+t+n.w/2,n.y=m+n.h/2}}(i,r,0===t?0:r)}return{width:t.w,height:t.h}}(g,h);for(let t of(b.length=0,x.length=0,m))0===t.kind&&ak.has(t.shape)?(t.bw=t.nw,t.bh=t.nh):1===t.kind?(t.bw=t.span>1?t.w:t.nw,t.bh=t.nh):(t.bw=t.w,t.bh=0===t.kind&&aM.has(t.shape)?t.nh:t.h),0===t.kind&&"cyl"===t.shape&&(t.dy=Math.min(12,Math.max(6,t.bw/14))/2),0===t.kind||1===t.kind?b.push(t):t.head>0&&x.push({x:t.x,y:t.y-t.h/2+(t.head+h)/2+2,bw:t.label.width,bh:t.label.height});return t},k=$(),M=new Map,_=new Set,A=[],E=[];for(let r of t.edges){let t=v.get(r.start??""),n=v.get(r.end??"");if(void 0===t||void 0===n)continue;let i=Math.min(t.index,n.index)*m.length+Math.max(t.index,n.index);M.set(i,(M.get(i)??0)+1),r.label&&_.add(i),A.push([t,n]),E.push(r)}let S=E.length*b.length<=2e6?b:void 0,C=[],T=new Map,I=[],N=t=>{(()=>{let t=new Map;C.length=0,T.clear();for(let r=0;r<E.length;r++){let[n,i]=A[r],a=Math.min(n.index,i.index)*m.length+Math.max(n.index,i.index),s=M.get(a)??1,c=t.get(a)??0;t.set(a,c+1);let d=n7(E[r].label,!1,l,o,200),u,h,f;if(n===i){let[t,r,i]=aT(n,c+1);u=[],h=t+i+6+d.width/2,f=r-i/2}else{let t=(u=function(t,r,n,i){let a=t.x-t.bw/2,s=t.x+t.bw/2,o=t.y-t.bh/2,l=t.y+t.bh/2,c=r.x-r.bw/2,d=r.x+r.bw/2,u=r.y-r.bh/2,h=r.y+r.bh/2,f=Math.max(a,c),p=Math.min(s,d),g=Math.max(o,u),m=Math.min(l,h),y=p-f>6,v=m-g>6;if(y&&v){let n=t.bw*t.bh<=r.bw*r.bh?t:r,i=n===t?r:t,a=n.y-n.bh/2-(i.y-i.bh/2),s=i.y+i.bh/2-(n.y+n.bh/2),o=n.x-n.bw/2-(i.x-i.bw/2),l=i.x+i.bw/2-(n.x+n.bw/2),c=Math.min(a,s,o,l),d;return d=c===s?[n.x,aA(n,n.x,1),n.x,i.y+i.bh/2]:c===a?[n.x,aA(n,n.x,-1),n.x,i.y-i.bh/2]:c===l?[aE(n,n.y,1),n.y,i.x+i.bw/2,n.y]:[aE(n,n.y,-1),n.y,i.x-i.bw/2,n.y],n===t?d:[d[2],d[3],d[0],d[1]]}if(y){let i=Math.min(6,(p-f)/2),a=Math.min(Math.max((f+p)/2+n,f+i),p-i),s=r.y>t.y?1:-1;return[a,aA(t,a,s),a,aA(r,a,-s)]}if(v){let i=Math.min(6,(m-g)/2),a=Math.min(Math.max((g+m)/2+n,g+i),m-i),s=r.x>t.x?1:-1;return[aE(t,a,s),a,aE(r,a,-s),a]}let b=r.x>t.x?1:-1,x=r.y>t.y?1:-1,w=[aE(t,t.y,b),t.y,r.x,t.y,r.x,aA(r,r.x,-x)],$=[t.x,aA(t,t.x,x),t.x,r.y,aE(r,r.y,-b),r.y],k=Math.abs(r.x-t.x)>=Math.abs(r.y-t.y),M=k?w:$;if(void 0===i)return M;let _=aC(M,t,r,i);if(0===_)return M;let A=k?$:w,E=aC(A,t,r,i);if(E<_&&(M=A,_=E),0===_)return M;let S=[];return aS(t,r.x,r.y,S),aS(r,t.x,t.y,S),aC(S,t,r,i)<_?S:M}(n,i,(c-(s-1)/2)*(_.has(a)?Math.round(1.5*o)+2:14),S)).length,l=Math.abs(u[2]-u[0])+Math.abs(u[3]-u[1]),p=Math.abs(u[t-2]-u[t-4])+Math.abs(u[t-1]-u[t-3]),g=2*(6===t&&p>l),m=d.width>0?function(t,r,n,i,a,s,o){if(void 0===o)return .5;for(let l of aI)if(!aN(t[r]+(t[r+2]-t[r])*l,t[r+1]+(t[r+3]-t[r+1])*l,n,i,a,s,o))return l;return .5}(u,g,d.width+8,d.height,n,i,S):.5;if(h=u[g]+(u[g+2]-u[g])*m,f=u[g+1]+(u[g+3]-u[g+1])*m,d.width>0&&s>1){I[r]=u.slice(g,g+4);let t=T.get(a);t?t.push(r):T.set(a,[r])}}C.push({edge:E[r],points:u,loop:n===i?c+1:0,label:d,lx:h,ly:f})}})();let r=S&&[...S,...x],n=new Map,a=!1;for(let s of T.values()){if(s.length<2)continue;let[o,l]=A[s[0]],c=function(t,r,n,i,a,s){let o=n[t[0]][0]===n[t[0]][2],l=-1/0,c=1/0,d=-4,u=!1;for(let i=0;i<t.length;i++){let a=n[t[i]];if(o?a[0]!==a[2]:a[1]!==a[3])return 0;l=Math.max(l,o?Math.min(a[1],a[3]):Math.min(a[0],a[2])),c=Math.min(c,o?Math.max(a[1],a[3]):Math.max(a[0],a[2]));let s=r[t[i]];d+=(o?s.label.height:s.label.width+8)+4;for(let n=0;n<i;n++){let i=r[t[n]];Math.abs(s.lx-i.lx)<(s.label.width+i.label.width)/2+8&&Math.abs(s.ly-i.ly)<(s.label.height+i.label.height)/2&&(u=!0)}}if(!u)return 0;if(d>c-l-16)return d-(c-l-16);let h=[],f=(l+c-d)/2;for(let n of t){let{label:t,lx:l,ly:c}=r[n],d=o?t.height:t.width+8,u=f+d/2;if(aN(o?l:u,o?u:c,t.width+8,t.height,i,a,s))return 0;h.push(u),f+=d+4}return t.forEach((t,n)=>{o?r[t].ly=h[n]:r[t].lx=h[n]}),0}(s,C,I,o,l,r),d=I[s[0]][0]===I[s[0]][2];t&&c>0&&(d||!i)&&function(t,r,n,i,a,s){let o,l=new Set;for(let n=r;void 0!==n;n=t[n.index])l.add(n);let c,d=n;for(;void 0!==d&&!l.has(d);)c=d,d=t[d.index];if(void 0===d||void 0===c||d===r)return!1;let u=r;for(;t[u.index]!==d;)u=t[u.index];if(i){if(u.row===c.row)return!1;o=Math.max(u.row,c.row)-1,d.rowGaps===ax&&(d.rowGaps=[])}else{let[t,r]=u.col<c.col?[u,c]:[c,u];if(r.col<t.col+t.span)return!1;o=r.col-1,d.colGaps===ax&&(d.colGaps=[])}let h=i?d.rowGaps:d.colGaps;return s.has(h)||s.set(h,h.slice()),h[o]=Math.max(h[o]??0,(s.get(h)[o]??0)+a),!0}(y,o,l,d,Math.ceil(c),n)&&(a=!0)}return a},O=()=>{let t=0;for(let r=0;r<C.length;r++){let n=C[r];for(let i=r+1;i<C.length;i++){let r=C[i],a=(n.label.width+8)/2,s=(r.label.width+8)/2,o=Math.min(n.lx+a,r.lx+s)-Math.max(n.lx-a,r.lx-s),l=Math.min(n.ly+n.label.height/2,r.ly+r.label.height/2)-Math.max(n.ly-n.label.height/2,r.ly-r.label.height/2);n.label.width>0&&r.label.width>0&&o>0&&l>0&&(t+=o*l)}}return t},D=0,R=0,L=0,z=0,P=(t,r,n,i)=>{t-n/2<D&&(D=t-n/2),t+n/2>L&&(L=t+n/2),r-i/2<R&&(R=r-i/2),r+i/2>z&&(z=r+i/2)},j=()=>{D=0,R=0,L=k.width,z=k.height;for(let t=0;t<C.length;t++){let r=C[t];if(r.loop>0){let[n,i,a]=aT(A[t][0],r.loop);P(n,i,2*a+2,2*a+2)}r.label.width>0&&P(r.lx,r.ly,r.label.width+8,r.label.height)}return L-D};if(N(E.length*E.length<=2e6)){let t=O(),r=j(),i=!0;for(let t=0;t<3&&i;t++)k=$(),i=N(t<2);let a=j(),s=void 0!==n.maxWidth&&n.maxWidth>0?n.maxWidth:1/0;if(O()>t-1||a>r&&Math.ceil(a+2*c)>s){for(let t of m)t.rowGaps=ax,t.colGaps=ax;k=$(),N(!1)}}j();let F=ad(t.title,l,s,i?io(n):4e3),B=F.height>0?F.height+12:0,W=Math.max(L-D,F.width),H=c-D+(W-(L-D))/2,U=c+B-R;for(let t of m)t.x+=H,t.y+=U;let q=Math.ceil(W+2*c),V=Math.ceil(z-R+B+2*c),Y="",G="",Z=[];for(let t=1;t<m.length;t++){let r=m[t];if(3===r.kind)continue;let n=nc((r.block.classes??ay).join(" ")),i=eS(r.block.id);if(2===r.kind){let t=r.y-r.h/2;e6(r.style.shape)&&Z.push({box:[r.x-r.w/2,t,r.x+r.w/2,t+r.h],shape:r.style.shape}),Y+=`<g class="pele-cluster${n}" data-id="${i}"><rect x="${eT(r.x-r.w/2)}" y="${eT(t)}" width="${eT(r.w)}" height="${eT(r.h)}" fill="var(--_a)"${r8(r.style.shape)?"":' fill-opacity="0.5"'} stroke="var(--_b)"${r9(r.style.shape)}/>`+eI(r.label,r.x,t+(r.head+h)/2+2,` class="pele-cluster-label"${e8(r.style,"var(--_m)")}${r.style.text}`,d)+"</g>";continue}let a=1===r.kind,s=r.label;if(r.span>1&&r.label.width>0&&r.label.lines.length>1&&r.bw>r.nw&&(a||!ak.has(r.shape))){let t=!!r.style.bold|2*!!r.style.italic,n=r.label.width+(r.bw-r.nw);s=n7(r.block.label,!1,l,r.label.size,n,t)}G+=`<g class="pele-node pele-shape-${a?"block-arrow":r.shape}${n}" data-id="${i}" transform="translate(${eT(r.x)},${eT(r.y)})">`+(a?function(t,r,n,i){let a=af(t),s=r/2,o=n/2,l;if("x"===a){let r=Math.min(o,20),n=o-7,i=2&t?-s+r:-s,a=1&t?s-r:s;l=[i,-n,a,-n],1&t&&l.push(a,-o,s,0,a,o),l.push(a,n,i,n),2&t&&l.push(i,o,-s,0,i,-o)}else if("y"===a){let r=Math.min(s,20),n=s-7,i=4&t?-o+r:-o,a=8&t?o-r:o;l=[n,i,n,a],8&t&&l.push(s,a,0,o,-s,a),l.push(-n,a,-n,i),4&t&&l.push(-s,i,0,-o,s,i)}else{let r=2&t?-s+12:-s,n=1&t?s-12:s,i=4&t?-o+12:-o,a=8&t?o-12:o,c=(r+n)/2,d=(i+a)/2,u=Math.min(10,(n-r)/2),h=Math.min(10,(a-i)/2);l=[r,i],4&t&&l.push(c-u,i,c,-o,c+u,i),l.push(n,i),1&t&&l.push(n,d-h,s,d,n,d+h),l.push(n,a),8&t&&l.push(c+u,a,c,o,c-u,a),l.push(r,a),2&t&&l.push(r,d+h,-s,d,r,d-h)}let c="";for(let t=0;t<l.length;t+=2)c+=(t?" ":"")+eT(l[t])+","+eT(l[t+1]);return`<polygon points="${c}" stroke-linejoin="round"${i}/>`}(r.mask,r.bw,r.bh,am+r.style.shape):nD(r.shape,r.bw,r.bh,am+r.style.shape,' stroke="var(--_b)"'+r.style.line))+eI(s,r.dx,r.dy,` class="pele-label"${a||nL(r.shape)?e8(r.style):""}${r.style.text}`,d)+"</g>"}let X="",K="",J="";for(let t=0;t<C.length;t++){let{edge:r,points:n,loop:i,label:a}=C[t],s=r.arrowTypeStart??"",o=r.arrowTypeEnd??"",l;if(i>0)l=function(t,r,n,i){let[a,s,o,l,c]=aT(t,r),d=l+n/o,u=c-i/o,h=(u-d)%(2*Math.PI);h<=0&&(h+=2*Math.PI);let f=a+o*Math.cos(d),p=s+o*Math.sin(d),g=a+o*Math.cos(u),m=s+o*Math.sin(u),y=a+o*Math.cos(l),v=s+o*Math.sin(l),b=a+o*Math.cos(c),x=s+o*Math.sin(c),w=Math.hypot(y-f,v-p),$=Math.hypot(b-g,x-m);return{d:`M${eT(f)},${eT(p)}A${eT(o)},${eT(o)} 0 ${+(h>Math.PI)} 1 ${eT(g)},${eT(m)}`,sx:y,sy:v,sdx:w>0?(y-f)/w:Math.sin(l),sdy:w>0?(v-p)/w:-Math.cos(l),ex:b,ey:x,edx:$>0?(b-g)/$:-Math.sin(c),edy:$>0?(x-m)/$:Math.cos(c)}}(A[t][0],i,rq(s),rq(o));else{for(let t=0;t<n.length;t+=2)n[t]+=H,n[t+1]+=U;l=function(t,r,n){let i=t.length,a=t[0],s=t[1],o=t[i-2],l=t[i-1],c=t[2]-a,d=t[3]-s,u=Math.hypot(c,d);c/=u||1,d/=u||1;let h=o-t[i-4],f=l-t[i-3],p=Math.hypot(h,f);if(h/=p||1,f/=p||1,4===i&&r+n>u){let t=u/(r+n);r*=t,n*=t}r=Math.min(r,u),n=Math.min(n,p);let g=`M${eT(a+c*r)},${eT(s+d*r)}`;if(6===i){let i=Math.max(0,Math.min(8,u-r,p-n));g+=`L${eT(t[2]-c*i)},${eT(t[3]-d*i)}Q${eT(t[2])},${eT(t[3])} ${eT(t[2]+h*i)},${eT(t[3]+f*i)}`}return{d:g+=`L${eT(o-h*n)},${eT(l-f*n)}`,sx:a,sy:s,sdx:-c,sdy:-d,ex:o,ey:l,edx:h,edy:f}}(n,rq(s),rq(o))}let c=rJ(l.d,[l.sx,l.sy,l.ex,l.ey],Z);""===c&&(X+=r0(l,s,o,"","thick"===r.thickness));let u=eS(r.id);if(K+=`<g class="pele-edge" data-id="${u}"${c?` stroke="${c}"`:""}><path d="${l.d}"${"thick"===r.thickness?' stroke-width="2.5"':""}${"dotted"===r.pattern?' stroke-dasharray="3 4"':""}/>`+rV(s,l.sx,l.sy,l.sdx,l.sdy,c||"var(--_l)")+rV(o,l.ex,l.ey,l.edx,l.edy,c||"var(--_l)")+"</g>",a.width>0){let n=C[t].lx+H,i=C[t].ly+U;J+=r2(r.id,a,n,i,"",d)}}return{svg:np("block",q,V,s,n,t,eI(F,q/2,c+F.height/2,' class="pele-title" font-weight="var(--_tw)"')+(Y?`<g class="pele-clusters">${Y}</g>`:"")+r1(X)+(K?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${K}</g>`:"")+`<g class="pele-nodes">${G}</g>`+(J?`<g class="pele-edge-labels" font-size="${o}">${J}</g>`:"")),width:q,height:V,links:[]}})(t,r,n,i))}},{type:"railroad",parse:(t,r,n)=>(function(t,r){let n=function(t){let r=uL.exec(t);if(null===r)return;let n=r[1]?.toLowerCase();return"ebnf-"===n?"ebnf":"abnf-"===n?"abnf":"peg-"===n?"peg":"railroad"}(t);if(void 0===n)throw new a("No railroad diagram keyword found.","syntax",{type:"railroad"});let i=new uR;return r&&(i.title=r),function(t,r,n){let[i,a]=function(t,r){switch(r){case"ebnf":{let r=d9(t,uw,"RailroadEbnf",16,d8,t=>{let r=t.expect(19);t.accept(2)||t.expect(1);let n={$type:"EbnfRule",name:r,definition:function(t){let r=[],n=u$(void 0,{$type:"EbnfChoice",alternatives:[]},-2,!1),i=!1;for(;;){let a,s=t.kind;switch(s){case 20:a={$type:"EbnfTerminal",value:d8(t.take())};break;case 19:a={$type:"EbnfNonTerminal",name:t.take()};break;case 21:a={$type:"EbnfSpecial",text:t.take().slice(1,-1).trim()};break;case 6:case 8:case 10:{t.i++;let a={$type:"EbnfChoice",alternatives:[]};r.push(n),n=u$({$type:uk[s-6>>1],element:a},a,s+1,i),i=!1;continue}default:t.fail("a terminal, a name, or an opening bracket")}for(;;){i?(n.term.postfixes.push({$type:"EbnfExceptionPostfix",except:a}),i=!1):(n.term={$type:"EbnfTerm",base:a,postfixes:[]},n.sequence.elements.push(n.term));let s=n.term.postfixes;for(;;){let r=t.kind;if(12===r)s.push({$type:"EbnfOptionalPostfix",operator:t.take()});else if(13===r)s.push({$type:"EbnfZeroOrMorePostfix",operator:t.take()});else if(14===r)s.push({$type:"EbnfOneOrMorePostfix",operator:t.take()});else break}let o=t.kind;if(o===n.close){t.i++,a=n.node,i=n.except,n=r.pop();continue}if(15===o)t.i++,i=!0;else if(5===o)t.i++;else if(4===o)t.i++,n.sequence={$type:"EbnfSequence",elements:[]},n.choice.alternatives.push(n.sequence);else if(20!==o&&19!==o&&21!==o&&6!==o&&8!==o&&10!==o){if(0===r.length)return n.choice;t.fail(`token of type '${uw[n.close].name}'`)}break}}}(t)};return t.expect(3),n});return[r,ul(r,uM)]}case"abnf":{let r=d9(t,uf,"RailroadAbnf",8,t=>t.slice(1,-1),t=>{let r=t.expect(11);t.expect(1);let n=function(t){let r=[],n=up(void 0,{$type:"AbnfAlternation",alternatives:[]},-2,void 0);for(;;){let i=14===t.kind||15===t.kind?t.take():void 0,a,s=t.kind;switch(s){case 12:a={$type:"AbnfStringLiteral",value:t.take().slice(1,-1)};break;case 13:a={$type:"AbnfNumVal",value:t.take()};break;case 11:a={$type:"AbnfRuleName",name:t.take()};break;case 4:case 6:{t.i++;let a={$type:"AbnfAlternation",alternatives:[]};r.push(n),n=up({$type:4===s?"AbnfGroup":"AbnfOptionalGroup",element:a},a,s+1,i);continue}default:t.fail("a string, a number, a name, or an opening bracket")}for(;;){n.concatenation.elements.push(void 0===i?{$type:"AbnfElement",primary:a}:{$type:"AbnfElement",repeat:i,primary:a});let s=t.kind;if(s===n.close){t.i++,a=n.node,i=n.repeat,n=r.pop();continue}if(3===s)t.i++,n.concatenation={$type:"AbnfConcatenation",elements:[]},n.alternation.alternatives.push(n.concatenation);else if(12!==s&&13!==s&&11!==s&&4!==s&&6!==s&&14!==s&&15!==s){if(0===r.length)return n.alternation;t.fail(`token of type '${uf[n.close].name}'`)}break}}}(t);return t.expect(2),{$type:"AbnfRule",name:r,definition:n}});return[r,ul(r,ug)]}case"peg":{let r=d9(t,uN,"RailroadPeg",12,d8,t=>{let r=t.expect(15);t.expect(1);let n={$type:"PegRule",name:r,definition:function(t){let r=[],n=uO(void 0,{$type:"PegOrderedChoice",alternatives:[]},void 0);for(;;){let i=4===t.kind||5===t.kind?t.take():void 0,a;switch(t.kind){case 16:a={$type:"PegLiteral",value:d8(t.take())};break;case 15:a={$type:"PegIdentifier",name:t.take()};break;case 11:a={$type:"PegAny",dot:t.take()};break;case 9:{t.i++;let a={$type:"PegOrderedChoice",alternatives:[]};r.push(n),n=uO({$type:"PegGroup",element:a},a,i);continue}default:t.fail("a literal, a name, a dot, or an opening parenthesis")}for(;;){let s={$type:"PegSuffix",primary:a};(6===t.kind||7===t.kind||8===t.kind)&&(s.operator=t.take()),n.sequence.elements.push(void 0===i?{$type:"PegPrefix",suffix:s}:{$type:"PegPrefix",operator:i,suffix:s});let o=t.kind;if(10===o&&r.length>0){t.i++,a=n.node,i=n.operator,n=r.pop();continue}if(3===o)t.i++,n.sequence={$type:"PegSequence",elements:[]},n.choice.alternatives.push(n.sequence);else if(4!==o&&5!==o&&16!==o&&15!==o&&11!==o&&9!==o){if(0===r.length)return n.choice;t.fail("token of type ')'")}break}}}(t)};return t.expect(2),n});return[r,ul(r,uD)]}default:{let r=d9(t,uE,"Railroad",14,d8,t=>{let r=t.expect(17);t.expect(9);let n=function(t){let r=[];for(;;){let n;switch(t.kind){case 6:n={$type:"RailroadTerminalExpr",value:uS(t)};break;case 1:n={$type:"RailroadNonTerminalExpr",name:uS(t)};break;case 7:n={$type:"RailroadSpecialExpr",text:uS(t)};break;case 4:n={$type:"RailroadSequenceExpr",elements:[]};break;case 8:n={$type:"RailroadChoiceExpr",alternatives:[]};break;case 5:n=uC("RailroadOptionalExpr");break;case 3:n=uC("RailroadOneOrMoreExpr");break;case 2:n=uC("RailroadZeroOrMoreExpr");break;default:t.fail("an expression")}if("elements"in n||"alternatives"in n||"element"in n){t.i++,t.expect(11),r.push(n);continue}for(;;){let i=r[r.length-1];if(void 0===i)return n;if("element"in i)i.element=n;else if(("elements"in i?i.elements:i.alternatives).push(n),t.accept(12))break;t.expect(13),r.pop(),n=i}}}(t);return t.expect(10),{$type:"RailroadRule",name:r,definition:n}});return[r,ul(r,uT)]}}}(r,n);for(let r of(t.notation=n,i.accDescr&&t.setAccDescription(i.accDescr),i.accTitle&&t.setAccTitle(i.accTitle),i.title&&t.setTitle(i.title),a))t.addRule(r)}(i,t,n),i})(t,n),render:function(t,r,n){return iu(n,i=>(function(t,r,n,i){let a=n.fontSize??16,s=uz(r,"fontSize",0,200),o=s||Math.round(.875*a),l=s||a,c=uz(r,"padding",-1,200),d=Math.round(1.5*o),u={measurer:n.measurer??e$(n.fontFamily,n.fontFamilyMono),size:o,padding:c<0?12:c,height:uB(d+(c<0?9:2*c)),gap:Math.min(uz(r,"horizontalSeparation",16,500),i?12:1/0),sep:uz(r,"verticalSeparation",10,500),arc:Math.min(uz(r,"arcRadius",10,200),i?6:1/0)},h=r.railroad?.showMarkers===!1?0:uz(r,"markerRadius",4,50),f=uz(r,"strokeWidth",0,20),p=f>0?` stroke-width="${eT(f)}"`:"",g=n.padding??8,{arc:m}=u,y=eT(m),v=(t,r,n)=>`a${y},${y} 0 0 ${t} ${r}${y},${n}${y}`,b=v(1,"",""),x=v(0,"",""),w=v(0,"","-"),$=v(1,"","-"),k=v(0,"-",""),M=v(0,"-","-"),_=n7(t.title,!1,u.measurer,a,i?io(n):4e3,1),A=_.height>0?_.height+16:0,E=Math.round(1.5*l),S=.35*o,C=u.height/2,T="",I="",N="",O=(t,r,n)=>{n>t&&(T+=`M${eT(t)},${eT(r)}H${eT(n)}`)},D=(t,r,n)=>{let i=[t],a=[r,n];for(;i.length>0;){let t=i.pop(),r=a.pop(),n=a.pop(),s=t.kids,o=n+t.width;switch(t.kind){case 3:{let t=o;for(let n=s.length-1;n>=0;n--)t-=s[n].width,i.push(s[n]),a.push(t,r),n>0&&O(t-u.gap,r,t),t-=u.gap;break}case 7:{let t=n+2*m,l=i.length,c=0;O(n,r,t);for(let l=0;l<s.length;l++){let d=s[l],h=r+c;if(i.push(d),a.push(h,t),l+1<s.length){let i=s[l+1],a=c+d.down+Math.max(u.sep,2*m)+i.up,f=r+c+d.down+Math.max(u.sep,2*m)/2;T+=`M${eT(t+d.width)},${eT(h)}H${eT(o-2*m)}V${eT(f)}H${eT(n+m)}V${eT(r+a)}H${eT(t)}`,I+=`M${eT(t-7)},${eT(r+a-3.5)}l7,3.5l-7,3.5z`,c=a}else T+=`M${eT(t+d.width)},${eT(h)}H${eT(o-m)}V${eT(r)}H${eT(o)}`}uF(i,l),uF(a,2*l);break}case 4:{let l=t.width-4*m,c=n+m,d=o-m,h=i.length,f=0;for(let t=0;t<s.length;t++){let h=s[t];t>0&&(f=uH(f,s[t-1],h,u));let p=r+f,g=n+2*m+(l-h.width)/2,y=t===s.length-1;0===t?(O(n,r,g),O(g+h.width,r,o)):T+=(y?`M${eT(n)},${eT(r)}${b}V${eT(p-m)}`:`M${eT(c)},${eT(p-m)}`)+x+(g>c+m?`H${eT(g)}`:"")+`M${eT(g+h.width)},${eT(p)}`+(g>c+m?`H${eT(d-m)}`:"")+w+(y?`V${eT(r+m)}${$}`:""),i.push(h),a.push(p,g)}uF(i,h),uF(a,2*h);break}case 5:{let l=s[0],c=n+2*m;O(n,r,c),O(c+l.width,r,o),T+=`M${eT(n)},${eT(r)}${w}V${eT(r-t.reach+m)}${$}H${eT(o-2*m)}${b}V${eT(r-m)}${x}`,i.push(l),a.push(c,r);break}case 6:{let l=s[0],c=n+(t.width-l.width)/2,d=r+t.reach,u=n+t.width/2;O(n,r,c),O(c+l.width,r,o),T+=`M${eT(n+m)},${eT(r)}${k}V${eT(d-m)}${x}H${eT(o-m)}${w}V${eT(r+m)}${M}`,I+=`M${eT(u-3.5)},${eT(d)}l7,-3.5v7z`,""!==t.text&&(N+=`<text class="pele-edge-label pele-count" x="${eT(u)}" y="${eT(d+12+3)}" font-size="12" fill="var(--_m)">${eE(t.text)}</text>`),i.push(l),a.push(c,r);break}default:{let i=t.text,a=i.startsWith(" ")||i.endsWith(" ")||i.includes(" ")?' xml:space="preserve"':"",s=`<rect x="${eT(n)}" y="${eT(r-C)}" width="${eT(t.width)}" height="${eT(u.height)}"`,o=`<text x="${eT(n+t.width/2)}" y="${eT(r+S)}"${a}`;0===t.kind?N+=`<g class="pele-node pele-terminal">${s} rx="${eT(C)}" fill="var(--_s)" stroke="var(--_b)"${p}/>${o} font-family="${r3}">${eE(i)}</text></g>`:1===t.kind?N+=`<g class="pele-node pele-nonterminal" data-id="${eS(t.id)}">${s} fill="var(--_bg)" stroke="var(--_b)"${p}${r5}/>${o}>${eE(i)}</text></g>`:N+=`<g class="pele-node pele-special">${s} fill="var(--_bg)" stroke="var(--_b)" stroke-dasharray="4 3"${p}${r5}/>${o} font-style="italic"><tspan fill="var(--_m)">? </tspan>${eE(i.slice(2,-2))}<tspan fill="var(--_m)"> ?</tspan></text></g>`}}}},R="",L=_.width,z=g+A,P=g+_.height;for(let r of t.rules){let t=function(t,r,n=1/0){let i=new Map,a=[[t,n]];for(let t=0;n!==1/0&&t<a.length;t++){let[n,s]=a[t];i.set(n,s);let o="choice"===n.type||"optional"===n.type?4*r.arc:"repetition"===n.type?(0===n.min?6:2)*r.arc:"sequence"===n.type?6*r.arc:0;for(let t of ue(n))a.push([t,Math.max(40,s-o)])}return uc(t,ue,(t,n)=>{let a=i.get(t)??1/0;switch(t.type){case"terminal":{let n=uj(t.value);return uW(0,/^ +$/.test(n)?"␣".repeat(n.length):n,"",4,r)}case"nonterminal":return uW(1,uj(t.name),t.name,0,r);case"special":return uW(2,"? "+uj(t.text)+" ?","",2,r);case"sequence":{let t=Math.max(0,n.length-1)*r.gap,i=0,s=0;for(let r of n)t+=r.width,i=Math.max(i,r.up),s=Math.max(s,r.down);let o={kind:3,width:t,up:i,down:s,kids:n,text:"",id:"",reach:0};if(t<=a||n.length<2)return o;let l=[],c=[],d=0,u=()=>{let t=0,r=0;for(let n of c)t=Math.max(t,n.up),r=Math.max(r,n.down);l.push({kind:3,width:d,up:t,down:r,kids:c,text:"",id:"",reach:0}),c=[],d=0};for(let t of n)c.length&&d+r.gap+t.width>Math.max(40,a-6*r.arc)&&u(),d+=(c.length?r.gap:0)+t.width,c.push(t);if(u(),l.length<2)return o;let h=0,f=0;for(let t=0;t<l.length;t++)h=Math.max(h,l[t].width),t&&(f+=l[t-1].down+Math.max(r.sep,2*r.arc)+l[t].up);return{kind:7,width:h+6*r.arc,up:l[0].up,down:f+l[l.length-1].down,kids:l,text:"",id:"",reach:0}}case"choice":{let t=0,i=0;for(let a=0;a<n.length;a++)t=Math.max(t,n[a].width),a>0&&(i=uH(i,n[a-1],n[a],r));let a=n[n.length-1];return{kind:4,width:t+4*r.arc,up:n.length>0?n[0].up:0,down:a?i+a.down:0,kids:n,text:"",id:"",reach:0}}case"optional":return uU(n[0],r);case"repetition":{let{min:i,max:a}=t,s=n[0];if(1===i&&1===a)return s;let o=function(t,r){if(r===1/0&&t<=1)return"";let n=t=>Number.isFinite(t)?String(t):"∞";return t===r?n(t)+"\xd7":r===1/0?"≥"+n(t)+"\xd7":0===t?"≤"+n(r)+"\xd7":n(t)+"–"+n(r)+"\xd7"}(i,a),l=Math.max(s.down+r.sep,2*r.arc),c=""===o?0:uB(r.measurer.width(o,12,0)),d={kind:6,width:Math.max(s.width,c)+2*r.arc,up:s.up,down:l+(""===o?4.5:18),kids:[s],text:o,id:"",reach:l};return 0===i?uU(d,r):d}}})}(r.definition,u,i?Math.max(80,(n.maxWidth??320)-2*g-4*h-24-1):1/0),a=uj(r.name),s=z+E+6+t.up,o=g+2*h,c=o+12,d=c+t.width+12;T="",I="",N="",O(o,s,c),O(c+t.width,s,d),D(t,c,s);let f=h>0?`<circle class="pele-marker pele-start" cx="${eT(g+h)}" cy="${eT(s)}" r="${eT(h)}" fill="var(--_l)"/><circle class="pele-marker pele-end" cx="${eT(d+h)}" cy="${eT(s)}" r="${eT(h)}" fill="var(--_l)"/>`:"";R+=`<g class="pele-rule" data-id="${eS(r.name)}"><text class="pele-rule-name" x="${eT(g)}" y="${eT(z+E/2+.35*l)}" font-size="${eT(l)}" font-weight="var(--_hw)" text-anchor="start">${eE(a)}</text><path class="pele-edge pele-track" d="${T}" fill="none" stroke="var(--_l)"${p}/>`+(I?`<path class="pele-marker" d="${I}" fill="var(--_l)"/>`:"")+f+N+"</g>",L=Math.max(L,d+2*h-g,u.measurer.width(a,l,1)),z=(P=s+t.down)+u.sep+18}let j=Math.ceil(L+2*g),F=Math.ceil(P+g),B=eI(_,j/2,g+_.height/2,' class="pele-title" font-weight="var(--_tw)"')+(R?`<g class="pele-rules" transform="translate(0.5,0.5)" font-size="${eT(o)}" text-anchor="middle">${R}</g>`:"");return{svg:np("railroad",j,F,a,n,t,B),width:j,height:F,links:[]}})(t,r,n,i))}},{type:"agentflow",keepComments:!0,parse(t,r,n,i,a){let l=new tX({inheritDir:!0===(r.flowchart??{}).inheritDir,direction:"string"==typeof r.direction?r.direction:void 0,lineOffset:i,source:t,maxEdges:a.maxEdges});return n&&(l.title=n),function(t,r,n=!1){let i=!n&&t.includes("}")?t.replace(rh,`}
|
|
137
|
+
`):t,{types:a,texts:l,starts:c,locs:u}=function(t){let r=t.length,n=[],i=[],a=[],s=[],o=[],l=0,c=0,d=1,u=0,h=!0,f=t.indexOf("direction"),p=t.indexOf("@"),g=-1,m=0,y=0,v=-1,b=-1,x=-1,w=-1,$=-1,k=-1,M=-1,_=r=>{let n=-1;for(let i=c;i<r;i++){let a=t.charCodeAt(i);10===a?(d++,n=i):13===a&&(i+1<r&&10===t.charCodeAt(i+1)&&i++,d++,n=i)}if(n<0)u+=r-c;else{let i=n+1;for(;i<r;){let r=t.charCodeAt(i);if(8232===r||8233===r)break;i++}u=i-n-1}c=r},A=(r,o)=>{n.push(r),i.push(t.slice(c,o)),a.push(c),s.push(d,u),_(o),s.push(d,u)},E=(r,o)=>{n.push(r),i.push(t.slice(c,o)),a.push(c),s.push(d,u),u+=o-c,c=o,s.push(d,u)},S=(r,o)=>{n.push(r),i.push(t.slice(c,o)),a.push(c),s.push(d,u);for(let r=c;r<o;r++){let n=t.charCodeAt(r);10===n||13===n?(d++,u=0):u++}c=o,s.push(d,u)},C=(t,r,o)=>{n.push(t),i.push(r),a.push(c),s.push(d,u),_(o),s.push(d,u)},T=t=>{o.push(l),l=t},I=()=>{o.length>0&&(l=o.pop())},N=(r,n)=>(r.lastIndex=n,r.test(t)?r.lastIndex:-1),O=r=>t.startsWith(r,c)&&!J(t.charCodeAt(c+r.length)),D=n=>{if(n>=b&&n<=x)return x;let i=n;for(;i<r&&V(t.charCodeAt(i));)i++;return b=n,x=i,i},R=r=>{let n=D(r);if(n===M||45!==t.charCodeAt(n)||45!==t.charCodeAt(n+1))return -1;let i=n+2;for(;45===t.charCodeAt(i);)i++;let a=t.charCodeAt(i);return 120===a||62===a?D(i+1):(M=n,-1)},L=()=>{let r=D(c);if(r===k||45!==t.charCodeAt(r))return!1;let n=t.charCodeAt(r+1),i=r+2;if(45===n){for(;45===t.charCodeAt(i);)i++;let n=t.charCodeAt(i);return 120===n||62===n?A(42,D(i+1)):(T(10),A(43,D(r+2))),!0}if(46===n){for(;46===t.charCodeAt(i);)i++;if(45===t.charCodeAt(i))return A(42,D(i+1)),!0}return k=r,!1},z=n=>{if(37!==t.charCodeAt(n)||37!==t.charCodeAt(n+1)||123===t.charCodeAt(n+2))return -1;let i=t.indexOf(`
|
|
138
|
+
`,n+2);return -1===i?r:i},P=()=>{96===t.charCodeAt(c+1)?(T(2),_(c+2)):(T(1),_(c+1))},j=r=>{let n=t.charCodeAt(c+1);return 40===r?(45===n?(T(8),E(47,c+2)):91===n?(T(7),E(49,c+2)):40===n&&40===t.charCodeAt(c+2)?(T(7),E(57,c+3)):(T(7),E(72,c+1)),!0):91===r?(91===n?(T(7),E(51,c+2)):40===n?(T(7),E(55,c+2)):47===n?(T(9),E(60,c+2)):92===n?(T(9),E(61,c+2)):(T(7),E(74,c+1)),!0):124===r?(T(7),E(70,c+1),!0):123===r&&(T(7),E(76,c+1),!0)},F=()=>{let n=c;for(;n<r;){let i=t.charCodeAt(n);if(i<128&&1===tQ[i])n++;else if(45===i&&n+1<r){let r=t.charCodeAt(n+1);if(62===r||45===r||46===r)break;n++}else break}return n!==c&&(E(67,n),!0)},B=n=>{let i=n;for(;i<r;){let r=t.charCodeAt(i);if(32!==r&&9!==r)break;i++}return i},W=n=>{let i;switch(n){case 97:if(t.startsWith("acc",c)){if((i=N(t0,c))>=0)return T(3),A(2,i),!0;if((i=N(t1,c))>=0)return T(4),A(4,i),!0;if((i=N(t2,c))>=0)return T(5),_(i),!0}if(O("agentflow-beta"))return h&&(h=!1,T(6)),E(20,c+14),!0;break;case 64:if(123===t.charCodeAt(c+1))return T(14),C(7,"",c+2),!0;break;case 99:if((i=N(t4,c))>=0)return T(12),_(i),!0;if(O("classDef"))return E(16,c+8),!0;if(O("class"))return E(17,c+5),!0;if((i=N(t3,c))>=0)return T(11),_(i),!0;if(O("connector"))return E(22,c+9),!0;break;case 34:return P(),!0;case 115:if(O("style"))return E(12,c+5),!0;break;case 100:if(O("default"))return E(13,c+7),!0;break;case 108:if(O("linkStyle"))return E(14,c+9),!0;break;case 105:if(O("interpolate"))return E(15,c+11),!0;break;case 104:if(t.startsWith("href",c)&&V(t.charCodeAt(c+4)))return A(18,c+5),!0;break;case 102:if(O("flow"))return E(21,c+4),!0;break;case 103:if(O("global"))return E(23,B(c+6)),!0;break;case 101:if(O("end"))return E(24,B(c+3)),!0;break;case 95:if(O("_self"))return E(25,c+5),!0;if(O("_blank"))return E(25,c+6),!0;if(O("_parent"))return E(25,c+7),!0;if(O("_top"))return E(25,c+4),!0}if(-1!==f&&c>=m&&(f<c&&(f=t.indexOf("direction",c)),-1!==f&&(g<c&&(re.lastIndex=c,g=re.test(t)?re.lastIndex-1:r),f<g))){for(let t=0;t<5;t++)if((i=N(t7[t],c))>=0)return A(28+t,i),!0;m=g}if(-1!==p&&34!==n&&!V(n)){if(c>=y){p<c&&(p=t.indexOf("@",c));let n=c;for(;n<r;){let r=t.charCodeAt(n);if(34===r||V(r))break;n++}if(y=n,v=-1,-1!==p&&p<n)for(let i=Math.min(n,r-1)-1;i>=p;i--){if(64!==t.charCodeAt(i))continue;let r=t.charCodeAt(i+1);if(123!==r&&34!==r){v=i;break}}}if(v>c)return E(33,v+1),!0}if(n>=48&&n<=57){let n=c+1;for(;n<r;){let r=t.charCodeAt(n);if(r<48||r>57)break;n++}return E(34,n),!0}switch(n){case 35:return E(35,c+1),!0;case 58:return 58===t.charCodeAt(c+1)&&58===t.charCodeAt(c+2)?E(36,c+3):E(37,c+1),!0;case 38:return E(38,c+1),!0;case 59:return E(39,c+1),!0;case 44:return E(40,c+1),!0;case 42:return E(41,c+1),!0;case 60:return E(62,c+1),!0;case 45:return L()||F()||E(68,c+1),!0;case 40:case 124:case 123:return j(n);case 91:return 124===t.charCodeAt(c+1)?(E(52,c+2),!0):j(n);case 62:return T(7),E(53,c+1),!0;case 94:return E(63,c+1),!0;case 92:return 124===t.charCodeAt(c+1)?(E(64,c+2),!0):F();case 118:return J(t.charCodeAt(c+1))?F():(E(65,c+1),!0);case 37:return(i=z(c))>=0?(A(66,i),!0):F()}if(V(n)){if(L())return!0;if((32===n||9===n)&&(i=z((n=>{if(n>=w&&n<=$)return $;let i=n;for(;i<r;){let r=t.charCodeAt(i);if(32!==r&&9!==r)break;i++}return w=n,$=i,i})(c)))>=0)return A(66,i),!0;for(i=c;;){let r=t.charCodeAt(i);if(10===r)i++;else if(13===r&&10===t.charCodeAt(i+1))i+=2;else break}return i>c?A(77,i):A(78,c+1),!0}return n<128?F():!!tK(n)&&(E(69,c+1),!0)};for(;;){if(c>=r){let t=-1;switch(l){case 0:t=79;break;case 3:t=3;break;case 4:t=5;break;case 5:t=6;break;case 11:t=19;break;case 12:t=8;break;case 13:t=9}-1!==t&&E(t,r);break}let o=t.charCodeAt(c),h=!0;switch(l){case 0:h=W(o);break;case 1:if(34===o)96===t.charCodeAt(c+1)?(T(2),_(c+2)):(I(),_(c+1));else{let n=t.indexOf('"',c);A(11,-1===n?r:n)}break;case 2:if(96===o)34===t.charCodeAt(c+1)?(I(),_(c+2)):h=!1;else if(34===o)P();else{let n=c+1;for(;n<r;){let r=t.charCodeAt(n);if(96===r||34===r)break;n++}A(10,n)}break;case 3:case 4:{let n=t.indexOf(`
|
|
139
|
+
`,c);-1===n&&(n=r);let i=3===l?3:5;I(),A(i,n);break}case 5:if(125===o)I(),_(c+1);else{let n=t.indexOf("}",c);-1===n&&(n=r),A(6,n)}break;case 6:{let t;34===o?P():(t=N(t5,c))>=0?(I(),A(26,t)):(t=N(t6,c))>=0||(t=N(t8,c))>=0||(t=N(t9,c))>=0?(I(),A(27,t)):h=j(o);break}case 7:{let n=t.charCodeAt(c+1);switch(o){case 34:P();break;case 40:case 91:case 123:j(o);break;case 93:I(),41===n?E(48,c+2):93===n?E(50,c+2):E(73,c+1);break;case 41:I(),93===n?E(54,c+2):41===n&&41===t.charCodeAt(c+2)?E(56,c+3):E(71,c+1);break;case 124:I(),E(70,c+1);break;case 125:I(),E(75,c+1);break;case 37:{let t=z(c);t>=0?_(t):h=!1;break}default:{let n=c+1;for(;n<r;){let r=t.charCodeAt(n);if(91===r||93===r||40===r||41===r||123===r||125===r||124===r||34===r||37===r)break;n++}A(46,n)}}break}case 8:{let n=t.charCodeAt(c+1),i;if(34===o)P();else if(37===o&&(i=z(c))>=0)_(i);else if((45===o||47===o||41===o)&&41===n)I(),E(45,c+2);else if(40===o||91===o||123===o)j(o);else if(41===o||93===o||125===o)h=!1;else{let n=c+1;for(;n<r;){let r=t.charCodeAt(n);if(34===r||40===r||41===r||91===r||93===r||123===r||125===r||(45===r||47===r)&&41===t.charCodeAt(n+1)||37===r&&37===t.charCodeAt(n+1)&&123!==t.charCodeAt(n+2))break;n++}S(46,n)}break}case 9:{let n=t.charCodeAt(c+1);if(34===o){P();break}switch(o){case 40:45===n||91===n||40===n&&40===t.charCodeAt(c+2)?j(o):93===n?(I(),E(58,c+2)):j(o);break;case 91:case 123:j(o);break;case 92:93===n?(I(),E(58,c+2)):E(46,c+1);break;case 47:93===n?(I(),E(59,c+2)):E(46,c+1);break;case 93:case 41:93===n?(I(),E(58,c+2)):h=!1;break;case 125:h=!1;break;case 37:{let t=z(c);t>=0?_(t):h=!1;break}default:{if((63===o||61===o)&&93===n){I(),E(58,c+2);break}let i=c+1;for(;i<r;){let r=t.charCodeAt(i);if(92===r||91===r||93===r||40===r||41===r||123===r||125===r||47===r||37===r)break;i++}A(46,i)}}break}case 10:{if(34===o){P();break}let n=R(c);if(n>=0){I(),A(42,n);break}if(45===o&&45===t.charCodeAt(c+1)){h=!1;break}let i=c+1;for(;i<r;){let r=t.charCodeAt(i);if(34===r)break;if(45===r){if(45===t.charCodeAt(i+1))break}else if(V(r)&&R(i)>=0)break;i++}S(44,i);break}case 11:if(34===o)P();else if(V(o))I(),_(c+1);else{let n=c+1;for(;n<r&&!V(t.charCodeAt(n));)n++;E(19,n)}break;case 12:if(40===o){let t=N(rt,c);I(),t>=0?_(t):(T(13),_(c+1))}else{let n=t.indexOf("(",c);-1===n&&(n=r),A(8,n)}break;case 13:if(41===o)I(),_(c+1);else{let n=t.indexOf(")",c);-1===n&&(n=r),A(9,n)}break;case 14:if(34===o)T(15),E(7,c+1);else if(125===o)I(),_(c+1);else if(94===o)h=!1;else{let n=c+1;for(;n<r;){let r=t.charCodeAt(n);if(125===r||94===r||34===r)break;n++}A(7,n)}break;case 15:if(34===o)I(),E(7,c+1);else{let n=t.indexOf('"',c);-1===n&&(n=r),C(7,t.slice(c,n).replace(rr,"<br/>"),n)}}if(!h)return n.push(1),i.push(""),a.push(c),s.push(d,u,d,u),{types:n,texts:i,starts:a,locs:s}}return n.push(0),i.push(""),a.push(r),s.push(d,u,d,u),{types:n,texts:i,starts:a,locs:s}}(i),h=0,f,p=0,g=0,m=r=>{let n=a[h],l=c[h];if(79===n||0===n){let t=h;for(;t>0&&rd[a[t-1]];)t--;l=i.slice(0,c[t]).trimEnd().length}let u=i===t?l:o([s(t,rh,2)],l);throw 1===n?d("agentflow",t,u,"",!0):d("agentflow",t,u,`Expecting ${r}, got '${tJ[n]}'`)},y=(t,r)=>({first_line:u[4*t],first_column:u[4*t+1],last_line:u[4*r+2],last_column:u[4*r+3]}),v=(t,r="")=>(a[h]!==t&&m(`'${tJ[t]}'${r?", "+r:""}`),l[h++]),b=()=>{0===ro[a[h]]&&m(rc),h++},x=()=>{0===rn[a[h]]&&m("'NODE_STRING'");let t=l[h++];for(;1===rn[a[h]];)t+=l[h++];return t},w=()=>{0===ri[a[h]]&&m("'NODE_STRING'");let t=l[h++];for(;1===ri[a[h]];)t+=l[h++];return t},$=()=>{let t=a[h],r;if(11===t)r="string";else if(10===t)r="markdown";else{if(46!==t&&62!==t&&53!==t&&69!==t)return m(`${rl}, 'TAGEND', 'STR', 'MD_STR'`);r="text"}let n=l[h++];for(;;){let t=a[h];if(46!==t&&62!==t&&53!==t&&69!==t)break;n+=l[h++]}return{text:n,type:r}},k=t=>{v(t,rl)},M=()=>{p=h;let t=l[h++];for(;7===a[h];)t+=l[h++];return g=h-1,t},_=(t,n,i,a)=>{let s=y(i,a);r.addVertex(t,void 0,void 0,void 0,void 0,void 0,void 0,n,s),r.extendVertexMapping(t,s)},A=(t,n)=>{void 0!==n.data&&r.addVertex(t,void 0,void 0,void 0,void 0,void 0,void 0,n.data,y(n.dataFrom,n.dataTo))},E=()=>{let t=(()=>{let t=h,n=x(),i,s,o;switch(a[h]){case 74:h++,i=$(),k(73),s="square";break;case 57:h++,i=$(),k(56),s="doublecircle";break;case 72:72===a[++h]?(h++,i=$(),k(71),v(71),s="circle"):(i=$(),k(71),s="round");break;case 47:h++,i=$(),k(45),s="ellipse";break;case 49:h++,i=$(),k(48),s="stadium";break;case 51:h++,i=$(),k(50),s="subroutine";break;case 52:{h++;let t=v(67);v(37);let r=v(67);v(70),i=$(),k(73),s="rect",o={[t]:r};break}case 55:h++,i=$(),k(54),s="cylinder";break;case 76:76===a[++h]?(h++,i=$(),k(75),v(75),s="hexagon"):(i=$(),k(75),s="diamond");break;case 53:h++,i=$(),k(73),s="odd";break;case 60:h++,i=$(),59===a[h]?(h++,s="lean_right"):(k(58),s="trapezoid");break;case 61:h++,i=$(),58===a[h]?(h++,s="lean_left"):(k(59),s="inv_trapezoid")}return void 0!==o?r.addVertex(n,i,s,void 0,void 0,void 0,o):void 0!==s?r.addVertex(n,i,s):r.addVertex(n),r.addVertexMapping(n,i,s,y(t,h-1)),n})();return 36===a[h]&&(h++,r.setClass(t,x())),t},S=()=>{let t=[E()];for(f=void 0;;){let r=7===a[h]?M():void 0,n=p,i=g;if(78!==a[h])return f=r,t;do h++;while(78===a[h]);if(38!==a[h])return void 0!==r&&m("'AMP'"),t;78!==a[++h]&&m("'SPACE'");do h++;while(78===a[h]);let s=E();void 0!==r&&_(t[t.length-1],r,n,i),t.push(s)}},C=()=>{let t;if(33===a[h]&&(t=l[h++]),42===a[h]){let n=r.destructLink(l[h++]);return void 0!==t&&(n.id=t),70===a[h]&&(h++,n.text=$(),k(70),78===a[h]&&h++),n}if(43===a[h]){let n=l[h++],i=(()=>{let t=a[h],r;if(11===t)r="string";else if(10===t)r="markdown";else{if(44!==t&&69!==t)return m("'EDGE_TEXT', 'STR', 'MD_STR'");r="text"}let n=l[h++];for(;44===a[h]||69===a[h];)n+=l[h++];return{text:n,type:r}})(),s=v(42,"'EDGE_TEXT'"),o=r.destructLink(s,n);return o.text=i,void 0!==t&&(o.id=t),o}return m("'LINK', 'START_LINK'")},T=()=>{0===rs[a[h]]&&m("'NODE_STRING', 'NUM', 'COLON', 'BRKT'");let t=l[h++];for(;1===rs[a[h]];)t+=l[h++];return t},I=()=>{let t=[T()];for(;40===a[h];)h++,t.push(T());return t},N=(t,n)=>{if(78!==a[h])return void r.setLink(t,n);if(25===a[++h])return void r.setLink(t,n,l[h++]);let i=v(11,"'LINK_TARGET'");78===a[h]?(h++,r.setLink(t,n,v(25))):r.setLink(t,n),r.setTooltip(t,i)},O=t=>{v(78,rc);let r=(()=>{let t=a[h],r;if(11===t)r="text";else if(10===t)r="markdown";else{if(1!==ra[t])return m("'NODE_STRING', 'STR', 'MD_STR'");r="text"}let n=l[h++];for(;1===ra[a[h]];)n+=l[h++];return{text:n,type:r}})(),n={text:"",type:"text"};74===a[h]&&(h++,n=$(),k(73));let i=7===a[h]?M():void 0;return 0===ro[a[h]]&&m(`${rc}, 'SHAPE_DATA'`),{global:!1,at:t,id:r,title:n,data:i,dataFrom:p,dataTo:g,list:[],collect:!1}},D=()=>{let t=a[h];switch(t){case 12:{h++,v(78);let t=x();return v(78),r.addVertex(t,void 0,void 0,I()),b(),ru}case 14:return(()=>{let t;if(h++,v(78),13===a[h])t=[l[h++]];else for(t=[v(34,"'DEFAULT'")];40===a[h];)h++,t.push(v(34));if(v(78),15!==a[h])return r.updateLink(t,I());h++,v(78);let n=w();if(78===a[h]){h++;let i=I();r.updateLinkInterpolate(t,n),r.updateLink(t,i)}else r.updateLinkInterpolate(t,n)})(),b(),ru;case 16:{h++,v(78);let t=x();return v(78),r.addClass(t,I()),b(),ru}case 17:{h++,v(78);let t=x();return v(78),r.setClass(t,x()),b(),ru}case 19:return(()=>{let t=l[h++];switch(a[h]){case 8:{let n=l[h++],i=9===a[h],s=i?l[h++]:void 0,o;78===a[h]&&(h++,o=v(11)),i?r.setClickEvent(t,n,s):r.setClickEvent(t,n),void 0!==o&&r.setTooltip(t,o);return}case 18:h++,N(t,v(11));return;case 11:N(t,l[h++]);return;default:{let n=w();if(78===a[h]){h++;let i=v(11);r.setClickEvent(t,n),r.setTooltip(t,i)}else r.setClickEvent(t,n)}}})(),b(),ru;case 22:{let t=O(h++),n=h++,i=r.addConnector(t.id,t.title);return A(i,t),r.addConnectorMapping(t.id,t.title,y(t.at,t.at),y(n,n)),i}case 28:case 29:case 30:case 31:case 32:return h++,{stmt:"dir",value:rf[t-28]};case 2:{h++;let t=v(3).trim();return r.setAccTitle(t),t}case 4:{h++;let t=v(5).trim();return r.setAccDescription(t),t}case 6:{let t=l[h++].trim();return r.setAccDescription(t),t}default:{0===rn[t]&&m(rp);let n=(()=>{let t=h,n=S();void 0!==f&&_(n[n.length-1],f,p,g);let i=n;for(;;){let s=a[h];if(42!==s&&43!==s&&33!==s)return i;let o=C(),l=S();void 0!==f&&_(l[l.length-1],f,p,g),r.addLink(n,l,o),r.addEdgeMapping(n,l,o,y(t,h-1)),i=l.concat(i),n=l}})();return b(),n}}};for(;78===a[h]||77===a[h]||66===a[h];)h++;if(v(20,"'SPACE', 'NEWLINE', 'COMMENT'"),26===a[h])h++,r.setDirection("TB");else{let t=v(27,"'NODIR'"),n=a[h];if(78===n){do h++;while(78===a[h]);77!==(n=a[h])&&m("'NEWLINE', 'SPACE'")}else 39!==n&&77!==n&&66!==n&&m("'COMMENT', 'SEMI', 'NEWLINE', 'SPACE'");h++,r.setDirection(t)}(()=>{let t=[],n=[],i=!1;for(;;){let s=a[h];if(0===s)break;if(24===s){let a=t.pop();if(void 0===a)break;let s=h++;if(a.global){r.addGlobal(n),n=a.list,i=a.collect;continue}let o=r.addSubGraph(a.id,n,a.title,"flow");A(o,a),r.addSubgraphMapping(a.id,a.title,y(a.at,a.at),y(s,s)),n=a.list,(i=a.collect)&&n.push(o)}else if(39===s||77===s||78===s||79===s)i&&n.push(l[h]),h++;else if(66===s)h++;else if(21===s||23===s){let r=h++,o;23===s||1===ro[a[h]]?(o={global:23===s,at:r,id:void 0,title:void 0,data:void 0,dataFrom:0,dataTo:0,list:n,collect:i},b()):((o=O(r)).list=n,o.collect=i,h++),t.push(o),n=[],i=!0}else{let t=D();i&&(!Array.isArray(t)||t.length>0)&&n.push(t)}}t.length>0&&m("'end'")})(),0!==a[h]&&m(rp)}(t,l),ib(l,r),l},render:function(t,r,n){return id(t.direction)?ic(n,i=>i$(t,r,n,i)):i$(t,r,n,!1)}},{type:"treeView",parse:(t,r,n)=>{var i;let s;return i=function(t){let{text:r,lineMap:n,columns:i}=function(t){let r=new Map,n=new Map;if(!fs.test(t))return{text:t,lineMap:r,columns:n};let i=t.split(`
|
|
140
|
+
`),a=-1;for(let t=0;t<i.length;t++)if("treeView-beta"===i[t].trim()){a=t;break}if(-1===a)return{text:t,lineMap:r,columns:n};let s=t=>""===t.trim()||fh.test(t)||fu.test(t),o=[];for(let t=a+1;t<i.length;t++){let r=i[t];s(r)||fc.test(r)||o.push(r.replace(/\t/g," "))}if(!o.some(t=>fs.test(t)))return{text:t,lineMap:r,columns:n};let l=function(t){for(let r of t){let t=fo.exec(r);if(t?.index&&t.index>0)return t.index}return 4}(o),c=[],d=(t,i,a)=>{c.push(t),r.set(c.length,i+1),a&&n.set(c.length,a)};for(let t=0;t<=a;t++)d(i[t],t);for(let r=a+1;r<i.length;r++){let n=i[r];if(s(n)){d(n,r);continue}if(fc.test(n))continue;let a=n.replace(/\t/g," "),o=fo.exec(a);if(o){let i=Math.round(o.index/l)+1,s=o.index+1;for(;s<a.length&&fl.test(a[s]);)s++;for(;s<a.length&&" "===a[s];)s++;let c=a.slice(s).trimEnd();c||fp(t,r,"Empty node — expected a filename or directory name after the box-drawing prefix");let u=" ".repeat(i);d(u+c,r,t=>(function(t,r){let n=0;for(let i=0;n<t.length&&i<r;n++)i+=" "===t[n]?4:1;return n})(n,s+Math.max(t-u.length,0)))}else{if(fd.test(a))continue;fs.test(a)?d(n,r):/^\s+/.test(a)?fp(t,r,"Unexpected indentation without box-drawing characters. In box-drawing format, use ├── or └── prefixes for indented nodes."):d(n,r)}}return{text:c.join(`
|
|
141
|
+
`),lineMap:r,columns:n}}(t);try{var s,o;let t=new iG(iE(r,fm,"treeView"),fm,"treeView"),n={$type:"TreeView",nodes:[]};for(t.expect(0);;)if(1===t.kind)n.accDescr=iq(t.take());else if(2===t.kind)n.accTitle=iU(t.take());else if(3===t.kind)n.title=iH(t.take());else break;for(;-1!==t.kind;){let r={$type:"TreeNode",name:""};if(7===t.kind&&(r.indent=t.take().length),8===t.kind){let n=t.take();r.name=n.substring(1,n.length-1)}else 12===t.kind?r.name=fy(t.take()):t.fail("a name");for(;;)if(4===t.kind)r.classAnnotation=fv("CLASS_ANNOTATION",t.take());else if(5===t.kind)r.iconAnnotation=fv("ICON_ANNOTATION",t.take());else if(6===t.kind)r.descAnnotation=fv("DESC_ANNOTATION",t.take());else break;n.nodes.push(r)}return n}catch(p){if(!(p instanceof a)||r===t)throw p;let l=n.get(p.line);if(void 0===l)throw p;let d=p.column>0?i.get(p.line)?.(p.column-1)??p.column-1:0,u=c(t,ff(t,l)+d),h=p.message.includes(`
|
|
142
|
+
`)?p.message.indexOf(`
|
|
143
|
+
`):p.message.length,f=p.message.slice(h);throw new a((s=p.message.slice(0,h),o=new Map([[p.line,u.line]]),s.replace(/\bline\s+(\d+)\b/gi,(t,r)=>{let n=o.get(parseInt(r,10));return n?`line ${n}`:t})+(p.snippet?f.replace(p.snippet,()=>u.snippet):f)),p.code,{type:p.type,line:u.line,column:p.column>0?u.column:0,snippet:p.snippet?u.snippet:""})}}(t),function(t,r){for(let n of t.nodes){let t="number"==typeof n.indent?n.indent:0,i=n.name,a=i.endsWith("/");a&&(i=i.slice(0,-1));let s=n.iconAnnotation;r.addNode(t,i,a?"directory":"file",n.classAnnotation||void 0,void 0!==s?s||"none":void 0,n.descAnnotation||void 0)}}(i,s=new fb),{type:"treeView",title:i.title||n,accTitle:i.accTitle?i.accTitle.replace(/^\s+/g,""):void 0,accDescr:i.accDescr?i.accDescr.replace(/\n\s+/g,`
|
|
144
|
+
`):void 0,root:s.root,count:s.count}},render:function(t,r,n){return iu(n,i=>(function(t,r,n,i){let a,s,o=n.fontSize??16,l=n.measurer??e$(n.fontFamily,n.fontFamilyMono),c=n.padding??8,d={showIcons:!!(s=(a=t=>"object"!=typeof t||null===t||Array.isArray(t)?void 0:t)(r.treeView)??{}).showIcons,defaultIconPack:"string"==typeof s.defaultIconPack?s.defaultIconPack:"",filenameIcons:a(s.filenameIcons),extensionIcons:a(s.extensionIcons)},u=Array.isArray(n.monospace)&&n.monospace.includes("files"),h=u?` font-family="${r3}"`:"",{paddingX:f,paddingY:p,rowIndent:g,lineThickness:m}={paddingX:f_(r,"paddingX",5,0,100),paddingY:f_(r,"paddingY",2,0,100),rowIndent:f_(r,"rowIndent",15,0,400),lineThickness:f_(r,"lineThickness",1,.25,12)},v=0,b=t.root.children.map(t=>[t,0]);for(let t=0;i&&t<b.length;t++){let[r,n]=b[t];for(let t of(v=Math.max(v,n),r.children))b.push([t,n+1])}let x=i?Math.min(g+f,Math.max(2,((n.maxWidth??320)-120)/Math.max(1,v))):g+f,w=Math.round(1.5*o)+2*p,$=n7(t.title,!1,l,o,i?io(n):4e3,1),k=$.height>0?$.height+12:0,M=[],_=new Map,A=[],E=(t,r)=>{let n=t.some(t=>void 0!==fM(t,d));for(let i=t.length-1;i>=0;i--)A.push([t[i],r,n])};E(t.root.children,0);let S=0,C=!1,T=0;for(;A.length>0;){let[t,r,a]=A.pop(),s=r*x,h=y(t.name),f=s+(a?o+6:0),g=Math.max(40,(n.maxWidth??320)-2*c-8-f),m="directory"===t.nodeType|4*!!u,v=i?aX(h,l,o,g,m):void 0,b=i&&t.description?aX(y(t.description),l,o,g,2):void 0,$=v?v.width:l.width(h,o,m);f+$>S&&(S=f+$);let k=void 0!==t.cssClass&&t.cssClass.split(/\s+/).includes("highlight");k&&(C=!0);let I=i?Math.max(w,(v?.height??0)+(b?.height??0)+2*p):w,N={node:t,x:s,cy:T+(i?p+Math.max(o,v?.height??0)/2:I/2),icon:fM(t,d),text:h,labelX:f,highlighted:k,label:v,description:b,top:T,height:I};T+=I,M.push(N),_.set(t,N),E(t.children,r+1)}let I=S+16,N=S;for(let t of M){let r=t.node.description;if(!r)continue;let n=t.description?t.description.width:l.width(y(r),o,2);N=Math.max(N,(i?t.labelX:I)+n)}N=Math.max(N,$.width);let O=c+4*!!C,D=c+k,R=Math.ceil(N+2*O),L=Math.ceil(D+T+c),z="";for(let t of M){let r=t.node.children;if(0===r.length)continue;let n=O+t.x+7,i=Math.max(n,O+t.x+x-f),a=D+_.get(r[r.length-1]).cy,s=Math.min(4,i-n),o=`M${eT(n)},${eT(D+t.top+t.height-2)}V${eT(a-s)}`;s>0&&(o+=`Q${eT(n)},${eT(a)} ${eT(n+s)},${eT(a)}H${eT(i)}`);for(let t=0;t<r.length-1&&i>n;t++)o+=`M${eT(n)},${eT(D+_.get(r[t]).cy)}H${eT(i)}`;z+=`<path d="${o}"/>`}let P=.35*o,j="";for(let t of M){let r=t.node,i=D+t.cy,a="directory"===r.nodeType,s="";if(t.highlighted){let r=O+t.x-4;s+=`<rect class="pele-tree-highlight" x="${eT(r)}" y="${eT(D+t.top+1)}" width="${eT(R-O+4-r)}" height="${eT(t.height-2)}" fill="var(--_c)" fill-opacity="0.14"${r5}/>`}if(void 0!==t.icon){let r=t.icon.startsWith(fx+":")?t.icon.slice(fx.length+1):"",l=fw.get(r)??fw.get(a?"folder":"file"),c=n.icons?.(t.icon)??`<path d="${l}" stroke="var(--_m)" stroke-width="1.5"/>`;s+=`<svg class="pele-icon" data-icon="${eS(t.icon)}" x="${eT(O+t.x)}" y="${eT(i-o/2)}" width="${eT(o)}" height="${eT(o)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${c}</svg>`}t.label?s+=aJ(t.label,O+t.labelX,D+t.top+p,` class="pele-label"${a?' font-weight="var(--_hw)"':""}${h}`):""!==t.text&&(s+=`<text class="pele-label" x="${eT(O+t.labelX)}" y="${eT(i+P)}"${a?' font-weight="var(--_hw)"':""}${h} xml:space="preserve">${eE(t.text)}</text>`),t.description?s+=aJ(t.description,O+t.labelX,D+t.top+p+(t.label?.height??0),' class="pele-tree-description" font-style="italic" fill="var(--_m)"'):r.description&&(s+=`<text class="pele-tree-description" x="${eT(O+I)}" y="${eT(i+P)}" font-style="italic" fill="var(--_m)" xml:space="preserve">${eE(y(r.description))}</text>`),j+=`<g class="pele-node pele-tree-${a?"dir":"file"}${nc(r.cssClass??"")}" data-id="${eS(r.name)}">${s}</g>`}let F=eI($,R/2,c+$.height/2,' class="pele-title" font-weight="var(--_tw)"')+(z?`<g class="pele-tree-guides" fill="none" stroke="var(--_b)" stroke-width="${eT(m)}">${z}</g>`:"")+j;return{svg:np("treeView",R,L,o,n,t,F),width:R,height:L,links:[]}})(t,r,n,i))}},{type:"cynefin",parse:(t,r,n)=>{var i;let a;return i=function(t){let r=new iG(iE(t,sO,"cynefin"),sO,"cynefin"),n={$type:"Cynefin",domains:[],transitions:[]},i=()=>{for(;9===r.kinds[r.i];)r.i++},a=()=>{-1!==r.kind&&(9!==r.kind&&r.fail("a line break or the end of input"),i())};for(i(),1!==r.kind&&0!==r.kind&&r.fail("'cynefin-beta'"),r.i++;-1!==r.kind;)switch(r.kind){case 9:r.i++;break;case 5:n.accDescr=iq(r.take()),a();break;case 6:n.accTitle=iU(r.take()),a();break;case 7:n.title=iH(r.take()),a();break;case 4:{let t=r.take();if(r.accept(2)){let i={$type:"Transition",from:t,to:r.expect(4)};r.accept(3)&&(i.label=iY(r.expect(8))),a(),n.transitions.push(i);break}let s={$type:"DomainBlock",domain:t,items:[]};for(i();8===r.kinds[r.i];)s.items.push({$type:"DomainItem",label:iY(r.take())}),i();n.domains.push(s);break}default:r.fail("a domain, a transition, a title, or a line break")}return n}(t),(a=new sN).setDomains(i.domains),a.setTransitions(i.transitions),{type:"cynefin",title:i.title||n,accTitle:i.accTitle?i.accTitle.replace(/^\s+/g,""):void 0,accDescr:i.accDescr?i.accDescr.replace(/\n\s+/g,`
|
|
145
|
+
`):void 0,domains:a.domains,transitions:a.transitions}},render:function(t,r,n){var i,a,s;let o,l,c=n.fontSize??16,d=Math.round(.8125*c),u=Math.round(.875*c),h=n.measurer??e$(n.fontFamily,n.fontFamilyMono),f=n.padding??8,p=n.icons,g=r.cynefin?.showDomainDescriptions!==!1,m=sH(r,"boundaryAmplitude",8,0,50),y=(i=sH(r,"seed",0,-1e15,1e15),a=n.idPrefix??"pele","number"==typeof i&&Number.isFinite(i)&&0!==i?i:function(t){let r=0;for(let n=0;n<t.length;n++)r=(r<<5)-r+t.charCodeAt(n)|0;return r}(a)),v=Math.round(1.5*u),b=(t,r)=>{let n=n7(t,!1,h,u,200);return{text:t,label:n,w:n.width+20,h:Math.max(n.height,v)+8,overflow:r}},x=r=>{let n=sW.get(r),i=n7(n[0],!1,h,c,4e3,1),a=[];if(g)for(let t of[n[1],n[2]])t&&a.push(n7(t,!1,h,d,4e3,2));let s=t.domains.get(r)?.items??[],o="confusion"===r&&s.length>3?3:s.length,l=[];for(let t=0;t<o;t++)l.push(b(s[t].label,!1));o<s.length&&l.push(b(`+${s.length-o} more`,!0));let u=i.width,f=i.height;for(let t of a)u=Math.max(u,t.width),f+=t.height;for(let t of(l.length>0&&(f+=4),l))u=Math.max(u,t.w),f+=6+t.h;return{name:r,title:i,subtitles:a,badges:l,w:u,h:f,cx:0,cy:0}},w=sB.map(([t])=>x(t)),$=x("confusion"),k=Math.max(88,.71*$.w+8),M=Math.max(64,.71*$.h+6),_=sH(r,"width",640,100,1e4)/2,A=sH(r,"height",440,100,1e4)/2;for(let t of w)_=Math.max(_,t.w+40),A=Math.max(A,t.h+40);for(let t of w){if(((_-t.w)/2/(k+10))**2+((A-t.h)/2/(M+10))**2>=1)continue;let r=t.w+2*(k+10),n=t.h+2*(M+10);r*A<=_*n?_=Math.max(_,r):A=Math.max(A,n)}let E=n7(t.title,!1,h,c,4e3,1),S=E.height>0?E.height+12:0,C=2*_,T=2*A,I=f+S,N=f+_,O=I+A,D=f+C,R=I+T,L=sz(I,O,N,y,m,{...sR,segments:4,pinEnd:!0}),z=sz(f,N,O,y+100,m,{...sL,segments:4,pinEnd:!0}),P=sz(N,D,O,y+200,m,{...sL,segments:4,pinStart:!0}),j=(s=.03*C,o=R-O,[N,O,N+s,O+.2*o,N-1.5*s,O+.55*o,N+.5*s,O+.75*o,N-s,O+.85*o,N+.3*s,O+.95*o,N,R]),F=(t,r)=>r?`${eT(t[t.length-2])},${eT(t[t.length-1])}`:`${eT(t[0])},${eT(t[1])}`,B=new Map([["complex",`M${eT(f)},${eT(I)}L${F(L,!1)}${sP(L)}${sj(z)}Z`],["complicated",`M${F(L,!1)}L${eT(D)},${eT(I)}L${F(P,!0)}${sj(P)}${sj(L)}Z`],["chaotic",`M${F(z,!1)}${sP(z)}${sP(j)}L${eT(f)},${eT(R)}Z`],["clear",`M${F(P,!1)}${sP(P)}L${eT(D)},${eT(R)}L${F(j,!0)}${sj(j)}Z`]]),W="";for(let[t,,,r]of sB)W+=`<path class="pele-cynefin-region" data-id="${t}" d="${B.get(t)}" fill="${nu(r)}" fill-opacity="0.14"/>`;let H=`<g class="pele-cynefin-boundaries" fill="none" stroke="var(--_b)" stroke-dasharray="6 3"><path d="${sF(L)}"/><path d="${sF(z)}"/><path d="${sF(P)}"/><path class="pele-cynefin-cliff" d="${sF(j)}" stroke="var(--_l)" stroke-width="2" stroke-dasharray="none" stroke-linecap="round"/></g>`,U=(l=`${eT(k)},${eT(M)}`,`M${eT(N-k)},${eT(O)}A${l} 0 1,1 ${eT(N+k)},${eT(O)}A${l} 0 1,1 ${eT(N-k)},${eT(O)}Z`),q=`<path d="${U}" fill="var(--_bg)"/><path class="pele-cynefin-region" data-id="confusion" d="${U}" fill="${nu(4)}" fill-opacity="0.18" stroke="var(--_b)" stroke-dasharray="4 2"/>`,V=t=>{let r=t.cy-t.h/2,n=eI(t.title,t.cx,r+t.title.height/2,' class="pele-label" font-weight="var(--_hw)"');for(let i of(r+=t.title.height,t.subtitles))n+=eI(i,t.cx,r+i.height/2,` class="pele-cynefin-subtitle" font-size="${d}" font-style="italic" fill="var(--_m)"`),r+=i.height;for(let i of(r+=4,t.badges))r+=6,n+=`<g class="pele-node${i.overflow?" pele-cynefin-overflow":""}"${i.overflow?"":` data-id="${eS(i.text)}"`}><rect x="${eT(t.cx-i.w/2)}" y="${eT(r)}" width="${eT(i.w)}" height="${eT(i.h)}" fill="var(--_bg)" stroke="var(--_b)"${i.overflow?' stroke-dasharray="3 2"':""}${r5}/>`+eI(i.label,t.cx,r+i.h/2,` class="pele-label" font-size="${u}"${i.overflow?' fill="var(--_m)"':""}`,p)+"</g>",r+=i.h;return`<g class="pele-cynefin-domain" data-id="${t.name}">${n}</g>`},Y=new Map,G="";sB.forEach(([t,r,n],i)=>{let a=w[i];a.cx=f+_*(r+.5),a.cy=I+A*(n+.5),Y.set(t,a),G+=V(a)}),$.cx=N,$.cy=O,Y.set("confusion",$),G+=V($);let Z=(t,r,n)=>t===$?((r-N)/(k+4))**2+((n-O)/(M+4))**2<=1:Math.abs(r-t.cx)<=t.w/2+8&&Math.abs(n-t.cy)<=t.h/2+8,X="",K=new Map;for(let r of t.transitions){let t=Y.get(r.from),n=Y.get(r.to);if(!t||!n||t===n)continue;let i=r.from<r.to?`${r.from} ${r.to}`:`${r.to} ${r.from}`,a=K.get(i)??0;K.set(i,a+1);let s=n.cx-t.cx,o=n.cy-t.cy,l=Math.hypot(s,o)||1,c=(t.cx+n.cx)/2,u=(t.cy+n.cy)/2,g=-o*(c-N)+s*(u-O)>=0?1:-1,m=-o/l*g,y=s/l*g,v=(t!==$&&n!==$&&Math.abs(s)>1&&Math.abs(o)>1?2*(Math.hypot(k*m,M*y)+16):.15*l)+56*a,b=c+m*v,x=u+y*v,w=r=>{let i=1-r;return[i*i*t.cx+2*i*r*b+r*r*n.cx,i*i*t.cy+2*i*r*x+r*r*n.cy]},_=(t,r,n,i)=>{for(let a=0;a<16;a++){let a=(r+n)/2;Z(t,...w(a))===i?r=a:n=a}return(r+n)/2},A=1;for(;A<=48&&Z(t,...w(A/48));)A++;if(A>48)continue;let E=_(t,(A-1)/48,A/48,!0);for(;A<=48&&!Z(n,...w(A/48));)A++;let S=A>48?1:_(n,(A-1)/48,A/48,!1),[C,T]=w(E),[I,R]=w(S),L=(t,r,n)=>(1-E)*(1-S)*t+((1-E)*S+E*(1-S))*r+E*S*n,z=L(t.cx,b,n.cx),P=L(t.cy,x,n.cy),j=Math.hypot(I-z,R-P)||1,F=(I-z)/j,B=(R-P)/j,W=rV("arrow_point",I,R,F,B,"var(--_l)");I-=F*rq("arrow_point"),R-=B*rq("arrow_point");let H="";if(r.label){let t=n7(r.label,!1,h,d,200),[n,i]=w((E+S)/2),a=Math.abs(m)*t.width/2+Math.abs(y)*t.height/2+6,s=t.width/2+4;H=eI(t,Math.min(Math.max(n+m*a,f+s),Math.max(D-s,f+s)),i+y*a,` class="pele-edge-label" font-size="${d}"`,p)}X+=`<g class="pele-edge" data-id="${r.from}-${r.to}"><path d="M${eT(C)},${eT(T)}Q${eT(z)},${eT(P)} ${eT(I)},${eT(R)}" fill="none" stroke="var(--_l)"/>`+W+H+"</g>"}let J=Math.ceil(Math.max(C,E.width)+2*f),Q=Math.ceil(T+S+2*f);return{svg:np("cynefin",J,Q,c,n,t,eI(E,f+C/2,f+E.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g class="pele-cynefin-regions">${W}</g>`+H+q+G+(X?`<g class="pele-edges">${X}</g>`:"")),width:J,height:Q,links:[]}}},{type:"wardley",section:"wardley-beta",parse:(t,r,n)=>{var i;let s;return i=function(t){let r=new iG(iE(t,go,"wardley"),go,"wardley"),n={$type:"Wardley",anchors:[],components:[],links:[],evolves:[],pipelines:[],notes:[],annotations:[],annotation:[],accelerators:[],deaccelerators:[]},i=t=>r.kinds[r.i]===t,a=()=>i(36)||i(37)||i(30),s=()=>i(36)?iY(r.take()):i(37)||i(30)?r.take():r.fail("a name"),o=()=>Number(r.expect(10)),l=()=>parseInt(r.expect(35)),c=()=>i(10)?Number(r.take()):parseInt(r.expect(35)),d=()=>{if(!i(-1))for(i(38)||r.fail("a line break or the end of input");i(38);)r.i++},u=t=>{r.expect(0);let n=t();r.expect(1);let i=t();return r.expect(2),[n,i]},h=()=>{r.expect(21),r.expect(0);let t=r.accept(7),n=l();r.expect(1);let i=r.accept(7),a=l();return r.expect(2),{$type:"Label",negX:t,offsetX:n,negY:i,offsetY:a}},f=()=>{let t={$type:"EvolutionStage",name:s()};return r.accept(3)&&(t.boundary=o()),r.accept(4)&&(t.secondName=s()),t};for(;i(38);)r.i++;for(r.expect(16);!i(-1);)switch(r.kind){case 38:r.i++;break;case 32:n.accDescr=iq(r.take()),d();break;case 33:n.accTitle=iU(r.take()),d();break;case 34:n.title=iH(r.take()),d();break;case 17:{r.i++;let[t,i]=u(l);d(),n.size={$type:"Size",width:t,height:i};break}case 18:{r.i++;let t=[f()];for(r.expect(11),t.push(f());r.accept(11);)t.push(f());d(),n.evolution={$type:"Evolution",stages:t};break}case 19:{r.i++;let t=s(),[i,a]=u(o);d(),n.anchors.push({$type:"Anchor",name:t,visibility:i,evolution:a});break}case 20:{r.i++;let t={$type:"Component",name:s(),visibility:0,evolution:0,inertia:!1};[t.visibility,t.evolution]=u(o),i(21)&&(t.label=h()),i(5)&&15===r.kinds[r.i+1]&&(r.i++,t.decorator={$type:"Decorator",strategy:r.take()},r.expect(6)),r.accept(22)?t.inertia=!0:r.accept(5)&&(r.expect(22),r.expect(6),t.inertia=!0),d(),n.components.push(t);break}case 23:{r.i++;let t=s(),i=o();d(),n.evolves.push({$type:"Evolve",component:t,target:i});break}case 24:{r.i++;let t=s();for(r.expect(8),r.expect(38);i(38);)r.i++;let a=[];do{r.expect(20);let t={$type:"PipelineComponent",name:s(),evolution:0};r.expect(0),t.evolution=o(),r.expect(2),i(21)&&(t.label=h()),d(),a.push(t)}while(i(20));r.expect(9),d(),n.pipelines.push({$type:"Pipeline",parent:t,components:a});break}case 25:{r.i++;let t=iY(r.expect(36)),[i,a]=u(o);d(),n.notes.push({$type:"Note",text:t,visibility:i,evolution:a});break}case 26:{r.i++;let[t,i]=u(c);d(),n.annotations.push({$type:"Annotations",x:t,y:i});break}case 27:{r.i++;let t=l();r.expect(1);let[i,a]=u(c),s=iY(r.expect(36));d(),n.annotation.push({$type:"Annotation",number:t,x:i,y:a,text:s});break}case 28:case 29:{let t=29===r.kind;r.i++;let i=s(),[a,l]=u(o);d(),t?n.deaccelerators.push({$type:"Deaccelerator",name:i,x:a,y:l}):n.accelerators.push({$type:"Accelerator",name:i,x:a,y:l});break}default:{a()||r.fail("a statement");let t={$type:"Link",from:s(),to:""};i(12)&&(t.fromPort=r.take()),(i(13)||i(11))&&(t.arrow=r.take()),t.to=s(),i(12)&&(t.toPort=r.take()),i(14)&&(t.linkLabel=r.take().substring(1).trim()),d(),n.links.push(t)}}return n}(t),function(t,r){for(let n of(t.size&&r.setSize(t.size.width,t.size.height),t.evolution&&r.setAxes({stages:t.evolution.stages.map(t=>t.secondName?`${t.name.trim()} / ${t.secondName.trim()}`:t.name.trim()),stageBoundaries:t.evolution.stages.filter(t=>void 0!==t.boundary).map(t=>t.boundary)}),t.anchors)){let t=ge(n.visibility,n.evolution,`Anchor "${n.name}"`);r.addNode({id:n.name,label:n.name,x:t.x,y:t.y,className:"anchor"})}for(let n of t.components){let t=ge(n.visibility,n.evolution,`Component "${n.name}"`),[i,a]=gr(n.label);r.addNode({id:n.name,label:n.name,x:t.x,y:t.y,className:"component",labelOffsetX:i,labelOffsetY:a,inertia:n.inertia,sourceStrategy:n.decorator?.strategy})}for(let n of t.notes){let t=ge(n.visibility,n.evolution,`Note "${n.text}"`);r.addNote({text:n.text,x:t.x,y:t.y})}for(let n of t.pipelines){let t=r.getNode(n.parent);if(!t||"number"!=typeof t.y)throw new a(`Pipeline "${n.parent}" must reference an existing component with coordinates.`,"semantic",{type:"wardley"});let i=t.y;for(let t of(r.startPipeline(n.parent),n.components)){let a=`${n.parent}_${t.name}`,[s,o]=gr(t.label),l=p7(t.evolution,`Pipeline component "${t.name}" evolution`);r.addNode({id:a,label:t.name,x:l,y:i,className:"pipeline-component",labelOffsetX:s,labelOffsetY:o,inertia:void 0,sourceStrategy:void 0}),r.addPipelineComponent(n.parent,a)}}for(let n of t.links){let t=!!n.arrow&&(n.arrow.includes("-.->")||n.arrow.includes(".-.")),i=function(t){if(!t?.startsWith("+"))return{};let r=t.indexOf("'",2),n="'"===t[1]&&-1!==r?t.slice(2,r):void 0;return t.includes("<>")?{flow:"bidirectional",label:n}:t.includes("<")?{flow:"backward",label:n}:t.includes(">")?{flow:"forward",label:n}:{label:n}}(n.arrow),a=gt(n.fromPort)??gt(n.toPort)??i.flow;r.addLink({source:r.resolveNodeId(n.from),target:r.resolveNodeId(n.to),dashed:t,label:i.label??n.linkLabel,flow:a})}for(let n of t.evolves){let t=r.getNode(n.component);t?.y!==void 0&&r.addTrend({nodeId:n.component,targetX:p7(n.target,`Evolve target for "${n.component}"`),targetY:t.y})}if(t.annotations.length>0){let n=ge(t.annotations[0].x,t.annotations[0].y,"Annotations box");r.setAnnotationsBox(n.x,n.y)}for(let n of t.annotation){let t=ge(n.x,n.y,`Annotation ${n.number}`);r.addAnnotation({number:n.number,coordinates:[{x:t.x,y:t.y}],text:n.text})}for(let n of t.accelerators){let t=ge(n.x,n.y,`Accelerator "${n.name}"`);r.addAccelerator({name:n.name,x:t.x,y:t.y})}for(let n of t.deaccelerators){let t=ge(n.x,n.y,`Deaccelerator "${n.name}"`);r.addDeaccelerator({name:n.name,x:t.x,y:t.y})}}(i,s=new p9),{type:"wardley",title:i.title||n,accTitle:i.accTitle?i.accTitle.replace(/^\s+/g,""):void 0,accDescr:i.accDescr?i.accDescr.replace(/\n\s+/g,`
|
|
146
|
+
`):void 0,...s.build()}},render:function(t,r,n){let i=gf(r,t.size?.width,"width",900);return is(n,i,160,(a,s)=>(function(t,r,n,i,a,s){let o=n.fontSize??16,l=Math.round(.8125*o),c=Math.round(.6875*o),d=n.measurer??e$(n.fontFamily,n.fontFamilyMono),u=n.padding??8,h=gf(r,t.size?.height,"height",600)*Math.max(.75,i/a),f=r["wardley-beta"]?.showGrid===!0,p=0,g=0,m=i,y=h,v=(t,r,n,i)=>{t<p&&(p=t),r<g&&(g=r),n>m&&(m=n),i>y&&(y=i)},b=(t,r,i,a)=>(v(r-t.width/2,i-t.height/2,r+t.width/2,i+t.height/2),eI(t,r,i,a,n.icons)),x=(t,r,n,i)=>(v(r,n-t.size,r+t.width,n-t.size+t.height+4),gh(t,r,n,i)),w=(t,r,n=s?Math.max(64,Math.min(120,i/2)):4e3,a=0)=>n7(t,!1,d,r,n,a),$=t=>t/100*i,k=t=>h-t/100*h,M=t.axes.stages&&t.axes.stages.length>0?t.axes.stages:gl,_=t.axes.stageBoundaries,A=void 0!==_&&_.length===M.length,E="",S="",C=h,T=0;if(M.forEach((t,r)=>{let n=A?T:r/M.length,a=A?gu(_[r],0,1):(r+1)/M.length;T=a,r>0&&(E+=`<path class="pele-wardley-stage" d="M${eT(n*i)},0V${eT(h)}" stroke="var(--_b)" stroke-dasharray="4 4"/>`);let s=w(t,l,Math.max(48,Math.abs(a-n)*i-12));S+=b(s,(n+a)/2*i,h+8+s.height/2,` class="pele-wardley-stage-label" font-size="${l}" fill="var(--_m)"`),C=Math.max(C,h+8+s.height)}),f)for(let t=1;t<4;t++)E+=`<path class="pele-wardley-grid" d="M${eT(i*t/4)},0V${eT(h)}M0,${eT(h*t/4)}H${eT(i)}" stroke="var(--_b)" stroke-dasharray="2 6"/>`;E+=`<path class="pele-wardley-axis" d="M0,0V${eT(h)}H${eT(i)}" stroke="${gd}"/>`;let I=w(t.axes.xLabel??"Evolution",l),N=w(t.axes.yLabel??"Visibility",l),O=` class="pele-wardley-axis-label" font-size="${l}" font-weight="var(--_hw)"`,D=b(I,i/2,C+6+I.height/2,O)+eI(N,-16,h/2,`${O} transform="rotate(-90 -16 ${eT(h/2)})"`);v(-16-N.height/2,0,0,0);let R=C+6+I.height+10,L=new Map;for(let r of t.nodes)L.set(r.id,{x:$(r.x),y:k(r.y),node:r});let z="",P=new Map;for(let r of t.pipelines){P.set(r.nodeId,new Set(r.componentIds));let t=[];for(let n of r.componentIds){let r=L.get(n);r&&t.push(r)}if(0===t.length)continue;t.sort((t,r)=>t.x-r.x);let n=t[0].x,i=t[t.length-1].x,a=t[0].y,s=a-12,o=L.get(r.nodeId);o&&(o.x=(n+i)/2,o.y=s-10/6),v(n-15,s,i+15,s+24),z+=`<g class="pele-wardley-pipeline" data-id="${eS(r.nodeId)}"><rect x="${eT(n-15)}" y="${eT(s)}" width="${eT(i-n+30)}" height="${eT(24)}" fill="var(--_s)" stroke="var(--_b)"${r5}/>`+(t.length>1?`<path d="M${eT(n)},${eT(a)}H${eT(i)}" stroke="${gd}" stroke-dasharray="4 4"/>`:"")+"</g>"}let j=new Map,F=(t,r,n)=>{let a=t.node;if("anchor"===a.className){let t=j.get(a);return t||j.set(a,t=w(a.label,l,s?Math.max(64,i/2):4e3,1)),1/Math.hypot(r/(t.width/2+5),n/(.8*l))}return a.isPipelineParent?10/Math.SQRT2:a.sourceStrategy?12:6},B=new Map,W=(t,r,n)=>{.25>Math.abs(r)||.25>Math.abs(n)||B.set(t,(B.get(t)??0)|(r>0?n<0?1:2:n<0?4:8))},H="";for(let r of t.links){let t=L.get(r.source),n=L.get(r.target);if(!t||!n||t===n||P.get(r.target)?.has(r.source))continue;let i=n.x-t.x,a=n.y-t.y,s=Math.hypot(i,a);if(s<.01)continue;let o=i/s,l=a/s,d=F(t,o,l),u=F(n,o,l);if(d+u>=s)continue;W(t,o,l),W(n,-o,-l);let h=t.x+o*d,f=t.y+l*d,p=n.x-o*u,g=n.y-l*u,m="";("forward"===r.flow||"bidirectional"===r.flow)&&(m+=rV("arrow_point",p,g,o,l,gd),p-=o*rq("arrow_point"),g-=l*rq("arrow_point")),("backward"===r.flow||"bidirectional"===r.flow)&&(m+=rV("arrow_point",h,f,-o,-l,gd),h+=o*rq("arrow_point"),f+=l*rq("arrow_point"));let y="";if(r.label){let i=w(r.label,c+1,200),a=o>=0?1:-1,s=l*a,d=-o*a,u=5+Math.abs(s)*i.width/2+Math.abs(d)*i.height/2;y=b(i,(t.x+n.x)/2+s*u,(t.y+n.y)/2+d*u,` class="pele-edge-label" font-size="${c+1}" fill="var(--_m)"`)}H+=`<g class="pele-edge${r.dashed?" pele-wardley-dashed":""}" data-id="${eS(r.source)}-${eS(r.target)}"><path d="M${eT(h)},${eT(f)}L${eT(p)},${eT(g)}" stroke="${gd}"${r.dashed?' stroke-dasharray="6 6"':""}/>`+m+y+"</g>"}let U="";for(let r of t.trends){let t=L.get(r.nodeId);if(!t)continue;let n=$(r.targetX),i=k(r.targetY),a=n-t.x,s=i-t.y,o=Math.hypot(a,s),l="",c=o>0?F(t,a/o,s/o):0;if(o>c+6+4){let r=a/o,d=s/o,u=n-8*r,h=i-8*d;l=`<path d="M${eT(t.x+r*c)},${eT(t.y+d*c)}L${eT(u-r*rq("arrow_point"))},${eT(h-d*rq("arrow_point"))}" stroke="${gc}" stroke-dasharray="4 4"/>`+rV("arrow_point",u,h,r,d,gc)}v(n-6,i-6,n+6,i+6),U+=`<g class="pele-wardley-trend" data-id="${eS(r.nodeId)}">${l}<circle cx="${eT(n)}" cy="${eT(i)}" r="6" fill="var(--_bg)" stroke="${gc}"/></g>`}let q="";for(let t of L.values()){let r=t.node,{x:n,y:a}=t,o="anchor"===r.className,c=r.sourceStrategy,d="";if(c){let t="outsource"===c?"var(--_m)":"buy"===c?"var(--_a)":"build"===c?"var(--_s)":"var(--_bg)";d+=`<circle class="pele-wardley-${c}" cx="${eT(n)}" cy="${eT(a)}" r="12" fill="${t}" stroke="${gd}"/>`}if("market"===c){let t=7.199999999999999*Math.cos(Math.PI/6),r=a+7.199999999999999*Math.sin(Math.PI/6);for(let[i,s]of(d+=`<path d="M${eT(n)},${eT(a-7.199999999999999)}L${eT(n-t)},${eT(r)}H${eT(n+t)}Z" fill="none" stroke="${gd}"/>`,[[n,a-7.199999999999999],[n-t,r],[n+t,r]]))d+=`<circle cx="${eT(i)}" cy="${eT(s)}" r="${eT(4.199999999999999)}" fill="var(--_bg)" stroke="${gd}"/>`}else r.isPipelineParent?d+=`<rect x="${eT(n-5)}" y="${eT(a-5)}" width="10" height="10" fill="var(--_bg)" stroke="${gd}"/>`:o||(d+=`<circle cx="${eT(n)}" cy="${eT(a)}" r="6" fill="var(--_bg)" stroke="${gd}"/>`);if(!0===r.inertia){let t=(r.isPipelineParent?5:6)+10+10*!!c;d+=`<rect class="pele-wardley-inertia" x="${eT(n+t)}" y="${eT(a-6)}" width="4" height="12" fill="${gd}"/>`}let u=void 0===r.labelOffsetX?void 0:gu(r.labelOffsetX,-5e3,5e3),h=void 0===r.labelOffsetY?void 0:gu(r.labelOffsetY,-5e3,5e3),f;if(o)f=b(j.get(r)??w(r.label,l,s?Math.max(64,i/2):4e3,1),n+(u??0),a+(h??-3),` class="pele-label" font-size="${l}" font-weight="var(--_hw)"`);else{let i=w(r.label,l),s=` class="pele-label" font-size="${l}"`,o=8+10*!!c;if(void 0!==u||void 0!==h)f=x(i,n+(u??o),a+(h??-o),s);else if(r.inPipeline)f=b(i,n,a+12+4+i.height/2,s);else{let r=B.get(t)??0,c=(1&r)==0?1:(2&r)==0?2:(4&r)==0?4:(8&r)==0?8:1,d=1===c||2===c,u=1===c||4===c;f=x(i,d?n+o:n-o-i.width,u?a-o:a+o+.75*l,s)}}v(n-12,a-12,n+12+20,a+12),q+=`<g class="pele-node pele-wardley-${o?"anchor":r.isPipelineParent?"pipeline-parent":r.inPipeline?"pipeline-component":"component"}" data-id="${eS(r.id)}">${d}${f}</g>`}let V="";for(let r of t.annotations){let t=w(String(r.number),c,4e3,1),n="";for(let i of r.coordinates){let r=$(i.x),a=k(i.y),s=Math.max(10,t.width/2+4);v(r-s,a-s,r+s,a+s),n+=`<circle cx="${eT(r)}" cy="${eT(a)}" r="${eT(s)}" fill="var(--_bg)" stroke="${gd}"/>`+eI(t,r,a,` font-size="${c}" font-weight="var(--_hw)"`)}V+=`<g class="pele-wardley-annotation" data-id="${eS(String(r.number))}">${n}</g>`}let Y=t.annotations.filter(t=>t.text).sort((t,r)=>t.number-r.number);if(Y.length>0){let r=Y.map(t=>w(`${t.number}. ${t.text}`,l,s?Math.max(80,i-20):320)),n=0,a=0;for(let t of r)n=Math.max(n,t.width),a+=t.height;n+=20,a+=14;let o=t.annotationsBox,c=o?gu($(o.x),0,Math.max(0,i-n)):0,d=o?gu(k(o.y),0,Math.max(0,h-a)):R;v(c,d,c+n,d+a);let u="",f=d+7;for(let t of r)u+=gh(t,c+10,f+t.lineHeight/2+.35*l,` font-size="${l}"`),f+=t.height;V+=`<g class="pele-wardley-annotations"><rect x="${eT(c)}" y="${eT(d)}" width="${eT(n)}" height="${eT(a)}" fill="var(--_bg)" stroke="var(--_b)"${r5}/>${u}</g>`}let G="";for(let r of t.notes)G+=x(w(r.text,l,Math.min(360,.6*i),1),$(r.x),k(r.y),` class="pele-wardley-note" font-size="${l}" font-weight="var(--_hw)"`);let Z="",X=(t,r,n,i)=>{let a=$(r),s=k(n),o=i?a:a+60,l=i?a+60-20:a+20,d=`M${eT(o)},${eT(s-15)}H${eT(l)}V${eT(s-15-8)}L${eT(i?a+60:a)},${eT(s)}L${eT(l)},${eT(s+15+8)}V${eT(s+15)}H${eT(o)}Z`;v(a,s-15-8,a+60,s+15+8),Z+=`<g class="pele-wardley-${i?"accelerator":"deaccelerator"}" data-id="${eS(t)}"><path d="${d}" fill="var(--_s)" stroke="${gd}"/>`+b(w(t,c+1,160,1),a+30,s+15+8+12,` font-size="${c+1}" font-weight="var(--_hw)"`)+"</g>"};for(let r of t.accelerators)X(r.name,r.x,r.y,!0);for(let r of t.deaccelerators)X(r.name,r.x,r.y,!1);let K=n7(t.title,!1,d,o,s?Math.max(80,i):4e3,1),J=K.height>0?K.height+12:0,Q=Math.min(p,i/2-K.width/2),ee=Math.max(m,i/2+K.width/2),et=u-Q,er=u+J-g,en=Math.ceil(ee-Q+2*u),ei=Math.ceil(y-g+J+2*u);return{svg:np("wardley",en,ei,o,n,t,eI(K,et+i/2,u+K.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${eT(et)},${eT(er)})"><g class="pele-wardley-frame" fill="none">${E}</g>`+S+D+z+(H?`<g class="pele-edges" fill="none">${H}</g>`:"")+(U?`<g class="pele-wardley-trends" fill="none">${U}</g>`:"")+q+V+G+Z+"</g>"),width:en,height:ei,links:[]}})(t,r,n,a,i,s))}},{type:"eventmodeling",keepComments:!0,parse:(t,r,n)=>(function(t,r){let n=new Set;for(let r of t.frames){if(n.has(r.name)){let n=c(t.$source,r.$offset).line;throw new a(`Duplicate event modeling frame ID "${r.name}" on line ${n}`,"semantic",{type:"eventmodeling",line:n})}n.add(r.name)}let i=new Map;for(let r of t.dataEntities)i.has(r.name)||i.set(r.name,r.dataBlockValue);let s=new Map,o=new Map,l=[],d=new Map,u=[];t.frames.forEach((t,r)=>{let n=t.entityIdentifier.split("."),a=2===n.length?n[0]:void 0,c=on.get(t.modelEntityType)??"event",h=void 0===t.dataInlineValue?void 0:oa(t.dataInlineValue);if(t.dataReference){let r=i.get(t.dataReference.$refText);void 0!==r&&(h=oa(r))}let f={id:t.name,kind:c,entity:t.entityIdentifier,name:2===n.length?n[1]:t.entityIdentifier,namespace:a,reset:"EmResetFrame"===t.$type,lane:((t,r)=>{let n="ui"===t||"processor"===t?"trigger":"event"===t?"stream":"state",i=void 0===r?n:`${n} ${r}`,a=s.get(i);if(!a){let[t,l,c]=oi.get(n),d=t;void 0!==r&&(d=o.get(n)??t+1,o.set(n,d+1)),a={index:d,label:void 0===r?l:c+r,group:n,namespace:r},s.set(i,a)}return a})(c,a),data:h,dataType:t.dataType};if(l.push(f),d.set(f.id,f),t.sourceFrames.length>0){let r=new Set(t.sourceFrames.map(t=>t.$refText));for(let t of l)r.has(t.id)&&u.push({source:t,target:f})}else if(r>0&&!f.reset){for(let t=r-1;t>=0;t--)if(l[t].lane!==f.lane){u.push({source:l[t],target:f});break}}});let h=t=>t.map(t=>t.entityIdentifier.$refText);return{type:"eventmodeling",title:t.title&&iH(t.title)||r,accTitle:t.accTitle?iU(t.accTitle).replace(/^\s+/g,""):void 0,accDescr:t.accDescr?iq(t.accDescr).replace(/\n\s+/g,`
|
|
147
|
+
`):void 0,boxes:l,lanes:[...s.values()].sort((t,r)=>t.index-r.index),relations:u,notes:t.noteEntities.map(t=>({frame:t.sourceFrame.$refText,text:oa(t.dataBlockValue),dataType:t.dataType})),specifications:t.gwtEntities.map(t=>({frame:t.sourceFrame.$refText,given:h(t.givenStatements),when:h(t.whenStatements),then:h(t.thenStatements)})),entities:t.modelEntities.map(t=>t.name)}})(function(t){let r=new iG(iE(t,oh,"eventmodeling"),oh,"eventmodeling"),n={$type:"EventModel",modelEntities:[],frames:[],dataEntities:[],noteEntities:[],gwtEntities:[],$source:t},i=t=>r.kinds[r.i]===t,a=(t,n)=>t.has(r.kinds[r.i])?r.take():r.fail(n),s=()=>{let t=r.expect(og.id);for(;r.accept(og.dot);)t+="."+r.expect(og.id);return t},o=()=>{if(!r.accept(og.tick))return;let t=a(ob,"a data type");return r.expect(og.tick),t},l=()=>{let t=[];do a(ov,"an entity type"),t.push({$type:"EmGwtStatement",entityIdentifier:{$refText:r.expect(og.id)}});while(ov.has(r.kinds[r.i]));return t};for(r.expect(og.keyword);!i(-1);){let t=r.kinds[r.i];if(t===og.accDescr)n.accDescr=r.take();else if(t===og.accTitle)n.accTitle=r.take();else if(t===og.title)n.title=r.take();else if(t===og.entity)r.i++,n.modelEntities.push({$type:"EmModelEntity",name:s()});else if(om.has(t)||oy.has(t)){let l={$type:om.has(t)?"EmTimeFrame":"EmResetFrame",name:"",modelEntityType:"",entityIdentifier:"",sourceFrames:[],$offset:r.tokens.starts[r.i]};for(r.i++,l.name=r.expect(og.frameId),l.modelEntityType=a(ov,"an entity type"),l.entityIdentifier=s();r.accept(og.arrow);)l.sourceFrames.push({$refText:r.expect(og.frameId)});if(r.accept(og.open)&&(l.dataReference={$refText:r.expect(og.id)},r.expect(og.close)),i(og.tick)||i(og.inline)){let t=o();void 0!==t&&(l.dataType=t),l.dataInlineValue=r.expect(og.inline)}n.frames.push(l)}else if(t===og.data){r.i++;let t={$type:"EmDataEntity",name:r.expect(og.id),dataBlockValue:""},i=o();void 0!==i&&(t.dataType=i),t.dataBlockValue=r.expect(og.block),n.dataEntities.push(t)}else if(t===og.note){r.i++;let t={$type:"EmNoteEntity",sourceFrame:{$refText:r.expect(og.frameId)},dataBlockValue:""},i=o();void 0!==i&&(t.dataType=i),t.dataBlockValue=r.expect(og.block),n.noteEntities.push(t)}else if(t===og.gwt){r.i++;let t={$type:"EmGwt",sourceFrame:{$refText:r.expect(og.frameId)},givenStatements:[],whenStatements:[],thenStatements:[]};r.expect(og.given),t.givenStatements=l(),r.accept(og.when)&&(t.whenStatements=l()),r.expect(og.then),t.thenStatements=l(),n.gwtEntities.push(t)}else r.fail("a frame, an entity, a data block, a note, or a specification")}return n}(t),n),render:function(t,r,n){return ic(n,r=>(function(t,r,n){if(n)return function(t,r){let n=r.fontSize??16,i=Math.round(.875*n),a=Math.round(.75*n),s=r.padding??8,o=r.measurer??e$(r.fontFamily,r.fontFamilyMono),l=Math.max(160,(r.maxWidth??320)-2*s),c=new Map(t.boxes.map((t,r)=>[t,r])),d=new Map,u=new Set;for(let r of t.relations){let n=c.get(r.source),i=c.get(r.target);if(void 0===n||void 0===i||n===i)continue;if(2>Math.abs(n-i)){u.add(t.boxes[Math.max(n,i)]);continue}let a=d.get(r.target);a?(a[0]=Math.min(a[0],n),a[1]=Math.max(a[1],n)):d.set(r.target,[Math.min(n,i),Math.max(n,i)])}let h=new Map,f=[];for(let[t,[r,n]]of[...d].sort((t,r)=>t[1][0]-r[1][0])){let i=f.findIndex(t=>t<r);i<0&&(i=f.length),f[i]=n,h.set(t,i)}let p=24+8*Math.max(0,f.length-1),g=Math.max(120,l-p),m=g-24,v=n7(t.title,!1,o,n,l,1),b=s+(v.height?v.height+12:0),x=s+v.height,w=Math.max(v.width,g+p),$="",k="",M="",_=new Map,A=(t,r,n=0)=>aX(y(t),o,r,m,n);for(let r of(t.boxes.forEach((t,r)=>{let n=u.has(t)?m-20:m,l=aK(n7(t.lane.label,!1,o,i,n,1),o,n),c=n7(t.name,!1,o,i,m-36,1),d=t.data?A(t.data,a,4):void 0,h=Math.max(g,l.width+24,c.width+24+36,(d?.width??0)+24),f=l.height+12,y=20+c.height+(d?d.height+6:0),v=ox.get(t.kind),k=b+f,M=`x="${eT(s)}" y="${eT(k)}" width="${eT(h)}" height="${eT(y)}"`;$+=`<g class="pele-cluster pele-em-lane" data-id="${eS(t.lane.label)}">`+aJ(l,s+12,b,` class="pele-cluster-label" font-size="${i}" font-weight="var(--_hw)" fill="var(--_m)"`)+`<g class="pele-node pele-em-${t.kind}${t.reset?" pele-em-reset":""}" data-id="${eS(t.id)}"><rect ${M} fill="var(--_bg)" stroke="var(--_b)"${r5}/>`+(void 0===v?"":`<rect ${M} fill="${nu(v)}" fill-opacity="0.22" stroke="${nu(v)}"${r5}/>`)+eI(c,s+12+c.width/2,k+10+c.height/2,` class="pele-label" font-size="${i}" font-weight="var(--_hw)"`)+`<text class="pele-em-frame" x="${eT(s+h-12)}" y="${eT(k+10+i)}" text-anchor="end" font-size="${a}" fill="var(--_m)">${eE(t.id)}</text>`+(d?o$(d.lines.map(t=>t.map(t=>t.text).join("")),s+12,k+10+c.height+6+d.lineHeight/2+.35*a,d.lineHeight,` class="pele-em-data" font-family="${r3}" font-size="${a}"`):"")+"</g></g>",_.set(t,{y:k,h:y,w:h,index:r,lane:l.width}),w=Math.max(w,h+p),b=(x=k+y)+28}),t.relations)){let t=_.get(r.source),n=_.get(r.target);if(!t||!n||t===n)continue;let i=n.y>t.y,a=i?1:-1,o=i?t.y+t.h:t.y,l=i?n.y:n.y+n.h,c,d;if(1===Math.abs(t.index-n.index)){let r=s+Math.max(Math.min(t.w,n.w)/2,12+(i?n:t).lane+16);c=`M${eT(r)},${eT(o)}V${eT(l-a*rq("arrow_point"))}`,d=rV("arrow_point",r,l,0,a,"var(--_l)")}else{let i=s+w-p+12+8*(h.get(r.target)??0),a=t.y+t.h/2-5,o=n.y+n.h/2+5;c=`M${eT(s+t.w)},${eT(a)}H${eT(i)}V${eT(o)}H${eT(s+n.w+rq("arrow_point"))}`,d=rV("arrow_point",s+n.w,o,-1,0,"var(--_l)")}k+=`<g class="pele-edge" data-id="${eS(r.source.id)}-${eS(r.target.id)}"><path d="${c}" fill="none" stroke="var(--_l)"/>${d}</g>`}let E=new Map(t.boxes.map(t=>[t.id,t.name])),S=(t,r,n,a)=>{let l=n7(`${r} \xb7 ${n}${E.has(n)?" "+E.get(n):""}`,!1,o,i,m,1),c=A(a,i),d=Math.max(g,l.width+24,c.width+24),u=20+l.height+c.height;M+=`<g class="pele-em-${t}" data-id="${eS(n)}"><rect x="${eT(s)}" y="${eT(b)}" width="${eT(d)}" height="${eT(u)}" fill="var(--_bg)" stroke="var(--_b)"${r5}/>`+eI(l,s+12+l.width/2,b+10+l.height/2,` font-size="${i}" font-weight="var(--_hw)"`)+o$(c.lines.map(t=>t.map(t=>t.text).join("")),s+12,b+10+l.height+c.lineHeight/2+.35*i,c.lineHeight,` font-size="${i}"`)+"</g>",b=(x=b+u)+8,w=Math.max(w,d)};for(let r of t.notes)S("note","Note",r.frame,r.text);for(let r of t.specifications){let t=[`Given ${r.given.join(", ")}`];r.when.length&&t.push(`When ${r.when.join(", ")}`),t.push(`Then ${r.then.join(", ")}`),S("specification","Given / When / Then",r.frame,t.join(`
|
|
148
|
+
`))}let C=Math.ceil(w+2*s),T=Math.ceil(x+s),I=eI(v,C/2,s+v.height/2,' class="pele-title" font-weight="var(--_tw)"')+k+$+M;return{svg:np("eventmodeling",C,T,n,r,t,I),width:C,height:T,links:[]}}(t,r);let i=r.fontSize??16,a=Math.round(.875*i),s=Math.round(.8125*i),o=Math.round(.75*i),l=Math.round(1.4*o),c=Math.round(1.5*s),d=r.measurer??e$(r.fontFamily,r.fontFamilyMono),u=r.padding??8,h=(t,r,n)=>{let i=0;for(let a of t)i=Math.max(i,d.width(a,r,n));return i},f=new Map,p=0;for(let r of t.lanes){let t=n7(r.label,!1,d,s,4e3,1);p=Math.max(p,t.width),f.set(r,{lane:r,label:t,right:-1/0,y:0,h:0})}p+=24;let g=[],m=new Map,v;for(let r of t.boxes){let t=f.get(r.lane),n=n7(r.name,!1,d,a,4e3,1),i=r.data?ow(r.data,48):[],s=Math.max(96,Math.max(n.width,h(i,o,4))+24),c=20+n.height+(i.length>0?6+i.length*l:0),u=0;if(v){let n=v.x+Math.max(v.w/2,v.w-80);u=v.box.lane===r.lane?t.right+16:Math.max(n,t.right+16)}let p={box:r,name:n,data:i,x:u,y:0,w:s,h:c};t.right=u+s,t.h=Math.max(t.h,c),g.push(p),m.set(r,p),v=p}let b=0;for(let t of g)b=Math.max(b,t.x+t.w);let x=p+b+12,w=n7(t.title,!1,d,i,4e3,1),$=u+(w.height>0?w.height+12:0),k=$,M="";for(let t of f.values())t.y=k,t.h+=24,M+=`<g class="pele-cluster pele-em-lane" data-id="${eS(t.lane.label)}"><rect x="${eT(u)}" y="${eT(k)}" width="${eT(x)}" height="${eT(t.h)}" fill="var(--_s)"${r5}/>`+eI(t.label,u+12+t.label.width/2,k+t.h/2,` class="pele-cluster-label" font-size="${s}" font-weight="var(--_hw)" fill="var(--_m)"`)+"</g>",k+=t.h+8;let _=f.size>0?k-8:$,A="";for(let t of g){let r=f.get(t.box.lane);t.x+=u+p,t.y=r.y+(r.h-t.h)/2;let n=ox.get(t.box.kind),i=`x="${eT(t.x)}" y="${eT(t.y)}" width="${eT(t.w)}" height="${eT(t.h)}"`,s=void 0===n?`<rect ${i} fill="var(--_bg)" stroke="var(--_b)"${r5}/>`:`<rect ${i} fill="var(--_bg)"${r5}/><rect ${i} fill="${nu(n)}" fill-opacity="0.22" stroke="${nu(n)}"${r5}/>`,c=t.y+10+t.name.height/2,d=eI(t.name,t.x+t.w/2,c,` class="pele-label" font-size="${a}" font-weight="var(--_hw)"`)+o$(t.data,t.x+12,t.y+10+t.name.height+6+l/2+.35*o,l,` class="pele-em-data" font-family="${r3}" font-size="${o}"`);A+=`<g class="pele-node pele-em-${t.box.kind}${t.box.reset?" pele-em-reset":""}" data-id="${eS(t.box.id)}">${s}${d}</g>`}let E="",S=rq("arrow_point");for(let r of t.relations){let t,n,i=m.get(r.source),a=m.get(r.target);if(i&&a&&i!==a){if(i.box.lane===a.box.lane){let r=a.x>=i.x,s=r?i.x+i.w:i.x,o=r?a.x:a.x+a.w,l=i.y+i.h/2,c=a.y+a.h/2,d=o>=s?1:-1;t=`M${eT(s)},${eT(l)}L${eT(o-d*S)},${eT(c)}`,n=rV("arrow_point",o,c,d,0,"var(--_l)")}else{let r=a.y>i.y,s=Math.max(i.x,a.x),o=Math.min(i.x+i.w,a.x+a.w),l=t=>Math.min(24,t/4),c=o-s>=16?(s+o)/2:a.x>i.x?i.x+i.w-l(i.w):i.x+l(i.w),d=o-s>=16?c:a.x>i.x?a.x+l(a.w):a.x+a.w-l(a.w),u=r?i.y+i.h:i.y,h=r?a.y:a.y+a.h,f=r?1:-1,p=h-f*S,g=(u+p)/2;t=c===d?`M${eT(c)},${eT(u)}V${eT(p)}`:`M${eT(c)},${eT(u)}C${eT(c)},${eT(g)} ${eT(d)},${eT(g)} ${eT(d)},${eT(p)}`,n=rV("arrow_point",d,h,0,f,"var(--_l)")}E+=`<g class="pele-edge" data-id="${eS(r.source.id)}-${eS(r.target.id)}"><path d="${t}" fill="none" stroke="var(--_l)"/>${n}</g>`}}let C=new Map;for(let r of t.boxes)C.set(r.id,r.name);let T="",I=0,N=(t,r,n,i)=>{let a=n7(`${r} \xb7 ${n}${C.has(n)?" "+C.get(n):""}`,!1,d,s,4e3,1),o=Math.max(a.width,h(i,s,0))+24,l=20+a.height+i.length*c,p=_+8*(""!==T||0!==f.size);T+=`<g class="pele-em-${t}" data-id="${eS(n)}"><rect x="${eT(u)}" y="${eT(p)}" width="${eT(o)}" height="${eT(l)}" fill="var(--_bg)" stroke="var(--_b)"${r5}/>`+eI(a,u+12+a.width/2,p+10+a.height/2,` font-size="${s}" font-weight="var(--_hw)"`)+o$(i,u+12,p+10+a.height+c/2+.35*s,c,` font-size="${s}"`)+"</g>",_=p+l,I=Math.max(I,o)};for(let r of t.notes)N("note","Note",r.frame,ow(r.text,80));for(let r of t.specifications){let t=[`Given ${r.given.join(", ")}`];r.when.length>0&&t.push(`When ${r.when.join(", ")}`),t.push(`Then ${r.then.join(", ")}`),N("specification","Given / When / Then",r.frame,t.flatMap(t=>ow(t,80)))}let O=Math.ceil(Math.max(f.size>0?x:0,I,w.width)+2*u),D=Math.ceil(_+u),R=eI(w,O/2,u+w.height/2,' class="pele-title" font-weight="var(--_tw)"')+M+E+A+T;return{svg:np("eventmodeling",O,D,i,r,t,R),width:O,height:D,links:[]}})(t,n,r))}},{type:"usecase",math:!0,parse:(t,r,n)=>(function(t,r){f3=t,({types:f5,starts:f6,ends:f8}=function(t){let r=[],n=[],i=[],a=t.length,s=0,o=!0,l=!1;for(;s<a;){let c=t.charCodeAt(s);if(32===c||9===c){s++;continue}let d,u=s+1,h=!1;if(c<128&&(1&fL[c])!=0){if(d=0,97===c&&o&&t.startsWith("acc",s)){let r=t.startsWith("Descr",s+3);if(r||t.startsWith("Title",s+3)){let n=s+8;for(;Y(t.charCodeAt(n));)n++;let i=t.charCodeAt(n);if(58===i)for(d=r?42:41,u=n+1;u<a&&10!==t.charCodeAt(u)&&13!==t.charCodeAt(u);)u++;else if(123===i&&r&&!l){let r=t.indexOf("}",n+1);-1===r?l=!0:(d=40,u=r+1)}}}else if(106===c&&t.startsWith("json",s)&&Y(t.charCodeAt(s+4))){let l=s+5;for(;Y(t.charCodeAt(l));)l++;let c=l;for(;fP(t.charCodeAt(l));)l++;if(l>c){for(;Y(t.charCodeAt(l));)l++;if(64===t.charCodeAt(l)){for(l++;Y(t.charCodeAt(l));)l++;if(123===t.charCodeAt(l)){r.push(43),n.push(s),i.push(l),s=l;let c=0,d=!1,u=!1,h=l;for(;h<a;h++){let r=t.charCodeAt(h);if(d)u?u=!1:92===r?u=!0:34===r&&(d=!1);else if(34===r)d=!0;else if(123===r)c++;else if(125===r&&0==--c)break}r.push(h<a?44:45),n.push(l),s=h<a?h+1:a,i.push(s),o=!1;continue}}}}if(0===d){for(;u<a&&fP(t.charCodeAt(u));)u++;let r=function(t,r,n){switch(n){case 97:return 2*!!t.startsWith("actor",r);case 115:return t.startsWith("systemBoundary",r)?3:16*!!t.startsWith("style",r);case 101:return t.startsWith("end",r)?4:18*!!fj(t,r,"extend");case 69:return 18*!!fj(t,r,"extend");case 100:return 5*!!t.startsWith("direction",r);case 84:return t.startsWith("TD",r)?6:7*!!t.startsWith("TB",r);case 66:return 8*!!t.startsWith("BT",r);case 76:return 9*!!t.startsWith("LR",r);case 82:return 10*!!t.startsWith("RL",r);case 110:return 11*!!t.startsWith("note",r);case 102:return t.startsWith("for",r)?12:20*!!t.startsWith("false",r);case 106:return 13*!!t.startsWith("json",r);case 99:return t.startsWith("classDef",r)?14:15*!!t.startsWith("class",r);case 105:case 73:return 17*!!fj(t,r,"include");case 116:return 19*!!t.startsWith("true",r);case 117:return+!!t.startsWith("usecase-beta",r);default:return 0}}(t,s,c);if(0!==r)1===r||u-s===fz[r]?(d=r,u=s+fz[r]):d=21;else if((111===c||120===c)&&45===t.charCodeAt(s+1)&&45===t.charCodeAt(s+2))d=111===c?56:58,u=s+3;else if(Z(c)){let r=s+1;for(;Z(t.charCodeAt(r));)r++;if(46===t.charCodeAt(r)&&Z(t.charCodeAt(r+1))){for(d=22,u=r+2;Z(t.charCodeAt(u));)u++;for(;X(t.charCodeAt(u));)u++}else d=21}else for(d=21;45===t.charCodeAt(u)&&fP(t.charCodeAt(u+1));)for(d=27,u+=2;fP(t.charCodeAt(u));)u++}}else if(10===c)d=39,h=!0;else if(13===c)d=39,h=!0,10===t.charCodeAt(u)&&u++;else if(34===c||39===c){if(34===c&&96===t.charCodeAt(s+1)){let r=t.indexOf('`"',s+2);d=-1===r?37:36,u=-1===r?a:r+2}else if(d=35,-1===(u=fW(t,s,c))){let r=s+1;for(;r<a&&!function(t,r){let n=t.charCodeAt(r);return 34!==n&&39!==n||34===n&&96===t.charCodeAt(r+1)||-1!==fW(t,r,n)}(t,r);)r++;throw fH(t,s,r-s)}}else if(37===c)if(o&&37===t.charCodeAt(u))for(d=38;u<a&&10!==t.charCodeAt(u)&&13!==t.charCodeAt(u);)u++;else d=31;else if(45===c)if(45!==t.charCodeAt(u))d=29;else{for(;45===t.charCodeAt(u);)u++;let r=t.charCodeAt(u),n=u-s==2;n&&124===r&&62===t.charCodeAt(u+1)?(d=46,u+=2):62===r?(d=53,u++):n&&(111===r||120===r)?(d=111===r?55:57,u++):d=59}else if(46===c){let r=t.charCodeAt(u);if(46===r&&62===t.charCodeAt(u+1))d=47,u+=2;else if(Z(r)){for(d=22;Z(t.charCodeAt(u));)u++;for(;X(t.charCodeAt(u));)u++}else d=30}else if(60===c)if(60===t.charCodeAt(u)){if(r.push(48),n.push(s),i.push(s+2),o=!1,(s+=2)>=a)break;if(62===t.charCodeAt(s)&&62===t.charCodeAt(s+1))d=49,u=s+2;else{let o=s,l=!1;for(;o<a;o++){let r=t.charCodeAt(o);if(10===r||13===r)break;if(62===r&&62===t.charCodeAt(o+1)){l=!0;break}}if(l&&""!==t.slice(s,o).trim())r.push(50),n.push(s),i.push(o),d=49,s=o,u=o+2;else{for(;o<a&&10!==t.charCodeAt(o)&&13!==t.charCodeAt(o);)o++;if(o===s){for(;o<a&&(10===t.charCodeAt(o)||13===t.charCodeAt(o));)o++;throw fH(t,s,o-s)}d=51,u=o}}}else if(45===t.charCodeAt(u)&&45===t.charCodeAt(u+1))for(d=54,u+=2;45===t.charCodeAt(u);)u++;else d=33;else if(58===c)58===t.charCodeAt(u)&&58===t.charCodeAt(u+1)?(d=52,u+=2):d=25;else if(64===c)123===t.charCodeAt(u)?(d=60,u++):d=23;else if(123===c)d=61;else if(125===c)d=62;else if(91===c)d=63;else if(93===c)d=64;else if(40===c)d=65;else if(41===c)d=66;else if(44===c)d=24;else if(35===c){for(;K(t.charCodeAt(u));)u++;d=u>s+1?26:32}else if(92===c)44===t.charCodeAt(u)?(d=28,u++):d=33;else if(c<127&&c>32)d=(2&fL[c])!=0?32:33;else for(d=34;u<a;){let r=t.charCodeAt(u);if(r>=32&&r<127||9===r||10===r||13===r)break;u++}r.push(d),n.push(s),i.push(u),s=u,o=h}for(let t=0;t<3;t++)r.push(0),n.push(a),i.push(a);return{types:r,starts:n,ends:i}}(t)),f9=0,f1={elements:[],boundaries:[],jsons:[],relationships:[],notes:[],metadata:[],classes:[],styles:[],classDefs:[],direction:void 0,accTitle:"",accDescription:""},f2=void 0,pe=[],pt=0,pr=0;try{let n=po(1);ph();let i=[];for(;(1&fQ[f5[f9]])!=0;)i.push(function t(r){let n=f9,i=f5[f9];if(39===i)return f9++,{kind:"blank",span:pi(n)};if(38===i)return f9++,ph(),{kind:"comment",span:pi(n)};let a=r?function(){let r=f9,n=f5[f9],i;if(41===n||42===n||40===n){f9++;let t=pn(r);40===n?f1.accDescription=t.slice(t.indexOf("{")+1,t.lastIndexOf("}")).trim():42===n?f1.accDescription=t.slice(t.indexOf(":")+1).trim():f1.accTitle=t.slice(t.indexOf(":")+1).trim(),i=pT(41===n?"accTitle":"accDescr")}else if(5===n){let t=f5[++f9];(t<6||t>10)&&pl("TD|TB|BT|LR|RL"),f1.direction=6===t?"TB":pn(f9),f9++,i=pT("direction")}else{if(2===n)return pO(!0);if(3===n)return function(){f9++;let r=p$(!0),n={id:r.id,label:r.label,span:r.span,generated:r.generated,classes:r.classes},i=60===f5[f9]?pb():void 0;52===f5[f9]&&pw(r.classes,r.classSpans),ph(),f1.boundaries.push(n),f2=n;let a=[];for(;(16&fQ[f5[f9]])!=0;)a.push(t(!1));f2=void 0;let s=po(4);ph();let o=pT("group");return o.group=n.id,o.idSpan=n.span,o.titleSpan=n.label.span,o.endSpan=pi(s),o.classSpans=r.classSpans,a.length>0&&(o.children=a),i&&(o.metadata=px(i),f1.metadata.push({target:n.id,span:n.span,properties:i,statement:o})),o}();if(11===n){f9++,po(12);let t=po(21),r=pm();f1.notes.push({target:pn(t),span:pi(t),label:r}),(i=pT("note")).ref=`note-${pr++}`,i.refSpan=r.span,i.nodes=[pP(t)]}else if(43===n){f9++;let t=po(44),n=[],a=[];52===f5[f9]&&pw(n,a);let s=f6[r]+4;for(;32===f3.charCodeAt(s)||9===f3.charCodeAt(s);)s++;let o=s;for(;/\w/.test(f3.charAt(o));)o++;let l={id:f3.slice(s,o),value:{},propertyOrder:new Map,span:[s,o],classes:n};f1.jsons.push(l),pe.push([l,t]),(i=pT("json")).nodes=[{id:l.id,span:l.span,idSpan:l.span,defines:!0,classSpans:a}],i.classSpans=a}else if(14===n){f9++;let t=pz();f1.classDefs.push({ids:t.map(pn),styles:pL()}),(i=pT("classDef")).ref=pn(t[0]),i.refSpan=pi(t[0])}else if(15===n){f9++;let t=pz(),r=pz();f1.classes.push({targets:t.map(t=>({id:pn(t),span:pi(t)})),classes:r.map(pn)}),(i=pT("classAssign")).ref=pn(r[0]),i.refSpan=pi(r[0]),i.nodes=t.map(pP)}else if(16===n){f9++;let t=po(21);f1.styles.push({target:pn(t),span:pi(t),styles:pL()}),(i=pT("style")).nodes=[pP(t)]}else{let t=f5[f9+1];if(60!==t)return((8&fQ[t])==0&&(21!==n||65!==t&&63!==t)||21===n&&f4.has(pn(r).toLowerCase()))&&pl(pc()),pD(!0);{(64&fQ[f5[f9+2]])==0&&pl(pc()),f9++;let t=pP(r);21!==n&&(t.id=pg(f3.slice(t.span[0],t.span[1])));let a=pb();(i=pT("metadata")).nodes=[t],i.metadata=px(a),f1.metadata.push({target:t.id,span:t.span,properties:a,statement:i})}}}return ph(),i}():2===i?pO(!1):pD(!1);if(a.span=[f6[n],f7],a.edges)for(let t of a.edges)t.span=a.span;return a}(!0));for(let[r,n]of(0!==f5[f9]&&pa(`Redundant input, expecting EOF but found: ${pn(f9)}`),pe)){let i=function(t,r){let n;try{n=JSON.parse(t)}catch(l){let n=l instanceof Error?l.message:String(l),i=m(t);if(i!==t)try{JSON.parse(i)}catch(t){t instanceof Error&&(n=t.message)}let[a,s]=r(),o=function(t,r,n,i){let a=/\bposition (\d+)\b/.exec(t);if(a)return fY(r,parseInt(a[1],10),n,i);let s=/\bline (\d+) column (\d+)\b/.exec(t);if(s){let t=parseInt(s[1],10),r=parseInt(s[2],10);return[n+t-1,1===t?i+r-1:r]}if(/unexpected end|end of json input/i.test(t))return fY(r,r.length,n,i)}(n,i,a,s);if(!o){let t=0;try{fV(i)}catch(r){r instanceof fq&&(t=r.offset)}o=fY(i,t,a,s)}throw fG(`Invalid JSON: ${n}`,o[0],o[1])}if("object"!=typeof n||null===n||Array.isArray(n)){let[t,n]=r();throw fG("JSON value must have an object root",t,n)}return{value:n,propertyOrder:fV(t)}}(pn(n),()=>fF(t,f6[n]));r.value=i.value,r.propertyOrder=i.propertyOrder}return function(t,r,n,i,s){let o={type:"usecase",actors:new Map,useCases:new Map,systemBoundaries:new Map,relationships:[],notes:new Map,jsonNodes:new Map,classDefs:new Map,direction:"LR",title:void 0,accTitle:"",accDescr:"",accDescription:"",source:"",headerSpan:[0,0],statements:[]},{actors:l,useCases:c,systemBoundaries:d}=o,u=new Map,h=new Map,f=new Map,p=new Map,g=new Map,m=r=>fB(t,r[0],r[1]),y=(r,n)=>{let[i,s]=fF(t,n[0]);return new a(r,"semantic",{type:"usecase",line:i,column:s})},v=(t,r)=>{throw y(`${t} at ${m(r)}`,r)},b=(t,r,n,i,a)=>{let s=t=>void 0===t?"":` (label "${t}")`;throw y(`${t} at ${m(r)}${s(i)}; previous declaration at ${m(n)}${s(a)}`,r)},x=(t,r,n)=>v(`Metadata property '${n.key}' is invalid for ${r} '${t}'`,n.keySpan),w=(t,r)=>{let n=g.get(t);(void 0===n||r<n)&&g.set(t,r)},$=t=>[...t].sort((t,r)=>(g.get(t.id)??0)-(g.get(r.id)??0)),k=(t,r)=>{u.set(t.id,{kind:r,span:t.span,generated:t.generated,label:t.label.text})},M=(t,r)=>{let n=u.get(t.id);if(!n)return;let i=t.generated?t.label.text:void 0,a=n.generated?n.label:void 0;n.kind!==r&&b(`ID '${t.id}' is declared as both ${n.kind} and ${r}`,t.span,n.span,i,a),(n.generated||t.generated)&&b(`Generated ID '${t.id}' collides with another declaration`,t.span,n.span,i,a)},_=(t,r,n)=>{let i=u.get(t);i&&b(`ID '${t}' is declared more than once (${i.kind} and ${r})`,n,i.span,void 0,i.generated?i.label:void 0),u.set(t,{kind:r,span:n,generated:!1})},A=(t,r,n)=>{let{key:i,value:a}=r,s=s=>{n||void 0===s||s===a||b(`Actor '${t.id}' has conflicting ${i} metadata`,r.keySpan,t.span)};"type"===i&&("normal"===a||"hollow"===a||"awesome"===a)?(s(t.actorType),t.actorType=a):"icon"===i&&"string"==typeof a?(s(t.icon),t.icon=a):"business"===i&&"boolean"==typeof a?(s(t.business),t.business=a):x(t.id,"actor",r)},E=(t,r,n)=>{for(let i of r??[])"actor"===t.kind?A(t,i,n):"business"===i.key&&"boolean"==typeof i.value?(n||void 0===t.business||t.business===i.value||b(`Use case '${t.id}' has conflicting business metadata`,i.keySpan,t.span),t.business=i.value):x(t.id,"usecase",i)},S=t=>{let r;if("actor"===t.kind){c.delete(t.id);let n={id:t.id,label:t.label.text,labelType:t.label.type,business:t.business??!1,classes:[...t.classes],type:t.icon?"icon":t.actorType??"normal",styles:l.get(t.id)?.styles??[]};t.icon&&(n.icon=t.icon),l.set(t.id,n),r=n}else l.delete(t.id),r={id:t.id,label:t.label.text,labelType:t.label.type,business:t.business??!1,classes:[...t.classes],shape:t.shape??"ellipse",styles:c.get(t.id)?.styles??[]},c.set(t.id,r);t.stereotype&&(r.stereotype=t.stereotype),t.parent?.id&&(r.parentId=t.parent.id)},C=t=>{M(t,t.kind);let r=t.parent?.id?t.parent:void 0,n=h.get(t.id);if(!n){let n={kind:t.kind,id:t.id,label:t.label,span:t.span,generated:t.generated,classes:[...t.classes],parent:r,shape:t.shape,stereotype:t.stereotype,stereotypeSpan:t.stereotype?t.span:void 0};E(n,t.metadata,!1),h.set(t.id,n),k(t,t.kind);return}(n.label.text!==t.label.text||n.label.type!==t.label.type)&&b(`ID '${t.id}' has conflicting labels`,t.span,n.span),t.shape&&n.shape&&t.shape!==n.shape&&b(`Use case '${t.id}' has conflicting shapes`,t.span,n.span),r&&n.parent?.id&&r.id!==n.parent.id&&b(`Element '${t.id}' belongs to more than one system boundary`,r.span,n.parent.span),t.stereotype&&n.stereotype&&t.stereotype!==n.stereotype&&b(`Element '${t.id}' has conflicting stereotypes`,t.span,n.stereotypeSpan??n.span),n.shape??=t.shape,n.parent??=t.parent,n.stereotype??=t.stereotype,n.stereotypeSpan??=t.stereotype?t.span:void 0,fU(n.classes,t.classes),E(n,t.metadata,!1)},T=t=>{M(t,"boundary");let r=f.get(t.id);if(r){(r.label.text!==t.label.text||r.label.type!==t.label.type)&&b(`Boundary '${t.id}' has conflicting titles`,t.span,r.span),fU(r.classes,t.classes);return}f.set(t.id,{...t,classes:[...t.classes],members:[]}),k(t,"boundary")},I=t=>{t.classed&&!t.declares&&v(`Relationship endpoint '${t.id}' uses ::: without declaring the node`,t.span);let r=u.get(t.id);return r?r.kind:(h.set(t.id,{...t,kind:"usecase",shape:"ellipse",classes:[]}),k(t,"usecase"),w(t.id,t.span[0]),"usecase")},N=(t,r)=>{let n=u.get(t)?.kind;return("actor"===n?l.get(t):"usecase"===n?c.get(t):"boundary"===n?d.get(t):"json"===n?o.jsonNodes.get(t):p.get(t))??v(`Class/style target '${t}' is unresolved or anonymous`,r)},O=[];for(let{source:t,target:n}of r.relationships)w(t.id,t.span[0]),w(n.id,n.span[0]);for(let t of r.elements)w(t.id,t.span[0]),O.push({offset:t.span[0],run:()=>C(t)});for(let t of r.boundaries)w(t.id,t.span[0]),O.push({offset:t.span[0],run:()=>T(t)});for(let t of r.jsons)w(t.id,t.span[0]),O.push({offset:t.span[0],run:()=>_(t.id,"json",t.span)});for(let{id:t,idSpan:n}of r.relationships)t&&n&&O.push({offset:n[0],run:()=>_(t,"edge",n)});for(let t of(O.sort((t,r)=>t.offset-r.offset),O))t.run();for(let t of $(h.values()))S(t);for(let t of $(f.values()))d.set(t.id,{id:t.id,label:t.label.text,labelType:t.label.type,type:"rect",members:[],classes:[],styles:[]});for(let t of $(r.jsons))o.jsonNodes.set(t.id,{id:t.id,value:t.value,propertyOrder:t.propertyOrder,classes:[...t.classes],styles:[]});let D=0;for(let t of r.relationships){let{source:r,target:n,type:i}=t,a=I(r),s=I(n),l=t=>"actor"===t||"usecase"===t||"json"===t;l(a)||b(`Relationship source '${r.id}' cannot be ${a}`,r.span,u.get(r.id).span),l(s)||b(`Relationship target '${n.id}' cannot be ${s}`,n.span,u.get(n.id).span),("include"===i||"extend"===i)&&("usecase"!==a||"usecase"!==s)&&v(`${i} relationship requires use-case endpoints`,t.span),"generalization"===i&&("json"===a||a!==s)&&v("Generalization requires actor-to-actor or use-case-to-use-case endpoints",t.span),"association"===i&&("json"===a||"json"===s)&&t.arrowType>2&&v(`JSON relationship '${r.id}' to '${n.id}' permits only point, reversed-point, or markerless solid association`,t.span);let c=t.id??`edge-${D++}`,d={id:c,explicitId:!!t.id,source:r.id,target:n.id,type:i,arrowType:t.arrowType,minlen:t.minlen,classes:[],styles:[],animate:!1};t.label&&(d.label=t.label.text,d.labelType=t.label.type),o.relationships.push(d),p.set(c,d)}let R=new Map(l),L=new Map(c);for(let t of(l.clear(),c.clear(),$(h.values()))){let r=R.get(t.id),n=L.get(t.id);r?l.set(t.id,r):n?c.set(t.id,n):S(t)}for(let{target:t,span:n,properties:i,statement:a}of r.metadata){let r=u.get(t);if(!r){let r=function(t){let r=new Set(["actor","usecase","boundary","edge"]);for(let{key:n,value:i}of t)if("icon"===n)r.clear(),r.add("actor");else if("animate"===n||"animation"===n)r.clear(),r.add("edge");else if("type"===n)r.clear(),"rect"===i||"package"===i?r.add("boundary"):("normal"===i||"hollow"===i||"awesome"===i)&&r.add("actor");else{if("business"!==n)return;r.delete("boundary"),r.delete("edge")}return 1===r.size?[...r][0]:void 0}(i);return v(`Metadata target '${t}' is unresolved${r?` (metadata implies ${r})`:""}`,n)}let s=r.kind;"actor"===s||"usecase"===s?E(h.get(t),i,!0):"edge"===s&&(a.kind="edgeMetadata",a.edges=[{id:t,span:a.span,idSpan:n,metadata:a.metadata}],delete a.nodes);let o=f.get(t),l=p.get(t);for(let r of"actor"===s||"usecase"===s?[]:i){let{key:n,value:i}=r;"boundary"===s&&o&&"type"===n&&("rect"===i||"package"===i)?o.type=i:"edge"===s&&l&&"animate"===n&&"boolean"==typeof i?l.animate=i:"edge"===s&&l&&"animation"===n&&("fast"===i||"slow"===i)?(l.animation=i,l.animate=!0):x(t,s,r)}}for(let t of o.relationships)t.animation&&(t.animate=!0);for(let t of h.values())"actor"===t.kind?(t.icon&&t.actorType&&"normal"!==t.actorType&&v(`Actor '${t.id}' cannot combine icon with type '${t.actorType}'`,t.span),t.business&&(t.icon||"awesome"===t.actorType)&&v(`Business actor '${t.id}' must use normal or hollow geometry`,t.span)):"rect"===t.shape&&t.business&&v(`Rectangular use case '${t.id}' cannot be a business use case`,t.span),S(t);for(let t of[...r.elements].sort((t,r)=>t.span[0]-r.span[0])){if(!t.parent?.id)continue;let r=f.get(t.parent.id).members;r.includes(t.id)||r.push(t.id)}for(let t of f.values()){let r=d.get(t.id);r.type=t.type??"rect",r.members=t.members,r.classes=[...t.classes]}let z=0;for(let t of r.notes){let r=u.get(t.target);if(!r)return v(`Note target '${t.target}' is unresolved`,t.span);"actor"!==r.kind&&"usecase"!==r.kind&&b(`Note target '${t.target}' must be an actor or use case, not ${r.kind}`,t.span,r.span);let n=`note-${z++}`;o.notes.set(n,{id:n,target:t.target,label:t.label.text,labelType:t.label.type})}for(let t of r.classDefs)for(let r of t.ids)o.classDefs.set(r,{id:r,styles:[...t.styles]});for(let t of r.classes)for(let r of t.targets)fU(N(r.id,r.span).classes,t.classes);for(let t of r.styles)N(t.target,t.span).styles.push(...t.styles);return o.direction=r.direction??o.direction,o.title=s,o.accTitle=r.accTitle,o.accDescription=r.accDescription,o.accDescr=r.accDescription.replace(/\n\s+/g,`
|
|
149
|
+
`),o.source=t,o.headerSpan=n,o.statements=i,o}(t,f1,pi(n),i,r)}finally{f3="",f5=f6=f8=pe=[]}})(t,n),render:function(t,r,n){return id(t.direction)?ic(n,i=>pX(t,r,n,i)):pX(t,r,n,!1)}},{type:"venn",parse(t,r,n){let i=new pQ;return n&&(i.title=n),function(t,r){let n=new p2(t,r),i=-1,s=()=>-1===i?i=n.next():i,o=r=>{throw 1===s()?d("venn",t,n.start,"",!0):d("venn",t,n.start,`Expecting ${r}, got '${p0[i]}'`)},l=()=>(i=-1,n.text),c=t=>(s()!==t&&o(`'${p0[t]}'`),l()),u=()=>(16!==s()&&17!==i&&o("'IDENTIFIER', 'STRING'"),l()),h=()=>{let t=[u()];for(;18===s();)l(),t.push(u());return t},f=(t,n)=>{let i=11===s()?l():void 0,o;if(19===s()&&(l(),o=parseFloat(c(12))),n){if(t.length<2)throw new a("union requires multiple identifiers","semantic",{type:"venn"});r.validateUnionIdentifiers(t)}r.addSubsetData(t,i,o),r.setIndentMode(!0)},p=t=>{let n=s();16!==n&&17!==n&&12!==n&&o("'NUMERIC', 'IDENTIFIER', 'STRING'");let i=l(),a=12!==n&&11===s()?l():void 0;r.addTextData(t(),i,a)},g=()=>{let t=h(),n=[];for(;;){let t,r=c(16);if(c(19),17===s())t=l();else{let r=[];for(;16===s()||i>=12&&i<=15;)r.push(l());0===r.length&&o("'NUMERIC', 'IDENTIFIER', 'STRING', 'HEXCOLOR', 'RGBCOLOR', 'RGBACOLOR'"),t=r.join(" ")}if(n.push([r,t]),18!==s())break;l()}r.addStyleData(t,n)};for(;3===s();)l();for(c(4);;){let t=s();if(2===t)return;if((t<3||t>10||4===t)&&o("'EOF', 'NEWLINE', 'TITLE', 'SET', 'UNION', 'TEXT', 'INDENT_TEXT', 'STYLE'"),l(),5===t)r.setDiagramTitle(n.text.slice(6));else if(6===t)f([u()],!1);else if(7===t)f(h(),!0);else if(8===t){let t=h();p(()=>t)}else 9===t?p(()=>{let t=r.getCurrentSets();if(!t)throw new a("text requires set","semantic",{type:"venn"});return t}):10===t&&g()}}(t,i),i},render:function(t,r,n){let i=n.fontSize??16,a=Math.round(.875*i),s=Math.round(.8125*i),o=n.measurer??e$(n.fontFamily,n.fontFamilyMono),l=n.padding??8,c=function(t){let r=new Map;for(let n of t)for(let t of n.sets)r.has(t)||r.set(t,10);for(let n of t)1===n.sets.length&&r.set(n.sets[0],n.size);let n=new Map,i=[],a=0;for(let t of r.values())Number.isFinite(t)&&t>a&&(a=t);0===a&&(a=10);let s=Math.sqrt(a/Math.PI);for(let[t,a]of r){n.set(t,i.length);let r=Number.isFinite(a)&&a>0?Math.sqrt(a/Math.PI):0;i.push({id:t,x:0,y:0,r:Math.max(r,.3*s)})}let o=i.length;if(o<2)return i;let l=new Map;for(let r of function(t){let r=new Set,n=new Map;for(let i of t)r.add(JSON.stringify([...i.sets].sort())),1===i.sets.length&&n.set(i.sets[0],i.size);let i=[];for(let a of t){if(a.sets.length<3)continue;let t=[...a.sets].sort();for(let a=0;a<t.length-1;a++)for(let s=a+1;s<t.length;s++){let o=[t[a],t[s]],l=JSON.stringify(o);if(r.has(l))continue;r.add(l);let c=n.get(o[0]),d=n.get(o[1]);i.push({sets:o,size:void 0!==c&&void 0!==d?Math.min(c,d)/4:2.5,label:""})}}return i.length>0?[...t,...i]:t}(t)){if(2!==r.sets.length)continue;let t=n.get(r.sets[0]),i=n.get(r.sets[1]);t!==i&&l.set(Math.min(t,i)*o+Math.max(t,i),r.size)}let c=new Map;for(let[t,r]of l)c.set(t,function(t,r,n){let i=Math.abs(t-r),a=t+r;if(!(n>0))return a;if(n>=Math.PI*Math.min(t,r)**2)return i;for(let s=0;s<48;s++){let s=(i+a)/2;(function(t,r,n){if(n>=t+r)return 0;let i=Math.min(t,r);return n<=Math.abs(t-r)?Math.PI*i*i:t*t*Math.acos((n*n+t*t-r*r)/(2*n*t))+r*r*Math.acos((n*n+r*r-t*t)/(2*n*r))-.5*Math.sqrt(Math.max((-n+t+r)*(n+t-r)*(n-t+r)*(n+t+r),0))})(t,r,s)>n?i=s:a=s}return(i+a)/2}(i[Math.floor(t/o)].r,i[t%o].r,r));let d=.15*s,u=(t,r)=>c.get(t*o+r)??i[t].r+i[r].r+d;if(2===o)return i[1].x=u(0,1),i;if(3===o){let r=u(0,1),n=u(0,2),a=u(1,2),o=t.some(t=>3===new Set(t.sets).size);for(let t=0;t<40;t++){let t=r>0?(r*r+n*n-a*a)/(2*r):0;if(i[1].x=r,i[2].x=Math.max(-n,Math.min(n,t)),i[2].y=Math.sqrt(Math.max(n*n-t*t,0)),!o||p5(i,[0,1,2],[]).margin>.12*s)break;r*=.94,n*=.94,a*=.94}return i}let h=0;for(let t of i)h+=2*t.r+d;let f=Math.min(300,Math.floor(3e6/(o*o)));if(o<=64){let t=h/p4;i.forEach((r,n)=>{let i=n*p4/o-Math.PI/2;r.x=Math.cos(i)*t,r.y=Math.sin(i)*t})}else{let t=Math.ceil(Math.sqrt(o)),r=2*s+d;i.forEach((n,i)=>{n.x=i%t*r,n.y=Math.floor(i/t)*r})}let p=new Float64Array(o),g=new Float64Array(o),m=new Int32Array(o);for(let t=0;t<f;t++){p.fill(0),g.fill(0),m.fill(0);for(let t=0;t<o;t++)for(let r=t+1;r<o;r++){let n=c.get(t*o+r),a=i[t].r+i[r].r+d,s=i[r].x-i[t].x,l=i[r].y-i[t].y,u=Math.hypot(s,l);if(void 0===n&&u>=a)continue;u<1e-9&&(s=Math.cos(t+r),l=Math.sin(t+r),u=1);let h=(u-(n??a))/2/u;p[t]+=s*h,g[t]+=l*h,p[r]-=s*h,g[r]-=l*h,m[t]++,m[r]++}for(let t=0;t<o;t++)0!==m[t]&&(i[t].x+=p[t]/m[t],i[t].y+=g[t]/m[t])}return i}(t.subsets),d=new Map;c.forEach((t,r)=>d.set(t.id,r));let u=new Map;for(let{targets:r,styles:n}of t.styles){let t=p8(r),i=u.get(t);for(let[r,a]of(i||u.set(t,i=new Map),n))i.set(r,a)}let h=t=>{let r=u.get(t);if(!r)return p6;let n=[];for(let[t,i]of r)n.push(`${t}:${i}`);return no(n)},f=c.map(()=>[]);for(let t=0;t<c.length;t++)for(let r=t+1;r<c.length;r++)Math.hypot(c[t].x-c[r].x,c[t].y-c[r].y)<c[t].r+c[r].r&&(f[t].push(r),f[r].push(t));let p=new Map;for(let r of t.subsets)p.set(p8(r.sets),r);let g=new Map;for(let[t,r]of p){let n=[...new Set(r.sets)],s=n.map(t=>d.get(t)),l=new Set(s),u=s[0];for(let t of s)c[t].r<c[u].r&&(u=t);let p=h(t),m=r.label??(1===r.sets.length?r.sets[0]:void 0),y=!!p.bold|2*!!p.italic,v=f[u].filter(t=>!l.has(t)),b=p5(c,s,v),x=v.length>0&&b.margin<.2*c[u].r;x&&(b=p5(c,s,[]));let w={sets:n,inside:s,spot:b,lines:[],style:p,across:x};if(m){let t=1===n.length?i:a;w.lines.push({id:void 0,raw:m,size:t,base:y,label:n7(m,!1,o,t,4e3,y)})}g.set(t,w)}for(let r of t.textNodes){let t=r.label??r.id;g.get(p8(r.sets))?.lines.push({id:r.id,raw:t,size:s,base:0,label:n7(t,!1,o,s,4e3)})}let m=0;for(let t of c)t.r>m&&(m=t.r);let y=m>0?100/m:1,v=1;for(let t of g.values()){if(t.spot.margin<=0)continue;let r=0,n=0;for(let i of t.lines)r=Math.max(r,i.label.width),n+=i.label.height;v=Math.max(v,Math.min((Math.hypot(r,n)/2+4)/(t.spot.margin*y),1.6))}for(let t of(y*=v,g.values())){let r=Math.max(t.spot.margin*y*1.8,72);for(let n of t.lines)n.label.width>r&&(n.label=n7(n.raw,!1,o,n.size,r,n.base))}let b=1/0,x=1/0,w=-1/0,$=-1/0;for(let t of c)b=Math.min(b,(t.x-t.r)*y),x=Math.min(x,(t.y-t.r)*y),w=Math.max(w,(t.x+t.r)*y),$=Math.max($,(t.y+t.r)*y);for(let t of g.values()){let r=0,n=0;for(let i of t.lines)r=Math.max(r,i.label.width),n+=i.label.height;b=Math.min(b,t.spot.x*y-r/2),w=Math.max(w,t.spot.x*y+r/2),x=Math.min(x,t.spot.y*y-n/2),$=Math.max($,t.spot.y*y+n/2)}0===c.length&&(b=x=w=$=0);let k=n7(t.title&&pK(t.title),!1,o,i,4e3,1),M=k.height>0?k.height+12:0,_=Math.max(w-b,k.width),A=l+(_-(w-b))/2-b,E=l+M-x,S=Math.ceil(_+2*l),C=Math.ceil($-x+M+2*l),T=c.map(t=>({id:t.id,x:t.x*y+A,y:t.y*y+E,r:t.r*y})),I="";T.forEach((t,r)=>{let n=nu(r),i=g.get(t.id)?.style??p6;I+=`<circle class="pele-venn-set" data-id="${eS(t.id)}" cx="${eT(t.x)}" cy="${eT(t.y)}" r="${eT(t.r)}" fill="${n}" fill-opacity="0.2" stroke="${n}"${i.shape}/>`});let N=[...g.values()].filter(t=>t.sets.length>1&&""!==t.style.shape),O=t=>{if(t.across)return"";let r=1===t.sets.length&&/[";]fill-opacity:/.test(t.style.shape)?t.style.shape:"";for(let n of N)n.sets.every(r=>t.sets.includes(r))&&(r=n.style.shape);return r},D="",R="";for(let t of g.values()){let r=eS(t.sets.join("|"));if(t.sets.length>1&&""!==t.style.shape){let n=function(t,r){let n=t=>`M${r(t.x-t.r)},${r(t.y)}A${r(t.r)},${r(t.r)} 0 1 1 ${r(t.x+t.r)},${r(t.y)}A${r(t.r)},${r(t.r)} 0 1 1 ${r(t.x-t.r)},${r(t.y)}Z`;if(1===t.length)return n(t[0]);let i=(r,n,i,a)=>{for(let s of t)if(s!==i&&s!==a&&Math.hypot(r-s.x,n-s.y)>s.r*(1+1e-9))return!1;return!0},a=[];for(let r=0;r<t.length;r++)for(let n=r+1;n<t.length;n++){let s=t[r],o=t[n],l=Math.hypot(o.x-s.x,o.y-s.y);if(l>=s.r+o.r||l<=Math.abs(s.r-o.r)||0===l)continue;let c=(s.r*s.r-o.r*o.r+l*l)/(2*l),d=Math.sqrt(Math.max(s.r*s.r-c*c,0)),u=s.x+(o.x-s.x)*c/l,h=s.y+(o.y-s.y)*c/l;for(let t of[1,-1]){let r=u+t*d*(o.y-s.y)/l,n=h-t*d*(o.x-s.x)/l;i(r,n,s,o)&&a.push({x:r,y:n,a:s,b:o})}}if(a.length<2){let r=t[0];for(let n of t)n.r<r.r&&(r=n);for(let n of t)if(n!==r&&Math.hypot(n.x-r.x,n.y-r.y)+r.r>n.r*(1+1e-9))return"";return n(r)}let s=0,o=0;for(let t of a)s+=t.x/a.length,o+=t.y/a.length;a.sort((t,r)=>Math.atan2(t.y-o,t.x-s)-Math.atan2(r.y-o,r.x-s));let l="";for(let t=0;t<a.length;t++){let n=a[t],i=a[(t+1)%a.length];0===t&&(l=`M${r(n.x)},${r(n.y)}`);let s,o=0,c=1/0;for(let t of[n.a,n.b]){if(t!==i.a&&t!==i.b)continue;let r=Math.atan2(n.y-t.y,n.x-t.x),a=Math.atan2(i.y-t.y,i.x-t.x)-r;a<=0&&(a+=p4);let l=t.x+t.r*Math.cos(r+a/2),d=t.y+t.r*Math.sin(r+a/2),u=Math.hypot(l-(n.x+i.x)/2,d-(n.y+i.y)/2);u<c&&(c=u,s=t,o=+(a>Math.PI))}void 0===s?l+=`L${r(i.x)},${r(i.y)}`:l+=`A${r(s.r)},${r(s.r)} 0 ${o} 1 ${r(i.x)},${r(i.y)}`}return l+"Z"}(t.inside.map(t=>T[t]),eT);""!==n&&(D+=`<path class="pele-venn-overlap" data-id="${r}" d="${n}" fill="none"${t.style.shape}/>`)}let n=0;for(let r of t.lines)n+=r.label.height;if(0===n)continue;let a=t.spot.x*y+A,o=t.spot.y*y+E-n/2,l=O(t),c="";for(let r of t.lines){let n=void 0===r.id?t.style.text:h(r.id).text,d=e5(l,n),u=void 0===r.id?` class="pele-label"${r.size===i?"":` font-size="${r.size}"`}${d?` fill="${d}"`:""}${n}`:` class="pele-venn-text" data-id="${eS(r.id)}" font-size="${s}" fill="${d??"var(--_m)"}"${n}`;c+=eI(r.label,a,o+r.label.height/2,u),o+=r.label.height}R+=`<g class="pele-venn-region" data-id="${r}">${c}</g>`}return{svg:np("venn",S,C,i,n,{},eI(k,S/2,l+k.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g class="pele-venn-sets">${I}</g>`+(D?`<g class="pele-venn-overlaps">${D}</g>`:"")+(R?`<g class="pele-venn-labels">${R}</g>`:"")),width:S,height:C,links:[]}}},{type:"ishikawa",parse(t,r,n){let i=new cI;return i.title=n,function(t,r){let{types:n,starts:i,ends:a}=function(t){let r=[],n=[],i=[],a=t.length,s=0;for(;s<a;){let o,l,c=s,d=-1;for(;c<a&&V(t.charCodeAt(c));)10===t.charCodeAt(c)&&(d=c),c++;if(37===t.charCodeAt(c)&&37===t.charCodeAt(c+1))for(o=2,l=c+2;l<a;){let r=t.charCodeAt(l);if(10===r||13===r||8232===r||8233===r)break;l++}else if(c===s){let r=function(t,r){let n=0;for(;n<13;){let i=t.charCodeAt(r+n),a="ishikawa-beta".charCodeAt(n);if(i!==a&&(i+32!==a||i<65||i>90))break;n++}return 13!==n||J(t.charCodeAt(r+13))?8*!(!(n>=8)||J(t.charCodeAt(r+8))):13}(t,s);r>0?(o=4,l=s+r):(o=6,-1===(l=t.indexOf(`
|
|
150
|
+
`,s))&&(l=a))}else d>s?(o=2,l=d+1):d===s?(o=3,l=s+1):(o=5,l=c);r.push(o),n.push(s),i.push(l),s=l}return r.push(1,0),n.push(a,a),i.push(a,a),{types:r,starts:n,ends:i}}(t),s=0,o=r=>{throw d("ishikawa",t,i[s],`Expecting ${r}, got '${cN[n[s]]}'`)};if(2===n[s]){for(s++;2===n[s]||3===n[s];)s++;4!==n[s]&&o("'SPACELINE', 'NL', 'ISHIKAWA'")}else 4!==n[s]&&o("'SPACELINE', 'ISHIKAWA'");for(3===n[++s]&&s++;;){let l=n[s];if(6===l||5===l&&6===n[s+1]){let c=6===l?s:s+1;2!==n[s=c+1]&&3!==n[s]&&1!==n[s]&&o(cO),r.addNode(6===l?0:a[c-1]-i[c-1],t.slice(i[c],a[c]).trim())}else 2===l||5===l?2!==n[++s]&&3!==n[s]&&1!==n[s]&&o(5===l?`${cO}, 'TEXT'`:cO):o("'SPACELINE', 'SPACELIST', 'TEXT'");for(s++;3===n[s]||1===n[s];)s++;if(0===n[s])return}}(t,i),i},render:function(t,r,n){return ic(n,r=>(function(t,r,n){let i=r.fontSize??16,a=Math.round(.875*i),s=r.measurer??e$(r.fontFamily,r.fontFamilyMono),o=r.padding??8;if(n)return function(t,r){let n=r.fontSize??16,i=Math.round(.875*n),a=r.measurer??e$(r.fontFamily,r.fontFamilyMono),s=r.padding??8,o=Math.max(140,(r.maxWidth??320)-2*s),l=n7(t.title,!1,a,n,io(r),1),c=[],d=t.root?[{node:t.root,depth:0,parent:-1}]:[],u=0;for(;d.length;){let t=d.pop(),r=c.length;c.push({...t,x:0,y:0,w:0,h:0}),u=Math.max(u,t.depth);for(let n=t.node.children.length-1;n>=0;n--)d.push({node:t.node.children[n],depth:t.depth+1,parent:r})}let h=Math.min(20,Math.max(2,(o-120)/Math.max(1,u))),f=s+(l.height?l.height+12:0),p=l.width,g="",m="";for(let t of c){t.x=s+t.depth*h;let r=Math.max(60,o-t.depth*h-20);t.label=aK(n7(t.node.text,!1,a,t.depth<2?n:i,r,+(t.depth<2)),a,r),t.w=t.label.width+20,t.h=t.label.height+12,t.y=f,f+=t.h+12,p=Math.max(p,t.x-s+t.w);let l=t.depth<2;if(g+=`<g class="pele-node ${0===t.depth?"pele-ishikawa-head":1===t.depth?"pele-ishikawa-category":"pele-ishikawa-cause"}" data-id="${eS(t.node.text)}">`+(l?`<rect x="${eT(t.x)}" y="${eT(t.y)}" width="${eT(t.w)}" height="${eT(t.h)}" rx="${0===t.depth?12:4}" fill="var(--_s)" stroke="var(--_b)"/>`:"")+eI(t.label,t.x+t.w/2,t.y+t.h/2,` class="pele-label"${t.depth<2?' font-weight="var(--_hw)"':""}${t.depth>1?` font-size="${i}"`:""}`)+"</g>",t.parent>=0){let r=c[t.parent],n=r.x+h/2;m+=`<path class="pele-edge" d="M${eT(n)},${eT(r.y+r.h)}V${eT(t.y+t.h/2)}H${eT(t.x)}" fill="none" stroke="var(--_b)"/>`}}let y=Math.ceil(p+2*s),v=Math.ceil(Math.max(s+l.height,f-12)+s),b=eI(l,y/2,s+l.height/2,' class="pele-title" font-weight="var(--_tw)"')+m+g;return{svg:np("ishikawa",y,v,n,r,{},b),width:y,height:v,links:[]}}(t,r);let l=t.root,c=n7(t.title,!1,s,i,4e3,1),d=c.height>0?c.height+12:0,u="",h=0,f=0,p=0,g=0;if(l){let t=n7(l.text,!1,s,i,200,1),r=Math.max(t.height+24,48),n=t.width+24+r/2,o=l.children.map((t,r)=>(function(t,r,n,i,a){let s=n7(t.text,!1,n,i,180),o=Math.round(1.5*a),l=[],c=[],d=[],u=(t,n,i)=>{let a=t.length;for(let s=a-1;s>=0;s--)d.push({node:t[r?a-1-s:s],depth:n,parent:i,slot:s,bone:-1})};for(u(t.children,2,-1);d.length>0;){let t=d.pop();if(-1!==t.bone){c.push(t.bone);continue}let r=l.length;l.push({label:n7(t.node.text,!1,n,a,200),depth:t.depth,parent:t.parent,slot:t.slot,kids:t.node.children.length,rise:0,at:0,textEnd:0}),t.depth%2==0?c.push(r):(t.bone=r,d.push(t)),u(t.node.children,t.depth+1,r)}let h=14;for(let t of c){let r=Math.max(l[t].label.height,o)+6;l[t].rise=h+r/2,h+=r}let f=s.width+20,p=f/2;for(let t of l){let r=-1===t.parent?void 0:l[t.parent];t.depth%2==0?(t.at=r?r.at:0,t.textEnd=t.at-(t.kids>0?(t.kids+1)*22:18)-5):(t.at=r.at-(r.kids-t.slot)*22,t.textEnd=t.at-5),p=Math.max(p,t.label.width-t.textEnd)}return{node:t,label:s,boxW:f,boxH:s.height+10,bones:l,rise:h+8,reach:p}})(t,r%2==0,s,i,a));for(let t of o)t.rise=Math.max(t.rise,r/2+14);let c=[],d=-34;for(let t=0;t<o.length;t+=2){if(t>0){let r=0;for(let n=0;n<2;n++){let i=o[t-2+n],a=o[t+n];i&&(r=Math.max(r,i.reach+(a?a.boxW/2:0)))}d-=r+26}c.push(d,d)}let m=o.length>0?d-28:-34;f=n,h=m,p=-r/2,g=r/2;let y="";o.forEach((t,r)=>{let n=r%2==0?-1:1,i=c[r],s=(t,r)=>i+t-.5*r,o=s(0,t.rise),l=n*t.rise,d=`M${eT(i-.5/cD*7)},${eT(7*n/cD)}L${eT(o)},${eT(l)}`,u="";for(let r of t.bones){let i=n*r.rise;if(r.depth%2==0)d+=`M${eT(s(r.at,r.rise))},${eT(i)}H${eT(s(r.textEnd+5,r.rise))}`;else{let a=t.bones[r.parent].rise;d+=`M${eT(s(r.at,a))},${eT(n*a)}L${eT(s(r.at,r.rise))},${eT(i)}`}let a=s(r.textEnd,r.rise);u+=eI(r.label,a-r.label.width/2,i,r.depth>2?' fill="var(--_m)"':""),h=Math.min(h,a-r.label.width)}let m=l+n*(t.boxH/2);h=Math.min(h,o-t.boxW/2),f=Math.max(f,o+t.boxW/2),p=Math.min(p,m-t.boxH/2),g=Math.max(g,m+t.boxH/2),y+=`<g class="pele-ishikawa-category" data-id="${eS(t.node.text)}"><path class="pele-ishikawa-bones" d="${d}" fill="none" stroke="var(--_l)"/>`+rV("arrow_point",i,0,.5/cD,-n/cD,"var(--_l)")+`<rect x="${eT(o-t.boxW/2)}" y="${eT(m-t.boxH/2)}" width="${eT(t.boxW)}" height="${eT(t.boxH)}" fill="var(--_s)" stroke="var(--_b)"${r5}/>`+eI(t.label,o,m,' class="pele-label"')+(u?`<g class="pele-ishikawa-causes" font-size="${a}">${u}</g>`:"")+"</g>"});let v=r/2;u=`<path class="pele-ishikawa-spine" d="M${eT(m)},0H${eT(-7)}" fill="none" stroke="var(--_l)"/>`+rV("arrow_point",0,0,1,0,"var(--_l)")+y+`<g class="pele-ishikawa-head" data-id="${eS(l.text)}"><path d="M0,${eT(-v)}H${eT(n-v)}A${eT(v)},${eT(v)} 0 0 1 ${eT(n-v)},${eT(v)}H0Z" fill="var(--_s)" stroke="var(--_b)" stroke-linejoin="round"/>`+eI(t,12+t.width/2,0,' class="pele-label" font-weight="var(--_hw)"')+"</g>"}let m=Math.max(f-h,c.width),y=Math.ceil(m+2*o),v=Math.ceil(g-p+d+2*o),b=o+(m-(f-h))/2-h,x=o+d-p;return{svg:np("ishikawa",y,v,i,r,{},eI(c,y/2,o+c.height/2,' class="pele-title" font-weight="var(--_tw)"')+(u?`<g transform="translate(${eT(b)},${eT(x)})">${u}</g>`:"")),width:y,height:v,links:[]}})(t,n,r))}},fe)},7215(){let t,r=Symbol.for("yaml.alias"),n=Symbol.for("yaml.document"),i=Symbol.for("yaml.map"),a=Symbol.for("yaml.pair"),s=Symbol.for("yaml.scalar"),o=Symbol.for("yaml.seq"),l=Symbol.for("yaml.node.type"),c=t=>!!t&&"object"==typeof t&&t[l]===r,d=t=>!!t&&"object"==typeof t&&t[l]===n,u=t=>!!t&&"object"==typeof t&&t[l]===i,h=t=>!!t&&"object"==typeof t&&t[l]===a,f=t=>!!t&&"object"==typeof t&&t[l]===s,p=t=>!!t&&"object"==typeof t&&t[l]===o;function g(t){if(t&&"object"==typeof t)switch(t[l]){case i:case o:return!0}return!1}function m(t){if(t&&"object"==typeof t)switch(t[l]){case r:case i:case s:case o:return!0}return!1}let y=t=>(f(t)||g(t))&&!!t.anchor,v=Symbol("break visit"),b=Symbol("skip children"),x=Symbol("remove node");function w(t,r){let n=_(r);d(t)?$(null,t.contents,n,Object.freeze([t]))===x&&(t.contents=null):$(null,t,n,Object.freeze([]))}function $(t,r,n,i){let a=A(t,r,n,i);if(m(a)||h(a))return E(t,i,a),$(t,a,n,i);if("symbol"!=typeof a){if(g(r)){i=Object.freeze(i.concat(r));for(let t=0;t<r.items.length;++t){let a=$(t,r.items[t],n,i);if("number"==typeof a)t=a-1;else{if(a===v)return v;a===x&&(r.items.splice(t,1),t-=1)}}}else if(h(r)){i=Object.freeze(i.concat(r));let t=$("key",r.key,n,i);if(t===v)return v;t===x&&(r.key=null);let a=$("value",r.value,n,i);if(a===v)return v;a===x&&(r.value=null)}}return a}async function k(t,r){let n=_(r);d(t)?await M(null,t.contents,n,Object.freeze([t]))===x&&(t.contents=null):await M(null,t,n,Object.freeze([]))}async function M(t,r,n,i){let a=await A(t,r,n,i);if(m(a)||h(a))return E(t,i,a),M(t,a,n,i);if("symbol"!=typeof a){if(g(r)){i=Object.freeze(i.concat(r));for(let t=0;t<r.items.length;++t){let a=await M(t,r.items[t],n,i);if("number"==typeof a)t=a-1;else{if(a===v)return v;a===x&&(r.items.splice(t,1),t-=1)}}}else if(h(r)){i=Object.freeze(i.concat(r));let t=await M("key",r.key,n,i);if(t===v)return v;t===x&&(r.key=null);let a=await M("value",r.value,n,i);if(a===v)return v;a===x&&(r.value=null)}}return a}function _(t){return"object"==typeof t&&(t.Collection||t.Node||t.Value)?Object.assign({Alias:t.Node,Map:t.Node,Scalar:t.Node,Seq:t.Node},t.Value&&{Map:t.Value,Scalar:t.Value,Seq:t.Value},t.Collection&&{Map:t.Collection,Seq:t.Collection},t):t}function A(t,r,n,i){return"function"==typeof n?n(t,r,i):u(r)?n.Map?.(t,r,i):p(r)?n.Seq?.(t,r,i):h(r)?n.Pair?.(t,r,i):f(r)?n.Scalar?.(t,r,i):c(r)?n.Alias?.(t,r,i):void 0}function E(t,r,n){let i=r[r.length-1];if(g(i))i.items[t]=n;else if(h(i))"key"===t?i.key=n:i.value=n;else if(d(i))i.contents=n;else{let t=c(i)?"alias":"scalar";throw Error(`Cannot replace node with ${t} parent`)}}w.BREAK=v,w.SKIP=b,w.REMOVE=x,k.BREAK=v,k.SKIP=b,k.REMOVE=x;let S={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},C=t=>t.replace(/[!,[\]{}]/g,t=>S[t]);class T{constructor(t,r){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},T.defaultYaml,t),this.tags=Object.assign({},T.defaultTags,r)}clone(){let t=new T(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new T(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:T.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},T.defaultTags)}return t}add(t,r){this.atNextDocument&&(this.yaml={explicit:T.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},T.defaultTags),this.atNextDocument=!1);let n=t.trim().split(/[ \t]+/),i=n.shift();switch(i){case"%TAG":{if(2!==n.length&&(r(0,"%TAG directive should contain exactly two parts"),n.length<2))return!1;let[t,i]=n;return this.tags[t]=i,!0}case"%YAML":{if(this.yaml.explicit=!0,1!==n.length)return r(0,"%YAML directive should contain exactly one part"),!1;let[t]=n;if("1.1"===t||"1.2"===t)return this.yaml.version=t,!0;{let n=/^\d+\.\d+$/.test(t);return r(6,`Unsupported YAML version ${t}`,n),!1}}default:return r(0,`Unknown directive ${i}`,!0),!1}}tagName(t,r){if("!"===t)return"!";if("!"!==t[0])return r(`Not a valid tag: ${t}`),null;if("<"===t[1]){let n=t.slice(2,-1);return"!"===n||"!!"===n?(r(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(">"!==t[t.length-1]&&r("Verbatim tags must end with a >"),n)}let[,n,i]=t.match(/^(.*!)([^!]*)$/s);i||r(`The ${t} tag has no suffix`);let a=this.tags[n];if(a)try{return a+decodeURIComponent(i)}catch(t){return r(String(t)),null}return"!"===n?t:(r(`Could not resolve tag: ${t}`),null)}tagString(t){for(let[r,n]of Object.entries(this.tags))if(t.startsWith(n))return r+C(t.substring(n.length));return"!"===t[0]?t:`!<${t}>`}toString(t){let r,n=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],i=Object.entries(this.tags);if(t&&i.length>0&&m(t.contents)){let n={};w(t.contents,(t,r)=>{m(r)&&r.tag&&(n[r.tag]=!0)}),r=Object.keys(n)}else r=[];for(let[a,s]of i)("!!"!==a||"tag:yaml.org,2002:"!==s)&&(!t||r.some(t=>t.startsWith(s)))&&n.push(`%TAG ${a} ${s}`);return n.join("\n")}}function I(t){if(/[\x00-\x19\s,[\]{}]/.test(t)){let r=JSON.stringify(t);throw Error(`Anchor must not contain whitespace or control characters: ${r}`)}return!0}function N(t,r,n){if(Array.isArray(t))return t.map((t,r)=>N(t,String(r),n));if(t&&"function"==typeof t.toJSON){if(!n||!y(t))return t.toJSON(r,n);let i={aliasCount:0,count:1,res:void 0};n.anchors.set(t,i),n.onCreate=t=>{i.res=t,delete n.onCreate};let a=t.toJSON(r,n);return n.onCreate&&n.onCreate(a),a}return"bigint"!=typeof t||n?.keep?t:Number(t)}T.defaultYaml={explicit:!1,version:"1.2"},T.defaultTags={"!!":"tag:yaml.org,2002:"};class O{constructor(t){Object.defineProperty(this,l,{value:t})}clone(){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(t.range=this.range.slice()),t}toJS(t,{mapAsMap:r,maxAliasCount:n,onAnchor:i,reviver:a}={}){if(!d(t))throw TypeError("A document argument is required");let s={anchors:new Map,doc:t,keep:!0,mapAsMap:!0===r,mapKeyWarned:!1,maxAliasCount:"number"==typeof n?n:100},o=N(this,"",s);if("function"==typeof i)for(let{count:t,res:r}of s.anchors.values())i(r,t);return"function"==typeof a?function t(r,n,i,a){if(a&&"object"==typeof a)if(Array.isArray(a))for(let n=0,i=a.length;n<i;++n){let i=a[n],s=t(r,a,String(n),i);void 0===s?delete a[n]:s!==i&&(a[n]=s)}else if(a instanceof Map)for(let n of Array.from(a.keys())){let i=a.get(n),s=t(r,a,n,i);void 0===s?a.delete(n):s!==i&&a.set(n,s)}else if(a instanceof Set)for(let n of Array.from(a)){let i=t(r,a,n,n);void 0===i?a.delete(n):i!==n&&(a.delete(n),a.add(i))}else for(let[n,i]of Object.entries(a)){let s=t(r,a,n,i);void 0===s?delete a[n]:s!==i&&(a[n]=s)}return r.call(n,i,a)}(a,{"":o},"",o):o}}class D extends O{constructor(t){super(r),this.source=t,Object.defineProperty(this,"tag",{set(){throw Error("Alias nodes cannot have tags")}})}resolve(t,r){let n,i;if(r?.maxAliasCount===0)throw ReferenceError("Alias resolution is disabled");for(let a of(r?.aliasResolveCache?n=r.aliasResolveCache:(n=[],w(t,{Node:(t,r)=>{(c(r)||y(r))&&n.push(r)}}),r&&(r.aliasResolveCache=n)),n)){if(a===this)break;a.anchor===this.source&&(i=a)}if(i&&r){let{anchors:t,doc:n,maxAliasCount:a}=r,s=t.get(i);if(s||(N(i,null,r),s=t.get(i)),s?.res===void 0)throw ReferenceError("This should not happen: Alias anchor was not resolved?");if(a>=0&&(s.count+=1,0===s.aliasCount&&(s.aliasCount=function t(r,n,i){if(c(n)){let t=n.resolve(r),a=i&&t&&i.get(t);return a?a.count*a.aliasCount:0}if(g(n)){let a=0;for(let s of n.items){let n=t(r,s,i);n>a&&(a=n)}return a}return h(n)?Math.max(t(r,n.key,i),t(r,n.value,i)):1}(n,i,t)),s.count*s.aliasCount>a))throw ReferenceError("Excessive alias count indicates a resource exhaustion attack")}return i}toJSON(t,r){if(!r)return{source:this.source};let n=this.resolve(r.doc,r);if(!n)throw ReferenceError(`Unresolved alias (the anchor must be set before the alias): ${this.source}`);return r.anchors.get(n).res}toString(t,r,n){let i=`*${this.source}`;if(t){if(I(this.source),t.options.verifyAliasOrder&&!t.anchors.has(this.source))throw Error(`Unresolved alias (the anchor must be set before the alias): ${this.source}`);if(t.implicitKey)return`${i} `}return i}}let R=t=>!t||"function"!=typeof t&&"object"!=typeof t;class L extends O{constructor(t){super(s),this.value=t}toJSON(t,r){return r?.keep?this.value:N(this.value,t,r)}toString(){return String(this.value)}}function z(t,r,n){let a;if(d(t)&&(t=t.contents),m(t))return t;if(h(t)){let r=n.schema[i].createNode?.(n.schema,null,n);return r.items.push(t),r}(t instanceof String||t instanceof Number||t instanceof Boolean||"u">typeof BigInt&&t instanceof BigInt)&&(t=t.valueOf());let{aliasDuplicateObjects:s,onAnchor:l,onTagObj:c,schema:u,sourceObjects:f}=n;if(s&&t&&"object"==typeof t){if(a=f.get(t))return a.anchor??(a.anchor=l(t)),new D(a.anchor);a={anchor:null,node:null},f.set(t,a)}r?.startsWith("!!")&&(r="tag:yaml.org,2002:"+r.slice(2));let p=function(t,r,n){if(r){let t=n.filter(t=>t.tag===r),i=t.find(t=>!t.format)??t[0];if(!i)throw Error(`Tag ${r} not found`);return i}return n.find(r=>r.identify?.(t)&&!r.format)}(t,r,u.tags);if(!p){if(t&&"function"==typeof t.toJSON&&(t=t.toJSON()),!t||"object"!=typeof t){let r=new L(t);return a&&(a.node=r),r}p=t instanceof Map?u[i]:Symbol.iterator in Object(t)?u[o]:u[i]}c&&(c(p),delete n.onTagObj);let g=p?.createNode?p.createNode(n.schema,t,n):"function"==typeof p?.nodeClass?.from?p.nodeClass.from(n.schema,t,n):new L(t);return r?g.tag=r:p.default||(g.tag=p.tag),a&&(a.node=g),g}function P(t,r,n){let i=n;for(let t=r.length-1;t>=0;--t){let n=r[t];if("number"==typeof n&&Number.isInteger(n)&&n>=0){let t=[];t[n]=i,i=t}else i=new Map([[n,i]])}return z(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error("This should not happen, please report a bug.")},schema:t,sourceObjects:new Map})}L.BLOCK_FOLDED="BLOCK_FOLDED",L.BLOCK_LITERAL="BLOCK_LITERAL",L.PLAIN="PLAIN",L.QUOTE_DOUBLE="QUOTE_DOUBLE",L.QUOTE_SINGLE="QUOTE_SINGLE";class j extends O{constructor(t,r){super(t),Object.defineProperty(this,"schema",{value:r,configurable:!0,enumerable:!1,writable:!0})}clone(t){let r=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return t&&(r.schema=t),r.items=r.items.map(r=>m(r)||h(r)?r.clone(t):r),this.range&&(r.range=this.range.slice()),r}addIn(t,r){if(null==t||"object"==typeof t&&t[Symbol.iterator]().next().done)this.add(r);else{let[n,...i]=t,a=this.get(n,!0);if(g(a))a.addIn(i,r);else if(void 0===a&&this.schema)this.set(n,P(this.schema,i,r));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${i}`)}}deleteIn(t){let[r,...n]=t;if(0===n.length)return this.delete(r);let i=this.get(r,!0);if(g(i))return i.deleteIn(n);throw Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}getIn(t,r){let[n,...i]=t,a=this.get(n,!0);return 0===i.length?!r&&f(a)?a.value:a:g(a)?a.getIn(i,r):void 0}hasAllNullValues(t){return this.items.every(r=>{if(!h(r))return!1;let n=r.value;return null==n||t&&f(n)&&null==n.value&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(t){let[r,...n]=t;if(0===n.length)return this.has(r);let i=this.get(r,!0);return!!g(i)&&i.hasIn(n)}setIn(t,r){let[n,...i]=t;if(0===i.length)this.set(n,r);else{let t=this.get(n,!0);if(g(t))t.setIn(i,r);else if(void 0===t&&this.schema)this.set(n,P(this.schema,i,r));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${i}`)}}}let F=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function B(t,r){return/^\n+$/.test(t)?t.substring(1):r?t.replace(/^(?! *$)/gm,r):t}let W=(t,r,n)=>t.endsWith("\n")?B(n,r):n.includes("\n")?"\n"+B(n,r):(t.endsWith(" ")?"":" ")+n,H="block",U="quoted";function q(t,r,n="flow",{indentAtStart:i,lineWidth:a=80,minContentWidth:s=20,onFold:o,onOverflow:l}={}){let c,d,u;if(!a||a<0)return t;a<s&&(s=0);let h=Math.max(1+s,1+a-r.length);if(t.length<=h)return t;let f=[],p={},g=a-r.length;"number"==typeof i&&(i>a-Math.max(2,s)?f.push(0):g=a-i);let m=!1,y=-1,v=-1,b=-1;for(n===H&&-1!==(y=V(t,y,r.length))&&(g=y+h);u=t[y+=1];){if(n===U&&"\\"===u){switch(v=y,t[y+1]){case"x":y+=3;break;case"u":y+=5;break;case"U":y+=9;break;default:y+=1}b=y}if("\n"===u)n===H&&(y=V(t,y,r.length)),g=y+r.length+h,c=void 0;else{if(" "===u&&d&&" "!==d&&"\n"!==d&&" "!==d){let r=t[y+1];r&&" "!==r&&"\n"!==r&&" "!==r&&(c=y)}if(y>=g)if(c)f.push(c),g=c+h,c=void 0;else if(n===U){for(;" "===d||" "===d;)d=u,u=t[y+=1],m=!0;let r=y>b+1?y-2:v-1;if(p[r])return t;f.push(r),p[r]=!0,g=r+h,c=void 0}else m=!0}d=u}if(m&&l&&l(),0===f.length)return t;o&&o();let x=t.slice(0,f[0]);for(let i=0;i<f.length;++i){let a=f[i],s=f[i+1]||t.length;0===a?x=`
|
|
151
|
+
${r}${t.slice(0,s)}`:(n===U&&p[a]&&(x+=`${t[a]}\\`),x+=`
|
|
152
|
+
${r}${t.slice(a+1,s)}`)}return x}function V(t,r,n){let i=r,a=r+1,s=t[a];for(;" "===s||" "===s;)if(r<a+n)s=t[++r];else{do s=t[++r];while(s&&"\n"!==s);i=r,s=t[a=r+1]}return i}let Y=(t,r)=>({indentAtStart:r?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth});function G(t,r){let n=JSON.stringify(t);if(r.options.doubleQuotedAsJSON)return n;let{implicitKey:i}=r,a=r.options.doubleQuotedMinMultiLineLength,s=r.indent||(/^(%|---|\.\.\.)/m.test(t)?" ":""),o="",l=0;for(let t=0,r=n[t];r;r=n[++t])if(" "===r&&"\\"===n[t+1]&&"n"===n[t+2]&&(o+=n.slice(l,t)+"\\ ",t+=1,l=t,r="\\"),"\\"===r)switch(n[t+1]){case"u":{o+=n.slice(l,t);let r=n.substr(t+2,4);switch(r){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:"00"===r.substr(0,2)?o+="\\x"+r.substr(2):o+=n.substr(t,6)}t+=5,l=t+1}break;case"n":if(i||'"'===n[t+2]||n.length<a)t+=1;else{for(o+=n.slice(l,t)+"\n\n";"\\"===n[t+2]&&"n"===n[t+3]&&'"'!==n[t+4];)o+="\n",t+=2;o+=s," "===n[t+2]&&(o+="\\"),t+=1,l=t+1}break;default:t+=1}return o=l?o+n.slice(l):n,i?o:q(o,s,"quoted",Y(r,!1))}function Z(t,r){if(!1===r.options.singleQuote||r.implicitKey&&t.includes("\n")||/[ \t]\n|\n[ \t]/.test(t))return G(t,r);let n=r.indent||(/^(%|---|\.\.\.)/m.test(t)?" ":""),i="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
153
|
+
${n}`)+"'";return r.implicitKey?i:q(i,n,"flow",Y(r,!1))}function X(t,r){let n,{singleQuote:i}=r.options;if(!1===i)n=G;else{let r=t.includes('"'),a=t.includes("'");n=r&&!a?Z:a&&!r?G:i?Z:G}return n(t,r)}try{t=RegExp("(^|(?<!\n))\n+(?!\n|$)","g")}catch{t=/\n+(?!\n|$)/g}function K({comment:r,type:n,value:i},a,s,o){let l,c,d,u,{blockQuote:h,commentString:f,lineWidth:p}=a.options;if(!h||/\n[\t ]+$/.test(i))return X(i,a);let g=a.indent||(a.forceBlockIndent||(u=i,/^(%|---|\.\.\.)/m.test(u))?" ":""),m="literal"===h||"folded"!==h&&n!==L.BLOCK_FOLDED&&(n===L.BLOCK_LITERAL||!function(t,r,n){if(!r||r<0)return!1;let i=r-n,a=t.length;if(a<=i)return!1;for(let r=0,n=0;r<a;++r)if("\n"===t[r]){if(r-n>i)return!0;if(a-(n=r+1)<=i)return!1}return!0}(i,p,g.length));if(!i)return m?"|\n":">\n";for(c=i.length;c>0;--c){let t=i[c-1];if("\n"!==t&&" "!==t&&" "!==t)break}let y=i.substring(c),v=y.indexOf("\n");-1===v?l="-":i===y||v!==y.length-1?(l="+",o&&o()):l="",y&&(i=i.slice(0,-y.length),"\n"===y[y.length-1]&&(y=y.slice(0,-1)),y=y.replace(t,`$&${g}`));let b=!1,x=-1;for(d=0;d<i.length;++d){let t=i[d];if(" "===t)b=!0;else if("\n"===t)x=d;else break}let w=i.substring(0,x<d?x+1:d);w&&(i=i.substring(w.length),w=w.replace(/\n+/g,`$&${g}`));let $=g?"2":"1",k=(b?$:"")+l;if(r&&(k+=" "+f(r.replace(/ ?[\r\n]+/g," ")),s&&s()),!m){let t=i.replace(/\n+/g,"\n$&").replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${g}`),r=!1,s=Y(a,!0);"folded"!==h&&n!==L.BLOCK_FOLDED&&(s.onOverflow=()=>{r=!0});let o=q(`${w}${t}${y}`,g,"block",s);if(!r)return`>${k}
|
|
154
|
+
${g}${o}`}return i=i.replace(/\n+/g,`$&${g}`),`|${k}
|
|
155
|
+
${g}${w}${i}${y}`}function J(t,r,n,i){let{implicitKey:a,inFlow:s}=r,o="string"==typeof t.value?t:Object.assign({},t,{value:String(t.value)}),{type:l}=t;l!==L.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(l=L.QUOTE_DOUBLE);let c=t=>{switch(t){case L.BLOCK_FOLDED:case L.BLOCK_LITERAL:return a||s?X(o.value,r):K(o,r,n,i);case L.QUOTE_DOUBLE:return G(o.value,r);case L.QUOTE_SINGLE:return Z(o.value,r);case L.PLAIN:return function(t,r,n,i){let{type:a,value:s}=t,{actualString:o,implicitKey:l,indent:c,indentStep:d,inFlow:u}=r;if(l&&s.includes("\n")||u&&/[[\]{},]/.test(s))return X(s,r);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(s))return l||u||!s.includes("\n")?X(s,r):K(t,r,n,i);if(!l&&!u&&a!==L.PLAIN&&s.includes("\n"))return K(t,r,n,i);if(/^(%|---|\.\.\.)/m.test(s)){if(""===c)return r.forceBlockIndent=!0,K(t,r,n,i);else if(l&&c===d)return X(s,r)}let h=s.replace(/\n+/g,`$&
|
|
156
|
+
${c}`);if(o){let t=t=>t.default&&"tag:yaml.org,2002:str"!==t.tag&&t.test?.test(h),{compat:n,tags:i}=r.doc.schema;if(i.some(t)||n?.some(t))return X(s,r)}return l?h:q(h,c,"flow",Y(r,!1))}(o,r,n,i);default:return null}},d=c(l);if(null===d){let{defaultKeyType:t,defaultStringType:n}=r.options,i=a&&t||n;if(null===(d=c(i)))throw Error(`Unsupported default string type ${i}`)}return d}function Q(t,r,n,i){let a;if(h(t))return t.toString(r,n,i);if(c(t)){if(r.doc.directives)return t.toString(r);if(r.resolvedAliases?.has(t))throw TypeError("Cannot stringify circular structure without alias nodes");r.resolvedAliases?r.resolvedAliases.add(t):r.resolvedAliases=new Set([t]),t=t.resolve(r.doc)}let s=m(t)?t:r.doc.createNode(t,{onTagObj:t=>a=t});a??(a=function(t,r){let n,i;if(r.tag){let n=t.filter(t=>t.tag===r.tag);if(n.length>0)return n.find(t=>t.format===r.format)??n[0]}if(f(r)){n=r.value;let a=t.filter(t=>t.identify?.(n));if(a.length>1){let t=a.filter(t=>t.test);t.length>0&&(a=t)}i=a.find(t=>t.format===r.format)??a.find(t=>!t.format)}else n=r,i=t.find(t=>t.nodeClass&&n instanceof t.nodeClass);if(!i){let t=n?.constructor?.name??(null===n?"null":typeof n);throw Error(`Tag not resolved for ${t} value`)}return i}(r.doc.schema.tags,s));let o=function(t,r,{anchors:n,doc:i}){if(!i.directives)return"";let a=[],s=(f(t)||g(t))&&t.anchor;s&&I(s)&&(n.add(s),a.push(`&${s}`));let o=t.tag??(r.default?null:r.tag);return o&&a.push(i.directives.tagString(o)),a.join(" ")}(s,a,r);o.length>0&&(r.indentAtStart=(r.indentAtStart??0)+o.length+1);let l="function"==typeof a.stringify?a.stringify(s,r,n,i):f(s)?J(s,r,n,i):s.toString(r,n,i);return o?f(s)||"{"===l[0]||"["===l[0]?`${o} ${l}`:`${o}
|
|
157
|
+
${r.indent}${l}`:l}let ee=t=>"<<"===t||"symbol"==typeof t&&"<<"===t.description,et="tag:yaml.org,2002:merge";function er(t,r,n){let i=ei(t,n);if(p(i))for(let n of i.items)en(t,r,n);else if(Array.isArray(i))for(let n of i)en(t,r,n);else en(t,r,i)}function en(t,r,n){let i=ei(t,n);if(!u(i))throw Error("Merge sources must be maps or map aliases");for(let[n,a]of i.toJSON(null,t,Map))r instanceof Map?r.has(n)||r.set(n,a):r instanceof Set?r.add(n):Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:a,writable:!0,enumerable:!0,configurable:!0});return r}function ei(t,r){return t&&c(r)?r.resolve(t.doc,t):r}function ea(t,r,{key:n,value:i}){if(m(n)&&n.addToJSMap)n.addToJSMap(t,r,i);else if((ee(n)||f(n)&&(!n.type||n.type===L.PLAIN)&&ee(n.value))&&t?.doc.schema.tags.some(t=>t.tag===et&&t.default))er(t,r,i);else{let a=N(n,"",t);if(r instanceof Map)r.set(a,N(i,a,t));else if(r instanceof Set)r.add(a);else{let s=function(t,r,n){if(null===r)return"";if("object"!=typeof r)return String(r);if(m(t)&&n?.doc){let r=function(t,r){let n,i=Object.assign({blockQuote:!0,commentString:F,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},t.schema.toStringOptions,r);switch(i.collectionStyle){case"block":n=!1;break;case"flow":n=!0;break;default:n=null}return{anchors:new Set,doc:t,flowCollectionPadding:i.flowCollectionPadding?" ":"",indent:"",indentStep:"number"==typeof i.indent?" ".repeat(i.indent):" ",inFlow:n,options:i}}(n.doc,{});for(let t of(r.anchors=new Set,n.anchors.keys()))r.anchors.add(t.anchor);r.inFlow=!0,r.inStringifyKey=!0;let s=t.toString(r);if(!n.mapKeyWarned){var i,a;let t=JSON.stringify(s);t.length>40&&(t=t.substring(0,36)+'..."'),i=n.doc.options.logLevel,a=`Keys with collection values will be stringified due to JS Object restrictions: ${t}. Set mapAsMap: true to use object keys.`,("debug"===i||"warn"===i)&&console.warn(a),n.mapKeyWarned=!0}return s}return JSON.stringify(r)}(n,a,t),o=N(i,s,t);s in r?Object.defineProperty(r,s,{value:o,writable:!0,enumerable:!0,configurable:!0}):r[s]=o}}return r}function es(t,r,n){return new eo(z(t,void 0,n),z(r,void 0,n))}class eo{constructor(t,r=null){Object.defineProperty(this,l,{value:a}),this.key=t,this.value=r}clone(t){let{key:r,value:n}=this;return m(r)&&(r=r.clone(t)),m(n)&&(n=n.clone(t)),new eo(r,n)}toJSON(t,r){let n=r?.mapAsMap?new Map:{};return ea(r,n,this)}toString(t,r,n){return t?.doc?function({key:t,value:r},n,i,a){let s,o,l,{allNullValues:c,doc:d,indent:u,indentStep:h,options:{commentString:y,indentSeq:v,simpleKeys:b}}=n,x=m(t)&&t.comment||null;if(b){if(x)throw Error("With simple keys, key nodes cannot have comments");if(g(t)||!m(t)&&"object"==typeof t)throw Error("With simple keys, collection cannot be used as a key value")}let w=!b&&(!t||x&&null==r&&!n.inFlow||g(t)||(f(t)?t.type===L.BLOCK_FOLDED||t.type===L.BLOCK_LITERAL:"object"==typeof t));n=Object.assign({},n,{allNullValues:!1,implicitKey:!w&&(b||!c),indent:u+h});let $=!1,k=!1,M=Q(t,n,()=>$=!0,()=>k=!0);if(!w&&!n.inFlow&&M.length>1024){if(b)throw Error("With simple keys, single line scalar must not span more than 1024 characters");w=!0}if(n.inFlow){if(c||null==r)return $&&i&&i(),""===M?"?":w?`? ${M}`:M}else if(c&&!b||null==r&&w)return M=`? ${M}`,x&&!$?M+=W(M,n.indent,y(x)):k&&a&&a(),M;$&&(x=null),w?(x&&(M+=W(M,n.indent,y(x))),M=`? ${M}
|
|
158
|
+
${u}:`):(M=`${M}:`,x&&(M+=W(M,n.indent,y(x)))),m(r)?(s=!!r.spaceBefore,o=r.commentBefore,l=r.comment):(s=!1,o=null,l=null,r&&"object"==typeof r&&(r=d.createNode(r))),n.implicitKey=!1,!w&&!x&&f(r)&&(n.indentAtStart=M.length+1),k=!1,!(!v&&h.length>=2&&!n.inFlow&&!w&&p(r))||r.flow||r.tag||r.anchor||(n.indent=n.indent.substring(2));let _=!1,A=Q(r,n,()=>_=!0,()=>k=!0),E=" ";if(x||s||o){if(E=s?"\n":"",o){let t=y(o);E+=`
|
|
159
|
+
${B(t,n.indent)}`}""!==A||n.inFlow?E+=`
|
|
160
|
+
${n.indent}`:"\n"===E&&l&&(E="\n\n")}else if(!w&&g(r)){let t=A[0],i=A.indexOf("\n"),a=-1!==i,s=n.inFlow??r.flow??0===r.items.length;if(a||!s){let r=!1;if(a&&("&"===t||"!"===t)){let n=A.indexOf(" ");"&"===t&&-1!==n&&n<i&&"!"===A[n+1]&&(n=A.indexOf(" ",n+1)),(-1===n||i<n)&&(r=!0)}r||(E=`
|
|
161
|
+
${n.indent}`)}}else(""===A||"\n"===A[0])&&(E="");return M+=E+A,n.inFlow?_&&i&&i():l&&!_?M+=W(M,n.indent,y(l)):k&&a&&a(),M}(this,t,r,n):JSON.stringify(this)}}function el(t,r,n){return(r.inFlow??t.flow?function({items:t},r,{flowChars:n,itemIndent:i}){let{indent:a,indentStep:s,flowCollectionPadding:o,options:{commentString:l}}=r,c=Object.assign({},r,{indent:i+=s,inFlow:!0,type:null}),d=!1,u=0,f=[];for(let n=0;n<t.length;++n){let a=t[n],s=null;if(m(a))a.spaceBefore&&f.push(""),ec(r,f,a.commentBefore,!1),a.comment&&(s=a.comment);else if(h(a)){let t=m(a.key)?a.key:null;t&&(t.spaceBefore&&f.push(""),ec(r,f,t.commentBefore,!1),t.comment&&(d=!0));let n=m(a.value)?a.value:null;n?(n.comment&&(s=n.comment),n.commentBefore&&(d=!0)):null==a.value&&t?.comment&&(s=t.comment)}s&&(d=!0);let o=Q(a,c,()=>s=null);d||(d=f.length>u||o.includes("\n")),n<t.length-1?o+=",":r.options.trailingComma&&(r.options.lineWidth>0&&(d||(d=f.reduce((t,r)=>t+r.length+2,2)+(o.length+2)>r.options.lineWidth)),d&&(o+=",")),s&&(o+=W(o,i,l(s))),f.push(o),u=f.length}let{start:p,end:g}=n;if(0===f.length)return p+g;if(!d){let t=f.reduce((t,r)=>t+r.length+2,2);d=r.options.lineWidth>0&&t>r.options.lineWidth}if(!d)return`${p}${o}${f.join(" ")}${o}${g}`;{let t=p;for(let r of f)t+=r?`
|
|
162
|
+
${s}${a}${r}`:"\n";return`${t}
|
|
163
|
+
${a}${g}`}}:function({comment:t,items:r},n,{blockItemPrefix:i,flowChars:a,itemIndent:s,onChompKeep:o,onComment:l}){let c,{indent:d,options:{commentString:u}}=n,f=Object.assign({},n,{indent:s,type:null}),p=!1,g=[];for(let t=0;t<r.length;++t){let a=r[t],o=null;if(m(a))!p&&a.spaceBefore&&g.push(""),ec(n,g,a.commentBefore,p),a.comment&&(o=a.comment);else if(h(a)){let t=m(a.key)?a.key:null;t&&(!p&&t.spaceBefore&&g.push(""),ec(n,g,t.commentBefore,p))}p=!1;let l=Q(a,f,()=>o=null,()=>p=!0);o&&(l+=W(l,s,u(o))),p&&o&&(p=!1),g.push(i+l)}if(0===g.length)c=a.start+a.end;else{c=g[0];for(let t=1;t<g.length;++t){let r=g[t];c+=r?`
|
|
164
|
+
${d}${r}`:"\n"}}return t?(c+="\n"+B(u(t),d),l&&l()):p&&o&&o(),c})(t,r,n)}function ec({indent:t,options:{commentString:r}},n,i,a){if(i&&a&&(i=i.replace(/^\n+/,"")),i){let a=B(r(i),t);n.push(a.trimStart())}}function ed(t,r){let n=f(r)?r.value:r;for(let i of t)if(h(i)&&(i.key===r||i.key===n||f(i.key)&&i.key.value===n))return i}class eu extends j{static get tagName(){return"tag:yaml.org,2002:map"}constructor(t){super(i,t),this.items=[]}static from(t,r,n){let{keepUndefined:i,replacer:a}=n,s=new this(t),o=(t,o)=>{if("function"==typeof a)o=a.call(r,t,o);else if(Array.isArray(a)&&!a.includes(t))return;(void 0!==o||i)&&s.items.push(es(t,o,n))};if(r instanceof Map)for(let[t,n]of r)o(t,n);else if(r&&"object"==typeof r)for(let t of Object.keys(r))o(t,r[t]);return"function"==typeof t.sortMapEntries&&s.items.sort(t.sortMapEntries),s}add(t,r){let n;n=h(t)?t:t&&"object"==typeof t&&"key"in t?new eo(t.key,t.value):new eo(t,t?.value);let i=ed(this.items,n.key),a=this.schema?.sortMapEntries;if(i){if(!r)throw Error(`Key ${n.key} already set`);f(i.value)&&R(n.value)?i.value.value=n.value:i.value=n.value}else if(a){let t=this.items.findIndex(t=>0>a(n,t));-1===t?this.items.push(n):this.items.splice(t,0,n)}else this.items.push(n)}delete(t){let r=ed(this.items,t);return!!r&&this.items.splice(this.items.indexOf(r),1).length>0}get(t,r){let n=ed(this.items,t),i=n?.value;return(!r&&f(i)?i.value:i)??void 0}has(t){return!!ed(this.items,t)}set(t,r){this.add(new eo(t,r),!0)}toJSON(t,r,n){let i=n?new n:r?.mapAsMap?new Map:{};for(let t of(r?.onCreate&&r.onCreate(i),this.items))ea(r,i,t);return i}toString(t,r,n){if(!t)return JSON.stringify(this);for(let t of this.items)if(!h(t))throw Error(`Map items must all be pairs; found ${JSON.stringify(t)} instead`);return!t.allNullValues&&this.hasAllNullValues(!1)&&(t=Object.assign({},t,{allNullValues:!0})),el(this,t,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:t.indent||"",onChompKeep:n,onComment:r})}}class eh extends j{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(t){super(o,t),this.items=[]}add(t){this.items.push(t)}delete(t){let r=ef(t);return"number"==typeof r&&this.items.splice(r,1).length>0}get(t,r){let n=ef(t);if("number"!=typeof n)return;let i=this.items[n];return!r&&f(i)?i.value:i}has(t){let r=ef(t);return"number"==typeof r&&r<this.items.length}set(t,r){let n=ef(t);if("number"!=typeof n)throw Error(`Expected a valid index, not ${t}.`);let i=this.items[n];f(i)&&R(r)?i.value=r:this.items[n]=r}toJSON(t,r){let n=[];r?.onCreate&&r.onCreate(n);let i=0;for(let t of this.items)n.push(N(t,String(i++),r));return n}toString(t,r,n){return t?el(this,t,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(t.indent||"")+" ",onChompKeep:n,onComment:r}):JSON.stringify(this)}static from(t,r,n){let{replacer:i}=n,a=new this(t);if(r&&Symbol.iterator in Object(r)){let t=0;for(let s of r){if("function"==typeof i){let n=r instanceof Set?s:String(t++);s=i.call(r,n,s)}a.items.push(z(s,void 0,n))}}return a}}function ef(t){let r=f(t)?t.value:t;return r&&"string"==typeof r&&(r=Number(r)),"number"==typeof r&&Number.isInteger(r)&&r>=0?r:null}function ep(t){return"bigint"==typeof t||Number.isInteger(t)}let eg=({value:t})=>JSON.stringify(t);[{collection:"map",default:!0,nodeClass:eu,tag:"tag:yaml.org,2002:map",resolve:(t,r)=>(u(t)||r("Expected a mapping for this tag"),t),createNode:(t,r,n)=>eu.from(t,r,n)},{collection:"seq",default:!0,nodeClass:eh,tag:"tag:yaml.org,2002:seq",resolve:(t,r)=>(p(t)||r("Expected a sequence for this tag"),t),createNode:(t,r,n)=>eh.from(t,r,n)}].concat([{identify:t=>"string"==typeof t,default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:eg},{identify:t=>null==t,createNode:()=>new L(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:eg},{identify:t=>"boolean"==typeof t,default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>"true"===t,stringify:eg},{identify:ep,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(t,r,{intAsBigInt:n})=>n?BigInt(t):parseInt(t,10),stringify:({value:t})=>ep(t)?t.toString():JSON.stringify(t)},{identify:t=>"number"==typeof t,default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:t=>parseFloat(t),stringify:eg}],{default:!0,tag:"",test:/^/,resolve:(t,r)=>(r(`Unresolved plain scalar ${JSON.stringify(t)}`),t)});class em extends eh{constructor(){super(),this.add=eu.prototype.add.bind(this),this.delete=eu.prototype.delete.bind(this),this.get=eu.prototype.get.bind(this),this.has=eu.prototype.has.bind(this),this.set=eu.prototype.set.bind(this),this.tag=em.tag}toJSON(t,r){if(!r)return super.toJSON(t);let n=new Map;for(let t of(r?.onCreate&&r.onCreate(n),this.items)){let i,a;if(h(t)?(i=N(t.key,"",r),a=N(t.value,i,r)):i=N(t,"",r),n.has(i))throw Error("Ordered maps must not include duplicate keys");n.set(i,a)}return n}static from(t,r,n){let i=function(t,r,n){let{replacer:i}=n,a=new eh(t);a.tag="tag:yaml.org,2002:pairs";let s=0;if(r&&Symbol.iterator in Object(r))for(let t of r){let o,l;if("function"==typeof i&&(t=i.call(r,String(s++),t)),Array.isArray(t))if(2===t.length)o=t[0],l=t[1];else throw TypeError(`Expected [key, value] tuple: ${t}`);else if(t&&t instanceof Object){let r=Object.keys(t);if(1===r.length)l=t[o=r[0]];else throw TypeError(`Expected tuple with one key, not ${r.length} keys`)}else o=t;a.items.push(es(o,l,n))}return a}(t,r,n),a=new this;return a.items=i.items,a}}function ey({value:t,source:r},n){return r&&(t?ev:eb).test.test(r)?r:t?n.options.trueStr:n.options.falseStr}em.tag="tag:yaml.org,2002:omap";let ev={identify:t=>!0===t,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new L(!0),stringify:ey},eb={identify:t=>!1===t,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new L(!1),stringify:ey};class ex extends eu{constructor(t){super(t),this.tag=ex.tag}add(t){let r;r=h(t)?t:t&&"object"==typeof t&&"key"in t&&"value"in t&&null===t.value?new eo(t.key,null):new eo(t,null),ed(this.items,r.key)||this.items.push(r)}get(t,r){let n=ed(this.items,t);return!r&&h(n)?f(n.key)?n.key.value:n.key:n}set(t,r){if("boolean"!=typeof r)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof r}`);let n=ed(this.items,t);n&&!r?this.items.splice(this.items.indexOf(n),1):!n&&r&&this.items.push(new eo(t))}toJSON(t,r){return super.toJSON(t,r,Set)}toString(t,r,n){if(!t)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},t,{allNullValues:!0}),r,n);throw Error("Set items must all have null values")}static from(t,r,n){let{replacer:i}=n,a=new this(t);if(r&&Symbol.iterator in Object(r))for(let t of r)"function"==typeof i&&(t=i.call(r,t,t)),a.items.push(es(t,null,n));return a}}ex.tag="tag:yaml.org,2002:set";let ew={identify:t=>t instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(t){let r=t.match(ew.test);if(!r)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,n,i,a,s,o,l]=r.map(Number),c=Date.UTC(n,i-1,a,s||0,o||0,l||0,r[7]?Number((r[7]+"00").substr(1,3)):0),d=r[8];if(d&&"Z"!==d){var u,h;let t,r,n,i,a=(h=!1,r="-"===(t=(u=d)[0])||"+"===t?u.substring(1):u,n=t=>h?BigInt(t):Number(t),i=r.replace(/_/g,"").split(":").reduce((t,r)=>t*n(60)+n(r),n(0)),"-"===t?n(-1)*i:i);30>Math.abs(a)&&(a*=60),c-=6e4*a}return new Date(c)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""},e$=Symbol("break visit"),ek=Symbol("skip children"),eM=Symbol("remove item");function e_(t,r){"type"in t&&"document"===t.type&&(t={start:t.start,value:t.value}),function t(r,n,i){let a=i(n,r);if("symbol"==typeof a)return a;for(let s of["key","value"]){let o=n[s];if(o&&"items"in o){for(let n=0;n<o.items.length;++n){let a=t(Object.freeze(r.concat([[s,n]])),o.items[n],i);if("number"==typeof a)n=a-1;else{if(a===e$)return e$;a===eM&&(o.items.splice(n,1),n-=1)}}"function"==typeof a&&"key"===s&&(a=a(n,r))}}return"function"==typeof a?a(n,r):a}(Object.freeze([]),t,r)}e_.BREAK=e$,e_.SKIP=ek,e_.REMOVE=eM,e_.itemAtPath=(t,r)=>{let n=t;for(let[t,i]of r){let r=n?.[t];if(!r||!("items"in r))return;n=r.items[i]}return n},e_.parentCollection=(t,r)=>{let n=e_.itemAtPath(t,r.slice(0,-1)),i=r[r.length-1][0],a=n?.[i];if(a&&"items"in a)return a;throw Error("Parent collection not found")}},9211(t,r,n){var i,a;let s,o,l,c,d,u,h,f,p,g;function m(t){let r=Object.values(t).filter(t=>"number"==typeof t);return Object.entries(t).filter(([t,n])=>-1===r.indexOf(+t)).map(([t,r])=>r)}function y(t,r="|"){return t.map(t=>P(t)).join(r)}function v(t,r){return"bigint"==typeof r?r.toString():r}n.d(r,{gMt:()=>ir,Ikc:()=>n7,g1P:()=>is,zMY:()=>n2,YjP:()=>nA,euz:()=>id,aig:()=>nJ,k5n:()=>il,YOg:()=>n8});class b{constructor(t){this._getter=t,this._value=void 0}get value(){let t=this._getter;return void 0!==t&&(this._value=t(),this._getter=void 0),this._value}}function x(t){return new b(t)}function w(t){let r=+!!t.startsWith("^"),n=t.endsWith("$")?t.length-1:t.length;return t.slice(r,n)}function $(t,r,n){Object.defineProperty(t,r,{value:n,writable:!0,enumerable:!0,configurable:!0})}function k(t){let r=Object.getOwnPropertyDescriptor(t,"shape");return r?.get?r.get.raw:r?.value}function M(t){return k(t._zod.def)??t._zod.def.shape}function _(t,r,n){Object.defineProperty(t,r,{get(){let t=n();return $(this,r,t),t},enumerable:!0,configurable:!0})}function A(t,r,n){r in t?$(t,r,n):t[r]=n}function E(t,r,n,i){let a=M(r);for(let s of n){let n=Object.getOwnPropertyDescriptor(a,s);n.enumerable&&(n.get?_(t,s,()=>{let t=r._zod.def.shape[s];return i?i(t,s):t}):A(t,s,i?i(n.value,s):n.value))}}function S(...t){let r={};for(let n of t)Object.assign(r,Object.getOwnPropertyDescriptors(n));return Object.defineProperties({},r)}let C="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function T(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}let I=x(()=>{if(ed.jitless||"u">typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return Function(""),!0}catch(t){return!1}});function N(t){if(!1===T(t))return!1;let r=t.constructor;if(void 0===r||"function"!=typeof r)return!0;let n=r.prototype;return!1!==T(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function O(t){return N(t)?{...t}:Array.isArray(t)?[...t]:t instanceof Map?new Map(t):t instanceof Set?new Set(t):t}let D=new Set(["string","number","symbol"]);function R(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function L(t,r,n){let i=new t._zod.constr(r??t._zod.def);return(!r||n?.parent)&&(i._zod.parent=t),i}function z(t){if(!t)return{};if("string"==typeof t)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,"string"==typeof t.error)?{...t,error:()=>t.error}:t}function P(t){return"bigint"==typeof t?t.toString()+"n":"string"==typeof t?`"${t}"`:`${t}`}let j={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-0x80000000,0x7fffffff],uint32:[0,0xffffffff],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},F={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function B(t,r){let n=M(t),i=[];for(let t of Reflect.ownKeys(r)){if(!Object.getOwnPropertyDescriptor(n,t)?.enumerable)throw Error(`Unrecognized key: "${String(t)}"`);r[t]&&i.push(t)}return i}function W(t,r){let n={};E(n,t,Reflect.ownKeys(M(t)));for(let t of Reflect.ownKeys(r)){let i=Object.getOwnPropertyDescriptor(r,t);i.enumerable&&(i.get?_(n,t,()=>r[t]):A(n,t,i.value))}return n}function H(t,r,n,i="partial"){let a=r._zod.def.checks;if(a&&a.length>0)throw Error(`.${i}() cannot be used on object schemas containing refinements`);let s=n?new Set(B(r,n)):void 0,o={};return E(o,r,Reflect.ownKeys(M(r)),t&&((r,n)=>s&&!s.has(n)?r:new t({type:"optional",innerType:r}))),L(r,S(r._zod.def,{shape:o,checks:[]}))}function U(t,r=0){if(!0===t.aborted)return!0;for(let n=r;n<t.issues.length;n++)if(t.issues[n]?.continue!==!0)return!0;return!1}function q(t,r){return r.map(r=>(r.path??(r.path=[]),r.path.unshift(t),r))}function V(t){return"string"==typeof t?t:t?.message}function Y(t){let r=[];for(let n of t??[]){let t=n._zod.def;if(!/_(length|size)$|_equals$/.test(t.check))break;let i=t.maximum??t.length??t.size;i>=0&&r.push([i,n])}return r}function G(t,r,n){var i;for(let a=r;a<t.length;a++)(i=t[a]).schema??(i.schema=n)}function Z(t,r,n){let i=t.inst?._zod?.traits;i?.has("$ZodType")&&(i.has("$ZodCheck")?t.schema??(t.schema=t.inst):t.schema=t.inst);let a=t.schema!==t.inst?t.schema?._zod.def?.error:void 0,s=t.message?t.message:V(t.inst?._zod.def?.error?.(t))??V(a?.(t))??V(r?.error?.(t))??V(n.customError?.(t))??V(n.localeError?.(t))??"Invalid input",o={};for(let r of Object.keys(t))"inst"!==r&&"schema"!==r&&"continue"!==r&&"input"!==r&&"__proto__"!==r&&(o[r]=t[r]);return o.path??(o.path=[]),o.message=s,r?.reportInput&&(o.input=t.input),o}let X=/[\uD800-\uDBFF]/;function K(t){let r=t.length;if(!X.test(t))return r;let n=r;for(let i=0;i<r-1;i++)(64512&t.charCodeAt(i))==55296&&(64512&t.charCodeAt(i+1))==56320&&(n--,i++);return n}function J(t){return Array.isArray(t)?"array":"string"==typeof t?"string":"unknown"}function Q(...t){let[r,n,i]=t;return"string"==typeof r?{message:r,code:"custom",input:n,inst:i}:{...r}}function ee(t,r,n,i=!0){return Object.defineProperty(t,r,{configurable:!0,writable:!0,enumerable:i,value:n}),n}function et(t,r){for(let n in t){let i=t[n];Object.defineProperty(r,n,{configurable:!0,enumerable:!0,get(){return ee(this,n,i(this))},set(t){ee(this,n,t)}})}return r}let er=!1,en={configurable:!0,get(){er=!0}};function ei(t,r,n){let i=Object.getPrototypeOf(t._zod);if(r in i&&s!==t._zod){s=void 0;return}s=t._zod,Object.defineProperty(i,r,{configurable:!0,get(){Object.defineProperty(this,r,en);let t=er;er=!1;try{let i=n(this);return er?delete this[r]:Object.defineProperty(this,r,{configurable:!0,writable:!0,value:i}),er=er||t,i}catch(n){throw delete this[r],er=er||t,n}},set(t){Object.defineProperty(this,r,{configurable:!0,writable:!0,value:t})}})}let ea={value:void 0,enumerable:!1},es="captureStackTrace"in Error?Error:null;function eo(t,r,n,i){function a(t){this.def=t,this.constr=d,this.traits=new Set}a.prototype={};let s=n&&new WeakSet;function o(i,o){if(i._zod){if(i._zod.traits.has(t))return}else{ea.value=new a(o);try{Object.defineProperty(i,"_zod",ea)}finally{ea.value=void 0}}if(i._zod.traits.add(t),r(i,o),s){let t=Object.getPrototypeOf(i),r=i._zod.constr.prototype,a=t;for(;a&&a!==r;)a=Object.getPrototypeOf(a);let o=a??t;if(!s.has(o)){s.add(o);for(let t in n){let r=Object.getOwnPropertyDescriptor(n,t);r.get?Object.defineProperty(o,t,{...r,enumerable:!1}):function(t,r,n){Object.defineProperty(t,r,{configurable:!0,get(){return this==null?n:ee(this,r,n.bind(this))},set(t){ee(this,r,t)}})}(o,t,r.value)}}}let l=d.prototype;for(let t in l)Object.prototype.hasOwnProperty.call(l,t)&&(t in i||(i[t]=l[t].bind(i)))}let l=i?.Parent??Object;class c extends l{}function d(t){let r=i?.Parent?function(t){let r=es;if(r){let n=r.stackTraceLimit;if("number"==typeof n){try{r.stackTraceLimit=0}catch{return es=null,new t}try{return new t}finally{r.stackTraceLimit=n}}}return new t}(c):this;o(r,t);let n=r._zod.deferred;if(n){for(let t of n)t();r._zod.deferred=void 0}let a=globalThis.__zod_globalConfig?.postProcessor;return a&&a(r),r}return Object.defineProperty(c,"name",{value:t}),Object.defineProperty(d,"init",{value:o}),Object.defineProperty(d,Symbol.hasInstance,{value:r=>!!i?.Parent&&r instanceof i.Parent||r?._zod?.traits?.has(t)}),Object.defineProperty(d,"name",{value:t}),d}class el extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class ec extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(i=globalThis).__zod_globalConfig??(i.__zod_globalConfig={});let ed=globalThis.__zod_globalConfig;function eu(t){return t&&Object.assign(ed,t),ed}class eh extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}let ef="~memo",ep=[];function eg(t){return null!==t&&"object"==typeof t}function em(t){return t.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}let ey=new WeakMap,ev=[],eb={alloc(t,r,n){let i=o;if(!i)return n;o=void 0;let a={value:n,issues:null};return i.set(r.value,a),ev.push(a),n},guard(t){var r;(r=t._zod).deferred??(r.deferred=[]),t._zod.deferred.push(()=>{let r=t._zod.parse,n=(t,n)=>{var i,a;let s;if("backward"!==n.direction&&(i=n,a=t.value,void 0!==(s=i[ef]?.backEdges)&&eg(a)&&s.has(a)))throw new eh;return r(t,n)};t._zod.parse=n,t._zod.run===r&&(t._zod.run=n)})},attach(t){var r;let n,i,a,s=!1;(r=t._zod).deferred??(r.deferred=[]),t._zod.deferred.push(()=>{let r=t._zod.parse,l=(c,d)=>{let u;if(void 0===n){let i=function t(r,n,i){var a,s;let o=ey.get(r);if(void 0!==o)return 2*!!o;if(n.has(r))return 2;n.add(r);let l=0,c=r=>{if(2!==l&&r?._zod){let a=t(r,n,i);a>l&&(l=a)}},d=t=>{t>l&&(l=t)},u=r._zod.def;switch(u.type){case"object":{let r=k(u);d(r?((r,a)=>{let s=0;for(let o of Reflect.ownKeys(r)){let l=Object.getOwnPropertyDescriptor(r,o);if(a&&!l.enumerable)continue;let c=l.get?1:l.value?._zod?t(l.value,n,i):0;c>s&&(s=c)}return s})(r,!0):1),c(u.catchall);break}case"array":c(u.element);break;case"tuple":for(let t of u.items)c(t);c(u.rest);break;case"record":case"map":c(u.keyType),c(u.valueType);break;case"set":c(u.valueType);break;case"union":for(let t of u.options)c(t);break;case"intersection":c(u.left),c(u.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":c(u.innerType);break;case"pipe":c(u.in),c(u.out);break;case"function":c(u.input),c(u.output);break;case"lazy":{let a=u._cachedInner??(i?r._zod.innerType:void 0);d(a?t(a,n,!1):1);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 t in u){let r=Object.getOwnPropertyDescriptor(u,t);if(!r||r.get)continue;let n=r.value;if(n&&"object"==typeof n){if(n._zod)c(n);else if(Array.isArray(n))for(let t of n)c(t)}}}return n.delete(r),a=r,1!==(s=l)&&ey.set(a,2===s),s}(t,new Set,!1);if(0===i)return t._zod.parse=r,t._zod.run===l&&(t._zod.run=r),r(c,d);2===i||s?n=!0:s=!0}let h=c.value;if(!eg(h))return r(c,d);let f=d[ef];if(f||(f={buckets:new WeakMap,backEdges:void 0},d[ef]=f),i===d)u=a;else{var p;let r;(r=(p=f).buckets.get(t))||(r=new WeakMap,p.buckets.set(t,r)),u=r,i=d,a=u}let g=u.get(h);if(g)return c.value=g.value,g.issues?g.issues.length&&c.issues.push(...em(g.issues)):(c.memo=!0,f.backEdges??(f.backEdges=new WeakSet),f.backEdges.add(g.value)),c;o=u;let m=ev.length,y=r(c,d);o=void 0;let v=ev.length>m?ev.pop():void 0;return y instanceof Promise?y.then(t=>(v&&(v.issues=t.issues.length?em(t.issues):ep),t)):(v&&(v.issues=y.issues.length?em(y.issues):ep),y)};t._zod.parse=l,t._zod.run===r&&(t._zod.run=l)})}},ex=/^[cC][0-9a-z]{6,}$/,ew=/^[0-9a-z]+$/,e$=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,ek=/^[0-9a-vA-V]{20}$/,eM=/^[A-Za-z0-9]{27}$/,e_=/^[a-zA-Z0-9_-]{21}$/,eA=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,eE=/^([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})$/,eS=t=>t?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[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)$/,eC=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,eT=/^(?:(?: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])$/,eI=/^(([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}|:))$/,eN=/^((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])$/,eO=/^(([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])$/,eD=/^https?$/,eR=/^\+[1-9]\d{6,14}$/,eL="(?:(?:\\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])))",ez=RegExp(`^${eL}$`);function eP(t){let r="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof t.precision?-1===t.precision?`${r}`:0===t.precision?`${r}:[0-5]\\d`:`${r}:[0-5]\\d\\.\\d{${t.precision}}`:t.seconds?`${r}:[0-5]\\d(?:\\.\\d+)?`:`${r}(?::[0-5]\\d(?:\\.\\d+)?)?`}let ej=/^[\s\S]{0,}$/,eF=/^-?\d+$/,eB=/^-?\d+(?:\.\d+)?$/,eW=/^(?:true|false)$/i,eH=/^[^A-Z]*$/,eU=/^[^a-z]*$/,eq=eo("$ZodCheck",(t,r)=>{var n;t._zod??(t._zod={}),t._zod.def=r,(n=t._zod).onattach??(n.onattach=[])}),eV=t=>{let r=t.value;return null!=r&&void 0!==r.length},eY={number:"number",bigint:"bigint",object:"date"},eG=eo("$ZodCheckLessThan",(t,r)=>{eq.init(t,r);let n=eY[typeof r.value];t._zod.check=i=>{(r.inclusive?i.value<=r.value:i.value<r.value)||i.issues.push({origin:eY[typeof i.value]??n,code:"too_big",maximum:"object"==typeof r.value?r.value.getTime():r.value,input:i.value,inclusive:r.inclusive,inst:t,continue:!r.abort})}}),eZ=eo("$ZodCheckGreaterThan",(t,r)=>{eq.init(t,r);let n=eY[typeof r.value];t._zod.check=i=>{(r.inclusive?i.value>=r.value:i.value>r.value)||i.issues.push({origin:eY[typeof i.value]??n,code:"too_small",minimum:"object"==typeof r.value?r.value.getTime():r.value,input:i.value,inclusive:r.inclusive,inst:t,continue:!r.abort})}}),eX=eo("$ZodCheckMultipleOf",(t,r)=>{eq.init(t,r),t._zod.check=n=>{let i,a,s;if(typeof n.value!=typeof r.value)throw Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof n.value?r.value!==BigInt(0)&&n.value%r.value===BigInt(0):0==(a=Math.round(i=n.value/r.value),s=4*Number.EPSILON*Math.max(Math.abs(i),1),Math.abs(i-a)<s?0:i-a))||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:r.value,input:n.value,inst:t,continue:!r.abort})}}),eK=eo("$ZodCheckNumberFormat",(t,r)=>{eq.init(t,r),r.format=r.format||"float64";let n=r.format?.includes("int"),i=n?"int":"number",[a,s]=j[r.format];t._zod.check=o=>{let l=o.value;if(n){if(!Number.isInteger(l))return void o.issues.push({expected:i,format:r.format,code:"invalid_type",continue:!1,input:l,inst:t});if(!Number.isSafeInteger(l))return void(l>0?o.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:i,inclusive:!0,continue:!r.abort}):o.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:i,inclusive:!0,continue:!r.abort}))}l<a&&o.issues.push({origin:"number",input:l,code:"too_small",minimum:a,inclusive:!0,inst:t,continue:!r.abort}),l>s&&o.issues.push({origin:"number",input:l,code:"too_big",maximum:s,inclusive:!0,inst:t,continue:!r.abort})}}),eJ=eo("$ZodCheckMaxLength",(t,r)=>{var n;eq.init(t,r),(n=t._zod.def).when??(n.when=eV),t._zod.check=n=>{let i=n.value,a=i.length;if(("string"==typeof i&&a>r.maximum?K(i):a)<=r.maximum)return;let s=J(i);n.issues.push({origin:s,code:"too_big",maximum:r.maximum,inclusive:!0,input:i,inst:t,continue:!r.abort})}}),eQ=eo("$ZodCheckMinLength",(t,r)=>{var n;eq.init(t,r),(n=t._zod.def).when??(n.when=eV),t._zod.check=n=>{let i=n.value,a=i.length;if(("string"==typeof i&&a>=r.minimum&&a<2*r.minimum?K(i):a)>=r.minimum)return;let s=J(i);n.issues.push({origin:s,code:"too_small",minimum:r.minimum,inclusive:!0,input:i,inst:t,continue:!r.abort})}}),e0=eo("$ZodCheckLengthEquals",(t,r)=>{var n;eq.init(t,r),(n=t._zod.def).when??(n.when=eV),t._zod.check=n=>{let i=n.value,a=i.length,s="string"==typeof i&&a>=r.length&&a<=2*r.length?K(i):a;if(s===r.length)return;let o=J(i),l=s>r.length;n.issues.push({origin:o,...l?{code:"too_big",maximum:r.length}:{code:"too_small",minimum:r.length},inclusive:!0,exact:!0,input:n.value,inst:t,continue:!r.abort})}}),e1=eo("$ZodCheckStringFormat",(t,r)=>{var n,i;eq.init(t,r),r.pattern?(n=t._zod).check??(n.check=n=>{r.pattern.lastIndex=0,r.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:r.format,input:n.value,...r.pattern?{pattern:r.pattern.toString()}:{},inst:t,continue:!r.abort})}):(i=t._zod).check??(i.check=()=>{})}),e2=eo("$ZodCheckRegex",(t,r)=>{e1.init(t,r),t._zod.check=n=>{r.pattern.lastIndex=0,r.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:r.pattern.toString(),inst:t,continue:!r.abort})}}),e4=eo("$ZodCheckLowerCase",(t,r)=>{r.pattern??(r.pattern=eH),e1.init(t,r)}),e3=eo("$ZodCheckUpperCase",(t,r)=>{r.pattern??(r.pattern=eU),e1.init(t,r)}),e5=eo("$ZodCheckIncludes",(t,r)=>{eq.init(t,r);let n=R(r.includes),i=new RegExp("number"==typeof r.position?`^.{${r.position},}${n}`:n);r.pattern=i,t._zod.check=n=>{n.value.includes(r.includes,r.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:r.includes,input:n.value,inst:t,continue:!r.abort})}}),e6=eo("$ZodCheckStartsWith",(t,r)=>{eq.init(t,r);let n=RegExp(`^${R(r.prefix)}.*`);r.pattern??(r.pattern=n),t._zod.check=n=>{n.value.startsWith(r.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:r.prefix,input:n.value,inst:t,continue:!r.abort})}}),e8=eo("$ZodCheckEndsWith",(t,r)=>{eq.init(t,r);let n=RegExp(`.*${R(r.suffix)}$`);r.pattern??(r.pattern=n),t._zod.check=n=>{n.value.endsWith(r.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:r.suffix,input:n.value,inst:t,continue:!r.abort})}}),e9=eo("$ZodCheckOverwrite",(t,r)=>{eq.init(t,r),t._zod.check=t=>{t.value=r.tx(t.value)}});class e7{constructor(t=[],r={}){this.content=[],this.indent=0,this.args=t,this.closed=r}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if("function"==typeof t){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let r=t.split("\n").filter(t=>t),n=Math.min(...r.map(t=>t.length-t.trimStart().length));for(let t of r.map(t=>t.slice(n)).map(t=>" ".repeat(2*this.indent)+t))this.content.push(t)}compile(){let t=Function,r=this?.content??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
|
|
165
|
+
${r.join("\n")}
|
|
166
|
+
};`)(...Object.values(this.closed))}}let te={major:4,minor:6,patch:7},tt=eo("$ZodType",(t,r)=>{var n;t??(t={}),t._zod.def=r,t._zod.bag=t._zod.bag||{},t._zod.version=te;let i=t._zod.def.checks,a=t._zod.traits.has("$ZodCheck")?[t,...i??[]]:i?.length?[...i]:[];for(let r of a)for(let n of r._zod.onattach)n(t);if(0===a.length)(n=t._zod).deferred??(n.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{let r=(r,n,i)=>{let a;if(r.memo)return r;let s=U(r);for(let o of n){if(o._zod.def.when){if(function(t,r=0){if(!0===t.aborted)return!0;for(let n=r;n<t.issues.length;n++)if(t.issues[n]?.continue===!1)return!0;return!1}(r)||!o._zod.def.when(r))continue}else if(s)continue;let n=r.issues.length,l=o._zod.check(r);if(l instanceof Promise&&i?.async===!1)throw new el;if(a||l instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await l,r.issues.length!==n&&(G(r.issues,n,t),s||(s=U(r,n)))});else{if(r.issues.length===n)continue;G(r.issues,n,t),s||(s=U(r,n))}}return a?a.then(()=>r):r},n=(n,i,s)=>{if(U(n))return n.aborted=!0,n;let o=r(i,a,s);if(o instanceof Promise){if(!1===s.async)throw new el;return o.then(r=>t._zod.parse(r,s))}return t._zod.parse(o,s)};t._zod.run=(i,s)=>{if(s.skipChecks)return t._zod.parse(i,s);if("backward"===s.direction){let r=t._zod.parse({value:i.value,issues:[]},{...s,skipChecks:!0});return r instanceof Promise?r.then(t=>n(t,i,s)):n(r,i,s)}let o=t._zod.parse(i,s);if(o instanceof Promise){if(!1===s.async)throw new el;return o.then(t=>r(t,a,s))}return r(o,a,s)}}},{get"~standard"(){return ee(this,"~standard",ti(this),!1)},set"~standard"(value){ee(this,"~standard",value)}}),tr=(t,r)=>t.issues.length?{issues:t.issues.map(t=>Z(t,r,eu()))}:{value:t.value};async function tn(t,r){let n={async:!0};return tr(await t._zod.run({value:r,issues:[]},n),n)}function ti(t){return{validate:r=>{let n={async:!1};try{let i=t._zod.run({value:r,issues:[]},n);if(!(i instanceof Promise))return tr(i,n)}catch(t){}return tn(t,r)},vendor:"zod",version:1}}let ta=eo("$ZodString",(t,r)=>{tt.init(t,r),t._zod.pattern=r.pattern??ej,t._zod.parse=(n,i)=>{if(r.coerce)try{n.value=String(n.value)}catch(t){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:t}),n}}),ts=eo("$ZodStringFormat",(t,r)=>{e1.init(t,r),ta.init(t,r)}),to=eo("$ZodGUID",(t,r)=>{r.pattern??(r.pattern=eE),ts.init(t,r)}),tl=eo("$ZodUUID",(t,r)=>{if(r.version){let t={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[r.version];if(void 0===t)throw Error(`Invalid UUID version: "${r.version}"`);r.pattern??(r.pattern=eS(t))}else r.pattern??(r.pattern=eS());ts.init(t,r)}),tc=eo("$ZodEmail",(t,r)=>{r.pattern??(r.pattern=eC),ts.init(t,r)});function td(t){try{if("u">typeof URL&&"function"==typeof URL.canParse)return URL.canParse(t);return new URL(t),!0}catch{return!1}}let tu=/[\t\n\r]/g;function th(t){return t.replace(tu,"")}let tf=eo("$ZodURL",(t,r)=>{ts.init(t,r),t._zod.check=n=>{try{var i,a;let s=n.value.trim(),o="normalize"in r||"hostname"in r||"protocol"in r?function(t,r){if(!r.normalize&&r.protocol?.source===eD.source&&!/^https?:\/\//i.test(t))return 1;try{if("u">typeof URL){let r=URL;if("function"==typeof r.parse)return r.parse(t)??2}return new URL(t)}catch{return 2}}(s,r):td(s)||2;if(1===o)return void n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:t,continue:!r.abort});if(2===o)return void n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:t,continue:!r.abort});if(!0===o){n.value=th(s);return}r.hostname&&((i=r.hostname).lastIndex=0,!i.test(o.hostname))&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:r.hostname.source,input:n.value,inst:t,continue:!r.abort}),r.protocol&&((a=r.protocol).lastIndex=0,!a.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol))&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:r.protocol.source,input:n.value,inst:t,continue:!r.abort}),n.value=r.normalize?o.href:th(s);return}catch(i){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:t,continue:!r.abort})}}}),tp=eo("$ZodEmoji",(t,r)=>{r.pattern??(r.pattern=RegExp("^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$","u")),ts.init(t,r)}),tg=eo("$ZodNanoID",(t,r)=>{var n;if(void 0!==r.length&&(!Number.isInteger(r.length)||r.length<1))throw Error(`Invalid nanoid length: ${r.length}`);r.pattern??(r.pattern=void 0===r.length?e_:(n=r.length,RegExp(`^[a-zA-Z0-9_-]{${n}}$`))),ts.init(t,r)}),tm=eo("$ZodCUID",(t,r)=>{r.pattern??(r.pattern=ex),ts.init(t,r)}),ty=eo("$ZodCUID2",(t,r)=>{r.pattern??(r.pattern=ew),ts.init(t,r)}),tv=eo("$ZodULID",(t,r)=>{r.pattern??(r.pattern=e$),ts.init(t,r)}),tb=eo("$ZodXID",(t,r)=>{r.pattern??(r.pattern=ek),ts.init(t,r)}),tx=eo("$ZodKSUID",(t,r)=>{r.pattern??(r.pattern=eM),ts.init(t,r)}),tw=eo("$ZodISODateTime",(t,r)=>{let n,i,a;r.pattern??(n=["Z"],r.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)"),i=`${eP({precision:r.precision,seconds:!0})}(?:${n.join("|")})`,a=r.local?`${i}|${eP({precision:r.precision})}`:i,r.pattern=RegExp(`^${eL}T(?:${a})$`)),ts.init(t,r)}),t$=eo("$ZodISODate",(t,r)=>{r.pattern??(r.pattern=ez),ts.init(t,r)}),tk=eo("$ZodISOTime",(t,r)=>{r.pattern??(r.pattern=RegExp(`^${eP(r)}$`)),ts.init(t,r)}),tM=eo("$ZodISODuration",(t,r)=>{r.pattern??(r.pattern=eA),ts.init(t,r)}),t_=eo("$ZodIPv4",(t,r)=>{r.pattern??(r.pattern=eT),ts.init(t,r)}),tA=/^[0-9a-fA-F:.]+$/;function tE(t){return!!tA.test(t)&&td(`http://[${t}]`)}let tS=eo("$ZodIPv6",(t,r)=>{r.pattern??(r.pattern=eI),ts.init(t,r),t._zod.check=n=>{tE(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:t,continue:!r.abort})}}),tC=eo("$ZodCIDRv4",(t,r)=>{r.pattern??(r.pattern=eN),ts.init(t,r)}),tT=eo("$ZodCIDRv6",(t,r)=>{r.pattern??(r.pattern=eO),ts.init(t,r),t._zod.check=n=>{!function(t){let r=t.split("/");if(2!==r.length)return!1;let[n,i]=r;if(!i)return!1;let a=Number(i);return`${a}`===i&&!(a<0)&&!(a>128)&&tE(n)}(n.value)&&n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:t,continue:!r.abort})}});function tI(t){if(""===t)return!0;if(/\s/.test(t)||t.length%4!=0)return!1;try{return atob(t),!0}catch{return!1}}let tN=/^[0-9a-zA-Z+/]*={0,2}$/,tO=eo("$ZodBase64",(t,r)=>{r.pattern??(r.pattern=tN),ts.init(t,r),t._zod.check=n=>{tI(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:t,continue:!r.abort})}}),tD=/^[A-Za-z0-9_-]*$/,tR=eo("$ZodBase64URL",(t,r)=>{r.pattern??(r.pattern=tD),ts.init(t,r),t._zod.check=n=>{!function(t){if(!tD.test(t))return!1;let r=t.replace(/[-_]/g,t=>"-"===t?"+":"/");return tI(r.padEnd(4*Math.ceil(r.length/4),"="))}(n.value)&&n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:t,continue:!r.abort})}}),tL=eo("$ZodE164",(t,r)=>{r.pattern??(r.pattern=eR),ts.init(t,r)}),tz=eo("$ZodJWT",(t,r)=>{ts.init(t,r),t._zod.check=n=>{!function(t,r=null){try{let n=t.split(".");if(3!==n.length)return!1;let[i]=n;if(!i)return!1;let a=JSON.parse(atob(i));if("typ"in a&&a?.typ!=="JWT"||!a.alg||r&&(!("alg"in a)||a.alg!==r))return!1;return!0}catch{return!1}}(n.value,r.alg)&&n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:t,continue:!r.abort})}}),tP=eo("$ZodNumber",(t,r)=>{tt.init(t,r),t._zod.pattern=eB,t._zod.parse=(n,i)=>{if(r.coerce)try{n.value=Number(n.value)}catch(t){}let a=n.value;if("number"==typeof a&&!Number.isNaN(a)&&Number.isFinite(a))return n;let s="number"==typeof a?Number.isNaN(a)?"NaN":Number.isFinite(a)?void 0:String(a):void 0;return n.issues.push({expected:"number",code:"invalid_type",input:a,inst:t,...s?{received:s}:{}}),n}}),tj=eo("$ZodNumberFormat",(t,r)=>{eK.init(t,r),tP.init(t,r)}),tF=eo("$ZodBoolean",(t,r)=>{tt.init(t,r),t._zod.pattern=eW,t._zod.parse=(n,i)=>{if(r.coerce)try{n.value=!!n.value}catch(t){}let a=n.value;return"boolean"==typeof a||n.issues.push({expected:"boolean",code:"invalid_type",input:a,inst:t}),n}}),tB=eo("$ZodUnknown",(t,r)=>{tt.init(t,r),t._zod.parse=t=>t}),tW=eo("$ZodNever",(t,r)=>{tt.init(t,r),t._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:t}),r)}),tH=t=>Array.isArray(t)?t.length:-1;function tU(t,r,n){t.issues.length&&r.issues.push(...q(n,t.issues)),r.value[n]=t.value}let tq=eo("$ZodArray",(t,r)=>{tt.init(t,r);let n=ed.memoizer;n?.attach(t),t._zod.parse=(i,a)=>{let s=i.value;if(!Array.isArray(s))return i.issues.push({expected:"array",code:"invalid_type",input:s,inst:t}),i;i.value=n?n.alloc(t,i,Array(s.length),a):Array(s.length);let o=[],l=a?.abortEarly;for(let t=0;t<s.length;t++){let n=s[t],c=r.element._zod.run({value:n,issues:[]},a);if(c instanceof Promise)o.push(c.then(r=>tU(r,i,t)));else if(tU(c,i,t),l&&0!==c.issues.length&&U(c))break}return o.length?Promise.all(o).then(()=>i):i},function(t,r){let n=Y(t._zod.def.checks);if(!n.length)return;let i=Math.min(...n.map(t=>t[0])),a=t._zod.parse;t._zod.parse=(n,s)=>{let o=r(n.value);if(o>i&&!s?.skipChecks&&s?.direction!=="backward"){for(let[r,i]of Y(t._zod.def.checks))if(o>r&&i._zod.def.when(n)){let r=n.issues.length;return i._zod.check(n),n.issues[r].continue=!1,G(n.issues,r,t),n}}return a(n,s)}}(t,tH)});function tV(t,r,n,i,a,s){let o=n in i,l="optional"===s;if(o||!l||"optional"!==a){if(t.issues.length){if(void 0!==a&&l&&!o)return;r.issues.push(...q(n,t.issues))}if(!o&&void 0===a){t.issues.length||r.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}void 0===t.value?(o||"defaulted"===a&&!l)&&(r.value[n]=void 0):r.value[n]=t.value}}let tY=[];function tG(t){var r;let n=Object.keys(t.shape),i=Object.getOwnPropertySymbols(t.shape),a=i.length?i:tY,s=a.length?[...n,...a]:n;for(let r of s)if(!t.shape?.[r]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(r)}": expected a Zod schema`);let o=Object.keys(r=t.shape).filter(t=>void 0!==r[t]._zod.optin&&"optional"===r[t]._zod.optout);return{...t,allKeys:s,symbolKeys:a,keySet:new Set(n),numKeys:n.length,optionalKeys:new Set(o)}}function tZ(t,r,n,i,a,s,o){let l=[],c=a.keySet,d=a.catchall._zod,u=d.def.type,h=d.optin,f=d.optout,p=0;for(let a in r){if(o&&n.issues.length!==p){if(U(n,p))break;p=n.issues.length}if(c.has(a))continue;if("__proto__"===a){"never"===u&&l.push(a);continue}if("never"===u){l.push(a);continue}let s=d.run({value:r[a],issues:[]},i);s instanceof Promise?t.push(s.then(t=>tV(t,n,a,r,h,f))):tV(s,n,a,r,h,f)}return(l.length&&n.issues.push({code:"unrecognized_keys",keys:l,input:r,inst:s,continue:!0}),t.length)?Promise.all(t).then(()=>n):n}let tX=eo("$ZodObject",(t,r)=>{let n;tt.init(t,r);let i=Object.getOwnPropertyDescriptor(r,"shape"),a=i?.get?i.get.raw:r.shape??{};if(a){let t=()=>{let n={...a};return Object.defineProperty(r,"shape",{value:n}),t.raw=n,n};t.raw=a,Object.defineProperty(r,"shape",{get:t})}let s=x(()=>tG(r));ei(t,"propValues",t=>{let r=t.def.shape,n={};for(let t in r){let i=r[t]._zod;if(i.values){for(let r of(Object.prototype.hasOwnProperty.call(n,t)||$(n,t,new Set),i.values))n[t].add(r);void 0!==i.optin&&n[t].add(void 0)}}return n});let o=r.catchall,l=ed.memoizer;l?.attach(t),t._zod.parse=(r,i)=>{n??(n=s.value);let a=r.value;if(!T(a))return r.issues.push({expected:"object",code:"invalid_type",input:a,inst:t}),r;r.value=l?l.alloc(t,r,{},i):{};let c=[],d=n.shape,u=i?.abortEarly,h=r.issues.length;for(let t of n.allKeys){if(u&&r.issues.length!==h){if(U(r,h))break;h=r.issues.length}if("__proto__"===t)continue;let n=d[t],s=n._zod.optin,o=n._zod.optout,l=n._zod.run({value:a[t],issues:[]},i);l instanceof Promise?c.push(l.then(n=>tV(n,r,t,a,s,o))):tV(l,r,t,a,s,o)}return o?tZ(c,a,r,i,s.value,t,!0===u):c.length?Promise.all(c).then(()=>r):r}}),tK=eo("$ZodObjectJIT",(t,r)=>{let n,i;tX.init(t,r);let a=t._zod.parse,s=x(()=>tG(r)),o=ed.memoizer,l=!ed.jitless,c=l&&I.value,d=r.catchall;t._zod.parse=(u,h)=>{i??(i=s.value);let f=u.value;return T(f)?l&&c&&h?.async===!1&&!0!==h.jitless?(n||(n=(r=>{let n=s.value,i=n.symbolKeys,a=new e7(["payload","ctx"],{shape:r,inst:t,memo:o,syms:i}),l=t=>`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`,c=(t,r)=>`
|
|
167
|
+
let ${t}_ab = false;
|
|
168
|
+
for (let i = 0; i < ${t}.issues.length; i++) {
|
|
169
|
+
const iss = ${t}.issues[i];
|
|
170
|
+
iss.path = iss.path ? [${r}, ...iss.path] : [${r}];
|
|
171
|
+
payload.issues.push(iss);
|
|
172
|
+
if (iss.continue !== true) ${t}_ab = true;
|
|
173
|
+
}
|
|
174
|
+
if (${t}_ab && ctx && ctx.abortEarly) {
|
|
175
|
+
payload.value = newResult;
|
|
176
|
+
return payload;
|
|
177
|
+
}`;a.write("const input = payload.value;");let d=Object.create(null),u=0;for(let t of n.allKeys)d[t]=`key_${u++}`;for(let t of(a.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};"),n.allKeys)){if("__proto__"===t)continue;let n=d[t],s="symbol"==typeof t?`syms[${i.indexOf(t)}]`:JSON.stringify(t),o=`${s} in input`,u=r[t],h=u?._zod?.optin,f=void 0!==h,p=u?._zod?.optout==="optional";if(a.write(`const ${n} = ${l(s)};`),f&&p){let t="optional"===h?`${n}_present`:`${n}.value !== undefined || ${n}_present`;a.write(`
|
|
178
|
+
const ${n}_present = ${o};
|
|
179
|
+
if (!${n}.issues.length || ${n}_present) {
|
|
180
|
+
if (${n}.issues.length) {${c(n,s)}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (${t}) {
|
|
184
|
+
newResult[${s}] = ${n}.value;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
`)}else f?(a.write(`
|
|
189
|
+
if (${n}.issues.length) {${c(n,s)}
|
|
190
|
+
}
|
|
191
|
+
`),"defaulted"===h?a.write(`newResult[${s}] = ${n}.value;`):a.write(`
|
|
192
|
+
if (${n}.value !== undefined || ${o}) {
|
|
193
|
+
newResult[${s}] = ${n}.value;
|
|
194
|
+
}
|
|
195
|
+
`)):a.write(`
|
|
196
|
+
const ${n}_present = ${o};
|
|
197
|
+
if (${n}.issues.length) {${c(n,s)}
|
|
198
|
+
}
|
|
199
|
+
if (!${n}_present && !${n}.issues.length) {
|
|
200
|
+
payload.issues.push({
|
|
201
|
+
code: "invalid_type",
|
|
202
|
+
expected: "nonoptional",
|
|
203
|
+
input: undefined,
|
|
204
|
+
path: [${s}]
|
|
205
|
+
});
|
|
206
|
+
if (ctx && ctx.abortEarly) {
|
|
207
|
+
payload.value = newResult;
|
|
208
|
+
return payload;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (${n}_present) {
|
|
213
|
+
newResult[${s}] = ${n}.value;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
`)}return a.write("payload.value = newResult;"),a.write("return payload;"),a.compile()})(r.shape)),u=n(u,h),d)?tZ([],f,u,h,i,t,h?.abortEarly===!0):u:a(u,h):(u.issues.push({expected:"object",code:"invalid_type",input:f,inst:t}),u)}});function tJ(t,r,n,i){for(let n of t)if(0===n.issues.length)return r.value=n.value,r;let a=t.filter(t=>!U(t));return 1===a.length?(r.value=a[0].value,a[0]):(r.issues.push({code:"invalid_union",input:r.value,inst:n,errors:t.map(t=>t.issues.map(t=>Z(t,i,eu())))}),r)}let tQ=eo("$ZodUnion",(t,r)=>{tt.init(t,r),ei(t,"optin",t=>t.def.options.some(t=>"defaulted"===t._zod.optin)?"defaulted":t.def.options.some(t=>void 0!==t._zod.optin)?"optional":void 0),ei(t,"optout",t=>t.def.options.some(t=>"optional"===t._zod.optout)?"optional":void 0),ei(t,"values",t=>{if(t.def.options.every(t=>t._zod.values))return new Set(t.def.options.flatMap(t=>Array.from(t._zod.values)))}),ei(t,"pattern",t=>{if(t.def.options.every(t=>t._zod.pattern)){let r=t.def.options.map(t=>t._zod.pattern);return RegExp(`^(${r.map(t=>w(t.source)).join("|")})$`)}});let n=1===r.options.length?r.options[0]._zod.run:null;t._zod.parse=(i,a)=>{if(n)return n(i,a);let s=!1,o=[];for(let t of r.options){let r=t._zod.run({value:i.value,issues:[]},a);if(r instanceof Promise)o.push(r),s=!0;else{if(0===r.issues.length)return r;o.push(r)}}return s?Promise.all(o).then(r=>tJ(r,i,t,a)):tJ(o,i,t,a)}}),t0=eo("$ZodDiscriminatedUnion",(t,r)=>{r.inclusive=!1,tQ.init(t,r);let n=t._zod.parse;ei(t,"propValues",t=>{let r={},n=0;for(let i of t.def.options){let a=i._zod.propValues;if(!a||0===Object.keys(a).length)throw Error(`Invalid discriminated union option at index "${t.def.options.indexOf(i)}"`);for(let[i,s]of(a[t.def.discriminator]?.has(void 0)&&n++,Object.entries(a)))for(let t of(Object.prototype.hasOwnProperty.call(r,i)||$(r,i,new Set),s))r[i].add(t)}return!t.def.unionFallback&&n>1&&r[t.def.discriminator]?.delete(void 0),r}),r.options.forEach((t,n)=>{let i=k(t._zod.def);if(i&&!Object.prototype.hasOwnProperty.call(i,r.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let i=x(()=>(function(t){let r=new Map;for(let n of t.options){let i=n._zod.propValues?.[t.discriminator];if(!i||0===i.size)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let t of i)if(r.has(t)){if(void 0!==t)throw Error(`Duplicate discriminator value "${String(t)}"`);r.set(t,null)}else r.set(t,n)}return r})(r));t._zod.parse=(a,s)=>{let o=a.value;if(!T(o))return a.issues.push({code:"invalid_type",expected:"object",input:o,inst:t}),a;let l=o?.[r.discriminator],c=i.value.get(l);return c&&(void 0!==l||"backward"!==s.direction)?c._zod.run(a,s):r.unionFallback||"backward"===s.direction?n(a,s):(a.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:r.discriminator,options:Array.from(i.value.keys()).filter(t=>null!==i.value.get(t)),input:o,path:[r.discriminator],inst:t}),a)}}),t1=eo("$ZodIntersection",(t,r)=>{tt.init(t,r),t._zod.parse=(t,n)=>{let i=t.value,a=r.left._zod.run({value:i,issues:[]},n),s=r.right._zod.run({value:i,issues:[]},n);return a instanceof Promise||s instanceof Promise?Promise.all([a,s]).then(([r,n])=>t2(t,r,n)):t2(t,a,s)}});function t2(t,r,n){let i,a=new Map,s=new Map,o=(t,r)=>{let n;if("unrecognized_keys"!==t.code||t.path?.length)if("invalid_key"!==t.code||"record"!==t.origin||t.path?.length!==1)return!1;else{let r=String(t.path[0]);s.has(r)||s.set(r,t),n=[r]}else i??(i=t),n=t.keys;for(let t of n)a.has(t)||a.set(t,{}),a.get(t)[r]=!0;return!0};for(let n of r.issues)o(n,"l")||t.issues.push(n);for(let r of n.issues)o(r,"r")||t.issues.push(r);let l=[...a].filter(([,t])=>t.l&&t.r).map(([t])=>t);if(l.length){let r=i?l.filter(t=>i.keys.includes(t)):[];for(let n of(r.length&&t.issues.push({...i,keys:r}),l))!r.includes(n)&&s.has(n)&&t.issues.push(s.get(n))}let c=function t(r,n){if(r===n||r instanceof Date&&n instanceof Date&&+r==+n)return{valid:!0,data:r};if(N(r)&&N(n)){let i=Object.keys(n),a=Object.keys(r).filter(t=>-1!==i.indexOf(t)),s={...r,...n};for(let i of(Object.prototype.hasOwnProperty.call(s,"__proto__")&&delete s.__proto__,a)){if("__proto__"===i)continue;let a=t(r[i],n[i]);if(!a.valid)return{valid:!1,mergeErrorPath:[i,...a.mergeErrorPath]};s[i]=a.data}return{valid:!0,data:s}}if(Array.isArray(r)&&Array.isArray(n)){if(r.length!==n.length)return{valid:!1,mergeErrorPath:[]};let i=[];for(let a=0;a<r.length;a++){let s=t(r[a],n[a]);if(!s.valid)return{valid:!1,mergeErrorPath:[a,...s.mergeErrorPath]};i.push(s.data)}return{valid:!0,data:i}}return{valid:!1,mergeErrorPath:[]}}(r.value,n.value);if(!c.valid){if(U(t))return t;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return t.value=c.data,t}let t4=eo("$ZodRecord",(t,r)=>{tt.init(t,r);let n=ed.memoizer;n?.attach(t),t._zod.parse=(i,a)=>{let s=i.value;if(!N(s))return i.issues.push({expected:"record",code:"invalid_type",input:s,inst:t}),i;let o=[],l=r.keyType._zod.values;if(l&&!r.partial){let c;i.value=n?n.alloc(t,i,{},a):{};let d=new Set;for(let n of l)if("string"==typeof n||"number"==typeof n||"symbol"==typeof n){if(d.add("number"==typeof n?n.toString():n),"__proto__"===n)continue;let l=r.keyType._zod.run({value:n,issues:[]},a);if(l instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(l.issues.length){i.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(t=>Z(t,a,eu())),input:n,path:[n],inst:t});continue}let c=l.value;if("__proto__"===c)continue;let u=r.valueType._zod.run({value:s[n],issues:[]},a);u instanceof Promise?o.push(u.then(t=>{t.issues.length&&i.issues.push(...q(n,t.issues)),i.value[c]=t.value})):(u.issues.length&&i.issues.push(...q(n,u.issues)),i.value[c]=u.value)}for(let t in s)if(!d.has(t))if("loose"===r.mode){if("__proto__"===t)continue;i.value[t]=s[t]}else(c=c??[]).push(t);c&&c.length>0&&i.issues.push({code:"unrecognized_keys",input:s,inst:t,keys:c,continue:!0})}else{let c;for(let d of(i.value=n?n.alloc(t,i,{},a):{},Reflect.ownKeys(s))){if("__proto__"===d||!Object.prototype.propertyIsEnumerable.call(s,d))continue;let n=r.keyType._zod.run({value:d,issues:[]},a);if(n instanceof Promise)throw Error("Async schemas not supported in object keys currently");if("string"==typeof d&&eB.test(d)&&n.issues.length){let t=r.keyType._zod.run({value:Number(d),issues:[]},a);if(t instanceof Promise)throw Error("Async schemas not supported in object keys currently");0===t.issues.length&&(n=t)}if(n.issues.length){"loose"===r.mode?i.value[d]=s[d]:l?(c=c??[]).push(d):i.issues.push({code:"invalid_key",origin:"record",issues:n.issues.map(t=>Z(t,a,eu())),input:d,path:[d],inst:t});continue}let u=n.value;if("__proto__"===u)continue;let h=r.valueType._zod.run({value:s[d],issues:[]},a);h instanceof Promise?o.push(h.then(t=>{t.issues.length&&i.issues.push(...q(d,t.issues)),i.value[u]=t.value})):(h.issues.length&&i.issues.push(...q(d,h.issues)),i.value[u]=h.value)}c&&c.length>0&&i.issues.push({code:"unrecognized_keys",input:s,inst:t,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>i):i}}),t3=eo("$ZodEnum",(t,r)=>{tt.init(t,r);let n=m(r.entries),i=new Set(n);t._zod.values=i,ei(t,"pattern",t=>{let r=m(t.def.entries).filter(t=>D.has(typeof t));return new RegExp(r.length?`^(${r.map(t=>R(t.toString())).join("|")})$`:"^[^\\s\\S]$")}),t._zod.parse=(r,a)=>{let s=r.value;return i.has(s)||r.issues.push({code:"invalid_value",values:n,input:s,inst:t}),r}}),t5=eo("$ZodLiteral",(t,r)=>{tt.init(t,r);let n=new Set(r.values);t._zod.values=n,ei(t,"pattern",t=>{let r=t.def.values;return new RegExp(r.length?`^(${r.map(t=>"string"==typeof t?R(t):t?R(t.toString()):String(t)).join("|")})$`:"^[^\\s\\S]$")}),t._zod.parse=(i,a)=>{let s=i.value;return n.has(s)||i.issues.push({code:"invalid_value",values:r.values,input:s,inst:t}),i}}),t6=eo("$ZodTransform",(t,r)=>{tt.init(t,r),t._zod.optin="optional",ed.memoizer?.guard(t),t._zod.parse=(n,i)=>{if("backward"===i.direction)throw new ec(t.constructor.name);let a=r.transform(n.value,n);if(i.async)return(a instanceof Promise?a:Promise.resolve(a)).then(t=>(n.value=t,n));if(a instanceof Promise)throw new el;return n.value=a,n}});function t8(t,r){return t.value=r.issues.length?void 0:r.value,t}let t9=eo("$ZodOptional",(t,r)=>{tt.init(t,r),ei(t,"optin",t=>"defaulted"===t.def.innerType._zod.optin?"defaulted":"optional"),t._zod.optout="optional",ei(t,"values",t=>{let r=t.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),ei(t,"pattern",t=>{let r=t.def.innerType._zod.pattern;return r?RegExp(`^(${w(r.source)})?$`):void 0}),t._zod.parse=(t,n)=>{if(void 0===t.value){if("defaulted"!==r.innerType._zod.optin)return t;let i=r.innerType._zod.run({value:t.value,issues:[]},n);return i instanceof Promise?i.then(r=>t8(t,r)):t8(t,i)}return r.innerType._zod.run(t,n)}}),t7=eo("$ZodExactOptional",(t,r)=>{t9.init(t,r),ei(t,"values",t=>t.def.innerType._zod.values),ei(t,"pattern",t=>t.def.innerType._zod.pattern),t._zod.parse=(t,n)=>r.innerType._zod.run(t,n)}),re=eo("$ZodNullable",(t,r)=>{tt.init(t,r),ei(t,"optin",t=>t.def.innerType._zod.optin),ei(t,"optout",t=>t.def.innerType._zod.optout),ei(t,"pattern",t=>{let r=t.def.innerType._zod.pattern;return r?RegExp(`^(${w(r.source)}|null)$`):void 0}),ei(t,"values",t=>t.def.innerType._zod.values?new Set([...t.def.innerType._zod.values,null]):void 0),t._zod.parse=(t,n)=>null===t.value?t:r.innerType._zod.run(t,n)}),rt=eo("$ZodDefault",(t,r)=>{tt.init(t,r),t._zod.optin="defaulted",ei(t,"values",t=>t.def.innerType._zod.values),t._zod.parse=(t,n)=>{if("backward"===n.direction)return r.innerType._zod.run(t,n);if(void 0===t.value)return t.value=r.defaultValue,t;let i=r.innerType._zod.run(t,n);return i instanceof Promise?i.then(t=>rr(t,r)):rr(i,r)}});function rr(t,r){return void 0===t.value&&(t.value=r.defaultValue),t}let rn=eo("$ZodPrefault",(t,r)=>{tt.init(t,r),t._zod.optin="defaulted",ei(t,"values",t=>t.def.innerType._zod.values),t._zod.parse=(t,n)=>("backward"===n.direction||void 0===t.value&&(t.value=r.defaultValue),r.innerType._zod.run(t,n))}),ri=eo("$ZodNonOptional",(t,r)=>{tt.init(t,r),ei(t,"values",t=>{let r=t.def.innerType._zod.values;return r?new Set([...r].filter(t=>void 0!==t)):void 0}),t._zod.parse=(n,i)=>{let a=r.innerType._zod.run(n,i);return a instanceof Promise?a.then(r=>ra(r,t)):ra(a,t)}});function ra(t,r){return t.issues.length||void 0!==t.value||t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:r}),t}function rs(t,r,n,i){return r.issues.length?t.value=n.catchValue({...r,value:t.value,error:{issues:r.issues.map(t=>Z(t,i,eu()))},input:t.value}):(t.value=r.value,r.memo&&(t.memo=!0)),t}let ro=eo("$ZodCatch",(t,r)=>{tt.init(t,r),ei(t,"optin",t=>"defaulted"===t.def.innerType._zod.optin?"defaulted":"optional"),ei(t,"optout",t=>t.def.innerType._zod.optout),ei(t,"values",t=>t.def.innerType._zod.values),t._zod.parse=(t,n)=>{if("backward"===n.direction)return r.innerType._zod.run(t,n);let i=r.innerType._zod.run({value:t.value,issues:[]},n);return i instanceof Promise?i.then(i=>rs(t,i,r,n)):rs(t,i,r,n)}}),rl=eo("$ZodPipe",(t,r)=>{tt.init(t,r),ei(t,"values",t=>t.def.in._zod.values),ei(t,"optin",t=>t.def.in._zod.optin),ei(t,"optout",t=>t.def.out._zod.optout),ei(t,"propValues",t=>t.def.in._zod.propValues),t._zod.parse=(t,n)=>{if("backward"===n.direction){let i=r.out._zod.run(t,n);return i instanceof Promise?i.then(t=>rc(t,r.in,n)):rc(i,r.in,n)}let i=r.in._zod.run(t,n);return i instanceof Promise?i.then(t=>rc(t,r.out,n)):rc(i,r.out,n)}});function rc(t,r,n){return t.issues.some(t=>"unrecognized_keys"!==t.code)?(t.aborted=!0,t):r._zod.run({value:t.value,issues:t.issues},n)}let rd=eo("$ZodReadonly",(t,r)=>{tt.init(t,r),ei(t,"propValues",t=>t.def.innerType._zod.propValues),ei(t,"values",t=>t.def.innerType._zod.values),ei(t,"optin",t=>t.def.innerType?._zod?.optin),ei(t,"optout",t=>t.def.innerType?._zod?.optout),t._zod.parse=(t,n)=>{if("backward"===n.direction)return r.innerType._zod.run(t,n);let i=r.innerType._zod.run(t,n);return i instanceof Promise?i.then(ru):ru(i)}});function ru(t){return t.memo||(t.value=Object.freeze(t.value)),t}let rh=eo("$ZodCustom",(t,r)=>{eq.init(t,r),tt.init(t,r),t._zod.parse=(t,r)=>t,t._zod.check=n=>{let i=n.value,a=r.fn(i);if(a instanceof Promise)return a.then(r=>rf(r,n,i,t));rf(a,n,i,t)}});function rf(t,r,n,i){if(!t){let t={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};i._zod.def.params&&(t.params=i._zod.def.params),r.issues.push(Q(t))}}(a=globalThis).__zod_globalRegistry??(a.__zod_globalRegistry=new class t{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let n=r[0];return this._map.set(t,n),n&&"object"==typeof n&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&"object"==typeof r&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let n={...this.get(r)??{}};delete n.id;let i={...n,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}});let rp=globalThis.__zod_globalRegistry;function rg(t){return t.checks&&(t.checks=[...t.checks]),t}function rm(t,r){return new eG({check:"less_than",...z(r),value:t,inclusive:!1})}function ry(t,r){return new eG({check:"less_than",...z(r),value:t,inclusive:!0})}function rv(t,r){return new eZ({check:"greater_than",...z(r),value:t,inclusive:!1})}function rb(t,r){return new eZ({check:"greater_than",...z(r),value:t,inclusive:!0})}function rx(t,r){return new eX({check:"multiple_of",...z(r),value:t})}function rw(t,r){return new eJ({check:"max_length",...z(r),maximum:t})}function r$(t,r){return new eQ({check:"min_length",...z(r),minimum:t})}function rk(t,r){return new e0({check:"length_equals",...z(r),length:t})}function rM(t){return new e9({check:"overwrite",tx:t})}function r_(t,...r){for(let n of r)for(let r of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,r)&&$(t,r,n[r]);return t}function rA(t){let r=t?.target??"draft-2020-12";return"draft-4"===r&&(r="draft-04"),"draft-7"===r&&(r="draft-07"),{processors:t.processors??{},metadataRegistry:t?.metadata??rp,target:r,unrepresentable:t?.unrepresentable??"throw",override:t?.override??(()=>{}),io:t?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:t?.cycles??"ref",reused:t?.reused??"inline",intersections:[],deferred:[],external:t?.external??void 0}}function rE(t,r,n,i,a){let s="function"==typeof r.unrepresentable?r.unrepresentable({zodSchema:t,path:i.path,message:a}):r.unrepresentable;if("any"===s)return!1;if(void 0===s||"throw"===s)throw Error(a);return Object.assign(n,s),!0}function rS(t,r,n={path:[],schemaPath:[]}){var i;let a=t._zod.def,s=r.seen.get(t);if(s)return s.count++,n.schemaPath.includes(t)&&(s.cycle=n.path),s.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};r.seen.set(t,o),r.sharedDefsExtractedFor=void 0,r.sharedEmitDoneFor=void 0;let l=t._zod.toJSONSchema?.();if(l)o.schema=l;else{let i={...n,schemaPath:[...n.schemaPath,t],path:n.path};if(t._zod.processJSONSchema)t._zod.processJSONSchema(r,o.schema,i);else{let n=o.schema,s=r.processors[a.type];if(!s)throw Error(`[toJSONSchema]: Non-representable type encountered: ${a.type}`);s(t,r,n,i)}let s=t._zod.parent;s&&(o.ref||(o.ref=s),rS(s,r,i),r.seen.get(s).isParent=!0)}let c=r.metadataRegistry.get(t);return c&&r_(o.schema,c),"input"===r.io&&function t(r,n){let i=n??{seen:new Set};if(i.seen.has(r))return!1;i.seen.add(r);let a=r._zod.def;if("transform"===a.type)return!0;if("array"===a.type)return t(a.element,i);if("set"===a.type)return t(a.valueType,i);if("lazy"===a.type)return t(a.getter(),i);if("promise"===a.type||"optional"===a.type||"nonoptional"===a.type||"nullable"===a.type||"readonly"===a.type||"default"===a.type||"prefault"===a.type||"catch"===a.type)return t(a.innerType,i);if("intersection"===a.type)return t(a.left,i)||t(a.right,i);if("record"===a.type||"map"===a.type)return t(a.keyType,i)||t(a.valueType,i);if("pipe"===a.type)return!!r._zod.traits.has("$ZodCodec")||t(a.in,i)||t(a.out,i);if("object"===a.type){for(let r in a.shape)if(t(a.shape[r],i))return!0;return!1}if("union"===a.type){for(let r of a.options)if(t(r,i))return!0;return!1}if("tuple"===a.type){for(let r of a.items)if(t(r,i))return!0;if(a.rest&&t(a.rest,i))return!0}return!1}(t)&&(delete o.schema.examples,delete o.schema.default),"input"===r.io&&"_prefault"in o.schema&&((i=o.schema).default??(i.default=o.schema._prefault)),delete o.schema._prefault,r.seen.get(t).schema}function rC(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}function rT(t,r){let n=t.seen.get(r);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");if(t.external&&t.sharedDefsExtractedFor===t.external)return;let i=new Map;for(let r of t.seen.entries()){let n=t.metadataRegistry.get(r[0])?.id;if(n){let t=i.get(n);if(t&&t!==r[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(n,r[0])}}let a=r=>{if(r[1].schema.$ref)return;let i=r[1],{ref:a,defId:s}=(r=>{let i="draft-2020-12"===t.target?"$defs":"definitions";if(t.external){let n=t.external.registry.get(r[0])?.id,a=t.external.uri??(t=>t);if(n)return{ref:a(n)};let s=r[1].defId??r[1].schema.id??`schema${t.counter++}`;return r[1].defId=s,{defId:s,ref:`${a("__shared")}#/${i}/${rC(s)}`}}let a=`#/${i}/`;if(r[1]===n&&!r[1].schema.id)return{ref:"#"};let s=r[1].schema.id??`__schema${t.counter++}`;return{defId:s,ref:a+rC(s)}})(r);i.def={...i.schema},s&&(i.defId=s);let o=i.schema;for(let t in o)delete o[t];o.$ref=a};if("throw"===t.cycles)for(let r of t.seen.entries()){let t=r[1];if(t.cycle)throw Error(`Cycle detected: #/${t.cycle?.join("/")}/<root>
|
|
217
|
+
|
|
218
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of t.seen.entries()){let i=n[1];if(r===n[0]){a(n);continue}if(t.external){let i=t.external.registry.get(n[0])?.id;if(r!==n[0]&&i){a(n);continue}}if(t.metadataRegistry.get(n[0])?.id||i.cycle){a(n);continue}i.count>1&&"ref"===t.reused&&a(n)}t.external&&(t.sharedDefsExtractedFor=t.external)}let rI=new Set(["type","properties","required","additionalProperties"]),rN=["oneOf","anyOf"];function rO(t){let r=t.additionalProperties;return void 0===r||!1===r||"object"!=typeof r||null===r?null:Object.keys(r).length?r:null}function rD(t){let r=[];for(let n of t){if("object"!=typeof n||"object"!==n.type)return null;for(let t in n)if(!rI.has(t))return null;r.push(n)}let n={},i=new Set;for(let t of r){for(let i in t.properties){if(Object.prototype.hasOwnProperty.call(n,i))continue;let t=[];for(let n of r){let r=n.properties?.[i]??rO(n);null!=r&&(t.some(t=>JSON.stringify(t)===JSON.stringify(r))||t.push(r))}$(n,i,1===t.length?t[0]:rD(t)??{allOf:t})}for(let r of t.required??[])i.add(r)}let a={type:"object",properties:n};if(i.size&&(a.required=[...i]),r.every(t=>!1===t.additionalProperties))a.additionalProperties=!1;else{let t=[];for(let n of r){let r=rO(n);r&&!t.some(t=>JSON.stringify(t)===JSON.stringify(r))&&t.push(r)}1===t.length?a.additionalProperties=t[0]:t.length>1&&(a.additionalProperties={allOf:t})}return a}function rR(t,r){let n=t.seen.get(r);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let i=r=>{let n=t.seen.get(r);if(null===n.ref)return;let a=n.def??n.schema,s={...a},o=n.ref;if(n.ref=null,o){i(o);let n=t.seen.get(o),l=n.schema;if(l.$ref&&("draft-07"===t.target||"draft-04"===t.target||"openapi-3.0"===t.target)?(a.allOf=a.allOf??[],a.allOf.push(l)):r_(a,l),r_(a,s),r._zod.parent===o)for(let t in a)"$ref"!==t&&"allOf"!==t&&(t in s||delete a[t]);if(l.$ref&&n.def)for(let t in a)"$ref"!==t&&"allOf"!==t&&t in n.def&&JSON.stringify(a[t])===JSON.stringify(n.def[t])&&delete a[t]}let l=r._zod.parent;if(l&&l!==o){i(l);let r=t.seen.get(l);if(r?.schema.$ref&&(a.$ref=r.schema.$ref,r.def))for(let t in a)"$ref"!==t&&"allOf"!==t&&t in r.def&&JSON.stringify(a[t])===JSON.stringify(r.def[t])&&delete a[t]}t.override({zodSchema:r,jsonSchema:a,path:n.path??[]})};if(!t.external||t.sharedEmitDoneFor!==t.external){for(let r of[...t.seen.entries()].reverse())i(r[0]);if("openapi-3.0"!==t.target)for(let r of t.seen.entries())!function t(r){let n=r.anyOf;if(!Array.isArray(n)||0===n.length||void 0!==r.type)return;let i=[];for(let r of n){if(!r||"object"!=typeof r)return;t(r);let n=Object.keys(r);if(1!==n.length||"type"!==n[0])return;let a=r.type;for(let t of Array.isArray(a)?a:[a]){if("string"!=typeof t)return;i.includes(t)||i.push(t)}}delete r.anyOf,r.type=1===i.length?i[0]:i}(r[1].def??r[1].schema);for(let r of t.deferred)r();if(t.intersections.length){let r=new Map;for(let n of t.seen.values())for(let t of[n.schema,n.def]){let n=t?.allOf;if(!Array.isArray(n))continue;let i=r.get(n);i?i.push(t):r.set(n,[t])}for(let n of t.intersections)for(let t of r.get(n)??[])!function(t){let r=t.allOf;if(!Array.isArray(r)||r.length<2)return;for(let r of rI)if(r in t)return;let n=r.filter(t=>rN.some(r=>Array.isArray(t[r]))),i=null;if(n.length){let t=n[0],a=rN.find(r=>Array.isArray(t[r]));if(1!==Object.keys(t).length)return;let s=r.filter(r=>r!==t),o=t[a].map(t=>rD([...s,t]));if(o.some(t=>!t))return;i={[a]:o}}else i=rD(r);i&&(delete t.allOf,r_(t,i))}(t)}}let a={};if("draft-2020-12"===t.target?a.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===t.target?a.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===t.target?a.$schema="http://json-schema.org/draft-04/schema#":t.target,t.external?.uri){let n=t.external.registry.get(r)?.id;if(!n)throw Error("Schema is missing an `id` property");a.$id=t.external.uri(n)}r_(a,n.defId?n.schema:n.def??n.schema);let s=t.metadataRegistry.get(r)?.id;void 0!==s&&a.id===s&&delete a.id;let o=t.external?.defs??{};if(!t.external||t.sharedEmitDoneFor!==t.external)for(let r of t.seen.entries()){let t=r[1];t.def&&t.defId&&(t.def.id===t.defId&&delete t.def.id,$(o,t.defId,t.def))}t.external&&(t.sharedEmitDoneFor=t.external),t.external||Object.keys(o).length>0&&("draft-2020-12"===t.target?a.$defs=o:a.definitions=o);try{let n=JSON.parse(JSON.stringify(a));return Object.defineProperty(n,"~standard",{value:{...r["~standard"],jsonSchema:{input:rL(r,"input",t.processors),output:rL(r,"output",t.processors)}},enumerable:!1,writable:!1}),n}catch(t){throw Error("Error converting schema to JSON.")}}let rL=(t,r,n={})=>i=>{let{libraryOptions:a,target:s}=i??{},o=rA({...a??{},target:s,io:r,processors:n});return rS(t,o),rT(o,t),rR(o,t)},rz=(t,r,n)=>{(void 0===t[r]||n>t[r])&&(t[r]=n)},rP=(t,r,n)=>{(void 0===t[r]||n<t[r])&&(t[r]=n)},rj=(t,r)=>{rz(t,"minimum",r),rP(t,"maximum",r)},rF=(t,r)=>{t.multipleOf??(t.multipleOf=[]),t.multipleOf.includes(r)||t.multipleOf.push(r)},rB=(t,r)=>{t.patterns??(t.patterns=new Set),t.patterns.add(r)},rW=(t,r)=>{t.mime=t.mime?t.mime.filter(t=>r.includes(t)):[...r]},rH=(t,r)=>{t.format=r,r.includes("int")&&(t.isInt=!0)},rU=(t,r)=>rz(t,"minimum",r.minimum),rq=(t,r)=>rP(t,"maximum",r.maximum),rV=t=>(r,n)=>{rH(r,n.format);let[i,a]=t[n.format];rz(r,"minimum",i),rP(r,"maximum",a)},rY={greater_than:(t,r)=>rz(t,r.inclusive?"minimum":"exclusiveMinimum",r.value),less_than:(t,r)=>rP(t,r.inclusive?"maximum":"exclusiveMaximum",r.value),multiple_of:(t,r)=>rF(t,r.value),number_format:rV(j),bigint_format:rV(F),min_length:rU,max_length:rq,length_equals:(t,r)=>rj(t,r.length),min_size:rU,max_size:rq,size_equals:(t,r)=>rj(t,r.size),string_format:(t,r)=>{rH(t,r.format),r.pattern&&rB(t,r.pattern),("base64"===r.format||"base64url"===r.format)&&(t.contentEncoding=r.format),(r.local||-1===r.precision)&&(t.laxFormat=!0)},mime_type:(t,r)=>rW(t,r.mime)};function rG(t){let r={},n=t._zod.def;for(let i of t._zod.traits.has("$ZodCheck")?[t,...n.checks??[]]:n.checks??[])rY[i._zod.def.check]?.(r,i._zod.def);let i=t._zod.bag;for(let t of(void 0!==i.minimum&&rz(r,"minimum",i.minimum),void 0!==i.exclusiveMinimum&&rz(r,"exclusiveMinimum",i.exclusiveMinimum),void 0!==i.maximum&&rP(r,"maximum",i.maximum),void 0!==i.exclusiveMaximum&&rP(r,"exclusiveMaximum",i.exclusiveMaximum),void 0!==i.multipleOf&&rF(r,i.multipleOf),void 0!==i.format&&(r.format??(r.format=i.format),i.format.includes("int")&&(r.isInt=!0)),i.mime&&rW(r,i.mime),i.patterns??[]))rB(r,t);return r}let rZ={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},rX=new Map([[tN,/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/],[tD,/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/]]),rK=t=>rX.get(t)??t;function rJ(t){let r=t._zod.def;return"pipe"===r.type&&r.in._zod.traits.has("$ZodTransform")?rJ(r.out):"catch"===r.type?rJ(r.innerType):t._zod.optin}let rQ=new WeakMap,r0=Symbol();function r1(t,r,n,i,a){let s=!1,o=JSON.stringify(t,(t,r)=>"bigint"!=typeof r?r:(s=!0,null));return s?(rE(r,n,i,a,"BigInt defaults cannot be represented in JSON Schema"),r0):JSON.parse(o)}let r2=(t,r,n,i)=>{let a=t._zod.def;rS(a.innerType,r,i),r.seen.get(t).ref=a.innerType},r4={get:function(){let t=this._zod;return t.message??(t.message=JSON.stringify(t.def,v,2)),t.message},set:function(t){this._zod.message=t},enumerable:!0,configurable:!0},r3={value:void 0,enumerable:!1},r5=new WeakSet([Object.prototype,Error.prototype]),r6=(t,r)=>{t.name="$ZodError",r3.value=r,Object.defineProperty(t,"issues",r3),r3.value=void 0,Object.defineProperty(t,"message",r4);let n=Object.getPrototypeOf(t);r5.has(n)||(r5.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let t=()=>this.message;return Object.defineProperty(this,"toString",{value:t,configurable:!0,writable:!0}),t},set(t){Object.defineProperty(this,"toString",{value:t,configurable:!0,writable:!0})}}))},r8=eo("$ZodError",r6);function r9(t,r){return{callee:r?.callee??t,Err:r?.Err}}eo("$ZodError",r6,void 0,{Parent:Error});let r7=t=>{let r=(n,i,a,s)=>{let o=a?{...a,async:!1}:{async:!1},l=n._zod.run({value:i,issues:[]},o);if(l instanceof Promise)throw new el;if(l.issues.length){let n=new(s?.Err??t)(l.issues.map(t=>Z(t,o,eu())));throw C(n,s?.callee??r),n}return l.value};return r},ne=t=>{let r=async(n,i,a,s)=>{let o=a?{...a,async:!0}:{async:!0},l=n._zod.run({value:i,issues:[]},o);if(l instanceof Promise&&(l=await l),l.issues.length){let n=new(s?.Err??t)(l.issues.map(t=>Z(t,o,eu())));throw C(n,s?.callee??r),n}return l.value};return r},nt=t=>(r,n,i)=>{let a=i?{...i,async:!1}:{async:!1},s=r._zod.run({value:n,issues:[]},a);if(s instanceof Promise)throw new el;return s.issues.length?nr(t,s.issues,a):{success:!0,data:s.value}};function nr(t,r,n){let i;return{success:!1,get error(){return i||(i=new t(r.map(t=>Z(t,n,eu()))),r=void 0,n=void 0),i},set error(e){i=e,r=void 0,n=void 0}}}let nn=t=>async(r,n,i)=>{let a=i?{...i,async:!0}:{async:!0},s=r._zod.run({value:n,issues:[]},a);return s instanceof Promise&&(s=await s),s.issues.length?nr(t,s.issues,a):{success:!0,data:s.value}},ni=Symbol.for("zod.compile.invalid"),na=Symbol.for("zod.compile.fallback"),ns=async(t,r,n)=>{let i=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},a=t._zod.run({value:r,issues:[]},i);return a instanceof Promise&&(a=await a),0===a.issues.length},no=new WeakSet([Object.prototype,Error.prototype]);function nl(t,r,n){Object.defineProperty(t,r,{configurable:!0,enumerable:!1,get(){let t=n(this);return Object.defineProperty(this,r,{value:t,configurable:!0,writable:!0}),t},set(t){Object.defineProperty(this,r,{value:t,configurable:!0,writable:!0})}})}let nc=eo("ZodError",(t,r)=>{r8.init(t,r),t.name="ZodError";let n=Object.getPrototypeOf(t);no.has(n)||(no.add(n),nl(n,"format",t=>r=>(function(t,r=t=>t.message){let n={_errors:[]},i=(t,a=[])=>{for(let s of t.issues)if("invalid_union"===s.code&&s.errors.length)s.errors.map(t=>i({issues:t},[...a,...s.path]));else if("invalid_key"===s.code)i({issues:s.issues},[...a,...s.path]);else if("invalid_element"===s.code)i({issues:s.issues},[...a,...s.path]);else{let t=[...a,...s.path];if(0===t.length)n._errors.push(r(s));else{let i=n,a=0;for(;a<t.length;){let n=t[a],o=a===t.length-1;if("_errors"===n){o&&i._errors.push(r(s)),a++;continue}Object.prototype.hasOwnProperty.call(i,n)||Object.defineProperty(i,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let l=i[n];o&&l._errors.push(r(s)),i=l,a++}}}};return i(t),n})(t,r)),nl(n,"flatten",t=>r=>(function(t,r=t=>t.message){let n={},i=[];for(let o of t.issues)if(o.path.length>0){var a,s;(a=o.path[0],s=()=>[],!Object.prototype.hasOwnProperty.call(n,a)&&("__proto__"===a?Object.defineProperty(n,a,{value:s(),writable:!0,enumerable:!0,configurable:!0}):n[a]=s()),n[a]).push(r(o))}else i.push(r(o));return{formErrors:i,fieldErrors:n}})(t,r)),nl(n,"addIssue",t=>r=>{t.issues.push(r),t.message=JSON.stringify(t.issues,v,2)}),nl(n,"addIssues",t=>r=>{t.issues.push(...r),t.message=JSON.stringify(t.issues,v,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return 0===this.issues.length}}))},void 0,{Parent:Error}),nd=r7(nc),nu=ne(nc),nh=nt(nc),nf=nn(nc),np=(l=r7(nc),c=(t,r,n,i)=>l(t,r,n?{...n,direction:"backward"}:{direction:"backward"},r9(c,i))),ng=(d=r7(nc),u=(t,r,n,i)=>d(t,r,n,r9(u,i))),nm=(h=ne(nc),f=async(t,r,n,i)=>{let a=n?{...n,direction:"backward"}:{direction:"backward"};return await h(t,r,a,r9(f,i))}),ny=(p=ne(nc),g=async(t,r,n,i)=>await p(t,r,n,r9(g,i))),nv=(t,r,n)=>{let i=n?{...n,direction:"backward"}:{direction:"backward"};return nt(nc)(t,r,i)},nb=(t,r,n)=>nt(nc)(t,r,n),nx=async(t,r,n)=>{let i=n?{...n,direction:"backward"}:{direction:"backward"};return nn(nc)(t,r,i)},nw=async(t,r,n)=>nn(nc)(t,r,n);function n$(){ed.memoizer||eu({memoizer:eb})}let nk=eo("ZodType",(t,r)=>(ed.localeError||eu({localeError:(()=>{let t={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"}},r={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"},n={nan:"NaN"};function i(t,r){return"number"!==t||"number"!=typeof r||Number.isFinite(r)?n[t]??t:String(r)}return n=>{switch(n.code){case"invalid_type":{let t=i(n.expected),r=i(function(t){let r=typeof t;switch(r){case"number":return Number.isNaN(t)?"nan":"number";case"object":if(null===t)return"null";if(Array.isArray(t))return"array";if(t&&Object.getPrototypeOf(t)!==Object.prototype&&"constructor"in t&&t.constructor)return t.constructor.name}return r}(n.input),n.input);return`Invalid input: expected ${t}, received ${r}`}case"invalid_value":if(1===n.values.length)return`Invalid input: expected ${P(n.values[0])}`;return`Invalid option: expected one of ${y(n.values,"|")}`;case"too_big":{let r=n.exact?"exactly ":n.inclusive?"<=":"<",i=t[n.origin]??null;if(i)return`Too big: expected ${n.origin??"value"} to have ${r}${n.maximum.toString()} ${i.unit??"elements"}`;return`Too big: expected ${n.origin??"value"} to be ${r}${n.maximum.toString()}`}case"too_small":{let r=n.exact?"exactly ":n.inclusive?">=":">",i=t[n.origin]??null;if(i)return`Too small: expected ${n.origin} to have ${r}${n.minimum.toString()} ${i.unit}`;return`Too small: expected ${n.origin} to be ${r}${n.minimum.toString()}`}case"invalid_format":if("starts_with"===n.format)return`Invalid string: must start with "${n.prefix}"`;if("ends_with"===n.format)return`Invalid string: must end with "${n.suffix}"`;if("includes"===n.format)return`Invalid string: must include "${n.includes}"`;if("regex"===n.format)return`Invalid string: must match pattern ${n.pattern}`;return`Invalid ${r[n.format]??n.format}`;case"not_multiple_of":return`Invalid number: must be a multiple of ${n.divisor}`;case"unrecognized_keys":return`Unrecognized key${n.keys.length>1?"s":""}: ${y(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":if(n.options&&Array.isArray(n.options)&&n.options.length>0){let t=n.options.map(t=>`'${t}'`).join(" | ");return`Invalid discriminator value. Expected ${t}`}if(!1===n.inclusive)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}})()}),tt.init(t,r),t.def=r,t.type=r.type,t),{check(...t){let r=this.def;return this.clone(S(r,{checks:[...r.checks??[],...t.map(t=>"function"==typeof t?{_zod:{check:t,def:{check:"custom"},onattach:[]}}:t)]}),{parent:!0})},with(...t){return this.check(...t)},clone(t,r){return L(this,t,r)},brand(){return this},register(t,r){return t.add(this,r),this},refine(t,r){return this.check(function(t,r={}){return new i_({type:"custom",check:"custom",fn:t,...z(r)})}(t,r))},superRefine(t,r){return this.check(function(t,r){var n;let i,a;return n=r=>(r.addIssue=t=>{"string"==typeof t?r.issues.push(Q(t,r.value,i._zod.def)):(t.fatal&&(t.continue=!1),t.code??(t.code="custom"),"input"in t||(t.input=r.value),t.inst??(t.inst=i),t.continue??(t.continue=!i._zod.def.abort),r.issues.push(Q(t)))},t(r.value,r)),(a=new eq({check:"custom",...z(r)}))._zod.check=n,i=a}(t,r))},overwrite(t){return this.check(rM(t))},optional(){return ip(this)},exactOptional(){var t;return t=this,new ig({type:"optional",innerType:t})},nullable(){return iy(this)},nullish(){return ip(iy(this))},nonoptional(t){var r;return r=this,new ix({type:"nonoptional",innerType:r,...z(t)})},array(){return n8(this)},or(t){return new ie({type:"union",options:[this,t],...z(void 0)})},and(t){var r;return r=this,new ii({type:"intersection",left:r,right:t})},transform(t){return ik(this,new iu({type:"transform",transform:t}))},default(t){var r,n;return r=this,n=t,new iv({type:"default",innerType:r,get defaultValue(){return"function"==typeof n?n():O(n)}})},prefault(t){var r,n;return r=this,n=t,new ib({type:"prefault",innerType:r,get defaultValue(){return"function"==typeof n?n():O(n)}})},catch(t){return function(t,r){let n;return new iw({type:"catch",innerType:t,catchValue:"function"==typeof r?r:((n=()=>r)["~constantCatch"]=!0,n)})}(this,t)},pipe(t){return ik(this,t)},readonly(){var t;return t=this,new iM({type:"readonly",innerType:t})},describe(t){let r=this.clone();return rp.add(r,{description:t}),r},meta(...t){if(0===t.length)return rp.get(this);let r=this.clone();return rp.add(r,t[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(t,...r){return 0===r.length?t(this):t(this,...r)},get"~standard"(){return ee(this,"~standard",{...ti(this),jsonSchema:{input:rL(this,"input"),output:rL(this,"output")}},!1)},set"~standard"(value){ee(this,"~standard",value)},parse:function t(r,n){return nd(this,r,n,{callee:t})},parseAsync:async function t(r,n){return await nu(this,r,n,{callee:t})},safeParse(t,r){return nh(this,t,r)},async safeParseAsync(t,r){return nf(this,t,r)},get spa(){return this?.safeParseAsync},set spa(value){ee(this,"spa",value)},validate(t,r){let n=this._zod.bag.validator;if(void 0!==n){if(n(t)!==ni)return!0;if(!0===n.definite&&void 0===r)return!1}return function(t,r,n){let i,a=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},s=t._zod.bag.fallbackRun;if(s?(a[na]=!0,i=s({value:r,issues:[]},a)):i=t._zod.run({value:r,issues:[]},a),i instanceof Promise)throw new el;return 0===i.issues.length}(this,t,r)},validateAsync(t,r){return ns(this,t,r)},encode:function t(r,n){return np(this,r,n,{callee:t})},decode:function t(r,n){return ng(this,r,n,{callee:t})},encodeAsync:async function t(r,n){return await nm(this,r,n,{callee:t})},decodeAsync:async function t(r,n){return await ny(this,r,n,{callee:t})},safeEncode(t,r){return nv(this,t,r)},safeDecode(t,r){return nb(this,t,r)},async safeEncodeAsync(t,r){return nx(this,t,r)},async safeDecodeAsync(t,r){return nw(this,t,r)},toJSONSchema(t){return((t,r={})=>n=>{let i=rA({...n,processors:r});return rS(t,i),rT(i,t),rR(i,t)})(this,{})(t)},get description(){return rp.get(this)?.description},get _def(){return this._zod.def}}),nM=eo("_ZodString",(t,r)=>{ta.init(t,r),nk.init(t,r),t._zod.processJSONSchema=(r,n,i)=>((t,r,n,i)=>{n.type="string";let{minimum:a,maximum:s,format:o,patterns:l,contentEncoding:c,laxFormat:d}=rG(t);if("number"==typeof a&&(n.minLength=a),"number"==typeof s&&(n.maxLength=s),o&&(n.format=rZ[o]??o,""===n.format&&delete n.format,("time"===o||d)&&delete n.format),c&&(n.contentEncoding=c),l&&l.size>0){let t=[...l].map(rK);1===t.length?n.pattern=t[0].source:t.length>1&&(n.allOf=[...t.map(t=>({..."draft-07"===r.target||"draft-04"===r.target||"openapi-3.0"===r.target?{type:"string"}:{},pattern:t.source}))])}})(t,r,n,0)},et({format:t=>rG(t).format??null,minLength:t=>rG(t).minimum??null,maxLength:t=>rG(t).maximum??null},{regex(...t){return this.check(function(t,r){return new e2({check:"string_format",format:"regex",...z(r),pattern:t})}(...t))},includes(...t){return this.check(function(t,r){return new e5({check:"string_format",format:"includes",...z(r),includes:t})}(...t))},startsWith(...t){return this.check(function(t,r){return new e6({check:"string_format",format:"starts_with",...z(r),prefix:t})}(...t))},endsWith(...t){return this.check(function(t,r){return new e8({check:"string_format",format:"ends_with",...z(r),suffix:t})}(...t))},min(...t){return this.check(r$(...t))},max(...t){return this.check(rw(...t))},length(...t){return this.check(rk(...t))},nonempty(...t){return this.check(r$(1,...t))},lowercase(t){return this.check(new e4({check:"string_format",format:"lowercase",...z(t)}))},uppercase(t){return this.check(new e3({check:"string_format",format:"uppercase",...z(t)}))},trim(){return this.check(rM(t=>t.trim()))},normalize(...t){return this.check(function(t){return rM(r=>r.normalize(t))}(...t))},toLowerCase(){return this.check(rM(t=>t.toLowerCase()))},toUpperCase(){return this.check(rM(t=>t.toUpperCase()))},slugify(){return this.check(rM(t=>t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")))}})),n_=eo("ZodString",(t,r)=>{ta.init(t,r),nM.init(t,r)},{email(t){return this.check(new nN({type:"string",format:"email",check:"string_format",abort:!1,...z(t)}))},url(t){return this.check(new nR({type:"string",format:"url",check:"string_format",abort:!1,...z(t)}))},jwt(t){return this.check(new nX({type:"string",format:"jwt",check:"string_format",abort:!1,...z(t)}))},emoji(t){return this.check(new nL({type:"string",format:"emoji",check:"string_format",abort:!1,...z(t)}))},guid(t){return this.check(new nO({type:"string",format:"guid",check:"string_format",abort:!1,...z(t)}))},uuid(t){return this.check(new nD({type:"string",format:"uuid",check:"string_format",abort:!1,...z(t)}))},uuidv4(t){return this.check(new nD({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...z(t)}))},uuidv6(t){return this.check(new nD({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...z(t)}))},uuidv7(t){return this.check(new nD({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...z(t)}))},nanoid(t){return this.check(new nz({type:"string",format:"nanoid",check:"string_format",abort:!1,...z(t)}))},cuid(t){return this.check(new nP({type:"string",format:"cuid",check:"string_format",abort:!1,...z(t)}))},cuid2(t){return this.check(new nj({type:"string",format:"cuid2",check:"string_format",abort:!1,...z(t)}))},ulid(t){return this.check(new nF({type:"string",format:"ulid",check:"string_format",abort:!1,...z(t)}))},base64(t){return this.check(new nY({type:"string",format:"base64",check:"string_format",abort:!1,...z(t)}))},base64url(t){return this.check(new nG({type:"string",format:"base64url",check:"string_format",abort:!1,...z(t)}))},xid(t){return this.check(new nB({type:"string",format:"xid",check:"string_format",abort:!1,...z(t)}))},ksuid(t){return this.check(new nW({type:"string",format:"ksuid",check:"string_format",abort:!1,...z(t)}))},ipv4(t){return this.check(new nH({type:"string",format:"ipv4",check:"string_format",abort:!1,...z(t)}))},ipv6(t){return this.check(new nU({type:"string",format:"ipv6",check:"string_format",abort:!1,...z(t)}))},cidrv4(t){return this.check(new nq({type:"string",format:"cidrv4",check:"string_format",abort:!1,...z(t)}))},cidrv6(t){return this.check(new nV({type:"string",format:"cidrv6",check:"string_format",abort:!1,...z(t)}))},e164(t){return this.check(new nZ({type:"string",format:"e164",check:"string_format",abort:!1,...z(t)}))},datetime(t){return this.check(new nS({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...z(t)}))},date(t){return this.check(new nC({type:"string",format:"date",check:"string_format",...z(t)}))},time(t){return this.check(new nT({type:"string",format:"time",check:"string_format",precision:null,...z(t)}))},duration(t){return this.check(new nI({type:"string",format:"duration",check:"string_format",...z(t)}))}});function nA(t){return new n_(rg({type:"string",...z(t)}))}let nE=eo("ZodStringFormat",(t,r)=>{ts.init(t,r),nM.init(t,r)}),nS=eo("ZodISODateTime",(t,r)=>{tw.init(t,r),nE.init(t,r)}),nC=eo("ZodISODate",(t,r)=>{t$.init(t,r),nE.init(t,r)}),nT=eo("ZodISOTime",(t,r)=>{tk.init(t,r),nE.init(t,r)}),nI=eo("ZodISODuration",(t,r)=>{tM.init(t,r),nE.init(t,r)}),nN=eo("ZodEmail",(t,r)=>{tc.init(t,r),nE.init(t,r)}),nO=eo("ZodGUID",(t,r)=>{to.init(t,r),nE.init(t,r)}),nD=eo("ZodUUID",(t,r)=>{tl.init(t,r),nE.init(t,r)}),nR=eo("ZodURL",(t,r)=>{tf.init(t,r),nE.init(t,r)}),nL=eo("ZodEmoji",(t,r)=>{tp.init(t,r),nE.init(t,r)}),nz=eo("ZodNanoID",(t,r)=>{tg.init(t,r),nE.init(t,r)}),nP=eo("ZodCUID",(t,r)=>{tm.init(t,r),nE.init(t,r)}),nj=eo("ZodCUID2",(t,r)=>{ty.init(t,r),nE.init(t,r)}),nF=eo("ZodULID",(t,r)=>{tv.init(t,r),nE.init(t,r)}),nB=eo("ZodXID",(t,r)=>{tb.init(t,r),nE.init(t,r)}),nW=eo("ZodKSUID",(t,r)=>{tx.init(t,r),nE.init(t,r)}),nH=eo("ZodIPv4",(t,r)=>{t_.init(t,r),nE.init(t,r)}),nU=eo("ZodIPv6",(t,r)=>{tS.init(t,r),nE.init(t,r)}),nq=eo("ZodCIDRv4",(t,r)=>{tC.init(t,r),nE.init(t,r)}),nV=eo("ZodCIDRv6",(t,r)=>{tT.init(t,r),nE.init(t,r)}),nY=eo("ZodBase64",(t,r)=>{tO.init(t,r),nE.init(t,r)}),nG=eo("ZodBase64URL",(t,r)=>{tR.init(t,r),nE.init(t,r)}),nZ=eo("ZodE164",(t,r)=>{tL.init(t,r),nE.init(t,r)}),nX=eo("ZodJWT",(t,r)=>{tz.init(t,r),nE.init(t,r)}),nK=eo("ZodNumber",(t,r)=>{tP.init(t,r),nk.init(t,r),t._zod.processJSONSchema=(r,n,i)=>((t,r,n,i)=>{let{minimum:a,maximum:s,multipleOf:o,exclusiveMaximum:l,exclusiveMinimum:c,isInt:d}=rG(t);n.type=d?"integer":"number";let u="number"==typeof c&&c>=(a??-1/0),h="number"==typeof l&&l<=(s??1/0),f="draft-04"===r.target||"openapi-3.0"===r.target;if(u?f?(n.minimum=c,n.exclusiveMinimum=!0):n.exclusiveMinimum=c:"number"==typeof a&&(n.minimum=a),h?f?(n.maximum=l,n.exclusiveMaximum=!0):n.exclusiveMaximum=l:"number"==typeof s&&(n.maximum=s),o){let a=new Set;for(let s of o)Number.isFinite(s)&&0!==s?a.add(Math.abs(s)):rE(t,r,n,i,`A multipleOf divisor of ${s} cannot be represented in JSON Schema`);let[s,...l]=a;void 0!==s&&(n.multipleOf=s),l.length&&(n.allOf=[...n.allOf??[],...l.map(t=>({multipleOf:t}))])}})(t,r,n,i),t.isFinite=!0},et({minValue:t=>{let{minimum:r,exclusiveMinimum:n}=rG(t);return Math.max(r??-1/0,n??-1/0)},maxValue:t=>{let{maximum:r,exclusiveMaximum:n}=rG(t);return Math.min(r??1/0,n??1/0)},isInt:t=>{let{isInt:r,multipleOf:n}=rG(t);return!!r||!!n?.some(Number.isSafeInteger)},format:t=>rG(t).format??null},{gt(t,r){return this.check(rv(t,r))},gte(t,r){return this.check(rb(t,r))},min(t,r){return this.check(rb(t,r))},lt(t,r){return this.check(rm(t,r))},lte(t,r){return this.check(ry(t,r))},max(t,r){return this.check(ry(t,r))},int(t){return this.check(n0(t))},safe(t){return this.check(n0(t))},positive(t){return this.check(rv(0,t))},nonnegative(t){return this.check(rb(0,t))},negative(t){return this.check(rm(0,t))},nonpositive(t){return this.check(ry(0,t))},multipleOf(t,r){return this.check(rx(t,r))},step(t,r){return this.check(rx(t,r))},finite(){return this}}));function nJ(t){return new nK(rg({type:"number",checks:[],...z(t)}))}let nQ=eo("ZodNumberFormat",(t,r)=>{tj.init(t,r),nK.init(t,r)});function n0(t){return new nQ({type:"number",check:"number_format",abort:!1,format:"safeint",...z(t)})}let n1=eo("ZodBoolean",(t,r)=>{tF.init(t,r),nk.init(t,r),t._zod.processJSONSchema=(t,r,n)=>{r.type="boolean"}});function n2(t){return new n1({type:"boolean",...z(t)})}let n4=eo("ZodUnknown",(t,r)=>{tB.init(t,r),nk.init(t,r),t._zod.processJSONSchema=(t,r,n)=>{}});function n3(){return new n4({type:"unknown"})}let n5=eo("ZodNever",(t,r)=>{tW.init(t,r),nk.init(t,r),t._zod.processJSONSchema=(t,r,n)=>{r.not={}}}),n6=eo("ZodArray",(t,r)=>{n$(),tq.init(t,r),nk.init(t,r),t._zod.processJSONSchema=(r,n,i)=>((t,r,n,i)=>{let a=t._zod.def,{minimum:s,maximum:o}=rG(t);"number"==typeof s&&(n.minItems=s),"number"==typeof o&&(n.maxItems=o),n.type="array",n.items=rS(a.element,r,{...i,path:[...i.path,"items"]})})(t,r,n,i),t.element=r.element},{min(t,r){return this.check(r$(t,r))},nonempty(t){return this.check(r$(1,t))},max(t,r){return this.check(rw(t,r))},length(t,r){return this.check(rk(t,r))},unwrap(){return this.element}});function n8(t,r){return new n6({type:"array",element:t,...z(r)})}let n9=eo("ZodObject",(t,r)=>{var n;let i,a;n$(),tK.init(t,r),nk.init(t,r),t._zod.processJSONSchema=(r,n,i)=>((t,r,n,i)=>{let a=t._zod.def,s=a.shape;if(Object.getOwnPropertySymbols(s).length&&rE(t,r,n,i,"Symbol keys cannot be represented in JSON Schema"))return;for(let t in n.type="object",n.properties={},s)$(n.properties,t,rS(s[t],r,{...i,path:[...i.path,"properties",t]}));let o=[];for(let t of Object.keys(s)){let n=a.shape[t];("input"===r.io?void 0===rJ(n):void 0===n._zod.optout)&&o.push(t)}o.length>0&&(n.required=o),a.catchall?._zod.def.type==="never"?n.additionalProperties=!1:a.catchall?a.catchall&&(n.additionalProperties=rS(a.catchall,r,{...i,path:[...i.path,"additionalProperties"]})):"output"===r.io&&(n.additionalProperties=!1)})(t,r,n,i),n="shape",(a=n in(i=Object.getPrototypeOf(t))?void 0:i)&&Object.defineProperty(a,n,{configurable:!0,get(){let t={configurable:!0,writable:!0,enumerable:!1,value:void 0};return Object.defineProperty(this,n,t),t.value=(t=>t._zod.def.shape)(this),Object.defineProperty(this,n,t),t.value},set(t){Object.defineProperty(this,n,{configurable:!0,writable:!0,enumerable:!1,value:t})}})},{keyof(){return il(Object.keys(this._zod.def.shape))},catchall(t){return this.clone(S(this._zod.def,{catchall:t}))},passthrough(){return this.clone(S(this._zod.def,{catchall:n3()}))},loose(){return this.clone(S(this._zod.def,{catchall:n3()}))},strict(){return this.clone(S(this._zod.def,{catchall:new n5({type:"never",...z(void 0)})}))},strip(){return this.clone(S(this._zod.def,{catchall:void 0}))},extend(t){if(!N(t))throw Error("Invalid input to extend: expected a plain object");let r=this._zod.def.checks;if(r&&r.length>0){let r=M(this);for(let n of Reflect.ownKeys(t))if(void 0!==Object.getOwnPropertyDescriptor(r,n))throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return L(this,S(this._zod.def,{shape:W(this,t)}))},safeExtend(t){if(!N(t))throw Error("Invalid input to safeExtend: expected a plain object");return L(this,S(this._zod.def,{shape:W(this,t)}))},merge(t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(this._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r={};return E(r,this,Reflect.ownKeys(M(this))),E(r,t,Reflect.ownKeys(M(t))),L(this,S(this._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))},pick(t){return function(t,r){let n=t._zod.def,i=n.checks;if(i&&i.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let a={};return E(a,t,B(t,r)),L(t,S(n,{shape:a,checks:[]}))}(this,t)},omit(t){return function(t,r){let n=t._zod.def,i=n.checks;if(i&&i.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let a=new Set(B(t,r)),s={};return E(s,t,Reflect.ownKeys(M(t)).filter(t=>!a.has(t))),L(t,S(n,{shape:s,checks:[]}))}(this,t)},partial(...t){return H(ih,this,t[0])},exactPartial(...t){return H(ig,this,t[0],"exactPartial")},required(...t){var r;let n,i;return n=(r=t[0])?new Set(B(this,r)):void 0,E(i={},this,Reflect.ownKeys(M(this)),(t,r)=>n&&!n.has(r)?t:new ix({type:"nonoptional",innerType:t})),L(this,S(this._zod.def,{shape:i}))}});function n7(t,r){return new n9({type:"object",shape:t??{},...z(r)})}let ie=eo("ZodUnion",(t,r)=>{tQ.init(t,r),nk.init(t,r),t._zod.processJSONSchema=(r,n,i)=>{let a,s,o;return s=!1===(a=t._zod.def).inclusive,o=a.options.map((t,n)=>rS(t,r,{...i,path:[...i.path,s?"oneOf":"anyOf",n]})),void(s?n.oneOf=o:n.anyOf=o)},t.options=r.options}),it=eo("ZodDiscriminatedUnion",(t,r)=>{ie.init(t,r),t0.init(t,r)});function ir(t,r,n){return new it({type:"union",options:r,discriminator:t,...z(n)})}let ii=eo("ZodIntersection",(t,r)=>{t1.init(t,r),nk.init(t,r),t._zod.processJSONSchema=(r,n,i)=>{let a,s,o,l,c;return s=rS((a=t._zod.def).left,r,{...i,path:[...i.path,"allOf",0]}),o=rS(a.right,r,{...i,path:[...i.path,"allOf",1]}),void(n.allOf=c=[...(l=t=>"allOf"in t&&1===Object.keys(t).length)(s)?s.allOf:[s],...l(o)?o.allOf:[o]],r.intersections.push(c))}}),ia=eo("ZodRecord",(t,r)=>{n$(),t4.init(t,r),nk.init(t,r),t._zod.processJSONSchema=(r,n,i)=>((t,r,n,i)=>{let a=t._zod.def;n.type="object";let s=a.keyType,o=rG(s).patterns;if("loose"===a.mode&&o&&o.size>0){let t=rS(a.valueType,r,{...i,path:[...i.path,"patternProperties","*"]});for(let r of(n.patternProperties={},o))$(n.patternProperties,rK(r).source,t)}else{if("draft-07"===r.target||"draft-2020-12"===r.target){n.propertyNames=rS(a.keyType,r,{...i,path:[...i.path,"propertyNames"]});let s=rQ.get(r);s||(s=[],rQ.set(r,s),r.deferred.push(()=>(function(t){let r=new Map;for(let n of t.seen.values())n.def&&!r.has(n.schema)&&r.set(n.schema,n);let n=new Map;for(let i of rQ.get(t)??[]){let a=t.seen.get(i),s=(a?.def??a?.schema)?.propertyNames;if(!s||!0===s||n.has(s))continue;let o=function t(r,n,i){if(n.$ref){if(i.has(n))return n;i.add(n);let a=r.get(n)?.def;if(!a)return n;let s=t(r,a,i);return s===a?n:s}for(let a of["anyOf","oneOf"]){let s=n[a];if(!Array.isArray(s))continue;let o=s.map(n=>t(r,n,i));o.some((t,r)=>t!==s[r])&&(n={...n,[a]:o})}let a=Array.isArray(n.type)?n.type:[n.type],s=!a.includes("string")&&a.some(t=>"number"===t||"integer"===t),o=n.enum??(void 0!==n.const?[n.const]:void 0);if(!s&&!o?.some(t=>"number"==typeof t))return n;let{minimum:l,maximum:c,exclusiveMinimum:d,exclusiveMaximum:u,multipleOf:h,format:f,id:p,...g}=n;return g.enum?g.enum=g.enum.map(t=>"number"==typeof t?String(t):t):"number"==typeof g.const&&(g.const=String(g.const)),s&&(g.type="string",o||(g.pattern=(a.includes("number")?eB:eF).source)),g}(r,s,new Set);o!==s&&n.set(s,o)}if(n.size)for(let r of t.seen.values())for(let t of[r.schema,r.def]){let r=t&&n.get(t.propertyNames);r&&(t.propertyNames=r)}})(r))),s.push(t)}n.additionalProperties=rS(a.valueType,r,{...i,path:[...i.path,"additionalProperties"]})}let l=s._zod.values,c="input"===r.io&&void 0!==rJ(a.valueType);if(l&&!a.partial&&!c){let t=[...l].filter(t=>"string"==typeof t||"number"==typeof t);t.length>0&&(n.required=t.map(String))}})(t,r,n,i),t.keyType=r.keyType,t.valueType=r.valueType});function is(t,r,n){return new ia(r&&r._zod?{type:"record",keyType:t,valueType:r,...z(n)}:{type:"record",keyType:nA(),valueType:t,...z(r)})}let io=eo("ZodEnum",(t,r)=>{t3.init(t,r),nk.init(t,r),t._zod.processJSONSchema=(r,n,i)=>((t,r,n,i)=>{let a=m(t._zod.def.entries);if(0===a.length){n.not={};return}a.every(t=>"number"==typeof t)&&(n.type="number"),a.every(t=>"string"==typeof t)&&(n.type="string"),n.enum=a})(t,0,n,0),t.enum=r.entries,t.options=[...t._zod.values];let n=new Set(Object.keys(r.entries));t.extract=(t,i)=>{let a={};for(let i of t)if(n.has(i))a[i]=r.entries[i];else throw Error(`Key ${i} not found in enum`);return new io({...r,checks:[],...z(i),entries:a})},t.exclude=(t,i)=>{let a={...r.entries};for(let r of t)if(n.has(r))delete a[r];else throw Error(`Key ${r} not found in enum`);return new io({...r,checks:[],...z(i),entries:a})}});function il(t,r){return new io({type:"enum",entries:Array.isArray(t)?Object.fromEntries(t.map(t=>[t,t])):t,...z(r)})}let ic=eo("ZodLiteral",(t,r)=>{t5.init(t,r),nk.init(t,r),t._zod.processJSONSchema=(r,n,i)=>((t,r,n,i)=>{let a=t._zod.def;if(0===a.values.length){n.not={};return}let s=[];for(let o of a.values)if(void 0===o){if(rE(t,r,n,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if("bigint"==typeof o){if(rE(t,r,n,i,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(o))}else s.push(o);if(0===s.length);else if(1===s.length){let t=s[0];n.type=null===t?"null":typeof t,"draft-04"===r.target||"openapi-3.0"===r.target?n.enum=[t]:n.const=t}else s.every(t=>"number"==typeof t)&&(n.type="number"),s.every(t=>"string"==typeof t)&&(n.type="string"),s.every(t=>"boolean"==typeof t)&&(n.type="boolean"),s.every(t=>null===t)&&(n.type="null"),n.enum=s})(t,r,n,i),t.values=new Set(r.values),Object.defineProperty(t,"value",{get(){if(r.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return r.values[0]}})});function id(t,r){return new ic({type:"literal",values:Array.isArray(t)?t:[t],...z(r)})}let iu=eo("ZodTransform",(t,r)=>{n$(),t6.init(t,r),nk.init(t,r),t._zod.processJSONSchema=(r,n,i)=>{rE(t,r,n,i,"Transforms cannot be represented in JSON Schema")},t._zod.parse=(n,i)=>{if("backward"===i.direction)throw new ec(t.constructor.name);n.addIssue=i=>{"string"==typeof i?n.issues.push(Q(i,n.value,r)):(i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=n.value),i.inst??(i.inst=t),n.issues.push(Q(i)))};let a=r.transform(n.value,n);return a instanceof Promise?a.then(t=>(n.value=t,n)):(n.value=a,n)}}),ih=eo("ZodOptional",(t,r)=>{t9.init(t,r),nk.init(t,r),t._zod.processJSONSchema=(r,n,i)=>r2(t,r,n,i),t.unwrap=()=>t._zod.def.innerType});function ip(t){return new ih({type:"optional",innerType:t})}let ig=eo("ZodExactOptional",(t,r)=>{t7.init(t,r),nk.init(t,r),t._zod.processJSONSchema=(r,n,i)=>r2(t,r,n,i),t.unwrap=()=>t._zod.def.innerType}),im=eo("ZodNullable",(t,r)=>{re.init(t,r),nk.init(t,r),t._zod.processJSONSchema=(r,n,i)=>{let a,s,o;return s=rS((a=t._zod.def).innerType,r,i),o=r.seen.get(t),void("openapi-3.0"===r.target?(o.ref=a.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}])},t.unwrap=()=>t._zod.def.innerType});function iy(t){return new im({type:"nullable",innerType:t})}let iv=eo("ZodDefault",(t,r)=>{rt.init(t,r),nk.init(t,r),t._zod.processJSONSchema=(r,n,i)=>{let a,s;return rS((a=t._zod.def).innerType,r,i),r.seen.get(t).ref=a.innerType,void((s=r1(a.defaultValue,t,r,n,i))!==r0&&(n.default=s))},t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap}),ib=eo("ZodPrefault",(t,r)=>{rn.init(t,r),nk.init(t,r),t._zod.processJSONSchema=(r,n,i)=>((t,r,n,i)=>{let a=t._zod.def;if(rS(a.innerType,r,i),r.seen.get(t).ref=a.innerType,"input"!==r.io)return;let s=r1(a.defaultValue,t,r,n,i);s!==r0&&(n._prefault=s)})(t,r,n,i),t.unwrap=()=>t._zod.def.innerType}),ix=eo("ZodNonOptional",(t,r)=>{ri.init(t,r),nk.init(t,r),t._zod.processJSONSchema=(r,n,i)=>{let a;rS((a=t._zod.def).innerType,r,i),r.seen.get(t).ref=a.innerType},t.unwrap=()=>t._zod.def.innerType}),iw=eo("ZodCatch",(t,r)=>{ro.init(t,r),nk.init(t,r),t._zod.processJSONSchema=(r,n,i)=>((t,r,n,i)=>{let a,s=t._zod.def;rS(s.innerType,r,i),r.seen.get(t).ref=s.innerType;try{a=s.catchValue(void 0)}catch{rE(t,r,n,i,"Dynamic catch values are not supported in JSON Schema");return}n.default=a})(t,r,n,i),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap}),i$=eo("ZodPipe",(t,r)=>{rl.init(t,r),nk.init(t,r),t._zod.processJSONSchema=(r,n,i)=>{let a,s,o;return s=(a=t._zod.def).in._zod.traits.has("$ZodTransform"),void(rS(o="input"===r.io?s?a.out:a.in:a.out,r,i),r.seen.get(t).ref=o)},t.in=r.in,t.out=r.out});function ik(t,r){return new i$({type:"pipe",in:t,out:r})}let iM=eo("ZodReadonly",(t,r)=>{rd.init(t,r),nk.init(t,r),t._zod.processJSONSchema=(r,n,i)=>{let a;rS((a=t._zod.def).innerType,r,i),r.seen.get(t).ref=a.innerType,n.readOnly=!0},t.unwrap=()=>t._zod.def.innerType}),i_=eo("ZodCustom",(t,r)=>{rh.init(t,r),nk.init(t,r),t._zod.processJSONSchema=(r,n,i)=>{rE(t,r,n,i,"Custom types cannot be represented in JSON Schema")}})},6444(t,r,n){n.d(r,{v:()=>o});var i=n(7014);let a=t=>{let r,n=new Set,i=(t,i)=>{let a="function"==typeof t?t(r):t;if(!Object.is(a,r)){let t=r;r=(null!=i?i:"object"!=typeof a||null===a)?a:Object.assign({},r,a),n.forEach(n=>n(r,t))}},a=()=>r,s={setState:i,getState:a,getInitialState:()=>o,subscribe:t=>(n.add(t),()=>n.delete(t))},o=r=t(i,a,s);return s},s=t=>{let r=t?a(t):a,n=t=>(function(t,r=t=>t){let n=i.useSyncExternalStore(t.subscribe,i.useCallback(()=>r(t.getState()),[t,r]),()=>r(t.getInitialState()));return i.useDebugValue(n),n})(r,t);return Object.assign(n,r),n},o=t=>t?s(t):s}}]);
|