ryugi-artifacts 1.103.0 → 1.103.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +5 -5
- package/dist/document-host.cjs +1 -1
- package/dist/runtime/deck/{embed-CcbYYWxd.js → embed-DRPOUKsk.js} +1 -1
- package/dist/runtime/deck/{open-yuM77vw2.js → open-CoGdPanV.js} +9 -0
- package/dist/runtime/ryugi-deck.js +33 -23
- package/dist/server.cjs +55 -55
- package/dist/viewer/{AgentStatusPill-CaCkr8on.js → AgentStatusPill-DAWtJa6j.js} +1 -1
- package/dist/viewer/{DaemonDock-DF-aTVNL.js → DaemonDock-DxvtHALU.js} +1 -1
- package/dist/viewer/{SlidesLayout-BKPSVM9Q.js → SlidesLayout-B1JTgUF3.js} +2 -2
- package/dist/viewer/WhiteboardLayout-BXSq3hNU.css +1 -0
- package/dist/viewer/WhiteboardLayout-Dnahdu0L.js +4 -0
- package/dist/viewer/index.js +2 -2
- package/dist/viewer/{titlePrefix-DGoOkYsx.js → titlePrefix-DBqLIMmC.js} +1 -1
- package/package.json +1 -1
- package/dist/viewer/WhiteboardLayout-B6E-yN7C.js +0 -4
package/dist/server.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),s=(e,n)=>{let r=Object.setPrototypeOf({},null);for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n&1||t(r,Symbol.toStringTag,{value:`Module`}),n&2?r:Object.preventExtensions(r)},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,o)=>(o=n==null?{}:e(i(n)),c(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));let u=require("node:child_process"),d=require("node:crypto");d=l(d,1);let f=require("node:fs");f=l(f,1);let p=require("node:os");p=l(p,1);let m=require("node:path");m=l(m,1);let h=require("node:net");h=l(h,1);let g=require("node:util"),_=require("node:http");_=l(_,1);let v=require("node:fs/promises");v=l(v,1);let y=require("node:async_hooks");var b=`1.103.
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),s=(e,n)=>{let r=Object.setPrototypeOf({},null);for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n&1||t(r,Symbol.toStringTag,{value:`Module`}),n&2?r:Object.preventExtensions(r)},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,o)=>(o=n==null?{}:e(i(n)),c(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));let u=require("node:child_process"),d=require("node:crypto");d=l(d,1);let f=require("node:fs");f=l(f,1);let p=require("node:os");p=l(p,1);let m=require("node:path");m=l(m,1);let h=require("node:net");h=l(h,1);let g=require("node:util"),_=require("node:http");_=l(_,1);let v=require("node:fs/promises");v=l(v,1);let y=require("node:async_hooks");var b=`1.103.2`;const x=e=>`Ryugi ${e} (${b})`,S=process.platform!==`win32`;function C(e,...t){S&&(process.title=[x(e),...t].join(` `))}const w=e=>S?[`--title=${x(e)}`]:[];function T(e=process.env,t=process.platform,n=process.getuid?.()??-1,r=p.default.tmpdir()){return e.RYUGI_RUNTIME_DIR?m.default.join(e.RYUGI_RUNTIME_DIR,`servers`):t===`win32`?m.default.join(r,`ryugi`,`servers`):`/tmp/ryugi-${n}/servers`}const E=/^[a-z][a-z0-9_-]{0,31}$/,D=/^(?!\.\.?$)(?!.*\.\.)[\w.:-]{1,128}$/;function O(e=process.env,t=process.platform){if(e.RYUGI_HUB_SOCKET)return e.RYUGI_HUB_SOCKET;let n=e.RYUGI_SERVER_HOME?m.default.resolve(e.RYUGI_SERVER_HOME):null,r=n&&n!==m.default.join(p.default.homedir(),`.ryugi`,`server`)?`-${(0,d.createHash)(`sha256`).update(n).digest(`hex`).slice(0,12)}`:``;return t===`win32`?`\\\\.\\pipe\\ryugi-hub-${p.default.userInfo().username}${r}`:m.default.join(m.default.dirname(T(e,t)),`hub${r}.sock`)}const k=e=>new Promise(t=>{let n=h.default.connect(e);n.once(`connect`,()=>{n.destroy(),t(!0)}),n.once(`error`,()=>t(!1))});async function A(e){if(process.platform===`win32`)return;let t=m.default.dirname(e);if(f.default.existsSync(t)||f.default.mkdirSync(t,{recursive:!0,mode:448}),f.default.existsSync(e)){if(await k(e))throw Error(`another hub owns the agent socket ${e}`);f.default.rmSync(e,{force:!0})}}async function j(e){await A(e.socketPath);let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Set,r=1,i=(e,t)=>{e.destroyed||e.write(`${JSON.stringify(t)}\n`)},a=h.default.createServer(a=>{n.add(a);let o=null,s=``,c=n=>{if(o)n.t===`delivered`?e.onDelivered(o,{id:n.id}):n.t===`unsubscribe`&&e.onUnsubscribe?.(o);else{if(n.t!==`hello`)return a.destroy();if(n.protocol!==1)return i(a,{t:`refuse`,reason:`version`}),a.end();let{host:s,session:c,agent:l,version:u}=n;if(typeof s!=`string`||!E.test(s)||typeof c!=`string`||!D.test(c)||typeof l!=`string`||!l)return i(a,{t:`refuse`,reason:`hello`}),a.end();for(let[e,n]of t)e.host===s&&e.session===c&&(t.delete(e),i(n,{t:`bye`,reason:`replaced`}),n.end());o={id:r++,host:s,session:c,agent:l,version:typeof u==`string`?u:``},t.set(o,a),i(a,{t:`welcome`,version:e.version}),e.onHello(o)}};a.on(`data`,e=>{if(s+=e.toString(`utf8`),s.length>1048576)return a.destroy();for(let e=s.indexOf(`
|
|
2
2
|
`);e>=0;e=s.indexOf(`
|
|
3
3
|
`)){let t=s.slice(0,e);s=s.slice(e+1);let n;try{n=JSON.parse(t)}catch{return a.destroy()}n&&typeof n==`object`&&c(n)}}),a.on(`error`,()=>a.destroy()),a.on(`close`,()=>{n.delete(a),o&&t.get(o)===a&&(t.delete(o),e.onClose(o))})});return await new Promise((t,n)=>{a.once(`error`,n),a.listen(e.socketPath,()=>{a.off(`error`,n),t()})}),process.platform!==`win32`&&f.default.chmodSync(e.socketPath,384),{connections:()=>[...t.keys()],send:(e,n)=>{let r=t.get(e);r&&i(r,n)},close:()=>new Promise(t=>{for(let e of n)e.destroy();a.close(()=>{process.platform!==`win32`&&f.default.rmSync(e.socketPath,{force:!0}),t()})})}}const M=[27319,27320,27321],N={html:`text/html; charset=utf-8`,js:`text/javascript; charset=utf-8`,mjs:`text/javascript; charset=utf-8`,css:`text/css; charset=utf-8`,json:`application/json; charset=utf-8`,xml:`application/xml; charset=utf-8`,txt:`text/plain; charset=utf-8`,svg:`image/svg+xml`,png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,avif:`image/avif`,ico:`image/x-icon`,woff:`font/woff`,woff2:`font/woff2`,ttf:`font/ttf`,otf:`font/otf`,mp4:`video/mp4`,webm:`video/webm`},P=N.json;function F(e){let t=e.slice(Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`))+1),n=t.lastIndexOf(`.`);return n>0&&N[t.slice(n+1).toLowerCase()]||`application/octet-stream`}const ee=()=>d.default.randomBytes(24).toString(`base64url`);function te(e,t){let n=Buffer.from(e),r=Buffer.from(t);return n.length===r.length&&d.default.timingSafeEqual(n,r)}function I(e){let t={};for(let n of(e??``).split(`;`)){let e=n.indexOf(`=`);e>0&&(t[n.slice(0,e).trim()]=n.slice(e+1).trim())}return t}function ne(e){try{return f.default.readFileSync(e,`utf8`).trim()}catch{return``}}function re(e,t,n){return new Promise((r,i)=>{let a=t=>{e.off(`listening`,o),i(t)},o=()=>{e.off(`error`,a),r(e.address().port)};e.once(`error`,a),e.once(`listening`,o),e.listen(n,t)})}const ie=e=>e.includes(`:`)&&!e.startsWith(`[`)?`[${e}]`:e;function ae(e,t,n,r={}){e.writeHead(t,{"Referrer-Policy":`no-referrer`,"Cache-Control":`no-store`,...r}),e.end(n)}function L(e,t,n){ae(e,t,JSON.stringify(n),{"Content-Type":P})}function oe(e,t){let n=e&&/^bytes=(\d*)-(\d*)$/.exec(e.trim());if(!n||!n[1]&&!n[2])return null;let r=n[1]?Number(n[1]):Math.max(0,t-Number(n[2])),i=n[1]&&n[2]?Math.min(Number(n[2]),t-1):t-1;return r>i||r>=t?`unsatisfiable`:{start:r,end:i}}function se(e,t,n={},r){f.default.stat(t,(i,a)=>{if(i||!a.isFile()){ae(e,404,`Not found`);return}let o={"Referrer-Policy":`no-referrer`,"Cache-Control":`no-store`,"Content-Type":F(t),"Accept-Ranges":`bytes`,...n},s=oe(r,a.size);s===`unsatisfiable`?(e.writeHead(416,{...o,"Content-Range":`bytes */${a.size}`}),e.end()):(s?e.writeHead(206,{...o,"Content-Range":`bytes ${s.start}-${s.end}/${a.size}`,"Content-Length":String(s.end-s.start+1)}):e.writeHead(200,{...o,"Content-Length":String(a.size)}),f.default.createReadStream(t,s??{}).on(`error`,()=>e.destroy()).pipe(e))})}const ce=[27329,27330,27331];function le(e,t){let n=t===`main`?e.RYUGI_ARTIFACTS_PORTS:e.RYUGI_ARTIFACTS_BOARD_PORTS,r=t===`main`?M:ce;if(!n)return r;let i=n.split(`,`).map(e=>Number(e.trim()));return i.length&&i.every(e=>Number.isInteger(e)&&e>=0&&e<65536)?i:r}async function ue(e,t,n){for(let r of n)try{return await re(e,t,r)}catch(e){if(e.code!==`EADDRINUSE`)throw e}throw Error(`Ports ${n.join(`, `)} are all in use; pick a free one with --port <n>`)}const de=e=>e===`127.0.0.1`||e===`localhost`||e===`::1`;function fe(e,t=[]){let n=e.ARTIFACTS_HOST||`127.0.0.1`,r=e.ARTIFACTS_URL_HOST||(de(n)?`localhost`:n),i=t.find(e=>e.startsWith(`--artifacts-server-id=`)),a=t.find(e=>e.startsWith(`--port=`)),o=a?Number(a.slice(7)):NaN;return{host:n,urlHost:r,ports:Number.isInteger(o)&&o>=0&&o<65536?[o]:le(e,`main`),boardPorts:le(e,`board`),openCmd:e.ARTIFACTS_OPEN_CMD||null,serverId:i?i.slice(22):null,cloudOrigin:(e.RYUGI_CLOUD_ORIGIN||`https://ryugi.innei.dev`).replace(/\/+$/,``)}}function pe(e,t){return e===`darwin`?{bin:`open`,args:[t]}:e===`win32`?{bin:`cmd`,args:[`/c`,`start`,`""`,t]}:e===`linux`||e===`freebsd`||e===`openbsd`?{bin:`xdg-open`,args:[t]}:null}const me=(0,g.promisify)(u.execFile),he=String.raw`
|
|
4
4
|
function run(urls) {
|
|
@@ -980,67 +980,67 @@ ${r}`,`syntax`,{type:e,...a})}var Cft=`amp:38,lt:60,gt:62,quot:34,apos:39,nbsp:1
|
|
|
980
980
|
`)}addSubGraph(e,t,n,r){let i=e?.text?.trim(),a=n?.text||``;e!==void 0&&e===n&&/\s/.test(a)&&(i=void 0);let o=/* @__PURE__ */ new Set,s=[],c;for(let e of t)if(typeof e==`string`)e.trim()!==``&&!o.has(e)&&(o.add(e),s.push(e));else if(Array.isArray(e))for(let t of e)t.trim()!==``&&!o.has(t)&&(o.add(t),s.push(t));else c=e.value;c??=this.options.inheritDir?this.direction??this.options.direction:void 0,i??=`subGraph`+this.subCount,this.subCount++;let l=this.members,u=s.filter(e=>e!==i&&!this.globalNodes.has(e)&&!l.has(e));for(let e of u)l.add(e);let d=this.subgraphLookup.get(i);if(d){for(let e of u)d.nodes.push(e);return a.trim()&&(d.title=a.trim()),c&&(d.dir=c),i}let f={id:i,nodes:u,title:a.trim(),classes:[],dir:c,labelType:Aq(n?.type),type:`flow`};return this.subgraphs.push(f),this.subgraphLookup.set(i,f),i}addGlobal(e){let t=!1,n=e=>{let n=e.trim();n!==``&&(this.globalNodes.add(n),this.members.delete(n)&&(t=!0))};for(let t of e)if(typeof t==`string`)n(t);else if(Array.isArray(t))for(let e of t)n(e);if(t)for(let e of this.subgraphs)e.nodes=e.nodes.filter(e=>!this.globalNodes.has(e))}addConnector(e,t){let n=e?.text?.trim();if(!n)return``;let r=t?.text?.trim()??``,i=this.connectors.get(n);if(i)r.length>0&&(i.text=r);else{let e={id:n,labelType:`text`,styles:[],classes:[],isConnector:!0,text:r.length>0?r:n};this.connectors.set(n,e),this.nodes.set(n,e)}return n}destructLink(e,t){let n=cmt(e);return t&&(t.includes(`.`)?`dotted`:`normal`)!==n.stroke?{type:`INVALID`,stroke:`INVALID`}:{...n,edgeSemantic:smt(n.type,n.stroke)}}subgraph(e){return this.subgraphLookup.get(e)}vertexKind(e){if(tmt(e))return`tool`;let t=kq(e.type);return t===`hexagon`||t===`hex`?`action`:t===`lean-right`||t===`lean_right`?`input`:t===`lin-doc`||t===`lined-document`?`refdoc`:t===`diamond`?`decision`:`task`}semanticModel(){let e=[],t=[];for(let[n,r]of this.nodes){if(this.subgraphLookup.has(n))continue;let i=lmt(r.metadata);if(r.isConnector){let e={id:n};r.text!==void 0&&r.text!==n&&(e.title=r.text),i&&(e.metadata=i),t.push(e);continue}let a={id:n};r.text!==void 0&&(a.label=r.text);let o=kq(r.type);o!==void 0&&(a.shape=o),a.vertexKind=this.vertexKind(r),i&&(a.metadata=i),e.push(a)}let n={vertices:e,edges:this.edges.map(e=>{let t={start:e.start,end:e.end};return e.id!==void 0&&(t.id=e.id),e.text.length>0&&(t.label=e.text),e.type!==void 0&&(t.type=e.type),e.stroke!==void 0&&(t.stroke=e.stroke),e.edgeSemantic!==void 0&&(t.edgeSemantic=e.edgeSemantic),e.length!==void 0&&(t.length=e.length),e.metadata&&Object.keys(e.metadata).length>0&&(t.metadata={...e.metadata}),t}),subGraphs:this.subgraphs.map(e=>{let t={id:e.id,nodes:[...e.nodes],type:e.type,title:e.title};e.dir!==void 0&&(t.direction=e.dir);let n=lmt(e.metadata);return n&&(t.metadata=n),t}),connectors:t,diagnostics:this.diagnostics};return this.direction!==void 0&&(n.direction=this.direction),n}position(e){let t=e?.first_line??0,n=e?.first_column??0;return{startLine:t+this.lineOffset,startColumn:n,endLine:(e?.last_line??t)+this.lineOffset,endColumn:e?.last_column??n,startIndex:0,endIndex:0}}pushMapping(e,t,n){let r={id:e,type:t,position:n};return this.mappings.push(r),this.firstMapping.has(e)||this.firstMapping.set(e,r),r}addVertexMapping(e,t,n,r){if(!e)return;let i=this.pushMapping(e,`vertex`,this.position(r));n??this.bareMappings.add(i)}extendVertexMapping(e,t){if(!e||!t)return;let n=this.position(t);for(let t=this.mappings.length-1;t>=0;t--){let r=this.mappings[t];if(r.type!==`vertex`||r.id!==e)continue;this.bareMappings.delete(r)&&(r.type=`attachment`);let i=r.position;(n.endLine>i.endLine||n.endLine===i.endLine&&n.endColumn>i.endColumn)&&(i.endLine=n.endLine,i.endColumn=n.endColumn);return}this.pushMapping(e,`attachment`,n)}addEdgeMapping(e,t,n,r){let i=Array.isArray(t)?t.filter(e=>typeof e==`string`&&e!==``):[];this.pushMapping(i.length>0?i.join(`>`):`edge`,`edge`,this.position(r))}blockMapping(e,t,n,r){if(!e)return;let i=this.position(n),a=r?this.position(r):i;this.pushMapping(e,t,{startLine:i.startLine,startColumn:i.startColumn,endLine:a.endLine,endColumn:a.endColumn,startIndex:0,endIndex:0})}addSubgraphMapping(e,t,n,r){let i=typeof e==`string`?e:e?.text;this.blockMapping(i??``,`subgraph`,n,r)}addConnectorMapping(e,t,n,r){this.blockMapping(e?.text?.trim()??``,`connector`,n,r)}emit(e,t,n,r){let i=r?.nodeId??r?.edgeId,a={id:e,severity:t,message:n};r?.nodeId?a.nodeId=r.nodeId:r?.edgeId&&(a.edgeId=r.edgeId);let o=i?this.firstMapping.get(i):void 0;o&&(a.position=o.position);let s=i??``,c=this.reported.get(s);if(c===void 0)this.reported.set(s,[a]);else{for(let r of c)if(r.id===e&&r.severity===t&&r.message===n&&r.nodeId===a.nodeId&&r.edgeId===a.edgeId)return;c.push(a)}this.diagnostics.push(a),this.options.log?.(t,`agentflow[${e}]: ${n}`)}emitWarning(e,t,n){this.emit(e,`warning`,t,n)}emitError(e,t,n){this.emit(e,`error`,t,n)}},dmt=`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`,fmt;function pmt(){let e=dmt.split(` `),t=new Uint16Array(e.length),n=0;for(let r=0;r<e.length;r+=2){let i=n+parseInt(e[r],36);n=i+parseInt(e[r+1],36),t[r]=i,t[r+1]=n}return t}function Nq(e){if(e<170||e>65500)return!1;let t=fmt??=pmt(),n=0,r=(t.length>>1)-1;for(;n<=r;){let i=n+r>>1;if(e<t[i*2])r=i-1;else if(e>t[i*2+1])n=i+1;else return!0}return!1}var mmt=/* @__PURE__ */ `$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`.split(`.`),hmt=/* @__PURE__ */ new Uint8Array(128);for(let e of`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!"#$%&'*+.\`?\\_/`)hmt[e.charCodeAt(0)]=1;var gmt=/accTitle\s*:\s*/y,_mt=/accDescr\s*:\s*/y,vmt=/accDescr\s*\{\s*/y,ymt=/call\s+/y,bmt=/click\s+/y,xmt=/(?:\r?\n)*\s*\n/y,Smt=/\s*(?:LR|RL|TB|BT|TD|BR)\b/y,Cmt=/\s*[<>^]/y,wmt=/\s*v\b/y,Tmt=[/.*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],Pq=/[\n\r\u2028\u2029]/g,Emt=/\(\s*\)/y,Dmt=/\n\s*/g;function Omt(e){let t=e.length,n=[],r=[],i=[],a=[],o=[],s=0,c=0,l=1,u=0,d=!0,f=e.indexOf(`direction`),p=e.indexOf(`@`),m=-1,h=0,g=0,_=-1,v=-1,y=-1,b=-1,x=-1,S=-1,C=-1,w=t=>{let n=-1;for(let r=c;r<t;r++){let i=e.charCodeAt(r);i===10?(l++,n=r):i===13&&(r+1<t&&e.charCodeAt(r+1)===10&&r++,l++,n=r)}if(n<0)u+=t-c;else{let r=n+1;for(;r<t;){let t=e.charCodeAt(r);if(t===8232||t===8233)break;r++}u=r-n-1}c=t},T=(t,o)=>{n.push(t),r.push(e.slice(c,o)),i.push(c),a.push(l,u),w(o),a.push(l,u)},E=(t,o)=>{n.push(t),r.push(e.slice(c,o)),i.push(c),a.push(l,u),u+=o-c,c=o,a.push(l,u)},D=(t,o)=>{n.push(t),r.push(e.slice(c,o)),i.push(c),a.push(l,u);for(let t=c;t<o;t++){let n=e.charCodeAt(t);n===10||n===13?(l++,u=0):u++}c=o,a.push(l,u)},O=(e,t,o)=>{n.push(e),r.push(t),i.push(c),a.push(l,u),w(o),a.push(l,u)},k=e=>{o.push(s),s=e},A=()=>{o.length>0&&(s=o.pop())},j=(t,n)=>(t.lastIndex=n,t.test(e)?t.lastIndex:-1),M=t=>e.startsWith(t,c)&&!aq(e.charCodeAt(c+t.length)),N=n=>{if(n>=v&&n<=y)return y;let r=n;for(;r<t&&eq(e.charCodeAt(r));)r++;return v=n,y=r,r},P=n=>{if(n>=b&&n<=x)return x;let r=n;for(;r<t;){let t=e.charCodeAt(r);if(t!==32&&t!==9)break;r++}return b=n,x=r,r},F=t=>{let n=N(t);if(n===C||e.charCodeAt(n)!==45||e.charCodeAt(n+1)!==45)return-1;let r=n+2;for(;e.charCodeAt(r)===45;)r++;let i=e.charCodeAt(r);return i===120||i===62?N(r+1):(C=n,-1)},ee=()=>{let t=N(c);if(t===S||e.charCodeAt(t)!==45)return!1;let n=e.charCodeAt(t+1),r=t+2;if(n===45){for(;e.charCodeAt(r)===45;)r++;let n=e.charCodeAt(r);return n===120||n===62?T(42,N(r+1)):(k(10),T(43,N(t+2))),!0}if(n===46){for(;e.charCodeAt(r)===46;)r++;if(e.charCodeAt(r)===45)return T(42,N(r+1)),!0}return S=t,!1},te=n=>{if(e.charCodeAt(n)!==37||e.charCodeAt(n+1)!==37||e.charCodeAt(n+2)===123)return-1;let r=e.indexOf(`
|
|
981
981
|
`,n+2);return r===-1?t:r},I=()=>{e.charCodeAt(c+1)===96?(k(2),w(c+2)):(k(1),w(c+1))},ne=t=>{let n=e.charCodeAt(c+1);return t===40?(n===45?(k(8),E(47,c+2)):n===91?(k(7),E(49,c+2)):n===40&&e.charCodeAt(c+2)===40?(k(7),E(57,c+3)):(k(7),E(72,c+1)),!0):t===91?(n===91?(k(7),E(51,c+2)):n===40?(k(7),E(55,c+2)):n===47?(k(9),E(60,c+2)):n===92?(k(9),E(61,c+2)):(k(7),E(74,c+1)),!0):t===124?(k(7),E(70,c+1),!0):t===123&&(k(7),E(76,c+1),!0)},re=()=>{let n=c;for(;n<t;){let r=e.charCodeAt(n);if(r<128&&hmt[r]===1)n++;else if(r===45&&n+1<t){let t=e.charCodeAt(n+1);if(t===62||t===45||t===46)break;n++}else break}return n!==c&&(E(67,n),!0)},ie=n=>{let r=n;for(;r<t;){let t=e.charCodeAt(r);if(t!==32&&t!==9)break;r++}return r},ae=n=>{let r;switch(n){case 97:if(e.startsWith(`acc`,c)){if((r=j(gmt,c))>=0)return k(3),T(2,r),!0;if((r=j(_mt,c))>=0)return k(4),T(4,r),!0;if((r=j(vmt,c))>=0)return k(5),w(r),!0}if(M(`agentflow-beta`))return d&&(d=!1,k(6)),E(20,c+14),!0;break;case 64:if(e.charCodeAt(c+1)===123)return k(14),O(7,``,c+2),!0;break;case 99:if((r=j(ymt,c))>=0)return k(12),w(r),!0;if(M(`classDef`))return E(16,c+8),!0;if(M(`class`))return E(17,c+5),!0;if((r=j(bmt,c))>=0)return k(11),w(r),!0;if(M(`connector`))return E(22,c+9),!0;break;case 34:return I(),!0;case 115:if(M(`style`))return E(12,c+5),!0;break;case 100:if(M(`default`))return E(13,c+7),!0;break;case 108:if(M(`linkStyle`))return E(14,c+9),!0;break;case 105:if(M(`interpolate`))return E(15,c+11),!0;break;case 104:if(e.startsWith(`href`,c)&&eq(e.charCodeAt(c+4)))return T(18,c+5),!0;break;case 102:if(M(`flow`))return E(21,c+4),!0;break;case 103:if(M(`global`))return E(23,ie(c+6)),!0;break;case 101:if(M(`end`))return E(24,ie(c+3)),!0;break;case 95:if(M(`_self`))return E(25,c+5),!0;if(M(`_blank`))return E(25,c+6),!0;if(M(`_parent`))return E(25,c+7),!0;if(M(`_top`))return E(25,c+4),!0}if(f!==-1&&c>=h&&(f<c&&(f=e.indexOf(`direction`,c)),f!==-1&&(m<c&&(Pq.lastIndex=c,m=Pq.test(e)?Pq.lastIndex-1:t),f<m))){for(let e=0;e<5;e++)if((r=j(Tmt[e],c))>=0)return T(28+e,r),!0;h=m}if(p!==-1&&n!==34&&!eq(n)){if(c>=g){p<c&&(p=e.indexOf(`@`,c));let n=c;for(;n<t;){let t=e.charCodeAt(n);if(t===34||eq(t))break;n++}if(g=n,_=-1,p!==-1&&p<n)for(let r=Math.min(n,t-1)-1;r>=p;r--){if(e.charCodeAt(r)!==64)continue;let t=e.charCodeAt(r+1);if(t!==123&&t!==34){_=r;break}}}if(_>c)return E(33,_+1),!0}if(n>=48&&n<=57){let n=c+1;for(;n<t;){let t=e.charCodeAt(n);if(t<48||t>57)break;n++}return E(34,n),!0}switch(n){case 35:return E(35,c+1),!0;case 58:return e.charCodeAt(c+1)===58&&e.charCodeAt(c+2)===58?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 ee()||re()||E(68,c+1),!0;case 40:return ne(n);case 91:return e.charCodeAt(c+1)===124?(E(52,c+2),!0):ne(n);case 124:case 123:return ne(n);case 62:return k(7),E(53,c+1),!0;case 94:return E(63,c+1),!0;case 92:return e.charCodeAt(c+1)===124?(E(64,c+2),!0):re();case 118:return aq(e.charCodeAt(c+1))?re():(E(65,c+1),!0);case 37:return(r=te(c))>=0?(T(66,r),!0):re()}if(eq(n)){if(ee())return!0;if((n===32||n===9)&&(r=te(P(c)))>=0)return T(66,r),!0;for(r=c;;){let t=e.charCodeAt(r);if(t===10)r++;else if(t===13&&e.charCodeAt(r+1)===10)r+=2;else break}return r>c?T(77,r):T(78,c+1),!0}return n<128?re():Nq(n)?(E(69,c+1),!0):!1};e:for(;;){if(c>=t){let e=-1;switch(s){case 0:e=79;break;case 3:e=3;break;case 4:e=5;break;case 5:e=6;break;case 11:e=19;break;case 12:e=8;break;case 13:e=9}e!==-1&&E(e,t);break}let o=e.charCodeAt(c),d=!0;switch(s){case 0:d=ae(o);break;case 1:if(o===34)e.charCodeAt(c+1)===96?(k(2),w(c+2)):(A(),w(c+1));else{let n=e.indexOf(`"`,c);T(11,n===-1?t:n)}break;case 2:if(o===96)e.charCodeAt(c+1)===34?(A(),w(c+2)):d=!1;else if(o===34)I();else{let n=c+1;for(;n<t;){let t=e.charCodeAt(n);if(t===96||t===34)break;n++}T(10,n)}break;case 3:case 4:{let n=e.indexOf(`
|
|
982
982
|
`,c);n===-1&&(n=t);let r=s===3?3:5;A(),T(r,n);break}case 5:if(o===125)A(),w(c+1);else{let n=e.indexOf(`}`,c);n===-1&&(n=t),T(6,n)}break;case 6:{let e;o===34?I():(e=j(xmt,c))>=0?(A(),T(26,e)):(e=j(Smt,c))>=0||(e=j(Cmt,c))>=0||(e=j(wmt,c))>=0?(A(),T(27,e)):d=ne(o);break}case 7:{let n=e.charCodeAt(c+1);switch(o){case 34:I();break;case 40:case 91:case 123:ne(o);break;case 93:A(),n===41?E(48,c+2):n===93?E(50,c+2):E(73,c+1);break;case 41:A(),n===93?E(54,c+2):n===41&&e.charCodeAt(c+2)===41?E(56,c+3):E(71,c+1);break;case 124:A(),E(70,c+1);break;case 125:A(),E(75,c+1);break;case 37:{let e=te(c);e>=0?w(e):d=!1;break}default:{let n=c+1;for(;n<t;){let t=e.charCodeAt(n);if(t===91||t===93||t===40||t===41||t===123||t===125||t===124||t===34||t===37)break;n++}T(46,n)}}break}case 8:{let n=e.charCodeAt(c+1),r;if(o===34)I();else if(o===37&&(r=te(c))>=0)w(r);else if((o===45||o===47||o===41)&&n===41)A(),E(45,c+2);else if(o===40||o===91||o===123)ne(o);else if(o===41||o===93||o===125)d=!1;else{let n=c+1;for(;n<t;){let t=e.charCodeAt(n);if(t===34||t===40||t===41||t===91||t===93||t===123||t===125||(t===45||t===47)&&e.charCodeAt(n+1)===41||t===37&&e.charCodeAt(n+1)===37&&e.charCodeAt(n+2)!==123)break;n++}D(46,n)}break}case 9:{let n=e.charCodeAt(c+1);if(o===34){I();break}switch(o){case 40:n===45||n===91||n===40&&e.charCodeAt(c+2)===40?ne(o):n===93?(A(),E(58,c+2)):ne(o);break;case 91:case 123:ne(o);break;case 92:n===93?(A(),E(58,c+2)):E(46,c+1);break;case 47:n===93?(A(),E(59,c+2)):E(46,c+1);break;case 93:case 41:n===93?(A(),E(58,c+2)):d=!1;break;case 125:d=!1;break;case 37:{let e=te(c);e>=0?w(e):d=!1;break}default:{if((o===63||o===61)&&n===93){A(),E(58,c+2);break}let r=c+1;for(;r<t;){let t=e.charCodeAt(r);if(t===92||t===91||t===93||t===40||t===41||t===123||t===125||t===47||t===37)break;r++}T(46,r)}}break}case 10:{if(o===34){I();break}let n=F(c);if(n>=0){A(),T(42,n);break}if(o===45&&e.charCodeAt(c+1)===45){d=!1;break}let r=c+1;for(;r<t;){let t=e.charCodeAt(r);if(t===34)break;if(t===45){if(e.charCodeAt(r+1)===45)break}else if(eq(t)&&F(r)>=0)break;r++}D(44,r);break}case 11:if(o===34)I();else if(eq(o))A(),w(c+1);else{let n=c+1;for(;n<t&&!eq(e.charCodeAt(n));)n++;E(19,n)}break;case 12:if(o===40){let e=j(Emt,c);A(),e>=0?w(e):(k(13),w(c+1))}else{let n=e.indexOf(`(`,c);n===-1&&(n=t),T(8,n)}break;case 13:if(o===41)A(),w(c+1);else{let n=e.indexOf(`)`,c);n===-1&&(n=t),T(9,n)}break;case 14:if(o===34)k(15),E(7,c+1);else if(o===125)A(),w(c+1);else if(o===94)d=!1;else{let n=c+1;for(;n<t;){let t=e.charCodeAt(n);if(t===125||t===94||t===34)break;n++}T(7,n)}break;case 15:if(o===34)A(),E(7,c+1);else{let n=e.indexOf(`"`,c);n===-1&&(n=t),O(7,e.slice(c,n).replace(Dmt,`<br/>`),n)}}if(!d)return n.push(1),r.push(``),i.push(c),a.push(l,u,l,u),{types:n,texts:r,starts:i,locs:a};continue e}return n.push(0),r.push(``),i.push(t),a.push(l,u,l,u),{types:n,texts:r,starts:i,locs:a}}var Fq=/* @__PURE__ */ new Uint8Array(80);for(let e of[34,67,65,68,13,40,37,38,35,41,69])Fq[e]=1;var Iq=/* @__PURE__ */ new Uint8Array(80);for(let e of[34,69,67,27,65,68,40,37,38,35,41])Iq[e]=1;var Lq=/* @__PURE__ */ new Uint8Array(80);for(let e of[34,67,78,68,38,69,37,41,35,12,14,16,17,19,20,27,21,22,23,24,65,63,43])Lq[e]=1;var Rq=/* @__PURE__ */ new Uint8Array(80);for(let e of[34,67,37,78,35,12])Rq[e]=1;var zq=/* @__PURE__ */ new Uint8Array(80);for(let e of[77,39,79,66])zq[e]=1;var kmt=`'UNICODE_TEXT', 'TEXT', 'TAGSTART'`,Bq=`'COMMENT', 'SEMI', 'NEWLINE', 'EOF'`,Vq=[],Amt=/}[^\S\n]*\n/g;function jmt(e,t,n=!1){let r=!n&&e.includes(`}`)?e.replace(Amt,`}
|
|
983
|
-
`):e,{types:i,texts:a,starts:o,locs:s}=Omt(r),c=0,l,u=0,d=0,f=e=>{let t=i[c];throw t===1?FK(`agentflow`,r,o[c],``,!0):FK(`agentflow`,r,o[c],`Expecting ${e}, got '${mmt[t]}'`)},p=(e,t)=>({first_line:s[4*e],first_column:s[4*e+1],last_line:s[4*t+2],last_column:s[4*t+3]}),m=(e,t=``)=>(i[c]!==e&&f(`'${mmt[e]}'${t?`, `+t:``}`),a[c++]),h=()=>{zq[i[c]]===0&&f(Bq),c++},g=()=>{Fq[i[c]]===0&&f(`'NODE_STRING'`);let e=a[c++];for(;Fq[i[c]]===1;)e+=a[c++];return e},_=()=>{Iq[i[c]]===0&&f(`'NODE_STRING'`);let e=a[c++];for(;Iq[i[c]]===1;)e+=a[c++];return e},v=()=>{let e=i[c],t;if(e===11)t=`string`;else if(e===10)t=`markdown`;else if(e===46||e===62||e===53||e===69)t=`text`;else return f(`${kmt}, 'TAGEND', 'STR', 'MD_STR'`);let n=a[c++];for(;;){let e=i[c];if(e!==46&&e!==62&&e!==53&&e!==69)break;n+=a[c++]}return{text:n,type:t}},y=e=>{m(e,kmt)},b=()=>{let e=i[c],t;if(e===11)t=`string`;else if(e===10)t=`markdown`;else if(e===44||e===69)t=`text`;else return f(`'EDGE_TEXT', 'STR', 'MD_STR'`);let n=a[c++];for(;i[c]===44||i[c]===69;)n+=a[c++];return{text:n,type:t}},x=()=>{let e=i[c],t;if(e===11)t=`text`;else if(e===10)t=`markdown`;else if(Lq[e]===1)t=`text`;else return f(`'NODE_STRING', 'STR', 'MD_STR'`);let n=a[c++];for(;Lq[i[c]]===1;)n+=a[c++];return{text:n,type:t}},S=()=>{u=c;let e=a[c++];for(;i[c]===7;)e+=a[c++];return d=c-1,e},C=(e,n,r,i)=>{let a=p(r,i);t.addVertex(e,void 0,void 0,void 0,void 0,void 0,void 0,n,a),t.extendVertexMapping(e,a)},w=(e,n)=>{n.data!==void 0&&t.addVertex(e,void 0,void 0,void 0,void 0,void 0,void 0,n.data,p(n.dataFrom,n.dataTo))},T=()=>{let e=c,n=g(),r,a,o;switch(i[c]){case 74:c++,r=v(),y(73),a=`square`;break;case 57:c++,r=v(),y(56),a=`doublecircle`;break;case 72:c++,i[c]===72?(c++,r=v(),y(71),m(71),a=`circle`):(r=v(),y(71),a=`round`);break;case 47:c++,r=v(),y(45),a=`ellipse`;break;case 49:c++,r=v(),y(48),a=`stadium`;break;case 51:c++,r=v(),y(50),a=`subroutine`;break;case 52:{c++;let e=m(67);m(37);let t=m(67);m(70),r=v(),y(73),a=`rect`,o={[e]:t};break}case 55:c++,r=v(),y(54),a=`cylinder`;break;case 76:c++,i[c]===76?(c++,r=v(),y(75),m(75),a=`hexagon`):(r=v(),y(75),a=`diamond`);break;case 53:c++,r=v(),y(73),a=`odd`;break;case 60:c++,r=v(),i[c]===59?(c++,a=`lean_right`):(y(58),a=`trapezoid`);break;case 61:c++,r=v(),i[c]===58?(c++,a=`lean_left`):(y(59),a=`inv_trapezoid`)}return o===void 0?a===void 0?t.addVertex(n):t.addVertex(n,r,a):t.addVertex(n,r,a,void 0,void 0,void 0,o),t.addVertexMapping(n,r,a,p(e,c-1)),n},E=()=>{let e=T();return i[c]===36&&(c++,t.setClass(e,g())),e},D=()=>{let e=[E()];for(l=void 0;;){let t=i[c]===7?S():void 0,n=u,r=d;if(i[c]!==78)return l=t,e;do c++;while(i[c]===78);if(i[c]!==38)return t!==void 0&&f(`'AMP'`),e;c++,i[c]!==78&&f(`'SPACE'`);do c++;while(i[c]===78);let a=E();t!==void 0&&C(e[e.length-1],t,n,r),e.push(a)}},O=()=>{let e;if(i[c]===33&&(e=a[c++]),i[c]===42){let n=t.destructLink(a[c++]);return e!==void 0&&(n.id=e),i[c]===70&&(c++,n.text=v(),y(70),i[c]===78&&c++),n}if(i[c]===43){let n=a[c++],r=b(),i=m(42,`'EDGE_TEXT'`),o=t.destructLink(i,n);return o.text=r,e!==void 0&&(o.id=e),o}return f(`'LINK', 'START_LINK'`)},k=()=>{let e=c,n=D();l!==void 0&&C(n[n.length-1],l,u,d);let r=n;for(;;){let a=i[c];if(a!==42&&a!==43&&a!==33)return r;let o=O(),s=D();l!==void 0&&C(s[s.length-1],l,u,d),t.addLink(n,s,o),t.addEdgeMapping(n,s,o,p(e,c-1)),r=s.concat(r),n=s}},A=()=>{Rq[i[c]]===0&&f(`'NODE_STRING', 'NUM', 'COLON', 'BRKT'`);let e=a[c++];for(;Rq[i[c]]===1;)e+=a[c++];return e},j=()=>{let e=[A()];for(;i[c]===40;)c++,e.push(A());return e},M=()=>{c++,m(78);let e;if(i[c]===13)e=[a[c++]];else for(e=[m(34,`'DEFAULT'`)];i[c]===40;)c++,e.push(m(34));if(m(78),i[c]!==15){t.updateLink(e,j());return}c++,m(78);let n=_();if(i[c]===78){c++;let r=j();t.updateLinkInterpolate(e,n),t.updateLink(e,r)}else t.updateLinkInterpolate(e,n)},N=(e,n)=>{if(i[c]!==78){t.setLink(e,n);return}if(c++,i[c]===25){t.setLink(e,n,a[c++]);return}let r=m(11,`'LINK_TARGET'`);i[c]===78?(c++,t.setLink(e,n,m(25))):t.setLink(e,n),t.setTooltip(e,r)},P=()=>{let e=a[c++];switch(i[c]){case 8:{let n=a[c++],r=i[c]===9,o=r?a[c++]:void 0,s;i[c]===78&&(c++,s=m(11)),r?t.setClickEvent(e,n,o):t.setClickEvent(e,n),s!==void 0&&t.setTooltip(e,s);return}case 18:c++,N(e,m(11));return;case 11:N(e,a[c++]);return;default:{let n=_();if(i[c]===78){c++;let r=m(11);t.setClickEvent(e,n),t.setTooltip(e,r)}else t.setClickEvent(e,n)}}},F=e=>{m(78,Bq);let t=x(),n={text:``,type:`text`};i[c]===74&&(c++,n=v(),y(73));let r=i[c]===7?S():void 0;return zq[i[c]]===0&&f(`${Bq}, 'SHAPE_DATA'`),{global:!1,at:e,id:t,title:n,data:r,dataFrom:u,dataTo:d,list:[],collect:!1}},ee=()=>{let e=i[c];switch(e){case 12:{c++,m(78);let e=g();return m(78),t.addVertex(e,void 0,void 0,j()),h(),Vq}case 14:return M(),h(),Vq;case 16:{c++,m(78);let e=g();return m(78),t.addClass(e,j()),h(),Vq}case 17:{c++,m(78);let e=g();return m(78),t.setClass(e,g()),h(),Vq}case 19:return P(),h(),Vq;case 22:{let e=F(c++),n=c++,r=t.addConnector(e.id,e.title);return w(r,e),t.addConnectorMapping(e.id,e.title,p(e.at,e.at),p(n,n)),r}case 28:case 29:case 30:case 31:case 32:return c++,{stmt:`dir`,value:Mmt[e-28]};case 2:{c++;let e=m(3).trim();return t.setAccTitle(e),e}case 4:{c++;let e=m(5).trim();return t.setAccDescription(e),e}case 6:{let e=a[c++].trim();return t.setAccDescription(e),e}default:{Fq[e]===0&&f(Nmt);let t=k();return h(),t}}},te=()=>{let e=[],n=[],r=!1;for(;;){let o=i[c];if(o===0)break;if(o===24){let i=e.pop();if(i===void 0)break;let a=c++;if(i.global){t.addGlobal(n),n=i.list,r=i.collect;continue}let o=t.addSubGraph(i.id,n,i.title,`flow`);w(o,i),t.addSubgraphMapping(i.id,i.title,p(i.at,i.at),p(a,a)),n=i.list,r=i.collect,r&&n.push(o)}else if(o===39||o===77||o===78||o===79)r&&n.push(a[c]),c++;else if(o===66)c++;else if(o===21||o===23){let t=c++,a;o===23||zq[i[c]]===1?(a={global:o===23,at:t,id:void 0,title:void 0,data:void 0,dataFrom:0,dataTo:0,list:n,collect:r},h()):(a=F(t),a.list=n,a.collect=r,c++),e.push(a),n=[],r=!0}else{let e=ee();r&&(!Array.isArray(e)||e.length>0)&&n.push(e)}}e.length>0&&f(`'end'`)};for(;i[c]===78||i[c]===77||i[c]===66;)c++;if(m(20,`'SPACE', 'NEWLINE', 'COMMENT'`),i[c]===26)c++,t.setDirection(`TB`);else{let e=m(27,`'NODIR'`),n=i[c];if(n===78){do c++;while(i[c]===78);n=i[c],n!==77&&f(`'NEWLINE', 'SPACE'`)}else n!==39&&n!==77&&n!==66&&f(`'COMMENT', 'SEMI', 'NEWLINE', 'SPACE'`);c++,t.setDirection(e)}te(),i[c]!==0&&f(Nmt)}var Mmt=[`TB`,`BT`,`RL`,`LR`,`TD`],Nmt=`'COMMENT', 'SEMI', 'NEWLINE', 'SPACE', 'EOF', 'flow', 'global', 'connector', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'STYLE', 'LINKSTYLE', 'CLASSDEF', 'CLASS', 'CLICK', 'NODE_STRING'`;function Hq(e,t,n=0){return{w:e,h:t,kind:n,pin:0,span:0,x:0,y:0,rank:0}}function Uq(e,t,n=1,r=0,i=0){return{tail:e,head:t,minlen:n,labelW:r,labelH:i,tailDx:0,headDx:0,tailFixed:!1,headFixed:!1,reversed:!1,points:[],labelX:0,labelY:0}}var Pmt=24,Fmt=2e4,Wq=16,Imt=8,Lmt=.125,Rmt=3,zmt=18,Bmt=10,Vmt=14,Hmt=2,Umt=28,Wmt=12,Gmt=12,Kmt=8,qmt=4,Jmt=.5,Gq=.5,Ymt=12,Xmt=40,Zmt=400;function Kq(e){return e===1||e===2}function Qmt(e,t,n,r){for(let i=t+1;i<n;i++){let n=e[i],a=r[n],o=i-1;for(;o>=t&&(r[e[o]]>a||r[e[o]]===a&&e[o]>n);)e[o+1]=e[o],o--;e[o+1]=n}}function $mt(e,t,n){let r=e.length;if(r===0)return{width:0,height:0};let i=t.length,a=1;if(i>0){let e=/* @__PURE__ */ new Set;for(let n of t){let t=Math.min(n.tail,n.head),i=Math.max(n.tail,n.head),o=t*r+i;if(n.labelW>0||e.has(o)){a=2;break}e.add(o)}}qq(e,t),Jq(e,t,a);let o=new Int32Array(i),s=0;for(let n=0;n<i;n++){let r=t[n];o[n]=Math.abs(e[r.head].rank-e[r.tail].rank),o[n]>1&&(s+=o[n]-1)}let c=new Uint8Array(i);if(s>Fmt){let e=[];for(let t=0;t<i;t++)o[t]>1&&e.push(t);e.sort((e,t)=>o[t]-o[e]||e-t);for(let t of e){if(s<=Fmt)break;c[t]=1,s-=o[t]-1}}let l=r+s,u=new Float64Array(l),d=new Float64Array(l),f=new Uint8Array(l),p=new Int32Array(l),m=0;for(let t=0;t<r;t++){let n=e[t];u[t]=n.w,d[t]=n.h,f[t]=n.kind,p[t]=n.rank,n.rank>m&&(m=n.rank)}let h=0;for(let e=0;e<i;e++)c[e]||(h+=o[e]);let g=new Int32Array(h),_=new Int32Array(h),v=new Float64Array(h),y=new Float64Array(h),b=new Int32Array(i).fill(-1),x=new Uint8Array(m+1),S=new Int32Array(i).fill(-1),C=!1;for(let t=0;t<r;t++)e[t].span>0&&e[t].kind===0&&(C=!0);let w=C?new Uint8Array(h):void 0,T=C?new Uint8Array(h):void 0,E=new Int32Array(i).fill(-1),D=new Int32Array(i).fill(-1),O=!1;{let e=r,n=0;for(let r=0;r<i;r++){if(c[r])continue;let i=t[r],o=i.reversed?i.head:i.tail,s=i.reversed?i.tail:i.head,l=i.reversed?i.headDx:i.tailDx,m=i.reversed?i.tailDx:i.headDx;(l!==0||m!==0)&&(O=!0);let h=p[o],C=p[s],k=-1;i.labelW>0&&(k=h+(C-h>>1),a===2&&C-h>=4?(k&1)==1&&(k+=i.reversed?1:-1):a===2&&!(k&1)&&(k+=i.reversed?1:-1));let A=o;C-h>1&&(b[r]=e),E[r]=n,w&&!(i.reversed?i.headFixed:i.tailFixed)&&(w[n]=i.reversed?2:1);for(let t=h+1;t<C;t++){let a=e++;p[a]=t,t===k?(u[a]=i.labelW,d[a]=i.labelH,f[a]=2,S[r]=a,x[t]|=i.reversed?2:1):f[a]=1,g[n]=A,_[n]=a,v[n]=A===o?l:0,n++,A=a}g[n]=A,_[n]=s,v[n]=A===o?l:0,y[n]=m,T&&!(i.reversed?i.tailFixed:i.headFixed)&&(T[n]=i.reversed?1:2),D[r]=n,n++}}let k=new Int32Array(l+1),A=new Int32Array(l+1);for(let e=0;e<h;e++)k[g[e]+1]++,A[_[e]+1]++;for(let e=0;e<l;e++)k[e+1]+=k[e],A[e+1]+=A[e];let j=new Int32Array(h),M=new Int32Array(h);{let e=k.slice(0,l),t=A.slice(0,l);for(let n=0;n<h;n++)j[e[g[n]]++]=n,M[t[_[n]]++]=n}let N=new Int32Array(m+2);for(let e=0;e<l;e++)N[p[e]+1]++;for(let e=0;e<=m;e++)N[e+1]+=N[e];let P=new Int32Array(l),F=new Int32Array(l);{let e=new Int32Array(l),t=N.slice(0,m+1);for(let n=0;n<l;n++)e[t[p[n]]++]=n;t.set(N.subarray(0,m+1));let n=new Uint8Array(l),r=[];for(let i=0;i<l;i++)if(!n[e[i]])for(r.push(e[i]);r.length>0;){let e=r.pop();if(!n[e]){n[e]=1,P[t[p[e]]++]=e;for(let t=k[e+1]-1;t>=k[e];t--){let e=_[j[t]];n[e]||r.push(e)}}}}let ee=!1;for(let t=0;t<r;t++)e[t].pin!==0&&(ee=!0);if(ee)for(let t=0;t<=m;t++){let n=Array.from(P.subarray(N[t],N[t+1])),i=/* @__PURE__ */ new Map;n.forEach((e,t)=>i.set(e,t));let a=t=>t<r?e[t].pin:0;n.sort((e,t)=>a(e)-a(t)||i.get(e)-i.get(t)),P.set(n,N[t])}let te=()=>{for(let e=0;e<=m;e++){let t=N[e];for(let n=t,r=N[e+1];n<r;n++)F[P[n]]=n-t}};te();let I={n:l,real:r,maxRank:m,W:u,KIND:f,RANK:p,EF:g,ET:_,EFD:v,ETD:y,succStart:k,succE:j,predStart:A,predE:M,layerStart:N,order:P,pos:F,offsets:O};h>0&&m>0&&(dht(I,e),te()),w&&T&&tht(I,e,w,T);let ne=pht(I,n),re=sht(I);if(w&&T){let r=nht(I,w,T);iht(I,e,ne,r,n,re),aht(I,e,ne,w,T,r,re),oht(I,ne,re,n);for(let e=0;e<i;e++){if(c[e])continue;let n=t[e],r=v[E[e]],i=y[D[e]];n.tailDx=n.reversed?i:r,n.headDx=n.reversed?r:i}}let ie=new Uint8Array(l);re&&!n.tracks&&lht(I,ne,re,b,o,n.apart?0:n.edgeSep,ie),n.tracks||uht(I,ne,b,o,n.edgeSep,ie);let ae=new Int32Array(i+1),L=n.tracks||w&&!n.straight?{from:[],to:[],rank:[],lower:[],track:[],levels:[],wide:[]}:void 0,oe=new Int32Array(m+1);if(L){for(let e=0;e<i;e++){if(ae[e]=L.from.length,c[e])continue;let t=b[e],r=!1;for(let i=t,a=t<0?t:t+o[e]-1;i<a;i++){let e=re!==void 0&&re[p[i]]===1;!n.tracks&&e!==(ie[i]===1)&&(r=!0)}if(r)continue;let i=ne[g[E[e]]]+v[E[e]],a=p[g[E[e]]];for(let n=t,r=t<0?t:t+o[e]-1;n<r;n++)re&&re[p[n]]||(L.from.push(i),L.to.push(ne[n]),L.rank.push(a),L.lower.push(n),i=ne[n],a=p[n]);L.from.push(i),L.to.push(ne[_[D[e]]]+y[D[e]]),L.rank.push(a),L.lower.push(-1)}ae[i]=L.from.length}let se=(e,t)=>{let n=!1;for(let r=N[e];r<N[e+1];r++){let e=f[P[r]];if(e===t)n=!0;else if(e!==1)return!1}return n},ce=se(0,3)?a:0,le=se(m,4)?a:0,ue=new Float64Array(m+1);for(let e=0;e<h;e++){let t=Math.abs(ne[g[e]]+v[e]-ne[_[e]]-y[e]);t>ue[p[g[e]]]&&(ue[p[g[e]]]=t)}let de=new Float64Array(m+1),fe=new Float64Array(m+1),pe=e=>(e<ce||e>=m-le?n.portSep:n.rankSep)/a,me=new Float64Array(m+1);for(let e=0;e<m;e++)me[e]=L?pe(e):Math.max(pe(e),Math.min(Rmt*n.rankSep/a,ue[e]*Lmt));let he=new Uint8Array(m+1).fill(1);for(let e=0;e<r;e++)he[p[e]]=0;for(let e=1;e<m;e++){if(n.tracks||!he[e]||x[e]!==1&&x[e]!==2)continue;let t=Math.min((n.headRoom??0)/2,me[x[e]===1?e-1:e]/2);me[e-1]+=x[e]===1?-t:t,me[e]+=x[e]===1?t:-t}let ge=e=>f[e]===1&&he[p[e]]&&!n.tracks?(fe[p[e]]-de[p[e]])/4:0,_e=n.tracks?zmt:Umt,ve=n.tracks?Bmt:Wmt,ye=n.tracks?Vmt:Wmt,be=new Int32Array(m+1);if(L){let e=new Float64Array(m+1);for(let t=0;t<m;t++){if(re&&re[t])continue;let n=t+1;for(e[t]=me[t];n<m&&re&&re[n];)e[t]+=me[n++];be[t]=n}for(let t=0;t<L.from.length;t++)L.wide.push(+(Math.abs(L.from[t]-L.to[t])>Hmt*e[L.rank[t]]));let t=new Float64Array(m+1);cht(L,oe,!n.tracks,e,t);for(let r=0;r<m;r++)oe[r]>0?me[r]+=Math.max(0,2*_e+(oe[r]-1)*ve-e[r]):t[r]>0&&(me[r]+=Math.max(0,Math.min(Rmt*n.rankSep,t[r])-e[r]))}let xe=0;for(let e=0;e<=m;e++){let t=0;for(let n=N[e];n<N[e+1];n++)d[P[n]]>t&&(t=d[P[n]]);de[e]=xe,fe[e]=xe+t,xe+=t+me[e]}let Se=xe,Ce=(e,t=L.track[e])=>{let r=L.rank[e],i=fe[r],a=de[be[r]],o=n.tracks?oe[r]:L.levels[e],s=o>1?Math.min(ye,(a-i-2*_e)/(o-1)):0;return(i+a)/2+(t-(o-1)/2)*s},we=1/0,Te=-1/0;for(let e=0;e<l;e++){let t=u[e]/2;ne[e]-t<we&&(we=ne[e]-t),ne[e]+t>Te&&(Te=ne[e]+t)}let Ee=new Uint8Array(m+1),De=new Uint8Array(m+1);for(let e=0;e<r;e++)f[e]!==0||!w||(A[e+1]>A[e]&&(Ee[p[e]]=1),k[e+1]>k[e]&&(De[p[e]]=1));for(let t=0;t<r;t++){let n=e[t],r=n.rank;n.x=ne[t]-we,n.y=f[t]===0&&De[r]&&!Ee[r]?fe[r]-n.h/2:f[t]===0&&Ee[r]&&!De[r]?de[r]+n.h/2:(de[r]+fe[r])/2}for(let r=0;r<i;r++){let i=t[r],a=e[i.reversed?i.head:i.tail],s=e[i.reversed?i.tail:i.head],c=[a.x+(i.reversed?i.headDx:i.tailDx),a.y+a.h/2],l=b[r];if(L&&ae[r+1]>ae[r])for(let e=ae[r];e<ae[r+1];e++){if(L.track[e]>=0&&(n.tracks||L.wide[e]===1)){let t=Ce(e);c.push(L.from[e]-we,t,L.to[e]-we,t)}else L.track[e]>0&&c.push(L.from[e]-we,Ce(e,L.track[e]-1));let t=L.lower[e];t<0||(c.push(ne[t]-we,de[p[t]]+ge(t)),fe[p[t]]>de[p[t]]&&c.push(ne[t]-we,fe[p[t]]-ge(t)))}else if(l>=0)for(let e=l,t=l+o[r]-1;e<t;e++){if(ie[e])continue;let t=ne[e]-we,n=de[p[e]],r=fe[p[e]];c.push(t,n+ge(e)),r>n&&c.push(t,r-ge(e))}if(c.push(s.x+(i.reversed?i.tailDx:i.headDx),s.y-s.h/2),i.reversed)for(let e=0,t=c.length-2;e<t;e+=2,t-=2){let n=c[e],r=c[e+1];c[e]=c[t],c[e+1]=c[t+1],c[t]=n,c[t+1]=r}i.points=c;let u=S[r];u>=0?(i.labelX=ne[u]-we,i.labelY=(de[p[u]]+fe[p[u]])/2):i.labelW>0&&(i.labelX=(c[0]+c[c.length-2])/2,i.labelY=(c[1]+c[c.length-1])/2)}return{width:Te-we,height:Se}}function qq(e,t){let n=e.length,r=t.length,i=new Int32Array(n+1);for(let n=0;n<r;n++){let r=t[n];r.reversed=e[r.head].kind===3||e[r.tail].kind===4,r.reversed||i[r.tail+1]++}for(let e=0;e<n;e++)i[e+1]+=i[e];let a=new Int32Array(i[n]);{let e=i.slice(0,n);for(let n=0;n<r;n++)t[n].reversed||(a[e[t[n].tail]++]=n)}let o=new Uint8Array(n),s=i.slice(0,n),c=[];for(let e=0;e<n;e++)if(o[e]===0)for(c.push(e),o[e]=1;c.length>0;){let e=c[c.length-1];if(s[e]<i[e+1]){let n=t[a[s[e]++]],r=n.head;o[r]===1?n.reversed=!0:o[r]===0&&(o[r]=1,c.push(r))}else o[e]=2,c.pop()}}function Jq(e,t,n){let r=e.length,i=t.length,a=new Int32Array(i),o=new Int32Array(i),s=new Int32Array(i),c=new Int32Array(r+1),l=new Int32Array(r+1);for(let e=0;e<i;e++){let r=t[e],i=r.reversed?r.head:r.tail,u=r.reversed?r.tail:r.head;a[e]=i,o[e]=u,s[e]=Math.max(1,r.minlen)*n,c[i+1]++,l[u+1]++}for(let e=0;e<r;e++)c[e+1]+=c[e],l[e+1]+=l[e];let u=new Int32Array(i),d=new Int32Array(i);{let e=c.slice(0,r),t=l.slice(0,r);for(let n=0;n<i;n++)u[e[a[n]]++]=n,d[t[o[n]]++]=n}let f=new Int32Array(r),p=new Int32Array(r);for(let e=0;e<r;e++)p[e]=l[e+1]-l[e];let m=new Int32Array(r),h=0;for(let e=0;e<r;e++)p[e]===0&&(m[h++]=e);for(let e=0;e<h;e++){let t=m[e];for(let e=c[t];e<c[t+1];e++){let n=u[e],r=o[n];f[t]+s[n]>f[r]&&(f[r]=f[t]+s[n]),--p[r]===0&&(m[h++]=r)}}for(let e=0;e<8;e++){let e=!1;for(let t=h-1;t>=0;t--){let n=m[t],r=l[n+1]-l[n],i=c[n+1]-c[n];if(r===0&&i===0)continue;let p=-1/0,h=1/0;for(let e=l[n];e<l[n+1];e++){let t=d[e];p=Math.max(p,f[a[t]]+s[t])}for(let e=c[n];e<c[n+1];e++){let t=u[e];h=Math.min(h,f[o[t]]-s[t])}let g=f[n];i>r&&h!==1/0?g=h:r>i&&p!==-1/0&&(g=p),g!==f[n]&&(f[n]=g,e=!0)}if(!e)break}let g=1/0,_=-1/0,v=!1;for(let t=0;t<r;t++){let n=e[t].kind;n===3&&(v=!0),n!==3&&n!==4&&(f[t]<g&&(g=f[t]),f[t]>_&&(_=f[t]))}g===1/0&&(g=0,_=0);for(let t=0;t<r;t++)e[t].kind===3?f[t]=g-n:e[t].kind===4&&(f[t]=_+n);v&&(g-=n);for(let t=0;t<r;t++)e[t].rank=f[t]-g}function eht(e,t,n,r,i,a,o){let s=n===0?e.predStart:e.succStart,c=n===0?e.predE:e.succE,l=n===0?e.EF:e.ET,u=e.pos;a.length=0;for(let e=s[t];e<s[t+1];e++)i[c[e]]!==0&&a.push(c[e]);if(a.length<2)return 0;a.sort((e,t)=>u[l[e]]-u[l[t]]||e-t);let d=e=>{let t=0;o.length=a.length,o[0]=0;for(let n=1;n<a.length;n++){let r=i[a[n]]===i[a[n-1]];o[n]=e(r&&i[a[n]]===1,r),t+=o[n]}return t},f=d(()=>1);if(r/f<Imt&&(f=d(e=>e?.5:1)),r/f<Imt&&(f=d((e,t)=>+!t)),f===0)return 0;let p=Math.min(Wq,r/f);for(let e=1;e<a.length;e++)o[e]*=p;return f*p}function tht(e,t,n,r){let{real:i,W:a,EFD:o,ETD:s}=e,c=[],l=[];for(let u=0;u<i;u++){let i=Math.min(t[u].span,a[u]);if(!(i<=0||t[u].kind!==0))for(let t=0;t<2;t++){let a=eht(e,u,t,i,t===0?r:n,c,l);if(a===0)continue;let d=t===0?s:o,f=-a/2;for(let e=0;e<c.length;e++)f+=l[e],d[c[e]]=f}}}function Yq(e,t,n,r){if(!t)return n;let{KIND:i,RANK:a,EF:o,ET:s,succStart:c,succE:l,predStart:u,predE:d}=e;for(let e=0;e<1e5;e++){let e=r===0?o[n]:s[n];if(i[e]!==1||!t[a[e]])break;n=r===0?d[u[e]]:l[c[e]]}return n}function nht(e,t,n){let r=[new Int32Array(e.n),new Int32Array(e.n)];for(let i=0;i<e.EF.length;i++)n[i]!==0&&r[0][e.ET[i]]++,t[i]!==0&&r[1][e.EF[i]]++;return r}function rht(e,t){return Math.max(.25,Math.min(.5,4*Math.abs(t)/(Math.abs(e)||1)))}function iht(e,t,n,r,i,a){let o=i.edgeSep,{n:s,real:c,maxRank:l,KIND:u,RANK:d,W:f,EF:p,ET:m,EFD:h,ETD:g,succStart:_,succE:v,predStart:y,predE:b,layerStart:x,order:S,pos:C}=e,w=e=>u[e]===2||u[e]===1&&(a===void 0||a[d[e]]!==1),T=(e,i)=>{let a=i===0?p[e]:m[e];return[i===0?n[a]+h[e]:n[a]+g[e],a<c&&t[a].kind===0?r[1-i][a]:0]},E=e=>{let t=x[d[e]],r=t+C[e],a=t=>f[t]/2+f[e]/2+(u[t]===0?i.nodeSep/2+o/2:u[t]===u[e]?o:o/2);return[r>t?n[S[r-1]]+a(S[r-1]):-1/0,r+1<x[d[e]+1]?n[S[r+1]]-a(S[r+1]):1/0]},D=(e,t,n,r,i)=>{let a=(t[1]===n[1]?Math.abs(t[0]-e)<=Math.abs(n[0]-e):t[1]<n[1])?[t[0],n[0]]:[n[0],t[0]];return a.find(e=>e>=r&&e<=i)??Math.max(r,Math.min(i,a[0]))},O=new Uint8Array(s),k=[];for(let t=1;t<l;t++)for(let r=x[t];r<x[t+1];r++){if(!w(S[r])||O[S[r]])continue;let t=S[r];for(;Kq(u[p[b[y[t]]]]);)t=p[b[y[t]]];let i=t,o=-1/0,s=1/0;k.length=0;for(let e=t;Kq(u[e]);e=m[v[_[e]]]){if(i=e,!w(e))continue;O[e]=1,k.push(e);let[t,n]=E(e);t>o&&(o=t),n<s&&(s=n)}if(o<=s){let e=D(n[k[0]],T(b[y[t]],0),T(v[_[i]],1),o,s);for(let t of k)n[t]=e}else for(let t of k){let[r,i]=E(t);r>i||(n[t]=D(n[t],T(Yq(e,a,b[y[t]],0),0),T(Yq(e,a,v[_[t]],1),1),r,i))}}}function aht(e,t,n,r,i,a,o){let{real:s,W:c,EF:l,ET:u,EFD:d,ETD:f,succStart:p,succE:m,predStart:h,predE:g,pos:_}=e,v=[],y=[],b=[],x=[],S=[],C=(p,m,h,g,_)=>{if(a[m][h]<2)return 0;p=Yq(e,o,p,m);let v=m===0?l[p]:u[p],y=m===0?n[v]+d[p]:n[v]+f[p];if(_&&Math.abs(y-n[h])<=g/2+Gq)return Math.max(-g/2,Math.min(g/2,y-n[h]));let b=y,x=0;v<s&&t[v].kind===0&&(m===0?r:i)[p]!==0&&a[1-m][v]>=2&&(x=Math.max(0,Math.min(t[v].span,c[v])),x>0&&(b=n[v]));let S=Math.max(n[h]-g/2,b-x/2),C=Math.min(n[h]+g/2,b+x/2);if(S>C+Gq){let e=Math.max(0,g/2-Xmt);return Math.max(-e,Math.min(e,y-n[h]))}let w=(n[h]*x+b*g)/(x+g);return Math.max(S,Math.min(C,w))-n[h]};for(let n=0,a=!0;a&&n<6;n++){a=!1;for(let o=0;o<s;o++){let s=Math.min(t[o].span,c[o]);if(!(s<=0||t[o].kind!==0))for(let t=0;t<2;t++){let c=t===0?i:r,w=t===0?f:d,T=t===0?l:u,E=t===0?h:p,D=t===0?g:m;if(eht(e,o,t,s,c,v,y),v.length===0)continue;v.length===1&&(y[0]=0),b.length=0;for(let e=E[o];e<E[o+1];e++)b.push(D[e]);b.sort((e,t)=>_[T[e]]-_[T[t]]||e-t);let O=0,k=-s/2;for(let e=0;e<=b.length;e++){let r=e<b.length&&c[b[e]]===0;if(e<b.length&&!r)continue;let i=0;for(let t=e-1;t>=0&&c[b[t]]!==0;t--)i++;let l=r?w[b[e]]-Wq:s/2;if(i>0){x.length=0,S.length=0;let e=0;for(let r=0;r<i;r++){r>0&&(e+=y[O+r]),x.push(C(v[O+r],t,o,s,n>0)-e),S.push(1);let i=r>0&&y[O+r]===0;for(;x.length>1&&(i||x[x.length-2]/S[S.length-2]>x[x.length-1]/S[S.length-1]);){i=!1;let e=x.pop(),t=S.pop();x[x.length-1]+=e,S[S.length-1]+=t}}let r=e,c=0;e=0;for(let t=0;t<x.length;t++){let n=l-r<k?(k+l-r)/2:Math.max(k,Math.min(l-r,x[t]/S[t]));for(let r=0;r<S[t];r++,c++)c>0&&(e+=y[O+c]),Math.abs(w[v[O+c]]-n-e)>.01&&(a=!0),w[v[O+c]]=n+e}O+=i}r&&(k=w[b[e]]+Wq)}}}}}function oht(e,t,n,r){let{n:i,KIND:a,RANK:o,EF:s,ET:c,EFD:l,ETD:u,layerStart:d,order:f,pos:p}=e,m=e=>n!==void 0&&a[e]===1&&n[o[e]]===1,h=[],g=[],_=[],v=[];for(let t=0;t<s.length;t++){if(m(s[t]))continue;let r=Yq(e,n,t,1);h.push(s[t]),g.push(c[r]),_.push(l[t]),v.push(u[r])}let y=e=>t[g[e]]+v[e]-t[h[e]]-_[e],b=new Int32Array(i),x=[];for(let e=0;e<i;e++)b[e]=e,x.push([e]);let S=(e,t)=>{let n=b[e],r=b[t];if(n!==r){x[n].length<x[r].length&&([n,r]=[r,n]);for(let e of x[r])b[e]=n,x[n].push(e);x[r]=[]}},C=[];for(let e=0;e<h.length;e++){let t=Math.abs(y(e));t<.01?S(h[e],g[e]):t<=Ymt&&C.push(e)}if(C.length===0)return;C.sort((e,t)=>Math.abs(y(e))-Math.abs(y(t))||e-t);let w=t=>fht(e,r,t),T=(e,n)=>{for(let r of x[e]){let i=d[o[r]],a=d[o[r]+1],s=i+p[r];if(s>i&&b[f[s-1]]!==e&&t[r]+n-t[f[s-1]]<w(r)+w(f[s-1])-.01||s+1<a&&b[f[s+1]]!==e&&t[f[s+1]]-t[r]-n<w(r)+w(f[s+1])-.01)return!1}return!0};for(let e of C){let n=y(e);if(Math.abs(n)<.01){S(h[e],g[e]);continue}if(Math.abs(n)>Ymt||b[h[e]]===b[g[e]])continue;let r=b[h[e]],i=b[g[e]],a=x[r].length<=x[i].length?r:i;for(let o of[a,a===r?i:r]){let i=o===r?n:-n;if(T(o,i)){for(let e of x[o])t[e]+=i;S(h[e],g[e]);break}}}}function sht(e){let{maxRank:t,KIND:n,layerStart:r,order:i}=e,a=new Uint8Array(t+1),o=!1;for(let e=1;e<t;e++){let t=r[e+1]>r[e];for(let a=r[e];t&&a<r[e+1];a++)n[i[a]]!==1&&(t=!1);t&&(a[e]=1,o=!0)}return o?a:void 0}function cht(e,t,n,r,i){let{from:a,to:o,rank:s,track:c,levels:l,wide:u}=e,d=a.length,f=/* @__PURE__ */ new Map;for(let e=0;e<d;e++){if(c.push(-1),l.push(0),Math.abs(a[e]-o[e])<Gq)continue;let t=f.get(s[e]);t?t.push(e):f.set(s[e],[e])}let p=new Float64Array(d),m=new Float64Array(d);for(let e=0;e<d;e++)p[e]=Math.min(a[e],o[e]),m[e]=Math.max(a[e],o[e]);let h=(e,t)=>+(e>=p[t]-Gq&&e<=m[t]+Gq),g=(e,t)=>Math.abs(a[e]-a[t])<Gq||Math.abs(o[e]-o[t])<Gq,_=(e,t)=>p[e]<m[t]-Gq&&p[t]<m[e]-Gq,v=(e,t)=>_(e,t)&&!g(e,t),y=(e,t)=>_(e,t)||h(o[e],t)+h(a[t],e)+h(o[t],e)+h(a[e],t)>0,b=(e,t)=>h(o[e],t)+h(a[t],e),x=e=>{e.sort((e,t)=>m[t]-p[t]-(m[e]-p[e])||p[e]-p[t]||e-t);let t=e.length,r=[],i=e.map((e,t)=>t),a=e=>{for(;i[e]!==e;)e=i[e]=i[i[e]];return e},o=e;if(t<=Zmt){let n=new Int32Array(t),s=[];for(let e=0;e<t;e++)r.push([]),s.push([]);for(let o=0;o<t;o++)for(let c=o+1;c<t;c++){let t=e[o],l=e[c];if(!y(t,l))continue;i[a(o)]=a(c);let u=b(t,l),d=b(l,t);if(u===d)continue;let f=u<d?o:c,p=u<d?c:o;r[p].push(f),s[f].push(p),n[p]++}let c=new Uint8Array(t),l=[];for(let e=0;e<t;e++){let e=-1;for(let r=0;r<t&&!(!c[r]&&((e<0||n[r]<n[e])&&(e=r),n[r]===0));r++);c[e]=1,l.push(e);for(let t of s[e])n[t]--}o=l.map(t=>e[t])}let s=/* @__PURE__ */ new Map;e.forEach((e,t)=>s.set(e,t));let u=[];for(let t of o){let n=0;for(let i of r[s.get(t)]??[])c[e[i]]>=n&&(n=c[e[i]]+1);for(;;n++){let e=u[n]??=[],r=!0;for(let n of e)v(t,n)&&(r=!1);if(r){e.push(t);break}}c[t]=n}let d=/* @__PURE__ */ new Map,f=/* @__PURE__ */ new Map;return e.forEach((e,t)=>{let n=a(t);d.set(n,Math.min(d.get(n)??1/0,c[e])),f.set(n,Math.max(f.get(n)??-1/0,c[e]))}),e.forEach((e,t)=>{let r=a(t);l[e]=f.get(r)-d.get(r)+1,n&&(c[e]-=d.get(r))}),u.length},S=(e,t,n)=>{let r=rht(o[e]-a[e],t);for(let i=0;i<=16;i++){let s=i/16,c=1-s;n[2*i]=a[e]+(o[e]-a[e])*s*s*(3-2*s),n[2*i+1]=t*(3*r*s*c*c+3*(1-r)*s*s*c+s*s*s)}},C=/* @__PURE__ */ new Float64Array(34),w=/* @__PURE__ */ new Float64Array(34),T=(e,t)=>{let n=1/0;for(let r=0;r<=16;r++){let i=e[2*r],a=e[2*r+1];for(let e=0;e<16;e++){let r=t[2*e+2]-t[2*e],o=t[2*e+3]-t[2*e+1],s=Math.max(0,Math.min(1,((i-t[2*e])*r+(a-t[2*e+1])*o)/(r*r+o*o||1))),c=Math.hypot(i-t[2*e]-s*r,a-t[2*e+1]-s*o);c<n&&(n=c)}}return n},E=(e,t,n)=>{let r=Math.max(n/2,n-2*Gmt);return S(e,r,C),S(t,r,w),Math.min(T(C,w),T(w,C))};for(let[e,s]of f){if(!n){t[e]=x(s);continue}if(s.length>Zmt)continue;let d=s.filter(e=>u[e]===1);x(d);let f=new Set(d.filter(e=>l[e]>1));for(let t=0;t<s.length;t++)for(let n=t+1;n<s.length;n++){let i=s[t],c=s[n];f.has(i)&&f.has(c)||!v(i,c)||a[i]<o[i]!=a[c]<o[c]||E(i,c,r[e])<(u[i]===1||u[c]===1?Kmt:qmt)&&f.add(i).add(c)}for(let e of d)c[e]=-1,l[e]=0;if(f.size===0)continue;let h=0,b=0,S=[...f];for(let e=0;e<S.length;e++)for(let t=e+1;t<S.length;t++){let n=S[e],r=S[t];_(n,r)&&(a[n]<o[n]==a[r]<o[r]?g(n,r)||b++:h++)}if(h>b){for(let t of s)(m[t]-p[t])*Jmt>i[e]&&(i[e]=(m[t]-p[t])*Jmt);continue}let C=e=>{for(let t of f)if(y(e,t))return!0;return!1},w=s.filter(e=>f.has(e)||u[e]!==1&&C(e));x(w);let T=0;for(let e of w)l[e]>T&&(T=l[e]);t[e]=T}}function lht(e,t,n,r,i,a,o){let{maxRank:s,EF:c,ET:l,EFD:u,ETD:d,succStart:f,succE:p,predStart:m,predE:h,layerStart:g,order:_}=e,v=new Float64Array(t.length),y=new Float64Array(t.length),b=new Float64Array(t.length);for(let a=0;a<r.length;a++){let o=r[a];if(o<0)continue;let s=o+i[a]-1,g=e.RANK[o];for(let e=o;e<s;e++){if(!n[g+e-o])continue;let r=e;for(;r+1<s&&n[g+r+1-o];)r++;let i=h[m[e]],a=p[f[r]],_=t[c[i]]+u[i],x=t[l[a]]+d[a],S=r-e+2;for(let t=e;t<=r;t++)v[t]=_+(x-_)*(t-e+1)/S,y[t]=_,b[t]=x;e=r}}let x=[];for(let r=1;r<s;r++){if(!n[r])continue;let i=g[r],s=g[r+1],c=Array.from(_.subarray(i,s)).sort((e,t)=>y[e]-y[t]||b[e]-b[t]||e-t);for(let n=0;n<c.length;){x.length=0;let r=n;for(;r<c.length&&Math.abs(y[c[r]]-y[c[n]])<1&&Math.abs(b[c[r]]-b[c[n]])<1;r++)x.push(c[r]);x.sort((t,n)=>e.pos[t]-e.pos[n]);for(let e=0;e<x.length;e++){let n=x[e];t[n]=v[n]+(e-(x.length-1)/2)*a,(x.length===1||a===0)&&(o[n]=1)}n=r}}}function uht(e,t,n,r,i,a){let{maxRank:o,W:s,KIND:c,RANK:l,EF:u,ET:d,EFD:f,ETD:p,succStart:m,succE:h,predStart:g,predE:_,layerStart:v,order:y}=e,b=new Uint8Array(o+1),x=!1;for(let e=1;e<o;e++){let t=!1,n=!1;for(let r=v[e];r<v[e+1];r++){let e=c[y[r]];e===2?t=!0:e!==1&&(n=!0)}t&&!n&&(b[e]=1,x=!0)}if(x)for(let e=0;e<n.length;e++){let o=n[e];if(!(o<0))for(let n=o,x=o+r[e]-1;n<x;n++){if(c[n]!==1||!b[l[n]])continue;let e=n,r=n;for(;e>o&&a[e-1];)e--;for(;r+1<x&&a[r+1];)r++;let S=_[g[e]],C=h[m[r]],w=t[u[S]]+f[S],T=t[d[C]]+p[C],E=Math.min(w,T)-i,D=Math.max(w,T)+i,O=!0,k=l[n];for(let e=v[k];O&&e<v[k+1];e++){let n=y[e];c[n]===2&&t[n]+s[n]/2>E&&t[n]-s[n]/2<D&&(O=!1)}if(!O)continue;a[n]=1;let A=r-e+2;for(let n=e;n<=r;n++)t[n]=w+(T-w)*(n-e+1)/A}}}function dht(e,t){let{n,real:r,maxRank:i,W:a,EF:o,ET:s,EFD:c,ETD:l,succStart:u,succE:d,predStart:f,predE:p,layerStart:m,order:h,pos:g,offsets:_}=e,v=0;for(let e=0;e<=i;e++)v=Math.max(v,m[e+1]-m[e]);let y=_?new Int32Array(o.length):void 0,b=1;for(;b<(y?v+o.length:v);)b<<=1;let x=new Int32Array(2*b),S=new Int32Array(o.length),C=()=>{let e=0;for(let t=0;t<i;t++){let n=m[t+2]-m[t+1];if(y){let e=0;for(let n=m[t+1];n<m[t+2];n++){let t=f[h[n]],r=f[h[n]+1],i=!1;for(let e=t+1;e<r;e++)l[p[e]]!==l[p[t]]&&(i=!0);if(i){let n=Array.from(p.subarray(t,r));n.sort((e,t)=>l[e]-l[t]);for(let t=0;t<n.length;t++)t>0&&l[n[t]]!==l[n[t-1]]&&e++,y[n[t]]=e}else for(let n=t;n<r;n++)y[p[n]]=e;e++}n=e}if(n<2)continue;let r=0;for(let e=m[t];e<m[t+1];e++){let t=h[e],n=u[t],i=u[t+1],a=r;for(let e=n;e<i;e++)S[r++]=y?y[d[e]]:g[s[d[e]]];let o=r-a;if(o<2)continue;let l=!1;if(y)for(let e=n+1;e<i;e++)c[d[e]]!==c[d[n]]&&(l=!0);if(y&&l){let e=Array.from(d.subarray(n,i));e.sort((e,t)=>c[e]-c[t]||y[e]-y[t]);for(let t=0;t<o;t++)S[a+t]=y[e[t]]}else if(o<=12)for(let e=a+1;e<r;e++){let t=S[e],n=e-1;for(;n>=a&&S[n]>t;)S[n+1]=S[n],n--;S[n+1]=t}else S.subarray(a,r).sort()}if(r<2)continue;let i=1;for(;i<n;)i<<=1;x.fill(0,0,2*i);for(let t=0;t<r;t++){let n=S[t]+i;for(x[n]++;n>1;)!(n&1)&&(e+=x[n+1]),n>>=1,x[n]++}}return e},w=C();if(w===0)return;let T=h.slice(),E=new Float64Array(n),D=new Int32Array(v),O=(e,t)=>E[e]-E[t]||g[e]-g[t],k=(e,t)=>E[e]-E[t]||g[t]-g[e],A=(e,n)=>{let v=e?f:u,y=e?p:d,b=e?o:s,x=e?c:l;for(let o=1;o<=i;o++){let s=e?o:i-o,c=m[s],l=m[s+1],u=0;for(let e=c;e<l;e++){let n=h[e],i=n<r?t[n].pin:0;if(i!==0){E[n]=i*1e9,D[u++]=n;continue}let o=v[n],s=v[n+1];if(o===s){E[n]=-1;continue}let c=0;for(let e=o;e<s;e++){let t=b[y[e]];c+=g[t],_&&a[t]>0&&(c+=x[y[e]]/a[t])}E[n]=c/(s-o),D[u++]=n}if(u<2)continue;D.subarray(0,u).sort(n?k:O);let d=0;for(let e=c;e<l;e++)E[h[e]]!==-1&&(h[e]=D[d++]);for(let e=c;e<l;e++)g[h[e]]=e-c}},j=()=>{let e=0;for(let t=0;t<=i;t++)for(let n=m[t];n<m[t+1];n++)if(!(h[n]>=r))for(let r=n+1;r<m[t+1];r++)h[r]<h[n]&&e++;return e},M=()=>{for(let e=0;e<=i;e++)for(let t=m[e];t<m[e+1];t++)g[h[t]]=t-m[e]},N=h.slice(),P=w,F=n<=600,ee=T,te=1/0;for(let e=0;e<(F?2:1);e++){e>0&&(h.set(N),M());let t=P,n=N.slice();for(let r=0,i=0;i<4&&r<Pmt;r++,i++){A((r+e)%2==0,r%4>=2);let a=C();if(a<t&&(t=a,n.set(h),i=0,a===0))break}h.set(n);let r=F?j():0;(e===0||t<w||t===w&&r<te)&&(w=t,ee=n,te=r)}if(h.set(ee),M(),T.set(ee),F){for(let e=0;e<r;e++)if(t[e].pin!==0)return;if(te!==0){for(let e=0;e<=i;e++)h.subarray(m[e],m[e+1]).reverse();M(),(C()>w||j()>=te)&&h.set(T)}}}function fht(e,t,n){return e.W[n]/2+(e.KIND[n]===0?t.nodeSep:t.edgeSep)/2}function pht(e,t){let{n,maxRank:r,W:i,KIND:a,EF:o,ET:s,EFD:c,ETD:l,succStart:u,succE:d,predStart:f,predE:p,layerStart:m,order:h,pos:g}=e,_=o.length,v=new Float64Array(n);for(let r=0;r<n;r++)v[r]=fht(e,t,r);let y=new Int32Array(_);for(let e=0;e<_;e++)y[e]=g[s[e]];for(let e=0;e<n;e++)u[e+1]-u[e]>1&&Qmt(d,u[e],u[e+1],y);for(let e=0;e<_;e++)y[e]=g[o[e]];for(let e=0;e<n;e++)f[e+1]-f[e]>1&&Qmt(p,f[e],f[e+1],y);let b=new Uint8Array(_);for(let e=1;e<=r;e++){let t=m[e]-m[e-1],n=m[e],r=m[e+1],i=0,s=n;for(let e=n;e<r;e++){let n=h[e],c=-1;if(Kq(a[n])){let e=o[p[f[n]]];Kq(a[e])&&(c=e)}let l=c>=0?g[c]:t;if(c>=0||e===r-1){for(let t=s;t<=e;t++){let e=h[t],n=Kq(a[e]);for(let t=f[e];t<f[e+1];t++){let e=p[t],r=g[o[e]];(r<i||l<r)&&!(n&&Kq(a[o[e]]))&&(b[e]=1)}}s=e+1,i=l}}}let x=[],S=new Int32Array(n),C=new Int32Array(n),w=new Float64Array(n),T=new Int32Array(n),E=new Int32Array(n),D=new Float64Array(n),O=new Int32Array(n),k=new Int32Array(n+1),A=new Int32Array(n),j=new Int32Array(n),M=new Int32Array(n);for(let e=0;e<4;e++){let t=e<2,i=(e&1)==1,a=t?f:u,_=t?p:d,y=t?o:s,N=t?l:c,P=t?c:l;for(let e=0;e<n;e++)S[e]=e,C[e]=e,w[e]=0;for(let e=0;e<=r;e++){let n=t?e:r-e,o=m[n],s=m[n+1],c=t?n-1:n+1,l=c>=0&&c<=r?m[c+1]-m[c]-1:0,u=-1;for(let e=i?s-1:o;i?e>=o:e<s;i?e--:e++){let t=h[e],n=a[t],r=a[t+1]-n;if(r===0)continue;let o=n+(r-1>>1),s=n+(r>>1);for(let e=0;e<2&&(e!==1||o!==s);e++){let n=_[e===0===i?s:o],r=y[n],a=i?l-g[r]:g[r];C[t]===t&&u<a&&b[n]===0&&(C[r]=t,C[t]=S[t]=S[r],w[t]=w[r]+P[n]-N[n],u=a)}}}let F=0;O.fill(0),k.fill(0);for(let e=0;e<=r;e++){let t=m[e],n=m[e+1];for(let e=t+1;e<n;e++){let t=i?h[e]:h[e-1],n=i?h[e-1]:h[e],r=v[t]+v[n];T[F]=S[t],E[F]=S[n],D[F]=i?r-w[t]+w[n]:r+w[t]-w[n],O[S[n]]++,k[S[t]+1]++,F++}}for(let e=0;e<n;e++)k[e+1]+=k[e];j.set(k.subarray(0,n));for(let e=0;e<F;e++)A[j[T[e]]++]=e;let ee=new Float64Array(n),te=0;for(let e=0;e<n;e++)S[e]===e&&O[e]===0&&(M[te++]=e);for(let e=0;e<te;e++){let t=M[e];for(let e=k[t];e<k[t+1];e++){let n=A[e],r=E[n];ee[t]+D[n]>ee[r]&&(ee[r]=ee[t]+D[n]),--O[r]===0&&(M[te++]=r)}}for(let e=te-1;e>=0;e--){let t=M[e],n=1/0;for(let e=k[t];e<k[t+1];e++){let t=A[e],r=ee[E[t]]-D[t];r<n&&(n=r)}n!==1/0&&n>ee[t]&&(ee[t]=n)}let I=new Float64Array(n);for(let e=0;e<n;e++)I[e]=(i?-ee[S[e]]:ee[S[e]])+w[e];x.push(I)}let N=0,P=1/0,F=[],ee=[];for(let e=0;e<4;e++){let t=1/0,r=-1/0,a=x[e];for(let e=0;e<n;e++){let n=i[e]/2;a[e]-n<t&&(t=a[e]-n),a[e]+n>r&&(r=a[e]+n)}F.push(t),ee.push(r),r-t<P&&(P=r-t,N=e)}for(let e=0;e<4;e++){let t=e&1?ee[N]-ee[e]:F[N]-F[e];if(t!==0){let r=x[e];for(let e=0;e<n;e++)r[e]+=t}}let te=new Float64Array(n);for(let e=0;e<n;e++){let t=x[0][e],n=x[1][e],r=x[2][e],i=x[3][e],a;t>n&&(a=t,t=n,n=a),r>i&&(a=r,r=i,i=a),t>r&&(a=t,t=r,r=a),n>i&&(a=n,n=i,i=a),n>r&&(a=n,n=r,r=a),te[e]=(n+r)/2}return te}function Xq(e){return e===`BT`||e===`LR`||e===`RL`?e:`TB`}var mht=4e4;function Zq(e,t,n,r){for(let t of e)t.x+=n,t.y+=r;for(let e of t){for(let t=0;t<e.route.length;t+=3)e.route[t]+=n,e.route[t+1]+=r;e.labelX+=n,e.labelY+=r}}function Qq(e,t,n=-1){return{w:e,h:t,parent:n,isGroup:!1,dir:void 0,padX:0,padTop:0,padBottom:0,minW:0,seq:0,span:0,x:0,y:0}}function hht(e){return e===`TB`?0:e===`BT`?2:e===`LR`?3:1}function $q(e){return e+2&3}function eJ(e,t,n,r){let i=e.length,a=/* @__PURE__ */ new Map,o=[],s=(e,t)=>{let n={id:e,dir:t,items:[],edges:[],ports:[],portOf:/* @__PURE__ */ new Map,routes:/* @__PURE__ */ new Map,x:0,y:0};return a.set(e,n),n},c=s(-1,n),l=[];for(let e=0;e<i;e++)l.push([]);let u=[];for(let t=0;t<i;t++){let n=e[t].parent;n>=0&&n<i&&n!==t&&e[n].isGroup?l[n].push(t):(e[t].parent=-1,u.push(t))}c.items=u,o.push(c);let d=new Int32Array(i),f=new Uint8Array(i),p=t=>{for(let n=t;n<o.length;n++){let t=o[n];for(let n of t.items)if(f[n]=1,d[n]=t.id<0?0:d[t.id]+1,e[n].isGroup){let r=s(n,e[n].dir??t.dir);r.items=l[n],o.push(r)}}};p(0);for(let t=0;t<i;t++){if(f[t])continue;let r=e[t].parent;if(l[r]=l[r].filter(e=>e!==t),e[t].parent=-1,c.items.push(t),f[t]=1,d[t]=0,e[t].isGroup){let r=o.length,i=s(t,e[t].dir??n);i.items=l[t],o.push(i),p(r)}}for(let t=o.length-1;t>0;t--){let n=o[t],r=1/0;for(let t of n.items)e[t].seq<r&&(r=e[t].seq);r!==1/0&&(e[n.id].seq=r)}for(let t of o)t.items.sort((t,n)=>e[t].seq-e[n].seq||t-n);let m=0;for(let n of t){let t=n.src,r=n.dst,i=0;for(;d[t]>d[r];i++)t=e[t].parent;for(;d[r]>d[t];i++)r=e[r].parent;for(;t!==r&&e[t].parent!==e[r].parent;i+=2)t=e[t].parent,r=e[r].parent;t!==r&&(m+i>mht?(n.src=t,n.dst=r):m+=i)}let h=[],g=[];for(let n=0;n<t.length;n++){let r=t[n];if(r.route=[],r.src===r.dst){h.push(n);continue}let i=r.src,o=r.dst,s=[],c=[];for(;d[i]>d[o];)s.push(i),i=e[i].parent;for(;d[o]>d[i];)c.push(o),o=e[o].parent;if(i===o)g.push(n);else{for(;e[i].parent!==e[o].parent;)s.push(i),c.push(o),i=e[i].parent,o=e[o].parent;a.get(e[i].parent).edges.push({e:n,a:i,b:o});for(let[t,r]of[[s,!0],[c,!1]])for(let i of t){let t=a.get(e[i].parent),o={e:n,inner:i,out:r,side:0,px:0,py:0,route:[]};t.ports.push(o),t.portOf.set(n*2+ +!r,o)}}}let _=new Int32Array(i),v=(e,t,n)=>(n?t.src:t.dst)!==e,y=(n,r)=>{let i=n.dir===`TB`||n.dir===`BT`,o=hht(n.dir),s=[],c=[];n.items.forEach((t,n)=>{_[t]=n;let a=e[t],o=r?Hq(i?a.w:a.h,i?a.h:a.w):Hq(0,0);o.span=a.isGroup?Math.min(a.span,o.w-2*a.padX):a.span,s.push(o)});let l=(n,r,i)=>e[n].isGroup&&v(n,t[r],i),u=(n,o,s)=>{if(!r||!e[n].isGroup||!v(n,t[o],s))return 0;let c=a.get(n).portOf.get(o*2+ +!s);return i?c.px-e[n].w/2:c.py-e[n].h/2};for(let e of n.edges){let n=t[e.e],a=Uq(_[e.a],_[e.b],n.minlen);r&&(a.labelW=i?n.labelW:n.labelH,a.labelH=i?n.labelH:n.labelW,a.tailDx=u(e.a,e.e,!0),a.headDx=u(e.b,e.e,!1),a.tailFixed=l(e.a,e.e,!0),a.headFixed=l(e.b,e.e,!1)),c.push(a)}let d=new Int32Array(n.ports.length).fill(-1);return n.ports.forEach((e,t)=>{if(e.side===o||e.side===$q(o)){let n=s.length;s.push(Hq(0,0,e.side===o?3:4)),d[t]=n;let r=e.out?Uq(_[e.inner],n):Uq(n,_[e.inner]);e.out?(r.tailDx=u(e.inner,e.e,!0),r.tailFixed=l(e.inner,e.e,!0)):(r.headDx=u(e.inner,e.e,!1),r.headFixed=l(e.inner,e.e,!1)),c.push(r)}else s[_[e.inner]].pin=e.side===0||e.side===3?-1:1}),{lnodes:s,ledges:c,dummies:d}};for(let n of o){for(let r of n.ports)e[r.inner].isGroup&&v(r.inner,t[r.e],r.out)&&(a.get(r.inner).portOf.get(r.e*2+ +!r.out).side=r.side);if(n.edges.length===0)continue;let r=!1;for(let i of n.edges){let n=t[i.e];(e[i.a].isGroup&&n.src!==i.a||e[i.b].isGroup&&n.dst!==i.b)&&(r=!0)}if(!r)continue;let{lnodes:i,ledges:o}=y(n,!1);qq(i,o),Jq(i,o,1);let s=hht(n.dir);n.edges.forEach((n,r)=>{let i=t[n.e],c=!o[r].reversed;e[n.a].isGroup&&i.src!==n.a&&(a.get(n.a).portOf.get(n.e*2).side=c?$q(s):s),e[n.b].isGroup&&i.dst!==n.b&&(a.get(n.b).portOf.get(n.e*2+1).side=c?s:$q(s))})}let b={width:0,height:0};for(let n=o.length-1;n>=0;n--){let i=o[n],s=i.id>=0?e[i.id]:void 0,c=i.dir===`TB`||i.dir===`BT`,l=i.dir===`BT`||i.dir===`RL`,{lnodes:u,ledges:d,dummies:f}=y(i,!0),p=$mt(u,d,r),m=c?p.width:p.height,h=c?p.height:p.width,g=s?s.padX:0,_=s?s.padTop:0,x=Math.max(m+2*g,s?s.minW:0),S=h+_+(s?s.padBottom:0),C=(x-m)/2,w=_,T=(e,t)=>C+(c?e:l?p.height-t:t),E=(e,t)=>w+(c?l?p.height-t:t:e),D=+!c,O=e=>{let t=[];for(let n=0;n<e.length;n+=2)t.push(T(e[n],e[n+1]),E(e[n],e[n+1]),D);return t};i.items.forEach((t,n)=>{e[t].x=T(u[n].x,u[n].y),e[t].y=E(u[n].x,u[n].y)}),i.edges.forEach((e,n)=>{let r=d[n];i.routes.set(e.e,O(r.points));let a=t[e.e];a.labelW>0&&(a.labelX=T(r.labelX,r.labelY),a.labelY=E(r.labelX,r.labelY))});let k=i.edges.length;i.ports.forEach((n,r)=>{let i=e[n.inner];if(f[r]>=0){let e=O(d[k++].points),t=n.out?e.length-3:0,r=e[t],i=e[t+1];n.side===0?i=0:n.side===2?i=S:r=n.side===3?0:x,n.out?e.push(r,i,D):e.unshift(r,i,D),n.px=r,n.py=i,n.route=e;return}let o=i.x,s=i.y;if(i.isGroup&&v(n.inner,t[n.e],n.out)){let e=a.get(n.inner).portOf.get(n.e*2+ +!n.out);o+=e.px-i.w/2,s+=e.py-i.h/2}else n.side===0?s-=i.h/2:n.side===2?s+=i.h/2:n.side===3?o-=i.w/2:o+=i.w/2;let c=o,l=s;n.side===0?l=0:n.side===2?l=S:c=n.side===3?0:x;let u=n.side===0||n.side===2?0:1;n.px=c,n.py=l,n.route=n.out?[o,s,u,c,l,u]:[c,l,u,o,s,u]}),s?(s.w=x,s.h=S):b={width:x,height:S}}for(let t of o){let n=t.x,r=t.y;for(let i of t.items){let t=e[i];if(t.x+=n,t.y+=r,t.isGroup){let e=a.get(i);e.x=t.x-t.w/2,e.y=t.y-t.h/2}}}let x=(e,t,n,r)=>{for(let i=0;i<t.length;i+=3){let a=t[i]+n,o=t[i+1]+r,s=e.length;s>=3&&Math.abs(e[s-3]-a)<.01&&Math.abs(e[s-2]-o)<.01||e.push(a,o,t[i+2])}};for(let n of o)for(let r of n.edges){let i=t[r.e],o=[],s=[];for(let t=i.src;e[t].parent!==n.id;t=e[t].parent)s.push(a.get(e[t].parent));for(let e of s)x(o,e.portOf.get(r.e*2).route,e.x,e.y);x(o,n.routes.get(r.e),n.x,n.y);let c=[];for(let t=i.dst;e[t].parent!==n.id;t=e[t].parent)c.push(a.get(e[t].parent));for(let e=c.length-1;e>=0;e--)x(o,c[e].portOf.get(r.e*2+1).route,c[e].x,c[e].y);i.route=o,i.labelW>0&&(i.labelX+=n.x,i.labelY+=n.y)}for(let n of g){let r=t[n],i=e[r.src],a=e[r.dst];r.route=[i.x,i.y,0,a.x,a.y,0],r.labelX=(i.x+a.x)/2,r.labelY=(i.y+a.y)/2}for(let n of h){let r=t[n],i=e[r.src];r.labelX=i.x+i.w/2+28+r.labelW/2,r.labelY=i.y}return b}function tJ(e,t){for(let n=0;n<t.length;n+=3){let r=Math.round(t[n+1]),i=e.get(r);i?i.push(t[n]):e.set(r,[t[n]])}}function nJ(e,t,n,r){if(t===0)return e.x;let i=e.y-e.h/2,a=e.x-e.w/2,o=t/2,s=[a+r-6+o,e.x,a+e.w-r+6-o],c=n.get(Math.round(i));if(c===void 0)return s[0];let l=s[0],u=-1;for(let t of s){let n=1/0;for(let r of c)r>a&&r<a+e.w&&(n=Math.min(n,Math.abs(r-t)-o));if(n>=6)return t;n>u+.5&&(u=n,l=t)}return l}function ght(e,t,n,r){let i=t>0?r.get(Math.round(e.y-e.h/2)):void 0;if(i===void 0)return!1;let a=e.x-e.w/2;for(let r of i)if(r>a&&r<a+e.w&&Math.abs(r-n)<t/2+4)return!0;return!1}function _ht(e,t,n,r,i,a,o,s){let c=1;for(let e=a[o].parent;e>=0&&c<8;e=a[e].parent)c++;let l=`color-mix(in srgb,var(--_a) ${K(100*(1-.5**c))}%,var(--_bg))`;return`<g class="pele-cluster-title" data-id="${i}">`+gq(e,t,n,` fill="none" stroke="${l}" stroke-width="5" stroke-linejoin="round"`,s)+gq(e,t,n,r,s)+`</g>`}var rJ=8,vht=12,iJ=.62,aJ=6;function yht(){let e=/* @__PURE__ */ new Map;return{add(t,n,r){let i=sJ(r);n>=0&&i>0&&i+aJ>(e.get(t*4+n)??0)&&e.set(t*4+n,i+aJ)},of:(t,n)=>n>=0?e.get(t*4+n)??0:0}}function oJ(e,t,n,r,i=n>0?n+aJ:0,a=r>0?r+aJ:0){let o=t===`linear`,s=t===`step`||t===`stepBefore`||t===`stepAfter`,c=[],l=[],u=[],d=(e,t,n,r)=>Math.abs(e-n)<.01&&Math.abs(t-r)<.01;for(let n=0;n<e.length;n+=3){let r=e[n],i=e[n+1],a=e[n+2],o=c.length-1;if(s&&o>=0&&Math.abs(r-c[o])>=.01&&Math.abs(i-l[o])>=.01){let e=c[o],n=l[o],s=t===`stepBefore`?n:t===`stepAfter`?i:(n+i)/2,f=t===`stepBefore`?e:t===`stepAfter`?r:(e+r)/2,p=a===0?[e,s,r,s]:[f,n,f,i];for(let t=0;t<4;t+=2)d(p[t],p[t+1],e,n)||d(p[t],p[t+1],r,i)||(c.push(p[t]),l.push(p[t+1]),u.push(a))}c.push(r),l.push(i),u.push(a)}let f=c.length-1,p=e=>Math.abs(c[e]-c[e-1])<.01||Math.abs(l[e]-l[e-1])<.01,m=e=>o||p(e),h=(e,t,n)=>{if(!m(Math.max(e,t)))return n===0?[0,Math.sign(l[t]-l[e])||1]:[Math.sign(c[t]-c[e])||1,0];let r=c[t]-c[e],i=l[t]-l[e],a=Math.hypot(r,i)||1;return[r/a,i/a]},[g,_]=h(0,1,u[1]),[v,y]=h(f-1,f,u[f]),b=c[0],x=l[0],S=c[f],C=l[f];c[0]+=g*n,l[0]+=_*n,c[f]-=v*r,l[f]-=y*r;let w=e=>Math.abs(c[e]-c[e-1])+Math.abs(l[e]-l[e-1]),T=e=>!o&&e>0&&e<f&&p(e)&&p(e+1)&&w(e)>=.01&&w(e+1)>=.01&&Math.abs(c[e]-c[e-1])<.01!=Math.abs(c[e+1]-c[e])<.01,E=(e,t,n)=>Math.abs(c[e]-c[e-1])*Math.abs(t)+Math.abs(l[e]-l[e-1])*Math.abs(n),D=(e,t,n)=>{let r=Math.min(Math.max(0,e-aJ-t),n/4);return r+Math.min(e-t-r,(n-r)/4)},O=a>r&&(!m(f)||T(f-1))?D(a,r,E(f,v,y)):0,k=i>n&&(!m(1)||T(1))?D(i,n,E(1,g,_)):0;O>=1&&(c.splice(f,0,c[f]-v*O),l.splice(f,0,l[f]-y*O),u.splice(f,0,u[f]),f++),k>=1&&(c.splice(1,0,c[0]+g*k),l.splice(1,0,l[0]+_*k),u.splice(1,0,u[1]),f++);let A=`M${K(c[0])},${K(l[0])}`,j=c[0],M=l[0],N=(e,t)=>{d(e,t,j,M)||(A+=`L${K(e)},${K(t)}`,j=e,M=t)};for(let e=1;e<=f;e++){let t=c[e],n=l[e];if(!m(e)){let r=u[e]===0,i=r?n-M:t-j,a=Math.abs(i)*rht(r?t-j:n-M,i),o=r?0:Math.sign(i)*a,s=r?Math.sign(i)*a:0;A+=`C${K(j+o)},${K(M+s)} ${K(t-o)},${K(n-s)} ${K(t)},${K(n)}`,j=t,M=n;continue}if(!T(e)){if(e<f&&p(e)&&p(e+1)&&(t-c[e-1])*(c[e+1]-t)+(n-l[e-1])*(l[e+1]-n)>0)continue;N(t,n);continue}let r=T(e-1)?w(e)/2:w(e),i=T(e+1)?w(e+1)/2:w(e+1);s&&(r=i=Math.min(vht,r,i));let[a,o]=h(e-1,e,u[e]),[d,g]=h(e,e+1,u[e+1]);N(t-a*r,n-o*r),j=t+d*i,M=n+g*i,A+=s?`Q${K(t)},${K(n)} ${K(j)},${K(M)}`:`C${K(t-a*r*(1-iJ))},${K(n-o*r*(1-iJ))} ${K(t+d*i*(1-iJ))},${K(n+g*i*(1-iJ))} ${K(j)},${K(M)}`}return{d:A,sx:b,sy:x,sdx:-g,sdy:-_,ex:S,ey:C,edx:v,edy:y}}function sJ(e){return e===`arrow_point`?rJ-1:e===`arrow_circle`?rJ:e===`arrow_cross`?4:0}function cJ(e,t,n,r,i,a){let o=-i,s=r;if(e===`arrow_point`){let e=t-r*rJ,c=n-i*rJ,l=rJ*.42;return`<path class="pele-marker" d="M${K(t)},${K(n)}L${K(e+o*l)},${K(c+s*l)}L${K(e-o*l)},${K(c-s*l)}Z" fill="${a}" stroke="none"/>`}if(e===`arrow_circle`)return`<circle class="pele-marker" cx="${K(t-r*4)}" cy="${K(n-i*4)}" r="3.5" fill="${a}" stroke="none"/>`;if(e===`arrow_cross`){let e=t-r*4,a=n-i*4,c=3.5,l=(r+o)*c,u=(i+s)*c,d=(r-o)*c,f=(i-s)*c;return`<path class="pele-marker" d="M${K(e-l)},${K(a-u)}L${K(e+l)},${K(a+u)}M${K(e-d)},${K(a-f)}L${K(e+d)},${K(a+f)}"/>`}return``}function lJ(e,t,n,r,i,a){let o=t.width+8,s=t.height;return`<g class="pele-edge-label" data-id="${mq(e)}"><rect x="${K(n-o/2)}" y="${K(r-s/2)}" width="${K(o)}" height="${K(s)}" rx="3" fill="var(--_bg)"/>`+gq(t,n,r,i,a)+`</g>`}function uJ(e,t,n,r,i,a,o,s){let c=(i?t:n)/2,l=Math.min(c-4,8+r*6),u=a+r*8,d=Math.hypot(u,l)||1,f=(r,a)=>i?`${K(e.x+a)},${K(e.y+n/2+r)}`:`${K(e.x+t/2+r)},${K(e.y+a)}`,p=u/d*o,m=l/d*o;return i?(s.labelX=e.x,s.labelY=e.y+n/2+u+4+s.labelH/2):(s.labelX=e.x+t/2+u+4+s.labelW/2,s.labelY=e.y),{d:`M${f(0,-l)}C${f(u,-l*2)} ${f(u,l*2)} ${f(p,l+m)}`,sx:i?e.x-l:e.x+t/2,sy:i?e.y+n/2:e.y-l,sdx:i?0:-1,sdy:i?-1:0,ex:i?e.x+l:e.x+t/2,ey:i?e.y+n/2:e.y+l,edx:i?-l/d:-u/d,edy:i?-u/d:-l/d}}var bht=`--_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)`,dJ=`var(--_fm)`,fJ=`var(--pele-radius,4px)`,pJ=`var(--pele-critical,#e45756)`,xht=String.raw`(?:"[^"'\\\n<>{}();:@]*"|'[^"'\\\n<>{}();:@]*'|[\p{L}\p{N}_-][\p{L}\p{N}_ .-]*)`,Sht=new RegExp(String.raw`^\s*${xht}(?:\s*,\s*${xht})*\s*$`,`u`);function Cht(e,t){return e&&Sht.test(e)?e:t}function wht(e,t,n){return`;--_fm:var(--pele-font-mono,${Cht(n,`monospace`)});font:${e}px sans-serif;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;font-family:var(--pele-font,${Cht(t,`sans-serif`)})`}var Tht=/* @__PURE__ */ new Set([`fill`,`fill-opacity`,`stroke`,`stroke-width`,`stroke-dasharray`,`stroke-dashoffset`,`stroke-linecap`,`stroke-linejoin`,`stroke-opacity`,`opacity`,`rx`,`ry`]),Eht=/* @__PURE__ */ new Set([`color`,`font-size`,`font-family`,`font-weight`,`font-style`,`text-decoration`,`letter-spacing`,`word-spacing`,`opacity`]),Dht=/url\s*\(|expression\s*\(|javascript:|[<>{};\\]|@import|image-set|\/\*/i,Oht={shape:``,line:``,text:``,stroke:void 0,bold:!1,italic:!1,fontSize:void 0};function mJ(e){if(e.length===0)return Oht;let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map;for(let r of e){let e=r.indexOf(`:`);if(e<=0)continue;let i=r.slice(0,e).trim().toLowerCase(),a=r.slice(e+1).replace(/!important/gi,``).trim();a===``||Dht.test(a)||(Tht.has(i)&&t.set(i,a),Eht.has(i)&&n.set(i===`color`?`fill`:i,a))}if(t.size===0&&n.size===0)return Oht;let r=``,i=``;for(let[e,n]of t)r+=`${e}:${n};`,e!==`fill`&&e!==`fill-opacity`&&(i+=`${e}:${n};`);let a=``;for(let[e,t]of n)a+=`${e}:${t};`;let o=n.get(`font-weight`),s=n.get(`font-size`),c=s&&/^[\d.]+(px)?$/.test(s)?parseFloat(s):void 0;return{shape:r?` style="${pq(r)}"`:``,line:i?` style="${pq(i)}"`:``,text:a?` style="${pq(a)}"`:``,stroke:t.get(`stroke`),bold:o===`bold`||o===`bolder`||Number(o)>=600,italic:n.get(`font-style`)===`italic`,fontSize:c!==void 0&&c>0&&c<=200?c:void 0}}var kht=/[^\w-]+/g;function hJ(e){let t=e.replace(kht,` `).trim();return t===``?``:` `+t}var Aht=[`#4c78a8`,`#f58518`,`#54a24b`,`#e45756`,`#72b7b2`,`#eeca3b`,`#b279a2`,`#9d755d`];function gJ(e){let t=(e%8+8)%8;return`var(--pele-series-${t+1},${Aht[t]})`}var _J=` rx="${fJ}"`,jht=/<rect\b[^>]*>/g;function Mht(e){return e.includes(_J)?e.replace(jht,e=>{let t=e.indexOf(_J);if(t<0)return e;let n=e.slice(0,t)+e.slice(t+_J.length),r=n.indexOf(` style="`);if(r>=0)return`${n.slice(0,r+8)}rx:var(--_r);${n.slice(r+8)}`;let i=n.endsWith(`/>`)?n.length-2:n.length-1;return`${n.slice(0,i)} style="rx:var(--_r)"${n.slice(i)}`}):e}var Nht=[[`--_tw`,`title`],[`--_hw`,`heading`],[`--_w`,`bold`]];function vJ(e,t,n,r,i,a,o){let s=pq(i.idPrefix??`pele`),c=``,l=``;a.accTitle&&(c+=`<title id="${s}-title">${mq(a.accTitle)}</title>`,l+=` aria-labelledby="${s}-title"`),a.accDescr&&(c+=`<desc id="${s}-desc">${mq(a.accDescr)}</desc>`,l+=` aria-describedby="${s}-desc"`);let u=i.responsive===!1?``:`max-width:100%;height:auto;`;o=Mht(o);let d=o.includes(`var(--_r)`)?`;--_r:${fJ}`:``;for(let[e,t]of Nht)o.includes(`var(${e})`)&&(d+=`;${e}:var(--pele-${t}-weight,bold)`);return`<svg xmlns="http://www.w3.org/2000/svg" class="pele pele-${e}" viewBox="0 0 ${t} ${n}" width="${t}" height="${n}" style="${u}${bht}${d}${pq(wht(r,i.fontFamily,i.fontFamilyMono))}" fill="var(--_fg)" role="graphics-document document" aria-roledescription="${e}"${l}>`+c+o+`</svg>`}var yJ=18,bJ=12,xJ=12,SJ=(e,t,n)=>(n?t:e)-2*xJ,CJ=e=>(t,n,r)=>r?0:t-2*e(n)-2*xJ;function wJ(e,t,n){let r=Math.min(1,Math.abs(e)/t);return n*(1-Math.sqrt(1-r*r))}var TJ=(e,t,n,r)=>n&1?wJ(r,t/2,e/2):wJ(r,e/2,t/2),EJ=(e,t,n)=>(n?t:e)*.6,Pht=(e,t,n,r)=>n&1?0:wJ(r,e/2,Math.min(12,Math.max(6,e/14))),DJ=(e,t)=>()=>({w:e,h:t,dy:0});function Fht(e,t,n){let r=Math.max(1.6*e+40,80),i=(t+10)/(1-(e+8)/r),a=i/2-10-t/2;return{w:r,h:i,dy:n?-a:a}}function OJ(e,t){return`<path d="${e}"${t}/>`}var kJ=(e,t,n)=>n&1?t/8:0,AJ=(e,t)=>({w:Math.max(e+2*yJ,2*yJ+12),h:t+2*bJ,dy:0});function jJ(e,t){let n=``;for(let t=0;t<e.length;t+=2)n+=(t?` `:``)+K(e[t])+`,`+K(e[t+1]);return`<polygon points="${n}"${t}/>`}function MJ(e,t,n,r=``){return`<rect x="${K(-e/2)}" y="${K(-t/2)}" width="${K(e)}" height="${K(t)}"${r}${n}/>`}var NJ=` rx="${fJ}"`,Iht={rect:{size:AJ,span:SJ,draw:(e,t,n)=>MJ(e,t,n,NJ)},rounded:{size:AJ,span:SJ,draw:(e,t,n)=>MJ(e,t,n,` rx="${K(Math.min(12,t/2))}"`)},stadium:{inset:(e,t,n,r)=>n&1?wJ(r,t/2,t/2):0,span:(e,t,n)=>n?t*.6:e-t,size:(e,t)=>{let n=t+2*bJ;return{w:e+n*.5+2*yJ-8,h:n,dy:0}},draw:(e,t,n)=>MJ(e,t,n,` rx="${K(t/2)}"`)},"fr-rect":{span:SJ,size:(e,t)=>({w:e+2*yJ+16,h:t+2*bJ,dy:0}),draw:(e,t,n,r)=>{let i=e/2-8;return MJ(e,t,n,NJ)+`<path d="M${K(-i)},${K(-t/2)}V${K(t/2)}M${K(i)},${K(-t/2)}V${K(t/2)}" fill="none"${r}/>`}},cyl:{inset:Pht,span:(e,t,n)=>n?t-2*xJ-12:e*.6,size:(e,t)=>{let n=Math.max(e+2*yJ,56),r=Math.min(12,Math.max(6,n/14));return{w:n,h:t+2*bJ+2*r,dy:r/2}},draw:(e,t,n,r)=>{let i=e/2,a=Math.min(12,Math.max(6,e/14)),o=-t/2+a,s=t/2-a;return`<path d="M${K(-i)},${K(o)}A${K(i)},${K(a)} 0 0 1 ${K(i)},${K(o)}V${K(s)}A${K(i)},${K(a)} 0 0 1 ${K(-i)},${K(s)}Z"${n}/><path d="M${K(-i)},${K(o)}A${K(i)},${K(a)} 0 0 0 ${K(i)},${K(o)}" fill="none"${r}/>`}},circle:{inset:TJ,span:EJ,size:(e,t)=>{let n=Math.max(Math.sqrt(e*e+t*t)+16,44);return{w:n,h:n,dy:0}},draw:(e,t,n)=>`<circle r="${K(e/2)}"${n}/>`},"dbl-circ":{inset:TJ,span:EJ,size:(e,t)=>{let n=Math.max(Math.sqrt(e*e+t*t)+26,54);return{w:n,h:n,dy:0}},draw:(e,t,n,r)=>`<circle r="${K(e/2)}"${n}/><circle r="${K(e/2-5)}" fill="none"${r}/>`},ellipse:{inset:TJ,span:EJ,size:(e,t)=>({w:e*1.3+2*yJ,h:t*1.2+2*bJ,dy:0}),draw:(e,t,n)=>`<ellipse rx="${K(e/2)}" ry="${K(t/2)}"${n}/>`},diam:{inset:(e,t,n,r)=>n&1?Math.abs(r)*e/t:Math.abs(r)*t/e,span:(e,t,n)=>(n?t:e)*.6,size:(e,t)=>{let n=e+16,r=t+8;return{w:n+1.6*r,h:n/1.6+r,dy:0}},draw:(e,t,n)=>jJ([0,-t/2,e/2,0,0,t/2,-e/2,0],n)},hex:{inset:(e,t,n,r)=>n&1?Math.abs(r)/2:0,span:(e,t,n)=>n?t*.5:e-t/2-xJ,size:(e,t)=>{let n=t+2*bJ;return{w:e+2*yJ+n/2,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return jJ([-e/2+r,-t/2,e/2-r,-t/2,e/2,0,e/2-r,t/2,-e/2+r,t/2,-e/2,0],n)}},odd:{inset:(e,t,n)=>n===3?t/4:0,span:CJ(()=>0),size:(e,t)=>{let n=t+2*bJ;return{w:e+2*yJ+n/4,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return jJ([-e/2,-t/2,e/2,-t/2,e/2,t/2,-e/2,t/2,-e/2+r,0],n)}},"lean-r":{inset:kJ,span:CJ(e=>e/4),size:(e,t)=>{let n=t+2*bJ;return{w:e+2*yJ+n/2,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return jJ([-e/2+r,-t/2,e/2,-t/2,e/2-r,t/2,-e/2,t/2],n)}},"lean-l":{inset:kJ,span:CJ(e=>e/4),size:(e,t)=>{let n=t+2*bJ;return{w:e+2*yJ+n/2,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return jJ([-e/2,-t/2,e/2-r,-t/2,e/2,t/2,-e/2+r,t/2],n)}},"trap-b":{inset:kJ,span:CJ(e=>e/4),size:(e,t)=>{let n=t+2*bJ;return{w:e+2*yJ+n/2,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return jJ([-e/2+r,-t/2,e/2-r,-t/2,e/2,t/2,-e/2,t/2],n)}},"trap-t":{inset:kJ,span:CJ(e=>e/4),size:(e,t)=>{let n=t+2*bJ;return{w:e+2*yJ+n/2,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return jJ([-e/2,-t/2,e/2,-t/2,e/2-r,t/2,-e/2+r,t/2],n)}},text:{span:SJ,size:(e,t)=>({w:e+8,h:t+8,dy:0}),draw:(e,t)=>MJ(e,t,` fill="none" stroke="none"`)},"sm-circ":{noLabel:!0,inset:TJ,span:EJ,size:DJ(14,14),draw:(e,t,n)=>`<circle r="${K(e/2)}"${n}/>`},"f-circ":{noLabel:!0,inset:TJ,span:EJ,size:DJ(14,14),draw:(e,t,n,r)=>`<circle r="${K(e/2)}" fill="var(--_l)"${r}/>`},"fr-circ":{noLabel:!0,inset:TJ,span:EJ,size:DJ(18,18),draw:(e,t,n,r)=>`<circle r="${K(e/2)}"${n}/><circle r="${K(e/2-4)}" fill="var(--_l)"${r}/>`},fork:{noLabel:!0,span:(e,t,n)=>(n?t:e)-8,size:DJ(72,8),draw:(e,t,n,r)=>MJ(e,t,` fill="var(--_l)"${r}`,` rx="2"`)},"notch-rect":{size:AJ,span:SJ,draw:(e,t,n)=>jJ([-e/2+10,-t/2,e/2,-t/2,e/2,t/2,-e/2,t/2,-e/2,-t/2+10],n)},"lin-rect":{span:SJ,size:(e,t)=>({w:e+2*yJ+8,h:t+2*bJ,dy:0}),draw:(e,t,n,r)=>MJ(e,t,n,NJ)+`<path d="M${K(-e/2+8)},${K(-t/2)}V${K(t/2)}" fill="none"${r}/>`},"div-rect":{span:SJ,size:(e,t)=>({w:e+2*yJ,h:t+2*bJ+8,dy:4}),draw:(e,t,n,r)=>MJ(e,t,n,NJ)+`<path d="M${K(-e/2)},${K(-t/2+8)}H${K(e/2)}" fill="none"${r}/>`},"win-pane":{span:SJ,size:(e,t)=>({w:e+2*yJ+8,h:t+2*bJ+8,dy:4}),draw:(e,t,n,r)=>MJ(e,t,n,NJ)+`<path d="M${K(-e/2+8)},${K(-t/2)}V${K(t/2)}M${K(-e/2)},${K(-t/2+8)}H${K(e/2)}" fill="none"${r}/>`},tri:{inset:(e,t,n)=>n&1?e/4:0,size:(e,t)=>Fht(e,t,!1),draw:(e,t,n)=>jJ([0,-t/2,e/2,t/2,-e/2,t/2],n)},"flip-tri":{inset:(e,t,n)=>n&1?e/4:0,size:(e,t)=>Fht(e,t,!0),draw:(e,t,n)=>jJ([-e/2,-t/2,e/2,-t/2,0,t/2],n)},"sl-rect":{inset:(e,t,n)=>n===0?5:0,size:(e,t)=>({w:e+2*yJ,h:t+2*bJ+10,dy:5}),draw:(e,t,n)=>jJ([-e/2,-t/2+10,e/2,-t/2,e/2,t/2,-e/2,t/2],n)},"notch-pent":{span:SJ,size:(e,t)=>({w:e+2*yJ,h:t+2*bJ,dy:0}),draw:(e,t,n)=>jJ([-e/2+10,-t/2,e/2-10,-t/2,e/2,-t/2+10,e/2,t/2,-e/2,t/2,-e/2,-t/2+10],n)},hourglass:{noLabel:!0,inset:(e,t,n)=>n&1?e/2:0,size:DJ(32,40),draw:(e,t,n)=>jJ([-e/2,-t/2,e/2,-t/2,-e/2,t/2,e/2,t/2],n)},delay:{size:(e,t)=>{let n=t+2*bJ;return{w:e+2*yJ+n/4,h:n,dy:0}},draw:(e,t,n)=>{let r=t/2;return`<path d="M${K(-e/2)},${K(-r)}H${K(e/2-r)}A${K(r)},${K(r)} 0 0 1 ${K(e/2-r)},${K(r)}H${K(-e/2)}Z"${n}/>`}},"h-cyl":{size:(e,t)=>{let n=t+2*bJ,r=Math.min(12,n/4);return{w:e+2*yJ+2*r,h:n,dy:0}},draw:(e,t,n,r)=>{let i=t/2,a=Math.min(12,t/4),o=-e/2+a,s=e/2-a;return`<path d="M${K(o)},${K(-i)}H${K(s)}A${K(a)},${K(i)} 0 0 1 ${K(s)},${K(i)}H${K(o)}A${K(a)},${K(i)} 0 0 1 ${K(o)},${K(-i)}Z"${n}/><path d="M${K(s)},${K(-i)}A${K(a)},${K(i)} 0 0 0 ${K(s)},${K(i)}" fill="none"${r}/>`}},"cross-circ":{noLabel:!0,inset:TJ,span:EJ,size:DJ(44,44),draw:(e,t,n,r)=>{let i=e/2,a=i*Math.SQRT1_2;return`<circle r="${K(i)}"${n}/><path d="M${K(-a)},${K(-a)}L${K(a)},${K(a)}M${K(a)},${K(-a)}L${K(-a)},${K(a)}" fill="none"${r}/>`}},"st-rect":{span:(e,t,n)=>(n?t:e)-2*xJ-8,size:(e,t)=>({w:e+2*yJ+8,h:t+2*bJ+8,dy:4}),draw:(e,t,n)=>{let r=e-8,i=t-8,a=``;for(let o=0;o<3;o++){let s=-e/2+(2-o)*4,c=-t/2+o*4;a+=`<rect x="${K(s)}" y="${K(c)}" width="${K(r)}" height="${K(i)}"${NJ}${n}/>`}return a}},doc:{inset:(e,t,n)=>n===2?10:0,size:(e,t)=>({w:e+2*yJ,h:t+2*bJ+10,dy:-5}),draw:(e,t,n)=>FJ(e,t,n)},flag:{inset:(e,t,n)=>n&1?0:8,size:(e,t)=>({w:e+2*yJ,h:t+2*bJ+16,dy:0}),draw:(e,t,n)=>{let r=e/2,i=t/2-8,a=e/4;return`<path d="M${K(-r)},${K(-i)}q${K(a)},-10 ${K(2*a)},0t${K(2*a)},0V${K(i)}q${K(-a)},10 ${K(-2*a)},0t${K(-2*a)},0Z"${n}/>`}},datastore:{size:AJ,span:SJ,draw:(e,t,n,r)=>MJ(e,t,n.replace(`stroke="var(--_b)"`,`stroke="none"`))+`<path d="M${K(-e/2)},${K(-t/2)}H${K(e/2)}M${K(-e/2)},${K(t/2)}H${K(e/2)}" fill="none"${r}/>`},folder:{size:(e,t)=>({w:Math.max(e+2*yJ,64),h:t+2*bJ+8,dy:4}),draw:(e,t,n)=>{let r=e/2,i=t/2,a=Math.min(e*.4,48);return OJ(`M${K(-r)},${K(-i)}H${K(-r+a)}L${K(-r+a+8)},${K(-i+8)}H${K(r)}V${K(i)}H${K(-r)}Z`,n)}},bucket:{size:(e,t)=>({w:e+2*yJ+20,h:t+2*bJ+10,dy:3}),inset:(e,t,n)=>n&1?t/12:0,draw:(e,t,n,r)=>{let i=e/2,a=t/2,o=t/6;return OJ(`M${K(-i)},${K(-a+5)}A${K(i)},${K(5)} 0 0 1 ${K(i)},${K(-a+5)}L${K(i-o)},${K(a-5)}A${K(i-o)},${K(5)} 0 0 1 ${K(-i+o)},${K(a-5)}Z`,n)+`<path d="M${K(-i)},${K(-a+5)}A${K(i)},${K(5)} 0 0 0 ${K(i)},${K(-a+5)}" fill="none"${r}/>`}},console:{span:SJ,size:(e,t)=>({w:Math.max(e+2*yJ,72),h:t+2*bJ+12,dy:6}),draw:(e,t,n,r)=>MJ(e,t,n,NJ)+`<path d="M${K(-e/2)},${K(-t/2+12)}H${K(e/2)}M${K(-e/2+7)},${K(-t/2+4)}l3,2.5l-3,2.5M${K(-e/2+13)},${K(-t/2+9)}h4" fill="none"${r}/>`},browser:{span:SJ,size:(e,t)=>({w:Math.max(e+2*yJ,72),h:t+2*bJ+12,dy:6}),draw:(e,t,n,r)=>{let i=``;for(let n=0;n<3;n++)i+=`<circle cx="${K(-e/2+8+n*7)}" cy="${K(-t/2+6)}" r="1.5" fill="none"${r}/>`;return MJ(e,t,n,NJ)+`<path d="M${K(-e/2)},${K(-t/2+12)}H${K(e/2)}" fill="none"${r}/>`+i}},person:{size:(e,t)=>({w:Math.max(e+2*yJ,56),h:t+2*bJ+26,dy:13}),draw:(e,t,n)=>{let r=-t/2;return`<rect x="${K(-e/2)}" y="${K(r+26)}" width="${K(e)}" height="${K(t-26)}" rx="12"${n}/><circle cy="${K(r+14)}" r="13"${n}/>`}},bang:{size:(e,t)=>({w:e+2*yJ+28,h:t+2*bJ+24,dy:0}),inset:()=>3,draw:(e,t,n)=>{let r=[];for(let n=0;n<28;n++){let i=Math.PI*n/14-Math.PI/2,a=n%2==0?1:.82;r.push(e/2*Math.cos(i)*a,t/2*Math.sin(i)*a)}return jJ(r,n)}},cloud:{size:(e,t)=>({w:e+2*yJ+32,h:t+2*bJ+24,dy:0}),inset:(e,t,n)=>n&1?2:1,draw:(e,t,n)=>{let r=e/2,i=t/2,a=i*.55;return OJ(`M${K(-r+a)},${K(i)}A${K(a)},${K(a)} 0 0 1 ${K(-r+a*.6)},${K(-i*.1)}A${K(r*.42)},${K(i*.7)} 0 0 1 ${K(-r*.1)},${K(-i*.72)}A${K(r*.4)},${K(i*.62)} 0 0 1 ${K(r*.62)},${K(-i*.42)}A${K(a*1.05)},${K(a*1.05)} 0 0 1 ${K(r-a)},${K(i)}Z`,n)}},brace:{size:(e,t)=>({w:e+2*yJ+12,h:t+2*bJ,dy:0}),draw:(e,t,n,r)=>MJ(e,t,` fill="none" stroke="none"`)+PJ(-e/2+12,t,-1,r)},"brace-r":{size:(e,t)=>({w:e+2*yJ+12,h:t+2*bJ,dy:0}),draw:(e,t,n,r)=>MJ(e,t,` fill="none" stroke="none"`)+PJ(e/2-12,t,1,r)},braces:{size:(e,t)=>({w:e+2*yJ+24,h:t+2*bJ,dy:0}),draw:(e,t,n,r)=>MJ(e,t,` fill="none" stroke="none"`)+PJ(-e/2+12,t,-1,r)+PJ(e/2-12,t,1,r)},bolt:{noLabel:!0,size:DJ(36,56),inset:(e,t,n)=>n&1?e/4:0,draw:(e,t,n)=>jJ([e*.15,-t/2,-e/2,t*.08,-e*.05,t*.08,-e*.15,t/2,e/2,-t*.08,e*.05,-t*.08],n)},"lin-cyl":{inset:Pht,span:(e,t,n)=>n?t-2*xJ-20:e*.6,size:(e,t)=>{let n=Math.max(e+2*yJ,56),r=Math.min(12,Math.max(6,n/14));return{w:n,h:t+2*bJ+2*r+8,dy:r/2+4}},draw:(e,t,n,r)=>{let i=e/2,a=Math.min(12,Math.max(6,e/14)),o=-t/2+a,s=t/2-a,c=e=>`M${K(-i)},${K(e)}A${K(i)},${K(a)} 0 0 0 ${K(i)},${K(e)}`;return OJ(`M${K(-i)},${K(o)}A${K(i)},${K(a)} 0 0 1 ${K(i)},${K(o)}V${K(s)}A${K(i)},${K(a)} 0 0 1 ${K(-i)},${K(s)}Z`,n)+`<path d="${c(o)}${c(o+8)}" fill="none"${r}/>`}},"curv-trap":{size:(e,t)=>{let n=t+2*bJ;return{w:e+2*yJ+n*.6,h:n,dy:0}},draw:(e,t,n)=>{let r=e/2,i=t/2,a=t*.3;return OJ(`M${K(-r+a)},${K(-i)}H${K(r-a)}A${K(a)},${K(i)} 0 0 1 ${K(r-a)},${K(i)}H${K(-r+a)}L${K(-r)},0Z`,n)}},docs:{size:(e,t)=>({w:e+2*yJ+8,h:t+2*bJ+18,dy:-1}),inset:(e,t,n)=>n===2?10:0,draw:(e,t,n)=>{let r=``;for(let i=0;i<3;i++)r+=`<g transform="translate(${(1-i)*4},${(i-1)*4})">${FJ(e-8,t-8,n)}</g>`;return r}},"bow-rect":{size:(e,t)=>{let n=t+2*bJ;return{w:e+2*yJ+n*.4,h:n,dy:0}},inset:(e,t,n)=>n===1?t*.2:0,draw:(e,t,n)=>{let r=e/2,i=t/2,a=t*.2;return OJ(`M${K(-r+a)},${K(-i)}H${K(r)}A${K(a)},${K(i)} 0 0 0 ${K(r)},${K(i)}H${K(-r+a)}A${K(a)},${K(i)} 0 0 1 ${K(-r+a)},${K(-i)}Z`,n)}},"tag-rect":{size:AJ,span:SJ,draw:(e,t,n,r)=>MJ(e,t,n,NJ)+`<path d="M${K(e/2-12)},${K(t/2)}L${K(e/2)},${K(t/2-12)}" fill="none"${r}/>`},"tag-doc":{size:(e,t)=>({w:e+2*yJ,h:t+2*bJ+10,dy:-5}),inset:(e,t,n)=>n===2?10:0,draw:(e,t,n,r)=>FJ(e,t,n)+`<path d="M${K(e/2-12)},${K(t/2-14)}L${K(e/2)},${K(t/2-26)}" fill="none"${r}/>`},"lin-doc":{size:(e,t)=>({w:e+2*yJ+8,h:t+2*bJ+10,dy:-5}),inset:(e,t,n)=>n===2?10:0,draw:(e,t,n,r)=>FJ(e,t,n)+`<path d="M${K(-e/2+8)},${K(-t/2)}V${K(t/2-6)}" fill="none"${r}/>`},collapsedGroup:{size:(e,t)=>({w:e+2*yJ+8,h:t+2*bJ+8,dy:-2}),draw:(e,t,n)=>`<rect x="${K(-e/2+6)}" y="${K(-t/2+8)}" width="${K(e-12)}" height="${K(t-8)}"${NJ}${n}/><rect x="${K(-e/2)}" y="${K(-t/2)}" width="${K(e)}" height="${K(t-4)}"${NJ}${n}/>`}};function PJ(e,t,n,r){let i=t/2,a=6*n;return`<path d="M${K(e)},${K(-i)}q${K(a)},0 ${K(a)},6V-6q0,6 ${K(a)},6q${K(-a)},0 ${K(-a)},6V${K(i-6)}q0,6 ${K(-a)},6" fill="none"${r}/>`}function FJ(e,t,n){let r=e/2,i=-t/2,a=t/2-10,o=e/4;return`<path d="M${K(-r)},${K(i)}H${K(r)}V${K(a)}q${K(-o)},-12 ${K(-2*o)},0t${K(-2*o)},0Z"${n}/>`}var Lht=Iht.rect,IJ=new Map(Object.entries(Iht));function LJ(e,t,n){return(IJ.get(e)??Lht).size(t,n)}function RJ(e,t,n,r,i){return(IJ.get(e)??Lht).draw(t,n,r,i)}function zJ(e,t,n,r,i=0){return IJ.get(e)?.inset?.(t,n,r,i)??0}function Rht(e,t,n,r){return Math.max(0,IJ.get(e)?.span?.(t,n,r)??0)}function zht(e){return IJ.get(e)?.noLabel!==!0}function BJ(e,t,n){let r=e[t]-n.x,i=e[t+1]-n.y;return Math.abs(Math.abs(i)-n.h/2)<.5?i<0?0:2:Math.abs(Math.abs(r)-n.w/2)<.5?r<0?3:1:-1}function VJ(e,t,n,r){if(r.isGroup)return;let i=BJ(e,t,r);if(i===0||i===2){let a=zJ(n.shape,n.w,n.h,i,e[t]-r.x)+(r.h-n.h)/2;e[t+1]+=i===0?a:-a}else if(i>=0){let a=zJ(n.shape,n.w,n.h,i,e[t+1]-r.y)+(r.w-n.w)/2;e[t]+=i===3?a:-a}}var Bht=1.5,Vht=/<br\s*\/?>|\\n|\n/gi,Hht=/<\/?([a-zA-Z][\w-]*)(?:\s[^<>]*)?\/?>/y,Uht=/(fa[bklrs]?):fa-([\w-]+)/g,Wht=/[<\\\n*_]|fa[bklrs]?:fa-/,HJ=`\\u2e80-\\u9fff\\uf900-\\ufaff\\uff00-\\uff60`,Ght=`、。,.:;!?)]}」』】〕〉》〙〗ー…‥・ゝゞぁぃぅぇぉっゃゅょゎァィゥェォッャュョヮ,.:;!?)\\]}`,Kht=`([{「『【〔〈《〘〖([{`,qht=RegExp(`[${HJ}]`),Jht=RegExp(`\\s*(?:[${Kht}]*[${HJ}][${Ght}]*|[^\\s${HJ}]+[${Ght}]*)\\s*|\\s+`,`g`),Yht={lines:[],widths:[],width:0,height:0,size:0,lineHeight:0};function Xht(e){let t=e.split(`
|
|
983
|
+
`):e,{types:i,texts:a,starts:o,locs:s}=Omt(r),c=0,l,u=0,d=0,f=e=>{let t=i[c];throw t===1?FK(`agentflow`,r,o[c],``,!0):FK(`agentflow`,r,o[c],`Expecting ${e}, got '${mmt[t]}'`)},p=(e,t)=>({first_line:s[4*e],first_column:s[4*e+1],last_line:s[4*t+2],last_column:s[4*t+3]}),m=(e,t=``)=>(i[c]!==e&&f(`'${mmt[e]}'${t?`, `+t:``}`),a[c++]),h=()=>{zq[i[c]]===0&&f(Bq),c++},g=()=>{Fq[i[c]]===0&&f(`'NODE_STRING'`);let e=a[c++];for(;Fq[i[c]]===1;)e+=a[c++];return e},_=()=>{Iq[i[c]]===0&&f(`'NODE_STRING'`);let e=a[c++];for(;Iq[i[c]]===1;)e+=a[c++];return e},v=()=>{let e=i[c],t;if(e===11)t=`string`;else if(e===10)t=`markdown`;else if(e===46||e===62||e===53||e===69)t=`text`;else return f(`${kmt}, 'TAGEND', 'STR', 'MD_STR'`);let n=a[c++];for(;;){let e=i[c];if(e!==46&&e!==62&&e!==53&&e!==69)break;n+=a[c++]}return{text:n,type:t}},y=e=>{m(e,kmt)},b=()=>{let e=i[c],t;if(e===11)t=`string`;else if(e===10)t=`markdown`;else if(e===44||e===69)t=`text`;else return f(`'EDGE_TEXT', 'STR', 'MD_STR'`);let n=a[c++];for(;i[c]===44||i[c]===69;)n+=a[c++];return{text:n,type:t}},x=()=>{let e=i[c],t;if(e===11)t=`text`;else if(e===10)t=`markdown`;else if(Lq[e]===1)t=`text`;else return f(`'NODE_STRING', 'STR', 'MD_STR'`);let n=a[c++];for(;Lq[i[c]]===1;)n+=a[c++];return{text:n,type:t}},S=()=>{u=c;let e=a[c++];for(;i[c]===7;)e+=a[c++];return d=c-1,e},C=(e,n,r,i)=>{let a=p(r,i);t.addVertex(e,void 0,void 0,void 0,void 0,void 0,void 0,n,a),t.extendVertexMapping(e,a)},w=(e,n)=>{n.data!==void 0&&t.addVertex(e,void 0,void 0,void 0,void 0,void 0,void 0,n.data,p(n.dataFrom,n.dataTo))},T=()=>{let e=c,n=g(),r,a,o;switch(i[c]){case 74:c++,r=v(),y(73),a=`square`;break;case 57:c++,r=v(),y(56),a=`doublecircle`;break;case 72:c++,i[c]===72?(c++,r=v(),y(71),m(71),a=`circle`):(r=v(),y(71),a=`round`);break;case 47:c++,r=v(),y(45),a=`ellipse`;break;case 49:c++,r=v(),y(48),a=`stadium`;break;case 51:c++,r=v(),y(50),a=`subroutine`;break;case 52:{c++;let e=m(67);m(37);let t=m(67);m(70),r=v(),y(73),a=`rect`,o={[e]:t};break}case 55:c++,r=v(),y(54),a=`cylinder`;break;case 76:c++,i[c]===76?(c++,r=v(),y(75),m(75),a=`hexagon`):(r=v(),y(75),a=`diamond`);break;case 53:c++,r=v(),y(73),a=`odd`;break;case 60:c++,r=v(),i[c]===59?(c++,a=`lean_right`):(y(58),a=`trapezoid`);break;case 61:c++,r=v(),i[c]===58?(c++,a=`lean_left`):(y(59),a=`inv_trapezoid`)}return o===void 0?a===void 0?t.addVertex(n):t.addVertex(n,r,a):t.addVertex(n,r,a,void 0,void 0,void 0,o),t.addVertexMapping(n,r,a,p(e,c-1)),n},E=()=>{let e=T();return i[c]===36&&(c++,t.setClass(e,g())),e},D=()=>{let e=[E()];for(l=void 0;;){let t=i[c]===7?S():void 0,n=u,r=d;if(i[c]!==78)return l=t,e;do c++;while(i[c]===78);if(i[c]!==38)return t!==void 0&&f(`'AMP'`),e;c++,i[c]!==78&&f(`'SPACE'`);do c++;while(i[c]===78);let a=E();t!==void 0&&C(e[e.length-1],t,n,r),e.push(a)}},O=()=>{let e;if(i[c]===33&&(e=a[c++]),i[c]===42){let n=t.destructLink(a[c++]);return e!==void 0&&(n.id=e),i[c]===70&&(c++,n.text=v(),y(70),i[c]===78&&c++),n}if(i[c]===43){let n=a[c++],r=b(),i=m(42,`'EDGE_TEXT'`),o=t.destructLink(i,n);return o.text=r,e!==void 0&&(o.id=e),o}return f(`'LINK', 'START_LINK'`)},k=()=>{let e=c,n=D();l!==void 0&&C(n[n.length-1],l,u,d);let r=n;for(;;){let a=i[c];if(a!==42&&a!==43&&a!==33)return r;let o=O(),s=D();l!==void 0&&C(s[s.length-1],l,u,d),t.addLink(n,s,o),t.addEdgeMapping(n,s,o,p(e,c-1)),r=s.concat(r),n=s}},A=()=>{Rq[i[c]]===0&&f(`'NODE_STRING', 'NUM', 'COLON', 'BRKT'`);let e=a[c++];for(;Rq[i[c]]===1;)e+=a[c++];return e},j=()=>{let e=[A()];for(;i[c]===40;)c++,e.push(A());return e},M=()=>{c++,m(78);let e;if(i[c]===13)e=[a[c++]];else for(e=[m(34,`'DEFAULT'`)];i[c]===40;)c++,e.push(m(34));if(m(78),i[c]!==15){t.updateLink(e,j());return}c++,m(78);let n=_();if(i[c]===78){c++;let r=j();t.updateLinkInterpolate(e,n),t.updateLink(e,r)}else t.updateLinkInterpolate(e,n)},N=(e,n)=>{if(i[c]!==78){t.setLink(e,n);return}if(c++,i[c]===25){t.setLink(e,n,a[c++]);return}let r=m(11,`'LINK_TARGET'`);i[c]===78?(c++,t.setLink(e,n,m(25))):t.setLink(e,n),t.setTooltip(e,r)},P=()=>{let e=a[c++];switch(i[c]){case 8:{let n=a[c++],r=i[c]===9,o=r?a[c++]:void 0,s;i[c]===78&&(c++,s=m(11)),r?t.setClickEvent(e,n,o):t.setClickEvent(e,n),s!==void 0&&t.setTooltip(e,s);return}case 18:c++,N(e,m(11));return;case 11:N(e,a[c++]);return;default:{let n=_();if(i[c]===78){c++;let r=m(11);t.setClickEvent(e,n),t.setTooltip(e,r)}else t.setClickEvent(e,n)}}},F=e=>{m(78,Bq);let t=x(),n={text:``,type:`text`};i[c]===74&&(c++,n=v(),y(73));let r=i[c]===7?S():void 0;return zq[i[c]]===0&&f(`${Bq}, 'SHAPE_DATA'`),{global:!1,at:e,id:t,title:n,data:r,dataFrom:u,dataTo:d,list:[],collect:!1}},ee=()=>{let e=i[c];switch(e){case 12:{c++,m(78);let e=g();return m(78),t.addVertex(e,void 0,void 0,j()),h(),Vq}case 14:return M(),h(),Vq;case 16:{c++,m(78);let e=g();return m(78),t.addClass(e,j()),h(),Vq}case 17:{c++,m(78);let e=g();return m(78),t.setClass(e,g()),h(),Vq}case 19:return P(),h(),Vq;case 22:{let e=F(c++),n=c++,r=t.addConnector(e.id,e.title);return w(r,e),t.addConnectorMapping(e.id,e.title,p(e.at,e.at),p(n,n)),r}case 28:case 29:case 30:case 31:case 32:return c++,{stmt:`dir`,value:Mmt[e-28]};case 2:{c++;let e=m(3).trim();return t.setAccTitle(e),e}case 4:{c++;let e=m(5).trim();return t.setAccDescription(e),e}case 6:{let e=a[c++].trim();return t.setAccDescription(e),e}default:{Fq[e]===0&&f(Nmt);let t=k();return h(),t}}},te=()=>{let e=[],n=[],r=!1;for(;;){let o=i[c];if(o===0)break;if(o===24){let i=e.pop();if(i===void 0)break;let a=c++;if(i.global){t.addGlobal(n),n=i.list,r=i.collect;continue}let o=t.addSubGraph(i.id,n,i.title,`flow`);w(o,i),t.addSubgraphMapping(i.id,i.title,p(i.at,i.at),p(a,a)),n=i.list,r=i.collect,r&&n.push(o)}else if(o===39||o===77||o===78||o===79)r&&n.push(a[c]),c++;else if(o===66)c++;else if(o===21||o===23){let t=c++,a;o===23||zq[i[c]]===1?(a={global:o===23,at:t,id:void 0,title:void 0,data:void 0,dataFrom:0,dataTo:0,list:n,collect:r},h()):(a=F(t),a.list=n,a.collect=r,c++),e.push(a),n=[],r=!0}else{let e=ee();r&&(!Array.isArray(e)||e.length>0)&&n.push(e)}}e.length>0&&f(`'end'`)};for(;i[c]===78||i[c]===77||i[c]===66;)c++;if(m(20,`'SPACE', 'NEWLINE', 'COMMENT'`),i[c]===26)c++,t.setDirection(`TB`);else{let e=m(27,`'NODIR'`),n=i[c];if(n===78){do c++;while(i[c]===78);n=i[c],n!==77&&f(`'NEWLINE', 'SPACE'`)}else n!==39&&n!==77&&n!==66&&f(`'COMMENT', 'SEMI', 'NEWLINE', 'SPACE'`);c++,t.setDirection(e)}te(),i[c]!==0&&f(Nmt)}var Mmt=[`TB`,`BT`,`RL`,`LR`,`TD`],Nmt=`'COMMENT', 'SEMI', 'NEWLINE', 'SPACE', 'EOF', 'flow', 'global', 'connector', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'STYLE', 'LINKSTYLE', 'CLASSDEF', 'CLASS', 'CLICK', 'NODE_STRING'`;function Hq(e,t,n=0){return{w:e,h:t,kind:n,pin:0,span:0,x:0,y:0,rank:0}}function Uq(e,t,n=1,r=0,i=0){return{tail:e,head:t,minlen:n,labelW:r,labelH:i,tailDx:0,headDx:0,tailFixed:!1,headFixed:!1,reversed:!1,points:[],labelX:0,labelY:0}}var Pmt=24,Fmt=2e4,Wq=16,Imt=8,Lmt=.125,Rmt=3,zmt=18,Bmt=10,Vmt=14,Hmt=2,Umt=28,Wmt=12,Gmt=12,Kmt=8,qmt=4,Jmt=.5,Gq=.5,Ymt=12,Xmt=40,Zmt=400;function Kq(e){return e===1||e===2}function Qmt(e,t,n,r){for(let i=t+1;i<n;i++){let n=e[i],a=r[n],o=i-1;for(;o>=t&&(r[e[o]]>a||r[e[o]]===a&&e[o]>n);)e[o+1]=e[o],o--;e[o+1]=n}}function $mt(e,t,n){let r=e.length;if(r===0)return{width:0,height:0};let i=t.length,a=1;if(i>0){let e=/* @__PURE__ */ new Set;for(let n of t){let t=Math.min(n.tail,n.head),i=Math.max(n.tail,n.head),o=t*r+i;if(n.labelW>0||e.has(o)){a=2;break}e.add(o)}}qq(e,t),Jq(e,t,a);let o=new Int32Array(i),s=0;for(let n=0;n<i;n++){let r=t[n];o[n]=Math.abs(e[r.head].rank-e[r.tail].rank),o[n]>1&&(s+=o[n]-1)}let c=new Uint8Array(i);if(s>Fmt){let e=[];for(let t=0;t<i;t++)o[t]>1&&e.push(t);e.sort((e,t)=>o[t]-o[e]||e-t);for(let t of e){if(s<=Fmt)break;c[t]=1,s-=o[t]-1}}let l=r+s,u=new Float64Array(l),d=new Float64Array(l),f=new Uint8Array(l),p=new Int32Array(l),m=0;for(let t=0;t<r;t++){let n=e[t];u[t]=n.w,d[t]=n.h,f[t]=n.kind,p[t]=n.rank,n.rank>m&&(m=n.rank)}let h=0;for(let e=0;e<i;e++)c[e]||(h+=o[e]);let g=new Int32Array(h),_=new Int32Array(h),v=new Float64Array(h),y=new Float64Array(h),b=new Int32Array(i).fill(-1),x=new Uint8Array(m+1),S=new Int32Array(i).fill(-1),C=!1;for(let t=0;t<r;t++)e[t].span>0&&e[t].kind===0&&(C=!0);let w=C?new Uint8Array(h):void 0,T=C?new Uint8Array(h):void 0,E=new Int32Array(i).fill(-1),D=new Int32Array(i).fill(-1),O=!1;{let e=r,n=0;for(let r=0;r<i;r++){if(c[r])continue;let i=t[r],o=i.reversed?i.head:i.tail,s=i.reversed?i.tail:i.head,l=i.reversed?i.headDx:i.tailDx,m=i.reversed?i.tailDx:i.headDx;(l!==0||m!==0)&&(O=!0);let h=p[o],C=p[s],k=-1;i.labelW>0&&(k=h+(C-h>>1),a===2&&C-h>=4?(k&1)==1&&(k+=i.reversed?1:-1):a===2&&!(k&1)&&(k+=i.reversed?1:-1));let A=o;C-h>1&&(b[r]=e),E[r]=n,w&&!(i.reversed?i.headFixed:i.tailFixed)&&(w[n]=i.reversed?2:1);for(let t=h+1;t<C;t++){let a=e++;p[a]=t,t===k?(u[a]=i.labelW,d[a]=i.labelH,f[a]=2,S[r]=a,x[t]|=i.reversed?2:1):f[a]=1,g[n]=A,_[n]=a,v[n]=A===o?l:0,n++,A=a}g[n]=A,_[n]=s,v[n]=A===o?l:0,y[n]=m,T&&!(i.reversed?i.tailFixed:i.headFixed)&&(T[n]=i.reversed?1:2),D[r]=n,n++}}let k=new Int32Array(l+1),A=new Int32Array(l+1);for(let e=0;e<h;e++)k[g[e]+1]++,A[_[e]+1]++;for(let e=0;e<l;e++)k[e+1]+=k[e],A[e+1]+=A[e];let j=new Int32Array(h),M=new Int32Array(h);{let e=k.slice(0,l),t=A.slice(0,l);for(let n=0;n<h;n++)j[e[g[n]]++]=n,M[t[_[n]]++]=n}let N=new Int32Array(m+2);for(let e=0;e<l;e++)N[p[e]+1]++;for(let e=0;e<=m;e++)N[e+1]+=N[e];let P=new Int32Array(l),F=new Int32Array(l);{let e=new Int32Array(l),t=N.slice(0,m+1);for(let n=0;n<l;n++)e[t[p[n]]++]=n;t.set(N.subarray(0,m+1));let n=new Uint8Array(l),r=[];for(let i=0;i<l;i++)if(!n[e[i]])for(r.push(e[i]);r.length>0;){let e=r.pop();if(!n[e]){n[e]=1,P[t[p[e]]++]=e;for(let t=k[e+1]-1;t>=k[e];t--){let e=_[j[t]];n[e]||r.push(e)}}}}let ee=!1;for(let t=0;t<r;t++)e[t].pin!==0&&(ee=!0);if(ee)for(let t=0;t<=m;t++){let n=Array.from(P.subarray(N[t],N[t+1])),i=/* @__PURE__ */ new Map;n.forEach((e,t)=>i.set(e,t));let a=t=>t<r?e[t].pin:0;n.sort((e,t)=>a(e)-a(t)||i.get(e)-i.get(t)),P.set(n,N[t])}let te=()=>{for(let e=0;e<=m;e++){let t=N[e];for(let n=t,r=N[e+1];n<r;n++)F[P[n]]=n-t}};te();let I={n:l,real:r,maxRank:m,W:u,KIND:f,RANK:p,EF:g,ET:_,EFD:v,ETD:y,succStart:k,succE:j,predStart:A,predE:M,layerStart:N,order:P,pos:F,offsets:O};h>0&&m>0&&(dht(I,e),te()),w&&T&&tht(I,e,w,T);let ne=pht(I,n),re=sht(I);if(w&&T){let r=nht(I,w,T);iht(I,e,ne,r,n,re),aht(I,e,ne,w,T,r,re),oht(I,ne,re,n);for(let e=0;e<i;e++){if(c[e])continue;let n=t[e],r=v[E[e]],i=y[D[e]];n.tailDx=n.reversed?i:r,n.headDx=n.reversed?r:i}}let ie=new Uint8Array(l);re&&!n.tracks&&lht(I,ne,re,b,o,n.apart?0:n.edgeSep,ie),n.tracks||uht(I,ne,b,o,n.edgeSep,ie);let ae=new Int32Array(i+1),L=n.tracks||w&&!n.straight?{from:[],to:[],rank:[],lower:[],track:[],levels:[],wide:[]}:void 0,oe=new Int32Array(m+1);if(L){for(let e=0;e<i;e++){if(ae[e]=L.from.length,c[e])continue;let t=b[e],r=!1;for(let i=t,a=t<0?t:t+o[e]-1;i<a;i++){let e=re!==void 0&&re[p[i]]===1;!n.tracks&&e!==(ie[i]===1)&&(r=!0)}if(r)continue;let i=ne[g[E[e]]]+v[E[e]],a=p[g[E[e]]];for(let n=t,r=t<0?t:t+o[e]-1;n<r;n++)re&&re[p[n]]||(L.from.push(i),L.to.push(ne[n]),L.rank.push(a),L.lower.push(n),i=ne[n],a=p[n]);L.from.push(i),L.to.push(ne[_[D[e]]]+y[D[e]]),L.rank.push(a),L.lower.push(-1)}ae[i]=L.from.length}let se=(e,t)=>{let n=!1;for(let r=N[e];r<N[e+1];r++){let e=f[P[r]];if(e===t)n=!0;else if(e!==1)return!1}return n},ce=se(0,3)?a:0,le=se(m,4)?a:0,ue=new Float64Array(m+1);for(let e=0;e<h;e++){let t=Math.abs(ne[g[e]]+v[e]-ne[_[e]]-y[e]);t>ue[p[g[e]]]&&(ue[p[g[e]]]=t)}let de=new Float64Array(m+1),fe=new Float64Array(m+1),pe=e=>(e<ce||e>=m-le?n.portSep:n.rankSep)/a,me=new Float64Array(m+1);for(let e=0;e<m;e++)me[e]=L?pe(e):Math.max(pe(e),Math.min(Rmt*n.rankSep/a,ue[e]*Lmt));let he=new Uint8Array(m+1).fill(1);for(let e=0;e<r;e++)he[p[e]]=0;for(let e=1;e<m;e++){if(n.tracks||!he[e]||x[e]!==1&&x[e]!==2)continue;let t=Math.min((n.headRoom??0)/2,me[x[e]===1?e-1:e]/2);me[e-1]+=x[e]===1?-t:t,me[e]+=x[e]===1?t:-t}let ge=e=>f[e]===1&&he[p[e]]&&!n.tracks?(fe[p[e]]-de[p[e]])/4:0,_e=n.tracks?zmt:Umt,ve=n.tracks?Bmt:Wmt,ye=n.tracks?Vmt:Wmt,be=new Int32Array(m+1);if(L){let e=new Float64Array(m+1);for(let t=0;t<m;t++){if(re&&re[t])continue;let n=t+1;for(e[t]=me[t];n<m&&re&&re[n];)e[t]+=me[n++];be[t]=n}for(let t=0;t<L.from.length;t++)L.wide.push(+(Math.abs(L.from[t]-L.to[t])>Hmt*e[L.rank[t]]));let t=new Float64Array(m+1);cht(L,oe,!n.tracks,e,t);for(let r=0;r<m;r++)oe[r]>0?me[r]+=Math.max(0,2*_e+(oe[r]-1)*ve-e[r]):t[r]>0&&(me[r]+=Math.max(0,Math.min(Rmt*n.rankSep,t[r])-e[r]))}let xe=0;for(let e=0;e<=m;e++){let t=0;for(let n=N[e];n<N[e+1];n++)d[P[n]]>t&&(t=d[P[n]]);de[e]=xe,fe[e]=xe+t,xe+=t+me[e]}let Se=xe,Ce=(e,t=L.track[e])=>{let r=L.rank[e],i=fe[r],a=de[be[r]],o=n.tracks?oe[r]:L.levels[e],s=o>1?Math.min(ye,(a-i-2*_e)/(o-1)):0;return(i+a)/2+(t-(o-1)/2)*s},we=1/0,Te=-1/0;for(let e=0;e<l;e++){let t=u[e]/2;ne[e]-t<we&&(we=ne[e]-t),ne[e]+t>Te&&(Te=ne[e]+t)}let Ee=new Uint8Array(m+1),De=new Uint8Array(m+1);for(let e=0;e<r;e++)f[e]!==0||!w||(A[e+1]>A[e]&&(Ee[p[e]]=1),k[e+1]>k[e]&&(De[p[e]]=1));for(let t=0;t<r;t++){let n=e[t],r=n.rank;n.x=ne[t]-we,n.y=f[t]===0&&De[r]&&!Ee[r]?fe[r]-n.h/2:f[t]===0&&Ee[r]&&!De[r]?de[r]+n.h/2:(de[r]+fe[r])/2}for(let r=0;r<i;r++){let i=t[r],a=e[i.reversed?i.head:i.tail],s=e[i.reversed?i.tail:i.head],c=[a.x+(i.reversed?i.headDx:i.tailDx),a.y+a.h/2],l=b[r];if(L&&ae[r+1]>ae[r])for(let e=ae[r];e<ae[r+1];e++){if(L.track[e]>=0&&(n.tracks||L.wide[e]===1)){let t=Ce(e);c.push(L.from[e]-we,t,L.to[e]-we,t)}else L.track[e]>0&&c.push(L.from[e]-we,Ce(e,L.track[e]-1));let t=L.lower[e];t<0||(c.push(ne[t]-we,de[p[t]]+ge(t)),fe[p[t]]>de[p[t]]&&c.push(ne[t]-we,fe[p[t]]-ge(t)))}else if(l>=0)for(let e=l,t=l+o[r]-1;e<t;e++){if(ie[e])continue;let t=ne[e]-we,n=de[p[e]],r=fe[p[e]];c.push(t,n+ge(e)),r>n&&c.push(t,r-ge(e))}if(c.push(s.x+(i.reversed?i.tailDx:i.headDx),s.y-s.h/2),i.reversed)for(let e=0,t=c.length-2;e<t;e+=2,t-=2){let n=c[e],r=c[e+1];c[e]=c[t],c[e+1]=c[t+1],c[t]=n,c[t+1]=r}i.points=c;let u=S[r];u>=0?(i.labelX=ne[u]-we,i.labelY=(de[p[u]]+fe[p[u]])/2):i.labelW>0&&(i.labelX=(c[0]+c[c.length-2])/2,i.labelY=(c[1]+c[c.length-1])/2)}return{width:Te-we,height:Se}}function qq(e,t){let n=e.length,r=t.length,i=new Int32Array(n+1);for(let n=0;n<r;n++){let r=t[n];r.reversed=e[r.head].kind===3||e[r.tail].kind===4,r.reversed||i[r.tail+1]++}for(let e=0;e<n;e++)i[e+1]+=i[e];let a=new Int32Array(i[n]);{let e=i.slice(0,n);for(let n=0;n<r;n++)t[n].reversed||(a[e[t[n].tail]++]=n)}let o=new Uint8Array(n),s=i.slice(0,n),c=[];for(let e=0;e<n;e++)if(o[e]===0)for(c.push(e),o[e]=1;c.length>0;){let e=c[c.length-1];if(s[e]<i[e+1]){let n=t[a[s[e]++]],r=n.head;o[r]===1?n.reversed=!0:o[r]===0&&(o[r]=1,c.push(r))}else o[e]=2,c.pop()}}function Jq(e,t,n){let r=e.length,i=t.length,a=new Int32Array(i),o=new Int32Array(i),s=new Int32Array(i),c=new Int32Array(r+1),l=new Int32Array(r+1);for(let e=0;e<i;e++){let r=t[e],i=r.reversed?r.head:r.tail,u=r.reversed?r.tail:r.head;a[e]=i,o[e]=u,s[e]=Math.max(1,r.minlen)*n,c[i+1]++,l[u+1]++}for(let e=0;e<r;e++)c[e+1]+=c[e],l[e+1]+=l[e];let u=new Int32Array(i),d=new Int32Array(i);{let e=c.slice(0,r),t=l.slice(0,r);for(let n=0;n<i;n++)u[e[a[n]]++]=n,d[t[o[n]]++]=n}let f=new Int32Array(r),p=new Int32Array(r);for(let e=0;e<r;e++)p[e]=l[e+1]-l[e];let m=new Int32Array(r),h=0;for(let e=0;e<r;e++)p[e]===0&&(m[h++]=e);for(let e=0;e<h;e++){let t=m[e];for(let e=c[t];e<c[t+1];e++){let n=u[e],r=o[n];f[t]+s[n]>f[r]&&(f[r]=f[t]+s[n]),--p[r]===0&&(m[h++]=r)}}for(let e=0;e<8;e++){let e=!1;for(let t=h-1;t>=0;t--){let n=m[t],r=l[n+1]-l[n],i=c[n+1]-c[n];if(r===0&&i===0)continue;let p=-1/0,h=1/0;for(let e=l[n];e<l[n+1];e++){let t=d[e];p=Math.max(p,f[a[t]]+s[t])}for(let e=c[n];e<c[n+1];e++){let t=u[e];h=Math.min(h,f[o[t]]-s[t])}let g=f[n];i>r&&h!==1/0?g=h:r>i&&p!==-1/0&&(g=p),g!==f[n]&&(f[n]=g,e=!0)}if(!e)break}let g=1/0,_=-1/0,v=!1;for(let t=0;t<r;t++){let n=e[t].kind;n===3&&(v=!0),n!==3&&n!==4&&(f[t]<g&&(g=f[t]),f[t]>_&&(_=f[t]))}g===1/0&&(g=0,_=0);for(let t=0;t<r;t++)e[t].kind===3?f[t]=g-n:e[t].kind===4&&(f[t]=_+n);v&&(g-=n);for(let t=0;t<r;t++)e[t].rank=f[t]-g}function eht(e,t,n,r,i,a,o){let s=n===0?e.predStart:e.succStart,c=n===0?e.predE:e.succE,l=n===0?e.EF:e.ET,u=e.pos;a.length=0;for(let e=s[t];e<s[t+1];e++)i[c[e]]!==0&&a.push(c[e]);if(a.length<2)return 0;a.sort((e,t)=>u[l[e]]-u[l[t]]||e-t);let d=e=>{let t=0;o.length=a.length,o[0]=0;for(let n=1;n<a.length;n++){let r=i[a[n]]===i[a[n-1]];o[n]=e(r&&i[a[n]]===1,r),t+=o[n]}return t},f=d(()=>1);if(r/f<Imt&&(f=d(e=>e?.5:1)),r/f<Imt&&(f=d((e,t)=>+!t)),f===0)return 0;let p=Math.min(Wq,r/f);for(let e=1;e<a.length;e++)o[e]*=p;return f*p}function tht(e,t,n,r){let{real:i,W:a,EFD:o,ETD:s}=e,c=[],l=[];for(let u=0;u<i;u++){let i=Math.min(t[u].span,a[u]);if(!(i<=0||t[u].kind!==0))for(let t=0;t<2;t++){let a=eht(e,u,t,i,t===0?r:n,c,l);if(a===0)continue;let d=t===0?s:o,f=-a/2;for(let e=0;e<c.length;e++)f+=l[e],d[c[e]]=f}}}function Yq(e,t,n,r){if(!t)return n;let{KIND:i,RANK:a,EF:o,ET:s,succStart:c,succE:l,predStart:u,predE:d}=e;for(let e=0;e<1e5;e++){let e=r===0?o[n]:s[n];if(i[e]!==1||!t[a[e]])break;n=r===0?d[u[e]]:l[c[e]]}return n}function nht(e,t,n){let r=[new Int32Array(e.n),new Int32Array(e.n)];for(let i=0;i<e.EF.length;i++)n[i]!==0&&r[0][e.ET[i]]++,t[i]!==0&&r[1][e.EF[i]]++;return r}function rht(e,t){return Math.max(.25,Math.min(.5,4*Math.abs(t)/(Math.abs(e)||1)))}function iht(e,t,n,r,i,a){let o=i.edgeSep,{n:s,real:c,maxRank:l,KIND:u,RANK:d,W:f,EF:p,ET:m,EFD:h,ETD:g,succStart:_,succE:v,predStart:y,predE:b,layerStart:x,order:S,pos:C}=e,w=e=>u[e]===2||u[e]===1&&(a===void 0||a[d[e]]!==1),T=(e,i)=>{let a=i===0?p[e]:m[e];return[i===0?n[a]+h[e]:n[a]+g[e],a<c&&t[a].kind===0?r[1-i][a]:0]},E=e=>{let t=x[d[e]],r=t+C[e],a=t=>f[t]/2+f[e]/2+(u[t]===0?i.nodeSep/2+o/2:u[t]===u[e]?o:o/2);return[r>t?n[S[r-1]]+a(S[r-1]):-1/0,r+1<x[d[e]+1]?n[S[r+1]]-a(S[r+1]):1/0]},D=(e,t,n,r,i)=>{let a=(t[1]===n[1]?Math.abs(t[0]-e)<=Math.abs(n[0]-e):t[1]<n[1])?[t[0],n[0]]:[n[0],t[0]];return a.find(e=>e>=r&&e<=i)??Math.max(r,Math.min(i,a[0]))},O=new Uint8Array(s),k=[];for(let t=1;t<l;t++)for(let r=x[t];r<x[t+1];r++){if(!w(S[r])||O[S[r]])continue;let t=S[r];for(;Kq(u[p[b[y[t]]]]);)t=p[b[y[t]]];let i=t,o=-1/0,s=1/0;k.length=0;for(let e=t;Kq(u[e]);e=m[v[_[e]]]){if(i=e,!w(e))continue;O[e]=1,k.push(e);let[t,n]=E(e);t>o&&(o=t),n<s&&(s=n)}if(o<=s){let e=D(n[k[0]],T(b[y[t]],0),T(v[_[i]],1),o,s);for(let t of k)n[t]=e}else for(let t of k){let[r,i]=E(t);r>i||(n[t]=D(n[t],T(Yq(e,a,b[y[t]],0),0),T(Yq(e,a,v[_[t]],1),1),r,i))}}}function aht(e,t,n,r,i,a,o){let{real:s,W:c,EF:l,ET:u,EFD:d,ETD:f,succStart:p,succE:m,predStart:h,predE:g,pos:_}=e,v=[],y=[],b=[],x=[],S=[],C=(p,m,h,g,_)=>{if(a[m][h]<2)return 0;p=Yq(e,o,p,m);let v=m===0?l[p]:u[p],y=m===0?n[v]+d[p]:n[v]+f[p];if(_&&Math.abs(y-n[h])<=g/2+Gq)return Math.max(-g/2,Math.min(g/2,y-n[h]));let b=y,x=0;v<s&&t[v].kind===0&&(m===0?r:i)[p]!==0&&a[1-m][v]>=2&&(x=Math.max(0,Math.min(t[v].span,c[v])),x>0&&(b=n[v]));let S=Math.max(n[h]-g/2,b-x/2),C=Math.min(n[h]+g/2,b+x/2);if(S>C+Gq){let e=Math.max(0,g/2-Xmt);return Math.max(-e,Math.min(e,y-n[h]))}let w=(n[h]*x+b*g)/(x+g);return Math.max(S,Math.min(C,w))-n[h]};for(let n=0,a=!0;a&&n<6;n++){a=!1;for(let o=0;o<s;o++){let s=Math.min(t[o].span,c[o]);if(!(s<=0||t[o].kind!==0))for(let t=0;t<2;t++){let c=t===0?i:r,w=t===0?f:d,T=t===0?l:u,E=t===0?h:p,D=t===0?g:m;if(eht(e,o,t,s,c,v,y),v.length===0)continue;v.length===1&&(y[0]=0),b.length=0;for(let e=E[o];e<E[o+1];e++)b.push(D[e]);b.sort((e,t)=>_[T[e]]-_[T[t]]||e-t);let O=0,k=-s/2;for(let e=0;e<=b.length;e++){let r=e<b.length&&c[b[e]]===0;if(e<b.length&&!r)continue;let i=0;for(let t=e-1;t>=0&&c[b[t]]!==0;t--)i++;let l=r?w[b[e]]-Wq:s/2;if(i>0){x.length=0,S.length=0;let e=0;for(let r=0;r<i;r++){r>0&&(e+=y[O+r]),x.push(C(v[O+r],t,o,s,n>0)-e),S.push(1);let i=r>0&&y[O+r]===0;for(;x.length>1&&(i||x[x.length-2]/S[S.length-2]>x[x.length-1]/S[S.length-1]);){i=!1;let e=x.pop(),t=S.pop();x[x.length-1]+=e,S[S.length-1]+=t}}let r=e,c=0;e=0;for(let t=0;t<x.length;t++){let n=l-r<k?(k+l-r)/2:Math.max(k,Math.min(l-r,x[t]/S[t]));for(let r=0;r<S[t];r++,c++)c>0&&(e+=y[O+c]),Math.abs(w[v[O+c]]-n-e)>.01&&(a=!0),w[v[O+c]]=n+e}O+=i}r&&(k=w[b[e]]+Wq)}}}}}function oht(e,t,n,r){let{n:i,KIND:a,RANK:o,EF:s,ET:c,EFD:l,ETD:u,layerStart:d,order:f,pos:p}=e,m=e=>n!==void 0&&a[e]===1&&n[o[e]]===1,h=[],g=[],_=[],v=[];for(let t=0;t<s.length;t++){if(m(s[t]))continue;let r=Yq(e,n,t,1);h.push(s[t]),g.push(c[r]),_.push(l[t]),v.push(u[r])}let y=e=>t[g[e]]+v[e]-t[h[e]]-_[e],b=new Int32Array(i),x=[];for(let e=0;e<i;e++)b[e]=e,x.push([e]);let S=(e,t)=>{let n=b[e],r=b[t];if(n!==r){x[n].length<x[r].length&&([n,r]=[r,n]);for(let e of x[r])b[e]=n,x[n].push(e);x[r]=[]}},C=[];for(let e=0;e<h.length;e++){let t=Math.abs(y(e));t<.01?S(h[e],g[e]):t<=Ymt&&C.push(e)}if(C.length===0)return;C.sort((e,t)=>Math.abs(y(e))-Math.abs(y(t))||e-t);let w=t=>fht(e,r,t),T=(e,n)=>{for(let r of x[e]){let i=d[o[r]],a=d[o[r]+1],s=i+p[r];if(s>i&&b[f[s-1]]!==e&&t[r]+n-t[f[s-1]]<w(r)+w(f[s-1])-.01||s+1<a&&b[f[s+1]]!==e&&t[f[s+1]]-t[r]-n<w(r)+w(f[s+1])-.01)return!1}return!0};for(let e of C){let n=y(e);if(Math.abs(n)<.01){S(h[e],g[e]);continue}if(Math.abs(n)>Ymt||b[h[e]]===b[g[e]])continue;let r=b[h[e]],i=b[g[e]],a=x[r].length<=x[i].length?r:i;for(let o of[a,a===r?i:r]){let i=o===r?n:-n;if(T(o,i)){for(let e of x[o])t[e]+=i;S(h[e],g[e]);break}}}}function sht(e){let{maxRank:t,KIND:n,layerStart:r,order:i}=e,a=new Uint8Array(t+1),o=!1;for(let e=1;e<t;e++){let t=r[e+1]>r[e];for(let a=r[e];t&&a<r[e+1];a++)n[i[a]]!==1&&(t=!1);t&&(a[e]=1,o=!0)}return o?a:void 0}function cht(e,t,n,r,i){let{from:a,to:o,rank:s,track:c,levels:l,wide:u}=e,d=a.length,f=/* @__PURE__ */ new Map;for(let e=0;e<d;e++){if(c.push(-1),l.push(0),Math.abs(a[e]-o[e])<Gq)continue;let t=f.get(s[e]);t?t.push(e):f.set(s[e],[e])}let p=new Float64Array(d),m=new Float64Array(d);for(let e=0;e<d;e++)p[e]=Math.min(a[e],o[e]),m[e]=Math.max(a[e],o[e]);let h=(e,t)=>+(e>=p[t]-Gq&&e<=m[t]+Gq),g=(e,t)=>Math.abs(a[e]-a[t])<Gq||Math.abs(o[e]-o[t])<Gq,_=(e,t)=>p[e]<m[t]-Gq&&p[t]<m[e]-Gq,v=(e,t)=>_(e,t)&&!g(e,t),y=(e,t)=>_(e,t)||h(o[e],t)+h(a[t],e)+h(o[t],e)+h(a[e],t)>0,b=(e,t)=>h(o[e],t)+h(a[t],e),x=e=>{e.sort((e,t)=>m[t]-p[t]-(m[e]-p[e])||p[e]-p[t]||e-t);let t=e.length,r=[],i=e.map((e,t)=>t),a=e=>{for(;i[e]!==e;)e=i[e]=i[i[e]];return e},o=e;if(t<=Zmt){let n=new Int32Array(t),s=[];for(let e=0;e<t;e++)r.push([]),s.push([]);for(let o=0;o<t;o++)for(let c=o+1;c<t;c++){let t=e[o],l=e[c];if(!y(t,l))continue;i[a(o)]=a(c);let u=b(t,l),d=b(l,t);if(u===d)continue;let f=u<d?o:c,p=u<d?c:o;r[p].push(f),s[f].push(p),n[p]++}let c=new Uint8Array(t),l=[];for(let e=0;e<t;e++){let e=-1;for(let r=0;r<t&&!(!c[r]&&((e<0||n[r]<n[e])&&(e=r),n[r]===0));r++);c[e]=1,l.push(e);for(let t of s[e])n[t]--}o=l.map(t=>e[t])}let s=/* @__PURE__ */ new Map;e.forEach((e,t)=>s.set(e,t));let u=[];for(let t of o){let n=0;for(let i of r[s.get(t)]??[])c[e[i]]>=n&&(n=c[e[i]]+1);for(;;n++){let e=u[n]??=[],r=!0;for(let n of e)v(t,n)&&(r=!1);if(r){e.push(t);break}}c[t]=n}let d=/* @__PURE__ */ new Map,f=/* @__PURE__ */ new Map;return e.forEach((e,t)=>{let n=a(t);d.set(n,Math.min(d.get(n)??1/0,c[e])),f.set(n,Math.max(f.get(n)??-1/0,c[e]))}),e.forEach((e,t)=>{let r=a(t);l[e]=f.get(r)-d.get(r)+1,n&&(c[e]-=d.get(r))}),u.length},S=(e,t,n)=>{let r=rht(o[e]-a[e],t);for(let i=0;i<=16;i++){let s=i/16,c=1-s;n[2*i]=a[e]+(o[e]-a[e])*s*s*(3-2*s),n[2*i+1]=t*(3*r*s*c*c+3*(1-r)*s*s*c+s*s*s)}},C=/* @__PURE__ */ new Float64Array(34),w=/* @__PURE__ */ new Float64Array(34),T=(e,t)=>{let n=1/0;for(let r=0;r<=16;r++){let i=e[2*r],a=e[2*r+1];for(let e=0;e<16;e++){let r=t[2*e+2]-t[2*e],o=t[2*e+3]-t[2*e+1],s=Math.max(0,Math.min(1,((i-t[2*e])*r+(a-t[2*e+1])*o)/(r*r+o*o||1))),c=Math.hypot(i-t[2*e]-s*r,a-t[2*e+1]-s*o);c<n&&(n=c)}}return n},E=(e,t,n)=>{let r=Math.max(n/2,n-2*Gmt);return S(e,r,C),S(t,r,w),Math.min(T(C,w),T(w,C))};for(let[e,s]of f){if(!n){t[e]=x(s);continue}if(s.length>Zmt)continue;let d=s.filter(e=>u[e]===1);x(d);let f=new Set(d.filter(e=>l[e]>1));for(let t=0;t<s.length;t++)for(let n=t+1;n<s.length;n++){let i=s[t],c=s[n];f.has(i)&&f.has(c)||!v(i,c)||a[i]<o[i]!=a[c]<o[c]||E(i,c,r[e])<(u[i]===1||u[c]===1?Kmt:qmt)&&f.add(i).add(c)}for(let e of d)c[e]=-1,l[e]=0;if(f.size===0)continue;let h=0,b=0,S=[...f];for(let e=0;e<S.length;e++)for(let t=e+1;t<S.length;t++){let n=S[e],r=S[t];_(n,r)&&(a[n]<o[n]==a[r]<o[r]?g(n,r)||b++:h++)}if(h>b){for(let t of s)(m[t]-p[t])*Jmt>i[e]&&(i[e]=(m[t]-p[t])*Jmt);continue}let C=e=>{for(let t of f)if(y(e,t))return!0;return!1},w=s.filter(e=>f.has(e)||u[e]!==1&&C(e));x(w);let T=0;for(let e of w)l[e]>T&&(T=l[e]);t[e]=T}}function lht(e,t,n,r,i,a,o){let{maxRank:s,EF:c,ET:l,EFD:u,ETD:d,succStart:f,succE:p,predStart:m,predE:h,layerStart:g,order:_}=e,v=new Float64Array(t.length),y=new Float64Array(t.length),b=new Float64Array(t.length);for(let a=0;a<r.length;a++){let o=r[a];if(o<0)continue;let s=o+i[a]-1,g=e.RANK[o];for(let e=o;e<s;e++){if(!n[g+e-o])continue;let r=e;for(;r+1<s&&n[g+r+1-o];)r++;let i=h[m[e]],a=p[f[r]],_=t[c[i]]+u[i],x=t[l[a]]+d[a],S=r-e+2;for(let t=e;t<=r;t++)v[t]=_+(x-_)*(t-e+1)/S,y[t]=_,b[t]=x;e=r}}let x=[];for(let r=1;r<s;r++){if(!n[r])continue;let i=g[r],s=g[r+1],c=Array.from(_.subarray(i,s)).sort((e,t)=>y[e]-y[t]||b[e]-b[t]||e-t);for(let n=0;n<c.length;){x.length=0;let r=n;for(;r<c.length&&Math.abs(y[c[r]]-y[c[n]])<1&&Math.abs(b[c[r]]-b[c[n]])<1;r++)x.push(c[r]);x.sort((t,n)=>e.pos[t]-e.pos[n]);for(let e=0;e<x.length;e++){let n=x[e];t[n]=v[n]+(e-(x.length-1)/2)*a,(x.length===1||a===0)&&(o[n]=1)}n=r}}}function uht(e,t,n,r,i,a){let{maxRank:o,W:s,KIND:c,RANK:l,EF:u,ET:d,EFD:f,ETD:p,succStart:m,succE:h,predStart:g,predE:_,layerStart:v,order:y}=e,b=new Uint8Array(o+1),x=!1;for(let e=1;e<o;e++){let t=!1,n=!1;for(let r=v[e];r<v[e+1];r++){let e=c[y[r]];e===2?t=!0:e!==1&&(n=!0)}t&&!n&&(b[e]=1,x=!0)}if(x)for(let e=0;e<n.length;e++){let o=n[e];if(!(o<0))for(let n=o,x=o+r[e]-1;n<x;n++){if(c[n]!==1||!b[l[n]])continue;let e=n,r=n;for(;e>o&&a[e-1];)e--;for(;r+1<x&&a[r+1];)r++;let S=_[g[e]],C=h[m[r]],w=t[u[S]]+f[S],T=t[d[C]]+p[C],E=Math.min(w,T)-i,D=Math.max(w,T)+i,O=!0,k=l[n];for(let e=v[k];O&&e<v[k+1];e++){let n=y[e];c[n]===2&&t[n]+s[n]/2>E&&t[n]-s[n]/2<D&&(O=!1)}if(!O)continue;a[n]=1;let A=r-e+2;for(let n=e;n<=r;n++)t[n]=w+(T-w)*(n-e+1)/A}}}function dht(e,t){let{n,real:r,maxRank:i,W:a,EF:o,ET:s,EFD:c,ETD:l,succStart:u,succE:d,predStart:f,predE:p,layerStart:m,order:h,pos:g,offsets:_}=e,v=0;for(let e=0;e<=i;e++)v=Math.max(v,m[e+1]-m[e]);let y=_?new Int32Array(o.length):void 0,b=1;for(;b<(y?v+o.length:v);)b<<=1;let x=new Int32Array(2*b),S=new Int32Array(o.length),C=()=>{let e=0;for(let t=0;t<i;t++){let n=m[t+2]-m[t+1];if(y){let e=0;for(let n=m[t+1];n<m[t+2];n++){let t=f[h[n]],r=f[h[n]+1],i=!1;for(let e=t+1;e<r;e++)l[p[e]]!==l[p[t]]&&(i=!0);if(i){let n=Array.from(p.subarray(t,r));n.sort((e,t)=>l[e]-l[t]);for(let t=0;t<n.length;t++)t>0&&l[n[t]]!==l[n[t-1]]&&e++,y[n[t]]=e}else for(let n=t;n<r;n++)y[p[n]]=e;e++}n=e}if(n<2)continue;let r=0;for(let e=m[t];e<m[t+1];e++){let t=h[e],n=u[t],i=u[t+1],a=r;for(let e=n;e<i;e++)S[r++]=y?y[d[e]]:g[s[d[e]]];let o=r-a;if(o<2)continue;let l=!1;if(y)for(let e=n+1;e<i;e++)c[d[e]]!==c[d[n]]&&(l=!0);if(y&&l){let e=Array.from(d.subarray(n,i));e.sort((e,t)=>c[e]-c[t]||y[e]-y[t]);for(let t=0;t<o;t++)S[a+t]=y[e[t]]}else if(o<=12)for(let e=a+1;e<r;e++){let t=S[e],n=e-1;for(;n>=a&&S[n]>t;)S[n+1]=S[n],n--;S[n+1]=t}else S.subarray(a,r).sort()}if(r<2)continue;let i=1;for(;i<n;)i<<=1;x.fill(0,0,2*i);for(let t=0;t<r;t++){let n=S[t]+i;for(x[n]++;n>1;)!(n&1)&&(e+=x[n+1]),n>>=1,x[n]++}}return e},w=C();if(w===0)return;let T=h.slice(),E=new Float64Array(n),D=new Int32Array(v),O=(e,t)=>E[e]-E[t]||g[e]-g[t],k=(e,t)=>E[e]-E[t]||g[t]-g[e],A=(e,n)=>{let v=e?f:u,y=e?p:d,b=e?o:s,x=e?c:l;for(let o=1;o<=i;o++){let s=e?o:i-o,c=m[s],l=m[s+1],u=0;for(let e=c;e<l;e++){let n=h[e],i=n<r?t[n].pin:0;if(i!==0){E[n]=i*1e9,D[u++]=n;continue}let o=v[n],s=v[n+1];if(o===s){E[n]=-1;continue}let c=0;for(let e=o;e<s;e++){let t=b[y[e]];c+=g[t],_&&a[t]>0&&(c+=x[y[e]]/a[t])}E[n]=c/(s-o),D[u++]=n}if(u<2)continue;D.subarray(0,u).sort(n?k:O);let d=0;for(let e=c;e<l;e++)E[h[e]]!==-1&&(h[e]=D[d++]);for(let e=c;e<l;e++)g[h[e]]=e-c}},j=()=>{let e=0;for(let t=0;t<=i;t++)for(let n=m[t];n<m[t+1];n++)if(!(h[n]>=r))for(let r=n+1;r<m[t+1];r++)h[r]<h[n]&&e++;return e},M=()=>{for(let e=0;e<=i;e++)for(let t=m[e];t<m[e+1];t++)g[h[t]]=t-m[e]},N=h.slice(),P=w,F=n<=600,ee=T,te=1/0;for(let e=0;e<(F?2:1);e++){e>0&&(h.set(N),M());let t=P,n=N.slice();for(let r=0,i=0;i<4&&r<Pmt;r++,i++){A((r+e)%2==0,r%4>=2);let a=C();if(a<t&&(t=a,n.set(h),i=0,a===0))break}h.set(n);let r=F?j():0;(e===0||t<w||t===w&&r<te)&&(w=t,ee=n,te=r)}if(h.set(ee),M(),T.set(ee),F){for(let e=0;e<r;e++)if(t[e].pin!==0)return;if(te!==0){for(let e=0;e<=i;e++)h.subarray(m[e],m[e+1]).reverse();M(),(C()>w||j()>=te)&&h.set(T)}}}function fht(e,t,n){return e.W[n]/2+(e.KIND[n]===0?t.nodeSep:t.edgeSep)/2}function pht(e,t){let{n,maxRank:r,W:i,KIND:a,EF:o,ET:s,EFD:c,ETD:l,succStart:u,succE:d,predStart:f,predE:p,layerStart:m,order:h,pos:g}=e,_=o.length,v=new Float64Array(n);for(let r=0;r<n;r++)v[r]=fht(e,t,r);let y=new Int32Array(_);for(let e=0;e<_;e++)y[e]=g[s[e]];for(let e=0;e<n;e++)u[e+1]-u[e]>1&&Qmt(d,u[e],u[e+1],y);for(let e=0;e<_;e++)y[e]=g[o[e]];for(let e=0;e<n;e++)f[e+1]-f[e]>1&&Qmt(p,f[e],f[e+1],y);let b=new Uint8Array(_);for(let e=1;e<=r;e++){let t=m[e]-m[e-1],n=m[e],r=m[e+1],i=0,s=n;for(let e=n;e<r;e++){let n=h[e],c=-1;if(Kq(a[n])){let e=o[p[f[n]]];Kq(a[e])&&(c=e)}let l=c>=0?g[c]:t;if(c>=0||e===r-1){for(let t=s;t<=e;t++){let e=h[t],n=Kq(a[e]);for(let t=f[e];t<f[e+1];t++){let e=p[t],r=g[o[e]];(r<i||l<r)&&!(n&&Kq(a[o[e]]))&&(b[e]=1)}}s=e+1,i=l}}}let x=[],S=new Int32Array(n),C=new Int32Array(n),w=new Float64Array(n),T=new Int32Array(n),E=new Int32Array(n),D=new Float64Array(n),O=new Int32Array(n),k=new Int32Array(n+1),A=new Int32Array(n),j=new Int32Array(n),M=new Int32Array(n);for(let e=0;e<4;e++){let t=e<2,i=(e&1)==1,a=t?f:u,_=t?p:d,y=t?o:s,N=t?l:c,P=t?c:l;for(let e=0;e<n;e++)S[e]=e,C[e]=e,w[e]=0;for(let e=0;e<=r;e++){let n=t?e:r-e,o=m[n],s=m[n+1],c=t?n-1:n+1,l=c>=0&&c<=r?m[c+1]-m[c]-1:0,u=-1;for(let e=i?s-1:o;i?e>=o:e<s;i?e--:e++){let t=h[e],n=a[t],r=a[t+1]-n;if(r===0)continue;let o=n+(r-1>>1),s=n+(r>>1);for(let e=0;e<2&&(e!==1||o!==s);e++){let n=_[e===0===i?s:o],r=y[n],a=i?l-g[r]:g[r];C[t]===t&&u<a&&b[n]===0&&(C[r]=t,C[t]=S[t]=S[r],w[t]=w[r]+P[n]-N[n],u=a)}}}let F=0;O.fill(0),k.fill(0);for(let e=0;e<=r;e++){let t=m[e],n=m[e+1];for(let e=t+1;e<n;e++){let t=i?h[e]:h[e-1],n=i?h[e-1]:h[e],r=v[t]+v[n];T[F]=S[t],E[F]=S[n],D[F]=i?r-w[t]+w[n]:r+w[t]-w[n],O[S[n]]++,k[S[t]+1]++,F++}}for(let e=0;e<n;e++)k[e+1]+=k[e];j.set(k.subarray(0,n));for(let e=0;e<F;e++)A[j[T[e]]++]=e;let ee=new Float64Array(n),te=0;for(let e=0;e<n;e++)S[e]===e&&O[e]===0&&(M[te++]=e);for(let e=0;e<te;e++){let t=M[e];for(let e=k[t];e<k[t+1];e++){let n=A[e],r=E[n];ee[t]+D[n]>ee[r]&&(ee[r]=ee[t]+D[n]),--O[r]===0&&(M[te++]=r)}}for(let e=te-1;e>=0;e--){let t=M[e],n=1/0;for(let e=k[t];e<k[t+1];e++){let t=A[e],r=ee[E[t]]-D[t];r<n&&(n=r)}n!==1/0&&n>ee[t]&&(ee[t]=n)}let I=new Float64Array(n);for(let e=0;e<n;e++)I[e]=(i?-ee[S[e]]:ee[S[e]])+w[e];x.push(I)}let N=0,P=1/0,F=[],ee=[];for(let e=0;e<4;e++){let t=1/0,r=-1/0,a=x[e];for(let e=0;e<n;e++){let n=i[e]/2;a[e]-n<t&&(t=a[e]-n),a[e]+n>r&&(r=a[e]+n)}F.push(t),ee.push(r),r-t<P&&(P=r-t,N=e)}for(let e=0;e<4;e++){let t=e&1?ee[N]-ee[e]:F[N]-F[e];if(t!==0){let r=x[e];for(let e=0;e<n;e++)r[e]+=t}}let te=new Float64Array(n);for(let e=0;e<n;e++){let t=x[0][e],n=x[1][e],r=x[2][e],i=x[3][e],a;t>n&&(a=t,t=n,n=a),r>i&&(a=r,r=i,i=a),t>r&&(a=t,t=r,r=a),n>i&&(a=n,n=i,i=a),n>r&&(a=n,n=r,r=a),te[e]=(n+r)/2}return te}function Xq(e){return e===`BT`||e===`LR`||e===`RL`?e:`TB`}var mht=4e4;function Zq(e,t,n,r){for(let t of e)t.x+=n,t.y+=r;for(let e of t){for(let t=0;t<e.route.length;t+=3)e.route[t]+=n,e.route[t+1]+=r;e.labelX+=n,e.labelY+=r}}function Qq(e,t,n=-1){return{w:e,h:t,parent:n,isGroup:!1,dir:void 0,padX:0,padTop:0,padBottom:0,minW:0,seq:0,span:0,x:0,y:0}}function hht(e){return e===`TB`?0:e===`BT`?2:e===`LR`?3:1}function $q(e){return e+2&3}function eJ(e,t,n,r){let i=e.length,a=/* @__PURE__ */ new Map,o=[],s=(e,t)=>{let n={id:e,dir:t,items:[],edges:[],ports:[],portOf:/* @__PURE__ */ new Map,routes:/* @__PURE__ */ new Map,x:0,y:0};return a.set(e,n),n},c=s(-1,n),l=[];for(let e=0;e<i;e++)l.push([]);let u=[];for(let t=0;t<i;t++){let n=e[t].parent;n>=0&&n<i&&n!==t&&e[n].isGroup?l[n].push(t):(e[t].parent=-1,u.push(t))}c.items=u,o.push(c);let d=new Int32Array(i),f=new Uint8Array(i),p=t=>{for(let n=t;n<o.length;n++){let t=o[n];for(let n of t.items)if(f[n]=1,d[n]=t.id<0?0:d[t.id]+1,e[n].isGroup){let r=s(n,e[n].dir??t.dir);r.items=l[n],o.push(r)}}};p(0);for(let t=0;t<i;t++){if(f[t])continue;let r=e[t].parent;if(l[r]=l[r].filter(e=>e!==t),e[t].parent=-1,c.items.push(t),f[t]=1,d[t]=0,e[t].isGroup){let r=o.length,i=s(t,e[t].dir??n);i.items=l[t],o.push(i),p(r)}}for(let t=o.length-1;t>0;t--){let n=o[t],r=1/0;for(let t of n.items)e[t].seq<r&&(r=e[t].seq);r!==1/0&&(e[n.id].seq=r)}for(let t of o)t.items.sort((t,n)=>e[t].seq-e[n].seq||t-n);let m=0;for(let n of t){let t=n.src,r=n.dst,i=0;for(;d[t]>d[r];i++)t=e[t].parent;for(;d[r]>d[t];i++)r=e[r].parent;for(;t!==r&&e[t].parent!==e[r].parent;i+=2)t=e[t].parent,r=e[r].parent;t!==r&&(m+i>mht?(n.src=t,n.dst=r):m+=i)}let h=[],g=[];for(let n=0;n<t.length;n++){let r=t[n];if(r.route=[],r.src===r.dst){h.push(n);continue}let i=r.src,o=r.dst,s=[],c=[];for(;d[i]>d[o];)s.push(i),i=e[i].parent;for(;d[o]>d[i];)c.push(o),o=e[o].parent;if(i===o)g.push(n);else{for(;e[i].parent!==e[o].parent;)s.push(i),c.push(o),i=e[i].parent,o=e[o].parent;a.get(e[i].parent).edges.push({e:n,a:i,b:o});for(let[t,r]of[[s,!0],[c,!1]])for(let i of t){let t=a.get(e[i].parent),o={e:n,inner:i,out:r,side:0,px:0,py:0,route:[]};t.ports.push(o),t.portOf.set(n*2+ +!r,o)}}}let _=new Int32Array(i),v=(e,t,n)=>(n?t.src:t.dst)!==e,y=(n,r)=>{let i=n.dir===`TB`||n.dir===`BT`,o=hht(n.dir),s=[],c=[];n.items.forEach((t,n)=>{_[t]=n;let a=e[t],o=r?Hq(i?a.w:a.h,i?a.h:a.w):Hq(0,0);o.span=a.isGroup?Math.min(a.span,o.w-2*a.padX):a.span,s.push(o)});let l=(n,r,i)=>e[n].isGroup&&v(n,t[r],i),u=(n,o,s)=>{if(!r||!e[n].isGroup||!v(n,t[o],s))return 0;let c=a.get(n).portOf.get(o*2+ +!s);return i?c.px-e[n].w/2:c.py-e[n].h/2};for(let e of n.edges){let n=t[e.e],a=Uq(_[e.a],_[e.b],n.minlen);r&&(a.labelW=i?n.labelW:n.labelH,a.labelH=i?n.labelH:n.labelW,a.tailDx=u(e.a,e.e,!0),a.headDx=u(e.b,e.e,!1),a.tailFixed=l(e.a,e.e,!0),a.headFixed=l(e.b,e.e,!1)),c.push(a)}let d=new Int32Array(n.ports.length).fill(-1);return n.ports.forEach((e,t)=>{if(e.side===o||e.side===$q(o)){let n=s.length;s.push(Hq(0,0,e.side===o?3:4)),d[t]=n;let r=e.out?Uq(_[e.inner],n):Uq(n,_[e.inner]);e.out?(r.tailDx=u(e.inner,e.e,!0),r.tailFixed=l(e.inner,e.e,!0)):(r.headDx=u(e.inner,e.e,!1),r.headFixed=l(e.inner,e.e,!1)),c.push(r)}else s[_[e.inner]].pin=e.side===0||e.side===3?-1:1}),{lnodes:s,ledges:c,dummies:d}};for(let n of o){for(let r of n.ports)e[r.inner].isGroup&&v(r.inner,t[r.e],r.out)&&(a.get(r.inner).portOf.get(r.e*2+ +!r.out).side=r.side);if(n.edges.length===0)continue;let r=!1;for(let i of n.edges){let n=t[i.e];(e[i.a].isGroup&&n.src!==i.a||e[i.b].isGroup&&n.dst!==i.b)&&(r=!0)}if(!r)continue;let{lnodes:i,ledges:o}=y(n,!1);qq(i,o),Jq(i,o,1);let s=hht(n.dir);n.edges.forEach((n,r)=>{let i=t[n.e],c=!o[r].reversed;e[n.a].isGroup&&i.src!==n.a&&(a.get(n.a).portOf.get(n.e*2).side=c?$q(s):s),e[n.b].isGroup&&i.dst!==n.b&&(a.get(n.b).portOf.get(n.e*2+1).side=c?s:$q(s))})}let b={width:0,height:0};for(let n=o.length-1;n>=0;n--){let i=o[n],s=i.id>=0?e[i.id]:void 0,c=i.dir===`TB`||i.dir===`BT`,l=i.dir===`BT`||i.dir===`RL`,{lnodes:u,ledges:d,dummies:f}=y(i,!0),p=$mt(u,d,r),m=c?p.width:p.height,h=c?p.height:p.width,g=s?s.padX:0,_=s?s.padTop:0,x=Math.max(m+2*g,s?s.minW:0),S=h+_+(s?s.padBottom:0),C=(x-m)/2,w=_,T=(e,t)=>C+(c?e:l?p.height-t:t),E=(e,t)=>w+(c?l?p.height-t:t:e),D=+!c,O=e=>{let t=[];for(let n=0;n<e.length;n+=2)t.push(T(e[n],e[n+1]),E(e[n],e[n+1]),D);return t};i.items.forEach((t,n)=>{e[t].x=T(u[n].x,u[n].y),e[t].y=E(u[n].x,u[n].y)}),i.edges.forEach((e,n)=>{let r=d[n];i.routes.set(e.e,O(r.points));let a=t[e.e];a.labelW>0&&(a.labelX=T(r.labelX,r.labelY),a.labelY=E(r.labelX,r.labelY))});let k=i.edges.length;i.ports.forEach((n,r)=>{let i=e[n.inner];if(f[r]>=0){let e=O(d[k++].points),t=n.out?e.length-3:0,r=e[t],i=e[t+1];n.side===0?i=0:n.side===2?i=S:r=n.side===3?0:x,n.out?e.push(r,i,D):e.unshift(r,i,D),n.px=r,n.py=i,n.route=e;return}let o=i.x,s=i.y;if(i.isGroup&&v(n.inner,t[n.e],n.out)){let e=a.get(n.inner).portOf.get(n.e*2+ +!n.out);o+=e.px-i.w/2,s+=e.py-i.h/2}else n.side===0?s-=i.h/2:n.side===2?s+=i.h/2:n.side===3?o-=i.w/2:o+=i.w/2;let c=o,l=s;n.side===0?l=0:n.side===2?l=S:c=n.side===3?0:x;let u=n.side===0||n.side===2?0:1;n.px=c,n.py=l,n.route=n.out?[o,s,u,c,l,u]:[c,l,u,o,s,u]}),s?(s.w=x,s.h=S):b={width:x,height:S}}for(let t of o){let n=t.x,r=t.y;for(let i of t.items){let t=e[i];if(t.x+=n,t.y+=r,t.isGroup){let e=a.get(i);e.x=t.x-t.w/2,e.y=t.y-t.h/2}}}let x=(e,t,n,r)=>{for(let i=0;i<t.length;i+=3){let a=t[i]+n,o=t[i+1]+r,s=e.length;s>=3&&Math.abs(e[s-3]-a)<.01&&Math.abs(e[s-2]-o)<.01||e.push(a,o,t[i+2])}};for(let n of o)for(let r of n.edges){let i=t[r.e],o=[],s=[];for(let t=i.src;e[t].parent!==n.id;t=e[t].parent)s.push(a.get(e[t].parent));for(let e of s)x(o,e.portOf.get(r.e*2).route,e.x,e.y);x(o,n.routes.get(r.e),n.x,n.y);let c=[];for(let t=i.dst;e[t].parent!==n.id;t=e[t].parent)c.push(a.get(e[t].parent));for(let e=c.length-1;e>=0;e--)x(o,c[e].portOf.get(r.e*2+1).route,c[e].x,c[e].y);i.route=o,i.labelW>0&&(i.labelX+=n.x,i.labelY+=n.y)}for(let n of g){let r=t[n],i=e[r.src],a=e[r.dst];r.route=[i.x,i.y,0,a.x,a.y,0],r.labelX=(i.x+a.x)/2,r.labelY=(i.y+a.y)/2}for(let n of h){let r=t[n],i=e[r.src];r.labelX=i.x+i.w/2+28+r.labelW/2,r.labelY=i.y}return b}function tJ(e,t){for(let n=0;n<t.length;n+=3){let r=Math.round(t[n+1]),i=e.get(r);i?i.push(t[n]):e.set(r,[t[n]])}}function nJ(e,t,n,r){if(t===0)return e.x;let i=e.y-e.h/2,a=e.x-e.w/2,o=t/2,s=[a+r-6+o,e.x,a+e.w-r+6-o],c=n.get(Math.round(i));if(c===void 0)return s[0];let l=s[0],u=-1;for(let t of s){let n=1/0;for(let r of c)r>a&&r<a+e.w&&(n=Math.min(n,Math.abs(r-t)-o));if(n>=6)return t;n>u+.5&&(u=n,l=t)}return l}function ght(e,t,n,r){let i=t>0?r.get(Math.round(e.y-e.h/2)):void 0;if(i===void 0)return!1;let a=e.x-e.w/2;for(let r of i)if(r>a&&r<a+e.w&&Math.abs(r-n)<t/2+4)return!0;return!1}function _ht(e,t,n,r,i,a,o,s){let c=1;for(let e=a[o].parent;e>=0&&c<8;e=a[e].parent)c++;let l=`color-mix(in srgb,var(--_a) ${K(100*(1-.5**c))}%,var(--_bg))`;return`<g class="pele-cluster-title" data-id="${i}">`+gq(e,t,n,` fill="none" stroke="${l}" stroke-width="5" stroke-linejoin="round"`,s)+gq(e,t,n,r,s)+`</g>`}var rJ=8,vht=12,iJ=.62,aJ=6;function yht(){let e=/* @__PURE__ */ new Map;return{add(t,n,r){let i=sJ(r);n>=0&&i>0&&i+aJ>(e.get(t*4+n)??0)&&e.set(t*4+n,i+aJ)},of:(t,n)=>n>=0?e.get(t*4+n)??0:0}}function oJ(e,t,n,r,i=n>0?n+aJ:0,a=r>0?r+aJ:0){let o=t===`linear`,s=t===`step`||t===`stepBefore`||t===`stepAfter`,c=[],l=[],u=[],d=(e,t,n,r)=>Math.abs(e-n)<.01&&Math.abs(t-r)<.01;for(let n=0;n<e.length;n+=3){let r=e[n],i=e[n+1],a=e[n+2],o=c.length-1;if(s&&o>=0&&Math.abs(r-c[o])>=.01&&Math.abs(i-l[o])>=.01){let e=c[o],n=l[o],s=t===`stepBefore`?n:t===`stepAfter`?i:(n+i)/2,f=t===`stepBefore`?e:t===`stepAfter`?r:(e+r)/2,p=a===0?[e,s,r,s]:[f,n,f,i];for(let t=0;t<4;t+=2)d(p[t],p[t+1],e,n)||d(p[t],p[t+1],r,i)||(c.push(p[t]),l.push(p[t+1]),u.push(a))}c.push(r),l.push(i),u.push(a)}let f=c.length-1,p=e=>Math.abs(c[e]-c[e-1])<.01||Math.abs(l[e]-l[e-1])<.01,m=e=>o||p(e),h=(e,t,n)=>{if(!m(Math.max(e,t)))return n===0?[0,Math.sign(l[t]-l[e])||1]:[Math.sign(c[t]-c[e])||1,0];let r=c[t]-c[e],i=l[t]-l[e],a=Math.hypot(r,i)||1;return[r/a,i/a]},[g,_]=h(0,1,u[1]),[v,y]=h(f-1,f,u[f]),b=c[0],x=l[0],S=c[f],C=l[f];c[0]+=g*n,l[0]+=_*n,c[f]-=v*r,l[f]-=y*r;let w=e=>Math.abs(c[e]-c[e-1])+Math.abs(l[e]-l[e-1]),T=e=>!o&&e>0&&e<f&&p(e)&&p(e+1)&&w(e)>=.01&&w(e+1)>=.01&&Math.abs(c[e]-c[e-1])<.01!=Math.abs(c[e+1]-c[e])<.01,E=(e,t,n)=>Math.abs(c[e]-c[e-1])*Math.abs(t)+Math.abs(l[e]-l[e-1])*Math.abs(n),D=(e,t,n)=>{let r=Math.min(Math.max(0,e-aJ-t),n/4);return r+Math.min(e-t-r,(n-r)/4)},O=a>r&&(!m(f)||T(f-1))?D(a,r,E(f,v,y)):0,k=i>n&&(!m(1)||T(1))?D(i,n,E(1,g,_)):0;O>=1&&(c.splice(f,0,c[f]-v*O),l.splice(f,0,l[f]-y*O),u.splice(f,0,u[f]),f++),k>=1&&(c.splice(1,0,c[0]+g*k),l.splice(1,0,l[0]+_*k),u.splice(1,0,u[1]),f++);let A=`M${K(c[0])},${K(l[0])}`,j=c[0],M=l[0],N=(e,t)=>{d(e,t,j,M)||(A+=`L${K(e)},${K(t)}`,j=e,M=t)};for(let e=1;e<=f;e++){let t=c[e],n=l[e];if(!m(e)){let r=u[e]===0,i=r?n-M:t-j,a=Math.abs(i)*rht(r?t-j:n-M,i),o=r?0:Math.sign(i)*a,s=r?Math.sign(i)*a:0;A+=`C${K(j+o)},${K(M+s)} ${K(t-o)},${K(n-s)} ${K(t)},${K(n)}`,j=t,M=n;continue}if(!T(e)){if(e<f&&p(e)&&p(e+1)&&(t-c[e-1])*(c[e+1]-t)+(n-l[e-1])*(l[e+1]-n)>0)continue;N(t,n);continue}let r=T(e-1)?w(e)/2:w(e),i=T(e+1)?w(e+1)/2:w(e+1);s&&(r=i=Math.min(vht,r,i));let[a,o]=h(e-1,e,u[e]),[d,g]=h(e,e+1,u[e+1]);N(t-a*r,n-o*r),j=t+d*i,M=n+g*i,A+=s?`Q${K(t)},${K(n)} ${K(j)},${K(M)}`:`C${K(t-a*r*(1-iJ))},${K(n-o*r*(1-iJ))} ${K(t+d*i*(1-iJ))},${K(n+g*i*(1-iJ))} ${K(j)},${K(M)}`}return{d:A,sx:b,sy:x,sdx:-g,sdy:-_,ex:S,ey:C,edx:v,edy:y}}function sJ(e){return e===`arrow_point`?rJ-1:e===`arrow_circle`?rJ:e===`arrow_cross`?4:0}function cJ(e,t,n,r,i,a){let o=-i,s=r;if(e===`arrow_point`){let e=t-r*rJ,c=n-i*rJ,l=rJ*.42;return`<path class="pele-marker" d="M${K(t)},${K(n)}L${K(e+o*l)},${K(c+s*l)}L${K(e-o*l)},${K(c-s*l)}Z" fill="${a}" stroke="none"/>`}if(e===`arrow_circle`)return`<circle class="pele-marker" cx="${K(t-r*4)}" cy="${K(n-i*4)}" r="3.5" fill="${a}" stroke="none"/>`;if(e===`arrow_cross`){let e=t-r*4,a=n-i*4,c=3.5,l=(r+o)*c,u=(i+s)*c,d=(r-o)*c,f=(i-s)*c;return`<path class="pele-marker" d="M${K(e-l)},${K(a-u)}L${K(e+l)},${K(a+u)}M${K(e-d)},${K(a-f)}L${K(e+d)},${K(a+f)}"/>`}return``}function lJ(e,t,n,r,i,a){let o=t.width+8,s=t.height;return`<g class="pele-edge-label" data-id="${mq(e)}"><rect x="${K(n-o/2)}" y="${K(r-s/2)}" width="${K(o)}" height="${K(s)}" rx="3" fill="var(--_bg)"/>`+gq(t,n,r,i,a)+`</g>`}function bht(e,t,n,r,i,a,o,s){let c=(i?t:n)/2,l=Math.min(c-4,8+r*6),u=a+r*8,d=Math.hypot(u,l)||1,f=(r,a)=>i?`${K(e.x+a)},${K(e.y+n/2+r)}`:`${K(e.x+t/2+r)},${K(e.y+a)}`,p=u/d*o,m=l/d*o;return i?(s.labelX=e.x,s.labelY=e.y+n/2+u+4+s.labelH/2):(s.labelX=e.x+t/2+u+4+s.labelW/2,s.labelY=e.y),{d:`M${f(0,-l)}C${f(u,-l*2)} ${f(u,l*2)} ${f(p,l+m)}`,sx:i?e.x-l:e.x+t/2,sy:i?e.y+n/2:e.y-l,sdx:i?0:-1,sdy:i?-1:0,ex:i?e.x+l:e.x+t/2,ey:i?e.y+n/2:e.y+l,edx:i?-l/d:-u/d,edy:i?-u/d:-l/d}}var xht=`--_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)`,uJ=`var(--_fm)`,dJ=`var(--pele-radius,4px)`,fJ=`var(--pele-critical,#e45756)`,Sht=String.raw`(?:"[^"'\\\n<>{}();:@]*"|'[^"'\\\n<>{}();:@]*'|[\p{L}\p{N}_-][\p{L}\p{N}_ .-]*)`,Cht=new RegExp(String.raw`^\s*${Sht}(?:\s*,\s*${Sht})*\s*$`,`u`);function wht(e,t){return e&&Cht.test(e)?e:t}function Tht(e,t,n){return`;--_fm:var(--pele-font-mono,${wht(n,`monospace`)});font:${e}px sans-serif;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;font-family:var(--pele-font,${wht(t,`sans-serif`)})`}var Eht=/* @__PURE__ */ new Set([`fill`,`fill-opacity`,`stroke`,`stroke-width`,`stroke-dasharray`,`stroke-dashoffset`,`stroke-linecap`,`stroke-linejoin`,`stroke-opacity`,`opacity`,`rx`,`ry`]),Dht=/* @__PURE__ */ new Set([`color`,`font-size`,`font-family`,`font-weight`,`font-style`,`text-decoration`,`letter-spacing`,`word-spacing`,`opacity`]),Oht=/url\s*\(|expression\s*\(|javascript:|[<>{};\\]|@import|image-set|\/\*/i,kht={shape:``,line:``,text:``,stroke:void 0,bold:!1,italic:!1,fontSize:void 0};function pJ(e){if(e.length===0)return kht;let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map;for(let r of e){let e=r.indexOf(`:`);if(e<=0)continue;let i=r.slice(0,e).trim().toLowerCase(),a=r.slice(e+1).replace(/!important/gi,``).trim();a===``||Oht.test(a)||(Eht.has(i)&&t.set(i,a),Dht.has(i)&&n.set(i===`color`?`fill`:i,a))}if(t.size===0&&n.size===0)return kht;let r=``,i=``;for(let[e,n]of t)r+=`${e}:${n};`,e!==`fill`&&e!==`fill-opacity`&&(i+=`${e}:${n};`);let a=``;for(let[e,t]of n)a+=`${e}:${t};`;let o=n.get(`font-weight`),s=n.get(`font-size`),c=s&&/^[\d.]+(px)?$/.test(s)?parseFloat(s):void 0;return{shape:r?` style="${pq(r)}"`:``,line:i?` style="${pq(i)}"`:``,text:a?` style="${pq(a)}"`:``,stroke:t.get(`stroke`),bold:o===`bold`||o===`bolder`||Number(o)>=600,italic:n.get(`font-style`)===`italic`,fontSize:c!==void 0&&c>0&&c<=200?c:void 0}}var Aht=/[^\w-]+/g;function mJ(e){let t=e.replace(Aht,` `).trim();return t===``?``:` `+t}var jht=[`#4c78a8`,`#f58518`,`#54a24b`,`#e45756`,`#72b7b2`,`#eeca3b`,`#b279a2`,`#9d755d`];function hJ(e){let t=(e%8+8)%8;return`var(--pele-series-${t+1},${jht[t]})`}var gJ=` rx="${dJ}"`,Mht=/<rect\b[^>]*>/g;function Nht(e){return e.includes(gJ)?e.replace(Mht,e=>{let t=e.indexOf(gJ);if(t<0)return e;let n=e.slice(0,t)+e.slice(t+gJ.length),r=n.indexOf(` style="`);if(r>=0)return`${n.slice(0,r+8)}rx:var(--_r);${n.slice(r+8)}`;let i=n.endsWith(`/>`)?n.length-2:n.length-1;return`${n.slice(0,i)} style="rx:var(--_r)"${n.slice(i)}`}):e}var Pht=[[`--_tw`,`title`],[`--_hw`,`heading`],[`--_w`,`bold`]];function _J(e,t,n,r,i,a,o){let s=pq(i.idPrefix??`pele`),c=``,l=``;a.accTitle&&(c+=`<title id="${s}-title">${mq(a.accTitle)}</title>`,l+=` aria-labelledby="${s}-title"`),a.accDescr&&(c+=`<desc id="${s}-desc">${mq(a.accDescr)}</desc>`,l+=` aria-describedby="${s}-desc"`);let u=i.responsive===!1?``:`max-width:100%;height:auto;`;o=Nht(o);let d=o.includes(`var(--_r)`)?`;--_r:${dJ}`:``;for(let[e,t]of Pht)o.includes(`var(${e})`)&&(d+=`;${e}:var(--pele-${t}-weight,bold)`);return`<svg xmlns="http://www.w3.org/2000/svg" class="pele pele-${e}" viewBox="0 0 ${t} ${n}" width="${t}" height="${n}" style="${u}${xht}${d}${pq(Tht(r,i.fontFamily,i.fontFamilyMono))}" fill="var(--_fg)" role="graphics-document document" aria-roledescription="${e}"${l}>`+c+o+`</svg>`}var vJ=18,yJ=12,bJ=12,xJ=(e,t,n)=>(n?t:e)-2*bJ,SJ=e=>(t,n,r)=>r?0:t-2*e(n)-2*bJ;function CJ(e,t,n){let r=Math.min(1,Math.abs(e)/t);return n*(1-Math.sqrt(1-r*r))}var wJ=(e,t,n,r)=>n&1?CJ(r,t/2,e/2):CJ(r,e/2,t/2),TJ=(e,t,n)=>(n?t:e)*.6,Fht=(e,t,n,r)=>n&1?0:CJ(r,e/2,Math.min(12,Math.max(6,e/14))),EJ=(e,t)=>()=>({w:e,h:t,dy:0});function Iht(e,t,n){let r=Math.max(1.6*e+40,80),i=(t+10)/(1-(e+8)/r),a=i/2-10-t/2;return{w:r,h:i,dy:n?-a:a}}function DJ(e,t){return`<path d="${e}"${t}/>`}var OJ=(e,t,n)=>n&1?t/8:0,kJ=(e,t)=>({w:Math.max(e+2*vJ,2*vJ+12),h:t+2*yJ,dy:0});function AJ(e,t){let n=``;for(let t=0;t<e.length;t+=2)n+=(t?` `:``)+K(e[t])+`,`+K(e[t+1]);return`<polygon points="${n}"${t}/>`}function jJ(e,t,n,r=``){return`<rect x="${K(-e/2)}" y="${K(-t/2)}" width="${K(e)}" height="${K(t)}"${r}${n}/>`}var MJ=` rx="${dJ}"`,Lht={rect:{size:kJ,span:xJ,draw:(e,t,n)=>jJ(e,t,n,MJ)},rounded:{size:kJ,span:xJ,draw:(e,t,n)=>jJ(e,t,n,` rx="${K(Math.min(12,t/2))}"`)},stadium:{inset:(e,t,n,r)=>n&1?CJ(r,t/2,t/2):0,span:(e,t,n)=>n?t*.6:e-t,size:(e,t)=>{let n=t+2*yJ;return{w:e+n*.5+2*vJ-8,h:n,dy:0}},draw:(e,t,n)=>jJ(e,t,n,` rx="${K(t/2)}"`)},"fr-rect":{span:xJ,size:(e,t)=>({w:e+2*vJ+16,h:t+2*yJ,dy:0}),draw:(e,t,n,r)=>{let i=e/2-8;return jJ(e,t,n,MJ)+`<path d="M${K(-i)},${K(-t/2)}V${K(t/2)}M${K(i)},${K(-t/2)}V${K(t/2)}" fill="none"${r}/>`}},cyl:{inset:Fht,span:(e,t,n)=>n?t-2*bJ-12:e*.6,size:(e,t)=>{let n=Math.max(e+2*vJ,56),r=Math.min(12,Math.max(6,n/14));return{w:n,h:t+2*yJ+2*r,dy:r/2}},draw:(e,t,n,r)=>{let i=e/2,a=Math.min(12,Math.max(6,e/14)),o=-t/2+a,s=t/2-a;return`<path d="M${K(-i)},${K(o)}A${K(i)},${K(a)} 0 0 1 ${K(i)},${K(o)}V${K(s)}A${K(i)},${K(a)} 0 0 1 ${K(-i)},${K(s)}Z"${n}/><path d="M${K(-i)},${K(o)}A${K(i)},${K(a)} 0 0 0 ${K(i)},${K(o)}" fill="none"${r}/>`}},circle:{inset:wJ,span:TJ,size:(e,t)=>{let n=Math.max(Math.sqrt(e*e+t*t)+16,44);return{w:n,h:n,dy:0}},draw:(e,t,n)=>`<circle r="${K(e/2)}"${n}/>`},"dbl-circ":{inset:wJ,span:TJ,size:(e,t)=>{let n=Math.max(Math.sqrt(e*e+t*t)+26,54);return{w:n,h:n,dy:0}},draw:(e,t,n,r)=>`<circle r="${K(e/2)}"${n}/><circle r="${K(e/2-5)}" fill="none"${r}/>`},ellipse:{inset:wJ,span:TJ,size:(e,t)=>({w:e*1.3+2*vJ,h:t*1.2+2*yJ,dy:0}),draw:(e,t,n)=>`<ellipse rx="${K(e/2)}" ry="${K(t/2)}"${n}/>`},diam:{inset:(e,t,n,r)=>n&1?Math.abs(r)*e/t:Math.abs(r)*t/e,span:(e,t,n)=>(n?t:e)*.6,size:(e,t)=>{let n=e+16,r=t+8;return{w:n+1.6*r,h:n/1.6+r,dy:0}},draw:(e,t,n)=>AJ([0,-t/2,e/2,0,0,t/2,-e/2,0],n)},hex:{inset:(e,t,n,r)=>n&1?Math.abs(r)/2:0,span:(e,t,n)=>n?t*.5:e-t/2-bJ,size:(e,t)=>{let n=t+2*yJ;return{w:e+2*vJ+n/2,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return AJ([-e/2+r,-t/2,e/2-r,-t/2,e/2,0,e/2-r,t/2,-e/2+r,t/2,-e/2,0],n)}},odd:{inset:(e,t,n)=>n===3?t/4:0,span:SJ(()=>0),size:(e,t)=>{let n=t+2*yJ;return{w:e+2*vJ+n/4,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return AJ([-e/2,-t/2,e/2,-t/2,e/2,t/2,-e/2,t/2,-e/2+r,0],n)}},"lean-r":{inset:OJ,span:SJ(e=>e/4),size:(e,t)=>{let n=t+2*yJ;return{w:e+2*vJ+n/2,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return AJ([-e/2+r,-t/2,e/2,-t/2,e/2-r,t/2,-e/2,t/2],n)}},"lean-l":{inset:OJ,span:SJ(e=>e/4),size:(e,t)=>{let n=t+2*yJ;return{w:e+2*vJ+n/2,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return AJ([-e/2,-t/2,e/2-r,-t/2,e/2,t/2,-e/2+r,t/2],n)}},"trap-b":{inset:OJ,span:SJ(e=>e/4),size:(e,t)=>{let n=t+2*yJ;return{w:e+2*vJ+n/2,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return AJ([-e/2+r,-t/2,e/2-r,-t/2,e/2,t/2,-e/2,t/2],n)}},"trap-t":{inset:OJ,span:SJ(e=>e/4),size:(e,t)=>{let n=t+2*yJ;return{w:e+2*vJ+n/2,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return AJ([-e/2,-t/2,e/2,-t/2,e/2-r,t/2,-e/2+r,t/2],n)}},text:{span:xJ,size:(e,t)=>({w:e+8,h:t+8,dy:0}),draw:(e,t)=>jJ(e,t,` fill="none" stroke="none"`)},"sm-circ":{noLabel:!0,inset:wJ,span:TJ,size:EJ(14,14),draw:(e,t,n)=>`<circle r="${K(e/2)}"${n}/>`},"f-circ":{noLabel:!0,inset:wJ,span:TJ,size:EJ(14,14),draw:(e,t,n,r)=>`<circle r="${K(e/2)}" fill="var(--_l)"${r}/>`},"fr-circ":{noLabel:!0,inset:wJ,span:TJ,size:EJ(18,18),draw:(e,t,n,r)=>`<circle r="${K(e/2)}"${n}/><circle r="${K(e/2-4)}" fill="var(--_l)"${r}/>`},fork:{noLabel:!0,span:(e,t,n)=>(n?t:e)-8,size:EJ(72,8),draw:(e,t,n,r)=>jJ(e,t,` fill="var(--_l)"${r}`,` rx="2"`)},"notch-rect":{size:kJ,span:xJ,draw:(e,t,n)=>AJ([-e/2+10,-t/2,e/2,-t/2,e/2,t/2,-e/2,t/2,-e/2,-t/2+10],n)},"lin-rect":{span:xJ,size:(e,t)=>({w:e+2*vJ+8,h:t+2*yJ,dy:0}),draw:(e,t,n,r)=>jJ(e,t,n,MJ)+`<path d="M${K(-e/2+8)},${K(-t/2)}V${K(t/2)}" fill="none"${r}/>`},"div-rect":{span:xJ,size:(e,t)=>({w:e+2*vJ,h:t+2*yJ+8,dy:4}),draw:(e,t,n,r)=>jJ(e,t,n,MJ)+`<path d="M${K(-e/2)},${K(-t/2+8)}H${K(e/2)}" fill="none"${r}/>`},"win-pane":{span:xJ,size:(e,t)=>({w:e+2*vJ+8,h:t+2*yJ+8,dy:4}),draw:(e,t,n,r)=>jJ(e,t,n,MJ)+`<path d="M${K(-e/2+8)},${K(-t/2)}V${K(t/2)}M${K(-e/2)},${K(-t/2+8)}H${K(e/2)}" fill="none"${r}/>`},tri:{inset:(e,t,n)=>n&1?e/4:0,size:(e,t)=>Iht(e,t,!1),draw:(e,t,n)=>AJ([0,-t/2,e/2,t/2,-e/2,t/2],n)},"flip-tri":{inset:(e,t,n)=>n&1?e/4:0,size:(e,t)=>Iht(e,t,!0),draw:(e,t,n)=>AJ([-e/2,-t/2,e/2,-t/2,0,t/2],n)},"sl-rect":{inset:(e,t,n)=>n===0?5:0,size:(e,t)=>({w:e+2*vJ,h:t+2*yJ+10,dy:5}),draw:(e,t,n)=>AJ([-e/2,-t/2+10,e/2,-t/2,e/2,t/2,-e/2,t/2],n)},"notch-pent":{span:xJ,size:(e,t)=>({w:e+2*vJ,h:t+2*yJ,dy:0}),draw:(e,t,n)=>AJ([-e/2+10,-t/2,e/2-10,-t/2,e/2,-t/2+10,e/2,t/2,-e/2,t/2,-e/2,-t/2+10],n)},hourglass:{noLabel:!0,inset:(e,t,n)=>n&1?e/2:0,size:EJ(32,40),draw:(e,t,n)=>AJ([-e/2,-t/2,e/2,-t/2,-e/2,t/2,e/2,t/2],n)},delay:{size:(e,t)=>{let n=t+2*yJ;return{w:e+2*vJ+n/4,h:n,dy:0}},draw:(e,t,n)=>{let r=t/2;return`<path d="M${K(-e/2)},${K(-r)}H${K(e/2-r)}A${K(r)},${K(r)} 0 0 1 ${K(e/2-r)},${K(r)}H${K(-e/2)}Z"${n}/>`}},"h-cyl":{size:(e,t)=>{let n=t+2*yJ,r=Math.min(12,n/4);return{w:e+2*vJ+2*r,h:n,dy:0}},draw:(e,t,n,r)=>{let i=t/2,a=Math.min(12,t/4),o=-e/2+a,s=e/2-a;return`<path d="M${K(o)},${K(-i)}H${K(s)}A${K(a)},${K(i)} 0 0 1 ${K(s)},${K(i)}H${K(o)}A${K(a)},${K(i)} 0 0 1 ${K(o)},${K(-i)}Z"${n}/><path d="M${K(s)},${K(-i)}A${K(a)},${K(i)} 0 0 0 ${K(s)},${K(i)}" fill="none"${r}/>`}},"cross-circ":{noLabel:!0,inset:wJ,span:TJ,size:EJ(44,44),draw:(e,t,n,r)=>{let i=e/2,a=i*Math.SQRT1_2;return`<circle r="${K(i)}"${n}/><path d="M${K(-a)},${K(-a)}L${K(a)},${K(a)}M${K(a)},${K(-a)}L${K(-a)},${K(a)}" fill="none"${r}/>`}},"st-rect":{span:(e,t,n)=>(n?t:e)-2*bJ-8,size:(e,t)=>({w:e+2*vJ+8,h:t+2*yJ+8,dy:4}),draw:(e,t,n)=>{let r=e-8,i=t-8,a=``;for(let o=0;o<3;o++){let s=-e/2+(2-o)*4,c=-t/2+o*4;a+=`<rect x="${K(s)}" y="${K(c)}" width="${K(r)}" height="${K(i)}"${MJ}${n}/>`}return a}},doc:{inset:(e,t,n)=>n===2?10:0,size:(e,t)=>({w:e+2*vJ,h:t+2*yJ+10,dy:-5}),draw:(e,t,n)=>PJ(e,t,n)},flag:{inset:(e,t,n)=>n&1?0:8,size:(e,t)=>({w:e+2*vJ,h:t+2*yJ+16,dy:0}),draw:(e,t,n)=>{let r=e/2,i=t/2-8,a=e/4;return`<path d="M${K(-r)},${K(-i)}q${K(a)},-10 ${K(2*a)},0t${K(2*a)},0V${K(i)}q${K(-a)},10 ${K(-2*a)},0t${K(-2*a)},0Z"${n}/>`}},datastore:{size:kJ,span:xJ,draw:(e,t,n,r)=>jJ(e,t,n.replace(`stroke="var(--_b)"`,`stroke="none"`))+`<path d="M${K(-e/2)},${K(-t/2)}H${K(e/2)}M${K(-e/2)},${K(t/2)}H${K(e/2)}" fill="none"${r}/>`},folder:{size:(e,t)=>({w:Math.max(e+2*vJ,64),h:t+2*yJ+8,dy:4}),draw:(e,t,n)=>{let r=e/2,i=t/2,a=Math.min(e*.4,48);return DJ(`M${K(-r)},${K(-i)}H${K(-r+a)}L${K(-r+a+8)},${K(-i+8)}H${K(r)}V${K(i)}H${K(-r)}Z`,n)}},bucket:{size:(e,t)=>({w:e+2*vJ+20,h:t+2*yJ+10,dy:3}),inset:(e,t,n)=>n&1?t/12:0,draw:(e,t,n,r)=>{let i=e/2,a=t/2,o=t/6;return DJ(`M${K(-i)},${K(-a+5)}A${K(i)},${K(5)} 0 0 1 ${K(i)},${K(-a+5)}L${K(i-o)},${K(a-5)}A${K(i-o)},${K(5)} 0 0 1 ${K(-i+o)},${K(a-5)}Z`,n)+`<path d="M${K(-i)},${K(-a+5)}A${K(i)},${K(5)} 0 0 0 ${K(i)},${K(-a+5)}" fill="none"${r}/>`}},console:{span:xJ,size:(e,t)=>({w:Math.max(e+2*vJ,72),h:t+2*yJ+12,dy:6}),draw:(e,t,n,r)=>jJ(e,t,n,MJ)+`<path d="M${K(-e/2)},${K(-t/2+12)}H${K(e/2)}M${K(-e/2+7)},${K(-t/2+4)}l3,2.5l-3,2.5M${K(-e/2+13)},${K(-t/2+9)}h4" fill="none"${r}/>`},browser:{span:xJ,size:(e,t)=>({w:Math.max(e+2*vJ,72),h:t+2*yJ+12,dy:6}),draw:(e,t,n,r)=>{let i=``;for(let n=0;n<3;n++)i+=`<circle cx="${K(-e/2+8+n*7)}" cy="${K(-t/2+6)}" r="1.5" fill="none"${r}/>`;return jJ(e,t,n,MJ)+`<path d="M${K(-e/2)},${K(-t/2+12)}H${K(e/2)}" fill="none"${r}/>`+i}},person:{size:(e,t)=>({w:Math.max(e+2*vJ,56),h:t+2*yJ+26,dy:13}),draw:(e,t,n)=>{let r=-t/2;return`<rect x="${K(-e/2)}" y="${K(r+26)}" width="${K(e)}" height="${K(t-26)}" rx="12"${n}/><circle cy="${K(r+14)}" r="13"${n}/>`}},bang:{size:(e,t)=>({w:e+2*vJ+28,h:t+2*yJ+24,dy:0}),inset:()=>3,draw:(e,t,n)=>{let r=[];for(let n=0;n<28;n++){let i=Math.PI*n/14-Math.PI/2,a=n%2==0?1:.82;r.push(e/2*Math.cos(i)*a,t/2*Math.sin(i)*a)}return AJ(r,n)}},cloud:{size:(e,t)=>({w:e+2*vJ+32,h:t+2*yJ+24,dy:0}),inset:(e,t,n)=>n&1?2:1,draw:(e,t,n)=>{let r=e/2,i=t/2,a=i*.55;return DJ(`M${K(-r+a)},${K(i)}A${K(a)},${K(a)} 0 0 1 ${K(-r+a*.6)},${K(-i*.1)}A${K(r*.42)},${K(i*.7)} 0 0 1 ${K(-r*.1)},${K(-i*.72)}A${K(r*.4)},${K(i*.62)} 0 0 1 ${K(r*.62)},${K(-i*.42)}A${K(a*1.05)},${K(a*1.05)} 0 0 1 ${K(r-a)},${K(i)}Z`,n)}},brace:{size:(e,t)=>({w:e+2*vJ+12,h:t+2*yJ,dy:0}),draw:(e,t,n,r)=>jJ(e,t,` fill="none" stroke="none"`)+NJ(-e/2+12,t,-1,r)},"brace-r":{size:(e,t)=>({w:e+2*vJ+12,h:t+2*yJ,dy:0}),draw:(e,t,n,r)=>jJ(e,t,` fill="none" stroke="none"`)+NJ(e/2-12,t,1,r)},braces:{size:(e,t)=>({w:e+2*vJ+24,h:t+2*yJ,dy:0}),draw:(e,t,n,r)=>jJ(e,t,` fill="none" stroke="none"`)+NJ(-e/2+12,t,-1,r)+NJ(e/2-12,t,1,r)},bolt:{noLabel:!0,size:EJ(36,56),inset:(e,t,n)=>n&1?e/4:0,draw:(e,t,n)=>AJ([e*.15,-t/2,-e/2,t*.08,-e*.05,t*.08,-e*.15,t/2,e/2,-t*.08,e*.05,-t*.08],n)},"lin-cyl":{inset:Fht,span:(e,t,n)=>n?t-2*bJ-20:e*.6,size:(e,t)=>{let n=Math.max(e+2*vJ,56),r=Math.min(12,Math.max(6,n/14));return{w:n,h:t+2*yJ+2*r+8,dy:r/2+4}},draw:(e,t,n,r)=>{let i=e/2,a=Math.min(12,Math.max(6,e/14)),o=-t/2+a,s=t/2-a,c=e=>`M${K(-i)},${K(e)}A${K(i)},${K(a)} 0 0 0 ${K(i)},${K(e)}`;return DJ(`M${K(-i)},${K(o)}A${K(i)},${K(a)} 0 0 1 ${K(i)},${K(o)}V${K(s)}A${K(i)},${K(a)} 0 0 1 ${K(-i)},${K(s)}Z`,n)+`<path d="${c(o)}${c(o+8)}" fill="none"${r}/>`}},"curv-trap":{size:(e,t)=>{let n=t+2*yJ;return{w:e+2*vJ+n*.6,h:n,dy:0}},draw:(e,t,n)=>{let r=e/2,i=t/2,a=t*.3;return DJ(`M${K(-r+a)},${K(-i)}H${K(r-a)}A${K(a)},${K(i)} 0 0 1 ${K(r-a)},${K(i)}H${K(-r+a)}L${K(-r)},0Z`,n)}},docs:{size:(e,t)=>({w:e+2*vJ+8,h:t+2*yJ+18,dy:-1}),inset:(e,t,n)=>n===2?10:0,draw:(e,t,n)=>{let r=``;for(let i=0;i<3;i++)r+=`<g transform="translate(${(1-i)*4},${(i-1)*4})">${PJ(e-8,t-8,n)}</g>`;return r}},"bow-rect":{size:(e,t)=>{let n=t+2*yJ;return{w:e+2*vJ+n*.4,h:n,dy:0}},inset:(e,t,n)=>n===1?t*.2:0,draw:(e,t,n)=>{let r=e/2,i=t/2,a=t*.2;return DJ(`M${K(-r+a)},${K(-i)}H${K(r)}A${K(a)},${K(i)} 0 0 0 ${K(r)},${K(i)}H${K(-r+a)}A${K(a)},${K(i)} 0 0 1 ${K(-r+a)},${K(-i)}Z`,n)}},"tag-rect":{size:kJ,span:xJ,draw:(e,t,n,r)=>jJ(e,t,n,MJ)+`<path d="M${K(e/2-12)},${K(t/2)}L${K(e/2)},${K(t/2-12)}" fill="none"${r}/>`},"tag-doc":{size:(e,t)=>({w:e+2*vJ,h:t+2*yJ+10,dy:-5}),inset:(e,t,n)=>n===2?10:0,draw:(e,t,n,r)=>PJ(e,t,n)+`<path d="M${K(e/2-12)},${K(t/2-14)}L${K(e/2)},${K(t/2-26)}" fill="none"${r}/>`},"lin-doc":{size:(e,t)=>({w:e+2*vJ+8,h:t+2*yJ+10,dy:-5}),inset:(e,t,n)=>n===2?10:0,draw:(e,t,n,r)=>PJ(e,t,n)+`<path d="M${K(-e/2+8)},${K(-t/2)}V${K(t/2-6)}" fill="none"${r}/>`},collapsedGroup:{size:(e,t)=>({w:e+2*vJ+8,h:t+2*yJ+8,dy:-2}),draw:(e,t,n)=>`<rect x="${K(-e/2+6)}" y="${K(-t/2+8)}" width="${K(e-12)}" height="${K(t-8)}"${MJ}${n}/><rect x="${K(-e/2)}" y="${K(-t/2)}" width="${K(e)}" height="${K(t-4)}"${MJ}${n}/>`}};function NJ(e,t,n,r){let i=t/2,a=6*n;return`<path d="M${K(e)},${K(-i)}q${K(a)},0 ${K(a)},6V-6q0,6 ${K(a)},6q${K(-a)},0 ${K(-a)},6V${K(i-6)}q0,6 ${K(-a)},6" fill="none"${r}/>`}function PJ(e,t,n){let r=e/2,i=-t/2,a=t/2-10,o=e/4;return`<path d="M${K(-r)},${K(i)}H${K(r)}V${K(a)}q${K(-o)},-12 ${K(-2*o)},0t${K(-2*o)},0Z"${n}/>`}var Rht=Lht.rect,FJ=new Map(Object.entries(Lht));function IJ(e,t,n){return(FJ.get(e)??Rht).size(t,n)}function LJ(e,t,n,r,i){return(FJ.get(e)??Rht).draw(t,n,r,i)}function RJ(e,t,n,r,i=0){return FJ.get(e)?.inset?.(t,n,r,i)??0}function zht(e,t,n,r){return Math.max(0,FJ.get(e)?.span?.(t,n,r)??0)}function Bht(e){return FJ.get(e)?.noLabel!==!0}function zJ(e,t,n){let r=e[t]-n.x,i=e[t+1]-n.y;return Math.abs(Math.abs(i)-n.h/2)<.5?i<0?0:2:Math.abs(Math.abs(r)-n.w/2)<.5?r<0?3:1:-1}function BJ(e,t,n,r){if(r.isGroup)return;let i=zJ(e,t,r);if(i===0||i===2){let a=RJ(n.shape,n.w,n.h,i,e[t]-r.x)+(r.h-n.h)/2;e[t+1]+=i===0?a:-a}else if(i>=0){let a=RJ(n.shape,n.w,n.h,i,e[t+1]-r.y)+(r.w-n.w)/2;e[t]+=i===3?a:-a}}var Vht=1.5,Hht=/<br\s*\/?>|\\n|\n/gi,Uht=/<\/?([a-zA-Z][\w-]*)(?:\s[^<>]*)?\/?>/y,Wht=/(fa[bklrs]?):fa-([\w-]+)/g,Ght=/[<\\\n*_]|fa[bklrs]?:fa-/,VJ=`\\u2e80-\\u9fff\\uf900-\\ufaff\\uff00-\\uff60`,Kht=`、。,.:;!?)]}」』】〕〉》〙〗ー…‥・ゝゞぁぃぅぇぉっゃゅょゎァィゥェォッャュョヮ,.:;!?)\\]}`,qht=`([{「『【〔〈《〘〖([{`,Jht=RegExp(`[${VJ}]`),Yht=RegExp(`\\s*(?:[${qht}]*[${VJ}][${Kht}]*|[^\\s${VJ}]+[${Kht}]*)\\s*|\\s+`,`g`),Xht={lines:[],widths:[],width:0,height:0,size:0,lineHeight:0};function Zht(e){let t=e.split(`
|
|
984
984
|
`),n=1/0;for(let e of t){if(e.trim()===``)continue;let t=e.length-e.trimStart().length;t<n&&(n=t)}return n===1/0||n===0?e:t.map(e=>e.slice(Math.min(n,e.length-e.trimStart().length))).join(`
|
|
985
|
-
`)}function
|
|
986
|
-
`)).trim():e.trim(),c=[],l=[],u=0;for(let e of s.split(Vht)){let o=[];Qht(o,e.trim(),t,a);let s=$ht(o,n,r);s>i?egt(o,n,r,i,c,l):(c.push(o),l.push(s))}for(let e of l)e>u&&(u=e);return{lines:c,widths:l,width:u,height:c.length*o,size:r,lineHeight:o}}function GJ(e,t,n,r){let i=r(t,!1),a=e.maxWidth;if(a===void 0||!(a>0)||i.width<=a)return i;let o=Math.min(n,t),s=t;i=r(s,!0);for(let e=0;e<3&&i.width>a&&s>o;e++)s=Math.max(o,s-(i.width-a)),i=r(s,!0);return i}function KJ(e){let t=e.maxWidth;return t!==void 0&&t>0?Math.max(80,t-2*(e.padding??8)):4e3}function qJ(e,t,n,r=0){let i=e.maxWidth;return i===void 0||!(i>0)?t:Math.max(Math.min(n,t),Math.min(t,i-r))}var tgt=640;function JJ(e,t){let n=t(!1),r=e.maxWidth;if(e.autoDirection===!1||r===void 0||!(r>0)||n.width<=r)return n;let i=e.directionBreakpoint;if(r>=(i!==void 0&&i>0?i:tgt))return n;let a=t(!0);return a.width<n.width?a:n}function YJ(e){return e===`LR`||e===`RL`}function XJ(e,t){let n=t(!1),r=e.maxWidth;if(r===void 0||!(r>0)||n.width<=r)return n;let i=t(!0);return i.width<n.width?i:n}var ZJ=/* @__PURE__ */ new Map([[`tool`,0],[`task`,1],[`decision`,2],[`input`,3],[`refdoc`,4],[`connector`,5],[`action`,6]]),ngt=ZJ.size,rgt=e=>Math.max(1,e-ngt),igt=(e,t)=>{let n=ngt+e%rgt(t);return t>0?n%t:n};function agt(e,t,n,r){let i=n.size;for(let a of e){if(a.isGroup||a.shape===`collapsedGroup`){a.colorIndex=igt(n.get(a.id)??i++,r);continue}let e=t(a.id);e&&ZJ.has(e)&&(a.kind=e)}}function ogt(e,t,n){let r=[],i=[],a=e.subgraphs,o=t=>{let n=[];for(let r of t){let t=e.classes.get(r);t?.styles&&(n=[...n,...t.styles].map(e=>e.trim())),t?.textStyles&&(n=[...n,...t.textStyles].map(e=>e.trim()))}return n},s=/* @__PURE__ */ new Set,c=/* @__PURE__ */ new Map,l=/* @__PURE__ */ new Set;for(let t of a){if(t.metadata?.view!==`collapsed`||s.has(t.id))continue;let n=[t.id];for(;n.length>0;){let r=e.subgraph(n.pop())?.nodes;if(r!==void 0)for(let e of r)e===t.id||s.has(e)||(s.add(e),c.set(e,t.id),l.has(e)||n.push(e))}l.add(t.id)}let u=/* @__PURE__ */ new Map;for(let e of s){let t=[e],n=c.get(e);for(;;){let e=u.get(n),r=e??c.get(n);if(r===void 0||(e===void 0&&t.push(n),n=r,e!==void 0))break}for(let e of t)u.set(e,n)}let d=/* @__PURE__ */ new Map;a.forEach((e,t)=>d.set(e.id,t));let f=/* @__PURE__ */ new Map,p=(e,t,n)=>{let r=d.get(e);if(r===void 0||r<n)return!1;let i=t;for(let t=0;i!==void 0&&t<=a.length;t++){if(i===e)return!0;i=f.get(i)}return!1};for(let t=a.length-1;t>=0;t--){let n=a[t];if(!s.has(n.id))for(let r of n.nodes)p(r,n.id,t)?e.emitWarning(`CONTAINMENT_VIOLATION`,`Container "${n.id}" cannot contain "${r}" because "${r}" already contains it. The nesting that would close the loop is dropped.`,{nodeId:r}):f.set(r,n.id)}let m=/* @__PURE__ */ new Map;for(let e=a.length-1;e>=0;e--){let t=a[e];if(s.has(t.id))continue;let n=t.metadata?.view===`collapsed`,i={id:t.id,label:t.title,labelType:t.labelType,parentId:f.get(t.id),cssStyles:[],cssCompiledStyles:o(t.classes),cssClasses:t.classes.join(` `),shape:n?`collapsedGroup`:`flowGroup`,dir:t.dir,isGroup:!n,metadata:n?{...t.metadata,containerType:t.type}:t.metadata};r.push(i),m.set(t.id,i)}for(let t of e.nodes.values()){if(s.has(t.id))continue;let n=m.get(t.id);if(n){n.cssStyles=t.styles,n.cssCompiledStyles=o(t.classes),n.cssClasses=t.classes.join(` `);continue}let i=kq(t.type),a={id:t.id,label:t.text,labelType:t.labelType,parentId:f.get(t.id),cssStyles:t.styles,cssCompiledStyles:o([`default`,`node`,...t.classes]),cssClasses:`default `+t.classes.join(` `),dir:t.dir,link:t.link,linkTarget:t.linkTarget,tooltip:e.tooltips.get(t.id),metadata:t.metadata,isGroup:!1,shape:i===`square`||i===void 0?`squareRect`:i};r.push(a),m.set(t.id,a)}e.edges.forEach((t,r)=>{let a=u.get(t.start)??t.start,s=u.get(t.end)??t.end;if(a===s&&t.start!==t.end)return;let c=[...e.defaultEdgeStyle??[]];t.style&&c.push(...t.style);let l=t.type===`arrow_open`?`none`:t.type===`arrow_cross`||t.type===`arrow_point`?t.type:`arrow_point`;i.push({id:t.id||`L_${a}_${s}_${r}`,isUserDefinedId:t.isUserDefinedId,start:a,end:s,type:t.type??`normal`,label:t.text,labelType:t.labelType,thickness:t.stroke,pattern:t.stroke,minlen:t.length,classes:`edge-thickness-normal edge-pattern-solid flowchart-link`,arrowTypeStart:`none`,arrowTypeEnd:l,cssCompiledStyles:o(t.classes),style:c,animate:t.animate,animation:t.animation,curve:t.interpolate||e.defaultInterpolate||n,metadata:t.metadata})}),Qpt(r,e);let h=/* @__PURE__ */ new Map;for(let e of a){let t=f.get(e.id);if(t===void 0)continue;let n=h.get(t);n?n.push(e.id):h.set(t,[e.id])}let g=/* @__PURE__ */ new Map;for(let e of a){if(f.get(e.id)!==void 0)continue;let t=[e.id];for(;t.length>0;){let e=t.pop();if(g.has(e))continue;g.set(e,g.size);let n=h.get(e);if(n)for(let e=n.length-1;e>=0;e--)t.push(n[e])}}return agt(r,t=>{if(e.connectors.has(t))return`connector`;let n=e.nodes.get(t);return n?e.vertexKind(n):void 0},g,t),{nodes:r,edges:i}}var sgt=8,cgt=40,lgt=16,ugt=48,QJ=20,$J=26,eY=14,dgt=`collapsed`,fgt={TB:2,RL:3,BT:0,LR:1},pgt=/* @__PURE__ */ new WeakMap;function mgt(e,t){let n=pgt.get(e);if(n===void 0){let r=t.flowchart?.curve;n=ogt(e,sgt,typeof r==`string`?r:void 0),pgt.set(e,n)}return n}function tY(e,t,n){let r=e.agentflow?.[t];return typeof r==`number`&&r>0?Math.min(r,2e3):n}var hgt=/[";]fill:/;function nY(e,t,n){let r=gJ(e);return` fill="${r}"${hgt.test(n.shape)?``:` fill-opacity="${t}"`} stroke="${r}"`}function ggt(e,t,n){return YJ(e.direction)?JJ(n,r=>_gt(e,t,n,r)):_gt(e,t,n,!1)}function _gt(e,t,n,r){let i=mgt(e,t),a=n.fontSize??16,o=Math.round(a*.875),s=n.measurer??fq(n.fontFamily),c=tY(t,`wrappingWidth`,120),l=tY(t,`minNodeWidth`,120),u=n.padding??8,d=n.icons,f=/* @__PURE__ */ new Map,p=[],m=[];i.nodes.forEach((e,t)=>f.set(e.id,t));for(let e of i.nodes){let t=mJ(e.cssStyles.length>0?e.cssCompiledStyles.concat(e.cssStyles):e.cssCompiledStyles),n=+!!t.bold|(t.italic?2:0),r=e.labelType===`markdown`,i=t.fontSize??a,o,u;if(e.isGroup){let a=WJ(e.label,r,s,i,4e3,n);o={node:e,style:t,label:a,shape:`group`,w:0,h:0,dy:0,loops:0},u=Qq(0,0),u.isGroup=!0,u.dir=e.dir?Xq(e.dir):void 0,u.padX=QJ,u.padTop=a.height>0?a.height+16:QJ,u.padBottom=QJ,u.minW=a.width+2*QJ-12}else if(e.shape===`collapsedGroup`){let a=WJ(e.label,r,s,i,c,n),d=Math.max(a.width,l)+2*yJ,f=a.height+2*bJ+eY;o={node:e,style:t,label:a,shape:dgt,w:d,h:f,dy:-eY/2,loops:0},u=Qq(d,f)}else{let a=qpt(e.shape),d=WJ(e.label,r,s,i,c,n),f=LJ(a,a===`diam`?d.width:Math.max(d.width,l),d.height);o={node:e,style:t,label:d,shape:a,w:f.w,h:f.h,dy:f.dy,loops:0},u=Qq(f.w,f.h)}u.seq=p.length,p.push(o),m.push(u)}i.nodes.forEach((e,t)=>{m[t].parent=e.parentId===void 0?-1:f.get(e.parentId)??-1});let h=r?`TB`:Xq(e.direction),g=e=>{let t;for(let n=m[e].parent,r=0;n>=0&&t===void 0&&r<1e4;n=m[n].parent,r++)t=m[n].dir;return t??h},_=e=>{let t=g(e);return t===`LR`||t===`RL`},v=new Int32Array(m.length).fill(-1);for(let e=0;e<m.length;e++){let t=[],n=e;for(;n>=0&&v[n]<0&&t.length<=m.length;)t.push(n),n=m[n].parent;let r=n>=0?v[n]+1:0;for(let e=t.length-1;e>=0;e--)v[t[e]]=r++}let y=(e,t)=>{let n=t;for(let r=v[t];r>v[e];r--)n=m[n].parent;return n===e&&t!==e},b=[],x=[],S=[],C=[];for(let e of i.edges){let t=f.get(e.start),n=f.get(e.end);if(t===void 0||n===void 0)continue;let r=WJ(e.label,e.labelType===`markdown`,s,o,c);y(t,n)||y(n,t)?C.push({edge:e,label:r,src:t,dst:n}):(t===n&&(p[t].loops++,_(t)?m[t].h+=2*($J+(r.height>0?r.height+8:0)):m[t].w+=2*($J+(r.width>0?r.width+12:0))),S.push(e),x.push(r),b.push({src:t,dst:n,minlen:e.minlen??1,labelW:r.width>0?r.width+12:0,labelH:r.height>0?r.height+4:0,route:[],labelX:0,labelY:0}))}let w=eJ(m,b,h,{nodeSep:tY(t,`nodeSpacing`,cgt),edgeSep:lgt,rankSep:tY(t,`rankSpacing`,ugt),portSep:20}),T=WJ(e.title,!1,s,a,4e3,1),E=T.height>0?T.height+12:0,D=Math.max(w.width,T.width);Zq(m,b,u+(D-w.width)/2,u+E);let O=Math.ceil(D+2*u),k=Math.ceil(w.height+E+2*u),A=[],j=[],M=[],N=[],P=C.length*m.length<2e6;for(let{edge:e,src:t,dst:n}of C){let r=y(n,t),i=r?n:t,a=r?t:n,o=m[i],s=m[a],c=fgt[o.dir??g(i)],l=r?c:c+2&3,u=e=>{let t=!(e&1),n=e===0||e===3?-1:1,i=t?s.x:s.x+n*s.w/2,a=t?s.y+n*s.h/2:s.y,c=t?s.x:o.x+n*o.w/2,l=t?o.y+n*o.h/2:s.y,u=+!t;return r?[i,a,u,c,l,u]:[c,l,u,i,a,u]},d=e=>{for(let t=0;t<m.length;t++){let n=m[t];if(t!==a&&!n.isGroup&&n.x+n.w/2>Math.min(e[0],e[3])-1&&n.x-n.w/2<Math.max(e[0],e[3])+1&&n.y+n.h/2>Math.min(e[1],e[4])-1&&n.y-n.h/2<Math.max(e[1],e[4])+1)return!0}return!1},f=u(l);if(P&&d(f))for(let e of[l+1&3,l+3&3,l+2&3]){let t=u(e);if(!d(t)){f=t;break}}N.push(f),M.push((f[0]+f[3])/2,(f[1]+f[4])/2);let h=f.slice();VJ(h,r?0:3,p[a],s),j.push(oJ(h,`linear`,0,sJ(e.arrowTypeEnd)))}let F=/* @__PURE__ */ new Map,ee=!1;for(let e of m)e.isGroup&&(ee=!0);if(ee){for(let e of b)tJ(F,e.route);for(let e of N)tJ(F,e)}let te=``,I=``;for(let e=0;e<p.length;e++){let t=p[e],r=m[e],i=t.node,a=r.x,o=r.y,s=hJ(i.cssClasses.replace(/^default\s?/,``)),c=mq(i.id);if(r.isGroup){let e=nJ(r,t.label.width,F,QJ);te+=`<g class="pele-cluster pele-flow${s}" data-id="${c}"><rect x="${K(a-r.w/2)}" y="${K(o-r.h/2)}" width="${K(r.w)}" height="${K(r.h)}" rx="${fJ}"${nY(i.colorIndex??ZJ.size,`0.06`,t.style)}${t.style.shape}/>`+gq(t.label,e,o-r.h/2+8+t.label.height/2,` class="pele-cluster-label" fill="var(--_m)"${t.style.text}`,d)+`</g>`;continue}let l=t.w,u=t.h,f=``,h;if(t.shape===dgt){let e=gJ(i.colorIndex??ZJ.size),n=u/2-eY-2,r=n+(eY+2)/2;h=`<rect x="${K(-l/2)}" y="${K(-u/2)}" width="${K(l)}" height="${K(u)}" rx="${fJ}"${nY(i.colorIndex??ZJ.size,`0.06`,t.style)}${t.style.shape}/><path d="M${K(-l/2+10)},${K(n)}H${K(l/2-10)}" fill="none" stroke="${e}" stroke-dasharray="3 3"${t.style.line}/><path class="pele-collapsed-mark" d="${rY(-9,r)}${rY(0,r)}${rY(9,r)}" fill="${e}" stroke="none"/>`}else{let e=ZJ.get(i.kind??`task`)??1;f=` pele-kind-${i.kind??`task`}`,h=RJ(t.shape,l,u,nY(e,`0.14`,t.style)+t.style.shape,` stroke="${gJ(e)}"`+t.style.line)}let g=gq(t.label,0,t.dy,` class="pele-label"${t.style.text}`,d);if(/ internal-link(?: |$)/.test(s+` `)&&i.label&&n.links!==!1){let e=RK(i.label),t=wq(Sq(e),n)!==void 0,r=pq(e);g=`<a class="internal-link"${t?` href="${r}"${Eq(n)}`:``} data-href="${r}">${g}</a>`,A.push({id:i.id,href:e,internal:!0})}let _=h+g;i.tooltip&&(_=`<title>${mq(i.tooltip)}</title>`+_),i.link&&(_=Tq(_,i.link,i.id,A,n,i.linkTarget?` target="${pq(i.linkTarget)}"`:``)),I+=`<g class="pele-node pele-shape-${t.shape}${f}${s}" data-id="${c}" transform="translate(${K(a)},${K(o)})">${_}</g>`}let ne=``,re=``,ie=(e,t,n,r,i)=>{let a=e.style.length>0||e.cssCompiledStyles.length>0?mJ(e.cssCompiledStyles.concat(e.style)):void 0,o=e.arrowTypeEnd,s=a?.stroke?pq(a.stroke):`var(--_l)`,c=e.thickness===`dotted`?`reference`:o===`arrow_cross`?`failure`:`sequence`,l=hJ(e.classes.replace(/edge-thickness-normal|edge-pattern-solid|flowchart-link/g,``));ne+=`<g class="pele-edge pele-edge-${c}${l}" data-id="${mq(e.id)}"${a?.line??``}><path d="${n.d}"${e.thickness===`dotted`?` stroke-dasharray="3 4"`:``}/>`+cJ(o,n.ex,n.ey,n.edx,n.edy,s)+`</g>`,t.width>0&&(re+=lJ(e.id,t,r,i,a?.text??``,d))},ae=/* @__PURE__ */ new Map;for(let e=0;e<b.length;e++){let t=b[e],n=S[e],r=x[e],i=n.arrowTypeEnd,a;if(t.src===t.dst){let e=p[t.src],n=ae.get(t.src)??0;ae.set(t.src,n+1),a=uJ(m[t.src],e.w,e.h,n,_(t.src),$J,sJ(i),t)}else{let e=t.route.slice();VJ(e,0,p[t.src],m[t.src]),VJ(e,e.length-3,p[t.dst],m[t.dst]),a=oJ(e,n.curve,0,sJ(i))}ie(n,r,a,t.labelX,t.labelY)}return C.forEach((e,t)=>ie(e.edge,e.label,j[t],M[2*t],M[2*t+1])),{svg:vJ(`agentflow`,O,k,a,n,e,gq(T,O/2,u+T.height/2,` class="pele-title" font-weight="var(--_tw)"`)+(te?`<g class="pele-clusters">${te}</g>`:``)+(ne?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${ne}</g>`:``)+(re?`<g class="pele-edge-labels" font-size="${o}">${re}</g>`:``)+`<g class="pele-nodes">${I}</g>`),width:O,height:k,links:A}}function rY(e,t){return`M${K(e-1.75)},${K(t)}a1.75,1.75 0 1 0 3.5,0a1.75,1.75 0 1 0 -3.5,0Z`}var vgt={type:`agentflow`,keepComments:!0,parse(e,t,n,r,i){let a=new umt({inheritDir:(t.flowchart??{}).inheritDir===!0,direction:typeof t.direction==`string`?t.direction:void 0,lineOffset:r,maxEdges:i.maxEdges});return n&&(a.title=n),jmt(e,a),mgt(a,t),a},render:ggt};function iY(e){throw new NK(e,`semantic`,{type:`architecture`})}var ygt=class{type=`architecture`;title;accTitle;accDescr;nodes=/* @__PURE__ */ new Map;groups=/* @__PURE__ */ new Map;edges=[];layoutHints=[];registered=/* @__PURE__ */ new Map;register(e,t,n){this.registered.has(t)&&iY(`The ${e} id [${t}] is already in use by another ${this.registered.get(t)}`),n!==void 0&&(t===n&&iY(`The ${e} [${t}] cannot be placed within itself`),this.registered.has(n)||iY(`The ${e} [${t}]'s parent does not exist. Please make sure the parent is created before this ${e}`),this.registered.get(n)===`node`&&iY(`The ${e} [${t}]'s parent is not a group`)),this.registered.set(t,e===`group`?`group`:`node`)}addService({id:e,icon:t,iconText:n,title:r,in:i}){this.register(`service`,e,i),this.nodes.set(e,{id:e,type:`service`,icon:t,iconText:n,title:r,in:i})}addJunction({id:e,in:t}){this.register(`junction`,e,t),this.nodes.set(e,{id:e,type:`junction`,in:t})}addGroup({id:e,icon:t,title:n,in:r}){this.register(`group`,e,r),this.groups.set(e,{id:e,icon:t,title:n,in:r})}addEdge({lhsId:e,rhsId:t,lhsDir:n,rhsDir:r,lhsInto:i,rhsInto:a,lhsGroup:o,rhsGroup:s,title:c}){let l=[[`left`,e,o],[`right`,t,s]];for(let[e,t]of l)this.registered.has(t)||iY(`The ${e}-hand id [${t}] does not yet exist. Please create the service/group before declaring an edge to it.`);for(let[e,t]of l)this.nodes.has(t)||iY(`The ${e}-hand id [${t}] is a group. Add {group} to a service inside it instead.`);let u=this.nodes.get(e).in;if(u!==void 0&&u===this.nodes.get(t).in)for(let[e,t,n]of l)n&&iY(`The ${e}-hand id [${t}] is modified to traverse the group boundary, but the edge does not pass through two groups.`);this.edges.push({lhsId:e,lhsDir:n,lhsInto:i,lhsGroup:o,rhsId:t,rhsDir:r,rhsInto:a,rhsGroup:s,title:c})}addLayoutHint(e){e.members.length<2&&iY(`An align directive requires at least two members; got ${e.members.length}`);let t=/* @__PURE__ */ new Set;for(let n of e.members)this.registered.get(n)!==`node`&&iY(`align ${e.direction} references [${n}], which is not a service or junction`),t.has(n)&&iY(`align ${e.direction} lists [${n}] more than once`),t.add(n);this.layoutHints.push(e)}};function bgt(e,t){e.accDescr&&(t.accDescr=e.accDescr.replace(/\n\s+/g,`
|
|
987
|
-
`)),e.accTitle&&(t.accTitle=e.accTitle.replace(/^\s+/g,``)),e.title&&(t.title=e.title);for(let n of e.groups)t.addGroup(n);for(let n of e.services)t.addService(n);for(let n of e.junctions)t.addJunction(n);for(let n of e.edges)t.addEdge(n);for(let n of e.alignments)t.addLayoutHint({direction:n.direction,members:[...n.members]})}var
|
|
988
|
-
`},
|
|
989
|
-
`):
|
|
990
|
-
`],[`r`,`\r`],[`t`,` `],[`v`,`\v`],[`0`,`\0`]]);function bY(e){if(!e.includes(`\\`))return e.slice(1,-1);let t=``;for(let n=1;n<e.length-1;n++){let r=e[n];if(r===`\\`){let r=e[++n];t+=Egt.get(r)??r}else t+=r}return t}var xY=class{constructor(e,t,n){this.tokens=e,this.types=t,this.diagram=n,this.kinds=e.kinds}tokens;types;diagram;i=0;kinds;get kind(){return this.kinds[this.i]}text(e=this.i){return this.tokens.src.slice(this.tokens.starts[e],this.tokens.ends[e])}take(){return this.text(this.i++)}accept(e){return this.kinds[this.i]===e&&(this.i++,!0)}expect(e){return this.kinds[this.i]!==e&&this.fail(`token of type '${this.types[e].name}'`),this.take()}fail(e){let t=this.kind===-1?`end of input`:`\`${this.text()}\``;throw FK(this.diagram,this.tokens.src,this.tokens.starts[this.i],`Expecting ${e} but found ${t}.`)}},Dgt={name:`ID`,pattern:/[\w]([-\w]*\w)?/y};function SY(e){return{name:e,pattern:e,longer:[Dgt]}}var Ogt=[SY(`architecture-beta`),SY(`junction`),SY(`service`),SY(`column`),SY(`group`),SY(`align`),SY(`row`),{name:`--`,pattern:`--`,longer:[fY]},SY(`in`),{name:`:`,pattern:`:`},{name:`-`,pattern:`-`,longer:[fY]},{name:`ARROW_DIRECTION`,pattern:/L|R|T|B/y},{name:`ARROW_GROUP`,pattern:/\{group\}/y},{name:`ARROW_INTO`,pattern:/<|>/y},oY,sY,cY,lY,Dgt,uY,dY,fY,pY,mY,{name:`ARCH_ICON`,pattern:/\([\w-:]+\)/y},{name:`ARCH_TITLE`,pattern:/\[(?:"([^"\\]|\\.)*"|'([^'\\]|\\.)*'|[^\[\]\r\n]+)\]/y}];function CY(e){let t=e.slice(1,-1).trim();return(t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`))&&(t=t.slice(1,-1).replace(/\\"/g,`"`).replace(/\\'/g,`'`)),t.trim()}function kgt(e){let t=new xY(aY(e,Ogt,`architecture`),Ogt,`architecture`),n={$type:`Architecture`,groups:[],services:[],junctions:[],edges:[],alignments:[]},r=e=>t.kinds[t.i]===e,i=()=>{if(t.kind!==-1)for(t.kind!==19&&t.fail(`a line break or the end of input`);t.kind===19;)t.i++};for(;t.kind===19;)t.i++;for(t.expect(0);t.kind!==-1;){switch(t.kind){case 19:t.i++;continue;case 14:n.accDescr=yY(t.take());break;case 15:n.accTitle=vY(t.take());break;case 16:n.title=_Y(t.take());break;case 4:{t.i++;let e={$type:`Group`,id:t.expect(18)};r(24)&&(e.icon=t.take().slice(1,-1)),r(25)&&(e.title=CY(t.take())),t.accept(8)&&(e.in=t.expect(18)),n.groups.push(e);break}case 2:{t.i++;let e={$type:`Service`,id:t.expect(18)};r(17)?e.iconText=bY(t.take()):r(24)&&(e.icon=t.take().slice(1,-1)),r(25)&&(e.title=CY(t.take())),t.accept(8)&&(e.in=t.expect(18)),n.services.push(e);break}case 1:{t.i++;let e={$type:`Junction`,id:t.expect(18)};t.accept(8)&&(e.in=t.expect(18)),n.junctions.push(e);break}case 18:{let e=t.take(),i=t.accept(12);t.expect(9);let a=t.expect(11),o=t.accept(13),s;t.accept(7)||(r(10)||t.fail(`'--' or '-'`),t.i++,s=CY(t.expect(25)),t.expect(10));let c=t.accept(13),l=t.expect(11);t.expect(9);let u=t.expect(18),d=t.accept(12);n.edges.push({$type:`Edge`,lhsId:e,lhsGroup:i,lhsDir:a,lhsInto:o,title:s,rhsInto:c,rhsDir:l,rhsId:u,rhsGroup:d});break}case 5:{t.i++,!r(6)&&!r(3)&&t.fail(`'row' or 'column'`);let e=t.take(),i=[t.expect(18),t.expect(18)];for(;r(18);)i.push(t.take());n.alignments.push({$type:`Alignment`,direction:e,members:i});break}default:t.fail(`a group, a service, a junction, an edge, an alignment, a title, or a line break`)}i()}return n}var Agt=/* @__PURE__ */ 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`]]);function jgt(e){let t=Agt.get(e);return t===void 0?``:`<path d="${t}" stroke="var(--_fg)" stroke-width="1.5"/>`}var wY=[-1,1,0,0],TY=[0,0,-1,1];function EY(e){return e===`L`?0:e===`R`?1:e===`T`?2:3}var Mgt=64,DY=2**25,Ngt=2**26;function Pgt(e,t,n,r){let i=e.length,a=t.length,o=a,s=/* @__PURE__ */ new Map,c=/* @__PURE__ */ new Map,l=new Int32Array(i+a).fill(o),u=new Int32Array(a+1),d=[];for(let e=0;e<=a;e++)d.push([]);t.forEach((e,t)=>{c.set(e.id,t);let n=e.in===void 0?void 0:c.get(e.in);n!==void 0&&n!==t?(l[i+t]=n,u[t]=u[n]+1):u[t]=1}),e.forEach((e,t)=>{s.set(e.id,t);let n=e.in===void 0?void 0:c.get(e.in);n!==void 0&&(l[t]=n),d[l[t]].push(t)});for(let e=0;e<a;e++)d[l[i+e]].push(i+e);let f=[],p=[],m=[],h=[],g=[],_=[],v=Array(i+a),y=Array(i+a),b=(e,t,n,r,a)=>{if(e===t)return;let o=e,s=t,c=l[e],d=l[t];for(;c!==d;)u[c]>=u[d]?(o=i+c,c=l[o]):(s=i+d,d=l[s]);let v=f.length;f.push(e),p.push(t),m.push(n),h.push(r),g.push(o),_.push(s),(a[o]??=[]).push(v),(a[s]??=[]).push(v)};for(let e of r){let t=e.direction===`row`;for(let n=1;n<e.members.length;n++){let r=s.get(e.members[n-1]),i=s.get(e.members[n]);r!==void 0&&i!==void 0&&b(r,i,t?1:3,t?0:2,v)}}for(let e of[!1,!0])for(let t of n){if(t.lhsDir===t.rhsDir!==e)continue;let n=s.get(t.lhsId),r=s.get(t.rhsId);n!==void 0&&r!==void 0&&b(n,r,EY(t.lhsDir),EY(t.rhsDir),y)}let x=new Int32Array(i+a),S=new Int32Array(i+a),C=new Int32Array(i+a).fill(1),w=new Int32Array(i+a).fill(1),T=new Uint8Array(i+a),E=[],D=/* @__PURE__ */ new Map,O=[],k=/* @__PURE__ */ new Map,A=0,j=0,M=0,N=(e,t)=>{j=0,M=0;for(let n=e;n!==t;n=i+l[n])j+=x[n],M+=S[n]},P=(e,t,n)=>{if(x[e]=t,S[e]=n,T[e]=1,E.push(e),C[e]*w[e]>Mgt)O.push(e);else for(let r=n;r<n+w[e];r++)for(let n=t;n<t+C[e];n++)D.set((n+DY)*Ngt+r+DY,e)},F=(e,t,n,r,i)=>x[e]<t+r&&t<x[e]+C[e]&&S[e]<n+i&&n<S[e]+w[e],ee=(e,t,n,r)=>{if(n*r>Mgt){for(let i=A;i<E.length;i++)if(F(E[i],e,t,n,r))return E[i];return-1}for(let i=t;i<t+r;i++)for(let t=e;t<e+n;t++){let e=D.get((t+DY)*Ngt+i+DY);if(e!==void 0)return e}for(let i of O)if(F(i,e,t,n,r))return i;return-1},te=(e,t,n,r,i,a)=>{let o=`${e},${t},${n},${r},${i},${a}`,s=k.get(o)??0;for(;;){let o=ee(e+s*i,t+s*a,n,r);if(o<0)break;s=i>0?x[o]+C[o]-e:i<0?e+n-x[o]:a>0?S[o]+w[o]-t:t+r-S[o]}return k.set(o,s),s},I=(e,t)=>{let n=g[t]===e,r=n?_[t]:g[t];if(T[r])return;let i=n?m[t]:h[t],a=n?h[t]:m[t];N(n?f[t]:p[t],e);let o=j,s=M;N(n?p[t]:f[t],r);let c=wY[i],l=TY[i],u=0,d=0,v=wY[i]+wY[a]===0&&TY[i]+TY[a]===0;i===a?(c=+(wY[i]===0),l=1-c):v||(u=-wY[a],d=-TY[a]);let b,E;if(c===0?(E=l>0?S[e]+w[e]:S[e]-w[r],b=x[e]+o+u-j):(b=c>0?x[e]+C[e]:x[e]-C[r],E=S[e]+s+d-M),v){let e=y[r];if(e!==void 0&&e.length>1){let t=[];for(let n of e){let e=_[n]===r,o=e?g[n]:_[n];if(!T[o]||(e?m[n]:h[n])!==i||(e?h[n]:m[n])!==a)continue;N(e?f[n]:p[n],o);let s=c===0?x[o]+j:S[o]+M;N(e?p[n]:f[n],r),t.push(s-(c===0?j:M))}t.length>1&&(t.sort((e,t)=>e-t),c===0?b=t[t.length-1>>1]:E=t[t.length-1>>1])}let t=+(c===0),n=1-t,o=te(b,E,C[r],w[r],t,n),s=o===0?0:te(b,E,C[r],w[r],-t,-n),l=o<=s?o:-s;b+=t*l,E+=n*l}else{let e=te(b,E,C[r],w[r],c,l);b+=c*e,E+=l*e}P(r,b,E)},ne=e=>{let t=d[e];if(t.length===0)return;E.length=0;let n=[];for(let e of t){if(T[e])continue;A=E.length,n.push(A),D.clear(),O.length=0,k.clear(),P(e,0,0);let t=A,r=A,i=0;for(;;){if(t<E.length){let e=E[t++],n=v[e];if(n!==void 0)for(let t of n)I(e,t);continue}if(r>=E.length)break;let e=y[E[r]];e===void 0||i>=e.length?(r++,i=0):I(E[r],e[i++])}}n.push(E.length);let r=n.length-1,o=Array(r),s=Array(r),c=Array(r),l=Array(r),u=0,f=0;for(let e=0;e<r;e++){let t=1/0,r=1/0,i=-1/0,a=-1/0;for(let o=n[e];o<n[e+1];o++){let e=E[o];t=Math.min(t,x[e]),r=Math.min(r,S[e]),i=Math.max(i,x[e]+C[e]),a=Math.max(a,S[e]+w[e])}o[e]=t,s[e]=r,c[e]=i-t,l[e]=a-r,u+=c[e]*l[e],f=Math.max(f,c[e])}let p=Math.max(f,Math.ceil(Math.sqrt(u*2))),m=0,h=0,g=0,_=0;for(let e=0;e<r;e++){m>0&&m+c[e]>p&&(h+=g,m=0,g=0);for(let t=n[e];t<n[e+1];t++)x[E[t]]+=m-o[e],S[E[t]]+=h-s[e];m+=c[e],g=Math.max(g,l[e]),_=Math.max(_,m)}e<a&&(C[i+e]=_,w[i+e]=h+g)};for(let e=a-1;e>=0;e--)ne(e);ne(o);let re=new Int32Array(a),ie=new Int32Array(a),ae=new Int32Array(a),L=new Uint8Array(a);for(let e=0;e<a;e++){let t=l[i+e];ae[e]=t===o?-1:t,re[e]=x[i+e]+(t===o?0:re[t]),ie[e]=S[i+e]+(t===o?0:ie[t]),d[e].length===0&&(L[e]=1)}let oe=new Int32Array(i),se=new Int32Array(i),ce=new Int32Array(i);for(let e=0;e<i;e++){let t=l[e];ce[e]=t===o?-1:t,oe[e]=x[e]+(t===o?0:re[t]),se[e]=S[e]+(t===o?0:ie[t])}return{col:oe,row:se,groupCol:re,groupRow:ie,groupCols:C.slice(i),groupRows:w.slice(i),groupParent:ae,groupEmpty:L,nodeParent:ce}}var OY=12,Fgt=6,Igt=4,Lgt=3,Rgt=[-1,1,0,0],zgt=[0,0,-1,1];function kY(e,t,n,r,i){let a=e.architecture,o=typeof a==`object`&&a&&!Array.isArray(a)?a[t]:void 0;return typeof o==`number`&&Number.isFinite(o)?Math.min(i,Math.max(r,o)):n}function Bgt(e){let t=/* @__PURE__ */ new Map;for(let n of e.sort((e,t)=>e-t))t.has(n)||t.set(n,t.size);return t}function Vgt(e,t,n,r,i){return`<svg class="pele-icon" data-icon="${mq(e)}" x="${K(t)}" y="${K(n)}" width="${K(r)}" height="${K(r)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${i?.(e)??jgt(e)}</svg>`}function Hgt(e,t,n,r){let i=e.lines.length>n;if(!i&&e.width<=t)return e;let a=r.width(`…`,e.size,0),o=[],s=[],c=0;for(let l=0;l<Math.min(n,e.lines.length);l++){let u=e.lines[l].map(e=>({...e})),d=e.widths[l];if(d>t||i&&l===n-1)for(;;){let n=u[u.length-1];if(n===void 0){u.push({text:`…`,style:0,width:a}),d=a;break}let i=d-n.width;if(n.icon===void 0&&i+a<t){let o=0,s=n.text.length;for(;o<s;){let c=o+s+1>>1;i+r.width(n.text.slice(0,c),e.size,n.style)+a<=t?o=c:s=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=r.width(n.text,e.size,n.style),d=i+n.width;break}u.pop(),d=i}o.push(u),s.push(d),c=Math.max(c,d)}return{...e,lines:o,widths:s,width:c,height:o.length*e.lineHeight}}function Ugt(e,t){let{x:n,y:r,dx:i,dy:a}=e,{x:o,y:s,dx:c,dy:l}=t,u=n+i*OY,d=r+a*OY,f=o+c*OY,p=s+l*OY;if(i*c+a*l===0){let e=i===0?n:o,t=i===0?s:r;return(e-n)*i+(t-r)*a>0&&(e-o)*c+(t-s)*l>0?[n,r,e,t,o,s]:i===0?[n,r,u,d,f,d,f,p,o,s]:[n,r,u,d,u,p,f,p,o,s]}let m=i!==0,h=m?s-r:o-n;if(i===-c&&a===-l){if((o-n)*i+(s-r)*a>0){if(Math.abs(h)<.5)return[n,r,o,s];if(m){let a=i>0?e.x1:t.x1,c=i>0?t.x0:e.x0,l=a<c?(a+c)/2:(n+o)/2;return[n,r,l,r,l,s,o,s]}let c=a>0?e.y1:t.y1,l=a>0?t.y0:e.y0,u=c<l?(c+l)/2:(r+s)/2;return[n,r,n,u,o,u,o,s]}}else if(Math.abs(h)>=1){if(m){let e=i>0?Math.max(n,o)+OY:Math.min(n,o)-OY;return[n,r,e,r,e,s,o,s]}let e=a>0?Math.max(r,s)+OY:Math.min(r,s)-OY;return[n,r,n,e,o,e,o,s]}if(m){let i=e.y1+OY<=t.y0?(e.y1+t.y0)/2:t.y1+OY<=e.y0?(t.y1+e.y0)/2:Math.max(e.y1,t.y1)+OY;return[n,r,u,r,u,i,f,i,f,s,o,s]}let g=e.x1+OY<=t.x0?(e.x1+t.x0)/2:t.x1+OY<=e.x0?(t.x1+e.x0)/2:Math.max(e.x1,t.x1)+OY;return[n,r,n,d,g,d,g,p,o,p,o,s]}function Wgt(e){let t=[e[0],e[1]];for(let n=2;n<e.length;n+=2){let r=e[n],i=e[n+1],a=t.length,o=Math.abs(r-t[a-2])<.01,s=Math.abs(i-t[a-1])<.01;o&&s||(a>=4&&(o&&Math.abs(t[a-4]-t[a-2])<.01||s&&Math.abs(t[a-3]-t[a-1])<.01)?(t[a-2]=r,t[a-1]=i):t.push(r,i))}return t}function Ggt(e,t,n){let r=e.length/2,i=Array(r),a=Array(r);for(let t=0;t<r;t++)i[t]=e[t*2],a[t]=e[t*2+1];let o=(e,t,n)=>{let r=Math.hypot(i[t]-i[e],a[t]-a[e]),o=Math.min(n,Math.max(0,r-1));r>0&&o>0&&(i[e]+=(i[t]-i[e])/r*o,a[e]+=(a[t]-a[e])/r*o)};o(0,1,t),o(r-1,r-2,n);let s=`M${K(i[0])},${K(a[0])}`;for(let e=1;e<r-1;e++){let t=Math.hypot(i[e]-i[e-1],a[e]-a[e-1]),n=Math.hypot(i[e+1]-i[e],a[e+1]-a[e]),r=Math.min(Fgt,t/2,n/2);if(r<.5){s+=`L${K(i[e])},${K(a[e])}`;continue}let o=i[e]-(i[e]-i[e-1])/t*r,c=a[e]-(a[e]-a[e-1])/t*r,l=i[e]+(i[e+1]-i[e])/n*r,u=a[e]+(a[e+1]-a[e])/n*r;s+=`L${K(o)},${K(c)}Q${K(i[e])},${K(a[e])} ${K(l)},${K(u)}`}return s+`L${K(i[r-1])},${K(a[r-1])}`}function Kgt(e,t,n){return XJ(n,r=>qgt(e,t,n,r))}function qgt(e,t,n,r){let i=kY(t,`iconSize`,48,8,512),a=kY(t,`fontSize`,n.fontSize??16,4,128),o=Math.min(kY(t,`padding`,20,0,256),r?12:1/0),s=Math.round(a*.875),c=n.measurer??fq(n.fontFamily),l=n.padding??8,u=n.icons,d=i/2,f=[...e.nodes.values()],p=[...e.groups.values()],m=f.length,h=p.length,g=Pgt(f,p,e.edges,e.layoutHints),_=/* @__PURE__ */ new Map;f.forEach((e,t)=>_.set(e.id,t));let v=Array(m),y=new Float64Array(m),b=new Float64Array(m),x=r?Math.max(i,64):Math.max(i*2.25,96);for(let e=0;e<m;e++){let t=f[e],n=WJ(t.type===`service`?t.title:void 0,!0,c,a,x);v[e]=n,y[e]=Math.max(i,2*Math.ceil(n.width/2)),b[e]=i+(n.height>0?Igt+n.height:0)}let S=[],C=[];for(let e=0;e<m;e++)S.push(g.col[e]),C.push(g.row[e]);for(let e=0;e<h;e++)g.groupEmpty[e]&&(S.push(g.groupCol[e]),C.push(g.groupRow[e]));let w=Bgt(S),T=Bgt(C),E=w.size,D=T.size,O=new Float64Array(E),k=new Float64Array(D),A=r?Math.max(24,2*OY):Math.max(40,Math.round(i*.75)),j=new Float64Array(E).fill(A),M=new Float64Array(D).fill(A),N=new Int32Array(m),P=new Int32Array(m);for(let e=0;e<m;e++){let t=N[e]=w.get(g.col[e]),n=P[e]=T.get(g.row[e]);O[t]=Math.max(O[t],y[e]),k[n]=Math.max(k[n],b[e])}for(let e=0;e<h;e++){if(!g.groupEmpty[e])continue;let t=w.get(g.groupCol[e]),n=T.get(g.groupRow[e]);O[t]=Math.max(O[t],i),k[n]=Math.max(k[n],d)}let F=e.edges.length,ee=Array(F),te=new Int32Array(F*2);for(let t=0;t<F;t++){let n=e.edges[t],r=te[t*2]=_.get(n.lhsId)??-1,i=te[t*2+1]=_.get(n.rhsId)??-1,a=WJ(n.title,!0,c,s,160);if(ee[t]=a,!(a.width===0||r<0||i<0)){if(N[r]!==N[i]){let e=Math.min(N[r],N[i]);j[e]=Math.max(j[e],Math.ceil(a.width)+28)}else if(O[N[r]]=Math.max(O[N[r]],2*Math.ceil(a.width/2)+8),P[r]!==P[i]){let e=Math.min(P[r],P[i]);M[e]=Math.max(M[e],Math.ceil(a.height)+24)}}}let I=Array(h),ne=new Int32Array(h),re=new Int32Array(h),ie=new Int32Array(h),ae=new Int32Array(h),L=new Float64Array(h),oe=new Float64Array(h),se=new Float64Array(h),ce=new Float64Array(h),le=new Float64Array(h),ue=new Float64Array(h),de=new Float64Array(E),fe=new Float64Array(E),pe=new Float64Array(D),me=new Float64Array(D),he=Math.round(a*1.25);for(let e=0;e<h;e++){ne[e]=w.get(g.groupCol[e]),re[e]=w.get(g.groupCol[e]+g.groupCols[e]-1),ie[e]=T.get(g.groupRow[e]),ae[e]=T.get(g.groupRow[e]+g.groupRows[e]-1);let t=WJ(p[e].title,!0,c,a,r?Math.max(80,KJ(n)/2):320);I[e]=t;let i=p[e].icon?he:0;le[e]=t.width+i+(t.width>0&&i>0?6:0),ue[e]=Math.max(t.height,i)}for(let e=h-1;e>=0;e--){let t=o+L[e],n=o+oe[e],r=(ue[e]>0?Math.max(o,ue[e]+12):o)+se[e],i=o+ce[e];if(le[e]>0){let r=t+n;for(let t=ne[e];t<=re[e];t++)r+=O[t]+(t<re[e]?fe[t]+j[t]+de[t+1]:0);le[e]+20>r&&(n+=Math.ceil(le[e]+20-r))}L[e]=t,oe[e]=n,se[e]=r,ce[e]=i,de[ne[e]]=Math.max(de[ne[e]],t),fe[re[e]]=Math.max(fe[re[e]],n),pe[ie[e]]=Math.max(pe[ie[e]],r),me[ae[e]]=Math.max(me[ae[e]],i);let a=g.groupParent[e];a<0||(ne[a]===ne[e]&&(L[a]=Math.max(L[a],t)),re[a]===re[e]&&(oe[a]=Math.max(oe[a],n)),ie[a]===ie[e]&&(se[a]=Math.max(se[a],r)),ae[a]===ae[e]&&(ce[a]=Math.max(ce[a],i)))}let ge=new Float64Array(E),_e=new Float64Array(D),ve=0;for(let e=0;e<E;e++)ge[e]=ve+de[e],ve=ge[e]+O[e]+fe[e]+(e<E-1?j[e]:0);let ye=0;for(let e=0;e<D;e++)_e[e]=ye+pe[e],ye=_e[e]+k[e]+me[e]+(e<D-1?M[e]:0);let be=0,xe=0,Se=ve,Ce=ye,we=e=>ge[ne[e]]-L[e],Te=e=>ge[re[e]]+O[re[e]]+oe[e],Ee=e=>_e[ie[e]]-se[e],De=e=>_e[ae[e]]+k[ae[e]]+ce[e],Oe=e=>ge[N[e]]+O[N[e]]/2,ke=(e,t,n)=>{let r=Rgt[t],i=zgt[t],a=Oe(e),o=_e[P[e]],s={x:a,y:o+d,dx:r,dy:i,x0:a-y[e]/2,y0:o,x1:a+y[e]/2,y1:o+b[e],gap:0,wire:!1};f[e].type===`junction`?(s.x0=s.x1=a,s.y0=s.y1=s.y,s.gap=Lgt):r===0?s.y=i<0?o:o+b[e]+(v[e].height>0?2:0):s.x=a+r*d;let c=n?g.nodeParent[e]:-1;return c>=0&&(s.x0=we(c),s.x1=Te(c),s.y0=Ee(c),s.y1=De(c),s.gap=0,s.wire=f[e].type===`junction`,r===0?s.y=i<0?s.y0:s.y1:s.x=r<0?s.x0:s.x1),s},Ae=``,je=``,Me=[],Ne=sJ(`arrow_point`);for(let t=0;t<F;t++){let n=e.edges[t],r=te[t*2],i=te[t*2+1];if(r<0||i<0)continue;let a=ke(r,EY(n.lhsDir),n.lhsGroup),o=ke(i,EY(n.rhsDir),n.rhsGroup);a.x===o.x&&a.y===o.y&&a.dx===o.dx&&(a.x-=8*Math.abs(a.dy),a.y-=8*Math.abs(a.dx),o.x+=8*Math.abs(a.dy),o.y+=8*Math.abs(a.dx));let s=Ugt(a,o);a.wire&&s.unshift(Oe(r),_e[P[r]]+d),o.wire&&s.push(Oe(i),_e[P[i]]+d);let c=Wgt(s);if(c.length<4)continue;let l=mq(`${n.lhsId}-${n.rhsId}`);Ae+=`<g class="pele-edge" data-id="${l}"><path d="${Ggt(c,n.lhsInto&&!a.wire?Ne+a.gap:0,n.rhsInto&&!o.wire?Ne+o.gap:0)}"/>`+(n.lhsInto?cJ(`arrow_point`,a.x+a.dx*a.gap,a.y+a.dy*a.gap,-a.dx,-a.dy,`var(--_l)`):``)+(n.rhsInto?cJ(`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,m=-1,h=-1,g=ee[t];for(let e=0;e<c.length;e+=2)be=Math.min(be,c[e]-4),Se=Math.max(Se,c[e]+4),xe=Math.min(xe,c[e+1]-4),Ce=Math.max(Ce,c[e+1]+4);for(let e=0;e+3<c.length;e+=2){let t=Math.abs(c[e+1]-c[e+3])<.01,n=Math.abs(c[e]-c[e+2])+Math.abs(c[e+1]-c[e+3]);t||Me.push(c[e],Math.min(c[e+1],c[e+3]),Math.max(c[e+1],c[e+3])),n>p&&(f=e,p=n),t&&n>h&&(m=e,h=n)}if(g.width>0){let e=h>=g.width+8?m:f,t=(c[e]+c[e+2])/2,r=(c[e+1]+c[e+3])/2,i=g.width+8,s=Math.abs(c[e]-c[e+2])<.01;for(let e of[a,o])t+i/2<=e.x0||t-i/2>=e.x1||r+g.height/2<=e.y0||r-g.height/2>=e.y1||(s?t=t>=(e.x0+e.x1)/2?e.x1+i/2+4:e.x0-i/2-4:r=r>=(e.y0+e.y1)/2?e.y1+g.height/2+4:e.y0-g.height/2-4);be=Math.min(be,t-i/2),Se=Math.max(Se,t+i/2),xe=Math.min(xe,r-g.height/2),Ce=Math.max(Ce,r+g.height/2),je+=lJ(`${n.lhsId}-${n.rhsId}`,g,t,r,``,u)}}let Pe=``;for(let e=0;e<h;e++){let t=p[e],n=we(e),r=Ee(e),i=Te(e)-n,a=I[e],o=``;if(le[e]>0){let s=r+ue[e]+12,c=[];for(let e=0;e<Me.length;e+=3)Me[e+1]<s&&Me[e+2]>r&&Me[e]>n&&Me[e]<n+i&&c.push(Me[e]);c.sort((e,t)=>e-t),c.push(n+i-4);let l=n+10;for(let t of c){if(t-6-l>=le[e])break;l=Math.max(l,t+6)}l+le[e]>n+i-4&&(l=n+10);let d=r+6+ue[e]/2,f=l;t.icon&&(o+=Vgt(t.icon,l,d-he/2,he,u),f+=he+6),o+=gq(a,f+a.width/2,d,` class="pele-cluster-label" fill="var(--_m)"`,u)}Pe+=`<g class="pele-cluster" data-id="${mq(t.id)}"><rect x="${K(n)}" y="${K(r)}" width="${K(i)}" height="${K(De(e)-r)}" rx="${fJ}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"/>`+o+`</g>`}let Fe=``,Ie=i*.5,Le=Math.max(6,Math.round(a*.75));for(let e=0;e<m;e++){let t=f[e],n=`data-id="${mq(t.id)}" transform="translate(${K(Oe(e))},${K(_e[P[e]])})"`;if(t.type===`junction`){Fe+=`<g class="pele-node pele-junction" ${n}><circle cy="${K(d)}" r="${Lgt}" fill="var(--_l)"/></g>`;continue}let r=``;if(t.icon)r=Vgt(t.icon,-Ie/2,(i-Ie)/2,Ie,u);else if(t.iconText){let e=WJ(t.iconText,!1,c,Le,i-8),n=Math.max(1,Math.floor((i-4)/(e.lineHeight||1)));r=gq(Hgt(e,i-8,n,c),0,d,` class="pele-icon-text" font-size="${Le}"`,u)}Fe+=`<g class="pele-node pele-service" ${n}><rect x="${K(-d)}" width="${K(i)}" height="${K(i)}" rx="${fJ}" fill="var(--_s)" stroke="var(--_b)"/>`+r+gq(v[e],0,i+Igt+v[e].height/2,` class="pele-label"`,u)+`</g>`}let Re=WJ(e.title,!1,c,a,r?KJ(n):4e3,1),ze=Re.height>0?Re.height+12:0,Be=Math.ceil(Math.max(Se-be,Re.width)+2*l),Ve=Math.ceil(Ce-xe+ze+2*l),He=Math.round((Be-(Se-be))/2-be),Ue=Math.round(l+ze-xe),We=(Pe?`<g class="pele-clusters">${Pe}</g>`:``)+(Ae?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round" stroke-linejoin="round">${Ae}</g>`:``)+(je?`<g class="pele-edge-labels" font-size="${s}">${je}</g>`:``)+(Fe?`<g class="pele-nodes">${Fe}</g>`:``);return{svg:vJ(`architecture`,Be,Ve,a,n,e,gq(Re,Be/2,l+Re.height/2,` class="pele-title" font-weight="var(--_tw)"`)+(We?`<g transform="translate(${He},${Ue})">${We}</g>`:``)),width:Be,height:Ve,links:[]}}var Jgt={type:`architecture`,parse(e,t,n){let r=new ygt;return n&&(r.title=n),bgt(kgt(e),r),r},render:Kgt},Ygt=1e5;function Xgt(e){switch(e){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 Zgt(e){switch(e.trim().slice(-1)){case`x`:return`arrow_cross`;case`o`:return`arrow_circle`;case`>`:return`arrow_point`;default:return``}}function Qgt(e){switch(e.trim().charAt(0)){case`x`:return`arrow_cross`;case`o`:return`arrow_circle`;case`<`:return`arrow_point`;default:return`arrow_open`}}function $gt(e){return e.includes(`==`)?`thick`:`normal`}function e_t(e){return e.includes(`.-`)?`dotted`:`solid`}function t_t(e,t){let n=e.flat(),r=-1;for(let e of n)if(e.type===`column-setting`){r=e.columns??-1;break}return{list:n,at:0,parent:t,children:[],columns:r}}var n_t=class{type=`block`;title;root={id:`root`,type:`composite`,children:[],columns:-1};blocks=[];edges=[];classes=/* @__PURE__ */ new Map;byId=/* @__PURE__ */ new Map;typeStr2Type=Xgt;edgeStrToEdgeData=Zgt;edgeStrToEdgeStartData=Qgt;edgeStrToThickness=$gt;edgeStrToPattern=e_t;warn;pending=/* @__PURE__ */ new Set;edgeCount=/* @__PURE__ */ new Map;ids=0;colors=0;spaces=0;constructor(e={}){this.warn=e.warn}generateId(){return`id-`+ ++this.ids}addStyleClass(e,t=``){let n=this.classes.get(e);n||(n={id:e,styles:[],textStyles:[]},this.classes.set(e,n));for(let e of t.split(`,`)){let t=e.indexOf(`;`),r=(t===-1?e:e.slice(0,t)+e.slice(t+1)).trim();e.includes(`color`)&&n.textStyles.push(r.replace(`fill`,`bgFill`).replace(`color`,`fill`)),n.styles.push(r)}}addStyle2Node(e,t=``){this.named(e).styles=t.split(`,`)}setCssClass(e,t){for(let n of e.split(`,`))(this.named(n.trim()).classes??=[]).push(t)}named(e){let t=this.byId.get(e);return t===void 0&&(t={id:e,type:`na`,children:[]},this.byId.set(e,t),this.pending.add(e)),t}setHierarchy(e){let t=[t_t(e,this.root)];for(;t.length>0;){let e=t[t.length-1];if(e.at===e.list.length){e.parent.children=e.children,t.pop();continue}let n=e.list[e.at++];switch(e.columns>0&&n.type!==`column-setting`&&typeof n.widthInColumns==`number`&&n.widthInColumns>e.columns&&this.warn?.(`Block ${n.id} width ${n.widthInColumns} exceeds configured column width ${e.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`:e.parent.columns=n.columns??-1;continue;case`edge`:{let e=(this.edgeCount.get(n.id)??0)+1;this.edgeCount.set(n.id,e),n.id=e+`-`+n.id,this.edges.push(n);continue}}n.id??=this.generateId(),n.label||=n.type===`composite`?``:n.id;let r=this.byId.get(n.id),i=r===void 0||this.pending.delete(n.id);i?(r&&(n.classes=r.classes,n.styles=r.styles),n.type===`composite`&&(n.colorIndex=this.colors++),this.byId.set(n.id,n)):(n.type!==`na`&&(r.type=n.type),n.label!==n.id&&(r.label=n.label));let a=n.children;if(n.children=[],n.type===`space`){let t=n.width??1;if(!(t<=Ygt-this.spaces))throw new NK(`A block diagram can hold at most ${Ygt} space blocks.`,`limit`,{type:`block`});this.spaces+=Math.max(t,0);for(let r=0;r<t;r++){let t={...n,id:n.id+`-`+r,children:[]};this.byId.set(t.id,t),e.children.push(t)}}else i&&e.children.push(n);a&&a.length>0&&t.push(t_t(a,n))}this.blocks=this.root.children??[]}},r_t=/* @__PURE__ */ `$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`.split(`.`),i_t=[`right`,`left`,`x`,`y`,`up`,`down`],a_t=/* @__PURE__ */ new Uint8Array(128);for(let e of[9,10,11,12,13,32,40,41,45,58,60,61,62,91,123,125])a_t[e]=1;function o_t(e){let t=e.length,n=[],r=[],i=[],a=[],o=0,s=0,c=(e,t,a)=>(n.push(e),r.push(t),i.push(s),s=a,!0),l=(t,n)=>c(t,e.slice(s,n),n),u=e=>{a.push(o),o=e},d=()=>{a.length>0&&(o=a.pop())},f=n=>{for(;n<t&&eq(e.charCodeAt(n));)n++;return n},p=n=>{for(;n<t;){let t=e.charCodeAt(n);if(t<48||t>57)break;n++}return n},m=n=>{for(;n<t&&aq(e.charCodeAt(n));)n++;return n},h=t=>e.startsWith(t,s)&&!aq(e.charCodeAt(s+t.length)),g=()=>(e.charCodeAt(s+1)===96?(u(2),s+=2):(u(1),s++),!0),_=t=>{if(e.charCodeAt(t)!==46)return-1;do t++;while(e.charCodeAt(t)===46);if(e.charCodeAt(t)!==45)return-1;let n=e.charCodeAt(t+1);return n===120||n===111||n===62?t+2:t+1},v=t=>{let n=e.charCodeAt(t);(n===120||n===111||n===60)&&t++;let r=e.charCodeAt(t);if(r===46)return _(t);if(r!==45&&r!==61)return-1;let i=t+1;for(;e.charCodeAt(i)===r;)i++;if(i-t===1)return r===45?_(i):-1;let a=e.charCodeAt(i);return a===120||a===111||a===62?i+1:i-t>=3?i:-1},y=()=>{let t=v(s);if(t>=0)return l(33,f(t));let n=e.charCodeAt(s)===60?s+1:s,r=e.charCodeAt(n),i=e.charCodeAt(n+1);return r===45&&(i===45||i===46)||r===61&&i===61?(u(6),l(34,f(n+2))):!1},b=n=>{let r=e.indexOf(`
|
|
991
|
-
`,s);return r===-1&&(r=t),d(),l(n,r)},x=(t,n)=>{let r=m(s);if(r===s)return!1;for(;e.charCodeAt(r)===44;){let e=f(r+1),t=m(e);if(t===e)break;r=t}return o=n,l(t,r)},S=n=>{if(eq(n))return s=f(s+1),!0;let r;switch(n){case 98:if(e.startsWith(`block`,s)){if(h(`block-beta`))return l(2,s+10);if(e.charCodeAt(s+5)===58)return l(3,s+6);if(!aq(e.charCodeAt(s+5)))return l(2,s+5)}break;case 99:if(e.startsWith(`columns`,s)){if(r=f(s+7),r>s+7){if(e.startsWith(`auto`,r)&&!aq(e.charCodeAt(r+4)))return c(4,`-1`,r+4);let t=p(r);if(t>r)return c(4,e.slice(r,t),t)}}else if(e.startsWith(`class`,s)){let t=e.startsWith(`Def`,s+5),n=t?s+8:s+5;if(r=f(n),r>n)return u(t?7:9),l(t?11:15,r)}break;case 34:return g();case 115:if(e.startsWith(`space`,s)){if(e.charCodeAt(s+5)===58){let t=p(s+6);if(t>s+6)return c(7,e.slice(s+6,t),t)}if(!aq(e.charCodeAt(s+5)))return c(7,`1`,s+5)}else if(e.startsWith(`style`,s)&&(r=f(s+5),r>s+5))return u(11),l(18,r);break;case 100:if(h(`default`))return l(8,s+7);break;case 108:if(h(`linkStyle`))return l(9,s+9);break;case 105:if(h(`interpolate`))return l(10,s+11);break;case 97:if(e.startsWith(`accTitle`,s)){if(r=f(s+8),e.charCodeAt(r)===58)return u(13),l(21,f(r+1))}else if(e.startsWith(`accDescr`,s)){r=f(s+8);let t=e.charCodeAt(r);if(t===58)return u(14),l(23,f(r+1));if(t===123)return u(15),s=f(r+1),!0}break;case 101:if(h(`end`))return l(26,f(s+3));break;case 45:return e.charCodeAt(s+1)===41?(u(3),l(27,s+2)):y();case 61:return y();case 60:return e.charCodeAt(s+1)===91?(u(4),l(29,s+2)):y();case 40:{let t=e.charCodeAt(s+1),n=t===45||t===91?2:t===40?e.charCodeAt(s+2)===40?3:2:1;return u(3),l(27,s+n)}case 41:case 123:return u(3),l(27,e.charCodeAt(s+1)===n?s+2:s+1);case 62:return u(3),l(27,s+1);case 91:{let t=e.charCodeAt(s+1);return u(3),l(27,t===91||t===124||t===40||t===92||t===47?s+2:s+1)}case 58:{let t=p(s+1);return t>s+1&&c(36,e.slice(s+1,t),t)}}for(r=s;r<t;){let t=e.charCodeAt(r);if(t<128?a_t[t]===1:eq(t))break;r++}return r>s&&l(32,r)},C=t=>{let n=e.charCodeAt(s+1),r=0;switch(t){case 34:return g();case 40:r=n===45?2:n===40?e.charCodeAt(s+2)===40?3:2:1;break;case 41:r=n===41?e.charCodeAt(s+2)===41?3:2:n===93?2:1;break;case 125:r=n===125?2:1;break;case 45:r=n===41?2:0;break;case 93:r=n===93||n===41||n===62?2:1;break;case 92:case 47:r=n===93?2:0}return r!==0&&(d(),l(28,s+r))},w=t=>{if(t===41)return d(),d(),c(30,`]>`,f(s+1));let n=f(t===44?s+1:s);for(let r of i_t)if(e.startsWith(r,n)){let i=f(n+r.length);return c(31,e.slice(t===44?n:s,i),i)}return!1};for(;;){if(s>=t){let e=-1;switch(o){case 0:e=37;break;case 1:e=6;break;case 8:e=14;break;case 10:e=17;break;case 12:e=20;break;case 13:e=22;break;case 14:e=24;break;case 15:e=25}s=t,e!==-1&&c(e,``,t);break}let a=e.charCodeAt(s),p=!0;switch(o){case 0:p=S(a);break;case 1:if(a===34)d(),s++;else{let n=e.indexOf(`"`,s);l(6,n===-1?t:n)}break;case 2:if(a===96)p=e.charCodeAt(s+1)===34,p&&(d(),s+=2);else if(a===34)p=!1;else{let n=s+1;for(;n<t;){let t=e.charCodeAt(n);if(t===96||t===34)break;n++}l(5,n)}break;case 3:p=C(a);break;case 4:if(a===34)g();else if(a===93&&e.charCodeAt(s+1)===62){let t=f(s+2);p=e.charCodeAt(t)===40,p&&(u(5),s=t+1)}else p=!1;break;case 5:p=w(a);break;case 6:if(a===34)e.charCodeAt(s+1)===96?g():(l(35,s+1),u(1));else{let e=v(f(s));p=e>=0,p&&(d(),l(33,f(e)))}break;case 7:{let t=12,n=e.startsWith(`DEFAULT`,s)?s+7:s,r=f(n);(n===s||r===n)&&(t=13,n=m(s),r=f(n)),p=n>s&&r>n,p&&(o=8,l(t,r));break}case 8:b(14);break;case 9:p=x(16,10);break;case 10:b(17);break;case 11:p=x(19,12);break;case 12:b(20);break;case 13:b(22);break;case 14:b(24);break;case 15:if(a===125)d(),s++;else{let n=e.indexOf(`}`,s);l(25,n===-1?t:n)}}if(!p)return n.push(1),r.push(``),i.push(s),{types:n,texts:r,starts:i}}return n.push(0),r.push(``),i.push(t),{types:n,texts:r,starts:i}}var AY=`'NODE_ID', 'COLUMNS', 'SPACE_BLOCK', 'BLOCK_DIAGRAM_KEY', 'id-block', 'classDef', 'class', 'style'`;function s_t(e){let t=e[e.length-1];return Array.isArray(t)?(e.pop(),e.concat(t)):e}function c_t(e,t){let{types:n,texts:r,starts:i}=o_t(e),a=0,o=t=>{let r=n[a];throw r===1?FK(`block`,e,i[a],``,!0):FK(`block`,e,i[a],`Expecting ${t}, got '${r_t[r]}'`)},s=e=>(n[a]!==e&&o(`'${r_t[e]}'`),r[a++]),c=()=>{let e=s(32);if(n[a]===27){let t=r[a++];return{id:e,label:s(6),typeStr:t+s(28)}}if(n[a]===29){let t=r[a++],i=s(6),o=[s(31)];for(;n[a]===31;)o.push(r[a++]);return{id:e,label:i,typeStr:t+s(30),directions:o}}return{id:e}},l=()=>{let e=c(),i=n[a]===36?parseInt(r[a++],10):1,o={id:e.id,label:e.label,type:t.typeStr2Type(e.typeStr),directions:e.directions,widthInColumns:i},l;for(;n[a]===33||n[a]===34;){let e=``;n[a++]===34&&(s(35),e=s(6),s(33));let i=r[a-1],u=c(),d=t.edgeStrToEdgeData(i),f=t.edgeStrToEdgeStartData(i),p=t.edgeStrToThickness(i),m=t.edgeStrToPattern(i);l??=[{id:o.id,label:o.label,type:o.type,directions:o.directions}],o={id:u.id,label:u.label,type:t.typeStr2Type(u.typeStr),directions:u.directions},l.push({id:l[l.length-1].id+`-`+u.id,start:l[l.length-1].id,end:u.id,label:e,type:`edge`,thickness:p,pattern:m,directions:u.directions,arrowTypeEnd:d,arrowTypeStart:f},o)}return l??o};s(2);let u=[],d=[];for(;;)switch(n[a]){case 32:d.push(l());break;case 4:d.push({type:`column-setting`,columns:parseInt(r[a++],10)});break;case 7:{let e=parseInt(r[a++],10);d.push({id:t.generateId(),type:`space`,label:``,width:e,children:[]});break}case 2:a++,u.push({list:d,header:void 0}),d=[];break;case 3:a++,n[a]!==32&&o(`'NODE_ID'`),u.push({list:d,header:l()}),d=[];break;case 26:{let e=u.pop();if(e===void 0||d.length===0)return o(AY);a++;let n=t.generateId(),r=s_t(d);d=e.list,d.push(e.header===void 0?{id:n,type:`composite`,label:``,children:r}:{...e.header,type:`composite`,children:r});break}case 11:{a++;let e=s(13).trim();d.push({type:`classDef`,id:e,css:s(14).trim()});break}case 15:{a++;let e=s(16).trim();d.push({type:`applyClass`,id:e,styleClass:s(17).trim()});break}case 18:{a++;let e=s(19).trim();d.push({type:`applyStyles`,id:e,stylesStr:s(20).trim()});break}case 37:u.length>0&&o(AY+`, 'end'`),d.length===0&&o(AY),t.setHierarchy(s_t(d));return;default:o(d.length===0?AY:AY+(u.length>0?`, 'end'`:`, 'EOF'`))}}var jY=1,MY=2,NY=4,PY=8,FY=7,IY=20,LY=12;function l_t(e){let t=0;if(e)for(let n of e)switch(n.trim()){case`right`:t|=jY;break;case`left`:t|=MY;break;case`up`:t|=NY;break;case`down`:t|=PY;break;case`x`:t|=jY|MY;break;case`y`:t|=NY|PY}return t}var RY=(e,t)=>e&t?1:0;function zY(e){return e!==0&&(e&(NY|PY))===0?`x`:e!==0&&(e&(jY|MY))===0?`y`:``}function u_t(e,t,n){let r=zY(e),i=RY(e,MY)-RY(e,jY),a=RY(e,NY)-RY(e,PY);if(r===`x`){let r=Math.max(n+8,14)+2*FY,a=Math.min(r/2,IY);return{w:Math.max(t+12,16)+a*(e===(jY|MY)?2:1),h:r,dx:i*a/2,dy:0}}if(r===`y`){let r=Math.max(t+16,14)+2*FY,i=Math.min(r/2,IY);return{w:r,h:Math.max(n+8,16)+i*(e===(NY|PY)?2:1),dx:0,dy:a*i/2}}return{w:Math.max(t+16,24)+LY*(RY(e,MY)+RY(e,jY)),h:Math.max(n+8,24)+LY*(RY(e,NY)+RY(e,PY)),dx:i*LY/2,dy:a*LY/2}}function d_t(e,t,n,r){let i=zY(e),a=t/2,o=n/2,s;if(i===`x`){let t=Math.min(o,IY),n=o-FY,r=e&MY?-a+t:-a,i=e&jY?a-t:a;s=[r,-n,i,-n],e&jY&&s.push(i,-o,a,0,i,o),s.push(i,n,r,n),e&MY&&s.push(r,o,-a,0,r,-o)}else if(i===`y`){let t=Math.min(a,IY),n=a-FY,r=e&NY?-o+t:-o,i=e&PY?o-t:o;s=[n,r,n,i],e&PY&&s.push(a,i,0,o,-a,i),s.push(-n,i,-n,r),e&NY&&s.push(-a,r,0,-o,a,r)}else{let t=e&MY?-a+LY:-a,n=e&jY?a-LY:a,r=e&NY?-o+LY:-o,i=e&PY?o-LY:o,c=(t+n)/2,l=(r+i)/2,u=Math.min(10,(n-t)/2),d=Math.min(10,(i-r)/2);s=[t,r],e&NY&&s.push(c-u,r,c,-o,c+u,r),s.push(n,r),e&jY&&s.push(n,l-d,a,l,n,l+d),s.push(n,i),e&PY&&s.push(c+u,i,c,o,c-u,i),s.push(t,i),e&MY&&s.push(t,l+d,-a,l,t,l-d)}let c=``;for(let e=0;e<s.length;e+=2)c+=(e?` `:``)+K(s[e])+`,`+K(s[e+1]);return`<polygon points="${c}" stroke-linejoin="round"${r}/>`}var f_t=1e3;function p_t(e,t){if(e===0||!Number.isInteger(e))throw new NK(`Columns must be an integer !== 0.`,`semantic`,{type:`block`});if(t<0||!Number.isInteger(t))throw new NK(`Position must be a non-negative integer.`+t,`semantic`,{type:`block`});return e<0?{px:t,py:0}:{px:t%e,py:Math.floor(t/e)}}function m_t(e,t,n){let r=e.columns,i=[],a=0,o=0,s=0,c=0;for(let n of e.children){let{px:e,py:l}=p_t(r,a),u=n.span>=1?Math.min(n.span,f_t):1;if(r>0&&u>r-e&&(u=r-e),n.span=u,n.col=e,n.row=l,a+=u,e+u>o&&(o=e+u),l===i.length&&i.push(0),n.children.length===0?i[l]=-1:i[l]>=0&&n.nh>i[l]&&(i[l]=n.nh),n.space)continue;let d=(n.nw-t*(u-1))/u;d>s&&(s=d),n.nh>c&&(c=n.nh)}let l=(i.length-1)*t;for(let e=0;e<i.length;e++)i[e]<0&&(i[e]=c),l+=i[e];e.cols=o,e.heights=i,e.nw=Math.max(e.nw,o*s+(o-1)*t+2*n),e.nh=l+2*n+e.head}function h_t(e,t,n){let{cols:r,heights:i}=e,a=i.length,o=(e.w-2*n-(r-1)*t)/r,s=e.h-2*n-e.head-(a-1)*t,c=0;for(let e of i)c+=e;let l=c>0?s/c:0,u=c>0?0:s/a,d=e.x-e.w/2+n,f=e.y-e.h/2+n+e.head,p=0;for(let n of e.children){for(;p<n.row;p++)f+=i[p]*l+u+t;n.w=o*n.span+t*(n.span-1),n.h=i[p]*l+u,n.x=d+n.col*(o+t)+n.w/2,n.y=f+n.h/2}}function g_t(e,t){let n=[e];for(let e=0;e<n.length;e++)for(let t of n[e].children)n.push(t);for(let e=n.length-1;e>=0;e--){let r=n[e];r.children.length>0&&m_t(r,t,e===0?0:t)}e.w=e.nw,e.h=e.nh,e.x=e.w/2,e.y=e.h/2;for(let e=0;e<n.length;e++){let r=n[e];r.children.length>0&&h_t(r,t,e===0?0:t)}return{width:e.w,height:e.h}}var __t=12,v_t=200,y_t=8,b_t=` fill="var(--_s)" stroke="var(--_b)"`,x_t=` stroke="var(--_b)"`,S_t=[],C_t=[],w_t=[],T_t=[`default`],E_t=2e6,D_t=/* @__PURE__ */ 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`]]),O_t=/* @__PURE__ */ new Set([`circle`,`dbl-circ`,`diam`]),k_t=/* @__PURE__ */ new Set([`stadium`,`hex`,`odd`,`lean-r`,`lean-l`,`trap-b`,`trap-t`]);function BY(e){return e.kind===0&&(e.shape===`circle`||e.shape===`dbl-circ`)}function VY(e,t,n){let r=e.bw/2,i=e.bh/2,a=Math.abs(t-e.x),o=i;return BY(e)?o=Math.sqrt(Math.max(r*r-a*a,0)):e.kind===0&&e.shape===`diam`?o=i*Math.max(1-a/r,0):e.kind===0?o=i-zJ(e.shape,e.bw,e.bh,n>0?2:0):e.kind===1&&zY(e.mask)===`x`&&(o=i-FY),e.y+n*o}function HY(e,t,n){let r=e.bw/2,i=e.bh/2,a=Math.abs(t-e.y),o=r;return BY(e)?o=Math.sqrt(Math.max(i*i-a*a,0)):e.kind===0&&e.shape===`diam`?o=r*Math.max(1-a/i,0):e.kind===0?o=r-zJ(e.shape,e.bw,e.bh,n>0?1:3):e.kind===1&&zY(e.mask)===`y`&&(o=r-FY),e.x+n*o}function A_t(e,t,n,r){let i=t-e.x,a=n-e.y,o=e.bw/2,s=e.bh/2,c;c=BY(e)?o/(Math.hypot(i,a)||1):e.kind===0&&e.shape===`diam`?1/(Math.abs(i)/o+Math.abs(a)/s||1):Math.min(i===0?1/0:o/Math.abs(i),a===0?1/0:s/Math.abs(a)),c===1/0&&(c=0),r.push(e.x+i*c,e.y+a*c)}function j_t(e,t,n,r,i){let a=i.x-i.bw/2+1,o=i.x+i.bw/2-1,s=i.y-i.bh/2+1,c=i.y+i.bh/2-1;if(e<a&&n<a||e>o&&n>o||t<s&&r<s||t>c&&r>c)return!1;if(e===n||t===r)return!0;let l=n-e,u=r-t,d=(n,r)=>Math.sign(l*(r-t)-u*(n-e)),f=d(a,s);return f===0||d(o,s)!==f||d(o,c)!==f||d(a,c)!==f}function UY(e,t,n,r){let i=0;for(let a of r)if(a!==t&&a!==n){for(let t=0;t+3<e.length;t+=2)if(j_t(e[t],e[t+1],e[t+2],e[t+3],a)){i++;break}}return i}function M_t(e,t,n,r){let i=e.x-e.bw/2,a=e.x+e.bw/2,o=e.y-e.bh/2,s=e.y+e.bh/2,c=t.x-t.bw/2,l=t.x+t.bw/2,u=t.y-t.bh/2,d=t.y+t.bh/2,f=Math.max(i,c),p=Math.min(a,l),m=Math.max(o,u),h=Math.min(s,d),g=p-f>6,_=h-m>6;if(g&&_){let n=e.bw*e.bh<=t.bw*t.bh?e:t,r=n===e?t:e,i=n.y-n.bh/2-(r.y-r.bh/2),a=r.y+r.bh/2-(n.y+n.bh/2),o=n.x-n.bw/2-(r.x-r.bw/2),s=r.x+r.bw/2-(n.x+n.bw/2),c=Math.min(i,a,o,s),l;return l=c===a?[n.x,VY(n,n.x,1),n.x,r.y+r.bh/2]:c===i?[n.x,VY(n,n.x,-1),n.x,r.y-r.bh/2]:c===s?[HY(n,n.y,1),n.y,r.x+r.bw/2,n.y]:[HY(n,n.y,-1),n.y,r.x-r.bw/2,n.y],n===e?l:[l[2],l[3],l[0],l[1]]}if(g){let r=Math.min(6,(p-f)/2),i=Math.min(Math.max((f+p)/2+n,f+r),p-r),a=t.y>e.y?1:-1;return[i,VY(e,i,a),i,VY(t,i,-a)]}if(_){let r=Math.min(6,(h-m)/2),i=Math.min(Math.max((m+h)/2+n,m+r),h-r),a=t.x>e.x?1:-1;return[HY(e,i,a),i,HY(t,i,-a),i]}let v=t.x>e.x?1:-1,y=t.y>e.y?1:-1,b=[HY(e,e.y,v),e.y,t.x,e.y,t.x,VY(t,t.x,-y)],x=[e.x,VY(e,e.x,y),e.x,t.y,HY(t,t.y,-v),t.y],S=Math.abs(t.x-e.x)>=Math.abs(t.y-e.y),C=S?b:x;if(r===void 0)return C;let w=UY(C,e,t,r);if(w===0)return C;let T=S?x:b,E=UY(T,e,t,r);if(E<w&&(C=T,w=E),w===0)return C;let D=[];return A_t(e,t.x,t.y,D),A_t(t,e.x,e.y,D),UY(D,e,t,r)<w?D:C}function N_t(e,t,n){let r=e.length,i=e[0],a=e[1],o=e[r-2],s=e[r-1],c=e[2]-i,l=e[3]-a,u=Math.hypot(c,l);c/=u||1,l/=u||1;let d=o-e[r-4],f=s-e[r-3],p=Math.hypot(d,f);if(d/=p||1,f/=p||1,r===4&&t+n>u){let e=u/(t+n);t*=e,n*=e}t=Math.min(t,u),n=Math.min(n,p);let m=`M${K(i+c*t)},${K(a+l*t)}`;if(r===6){let r=Math.max(0,Math.min(y_t,u-t,p-n));m+=`L${K(e[2]-c*r)},${K(e[3]-l*r)}Q${K(e[2])},${K(e[3])} ${K(e[2]+d*r)},${K(e[3]+f*r)}`}return m+=`L${K(o-d*n)},${K(s-f*n)}`,{d:m,sx:i,sy:a,sdx:-c,sdy:-l,ex:o,ey:s,edx:d,edy:f}}function P_t(e,t){let n=e.bw/2,r=e.bh/2,i=Math.max(1,Math.min(10+5*(t-1),n,r));if(BY(e)){let t=e.x+n*Math.SQRT1_2,r=e.y-n*Math.SQRT1_2,a=2*Math.asin(Math.min(1,i/(2*n))),o=i=>Math.atan2(e.y-n*Math.sin(i)-r,e.x+n*Math.cos(i)-t);return[t,r,i,o(Math.PI/4+a),o(Math.PI/4-a)]}if(e.kind===0&&e.shape===`diam`){let t=Math.atan2(r,n);return[e.x+n/2,e.y-r/2,i,t+Math.PI,t]}return[e.x+n,e.y-r,i,Math.PI,Math.PI/2]}function F_t(e,t,n,r){let[i,a,o,s,c]=P_t(e,t),l=s+n/o,u=c-r/o,d=(u-l)%(2*Math.PI);d<=0&&(d+=2*Math.PI);let f=i+o*Math.cos(l),p=a+o*Math.sin(l),m=i+o*Math.cos(u),h=a+o*Math.sin(u),g=i+o*Math.cos(s),_=a+o*Math.sin(s),v=i+o*Math.cos(c),y=a+o*Math.sin(c),b=Math.hypot(g-f,_-p),x=Math.hypot(v-m,y-h);return{d:`M${K(f)},${K(p)}A${K(o)},${K(o)} 0 ${+(d>Math.PI)} 1 ${K(m)},${K(h)}`,sx:g,sy:_,sdx:b>0?(g-f)/b:Math.sin(s),sdy:b>0?(_-p)/b:-Math.cos(s),ex:v,ey:y,edx:x>0?(v-m)/x:-Math.sin(c),edy:x>0?(y-h)/x:Math.cos(c)}}var I_t=[.5,.3,.7,.15,.85];function L_t(e,t,n,r,i,a,o){if(o===void 0)return .5;for(let s of I_t){let c=e[t]+(e[t+2]-e[t])*s,l=e[t+1]+(e[t+3]-e[t+1])*s,u=!0;for(let e of o)if(e!==i&&e!==a&&Math.abs(c-e.x)<(n+e.bw)/2&&Math.abs(l-e.y)<(r+e.bh)/2){u=!1;break}if(u)return s}return .5}function R_t(e,t,n){return XJ(n,r=>z_t(e,t,n,r))}function z_t(e,t,n,r){let i=n.fontSize??16,a=Math.round(i*.875),o=n.measurer??fq(n.fontFamily),s=n.padding??8,c=n.icons,l=t.block?.padding,u=Math.min(typeof l==`number`&&l>=0?Math.min(l,200):__t,r?6:1/0),d=r?80:v_t,f=t=>{let n=[],r=e=>{for(let t of e)for(let e of t.split(`;`))n.push(e)};for(let n of t.classes&&t.classes.length>0?t.classes:T_t){let t=e.classes.get(n);t&&r(t.styles)}return t.styles&&r(t.styles),mJ(n)},p=(e,t)=>{let a=e.type,s=a===`space`?mJ(S_t):f(e),c=+!!s.bold|(s.italic?2:0),l=s.fontSize??i,p=0,m=``,h,g=0,_=0,v=0,y=0,b=0,x=0;if(a===`space`)p=3,h=WJ(void 0,!1,o,l,d);else if(a===`composite`)p=2,h=WJ(e.label,!1,o,l,r?KJ(n):4e3,c),v=h.height>0?h.height+4:0,g=h.width+2*u,_=v+2*u;else if(a===`block_arrow`){p=1,h=WJ(e.label,!1,o,l,d,c);let t=!0;for(let e of h.lines)for(let n of e)(n.icon!==void 0||n.text.trim()!==``)&&(t=!1);y=l_t(e.directions);let n=t?u_t(y,0,0):u_t(y,h.width,h.height);g=n.w,_=n.h,b=n.dx,x=n.dy}else{m=D_t.get(a??``)??`rect`,h=WJ(e.label,!1,o,l,d,c);let t=LJ(m,h.width,h.height);g=t.w,_=m===`cyl`?Math.max(t.h,h.height+40):t.h,x=t.dy}return{children:[],columns:p===2?e.columns??-1:-1,span:p===3?1:e.widthInColumns??1,space:p===3,head:v,nw:g,nh:_,col:0,row:0,cols:0,heights:w_t,x:0,y:0,w:0,h:0,block:e,kind:p,index:t,shape:m,label:h,style:s,mask:y,dx:b,dy:x,bw:0,bh:0}},m=p(e.root,0);m.nw=0,m.nh=0;let h=[m],g=/* @__PURE__ */ new Map;for(let e=0;e<h.length;e++){let t=h[e];if(t.kind===2)for(let e of t.block.children??C_t){let n=p(e,h.length);t.children.push(n),h.push(n),n.kind!==3&&g.set(e.id,n)}}let _=g_t(m,u),v=[];for(let e of h)e.kind===0&&O_t.has(e.shape)?(e.bw=e.nw,e.bh=e.nh):e.kind===1?(e.bw=e.span>1?e.w:e.nw,e.bh=e.nh):(e.bw=e.w,e.bh=e.kind===0&&k_t.has(e.shape)?e.nh:e.h),e.kind===0&&e.shape===`cyl`&&(e.dy=Math.min(12,Math.max(6,e.bw/14))/2),(e.kind===0||e.kind===1)&&v.push(e);let y=/* @__PURE__ */ new Map,b=/* @__PURE__ */ new Set,x=[],S=[];for(let t of e.edges){let e=g.get(t.start??``),n=g.get(t.end??``);if(e===void 0||n===void 0)continue;let r=Math.min(e.index,n.index)*h.length+Math.max(e.index,n.index);y.set(r,(y.get(r)??0)+1),t.label&&b.add(r),x.push([e,n]),S.push(t)}let C=S.length*v.length<=E_t?v:void 0,w=/* @__PURE__ */ new Map,T=[],E=0,D=0,O=_.width,k=_.height,A=(e,t,n,r)=>{e-n/2<E&&(E=e-n/2),e+n/2>O&&(O=e+n/2),t-r/2<D&&(D=t-r/2),t+r/2>k&&(k=t+r/2)};for(let e=0;e<S.length;e++){let[t,n]=x[e],r=Math.min(t.index,n.index)*h.length+Math.max(t.index,n.index),i=y.get(r)??1,s=w.get(r)??0;w.set(r,s+1);let c=WJ(S[e].label,!1,o,a,v_t),l,u,d;if(t===n){let[e,n,r]=P_t(t,s+1);l=[],A(e,n,2*r+2,2*r+2),u=e+r+6+c.width/2,d=n-r/2}else{let e=b.has(r)?Math.round(a*1.5)+2:14;l=M_t(t,n,(s-(i-1)/2)*e,C);let o=l.length,f=Math.abs(l[2]-l[0])+Math.abs(l[3]-l[1]),p=Math.abs(l[o-2]-l[o-4])+Math.abs(l[o-1]-l[o-3]),m=o===6&&p>f?2:0,h=c.width>0?L_t(l,m,c.width+8,c.height,t,n,C):.5;u=l[m]+(l[m+2]-l[m])*h,d=l[m+1]+(l[m+3]-l[m+1])*h}c.width>0&&A(u,d,c.width+8,c.height),T.push({edge:S[e],points:l,loop:t===n?s+1:0,label:c,lx:u,ly:d})}let j=WJ(e.title,!1,o,i,r?KJ(n):4e3,1),M=j.height>0?j.height+12:0,N=Math.max(O-E,j.width),P=s-E+(N-(O-E))/2,F=s+M-D;for(let e of h)e.x+=P,e.y+=F;let ee=Math.ceil(N+2*s),te=Math.ceil(k-D+M+2*s),I=``,ne=``;for(let e=1;e<h.length;e++){let t=h[e];if(t.kind===3)continue;let n=hJ((t.block.classes??S_t).join(` `)),r=mq(t.block.id);if(t.kind===2){let e=t.y-t.h/2;I+=`<g class="pele-cluster${n}" data-id="${r}"><rect x="${K(t.x-t.w/2)}" y="${K(e)}" width="${K(t.w)}" height="${K(t.h)}" rx="${fJ}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${t.style.shape}/>`+gq(t.label,t.x,e+(t.head+u)/2+2,` class="pele-cluster-label" fill="var(--_m)"${t.style.text}`,c)+`</g>`;continue}let i=t.kind===1;ne+=`<g class="pele-node pele-shape-${i?`block-arrow`:t.shape}${n}" data-id="${r}" transform="translate(${K(t.x)},${K(t.y)})">`+(i?d_t(t.mask,t.bw,t.bh,b_t+t.style.shape):RJ(t.shape,t.bw,t.bh,b_t+t.style.shape,x_t+t.style.line))+gq(t.label,t.dx,t.dy,` class="pele-label"${t.style.text}`,c)+`</g>`}let re=``,ie=``;for(let e=0;e<T.length;e++){let{edge:t,points:n,loop:r,label:i}=T[e],a=t.arrowTypeStart??``,o=t.arrowTypeEnd??``,s;if(r>0)s=F_t(x[e][0],r,sJ(a),sJ(o));else{for(let e=0;e<n.length;e+=2)n[e]+=P,n[e+1]+=F;s=N_t(n,sJ(a),sJ(o))}let l=mq(t.id);if(re+=`<g class="pele-edge" data-id="${l}"><path d="${s.d}"${t.thickness===`thick`?` stroke-width="2.5"`:``}${t.pattern===`dotted`?` stroke-dasharray="3 4"`:``}/>`+cJ(a,s.sx,s.sy,s.sdx,s.sdy,`var(--_l)`)+cJ(o,s.ex,s.ey,s.edx,s.edy,`var(--_l)`)+`</g>`,i.width>0){let n=T[e].lx+P,r=T[e].ly+F;ie+=lJ(t.id,i,n,r,``,c)}}return{svg:vJ(`block`,ee,te,i,n,e,gq(j,ee/2,s+j.height/2,` class="pele-title" font-weight="var(--_tw)"`)+(I?`<g class="pele-clusters">${I}</g>`:``)+(re?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${re}</g>`:``)+`<g class="pele-nodes">${ne}</g>`+(ie?`<g class="pele-edge-labels" font-size="${a}">${ie}</g>`:``)),width:ee,height:te,links:[]}}var B_t={type:`block`,parse(e,t,n){let r=new n_t;return r.title=n,c_t(e,r),r},render:R_t},V_t=/* @__PURE__ */ new Set([`label`,`type`,`descr`,`techn`,`sprite`,`tags`,`link`,`bgColor`,`fontColor`,`borderColor`,`shadowing`,`shape`,`legendText`,`legendSprite`]),H_t=/* @__PURE__ */ new Set([`label`,`descr`,`techn`,`sprite`,`tags`,`link`,`textColor`,`lineColor`]);function WY(e,t){let{key:n,value:r}=t;`from`in e&&(n===`offsetX`||n===`offsetY`)?e[n]=parseInt(r):(`from`in e?H_t:V_t).has(n)?e[n]=r:(e.extra??=/* @__PURE__ */ new Map).set(n,r)}function GY(e,t,n){n!==void 0&&(typeof n==`string`?e[t]=n:WY(e,n))}function KY(e,t,n){n===void 0?e[t]??=``:GY(e,t,n)}function U_t(e,t){e.labelAttr=void 0,typeof t==`object`?(e.label=``,e.labelAttr=t,WY(e,t)):e.label=t??``}var W_t=class{type=`c4`;c4Type;title;accTitle;accDescr;shapes=[];boundaries=[{alias:`global`,label:`global`,type:`global`,parent:void 0}];rels=[];shapeInRow=4;boundaryInRow=2;shapeIndex=/* @__PURE__ */ new Map;boundaryIndex=/* @__PURE__ */ new Map;relIndex=/* @__PURE__ */ new Map;current=this.boundaries[0];stack=[];setC4Type(e){this.c4Type=e}setTitle(e){this.title=e}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
992
|
-
`)}element(e,t,n,r){let i=typeof n==`string`?t.get(n):void 0;return i===void 0&&(i={alias:``,label:``,parent:void 0},e.push(i),typeof n==`string`?(i.alias=n,t.set(n,i)):(i.aliasAttr=n,
|
|
993
|
-
`,s+2);for(;n<t&&(e.charCodeAt(n)===10||e.charCodeAt(n)===13);)n++;s=n;continue}if(eq(n)){let n=s,r=-1;for(;n<t;){let t=e.charCodeAt(n);if(!eq(t))break;t===10&&(r=n),n++}r===-1?s=n:f(13,s,r+1);continue}if(n===123){f(62,s,s+1);continue}if(n===125){f(63,s,s+1);continue}if(aq(n)){let n=s+1;for(;n<t&&aq(e.charCodeAt(n));)n++;let r=n-s<=19?
|
|
994
|
-
`,s)),a=0):n===125?(s++,a=0):f(12,s,m(`}`,s))}return{types:n,starts:r,ends:i}}var
|
|
995
|
-
`)){let e=Array.from(o);e.length===0&&a.push(``);let s=0;for(;s<e.length;){let o=a=>t.width(e.slice(s,s+a).join(``),n,i)<=r,c=1;for(;c<e.length-s&&o(c);)c=Math.min(e.length-s,c*2);let l=1;for(;l<c;){let e=Math.ceil((l+c)/2);o(e)?l=e:c=e-1}let u=l,d=s+u<e.length;if(d&&!XY.test(e[s+u])){for(let t=u-1;t>0;t--)if(XY.test(e[s+t])){u=t+1;break}}let f=e.slice(s,s+u).join(``);for(a.push(d&&f.trimEnd()||f),s+=u;d&&s<e.length&&XY.test(e[s]);)s++}}e===``&&(a.length=0);let o=a.map(e=>t.width(e,n,i)),s=0;for(let e of o)s=Math.max(s,e);let c=Math.round(n*1.5);return{lines:a.map((e,t)=>[{text:e,style:i,width:o[t]}]),widths:o,width:s,height:a.length*c,size:n,lineHeight:c}}function QY(e,t,n){if(e.width<=n)return e;let r=[],i=[];for(let a=0;a<e.lines.length;a++){if(e.widths[a]<=n){r.push(e.lines[a]),i.push(e.widths[a]);continue}let o=[],s=0,c=()=>{r.push(o),i.push(s),o=[],s=0};for(let r of e.lines[a])if(r.icon!==void 0)o.length&&s+r.width>n&&c(),o.push(r),s+=r.width;else for(let i of Array.from(r.text)){let a=o[o.length-1],l=a&&a.icon===void 0&&a.style===r.style,u=t.width(l?a.text+i:i,e.size,r.style)-(l?a.width:0);o.length&&s+u>n&&(c(),a=void 0,u=t.width(i,e.size,r.style)),a&&a.icon===void 0&&a.style===r.style?(a.text+=i,a.width+=u):o.push({text:i,style:r.style,width:u}),s+=u}(o.length||!e.lines[a].length)&&c()}let a=0;for(let e of i)a=Math.max(a,e);return{...e,lines:r,widths:i,width:a,height:r.length*e.lineHeight}}function $Y(e,t,n,r){let i=vq(e),a=`<text`+yq(r,i),o=``;for(let s=0;s<e.lines.length;s++){let c=e.lines[s],l=n+(s+.5)*e.lineHeight;if(c.some(e=>e.icon!==void 0)){let n=e.widths[s];o+=gq({...e,lines:[c],widths:[n],width:n,height:e.lineHeight},t+n/2,l,r);continue}let u=``;for(let e of c){let t=_q(e.style&~i);u+=t?`<tspan${t}>${pq(e.text)}</tspan>`:pq(e.text)}u!==``&&(o+=`${a} x="${K(t)}" y="${K(l+e.size*.35)}" text-anchor="start" xml:space="preserve">${u}</text>`)}return o}var eX=28,tX=20,tvt=7,nvt=8,rvt=30,nX=88,rX=160,iX=26,ivt=e=>Math.min(12,Math.max(6,e/14)),avt=e=>Math.min(12,e/4);function aX(e,t,n,r,i,a,o,s){let c=0,l=1;if(o===0){if(i<e||i>n)return 1/0}else{let t=(e-i)/o,r=(n-i)/o;c=Math.max(c,Math.min(t,r)),l=Math.min(l,Math.max(t,r))}if(s===0){if(a<t||a>r)return 1/0}else{let e=(t-a)/s,n=(r-a)/s;c=Math.max(c,Math.min(e,n)),l=Math.min(l,Math.max(e,n))}return c<=l?c:1/0}function oX(e,t,n,r,i,a,o,s){let c=o/n,l=s/r,u=(i-e)/n,d=(a-t)/r,f=c*c+l*l,p=2*(c*u+l*d),m=u*u+d*d-1,h=p*p-4*f*m;if(f===0||h<0)return 1/0;let g=(-p-Math.sqrt(h))/(2*f);return g>=0&&g<=1?g:m<=0?0:1/0}function sX(e,t,n,r,i){let{x:a,y:o,w:s,h:c}=e,l=r-t,u=i-n;if(e.form===`person`)return Math.min(aX(a,o+iX,a+s,o+c,t,n,l,u),oX(a+s/2,o+14,13,13,t,n,l,u));if(e.form===`cyl`){let e=ivt(s);return Math.min(aX(a,o+e,a+s,o+c-e,t,n,l,u),oX(a+s/2,o+e,s/2,e,t,n,l,u),oX(a+s/2,o+c-e,s/2,e,t,n,l,u))}if(e.form===`h-cyl`){let e=avt(c);return Math.min(aX(a+e,o,a+s-e,o+c,t,n,l,u),oX(a+e,o+c/2,e,c/2,t,n,l,u),oX(a+s-e,o+c/2,e,c/2,t,n,l,u))}return aX(a,o,a+s,o+c,t,n,l,u)}function ovt(e,t,n,r,i){for(let a=2;a<e.length;a+=2){let o=e[a-2],s=e[a-1];if(aX(t,n,r,i,o,s,e[a]-o,e[a+1]-s)<=1)return!0}return!1}function cX(e,t){return e.x<=t.x&&e.y<=t.y&&e.x+e.w>=t.x+t.w&&e.y+e.h>=t.y+t.h}function svt(e,t,n){let r=e.x+e.w/2,i=e.y+e.h/2,a=t.x+t.w/2,o=t.y+t.h/2,s=cX(e,t);if(s||cX(t,e)){let n=s?e:t,r=s?t:e,i=r.x+r.w/2,a=r.y+r.h/2,o=r.x-n.x,c=n.x+n.w-r.x-r.w,l=r.y-n.y,u=n.y+n.h-r.y-r.h,d=Math.min(o,c,l,u),f=d===o?n.x:d===c?n.x+n.w:i,p=d===o||d===c?a:d===u?n.y+n.h:n.y,m=Math.min(sX(r,f,p,i,a),1),h=f+(i-f)*m,g=p+(a-p)*m;return s?[f,p,h,g]:[h,g,f,p]}let c=r,l=i,u=a,d=o,f=Math.max(e.x,t.x),p=Math.min(e.x+e.w,t.x+t.w),m=Math.max(e.y,t.y),h=Math.min(e.y+e.h,t.y+t.h);f<p?c=u=(f+p)/2:m<h&&(l=d=(m+h)/2);let g=Math.hypot(u-c,d-l)||1,_=-(d-l)/g*n,v=(u-c)/g*n,y=sX(e,u+_,d+v,c+_,l+v),b=sX(t,c+_,l+v,u+_,d+v);return y<=1&&b<=1?(c+=_,l+=v,u+=_,d+=v):(c=r,l=i,u=a,d=o,y=Math.min(sX(e,u,d,c,l),1),b=Math.min(sX(t,c,l,u,d),1)),[u+(c-u)*y,d+(l-d)*y,c+(u-c)*b,l+(d-l)*b]}var lX=6,cvt=3,lvt=12,uvt=class{upright=[];level=[];frames=[[],[]];taken=/* @__PURE__ */ new Map;squeezed=0;free(e,t,n,r){let i=Math.min(n,r),a=Math.max(n,r),o=(e,n)=>{for(let r=0;r<e.length;r+=3)if(Math.abs(e[r]-t)<n&&e[r+1]<a&&e[r+2]>i)return!0;return!1};return!o(e?this.upright:this.level,lX)&&!o(this.frames[+!e],cvt)}crossings(e){let t=0;for(let n=2;n<e.length;n+=2){let r=e[n]===e[n-2],i=r?e[n]:e[n+1],a=Math.min(r?e[n-1]:e[n-2],r?e[n+1]:e[n]),o=Math.max(r?e[n-1]:e[n-2],r?e[n+1]:e[n]),s=r?this.level:this.upright;for(let e=0;e<s.length;e+=3)s[e]>a&&s[e]<o&&s[e+1]<i&&s[e+2]>i&&t++}return t}frame(e){this.frames[0].push(e.x,e.y,e.y+e.h,e.x+e.w,e.y,e.y+e.h),this.frames[1].push(e.y,e.x,e.x+e.w,e.y+e.h,e.x,e.x+e.w)}take(e){for(let t=2;t<e.length;t+=2)e[t]===e[t-2]?this.upright.push(e[t],Math.min(e[t-1],e[t+1]),Math.max(e[t-1],e[t+1])):e[t+1]===e[t-1]&&this.level.push(e[t+1],Math.min(e[t-2],e[t]),Math.max(e[t-2],e[t]))}ports(e,t,n,r,i){let a=this.taken.get(e)??[],o=[];for(let e=0;e<9&&o.length<4;e++){let s=n+(e&1?1:-1)*Math.ceil(e/2)*lvt;if(s<r||s>i)continue;let c=!0;for(let e=0;e<a.length;e+=2)a[e]===t&&Math.abs(a[e+1]-s)<lvt&&(c=!1);c&&o.push(s)}return o.length?o:[n]}claim(e,t,n){let r=this.taken.get(e);r?r.push(t,n):this.taken.set(e,[t,n])}};function dvt(e,t,n){let r=e.length,i=Math.sign(e[2]-e[0]),a=Math.sign(e[3]-e[1]),o=`M${K(e[0]+i*t)},${K(e[1]+a*t)}`;for(let t=2;t<r-2;t+=2){let n=e[t],r=e[t+1],i=Math.sign(n-e[t-2]),a=Math.sign(r-e[t-1]),s=Math.sign(e[t+2]-n),c=Math.sign(e[t+3]-r),l=Math.min(nvt,Math.abs(n-e[t-2]+r-e[t-1])/2,Math.abs(e[t+2]-n+e[t+3]-r)/2);o+=`${i?`H`+K(n-i*l):`V`+K(r-a*l)}Q${K(n)},${K(r)} ${K(n+s*l)},${K(r+c*l)}`}let s=Math.sign(e[r-2]-e[r-4]),c=Math.sign(e[r-1]-e[r-3]);return o+(s?`H`+K(e[r-2]-s*n):`V`+K(e[r-1]-c*n))}function fvt(e,t,n,r){for(let i of t)if(i!==n&&i!==r&&ovt(e,i.x,i.y,i.x+i.w,i.y+i.h))return!1;return!0}function pvt(e,t,n,r,i){let a=e.length;return{d:dvt(e,n,r),sx:e[0],sy:e[1],sdx:-Math.sign(e[2]-e[0]),sdy:-Math.sign(e[3]-e[1]),ex:e[a-2],ey:e[a-1],edx:Math.sign(e[a-2]-e[a-4]),edy:Math.sign(e[a-1]-e[a-3]),x0:e[t],y0:e[t+1],x1:e[t+2],y1:e[t+3],nx:0,ny:0,lean:0,room:rX,...i,points:e}}function mvt(e,t){let n=[],r=(e+t)/2,i=Math.max(tvt,(t-e)/4);for(let a=0;a<9;a++){let o=r+(a&1?1:-1)*Math.ceil(a/2)*i;o>=e+lX&&o<=t-lX&&n.push(o)}return n}function hvt(e,t,n,r,i,a){let o=e.x+e.w/2,s=e.y+e.h/2,c=t.x+t.w/2,l=t.y+t.h/2,u,d=(i,a,o)=>{if(!fvt(i,n,e,t))return;for(let e=2;e<i.length;e+=2){let t=i[e]===i[e-2];if(!r.free(t,t?i[e]:i[e+1],t?i[e-1]:i[e-2],t?i[e+1]:i[e]))return}let s=r.crossings(i)*1e6;for(let e=2;e<i.length;e+=2)s+=Math.abs(i[e]-i[e-2])+Math.abs(i[e+1]-i[e-1]);(!u||s<u.cost)&&(u={points:i,cost:s,upright:a,sides:o})};if(e.x+e.w<=t.x||t.x+t.w<=e.x){let n=c>o,i=Math.sign(l-s),a=n?[1,0]:[0,1],f=mvt(n?e.x+e.w:t.x+t.w,n?t.x:e.x);e:for(let n of r.ports(e,a[0],s+i*e.h/4,e.y+8,e.y+e.h-8))for(let s of r.ports(t,a[1],l-i*t.h/4,t.y+8,t.y+t.h-8))for(let r of f){let i=r+(o-r)*Math.min(sX(e,r,n,o,n),1),l=r+(c-r)*Math.min(sX(t,r,s,c,s),1),f=u;if(d([i,n,r,n,r,s,l,s],!0,a),u!==f)break e}}if(e.y+e.h<=t.y||t.y+t.h<=e.y){let n=l>s,i=Math.sign(c-o),a=n?[3,2]:[2,3],f=mvt(n?e.y+e.h:t.y+t.h,n?t.y:e.y);e:for(let n of r.ports(e,a[0],o+i*e.w/4,e.x+8,e.x+e.w-8))for(let o of r.ports(t,a[1],c-i*t.w/4,t.x+8,t.x+t.w-8))for(let r of f){let i=r+(s-r)*Math.min(sX(e,n,r,n,s),1),c=r+(l-r)*Math.min(sX(t,o,r,o,l),1),f=u;if(d([n,i,n,r,o,r,o,c],!1,a),u!==f)break e}}if(!u)return;let{points:f,upright:p,sides:m}=u;return r.take(f),r.claim(e,m[0],p?f[1]:f[0]),r.claim(t,m[1],p?f[7]:f[6]),pvt(f,2,i,a,{room:p?nX:rX})}function gvt(e,t,n,r,i,a,o){if(e===t){let t=Math.min(e.h/2-4,10),n=Math.hypot(eX,t),r=e.x+e.w,i=e.y+e.h/2,s=eX/n,c=t/n;return{d:`M${K(r+s*a)},${K(i-t-c*a)}C${K(r+eX)},${K(i-t*2)} ${K(r+eX)},${K(i+t*2)} ${K(r+s*o)},${K(i+t+c*o)}`,sx:r,sy:i-t,sdx:-s,sdy:c,ex:r,ey:i+t,edx:-s,edy:-c,x0:r+eX+4,y0:i,x1:r+eX+4,y1:i,nx:1,ny:0,lean:0,room:64,points:[]}}let[s,c,l,u]=svt(e,t,n),d=s===l,f=!1;if(r&&!cX(e,t)&&!cX(t,e))for(let n of r)n!==e&&n!==t&&aX(n.x,n.y,n.x+n.w,n.y+n.h,s,c,l-s,u-c)<=1&&(f=!0);if(r&&f&&!d&&c!==u){let n=hvt(e,t,r,i,a,o);if(n)return n;i.squeezed++}if(r&&f&&(d||c===u)){let n=n=>{let i=n?-1/0:1/0,a=e=>{let t=d?e.x:e.y;i=n?Math.max(i,t+(d?e.w:e.h)):Math.min(i,t)};a(e),a(t);for(let n of r)n!==e&&n!==t&&aX(n.x,n.y,n.x+n.w,n.y+n.h,s,c,l-s,u-c)<=1&&a(n);return i},f=d?Math.min(e.y,t.y):Math.min(e.x,t.x),p=d?Math.max(e.y+e.h,t.y+t.h):Math.max(e.x+e.w,t.x+t.w),m=(n,i)=>{for(let a of r){if(a===e||a===t)continue;let r=d?a.y<p&&a.y+a.h>f:a.x<p&&a.x+a.w>f,o=d?a.x:a.y,s=o+(d?a.w:a.h);if(r&&(n?s>i:o<i))return!1}return!0},h=e.x+e.w/2,g=e.y+e.h/2,_=t.x+t.w/2,v=t.y+t.h/2,y=Math.sign(d?v-g:_-h),b=a=>{let o=n(a),s=a?1:-1,c=d?+!!a:a?3:2,l=d?i.ports(e,c,g+y*e.h/4,e.y+8,e.y+e.h-8)[0]:i.ports(e,c,h+y*e.w/4,e.x+8,e.x+e.w-8)[0],u=d?i.ports(t,c,v-y*t.h/4,t.y+8,t.y+t.h-8)[0]:i.ports(t,c,_-y*t.w/4,t.x+8,t.x+t.w-8)[0],f=n=>{if(d){let r=n+(h-n)*Math.min(sX(e,n,l,h,l),1),i=n+(_-n)*Math.min(sX(t,n,u,_,u),1);return[r,l,n,l,n,u,i,u]}let r=n+(g-n)*Math.min(sX(e,l,n,l,g),1),i=n+(v-n)*Math.min(sX(t,u,n,u,v),1);return[l,r,l,n,u,n,u,i]},p=f(o+s*tX);for(let n=0;n<=4;n++){let a=o+s*(tX+n*tvt),m=f(a);if(fvt(m,r,e,t)&&(p=m,i.free(d,a,l,u)))return{points:p,side:c,p0:l,p1:u,step:n}}return{points:p,side:c,p0:l,p1:u,step:5}},x=d?u>c:l<s,S=m(x,n(x)),C=m(!x,n(!x)),w=b(x),T=S===C?b(!x):void 0,E=e=>i.crossings(e.points)*8+e.step,D=C&&!S||T&&E(T)<E(w)?!x:x,{points:O,side:k,p0:A,p1:j,step:M}=D===x?w:T??b(!x),N=D?1:-1;return M>4&&i.squeezed++,i.take(O),i.claim(e,k,A),i.claim(t,k,j),pvt(O,2,a,o,d?{nx:N,lean:rvt,room:nX}:{room:rX})}let p=Math.hypot(l-s,u-c)||1,m=(l-s)/p,h=(u-c)/p;return(d||c===u)&&i.take([s,c,l,u]),{d:`M${K(s+m*a)},${K(c+h*a)}L${K(l-m*o)},${K(u-h*o)}`,sx:s,sy:c,sdx:-m,sdy:-h,ex:l,ey:u,edx:m,edy:h,x0:s,y0:c,x1:l,y1:u,nx:n?-h:0,ny:n?m:0,lean:0,room:Math.abs(m)>Math.abs(h)?nX:rX,points:[s,c,l,u]}}var uX=216,_vt=64,vvt=14,yvt=12,bvt=100,xvt=88,Svt=tX+8,dX=48,fX=16,pX=10,mX=/* @__PURE__ */ new Map([[`person`,`person`],[`box`,`rect`],[`rounded`,`rect`],[`component`,`rect`],[`cylinder`,`cyl`],[`database`,`cyl`],[`db`,`cyl`],[`queue`,`h-cyl`],[`pipe`,`h-cyl`]]);function Cvt(e){let t=mX.get((e.shape??``).toLowerCase())??mX.get((e.sprite??``).toLowerCase());if(t)return t;if(e.tags)for(let t of e.tags.split(`,`)){let e=mX.get(t.trim().toLowerCase());if(e)return e}let n=e.kind;return n.endsWith(`person`)?`person`:n.endsWith(`_db`)?`cyl`:n.endsWith(`_queue`)?`h-cyl`:`rect`}function wvt(e,t,n,r,i=uX){let a=Cvt(e),o=a===`h-cyl`?36:0,s=a===`person`?iX:a===`cyl`?24:0,c=i-2*vvt-o,l=[WJ(`«`+e.kind.replace(/_/g,` `)+`»`,!1,t,r-1,c),WJ(e.label,!1,t,n,c,1),WJ(e.techn?`[${e.techn}]`:void 0,!1,t,r,c),WJ(e.descr,!1,t,r,c)],u=0,d=l[3].height>0?4:0;for(let e of l)u=Math.max(u,e.width),d+=e.height;return{shape:e,form:a,labels:l,textH:d,x:0,y:0,w:Math.max(i,u+2*vvt+o),h:Math.max(_vt,d+2*yvt+s)}}function Tvt(e,t,n,r,i){let a=0,o=0;for(let s=0;s<e.length;s+=t){let c=Math.min(e.length,s+t),l=0,u=0;for(let t=s;t<c;t++)u=Math.max(u,e[t].h);for(let t=s;t<c;t++){let r=e[t];r.x=l,r.y=o,i&&(r.h=u),l+=r.w+n}a=Math.max(a,l-n),o+=u+r}return[a,e.length>0?o-r:0]}function Evt(e,t,n,r,i,a){let o=i===void 0?Svt:12,s=/* @__PURE__ */ new Map;for(let a of e.boundaries){let e=i===void 0?4e3:Math.max(80,i-2*fX-2*Svt*2),c=a.parent?[WJ(a.label,!1,t,n,e,1),WJ(a.type?`[${a.type}]`:void 0,!1,t,r,e),WJ(a.descr,!1,t,r,e)]:[],l=0,u=0;for(let e of c)l+=e.height,u=Math.max(u,e.width);s.set(a,{boundary:a,kids:[],nodes:[],labels:c,head:l>0?l+pX+6+tX:o,headW:u,headX:fX,x:0,y:0,w:0,h:0,form:`rect`})}let c=s.get(e.boundaries[0]);for(let e of s.values()){let t=e.boundary.parent;t&&s.get(t)?.kids.push(e)}let l=[c],u=/* @__PURE__ */ new Map([[c.boundary,0]]);for(let e=0;e<l.length;e++)for(let t of l[e].kids)u.set(t.boundary,u.get(l[e].boundary)+1),l.push(t);for(let a of e.shapes)if(a.parent){let e=u.get(a.parent)??0,c=i===void 0?uX:Math.max(100,Math.min(uX,i-2*e*o-32));s.get(a.parent)?.nodes.push(wvt(a,t,n,r,c))}let d=Math.max(1,e.shapeInRow),f=Math.max(1,e.boundaryInRow),p=/* @__PURE__ */ new Map;for(let e=l.length-1;e>=0;e--){let t=l[e],n=i===void 0?bvt:a,r=(e,t,n)=>{if(i===void 0)return t;let r=1;for(let t of e)r=Math.max(r,t.w);return Math.max(1,Math.min(t,Math.floor((i+n-2*o)/(r+n))))},[s,u]=Tvt(t.nodes,r(t.nodes,d,n),n,xvt,!0),[m,h]=Tvt(t.kids,r(t.kids,f,dX),dX,dX,!1),g=u>0&&h>0?dX:0,_=t===c?0:o;p.set(t,u+g),t.w=Math.max(s,m,t.headW+2*fX-2*_)+2*_,t.h=(_&&t.head)+u+g+h+_}let m=/* @__PURE__ */ new Map;for(let e of l){let t=e.x+(e===c?0:o),n=e.y+(e===c?0:e.head);for(let r of e.nodes)r.x+=t,r.y+=n,m.set(r.shape,r);for(let r of e.kids)r.x+=t,r.y+=n+p.get(e);e!==c&&m.set(e.boundary,e)}return{order:l,boxes:m}}var Dvt=7,hX=36,gX=24,Ovt=2e3,_X=8,kvt=[.5,.4,.6,.3,.7,.2,.8],Avt=2e6;function vX(e,t,n){let r=[];return e&&r.push(`fill:`+e),t&&r.push(`stroke:`+t),n&&r.push(`color:`+n),mJ(r)}function yX(e,t,n,r,i){return t?Tq(e,Sq(t.includes(`¶ß`)?t.replace(/\ufb02\u00b0\u00b0?/g,`#`).replace(/\u00b6\u00df/g,`;`):t),n,r,i):e}function jvt(e,t,n){return XJ(n,r=>{if(!r)return bX(e,t,n,!1)[0];let[i,a]=bX(e,t,n,!0,hX);for(let r=hX+gX;a>0&&r<=hX+3*gX;r+=gX){let[o,s]=bX(e,t,n,!0,r);s<a&&([i,a]=[o,s])}return i})}function bX(e,t,n,r,i=hX){let a=n.fontSize??16,o=Math.round(a*.8125),s=n.measurer??fq(n.fontFamily),c=n.padding??8,l=[],{order:u,boxes:d}=Evt(e,s,a,o,r?Math.max(80,(n.maxWidth??320)-2*c):void 0,i),f=u[0],p=0,m=0,h=f.w,g=f.h,_=(e,t,n,r)=>{p=Math.min(p,e),m=Math.min(m,t),h=Math.max(h,n),g=Math.max(g,r)},v=[],y=/* @__PURE__ */ new Map;for(let t of e.rels){let n=t.fromAttr?void 0:e.getC4Shape(t.from),r=t.toAttr?void 0:e.getC4Shape(t.to),i=n&&d.get(n),a=r&&d.get(r);if(!i||!a)throw new NK(`C4 rel "${t.from}" -> "${t.to}" references an unknown shape or boundary`,`semantic`,{type:`c4`});v.push(i,a);let o=y.get(i);o||y.set(i,o=/* @__PURE__ */ new Set),o.add(a)}let b=[],x=[];for(let e of u)for(let t of e.nodes)b.push(t),x.push(t.x+_X,t.y+_X,t.x+t.w-_X,t.y+t.h-_X);let S=e.rels.length*(b.length+u.length+3*e.rels.length)<=Avt,C=(e,t,n,r)=>{let i=0;for(let a=0;a<x.length;a+=4){let o=Math.min(n,x[a+2])-Math.max(e,x[a]);if(o<=0)continue;let s=Math.min(r,x[a+3])-Math.max(t,x[a+1]);s>0&&(i+=o*s)}return i},w=e=>e?Math.max(-Ovt,Math.min(Ovt,e)):0,T=``,E=sJ(`arrow_point`),D=new uvt;for(let e of u)e!==f&&D.frame(e);let O=e.rels.map((e,t)=>{let n=v[t*2],r=v[t*2+1],i=vX(void 0,e.lineColor,void 0),a=i.stroke?pq(i.stroke):`var(--_l)`,o=e.type===`birel`||e.type===`rel_b`,s=e.type!==`rel_b`,c=gvt(n,r,n!==r&&y.get(r)?.has(n)===!0?Dvt:0,S?b:void 0,D,o?E:0,s?E:0);return _(Math.min(c.x0,c.x1),Math.min(c.y0,c.y1),Math.max(c.x0,c.x1),Math.max(c.y0,c.y1)),o&&S&&x.push(c.sx-rJ,c.sy-rJ,c.sx+rJ,c.sy+rJ),s&&S&&x.push(c.ex-rJ,c.ey-rJ,c.ex+rJ,c.ey+rJ),T+=`<g class="pele-edge" data-id="${mq(e.from+`-`+e.to)}"${i.line}><path d="${c.d}"/>`+(o?cJ(`arrow_point`,c.sx,c.sy,c.sdx,c.sdy,a):``)+(s?cJ(`arrow_point`,c.ex,c.ey,c.edx,c.edy,a):``)+`</g>`,c});for(let e of u){if(!S||e.headW===0)continue;let t=e.y+pX,n=e.y+e.head-tX,r=1/0;for(let i of[fX,(e.w-e.headW)/2,e.w-fX-e.headW]){let a=0;for(let r of O)ovt(r.points,e.x+i-4,t,e.x+i+e.headW+4,n)&&a++;if(a<r&&(r=a,e.headX=i),a===0)break}x.push(e.x+e.headX-4,t,e.x+e.headX+e.headW+4,n)}let k=``;e.rels.forEach((t,i)=>{let a=O[i],c=t.from+`-`+t.to,u=vX(void 0,void 0,t.textColor),d=WJ((e.c4Type===`C4Dynamic`?i+1+`: `:``)+t.label,!1,s,o,a.room),f=WJ(t.techn?`[${t.techn}]`:void 0,!1,s,o,a.room,2),p=Math.max(d.width,f.width)+8,m=d.height+f.height;if(m===0)return;let h=Math.abs(a.nx)*(p/2)+Math.abs(a.ny)*(m/2)+2,g=a.lean?Math.max(0,Math.min(a.lean,h-14)):h,v=a.nx*g+(r?0:w(t.offsetX)),y=a.ny*g+(r?0:w(t.offsetY)),b=.5;if(S){let e=1/0,t=v!==a.nx*g||y!==a.ny*g;for(let n=0;n<(t?2:1)&&e>0;n++){let t=n?a.nx*g:v,r=n?a.ny*g:y;for(let n of kvt){let i=a.x0+(a.x1-a.x0)*n+t,o=a.y0+(a.y1-a.y0)*n+r,s=C(i-p/2,o-m/2,i+p/2,o+m/2);if(s<e&&(e=s,b=n,v=t,y=r),s===0)break}}}let T=a.x0+(a.x1-a.x0)*b+v,E=a.y0+(a.y1-a.y0)*b+y-m/2;S&&x.push(T-p/2,E,T+p/2,E+m),_(T-p/2,E,T+p/2,E+m),k+=`<g class="pele-edge-label" data-id="${mq(c)}">`+(t.descr?`<title>${mq(t.descr)}</title>`:``)+`<rect x="${K(T-p/2)}" y="${K(E)}" width="${K(p)}" height="${K(m)}" rx="3" fill="var(--_bg)"/>`+yX(gq(d,T,E+d.height/2,u.text)+gq(f,T,E+d.height+f.height/2,` class="pele-c4-techn" fill="var(--_m)"${u.text}`),t.link,c,l,n)+`</g>`});let A=``,j=``;for(let e of u){if(e!==f){let t=e.boundary,r=vX(t.bgColor,t.borderColor,t.fontColor),i=e.x+e.headX,a=e.y+pX,s=$Y(e.labels[0],i,a,` class="pele-cluster-label" font-weight="var(--_hw)"${r.text}`);a+=e.labels[0].height,s+=$Y(e.labels[1],i,a,` class="pele-c4-type" font-size="${o}" fill="var(--_m)"${r.text}`),a+=e.labels[1].height,s+=$Y(e.labels[2],i,a,` class="pele-c4-descr" font-size="${o}" fill="var(--_m)"${r.text}`),A+=`<g class="pele-cluster pele-c4-${t.nodeType?`node`:`boundary`}" data-id="${mq(t.alias)}"><rect x="${K(e.x)}" y="${K(e.y)}" width="${K(e.w)}" height="${K(e.h)}" rx="${fJ}" fill="none" stroke="var(--_b)"${t.nodeType?``:` stroke-dasharray="6 4"`}${r.shape}/>`+yX(s,t.link,t.alias,l,n)+`</g>`}for(let t of e.nodes){let e=t.shape,r=e.kind.startsWith(`external`),i=vX(e.bgColor,e.borderColor,e.fontColor),a=` stroke="var(--_b)"`+(r?` stroke-dasharray="4 3"`:``),{w:s,h:c,form:u,labels:d}=t,f=u===`h-cyl`?-avt(c)/2:0,p=u===`person`?iX/2:u===`cyl`?ivt(s)/2:0,m=` fill="var(--_m)"${i.text}`,h=p-t.textH/2,g=gq(d[0],f,h+d[0].height/2,` class="pele-c4-type" font-size="${o-1}"${m}`);h+=d[0].height,g+=gq(d[1],f,h+d[1].height/2,` class="pele-label" font-weight="var(--_hw)"${i.text}`),h+=d[1].height,g+=gq(d[2],f,h+d[2].height/2,` class="pele-c4-techn" font-size="${o}"${m}`),h+=d[2].height+4,g+=gq(d[3],f,h+d[3].height/2,` class="pele-c4-descr" font-size="${o}"${i.text}`),j+=`<g class="pele-node pele-shape-${u} pele-c4-${e.kind}${r?` pele-c4-external`:``}" data-id="${mq(e.alias)}" transform="translate(${K(t.x+s/2)},${K(t.y+c/2)})">`+yX(RJ(u,s,c,` fill="var(${r?`--_bg`:`--_s`})"${a}${i.shape}`,a+i.line)+g,e.link,e.alias,l,n)+`</g>`}}let M=WJ(e.title,!1,s,a,r?KJ(n):4e3,1),N=M.height>0?M.height+12:0,P=Math.max(h-p,M.width),F=Math.ceil(P+2*c),ee=Math.ceil(g-m+N+2*c),te=c-p+(P-(h-p))/2,I=c+N-m;return[{svg:vJ(`c4`,F,ee,a,n,e,gq(M,F/2,c+M.height/2,` class="pele-title" font-weight="var(--_tw)"`)+`<g transform="translate(${K(te)},${K(I)})">`+(A?`<g class="pele-clusters">${A}</g>`:``)+(T?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${T}</g>`:``)+(j?`<g class="pele-nodes">${j}</g>`:``)+(k?`<g class="pele-edge-labels" font-size="${o}">${k}</g>`:``)+`</g>`),width:F,height:ee,links:l},D.squeezed]}var Mvt={type:`c4`,parse(e,t,n){let r=new W_t;return n&&(r.title=n),evt(e,r),r},render:jvt};function xX(e){let t=0;for(let n=e.indexOf(`~`);n!==-1;n=e.indexOf(`~`,n+1))t++;return t}function Nvt(e){let t=xX(e);if(t<=1)return e;let n=t%2!=0&&e.startsWith(`~`),r=e.split(``),i=[];for(let e=+!!n;e<r.length;e++)r[e]===`~`&&i.push(e);for(let e=0,t=i.length-1;e<t;e++,t--)r[i[e]]=`<`,r[i[t]]=`>`;return r.join(``)}function SX(e){if(!e.includes(`~`))return e;let t=e.split(/(,)/),n=[];for(let e=0;e<t.length;e++){let r=t[e];r===`,`&&e>0&&e+1<t.length&&xX(t[e-1])===1&&xX(t[e+1])===1&&(r=t[e-1]+`,`+t[e+1],e++,n.pop()),n.push(Nvt(r))}return n.join(``)}function Pvt(e){return e===`#`||e===`+`||e===`~`||e===`-`}var Fvt=class{id=``;memberType;visibility=``;classifier=``;parameters=``;returnType=``;constructor(e,t){this.memberType=t,t===`method`&&this.parseMethod(e)||this.parseAttribute(e),this.id=this.id.startsWith(` `)?` `+this.id.trim():this.id.trim()}parseMethod(e){let t=e.length;for(let n=0;n<t;){let r=n;for(;r<t&&!nq(e.charCodeAt(r));)r++;let i=r-1;for(;i>n&&e.charCodeAt(i)!==41;)i--;let a=i-1;for(;a>n&&e.charCodeAt(a)!==40;)a--;if(a>n){let r=e[n],o=Pvt(r)&&a>n+1;o&&(this.visibility=r),this.id=e.slice(o?n+1:n,a),this.parameters=e.slice(a+1,i).trim();let s=i+1,c=``;if(s<t){let t=e[s];(t===`$`||t===`*`||t.trim()===``)&&(c=t.trim(),s++)}let l=s;for(;l<t&&!nq(e.charCodeAt(l));)l++;if(this.returnType=e.slice(s,l).trim(),c===``){let e=this.returnType.slice(-1);(e===`$`||e===`*`)&&(c=e,this.returnType=this.returnType.slice(0,-1))}return this.classifier=c,!0}n=r+1}return this.memberType=`attribute`,!1}parseAttribute(e){let t=e.slice(0,1),n=e.slice(-1);Pvt(t)&&(this.visibility=t),(n===`$`||n===`*`)&&(this.classifier=n),this.id=e.substring(this.visibility===``?0:1,this.classifier===``?e.length:e.length-1)}getDisplayDetails(){let e=this.visibility+SX(this.id);return this.memberType===`method`&&(e+=`(${SX(this.parameters.trim())})`,this.returnType&&(e+=` : `+SX(this.returnType))),{displayText:e.trim(),cssStyle:this.parseClassifier()}}parseClassifier(){return this.classifier===`*`?`font-style:italic;`:this.classifier===`$`?`text-decoration:underline;`:``}},Ivt={LINE:0,DOTTED_LINE:1},CX={AGGREGATION:0,EXTENSION:1,COMPOSITION:2,DEPENDENCY:3,LOLLIPOP:4},Lvt=`classId-`;function wX(e){let t=e.indexOf(`~`);if(t<=0)return{className:e,type:``};let n=e.indexOf(`~`,t+1);return{className:e.slice(0,t),type:e.slice(t+1,n===-1?e.length:n)}}function Rvt(e){let t=e.charCodeAt(0);return wX(t>=48&&t<=57?Lvt+e:e).className}var zvt=class{type=`class`;lineType=Ivt;relationType=CX;direction=`TB`;classes=/* @__PURE__ */ new Map;relations=[];notes=/* @__PURE__ */ new Map;namespaces=/* @__PURE__ */ new Map;interfaces=[];styleClasses=/* @__PURE__ */ new Map;title;accTitle;accDescr;namespaceStack=[];withCssClass=/* @__PURE__ */ new Map;addClass(e){let{className:t,type:n}=wX(e);if(this.classes.has(t))return;let r={id:t,type:n,label:t,cssClasses:`default`,methods:[],members:[],annotations:[],styles:[]};this.classes.set(t,r),this.tag(r,`default`)}tag(e,t){let n=this.withCssClass.get(t);n?n.add(e):this.withCssClass.set(t,/* @__PURE__ */ new Set([e]))}ensure(e){return this.addClass(e),this.classes.get(wX(e).className)}setClassLabel(e,t){this.ensure(e).label=t}addRelation(e){let{type1:t,type2:n}=e.relation;t===CX.LOLLIPOP&&n===`none`?(this.addClass(e.id2),e.id1=this.addInterface(e.id1,e.id2)):n===CX.LOLLIPOP&&t===`none`?(this.addClass(e.id1),e.id2=this.addInterface(e.id2,e.id1)):(this.addClass(e.id1),this.addClass(e.id2)),e.id1=wX(e.id1).className,e.id2=wX(e.id2).className,e.relationTitle1=e.relationTitle1.trim(),e.relationTitle2=e.relationTitle2.trim(),this.relations.push(e)}addInterface(e,t){let n=`interface${this.interfaces.length}`;return this.interfaces.push({id:n,label:e,classId:t}),n}addAnnotation(e,t){this.ensure(e).annotations.push(t)}addMember(e,t){let n=this.ensure(e);if(typeof t!=`string`)return;let r=t.trim();if(r.startsWith(`<<`)&&r.endsWith(`>>`))n.annotations.push(r.substring(2,r.length-2));else if(r.indexOf(`)`)>0){let e=new Fvt(r,`method`);(e.memberType===`method`?n.methods:n.members).push(e)}else r&&n.members.push(new Fvt(r,`attribute`))}addMembers(e,t){if(Array.isArray(t)){t.reverse();for(let n of t)this.addMember(e,n)}}addNote(e,t){let n=this.notes.size,r=`note${n}`;return this.notes.set(r,{id:r,class:t,text:e,index:n}),r}cleanupLabel(e){return(e.startsWith(`:`)?e.substring(1):e).trim()}setCssClass(e,t){for(let n of e.split(`,`)){let e=this.classes.get(Rvt(n));if(e!==void 0){e.cssClasses+=` `+t;for(let n of t.split(` `))this.tag(e,n)}}}defineClass(e,t){for(let n of e){let e=this.styleClasses.get(n);if(e===void 0&&(e={id:n,styles:[],textStyles:[]},this.styleClasses.set(n,e)),!t)continue;for(let n of t)n.includes(`color`)&&e.textStyles.push(n.replace(`fill`,`bgFill`)),e.styles.push(n);let r=this.withCssClass.get(n);if(r===void 0)continue;let i=t.flatMap(e=>e.split(`,`));for(let e of r)for(let t of i)e.styles.push(t)}}setTooltip(e,t){if(t!==void 0)for(let n of e.split(`,`)){let e=this.classes.get(wX(n).className);e&&(e.tooltip=t)}}setLink(e,t,n){let r=RK(t).trim();for(let t of e.split(`,`)){let e=this.classes.get(Rvt(t));e&&(e.link=r?Sq(r):void 0,e.linkTarget=typeof n==`string`?n:`_blank`)}this.setCssClass(e,`clickable`)}setClickEvent(e,t,n){for(let t of e.split(`,`)){let e=this.classes.get(wX(t).className);e&&(e.haveCallback=!0)}this.setCssClass(e,`clickable`)}setDirection(e){this.direction=e}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,``)}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
985
|
+
`)}function HJ(e,t,n){if(t===``)return;let r=RK(t),i=e[e.length-1];i&&i.style===n&&i.icon===void 0?i.text+=r:e.push({text:r,style:n,width:0})}function Qht(e,t,n){if(!t.includes(`:fa-`)){HJ(e,t,n);return}let r=0;Wht.lastIndex=0;let i;for(;(i=Wht.exec(t))!==null;){let a=`${i[1]}:fa-${i[2]}`;if(HJ(e,t.slice(r,i.index),n),r=i.index+i[0].length,VK(a)!==``)e.push({text:``,style:n,icon:a,width:0});else if(t[r]===` `)r++;else if(r===t.length){let t=e[e.length-1];t&&t.icon===void 0&&(t.text=t.text.trimEnd())}}HJ(e,t.slice(r),n)}function $ht(e,t,n,r){let i=r,a=0,o=``,s=0,c=t.length,l=()=>{Qht(e,o,i),o=``};for(;s<c;){let e=t[s];if(e===`<`){Uht.lastIndex=s;let e=Uht.exec(t);if(e&&e.index===s){let n=e[1].toLowerCase(),a=t[s+1]===`/`,o=n===`b`||n===`strong`?1:n===`i`||n===`em`?2:0;o&&(l(),i=a?i&~o|r&o:i|o),s+=e[0].length;continue}}else if(n&&(e===`*`||e===`_`)){let n=t[s+1]===e,o=n?1:2,u=n?2:1,d=(a&o)===0,f=s>0?t[s-1]:` `,p=s+u<c?t[s+u]:` `,m=d&&p.trim()!==``&&t.indexOf(n?e+e:e,s+u)!==-1,h=!d&&f.trim()!==``,g=e===`_`&&/\w/.test(f)&&/\w/.test(p);if((m||h)&&!g){l(),a=m?a|o:a&~o,i=m?i|o:i&~o|r&o,s+=u;continue}}o+=e,s++}l()}function egt(e,t,n){let r=0;for(let i of e)i.width=i.icon===void 0?t.width(i.text,n,i.style):n*1.25,r+=i.width;return r}function tgt(e,t,n,r,i,a){let o=[],s=0,c=()=>{let e=o[o.length-1];if(e&&e.icon===void 0){let r=e.text.trimEnd();if(r!==e.text){e.text=r;let i=t.width(r,n,e.style);s+=i-e.width,e.width=i}}i.push(o),a.push(s),o=[],s=0};for(let i of e)if(i.icon!==void 0){let e=n*1.25;s>0&&s+e>r&&c(),o.push({...i,width:e}),s+=e}else for(let e of i.text.match(Yht)??[]){let a=e;s>0&&s+t.width(a.trimEnd(),n,i.style)>r&&(c(),a=a.trimStart());let l=o[o.length-1];if(l&&l.style===i.style&&l.icon===void 0){l.text+=a,l.width=t.width(l.text,n,l.style),s=0;for(let e of o)s+=e.width}else{let e=t.width(a,n,i.style);o.push({text:a,style:i.style,width:e}),s+=e}}(o.length>0||i.length===0)&&c()}function UJ(e,t,n,r,i,a=0){if(e===void 0||e===``)return Xht;let o=Math.round(r*Vht);if(!Ght.test(e)&&!e.includes(`&`)&&!e.includes(`fl`)){let t=e.trim(),s=n.width(t,r,a);if(s<=i||!(t.includes(` `)||Jht.test(t)))return{lines:[[{text:t,style:a,width:s}]],widths:[s],width:s,height:o,size:r,lineHeight:o};let c=[],l=[];tgt([{text:t,style:a,width:s}],n,r,i,c,l);let u=0;for(let e of l)e>u&&(u=e);return{lines:c,widths:l,width:u,height:c.length*o,size:r,lineHeight:o}}let s=t?Zht(e.replace(/\r\n?/g,`
|
|
986
|
+
`)).trim():e.trim(),c=[],l=[],u=0;for(let e of s.split(Hht)){let o=[];$ht(o,e.trim(),t,a);let s=egt(o,n,r);s>i?tgt(o,n,r,i,c,l):(c.push(o),l.push(s))}for(let e of l)e>u&&(u=e);return{lines:c,widths:l,width:u,height:c.length*o,size:r,lineHeight:o}}function WJ(e,t,n,r){let i=r(t,!1),a=e.maxWidth;if(a===void 0||!(a>0)||i.width<=a)return i;let o=Math.min(n,t),s=t;i=r(s,!0);for(let e=0;e<3&&i.width>a&&s>o;e++)s=Math.max(o,s-(i.width-a)),i=r(s,!0);return i}function GJ(e){let t=e.maxWidth;return t!==void 0&&t>0?Math.max(80,t-2*(e.padding??8)):4e3}function KJ(e,t,n,r=0){let i=e.maxWidth;return i===void 0||!(i>0)?t:Math.max(Math.min(n,t),Math.min(t,i-r))}var ngt=640;function qJ(e,t){let n=t(!1),r=e.maxWidth;if(e.autoDirection===!1||r===void 0||!(r>0)||n.width<=r)return n;let i=e.directionBreakpoint;if(r>=(i!==void 0&&i>0?i:ngt))return n;let a=t(!0);return a.width<n.width?a:n}function JJ(e){return e===`LR`||e===`RL`}function YJ(e,t){let n=t(!1),r=e.maxWidth;if(r===void 0||!(r>0)||n.width<=r)return n;let i=t(!0);return i.width<n.width?i:n}var XJ=/* @__PURE__ */ new Map([[`tool`,0],[`task`,1],[`decision`,2],[`input`,3],[`refdoc`,4],[`connector`,5],[`action`,6]]),rgt=XJ.size,igt=e=>Math.max(1,e-rgt),agt=(e,t)=>{let n=rgt+e%igt(t);return t>0?n%t:n};function ogt(e,t,n,r){let i=n.size;for(let a of e){if(a.isGroup||a.shape===`collapsedGroup`){a.colorIndex=agt(n.get(a.id)??i++,r);continue}let e=t(a.id);e&&XJ.has(e)&&(a.kind=e)}}function sgt(e,t,n){let r=[],i=[],a=e.subgraphs,o=t=>{let n=[];for(let r of t){let t=e.classes.get(r);t?.styles&&(n=[...n,...t.styles].map(e=>e.trim())),t?.textStyles&&(n=[...n,...t.textStyles].map(e=>e.trim()))}return n},s=/* @__PURE__ */ new Set,c=/* @__PURE__ */ new Map,l=/* @__PURE__ */ new Set;for(let t of a){if(t.metadata?.view!==`collapsed`||s.has(t.id))continue;let n=[t.id];for(;n.length>0;){let r=e.subgraph(n.pop())?.nodes;if(r!==void 0)for(let e of r)e===t.id||s.has(e)||(s.add(e),c.set(e,t.id),l.has(e)||n.push(e))}l.add(t.id)}let u=/* @__PURE__ */ new Map;for(let e of s){let t=[e],n=c.get(e);for(;;){let e=u.get(n),r=e??c.get(n);if(r===void 0||(e===void 0&&t.push(n),n=r,e!==void 0))break}for(let e of t)u.set(e,n)}let d=/* @__PURE__ */ new Map;a.forEach((e,t)=>d.set(e.id,t));let f=/* @__PURE__ */ new Map,p=(e,t,n)=>{let r=d.get(e);if(r===void 0||r<n)return!1;let i=t;for(let t=0;i!==void 0&&t<=a.length;t++){if(i===e)return!0;i=f.get(i)}return!1};for(let t=a.length-1;t>=0;t--){let n=a[t];if(!s.has(n.id))for(let r of n.nodes)p(r,n.id,t)?e.emitWarning(`CONTAINMENT_VIOLATION`,`Container "${n.id}" cannot contain "${r}" because "${r}" already contains it. The nesting that would close the loop is dropped.`,{nodeId:r}):f.set(r,n.id)}let m=/* @__PURE__ */ new Map;for(let e=a.length-1;e>=0;e--){let t=a[e];if(s.has(t.id))continue;let n=t.metadata?.view===`collapsed`,i={id:t.id,label:t.title,labelType:t.labelType,parentId:f.get(t.id),cssStyles:[],cssCompiledStyles:o(t.classes),cssClasses:t.classes.join(` `),shape:n?`collapsedGroup`:`flowGroup`,dir:t.dir,isGroup:!n,metadata:n?{...t.metadata,containerType:t.type}:t.metadata};r.push(i),m.set(t.id,i)}for(let t of e.nodes.values()){if(s.has(t.id))continue;let n=m.get(t.id);if(n){n.cssStyles=t.styles,n.cssCompiledStyles=o(t.classes),n.cssClasses=t.classes.join(` `);continue}let i=kq(t.type),a={id:t.id,label:t.text,labelType:t.labelType,parentId:f.get(t.id),cssStyles:t.styles,cssCompiledStyles:o([`default`,`node`,...t.classes]),cssClasses:`default `+t.classes.join(` `),dir:t.dir,link:t.link,linkTarget:t.linkTarget,tooltip:e.tooltips.get(t.id),metadata:t.metadata,isGroup:!1,shape:i===`square`||i===void 0?`squareRect`:i};r.push(a),m.set(t.id,a)}e.edges.forEach((t,r)=>{let a=u.get(t.start)??t.start,s=u.get(t.end)??t.end;if(a===s&&t.start!==t.end)return;let c=[...e.defaultEdgeStyle??[]];t.style&&c.push(...t.style);let l=t.type===`arrow_open`?`none`:t.type===`arrow_cross`||t.type===`arrow_point`?t.type:`arrow_point`;i.push({id:t.id||`L_${a}_${s}_${r}`,isUserDefinedId:t.isUserDefinedId,start:a,end:s,type:t.type??`normal`,label:t.text,labelType:t.labelType,thickness:t.stroke,pattern:t.stroke,minlen:t.length,classes:`edge-thickness-normal edge-pattern-solid flowchart-link`,arrowTypeStart:`none`,arrowTypeEnd:l,cssCompiledStyles:o(t.classes),style:c,animate:t.animate,animation:t.animation,curve:t.interpolate||e.defaultInterpolate||n,metadata:t.metadata})}),Qpt(r,e);let h=/* @__PURE__ */ new Map;for(let e of a){let t=f.get(e.id);if(t===void 0)continue;let n=h.get(t);n?n.push(e.id):h.set(t,[e.id])}let g=/* @__PURE__ */ new Map;for(let e of a){if(f.get(e.id)!==void 0)continue;let t=[e.id];for(;t.length>0;){let e=t.pop();if(g.has(e))continue;g.set(e,g.size);let n=h.get(e);if(n)for(let e=n.length-1;e>=0;e--)t.push(n[e])}}return ogt(r,t=>{if(e.connectors.has(t))return`connector`;let n=e.nodes.get(t);return n?e.vertexKind(n):void 0},g,t),{nodes:r,edges:i}}var cgt=8,lgt=40,ugt=16,dgt=48,ZJ=20,QJ=26,$J=14,fgt=`collapsed`,pgt={TB:2,RL:3,BT:0,LR:1},mgt=/* @__PURE__ */ new WeakMap;function hgt(e,t){let n=mgt.get(e);if(n===void 0){let r=t.flowchart?.curve;n=sgt(e,cgt,typeof r==`string`?r:void 0),mgt.set(e,n)}return n}function eY(e,t,n){let r=e.agentflow?.[t];return typeof r==`number`&&r>0?Math.min(r,2e3):n}var ggt=/[";]fill:/;function tY(e,t,n){let r=hJ(e);return` fill="${r}"${ggt.test(n.shape)?``:` fill-opacity="${t}"`} stroke="${r}"`}function _gt(e,t,n){return JJ(e.direction)?qJ(n,r=>vgt(e,t,n,r)):vgt(e,t,n,!1)}function vgt(e,t,n,r){let i=hgt(e,t),a=n.fontSize??16,o=Math.round(a*.875),s=n.measurer??fq(n.fontFamily),c=eY(t,`wrappingWidth`,120),l=eY(t,`minNodeWidth`,120),u=n.padding??8,d=n.icons,f=/* @__PURE__ */ new Map,p=[],m=[];i.nodes.forEach((e,t)=>f.set(e.id,t));for(let e of i.nodes){let t=pJ(e.cssStyles.length>0?e.cssCompiledStyles.concat(e.cssStyles):e.cssCompiledStyles),n=+!!t.bold|(t.italic?2:0),r=e.labelType===`markdown`,i=t.fontSize??a,o,u;if(e.isGroup){let a=UJ(e.label,r,s,i,4e3,n);o={node:e,style:t,label:a,shape:`group`,w:0,h:0,dy:0,loops:0},u=Qq(0,0),u.isGroup=!0,u.dir=e.dir?Xq(e.dir):void 0,u.padX=ZJ,u.padTop=a.height>0?a.height+16:ZJ,u.padBottom=ZJ,u.minW=a.width+2*ZJ-12}else if(e.shape===`collapsedGroup`){let a=UJ(e.label,r,s,i,c,n),d=Math.max(a.width,l)+2*vJ,f=a.height+2*yJ+$J;o={node:e,style:t,label:a,shape:fgt,w:d,h:f,dy:-$J/2,loops:0},u=Qq(d,f)}else{let a=qpt(e.shape),d=UJ(e.label,r,s,i,c,n),f=IJ(a,a===`diam`?d.width:Math.max(d.width,l),d.height);o={node:e,style:t,label:d,shape:a,w:f.w,h:f.h,dy:f.dy,loops:0},u=Qq(f.w,f.h)}u.seq=p.length,p.push(o),m.push(u)}i.nodes.forEach((e,t)=>{m[t].parent=e.parentId===void 0?-1:f.get(e.parentId)??-1});let h=r?`TB`:Xq(e.direction),g=e=>{let t;for(let n=m[e].parent,r=0;n>=0&&t===void 0&&r<1e4;n=m[n].parent,r++)t=m[n].dir;return t??h},_=e=>{let t=g(e);return t===`LR`||t===`RL`},v=new Int32Array(m.length).fill(-1);for(let e=0;e<m.length;e++){let t=[],n=e;for(;n>=0&&v[n]<0&&t.length<=m.length;)t.push(n),n=m[n].parent;let r=n>=0?v[n]+1:0;for(let e=t.length-1;e>=0;e--)v[t[e]]=r++}let y=(e,t)=>{let n=t;for(let r=v[t];r>v[e];r--)n=m[n].parent;return n===e&&t!==e},b=[],x=[],S=[],C=[];for(let e of i.edges){let t=f.get(e.start),n=f.get(e.end);if(t===void 0||n===void 0)continue;let r=UJ(e.label,e.labelType===`markdown`,s,o,c);y(t,n)||y(n,t)?C.push({edge:e,label:r,src:t,dst:n}):(t===n&&(p[t].loops++,_(t)?m[t].h+=2*(QJ+(r.height>0?r.height+8:0)):m[t].w+=2*(QJ+(r.width>0?r.width+12:0))),S.push(e),x.push(r),b.push({src:t,dst:n,minlen:e.minlen??1,labelW:r.width>0?r.width+12:0,labelH:r.height>0?r.height+4:0,route:[],labelX:0,labelY:0}))}let w=eJ(m,b,h,{nodeSep:eY(t,`nodeSpacing`,lgt),edgeSep:ugt,rankSep:eY(t,`rankSpacing`,dgt),portSep:20}),T=UJ(e.title,!1,s,a,4e3,1),E=T.height>0?T.height+12:0,D=Math.max(w.width,T.width);Zq(m,b,u+(D-w.width)/2,u+E);let O=Math.ceil(D+2*u),k=Math.ceil(w.height+E+2*u),A=[],j=[],M=[],N=[],P=C.length*m.length<2e6;for(let{edge:e,src:t,dst:n}of C){let r=y(n,t),i=r?n:t,a=r?t:n,o=m[i],s=m[a],c=pgt[o.dir??g(i)],l=r?c:c+2&3,u=e=>{let t=!(e&1),n=e===0||e===3?-1:1,i=t?s.x:s.x+n*s.w/2,a=t?s.y+n*s.h/2:s.y,c=t?s.x:o.x+n*o.w/2,l=t?o.y+n*o.h/2:s.y,u=+!t;return r?[i,a,u,c,l,u]:[c,l,u,i,a,u]},d=e=>{for(let t=0;t<m.length;t++){let n=m[t];if(t!==a&&!n.isGroup&&n.x+n.w/2>Math.min(e[0],e[3])-1&&n.x-n.w/2<Math.max(e[0],e[3])+1&&n.y+n.h/2>Math.min(e[1],e[4])-1&&n.y-n.h/2<Math.max(e[1],e[4])+1)return!0}return!1},f=u(l);if(P&&d(f))for(let e of[l+1&3,l+3&3,l+2&3]){let t=u(e);if(!d(t)){f=t;break}}N.push(f),M.push((f[0]+f[3])/2,(f[1]+f[4])/2);let h=f.slice();BJ(h,r?0:3,p[a],s),j.push(oJ(h,`linear`,0,sJ(e.arrowTypeEnd)))}let F=/* @__PURE__ */ new Map,ee=!1;for(let e of m)e.isGroup&&(ee=!0);if(ee){for(let e of b)tJ(F,e.route);for(let e of N)tJ(F,e)}let te=``,I=``;for(let e=0;e<p.length;e++){let t=p[e],r=m[e],i=t.node,a=r.x,o=r.y,s=mJ(i.cssClasses.replace(/^default\s?/,``)),c=mq(i.id);if(r.isGroup){let e=nJ(r,t.label.width,F,ZJ);te+=`<g class="pele-cluster pele-flow${s}" data-id="${c}"><rect x="${K(a-r.w/2)}" y="${K(o-r.h/2)}" width="${K(r.w)}" height="${K(r.h)}" rx="${dJ}"${tY(i.colorIndex??XJ.size,`0.06`,t.style)}${t.style.shape}/>`+gq(t.label,e,o-r.h/2+8+t.label.height/2,` class="pele-cluster-label" fill="var(--_m)"${t.style.text}`,d)+`</g>`;continue}let l=t.w,u=t.h,f=``,h;if(t.shape===fgt){let e=hJ(i.colorIndex??XJ.size),n=u/2-$J-2,r=n+($J+2)/2;h=`<rect x="${K(-l/2)}" y="${K(-u/2)}" width="${K(l)}" height="${K(u)}" rx="${dJ}"${tY(i.colorIndex??XJ.size,`0.06`,t.style)}${t.style.shape}/><path d="M${K(-l/2+10)},${K(n)}H${K(l/2-10)}" fill="none" stroke="${e}" stroke-dasharray="3 3"${t.style.line}/><path class="pele-collapsed-mark" d="${nY(-9,r)}${nY(0,r)}${nY(9,r)}" fill="${e}" stroke="none"/>`}else{let e=XJ.get(i.kind??`task`)??1;f=` pele-kind-${i.kind??`task`}`,h=LJ(t.shape,l,u,tY(e,`0.14`,t.style)+t.style.shape,` stroke="${hJ(e)}"`+t.style.line)}let g=gq(t.label,0,t.dy,` class="pele-label"${t.style.text}`,d);if(/ internal-link(?: |$)/.test(s+` `)&&i.label&&n.links!==!1){let e=RK(i.label),t=wq(Sq(e),n)!==void 0,r=pq(e);g=`<a class="internal-link"${t?` href="${r}"${Eq(n)}`:``} data-href="${r}">${g}</a>`,A.push({id:i.id,href:e,internal:!0})}let _=h+g;i.tooltip&&(_=`<title>${mq(i.tooltip)}</title>`+_),i.link&&(_=Tq(_,i.link,i.id,A,n,i.linkTarget?` target="${pq(i.linkTarget)}"`:``)),I+=`<g class="pele-node pele-shape-${t.shape}${f}${s}" data-id="${c}" transform="translate(${K(a)},${K(o)})">${_}</g>`}let ne=``,re=``,ie=(e,t,n,r,i)=>{let a=e.style.length>0||e.cssCompiledStyles.length>0?pJ(e.cssCompiledStyles.concat(e.style)):void 0,o=e.arrowTypeEnd,s=a?.stroke?pq(a.stroke):`var(--_l)`,c=e.thickness===`dotted`?`reference`:o===`arrow_cross`?`failure`:`sequence`,l=mJ(e.classes.replace(/edge-thickness-normal|edge-pattern-solid|flowchart-link/g,``));ne+=`<g class="pele-edge pele-edge-${c}${l}" data-id="${mq(e.id)}"${a?.line??``}><path d="${n.d}"${e.thickness===`dotted`?` stroke-dasharray="3 4"`:``}/>`+cJ(o,n.ex,n.ey,n.edx,n.edy,s)+`</g>`,t.width>0&&(re+=lJ(e.id,t,r,i,a?.text??``,d))},ae=/* @__PURE__ */ new Map;for(let e=0;e<b.length;e++){let t=b[e],n=S[e],r=x[e],i=n.arrowTypeEnd,a;if(t.src===t.dst){let e=p[t.src],n=ae.get(t.src)??0;ae.set(t.src,n+1),a=bht(m[t.src],e.w,e.h,n,_(t.src),QJ,sJ(i),t)}else{let e=t.route.slice();BJ(e,0,p[t.src],m[t.src]),BJ(e,e.length-3,p[t.dst],m[t.dst]),a=oJ(e,n.curve,0,sJ(i))}ie(n,r,a,t.labelX,t.labelY)}return C.forEach((e,t)=>ie(e.edge,e.label,j[t],M[2*t],M[2*t+1])),{svg:_J(`agentflow`,O,k,a,n,e,gq(T,O/2,u+T.height/2,` class="pele-title" font-weight="var(--_tw)"`)+(te?`<g class="pele-clusters">${te}</g>`:``)+(ne?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${ne}</g>`:``)+(re?`<g class="pele-edge-labels" font-size="${o}">${re}</g>`:``)+`<g class="pele-nodes">${I}</g>`),width:O,height:k,links:A}}function nY(e,t){return`M${K(e-1.75)},${K(t)}a1.75,1.75 0 1 0 3.5,0a1.75,1.75 0 1 0 -3.5,0Z`}var ygt={type:`agentflow`,keepComments:!0,parse(e,t,n,r,i){let a=new umt({inheritDir:(t.flowchart??{}).inheritDir===!0,direction:typeof t.direction==`string`?t.direction:void 0,lineOffset:r,maxEdges:i.maxEdges});return n&&(a.title=n),jmt(e,a),hgt(a,t),a},render:_gt};function rY(e){throw new NK(e,`semantic`,{type:`architecture`})}var bgt=class{type=`architecture`;title;accTitle;accDescr;nodes=/* @__PURE__ */ new Map;groups=/* @__PURE__ */ new Map;edges=[];layoutHints=[];registered=/* @__PURE__ */ new Map;register(e,t,n){this.registered.has(t)&&rY(`The ${e} id [${t}] is already in use by another ${this.registered.get(t)}`),n!==void 0&&(t===n&&rY(`The ${e} [${t}] cannot be placed within itself`),this.registered.has(n)||rY(`The ${e} [${t}]'s parent does not exist. Please make sure the parent is created before this ${e}`),this.registered.get(n)===`node`&&rY(`The ${e} [${t}]'s parent is not a group`)),this.registered.set(t,e===`group`?`group`:`node`)}addService({id:e,icon:t,iconText:n,title:r,in:i}){this.register(`service`,e,i),this.nodes.set(e,{id:e,type:`service`,icon:t,iconText:n,title:r,in:i})}addJunction({id:e,in:t}){this.register(`junction`,e,t),this.nodes.set(e,{id:e,type:`junction`,in:t})}addGroup({id:e,icon:t,title:n,in:r}){this.register(`group`,e,r),this.groups.set(e,{id:e,icon:t,title:n,in:r})}addEdge({lhsId:e,rhsId:t,lhsDir:n,rhsDir:r,lhsInto:i,rhsInto:a,lhsGroup:o,rhsGroup:s,title:c}){let l=[[`left`,e,o],[`right`,t,s]];for(let[e,t]of l)this.registered.has(t)||rY(`The ${e}-hand id [${t}] does not yet exist. Please create the service/group before declaring an edge to it.`);for(let[e,t]of l)this.nodes.has(t)||rY(`The ${e}-hand id [${t}] is a group. Add {group} to a service inside it instead.`);let u=this.nodes.get(e).in;if(u!==void 0&&u===this.nodes.get(t).in)for(let[e,t,n]of l)n&&rY(`The ${e}-hand id [${t}] is modified to traverse the group boundary, but the edge does not pass through two groups.`);this.edges.push({lhsId:e,lhsDir:n,lhsInto:i,lhsGroup:o,rhsId:t,rhsDir:r,rhsInto:a,rhsGroup:s,title:c})}addLayoutHint(e){e.members.length<2&&rY(`An align directive requires at least two members; got ${e.members.length}`);let t=/* @__PURE__ */ new Set;for(let n of e.members)this.registered.get(n)!==`node`&&rY(`align ${e.direction} references [${n}], which is not a service or junction`),t.has(n)&&rY(`align ${e.direction} lists [${n}] more than once`),t.add(n);this.layoutHints.push(e)}};function xgt(e,t){e.accDescr&&(t.accDescr=e.accDescr.replace(/\n\s+/g,`
|
|
987
|
+
`)),e.accTitle&&(t.accTitle=e.accTitle.replace(/^\s+/g,``)),e.title&&(t.title=e.title);for(let n of e.groups)t.addGroup(n);for(let n of e.services)t.addService(n);for(let n of e.junctions)t.addJunction(n);for(let n of e.edges)t.addEdge(n);for(let n of e.alignments)t.addLayoutHint({direction:n.direction,members:[...n.members]})}var Sgt=/* @__PURE__ */ new WeakMap;function Cgt(e){let t=e.map((e,t)=>t),n=[];for(let r=0;r<128;r++){let i=String.fromCharCode(r);n.push(t.filter(t=>{let{pattern:n,first:r}=e[t];return typeof n==`string`?n[0]===i:r===void 0||r.includes(i)}))}let r={starting:n,every:t,longer:e.map(t=>t.longer?.map(t=>e.indexOf(t)))};return Sgt.set(e,r),r}function iY(e,t,n){let r=[],i=[],a=[],o=new Uint8Array(t.length),{starting:s,every:c,longer:l}=Sgt.get(t)??Cgt(t),u=[],d=e.length,f=(n,r)=>{if(o[n])return-1;let i=t[n];if(i.match!==void 0)return i.match(e,r);if(i.scanner!==void 0)return(u[n]??=i.scanner())(e,r);let a=i.pattern;return typeof a==`string`?e.startsWith(a,r)?r+a.length:-1:(a.lastIndex=r,a.test(e)?a.lastIndex:(i.opener!==void 0&&(i.opener.lastIndex=r,i.opener.test(e)&&(o[n]=1)),-1))},p=0;e:for(;p<d;){let o=e.charCodeAt(p);for(let e of o<128?s[o]:c){let n=f(e,p);if(n<=p)continue;let o=e,s=l[e];if(s!==void 0)for(let e of s){let t=f(e,p);if(t>n){o=e,n=t;break}}t[o].hidden||(r.push(o),i.push(p),a.push(n)),p=n;continue e}throw FK(n,e,p,``,!0)}return r.push(-1),i.push(d),a.push(d),{kinds:r,starts:i,ends:a,src:e}}var aY={name:`ACC_DESCR`,pattern:/[\t ]*accDescr(?:[\t ]*:([^\n\r]*?(?=%%)|[^\n\r]*)|\s*{([^}]*)})/y,first:` a`},oY={name:`ACC_TITLE`,pattern:/[\t ]*accTitle[\t ]*:(?:[^\n\r]*?(?=%%)|[^\n\r]*)/y,first:` a`},sY={name:`TITLE`,pattern:/[\t ]*title(?:[\t ][^\n\r]*?(?=%%)|[\t ][^\n\r]*|)/y,first:` t`},cY={name:`STRING`,pattern:/"([^"\\]|\\.)*"|'([^'\\]|\\.)*'/y,first:`"'`},lY={name:`NEWLINE`,pattern:/\r?\n/y,first:`\r
|
|
988
|
+
`},uY={name:`WHITESPACE`,pattern:/[\t ]+/y,hidden:!0,first:` `},dY={name:`YAML`,pattern:/---[\t ]*\r?\n(?:[\S\s]*?\r?\n)?---(?:\r?\n|(?!\S))/y,hidden:!0,opener:/---[\t ]*\r?\n/y,first:`-`},fY={name:`DIRECTIVE`,pattern:/[\t ]*%%{[\S\s]*?}%%(?:\r?\n|(?!\S))/y,hidden:!0,opener:/[\t ]*%%{/y,first:` %`},pY={name:`SINGLE_LINE_COMMENT`,pattern:/[\t ]*%%[^\n\r]*/y,first:` %`,hidden:!0};function mY(e){return{name:e,pattern:RegExp(e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)+`(?:(?=%%)|(?!\\S))`,`y`),first:e[0]}}var wgt=/accDescr(?:[\t ]*:([^\n\r]*)|\s*{([^}]*)})/,Tgt=/accTitle[\t ]*:([^\n\r]*)/,Egt=/title([\t ][^\n\r]*|)/;function hY(e){return e.trim().replace(/[\t ]{2,}/gm,` `)}function gY(e){return hY(Egt.exec(e)[1])}function _Y(e){return hY(Tgt.exec(e)[1])}function vY(e){let t=wgt.exec(e);return t[1]===void 0?t[2].replace(/^\s*/gm,``).replace(/\s+$/gm,``).replace(/[\t ]{2,}/gm,` `).replace(/[\n\r]{2,}/gm,`
|
|
989
|
+
`):hY(t[1])}var Dgt=/* @__PURE__ */ new Map([[`b`,`\b`],[`f`,`\f`],[`n`,`
|
|
990
|
+
`],[`r`,`\r`],[`t`,` `],[`v`,`\v`],[`0`,`\0`]]);function yY(e){if(!e.includes(`\\`))return e.slice(1,-1);let t=``;for(let n=1;n<e.length-1;n++){let r=e[n];if(r===`\\`){let r=e[++n];t+=Dgt.get(r)??r}else t+=r}return t}var bY=class{constructor(e,t,n){this.tokens=e,this.types=t,this.diagram=n,this.kinds=e.kinds}tokens;types;diagram;i=0;kinds;get kind(){return this.kinds[this.i]}text(e=this.i){return this.tokens.src.slice(this.tokens.starts[e],this.tokens.ends[e])}take(){return this.text(this.i++)}accept(e){return this.kinds[this.i]===e&&(this.i++,!0)}expect(e){return this.kinds[this.i]!==e&&this.fail(`token of type '${this.types[e].name}'`),this.take()}fail(e){let t=this.kind===-1?`end of input`:`\`${this.text()}\``;throw FK(this.diagram,this.tokens.src,this.tokens.starts[this.i],`Expecting ${e} but found ${t}.`)}},Ogt={name:`ID`,pattern:/[\w]([-\w]*\w)?/y};function xY(e){return{name:e,pattern:e,longer:[Ogt]}}var kgt=[xY(`architecture-beta`),xY(`junction`),xY(`service`),xY(`column`),xY(`group`),xY(`align`),xY(`row`),{name:`--`,pattern:`--`,longer:[dY]},xY(`in`),{name:`:`,pattern:`:`},{name:`-`,pattern:`-`,longer:[dY]},{name:`ARROW_DIRECTION`,pattern:/L|R|T|B/y},{name:`ARROW_GROUP`,pattern:/\{group\}/y},{name:`ARROW_INTO`,pattern:/<|>/y},aY,oY,sY,cY,Ogt,lY,uY,dY,fY,pY,{name:`ARCH_ICON`,pattern:/\([\w-:]+\)/y},{name:`ARCH_TITLE`,pattern:/\[(?:"([^"\\]|\\.)*"|'([^'\\]|\\.)*'|[^\[\]\r\n]+)\]/y}];function SY(e){let t=e.slice(1,-1).trim();return(t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`))&&(t=t.slice(1,-1).replace(/\\"/g,`"`).replace(/\\'/g,`'`)),t.trim()}function Agt(e){let t=new bY(iY(e,kgt,`architecture`),kgt,`architecture`),n={$type:`Architecture`,groups:[],services:[],junctions:[],edges:[],alignments:[]},r=e=>t.kinds[t.i]===e,i=()=>{if(t.kind!==-1)for(t.kind!==19&&t.fail(`a line break or the end of input`);t.kind===19;)t.i++};for(;t.kind===19;)t.i++;for(t.expect(0);t.kind!==-1;){switch(t.kind){case 19:t.i++;continue;case 14:n.accDescr=vY(t.take());break;case 15:n.accTitle=_Y(t.take());break;case 16:n.title=gY(t.take());break;case 4:{t.i++;let e={$type:`Group`,id:t.expect(18)};r(24)&&(e.icon=t.take().slice(1,-1)),r(25)&&(e.title=SY(t.take())),t.accept(8)&&(e.in=t.expect(18)),n.groups.push(e);break}case 2:{t.i++;let e={$type:`Service`,id:t.expect(18)};r(17)?e.iconText=yY(t.take()):r(24)&&(e.icon=t.take().slice(1,-1)),r(25)&&(e.title=SY(t.take())),t.accept(8)&&(e.in=t.expect(18)),n.services.push(e);break}case 1:{t.i++;let e={$type:`Junction`,id:t.expect(18)};t.accept(8)&&(e.in=t.expect(18)),n.junctions.push(e);break}case 18:{let e=t.take(),i=t.accept(12);t.expect(9);let a=t.expect(11),o=t.accept(13),s;t.accept(7)||(r(10)||t.fail(`'--' or '-'`),t.i++,s=SY(t.expect(25)),t.expect(10));let c=t.accept(13),l=t.expect(11);t.expect(9);let u=t.expect(18),d=t.accept(12);n.edges.push({$type:`Edge`,lhsId:e,lhsGroup:i,lhsDir:a,lhsInto:o,title:s,rhsInto:c,rhsDir:l,rhsId:u,rhsGroup:d});break}case 5:{t.i++,!r(6)&&!r(3)&&t.fail(`'row' or 'column'`);let e=t.take(),i=[t.expect(18),t.expect(18)];for(;r(18);)i.push(t.take());n.alignments.push({$type:`Alignment`,direction:e,members:i});break}default:t.fail(`a group, a service, a junction, an edge, an alignment, a title, or a line break`)}i()}return n}var jgt=/* @__PURE__ */ 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`]]);function Mgt(e){let t=jgt.get(e);return t===void 0?``:`<path d="${t}" stroke="var(--_fg)" stroke-width="1.5"/>`}var CY=[-1,1,0,0],wY=[0,0,-1,1];function TY(e){return e===`L`?0:e===`R`?1:e===`T`?2:3}var Ngt=64,EY=2**25,Pgt=2**26;function Fgt(e,t,n,r){let i=e.length,a=t.length,o=a,s=/* @__PURE__ */ new Map,c=/* @__PURE__ */ new Map,l=new Int32Array(i+a).fill(o),u=new Int32Array(a+1),d=[];for(let e=0;e<=a;e++)d.push([]);t.forEach((e,t)=>{c.set(e.id,t);let n=e.in===void 0?void 0:c.get(e.in);n!==void 0&&n!==t?(l[i+t]=n,u[t]=u[n]+1):u[t]=1}),e.forEach((e,t)=>{s.set(e.id,t);let n=e.in===void 0?void 0:c.get(e.in);n!==void 0&&(l[t]=n),d[l[t]].push(t)});for(let e=0;e<a;e++)d[l[i+e]].push(i+e);let f=[],p=[],m=[],h=[],g=[],_=[],v=Array(i+a),y=Array(i+a),b=(e,t,n,r,a)=>{if(e===t)return;let o=e,s=t,c=l[e],d=l[t];for(;c!==d;)u[c]>=u[d]?(o=i+c,c=l[o]):(s=i+d,d=l[s]);let v=f.length;f.push(e),p.push(t),m.push(n),h.push(r),g.push(o),_.push(s),(a[o]??=[]).push(v),(a[s]??=[]).push(v)};for(let e of r){let t=e.direction===`row`;for(let n=1;n<e.members.length;n++){let r=s.get(e.members[n-1]),i=s.get(e.members[n]);r!==void 0&&i!==void 0&&b(r,i,t?1:3,t?0:2,v)}}for(let e of[!1,!0])for(let t of n){if(t.lhsDir===t.rhsDir!==e)continue;let n=s.get(t.lhsId),r=s.get(t.rhsId);n!==void 0&&r!==void 0&&b(n,r,TY(t.lhsDir),TY(t.rhsDir),y)}let x=new Int32Array(i+a),S=new Int32Array(i+a),C=new Int32Array(i+a).fill(1),w=new Int32Array(i+a).fill(1),T=new Uint8Array(i+a),E=[],D=/* @__PURE__ */ new Map,O=[],k=/* @__PURE__ */ new Map,A=0,j=0,M=0,N=(e,t)=>{j=0,M=0;for(let n=e;n!==t;n=i+l[n])j+=x[n],M+=S[n]},P=(e,t,n)=>{if(x[e]=t,S[e]=n,T[e]=1,E.push(e),C[e]*w[e]>Ngt)O.push(e);else for(let r=n;r<n+w[e];r++)for(let n=t;n<t+C[e];n++)D.set((n+EY)*Pgt+r+EY,e)},F=(e,t,n,r,i)=>x[e]<t+r&&t<x[e]+C[e]&&S[e]<n+i&&n<S[e]+w[e],ee=(e,t,n,r)=>{if(n*r>Ngt){for(let i=A;i<E.length;i++)if(F(E[i],e,t,n,r))return E[i];return-1}for(let i=t;i<t+r;i++)for(let t=e;t<e+n;t++){let e=D.get((t+EY)*Pgt+i+EY);if(e!==void 0)return e}for(let i of O)if(F(i,e,t,n,r))return i;return-1},te=(e,t,n,r,i,a)=>{let o=`${e},${t},${n},${r},${i},${a}`,s=k.get(o)??0;for(;;){let o=ee(e+s*i,t+s*a,n,r);if(o<0)break;s=i>0?x[o]+C[o]-e:i<0?e+n-x[o]:a>0?S[o]+w[o]-t:t+r-S[o]}return k.set(o,s),s},I=(e,t)=>{let n=g[t]===e,r=n?_[t]:g[t];if(T[r])return;let i=n?m[t]:h[t],a=n?h[t]:m[t];N(n?f[t]:p[t],e);let o=j,s=M;N(n?p[t]:f[t],r);let c=CY[i],l=wY[i],u=0,d=0,v=CY[i]+CY[a]===0&&wY[i]+wY[a]===0;i===a?(c=+(CY[i]===0),l=1-c):v||(u=-CY[a],d=-wY[a]);let b,E;if(c===0?(E=l>0?S[e]+w[e]:S[e]-w[r],b=x[e]+o+u-j):(b=c>0?x[e]+C[e]:x[e]-C[r],E=S[e]+s+d-M),v){let e=y[r];if(e!==void 0&&e.length>1){let t=[];for(let n of e){let e=_[n]===r,o=e?g[n]:_[n];if(!T[o]||(e?m[n]:h[n])!==i||(e?h[n]:m[n])!==a)continue;N(e?f[n]:p[n],o);let s=c===0?x[o]+j:S[o]+M;N(e?p[n]:f[n],r),t.push(s-(c===0?j:M))}t.length>1&&(t.sort((e,t)=>e-t),c===0?b=t[t.length-1>>1]:E=t[t.length-1>>1])}let t=+(c===0),n=1-t,o=te(b,E,C[r],w[r],t,n),s=o===0?0:te(b,E,C[r],w[r],-t,-n),l=o<=s?o:-s;b+=t*l,E+=n*l}else{let e=te(b,E,C[r],w[r],c,l);b+=c*e,E+=l*e}P(r,b,E)},ne=e=>{let t=d[e];if(t.length===0)return;E.length=0;let n=[];for(let e of t){if(T[e])continue;A=E.length,n.push(A),D.clear(),O.length=0,k.clear(),P(e,0,0);let t=A,r=A,i=0;for(;;){if(t<E.length){let e=E[t++],n=v[e];if(n!==void 0)for(let t of n)I(e,t);continue}if(r>=E.length)break;let e=y[E[r]];e===void 0||i>=e.length?(r++,i=0):I(E[r],e[i++])}}n.push(E.length);let r=n.length-1,o=Array(r),s=Array(r),c=Array(r),l=Array(r),u=0,f=0;for(let e=0;e<r;e++){let t=1/0,r=1/0,i=-1/0,a=-1/0;for(let o=n[e];o<n[e+1];o++){let e=E[o];t=Math.min(t,x[e]),r=Math.min(r,S[e]),i=Math.max(i,x[e]+C[e]),a=Math.max(a,S[e]+w[e])}o[e]=t,s[e]=r,c[e]=i-t,l[e]=a-r,u+=c[e]*l[e],f=Math.max(f,c[e])}let p=Math.max(f,Math.ceil(Math.sqrt(u*2))),m=0,h=0,g=0,_=0;for(let e=0;e<r;e++){m>0&&m+c[e]>p&&(h+=g,m=0,g=0);for(let t=n[e];t<n[e+1];t++)x[E[t]]+=m-o[e],S[E[t]]+=h-s[e];m+=c[e],g=Math.max(g,l[e]),_=Math.max(_,m)}e<a&&(C[i+e]=_,w[i+e]=h+g)};for(let e=a-1;e>=0;e--)ne(e);ne(o);let re=new Int32Array(a),ie=new Int32Array(a),ae=new Int32Array(a),L=new Uint8Array(a);for(let e=0;e<a;e++){let t=l[i+e];ae[e]=t===o?-1:t,re[e]=x[i+e]+(t===o?0:re[t]),ie[e]=S[i+e]+(t===o?0:ie[t]),d[e].length===0&&(L[e]=1)}let oe=new Int32Array(i),se=new Int32Array(i),ce=new Int32Array(i);for(let e=0;e<i;e++){let t=l[e];ce[e]=t===o?-1:t,oe[e]=x[e]+(t===o?0:re[t]),se[e]=S[e]+(t===o?0:ie[t])}return{col:oe,row:se,groupCol:re,groupRow:ie,groupCols:C.slice(i),groupRows:w.slice(i),groupParent:ae,groupEmpty:L,nodeParent:ce}}var DY=12,Igt=6,Lgt=4,Rgt=3,zgt=[-1,1,0,0],Bgt=[0,0,-1,1];function OY(e,t,n,r,i){let a=e.architecture,o=typeof a==`object`&&a&&!Array.isArray(a)?a[t]:void 0;return typeof o==`number`&&Number.isFinite(o)?Math.min(i,Math.max(r,o)):n}function Vgt(e){let t=/* @__PURE__ */ new Map;for(let n of e.sort((e,t)=>e-t))t.has(n)||t.set(n,t.size);return t}function Hgt(e,t,n,r,i){return`<svg class="pele-icon" data-icon="${mq(e)}" x="${K(t)}" y="${K(n)}" width="${K(r)}" height="${K(r)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${i?.(e)??Mgt(e)}</svg>`}function Ugt(e,t,n,r){let i=e.lines.length>n;if(!i&&e.width<=t)return e;let a=r.width(`…`,e.size,0),o=[],s=[],c=0;for(let l=0;l<Math.min(n,e.lines.length);l++){let u=e.lines[l].map(e=>({...e})),d=e.widths[l];if(d>t||i&&l===n-1)for(;;){let n=u[u.length-1];if(n===void 0){u.push({text:`…`,style:0,width:a}),d=a;break}let i=d-n.width;if(n.icon===void 0&&i+a<t){let o=0,s=n.text.length;for(;o<s;){let c=o+s+1>>1;i+r.width(n.text.slice(0,c),e.size,n.style)+a<=t?o=c:s=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=r.width(n.text,e.size,n.style),d=i+n.width;break}u.pop(),d=i}o.push(u),s.push(d),c=Math.max(c,d)}return{...e,lines:o,widths:s,width:c,height:o.length*e.lineHeight}}function Wgt(e,t){let{x:n,y:r,dx:i,dy:a}=e,{x:o,y:s,dx:c,dy:l}=t,u=n+i*DY,d=r+a*DY,f=o+c*DY,p=s+l*DY;if(i*c+a*l===0){let e=i===0?n:o,t=i===0?s:r;return(e-n)*i+(t-r)*a>0&&(e-o)*c+(t-s)*l>0?[n,r,e,t,o,s]:i===0?[n,r,u,d,f,d,f,p,o,s]:[n,r,u,d,u,p,f,p,o,s]}let m=i!==0,h=m?s-r:o-n;if(i===-c&&a===-l){if((o-n)*i+(s-r)*a>0){if(Math.abs(h)<.5)return[n,r,o,s];if(m){let a=i>0?e.x1:t.x1,c=i>0?t.x0:e.x0,l=a<c?(a+c)/2:(n+o)/2;return[n,r,l,r,l,s,o,s]}let c=a>0?e.y1:t.y1,l=a>0?t.y0:e.y0,u=c<l?(c+l)/2:(r+s)/2;return[n,r,n,u,o,u,o,s]}}else if(Math.abs(h)>=1){if(m){let e=i>0?Math.max(n,o)+DY:Math.min(n,o)-DY;return[n,r,e,r,e,s,o,s]}let e=a>0?Math.max(r,s)+DY:Math.min(r,s)-DY;return[n,r,n,e,o,e,o,s]}if(m){let i=e.y1+DY<=t.y0?(e.y1+t.y0)/2:t.y1+DY<=e.y0?(t.y1+e.y0)/2:Math.max(e.y1,t.y1)+DY;return[n,r,u,r,u,i,f,i,f,s,o,s]}let g=e.x1+DY<=t.x0?(e.x1+t.x0)/2:t.x1+DY<=e.x0?(t.x1+e.x0)/2:Math.max(e.x1,t.x1)+DY;return[n,r,n,d,g,d,g,p,o,p,o,s]}function Ggt(e){let t=[e[0],e[1]];for(let n=2;n<e.length;n+=2){let r=e[n],i=e[n+1],a=t.length,o=Math.abs(r-t[a-2])<.01,s=Math.abs(i-t[a-1])<.01;o&&s||(a>=4&&(o&&Math.abs(t[a-4]-t[a-2])<.01||s&&Math.abs(t[a-3]-t[a-1])<.01)?(t[a-2]=r,t[a-1]=i):t.push(r,i))}return t}function Kgt(e,t,n){let r=e.length/2,i=Array(r),a=Array(r);for(let t=0;t<r;t++)i[t]=e[t*2],a[t]=e[t*2+1];let o=(e,t,n)=>{let r=Math.hypot(i[t]-i[e],a[t]-a[e]),o=Math.min(n,Math.max(0,r-1));r>0&&o>0&&(i[e]+=(i[t]-i[e])/r*o,a[e]+=(a[t]-a[e])/r*o)};o(0,1,t),o(r-1,r-2,n);let s=`M${K(i[0])},${K(a[0])}`;for(let e=1;e<r-1;e++){let t=Math.hypot(i[e]-i[e-1],a[e]-a[e-1]),n=Math.hypot(i[e+1]-i[e],a[e+1]-a[e]),r=Math.min(Igt,t/2,n/2);if(r<.5){s+=`L${K(i[e])},${K(a[e])}`;continue}let o=i[e]-(i[e]-i[e-1])/t*r,c=a[e]-(a[e]-a[e-1])/t*r,l=i[e]+(i[e+1]-i[e])/n*r,u=a[e]+(a[e+1]-a[e])/n*r;s+=`L${K(o)},${K(c)}Q${K(i[e])},${K(a[e])} ${K(l)},${K(u)}`}return s+`L${K(i[r-1])},${K(a[r-1])}`}function qgt(e,t,n){return YJ(n,r=>Jgt(e,t,n,r))}function Jgt(e,t,n,r){let i=OY(t,`iconSize`,48,8,512),a=OY(t,`fontSize`,n.fontSize??16,4,128),o=Math.min(OY(t,`padding`,20,0,256),r?12:1/0),s=Math.round(a*.875),c=n.measurer??fq(n.fontFamily),l=n.padding??8,u=n.icons,d=i/2,f=[...e.nodes.values()],p=[...e.groups.values()],m=f.length,h=p.length,g=Fgt(f,p,e.edges,e.layoutHints),_=/* @__PURE__ */ new Map;f.forEach((e,t)=>_.set(e.id,t));let v=Array(m),y=new Float64Array(m),b=new Float64Array(m),x=r?Math.max(i,64):Math.max(i*2.25,96);for(let e=0;e<m;e++){let t=f[e],n=UJ(t.type===`service`?t.title:void 0,!0,c,a,x);v[e]=n,y[e]=Math.max(i,2*Math.ceil(n.width/2)),b[e]=i+(n.height>0?Lgt+n.height:0)}let S=[],C=[];for(let e=0;e<m;e++)S.push(g.col[e]),C.push(g.row[e]);for(let e=0;e<h;e++)g.groupEmpty[e]&&(S.push(g.groupCol[e]),C.push(g.groupRow[e]));let w=Vgt(S),T=Vgt(C),E=w.size,D=T.size,O=new Float64Array(E),k=new Float64Array(D),A=r?Math.max(24,2*DY):Math.max(40,Math.round(i*.75)),j=new Float64Array(E).fill(A),M=new Float64Array(D).fill(A),N=new Int32Array(m),P=new Int32Array(m);for(let e=0;e<m;e++){let t=N[e]=w.get(g.col[e]),n=P[e]=T.get(g.row[e]);O[t]=Math.max(O[t],y[e]),k[n]=Math.max(k[n],b[e])}for(let e=0;e<h;e++){if(!g.groupEmpty[e])continue;let t=w.get(g.groupCol[e]),n=T.get(g.groupRow[e]);O[t]=Math.max(O[t],i),k[n]=Math.max(k[n],d)}let F=e.edges.length,ee=Array(F),te=new Int32Array(F*2);for(let t=0;t<F;t++){let n=e.edges[t],r=te[t*2]=_.get(n.lhsId)??-1,i=te[t*2+1]=_.get(n.rhsId)??-1,a=UJ(n.title,!0,c,s,160);if(ee[t]=a,!(a.width===0||r<0||i<0)){if(N[r]!==N[i]){let e=Math.min(N[r],N[i]);j[e]=Math.max(j[e],Math.ceil(a.width)+28)}else if(O[N[r]]=Math.max(O[N[r]],2*Math.ceil(a.width/2)+8),P[r]!==P[i]){let e=Math.min(P[r],P[i]);M[e]=Math.max(M[e],Math.ceil(a.height)+24)}}}let I=Array(h),ne=new Int32Array(h),re=new Int32Array(h),ie=new Int32Array(h),ae=new Int32Array(h),L=new Float64Array(h),oe=new Float64Array(h),se=new Float64Array(h),ce=new Float64Array(h),le=new Float64Array(h),ue=new Float64Array(h),de=new Float64Array(E),fe=new Float64Array(E),pe=new Float64Array(D),me=new Float64Array(D),he=Math.round(a*1.25);for(let e=0;e<h;e++){ne[e]=w.get(g.groupCol[e]),re[e]=w.get(g.groupCol[e]+g.groupCols[e]-1),ie[e]=T.get(g.groupRow[e]),ae[e]=T.get(g.groupRow[e]+g.groupRows[e]-1);let t=UJ(p[e].title,!0,c,a,r?Math.max(80,GJ(n)/2):320);I[e]=t;let i=p[e].icon?he:0;le[e]=t.width+i+(t.width>0&&i>0?6:0),ue[e]=Math.max(t.height,i)}for(let e=h-1;e>=0;e--){let t=o+L[e],n=o+oe[e],r=(ue[e]>0?Math.max(o,ue[e]+12):o)+se[e],i=o+ce[e];if(le[e]>0){let r=t+n;for(let t=ne[e];t<=re[e];t++)r+=O[t]+(t<re[e]?fe[t]+j[t]+de[t+1]:0);le[e]+20>r&&(n+=Math.ceil(le[e]+20-r))}L[e]=t,oe[e]=n,se[e]=r,ce[e]=i,de[ne[e]]=Math.max(de[ne[e]],t),fe[re[e]]=Math.max(fe[re[e]],n),pe[ie[e]]=Math.max(pe[ie[e]],r),me[ae[e]]=Math.max(me[ae[e]],i);let a=g.groupParent[e];a<0||(ne[a]===ne[e]&&(L[a]=Math.max(L[a],t)),re[a]===re[e]&&(oe[a]=Math.max(oe[a],n)),ie[a]===ie[e]&&(se[a]=Math.max(se[a],r)),ae[a]===ae[e]&&(ce[a]=Math.max(ce[a],i)))}let ge=new Float64Array(E),_e=new Float64Array(D),ve=0;for(let e=0;e<E;e++)ge[e]=ve+de[e],ve=ge[e]+O[e]+fe[e]+(e<E-1?j[e]:0);let ye=0;for(let e=0;e<D;e++)_e[e]=ye+pe[e],ye=_e[e]+k[e]+me[e]+(e<D-1?M[e]:0);let be=0,xe=0,Se=ve,Ce=ye,we=e=>ge[ne[e]]-L[e],Te=e=>ge[re[e]]+O[re[e]]+oe[e],Ee=e=>_e[ie[e]]-se[e],De=e=>_e[ae[e]]+k[ae[e]]+ce[e],Oe=e=>ge[N[e]]+O[N[e]]/2,ke=(e,t,n)=>{let r=zgt[t],i=Bgt[t],a=Oe(e),o=_e[P[e]],s={x:a,y:o+d,dx:r,dy:i,x0:a-y[e]/2,y0:o,x1:a+y[e]/2,y1:o+b[e],gap:0,wire:!1};f[e].type===`junction`?(s.x0=s.x1=a,s.y0=s.y1=s.y,s.gap=Rgt):r===0?s.y=i<0?o:o+b[e]+(v[e].height>0?2:0):s.x=a+r*d;let c=n?g.nodeParent[e]:-1;return c>=0&&(s.x0=we(c),s.x1=Te(c),s.y0=Ee(c),s.y1=De(c),s.gap=0,s.wire=f[e].type===`junction`,r===0?s.y=i<0?s.y0:s.y1:s.x=r<0?s.x0:s.x1),s},Ae=``,je=``,Me=[],Ne=sJ(`arrow_point`);for(let t=0;t<F;t++){let n=e.edges[t],r=te[t*2],i=te[t*2+1];if(r<0||i<0)continue;let a=ke(r,TY(n.lhsDir),n.lhsGroup),o=ke(i,TY(n.rhsDir),n.rhsGroup);a.x===o.x&&a.y===o.y&&a.dx===o.dx&&(a.x-=8*Math.abs(a.dy),a.y-=8*Math.abs(a.dx),o.x+=8*Math.abs(a.dy),o.y+=8*Math.abs(a.dx));let s=Wgt(a,o);a.wire&&s.unshift(Oe(r),_e[P[r]]+d),o.wire&&s.push(Oe(i),_e[P[i]]+d);let c=Ggt(s);if(c.length<4)continue;let l=mq(`${n.lhsId}-${n.rhsId}`);Ae+=`<g class="pele-edge" data-id="${l}"><path d="${Kgt(c,n.lhsInto&&!a.wire?Ne+a.gap:0,n.rhsInto&&!o.wire?Ne+o.gap:0)}"/>`+(n.lhsInto?cJ(`arrow_point`,a.x+a.dx*a.gap,a.y+a.dy*a.gap,-a.dx,-a.dy,`var(--_l)`):``)+(n.rhsInto?cJ(`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,m=-1,h=-1,g=ee[t];for(let e=0;e<c.length;e+=2)be=Math.min(be,c[e]-4),Se=Math.max(Se,c[e]+4),xe=Math.min(xe,c[e+1]-4),Ce=Math.max(Ce,c[e+1]+4);for(let e=0;e+3<c.length;e+=2){let t=Math.abs(c[e+1]-c[e+3])<.01,n=Math.abs(c[e]-c[e+2])+Math.abs(c[e+1]-c[e+3]);t||Me.push(c[e],Math.min(c[e+1],c[e+3]),Math.max(c[e+1],c[e+3])),n>p&&(f=e,p=n),t&&n>h&&(m=e,h=n)}if(g.width>0){let e=h>=g.width+8?m:f,t=(c[e]+c[e+2])/2,r=(c[e+1]+c[e+3])/2,i=g.width+8,s=Math.abs(c[e]-c[e+2])<.01;for(let e of[a,o])t+i/2<=e.x0||t-i/2>=e.x1||r+g.height/2<=e.y0||r-g.height/2>=e.y1||(s?t=t>=(e.x0+e.x1)/2?e.x1+i/2+4:e.x0-i/2-4:r=r>=(e.y0+e.y1)/2?e.y1+g.height/2+4:e.y0-g.height/2-4);be=Math.min(be,t-i/2),Se=Math.max(Se,t+i/2),xe=Math.min(xe,r-g.height/2),Ce=Math.max(Ce,r+g.height/2),je+=lJ(`${n.lhsId}-${n.rhsId}`,g,t,r,``,u)}}let Pe=``;for(let e=0;e<h;e++){let t=p[e],n=we(e),r=Ee(e),i=Te(e)-n,a=I[e],o=``;if(le[e]>0){let s=r+ue[e]+12,c=[];for(let e=0;e<Me.length;e+=3)Me[e+1]<s&&Me[e+2]>r&&Me[e]>n&&Me[e]<n+i&&c.push(Me[e]);c.sort((e,t)=>e-t),c.push(n+i-4);let l=n+10;for(let t of c){if(t-6-l>=le[e])break;l=Math.max(l,t+6)}l+le[e]>n+i-4&&(l=n+10);let d=r+6+ue[e]/2,f=l;t.icon&&(o+=Hgt(t.icon,l,d-he/2,he,u),f+=he+6),o+=gq(a,f+a.width/2,d,` class="pele-cluster-label" fill="var(--_m)"`,u)}Pe+=`<g class="pele-cluster" data-id="${mq(t.id)}"><rect x="${K(n)}" y="${K(r)}" width="${K(i)}" height="${K(De(e)-r)}" rx="${dJ}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"/>`+o+`</g>`}let Fe=``,Ie=i*.5,Le=Math.max(6,Math.round(a*.75));for(let e=0;e<m;e++){let t=f[e],n=`data-id="${mq(t.id)}" transform="translate(${K(Oe(e))},${K(_e[P[e]])})"`;if(t.type===`junction`){Fe+=`<g class="pele-node pele-junction" ${n}><circle cy="${K(d)}" r="${Rgt}" fill="var(--_l)"/></g>`;continue}let r=``;if(t.icon)r=Hgt(t.icon,-Ie/2,(i-Ie)/2,Ie,u);else if(t.iconText){let e=UJ(t.iconText,!1,c,Le,i-8),n=Math.max(1,Math.floor((i-4)/(e.lineHeight||1)));r=gq(Ugt(e,i-8,n,c),0,d,` class="pele-icon-text" font-size="${Le}"`,u)}Fe+=`<g class="pele-node pele-service" ${n}><rect x="${K(-d)}" width="${K(i)}" height="${K(i)}" rx="${dJ}" fill="var(--_s)" stroke="var(--_b)"/>`+r+gq(v[e],0,i+Lgt+v[e].height/2,` class="pele-label"`,u)+`</g>`}let Re=UJ(e.title,!1,c,a,r?GJ(n):4e3,1),ze=Re.height>0?Re.height+12:0,Be=Math.ceil(Math.max(Se-be,Re.width)+2*l),Ve=Math.ceil(Ce-xe+ze+2*l),He=Math.round((Be-(Se-be))/2-be),Ue=Math.round(l+ze-xe),We=(Pe?`<g class="pele-clusters">${Pe}</g>`:``)+(Ae?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round" stroke-linejoin="round">${Ae}</g>`:``)+(je?`<g class="pele-edge-labels" font-size="${s}">${je}</g>`:``)+(Fe?`<g class="pele-nodes">${Fe}</g>`:``);return{svg:_J(`architecture`,Be,Ve,a,n,e,gq(Re,Be/2,l+Re.height/2,` class="pele-title" font-weight="var(--_tw)"`)+(We?`<g transform="translate(${He},${Ue})">${We}</g>`:``)),width:Be,height:Ve,links:[]}}var Ygt={type:`architecture`,parse(e,t,n){let r=new bgt;return n&&(r.title=n),xgt(Agt(e),r),r},render:qgt},Xgt=1e5;function Zgt(e){switch(e){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 Qgt(e){switch(e.trim().slice(-1)){case`x`:return`arrow_cross`;case`o`:return`arrow_circle`;case`>`:return`arrow_point`;default:return``}}function $gt(e){switch(e.trim().charAt(0)){case`x`:return`arrow_cross`;case`o`:return`arrow_circle`;case`<`:return`arrow_point`;default:return`arrow_open`}}function e_t(e){return e.includes(`==`)?`thick`:`normal`}function t_t(e){return e.includes(`.-`)?`dotted`:`solid`}function n_t(e,t){let n=e.flat(),r=-1;for(let e of n)if(e.type===`column-setting`){r=e.columns??-1;break}return{list:n,at:0,parent:t,children:[],columns:r}}var r_t=class{type=`block`;title;root={id:`root`,type:`composite`,children:[],columns:-1};blocks=[];edges=[];classes=/* @__PURE__ */ new Map;byId=/* @__PURE__ */ new Map;typeStr2Type=Zgt;edgeStrToEdgeData=Qgt;edgeStrToEdgeStartData=$gt;edgeStrToThickness=e_t;edgeStrToPattern=t_t;warn;pending=/* @__PURE__ */ new Set;edgeCount=/* @__PURE__ */ new Map;ids=0;colors=0;spaces=0;constructor(e={}){this.warn=e.warn}generateId(){return`id-`+ ++this.ids}addStyleClass(e,t=``){let n=this.classes.get(e);n||(n={id:e,styles:[],textStyles:[]},this.classes.set(e,n));for(let e of t.split(`,`)){let t=e.indexOf(`;`),r=(t===-1?e:e.slice(0,t)+e.slice(t+1)).trim();e.includes(`color`)&&n.textStyles.push(r.replace(`fill`,`bgFill`).replace(`color`,`fill`)),n.styles.push(r)}}addStyle2Node(e,t=``){this.named(e).styles=t.split(`,`)}setCssClass(e,t){for(let n of e.split(`,`))(this.named(n.trim()).classes??=[]).push(t)}named(e){let t=this.byId.get(e);return t===void 0&&(t={id:e,type:`na`,children:[]},this.byId.set(e,t),this.pending.add(e)),t}setHierarchy(e){let t=[n_t(e,this.root)];for(;t.length>0;){let e=t[t.length-1];if(e.at===e.list.length){e.parent.children=e.children,t.pop();continue}let n=e.list[e.at++];switch(e.columns>0&&n.type!==`column-setting`&&typeof n.widthInColumns==`number`&&n.widthInColumns>e.columns&&this.warn?.(`Block ${n.id} width ${n.widthInColumns} exceeds configured column width ${e.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`:e.parent.columns=n.columns??-1;continue;case`edge`:{let e=(this.edgeCount.get(n.id)??0)+1;this.edgeCount.set(n.id,e),n.id=e+`-`+n.id,this.edges.push(n);continue}}n.id??=this.generateId(),n.label||=n.type===`composite`?``:n.id;let r=this.byId.get(n.id),i=r===void 0||this.pending.delete(n.id);i?(r&&(n.classes=r.classes,n.styles=r.styles),n.type===`composite`&&(n.colorIndex=this.colors++),this.byId.set(n.id,n)):(n.type!==`na`&&(r.type=n.type),n.label!==n.id&&(r.label=n.label));let a=n.children;if(n.children=[],n.type===`space`){let t=n.width??1;if(!(t<=Xgt-this.spaces))throw new NK(`A block diagram can hold at most ${Xgt} space blocks.`,`limit`,{type:`block`});this.spaces+=Math.max(t,0);for(let r=0;r<t;r++){let t={...n,id:n.id+`-`+r,children:[]};this.byId.set(t.id,t),e.children.push(t)}}else i&&e.children.push(n);a&&a.length>0&&t.push(n_t(a,n))}this.blocks=this.root.children??[]}},i_t=/* @__PURE__ */ `$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`.split(`.`),a_t=[`right`,`left`,`x`,`y`,`up`,`down`],o_t=/* @__PURE__ */ new Uint8Array(128);for(let e of[9,10,11,12,13,32,40,41,45,58,60,61,62,91,123,125])o_t[e]=1;function s_t(e){let t=e.length,n=[],r=[],i=[],a=[],o=0,s=0,c=(e,t,a)=>(n.push(e),r.push(t),i.push(s),s=a,!0),l=(t,n)=>c(t,e.slice(s,n),n),u=e=>{a.push(o),o=e},d=()=>{a.length>0&&(o=a.pop())},f=n=>{for(;n<t&&eq(e.charCodeAt(n));)n++;return n},p=n=>{for(;n<t;){let t=e.charCodeAt(n);if(t<48||t>57)break;n++}return n},m=n=>{for(;n<t&&aq(e.charCodeAt(n));)n++;return n},h=t=>e.startsWith(t,s)&&!aq(e.charCodeAt(s+t.length)),g=()=>(e.charCodeAt(s+1)===96?(u(2),s+=2):(u(1),s++),!0),_=t=>{if(e.charCodeAt(t)!==46)return-1;do t++;while(e.charCodeAt(t)===46);if(e.charCodeAt(t)!==45)return-1;let n=e.charCodeAt(t+1);return n===120||n===111||n===62?t+2:t+1},v=t=>{let n=e.charCodeAt(t);(n===120||n===111||n===60)&&t++;let r=e.charCodeAt(t);if(r===46)return _(t);if(r!==45&&r!==61)return-1;let i=t+1;for(;e.charCodeAt(i)===r;)i++;if(i-t===1)return r===45?_(i):-1;let a=e.charCodeAt(i);return a===120||a===111||a===62?i+1:i-t>=3?i:-1},y=()=>{let t=v(s);if(t>=0)return l(33,f(t));let n=e.charCodeAt(s)===60?s+1:s,r=e.charCodeAt(n),i=e.charCodeAt(n+1);return r===45&&(i===45||i===46)||r===61&&i===61?(u(6),l(34,f(n+2))):!1},b=n=>{let r=e.indexOf(`
|
|
991
|
+
`,s);return r===-1&&(r=t),d(),l(n,r)},x=(t,n)=>{let r=m(s);if(r===s)return!1;for(;e.charCodeAt(r)===44;){let e=f(r+1),t=m(e);if(t===e)break;r=t}return o=n,l(t,r)},S=n=>{if(eq(n))return s=f(s+1),!0;let r;switch(n){case 98:if(e.startsWith(`block`,s)){if(h(`block-beta`))return l(2,s+10);if(e.charCodeAt(s+5)===58)return l(3,s+6);if(!aq(e.charCodeAt(s+5)))return l(2,s+5)}break;case 99:if(e.startsWith(`columns`,s)){if(r=f(s+7),r>s+7){if(e.startsWith(`auto`,r)&&!aq(e.charCodeAt(r+4)))return c(4,`-1`,r+4);let t=p(r);if(t>r)return c(4,e.slice(r,t),t)}}else if(e.startsWith(`class`,s)){let t=e.startsWith(`Def`,s+5),n=t?s+8:s+5;if(r=f(n),r>n)return u(t?7:9),l(t?11:15,r)}break;case 34:return g();case 115:if(e.startsWith(`space`,s)){if(e.charCodeAt(s+5)===58){let t=p(s+6);if(t>s+6)return c(7,e.slice(s+6,t),t)}if(!aq(e.charCodeAt(s+5)))return c(7,`1`,s+5)}else if(e.startsWith(`style`,s)&&(r=f(s+5),r>s+5))return u(11),l(18,r);break;case 100:if(h(`default`))return l(8,s+7);break;case 108:if(h(`linkStyle`))return l(9,s+9);break;case 105:if(h(`interpolate`))return l(10,s+11);break;case 97:if(e.startsWith(`accTitle`,s)){if(r=f(s+8),e.charCodeAt(r)===58)return u(13),l(21,f(r+1))}else if(e.startsWith(`accDescr`,s)){r=f(s+8);let t=e.charCodeAt(r);if(t===58)return u(14),l(23,f(r+1));if(t===123)return u(15),s=f(r+1),!0}break;case 101:if(h(`end`))return l(26,f(s+3));break;case 45:return e.charCodeAt(s+1)===41?(u(3),l(27,s+2)):y();case 61:return y();case 60:return e.charCodeAt(s+1)===91?(u(4),l(29,s+2)):y();case 40:{let t=e.charCodeAt(s+1),n=t===45||t===91?2:t===40?e.charCodeAt(s+2)===40?3:2:1;return u(3),l(27,s+n)}case 41:case 123:return u(3),l(27,e.charCodeAt(s+1)===n?s+2:s+1);case 62:return u(3),l(27,s+1);case 91:{let t=e.charCodeAt(s+1);return u(3),l(27,t===91||t===124||t===40||t===92||t===47?s+2:s+1)}case 58:{let t=p(s+1);return t>s+1&&c(36,e.slice(s+1,t),t)}}for(r=s;r<t;){let t=e.charCodeAt(r);if(t<128?o_t[t]===1:eq(t))break;r++}return r>s&&l(32,r)},C=t=>{let n=e.charCodeAt(s+1),r=0;switch(t){case 34:return g();case 40:r=n===45?2:n===40?e.charCodeAt(s+2)===40?3:2:1;break;case 41:r=n===41?e.charCodeAt(s+2)===41?3:2:n===93?2:1;break;case 125:r=n===125?2:1;break;case 45:r=n===41?2:0;break;case 93:r=n===93||n===41||n===62?2:1;break;case 92:case 47:r=n===93?2:0}return r!==0&&(d(),l(28,s+r))},w=t=>{if(t===41)return d(),d(),c(30,`]>`,f(s+1));let n=f(t===44?s+1:s);for(let r of a_t)if(e.startsWith(r,n)){let i=f(n+r.length);return c(31,e.slice(t===44?n:s,i),i)}return!1};for(;;){if(s>=t){let e=-1;switch(o){case 0:e=37;break;case 1:e=6;break;case 8:e=14;break;case 10:e=17;break;case 12:e=20;break;case 13:e=22;break;case 14:e=24;break;case 15:e=25}s=t,e!==-1&&c(e,``,t);break}let a=e.charCodeAt(s),p=!0;switch(o){case 0:p=S(a);break;case 1:if(a===34)d(),s++;else{let n=e.indexOf(`"`,s);l(6,n===-1?t:n)}break;case 2:if(a===96)p=e.charCodeAt(s+1)===34,p&&(d(),s+=2);else if(a===34)p=!1;else{let n=s+1;for(;n<t;){let t=e.charCodeAt(n);if(t===96||t===34)break;n++}l(5,n)}break;case 3:p=C(a);break;case 4:if(a===34)g();else if(a===93&&e.charCodeAt(s+1)===62){let t=f(s+2);p=e.charCodeAt(t)===40,p&&(u(5),s=t+1)}else p=!1;break;case 5:p=w(a);break;case 6:if(a===34)e.charCodeAt(s+1)===96?g():(l(35,s+1),u(1));else{let e=v(f(s));p=e>=0,p&&(d(),l(33,f(e)))}break;case 7:{let t=12,n=e.startsWith(`DEFAULT`,s)?s+7:s,r=f(n);(n===s||r===n)&&(t=13,n=m(s),r=f(n)),p=n>s&&r>n,p&&(o=8,l(t,r));break}case 8:b(14);break;case 9:p=x(16,10);break;case 10:b(17);break;case 11:p=x(19,12);break;case 12:b(20);break;case 13:b(22);break;case 14:b(24);break;case 15:if(a===125)d(),s++;else{let n=e.indexOf(`}`,s);l(25,n===-1?t:n)}}if(!p)return n.push(1),r.push(``),i.push(s),{types:n,texts:r,starts:i}}return n.push(0),r.push(``),i.push(t),{types:n,texts:r,starts:i}}var kY=`'NODE_ID', 'COLUMNS', 'SPACE_BLOCK', 'BLOCK_DIAGRAM_KEY', 'id-block', 'classDef', 'class', 'style'`;function c_t(e){let t=e[e.length-1];return Array.isArray(t)?(e.pop(),e.concat(t)):e}function l_t(e,t){let{types:n,texts:r,starts:i}=s_t(e),a=0,o=t=>{let r=n[a];throw r===1?FK(`block`,e,i[a],``,!0):FK(`block`,e,i[a],`Expecting ${t}, got '${i_t[r]}'`)},s=e=>(n[a]!==e&&o(`'${i_t[e]}'`),r[a++]),c=()=>{let e=s(32);if(n[a]===27){let t=r[a++];return{id:e,label:s(6),typeStr:t+s(28)}}if(n[a]===29){let t=r[a++],i=s(6),o=[s(31)];for(;n[a]===31;)o.push(r[a++]);return{id:e,label:i,typeStr:t+s(30),directions:o}}return{id:e}},l=()=>{let e=c(),i=n[a]===36?parseInt(r[a++],10):1,o={id:e.id,label:e.label,type:t.typeStr2Type(e.typeStr),directions:e.directions,widthInColumns:i},l;for(;n[a]===33||n[a]===34;){let e=``;n[a++]===34&&(s(35),e=s(6),s(33));let i=r[a-1],u=c(),d=t.edgeStrToEdgeData(i),f=t.edgeStrToEdgeStartData(i),p=t.edgeStrToThickness(i),m=t.edgeStrToPattern(i);l??=[{id:o.id,label:o.label,type:o.type,directions:o.directions}],o={id:u.id,label:u.label,type:t.typeStr2Type(u.typeStr),directions:u.directions},l.push({id:l[l.length-1].id+`-`+u.id,start:l[l.length-1].id,end:u.id,label:e,type:`edge`,thickness:p,pattern:m,directions:u.directions,arrowTypeEnd:d,arrowTypeStart:f},o)}return l??o};s(2);let u=[],d=[];for(;;)switch(n[a]){case 32:d.push(l());break;case 4:d.push({type:`column-setting`,columns:parseInt(r[a++],10)});break;case 7:{let e=parseInt(r[a++],10);d.push({id:t.generateId(),type:`space`,label:``,width:e,children:[]});break}case 2:a++,u.push({list:d,header:void 0}),d=[];break;case 3:a++,n[a]!==32&&o(`'NODE_ID'`),u.push({list:d,header:l()}),d=[];break;case 26:{let e=u.pop();if(e===void 0||d.length===0)return o(kY);a++;let n=t.generateId(),r=c_t(d);d=e.list,d.push(e.header===void 0?{id:n,type:`composite`,label:``,children:r}:{...e.header,type:`composite`,children:r});break}case 11:{a++;let e=s(13).trim();d.push({type:`classDef`,id:e,css:s(14).trim()});break}case 15:{a++;let e=s(16).trim();d.push({type:`applyClass`,id:e,styleClass:s(17).trim()});break}case 18:{a++;let e=s(19).trim();d.push({type:`applyStyles`,id:e,stylesStr:s(20).trim()});break}case 37:u.length>0&&o(kY+`, 'end'`),d.length===0&&o(kY),t.setHierarchy(c_t(d));return;default:o(d.length===0?kY:kY+(u.length>0?`, 'end'`:`, 'EOF'`))}}var AY=1,jY=2,MY=4,NY=8,PY=7,FY=20,IY=12;function u_t(e){let t=0;if(e)for(let n of e)switch(n.trim()){case`right`:t|=AY;break;case`left`:t|=jY;break;case`up`:t|=MY;break;case`down`:t|=NY;break;case`x`:t|=AY|jY;break;case`y`:t|=MY|NY}return t}var LY=(e,t)=>e&t?1:0;function RY(e){return e!==0&&(e&(MY|NY))===0?`x`:e!==0&&(e&(AY|jY))===0?`y`:``}function d_t(e,t,n){let r=RY(e),i=LY(e,jY)-LY(e,AY),a=LY(e,MY)-LY(e,NY);if(r===`x`){let r=Math.max(n+8,14)+2*PY,a=Math.min(r/2,FY);return{w:Math.max(t+12,16)+a*(e===(AY|jY)?2:1),h:r,dx:i*a/2,dy:0}}if(r===`y`){let r=Math.max(t+16,14)+2*PY,i=Math.min(r/2,FY);return{w:r,h:Math.max(n+8,16)+i*(e===(MY|NY)?2:1),dx:0,dy:a*i/2}}return{w:Math.max(t+16,24)+IY*(LY(e,jY)+LY(e,AY)),h:Math.max(n+8,24)+IY*(LY(e,MY)+LY(e,NY)),dx:i*IY/2,dy:a*IY/2}}function f_t(e,t,n,r){let i=RY(e),a=t/2,o=n/2,s;if(i===`x`){let t=Math.min(o,FY),n=o-PY,r=e&jY?-a+t:-a,i=e&AY?a-t:a;s=[r,-n,i,-n],e&AY&&s.push(i,-o,a,0,i,o),s.push(i,n,r,n),e&jY&&s.push(r,o,-a,0,r,-o)}else if(i===`y`){let t=Math.min(a,FY),n=a-PY,r=e&MY?-o+t:-o,i=e&NY?o-t:o;s=[n,r,n,i],e&NY&&s.push(a,i,0,o,-a,i),s.push(-n,i,-n,r),e&MY&&s.push(-a,r,0,-o,a,r)}else{let t=e&jY?-a+IY:-a,n=e&AY?a-IY:a,r=e&MY?-o+IY:-o,i=e&NY?o-IY:o,c=(t+n)/2,l=(r+i)/2,u=Math.min(10,(n-t)/2),d=Math.min(10,(i-r)/2);s=[t,r],e&MY&&s.push(c-u,r,c,-o,c+u,r),s.push(n,r),e&AY&&s.push(n,l-d,a,l,n,l+d),s.push(n,i),e&NY&&s.push(c+u,i,c,o,c-u,i),s.push(t,i),e&jY&&s.push(t,l+d,-a,l,t,l-d)}let c=``;for(let e=0;e<s.length;e+=2)c+=(e?` `:``)+K(s[e])+`,`+K(s[e+1]);return`<polygon points="${c}" stroke-linejoin="round"${r}/>`}var p_t=1e3;function m_t(e,t){if(e===0||!Number.isInteger(e))throw new NK(`Columns must be an integer !== 0.`,`semantic`,{type:`block`});if(t<0||!Number.isInteger(t))throw new NK(`Position must be a non-negative integer.`+t,`semantic`,{type:`block`});return e<0?{px:t,py:0}:{px:t%e,py:Math.floor(t/e)}}function h_t(e,t,n){let r=e.columns,i=[],a=0,o=0,s=0,c=0;for(let n of e.children){let{px:e,py:l}=m_t(r,a),u=n.span>=1?Math.min(n.span,p_t):1;if(r>0&&u>r-e&&(u=r-e),n.span=u,n.col=e,n.row=l,a+=u,e+u>o&&(o=e+u),l===i.length&&i.push(0),n.children.length===0?i[l]=-1:i[l]>=0&&n.nh>i[l]&&(i[l]=n.nh),n.space)continue;let d=(n.nw-t*(u-1))/u;d>s&&(s=d),n.nh>c&&(c=n.nh)}let l=(i.length-1)*t;for(let e=0;e<i.length;e++)i[e]<0&&(i[e]=c),l+=i[e];e.cols=o,e.heights=i,e.nw=Math.max(e.nw,o*s+(o-1)*t+2*n),e.nh=l+2*n+e.head}function g_t(e,t,n){let{cols:r,heights:i}=e,a=i.length,o=(e.w-2*n-(r-1)*t)/r,s=e.h-2*n-e.head-(a-1)*t,c=0;for(let e of i)c+=e;let l=c>0?s/c:0,u=c>0?0:s/a,d=e.x-e.w/2+n,f=e.y-e.h/2+n+e.head,p=0;for(let n of e.children){for(;p<n.row;p++)f+=i[p]*l+u+t;n.w=o*n.span+t*(n.span-1),n.h=i[p]*l+u,n.x=d+n.col*(o+t)+n.w/2,n.y=f+n.h/2}}function __t(e,t){let n=[e];for(let e=0;e<n.length;e++)for(let t of n[e].children)n.push(t);for(let e=n.length-1;e>=0;e--){let r=n[e];r.children.length>0&&h_t(r,t,e===0?0:t)}e.w=e.nw,e.h=e.nh,e.x=e.w/2,e.y=e.h/2;for(let e=0;e<n.length;e++){let r=n[e];r.children.length>0&&g_t(r,t,e===0?0:t)}return{width:e.w,height:e.h}}var v_t=12,y_t=200,b_t=8,x_t=` fill="var(--_s)" stroke="var(--_b)"`,S_t=` stroke="var(--_b)"`,C_t=[],w_t=[],T_t=[],E_t=[`default`],D_t=2e6,O_t=/* @__PURE__ */ 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`]]),k_t=/* @__PURE__ */ new Set([`circle`,`dbl-circ`,`diam`]),A_t=/* @__PURE__ */ new Set([`stadium`,`hex`,`odd`,`lean-r`,`lean-l`,`trap-b`,`trap-t`]);function zY(e){return e.kind===0&&(e.shape===`circle`||e.shape===`dbl-circ`)}function BY(e,t,n){let r=e.bw/2,i=e.bh/2,a=Math.abs(t-e.x),o=i;return zY(e)?o=Math.sqrt(Math.max(r*r-a*a,0)):e.kind===0&&e.shape===`diam`?o=i*Math.max(1-a/r,0):e.kind===0?o=i-RJ(e.shape,e.bw,e.bh,n>0?2:0):e.kind===1&&RY(e.mask)===`x`&&(o=i-PY),e.y+n*o}function VY(e,t,n){let r=e.bw/2,i=e.bh/2,a=Math.abs(t-e.y),o=r;return zY(e)?o=Math.sqrt(Math.max(i*i-a*a,0)):e.kind===0&&e.shape===`diam`?o=r*Math.max(1-a/i,0):e.kind===0?o=r-RJ(e.shape,e.bw,e.bh,n>0?1:3):e.kind===1&&RY(e.mask)===`y`&&(o=r-PY),e.x+n*o}function j_t(e,t,n,r){let i=t-e.x,a=n-e.y,o=e.bw/2,s=e.bh/2,c;c=zY(e)?o/(Math.hypot(i,a)||1):e.kind===0&&e.shape===`diam`?1/(Math.abs(i)/o+Math.abs(a)/s||1):Math.min(i===0?1/0:o/Math.abs(i),a===0?1/0:s/Math.abs(a)),c===1/0&&(c=0),r.push(e.x+i*c,e.y+a*c)}function M_t(e,t,n,r,i){let a=i.x-i.bw/2+1,o=i.x+i.bw/2-1,s=i.y-i.bh/2+1,c=i.y+i.bh/2-1;if(e<a&&n<a||e>o&&n>o||t<s&&r<s||t>c&&r>c)return!1;if(e===n||t===r)return!0;let l=n-e,u=r-t,d=(n,r)=>Math.sign(l*(r-t)-u*(n-e)),f=d(a,s);return f===0||d(o,s)!==f||d(o,c)!==f||d(a,c)!==f}function HY(e,t,n,r){let i=0;for(let a of r)if(a!==t&&a!==n){for(let t=0;t+3<e.length;t+=2)if(M_t(e[t],e[t+1],e[t+2],e[t+3],a)){i++;break}}return i}function N_t(e,t,n,r){let i=e.x-e.bw/2,a=e.x+e.bw/2,o=e.y-e.bh/2,s=e.y+e.bh/2,c=t.x-t.bw/2,l=t.x+t.bw/2,u=t.y-t.bh/2,d=t.y+t.bh/2,f=Math.max(i,c),p=Math.min(a,l),m=Math.max(o,u),h=Math.min(s,d),g=p-f>6,_=h-m>6;if(g&&_){let n=e.bw*e.bh<=t.bw*t.bh?e:t,r=n===e?t:e,i=n.y-n.bh/2-(r.y-r.bh/2),a=r.y+r.bh/2-(n.y+n.bh/2),o=n.x-n.bw/2-(r.x-r.bw/2),s=r.x+r.bw/2-(n.x+n.bw/2),c=Math.min(i,a,o,s),l;return l=c===a?[n.x,BY(n,n.x,1),n.x,r.y+r.bh/2]:c===i?[n.x,BY(n,n.x,-1),n.x,r.y-r.bh/2]:c===s?[VY(n,n.y,1),n.y,r.x+r.bw/2,n.y]:[VY(n,n.y,-1),n.y,r.x-r.bw/2,n.y],n===e?l:[l[2],l[3],l[0],l[1]]}if(g){let r=Math.min(6,(p-f)/2),i=Math.min(Math.max((f+p)/2+n,f+r),p-r),a=t.y>e.y?1:-1;return[i,BY(e,i,a),i,BY(t,i,-a)]}if(_){let r=Math.min(6,(h-m)/2),i=Math.min(Math.max((m+h)/2+n,m+r),h-r),a=t.x>e.x?1:-1;return[VY(e,i,a),i,VY(t,i,-a),i]}let v=t.x>e.x?1:-1,y=t.y>e.y?1:-1,b=[VY(e,e.y,v),e.y,t.x,e.y,t.x,BY(t,t.x,-y)],x=[e.x,BY(e,e.x,y),e.x,t.y,VY(t,t.y,-v),t.y],S=Math.abs(t.x-e.x)>=Math.abs(t.y-e.y),C=S?b:x;if(r===void 0)return C;let w=HY(C,e,t,r);if(w===0)return C;let T=S?x:b,E=HY(T,e,t,r);if(E<w&&(C=T,w=E),w===0)return C;let D=[];return j_t(e,t.x,t.y,D),j_t(t,e.x,e.y,D),HY(D,e,t,r)<w?D:C}function P_t(e,t,n){let r=e.length,i=e[0],a=e[1],o=e[r-2],s=e[r-1],c=e[2]-i,l=e[3]-a,u=Math.hypot(c,l);c/=u||1,l/=u||1;let d=o-e[r-4],f=s-e[r-3],p=Math.hypot(d,f);if(d/=p||1,f/=p||1,r===4&&t+n>u){let e=u/(t+n);t*=e,n*=e}t=Math.min(t,u),n=Math.min(n,p);let m=`M${K(i+c*t)},${K(a+l*t)}`;if(r===6){let r=Math.max(0,Math.min(b_t,u-t,p-n));m+=`L${K(e[2]-c*r)},${K(e[3]-l*r)}Q${K(e[2])},${K(e[3])} ${K(e[2]+d*r)},${K(e[3]+f*r)}`}return m+=`L${K(o-d*n)},${K(s-f*n)}`,{d:m,sx:i,sy:a,sdx:-c,sdy:-l,ex:o,ey:s,edx:d,edy:f}}function F_t(e,t){let n=e.bw/2,r=e.bh/2,i=Math.max(1,Math.min(10+5*(t-1),n,r));if(zY(e)){let t=e.x+n*Math.SQRT1_2,r=e.y-n*Math.SQRT1_2,a=2*Math.asin(Math.min(1,i/(2*n))),o=i=>Math.atan2(e.y-n*Math.sin(i)-r,e.x+n*Math.cos(i)-t);return[t,r,i,o(Math.PI/4+a),o(Math.PI/4-a)]}if(e.kind===0&&e.shape===`diam`){let t=Math.atan2(r,n);return[e.x+n/2,e.y-r/2,i,t+Math.PI,t]}return[e.x+n,e.y-r,i,Math.PI,Math.PI/2]}function I_t(e,t,n,r){let[i,a,o,s,c]=F_t(e,t),l=s+n/o,u=c-r/o,d=(u-l)%(2*Math.PI);d<=0&&(d+=2*Math.PI);let f=i+o*Math.cos(l),p=a+o*Math.sin(l),m=i+o*Math.cos(u),h=a+o*Math.sin(u),g=i+o*Math.cos(s),_=a+o*Math.sin(s),v=i+o*Math.cos(c),y=a+o*Math.sin(c),b=Math.hypot(g-f,_-p),x=Math.hypot(v-m,y-h);return{d:`M${K(f)},${K(p)}A${K(o)},${K(o)} 0 ${+(d>Math.PI)} 1 ${K(m)},${K(h)}`,sx:g,sy:_,sdx:b>0?(g-f)/b:Math.sin(s),sdy:b>0?(_-p)/b:-Math.cos(s),ex:v,ey:y,edx:x>0?(v-m)/x:-Math.sin(c),edy:x>0?(y-h)/x:Math.cos(c)}}var L_t=[.5,.3,.7,.15,.85];function R_t(e,t,n,r,i,a,o){if(o===void 0)return .5;for(let s of L_t){let c=e[t]+(e[t+2]-e[t])*s,l=e[t+1]+(e[t+3]-e[t+1])*s,u=!0;for(let e of o)if(e!==i&&e!==a&&Math.abs(c-e.x)<(n+e.bw)/2&&Math.abs(l-e.y)<(r+e.bh)/2){u=!1;break}if(u)return s}return .5}function z_t(e,t,n){return YJ(n,r=>B_t(e,t,n,r))}function B_t(e,t,n,r){let i=n.fontSize??16,a=Math.round(i*.875),o=n.measurer??fq(n.fontFamily),s=n.padding??8,c=n.icons,l=t.block?.padding,u=Math.min(typeof l==`number`&&l>=0?Math.min(l,200):v_t,r?6:1/0),d=r?80:y_t,f=t=>{let n=[],r=e=>{for(let t of e)for(let e of t.split(`;`))n.push(e)};for(let n of t.classes&&t.classes.length>0?t.classes:E_t){let t=e.classes.get(n);t&&r(t.styles)}return t.styles&&r(t.styles),pJ(n)},p=(e,t)=>{let a=e.type,s=a===`space`?pJ(C_t):f(e),c=+!!s.bold|(s.italic?2:0),l=s.fontSize??i,p=0,m=``,h,g=0,_=0,v=0,y=0,b=0,x=0;if(a===`space`)p=3,h=UJ(void 0,!1,o,l,d);else if(a===`composite`)p=2,h=UJ(e.label,!1,o,l,r?GJ(n):4e3,c),v=h.height>0?h.height+4:0,g=h.width+2*u,_=v+2*u;else if(a===`block_arrow`){p=1,h=UJ(e.label,!1,o,l,d,c);let t=!0;for(let e of h.lines)for(let n of e)(n.icon!==void 0||n.text.trim()!==``)&&(t=!1);y=u_t(e.directions);let n=t?d_t(y,0,0):d_t(y,h.width,h.height);g=n.w,_=n.h,b=n.dx,x=n.dy}else{m=O_t.get(a??``)??`rect`,h=UJ(e.label,!1,o,l,d,c);let t=IJ(m,h.width,h.height);g=t.w,_=m===`cyl`?Math.max(t.h,h.height+40):t.h,x=t.dy}return{children:[],columns:p===2?e.columns??-1:-1,span:p===3?1:e.widthInColumns??1,space:p===3,head:v,nw:g,nh:_,col:0,row:0,cols:0,heights:T_t,x:0,y:0,w:0,h:0,block:e,kind:p,index:t,shape:m,label:h,style:s,mask:y,dx:b,dy:x,bw:0,bh:0}},m=p(e.root,0);m.nw=0,m.nh=0;let h=[m],g=/* @__PURE__ */ new Map;for(let e=0;e<h.length;e++){let t=h[e];if(t.kind===2)for(let e of t.block.children??w_t){let n=p(e,h.length);t.children.push(n),h.push(n),n.kind!==3&&g.set(e.id,n)}}let _=__t(m,u),v=[];for(let e of h)e.kind===0&&k_t.has(e.shape)?(e.bw=e.nw,e.bh=e.nh):e.kind===1?(e.bw=e.span>1?e.w:e.nw,e.bh=e.nh):(e.bw=e.w,e.bh=e.kind===0&&A_t.has(e.shape)?e.nh:e.h),e.kind===0&&e.shape===`cyl`&&(e.dy=Math.min(12,Math.max(6,e.bw/14))/2),(e.kind===0||e.kind===1)&&v.push(e);let y=/* @__PURE__ */ new Map,b=/* @__PURE__ */ new Set,x=[],S=[];for(let t of e.edges){let e=g.get(t.start??``),n=g.get(t.end??``);if(e===void 0||n===void 0)continue;let r=Math.min(e.index,n.index)*h.length+Math.max(e.index,n.index);y.set(r,(y.get(r)??0)+1),t.label&&b.add(r),x.push([e,n]),S.push(t)}let C=S.length*v.length<=D_t?v:void 0,w=/* @__PURE__ */ new Map,T=[],E=0,D=0,O=_.width,k=_.height,A=(e,t,n,r)=>{e-n/2<E&&(E=e-n/2),e+n/2>O&&(O=e+n/2),t-r/2<D&&(D=t-r/2),t+r/2>k&&(k=t+r/2)};for(let e=0;e<S.length;e++){let[t,n]=x[e],r=Math.min(t.index,n.index)*h.length+Math.max(t.index,n.index),i=y.get(r)??1,s=w.get(r)??0;w.set(r,s+1);let c=UJ(S[e].label,!1,o,a,y_t),l,u,d;if(t===n){let[e,n,r]=F_t(t,s+1);l=[],A(e,n,2*r+2,2*r+2),u=e+r+6+c.width/2,d=n-r/2}else{let e=b.has(r)?Math.round(a*1.5)+2:14;l=N_t(t,n,(s-(i-1)/2)*e,C);let o=l.length,f=Math.abs(l[2]-l[0])+Math.abs(l[3]-l[1]),p=Math.abs(l[o-2]-l[o-4])+Math.abs(l[o-1]-l[o-3]),m=o===6&&p>f?2:0,h=c.width>0?R_t(l,m,c.width+8,c.height,t,n,C):.5;u=l[m]+(l[m+2]-l[m])*h,d=l[m+1]+(l[m+3]-l[m+1])*h}c.width>0&&A(u,d,c.width+8,c.height),T.push({edge:S[e],points:l,loop:t===n?s+1:0,label:c,lx:u,ly:d})}let j=UJ(e.title,!1,o,i,r?GJ(n):4e3,1),M=j.height>0?j.height+12:0,N=Math.max(O-E,j.width),P=s-E+(N-(O-E))/2,F=s+M-D;for(let e of h)e.x+=P,e.y+=F;let ee=Math.ceil(N+2*s),te=Math.ceil(k-D+M+2*s),I=``,ne=``;for(let e=1;e<h.length;e++){let t=h[e];if(t.kind===3)continue;let n=mJ((t.block.classes??C_t).join(` `)),r=mq(t.block.id);if(t.kind===2){let e=t.y-t.h/2;I+=`<g class="pele-cluster${n}" data-id="${r}"><rect x="${K(t.x-t.w/2)}" y="${K(e)}" width="${K(t.w)}" height="${K(t.h)}" rx="${dJ}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${t.style.shape}/>`+gq(t.label,t.x,e+(t.head+u)/2+2,` class="pele-cluster-label" fill="var(--_m)"${t.style.text}`,c)+`</g>`;continue}let i=t.kind===1;ne+=`<g class="pele-node pele-shape-${i?`block-arrow`:t.shape}${n}" data-id="${r}" transform="translate(${K(t.x)},${K(t.y)})">`+(i?f_t(t.mask,t.bw,t.bh,x_t+t.style.shape):LJ(t.shape,t.bw,t.bh,x_t+t.style.shape,S_t+t.style.line))+gq(t.label,t.dx,t.dy,` class="pele-label"${t.style.text}`,c)+`</g>`}let re=``,ie=``;for(let e=0;e<T.length;e++){let{edge:t,points:n,loop:r,label:i}=T[e],a=t.arrowTypeStart??``,o=t.arrowTypeEnd??``,s;if(r>0)s=I_t(x[e][0],r,sJ(a),sJ(o));else{for(let e=0;e<n.length;e+=2)n[e]+=P,n[e+1]+=F;s=P_t(n,sJ(a),sJ(o))}let l=mq(t.id);if(re+=`<g class="pele-edge" data-id="${l}"><path d="${s.d}"${t.thickness===`thick`?` stroke-width="2.5"`:``}${t.pattern===`dotted`?` stroke-dasharray="3 4"`:``}/>`+cJ(a,s.sx,s.sy,s.sdx,s.sdy,`var(--_l)`)+cJ(o,s.ex,s.ey,s.edx,s.edy,`var(--_l)`)+`</g>`,i.width>0){let n=T[e].lx+P,r=T[e].ly+F;ie+=lJ(t.id,i,n,r,``,c)}}return{svg:_J(`block`,ee,te,i,n,e,gq(j,ee/2,s+j.height/2,` class="pele-title" font-weight="var(--_tw)"`)+(I?`<g class="pele-clusters">${I}</g>`:``)+(re?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${re}</g>`:``)+`<g class="pele-nodes">${ne}</g>`+(ie?`<g class="pele-edge-labels" font-size="${a}">${ie}</g>`:``)),width:ee,height:te,links:[]}}var V_t={type:`block`,parse(e,t,n){let r=new r_t;return r.title=n,l_t(e,r),r},render:z_t},H_t=/* @__PURE__ */ new Set([`label`,`type`,`descr`,`techn`,`sprite`,`tags`,`link`,`bgColor`,`fontColor`,`borderColor`,`shadowing`,`shape`,`legendText`,`legendSprite`]),U_t=/* @__PURE__ */ new Set([`label`,`descr`,`techn`,`sprite`,`tags`,`link`,`textColor`,`lineColor`]);function UY(e,t){let{key:n,value:r}=t;`from`in e&&(n===`offsetX`||n===`offsetY`)?e[n]=parseInt(r):(`from`in e?U_t:H_t).has(n)?e[n]=r:(e.extra??=/* @__PURE__ */ new Map).set(n,r)}function WY(e,t,n){n!==void 0&&(typeof n==`string`?e[t]=n:UY(e,n))}function GY(e,t,n){n===void 0?e[t]??=``:WY(e,t,n)}function W_t(e,t){e.labelAttr=void 0,typeof t==`object`?(e.label=``,e.labelAttr=t,UY(e,t)):e.label=t??``}var G_t=class{type=`c4`;c4Type;title;accTitle;accDescr;shapes=[];boundaries=[{alias:`global`,label:`global`,type:`global`,parent:void 0}];rels=[];shapeInRow=4;boundaryInRow=2;shapeIndex=/* @__PURE__ */ new Map;boundaryIndex=/* @__PURE__ */ new Map;relIndex=/* @__PURE__ */ new Map;current=this.boundaries[0];stack=[];setC4Type(e){this.c4Type=e}setTitle(e){this.title=e}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
992
|
+
`)}element(e,t,n,r){let i=typeof n==`string`?t.get(n):void 0;return i===void 0&&(i={alias:``,label:``,parent:void 0},e.push(i),typeof n==`string`?(i.alias=n,t.set(n,i)):(i.aliasAttr=n,UY(i,n))),W_t(i,r),i}addPersonOrSystem(e,t){let n=this.element(this.shapes,this.shapeIndex,t[0],t[1]);GY(n,`descr`,t[2]),this.finishShape(n,e,t,3)}addContainer(e,t){let n=this.element(this.shapes,this.shapeIndex,t[0],t[1]);GY(n,`techn`,t[2]),GY(n,`descr`,t[3]),this.finishShape(n,e,t,4)}addComponent(e,t){this.addContainer(e,t)}finishShape(e,t,n,r){WY(e,`sprite`,n[r]),WY(e,`tags`,n[r+1]),WY(e,`link`,n[r+2]),e.kind=t,e.parent=this.current}boundary(e,t){let n=this.element(this.boundaries,this.boundaryIndex,e[0],e[1]);return e[2]===void 0?n.type=t:WY(n,`type`,e[2]),n}open(e){e.parent=this.current,this.stack.push(this.current),this.current=e}addPersonOrSystemBoundary(e,t=`system`){let n=this.boundary(e,t);WY(n,`tags`,e[3]),WY(n,`link`,e[4]),this.open(n)}addContainerBoundary(e){this.addPersonOrSystemBoundary(e,`container`)}addDeploymentNode(e,t){let n=this.boundary(t,`node`);GY(n,`descr`,t[3]),WY(n,`sprite`,t[4]),WY(n,`tags`,t[5]),WY(n,`link`,t[6]),n.nodeType=e,this.open(n)}popBoundaryParseStack(){this.current=this.stack.pop()??this.boundaries[0]}addRel(e,t){let n=t[0],r=t[1];if(n===void 0||r===void 0||t[2]===void 0)return;let i=typeof n==`string`&&typeof r==`string`,a=i?this.relIndex.get(n)?.get(r):void 0;if(a===void 0){if(a={type:e,from:``,to:``,label:``},this.rels.push(a),i){let e=this.relIndex.get(n);e===void 0&&this.relIndex.set(n,e=/* @__PURE__ */ new Map),e.set(r,a)}typeof n==`string`?a.from=n:a.fromAttr=n,typeof r==`string`?a.to=r:a.toAttr=r}a.type=e,W_t(a,t[2]),GY(a,`techn`,t[3]),GY(a,`descr`,t[4]),WY(a,`sprite`,t[5]),WY(a,`tags`,t[6]),WY(a,`link`,t[7])}getC4Shape(e){return this.shapeIndex.get(e)??this.boundaryIndex.get(e)}updateElStyle(e,t){let n=typeof t[0]==`string`?this.getC4Shape(t[0]):void 0;n!==void 0&&(WY(n,`bgColor`,t[1]),WY(n,`fontColor`,t[2]),WY(n,`borderColor`,t[3]),WY(n,`shadowing`,t[4]),WY(n,`shape`,t[5]),WY(n,`sprite`,t[6]),WY(n,`techn`,t[7]),WY(n,`legendText`,t[8]),WY(n,`legendSprite`,t[9]))}updateRelStyle(e,t){let n=t[0],r=t[1],i=typeof n==`string`&&typeof r==`string`?this.relIndex.get(n)?.get(r):void 0;if(i===void 0)return;WY(i,`textColor`,t[2]),WY(i,`lineColor`,t[3]);let a=t[4],o=t[5];typeof a==`string`?i.offsetX=parseInt(a):a!==void 0&&UY(i,a),typeof o==`string`?i.offsetY=parseInt(o):o!==void 0&&UY(i,o)}updateLayoutConfig(e,t){let n=e=>e===void 0?NaN:parseInt(typeof e==`string`?e:e.value),r=n(t[0]),i=n(t[1]);r>=1&&(this.shapeInRow=r),i>=1&&(this.boundaryInRow=i)}},K_t=/* @__PURE__ */ `$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`.split(`.`),q_t=/* @__PURE__ */ 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]]),KY=[/.*direction\s+TB[^\n]*/y,/.*direction\s+BT[^\n]*/y,/.*direction\s+RL[^\n]*/y,/.*direction\s+LR[^\n]*/y],qY=/[\n\r\u2028\u2029]/g;function J_t(e){let t=e.length,n=[],r=[],i=[],a=0,o=9,s=0,c=!1,l=-2,u=-1,d=0,f=(e,t,a)=>{n.push(e),r.push(t),i.push(a),s=a},p=n=>{for(;n<t&&eq(e.charCodeAt(n));)n++;return n},m=(n,r)=>{let i=e.indexOf(n,r);return i===-1?t:i},h=(n,r)=>{let i=s+n.length;if(!e.startsWith(n,s)||!eq(e.charCodeAt(i)))return!1;let a=++i;for(;i<t;){let t=e.charCodeAt(i);if(t===35||t===10||t===59)break;i++}return i!==a&&(f(r,s,i),!0)};for(;;){if(c){f(0,t,t);break}s>=t&&(c=!0);let n=e.charCodeAt(s);if(a===0){if(s>=t){f(64,t,t);continue}if(l!==-1&&s>=d&&(l<s&&(l=e.indexOf(`direction`,s)),l!==-1&&(u<s&&(qY.lastIndex=s,u=qY.test(e)?qY.lastIndex-1:t),l<u))){let t=!1;for(let n=0;n<4&&!t;n++)KY[n].lastIndex=s,KY[n].test(e)&&(f(2+n,s,KY[n].lastIndex),t=!0);if(t)continue;d=u}if(n===116&&h(`title`,6))continue;if(n===97){if(h(`accDescription`,7))continue;let t=e.startsWith(`accTitle`,s);if(t||e.startsWith(`accDescr`,s)){let n=p(s+8),r=e.charCodeAt(n);if(r===58){f(t?8:10,s,p(n+1)),o=t?9:11,a=7;continue}if(r===123&&!t){s=p(n+1),a=8;continue}}}if(n===37&&e.charCodeAt(s+1)===37){let n=m(`
|
|
993
|
+
`,s+2);for(;n<t&&(e.charCodeAt(n)===10||e.charCodeAt(n)===13);)n++;s=n;continue}if(eq(n)){let n=s,r=-1;for(;n<t;){let t=e.charCodeAt(n);if(!eq(t))break;t===10&&(r=n),n++}r===-1?s=n:f(13,s,r+1);continue}if(n===123){f(62,s,s+1);continue}if(n===125){f(63,s,s+1);continue}if(aq(n)){let n=s+1;for(;n<t&&aq(e.charCodeAt(n));)n++;let r=n-s<=19?q_t.get(e.slice(s,n)):void 0;if(r!==void 0){r>18&&(a=1),f(r,s,n);continue}}f(1,s,s);break}if(a===1){if(s>=t)f(57,t,t);else if(n===40){let t=s+1;for(;e.charCodeAt(t)===32;)t++;e.charCodeAt(t)===44?f(58,s,t+1):s++,a=2}else if(n===41)s++,a=0;else{f(1,s,s);break}}else if(a===2){if(s>=t)continue;if(n===41)s++,a=0;else if(n===44)e.charCodeAt(s+1)===44?f(58,s,s+2):s++;else{let t=s;for(;e.charCodeAt(t)===32;)t++;let n=e.charCodeAt(t);n===34?e.charCodeAt(t+1)===34?f(58,s,t+2):(s=t+1,a=3):n===36?(s=t+1,a=4):f(59,s,m(`,`,s))}}else if(a===3)n===34?(s++,a=2):f(59,s,m(`"`,s));else if(a===4)f(60,s,m(`=`,s)),a=5;else if(a===5){if(s>=t)continue;let r=s+1;if(n===61)for(;e.charCodeAt(r)===32;)r++;if(n!==61||e.charCodeAt(r)!==34){f(1,s,s);break}s=r+1,a=6}else if(a===6){if(s>=t)continue;n===34?(s++,a=2):f(61,s,m(`"`,s))}else a===7?(f(o,s,m(`
|
|
994
|
+
`,s)),a=0):n===125?(s++,a=0):f(12,s,m(`}`,s))}return{types:n,starts:r,ends:i}}var JY=[`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`],Y_t=[`rel`,`birel`,`rel_u`,`rel_d`,`rel_l`,`rel_r`,`rel_b`,`rel`],X_t=[`node`,`nodeL`,`nodeR`],Z_t=`'direction_tb', 'direction_bt', 'direction_rl', 'direction_lr', 'C4_CONTEXT', 'C4_CONTAINER', 'C4_COMPONENT', 'C4_DYNAMIC', 'C4_DEPLOYMENT'`,Q_t=`'STR', 'STR_KEY', 'ATTRIBUTE', 'ATTRIBUTE_EMPTY'`;function $_t(e){return e===6||e===7||e===8||e===10||e===12}function evt(e){return e>=19&&e<=56}function tvt(e,t){let{types:n,starts:r,ends:i}=J_t(e),a=0,o=t=>e.slice(r[t],i[t]),s=t=>{let i=n[a];throw i===1?FK(`c4`,e,r[a],``,!0):FK(`c4`,e,r[a],`Expecting ${t}, got '${K_t[i]}'`)},c=e=>{n[a]!==e&&s(`'${K_t[e]}'`),a++},l=()=>{let e=[];for(;;){let t=n[a];if(t===59)e.push(o(a++).trim());else if(t===58)e.push(``),a++;else if(t===60)a++,n[a]!==61&&s(`'STR_VALUE'`),e.push({key:o(a-1).trim(),value:o(a).trim()}),a++;else break}return e.length===0&&s(Q_t),e},u=e=>{e===6?t.setTitle(o(a++).substring(6)):e===7?t.setAccDescription(o(a++).substring(15)):e===12?t.setAccDescription(o(a++).trim()):(a++,e===8?(n[a]!==9&&s(`'acc_title_value'`),t.setTitle(o(a++).trim())):(n[a]!==11&&s(`'acc_descr_value'`),t.setAccDescription(o(a++).trim())))},d=e=>{a++;let r=l();if(e<=26)t.addPersonOrSystem(JY[e-19],r);else if(e<=32)t.addContainer(JY[e-19],r);else if(e<=38)t.addComponent(JY[e-19],r);else{if(e<=45)return e===39?r.splice(2,0,`ENTERPRISE`):e===40?r.splice(2,0,`SYSTEM`):e===42&&r.splice(2,0,`CONTAINER`),e>=43?t.addDeploymentNode(X_t[e-43],r):e===42?t.addContainerBoundary(r):t.addPersonOrSystemBoundary(r),n[a]===62?(a++,c(13)):n[a]===13?(a++,c(62),n[a]===13&&a++):s(`'NEWLINE', 'LBRACE'`),!0;e<=53?(e===53&&r.splice(0,1),t.addRel(Y_t[e-46],r)):e===54?t.updateElStyle(`update_el_style`,r):e===55?t.updateRelStyle(`update_rel_style`,r):t.updateLayoutConfig(`update_layout_config`,r)}return!1},f=n[a];(f<14||f>18)&&s(Z_t),a++,c(13);let p=0,m=0;for(;;){let e=n[a];if(m===3||m===4){if(e===13){a++,m=2;continue}if(m===3&&evt(e)){m=1;continue}}else if(evt(e)){d(e)?(p++,m=1):m=4;continue}else if($_t(e)&&m!==1){u(e),m=3;continue}else m!==2&&s(`'title', 'accDescription', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'PERSON', 'REL'`);if(p>0)e!==63&&s(`'NEWLINE', 'RBRACE'`),a++,t.popBoundaryParseStack(),p--,m=4;else{e!==64&&s(`'NEWLINE', 'EOF'`),a++,c(0),t.setC4Type(o(0));return}}}var YY=/\s/;function XY(e,t,n,r,i=0){let a=[];for(let o of e.split(`
|
|
995
|
+
`)){let e=Array.from(o);e.length===0&&a.push(``);let s=0;for(;s<e.length;){let o=a=>t.width(e.slice(s,s+a).join(``),n,i)<=r,c=1;for(;c<e.length-s&&o(c);)c=Math.min(e.length-s,c*2);let l=1;for(;l<c;){let e=Math.ceil((l+c)/2);o(e)?l=e:c=e-1}let u=l,d=s+u<e.length;if(d&&!YY.test(e[s+u])){for(let t=u-1;t>0;t--)if(YY.test(e[s+t])){u=t+1;break}}let f=e.slice(s,s+u).join(``);for(a.push(d&&f.trimEnd()||f),s+=u;d&&s<e.length&&YY.test(e[s]);)s++}}e===``&&(a.length=0);let o=a.map(e=>t.width(e,n,i)),s=0;for(let e of o)s=Math.max(s,e);let c=Math.round(n*1.5);return{lines:a.map((e,t)=>[{text:e,style:i,width:o[t]}]),widths:o,width:s,height:a.length*c,size:n,lineHeight:c}}function ZY(e,t,n){if(e.width<=n)return e;let r=[],i=[];for(let a=0;a<e.lines.length;a++){if(e.widths[a]<=n){r.push(e.lines[a]),i.push(e.widths[a]);continue}let o=[],s=0,c=()=>{r.push(o),i.push(s),o=[],s=0};for(let r of e.lines[a])if(r.icon!==void 0)o.length&&s+r.width>n&&c(),o.push(r),s+=r.width;else for(let i of Array.from(r.text)){let a=o[o.length-1],l=a&&a.icon===void 0&&a.style===r.style,u=t.width(l?a.text+i:i,e.size,r.style)-(l?a.width:0);o.length&&s+u>n&&(c(),a=void 0,u=t.width(i,e.size,r.style)),a&&a.icon===void 0&&a.style===r.style?(a.text+=i,a.width+=u):o.push({text:i,style:r.style,width:u}),s+=u}(o.length||!e.lines[a].length)&&c()}let a=0;for(let e of i)a=Math.max(a,e);return{...e,lines:r,widths:i,width:a,height:r.length*e.lineHeight}}function QY(e,t,n,r){let i=vq(e),a=`<text`+yq(r,i),o=``;for(let s=0;s<e.lines.length;s++){let c=e.lines[s],l=n+(s+.5)*e.lineHeight;if(c.some(e=>e.icon!==void 0)){let n=e.widths[s];o+=gq({...e,lines:[c],widths:[n],width:n,height:e.lineHeight},t+n/2,l,r);continue}let u=``;for(let e of c){let t=_q(e.style&~i);u+=t?`<tspan${t}>${pq(e.text)}</tspan>`:pq(e.text)}u!==``&&(o+=`${a} x="${K(t)}" y="${K(l+e.size*.35)}" text-anchor="start" xml:space="preserve">${u}</text>`)}return o}var $Y=28,eX=20,tX=7,nvt=8,rvt=30,nX=88,rX=160,iX=26,ivt=e=>Math.min(12,Math.max(6,e/14)),avt=e=>Math.min(12,e/4);function aX(e,t,n,r,i,a,o,s){let c=0,l=1;if(o===0){if(i<e||i>n)return 1/0}else{let t=(e-i)/o,r=(n-i)/o;c=Math.max(c,Math.min(t,r)),l=Math.min(l,Math.max(t,r))}if(s===0){if(a<t||a>r)return 1/0}else{let e=(t-a)/s,n=(r-a)/s;c=Math.max(c,Math.min(e,n)),l=Math.min(l,Math.max(e,n))}return c<=l?c:1/0}function oX(e,t,n,r,i,a,o,s){let c=o/n,l=s/r,u=(i-e)/n,d=(a-t)/r,f=c*c+l*l,p=2*(c*u+l*d),m=u*u+d*d-1,h=p*p-4*f*m;if(f===0||h<0)return 1/0;let g=(-p-Math.sqrt(h))/(2*f);return g>=0&&g<=1?g:m<=0?0:1/0}function sX(e,t,n,r,i){let{x:a,y:o,w:s,h:c}=e,l=r-t,u=i-n;if(e.form===`person`)return Math.min(aX(a,o+iX,a+s,o+c,t,n,l,u),oX(a+s/2,o+14,13,13,t,n,l,u));if(e.form===`cyl`){let e=ivt(s);return Math.min(aX(a,o+e,a+s,o+c-e,t,n,l,u),oX(a+s/2,o+e,s/2,e,t,n,l,u),oX(a+s/2,o+c-e,s/2,e,t,n,l,u))}if(e.form===`h-cyl`){let e=avt(c);return Math.min(aX(a+e,o,a+s-e,o+c,t,n,l,u),oX(a+e,o+c/2,e,c/2,t,n,l,u),oX(a+s-e,o+c/2,e,c/2,t,n,l,u))}return aX(a,o,a+s,o+c,t,n,l,u)}function ovt(e,t,n,r,i){for(let a=2;a<e.length;a+=2){let o=e[a-2],s=e[a-1];if(aX(t,n,r,i,o,s,e[a]-o,e[a+1]-s)<=1)return!0}return!1}function cX(e,t){return e.x<=t.x&&e.y<=t.y&&e.x+e.w>=t.x+t.w&&e.y+e.h>=t.y+t.h}function svt(e,t,n){let r=e.x+e.w/2,i=e.y+e.h/2,a=t.x+t.w/2,o=t.y+t.h/2,s=cX(e,t);if(s||cX(t,e)){let n=s?e:t,r=s?t:e,i=r.x+r.w/2,a=r.y+r.h/2,o=r.x-n.x,c=n.x+n.w-r.x-r.w,l=r.y-n.y,u=n.y+n.h-r.y-r.h,d=Math.min(o,c,l,u),f=d===o?n.x:d===c?n.x+n.w:i,p=d===o||d===c?a:d===u?n.y+n.h:n.y,m=Math.min(sX(r,f,p,i,a),1),h=f+(i-f)*m,g=p+(a-p)*m;return s?[f,p,h,g]:[h,g,f,p]}let c=r,l=i,u=a,d=o,f=Math.max(e.x,t.x),p=Math.min(e.x+e.w,t.x+t.w),m=Math.max(e.y,t.y),h=Math.min(e.y+e.h,t.y+t.h);f<p?c=u=(f+p)/2:m<h&&(l=d=(m+h)/2);let g=Math.hypot(u-c,d-l)||1,_=-(d-l)/g*n,v=(u-c)/g*n,y=sX(e,u+_,d+v,c+_,l+v),b=sX(t,c+_,l+v,u+_,d+v);return y<=1&&b<=1?(c+=_,l+=v,u+=_,d+=v):(c=r,l=i,u=a,d=o,y=Math.min(sX(e,u,d,c,l),1),b=Math.min(sX(t,c,l,u,d),1)),[u+(c-u)*y,d+(l-d)*y,c+(u-c)*b,l+(d-l)*b]}var lX=6,cvt=3,lvt=12,uvt=class{upright=[];level=[];frames=[[],[]];taken=/* @__PURE__ */ new Map;squeezed=0;free(e,t,n,r){let i=Math.min(n,r),a=Math.max(n,r),o=(e,n)=>{for(let r=0;r<e.length;r+=3)if(Math.abs(e[r]-t)<n&&e[r+1]<a&&e[r+2]>i)return!0;return!1};return!o(e?this.upright:this.level,lX)&&!o(this.frames[+!e],cvt)}crossings(e){let t=0;for(let n=2;n<e.length;n+=2){let r=e[n]===e[n-2],i=r?e[n]:e[n+1],a=Math.min(r?e[n-1]:e[n-2],r?e[n+1]:e[n]),o=Math.max(r?e[n-1]:e[n-2],r?e[n+1]:e[n]),s=r?this.level:this.upright;for(let e=0;e<s.length;e+=3)s[e]>a&&s[e]<o&&s[e+1]<i&&s[e+2]>i&&t++}return t}frame(e){this.frames[0].push(e.x,e.y,e.y+e.h,e.x+e.w,e.y,e.y+e.h),this.frames[1].push(e.y,e.x,e.x+e.w,e.y+e.h,e.x,e.x+e.w)}take(e){for(let t=2;t<e.length;t+=2)e[t]===e[t-2]?this.upright.push(e[t],Math.min(e[t-1],e[t+1]),Math.max(e[t-1],e[t+1])):e[t+1]===e[t-1]&&this.level.push(e[t+1],Math.min(e[t-2],e[t]),Math.max(e[t-2],e[t]))}ports(e,t,n,r,i){let a=this.taken.get(e)??[],o=[];for(let e=0;e<9&&o.length<4;e++){let s=n+(e&1?1:-1)*Math.ceil(e/2)*lvt;if(s<r||s>i)continue;let c=!0;for(let e=0;e<a.length;e+=2)a[e]===t&&Math.abs(a[e+1]-s)<lvt&&(c=!1);c&&o.push(s)}return o.length?o:[n]}claim(e,t,n){let r=this.taken.get(e);r?r.push(t,n):this.taken.set(e,[t,n])}};function dvt(e,t,n){let r=e.length,i=Math.sign(e[2]-e[0]),a=Math.sign(e[3]-e[1]),o=`M${K(e[0]+i*t)},${K(e[1]+a*t)}`;for(let t=2;t<r-2;t+=2){let n=e[t],r=e[t+1],i=Math.sign(n-e[t-2]),a=Math.sign(r-e[t-1]),s=Math.sign(e[t+2]-n),c=Math.sign(e[t+3]-r),l=Math.min(nvt,Math.abs(n-e[t-2]+r-e[t-1])/2,Math.abs(e[t+2]-n+e[t+3]-r)/2);o+=`${i?`H`+K(n-i*l):`V`+K(r-a*l)}Q${K(n)},${K(r)} ${K(n+s*l)},${K(r+c*l)}`}let s=Math.sign(e[r-2]-e[r-4]),c=Math.sign(e[r-1]-e[r-3]);return o+(s?`H`+K(e[r-2]-s*n):`V`+K(e[r-1]-c*n))}function fvt(e,t,n,r){for(let i of t)if(i!==n&&i!==r&&ovt(e,i.x,i.y,i.x+i.w,i.y+i.h))return!1;return!0}function pvt(e,t,n,r,i){let a=e.length;return{d:dvt(e,n,r),sx:e[0],sy:e[1],sdx:-Math.sign(e[2]-e[0]),sdy:-Math.sign(e[3]-e[1]),ex:e[a-2],ey:e[a-1],edx:Math.sign(e[a-2]-e[a-4]),edy:Math.sign(e[a-1]-e[a-3]),x0:e[t],y0:e[t+1],x1:e[t+2],y1:e[t+3],nx:0,ny:0,lean:0,room:rX,...i,points:e}}function mvt(e,t){let n=[],r=(e+t)/2,i=Math.max(tX,(t-e)/4);for(let a=0;a<9;a++){let o=r+(a&1?1:-1)*Math.ceil(a/2)*i;o>=e+lX&&o<=t-lX&&n.push(o)}return n}function hvt(e,t,n,r,i,a){let o=e.x+e.w/2,s=e.y+e.h/2,c=t.x+t.w/2,l=t.y+t.h/2,u,d=(i,a,o)=>{if(!fvt(i,n,e,t))return;for(let e=2;e<i.length;e+=2){let t=i[e]===i[e-2];if(!r.free(t,t?i[e]:i[e+1],t?i[e-1]:i[e-2],t?i[e+1]:i[e]))return}let s=r.crossings(i)*1e6;for(let e=2;e<i.length;e+=2)s+=Math.abs(i[e]-i[e-2])+Math.abs(i[e+1]-i[e-1]);(!u||s<u.cost)&&(u={points:i,cost:s,upright:a,sides:o})};if(e.x+e.w<=t.x||t.x+t.w<=e.x){let n=c>o,i=Math.sign(l-s),a=n?[1,0]:[0,1],f=mvt(n?e.x+e.w:t.x+t.w,n?t.x:e.x);e:for(let n of r.ports(e,a[0],s+i*e.h/4,e.y+8,e.y+e.h-8))for(let s of r.ports(t,a[1],l-i*t.h/4,t.y+8,t.y+t.h-8))for(let r of f){let i=r+(o-r)*Math.min(sX(e,r,n,o,n),1),l=r+(c-r)*Math.min(sX(t,r,s,c,s),1),f=u;if(d([i,n,r,n,r,s,l,s],!0,a),u!==f)break e}}if(e.y+e.h<=t.y||t.y+t.h<=e.y){let n=l>s,i=Math.sign(c-o),a=n?[3,2]:[2,3],f=mvt(n?e.y+e.h:t.y+t.h,n?t.y:e.y);e:for(let n of r.ports(e,a[0],o+i*e.w/4,e.x+8,e.x+e.w-8))for(let o of r.ports(t,a[1],c-i*t.w/4,t.x+8,t.x+t.w-8))for(let r of f){let i=r+(s-r)*Math.min(sX(e,n,r,n,s),1),c=r+(l-r)*Math.min(sX(t,o,r,o,l),1),f=u;if(d([n,i,n,r,o,r,o,c],!1,a),u!==f)break e}}if(!u)return;let{points:f,upright:p,sides:m}=u;return r.take(f),r.claim(e,m[0],p?f[1]:f[0]),r.claim(t,m[1],p?f[7]:f[6]),pvt(f,2,i,a,{room:p?nX:rX})}function gvt(e,t,n,r,i,a,o){if(e===t){let t=Math.min(e.h/2-4,10),n=Math.hypot($Y,t),r=e.x+e.w,i=e.y+e.h/2,s=$Y/n,c=t/n;return{d:`M${K(r+s*a)},${K(i-t-c*a)}C${K(r+$Y)},${K(i-t*2)} ${K(r+$Y)},${K(i+t*2)} ${K(r+s*o)},${K(i+t+c*o)}`,sx:r,sy:i-t,sdx:-s,sdy:c,ex:r,ey:i+t,edx:-s,edy:-c,x0:r+$Y+4,y0:i,x1:r+$Y+4,y1:i,nx:1,ny:0,lean:0,room:64,points:[]}}let[s,c,l,u]=svt(e,t,n),d=s===l,f=!1;if(r&&!cX(e,t)&&!cX(t,e))for(let n of r)n!==e&&n!==t&&aX(n.x,n.y,n.x+n.w,n.y+n.h,s,c,l-s,u-c)<=1&&(f=!0);if(r&&f&&!d&&c!==u){let n=hvt(e,t,r,i,a,o);if(n)return n;i.squeezed++}if(r&&f&&(d||c===u)){let n=n=>{let i=n?-1/0:1/0,a=e=>{let t=d?e.x:e.y;i=n?Math.max(i,t+(d?e.w:e.h)):Math.min(i,t)};a(e),a(t);for(let n of r)n!==e&&n!==t&&aX(n.x,n.y,n.x+n.w,n.y+n.h,s,c,l-s,u-c)<=1&&a(n);return i},f=d?Math.min(e.y,t.y):Math.min(e.x,t.x),p=d?Math.max(e.y+e.h,t.y+t.h):Math.max(e.x+e.w,t.x+t.w),m=(n,i)=>{for(let a of r){if(a===e||a===t)continue;let r=d?a.y<p&&a.y+a.h>f:a.x<p&&a.x+a.w>f,o=d?a.x:a.y,s=o+(d?a.w:a.h);if(r&&(n?s>i:o<i))return!1}return!0},h=e.x+e.w/2,g=e.y+e.h/2,_=t.x+t.w/2,v=t.y+t.h/2,y=Math.sign(d?v-g:_-h),b=a=>{let o=n(a),s=a?1:-1,c=d?+!!a:a?3:2,l=d?i.ports(e,c,g+y*e.h/4,e.y+8,e.y+e.h-8)[0]:i.ports(e,c,h+y*e.w/4,e.x+8,e.x+e.w-8)[0],u=d?i.ports(t,c,v-y*t.h/4,t.y+8,t.y+t.h-8)[0]:i.ports(t,c,_-y*t.w/4,t.x+8,t.x+t.w-8)[0],f=n=>{if(d){let r=n+(h-n)*Math.min(sX(e,n,l,h,l),1),i=n+(_-n)*Math.min(sX(t,n,u,_,u),1);return[r,l,n,l,n,u,i,u]}let r=n+(g-n)*Math.min(sX(e,l,n,l,g),1),i=n+(v-n)*Math.min(sX(t,u,n,u,v),1);return[l,r,l,n,u,n,u,i]},p=f(o+s*eX);for(let n=0;n<=4;n++){let a=o+s*(eX+n*tX),m=f(a);if(fvt(m,r,e,t)&&(p=m,i.free(d,a,l,u)))return{points:p,side:c,p0:l,p1:u,step:n}}return{points:p,side:c,p0:l,p1:u,step:5}},x=d?u>c:l<s,S=m(x,n(x)),C=m(!x,n(!x)),w=b(x),T=S===C?b(!x):void 0,E=e=>i.crossings(e.points)*8+e.step,D=C&&!S||T&&E(T)<E(w)?!x:x,{points:O,side:k,p0:A,p1:j,step:M}=D===x?w:T??b(!x),N=D?1:-1;return M>4&&i.squeezed++,i.take(O),i.claim(e,k,A),i.claim(t,k,j),pvt(O,2,a,o,d?{nx:N,lean:rvt,room:nX}:{room:rX})}let p=Math.hypot(l-s,u-c)||1,m=(l-s)/p,h=(u-c)/p;return(d||c===u)&&i.take([s,c,l,u]),{d:`M${K(s+m*a)},${K(c+h*a)}L${K(l-m*o)},${K(u-h*o)}`,sx:s,sy:c,sdx:-m,sdy:-h,ex:l,ey:u,edx:m,edy:h,x0:s,y0:c,x1:l,y1:u,nx:n?-h:0,ny:n?m:0,lean:0,room:Math.abs(m)>Math.abs(h)?nX:rX,points:[s,c,l,u]}}var uX=216,_vt=64,vvt=14,yvt=12,bvt=100,xvt=88,Svt=eX+8,dX=48,fX=16,pX=10,mX=/* @__PURE__ */ new Map([[`person`,`person`],[`box`,`rect`],[`rounded`,`rect`],[`component`,`rect`],[`cylinder`,`cyl`],[`database`,`cyl`],[`db`,`cyl`],[`queue`,`h-cyl`],[`pipe`,`h-cyl`]]);function Cvt(e){let t=mX.get((e.shape??``).toLowerCase())??mX.get((e.sprite??``).toLowerCase());if(t)return t;if(e.tags)for(let t of e.tags.split(`,`)){let e=mX.get(t.trim().toLowerCase());if(e)return e}let n=e.kind;return n.endsWith(`person`)?`person`:n.endsWith(`_db`)?`cyl`:n.endsWith(`_queue`)?`h-cyl`:`rect`}function wvt(e,t,n,r,i=uX){let a=Cvt(e),o=a===`h-cyl`?36:0,s=a===`person`?iX:a===`cyl`?24:0,c=i-2*vvt-o,l=[UJ(`«`+e.kind.replace(/_/g,` `)+`»`,!1,t,r-1,c),UJ(e.label,!1,t,n,c,1),UJ(e.techn?`[${e.techn}]`:void 0,!1,t,r,c),UJ(e.descr,!1,t,r,c)],u=0,d=l[3].height>0?4:0;for(let e of l)u=Math.max(u,e.width),d+=e.height;return{shape:e,form:a,labels:l,textH:d,x:0,y:0,w:Math.max(i,u+2*vvt+o),h:Math.max(_vt,d+2*yvt+s)}}function Tvt(e,t,n,r,i){let a=0,o=0;for(let s=0;s<e.length;s+=t){let c=Math.min(e.length,s+t),l=0,u=0;for(let t=s;t<c;t++)u=Math.max(u,e[t].h);for(let t=s;t<c;t++){let r=e[t];r.x=l,r.y=o,i&&(r.h=u),l+=r.w+n}a=Math.max(a,l-n),o+=u+r}return[a,e.length>0?o-r:0]}function Evt(e,t,n,r,i,a){let o=i===void 0?Svt:12,s=/* @__PURE__ */ new Map;for(let a of e.boundaries){let e=i===void 0?4e3:Math.max(80,i-2*fX-2*Svt*2),c=a.parent?[UJ(a.label,!1,t,n,e,1),UJ(a.type?`[${a.type}]`:void 0,!1,t,r,e),UJ(a.descr,!1,t,r,e)]:[],l=0,u=0;for(let e of c)l+=e.height,u=Math.max(u,e.width);s.set(a,{boundary:a,kids:[],nodes:[],labels:c,head:l>0?l+pX+6+eX:o,headW:u,headX:fX,x:0,y:0,w:0,h:0,form:`rect`})}let c=s.get(e.boundaries[0]);for(let e of s.values()){let t=e.boundary.parent;t&&s.get(t)?.kids.push(e)}let l=[c],u=/* @__PURE__ */ new Map([[c.boundary,0]]);for(let e=0;e<l.length;e++)for(let t of l[e].kids)u.set(t.boundary,u.get(l[e].boundary)+1),l.push(t);for(let a of e.shapes)if(a.parent){let e=u.get(a.parent)??0,c=i===void 0?uX:Math.max(100,Math.min(uX,i-2*e*o-32));s.get(a.parent)?.nodes.push(wvt(a,t,n,r,c))}let d=Math.max(1,e.shapeInRow),f=Math.max(1,e.boundaryInRow),p=/* @__PURE__ */ new Map;for(let e=l.length-1;e>=0;e--){let t=l[e],n=i===void 0?bvt:a,r=(e,t,n)=>{if(i===void 0)return t;let r=1;for(let t of e)r=Math.max(r,t.w);return Math.max(1,Math.min(t,Math.floor((i+n-2*o)/(r+n))))},[s,u]=Tvt(t.nodes,r(t.nodes,d,n),n,xvt,!0),[m,h]=Tvt(t.kids,r(t.kids,f,dX),dX,dX,!1),g=u>0&&h>0?dX:0,_=t===c?0:o;p.set(t,u+g),t.w=Math.max(s,m,t.headW+2*fX-2*_)+2*_,t.h=(_&&t.head)+u+g+h+_}let m=/* @__PURE__ */ new Map;for(let e of l){let t=e.x+(e===c?0:o),n=e.y+(e===c?0:e.head);for(let r of e.nodes)r.x+=t,r.y+=n,m.set(r.shape,r);for(let r of e.kids)r.x+=t,r.y+=n+p.get(e);e!==c&&m.set(e.boundary,e)}return{order:l,boxes:m}}var Dvt=7,hX=36,gX=24,Ovt=2e3,_X=8,kvt=[.5,.4,.6,.3,.7,.2,.8],Avt=2e6;function vX(e,t,n){let r=[];return e&&r.push(`fill:`+e),t&&r.push(`stroke:`+t),n&&r.push(`color:`+n),pJ(r)}function yX(e,t,n,r,i){return t?Tq(e,Sq(t.includes(`¶ß`)?t.replace(/\ufb02\u00b0\u00b0?/g,`#`).replace(/\u00b6\u00df/g,`;`):t),n,r,i):e}function jvt(e,t,n){return YJ(n,r=>{if(!r)return bX(e,t,n,!1)[0];let[i,a]=bX(e,t,n,!0,hX);for(let r=hX+gX;a>0&&r<=hX+3*gX;r+=gX){let[o,s]=bX(e,t,n,!0,r);s<a&&([i,a]=[o,s])}return i})}function bX(e,t,n,r,i=hX){let a=n.fontSize??16,o=Math.round(a*.8125),s=n.measurer??fq(n.fontFamily),c=n.padding??8,l=[],{order:u,boxes:d}=Evt(e,s,a,o,r?Math.max(80,(n.maxWidth??320)-2*c):void 0,i),f=u[0],p=0,m=0,h=f.w,g=f.h,_=(e,t,n,r)=>{p=Math.min(p,e),m=Math.min(m,t),h=Math.max(h,n),g=Math.max(g,r)},v=[],y=/* @__PURE__ */ new Map;for(let t of e.rels){let n=t.fromAttr?void 0:e.getC4Shape(t.from),r=t.toAttr?void 0:e.getC4Shape(t.to),i=n&&d.get(n),a=r&&d.get(r);if(!i||!a)throw new NK(`C4 rel "${t.from}" -> "${t.to}" references an unknown shape or boundary`,`semantic`,{type:`c4`});v.push(i,a);let o=y.get(i);o||y.set(i,o=/* @__PURE__ */ new Set),o.add(a)}let b=[],x=[];for(let e of u)for(let t of e.nodes)b.push(t),x.push(t.x+_X,t.y+_X,t.x+t.w-_X,t.y+t.h-_X);let S=e.rels.length*(b.length+u.length+3*e.rels.length)<=Avt,C=(e,t,n,r)=>{let i=0;for(let a=0;a<x.length;a+=4){let o=Math.min(n,x[a+2])-Math.max(e,x[a]);if(o<=0)continue;let s=Math.min(r,x[a+3])-Math.max(t,x[a+1]);s>0&&(i+=o*s)}return i},w=e=>e?Math.max(-Ovt,Math.min(Ovt,e)):0,T=``,E=sJ(`arrow_point`),D=new uvt;for(let e of u)e!==f&&D.frame(e);let O=e.rels.map((e,t)=>{let n=v[t*2],r=v[t*2+1],i=vX(void 0,e.lineColor,void 0),a=i.stroke?pq(i.stroke):`var(--_l)`,o=e.type===`birel`||e.type===`rel_b`,s=e.type!==`rel_b`,c=gvt(n,r,n!==r&&y.get(r)?.has(n)===!0?Dvt:0,S?b:void 0,D,o?E:0,s?E:0);return _(Math.min(c.x0,c.x1),Math.min(c.y0,c.y1),Math.max(c.x0,c.x1),Math.max(c.y0,c.y1)),o&&S&&x.push(c.sx-rJ,c.sy-rJ,c.sx+rJ,c.sy+rJ),s&&S&&x.push(c.ex-rJ,c.ey-rJ,c.ex+rJ,c.ey+rJ),T+=`<g class="pele-edge" data-id="${mq(e.from+`-`+e.to)}"${i.line}><path d="${c.d}"/>`+(o?cJ(`arrow_point`,c.sx,c.sy,c.sdx,c.sdy,a):``)+(s?cJ(`arrow_point`,c.ex,c.ey,c.edx,c.edy,a):``)+`</g>`,c});for(let e of u){if(!S||e.headW===0)continue;let t=e.y+pX,n=e.y+e.head-eX,r=1/0;for(let i of[fX,(e.w-e.headW)/2,e.w-fX-e.headW]){let a=0;for(let r of O)ovt(r.points,e.x+i-4,t,e.x+i+e.headW+4,n)&&a++;if(a<r&&(r=a,e.headX=i),a===0)break}x.push(e.x+e.headX-4,t,e.x+e.headX+e.headW+4,n)}let k=``;e.rels.forEach((t,i)=>{let a=O[i],c=t.from+`-`+t.to,u=vX(void 0,void 0,t.textColor),d=UJ((e.c4Type===`C4Dynamic`?i+1+`: `:``)+t.label,!1,s,o,a.room),f=UJ(t.techn?`[${t.techn}]`:void 0,!1,s,o,a.room,2),p=Math.max(d.width,f.width)+8,m=d.height+f.height;if(m===0)return;let h=Math.abs(a.nx)*(p/2)+Math.abs(a.ny)*(m/2)+2,g=a.lean?Math.max(0,Math.min(a.lean,h-14)):h,v=a.nx*g+(r?0:w(t.offsetX)),y=a.ny*g+(r?0:w(t.offsetY)),b=.5;if(S){let e=1/0,t=v!==a.nx*g||y!==a.ny*g;for(let n=0;n<(t?2:1)&&e>0;n++){let t=n?a.nx*g:v,r=n?a.ny*g:y;for(let n of kvt){let i=a.x0+(a.x1-a.x0)*n+t,o=a.y0+(a.y1-a.y0)*n+r,s=C(i-p/2,o-m/2,i+p/2,o+m/2);if(s<e&&(e=s,b=n,v=t,y=r),s===0)break}}}let T=a.x0+(a.x1-a.x0)*b+v,E=a.y0+(a.y1-a.y0)*b+y-m/2;S&&x.push(T-p/2,E,T+p/2,E+m),_(T-p/2,E,T+p/2,E+m),k+=`<g class="pele-edge-label" data-id="${mq(c)}">`+(t.descr?`<title>${mq(t.descr)}</title>`:``)+`<rect x="${K(T-p/2)}" y="${K(E)}" width="${K(p)}" height="${K(m)}" rx="3" fill="var(--_bg)"/>`+yX(gq(d,T,E+d.height/2,u.text)+gq(f,T,E+d.height+f.height/2,` class="pele-c4-techn" fill="var(--_m)"${u.text}`),t.link,c,l,n)+`</g>`});let A=``,j=``;for(let e of u){if(e!==f){let t=e.boundary,r=vX(t.bgColor,t.borderColor,t.fontColor),i=e.x+e.headX,a=e.y+pX,s=QY(e.labels[0],i,a,` class="pele-cluster-label" font-weight="var(--_hw)"${r.text}`);a+=e.labels[0].height,s+=QY(e.labels[1],i,a,` class="pele-c4-type" font-size="${o}" fill="var(--_m)"${r.text}`),a+=e.labels[1].height,s+=QY(e.labels[2],i,a,` class="pele-c4-descr" font-size="${o}" fill="var(--_m)"${r.text}`),A+=`<g class="pele-cluster pele-c4-${t.nodeType?`node`:`boundary`}" data-id="${mq(t.alias)}"><rect x="${K(e.x)}" y="${K(e.y)}" width="${K(e.w)}" height="${K(e.h)}" rx="${dJ}" fill="none" stroke="var(--_b)"${t.nodeType?``:` stroke-dasharray="6 4"`}${r.shape}/>`+yX(s,t.link,t.alias,l,n)+`</g>`}for(let t of e.nodes){let e=t.shape,r=e.kind.startsWith(`external`),i=vX(e.bgColor,e.borderColor,e.fontColor),a=` stroke="var(--_b)"`+(r?` stroke-dasharray="4 3"`:``),{w:s,h:c,form:u,labels:d}=t,f=u===`h-cyl`?-avt(c)/2:0,p=u===`person`?iX/2:u===`cyl`?ivt(s)/2:0,m=` fill="var(--_m)"${i.text}`,h=p-t.textH/2,g=gq(d[0],f,h+d[0].height/2,` class="pele-c4-type" font-size="${o-1}"${m}`);h+=d[0].height,g+=gq(d[1],f,h+d[1].height/2,` class="pele-label" font-weight="var(--_hw)"${i.text}`),h+=d[1].height,g+=gq(d[2],f,h+d[2].height/2,` class="pele-c4-techn" font-size="${o}"${m}`),h+=d[2].height+4,g+=gq(d[3],f,h+d[3].height/2,` class="pele-c4-descr" font-size="${o}"${i.text}`),j+=`<g class="pele-node pele-shape-${u} pele-c4-${e.kind}${r?` pele-c4-external`:``}" data-id="${mq(e.alias)}" transform="translate(${K(t.x+s/2)},${K(t.y+c/2)})">`+yX(LJ(u,s,c,` fill="var(${r?`--_bg`:`--_s`})"${a}${i.shape}`,a+i.line)+g,e.link,e.alias,l,n)+`</g>`}}let M=UJ(e.title,!1,s,a,r?GJ(n):4e3,1),N=M.height>0?M.height+12:0,P=Math.max(h-p,M.width),F=Math.ceil(P+2*c),ee=Math.ceil(g-m+N+2*c),te=c-p+(P-(h-p))/2,I=c+N-m;return[{svg:_J(`c4`,F,ee,a,n,e,gq(M,F/2,c+M.height/2,` class="pele-title" font-weight="var(--_tw)"`)+`<g transform="translate(${K(te)},${K(I)})">`+(A?`<g class="pele-clusters">${A}</g>`:``)+(T?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${T}</g>`:``)+(j?`<g class="pele-nodes">${j}</g>`:``)+(k?`<g class="pele-edge-labels" font-size="${o}">${k}</g>`:``)+`</g>`),width:F,height:ee,links:l},D.squeezed]}var Mvt={type:`c4`,parse(e,t,n){let r=new G_t;return n&&(r.title=n),tvt(e,r),r},render:jvt};function xX(e){let t=0;for(let n=e.indexOf(`~`);n!==-1;n=e.indexOf(`~`,n+1))t++;return t}function Nvt(e){let t=xX(e);if(t<=1)return e;let n=t%2!=0&&e.startsWith(`~`),r=e.split(``),i=[];for(let e=+!!n;e<r.length;e++)r[e]===`~`&&i.push(e);for(let e=0,t=i.length-1;e<t;e++,t--)r[i[e]]=`<`,r[i[t]]=`>`;return r.join(``)}function SX(e){if(!e.includes(`~`))return e;let t=e.split(/(,)/),n=[];for(let e=0;e<t.length;e++){let r=t[e];r===`,`&&e>0&&e+1<t.length&&xX(t[e-1])===1&&xX(t[e+1])===1&&(r=t[e-1]+`,`+t[e+1],e++,n.pop()),n.push(Nvt(r))}return n.join(``)}function Pvt(e){return e===`#`||e===`+`||e===`~`||e===`-`}var Fvt=class{id=``;memberType;visibility=``;classifier=``;parameters=``;returnType=``;constructor(e,t){this.memberType=t,t===`method`&&this.parseMethod(e)||this.parseAttribute(e),this.id=this.id.startsWith(` `)?` `+this.id.trim():this.id.trim()}parseMethod(e){let t=e.length;for(let n=0;n<t;){let r=n;for(;r<t&&!nq(e.charCodeAt(r));)r++;let i=r-1;for(;i>n&&e.charCodeAt(i)!==41;)i--;let a=i-1;for(;a>n&&e.charCodeAt(a)!==40;)a--;if(a>n){let r=e[n],o=Pvt(r)&&a>n+1;o&&(this.visibility=r),this.id=e.slice(o?n+1:n,a),this.parameters=e.slice(a+1,i).trim();let s=i+1,c=``;if(s<t){let t=e[s];(t===`$`||t===`*`||t.trim()===``)&&(c=t.trim(),s++)}let l=s;for(;l<t&&!nq(e.charCodeAt(l));)l++;if(this.returnType=e.slice(s,l).trim(),c===``){let e=this.returnType.slice(-1);(e===`$`||e===`*`)&&(c=e,this.returnType=this.returnType.slice(0,-1))}return this.classifier=c,!0}n=r+1}return this.memberType=`attribute`,!1}parseAttribute(e){let t=e.slice(0,1),n=e.slice(-1);Pvt(t)&&(this.visibility=t),(n===`$`||n===`*`)&&(this.classifier=n),this.id=e.substring(this.visibility===``?0:1,this.classifier===``?e.length:e.length-1)}getDisplayDetails(){let e=this.visibility+SX(this.id);return this.memberType===`method`&&(e+=`(${SX(this.parameters.trim())})`,this.returnType&&(e+=` : `+SX(this.returnType))),{displayText:e.trim(),cssStyle:this.parseClassifier()}}parseClassifier(){return this.classifier===`*`?`font-style:italic;`:this.classifier===`$`?`text-decoration:underline;`:``}},Ivt={LINE:0,DOTTED_LINE:1},CX={AGGREGATION:0,EXTENSION:1,COMPOSITION:2,DEPENDENCY:3,LOLLIPOP:4},Lvt=`classId-`;function wX(e){let t=e.indexOf(`~`);if(t<=0)return{className:e,type:``};let n=e.indexOf(`~`,t+1);return{className:e.slice(0,t),type:e.slice(t+1,n===-1?e.length:n)}}function Rvt(e){let t=e.charCodeAt(0);return wX(t>=48&&t<=57?Lvt+e:e).className}var zvt=class{type=`class`;lineType=Ivt;relationType=CX;direction=`TB`;classes=/* @__PURE__ */ new Map;relations=[];notes=/* @__PURE__ */ new Map;namespaces=/* @__PURE__ */ new Map;interfaces=[];styleClasses=/* @__PURE__ */ new Map;title;accTitle;accDescr;namespaceStack=[];withCssClass=/* @__PURE__ */ new Map;addClass(e){let{className:t,type:n}=wX(e);if(this.classes.has(t))return;let r={id:t,type:n,label:t,cssClasses:`default`,methods:[],members:[],annotations:[],styles:[]};this.classes.set(t,r),this.tag(r,`default`)}tag(e,t){let n=this.withCssClass.get(t);n?n.add(e):this.withCssClass.set(t,/* @__PURE__ */ new Set([e]))}ensure(e){return this.addClass(e),this.classes.get(wX(e).className)}setClassLabel(e,t){this.ensure(e).label=t}addRelation(e){let{type1:t,type2:n}=e.relation;t===CX.LOLLIPOP&&n===`none`?(this.addClass(e.id2),e.id1=this.addInterface(e.id1,e.id2)):n===CX.LOLLIPOP&&t===`none`?(this.addClass(e.id1),e.id2=this.addInterface(e.id2,e.id1)):(this.addClass(e.id1),this.addClass(e.id2)),e.id1=wX(e.id1).className,e.id2=wX(e.id2).className,e.relationTitle1=e.relationTitle1.trim(),e.relationTitle2=e.relationTitle2.trim(),this.relations.push(e)}addInterface(e,t){let n=`interface${this.interfaces.length}`;return this.interfaces.push({id:n,label:e,classId:t}),n}addAnnotation(e,t){this.ensure(e).annotations.push(t)}addMember(e,t){let n=this.ensure(e);if(typeof t!=`string`)return;let r=t.trim();if(r.startsWith(`<<`)&&r.endsWith(`>>`))n.annotations.push(r.substring(2,r.length-2));else if(r.indexOf(`)`)>0){let e=new Fvt(r,`method`);(e.memberType===`method`?n.methods:n.members).push(e)}else r&&n.members.push(new Fvt(r,`attribute`))}addMembers(e,t){if(Array.isArray(t)){t.reverse();for(let n of t)this.addMember(e,n)}}addNote(e,t){let n=this.notes.size,r=`note${n}`;return this.notes.set(r,{id:r,class:t,text:e,index:n}),r}cleanupLabel(e){return(e.startsWith(`:`)?e.substring(1):e).trim()}setCssClass(e,t){for(let n of e.split(`,`)){let e=this.classes.get(Rvt(n));if(e!==void 0){e.cssClasses+=` `+t;for(let n of t.split(` `))this.tag(e,n)}}}defineClass(e,t){for(let n of e){let e=this.styleClasses.get(n);if(e===void 0&&(e={id:n,styles:[],textStyles:[]},this.styleClasses.set(n,e)),!t)continue;for(let n of t)n.includes(`color`)&&e.textStyles.push(n.replace(`fill`,`bgFill`)),e.styles.push(n);let r=this.withCssClass.get(n);if(r===void 0)continue;let i=t.flatMap(e=>e.split(`,`));for(let e of r)for(let t of i)e.styles.push(t)}}setTooltip(e,t){if(t!==void 0)for(let n of e.split(`,`)){let e=this.classes.get(wX(n).className);e&&(e.tooltip=t)}}setLink(e,t,n){let r=RK(t).trim();for(let t of e.split(`,`)){let e=this.classes.get(Rvt(t));e&&(e.link=r?Sq(r):void 0,e.linkTarget=typeof n==`string`?n:`_blank`)}this.setCssClass(e,`clickable`)}setClickEvent(e,t,n){for(let t of e.split(`,`)){let e=this.classes.get(wX(t).className);e&&(e.haveCallback=!0)}this.setCssClass(e,`clickable`)}setDirection(e){this.direction=e}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,``)}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
996
996
|
`)}addNamespace(e,t){let n=this.namespaceStack[this.namespaceStack.length-1],r=n?`${n}.${e}`:e;this.namespaceStack.push(r);let i=this.namespaces.get(r);if(i)return i.explicit=!0,t&&(i.label=t),r;let a=n||void 0,o=n?n.length+1:0;for(;;){let e=r.indexOf(`.`,o),n=e===-1,i=n?r:r.slice(0,e),s=this.namespaces.get(i);if(s===void 0){let c=r.slice(o,n?r.length:e);s={id:i,label:n&&t?t:c,classes:/* @__PURE__ */ new Map,notes:/* @__PURE__ */ new Map,children:/* @__PURE__ */ new Map,parent:a,explicit:n},this.namespaces.set(i,s)}else n&&(s.explicit=!0);let c=a?this.namespaces.get(a):void 0;if(c&&(c.children.has(i)||c.children.set(i,s),s.parent??=a),n)return r;a=i,o=e+1}}popNamespace(){this.namespaceStack.pop()}addClassesToNamespace(e,t,n){let r=this.namespaces.get(e);if(r!==void 0){for(let n of t){let{className:t}=wX(n),i=this.classes.get(t);i!==void 0&&(i.parent=e,r.classes.set(t,i))}for(let t of n){let n=this.notes.get(t);n!==void 0&&(n.parent=e,r.notes.set(t,n))}}}setCssStyle(e,t){let n=this.classes.get(e);if(t&&n)for(let e of t)for(let t of e.split(`,`))n.styles.push(t)}},Bvt=/* @__PURE__ */ `$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`.split(`.`),Vvt=[4,6,4,9,44,45,12,14,15,4,56,4,56],Hvt=[/.*direction\s+TB[^\n]*/y,/.*direction\s+BT[^\n]*/y,/.*direction\s+RL[^\n]*/y,/.*direction\s+LR[^\n]*/y],TX=/[\n\r\u2028\u2029]/g;function Uvt(e){let t=e.length,n=[],r=[],i=[],a=[],o=0,s=0,c=e.indexOf(`direction`),l=-1,u=0,d=(t,a,o)=>(n.push(t),r.push(e.slice(a,o)),i.push(a),s=o,!0),f=e=>{a.push(o),o=e},p=()=>{a.length>0&&(o=a.pop())},m=t=>e.startsWith(t,s)&&!aq(e.charCodeAt(s+t.length)),h=n=>{for(;n<t&&eq(e.charCodeAt(n));)n++;return n},g=n=>{let r=e.indexOf(n,s);return r===-1?t:r},_=n=>{let r=s,i=-1;for(let n=e.charCodeAt(r);r<t&&eq(n);n=e.charCodeAt(++r))n===10&&(i=r);i<0?s=r:(n&&p(),d(3,s,i+1))},v=t=>{switch(t){case 99:if(m(`cssClass`))return d(48,s,s+8);if(m(`callback`))return d(40,s,s+8);if(m(`click`))return d(43,s,s+5);break;case 108:if(m(`link`))return d(41,s,s+4);break;case 110:if(m(`note for`))return d(24,s,s+8);if(m(`note`))return d(25,s,s+4);break;case 60:if(e.charCodeAt(s+1)===60)return d(20,s,s+2);break;case 62:if(e.charCodeAt(s+1)===62)return d(21,s,s+2);break;case 104:if(m(`href`))return d(46,s,s+4)}return!1},y=n=>{if(v(n))return!0;let r=e.charCodeAt(s+1);switch(n){case 34:return f(1),s++,!0;case 126:return f(3),s++,!0;case 96:return f(2),s++,!0;case 95:if(m(`_self`))return d(42,s,s+5);if(m(`_blank`))return d(42,s,s+6);if(m(`_parent`))return d(42,s,s+7);if(m(`_top`))return d(42,s,s+4);break;case 60:return r===124?d(34,s,s+2):d(36,s,s+1);case 124:return r===62&&d(34,s,s+2);case 62:return d(36,s,s+1);case 42:return d(35,s,s+1);case 111:if(!aq(r))return d(33,s,s+1);break;case 40:return r===41&&d(37,s,s+2);case 45:return r===45?d(38,s,s+2):d(52,s,s+1);case 46:return r===46?d(39,s,s+2):d(8,s,s+1);case 58:{let n=s+1;for(;n<t;){let t=e.charCodeAt(n);if(t===58||t===10||t===59)break;n++}return n>s+1?d(10,s,n):r===58&&e.charCodeAt(s+2)===58&&d(19,s,s+3)}case 43:return d(58,s,s+1);case 37:return d(51,s,s+1);case 61:return d(59,s,s+1);case 91:return d(5,s,s+1);case 93:return d(7,s,s+1);case 33:case 35:case 36:case 38:case 39:case 44:case 63:case 92:case 47:return d(60,s,s+1)}if(aq(n)){let t=s+1;for(;aq(e.charCodeAt(t));)t++;return d(27,s,t)}return Nq(n)&&d(53,s,s+1)},b=()=>{if(c===-1||s<u||(c<s&&(c=e.indexOf(`direction`,s)),c===-1)||(l<s&&(TX.lastIndex=s,l=TX.test(e)?TX.lastIndex-1:t),c>=l))return!1;for(let t=0;t<4;t++){let n=Hvt[t];if(n.lastIndex=s,n.test(e))return d(29+t,s,n.lastIndex)}return u=l,!1},x=n=>{if(b())return!0;if(eq(n))return _(!1),!0;switch(n){case 37:if(e.charCodeAt(s+1)===37){let n=g(`
|
|
997
997
|
`);for(;n<t&&(e.charCodeAt(n)===10||e.charCodeAt(n)===13);)n++;return s=n,!0}break;case 97:{let t=e.startsWith(`accTitle`,s);if(!t&&!e.startsWith(`accDescr`,s))break;let n=h(s+8),r=e.charCodeAt(n);if(r===58)return d(t?11:13,s,h(n+1)),f(t?6:7),!0;if(r===123&&!t)return s=h(n+1),f(8),!0;break}case 99:if(m(`classDiagram-v2`))return d(2,s,s+15);if(m(`classDiagram`))return d(2,s,s+12);if(e.startsWith(`call`,s)&&eq(e.charCodeAt(s+4)))return s=h(s+4),f(4),!0;if(m(`classDef`))return d(26,s,s+8);if(m(`class`))return f(9),d(22,s,s+5);break;case 91:if(e.startsWith(`*]`,s+1))return d(55,s,s+3);break;case 115:if(m(`style`))return d(47,s,s+5);break;case 110:if(m(`namespace`))return f(11),d(18,s,s+9);break;case 44:return d(28,s,s+1);case 35:return d(50,s,s+1)}return y(n)||n===58&&d(49,s,s+1)};for(;;){if(s>=t){n.push(Vvt[o]),r.push(``),i.push(t);break}let a=e.charCodeAt(s),c=!0;switch(o){case 0:c=x(a);break;case 9:eq(a)?_(!0):a===125?(p(),p(),d(17,s,s+1)):a===123?(f(10),d(16,s,s+1)):c=y(a);break;case 10:if(a===34)f(1),s++;else if(a===125)p(),d(17,s,s+1);else if(a===91&&e.startsWith(`*]`,s+1))d(55,s,s+3);else if(a===123)d(57,s,s+1);else if(a===10)s++;else{let n=s+1;for(;n<t;){let t=e.charCodeAt(n);if(t===123||t===125||t===10)break;n++}d(23,s,n)}break;case 11:eq(a)?_(!0):a===123?(f(12),d(16,s,s+1)):a===125?p():a===110&&m(`namespace`)?(f(11),d(18,s,s+9)):c=y(a);break;case 12:eq(a)?_(!1):a===125?(p(),d(17,s,s+1)):a===110&&m(`namespace`)?(f(11),d(18,s,s+9)):a===91&&e.startsWith(`*]`,s+1)?d(55,s,s+3):a===99&&m(`class`)?(f(9),d(22,s,s+5)):c=y(a);break;case 1:a===34?(p(),s++):d(6,s,g(`"`));break;case 3:if(a===34)f(1),s++;else{if(v(a))break;a===126?(p(),s++):d(9,s,g(`~`))}break;case 2:if(a===34)f(1),s++;else{if(v(a))break;a===126?(f(3),s++):a===96?(p(),s++):d(54,s,g("`"))}break;case 4:if(a===40){let t=h(s+1);p(),e.charCodeAt(t)===41?s=t+1:(f(5),s++)}else d(44,s,g(`(`));break;case 5:a===41?(p(),s++):d(45,s,g(`)`));break;case 6:case 7:d(o===6?12:14,s,g(`
|
|
998
|
-
`)),p();break;case 8:a===125?(p(),s++):d(15,s,g(`}`))}if(!c)return n.push(1),r.push(``),i.push(s),{types:n,texts:r,starts:i}}return n.push(0),r.push(``),i.push(t),{types:n,texts:r,starts:i}}var EX=61,DX=new Uint8Array(EX);for(let e of[53,27,52])DX[e]=1;var OX=new Uint8Array(EX);for(let e of[27,49,50,47,51,10])OX[e]=1;var kX=new Uint8Array(EX);kX[33]=1,kX[34]=2,kX[35]=3,kX[36]=4,kX[37]=5;var Wvt=`'UNICODE_TEXT', 'NUM', 'ALPHA', 'MINUS', 'BQUOTE_STR'`;function Gvt(e,t){let{types:n,texts:r,starts:i}=Uvt(e),a=0,o=t=>{let r=n[a];throw r===1?FK(`class`,e,i[a],``,!0):FK(`class`,e,i[a],`Expecting ${t}, got '${Bvt[r]}'`)},s=e=>(n[a]!==e&&o(`'${Bvt[e]}'`),r[a++]),c=()=>(DX[n[a]]===0&&o(`'UNICODE_TEXT', 'NUM', 'ALPHA', 'MINUS'`),r[a++]),l=e=>{let t=``;for(;;){if(n[a]===54){t+=r[a++];break}DX[n[a]]===0&&o(Wvt),t+=r[a++];let e=n[a];if(e===8)t+=`.`,a++;else if(DX[e]===0&&e!==54)break}return e&&n[a]===9&&(t+=`~`+r[a++]+`~`),t},u=()=>{a++;let e=s(6);return s(7),e},d=()=>{n[a]!==23&&o(`'STRUCT_STOP', 'MEMBER'`);let e=[];for(;n[a]===23;)e.push(r[a++]);return s(17),e.reverse()},f=()=>{a++;let e=l(!0);switch(t.addClass(e),n[a]===5&&t.setClassLabel(e,u()),n[a]){case 19:{a++;let r=c();t.setCssClass(e,r),n[a]===16&&(a++,t.addMembers(e,d()));break}case 16:a++,n[a]===17?a++:t.addMembers(e,d());break;case 20:{a++;let r=c();s(21),t.addAnnotation(e,r),n[a]===16&&(a++,n[a]===17?a++:t.addMembers(e,d()));break}}return e},p=()=>{if(n[a++]===25)return t.addNote(s(6));let e=l(!0);return t.addNote(s(6),e)},m=()=>{let e=[];for(;;){a++;let r=l(!1),i=n[a]===5?t.addNamespace(r,u()):t.addNamespace(r);s(16),n[a]===3&&a++,e.push({id:i,classes:[],notes:[]});let c=!0;for(;c;){let r=e[e.length-1],i=n[a];if(i===18)break;for(i===22?r.classes.push(f()):i===25||i===24?r.notes.push(p()):o(`'NAMESPACE', 'CLASS', 'NOTE_FOR', 'NOTE'`);;){if(n[a]===3){let e=n[a+1];if(e===18||e===22||e===25||e===24){a++;break}a++}s(17);let r=e.pop();if(t.addClassesToNamespace(r.id,r.classes,r.notes),t.popNamespace(),e.length===0){c=!1;break}}}if(e.length===0)return}},h=()=>{let e=kX[n[a]];return e===0?`none`:(a++,e-1)},g=()=>{let e=l(!0),i=n[a];if(i===10){t.addMember(e,t.cleanupLabel(r[a++]));return}let s=`none`;if(i===6)s=r[a++],i=n[a];else if(kX[i]===0&&i!==38&&i!==39)return;let c=h();i=n[a],i!==38&&i!==39&&o(`'AGGREGATION', 'EXTENSION', 'COMPOSITION', 'DEPENDENCY', 'LOLLIPOP', 'LINE', 'DOTTED_LINE'`),a++;let u=h(),d=n[a]===6?r[a++]:`none`,f={id1:e,id2:l(!0),relation:{type1:c,type2:u,lineType:i===38?0:1},relationTitle1:s,relationTitle2:d};n[a]===10&&(f.title=t.cleanupLabel(r[a++])),t.addRelation(f)},_=()=>{let e=[];for(;;){OX[n[a]]===0&&o(`'ALPHA', 'NUM', 'COLON', 'UNIT', 'SPACE', 'BRKT', 'STYLE', 'PCT', 'LABEL'`);let t=r[a++];for(;OX[n[a]]===1;)t+=r[a++];if(e.push(t),n[a]!==28)return e;a++}},v=e=>{n[a]===6&&t.setTooltip(e,r[a++])},y=e=>{let i=s(6),o=n[a]===6?r[a++]:void 0;n[a]===42?t.setLink(e,i,r[a++]):t.setLink(e,i),o!==void 0&&t.setTooltip(e,o)},b=()=>{let e=n[a];switch(e){case 53:case 27:case 52:case 54:g();return;case 18:m();return;case 22:f();return;case 23:a++;return;case 20:{a++;let e=c();s(21),t.addAnnotation(l(!0),e);return}case 40:{a++;let e=l(!0);t.setClickEvent(e,s(6)),v(e);return}case 41:a++,y(l(!0));return;case 43:{a++;let e=l(!0);if(n[a]===46){a++,y(e);return}let i=s(44);n[a]===45?t.setClickEvent(e,i,r[a++]):t.setClickEvent(e,i),v(e);return}case 47:{a++;let e=s(27);t.setCssStyle(e,_());return}case 48:{a++;let e=s(6);t.setCssClass(e,s(27));return}case 25:case 24:p();return;case 26:{a++;let e=[s(27)];for(;n[a]===28;)a++,e.push(s(27));t.defineClass(e,_());return}case 29:case 30:case 31:case 32:a++,t.setDirection(e===29?`TB`:e===30?`BT`:e===31?`RL`:`LR`);return;case 11:a++,t.setAccTitle(s(12).trim());return;case 13:a++,t.setAccDescription(s(14).trim());return;case 15:t.setAccDescription(r[a++].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'`)},x=n[a]===2;for(x&&(a++,s(3));b(),!(n[a]!==3||(a++,n[a]===4||n[a]===0)););x&&s(4),s(0)}function Kvt(e,t,n,r,i,a,o){let s=WJ(e,!1,t,n,4e3,1);if(s.height===0)return{width:i,height:a,content:o};let c=s.height+12,l=Math.max(i,Math.ceil(s.width+2*r));return{width:l,height:Math.ceil(a+c),content:gq(s,l/2,r+s.height/2,` class="pele-title" font-weight="var(--_tw)"`)+`<g transform="translate(${K((l-i)/2)},${K(c)})">${o}</g>`}}var qvt=[`aggregation`,`extension`,`composition`,`dependency`,`lollipop`];function Jvt(e){return typeof e==`number`&&qvt[e]||`none`}function Yvt(e,t=!0){let n=[],r=[],i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Map,o=/* @__PURE__ */ new Map,s=/* @__PURE__ */ new Map,c=n=>{if(t||n===void 0)return n;let r=[],i=n,a;for(;i;){if(s.has(i)){a=s.get(i);break}let t=e.namespaces.get(i);if(t===void 0)break;if(t.explicit){a=i;break}r.push(i),i=t.parent}for(let e of r)s.set(e,a);return a},l=e=>e===void 0?-1:i.get(e)??-1;for(let r of e.namespaces.values())!t&&!r.explicit||(i.set(r.id,n.length),n.push({id:r.id,label:t?r.label:r.id,isGroup:!0,shape:`rect`,parentId:t?r.parent:void 0,parent:-1}));for(let e of n)e.parent=l(e.parentId);let u=0;for(let t of e.classes.values()){let e=c(t.parent);a.set(t.id,n.length),n.push({id:t.id,label:t.label,isGroup:!1,shape:`classBox`,parentId:e,parent:l(e),classNode:t,colorIndex:u++})}for(let t of e.notes.values()){let e=c(t.parent),i=t.class===void 0?void 0:a.get(t.class);i!==void 0&&r.push({id:`edgeNote${t.index}`,start:t.id,end:n[i].id,source:n.length,target:i,label:void 0,arrowTypeStart:`none`,arrowTypeEnd:`none`,startLabelRight:``,endLabelLeft:``,pattern:`dotted`,classes:`relation`}),n.push({id:t.id,label:t.text,isGroup:!1,shape:`note`,parentId:e,parent:l(e)})}for(let t of e.interfaces){let e=a.get(t.classId);o.set(t.id,n.length),n.push({id:t.id,label:t.label,isGroup:!1,shape:`interface`,parentId:void 0,parent:e===void 0?-1:n[e].parent})}let d=0;for(let t of e.relations){d++;let{type1:e,type2:n}=t.relation,i=e===CX.LOLLIPOP&&n===`none`?o:a,s=i===a&&n===CX.LOLLIPOP&&e===`none`?o:a;r.push({id:`id_${t.id1}_${t.id2}_${d}`,start:t.id1,end:t.id2,source:i.get(t.id1)??-1,target:s.get(t.id2)??-1,label:t.title,arrowTypeStart:Jvt(e),arrowTypeEnd:Jvt(n),startLabelRight:t.relationTitle1===`none`?``:t.relationTitle1,endLabelLeft:t.relationTitle2===`none`?``:t.relationTitle2,pattern:t.relation.lineType===1?`dashed`:`solid`,classes:`relation`})}return{nodes:n,edges:r}}var AX=12,jX=16,MX=6,NX=5;function Xvt(e){switch(e){case`extension`:return AX;case`composition`:case`aggregation`:return jX;case`lollipop`:return 2*NX;case`dependency`:return sJ(`arrow_point`)}return 0}function Zvt(e,t,n,r,i,a){let o=-i,s=r;switch(e){case`extension`:{let e=t-r*AX,a=n-i*AX;return`<path class="pele-marker" d="M${K(t)},${K(n)}L${K(e+o*MX)},${K(a+s*MX)}L${K(e-o*MX)},${K(a-s*MX)}Z" stroke-linejoin="round"/>`}case`composition`:case`aggregation`:{let c=t-r*jX/2,l=n-i*jX/2,u=MX-1;return`<path class="pele-marker" d="M${K(t)},${K(n)}L${K(c+o*u)},${K(l+s*u)}L${K(t-r*jX)},${K(n-i*jX)}L${K(c-o*u)},${K(l-s*u)}Z" stroke-linejoin="round"${e===`composition`?` fill="${a}"`:``}/>`}case`lollipop`:return`<circle class="pele-marker" cx="${K(t-r*NX)}" cy="${K(n-i*NX)}" r="${NX}"/>`;case`dependency`:return cJ(`arrow_point`,t,n,r,i,a)}return``}var Qvt=40,$vt=16,eyt=56,PX=20,tyt=26,FX=12,IX=8,nyt=6,ryt=10,iyt=64,LX=8,RX=`var(--_l)`,ayt=/* @__PURE__ */ new Set([`_self`,`_blank`,`_parent`,`_top`]);function oyt(e,t,n){let r=e[t];return typeof r==`number`&&r>0?Math.min(r,2e3):n}var zX=[],BX=[];function syt(e,t,n){let r=RK(e.getDisplayDetails().displayText).trim();return{text:r,width:t.width(r,n,e.classifier===`*`?2:0),classifier:e.classifier}}function cyt(e,t,n){let r=r=>XJ(n,i=>lyt(e,t,n,r,i));return YJ(e.direction)?JJ(n,r):r(!1)}function lyt(e,t,n,r,i){let a=t.class??{},o=Yvt(e,a.hierarchicalNamespaces!==!1),s=a.hideEmptyMembersBox===!0,c=n.fontSize??16,l=Math.round(c*.875),u=Math.round(c*.8),d=Math.round(u*1.4),f=n.measurer??fq(n.fontFamily),p=n.padding??8,m=r?`TB`:Xq(e.direction),h=/* @__PURE__ */ new Map,g=/* @__PURE__ */ new Map,_=/* @__PURE__ */ new Map,v=e=>{let t=h.get(e);if(t===void 0){let n=mJ([e]);t=n.shape===``&&n.text===``?``:e.slice(0,e.indexOf(`:`)).trim().toLowerCase(),h.set(e,t)}t!==``&&_.set(t,e)},y=t=>{_.clear();let n=g.get(t.cssClasses);if(n===void 0){for(let n of t.cssClasses.split(` `)){let t=e.styleClasses.get(n);if(t)for(let e of t.styles)for(let t of e.split(`,`))v(t)}n=[..._],g.set(t.cssClasses,n)}else for(let[e,t]of n)_.set(e,t);for(let e of t.styles)v(e);return mJ(_.size===0?BX:[..._.values()])},b=new Int32Array(o.nodes.length);for(let e of o.nodes)e.parent>=0&&b[e.parent]++;let x=new Uint8Array(o.nodes.length);for(let e of o.edges){if(e.source<0||e.target<0)continue;let t=o.nodes[e.source].parent,n=o.nodes[e.target].parent;if(t!==n){for(let e=t;e>=0&&x[e]===0;e=o.nodes[e].parent)x[e]=1;for(let e=n;e>=0&&x[e]===0;e=o.nodes[e].parent)x[e]=1}}let S=[],C=[];o.nodes.forEach((e,t)=>{let n,r;if(e.isGroup){let a=WJ(e.label,!1,f,c,4e3);n=w(e,a,0,0,c),b[t]>0?(r=Qq(0,0),r.isGroup=!0,r.padX=PX,r.padTop=a.height>0?a.height+16:PX,r.padBottom=PX,r.minW=a.width+2*PX-12+(x[t]===1&&!i?Math.min(a.width+24,240):0)):(n.w=Math.max(a.width+2*PX,80),n.h=a.height+2*PX,r=Qq(n.w,n.h))}else if(e.classNode)n=T(e,e.classNode),r=Qq(n.w,n.h);else if(e.shape===`note`){let t=WJ(e.label,!0,f,l,260);n=w(e,t,Math.max(t.width+2*FX,40),t.height+2*IX,l),r=Qq(n.w,n.h)}else{let t=WJ(e.label,!1,f,l,200);n=w(e,t,Math.max(t.width,12)+4,Math.max(t.height,12),l),r=Qq(n.w,n.h)}r.parent=e.parent,r.seq=t,S.push(n),C.push(r)});function w(e,t,n,r,i){return{node:e,style:mJ(BX),label:t,w:n,h:r,loops:0,annotations:BX,attributes:zX,methods:zX,titleH:0,attributesH:0,fontSize:i}}function T(e,t){let n=y(t),r=n.fontSize??c,i=Math.round(r*.875),a=Math.round(i*1.5),o=t.type?`<`+SX(t.type).replace(/</g,`<`).replace(/>/g,`>`)+`>`:``,l=WJ(t.label+o,!1,f,r,4e3,1|(n.italic?2:0)),p=t.annotations.length>0?t.annotations.map(e=>`«${RK(e).trim()}»`):BX,m=t.members.length>0?t.members.map(e=>syt(e,f,i)):zX,h=t.methods.length>0?t.methods.map(e=>syt(e,f,i)):zX,g=l.width;for(let e of p)g=Math.max(g,f.width(e,u,0));for(let e of m)g=Math.max(g,e.width);for(let e of h)g=Math.max(g,e.width);let _=!(s&&m.length===0&&h.length===0),v=e=>_?e>0?2*nyt+e*a:ryt:0,b=2*IX+p.length*d+Math.max(l.height,Math.round(r*1.5)),x=v(m.length);return{node:e,style:n,label:l,w:Math.max(g+2*FX,iyt),h:b+x+v(h.length),loops:0,annotations:p,attributes:m,methods:h,titleH:b,attributesH:x,fontSize:r}}let E=[],D=[],O=[],k=[],A=[],j=new Float64Array(S.length*4),M=(e,t,n)=>{j[e*4+t]++,n>j[e*4+t+1]&&(j[e*4+t+1]=n)};for(let e of o.edges){if(e.source<0||e.target<0)continue;let t=WJ(e.label,!0,f,l,200),n=e.startLabelRight?f.width(RK(e.startLabelRight),u,0):0,r=e.endLabelLeft?f.width(RK(e.endLabelLeft),u,0):0;e.source===e.target?(S[e.source].loops++,C[e.source].w+=2*(tyt+(t.width>0?t.width+12:0))):(M(e.source,0,n),M(e.target,2,r)),k.push(n),A.push(r),D.push(e),O.push(t),E.push({src:e.source,dst:e.target,minlen:1,labelW:t.width>0?t.width+12:0,labelH:t.height>0?t.height+4:0,route:[],labelX:0,labelY:0})}if(m===`TB`||m===`BT`)for(let e=0;e<S.length;e++){if(!S[e].node.classNode)continue;let t=0;for(let n=0;n<4;n+=2){let r=j[e*4+n],i=j[e*4+n+1];r>1&&(t=Math.max(t,(r-1)*(i>0?i+24:14)+24))}t=Math.min(t,480),t>S[e].w&&(C[e].w+=t-S[e].w,S[e].w=t)}let N=!1;for(let e=0;e<D.length&&!N;e++)N=k[e]>0||A[e]>0;let P=eJ(C,E,m,{nodeSep:oyt(a,`nodeSpacing`,Qvt),edgeSep:$vt,rankSep:oyt(a,`rankSpacing`,N?eyt+16:eyt),portSep:20,apart:!0}),F=/* @__PURE__ */ new Map,ee=[],te=(e,t,n,r,i)=>{let a=e.route,o=C[n],s=BJ(a,t,o);if(s<0)return;let c=(o.w-S[n].w)/2;s===1?a[t]-=c:s===3&&(a[t]+=c);let l=s&1,u=a[(t===0?3:t-3)+l],d=u-a[t+l],f={route:a,at:t,toward:u,order:i,room:r,side:s,after:l?d>0:d>=0},p=n*4+s,m=F.get(p);return m?m.push(f):F.set(p,[f]),f},I=[],ne=[];for(let e=0;e<E.length;e++){let t=E[e],n=t.src!==t.dst&&t.route.length>=6;I.push(n?te(t,0,t.src,k[e],e):void 0),ne.push(n?te(t,t.route.length-3,t.dst,A[e],e):void 0)}let re=(e,t,n)=>{for(let r=C[e].parent,i=0;r>=0&&i<1e4;r=C[r].parent,i++){let e=C[r],i=Math.abs(t-e.x),a=Math.abs(n-e.y);if(Math.abs(a-e.h/2)<.5&&i<=e.w/2+.5||Math.abs(i-e.w/2)<.5&&a<=e.h/2+.5)return!0}return!1},ie=[];for(let[e,t]of F){if(t.length<2)continue;let n=e>>2,r=e&1,i=r?S[n].h:S[n].w;t.sort((e,t)=>e.toward-t.toward||e.order-t.order);let a=0;for(let e=0;e+1<t.length;e++){let n=t[e],i=t[e+1],o=r?20:24;n.room>0&&n.after&&(o+=r?d+6:n.room),i.room>0&&!i.after&&(o+=r?d+6:i.room),ie[e]=o,a+=o}let o=Math.min(1,(i-24)/a);if(o<=0)continue;let s=(r?C[n].y:C[n].x)-a*o/2;for(let e=0;e<t.length;e++){let{route:i,at:a}=t[e],c=a===0?3:-3,l=a+c,u=-1;for(let e=l;e>=0&&e<i.length&&Math.abs(i[e+r]-i[l+r])<.5;e+=c)if(re(n,i[e],i[e+1])){u=e;break}if(u>=0&&Math.abs(i[l+r]-s)<=24)for(let e=l;e!==u+c;e+=c)i[e+r]=s;i[a+r]=s,s+=ie[e]*o}}let ae=(e,t,n,r)=>{if(t===void 0||n<=0)return;let i=t.side&1,a=r?0:e.length-3,o=a+1-i,s=Math.abs(e[(r?3:a-3)+1-i]-e[o]),c=Math.min(i?n+10:d+6,s*.35);if(c<4)return;let l=[e[a],e[a+1],e[a+2]];l[1-i]+=(t.side===0||t.side===3?-1:1)*c,e.splice(r?3:a,0,l[0],l[1],l[2])};for(let e=0;e<E.length;e++)ae(E[e].route,I[e],k[e],!0),ae(E[e].route,ne[e],A[e],!1);let L=0,oe=0,se=P.width,ce=P.height,le=(e,t,n,r,i,a)=>{if(!e)return;let o=n,s=r;i&1?(o+=(i===3?-1:1)*(5+t/2),s+=(a?1:-1)*(7+d/2)):(o+=(a?1:-1)*(9+t/2),s+=(i===0?-1:1)*(3+d/2)),ee.push({text:RK(e),x:o,y:s}),L=Math.min(L,o-t/2),se=Math.max(se,o+t/2),oe=Math.min(oe,s-d/2),ce=Math.max(ce,s+d/2)},ue=/* @__PURE__ */ new Map,de=new Int32Array(E.length);for(let e=0;e<E.length;e++){let t=E[e],n=D[e],r=t.route;if(t.src===t.dst){let r=ue.get(t.src)??0;ue.set(t.src,r+1),de[e]=r;let i=C[t.src],a=S[t.src],o=i.x+a.w/2,s=Math.min(a.h/2-4,8+r*6);le(n.startLabelRight,k[e],o,i.y-s,1,!1),le(n.endLabelLeft,A[e],o,i.y+s,1,!0)}else if(r.length>=6){let t=r.length-3,i=I[e],a=ne[e];le(n.startLabelRight,k[e],r[0],r[1],i?i.side:2,!i||i.after),le(n.endLabelLeft,A[e],r[t],r[t+1],a?a.side:0,!a||a.after)}}let fe=p-L,pe=p-oe,me=Math.ceil(se-L+2*p),he=Math.ceil(ce-oe+2*p),ge=[],_e=/* @__PURE__ */ new Map;if(o.nodes.length>0&&o.nodes[0].isGroup)for(let e of E)tJ(_e,e.route);let ve=``,ye=``,be=``;for(let e=0;e<S.length;e++){let t=S[e],r=C[e],i=t.node,a=r.x+fe,s=r.y+pe,c=mq(i.id),u=r.isGroup?r.w:t.w,d=r.isGroup?r.h:t.h;if(i.isGroup){let n=r.isGroup?nJ(r,t.label.width,_e,PX):r.x,i=s-d/2+8+t.label.height/2,l=` class="pele-cluster-label" fill="var(--_m)"`,f=r.isGroup&&ght(r,t.label.width,n,_e);f&&(ye+=_ht(t.label,n+fe,i,l,c,o.nodes,e)),ve+=`<g class="pele-cluster pele-namespace" data-id="${c}"><rect x="${K(a-u/2)}" y="${K(s-d/2)}" width="${K(u)}" height="${K(d)}" rx="${fJ}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"/>`+(f?``:gq(t.label,n+fe,i,l))+`</g>`;continue}let f=` transform="translate(${K(a)},${K(s)})"`;if(i.classNode)be+=xe(t,i.classNode,c,f);else if(i.shape===`note`){let e=u/2,r=-d/2;be+=`<g class="pele-node pele-note" data-id="${c}"${f}><path d="M${K(-e)},${K(r)}H${K(e-LX)}L${K(e)},${K(r+LX)}V${K(-r)}H${K(-e)}Z" fill="var(--_a)" stroke="var(--_b)" stroke-linejoin="round"/><path d="M${K(e-LX)},${K(r)}V${K(r+LX)}H${K(e)}" fill="none" stroke="var(--_b)" stroke-linejoin="round"/>`+gq(t.label,0,0,` class="pele-label" font-size="${l}"`,n.icons)+`</g>`}else be+=`<g class="pele-node pele-interface" data-id="${c}"${f}>`+gq(t.label,0,0,` class="pele-label" font-size="${l}"`,n.icons)+`</g>`}function xe(e,t,r,i){let{w:a,h:o,style:s}=e,l=-a/2,f=-o/2,p=Math.round(e.fontSize*.875),m=Math.round(p*1.5),h=`<rect x="${K(l)}" y="${K(f)}" width="${K(a)}" height="${K(o)}" rx="${fJ}" fill="var(--_s)" stroke="var(--_b)"${s.shape}/>`,g=f+e.titleH,_=g+e.attributesH;if(o>e.titleH){let e=s.stroke?` style="stroke:${pq(s.stroke)}"`:``;h+=`<path class="pele-divider" d="M${K(l)},${K(g)}H${K(-l)}M${K(l)},${K(_)}H${K(-l)}" fill="none" stroke="var(--_b)"${e}/>`}let v=f+IX;for(let t of e.annotations)h+=`<text class="pele-annotation" x="0" y="${K(v+d/2+u*.35)}" text-anchor="middle" font-size="${u}" fill="var(--_m)">${pq(t)}</text>`,v+=d;let y=e.fontSize===c?``:` font-size="${K(e.fontSize)}"`;h+=gq(e.label,0,(v+g-IX)/2,` class="pele-label"${y} font-weight="var(--_hw)"${s.text}`,n.icons);let b=(e,t,n)=>{let r=``,i=n+nyt+m/2+p*.35;for(let n of e){let e=n.classifier===`$`?` pele-static"${s.text?s.text.slice(0,-1)+`text-decoration:underline"`:` style="text-decoration:underline"`}`:n.classifier===`*`?` pele-abstract" font-style="italic"${s.text}`:`"${s.text}`;r+=`<text class="pele-member pele-${t}${e} x="${K(l+FX)}" y="${K(i)}">${pq(n.text)}</text>`,i+=m}return r};return(e.attributes.length>0||e.methods.length>0)&&(h+=`<g class="pele-members" font-size="${p}">${b(e.attributes,`attribute`,g)}${b(e.methods,`method`,_)}</g>`),t.tooltip&&(h=`<title>${mq(t.tooltip)}</title>`+h),t.link&&(h=Tq(h,t.link,t.id,ge,n,t.linkTarget&&ayt.has(t.linkTarget)?` target="${t.linkTarget}"`:``)),`<g class="pele-node pele-class${hJ(t.cssClasses.replace(/^default\s?/,``))}" data-id="${r}"${i}>${h}</g>`}let Se=``,Ce=``;for(let e=0;e<E.length;e++){let t=E[e],r=D[e],i=O[e],a=r.arrowTypeStart,o=r.arrowTypeEnd,s=Xvt(a),c=Xvt(o),l;if(t.src===t.dst){let n=C[t.src],r=S[t.src],i=de[e],a=n.x+fe+r.w/2,o=n.y+pe,u=Math.min(r.h/2-4,8+i*6),d=tyt+i*8;l={d:`M${K(a+s)},${K(o-u)}C${K(a+d+s)},${K(o-u)} ${K(a+d+c)},${K(o+u)} ${K(a+c)},${K(o+u)}`,sx:a,sy:o-u,sdx:-1,sdy:0,ex:a,ey:o+u,edx:-1,edy:0},t.labelX=n.x+r.w/2+d+4+t.labelW/2,t.labelY=n.y}else{let e=t.route;for(let t=0;t<e.length;t+=3)e[t]+=fe,e[t+1]+=pe;l=oJ(e,void 0,s,c)}let u=r.pattern===`dashed`?` stroke-dasharray="6 4"`:r.pattern===`dotted`?` stroke-dasharray="2 4"`:``;if(Se+=`<g class="pele-edge${r.pattern===`dotted`?` pele-note-edge`:` pele-relation`}" data-id="${mq(r.id)}"><path d="${l.d}"${u}/>`+Zvt(a,l.sx,l.sy,l.sdx,l.sdy,RX)+Zvt(o,l.ex,l.ey,l.edx,l.edy,RX)+`</g>`,i.width>0){let e=t.labelX+fe,a=t.labelY+pe;Ce+=lJ(r.id,i,e,a,``,n.icons)}}let we=``;for(let e of ee)we+=`<text class="pele-cardinality" x="${K(e.x+fe)}" y="${K(e.y+pe+u*.35)}" text-anchor="middle">${pq(e.text)}</text>`;let Te=Kvt(e.title,f,c,p,me,he,(ve?`<g class="pele-clusters">${ve}</g>`:``)+(Se?`<g class="pele-edges" fill="none" stroke="${RX}" stroke-linecap="round">${Se}</g>`:``)+(ye?`<g class="pele-cluster-titles">${ye}</g>`:``)+(Ce?`<g class="pele-edge-labels" font-size="${l}">${Ce}</g>`:``)+(we?`<g class="pele-cardinalities" font-size="${u}" fill="var(--_m)">${we}</g>`:``)+`<g class="pele-nodes">${be}</g>`);return{svg:vJ(`class`,Te.width,Te.height,c,n,e,Te.content),width:Te.width,height:Te.height,links:ge}}var uyt={type:`class`,parse(e,t,n){let r=new zvt;return n&&(r.title=n),Gvt(e,r),r},render:cyt},dyt=class{domains=/* @__PURE__ */ new Map;transitions=[];setDomains(e){if(e)for(let t of e){let e=t.domain;this.domains.set(e,{name:e,items:(t.items??[]).map(e=>({label:e.label}))})}}setTransitions(e){e&&(this.transitions=e.filter(e=>e.from!==e.to).map(e=>({from:e.from,to:e.to,label:e.label||void 0})))}};function fyt(e,t){let n=new dyt;return n.setDomains(e.domains),n.setTransitions(e.transitions),{type:`cynefin`,title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,``):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
|
|
999
|
-
`):void 0,domains:n.domains,transitions:n.transitions}}var pyt=[{name:`cynefin-beta:`,pattern:`cynefin-beta:`},hY(`cynefin-beta`),{name:`-->`,pattern:`-->`},{name:`:`,pattern:`:`},{name:`DOMAIN_NAME`,pattern:/complex|complicated|clear|chaotic|confusion/y},oY,sY,cY,lY,uY,dY,fY,pY,mY];function myt(e){let t=new xY(aY(e,pyt,`cynefin`),pyt,`cynefin`),n={$type:`Cynefin`,domains:[],transitions:[]},r=()=>{for(;t.kinds[t.i]===9;)t.i++},i=()=>{t.kind!==-1&&(t.kind!==9&&t.fail(`a line break or the end of input`),r())};for(r(),t.kind!==1&&t.kind!==0&&t.fail(`'cynefin-beta'`),t.i++;t.kind!==-1;)switch(t.kind){case 9:t.i++;break;case 5:n.accDescr=yY(t.take()),i();break;case 6:n.accTitle=vY(t.take()),i();break;case 7:n.title=_Y(t.take()),i();break;case 4:{let e=t.take();if(t.accept(2)){let r={$type:`Transition`,from:e,to:t.expect(4)};t.accept(3)&&(r.label=bY(t.expect(8))),i(),n.transitions.push(r);break}let a={$type:`DomainBlock`,domain:e,items:[]};for(r();t.kinds[t.i]===8;)a.items.push({$type:`DomainItem`,label:bY(t.take())}),r();n.domains.push(a);break}default:t.fail(`a domain, a transition, a title, or a line break`)}return n}function hyt(e){let t=e+1831565813|0;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function gyt(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t}function _yt(e,t){return typeof e==`number`&&Number.isFinite(e)&&e!==0?e:gyt(t)}var vyt={segments:7,vertical:!0,pointStep:17,controlStep:31,controlShift:7},yyt={segments:7,vertical:!1,pointStep:23,controlStep:37,controlShift:11};function VX(e,t,n,r,i,a){let o=(t-e)/a.segments,s=[],c=[];for(let t=0;t<=a.segments;t++){let l=t===0&&a.pinStart||t===a.segments&&a.pinEnd;s.push(e+t*o),c.push(l?n:n+hyt(r+t*a.pointStep)*i*2-i)}let l=a.vertical?[c[0],s[0]]:[s[0],c[0]];for(let e=0;e<a.segments;e++){let t=(s[e]+s[e+1])/2,n=i*1.5*(e%2==0?1:-1)*hyt(r+e*a.controlStep+a.controlShift);a.vertical?l.push(c[e]+n,t,c[e+1]-n,t,c[e+1],s[e+1]):l.push(t,c[e]+n,t,c[e+1]-n,s[e+1],c[e+1])}return l}function byt(e,t,n,r){let i=n-t;return[e,t,e+r,t+i*.2,e-r*1.5,t+i*.55,e+r*.5,t+i*.75,e-r,t+i*.85,e+r*.3,t+i*.95,e,n]}function HX(e){let t=``;for(let n=2;n<e.length;n+=6)t+=`C${K(e[n])},${K(e[n+1])} ${K(e[n+2])},${K(e[n+3])} ${K(e[n+4])},${K(e[n+5])}`;return t}function UX(e){let t=``;for(let n=e.length-6;n>=2;n-=6)t+=`C${K(e[n+2])},${K(e[n+3])} ${K(e[n])},${K(e[n+1])} ${K(e[n-2])},${K(e[n-1])}`;return t}function WX(e){return`M${K(e[0])},${K(e[1])}${HX(e)}`}function xyt(e,t,n,r){let i=`${K(n)},${K(r)}`;return`M${K(e-n)},${K(t)}A${i} 0 1,1 ${K(e+n)},${K(t)}A${i} 0 1,1 ${K(e-n)},${K(t)}Z`}var GX=[[`complex`,0,0,0],[`complicated`,1,0,1],[`chaotic`,0,1,3],[`clear`,1,1,2]],Syt=4,Cyt=/* @__PURE__ */ 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`]]]),wyt=3,Tyt=200,Eyt=10,Dyt=4,KX=6,Oyt=10,kyt=20,qX=10;function JX(e,t,n,r,i){let a=e.cynefin?.[t];return typeof a==`number`&&a>=r&&a<=i?a:n}function Ayt(e,t,n){let r=n.fontSize??16,i=Math.round(r*.8125),a=Math.round(r*.875),o=n.measurer??fq(n.fontFamily),s=n.padding??8,c=n.icons,l=t.cynefin?.showDomainDescriptions!==!1,u=JX(t,`boundaryAmplitude`,8,0,50),d=_yt(JX(t,`seed`,0,-0x38d7ea4c68000,0x38d7ea4c68000),n.idPrefix??`pele`),f=Math.round(a*1.5),p=(e,t)=>{let n=WJ(e,!1,o,a,Tyt);return{text:e,label:n,w:n.width+2*Eyt,h:Math.max(n.height,f)+2*Dyt,overflow:t}},m=t=>{let n=Cyt.get(t),a=WJ(n[0],!1,o,r,4e3,1),s=[];if(l)for(let e of[n[1],n[2]])e&&s.push(WJ(e,!1,o,i,4e3,2));let c=e.domains.get(t)?.items??[],u=t===`confusion`&&c.length>wyt?wyt:c.length,d=[];for(let e=0;e<u;e++)d.push(p(c[e].label,!1));u<c.length&&d.push(p(`+${c.length-u} more`,!0));let f=a.width,m=a.height;for(let e of s)f=Math.max(f,e.width),m+=e.height;d.length>0&&(m+=Oyt-KX);for(let e of d)f=Math.max(f,e.w),m+=KX+e.h;return{name:t,title:a,subtitles:s,badges:d,w:f,h:m,cx:0,cy:0}},h=GX.map(([e])=>m(e)),g=m(`confusion`),_=Math.max(88,g.w*.71+8),v=Math.max(64,g.h*.71+6),y=JX(t,`width`,640,100,1e4)/2,b=JX(t,`height`,440,100,1e4)/2;for(let e of h)y=Math.max(y,e.w+2*kyt),b=Math.max(b,e.h+2*kyt);for(let e of h){let t=(y-e.w)/2,n=(b-e.h)/2;if((t/(_+qX))**2+(n/(v+qX))**2>=1)continue;let r=e.w+2*(_+qX),i=e.h+2*(v+qX);r*b<=y*i?y=Math.max(y,r):b=Math.max(b,i)}let x=WJ(e.title,!1,o,r,4e3,1),S=x.height>0?x.height+12:0,C=2*y,w=2*b,T=s,E=s+S,D=T+y,O=E+b,k=T+C,A=E+w,j=VX(E,O,D,d,u,{...vyt,segments:4,pinEnd:!0}),M=VX(T,D,O,d+100,u,{...yyt,segments:4,pinEnd:!0}),N=VX(D,k,O,d+200,u,{...yyt,segments:4,pinStart:!0}),P=byt(D,O,A,C*.03),F=(e,t)=>t?`${K(e[e.length-2])},${K(e[e.length-1])}`:`${K(e[0])},${K(e[1])}`,ee=/* @__PURE__ */ new Map([[`complex`,`M${K(T)},${K(E)}L${F(j,!1)}${HX(j)}${UX(M)}Z`],[`complicated`,`M${F(j,!1)}L${K(k)},${K(E)}L${F(N,!0)}${UX(N)}${UX(j)}Z`],[`chaotic`,`M${F(M,!1)}${HX(M)}${HX(P)}L${K(T)},${K(A)}Z`],[`clear`,`M${F(N,!1)}${HX(N)}L${K(k)},${K(A)}L${F(P,!0)}${UX(P)}Z`]]),te=``;for(let[e,,,t]of GX)te+=`<path class="pele-cynefin-region" data-id="${e}" d="${ee.get(e)}" fill="${gJ(t)}" fill-opacity="0.14"/>`;let I=`<g class="pele-cynefin-boundaries" fill="none" stroke="var(--_b)" stroke-dasharray="6 3"><path d="${WX(j)}"/><path d="${WX(M)}"/><path d="${WX(N)}"/><path class="pele-cynefin-cliff" d="${WX(P)}" stroke="var(--_l)" stroke-width="2" stroke-dasharray="none" stroke-linecap="round"/></g>`,ne=xyt(D,O,_,v),re=`<path d="${ne}" fill="var(--_bg)"/><path class="pele-cynefin-region" data-id="confusion" d="${ne}" fill="${gJ(Syt)}" fill-opacity="0.18" stroke="var(--_b)" stroke-dasharray="4 2"/>`,ie=e=>{let t=e.cy-e.h/2,n=gq(e.title,e.cx,t+e.title.height/2,` class="pele-label" font-weight="var(--_hw)"`);t+=e.title.height;for(let r of e.subtitles)n+=gq(r,e.cx,t+r.height/2,` class="pele-cynefin-subtitle" font-size="${i}" font-style="italic" fill="var(--_m)"`),t+=r.height;t+=Oyt-KX;for(let r of e.badges)t+=KX,n+=`<g class="pele-node${r.overflow?` pele-cynefin-overflow`:``}"${r.overflow?``:` data-id="${mq(r.text)}"`}><rect x="${K(e.cx-r.w/2)}" y="${K(t)}" width="${K(r.w)}" height="${K(r.h)}" rx="${fJ}" fill="var(--_bg)" stroke="var(--_b)"${r.overflow?` stroke-dasharray="3 2"`:``}/>`+gq(r.label,e.cx,t+r.h/2,` class="pele-label" font-size="${a}"${r.overflow?` fill="var(--_m)"`:``}`,c)+`</g>`,t+=r.h;return`<g class="pele-cynefin-domain" data-id="${e.name}">${n}</g>`},ae=/* @__PURE__ */ new Map,L=``;GX.forEach(([e,t,n],r)=>{let i=h[r];i.cx=T+y*(t+.5),i.cy=E+b*(n+.5),ae.set(e,i),L+=ie(i)}),g.cx=D,g.cy=O,ae.set(`confusion`,g),L+=ie(g);let oe=(e,t,n)=>e===g?((t-D)/(_+4))**2+((n-O)/(v+4))**2<=1:Math.abs(t-e.cx)<=e.w/2+8&&Math.abs(n-e.cy)<=e.h/2+8,se=``,ce=/* @__PURE__ */ new Map;for(let t of e.transitions){let e=ae.get(t.from),n=ae.get(t.to);if(!e||!n||e===n)continue;let r=t.from<t.to?`${t.from} ${t.to}`:`${t.to} ${t.from}`,a=ce.get(r)??0;ce.set(r,a+1);let s=n.cx-e.cx,l=n.cy-e.cy,u=Math.hypot(s,l)||1,d=(e.cx+n.cx)/2,f=(e.cy+n.cy)/2,p=-l*(d-D)+s*(f-O)>=0?1:-1,m=-l/u*p,h=s/u*p,y=(e!==g&&n!==g&&Math.abs(s)>1&&Math.abs(l)>1?2*(Math.hypot(_*m,v*h)+16):u*.15)+a*56,b=d+m*y,x=f+h*y,S=t=>{let r=1-t;return[r*r*e.cx+2*r*t*b+t*t*n.cx,r*r*e.cy+2*r*t*x+t*t*n.cy]},C=(e,t,n,r)=>{for(let i=0;i<16;i++){let i=(t+n)/2;oe(e,...S(i))===r?t=i:n=i}return(t+n)/2},w=1;for(;w<=48&&oe(e,...S(w/48));)w++;if(w>48)continue;let E=C(e,(w-1)/48,w/48,!0);for(;w<=48&&!oe(n,...S(w/48));)w++;let A=w>48?1:C(n,(w-1)/48,w/48,!1),[j,M]=S(E),[N,P]=S(A),F=(e,t,n)=>(1-E)*(1-A)*e+((1-E)*A+E*(1-A))*t+E*A*n,ee=F(e.cx,b,n.cx),te=F(e.cy,x,n.cy),I=Math.hypot(N-ee,P-te)||1,ne=(N-ee)/I,re=(P-te)/I,ie=cJ(`arrow_point`,N,P,ne,re,`var(--_l)`);N-=ne*sJ(`arrow_point`),P-=re*sJ(`arrow_point`);let L=``;if(t.label){let e=WJ(t.label,!1,o,i,Tyt),[n,r]=S((E+A)/2),a=Math.abs(m)*e.width/2+Math.abs(h)*e.height/2+6,s=e.width/2+4;L=gq(e,Math.min(Math.max(n+m*a,T+s),Math.max(k-s,T+s)),r+h*a,` class="pele-edge-label" font-size="${i}"`,c)}se+=`<g class="pele-edge" data-id="${t.from}-${t.to}"><path d="M${K(j)},${K(M)}Q${K(ee)},${K(te)} ${K(N)},${K(P)}" fill="none" stroke="var(--_l)"/>`+ie+L+`</g>`}let le=Math.ceil(Math.max(C,x.width)+2*s),ue=Math.ceil(w+S+2*s);return{svg:vJ(`cynefin`,le,ue,r,n,e,gq(x,T+C/2,s+x.height/2,` class="pele-title" font-weight="var(--_tw)"`)+`<g class="pele-cynefin-regions">${te}</g>`+I+re+L+(se?`<g class="pele-edges">${se}</g>`:``)),width:le,height:ue,links:[]}}var jyt={type:`cynefin`,parse:(e,t,n)=>fyt(myt(e),n),render:Ayt};function Myt(e){return e===`markdown`||e===`string`||e===`text`?e:`markdown`}var Nyt=class{type=`er`;direction=`TB`;entities=/* @__PURE__ */ new Map;relationships=[];classes=/* @__PURE__ */ new Map;subgraphs=[];title;accTitle;accDescr;subgraphLookup=/* @__PURE__ */ new Map;claimed=/* @__PURE__ */ new Set;addEntity(e,t=``){let n=this.entities.get(e);return n===void 0?(n={id:`entity-${e}-${this.entities.size}`,label:e,alias:t,attributes:[],cssClasses:`default`,cssStyles:[]},this.entities.set(e,n)):!n.alias&&t&&(n.alias=t),n}addAttributes(e,t){let n=this.addEntity(e);for(let e=t.length-1;e>=0;e--){let r=t[e];r.keys??=[],r.comment??=``,n.attributes.push(r)}}addRelationship(e,t,n,r){let i=this.subgraphLookup.has(e)?e:this.addEntity(e).id,a=this.subgraphLookup.has(n)?n:this.addEntity(n).id;this.relationships.push({entityA:i,roleA:t,entityB:a,relSpec:r})}setDirection(e){this.direction=e}addCssStyles(e,t){if(t)for(let n of e){let e=this.entities.get(n);if(e)for(let n of t)e.cssStyles.push(n);let r=this.subgraphLookup.get(n);if(r)for(let e of t)r.cssStyles.push(e)}}addClass(e,t){for(let n of e){let e=this.classes.get(n);if(e===void 0&&(e={id:n,styles:[],textStyles:[]},this.classes.set(n,e)),t)for(let n of t)n.includes(`color`)&&e.textStyles.push(n.replace(`fill`,`bgFill`)),e.styles.push(n)}}setClass(e,t){for(let n of e){let e=this.entities.get(n);if(e)for(let n of t)e.cssClasses+=` `+n;let r=this.subgraphLookup.get(n);if(r)for(let e of t)r.classes.push(e)}}addSubGraph(e,t,n){let r=e.text.trim(),i=/* @__PURE__ */ new Set,a=[],o;for(let e of t.flat()){if(typeof e!=`string`){e?.stmt===`dir`&&(o=e.value);continue}let t=e.trim();t===``||i.has(t)||(i.add(t),this.claimed.has(e)||a.push(e))}for(let e of a)this.claimed.add(e);let s={id:r,nodes:a,title:(n.text||``).trim(),classes:[],cssStyles:[],dir:o,labelType:Myt(n.type)};return this.subgraphs.push(s),this.subgraphLookup.set(r,s),r}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,``)}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
998
|
+
`)),p();break;case 8:a===125?(p(),s++):d(15,s,g(`}`))}if(!c)return n.push(1),r.push(``),i.push(s),{types:n,texts:r,starts:i}}return n.push(0),r.push(``),i.push(t),{types:n,texts:r,starts:i}}var EX=61,DX=new Uint8Array(EX);for(let e of[53,27,52])DX[e]=1;var OX=new Uint8Array(EX);for(let e of[27,49,50,47,51,10])OX[e]=1;var kX=new Uint8Array(EX);kX[33]=1,kX[34]=2,kX[35]=3,kX[36]=4,kX[37]=5;var Wvt=`'UNICODE_TEXT', 'NUM', 'ALPHA', 'MINUS', 'BQUOTE_STR'`;function Gvt(e,t){let{types:n,texts:r,starts:i}=Uvt(e),a=0,o=t=>{let r=n[a];throw r===1?FK(`class`,e,i[a],``,!0):FK(`class`,e,i[a],`Expecting ${t}, got '${Bvt[r]}'`)},s=e=>(n[a]!==e&&o(`'${Bvt[e]}'`),r[a++]),c=()=>(DX[n[a]]===0&&o(`'UNICODE_TEXT', 'NUM', 'ALPHA', 'MINUS'`),r[a++]),l=e=>{let t=``;for(;;){if(n[a]===54){t+=r[a++];break}DX[n[a]]===0&&o(Wvt),t+=r[a++];let e=n[a];if(e===8)t+=`.`,a++;else if(DX[e]===0&&e!==54)break}return e&&n[a]===9&&(t+=`~`+r[a++]+`~`),t},u=()=>{a++;let e=s(6);return s(7),e},d=()=>{n[a]!==23&&o(`'STRUCT_STOP', 'MEMBER'`);let e=[];for(;n[a]===23;)e.push(r[a++]);return s(17),e.reverse()},f=()=>{a++;let e=l(!0);switch(t.addClass(e),n[a]===5&&t.setClassLabel(e,u()),n[a]){case 19:{a++;let r=c();t.setCssClass(e,r),n[a]===16&&(a++,t.addMembers(e,d()));break}case 16:a++,n[a]===17?a++:t.addMembers(e,d());break;case 20:{a++;let r=c();s(21),t.addAnnotation(e,r),n[a]===16&&(a++,n[a]===17?a++:t.addMembers(e,d()));break}}return e},p=()=>{if(n[a++]===25)return t.addNote(s(6));let e=l(!0);return t.addNote(s(6),e)},m=()=>{let e=[];for(;;){a++;let r=l(!1),i=n[a]===5?t.addNamespace(r,u()):t.addNamespace(r);s(16),n[a]===3&&a++,e.push({id:i,classes:[],notes:[]});let c=!0;for(;c;){let r=e[e.length-1],i=n[a];if(i===18)break;for(i===22?r.classes.push(f()):i===25||i===24?r.notes.push(p()):o(`'NAMESPACE', 'CLASS', 'NOTE_FOR', 'NOTE'`);;){if(n[a]===3){let e=n[a+1];if(e===18||e===22||e===25||e===24){a++;break}a++}s(17);let r=e.pop();if(t.addClassesToNamespace(r.id,r.classes,r.notes),t.popNamespace(),e.length===0){c=!1;break}}}if(e.length===0)return}},h=()=>{let e=kX[n[a]];return e===0?`none`:(a++,e-1)},g=()=>{let e=l(!0),i=n[a];if(i===10){t.addMember(e,t.cleanupLabel(r[a++]));return}let s=`none`;if(i===6)s=r[a++],i=n[a];else if(kX[i]===0&&i!==38&&i!==39)return;let c=h();i=n[a],i!==38&&i!==39&&o(`'AGGREGATION', 'EXTENSION', 'COMPOSITION', 'DEPENDENCY', 'LOLLIPOP', 'LINE', 'DOTTED_LINE'`),a++;let u=h(),d=n[a]===6?r[a++]:`none`,f={id1:e,id2:l(!0),relation:{type1:c,type2:u,lineType:i===38?0:1},relationTitle1:s,relationTitle2:d};n[a]===10&&(f.title=t.cleanupLabel(r[a++])),t.addRelation(f)},_=()=>{let e=[];for(;;){OX[n[a]]===0&&o(`'ALPHA', 'NUM', 'COLON', 'UNIT', 'SPACE', 'BRKT', 'STYLE', 'PCT', 'LABEL'`);let t=r[a++];for(;OX[n[a]]===1;)t+=r[a++];if(e.push(t),n[a]!==28)return e;a++}},v=e=>{n[a]===6&&t.setTooltip(e,r[a++])},y=e=>{let i=s(6),o=n[a]===6?r[a++]:void 0;n[a]===42?t.setLink(e,i,r[a++]):t.setLink(e,i),o!==void 0&&t.setTooltip(e,o)},b=()=>{let e=n[a];switch(e){case 53:case 27:case 52:case 54:g();return;case 18:m();return;case 22:f();return;case 23:a++;return;case 20:{a++;let e=c();s(21),t.addAnnotation(l(!0),e);return}case 40:{a++;let e=l(!0);t.setClickEvent(e,s(6)),v(e);return}case 41:a++,y(l(!0));return;case 43:{a++;let e=l(!0);if(n[a]===46){a++,y(e);return}let i=s(44);n[a]===45?t.setClickEvent(e,i,r[a++]):t.setClickEvent(e,i),v(e);return}case 47:{a++;let e=s(27);t.setCssStyle(e,_());return}case 48:{a++;let e=s(6);t.setCssClass(e,s(27));return}case 25:case 24:p();return;case 26:{a++;let e=[s(27)];for(;n[a]===28;)a++,e.push(s(27));t.defineClass(e,_());return}case 29:case 30:case 31:case 32:a++,t.setDirection(e===29?`TB`:e===30?`BT`:e===31?`RL`:`LR`);return;case 11:a++,t.setAccTitle(s(12).trim());return;case 13:a++,t.setAccDescription(s(14).trim());return;case 15:t.setAccDescription(r[a++].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'`)},x=n[a]===2;for(x&&(a++,s(3));b(),!(n[a]!==3||(a++,n[a]===4||n[a]===0)););x&&s(4),s(0)}function Kvt(e,t,n,r,i,a,o){let s=UJ(e,!1,t,n,4e3,1);if(s.height===0)return{width:i,height:a,content:o};let c=s.height+12,l=Math.max(i,Math.ceil(s.width+2*r));return{width:l,height:Math.ceil(a+c),content:gq(s,l/2,r+s.height/2,` class="pele-title" font-weight="var(--_tw)"`)+`<g transform="translate(${K((l-i)/2)},${K(c)})">${o}</g>`}}var qvt=[`aggregation`,`extension`,`composition`,`dependency`,`lollipop`];function Jvt(e){return typeof e==`number`&&qvt[e]||`none`}function Yvt(e,t=!0){let n=[],r=[],i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Map,o=/* @__PURE__ */ new Map,s=/* @__PURE__ */ new Map,c=n=>{if(t||n===void 0)return n;let r=[],i=n,a;for(;i;){if(s.has(i)){a=s.get(i);break}let t=e.namespaces.get(i);if(t===void 0)break;if(t.explicit){a=i;break}r.push(i),i=t.parent}for(let e of r)s.set(e,a);return a},l=e=>e===void 0?-1:i.get(e)??-1;for(let r of e.namespaces.values())!t&&!r.explicit||(i.set(r.id,n.length),n.push({id:r.id,label:t?r.label:r.id,isGroup:!0,shape:`rect`,parentId:t?r.parent:void 0,parent:-1}));for(let e of n)e.parent=l(e.parentId);let u=0;for(let t of e.classes.values()){let e=c(t.parent);a.set(t.id,n.length),n.push({id:t.id,label:t.label,isGroup:!1,shape:`classBox`,parentId:e,parent:l(e),classNode:t,colorIndex:u++})}for(let t of e.notes.values()){let e=c(t.parent),i=t.class===void 0?void 0:a.get(t.class);i!==void 0&&r.push({id:`edgeNote${t.index}`,start:t.id,end:n[i].id,source:n.length,target:i,label:void 0,arrowTypeStart:`none`,arrowTypeEnd:`none`,startLabelRight:``,endLabelLeft:``,pattern:`dotted`,classes:`relation`}),n.push({id:t.id,label:t.text,isGroup:!1,shape:`note`,parentId:e,parent:l(e)})}for(let t of e.interfaces){let e=a.get(t.classId);o.set(t.id,n.length),n.push({id:t.id,label:t.label,isGroup:!1,shape:`interface`,parentId:void 0,parent:e===void 0?-1:n[e].parent})}let d=0;for(let t of e.relations){d++;let{type1:e,type2:n}=t.relation,i=e===CX.LOLLIPOP&&n===`none`?o:a,s=i===a&&n===CX.LOLLIPOP&&e===`none`?o:a;r.push({id:`id_${t.id1}_${t.id2}_${d}`,start:t.id1,end:t.id2,source:i.get(t.id1)??-1,target:s.get(t.id2)??-1,label:t.title,arrowTypeStart:Jvt(e),arrowTypeEnd:Jvt(n),startLabelRight:t.relationTitle1===`none`?``:t.relationTitle1,endLabelLeft:t.relationTitle2===`none`?``:t.relationTitle2,pattern:t.relation.lineType===1?`dashed`:`solid`,classes:`relation`})}return{nodes:n,edges:r}}var AX=12,jX=16,MX=6,NX=5;function Xvt(e){switch(e){case`extension`:return AX;case`composition`:case`aggregation`:return jX;case`lollipop`:return 2*NX;case`dependency`:return sJ(`arrow_point`)}return 0}function Zvt(e,t,n,r,i,a){let o=-i,s=r;switch(e){case`extension`:{let e=t-r*AX,a=n-i*AX;return`<path class="pele-marker" d="M${K(t)},${K(n)}L${K(e+o*MX)},${K(a+s*MX)}L${K(e-o*MX)},${K(a-s*MX)}Z" stroke-linejoin="round"/>`}case`composition`:case`aggregation`:{let c=t-r*jX/2,l=n-i*jX/2,u=MX-1;return`<path class="pele-marker" d="M${K(t)},${K(n)}L${K(c+o*u)},${K(l+s*u)}L${K(t-r*jX)},${K(n-i*jX)}L${K(c-o*u)},${K(l-s*u)}Z" stroke-linejoin="round"${e===`composition`?` fill="${a}"`:``}/>`}case`lollipop`:return`<circle class="pele-marker" cx="${K(t-r*NX)}" cy="${K(n-i*NX)}" r="${NX}"/>`;case`dependency`:return cJ(`arrow_point`,t,n,r,i,a)}return``}var Qvt=40,$vt=16,eyt=56,PX=20,tyt=26,FX=12,IX=8,nyt=6,ryt=10,iyt=64,LX=8,RX=`var(--_l)`,ayt=/* @__PURE__ */ new Set([`_self`,`_blank`,`_parent`,`_top`]);function oyt(e,t,n){let r=e[t];return typeof r==`number`&&r>0?Math.min(r,2e3):n}var zX=[],BX=[];function syt(e,t,n){let r=RK(e.getDisplayDetails().displayText).trim();return{text:r,width:t.width(r,n,e.classifier===`*`?2:0),classifier:e.classifier}}function cyt(e,t,n){let r=r=>YJ(n,i=>lyt(e,t,n,r,i));return JJ(e.direction)?qJ(n,r):r(!1)}function lyt(e,t,n,r,i){let a=t.class??{},o=Yvt(e,a.hierarchicalNamespaces!==!1),s=a.hideEmptyMembersBox===!0,c=n.fontSize??16,l=Math.round(c*.875),u=Math.round(c*.8),d=Math.round(u*1.4),f=n.measurer??fq(n.fontFamily),p=n.padding??8,m=r?`TB`:Xq(e.direction),h=/* @__PURE__ */ new Map,g=/* @__PURE__ */ new Map,_=/* @__PURE__ */ new Map,v=e=>{let t=h.get(e);if(t===void 0){let n=pJ([e]);t=n.shape===``&&n.text===``?``:e.slice(0,e.indexOf(`:`)).trim().toLowerCase(),h.set(e,t)}t!==``&&_.set(t,e)},y=t=>{_.clear();let n=g.get(t.cssClasses);if(n===void 0){for(let n of t.cssClasses.split(` `)){let t=e.styleClasses.get(n);if(t)for(let e of t.styles)for(let t of e.split(`,`))v(t)}n=[..._],g.set(t.cssClasses,n)}else for(let[e,t]of n)_.set(e,t);for(let e of t.styles)v(e);return pJ(_.size===0?BX:[..._.values()])},b=new Int32Array(o.nodes.length);for(let e of o.nodes)e.parent>=0&&b[e.parent]++;let x=new Uint8Array(o.nodes.length);for(let e of o.edges){if(e.source<0||e.target<0)continue;let t=o.nodes[e.source].parent,n=o.nodes[e.target].parent;if(t!==n){for(let e=t;e>=0&&x[e]===0;e=o.nodes[e].parent)x[e]=1;for(let e=n;e>=0&&x[e]===0;e=o.nodes[e].parent)x[e]=1}}let S=[],C=[];o.nodes.forEach((e,t)=>{let n,r;if(e.isGroup){let a=UJ(e.label,!1,f,c,4e3);n=w(e,a,0,0,c),b[t]>0?(r=Qq(0,0),r.isGroup=!0,r.padX=PX,r.padTop=a.height>0?a.height+16:PX,r.padBottom=PX,r.minW=a.width+2*PX-12+(x[t]===1&&!i?Math.min(a.width+24,240):0)):(n.w=Math.max(a.width+2*PX,80),n.h=a.height+2*PX,r=Qq(n.w,n.h))}else if(e.classNode)n=T(e,e.classNode),r=Qq(n.w,n.h);else if(e.shape===`note`){let t=UJ(e.label,!0,f,l,260);n=w(e,t,Math.max(t.width+2*FX,40),t.height+2*IX,l),r=Qq(n.w,n.h)}else{let t=UJ(e.label,!1,f,l,200);n=w(e,t,Math.max(t.width,12)+4,Math.max(t.height,12),l),r=Qq(n.w,n.h)}r.parent=e.parent,r.seq=t,S.push(n),C.push(r)});function w(e,t,n,r,i){return{node:e,style:pJ(BX),label:t,w:n,h:r,loops:0,annotations:BX,attributes:zX,methods:zX,titleH:0,attributesH:0,fontSize:i}}function T(e,t){let n=y(t),r=n.fontSize??c,i=Math.round(r*.875),a=Math.round(i*1.5),o=t.type?`<`+SX(t.type).replace(/</g,`<`).replace(/>/g,`>`)+`>`:``,l=UJ(t.label+o,!1,f,r,4e3,1|(n.italic?2:0)),p=t.annotations.length>0?t.annotations.map(e=>`«${RK(e).trim()}»`):BX,m=t.members.length>0?t.members.map(e=>syt(e,f,i)):zX,h=t.methods.length>0?t.methods.map(e=>syt(e,f,i)):zX,g=l.width;for(let e of p)g=Math.max(g,f.width(e,u,0));for(let e of m)g=Math.max(g,e.width);for(let e of h)g=Math.max(g,e.width);let _=!(s&&m.length===0&&h.length===0),v=e=>_?e>0?2*nyt+e*a:ryt:0,b=2*IX+p.length*d+Math.max(l.height,Math.round(r*1.5)),x=v(m.length);return{node:e,style:n,label:l,w:Math.max(g+2*FX,iyt),h:b+x+v(h.length),loops:0,annotations:p,attributes:m,methods:h,titleH:b,attributesH:x,fontSize:r}}let E=[],D=[],O=[],k=[],A=[],j=new Float64Array(S.length*4),M=(e,t,n)=>{j[e*4+t]++,n>j[e*4+t+1]&&(j[e*4+t+1]=n)};for(let e of o.edges){if(e.source<0||e.target<0)continue;let t=UJ(e.label,!0,f,l,200),n=e.startLabelRight?f.width(RK(e.startLabelRight),u,0):0,r=e.endLabelLeft?f.width(RK(e.endLabelLeft),u,0):0;e.source===e.target?(S[e.source].loops++,C[e.source].w+=2*(tyt+(t.width>0?t.width+12:0))):(M(e.source,0,n),M(e.target,2,r)),k.push(n),A.push(r),D.push(e),O.push(t),E.push({src:e.source,dst:e.target,minlen:1,labelW:t.width>0?t.width+12:0,labelH:t.height>0?t.height+4:0,route:[],labelX:0,labelY:0})}if(m===`TB`||m===`BT`)for(let e=0;e<S.length;e++){if(!S[e].node.classNode)continue;let t=0;for(let n=0;n<4;n+=2){let r=j[e*4+n],i=j[e*4+n+1];r>1&&(t=Math.max(t,(r-1)*(i>0?i+24:14)+24))}t=Math.min(t,480),t>S[e].w&&(C[e].w+=t-S[e].w,S[e].w=t)}let N=!1;for(let e=0;e<D.length&&!N;e++)N=k[e]>0||A[e]>0;let P=eJ(C,E,m,{nodeSep:oyt(a,`nodeSpacing`,Qvt),edgeSep:$vt,rankSep:oyt(a,`rankSpacing`,N?eyt+16:eyt),portSep:20,apart:!0}),F=/* @__PURE__ */ new Map,ee=[],te=(e,t,n,r,i)=>{let a=e.route,o=C[n],s=zJ(a,t,o);if(s<0)return;let c=(o.w-S[n].w)/2;s===1?a[t]-=c:s===3&&(a[t]+=c);let l=s&1,u=a[(t===0?3:t-3)+l],d=u-a[t+l],f={route:a,at:t,toward:u,order:i,room:r,side:s,after:l?d>0:d>=0},p=n*4+s,m=F.get(p);return m?m.push(f):F.set(p,[f]),f},I=[],ne=[];for(let e=0;e<E.length;e++){let t=E[e],n=t.src!==t.dst&&t.route.length>=6;I.push(n?te(t,0,t.src,k[e],e):void 0),ne.push(n?te(t,t.route.length-3,t.dst,A[e],e):void 0)}let re=(e,t,n)=>{for(let r=C[e].parent,i=0;r>=0&&i<1e4;r=C[r].parent,i++){let e=C[r],i=Math.abs(t-e.x),a=Math.abs(n-e.y);if(Math.abs(a-e.h/2)<.5&&i<=e.w/2+.5||Math.abs(i-e.w/2)<.5&&a<=e.h/2+.5)return!0}return!1},ie=[];for(let[e,t]of F){if(t.length<2)continue;let n=e>>2,r=e&1,i=r?S[n].h:S[n].w;t.sort((e,t)=>e.toward-t.toward||e.order-t.order);let a=0;for(let e=0;e+1<t.length;e++){let n=t[e],i=t[e+1],o=r?20:24;n.room>0&&n.after&&(o+=r?d+6:n.room),i.room>0&&!i.after&&(o+=r?d+6:i.room),ie[e]=o,a+=o}let o=Math.min(1,(i-24)/a);if(o<=0)continue;let s=(r?C[n].y:C[n].x)-a*o/2;for(let e=0;e<t.length;e++){let{route:i,at:a}=t[e],c=a===0?3:-3,l=a+c,u=-1;for(let e=l;e>=0&&e<i.length&&Math.abs(i[e+r]-i[l+r])<.5;e+=c)if(re(n,i[e],i[e+1])){u=e;break}if(u>=0&&Math.abs(i[l+r]-s)<=24)for(let e=l;e!==u+c;e+=c)i[e+r]=s;i[a+r]=s,s+=ie[e]*o}}let ae=(e,t,n,r)=>{if(t===void 0||n<=0)return;let i=t.side&1,a=r?0:e.length-3,o=a+1-i,s=Math.abs(e[(r?3:a-3)+1-i]-e[o]),c=Math.min(i?n+10:d+6,s*.35);if(c<4)return;let l=[e[a],e[a+1],e[a+2]];l[1-i]+=(t.side===0||t.side===3?-1:1)*c,e.splice(r?3:a,0,l[0],l[1],l[2])};for(let e=0;e<E.length;e++)ae(E[e].route,I[e],k[e],!0),ae(E[e].route,ne[e],A[e],!1);let L=0,oe=0,se=P.width,ce=P.height,le=(e,t,n,r,i,a)=>{if(!e)return;let o=n,s=r;i&1?(o+=(i===3?-1:1)*(5+t/2),s+=(a?1:-1)*(7+d/2)):(o+=(a?1:-1)*(9+t/2),s+=(i===0?-1:1)*(3+d/2)),ee.push({text:RK(e),x:o,y:s}),L=Math.min(L,o-t/2),se=Math.max(se,o+t/2),oe=Math.min(oe,s-d/2),ce=Math.max(ce,s+d/2)},ue=/* @__PURE__ */ new Map,de=new Int32Array(E.length);for(let e=0;e<E.length;e++){let t=E[e],n=D[e],r=t.route;if(t.src===t.dst){let r=ue.get(t.src)??0;ue.set(t.src,r+1),de[e]=r;let i=C[t.src],a=S[t.src],o=i.x+a.w/2,s=Math.min(a.h/2-4,8+r*6);le(n.startLabelRight,k[e],o,i.y-s,1,!1),le(n.endLabelLeft,A[e],o,i.y+s,1,!0)}else if(r.length>=6){let t=r.length-3,i=I[e],a=ne[e];le(n.startLabelRight,k[e],r[0],r[1],i?i.side:2,!i||i.after),le(n.endLabelLeft,A[e],r[t],r[t+1],a?a.side:0,!a||a.after)}}let fe=p-L,pe=p-oe,me=Math.ceil(se-L+2*p),he=Math.ceil(ce-oe+2*p),ge=[],_e=/* @__PURE__ */ new Map;if(o.nodes.length>0&&o.nodes[0].isGroup)for(let e of E)tJ(_e,e.route);let ve=``,ye=``,be=``;for(let e=0;e<S.length;e++){let t=S[e],r=C[e],i=t.node,a=r.x+fe,s=r.y+pe,c=mq(i.id),u=r.isGroup?r.w:t.w,d=r.isGroup?r.h:t.h;if(i.isGroup){let n=r.isGroup?nJ(r,t.label.width,_e,PX):r.x,i=s-d/2+8+t.label.height/2,l=` class="pele-cluster-label" fill="var(--_m)"`,f=r.isGroup&&ght(r,t.label.width,n,_e);f&&(ye+=_ht(t.label,n+fe,i,l,c,o.nodes,e)),ve+=`<g class="pele-cluster pele-namespace" data-id="${c}"><rect x="${K(a-u/2)}" y="${K(s-d/2)}" width="${K(u)}" height="${K(d)}" rx="${dJ}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"/>`+(f?``:gq(t.label,n+fe,i,l))+`</g>`;continue}let f=` transform="translate(${K(a)},${K(s)})"`;if(i.classNode)be+=xe(t,i.classNode,c,f);else if(i.shape===`note`){let e=u/2,r=-d/2;be+=`<g class="pele-node pele-note" data-id="${c}"${f}><path d="M${K(-e)},${K(r)}H${K(e-LX)}L${K(e)},${K(r+LX)}V${K(-r)}H${K(-e)}Z" fill="var(--_a)" stroke="var(--_b)" stroke-linejoin="round"/><path d="M${K(e-LX)},${K(r)}V${K(r+LX)}H${K(e)}" fill="none" stroke="var(--_b)" stroke-linejoin="round"/>`+gq(t.label,0,0,` class="pele-label" font-size="${l}"`,n.icons)+`</g>`}else be+=`<g class="pele-node pele-interface" data-id="${c}"${f}>`+gq(t.label,0,0,` class="pele-label" font-size="${l}"`,n.icons)+`</g>`}function xe(e,t,r,i){let{w:a,h:o,style:s}=e,l=-a/2,f=-o/2,p=Math.round(e.fontSize*.875),m=Math.round(p*1.5),h=`<rect x="${K(l)}" y="${K(f)}" width="${K(a)}" height="${K(o)}" rx="${dJ}" fill="var(--_s)" stroke="var(--_b)"${s.shape}/>`,g=f+e.titleH,_=g+e.attributesH;if(o>e.titleH){let e=s.stroke?` style="stroke:${pq(s.stroke)}"`:``;h+=`<path class="pele-divider" d="M${K(l)},${K(g)}H${K(-l)}M${K(l)},${K(_)}H${K(-l)}" fill="none" stroke="var(--_b)"${e}/>`}let v=f+IX;for(let t of e.annotations)h+=`<text class="pele-annotation" x="0" y="${K(v+d/2+u*.35)}" text-anchor="middle" font-size="${u}" fill="var(--_m)">${pq(t)}</text>`,v+=d;let y=e.fontSize===c?``:` font-size="${K(e.fontSize)}"`;h+=gq(e.label,0,(v+g-IX)/2,` class="pele-label"${y} font-weight="var(--_hw)"${s.text}`,n.icons);let b=(e,t,n)=>{let r=``,i=n+nyt+m/2+p*.35;for(let n of e){let e=n.classifier===`$`?` pele-static"${s.text?s.text.slice(0,-1)+`text-decoration:underline"`:` style="text-decoration:underline"`}`:n.classifier===`*`?` pele-abstract" font-style="italic"${s.text}`:`"${s.text}`;r+=`<text class="pele-member pele-${t}${e} x="${K(l+FX)}" y="${K(i)}">${pq(n.text)}</text>`,i+=m}return r};return(e.attributes.length>0||e.methods.length>0)&&(h+=`<g class="pele-members" font-size="${p}">${b(e.attributes,`attribute`,g)}${b(e.methods,`method`,_)}</g>`),t.tooltip&&(h=`<title>${mq(t.tooltip)}</title>`+h),t.link&&(h=Tq(h,t.link,t.id,ge,n,t.linkTarget&&ayt.has(t.linkTarget)?` target="${t.linkTarget}"`:``)),`<g class="pele-node pele-class${mJ(t.cssClasses.replace(/^default\s?/,``))}" data-id="${r}"${i}>${h}</g>`}let Se=``,Ce=``;for(let e=0;e<E.length;e++){let t=E[e],r=D[e],i=O[e],a=r.arrowTypeStart,o=r.arrowTypeEnd,s=Xvt(a),c=Xvt(o),l;if(t.src===t.dst){let n=C[t.src],r=S[t.src],i=de[e],a=n.x+fe+r.w/2,o=n.y+pe,u=Math.min(r.h/2-4,8+i*6),d=tyt+i*8;l={d:`M${K(a+s)},${K(o-u)}C${K(a+d+s)},${K(o-u)} ${K(a+d+c)},${K(o+u)} ${K(a+c)},${K(o+u)}`,sx:a,sy:o-u,sdx:-1,sdy:0,ex:a,ey:o+u,edx:-1,edy:0},t.labelX=n.x+r.w/2+d+4+t.labelW/2,t.labelY=n.y}else{let e=t.route;for(let t=0;t<e.length;t+=3)e[t]+=fe,e[t+1]+=pe;l=oJ(e,void 0,s,c)}let u=r.pattern===`dashed`?` stroke-dasharray="6 4"`:r.pattern===`dotted`?` stroke-dasharray="2 4"`:``;if(Se+=`<g class="pele-edge${r.pattern===`dotted`?` pele-note-edge`:` pele-relation`}" data-id="${mq(r.id)}"><path d="${l.d}"${u}/>`+Zvt(a,l.sx,l.sy,l.sdx,l.sdy,RX)+Zvt(o,l.ex,l.ey,l.edx,l.edy,RX)+`</g>`,i.width>0){let e=t.labelX+fe,a=t.labelY+pe;Ce+=lJ(r.id,i,e,a,``,n.icons)}}let we=``;for(let e of ee)we+=`<text class="pele-cardinality" x="${K(e.x+fe)}" y="${K(e.y+pe+u*.35)}" text-anchor="middle">${pq(e.text)}</text>`;let Te=Kvt(e.title,f,c,p,me,he,(ve?`<g class="pele-clusters">${ve}</g>`:``)+(Se?`<g class="pele-edges" fill="none" stroke="${RX}" stroke-linecap="round">${Se}</g>`:``)+(ye?`<g class="pele-cluster-titles">${ye}</g>`:``)+(Ce?`<g class="pele-edge-labels" font-size="${l}">${Ce}</g>`:``)+(we?`<g class="pele-cardinalities" font-size="${u}" fill="var(--_m)">${we}</g>`:``)+`<g class="pele-nodes">${be}</g>`);return{svg:_J(`class`,Te.width,Te.height,c,n,e,Te.content),width:Te.width,height:Te.height,links:ge}}var uyt={type:`class`,parse(e,t,n){let r=new zvt;return n&&(r.title=n),Gvt(e,r),r},render:cyt},dyt=class{domains=/* @__PURE__ */ new Map;transitions=[];setDomains(e){if(e)for(let t of e){let e=t.domain;this.domains.set(e,{name:e,items:(t.items??[]).map(e=>({label:e.label}))})}}setTransitions(e){e&&(this.transitions=e.filter(e=>e.from!==e.to).map(e=>({from:e.from,to:e.to,label:e.label||void 0})))}};function fyt(e,t){let n=new dyt;return n.setDomains(e.domains),n.setTransitions(e.transitions),{type:`cynefin`,title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,``):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
|
|
999
|
+
`):void 0,domains:n.domains,transitions:n.transitions}}var pyt=[{name:`cynefin-beta:`,pattern:`cynefin-beta:`},mY(`cynefin-beta`),{name:`-->`,pattern:`-->`},{name:`:`,pattern:`:`},{name:`DOMAIN_NAME`,pattern:/complex|complicated|clear|chaotic|confusion/y},aY,oY,sY,cY,lY,uY,dY,fY,pY];function myt(e){let t=new bY(iY(e,pyt,`cynefin`),pyt,`cynefin`),n={$type:`Cynefin`,domains:[],transitions:[]},r=()=>{for(;t.kinds[t.i]===9;)t.i++},i=()=>{t.kind!==-1&&(t.kind!==9&&t.fail(`a line break or the end of input`),r())};for(r(),t.kind!==1&&t.kind!==0&&t.fail(`'cynefin-beta'`),t.i++;t.kind!==-1;)switch(t.kind){case 9:t.i++;break;case 5:n.accDescr=vY(t.take()),i();break;case 6:n.accTitle=_Y(t.take()),i();break;case 7:n.title=gY(t.take()),i();break;case 4:{let e=t.take();if(t.accept(2)){let r={$type:`Transition`,from:e,to:t.expect(4)};t.accept(3)&&(r.label=yY(t.expect(8))),i(),n.transitions.push(r);break}let a={$type:`DomainBlock`,domain:e,items:[]};for(r();t.kinds[t.i]===8;)a.items.push({$type:`DomainItem`,label:yY(t.take())}),r();n.domains.push(a);break}default:t.fail(`a domain, a transition, a title, or a line break`)}return n}function hyt(e){let t=e+1831565813|0;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function gyt(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t}function _yt(e,t){return typeof e==`number`&&Number.isFinite(e)&&e!==0?e:gyt(t)}var vyt={segments:7,vertical:!0,pointStep:17,controlStep:31,controlShift:7},yyt={segments:7,vertical:!1,pointStep:23,controlStep:37,controlShift:11};function VX(e,t,n,r,i,a){let o=(t-e)/a.segments,s=[],c=[];for(let t=0;t<=a.segments;t++){let l=t===0&&a.pinStart||t===a.segments&&a.pinEnd;s.push(e+t*o),c.push(l?n:n+hyt(r+t*a.pointStep)*i*2-i)}let l=a.vertical?[c[0],s[0]]:[s[0],c[0]];for(let e=0;e<a.segments;e++){let t=(s[e]+s[e+1])/2,n=i*1.5*(e%2==0?1:-1)*hyt(r+e*a.controlStep+a.controlShift);a.vertical?l.push(c[e]+n,t,c[e+1]-n,t,c[e+1],s[e+1]):l.push(t,c[e]+n,t,c[e+1]-n,s[e+1],c[e+1])}return l}function byt(e,t,n,r){let i=n-t;return[e,t,e+r,t+i*.2,e-r*1.5,t+i*.55,e+r*.5,t+i*.75,e-r,t+i*.85,e+r*.3,t+i*.95,e,n]}function HX(e){let t=``;for(let n=2;n<e.length;n+=6)t+=`C${K(e[n])},${K(e[n+1])} ${K(e[n+2])},${K(e[n+3])} ${K(e[n+4])},${K(e[n+5])}`;return t}function UX(e){let t=``;for(let n=e.length-6;n>=2;n-=6)t+=`C${K(e[n+2])},${K(e[n+3])} ${K(e[n])},${K(e[n+1])} ${K(e[n-2])},${K(e[n-1])}`;return t}function WX(e){return`M${K(e[0])},${K(e[1])}${HX(e)}`}function xyt(e,t,n,r){let i=`${K(n)},${K(r)}`;return`M${K(e-n)},${K(t)}A${i} 0 1,1 ${K(e+n)},${K(t)}A${i} 0 1,1 ${K(e-n)},${K(t)}Z`}var GX=[[`complex`,0,0,0],[`complicated`,1,0,1],[`chaotic`,0,1,3],[`clear`,1,1,2]],Syt=4,Cyt=/* @__PURE__ */ 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`]]]),wyt=3,Tyt=200,Eyt=10,Dyt=4,KX=6,Oyt=10,kyt=20,qX=10;function JX(e,t,n,r,i){let a=e.cynefin?.[t];return typeof a==`number`&&a>=r&&a<=i?a:n}function Ayt(e,t,n){let r=n.fontSize??16,i=Math.round(r*.8125),a=Math.round(r*.875),o=n.measurer??fq(n.fontFamily),s=n.padding??8,c=n.icons,l=t.cynefin?.showDomainDescriptions!==!1,u=JX(t,`boundaryAmplitude`,8,0,50),d=_yt(JX(t,`seed`,0,-0x38d7ea4c68000,0x38d7ea4c68000),n.idPrefix??`pele`),f=Math.round(a*1.5),p=(e,t)=>{let n=UJ(e,!1,o,a,Tyt);return{text:e,label:n,w:n.width+2*Eyt,h:Math.max(n.height,f)+2*Dyt,overflow:t}},m=t=>{let n=Cyt.get(t),a=UJ(n[0],!1,o,r,4e3,1),s=[];if(l)for(let e of[n[1],n[2]])e&&s.push(UJ(e,!1,o,i,4e3,2));let c=e.domains.get(t)?.items??[],u=t===`confusion`&&c.length>wyt?wyt:c.length,d=[];for(let e=0;e<u;e++)d.push(p(c[e].label,!1));u<c.length&&d.push(p(`+${c.length-u} more`,!0));let f=a.width,m=a.height;for(let e of s)f=Math.max(f,e.width),m+=e.height;d.length>0&&(m+=Oyt-KX);for(let e of d)f=Math.max(f,e.w),m+=KX+e.h;return{name:t,title:a,subtitles:s,badges:d,w:f,h:m,cx:0,cy:0}},h=GX.map(([e])=>m(e)),g=m(`confusion`),_=Math.max(88,g.w*.71+8),v=Math.max(64,g.h*.71+6),y=JX(t,`width`,640,100,1e4)/2,b=JX(t,`height`,440,100,1e4)/2;for(let e of h)y=Math.max(y,e.w+2*kyt),b=Math.max(b,e.h+2*kyt);for(let e of h){let t=(y-e.w)/2,n=(b-e.h)/2;if((t/(_+qX))**2+(n/(v+qX))**2>=1)continue;let r=e.w+2*(_+qX),i=e.h+2*(v+qX);r*b<=y*i?y=Math.max(y,r):b=Math.max(b,i)}let x=UJ(e.title,!1,o,r,4e3,1),S=x.height>0?x.height+12:0,C=2*y,w=2*b,T=s,E=s+S,D=T+y,O=E+b,k=T+C,A=E+w,j=VX(E,O,D,d,u,{...vyt,segments:4,pinEnd:!0}),M=VX(T,D,O,d+100,u,{...yyt,segments:4,pinEnd:!0}),N=VX(D,k,O,d+200,u,{...yyt,segments:4,pinStart:!0}),P=byt(D,O,A,C*.03),F=(e,t)=>t?`${K(e[e.length-2])},${K(e[e.length-1])}`:`${K(e[0])},${K(e[1])}`,ee=/* @__PURE__ */ new Map([[`complex`,`M${K(T)},${K(E)}L${F(j,!1)}${HX(j)}${UX(M)}Z`],[`complicated`,`M${F(j,!1)}L${K(k)},${K(E)}L${F(N,!0)}${UX(N)}${UX(j)}Z`],[`chaotic`,`M${F(M,!1)}${HX(M)}${HX(P)}L${K(T)},${K(A)}Z`],[`clear`,`M${F(N,!1)}${HX(N)}L${K(k)},${K(A)}L${F(P,!0)}${UX(P)}Z`]]),te=``;for(let[e,,,t]of GX)te+=`<path class="pele-cynefin-region" data-id="${e}" d="${ee.get(e)}" fill="${hJ(t)}" fill-opacity="0.14"/>`;let I=`<g class="pele-cynefin-boundaries" fill="none" stroke="var(--_b)" stroke-dasharray="6 3"><path d="${WX(j)}"/><path d="${WX(M)}"/><path d="${WX(N)}"/><path class="pele-cynefin-cliff" d="${WX(P)}" stroke="var(--_l)" stroke-width="2" stroke-dasharray="none" stroke-linecap="round"/></g>`,ne=xyt(D,O,_,v),re=`<path d="${ne}" fill="var(--_bg)"/><path class="pele-cynefin-region" data-id="confusion" d="${ne}" fill="${hJ(Syt)}" fill-opacity="0.18" stroke="var(--_b)" stroke-dasharray="4 2"/>`,ie=e=>{let t=e.cy-e.h/2,n=gq(e.title,e.cx,t+e.title.height/2,` class="pele-label" font-weight="var(--_hw)"`);t+=e.title.height;for(let r of e.subtitles)n+=gq(r,e.cx,t+r.height/2,` class="pele-cynefin-subtitle" font-size="${i}" font-style="italic" fill="var(--_m)"`),t+=r.height;t+=Oyt-KX;for(let r of e.badges)t+=KX,n+=`<g class="pele-node${r.overflow?` pele-cynefin-overflow`:``}"${r.overflow?``:` data-id="${mq(r.text)}"`}><rect x="${K(e.cx-r.w/2)}" y="${K(t)}" width="${K(r.w)}" height="${K(r.h)}" rx="${dJ}" fill="var(--_bg)" stroke="var(--_b)"${r.overflow?` stroke-dasharray="3 2"`:``}/>`+gq(r.label,e.cx,t+r.h/2,` class="pele-label" font-size="${a}"${r.overflow?` fill="var(--_m)"`:``}`,c)+`</g>`,t+=r.h;return`<g class="pele-cynefin-domain" data-id="${e.name}">${n}</g>`},ae=/* @__PURE__ */ new Map,L=``;GX.forEach(([e,t,n],r)=>{let i=h[r];i.cx=T+y*(t+.5),i.cy=E+b*(n+.5),ae.set(e,i),L+=ie(i)}),g.cx=D,g.cy=O,ae.set(`confusion`,g),L+=ie(g);let oe=(e,t,n)=>e===g?((t-D)/(_+4))**2+((n-O)/(v+4))**2<=1:Math.abs(t-e.cx)<=e.w/2+8&&Math.abs(n-e.cy)<=e.h/2+8,se=``,ce=/* @__PURE__ */ new Map;for(let t of e.transitions){let e=ae.get(t.from),n=ae.get(t.to);if(!e||!n||e===n)continue;let r=t.from<t.to?`${t.from} ${t.to}`:`${t.to} ${t.from}`,a=ce.get(r)??0;ce.set(r,a+1);let s=n.cx-e.cx,l=n.cy-e.cy,u=Math.hypot(s,l)||1,d=(e.cx+n.cx)/2,f=(e.cy+n.cy)/2,p=-l*(d-D)+s*(f-O)>=0?1:-1,m=-l/u*p,h=s/u*p,y=(e!==g&&n!==g&&Math.abs(s)>1&&Math.abs(l)>1?2*(Math.hypot(_*m,v*h)+16):u*.15)+a*56,b=d+m*y,x=f+h*y,S=t=>{let r=1-t;return[r*r*e.cx+2*r*t*b+t*t*n.cx,r*r*e.cy+2*r*t*x+t*t*n.cy]},C=(e,t,n,r)=>{for(let i=0;i<16;i++){let i=(t+n)/2;oe(e,...S(i))===r?t=i:n=i}return(t+n)/2},w=1;for(;w<=48&&oe(e,...S(w/48));)w++;if(w>48)continue;let E=C(e,(w-1)/48,w/48,!0);for(;w<=48&&!oe(n,...S(w/48));)w++;let A=w>48?1:C(n,(w-1)/48,w/48,!1),[j,M]=S(E),[N,P]=S(A),F=(e,t,n)=>(1-E)*(1-A)*e+((1-E)*A+E*(1-A))*t+E*A*n,ee=F(e.cx,b,n.cx),te=F(e.cy,x,n.cy),I=Math.hypot(N-ee,P-te)||1,ne=(N-ee)/I,re=(P-te)/I,ie=cJ(`arrow_point`,N,P,ne,re,`var(--_l)`);N-=ne*sJ(`arrow_point`),P-=re*sJ(`arrow_point`);let L=``;if(t.label){let e=UJ(t.label,!1,o,i,Tyt),[n,r]=S((E+A)/2),a=Math.abs(m)*e.width/2+Math.abs(h)*e.height/2+6,s=e.width/2+4;L=gq(e,Math.min(Math.max(n+m*a,T+s),Math.max(k-s,T+s)),r+h*a,` class="pele-edge-label" font-size="${i}"`,c)}se+=`<g class="pele-edge" data-id="${t.from}-${t.to}"><path d="M${K(j)},${K(M)}Q${K(ee)},${K(te)} ${K(N)},${K(P)}" fill="none" stroke="var(--_l)"/>`+ie+L+`</g>`}let le=Math.ceil(Math.max(C,x.width)+2*s),ue=Math.ceil(w+S+2*s);return{svg:_J(`cynefin`,le,ue,r,n,e,gq(x,T+C/2,s+x.height/2,` class="pele-title" font-weight="var(--_tw)"`)+`<g class="pele-cynefin-regions">${te}</g>`+I+re+L+(se?`<g class="pele-edges">${se}</g>`:``)),width:le,height:ue,links:[]}}var jyt={type:`cynefin`,parse:(e,t,n)=>fyt(myt(e),n),render:Ayt};function Myt(e){return e===`markdown`||e===`string`||e===`text`?e:`markdown`}var Nyt=class{type=`er`;direction=`TB`;entities=/* @__PURE__ */ new Map;relationships=[];classes=/* @__PURE__ */ new Map;subgraphs=[];title;accTitle;accDescr;subgraphLookup=/* @__PURE__ */ new Map;claimed=/* @__PURE__ */ new Set;addEntity(e,t=``){let n=this.entities.get(e);return n===void 0?(n={id:`entity-${e}-${this.entities.size}`,label:e,alias:t,attributes:[],cssClasses:`default`,cssStyles:[]},this.entities.set(e,n)):!n.alias&&t&&(n.alias=t),n}addAttributes(e,t){let n=this.addEntity(e);for(let e=t.length-1;e>=0;e--){let r=t[e];r.keys??=[],r.comment??=``,n.attributes.push(r)}}addRelationship(e,t,n,r){let i=this.subgraphLookup.has(e)?e:this.addEntity(e).id,a=this.subgraphLookup.has(n)?n:this.addEntity(n).id;this.relationships.push({entityA:i,roleA:t,entityB:a,relSpec:r})}setDirection(e){this.direction=e}addCssStyles(e,t){if(t)for(let n of e){let e=this.entities.get(n);if(e)for(let n of t)e.cssStyles.push(n);let r=this.subgraphLookup.get(n);if(r)for(let e of t)r.cssStyles.push(e)}}addClass(e,t){for(let n of e){let e=this.classes.get(n);if(e===void 0&&(e={id:n,styles:[],textStyles:[]},this.classes.set(n,e)),t)for(let n of t)n.includes(`color`)&&e.textStyles.push(n.replace(`fill`,`bgFill`)),e.styles.push(n)}}setClass(e,t){for(let n of e){let e=this.entities.get(n);if(e)for(let n of t)e.cssClasses+=` `+n;let r=this.subgraphLookup.get(n);if(r)for(let e of t)r.classes.push(e)}}addSubGraph(e,t,n){let r=e.text.trim(),i=/* @__PURE__ */ new Set,a=[],o;for(let e of t.flat()){if(typeof e!=`string`){e?.stmt===`dir`&&(o=e.value);continue}let t=e.trim();t===``||i.has(t)||(i.add(t),this.claimed.has(e)||a.push(e))}for(let e of a)this.claimed.add(e);let s={id:r,nodes:a,title:(n.text||``).trim(),classes:[],cssStyles:[],dir:o,labelType:Myt(n.type)};return this.subgraphs.push(s),this.subgraphLookup.set(r,s),r}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,``)}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
1000
1000
|
`)}},Pyt=/* @__PURE__ */ `$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`.split(`.`),YX=1,XX=2,ZX=4,QX=8,$X=/* @__PURE__ */ new Uint8Array(128);for(let e=0;e<128;e++){let t=e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95,n=t&&(e<48||e>57);t&&($X[e]|=YX|XX|QX),n&&($X[e]|=ZX)}for(let e of`-*`)$X[e.charCodeAt(0)]|=YX|XX|QX;$X[46]|=YX|QX,$X[42]|=ZX;for(let e of`[](),`)$X[e.charCodeAt(0)]|=QX;var Fyt=/accTitle\s*:\s*/iy,Iyt=/accDescr\s*:\s*/iy,Lyt=/accDescr\s*\{\s*/iy,Ryt=[/.*direction\s+TB[^\n]*/iy,/.*direction\s+BT[^\n]*/iy,/.*direction\s+RL[^\n]*/iy,/.*direction\s+LR[^\n]*/iy],eZ=/direction/gi,tZ=/[\n\r\u2028\u2029]/g;function zyt(e,t){return e<128?($X[e]&t)!==0:e>=192||e===181}function Byt(e){let t=e.length,n=[],r=[],i=[],a=0,o=0,s=-2,c=0,l=-1,u=-2,d=-1,f=-1,p=-1,m=(t,a,s)=>{n.push(t),r.push(e.slice(a,s)),i.push(a),o=s},h=(t,n)=>(t.lastIndex=n,t.test(e)?t.lastIndex:-1),g=t=>{for(let n=0;n<t.length;n++){let r=t.charCodeAt(n),i=e.charCodeAt(o+n);if(i!==r&&(r<97||r>122||(i|32)!==r))return!1}return!0},_=t=>g(t)&&!aq(e.charCodeAt(o+t.length)),v=t=>{let n=e.charCodeAt(t);return n>=65&&n<=90?n+32:n},y=n=>(tZ.lastIndex=n,tZ.test(e)?tZ.lastIndex-1:t),b=t=>{for(;rq(e.charCodeAt(t));)t++;return t},x=()=>{if(s===-1||s<o&&(eZ.lastIndex=o,s=eZ.test(e)?eZ.lastIndex-9:-1,s===-1)||o<c||(l<o&&(l=y(o)),s>=l))return!1;for(let e=0;e<4;e++){let t=h(Ryt[e],o);if(t>=0)return m(18+e,o,t),!0}return c=l,!1},S=()=>{let t=e.indexOf(`"`,o+1);if(t===-1){m(45,o,o+1);return}let n=t>o+1;for(let r=o+1;n&&r<t;r++){let t=e.charCodeAt(r);(t===37||t===92||t===13||t===10||t===11||t===8)&&(n=!1)}m(n?31:44,o,t+1)},C=t=>{let n=e.charCodeAt(o+1);if(n===43&&(t===49||t===48)){m(t===49?39:38,o,o+2);return}let r=b(o+1);if(e.charCodeAt(r)===46&&rq(e.charCodeAt(r+1)))m(32,o,b(r+2));else{if(t===49){if(eq(n)){let t=o+2;for(;eq(e.charCodeAt(t));)t++;let n=e.charCodeAt(t);if(aq(n)||n===34||n===39){m(40,o,o+1);return}}else if(n===45||n===46){let t=e.charCodeAt(o+2);if(t===45||t===46){m(40,o,o+1);return}}if(!aq(n)){m(33,o,o+1);return}}m(29,o,r)}},w=t=>{let n=e.charCodeAt(o+1);switch(t){case 101:if(_(`erdiagram`))m(2,o,o+9);else if(_(`end`)){let t=o+3;for(;eq(e.charCodeAt(t));)t++;m(16,o,t)}else return!1;return!0;case 115:if(_(`style`))a=6,m(27,o,o+5);else if(_(`subgraph`))m(17,o,o+8);else return!1;return!0;case 99:if(_(`classdef`))a=6,m(22,o,o+8);else if(_(`class`))m(26,o,o+5);else return!1;return!0;case 111:if(_(`one or zero`))m(37,o,o+11);else if(_(`one or more`)||_(`one or many`))m(39,o,o+11);else if(_(`one`))m(40,o,o+3);else if(_(`only one`))m(40,o,o+8);else if(n===124)m(37,o,o+2);else if(n===123)m(38,o,o+2);else if(_(`optionally to`))m(42,o,o+13);else return!1;return!0;case 122:if(_(`zero or one`))m(37,o,o+11);else if(_(`zero or more`)||_(`zero or many`))m(38,o,o+12);else return!1;return!0;case 109:if(g(`many(0)`))m(38,o,o+7);else if(g(`many(1)`))m(39,o,o+7);else if(_(`many`))m(38,o,o+4);else return!1;return!0;case 116:return _(`to`)?(m(43,o,o+2),!0):!1;case 117:return n!==46&&n!==45&&n!==124?!1:(m(41,o,o+1),!0);case 124:if(v(o+1)===111&&!aq(e.charCodeAt(o+2)))m(37,o,o+2);else if(n===124)m(40,o,o+2);else if(n===123)m(39,o,o+2);else return!1;return!0;case 125:if(v(o+1)===111&&!aq(e.charCodeAt(o+2)))m(38,o,o+2);else if(n===124)m(39,o,o+2);else return!1;return!0;case 46:return n!==46&&n!==45?!1:(m(42,o,o+2),!0);case 45:if(n===45)m(43,o,o+2);else if(n===46)m(42,o,o+2);else return!1;return!0}return!1},T=t=>{let n;if((t===97||t===65)&&g(`acc`)){if((n=h(Fyt,o))>=0){a=3,m(11,o,n);return}if((n=h(Iyt,o))>=0){a=4,m(13,o,n);return}if((n=h(Lyt,o))>=0){a=5,o=n;return}}if(!x()){switch(t){case 32:case 9:case 13:n=o+1;for(let t=e.charCodeAt(n);t===32||t===9||t===13;t=e.charCodeAt(n))n++;o=n;return;case 10:for(n=o+1;e.charCodeAt(n)===10;)n++;m(4,o,n);return;case 34:S();return;case 123:a=1,m(7,o,o+1);return;case 35:m(30,o,o+1);return;case 44:m(25,o,o+1);return;case 58:e.charCodeAt(o+1)===58&&e.charCodeAt(o+2)===58?m(6,o,o+3):m(5,o,o+1);return;case 91:m(9,o,o+1);return;case 93:m(10,o,o+1);return}if(rq(t)){C(t);return}if(!w(t>=65&&t<=90?t+32:t)){if(t>=128||($X[t]&YX)!==0){n=o+1;for(let t=e.charCodeAt(n);t>=128||($X[t]&YX)!==0;t=e.charCodeAt(n))n++;m(23,o,n);return}m(45,o,o+1)}}},E=()=>{if(u===-1||u<o&&(u=e.indexOf(`~`,o),u===-1))return!1;if(p<o){let n=o;for(;n<t&&!eq(e.charCodeAt(n));)n++;p=n}if(u>=p||(d<o&&(d=y(o),f=e.lastIndexOf(`~`,d-1)),f<=u))return!1;let n=f+1;for(;n<t&&!eq(e.charCodeAt(n));)n++;return m(34,o,n),!0},D=n=>{if(eq(n)){for(o++;eq(e.charCodeAt(o));)o++;return}let r=n|32;if((r===112||r===102||r===117)&&(e.charCodeAt(o+1)|32)==107&&!aq(e.charCodeAt(o+2)))m(35,o,o+2);else if(!E()){if(zyt(n,ZX)){let n=o+1;for(;n<t&&zyt(e.charCodeAt(n),QX);)n++;m(34,o,n);return}if(n===96){a=2,o++;return}if(n===34){let t=e.indexOf(`"`,o+1);if(t!==-1){m(36,o,t+1);return}}else if(n===125){a=0,m(8,o,o+1);return}m(45,o,o+1)}};for(;o<t;){let s=e.charCodeAt(o),c;switch(a){case 0:T(s);break;case 1:D(s);break;case 2:s===96?(a=1,o++):(c=e.indexOf("`",o),m(34,o,c===-1?t:c));break;case 3:case 4:c=e.indexOf(`
|
|
1001
|
-
`,o),m(a===3?12:14,o,c===-1?t:c),a=0;break;case 5:s===125?(a=0,o++):(c=e.indexOf(`}`,o),m(15,o,c===-1?t:c));break;case 6:if(s===10){for(c=o+1;e.charCodeAt(c)===10;)c++;a=0,m(4,o,c)}else if(eq(s))for(o++;eq(e.charCodeAt(o));)o++;else if(s===58)m(5,o,o+1);else if(s===44)m(25,o,o+1);else if(s===35)m(30,o,o+1);else if(s===59)m(28,o,o+1);else if(s>=128||($X[s]&XX)!==0){c=o+1;for(let t=e.charCodeAt(c);t>=128||($X[t]&XX)!==0;t=e.charCodeAt(c))c++;m(24,o,c)}else return n.push(1),r.push(``),i.push(o),{types:n,texts:r,starts:i}}}let O=a===0?3:a===3?12:a===4?14:a===5?15:-1;return O!==-1&&(n.push(O),r.push(``),i.push(t)),n.push(0),r.push(``),i.push(t),{types:n,texts:r,starts:i}}var nZ=/* @__PURE__ */ new Map([[37,`ZERO_OR_ONE`],[38,`ZERO_OR_MORE`],[39,`ONE_OR_MORE`],[40,`ONLY_ONE`],[41,`MD_PARENT`]]),Vyt=[`TB`,`BT`,`RL`,`LR`],Hyt=`'UNICODE_TEXT', 'NUM', 'ENTITY_NAME', 'DECIMAL_NUM', 'ENTITY_ONE'`,Uyt=`'ZERO_OR_ONE', 'ZERO_OR_MORE', 'ONE_OR_MORE', 'ONLY_ONE', 'MD_PARENT'`,rZ=`'EOF', 'NEWLINE', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'SUBGRAPH', 'direction_tb', 'direction_bt', 'direction_rl', 'direction_lr', 'CLASSDEF', 'CLASS', 'STYLE', `+Hyt;function Wyt(e,t){let{types:n,texts:r,starts:i}=Byt(e),a=0,o=t=>{let o=n[a];throw o===1?FK(`er`,e,i[a],``,!0):FK(`er`,e,i[a],`Expecting ${t}, got '${o===45?r[a]:Pyt[o]}'`)},s=e=>(n[a]!==e&&o(`'${Pyt[e]}'`),r[a++]),c=()=>{let e=n[a];e!==4&&e!==28&&e!==3&&o(`'EOF', 'NEWLINE', 'SEMI'`),a++},l=e=>e===23||e===31||e===29||e===32||e===33,u=()=>{let e=n[a];l(e)||o(Hyt);let t=r[a++];return e===31?t.slice(1,-1):t},d=()=>{let e=[];for(;;){let t=n[a];if(t!==23&&t!==24&&o(`'UNICODE_TEXT', 'STYLE_TEXT'`),e.push(r[a++]),n[a]!==25)return e;a++}},f=e=>e===24||e===29||e===5||e===30,p=()=>{let e=[];for(;;){f(n[a])||o(`'STYLE_TEXT', 'COLON', 'NUM', 'BRKT'`);let t=r[a++];for(;f(n[a]);)t+=r[a++];if(e.push(t),n[a]!==25)return e;a++}},m=()=>{let e=nZ.get(n[a++]),t=n[a];t!==43&&t!==42&&o(`'NON_IDENTIFYING', 'IDENTIFYING'`);let r=t===43?`IDENTIFYING`:`NON_IDENTIFYING`;a++;let i=nZ.get(n[a]);return i===void 0?o(Uyt):(a++,{cardA:i,relType:r,cardB:e})},h=()=>{let e=n[a];e!==44&&e!==31&&e!==23&&o(`'UNICODE_TEXT', 'ENTITY_NAME', 'WORD'`);let t=r[a++];return e===23?t:t.slice(1,-1)},g=e=>n[a]===45&&r[a]===e,_=()=>{let e=[];do{let t=s(34);g(`?`)&&(t+=r[a++]),n[a]!==34&&o(t.endsWith(`?`)?`'ATTRIBUTE_WORD'`:`'ATTRIBUTE_WORD', '?'`);let i={type:t,name:r[a++]};if(n[a]===35){let e=[r[a++]];for(;g(`,`);)a++,e.push(s(35));i.keys=e}n[a]===36&&(i.comment=r[a++].slice(1,-1)),e.push(i)}while(n[a]!==8);return e.reverse()},v=()=>{if(n[a]!==7)return;if(a++,n[a]===8){a++;return}let e=_();return a++,e},y=()=>{let e=u(),r=n[a];if(r===9){a++;let r=u();s(10);let i;n[a]===6&&(a++,i=d());let o=v();return t.addEntity(e,r),o&&t.addAttributes(e,o),i&&t.setClass([e],i),[e]}let i;if(r===6&&(a++,i=d(),r=n[a]),nZ.has(r)){let r=m(),o=u(),c;n[a]===6&&(a++,c=d()),s(5);let l=h();return t.addEntity(e),t.addEntity(o),t.addRelationship(e,l,o,r),i&&t.setClass([e],i),c&&t.setClass([o],c),[e,o]}let o=v();return t.addEntity(e),o&&t.addAttributes(e,o),i&&t.setClass([e],i),[e]};s(2);let b=[{id:``,title:``,list:[]}],x=b[0],S=!1;for(;;){let e=n[a];switch(e){case 4:a++;break;case 3:a++,S&&o(`'END', ${rZ}`);return;case 16:{S||o(rZ),a++;let e=t.addSubGraph({text:x.id},x.list,{text:x.title});b.pop(),x=b[b.length-1],S=b.length>1,S&&x.list.push(e);break}case 17:{a++;let e=u(),t=e;if(n[a]===9){for(a++,t=u();l(n[a]);)t+=` `+u();s(10)}c(),x={id:e,title:t,list:[]},b.push(x),S=!0;break}case 11:{a++;let e=s(12).trim();t.setAccTitle(e),S&&x.list.push(e);break}case 13:{a++;let e=s(14).trim();t.setAccDescription(e),S&&x.list.push(e);break}case 15:{let e=r[a++].trim();t.setAccDescription(e),S&&x.list.push(e);break}case 18:case 19:case 20:case 21:{a++;let n=Vyt[e-18];S?x.list.push({stmt:`dir`,value:n}):t.setDirection(n);break}case 22:{let e=r[a++],n=d(),i=p();c(),t.addClass(n,i),S&&x.list.push(e);break}case 26:{let e=r[a++],n=d();t.setClass(n,d()),S&&x.list.push(e);break}case 27:{let e=r[a++],n=d(),i=p();c(),t.addCssStyles(n,i),S&&x.list.push(e);break}default:{l(e)||o(S?`'END', ${rZ}`:rZ);let t=y();if(S)for(let e of t)x.list.push(e)}}}}var Gyt=[];function Kyt(e){let t=[],n=[],r=e.subgraphs,i=t=>{let n=[];for(let r of t){let t=e.classes.get(r);if(t!==void 0){for(let e of t.styles)n.push(e.trim());for(let e of t.textStyles)n.push(e.trim())}}return n},a=/* @__PURE__ */ new Map,o=/* @__PURE__ */ new Set;for(let e=r.length-1;e>=0;e--){let t=r[e];o.add(t.id);for(let e of t.nodes)a.set(e,t.id)}for(let e=r.length-1;e>=0;e--){let n=r[e];t.push({id:n.id,label:n.title,alias:``,attributes:Gyt,isGroup:!0,parentId:a.get(n.id),cssStyles:n.cssStyles,cssCompiledStyles:i(n.classes),cssClasses:n.classes.join(` `),dir:n.dir,labelType:n.labelType})}let s=/* @__PURE__ */ new Map;for(let[n,r]of e.entities)o.has(n)?s.set(r.id,n):t.push({id:r.id,label:r.label,alias:r.alias,attributes:r.attributes,isGroup:!1,parentId:a.get(n),cssStyles:r.cssStyles,cssCompiledStyles:i(r.cssClasses.split(` `)),cssClasses:r.cssClasses,dir:void 0,labelType:`markdown`});return e.relationships.forEach((e,t)=>{n.push({id:`id_${e.entityA}_${e.entityB}_${t}`,start:s.get(e.entityA)??e.entityA,end:s.get(e.entityB)??e.entityB,label:e.roleA,arrowTypeStart:e.relSpec.cardB.toLowerCase(),arrowTypeEnd:e.relSpec.cardA.toLowerCase(),pattern:e.relSpec.relType===`IDENTIFYING`?`solid`:`dashed`})}),{nodes:t,edges:n}}var iZ=18,qyt=5,Jyt=6,aZ=10,Yyt=3.5;function oZ(e,t,n,r,i){let a=(e,a)=>K(t-r*e-i*a)+`,`+K(n-i*e+r*a),o=e=>`M${a(e,-qyt)}L${a(e,qyt)}`,s=`M${a(0,-Jyt)}L${a(aZ,0)}L${a(0,Jyt)}`,c=e=>`<circle class="pele-marker" cx="${K(t-r*e)}" cy="${K(n-i*e)}" r="${Yyt}" fill="var(--_bg)"/>`,l=e=>`<path class="pele-marker" d="${e}"/>`;switch(e){case`only_one`:return l(o(6)+o(10));case`zero_or_one`:return l(o(6))+c(13.5);case`one_or_more`:return l(s+o(aZ+3.5));case`zero_or_more`:return l(s)+c(aZ+Yyt+.5);case`md_parent`:return`<path class="pele-marker" d="M${a(0,0)}L${a(6,4)}L${a(12,0)}L${a(6,-4)}Z" fill="var(--_bg)"/>`}return``}var Xyt=48,Zyt=20,Qyt=64,sZ=20,cZ=28,$yt=38,ebt=96,tbt=18,nbt=12,rbt=9,lZ=12,ibt=16,uZ=9,abt=260,dZ=1e6,obt=[],sbt=18,cbt=14,lbt=` fill="var(--_s)" stroke="var(--_b)"`;function ubt(e,t,n){let r=e.er?.[t];return typeof r==`number`&&r>0?Math.min(r,2e3):n}function fZ(e,t,n,r,i){let a=e.lines;if(a.length===0)return``;if(a.length===1&&a[0].length===1&&a[0][0].icon===void 0&&a[0][0].style===0)return`<text${r} x="${K(t)}" y="${K(n)}">${pq(a[0][0].text)}</text>`;let o=vq(e),s=``,c=``;for(let r of a){let a=!1;for(let e of r)e.icon!==void 0&&(a=!0);let l=t,u=!1;for(let t of r){if(t.icon!==void 0){let r=e.size*1.1;c+=`<svg class="pele-icon" data-icon="${mq(t.icon)}" x="${K(l)}" y="${K(n-e.size*.35-r/2)}" width="${K(r)}" height="${K(r)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${i?.(t.icon)??``}</svg>`}else if(t.text!==``){let e=a||!u?` x="${K(l)}" y="${K(n)}"`:``;s+=`<tspan${e}${_q(t.style&~o)}>${pq(t.text)}</tspan>`,u=!0}l+=t.width}n+=e.lineHeight}return`<text${yq(r,o)} xml:space="preserve">${s}</text>${c}`}function pZ(e){let t=SX(e);return t===e?e:t.replace(/</g,`<`).replace(/>/g,`>`)}function dbt(e,t,n){return YJ(e.direction)?JJ(n,r=>fbt(e,t,n,r)):fbt(e,t,n,!1)}function fbt(e,t,n,r){let i=Kyt(e),a=n.fontSize??16,o=Math.round(a*.875),s=n.measurer??fq(n.fontFamily),c=n.padding??8,l=n.icons,u=/* @__PURE__ */ new Map,d=[],f=[];i.nodes.forEach((e,t)=>u.set(e.id,t));let p=[],m=[],h=[],g=/* @__PURE__ */ new Map,_=[];for(let e of i.edges){let t=u.get(e.start),n=u.get(e.end);if(t===void 0||n===void 0)continue;let r=WJ(e.label,!0,s,o,200),i;if(t===n){i={label:r,band:0,at:0};let e=g.get(t);e?e.push(i):g.set(t,[i])}_.push(i),h.push(e),m.push(r),p.push({src:t,dst:n,minlen:1,labelW:r.width>0?r.width+12:0,labelH:r.height>0?r.height+4:0,route:[],labelX:0,labelY:0})}let v=t=>{let n=t;for(let e=0;e<i.nodes.length;e++){let e=i.nodes[n].parentId,t=e===void 0?void 0:u.get(e);if(t===void 0)break;let r=i.nodes[t].dir;if(r)return r===`LR`||r===`RL`;n=t}return e.direction===`LR`||e.direction===`RL`};for(let e=0;e<i.nodes.length;e++){let t=i.nodes[e],n=mJ(t.cssStyles.length>0?t.cssCompiledStyles.concat(t.cssStyles):t.cssCompiledStyles),r=+!!n.bold|(n.italic?2:0),c=n.fontSize??a,l=n.fontSize??o,u=n.fontSize??Math.round(a*.75),p=t.isGroup?WJ(t.label,!0,s,c,4e3,r):WJ(t.alias||t.label,!0,s,c,240,r),m=g.get(e)??obt,h=m.length>0&&!t.isGroup&&v(e),_={node:t,style:n,label:p,w:0,h:0,headH:0,rows:[],cols:[],rowSize:l,keySize:u,below:h},y=0,b=0;for(let e of m)e.band=Math.max($yt,h?e.label.width+12:e.label.height+6),b+=e.band,y=Math.max(y,h?e.label.height:e.label.width);let x=Math.max(ebt,h?b+8:0),S;if(t.isGroup)S=Qq(0,0),S.isGroup=!0,S.dir=t.dir?Xq(t.dir):void 0,S.padX=sZ,S.padTop=_.label.height>0?_.label.height+16:sZ,S.padBottom=sZ,S.minW=Math.max(_.label.width+2*sZ-12,ebt);else{let e=Math.max(p.height,Math.round(c*1.5));if(t.attributes.length===0)_.w=Math.max(p.width+2*tbt,x),_.h=Math.max(e+2*nbt,h?0:b+8);else{let n=Math.round(l*1.5),i=[0,0,0,0];for(let e of t.attributes){let t=[WJ(pZ(e.type),!0,s,l,dZ,r),WJ(pZ(e.name),!0,s,l,dZ,r),WJ(e.keys.join(`, `),!1,s,u,dZ,r),WJ(pZ(e.comment),!0,s,l,abt,r)],a=n;for(let e=0;e<4;e++)t[e].width>i[e]&&(i[e]=t[e].width),t[e].height>a&&(a=t[e].height);_.rows.push({cells:t,h:a+uZ}),_.h+=a+uZ}let a=0,o=0;for(let e of i)e!==0&&(o+=e+(a>0?ibt:0),a++);_.w=Math.max(o+2*lZ,p.width+2*tbt,x);let c=a>0?(_.w-o-2*lZ)/a:0,d=lZ;for(let e of i)_.cols.push(d),e>0&&(d+=e+c+ibt);_.headH=e+2*rbt,_.h+=_.headH}let n=m.length>0?2*(iZ+cZ*.75+10+y):0;S=h?Qq(_.w,_.h+n):Qq(_.w+n,_.h)}S.seq=d.length,d.push(_),f.push(S)}i.nodes.forEach((e,t)=>{f[t].parent=e.parentId===void 0?-1:u.get(e.parentId)??-1});let y=eJ(f,p,r?`TB`:Xq(e.direction),{nodeSep:ubt(t,`nodeSpacing`,Xyt),edgeSep:Zyt,rankSep:ubt(t,`rankSpacing`,Qyt),portSep:24});mbt(p,f,d);let b=y.width;for(let[e,t]of g){let n=f[e];if(!n.isGroup)continue;let r=0;for(let e of t)r=Math.max(r,e.label.width);b=Math.max(b,n.x+n.w/2+iZ+cZ*.75+10+r)}let x=WJ(e.title,!1,s,a,4e3,1),S=x.height>0?x.height+12:0,C=Math.max(b,x.width);Zq(f,p,c+(C-b)/2,c+S);let w=Math.ceil(C+2*c),T=Math.ceil(y.height+S+2*c),E=[],D=/* @__PURE__ */ new Map,O=!1;for(let e of f)e.isGroup&&(O=!0);if(O)for(let e of p)tJ(D,e.route);let k=``,A=``;for(let e=0;e<d.length;e++){let t=d[e],r=f[e],i=t.node,a=hJ(i.cssClasses.replace(/^default\s?/,``));if(r.isGroup){t.w=r.w,t.h=r.h;let e=r.x-r.w/2,n=r.y-r.h/2,o=nJ(r,t.label.width,D,sZ);k+=`<g class="pele-cluster${a}" data-id="${mq(i.id)}"><rect x="${K(e)}" y="${K(n)}" width="${K(r.w)}" height="${K(r.h)}" rx="${fJ}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${t.style.shape}/>`+gq(t.label,o,n+8+t.label.height/2,` class="pele-cluster-label" fill="var(--_m)"${t.style.text}`,l)+`</g>`;continue}let o=t.w,s=t.h,c=-o/2,u=-s/2,p=t.style.text,m=`x="${K(c)}" y="${K(u)}" width="${K(o)}" height="${K(s)}" rx="${fJ}"`,h=gq(t.label,0,t.rows.length>0?u+t.headH/2:0,` class="pele-label"${p}`,l),g=RK(i.alias||i.label);if(/ internal-link(?: |$)/.test(a+` `)&&h!==``&&n.links!==!1){let e=wq(Sq(g),n)!==void 0,t=pq(g);h=`<a class="internal-link"${e?` href="${t}"${Eq(n)}`:``} data-href="${t}">${h}</a>`,E.push({id:i.label,href:g,internal:!0})}let _;if(t.rows.length===0)_=`<rect ${m}${lbt}${t.style.shape}/>`+h;else{let e=Math.round(t.rowSize*1.5),n=t.style.stroke?pq(t.style.stroke):`var(--_b)`,r=``,i=``,a=u+t.headH;for(let n=0;n<t.rows.length;n++){let s=t.rows[n];if(n%2==0){let e=`x="${K(c)}" width="${K(o)}"`;n===t.rows.length-1?r+=`<rect ${e} y="${K(a)}" height="${K(s.h)}" rx="${fJ}"/><rect ${e} y="${K(a)}" height="${K(s.h/2)}"/>`:r+=`<rect ${e} y="${K(a)}" height="${K(s.h)}"/>`}let u=a+uZ/2+e/2+t.rowSize*.35,[d,f,m,h]=s.cells;i+=fZ(d,c+t.cols[0],u,` class="pele-er-type" fill="var(--_m)"${p}`,l)+fZ(f,c+t.cols[1],u,` class="pele-er-name"${p}`,l)+fZ(m,c+t.cols[2],u,` class="pele-er-keys" font-size="${t.keySize}" fill="var(--_m)"${p}`,l)+fZ(h,c+t.cols[3],u,` class="pele-er-comment" fill="var(--_m)"${p}`,l),a+=s.h}let s=K(u+t.headH);_=`<rect ${m}${lbt}${t.style.shape}/><g class="pele-er-stripes" fill="var(--_bg)"${t.style.shape.includes(`fill:`)?` opacity="0.6"`:``}>${r}</g><path class="pele-er-divider" d="M${K(c)},${s}H${K(c+o)}" stroke="${n}"/><rect ${m} fill="none" stroke="var(--_b)"${t.style.line}/>`+h+`<g class="pele-er-attributes" font-size="${t.rowSize}">${i}</g>`}A+=`<g class="pele-node pele-entity${a}" data-id="${mq(i.label)}" transform="translate(${K(r.x)},${K(r.y)})">${_}</g>`}for(let[e,t]of g){let n=d[e],r=0;for(let e of t)r+=e.band;let i=Math.min(1,Math.max((n.below?n.w:n.h)-8,0)/r),a=-r*i/2;for(let e of t)e.band*=i,e.at=a+e.band/2,a+=e.band}let j=``,M=``;for(let e=0;e<p.length;e++){let t=p[e],n=h[e],r=m[e],i,a,o,s=_[e];if(s){let e=f[t.src],c=d[t.src],l=Math.max(Math.min(s.band/2-6,13),1),u=iZ+cZ*.75+6;if(c.below){let d=e.x+s.at,f=e.y+c.h/2,p=K(f+iZ),m=K(f+iZ+cZ);i=`M${K(d-l)},${K(f)}V${p}C${K(d-l)},${m} ${K(d+l)},${m} ${K(d+l)},${p}V${K(f)}`,a=oZ(n.arrowTypeStart,d-l,f,0,-1),o=oZ(n.arrowTypeEnd,d+l,f,0,-1),t.labelX=d,t.labelY=f+u+r.height/2}else{let d=e.x+c.w/2,f=e.y+s.at,p=K(d+iZ),m=K(d+iZ+cZ);i=`M${K(d)},${K(f-l)}H${p}C${m},${K(f-l)} ${m},${K(f+l)} ${p},${K(f+l)}H${K(d)}`,a=oZ(n.arrowTypeStart,d,f-l,-1,0),o=oZ(n.arrowTypeEnd,d,f+l,-1,0),t.labelX=d+u+r.width/2,t.labelY=f}}else{let e=pbt(t.route);if(e.length<6)continue;hbt(e,0,d[t.src],f[t.src]),hbt(e,e.length-3,d[t.dst],f[t.dst]);let r=Math.abs(e[e.length-3]-e[0]),s=Math.abs(e[e.length-2]-e[1]),c=e.length===6&&(r<.01||s<.01||Math.hypot(r,s)<=3*iZ)?0:iZ,l=oJ(e,void 0,c,c);i=c>0?`M${K(l.sx)},${K(l.sy)}L${l.d.slice(1)}L${K(l.ex)},${K(l.ey)}`:l.d,a=oZ(n.arrowTypeStart,l.sx,l.sy,l.sdx,l.sdy),o=oZ(n.arrowTypeEnd,l.ex,l.ey,l.edx,l.edy)}let c=n.pattern===`dashed`;if(j+=`<g class="pele-edge pele-er-${c?`non-identifying`:`identifying`}" data-id="${mq(n.id)}"><path d="${i}"${c?` stroke-dasharray="4 3"`:``}/>`+a+o+`</g>`,r.width>0){let e=t.labelX,i=t.labelY;M+=lJ(n.id,r,e,i,``,l)}}return{svg:vJ(`er`,w,T,a,n,e,gq(x,w/2,c+x.height/2,` class="pele-title" font-weight="var(--_tw)"`)+(k?`<g class="pele-clusters">${k}</g>`:``)+(j?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${j}</g>`:``)+(M?`<g class="pele-edge-labels" font-size="${o}">${M}</g>`:``)+`<g class="pele-nodes">${A}</g>`),width:w,height:T,links:E}}function pbt(e){let t=e.slice(0,3);for(let n=3;n<e.length;n+=3){let r=t.length-3,i=i=>Math.abs(t[r+i]-e[n+i])<.01&&Math.abs(e[n+i]-e[n+3+i])<.01;n+3<e.length&&(i(0)||i(1))||t.push(e[n],e[n+1],e[n+2])}return t}function mbt(e,t,n){let r=/* @__PURE__ */ new Map,i=(e,n,i,a)=>{let o=t[e],s=n[i]-o.x,c=n[i+1]-o.y,l;if(Math.abs(Math.abs(c)-o.h/2)<.5)l=c<0?0:2;else if(Math.abs(Math.abs(s)-o.w/2)<.5)l=s<0?3:1;else return;let u=e*4+l,d={route:n,at:i,toward:n[a+(l&1?1:0)]},f=r.get(u);f?f.push(d):r.set(u,[d])};for(let t of e){let e=t.route.length-3;t.src===t.dst||e<3||(i(t.src,t.route,0,3),i(t.dst,t.route,e,e-3))}for(let[e,i]of r){if(i.length<2)continue;let r=e>>2,a=(e&1)==1,o=t[r].isGroup?t[r]:n[r],s=a?o.h:o.w,c=Math.max(Math.min(sbt,(s-2*cbt)/(i.length-1)),0),l=a?t[r].y:t[r].x;i.sort((e,t)=>e.toward-t.toward);for(let e=0;e<i.length;e++)i[e].route[i[e].at+ +!!a]=l+(e-(i.length-1)/2)*c}}function hbt(e,t,n,r){if(r.isGroup)return;let i=e[t]-r.x,a=e[t+1]-r.y;r.w!==n.w&&Math.abs(Math.abs(i)-r.w/2)<.5&&(e[t]-=Math.sign(i)*(r.w-n.w)/2),r.h!==n.h&&Math.abs(Math.abs(a)-r.h/2)<.5&&(e[t+1]-=Math.sign(a)*(r.h-n.h)/2)}var gbt={type:`er`,parse(e,t,n){let r=new Nyt;return n&&(r.title=n),Wyt(e,r),r},render:dbt},_bt=/* @__PURE__ */ new Map([[`ui`,`ui`],[`pcr`,`processor`],[`processor`,`processor`],[`rmo`,`readmodel`],[`readmodel`,`readmodel`],[`cmd`,`command`],[`command`,`command`],[`evt`,`event`],[`event`,`event`]]),vbt=/* @__PURE__ */ new Map([[`trigger`,[0,`UI/Automation`,`UI/A: `]],[`state`,[100,`Command/Read Model`,`C/RM: `]],[`stream`,[200,`Events`,`Stream: `]]]);function ybt(e){return e===`ui`||e===`processor`?`trigger`:e===`event`?`stream`:`state`}function mZ(e){let t=e.indexOf(`{`),n=e.lastIndexOf(`}`),r=(t!==-1&&n>t?e.slice(t+1,n):t===-1&&e.length>=2?e.slice(1,-1):``).replace(/\r/g,``).split(`
|
|
1001
|
+
`,o),m(a===3?12:14,o,c===-1?t:c),a=0;break;case 5:s===125?(a=0,o++):(c=e.indexOf(`}`,o),m(15,o,c===-1?t:c));break;case 6:if(s===10){for(c=o+1;e.charCodeAt(c)===10;)c++;a=0,m(4,o,c)}else if(eq(s))for(o++;eq(e.charCodeAt(o));)o++;else if(s===58)m(5,o,o+1);else if(s===44)m(25,o,o+1);else if(s===35)m(30,o,o+1);else if(s===59)m(28,o,o+1);else if(s>=128||($X[s]&XX)!==0){c=o+1;for(let t=e.charCodeAt(c);t>=128||($X[t]&XX)!==0;t=e.charCodeAt(c))c++;m(24,o,c)}else return n.push(1),r.push(``),i.push(o),{types:n,texts:r,starts:i}}}let O=a===0?3:a===3?12:a===4?14:a===5?15:-1;return O!==-1&&(n.push(O),r.push(``),i.push(t)),n.push(0),r.push(``),i.push(t),{types:n,texts:r,starts:i}}var nZ=/* @__PURE__ */ new Map([[37,`ZERO_OR_ONE`],[38,`ZERO_OR_MORE`],[39,`ONE_OR_MORE`],[40,`ONLY_ONE`],[41,`MD_PARENT`]]),Vyt=[`TB`,`BT`,`RL`,`LR`],Hyt=`'UNICODE_TEXT', 'NUM', 'ENTITY_NAME', 'DECIMAL_NUM', 'ENTITY_ONE'`,Uyt=`'ZERO_OR_ONE', 'ZERO_OR_MORE', 'ONE_OR_MORE', 'ONLY_ONE', 'MD_PARENT'`,rZ=`'EOF', 'NEWLINE', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'SUBGRAPH', 'direction_tb', 'direction_bt', 'direction_rl', 'direction_lr', 'CLASSDEF', 'CLASS', 'STYLE', `+Hyt;function Wyt(e,t){let{types:n,texts:r,starts:i}=Byt(e),a=0,o=t=>{let o=n[a];throw o===1?FK(`er`,e,i[a],``,!0):FK(`er`,e,i[a],`Expecting ${t}, got '${o===45?r[a]:Pyt[o]}'`)},s=e=>(n[a]!==e&&o(`'${Pyt[e]}'`),r[a++]),c=()=>{let e=n[a];e!==4&&e!==28&&e!==3&&o(`'EOF', 'NEWLINE', 'SEMI'`),a++},l=e=>e===23||e===31||e===29||e===32||e===33,u=()=>{let e=n[a];l(e)||o(Hyt);let t=r[a++];return e===31?t.slice(1,-1):t},d=()=>{let e=[];for(;;){let t=n[a];if(t!==23&&t!==24&&o(`'UNICODE_TEXT', 'STYLE_TEXT'`),e.push(r[a++]),n[a]!==25)return e;a++}},f=e=>e===24||e===29||e===5||e===30,p=()=>{let e=[];for(;;){f(n[a])||o(`'STYLE_TEXT', 'COLON', 'NUM', 'BRKT'`);let t=r[a++];for(;f(n[a]);)t+=r[a++];if(e.push(t),n[a]!==25)return e;a++}},m=()=>{let e=nZ.get(n[a++]),t=n[a];t!==43&&t!==42&&o(`'NON_IDENTIFYING', 'IDENTIFYING'`);let r=t===43?`IDENTIFYING`:`NON_IDENTIFYING`;a++;let i=nZ.get(n[a]);return i===void 0?o(Uyt):(a++,{cardA:i,relType:r,cardB:e})},h=()=>{let e=n[a];e!==44&&e!==31&&e!==23&&o(`'UNICODE_TEXT', 'ENTITY_NAME', 'WORD'`);let t=r[a++];return e===23?t:t.slice(1,-1)},g=e=>n[a]===45&&r[a]===e,_=()=>{let e=[];do{let t=s(34);g(`?`)&&(t+=r[a++]),n[a]!==34&&o(t.endsWith(`?`)?`'ATTRIBUTE_WORD'`:`'ATTRIBUTE_WORD', '?'`);let i={type:t,name:r[a++]};if(n[a]===35){let e=[r[a++]];for(;g(`,`);)a++,e.push(s(35));i.keys=e}n[a]===36&&(i.comment=r[a++].slice(1,-1)),e.push(i)}while(n[a]!==8);return e.reverse()},v=()=>{if(n[a]!==7)return;if(a++,n[a]===8){a++;return}let e=_();return a++,e},y=()=>{let e=u(),r=n[a];if(r===9){a++;let r=u();s(10);let i;n[a]===6&&(a++,i=d());let o=v();return t.addEntity(e,r),o&&t.addAttributes(e,o),i&&t.setClass([e],i),[e]}let i;if(r===6&&(a++,i=d(),r=n[a]),nZ.has(r)){let r=m(),o=u(),c;n[a]===6&&(a++,c=d()),s(5);let l=h();return t.addEntity(e),t.addEntity(o),t.addRelationship(e,l,o,r),i&&t.setClass([e],i),c&&t.setClass([o],c),[e,o]}let o=v();return t.addEntity(e),o&&t.addAttributes(e,o),i&&t.setClass([e],i),[e]};s(2);let b=[{id:``,title:``,list:[]}],x=b[0],S=!1;for(;;){let e=n[a];switch(e){case 4:a++;break;case 3:a++,S&&o(`'END', ${rZ}`);return;case 16:{S||o(rZ),a++;let e=t.addSubGraph({text:x.id},x.list,{text:x.title});b.pop(),x=b[b.length-1],S=b.length>1,S&&x.list.push(e);break}case 17:{a++;let e=u(),t=e;if(n[a]===9){for(a++,t=u();l(n[a]);)t+=` `+u();s(10)}c(),x={id:e,title:t,list:[]},b.push(x),S=!0;break}case 11:{a++;let e=s(12).trim();t.setAccTitle(e),S&&x.list.push(e);break}case 13:{a++;let e=s(14).trim();t.setAccDescription(e),S&&x.list.push(e);break}case 15:{let e=r[a++].trim();t.setAccDescription(e),S&&x.list.push(e);break}case 18:case 19:case 20:case 21:{a++;let n=Vyt[e-18];S?x.list.push({stmt:`dir`,value:n}):t.setDirection(n);break}case 22:{let e=r[a++],n=d(),i=p();c(),t.addClass(n,i),S&&x.list.push(e);break}case 26:{let e=r[a++],n=d();t.setClass(n,d()),S&&x.list.push(e);break}case 27:{let e=r[a++],n=d(),i=p();c(),t.addCssStyles(n,i),S&&x.list.push(e);break}default:{l(e)||o(S?`'END', ${rZ}`:rZ);let t=y();if(S)for(let e of t)x.list.push(e)}}}}var Gyt=[];function Kyt(e){let t=[],n=[],r=e.subgraphs,i=t=>{let n=[];for(let r of t){let t=e.classes.get(r);if(t!==void 0){for(let e of t.styles)n.push(e.trim());for(let e of t.textStyles)n.push(e.trim())}}return n},a=/* @__PURE__ */ new Map,o=/* @__PURE__ */ new Set;for(let e=r.length-1;e>=0;e--){let t=r[e];o.add(t.id);for(let e of t.nodes)a.set(e,t.id)}for(let e=r.length-1;e>=0;e--){let n=r[e];t.push({id:n.id,label:n.title,alias:``,attributes:Gyt,isGroup:!0,parentId:a.get(n.id),cssStyles:n.cssStyles,cssCompiledStyles:i(n.classes),cssClasses:n.classes.join(` `),dir:n.dir,labelType:n.labelType})}let s=/* @__PURE__ */ new Map;for(let[n,r]of e.entities)o.has(n)?s.set(r.id,n):t.push({id:r.id,label:r.label,alias:r.alias,attributes:r.attributes,isGroup:!1,parentId:a.get(n),cssStyles:r.cssStyles,cssCompiledStyles:i(r.cssClasses.split(` `)),cssClasses:r.cssClasses,dir:void 0,labelType:`markdown`});return e.relationships.forEach((e,t)=>{n.push({id:`id_${e.entityA}_${e.entityB}_${t}`,start:s.get(e.entityA)??e.entityA,end:s.get(e.entityB)??e.entityB,label:e.roleA,arrowTypeStart:e.relSpec.cardB.toLowerCase(),arrowTypeEnd:e.relSpec.cardA.toLowerCase(),pattern:e.relSpec.relType===`IDENTIFYING`?`solid`:`dashed`})}),{nodes:t,edges:n}}var iZ=18,qyt=5,Jyt=6,aZ=10,Yyt=3.5;function oZ(e,t,n,r,i){let a=(e,a)=>K(t-r*e-i*a)+`,`+K(n-i*e+r*a),o=e=>`M${a(e,-qyt)}L${a(e,qyt)}`,s=`M${a(0,-Jyt)}L${a(aZ,0)}L${a(0,Jyt)}`,c=e=>`<circle class="pele-marker" cx="${K(t-r*e)}" cy="${K(n-i*e)}" r="${Yyt}" fill="var(--_bg)"/>`,l=e=>`<path class="pele-marker" d="${e}"/>`;switch(e){case`only_one`:return l(o(6)+o(10));case`zero_or_one`:return l(o(6))+c(13.5);case`one_or_more`:return l(s+o(aZ+3.5));case`zero_or_more`:return l(s)+c(aZ+Yyt+.5);case`md_parent`:return`<path class="pele-marker" d="M${a(0,0)}L${a(6,4)}L${a(12,0)}L${a(6,-4)}Z" fill="var(--_bg)"/>`}return``}var Xyt=48,Zyt=20,Qyt=64,sZ=20,cZ=28,$yt=38,ebt=96,tbt=18,nbt=12,rbt=9,lZ=12,ibt=16,uZ=9,abt=260,dZ=1e6,obt=[],sbt=18,cbt=14,lbt=` fill="var(--_s)" stroke="var(--_b)"`;function ubt(e,t,n){let r=e.er?.[t];return typeof r==`number`&&r>0?Math.min(r,2e3):n}function fZ(e,t,n,r,i){let a=e.lines;if(a.length===0)return``;if(a.length===1&&a[0].length===1&&a[0][0].icon===void 0&&a[0][0].style===0)return`<text${r} x="${K(t)}" y="${K(n)}">${pq(a[0][0].text)}</text>`;let o=vq(e),s=``,c=``;for(let r of a){let a=!1;for(let e of r)e.icon!==void 0&&(a=!0);let l=t,u=!1;for(let t of r){if(t.icon!==void 0){let r=e.size*1.1;c+=`<svg class="pele-icon" data-icon="${mq(t.icon)}" x="${K(l)}" y="${K(n-e.size*.35-r/2)}" width="${K(r)}" height="${K(r)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${i?.(t.icon)??``}</svg>`}else if(t.text!==``){let e=a||!u?` x="${K(l)}" y="${K(n)}"`:``;s+=`<tspan${e}${_q(t.style&~o)}>${pq(t.text)}</tspan>`,u=!0}l+=t.width}n+=e.lineHeight}return`<text${yq(r,o)} xml:space="preserve">${s}</text>${c}`}function pZ(e){let t=SX(e);return t===e?e:t.replace(/</g,`<`).replace(/>/g,`>`)}function dbt(e,t,n){return JJ(e.direction)?qJ(n,r=>fbt(e,t,n,r)):fbt(e,t,n,!1)}function fbt(e,t,n,r){let i=Kyt(e),a=n.fontSize??16,o=Math.round(a*.875),s=n.measurer??fq(n.fontFamily),c=n.padding??8,l=n.icons,u=/* @__PURE__ */ new Map,d=[],f=[];i.nodes.forEach((e,t)=>u.set(e.id,t));let p=[],m=[],h=[],g=/* @__PURE__ */ new Map,_=[];for(let e of i.edges){let t=u.get(e.start),n=u.get(e.end);if(t===void 0||n===void 0)continue;let r=UJ(e.label,!0,s,o,200),i;if(t===n){i={label:r,band:0,at:0};let e=g.get(t);e?e.push(i):g.set(t,[i])}_.push(i),h.push(e),m.push(r),p.push({src:t,dst:n,minlen:1,labelW:r.width>0?r.width+12:0,labelH:r.height>0?r.height+4:0,route:[],labelX:0,labelY:0})}let v=t=>{let n=t;for(let e=0;e<i.nodes.length;e++){let e=i.nodes[n].parentId,t=e===void 0?void 0:u.get(e);if(t===void 0)break;let r=i.nodes[t].dir;if(r)return r===`LR`||r===`RL`;n=t}return e.direction===`LR`||e.direction===`RL`};for(let e=0;e<i.nodes.length;e++){let t=i.nodes[e],n=pJ(t.cssStyles.length>0?t.cssCompiledStyles.concat(t.cssStyles):t.cssCompiledStyles),r=+!!n.bold|(n.italic?2:0),c=n.fontSize??a,l=n.fontSize??o,u=n.fontSize??Math.round(a*.75),p=t.isGroup?UJ(t.label,!0,s,c,4e3,r):UJ(t.alias||t.label,!0,s,c,240,r),m=g.get(e)??obt,h=m.length>0&&!t.isGroup&&v(e),_={node:t,style:n,label:p,w:0,h:0,headH:0,rows:[],cols:[],rowSize:l,keySize:u,below:h},y=0,b=0;for(let e of m)e.band=Math.max($yt,h?e.label.width+12:e.label.height+6),b+=e.band,y=Math.max(y,h?e.label.height:e.label.width);let x=Math.max(ebt,h?b+8:0),S;if(t.isGroup)S=Qq(0,0),S.isGroup=!0,S.dir=t.dir?Xq(t.dir):void 0,S.padX=sZ,S.padTop=_.label.height>0?_.label.height+16:sZ,S.padBottom=sZ,S.minW=Math.max(_.label.width+2*sZ-12,ebt);else{let e=Math.max(p.height,Math.round(c*1.5));if(t.attributes.length===0)_.w=Math.max(p.width+2*tbt,x),_.h=Math.max(e+2*nbt,h?0:b+8);else{let n=Math.round(l*1.5),i=[0,0,0,0];for(let e of t.attributes){let t=[UJ(pZ(e.type),!0,s,l,dZ,r),UJ(pZ(e.name),!0,s,l,dZ,r),UJ(e.keys.join(`, `),!1,s,u,dZ,r),UJ(pZ(e.comment),!0,s,l,abt,r)],a=n;for(let e=0;e<4;e++)t[e].width>i[e]&&(i[e]=t[e].width),t[e].height>a&&(a=t[e].height);_.rows.push({cells:t,h:a+uZ}),_.h+=a+uZ}let a=0,o=0;for(let e of i)e!==0&&(o+=e+(a>0?ibt:0),a++);_.w=Math.max(o+2*lZ,p.width+2*tbt,x);let c=a>0?(_.w-o-2*lZ)/a:0,d=lZ;for(let e of i)_.cols.push(d),e>0&&(d+=e+c+ibt);_.headH=e+2*rbt,_.h+=_.headH}let n=m.length>0?2*(iZ+cZ*.75+10+y):0;S=h?Qq(_.w,_.h+n):Qq(_.w+n,_.h)}S.seq=d.length,d.push(_),f.push(S)}i.nodes.forEach((e,t)=>{f[t].parent=e.parentId===void 0?-1:u.get(e.parentId)??-1});let y=eJ(f,p,r?`TB`:Xq(e.direction),{nodeSep:ubt(t,`nodeSpacing`,Xyt),edgeSep:Zyt,rankSep:ubt(t,`rankSpacing`,Qyt),portSep:24});mbt(p,f,d);let b=y.width;for(let[e,t]of g){let n=f[e];if(!n.isGroup)continue;let r=0;for(let e of t)r=Math.max(r,e.label.width);b=Math.max(b,n.x+n.w/2+iZ+cZ*.75+10+r)}let x=UJ(e.title,!1,s,a,4e3,1),S=x.height>0?x.height+12:0,C=Math.max(b,x.width);Zq(f,p,c+(C-b)/2,c+S);let w=Math.ceil(C+2*c),T=Math.ceil(y.height+S+2*c),E=[],D=/* @__PURE__ */ new Map,O=!1;for(let e of f)e.isGroup&&(O=!0);if(O)for(let e of p)tJ(D,e.route);let k=``,A=``;for(let e=0;e<d.length;e++){let t=d[e],r=f[e],i=t.node,a=mJ(i.cssClasses.replace(/^default\s?/,``));if(r.isGroup){t.w=r.w,t.h=r.h;let e=r.x-r.w/2,n=r.y-r.h/2,o=nJ(r,t.label.width,D,sZ);k+=`<g class="pele-cluster${a}" data-id="${mq(i.id)}"><rect x="${K(e)}" y="${K(n)}" width="${K(r.w)}" height="${K(r.h)}" rx="${dJ}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${t.style.shape}/>`+gq(t.label,o,n+8+t.label.height/2,` class="pele-cluster-label" fill="var(--_m)"${t.style.text}`,l)+`</g>`;continue}let o=t.w,s=t.h,c=-o/2,u=-s/2,p=t.style.text,m=`x="${K(c)}" y="${K(u)}" width="${K(o)}" height="${K(s)}" rx="${dJ}"`,h=gq(t.label,0,t.rows.length>0?u+t.headH/2:0,` class="pele-label"${p}`,l),g=RK(i.alias||i.label);if(/ internal-link(?: |$)/.test(a+` `)&&h!==``&&n.links!==!1){let e=wq(Sq(g),n)!==void 0,t=pq(g);h=`<a class="internal-link"${e?` href="${t}"${Eq(n)}`:``} data-href="${t}">${h}</a>`,E.push({id:i.label,href:g,internal:!0})}let _;if(t.rows.length===0)_=`<rect ${m}${lbt}${t.style.shape}/>`+h;else{let e=Math.round(t.rowSize*1.5),n=t.style.stroke?pq(t.style.stroke):`var(--_b)`,r=``,i=``,a=u+t.headH;for(let n=0;n<t.rows.length;n++){let s=t.rows[n];if(n%2==0){let e=`x="${K(c)}" width="${K(o)}"`;n===t.rows.length-1?r+=`<rect ${e} y="${K(a)}" height="${K(s.h)}" rx="${dJ}"/><rect ${e} y="${K(a)}" height="${K(s.h/2)}"/>`:r+=`<rect ${e} y="${K(a)}" height="${K(s.h)}"/>`}let u=a+uZ/2+e/2+t.rowSize*.35,[d,f,m,h]=s.cells;i+=fZ(d,c+t.cols[0],u,` class="pele-er-type" fill="var(--_m)"${p}`,l)+fZ(f,c+t.cols[1],u,` class="pele-er-name"${p}`,l)+fZ(m,c+t.cols[2],u,` class="pele-er-keys" font-size="${t.keySize}" fill="var(--_m)"${p}`,l)+fZ(h,c+t.cols[3],u,` class="pele-er-comment" fill="var(--_m)"${p}`,l),a+=s.h}let s=K(u+t.headH);_=`<rect ${m}${lbt}${t.style.shape}/><g class="pele-er-stripes" fill="var(--_bg)"${t.style.shape.includes(`fill:`)?` opacity="0.6"`:``}>${r}</g><path class="pele-er-divider" d="M${K(c)},${s}H${K(c+o)}" stroke="${n}"/><rect ${m} fill="none" stroke="var(--_b)"${t.style.line}/>`+h+`<g class="pele-er-attributes" font-size="${t.rowSize}">${i}</g>`}A+=`<g class="pele-node pele-entity${a}" data-id="${mq(i.label)}" transform="translate(${K(r.x)},${K(r.y)})">${_}</g>`}for(let[e,t]of g){let n=d[e],r=0;for(let e of t)r+=e.band;let i=Math.min(1,Math.max((n.below?n.w:n.h)-8,0)/r),a=-r*i/2;for(let e of t)e.band*=i,e.at=a+e.band/2,a+=e.band}let j=``,M=``;for(let e=0;e<p.length;e++){let t=p[e],n=h[e],r=m[e],i,a,o,s=_[e];if(s){let e=f[t.src],c=d[t.src],l=Math.max(Math.min(s.band/2-6,13),1),u=iZ+cZ*.75+6;if(c.below){let d=e.x+s.at,f=e.y+c.h/2,p=K(f+iZ),m=K(f+iZ+cZ);i=`M${K(d-l)},${K(f)}V${p}C${K(d-l)},${m} ${K(d+l)},${m} ${K(d+l)},${p}V${K(f)}`,a=oZ(n.arrowTypeStart,d-l,f,0,-1),o=oZ(n.arrowTypeEnd,d+l,f,0,-1),t.labelX=d,t.labelY=f+u+r.height/2}else{let d=e.x+c.w/2,f=e.y+s.at,p=K(d+iZ),m=K(d+iZ+cZ);i=`M${K(d)},${K(f-l)}H${p}C${m},${K(f-l)} ${m},${K(f+l)} ${p},${K(f+l)}H${K(d)}`,a=oZ(n.arrowTypeStart,d,f-l,-1,0),o=oZ(n.arrowTypeEnd,d,f+l,-1,0),t.labelX=d+u+r.width/2,t.labelY=f}}else{let e=pbt(t.route);if(e.length<6)continue;hbt(e,0,d[t.src],f[t.src]),hbt(e,e.length-3,d[t.dst],f[t.dst]);let r=Math.abs(e[e.length-3]-e[0]),s=Math.abs(e[e.length-2]-e[1]),c=e.length===6&&(r<.01||s<.01||Math.hypot(r,s)<=3*iZ)?0:iZ,l=oJ(e,void 0,c,c);i=c>0?`M${K(l.sx)},${K(l.sy)}L${l.d.slice(1)}L${K(l.ex)},${K(l.ey)}`:l.d,a=oZ(n.arrowTypeStart,l.sx,l.sy,l.sdx,l.sdy),o=oZ(n.arrowTypeEnd,l.ex,l.ey,l.edx,l.edy)}let c=n.pattern===`dashed`;if(j+=`<g class="pele-edge pele-er-${c?`non-identifying`:`identifying`}" data-id="${mq(n.id)}"><path d="${i}"${c?` stroke-dasharray="4 3"`:``}/>`+a+o+`</g>`,r.width>0){let e=t.labelX,i=t.labelY;M+=lJ(n.id,r,e,i,``,l)}}return{svg:_J(`er`,w,T,a,n,e,gq(x,w/2,c+x.height/2,` class="pele-title" font-weight="var(--_tw)"`)+(k?`<g class="pele-clusters">${k}</g>`:``)+(j?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${j}</g>`:``)+(M?`<g class="pele-edge-labels" font-size="${o}">${M}</g>`:``)+`<g class="pele-nodes">${A}</g>`),width:w,height:T,links:E}}function pbt(e){let t=e.slice(0,3);for(let n=3;n<e.length;n+=3){let r=t.length-3,i=i=>Math.abs(t[r+i]-e[n+i])<.01&&Math.abs(e[n+i]-e[n+3+i])<.01;n+3<e.length&&(i(0)||i(1))||t.push(e[n],e[n+1],e[n+2])}return t}function mbt(e,t,n){let r=/* @__PURE__ */ new Map,i=(e,n,i,a)=>{let o=t[e],s=n[i]-o.x,c=n[i+1]-o.y,l;if(Math.abs(Math.abs(c)-o.h/2)<.5)l=c<0?0:2;else if(Math.abs(Math.abs(s)-o.w/2)<.5)l=s<0?3:1;else return;let u=e*4+l,d={route:n,at:i,toward:n[a+(l&1?1:0)]},f=r.get(u);f?f.push(d):r.set(u,[d])};for(let t of e){let e=t.route.length-3;t.src===t.dst||e<3||(i(t.src,t.route,0,3),i(t.dst,t.route,e,e-3))}for(let[e,i]of r){if(i.length<2)continue;let r=e>>2,a=(e&1)==1,o=t[r].isGroup?t[r]:n[r],s=a?o.h:o.w,c=Math.max(Math.min(sbt,(s-2*cbt)/(i.length-1)),0),l=a?t[r].y:t[r].x;i.sort((e,t)=>e.toward-t.toward);for(let e=0;e<i.length;e++)i[e].route[i[e].at+ +!!a]=l+(e-(i.length-1)/2)*c}}function hbt(e,t,n,r){if(r.isGroup)return;let i=e[t]-r.x,a=e[t+1]-r.y;r.w!==n.w&&Math.abs(Math.abs(i)-r.w/2)<.5&&(e[t]-=Math.sign(i)*(r.w-n.w)/2),r.h!==n.h&&Math.abs(Math.abs(a)-r.h/2)<.5&&(e[t+1]-=Math.sign(a)*(r.h-n.h)/2)}var gbt={type:`er`,parse(e,t,n){let r=new Nyt;return n&&(r.title=n),Wyt(e,r),r},render:dbt},_bt=/* @__PURE__ */ new Map([[`ui`,`ui`],[`pcr`,`processor`],[`processor`,`processor`],[`rmo`,`readmodel`],[`readmodel`,`readmodel`],[`cmd`,`command`],[`command`,`command`],[`evt`,`event`],[`event`,`event`]]),vbt=/* @__PURE__ */ new Map([[`trigger`,[0,`UI/Automation`,`UI/A: `]],[`state`,[100,`Command/Read Model`,`C/RM: `]],[`stream`,[200,`Events`,`Stream: `]]]);function ybt(e){return e===`ui`||e===`processor`?`trigger`:e===`event`?`stream`:`state`}function mZ(e){let t=e.indexOf(`{`),n=e.lastIndexOf(`}`),r=(t!==-1&&n>t?e.slice(t+1,n):t===-1&&e.length>=2?e.slice(1,-1):``).replace(/\r/g,``).split(`
|
|
1002
1002
|
`);for(;r.length>0&&r[0].trim()===``;)r.shift();for(;r.length>0&&r[r.length-1].trim()===``;)r.pop();let i=1/0;for(let e of r)e.trim()!==``&&(i=Math.min(i,e.length-e.trimStart().length));return r.map(e=>e.slice(Math.min(i,e.length)).trimEnd()).join(`
|
|
1003
|
-
`)}function bbt(e,t){let n=/* @__PURE__ */ new Set;for(let t of e.frames){if(n.has(t.name)){let n=PK(e.$source,t.$offset).line;throw new NK(`Duplicate event modeling frame ID "${t.name}" on line ${n}`,`semantic`,{type:`eventmodeling`,line:n})}n.add(t.name)}let r=/* @__PURE__ */ new Map;for(let t of e.dataEntities)r.has(t.name)||r.set(t.name,t.dataBlockValue);let i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Map,o=(e,t)=>{let n=ybt(e),r=t===void 0?n:`${n} ${t}`,o=i.get(r);if(!o){let[e,s,c]=vbt.get(n),l=e;t!==void 0&&(l=a.get(n)??e+1,a.set(n,l+1)),o={index:l,label:t===void 0?s:c+t,group:n,namespace:t},i.set(r,o)}return o},s=[],c=/* @__PURE__ */ new Map,l=[];e.frames.forEach((e,t)=>{let n=e.entityIdentifier.split(`.`),i=n.length===2?n[0]:void 0,a=_bt.get(e.modelEntityType)??`event`,u=e.dataInlineValue===void 0?void 0:mZ(e.dataInlineValue);if(e.dataReference){let t=r.get(e.dataReference.$refText);t!==void 0&&(u=mZ(t))}let d={id:e.name,kind:a,entity:e.entityIdentifier,name:n.length===2?n[1]:e.entityIdentifier,namespace:i,reset:e.$type===`EmResetFrame`,lane:o(a,i),data:u,dataType:e.dataType};if(s.push(d),c.set(d.id,d),e.sourceFrames.length>0){let t=new Set(e.sourceFrames.map(e=>e.$refText));for(let e of s)t.has(e.id)&&l.push({source:e,target:d})}else if(t>0&&!d.reset){for(let e=t-1;e>=0;e--)if(s[e].lane!==d.lane){l.push({source:s[e],target:d});break}}});let u=e=>e.map(e=>e.entityIdentifier.$refText);return{type:`eventmodeling`,title:e.title&&
|
|
1004
|
-
`):void 0,boxes:s,lanes:[...i.values()].sort((e,t)=>e.index-t.index),relations:l,notes:e.noteEntities.map(e=>({frame:e.sourceFrame.$refText,text:mZ(e.dataBlockValue),dataType:e.dataType})),specifications:e.gwtEntities.map(e=>({frame:e.sourceFrame.$refText,given:u(e.givenStatements),when:u(e.whenStatements),then:u(e.thenStatements)})),entities:e.modelEntities.map(e=>e.name)}}var hZ=/[\t ]*accDescr(?:[\t ]*:(?:[^\n\r]*?(?=%%)|[^\n\r]*)|\s*({))/y;function xbt(){let e=!1;return(t,n)=>{hZ.lastIndex=n;let r=hZ.exec(t);if(r===null)return-1;let i=hZ.lastIndex;if(r[1]===void 0)return i;if(e)return-1;let a=t.indexOf(`}`,i);return e=a===-1,a+1||-1}}function gZ(e=`ACC_DESCR`){return{...
|
|
1005
|
-
`))if(r.length<=t)n.push(r);else for(let e=0;e<r.length;e+=t)n.push(r.slice(e,e+t));return n}function kZ(e,t,n,r,i){let a=``;for(let i=0;i<e.length;i++)e[i]!==``&&(a+=`<tspan x="${K(t)}" y="${K(n+i*r)}">${pq(e[i])}</tspan>`);return a===``?``:`<text${i} xml:space="preserve">${a}</text>`}function Fbt(e,t,n){return
|
|
1006
|
-
`))}let D=Math.ceil(y+2*a),O=Math.ceil(v+a);return{svg:
|
|
1003
|
+
`)}function bbt(e,t){let n=/* @__PURE__ */ new Set;for(let t of e.frames){if(n.has(t.name)){let n=PK(e.$source,t.$offset).line;throw new NK(`Duplicate event modeling frame ID "${t.name}" on line ${n}`,`semantic`,{type:`eventmodeling`,line:n})}n.add(t.name)}let r=/* @__PURE__ */ new Map;for(let t of e.dataEntities)r.has(t.name)||r.set(t.name,t.dataBlockValue);let i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Map,o=(e,t)=>{let n=ybt(e),r=t===void 0?n:`${n} ${t}`,o=i.get(r);if(!o){let[e,s,c]=vbt.get(n),l=e;t!==void 0&&(l=a.get(n)??e+1,a.set(n,l+1)),o={index:l,label:t===void 0?s:c+t,group:n,namespace:t},i.set(r,o)}return o},s=[],c=/* @__PURE__ */ new Map,l=[];e.frames.forEach((e,t)=>{let n=e.entityIdentifier.split(`.`),i=n.length===2?n[0]:void 0,a=_bt.get(e.modelEntityType)??`event`,u=e.dataInlineValue===void 0?void 0:mZ(e.dataInlineValue);if(e.dataReference){let t=r.get(e.dataReference.$refText);t!==void 0&&(u=mZ(t))}let d={id:e.name,kind:a,entity:e.entityIdentifier,name:n.length===2?n[1]:e.entityIdentifier,namespace:i,reset:e.$type===`EmResetFrame`,lane:o(a,i),data:u,dataType:e.dataType};if(s.push(d),c.set(d.id,d),e.sourceFrames.length>0){let t=new Set(e.sourceFrames.map(e=>e.$refText));for(let e of s)t.has(e.id)&&l.push({source:e,target:d})}else if(t>0&&!d.reset){for(let e=t-1;e>=0;e--)if(s[e].lane!==d.lane){l.push({source:s[e],target:d});break}}});let u=e=>e.map(e=>e.entityIdentifier.$refText);return{type:`eventmodeling`,title:e.title&&gY(e.title)||t,accTitle:e.accTitle?_Y(e.accTitle).replace(/^\s+/g,``):void 0,accDescr:e.accDescr?vY(e.accDescr).replace(/\n\s+/g,`
|
|
1004
|
+
`):void 0,boxes:s,lanes:[...i.values()].sort((e,t)=>e.index-t.index),relations:l,notes:e.noteEntities.map(e=>({frame:e.sourceFrame.$refText,text:mZ(e.dataBlockValue),dataType:e.dataType})),specifications:e.gwtEntities.map(e=>({frame:e.sourceFrame.$refText,given:u(e.givenStatements),when:u(e.whenStatements),then:u(e.thenStatements)})),entities:e.modelEntities.map(e=>e.name)}}var hZ=/[\t ]*accDescr(?:[\t ]*:(?:[^\n\r]*?(?=%%)|[^\n\r]*)|\s*({))/y;function xbt(){let e=!1;return(t,n)=>{hZ.lastIndex=n;let r=hZ.exec(t);if(r===null)return-1;let i=hZ.lastIndex;if(r[1]===void 0)return i;if(e)return-1;let a=t.indexOf(`}`,i);return e=a===-1,a+1||-1}}function gZ(e=`ACC_DESCR`){return{...aY,name:e,scanner:xbt}}var _Z={name:`EM_ID`,pattern:/[_a-zA-Z][\w_]*/y},vZ=e=>({name:e,pattern:e,longer:[_Z]}),yZ=e=>({name:e,pattern:e}),Sbt=[`resetframe`,`readmodel`,`processor`,`timeframe`,`command`,`entity`,`event`,`jsobj`,`figma`,`given`,`json`,`salt`,`html`,`text`,`data`,`note`,`when`,`then`,`rmo`,`cmd`,`evt`,`pcr`,`uri`],bZ=[{...mY(`eventmodeling`),longer:[_Z]},...Sbt.map(vZ),yZ(`->>`),vZ(`gwt`),vZ(`ui`),vZ(`md`),vZ(`tf`),yZ(`[[`),yZ(`]]`),vZ(`rf`),yZ("`"),yZ(`.`),_Z,{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},gZ(`EM_ACC_DESCR`),{...oY,name:`EM_ACC_TITLE`},{...sY,name:`EM_TITLE`},{name:`EM_WS`,pattern:/\s+/y,hidden:!0},{...dY,name:`EM_YAML`},{...fY,name:`EM_DIRECTIVE`},{...pY,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}],xZ=e=>bZ.findIndex(t=>t.name===e),SZ=e=>new Set(e.map(xZ)),CZ={keyword:0,arrow:xZ(`->>`),open:xZ(`[[`),close:xZ(`]]`),tick:xZ("`"),dot:xZ(`.`),id:xZ(`EM_ID`),frameId:xZ(`EM_FID`),inline:xZ(`EM_DATA_INLINE`),block:xZ(`EM_DATA_BLOCK`),accDescr:xZ(`EM_ACC_DESCR`),accTitle:xZ(`EM_ACC_TITLE`),title:xZ(`EM_TITLE`),entity:xZ(`entity`),data:xZ(`data`),note:xZ(`note`),gwt:xZ(`gwt`),given:xZ(`given`),when:xZ(`when`),then:xZ(`then`)},Cbt=SZ([`tf`,`timeframe`]),wbt=SZ([`rf`,`resetframe`]),wZ=SZ([`rmo`,`readmodel`,`ui`,`cmd`,`command`,`evt`,`event`,`pcr`,`processor`]),Tbt=SZ([`json`,`jsobj`,`figma`,`salt`,`uri`,`md`,`html`,`text`]);function Ebt(e){let t=new bY(iY(e,bZ,`eventmodeling`),bZ,`eventmodeling`),n={$type:`EventModel`,modelEntities:[],frames:[],dataEntities:[],noteEntities:[],gwtEntities:[],$source:e},r=e=>t.kinds[t.i]===e,i=(e,n)=>e.has(t.kinds[t.i])?t.take():t.fail(n),a=()=>{let e=t.expect(CZ.id);for(;t.accept(CZ.dot);)e+=`.`+t.expect(CZ.id);return e},o=()=>{if(!t.accept(CZ.tick))return;let e=i(Tbt,`a data type`);return t.expect(CZ.tick),e},s=()=>{let e=[];do i(wZ,`an entity type`),e.push({$type:`EmGwtStatement`,entityIdentifier:{$refText:t.expect(CZ.id)}});while(wZ.has(t.kinds[t.i]));return e};for(t.expect(CZ.keyword);!r(-1);){let e=t.kinds[t.i];if(e===CZ.accDescr)n.accDescr=t.take();else if(e===CZ.accTitle)n.accTitle=t.take();else if(e===CZ.title)n.title=t.take();else if(e===CZ.entity)t.i++,n.modelEntities.push({$type:`EmModelEntity`,name:a()});else if(Cbt.has(e)||wbt.has(e)){let s={$type:Cbt.has(e)?`EmTimeFrame`:`EmResetFrame`,name:``,modelEntityType:``,entityIdentifier:``,sourceFrames:[],$offset:t.tokens.starts[t.i]};for(t.i++,s.name=t.expect(CZ.frameId),s.modelEntityType=i(wZ,`an entity type`),s.entityIdentifier=a();t.accept(CZ.arrow);)s.sourceFrames.push({$refText:t.expect(CZ.frameId)});if(t.accept(CZ.open)&&(s.dataReference={$refText:t.expect(CZ.id)},t.expect(CZ.close)),r(CZ.tick)||r(CZ.inline)){let e=o();e!==void 0&&(s.dataType=e),s.dataInlineValue=t.expect(CZ.inline)}n.frames.push(s)}else if(e===CZ.data){t.i++;let e={$type:`EmDataEntity`,name:t.expect(CZ.id),dataBlockValue:``},r=o();r!==void 0&&(e.dataType=r),e.dataBlockValue=t.expect(CZ.block),n.dataEntities.push(e)}else if(e===CZ.note){t.i++;let e={$type:`EmNoteEntity`,sourceFrame:{$refText:t.expect(CZ.frameId)},dataBlockValue:``},r=o();r!==void 0&&(e.dataType=r),e.dataBlockValue=t.expect(CZ.block),n.noteEntities.push(e)}else if(e===CZ.gwt){t.i++;let e={$type:`EmGwt`,sourceFrame:{$refText:t.expect(CZ.frameId)},givenStatements:[],whenStatements:[],thenStatements:[]};t.expect(CZ.given),e.givenStatements=s(),t.accept(CZ.when)&&(e.whenStatements=s()),t.expect(CZ.then),e.thenStatements=s(),n.gwtEntities.push(e)}else t.fail(`a frame, an entity, a data block, a note, or a specification`)}return n}var Dbt=/* @__PURE__ */ new Map([[`command`,0],[`event`,1],[`readmodel`,2],[`processor`,6]]),TZ=12,EZ=10,Obt=96,kbt=16,Abt=80,DZ=12,jbt=8,Mbt=48,Nbt=80,Pbt=8;function OZ(e,t){let n=[];for(let r of RK(e).split(`
|
|
1005
|
+
`))if(r.length<=t)n.push(r);else for(let e=0;e<r.length;e+=t)n.push(r.slice(e,e+t));return n}function kZ(e,t,n,r,i){let a=``;for(let i=0;i<e.length;i++)e[i]!==``&&(a+=`<tspan x="${K(t)}" y="${K(n+i*r)}">${pq(e[i])}</tspan>`);return a===``?``:`<text${i} xml:space="preserve">${a}</text>`}function Fbt(e,t,n){return qJ(n,r=>Ibt(e,t,n,r))}function Ibt(e,t,n,r){if(r)return Bbt(e,n);let i=n.fontSize??16,a=Math.round(i*.875),o=Math.round(i*.8125),s=Math.round(i*.75),c=Math.round(s*1.4),l=Math.round(o*1.5),u=n.measurer??fq(n.fontFamily,n.fontFamilyMono),d=n.padding??8,f=(e,t,n)=>{let r=0;for(let i of e)r=Math.max(r,u.width(i,t,n));return r},p=/* @__PURE__ */ new Map,m=0;for(let t of e.lanes){let e=UJ(t.label,!1,u,o,4e3,1);m=Math.max(m,e.width),p.set(t,{lane:t,label:e,right:-1/0,y:0,h:0})}m+=2*DZ;let h=[],g=/* @__PURE__ */ new Map,_;for(let t of e.boxes){let e=p.get(t.lane),n=UJ(t.name,!1,u,a,4e3,1),r=t.data?OZ(t.data,Mbt):[],i=Math.max(Obt,Math.max(n.width,f(r,s,4))+2*TZ),o=2*EZ+n.height+(r.length>0?6+r.length*c:0),l=0;if(_){let n=_.x+Math.max(_.w/2,_.w-Abt);l=_.box.lane===t.lane?e.right+kbt:Math.max(n,e.right+kbt)}let d={box:t,name:n,data:r,x:l,y:0,w:i,h:o};e.right=l+i,e.h=Math.max(e.h,o),h.push(d),g.set(t,d),_=d}let v=0;for(let e of h)v=Math.max(v,e.x+e.w);let y=m+v+DZ,b=UJ(e.title,!1,u,i,4e3,1),x=b.height>0?b.height+12:0,S=d,C=d+x,w=C,T=``;for(let e of p.values())e.y=w,e.h+=2*DZ,T+=`<g class="pele-cluster pele-em-lane" data-id="${mq(e.lane.label)}"><rect x="${K(S)}" y="${K(w)}" width="${K(y)}" height="${K(e.h)}" rx="${dJ}" fill="var(--_s)"/>`+gq(e.label,S+DZ+e.label.width/2,w+e.h/2,` class="pele-cluster-label" font-size="${o}" font-weight="var(--_hw)" fill="var(--_m)"`)+`</g>`,w+=e.h+jbt;let E=p.size>0?w-jbt:C,D=``;for(let e of h){let t=p.get(e.box.lane);e.x+=S+m,e.y=t.y+(t.h-e.h)/2;let n=Dbt.get(e.box.kind),r=`x="${K(e.x)}" y="${K(e.y)}" width="${K(e.w)}" height="${K(e.h)}" rx="${dJ}"`,i=n===void 0?`<rect ${r} fill="var(--_bg)" stroke="var(--_b)"/>`:`<rect ${r} fill="var(--_bg)"/><rect ${r} fill="${hJ(n)}" fill-opacity="0.22" stroke="${hJ(n)}"/>`,o=e.y+EZ+e.name.height/2,l=gq(e.name,e.x+e.w/2,o,` class="pele-label" font-size="${a}" font-weight="var(--_hw)"`)+kZ(e.data,e.x+TZ,e.y+EZ+e.name.height+6+c/2+s*.35,c,` class="pele-em-data" font-family="${uJ}" font-size="${s}"`);D+=`<g class="pele-node pele-em-${e.box.kind}${e.box.reset?` pele-em-reset`:``}" data-id="${mq(e.box.id)}">${i}${l}</g>`}let O=``,k=sJ(`arrow_point`);for(let t of e.relations){let e=g.get(t.source),n=g.get(t.target);if(!e||!n||e===n)continue;let r,i;if(e.box.lane===n.box.lane){let t=n.x>=e.x,a=t?e.x+e.w:e.x,o=t?n.x:n.x+n.w,s=e.y+e.h/2,c=n.y+n.h/2,l=o>=a?1:-1;r=`M${K(a)},${K(s)}L${K(o-l*k)},${K(c)}`,i=cJ(`arrow_point`,o,c,l,0,`var(--_l)`)}else{let t=n.y>e.y,a=Math.max(e.x,n.x),o=Math.min(e.x+e.w,n.x+n.w),s=e=>Math.min(24,e/4),c=o-a>=16?(a+o)/2:n.x>e.x?e.x+e.w-s(e.w):e.x+s(e.w),l=o-a>=16?c:n.x>e.x?n.x+s(n.w):n.x+n.w-s(n.w),u=t?e.y+e.h:e.y,d=t?n.y:n.y+n.h,f=t?1:-1,p=d-f*k,m=(u+p)/2;r=c===l?`M${K(c)},${K(u)}V${K(p)}`:`M${K(c)},${K(u)}C${K(c)},${K(m)} ${K(l)},${K(m)} ${K(l)},${K(p)}`,i=cJ(`arrow_point`,l,d,0,f,`var(--_l)`)}O+=`<g class="pele-edge" data-id="${mq(t.source.id)}-${mq(t.target.id)}"><path d="${r}" fill="none" stroke="var(--_l)"/>${i}</g>`}let A=/* @__PURE__ */ new Map;for(let t of e.boxes)A.set(t.id,t.name);let j=``,M=0,N=(e,t,n,r)=>{let i=UJ(`${t} · ${n}${A.has(n)?` `+A.get(n):``}`,!1,u,o,4e3,1),a=Math.max(i.width,f(r,o,0))+2*TZ,s=2*EZ+i.height+r.length*l,c=E+(j===``&&p.size===0?0:Pbt);j+=`<g class="pele-em-${e}" data-id="${mq(n)}"><rect x="${K(S)}" y="${K(c)}" width="${K(a)}" height="${K(s)}" rx="${dJ}" fill="var(--_bg)" stroke="var(--_b)"/>`+gq(i,S+TZ+i.width/2,c+EZ+i.height/2,` font-size="${o}" font-weight="var(--_hw)"`)+kZ(r,S+TZ,c+EZ+i.height+l/2+o*.35,l,` font-size="${o}"`)+`</g>`,E=c+s,M=Math.max(M,a)};for(let t of e.notes)N(`note`,`Note`,t.frame,OZ(t.text,Nbt));for(let t of e.specifications){let e=[`Given ${t.given.join(`, `)}`];t.when.length>0&&e.push(`When ${t.when.join(`, `)}`),e.push(`Then ${t.then.join(`, `)}`),N(`specification`,`Given / When / Then`,t.frame,e.flatMap(e=>OZ(e,Nbt)))}let P=Math.max(p.size>0?y:0,M,b.width),F=Math.ceil(P+2*d),ee=Math.ceil(E+d);return{svg:_J(`eventmodeling`,F,ee,i,n,e,gq(b,F/2,d+b.height/2,` class="pele-title" font-weight="var(--_tw)"`)+T+O+D+j),width:F,height:ee,links:[]}}var Lbt=8,Rbt=120,zbt=20;function Bbt(e,t){let n=t.fontSize??16,r=Math.round(n*.875),i=Math.round(n*.75),a=t.padding??8,o=t.measurer??fq(t.fontFamily,t.fontFamilyMono),s=Math.max(160,(t.maxWidth??320)-2*a),c=new Map(e.boxes.map((e,t)=>[e,t])),l=/* @__PURE__ */ new Map,u=/* @__PURE__ */ new Set;for(let t of e.relations){let n=c.get(t.source),r=c.get(t.target);if(n===void 0||r===void 0||n===r)continue;if(Math.abs(n-r)<2){u.add(e.boxes[Math.max(n,r)]);continue}let i=l.get(t.target);i?(i[0]=Math.min(i[0],n),i[1]=Math.max(i[1],n)):l.set(t.target,[Math.min(n,r),Math.max(n,r)])}let d=/* @__PURE__ */ new Map,f=[];for(let[e,[t,n]]of[...l].sort((e,t)=>e[1][0]-t[1][0])){let r=f.findIndex(e=>e<t);r<0&&(r=f.length),f[r]=n,d.set(e,r)}let p=24+Lbt*Math.max(0,f.length-1),m=Math.max(Rbt,s-p),h=m-2*TZ,g=UJ(e.title,!1,o,n,s,1),_=a+(g.height?g.height+12:0),v=a+g.height,y=Math.max(g.width,m+p),b=``,x=``,S=``,C=/* @__PURE__ */ new Map,w=(e,t,n=0)=>XY(RK(e),o,t,h,n);e.boxes.forEach((e,t)=>{let n=u.has(e)?h-zbt:h,s=ZY(UJ(e.lane.label,!1,o,r,n,1),o,n),c=UJ(e.name,!1,o,r,h-36,1),l=e.data?w(e.data,i,4):void 0,d=Math.max(m,s.width+2*TZ,c.width+2*TZ+36,(l?.width??0)+2*TZ),f=s.height+12,g=2*EZ+c.height+(l?l.height+6:0),x=Dbt.get(e.kind),S=_+f,T=`x="${K(a)}" y="${K(S)}" width="${K(d)}" height="${K(g)}" rx="${dJ}"`;b+=`<g class="pele-cluster pele-em-lane" data-id="${mq(e.lane.label)}">`+QY(s,a+TZ,_,` class="pele-cluster-label" font-size="${r}" font-weight="var(--_hw)" fill="var(--_m)"`)+`<g class="pele-node pele-em-${e.kind}${e.reset?` pele-em-reset`:``}" data-id="${mq(e.id)}"><rect ${T} fill="var(--_bg)" stroke="var(--_b)"/>`+(x===void 0?``:`<rect ${T} fill="${hJ(x)}" fill-opacity="0.22" stroke="${hJ(x)}"/>`)+gq(c,a+TZ+c.width/2,S+EZ+c.height/2,` class="pele-label" font-size="${r}" font-weight="var(--_hw)"`)+`<text class="pele-em-frame" x="${K(a+d-TZ)}" y="${K(S+EZ+r)}" text-anchor="end" font-size="${i}" fill="var(--_m)">${pq(e.id)}</text>`+(l?kZ(l.lines.map(e=>e.map(e=>e.text).join(``)),a+TZ,S+EZ+c.height+6+l.lineHeight/2+i*.35,l.lineHeight,` class="pele-em-data" font-family="${uJ}" font-size="${i}"`):``)+`</g></g>`,C.set(e,{y:S,h:g,w:d,index:t,lane:s.width}),y=Math.max(y,d+p),v=S+g,_=v+28});for(let t of e.relations){let e=C.get(t.source),n=C.get(t.target);if(!e||!n||e===n)continue;let r=n.y>e.y,i=r?1:-1,o=r?e.y+e.h:e.y,s=r?n.y:n.y+n.h,c,l;if(Math.abs(e.index-n.index)===1){let t=a+Math.max(Math.min(e.w,n.w)/2,TZ+(r?n:e).lane+16);c=`M${K(t)},${K(o)}V${K(s-i*sJ(`arrow_point`))}`,l=cJ(`arrow_point`,t,s,0,i,`var(--_l)`)}else{let r=a+y-p+12+Lbt*(d.get(t.target)??0),i=e.y+e.h/2-5,o=n.y+n.h/2+5;c=`M${K(a+e.w)},${K(i)}H${K(r)}V${K(o)}H${K(a+n.w+sJ(`arrow_point`))}`,l=cJ(`arrow_point`,a+n.w,o,-1,0,`var(--_l)`)}x+=`<g class="pele-edge" data-id="${mq(t.source.id)}-${mq(t.target.id)}"><path d="${c}" fill="none" stroke="var(--_l)"/>${l}</g>`}let T=new Map(e.boxes.map(e=>[e.id,e.name])),E=(e,t,n,i)=>{let s=UJ(`${t} · ${n}${T.has(n)?` `+T.get(n):``}`,!1,o,r,h,1),c=w(i,r),l=Math.max(m,s.width+2*TZ,c.width+2*TZ),u=2*EZ+s.height+c.height;S+=`<g class="pele-em-${e}" data-id="${mq(n)}"><rect x="${K(a)}" y="${K(_)}" width="${K(l)}" height="${K(u)}" rx="${dJ}" fill="var(--_bg)" stroke="var(--_b)"/>`+gq(s,a+TZ+s.width/2,_+EZ+s.height/2,` font-size="${r}" font-weight="var(--_hw)"`)+kZ(c.lines.map(e=>e.map(e=>e.text).join(``)),a+TZ,_+EZ+s.height+c.lineHeight/2+r*.35,c.lineHeight,` font-size="${r}"`)+`</g>`,v=_+u,_=v+Pbt,y=Math.max(y,l)};for(let t of e.notes)E(`note`,`Note`,t.frame,t.text);for(let t of e.specifications){let e=[`Given ${t.given.join(`, `)}`];t.when.length&&e.push(`When ${t.when.join(`, `)}`),e.push(`Then ${t.then.join(`, `)}`),E(`specification`,`Given / When / Then`,t.frame,e.join(`
|
|
1006
|
+
`))}let D=Math.ceil(y+2*a),O=Math.ceil(v+a);return{svg:_J(`eventmodeling`,D,O,n,t,e,gq(g,D/2,a+g.height/2,` class="pele-title" font-weight="var(--_tw)"`)+x+b+S),width:D,height:O,links:[]}}var Vbt={type:`eventmodeling`,keepComments:!0,parse:(e,t,n)=>bbt(Ebt(e),n),render:Fbt};function AZ(e){return e===`markdown`||e===`string`||e===`text`?e:`markdown`}function Hbt(e){return e.startsWith(`"`)&&e.endsWith(`"`)?e.substring(1,e.length-1):e}function Ubt(e,t){let n=0;for(let r=0;r<t.length;r++)t[r]===e&&n++;return n}function Wbt(e){let t=e.trim(),n=`arrow_open`;switch(t[0]){case`<`:n=`arrow_point`,t=t.slice(1);break;case`x`:n=`arrow_cross`,t=t.slice(1);break;case`o`:n=`arrow_circle`,t=t.slice(1)}let r=`normal`;return t.includes(`=`)&&(r=`thick`),t.includes(`.`)&&(r=`dotted`),{type:n,stroke:r}}function Gbt(e){let t=e.trim(),n=t.slice(0,-1),r=`arrow_open`;switch(t.slice(-1)){case`x`:r=`arrow_cross`,t.startsWith(`x`)&&(r=`double_`+r,n=n.slice(1));break;case`>`:r=`arrow_point`,t.startsWith(`<`)&&(r=`double_`+r,n=n.slice(1));break;case`o`:r=`arrow_circle`,t.startsWith(`o`)&&(r=`double_`+r,n=n.slice(1))}let i=`normal`,a=n.length-1;n.startsWith(`=`)&&(i=`thick`),n.startsWith(`~`)&&(i=`invisible`);let o=Ubt(`.`,n);return o&&(i=`dotted`,a=o),{type:r,stroke:i,length:a}}var Kbt=class{type=`flowchart`;direction;nodes=/* @__PURE__ */ new Map;edges=[];subgraphs=[];classes=/* @__PURE__ */ new Map;tooltips=/* @__PURE__ */ new Map;defaultEdgeStyle;defaultInterpolate;title;accTitle;accDescr;subgraphLookup=/* @__PURE__ */ new Map;members=/* @__PURE__ */ new Set;edgeById=/* @__PURE__ */ new Map;pairCount=/* @__PURE__ */ new Map;subCount=0;options;constructor(e={}){this.options=e}addVertex(e,t,n,r,i,a,o={},s){if(!e||e.trim().length===0)return;let c;if(s!==void 0){let t=s.includes(`
|
|
1007
1007
|
`)?s+`
|
|
1008
1008
|
`:`{
|
|
1009
1009
|
`+s+`
|
|
1010
1010
|
}`,n;try{n=$K(t)}catch(t){throw new NK(`Metadata of "${e}" is not valid YAML. ${t.message}`,`syntax`,{type:`flowchart`})}c=typeof n==`object`&&n&&!Array.isArray(n)?n:void 0}let l=this.subgraphLookup.get(e);if(l&&c){l.metadata={...l.metadata,...c};return}let u=this.edgeById.get(e);if(u){c?.animate!==void 0&&(u.animate=c.animate),c?.animation!==void 0&&(u.animation=c.animation),c?.curve!==void 0&&(u.interpolate=c.curve);return}let d=this.nodes.get(e);if(d===void 0&&(t===void 0&&n===void 0&&r!=null&&this.options.warn?.(`Style applied to unknown node "${e}". This may indicate a typo. The node will be created automatically.`),d={id:e,labelType:`text`,styles:[],classes:[]},this.nodes.set(e,d)),t===void 0?d.text===void 0&&(d.text=e):(d.labelType=t.type,d.text=Hbt(t.text.trim())),n!==void 0&&(d.type=n),r!=null)for(let e of r)d.styles.push(e);if(i!=null)for(let e of i)d.classes.push(e);if(a!==void 0&&(d.dir=a),d.props===void 0?d.props=o:o!==void 0&&Object.assign(d.props,o),c===void 0)return;if(c.shape){let e=String(c.shape);if(e!==e.toLowerCase()||e.includes(`_`))throw new NK(`No such shape: ${e}. Shape names should be lowercase.`,`semantic`,{type:`flowchart`});if(!Kpt(e))throw new NK(`No such shape: ${e}.`,`semantic`,{type:`flowchart`});d.type=e}let f=typeof c.label==`string`?c.label:void 0;c.label&&(d.text=String(c.label),d.labelType=AZ(c.labelType)),c.icon&&(d.icon=String(c.icon),!f?.trim()&&d.text===e&&(d.text=``)),c.form&&(d.form=String(c.form)),c.pos&&(d.pos=String(c.pos)),c.img&&(d.img=String(c.img),!f?.trim()&&d.text===e&&(d.text=``)),c.constraint&&(d.constraint=String(c.constraint)),c.w&&(d.assetWidth=Number(c.w)),c.h&&(d.assetHeight=Number(c.h))}addSingleLink(e,t,n,r){let i={start:e,end:t,type:void 0,text:``,labelType:`text`,classes:[],isUserDefinedId:!1,interpolate:this.defaultInterpolate},a=n?.text;if(a!==void 0&&(i.text=Hbt(a.text.trim()),i.labelType=AZ(a.type)),n!==void 0&&(i.type=n.type,i.stroke=n.stroke,i.length=n.length>10?10:n.length),r&&!this.edgeById.has(r))i.id=r,i.isUserDefinedId=!0;else{let n=this.pairCount.get(e+`\0`+t)??0;i.id=`L_${e}_${t}_${n===0?0:n+1}`}let o=this.options.maxEdges;if(o!==void 0&&this.edges.length>=o)throw new NK(`Edge limit exceeded. ${this.edges.length} edges found, but the limit is ${o}.`,`limit`,{type:`flowchart`});this.edges.push(i);let s=e+`\0`+t;this.pairCount.set(s,(this.pairCount.get(s)??0)+1),this.edgeById.has(i.id)||this.edgeById.set(i.id,i)}addLink(e,t,n){let r=typeof n?.id==`string`?n.id.replace(`@`,``):void 0,i=e[e.length-1],a=t[0];for(let o of e)for(let e of t)this.addSingleLink(o,e,n,o===i&&e===a?r:void 0)}updateLinkInterpolate(e,t){for(let n of e)n==="default"?this.defaultInterpolate=t:this.edgeAt(n).interpolate=t}updateLink(e,t){for(let n of e){if(n==="default"){this.defaultEdgeStyle=t;continue}let e=this.edgeAt(n);e.style=t,t.length>0&&!t.some(e=>e?.startsWith(`fill`))&&t.push(`fill:none`)}}edgeAt(e){let t=this.edges[Number(e)];if(t===void 0)throw new NK(`The index ${e} 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 t}addClass(e,t){let n=t.join().replace(/\\,/g,`§§§`).replace(/,/g,`;`).replace(/§§§/g,`,`).split(`;`);for(let t of e.split(`,`)){let e=this.classes.get(t);e===void 0&&(e={id:t,styles:[],textStyles:[]},this.classes.set(t,e));for(let t of n)t.includes(`color`)&&e.textStyles.push(t.replace(`fill`,`bgFill`)),e.styles.push(t)}}setDirection(e){let t=e.trim();t.includes(`<`)&&(t=`RL`),t.includes(`^`)&&(t=`BT`),t.includes(`>`)&&(t=`LR`),t.includes(`v`)&&(t=`TB`),t===`TD`&&(t=`TB`),this.direction=t}setClass(e,t){for(let n of e.split(`,`))this.nodes.get(n)?.classes.push(t),this.edgeById.get(n)?.classes.push(t),this.subgraphLookup.get(n)?.classes.push(t)}setTooltip(e,t){if(t!==void 0)for(let n of e.split(`,`))this.tooltips.set(n,t)}setLink(e,t,n){let r=t.trim();for(let t of e.split(`,`)){let e=this.nodes.get(t);e!==void 0&&(e.link=r?Cq(r):void 0,e.linkTarget=n)}this.setClass(e,`clickable`)}setClickEvent(e,t,n){this.setClass(e,`clickable`)}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,``)}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
1011
1011
|
`)}addSubGraph(e,t,n){let r=e?.text.trim(),i=n?.text??``;e!==void 0&&e===n&&/\s/.test(i)&&(r=void 0);let a=/* @__PURE__ */ new Set,o=[],s;for(let e of t)if(typeof e==`string`)e.trim()!==``&&!a.has(e)&&(a.add(e),o.push(e));else if(Array.isArray(e))for(let t of e)t.trim()!==``&&!a.has(t)&&(a.add(t),o.push(t));else s=e.value;s??=this.options.inheritDir?this.direction??this.options.direction:void 0,r??=`subGraph`+this.subCount,i||=``,this.subCount++;let c={id:r,nodes:o,title:i.trim(),classes:[],dir:s,labelType:AZ(n?.type)},l=this.members;c.nodes=o.filter(e=>!l.has(e)&&e!==r);for(let e of c.nodes)l.add(e);let u=this.subgraphLookup.get(r);if(u)for(let e of c.nodes)u.nodes.push(e);else this.subgraphs.push(c);return this.subgraphLookup.set(r,u??c),r}exists(e,t){for(let n of e)if(n.nodes.includes(t))return!0;return!1}makeUniq(e,t){let n=/* @__PURE__ */ new Set;for(let e of t)for(let t of e.nodes)n.add(t);return{nodes:e.nodes.filter(e=>!n.has(e))}}destructLink(e,t){let n=Gbt(e);if(!t)return n;let r=Wbt(t);if(r.stroke!==n.stroke)return{type:`INVALID`,stroke:`INVALID`};if(r.type===`arrow_open`)r.type=n.type;else{if(r.type!==n.type)return{type:`INVALID`,stroke:`INVALID`};r.type=`double_`+r.type}return r.type===`double_arrow`&&(r.type=`double_arrow_point`),r.length=n.length,r}subgraph(e){return this.subgraphLookup.get(e)}},qbt=/* @__PURE__ */ `$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`.split(`.`),Jbt=/* @__PURE__ */ new Uint8Array(128);for(let e of`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!"#$%&'*+.\`?\\_/`)Jbt[e.charCodeAt(0)]=1;var Ybt=/accTitle\s*:\s*/y,Xbt=/accDescr\s*:\s*/y,Zbt=/accDescr\s*\{\s*/y,Qbt=/call\s+/y,$bt=/click\s+/y,ext=/(?:\r?\n)*\s*\n/y,txt=/\s*(?:LR|RL|TB|BT|TD|BR)\b/y,nxt=/\s*[<>^]/y,rxt=/\s*v\b/y,ixt=[/.*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],jZ=/[\n\r\u2028\u2029]/g,axt=/\s*[xo<]?--+[-xo>]\s*/y,oxt=/\s*[xo<]?--\s*/y,sxt=/\s*[xo<]?==+[=xo>]\s*/y,cxt=/\s*[xo<]?==\s*/y,MZ=/\s*[xo<]?-?\.+-[xo>]?\s*/y,lxt=/\s*[xo<]?-\.\s*/y,uxt=/\s*~~~+\s*/y,dxt=/(?:\r?\n)+/y,fxt=/[^\S\n\r]+/y,pxt=/\(\s*\)/y,mxt=/\n\s*/g;function hxt(e){let t=e.length,n=[],r=[],i=[],a=[],o=0,s=0,c=!0,l=e.indexOf(`direction`),u=e.indexOf(`@`),d=-1,f=0,p=0,m=-1,h=-1,g=-1,_=(t,a,o)=>{n.push(t),r.push(e.slice(a,o)),i.push(a),s=o},v=e=>{a.push(o),o=e},y=()=>{a.length>0&&(o=a.pop())},b=(t,n)=>(t.lastIndex=n,t.test(e)?t.lastIndex:-1),x=t=>e.startsWith(t,s)&&!aq(e.charCodeAt(s+t.length)),S=n=>{let r=n;if(n>=h&&n<=g)r=g;else if(eq(e.charCodeAt(n))){for(;r<t&&eq(e.charCodeAt(r));)r++;h=n,g=r}let i=e.charCodeAt(r);return i===120||i===111||i===60?e.charCodeAt(r+1):i},C=n=>{let r=n;if(n>=h&&n<=g)r=g;else if(eq(e.charCodeAt(n))){for(;r<t&&eq(e.charCodeAt(r));)r++;h=n,g=r}return e.charCodeAt(r)===126},w=()=>{e.charCodeAt(s+1)===96?(v(2),s+=2):(v(1),s++)},T=()=>{if(!C(s))return!1;let e=b(uxt,s);return e<0?!1:(_(40,s,e),!0)},E=t=>{let n=e.charCodeAt(s+1);return t===40?(n===45?(v(8),_(45,s,s+2)):n===91?(v(7),_(47,s,s+2)):n===40&&e.charCodeAt(s+2)===40?(v(7),_(55,s,s+3)):(v(7),_(69,s,s+1)),!0):t===91?(n===91?(v(7),_(49,s,s+2)):n===40?(v(7),_(53,s,s+2)):n===47?(v(9),_(58,s,s+2)):n===92?(v(9),_(59,s,s+2)):(v(7),_(71,s,s+1)),!0):t===124?(v(7),_(67,s,s+1),!0):t===123&&(v(7),_(73,s,s+1),!0)},D=e=>{c&&(c=!1,v(6)),_(20,s,s+e)},O=()=>{let n=s;for(;n<t;){let r=e.charCodeAt(n);if(r<128&&Jbt[r]===1)n++;else if(r===45&&n+1<t){let t=e.charCodeAt(n+1);if(t===62||t===45||t===46)break;n++}else break}return n!==s&&(_(64,s,n),!0)},k=e=>{let t=S(s),n;if(t===45){if((n=b(axt,s))>=0)return _(40,s,n),!0;if((n=b(oxt,s))>=0)return v(10),_(41,s,n),!0;if((n=b(MZ,s))>=0)return _(40,s,n),!0;if((n=b(lxt,s))>=0)return v(12),_(41,s,n),!0}else if(t===61){if((n=b(sxt,s))>=0)return _(40,s,n),!0;if((n=b(cxt,s))>=0)return v(11),_(41,s,n),!0}else if(t===46&&(n=b(MZ,s))>=0)return _(40,s,n),!0;return e!==45&&e!==61&&e!==46&&T()},A=a=>{let o;switch(a){case 97:if(e.startsWith(`acc`,s)){if((o=b(Ybt,s))>=0)return v(3),_(2,s,o),!0;if((o=b(Xbt,s))>=0)return v(4),_(4,s,o),!0;if((o=b(Zbt,s))>=0)return v(5),s=o,!0}break;case 64:if(e.charCodeAt(s+1)===123)return v(16),n.push(7),r.push(``),i.push(s),s+=2,!0;break;case 99:if((o=b(Qbt,s))>=0)return v(14),s=o,!0;if(x(`classDef`))return _(16,s,s+8),!0;if(x(`class`))return _(17,s,s+5),!0;if((o=b($bt,s))>=0)return v(13),s=o,!0;break;case 34:return w(),!0;case 115:if(x(`style`))return _(12,s,s+5),!0;if(x(`swimlane-beta`))return D(13),!0;if(x(`subgraph`))return _(21,s,s+8),!0;break;case 100:if(x(`default`))return _(13,s,s+7),!0;break;case 108:if(x(`linkStyle`))return _(14,s,s+9),!0;break;case 105:if(x(`interpolate`))return _(15,s,s+11),!0;break;case 104:if(e.startsWith(`href`,s)&&eq(e.charCodeAt(s+4)))return _(18,s,s+5),!0;break;case 102:if(x(`flowchart-elk`))return D(13),!0;if(x(`flowchart`))return D(9),!0;break;case 103:if(x(`graph`))return D(5),!0;break;case 101:if(x(`end`)){for(o=s+3;o<t&&eq(e.charCodeAt(o));)o++;return _(22,s,o),!0}break;case 95:if(x(`_self`))return _(23,s,s+5),!0;if(x(`_blank`))return _(23,s,s+6),!0;if(x(`_parent`))return _(23,s,s+7),!0;if(x(`_top`))return _(23,s,s+4),!0}if(l!==-1&&s>=f&&(l<s&&(l=e.indexOf(`direction`,s)),l!==-1&&(d<s&&(jZ.lastIndex=s,d=jZ.test(e)?jZ.lastIndex-1:t),l<d))){for(let e=0;e<5;e++)if((o=b(ixt[e],s))>=0)return _(26+e,s,o),!0;f=d}if(u!==-1&&a!==34&&!eq(a)){if(s>=p){u<s&&(u=e.indexOf(`@`,s));let n=s;for(;n<t;){let t=e.charCodeAt(n);if(t===34||eq(t))break;n++}if(p=n,m=-1,u!==-1&&u<n)for(let r=Math.min(n,t-1)-1;r>=u;r--){if(e.charCodeAt(r)!==64)continue;let t=e.charCodeAt(r+1);if(t!==123&&t!==34){m=r;break}}}if(m>s)return _(31,s,m+1),!0}if(a>=48&&a<=57){let n=s+1;for(;n<t;){let t=e.charCodeAt(n);if(t<48||t>57)break;n++}return _(32,s,n),!0}switch(a){case 35:return _(33,s,s+1),!0;case 58:return e.charCodeAt(s+1)===58&&e.charCodeAt(s+2)===58?_(34,s,s+3):_(35,s,s+1),!0;case 38:return _(36,s,s+1),!0;case 59:return _(37,s,s+1),!0;case 44:return _(38,s,s+1),!0;case 42:return _(39,s,s+1),!0;case 120:case 111:return k(a)||O();case 60:return k(a)||_(60,s,s+1),!0;case 45:return k(a)||O()||_(65,s,s+1),!0;case 61:return k(a);case 46:return k(a)||O();case 126:return T();case 40:return E(a);case 91:return e.charCodeAt(s+1)===124?(_(50,s,s+2),!0):E(a);case 124:case 123:return E(a);case 62:return v(7),_(51,s,s+1),!0;case 94:return _(61,s,s+1),!0;case 92:return e.charCodeAt(s+1)===124?(_(62,s,s+2),!0):O();case 118:return aq(e.charCodeAt(s+1))?O():(_(63,s,s+1),!0)}return eq(a)?k(a)?!0:(o=b(dxt,s))>=0?(_(74,s,o),!0):(o=b(fxt,s))>=0&&(_(75,s,o),!0):a<128?O():Nq(a)?(_(66,s,s+1),!0):!1},j=(n,r,i,a)=>{if(n===34)return w(),!0;let o=S(s);if(o===i||o===a){let e=b(r,s);if(e>=0)return y(),_(40,s,e),!0}if(n===i&&(i!==45||e.charCodeAt(s+1)===45))return!1;let c=s+1;for(;c<t;){let t=e.charCodeAt(c);if(t===34)break;if(t===i){if(i!==45||e.charCodeAt(c+1)===45)break}else if(t===120||t===111||t===60||t===a||eq(t)){let e=S(c);if((e===i||e===a)&&b(r,c)>=0)break}c++}return _(42,s,c),!0};e:for(;;){if(s>=t){let e=-1;switch(o){case 0:e=76;break;case 3:e=3;break;case 4:e=5;break;case 5:e=6;break;case 13:e=19;break;case 14:e=8;break;case 15:e=9}e!==-1&&_(e,t,t);break}let a=e.charCodeAt(s),c=!0;switch(o){case 0:c=A(a);break;case 1:if(a===34)e.charCodeAt(s+1)===96?(v(2),s+=2):(y(),s++);else{let n=e.indexOf(`"`,s);_(11,s,n===-1?t:n)}break;case 2:if(a===96)e.charCodeAt(s+1)===34?(y(),s+=2):c=!1;else if(a===34)w();else{let n=s+1;for(;n<t;){let t=e.charCodeAt(n);if(t===96||t===34)break;n++}_(10,s,n)}break;case 3:case 4:{let n=e.indexOf(`
|
|
1012
1012
|
`,s);n===-1&&(n=t);let r=o===3?3:5;y(),_(r,s,n);break}case 5:if(a===125)y(),s++;else{let n=e.indexOf(`}`,s);n===-1&&(n=t),_(6,s,n)}break;case 6:{let e;a===34?w():(e=b(ext,s))>=0?(y(),_(24,s,e)):(e=b(txt,s))>=0||(e=b(nxt,s))>=0||(e=b(rxt,s))>=0?(y(),_(25,s,e)):c=T()||E(a);break}case 7:{let n=e.charCodeAt(s+1);switch(a){case 34:w();break;case 40:case 91:case 123:E(a);break;case 93:y(),n===41?_(46,s,s+2):n===93?_(48,s,s+2):_(70,s,s+1);break;case 41:y(),n===93?_(52,s,s+2):n===41&&e.charCodeAt(s+2)===41?_(54,s,s+3):_(68,s,s+1);break;case 124:y(),_(67,s,s+1);break;case 125:y(),_(72,s,s+1);break;default:{if((a===126||eq(a))&&T())break;let n=s+1;for(;n<t;){let t=e.charCodeAt(n);if(t===91||t===93||t===40||t===41||t===123||t===125||t===124||t===34)break;n++}_(44,s,n)}}break}case 8:{let n=e.charCodeAt(s+1);if(a===34)w();else{if((a===126||eq(a))&&T())break;if((a===45||a===47||a===41)&&n===41)y(),_(43,s,s+2);else if(a===40||a===91||a===123)E(a);else if(a===41||a===93||a===125)c=!1;else{let n=s+1;for(;n<t;){let t=e.charCodeAt(n);if(t===34||t===40||t===41||t===91||t===93||t===123||t===125||(t===45||t===47)&&e.charCodeAt(n+1)===41||(t===126||eq(t))&&C(n)&&b(uxt,n)>=0)break;n++}_(44,s,n)}}break}case 9:{let n=e.charCodeAt(s+1);if(a===34){w();break}if((a===126||eq(a))&&T())break;switch(a){case 40:n===45||n===91||n===40&&e.charCodeAt(s+2)===40?E(a):n===93?(y(),_(56,s,s+2)):E(a);break;case 91:case 123:E(a);break;case 92:n===93?(y(),_(56,s,s+2)):_(44,s,s+1);break;case 47:n===93?(y(),_(57,s,s+2)):_(44,s,s+1);break;case 93:case 41:n===93?(y(),_(56,s,s+2)):c=!1;break;case 125:c=!1;break;default:{if((a===63||a===61)&&n===93){y(),_(56,s,s+2);break}let r=s+1;for(;r<t;){let t=e.charCodeAt(r);if(t===92||t===91||t===93||t===40||t===41||t===123||t===125||t===47)break;r++}_(44,s,r)}}break}case 10:c=j(a,axt,45,-1);break;case 11:c=j(a,sxt,61,-1);break;case 12:c=j(a,MZ,46,45);break;case 13:if(a===34)w();else if(eq(a))y(),s++;else{let n=s+1;for(;n<t&&!eq(e.charCodeAt(n));)n++;_(19,s,n)}break;case 14:if(a===40){let e=b(pxt,s);y(),e>=0?s=e:(v(15),s++)}else{let n=e.indexOf(`(`,s);n===-1&&(n=t),_(8,s,n)}break;case 15:if(a===41)y(),s++;else{let n=e.indexOf(`)`,s);n===-1&&(n=t),_(9,s,n)}break;case 16:if(a===34)v(17),_(7,s,s+1);else if(a===125)y(),s++;else if(a===94)c=!1;else{let n=s+1;for(;n<t;){let t=e.charCodeAt(n);if(t===125||t===94||t===34)break;n++}_(7,s,n)}break;case 17:if(a===34)y(),_(7,s,s+1);else{let a=e.indexOf(`"`,s);a===-1&&(a=t),n.push(7),r.push(e.slice(s,a).replace(mxt,`<br/>`)),i.push(s),s=a}}if(!c)return n.push(1),r.push(``),i.push(s),{types:n,texts:r,starts:i};continue e}return n.push(0),r.push(``),i.push(t),{types:n,texts:r,starts:i}}var NZ=/* @__PURE__ */ new Uint8Array(77);for(let e of[32,64,63,65,13,38,35,36,33,39,66])NZ[e]=1;var PZ=/* @__PURE__ */ new Uint8Array(77);for(let e of[32,66,64,25,63,65,38,35,36,33,39])PZ[e]=1;var FZ=/* @__PURE__ */ new Uint8Array(77);for(let e of[32,64,75,65,36,66,35,39,33,12,14,16,17,19,20,25,21,22,63,61,41])FZ[e]=1;var IZ=/* @__PURE__ */ new Uint8Array(77);for(let e of[32,64,35,75,33,12])IZ[e]=1;var gxt=`'UNICODE_TEXT', 'TEXT', 'TAGSTART'`,LZ=[],_xt=/}\s*\n/g;function vxt(e,t){let n=e.includes(`}`)?e.replace(_xt,`}
|
|
1013
|
-
`):e,{types:r,texts:i,starts:a}=hxt(n),o=0,s,c=e=>{let t=r[o];throw t===1?FK(`flowchart`,n,a[o],``,!0):FK(`flowchart`,n,a[o],`Expecting ${e}, got '${qbt[t]}'`)},l=(e,t=``)=>(r[o]!==e&&c(`'${qbt[e]}'${t?`, `+t:``}`),i[o++]),u=()=>{let e=r[o];e!==74&&e!==37&&e!==76&&c(`'SEMI', 'NEWLINE', 'EOF'`),o++},d=()=>{NZ[r[o]]===0&&c(`'NODE_STRING'`);let e=i[o++];for(;NZ[r[o]]===1;)e+=i[o++];return e},f=()=>{PZ[r[o]]===0&&c(`'NODE_STRING'`);let e=i[o++];for(;PZ[r[o]]===1;)e+=i[o++];return e},p=()=>{let e=r[o],t;if(e===11)t=`string`;else if(e===10)t=`markdown`;else if(e===44||e===60||e===51||e===66)t=`text`;else return c(`${gxt}, 'TAGEND', 'STR', 'MD_STR'`);let n=i[o++];for(;;){let e=r[o];if(e!==44&&e!==60&&e!==51&&e!==66)break;n+=i[o++]}return{text:n,type:t}},m=e=>{l(e,gxt)},h=()=>{let e=r[o],t;if(e===11)t=`string`;else if(e===10)t=`markdown`;else if(e===42||e===66)t=`text`;else return c(`'EDGE_TEXT', 'STR', 'MD_STR'`);let n=i[o++];for(;r[o]===42||r[o]===66;)n+=i[o++];return{text:n,type:t}},g=()=>{let e=r[o],t;if(e===11)t=`text`;else if(e===10)t=`markdown`;else if(FZ[e]===1)t=`text`;else return c(`'NODE_STRING', 'STR', 'MD_STR'`);let n=i[o++];for(;FZ[r[o]]===1;)n+=i[o++];return{text:n,type:t}},_=()=>{let e=i[o++];for(;r[o]===7;)e+=i[o++];return e},v=()=>{let e=d(),n;switch(r[o]){case 71:o++,n=p(),m(70),t.addVertex(e,n,`square`);break;case 55:o++,n=p(),m(54),t.addVertex(e,n,`doublecircle`);break;case 69:o++,r[o]===69?(o++,n=p(),m(68),l(68),t.addVertex(e,n,`circle`)):(n=p(),m(68),t.addVertex(e,n,`round`));break;case 45:o++,n=p(),m(43),t.addVertex(e,n,`ellipse`);break;case 47:o++,n=p(),m(46),t.addVertex(e,n,`stadium`);break;case 49:o++,n=p(),m(48),t.addVertex(e,n,`subroutine`);break;case 50:{o++;let r=l(64);l(35);let i=l(64);l(67),n=p(),m(70),t.addVertex(e,n,`rect`,void 0,void 0,void 0,{[r]:i});break}case 53:o++,n=p(),m(52),t.addVertex(e,n,`cylinder`);break;case 73:o++,r[o]===73?(o++,n=p(),m(72),l(72),t.addVertex(e,n,`hexagon`)):(n=p(),m(72),t.addVertex(e,n,`diamond`));break;case 51:o++,n=p(),m(70),t.addVertex(e,n,`odd`);break;case 58:o++,n=p(),r[o]===57?(o++,t.addVertex(e,n,`lean_right`)):(m(56),t.addVertex(e,n,`trapezoid`));break;case 59:o++,n=p(),r[o]===56?(o++,t.addVertex(e,n,`lean_left`)):(m(57),t.addVertex(e,n,`inv_trapezoid`));break;default:t.addVertex(e)}return e},y=()=>{let e=v();return r[o]===34&&(o++,t.setClass(e,d())),e},b=()=>{let e=[y()];for(s=void 0;;){let n=r[o]===7?_():void 0;if(r[o]!==75)return s=n,e;do o++;while(r[o]===75);if(r[o]!==36)return n!==void 0&&c(`'AMP'`),e;o++,r[o]!==75&&c(`'SPACE'`);do o++;while(r[o]===75);let i=y();n!==void 0&&t.addVertex(e[e.length-1],void 0,void 0,void 0,void 0,void 0,void 0,n),e.push(i)}},x=()=>{let e;if(r[o]===31&&(e=i[o++]),r[o]===40){let n=t.destructLink(i[o++]);return e!==void 0&&(n.id=e),r[o]===67&&(o++,n.text=p(),m(67),r[o]===75&&o++),n}if(r[o]===41){let n=i[o++],r=h(),a=l(40,`'EDGE_TEXT'`),s=t.destructLink(a,n);return s.text=r,e!==void 0&&(s.id=e),s}return c(`'LINK', 'START_LINK'`)},S=()=>{let e=b();s!==void 0&&t.addVertex(e[e.length-1],void 0,void 0,void 0,void 0,void 0,void 0,s);let n=e;for(;;){let i=r[o];if(i!==40&&i!==41&&i!==31)return n;let a=x(),c=b();s!==void 0&&t.addVertex(c[c.length-1],void 0,void 0,void 0,void 0,void 0,void 0,s),t.addLink(e,c,a),n=c.concat(n),e=c}},C=()=>{IZ[r[o]]===0&&c(`'NODE_STRING', 'NUM', 'COLON', 'BRKT'`);let e=i[o++];for(;IZ[r[o]]===1;)e+=i[o++];return e},w=()=>{let e=[C()];for(;r[o]===38;)o++,e.push(C());return e},T=()=>{o++,l(75);let e;if(r[o]===13)e=[i[o++]];else for(e=[l(32,`'DEFAULT'`)];r[o]===38;)o++,e.push(l(32));if(l(75),r[o]!==15){t.updateLink(e,w());return}o++,l(75);let n=f();if(r[o]===75){o++;let r=w();t.updateLinkInterpolate(e,n),t.updateLink(e,r)}else t.updateLinkInterpolate(e,n)},E=(e,n)=>{if(r[o]!==75){t.setLink(e,n);return}if(o++,r[o]===23){t.setLink(e,n,i[o++]);return}let a=l(11,`'LINK_TARGET'`);r[o]===75?(o++,t.setLink(e,n,l(23))):t.setLink(e,n),t.setTooltip(e,a)},D=()=>{let e=i[o++];switch(r[o]){case 8:{let n=i[o++],a=r[o]===9,s=a?i[o++]:void 0,c;r[o]===75&&(o++,c=l(11)),a?t.setClickEvent(e,n,s):t.setClickEvent(e,n),c!==void 0&&t.setTooltip(e,c);return}case 18:o++,E(e,l(11));return;case 11:E(e,i[o++]);return;default:{let n=f();if(r[o]===75){o++;let r=l(11);t.setClickEvent(e,n),t.setTooltip(e,r)}else t.setClickEvent(e,n)}}},O=()=>{o++;let e=r[o];if(e===74||e===37||e===76)return o++,{id:void 0,title:void 0,list:[],collect:!1};l(75,`'SEMI', 'NEWLINE', 'EOF'`);let t=g(),n=t;return r[o]===71&&(o++,n=p(),m(70)),e=r[o],e!==74&&e!==37&&e!==76&&c(`'SEMI', 'NEWLINE', 'EOF', 'SQS'`),o++,{id:t,title:n,list:[],collect:!1}},k=()=>{let e=r[o];switch(e){case 12:{o++,l(75);let e=d();return l(75),t.addVertex(e,void 0,void 0,w()),u(),LZ}case 14:return T(),u(),LZ;case 16:{o++,l(75);let e=d();return l(75),t.addClass(e,w()),u(),LZ}case 17:{o++,l(75);let e=d();return l(75),t.setClass(e,d()),u(),LZ}case 19:return D(),u(),LZ;case 26:case 27:case 28:case 29:case 30:return o++,{stmt:`dir`,value:yxt[e-26]};case 2:{o++;let e=l(3).trim();return t.setAccTitle(e),e}case 4:{o++;let e=l(5).trim();return t.setAccDescription(e),e}case 6:{let e=i[o++].trim();return t.setAccDescription(e),e}default:{NZ[e]===0&&c(bxt);let t=S();return u(),t}}},A=()=>{let e=[],n=[],a=!1;for(;;){let s=r[o];if(s===0)break;if(s===22){let r=e.pop();if(r===void 0)break;o++;let i=t.addSubGraph(r.id,n,r.title);n=r.list,a=r.collect,a&&n.push(i)}else if(s===37||s===74||s===75||s===76)a&&n.push(i[o]),o++;else if(s===21){let t=O();t.list=n,t.collect=a,e.push(t),n=[],a=!0}else{let e=k();a&&(!Array.isArray(e)||e.length>0)&&n.push(e)}}e.length>0&&c(`'end'`)};for(;r[o]===75||r[o]===74;)o++;if(l(20,`'SPACE', 'NEWLINE'`),r[o]===24)o++,t.setDirection(`TB`);else{let e=l(25,`'NODIR'`),n=r[o];if(n===75){do o++;while(r[o]===75);n=r[o],n!==74&&c(`'NEWLINE', 'SPACE'`)}else n!==37&&n!==74&&c(`'SEMI', 'NEWLINE', 'SPACE'`);o++,t.setDirection(e)}A(),r[o]!==0&&c(bxt)}var yxt=[`TB`,`BT`,`RL`,`LR`,`TD`],bxt=`'SEMI', 'NEWLINE', 'SPACE', 'EOF', 'subgraph', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'STYLE', 'LINKSTYLE', 'CLASSDEF', 'CLASS', 'CLICK', 'NODE_STRING'`;function xxt(e){if(e.img)return`imageSquare`;if(e.icon)return e.form===`circle`?`iconCircle`:e.form===`square`?`iconSquare`:e.form===`rounded`?`iconRounded`:`icon`;switch(e.type){case`square`:case void 0:return`squareRect`;case`round`:return`roundedRect`;default:return e.type}}function Sxt(e){switch(e){case`arrow_point`:case`arrow_circle`:case`arrow_cross`:return[`none`,e];case`double_arrow_point`:case`double_arrow_circle`:case`double_arrow_cross`:{let t=e.replace(`double_`,``);return[t,t]}}return[`none`,`arrow_point`]}function Cxt(e,t){let n=[],r=[],i=e.subgraphs,a=t=>{let n=[];for(let r of t){let t=e.classes.get(r);t?.styles&&(n=[...n,...t.styles].map(e=>e.trim())),t?.textStyles&&(n=[...n,...t.textStyles].map(e=>e.trim()))}return n},o=/* @__PURE__ */ new Map;for(let t of i)for(let n of t.nodes)e.subgraph(n)&&o.set(n,t.id);let s=/* @__PURE__ */ new Map,c=/* @__PURE__ */ new Map;for(let e of i){let t=o.get(e.id);if(t===void 0)continue;let n=c.get(t);n?n.push(e.id):c.set(t,[e.id])}let l=0;for(let e of i){if(o.has(e.id))continue;let t=[e.id];for(;t.length>0;){let e=t.pop();if(s.has(e))continue;s.set(e,l++);let n=c.get(e);if(n)for(let e=n.length-1;e>=0;e--)t.push(n[e])}}let u=t=>e.subgraph(t)?.metadata?.view===`collapsed`,d=!1;for(let e of i)e.metadata?.view===`collapsed`&&(d=!0);let f=/* @__PURE__ */ new Map,p=e=>{let t=[],n=/* @__PURE__ */ new Set,r=e;for(;r!==void 0&&!f.has(r)&&!n.has(r);)n.add(r),t.push(r),r=o.get(r);let i=r===void 0?void 0:f.get(r);for(let e=t.length-1;e>=0;e--)i===void 0&&u(t[e])&&(i=t[e]),f.set(t[e],i);return i},m=/* @__PURE__ */ new Set,h=/* @__PURE__ */ new Map;for(let e of d?i:[]){let t=p(e.id);if(t!==void 0){e.id!==t&&(m.add(e.id),h.set(e.id,t));for(let n of e.nodes)n!==t&&(m.add(n),h.set(n,t))}}let g=/* @__PURE__ */ new Map,_=/* @__PURE__ */ new Set;for(let e=i.length-1;e>=0;e--){let t=i[e];if(!m.has(t.id)){t.nodes.length>0&&_.add(t.id);for(let e of t.nodes)g.set(e,t.id)}}let v=/* @__PURE__ */ new Map;for(let e=i.length-1;e>=0;e--){let t=i[e];if(m.has(t.id))continue;let r=t.metadata?.view===`collapsed`,o={id:t.id,label:t.title,labelType:t.labelType,parentId:g.get(t.id),cssStyles:[],cssCompiledStyles:a(t.classes),cssClasses:t.classes.join(` `),shape:r?`collapsedGroup`:`rect`,dir:t.dir,isGroup:!r,colorIndex:s.get(t.id)};r||(o.metadata=t.metadata),n.push(o),v.set(t.id,o)}for(let t of e.nodes.values()){if(m.has(t.id))continue;let r=v.get(t.id);if(r){r.cssStyles=t.styles,r.cssCompiledStyles=a(t.classes),r.cssClasses=t.classes.join(` `);continue}let i=_.has(t.id),o={id:t.id,label:t.text,labelType:t.labelType,parentId:g.get(t.id),cssStyles:t.styles,cssCompiledStyles:a([`default`,`node`,...t.classes]),cssClasses:`default `+t.classes.join(` `),dir:t.dir,link:t.link,linkTarget:t.linkTarget,tooltip:e.tooltips.get(t.id),icon:t.icon,pos:t.pos,img:t.img,assetWidth:t.assetWidth,assetHeight:t.assetHeight,constraint:t.constraint,isGroup:i,shape:i?`rect`:xxt(t)};n.push(o),v.set(t.id,o)}return e.edges.forEach((n,i)=>{let o=h.get(n.start)??n.start,s=h.get(n.end)??n.end;if(o===s&&(h.has(n.start)||h.has(n.end)))return;let[c,l]=Sxt(n.type),u=[...e.defaultEdgeStyle??[]];n.style&&u.push(...n.style);let d=n.stroke===`invisible`||n.type===`arrow_open`;r.push({id:n.id||`L_${o}_${s}_${i}`,isUserDefinedId:n.isUserDefinedId,start:o,end:s,type:n.type??`normal`,label:n.text,labelType:n.labelType,thickness:n.stroke,pattern:n.stroke,minlen:n.length,classes:n.stroke===`invisible`?``:`edge-thickness-normal edge-pattern-solid flowchart-link`,arrowTypeStart:d?`none`:c,arrowTypeEnd:d?`none`:l,cssCompiledStyles:a(n.classes),style:u,animate:n.animate,animation:n.animation,curve:n.interpolate||e.defaultInterpolate||t})}),{nodes:n,edges:r}}var wxt=40,Txt=16,Ext=48,Dxt=20,RZ=26,zZ=` fill="var(--_s)" stroke="var(--_b)"`,Oxt=` stroke="var(--_b)"`;function BZ(e,t,n){let r=e[t];return typeof r==`number`&&r>0?Math.min(r,2e3):n}function VZ(e,t){return e!==void 0&&e>0&&e<=4e3?e:t}function kxt(e,t,n,r){let i=i=>XJ(n,a=>Axt(e,t,n,r,i,a));return YJ(e.direction)?JJ(n,i):i(!1)}function Axt(e,t,n,r,i,a){let o=a?12:Dxt,s=r?t[r.type]:void 0,c=typeof s==`object`&&s&&!Array.isArray(s)?s:t.flowchart??{},l=Cxt(e,typeof c.curve==`string`?c.curve:void 0);r?.prepare(l);let u=n.fontSize??16,d=Math.round(u*.875),f=n.measurer??fq(n.fontFamily),p=Math.min(BZ(c,`wrappingWidth`,200),r&&a?100:1/0),m=n.padding??8,h=n.icons,g=/* @__PURE__ */ new Map,_=[],v=[];l.nodes.forEach((e,t)=>g.set(e.id,t));for(let e of l.nodes){let t=mJ(e.cssStyles.length>0?e.cssCompiledStyles.concat(e.cssStyles):e.cssCompiledStyles),i=+!!t.bold|(t.italic?2:0),s=e.labelType===`markdown`,c=t.fontSize??u,l,d;if(e.isGroup){let u=WJ(e.label,s,f,c,r&&a?Math.max(80,KJ(n)/2):4e3,i);l={node:e,style:t,label:u,shape:`group`,w:0,h:0,dy:0,loops:0},d=Qq(0,0),d.isGroup=!0,d.dir=e.dir?Xq(e.dir):void 0,d.padX=o,d.padTop=u.height>0?u.height+16:Dxt,d.padBottom=o,d.minW=u.width+2*o-12}else{let n=qpt(e.shape),r=WJ(e.img||e.icon||zht(n)?e.label:void 0,s,f,c,p,i),a,o,u=0;if(e.img||e.icon){let t=e.img?80:48,n=VZ(e.assetWidth,t),i=VZ(e.assetHeight,t);a=Math.max(n,r.width+8),o=i+(r.height>0?r.height+6:0),u=e.pos===`t`?-i/2:i/2,r.height===0&&(u=0)}else{let e=LJ(n,r.width,r.height);a=e.w,o=e.h,u=e.dy}l={node:e,style:t,label:r,shape:n,w:a,h:o,dy:u,loops:0},d=Qq(a,o)}d.seq=_.length,_.push(l),v.push(d)}l.nodes.forEach((e,t)=>{v[t].parent=e.parentId===void 0?-1:g.get(e.parentId)??-1});let y=i?`TB`:Xq(e.direction),b=e=>{let t;for(let n=v[e].parent,r=0;n>=0&&t===void 0&&r<1e4;n=v[n].parent,r++)t=v[n].dir;return t??=y,t===`LR`||t===`RL`};_.forEach((e,t)=>{e.node.isGroup?v[t].span=1/0:!e.node.img&&!e.node.icon&&(v[t].span=Rht(e.shape,e.w,e.h,b(t)))});let x=[],S=[],C=[];for(let e of l.edges){let t=g.get(e.start),n=g.get(e.end);if(t===void 0||n===void 0)continue;let r=WJ(e.label,e.labelType===`markdown`,f,d,p);t===n&&(_[t].loops++,b(t)?v[t].h+=2*(RZ+(r.height>0?r.height+8:0)):v[t].w+=2*(RZ+(r.width>0?r.width+12:0))),C.push(e),S.push(r),x.push({src:t,dst:n,minlen:e.minlen??1,labelW:r.width>0?r.width+12:0,labelH:r.height>0?r.height+4:0,route:[],labelX:0,labelY:0})}let w={nodeSep:BZ(c,`nodeSpacing`,wxt)*(a?.5:1),edgeSep:Txt,rankSep:BZ(c,`rankSpacing`,Ext)*(a?.75:1),portSep:20,tracks:typeof c.curve==`string`&&/^step/.test(c.curve),straight:c.curve===`linear`,headRoom:sJ(`arrow_point`)},T=r?r.layout(v,x,y,w,a):eJ(v,x,y,w),E=WJ(e.title,!1,f,u,a?KJ(n):4e3,1),D=E.height>0?E.height+12:0,O=Math.max(T.width,E.width);Zq(v,x,m+(O-T.width)/2,m+D);let k=Math.ceil(O+2*m),A=Math.ceil(T.height+D+2*m),j=[],M=/* @__PURE__ */ new Map,N=!1;for(let e of v)e.isGroup&&(N=!0);if(N)for(let e of x)tJ(M,e.route);let P=``,F=``,ee=``;for(let e=0;e<_.length;e++){let t=_[e],i=v[e],a=t.node,s=i.x,c=i.y,l=hJ(a.cssClasses.replace(/^default\s?/,``)),u=mq(a.id);if(i.isGroup&&r?.drawGroup&&i.parent<0){P+=r.drawGroup(i,t.label,t.style,l,u,y,h);continue}if(i.isGroup){let n=nJ(i,t.label.width,M,o),r=c-i.h/2+8+t.label.height/2,a=` class="pele-cluster-label" fill="var(--_m)"${t.style.text}`,d=ght(i,t.label.width,n,M);d&&(F+=_ht(t.label,n,r,a,u,v,e,h)),P+=`<g class="pele-cluster${l}" data-id="${u}"><rect x="${K(s-i.w/2)}" y="${K(c-i.h/2)}" width="${K(i.w)}" height="${K(i.h)}" rx="${fJ}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${t.style.shape}/>`+(d?``:gq(t.label,n,r,a,h))+`</g>`;continue}let d=t.w,f=t.h,p;if(a.img){let e=VZ(a.assetWidth,80),r=VZ(a.assetHeight,80),i=t.label.height>0?a.pos===`t`?f/2-r:-f/2:-r/2,o=Hpt(Cq(a.img),n);p=o===void 0?``:`<image href="${pq(o)}" x="${K(-e/2)}" y="${K(i)}" width="${K(e)}" height="${K(r)}" preserveAspectRatio="${a.constraint===`on`?`xMidYMid meet`:`none`}"/>`}else if(a.icon){let e=VZ(a.assetHeight,48),n=t.label.height>0?a.pos===`t`?f/2-e:-f/2:-e/2,r=a.shape===`icon`?``:a.shape===`iconCircle`?`<circle cy="${K(n+e/2)}" r="${K(e/2)}"${zZ}${t.style.shape}/>`:`<rect x="${K(-e/2)}" y="${K(n)}" width="${K(e)}" height="${K(e)}" rx="${a.shape===`iconRounded`?8:0}"${zZ}${t.style.shape}/>`,i=e*.6;p=r+`<svg class="pele-icon" data-icon="${mq(a.icon)}" x="${K(-i/2)}" y="${K(n+(e-i)/2)}" width="${K(i)}" height="${K(i)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${h?.(a.icon)??``}</svg>`}else p=RJ(t.shape,d,f,zZ+t.style.shape,Oxt+t.style.line);let m=gq(t.label,0,t.dy,` class="pele-label"${t.style.text}`,h);if(/ internal-link(?: |$)/.test(l+` `)&&a.label&&n.links!==!1){let e=RK(a.label),t=wq(Sq(e),n)!==void 0,r=pq(e);m=`<a class="internal-link"${t?` href="${r}"${Eq(n)}`:``} data-href="${r}">${m}</a>`,j.push({id:a.id,href:e,internal:!0})}let g=p+m;a.tooltip&&(g=`<title>${mq(a.tooltip)}</title>`+g),a.link&&(g=Tq(g,a.link,a.id,j,n,a.linkTarget?` target="${pq(a.linkTarget)}"`:``)),ee+=`<g class="pele-node pele-shape-${t.shape}${l}" data-id="${u}" transform="translate(${K(s)},${K(c)})">${g}</g>`}let te=yht();for(let e=0;e<x.length;e++){let t=x[e];t.src===t.dst||C[e].thickness===`invisible`||t.route.length<6||(te.add(t.src,BJ(t.route,0,v[t.src]),C[e].arrowTypeStart),te.add(t.dst,BJ(t.route,t.route.length-3,v[t.dst]),C[e].arrowTypeEnd))}let I=``,ne=``,re=/* @__PURE__ */ new Map;for(let e=0;e<x.length;e++){let t=x[e],n=C[e],r=S[e],i=n.style.length>0||n.cssCompiledStyles.length>0?mJ(n.cssCompiledStyles.concat(n.style)):void 0;if(n.thickness!==`invisible`){let e=n.arrowTypeStart,r=n.arrowTypeEnd,a;if(t.src===t.dst){let e=_[t.src],n=re.get(t.src)??0;re.set(t.src,n+1),a=uJ(v[t.src],e.w,e.h,n,b(t.src),RZ,sJ(r),t)}else{let i=t.route.slice(),o=te.of(t.src,BJ(i,0,v[t.src])),s=te.of(t.dst,BJ(i,i.length-3,v[t.dst]));VJ(i,0,_[t.src],v[t.src]),VJ(i,i.length-3,_[t.dst],v[t.dst]),a=oJ(i,n.curve,sJ(e),sJ(r),o,s)}let o=i?.stroke&&n.thickness!==`invisible`?pq(i.stroke):`var(--_l)`,s=``;n.thickness===`thick`?s+=` stroke-width="2.5"`:n.thickness===`dotted`&&(s+=` stroke-dasharray="3 4"`);let c=hJ(n.classes.replace(/edge-thickness-normal|edge-pattern-solid|flowchart-link/g,``));I+=`<g class="pele-edge${c}" data-id="${mq(n.id)}"${i?.line??``}><path d="${a.d}"${s}/>`+cJ(e,a.sx,a.sy,a.sdx,a.sdy,o)+cJ(r,a.ex,a.ey,a.edx,a.edy,o)+`</g>`}if(r.width>0){let e=t.labelX,a=t.labelY;ne+=lJ(n.id,r,e,a,i?.text??``,h)}}return{svg:vJ(r?.type??`flowchart`,k,A,u,n,e,gq(E,k/2,m+E.height/2,` class="pele-title" font-weight="var(--_tw)"`)+(P?`<g class="pele-clusters">${P}</g>`:``)+(I?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${I}</g>`:``)+(F?`<g class="pele-cluster-titles">${F}</g>`:``)+(ne?`<g class="pele-edge-labels" font-size="${d}">${ne}</g>`:``)+`<g class="pele-nodes">${ee}</g>`),width:k,height:A,links:j}}var jxt={type:`flowchart`,parse(e,t,n,r,i){let a=new Kbt({inheritDir:(t.flowchart??{}).inheritDir===!0,maxEdges:i.maxEdges});return n&&(a.title=n),vxt(e,a),a},render:kxt},HZ=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],UZ=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`];function WZ(e){return!Number.isNaN(e.getTime())}function GZ(e,t){let n=String(e);return n.length>=t?n:`0`.repeat(t-n.length)+n}function Mxt(e){let t=[`th`,`st`,`nd`,`rd`],n=e%100;return e+(t[(n-20)%10]||t[n]||t[0])}function KZ(e){let t=-Math.round(e.getTimezoneOffset()/15)*15;return t===0?0:t}function Nxt(e){let t=KZ(e),n=Math.abs(t);return(t>=0?`+`:`-`)+GZ(Math.floor(n/60),2)+`:`+GZ(n%60,2)}function Pxt(e){return e.getDay()||7}function qZ(e,t){let n=new Date(e);return n.setDate(n.getDate()+t),n}function Fxt(e){let t=new Date(e.getFullYear(),e.getMonth()+1,0);return t.setHours(23,59,59,999),t.getDate()}function Ixt(e,t){let n=new Date(e);return n.setDate(1),t(n),n.setDate(Math.min(e.getDate(),Fxt(n))),n}function Lxt(e,t,n){switch(n){case`M`:return Ixt(e,n=>n.setMonth(e.getMonth()+t));case`y`:return Ixt(e,n=>n.setFullYear(e.getFullYear()+t));case`d`:return qZ(e,Math.round(t));case`w`:return qZ(e,Math.round(7*t));case`h`:return new Date(e.getTime()+t*36e5);case`m`:return new Date(e.getTime()+t*6e4);case`s`:return new Date(e.getTime()+t*1e3);default:return new Date(e.getTime()+t)}}function Rxt(e){return qZ(e,4-Pxt(e))}function zxt(e){let t=Rxt(e),n=new Date(t.getFullYear(),0,1),r=Pxt(n),i=qZ(n,4-r+(r>4?7:0)),a=(KZ(i)-KZ(t))*6e4,o=(t.getTime()-i.getTime()-a)/6048e5;return(o<0?Math.ceil(o)||0:Math.floor(o))+1}var Bxt=/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g,Vxt=/\[([^\]]+)]|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,Hxt=`YYYY-MM-DDTHH:mm:ssZ`;function Uxt(e,t){if(!WZ(e))return`Invalid Date`;let n=t||Hxt;if(n===`YYYY-MM-DD`)return Wxt(e);let r=!1,i=n.replace(Bxt,t=>{switch(t){case`Q`:return String(Math.ceil((e.getMonth()+1)/3));case`Do`:return`[`+Mxt(e.getDate())+`]`;case`GGGG`:return String(Rxt(e).getFullYear());case`W`:return String(zxt(e));case`WW`:return GZ(zxt(e),2);case`k`:return String(e.getHours()||24);case`kk`:return GZ(e.getHours()||24,2);case`X`:return String(Math.floor(e.getTime()/1e3));case`x`:return String(e.getTime());case`gggg`:case`wo`:case`w`:case`ww`:case`z`:case`zzz`:return r=!0,t;default:return t}});if(r)return;let a=e.getHours();return i.replace(Vxt,(t,n)=>{if(n)return n;switch(t){case`YY`:return String(e.getFullYear()).slice(-2);case`YYYY`:return GZ(e.getFullYear(),4);case`M`:return String(e.getMonth()+1);case`MM`:return GZ(e.getMonth()+1,2);case`MMM`:return HZ[e.getMonth()].slice(0,3);case`MMMM`:return HZ[e.getMonth()];case`D`:return String(e.getDate());case`DD`:return GZ(e.getDate(),2);case`d`:return String(e.getDay());case`dd`:return UZ[e.getDay()].slice(0,2);case`ddd`:return UZ[e.getDay()].slice(0,3);case`dddd`:return UZ[e.getDay()];case`H`:return String(a);case`HH`:return GZ(a,2);case`h`:return String(a%12||12);case`hh`:return GZ(a%12||12,2);case`a`:return a<12?`am`:`pm`;case`A`:return a<12?`AM`:`PM`;case`m`:return String(e.getMinutes());case`mm`:return GZ(e.getMinutes(),2);case`s`:return String(e.getSeconds());case`ss`:return GZ(e.getSeconds(),2);case`SSS`:return GZ(e.getMilliseconds(),3);case`Z`:return Nxt(e);default:return Nxt(e).replace(`:`,``)}})}function Wxt(e){let t=e.getFullYear(),n=e.getMonth()+1,r=e.getDate();return(t>=1e3&&t<=9999?t:GZ(t,4))+(n<10?`-0`:`-`)+n+(r<10?`-0`:`-`)+r}var Gxt=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,Kxt=/\[[^\]]+]/g,qxt=/\d/,JZ=/\d\d/,Jxt=/\d{3}/,Yxt=/\d{4}/,YZ=/\d\d?/,Xxt=/[+-]?\d+/,Zxt=/[+-]\d\d:?(\d\d)?|Z/,XZ=/\d*[^-_:/,()\s\d]+/;function ZZ(e){return(t,n)=>(t[e]=+n,!0)}var Qxt=(e,t)=>{if(t===`Z`)return e.offset=0,!0;let n=t.match(/([+-]|\d\d)/g),r=n[1]*60+(+n[2]||0);return e.offset=r===0?0:n[0]===`+`?-r:r,!0};function $xt(e){return(t,n)=>{let r=e.indexOf(n)+1;return r<1?!1:(t.month=r%12||r,!0)}}var eSt=/* @__PURE__ */ new Map([[`A`,{re:XZ,read:(e,t)=>(e.afternoon=t===`PM`,!0)}],[`a`,{re:XZ,read:(e,t)=>(e.afternoon=t===`pm`,!0)}],[`Q`,{re:qxt,read:(e,t)=>(e.month=(t-1)*3+1,!0)}],[`S`,{re:qxt,read:(e,t)=>(e.milliseconds=t*100,!0)}],[`SS`,{re:JZ,read:(e,t)=>(e.milliseconds=t*10,!0)}],[`SSS`,{re:Jxt,read:(e,t)=>(e.milliseconds=+t,!0)}],[`s`,{re:YZ,read:ZZ(`seconds`)}],[`ss`,{re:YZ,read:ZZ(`seconds`)}],[`m`,{re:YZ,read:ZZ(`minutes`)}],[`mm`,{re:YZ,read:ZZ(`minutes`)}],[`H`,{re:YZ,read:ZZ(`hours`)}],[`h`,{re:YZ,read:ZZ(`hours`)}],[`HH`,{re:YZ,read:ZZ(`hours`)}],[`hh`,{re:YZ,read:ZZ(`hours`)}],[`D`,{re:YZ,read:ZZ(`day`)}],[`DD`,{re:JZ,read:ZZ(`day`)}],[`Do`,{re:XZ,read:(e,t)=>{let n=t.match(/\d+/);if(!n)return!1;e.day=+n[0],e.dayGiven=!0;for(let n=1;n<=31;n++)Mxt(n)===t&&(e.day=n);return!0}}],[`w`,{re:YZ,read:ZZ(`week`)}],[`ww`,{re:JZ,read:ZZ(`week`)}],[`M`,{re:YZ,read:ZZ(`month`)}],[`MM`,{re:JZ,read:ZZ(`month`)}],[`MMM`,{re:XZ,read:$xt(HZ.map(e=>e.slice(0,3)))}],[`MMMM`,{re:XZ,read:$xt(HZ)}],[`Y`,{re:Xxt,read:ZZ(`year`)}],[`YY`,{re:JZ,read:(e,t)=>(e.year=+t+(+t>68?1900:2e3),!0)}],[`YYYY`,{re:Yxt,read:ZZ(`year`)}],[`Z`,{re:Zxt,read:Qxt}],[`ZZ`,{re:Zxt,read:Qxt}]]),tSt,QZ=null;function nSt(e){if(e===tSt)return QZ;if(tSt=e,QZ=null,/[Ll]/.test(e.replace(Kxt,``)))return null;let t=e.match(Gxt);return t?(QZ=t.map(e=>eSt.get(e)??e.replace(/^\[|\]$/g,``)),QZ):null}function rSt(e,t,n){if(t===`x`||t===`X`)return/* @__PURE__ */ new Date((t===`X`?1e3:1)*Number(e));let r=nSt(t);if(!r)return;let i={},a=e,o=0;for(let e of r){if(typeof e==`string`){o+=e.length;continue}let t=e.re.exec(a.slice(o));if(!t||!e.read(i,t[0]))return;a=a.replace(t[0],``)}i.afternoon!==void 0&&i.hours!==void 0&&(i.afternoon?i.hours<12&&(i.hours+=12):i.hours===12&&(i.hours=0));let s=i.dayGiven||i.day?i.day:!i.year&&!i.month?n.getDate():1,c=i.year||n.getFullYear(),l=0;i.year&&!i.month||(l=i.month>0?i.month-1:n.getMonth());let u=i.hours||0,d=i.minutes||0,f=i.seconds||0,p=i.milliseconds||0;if(i.offset!==void 0)return new Date(Date.UTC(c,l,s,u,d,f,p+i.offset*6e4));if(!i.week)return new Date(c,l,s,u,d,f,p)}function iSt(e,t,n){let r=rSt(e,t,n);return r&&WZ(r)&&Uxt(r,t)===e?r:void 0}var aSt=/^[YMDHhmsSZXx\-/.:, T]*$/,oSt=/^\s*(active|done|crit|milestone|vert)\s*$/,sSt=/^after\s+([\d\w- ]+)/,cSt=/^until\s+([\d\w- ]+)/,lSt=/^(\d+(?:\.\d+)?)([Mdhmswy]|ms)$/,uSt=/[\s,]+/,dSt=/^\d+$/,fSt=new Set(UZ.map(e=>e.toLowerCase())),pSt=4e8,mSt=400,hSt=200,gSt=400;function _St(e){let t=e===void 0?NaN:+e;return Number.isFinite(t)?t:Date.now()}function vSt(e){let t=lSt.exec(e.trim());return t?[Number.parseFloat(t[1]),t[2]]:[NaN,`ms`]}function ySt(e,t){let n=new Set(e);for(let e of t.toLowerCase().split(uSt))e!==``&&n.add(e);return[...n]}var bSt=class{type=`gantt`;title;accTitle;accDescr;dateFormat=``;axisFormat=``;tickInterval;todayMarker=``;includes=[];excludes=[];inclusiveEndDates=!1;topAxis=!1;displayMode=``;weekday;weekend=`saturday`;sections=[];links=/* @__PURE__ */ new Map;tasks=[];byId=/* @__PURE__ */ new Map;currentSection=``;taskCount=0;lastOrder=0;lastTaskId;options;now=0;work=0;includeSet=/* @__PURE__ */ new Set;excludeSet=/* @__PURE__ */ new Set;excludedDays=[];datedTokens=!1;constructor(e={}){this.options=e}setDateFormat(e){this.dateFormat=e}enableInclusiveEndDates(){this.inclusiveEndDates=!0}TopAxis(){this.topAxis=!0}setAxisFormat(e){this.axisFormat=e}setTickInterval(e){this.tickInterval=e}setTodayMarker(e){this.todayMarker=e}setIncludes(e){this.includes=ySt(this.includes,e)}setExcludes(e){this.excludes=ySt(this.excludes,e)}setWeekday(e){this.weekday=e}setWeekend(e){this.weekend=e}setDiagramTitle(e){this.title=e}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,``)}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
1013
|
+
`):e,{types:r,texts:i,starts:a}=hxt(n),o=0,s,c=e=>{let t=r[o];throw t===1?FK(`flowchart`,n,a[o],``,!0):FK(`flowchart`,n,a[o],`Expecting ${e}, got '${qbt[t]}'`)},l=(e,t=``)=>(r[o]!==e&&c(`'${qbt[e]}'${t?`, `+t:``}`),i[o++]),u=()=>{let e=r[o];e!==74&&e!==37&&e!==76&&c(`'SEMI', 'NEWLINE', 'EOF'`),o++},d=()=>{NZ[r[o]]===0&&c(`'NODE_STRING'`);let e=i[o++];for(;NZ[r[o]]===1;)e+=i[o++];return e},f=()=>{PZ[r[o]]===0&&c(`'NODE_STRING'`);let e=i[o++];for(;PZ[r[o]]===1;)e+=i[o++];return e},p=()=>{let e=r[o],t;if(e===11)t=`string`;else if(e===10)t=`markdown`;else if(e===44||e===60||e===51||e===66)t=`text`;else return c(`${gxt}, 'TAGEND', 'STR', 'MD_STR'`);let n=i[o++];for(;;){let e=r[o];if(e!==44&&e!==60&&e!==51&&e!==66)break;n+=i[o++]}return{text:n,type:t}},m=e=>{l(e,gxt)},h=()=>{let e=r[o],t;if(e===11)t=`string`;else if(e===10)t=`markdown`;else if(e===42||e===66)t=`text`;else return c(`'EDGE_TEXT', 'STR', 'MD_STR'`);let n=i[o++];for(;r[o]===42||r[o]===66;)n+=i[o++];return{text:n,type:t}},g=()=>{let e=r[o],t;if(e===11)t=`text`;else if(e===10)t=`markdown`;else if(FZ[e]===1)t=`text`;else return c(`'NODE_STRING', 'STR', 'MD_STR'`);let n=i[o++];for(;FZ[r[o]]===1;)n+=i[o++];return{text:n,type:t}},_=()=>{let e=i[o++];for(;r[o]===7;)e+=i[o++];return e},v=()=>{let e=d(),n;switch(r[o]){case 71:o++,n=p(),m(70),t.addVertex(e,n,`square`);break;case 55:o++,n=p(),m(54),t.addVertex(e,n,`doublecircle`);break;case 69:o++,r[o]===69?(o++,n=p(),m(68),l(68),t.addVertex(e,n,`circle`)):(n=p(),m(68),t.addVertex(e,n,`round`));break;case 45:o++,n=p(),m(43),t.addVertex(e,n,`ellipse`);break;case 47:o++,n=p(),m(46),t.addVertex(e,n,`stadium`);break;case 49:o++,n=p(),m(48),t.addVertex(e,n,`subroutine`);break;case 50:{o++;let r=l(64);l(35);let i=l(64);l(67),n=p(),m(70),t.addVertex(e,n,`rect`,void 0,void 0,void 0,{[r]:i});break}case 53:o++,n=p(),m(52),t.addVertex(e,n,`cylinder`);break;case 73:o++,r[o]===73?(o++,n=p(),m(72),l(72),t.addVertex(e,n,`hexagon`)):(n=p(),m(72),t.addVertex(e,n,`diamond`));break;case 51:o++,n=p(),m(70),t.addVertex(e,n,`odd`);break;case 58:o++,n=p(),r[o]===57?(o++,t.addVertex(e,n,`lean_right`)):(m(56),t.addVertex(e,n,`trapezoid`));break;case 59:o++,n=p(),r[o]===56?(o++,t.addVertex(e,n,`lean_left`)):(m(57),t.addVertex(e,n,`inv_trapezoid`));break;default:t.addVertex(e)}return e},y=()=>{let e=v();return r[o]===34&&(o++,t.setClass(e,d())),e},b=()=>{let e=[y()];for(s=void 0;;){let n=r[o]===7?_():void 0;if(r[o]!==75)return s=n,e;do o++;while(r[o]===75);if(r[o]!==36)return n!==void 0&&c(`'AMP'`),e;o++,r[o]!==75&&c(`'SPACE'`);do o++;while(r[o]===75);let i=y();n!==void 0&&t.addVertex(e[e.length-1],void 0,void 0,void 0,void 0,void 0,void 0,n),e.push(i)}},x=()=>{let e;if(r[o]===31&&(e=i[o++]),r[o]===40){let n=t.destructLink(i[o++]);return e!==void 0&&(n.id=e),r[o]===67&&(o++,n.text=p(),m(67),r[o]===75&&o++),n}if(r[o]===41){let n=i[o++],r=h(),a=l(40,`'EDGE_TEXT'`),s=t.destructLink(a,n);return s.text=r,e!==void 0&&(s.id=e),s}return c(`'LINK', 'START_LINK'`)},S=()=>{let e=b();s!==void 0&&t.addVertex(e[e.length-1],void 0,void 0,void 0,void 0,void 0,void 0,s);let n=e;for(;;){let i=r[o];if(i!==40&&i!==41&&i!==31)return n;let a=x(),c=b();s!==void 0&&t.addVertex(c[c.length-1],void 0,void 0,void 0,void 0,void 0,void 0,s),t.addLink(e,c,a),n=c.concat(n),e=c}},C=()=>{IZ[r[o]]===0&&c(`'NODE_STRING', 'NUM', 'COLON', 'BRKT'`);let e=i[o++];for(;IZ[r[o]]===1;)e+=i[o++];return e},w=()=>{let e=[C()];for(;r[o]===38;)o++,e.push(C());return e},T=()=>{o++,l(75);let e;if(r[o]===13)e=[i[o++]];else for(e=[l(32,`'DEFAULT'`)];r[o]===38;)o++,e.push(l(32));if(l(75),r[o]!==15){t.updateLink(e,w());return}o++,l(75);let n=f();if(r[o]===75){o++;let r=w();t.updateLinkInterpolate(e,n),t.updateLink(e,r)}else t.updateLinkInterpolate(e,n)},E=(e,n)=>{if(r[o]!==75){t.setLink(e,n);return}if(o++,r[o]===23){t.setLink(e,n,i[o++]);return}let a=l(11,`'LINK_TARGET'`);r[o]===75?(o++,t.setLink(e,n,l(23))):t.setLink(e,n),t.setTooltip(e,a)},D=()=>{let e=i[o++];switch(r[o]){case 8:{let n=i[o++],a=r[o]===9,s=a?i[o++]:void 0,c;r[o]===75&&(o++,c=l(11)),a?t.setClickEvent(e,n,s):t.setClickEvent(e,n),c!==void 0&&t.setTooltip(e,c);return}case 18:o++,E(e,l(11));return;case 11:E(e,i[o++]);return;default:{let n=f();if(r[o]===75){o++;let r=l(11);t.setClickEvent(e,n),t.setTooltip(e,r)}else t.setClickEvent(e,n)}}},O=()=>{o++;let e=r[o];if(e===74||e===37||e===76)return o++,{id:void 0,title:void 0,list:[],collect:!1};l(75,`'SEMI', 'NEWLINE', 'EOF'`);let t=g(),n=t;return r[o]===71&&(o++,n=p(),m(70)),e=r[o],e!==74&&e!==37&&e!==76&&c(`'SEMI', 'NEWLINE', 'EOF', 'SQS'`),o++,{id:t,title:n,list:[],collect:!1}},k=()=>{let e=r[o];switch(e){case 12:{o++,l(75);let e=d();return l(75),t.addVertex(e,void 0,void 0,w()),u(),LZ}case 14:return T(),u(),LZ;case 16:{o++,l(75);let e=d();return l(75),t.addClass(e,w()),u(),LZ}case 17:{o++,l(75);let e=d();return l(75),t.setClass(e,d()),u(),LZ}case 19:return D(),u(),LZ;case 26:case 27:case 28:case 29:case 30:return o++,{stmt:`dir`,value:yxt[e-26]};case 2:{o++;let e=l(3).trim();return t.setAccTitle(e),e}case 4:{o++;let e=l(5).trim();return t.setAccDescription(e),e}case 6:{let e=i[o++].trim();return t.setAccDescription(e),e}default:{NZ[e]===0&&c(bxt);let t=S();return u(),t}}},A=()=>{let e=[],n=[],a=!1;for(;;){let s=r[o];if(s===0)break;if(s===22){let r=e.pop();if(r===void 0)break;o++;let i=t.addSubGraph(r.id,n,r.title);n=r.list,a=r.collect,a&&n.push(i)}else if(s===37||s===74||s===75||s===76)a&&n.push(i[o]),o++;else if(s===21){let t=O();t.list=n,t.collect=a,e.push(t),n=[],a=!0}else{let e=k();a&&(!Array.isArray(e)||e.length>0)&&n.push(e)}}e.length>0&&c(`'end'`)};for(;r[o]===75||r[o]===74;)o++;if(l(20,`'SPACE', 'NEWLINE'`),r[o]===24)o++,t.setDirection(`TB`);else{let e=l(25,`'NODIR'`),n=r[o];if(n===75){do o++;while(r[o]===75);n=r[o],n!==74&&c(`'NEWLINE', 'SPACE'`)}else n!==37&&n!==74&&c(`'SEMI', 'NEWLINE', 'SPACE'`);o++,t.setDirection(e)}A(),r[o]!==0&&c(bxt)}var yxt=[`TB`,`BT`,`RL`,`LR`,`TD`],bxt=`'SEMI', 'NEWLINE', 'SPACE', 'EOF', 'subgraph', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'STYLE', 'LINKSTYLE', 'CLASSDEF', 'CLASS', 'CLICK', 'NODE_STRING'`;function xxt(e){if(e.img)return`imageSquare`;if(e.icon)return e.form===`circle`?`iconCircle`:e.form===`square`?`iconSquare`:e.form===`rounded`?`iconRounded`:`icon`;switch(e.type){case`square`:case void 0:return`squareRect`;case`round`:return`roundedRect`;default:return e.type}}function Sxt(e){switch(e){case`arrow_point`:case`arrow_circle`:case`arrow_cross`:return[`none`,e];case`double_arrow_point`:case`double_arrow_circle`:case`double_arrow_cross`:{let t=e.replace(`double_`,``);return[t,t]}}return[`none`,`arrow_point`]}function Cxt(e,t){let n=[],r=[],i=e.subgraphs,a=t=>{let n=[];for(let r of t){let t=e.classes.get(r);t?.styles&&(n=[...n,...t.styles].map(e=>e.trim())),t?.textStyles&&(n=[...n,...t.textStyles].map(e=>e.trim()))}return n},o=/* @__PURE__ */ new Map;for(let t of i)for(let n of t.nodes)e.subgraph(n)&&o.set(n,t.id);let s=/* @__PURE__ */ new Map,c=/* @__PURE__ */ new Map;for(let e of i){let t=o.get(e.id);if(t===void 0)continue;let n=c.get(t);n?n.push(e.id):c.set(t,[e.id])}let l=0;for(let e of i){if(o.has(e.id))continue;let t=[e.id];for(;t.length>0;){let e=t.pop();if(s.has(e))continue;s.set(e,l++);let n=c.get(e);if(n)for(let e=n.length-1;e>=0;e--)t.push(n[e])}}let u=t=>e.subgraph(t)?.metadata?.view===`collapsed`,d=!1;for(let e of i)e.metadata?.view===`collapsed`&&(d=!0);let f=/* @__PURE__ */ new Map,p=e=>{let t=[],n=/* @__PURE__ */ new Set,r=e;for(;r!==void 0&&!f.has(r)&&!n.has(r);)n.add(r),t.push(r),r=o.get(r);let i=r===void 0?void 0:f.get(r);for(let e=t.length-1;e>=0;e--)i===void 0&&u(t[e])&&(i=t[e]),f.set(t[e],i);return i},m=/* @__PURE__ */ new Set,h=/* @__PURE__ */ new Map;for(let e of d?i:[]){let t=p(e.id);if(t!==void 0){e.id!==t&&(m.add(e.id),h.set(e.id,t));for(let n of e.nodes)n!==t&&(m.add(n),h.set(n,t))}}let g=/* @__PURE__ */ new Map,_=/* @__PURE__ */ new Set;for(let e=i.length-1;e>=0;e--){let t=i[e];if(!m.has(t.id)){t.nodes.length>0&&_.add(t.id);for(let e of t.nodes)g.set(e,t.id)}}let v=/* @__PURE__ */ new Map;for(let e=i.length-1;e>=0;e--){let t=i[e];if(m.has(t.id))continue;let r=t.metadata?.view===`collapsed`,o={id:t.id,label:t.title,labelType:t.labelType,parentId:g.get(t.id),cssStyles:[],cssCompiledStyles:a(t.classes),cssClasses:t.classes.join(` `),shape:r?`collapsedGroup`:`rect`,dir:t.dir,isGroup:!r,colorIndex:s.get(t.id)};r||(o.metadata=t.metadata),n.push(o),v.set(t.id,o)}for(let t of e.nodes.values()){if(m.has(t.id))continue;let r=v.get(t.id);if(r){r.cssStyles=t.styles,r.cssCompiledStyles=a(t.classes),r.cssClasses=t.classes.join(` `);continue}let i=_.has(t.id),o={id:t.id,label:t.text,labelType:t.labelType,parentId:g.get(t.id),cssStyles:t.styles,cssCompiledStyles:a([`default`,`node`,...t.classes]),cssClasses:`default `+t.classes.join(` `),dir:t.dir,link:t.link,linkTarget:t.linkTarget,tooltip:e.tooltips.get(t.id),icon:t.icon,pos:t.pos,img:t.img,assetWidth:t.assetWidth,assetHeight:t.assetHeight,constraint:t.constraint,isGroup:i,shape:i?`rect`:xxt(t)};n.push(o),v.set(t.id,o)}return e.edges.forEach((n,i)=>{let o=h.get(n.start)??n.start,s=h.get(n.end)??n.end;if(o===s&&(h.has(n.start)||h.has(n.end)))return;let[c,l]=Sxt(n.type),u=[...e.defaultEdgeStyle??[]];n.style&&u.push(...n.style);let d=n.stroke===`invisible`||n.type===`arrow_open`;r.push({id:n.id||`L_${o}_${s}_${i}`,isUserDefinedId:n.isUserDefinedId,start:o,end:s,type:n.type??`normal`,label:n.text,labelType:n.labelType,thickness:n.stroke,pattern:n.stroke,minlen:n.length,classes:n.stroke===`invisible`?``:`edge-thickness-normal edge-pattern-solid flowchart-link`,arrowTypeStart:d?`none`:c,arrowTypeEnd:d?`none`:l,cssCompiledStyles:a(n.classes),style:u,animate:n.animate,animation:n.animation,curve:n.interpolate||e.defaultInterpolate||t})}),{nodes:n,edges:r}}var wxt=40,Txt=16,Ext=48,Dxt=20,RZ=26,zZ=` fill="var(--_s)" stroke="var(--_b)"`,Oxt=` stroke="var(--_b)"`;function BZ(e,t,n){let r=e[t];return typeof r==`number`&&r>0?Math.min(r,2e3):n}function VZ(e,t){return e!==void 0&&e>0&&e<=4e3?e:t}function kxt(e,t,n,r){let i=i=>YJ(n,a=>Axt(e,t,n,r,i,a));return JJ(e.direction)?qJ(n,i):i(!1)}function Axt(e,t,n,r,i,a){let o=a?12:Dxt,s=r?t[r.type]:void 0,c=typeof s==`object`&&s&&!Array.isArray(s)?s:t.flowchart??{},l=Cxt(e,typeof c.curve==`string`?c.curve:void 0);r?.prepare(l);let u=n.fontSize??16,d=Math.round(u*.875),f=n.measurer??fq(n.fontFamily),p=Math.min(BZ(c,`wrappingWidth`,200),r&&a?100:1/0),m=n.padding??8,h=n.icons,g=/* @__PURE__ */ new Map,_=[],v=[];l.nodes.forEach((e,t)=>g.set(e.id,t));for(let e of l.nodes){let t=pJ(e.cssStyles.length>0?e.cssCompiledStyles.concat(e.cssStyles):e.cssCompiledStyles),i=+!!t.bold|(t.italic?2:0),s=e.labelType===`markdown`,c=t.fontSize??u,l,d;if(e.isGroup){let u=UJ(e.label,s,f,c,r&&a?Math.max(80,GJ(n)/2):4e3,i);l={node:e,style:t,label:u,shape:`group`,w:0,h:0,dy:0,loops:0},d=Qq(0,0),d.isGroup=!0,d.dir=e.dir?Xq(e.dir):void 0,d.padX=o,d.padTop=u.height>0?u.height+16:Dxt,d.padBottom=o,d.minW=u.width+2*o-12}else{let n=qpt(e.shape),r=UJ(e.img||e.icon||Bht(n)?e.label:void 0,s,f,c,p,i),a,o,u=0;if(e.img||e.icon){let t=e.img?80:48,n=VZ(e.assetWidth,t),i=VZ(e.assetHeight,t);a=Math.max(n,r.width+8),o=i+(r.height>0?r.height+6:0),u=e.pos===`t`?-i/2:i/2,r.height===0&&(u=0)}else{let e=IJ(n,r.width,r.height);a=e.w,o=e.h,u=e.dy}l={node:e,style:t,label:r,shape:n,w:a,h:o,dy:u,loops:0},d=Qq(a,o)}d.seq=_.length,_.push(l),v.push(d)}l.nodes.forEach((e,t)=>{v[t].parent=e.parentId===void 0?-1:g.get(e.parentId)??-1});let y=i?`TB`:Xq(e.direction),b=e=>{let t;for(let n=v[e].parent,r=0;n>=0&&t===void 0&&r<1e4;n=v[n].parent,r++)t=v[n].dir;return t??=y,t===`LR`||t===`RL`};_.forEach((e,t)=>{e.node.isGroup?v[t].span=1/0:!e.node.img&&!e.node.icon&&(v[t].span=zht(e.shape,e.w,e.h,b(t)))});let x=[],S=[],C=[];for(let e of l.edges){let t=g.get(e.start),n=g.get(e.end);if(t===void 0||n===void 0)continue;let r=UJ(e.label,e.labelType===`markdown`,f,d,p);t===n&&(_[t].loops++,b(t)?v[t].h+=2*(RZ+(r.height>0?r.height+8:0)):v[t].w+=2*(RZ+(r.width>0?r.width+12:0))),C.push(e),S.push(r),x.push({src:t,dst:n,minlen:e.minlen??1,labelW:r.width>0?r.width+12:0,labelH:r.height>0?r.height+4:0,route:[],labelX:0,labelY:0})}let w={nodeSep:BZ(c,`nodeSpacing`,wxt)*(a?.5:1),edgeSep:Txt,rankSep:BZ(c,`rankSpacing`,Ext)*(a?.75:1),portSep:20,tracks:typeof c.curve==`string`&&/^step/.test(c.curve),straight:c.curve===`linear`,headRoom:sJ(`arrow_point`)},T=r?r.layout(v,x,y,w,a):eJ(v,x,y,w),E=UJ(e.title,!1,f,u,a?GJ(n):4e3,1),D=E.height>0?E.height+12:0,O=Math.max(T.width,E.width);Zq(v,x,m+(O-T.width)/2,m+D);let k=Math.ceil(O+2*m),A=Math.ceil(T.height+D+2*m),j=[],M=/* @__PURE__ */ new Map,N=!1;for(let e of v)e.isGroup&&(N=!0);if(N)for(let e of x)tJ(M,e.route);let P=``,F=``,ee=``;for(let e=0;e<_.length;e++){let t=_[e],i=v[e],a=t.node,s=i.x,c=i.y,l=mJ(a.cssClasses.replace(/^default\s?/,``)),u=mq(a.id);if(i.isGroup&&r?.drawGroup&&i.parent<0){P+=r.drawGroup(i,t.label,t.style,l,u,y,h);continue}if(i.isGroup){let n=nJ(i,t.label.width,M,o),r=c-i.h/2+8+t.label.height/2,a=` class="pele-cluster-label" fill="var(--_m)"${t.style.text}`,d=ght(i,t.label.width,n,M);d&&(F+=_ht(t.label,n,r,a,u,v,e,h)),P+=`<g class="pele-cluster${l}" data-id="${u}"><rect x="${K(s-i.w/2)}" y="${K(c-i.h/2)}" width="${K(i.w)}" height="${K(i.h)}" rx="${dJ}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${t.style.shape}/>`+(d?``:gq(t.label,n,r,a,h))+`</g>`;continue}let d=t.w,f=t.h,p;if(a.img){let e=VZ(a.assetWidth,80),r=VZ(a.assetHeight,80),i=t.label.height>0?a.pos===`t`?f/2-r:-f/2:-r/2,o=Hpt(Cq(a.img),n);p=o===void 0?``:`<image href="${pq(o)}" x="${K(-e/2)}" y="${K(i)}" width="${K(e)}" height="${K(r)}" preserveAspectRatio="${a.constraint===`on`?`xMidYMid meet`:`none`}"/>`}else if(a.icon){let e=VZ(a.assetHeight,48),n=t.label.height>0?a.pos===`t`?f/2-e:-f/2:-e/2,r=a.shape===`icon`?``:a.shape===`iconCircle`?`<circle cy="${K(n+e/2)}" r="${K(e/2)}"${zZ}${t.style.shape}/>`:`<rect x="${K(-e/2)}" y="${K(n)}" width="${K(e)}" height="${K(e)}" rx="${a.shape===`iconRounded`?8:0}"${zZ}${t.style.shape}/>`,i=e*.6;p=r+`<svg class="pele-icon" data-icon="${mq(a.icon)}" x="${K(-i/2)}" y="${K(n+(e-i)/2)}" width="${K(i)}" height="${K(i)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${h?.(a.icon)??``}</svg>`}else p=LJ(t.shape,d,f,zZ+t.style.shape,Oxt+t.style.line);let m=gq(t.label,0,t.dy,` class="pele-label"${t.style.text}`,h);if(/ internal-link(?: |$)/.test(l+` `)&&a.label&&n.links!==!1){let e=RK(a.label),t=wq(Sq(e),n)!==void 0,r=pq(e);m=`<a class="internal-link"${t?` href="${r}"${Eq(n)}`:``} data-href="${r}">${m}</a>`,j.push({id:a.id,href:e,internal:!0})}let g=p+m;a.tooltip&&(g=`<title>${mq(a.tooltip)}</title>`+g),a.link&&(g=Tq(g,a.link,a.id,j,n,a.linkTarget?` target="${pq(a.linkTarget)}"`:``)),ee+=`<g class="pele-node pele-shape-${t.shape}${l}" data-id="${u}" transform="translate(${K(s)},${K(c)})">${g}</g>`}let te=yht();for(let e=0;e<x.length;e++){let t=x[e];t.src===t.dst||C[e].thickness===`invisible`||t.route.length<6||(te.add(t.src,zJ(t.route,0,v[t.src]),C[e].arrowTypeStart),te.add(t.dst,zJ(t.route,t.route.length-3,v[t.dst]),C[e].arrowTypeEnd))}let I=``,ne=``,re=/* @__PURE__ */ new Map;for(let e=0;e<x.length;e++){let t=x[e],n=C[e],r=S[e],i=n.style.length>0||n.cssCompiledStyles.length>0?pJ(n.cssCompiledStyles.concat(n.style)):void 0;if(n.thickness!==`invisible`){let e=n.arrowTypeStart,r=n.arrowTypeEnd,a;if(t.src===t.dst){let e=_[t.src],n=re.get(t.src)??0;re.set(t.src,n+1),a=bht(v[t.src],e.w,e.h,n,b(t.src),RZ,sJ(r),t)}else{let i=t.route.slice(),o=te.of(t.src,zJ(i,0,v[t.src])),s=te.of(t.dst,zJ(i,i.length-3,v[t.dst]));BJ(i,0,_[t.src],v[t.src]),BJ(i,i.length-3,_[t.dst],v[t.dst]),a=oJ(i,n.curve,sJ(e),sJ(r),o,s)}let o=i?.stroke&&n.thickness!==`invisible`?pq(i.stroke):`var(--_l)`,s=``;n.thickness===`thick`?s+=` stroke-width="2.5"`:n.thickness===`dotted`&&(s+=` stroke-dasharray="3 4"`);let c=mJ(n.classes.replace(/edge-thickness-normal|edge-pattern-solid|flowchart-link/g,``));I+=`<g class="pele-edge${c}" data-id="${mq(n.id)}"${i?.line??``}><path d="${a.d}"${s}/>`+cJ(e,a.sx,a.sy,a.sdx,a.sdy,o)+cJ(r,a.ex,a.ey,a.edx,a.edy,o)+`</g>`}if(r.width>0){let e=t.labelX,a=t.labelY;ne+=lJ(n.id,r,e,a,i?.text??``,h)}}return{svg:_J(r?.type??`flowchart`,k,A,u,n,e,gq(E,k/2,m+E.height/2,` class="pele-title" font-weight="var(--_tw)"`)+(P?`<g class="pele-clusters">${P}</g>`:``)+(I?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${I}</g>`:``)+(F?`<g class="pele-cluster-titles">${F}</g>`:``)+(ne?`<g class="pele-edge-labels" font-size="${d}">${ne}</g>`:``)+`<g class="pele-nodes">${ee}</g>`),width:k,height:A,links:j}}var jxt={type:`flowchart`,parse(e,t,n,r,i){let a=new Kbt({inheritDir:(t.flowchart??{}).inheritDir===!0,maxEdges:i.maxEdges});return n&&(a.title=n),vxt(e,a),a},render:kxt},HZ=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],UZ=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`];function WZ(e){return!Number.isNaN(e.getTime())}function GZ(e,t){let n=String(e);return n.length>=t?n:`0`.repeat(t-n.length)+n}function Mxt(e){let t=[`th`,`st`,`nd`,`rd`],n=e%100;return e+(t[(n-20)%10]||t[n]||t[0])}function KZ(e){let t=-Math.round(e.getTimezoneOffset()/15)*15;return t===0?0:t}function Nxt(e){let t=KZ(e),n=Math.abs(t);return(t>=0?`+`:`-`)+GZ(Math.floor(n/60),2)+`:`+GZ(n%60,2)}function Pxt(e){return e.getDay()||7}function qZ(e,t){let n=new Date(e);return n.setDate(n.getDate()+t),n}function Fxt(e){let t=new Date(e.getFullYear(),e.getMonth()+1,0);return t.setHours(23,59,59,999),t.getDate()}function Ixt(e,t){let n=new Date(e);return n.setDate(1),t(n),n.setDate(Math.min(e.getDate(),Fxt(n))),n}function Lxt(e,t,n){switch(n){case`M`:return Ixt(e,n=>n.setMonth(e.getMonth()+t));case`y`:return Ixt(e,n=>n.setFullYear(e.getFullYear()+t));case`d`:return qZ(e,Math.round(t));case`w`:return qZ(e,Math.round(7*t));case`h`:return new Date(e.getTime()+t*36e5);case`m`:return new Date(e.getTime()+t*6e4);case`s`:return new Date(e.getTime()+t*1e3);default:return new Date(e.getTime()+t)}}function Rxt(e){return qZ(e,4-Pxt(e))}function zxt(e){let t=Rxt(e),n=new Date(t.getFullYear(),0,1),r=Pxt(n),i=qZ(n,4-r+(r>4?7:0)),a=(KZ(i)-KZ(t))*6e4,o=(t.getTime()-i.getTime()-a)/6048e5;return(o<0?Math.ceil(o)||0:Math.floor(o))+1}var Bxt=/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g,Vxt=/\[([^\]]+)]|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,Hxt=`YYYY-MM-DDTHH:mm:ssZ`;function Uxt(e,t){if(!WZ(e))return`Invalid Date`;let n=t||Hxt;if(n===`YYYY-MM-DD`)return Wxt(e);let r=!1,i=n.replace(Bxt,t=>{switch(t){case`Q`:return String(Math.ceil((e.getMonth()+1)/3));case`Do`:return`[`+Mxt(e.getDate())+`]`;case`GGGG`:return String(Rxt(e).getFullYear());case`W`:return String(zxt(e));case`WW`:return GZ(zxt(e),2);case`k`:return String(e.getHours()||24);case`kk`:return GZ(e.getHours()||24,2);case`X`:return String(Math.floor(e.getTime()/1e3));case`x`:return String(e.getTime());case`gggg`:case`wo`:case`w`:case`ww`:case`z`:case`zzz`:return r=!0,t;default:return t}});if(r)return;let a=e.getHours();return i.replace(Vxt,(t,n)=>{if(n)return n;switch(t){case`YY`:return String(e.getFullYear()).slice(-2);case`YYYY`:return GZ(e.getFullYear(),4);case`M`:return String(e.getMonth()+1);case`MM`:return GZ(e.getMonth()+1,2);case`MMM`:return HZ[e.getMonth()].slice(0,3);case`MMMM`:return HZ[e.getMonth()];case`D`:return String(e.getDate());case`DD`:return GZ(e.getDate(),2);case`d`:return String(e.getDay());case`dd`:return UZ[e.getDay()].slice(0,2);case`ddd`:return UZ[e.getDay()].slice(0,3);case`dddd`:return UZ[e.getDay()];case`H`:return String(a);case`HH`:return GZ(a,2);case`h`:return String(a%12||12);case`hh`:return GZ(a%12||12,2);case`a`:return a<12?`am`:`pm`;case`A`:return a<12?`AM`:`PM`;case`m`:return String(e.getMinutes());case`mm`:return GZ(e.getMinutes(),2);case`s`:return String(e.getSeconds());case`ss`:return GZ(e.getSeconds(),2);case`SSS`:return GZ(e.getMilliseconds(),3);case`Z`:return Nxt(e);default:return Nxt(e).replace(`:`,``)}})}function Wxt(e){let t=e.getFullYear(),n=e.getMonth()+1,r=e.getDate();return(t>=1e3&&t<=9999?t:GZ(t,4))+(n<10?`-0`:`-`)+n+(r<10?`-0`:`-`)+r}var Gxt=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,Kxt=/\[[^\]]+]/g,qxt=/\d/,JZ=/\d\d/,Jxt=/\d{3}/,Yxt=/\d{4}/,YZ=/\d\d?/,Xxt=/[+-]?\d+/,Zxt=/[+-]\d\d:?(\d\d)?|Z/,XZ=/\d*[^-_:/,()\s\d]+/;function ZZ(e){return(t,n)=>(t[e]=+n,!0)}var Qxt=(e,t)=>{if(t===`Z`)return e.offset=0,!0;let n=t.match(/([+-]|\d\d)/g),r=n[1]*60+(+n[2]||0);return e.offset=r===0?0:n[0]===`+`?-r:r,!0};function $xt(e){return(t,n)=>{let r=e.indexOf(n)+1;return r<1?!1:(t.month=r%12||r,!0)}}var eSt=/* @__PURE__ */ new Map([[`A`,{re:XZ,read:(e,t)=>(e.afternoon=t===`PM`,!0)}],[`a`,{re:XZ,read:(e,t)=>(e.afternoon=t===`pm`,!0)}],[`Q`,{re:qxt,read:(e,t)=>(e.month=(t-1)*3+1,!0)}],[`S`,{re:qxt,read:(e,t)=>(e.milliseconds=t*100,!0)}],[`SS`,{re:JZ,read:(e,t)=>(e.milliseconds=t*10,!0)}],[`SSS`,{re:Jxt,read:(e,t)=>(e.milliseconds=+t,!0)}],[`s`,{re:YZ,read:ZZ(`seconds`)}],[`ss`,{re:YZ,read:ZZ(`seconds`)}],[`m`,{re:YZ,read:ZZ(`minutes`)}],[`mm`,{re:YZ,read:ZZ(`minutes`)}],[`H`,{re:YZ,read:ZZ(`hours`)}],[`h`,{re:YZ,read:ZZ(`hours`)}],[`HH`,{re:YZ,read:ZZ(`hours`)}],[`hh`,{re:YZ,read:ZZ(`hours`)}],[`D`,{re:YZ,read:ZZ(`day`)}],[`DD`,{re:JZ,read:ZZ(`day`)}],[`Do`,{re:XZ,read:(e,t)=>{let n=t.match(/\d+/);if(!n)return!1;e.day=+n[0],e.dayGiven=!0;for(let n=1;n<=31;n++)Mxt(n)===t&&(e.day=n);return!0}}],[`w`,{re:YZ,read:ZZ(`week`)}],[`ww`,{re:JZ,read:ZZ(`week`)}],[`M`,{re:YZ,read:ZZ(`month`)}],[`MM`,{re:JZ,read:ZZ(`month`)}],[`MMM`,{re:XZ,read:$xt(HZ.map(e=>e.slice(0,3)))}],[`MMMM`,{re:XZ,read:$xt(HZ)}],[`Y`,{re:Xxt,read:ZZ(`year`)}],[`YY`,{re:JZ,read:(e,t)=>(e.year=+t+(+t>68?1900:2e3),!0)}],[`YYYY`,{re:Yxt,read:ZZ(`year`)}],[`Z`,{re:Zxt,read:Qxt}],[`ZZ`,{re:Zxt,read:Qxt}]]),tSt,QZ=null;function nSt(e){if(e===tSt)return QZ;if(tSt=e,QZ=null,/[Ll]/.test(e.replace(Kxt,``)))return null;let t=e.match(Gxt);return t?(QZ=t.map(e=>eSt.get(e)??e.replace(/^\[|\]$/g,``)),QZ):null}function rSt(e,t,n){if(t===`x`||t===`X`)return/* @__PURE__ */ new Date((t===`X`?1e3:1)*Number(e));let r=nSt(t);if(!r)return;let i={},a=e,o=0;for(let e of r){if(typeof e==`string`){o+=e.length;continue}let t=e.re.exec(a.slice(o));if(!t||!e.read(i,t[0]))return;a=a.replace(t[0],``)}i.afternoon!==void 0&&i.hours!==void 0&&(i.afternoon?i.hours<12&&(i.hours+=12):i.hours===12&&(i.hours=0));let s=i.dayGiven||i.day?i.day:!i.year&&!i.month?n.getDate():1,c=i.year||n.getFullYear(),l=0;i.year&&!i.month||(l=i.month>0?i.month-1:n.getMonth());let u=i.hours||0,d=i.minutes||0,f=i.seconds||0,p=i.milliseconds||0;if(i.offset!==void 0)return new Date(Date.UTC(c,l,s,u,d,f,p+i.offset*6e4));if(!i.week)return new Date(c,l,s,u,d,f,p)}function iSt(e,t,n){let r=rSt(e,t,n);return r&&WZ(r)&&Uxt(r,t)===e?r:void 0}var aSt=/^[YMDHhmsSZXx\-/.:, T]*$/,oSt=/^\s*(active|done|crit|milestone|vert)\s*$/,sSt=/^after\s+([\d\w- ]+)/,cSt=/^until\s+([\d\w- ]+)/,lSt=/^(\d+(?:\.\d+)?)([Mdhmswy]|ms)$/,uSt=/[\s,]+/,dSt=/^\d+$/,fSt=new Set(UZ.map(e=>e.toLowerCase())),pSt=4e8,mSt=400,hSt=200,gSt=400;function _St(e){let t=e===void 0?NaN:+e;return Number.isFinite(t)?t:Date.now()}function vSt(e){let t=lSt.exec(e.trim());return t?[Number.parseFloat(t[1]),t[2]]:[NaN,`ms`]}function ySt(e,t){let n=new Set(e);for(let e of t.toLowerCase().split(uSt))e!==``&&n.add(e);return[...n]}var bSt=class{type=`gantt`;title;accTitle;accDescr;dateFormat=``;axisFormat=``;tickInterval;todayMarker=``;includes=[];excludes=[];inclusiveEndDates=!1;topAxis=!1;displayMode=``;weekday;weekend=`saturday`;sections=[];links=/* @__PURE__ */ new Map;tasks=[];byId=/* @__PURE__ */ new Map;currentSection=``;taskCount=0;lastOrder=0;lastTaskId;options;now=0;work=0;includeSet=/* @__PURE__ */ new Set;excludeSet=/* @__PURE__ */ new Set;excludedDays=[];datedTokens=!1;constructor(e={}){this.options=e}setDateFormat(e){this.dateFormat=e}enableInclusiveEndDates(){this.inclusiveEndDates=!0}TopAxis(){this.topAxis=!0}setAxisFormat(e){this.axisFormat=e}setTickInterval(e){this.tickInterval=e}setTodayMarker(e){this.todayMarker=e}setIncludes(e){this.includes=ySt(this.includes,e)}setExcludes(e){this.excludes=ySt(this.excludes,e)}setWeekday(e){this.weekday=e}setWeekend(e){this.weekend=e}setDiagramTitle(e){this.title=e}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,``)}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
1014
1014
|
`)}addSection(e){this.currentSection=e,this.sections.push(e)}addTask(e,t){let n=(t.startsWith(`:`)?t.slice(1):t).split(`,`),r={id:``,task:e,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:t,start:void 0,end:``}},i;for(;n.length>0&&(i=oSt.exec(n[0]))!==null;)r[i[1]]=!0,n.shift();if(n.length===0)throw new NK(`Task "${e.trim()}" needs a duration or an end date.`,`semantic`,{type:`gantt`});if(n.length>3)throw new NK(`Task "${e.trim()}" has too many fields. A task takes an id, a start, and an end or duration.`,`semantic`,{type:`gantt`});for(let e=0;e<n.length;e++)n[e]=n[e].trim();n.length===3?r.id=n[0]:(this.taskCount++,r.id=`task`+this.taskCount),n.length>1&&(r.raw.start=n[n.length-2]),r.raw.end=n[n.length-1],r.vert||(r.order=this.lastOrder++),this.tasks.push(r),this.lastTaskId=r.id,this.byId.set(r.id,r)}setLink(e,t){let n=Cq(t);for(let t of e.split(`,`))this.byId.has(t)&&this.links.set(t,n);this.setClass(e,`clickable`)}setClickEvent(e,t,n){this.setClass(e,`clickable`)}setClass(e,t){for(let n of e.split(`,`))this.byId.get(n)?.classes.push(t)}getTasks(e){this.now=_St(e),this.work=0,this.includeSet=new Set(this.includes),this.excludeSet=new Set(this.excludes);let t=this.weekend===`friday`?5:this.weekend===`saturday`?6:NaN,n=this.excludeSet.has(`weekends`);this.excludedDays=UZ.map((e,r)=>{let i=r||7;return n&&(i===t||i===t+1)||this.excludeSet.has(e.toLowerCase())}),this.datedTokens=this.includes.length>0||!aSt.test(this.dateFormat.trim());for(let e of this.excludes)e!==`weekends`&&!fSt.has(e)&&(this.datedTokens=!0);for(let e of this.tasks)e.startTime=e.endTime=void 0,e.renderEndTime=null,e.processed=e.manualEndTime=!1;let r=this.compileTasks();for(let e=0;!r&&e<10;e++)r=this.compileTasks();return this.tasks}isInvalidDate(e){let t=this.excludedDays[e.getDay()];if(!this.datedTokens)return t;let n=this.dateFormat.trim(),r=Wxt(e),i=r;this.spend(hSt),n!==`YYYY-MM-DD`&&(this.spend(gSt+n.length*8),i=Uxt(e,n));let a=e=>e.has(r)||i!==void 0&&e.has(i);return a(this.includeSet)?!1:t||a(this.excludeSet)}spend(e){if(this.work+=e,this.work>pSt)throw new NK(`The gantt chart takes too much work to schedule.`,`limit`,{type:`gantt`})}parse(e,t){return this.spend((t.length+1)*(e.length+1)),iSt(e,t,new Date(this.now))}today(){let e=new Date(this.now);return e.setHours(0,0,0,0),e}warn(e){this.options.warn&&this.options.warn(e())}compileTasks(){let e=!0;for(let t of this.tasks)this.compileTask(t),e&&=t.processed;return e}compileTask(e){let t=e.raw.start;if(t===void 0){let t=e.prevTaskId===void 0?void 0:this.byId.get(e.prevTaskId);e.startTime=t?t.endTime:this.today()}else{let n=this.getStartDate(t);n&&(e.startTime=n)}e.startTime&&(e.endTime=this.getEndDate(e.startTime,e.raw.end),e.endTime&&(e.processed=!0,e.manualEndTime=this.parse(e.raw.end,`YYYY-MM-DD`)!==void 0,this.checkTaskDates(e)))}references(e,t){let n=[],r;for(let e of t.split(` `)){if(e===``)continue;let t=this.byId.get(e);t?n.push(t):(r??=[]).push(e)}if(r){let t=r;this.warn(()=>`Gantt: "${e}" refers to task ids that do not exist: ${t.join(`, `)}.`)}return n}getStartDate(e){let t=e.trim(),n=this.dateFormat.trim();if((n===`x`||n===`X`)&&dSt.test(t))return this.checked(new Date(Number(t)),t);let r=sSt.exec(t);if(r!==null){let e=this.references(`after`,r[1]),t;for(let n of e)(!t||n.endTime>t.endTime)&&(t=n);return t?t.endTime:this.today()}let i=this.parse(t,n);if(i)return i;let a=new Date(t);if(!WZ(a)||a.getFullYear()<-1e4||a.getFullYear()>1e4)throw new NK(`Invalid date:`+t,`semantic`,{type:`gantt`});return a}checked(e,t){if(!WZ(e))throw new NK(`Invalid date:`+t,`semantic`,{type:`gantt`});return e}getEndDate(e,t){let n=t.trim(),r=cSt.exec(n);if(r!==null){let e=this.references(`until`,r[1]),t;for(let n of e)(!t||n.startTime<t.startTime)&&(t=n);return t?t.startTime:this.today()}let i=this.dateFormat.trim(),a=this.parse(n,i);if(a)return this.inclusiveEndDates?qZ(a,1):a;let[o,s]=vSt(n);if(Number.isNaN(o))return this.warn(()=>`Gantt: "${n}" is neither a date in the "${i}" format nor a duration such as "3d", so the task gets no duration.`),new Date(e);let c=Lxt(e,o,s);return WZ(c)?c:new Date(e)}checkTaskDates(e){if(this.excludes.length===0||e.manualEndTime)return;let t=qZ(e.startTime,1),n=new Date(e.endTime),r=+qZ(n,1e4),i=!1,a=null;for(;+t<=+n;){if(this.spend(mSt),i||(a=+n),i=this.isInvalidDate(t),i&&(n.setDate(n.getDate()+1),+n>r))throw new NK("Failed to find a valid date that was not excluded by `excludes` after 10,000 iterations.",`semantic`,{type:`gantt`});t.setDate(t.getDate()+1)}e.endTime=n,e.renderEndTime=a===null?null:new Date(a)}},xSt=/* @__PURE__ */ `$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`.split(`.`),SSt=/accTitle\s*:\s*/iy,CSt=/accDescr\s*:\s*/iy,wSt=/accDescr\s*\{\s*/iy,TSt=/href\s+"/iy,ESt=/call\s+/iy,DSt=/click\s+/iy,OSt=/\(\s*\)/y,$Z=/weekday\s+(monday|tuesday|wednesday|thursday|friday|saturday|sunday)\b/iy,kSt=[`monday`,`tuesday`,`wednesday`,`thursday`,`friday`,`saturday`,`sunday`],eQ=/weekend\s+(?:(friday)|saturday)\b/iy,ASt=/\d\d\d\d-\d\d-\d\d\b/y,jSt=/* @__PURE__ */ 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[^\n]+/iy,32]]],[101,[[/excludes\s[^#\n;]+/iy,20]]],[115,[[/section\s[^\n]+/iy,34]]]]);function MSt(e){let t=e.length,n=[],r=[],i=[],a=0,o=0,s=(t,a,s)=>{n.push(t),r.push(e.slice(a,s)),i.push(a),o=s},c=t=>(t.lastIndex=o,t.test(e)?t.lastIndex:-1),l=(n,r)=>{let i=e.indexOf(n,r);return i===-1?t:i},u=t=>{let n;switch(t|32){case 97:if((n=c(SSt))>=0)return a=1,s(3,o,n),!0;if((n=c(CSt))>=0)return a=2,s(5,o,n),!0;if((n=c(wSt))>=0)return a=3,o=n,!0;break;case 104:if((n=c(TSt))>=0)return a=4,o=n,!0;break;case 99:if((n=c(ESt))>=0)return a=5,o=n,!0;if((n=c(DSt))>=0)return a=7,o=n,!0;break;case 119:{$Z.lastIndex=o;let t=$Z.exec(e);if(t)return s(22+kSt.indexOf(t[1].toLowerCase()),o,$Z.lastIndex),!0;if(eQ.lastIndex=o,t=eQ.exec(e),t)return s(t[1]===void 0?30:29,o,eQ.lastIndex),!0;break}}let r=jSt.get(t|32);if(r){for(let[e,t]of r)if((n=c(e))>=0)return s(t,o,n),!0}return!1};for(;;){if(o>=t){let e=38;switch(a){case 1:e=4;break;case 2:e=6;break;case 3:e=7;break;case 4:e=9;break;case 5:e=10;break;case 6:e=11;break;case 7:e=12}s(e,t,t);break}let d=e.charCodeAt(o);switch(a){case 0:{let a=e.charCodeAt(o+1);if(d===37){if(a!==37){let t=l(`
|
|
1015
1015
|
`,o+1);for(;e.charCodeAt(t)===10;)t++;o=t}else{if(e.charCodeAt(o+2)===123)return s(2,o,o+3),s(1,o,o),{types:n,texts:r,starts:i};o=l(`
|
|
1016
1016
|
`,o+2)}}else if(d!==125&&a===37)o=l(`
|
|
1017
1017
|
`,o+2);else if(d===10){let t=o+1;for(;e.charCodeAt(t)===10;)t++;s(8,o,t)}else if(eq(d))for(o++;o<t&&eq(e.charCodeAt(o));)o++;else{if(u(d))break;if(d>=48&&d<=57&&c(ASt)>=0)s(31,o,o+10);else if(d!==58){let n=o+1;for(;n<t;){let t=e.charCodeAt(n);if(t===58||t===10)break;n++}s(35,o,n)}else{let n=o+1;for(;n<t;){let t=e.charCodeAt(n);if(t===35||t===10||t===59)break;n++}s(n>o+1?36:37,o,n)}}break}case 1:case 2:{let e=a===1?4:6;a=0,s(e,o,l(`
|
|
1018
|
-
`,o));break}case 3:d===125?(a=0,o++):s(7,o,l(`}`,o));break;case 4:d===34?(a=0,o++):s(9,o,l(`"`,o));break;case 5:if(d===40){let e=c(OSt);e>=0?(a=0,o=e):(a=6,o++)}else s(10,o,l(`(`,o));break;case 6:d===41?(a=0,o++):s(11,o,l(`)`,o));break;case 7:if(eq(d))a=0,o++;else{let n=o+1;for(;n<t&&!eq(e.charCodeAt(n));)n++;s(12,o,n)}}}return n.push(0),r.push(``),i.push(t),{types:n,texts:r,starts:i}}var NSt=[`monday`,`tuesday`,`wednesday`,`thursday`,`friday`,`saturday`,`sunday`],PSt=`'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'`,tQ=/* @__PURE__ */ new Uint8Array(39);for(let e=22;e<=30;e++)tQ[e]=1;for(let e of[38,8,14,15,16,17,18,20,19,21,32,3,5,7,34,35,12])tQ[e]=1;function FSt(e,t){let{types:n,texts:r,starts:i}=MSt(e),a=0,o=t=>{let r=n[a];throw FK(`gantt`,e,i[a],`Expecting ${t}, got '${r===0?`1`:xSt[r]}'`)},s=(e=``)=>{tQ[n[a]]!==1&&o(PSt+e)};for(n[a]!==13&&o(`'gantt'`),a++;;){let e=n[a],i=r[a];switch(tQ[e]!==1&&o(PSt),a++,e){case 38:if(n[a]===0)return;s();break;case 8:break;case 14:s(),t.setDateFormat(i.slice(11));break;case 15:s(),t.enableInclusiveEndDates();break;case 16:s(),t.TopAxis();break;case 17:s(),t.setAxisFormat(i.slice(11));break;case 18:s(),t.setTickInterval(i.slice(13));break;case 20:s(),t.setExcludes(i.slice(9));break;case 19:s(),t.setIncludes(i.slice(9));break;case 21:s(),t.setTodayMarker(i.slice(12));break;case 29:s(),t.setWeekend(`friday`);break;case 30:s(),t.setWeekend(`saturday`);break;case 32:s(),t.setDiagramTitle(i.slice(6));break;case 3:{n[a]!==4&&o(`'acc_title_value'`);let e=r[a++];s(),t.setAccTitle(e.trim());break}case 5:{n[a]!==6&&o(`'acc_descr_value'`);let e=r[a++];s(),t.setAccDescription(e.trim());break}case 7:s(),t.setAccDescription(i.trim());break;case 34:s(),t.addSection(i.slice(8));break;case 35:{n[a]!==36&&o(`'taskData'`);let e=r[a++];s(),t.addTask(i,e);break}case 12:{let e,c=null,l;n[a]===10?(e=r[a++],n[a]===11&&(c=r[a++]),n[a]===9?(l=r[a++],s()):s(c===null?`, 'callbackargs', 'href'`:`, 'href'`)):n[a]===9?(l=r[a++],n[a]===10?(e=r[a++],n[a]===11?(c=r[a++],s()):s(`, 'callbackargs'`)):s(`, 'callbackname'`)):o(`'callbackname', 'href'`),e!==void 0&&t.setClickEvent(i,e,c),l!==void 0&&t.setLink(i,l);break}default:s(),t.setWeekday(NSt[e-22])}}}var nQ=1e3,rQ=60*nQ,iQ=60*rQ,aQ=24*iQ,oQ=7*aQ,sQ=30*aQ,cQ=365*aQ;function lQ(e){e.setHours(0,0,0,0)}function uQ(e){return{floor(t){t.setDate(t.getDate()-(t.getDay()+7-e)%7),lQ(t)},offset:(e,t)=>e.setDate(e.getDate()+t*7),cycle:1/0,ms:oQ}}var dQ={millisecond:{floor:()=>{},offset:(e,t)=>e.setTime(+e+t),cycle:1/0,ms:1},second:{floor:e=>e.setTime(+e-e.getMilliseconds()),offset:(e,t)=>e.setTime(+e+t*nQ),field:e=>e.getUTCSeconds(),cycle:60,ms:nQ},minute:{floor:e=>e.setTime(+e-e.getMilliseconds()-e.getSeconds()*nQ),offset:(e,t)=>e.setTime(+e+t*rQ),field:e=>e.getMinutes(),cycle:60,ms:rQ},hour:{floor:e=>e.setTime(+e-e.getMilliseconds()-e.getSeconds()*nQ-e.getMinutes()*rQ),offset:(e,t)=>e.setTime(+e+t*iQ),field:e=>e.getHours(),cycle:24,ms:iQ},day:{floor:lQ,offset:(e,t)=>e.setDate(e.getDate()+t),field:e=>e.getDate()-1,cycle:31,ms:aQ},month:{floor(e){e.setDate(1),lQ(e)},offset:(e,t)=>e.setMonth(e.getMonth()+t),field:e=>e.getMonth(),cycle:12,ms:sQ},year:{floor(e){e.setMonth(0,1),lQ(e)},offset:(e,t)=>e.setFullYear(e.getFullYear()+t),cycle:1/0,ms:cQ}};function fQ(e,t,n){return Math.floor((+t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*rQ)/n)}function ISt(e,t){return(e%t+t)%t}function pQ(e,t,n){let r=e===`week`?uQ(n):dQ[e];if(t<=1)return r;if(e===`millisecond`)return{...r,floor:e=>e.setTime(Math.floor(+e/t)*t),offset:(e,n)=>e.setTime(+e+n*t)};if(e===`year`)return{...r,floor(e){e.setFullYear(Math.floor(e.getFullYear()/t)*t),r.floor(e)},offset:(e,n)=>e.setFullYear(e.getFullYear()+n*t)};if(e===`week`){let e=/* @__PURE__ */ new Date(0);return r.floor(e),{...r,floor(n){r.floor(n),r.offset(n,-ISt(fQ(e,n,oQ),t))},offset:(e,n)=>r.offset(e,n*t)}}let i=r.field,a=e=>i(e)%t===0;return{...r,floor(e){for(r.floor(e);Number.isFinite(+e)&&!a(e);r.floor(e))e.setTime(e-1)},offset(e,t){for(let n=0;n<t&&Number.isFinite(+e);n++)do r.offset(e,1);while(Number.isFinite(+e)&&!a(e))}}}function LSt(e,t,n,r){let i=/* @__PURE__ */ new Date(t-1);e.floor(i),e.offset(i,1),e.floor(i);let a=[],o=-1/0;for(;+i<=n&&+i>o;){if(a.length>=r)return;o=+i,a.push(o),e.offset(i,1),e.floor(i)}return a}function RSt(e,t,n){let r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/10**i;return 10**i*(a>=Math.sqrt(50)?10:a>=Math.sqrt(10)?5:a>=Math.SQRT2?2:1)}var mQ=[[`second`,1,nQ],[`second`,5,5*nQ],[`second`,15,15*nQ],[`second`,30,30*nQ],[`minute`,1,rQ],[`minute`,5,5*rQ],[`minute`,15,15*rQ],[`minute`,30,30*rQ],[`hour`,1,iQ],[`hour`,3,3*iQ],[`hour`,6,6*iQ],[`hour`,12,12*iQ],[`day`,1,aQ],[`day`,2,2*aQ],[`week`,1,oQ],[`month`,1,sQ],[`month`,3,3*sQ],[`year`,1,cQ]];function zSt(e,t,n){let r=(t-e)/n,i=0;for(;i<mQ.length&&mQ[i][2]<=r;)i++;let a;if(i===mQ.length)a=pQ(`year`,Math.max(1,RSt(e/cQ,t/cQ,n)),0);else if(i===0)a=pQ(`millisecond`,Math.max(RSt(e,t,n),1),0);else{let[e,t]=mQ[r/mQ[i-1][2]<mQ[i][2]/r?i-1:i];a=pQ(e,t,0)}return LSt(a,e,t,4*n+8)??[]}var BSt=/^([1-9]\d*)(millisecond|second|minute|hour|day|week|month)$/,VSt=[`sunday`,`monday`,`tuesday`,`wednesday`,`thursday`,`friday`,`saturday`];function HSt(e,t,n,r,i){let a=BSt.exec(e);if(!a)return;let o=parseInt(a[1],10),s=a[2],c=pQ(s,o,Math.max(0,VSt.indexOf(t)));if(!((r-n)/(Math.min(o,c.cycle)*c.ms)>i))return LSt(c,n,r,i)}function hQ(e,t,n){let r=e<0?`-`:``,i=String(r?-e:e);return r+(i.length<n?t.repeat(n-i.length)+i:i)}function gQ(e,t){let n=/* @__PURE__ */ new Date(+e);return t.floor(n),n}function USt(e,t){let n=uQ(t),r=gQ(e,dQ.year);return fQ(gQ(/* @__PURE__ */ new Date(r-1),n),gQ(e,n),oQ)}function _Q(e){let t=uQ(4),n=e.getDay(),r=gQ(n>=4||n===0?e:/* @__PURE__ */ new Date(e-1),t);return n>=4||n===0||(t.offset(r,1),t.floor(r)),r}var WSt=/* @__PURE__ */ new Map([[`-`,``],[`_`,` `],[`0`,`0`]]);function vQ(e,t){let n=``,r=0,i=e.length;for(let a=0;a<i;a++){if(e.charCodeAt(a)!==37)continue;n+=e.slice(r,a);let i=e.charAt(++a),o=WSt.get(i);o===void 0?o=i===`e`?` `:`0`:i=e.charAt(++a),n+=GSt(i,t,o),r=a+1}return n+e.slice(r)}function GSt(e,t,n){switch(e){case`a`:return UZ[t.getDay()].slice(0,3);case`A`:return UZ[t.getDay()];case`b`:return HZ[t.getMonth()].slice(0,3);case`B`:return HZ[t.getMonth()];case`c`:return vQ(`%x, %X`,t);case`d`:case`e`:return hQ(t.getDate(),n,2);case`f`:return hQ(t.getMilliseconds(),n,3)+`000`;case`g`:return hQ(_Q(t).getFullYear()%100,n,2);case`G`:return hQ(_Q(t).getFullYear()%1e4,n,4);case`H`:return hQ(t.getHours(),n,2);case`I`:return hQ(t.getHours()%12||12,n,2);case`j`:return hQ(1+fQ(gQ(t,dQ.year),gQ(t,dQ.day),aQ),n,3);case`L`:return hQ(t.getMilliseconds(),n,3);case`m`:return hQ(t.getMonth()+1,n,2);case`M`:return hQ(t.getMinutes(),n,2);case`p`:return t.getHours()>=12?`PM`:`AM`;case`q`:return String(1+Math.floor(t.getMonth()/3));case`Q`:return String(+t);case`s`:return String(Math.floor(t/1e3));case`S`:return hQ(t.getSeconds(),n,2);case`u`:return String(t.getDay()||7);case`U`:return hQ(USt(t,0),n,2);case`V`:{let e=_Q(t),r=gQ(e,dQ.year);return hQ(fQ(gQ(r,uQ(4)),e,oQ)+ +(r.getDay()===4),n,2)}case`w`:return String(t.getDay());case`W`:return hQ(USt(t,1),n,2);case`x`:return vQ(`%-m/%-d/%Y`,t);case`X`:return vQ(`%-I:%M:%S %p`,t);case`y`:return hQ(t.getFullYear()%100,n,2);case`Y`:return hQ(t.getFullYear()%1e4,n,4);case`Z`:{let e=t.getTimezoneOffset(),n=Math.abs(e);return(e>0?`-`:`+`)+hQ(Math.floor(n/60),`0`,2)+hQ(n%60,`0`,2)}case`%`:return`%`;default:return e}}var KSt=800,qSt=240,yQ=8,JSt=/<br\s*\/?>/gi;function bQ(e,t,n,r){let i=e.gantt?.[t];return typeof i==`number`&&Number.isFinite(i)?Math.min(r,Math.max(n,i)):void 0}function xQ(e,t){let n=e.gantt?.[t];return typeof n==`string`?n:void 0}function YSt(e,t){return e.gantt?.[t]===!0}function XSt(e,t,n){let r=WJ(e.replace(JSt,` `),!1,t,n,4e3);return r.lines.length<=1?r:{...r,lines:[r.lines[0]],widths:[r.widths[0]],width:r.widths[0],height:r.lineHeight}}function SQ(e){return Number.isFinite(+e.startTime)&&Number.isFinite(+e.endTime)}function ZSt(e,t,n){let r=e.filter(SQ).sort((e,t)=>+e.startTime-t.startTime||e.order-t.order),i=[];for(let e of r){let r=+e.startTime,a=0;for(;a<i.length&&r<i[a];)a++;i[a]=+e.endTime,n.set(e,t+a)}let a=i.length;for(let r of e)n.has(r)||n.set(r,t+a++);return Math.max(a,1)}function QSt(e,t,n){let r=n.fontSize??16,i=n.measurer??fq(n.fontFamily),a=n.padding??8,o=_St(n.now),s=bQ(t,`fontSize`,4,72)??Math.round(r*.8125),c=bQ(t,`sectionFontSize`,4,72)??s,l=Math.round(r*.75),u=bQ(t,`barHeight`,4,400)??Math.round(s*1.85),d=u+(bQ(t,`barGap`,0,400)??Math.round(u/4)),f=Math.round(bQ(t,`numberSectionStyles`,1,1e3)??4),p=e.displayMode===`compact`,m=e.topAxis||YSt(t,`topAxis`),h=e.getTasks(o),g=h.filter(e=>!e.vert),_=h.filter(e=>e.vert&&SQ(e)),v=/* @__PURE__ */ new Map;for(let e of g)v.has(e.section)||v.set(e.section,v.size);let y=/* @__PURE__ */ new Map,b=[];if(p){let e=/* @__PURE__ */ new Map;for(let t of g){let n=e.get(t.section);n?n.push(t):e.set(t.section,[t])}for(let[t,n]of e){let e=ZSt(n,b.length,y);for(let n=0;n<e;n++)b.push(t)}}else for(let e of g)y.set(e,b.length),b.push(e.section);let x=b.length,S=1/0,C=-1/0;for(let e of h)SQ(e)&&(S=Math.min(S,+e.startTime),C=Math.max(C,+e.endTime));let w=S<=C,T=WJ(e.title,!1,i,r,4e3,1),E=T.height>0?T.height+16:0;if(!w){let t=Math.ceil(Math.max(T.width,1)+2*a),i=Math.ceil(Math.max(T.height,1)+2*a);return{svg:vJ(`gantt`,t,i,r,n,e,gq(T,t/2,a+T.height/2,` class="pele-title" font-weight="var(--_tw)"`)),width:t,height:i,links:[]}}let D=/* @__PURE__ */ new Map,O=0;for(let e of v.keys()){let t=WJ(e,!1,i,c,180);D.set(e,t),O=Math.max(O,t.width)}let k=e.axisFormat||(e.dateFormat===`D`?`%d`:xQ(t,`axisFormat`)??`%Y-%m-%d`),A=e=>vQ(k,new Date(e)),j=Math.max(i.width(A(S),l,0),i.width(A(C),l,0)),M=a+(bQ(t,`leftPadding`,0,2e3)??Math.max(O>0?O+24:0,j/2)),N=bQ(t,`rightPadding`,0,2e3)??Math.max(16,j/2),P=qJ(n,bQ(t,`useWidth`,100,2e4)??KSt,280),F=Math.max(qSt,P-M-N-a),ee=M+F,te=C>S?F/(C-S):0,I=e=>te===0?M+F/2:M+(e-S)*te,ne=Math.round(l*1.75),re=bQ(t,`topPadding`,0,2e3),ie=bQ(t,`gridLineStartPadding`,0,2e3),ae=a+E+(m?ne:0),L=Math.max(ae,re??0),oe=re!==void 0&&ie!==void 0?Math.max(0,Math.min(re-ie,L-ae)):0,se=Math.max(x,1)*d,ce=L+se,le=[],ue=ee+N;for(let e of g){let t=XSt(e.task,i,s),n=y.get(e);if(!SQ(e)){let r=M+yQ+t.width/2;ue=Math.max(ue,r+t.width/2),le.push({task:e,label:t,row:n,x0:NaN,x1:NaN,labelX:r,inside:!1});continue}let r=I(+e.startTime),a=Math.max(I(+(e.renderEndTime??e.endTime)),r+(e.milestone?0:2));if(e.milestone){let t=r+(I(+e.endTime)-r)/2;r=t-u/2,a=t+u/2}let o=!e.milestone&&t.width+2*yQ<=a-r,c=(r+a)/2;if(!o){let e=a+yQ+t.width<=ee+N,n=r-yQ-t.width>=M;c=e||!n?a+yQ+t.width/2:r-yQ-t.width/2,ue=Math.max(ue,c+t.width/2)}le.push({task:e,label:t,row:n,x0:r,x1:a,labelX:c,inside:o})}let de=e.tickInterval||xQ(t,`tickInterval`)||``,fe=e.weekday??xQ(t,`weekday`)??`sunday`,pe=Math.max(2,Math.min(10,Math.floor(F/(j+24)))),me=HSt(de,fe,S,C,Math.ceil(F/3))??zSt(S,C,pe),he=``,ge=``,_e=``,ve=-1/0,ye=``,be=ce+ne/2+2,xe=L-oe-ne/2-2;for(let e of me){let t=I(e);he+=`M${K(t)},${K(L-oe)}V${K(ce)}`;let n=A(e),r=i.width(n,l,0);if(t-r/2<ve+8||n===ye)continue;ve=t+r/2,ye=n,ue=Math.max(ue,ve);let a=`text-anchor="middle">${pq(n)}</text>`;ge+=`<text x="${K(t)}" y="${K(be+l*.35)}" ${a}`,m&&(_e+=`<text x="${K(t)}" y="${K(xe+l*.35)}" ${a}`)}let Se=``,Ce=``,we=[],Te=ce+ne+4,Ee=Math.round(s*1.5);for(let e of[..._].sort((e,t)=>+e.startTime-t.startTime)){let t=I(+e.startTime),n=XSt(e.task,i,s),r=Math.max(a+n.width/2,t),o=0;for(;o<we.length&&r-n.width/2<we[o]+8;)o++;we[o]=r+n.width/2,ue=Math.max(ue,we[o]),Se+=`<path class="pele-vert" data-id="${mq(e.id)}" d="M${K(t)},${K(L-oe)}V${K(ce)}"/>`,Ce+=gq(n,r,Te+o*Ee+Ee/2,` class="pele-vert-label" data-id="${mq(e.id)}"`)}let De=Math.ceil(Math.max(ue,a+T.width)+a),Oe=Math.ceil(ce+ne+(we.length>0?4+we.length*Ee:0)+a),ke=``,Ae=``;for(let e=0;e<x;){let t=b[e],r=e+1;for(;r<x&&b[r]===t;)r++;let i=v.get(t)%f,o=L+e*d,s=(r-e)*d;(v.size>1||t!==``)&&(ke+=`<rect class="pele-section pele-section-${i}" x="0" y="${K(o)}" width="${De}" height="${K(s)}" fill="${i%2==0?`var(--_s)`:`none`}"/>`);let c=D.get(t);Ae+=gq(c,a+8+c.width/2,o+s/2,` class="pele-section-label" data-id="${mq(t)}"`,n.icons),e=r}let je=``;if((e.excludes.length>0||e.includes.length>0)&&+Lxt(new Date(S),6,`y`)>C){let t,n,r=()=>{if(!t||!n)return;let e=new Date(t);e.setHours(0,0,0,0);let r=new Date(n);r.setHours(23,59,59,999);let i=Math.max(M,I(+e)),a=Math.min(ee,I(+r));a>i&&(je+=`<rect x="${K(i)}" y="${K(L)}" width="${K(a-i)}" height="${K(se)}"/>`),t=n=void 0};for(let i=new Date(S);+i<=C;i=qZ(i,1))e.isInvalidDate(i)?(t??=i,n=i):r();r()}let Me=[],Ne=``;for(let t of le){let r=t.task,i=L+t.row*d+d/2,a=r.active?`active`:r.done?`done`:``,o=`pele-task`;a&&(o+=` pele-`+a),r.crit&&(o+=` pele-crit`),r.milestone&&(o+=` pele-milestone`),r.classes.includes(`clickable`)&&(o+=` pele-clickable`);let s=``,c=``;if(Number.isNaN(t.x0))o+=` pele-unscheduled`,c=` fill="var(--_m)"`;else{let e=r.crit?pJ:`var(--_c)`,n=a===`done`?`fill="var(--_a)"`:a===`active`?`fill="${e}" fill-opacity="0.25"`:`fill="${e}"`,o=`stroke="${a===`done`&&!r.crit?`var(--_b)`:e}"`;if(r.milestone){let e=(t.x0+t.x1)/2,r=u/2;s=`<path d="M${K(e)},${K(i-r)}L${K(e+r)},${K(i)}L${K(e)},${K(i+r)}L${K(e-r)},${K(i)}Z" ${n} ${o} stroke-linejoin="round"/>`}else s=`<rect x="${K(t.x0)}" y="${K(i-u/2)}" width="${K(t.x1-t.x0)}" height="${K(u)}" rx="${fJ}" ${n} ${o}/>`;t.inside?c=a===``?` fill="var(--_bg)"`:``:a===`done`&&(c=` fill="var(--_m)"`)}let l=s+gq(t.label,t.labelX,i,` class="pele-label"${c}`),f=e.links.get(r.id);f!==void 0&&(l=Tq(l,f,r.id,Me,n)),Ne+=`<g class="${o}" data-id="${mq(r.id)}">${l}</g>`}let Pe=``;if(e.todayMarker!==`off`&&o>=S&&o<=C&&C>S){let t=I(o),n=L-oe,r=e.todayMarker?mJ(e.todayMarker.split(`,`)).line:``;Pe=`<g class="pele-today"><path d="M${K(t)},${K(n)}V${K(ce)}" fill="none" stroke="var(--_c)" stroke-width="2"${r}/>`+(r?``:`<path d="M${K(t-4)},${K(n-5)}H${K(t+4)}L${K(t)},${K(n+1)}Z" fill="var(--_c)"/>`)+`</g>`}let Fe=`M${K(M)},${K(ce)}H${K(ee)}`+(m?`M${K(M)},${K(L-oe)}H${K(ee)}`:``);return{svg:vJ(`gantt`,De,Oe,r,n,e,gq(T,De/2,a+T.height/2,` class="pele-title" font-weight="var(--_tw)"`)+(ke?`<g class="pele-sections">${ke}</g>`:``)+(je?`<g class="pele-excluded" fill="var(--_a)">${je}</g>`:``)+`<g class="pele-grid" fill="none"><path d="${he}" stroke="var(--_b)" stroke-dasharray="1 3"/><path d="${Fe}" stroke="var(--_b)"/></g>`+(Se?`<g class="pele-verts" fill="none" stroke="var(--_l)" stroke-width="1.5" stroke-dasharray="4 3">${Se}</g>`:``)+Pe+`<g class="pele-tasks" font-size="${K(s)}">${Ne}</g><g class="pele-section-labels" font-size="${K(c)}">${Ae}</g><g class="pele-axis" font-size="${l}" fill="var(--_m)">${ge}${_e}</g>`+(Ce?`<g class="pele-vert-labels" font-size="${K(s)}">${Ce}</g>`:``)),width:De,height:Oe,links:Me}}var $St={type:`gantt`,parse(e,t,n){let r=new bSt;n&&(r.title=n);let i=t.gantt?.displayMode;return typeof i==`string`&&(r.displayMode=i),FSt(e,r),r},render:QSt},CQ={NORMAL:0,REVERSE:1,HIGHLIGHT:2,MERGE:3,CHERRY_PICK:4};function wQ(e){throw new NK(e,`semantic`,{type:`gitGraph`})}function eCt(e){return e===`REVERSE`?CQ.REVERSE:e===`HIGHLIGHT`?CQ.HIGHLIGHT:CQ.NORMAL}function tCt(e,t){e.dir&&t.setDirection(e.dir);for(let n of e.statements)nCt(n,t)}function nCt(e,t){switch(e.$type){case`Commit`:t.commit({id:e.id,msg:e.message??``,type:e.type===void 0?CQ.NORMAL:eCt(e.type),tags:e.tags??void 0});break;case`Branch`:t.branch({name:e.name,order:e.order??0});break;case`Merge`:t.merge({branch:e.branch,id:e.id??``,type:e.type===void 0?void 0:eCt(e.type),tags:e.tags??void 0});break;case`Checkout`:t.checkout(e.branch);break;case`CherryPicking`:t.cherryPick({id:e.id,targetId:``,tags:e.tags?.length===0?void 0:e.tags,parent:e.parent})}}function rCt(e,t,n){let r=t.gitGraph,i=typeof r?.mainBranchName==`string`?r.mainBranchName:`main`,a=typeof r?.mainBranchOrder==`number`?r.mainBranchOrder:0,o=/* @__PURE__ */ new Map,s=/* @__PURE__ */ new Map([[i,null]]),c=/* @__PURE__ */ new Map([[i,a]]),l=[],u=null,d=i,f=`LR`,p=0,m=()=>{for(let e=p+1;;e+=2654435761){let t=`${p}-${(Math.imul(e,2654435761)>>>0).toString(16).padStart(8,`0`).slice(0,7)}`;if(!o.has(t))return t}},h=e=>{u=e,o.set(e.id,e),s.set(d,e.id)},g=e=>{s.has(e)||wQ(`Trying to checkout branch which is not yet created. (Help try using "branch ${e}")`),d=e;let t=s.get(e);u=t?o.get(t)??null:null};tCt(e,{setDirection(e){f=e},commit({msg:e,id:t,type:n,tags:r}){let i={id:t||m(),message:e,seq:p++,type:n??CQ.NORMAL,tags:r?[...r]:[],parents:u===null?[]:[u.id],branch:d};o.has(i.id)&&l.push(`Commit ID ${i.id} already exists`),h(i)},branch({name:e,order:t}){s.has(e)&&wQ(`Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ${e}")`),s.set(e,u===null?null:u.id),c.set(e,t),g(e)},merge({branch:e,id:t,type:n,tags:r}){let i=s.get(d),a=s.get(e),c=i?o.get(i):void 0,l=a?o.get(a):void 0;c&&l&&c.branch===e&&wQ(`Cannot merge branch '${e}' into itself.`),d===e&&wQ(`Incorrect usage of "merge". Cannot merge a branch to itself`),c===void 0&&wQ(`Incorrect usage of "merge". Current branch (${d})has no commits`),s.has(e)||wQ(`Incorrect usage of "merge". Branch to be merged (${e}) does not exist`),l===void 0&&wQ(`Incorrect usage of "merge". Branch to be merged (${e}) has no commits`),c===l&&wQ(`Incorrect usage of "merge". Both branches have same head`),t&&o.has(t)&&wQ(`Incorrect usage of "merge". Commit with id:${t} already exists, use different custom id`),h({id:t||m(),message:`merged branch ${e} into ${d}`,seq:p++,parents:u===null?[]:[u.id,a||``],branch:d,type:CQ.MERGE,customType:n,customId:!!t,tags:r?[...r]:[]})},cherryPick({id:e,targetId:t,tags:n,parent:r}){let i=e?o.get(e):void 0;if(i===void 0&&wQ(`Incorrect usage of "cherryPick". Source commit id should exist and provided`),r&&!i.parents.includes(r)&&wQ(`Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit.`),i.type===CQ.MERGE&&!r&&wQ(`Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified.`),t&&o.has(t))return;i.branch===d&&wQ(`Incorrect usage of "cherryPick". Source commit is already on current branch`);let a=s.get(d);a&&o.has(a)||wQ(`Incorrect usage of "cherry-pick". Current branch (${d})has no commits`),h({id:m(),message:`cherry-picked ${i.message} into ${d}`,seq:p++,parents:u===null?[]:[u.id,i.id],branch:d,type:CQ.CHERRY_PICK,tags:n?n.filter(Boolean):[`cherry-pick:${i.id}${i.type===CQ.MERGE?`|parent:${r}`:``}`]})},checkout:g});let _=[...c].map(([e,t],n)=>({name:e,order:t??parseFloat(`0.${n}`)})).sort((e,t)=>e.order-t.order).map(e=>e.name);return{type:`gitGraph`,title:e.title||n,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,``):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
|
|
1019
|
-
`):void 0,direction:f,commits:o,branches:s,lanes:_,currentBranch:d,head:u,warnings:l}}var iCt={name:`REFERENCE`,pattern:/\w([-\./\w]*[-\w])?/y},aCt=[iCt];function TQ(e){return{name:e,pattern:e,longer:aCt}}var oCt=[TQ(`cherry-pick`),{name:`gitGraph:`,pattern:`gitGraph:`},TQ(`HIGHLIGHT`),{...
|
|
1020
|
-
`,s=0),s+=e}o+=a}return EQ(o,t,n,r,i)}var OQ=7,dCt=44,fCt=44,kQ=36,AQ=8,jQ=20,MQ=20,NQ=7,pCt=6,PQ=Math.SQRT1_2,mCt=[`normal`,`reverse`,`highlight`,`merge`,`cherry-pick`];function FQ(e,t,n){let r=e.gitGraph?.[t];return typeof r==`boolean`?r:n}function hCt(e){return NQ+4+e.width+6}function gCt(e,t,n,r){let i=`cx="${K(t)}" cy="${K(n)}"`;if(e===CQ.HIGHLIGHT)return`<rect x="${K(t-OQ-1)}" y="${K(n-OQ-1)}" width="${2*OQ+2}" height="${2*OQ+2}" rx="2" fill="${r}"/>`;if(e===CQ.MERGE)return`<circle ${i} r="${OQ-1}" fill="var(--_bg)" stroke="${r}" stroke-width="2"/><circle ${i} r="2.5" fill="${r}"/>`;let a=`<circle ${i} r="${OQ}" fill="${r}"/>`;return e===CQ.REVERSE?a+`<path d="M${K(t-3)},${K(n-3)}l6,6M${K(t-3)},${K(n+3)}l6,-6" fill="none" stroke="var(--_bg)" stroke-width="1.5" stroke-linecap="round"/>`:e===CQ.CHERRY_PICK?a+`<path d="M${K(t-2.6)},${K(n+1)}L${K(t+.8)},${K(n-4.2)}L${K(t+2.6)},${K(n+1)}" fill="none" stroke="var(--_bg)" stroke-linejoin="round"/><circle cx="${K(t-2.6)}" cy="${K(n+2.2)}" r="1.8" fill="var(--_bg)"/><circle cx="${K(t+2.6)}" cy="${K(n+2.2)}" r="1.8" fill="var(--_bg)"/>`:a}function _Ct(e,t,n){return e.direction===`LR`?
|
|
1021
|
-
`):void 0}}var xCt=[
|
|
1022
|
-
`,a),l===-1&&(l=i))}else s>a?(c=2,l=s+1):s===a?(c=3,l=a+1):(c=5,l=o);t.push(c),n.push(a),r.push(l),a=l}return t.push(1,0),n.push(i,i),r.push(i,i),{types:t,starts:n,ends:r}}var IQ=`'SPACELINE', 'NL', 'EOF'`;function ACt(e,t){let{types:n,starts:r,ends:i}=kCt(e),a=0,o=t=>{throw FK(`ishikawa`,e,r[a],`Expecting ${t}, got '${DCt[n[a]]}'`)};if(n[a]===2){for(a++;n[a]===2||n[a]===3;)a++;n[a]!==4&&o(`'SPACELINE', 'NL', 'ISHIKAWA'`)}else n[a]!==4&&o(`'SPACELINE', 'ISHIKAWA'`);for(a++,n[a]===3&&a++;;){let s=n[a];if(s===6||s===5&&n[a+1]===6){let c=s===6?a:a+1;a=c+1,n[a]!==2&&n[a]!==3&&n[a]!==1&&o(IQ),t.addNode(s===6?0:i[c-1]-r[c-1],e.slice(r[c],i[c]).trim())}else s===2||s===5?(a++,n[a]!==2&&n[a]!==3&&n[a]!==1&&o(s===5?`${IQ}, 'TEXT'`:IQ)):o(`'SPACELINE', 'SPACELIST', 'TEXT'`);for(a++;n[a]===3||n[a]===1;)a++;if(n[a]===0)return}}var LQ=.5,RQ=Math.hypot(LQ,1),jCt=14,MCt=6,NCt=8,PCt=22,FCt=18,zQ=5,ICt=26,LCt=34,RCt=28,zCt=10,BCt=5;function VCt(e,t,n,r,i){let a=
|
|
1018
|
+
`,o));break}case 3:d===125?(a=0,o++):s(7,o,l(`}`,o));break;case 4:d===34?(a=0,o++):s(9,o,l(`"`,o));break;case 5:if(d===40){let e=c(OSt);e>=0?(a=0,o=e):(a=6,o++)}else s(10,o,l(`(`,o));break;case 6:d===41?(a=0,o++):s(11,o,l(`)`,o));break;case 7:if(eq(d))a=0,o++;else{let n=o+1;for(;n<t&&!eq(e.charCodeAt(n));)n++;s(12,o,n)}}}return n.push(0),r.push(``),i.push(t),{types:n,texts:r,starts:i}}var NSt=[`monday`,`tuesday`,`wednesday`,`thursday`,`friday`,`saturday`,`sunday`],PSt=`'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'`,tQ=/* @__PURE__ */ new Uint8Array(39);for(let e=22;e<=30;e++)tQ[e]=1;for(let e of[38,8,14,15,16,17,18,20,19,21,32,3,5,7,34,35,12])tQ[e]=1;function FSt(e,t){let{types:n,texts:r,starts:i}=MSt(e),a=0,o=t=>{let r=n[a];throw FK(`gantt`,e,i[a],`Expecting ${t}, got '${r===0?`1`:xSt[r]}'`)},s=(e=``)=>{tQ[n[a]]!==1&&o(PSt+e)};for(n[a]!==13&&o(`'gantt'`),a++;;){let e=n[a],i=r[a];switch(tQ[e]!==1&&o(PSt),a++,e){case 38:if(n[a]===0)return;s();break;case 8:break;case 14:s(),t.setDateFormat(i.slice(11));break;case 15:s(),t.enableInclusiveEndDates();break;case 16:s(),t.TopAxis();break;case 17:s(),t.setAxisFormat(i.slice(11));break;case 18:s(),t.setTickInterval(i.slice(13));break;case 20:s(),t.setExcludes(i.slice(9));break;case 19:s(),t.setIncludes(i.slice(9));break;case 21:s(),t.setTodayMarker(i.slice(12));break;case 29:s(),t.setWeekend(`friday`);break;case 30:s(),t.setWeekend(`saturday`);break;case 32:s(),t.setDiagramTitle(i.slice(6));break;case 3:{n[a]!==4&&o(`'acc_title_value'`);let e=r[a++];s(),t.setAccTitle(e.trim());break}case 5:{n[a]!==6&&o(`'acc_descr_value'`);let e=r[a++];s(),t.setAccDescription(e.trim());break}case 7:s(),t.setAccDescription(i.trim());break;case 34:s(),t.addSection(i.slice(8));break;case 35:{n[a]!==36&&o(`'taskData'`);let e=r[a++];s(),t.addTask(i,e);break}case 12:{let e,c=null,l;n[a]===10?(e=r[a++],n[a]===11&&(c=r[a++]),n[a]===9?(l=r[a++],s()):s(c===null?`, 'callbackargs', 'href'`:`, 'href'`)):n[a]===9?(l=r[a++],n[a]===10?(e=r[a++],n[a]===11?(c=r[a++],s()):s(`, 'callbackargs'`)):s(`, 'callbackname'`)):o(`'callbackname', 'href'`),e!==void 0&&t.setClickEvent(i,e,c),l!==void 0&&t.setLink(i,l);break}default:s(),t.setWeekday(NSt[e-22])}}}var nQ=1e3,rQ=60*nQ,iQ=60*rQ,aQ=24*iQ,oQ=7*aQ,sQ=30*aQ,cQ=365*aQ;function lQ(e){e.setHours(0,0,0,0)}function uQ(e){return{floor(t){t.setDate(t.getDate()-(t.getDay()+7-e)%7),lQ(t)},offset:(e,t)=>e.setDate(e.getDate()+t*7),cycle:1/0,ms:oQ}}var dQ={millisecond:{floor:()=>{},offset:(e,t)=>e.setTime(+e+t),cycle:1/0,ms:1},second:{floor:e=>e.setTime(+e-e.getMilliseconds()),offset:(e,t)=>e.setTime(+e+t*nQ),field:e=>e.getUTCSeconds(),cycle:60,ms:nQ},minute:{floor:e=>e.setTime(+e-e.getMilliseconds()-e.getSeconds()*nQ),offset:(e,t)=>e.setTime(+e+t*rQ),field:e=>e.getMinutes(),cycle:60,ms:rQ},hour:{floor:e=>e.setTime(+e-e.getMilliseconds()-e.getSeconds()*nQ-e.getMinutes()*rQ),offset:(e,t)=>e.setTime(+e+t*iQ),field:e=>e.getHours(),cycle:24,ms:iQ},day:{floor:lQ,offset:(e,t)=>e.setDate(e.getDate()+t),field:e=>e.getDate()-1,cycle:31,ms:aQ},month:{floor(e){e.setDate(1),lQ(e)},offset:(e,t)=>e.setMonth(e.getMonth()+t),field:e=>e.getMonth(),cycle:12,ms:sQ},year:{floor(e){e.setMonth(0,1),lQ(e)},offset:(e,t)=>e.setFullYear(e.getFullYear()+t),cycle:1/0,ms:cQ}};function fQ(e,t,n){return Math.floor((+t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*rQ)/n)}function ISt(e,t){return(e%t+t)%t}function pQ(e,t,n){let r=e===`week`?uQ(n):dQ[e];if(t<=1)return r;if(e===`millisecond`)return{...r,floor:e=>e.setTime(Math.floor(+e/t)*t),offset:(e,n)=>e.setTime(+e+n*t)};if(e===`year`)return{...r,floor(e){e.setFullYear(Math.floor(e.getFullYear()/t)*t),r.floor(e)},offset:(e,n)=>e.setFullYear(e.getFullYear()+n*t)};if(e===`week`){let e=/* @__PURE__ */ new Date(0);return r.floor(e),{...r,floor(n){r.floor(n),r.offset(n,-ISt(fQ(e,n,oQ),t))},offset:(e,n)=>r.offset(e,n*t)}}let i=r.field,a=e=>i(e)%t===0;return{...r,floor(e){for(r.floor(e);Number.isFinite(+e)&&!a(e);r.floor(e))e.setTime(e-1)},offset(e,t){for(let n=0;n<t&&Number.isFinite(+e);n++)do r.offset(e,1);while(Number.isFinite(+e)&&!a(e))}}}function LSt(e,t,n,r){let i=/* @__PURE__ */ new Date(t-1);e.floor(i),e.offset(i,1),e.floor(i);let a=[],o=-1/0;for(;+i<=n&&+i>o;){if(a.length>=r)return;o=+i,a.push(o),e.offset(i,1),e.floor(i)}return a}function RSt(e,t,n){let r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/10**i;return 10**i*(a>=Math.sqrt(50)?10:a>=Math.sqrt(10)?5:a>=Math.SQRT2?2:1)}var mQ=[[`second`,1,nQ],[`second`,5,5*nQ],[`second`,15,15*nQ],[`second`,30,30*nQ],[`minute`,1,rQ],[`minute`,5,5*rQ],[`minute`,15,15*rQ],[`minute`,30,30*rQ],[`hour`,1,iQ],[`hour`,3,3*iQ],[`hour`,6,6*iQ],[`hour`,12,12*iQ],[`day`,1,aQ],[`day`,2,2*aQ],[`week`,1,oQ],[`month`,1,sQ],[`month`,3,3*sQ],[`year`,1,cQ]];function zSt(e,t,n){let r=(t-e)/n,i=0;for(;i<mQ.length&&mQ[i][2]<=r;)i++;let a;if(i===mQ.length)a=pQ(`year`,Math.max(1,RSt(e/cQ,t/cQ,n)),0);else if(i===0)a=pQ(`millisecond`,Math.max(RSt(e,t,n),1),0);else{let[e,t]=mQ[r/mQ[i-1][2]<mQ[i][2]/r?i-1:i];a=pQ(e,t,0)}return LSt(a,e,t,4*n+8)??[]}var BSt=/^([1-9]\d*)(millisecond|second|minute|hour|day|week|month)$/,VSt=[`sunday`,`monday`,`tuesday`,`wednesday`,`thursday`,`friday`,`saturday`];function HSt(e,t,n,r,i){let a=BSt.exec(e);if(!a)return;let o=parseInt(a[1],10),s=a[2],c=pQ(s,o,Math.max(0,VSt.indexOf(t)));if(!((r-n)/(Math.min(o,c.cycle)*c.ms)>i))return LSt(c,n,r,i)}function hQ(e,t,n){let r=e<0?`-`:``,i=String(r?-e:e);return r+(i.length<n?t.repeat(n-i.length)+i:i)}function gQ(e,t){let n=/* @__PURE__ */ new Date(+e);return t.floor(n),n}function USt(e,t){let n=uQ(t),r=gQ(e,dQ.year);return fQ(gQ(/* @__PURE__ */ new Date(r-1),n),gQ(e,n),oQ)}function _Q(e){let t=uQ(4),n=e.getDay(),r=gQ(n>=4||n===0?e:/* @__PURE__ */ new Date(e-1),t);return n>=4||n===0||(t.offset(r,1),t.floor(r)),r}var WSt=/* @__PURE__ */ new Map([[`-`,``],[`_`,` `],[`0`,`0`]]);function vQ(e,t){let n=``,r=0,i=e.length;for(let a=0;a<i;a++){if(e.charCodeAt(a)!==37)continue;n+=e.slice(r,a);let i=e.charAt(++a),o=WSt.get(i);o===void 0?o=i===`e`?` `:`0`:i=e.charAt(++a),n+=GSt(i,t,o),r=a+1}return n+e.slice(r)}function GSt(e,t,n){switch(e){case`a`:return UZ[t.getDay()].slice(0,3);case`A`:return UZ[t.getDay()];case`b`:return HZ[t.getMonth()].slice(0,3);case`B`:return HZ[t.getMonth()];case`c`:return vQ(`%x, %X`,t);case`d`:case`e`:return hQ(t.getDate(),n,2);case`f`:return hQ(t.getMilliseconds(),n,3)+`000`;case`g`:return hQ(_Q(t).getFullYear()%100,n,2);case`G`:return hQ(_Q(t).getFullYear()%1e4,n,4);case`H`:return hQ(t.getHours(),n,2);case`I`:return hQ(t.getHours()%12||12,n,2);case`j`:return hQ(1+fQ(gQ(t,dQ.year),gQ(t,dQ.day),aQ),n,3);case`L`:return hQ(t.getMilliseconds(),n,3);case`m`:return hQ(t.getMonth()+1,n,2);case`M`:return hQ(t.getMinutes(),n,2);case`p`:return t.getHours()>=12?`PM`:`AM`;case`q`:return String(1+Math.floor(t.getMonth()/3));case`Q`:return String(+t);case`s`:return String(Math.floor(t/1e3));case`S`:return hQ(t.getSeconds(),n,2);case`u`:return String(t.getDay()||7);case`U`:return hQ(USt(t,0),n,2);case`V`:{let e=_Q(t),r=gQ(e,dQ.year);return hQ(fQ(gQ(r,uQ(4)),e,oQ)+ +(r.getDay()===4),n,2)}case`w`:return String(t.getDay());case`W`:return hQ(USt(t,1),n,2);case`x`:return vQ(`%-m/%-d/%Y`,t);case`X`:return vQ(`%-I:%M:%S %p`,t);case`y`:return hQ(t.getFullYear()%100,n,2);case`Y`:return hQ(t.getFullYear()%1e4,n,4);case`Z`:{let e=t.getTimezoneOffset(),n=Math.abs(e);return(e>0?`-`:`+`)+hQ(Math.floor(n/60),`0`,2)+hQ(n%60,`0`,2)}case`%`:return`%`;default:return e}}var KSt=800,qSt=240,yQ=8,JSt=/<br\s*\/?>/gi;function bQ(e,t,n,r){let i=e.gantt?.[t];return typeof i==`number`&&Number.isFinite(i)?Math.min(r,Math.max(n,i)):void 0}function xQ(e,t){let n=e.gantt?.[t];return typeof n==`string`?n:void 0}function YSt(e,t){return e.gantt?.[t]===!0}function XSt(e,t,n){let r=UJ(e.replace(JSt,` `),!1,t,n,4e3);return r.lines.length<=1?r:{...r,lines:[r.lines[0]],widths:[r.widths[0]],width:r.widths[0],height:r.lineHeight}}function SQ(e){return Number.isFinite(+e.startTime)&&Number.isFinite(+e.endTime)}function ZSt(e,t,n){let r=e.filter(SQ).sort((e,t)=>+e.startTime-t.startTime||e.order-t.order),i=[];for(let e of r){let r=+e.startTime,a=0;for(;a<i.length&&r<i[a];)a++;i[a]=+e.endTime,n.set(e,t+a)}let a=i.length;for(let r of e)n.has(r)||n.set(r,t+a++);return Math.max(a,1)}function QSt(e,t,n){let r=n.fontSize??16,i=n.measurer??fq(n.fontFamily),a=n.padding??8,o=_St(n.now),s=bQ(t,`fontSize`,4,72)??Math.round(r*.8125),c=bQ(t,`sectionFontSize`,4,72)??s,l=Math.round(r*.75),u=bQ(t,`barHeight`,4,400)??Math.round(s*1.85),d=u+(bQ(t,`barGap`,0,400)??Math.round(u/4)),f=Math.round(bQ(t,`numberSectionStyles`,1,1e3)??4),p=e.displayMode===`compact`,m=e.topAxis||YSt(t,`topAxis`),h=e.getTasks(o),g=h.filter(e=>!e.vert),_=h.filter(e=>e.vert&&SQ(e)),v=/* @__PURE__ */ new Map;for(let e of g)v.has(e.section)||v.set(e.section,v.size);let y=/* @__PURE__ */ new Map,b=[];if(p){let e=/* @__PURE__ */ new Map;for(let t of g){let n=e.get(t.section);n?n.push(t):e.set(t.section,[t])}for(let[t,n]of e){let e=ZSt(n,b.length,y);for(let n=0;n<e;n++)b.push(t)}}else for(let e of g)y.set(e,b.length),b.push(e.section);let x=b.length,S=1/0,C=-1/0;for(let e of h)SQ(e)&&(S=Math.min(S,+e.startTime),C=Math.max(C,+e.endTime));let w=S<=C,T=UJ(e.title,!1,i,r,4e3,1),E=T.height>0?T.height+16:0;if(!w){let t=Math.ceil(Math.max(T.width,1)+2*a),i=Math.ceil(Math.max(T.height,1)+2*a);return{svg:_J(`gantt`,t,i,r,n,e,gq(T,t/2,a+T.height/2,` class="pele-title" font-weight="var(--_tw)"`)),width:t,height:i,links:[]}}let D=/* @__PURE__ */ new Map,O=0;for(let e of v.keys()){let t=UJ(e,!1,i,c,180);D.set(e,t),O=Math.max(O,t.width)}let k=e.axisFormat||(e.dateFormat===`D`?`%d`:xQ(t,`axisFormat`)??`%Y-%m-%d`),A=e=>vQ(k,new Date(e)),j=Math.max(i.width(A(S),l,0),i.width(A(C),l,0)),M=a+(bQ(t,`leftPadding`,0,2e3)??Math.max(O>0?O+24:0,j/2)),N=bQ(t,`rightPadding`,0,2e3)??Math.max(16,j/2),P=KJ(n,bQ(t,`useWidth`,100,2e4)??KSt,280),F=Math.max(qSt,P-M-N-a),ee=M+F,te=C>S?F/(C-S):0,I=e=>te===0?M+F/2:M+(e-S)*te,ne=Math.round(l*1.75),re=bQ(t,`topPadding`,0,2e3),ie=bQ(t,`gridLineStartPadding`,0,2e3),ae=a+E+(m?ne:0),L=Math.max(ae,re??0),oe=re!==void 0&&ie!==void 0?Math.max(0,Math.min(re-ie,L-ae)):0,se=Math.max(x,1)*d,ce=L+se,le=[],ue=ee+N;for(let e of g){let t=XSt(e.task,i,s),n=y.get(e);if(!SQ(e)){let r=M+yQ+t.width/2;ue=Math.max(ue,r+t.width/2),le.push({task:e,label:t,row:n,x0:NaN,x1:NaN,labelX:r,inside:!1});continue}let r=I(+e.startTime),a=Math.max(I(+(e.renderEndTime??e.endTime)),r+(e.milestone?0:2));if(e.milestone){let t=r+(I(+e.endTime)-r)/2;r=t-u/2,a=t+u/2}let o=!e.milestone&&t.width+2*yQ<=a-r,c=(r+a)/2;if(!o){let e=a+yQ+t.width<=ee+N,n=r-yQ-t.width>=M;c=e||!n?a+yQ+t.width/2:r-yQ-t.width/2,ue=Math.max(ue,c+t.width/2)}le.push({task:e,label:t,row:n,x0:r,x1:a,labelX:c,inside:o})}let de=e.tickInterval||xQ(t,`tickInterval`)||``,fe=e.weekday??xQ(t,`weekday`)??`sunday`,pe=Math.max(2,Math.min(10,Math.floor(F/(j+24)))),me=HSt(de,fe,S,C,Math.ceil(F/3))??zSt(S,C,pe),he=``,ge=``,_e=``,ve=-1/0,ye=``,be=ce+ne/2+2,xe=L-oe-ne/2-2;for(let e of me){let t=I(e);he+=`M${K(t)},${K(L-oe)}V${K(ce)}`;let n=A(e),r=i.width(n,l,0);if(t-r/2<ve+8||n===ye)continue;ve=t+r/2,ye=n,ue=Math.max(ue,ve);let a=`text-anchor="middle">${pq(n)}</text>`;ge+=`<text x="${K(t)}" y="${K(be+l*.35)}" ${a}`,m&&(_e+=`<text x="${K(t)}" y="${K(xe+l*.35)}" ${a}`)}let Se=``,Ce=``,we=[],Te=ce+ne+4,Ee=Math.round(s*1.5);for(let e of[..._].sort((e,t)=>+e.startTime-t.startTime)){let t=I(+e.startTime),n=XSt(e.task,i,s),r=Math.max(a+n.width/2,t),o=0;for(;o<we.length&&r-n.width/2<we[o]+8;)o++;we[o]=r+n.width/2,ue=Math.max(ue,we[o]),Se+=`<path class="pele-vert" data-id="${mq(e.id)}" d="M${K(t)},${K(L-oe)}V${K(ce)}"/>`,Ce+=gq(n,r,Te+o*Ee+Ee/2,` class="pele-vert-label" data-id="${mq(e.id)}"`)}let De=Math.ceil(Math.max(ue,a+T.width)+a),Oe=Math.ceil(ce+ne+(we.length>0?4+we.length*Ee:0)+a),ke=``,Ae=``;for(let e=0;e<x;){let t=b[e],r=e+1;for(;r<x&&b[r]===t;)r++;let i=v.get(t)%f,o=L+e*d,s=(r-e)*d;(v.size>1||t!==``)&&(ke+=`<rect class="pele-section pele-section-${i}" x="0" y="${K(o)}" width="${De}" height="${K(s)}" fill="${i%2==0?`var(--_s)`:`none`}"/>`);let c=D.get(t);Ae+=gq(c,a+8+c.width/2,o+s/2,` class="pele-section-label" data-id="${mq(t)}"`,n.icons),e=r}let je=``;if((e.excludes.length>0||e.includes.length>0)&&+Lxt(new Date(S),6,`y`)>C){let t,n,r=()=>{if(!t||!n)return;let e=new Date(t);e.setHours(0,0,0,0);let r=new Date(n);r.setHours(23,59,59,999);let i=Math.max(M,I(+e)),a=Math.min(ee,I(+r));a>i&&(je+=`<rect x="${K(i)}" y="${K(L)}" width="${K(a-i)}" height="${K(se)}"/>`),t=n=void 0};for(let i=new Date(S);+i<=C;i=qZ(i,1))e.isInvalidDate(i)?(t??=i,n=i):r();r()}let Me=[],Ne=``;for(let t of le){let r=t.task,i=L+t.row*d+d/2,a=r.active?`active`:r.done?`done`:``,o=`pele-task`;a&&(o+=` pele-`+a),r.crit&&(o+=` pele-crit`),r.milestone&&(o+=` pele-milestone`),r.classes.includes(`clickable`)&&(o+=` pele-clickable`);let s=``,c=``;if(Number.isNaN(t.x0))o+=` pele-unscheduled`,c=` fill="var(--_m)"`;else{let e=r.crit?fJ:`var(--_c)`,n=a===`done`?`fill="var(--_a)"`:a===`active`?`fill="${e}" fill-opacity="0.25"`:`fill="${e}"`,o=`stroke="${a===`done`&&!r.crit?`var(--_b)`:e}"`;if(r.milestone){let e=(t.x0+t.x1)/2,r=u/2;s=`<path d="M${K(e)},${K(i-r)}L${K(e+r)},${K(i)}L${K(e)},${K(i+r)}L${K(e-r)},${K(i)}Z" ${n} ${o} stroke-linejoin="round"/>`}else s=`<rect x="${K(t.x0)}" y="${K(i-u/2)}" width="${K(t.x1-t.x0)}" height="${K(u)}" rx="${dJ}" ${n} ${o}/>`;t.inside?c=a===``?` fill="var(--_bg)"`:``:a===`done`&&(c=` fill="var(--_m)"`)}let l=s+gq(t.label,t.labelX,i,` class="pele-label"${c}`),f=e.links.get(r.id);f!==void 0&&(l=Tq(l,f,r.id,Me,n)),Ne+=`<g class="${o}" data-id="${mq(r.id)}">${l}</g>`}let Pe=``;if(e.todayMarker!==`off`&&o>=S&&o<=C&&C>S){let t=I(o),n=L-oe,r=e.todayMarker?pJ(e.todayMarker.split(`,`)).line:``;Pe=`<g class="pele-today"><path d="M${K(t)},${K(n)}V${K(ce)}" fill="none" stroke="var(--_c)" stroke-width="2"${r}/>`+(r?``:`<path d="M${K(t-4)},${K(n-5)}H${K(t+4)}L${K(t)},${K(n+1)}Z" fill="var(--_c)"/>`)+`</g>`}let Fe=`M${K(M)},${K(ce)}H${K(ee)}`+(m?`M${K(M)},${K(L-oe)}H${K(ee)}`:``);return{svg:_J(`gantt`,De,Oe,r,n,e,gq(T,De/2,a+T.height/2,` class="pele-title" font-weight="var(--_tw)"`)+(ke?`<g class="pele-sections">${ke}</g>`:``)+(je?`<g class="pele-excluded" fill="var(--_a)">${je}</g>`:``)+`<g class="pele-grid" fill="none"><path d="${he}" stroke="var(--_b)" stroke-dasharray="1 3"/><path d="${Fe}" stroke="var(--_b)"/></g>`+(Se?`<g class="pele-verts" fill="none" stroke="var(--_l)" stroke-width="1.5" stroke-dasharray="4 3">${Se}</g>`:``)+Pe+`<g class="pele-tasks" font-size="${K(s)}">${Ne}</g><g class="pele-section-labels" font-size="${K(c)}">${Ae}</g><g class="pele-axis" font-size="${l}" fill="var(--_m)">${ge}${_e}</g>`+(Ce?`<g class="pele-vert-labels" font-size="${K(s)}">${Ce}</g>`:``)),width:De,height:Oe,links:Me}}var $St={type:`gantt`,parse(e,t,n){let r=new bSt;n&&(r.title=n);let i=t.gantt?.displayMode;return typeof i==`string`&&(r.displayMode=i),FSt(e,r),r},render:QSt},CQ={NORMAL:0,REVERSE:1,HIGHLIGHT:2,MERGE:3,CHERRY_PICK:4};function wQ(e){throw new NK(e,`semantic`,{type:`gitGraph`})}function eCt(e){return e===`REVERSE`?CQ.REVERSE:e===`HIGHLIGHT`?CQ.HIGHLIGHT:CQ.NORMAL}function tCt(e,t){e.dir&&t.setDirection(e.dir);for(let n of e.statements)nCt(n,t)}function nCt(e,t){switch(e.$type){case`Commit`:t.commit({id:e.id,msg:e.message??``,type:e.type===void 0?CQ.NORMAL:eCt(e.type),tags:e.tags??void 0});break;case`Branch`:t.branch({name:e.name,order:e.order??0});break;case`Merge`:t.merge({branch:e.branch,id:e.id??``,type:e.type===void 0?void 0:eCt(e.type),tags:e.tags??void 0});break;case`Checkout`:t.checkout(e.branch);break;case`CherryPicking`:t.cherryPick({id:e.id,targetId:``,tags:e.tags?.length===0?void 0:e.tags,parent:e.parent})}}function rCt(e,t,n){let r=t.gitGraph,i=typeof r?.mainBranchName==`string`?r.mainBranchName:`main`,a=typeof r?.mainBranchOrder==`number`?r.mainBranchOrder:0,o=/* @__PURE__ */ new Map,s=/* @__PURE__ */ new Map([[i,null]]),c=/* @__PURE__ */ new Map([[i,a]]),l=[],u=null,d=i,f=`LR`,p=0,m=()=>{for(let e=p+1;;e+=2654435761){let t=`${p}-${(Math.imul(e,2654435761)>>>0).toString(16).padStart(8,`0`).slice(0,7)}`;if(!o.has(t))return t}},h=e=>{u=e,o.set(e.id,e),s.set(d,e.id)},g=e=>{s.has(e)||wQ(`Trying to checkout branch which is not yet created. (Help try using "branch ${e}")`),d=e;let t=s.get(e);u=t?o.get(t)??null:null};tCt(e,{setDirection(e){f=e},commit({msg:e,id:t,type:n,tags:r}){let i={id:t||m(),message:e,seq:p++,type:n??CQ.NORMAL,tags:r?[...r]:[],parents:u===null?[]:[u.id],branch:d};o.has(i.id)&&l.push(`Commit ID ${i.id} already exists`),h(i)},branch({name:e,order:t}){s.has(e)&&wQ(`Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ${e}")`),s.set(e,u===null?null:u.id),c.set(e,t),g(e)},merge({branch:e,id:t,type:n,tags:r}){let i=s.get(d),a=s.get(e),c=i?o.get(i):void 0,l=a?o.get(a):void 0;c&&l&&c.branch===e&&wQ(`Cannot merge branch '${e}' into itself.`),d===e&&wQ(`Incorrect usage of "merge". Cannot merge a branch to itself`),c===void 0&&wQ(`Incorrect usage of "merge". Current branch (${d})has no commits`),s.has(e)||wQ(`Incorrect usage of "merge". Branch to be merged (${e}) does not exist`),l===void 0&&wQ(`Incorrect usage of "merge". Branch to be merged (${e}) has no commits`),c===l&&wQ(`Incorrect usage of "merge". Both branches have same head`),t&&o.has(t)&&wQ(`Incorrect usage of "merge". Commit with id:${t} already exists, use different custom id`),h({id:t||m(),message:`merged branch ${e} into ${d}`,seq:p++,parents:u===null?[]:[u.id,a||``],branch:d,type:CQ.MERGE,customType:n,customId:!!t,tags:r?[...r]:[]})},cherryPick({id:e,targetId:t,tags:n,parent:r}){let i=e?o.get(e):void 0;if(i===void 0&&wQ(`Incorrect usage of "cherryPick". Source commit id should exist and provided`),r&&!i.parents.includes(r)&&wQ(`Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit.`),i.type===CQ.MERGE&&!r&&wQ(`Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified.`),t&&o.has(t))return;i.branch===d&&wQ(`Incorrect usage of "cherryPick". Source commit is already on current branch`);let a=s.get(d);a&&o.has(a)||wQ(`Incorrect usage of "cherry-pick". Current branch (${d})has no commits`),h({id:m(),message:`cherry-picked ${i.message} into ${d}`,seq:p++,parents:u===null?[]:[u.id,i.id],branch:d,type:CQ.CHERRY_PICK,tags:n?n.filter(Boolean):[`cherry-pick:${i.id}${i.type===CQ.MERGE?`|parent:${r}`:``}`]})},checkout:g});let _=[...c].map(([e,t],n)=>({name:e,order:t??parseFloat(`0.${n}`)})).sort((e,t)=>e.order-t.order).map(e=>e.name);return{type:`gitGraph`,title:e.title||n,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,``):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
|
|
1019
|
+
`):void 0,direction:f,commits:o,branches:s,lanes:_,currentBranch:d,head:u,warnings:l}}var iCt={name:`REFERENCE`,pattern:/\w([-\./\w]*[-\w])?/y},aCt=[iCt];function TQ(e){return{name:e,pattern:e,longer:aCt}}var oCt=[TQ(`cherry-pick`),{name:`gitGraph:`,pattern:`gitGraph:`},TQ(`HIGHLIGHT`),{...mY(`gitGraph`),longer:aCt},TQ(`checkout`),TQ(`REVERSE`),{name:`parent:`,pattern:`parent:`},TQ(`commit`),TQ(`NORMAL`),TQ(`branch`),{name:`order:`,pattern:`order:`},TQ(`switch`),{name:`type:`,pattern:`type:`},TQ(`merge`),{name:`msg:`,pattern:`msg:`},{name:`tag:`,pattern:`tag:`},{name:`id:`,pattern:`id:`},TQ(`LR`),TQ(`TB`),TQ(`BT`),{name:`:`,pattern:`:`},{...aY,opener:/[\t ]*accDescr\s*{/y},oY,sY,{name:`INT`,pattern:/0|[1-9][0-9]*(?!\.)/y},cY,lY,uY,dY,fY,pY,iCt];function sCt(e){let t=new bY(iY(e,oCt,`gitGraph`),oCt,`gitGraph`),n={$type:`GitGraph`,statements:[]},r=()=>{if(t.kind!==-1)for(t.kind!==26&&t.fail(`a line break or the end of input`);t.kind===26;)t.i++},i=()=>t.kind===31?t.take():t.kind===25?yY(t.take()):t.fail(`a branch name`),a=()=>yY(t.expect(25)),o=()=>(t.kind!==8&&t.kind!==5&&t.kind!==2&&t.fail(`NORMAL, REVERSE, or HIGHLIGHT`),t.take());for(;t.kind===26;)t.i++;if(!t.accept(1)){t.expect(3);let e=t.kinds[t.i+1];(t.kind===17||t.kind===18||t.kind===19)&&e===20?(n.$type=`Direction`,n.dir=t.take(),t.i++):t.accept(20)}for(;t.kind!==-1;)switch(t.kind){case 26:t.i++;break;case 21:n.accDescr=vY(t.take()),r();break;case 22:n.accTitle=_Y(t.take()),r();break;case 23:n.title=gY(t.take()),r();break;case 7:{t.i++;let e={$type:`Commit`,tags:[]};for(;;)if(t.accept(16))e.id=a();else if(t.accept(15))e.tags.push(a());else if(t.accept(12))e.type=o();else if(t.accept(14)||t.kinds[t.i]===25)e.message=a();else break;r(),n.statements.push(e);break}case 9:{t.i++;let e={$type:`Branch`,name:i()};t.accept(10)&&(e.order=parseInt(t.expect(24))),r(),n.statements.push(e);break}case 13:{t.i++;let e={$type:`Merge`,branch:i(),tags:[]};for(;;)if(t.accept(16))e.id=a();else if(t.accept(15))e.tags.push(a());else if(t.accept(12))e.type=o();else break;r(),n.statements.push(e);break}case 4:case 11:{t.i++;let e={$type:`Checkout`,branch:i()};r(),n.statements.push(e);break}case 0:{t.i++;let e={$type:`CherryPicking`,tags:[]};for(;;)if(t.accept(16))e.id=a();else if(t.accept(15))e.tags.push(a());else if(t.accept(6))e.parent=a();else break;r(),n.statements.push(e);break}default:t.fail(`a statement, a title, or a line break`)}return n}var cCt=/<(?!br\s*\/?>)/gi,lCt=/:fa-/g,uCt=/<br\s*\/?>|fl°°?\w+¶ß|&#?\w+;|[\ud800-\udbff][\udc00-\udfff]|[\s\S]/gi;function EQ(e,t,n,r,i=0){let a=e;return a!==void 0&&(a.includes(`<`)&&(a=a.replace(cCt,`<`)),a.includes(`:fa-`)&&(a=a.replace(lCt,`:fa-`))),UJ(a,!1,t,n,r,i)}function DQ(e,t,n,r,i=0){let a=EQ(e,t,n,r,i);if(e===void 0||a.width<=r)return a;let o=``,s=0;for(let a of e.match(uCt)??[]){if(a.trim()===``||a.length>2&&a[0]===`<`)s=0;else{let e=t.width(a.length>2?`x`:a,n,i);s>0&&s+e>r&&(o+=`
|
|
1020
|
+
`,s=0),s+=e}o+=a}return EQ(o,t,n,r,i)}var OQ=7,dCt=44,fCt=44,kQ=36,AQ=8,jQ=20,MQ=20,NQ=7,pCt=6,PQ=Math.SQRT1_2,mCt=[`normal`,`reverse`,`highlight`,`merge`,`cherry-pick`];function FQ(e,t,n){let r=e.gitGraph?.[t];return typeof r==`boolean`?r:n}function hCt(e){return NQ+4+e.width+6}function gCt(e,t,n,r){let i=`cx="${K(t)}" cy="${K(n)}"`;if(e===CQ.HIGHLIGHT)return`<rect x="${K(t-OQ-1)}" y="${K(n-OQ-1)}" width="${2*OQ+2}" height="${2*OQ+2}" rx="2" fill="${r}"/>`;if(e===CQ.MERGE)return`<circle ${i} r="${OQ-1}" fill="var(--_bg)" stroke="${r}" stroke-width="2"/><circle ${i} r="2.5" fill="${r}"/>`;let a=`<circle ${i} r="${OQ}" fill="${r}"/>`;return e===CQ.REVERSE?a+`<path d="M${K(t-3)},${K(n-3)}l6,6M${K(t-3)},${K(n+3)}l6,-6" fill="none" stroke="var(--_bg)" stroke-width="1.5" stroke-linecap="round"/>`:e===CQ.CHERRY_PICK?a+`<path d="M${K(t-2.6)},${K(n+1)}L${K(t+.8)},${K(n-4.2)}L${K(t+2.6)},${K(n+1)}" fill="none" stroke="var(--_bg)" stroke-linejoin="round"/><circle cx="${K(t-2.6)}" cy="${K(n+2.2)}" r="1.8" fill="var(--_bg)"/><circle cx="${K(t+2.6)}" cy="${K(n+2.2)}" r="1.8" fill="var(--_bg)"/>`:a}function _Ct(e,t,n){return e.direction===`LR`?qJ(n,r=>vCt(e,t,n,r?`TB`:`LR`)):vCt(e,t,n,e.direction)}function vCt(e,t,n,r){let i=n.fontSize??16,a=Math.round(i*.75),o=n.measurer??fq(n.fontFamily),s=n.padding??8,c=FQ(t,`showBranches`,!0),l=FQ(t,`showCommitLabel`,!0),u=FQ(t,`rotateCommitLabel`,!0),d=FQ(t,`parallelCommits`,!1),f=r!==`LR`,p=r===`BT`,m=/* @__PURE__ */ new Map;e.lanes.forEach((e,t)=>m.set(e,t));let h=e.lanes.length,g=Math.round(i*.875),_=e.lanes.map(e=>EQ(c?e:``,o,g,4e3)),v=[],y=/* @__PURE__ */ new Map;for(let t of[...e.commits.values()].sort((e,t)=>e.seq-t.seq)){let e=l&&t.type!==CQ.CHERRY_PICK&&(t.type!==CQ.MERGE||t.customId===!0),n=[];for(let e of t.tags){let t=EQ(e,o,a,4e3);t.lines.length>0&&n.push(t)}let r={commit:t,index:v.length,lane:m.get(t.branch)??0,m:0,label:e?EQ(t.id,o,a,4e3):void 0,tags:n};v.push(r),y.set(t.id,r)}let b=new Float64Array(v.length),x=new Float64Array(v.length),S=new Float64Array(h).fill(OQ),C=new Float64Array(h).fill(OQ);v.forEach((e,t)=>{let{label:n,tags:r}=e,i=0,a=0;for(let e of r){let t=hCt(e);f?(i=Math.max(i,e.height),a+=t+4):(i=Math.max(i,t),a+=e.height+3)}let o=0,s=0;n!==void 0&&n.lines.length>0&&(u?s=3+PQ*(n.width+n.height):(o=f?n.height:n.width,s=6+(f?n.width:n.height))),b[t]=Math.max(OQ,i/2,o/2),x[t]=i/2;let c=OQ+(r.length>0?pCt+a:0),l=OQ+s,d=e.lane;S[d]=Math.max(S[d],f?l:c),C[d]=Math.max(C[d],f?c:l)});let w=new Float64Array(v.length);f||v.forEach((e,t)=>{if(x[t]!==0)for(let n of e.commit.parents){let r=y.get(n);r!==void 0&&r.lane<e.lane&&(w[t]=x[t]+4)}});let T=(e,t)=>Math.max(dCt,b[e]+b[t]+AQ,w[t]>0?b[e]+kQ+w[t]:0);v.forEach((e,t)=>{if(!d){e.m=t===0?0:v[t-1].m+T(t-1,t);return}let n=0;for(let r of e.commit.parents){let e=y.get(r);e===void 0||e.index>=t||(n=Math.max(n,e.m+T(e.index,t)))}e.m=n});let E=0;for(let e of v)E=Math.max(E,e.m);let D=new Float64Array(h);for(let e=0;e<h;e++){let t=_[e],n=t.lines.length===0?0:f?t.width/2+8:t.height/2+2;S[e]=Math.max(S[e],n),C[e]=Math.max(C[e],n),e>0&&(D[e]=D[e-1]+Math.max(fCt,C[e-1]+S[e]+AQ))}let O=(e,t)=>f?t:e,k=(e,t)=>f?p?-e:e:t,A=(e,t)=>`${K(O(e,t))},${K(k(e,t))}`,j=1/0,M=1/0,N=-1/0,P=-1/0,F=(e,t,n,r)=>{e<j&&(j=e),t<M&&(M=t),n>N&&(N=n),r>P&&(P=r)},ee=``;if(c)for(let t=0;t<h;t++){let n=_[t],r=hJ(t),i=D[t],a=n.width+16,o=n.height+4,s=n.lines.length===0?-jQ:-jQ-(f?o:a),c=O(s+(f?o:a)/2,i),l=k(s+(f?o:a)/2,i);F(O(-jQ,i),k(-jQ,i),O(-jQ,i),k(-jQ,i)),F(O(E+MQ,i),k(E+MQ,i),O(E+MQ,i),k(E+MQ,i)),ee+=`<g class="pele-branch" data-id="${mq(e.lanes[t])}"><path class="pele-lane" d="M${A(-jQ,i)}L${A(E+MQ,i)}" stroke="${r}" stroke-dasharray="2 4"/>`,n.lines.length>0&&(F(c-a/2,l-o/2,c+a/2,l+o/2),ee+=`<rect x="${K(c-a/2)}" y="${K(l-o/2)}" width="${K(a)}" height="${K(o)}" rx="${dJ}" fill="${r}"/>`+gq(n,c,l,` class="pele-label" fill="var(--_bg)"`)),ee+=`</g>`}let te=Array.from({length:h},()=>[]);for(let e of v)te[e.lane].push(e.m);if(d)for(let e of te)e.sort((e,t)=>e-t);let I=(e,t,n)=>{let r=te[e],i=0,a=r.length;for(;i<a;){let e=i+a>>1;r[e]<=t?i=e+1:a=e}return i<r.length&&r[i]<n},ne=``,re=``;for(let e of v){let{commit:t}=e,n=D[e.lane],r=e.m;for(let i=0;i<t.parents.length;i++){let a=y.get(t.parents[i]);if(a===void 0||a===e)continue;let o=D[a.lane],s=a.m;if(a.lane===e.lane){re+=`<path class="pele-edge" d="M${A(s,o)}L${A(r,n)}" stroke="${hJ(e.lane)}"/>`;continue}let c=i>0&&t.type===CQ.MERGE,l=i>0&&!c,u=`M${A(s,o)}`;if(r<=s){let e=(s+r)/2;u+=`C${A(e,o)} ${A(e,n)} ${A(r,n)}`}else if(!c&&!I(e.lane,s,r)){let e=Math.min(kQ,r-s);u+=`C${A(s+e/2,o)} ${A(s+e/2,n)} ${A(s+e,n)}L${A(r,n)}`}else{let t=a.lane<e.lane&&r-w[e.index]>s?r-w[e.index]:r,i=Math.min(kQ,t-s),l=o;(!c||I(a.lane,s,r))&&(l=o>n?n+C[e.lane]+AQ/2:n-S[e.lane]-AQ/2,i=Math.min(kQ,(t-s)/2),u+=`C${A(s+i/2,o)} ${A(s+i/2,l)} ${A(s+i,l)}`),u+=`L${A(t-i,l)}C${A(t-i/2,l)} ${A(t-i/2,n)} ${A(t,n)}`,t<r&&(u+=`L${A(r,n)}`)}ne+=`<path class="pele-edge${c?` pele-edge-merge`:l?` pele-edge-cherry-pick`:``}" d="${u}" stroke="${hJ(c?a.lane:e.lane)}"${l?` stroke-dasharray="4 3"`:``}/>`}}let ie=``;for(let e of v){let{commit:t,label:n,tags:r}=e,i=O(e.m,D[e.lane]),a=k(e.m,D[e.lane]),o=t.customType??t.type;F(i-OQ-1,a-OQ-1,i+OQ+1,a+OQ+1);let s=t.type<CQ.MERGE&&t.message!==``?`<title>${mq(t.message)}</title>`:``;if(s+=gCt(o,i,a,hJ(e.lane)),n!==void 0&&n.lines.length>0){let e=n.width,t=n.height,r=(n,r)=>`<rect x="${K(n-e/2-2)}" y="${K(r-t/2+2)}" width="${K(e+4)}" height="${K(t-4)}" rx="3" fill="var(--_bg)"/>`;if(u){let o=PQ*t/2,c=f?i-OQ-3-o:i+3,l=f?a:a+OQ+3+o,u=PQ*e+o;F(c-u,p?l-u:l-o,c+o,p?l+o:l+u),s+=`<g class="pele-commit-label" transform="rotate(${p?45:-45} ${K(c)} ${K(l)})">`+r(c-e/2,l)+gq(n,c-e/2,l,``)+`</g>`}else{let o=f?i-OQ-6-e/2:i,c=f?a:a+OQ+6+t/2;F(o-e/2,c-t/2,o+e/2,c+t/2),s+=`<g class="pele-commit-label">${r(o,c)}${gq(n,o,c,``)}</g>`}}let c=OQ+pCt;for(let e=f?0:r.length-1;e>=0&&e<r.length;e+=f?1:-1){let t=r[e],n=hCt(t),o=t.height,l=f?i+c:i-n/2,u=f?a:a-c-o/2;c+=f?n+4:o+3,F(l,u-o/2,l+n,u+o/2),s+=`<g class="pele-tag"><path d="M${K(l)},${K(u)}L${K(l+NQ)},${K(u-o/2)}H${K(l+n)}V${K(u+o/2)}H${K(l+NQ)}Z" fill="var(--_s)" stroke="var(--_b)" stroke-linejoin="round"/><circle cx="${K(l+NQ)}" cy="${K(u)}" r="1.5" fill="var(--_b)"/>`+gq(t,l+NQ+4+t.width/2,u,` fill="var(--_fg)"`)+`</g>`}let l=t.type===CQ.MERGE&&o!==CQ.MERGE?` pele-commit-merge`:``;ie+=`<g class="pele-commit pele-commit-${mCt[o]??mCt[0]}${l}" data-id="${mq(t.id)}">${s}</g>`}j>N&&F(0,0,0,0);let ae=UJ(e.title,!1,o,i,4e3,1),L=ae.height>0?ae.height+16:0,oe=Math.max(N-j,ae.width),se=Math.ceil(oe+2*s),ce=Math.ceil(P-M+L+2*s),le=s-j+(oe-(N-j))/2,ue=s+L-M;return{svg:_J(`gitGraph`,se,ce,i,n,e,gq(ae,se/2,s+ae.height/2,` class="pele-title" font-weight="var(--_tw)"`)+`<g transform="translate(${K(le)},${K(ue)})">`+(ee?`<g class="pele-branches" fill="none" font-size="${g}">${ee}</g>`:``)+(ne||re?`<g class="pele-edges" fill="none" stroke-width="2" stroke-linecap="round">${ne}${re}</g>`:``)+(ie?`<g class="pele-commits" font-size="${a}" fill="var(--_m)">${ie}</g>`:``)+`</g>`),width:se,height:ce,links:[]}}var yCt={type:`gitGraph`,parse:(e,t,n)=>rCt(sCt(e),t,n),render:_Ct};function bCt(e,t){return{type:`info`,title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,``):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
|
|
1021
|
+
`):void 0}}var xCt=[mY(`showInfo`),mY(`info`),aY,oY,sY,lY,uY,dY,fY,pY];function SCt(e){let t=new bY(iY(e,xCt,`info`),xCt,`info`),n={$type:`Info`};for(;t.kind===5;)t.i++;for(t.expect(1);t.kind===5;)t.i++;if(t.accept(0))for(;t.kind===5;)t.i++;for(;t.kind!==-1;){let e=t.kind;if(e===2?n.accDescr=vY(t.take()):e===3?n.accTitle=_Y(t.take()):e===4?n.title=gY(t.take()):t.fail(`a title or the end of input`),t.kind===-1)break;for(t.kind!==5&&t.fail(`a line break or the end of input`);t.kind===5;)t.i++}return n}var CCt=`1.7.0`;function wCt(e,t,n){let r=n.fontSize??16,i=n.measurer??fq(n.fontFamily),a=n.padding??8,o=UJ(e.title,!1,i,r,4e3,1),s=o.height>0?o.height+8:0,c=UJ(`Pele v${CCt}`,!1,i,r,4e3),l=Math.ceil(Math.max(o.width,c.width)+2*a),u=Math.ceil(s+c.height+2*a);return{svg:_J(`info`,l,u,r,n,e,gq(o,l/2,a+o.height/2,` class="pele-title" font-weight="var(--_tw)"`)+gq(c,l/2,a+s+c.height/2,` class="pele-version" fill="var(--_m)"`)),width:l,height:u,links:[]}}var TCt={type:`info`,parse:(e,t,n)=>bCt(SCt(e),n),render:wCt},ECt=class{type=`ishikawa`;title;root;stack=[];baseLevel;addNode(e,t){let n={text:t,children:[]};if(!this.root){this.root=n,this.stack=[{level:0,node:n}];return}this.baseLevel??=e;let r=Math.max(e-this.baseLevel+1,1),i=this.stack;for(;i.length>1&&i[i.length-1].level>=r;)i.pop();i[i.length-1].node.children.push(n),i.push({level:r,node:n})}},DCt=[`$end`,`EOF`,`SPACELINE`,`NL`,`ISHIKAWA`,`SPACELIST`,`TEXT`];function OCt(e,t){let n=0;for(;n<13;){let r=e.charCodeAt(t+n),i=`ishikawa-beta`.charCodeAt(n);if(r!==i&&(r+32!==i||r<65||r>90))break;n++}return n===13&&!aq(e.charCodeAt(t+13))?13:n>=8&&!aq(e.charCodeAt(t+8))?8:0}function kCt(e){let t=[],n=[],r=[],i=e.length,a=0;for(;a<i;){let o=a,s=-1;for(;o<i&&eq(e.charCodeAt(o));)e.charCodeAt(o)===10&&(s=o),o++;let c,l;if(e.charCodeAt(o)===37&&e.charCodeAt(o+1)===37)for(c=2,l=o+2;l<i;){let t=e.charCodeAt(l);if(t===10||t===13||t===8232||t===8233)break;l++}else if(o===a){let t=OCt(e,a);t>0?(c=4,l=a+t):(c=6,l=e.indexOf(`
|
|
1022
|
+
`,a),l===-1&&(l=i))}else s>a?(c=2,l=s+1):s===a?(c=3,l=a+1):(c=5,l=o);t.push(c),n.push(a),r.push(l),a=l}return t.push(1,0),n.push(i,i),r.push(i,i),{types:t,starts:n,ends:r}}var IQ=`'SPACELINE', 'NL', 'EOF'`;function ACt(e,t){let{types:n,starts:r,ends:i}=kCt(e),a=0,o=t=>{throw FK(`ishikawa`,e,r[a],`Expecting ${t}, got '${DCt[n[a]]}'`)};if(n[a]===2){for(a++;n[a]===2||n[a]===3;)a++;n[a]!==4&&o(`'SPACELINE', 'NL', 'ISHIKAWA'`)}else n[a]!==4&&o(`'SPACELINE', 'ISHIKAWA'`);for(a++,n[a]===3&&a++;;){let s=n[a];if(s===6||s===5&&n[a+1]===6){let c=s===6?a:a+1;a=c+1,n[a]!==2&&n[a]!==3&&n[a]!==1&&o(IQ),t.addNode(s===6?0:i[c-1]-r[c-1],e.slice(r[c],i[c]).trim())}else s===2||s===5?(a++,n[a]!==2&&n[a]!==3&&n[a]!==1&&o(s===5?`${IQ}, 'TEXT'`:IQ)):o(`'SPACELINE', 'SPACELIST', 'TEXT'`);for(a++;n[a]===3||n[a]===1;)a++;if(n[a]===0)return}}var LQ=.5,RQ=Math.hypot(LQ,1),jCt=14,MCt=6,NCt=8,PCt=22,FCt=18,zQ=5,ICt=26,LCt=34,RCt=28,zCt=10,BCt=5;function VCt(e,t,n,r,i){let a=UJ(e.text,!1,n,r,180),o=Math.round(i*1.5),s=[],c=[],l=[],u=(e,n,r)=>{let i=e.length;for(let a=i-1;a>=0;a--)l.push({node:e[t?i-1-a:a],depth:n,parent:r,slot:a,bone:-1})};for(u(e.children,2,-1);l.length>0;){let e=l.pop();if(e.bone!==-1){c.push(e.bone);continue}let t=s.length;s.push({label:UJ(e.node.text,!1,n,i,200),depth:e.depth,parent:e.parent,slot:e.slot,kids:e.node.children.length,rise:0,at:0,textEnd:0}),e.depth%2==0?c.push(t):(e.bone=t,l.push(e)),u(e.node.children,e.depth+1,t)}let d=jCt;for(let e of c){let t=Math.max(s[e].label.height,o)+MCt;s[e].rise=d+t/2,d+=t}let f=a.width+2*zCt,p=f/2;for(let e of s){let t=e.parent===-1?void 0:s[e.parent];e.depth%2==0?(e.at=t?t.at:0,e.textEnd=e.at-(e.kids>0?(e.kids+1)*PCt:FCt)-zQ):(e.at=t.at-(t.kids-e.slot)*PCt,e.textEnd=e.at-zQ),p=Math.max(p,e.label.width-e.textEnd)}return{node:e,label:a,boxW:f,boxH:a.height+2*BCt,bones:s,rise:d+NCt,reach:p}}function HCt(e,t,n){return qJ(n,r=>UCt(e,t,n,r))}function UCt(e,t,n,r){let i=n.fontSize??16,a=Math.round(i*.875),o=n.measurer??fq(n.fontFamily),s=n.padding??8;if(r)return WCt(e,n);let c=e.root,l=UJ(e.title,!1,o,i,4e3,1),u=l.height>0?l.height+12:0,d=``,f=0,p=0,m=0,h=0;if(c){let e=UJ(c.text,!1,o,i,200,1),t=Math.max(e.height+24,48),n=e.width+24+t/2,r=c.children.map((e,t)=>VCt(e,t%2==0,o,i,a));for(let e of r)e.rise=Math.max(e.rise,t/2+14);let s=[],l=-LCt;for(let e=0;e<r.length;e+=2){if(e>0){let t=0;for(let n=0;n<2;n++){let i=r[e-2+n],a=r[e+n];i&&(t=Math.max(t,i.reach+(a?a.boxW/2:0)))}l-=t+ICt}s.push(l,l)}let u=r.length>0?l-RCt:-LCt;p=n,f=u,m=-t/2,h=t/2;let g=``;r.forEach((e,t)=>{let n=t%2==0?-1:1,r=s[t],i=(e,t)=>r+e-t*LQ,o=i(0,e.rise),c=n*e.rise,l=rJ-1,u=`M${K(r-LQ/RQ*l)},${K(n*l/RQ)}L${K(o)},${K(c)}`,d=``;for(let t of e.bones){let r=n*t.rise;if(t.depth%2==0)u+=`M${K(i(t.at,t.rise))},${K(r)}H${K(i(t.textEnd+zQ,t.rise))}`;else{let a=e.bones[t.parent].rise;u+=`M${K(i(t.at,a))},${K(n*a)}L${K(i(t.at,t.rise))},${K(r)}`}let a=i(t.textEnd,t.rise);d+=gq(t.label,a-t.label.width/2,r,t.depth>2?` fill="var(--_m)"`:``),f=Math.min(f,a-t.label.width)}let _=c+n*(e.boxH/2);f=Math.min(f,o-e.boxW/2),p=Math.max(p,o+e.boxW/2),m=Math.min(m,_-e.boxH/2),h=Math.max(h,_+e.boxH/2),g+=`<g class="pele-ishikawa-category" data-id="${mq(e.node.text)}"><path class="pele-ishikawa-bones" d="${u}" fill="none" stroke="var(--_l)"/>`+cJ(`arrow_point`,r,0,LQ/RQ,-n/RQ,`var(--_l)`)+`<rect x="${K(o-e.boxW/2)}" y="${K(_-e.boxH/2)}" width="${K(e.boxW)}" height="${K(e.boxH)}" rx="${dJ}" fill="var(--_s)" stroke="var(--_b)"/>`+gq(e.label,o,_,` class="pele-label"`)+(d?`<g class="pele-ishikawa-causes" font-size="${a}">${d}</g>`:``)+`</g>`});let _=t/2;d=`<path class="pele-ishikawa-spine" d="M${K(u)},0H${K(-(rJ-1))}" fill="none" stroke="var(--_l)"/>`+cJ(`arrow_point`,0,0,1,0,`var(--_l)`)+g+`<g class="pele-ishikawa-head" data-id="${mq(c.text)}"><path d="M0,${K(-_)}H${K(n-_)}A${K(_)},${K(_)} 0 0 1 ${K(n-_)},${K(_)}H0Z" fill="var(--_s)" stroke="var(--_b)" stroke-linejoin="round"/>`+gq(e,12+e.width/2,0,` class="pele-label" font-weight="var(--_hw)"`)+`</g>`}let g=Math.max(p-f,l.width),_=Math.ceil(g+2*s),v=Math.ceil(h-m+u+2*s),y=s+(g-(p-f))/2-f,b=s+u-m;return{svg:_J(`ishikawa`,_,v,i,n,{},gq(l,_/2,s+l.height/2,` class="pele-title" font-weight="var(--_tw)"`)+(d?`<g transform="translate(${K(y)},${K(b)})">${d}</g>`:``)),width:_,height:v,links:[]}}function WCt(e,t){let n=t.fontSize??16,r=Math.round(n*.875),i=t.measurer??fq(t.fontFamily),a=t.padding??8,o=Math.max(140,(t.maxWidth??320)-2*a),s=UJ(e.title,!1,i,n,GJ(t),1),c=[],l=e.root?[{node:e.root,depth:0,parent:-1}]:[],u=0;for(;l.length;){let e=l.pop(),t=c.length;c.push({...e,x:0,y:0,w:0,h:0}),u=Math.max(u,e.depth);for(let n=e.node.children.length-1;n>=0;n--)l.push({node:e.node.children[n],depth:e.depth+1,parent:t})}let d=Math.min(20,Math.max(2,(o-120)/Math.max(1,u))),f=a+(s.height?s.height+12:0),p=s.width,m=``,h=``;for(let e of c){e.x=a+e.depth*d;let t=Math.max(60,o-e.depth*d-20);e.label=ZY(UJ(e.node.text,!1,i,e.depth<2?n:r,t,+(e.depth<2)),i,t),e.w=e.label.width+20,e.h=e.label.height+12,e.y=f,f+=e.h+12,p=Math.max(p,e.x-a+e.w);let s=e.depth<2;if(m+=`<g class="pele-node ${e.depth===0?`pele-ishikawa-head`:e.depth===1?`pele-ishikawa-category`:`pele-ishikawa-cause`}" data-id="${mq(e.node.text)}">`+(s?`<rect x="${K(e.x)}" y="${K(e.y)}" width="${K(e.w)}" height="${K(e.h)}" rx="${e.depth===0?12:4}" fill="var(--_s)" stroke="var(--_b)"/>`:``)+gq(e.label,e.x+e.w/2,e.y+e.h/2,` class="pele-label"${e.depth<2?` font-weight="var(--_hw)"`:``}${e.depth>1?` font-size="${r}"`:``}`)+`</g>`,e.parent>=0){let t=c[e.parent],n=t.x+d/2;h+=`<path class="pele-edge" d="M${K(n)},${K(t.y+t.h)}V${K(e.y+e.h/2)}H${K(e.x)}" fill="none" stroke="var(--_b)"/>`}}let g=Math.ceil(p+2*a),_=Math.ceil(Math.max(a+s.height,f-12)+a);return{svg:_J(`ishikawa`,g,_,n,t,{},gq(s,g/2,a+s.height/2,` class="pele-title" font-weight="var(--_tw)"`)+h+m),width:g,height:_,links:[]}}var GCt={type:`ishikawa`,parse(e,t,n){let r=new ECt;return r.title=n,ACt(e,r),r},render:HCt};function BQ(e){let t=/* @__PURE__ */ new Set;for(let n of e)for(let e of n.people)t.add(e);return[...t].sort()}var KCt=class{type=`journey`;title;accTitle;accDescr;sections=[];tasks=[];currentSection=``;setDiagramTitle(e){this.title=e}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,``)}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
1023
1023
|
`)}addSection(e){this.currentSection=e,this.sections.push(e)}addTask(e,t){let n=t.substring(1).split(`:`),r=n.length===1?[]:n[1].split(`,`).map(e=>e.trim());this.tasks.push({task:e,score:Number(n[0]),people:r,section:this.currentSection})}getActors(){return BQ(this.tasks)}};function VQ(e,t){let n=e.indexOf(`
|
|
1024
|
-
`,t);return n===-1?e.length:n}function HQ(e,t,n){for(let r=0;r<n.length;r++)if((e.charCodeAt(t+r)|32)!==n.charCodeAt(r))return!1;return!0}function qCt(e,t){let n=e.length,r=t;for(;r<n;){let t=e.charCodeAt(r);if(t===37&&e.charCodeAt(r+1)!==123)r=VQ(e,r);else if(t!==125&&e.charCodeAt(r+1)===37&&e.charCodeAt(r+2)===37)r=VQ(e,r+3);else{if(t===10)return r;if(eq(t))do r++;while(r<n&&eq(e.charCodeAt(r)));else if(t===35)r=VQ(e,r);else return r}}return r}function UQ(e,t){let n=t;for(;eq(e.charCodeAt(n));)n++;return n}function JCt(e,t,n,r){let i=HQ(e,t,`accdescr`);if(!i&&!HQ(e,t,`acctitle`))return t;let a=e.length,o=UQ(e,t+8),s=e.charCodeAt(o),c=(t,r,i)=>{n.types.push(t),n.texts.push(e.slice(r,i)),n.starts.push(r)};if(s===58){o=UQ(e,o+1);let n=VQ(e,o);return c(i?r+2:r,t,o),c(i?r+3:r+1,o,n),n}if(!i||s!==123)return t;for(o=UQ(e,o+1);e.charCodeAt(o)!==125;){let t=e.indexOf(`}`,o);if(t===-1&&(t=a),c(r+4,o,t),o===a)return a;o=t}return o+1}var YCt=[`$end`,`EOF`,`INVALID`,`NEWLINE`,`journey`,`title`,`acc_title`,`acc_title_value`,`acc_descr`,`acc_descr_value`,`acc_descr_multiline_value`,`section`,`taskName`,`taskData`,`:`];function WQ(e,t,n){let r=e.length,i=t;for(;i<r;i++){let t=e.charCodeAt(i);if(t===35||t===10||t===59||n&&t===58)break}return i}function XCt(e){let t=e.length,n=[],r=[],i=[],a={types:n,texts:r,starts:i},o=0,s=(t,a)=>{n.push(t),r.push(e.slice(o,a)),i.push(o),o=a};for(;o=qCt(e,o),!(o>=t);){let t=e.charCodeAt(o),n=o+1;if(t===10){for(;e.charCodeAt(n)===10;)n++;s(3,n)}else HQ(e,o,`journey`)&&!aq(e.charCodeAt(o+7))?s(4,o+7):HQ(e,o,`title`)&&eq(e.charCodeAt(o+5))&&(n=WQ(e,o+6,!1),n>o+6)?s(5,n):(n=JCt(e,o,a,6),n===o?HQ(e,o,`section`)&&eq(e.charCodeAt(o+7))&&(n=WQ(e,o+8,!0),n>o+8)?s(11,n):t===58?(n=WQ(e,o+1,!1),s(n>o+1?13:14,n>o+1?n:o+1)):t===59?s(2,o+1):s(12,WQ(e,o+1,!0)):o=n)}return(i.length===0||i[i.length-1]<t)&&s(1,t),s(0,t),a}var ZCt=`'EOF', 'SPACE', 'NEWLINE', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'section', 'taskName'`;function QCt(e,t){let{types:n,texts:r,starts:i}=XCt(e),a=(t,r)=>{let a=n[t]===0?`1`:YCt[n[t]];throw FK(`journey`,e,i[t],`Expecting ${r}, got '${a}'`)};n[0]!==4&&a(0,`'journey'`);for(let e=1;;e++){let i=r[e];switch(n[e]){case 3:break;case 5:t.setDiagramTitle(i.substring(6));break;case 6:t.setAccTitle(r[++e].trim());break;case 8:t.setAccDescription(r[++e].trim());break;case 10:t.setAccDescription(i.trim());break;case 11:t.addSection(i.substring(8));break;case 12:n[++e]!==13&&a(e,`'taskData'`),t.addTask(i,r[e]);break;case 1:return;default:a(e,ZCt)}}}var GQ=10,KQ=8,$Ct=124,ewt=200,qQ=12,twt=6,JQ=24,YQ=26,XQ=11,ZQ=5,nwt=13,rwt=20,iwt=`<circle cx="-3.6" cy="-2.8" r="1.3"/><circle cx="3.6" cy="-2.8" r="1.3"/>`,awt={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 owt(e,t,n){return`<g class="pele-face pele-face-${n}" transform="translate(${K(e)},${K(t)})"><circle r="${XQ}" fill="var(--_bg)" stroke="var(--_l)"/><g fill="var(--_l)">${iwt}</g><path d="${awt[n]}" fill="none" stroke="var(--_l)" stroke-linecap="round"/></g>`}function swt(e,t,n){return
|
|
1024
|
+
`,t);return n===-1?e.length:n}function HQ(e,t,n){for(let r=0;r<n.length;r++)if((e.charCodeAt(t+r)|32)!==n.charCodeAt(r))return!1;return!0}function qCt(e,t){let n=e.length,r=t;for(;r<n;){let t=e.charCodeAt(r);if(t===37&&e.charCodeAt(r+1)!==123)r=VQ(e,r);else if(t!==125&&e.charCodeAt(r+1)===37&&e.charCodeAt(r+2)===37)r=VQ(e,r+3);else{if(t===10)return r;if(eq(t))do r++;while(r<n&&eq(e.charCodeAt(r)));else if(t===35)r=VQ(e,r);else return r}}return r}function UQ(e,t){let n=t;for(;eq(e.charCodeAt(n));)n++;return n}function JCt(e,t,n,r){let i=HQ(e,t,`accdescr`);if(!i&&!HQ(e,t,`acctitle`))return t;let a=e.length,o=UQ(e,t+8),s=e.charCodeAt(o),c=(t,r,i)=>{n.types.push(t),n.texts.push(e.slice(r,i)),n.starts.push(r)};if(s===58){o=UQ(e,o+1);let n=VQ(e,o);return c(i?r+2:r,t,o),c(i?r+3:r+1,o,n),n}if(!i||s!==123)return t;for(o=UQ(e,o+1);e.charCodeAt(o)!==125;){let t=e.indexOf(`}`,o);if(t===-1&&(t=a),c(r+4,o,t),o===a)return a;o=t}return o+1}var YCt=[`$end`,`EOF`,`INVALID`,`NEWLINE`,`journey`,`title`,`acc_title`,`acc_title_value`,`acc_descr`,`acc_descr_value`,`acc_descr_multiline_value`,`section`,`taskName`,`taskData`,`:`];function WQ(e,t,n){let r=e.length,i=t;for(;i<r;i++){let t=e.charCodeAt(i);if(t===35||t===10||t===59||n&&t===58)break}return i}function XCt(e){let t=e.length,n=[],r=[],i=[],a={types:n,texts:r,starts:i},o=0,s=(t,a)=>{n.push(t),r.push(e.slice(o,a)),i.push(o),o=a};for(;o=qCt(e,o),!(o>=t);){let t=e.charCodeAt(o),n=o+1;if(t===10){for(;e.charCodeAt(n)===10;)n++;s(3,n)}else HQ(e,o,`journey`)&&!aq(e.charCodeAt(o+7))?s(4,o+7):HQ(e,o,`title`)&&eq(e.charCodeAt(o+5))&&(n=WQ(e,o+6,!1),n>o+6)?s(5,n):(n=JCt(e,o,a,6),n===o?HQ(e,o,`section`)&&eq(e.charCodeAt(o+7))&&(n=WQ(e,o+8,!0),n>o+8)?s(11,n):t===58?(n=WQ(e,o+1,!1),s(n>o+1?13:14,n>o+1?n:o+1)):t===59?s(2,o+1):s(12,WQ(e,o+1,!0)):o=n)}return(i.length===0||i[i.length-1]<t)&&s(1,t),s(0,t),a}var ZCt=`'EOF', 'SPACE', 'NEWLINE', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'section', 'taskName'`;function QCt(e,t){let{types:n,texts:r,starts:i}=XCt(e),a=(t,r)=>{let a=n[t]===0?`1`:YCt[n[t]];throw FK(`journey`,e,i[t],`Expecting ${r}, got '${a}'`)};n[0]!==4&&a(0,`'journey'`);for(let e=1;;e++){let i=r[e];switch(n[e]){case 3:break;case 5:t.setDiagramTitle(i.substring(6));break;case 6:t.setAccTitle(r[++e].trim());break;case 8:t.setAccDescription(r[++e].trim());break;case 10:t.setAccDescription(i.trim());break;case 11:t.addSection(i.substring(8));break;case 12:n[++e]!==13&&a(e,`'taskData'`),t.addTask(i,r[e]);break;case 1:return;default:a(e,ZCt)}}}var GQ=10,KQ=8,$Ct=124,ewt=200,qQ=12,twt=6,JQ=24,YQ=26,XQ=11,ZQ=5,nwt=13,rwt=20,iwt=`<circle cx="-3.6" cy="-2.8" r="1.3"/><circle cx="3.6" cy="-2.8" r="1.3"/>`,awt={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 owt(e,t,n){return`<g class="pele-face pele-face-${n}" transform="translate(${K(e)},${K(t)})"><circle r="${XQ}" fill="var(--_bg)" stroke="var(--_l)"/><g fill="var(--_l)">${iwt}</g><path d="${awt[n]}" fill="none" stroke="var(--_l)" stroke-linecap="round"/></g>`}function swt(e,t,n){return qJ(n,r=>cwt(e,t,n,r))}function cwt(e,t,n,r){let i=n.fontSize??16,a=Math.round(i*.875),o=Math.round(i*.75),s=n.measurer??fq(n.fontFamily),c=n.padding??8;if(r)return lwt(e,n);let l=e.tasks,u=l.length,d=BQ(l).filter(e=>e!==``),f=/* @__PURE__ */ new Map;d.forEach((e,t)=>f.set(e,t));let p=$Ct,m=l.map(e=>EQ(e.task,s,a,p)),h=0;for(let e of m)h=Math.max(h,e.width);h>p&&(p=Math.min(Math.ceil(h),ewt),m=l.map(e=>DQ(e.task,s,a,p)));let g=p+2*GQ,_=g+qQ,v=u>0?u*_-qQ:0,y=Math.round(a*1.5),b=Math.max(v,240),x=[],S=0,C=0,w=0;for(let e of d){let t=DQ(e,s,a,b-2*ZQ-6),n=2*ZQ+6+t.width;w>0&&w+n>b&&(w=0,C+=4);let r=w>0?x[x.length-1].y:C,i=Math.max(t.height,y);x.push({name:e,label:t,x:w,y:r,h:i}),w+=n,S=Math.max(S,w),C=Math.max(C,r+i),w+=rwt}let T=u>0?JQ+v:0,E=DQ(e.title,s,i,Math.max(T,320),1),D=E.height>0?E.height+16:0,O=Math.max(T,E.width,u>0?JQ+S:0),k=c+(O-T)/2+JQ,A=c+D,j=[],M=0;for(let e=0;e<u;){let t=e+1;for(;t<u&&l[t].section===l[e].section;)t++;let n;l[e].section!==``&&(n=DQ(l[e].section,s,a,(t-e)*_-qQ-2*GQ,1),M=Math.max(M,Math.max(n.height,y)+2*twt)),j.push({start:e,count:t-e,label:n}),e=t}let N=y;for(let e of m)N=Math.max(N,e.height);let P=d.length>0?2*ZQ+6:0,F=N+P+2*KQ,ee=A+(M>0?M+twt:0),te=ee+F+XQ+16,I=te+4*YQ,ne=k+v,re=``,ie=A;if(u>0){let e=``,t=``;for(let n=5;n>=1;n--){let r=te+(5-n)*YQ;e+=`M${K(k-6)},${K(r)}H${K(ne)}`,t+=`<text x="${K(k-12)}" y="${K(r+o*.35)}">${n}</text>`}re+=`<path class="pele-grid" d="${e}" fill="none" stroke="var(--_a)"/><g class="pele-scale" font-size="${o}" text-anchor="end" fill="var(--_m)">${t}</g>`;let n=``,r=``,i=``,s=[];l.forEach((e,t)=>{let o=k+t*_,c=o+g/2,l=e.score,u=te+(5-(Number.isNaN(l)?3:Math.min(5,Math.max(1,l))))*YQ;n+=`${t===0?`M`:`L`}${K(c)},${K(u)}`,r+=`M${K(c)},${K(ee+F)}V${K(u-XQ)}`,i+=owt(c,u,l>3?`happy`:l<3?`sad`:`neutral`);let d=``,p=e.people.filter(e=>e!==``),h=Math.min(nwt,(g-2*GQ-2*ZQ)/Math.max(p.length-1,1));p.forEach((e,t)=>{d+=`<circle class="pele-actor" cx="${K(c+(t-(p.length-1)/2)*h)}" cy="${K(ee+F-KQ-ZQ)}" r="${ZQ}" fill="${hJ(f.get(e)??0)}" stroke="var(--_s)"><title>${mq(e)}</title></circle>`}),s.push(`<g class="pele-node pele-task" data-id="${mq(e.task.trim())}"><rect x="${K(o)}" y="${K(ee)}" width="${K(g)}" height="${K(F)}" rx="${dJ}" fill="var(--_s)" stroke="var(--_b)"/>`+gq(m[t],c,ee+KQ+N/2,` font-size="${a}"`)+d+`</g>`)}),re+=`<path class="pele-stems" d="${r}" fill="none" stroke="var(--_b)" stroke-dasharray="2 3"/>`+(u>1?`<path class="pele-edge" d="${n}" fill="none" stroke="var(--_l)" stroke-linejoin="round"/>`:``)+i;for(let e of j){let t=s.slice(e.start,e.start+e.count).join(``);if(!e.label){re+=t;continue}let n=k+e.start*_,r=e.count*_-qQ;re+=`<g class="pele-cluster pele-section" data-id="${mq(l[e.start].section.trim())}"><rect x="${K(n)}" y="${K(A)}" width="${K(r)}" height="${K(M)}" rx="${dJ}" fill="var(--_a)"/>`+gq(e.label,n+r/2,A+M/2,` font-size="${a}" font-weight="var(--_hw)"`)+t+`</g>`}if(ie=I+XQ,x.length>0){let e=k+(v-S)/2,t=ie+16,n=``;for(let r of x){let i=t+r.y+r.h/2;n+=`<g class="pele-legend-item" data-id="${mq(r.name)}"><circle cx="${K(e+r.x+ZQ)}" cy="${K(i)}" r="${ZQ}" fill="${hJ(f.get(r.name)??0)}"/>`+gq(r.label,e+r.x+2*ZQ+6+r.label.width/2,i,``)+`</g>`}re+=`<g class="pele-legend" font-size="${a}">${n}</g>`,ie=t+C}}let ae=Math.ceil(O+2*c),L=Math.ceil(Math.max(ie,c)+c);return{svg:_J(`journey`,ae,L,i,n,e,gq(E,c+O/2,c+E.height/2,` class="pele-title" font-weight="var(--_tw)"`)+re),width:ae,height:L,links:[]}}function lwt(e,t){let n=t.fontSize??16,r=Math.round(n*.875),i=t.measurer??fq(t.fontFamily),a=t.padding??8,o=Math.max(140,(t.maxWidth??320)-2*a),s=DQ(e.title,i,n,o,1),c=BQ(e.tasks).filter(e=>e!==``),l=new Map(c.map((e,t)=>[e,t])),u=a+(s.height?s.height+16:0),d,f=``,p=s.width;e.tasks.forEach((t,s)=>{if(t.section!==d){d=t.section;let e=DQ(d,i,n,o-16,1);e.height&&(f+=gq(e,a+8+e.width/2,u+e.height/2,` class="pele-cluster-label" font-weight="var(--_hw)"`),p=Math.max(p,e.width+16),u+=e.height+8)}let c=DQ(t.task,i,r,o-72),m=t.people.filter(e=>e!==``).map(e=>({name:e,label:DQ(e,i,r,o-44)})),h=Math.max(c.height,42),g=2*KQ+h;for(let e of m)g+=Math.max(16,e.label.height)+4;let _=Math.max(o,c.width+72);f+=`<g class="pele-node pele-journey-step" data-id="${s}"><rect x="${K(a)}" y="${K(u)}" width="${K(_)}" height="${K(g)}" rx="${dJ}" fill="var(--_s)" stroke="var(--_b)"/>`,f+=gq(c,a+GQ+c.width/2,u+KQ+c.height/2,` class="pele-label"`);let v=a+_-28;f+=owt(v,u+KQ+XQ,t.score>3?`happy`:t.score<3?`sad`:`neutral`),Number.isNaN(t.score)||(f+=`<text class="pele-journey-score" x="${K(v)}" y="${K(u+KQ+2*XQ+r)}" font-size="${r}" text-anchor="middle">${K(Math.min(5,Math.max(1,t.score)))}</text>`);let y=u+KQ+h+4;for(let e of m){let t=Math.max(16,e.label.height);f+=`<circle class="pele-actor" cx="${K(a+16)}" cy="${K(y+t/2)}" r="${ZQ}" fill="${hJ(l.get(e.name))}"/>`+gq(e.label,a+28+e.label.width/2,y+t/2,` class="pele-journey-actor" font-size="${r}"`),y+=t+4}f+=`</g>`,u+=g,s+1<e.tasks.length&&(f+=`<path class="pele-edge" d="M${K(a+_/2)},${K(u)}v16" fill="none" stroke="var(--_l)"/>`),u+=16,p=Math.max(p,_)});let m=Math.ceil(p+2*a),h=Math.ceil(Math.max(a+s.height,u-(e.tasks.length?16:0))+a);return{svg:_J(`journey`,m,h,n,t,e,gq(s,m/2,a+s.height/2,` class="pele-title" font-weight="var(--_tw)"`)+f),width:m,height:h,links:[]}}var uwt={type:`journey`,parse(e,t,n){let r=new KCt;return r.title=n,QCt(e,r),r},render:swt},dwt=[`1`,`INVALID`,`SPACELINE`,`NL`,`EOF`,``,`SPACELIST`,`ICON`,`CLASS`,`NODE_DSTART`,`NODE_ID`,`NODE_DESCR`,`NODE_DEND`,`SHAPE_DATA`];function fwt(e,t){return e===5?t?`KANBAN`:`MINDMAP`:dwt[e]}var QQ={DEFAULT:0,NO_BORDER:0,ROUNDED_RECT:1,RECT:2,CIRCLE:3,CLOUD:4,BANG:5,HEXAGON:6};function pwt(e,t){switch(e){case`[`:return QQ.RECT;case`(`:return t===`)`?QQ.ROUNDED_RECT:QQ.CLOUD;case`((`:return QQ.CIRCLE;case`)`:return QQ.CLOUD;case`))`:return QQ.BANG;case`{{`:return QQ.HEXAGON;default:return QQ.DEFAULT}}var mwt=/\s+/y,$Q=/.+/y,hwt=/[^([\n){}]+/y,gwt=/[^([\n){}@]+/y,_wt=/[^)\](}]+/y,vwt=/[^`"]+/y,ywt=/[^}^"]+/y,bwt=/\n\s*/g;function xwt(e,t,n){for(let r=0;r<n.length;r++)if((e.charCodeAt(t+r)|32)!==n.charCodeAt(r))return!1;return!0}function Swt(e,t){let n=e.length,r=[],i=[],a=[],o=t?`kanban`:`mindmap`,s=t?gwt:hwt,c=0,l=0,u=-1,d=(e,t,n)=>{r.push(e),i.push(t),a.push(l),l=n},f=(t,n,r)=>{d(t,e.slice(l,n),n),c=r},p=(t,n)=>(t.lastIndex=n,t.test(e)?t.lastIndex:-1),m=t=>{let r=e.indexOf(t,l);return r===-1?n:r};for(;l<n;){let n=e.charCodeAt(l),r=e.charCodeAt(l+1),i;if(c===0){let a=n<=32||n>=160?Math.max(p(mwt,l),l):l;if(t&&n===64&&r===123)d(13,``,l+2),c=6;else if(e.charCodeAt(a)===37&&e.charCodeAt(a+1)===37)f(2,p($Q,a),0);else if(a>l)u<l&&(u=m(`
|
|
1025
1025
|
`)),u>=a?f(6,a,0):(i=e.lastIndexOf(`
|
|
1026
1026
|
`,a-1))>l?f(2,i+1,0):f(3,l+1,0);else if(xwt(e,l,o)&&!aq(e.charCodeAt(l+o.length)))f(5,l+o.length,0);else if(n===58&&r===58&&e.charCodeAt(l+2)===58)l+=3,c=1;else if(n===58&&r===58&&xwt(e,l+2,`icon`)&&e.charCodeAt(l+6)===40)l+=7,c=2;else if(n===45&&r===41||n===40&&(r===45||r===40)||(n===41||n===123)&&r===n)f(9,l+2,3);else if(n===41||n===40||n===91)f(9,l+1,3);else if((i=p(s,l))!==-1)f(10,i,0);else break}else if(c===3)n===34?(c=r===96?5:4,l+=r===96?2:1):n===41||n===40?f(12,r===n||n===40&&r===45?l+2:l+1,0):n===93?f(12,l+1,0):n===125&&r===125||n===45&&r===41?f(12,l+2,0):f(11,p(n===125?$Q:_wt,l),3);else if(c===4)n===34?(l++,c=3):f(11,m(`"`),4);else if(c===5){if(n===96&&r===34)l+=2,c=3;else if((i=p(vwt,l))!==-1)f(11,i,5);else break}else if(c===1){if((i=p($Q,l))!==-1)f(8,i,0);else if(n===10)l++,c=0;else break}else if(c===2)n===41?(l++,c=0):f(7,m(`)`),2);else if(c===6){if(n===34)f(13,l+1,7);else if(n===125)l++,c=0;else if((i=p(ywt,l))!==-1)f(13,i,6);else break}else n===34?f(13,l+1,6):(i=m(`"`),d(13,e.slice(l,i).replace(bwt,`<br/>`),i))}return l<n?d(1,``,l):(c===0&&d(4,``,n),d(0,``,n)),{types:r,texts:i,starts:a}}var e$=`'SPACELINE', 'NL', 'EOF'`,Cwt=/* @__PURE__ */ new Uint8Array(14);for(let e of[2,6,7,8,9,10])Cwt[e]=1;function t$(e){return e===2||e===3||e===4}function wwt(e,t,n){let r=n?`kanban`:`mindmap`,{types:i,texts:a,starts:o}=Swt(e,n),s=n?`, 'SHAPE_DATA'`:``,c=0,l=t=>{let a=i[c];throw a===1?FK(r,e,o[c],``,!0):FK(r,e,o[c],`Expecting ${t}, got '${fwt(a,n)}'`)},u=`'${fwt(5,n)}'`;if(i[c]===2){for(c++;i[c]===2||i[c]===3;)c++;i[c]!==5&&l(`'SPACELINE', 'NL', ${u}`)}else i[c]!==5&&l(`'SPACELINE', ${u}`);c++;let d=`'SPACELINE', 'NL', 'SPACELIST', 'ICON', 'CLASS', 'NODE_DSTART', 'NODE_ID'`;for(i[c]===3&&(c++,d=`'SPACELINE', 'SPACELIST', 'ICON', 'CLASS', 'NODE_DSTART', 'NODE_ID'`);;){let e=i[c],n=0,r=e===6;if(r&&(n=a[c++].length,e=i[c]),e===10||e===9){let r,o,u=0;if(e===10&&(r=a[c++]),i[c]===9){let e=a[c++];i[c]!==11&&l(`'NODE_DESCR'`),o=a[c++],i[c]!==12&&l(`'NODE_DEND'`);let n=a[c++];!t$(i[c])&&i[c]!==13&&l(e$+s),u=t.getType(e,n)}else!t$(i[c])&&i[c]!==13&&l(e$+`, 'NODE_DSTART'`+s),o=r;if(i[c]===13){let e=a[c++];for(;i[c]===13;)e+=a[c++];t$(i[c])||l(e$+s),t.addNode(n,r??o,o,u,e)}else t.addNode(n,r??o,o,u)}else if(e===7||e===8){let n=a[c++];t$(i[c])||l(e$),t.decorateNode(e===7?{icon:n}:{class:n})}else r?t$(e)||l(e$+`, 'ICON', 'CLASS', 'NODE_DSTART', 'NODE_ID'`):e===2?t$(i[++c])||l(e$):l(d);for(c++;i[c]===3||i[c]===4;)c++;if(i[c]===0)return;Cwt[i[c]]===0&&l(e$+`, 'SPACELIST', 'ICON', 'CLASS', 'NODE_DSTART', 'NODE_ID'`)}}var Twt=class{type=`kanban`;title;sections=[];getType=pwt;last;sectionLevel=0;misplaced;addNode(e,t,n,r,i){let a={id:t,level:e,label:n};if(i!==void 0){let e=i.includes(`
|
|
1027
1027
|
`)?i+`
|
|
1028
1028
|
`:`{
|
|
1029
1029
|
`+i+`
|
|
1030
|
-
}`,t;try{t=$K(e)}catch(e){throw new NK(`Metadata of "${a.id}" is not valid YAML. ${e.message}`,`syntax`,{type:`kanban`})}if(typeof t==`object`&&t&&!Array.isArray(t)){let e=t.shape?String(t.shape):``;if(e!==e.toLowerCase()||e.includes(`_`))throw new NK(`No such shape: ${e}. Shape names should be lowercase.`,`semantic`,{type:`kanban`});t.label&&(a.label=String(t.label)),t.icon&&(a.icon=String(t.icon)),t.assigned&&(a.assigned=String(t.assigned)),t.ticket&&(a.ticket=String(t.ticket)),t.priority&&(a.priority=String(t.priority))}}if(this.misplaced)throw new NK(`Items without section detected, found section ("${this.misplaced.label}")`,`semantic`,{type:`kanban`});let o=this.sections;if(o.length===0&&(this.sectionLevel=e),this.last=a,e===this.sectionLevel){let e=a;e.items=[],o.push(e)}else o[o.length-1].items.push(a),e<this.sectionLevel&&(this.misplaced=a)}decorateNode(e){let t=this.last;!e||!t||(e.icon&&(t.icon=e.icon),e.class&&(t.cssClasses=e.class))}};function Ewt(e,t){wwt(e,t,!0)}function n$(e,t,n,r,i){return`<svg class="pele-icon" data-icon="${mq(e)}" x="${K(t)}" y="${K(n)}" width="${K(r)}" height="${K(r)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${i?.(e)??``}</svg>`}var r$=12,i$=8,a$=10,o$=8,Dwt=4,s$=6,Owt=/* @__PURE__ */ new Map([[`very high`,`stroke="${pJ}"`],[`high`,`stroke="${pJ}" opacity="0.5"`],[`low`,`stroke="var(--_m)" opacity="0.5"`],[`very low`,`stroke="var(--_m)"`]]);function c$(e,t,n,r,i,a=0){let o=WJ(e,t,n,r,i,a);if(o.width<=i)return o;let s=[],c=[],l=0,u=[],d=0,f=()=>{s.push(u),c.push(d),l=Math.max(l,d),u=[],d=0};for(let e=0;e<o.lines.length;e++)if(o.widths[e]<=i)u=o.lines[e],d=o.widths[e],f();else{for(let t of o.lines[e]){if(t.icon!==void 0){d>0&&d+t.width>i&&f(),u.push(t),d+=t.width;continue}let e=``,a=d;for(let o of t.text){let s=n.width(o,r,t.style);d>0&&d+s>i&&(e&&u.push({text:e,style:t.style,width:d-a}),f(),e=``,a=0),e+=o,d+=s}e&&u.push({text:e,style:t.style,width:d-a})}f()}return{...o,lines:s,widths:c,width:l,height:s.length*o.lineHeight}}function l$(e,t,n,r,i,a=!1){let o=``;for(let s=0;s<e.lines.length;s++){let c=e.lines[s],l=n+(s+.5)*e.lineHeight;if(c.length===1&&c[0].icon===void 0)o+=`<text${yq(r,c[0].style)} x="${K(t)}" y="${K(l+e.size*.35)}"${a?` text-anchor="end"`:``}>${pq(c[0].text)}</text>`;else{let n=e.widths[s],u={...e,lines:[c],widths:[n],width:n,height:e.lineHeight};o+=gq(u,t+(a?-n:n)/2,l,r,i)}}return o}var u$=e=>!!e&&VK(e)!==``;function kwt(e,t,n){let r=n.fontSize??16,i=Math.round(r*.875),a=Math.round(r*1.5),o=Math.round(i*1.5),s=n.measurer??fq(n.fontFamily),c=n.padding??8,l=n.icons,u=t.kanban??{},d=u.sectionWidth,f=typeof d==`number`&&d>0?Math.min(Math.max(d,80),2e3):200,p=n.maxWidth!==void 0&&n.maxWidth>0?n.maxWidth-2*c:1/0,m=e.sections.length,h=m*(f+r$)-r$<=p,g=h?Math.max(m,1):Math.max(1,Math.floor((p+r$)/(f+r$))),_=h?f:Math.max(Math.min(f,p),Math.min(Math.floor((p+r$)/g)-r$,f*2)),v=typeof u.ticketBaseUrl==`string`?u.ticketBaseUrl:``,y=_-2*i$,b=y-2*a$,x=i*1.25,S=[],C=e.sections,w=[],T=[],E=[],D=a,O=[];for(let e of C){let t=s.width(String(e.items.length),i,0),n=t+12+(u$(e.icon)?x+s$:0),a=c$(e.label,!0,s,r,y-8-n,1);D=Math.max(D,a.height),T.push(t),w.push(a);let c=[],l=0;for(let t of e.items){let e=c$(t.label,!0,s,i,b-(u$(t.icon)?x+s$:0)),n=c$(t.ticket,!1,s,i,b),r=c$(t.assigned,!1,s,i,b),a=n.width+r.width+8>b?n.height+r.height:Math.max(n.height,r.height),u=2*a$+Math.max(e.height,o)+(a?Dwt+a:0);c.push({item:t,label:e,ticket:n,assigned:r,meta:a,height:u}),l+=u+o$}E.push(c),O.push(l)}D+=2*i$;let k=[],A=[];for(let e=0,t=0;e<C.length;e+=g){let n=o$;for(let t=e;t<Math.min(e+g,C.length);t++)n=Math.max(n,O[t]);A.push(t),k.push(D+n),t+=D+n+r$}let j=k.length>0?A[A.length-1]+k[k.length-1]:0,M=WJ(e.title,!1,s,r,KJ(n),1),N=M.height>0?M.height+16:0,P=Math.max(Math.min(C.length,g)*(_+r$)-r$,0),F=Math.max(P,M.width),ee=c+(F-P)/2,te=_-i$-4,I=``;for(let e=0;e<C.length;e++){let t=C[e],r=Math.floor(e/g),s=`<rect width="${_}" height="${K(k[r])}" rx="${fJ}" fill="var(--_s)"/>`+l$(w[e],i$+4,i$,` class="pele-cluster-label" font-weight="var(--_hw)"`,l)+`<text class="pele-count" x="${te}" y="${K(i$+a/2+i*.35)}" text-anchor="end" font-size="${i}" fill="var(--_m)">${t.items.length}</text>`;u$(t.icon)&&(s+=n$(t.icon,te-T[e]-s$-x,i$+(a-x)/2,x,l));let u=D;for(let t of E[e]){let e=t.item,r=(e.priority??``).trim().toLowerCase(),a=Owt.get(r),c=`<rect width="${y}" height="${K(t.height)}" rx="${fJ}" fill="var(--_bg)" stroke="var(--_b)"/>`;a!==void 0&&(c+=`<path class="pele-priority" d="M2.5,5V${K(t.height-5)}" fill="none" ${a} stroke-width="3" stroke-linecap="round"/>`),c+=l$(t.label,a$,a$,` class="pele-label"`,l),u$(e.icon)&&(c+=n$(e.icon,y-a$-x,a$+(o-x)/2,x,l));let d=t.height-a$;if(e.ticket){let r=d-t.meta,i=v?wq(Cq(v.replace(`#TICKET#`,()=>e.ticket)),n):void 0;i===void 0?c+=l$(t.ticket,a$,r,` class="pele-ticket" fill="var(--_m)"`,l):(c+=`<a href="${pq(i)}" target="_blank"${Eq(n)}>`+l$(t.ticket,a$,r,` class="pele-ticket" fill="var(--_c)"`,l)+`</a>`,S.push({id:e.id,href:i,internal:!1}))}e.assigned&&(c+=l$(t.assigned,y-a$,d-t.assigned.height,` class="pele-assigned" fill="var(--_m)"`,l,!0)),s+=`<g class="pele-node pele-card${a===void 0?``:` pele-priority-`+r.replace(` `,`-`)}${hJ(e.cssClasses??``)}" data-id="${mq(e.id)}" transform="translate(${i$},${K(u)})" font-size="${i}">${c}</g>`,u+=t.height+o$}I+=`<g class="pele-cluster pele-column${hJ(t.cssClasses??``)}" data-id="${mq(t.id)}" transform="translate(${K(ee+e%g*(_+r$))},${K(c+N+A[r])})">${s}</g>`}let ne=Math.ceil(F+2*c),re=Math.ceil(j+N+2*c);return{svg:vJ(`kanban`,ne,re,r,n,{},gq(M,ne/2,c+M.height/2,` class="pele-title" font-weight="var(--_tw)"`)+I),width:ne,height:re,links:S}}var Awt={type:`kanban`,parse(e,t,n){let r=new Twt;return r.title=n,Ewt(e,r),r},render:kwt},jwt=11,Mwt=class{type=`mindmap`;title;nodes=[];getType=pwt;baseLevel=0;open=[];addNode(e,t,n,r){let i=this.nodes.length===0;i&&(this.baseLevel=e),e-=this.baseLevel;let a=this.open,o=a.length;for(;o>0&&a[o-1].level>=e;)o--;let s=a[o-1];if(!s&&!i)throw new NK(`There can be only one root. No parent could be found for ("${n}")`,`semantic`,{type:`mindmap`});let c={id:this.nodes.length,nodeId:t,level:e,descr:n,type:r,children:[],isRoot:i};s&&(c.section=s.isRoot?s.children.length%jwt:s.section,s.children.push(c)),a.length=o,a.push(c),this.nodes.push(c)}decorateNode(e){let t=this.nodes[this.nodes.length-1];!e||!t||(e.icon&&(t.icon=e.icon),e.class&&(t.class=e.class))}};function Nwt(e,t){wwt(e,t,!1)}var Pwt=[``,`rounded`,`rect`,`circle`,`cloud`,`bang`,`hex`],Fwt=`stadium`,Iwt=36,Lwt=8,Rwt=18,zwt=52,Bwt=28,Vwt=6,Hwt=12,Uwt=.22,d$=6,f$=28,Wwt=12,Gwt=8,Kwt=10;function qwt(e,t,n,r){if(e.lines.length<2)return gq(e,t+e.width/2,n,` class="pele-label"`,r);let i=``;for(let a=0;a<e.lines.length;a++){let o=e.widths[a],s={lines:[e.lines[a]],widths:[o],width:o,height:e.lineHeight,size:e.size,lineHeight:e.lineHeight};i+=gq(s,t+o/2,n+(a-(e.lines.length-1)/2)*e.lineHeight,` class="pele-label"`,r)}return i}function Jwt(e,t,n){return JJ(n,r=>Ywt(e,t,n,r))}function Ywt(e,t,n,r){let i=n.fontSize??16,a=n.measurer??fq(n.fontFamily),o=n.padding??8,s=n.icons,c=t.mindmap?.maxNodeWidth,l=typeof c==`number`&&c>0?Math.min(c,2e3):200,u=i*1.25,d=e.nodes,f=d.length,p=new Int32Array(f),m=new Int32Array(f);for(let e=0;e<f;e++)for(let t of d[e].children)p[t.id]=e,m[t.id]=m[e]+1;let h=r&&n.maxWidth!==void 0&&n.maxWidth>0?n.maxWidth-2*o:1/0,g=Array(f),_=Array(f),v=new Float64Array(f),y=new Float64Array(f),b=new Float64Array(f),x=new Float64Array(f),S=new Uint8Array(f);for(let e=0;e<f;e++){let t=d[e];S[e]=+(t.icon!==void 0&&VK(t.icon)!==``);let n=Math.min(l,Math.max(72,h-m[e]*f$-2*Vwt-(S[e]?u+d$:0))),o=g[e]=WJ(t.descr,!0,a,i,n),s=o.width+(S[e]?u+(o.width>0?d$:0):0),c=Math.max(o.height,Math.round(i*1.5)),f=Pwt[t.type]||(e===0?Fwt:``);if(r&&e===0&&f!==`rect`&&f!==`rounded`&&(f=Fwt),_[e]=f,f===``){let n=t.children.length>0;v[e]=s+2*(n?Hwt:Vwt),y[e]=c+(n?6:0),x[e]=y[e]/2}else{let t=LJ(f,s,c);v[e]=t.w,y[e]=t.h,b[e]=t.dy,x[e]=t.h/2}}let C=new Float64Array(f),w=new Float64Array(f),T=new Float64Array(f),E=new Float64Array(f),D=0,O=(e,t,n,r)=>{let i=0,a=0;for(let o=t;o<n;o++){let t=e[o].id;w[t]=i,a=e[o].children.length>0||o+1<n&&e[o+1].children.length>0?Math.max(r,Rwt):r,i+=C[t]+a}D=i-a;let o=e[t].id,s=e[n-1].id;return(w[o]+T[o]+x[o]+w[s]+T[s]+x[s])/2};for(let e=f-1;e>0;e--){let t=d[e].children;if(t.length===0){C[e]=y[e];continue}let n=O(t,0,t.length,Lwt)-x[e],r=Math.min(0,n);C[e]=Math.max(D,n+y[e])-r,T[e]=n-r,E[e]=-r}let k=new Float64Array(f),A=new Float64Array(f),j=new Float64Array(f),M=new Int8Array(f),N=new Float64Array(f);if(r){let e=0;for(let t=0;t<f;t++)t>0&&p[t]===0&&(e+=Kwt),k[t]=m[t]*f$+v[t]/2,A[t]=e,e+=y[t]+Kwt}else if(f>0){let e=d[0].children,t=e.length,n=0;for(let t of e)n+=C[t.id];let r=t,i=1/0,a=0;for(let o=1;o<t;o++){a+=C[e[o-1].id];let s=Math.abs(2*a-n+(2*o-t)*Bwt);s<i&&(i=s,r=o)}for(let n=0,i=r,a=1;n<t;n=i,i=t,a=-1){let t=O(e,n,i,Bwt);for(let r=n;r<i;r++){let n=e[r].id;j[n]=w[n]-t,M[n]=a}}A[0]=-y[0]/2;for(let e=0;e<f;e++){e>0&&(A[e]=j[e]+T[e]);for(let t of d[e].children){let n=t.id;e>0&&(M[n]=M[e],j[n]=j[e]+E[e]+w[n]),k[n]=k[e]+M[n]*(v[e]/2+(e>0?Iwt:zwt)+v[n]/2)}}}let P=0,F=0,ee=0,te=0,I=``,ne=``,re=``,ie=``,ae=e=>{re!==``&&(I+=`<g class="pele-branch pele-section-${e??0}"><g class="pele-edges" fill="none" stroke="${ie}" stroke-width="1.5">${ne}</g>${re}</g>`,ne=re=``)};for(let e=1;e<=f;e++){let t=e%f,n=d[t],i=_[t],a=g[t],o=k[t],c=A[t];if(P=Math.min(P,o-v[t]/2),F=Math.max(F,o+v[t]/2),ee=Math.min(ee,c),te=Math.max(te,c+y[t]),(t===0||p[t]===0)&&ae(d[e-1].section),t>0&&r){p[t]===0&&(ie=gJ(n.section??0));let e=p[t],r=e===0?Math.min(Math.max(Wwt,y[0]/2),f$-Gwt):Wwt,a=k[e]-v[e]/2+Math.min(r,v[e]/2),s=N[e]||A[e]+y[e],l=o-v[t]/2+(i?zJ(i,v[t],y[t],3):0),u=c+x[t],d=Math.max(0,Math.min(Gwt,l-a,u-s));N[e]=u-d,ne+=`<path class="pele-edge" d="M${K(a)},${K(s)}V${K(u-d)}Q${K(a)},${K(u)} ${K(a+d)},${K(u)}H${K(l)}"/>`}else if(t>0){p[t]===0&&(ie=gJ(n.section??0));let e=p[t],r=M[t],a=r>0?1:3,s=k[e]+r*(v[e]/2-(_[e]?zJ(_[e],v[e],y[e],a):0)),l=A[e]+x[e],u=o-r*v[t]/2+(i?r*zJ(i,v[t],y[t],4-a):0),d=c+x[t],f=K((s+u)/2);ne+=`<path class="pele-edge" d="M${K(s)},${K(l)}C${f},${K(l)} ${f},${K(d)} ${K(u)},${K(d)}"/>`}let l=!i&&n.children.length>0,m=` fill="${ie}" fill-opacity="${Uwt}" stroke="${ie}"`,h=``;i?h=t>0?RJ(i,v[t],y[t],m,` stroke="${ie}"`):RJ(i,v[t],y[t],` fill="var(--_s)" stroke="var(--_b)"`,` stroke="var(--_b)"`):l&&(h=`<rect x="${K(-v[t]/2)}" y="${K(-y[t]/2)}" width="${K(v[t])}" height="${K(y[t])}" rx="${K(y[t]/2)}"${m}/>`);let C=0;n.icon&&S[t]&&(C=(u+(a.width>0?d$:0))/2,h+=n$(n.icon,-C-a.width/2,b[t]-u/2,u,s));let w=`<g class="pele-node pele-shape-${i||(l?`branch`:`text`)}${t>0?``:` pele-root`}${hJ(n.class??``)}" data-id="${mq(n.nodeId)}" transform="translate(${K(o)},${K(c+y[t]/2)})">`+h+(r&&!i?qwt(a,C-a.width/2,b[t],s):gq(a,C,b[t],` class="pele-label"`,s))+`</g>`;t>0?re+=w:I+=w}let L=WJ(e.title,!1,a,i,KJ(n),1),oe=L.height>0?L.height+16:0,se=Math.max(F-P,L.width),ce=Math.ceil(se+2*o),le=Math.ceil(te-ee+oe+2*o);return{svg:vJ(`mindmap`,ce,le,i,n,{},gq(L,ce/2,o+L.height/2,` class="pele-title" font-weight="var(--_tw)"`)+`<g transform="translate(${K(o-P+(se-F+P)/2)},${K(o+oe-ee)})">${I}</g>`),width:ce,height:le,links:[]}}var Xwt={type:`mindmap`,parse(e,t,n){let r=new Mwt;return r.title=n,Nwt(e,r),r},render:Jwt},Zwt=1e4;function p$(e,t,n,r,i){let a=e.packet?.[t];return typeof a==`number`&&a>=r?Math.min(a,i):n}function m$(e){return new NK(e,`semantic`,{type:`packet`})}function Qwt(e,t,n){let r=Math.floor(p$(t,`bitsPerRow`,32,1,4096)),i=[],a=-1,o=[],s=1;for(let t of e.blocks){let{start:e,end:n,bits:c}=t;if(e!==void 0&&n!==void 0&&n<e)throw m$(`Packet block ${e} - ${n} is invalid. End must be greater than start.`);if(e??=a+1,e!==a+1)throw m$(`Packet block ${e} - ${n??e} is not contiguous. It should start from ${a+1}.`);if(c===0)throw m$(`Packet block ${e} is invalid. Cannot have a zero bit field.`);for(n??=e+(c??1)-1,c??=n-e+1,a=n;o.length<=r+1&&i.length<Zwt;){let a=s*r-1;if(n<=a){o.push({start:e,end:n,bits:c,label:t.label}),n===a&&(i.push(o),o=[],s++);break}o.push({start:e,end:a,bits:a-e,label:t.label}),i.push(o),o=[],s++,e=a+1,c=n-e}}return o.length>0&&i.push(o),{type:`packet`,title:e.title||n,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,``):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
|
|
1031
|
-
`):void 0,bitsPerRow:r,rows:i}}var $wt=[{name:`packet-beta`,pattern:`packet-beta`},
|
|
1032
|
-
`):void 0,showData:e.showData,sections:n}}function aTt(e,t){let n=t;for(let t=e.charCodeAt(n);t>=48&&t<=57;t=e.charCodeAt(n))n++;return n}function oTt(){let e=0,t=0,n=-1;return(r,i)=>{let a=r.charCodeAt(i)===45?i+1:i;if((a<e||a>=t)&&(e=a,t=aTt(r,a),n=-1,t>a&&r.charCodeAt(t)===46)){let e=aTt(r,t+1),i=e-t-1;i>0&&r.charCodeAt(e)!==46?n=e:i>1&&(n=e-1)}return t===a?-1:n>=0?n:r.charCodeAt(a)===48?r.charCodeAt(a+1)===46?-1:a+1:r.charCodeAt(t)===46?t-1>a?t-1:-1:t}}var sTt=[
|
|
1030
|
+
}`,t;try{t=$K(e)}catch(e){throw new NK(`Metadata of "${a.id}" is not valid YAML. ${e.message}`,`syntax`,{type:`kanban`})}if(typeof t==`object`&&t&&!Array.isArray(t)){let e=t.shape?String(t.shape):``;if(e!==e.toLowerCase()||e.includes(`_`))throw new NK(`No such shape: ${e}. Shape names should be lowercase.`,`semantic`,{type:`kanban`});t.label&&(a.label=String(t.label)),t.icon&&(a.icon=String(t.icon)),t.assigned&&(a.assigned=String(t.assigned)),t.ticket&&(a.ticket=String(t.ticket)),t.priority&&(a.priority=String(t.priority))}}if(this.misplaced)throw new NK(`Items without section detected, found section ("${this.misplaced.label}")`,`semantic`,{type:`kanban`});let o=this.sections;if(o.length===0&&(this.sectionLevel=e),this.last=a,e===this.sectionLevel){let e=a;e.items=[],o.push(e)}else o[o.length-1].items.push(a),e<this.sectionLevel&&(this.misplaced=a)}decorateNode(e){let t=this.last;!e||!t||(e.icon&&(t.icon=e.icon),e.class&&(t.cssClasses=e.class))}};function Ewt(e,t){wwt(e,t,!0)}function n$(e,t,n,r,i){return`<svg class="pele-icon" data-icon="${mq(e)}" x="${K(t)}" y="${K(n)}" width="${K(r)}" height="${K(r)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${i?.(e)??``}</svg>`}var r$=12,i$=8,a$=10,o$=8,Dwt=4,s$=6,Owt=/* @__PURE__ */ new Map([[`very high`,`stroke="${fJ}"`],[`high`,`stroke="${fJ}" opacity="0.5"`],[`low`,`stroke="var(--_m)" opacity="0.5"`],[`very low`,`stroke="var(--_m)"`]]);function c$(e,t,n,r,i,a=0){let o=UJ(e,t,n,r,i,a);if(o.width<=i)return o;let s=[],c=[],l=0,u=[],d=0,f=()=>{s.push(u),c.push(d),l=Math.max(l,d),u=[],d=0};for(let e=0;e<o.lines.length;e++)if(o.widths[e]<=i)u=o.lines[e],d=o.widths[e],f();else{for(let t of o.lines[e]){if(t.icon!==void 0){d>0&&d+t.width>i&&f(),u.push(t),d+=t.width;continue}let e=``,a=d;for(let o of t.text){let s=n.width(o,r,t.style);d>0&&d+s>i&&(e&&u.push({text:e,style:t.style,width:d-a}),f(),e=``,a=0),e+=o,d+=s}e&&u.push({text:e,style:t.style,width:d-a})}f()}return{...o,lines:s,widths:c,width:l,height:s.length*o.lineHeight}}function l$(e,t,n,r,i,a=!1){let o=``;for(let s=0;s<e.lines.length;s++){let c=e.lines[s],l=n+(s+.5)*e.lineHeight;if(c.length===1&&c[0].icon===void 0)o+=`<text${yq(r,c[0].style)} x="${K(t)}" y="${K(l+e.size*.35)}"${a?` text-anchor="end"`:``}>${pq(c[0].text)}</text>`;else{let n=e.widths[s],u={...e,lines:[c],widths:[n],width:n,height:e.lineHeight};o+=gq(u,t+(a?-n:n)/2,l,r,i)}}return o}var u$=e=>!!e&&VK(e)!==``;function kwt(e,t,n){let r=n.fontSize??16,i=Math.round(r*.875),a=Math.round(r*1.5),o=Math.round(i*1.5),s=n.measurer??fq(n.fontFamily),c=n.padding??8,l=n.icons,u=t.kanban??{},d=u.sectionWidth,f=typeof d==`number`&&d>0?Math.min(Math.max(d,80),2e3):200,p=n.maxWidth!==void 0&&n.maxWidth>0?n.maxWidth-2*c:1/0,m=e.sections.length,h=m*(f+r$)-r$<=p,g=h?Math.max(m,1):Math.max(1,Math.floor((p+r$)/(f+r$))),_=h?f:Math.max(Math.min(f,p),Math.min(Math.floor((p+r$)/g)-r$,f*2)),v=typeof u.ticketBaseUrl==`string`?u.ticketBaseUrl:``,y=_-2*i$,b=y-2*a$,x=i*1.25,S=[],C=e.sections,w=[],T=[],E=[],D=a,O=[];for(let e of C){let t=s.width(String(e.items.length),i,0),n=t+12+(u$(e.icon)?x+s$:0),a=c$(e.label,!0,s,r,y-8-n,1);D=Math.max(D,a.height),T.push(t),w.push(a);let c=[],l=0;for(let t of e.items){let e=c$(t.label,!0,s,i,b-(u$(t.icon)?x+s$:0)),n=c$(t.ticket,!1,s,i,b),r=c$(t.assigned,!1,s,i,b),a=n.width+r.width+8>b?n.height+r.height:Math.max(n.height,r.height),u=2*a$+Math.max(e.height,o)+(a?Dwt+a:0);c.push({item:t,label:e,ticket:n,assigned:r,meta:a,height:u}),l+=u+o$}E.push(c),O.push(l)}D+=2*i$;let k=[],A=[];for(let e=0,t=0;e<C.length;e+=g){let n=o$;for(let t=e;t<Math.min(e+g,C.length);t++)n=Math.max(n,O[t]);A.push(t),k.push(D+n),t+=D+n+r$}let j=k.length>0?A[A.length-1]+k[k.length-1]:0,M=UJ(e.title,!1,s,r,GJ(n),1),N=M.height>0?M.height+16:0,P=Math.max(Math.min(C.length,g)*(_+r$)-r$,0),F=Math.max(P,M.width),ee=c+(F-P)/2,te=_-i$-4,I=``;for(let e=0;e<C.length;e++){let t=C[e],r=Math.floor(e/g),s=`<rect width="${_}" height="${K(k[r])}" rx="${dJ}" fill="var(--_s)"/>`+l$(w[e],i$+4,i$,` class="pele-cluster-label" font-weight="var(--_hw)"`,l)+`<text class="pele-count" x="${te}" y="${K(i$+a/2+i*.35)}" text-anchor="end" font-size="${i}" fill="var(--_m)">${t.items.length}</text>`;u$(t.icon)&&(s+=n$(t.icon,te-T[e]-s$-x,i$+(a-x)/2,x,l));let u=D;for(let t of E[e]){let e=t.item,r=(e.priority??``).trim().toLowerCase(),a=Owt.get(r),c=`<rect width="${y}" height="${K(t.height)}" rx="${dJ}" fill="var(--_bg)" stroke="var(--_b)"/>`;a!==void 0&&(c+=`<path class="pele-priority" d="M2.5,5V${K(t.height-5)}" fill="none" ${a} stroke-width="3" stroke-linecap="round"/>`),c+=l$(t.label,a$,a$,` class="pele-label"`,l),u$(e.icon)&&(c+=n$(e.icon,y-a$-x,a$+(o-x)/2,x,l));let d=t.height-a$;if(e.ticket){let r=d-t.meta,i=v?wq(Cq(v.replace(`#TICKET#`,()=>e.ticket)),n):void 0;i===void 0?c+=l$(t.ticket,a$,r,` class="pele-ticket" fill="var(--_m)"`,l):(c+=`<a href="${pq(i)}" target="_blank"${Eq(n)}>`+l$(t.ticket,a$,r,` class="pele-ticket" fill="var(--_c)"`,l)+`</a>`,S.push({id:e.id,href:i,internal:!1}))}e.assigned&&(c+=l$(t.assigned,y-a$,d-t.assigned.height,` class="pele-assigned" fill="var(--_m)"`,l,!0)),s+=`<g class="pele-node pele-card${a===void 0?``:` pele-priority-`+r.replace(` `,`-`)}${mJ(e.cssClasses??``)}" data-id="${mq(e.id)}" transform="translate(${i$},${K(u)})" font-size="${i}">${c}</g>`,u+=t.height+o$}I+=`<g class="pele-cluster pele-column${mJ(t.cssClasses??``)}" data-id="${mq(t.id)}" transform="translate(${K(ee+e%g*(_+r$))},${K(c+N+A[r])})">${s}</g>`}let ne=Math.ceil(F+2*c),re=Math.ceil(j+N+2*c);return{svg:_J(`kanban`,ne,re,r,n,{},gq(M,ne/2,c+M.height/2,` class="pele-title" font-weight="var(--_tw)"`)+I),width:ne,height:re,links:S}}var Awt={type:`kanban`,parse(e,t,n){let r=new Twt;return r.title=n,Ewt(e,r),r},render:kwt},jwt=11,Mwt=class{type=`mindmap`;title;nodes=[];getType=pwt;baseLevel=0;open=[];addNode(e,t,n,r){let i=this.nodes.length===0;i&&(this.baseLevel=e),e-=this.baseLevel;let a=this.open,o=a.length;for(;o>0&&a[o-1].level>=e;)o--;let s=a[o-1];if(!s&&!i)throw new NK(`There can be only one root. No parent could be found for ("${n}")`,`semantic`,{type:`mindmap`});let c={id:this.nodes.length,nodeId:t,level:e,descr:n,type:r,children:[],isRoot:i};s&&(c.section=s.isRoot?s.children.length%jwt:s.section,s.children.push(c)),a.length=o,a.push(c),this.nodes.push(c)}decorateNode(e){let t=this.nodes[this.nodes.length-1];!e||!t||(e.icon&&(t.icon=e.icon),e.class&&(t.class=e.class))}};function Nwt(e,t){wwt(e,t,!1)}var Pwt=[``,`rounded`,`rect`,`circle`,`cloud`,`bang`,`hex`],Fwt=`stadium`,Iwt=36,Lwt=8,Rwt=18,zwt=52,Bwt=28,Vwt=6,Hwt=12,Uwt=.22,d$=6,f$=28,Wwt=12,Gwt=8,Kwt=10;function qwt(e,t,n,r){if(e.lines.length<2)return gq(e,t+e.width/2,n,` class="pele-label"`,r);let i=``;for(let a=0;a<e.lines.length;a++){let o=e.widths[a],s={lines:[e.lines[a]],widths:[o],width:o,height:e.lineHeight,size:e.size,lineHeight:e.lineHeight};i+=gq(s,t+o/2,n+(a-(e.lines.length-1)/2)*e.lineHeight,` class="pele-label"`,r)}return i}function Jwt(e,t,n){return qJ(n,r=>Ywt(e,t,n,r))}function Ywt(e,t,n,r){let i=n.fontSize??16,a=n.measurer??fq(n.fontFamily),o=n.padding??8,s=n.icons,c=t.mindmap?.maxNodeWidth,l=typeof c==`number`&&c>0?Math.min(c,2e3):200,u=i*1.25,d=e.nodes,f=d.length,p=new Int32Array(f),m=new Int32Array(f);for(let e=0;e<f;e++)for(let t of d[e].children)p[t.id]=e,m[t.id]=m[e]+1;let h=r&&n.maxWidth!==void 0&&n.maxWidth>0?n.maxWidth-2*o:1/0,g=Array(f),_=Array(f),v=new Float64Array(f),y=new Float64Array(f),b=new Float64Array(f),x=new Float64Array(f),S=new Uint8Array(f);for(let e=0;e<f;e++){let t=d[e];S[e]=+(t.icon!==void 0&&VK(t.icon)!==``);let n=Math.min(l,Math.max(72,h-m[e]*f$-2*Vwt-(S[e]?u+d$:0))),o=g[e]=UJ(t.descr,!0,a,i,n),s=o.width+(S[e]?u+(o.width>0?d$:0):0),c=Math.max(o.height,Math.round(i*1.5)),f=Pwt[t.type]||(e===0?Fwt:``);if(r&&e===0&&f!==`rect`&&f!==`rounded`&&(f=Fwt),_[e]=f,f===``){let n=t.children.length>0;v[e]=s+2*(n?Hwt:Vwt),y[e]=c+(n?6:0),x[e]=y[e]/2}else{let t=IJ(f,s,c);v[e]=t.w,y[e]=t.h,b[e]=t.dy,x[e]=t.h/2}}let C=new Float64Array(f),w=new Float64Array(f),T=new Float64Array(f),E=new Float64Array(f),D=0,O=(e,t,n,r)=>{let i=0,a=0;for(let o=t;o<n;o++){let t=e[o].id;w[t]=i,a=e[o].children.length>0||o+1<n&&e[o+1].children.length>0?Math.max(r,Rwt):r,i+=C[t]+a}D=i-a;let o=e[t].id,s=e[n-1].id;return(w[o]+T[o]+x[o]+w[s]+T[s]+x[s])/2};for(let e=f-1;e>0;e--){let t=d[e].children;if(t.length===0){C[e]=y[e];continue}let n=O(t,0,t.length,Lwt)-x[e],r=Math.min(0,n);C[e]=Math.max(D,n+y[e])-r,T[e]=n-r,E[e]=-r}let k=new Float64Array(f),A=new Float64Array(f),j=new Float64Array(f),M=new Int8Array(f),N=new Float64Array(f);if(r){let e=0;for(let t=0;t<f;t++)t>0&&p[t]===0&&(e+=Kwt),k[t]=m[t]*f$+v[t]/2,A[t]=e,e+=y[t]+Kwt}else if(f>0){let e=d[0].children,t=e.length,n=0;for(let t of e)n+=C[t.id];let r=t,i=1/0,a=0;for(let o=1;o<t;o++){a+=C[e[o-1].id];let s=Math.abs(2*a-n+(2*o-t)*Bwt);s<i&&(i=s,r=o)}for(let n=0,i=r,a=1;n<t;n=i,i=t,a=-1){let t=O(e,n,i,Bwt);for(let r=n;r<i;r++){let n=e[r].id;j[n]=w[n]-t,M[n]=a}}A[0]=-y[0]/2;for(let e=0;e<f;e++){e>0&&(A[e]=j[e]+T[e]);for(let t of d[e].children){let n=t.id;e>0&&(M[n]=M[e],j[n]=j[e]+E[e]+w[n]),k[n]=k[e]+M[n]*(v[e]/2+(e>0?Iwt:zwt)+v[n]/2)}}}let P=0,F=0,ee=0,te=0,I=``,ne=``,re=``,ie=``,ae=e=>{re!==``&&(I+=`<g class="pele-branch pele-section-${e??0}"><g class="pele-edges" fill="none" stroke="${ie}" stroke-width="1.5">${ne}</g>${re}</g>`,ne=re=``)};for(let e=1;e<=f;e++){let t=e%f,n=d[t],i=_[t],a=g[t],o=k[t],c=A[t];if(P=Math.min(P,o-v[t]/2),F=Math.max(F,o+v[t]/2),ee=Math.min(ee,c),te=Math.max(te,c+y[t]),(t===0||p[t]===0)&&ae(d[e-1].section),t>0&&r){p[t]===0&&(ie=hJ(n.section??0));let e=p[t],r=e===0?Math.min(Math.max(Wwt,y[0]/2),f$-Gwt):Wwt,a=k[e]-v[e]/2+Math.min(r,v[e]/2),s=N[e]||A[e]+y[e],l=o-v[t]/2+(i?RJ(i,v[t],y[t],3):0),u=c+x[t],d=Math.max(0,Math.min(Gwt,l-a,u-s));N[e]=u-d,ne+=`<path class="pele-edge" d="M${K(a)},${K(s)}V${K(u-d)}Q${K(a)},${K(u)} ${K(a+d)},${K(u)}H${K(l)}"/>`}else if(t>0){p[t]===0&&(ie=hJ(n.section??0));let e=p[t],r=M[t],a=r>0?1:3,s=k[e]+r*(v[e]/2-(_[e]?RJ(_[e],v[e],y[e],a):0)),l=A[e]+x[e],u=o-r*v[t]/2+(i?r*RJ(i,v[t],y[t],4-a):0),d=c+x[t],f=K((s+u)/2);ne+=`<path class="pele-edge" d="M${K(s)},${K(l)}C${f},${K(l)} ${f},${K(d)} ${K(u)},${K(d)}"/>`}let l=!i&&n.children.length>0,m=` fill="${ie}" fill-opacity="${Uwt}" stroke="${ie}"`,h=``;i?h=t>0?LJ(i,v[t],y[t],m,` stroke="${ie}"`):LJ(i,v[t],y[t],` fill="var(--_s)" stroke="var(--_b)"`,` stroke="var(--_b)"`):l&&(h=`<rect x="${K(-v[t]/2)}" y="${K(-y[t]/2)}" width="${K(v[t])}" height="${K(y[t])}" rx="${K(y[t]/2)}"${m}/>`);let C=0;n.icon&&S[t]&&(C=(u+(a.width>0?d$:0))/2,h+=n$(n.icon,-C-a.width/2,b[t]-u/2,u,s));let w=`<g class="pele-node pele-shape-${i||(l?`branch`:`text`)}${t>0?``:` pele-root`}${mJ(n.class??``)}" data-id="${mq(n.nodeId)}" transform="translate(${K(o)},${K(c+y[t]/2)})">`+h+(r&&!i?qwt(a,C-a.width/2,b[t],s):gq(a,C,b[t],` class="pele-label"`,s))+`</g>`;t>0?re+=w:I+=w}let L=UJ(e.title,!1,a,i,GJ(n),1),oe=L.height>0?L.height+16:0,se=Math.max(F-P,L.width),ce=Math.ceil(se+2*o),le=Math.ceil(te-ee+oe+2*o);return{svg:_J(`mindmap`,ce,le,i,n,{},gq(L,ce/2,o+L.height/2,` class="pele-title" font-weight="var(--_tw)"`)+`<g transform="translate(${K(o-P+(se-F+P)/2)},${K(o+oe-ee)})">${I}</g>`),width:ce,height:le,links:[]}}var Xwt={type:`mindmap`,parse(e,t,n){let r=new Mwt;return r.title=n,Nwt(e,r),r},render:Jwt},Zwt=1e4;function p$(e,t,n,r,i){let a=e.packet?.[t];return typeof a==`number`&&a>=r?Math.min(a,i):n}function m$(e){return new NK(e,`semantic`,{type:`packet`})}function Qwt(e,t,n){let r=Math.floor(p$(t,`bitsPerRow`,32,1,4096)),i=[],a=-1,o=[],s=1;for(let t of e.blocks){let{start:e,end:n,bits:c}=t;if(e!==void 0&&n!==void 0&&n<e)throw m$(`Packet block ${e} - ${n} is invalid. End must be greater than start.`);if(e??=a+1,e!==a+1)throw m$(`Packet block ${e} - ${n??e} is not contiguous. It should start from ${a+1}.`);if(c===0)throw m$(`Packet block ${e} is invalid. Cannot have a zero bit field.`);for(n??=e+(c??1)-1,c??=n-e+1,a=n;o.length<=r+1&&i.length<Zwt;){let a=s*r-1;if(n<=a){o.push({start:e,end:n,bits:c,label:t.label}),n===a&&(i.push(o),o=[],s++);break}o.push({start:e,end:a,bits:a-e,label:t.label}),i.push(o),o=[],s++,e=a+1,c=n-e}}return o.length>0&&i.push(o),{type:`packet`,title:e.title||n,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,``):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
|
|
1031
|
+
`):void 0,bitsPerRow:r,rows:i}}var $wt=[{name:`packet-beta`,pattern:`packet-beta`},mY(`packet`),{name:`-`,pattern:`-`,longer:[dY]},{name:`+`,pattern:`+`},{name:`:`,pattern:`:`},aY,oY,sY,{name:`INT`,pattern:/0|[1-9][0-9]*(?!\.)/y},cY,lY,uY,dY,fY,pY];function eTt(e){let t=new bY(iY(e,$wt,`packet`),$wt,`packet`),n={$type:`Packet`,blocks:[]},r=()=>{if(t.kind!==-1)for(t.kind!==10&&t.fail(`a line break or the end of input`);t.kind===10;)t.i++};for(;t.kind===10;)t.i++;for(t.accept(0)||t.expect(1);t.kind!==-1;)switch(t.kind){case 10:t.i++;break;case 5:n.accDescr=vY(t.take()),r();break;case 6:n.accTitle=_Y(t.take()),r();break;case 7:n.title=gY(t.take()),r();break;case 8:case 3:{let e={$type:`PacketBlock`,label:``};t.accept(3)?e.bits=Number(t.expect(8)):(e.start=Number(t.take()),t.accept(2)&&(e.end=Number(t.expect(8)))),t.expect(4),e.label=yY(t.expect(9)),n.blocks.push(e),r();break}default:t.fail(`a field, a title, or a line break`)}return n}function h$(e,t,n,r,i,a=0){if(e===``||t<=0)return;let o=i.width(e,n,a);if(o<=t)return{text:e,size:n,width:o};let s=Math.max(r,Math.floor(n*t/o));for(;s>=r;){if(o=i.width(e,s,a),o<=t)return{text:e,size:s,width:o};s--}let c=Array.from(e),l=0,u=c.length-1;for(;l<u;){let e=l+u+1>>1;i.width(c.slice(0,e).join(``).trimEnd()+`…`,r,a)<=t?l=e:u=e-1}if(l===0)return;let d=c.slice(0,l).join(``).trimEnd()+`…`;return o=i.width(d,r,a),o<=t?{text:d,size:r,width:o}:void 0}function tTt(e,t,n){return qJ(n,r=>nTt(e,t,n,r))}function nTt(e,t,n,r){let i=n.fontSize??16,a=Math.round(i*.875),o=Math.round(i*.625),s=n.measurer??fq(n.fontFamily),c=n.padding??8,l=t.packet??{},u=p$(t,`rowHeight`,32,1,400),d=p$(t,`bitWidth`,32,1,400),f=p$(t,`paddingX`,5,0,400),p=p$(t,`paddingY`,5,0,400),m=l.showBits!==!1,h=l.bitOrder===`descending`,g=e.bitsPerRow,_=e.rows;if(r){let t=Math.max(1,Math.floor(((n.maxWidth??320)-2*c)/Math.min(d,18)));g=Math.min(g,Math.max(8,2**Math.floor(Math.log2(t))));let r=e.rows[e.rows.length-1],i=r?.[r.length-1]?.end??0;Math.ceil((i+1)/g)>1e4&&(g=e.bitsPerRow),d=Math.min(d,Math.max(18,((n.maxWidth??320)-2*c)/g));let a=e=>e.bits===e.end-e.start,o=[];for(let t of e.rows)for(let n of t){let t=o[o.length-1];t&&a(t)&&a(n)&&t.label===n.label&&n.start===t.end+1&&n.start%e.bitsPerRow===0?(t.end=n.end,t.bits=t.end-t.start):o.push({...n})}_=[];for(let e of o)for(let t=e.start;t<=e.end;){let n=Math.min(e.end,(Math.floor(t/g)+1)*g-1),r=Math.floor(t/g);(_[r]??(_[r]=[])).push({...e,start:t,end:n}),t=n+1}}let v=/* @__PURE__ */ new Map;if(r)for(let e of _)for(let t of e){let e=Math.max(1,(t.end-t.start+1)*d-Math.min(f,d-1)-6),n=XY(RK(t.label).trim(),s,a,e);v.set(t,n)}let y=m?o+4:0,b=_.map(e=>{let t=u;if(r)for(let n of e)t=Math.max(t,v.get(n).height+10);return t}),x=[],S=0;for(let e of b)x.push(S),S+=y+e+p;_.length&&(S-=p);let C=Math.min(f,d-1),w=_.length>0?g*d-C:0,T=UJ(e.title,!1,s,i,r?GJ(n):4e3,1),E=T.height>0?T.height+(S>0?12:0):0,D=/* @__PURE__ */ new Map,O=(e,t)=>{let n=D.get(e);return n||D.set(e,n=/* @__PURE__ */ new Map),n.has(t)||n.set(t,h$(RK(e).trim(),t,a,Math.round(i*.5),s)),n.get(t)},k=c+Math.max(0,(T.width-w)/2),A=``,j=``;_.forEach((e,t)=>{let n=c+x[t]+y,i=b[t];for(let t of e){let e=t.end-t.start+1,o=t.start%g,s=k+(h?g-o-e:o)*d,c=e*d-C,l=r?void 0:O(t.label,c-6);if(A+=`<g class="pele-node" data-id="${t.start}-${t.end}"><rect x="${K(s)}" y="${K(n)}" width="${K(c)}" height="${K(i)}" rx="${dJ}" fill="var(--_s)" stroke="var(--_b)"/>`+(r?gq(v.get(t),s+c/2,n+i/2,``):l&&l.size<=i?`<text x="${K(s+c/2)}" y="${K(n+i/2+l.size*.35)}"${l.size===a?``:` font-size="${K(l.size)}"`}>${pq(l.text)}</text>`:``)+`</g>`,!m)continue;let u=h?t.end:t.start,f=h?t.start:t.end;j+=e===1?`<text x="${K(s+c/2)}" y="${K(n-4)}" text-anchor="middle">${u}</text>`:`<text x="${K(s)}" y="${K(n-4)}">${u}</text><text x="${K(s+c)}" y="${K(n-4)}" text-anchor="end">${f}</text>`}});let M=Math.ceil(Math.max(w,T.width)+2*c),N=Math.ceil(S+E+2*c);return{svg:_J(`packet`,M,N,i,n,e,(A?`<g class="pele-packet-fields" font-size="${a}" text-anchor="middle">${A}</g>`:``)+(j?`<g class="pele-packet-bits" font-size="${o}" fill="var(--_m)">${j}</g>`:``)+gq(T,M/2,N-c-T.height/2,` class="pele-title" font-weight="var(--_tw)"`)),width:M,height:N,links:[]}}var rTt={type:`packet`,parse:(e,t,n)=>Qwt(eTt(e),t,n),render:tTt};function iTt(e,t){let n=/* @__PURE__ */ new Map;for(let{label:t,value:r}of e.sections){if(r<0)throw new NK(`"${t}" has invalid value: ${r}. Negative values are not allowed in pie charts. All slice values must be >= 0.`,`semantic`,{type:`pie`});n.has(t)||n.set(t,r)}return{type:`pie`,title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,``):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
|
|
1032
|
+
`):void 0,showData:e.showData,sections:n}}function aTt(e,t){let n=t;for(let t=e.charCodeAt(n);t>=48&&t<=57;t=e.charCodeAt(n))n++;return n}function oTt(){let e=0,t=0,n=-1;return(r,i)=>{let a=r.charCodeAt(i)===45?i+1:i;if((a<e||a>=t)&&(e=a,t=aTt(r,a),n=-1,t>a&&r.charCodeAt(t)===46)){let e=aTt(r,t+1),i=e-t-1;i>0&&r.charCodeAt(e)!==46?n=e:i>1&&(n=e-1)}return t===a?-1:n>=0?n:r.charCodeAt(a)===48?r.charCodeAt(a+1)===46?-1:a+1:r.charCodeAt(t)===46?t-1>a?t-1:-1:t}}var sTt=[mY(`showData`),mY(`pie`),{name:`:`,pattern:`:`},{name:`NUMBER_PIE`,pattern:/(?:-?[0-9]+\.[0-9]+(?!\.))|(?:-?(0|[1-9][0-9]*)(?!\.))/y,scanner:oTt,first:`-0123456789`},aY,oY,sY,cY,lY,uY,dY,fY,pY];function cTt(e){let t=new bY(iY(e,sTt,`pie`),sTt,`pie`),n={$type:`Pie`,showData:!1,sections:[]},r=()=>{if(t.kind!==-1)for(t.kind!==8&&t.fail(`a line break or the end of input`);t.kind===8;)t.i++};for(;t.kind===8;)t.i++;for(t.expect(1),n.showData=t.accept(0);t.kind!==-1;)switch(t.kind){case 8:t.i++;break;case 4:n.accDescr=vY(t.take()),r();break;case 5:n.accTitle=_Y(t.take()),r();break;case 6:n.title=gY(t.take()),r();break;case 7:{let e=yY(t.take());t.expect(2);let i=Number(t.expect(3));n.sections.push({$type:`PieSection`,label:e,value:i}),r();break}default:t.fail(`a section, a title, or a line break`)}return n}var lTt=120,g$=12,_$=26,v$=32,uTt=28;function y$(e,t){return e.pie?.[t]}function b$(e,t){return`${K(Math.sin(e)*t)},${K(-Math.cos(e)*t)}`}function dTt(e,t,n,r){if(t-e>=Math.PI*2-1e-9){let e=(e,t)=>`M0,${K(-e)}A${K(e)},${K(e)} 0 1 ${t} 0,${K(e)}A${K(e)},${K(e)} 0 1 ${t} 0,${K(-e)}Z`;return e(n,1)+(r>0?e(r,0):``)}let i=+(t-e>Math.PI);return r<=0?`M0,0L${b$(e,n)}A${K(n)},${K(n)} 0 ${i} 1 ${b$(t,n)}Z`:`M${b$(e,n)}A${K(n)},${K(n)} 0 ${i} 1 ${b$(t,n)}L${b$(t,r)}A${K(r)},${K(r)} 0 ${i} 0 ${b$(e,r)}Z`}function fTt(e,t,n){return WJ(n,lTt*2,140,(r,i)=>pTt(e,t,n,r/2,i))}function pTt(e,t,n,r,i){let a=n.fontSize??16,o=Math.round(a*.875),s=n.measurer??fq(n.fontFamily),c=n.padding??8,l=y$(t,`textPosition`),u=typeof l==`number`&&l>=0&&l<=1?l:.75,d=y$(t,`donutHole`),f=typeof d==`number`&&d>0&&d<=.9?d*r:0,p=String(y$(t,`legendPosition`)??`right`),m=i&&(p===`left`||p===`right`)?`bottom`:p,h=[...e.sections],g=0;for(let[,e]of h)g+=e;let _=h.map(([t,n])=>UJ(e.showData?`${t} [${n}]`:t,!1,s,o,4e3)),v=0;for(let e of _)v=Math.max(v,e.width);v+=_.length>0?g$+8:0;let y=_.length*_$,b=UJ(e.title,!1,s,a,GJ(n),1),x=b.height>0?b.height+16:0,S=h.map(([,e])=>{let t=g>0?e/g:0;return t*100>=1&&(t*100).toFixed(0)!==`0`?t:0}),C=S.map(e=>e===0||e>=.5?!1:2*r*u*Math.sin(e*Math.PI)<s.width((e*100).toFixed(0)+`%`,o,0)+6),w=C.includes(!0)?uTt:0,T=m===`left`||m===`right`||m===`center`?m:``,E=m===`top`||m===`bottom`,D=(r+w)*2,O=D,k=D;T===`left`||T===`right`?(O+=v>0?v$+v:0,k=Math.max(k,y)):E&&(O=Math.max(O,v),k+=y>0?20+y:0),O=Math.max(O,b.width);let A=c+(T===`left`?v+v$+D/2:T===`right`?D/2:O/2),j=c+x,M=j+(m===`top`?y+20+D/2:E?D/2:k/2),N=``,P=``,F=``,ee=0,te=r+uTt/2,I=[],ne=(e,t,n)=>I.every(r=>Math.abs(e-r.x)>=(n+r.width)/2+2||Math.abs(t-r.y)>=o+2);h.forEach(([e],t)=>{let n=S[t];if(n===0)return;let i=ee+n*Math.PI*2;N+=`<path class="pele-slice" data-id="${mq(e)}" d="${dTt(ee,i,r,f)}" fill="${hJ(t)}"/>`;let a=(ee+i)/2,c=(n*100).toFixed(0)+`%`;if(C[t]){let e=s.width(c,o,0),t=a;for(let n=0;n<360&&!ne(Math.sin(t)*te,-Math.cos(t)*te,e);n++)t+=2/te;let n=Math.sin(t)*te,r=-Math.cos(t)*te;I.push({x:n,y:r,width:e}),F+=`<text x="${K(n)}" y="${K(r+o*.35)}">${c}</text>`}else{let e=r*u;P+=`<text x="${K(Math.sin(a)*e)}" y="${K(-Math.cos(a)*e+o*.35)}">${c}</text>`}ee=i}),N===``&&(N=`<circle class="pele-slice" r="${r}" fill="none" stroke="var(--_b)"/>`);let re=``,ie,ae;T===`right`?(ie=A+D/2+v$,ae=j+(k-y)/2):T===`left`?(ie=c,ae=j+(k-y)/2):T===`center`?(ie=A-v/2,ae=M-y/2):(ie=c+(O-v)/2,ae=m===`top`?j:j+D+20),_.forEach((e,t)=>{let n=ae+t*_$+_$/2;re+=`<g class="pele-legend-item" data-id="${mq(h[t][0])}"><rect x="${K(ie)}" y="${K(n-g$/2)}" width="${g$}" height="${g$}" rx="2" fill="${hJ(t)}"/>`+gq(e,ie+g$+8+e.width/2,n,``)+`</g>`});let L=Math.ceil(O+2*c),oe=Math.ceil(k+x+2*c);return{svg:_J(`pie`,L,oe,a,n,e,gq(b,L/2,c+b.height/2,` class="pele-title" font-weight="var(--_tw)"`)+`<g class="pele-slices" transform="translate(${K(A)},${K(M)})" stroke="var(--_bg)" stroke-width="1" stroke-linejoin="round">${N}</g>`+(P?`<g class="pele-slice-labels" transform="translate(${K(A)},${K(M)})" font-size="${o}" text-anchor="middle" fill="var(--_bg)">${P}</g>`:``)+(F?`<g class="pele-slice-labels" transform="translate(${K(A)},${K(M)})" font-size="${o}" text-anchor="middle">${F}</g>`:``)+(re?`<g class="pele-legend" font-size="${o}">${re}</g>`:``)),width:L,height:oe,links:[]}}var mTt={type:`pie`,parse:(e,t,n)=>iTt(cTt(e),n),render:fTt},hTt=/^\d+$/,gTt=/^#?([\dA-Fa-f]{6}|[\dA-Fa-f]{3})$/,_Tt=/^\d+px$/;function x$(e,t,n){return new NK(`value for ${e} ${t} is invalid, please use a valid ${n}`,`semantic`,{type:`quadrantChart`})}function vTt(e){let t=e.trim(),n=t.indexOf(`:`);if(n===-1)return[t,`undefined`];let r=t.slice(n+1).trimStart(),i=r.indexOf(`:`);return[t.slice(0,n).trimEnd(),i===-1?r:r.slice(0,i).trimEnd()]}function yTt(e){let t={};for(let n of e){let[e,r]=vTt(n);if(e===`radius`){if(!hTt.test(r))throw x$(e,r,`number`);t.radius=parseInt(r)}else if(e===`color`){if(!gTt.test(r))throw x$(e,r,`hex code`);t.color=r}else if(e===`stroke-color`){if(!gTt.test(r))throw x$(e,r,`hex code`);t.strokeColor=r}else if(e===`stroke-width`){if(!_Tt.test(r))throw x$(e,r,`number of pixels (eg. 10px)`);t.strokeWidth=r}else throw new NK(`style named ${e} is not supported.`,`semantic`,{type:`quadrantChart`})}return t}function S$(e){return{text:e.text.trim(),type:e.type}}var bTt=class{type=`quadrantChart`;title;accTitle;accDescr;quadrants=[void 0,void 0,void 0,void 0];xAxisLeft;xAxisRight;yAxisBottom;yAxisTop;points=[];classes=/* @__PURE__ */ new Map;setQuadrant1Text(e){this.quadrants[0]=S$(e)}setQuadrant2Text(e){this.quadrants[1]=S$(e)}setQuadrant3Text(e){this.quadrants[2]=S$(e)}setQuadrant4Text(e){this.quadrants[3]=S$(e)}setXAxisLeftText(e){this.xAxisLeft=S$(e)}setXAxisRightText(e){this.xAxisRight=S$(e)}setYAxisBottomText(e){this.yAxisBottom=S$(e)}setYAxisTopText(e){this.yAxisTop=S$(e)}addPoint(e,t,n,r,i){this.points.push({x:Number(n),y:Number(r),text:S$(e),className:t,...yTt(i)})}addClass(e,t){this.classes.set(e,yTt(t))}setDiagramTitle(e){this.title=e}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,``)}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
1033
1033
|
`)}};function C$(e,t,n){for(let r=0;r<n.length;r++){let i=e.charCodeAt(t+r),a=n.charCodeAt(r);if(i!==a&&!(a>=97&&a<=122&&i===a-32))return!1}return!0}var xTt=/* @__PURE__ */ `$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`.split(`.`),w$=[41,4,6,8,9,19],T$=/* @__PURE__ */ new Uint8Array(128);for(let[e,t]of[[`:`,27],[`+`,28],[`,`,29],[`=`,30],[`*`,31],[`#`,32],[`_`,33],[`.`,34],[`&`,35],[`-`,36],[` \v\f`,38],[`;`,39],["!$%'`?\\/",40]])for(let n=0;n<e.length;n++)T$[e.charCodeAt(n)]=t;function STt(e){let t=e.length,n=[],r=[],i=[],a=[],o=0,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=(t,a,o)=>{n.push(t),r.push(e.slice(a,o)),i.push(a),s=o},_=e=>{a.push(o),o=e},v=()=>{a.length>0&&(o=a.pop())},y=n=>{let r=e.indexOf(`
|
|
1034
|
-
`,n);return r===-1?t:r},b=t=>{for(;e.charCodeAt(t)===32;)t++;return t},x=n=>{for(;n<t&&eq(e.charCodeAt(n));)n++;return n},S=n=>{let r=e.charCodeAt(n);if(r===49)return n+1;if(r!==48)return-1;let i=n+1;if(i<t&&!nq(e.charCodeAt(i))&&rq(e.charCodeAt(i+1)))for(i+=2;rq(e.charCodeAt(i));)i++;return i};e:for(;s<t;){let n=e.charCodeAt(s),r=e.charCodeAt(s+1);switch(o){case 0:break;case 1:case 2:case 3:g(w$[o],s,y(s)),v();continue;case 4:if(n===125)s++,v();else{let n=e.indexOf(`}`,s);g(9,s,n===-1?t:n)}continue;case 5:if(n===34)s++,v();else{let n=e.indexOf(`"`,s);g(19,s,n===-1?t:n)}continue;case 6:if(n===96&&r===34){s+=2,v();continue}if(n!==96&&n!==34){let n=s+1;for(let r=e.charCodeAt(n);n<t&&r!==96&&r!==34;r=e.charCodeAt(++n));g(18,s,n);continue}break e;case 7:if(aq(n)){let t=s+1;for(;aq(e.charCodeAt(t));)t++;g(20,s,t),v();continue}break e;case 8:{let t=S(s);if(t!==-1){g(22,s,t),_(9);continue}let n=x(s);if(e.charCodeAt(n)===93){s=b(n+1),v();continue}break e}case 9:{let t=x(s);if(e.charCodeAt(t)===44){s=x(t+1),o=10;continue}break e}case 10:{let e=S(s);if(e!==-1){g(23,s,e),v();continue}break e}}if(n===37&&r===37){s=y(s+2);continue}if(n!==125&&r===37&&e.charCodeAt(s+2)===37){s=y(s+3);continue}if(n===10||n===13){let t=s+1;for(let n=e.charCodeAt(t);n===10||n===13;n=e.charCodeAt(++t));g(2,s,t);continue}let i=n|32;if(i===116&&C$(e,s,`title`)&&!aq(e.charCodeAt(s+5))){g(3,s,s+5),_(1);continue}if(i===97&&C$(e,s,`acc`)){let t=C$(e,s+3,`descr`);if(t||C$(e,s+3,`title`)){let n=x(s+8),r=e.charCodeAt(n);if(r===58){g(t?7:5,s,x(n+1)),_(t?3:2);continue}if(r===123&&t){s=x(n+1),_(4);continue}}}let a=s;n===32&&((s<c||s>=l)&&(c=s,l=b(s)),a=l);let C=e.charCodeAt(a),w=C|32,T=0,E=0;if(w===120&&C$(e,a,`x-axis`))T=10,E=a+6;else if(w===121&&C$(e,a,`y-axis`))T=11,E=a+6;else if(C===45){if(a<u||a>=d)for(u=a,d=a;e.charCodeAt(d)===45;)d++;d-a>=2&&e.charCodeAt(d)===62&&(T=12,E=d+1)}else if(w===113&&C$(e,a,`quadrant`)){let t=e.charCodeAt(a+9);e.charCodeAt(a+8)===45&&t>=49&&t<=52?(T=13+t-49,E=a+10):C$(e,a+8,`chart`)&&(T=24,E=a+13)}if(T!==0)g(T,s,b(E));else if(i===99&&C$(e,s,`classdef`)&&!aq(e.charCodeAt(s+8)))g(17,s,s+8);else if(n===34)r===96?(s+=2,_(6)):(s++,_(5));else if(n===58&&r===58&&e.charCodeAt(s+2)===58)s+=3,_(7);else{if(n===58||eq(n)){let t=s;if(n!==58&&((s<f||s>=p)&&(f=s,p=x(s)),t=p),e.charCodeAt(t)===58&&((t+1<m||t+1>=h)&&(m=t+1,h=x(t+1)),e.charCodeAt(h)===91)){g(21,s,x(h+1)),_(8);continue}}if(iq(n)){let t=s+1;for(;iq(e.charCodeAt(t));)t++;g(25,s,t)}else if(n>=128){let t=s+1;for(;e.charCodeAt(t)>=128;)t++;g(26,s,t)}else if(rq(n)){let t=s+1;for(;rq(e.charCodeAt(t));)t++;g(37,s,t)}else if(T$[n]!==0)g(T$[n],s,s+1);else break}}return s<t?(n.push(1),r.push(``),i.push(s),{types:n,texts:r,starts:i}):(o<w$.length&&(n.push(w$[o]),r.push(``),i.push(t)),n.push(0),r.push(``),i.push(t),{types:n,texts:r,starts:i})}function E$(...e){let t=/* @__PURE__ */ new Uint8Array(42);for(let n of e)t[n]=1;return t}var CTt=E$(40,35,37,25,29,28,30,31,34,32,33,26),wTt=E$(25,37,36,29,27,35,32,31,26),D$=E$(25,37,27,38,32,36),TTt=E$(2,39,41),ETt=[`setQuadrant1Text`,`setQuadrant2Text`,`setQuadrant3Text`,`setQuadrant4Text`],DTt=`'STR', 'MD_STR', 'ALPHA', 'NUM', 'UNICODE_TEXT', 'PUNCTUATION'`;function OTt(e,t){let{types:n,texts:r,starts:i}=STt(e),a=0,o=t=>{let r=n[a];throw r===1?FK(`quadrantChart`,e,i[a],``,!0):FK(`quadrantChart`,e,i[a],`Expecting ${t}, got '${xTt[r]}'`)},s=e=>(n[a]!==e&&o(`'${xTt[e]}'`),r[a++]),c=e=>e===19||e===18||CTt[e]===1,l=()=>{let e=n[a];c(e)||o(DTt);let t=r[a++];for(;CTt[n[a]]===1||n[a]===38||n[a]===36;)t+=r[a++];return{text:t,type:e===18?`markdown`:`text`}},u=()=>{let e=[];for(;;){D$[n[a]]===0&&o(`'ALPHA', 'NUM', 'COLON', 'SPACE', 'BRKT', 'MINUS'`);let t=r[a++];for(;D$[n[a]]===1;)t+=r[a++];if(e.push(t.trim()),n[a]!==29)return e;a++}};for(;TTt[n[a]]===1||n[a]===38;)a++;for(s(24);n[a]!==0;){for(;n[a]===38;)a++;let e=n[a];switch(e){case 17:{a++,s(38),wTt[n[a]]===0&&o(`'ALPHA', 'NUM', 'UNICODE_TEXT'`);let e=r[a++];for(;wTt[n[a]]===1;)e+=r[a++];s(38),t.addClass(e,u());break}case 10:case 11:{a++;let r=l(),i;n[a]===12&&(a++,c(n[a])?i=l():r.text+=` ⟶ `),e===10?(t.setXAxisLeftText(r),i&&t.setXAxisRightText(i)):(t.setYAxisBottomText(r),i&&t.setYAxisTopText(i));break}case 13:case 14:case 15:case 16:a++,t[ETt[e-13]](l());break;case 3:a++,t.setDiagramTitle(s(4).trim());break;case 5:a++,t.setAccTitle(s(6).trim());break;case 7:a++,t.setAccDescription(s(8).trim());break;case 9:t.setAccDescription(r[a++].trim());break;default:if(c(e)){let e=l(),i=n[a]===20?r[a++]:``;s(21);let o=s(22),c=s(23);t.addPoint(e,i,o,c,D$[n[a]]===1?u():[])}}TTt[n[a]]===0&&o(`'NEWLINE', 'SEMI', 'EOF'`),a++}}var kTt=4,ATt=300;function O$(e,t){return e.quadrantChart?.[t]}function k$(e,t,n,r){let i=O$(e,t);return typeof i==`number`&&i>=0?Math.min(i,r):n}function jTt(e){return e.startsWith(`#`)?e:`#`+e}function MTt(e,t,n){let r=n.fontSize??16,i=Math.round(r*.875),a=Math.round(r*.75),o=n.measurer??fq(n.fontFamily),s=Math.round(Math.max(100,k$(t,`chartWidth`,500,4e3))),c=Math.round(
|
|
1035
|
-
`):void 0,axes:n,curves:r,options:i}}var A$=0,j$=0;function LTt(e,t){let n=t;for(let t=e.charCodeAt(n);t>=48&&t<=57;t=e.charCodeAt(n))n++;return n}function RTt(e,t){(t<A$||t>=j$)&&(A$=t,j$=LTt(e,t));let n=j$;if(n===t)return-1;let r=e.charCodeAt(n)===46;if(r){let t=LTt(e,n+1),r=t-n-1;if(r>0&&e.charCodeAt(t)!==46)return t;if(r>1)return t-1}return e.charCodeAt(t)===48?t+1:r?n-1>t?n-1:-1:n}var M$=
|
|
1036
|
-
`},{...
|
|
1037
|
-
`:i===`r`?`\r`:i===`t`?` `:i):n+=i}return n}function X$(e,t,n,r,i,a){let o=new xY(aY(e,t,`railroad`),t,`railroad`),s={$type:n,rules:[]};for(o.expect(0);;){let e=o.kind;if(e===r){let e=_Y(o.take()),t=e[0];s.title=(t===`"`||t===`'`)&&e.endsWith(t)?i(e):e}else if(e===r+1)s.accTitle=vY(o.take());else if(e===r+2)s.accDescr=yY(o.take());else break}for(;o.kind!==-1;)s.rules.push(a(o));return s}var $Tt=[];function Z$(e){let t=e,n=t.element??t.primary??t.suffix,r=t.alternatives??t.elements??(n?[n]:$Tt);if(t.base){r=[t.base];for(let e of t.postfixes)e.except&&r.push(e.except)}return r}var Q$=e=>({type:`terminal`,value:e}),$$=e=>({type:`nonterminal`,name:e}),e1=e=>({type:`special`,text:e}),t1=e=>({type:`optional`,element:e}),n1=(e,t,n=1/0)=>({type:`repetition`,element:e,min:t,max:n});function r1(e){return e.length===1?e[0]:{type:`sequence`,elements:e}}function i1(e){return e.length===1?e[0]:{type:`choice`,alternatives:e}}function a1(e,t){return e.rules.map(e=>({name:e.name,definition:eEt(e.definition,Z$,t)}))}function eEt(e,t,n){let r=[e],i=[t(e)],a=[[]];for(;;){let e=r.length-1,o=a[e];if(o.length<i[e].length){let n=i[e][o.length];r.push(n),i.push(t(n)),a.push([])}else{let t=n(r[e],o);if(e===0)return t;r.pop(),i.pop(),a.pop(),a[e-1].push(t)}}}var tEt=`0123456789`,nEt={name:`ABNF_RULENAME`,pattern:/[A-Za-z][A-Za-z0-9-]*/y,first:QTt},rEt={name:`ABNF_COMMENT`,pattern:/;[^\n\r]*/y,hidden:!0,first:`;`},iEt=[G$(`railroad-abnf-beta`,nEt),W$(`=`),W$(`;`,[rEt]),W$(`/`),W$(`(`),W$(`)`),W$(`[`),W$(`]`),V$,H$,U$,nEt,{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:tEt+`*`},{name:`ABNF_EXACT_REPEAT`,pattern:/[0-9]+/y,first:tEt},...J$(`ABNF`),rEt];function aEt(e,t,n,r){let i={$type:`AbnfConcatenation`,elements:[]};return t.alternatives.push(i),{alternation:t,concatenation:i,node:e,close:n,repeat:r}}function oEt(e){let t=[],n=aEt(void 0,{$type:`AbnfAlternation`,alternatives:[]},-2,void 0);for(;;){let r=e.kind===14||e.kind===15?e.take():void 0,i,a=e.kind;switch(a){case 12:i={$type:`AbnfStringLiteral`,value:e.take().slice(1,-1)};break;case 13:i={$type:`AbnfNumVal`,value:e.take()};break;case 11:i={$type:`AbnfRuleName`,name:e.take()};break;case 4:case 6:{e.i++;let i={$type:`AbnfAlternation`,alternatives:[]};t.push(n),n=aEt({$type:a===4?`AbnfGroup`:`AbnfOptionalGroup`,element:i},i,a+1,r);continue}default:e.fail(`a string, a number, a name, or an opening bracket`)}for(;;){n.concatenation.elements.push(r===void 0?{$type:`AbnfElement`,primary:i}:{$type:`AbnfElement`,repeat:r,primary:i});let a=e.kind;if(a===n.close)e.i++,i=n.node,r=n.repeat,n=t.pop();else{if(a===3)e.i++,n.concatenation={$type:`AbnfConcatenation`,elements:[]},n.alternation.alternatives.push(n.concatenation);else if(a!==12&&a!==13&&a!==11&&a!==4&&a!==6&&a!==14&&a!==15){if(t.length===0)return n.alternation;e.fail(`token of type '${iEt[n.close].name}'`)}break}}}}function sEt(e){return X$(e,iEt,`RailroadAbnf`,8,e=>e.slice(1,-1),e=>{let t=e.expect(11);e.expect(1);let n=oEt(e);return e.expect(2),{$type:`AbnfRule`,name:t,definition:n}})}function cEt(e,t){switch(e.$type){case`AbnfAlternation`:return i1(t);case`AbnfConcatenation`:return r1(t);case`AbnfElement`:{let n=e.repeat;if(!n)return t[0];let r=n.indexOf(`*`),i=r===-1,a=r>0||i?parseInt(n,10):0,o=i?a:r<n.length-1?parseInt(n.slice(r+1),10):1/0;return a===0&&o===1?t1(t[0]):n1(t[0],a,o)}case`AbnfStringLiteral`:case`AbnfNumVal`:return Q$(e.value);case`AbnfRuleName`:return $$(e.name);case`AbnfGroup`:return t[0];case`AbnfOptionalGroup`:return t1(t[0])}}var lEt=e=>a1(e,cEt);function uEt(e,t){if(e.charCodeAt(t)!==63)return-1;let n=!1;for(let r=t+1;r<e.length;r++){let t=e.charCodeAt(r);if(t===63)return n?r+1:-1;if(t===59)return-1;n||=!XTt(t)}return-1}var dEt=K$(`EBNF_ID`),fEt={name:`EBNF_SPECIAL_SEQUENCE`,pattern:/\?(?=[^?;]*[^?\s;][^?;]*\?)[^?;]*\?/y,first:`?`,scanner:()=>uEt},pEt=J$(`EBNF`),mEt={name:`EBNF_ISO_COMMENT`,pattern:/\(\*[\s\S]*?\*\)/y,hidden:!0,first:`(`,opener:/\(\*/y},hEt=[G$(`railroad-ebnf-beta`,dEt),W$(`::=`),W$(`=`),W$(`;`),W$(`|`),W$(`,`),W$(`(`,[mEt]),W$(`)`),W$(`[`),W$(`]`),W$(`{`),W$(`}`),W$(`?`,[fEt]),W$(`*`),W$(`+`),W$(`-`,[pEt[1]]),V$,H$,U$,dEt,q$(`EBNF_STRING`),fEt,...pEt,{name:`EBNF_BLOCK_COMMENT`,pattern:/\/\*[\s\S]*?\*\//y,hidden:!0,first:`/`,opener:/\/\*/y},mEt];function gEt(e,t,n,r){let i={$type:`EbnfSequence`,elements:[]};return t.alternatives.push(i),{choice:t,sequence:i,term:void 0,node:e,close:n,except:r}}var _Et=[`EbnfGroup`,`EbnfOptional`,`EbnfRepetition`];function vEt(e){let t=[],n=gEt(void 0,{$type:`EbnfChoice`,alternatives:[]},-2,!1),r=!1;for(;;){let i,a=e.kind;switch(a){case 20:i={$type:`EbnfTerminal`,value:Y$(e.take())};break;case 19:i={$type:`EbnfNonTerminal`,name:e.take()};break;case 21:i={$type:`EbnfSpecial`,text:e.take().slice(1,-1).trim()};break;case 6:case 8:case 10:{e.i++;let i={$type:`EbnfChoice`,alternatives:[]};t.push(n),n=gEt({$type:_Et[a-6>>1],element:i},i,a+1,r),r=!1;continue}default:e.fail(`a terminal, a name, or an opening bracket`)}for(;;){r?(n.term.postfixes.push({$type:`EbnfExceptionPostfix`,except:i}),r=!1):(n.term={$type:`EbnfTerm`,base:i,postfixes:[]},n.sequence.elements.push(n.term));let a=n.term.postfixes;for(;;){let t=e.kind;if(t===12)a.push({$type:`EbnfOptionalPostfix`,operator:e.take()});else if(t===13)a.push({$type:`EbnfZeroOrMorePostfix`,operator:e.take()});else if(t===14)a.push({$type:`EbnfOneOrMorePostfix`,operator:e.take()});else break}let o=e.kind;if(o===n.close)e.i++,i=n.node,r=n.except,n=t.pop();else{if(o===15)e.i++,r=!0;else if(o===5)e.i++;else if(o===4)e.i++,n.sequence={$type:`EbnfSequence`,elements:[]},n.choice.alternatives.push(n.sequence);else if(o!==20&&o!==19&&o!==21&&o!==6&&o!==8&&o!==10){if(t.length===0)return n.choice;e.fail(`token of type '${hEt[n.close].name}'`)}break}}}}function yEt(e){return X$(e,hEt,`RailroadEbnf`,16,Y$,e=>{let t=e.expect(19);e.accept(2)||e.expect(1);let n={$type:`EbnfRule`,name:t,definition:vEt(e)};return e.expect(3),n})}function bEt(e,t){switch(e.$type){case`EbnfChoice`:return i1(t);case`EbnfSequence`:return r1(t);case`EbnfTerm`:{let n=t[0],r=1;for(let i of e.postfixes)n=i.$type===`EbnfOptionalPostfix`?t1(n):i.$type===`EbnfExceptionPostfix`?{type:`sequence`,elements:[n,Q$(`-`),t[r++]]}:n1(n,+(i.$type===`EbnfOneOrMorePostfix`));return n}case`EbnfTerminal`:return Q$(e.value);case`EbnfNonTerminal`:return $$(e.name);case`EbnfSpecial`:return e1(e.text);case`EbnfGroup`:return t[0];case`EbnfOptional`:return t1(t[0]);case`EbnfRepetition`:return n1(t[0],0)}}var xEt=e=>a1(e,bEt),o1=K$(`RR_ID`),s1=e=>W$(e,[o1]),SEt=[G$(`railroad-beta`,o1),s1(`nonterminal`),s1(`zeroOrMore`),s1(`oneOrMore`),s1(`sequence`),s1(`optional`),s1(`terminal`),s1(`special`),s1(`choice`),W$(`=`),W$(`;`),W$(`(`),W$(`,`),W$(`)`),V$,H$,U$,o1,q$(`RR_STRING`),...J$(`RR`),{name:`RR_BLOCK_COMMENT`,pattern:/\/\*[\s\S]*?\*\//y,hidden:!0,first:`/`,opener:/\/\*/y}];function c1(e){e.i++,e.expect(11);let t=Y$(e.expect(18));return e.expect(13),t}function l1(e){return{$type:e,element:void 0}}function CEt(e){let t=[];for(;;){let n;switch(e.kind){case 6:n={$type:`RailroadTerminalExpr`,value:c1(e)};break;case 1:n={$type:`RailroadNonTerminalExpr`,name:c1(e)};break;case 7:n={$type:`RailroadSpecialExpr`,text:c1(e)};break;case 4:n={$type:`RailroadSequenceExpr`,elements:[]};break;case 8:n={$type:`RailroadChoiceExpr`,alternatives:[]};break;case 5:n=l1(`RailroadOptionalExpr`);break;case 3:n=l1(`RailroadOneOrMoreExpr`);break;case 2:n=l1(`RailroadZeroOrMoreExpr`);break;default:e.fail(`an expression`)}if(`elements`in n||`alternatives`in n||`element`in n)e.i++,e.expect(11),t.push(n);else for(;;){let r=t[t.length-1];if(r===void 0)return n;if(`element`in r)r.element=n;else if((`elements`in r?r.elements:r.alternatives).push(n),e.accept(12))break;e.expect(13),t.pop(),n=r}}}function wEt(e){return X$(e,SEt,`Railroad`,14,Y$,e=>{let t=e.expect(17);e.expect(9);let n=CEt(e);return e.expect(10),{$type:`RailroadRule`,name:t,definition:n}})}function TEt(e,t){switch(e.$type){case`RailroadTerminalExpr`:return Q$(e.value);case`RailroadNonTerminalExpr`:return $$(e.name);case`RailroadSpecialExpr`:return e1(e.text);case`RailroadSequenceExpr`:return r1(t);case`RailroadChoiceExpr`:return i1(t);case`RailroadOptionalExpr`:return t1(t[0]);default:return n1(t[0],+(e.$type===`RailroadOneOrMoreExpr`))}}var EEt=e=>a1(e,TEt),DEt=K$(`PEG_ID`),OEt=[G$(`railroad-peg-beta`,DEt),W$(`<-`),W$(`;`),W$(`/`),W$(`&`),W$(`!`),W$(`?`),W$(`*`),W$(`+`),W$(`(`),W$(`)`),W$(`.`),V$,H$,U$,DEt,q$(`PEG_STRING`),...J$(`PEG`),{name:`PEG_LINE_COMMENT`,pattern:/#[^\n\r]*/y,hidden:!0,first:`#`}];function kEt(e,t,n){let r={$type:`PegSequence`,elements:[]};return t.alternatives.push(r),{choice:t,sequence:r,node:e,operator:n}}function AEt(e){let t=[],n=kEt(void 0,{$type:`PegOrderedChoice`,alternatives:[]},void 0);for(;;){let r=e.kind===4||e.kind===5?e.take():void 0,i;switch(e.kind){case 16:i={$type:`PegLiteral`,value:Y$(e.take())};break;case 15:i={$type:`PegIdentifier`,name:e.take()};break;case 11:i={$type:`PegAny`,dot:e.take()};break;case 9:{e.i++;let i={$type:`PegOrderedChoice`,alternatives:[]};t.push(n),n=kEt({$type:`PegGroup`,element:i},i,r);continue}default:e.fail(`a literal, a name, a dot, or an opening parenthesis`)}for(;;){let a={$type:`PegSuffix`,primary:i};(e.kind===6||e.kind===7||e.kind===8)&&(a.operator=e.take()),n.sequence.elements.push(r===void 0?{$type:`PegPrefix`,suffix:a}:{$type:`PegPrefix`,operator:r,suffix:a});let o=e.kind;if(o===10&&t.length>0)e.i++,i=n.node,r=n.operator,n=t.pop();else{if(o===3)e.i++,n.sequence={$type:`PegSequence`,elements:[]},n.choice.alternatives.push(n.sequence);else if(o!==4&&o!==5&&o!==16&&o!==15&&o!==11&&o!==9){if(t.length===0)return n.choice;e.fail(`token of type ')'`)}break}}}}function jEt(e){return X$(e,OEt,`RailroadPeg`,12,Y$,e=>{let t=e.expect(15);e.expect(1);let n={$type:`PegRule`,name:t,definition:AEt(e)};return e.expect(2),n})}function MEt(e){switch(e.type){case`terminal`:return`"${e.value}"`;case`nonterminal`:return e.name;case`special`:return e.text;default:return`(...)`}}function NEt(e,t){let n=t[0];switch(e.$type){case`PegOrderedChoice`:return i1(t);case`PegSequence`:return r1(t);case`PegPrefix`:return e.operator?e1(e.operator+MEt(n)):n;case`PegSuffix`:return e.operator?e.operator===`?`?t1(n):n1(n,+(e.operator===`+`)):n;case`PegLiteral`:return Q$(e.value);case`PegIdentifier`:return $$(e.name);case`PegAny`:return e1(e.dot);case`PegGroup`:return n}}var PEt=e=>a1(e,NEt),FEt=class{type=`railroad`;notation=`railroad`;title;accTitle;accDescr;rules=[];byName=/* @__PURE__ */ new Map;setTitle(e){this.title=e}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,``)}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
1034
|
+
`,n);return r===-1?t:r},b=t=>{for(;e.charCodeAt(t)===32;)t++;return t},x=n=>{for(;n<t&&eq(e.charCodeAt(n));)n++;return n},S=n=>{let r=e.charCodeAt(n);if(r===49)return n+1;if(r!==48)return-1;let i=n+1;if(i<t&&!nq(e.charCodeAt(i))&&rq(e.charCodeAt(i+1)))for(i+=2;rq(e.charCodeAt(i));)i++;return i};e:for(;s<t;){let n=e.charCodeAt(s),r=e.charCodeAt(s+1);switch(o){case 0:break;case 1:case 2:case 3:g(w$[o],s,y(s)),v();continue;case 4:if(n===125)s++,v();else{let n=e.indexOf(`}`,s);g(9,s,n===-1?t:n)}continue;case 5:if(n===34)s++,v();else{let n=e.indexOf(`"`,s);g(19,s,n===-1?t:n)}continue;case 6:if(n===96&&r===34){s+=2,v();continue}if(n!==96&&n!==34){let n=s+1;for(let r=e.charCodeAt(n);n<t&&r!==96&&r!==34;r=e.charCodeAt(++n));g(18,s,n);continue}break e;case 7:if(aq(n)){let t=s+1;for(;aq(e.charCodeAt(t));)t++;g(20,s,t),v();continue}break e;case 8:{let t=S(s);if(t!==-1){g(22,s,t),_(9);continue}let n=x(s);if(e.charCodeAt(n)===93){s=b(n+1),v();continue}break e}case 9:{let t=x(s);if(e.charCodeAt(t)===44){s=x(t+1),o=10;continue}break e}case 10:{let e=S(s);if(e!==-1){g(23,s,e),v();continue}break e}}if(n===37&&r===37){s=y(s+2);continue}if(n!==125&&r===37&&e.charCodeAt(s+2)===37){s=y(s+3);continue}if(n===10||n===13){let t=s+1;for(let n=e.charCodeAt(t);n===10||n===13;n=e.charCodeAt(++t));g(2,s,t);continue}let i=n|32;if(i===116&&C$(e,s,`title`)&&!aq(e.charCodeAt(s+5))){g(3,s,s+5),_(1);continue}if(i===97&&C$(e,s,`acc`)){let t=C$(e,s+3,`descr`);if(t||C$(e,s+3,`title`)){let n=x(s+8),r=e.charCodeAt(n);if(r===58){g(t?7:5,s,x(n+1)),_(t?3:2);continue}if(r===123&&t){s=x(n+1),_(4);continue}}}let a=s;n===32&&((s<c||s>=l)&&(c=s,l=b(s)),a=l);let C=e.charCodeAt(a),w=C|32,T=0,E=0;if(w===120&&C$(e,a,`x-axis`))T=10,E=a+6;else if(w===121&&C$(e,a,`y-axis`))T=11,E=a+6;else if(C===45){if(a<u||a>=d)for(u=a,d=a;e.charCodeAt(d)===45;)d++;d-a>=2&&e.charCodeAt(d)===62&&(T=12,E=d+1)}else if(w===113&&C$(e,a,`quadrant`)){let t=e.charCodeAt(a+9);e.charCodeAt(a+8)===45&&t>=49&&t<=52?(T=13+t-49,E=a+10):C$(e,a+8,`chart`)&&(T=24,E=a+13)}if(T!==0)g(T,s,b(E));else if(i===99&&C$(e,s,`classdef`)&&!aq(e.charCodeAt(s+8)))g(17,s,s+8);else if(n===34)r===96?(s+=2,_(6)):(s++,_(5));else if(n===58&&r===58&&e.charCodeAt(s+2)===58)s+=3,_(7);else{if(n===58||eq(n)){let t=s;if(n!==58&&((s<f||s>=p)&&(f=s,p=x(s)),t=p),e.charCodeAt(t)===58&&((t+1<m||t+1>=h)&&(m=t+1,h=x(t+1)),e.charCodeAt(h)===91)){g(21,s,x(h+1)),_(8);continue}}if(iq(n)){let t=s+1;for(;iq(e.charCodeAt(t));)t++;g(25,s,t)}else if(n>=128){let t=s+1;for(;e.charCodeAt(t)>=128;)t++;g(26,s,t)}else if(rq(n)){let t=s+1;for(;rq(e.charCodeAt(t));)t++;g(37,s,t)}else if(T$[n]!==0)g(T$[n],s,s+1);else break}}return s<t?(n.push(1),r.push(``),i.push(s),{types:n,texts:r,starts:i}):(o<w$.length&&(n.push(w$[o]),r.push(``),i.push(t)),n.push(0),r.push(``),i.push(t),{types:n,texts:r,starts:i})}function E$(...e){let t=/* @__PURE__ */ new Uint8Array(42);for(let n of e)t[n]=1;return t}var CTt=E$(40,35,37,25,29,28,30,31,34,32,33,26),wTt=E$(25,37,36,29,27,35,32,31,26),D$=E$(25,37,27,38,32,36),TTt=E$(2,39,41),ETt=[`setQuadrant1Text`,`setQuadrant2Text`,`setQuadrant3Text`,`setQuadrant4Text`],DTt=`'STR', 'MD_STR', 'ALPHA', 'NUM', 'UNICODE_TEXT', 'PUNCTUATION'`;function OTt(e,t){let{types:n,texts:r,starts:i}=STt(e),a=0,o=t=>{let r=n[a];throw r===1?FK(`quadrantChart`,e,i[a],``,!0):FK(`quadrantChart`,e,i[a],`Expecting ${t}, got '${xTt[r]}'`)},s=e=>(n[a]!==e&&o(`'${xTt[e]}'`),r[a++]),c=e=>e===19||e===18||CTt[e]===1,l=()=>{let e=n[a];c(e)||o(DTt);let t=r[a++];for(;CTt[n[a]]===1||n[a]===38||n[a]===36;)t+=r[a++];return{text:t,type:e===18?`markdown`:`text`}},u=()=>{let e=[];for(;;){D$[n[a]]===0&&o(`'ALPHA', 'NUM', 'COLON', 'SPACE', 'BRKT', 'MINUS'`);let t=r[a++];for(;D$[n[a]]===1;)t+=r[a++];if(e.push(t.trim()),n[a]!==29)return e;a++}};for(;TTt[n[a]]===1||n[a]===38;)a++;for(s(24);n[a]!==0;){for(;n[a]===38;)a++;let e=n[a];switch(e){case 17:{a++,s(38),wTt[n[a]]===0&&o(`'ALPHA', 'NUM', 'UNICODE_TEXT'`);let e=r[a++];for(;wTt[n[a]]===1;)e+=r[a++];s(38),t.addClass(e,u());break}case 10:case 11:{a++;let r=l(),i;n[a]===12&&(a++,c(n[a])?i=l():r.text+=` ⟶ `),e===10?(t.setXAxisLeftText(r),i&&t.setXAxisRightText(i)):(t.setYAxisBottomText(r),i&&t.setYAxisTopText(i));break}case 13:case 14:case 15:case 16:a++,t[ETt[e-13]](l());break;case 3:a++,t.setDiagramTitle(s(4).trim());break;case 5:a++,t.setAccTitle(s(6).trim());break;case 7:a++,t.setAccDescription(s(8).trim());break;case 9:t.setAccDescription(r[a++].trim());break;default:if(c(e)){let e=l(),i=n[a]===20?r[a++]:``;s(21);let o=s(22),c=s(23);t.addPoint(e,i,o,c,D$[n[a]]===1?u():[])}}TTt[n[a]]===0&&o(`'NEWLINE', 'SEMI', 'EOF'`),a++}}var kTt=4,ATt=300;function O$(e,t){return e.quadrantChart?.[t]}function k$(e,t,n,r){let i=O$(e,t);return typeof i==`number`&&i>=0?Math.min(i,r):n}function jTt(e){return e.startsWith(`#`)?e:`#`+e}function MTt(e,t,n){let r=n.fontSize??16,i=Math.round(r*.875),a=Math.round(r*.75),o=n.measurer??fq(n.fontFamily),s=Math.round(Math.max(100,k$(t,`chartWidth`,500,4e3))),c=Math.round(KJ(n,s,280)),l=Math.round(Math.max(100,k$(t,`chartHeight`,500,4e3))*c/s),u=k$(t,`quadrantPadding`,n.padding??8,200),d=k$(t,`xAxisLabelPadding`,5,200),f=k$(t,`yAxisLabelPadding`,5,200),p=e.points.length>0,m=(e,t,n)=>UJ(e?.text,e?.type===`markdown`,o,t,Math.max(n,40)),h=UJ(e.title,!1,o,r,Math.max(c-2*u,40),1),g=k$(t,`titlePadding`,10,200),_=h.height>0?h.height+g:0,v=!!(e.xAxisLeft?.text||e.xAxisRight?.text),y=!!(e.yAxisBottom?.text||e.yAxisTop?.text),b=p||O$(t,`xAxisPosition`)===`bottom`,x=O$(t,`yAxisPosition`)===`right`,S=c-2*u,C=m(e.xAxisLeft,i,e.xAxisRight?S/2-16:S),w=m(e.xAxisRight,i,S/2-16),T=Math.max(C.height,w.height),E=v?T+d:0,D=l-2*u-_-E,O=m(e.yAxisBottom,i,e.yAxisTop?D/2-16:D),k=m(e.yAxisTop,i,D/2-16),A=Math.max(O.height,k.height),j=y?A+f:0,M=u+(x?0:j),N=u+_+(b?0:E),P=Math.max(0,S-j),F=Math.max(0,D),ee=Math.max(0,(P-kTt)/2),te=Math.max(0,(F-kTt)/2),I=[M+ee,N,M+P-ee,N+F,M,N+te,M+P,N+F-te],ne=(e,t,n,r,i)=>{for(let a=e;a<I.length;a+=4)if(t<I[a+2]&&r>I[a]&&n<I[a+3]&&i>I[a+1])return!1;return!0},re=k$(t,`quadrantTextTopPadding`,5,200),ie=``;for(let t=0;t<4;t++){let n=t===0||t===3?M+P-ee:M,i=t<2?N:N+F-te,a=m(e.quadrants[t],r,ee-16),o=n+ee/2,s=p?i+re+a.height/2:i+te/2;I.push(o-a.width/2,s-a.height/2,o+a.width/2,s+a.height/2),ie+=`<g class="pele-quadrant" data-id="${t+1}"><rect x="${K(n)}" y="${K(i)}" width="${K(ee)}" height="${K(te)}" rx="${dJ}"/>`+gq(a,o,s,` class="pele-label" fill="var(--_fg)" stroke="none"`)+`</g>`}let ae=``;if(v){let e=b?N+F+d+T/2:N-d-T/2;ae+=gq(C,w.height>0?M+P/4:M+C.width/2,e,``)+gq(w,M+P*3/4,e,``)}if(y){let e=x?M+P+f+A/2:M-f-A/2,t=(t,n)=>t.height>0?`<g transform="translate(${K(e)},${K(n)}) rotate(-90)">${gq(t,0,0,``)}</g>`:``;ae+=t(O,k.height>0?N+F*3/4:N+F-O.width/2)+t(k,N+F/4)}let L=k$(t,`pointRadius`,5,200),oe=k$(t,`pointTextPadding`,5,200),se=hJ(0),ce=[],le=[];for(let t of e.points){if(!(t.x>=0&&t.x<=1&&t.y>=0&&t.y<=1))continue;let n=e.classes.get(t.className),r=Math.min(t.radius??n?.radius??L,2e3),i=t.color??n?.color,o=t.strokeColor??n?.strokeColor,s=t.strokeWidth??n?.strokeWidth,c=[];i&&c.push(`fill:`+jTt(i)),s&&(o&&c.push(`stroke:`+jTt(o)),c.push(`stroke-width:`+s));let l=M+t.x*P,u=N+(1-t.y)*F;ce.push({cx:l,cy:u,reach:r+(s?Math.min(parseInt(s),400)/2:0),text:m(t.text,a,200)}),le.push(`<circle class="pele-point${mJ(t.className)}" data-id="${mq(t.text.text)}" cx="${K(l)}" cy="${K(u)}" r="${K(r)}"${s&&!o?` stroke="${se}"`:``}${pJ(c).shape}/>`)}let ue=ce.length<=ATt;if(ue)for(let{cx:e,cy:t,reach:n}of ce)I.push(e-n,t-n,e+n,t+n);let de=``;for(let{cx:e,cy:t,reach:n,text:r}of ce){let i=r.width/2,a=r.size*.6+(r.height-r.lineHeight)/2,o=n+oe,s=[e,t+o+a,e,t-o-a,e+o+i,t,e-o-i,t],c=e,l=s[1],u=!1;for(let e=0;e<16;e+=2){let t=e%8,n=t<4&&r.width<P?Math.min(Math.max(s[t],M+i),M+P-i):s[t],o=s[t+1];if(n-i<M||n+i>M+P||o-a<N||o+a>N+F)continue;let d=!ue||ne(e<8?0:8,n-i,o-a,n+i,o+a);if((!u||d)&&(c=n,l=o,u=!0),d)break}ue&&I.push(c-i,l-a,c+i,l+a),de+=gq(r,c,l,` class="pele-label"`)}return{svg:_J(`quadrantChart`,c,l,r,n,e,gq(h,c/2,g/2+h.height/2,` class="pele-title" font-weight="var(--_tw)"`)+`<g class="pele-quadrants" fill="var(--_s)" stroke="var(--_b)">${ie}</g>`+(ae?`<g class="pele-axis-labels" font-size="${i}" fill="var(--_m)">${ae}</g>`:``)+(ce.length>0?`<g class="pele-points" fill="${se}">${le.reverse().join(``)}</g><g class="pele-point-labels" font-size="${a}">${de}</g>`:``)),width:c,height:l,links:[]}}var NTt={type:`quadrantChart`,parse(e,t,n){let r=new bTt;return r.title=n,OTt(e,r),r},render:MTt},PTt=32;function FTt(e){return new NK(e,`semantic`,{type:`radar`})}function ITt(e,t){let n=e.axes.map(e=>({name:e.name,label:e.label??e.name})),r=e.curves.map(e=>{let t;if(e.entries[0].axis===void 0)t=e.entries.map(e=>e.value);else{if(n.length===0)throw FTt(`Axes must be populated before curves for reference entries`);let r=/* @__PURE__ */ new Map;for(let t of e.entries)t.axis!==void 0&&!r.has(t.axis.$refText)&&r.set(t.axis.$refText,t.value);t=n.map(e=>{let t=r.get(e.name);if(t===void 0)throw FTt(`Missing entry for axis `+e.label);return t})}return{name:e.name,label:e.label??e.name,entries:t}}),i={showLegend:!0,ticks:5,max:null,min:0,graticule:`circle`};for(let t of e.options)t.name===`showLegend`?i.showLegend=t.value:t.name===`graticule`?i.graticule=t.value:i[t.name]=t.value;return i.ticks>PTt&&(i.ticks=PTt),{type:`radar`,title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,``):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
|
|
1035
|
+
`):void 0,axes:n,curves:r,options:i}}var A$=0,j$=0;function LTt(e,t){let n=t;for(let t=e.charCodeAt(n);t>=48&&t<=57;t=e.charCodeAt(n))n++;return n}function RTt(e,t){(t<A$||t>=j$)&&(A$=t,j$=LTt(e,t));let n=j$;if(n===t)return-1;let r=e.charCodeAt(n)===46;if(r){let t=LTt(e,n+1),r=t-n-1;if(r>0&&e.charCodeAt(t)!==46)return t;if(r>1)return t-1}return e.charCodeAt(t)===48?t+1:r?n-1>t?n-1:-1:n}var M$=aY.pattern,N$=/[\t ]*accDescr\s*{/y,P$=-2;function zTt(e,t){return N$.lastIndex=t,N$.test(e)&&(P$===-2&&(P$=e.lastIndexOf(`}`)),N$.lastIndex>P$)?-1:(M$.lastIndex=t,M$.test(e)?M$.lastIndex:-1)}var F$={name:`ID`,pattern:/[\w]([-\w]*\w)?/y},I$=e=>({name:e,pattern:e,longer:[F$]}),L$=e=>({name:e,pattern:e}),BTt=[L$(`radar-beta:`),{...mY(`radar-beta`),longer:[F$]},I$(`showLegend`),I$(`graticule`),I$(`curve`),I$(`ticks`),I$(`axis`),I$(`max`),I$(`min`),L$(`:`),L$(`,`),L$(`[`),L$(`]`),L$(`{`),L$(`}`),{name:`GRATICULE`,pattern:/circle|polygon/y},{name:`BOOLEAN`,pattern:/true|false/y},{...aY,match:zTt},oY,sY,{name:`NUMBER`,pattern:/(?:[0-9]+\.[0-9]+(?!\.))|(?:0|[1-9][0-9]*(?!\.))/y,match:RTt},cY,F$,lY,uY,dY,fY,pY];function VTt(e){return A$=j$=0,P$=-2,iY(e,BTt,`radar`)}function HTt(e){let t=new bY(VTt(e),BTt,`radar`),n={$type:`Radar`,axes:[],curves:[],options:[]},r=()=>{for(;t.kind===23;)t.i++},i=()=>{t.kind!==-1&&(t.kind!==23&&t.fail(`a line break or the end of input`),r())},a=()=>{if(!t.accept(11))return;let e=yY(t.expect(21));return t.expect(12),e},o=e=>{if(!e)return{$type:`Entry`,value:Number(t.expect(20))};let n={$refText:t.expect(22)};return t.accept(9),{$type:`Entry`,axis:n,value:Number(t.expect(20))}},s=()=>{let e=t.expect(22),n=a(),i={$type:`Curve`,name:e,entries:[]};n!==void 0&&(i.label=n),t.expect(13),r(),t.kind!==20&&t.kind!==22&&t.fail(`a number or an axis name`);let s=t.kind===22;for(i.entries.push(o(s));t.accept(10);)r(),i.entries.push(o(s));return r(),t.expect(14),i},c=()=>{let e={$type:`Axis`,name:t.expect(22)},n=a();return n!==void 0&&(e.label=n),e},l=()=>{let e=t.kind,n=t.take(),r;return r=e===2?t.expect(16)===`true`:e===3?t.expect(15):Number(t.expect(20)),{$type:`Option`,name:n,value:r}},u=()=>t.kind===2||t.kind===5||t.kind===7||t.kind===8||t.kind===3;for(r(),t.accept(0)||(t.expect(1),t.accept(9)),r();t.kind!==-1;)switch(t.kind){case 23:t.i++;break;case 17:n.accDescr=vY(t.take()),i();break;case 18:n.accTitle=_Y(t.take()),i();break;case 19:n.title=gY(t.take()),i();break;case 6:t.i++;do n.axes.push(c());while(t.accept(10));break;case 4:t.i++;do n.curves.push(s());while(t.accept(10));break;default:for(u()||t.fail(`an axis, a curve, an option, a title, or a line break`),n.options.push(l());t.accept(10);)u()||t.fail(`an option`),n.options.push(l())}return n}var R$=12,z$=26,UTt=24;function B$(e,t,n,r,i){let a=e.radar?.[t];return typeof a==`number`&&a>=r?Math.min(a,i):n}function WTt(e,t,n,r){return r*(Math.min(Math.max(e,t),n)-t)/(n-t)}function GTt(e,t){let n=e.length,r=`M${K(e[0].x)},${K(e[0].y)}`;for(let i=0;i<n;i++){let a=e[(i-1+n)%n],o=e[i],s=e[(i+1)%n],c=e[(i+2)%n];r+=` C${K(o.x+(s.x-a.x)*t)},${K(o.y+(s.y-a.y)*t)} ${K(s.x-(c.x-o.x)*t)},${K(s.y-(c.y-o.y)*t)} ${K(s.x)},${K(s.y)}`}return r+` Z`}function KTt(e){let t=``;for(let n of e)t+=(t?` `:``)+K(n.x)+`,`+K(n.y);return t}function qTt(e,t,n){let r=B$(t,`width`,320,1,4e3);return WJ(n,r,160,(i,a)=>JTt(e,t,n,i,B$(t,`height`,320,1,4e3)*i/r,a))}function JTt(e,t,n,r,i,a){let o=n.fontSize??16,s=Math.round(o*.875),c=n.measurer??fq(n.fontFamily),l=n.padding??8,u=B$(t,`axisScaleFactor`,1,0,10),d=B$(t,`axisLabelFactor`,1.05,0,10),f=B$(t,`curveTension`,.17,0,1),p=Math.min(r,i)/2,{axes:m,curves:h}=e,{ticks:g,graticule:_,min:v}=e.options,y=m.length,b=m.map((e,t)=>{let n=2*Math.PI*t/y-Math.PI/2;return{x:Math.cos(n),y:Math.sin(n)}}),x=e.options.max;if(x===null){x=-1/0;for(let e of h)for(let t of e.entries)t>x&&(x=t)}let S=-r/2-B$(t,`marginLeft`,16,0,2e3),C=r/2+B$(t,`marginRight`,16,0,2e3),w=-i/2-B$(t,`marginTop`,16,0,2e3),T=i/2+B$(t,`marginBottom`,16,0,2e3),E=``;for(let e=0;e<g;e++){let t=Math.min(p,p*(e+1)/g);E+=_===`circle`?`<circle r="${K(t)}"/>`:`<polygon points="${KTt(b.map(e=>({x:e.x*t,y:e.y*t})))}"/>`}let D=``,O=``;b.forEach((e,t)=>{let n=p*u;D+=`M0,0L${K(e.x*n)},${K(e.y*n)}`;let r=UJ(m[t].label,!1,c,s,4e3),i=p*d+6,a=e.x*i+(e.x>.01?r.width/2:e.x<-.01?-r.width/2:0),o=e.y*i+(e.y>.01?r.height/2:e.y<-.01?-r.height/2:0);O+=`<g class="pele-axis-label" data-id="${mq(m[t].name)}">${gq(r,a,o,``)}</g>`,S=Math.min(S,a-r.width/2),C=Math.max(C,a+r.width/2),w=Math.min(w,o-r.height/2),T=Math.max(T,o+r.height/2)});let k=``;h.forEach((e,t)=>{if(e.entries.length!==y)return;let n=e.entries.map((e,t)=>{let n=WTt(e,v,x,p),r=Number.isFinite(n)?n:0;return{x:b[t].x*r,y:b[t].y*r}}),r=hJ(t),i=` class="pele-curve" data-id="${mq(e.name)}" fill="${r}" stroke="${r}"`;k+=_===`circle`?`<path${i} d="${GTt(n,f)}"/>`:`<polygon${i} points="${KTt(n)}"/>`});let A=e.options.showLegend?h.map(e=>UJ(e.label,!1,c,s,4e3)):[],j=0;for(let e of A)j=Math.max(j,e.width);let M=A.length*z$,N=a?-(R$+8+j)/2:C+UTt,P=a?T+UTt/2:-M/2;A.length>0&&a?(S=Math.min(S,N),C=Math.max(C,-N),T=P+M):A.length>0&&(C=N+R$+8+j,w=Math.min(w,-M/2),T=Math.max(T,M/2));let F=``;A.forEach((e,t)=>{let n=P+t*z$+z$/2,r=hJ(t);F+=`<g class="pele-legend-item" data-id="${mq(h[t].name)}"><rect x="${K(N)}" y="${K(n-R$/2)}" width="${R$}" height="${R$}" rx="2" fill="${r}" fill-opacity="0.4" stroke="${r}"/>`+gq(e,N+R$+8+e.width/2,n,``)+`</g>`});let ee=UJ(e.title,!1,c,o,GJ(n),1),te=ee.height>0?ee.height+8:0,I=Math.max(C-S,ee.width),ne=Math.ceil(I+2*l),re=Math.ceil(T-w+te+2*l),ie=`translate(${K(l+(I-(C-S))/2-S)},${K(l+te-w)})`;return{svg:_J(`radar`,ne,re,o,n,e,gq(ee,ne/2,l+ee.height/2,` class="pele-title" font-weight="var(--_tw)"`)+`<g transform="${ie}">`+(E?`<g class="pele-graticule" fill="none" stroke="var(--_a)">${E}</g>`:``)+(D?`<path class="pele-axes" d="${D}" fill="none" stroke="var(--_b)"/>`:``)+(k?`<g class="pele-curves" fill-opacity="0.2" stroke-width="1.5" stroke-linejoin="round">${k}</g>`:``)+(O?`<g class="pele-axis-labels" font-size="${s}">${O}</g>`:``)+(F?`<g class="pele-legend" font-size="${s}">${F}</g>`:``)+`</g>`),width:ne,height:re,links:[]}}var YTt={type:`radar`,parse:(e,t,n)=>ITt(HTt(e),n),render:qTt};function XTt(e){return e===32||e>=9&&e<=13||e>127&&/\s/.test(String.fromCharCode(e))}function ZTt(){let e=1/0;return(t,n)=>{if(!t.startsWith(`accDescr`,n))return-1;let r=t.length,i=n+8;for(;i<r&&(t.charCodeAt(i)===32||t.charCodeAt(i)===9);)i++;if(t.charCodeAt(i)===58){for(i++;i<r;i++){let e=t.charCodeAt(i);if(e===10||e===13||e===37&&t.charCodeAt(i+1)===37)break}return i}for(;i<r&&XTt(t.charCodeAt(i));)i++;if(t.charCodeAt(i)!==123||i>=e)return-1;let a=t.indexOf(`}`,i+1);return a===-1&&(e=i),a+1||-1}}var QTt=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,V$={name:`TITLE`,pattern:/title(?:[\t ][^\n\r]*?(?=%%)|[\t ][^\n\r]*|)/y,first:`t`},H$={name:`ACC_TITLE`,pattern:/accTitle[\t ]*:(?:[^\n\r]*?(?=%%)|[^\n\r]*)/y,first:`a`},U$={name:`ACC_DESCR`,pattern:/accDescr(?:[\t ]*:([^\n\r]*?(?=%%)|[^\n\r]*)|\s*{([^}]*)})/y,first:`a`,scanner:ZTt};function W$(e,t){return{name:e,pattern:e,longer:t}}function G$(e,t){return{...mY(e),longer:[t]}}function K$(e){return{name:e,pattern:/[A-Z_a-z][\w-]*/y,first:QTt+`_`}}function q$(e){return{name:e,pattern:/"([^"\\]|\\.)*"|'([^'\\]|\\.)*'/y,first:`"'`}}function J$(e){return[{name:e+`_WHITESPACE`,pattern:/[\t \r\n]+/y,hidden:!0,first:` \r
|
|
1036
|
+
`},{...dY,name:e+`_YAML`,first:`-`},{...fY,name:e+`_DIRECTIVE`,first:` %`},{...pY,name:e+`_SINGLE_LINE_COMMENT`,first:` %`}]}function Y$(e){if(!e.includes(`\\`))return e.slice(1,-1);let t=e.length-1,n=``;for(let r=1;r<t;r++){let i=e[r];i===`\\`&&r+1<t?(i=e[++r],n+=i===`n`?`
|
|
1037
|
+
`:i===`r`?`\r`:i===`t`?` `:i):n+=i}return n}function X$(e,t,n,r,i,a){let o=new bY(iY(e,t,`railroad`),t,`railroad`),s={$type:n,rules:[]};for(o.expect(0);;){let e=o.kind;if(e===r){let e=gY(o.take()),t=e[0];s.title=(t===`"`||t===`'`)&&e.endsWith(t)?i(e):e}else if(e===r+1)s.accTitle=_Y(o.take());else if(e===r+2)s.accDescr=vY(o.take());else break}for(;o.kind!==-1;)s.rules.push(a(o));return s}var $Tt=[];function Z$(e){let t=e,n=t.element??t.primary??t.suffix,r=t.alternatives??t.elements??(n?[n]:$Tt);if(t.base){r=[t.base];for(let e of t.postfixes)e.except&&r.push(e.except)}return r}var Q$=e=>({type:`terminal`,value:e}),$$=e=>({type:`nonterminal`,name:e}),e1=e=>({type:`special`,text:e}),t1=e=>({type:`optional`,element:e}),n1=(e,t,n=1/0)=>({type:`repetition`,element:e,min:t,max:n});function r1(e){return e.length===1?e[0]:{type:`sequence`,elements:e}}function i1(e){return e.length===1?e[0]:{type:`choice`,alternatives:e}}function a1(e,t){return e.rules.map(e=>({name:e.name,definition:eEt(e.definition,Z$,t)}))}function eEt(e,t,n){let r=[e],i=[t(e)],a=[[]];for(;;){let e=r.length-1,o=a[e];if(o.length<i[e].length){let n=i[e][o.length];r.push(n),i.push(t(n)),a.push([])}else{let t=n(r[e],o);if(e===0)return t;r.pop(),i.pop(),a.pop(),a[e-1].push(t)}}}var tEt=`0123456789`,nEt={name:`ABNF_RULENAME`,pattern:/[A-Za-z][A-Za-z0-9-]*/y,first:QTt},rEt={name:`ABNF_COMMENT`,pattern:/;[^\n\r]*/y,hidden:!0,first:`;`},iEt=[G$(`railroad-abnf-beta`,nEt),W$(`=`),W$(`;`,[rEt]),W$(`/`),W$(`(`),W$(`)`),W$(`[`),W$(`]`),V$,H$,U$,nEt,{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:tEt+`*`},{name:`ABNF_EXACT_REPEAT`,pattern:/[0-9]+/y,first:tEt},...J$(`ABNF`),rEt];function aEt(e,t,n,r){let i={$type:`AbnfConcatenation`,elements:[]};return t.alternatives.push(i),{alternation:t,concatenation:i,node:e,close:n,repeat:r}}function oEt(e){let t=[],n=aEt(void 0,{$type:`AbnfAlternation`,alternatives:[]},-2,void 0);for(;;){let r=e.kind===14||e.kind===15?e.take():void 0,i,a=e.kind;switch(a){case 12:i={$type:`AbnfStringLiteral`,value:e.take().slice(1,-1)};break;case 13:i={$type:`AbnfNumVal`,value:e.take()};break;case 11:i={$type:`AbnfRuleName`,name:e.take()};break;case 4:case 6:{e.i++;let i={$type:`AbnfAlternation`,alternatives:[]};t.push(n),n=aEt({$type:a===4?`AbnfGroup`:`AbnfOptionalGroup`,element:i},i,a+1,r);continue}default:e.fail(`a string, a number, a name, or an opening bracket`)}for(;;){n.concatenation.elements.push(r===void 0?{$type:`AbnfElement`,primary:i}:{$type:`AbnfElement`,repeat:r,primary:i});let a=e.kind;if(a===n.close)e.i++,i=n.node,r=n.repeat,n=t.pop();else{if(a===3)e.i++,n.concatenation={$type:`AbnfConcatenation`,elements:[]},n.alternation.alternatives.push(n.concatenation);else if(a!==12&&a!==13&&a!==11&&a!==4&&a!==6&&a!==14&&a!==15){if(t.length===0)return n.alternation;e.fail(`token of type '${iEt[n.close].name}'`)}break}}}}function sEt(e){return X$(e,iEt,`RailroadAbnf`,8,e=>e.slice(1,-1),e=>{let t=e.expect(11);e.expect(1);let n=oEt(e);return e.expect(2),{$type:`AbnfRule`,name:t,definition:n}})}function cEt(e,t){switch(e.$type){case`AbnfAlternation`:return i1(t);case`AbnfConcatenation`:return r1(t);case`AbnfElement`:{let n=e.repeat;if(!n)return t[0];let r=n.indexOf(`*`),i=r===-1,a=r>0||i?parseInt(n,10):0,o=i?a:r<n.length-1?parseInt(n.slice(r+1),10):1/0;return a===0&&o===1?t1(t[0]):n1(t[0],a,o)}case`AbnfStringLiteral`:case`AbnfNumVal`:return Q$(e.value);case`AbnfRuleName`:return $$(e.name);case`AbnfGroup`:return t[0];case`AbnfOptionalGroup`:return t1(t[0])}}var lEt=e=>a1(e,cEt);function uEt(e,t){if(e.charCodeAt(t)!==63)return-1;let n=!1;for(let r=t+1;r<e.length;r++){let t=e.charCodeAt(r);if(t===63)return n?r+1:-1;if(t===59)return-1;n||=!XTt(t)}return-1}var dEt=K$(`EBNF_ID`),fEt={name:`EBNF_SPECIAL_SEQUENCE`,pattern:/\?(?=[^?;]*[^?\s;][^?;]*\?)[^?;]*\?/y,first:`?`,scanner:()=>uEt},pEt=J$(`EBNF`),mEt={name:`EBNF_ISO_COMMENT`,pattern:/\(\*[\s\S]*?\*\)/y,hidden:!0,first:`(`,opener:/\(\*/y},hEt=[G$(`railroad-ebnf-beta`,dEt),W$(`::=`),W$(`=`),W$(`;`),W$(`|`),W$(`,`),W$(`(`,[mEt]),W$(`)`),W$(`[`),W$(`]`),W$(`{`),W$(`}`),W$(`?`,[fEt]),W$(`*`),W$(`+`),W$(`-`,[pEt[1]]),V$,H$,U$,dEt,q$(`EBNF_STRING`),fEt,...pEt,{name:`EBNF_BLOCK_COMMENT`,pattern:/\/\*[\s\S]*?\*\//y,hidden:!0,first:`/`,opener:/\/\*/y},mEt];function gEt(e,t,n,r){let i={$type:`EbnfSequence`,elements:[]};return t.alternatives.push(i),{choice:t,sequence:i,term:void 0,node:e,close:n,except:r}}var _Et=[`EbnfGroup`,`EbnfOptional`,`EbnfRepetition`];function vEt(e){let t=[],n=gEt(void 0,{$type:`EbnfChoice`,alternatives:[]},-2,!1),r=!1;for(;;){let i,a=e.kind;switch(a){case 20:i={$type:`EbnfTerminal`,value:Y$(e.take())};break;case 19:i={$type:`EbnfNonTerminal`,name:e.take()};break;case 21:i={$type:`EbnfSpecial`,text:e.take().slice(1,-1).trim()};break;case 6:case 8:case 10:{e.i++;let i={$type:`EbnfChoice`,alternatives:[]};t.push(n),n=gEt({$type:_Et[a-6>>1],element:i},i,a+1,r),r=!1;continue}default:e.fail(`a terminal, a name, or an opening bracket`)}for(;;){r?(n.term.postfixes.push({$type:`EbnfExceptionPostfix`,except:i}),r=!1):(n.term={$type:`EbnfTerm`,base:i,postfixes:[]},n.sequence.elements.push(n.term));let a=n.term.postfixes;for(;;){let t=e.kind;if(t===12)a.push({$type:`EbnfOptionalPostfix`,operator:e.take()});else if(t===13)a.push({$type:`EbnfZeroOrMorePostfix`,operator:e.take()});else if(t===14)a.push({$type:`EbnfOneOrMorePostfix`,operator:e.take()});else break}let o=e.kind;if(o===n.close)e.i++,i=n.node,r=n.except,n=t.pop();else{if(o===15)e.i++,r=!0;else if(o===5)e.i++;else if(o===4)e.i++,n.sequence={$type:`EbnfSequence`,elements:[]},n.choice.alternatives.push(n.sequence);else if(o!==20&&o!==19&&o!==21&&o!==6&&o!==8&&o!==10){if(t.length===0)return n.choice;e.fail(`token of type '${hEt[n.close].name}'`)}break}}}}function yEt(e){return X$(e,hEt,`RailroadEbnf`,16,Y$,e=>{let t=e.expect(19);e.accept(2)||e.expect(1);let n={$type:`EbnfRule`,name:t,definition:vEt(e)};return e.expect(3),n})}function bEt(e,t){switch(e.$type){case`EbnfChoice`:return i1(t);case`EbnfSequence`:return r1(t);case`EbnfTerm`:{let n=t[0],r=1;for(let i of e.postfixes)n=i.$type===`EbnfOptionalPostfix`?t1(n):i.$type===`EbnfExceptionPostfix`?{type:`sequence`,elements:[n,Q$(`-`),t[r++]]}:n1(n,+(i.$type===`EbnfOneOrMorePostfix`));return n}case`EbnfTerminal`:return Q$(e.value);case`EbnfNonTerminal`:return $$(e.name);case`EbnfSpecial`:return e1(e.text);case`EbnfGroup`:return t[0];case`EbnfOptional`:return t1(t[0]);case`EbnfRepetition`:return n1(t[0],0)}}var xEt=e=>a1(e,bEt),o1=K$(`RR_ID`),s1=e=>W$(e,[o1]),SEt=[G$(`railroad-beta`,o1),s1(`nonterminal`),s1(`zeroOrMore`),s1(`oneOrMore`),s1(`sequence`),s1(`optional`),s1(`terminal`),s1(`special`),s1(`choice`),W$(`=`),W$(`;`),W$(`(`),W$(`,`),W$(`)`),V$,H$,U$,o1,q$(`RR_STRING`),...J$(`RR`),{name:`RR_BLOCK_COMMENT`,pattern:/\/\*[\s\S]*?\*\//y,hidden:!0,first:`/`,opener:/\/\*/y}];function c1(e){e.i++,e.expect(11);let t=Y$(e.expect(18));return e.expect(13),t}function l1(e){return{$type:e,element:void 0}}function CEt(e){let t=[];for(;;){let n;switch(e.kind){case 6:n={$type:`RailroadTerminalExpr`,value:c1(e)};break;case 1:n={$type:`RailroadNonTerminalExpr`,name:c1(e)};break;case 7:n={$type:`RailroadSpecialExpr`,text:c1(e)};break;case 4:n={$type:`RailroadSequenceExpr`,elements:[]};break;case 8:n={$type:`RailroadChoiceExpr`,alternatives:[]};break;case 5:n=l1(`RailroadOptionalExpr`);break;case 3:n=l1(`RailroadOneOrMoreExpr`);break;case 2:n=l1(`RailroadZeroOrMoreExpr`);break;default:e.fail(`an expression`)}if(`elements`in n||`alternatives`in n||`element`in n)e.i++,e.expect(11),t.push(n);else for(;;){let r=t[t.length-1];if(r===void 0)return n;if(`element`in r)r.element=n;else if((`elements`in r?r.elements:r.alternatives).push(n),e.accept(12))break;e.expect(13),t.pop(),n=r}}}function wEt(e){return X$(e,SEt,`Railroad`,14,Y$,e=>{let t=e.expect(17);e.expect(9);let n=CEt(e);return e.expect(10),{$type:`RailroadRule`,name:t,definition:n}})}function TEt(e,t){switch(e.$type){case`RailroadTerminalExpr`:return Q$(e.value);case`RailroadNonTerminalExpr`:return $$(e.name);case`RailroadSpecialExpr`:return e1(e.text);case`RailroadSequenceExpr`:return r1(t);case`RailroadChoiceExpr`:return i1(t);case`RailroadOptionalExpr`:return t1(t[0]);default:return n1(t[0],+(e.$type===`RailroadOneOrMoreExpr`))}}var EEt=e=>a1(e,TEt),DEt=K$(`PEG_ID`),OEt=[G$(`railroad-peg-beta`,DEt),W$(`<-`),W$(`;`),W$(`/`),W$(`&`),W$(`!`),W$(`?`),W$(`*`),W$(`+`),W$(`(`),W$(`)`),W$(`.`),V$,H$,U$,DEt,q$(`PEG_STRING`),...J$(`PEG`),{name:`PEG_LINE_COMMENT`,pattern:/#[^\n\r]*/y,hidden:!0,first:`#`}];function kEt(e,t,n){let r={$type:`PegSequence`,elements:[]};return t.alternatives.push(r),{choice:t,sequence:r,node:e,operator:n}}function AEt(e){let t=[],n=kEt(void 0,{$type:`PegOrderedChoice`,alternatives:[]},void 0);for(;;){let r=e.kind===4||e.kind===5?e.take():void 0,i;switch(e.kind){case 16:i={$type:`PegLiteral`,value:Y$(e.take())};break;case 15:i={$type:`PegIdentifier`,name:e.take()};break;case 11:i={$type:`PegAny`,dot:e.take()};break;case 9:{e.i++;let i={$type:`PegOrderedChoice`,alternatives:[]};t.push(n),n=kEt({$type:`PegGroup`,element:i},i,r);continue}default:e.fail(`a literal, a name, a dot, or an opening parenthesis`)}for(;;){let a={$type:`PegSuffix`,primary:i};(e.kind===6||e.kind===7||e.kind===8)&&(a.operator=e.take()),n.sequence.elements.push(r===void 0?{$type:`PegPrefix`,suffix:a}:{$type:`PegPrefix`,operator:r,suffix:a});let o=e.kind;if(o===10&&t.length>0)e.i++,i=n.node,r=n.operator,n=t.pop();else{if(o===3)e.i++,n.sequence={$type:`PegSequence`,elements:[]},n.choice.alternatives.push(n.sequence);else if(o!==4&&o!==5&&o!==16&&o!==15&&o!==11&&o!==9){if(t.length===0)return n.choice;e.fail(`token of type ')'`)}break}}}}function jEt(e){return X$(e,OEt,`RailroadPeg`,12,Y$,e=>{let t=e.expect(15);e.expect(1);let n={$type:`PegRule`,name:t,definition:AEt(e)};return e.expect(2),n})}function MEt(e){switch(e.type){case`terminal`:return`"${e.value}"`;case`nonterminal`:return e.name;case`special`:return e.text;default:return`(...)`}}function NEt(e,t){let n=t[0];switch(e.$type){case`PegOrderedChoice`:return i1(t);case`PegSequence`:return r1(t);case`PegPrefix`:return e.operator?e1(e.operator+MEt(n)):n;case`PegSuffix`:return e.operator?e.operator===`?`?t1(n):n1(n,+(e.operator===`+`)):n;case`PegLiteral`:return Q$(e.value);case`PegIdentifier`:return $$(e.name);case`PegAny`:return e1(e.dot);case`PegGroup`:return n}}var PEt=e=>a1(e,NEt),FEt=class{type=`railroad`;notation=`railroad`;title;accTitle;accDescr;rules=[];byName=/* @__PURE__ */ new Map;setTitle(e){this.title=e}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,``)}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
1038
1038
|
`)}addRule(e){this.rules.push(e),this.byName.set(e.name,e)}getRule(e){return this.byName.get(e)}},IEt=/^\s*railroad-(ebnf-|abnf-|peg-)?beta/i;function LEt(e){let t=IEt.exec(e);if(t===null)return;let n=t[1]?.toLowerCase();return n===`ebnf-`?`ebnf`:n===`abnf-`?`abnf`:n===`peg-`?`peg`:`railroad`}function REt(e,t){switch(t){case`ebnf`:{let t=yEt(e);return[t,xEt(t)]}case`abnf`:{let t=sEt(e);return[t,lEt(t)]}case`peg`:{let t=jEt(e);return[t,PEt(t)]}default:{let t=wEt(e);return[t,EEt(t)]}}}function zEt(e,t,n){let[r,i]=REt(t,n);e.notation=n,r.accDescr&&e.setAccDescription(r.accDescr),r.accTitle&&e.setAccTitle(r.accTitle),r.title&&e.setTitle(r.title);for(let t of i)e.addRule(t)}function BEt(e,t){let n=LEt(e);if(n===void 0)throw new NK(`No railroad diagram keyword found.`,`syntax`,{type:`railroad`});let r=new FEt;return t&&(r.title=t),zEt(r,e,n),r}var u1=12,VEt=6,HEt=18,d1=12,f1=7;function p1(e,t,n,r){let i=e.railroad?.[t];return typeof i==`number`&&i>=0?Math.min(i,r):n}var UEt=/[\n\r\t]/g;function m1(e){return(e.includes(`¶ß`)?RK(e.replace(/&/g,`&`)):e).replace(UEt,e=>e===`
|
|
1039
|
-
`?`\\n`:e===`\r`?`\\r`:`\\t`)}function h1(e,t){for(let n=t,r=e.length-1;n<r;n++,r--){let t=e[n];e[n]=e[r],e[r]=t}}function g1(e){return Math.ceil(e/2)*2}function _1(e,t,n,r,i){let a=i.height/2;return{kind:e,width:Math.max(g1(i.measurer.width(t,i.size,r)+2*i.padding),i.height),up:a,down:a,kids:$Tt,text:t,id:n,reach:0}}function WEt(e,t){if(t===1/0&&e<=1)return``;let n=e=>Number.isFinite(e)?String(e):`∞`;return e===t?n(e)+`×`:t===1/0?`≥`+n(e)+`×`:e===0?`≤`+n(t)+`×`:n(e)+`–`+n(t)+`×`}function GEt(e,t,n,r){return Math.max(e+t.down+r.sep+n.up,2*r.arc)}function KEt(e,t){let n=Math.max(e.up+t.sep,2*t.arc);return{kind:5,width:e.width+4*t.arc,up:n,down:e.down,kids:[e],text:``,id:``,reach:n}}function qEt(e,t,n=1/0){let r=/* @__PURE__ */ new Map,i=[[e,n]];for(let e=0;n!==1/0&&e<i.length;e++){let[n,a]=i[e];r.set(n,a);let o=n.type===`choice`||n.type===`optional`?4*t.arc:n.type===`repetition`?(n.min===0?6:2)*t.arc:n.type===`sequence`?6*t.arc:0;for(let e of Z$(n))i.push([e,Math.max(40,a-o)])}return eEt(e,Z$,(e,n)=>{let i=r.get(e)??1/0;switch(e.type){case`terminal`:{let n=m1(e.value);return _1(0,/^ +$/.test(n)?`␣`.repeat(n.length):n,``,4,t)}case`nonterminal`:return _1(1,m1(e.name),e.name,0,t);case`special`:return _1(2,`? `+m1(e.text)+` ?`,``,2,t);case`sequence`:{let e=Math.max(0,n.length-1)*t.gap,r=0,a=0;for(let t of n)e+=t.width,r=Math.max(r,t.up),a=Math.max(a,t.down);let o={kind:3,width:e,up:r,down:a,kids:n,text:``,id:``,reach:0};if(e<=i||n.length<2)return o;let s=[],c=[],l=0,u=()=>{let e=0,t=0;for(let n of c)e=Math.max(e,n.up),t=Math.max(t,n.down);s.push({kind:3,width:l,up:e,down:t,kids:c,text:``,id:``,reach:0}),c=[],l=0};for(let e of n)c.length&&l+t.gap+e.width>Math.max(40,i-6*t.arc)&&u(),l+=(c.length?t.gap:0)+e.width,c.push(e);if(u(),s.length<2)return o;let d=0,f=0;for(let e=0;e<s.length;e++)d=Math.max(d,s[e].width),e&&(f+=s[e-1].down+Math.max(t.sep,2*t.arc)+s[e].up);return{kind:7,width:d+6*t.arc,up:s[0].up,down:f+s[s.length-1].down,kids:s,text:``,id:``,reach:0}}case`choice`:{let e=0,r=0;for(let i=0;i<n.length;i++)e=Math.max(e,n[i].width),i>0&&(r=GEt(r,n[i-1],n[i],t));let i=n[n.length-1];return{kind:4,width:e+4*t.arc,up:n.length>0?n[0].up:0,down:i?r+i.down:0,kids:n,text:``,id:``,reach:0}}case`optional`:return KEt(n[0],t);case`repetition`:{let{min:r,max:i}=e,a=n[0];if(r===1&&i===1)return a;let o=WEt(r,i),s=Math.max(a.down+t.sep,2*t.arc),c=o===``?0:g1(t.measurer.width(o,d1,0)),l={kind:6,width:Math.max(a.width,c)+2*t.arc,up:a.up,down:s+(o===``?f1/2+1:d1+6),kids:[a],text:o,id:``,reach:s};return r===0?KEt(l,t):l}}})}function JEt(e,t,n){return
|
|
1039
|
+
`?`\\n`:e===`\r`?`\\r`:`\\t`)}function h1(e,t){for(let n=t,r=e.length-1;n<r;n++,r--){let t=e[n];e[n]=e[r],e[r]=t}}function g1(e){return Math.ceil(e/2)*2}function _1(e,t,n,r,i){let a=i.height/2;return{kind:e,width:Math.max(g1(i.measurer.width(t,i.size,r)+2*i.padding),i.height),up:a,down:a,kids:$Tt,text:t,id:n,reach:0}}function WEt(e,t){if(t===1/0&&e<=1)return``;let n=e=>Number.isFinite(e)?String(e):`∞`;return e===t?n(e)+`×`:t===1/0?`≥`+n(e)+`×`:e===0?`≤`+n(t)+`×`:n(e)+`–`+n(t)+`×`}function GEt(e,t,n,r){return Math.max(e+t.down+r.sep+n.up,2*r.arc)}function KEt(e,t){let n=Math.max(e.up+t.sep,2*t.arc);return{kind:5,width:e.width+4*t.arc,up:n,down:e.down,kids:[e],text:``,id:``,reach:n}}function qEt(e,t,n=1/0){let r=/* @__PURE__ */ new Map,i=[[e,n]];for(let e=0;n!==1/0&&e<i.length;e++){let[n,a]=i[e];r.set(n,a);let o=n.type===`choice`||n.type===`optional`?4*t.arc:n.type===`repetition`?(n.min===0?6:2)*t.arc:n.type===`sequence`?6*t.arc:0;for(let e of Z$(n))i.push([e,Math.max(40,a-o)])}return eEt(e,Z$,(e,n)=>{let i=r.get(e)??1/0;switch(e.type){case`terminal`:{let n=m1(e.value);return _1(0,/^ +$/.test(n)?`␣`.repeat(n.length):n,``,4,t)}case`nonterminal`:return _1(1,m1(e.name),e.name,0,t);case`special`:return _1(2,`? `+m1(e.text)+` ?`,``,2,t);case`sequence`:{let e=Math.max(0,n.length-1)*t.gap,r=0,a=0;for(let t of n)e+=t.width,r=Math.max(r,t.up),a=Math.max(a,t.down);let o={kind:3,width:e,up:r,down:a,kids:n,text:``,id:``,reach:0};if(e<=i||n.length<2)return o;let s=[],c=[],l=0,u=()=>{let e=0,t=0;for(let n of c)e=Math.max(e,n.up),t=Math.max(t,n.down);s.push({kind:3,width:l,up:e,down:t,kids:c,text:``,id:``,reach:0}),c=[],l=0};for(let e of n)c.length&&l+t.gap+e.width>Math.max(40,i-6*t.arc)&&u(),l+=(c.length?t.gap:0)+e.width,c.push(e);if(u(),s.length<2)return o;let d=0,f=0;for(let e=0;e<s.length;e++)d=Math.max(d,s[e].width),e&&(f+=s[e-1].down+Math.max(t.sep,2*t.arc)+s[e].up);return{kind:7,width:d+6*t.arc,up:s[0].up,down:f+s[s.length-1].down,kids:s,text:``,id:``,reach:0}}case`choice`:{let e=0,r=0;for(let i=0;i<n.length;i++)e=Math.max(e,n[i].width),i>0&&(r=GEt(r,n[i-1],n[i],t));let i=n[n.length-1];return{kind:4,width:e+4*t.arc,up:n.length>0?n[0].up:0,down:i?r+i.down:0,kids:n,text:``,id:``,reach:0}}case`optional`:return KEt(n[0],t);case`repetition`:{let{min:r,max:i}=e,a=n[0];if(r===1&&i===1)return a;let o=WEt(r,i),s=Math.max(a.down+t.sep,2*t.arc),c=o===``?0:g1(t.measurer.width(o,d1,0)),l={kind:6,width:Math.max(a.width,c)+2*t.arc,up:a.up,down:s+(o===``?f1/2+1:d1+6),kids:[a],text:o,id:``,reach:s};return r===0?KEt(l,t):l}}})}function JEt(e,t,n){return YJ(n,r=>YEt(e,t,n,r))}function YEt(e,t,n,r){let i=n.fontSize??16,a=p1(t,`fontSize`,0,200),o=a||Math.round(i*.875),s=a||i,c=p1(t,`padding`,-1,200),l=Math.round(o*1.5),u={measurer:n.measurer??fq(n.fontFamily,n.fontFamilyMono),size:o,padding:c<0?12:c,height:g1(l+(c<0?9:2*c)),gap:Math.min(p1(t,`horizontalSeparation`,16,500),r?12:1/0),sep:p1(t,`verticalSeparation`,10,500),arc:Math.min(p1(t,`arcRadius`,10,200),r?6:1/0)},d=t.railroad?.showMarkers===!1?0:p1(t,`markerRadius`,4,50),f=p1(t,`strokeWidth`,0,20),p=f>0?` stroke-width="${K(f)}"`:``,m=n.padding??8,{arc:h}=u,g=K(h),_=(e,t,n)=>`a${g},${g} 0 0 ${e} ${t}${g},${n}${g}`,v=_(1,``,``),y=_(0,``,``),b=_(0,``,`-`),x=_(1,``,`-`),S=_(0,`-`,``),C=_(0,`-`,`-`),w=UJ(e.title,!1,u.measurer,i,r?GJ(n):4e3,1),T=w.height>0?w.height+16:0,E=Math.round(s*1.5),D=o*.35,O=u.height/2,k=``,A=``,j=``,M=(e,t,n)=>{n>e&&(k+=`M${K(e)},${K(t)}H${K(n)}`)},N=(e,t,n)=>{let r=[e],i=[t,n];for(;r.length>0;){let e=r.pop(),t=i.pop(),n=i.pop(),a=e.kids,o=n+e.width;switch(e.kind){case 3:{let e=o;for(let n=a.length-1;n>=0;n--)e-=a[n].width,r.push(a[n]),i.push(e,t),n>0&&M(e-u.gap,t,e),e-=u.gap;break}case 7:{let e=n+2*h,s=r.length,c=0;M(n,t,e);for(let s=0;s<a.length;s++){let l=a[s],d=t+c;if(r.push(l),i.push(d,e),s+1<a.length){let r=a[s+1],i=c+l.down+Math.max(u.sep,2*h)+r.up,f=t+c+l.down+Math.max(u.sep,2*h)/2;k+=`M${K(e+l.width)},${K(d)}H${K(o-2*h)}V${K(f)}H${K(n+h)}V${K(t+i)}H${K(e)}`,A+=`M${K(e-f1)},${K(t+i-f1/2)}l${f1},${f1/2}l${-f1},${f1/2}z`,c=i}else k+=`M${K(e+l.width)},${K(d)}H${K(o-h)}V${K(t)}H${K(o)}`}h1(r,s),h1(i,2*s);break}case 4:{let s=e.width-4*h,c=n+h,l=o-h,d=r.length,f=0;for(let e=0;e<a.length;e++){let d=a[e];e>0&&(f=GEt(f,a[e-1],d,u));let p=t+f,m=n+2*h+(s-d.width)/2,g=e===a.length-1;e===0?(M(n,t,m),M(m+d.width,t,o)):k+=(g?`M${K(n)},${K(t)}${v}V${K(p-h)}`:`M${K(c)},${K(p-h)}`)+y+(m>c+h?`H${K(m)}`:``)+`M${K(m+d.width)},${K(p)}`+(m>c+h?`H${K(l-h)}`:``)+b+(g?`V${K(t+h)}${x}`:``),r.push(d),i.push(p,m)}h1(r,d),h1(i,2*d);break}case 5:{let s=a[0],c=n+2*h;M(n,t,c),M(c+s.width,t,o),k+=`M${K(n)},${K(t)}${b}V${K(t-e.reach+h)}${x}H${K(o-2*h)}${v}V${K(t-h)}${y}`,r.push(s),i.push(c,t);break}case 6:{let s=a[0],c=n+(e.width-s.width)/2,l=t+e.reach,u=n+e.width/2;M(n,t,c),M(c+s.width,t,o),k+=`M${K(n+h)},${K(t)}${S}V${K(l-h)}${y}H${K(o-h)}${b}V${K(t+h)}${C}`,A+=`M${K(u-f1/2)},${K(l)}l${f1},${-f1/2}v${f1}z`,e.text!==``&&(j+=`<text class="pele-edge-label pele-count" x="${K(u)}" y="${K(l+d1+3)}" font-size="${d1}" fill="var(--_m)">${pq(e.text)}</text>`),r.push(s),i.push(c,t);break}default:{let r=e.text,i=r.startsWith(` `)||r.endsWith(` `)||r.includes(` `)?` xml:space="preserve"`:``,a=`<rect x="${K(n)}" y="${K(t-O)}" width="${K(e.width)}" height="${K(u.height)}"`,o=`<text x="${K(n+e.width/2)}" y="${K(t+D)}"${i}`;e.kind===0?j+=`<g class="pele-node pele-terminal">${a} rx="${K(O)}" fill="var(--_s)" stroke="var(--_b)"${p}/>${o} font-family="${uJ}">${pq(r)}</text></g>`:e.kind===1?j+=`<g class="pele-node pele-nonterminal" data-id="${mq(e.id)}">${a} rx="${dJ}" fill="var(--_bg)" stroke="var(--_b)"${p}/>${o}>${pq(r)}</text></g>`:j+=`<g class="pele-node pele-special">${a} rx="${dJ}" fill="var(--_bg)" stroke="var(--_b)" stroke-dasharray="4 3"${p}/>${o} font-style="italic"><tspan fill="var(--_m)">? </tspan>${pq(r.slice(2,-2))}<tspan fill="var(--_m)"> ?</tspan></text></g>`}}}},P=``,F=w.width,ee=m+T,te=m+w.height;for(let t of e.rules){let e=qEt(t.definition,u,r?Math.max(80,(n.maxWidth??320)-2*m-4*d-2*u1-1):1/0),i=m1(t.name),a=ee+E+VEt+e.up,o=m+2*d,c=o+u1,l=c+e.width+u1;k=``,A=``,j=``,M(o,a,c),M(c+e.width,a,l),N(e,c,a);let f=d>0?`<circle class="pele-marker pele-start" cx="${K(m+d)}" cy="${K(a)}" r="${K(d)}" fill="var(--_l)"/><circle class="pele-marker pele-end" cx="${K(l+d)}" cy="${K(a)}" r="${K(d)}" fill="var(--_l)"/>`:``;P+=`<g class="pele-rule" data-id="${mq(t.name)}"><text class="pele-rule-name" x="${K(m)}" y="${K(ee+E/2+s*.35)}" font-size="${K(s)}" font-weight="var(--_hw)" text-anchor="start">${pq(i)}</text><path class="pele-edge pele-track" d="${k}" fill="none" stroke="var(--_l)"${p}/>`+(A?`<path class="pele-marker" d="${A}" fill="var(--_l)"/>`:``)+f+j+`</g>`,F=Math.max(F,l+2*d-m,u.measurer.width(i,s,1)),te=a+e.down,ee=te+u.sep+HEt}let I=Math.ceil(F+2*m),ne=Math.ceil(te+m);return{svg:_J(`railroad`,I,ne,i,n,e,gq(w,I/2,m+w.height/2,` class="pele-title" font-weight="var(--_tw)"`)+(P?`<g class="pele-rules" transform="translate(0.5,0.5)" font-size="${K(o)}" text-anchor="middle">${P}</g>`:``)),width:I,height:ne,links:[]}}var XEt={type:`railroad`,parse:(e,t,n)=>BEt(e,n),render:JEt},v1={REQUIREMENT:`Requirement`,FUNCTIONAL_REQUIREMENT:`Functional Requirement`,INTERFACE_REQUIREMENT:`Interface Requirement`,PERFORMANCE_REQUIREMENT:`Performance Requirement`,PHYSICAL_REQUIREMENT:`Physical Requirement`,DESIGN_CONSTRAINT:`Design Constraint`},y1={LOW_RISK:`Low`,MED_RISK:`Medium`,HIGH_RISK:`High`},b1={VERIFY_ANALYSIS:`Analysis`,VERIFY_DEMONSTRATION:`Demonstration`,VERIFY_INSPECTION:`Inspection`,VERIFY_TEST:`Test`},x1={CONTAINS:`contains`,COPIES:`copies`,DERIVES:`derives`,SATISFIES:`satisfies`,VERIFIES:`verifies`,REFINES:`refines`,TRACES:`traces`},ZEt=1e6,QEt=class{type=`requirement`;direction=`TB`;requirements=/* @__PURE__ */ new Map;elements=/* @__PURE__ */ new Map;relations=[];classes=/* @__PURE__ */ new Map;title;accTitle;accDescr;newId=``;newText=``;newRisk=``;newVerifyMethod=``;newElementType=``;newDocRef=``;styleCopies=0;copy(e,t){if(this.styleCopies+=t.length,this.styleCopies>ZEt)throw new NK(`Requirement diagram applies too many style declarations.`,`limit`,{type:`requirement`});for(let n of t)e.push(n)}setDirection(e){this.direction=e}addRequirement(e,t){let n=this.requirements.get(e);return n===void 0&&(n={name:e,type:t,requirementId:this.newId,text:this.newText,risk:this.newRisk,verifyMethod:this.newVerifyMethod,cssStyles:[],classes:[`default`]},this.requirements.set(e,n)),this.newId=this.newText=this.newRisk=this.newVerifyMethod=``,n}setNewReqId(e){this.newId=e}setNewReqText(e){this.newText=e}setNewReqRisk(e){this.newRisk=e}setNewReqVerifyMethod(e){this.newVerifyMethod=e}addElement(e){let t=this.elements.get(e);return t===void 0&&(t={name:e,type:this.newElementType,docRef:this.newDocRef,cssStyles:[],classes:[`default`]},this.elements.set(e,t)),this.newElementType=this.newDocRef=``,t}setNewElementType(e){this.newElementType=e}setNewElementDocRef(e){this.newDocRef=e}addRelationship(e,t,n){this.relations.push({type:e,src:t,dst:n})}node(e){return this.requirements.get(e)??this.elements.get(e)}setCssStyle(e,t){for(let n of e){let e=this.node(n);if(!t||!e)return;for(let n of t)this.copy(e.cssStyles,n.includes(`,`)?n.split(`,`):[n])}}setClass(e,t){for(let n of e){let e=this.node(n);if(e)for(let n of t){e.classes.push(n);let t=this.classes.get(n)?.styles;t&&this.copy(e.cssStyles,t)}}}defineClass(e,t){for(let n of e){let e=this.classes.get(n);e===void 0&&(e={id:n,styles:[],textStyles:[]},this.classes.set(n,e));for(let n of t)n.includes(`color`)&&e.textStyles.push(n.replace(`fill`,`bgFill`)),e.styles.push(n);let r=t.flatMap(e=>e.split(`,`));for(let e of this.requirements.values())e.classes.includes(n)&&this.copy(e.cssStyles,r);for(let e of this.elements.values())e.classes.includes(n)&&this.copy(e.cssStyles,r)}}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,``)}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
1040
1040
|
`)}},$Et=/* @__PURE__ */ `$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`.split(`.`),eDt=/* @__PURE__ */ 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]]),tDt=/accTitle\s*:\s*/iy,nDt=/accDescr\s*:\s*/iy,rDt=/accDescr\s*\{\s*/iy,S1=/direction\s+(?:(TB)|(BT)|(RL)|LR)/gi,C1=/[\n\r\u2028\u2029]/g,iDt=22,aDt=/* @__PURE__ */ new Uint8Array(128);for(let e of`:,\r
|
|
1041
1041
|
{<>-=`)aDt[e.charCodeAt(0)]=1;function oDt(e){let t=e.length,n=[],r=[],i=[],a=[],o=0,s=0,c=[[],[],[],[]],l=[[],[],[],[]],u=[0,0,0,0],d=!1,f=-1;S1.lastIndex=0;for(let t=S1.exec(e);t!==null;t=S1.exec(e)){let e=t[1]===void 0?t[2]===void 0?t[3]===void 0?3:2:1:0;c[e].push(t.index),l[e].push(S1.lastIndex),d=!0}let p=(t,a,o)=>{n.push(t),r.push(e.slice(a,o)),i.push(a),s=o},m=e=>{a.push(o),o=e},h=()=>{a.length>0&&(o=a.pop())},g=(t,n)=>(t.lastIndex=n,t.test(e)?t.lastIndex:-1),_=n=>{let r=e.indexOf(`
|
|
1042
|
-
`,n);return r===-1?t:r},v=()=>{if(f<s){C1.lastIndex=s,f=C1.test(e)?C1.lastIndex-1:t;for(let e=0;e<4;e++){let t=c[e],n=u[e];for(;n<t.length&&t[n]<=f;)n++;u[e]=n}}for(let e=0;e<4;e++){let t=u[e]-1;if(t>=0&&c[e][t]>=s)return p(8+e,s,_(l[e][t])),!0}return!1},y=a=>{let o=a|32;if(o===116&&e.slice(s+1,s+5).toLowerCase()===`itle`&&eq(e.charCodeAt(s+5))){let n=s+6;for(;n<t;){let t=e.charCodeAt(n);if(t===35||t===10||t===59)break;n++}if(n>s+6)return p(2,s,n),!0}if(o===97&&(e.charCodeAt(s+1)|32)==99&&(e.charCodeAt(s+2)|32)==99){let e;if((e=g(tDt,s))>=0)return m(3),p(3,s,e),!0;if((e=g(nDt,s))>=0)return m(4),p(5,s,e),!0;if((e=g(rDt,s))>=0)return m(5),s=e,!0}if(d&&!nq(a)&&v())return!0;if(a===10||a===13&&e.charCodeAt(s+1)===10){let n=s;for(;n<t;){let t=e.charCodeAt(n);if(t===10)n++;else if(t===13&&e.charCodeAt(n+1)===10)n+=2;else break}return p(12,s,n),!0}if(eq(a)){for(s++;s<t&&eq(e.charCodeAt(s));)s++;return!0}if(a===35||a===37)return s=_(s),!0;if(aq(a)){let a=s+1;for(;a<t&&aq(e.charCodeAt(a));)a++;if(a-s<=iDt){let t=eDt.get(e.slice(s,a).toLowerCase());if(t!==void 0)return(t===46||t===47||t===48)&&m(2),p(t,s,a),!0}for(;a<t;){let t=e.charCodeAt(a);if(t<128&&aDt[t]===1)break;a++}return n.push(59),r.push(e.slice(s,a).trim()),i.push(s),s=a,!0}switch(a){case 123:return p(15,s,s+1),!0;case 125:return p(16,s,s+1),!0;case 58:return e.charCodeAt(s+1)===58&&e.charCodeAt(s+2)===58?p(17,s,s+3):p(18,s,s+1),!0;case 60:return e.charCodeAt(s+1)===45&&(p(55,s,s+2),!0);case 45:return e.charCodeAt(s+1)===62?p(56,s,s+2):p(57,s,s+1),!0;case 34:return m(1),s++,!0;case 44:return p(60,s,s+1),!0}return!1},b=n=>{if(aq(n)){let n=s+1;for(;n<t&&aq(e.charCodeAt(n));)n++;return p(49,s,n),!0}switch(n){case 58:return p(50,s,s+1),!0;case 59:return p(51,s,s+1),!0;case 37:return p(52,s,s+1),!0;case 45:return p(53,s,s+1),!0;case 35:return p(54,s,s+1),!0;case 32:return s++,!0;case 34:return m(1),s++,!0;case 10:return h(),s++,!0;case 44:return p(60,s,s+1),!0}return!1};for(;s<t;){let a=e.charCodeAt(s),c=!0;switch(o){case 0:c=y(a);break;case 2:c=b(a);break;case 1:if(a===34)h(),s++;else{let n=e.indexOf(`"`,s);p(58,s,n===-1?t:n)}break;case 3:h(),p(4,s,_(s));break;case 4:h(),p(6,s,_(s));break;case 5:if(a===125)h(),s++;else{let n=e.indexOf(`}`,s);p(7,s,n===-1?t:n)}}if(!c)return n.push(1),r.push(``),i.push(s),{types:n,texts:r,starts:i}}let x=o===0?13:o===1?58:o===3?4:o===4?6:o===5?7:-1;return x!==-1&&p(x,t,t),p(0,t,t),{types:n,texts:r,starts:i}}var sDt=[v1.REQUIREMENT,v1.FUNCTIONAL_REQUIREMENT,v1.INTERFACE_REQUIREMENT,v1.PERFORMANCE_REQUIREMENT,v1.PHYSICAL_REQUIREMENT,v1.DESIGN_CONSTRAINT,y1.LOW_RISK,y1.MED_RISK,y1.HIGH_RISK,b1.VERIFY_ANALYSIS,b1.VERIFY_DEMONSTRATION,b1.VERIFY_INSPECTION,b1.VERIFY_TEST,``,x1.CONTAINS,x1.COPIES,x1.DERIVES,x1.SATISFIES,x1.VERIFIES,x1.REFINES,x1.TRACES];function cDt(e){return e===49||e===50||e===54||e===53||e===51}function lDt(e,t){let{types:n,texts:r,starts:i}=oDt(e),a=0,o=[],s=[],c=(t,r=t,...o)=>{let s=n[a];if(s===1)throw FK(`requirement`,e,i[a],``,!0);for(let e=r;e>=t;e--)o.unshift(e);let c=o.map(e=>`'${$Et[e]}'`).join(`, `);throw FK(`requirement`,e,i[a],`Expecting ${c}, got '${$Et[s]}'`)},l=e=>(n[a]!==e&&c(e),r[a++]),u=(e,t)=>{let r=n[a];return(r<e||r>t)&&c(e,t),a++,sDt[r-23]},d=()=>{let e=n[a];return e!==59&&e!==58&&c(58,59),r[a++]},f=()=>{let e=n[a];if(e===3)a++,t.setAccTitle(l(4).trim());else if(e===5)a++,t.setAccDescription(l(6).trim());else if(e===7)t.setAccDescription(r[a++].trim());else return!1;return!0},p=()=>{let e=[];for(;;){let t=n[a];if(t!==49&&t!==59&&t!==58&&c(58,59,49),e.push(r[a++]),n[a]!==60)return e;a++}},m=()=>{let e=[];for(;;){cDt(n[a])||c(49,51,53,54);let t=r[a++];for(;cDt(n[a]);)t+=r[a++];if(e.push(t),n[a]!==60)return e;a++}},h=()=>{let e;return n[a]===17?(a++,e=p(),l(15)):n[a]===15?a++:c(15,15,17),l(12),e},g=e=>{for(o.length=0,s.length=0;;){let t=n[a];if(t===16){a++;break}t===12?a++:((e?t<19||t>22:t!==44&&t!==45)&&(e&&c(19,22,12,16),c(44,45,12,16)),a++,l(18),s.push(t===21?u(29,31):t===22?u(32,35):d()),o.push(t),l(12))}for(let e=o.length-1;e>=0;e--){let n=s[e];switch(o[e]){case 19:t.setNewReqId(n);break;case 20:t.setNewReqText(n);break;case 21:t.setNewReqRisk(n);break;case 22:t.setNewReqVerifyMethod(n);break;case 44:t.setNewElementType(n);break;default:t.setNewElementDocRef(n)}}};for(;f();)n[a]===12&&a++;for(n[a]!==14&&c(14,14,3,5,7),a++,l(12);;){let e=n[a];if(e===13)return;if(e===12)a++;else{if(f())continue;if(e>=8&&e<=11)a++,t.setDirection(e===8?`TB`:e===9?`BT`:e===10?`RL`:`LR`);else if(e>=23&&e<=28){let e=u(23,28),n=d(),r=h();g(!0),t.addRequirement(n,e),r&&t.setClass([n],r)}else if(e===36){a++;let e=d(),n=h();g(!1),t.addElement(e),n&&t.setClass([e],n)}else if(e===46){a++;let e=p();t.setCssStyle(e,m())}else if(e===47){a++;let e=p();t.defineClass(e,m())}else if(e===48){a++;let e=p();t.setClass(e,p())}else if(e===59||e===58){let e=r[a++],i=n[a];if(i===17)a++,t.setClass([e],p());else if(i===55||i===57){a++;let n=u(37,43);l(i===57?56:57);let r=d();i===57?t.addRelationship(n,e,r):t.addRelationship(n,r,e)}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)}}}function uDt(e){let t=[];for(let n of e.requirements.values())t.push({id:n.name,requirement:n,element:void 0,cssStyles:n.cssStyles,cssClasses:n.classes.join(` `)});for(let n of e.elements.values())t.push({id:n.name,requirement:void 0,element:n,cssStyles:n.cssStyles,cssClasses:n.classes.join(` `)});let n=t=>e.requirements.has(t)||e.elements.has(t)?t:void 0;return{nodes:t,edges:e.relations.map((e,t)=>({id:`${e.src}-${e.dst}-${t}`,start:n(e.src),end:n(e.dst),type:e.type,contains:e.type===x1.CONTAINS})),direction:e.direction}}var dDt=40,fDt=16,pDt=56,w1=14,T1=10,E1=2,mDt=12,hDt=120,gDt=280,_Dt=240,D1=26,vDt=6,yDt=9,O1=4.5,bDt=28,xDt=14;function k1(e,t,n){if(t===0||e.lines.length===0)return e;let r=0,i=[],a=e.lines.map(a=>{let o=0,s=a.map(r=>{let i=r.style|t,a=r.icon===void 0?n.width(r.text,e.size,i):r.width;return o+=a,{...r,style:i,width:a}});return i.push(o),o>r&&(r=o),s});return{...e,lines:a,widths:i,width:r}}function SDt(e,t,n,r){let i=n+e.lineHeight/2+e.size*.35,a=vq(e),o=``;for(let n of e.lines){let r=!0;for(let e of n)e.icon!==void 0||e.text===``||(o+=`<tspan${r?` x="${K(t)}" y="${K(i)}"`:``}${_q(e.style&~a)}>${pq(e.text)}</tspan>`,r=!1);i+=e.lineHeight}return o===``?``:`<text${yq(r,a)} text-anchor="start" xml:space="preserve">${o}</text>`}function CDt(e,t,n,r){let i=vDt,a=e-n*i,o=t-r*i;return`<circle class="pele-marker" cx="${K(a)}" cy="${K(o)}" r="${i}"/><path class="pele-marker" d="M${K(a-n*i)},${K(o-r*i)}L${K(a+n*i)},${K(o+r*i)}M${K(a+r*i)},${K(o-n*i)}L${K(a-r*i)},${K(o+n*i)}"/>`}function wDt(e,t,n,r){let i=e-n*yDt,a=t-r*yDt;return`<path class="pele-marker" d="M${K(i-r*O1)},${K(a+n*O1)}L${K(e)},${K(t)}L${K(i+r*O1)},${K(a-n*O1)}" stroke-linejoin="round"/>`}function TDt(e,t,n){let r=/* @__PURE__ */ new Map;for(let n of t){let t=n.route;if(!(n.src===n.dst||t.length<6))for(let i of[0,t.length-3]){let a=i===0?n.src:n.dst,o=e[a],s=t[i]-o.x,c=t[i+1]-o.y,l=i===0?3:i-3,u;if(Math.abs(Math.abs(c)-o.h/2)<.5)u=c<0?0:2;else if(Math.abs(Math.abs(s)-o.w/2)<.5)u=s<0?3:1;else continue;let d=a*4+u,f={route:t,at:i,toward:t[u%2==0?l:l+1]},p=r.get(d);p?p.push(f):r.set(d,[f])}}for(let[t,i]of r){if(i.length<2)continue;let r=t>>2,a=t%2==1,o=(a?n[r].h:n[r].w)-2*xDt,s=Math.max(0,Math.min(bDt,o/(i.length-1)));i.sort((e,t)=>e.toward-t.toward);for(let t=0;t<i.length;t++){let n=(t-(i.length-1)/2)*s;a?i[t].route[i[t].at+1]=e[r].y+n:i[t].route[i[t].at]=e[r].x+n}}}function EDt(e,t,n){return YJ(e.direction)?JJ(n,r=>DDt(e,t,n,r)):DDt(e,t,n,!1)}function DDt(e,t,n,r){let i=uDt(e),a=n.fontSize??16,o=Math.round(a*.875),s=n.measurer??fq(n.fontFamily),c=n.padding??8,l=/* @__PURE__ */ new Map,u=[],d=[];for(let e of i.nodes){let t=mJ(e.cssStyles),n=+!!t.bold|(t.italic?2:0),r=t.fontSize??a,i=t.fontSize??o,c=e.requirement,f=e.element,p=k1(WJ(`«${c?c.type:`Element`}»`,!1,s,i,4e3),n,s),m=k1(WJ(e.id,!0,s,r,gDt),n|1,s),h=c?[[`ID`,c.requirementId],[`Text`,c.text],[`Risk`,c.risk],[`Verification`,c.verifyMethod]]:[[`Type`,f.type],[`Doc Ref`,f.docRef]],g=[],_=0,v=0,y=0;for(let[e,t]of h){if(!t)continue;let r=k1(WJ(e,!1,s,i,4e3),n,s),a=k1(WJ(t,!0,s,i,_Dt),n,s),o=Math.max(r.height,a.height);g.push({key:r,value:a,height:o}),_=Math.max(_,r.width),v=Math.max(v,a.width),y+=o+E1}g.length>0&&(y+=2*T1-E1);let b=2*T1+p.height+m.height,x=Math.max(hDt,Math.max(p.width,m.width)+2*w1,g.length>0?_+mDt+v+2*w1:0);l.has(e.id)||l.set(e.id,u.length);let S=Qq(x,b+y);S.seq=u.length,u.push({node:e,style:t,kind:p,name:m,rows:g,keyWidth:_,headHeight:b,w:x,h:b+y}),d.push(S)}let f=r?`TB`:Xq(i.direction),p=f===`LR`||f===`RL`,m=[],h=[],g=[];for(let e of i.edges){let t=e.start===void 0?void 0:l.get(e.start),n=e.end===void 0?void 0:l.get(e.end);if(t===void 0||n===void 0)continue;let r=WJ(`«${e.type}»`,!1,s,o,4e3);t===n&&(p?d[t].h+=2*(D1+r.height+8):d[t].w+=2*(D1+r.width+12)),g.push(e),h.push(r),m.push({src:t,dst:n,minlen:1,labelW:r.width+12,labelH:r.height+4,route:[],labelX:0,labelY:0})}let _=eJ(d,m,f,{nodeSep:dDt,edgeSep:fDt,rankSep:pDt,portSep:20});TDt(d,m,u);let v=WJ(e.title,!1,s,a,4e3,1),y=v.height>0?v.height+12:0,b=Math.max(_.width,v.width),x=c+(b-_.width)/2,S=c+y,C=Math.ceil(b+2*c),w=Math.ceil(_.height+y+2*c),T=``;for(let e=0;e<u.length;e++){let t=u[e],{w:n,h:r,style:i}=t,a=-n/2,o=-r/2,s=`<rect x="${K(a)}" y="${K(o)}" width="${K(n)}" height="${K(r)}" rx="${fJ}" fill="var(--_s)" stroke="var(--_b)"${i.shape}/>`+gq(t.kind,0,o+T1+t.kind.height/2,` class="pele-stereotype" font-size="${t.kind.size}" fill="var(--_m)"${i.text}`)+gq(t.name,0,o+T1+t.kind.height+t.name.height/2,` class="pele-label" font-size="${t.name.size}" font-weight="var(--_hw)"${i.text}`);if(t.rows.length>0){let e=o+t.headHeight;s+=`<path class="pele-divider" d="M${K(a)},${K(e)}H${K(-a)}" stroke="var(--_b)"${i.line}/>`;let n=e+T1,r=``;for(let e of t.rows)r+=SDt(e.key,a+w1,n,` class="pele-field" fill="var(--_m)"${i.text}`)+SDt(e.value,a+w1+t.keyWidth+mDt,n,` class="pele-value"${i.text}`),n+=e.height+E1;s+=`<g class="pele-fields" font-size="${t.rows[0].key.size}">${r}</g>`}T+=`<g class="pele-node ${t.node.requirement?`pele-requirement`:`pele-element`}${hJ(t.node.cssClasses.replace(/^default\s?/,``))}" data-id="${mq(t.node.id)}" transform="translate(${K(d[e].x+x)},${K(d[e].y+S)})">${s}</g>`}let E=``,D=``,O=/* @__PURE__ */ new Map;for(let e=0;e<m.length;e++){let t=m[e],n=g[e],r=h[e],i=n.contains?2*vDt:0,a,o=t.labelX+x,s=t.labelY+S;if(t.src===t.dst){let e=u[t.src],n=d[t.src].x+x,r=d[t.src].y+S,c=O.get(t.src)??0;O.set(t.src,c+1);let l=(p?e.w:e.h)/2,f=Math.min(l-4,12+c*6),m=D1+c*8,h=(t,i)=>p?`${K(n+i)},${K(r+e.h/2+t)}`:`${K(n+e.w/2+t)},${K(r+i)}`,g=m/.75;a={d:`M${h(i,-f)}C${h(g,-f)} ${h(g,f)} ${h(0,f)}`,sx:p?n-f:n+e.w/2,sy:p?r+e.h/2:r-f,sdx:p?0:-1,sdy:p?-1:0,ex:p?n+f:n+e.w/2,ey:p?r+e.h/2:r+f,edx:p?0:-1,edy:p?-1:0},p?(o=n,s=r+e.h/2+m+4+t.labelH/2):(o=n+e.w/2+m+4+t.labelW/2,s=r)}else{let e=t.route.slice();for(let t=0;t<e.length;t+=3)e[t]+=x,e[t+1]+=S;a=oJ(e,void 0,i,0)}E+=`<g class="pele-edge pele-relationship-${n.contains?`contains`:`arrow`}" data-id="${mq(n.id)}"><path d="${a.d}"${n.contains?``:` stroke-dasharray="5 4"`}/>`+(n.contains?CDt(a.sx,a.sy,a.sdx,a.sdy):wDt(a.ex,a.ey,a.edx,a.edy))+`</g>`,D+=lJ(n.id,r,o,s,``)}return{svg:vJ(`requirement`,C,w,a,n,e,gq(v,C/2,c+v.height/2,` class="pele-title" font-weight="var(--_tw)"`)+(E?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${E}</g>`:``)+(D?`<g class="pele-edge-labels" font-size="${o}" fill="var(--_m)">${D}</g>`:``)+`<g class="pele-nodes">${T}</g>`),width:C,height:w,links:[]}}var ODt={type:`requirement`,parse(e,t,n){let r=new QEt;return n&&(r.title=n),lDt(e,r),r},render:EDt},kDt=class{type=`sankey`;nodes=[];links=[];title;accTitle;accDescr;lookup=/* @__PURE__ */ new Map;findOrCreateNode(e){let t=this.lookup.get(e);return t===void 0&&(t={id:e,index:this.nodes.length},this.lookup.set(e,t),this.nodes.push(t)),t}addLink(e,t,n){this.links.push({source:e,target:t,value:n})}},A1=[`$end`,`STUCK`,`SANKEY`,`NEWLINE`,`COMMA`,`DQUOTE`,`NON_ESCAPED_TEXT`,`ESCAPED_TEXT`,`EOF`];function ADt(e){return e>=32&&e<=126&&e!==34&&e!==44}function jDt(e){let t=e.length,n=[],r=[],i=[],a=[],o=0,s=0,c=(t,a,o)=>{n.push(t),r.push(e.slice(a,o)),i.push(a),s=o},l=t=>e.slice(s,s+t.length).toLowerCase()===t&&!aq(e.charCodeAt(s+t.length));for(;s<t;){let u=e.charCodeAt(s),d=s,f=s;if(o===2){if(u===34&&e.charCodeAt(s+1)!==34){a.length>0&&(o=a.pop()),c(5,s,s+1);continue}for(;f<t;){let t=e.charCodeAt(f);if(ADt(t)||t===44||t===13||t===10)f++;else if(t===34&&e.charCodeAt(f+1)===34)f+=2;else break}c(7,s,f)}else{if(o===0&&(u|32)==115){let e=l(`sankey-beta`)?11:l(`sankey`)?6:0;if(e>0){a.push(o),o=1,c(2,s,s+e);continue}}if(u===10||u===13&&e.charCodeAt(s+1)===10){c(3,s,u===10?s+1:s+2);continue}if(u===44){c(4,s,s+1);continue}if(u===34){a.push(o),o=2,c(5,s,s+1);continue}for(;f<t&&ADt(e.charCodeAt(f));)f++;c(6,s,f)}if(f===d)return c(1,s,s),{types:n,texts:r,starts:i}}return c(o===2?7:8,t,t),c(0,t,t),{types:n,texts:r,starts:i}}var MDt=/[\n\r]+/g;function NDt(e){return e===10||e===13?!1:e<128?e===32||e===9||e===11||e===12:e===160||e===5760||e>=8192&&e<=8202||e===8232||e===8233||e===8239||e===8287||e===12288||e===65279}function PDt(e){let t=0,n=e.length;for(;t<n&&NDt(e.charCodeAt(t));)t++;for(;n>t&&NDt(e.charCodeAt(n-1));)n--;return e.slice(t,n).replace(MDt,`
|
|
1043
|
-
`).trim()}function FDt(e,t){let{types:n,texts:r,starts:i}=jDt(e),a=0,o=t=>{let r=n[a],o=r===1?A1[n[a-1]]:A1[r];throw FK(`sankey`,e,i[a],`Expecting ${t}, got '${o}'`)},s=(e,t=``)=>{n[a]!==e&&o(`'${A1[e]}'${t}`),a++},c=()=>{if(n[a]===6)return r[a++];n[a]!==5&&o(`'DQUOTE', 'NON_ESCAPED_TEXT'`),a++,n[a]!==7&&o(`'ESCAPED_TEXT'`);let e=r[a++];return s(5),e},l=()=>c().trim().replaceAll(`""`,`"`);for(s(2),s(3);;){let e=l();s(4,`, 'NEWLINE', 'EOF'`);let r=l();s(4,`, 'NEWLINE', 'EOF'`);let i=c(),o=t.findOrCreateNode(e),u=t.findOrCreateNode(r);if(t.addLink(o,u,parseFloat(i.trim())),n[a]!==3)break;a++}n[a]===8&&a++,n[a]!==0&&o(`'NEWLINE', 'EOF'`)}var IDt=6;function j1(e,t){if(e.length>8)e.sort(t);else for(let n=1;n<e.length;n++){let r=e[n],i=n-1;for(;i>=0&&t(e[i],r)>0;)e[i+1]=e[i],i--;e[i+1]=r}}function LDt(e,t){let n=e.nodes.length,r=e.links.map(e=>({source:e.source.index,target:e.target.index,value:Number.isFinite(e.value)&&e.value>0?e.value:0,thickness:0,sourceY:0,targetY:0})),i=[],a=[];for(let e=0;e<n;e++)i.push([]),a.push([]);r.forEach((e,t)=>{i[e.source].push(t),a[e.target].push(t)});let o=new Int32Array(n),s=new Int32Array(n),c=[];for(let e=0;e<n;e++)s[e]=a[e].length,s[e]===0&&c.push(e);for(let e=0;e<c.length;e++){let t=c[e];for(let e of i[t]){let n=r[e].target;o[n]<o[t]+1&&(o[n]=o[t]+1),--s[n]===0&&c.push(n)}}if(c.length<n){let t=0;for(;s[t]===0;)t++;let i=new Uint8Array(n);for(;i[t]===0;){i[t]=1;for(let e of a[t])if(s[r[e].source]>0){t=r[e].source;break}}throw new NK(`Sankey diagrams cannot have circular links, and "${e.nodes[t].id}" is part of one.`,`semantic`,{type:`sankey`})}let l=1;for(let e=0;e<n;e++)o[e]+1>l&&(l=o[e]+1);let u=new Int32Array(n);for(let e=n-1;e>=0;e--){let t=c[e];for(let e of i[t])u[t]<u[r[e].target]+1&&(u[t]=u[r[e].target]+1)}let d=0;for(let e of r)e.value>d&&(d=e.value);let f=d>0?1/d:0,p=[],m=new Float64Array(n),h=[];for(let e=0;e<l;e++)h.push([]);let g=l>1?(t.width-t.nodeWidth)/(l-1):0;for(let e=0;e<n;e++){let n;if(t.alignment===`left`)n=o[e];else if(t.alignment===`right`)n=l-1-u[e];else if(t.alignment===`center`){if(n=o[e],a[e].length===0&&i[e].length>0){n=l;for(let t of i[e])o[r[t].target]-1<n&&(n=o[r[t].target]-1)}}else n=i[e].length>0?o[e]:l-1;let s=0,c=0,d=0,_=0;for(let t of a[e])s+=r[t].value*f,d+=r[t].value;for(let t of i[e])c+=r[t].value*f,_+=r[t].value;m[e]=Math.max(s,c),p.push({layer:n,value:Math.max(d,_),x:n*g,y:0,height:0}),h[n].push(e)}let _=1;for(let e of h)e.length>_&&(_=e.length);let v=_>1?Math.min(t.nodePadding,t.height/(_-1)):t.nodePadding,y=1/0;for(let e of h){let n=0;for(let t of e)n+=m[t];n>0&&(y=Math.min(y,(t.height-(e.length-1)*v)/n))}(!Number.isFinite(y)||y<0)&&(y=0);let b=Math.max(0,t.labelHeight-v),x=e=>{for(let n of h){let r=(n.length-1)*v;for(let t of n)r+=Math.max(m[t]*e,b);if(r>t.height+1e-6)return!1}return!0};if(b>0&&!x(y)){if(x(0)){let e=0;for(let t=0;t<40;t++){let t=(e+y)/2;x(t)?e=t:y=t}y=e}else b=0}let S=new Float64Array(n);for(let e of r)e.thickness=e.value*f*y;for(let e of h){let n=0;for(let t of e)p[t].height=m[t]*y,S[t]=Math.max(0,b-p[t].height)/2,p[t].y=n+S[t],n+=p[t].height+2*S[t]+v;let r=(t.height-n+v)/(e.length+1);e.forEach((e,t)=>p[e].y+=r*(t+1))}let C=e=>p[e].y+p[e].height/2,w=new Float64Array(r.length),T=new Float64Array(r.length),E=(e,t)=>C(r[e].target)-C(r[t].target)||e-t,D=(e,t)=>C(r[e].source)-C(r[t].source)||e-t,O=(e,t)=>C(e)-C(t)||e-t,k=e=>{let t=0;j1(i[e],E);for(let n of i[e])w[n]=t+r[n].thickness/2,t+=r[n].thickness},A=e=>{let t=0;j1(a[e],D);for(let n of a[e])T[n]=t+r[n].thickness/2,t+=r[n].thickness},j=()=>{for(let e=0;e<n;e++)k(e),A(e)},M=(e,n,o)=>{for(let t of e){let e=o?a[t]:i[t];if(e.length===0)continue;o?A(t):k(t);let s=0,c=0,l=0;for(let n of e){let e=o?p[r[n].source].y+w[n]-T[n]:p[r[n].target].y+T[n]-w[n];s+=e*r[n].thickness,c+=r[n].thickness,l+=C(o?r[n].source:r[n].target)-p[t].height/2}let u=c>0?s/c:l/e.length;p[t].y+=(u-p[t].y)*n}j1(e,O);let s=0;for(let t of e)p[t].y-S[t]<s&&(p[t].y=s+S[t]),s=p[t].y+p[t].height+S[t]+v;s=t.height;for(let t=e.length-1;t>=0;t--){let n=e[t];p[n].y+p[n].height+S[n]>s&&(p[n].y=s-p[n].height-S[n]),s=p[n].y-S[n]-v}};j();for(let e=0;e<IDt;e++){let t=.99**e;for(let e=l-2;e>=0;e--)M(h[e],t,!1);j();for(let e=1;e<l;e++)M(h[e],t,!0);j()}for(let e=0;e<r.length;e++)r[e].sourceY=p[r[e].source].y+w[e],r[e].targetY=p[r[e].target].y+T[e];return{nodes:p,links:r}}var RDt=6,zDt=15;function BDt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function M1(e,t,n,r,i){let a=e[t];return typeof a==`number`&&a>=r?Math.min(a,i):n}function VDt(e,t){let n=e[t];return typeof n==`string`||typeof n==`number`&&Number.isFinite(n)?String(n):``}function HDt(e){return Math.abs(e)<0x38d7ea4c68000?Math.round(e*100)/100:e}function UDt(e){return typeof e==`string`?mJ([`fill:${e}`]).shape:``}function WDt(e,t,n){let r=BDt(t.sankey)?t.sankey:{};return GJ(n,M1(r,`width`,600,1,1e4),160,t=>GDt(e,r,n,t))}function GDt(e,t,n,r){let i=n.fontSize??16,a=Math.round(i*.875),o=n.measurer??fq(n.fontFamily),s=n.padding??8,c=M1(t,`height`,400,1,1e4),l=Math.min(M1(t,`nodeWidth`,10,1,200),r),u=t.showValues!==!1,d=VDt(t,`prefix`),f=VDt(t,`suffix`),p=t.labelStyle===`outlined`,m=t.nodeAlignment===`left`||t.nodeAlignment===`right`||t.nodeAlignment===`center`?t.nodeAlignment:`justify`,h=typeof t.linkColor==`string`?t.linkColor:`gradient`,{nodes:g,links:_}=LDt(e,{width:r,height:c,nodeWidth:l,nodePadding:M1(t,`nodePadding`,12,0,200)+(u?zDt:0),labelHeight:a*1.15,alignment:m}),v=/* @__PURE__ */ new Map;if(BDt(t.nodeColors))for(let[e,n]of Object.entries(t.nodeColors)){let t=UDt(n);t&&v.set(e,t)}let y=t=>v.get(e.nodes[t].id)??``,b=0,x=0;g.forEach(e=>{e.value>x&&(x=e.value,b=e.layer)});let S=0,C=r,w=0,T=c,E=``,D=``;g.forEach((t,n)=>{let i=e.nodes[n].id,s=Math.max(t.height,1);D+=`<rect class="pele-sankey-node" data-id="${mq(i)}" x="${K(t.x)}" y="${K(t.y)}" width="${K(l)}" height="${K(s)}" rx="${K(Math.min(2,s/2))}" fill="${gJ(n)}"${y(n)}/>`;let c=u?`${d}${HDt(t.value)}${f}`:``,m=p?t.layer>=b:t.x<r/2,h=o.width(c?`${i} ${c}`:i,a,0),g=m?t.x+l+RDt:t.x-RDt,_=t.y+t.height/2;S=Math.min(S,m?g:g-h),C=Math.max(C,m?g+h:g),w=Math.min(w,_-a*.75),T=Math.max(T,_+a*.75);let v=` x="${K(g)}" y="${K(_+a*.35)}" text-anchor="${m?`start`:`end`}"`,x=pq(i)+(c?` <tspan class="pele-sankey-value" fill="var(--_m)">${pq(c)}</tspan>`:``);E+=`<g class="pele-label" data-id="${mq(i)}">`+(p?`<text${v} fill="none" stroke="var(--_bg)" stroke-width="3" stroke-linejoin="round">${pq(i)}${c?` `+pq(c):``}</text>`:``)+`<text${v}>${x}</text></g>`});let O=h===`gradient`||h===`source`||h===`target`?``:UDt(h),k=``;for(let t of _){let n=h===`target`?t.target:t.source,r=Math.max(t.thickness,1)/2,i=g[t.source].x+l,a=g[t.target].x,o=K((i+a)/2),s=mq(e.nodes[t.source].id),c=mq(e.nodes[t.target].id);k+=`<path class="pele-sankey-link" data-id="${s}->${c}" d="M${K(i)},${K(t.sourceY-r)}C${o},${K(t.sourceY-r)} ${o},${K(t.targetY-r)} ${K(a)},${K(t.targetY-r)}L${K(a)},${K(t.targetY+r)}C${o},${K(t.targetY+r)} ${o},${K(t.sourceY+r)} ${K(i)},${K(t.sourceY+r)}Z" fill="${gJ(n)}"${O||y(n)}><title>${s} → ${c}: ${mq(d)}${HDt(t.value)}${mq(f)}</title></path>`}let A=WJ(e.title,!1,o,i,KJ(n),1),j=A.height>0?A.height+12:0,M=Math.max(C-S,A.width),N=s-S+(M-(C-S))/2,P=s+j-w,F=Math.ceil(M+2*s),ee=Math.ceil(T-w+j+2*s);return{svg:vJ(`sankey`,F,ee,i,n,e,gq(A,F/2,s+A.height/2,` class="pele-title" font-weight="var(--_tw)"`)+`<g transform="translate(${K(N)},${K(P)})"><g class="pele-sankey-links" fill-opacity="0.4">${k}</g><g class="pele-sankey-nodes">${D}</g><g class="pele-labels" font-size="${a}">${E}</g></g>`),width:F,height:ee,links:[]}}var KDt={type:`sankey`,parse(e,t,n){let r=new kDt;return n&&(r.title=n),FDt(PDt(e),r),r},render:WDt},qDt=`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`,JDt,YDt=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?(%|deg|grad|rad|turn)?$/i;function XDt(e){if(e.toLowerCase()===`none`)return 4;let t=YDt.exec(e);return t?t[1]===void 0?1:t[1]===`%`?2:3:0}function ZDt(e,t){let n=XDt(e);return n===1||n===2||t&&n===4}function QDt(e){let t=e.startsWith(`hsl`),n=e.indexOf(`(`),r=e.slice(0,n);if(r!==`rgb`&&r!==`rgba`&&r!==`hsl`&&r!==`hsla`||e.length>120||e.indexOf(`)`)!==e.length-1)return!1;let i=e.slice(n+1,-1).trim(),a,o,s=i.includes(`,`);if(s)a=i.split(`,`).map(e=>e.trim()),a.length===4&&(o=a.pop());else{let e=i.split(`/`);if(e.length>2)return!1;a=e[0].trim().split(/\s+/),e.length===2&&(o=e[1].trim())}if(a.length!==3||o!==void 0&&!ZDt(o,!s))return!1;let c=a.map(XDt);if(s)return t?(c[0]===1||c[0]===3)&&c[1]===2&&c[2]===2:(c[0]===1||c[0]===2)&&c[1]===c[0]&&c[2]===c[0];for(let e=0;e<3;e++){let n=c[e];if(!(n===1||n===4||(t&&e===0?n===3:n===2)))return!1}return!0}function $Dt(e){return e.includes(`(`)?QDt(e):(JDt??=new Set(qDt.split(` `)),JDt.has(e.toLowerCase()))}var eOt=/^:?wrap:/,tOt=/^:?nowrap:/,nOt=/^:?(?:no)?wrap:/,rOt=/^(?:rgba?|hsla?)\s*\(/,iOt=/[\r\u2028\u2029]/,aOt=/^\w*/;function N1(e){throw new NK(e,`semantic`,{type:`sequence`})}function oOt(e){let t=e.trim(),n=eOt.test(t)?!0:!tOt.test(t)&&void 0;return{text:(n===void 0?t:t.replace(nOt,``)).trim(),wrap:n}}function sOt(e){let t=rOt.exec(e);if(t){let n=e.lastIndexOf(`)`);if(n>=t[0].length)return iOt.test(e.slice(t[0].length))?void 0:[e.slice(0,n+1),e.slice(n+1)]}if(iOt.test(e))return;let n=aOt.exec(e)[0];return[n,e.slice(n.length)]}function cOt(e){return typeof e==`string`?[...e].map((e,t)=>[String(t),e]):typeof e==`object`&&e?Object.entries(e):[]}var lOt=class{type=`sequence`;actors=/* @__PURE__ */ new Map;createdActors=/* @__PURE__ */ new Map;destroyedActors=/* @__PURE__ */ new Map;boxes=[];messages=[];notes=[];title;accTitle;accDescr;prevActor;currentBox;lastCreated;lastDestroyed;wrapEnabled;sequenceWrap;active=/* @__PURE__ */ new Map;constructor(e={}){this.wrapEnabled=e.wrap,this.sequenceWrap=e.sequenceWrap??!1}autoWrap(){return this.wrapEnabled??this.sequenceWrap}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,``)}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
1042
|
+
`,n);return r===-1?t:r},v=()=>{if(f<s){C1.lastIndex=s,f=C1.test(e)?C1.lastIndex-1:t;for(let e=0;e<4;e++){let t=c[e],n=u[e];for(;n<t.length&&t[n]<=f;)n++;u[e]=n}}for(let e=0;e<4;e++){let t=u[e]-1;if(t>=0&&c[e][t]>=s)return p(8+e,s,_(l[e][t])),!0}return!1},y=a=>{let o=a|32;if(o===116&&e.slice(s+1,s+5).toLowerCase()===`itle`&&eq(e.charCodeAt(s+5))){let n=s+6;for(;n<t;){let t=e.charCodeAt(n);if(t===35||t===10||t===59)break;n++}if(n>s+6)return p(2,s,n),!0}if(o===97&&(e.charCodeAt(s+1)|32)==99&&(e.charCodeAt(s+2)|32)==99){let e;if((e=g(tDt,s))>=0)return m(3),p(3,s,e),!0;if((e=g(nDt,s))>=0)return m(4),p(5,s,e),!0;if((e=g(rDt,s))>=0)return m(5),s=e,!0}if(d&&!nq(a)&&v())return!0;if(a===10||a===13&&e.charCodeAt(s+1)===10){let n=s;for(;n<t;){let t=e.charCodeAt(n);if(t===10)n++;else if(t===13&&e.charCodeAt(n+1)===10)n+=2;else break}return p(12,s,n),!0}if(eq(a)){for(s++;s<t&&eq(e.charCodeAt(s));)s++;return!0}if(a===35||a===37)return s=_(s),!0;if(aq(a)){let a=s+1;for(;a<t&&aq(e.charCodeAt(a));)a++;if(a-s<=iDt){let t=eDt.get(e.slice(s,a).toLowerCase());if(t!==void 0)return(t===46||t===47||t===48)&&m(2),p(t,s,a),!0}for(;a<t;){let t=e.charCodeAt(a);if(t<128&&aDt[t]===1)break;a++}return n.push(59),r.push(e.slice(s,a).trim()),i.push(s),s=a,!0}switch(a){case 123:return p(15,s,s+1),!0;case 125:return p(16,s,s+1),!0;case 58:return e.charCodeAt(s+1)===58&&e.charCodeAt(s+2)===58?p(17,s,s+3):p(18,s,s+1),!0;case 60:return e.charCodeAt(s+1)===45&&(p(55,s,s+2),!0);case 45:return e.charCodeAt(s+1)===62?p(56,s,s+2):p(57,s,s+1),!0;case 34:return m(1),s++,!0;case 44:return p(60,s,s+1),!0}return!1},b=n=>{if(aq(n)){let n=s+1;for(;n<t&&aq(e.charCodeAt(n));)n++;return p(49,s,n),!0}switch(n){case 58:return p(50,s,s+1),!0;case 59:return p(51,s,s+1),!0;case 37:return p(52,s,s+1),!0;case 45:return p(53,s,s+1),!0;case 35:return p(54,s,s+1),!0;case 32:return s++,!0;case 34:return m(1),s++,!0;case 10:return h(),s++,!0;case 44:return p(60,s,s+1),!0}return!1};for(;s<t;){let a=e.charCodeAt(s),c=!0;switch(o){case 0:c=y(a);break;case 2:c=b(a);break;case 1:if(a===34)h(),s++;else{let n=e.indexOf(`"`,s);p(58,s,n===-1?t:n)}break;case 3:h(),p(4,s,_(s));break;case 4:h(),p(6,s,_(s));break;case 5:if(a===125)h(),s++;else{let n=e.indexOf(`}`,s);p(7,s,n===-1?t:n)}}if(!c)return n.push(1),r.push(``),i.push(s),{types:n,texts:r,starts:i}}let x=o===0?13:o===1?58:o===3?4:o===4?6:o===5?7:-1;return x!==-1&&p(x,t,t),p(0,t,t),{types:n,texts:r,starts:i}}var sDt=[v1.REQUIREMENT,v1.FUNCTIONAL_REQUIREMENT,v1.INTERFACE_REQUIREMENT,v1.PERFORMANCE_REQUIREMENT,v1.PHYSICAL_REQUIREMENT,v1.DESIGN_CONSTRAINT,y1.LOW_RISK,y1.MED_RISK,y1.HIGH_RISK,b1.VERIFY_ANALYSIS,b1.VERIFY_DEMONSTRATION,b1.VERIFY_INSPECTION,b1.VERIFY_TEST,``,x1.CONTAINS,x1.COPIES,x1.DERIVES,x1.SATISFIES,x1.VERIFIES,x1.REFINES,x1.TRACES];function cDt(e){return e===49||e===50||e===54||e===53||e===51}function lDt(e,t){let{types:n,texts:r,starts:i}=oDt(e),a=0,o=[],s=[],c=(t,r=t,...o)=>{let s=n[a];if(s===1)throw FK(`requirement`,e,i[a],``,!0);for(let e=r;e>=t;e--)o.unshift(e);let c=o.map(e=>`'${$Et[e]}'`).join(`, `);throw FK(`requirement`,e,i[a],`Expecting ${c}, got '${$Et[s]}'`)},l=e=>(n[a]!==e&&c(e),r[a++]),u=(e,t)=>{let r=n[a];return(r<e||r>t)&&c(e,t),a++,sDt[r-23]},d=()=>{let e=n[a];return e!==59&&e!==58&&c(58,59),r[a++]},f=()=>{let e=n[a];if(e===3)a++,t.setAccTitle(l(4).trim());else if(e===5)a++,t.setAccDescription(l(6).trim());else if(e===7)t.setAccDescription(r[a++].trim());else return!1;return!0},p=()=>{let e=[];for(;;){let t=n[a];if(t!==49&&t!==59&&t!==58&&c(58,59,49),e.push(r[a++]),n[a]!==60)return e;a++}},m=()=>{let e=[];for(;;){cDt(n[a])||c(49,51,53,54);let t=r[a++];for(;cDt(n[a]);)t+=r[a++];if(e.push(t),n[a]!==60)return e;a++}},h=()=>{let e;return n[a]===17?(a++,e=p(),l(15)):n[a]===15?a++:c(15,15,17),l(12),e},g=e=>{for(o.length=0,s.length=0;;){let t=n[a];if(t===16){a++;break}t===12?a++:((e?t<19||t>22:t!==44&&t!==45)&&(e&&c(19,22,12,16),c(44,45,12,16)),a++,l(18),s.push(t===21?u(29,31):t===22?u(32,35):d()),o.push(t),l(12))}for(let e=o.length-1;e>=0;e--){let n=s[e];switch(o[e]){case 19:t.setNewReqId(n);break;case 20:t.setNewReqText(n);break;case 21:t.setNewReqRisk(n);break;case 22:t.setNewReqVerifyMethod(n);break;case 44:t.setNewElementType(n);break;default:t.setNewElementDocRef(n)}}};for(;f();)n[a]===12&&a++;for(n[a]!==14&&c(14,14,3,5,7),a++,l(12);;){let e=n[a];if(e===13)return;if(e===12)a++;else{if(f())continue;if(e>=8&&e<=11)a++,t.setDirection(e===8?`TB`:e===9?`BT`:e===10?`RL`:`LR`);else if(e>=23&&e<=28){let e=u(23,28),n=d(),r=h();g(!0),t.addRequirement(n,e),r&&t.setClass([n],r)}else if(e===36){a++;let e=d(),n=h();g(!1),t.addElement(e),n&&t.setClass([e],n)}else if(e===46){a++;let e=p();t.setCssStyle(e,m())}else if(e===47){a++;let e=p();t.defineClass(e,m())}else if(e===48){a++;let e=p();t.setClass(e,p())}else if(e===59||e===58){let e=r[a++],i=n[a];if(i===17)a++,t.setClass([e],p());else if(i===55||i===57){a++;let n=u(37,43);l(i===57?56:57);let r=d();i===57?t.addRelationship(n,e,r):t.addRelationship(n,r,e)}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)}}}function uDt(e){let t=[];for(let n of e.requirements.values())t.push({id:n.name,requirement:n,element:void 0,cssStyles:n.cssStyles,cssClasses:n.classes.join(` `)});for(let n of e.elements.values())t.push({id:n.name,requirement:void 0,element:n,cssStyles:n.cssStyles,cssClasses:n.classes.join(` `)});let n=t=>e.requirements.has(t)||e.elements.has(t)?t:void 0;return{nodes:t,edges:e.relations.map((e,t)=>({id:`${e.src}-${e.dst}-${t}`,start:n(e.src),end:n(e.dst),type:e.type,contains:e.type===x1.CONTAINS})),direction:e.direction}}var dDt=40,fDt=16,pDt=56,w1=14,T1=10,E1=2,mDt=12,hDt=120,gDt=280,_Dt=240,D1=26,vDt=6,yDt=9,O1=4.5,bDt=28,xDt=14;function k1(e,t,n){if(t===0||e.lines.length===0)return e;let r=0,i=[],a=e.lines.map(a=>{let o=0,s=a.map(r=>{let i=r.style|t,a=r.icon===void 0?n.width(r.text,e.size,i):r.width;return o+=a,{...r,style:i,width:a}});return i.push(o),o>r&&(r=o),s});return{...e,lines:a,widths:i,width:r}}function SDt(e,t,n,r){let i=n+e.lineHeight/2+e.size*.35,a=vq(e),o=``;for(let n of e.lines){let r=!0;for(let e of n)e.icon!==void 0||e.text===``||(o+=`<tspan${r?` x="${K(t)}" y="${K(i)}"`:``}${_q(e.style&~a)}>${pq(e.text)}</tspan>`,r=!1);i+=e.lineHeight}return o===``?``:`<text${yq(r,a)} text-anchor="start" xml:space="preserve">${o}</text>`}function CDt(e,t,n,r){let i=vDt,a=e-n*i,o=t-r*i;return`<circle class="pele-marker" cx="${K(a)}" cy="${K(o)}" r="${i}"/><path class="pele-marker" d="M${K(a-n*i)},${K(o-r*i)}L${K(a+n*i)},${K(o+r*i)}M${K(a+r*i)},${K(o-n*i)}L${K(a-r*i)},${K(o+n*i)}"/>`}function wDt(e,t,n,r){let i=e-n*yDt,a=t-r*yDt;return`<path class="pele-marker" d="M${K(i-r*O1)},${K(a+n*O1)}L${K(e)},${K(t)}L${K(i+r*O1)},${K(a-n*O1)}" stroke-linejoin="round"/>`}function TDt(e,t,n){let r=/* @__PURE__ */ new Map;for(let n of t){let t=n.route;if(!(n.src===n.dst||t.length<6))for(let i of[0,t.length-3]){let a=i===0?n.src:n.dst,o=e[a],s=t[i]-o.x,c=t[i+1]-o.y,l=i===0?3:i-3,u;if(Math.abs(Math.abs(c)-o.h/2)<.5)u=c<0?0:2;else if(Math.abs(Math.abs(s)-o.w/2)<.5)u=s<0?3:1;else continue;let d=a*4+u,f={route:t,at:i,toward:t[u%2==0?l:l+1]},p=r.get(d);p?p.push(f):r.set(d,[f])}}for(let[t,i]of r){if(i.length<2)continue;let r=t>>2,a=t%2==1,o=(a?n[r].h:n[r].w)-2*xDt,s=Math.max(0,Math.min(bDt,o/(i.length-1)));i.sort((e,t)=>e.toward-t.toward);for(let t=0;t<i.length;t++){let n=(t-(i.length-1)/2)*s;a?i[t].route[i[t].at+1]=e[r].y+n:i[t].route[i[t].at]=e[r].x+n}}}function EDt(e,t,n){return JJ(e.direction)?qJ(n,r=>DDt(e,t,n,r)):DDt(e,t,n,!1)}function DDt(e,t,n,r){let i=uDt(e),a=n.fontSize??16,o=Math.round(a*.875),s=n.measurer??fq(n.fontFamily),c=n.padding??8,l=/* @__PURE__ */ new Map,u=[],d=[];for(let e of i.nodes){let t=pJ(e.cssStyles),n=+!!t.bold|(t.italic?2:0),r=t.fontSize??a,i=t.fontSize??o,c=e.requirement,f=e.element,p=k1(UJ(`«${c?c.type:`Element`}»`,!1,s,i,4e3),n,s),m=k1(UJ(e.id,!0,s,r,gDt),n|1,s),h=c?[[`ID`,c.requirementId],[`Text`,c.text],[`Risk`,c.risk],[`Verification`,c.verifyMethod]]:[[`Type`,f.type],[`Doc Ref`,f.docRef]],g=[],_=0,v=0,y=0;for(let[e,t]of h){if(!t)continue;let r=k1(UJ(e,!1,s,i,4e3),n,s),a=k1(UJ(t,!0,s,i,_Dt),n,s),o=Math.max(r.height,a.height);g.push({key:r,value:a,height:o}),_=Math.max(_,r.width),v=Math.max(v,a.width),y+=o+E1}g.length>0&&(y+=2*T1-E1);let b=2*T1+p.height+m.height,x=Math.max(hDt,Math.max(p.width,m.width)+2*w1,g.length>0?_+mDt+v+2*w1:0);l.has(e.id)||l.set(e.id,u.length);let S=Qq(x,b+y);S.seq=u.length,u.push({node:e,style:t,kind:p,name:m,rows:g,keyWidth:_,headHeight:b,w:x,h:b+y}),d.push(S)}let f=r?`TB`:Xq(i.direction),p=f===`LR`||f===`RL`,m=[],h=[],g=[];for(let e of i.edges){let t=e.start===void 0?void 0:l.get(e.start),n=e.end===void 0?void 0:l.get(e.end);if(t===void 0||n===void 0)continue;let r=UJ(`«${e.type}»`,!1,s,o,4e3);t===n&&(p?d[t].h+=2*(D1+r.height+8):d[t].w+=2*(D1+r.width+12)),g.push(e),h.push(r),m.push({src:t,dst:n,minlen:1,labelW:r.width+12,labelH:r.height+4,route:[],labelX:0,labelY:0})}let _=eJ(d,m,f,{nodeSep:dDt,edgeSep:fDt,rankSep:pDt,portSep:20});TDt(d,m,u);let v=UJ(e.title,!1,s,a,4e3,1),y=v.height>0?v.height+12:0,b=Math.max(_.width,v.width),x=c+(b-_.width)/2,S=c+y,C=Math.ceil(b+2*c),w=Math.ceil(_.height+y+2*c),T=``;for(let e=0;e<u.length;e++){let t=u[e],{w:n,h:r,style:i}=t,a=-n/2,o=-r/2,s=`<rect x="${K(a)}" y="${K(o)}" width="${K(n)}" height="${K(r)}" rx="${dJ}" fill="var(--_s)" stroke="var(--_b)"${i.shape}/>`+gq(t.kind,0,o+T1+t.kind.height/2,` class="pele-stereotype" font-size="${t.kind.size}" fill="var(--_m)"${i.text}`)+gq(t.name,0,o+T1+t.kind.height+t.name.height/2,` class="pele-label" font-size="${t.name.size}" font-weight="var(--_hw)"${i.text}`);if(t.rows.length>0){let e=o+t.headHeight;s+=`<path class="pele-divider" d="M${K(a)},${K(e)}H${K(-a)}" stroke="var(--_b)"${i.line}/>`;let n=e+T1,r=``;for(let e of t.rows)r+=SDt(e.key,a+w1,n,` class="pele-field" fill="var(--_m)"${i.text}`)+SDt(e.value,a+w1+t.keyWidth+mDt,n,` class="pele-value"${i.text}`),n+=e.height+E1;s+=`<g class="pele-fields" font-size="${t.rows[0].key.size}">${r}</g>`}T+=`<g class="pele-node ${t.node.requirement?`pele-requirement`:`pele-element`}${mJ(t.node.cssClasses.replace(/^default\s?/,``))}" data-id="${mq(t.node.id)}" transform="translate(${K(d[e].x+x)},${K(d[e].y+S)})">${s}</g>`}let E=``,D=``,O=/* @__PURE__ */ new Map;for(let e=0;e<m.length;e++){let t=m[e],n=g[e],r=h[e],i=n.contains?2*vDt:0,a,o=t.labelX+x,s=t.labelY+S;if(t.src===t.dst){let e=u[t.src],n=d[t.src].x+x,r=d[t.src].y+S,c=O.get(t.src)??0;O.set(t.src,c+1);let l=(p?e.w:e.h)/2,f=Math.min(l-4,12+c*6),m=D1+c*8,h=(t,i)=>p?`${K(n+i)},${K(r+e.h/2+t)}`:`${K(n+e.w/2+t)},${K(r+i)}`,g=m/.75;a={d:`M${h(i,-f)}C${h(g,-f)} ${h(g,f)} ${h(0,f)}`,sx:p?n-f:n+e.w/2,sy:p?r+e.h/2:r-f,sdx:p?0:-1,sdy:p?-1:0,ex:p?n+f:n+e.w/2,ey:p?r+e.h/2:r+f,edx:p?0:-1,edy:p?-1:0},p?(o=n,s=r+e.h/2+m+4+t.labelH/2):(o=n+e.w/2+m+4+t.labelW/2,s=r)}else{let e=t.route.slice();for(let t=0;t<e.length;t+=3)e[t]+=x,e[t+1]+=S;a=oJ(e,void 0,i,0)}E+=`<g class="pele-edge pele-relationship-${n.contains?`contains`:`arrow`}" data-id="${mq(n.id)}"><path d="${a.d}"${n.contains?``:` stroke-dasharray="5 4"`}/>`+(n.contains?CDt(a.sx,a.sy,a.sdx,a.sdy):wDt(a.ex,a.ey,a.edx,a.edy))+`</g>`,D+=lJ(n.id,r,o,s,``)}return{svg:_J(`requirement`,C,w,a,n,e,gq(v,C/2,c+v.height/2,` class="pele-title" font-weight="var(--_tw)"`)+(E?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${E}</g>`:``)+(D?`<g class="pele-edge-labels" font-size="${o}" fill="var(--_m)">${D}</g>`:``)+`<g class="pele-nodes">${T}</g>`),width:C,height:w,links:[]}}var ODt={type:`requirement`,parse(e,t,n){let r=new QEt;return n&&(r.title=n),lDt(e,r),r},render:EDt},kDt=class{type=`sankey`;nodes=[];links=[];title;accTitle;accDescr;lookup=/* @__PURE__ */ new Map;findOrCreateNode(e){let t=this.lookup.get(e);return t===void 0&&(t={id:e,index:this.nodes.length},this.lookup.set(e,t),this.nodes.push(t)),t}addLink(e,t,n){this.links.push({source:e,target:t,value:n})}},A1=[`$end`,`STUCK`,`SANKEY`,`NEWLINE`,`COMMA`,`DQUOTE`,`NON_ESCAPED_TEXT`,`ESCAPED_TEXT`,`EOF`];function ADt(e){return e>=32&&e<=126&&e!==34&&e!==44}function jDt(e){let t=e.length,n=[],r=[],i=[],a=[],o=0,s=0,c=(t,a,o)=>{n.push(t),r.push(e.slice(a,o)),i.push(a),s=o},l=t=>e.slice(s,s+t.length).toLowerCase()===t&&!aq(e.charCodeAt(s+t.length));for(;s<t;){let u=e.charCodeAt(s),d=s,f=s;if(o===2){if(u===34&&e.charCodeAt(s+1)!==34){a.length>0&&(o=a.pop()),c(5,s,s+1);continue}for(;f<t;){let t=e.charCodeAt(f);if(ADt(t)||t===44||t===13||t===10)f++;else if(t===34&&e.charCodeAt(f+1)===34)f+=2;else break}c(7,s,f)}else{if(o===0&&(u|32)==115){let e=l(`sankey-beta`)?11:l(`sankey`)?6:0;if(e>0){a.push(o),o=1,c(2,s,s+e);continue}}if(u===10||u===13&&e.charCodeAt(s+1)===10){c(3,s,u===10?s+1:s+2);continue}if(u===44){c(4,s,s+1);continue}if(u===34){a.push(o),o=2,c(5,s,s+1);continue}for(;f<t&&ADt(e.charCodeAt(f));)f++;c(6,s,f)}if(f===d)return c(1,s,s),{types:n,texts:r,starts:i}}return c(o===2?7:8,t,t),c(0,t,t),{types:n,texts:r,starts:i}}var MDt=/[\n\r]+/g;function NDt(e){return e===10||e===13?!1:e<128?e===32||e===9||e===11||e===12:e===160||e===5760||e>=8192&&e<=8202||e===8232||e===8233||e===8239||e===8287||e===12288||e===65279}function PDt(e){let t=0,n=e.length;for(;t<n&&NDt(e.charCodeAt(t));)t++;for(;n>t&&NDt(e.charCodeAt(n-1));)n--;return e.slice(t,n).replace(MDt,`
|
|
1043
|
+
`).trim()}function FDt(e,t){let{types:n,texts:r,starts:i}=jDt(e),a=0,o=t=>{let r=n[a],o=r===1?A1[n[a-1]]:A1[r];throw FK(`sankey`,e,i[a],`Expecting ${t}, got '${o}'`)},s=(e,t=``)=>{n[a]!==e&&o(`'${A1[e]}'${t}`),a++},c=()=>{if(n[a]===6)return r[a++];n[a]!==5&&o(`'DQUOTE', 'NON_ESCAPED_TEXT'`),a++,n[a]!==7&&o(`'ESCAPED_TEXT'`);let e=r[a++];return s(5),e},l=()=>c().trim().replaceAll(`""`,`"`);for(s(2),s(3);;){let e=l();s(4,`, 'NEWLINE', 'EOF'`);let r=l();s(4,`, 'NEWLINE', 'EOF'`);let i=c(),o=t.findOrCreateNode(e),u=t.findOrCreateNode(r);if(t.addLink(o,u,parseFloat(i.trim())),n[a]!==3)break;a++}n[a]===8&&a++,n[a]!==0&&o(`'NEWLINE', 'EOF'`)}var IDt=6;function j1(e,t){if(e.length>8)e.sort(t);else for(let n=1;n<e.length;n++){let r=e[n],i=n-1;for(;i>=0&&t(e[i],r)>0;)e[i+1]=e[i],i--;e[i+1]=r}}function LDt(e,t){let n=e.nodes.length,r=e.links.map(e=>({source:e.source.index,target:e.target.index,value:Number.isFinite(e.value)&&e.value>0?e.value:0,thickness:0,sourceY:0,targetY:0})),i=[],a=[];for(let e=0;e<n;e++)i.push([]),a.push([]);r.forEach((e,t)=>{i[e.source].push(t),a[e.target].push(t)});let o=new Int32Array(n),s=new Int32Array(n),c=[];for(let e=0;e<n;e++)s[e]=a[e].length,s[e]===0&&c.push(e);for(let e=0;e<c.length;e++){let t=c[e];for(let e of i[t]){let n=r[e].target;o[n]<o[t]+1&&(o[n]=o[t]+1),--s[n]===0&&c.push(n)}}if(c.length<n){let t=0;for(;s[t]===0;)t++;let i=new Uint8Array(n);for(;i[t]===0;){i[t]=1;for(let e of a[t])if(s[r[e].source]>0){t=r[e].source;break}}throw new NK(`Sankey diagrams cannot have circular links, and "${e.nodes[t].id}" is part of one.`,`semantic`,{type:`sankey`})}let l=1;for(let e=0;e<n;e++)o[e]+1>l&&(l=o[e]+1);let u=new Int32Array(n);for(let e=n-1;e>=0;e--){let t=c[e];for(let e of i[t])u[t]<u[r[e].target]+1&&(u[t]=u[r[e].target]+1)}let d=0;for(let e of r)e.value>d&&(d=e.value);let f=d>0?1/d:0,p=[],m=new Float64Array(n),h=[];for(let e=0;e<l;e++)h.push([]);let g=l>1?(t.width-t.nodeWidth)/(l-1):0;for(let e=0;e<n;e++){let n;if(t.alignment===`left`)n=o[e];else if(t.alignment===`right`)n=l-1-u[e];else if(t.alignment===`center`){if(n=o[e],a[e].length===0&&i[e].length>0){n=l;for(let t of i[e])o[r[t].target]-1<n&&(n=o[r[t].target]-1)}}else n=i[e].length>0?o[e]:l-1;let s=0,c=0,d=0,_=0;for(let t of a[e])s+=r[t].value*f,d+=r[t].value;for(let t of i[e])c+=r[t].value*f,_+=r[t].value;m[e]=Math.max(s,c),p.push({layer:n,value:Math.max(d,_),x:n*g,y:0,height:0}),h[n].push(e)}let _=1;for(let e of h)e.length>_&&(_=e.length);let v=_>1?Math.min(t.nodePadding,t.height/(_-1)):t.nodePadding,y=1/0;for(let e of h){let n=0;for(let t of e)n+=m[t];n>0&&(y=Math.min(y,(t.height-(e.length-1)*v)/n))}(!Number.isFinite(y)||y<0)&&(y=0);let b=Math.max(0,t.labelHeight-v),x=e=>{for(let n of h){let r=(n.length-1)*v;for(let t of n)r+=Math.max(m[t]*e,b);if(r>t.height+1e-6)return!1}return!0};if(b>0&&!x(y)){if(x(0)){let e=0;for(let t=0;t<40;t++){let t=(e+y)/2;x(t)?e=t:y=t}y=e}else b=0}let S=new Float64Array(n);for(let e of r)e.thickness=e.value*f*y;for(let e of h){let n=0;for(let t of e)p[t].height=m[t]*y,S[t]=Math.max(0,b-p[t].height)/2,p[t].y=n+S[t],n+=p[t].height+2*S[t]+v;let r=(t.height-n+v)/(e.length+1);e.forEach((e,t)=>p[e].y+=r*(t+1))}let C=e=>p[e].y+p[e].height/2,w=new Float64Array(r.length),T=new Float64Array(r.length),E=(e,t)=>C(r[e].target)-C(r[t].target)||e-t,D=(e,t)=>C(r[e].source)-C(r[t].source)||e-t,O=(e,t)=>C(e)-C(t)||e-t,k=e=>{let t=0;j1(i[e],E);for(let n of i[e])w[n]=t+r[n].thickness/2,t+=r[n].thickness},A=e=>{let t=0;j1(a[e],D);for(let n of a[e])T[n]=t+r[n].thickness/2,t+=r[n].thickness},j=()=>{for(let e=0;e<n;e++)k(e),A(e)},M=(e,n,o)=>{for(let t of e){let e=o?a[t]:i[t];if(e.length===0)continue;o?A(t):k(t);let s=0,c=0,l=0;for(let n of e){let e=o?p[r[n].source].y+w[n]-T[n]:p[r[n].target].y+T[n]-w[n];s+=e*r[n].thickness,c+=r[n].thickness,l+=C(o?r[n].source:r[n].target)-p[t].height/2}let u=c>0?s/c:l/e.length;p[t].y+=(u-p[t].y)*n}j1(e,O);let s=0;for(let t of e)p[t].y-S[t]<s&&(p[t].y=s+S[t]),s=p[t].y+p[t].height+S[t]+v;s=t.height;for(let t=e.length-1;t>=0;t--){let n=e[t];p[n].y+p[n].height+S[n]>s&&(p[n].y=s-p[n].height-S[n]),s=p[n].y-S[n]-v}};j();for(let e=0;e<IDt;e++){let t=.99**e;for(let e=l-2;e>=0;e--)M(h[e],t,!1);j();for(let e=1;e<l;e++)M(h[e],t,!0);j()}for(let e=0;e<r.length;e++)r[e].sourceY=p[r[e].source].y+w[e],r[e].targetY=p[r[e].target].y+T[e];return{nodes:p,links:r}}var RDt=6,zDt=15;function BDt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function M1(e,t,n,r,i){let a=e[t];return typeof a==`number`&&a>=r?Math.min(a,i):n}function VDt(e,t){let n=e[t];return typeof n==`string`||typeof n==`number`&&Number.isFinite(n)?String(n):``}function HDt(e){return Math.abs(e)<0x38d7ea4c68000?Math.round(e*100)/100:e}function UDt(e){return typeof e==`string`?pJ([`fill:${e}`]).shape:``}function WDt(e,t,n){let r=BDt(t.sankey)?t.sankey:{};return WJ(n,M1(r,`width`,600,1,1e4),160,t=>GDt(e,r,n,t))}function GDt(e,t,n,r){let i=n.fontSize??16,a=Math.round(i*.875),o=n.measurer??fq(n.fontFamily),s=n.padding??8,c=M1(t,`height`,400,1,1e4),l=Math.min(M1(t,`nodeWidth`,10,1,200),r),u=t.showValues!==!1,d=VDt(t,`prefix`),f=VDt(t,`suffix`),p=t.labelStyle===`outlined`,m=t.nodeAlignment===`left`||t.nodeAlignment===`right`||t.nodeAlignment===`center`?t.nodeAlignment:`justify`,h=typeof t.linkColor==`string`?t.linkColor:`gradient`,{nodes:g,links:_}=LDt(e,{width:r,height:c,nodeWidth:l,nodePadding:M1(t,`nodePadding`,12,0,200)+(u?zDt:0),labelHeight:a*1.15,alignment:m}),v=/* @__PURE__ */ new Map;if(BDt(t.nodeColors))for(let[e,n]of Object.entries(t.nodeColors)){let t=UDt(n);t&&v.set(e,t)}let y=t=>v.get(e.nodes[t].id)??``,b=0,x=0;g.forEach(e=>{e.value>x&&(x=e.value,b=e.layer)});let S=0,C=r,w=0,T=c,E=``,D=``;g.forEach((t,n)=>{let i=e.nodes[n].id,s=Math.max(t.height,1);D+=`<rect class="pele-sankey-node" data-id="${mq(i)}" x="${K(t.x)}" y="${K(t.y)}" width="${K(l)}" height="${K(s)}" rx="${K(Math.min(2,s/2))}" fill="${hJ(n)}"${y(n)}/>`;let c=u?`${d}${HDt(t.value)}${f}`:``,m=p?t.layer>=b:t.x<r/2,h=o.width(c?`${i} ${c}`:i,a,0),g=m?t.x+l+RDt:t.x-RDt,_=t.y+t.height/2;S=Math.min(S,m?g:g-h),C=Math.max(C,m?g+h:g),w=Math.min(w,_-a*.75),T=Math.max(T,_+a*.75);let v=` x="${K(g)}" y="${K(_+a*.35)}" text-anchor="${m?`start`:`end`}"`,x=pq(i)+(c?` <tspan class="pele-sankey-value" fill="var(--_m)">${pq(c)}</tspan>`:``);E+=`<g class="pele-label" data-id="${mq(i)}">`+(p?`<text${v} fill="none" stroke="var(--_bg)" stroke-width="3" stroke-linejoin="round">${pq(i)}${c?` `+pq(c):``}</text>`:``)+`<text${v}>${x}</text></g>`});let O=h===`gradient`||h===`source`||h===`target`?``:UDt(h),k=``;for(let t of _){let n=h===`target`?t.target:t.source,r=Math.max(t.thickness,1)/2,i=g[t.source].x+l,a=g[t.target].x,o=K((i+a)/2),s=mq(e.nodes[t.source].id),c=mq(e.nodes[t.target].id);k+=`<path class="pele-sankey-link" data-id="${s}->${c}" d="M${K(i)},${K(t.sourceY-r)}C${o},${K(t.sourceY-r)} ${o},${K(t.targetY-r)} ${K(a)},${K(t.targetY-r)}L${K(a)},${K(t.targetY+r)}C${o},${K(t.targetY+r)} ${o},${K(t.sourceY+r)} ${K(i)},${K(t.sourceY+r)}Z" fill="${hJ(n)}"${O||y(n)}><title>${s} → ${c}: ${mq(d)}${HDt(t.value)}${mq(f)}</title></path>`}let A=UJ(e.title,!1,o,i,GJ(n),1),j=A.height>0?A.height+12:0,M=Math.max(C-S,A.width),N=s-S+(M-(C-S))/2,P=s+j-w,F=Math.ceil(M+2*s),ee=Math.ceil(T-w+j+2*s);return{svg:_J(`sankey`,F,ee,i,n,e,gq(A,F/2,s+A.height/2,` class="pele-title" font-weight="var(--_tw)"`)+`<g transform="translate(${K(N)},${K(P)})"><g class="pele-sankey-links" fill-opacity="0.4">${k}</g><g class="pele-sankey-nodes">${D}</g><g class="pele-labels" font-size="${a}">${E}</g></g>`),width:F,height:ee,links:[]}}var KDt={type:`sankey`,parse(e,t,n){let r=new kDt;return n&&(r.title=n),FDt(PDt(e),r),r},render:WDt},qDt=`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`,JDt,YDt=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?(%|deg|grad|rad|turn)?$/i;function XDt(e){if(e.toLowerCase()===`none`)return 4;let t=YDt.exec(e);return t?t[1]===void 0?1:t[1]===`%`?2:3:0}function ZDt(e,t){let n=XDt(e);return n===1||n===2||t&&n===4}function QDt(e){let t=e.startsWith(`hsl`),n=e.indexOf(`(`),r=e.slice(0,n);if(r!==`rgb`&&r!==`rgba`&&r!==`hsl`&&r!==`hsla`||e.length>120||e.indexOf(`)`)!==e.length-1)return!1;let i=e.slice(n+1,-1).trim(),a,o,s=i.includes(`,`);if(s)a=i.split(`,`).map(e=>e.trim()),a.length===4&&(o=a.pop());else{let e=i.split(`/`);if(e.length>2)return!1;a=e[0].trim().split(/\s+/),e.length===2&&(o=e[1].trim())}if(a.length!==3||o!==void 0&&!ZDt(o,!s))return!1;let c=a.map(XDt);if(s)return t?(c[0]===1||c[0]===3)&&c[1]===2&&c[2]===2:(c[0]===1||c[0]===2)&&c[1]===c[0]&&c[2]===c[0];for(let e=0;e<3;e++){let n=c[e];if(!(n===1||n===4||(t&&e===0?n===3:n===2)))return!1}return!0}function $Dt(e){return e.includes(`(`)?QDt(e):(JDt??=new Set(qDt.split(` `)),JDt.has(e.toLowerCase()))}var eOt=/^:?wrap:/,tOt=/^:?nowrap:/,nOt=/^:?(?:no)?wrap:/,rOt=/^(?:rgba?|hsla?)\s*\(/,iOt=/[\r\u2028\u2029]/,aOt=/^\w*/;function N1(e){throw new NK(e,`semantic`,{type:`sequence`})}function oOt(e){let t=e.trim(),n=eOt.test(t)?!0:!tOt.test(t)&&void 0;return{text:(n===void 0?t:t.replace(nOt,``)).trim(),wrap:n}}function sOt(e){let t=rOt.exec(e);if(t){let n=e.lastIndexOf(`)`);if(n>=t[0].length)return iOt.test(e.slice(t[0].length))?void 0:[e.slice(0,n+1),e.slice(n+1)]}if(iOt.test(e))return;let n=aOt.exec(e)[0];return[n,e.slice(n.length)]}function cOt(e){return typeof e==`string`?[...e].map((e,t)=>[String(t),e]):typeof e==`object`&&e?Object.entries(e):[]}var lOt=class{type=`sequence`;actors=/* @__PURE__ */ new Map;createdActors=/* @__PURE__ */ new Map;destroyedActors=/* @__PURE__ */ new Map;boxes=[];messages=[];notes=[];title;accTitle;accDescr;prevActor;currentBox;lastCreated;lastDestroyed;wrapEnabled;sequenceWrap;active=/* @__PURE__ */ new Map;constructor(e={}){this.wrapEnabled=e.wrap,this.sequenceWrap=e.sequenceWrap??!1}autoWrap(){return this.wrapEnabled??this.sequenceWrap}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,``)}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
1044
1044
|
`)}setDiagramTitle(e){this.title=e}parseMessage(e){return oOt(e)}parseBoxData(e){let t=sOt(e),n=t?.[0]?t[0].trim():`transparent`,r=t?.[1]?t[1].trim():void 0;if($Dt(n)||(n=`transparent`,r=e.trim()),r===void 0)return{text:void 0,color:n,wrap:void 0};let{text:i,wrap:a}=oOt(r);return{text:i||void 0,color:n,wrap:a}}addBox(e){this.currentBox={name:e.text,wrap:e.wrap??this.autoWrap(),fill:e.color,actorKeys:[]},this.boxes.push(this.currentBox)}addActor(e,t,n,r,i){let a=this.currentBox,o;if(i!==void 0){let t;try{t=$K(i.includes(`
|
|
1045
1045
|
`)?i+`
|
|
1046
1046
|
`:`{
|
|
@@ -1051,30 +1051,30 @@ ${r}`,`syntax`,{type:e,...a})}var Cft=`amp:38,lt:60,gt:62,quot:34,apos:39,nbsp:1
|
|
|
1051
1051
|
,;@`.includes(t)||(r|=8|(n?0:4)),`#
|
|
1052
1052
|
;`.includes(t)||(r|=16),!`/\\+()<>:
|
|
1053
1053
|
,;-`.includes(t)&&!n&&(r|=32),dOt[e]=r}function fOt(e){let t=e.length,n=[],r=[],i=[],a=[],o=0,s=0,c=-1,l=(t,a,o)=>{n.push(t),r.push(e.slice(a,o)),i.push(a),s=o},u=(e,t,a,o)=>{n.push(e),r.push(o),i.push(t),s=a},d=e=>{a.push(o),o=e},f=()=>{a.length>0&&(o=a.pop())},p=n=>(c<n&&(c=e.indexOf(`
|
|
1054
|
-
`,n),c===-1&&(c=t)),c),m=(t,n)=>{let r=e.charCodeAt(t);return r<128?(dOt[r]&n)!==0:n===4||n===32?!eq(r):!0},h=(t,n)=>{for(let r=0;r<n.length;r++){let i=n.charCodeAt(r),a=e.charCodeAt(t+r);if(i>=97&&i<=122?(a|32)!==i:a!==i)return!1}return!0},g=t=>h(s,t)&&!aq(e.charCodeAt(s+t.length)),_=n=>{for(;n<t&&eq(e.charCodeAt(n));)n++;return n},v=()=>{let n=s;for(;n<t;){let t=e.charCodeAt(n);if(t===10||!eq(t))break;n++}return n!==s&&(s=n,!0)},y=e=>{for(;e<t&&m(e,16);)e++;return e},b=(e,t,n)=>{l(e,s,s+t),d(n)},x=(e,t,n=-1)=>g(e)?(l(t,s,s+e.length),n>=0&&d(n),!0):!1,S=(n,r)=>{if(!h(s,n))return!1;let i=s+n.length,a=e.charCodeAt(i);if(a!==32&&a!==9)return!1;for(;a===32||a===9;)a=e.charCodeAt(++i);return i>=t||!m(i,32)?!1:(l(r,s,s+n.length),!0)},C=t=>{let n=e.charCodeAt(t),r=e.charCodeAt(t+1);if(n===45){if(r===120||r===88||r===41||r===92||r===47||r===45)return!0;let n=e.charCodeAt(t+2);return r===124&&(n===92||n===47)}return n===47||n===92?(r===124||r===n)&&e.charCodeAt(t+2)===45:n===40&&r===41},w=()=>{let n=s+1;for(;n<t&&m(n,1);)n++;for(;n<t&&!C(n);){let r=n;for(;e.charCodeAt(r)===45;)r++;if(r>=t||!m(r,2))break;for(r++;r<t&&m(r,2);)r++;n=r}u(48,s,n,e.slice(s,n).trim())},T=()=>{let t=s;for(;rq(e.charCodeAt(t));)t++;let n=t>s;if(e.charCodeAt(t)===46&&rq(e.charCodeAt(t+1))){let n=rq(e.charCodeAt(t+2))?t+3:t+2,r=e.charCodeAt(n);if(r===32||r===10)return l(10,s,n),!0}let r=e.charCodeAt(t);return n&&(r===32||r===10)?(l(10,s,t),!0):!1},E=()=>{let t=e.charCodeAt(s+1),n=e.charCodeAt(s+2);if(t===62)l(n===62?55:53,s,s+(n===62?3:2));else if(t===120||t===88)l(59,s,s+2);else if(t===41)l(61,s,s+2);else if(t===124&&n===92)l(63,s,s+3);else if(t===124&&n===47)l(64,s,s+3);else if(t===92&&n===92)l(65,s,s+3);else if(t===47&&n===47)l(66,s,s+3);else if(t===45){let t=e.charCodeAt(s+3);n===62?l(t===62?57:54,s,s+(t===62?4:3)):n===120||n===88?l(60,s,s+3):n===41?l(62,s,s+3):n===124&&t===92?l(67,s,s+4):n===124&&t===47?l(68,s,s+4):n===92&&t===92?l(69,s,s+4):n===47&&t===47?l(70,s,s+4):l(46,s,s+1)}else l(46,s,s+1)},D=t=>{let n=e.charCodeAt(s+1);if(n!==124&&n!==t||e.charCodeAt(s+2)!==45)return!1;let r=e.charCodeAt(s+3)===45,i=t===47,a;return a=n===124?r?i?75:76:i?71:72:r?i?77:78:i?73:74,l(a,s,s+(r?4:3)),!0},O=()=>{if(!h(s,`title`))return!1;let n=s+5,r=e.charCodeAt(n)===58;return r&&n++,!eq(e.charCodeAt(n))||n+1>=t||!m(n+1,16)?!1:(l(r?15:14,s,y(n+1)),!0)},k=()=>{let t=h(s,`accdescr`);if(!t&&!h(s,`acctitle`))return!1;let n=_(s+8),r=e.charCodeAt(n);return r===58?(l(t?18:16,s,_(n+1)),d(t?6:5),!0):t&&r===123?(s=_(n+1),d(7),!0):!1},A=e=>{switch(e|32){case 97:return x(`actor`,34,1)||x(`alt`,24,3)||x(`and`,30,3)||x(`activate`,12,1)||k()||x(`autonumber`,9);case 98:return x(`box`,6,3)||x(`break`,28,3);case 99:return x(`create`,5)||x(`critical`,27,3);case 100:return x(`destroy`,35,1)||S(`details`,41)||x(`deactivate`,13,1);case 101:return x(`else`,31,3)||x(`end`,8);case 108:return x(`loop`,21,3)||x(`left of`,43)||S(`links`,38)||S(`link`,39);case 110:return x(`note`,36);case 111:return x(`opt`,23,3)||x(`option`,29,3)||x(`over`,37)||x(`off`,11);case 112:return x(`participant`,32,1)||x(`par`,25,3)||x(`par_over`,26,3)||S(`properties`,40);case 114:return x(`rect`,22,3)||x(`right of`,44);case 115:return x(`sequencediagram`,4);case 116:return O();default:return!1}},j=()=>{let t=e.charCodeAt(s);if(t===10){let t=s+1;for(;e.charCodeAt(t)===10;)t++;l(3,s,t)}else if(eq(t))s=_(s+1);else if(t===35||t===37&&e.charCodeAt(s+1)!==123)s=p(s);else if(t!==125&&e.charCodeAt(s+1)===37&&e.charCodeAt(s+2)===37)s=p(s);else if((!rq(t)&&t!==46||!T())&&!(t<128&&(t|32)>=97&&(t|32)<=122&&A(t))){if(t===44)l(42,s,s+1);else if(t===59)l(3,s,s+1);else if(m(s,1))w();else if(t===45)E();else if(t===60&&e.startsWith(`<<->>`,s))l(56,s,s+5);else if(t===60&&e.startsWith(`<<-->>`,s))l(58,s,s+6);else{if((t===47||t===92)&&D(t))return;t===58?l(52,s,y(s+1)):t===43?l(45,s,s+1):t===40&&e.charCodeAt(s+1)===41?l(47,s,s+2):l(2,s,s+1)}}},M=()=>{if(v())return!0;let n=e.charCodeAt(s);if(n===35)return s=p(s),!0;if(n===64&&e.charCodeAt(s+1)===123)return b(49,2,4),!0;let r=s;for(;r<t&&m(r,4);)r++;if(r>s){let t=_(r);if(e.charCodeAt(t)===64&&e.charCodeAt(t+1)===123)return l(48,s,r),!0;if(t>r&&h(t,`as`)&&eq(e.charCodeAt(t+2)))return l(48,s,r),d(2),!0}let i=r;for(;i<t&&m(i,8);)i++;if(i>s){let n=e.charCodeAt(i),r=i;if(i<t&&n!==10&&n!==59)for(r--;r>s&&e.charCodeAt(r)!==35;)r--;if(r>s)return u(48,s,r,e.slice(s,r).trim()),f(),!0}if(e.charCodeAt(i)===60)return l(2,s,p(s)),f(),!0;if(n!==10){let t=p(s);return u(2,s,t,e.slice(s,t).trim()),f(),!0}return!1},N=()=>{switch(o){case 0:return j(),!0;case 1:return M();case 2:return v()?!0:e.charCodeAt(s)===35?(s=p(s),!0):(f(),f(),g(`as`)?b(33,2,3):l(3,s,s),!0);case 3:return v()?!0:e.charCodeAt(s)===35?(s=p(s),!0):(l(7,s,y(s)),f(),!0);case 4:if(e.charCodeAt(s)!==125){let n=e.indexOf(`}`,s);return n===-1&&(n=t),l(50,s,n),!0}{let t=_(s+1),n=t>s+1&&h(t,`as`)&&eq(e.charCodeAt(t+2));return l(51,s,s+1),f(),n?d(2):f(),!0}case 5:case 6:return l(o===5?17:19,s,p(s)),f(),!0;default:if(e.charCodeAt(s)===125)s++,f();else{let n=e.indexOf(`}`,s);n===-1&&(n=t),l(20,s,n)}return!0}};for(;s<t;)if(!N())return n.push(1),r.push(``),i.push(s),{types:n,texts:r,starts:i};return o===0||o===2?l(3,t,t):o===3?l(7,t,t):o===5?l(17,t,t):o===6?l(19,t,t):o===7&&l(20,t,t),n.push(0),r.push(``),i.push(t),{types:n,texts:r,starts:i}}var P1=(/* @__PURE__ */ new Int8Array(79)).fill(-1);P1[53]=5,P1[54]=6,P1[55]=0,P1[57]=1,P1[56]=33,P1[58]=34,P1[59]=3,P1[60]=4,P1[61]=24,P1[62]=25,P1[63]=41,P1[64]=42,P1[65]=43,P1[66]=44,P1[67]=51,P1[68]=52,P1[69]=53,P1[70]=54,P1[71]=45,P1[72]=46,P1[73]=47,P1[74]=48,P1[75]=55,P1[76]=56,P1[77]=57,P1[78]=58;var F1=(/* @__PURE__ */ new Int8Array(79)).fill(-1);F1[21]=2,F1[22]=3,F1[23]=4,F1[28]=5,F1[24]=6,F1[25]=7,F1[26]=7,F1[27]=8,F1[6]=1;var pOt=`'SOLID_OPEN_ARROW', 'DOTTED_OPEN_ARROW', 'SOLID_ARROW', 'DOTTED_ARROW', 'SOLID_CROSS', 'DOTTED_CROSS', 'SOLID_POINT', 'DOTTED_POINT'`;function mOt(e,t){let{types:n,texts:r,starts:i}=fOt(e),a=0,o=t=>{let r=n[a];throw r===1?FK(`sequence`,e,i[a],``,!0):FK(`sequence`,e,i[a],`Expecting ${t}, got '${uOt[r]}'`)},s=e=>(n[a]!==e&&o(`'${uOt[e]}'`),r[a++]),c=()=>{let e=n[a];return e!==48&&e!==39&&o(`'ACTOR'`),{type:`addParticipant`,actor:r[a++]}},l=()=>t.parseMessage(s(52).trim().substring(1)),u=()=>{let e=n[a++];if(e===35){let e=c();return s(3),e.type=`destroyParticipant`,e}let r=c();if(n[a]===49&&n[a-1]===48){a++;let e=s(50);s(51),r.config=e.trim()}if(r.draw=e===32?`participant`:`actor`,n[a]===33){a++;let e=s(7);s(3),r.description=t.parseMessage(e)}else n[a]===3?a++:o(`'AS', 'NEWLINE'`);return r},d=e=>{let t=!1;n[a]===47&&(t=!0,a++);let r=P1[n[a]];r<0&&o(pOt),a++;let i=n[a];i!==47&&(t||i!==45&&i!==46)||a++;let s=c(),u=l(),d={type:`addMessage`,from:e.actor,to:s.actor,signalType:r,msg:u},f=[e,s,d];if(t){let t=i===47;d.activate=t,d.centralConnection=t?61:60,t&&f.push({type:`centralConnection`,signalType:59,actor:s.actor}),f.push({type:`centralConnectionReverse`,signalType:60,actor:e.actor})}else i===45?(d.activate=!0,f.push({type:`activeStart`,signalType:17,actor:s.actor})):i===46?f.push({type:`activeEnd`,signalType:18,actor:e.actor}):i===47&&(d.activate=!0,d.centralConnection=59,f.push({type:`centralConnection`,signalType:59,actor:s.actor}));return f},f=e=>{a++;let t=c();return[t,{type:e,actor:t.actor,text:l()}]},p=()=>{a++;let e=n[a];if(e===37){a++;let e=c(),t=e,r=[e.actor,e.actor];if(n[a]===42){a++;let n=c();t=[e,n],r=[e.actor,n.actor]}return[t,{type:`addNote`,placement:2,actor:r,text:l()}]}e!==43&&e!==44&&o(`'over', 'left_of', 'right_of'`),a++;let t=c();return[t,{type:`addNote`,placement:e===43?0:1,actor:t.actor,text:l()}]},m=()=>{a++;let e={type:`sequenceIndex`,sequenceVisible:!0,signalType:26};return n[a]===10?(e.sequenceIndex=Number(r[a++]),e.sequenceIndexStep=n[a]===10?Number(r[a++]):1):n[a]===11&&(a++,e.sequenceVisible=!1),n[a]!==3&&o(`'NEWLINE', 'NUM', 'off'`),a++,e},h=(e,n,r,i)=>{let a=e.list,o=e.sections;if(o)for(let e=o.length-2;e>=0;e-=2){let s={type:n,signalType:i};s[r]=t.parseMessage(o[e+1]),a=o[e].concat([s,a])}return a},g=e=>{let n=e.text,r=e.list;switch(e.kind){case 1:r[0]={type:`boxStart`,boxData:t.parseBoxData(n)},r.push({type:`boxEnd`,boxText:n});break;case 2:r[0]={type:`loopStart`,loopText:t.parseMessage(n),signalType:10},r.push({type:`loopEnd`,loopText:n,signalType:11});break;case 3:r[0]={type:`rectStart`,color:t.parseMessage(n),signalType:22},r.push({type:`rectEnd`,color:t.parseMessage(n),signalType:23});break;case 4:r[0]={type:`optStart`,optText:t.parseMessage(n),signalType:15},r.push({type:`optEnd`,optText:t.parseMessage(n),signalType:16});break;case 5:r[0]={type:`breakStart`,breakText:t.parseMessage(n),signalType:30},r.push({type:`breakEnd`,optText:t.parseMessage(n),signalType:31});break;case 6:r=h(e,`else`,`altText`,13),r[0]={type:`altStart`,altText:t.parseMessage(n),signalType:12},r.push({type:`altEnd`,signalType:14});break;case 7:r=h(e,`and`,`parText`,20),r[0]={type:`parStart`,parText:t.parseMessage(n),signalType:e.startType},r.push({type:`parEnd`,signalType:21});break;default:r=h(e,`option`,`optionText`,28),r[0]={type:`criticalStart`,criticalText:t.parseMessage(n),signalType:27},r.push({type:`criticalEnd`,signalType:29})}return r};for(;n[a]===3;)a++;s(4);let _=[],v={kind:0,text:``,startType:0,list:[],sections:void 0};for(;;){let e=n[a],i=v.list;if(v.kind===1){if(e===32||e===34||e===35)i.push(u());else if(e===3)i.push([]),a++;else if(e===8){a++;let e=g(v);v=_.pop(),v.list.push(e)}else o(`'end', 'NEWLINE', 'participant', 'participant_actor', 'destroy'`)}else switch(e){case 3:case 2:i.push([]),a++;break;case 32:case 34:case 35:i.push(u());break;case 5:{a++;let e=n[a];e!==32&&e!==34&&e!==35&&o(`'participant', 'participant_actor', 'destroy'`);let t=u();t.type=`createParticipant`,i.push(t);break}case 48:i.push(d(c())),s(3);break;case 39:{let e=n[a+1];i.push(e===48||e===39?f(`addALink`):d(c())),s(3);break}case 38:i.push(f(`addLinks`)),s(3);break;case 40:i.push(f(`addProperties`)),s(3);break;case 41:i.push(f(`addDetails`)),s(3);break;case 36:i.push(p()),s(3);break;case 9:i.push(m());break;case 12:case 13:{a++;let t=c();s(3),i.push(e===12?{type:`activeStart`,signalType:17,actor:t.actor}:{type:`activeEnd`,signalType:18,actor:t.actor});break}case 14:case 15:{let n=r[a++].substring(e===14?6:7);t.setDiagramTitle(n),i.push(n);break}case 16:{a++;let e=s(17).trim();t.setAccTitle(e),i.push(e);break}case 18:{a++;let e=s(19).trim();t.setAccDescription(e),i.push(e);break}case 20:{let e=r[a++].trim();t.setAccDescription(e),i.push(e);break}case 21:case 22:case 23:case 28:case 24:case 25:case 26:case 27:case 6:{a++;let t=s(7);_.push(v),v={kind:F1[e],text:t,startType:e===26?32:19,list:[[]],sections:void 0};break}case 31:case 30:case 29:{v.kind!==(e===31?6:e===30?7:8)&&o(`'end'`),a++;let t=s(7);(v.sections??=[]).push(i,t),v.list=[];break}case 8:{v.kind===0&&o(`'NEWLINE', 'EOF'`),a++;let e=g(v);v=_.pop(),v.list.push(e);break}case 0:v.kind!==0&&o(`'end'`),t.apply(i);return;default:o(`'NEWLINE', 'ACTOR', 'participant', 'note', 'end'`)}}}var hOt=16,gOt=10,_Ot=34,vOt=4,I1=5,L1=6,R1=` fill="var(--_s)" stroke="var(--_b)"`,z1=` fill="none" stroke="var(--_b)"`,yOt=/* @__PURE__ */ new Set([`participant`,`actor`,`boundary`,`control`,`entity`,`database`,`collections`,`queue`]),bOt=/* @__PURE__ */ new Set([`actor`,`boundary`,`control`,`entity`,`database`]);function xOt(e){return yOt.has(e)?e:`participant`}function B1(e){return bOt.has(e)}function SOt(e,t,n,r,i=hOt){if(B1(e))return{w:Math.max(40,t.width+8),h:_Ot+(t.height>0?vOt+t.height:0)};let a=e===`collections`?I1:e===`queue`?2*L1:0;return{w:Math.max(n,t.width+2*i)+a,h:Math.max(r,t.height+2*gOt)+(e===`collections`?I1:0)}}function COt(e,t,n){let r=K(t),i=e=>K(n+e);switch(e){case`actor`:return`<circle cx="${r}" cy="${i(7)}" r="6"${R1}/><path d="M${r},${i(13)}V${i(24)}M${K(t-10)},${i(17)}H${K(t+10)}M${K(t-8)},${i(34)}L${r},${i(24)}L${K(t+8)},${i(34)}"${z1}/>`;case`boundary`:return`<path d="M${K(t-19)},${i(6)}V${i(28)}M${K(t-19)},${i(17)}H${K(t-8)}"${z1}/><circle cx="${K(t+3)}" cy="${i(17)}" r="11"${R1}/>`;case`control`:return`<circle cx="${r}" cy="${i(21)}" r="11"${R1}/><path d="M${K(t+5)},${i(5)}L${K(t-1)},${i(10)}L${K(t+5)},${i(15)}"${z1}/>`;case`entity`:return`<circle cx="${r}" cy="${i(15)}" r="11"${R1}/><path d="M${K(t-11)},${i(30)}H${K(t+11)}"${z1}/>`;default:{let e=K(t-14),n=K(t+14);return`<path d="M${e},${i(7)}V${i(27)}A14,5 0 0 0 ${n},${i(27)}V${i(7)}A14,5 0 0 0 ${e},${i(7)}Z"${R1}/><path d="M${e},${i(7)}A14,5 0 0 0 ${n},${i(7)}"${z1}/>`}}}function wOt(e,t,n,r,i,a){let{w:o,h:s}=r,c=` class="pele-label"`;if(B1(e))return COt(e,t,n)+gq(i,t,n+_Ot+vOt+i.height/2,c,a);let l=t-o/2;if(e===`collections`){let e=o-I1,t=s-I1;return`<rect x="${K(l+I1)}" y="${K(n)}" width="${K(e)}" height="${K(t)}" rx="${fJ}"${R1}/><rect x="${K(l)}" y="${K(n+I1)}" width="${K(e)}" height="${K(t)}" rx="${fJ}"${R1}/>`+gq(i,l+e/2,n+I1+t/2,c,a)}if(e===`queue`){let e=K(l+L1),r=K(l+o-L1),u=K(n+s),d=K(s/2);return`<path d="M${e},${K(n)}H${r}A${L1},${d} 0 0 1 ${r},${u}H${e}A${L1},${d} 0 0 1 ${e},${K(n)}Z"${R1}/><path d="M${r},${K(n)}A${L1},${d} 0 0 0 ${r},${u}"${z1}/>`+gq(i,t-L1/2,n+s/2,c,a)}return`<rect x="${K(l)}" y="${K(n)}" width="${K(o)}" height="${K(s)}" rx="${fJ}"${R1}/>`+gq(i,t,n+s/2,c,a)}var V1=[];function H1(e,t,n,r=1,i=!1){V1[e]={dotted:t,head:n,atStart:r!==1,atEnd:r!==0,bottom:i}}H1(0,!1,1),H1(1,!0,1),H1(3,!1,2),H1(4,!0,2),H1(5,!1,0),H1(6,!0,0),H1(24,!1,3),H1(25,!0,3),H1(33,!1,1,2),H1(34,!0,1,2);for(let e of[!1,!0]){let t=e?10:0;H1(41+t,e,4),H1(42+t,e,4,1,!0),H1(43+t,e,5),H1(44+t,e,5,1,!0),H1(45+t,e,4,0),H1(46+t,e,4,0,!0),H1(47+t,e,5,0),H1(48+t,e,5,0,!0)}var TOt=/* @__PURE__ */ new Map([[10,`loop`],[12,`alt`],[15,`opt`],[19,`par`],[32,`par`],[27,`critical`],[30,`break`],[22,`rect`]]),EOt=12,U1=28,DOt=22,W1=10,OOt=4,kOt=14,G1=10,AOt=16,jOt=20,MOt=10,K1=20,NOt=240,q1=16,J1=4,POt=` stroke-dasharray="4 4"`;function Y1(e){return e!==void 0&&V1[e]!==void 0}function FOt(e,t){let n=Array(e.length),r=Array(e.length),i=1,a=1,o=!1;for(let s=0;s<e.length;s++){let c=e[s];if(n[s]=NaN,r[s]=!1,c.type===26){let e=c.message;i=e.start||i,a=e.step||a,o=e.visible}else Y1(c.type)&&(n[s]=i,r[s]=o||t,i=Math.round((i+a)*100)/100)}return{index:n,shown:r,visible:o}}var IOt={lines:[],widths:[],width:0,height:0,size:0,lineHeight:0};function X1(e,t,n){let r=e[t];return typeof r==`number`&&r>=0&&r<=2e3?r:n}function LOt(e,t,n,r,i){let a=K(e-n*rJ);return i?`<path class="pele-marker" d="M${K(e)},${K(t)}L${a},${K(t+r*5)}"/>`:`<path class="pele-marker" d="M${K(e)},${K(t)}L${a},${K(t+r*4.5)}V${K(t)}Z" fill="var(--_l)" stroke="none"/>`}function Z1(e,t,n,r,i){switch(e){case 1:return cJ(`arrow_point`,t,n,r,0,`var(--_l)`);case 2:return cJ(`arrow_cross`,t,n,r,0,`var(--_l)`);case 3:return`<path class="pele-marker" d="M${K(t-r*rJ)},${K(n-4.5)}L${K(t)},${K(n)}L${K(t-r*rJ)},${K(n+4.5)}" stroke-linejoin="round"/>`;case 4:return LOt(t,n,r,i,!1);case 5:return LOt(t,n,r,i,!0);default:return``}}function ROt(e){return e===1?rJ-1:e===2?4:0}function zOt(e,t,n){return XJ(n,r=>BOt(e,t,n,r))}function BOt(e,t,n,r){let i=t.sequence??{},a=n.fontSize??16,o=Math.round(a*.875),s=Math.round(a*.75),c=n.measurer??fq(n.fontFamily),l=n.icons,u=n.padding??8,d=i.mirrorActors!==!1,f=i.rightAngles===!0,p=Math.min(X1(i,`actorMargin`,40),r?8:1/0),m=Math.min(X1(i,`width`,64),r?48:1/0),h=X1(i,`height`,Math.round(a*1.5)+20),g=Math.min(X1(i,`width`,160),r?Math.max(32,((n.maxWidth??320)-2*u)/Math.max(1,e.actors.size)-p-24):1/0),_=Math.max(4,14+X1(i,`messageMargin`,35)-35),v=Math.min(X1(i,`noteMargin`,10),r?6:1/0),y=Math.min(X1(i,`boxMargin`,10),r?6:1/0),b=i.messageAlign===`left`?-1:+(i.messageAlign===`right`),x=r?6:EOt,S=r?8:AOt,C=r?12:jOt,w=r?6:MOt,T=e.messages,E=T.length,D=FOt(T,i.showSequenceNumbers===!0),O=(e,t,n,i=g,a=0)=>{let o=WJ(e,!1,c,t,r||n?i:1/0,a);return r?QY(o,c,Math.max(120,i)):o},k;if(i.hideUnusedParticipants===!0){k=/* @__PURE__ */ new Set;for(let e of T)k.add(e.from).add(e.to)}let A=new Int32Array(E+1);A[E]=-1;for(let e=E-1;e>=0;e--)A[e]=Y1(T[e].type)?e:A[e+1];let j=[],M=/* @__PURE__ */ new Map;for(let[t,n]of e.actors){if(k&&!k.has(t))continue;let i=xOt(n.type),o=O(n.description,a,n.wrap),s=e.createdActors.get(t),c=e.destroyedActors.get(t),l=s===void 0?-1:A[Math.min(s,E)];l>=0&&T[l].to!==t&&(l=-1);let u=c===void 0?-1:A[Math.min(c,E)];u>=0&&T[u].to!==t&&T[u].from!==t&&(u=-1),M.set(t,j.length),j.push({id:t,actor:n,kind:i,label:o,size:SOt(i,o,m,h,r?8:void 0),x:0,createAt:l,destroyAt:u,top:0,lifeStart:0,lifeEnd:-1,activations:[]})}let N=j.length-1,P=/* @__PURE__ */ new Map,F=(e,t,n)=>{if(e<0||t>N)return;let r=e*j.length+t;(P.get(r)??0)<n&&P.set(r,n)},ee=e=>D.shown[e]?Math.max(q1,c.width(String(D.index[e]),s,0)+8):0,te=Array(E);for(let e=0;e<E;e++){let t=T[e],n=t.from===void 0?void 0:M.get(t.from),i=t.to===void 0?void 0:M.get(t.to);if(n!==void 0&&i!==void 0&&typeof t.message==`string`){if(t.type===2){let r=O(t.message,o,t.wrap),a=r.width+2*v;t.placement===0?F(n-1,n,a+2*G1+W1):t.placement===1?F(n,n+1,a+2*G1+W1):n===i?(F(n-1,n,a/2+G1),F(n,n+1,a/2+G1)):F(Math.min(n,i),Math.max(n,i),a-2*S),te[e]={kind:2,a:n,b:i,label:r,x:0,w:a}}else if(Y1(t.type)){let a=O(t.message,o,t.wrap),s=ee(e);if(n===i)F(n,n+1,U1+8+a.width+16+W1+s),te[e]={kind:1,a:n,b:i,label:a,x:0,w:0};else{let o=j[i].createAt===e?j[i].size.w/2:0,c=t.centralConnection?4*J1:0;F(Math.min(n,i),Math.max(n,i),(r?Math.min(a.width,Math.max(16,g-16)):a.width)+2*x+W1+s+o+c),te[e]={kind:0,a:n,b:i,label:a,x:0,w:0}}}}}let I=[];for(let e=0;e<=N;e++){let t=j[e].actor.box,n=I[I.length-1];t&&n&&n.box===t&&n.last===e-1?n.last=e:t&&I.push({box:t,first:e,last:e,title:O(t.name,o,t.wrap),grow:0})}let ne=Array(Math.max(N,0));for(let e=0;e<N;e++){let t=j[e],n=j[e+1],r=t.actor.box===n.actor.box?0:(t.actor.box?y:0)+(n.actor.box?y:0);ne[e]=Math.max(t.size.w/2+n.size.w/2+p+r,P.get(e*j.length+e+1)??0)}let re=[];for(let[e,t]of P){let n=Math.floor(e/j.length),r=e%j.length;r-n>1&&re.push([n,r,t])}re.sort((e,t)=>e[1]-e[0]-(t[1]-t[0])||e[0]-t[0]);for(let[e,t,n]of re){let r=0;for(let n=e;n<t;n++)r+=ne[n];if(r>=n)continue;let i=(n-r)/(t-e);for(let n=e;n<t;n++)ne[n]+=i}let ie=()=>{for(let e=1;e<=N;e++)j[e].x=j[e-1].x+ne[e-1]};ie();for(let e of I){let t=j[e.last].x+j[e.last].size.w/2-(j[e.first].x-j[e.first].size.w/2);e.grow=Math.max(0,(e.title.width-t)/2),e.grow!==0&&(e.first>0&&(ne[e.first-1]+=e.grow),e.last<N&&(ne[e.last]+=e.grow))}ie();let ae=1/0,L=-1/0,oe=(e,t)=>{e<ae&&(ae=e),t>L&&(L=t)};for(let e of j)oe(e.x-e.size.w/2,e.x+e.size.w/2);for(let e of I)oe(j[e.first].x-j[e.first].size.w/2-y-e.grow,j[e.last].x+j[e.last].size.w/2+y+e.grow);let se=Array(E),ce=[],le=()=>N<0?[0,120]:[j[0].x-C,j[N].x+C];for(let e=0;e<E;e++){let t=T[e],n=t.type,i=n===void 0?void 0:TOt.get(n),a=te[e];if(i!==void 0){let n={kind:i,x0:1/0,x1:-1/0,top:0,title:IOt,tabW:0,fill:i===`rect`&&typeof t.message==`string`?t.message:``,dividers:[e],dividerY:[],dividerLabels:[]};se[e]=n,ce.push(n)}else if(n===13||n===20||n===28)ce[ce.length-1]?.dividers.push(e);else if(n===11||n===14||n===16||n===21||n===29||n===31||n===23){let t=ce.pop();if(!t)continue;if(se[e]=t,t.x0>t.x1&&([t.x0,t.x1]=le()),t.kind!==`rect`){t.tabW=c.width(t.kind,s,1)+14;for(let e=0;e<t.dividers.length;e++){let n=T[t.dividers[e]].message,i=e===0?t.tabW+8:0,a=t.x1-t.x0-16-i,s=n?O(`[${n}]`,o,!0,Math.max(a,r?Math.min(NOt,g):NOt)):IOt;s.width>a&&(t.x1+=s.width-a),e===0?t.title=s:t.dividerLabels.push(s)}}oe(t.x0,t.x1);let n=ce[ce.length-1];n&&(n.x0=Math.min(n.x0,t.x0-w),n.x1=Math.max(n.x1,t.x1+w))}else if(a){let n=j[a.a],i=j[a.b],s,c;if(a.kind===2){if(t.placement===0)a.x=n.x-G1-a.w;else if(t.placement===1)a.x=n.x+G1;else if(a.a===a.b)a.x=n.x-a.w/2;else{let e=Math.min(n.x,i.x)-S,s=Math.max(n.x,i.x)+S;(r||t.wrap)&&(a.label=O(t.message,o,!0,Math.max(g,s-e-2*v))),a.w=Math.max(s-e,a.label.width+2*v),a.x=(e+s-a.w)/2}s=a.x,c=a.x+a.w}else a.kind===1?(s=n.x,c=n.x+W1+U1+8+a.label.width+ee(e)):(s=Math.min(n.x,i.x),c=Math.max(n.x,i.x),(r||t.wrap)&&(a.label=O(t.message,o,!0,Math.max(g,c-s-2*x-W1))),i.createAt===e&&(i.x>n.x?c+=i.size.w/2:s-=i.size.w/2));oe(s,c);let l=ce[ce.length-1];l&&(l.x0=Math.min(l.x0,s-C),l.x1=Math.max(l.x1,c+C))}}let ue=0;for(let e of I)ue=Math.max(ue,e.title.height);let de=I.length>0?y+(ue>0?ue+4:0):0,fe=0;for(let e of j)e.createAt<0&&(fe=Math.max(fe,e.size.h));let pe=de+fe;for(let e of j)e.top=pe-e.size.h,e.lifeStart=pe;let me=j.map(e=>e.x),he=(e,t)=>{let n=0,r=me.length;for(;n<r;){let t=n+r>>1;me[t]<=e?n=t+1:r=t}return n<me.length&&me[n]<t},ge=(e,t,n,r)=>{if(e.width===0)return``;let i=t-e.width/2;return(he(i,i+e.width)?`<rect x="${K(i-3)}" y="${K(n-e.height/2+2)}" width="${K(e.width+6)}" height="${K(e.height-4)}" rx="3" fill="var(--_bg)" stroke="none"/>`:``)+gq(e,t,n,r,l)},_e=(e,t=0)=>e.activations.length+t>0?e.x-W1/2:e.x,ve=(e,t=0)=>{let n=e.activations.length+t;return n>0?e.x+W1/2+(n-1)*OOt:e.x},ye=[],be=[],xe=``,Se=``,Ce=``,we=``,Te=``,Ee=``,De=(e,t)=>{let n=e.activations.pop(),r=Math.max(t,n+kOt),i=e.x-W1/2+e.activations.length*OOt;return oe(i,i+W1),be.push(`<rect class="pele-activation" data-id="${mq(e.id)}" x="${K(i)}" y="${K(n)}" width="${W1}" height="${K(r-n)}" rx="2"/>`),r},Oe=(e,t)=>{let n=e.x,r=t+16;return e.lifeEnd=r,Ee+=`<path class="pele-destroy" data-id="${mq(e.id)}" d="M${K(n-6)},${K(r-6)}L${K(n+6)},${K(r+6)}M${K(n+6)},${K(r-6)}L${K(n-6)},${K(r+6)}"/>`,r+6},ke=(e,t,n)=>{let r=e.actor.properties.get(`class`);return`<g class="pele-node pele-actor pele-actor-${e.kind}${n?` pele-actor-footer`:``}${typeof r==`string`?hJ(r):``}" data-id="${mq(e.id)}">`+wOt(e.kind,e.x,t,e.size,e.label,l)+`</g>`},Ae=(e,t,n,r)=>`<g class="pele-sequence-number"><rect x="${K(t-r/2)}" y="${K(n-q1/2)}" width="${K(r)}" height="${q1}" rx="${q1/2}" fill="var(--_l)" stroke="none"/><text x="${K(t)}" y="${K(n+s*.35)}" text-anchor="middle" font-size="${s}" fill="var(--_bg)" stroke="none">${pq(String(D.index[e]))}</text></g>`,je=pe+6,Me=[];for(let e=0;e<E;e++){let t=T[e],n=t.type,r=te[e],i=se[e];if(n===17){let e=t.from===void 0?void 0:M.get(t.from);e!==void 0&&j[e].activations.push(je)}else if(n===18){let e=t.from===void 0?void 0:M.get(t.from);e!==void 0&&j[e].activations.length>0&&(je=Math.max(je,De(j[e],je)))}else if(i&&i.dividers[0]===e)Me.push(i),i.kind===`rect`?(i.top=je+8,je=i.top):(i.top=je+12,je=i.top+Math.max(K1,i.title.height+2));else if(i){Me.pop();let e=je+12,t=K(i.x0),n=K(i.x1-i.x0);if(i.kind===`rect`){let r=i.fill?mJ([`fill:${i.fill}`]).shape:``;ye.push(`<rect class="pele-rect" x="${t}" y="${K(i.top)}" width="${n}" height="${K(e-i.top)}" rx="${fJ}"${r?``:` fill-opacity="0.5"`}${r}/>`)}else{let r=`<rect x="${t}" y="${K(i.top)}" width="${n}" height="${K(e-i.top)}" rx="${fJ}" fill="none"/>`;for(let e=0;e<i.dividerY.length;e++){let n=i.dividerY[e],a=i.dividerLabels[e];r+=`<path d="M${t},${K(n)}H${K(i.x1)}"${POt}/>`+ge(a,i.x0+8+a.width/2,n+2+a.height/2,` class="pele-frame-label" fill="var(--_m)" stroke="none"`)}r+=`<rect x="${t}" y="${K(i.top)}" width="${K(i.tabW)}" height="${K1}" rx="${fJ}" fill="var(--_s)"/><text class="pele-frame-kind" x="${K(i.x0+i.tabW/2)}" y="${K(i.top+K1/2+s*.35)}" text-anchor="middle" font-size="${s}" font-weight="var(--_hw)" fill="var(--_m)" stroke="none">${i.kind}</text>`+ge(i.title,i.x0+i.tabW+8+i.title.width/2,i.top+Math.max(K1,i.title.height)/2,` class="pele-frame-label" fill="var(--_m)" stroke="none"`),xe+=`<g class="pele-frame pele-frame-${i.kind}">${r}</g>`}je=e}else if(n===13||n===20||n===28){let e=Me[Me.length-1];if(e){let t=e.dividerLabels[e.dividerY.length];e.dividerY.push(je+12),je+=12+(t.height>0?t.height:0)}}else if(r&&r.kind===2){let e=j[r.a],n=r.label.height+2*Math.max(4,v-4),i=je+10,a=r.x;t.placement===1?a+=ve(e)-e.x:t.placement===0&&(a+=_e(e)-e.x),oe(a,a+r.w),we+=`<g class="pele-note" data-id="i${mq(t.id)}"><rect x="${K(a)}" y="${K(i)}" width="${K(r.w)}" height="${K(n)}" rx="${fJ}"/>`+gq(r.label,a+r.w/2,i+n/2,` class="pele-label" stroke="none" fill="var(--_fg)"`,l)+`</g>`,je=i+n}else if(r){let i=V1[n],a=j[r.a],o=j[r.b],s=r.label,c=ee(e),u=0;for(let n=e+1;n<E;n++){let e=T[n].type;if(e===17)T[n].from===t.to&&u++;else if(e!==18&&e!==59&&e!==60)break}let d=i.bottom?1:-1,p=i.dotted?POt:``,m=t.centralConnection,h=m===59||m===61,g=m===60||m===61,v=(e,t)=>`<circle class="pele-central" cx="${K(e)}" cy="${K(t)}" r="${J1}" fill="var(--_l)" stroke="none"/>`,y=i.atStart&&!i.atEnd,S=ROt(i.head),C=``,w;if(r.kind===1){let n=je+_+Math.max(0,(s.height-DOt)/2),r=n+DOt,o=g?a.x+J1:ve(a),m=h?a.x+J1:ve(a,u),b=Math.max(o,m)+U1+c/2;g&&(C+=v(a.x,n)),h&&(C+=v(a.x,r)),c>0&&(C+=Ae(e,y?m:o,y?r:n,c),y?m+=c/2:o+=c/2);let x=(i.atStart?Z1(i.head,o,n,-1,d):``)+(i.atEnd?Z1(i.head,m,r,-1,-d):``),T=K(o+(i.atStart?S:0)),E=K(m+(i.atEnd?S:0));C=`<path d="${f?`M${T},${K(n)}H${K(b)}V${K(r)}H${E}`:`M${T},${K(n)}H${K(b-6)}A6,6 0 0 1 ${K(b)},${K(n+6)}V${K(r-6)}A6,6 0 0 1 ${K(b-6)},${K(r)}H${E}`}"${p}/>`+x+C,oe(a.x,b+8+s.width),s.width>0&&(Ce+=`<g class="pele-edge-label" data-id="i${mq(t.id)}">${gq(s,b+8+s.width/2,(n+r)/2,``,l)}</g>`),w=r}else{let n=o.x>a.x?1:-1,r=o.createAt===e;w=je+_+Math.max(s.height>0?s.height+2:6,r?o.size.h/2-_+6:0);let l=n>0?ve(a):_e(a),f=n>0?_e(o,u):ve(o,u);if(r&&(o.top=w-o.size.h/2,o.lifeStart=o.top+o.size.h,f=o.x-n*(B1(o.kind)?18:o.size.w/2+1)),g&&(C+=v(a.x,w),l=a.x+n*J1),h&&(C+=v(o.x,w),f=o.x-n*J1),c>0){if(y){let t=h?f-n*(c/2+2):f;C+=Ae(e,t,w,c),f=t-n*c/2}else{let t=g?l+n*(c/2+2):l;C+=Ae(e,t,w,c),l=t+n*c/2}}let m=(i.atStart?Z1(i.head,l,w,-n,d*n):``)+(i.atEnd?Z1(i.head,f,w,n,d*n):``),T=l+(i.atStart?n*S:0),E=f-(i.atEnd?n*S:0);if(C=`<path d="M${K(T)},${K(w)}H${K(E)}"${p}/>`+m+C,s.width>0){let e=Math.min(l,f),n=Math.max(l,f),r=b<0?e+x+s.width/2:b>0?n-x-s.width/2:(e+n)/2;oe(r-s.width/2,r+s.width/2),Ce+=`<g class="pele-edge-label" data-id="i${mq(t.id)}">${ge(s,r,w-4-s.height/2,``)}</g>`}r&&(je=w+o.size.h/2-6)}Se+=`<g class="pele-edge pele-message" data-id="i${mq(t.id)}">${C}</g>`,je=Math.max(je,w),a.destroyAt===e&&(je=Math.max(je,Oe(a,w))),o.destroyAt===e&&o!==a&&(je=Math.max(je,Oe(o,w)))}}je+=20;for(let e of j)for(;e.activations.length>0;)De(e,je);let Ne=je;if(d){let e=0;for(let t of j)t.lifeEnd>=0||(e=Math.max(e,t.size.h),Te+=ke(t,je,!0));Ne=je+e}let Pe=``;for(let e of j){Te+=ke(e,e.top,!1);let t=e.lifeEnd>=0?e.lifeEnd:je;t>e.lifeStart&&(Pe+=`<path class="pele-lifeline" data-id="${mq(e.id)}" d="M${K(e.x)},${K(e.lifeStart)}V${K(t)}"/>`)}let Fe=``;for(let e of I){let t=j[e.first].x-j[e.first].size.w/2-y-e.grow,n=j[e.last].x+j[e.last].size.w/2+y+e.grow,r=e.box.fill===`transparent`?``:mJ([`fill:${e.box.fill}`]).shape;Fe+=`<g class="pele-cluster pele-box"${e.box.name?` data-id="${mq(e.box.name)}"`:``}><rect x="${K(t)}" y="0" width="${K(n-t)}" height="${K(Ne+y)}" rx="${fJ}" fill="var(--_a)" stroke="var(--_b)"${r?``:` fill-opacity="0.5"`}${r}/>`+gq(e.title,(t+n)/2,y/2+2+e.title.height/2,` class="pele-cluster-label" fill="var(--_m)"`,l)+`</g>`}I.length>0&&(Ne+=y);let Ie=0,Le=``,Re=O(e.title,a,!1,r?KJ(n):g,1);if(ae>L&&oe(0,Math.max(Re.width,40)),Re.width>0){let e=(ae+L)/2;oe(e-Re.width/2,e+Re.width/2),Ie=-Re.height-12,Le=gq(Re,e,Ie+Re.height/2,` class="pele-title" font-weight="var(--_tw)"`,l)}let ze=Math.ceil(L-ae+2*u),Be=Math.ceil(Ne-Ie+2*u);return{svg:vJ(`sequence`,ze,Be,a,n,e,`<g transform="translate(${K(u-ae)},${K(u-Ie)})">`+Le+(Fe?`<g class="pele-boxes" font-size="${o}">${Fe}</g>`:``)+(ye.length>0?`<g class="pele-rects" fill="var(--_a)">${ye.reverse().join(``)}</g>`:``)+(Pe?`<g class="pele-lifelines" fill="none" stroke="var(--_b)">${Pe}</g>`:``)+(be.length>0?`<g class="pele-activations" fill="var(--_s)" stroke="var(--_b)">${be.reverse().join(``)}</g>`:``)+(xe?`<g class="pele-frames" font-size="${o}" stroke="var(--_b)">${xe}</g>`:``)+(Se?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${Se}</g>`:``)+(Ee?`<g class="pele-destroys" fill="none" stroke="var(--_l)" stroke-width="1.5" stroke-linecap="round">${Ee}</g>`:``)+(Ce?`<g class="pele-edge-labels" font-size="${o}">${Ce}</g>`:``)+(we?`<g class="pele-notes" font-size="${o}" fill="var(--_a)" stroke="var(--_b)">${we}</g>`:``)+(Te?`<g class="pele-nodes">${Te}</g>`:``)+`</g>`),width:ze,height:Be,links:[]}}var VOt={type:`sequence`,parse(e,t,n){let r=t.sequence??{},i=new lOt({wrap:typeof t.wrap==`boolean`?t.wrap:void 0,sequenceWrap:r.wrap===!0});return n&&i.setDiagramTitle(n),mOt(e,i),i},render:zOt};function HOt(e){let t=`TB`;for(let n of e)typeof n!=`string`&&n.stmt===`dir`&&(t=n.value);return t}function UOt(e,t,n){let r=[],i=[],a=/* @__PURE__ */ new Map,o=/* @__PURE__ */ new Map,s=/* @__PURE__ */ new Map,c=0,l=0,u=e=>{if(!e.id||e.id===`</join></fork>`||e.id===`</choice>`)return;if(e.cssClasses){let t;for(let r of e.cssClasses.split(` `)){let i=n.get(r);if(i){t??=e.cssCompiledStyles.slice();for(let e of i.styles)t.push(e)}}t&&(e.cssCompiledStyles=t)}let t=a.get(e.id);if(t){let n=e.parentId??t.parentId;Object.assign(t,e),n!==void 0&&(t.parentId=n)}else a.set(e.id,e),r.push(e)},d=(e,n,r)=>{let a=n.id;if(a===`root`)return;let d=t.get(a),f=d?.classes?.join(` `)??``,p=d?.styles??[],m=o.get(a);if(!m){let e=`rect`;n.start===!0?e=`stateStart`:n.start===!1&&(e=`stateEnd`),n.type!=="default"&&(e=n.type),m={shape:e,description:a,cssClasses:`${f} statediagram-state`,cssStyles:p,type:void 0,dir:void 0,colorIndex:void 0},o.set(a,m)}if(n.description&&(Array.isArray(m.description)?(m.shape=`rectWithTitle`,m.description=m.description.concat(n.description)):m.description.length>0?(m.shape=`rectWithTitle`,m.description=m.description===a?[n.description].flat():[m.description,n.description].flat()):(m.shape=`rect`,m.description=Array.isArray(n.description)?n.description.slice():n.description)),m.description.length===1&&m.shape===`rectWithTitle`&&(m.shape=m.type===`group`?`roundedWithTitle`:`rect`),!m.type&&n.doc){if(m.type=`group`,m.dir=HOt(n.doc),m.shape=n.type===`divider`?`divider`:`roundedWithTitle`,m.shape===`divider`&&e?.id!==void 0&&s.has(e.id))m.colorIndex=s.get(e.id);else{let e=l++;m.colorIndex=f.trim()!==``||p.length>0?void 0:e}s.set(a,m.colorIndex),m.cssClasses=`${m.cssClasses} statediagram-cluster ${r?`statediagram-cluster-alt`:``}`}let h=m.description,g={id:a,shape:m.shape,label:Array.isArray(h)?h[0]:h,description:Array.isArray(h)?h.slice(1):[],cssClasses:m.cssClasses,cssCompiledStyles:[],cssStyles:m.cssStyles,type:m.type,isGroup:m.type===`group`,dir:m.dir,colorIndex:m.colorIndex};g.shape===`divider`&&(g.label=``),e&&e.id!==`root`&&(g.parentId=e.id);let _=n.note;if(!_){u(g);return}let v=(e,t,n,r)=>({id:e,shape:t,label:_.text,description:[],cssClasses:n,cssCompiledStyles:[],cssStyles:[],type:r?`group`:`node`,isGroup:r,dir:void 0,position:_.position}),y=v(`${a}----note-${c++}`,`note`,`statediagram-note`,!1);y.parentId=`${a}----parent`,y.noteFor=a,u(v(y.parentId,`noteGroup`,m.cssClasses,!0)),u(y),u(g);let b=_.position===`left of`,x=b?y.id:a,S=b?a:y.id;i.push({id:`${x}-${S}`,start:x,end:S,label:``,classes:`transition note-edge`,pattern:`dashed`})},f=[{item:void 0,doc:e,at:0,alt:!0}];for(;f.length>0;){let e=f[f.length-1];if(e.at>=e.doc.length){f.pop();continue}let t=e.doc[e.at++];typeof t!=`string`&&(t.stmt===`state`?(d(e.item,t,e.alt),t.doc&&f.push({item:t,doc:t.doc,at:0,alt:!e.alt})):t.stmt===`relation`&&(d(e.item,t.state1,e.alt),d(e.item,t.state2,e.alt),i.push({id:`edge${c++}`,start:t.state1.id,end:t.state2.id,label:t.description??``,classes:`transition`})))}for(let e of r)if(e.isGroup&&e.description.length>0)throw new NK(`Group nodes can only have label. Remove the additional description for node [${e.id}]`,`semantic`,{type:`state`});return{nodes:r,edges:i}}var WOt=class{type=`state`;rootDoc=[];states=/* @__PURE__ */ new Map;relations=[];classes=/* @__PURE__ */ new Map;links=/* @__PURE__ */ new Map;graph={nodes:[],edges:[]};title;accTitle;accDescr;dividerCount=0;get direction(){let e=`TB`;for(let t of this.rootDoc)typeof t!=`string`&&t.stmt===`dir`&&(e=t.value);return e}setRootDoc(e){this.rootDoc=e,this.translate(),this.extract(e)}extract(e){this.states=/* @__PURE__ */ new Map,this.relations=[],this.classes=/* @__PURE__ */ new Map;let t=Array.isArray(e)?e:e.doc;for(let e of t)if(typeof e!=`string`)switch(e.stmt){case`state`:this.addState(e.id.trim(),e.type,e.doc,e.description,e.note);break;case`relation`:this.addRelation(e.state1,e.state2,e.description);break;case`classDef`:this.addStyleClass(e.id.trim(),e.classes);break;case`style`:{let t=e.styleClass.split(`,`).map(e=>e.replace(/;/g,``).trim());for(let n of this.named(e.id.trim()))n.styles=t.slice();break}case`applyClass`:this.setCssClass(e.id.trim(),e.styleClass);break;case`click`:this.addLink(typeof e.id==`string`?e.id:e.id.id,e.url,e.tooltip)}this.graph=UOt(t,this.states,this.classes)}translate(){let e=[[`root`,{stmt:`root`,id:`root`,doc:this.rootDoc},!0]];for(;e.length>0;){let[t,n,r]=e.pop();if(typeof n==`string`)continue;if(n.stmt===`relation`){e.push([t,n.state2,!1],[t,n.state1,!0]);continue}if(n.stmt===`state`)n.id===`[*]`?(n.id=t+(r?`_start`:`_end`),n.start=r):n.id=n.id.trim();else if(n.stmt!==`root`)continue;if(!n.doc)continue;let i=[],a=[];for(let e of n.doc)typeof e!=`string`&&e.stmt===`state`&&e.type===`divider`&&!e.doc?(i.push({...e,doc:a}),a=[]):a.push(e);i.length>0&&(a.length>0&&i.push({stmt:`state`,id:this.getDividerId(),type:`divider`,doc:a}),n.doc=i);for(let t=n.doc.length-1;t>=0;t--)e.push([n.id,n.doc[t],!0])}}addState(e,t=`default`,n,r,i,a){let o=e.trim(),s=this.states.get(o);if(s?(s.doc||(s.doc=n),s.type||(s.type=t)):(s={stmt:`state`,id:o,descriptions:[],type:t,doc:n,note:i,classes:[],styles:[],textStyles:[]},this.states.set(o,s)),r)for(let e of Array.isArray(r)?r:[r])this.addDescription(o,e.trim());if(i&&(s.note=i),a)for(let e of a)this.setCssClass(o,e.trim())}getState(e){return this.states.get(e)}addLink(e,t,n){this.links.set(e,{url:t,tooltip:n})}addRelation(e,t,n=``){for(let n of[e,t])this.addState(n.id,n.type,n.doc,n.description,n.note,n.classes);this.relations.push({id1:e.id.trim(),id2:t.id.trim(),relationTitle:n})}addDescription(e,t){this.states.get(e)?.descriptions?.push(t.startsWith(`:`)?t.replace(`:`,``).trim():t)}getDividerId(){return`divider-id-${++this.dividerCount}`}addStyleClass(e,t=``){let n=this.classes.get(e);if(n||(n={id:e,styles:[],textStyles:[]},this.classes.set(e,n)),t)for(let e of t.split(`,`)){let t=e.replace(`;`,``).trim();e.includes(`color`)&&n.textStyles.push(t.replace(`fill`,`bgFill`).replace(`color`,`fill`)),n.styles.push(t)}}setCssClass(e,t){for(let n of this.named(e))n.classes?.push(t)}getDirection(){for(let e of this.rootDoc)if(typeof e!=`string`&&e.stmt===`dir`)return e.value;return`TB`}setDirection(e){for(let t of this.rootDoc)if(typeof t!=`string`&&t.stmt===`dir`){t.value=e;return}this.rootDoc.unshift({stmt:`dir`,value:e})}trimColon(e){return e.startsWith(`:`)?e.slice(1).trim():e.trim()}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,``)}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
1054
|
+
`,n),c===-1&&(c=t)),c),m=(t,n)=>{let r=e.charCodeAt(t);return r<128?(dOt[r]&n)!==0:n===4||n===32?!eq(r):!0},h=(t,n)=>{for(let r=0;r<n.length;r++){let i=n.charCodeAt(r),a=e.charCodeAt(t+r);if(i>=97&&i<=122?(a|32)!==i:a!==i)return!1}return!0},g=t=>h(s,t)&&!aq(e.charCodeAt(s+t.length)),_=n=>{for(;n<t&&eq(e.charCodeAt(n));)n++;return n},v=()=>{let n=s;for(;n<t;){let t=e.charCodeAt(n);if(t===10||!eq(t))break;n++}return n!==s&&(s=n,!0)},y=e=>{for(;e<t&&m(e,16);)e++;return e},b=(e,t,n)=>{l(e,s,s+t),d(n)},x=(e,t,n=-1)=>g(e)?(l(t,s,s+e.length),n>=0&&d(n),!0):!1,S=(n,r)=>{if(!h(s,n))return!1;let i=s+n.length,a=e.charCodeAt(i);if(a!==32&&a!==9)return!1;for(;a===32||a===9;)a=e.charCodeAt(++i);return i>=t||!m(i,32)?!1:(l(r,s,s+n.length),!0)},C=t=>{let n=e.charCodeAt(t),r=e.charCodeAt(t+1);if(n===45){if(r===120||r===88||r===41||r===92||r===47||r===45)return!0;let n=e.charCodeAt(t+2);return r===124&&(n===92||n===47)}return n===47||n===92?(r===124||r===n)&&e.charCodeAt(t+2)===45:n===40&&r===41},w=()=>{let n=s+1;for(;n<t&&m(n,1);)n++;for(;n<t&&!C(n);){let r=n;for(;e.charCodeAt(r)===45;)r++;if(r>=t||!m(r,2))break;for(r++;r<t&&m(r,2);)r++;n=r}u(48,s,n,e.slice(s,n).trim())},T=()=>{let t=s;for(;rq(e.charCodeAt(t));)t++;let n=t>s;if(e.charCodeAt(t)===46&&rq(e.charCodeAt(t+1))){let n=rq(e.charCodeAt(t+2))?t+3:t+2,r=e.charCodeAt(n);if(r===32||r===10)return l(10,s,n),!0}let r=e.charCodeAt(t);return n&&(r===32||r===10)?(l(10,s,t),!0):!1},E=()=>{let t=e.charCodeAt(s+1),n=e.charCodeAt(s+2);if(t===62)l(n===62?55:53,s,s+(n===62?3:2));else if(t===120||t===88)l(59,s,s+2);else if(t===41)l(61,s,s+2);else if(t===124&&n===92)l(63,s,s+3);else if(t===124&&n===47)l(64,s,s+3);else if(t===92&&n===92)l(65,s,s+3);else if(t===47&&n===47)l(66,s,s+3);else if(t===45){let t=e.charCodeAt(s+3);n===62?l(t===62?57:54,s,s+(t===62?4:3)):n===120||n===88?l(60,s,s+3):n===41?l(62,s,s+3):n===124&&t===92?l(67,s,s+4):n===124&&t===47?l(68,s,s+4):n===92&&t===92?l(69,s,s+4):n===47&&t===47?l(70,s,s+4):l(46,s,s+1)}else l(46,s,s+1)},D=t=>{let n=e.charCodeAt(s+1);if(n!==124&&n!==t||e.charCodeAt(s+2)!==45)return!1;let r=e.charCodeAt(s+3)===45,i=t===47,a;return a=n===124?r?i?75:76:i?71:72:r?i?77:78:i?73:74,l(a,s,s+(r?4:3)),!0},O=()=>{if(!h(s,`title`))return!1;let n=s+5,r=e.charCodeAt(n)===58;return r&&n++,!eq(e.charCodeAt(n))||n+1>=t||!m(n+1,16)?!1:(l(r?15:14,s,y(n+1)),!0)},k=()=>{let t=h(s,`accdescr`);if(!t&&!h(s,`acctitle`))return!1;let n=_(s+8),r=e.charCodeAt(n);return r===58?(l(t?18:16,s,_(n+1)),d(t?6:5),!0):t&&r===123?(s=_(n+1),d(7),!0):!1},A=e=>{switch(e|32){case 97:return x(`actor`,34,1)||x(`alt`,24,3)||x(`and`,30,3)||x(`activate`,12,1)||k()||x(`autonumber`,9);case 98:return x(`box`,6,3)||x(`break`,28,3);case 99:return x(`create`,5)||x(`critical`,27,3);case 100:return x(`destroy`,35,1)||S(`details`,41)||x(`deactivate`,13,1);case 101:return x(`else`,31,3)||x(`end`,8);case 108:return x(`loop`,21,3)||x(`left of`,43)||S(`links`,38)||S(`link`,39);case 110:return x(`note`,36);case 111:return x(`opt`,23,3)||x(`option`,29,3)||x(`over`,37)||x(`off`,11);case 112:return x(`participant`,32,1)||x(`par`,25,3)||x(`par_over`,26,3)||S(`properties`,40);case 114:return x(`rect`,22,3)||x(`right of`,44);case 115:return x(`sequencediagram`,4);case 116:return O();default:return!1}},j=()=>{let t=e.charCodeAt(s);if(t===10){let t=s+1;for(;e.charCodeAt(t)===10;)t++;l(3,s,t)}else if(eq(t))s=_(s+1);else if(t===35||t===37&&e.charCodeAt(s+1)!==123)s=p(s);else if(t!==125&&e.charCodeAt(s+1)===37&&e.charCodeAt(s+2)===37)s=p(s);else if((!rq(t)&&t!==46||!T())&&!(t<128&&(t|32)>=97&&(t|32)<=122&&A(t))){if(t===44)l(42,s,s+1);else if(t===59)l(3,s,s+1);else if(m(s,1))w();else if(t===45)E();else if(t===60&&e.startsWith(`<<->>`,s))l(56,s,s+5);else if(t===60&&e.startsWith(`<<-->>`,s))l(58,s,s+6);else{if((t===47||t===92)&&D(t))return;t===58?l(52,s,y(s+1)):t===43?l(45,s,s+1):t===40&&e.charCodeAt(s+1)===41?l(47,s,s+2):l(2,s,s+1)}}},M=()=>{if(v())return!0;let n=e.charCodeAt(s);if(n===35)return s=p(s),!0;if(n===64&&e.charCodeAt(s+1)===123)return b(49,2,4),!0;let r=s;for(;r<t&&m(r,4);)r++;if(r>s){let t=_(r);if(e.charCodeAt(t)===64&&e.charCodeAt(t+1)===123)return l(48,s,r),!0;if(t>r&&h(t,`as`)&&eq(e.charCodeAt(t+2)))return l(48,s,r),d(2),!0}let i=r;for(;i<t&&m(i,8);)i++;if(i>s){let n=e.charCodeAt(i),r=i;if(i<t&&n!==10&&n!==59)for(r--;r>s&&e.charCodeAt(r)!==35;)r--;if(r>s)return u(48,s,r,e.slice(s,r).trim()),f(),!0}if(e.charCodeAt(i)===60)return l(2,s,p(s)),f(),!0;if(n!==10){let t=p(s);return u(2,s,t,e.slice(s,t).trim()),f(),!0}return!1},N=()=>{switch(o){case 0:return j(),!0;case 1:return M();case 2:return v()?!0:e.charCodeAt(s)===35?(s=p(s),!0):(f(),f(),g(`as`)?b(33,2,3):l(3,s,s),!0);case 3:return v()?!0:e.charCodeAt(s)===35?(s=p(s),!0):(l(7,s,y(s)),f(),!0);case 4:if(e.charCodeAt(s)!==125){let n=e.indexOf(`}`,s);return n===-1&&(n=t),l(50,s,n),!0}{let t=_(s+1),n=t>s+1&&h(t,`as`)&&eq(e.charCodeAt(t+2));return l(51,s,s+1),f(),n?d(2):f(),!0}case 5:case 6:return l(o===5?17:19,s,p(s)),f(),!0;default:if(e.charCodeAt(s)===125)s++,f();else{let n=e.indexOf(`}`,s);n===-1&&(n=t),l(20,s,n)}return!0}};for(;s<t;)if(!N())return n.push(1),r.push(``),i.push(s),{types:n,texts:r,starts:i};return o===0||o===2?l(3,t,t):o===3?l(7,t,t):o===5?l(17,t,t):o===6?l(19,t,t):o===7&&l(20,t,t),n.push(0),r.push(``),i.push(t),{types:n,texts:r,starts:i}}var P1=(/* @__PURE__ */ new Int8Array(79)).fill(-1);P1[53]=5,P1[54]=6,P1[55]=0,P1[57]=1,P1[56]=33,P1[58]=34,P1[59]=3,P1[60]=4,P1[61]=24,P1[62]=25,P1[63]=41,P1[64]=42,P1[65]=43,P1[66]=44,P1[67]=51,P1[68]=52,P1[69]=53,P1[70]=54,P1[71]=45,P1[72]=46,P1[73]=47,P1[74]=48,P1[75]=55,P1[76]=56,P1[77]=57,P1[78]=58;var F1=(/* @__PURE__ */ new Int8Array(79)).fill(-1);F1[21]=2,F1[22]=3,F1[23]=4,F1[28]=5,F1[24]=6,F1[25]=7,F1[26]=7,F1[27]=8,F1[6]=1;var pOt=`'SOLID_OPEN_ARROW', 'DOTTED_OPEN_ARROW', 'SOLID_ARROW', 'DOTTED_ARROW', 'SOLID_CROSS', 'DOTTED_CROSS', 'SOLID_POINT', 'DOTTED_POINT'`;function mOt(e,t){let{types:n,texts:r,starts:i}=fOt(e),a=0,o=t=>{let r=n[a];throw r===1?FK(`sequence`,e,i[a],``,!0):FK(`sequence`,e,i[a],`Expecting ${t}, got '${uOt[r]}'`)},s=e=>(n[a]!==e&&o(`'${uOt[e]}'`),r[a++]),c=()=>{let e=n[a];return e!==48&&e!==39&&o(`'ACTOR'`),{type:`addParticipant`,actor:r[a++]}},l=()=>t.parseMessage(s(52).trim().substring(1)),u=()=>{let e=n[a++];if(e===35){let e=c();return s(3),e.type=`destroyParticipant`,e}let r=c();if(n[a]===49&&n[a-1]===48){a++;let e=s(50);s(51),r.config=e.trim()}if(r.draw=e===32?`participant`:`actor`,n[a]===33){a++;let e=s(7);s(3),r.description=t.parseMessage(e)}else n[a]===3?a++:o(`'AS', 'NEWLINE'`);return r},d=e=>{let t=!1;n[a]===47&&(t=!0,a++);let r=P1[n[a]];r<0&&o(pOt),a++;let i=n[a];i!==47&&(t||i!==45&&i!==46)||a++;let s=c(),u=l(),d={type:`addMessage`,from:e.actor,to:s.actor,signalType:r,msg:u},f=[e,s,d];if(t){let t=i===47;d.activate=t,d.centralConnection=t?61:60,t&&f.push({type:`centralConnection`,signalType:59,actor:s.actor}),f.push({type:`centralConnectionReverse`,signalType:60,actor:e.actor})}else i===45?(d.activate=!0,f.push({type:`activeStart`,signalType:17,actor:s.actor})):i===46?f.push({type:`activeEnd`,signalType:18,actor:e.actor}):i===47&&(d.activate=!0,d.centralConnection=59,f.push({type:`centralConnection`,signalType:59,actor:s.actor}));return f},f=e=>{a++;let t=c();return[t,{type:e,actor:t.actor,text:l()}]},p=()=>{a++;let e=n[a];if(e===37){a++;let e=c(),t=e,r=[e.actor,e.actor];if(n[a]===42){a++;let n=c();t=[e,n],r=[e.actor,n.actor]}return[t,{type:`addNote`,placement:2,actor:r,text:l()}]}e!==43&&e!==44&&o(`'over', 'left_of', 'right_of'`),a++;let t=c();return[t,{type:`addNote`,placement:e===43?0:1,actor:t.actor,text:l()}]},m=()=>{a++;let e={type:`sequenceIndex`,sequenceVisible:!0,signalType:26};return n[a]===10?(e.sequenceIndex=Number(r[a++]),e.sequenceIndexStep=n[a]===10?Number(r[a++]):1):n[a]===11&&(a++,e.sequenceVisible=!1),n[a]!==3&&o(`'NEWLINE', 'NUM', 'off'`),a++,e},h=(e,n,r,i)=>{let a=e.list,o=e.sections;if(o)for(let e=o.length-2;e>=0;e-=2){let s={type:n,signalType:i};s[r]=t.parseMessage(o[e+1]),a=o[e].concat([s,a])}return a},g=e=>{let n=e.text,r=e.list;switch(e.kind){case 1:r[0]={type:`boxStart`,boxData:t.parseBoxData(n)},r.push({type:`boxEnd`,boxText:n});break;case 2:r[0]={type:`loopStart`,loopText:t.parseMessage(n),signalType:10},r.push({type:`loopEnd`,loopText:n,signalType:11});break;case 3:r[0]={type:`rectStart`,color:t.parseMessage(n),signalType:22},r.push({type:`rectEnd`,color:t.parseMessage(n),signalType:23});break;case 4:r[0]={type:`optStart`,optText:t.parseMessage(n),signalType:15},r.push({type:`optEnd`,optText:t.parseMessage(n),signalType:16});break;case 5:r[0]={type:`breakStart`,breakText:t.parseMessage(n),signalType:30},r.push({type:`breakEnd`,optText:t.parseMessage(n),signalType:31});break;case 6:r=h(e,`else`,`altText`,13),r[0]={type:`altStart`,altText:t.parseMessage(n),signalType:12},r.push({type:`altEnd`,signalType:14});break;case 7:r=h(e,`and`,`parText`,20),r[0]={type:`parStart`,parText:t.parseMessage(n),signalType:e.startType},r.push({type:`parEnd`,signalType:21});break;default:r=h(e,`option`,`optionText`,28),r[0]={type:`criticalStart`,criticalText:t.parseMessage(n),signalType:27},r.push({type:`criticalEnd`,signalType:29})}return r};for(;n[a]===3;)a++;s(4);let _=[],v={kind:0,text:``,startType:0,list:[],sections:void 0};for(;;){let e=n[a],i=v.list;if(v.kind===1){if(e===32||e===34||e===35)i.push(u());else if(e===3)i.push([]),a++;else if(e===8){a++;let e=g(v);v=_.pop(),v.list.push(e)}else o(`'end', 'NEWLINE', 'participant', 'participant_actor', 'destroy'`)}else switch(e){case 3:case 2:i.push([]),a++;break;case 32:case 34:case 35:i.push(u());break;case 5:{a++;let e=n[a];e!==32&&e!==34&&e!==35&&o(`'participant', 'participant_actor', 'destroy'`);let t=u();t.type=`createParticipant`,i.push(t);break}case 48:i.push(d(c())),s(3);break;case 39:{let e=n[a+1];i.push(e===48||e===39?f(`addALink`):d(c())),s(3);break}case 38:i.push(f(`addLinks`)),s(3);break;case 40:i.push(f(`addProperties`)),s(3);break;case 41:i.push(f(`addDetails`)),s(3);break;case 36:i.push(p()),s(3);break;case 9:i.push(m());break;case 12:case 13:{a++;let t=c();s(3),i.push(e===12?{type:`activeStart`,signalType:17,actor:t.actor}:{type:`activeEnd`,signalType:18,actor:t.actor});break}case 14:case 15:{let n=r[a++].substring(e===14?6:7);t.setDiagramTitle(n),i.push(n);break}case 16:{a++;let e=s(17).trim();t.setAccTitle(e),i.push(e);break}case 18:{a++;let e=s(19).trim();t.setAccDescription(e),i.push(e);break}case 20:{let e=r[a++].trim();t.setAccDescription(e),i.push(e);break}case 21:case 22:case 23:case 28:case 24:case 25:case 26:case 27:case 6:{a++;let t=s(7);_.push(v),v={kind:F1[e],text:t,startType:e===26?32:19,list:[[]],sections:void 0};break}case 31:case 30:case 29:{v.kind!==(e===31?6:e===30?7:8)&&o(`'end'`),a++;let t=s(7);(v.sections??=[]).push(i,t),v.list=[];break}case 8:{v.kind===0&&o(`'NEWLINE', 'EOF'`),a++;let e=g(v);v=_.pop(),v.list.push(e);break}case 0:v.kind!==0&&o(`'end'`),t.apply(i);return;default:o(`'NEWLINE', 'ACTOR', 'participant', 'note', 'end'`)}}}var hOt=16,gOt=10,_Ot=34,vOt=4,I1=5,L1=6,R1=` fill="var(--_s)" stroke="var(--_b)"`,z1=` fill="none" stroke="var(--_b)"`,yOt=/* @__PURE__ */ new Set([`participant`,`actor`,`boundary`,`control`,`entity`,`database`,`collections`,`queue`]),bOt=/* @__PURE__ */ new Set([`actor`,`boundary`,`control`,`entity`,`database`]);function xOt(e){return yOt.has(e)?e:`participant`}function B1(e){return bOt.has(e)}function SOt(e,t,n,r,i=hOt){if(B1(e))return{w:Math.max(40,t.width+8),h:_Ot+(t.height>0?vOt+t.height:0)};let a=e===`collections`?I1:e===`queue`?2*L1:0;return{w:Math.max(n,t.width+2*i)+a,h:Math.max(r,t.height+2*gOt)+(e===`collections`?I1:0)}}function COt(e,t,n){let r=K(t),i=e=>K(n+e);switch(e){case`actor`:return`<circle cx="${r}" cy="${i(7)}" r="6"${R1}/><path d="M${r},${i(13)}V${i(24)}M${K(t-10)},${i(17)}H${K(t+10)}M${K(t-8)},${i(34)}L${r},${i(24)}L${K(t+8)},${i(34)}"${z1}/>`;case`boundary`:return`<path d="M${K(t-19)},${i(6)}V${i(28)}M${K(t-19)},${i(17)}H${K(t-8)}"${z1}/><circle cx="${K(t+3)}" cy="${i(17)}" r="11"${R1}/>`;case`control`:return`<circle cx="${r}" cy="${i(21)}" r="11"${R1}/><path d="M${K(t+5)},${i(5)}L${K(t-1)},${i(10)}L${K(t+5)},${i(15)}"${z1}/>`;case`entity`:return`<circle cx="${r}" cy="${i(15)}" r="11"${R1}/><path d="M${K(t-11)},${i(30)}H${K(t+11)}"${z1}/>`;default:{let e=K(t-14),n=K(t+14);return`<path d="M${e},${i(7)}V${i(27)}A14,5 0 0 0 ${n},${i(27)}V${i(7)}A14,5 0 0 0 ${e},${i(7)}Z"${R1}/><path d="M${e},${i(7)}A14,5 0 0 0 ${n},${i(7)}"${z1}/>`}}}function wOt(e,t,n,r,i,a){let{w:o,h:s}=r,c=` class="pele-label"`;if(B1(e))return COt(e,t,n)+gq(i,t,n+_Ot+vOt+i.height/2,c,a);let l=t-o/2;if(e===`collections`){let e=o-I1,t=s-I1;return`<rect x="${K(l+I1)}" y="${K(n)}" width="${K(e)}" height="${K(t)}" rx="${dJ}"${R1}/><rect x="${K(l)}" y="${K(n+I1)}" width="${K(e)}" height="${K(t)}" rx="${dJ}"${R1}/>`+gq(i,l+e/2,n+I1+t/2,c,a)}if(e===`queue`){let e=K(l+L1),r=K(l+o-L1),u=K(n+s),d=K(s/2);return`<path d="M${e},${K(n)}H${r}A${L1},${d} 0 0 1 ${r},${u}H${e}A${L1},${d} 0 0 1 ${e},${K(n)}Z"${R1}/><path d="M${r},${K(n)}A${L1},${d} 0 0 0 ${r},${u}"${z1}/>`+gq(i,t-L1/2,n+s/2,c,a)}return`<rect x="${K(l)}" y="${K(n)}" width="${K(o)}" height="${K(s)}" rx="${dJ}"${R1}/>`+gq(i,t,n+s/2,c,a)}var V1=[];function H1(e,t,n,r=1,i=!1){V1[e]={dotted:t,head:n,atStart:r!==1,atEnd:r!==0,bottom:i}}H1(0,!1,1),H1(1,!0,1),H1(3,!1,2),H1(4,!0,2),H1(5,!1,0),H1(6,!0,0),H1(24,!1,3),H1(25,!0,3),H1(33,!1,1,2),H1(34,!0,1,2);for(let e of[!1,!0]){let t=e?10:0;H1(41+t,e,4),H1(42+t,e,4,1,!0),H1(43+t,e,5),H1(44+t,e,5,1,!0),H1(45+t,e,4,0),H1(46+t,e,4,0,!0),H1(47+t,e,5,0),H1(48+t,e,5,0,!0)}var TOt=/* @__PURE__ */ new Map([[10,`loop`],[12,`alt`],[15,`opt`],[19,`par`],[32,`par`],[27,`critical`],[30,`break`],[22,`rect`]]),EOt=12,U1=28,DOt=22,W1=10,OOt=4,kOt=14,G1=10,AOt=16,jOt=20,MOt=10,K1=20,NOt=240,q1=16,J1=4,POt=` stroke-dasharray="4 4"`;function Y1(e){return e!==void 0&&V1[e]!==void 0}function FOt(e,t){let n=Array(e.length),r=Array(e.length),i=1,a=1,o=!1;for(let s=0;s<e.length;s++){let c=e[s];if(n[s]=NaN,r[s]=!1,c.type===26){let e=c.message;i=e.start||i,a=e.step||a,o=e.visible}else Y1(c.type)&&(n[s]=i,r[s]=o||t,i=Math.round((i+a)*100)/100)}return{index:n,shown:r,visible:o}}var IOt={lines:[],widths:[],width:0,height:0,size:0,lineHeight:0};function X1(e,t,n){let r=e[t];return typeof r==`number`&&r>=0&&r<=2e3?r:n}function LOt(e,t,n,r,i){let a=K(e-n*rJ);return i?`<path class="pele-marker" d="M${K(e)},${K(t)}L${a},${K(t+r*5)}"/>`:`<path class="pele-marker" d="M${K(e)},${K(t)}L${a},${K(t+r*4.5)}V${K(t)}Z" fill="var(--_l)" stroke="none"/>`}function Z1(e,t,n,r,i){switch(e){case 1:return cJ(`arrow_point`,t,n,r,0,`var(--_l)`);case 2:return cJ(`arrow_cross`,t,n,r,0,`var(--_l)`);case 3:return`<path class="pele-marker" d="M${K(t-r*rJ)},${K(n-4.5)}L${K(t)},${K(n)}L${K(t-r*rJ)},${K(n+4.5)}" stroke-linejoin="round"/>`;case 4:return LOt(t,n,r,i,!1);case 5:return LOt(t,n,r,i,!0);default:return``}}function ROt(e){return e===1?rJ-1:e===2?4:0}function zOt(e,t,n){return YJ(n,r=>BOt(e,t,n,r))}function BOt(e,t,n,r){let i=t.sequence??{},a=n.fontSize??16,o=Math.round(a*.875),s=Math.round(a*.75),c=n.measurer??fq(n.fontFamily),l=n.icons,u=n.padding??8,d=i.mirrorActors!==!1,f=i.rightAngles===!0,p=Math.min(X1(i,`actorMargin`,40),r?8:1/0),m=Math.min(X1(i,`width`,64),r?48:1/0),h=X1(i,`height`,Math.round(a*1.5)+20),g=Math.min(X1(i,`width`,160),r?Math.max(32,((n.maxWidth??320)-2*u)/Math.max(1,e.actors.size)-p-24):1/0),_=Math.max(4,14+X1(i,`messageMargin`,35)-35),v=Math.min(X1(i,`noteMargin`,10),r?6:1/0),y=Math.min(X1(i,`boxMargin`,10),r?6:1/0),b=i.messageAlign===`left`?-1:+(i.messageAlign===`right`),x=r?6:EOt,S=r?8:AOt,C=r?12:jOt,w=r?6:MOt,T=e.messages,E=T.length,D=FOt(T,i.showSequenceNumbers===!0),O=(e,t,n,i=g,a=0)=>{let o=UJ(e,!1,c,t,r||n?i:1/0,a);return r?ZY(o,c,Math.max(120,i)):o},k;if(i.hideUnusedParticipants===!0){k=/* @__PURE__ */ new Set;for(let e of T)k.add(e.from).add(e.to)}let A=new Int32Array(E+1);A[E]=-1;for(let e=E-1;e>=0;e--)A[e]=Y1(T[e].type)?e:A[e+1];let j=[],M=/* @__PURE__ */ new Map;for(let[t,n]of e.actors){if(k&&!k.has(t))continue;let i=xOt(n.type),o=O(n.description,a,n.wrap),s=e.createdActors.get(t),c=e.destroyedActors.get(t),l=s===void 0?-1:A[Math.min(s,E)];l>=0&&T[l].to!==t&&(l=-1);let u=c===void 0?-1:A[Math.min(c,E)];u>=0&&T[u].to!==t&&T[u].from!==t&&(u=-1),M.set(t,j.length),j.push({id:t,actor:n,kind:i,label:o,size:SOt(i,o,m,h,r?8:void 0),x:0,createAt:l,destroyAt:u,top:0,lifeStart:0,lifeEnd:-1,activations:[]})}let N=j.length-1,P=/* @__PURE__ */ new Map,F=(e,t,n)=>{if(e<0||t>N)return;let r=e*j.length+t;(P.get(r)??0)<n&&P.set(r,n)},ee=e=>D.shown[e]?Math.max(q1,c.width(String(D.index[e]),s,0)+8):0,te=Array(E);for(let e=0;e<E;e++){let t=T[e],n=t.from===void 0?void 0:M.get(t.from),i=t.to===void 0?void 0:M.get(t.to);if(n!==void 0&&i!==void 0&&typeof t.message==`string`){if(t.type===2){let r=O(t.message,o,t.wrap),a=r.width+2*v;t.placement===0?F(n-1,n,a+2*G1+W1):t.placement===1?F(n,n+1,a+2*G1+W1):n===i?(F(n-1,n,a/2+G1),F(n,n+1,a/2+G1)):F(Math.min(n,i),Math.max(n,i),a-2*S),te[e]={kind:2,a:n,b:i,label:r,x:0,w:a}}else if(Y1(t.type)){let a=O(t.message,o,t.wrap),s=ee(e);if(n===i)F(n,n+1,U1+8+a.width+16+W1+s),te[e]={kind:1,a:n,b:i,label:a,x:0,w:0};else{let o=j[i].createAt===e?j[i].size.w/2:0,c=t.centralConnection?4*J1:0;F(Math.min(n,i),Math.max(n,i),(r?Math.min(a.width,Math.max(16,g-16)):a.width)+2*x+W1+s+o+c),te[e]={kind:0,a:n,b:i,label:a,x:0,w:0}}}}}let I=[];for(let e=0;e<=N;e++){let t=j[e].actor.box,n=I[I.length-1];t&&n&&n.box===t&&n.last===e-1?n.last=e:t&&I.push({box:t,first:e,last:e,title:O(t.name,o,t.wrap),grow:0})}let ne=Array(Math.max(N,0));for(let e=0;e<N;e++){let t=j[e],n=j[e+1],r=t.actor.box===n.actor.box?0:(t.actor.box?y:0)+(n.actor.box?y:0);ne[e]=Math.max(t.size.w/2+n.size.w/2+p+r,P.get(e*j.length+e+1)??0)}let re=[];for(let[e,t]of P){let n=Math.floor(e/j.length),r=e%j.length;r-n>1&&re.push([n,r,t])}re.sort((e,t)=>e[1]-e[0]-(t[1]-t[0])||e[0]-t[0]);for(let[e,t,n]of re){let r=0;for(let n=e;n<t;n++)r+=ne[n];if(r>=n)continue;let i=(n-r)/(t-e);for(let n=e;n<t;n++)ne[n]+=i}let ie=()=>{for(let e=1;e<=N;e++)j[e].x=j[e-1].x+ne[e-1]};ie();for(let e of I){let t=j[e.last].x+j[e.last].size.w/2-(j[e.first].x-j[e.first].size.w/2);e.grow=Math.max(0,(e.title.width-t)/2),e.grow!==0&&(e.first>0&&(ne[e.first-1]+=e.grow),e.last<N&&(ne[e.last]+=e.grow))}ie();let ae=1/0,L=-1/0,oe=(e,t)=>{e<ae&&(ae=e),t>L&&(L=t)};for(let e of j)oe(e.x-e.size.w/2,e.x+e.size.w/2);for(let e of I)oe(j[e.first].x-j[e.first].size.w/2-y-e.grow,j[e.last].x+j[e.last].size.w/2+y+e.grow);let se=Array(E),ce=[],le=()=>N<0?[0,120]:[j[0].x-C,j[N].x+C];for(let e=0;e<E;e++){let t=T[e],n=t.type,i=n===void 0?void 0:TOt.get(n),a=te[e];if(i!==void 0){let n={kind:i,x0:1/0,x1:-1/0,top:0,title:IOt,tabW:0,fill:i===`rect`&&typeof t.message==`string`?t.message:``,dividers:[e],dividerY:[],dividerLabels:[]};se[e]=n,ce.push(n)}else if(n===13||n===20||n===28)ce[ce.length-1]?.dividers.push(e);else if(n===11||n===14||n===16||n===21||n===29||n===31||n===23){let t=ce.pop();if(!t)continue;if(se[e]=t,t.x0>t.x1&&([t.x0,t.x1]=le()),t.kind!==`rect`){t.tabW=c.width(t.kind,s,1)+14;for(let e=0;e<t.dividers.length;e++){let n=T[t.dividers[e]].message,i=e===0?t.tabW+8:0,a=t.x1-t.x0-16-i,s=n?O(`[${n}]`,o,!0,Math.max(a,r?Math.min(NOt,g):NOt)):IOt;s.width>a&&(t.x1+=s.width-a),e===0?t.title=s:t.dividerLabels.push(s)}}oe(t.x0,t.x1);let n=ce[ce.length-1];n&&(n.x0=Math.min(n.x0,t.x0-w),n.x1=Math.max(n.x1,t.x1+w))}else if(a){let n=j[a.a],i=j[a.b],s,c;if(a.kind===2){if(t.placement===0)a.x=n.x-G1-a.w;else if(t.placement===1)a.x=n.x+G1;else if(a.a===a.b)a.x=n.x-a.w/2;else{let e=Math.min(n.x,i.x)-S,s=Math.max(n.x,i.x)+S;(r||t.wrap)&&(a.label=O(t.message,o,!0,Math.max(g,s-e-2*v))),a.w=Math.max(s-e,a.label.width+2*v),a.x=(e+s-a.w)/2}s=a.x,c=a.x+a.w}else a.kind===1?(s=n.x,c=n.x+W1+U1+8+a.label.width+ee(e)):(s=Math.min(n.x,i.x),c=Math.max(n.x,i.x),(r||t.wrap)&&(a.label=O(t.message,o,!0,Math.max(g,c-s-2*x-W1))),i.createAt===e&&(i.x>n.x?c+=i.size.w/2:s-=i.size.w/2));oe(s,c);let l=ce[ce.length-1];l&&(l.x0=Math.min(l.x0,s-C),l.x1=Math.max(l.x1,c+C))}}let ue=0;for(let e of I)ue=Math.max(ue,e.title.height);let de=I.length>0?y+(ue>0?ue+4:0):0,fe=0;for(let e of j)e.createAt<0&&(fe=Math.max(fe,e.size.h));let pe=de+fe;for(let e of j)e.top=pe-e.size.h,e.lifeStart=pe;let me=j.map(e=>e.x),he=(e,t)=>{let n=0,r=me.length;for(;n<r;){let t=n+r>>1;me[t]<=e?n=t+1:r=t}return n<me.length&&me[n]<t},ge=(e,t,n,r)=>{if(e.width===0)return``;let i=t-e.width/2;return(he(i,i+e.width)?`<rect x="${K(i-3)}" y="${K(n-e.height/2+2)}" width="${K(e.width+6)}" height="${K(e.height-4)}" rx="3" fill="var(--_bg)" stroke="none"/>`:``)+gq(e,t,n,r,l)},_e=(e,t=0)=>e.activations.length+t>0?e.x-W1/2:e.x,ve=(e,t=0)=>{let n=e.activations.length+t;return n>0?e.x+W1/2+(n-1)*OOt:e.x},ye=[],be=[],xe=``,Se=``,Ce=``,we=``,Te=``,Ee=``,De=(e,t)=>{let n=e.activations.pop(),r=Math.max(t,n+kOt),i=e.x-W1/2+e.activations.length*OOt;return oe(i,i+W1),be.push(`<rect class="pele-activation" data-id="${mq(e.id)}" x="${K(i)}" y="${K(n)}" width="${W1}" height="${K(r-n)}" rx="2"/>`),r},Oe=(e,t)=>{let n=e.x,r=t+16;return e.lifeEnd=r,Ee+=`<path class="pele-destroy" data-id="${mq(e.id)}" d="M${K(n-6)},${K(r-6)}L${K(n+6)},${K(r+6)}M${K(n+6)},${K(r-6)}L${K(n-6)},${K(r+6)}"/>`,r+6},ke=(e,t,n)=>{let r=e.actor.properties.get(`class`);return`<g class="pele-node pele-actor pele-actor-${e.kind}${n?` pele-actor-footer`:``}${typeof r==`string`?mJ(r):``}" data-id="${mq(e.id)}">`+wOt(e.kind,e.x,t,e.size,e.label,l)+`</g>`},Ae=(e,t,n,r)=>`<g class="pele-sequence-number"><rect x="${K(t-r/2)}" y="${K(n-q1/2)}" width="${K(r)}" height="${q1}" rx="${q1/2}" fill="var(--_l)" stroke="none"/><text x="${K(t)}" y="${K(n+s*.35)}" text-anchor="middle" font-size="${s}" fill="var(--_bg)" stroke="none">${pq(String(D.index[e]))}</text></g>`,je=pe+6,Me=[];for(let e=0;e<E;e++){let t=T[e],n=t.type,r=te[e],i=se[e];if(n===17){let e=t.from===void 0?void 0:M.get(t.from);e!==void 0&&j[e].activations.push(je)}else if(n===18){let e=t.from===void 0?void 0:M.get(t.from);e!==void 0&&j[e].activations.length>0&&(je=Math.max(je,De(j[e],je)))}else if(i&&i.dividers[0]===e)Me.push(i),i.kind===`rect`?(i.top=je+8,je=i.top):(i.top=je+12,je=i.top+Math.max(K1,i.title.height+2));else if(i){Me.pop();let e=je+12,t=K(i.x0),n=K(i.x1-i.x0);if(i.kind===`rect`){let r=i.fill?pJ([`fill:${i.fill}`]).shape:``;ye.push(`<rect class="pele-rect" x="${t}" y="${K(i.top)}" width="${n}" height="${K(e-i.top)}" rx="${dJ}"${r?``:` fill-opacity="0.5"`}${r}/>`)}else{let r=`<rect x="${t}" y="${K(i.top)}" width="${n}" height="${K(e-i.top)}" rx="${dJ}" fill="none"/>`;for(let e=0;e<i.dividerY.length;e++){let n=i.dividerY[e],a=i.dividerLabels[e];r+=`<path d="M${t},${K(n)}H${K(i.x1)}"${POt}/>`+ge(a,i.x0+8+a.width/2,n+2+a.height/2,` class="pele-frame-label" fill="var(--_m)" stroke="none"`)}r+=`<rect x="${t}" y="${K(i.top)}" width="${K(i.tabW)}" height="${K1}" rx="${dJ}" fill="var(--_s)"/><text class="pele-frame-kind" x="${K(i.x0+i.tabW/2)}" y="${K(i.top+K1/2+s*.35)}" text-anchor="middle" font-size="${s}" font-weight="var(--_hw)" fill="var(--_m)" stroke="none">${i.kind}</text>`+ge(i.title,i.x0+i.tabW+8+i.title.width/2,i.top+Math.max(K1,i.title.height)/2,` class="pele-frame-label" fill="var(--_m)" stroke="none"`),xe+=`<g class="pele-frame pele-frame-${i.kind}">${r}</g>`}je=e}else if(n===13||n===20||n===28){let e=Me[Me.length-1];if(e){let t=e.dividerLabels[e.dividerY.length];e.dividerY.push(je+12),je+=12+(t.height>0?t.height:0)}}else if(r&&r.kind===2){let e=j[r.a],n=r.label.height+2*Math.max(4,v-4),i=je+10,a=r.x;t.placement===1?a+=ve(e)-e.x:t.placement===0&&(a+=_e(e)-e.x),oe(a,a+r.w),we+=`<g class="pele-note" data-id="i${mq(t.id)}"><rect x="${K(a)}" y="${K(i)}" width="${K(r.w)}" height="${K(n)}" rx="${dJ}"/>`+gq(r.label,a+r.w/2,i+n/2,` class="pele-label" stroke="none" fill="var(--_fg)"`,l)+`</g>`,je=i+n}else if(r){let i=V1[n],a=j[r.a],o=j[r.b],s=r.label,c=ee(e),u=0;for(let n=e+1;n<E;n++){let e=T[n].type;if(e===17)T[n].from===t.to&&u++;else if(e!==18&&e!==59&&e!==60)break}let d=i.bottom?1:-1,p=i.dotted?POt:``,m=t.centralConnection,h=m===59||m===61,g=m===60||m===61,v=(e,t)=>`<circle class="pele-central" cx="${K(e)}" cy="${K(t)}" r="${J1}" fill="var(--_l)" stroke="none"/>`,y=i.atStart&&!i.atEnd,S=ROt(i.head),C=``,w;if(r.kind===1){let n=je+_+Math.max(0,(s.height-DOt)/2),r=n+DOt,o=g?a.x+J1:ve(a),m=h?a.x+J1:ve(a,u),b=Math.max(o,m)+U1+c/2;g&&(C+=v(a.x,n)),h&&(C+=v(a.x,r)),c>0&&(C+=Ae(e,y?m:o,y?r:n,c),y?m+=c/2:o+=c/2);let x=(i.atStart?Z1(i.head,o,n,-1,d):``)+(i.atEnd?Z1(i.head,m,r,-1,-d):``),T=K(o+(i.atStart?S:0)),E=K(m+(i.atEnd?S:0));C=`<path d="${f?`M${T},${K(n)}H${K(b)}V${K(r)}H${E}`:`M${T},${K(n)}H${K(b-6)}A6,6 0 0 1 ${K(b)},${K(n+6)}V${K(r-6)}A6,6 0 0 1 ${K(b-6)},${K(r)}H${E}`}"${p}/>`+x+C,oe(a.x,b+8+s.width),s.width>0&&(Ce+=`<g class="pele-edge-label" data-id="i${mq(t.id)}">${gq(s,b+8+s.width/2,(n+r)/2,``,l)}</g>`),w=r}else{let n=o.x>a.x?1:-1,r=o.createAt===e;w=je+_+Math.max(s.height>0?s.height+2:6,r?o.size.h/2-_+6:0);let l=n>0?ve(a):_e(a),f=n>0?_e(o,u):ve(o,u);if(r&&(o.top=w-o.size.h/2,o.lifeStart=o.top+o.size.h,f=o.x-n*(B1(o.kind)?18:o.size.w/2+1)),g&&(C+=v(a.x,w),l=a.x+n*J1),h&&(C+=v(o.x,w),f=o.x-n*J1),c>0){if(y){let t=h?f-n*(c/2+2):f;C+=Ae(e,t,w,c),f=t-n*c/2}else{let t=g?l+n*(c/2+2):l;C+=Ae(e,t,w,c),l=t+n*c/2}}let m=(i.atStart?Z1(i.head,l,w,-n,d*n):``)+(i.atEnd?Z1(i.head,f,w,n,d*n):``),T=l+(i.atStart?n*S:0),E=f-(i.atEnd?n*S:0);if(C=`<path d="M${K(T)},${K(w)}H${K(E)}"${p}/>`+m+C,s.width>0){let e=Math.min(l,f),n=Math.max(l,f),r=b<0?e+x+s.width/2:b>0?n-x-s.width/2:(e+n)/2;oe(r-s.width/2,r+s.width/2),Ce+=`<g class="pele-edge-label" data-id="i${mq(t.id)}">${ge(s,r,w-4-s.height/2,``)}</g>`}r&&(je=w+o.size.h/2-6)}Se+=`<g class="pele-edge pele-message" data-id="i${mq(t.id)}">${C}</g>`,je=Math.max(je,w),a.destroyAt===e&&(je=Math.max(je,Oe(a,w))),o.destroyAt===e&&o!==a&&(je=Math.max(je,Oe(o,w)))}}je+=20;for(let e of j)for(;e.activations.length>0;)De(e,je);let Ne=je;if(d){let e=0;for(let t of j)t.lifeEnd>=0||(e=Math.max(e,t.size.h),Te+=ke(t,je,!0));Ne=je+e}let Pe=``;for(let e of j){Te+=ke(e,e.top,!1);let t=e.lifeEnd>=0?e.lifeEnd:je;t>e.lifeStart&&(Pe+=`<path class="pele-lifeline" data-id="${mq(e.id)}" d="M${K(e.x)},${K(e.lifeStart)}V${K(t)}"/>`)}let Fe=``;for(let e of I){let t=j[e.first].x-j[e.first].size.w/2-y-e.grow,n=j[e.last].x+j[e.last].size.w/2+y+e.grow,r=e.box.fill===`transparent`?``:pJ([`fill:${e.box.fill}`]).shape;Fe+=`<g class="pele-cluster pele-box"${e.box.name?` data-id="${mq(e.box.name)}"`:``}><rect x="${K(t)}" y="0" width="${K(n-t)}" height="${K(Ne+y)}" rx="${dJ}" fill="var(--_a)" stroke="var(--_b)"${r?``:` fill-opacity="0.5"`}${r}/>`+gq(e.title,(t+n)/2,y/2+2+e.title.height/2,` class="pele-cluster-label" fill="var(--_m)"`,l)+`</g>`}I.length>0&&(Ne+=y);let Ie=0,Le=``,Re=O(e.title,a,!1,r?GJ(n):g,1);if(ae>L&&oe(0,Math.max(Re.width,40)),Re.width>0){let e=(ae+L)/2;oe(e-Re.width/2,e+Re.width/2),Ie=-Re.height-12,Le=gq(Re,e,Ie+Re.height/2,` class="pele-title" font-weight="var(--_tw)"`,l)}let ze=Math.ceil(L-ae+2*u),Be=Math.ceil(Ne-Ie+2*u);return{svg:_J(`sequence`,ze,Be,a,n,e,`<g transform="translate(${K(u-ae)},${K(u-Ie)})">`+Le+(Fe?`<g class="pele-boxes" font-size="${o}">${Fe}</g>`:``)+(ye.length>0?`<g class="pele-rects" fill="var(--_a)">${ye.reverse().join(``)}</g>`:``)+(Pe?`<g class="pele-lifelines" fill="none" stroke="var(--_b)">${Pe}</g>`:``)+(be.length>0?`<g class="pele-activations" fill="var(--_s)" stroke="var(--_b)">${be.reverse().join(``)}</g>`:``)+(xe?`<g class="pele-frames" font-size="${o}" stroke="var(--_b)">${xe}</g>`:``)+(Se?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${Se}</g>`:``)+(Ee?`<g class="pele-destroys" fill="none" stroke="var(--_l)" stroke-width="1.5" stroke-linecap="round">${Ee}</g>`:``)+(Ce?`<g class="pele-edge-labels" font-size="${o}">${Ce}</g>`:``)+(we?`<g class="pele-notes" font-size="${o}" fill="var(--_a)" stroke="var(--_b)">${we}</g>`:``)+(Te?`<g class="pele-nodes">${Te}</g>`:``)+`</g>`),width:ze,height:Be,links:[]}}var VOt={type:`sequence`,parse(e,t,n){let r=t.sequence??{},i=new lOt({wrap:typeof t.wrap==`boolean`?t.wrap:void 0,sequenceWrap:r.wrap===!0});return n&&i.setDiagramTitle(n),mOt(e,i),i},render:zOt};function HOt(e){let t=`TB`;for(let n of e)typeof n!=`string`&&n.stmt===`dir`&&(t=n.value);return t}function UOt(e,t,n){let r=[],i=[],a=/* @__PURE__ */ new Map,o=/* @__PURE__ */ new Map,s=/* @__PURE__ */ new Map,c=0,l=0,u=e=>{if(!e.id||e.id===`</join></fork>`||e.id===`</choice>`)return;if(e.cssClasses){let t;for(let r of e.cssClasses.split(` `)){let i=n.get(r);if(i){t??=e.cssCompiledStyles.slice();for(let e of i.styles)t.push(e)}}t&&(e.cssCompiledStyles=t)}let t=a.get(e.id);if(t){let n=e.parentId??t.parentId;Object.assign(t,e),n!==void 0&&(t.parentId=n)}else a.set(e.id,e),r.push(e)},d=(e,n,r)=>{let a=n.id;if(a===`root`)return;let d=t.get(a),f=d?.classes?.join(` `)??``,p=d?.styles??[],m=o.get(a);if(!m){let e=`rect`;n.start===!0?e=`stateStart`:n.start===!1&&(e=`stateEnd`),n.type!=="default"&&(e=n.type),m={shape:e,description:a,cssClasses:`${f} statediagram-state`,cssStyles:p,type:void 0,dir:void 0,colorIndex:void 0},o.set(a,m)}if(n.description&&(Array.isArray(m.description)?(m.shape=`rectWithTitle`,m.description=m.description.concat(n.description)):m.description.length>0?(m.shape=`rectWithTitle`,m.description=m.description===a?[n.description].flat():[m.description,n.description].flat()):(m.shape=`rect`,m.description=Array.isArray(n.description)?n.description.slice():n.description)),m.description.length===1&&m.shape===`rectWithTitle`&&(m.shape=m.type===`group`?`roundedWithTitle`:`rect`),!m.type&&n.doc){if(m.type=`group`,m.dir=HOt(n.doc),m.shape=n.type===`divider`?`divider`:`roundedWithTitle`,m.shape===`divider`&&e?.id!==void 0&&s.has(e.id))m.colorIndex=s.get(e.id);else{let e=l++;m.colorIndex=f.trim()!==``||p.length>0?void 0:e}s.set(a,m.colorIndex),m.cssClasses=`${m.cssClasses} statediagram-cluster ${r?`statediagram-cluster-alt`:``}`}let h=m.description,g={id:a,shape:m.shape,label:Array.isArray(h)?h[0]:h,description:Array.isArray(h)?h.slice(1):[],cssClasses:m.cssClasses,cssCompiledStyles:[],cssStyles:m.cssStyles,type:m.type,isGroup:m.type===`group`,dir:m.dir,colorIndex:m.colorIndex};g.shape===`divider`&&(g.label=``),e&&e.id!==`root`&&(g.parentId=e.id);let _=n.note;if(!_){u(g);return}let v=(e,t,n,r)=>({id:e,shape:t,label:_.text,description:[],cssClasses:n,cssCompiledStyles:[],cssStyles:[],type:r?`group`:`node`,isGroup:r,dir:void 0,position:_.position}),y=v(`${a}----note-${c++}`,`note`,`statediagram-note`,!1);y.parentId=`${a}----parent`,y.noteFor=a,u(v(y.parentId,`noteGroup`,m.cssClasses,!0)),u(y),u(g);let b=_.position===`left of`,x=b?y.id:a,S=b?a:y.id;i.push({id:`${x}-${S}`,start:x,end:S,label:``,classes:`transition note-edge`,pattern:`dashed`})},f=[{item:void 0,doc:e,at:0,alt:!0}];for(;f.length>0;){let e=f[f.length-1];if(e.at>=e.doc.length){f.pop();continue}let t=e.doc[e.at++];typeof t!=`string`&&(t.stmt===`state`?(d(e.item,t,e.alt),t.doc&&f.push({item:t,doc:t.doc,at:0,alt:!e.alt})):t.stmt===`relation`&&(d(e.item,t.state1,e.alt),d(e.item,t.state2,e.alt),i.push({id:`edge${c++}`,start:t.state1.id,end:t.state2.id,label:t.description??``,classes:`transition`})))}for(let e of r)if(e.isGroup&&e.description.length>0)throw new NK(`Group nodes can only have label. Remove the additional description for node [${e.id}]`,`semantic`,{type:`state`});return{nodes:r,edges:i}}var WOt=class{type=`state`;rootDoc=[];states=/* @__PURE__ */ new Map;relations=[];classes=/* @__PURE__ */ new Map;links=/* @__PURE__ */ new Map;graph={nodes:[],edges:[]};title;accTitle;accDescr;dividerCount=0;get direction(){let e=`TB`;for(let t of this.rootDoc)typeof t!=`string`&&t.stmt===`dir`&&(e=t.value);return e}setRootDoc(e){this.rootDoc=e,this.translate(),this.extract(e)}extract(e){this.states=/* @__PURE__ */ new Map,this.relations=[],this.classes=/* @__PURE__ */ new Map;let t=Array.isArray(e)?e:e.doc;for(let e of t)if(typeof e!=`string`)switch(e.stmt){case`state`:this.addState(e.id.trim(),e.type,e.doc,e.description,e.note);break;case`relation`:this.addRelation(e.state1,e.state2,e.description);break;case`classDef`:this.addStyleClass(e.id.trim(),e.classes);break;case`style`:{let t=e.styleClass.split(`,`).map(e=>e.replace(/;/g,``).trim());for(let n of this.named(e.id.trim()))n.styles=t.slice();break}case`applyClass`:this.setCssClass(e.id.trim(),e.styleClass);break;case`click`:this.addLink(typeof e.id==`string`?e.id:e.id.id,e.url,e.tooltip)}this.graph=UOt(t,this.states,this.classes)}translate(){let e=[[`root`,{stmt:`root`,id:`root`,doc:this.rootDoc},!0]];for(;e.length>0;){let[t,n,r]=e.pop();if(typeof n==`string`)continue;if(n.stmt===`relation`){e.push([t,n.state2,!1],[t,n.state1,!0]);continue}if(n.stmt===`state`)n.id===`[*]`?(n.id=t+(r?`_start`:`_end`),n.start=r):n.id=n.id.trim();else if(n.stmt!==`root`)continue;if(!n.doc)continue;let i=[],a=[];for(let e of n.doc)typeof e!=`string`&&e.stmt===`state`&&e.type===`divider`&&!e.doc?(i.push({...e,doc:a}),a=[]):a.push(e);i.length>0&&(a.length>0&&i.push({stmt:`state`,id:this.getDividerId(),type:`divider`,doc:a}),n.doc=i);for(let t=n.doc.length-1;t>=0;t--)e.push([n.id,n.doc[t],!0])}}addState(e,t=`default`,n,r,i,a){let o=e.trim(),s=this.states.get(o);if(s?(s.doc||(s.doc=n),s.type||(s.type=t)):(s={stmt:`state`,id:o,descriptions:[],type:t,doc:n,note:i,classes:[],styles:[],textStyles:[]},this.states.set(o,s)),r)for(let e of Array.isArray(r)?r:[r])this.addDescription(o,e.trim());if(i&&(s.note=i),a)for(let e of a)this.setCssClass(o,e.trim())}getState(e){return this.states.get(e)}addLink(e,t,n){this.links.set(e,{url:t,tooltip:n})}addRelation(e,t,n=``){for(let n of[e,t])this.addState(n.id,n.type,n.doc,n.description,n.note,n.classes);this.relations.push({id1:e.id.trim(),id2:t.id.trim(),relationTitle:n})}addDescription(e,t){this.states.get(e)?.descriptions?.push(t.startsWith(`:`)?t.replace(`:`,``).trim():t)}getDividerId(){return`divider-id-${++this.dividerCount}`}addStyleClass(e,t=``){let n=this.classes.get(e);if(n||(n={id:e,styles:[],textStyles:[]},this.classes.set(e,n)),t)for(let e of t.split(`,`)){let t=e.replace(`;`,``).trim();e.includes(`color`)&&n.textStyles.push(t.replace(`fill`,`bgFill`).replace(`color`,`fill`)),n.styles.push(t)}}setCssClass(e,t){for(let n of this.named(e))n.classes?.push(t)}getDirection(){for(let e of this.rootDoc)if(typeof e!=`string`&&e.stmt===`dir`)return e.value;return`TB`}setDirection(e){for(let t of this.rootDoc)if(typeof t!=`string`&&t.stmt===`dir`){t.value=e;return}this.rootDoc.unshift({stmt:`dir`,value:e})}trimColon(e){return e.startsWith(`:`)?e.slice(1).trim():e.trim()}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,``)}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
1055
1055
|
`)}named(e){let t=[];for(let n of e.split(`,`)){let e=this.states.get(n);e||=(this.addState(n),this.states.get(n.trim())),e&&t.push(e)}return t}},GOt=/* @__PURE__ */ `$end.INVALID.NL.SD.DESCR.-->.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`.split(`.`),KOt=/direction/gi,qOt=/<<(?:fork|join|choice)>>|\[\[(?:fork|join|choice)\]\]/gi,JOt=/[\n\r\u2028\u2029]/g,YOt=/%%/g,XOt=/\{/g;function Q1(e,t){let n=0,r=-2;return i=>{if(r===-2||i<n||r!==-1&&i>r){e.lastIndex=i;let a=e.exec(t);r=a?a.index:-1,n=i}return r}}function ZOt(e){let t=e.length,n=[],r=[],i=[],a=[],o=0,s=0,c,l=Q1(KOt,e),u=Q1(qOt,e),d=Q1(JOt,e),f=Q1(YOt,e),p=Q1(XOt,e),m=-1,h=-1,g=[-1,-1,-1,-1],_=[0,0,0,0],v=-1,y=-1,b=[-1,-1,-1,-1,-1,-1],x=(t,a,o)=>{n.push(t),r.push(e.slice(a,o)),i.push(a),s=o},S=(e,t,a,o)=>{n.push(e),r.push(t),i.push(a),s=o},C=e=>{a.push(o),o=e},w=()=>{a.length>0&&(o=a.pop())},T=(t,n)=>{for(let r=0;r<t.length;r++){let i=t.charCodeAt(r),a=e.charCodeAt(n+r);if(a!==i&&!(i>=97&&i<=122&&a===i-32))return!1}return!0},E=n=>{let r=n;for(;r<t&&eq(e.charCodeAt(r));)r++;return r},D=n=>{let r=n;for(;r<t&&aq(e.charCodeAt(r));)r++;return r},O=n=>{let r=e.indexOf(`
|
|
1056
1056
|
`,n);return r===-1?t:r},k=e=>{let n=d(e);return n===-1?t:n},A=e=>{if(e<m||e>h){let n=l(e),r=n===-1?t:k(e);m=e,h=r,g[0]=g[1]=g[2]=g[3]=-1;for(let e=n;e!==-1&&e<r;e=l(e+1)){let t=E(e+9);if(t===e+9)continue;let n=T(`tb`,t)?0:T(`bt`,t)?1:T(`rl`,t)?2:T(`lr`,t)?3:-1;n!==-1&&(g[n]=e,_[n]=t+2)}}for(let t=0;t<4;t++)if(g[t]>=e)return t;return-1},j=n=>{if(n<v||n>y){let r=u(n),i=r===-1?t:k(n);v=n,y=i,b.fill(-1);for(let t=r;t!==-1&&t<i;t=u(t+1)){let n=e.charCodeAt(t+2)|32;b[(e.charCodeAt(t)===60?0:3)+(n===102?0:n===106?1:2)]=t}}for(let e=0;e<6;e++)if(b[e]>=n)return e;return-1},M=(e,t)=>{let n=f(e);return n===-1||n+2>t?(x(14,e,t),!0):n===e?(s=t,!1):(x(14,e,n),!0)},N=e=>(n.push(e),r.push(``),i.push(s),{types:n,texts:r,starts:i,error:c});for(;;){if(s>=t){switch(o){case 0:x(2,t,t);break;case 6:x(22,t,t);break;case 7:x(24,t,t);break;case 8:x(25,t,t);break;case 10:x(32,t,t);break;case 12:x(39,t,t);break;case 14:x(36,t,t);break;case 3:x(12,t,t);break;case 18:x(20,t,t);break;case 4:case 19:x(14,t,t)}return N(0)}let n=e.charCodeAt(s);switch(o){case 0:case 1:{let r=o===0,i=n|32;if(r){if(i===99&&T(`click`,s)&&!aq(e.charCodeAt(s+5))){x(26,s,s+5);continue}if(i===104&&T(`href`,s)&&!aq(e.charCodeAt(s+4))){x(28,s,s+4);continue}if(n===34){let t=e.indexOf(`"`,s+1);if(t!==-1){x(27,s,t+1);continue}}if(i===100&&T(`default`,s)&&!aq(e.charCodeAt(s+7))){x(33,s,s+7);continue}let t=A(s);if(t!==-1){x(40+t,s,O(_[t]));continue}if(n===10){let t=s+1;for(;e.charCodeAt(t)===10;)t++;x(2,s,t);continue}if(eq(n)){s=E(s);continue}}else if(n!==10&&eq(n)){let n=s+1;for(;n<t&&e.charCodeAt(n)!==10&&eq(e.charCodeAt(n));)n++;s=n;continue}if(n===35||n===37&&e.charCodeAt(s+1)===37&&e.charCodeAt(s+2)!==123){s=O(s);continue}if(i===115){if(r&&T(`scale`,s)){let e=E(s+5);if(e>s+5){x(7,s,e),C(5);continue}}if(T(`style`,s)){let e=E(s+5);if(e>s+5){x(34,s,e),C(13);continue}}if(T(`state`,s)){let e=E(s+5);if(e>s+5){s=e,C(2);continue}if(r&&T(`diagram`,s+5)){let t=T(`-v2`,s+12)?s+15:s+12;if(e=E(t),e>t){x(3,s,e);continue}}}}else if(i===99){if(T(`class`,s)){let e=T(`def`,s+5),t=e?s+8:s+5,n=E(t);if(n>t){x(e?29:37,s,n),C(e?9:11);continue}}}else if(i===97&&r&&(T(`acctitle`,s)||T(`accdescr`,s))){let t=(e.charCodeAt(s+3)|32)==116,n=E(s+8),r=e.charCodeAt(n);if(r===58){x(t?21:23,s,E(n+1)),C(t?6:7);continue}if(r===123&&!t){s=E(n+1),C(8);continue}}if(r){if(n===123){x(10,s,s+1),C(1);continue}}else{let e=A(s);if(e!==-1){x(40+e,s,O(_[e]));continue}if(n===125){x(11,s,s+1),w();continue}if(n===10){s++;continue}}if(i===110&&T(`note`,s)){let e=E(s+4);if(e>s+4){x(19,s,e),C(15);continue}}if(r&&i===104&&T(`hide empty description`,s)&&!aq(e.charCodeAt(s+22))){x(6,s,s+22);continue}if(n===91&&e.charCodeAt(s+1)===42&&e.charCodeAt(s+2)===93){x(44,s,s+3);continue}let a=s;for(;a<t;){let t=e.charCodeAt(a);if(t===58||t===45||t===123||eq(t))break;a++}if(a>s){M(s,a);continue}if(n===58){for(a=s+1;a<t;){let n=e.charCodeAt(a);if(n===10||n===59)break;if(n===58){let n=e.charCodeAt(a+1);if(a+1>=t||n===58||n===10||n===59)break;a++}a++}if(a>s+1){S(4,e.slice(s,a).trim(),s,a);continue}if(e.charCodeAt(s+1)===58&&e.charCodeAt(s+2)===58){x(45,s,s+3);continue}}else if(n===45&&e.charCodeAt(s+1)===45){if(e.charCodeAt(s+2)===62){x(5,s,s+3);continue}if(!r){x(18,s,s+2);continue}}if(!r)return N(1);x(48,s,s+1);continue}case 2:{if(n!==10&&eq(n)){let n=s+1;for(;n<t&&e.charCodeAt(n)!==10&&eq(e.charCodeAt(n));)n++;s=n;continue}if(n===35||n===37&&e.charCodeAt(s+1)===37&&e.charCodeAt(s+2)!==123){s=O(s);continue}let r=j(s);if(r!==-1){let t=b[r],n=r===2||r===5;S(n?17:r%3==0?15:16,e.slice(s,t).trim(),s,t+(n?10:8)),w();continue}if(n===34){s++,C(3);continue}let i=n===10?E(s):s;if(T(`as`,i)){let e=E(i+2);if(e>i+2){x(13,s,e),C(4);continue}}if(n===10){s++,w();continue}if(n===123){x(10,s,s+1),w(),C(1);continue}if(aq(n)){let t=D(s),n=E(t);if(n>t&&aq(e.charCodeAt(n))){let t=p(n+1);if(t!==-1&&t<k(n))return c=`Error: State name must be a single word. Found: "${e.slice(s,t+1).trim()}"`,N(1)}}let a=s+1;for(;a<t;){let t=e.charCodeAt(a);if(t===123||eq(t))break;a++}x(9,s,a);continue}case 3:{if(n===34){s++,w();continue}let r=e.indexOf(`"`,s);x(12,s,r===-1?t:r);continue}case 4:{let n=s;for(;n<t;){let t=e.charCodeAt(n);if(t===10||t===123)break;n++}M(s,n)&&w();continue}case 5:{if(n>=48&&n<=57){let n=s+1;for(;n<t&&e.charCodeAt(n)>=48&&e.charCodeAt(n)<=57;)n++;x(8,s,n);continue}let r=E(s);if(r>s&&T(`width`,r)&&!aq(e.charCodeAt(r+5))){s=r+5,w();continue}return N(1)}case 6:x(22,s,O(s)),w();continue;case 7:x(24,s,O(s)),w();continue;case 8:{if(n===125){s++,w();continue}let r=e.indexOf(`}`,s);x(25,s,r===-1?t:r);continue}case 9:{let e=T(`default`,s)&&E(s+7)>s+7,t=e?s+7:D(s),n=E(t);if(t===s||n===t)return N(1);x(e?31:30,s,n),w(),C(10);continue}case 10:x(32,s,O(s)),w();continue;case 11:{let t=D(s);if(t===s)return N(1);for(;e.charCodeAt(t)===44;){let e=E(t+1),n=D(e);if(n===e)break;t=n}x(38,s,t),w(),C(12);continue}case 12:x(39,s,O(s)),w();continue;case 13:{let n=s;for(;n<t&&(aq(e.charCodeAt(n))||e.charCodeAt(n)===44);)n++;let r=E(n);if(n===s||r===n)return N(1);x(35,s,r),w(),C(14);continue}case 14:x(36,s,O(s)),w();continue;case 15:if(T(`left of`,s)&&!aq(e.charCodeAt(s+7))){x(46,s,s+7),w(),C(16);continue}if(T(`right of`,s)&&!aq(e.charCodeAt(s+8))){x(47,s,s+8),w(),C(16);continue}if(n===34){s++,w(),C(18);continue}return N(1);case 16:{let n=E(s),r=n;for(;r<t;){let t=e.charCodeAt(r);if(t===58||t===45||eq(t))break;r++}if(r===n)return N(1);M(s,r)&&(w(),C(17));continue}case 17:{let n=E(s);if(e.charCodeAt(n)===58){let r=n+1;for(;r<t;){let t=e.charCodeAt(r);if(t===58||t===10||t===59)break;r++}if(r>n+1){S(20,e.slice(s+2,r).trim(),s,r),w();continue}}let r=e.indexOf(`
|
|
1057
1057
|
`,s),i=-1;for(;r!==-1&&(i=E(r),!T(`end note`,i)||aq(e.charCodeAt(i+8)));)r=e.indexOf(`
|
|
1058
|
-
`,i);if(r===-1)return N(1);S(20,e.slice(s,i).trim(),s,i+8),w();continue}case 18:{let r=E(s);if(T(`as`,r)){x(13,s,E(r+2)),w(),C(19);continue}if(n===34){s++;continue}let i=e.indexOf(`"`,s);x(20,s,i===-1?t:i);continue}case 19:M(s,O(s))&&w();continue}}}var QOt=[`TB`,`BT`,`RL`,`LR`],$1=`'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'`;function $Ot(e,t){let{types:n,texts:r,starts:i,error:a}=ZOt(e),o=0,s=t=>{let r=n[o];throw r===1?a===void 0?FK(`state`,e,i[o],``,!0):new NK(a,`syntax`,{type:`state`,...PK(e,i[o])}):FK(`state`,e,i[o],`Expecting ${t}, got '${GOt[r]}'`)},c=e=>(n[o]!==e&&s(`'${GOt[e]}'`),r[o++]),l=()=>{let e=n[o];e!==14&&e!==44&&s(`'ID', 'EDGE_STATE'`);let t=r[o++].trim();return n[o]===45?(o++,{stmt:`state`,id:t,classes:[c(14).trim()],type:`default`,description:``}):{stmt:`state`,id:t,type:`default`,description:``}};for(;n[o]===2;)o++;n[o]!==3&&s(`'NL', 'SD'`),o++;let u=[],d=[],f=e=>{e!==`nl`&&u.push(e)},p=(e,t)=>{o++;let n=[];u.push({stmt:`state`,id:e,type:`default`,description:t,doc:n}),d.push(u),u=n};for(;;){let e=n[o];switch(e){case 2:o++;break;case 14:case 44:{let e=l();if(n[o]===4)e.description=t.trimColon(r[o++]),f(e);else if(n[o]===5){o++;let i=l();n[o]===4?f({stmt:`relation`,state1:e,state2:i,description:t.trimColon(r[o++])}):f({stmt:`relation`,state1:e,state2:i})}else f(e);break}case 6:f(r[o++]);break;case 7:o++,c(8),f(r[o-2]);break;case 9:n[o+1]===10?p(r[o++],``):f(r[o++]);break;case 12:{let e=r[o++];c(13);let t=c(14);if(n[o]===10)p(t,e);else if(t.includes(`:`)){let n=t.split(`:`);f({stmt:`state`,id:n[0],type:`default`,description:[e.trim(),n[1]]})}else f({stmt:`state`,id:t,type:`default`,description:e.trim()});break}case 15:f({stmt:`state`,id:r[o++],type:`fork`});break;case 16:f({stmt:`state`,id:r[o++],type:`join`});break;case 17:f({stmt:`state`,id:r[o++],type:`choice`});break;case 18:o++,f({stmt:`state`,id:t.getDividerId(),type:`divider`});break;case 19:{let e=r[o++];if(n[o]===46||n[o]===47){let e=r[o++].trim();f({stmt:`state`,id:c(14).trim(),note:{position:e,text:c(20).trim()}})}else n[o]!==20&&s(`'NOTE_TEXT', 'left_of', 'right_of'`),o++,c(13),c(14),f(e);break}case 40:case 41:case 42:case 43:{let n=QOt[e-40];o++,t.setDirection(n),f({stmt:`dir`,value:n});break}case 21:{o++;let e=c(22).trim();t.setAccTitle(e),f(e);break}case 23:{o++;let e=c(24).trim();t.setAccDescription(e),f(e);break}case 25:{let e=r[o++].trim();t.setAccDescription(e),f(e);break}case 26:{o++;let e=l(),t,i=``;n[o]===28?(o++,t=c(27)):(n[o]!==27&&s(`'STRING', 'HREF'`),t=r[o++],i=c(27)),c(2),f({stmt:`click`,id:e,url:t,tooltip:i});break}case 29:o++,f({stmt:`classDef`,id:c(30).trim(),classes:c(32).trim()});break;case 34:o++,f({stmt:`style`,id:c(35).trim(),styleClass:c(36).trim()});break;case 37:o++,f({stmt:`applyClass`,id:c(38).trim(),styleClass:c(39).trim()});break;case 11:d.length===0&&s(`'$end', ${$1}`),o++,u=d.pop();break;case 0:return d.length>0&&s(`'STRUCT_STOP', ${$1}`),t.setRootDoc(u),u;default:s(d.length>0?`'STRUCT_STOP', ${$1}`:`'$end', ${$1}`)}}}var ekt=40,tkt=16,nkt=44,e0=16,t0=10,rkt=16,ikt=10,n0=26,akt=8,okt=320,r0=10,skt=8,ckt=` fill="var(--_s)" stroke="var(--_b)"`,i0=` fill="none" stroke="var(--_b)"`,lkt=/(?:^| )statediagram-(?:state|cluster-alt|cluster|note)(?= |$)/g,ukt=/* @__PURE__ */ new Map([[`rectWithTitle`,1],[`stateStart`,2],[`stateEnd`,3],[`choice`,4],[`fork`,5],[`join`,6],[`note`,7],[`divider`,10]]),dkt=[`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 fkt(e){return e===`TB`||e===`BT`}function a0(e,t,n){let r=e.state?.[t];return typeof r==`number`&&r>0?Math.min(r,2e3):n}function pkt(e){let t=0,n=e.length;for(;t<n&&e.charCodeAt(t)===34;)t++;for(;n>t&&e.charCodeAt(n-1)===34;)n--;return e.slice(t,n)}function mkt(e,t,n){return e<t?t:e>n?n:e}function o0(e,t,n,r,i){return`<rect x="${K(e)}" y="${K(t)}" width="${K(n)}" height="${K(r)}"${i}/>`}function s0(e,t,n,r){let i=Qq(0,0);return i.isGroup=!0,i.dir=e,i.padX=t,i.padTop=n,i.padBottom=r,i}function hkt(e,t,n){return YJ(e.direction)?JJ(n,r=>gkt(e,t,n,r)):gkt(e,t,n,!1)}function gkt(e,t,n,r){let i=e.graph,a=n.fontSize??16,o=Math.round(a*.875),s=n.measurer??fq(n.fontFamily),c=a0(t,`wrappingWidth`,200),l=n.padding??8,u=n.icons,d=r?`TB`:Xq(e.direction),f=WJ(void 0,!1,s,a,0),p=(e,t,n,r=0)=>WJ(e,!0,s,t,n,r),m=/* @__PURE__ */ new Map,h=[],g=[],_=(e,t,n)=>(h.push({node:e,kind:t,style:void 0,label:f,lines:[],w:0,h:0,titleH:0}),n&&g.push(n),h.length-1);for(let e of i.nodes){if(e.shape===`noteGroup`)continue;let t=e.isGroup?e.shape===`divider`?9:8:ukt.get(e.shape)??0;m.set(e.id,_(e,t,void 0))}let v=h.length,y=[];for(let e=0;e<v;e++){let t=h[e].node.parentId,n=t===void 0?void 0:m.get(t);y.push(n!==void 0&&n!==e&&h[n].node.isGroup?n:-1)}{let e=[];for(let t=0;t<v;t++)e.push([]);let t=[],n=new Uint8Array(v);for(let r=0;r<v;r++)y[r]===-1?(n[r]=1,t.push(r)):e[y[r]].push(r);let r=0,i=()=>{for(;r<t.length;r++)for(let i of e[t[r]])n[i]||(n[i]=1,t.push(i))};i();let a=new Int32Array(v).fill(-1);for(let e=0;e<v;e++){if(n[e])continue;let r=e;for(;a[r]!==e;)a[r]=e,r=y[r];y[r]=-1,n[r]=1,t.push(r),i()}}let b=new Int32Array(v).fill(-1);for(let e=0;e<v;e++){let t=h[e].node.noteFor,n=t===void 0?void 0:m.get(t);n!==void 0&&(b[e]=n,y[e]=y[n])}let x=e=>Xq(h[e].node.dir),S=e=>fkt(y[e]===-1?d:x(y[e])),C=new Int32Array(v),w=new Uint8Array(v),T=Array(v).fill(1/0),E=0,D=new Int32Array(2*v);for(let e of i.edges){let t=m.get(e.start),n=m.get(e.end);if(t!==void 0&&n!==void 0){if(e.pattern===`dashed`){w[h[t].kind===7?n:t]=1;continue}C[t]=Math.max(C[t],++D[2*t]),C[n]=Math.max(C[n],++D[2*n+1]),T[t]===1/0&&(T[t]=E++),T[n]===1/0&&(T[n]=E++)}}for(let e=0;e<v;e++){let t=h[e],n=t.node,r=mJ(n.cssStyles.length>0?n.cssCompiledStyles.concat(n.cssStyles):n.cssCompiledStyles),i=+!!r.bold|(r.italic?2:0),s=r.fontSize??a;t.style=r;let l;switch(t.kind){case 8:t.label=p(n.label,s,4e3,i),t.titleH=t.label.height>0?t.label.height+12:0,l=s0(x(e),e0,t.titleH+e0,e0),l.minW=t.label.width+2*e0;break;case 9:l=s0(x(e),t0,t0,t0);break;case 2:t.w=t.h=14;break;case 3:t.w=t.h=18;break;case 4:t.w=t.h=30;break;case 5:case 6:{let n=mkt(40*C[e]+16,72,320);t.w=S(e)?n:skt,t.h=S(e)?skt:n;break}case 10:break;case 7:t.label=p(n.label,o,Math.max(c,okt)),t.w=t.label.width+24,t.h=t.label.height+16;break;default:{t.label=p(n.label,s,c,i);let e=t.label.width,r=t.label.height+2*ikt;if(t.kind===1){r+=14;for(let a of n.description){let n=p(a===``?` `:a,o,c,i);t.lines.push(n),n.width>e&&(e=n.width),r+=n.height}}t.w=Math.max(e+2*rkt,56),t.h=r}}l??=Qq(t.w,t.h),(t.kind===0||t.kind===1)&&(l.span=(S(e)?t.w:t.h)-24),g.push(l)}let O=[],k=[],A=[],j=new Int32Array(v),M=new Float64Array(v),N=new Float64Array(v),P=/* @__PURE__ */ new Map,F=(e,t)=>{if(!g[e].isGroup)return!1;for(let n=y[t];n!==-1;n=y[n])if(n===e)return!0;return!1},ee=(e,t)=>(P.set(O.length,e),T.push(t?-1:1/0),_(void 0,10,Qq(0,0,e)));for(let e of i.edges){let t=m.get(e.start),n=m.get(e.end);if(t===void 0||n===void 0)continue;let r=p(e.label,o,c),i=r.width>0?r.width+12:0;t===n?(j[t]++,M[t]=Math.max(M[t],i),N[t]+=r.height):F(t,n)?t=ee(t,!0):F(n,t)&&(n=ee(n,!1)),A.push(e),k.push(r),O.push({src:t,dst:n,minlen:1,labelW:i,labelH:r.height>0?r.height+4:0,route:[],labelX:0,labelY:0})}for(let e=0;e<v;e++){if(b[e]!==-1)continue;let t=g[e],n=0;if(j[e]>0){let r=n0+(j[e]-1)*8;n=S(e)?r+M[e]:r*.75+4+N[e],t.isGroup||(S(e)?(t.w+=2*n,t.h=Math.max(t.h,N[e])):(t.h+=2*n,t.w=Math.max(t.w,M[e])),n=0)}if(!w[e]&&n===0){t.parent=y[e];continue}let r=S(e)?s0(`LR`,n,0,0):s0(`TB`,0,n,n);r.parent=y[e],T.push(T[e]),g[e].parent=_(void 0,10,r)}for(let e=0;e<v;e++)b[e]!==-1&&(g[e].parent=g[b[e]].parent);{let e=[];for(let t=0;t<g.length;t++)e.push([]);let t=[];for(let n=0;n<g.length;n++){let r=g[n].parent;r>=0?e[r].push(n):t.push(n)}let n=e=>h[e].kind===2?0:1,r=(e,t)=>n(e)-n(t)||(T[e]===T[t]?0:T[e]<T[t]?-1:1)||e-t,i=0,a=t.sort(r).reverse();for(;a.length>0;){let t=a.pop();g[t].seq=i++;let n=e[t].sort(r);for(let e=n.length-1;e>=0;e--)a.push(n[e])}}let te=eJ(g,O,d,{nodeSep:a0(t,`nodeSpacing`,ekt),edgeSep:tkt,rankSep:a0(t,`rankSpacing`,nkt),portSep:20,headRoom:sJ(`arrow_point`)}),I=Math.ceil(te.width+2*l),ne=Math.ceil(te.height+2*l),re=[],ie=/* @__PURE__ */ new Map;for(let e of O){let t=e.route;for(let e=3;e<t.length-3;e+=3){let n=Math.round(t[e+1]),r=ie.get(n);r?r.push(t[e]):ie.set(n,[t[e]])}}let ae=[];for(let e=0;e<g.length;e++)ae.push([]);let L=[];for(let e=0;e<g.length;e++){let t=g[e].parent;t>=0?ae[t].push(e):L.push(e)}let oe=L.slice();for(let e=0;e<L.length;e++)for(let t of ae[L[e]])L.push(t);let se=``,ce=``,le=``,ue=``,de=(e,t,n,r,i)=>{let a=e.filter(e=>h[e].kind===9);if(a.length<2)return;let o=(e,t)=>t?g[e].x-g[e].w/2:g[e].y-g[e].h/2,s=(e,t)=>t?g[e].x+g[e].w/2:g[e].y+g[e].h/2;for(let e of[!0,!1]){let c=a.slice().sort((t,n)=>o(t,e)-o(n,e)||t-n),u=!0;for(let t=1;t<c.length;t++)s(c[t-1],e)>o(c[t],e)+.5&&(u=!1);if(u){for(let a=1;a<c.length;a++){let u=K((s(c[a-1],e)+o(c[a],e))/2+l);ce+=`<path class="pele-divider" d="M${e?`${u},${K(n)}V${K(i)}`:`${K(t)},${u}H${K(r)}`}"/>`}return}}for(let e of a){let t=g[e];ce+=o0(t.x-t.w/2+l,t.y-t.h/2+l,t.w,t.h,` class="pele-divider" rx="${r0}"`)}};de(oe,l/2,l/2,I-l/2,ne-l/2);for(let t of L){let r=h[t],i=r.node,a=r.style;if(i===void 0||a===void 0||r.kind>=9)continue;let s=g[t],c=s.x+l,d=s.y+l,f=r.w,p=r.h,m=` class="pele-label"${a.text}`,_;switch(r.kind){case 8:{let e=c-s.w/2,n=d-s.h/2;_=o0(e,n,s.w,s.h,` rx="${r0}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${a.shape}`),r.titleH>0&&(_+=`<path d="M${K(e)},${K(n+r.titleH)}H${K(e+s.w)}"${i0}${a.line}/>`+gq(r.label,_kt(s,r.label.width,ie)+l,n+r.titleH/2,` class="pele-cluster-label"${a.text}`,u)),de(ae[t],e,n+r.titleH,e+s.w,n+s.h);break}case 2:_=`<circle r="7" fill="var(--_l)"${a.shape}/>`;break;case 3:_=`<circle r="8.5" fill="var(--_bg)" stroke="var(--_l)"${a.line}/><circle r="5" fill="var(--_l)"${a.shape}/>`;break;case 4:_=`<polygon points="0,${K(-p/2)} ${K(f/2)},0 0,${K(p/2)} ${K(-f/2)},0"${ckt}${a.shape}/>`;break;case 5:case 6:_=o0(-f/2,-p/2,f,p,` rx="2" fill="var(--_l)"${a.shape}`);break;case 7:{let e=K(f/2),t=K(p/2),n=K(f/2-akt),i=K(akt-p/2);_=`<path d="M-${e},-${t}H${n}L${e},${i}V${t}H-${e}Z" fill="var(--_bg)" stroke="var(--_b)"/><path d="M${n},-${t}V${i}H${e}"${i0}/>`+gq(r.label,0,0,` class="pele-label" font-size="${o}" fill="var(--_m)"`,u);break}default:{if(_=o0(-f/2,-p/2,f,p,` rx="${K(Math.min(r0,p/2))}"${ckt}${a.shape}`),r.kind===0){_+=gq(r.label,0,0,m,u);break}let e=ikt-p/2+r.label.height;_+=`<path d="M${K(-f/2)},${K(e+6)}H${K(f/2)}"${i0}${a.line}/>`+gq(r.label,0,e-r.label.height/2,m,u),e+=14;for(let t of r.lines)_+=gq(t,0,e+t.height/2,` class="pele-state-description" font-size="${o}"${a.text}`,u),e+=t.height}}let v=e.links.get(i.id);if(v){let e=RK(pkt(v.tooltip));e&&(_=`<title>${pq(e)}</title>`+_),_=Tq(_,Cq(pkt(v.url)),i.id,re,n,` target="_blank"`)}let y=`<g class="${dkt[r.kind]}${hJ(i.cssClasses.replace(lkt,``))}" data-id="${mq(i.id)}"`;r.kind===8?se+=`${y}>${_}</g>`:r.kind===7?ue+=`${y} transform="translate(${K(c)},${K(d)})">${_}</g>`:le+=`${y} transform="translate(${K(c)},${K(d)})">${_}</g>`}let fe=(e,t,n)=>{let r=g[n];if(r.isGroup)return;let i=h[n],a=i.kind===5||i.kind===6,o=t===0?3:t-3;for(let n of[1,0]){let s=n?r.h:r.w,c=n?i.h:i.w,u=n?i.w:i.h,d=(n?r.y:r.x)+l,f=(n?r.x:r.y)+l,p=e[t+n]-d;if(!(Math.abs(Math.abs(p)-s/2)>=.5)){e[t+n]-=Math.sign(p)*(s-c)/2,a&&u>c&&(e[t+1-n]=mkt(e[o+1-n],f-u/2+6,f+u/2-6));return}}},pe=yht();for(let e=0;e<O.length;e++){let t=O[e];t.src===t.dst||t.route.length<6||A[e].pattern===`dashed`||pe.add(t.dst,BJ(t.route,t.route.length-3,g[t.dst]),`arrow_point`)}let me=``,he=``,ge=new Int32Array(v),_e=new Float64Array(v);for(let e=0;e<O.length;e++){let t=O[e],n=A[e],r=k[e],i=n.pattern===`dashed`,a=i?`none`:`arrow_point`,o;if(t.src===t.dst){let e=g[t.src],n=h[t.src],i=ge[t.src]++,s=S(t.src),c=e.isGroup?e.w:n.w,u=e.isGroup?e.h:n.h,d=(s?c:u)/2,f=Math.max(Math.min((s?u:c)/2-4,8+i*6),2),p=n0+i*8,m=sJ(a)/(Math.hypot(p,f)||1),_=(t,n)=>e.x+l+(s?d+t:-n),v=(t,n)=>e.y+l+(s?n:d+t),y=(e,t)=>`${K(_(e,t))},${K(v(e,t))}`;o={d:`M${y(0,-f)}C${y(p,-2*f)} ${y(p,2*f)} ${y(p*m,f+f*m)}`,sx:0,sy:0,sdx:0,sdy:0,ex:_(0,f),ey:v(0,f),edx:_(-p,-f)-_(0,0),edy:v(-p,-f)-v(0,0)};let b=Math.hypot(o.edx,o.edy)||1;o.edx/=b,o.edy/=b;let x=n0+(j[t.src]-1)*8,C=_e[t.src]+r.height/2;_e[t.src]+=r.height,t.labelX=s?e.x+d+x+4+t.labelW/2:e.x,t.labelY=s?e.y-N[t.src]/2+C:e.y+d+x*.75+4+C}else{let n=t.route.slice(),r=pe.of(t.src,BJ(n,0,g[t.src])),i=pe.of(t.dst,BJ(n,n.length-3,g[t.dst]));for(let e=0;e<n.length;e+=3)n[e]+=l,n[e+1]+=l;fe(n,0,t.src),fe(n,n.length-3,t.dst);let s=P.get(e);if(s!==void 0&&n.length>=6){let e=g[s],r=h[t.src].kind===10,i=r?0:n.length-3,a=(e.dir===`TB`||e.dir===`LR`)===r,o=fkt(e.dir)?[n[i],e.y+l+(a?h[s].titleH-e.h/2:e.h/2),0]:[e.x+l+(a?-e.w/2:e.w/2),n[i+1],1];n=r?o.concat(n):n.concat(o)}o=oJ(n,void 0,0,sJ(a),r,i)}if(me+=`<g class="pele-edge ${i?`pele-note-edge" stroke="var(--_b)" stroke-dasharray="3 4`:`pele-transition`}" data-id="${mq(n.id)}"><path d="${o.d}"/>`+cJ(a,o.ex,o.ey,o.edx,o.edy,`var(--_l)`)+`</g>`,r.width>0){let e=t.labelX+l,i=t.labelY+l;he+=lJ(n.id,r,e,i,``,u)}}let ve=Kvt(e.title,s,a,l,I,ne,(se?`<g class="pele-clusters">${se}</g>`:``)+(ce?`<g class="pele-dividers" stroke-dasharray="4 4"${i0}>${ce}</g>`:``)+(me?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${me}</g>`:``)+(he?`<g class="pele-edge-labels" font-size="${o}">${he}</g>`:``)+`<g class="pele-nodes">${le}${ue}</g>`);return{svg:vJ(`state`,ve.width,ve.height,a,n,e,ve.content),width:ve.width,height:ve.height,links:re}}function _kt(e,t,n){let r=n.get(Math.round(e.y-e.h/2));if(r===void 0||t===0)return e.x;let i=e.x-e.w/2,a=t/2,o=e.x,s=-1;for(let t of[e.x,i+e0+a,i+e.w-e0-a]){let n=1/0;for(let o of r)o>i&&o<i+e.w&&(n=Math.min(n,Math.abs(o-t)-a));if(n>=6)return t;n>s+.5&&(s=n,o=t)}return o}var vkt={type:`state`,parse(e,t,n){let r=new WOt;return n&&(r.title=n),$Ot(e,r),r},render:hkt},ykt=34,bkt=24,xkt=8,Skt=2e4,Ckt=1e4,c0=2e6,wkt=4,Tkt=3,Ekt=8,l0=20,Dkt=20,Okt=14,kkt=3;function Akt(e,t,n,r,i=bkt){let a=e.length;if(a===0)return{width:0,height:0};let o=n===`LR`||n===`RL`,s=n===`BT`||n===`RL`,c=[];for(let t=a-1;t>=0;t--)e[t].parent<0&&e[t].isGroup&&c.push(t);let l=Math.max(1,c.length),u=new Int32Array(a).fill(-1);c.forEach((e,t)=>u[e]=t);let d=new Uint8Array(a);for(let t=0;t<a;t++)e[t].parent>=0&&(d[e[t].parent]=1);let f=new Float64Array(l).fill(i),p=i,m=t=>{let n=t,r=i;for(let t=0;e[n].parent>=0&&t<Ckt;t++)n=e[n].parent,u[n]<0&&(r+=Math.max(e[n].padX,e[n].padTop,e[n].padBottom));let a=Math.max(0,u[n]);return r>f[a]&&(f[a]=r),r>p&&(p=r),a},h=new Int32Array(a).fill(-1),g=[];for(let t=0;t<a;t++)u[t]>=0||e[t].isGroup&&d[t]||(h[t]=g.length,g.push(t));let _=e=>o?e.w:e.h,v=e=>o?e.h:e.w,y=g.map(t=>Hq(v(e[t]),_(e[t]))),b=[],x=[],S=1;{let e=/* @__PURE__ */ new Set;for(let n=0;n<t.length;n++){let r=t[n],i=h[r.src],a=h[r.dst];if(i<0||a<0||i===a)continue;let s=Math.min(i,a)*g.length+Math.max(i,a);(r.labelW>0||e.has(s))&&(S=2),e.add(s),b.push(Uq(i,a,r.minlen,o?r.labelH:r.labelW,o?r.labelW:r.labelH)),x.push(n)}}qq(y,b),Jq(y,b,S);let C=b.length,w=Int32Array.from(g,m),T=(n,i)=>{let d=f.map((e,t)=>i[t]?Math.max(e,Dkt):e),m=new Uint8Array(l),_=0,v=new Int32Array(C);for(let e=0;e<C;e++)v[e]=Math.abs(y[b[e].head].rank-y[b[e].tail].rank),n[e]||(_+=v[e]-1);let T=_>Skt,E=g.length+(T?0:_),D=new Int32Array(E),O=new Int32Array(E),k=new Float64Array(E),A=new Float64Array(E),j=new Uint8Array(E),M=0;for(let e=0;e<g.length;e++)D[e]=y[e].rank,O[e]=w[e],k[e]=y[e].w,A[e]=y[e].h,D[e]>M&&(M=D[e]);let N=new Int32Array(C).fill(-1),P=new Int32Array(C).fill(-1),F=[];{let e=g.length;for(let t=0;t<C;t++){let r=b[t],i=r.reversed?r.head:r.tail,a=r.reversed?r.tail:r.head;if(T||v[t]<2||n[t]){F.push(i,a);continue}let o=D[i],s=D[a],c=-1;r.labelW>0&&(c=o+(s-o>>1),S===2&&!(c&1)&&c--),N[t]=e;let l=i;for(let n=o+1;n<s;n++){let u=e++;D[u]=n,O[u]=O[i]+Math.round((O[a]-O[i])*(n-o)/(s-o)),j[u]=1,n===c&&(k[u]=r.labelW,A[u]=r.labelH,P[t]=u),F.push(l,u),l=u}F.push(l,a)}}let ee=new Int32Array(E+1),te=new Int32Array(E+1);for(let e=0;e<F.length;e+=2)te[F[e]+1]++,ee[F[e+1]+1]++;for(let e=0;e<E;e++)ee[e+1]+=ee[e],te[e+1]+=te[e];let I=new Int32Array(F.length/2),ne=new Int32Array(F.length/2);{let e=ee.slice(0,E),t=te.slice(0,E);for(let n=0;n<F.length;n+=2)ne[t[F[n]]++]=F[n+1],I[e[F[n+1]]++]=F[n]}let re=[];for(let e=0;e<=M;e++)re.push([]);for(let e=0;e<E;e++)re[D[e]].push(e);let ie=new Float64Array(E),ae=new Float64Array(E),L=e=>{e.sort((e,t)=>O[e]-O[t]||ae[e]-ae[t]||e-t);for(let t=0;t<e.length;t++)ie[e[t]]=t};for(let e of re){for(let t=0;t<e.length;t++)ae[e[t]]=t;L(e)}for(let e=0;e<xkt&&M>0;e++){let t=!(e&1);for(let e=1;e<=M;e++){let n=re[t?e:M-e],r=t?ee:te,i=t?I:ne;for(let e of n){let t=0,n=r[e+1]-r[e];for(let n=r[e];n<r[e+1];n++)t+=ie[i[n]];ae[e]=n>0?t/n:ie[e]}L(n)}}let oe=(e,t)=>j[e]||j[t]?r.edgeSep:r.nodeSep,se=(e,t)=>{let n=0;for(;n<e.length;){let r=n;for(;r+1<e.length&&O[e[r+1]]===O[e[n]];)r++;t(e,n,r),n=r+1}},ce=(e,t,n)=>{let r=k[e[t]];for(let i=t;i<n;i++)r+=oe(e[i],e[i+1])+k[e[i+1]];return r},le=new Float64Array(l),ue=c.length>0?ykt:0;for(let t=0;t<c.length;t++){let n=e[c[t]];le[t]=Math.max(0,n.minW-2*d[t]),n.padTop>ue&&(ue=n.padTop)}for(let e of re)se(e,(t,n,r)=>{let i=ce(e,n,r);i>le[O[e[n]]]&&(le[O[e[n]]]=i)});let de=new Float64Array(l+1);for(let e=0;e<l;e++)de[e+1]=de[e]+le[e]+2*d[e];let fe=new Float64Array(E),pe=new Float64Array(E),me=(e,t,n)=>{let r=O[e[t]],i=(de[r]+d[r]+(de[r+1]-d[r])-ce(e,t,n))/2;for(let r=t;r<=n;r++)fe[e[r]]=i+k[e[r]]/2,r<n&&(i+=k[e[r]]+oe(e[r],e[r+1]))},he=(e,t,n)=>{let r=O[e[t]],i=de[r]+d[r];for(let r=t;r<=n;r++){let t=e[r];fe[t]=Math.max(pe[t],i+k[t]/2),r<n&&(i=fe[t]+k[t]/2+oe(t,e[r+1]))}let a=de[r+1]-d[r];for(let r=n;r>=t;r--){let n=e[r];fe[n]=Math.min(fe[n],a-k[n]/2),r>t&&(a=fe[n]-k[n]/2-oe(e[r-1],n))}};for(let e of re)se(e,me);for(let e=0;e<4&&M>0;e++){let t=!(e&1);for(let e=1;e<=M;e++){let n=re[t?e:M-e],r=t?ee:te,i=t?I:ne;for(let e of n){let t=0,n=0;for(let a=r[e];a<r[e+1];a++)O[i[a]]===O[e]&&(t+=fe[i[a]],n++);pe[e]=n>0?t/n:fe[e]}se(n,he)}}let ge=new Float64Array(M+1),_e=new Float64Array(M+1),ve=new Float64Array(M+1).fill(r.rankSep/S);if(n.some(e=>e===1)){let e=r.rankSep/S;ve.fill(e/kkt);for(let t=0;t<C;t++){let r=b[t],i=r.reversed?r.head:r.tail,a=r.reversed?r.tail:r.head;if(n[t]){if(r.labelH<=0||v[t]>S)continue;let n=Math.min(e,(r.labelH+2*l0-Math.min(A[i],A[a])/2)/v[t]);for(let e=D[i];e<D[a];e++)n>ve[e]&&(ve[e]=n);continue}let o=N[t];if(o<0||v[t]<=S*r.minlen)for(let t=D[i];t<D[a];t++)ve[t]=e;else for(let n=o-1;n<o+v[t]-1;n++){let r=n<o?i:n,s=n+1<o+v[t]-1?n+1:a;(O[r]!==O[s]||Math.abs(fe[r]-fe[s])>=.5)&&(ve[D[r]]=e)}}}let ye=ue+p;for(let e=0;e<=M;e++){let t=0;for(let n of re[e])A[n]>t&&(t=A[n]);ge[e]=ye,_e[e]=ye+t,ye+=t+(e===M?0:ve[e])}let be=ye+p,xe=de[l],Se=e=>s?ue+be-e:e,Ce=(e,t)=>o?Se(t):e,we=(e,t)=>o?e:Se(t),Te=+!!o;for(let t=0;t<g.length;t++){let n=e[g[t]],r=(ge[D[t]]+_e[D[t]])/2;n.x=Ce(fe[t],r),n.y=we(fe[t],r)}for(let t=0;t<c.length;t++){let n=e[c[t]],r=(de[t]+de[t+1])/2,i=de[t+1]-de[t];n.x=o?be/2:r,n.y=o?r:be/2,n.w=o?be:i,n.h=o?i:be,n.padTop=ue}let Ee=new Int32Array(a),De=[];for(let t=0;t<a;t++){if(!e[t].isGroup||u[t]>=0||h[t]>=0)continue;let n=0;for(let r=e[t].parent;r>=0&&n<Ckt;r=e[r].parent)n++;Ee[t]=n,De.push(t)}De.sort((e,t)=>Ee[t]-Ee[e]||e-t);let Oe=new Float64Array(a*4);for(let e=0;e<a;e++)Oe[e*4]=1/0,Oe[e*4+1]=1/0,Oe[e*4+2]=-1/0,Oe[e*4+3]=-1/0;let ke=(e,t)=>{t.x-t.w/2<Oe[e*4]&&(Oe[e*4]=t.x-t.w/2),t.y-t.h/2<Oe[e*4+1]&&(Oe[e*4+1]=t.y-t.h/2),t.x+t.w/2>Oe[e*4+2]&&(Oe[e*4+2]=t.x+t.w/2),t.y+t.h/2>Oe[e*4+3]&&(Oe[e*4+3]=t.y+t.h/2)};for(let t of g)e[t].parent>=0&&u[e[t].parent]<0&&ke(e[t].parent,e[t]);for(let t of De){let n=e[t];if(Oe[t*4]===1/0)continue;let r=Math.max(Oe[t*4+2]-Oe[t*4]+2*n.padX,n.minW);n.x=(Oe[t*4]+Oe[t*4+2])/2,n.w=r,n.y=(Oe[t*4+1]-n.padTop+Oe[t*4+3]+n.padBottom)/2,n.h=Oe[t*4+3]-Oe[t*4+1]+n.padTop+n.padBottom,n.parent>=0&&u[n.parent]<0&&ke(n.parent,n)}for(let e of t)e.route=[];for(let e=0;e<C;e++){let n=b[e],r=t[x[e]],i=n.reversed?n.head:n.tail,a=n.reversed?n.tail:n.head,o=[fe[i],_e[D[i]]-(_e[D[i]]-ge[D[i]]-A[i])/2],s=N[e];if(s>=0)for(let t=s;t<s+v[e]-1;t++)o.push(fe[t],ge[D[t]]),_e[D[t]]>ge[D[t]]&&o.push(fe[t],_e[D[t]]);o.push(fe[a],ge[D[a]]+(_e[D[a]]-ge[D[a]]-A[a])/2);let c=[];for(let e=0;e<o.length;e+=2)c.push(Ce(o[e],o[e+1]),we(o[e],o[e+1]),Te);if(n.reversed)for(let e=0,t=c.length-3;e<t;e+=3,t-=3)for(let n=0;n<2;n++){let r=c[e+n];c[e+n]=c[t+n],c[t+n]=r}r.route=c;let l=P[e];if(l>=0){let e=(ge[D[l]]+_e[D[l]])/2;r.labelX=Ce(fe[l],e),r.labelY=we(fe[l],e)}else r.labelX=(c[0]+c[c.length-3])/2,r.labelY=(c[1]+c[c.length-2])/2}for(let n of t){if(n.route.length>0||n.src===n.dst)continue;let t=e[n.src],r=e[n.dst],[i,a]=jkt(t,r),[o,s]=jkt(r,t),c=+(Math.abs(o-i)>Math.abs(s-a));n.route=[i,a,c,o,s,c],n.labelX=(i+o)/2,n.labelY=(a+s)/2}let Ae=new Uint8Array(C),je=t.reduce((e,t)=>e+t.route.length/3,0),Me=C*(g.length+t.length+je);if(Me<=c0){let e=e=>(ge[D[e]]+_e[D[e]])/2,n=t.map(e=>[o?e.labelY:e.labelX,Se(o?e.labelX:e.labelY)]),r=(e,t,n,r,i,a,o,s)=>n>i-o/2&&e<i+o/2&&r>a-s/2&&t<a+s/2,i=(i,a,s,c,l,u,d)=>{for(let t=0;t<g.length;t++)if(t!==l&&t!==u&&r(i,a,s,c,fe[t],e(t),k[t]+8,A[t]+8))return!1;for(let e=0;e<t.length;e++){let l=t[e];if(e!==d&&l.labelW>0&&l.src!==l.dst&&r(i,a,s,c,n[e][0],n[e][1],o?l.labelH:l.labelW,o?l.labelW:l.labelH))return!1}return!0},a=(e,n,r,i,a)=>{let o=0;for(let s=0;s<t.length;s++){if(s===a)continue;let c=t[s].route;for(let t=3;t<c.length;t+=3)if(Math.max(c[t-3],c[t])>e&&Math.min(c[t-3],c[t])<r&&Math.max(c[t-2],c[t+1])>n&&Math.min(c[t-2],c[t+1])<i){o++;break}}return o},s=(e,n,r)=>{let i=0;for(let a=0;a<t.length;a++){let o=t[a].route;if(a===r||o.length===0)continue;let s=o.length-3;(Math.abs(o[0]-e)<1&&Math.abs(o[1]-n)<1||Math.abs(o[s]-e)<1&&Math.abs(o[s+1]-n)<1)&&i++}return i},c=(e,n,r,i,a)=>{let o=Math.abs(r-e)<.5,s=o?Math.min(n,i):Math.min(e,r),c=o?Math.max(n,i):Math.max(e,r),l=o?e:n;for(let e=0;e<t.length;e++){let n=t[e];if(e===a||n.src===t[a].src||n.dst===t[a].dst)continue;let r=n.route;for(let e=3;e<r.length;e+=3){let t=r[e-3+ +!o],n=r[e+ +!o];if(Math.abs(t-l)>=wkt||Math.abs(n-l)>=wkt)continue;let i=r[e-3+ +!!o],a=r[e+ +!!o];if(Math.min(c,Math.max(i,a))-Math.max(s,Math.min(i,a))>1)return!0}}return!1};for(let r=0;r<C;r++){let o=b[r],l=x[r],u=t[l],f=o.tail,p=o.head;if(O[f]===O[p]||Math.abs(fe[p]-fe[f])<1)continue;let h=fe[f],g=fe[p],_=e(f),v=e(p),y=Math.sign(g-h),S=Math.sign(v-_),C=(e,t)=>{for(let n=2;n<e.length;n+=2)if(!i(Math.min(e[n-2],e[n])-t,Math.min(e[n-1],e[n+1])-t,Math.max(e[n-2],e[n])+t,Math.max(e[n-1],e[n+1])+t,f,p,l)||c(Ce(e[n-2],e[n-1]),we(e[n-2],e[n-1]),Ce(e[n],e[n+1]),we(e[n],e[n+1]),l))return!1;let s=0,d=0,m=-1;if(u.labelW>0){let t=o.labelW,n=o.labelH;for(let r=2;r<e.length;r+=2){let o=(e[r-2]+e[r])/2,c=(e[r-1]+e[r+1])/2,f=Math.abs(e[r]-e[r-2]),p=Math.abs(e[r+1]-e[r-1]),h=f+p;if(h<=m||(f>0?f<t+8:p<n+8)||o-t/2<0||o+t/2>xe||c-n/2<0||c+n/2>be||!i(o-t/2,c-n/2,o+t/2,c+n/2,-1,-1,l))continue;let g=Ce(o,c),_=we(o,c);a(g-u.labelW/2,_-u.labelH/2,g+u.labelW/2,_+u.labelH/2,l)>0||(s=o,d=c,m=h)}if(m<0)return!1}let h=[e[0],e[1]];for(let t=2;t<e.length;t+=2){let n=e[t]-e[t-2],r=e[t+1]-e[t-1],i=Math.abs(n)+Math.abs(r),a=t>2?l0:0,o=t+2<e.length?l0:0;i>a+o+1&&(a&&h.push(e[t-2]+n/i*a,e[t-1]+r/i*a),o&&h.push(e[t]-n/i*o,e[t+1]-r/i*o)),h.push(e[t],e[t+1])}u.route=[];for(let e=0;e<h.length;e+=2){let t=e===0?h[0]!==h[2]:h[e]!==h[e-2];u.route.push(Ce(h[e],h[e+1]),we(h[e],h[e+1]),t?1-Te:Te)}return u.labelW>0&&(u.labelX=Ce(s,d),u.labelY=we(s,d),n[l]=[s,d]),Ae[r]=1,!0};if(C([h+y*k[f]/2,_,g,_,g,v-S*A[p]/2],2)||C([h,_+S*A[f]/2,h,v,g-y*k[p]/2,v],2)||Me>c0/Ekt)continue;let w=[];for(let e of O[f]<O[p]?[O[p],O[f]]:[O[f],O[p]]){let t=Math.max(d[e]-Okt,Math.min(d[e]/2,Dkt-Okt));for(let n of[de[e]+t,de[e+1]-t]){if(Math.abs(n-h)<k[f]/2+4||Math.abs(n-g)<k[p]/2+4)continue;let t=[h+Math.sign(n-h)*k[f]/2,_,n,_,n,v,g+Math.sign(n-g)*k[p]/2,v],r=(s(Ce(t[0],t[1]),we(t[0],t[1]),l)+s(Ce(t[6],t[7]),we(t[6],t[7]),l))*1e6;for(let e=2;e<t.length;e+=2){let n=Ce(t[e-2],t[e-1]),i=we(t[e-2],t[e-1]),o=Ce(t[e],t[e+1]),s=we(t[e],t[e+1]);r+=a(Math.min(n,o),Math.min(i,s),Math.max(n,o),Math.max(i,s),l)*1e6+Math.abs(o-n)+Math.abs(s-i)}w.push({pts:t,cost:r,lane:e})}}w.sort((e,t)=>e.cost-t.cost);for(let e of w)if(C(e.pts,1)){m[e.lane]=1;break}}}return{width:o?be:xe,height:o?xe:be,routed:Ae,margins:m,work:Me}},E=new Uint8Array(C),D=new Uint8Array(l),O=T(E,D);for(let e=0;e<Tkt&&O.work<=c0/Ekt;e++){let t=e===0?O.routed:E.map((e,t)=>e&O.routed[t]);if(t.every((e,t)=>e===E[t])&&O.margins.every((e,t)=>e===D[t]))break;E=t,D=O.margins,O=T(E,D)}return E.some((e,t)=>e&&!O.routed[t])&&(O=T(new Uint8Array(C),new Uint8Array(l))),{width:O.width,height:O.height}}function jkt(e,t){let n=t.x-e.x,r=t.y-e.y,i=Math.max(e.w/2,.5),a=Math.max(e.h/2,.5);if(Math.abs(n)<i&&Math.abs(r)<a)return i-Math.abs(n)<a-Math.abs(r)?[e.x+(n<0?-i:i),t.y]:[t.x,e.y+(r<0?-a:a)];let o=Math.min(n===0?1/0:i/Math.abs(n),r===0?1/0:a/Math.abs(r));return[e.x+n*o,e.y+r*o]}var Mkt=`__swimlane_default__`;function Nkt(e){let t=!1;for(let n of e.nodes)n.isGroup?n.dir=void 0:n.parentId===void 0&&(t=!0);if(t){for(let t of e.nodes)!t.isGroup&&t.parentId===void 0&&(t.parentId=Mkt);e.nodes.push({id:Mkt,label:void 0,labelType:`text`,shape:`rect`,isGroup:!0,parentId:void 0,cssStyles:[],cssCompiledStyles:[],cssClasses:``,dir:void 0})}}function Pkt(e,t,n,r,i,a,o){let s=e.x-e.w/2,c=e.y-e.h/2,l=a===`LR`||a===`RL`,u=l?s+e.padTop/2:e.x,d=l?e.y:c+e.padTop/2,f=gq(t,u,d,` class="pele-cluster-label" fill="var(--_m)"${n.text}`,o);return`<g class="pele-cluster pele-lane${r}" data-id="${i}"><rect x="${K(s)}" y="${K(c)}" width="${K(e.w)}" height="${K(e.h)}" fill="none" stroke="var(--_b)"/><rect x="${K(s)}" y="${K(c)}" width="${K(l?e.padTop:e.w)}" height="${K(l?e.h:e.padTop)}" fill="var(--_a)" stroke="var(--_b)"${n.shape}/>`+(l&&f?`<g transform="rotate(-90 ${K(u)} ${K(d)})">${f}</g>`:f)+`</g>`}var Fkt={type:`swimlane`,prepare:Nkt,layout:(e,t,n,r,i)=>Akt(e,t,n,r,i?12:void 0),drawGroup:Pkt},Ikt={type:`swimlane`,parse:jxt.parse,render:(e,t,n)=>kxt(e,t,n,Fkt)},Lkt=class{type=`timeline`;title;accTitle;accDescr;direction=`LR`;sections=[];periods=[];currentSection=``;getCommonDb(){return this}setDiagramTitle(e){this.title=e}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,``)}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
1059
|
-
`)}setDirection(e){this.direction=e}addSection(e){this.currentSection=e,this.sections.push(e)}addTask(e,t,n){this.periods.push({text:e,events:n?[n]:[],section:this.currentSection,sectionIndex:this.sections.length-1})}addEvent(e){let t=this.periods[this.periods.length-1];if(!t)throw new NK(`An event needs a time period before it.`,`semantic`,{type:`timeline`});t.events.push(e)}},Rkt=[`$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`];function zkt(e){let t=e.length,n=[],r=[],i=[],a={types:n,texts:r,starts:i},o=0,s=(t,a)=>{n.push(t),r.push(e.slice(o,a)),i.push(o),o=a};for(;o=qCt(e,o),!(o>=t);){let n=e.charCodeAt(o),r=o+1;if(n===10){for(;e.charCodeAt(r)===10;)r++;s(3,r)}else{if(HQ(e,o,`timeline`)){for(r=o+8;e.charCodeAt(r)===32||e.charCodeAt(r)===9;)r++;let t=HQ(e,r,`lr`);if(r>o+8&&(t||HQ(e,r,`td`))&&!aq(e.charCodeAt(r+2))){s(t?5:6,r+2);continue}if(!aq(e.charCodeAt(o+8))){s(4,o+8);continue}}if(HQ(e,o,`title`)&&eq(e.charCodeAt(o+5))&&o+6<t&&e.charCodeAt(o+6)!==10)s(7,VQ(e,o+6));else if(r=JCt(e,o,a,8),r!==o)o=r;else{if(HQ(e,o,`section`)&&eq(e.charCodeAt(o+7))){for(r=o+8;r<t&&e.charCodeAt(r)!==58&&e.charCodeAt(r)!==10;)r++;if(r>o+8){s(13,r);continue}}if(n!==58){r=o+1;for(let n=e.charCodeAt(r);r<t&&n!==35&&n!==58&&n!==10;n=e.charCodeAt(++r));s(14,r)}else{if(eq(e.charCodeAt(o+1))){for(r=o+2;r<t;r++){let t=e.charCodeAt(r);if(t===10||t===58&&eq(e.charCodeAt(r+1)))break}if(r>o+2){s(15,r);continue}}s(2,o+1)}}}}return(i.length===0||i[i.length-1]<t)&&s(1,t),s(0,t),a}var Bkt=`'EOF', 'SPACE', 'NEWLINE', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'section', 'period', 'event'`;function Vkt(e,t){let{types:n,texts:r,starts:i}=zkt(e),a=(t,r)=>{let a=n[t]===0?`1`:Rkt[n[t]];throw FK(`timeline`,e,i[t],`Expecting ${r}, got '${a}'`)},o=n[0];o!==4&&o!==5&&o!==6&&a(0,`'timeline', 'timeline_lr', 'timeline_td'`),o!==4&&t.setDirection(o===5?`LR`:`TD`);for(let e=1;;e++){let i=r[e];switch(n[e]){case 3:break;case 7:t.getCommonDb().setDiagramTitle(i.substring(6));break;case 8:t.getCommonDb().setAccTitle(r[++e].trim());break;case 10:t.getCommonDb().setAccDescription(r[++e].trim());break;case 12:t.getCommonDb().setAccDescription(i.trim());break;case 13:t.addSection(i.substring(8));break;case 14:t.addTask(i,0,``);break;case 15:t.addEvent(i.substring(2));break;case 1:return;default:a(e,Bkt)}}}var u0=12,Hkt=8,Ukt=152,Wkt=216,Gkt=264,d0=20,f0=20,p0=14,m0=8,h0=8,g0=12,Kkt=` fill="var(--_bg)"`,qkt=` fill="none" stroke="var(--_b)"`;function _0(e,t,n,r,i){return`<rect x="${K(e)}" y="${K(t)}" width="${K(n)}" height="${K(r)}" rx="${
|
|
1058
|
+
`,i);if(r===-1)return N(1);S(20,e.slice(s,i).trim(),s,i+8),w();continue}case 18:{let r=E(s);if(T(`as`,r)){x(13,s,E(r+2)),w(),C(19);continue}if(n===34){s++;continue}let i=e.indexOf(`"`,s);x(20,s,i===-1?t:i);continue}case 19:M(s,O(s))&&w();continue}}}var QOt=[`TB`,`BT`,`RL`,`LR`],$1=`'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'`;function $Ot(e,t){let{types:n,texts:r,starts:i,error:a}=ZOt(e),o=0,s=t=>{let r=n[o];throw r===1?a===void 0?FK(`state`,e,i[o],``,!0):new NK(a,`syntax`,{type:`state`,...PK(e,i[o])}):FK(`state`,e,i[o],`Expecting ${t}, got '${GOt[r]}'`)},c=e=>(n[o]!==e&&s(`'${GOt[e]}'`),r[o++]),l=()=>{let e=n[o];e!==14&&e!==44&&s(`'ID', 'EDGE_STATE'`);let t=r[o++].trim();return n[o]===45?(o++,{stmt:`state`,id:t,classes:[c(14).trim()],type:`default`,description:``}):{stmt:`state`,id:t,type:`default`,description:``}};for(;n[o]===2;)o++;n[o]!==3&&s(`'NL', 'SD'`),o++;let u=[],d=[],f=e=>{e!==`nl`&&u.push(e)},p=(e,t)=>{o++;let n=[];u.push({stmt:`state`,id:e,type:`default`,description:t,doc:n}),d.push(u),u=n};for(;;){let e=n[o];switch(e){case 2:o++;break;case 14:case 44:{let e=l();if(n[o]===4)e.description=t.trimColon(r[o++]),f(e);else if(n[o]===5){o++;let i=l();n[o]===4?f({stmt:`relation`,state1:e,state2:i,description:t.trimColon(r[o++])}):f({stmt:`relation`,state1:e,state2:i})}else f(e);break}case 6:f(r[o++]);break;case 7:o++,c(8),f(r[o-2]);break;case 9:n[o+1]===10?p(r[o++],``):f(r[o++]);break;case 12:{let e=r[o++];c(13);let t=c(14);if(n[o]===10)p(t,e);else if(t.includes(`:`)){let n=t.split(`:`);f({stmt:`state`,id:n[0],type:`default`,description:[e.trim(),n[1]]})}else f({stmt:`state`,id:t,type:`default`,description:e.trim()});break}case 15:f({stmt:`state`,id:r[o++],type:`fork`});break;case 16:f({stmt:`state`,id:r[o++],type:`join`});break;case 17:f({stmt:`state`,id:r[o++],type:`choice`});break;case 18:o++,f({stmt:`state`,id:t.getDividerId(),type:`divider`});break;case 19:{let e=r[o++];if(n[o]===46||n[o]===47){let e=r[o++].trim();f({stmt:`state`,id:c(14).trim(),note:{position:e,text:c(20).trim()}})}else n[o]!==20&&s(`'NOTE_TEXT', 'left_of', 'right_of'`),o++,c(13),c(14),f(e);break}case 40:case 41:case 42:case 43:{let n=QOt[e-40];o++,t.setDirection(n),f({stmt:`dir`,value:n});break}case 21:{o++;let e=c(22).trim();t.setAccTitle(e),f(e);break}case 23:{o++;let e=c(24).trim();t.setAccDescription(e),f(e);break}case 25:{let e=r[o++].trim();t.setAccDescription(e),f(e);break}case 26:{o++;let e=l(),t,i=``;n[o]===28?(o++,t=c(27)):(n[o]!==27&&s(`'STRING', 'HREF'`),t=r[o++],i=c(27)),c(2),f({stmt:`click`,id:e,url:t,tooltip:i});break}case 29:o++,f({stmt:`classDef`,id:c(30).trim(),classes:c(32).trim()});break;case 34:o++,f({stmt:`style`,id:c(35).trim(),styleClass:c(36).trim()});break;case 37:o++,f({stmt:`applyClass`,id:c(38).trim(),styleClass:c(39).trim()});break;case 11:d.length===0&&s(`'$end', ${$1}`),o++,u=d.pop();break;case 0:return d.length>0&&s(`'STRUCT_STOP', ${$1}`),t.setRootDoc(u),u;default:s(d.length>0?`'STRUCT_STOP', ${$1}`:`'$end', ${$1}`)}}}var ekt=40,tkt=16,nkt=44,e0=16,t0=10,rkt=16,ikt=10,n0=26,akt=8,okt=320,r0=10,skt=8,ckt=` fill="var(--_s)" stroke="var(--_b)"`,i0=` fill="none" stroke="var(--_b)"`,lkt=/(?:^| )statediagram-(?:state|cluster-alt|cluster|note)(?= |$)/g,ukt=/* @__PURE__ */ new Map([[`rectWithTitle`,1],[`stateStart`,2],[`stateEnd`,3],[`choice`,4],[`fork`,5],[`join`,6],[`note`,7],[`divider`,10]]),dkt=[`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 fkt(e){return e===`TB`||e===`BT`}function a0(e,t,n){let r=e.state?.[t];return typeof r==`number`&&r>0?Math.min(r,2e3):n}function pkt(e){let t=0,n=e.length;for(;t<n&&e.charCodeAt(t)===34;)t++;for(;n>t&&e.charCodeAt(n-1)===34;)n--;return e.slice(t,n)}function mkt(e,t,n){return e<t?t:e>n?n:e}function o0(e,t,n,r,i){return`<rect x="${K(e)}" y="${K(t)}" width="${K(n)}" height="${K(r)}"${i}/>`}function s0(e,t,n,r){let i=Qq(0,0);return i.isGroup=!0,i.dir=e,i.padX=t,i.padTop=n,i.padBottom=r,i}function hkt(e,t,n){return JJ(e.direction)?qJ(n,r=>gkt(e,t,n,r)):gkt(e,t,n,!1)}function gkt(e,t,n,r){let i=e.graph,a=n.fontSize??16,o=Math.round(a*.875),s=n.measurer??fq(n.fontFamily),c=a0(t,`wrappingWidth`,200),l=n.padding??8,u=n.icons,d=r?`TB`:Xq(e.direction),f=UJ(void 0,!1,s,a,0),p=(e,t,n,r=0)=>UJ(e,!0,s,t,n,r),m=/* @__PURE__ */ new Map,h=[],g=[],_=(e,t,n)=>(h.push({node:e,kind:t,style:void 0,label:f,lines:[],w:0,h:0,titleH:0}),n&&g.push(n),h.length-1);for(let e of i.nodes){if(e.shape===`noteGroup`)continue;let t=e.isGroup?e.shape===`divider`?9:8:ukt.get(e.shape)??0;m.set(e.id,_(e,t,void 0))}let v=h.length,y=[];for(let e=0;e<v;e++){let t=h[e].node.parentId,n=t===void 0?void 0:m.get(t);y.push(n!==void 0&&n!==e&&h[n].node.isGroup?n:-1)}{let e=[];for(let t=0;t<v;t++)e.push([]);let t=[],n=new Uint8Array(v);for(let r=0;r<v;r++)y[r]===-1?(n[r]=1,t.push(r)):e[y[r]].push(r);let r=0,i=()=>{for(;r<t.length;r++)for(let i of e[t[r]])n[i]||(n[i]=1,t.push(i))};i();let a=new Int32Array(v).fill(-1);for(let e=0;e<v;e++){if(n[e])continue;let r=e;for(;a[r]!==e;)a[r]=e,r=y[r];y[r]=-1,n[r]=1,t.push(r),i()}}let b=new Int32Array(v).fill(-1);for(let e=0;e<v;e++){let t=h[e].node.noteFor,n=t===void 0?void 0:m.get(t);n!==void 0&&(b[e]=n,y[e]=y[n])}let x=e=>Xq(h[e].node.dir),S=e=>fkt(y[e]===-1?d:x(y[e])),C=new Int32Array(v),w=new Uint8Array(v),T=Array(v).fill(1/0),E=0,D=new Int32Array(2*v);for(let e of i.edges){let t=m.get(e.start),n=m.get(e.end);if(t!==void 0&&n!==void 0){if(e.pattern===`dashed`){w[h[t].kind===7?n:t]=1;continue}C[t]=Math.max(C[t],++D[2*t]),C[n]=Math.max(C[n],++D[2*n+1]),T[t]===1/0&&(T[t]=E++),T[n]===1/0&&(T[n]=E++)}}for(let e=0;e<v;e++){let t=h[e],n=t.node,r=pJ(n.cssStyles.length>0?n.cssCompiledStyles.concat(n.cssStyles):n.cssCompiledStyles),i=+!!r.bold|(r.italic?2:0),s=r.fontSize??a;t.style=r;let l;switch(t.kind){case 8:t.label=p(n.label,s,4e3,i),t.titleH=t.label.height>0?t.label.height+12:0,l=s0(x(e),e0,t.titleH+e0,e0),l.minW=t.label.width+2*e0;break;case 9:l=s0(x(e),t0,t0,t0);break;case 2:t.w=t.h=14;break;case 3:t.w=t.h=18;break;case 4:t.w=t.h=30;break;case 5:case 6:{let n=mkt(40*C[e]+16,72,320);t.w=S(e)?n:skt,t.h=S(e)?skt:n;break}case 10:break;case 7:t.label=p(n.label,o,Math.max(c,okt)),t.w=t.label.width+24,t.h=t.label.height+16;break;default:{t.label=p(n.label,s,c,i);let e=t.label.width,r=t.label.height+2*ikt;if(t.kind===1){r+=14;for(let a of n.description){let n=p(a===``?` `:a,o,c,i);t.lines.push(n),n.width>e&&(e=n.width),r+=n.height}}t.w=Math.max(e+2*rkt,56),t.h=r}}l??=Qq(t.w,t.h),(t.kind===0||t.kind===1)&&(l.span=(S(e)?t.w:t.h)-24),g.push(l)}let O=[],k=[],A=[],j=new Int32Array(v),M=new Float64Array(v),N=new Float64Array(v),P=/* @__PURE__ */ new Map,F=(e,t)=>{if(!g[e].isGroup)return!1;for(let n=y[t];n!==-1;n=y[n])if(n===e)return!0;return!1},ee=(e,t)=>(P.set(O.length,e),T.push(t?-1:1/0),_(void 0,10,Qq(0,0,e)));for(let e of i.edges){let t=m.get(e.start),n=m.get(e.end);if(t===void 0||n===void 0)continue;let r=p(e.label,o,c),i=r.width>0?r.width+12:0;t===n?(j[t]++,M[t]=Math.max(M[t],i),N[t]+=r.height):F(t,n)?t=ee(t,!0):F(n,t)&&(n=ee(n,!1)),A.push(e),k.push(r),O.push({src:t,dst:n,minlen:1,labelW:i,labelH:r.height>0?r.height+4:0,route:[],labelX:0,labelY:0})}for(let e=0;e<v;e++){if(b[e]!==-1)continue;let t=g[e],n=0;if(j[e]>0){let r=n0+(j[e]-1)*8;n=S(e)?r+M[e]:r*.75+4+N[e],t.isGroup||(S(e)?(t.w+=2*n,t.h=Math.max(t.h,N[e])):(t.h+=2*n,t.w=Math.max(t.w,M[e])),n=0)}if(!w[e]&&n===0){t.parent=y[e];continue}let r=S(e)?s0(`LR`,n,0,0):s0(`TB`,0,n,n);r.parent=y[e],T.push(T[e]),g[e].parent=_(void 0,10,r)}for(let e=0;e<v;e++)b[e]!==-1&&(g[e].parent=g[b[e]].parent);{let e=[];for(let t=0;t<g.length;t++)e.push([]);let t=[];for(let n=0;n<g.length;n++){let r=g[n].parent;r>=0?e[r].push(n):t.push(n)}let n=e=>h[e].kind===2?0:1,r=(e,t)=>n(e)-n(t)||(T[e]===T[t]?0:T[e]<T[t]?-1:1)||e-t,i=0,a=t.sort(r).reverse();for(;a.length>0;){let t=a.pop();g[t].seq=i++;let n=e[t].sort(r);for(let e=n.length-1;e>=0;e--)a.push(n[e])}}let te=eJ(g,O,d,{nodeSep:a0(t,`nodeSpacing`,ekt),edgeSep:tkt,rankSep:a0(t,`rankSpacing`,nkt),portSep:20,headRoom:sJ(`arrow_point`)}),I=Math.ceil(te.width+2*l),ne=Math.ceil(te.height+2*l),re=[],ie=/* @__PURE__ */ new Map;for(let e of O){let t=e.route;for(let e=3;e<t.length-3;e+=3){let n=Math.round(t[e+1]),r=ie.get(n);r?r.push(t[e]):ie.set(n,[t[e]])}}let ae=[];for(let e=0;e<g.length;e++)ae.push([]);let L=[];for(let e=0;e<g.length;e++){let t=g[e].parent;t>=0?ae[t].push(e):L.push(e)}let oe=L.slice();for(let e=0;e<L.length;e++)for(let t of ae[L[e]])L.push(t);let se=``,ce=``,le=``,ue=``,de=(e,t,n,r,i)=>{let a=e.filter(e=>h[e].kind===9);if(a.length<2)return;let o=(e,t)=>t?g[e].x-g[e].w/2:g[e].y-g[e].h/2,s=(e,t)=>t?g[e].x+g[e].w/2:g[e].y+g[e].h/2;for(let e of[!0,!1]){let c=a.slice().sort((t,n)=>o(t,e)-o(n,e)||t-n),u=!0;for(let t=1;t<c.length;t++)s(c[t-1],e)>o(c[t],e)+.5&&(u=!1);if(u){for(let a=1;a<c.length;a++){let u=K((s(c[a-1],e)+o(c[a],e))/2+l);ce+=`<path class="pele-divider" d="M${e?`${u},${K(n)}V${K(i)}`:`${K(t)},${u}H${K(r)}`}"/>`}return}}for(let e of a){let t=g[e];ce+=o0(t.x-t.w/2+l,t.y-t.h/2+l,t.w,t.h,` class="pele-divider" rx="${r0}"`)}};de(oe,l/2,l/2,I-l/2,ne-l/2);for(let t of L){let r=h[t],i=r.node,a=r.style;if(i===void 0||a===void 0||r.kind>=9)continue;let s=g[t],c=s.x+l,d=s.y+l,f=r.w,p=r.h,m=` class="pele-label"${a.text}`,_;switch(r.kind){case 8:{let e=c-s.w/2,n=d-s.h/2;_=o0(e,n,s.w,s.h,` rx="${r0}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${a.shape}`),r.titleH>0&&(_+=`<path d="M${K(e)},${K(n+r.titleH)}H${K(e+s.w)}"${i0}${a.line}/>`+gq(r.label,_kt(s,r.label.width,ie)+l,n+r.titleH/2,` class="pele-cluster-label"${a.text}`,u)),de(ae[t],e,n+r.titleH,e+s.w,n+s.h);break}case 2:_=`<circle r="7" fill="var(--_l)"${a.shape}/>`;break;case 3:_=`<circle r="8.5" fill="var(--_bg)" stroke="var(--_l)"${a.line}/><circle r="5" fill="var(--_l)"${a.shape}/>`;break;case 4:_=`<polygon points="0,${K(-p/2)} ${K(f/2)},0 0,${K(p/2)} ${K(-f/2)},0"${ckt}${a.shape}/>`;break;case 5:case 6:_=o0(-f/2,-p/2,f,p,` rx="2" fill="var(--_l)"${a.shape}`);break;case 7:{let e=K(f/2),t=K(p/2),n=K(f/2-akt),i=K(akt-p/2);_=`<path d="M-${e},-${t}H${n}L${e},${i}V${t}H-${e}Z" fill="var(--_bg)" stroke="var(--_b)"/><path d="M${n},-${t}V${i}H${e}"${i0}/>`+gq(r.label,0,0,` class="pele-label" font-size="${o}" fill="var(--_m)"`,u);break}default:{if(_=o0(-f/2,-p/2,f,p,` rx="${K(Math.min(r0,p/2))}"${ckt}${a.shape}`),r.kind===0){_+=gq(r.label,0,0,m,u);break}let e=ikt-p/2+r.label.height;_+=`<path d="M${K(-f/2)},${K(e+6)}H${K(f/2)}"${i0}${a.line}/>`+gq(r.label,0,e-r.label.height/2,m,u),e+=14;for(let t of r.lines)_+=gq(t,0,e+t.height/2,` class="pele-state-description" font-size="${o}"${a.text}`,u),e+=t.height}}let v=e.links.get(i.id);if(v){let e=RK(pkt(v.tooltip));e&&(_=`<title>${pq(e)}</title>`+_),_=Tq(_,Cq(pkt(v.url)),i.id,re,n,` target="_blank"`)}let y=`<g class="${dkt[r.kind]}${mJ(i.cssClasses.replace(lkt,``))}" data-id="${mq(i.id)}"`;r.kind===8?se+=`${y}>${_}</g>`:r.kind===7?ue+=`${y} transform="translate(${K(c)},${K(d)})">${_}</g>`:le+=`${y} transform="translate(${K(c)},${K(d)})">${_}</g>`}let fe=(e,t,n)=>{let r=g[n];if(r.isGroup)return;let i=h[n],a=i.kind===5||i.kind===6,o=t===0?3:t-3;for(let n of[1,0]){let s=n?r.h:r.w,c=n?i.h:i.w,u=n?i.w:i.h,d=(n?r.y:r.x)+l,f=(n?r.x:r.y)+l,p=e[t+n]-d;if(!(Math.abs(Math.abs(p)-s/2)>=.5)){e[t+n]-=Math.sign(p)*(s-c)/2,a&&u>c&&(e[t+1-n]=mkt(e[o+1-n],f-u/2+6,f+u/2-6));return}}},pe=yht();for(let e=0;e<O.length;e++){let t=O[e];t.src===t.dst||t.route.length<6||A[e].pattern===`dashed`||pe.add(t.dst,zJ(t.route,t.route.length-3,g[t.dst]),`arrow_point`)}let me=``,he=``,ge=new Int32Array(v),_e=new Float64Array(v);for(let e=0;e<O.length;e++){let t=O[e],n=A[e],r=k[e],i=n.pattern===`dashed`,a=i?`none`:`arrow_point`,o;if(t.src===t.dst){let e=g[t.src],n=h[t.src],i=ge[t.src]++,s=S(t.src),c=e.isGroup?e.w:n.w,u=e.isGroup?e.h:n.h,d=(s?c:u)/2,f=Math.max(Math.min((s?u:c)/2-4,8+i*6),2),p=n0+i*8,m=sJ(a)/(Math.hypot(p,f)||1),_=(t,n)=>e.x+l+(s?d+t:-n),v=(t,n)=>e.y+l+(s?n:d+t),y=(e,t)=>`${K(_(e,t))},${K(v(e,t))}`;o={d:`M${y(0,-f)}C${y(p,-2*f)} ${y(p,2*f)} ${y(p*m,f+f*m)}`,sx:0,sy:0,sdx:0,sdy:0,ex:_(0,f),ey:v(0,f),edx:_(-p,-f)-_(0,0),edy:v(-p,-f)-v(0,0)};let b=Math.hypot(o.edx,o.edy)||1;o.edx/=b,o.edy/=b;let x=n0+(j[t.src]-1)*8,C=_e[t.src]+r.height/2;_e[t.src]+=r.height,t.labelX=s?e.x+d+x+4+t.labelW/2:e.x,t.labelY=s?e.y-N[t.src]/2+C:e.y+d+x*.75+4+C}else{let n=t.route.slice(),r=pe.of(t.src,zJ(n,0,g[t.src])),i=pe.of(t.dst,zJ(n,n.length-3,g[t.dst]));for(let e=0;e<n.length;e+=3)n[e]+=l,n[e+1]+=l;fe(n,0,t.src),fe(n,n.length-3,t.dst);let s=P.get(e);if(s!==void 0&&n.length>=6){let e=g[s],r=h[t.src].kind===10,i=r?0:n.length-3,a=(e.dir===`TB`||e.dir===`LR`)===r,o=fkt(e.dir)?[n[i],e.y+l+(a?h[s].titleH-e.h/2:e.h/2),0]:[e.x+l+(a?-e.w/2:e.w/2),n[i+1],1];n=r?o.concat(n):n.concat(o)}o=oJ(n,void 0,0,sJ(a),r,i)}if(me+=`<g class="pele-edge ${i?`pele-note-edge" stroke="var(--_b)" stroke-dasharray="3 4`:`pele-transition`}" data-id="${mq(n.id)}"><path d="${o.d}"/>`+cJ(a,o.ex,o.ey,o.edx,o.edy,`var(--_l)`)+`</g>`,r.width>0){let e=t.labelX+l,i=t.labelY+l;he+=lJ(n.id,r,e,i,``,u)}}let ve=Kvt(e.title,s,a,l,I,ne,(se?`<g class="pele-clusters">${se}</g>`:``)+(ce?`<g class="pele-dividers" stroke-dasharray="4 4"${i0}>${ce}</g>`:``)+(me?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${me}</g>`:``)+(he?`<g class="pele-edge-labels" font-size="${o}">${he}</g>`:``)+`<g class="pele-nodes">${le}${ue}</g>`);return{svg:_J(`state`,ve.width,ve.height,a,n,e,ve.content),width:ve.width,height:ve.height,links:re}}function _kt(e,t,n){let r=n.get(Math.round(e.y-e.h/2));if(r===void 0||t===0)return e.x;let i=e.x-e.w/2,a=t/2,o=e.x,s=-1;for(let t of[e.x,i+e0+a,i+e.w-e0-a]){let n=1/0;for(let o of r)o>i&&o<i+e.w&&(n=Math.min(n,Math.abs(o-t)-a));if(n>=6)return t;n>s+.5&&(s=n,o=t)}return o}var vkt={type:`state`,parse(e,t,n){let r=new WOt;return n&&(r.title=n),$Ot(e,r),r},render:hkt},ykt=34,bkt=24,xkt=8,Skt=2e4,Ckt=1e4,c0=2e6,wkt=4,Tkt=3,Ekt=8,l0=20,Dkt=20,Okt=14,kkt=3;function Akt(e,t,n,r,i=bkt){let a=e.length;if(a===0)return{width:0,height:0};let o=n===`LR`||n===`RL`,s=n===`BT`||n===`RL`,c=[];for(let t=a-1;t>=0;t--)e[t].parent<0&&e[t].isGroup&&c.push(t);let l=Math.max(1,c.length),u=new Int32Array(a).fill(-1);c.forEach((e,t)=>u[e]=t);let d=new Uint8Array(a);for(let t=0;t<a;t++)e[t].parent>=0&&(d[e[t].parent]=1);let f=new Float64Array(l).fill(i),p=i,m=t=>{let n=t,r=i;for(let t=0;e[n].parent>=0&&t<Ckt;t++)n=e[n].parent,u[n]<0&&(r+=Math.max(e[n].padX,e[n].padTop,e[n].padBottom));let a=Math.max(0,u[n]);return r>f[a]&&(f[a]=r),r>p&&(p=r),a},h=new Int32Array(a).fill(-1),g=[];for(let t=0;t<a;t++)u[t]>=0||e[t].isGroup&&d[t]||(h[t]=g.length,g.push(t));let _=e=>o?e.w:e.h,v=e=>o?e.h:e.w,y=g.map(t=>Hq(v(e[t]),_(e[t]))),b=[],x=[],S=1;{let e=/* @__PURE__ */ new Set;for(let n=0;n<t.length;n++){let r=t[n],i=h[r.src],a=h[r.dst];if(i<0||a<0||i===a)continue;let s=Math.min(i,a)*g.length+Math.max(i,a);(r.labelW>0||e.has(s))&&(S=2),e.add(s),b.push(Uq(i,a,r.minlen,o?r.labelH:r.labelW,o?r.labelW:r.labelH)),x.push(n)}}qq(y,b),Jq(y,b,S);let C=b.length,w=Int32Array.from(g,m),T=(n,i)=>{let d=f.map((e,t)=>i[t]?Math.max(e,Dkt):e),m=new Uint8Array(l),_=0,v=new Int32Array(C);for(let e=0;e<C;e++)v[e]=Math.abs(y[b[e].head].rank-y[b[e].tail].rank),n[e]||(_+=v[e]-1);let T=_>Skt,E=g.length+(T?0:_),D=new Int32Array(E),O=new Int32Array(E),k=new Float64Array(E),A=new Float64Array(E),j=new Uint8Array(E),M=0;for(let e=0;e<g.length;e++)D[e]=y[e].rank,O[e]=w[e],k[e]=y[e].w,A[e]=y[e].h,D[e]>M&&(M=D[e]);let N=new Int32Array(C).fill(-1),P=new Int32Array(C).fill(-1),F=[];{let e=g.length;for(let t=0;t<C;t++){let r=b[t],i=r.reversed?r.head:r.tail,a=r.reversed?r.tail:r.head;if(T||v[t]<2||n[t]){F.push(i,a);continue}let o=D[i],s=D[a],c=-1;r.labelW>0&&(c=o+(s-o>>1),S===2&&!(c&1)&&c--),N[t]=e;let l=i;for(let n=o+1;n<s;n++){let u=e++;D[u]=n,O[u]=O[i]+Math.round((O[a]-O[i])*(n-o)/(s-o)),j[u]=1,n===c&&(k[u]=r.labelW,A[u]=r.labelH,P[t]=u),F.push(l,u),l=u}F.push(l,a)}}let ee=new Int32Array(E+1),te=new Int32Array(E+1);for(let e=0;e<F.length;e+=2)te[F[e]+1]++,ee[F[e+1]+1]++;for(let e=0;e<E;e++)ee[e+1]+=ee[e],te[e+1]+=te[e];let I=new Int32Array(F.length/2),ne=new Int32Array(F.length/2);{let e=ee.slice(0,E),t=te.slice(0,E);for(let n=0;n<F.length;n+=2)ne[t[F[n]]++]=F[n+1],I[e[F[n+1]]++]=F[n]}let re=[];for(let e=0;e<=M;e++)re.push([]);for(let e=0;e<E;e++)re[D[e]].push(e);let ie=new Float64Array(E),ae=new Float64Array(E),L=e=>{e.sort((e,t)=>O[e]-O[t]||ae[e]-ae[t]||e-t);for(let t=0;t<e.length;t++)ie[e[t]]=t};for(let e of re){for(let t=0;t<e.length;t++)ae[e[t]]=t;L(e)}for(let e=0;e<xkt&&M>0;e++){let t=!(e&1);for(let e=1;e<=M;e++){let n=re[t?e:M-e],r=t?ee:te,i=t?I:ne;for(let e of n){let t=0,n=r[e+1]-r[e];for(let n=r[e];n<r[e+1];n++)t+=ie[i[n]];ae[e]=n>0?t/n:ie[e]}L(n)}}let oe=(e,t)=>j[e]||j[t]?r.edgeSep:r.nodeSep,se=(e,t)=>{let n=0;for(;n<e.length;){let r=n;for(;r+1<e.length&&O[e[r+1]]===O[e[n]];)r++;t(e,n,r),n=r+1}},ce=(e,t,n)=>{let r=k[e[t]];for(let i=t;i<n;i++)r+=oe(e[i],e[i+1])+k[e[i+1]];return r},le=new Float64Array(l),ue=c.length>0?ykt:0;for(let t=0;t<c.length;t++){let n=e[c[t]];le[t]=Math.max(0,n.minW-2*d[t]),n.padTop>ue&&(ue=n.padTop)}for(let e of re)se(e,(t,n,r)=>{let i=ce(e,n,r);i>le[O[e[n]]]&&(le[O[e[n]]]=i)});let de=new Float64Array(l+1);for(let e=0;e<l;e++)de[e+1]=de[e]+le[e]+2*d[e];let fe=new Float64Array(E),pe=new Float64Array(E),me=(e,t,n)=>{let r=O[e[t]],i=(de[r]+d[r]+(de[r+1]-d[r])-ce(e,t,n))/2;for(let r=t;r<=n;r++)fe[e[r]]=i+k[e[r]]/2,r<n&&(i+=k[e[r]]+oe(e[r],e[r+1]))},he=(e,t,n)=>{let r=O[e[t]],i=de[r]+d[r];for(let r=t;r<=n;r++){let t=e[r];fe[t]=Math.max(pe[t],i+k[t]/2),r<n&&(i=fe[t]+k[t]/2+oe(t,e[r+1]))}let a=de[r+1]-d[r];for(let r=n;r>=t;r--){let n=e[r];fe[n]=Math.min(fe[n],a-k[n]/2),r>t&&(a=fe[n]-k[n]/2-oe(e[r-1],n))}};for(let e of re)se(e,me);for(let e=0;e<4&&M>0;e++){let t=!(e&1);for(let e=1;e<=M;e++){let n=re[t?e:M-e],r=t?ee:te,i=t?I:ne;for(let e of n){let t=0,n=0;for(let a=r[e];a<r[e+1];a++)O[i[a]]===O[e]&&(t+=fe[i[a]],n++);pe[e]=n>0?t/n:fe[e]}se(n,he)}}let ge=new Float64Array(M+1),_e=new Float64Array(M+1),ve=new Float64Array(M+1).fill(r.rankSep/S);if(n.some(e=>e===1)){let e=r.rankSep/S;ve.fill(e/kkt);for(let t=0;t<C;t++){let r=b[t],i=r.reversed?r.head:r.tail,a=r.reversed?r.tail:r.head;if(n[t]){if(r.labelH<=0||v[t]>S)continue;let n=Math.min(e,(r.labelH+2*l0-Math.min(A[i],A[a])/2)/v[t]);for(let e=D[i];e<D[a];e++)n>ve[e]&&(ve[e]=n);continue}let o=N[t];if(o<0||v[t]<=S*r.minlen)for(let t=D[i];t<D[a];t++)ve[t]=e;else for(let n=o-1;n<o+v[t]-1;n++){let r=n<o?i:n,s=n+1<o+v[t]-1?n+1:a;(O[r]!==O[s]||Math.abs(fe[r]-fe[s])>=.5)&&(ve[D[r]]=e)}}}let ye=ue+p;for(let e=0;e<=M;e++){let t=0;for(let n of re[e])A[n]>t&&(t=A[n]);ge[e]=ye,_e[e]=ye+t,ye+=t+(e===M?0:ve[e])}let be=ye+p,xe=de[l],Se=e=>s?ue+be-e:e,Ce=(e,t)=>o?Se(t):e,we=(e,t)=>o?e:Se(t),Te=+!!o;for(let t=0;t<g.length;t++){let n=e[g[t]],r=(ge[D[t]]+_e[D[t]])/2;n.x=Ce(fe[t],r),n.y=we(fe[t],r)}for(let t=0;t<c.length;t++){let n=e[c[t]],r=(de[t]+de[t+1])/2,i=de[t+1]-de[t];n.x=o?be/2:r,n.y=o?r:be/2,n.w=o?be:i,n.h=o?i:be,n.padTop=ue}let Ee=new Int32Array(a),De=[];for(let t=0;t<a;t++){if(!e[t].isGroup||u[t]>=0||h[t]>=0)continue;let n=0;for(let r=e[t].parent;r>=0&&n<Ckt;r=e[r].parent)n++;Ee[t]=n,De.push(t)}De.sort((e,t)=>Ee[t]-Ee[e]||e-t);let Oe=new Float64Array(a*4);for(let e=0;e<a;e++)Oe[e*4]=1/0,Oe[e*4+1]=1/0,Oe[e*4+2]=-1/0,Oe[e*4+3]=-1/0;let ke=(e,t)=>{t.x-t.w/2<Oe[e*4]&&(Oe[e*4]=t.x-t.w/2),t.y-t.h/2<Oe[e*4+1]&&(Oe[e*4+1]=t.y-t.h/2),t.x+t.w/2>Oe[e*4+2]&&(Oe[e*4+2]=t.x+t.w/2),t.y+t.h/2>Oe[e*4+3]&&(Oe[e*4+3]=t.y+t.h/2)};for(let t of g)e[t].parent>=0&&u[e[t].parent]<0&&ke(e[t].parent,e[t]);for(let t of De){let n=e[t];if(Oe[t*4]===1/0)continue;let r=Math.max(Oe[t*4+2]-Oe[t*4]+2*n.padX,n.minW);n.x=(Oe[t*4]+Oe[t*4+2])/2,n.w=r,n.y=(Oe[t*4+1]-n.padTop+Oe[t*4+3]+n.padBottom)/2,n.h=Oe[t*4+3]-Oe[t*4+1]+n.padTop+n.padBottom,n.parent>=0&&u[n.parent]<0&&ke(n.parent,n)}for(let e of t)e.route=[];for(let e=0;e<C;e++){let n=b[e],r=t[x[e]],i=n.reversed?n.head:n.tail,a=n.reversed?n.tail:n.head,o=[fe[i],_e[D[i]]-(_e[D[i]]-ge[D[i]]-A[i])/2],s=N[e];if(s>=0)for(let t=s;t<s+v[e]-1;t++)o.push(fe[t],ge[D[t]]),_e[D[t]]>ge[D[t]]&&o.push(fe[t],_e[D[t]]);o.push(fe[a],ge[D[a]]+(_e[D[a]]-ge[D[a]]-A[a])/2);let c=[];for(let e=0;e<o.length;e+=2)c.push(Ce(o[e],o[e+1]),we(o[e],o[e+1]),Te);if(n.reversed)for(let e=0,t=c.length-3;e<t;e+=3,t-=3)for(let n=0;n<2;n++){let r=c[e+n];c[e+n]=c[t+n],c[t+n]=r}r.route=c;let l=P[e];if(l>=0){let e=(ge[D[l]]+_e[D[l]])/2;r.labelX=Ce(fe[l],e),r.labelY=we(fe[l],e)}else r.labelX=(c[0]+c[c.length-3])/2,r.labelY=(c[1]+c[c.length-2])/2}for(let n of t){if(n.route.length>0||n.src===n.dst)continue;let t=e[n.src],r=e[n.dst],[i,a]=jkt(t,r),[o,s]=jkt(r,t),c=+(Math.abs(o-i)>Math.abs(s-a));n.route=[i,a,c,o,s,c],n.labelX=(i+o)/2,n.labelY=(a+s)/2}let Ae=new Uint8Array(C),je=t.reduce((e,t)=>e+t.route.length/3,0),Me=C*(g.length+t.length+je);if(Me<=c0){let e=e=>(ge[D[e]]+_e[D[e]])/2,n=t.map(e=>[o?e.labelY:e.labelX,Se(o?e.labelX:e.labelY)]),r=(e,t,n,r,i,a,o,s)=>n>i-o/2&&e<i+o/2&&r>a-s/2&&t<a+s/2,i=(i,a,s,c,l,u,d)=>{for(let t=0;t<g.length;t++)if(t!==l&&t!==u&&r(i,a,s,c,fe[t],e(t),k[t]+8,A[t]+8))return!1;for(let e=0;e<t.length;e++){let l=t[e];if(e!==d&&l.labelW>0&&l.src!==l.dst&&r(i,a,s,c,n[e][0],n[e][1],o?l.labelH:l.labelW,o?l.labelW:l.labelH))return!1}return!0},a=(e,n,r,i,a)=>{let o=0;for(let s=0;s<t.length;s++){if(s===a)continue;let c=t[s].route;for(let t=3;t<c.length;t+=3)if(Math.max(c[t-3],c[t])>e&&Math.min(c[t-3],c[t])<r&&Math.max(c[t-2],c[t+1])>n&&Math.min(c[t-2],c[t+1])<i){o++;break}}return o},s=(e,n,r)=>{let i=0;for(let a=0;a<t.length;a++){let o=t[a].route;if(a===r||o.length===0)continue;let s=o.length-3;(Math.abs(o[0]-e)<1&&Math.abs(o[1]-n)<1||Math.abs(o[s]-e)<1&&Math.abs(o[s+1]-n)<1)&&i++}return i},c=(e,n,r,i,a)=>{let o=Math.abs(r-e)<.5,s=o?Math.min(n,i):Math.min(e,r),c=o?Math.max(n,i):Math.max(e,r),l=o?e:n;for(let e=0;e<t.length;e++){let n=t[e];if(e===a||n.src===t[a].src||n.dst===t[a].dst)continue;let r=n.route;for(let e=3;e<r.length;e+=3){let t=r[e-3+ +!o],n=r[e+ +!o];if(Math.abs(t-l)>=wkt||Math.abs(n-l)>=wkt)continue;let i=r[e-3+ +!!o],a=r[e+ +!!o];if(Math.min(c,Math.max(i,a))-Math.max(s,Math.min(i,a))>1)return!0}}return!1};for(let r=0;r<C;r++){let o=b[r],l=x[r],u=t[l],f=o.tail,p=o.head;if(O[f]===O[p]||Math.abs(fe[p]-fe[f])<1)continue;let h=fe[f],g=fe[p],_=e(f),v=e(p),y=Math.sign(g-h),S=Math.sign(v-_),C=(e,t)=>{for(let n=2;n<e.length;n+=2)if(!i(Math.min(e[n-2],e[n])-t,Math.min(e[n-1],e[n+1])-t,Math.max(e[n-2],e[n])+t,Math.max(e[n-1],e[n+1])+t,f,p,l)||c(Ce(e[n-2],e[n-1]),we(e[n-2],e[n-1]),Ce(e[n],e[n+1]),we(e[n],e[n+1]),l))return!1;let s=0,d=0,m=-1;if(u.labelW>0){let t=o.labelW,n=o.labelH;for(let r=2;r<e.length;r+=2){let o=(e[r-2]+e[r])/2,c=(e[r-1]+e[r+1])/2,f=Math.abs(e[r]-e[r-2]),p=Math.abs(e[r+1]-e[r-1]),h=f+p;if(h<=m||(f>0?f<t+8:p<n+8)||o-t/2<0||o+t/2>xe||c-n/2<0||c+n/2>be||!i(o-t/2,c-n/2,o+t/2,c+n/2,-1,-1,l))continue;let g=Ce(o,c),_=we(o,c);a(g-u.labelW/2,_-u.labelH/2,g+u.labelW/2,_+u.labelH/2,l)>0||(s=o,d=c,m=h)}if(m<0)return!1}let h=[e[0],e[1]];for(let t=2;t<e.length;t+=2){let n=e[t]-e[t-2],r=e[t+1]-e[t-1],i=Math.abs(n)+Math.abs(r),a=t>2?l0:0,o=t+2<e.length?l0:0;i>a+o+1&&(a&&h.push(e[t-2]+n/i*a,e[t-1]+r/i*a),o&&h.push(e[t]-n/i*o,e[t+1]-r/i*o)),h.push(e[t],e[t+1])}u.route=[];for(let e=0;e<h.length;e+=2){let t=e===0?h[0]!==h[2]:h[e]!==h[e-2];u.route.push(Ce(h[e],h[e+1]),we(h[e],h[e+1]),t?1-Te:Te)}return u.labelW>0&&(u.labelX=Ce(s,d),u.labelY=we(s,d),n[l]=[s,d]),Ae[r]=1,!0};if(C([h+y*k[f]/2,_,g,_,g,v-S*A[p]/2],2)||C([h,_+S*A[f]/2,h,v,g-y*k[p]/2,v],2)||Me>c0/Ekt)continue;let w=[];for(let e of O[f]<O[p]?[O[p],O[f]]:[O[f],O[p]]){let t=Math.max(d[e]-Okt,Math.min(d[e]/2,Dkt-Okt));for(let n of[de[e]+t,de[e+1]-t]){if(Math.abs(n-h)<k[f]/2+4||Math.abs(n-g)<k[p]/2+4)continue;let t=[h+Math.sign(n-h)*k[f]/2,_,n,_,n,v,g+Math.sign(n-g)*k[p]/2,v],r=(s(Ce(t[0],t[1]),we(t[0],t[1]),l)+s(Ce(t[6],t[7]),we(t[6],t[7]),l))*1e6;for(let e=2;e<t.length;e+=2){let n=Ce(t[e-2],t[e-1]),i=we(t[e-2],t[e-1]),o=Ce(t[e],t[e+1]),s=we(t[e],t[e+1]);r+=a(Math.min(n,o),Math.min(i,s),Math.max(n,o),Math.max(i,s),l)*1e6+Math.abs(o-n)+Math.abs(s-i)}w.push({pts:t,cost:r,lane:e})}}w.sort((e,t)=>e.cost-t.cost);for(let e of w)if(C(e.pts,1)){m[e.lane]=1;break}}}return{width:o?be:xe,height:o?xe:be,routed:Ae,margins:m,work:Me}},E=new Uint8Array(C),D=new Uint8Array(l),O=T(E,D);for(let e=0;e<Tkt&&O.work<=c0/Ekt;e++){let t=e===0?O.routed:E.map((e,t)=>e&O.routed[t]);if(t.every((e,t)=>e===E[t])&&O.margins.every((e,t)=>e===D[t]))break;E=t,D=O.margins,O=T(E,D)}return E.some((e,t)=>e&&!O.routed[t])&&(O=T(new Uint8Array(C),new Uint8Array(l))),{width:O.width,height:O.height}}function jkt(e,t){let n=t.x-e.x,r=t.y-e.y,i=Math.max(e.w/2,.5),a=Math.max(e.h/2,.5);if(Math.abs(n)<i&&Math.abs(r)<a)return i-Math.abs(n)<a-Math.abs(r)?[e.x+(n<0?-i:i),t.y]:[t.x,e.y+(r<0?-a:a)];let o=Math.min(n===0?1/0:i/Math.abs(n),r===0?1/0:a/Math.abs(r));return[e.x+n*o,e.y+r*o]}var Mkt=`__swimlane_default__`;function Nkt(e){let t=!1;for(let n of e.nodes)n.isGroup?n.dir=void 0:n.parentId===void 0&&(t=!0);if(t){for(let t of e.nodes)!t.isGroup&&t.parentId===void 0&&(t.parentId=Mkt);e.nodes.push({id:Mkt,label:void 0,labelType:`text`,shape:`rect`,isGroup:!0,parentId:void 0,cssStyles:[],cssCompiledStyles:[],cssClasses:``,dir:void 0})}}function Pkt(e,t,n,r,i,a,o){let s=e.x-e.w/2,c=e.y-e.h/2,l=a===`LR`||a===`RL`,u=l?s+e.padTop/2:e.x,d=l?e.y:c+e.padTop/2,f=gq(t,u,d,` class="pele-cluster-label" fill="var(--_m)"${n.text}`,o);return`<g class="pele-cluster pele-lane${r}" data-id="${i}"><rect x="${K(s)}" y="${K(c)}" width="${K(e.w)}" height="${K(e.h)}" fill="none" stroke="var(--_b)"/><rect x="${K(s)}" y="${K(c)}" width="${K(l?e.padTop:e.w)}" height="${K(l?e.h:e.padTop)}" fill="var(--_a)" stroke="var(--_b)"${n.shape}/>`+(l&&f?`<g transform="rotate(-90 ${K(u)} ${K(d)})">${f}</g>`:f)+`</g>`}var Fkt={type:`swimlane`,prepare:Nkt,layout:(e,t,n,r,i)=>Akt(e,t,n,r,i?12:void 0),drawGroup:Pkt},Ikt={type:`swimlane`,parse:jxt.parse,render:(e,t,n)=>kxt(e,t,n,Fkt)},Lkt=class{type=`timeline`;title;accTitle;accDescr;direction=`LR`;sections=[];periods=[];currentSection=``;getCommonDb(){return this}setDiagramTitle(e){this.title=e}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,``)}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
1059
|
+
`)}setDirection(e){this.direction=e}addSection(e){this.currentSection=e,this.sections.push(e)}addTask(e,t,n){this.periods.push({text:e,events:n?[n]:[],section:this.currentSection,sectionIndex:this.sections.length-1})}addEvent(e){let t=this.periods[this.periods.length-1];if(!t)throw new NK(`An event needs a time period before it.`,`semantic`,{type:`timeline`});t.events.push(e)}},Rkt=[`$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`];function zkt(e){let t=e.length,n=[],r=[],i=[],a={types:n,texts:r,starts:i},o=0,s=(t,a)=>{n.push(t),r.push(e.slice(o,a)),i.push(o),o=a};for(;o=qCt(e,o),!(o>=t);){let n=e.charCodeAt(o),r=o+1;if(n===10){for(;e.charCodeAt(r)===10;)r++;s(3,r)}else{if(HQ(e,o,`timeline`)){for(r=o+8;e.charCodeAt(r)===32||e.charCodeAt(r)===9;)r++;let t=HQ(e,r,`lr`);if(r>o+8&&(t||HQ(e,r,`td`))&&!aq(e.charCodeAt(r+2))){s(t?5:6,r+2);continue}if(!aq(e.charCodeAt(o+8))){s(4,o+8);continue}}if(HQ(e,o,`title`)&&eq(e.charCodeAt(o+5))&&o+6<t&&e.charCodeAt(o+6)!==10)s(7,VQ(e,o+6));else if(r=JCt(e,o,a,8),r!==o)o=r;else{if(HQ(e,o,`section`)&&eq(e.charCodeAt(o+7))){for(r=o+8;r<t&&e.charCodeAt(r)!==58&&e.charCodeAt(r)!==10;)r++;if(r>o+8){s(13,r);continue}}if(n!==58){r=o+1;for(let n=e.charCodeAt(r);r<t&&n!==35&&n!==58&&n!==10;n=e.charCodeAt(++r));s(14,r)}else{if(eq(e.charCodeAt(o+1))){for(r=o+2;r<t;r++){let t=e.charCodeAt(r);if(t===10||t===58&&eq(e.charCodeAt(r+1)))break}if(r>o+2){s(15,r);continue}}s(2,o+1)}}}}return(i.length===0||i[i.length-1]<t)&&s(1,t),s(0,t),a}var Bkt=`'EOF', 'SPACE', 'NEWLINE', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'section', 'period', 'event'`;function Vkt(e,t){let{types:n,texts:r,starts:i}=zkt(e),a=(t,r)=>{let a=n[t]===0?`1`:Rkt[n[t]];throw FK(`timeline`,e,i[t],`Expecting ${r}, got '${a}'`)},o=n[0];o!==4&&o!==5&&o!==6&&a(0,`'timeline', 'timeline_lr', 'timeline_td'`),o!==4&&t.setDirection(o===5?`LR`:`TD`);for(let e=1;;e++){let i=r[e];switch(n[e]){case 3:break;case 7:t.getCommonDb().setDiagramTitle(i.substring(6));break;case 8:t.getCommonDb().setAccTitle(r[++e].trim());break;case 10:t.getCommonDb().setAccDescription(r[++e].trim());break;case 12:t.getCommonDb().setAccDescription(i.trim());break;case 13:t.addSection(i.substring(8));break;case 14:t.addTask(i,0,``);break;case 15:t.addEvent(i.substring(2));break;case 1:return;default:a(e,Bkt)}}}var u0=12,Hkt=8,Ukt=152,Wkt=216,Gkt=264,d0=20,f0=20,p0=14,m0=8,h0=8,g0=12,Kkt=` fill="var(--_bg)"`,qkt=` fill="none" stroke="var(--_b)"`;function _0(e,t,n,r,i){return`<rect x="${K(e)}" y="${K(t)}" width="${K(n)}" height="${K(r)}" rx="${dJ}"${i}/>`}function Jkt(e,t,n){return e.direction===`TD`?Ykt(e,t,n,!0):qJ(n,r=>Ykt(e,t,n,r))}function Ykt(e,t,n,r){let i=n.fontSize??16,a=Math.round(i*.875),o=n.measurer??fq(n.fontFamily),s=n.padding??8,c=t.timeline?.disableMulticolor!==!0,l=e.periods,u=e.sections.length>0,d=e.sections.map((e,t)=>({section:t,periods:[]})),f={section:-1,periods:[]};l.forEach((e,t)=>(d[e.sectionIndex]??f).periods.push(t)),f.periods.length>0&&d.unshift(f);let p=r&&n.maxWidth!==void 0&&n.maxWidth>0?n.maxWidth-2*s:1/0,m=f0+p0*2+4*u0,h=Math.min(Ukt,Math.max(80,Math.round((p-m)*.38))),g=Math.min(Gkt,Math.max(110,p-m-h)),_=h,v=()=>r?g:_,y=l.map(e=>EQ(e.text,o,i,_)),b=l.map(e=>e.events.map(e=>EQ(e,o,a,v()))),x=0;for(let e of y)x=Math.max(x,e.width);if(!r)for(let e of b)for(let t of e)x=Math.max(x,t.width);let S=x>_;if(r)for(let e of b)for(let t of e)S||=t.width>g;S&&(_=Math.min(Math.max(Math.ceil(x),h),p===1/0?Wkt:h),y=l.map(e=>DQ(e.text,o,i,_)),b=l.map(e=>e.events.map(e=>DQ(e,o,a,v()))));let C=Math.round(i*1.5),w=_+2*u0,T=v()+2*u0,E=e=>Math.max(e.height,C)+2*Hkt,D=e=>Math.max(e.height,Math.round(a*1.5))+2*Hkt,O=(e,t)=>e.section>=0?hJ(e.section):u?`var(--_m)`:hJ(c?t:0),k=!1;for(let e of b)e.length>0&&(k=!0);let A=0;for(let e of d)A+=Math.max(e.periods.length,1);let j=w+d0,M=l.length>0,N=r?w+(k?f0+p0*2+T:M?f0+g0:0):A>0?A*j-d0+(M?g0+rJ:0):0,P=DQ(e.title,o,i,Math.max(N,320),1),F=P.height>0?P.height+16:0,ee=Math.max(N,P.width),te=s+(ee-N)/2,I=s+F,ne=(t,n)=>DQ(e.sections[t.section],o,i,n-2*u0,1),re=(e,t,n,r,i,a)=>_0(n,r,i,a,` fill="${hJ(e.section)}"`)+gq(t,n+i/2,r+a/2,` font-weight="var(--_hw)"`+Kkt),ie=(e,t,n,r,i)=>_0(n,r,w,i,` fill="${t}"`)+gq(y[e],n+w/2,r+i/2,Kkt),ae=(e,t,n,r,i)=>`<g class="pele-node pele-event">`+_0(n,r,T,i,` fill="${t}" fill-opacity="0.16"`)+gq(e,n+T/2,r+i/2,` font-size="${a}"`)+`</g>`,L=(e,t,n)=>`<circle class="pele-dot" cx="${K(e)}" cy="${K(t)}" r="4" fill="${n}" stroke="var(--_bg)" stroke-width="2"/>`,oe=t=>t.section>=0?`<g class="pele-cluster pele-section" data-id="${mq(e.sections[t.section].trim())}">`:``,se=e=>`<g class="pele-node pele-period" data-id="${mq(l[e].text.trim())}">`,ce=``,le;if(r){let e=te+w+f0,t=e+p0,n=t+p0,r=I;for(let i of d){if(ce+=oe(i),i.section>=0){let e=ne(i,N),t=E(e);ce+=re(i,e,te,r,N,t),r+=t+h0+4}for(let a of i.periods){let o=O(i,a),s=E(y[a]),c=r+s/2,l=`M${K(te+w)},${K(c)}H${K(e)}`,u=``,d=r,f=c;for(let e of b[a]){let r=D(e);f=d+r/2,l+=`M${K(t)},${K(f)}H${K(n)}`,u+=ae(e,o,n,d,r),d+=r+m0}u&&(l+=`M${K(e)},${K(c)}H${K(t)}V${K(f)}`),ce+=se(a)+ie(a,o,te,r,s)+`<path class="pele-edge" d="${l}"${qkt}/>`+L(e,c,o)+u+`</g>`,r=Math.max(r+s,d-m0)+d0}i.periods.length===0&&(r+=d0-h0-4),i.section>=0&&(ce+=`</g>`)}if(d.length>0&&(r-=d0),M){let t=r+g0+rJ;ce=`<path class="pele-axis" d="M${K(e)},${K(I)}V${K(t-rJ+1)}" fill="none" stroke="var(--_l)"/>`+cJ(`arrow_point`,e,t,0,1,`var(--_l)`)+ce,r=t}le=r+s}else{let e=0,t=d.map(t=>{if(t.section<0)return;let n=ne(t,Math.max(t.periods.length,1)*j-d0);return e=Math.max(e,E(n)),n}),n=0;for(let e of y)n=Math.max(n,E(e));let r=I+(u?e+h0:0),i=r+n+(n>0?f0:0),a=i+f0,o=M?i+g0:I+e,c=0;if(d.forEach((s,l)=>{let u=Math.max(s.periods.length,1),d=te+c*j;ce+=oe(s);let f=t[l];f&&(ce+=re(s,f,d,I,u*j-d0,e)),s.periods.forEach((e,t)=>{let c=O(s,e),l=d+t*j,u=l+w/2,f=`M${K(u)},${K(r+n)}V${K(b[e].length>0?a:i)}`,p=``,m=a;for(let t of b[e]){let e=D(t);m>a&&(f+=`M${K(u)},${K(m-m0)}V${K(m)}`),p+=ae(t,c,l,m,e),m+=e+m0}o=Math.max(o,m-m0),ce+=se(e)+ie(e,c,l,r,n)+`<path class="pele-edge" d="${f}"${qkt}/>`+L(u,i,c)+p+`</g>`}),s.section>=0&&(ce+=`</g>`),c+=u}),M){let e=te+N;ce=`<path class="pele-axis" d="M${K(te)},${K(i)}H${K(e-rJ+1)}" fill="none" stroke="var(--_l)"/>`+cJ(`arrow_point`,e,i,1,0,`var(--_l)`)+ce}le=o+s}let ue=Math.ceil(ee+2*s),de=Math.ceil(Math.max(le,s*2));return{svg:_J(`timeline`,ue,de,i,n,e,gq(P,ue/2,s+P.height/2,` class="pele-title" font-weight="var(--_tw)"`)+ce),width:ue,height:de,links:[]}}var Xkt={type:`timeline`,parse(e,t,n){let r=new Lkt;return r.title=n,Vkt(e,r),r},render:Jkt},v0=/[─━│┃└┗├┣]/,Zkt=/[└┗├┣]/,Qkt=/[─━]/,$kt=/^[\s│┃]+$/,eAt=/^[\s─━│┃└┗├┣]+$/,tAt=/^\s*(title[\t ]|accTitle[\t ]*:|accDescr[\t ]*[:{])/,nAt=/^\s*%%/,rAt=` `;function iAt(e){return e.some(e=>v0.test(e))}function aAt(e){for(let t of e){let e=Zkt.exec(t);if(e?.index&&e.index>0)return e.index}return 4}function oAt(e,t){return e.replace(/\bline\s+(\d+)\b/gi,(e,n)=>{let r=t.get(parseInt(n,10));return r?`line ${r}`:e})}function sAt(e,t){throw new NK(`Line ${e}: ${t}`,`syntax`,{type:`treeView`,line:e})}function cAt(e){let t=/* @__PURE__ */ new Map;if(!v0.test(e))return{text:e,lineMap:t};let n=e.split(`
|
|
1060
1060
|
`),r=-1;for(let e=0;e<n.length;e++)if(n[e].trim()===`treeView-beta`){r=e;break}if(r===-1)return{text:e,lineMap:t};let i=e=>e.trim()===``||nAt.test(e)||tAt.test(e),a=[];for(let e=r+1;e<n.length;e++){let t=n[e];i(t)||$kt.test(t)||a.push(t.replace(/\t/g,` `))}if(!iAt(a))return{text:e,lineMap:t};let o=aAt(a),s=[],c=(e,n)=>{s.push(e),t.set(s.length,n+1)};for(let e=0;e<=r;e++)c(n[e],e);for(let e=r+1;e<n.length;e++){let t=n[e];if(i(t)){c(t,e);continue}if($kt.test(t))continue;let r=t.replace(/\t/g,` `),a=Zkt.exec(r);if(a){let t=Math.round(a.index/o)+1,n=a.index+1;for(;n<r.length&&Qkt.test(r[n]);)n++;for(;n<r.length&&r[n]===` `;)n++;let i=r.slice(n).trimEnd();i||sAt(e+1,`Empty node — expected a filename or directory name after the box-drawing prefix`),c(rAt.repeat(t)+i,e)}else{if(eAt.test(r))continue;v0.test(r)?c(t,e):/^\s+/.test(r)?sAt(e+1,`Unexpected indentation without box-drawing characters. In box-drawing format, use ├── or └── prefixes for indented nodes.`):c(t,e)}}return{text:s.join(`
|
|
1061
|
-
`),lineMap:t}}function lAt(e,t){if(e.startsWith(`##`,t)||e.startsWith(`icon(`,t))return!0;if(!e.startsWith(`:::`,t))return!1;let n=t+3;for(;tq(e.charCodeAt(n));)n++;let r=e.charCodeAt(n);return r>=65&&r<=90||r>=97&&r<=122||r===95}function uAt(e,t){let n=e.charCodeAt(t);if(tq(n)||n===10||n===13||n===34||n===39||e.startsWith(`:::`,t)||e.startsWith(`icon(`,t)||e.startsWith(`##`,t))return-1;let r=e.length,i=t+1;for(;i<r;){let t=e.charCodeAt(i);if(t===10||t===13)break;if(tq(t)){let t=i+1;for(;tq(e.charCodeAt(t));)t++;if(lAt(e,t))break;i=t}else i++}return i}var dAt={name:`BARE_NAME`,pattern:/(?!:::|icon\(|##)[^ \t\n\r"'](?:(?![ \t]+:::[ \t]*[A-Za-z_]|[ \t]+icon\(|[ \t]+##)[^\n\r])*/y,match:uAt},fAt=[{...
|
|
1061
|
+
`),lineMap:t}}function lAt(e,t){if(e.startsWith(`##`,t)||e.startsWith(`icon(`,t))return!0;if(!e.startsWith(`:::`,t))return!1;let n=t+3;for(;tq(e.charCodeAt(n));)n++;let r=e.charCodeAt(n);return r>=65&&r<=90||r>=97&&r<=122||r===95}function uAt(e,t){let n=e.charCodeAt(t);if(tq(n)||n===10||n===13||n===34||n===39||e.startsWith(`:::`,t)||e.startsWith(`icon(`,t)||e.startsWith(`##`,t))return-1;let r=e.length,i=t+1;for(;i<r;){let t=e.charCodeAt(i);if(t===10||t===13)break;if(tq(t)){let t=i+1;for(;tq(e.charCodeAt(t));)t++;if(lAt(e,t))break;i=t}else i++}return i}var dAt={name:`BARE_NAME`,pattern:/(?!:::|icon\(|##)[^ \t\n\r"'](?:(?![ \t]+:::[ \t]*[A-Za-z_]|[ \t]+icon\(|[ \t]+##)[^\n\r])*/y,match:uAt},fAt=[{...mY(`treeView-beta`),longer:[dAt]},gZ(),oY,sY,{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},dAt];function pAt(e){let t=e.length;for(;t>0&&tq(e.charCodeAt(t-1));)t--;return t===e.length?e:e.slice(0,t)}function y0(e,t){switch(e){case`INDENTATION`:return t?.length||0;case`QUOTED_NAME`:return t.substring(1,t.length-1);case`BARE_NAME`:return pAt(t);case`CLASS_ANNOTATION`:return t.trim().substring(3).trim();case`ICON_ANNOTATION`:{let e=t.trim();return e.substring(5,e.length-1)}case`DESC_ANNOTATION`:return t.trim().substring(2).trim();default:return}}function mAt(e){let t=new bY(iY(e,fAt,`treeView`),fAt,`treeView`),n={$type:`TreeView`,nodes:[]};for(t.expect(0);;)if(t.kind===1)n.accDescr=vY(t.take());else if(t.kind===2)n.accTitle=_Y(t.take());else if(t.kind===3)n.title=gY(t.take());else break;for(;t.kind!==-1;){let e={$type:`TreeNode`,name:``};if(t.kind===7&&(e.indent=t.take().length),t.kind===8){let n=t.take();e.name=n.substring(1,n.length-1)}else t.kind===12?e.name=pAt(t.take()):t.fail(`a name`);for(;;)if(t.kind===4)e.classAnnotation=y0(`CLASS_ANNOTATION`,t.take());else if(t.kind===5)e.iconAnnotation=y0(`ICON_ANNOTATION`,t.take());else if(t.kind===6)e.descAnnotation=y0(`DESC_ANNOTATION`,t.take());else break;n.nodes.push(e)}return n}var hAt=class{count=1;root={id:0,level:-1,name:`/`,nodeType:`directory`,children:[]};stack=[this.root];addNode(e,t,n,r,i,a){let o=this.stack;for(;e<=o[o.length-1].level;)o.pop();let s={id:this.count++,level:e,name:t,nodeType:n,icon:i,cssClass:r,description:a,children:[]};o[o.length-1].children.push(s),o.push(s)}};function gAt(e,t){for(let n of e.nodes){let e=typeof n.indent==`number`?n.indent:0,r=n.name,i=r.endsWith(`/`);i&&(r=r.slice(0,-1));let a=n.iconAnnotation;t.addNode(e,r,i?`directory`:`file`,n.classAnnotation||void 0,a===void 0?void 0:a||`none`,n.descAnnotation||void 0)}}function _At(e){let{text:t,lineMap:n}=cAt(e);try{return mAt(t)}catch(e){if(n.size===0||!(e instanceof NK))throw e;let t=e.message.indexOf(`
|
|
1062
1062
|
`);throw new NK(t===-1?oAt(e.message,n):oAt(e.message.slice(0,t),n)+e.message.slice(t),e.code,{type:e.type,line:n.get(e.line)??e.line,column:e.column,snippet:e.snippet})}}function vAt(e,t){let n=new hAt;return gAt(e,n),{type:`treeView`,title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,``):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
|
|
1063
|
-
`):void 0,root:n.root,count:n.count}}var b0=`mermaid-treeview`,x0=/* @__PURE__ */ 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 S0(e,t){if(e===void 0||!Object.prototype.hasOwnProperty.call(e,t))return;let n=e[t];return typeof n==`string`?n:void 0}function yAt(e,t){let n=S0(t?.filenameIcons,e);if(n)return n;let r=e.lastIndexOf(`.`);if(r>0){let n=e.substring(r).toLowerCase();return S0(t?.extensionIcons,n)??S0(t?.extensionIcons,n.slice(1))}}function bAt(e,t){return e.includes(`:`)?e:x0.has(e)||!t?`${b0}:${e}`:`${t}:${e}`}function xAt(e,t){if(e.icon!==`none`){if(e.icon)return bAt(e.icon,t.defaultIconPack);if(t.showIcons){if(e.nodeType===`file`){let n=yAt(e.name,t);if(n===`none`)return;if(n)return bAt(n,t.defaultIconPack)}return`${b0}:${e.nodeType===`directory`?`folder`:`file`}`}}}function SAt(e){let t=e=>typeof e==`object`&&e&&!Array.isArray(e)?e:void 0,n=t(e.treeView)??{};return{showIcons:!!n.showIcons,defaultIconPack:typeof n.defaultIconPack==`string`?n.defaultIconPack:``,filenameIcons:t(n.filenameIcons),extensionIcons:t(n.extensionIcons)}}var CAt=6,wAt=16,TAt=7,EAt=4,C0=4;function w0(e,t,n,r,i){let a=e.treeView?.[t];return typeof a==`number`&&a>=r&&a<=i?a:n}function DAt(e){return{paddingX:w0(e,`paddingX`,5,0,100),paddingY:w0(e,`paddingY`,2,0,100),rowIndent:w0(e,`rowIndent`,15,0,400),lineThickness:w0(e,`lineThickness`,1,.25,12)}}function OAt(e,t,n){return
|
|
1064
|
-
`):void 0,roots:jAt(r),classes:n}}var NAt=[oY,sY,cY,{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}],PAt=/classDef\s+([A-Z_a-z]\w+)(?:\s+([^\n\r;]*))?;?/;function FAt(e){let t=new xY(aY(e,NAt,`treemap`),NAt,`treemap`),n=t.kinds,r={$type:`Treemap`,TreemapRows:[]},i=()=>t.accept(5)?t.expect(12):void 0;for(t.expect(3);t.kind!==-1;){let e=t.kind;if(e===0){r.accDescr=yY(t.take());continue}if(e===1){r.accTitle=vY(t.take());continue}if(e===2){r.title=_Y(t.take());continue}e!==8&&e!==14&&e!==4&&t.fail(`a node, a class definition, or a title`);let a=e===8?t.take().length:void 0;if(t.kind===4){let e=PAt.exec(t.take()),n={$type:`ClassDefStatement`,className:e[1]};e[2]&&(n.styleText=e[2]),a!==void 0&&(n.indent=a),r.TreemapRows.push(n);continue}let o=t.expect(14).slice(1,-1),s=n[t.i]===8?t.i+1:t.i,c;n[s]===6||n[s]===7?(t.i=s+1,t.accept(8),c={$type:`Leaf`,name:o,value:parseFloat(t.expect(13).replace(/,/g,``))}):c={$type:`Section`,name:o};let l=i();l!==void 0&&(c.classSelector=l);let u={$type:`TreemapRow`,item:c};a!==void 0&&(u.indent=a),r.TreemapRows.push(u)}return r}var IAt=/^(?:.?[<>=^])?([-+( ])?(\$)?0?\d*(,)?(?:\.(\d+))?(~)?([a-zA-Z%])?$/;function LAt(e){let t=``;for(let n=e.length;n>0;n-=3)t=e.slice(Math.max(0,n-3),n)+(t?`,`+t:``);return t}function RAt(e){let t=IAt.exec(e===`$0,0`?`$,`:e)??IAt.exec(`,`),n=t[1]===`+`,r=t[3]!==void 0,i=t[4]===void 0?void 0:Math.min(Number(t[4]),20),a=t[6]??``;return e=>{let o=Math.abs(e),s,c=``;if(a===`f`?s=o.toFixed(i??6):a===`%`?(s=(o*100).toFixed(i??6),c=`%`):s=a===`d`?Math.round(o).toFixed(0):a===`e`?o.toExponential(i??6):String(Number(o.toPrecision(Math.max(1,i??12)))),t[5]&&s.includes(`.`)&&!s.includes(`e`)&&(s=s.replace(/\.?0+$/,``)),r&&!s.includes(`e`)){let e=s.indexOf(`.`);s=e===-1?LAt(s):LAt(s.slice(0,e))+s.slice(e)}return(e<0?`-`:n?`+`:``)+(t[2]??``)+s+c}}function zAt(e,t,n){return{node:e,parent:t,series:n,value:e.children===void 0&&Number.isFinite(e.value)&&e.value>0?e.value:0,children:[],x:0,y:0,w:0,h:0}}function BAt(e,t,n,r,i,a,o){let s=t,c=0;for(;c<e.length;){let t=i*a/s,l=Math.min(i,a),u=e[c].value*t,d=u,f=Math.max(l*l*d/(u*u),u*u/(l*l*d)),p=c+1;for(;p<e.length;){let n=e[p].value*t,r=u+n,i=Math.max(l*l*d/(r*r),r*r/(l*l*n));if(i>f)break;f=i,u=r,p++}let m=u/l,h=0;for(let u=c;u<p;u++){let c=e[u],d=u===p-1?l-h:c.value*t/m,f=i>=a?n:n+h,g=i>=a?r+h:r,_=Math.round(f+o/2),v=Math.round(g+o/2);c.x=_,c.y=v,c.w=Math.round(f+(i>=a?m:d)-o/2)-_,c.h=Math.round(g+(i>=a?d:m)-o/2)-v,h+=d,s-=c.value}i>=a?(n+=m,i-=m):(r+=m,a-=m),c=p}}function VAt(e,t,n,r){let i=e.map((e,t)=>zAt(e,void 0,t)),a=i.slice();for(let e=0;e<a.length;e++){let t=a[e];for(let e of t.node.children??[]){let n=zAt(e,t,t.series);t.children.push(n),a.push(n)}}for(let e=a.length-1;e>=0;e--){let t=a[e];t.parent&&(t.parent.value+=t.value)}let{gap:o,header:s,side:c}=r,l=[],u=(e,t,n,r,i)=>{if(r<=0||i<=0)return;let a=e.filter(e=>e.value>0).sort((e,t)=>t.value-e.value),s=0;for(let e of a)s+=e.value;if(a.length!==0&&Number.isFinite(s)){BAt(a,s,t-o/2,n-o/2,r+o,i+o,o);for(let e of a)e.w>0&&e.h>0&&l.push(e)}};u(i,0,0,t,n);for(let e=0;e<l.length;e++){let t=l[e];t.children.length>0&&u(t.children,t.x+c,t.y+s,t.w-2*c,t.h-s-c)}return l}var T0=28,E0=6,D0=1.25;function O0(e,t,n,r,i){let a=e.treemap?.[t];return typeof a==`number`&&a>=r?Math.min(a,i):n}function HAt(e,t,n){let r=n.fontSize??16,i=Math.round(r*.875),a=Math.round(r*.75),o=Math.round(r*.5625),s=n.measurer??fq(n.fontFamily),c=t.treemap??{},l=n.padding??O0(t,`diagramPadding`,8,0,2e3),u=Math.round(qJ(n,O0(t,`nodeWidth`,64,1,400)*10,200,2*l)),d=Math.round(O0(t,`nodeHeight`,40,1,400)*10),f=c.showValues!==!1,p=RAt(typeof c.valueFormat==`string`?c.valueFormat:`,`),m=VAt(e.roots,u,d,{gap:O0(t,`padding`,4,0,200),header:T0,side:E0}),h=WJ(e.title,!1,s,r,KJ(n),1),g=h.height>0?h.height+8:0,_=l+Math.max(0,(h.width-u)/2),v=l+g,y=``,b=``;for(let e of m){let t=e.node,n=mJ(t.cssCompiledStyles??[]),c=gJ(e.series),l=_+e.x,u=v+e.y,d=RK(t.name).trim(),m=f?p(e.value):``,h=`data-id="${mq(t.name)}">`,g=`<rect x="${K(l)}" y="${K(u)}" width="${K(e.w)}" height="${K(e.h)}" rx="${fJ}" fill="${c}"`;if(t.children!==void 0){let r=``;if(e.h>=T0){let t=e.w-2*E0-4,o=m?s.width(m,a,0):0,c=o>0&&t-o-12>=3*i,f=h$(d,c?t-o-12:t,i,i,s,1),p=u+T0/2+1;f&&(r+=`<text x="${K(l+E0+2)}" y="${K(p+i*.35)}" font-weight="var(--_hw)"${n.text}>${pq(f.text)}</text>`),c&&(r+=`<text class="pele-value" x="${K(l+e.w-E0-2)}" y="${K(p+a*.35)}" font-size="${a}" text-anchor="end" fill="var(--_m)"${n.text}>${pq(m)}</text>`)}let o=/[";]fill:/.test(n.shape)?``:` fill-opacity="0.12"`;y+=`<g class="pele-node pele-section${hJ(t.classSelector??``)}" ${h}${g}${o} stroke="${c}"${n.shape}/>${r}</g>`;continue}let x=``,S=e.w-8,C=Math.min(r,Math.floor((e.h-4)/D0)),w=C>=o?h$(d,S,C,o,s):void 0;if(w){let t=K(l+e.w/2),r=u+e.h/2,i=Math.max(o,Math.round(w.size*.8)),a=(w.size+i)*D0;if(m&&a<=e.h-4&&s.width(m,i,0)<=S){let e=r-a/2+w.size*D0/2,o=r+a/2-i*D0/2;x=`<text x="${t}" y="${K(e+w.size*.35)}" font-size="${K(w.size)}"${n.text}>${pq(w.text)}</text><text class="pele-value" x="${t}" y="${K(o+i*.35)}" font-size="${K(i)}"${n.text}>${pq(m)}</text>`}else x=`<text x="${t}" y="${K(r+w.size*.35)}" font-size="${K(w.size)}"${n.text}>${pq(w.text)}</text>`}b+=`<g class="pele-node pele-leaf${hJ(t.classSelector??``)}" ${h}${g}${n.shape}/>${x}</g>`}let x=Math.ceil(Math.max(u,h.width)+2*l),S=Math.ceil(d+g+2*l);return{svg:vJ(`treemap`,x,S,r,n,e,gq(h,x/2,l+h.height/2,` class="pele-title" font-weight="var(--_tw)"`)+(y?`<g class="pele-sections" font-size="${i}">${y}</g>`:``)+(b?`<g class="pele-leaves" text-anchor="middle" fill="var(--_bg)">${b}</g>`:``)),width:x,height:S,links:[]}}var UAt={type:`treemap`,parse:(e,t,n)=>MAt(FAt(e),n),render:HAt},WAt=`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(` `),k0=1,GAt=2,A0=/* @__PURE__ */ new Uint8Array(128);for(let e=48;e<=57;e++)A0[e]=k0;for(let e=65;e<=90;e++)A0[e]=A0[e+32]=k0;A0[95]=k0;for(let e of`!#$&*+/=?^|~`)A0[e.charCodeAt(0)]=GAt;var KAt=[0,12,5,14,3,9,2,2,2,2,2,4,3,4,8,5,5,7,6,4,5];function j0(e){return e<128&&(A0[e]&k0)!==0}function M0(e,t,n){for(let r=0;r<n.length;r++)if((e.charCodeAt(t+r)|32)!==n.charCodeAt(r))return!1;return!0}function qAt(e,t,n){switch(n){case 97:return e.startsWith(`actor`,t)?2:0;case 115:return e.startsWith(`systemBoundary`,t)?3:e.startsWith(`style`,t)?16:0;case 101:return e.startsWith(`end`,t)?4:M0(e,t,`extend`)?18:0;case 69:return M0(e,t,`extend`)?18:0;case 100:return e.startsWith(`direction`,t)?5:0;case 84:return e.startsWith(`TD`,t)?6:e.startsWith(`TB`,t)?7:0;case 66:return e.startsWith(`BT`,t)?8:0;case 76:return e.startsWith(`LR`,t)?9:0;case 82:return e.startsWith(`RL`,t)?10:0;case 110:return e.startsWith(`note`,t)?11:0;case 102:return e.startsWith(`for`,t)?12:e.startsWith(`false`,t)?20:0;case 106:return e.startsWith(`json`,t)?13:0;case 99:return e.startsWith(`classDef`,t)?14:e.startsWith(`class`,t)?15:0;case 105:case 73:return M0(e,t,`include`)?17:0;case 116:return e.startsWith(`true`,t)?19:0;case 117:return+!!e.startsWith(`usecase-beta`,t);default:return 0}}function N0(e,t){let n=1,r=0;for(let i=0;i<t;i++){let a=e.charCodeAt(i);a!==10&&a!==13||(a===13&&i+1<t&&e.charCodeAt(i+1)===10&&i++,n++,r=i+1)}return[n,t-r+1]}function JAt(e,t,n){let[r,i]=N0(e,t);return`line ${r}, column ${i} [${t},${n})`}function YAt(e,t,n){for(let r=t+1;r<e.length;r++){let t=e.charCodeAt(r);if(t===n)return r+1;if(t===10||t===13)return-1}return-1}function XAt(e,t){let n=e.charCodeAt(t);return n!==34&&n!==39||n===34&&e.charCodeAt(t+1)===96||YAt(e,t,n)!==-1}function ZAt(e,t,n){let[r,i]=N0(e,t);return new NK(`Error lexing usecase diagram: unexpected character: ->${e.charAt(t)}<- at offset: ${t}, skipped ${n} characters. at line ${r}, column ${i} [${t},${t+n})`,`syntax`,{type:`usecase`,line:r,column:i})}function QAt(e){let t=[],n=[],r=[],i=e.length,a=0,o=!0,s=!1;for(;a<i;){let c=e.charCodeAt(a);if(c===32||c===9){a++;continue}let l,u=a+1,d=!1;if(c<128&&(A0[c]&k0)!==0){if(l=0,c===97&&o&&e.startsWith(`acc`,a)){let t=e.startsWith(`Descr`,a+3);if(t||e.startsWith(`Title`,a+3)){let n=a+8;for(;tq(e.charCodeAt(n));)n++;let r=e.charCodeAt(n);if(r===58)for(l=t?42:41,u=n+1;u<i&&e.charCodeAt(u)!==10&&e.charCodeAt(u)!==13;)u++;else if(r===123&&t&&!s){let t=e.indexOf(`}`,n+1);t===-1?s=!0:(l=40,u=t+1)}}}else if(c===106&&e.startsWith(`json`,a)&&tq(e.charCodeAt(a+4))){let s=a+5;for(;tq(e.charCodeAt(s));)s++;let c=s;for(;j0(e.charCodeAt(s));)s++;if(s>c){for(;tq(e.charCodeAt(s));)s++;if(e.charCodeAt(s)===64){for(s++;tq(e.charCodeAt(s));)s++;if(e.charCodeAt(s)===123){t.push(43),n.push(a),r.push(s),a=s;let c=0,l=!1,u=!1,d=s;for(;d<i;d++){let t=e.charCodeAt(d);if(l)u?u=!1:t===92?u=!0:t===34&&(l=!1);else if(t===34)l=!0;else if(t===123)c++;else if(t===125&&--c===0)break}t.push(d<i?44:45),n.push(s),a=d<i?d+1:i,r.push(a),o=!1;continue}}}}if(l===0){for(;u<i&&j0(e.charCodeAt(u));)u++;let t=qAt(e,a,c);if(t!==0)t===1||u-a===KAt[t]?(l=t,u=a+KAt[t]):l=21;else if((c===111||c===120)&&e.charCodeAt(a+1)===45&&e.charCodeAt(a+2)===45)l=c===111?56:58,u=a+3;else if(rq(c)){let t=a+1;for(;rq(e.charCodeAt(t));)t++;if(e.charCodeAt(t)===46&&rq(e.charCodeAt(t+1))){for(l=22,u=t+2;rq(e.charCodeAt(u));)u++;for(;iq(e.charCodeAt(u));)u++}else l=21}else for(l=21;e.charCodeAt(u)===45&&j0(e.charCodeAt(u+1));)for(l=27,u+=2;j0(e.charCodeAt(u));)u++}}else if(c===10)l=39,d=!0;else if(c===13)l=39,d=!0,e.charCodeAt(u)===10&&u++;else if(c===34||c===39){if(c===34&&e.charCodeAt(a+1)===96){let t=e.indexOf('`"',a+2);l=t===-1?37:36,u=t===-1?i:t+2}else if(l=35,u=YAt(e,a,c),u===-1){let t=a+1;for(;t<i&&!XAt(e,t);)t++;throw ZAt(e,a,t-a)}}else if(c===37){if(o&&e.charCodeAt(u)===37)for(l=38;u<i&&e.charCodeAt(u)!==10&&e.charCodeAt(u)!==13;)u++;else l=31}else if(c===45){if(e.charCodeAt(u)!==45)l=29;else{for(;e.charCodeAt(u)===45;)u++;let t=e.charCodeAt(u),n=u-a===2;n&&t===124&&e.charCodeAt(u+1)===62?(l=46,u+=2):t===62?(l=53,u++):n&&(t===111||t===120)?(l=t===111?55:57,u++):l=59}}else if(c===46){let t=e.charCodeAt(u);if(t===46&&e.charCodeAt(u+1)===62)l=47,u+=2;else if(rq(t)){for(l=22;rq(e.charCodeAt(u));)u++;for(;iq(e.charCodeAt(u));)u++}else l=30}else if(c===60){if(e.charCodeAt(u)===60){if(t.push(48),n.push(a),r.push(a+2),o=!1,a+=2,a>=i)break;if(e.charCodeAt(a)===62&&e.charCodeAt(a+1)===62)l=49,u=a+2;else{let o=a,s=!1;for(;o<i;o++){let t=e.charCodeAt(o);if(t===10||t===13)break;if(t===62&&e.charCodeAt(o+1)===62){s=!0;break}}if(s&&e.slice(a,o).trim()!==``)t.push(50),n.push(a),r.push(o),l=49,a=o,u=o+2;else{for(;o<i&&e.charCodeAt(o)!==10&&e.charCodeAt(o)!==13;)o++;if(o===a){for(;o<i&&(e.charCodeAt(o)===10||e.charCodeAt(o)===13);)o++;throw ZAt(e,a,o-a)}l=51,u=o}}}else if(e.charCodeAt(u)===45&&e.charCodeAt(u+1)===45)for(l=54,u+=2;e.charCodeAt(u)===45;)u++;else l=33}else if(c===58)e.charCodeAt(u)===58&&e.charCodeAt(u+1)===58?(l=52,u+=2):l=25;else if(c===64)e.charCodeAt(u)===123?(l=60,u++):l=23;else if(c===123)l=61;else if(c===125)l=62;else if(c===91)l=63;else if(c===93)l=64;else if(c===40)l=65;else if(c===41)l=66;else if(c===44)l=24;else if(c===35){for(;Hft(e.charCodeAt(u));)u++;l=u>a+1?26:32}else if(c===92)e.charCodeAt(u)===44?(l=28,u++):l=33;else if(c<127&&c>32)l=(A0[c]&GAt)===0?33:32;else for(l=34;u<i;){let t=e.charCodeAt(u);if(t>=32&&t<127||t===9||t===10||t===13)break;u++}t.push(l),n.push(a),r.push(u),a=u,o=d}for(let e=0;e<3;e++)t.push(0),n.push(i),r.push(i);return{types:t,starts:n,ends:r}}function $At(){return{type:`usecase`,actors:/* @__PURE__ */ new Map,useCases:/* @__PURE__ */ new Map,systemBoundaries:/* @__PURE__ */ new Map,relationships:[],notes:/* @__PURE__ */ new Map,jsonNodes:/* @__PURE__ */ new Map,classDefs:/* @__PURE__ */ new Map,direction:`LR`,title:void 0,accTitle:``,accDescr:``,accDescription:``,source:``,headerSpan:[0,0],statements:[]}}function ejt(){return{elements:[],boundaries:[],jsons:[],relationships:[],notes:[],metadata:[],classes:[],styles:[],classDefs:[],direction:void 0,accTitle:``,accDescription:``}}function P0(e,t){if(t.length===0)return;let n=new Set(e);for(let r of t)n.has(r)||(n.add(r),e.push(r))}function tjt(e){let t=/* @__PURE__ */ new Set([`actor`,`usecase`,`boundary`,`edge`]);for(let{key:n,value:r}of e)if(n===`icon`)t.clear(),t.add(`actor`);else if(n===`animate`||n===`animation`)t.clear(),t.add(`edge`);else if(n===`type`)t.clear(),r===`rect`||r===`package`?t.add(`boundary`):(r===`normal`||r===`hollow`||r===`awesome`)&&t.add(`actor`);else if(n===`business`)t.delete(`boundary`),t.delete(`edge`);else return;return t.size===1?[...t][0]:void 0}function njt(e,t,n,r,i){let a=$At(),{actors:o,useCases:s,systemBoundaries:c}=a,l=/* @__PURE__ */ new Map,u=/* @__PURE__ */ new Map,d=/* @__PURE__ */ new Map,f=/* @__PURE__ */ new Map,p=/* @__PURE__ */ new Map,m=t=>JAt(e,t[0],t[1]),h=(t,n)=>{let[r,i]=N0(e,n[0]);return new NK(t,`semantic`,{type:`usecase`,line:r,column:i})},g=(e,t)=>{throw h(`${e} at ${m(t)}`,t)},_=(e,t,n,r,i)=>{let a=e=>e===void 0?``:` (label "${e}")`;throw h(`${e} at ${m(t)}${a(r)}; previous declaration at ${m(n)}${a(i)}`,t)},v=(e,t,n)=>g(`Metadata property '${n.key}' is invalid for ${t} '${e}'`,n.keySpan),y=(e,t)=>{let n=p.get(e);(n===void 0||t<n)&&p.set(e,t)},b=e=>[...e].sort((e,t)=>(p.get(e.id)??0)-(p.get(t.id)??0)),x=(e,t)=>{l.set(e.id,{kind:t,span:e.span,generated:e.generated,label:e.label.text})},S=(e,t)=>{let n=l.get(e.id);if(!n)return;let r=e.generated?e.label.text:void 0,i=n.generated?n.label:void 0;n.kind!==t&&_(`ID '${e.id}' is declared as both ${n.kind} and ${t}`,e.span,n.span,r,i),(n.generated||e.generated)&&_(`Generated ID '${e.id}' collides with another declaration`,e.span,n.span,r,i)},C=(e,t,n)=>{let r=l.get(e);r&&_(`ID '${e}' is declared more than once (${r.kind} and ${t})`,n,r.span,void 0,r.generated?r.label:void 0),l.set(e,{kind:t,span:n,generated:!1})},w=(e,t,n)=>{let{key:r,value:i}=t,a=a=>{!n&&a!==void 0&&a!==i&&_(`Actor '${e.id}' has conflicting ${r} metadata`,t.keySpan,e.span)};r===`type`&&(i===`normal`||i===`hollow`||i===`awesome`)?(a(e.actorType),e.actorType=i):r===`icon`&&typeof i==`string`?(a(e.icon),e.icon=i):r===`business`&&typeof i==`boolean`?(a(e.business),e.business=i):v(e.id,`actor`,t)},T=(e,t,n)=>{for(let r of t??[])e.kind===`actor`?w(e,r,n):r.key===`business`&&typeof r.value==`boolean`?(!n&&e.business!==void 0&&e.business!==r.value&&_(`Use case '${e.id}' has conflicting business metadata`,r.keySpan,e.span),e.business=r.value):v(e.id,`usecase`,r)},E=e=>{let t;if(e.kind===`actor`){s.delete(e.id);let n={id:e.id,label:e.label.text,labelType:e.label.type,business:e.business??!1,classes:[...e.classes],type:e.icon?`icon`:e.actorType??`normal`,styles:o.get(e.id)?.styles??[]};e.icon&&(n.icon=e.icon),o.set(e.id,n),t=n}else o.delete(e.id),t={id:e.id,label:e.label.text,labelType:e.label.type,business:e.business??!1,classes:[...e.classes],shape:e.shape??`ellipse`,styles:s.get(e.id)?.styles??[]},s.set(e.id,t);e.stereotype&&(t.stereotype=e.stereotype),e.parent?.id&&(t.parentId=e.parent.id)},D=e=>{S(e,e.kind);let t=e.parent?.id?e.parent:void 0,n=u.get(e.id);if(n)(n.label.text!==e.label.text||n.label.type!==e.label.type)&&_(`ID '${e.id}' has conflicting labels`,e.span,n.span),e.shape&&n.shape&&e.shape!==n.shape&&_(`Use case '${e.id}' has conflicting shapes`,e.span,n.span),t&&n.parent?.id&&t.id!==n.parent.id&&_(`Element '${e.id}' belongs to more than one system boundary`,t.span,n.parent.span),e.stereotype&&n.stereotype&&e.stereotype!==n.stereotype&&_(`Element '${e.id}' has conflicting stereotypes`,e.span,n.stereotypeSpan??n.span),n.shape??=e.shape,n.parent??=e.parent,n.stereotype??=e.stereotype,n.stereotypeSpan??=e.stereotype?e.span:void 0,P0(n.classes,e.classes),T(n,e.metadata,!1);else{let n={kind:e.kind,id:e.id,label:e.label,span:e.span,generated:e.generated,classes:[...e.classes],parent:t,shape:e.shape,stereotype:e.stereotype,stereotypeSpan:e.stereotype?e.span:void 0};T(n,e.metadata,!1),u.set(e.id,n),x(e,e.kind)}},O=e=>{S(e,`boundary`);let t=d.get(e.id);t?((t.label.text!==e.label.text||t.label.type!==e.label.type)&&_(`Boundary '${e.id}' has conflicting titles`,e.span,t.span),P0(t.classes,e.classes)):(d.set(e.id,{...e,classes:[...e.classes],members:[]}),x(e,`boundary`))},k=e=>{e.classed&&!e.declares&&g(`Relationship endpoint '${e.id}' uses ::: without declaring the node`,e.span);let t=l.get(e.id);return t?t.kind:(u.set(e.id,{...e,kind:`usecase`,shape:`ellipse`,classes:[]}),x(e,`usecase`),y(e.id,e.span[0]),`usecase`)},A=(e,t)=>{let n=l.get(e)?.kind;return(n===`actor`?o.get(e):n===`usecase`?s.get(e):n===`boundary`?c.get(e):n===`json`?a.jsonNodes.get(e):f.get(e))??g(`Class/style target '${e}' is unresolved or anonymous`,t)},j=[];for(let{source:e,target:n}of t.relationships)y(e.id,e.span[0]),y(n.id,n.span[0]);for(let e of t.elements)y(e.id,e.span[0]),j.push({offset:e.span[0],run:()=>D(e)});for(let e of t.boundaries)y(e.id,e.span[0]),j.push({offset:e.span[0],run:()=>O(e)});for(let e of t.jsons)y(e.id,e.span[0]),j.push({offset:e.span[0],run:()=>C(e.id,`json`,e.span)});for(let{id:e,idSpan:n}of t.relationships)e&&n&&j.push({offset:n[0],run:()=>C(e,`edge`,n)});j.sort((e,t)=>e.offset-t.offset);for(let e of j)e.run();for(let e of b(u.values()))E(e);for(let e of b(d.values()))c.set(e.id,{id:e.id,label:e.label.text,labelType:e.label.type,type:`rect`,members:[],classes:[],styles:[]});for(let e of b(t.jsons))a.jsonNodes.set(e.id,{id:e.id,value:e.value,propertyOrder:e.propertyOrder,classes:[...e.classes],styles:[]});let M=0;for(let e of t.relationships){let{source:t,target:n,type:r}=e,i=k(t),o=k(n),s=e=>e===`actor`||e===`usecase`||e===`json`;s(i)||_(`Relationship source '${t.id}' cannot be ${i}`,t.span,l.get(t.id).span),s(o)||_(`Relationship target '${n.id}' cannot be ${o}`,n.span,l.get(n.id).span),r!==`include`&&r!==`extend`||i===`usecase`&&o===`usecase`||g(`${r} relationship requires use-case endpoints`,e.span),r===`generalization`&&(i===`json`||i!==o)&&g(`Generalization requires actor-to-actor or use-case-to-use-case endpoints`,e.span),r===`association`&&(i===`json`||o===`json`)&&e.arrowType>2&&g(`JSON relationship '${t.id}' to '${n.id}' permits only point, reversed-point, or markerless solid association`,e.span);let c=e.id??`edge-${M++}`,u={id:c,explicitId:!!e.id,source:t.id,target:n.id,type:r,arrowType:e.arrowType,minlen:e.minlen,classes:[],styles:[],animate:!1};e.label&&(u.label=e.label.text,u.labelType=e.label.type),a.relationships.push(u),f.set(c,u)}let N=new Map(o),P=new Map(s);o.clear(),s.clear();for(let e of b(u.values())){let t=N.get(e.id),n=P.get(e.id);t?o.set(e.id,t):n?s.set(e.id,n):E(e)}for(let{target:e,span:n,properties:r,statement:i}of t.metadata){let t=l.get(e);if(!t){let t=tjt(r);return g(`Metadata target '${e}' is unresolved${t?` (metadata implies ${t})`:``}`,n)}let a=t.kind;a===`actor`||a===`usecase`?T(u.get(e),r,!0):a===`edge`&&(i.kind=`edgeMetadata`,i.edges=[{id:e,span:i.span,idSpan:n,metadata:i.metadata}],delete i.nodes);let o=d.get(e),s=f.get(e);for(let t of a===`actor`||a===`usecase`?[]:r){let{key:n,value:r}=t;a===`boundary`&&o&&n===`type`&&(r===`rect`||r===`package`)?o.type=r:a===`edge`&&s&&n===`animate`&&typeof r==`boolean`?s.animate=r:a===`edge`&&s&&n===`animation`&&(r===`fast`||r===`slow`)?(s.animation=r,s.animate=!0):v(e,a,t)}}for(let e of a.relationships)e.animation&&(e.animate=!0);for(let e of u.values())e.kind===`actor`?(e.icon&&e.actorType&&e.actorType!==`normal`&&g(`Actor '${e.id}' cannot combine icon with type '${e.actorType}'`,e.span),e.business&&(e.icon||e.actorType===`awesome`)&&g(`Business actor '${e.id}' must use normal or hollow geometry`,e.span)):e.shape===`rect`&&e.business&&g(`Rectangular use case '${e.id}' cannot be a business use case`,e.span),E(e);for(let e of[...t.elements].sort((e,t)=>e.span[0]-t.span[0])){if(!e.parent?.id)continue;let t=d.get(e.parent.id).members;t.includes(e.id)||t.push(e.id)}for(let e of d.values()){let t=c.get(e.id);t.type=e.type??`rect`,t.members=e.members,t.classes=[...e.classes]}let F=0;for(let e of t.notes){let t=l.get(e.target);if(!t)return g(`Note target '${e.target}' is unresolved`,e.span);t.kind!==`actor`&&t.kind!==`usecase`&&_(`Note target '${e.target}' must be an actor or use case, not ${t.kind}`,e.span,t.span);let n=`note-${F++}`;a.notes.set(n,{id:n,target:e.target,label:e.label.text,labelType:e.label.type})}for(let e of t.classDefs)for(let t of e.ids)a.classDefs.set(t,{id:t,styles:[...e.styles]});for(let e of t.classes)for(let t of e.targets)P0(A(t.id,t.span).classes,e.classes);for(let e of t.styles)A(e.target,e.span).styles.push(...e.styles);return a.direction=t.direction??a.direction,a.title=i,a.accTitle=t.accTitle,a.accDescription=t.accDescription,a.accDescr=t.accDescription.replace(/\n\s+/g,`
|
|
1063
|
+
`):void 0,root:n.root,count:n.count}}var b0=`mermaid-treeview`,x0=/* @__PURE__ */ 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 S0(e,t){if(e===void 0||!Object.prototype.hasOwnProperty.call(e,t))return;let n=e[t];return typeof n==`string`?n:void 0}function yAt(e,t){let n=S0(t?.filenameIcons,e);if(n)return n;let r=e.lastIndexOf(`.`);if(r>0){let n=e.substring(r).toLowerCase();return S0(t?.extensionIcons,n)??S0(t?.extensionIcons,n.slice(1))}}function bAt(e,t){return e.includes(`:`)?e:x0.has(e)||!t?`${b0}:${e}`:`${t}:${e}`}function xAt(e,t){if(e.icon!==`none`){if(e.icon)return bAt(e.icon,t.defaultIconPack);if(t.showIcons){if(e.nodeType===`file`){let n=yAt(e.name,t);if(n===`none`)return;if(n)return bAt(n,t.defaultIconPack)}return`${b0}:${e.nodeType===`directory`?`folder`:`file`}`}}}function SAt(e){let t=e=>typeof e==`object`&&e&&!Array.isArray(e)?e:void 0,n=t(e.treeView)??{};return{showIcons:!!n.showIcons,defaultIconPack:typeof n.defaultIconPack==`string`?n.defaultIconPack:``,filenameIcons:t(n.filenameIcons),extensionIcons:t(n.extensionIcons)}}var CAt=6,wAt=16,TAt=7,EAt=4,C0=4;function w0(e,t,n,r,i){let a=e.treeView?.[t];return typeof a==`number`&&a>=r&&a<=i?a:n}function DAt(e){return{paddingX:w0(e,`paddingX`,5,0,100),paddingY:w0(e,`paddingY`,2,0,100),rowIndent:w0(e,`rowIndent`,15,0,400),lineThickness:w0(e,`lineThickness`,1,.25,12)}}function OAt(e,t,n){return YJ(n,r=>kAt(e,t,n,r))}function kAt(e,t,n,r){let i=n.fontSize??16,a=n.measurer??fq(n.fontFamily),o=n.padding??8,s=SAt(t),{paddingX:c,paddingY:l,rowIndent:u,lineThickness:d}=DAt(t),f=0,p=e.root.children.map(e=>[e,0]);for(let e=0;r&&e<p.length;e++){let[t,n]=p[e];f=Math.max(f,n);for(let e of t.children)p.push([e,n+1])}let m=r?Math.min(u+c,Math.max(2,((n.maxWidth??320)-120)/Math.max(1,f))):u+c,h=Math.round(i*1.5)+2*l,g=i,_=UJ(e.title,!1,a,i,r?GJ(n):4e3,1),v=_.height>0?_.height+12:0,y=e=>e.some(e=>xAt(e,s)!==void 0),b=[],x=/* @__PURE__ */ new Map,S=[],C=(e,t)=>{let n=y(e);for(let r=e.length-1;r>=0;r--)S.push([e[r],t,n])};C(e.root.children,0);let w=0,T=!1,E=0;for(;S.length>0;){let[e,t,c]=S.pop(),u=t*m,d=RK(e.name),f=u+(c?g+CAt:0),p=Math.max(40,(n.maxWidth??320)-2*o-2*C0-f),_=r?XY(d,a,i,p,+(e.nodeType===`directory`)):void 0,v=r&&e.description?XY(RK(e.description),a,i,p,2):void 0,y=_?_.width:a.width(d,i,+(e.nodeType===`directory`));f+y>w&&(w=f+y);let D=e.cssClass!==void 0&&e.cssClass.split(/\s+/).includes(`highlight`);D&&(T=!0);let O=r?Math.max(h,(_?.height??0)+(v?.height??0)+2*l):h,k={node:e,x:u,cy:E+(r?l+Math.max(g,_?.height??0)/2:O/2),icon:xAt(e,s),text:d,labelX:f,highlighted:D,label:_,description:v,top:E,height:O};E+=O,b.push(k),x.set(e,k),C(e.children,t+1)}let D=w+wAt,O=w;for(let e of b){let t=e.node.description;if(!t)continue;let n=e.description?e.description.width:a.width(RK(t),i,2);O=Math.max(O,(r?e.labelX:D)+n)}O=Math.max(O,_.width);let k=o+(T?C0:0),A=o+v,j=Math.ceil(O+2*k),M=Math.ceil(A+E+o),N=``;for(let e of b){let t=e.node.children;if(t.length===0)continue;let n=k+e.x+TAt,r=Math.max(n,k+e.x+m-c),i=A+x.get(t[t.length-1]).cy,a=Math.min(EAt,r-n),o=`M${K(n)},${K(A+e.top+e.height-2)}V${K(i-a)}`;a>0&&(o+=`Q${K(n)},${K(i)} ${K(n+a)},${K(i)}H${K(r)}`);for(let e=0;e<t.length-1&&r>n;e++)o+=`M${K(n)},${K(A+x.get(t[e]).cy)}H${K(r)}`;N+=`<path d="${o}"/>`}let P=i*.35,F=``;for(let e of b){let t=e.node,r=A+e.cy,i=t.nodeType===`directory`,a=``;if(e.highlighted){let t=k+e.x-C0;a+=`<rect class="pele-tree-highlight" x="${K(t)}" y="${K(A+e.top+1)}" width="${K(j-k+C0-t)}" height="${K(e.height-2)}" rx="${dJ}" fill="var(--_c)" fill-opacity="0.14"/>`}if(e.icon!==void 0){let t=e.icon.startsWith(b0+`:`)?e.icon.slice(b0.length+1):``,o=x0.get(t)??x0.get(i?`folder`:`file`),s=n.icons?.(e.icon)??`<path d="${o}" stroke="var(--_m)" stroke-width="1.5"/>`;a+=`<svg class="pele-icon" data-icon="${mq(e.icon)}" x="${K(k+e.x)}" y="${K(r-g/2)}" width="${K(g)}" height="${K(g)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${s}</svg>`}e.label?a+=QY(e.label,k+e.labelX,A+e.top+l,` class="pele-label"${i?` font-weight="var(--_hw)"`:``}`):e.text!==``&&(a+=`<text class="pele-label" x="${K(k+e.labelX)}" y="${K(r+P)}"${i?` font-weight="var(--_hw)"`:``} xml:space="preserve">${pq(e.text)}</text>`),e.description?a+=QY(e.description,k+e.labelX,A+e.top+l+(e.label?.height??0),` class="pele-tree-description" font-style="italic" fill="var(--_m)"`):t.description&&(a+=`<text class="pele-tree-description" x="${K(k+D)}" y="${K(r+P)}" font-style="italic" fill="var(--_m)" xml:space="preserve">${pq(RK(t.description))}</text>`),F+=`<g class="pele-node pele-tree-${i?`dir`:`file`}${mJ(t.cssClass??``)}" data-id="${mq(t.name)}">${a}</g>`}return{svg:_J(`treeView`,j,M,i,n,e,gq(_,j/2,o+_.height/2,` class="pele-title" font-weight="var(--_tw)"`)+(N?`<g class="pele-tree-guides" fill="none" stroke="var(--_b)" stroke-width="${K(d)}">${N}</g>`:``)+F),width:j,height:M,links:[]}}var AAt={type:`treeView`,parse:(e,t,n)=>vAt(_At(e),n),render:OAt};function jAt(e){let t=[],n=[];for(let r of e){let e=r.type===`Leaf`,i={name:r.name,children:e?void 0:[]};for(i.classSelector=r.classSelector,r.cssCompiledStyles&&(i.cssCompiledStyles=r.cssCompiledStyles),e&&r.value!==void 0&&(i.value=r.value);n.length>0&&n[n.length-1].level>=r.level;)n.pop();n.length===0?t.push(i):n[n.length-1].node.children.push(i),e||n.push({node:i,level:r.level})}return t}function MAt(e,t){let n=/* @__PURE__ */ new Map;for(let t of e.TreemapRows){if(t.$type!==`ClassDefStatement`)continue;let e=n.get(t.className);e||n.set(t.className,e=[]);let r=(t.styleText??``).replace(/\\,/g,`§§§`).replace(/,/g,`;`).replace(/§§§/g,`,`);for(let t of r.split(`;`))e.push(t)}let r=[];for(let t of e.TreemapRows){if(t.$type!==`TreemapRow`)continue;let e=t.item,i=e.classSelector?n.get(e.classSelector):void 0;r.push({level:t.indent??0,name:e.name,type:e.$type,value:e.$type===`Leaf`?e.value:void 0,classSelector:e.classSelector,cssCompiledStyles:i&&i.length>0?i:void 0})}return{type:`treemap`,title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,``):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
|
|
1064
|
+
`):void 0,roots:jAt(r),classes:n}}var NAt=[aY,oY,sY,{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}],PAt=/classDef\s+([A-Z_a-z]\w+)(?:\s+([^\n\r;]*))?;?/;function FAt(e){let t=new bY(iY(e,NAt,`treemap`),NAt,`treemap`),n=t.kinds,r={$type:`Treemap`,TreemapRows:[]},i=()=>t.accept(5)?t.expect(12):void 0;for(t.expect(3);t.kind!==-1;){let e=t.kind;if(e===0){r.accDescr=vY(t.take());continue}if(e===1){r.accTitle=_Y(t.take());continue}if(e===2){r.title=gY(t.take());continue}e!==8&&e!==14&&e!==4&&t.fail(`a node, a class definition, or a title`);let a=e===8?t.take().length:void 0;if(t.kind===4){let e=PAt.exec(t.take()),n={$type:`ClassDefStatement`,className:e[1]};e[2]&&(n.styleText=e[2]),a!==void 0&&(n.indent=a),r.TreemapRows.push(n);continue}let o=t.expect(14).slice(1,-1),s=n[t.i]===8?t.i+1:t.i,c;n[s]===6||n[s]===7?(t.i=s+1,t.accept(8),c={$type:`Leaf`,name:o,value:parseFloat(t.expect(13).replace(/,/g,``))}):c={$type:`Section`,name:o};let l=i();l!==void 0&&(c.classSelector=l);let u={$type:`TreemapRow`,item:c};a!==void 0&&(u.indent=a),r.TreemapRows.push(u)}return r}var IAt=/^(?:.?[<>=^])?([-+( ])?(\$)?0?\d*(,)?(?:\.(\d+))?(~)?([a-zA-Z%])?$/;function LAt(e){let t=``;for(let n=e.length;n>0;n-=3)t=e.slice(Math.max(0,n-3),n)+(t?`,`+t:``);return t}function RAt(e){let t=IAt.exec(e===`$0,0`?`$,`:e)??IAt.exec(`,`),n=t[1]===`+`,r=t[3]!==void 0,i=t[4]===void 0?void 0:Math.min(Number(t[4]),20),a=t[6]??``;return e=>{let o=Math.abs(e),s,c=``;if(a===`f`?s=o.toFixed(i??6):a===`%`?(s=(o*100).toFixed(i??6),c=`%`):s=a===`d`?Math.round(o).toFixed(0):a===`e`?o.toExponential(i??6):String(Number(o.toPrecision(Math.max(1,i??12)))),t[5]&&s.includes(`.`)&&!s.includes(`e`)&&(s=s.replace(/\.?0+$/,``)),r&&!s.includes(`e`)){let e=s.indexOf(`.`);s=e===-1?LAt(s):LAt(s.slice(0,e))+s.slice(e)}return(e<0?`-`:n?`+`:``)+(t[2]??``)+s+c}}function zAt(e,t,n){return{node:e,parent:t,series:n,value:e.children===void 0&&Number.isFinite(e.value)&&e.value>0?e.value:0,children:[],x:0,y:0,w:0,h:0}}function BAt(e,t,n,r,i,a,o){let s=t,c=0;for(;c<e.length;){let t=i*a/s,l=Math.min(i,a),u=e[c].value*t,d=u,f=Math.max(l*l*d/(u*u),u*u/(l*l*d)),p=c+1;for(;p<e.length;){let n=e[p].value*t,r=u+n,i=Math.max(l*l*d/(r*r),r*r/(l*l*n));if(i>f)break;f=i,u=r,p++}let m=u/l,h=0;for(let u=c;u<p;u++){let c=e[u],d=u===p-1?l-h:c.value*t/m,f=i>=a?n:n+h,g=i>=a?r+h:r,_=Math.round(f+o/2),v=Math.round(g+o/2);c.x=_,c.y=v,c.w=Math.round(f+(i>=a?m:d)-o/2)-_,c.h=Math.round(g+(i>=a?d:m)-o/2)-v,h+=d,s-=c.value}i>=a?(n+=m,i-=m):(r+=m,a-=m),c=p}}function VAt(e,t,n,r){let i=e.map((e,t)=>zAt(e,void 0,t)),a=i.slice();for(let e=0;e<a.length;e++){let t=a[e];for(let e of t.node.children??[]){let n=zAt(e,t,t.series);t.children.push(n),a.push(n)}}for(let e=a.length-1;e>=0;e--){let t=a[e];t.parent&&(t.parent.value+=t.value)}let{gap:o,header:s,side:c}=r,l=[],u=(e,t,n,r,i)=>{if(r<=0||i<=0)return;let a=e.filter(e=>e.value>0).sort((e,t)=>t.value-e.value),s=0;for(let e of a)s+=e.value;if(a.length!==0&&Number.isFinite(s)){BAt(a,s,t-o/2,n-o/2,r+o,i+o,o);for(let e of a)e.w>0&&e.h>0&&l.push(e)}};u(i,0,0,t,n);for(let e=0;e<l.length;e++){let t=l[e];t.children.length>0&&u(t.children,t.x+c,t.y+s,t.w-2*c,t.h-s-c)}return l}var T0=28,E0=6,D0=1.25;function O0(e,t,n,r,i){let a=e.treemap?.[t];return typeof a==`number`&&a>=r?Math.min(a,i):n}function HAt(e,t,n){let r=n.fontSize??16,i=Math.round(r*.875),a=Math.round(r*.75),o=Math.round(r*.5625),s=n.measurer??fq(n.fontFamily),c=t.treemap??{},l=n.padding??O0(t,`diagramPadding`,8,0,2e3),u=Math.round(KJ(n,O0(t,`nodeWidth`,64,1,400)*10,200,2*l)),d=Math.round(O0(t,`nodeHeight`,40,1,400)*10),f=c.showValues!==!1,p=RAt(typeof c.valueFormat==`string`?c.valueFormat:`,`),m=VAt(e.roots,u,d,{gap:O0(t,`padding`,4,0,200),header:T0,side:E0}),h=UJ(e.title,!1,s,r,GJ(n),1),g=h.height>0?h.height+8:0,_=l+Math.max(0,(h.width-u)/2),v=l+g,y=``,b=``;for(let e of m){let t=e.node,n=pJ(t.cssCompiledStyles??[]),c=hJ(e.series),l=_+e.x,u=v+e.y,d=RK(t.name).trim(),m=f?p(e.value):``,h=`data-id="${mq(t.name)}">`,g=`<rect x="${K(l)}" y="${K(u)}" width="${K(e.w)}" height="${K(e.h)}" rx="${dJ}" fill="${c}"`;if(t.children!==void 0){let r=``;if(e.h>=T0){let t=e.w-2*E0-4,o=m?s.width(m,a,0):0,c=o>0&&t-o-12>=3*i,f=h$(d,c?t-o-12:t,i,i,s,1),p=u+T0/2+1;f&&(r+=`<text x="${K(l+E0+2)}" y="${K(p+i*.35)}" font-weight="var(--_hw)"${n.text}>${pq(f.text)}</text>`),c&&(r+=`<text class="pele-value" x="${K(l+e.w-E0-2)}" y="${K(p+a*.35)}" font-size="${a}" text-anchor="end" fill="var(--_m)"${n.text}>${pq(m)}</text>`)}let o=/[";]fill:/.test(n.shape)?``:` fill-opacity="0.12"`;y+=`<g class="pele-node pele-section${mJ(t.classSelector??``)}" ${h}${g}${o} stroke="${c}"${n.shape}/>${r}</g>`;continue}let x=``,S=e.w-8,C=Math.min(r,Math.floor((e.h-4)/D0)),w=C>=o?h$(d,S,C,o,s):void 0;if(w){let t=K(l+e.w/2),r=u+e.h/2,i=Math.max(o,Math.round(w.size*.8)),a=(w.size+i)*D0;if(m&&a<=e.h-4&&s.width(m,i,0)<=S){let e=r-a/2+w.size*D0/2,o=r+a/2-i*D0/2;x=`<text x="${t}" y="${K(e+w.size*.35)}" font-size="${K(w.size)}"${n.text}>${pq(w.text)}</text><text class="pele-value" x="${t}" y="${K(o+i*.35)}" font-size="${K(i)}"${n.text}>${pq(m)}</text>`}else x=`<text x="${t}" y="${K(r+w.size*.35)}" font-size="${K(w.size)}"${n.text}>${pq(w.text)}</text>`}b+=`<g class="pele-node pele-leaf${mJ(t.classSelector??``)}" ${h}${g}${n.shape}/>${x}</g>`}let x=Math.ceil(Math.max(u,h.width)+2*l),S=Math.ceil(d+g+2*l);return{svg:_J(`treemap`,x,S,r,n,e,gq(h,x/2,l+h.height/2,` class="pele-title" font-weight="var(--_tw)"`)+(y?`<g class="pele-sections" font-size="${i}">${y}</g>`:``)+(b?`<g class="pele-leaves" text-anchor="middle" fill="var(--_bg)">${b}</g>`:``)),width:x,height:S,links:[]}}var UAt={type:`treemap`,parse:(e,t,n)=>MAt(FAt(e),n),render:HAt},WAt=`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(` `),k0=1,GAt=2,A0=/* @__PURE__ */ new Uint8Array(128);for(let e=48;e<=57;e++)A0[e]=k0;for(let e=65;e<=90;e++)A0[e]=A0[e+32]=k0;A0[95]=k0;for(let e of`!#$&*+/=?^|~`)A0[e.charCodeAt(0)]=GAt;var KAt=[0,12,5,14,3,9,2,2,2,2,2,4,3,4,8,5,5,7,6,4,5];function j0(e){return e<128&&(A0[e]&k0)!==0}function M0(e,t,n){for(let r=0;r<n.length;r++)if((e.charCodeAt(t+r)|32)!==n.charCodeAt(r))return!1;return!0}function qAt(e,t,n){switch(n){case 97:return e.startsWith(`actor`,t)?2:0;case 115:return e.startsWith(`systemBoundary`,t)?3:e.startsWith(`style`,t)?16:0;case 101:return e.startsWith(`end`,t)?4:M0(e,t,`extend`)?18:0;case 69:return M0(e,t,`extend`)?18:0;case 100:return e.startsWith(`direction`,t)?5:0;case 84:return e.startsWith(`TD`,t)?6:e.startsWith(`TB`,t)?7:0;case 66:return e.startsWith(`BT`,t)?8:0;case 76:return e.startsWith(`LR`,t)?9:0;case 82:return e.startsWith(`RL`,t)?10:0;case 110:return e.startsWith(`note`,t)?11:0;case 102:return e.startsWith(`for`,t)?12:e.startsWith(`false`,t)?20:0;case 106:return e.startsWith(`json`,t)?13:0;case 99:return e.startsWith(`classDef`,t)?14:e.startsWith(`class`,t)?15:0;case 105:case 73:return M0(e,t,`include`)?17:0;case 116:return e.startsWith(`true`,t)?19:0;case 117:return+!!e.startsWith(`usecase-beta`,t);default:return 0}}function N0(e,t){let n=1,r=0;for(let i=0;i<t;i++){let a=e.charCodeAt(i);a!==10&&a!==13||(a===13&&i+1<t&&e.charCodeAt(i+1)===10&&i++,n++,r=i+1)}return[n,t-r+1]}function JAt(e,t,n){let[r,i]=N0(e,t);return`line ${r}, column ${i} [${t},${n})`}function YAt(e,t,n){for(let r=t+1;r<e.length;r++){let t=e.charCodeAt(r);if(t===n)return r+1;if(t===10||t===13)return-1}return-1}function XAt(e,t){let n=e.charCodeAt(t);return n!==34&&n!==39||n===34&&e.charCodeAt(t+1)===96||YAt(e,t,n)!==-1}function ZAt(e,t,n){let[r,i]=N0(e,t);return new NK(`Error lexing usecase diagram: unexpected character: ->${e.charAt(t)}<- at offset: ${t}, skipped ${n} characters. at line ${r}, column ${i} [${t},${t+n})`,`syntax`,{type:`usecase`,line:r,column:i})}function QAt(e){let t=[],n=[],r=[],i=e.length,a=0,o=!0,s=!1;for(;a<i;){let c=e.charCodeAt(a);if(c===32||c===9){a++;continue}let l,u=a+1,d=!1;if(c<128&&(A0[c]&k0)!==0){if(l=0,c===97&&o&&e.startsWith(`acc`,a)){let t=e.startsWith(`Descr`,a+3);if(t||e.startsWith(`Title`,a+3)){let n=a+8;for(;tq(e.charCodeAt(n));)n++;let r=e.charCodeAt(n);if(r===58)for(l=t?42:41,u=n+1;u<i&&e.charCodeAt(u)!==10&&e.charCodeAt(u)!==13;)u++;else if(r===123&&t&&!s){let t=e.indexOf(`}`,n+1);t===-1?s=!0:(l=40,u=t+1)}}}else if(c===106&&e.startsWith(`json`,a)&&tq(e.charCodeAt(a+4))){let s=a+5;for(;tq(e.charCodeAt(s));)s++;let c=s;for(;j0(e.charCodeAt(s));)s++;if(s>c){for(;tq(e.charCodeAt(s));)s++;if(e.charCodeAt(s)===64){for(s++;tq(e.charCodeAt(s));)s++;if(e.charCodeAt(s)===123){t.push(43),n.push(a),r.push(s),a=s;let c=0,l=!1,u=!1,d=s;for(;d<i;d++){let t=e.charCodeAt(d);if(l)u?u=!1:t===92?u=!0:t===34&&(l=!1);else if(t===34)l=!0;else if(t===123)c++;else if(t===125&&--c===0)break}t.push(d<i?44:45),n.push(s),a=d<i?d+1:i,r.push(a),o=!1;continue}}}}if(l===0){for(;u<i&&j0(e.charCodeAt(u));)u++;let t=qAt(e,a,c);if(t!==0)t===1||u-a===KAt[t]?(l=t,u=a+KAt[t]):l=21;else if((c===111||c===120)&&e.charCodeAt(a+1)===45&&e.charCodeAt(a+2)===45)l=c===111?56:58,u=a+3;else if(rq(c)){let t=a+1;for(;rq(e.charCodeAt(t));)t++;if(e.charCodeAt(t)===46&&rq(e.charCodeAt(t+1))){for(l=22,u=t+2;rq(e.charCodeAt(u));)u++;for(;iq(e.charCodeAt(u));)u++}else l=21}else for(l=21;e.charCodeAt(u)===45&&j0(e.charCodeAt(u+1));)for(l=27,u+=2;j0(e.charCodeAt(u));)u++}}else if(c===10)l=39,d=!0;else if(c===13)l=39,d=!0,e.charCodeAt(u)===10&&u++;else if(c===34||c===39){if(c===34&&e.charCodeAt(a+1)===96){let t=e.indexOf('`"',a+2);l=t===-1?37:36,u=t===-1?i:t+2}else if(l=35,u=YAt(e,a,c),u===-1){let t=a+1;for(;t<i&&!XAt(e,t);)t++;throw ZAt(e,a,t-a)}}else if(c===37){if(o&&e.charCodeAt(u)===37)for(l=38;u<i&&e.charCodeAt(u)!==10&&e.charCodeAt(u)!==13;)u++;else l=31}else if(c===45){if(e.charCodeAt(u)!==45)l=29;else{for(;e.charCodeAt(u)===45;)u++;let t=e.charCodeAt(u),n=u-a===2;n&&t===124&&e.charCodeAt(u+1)===62?(l=46,u+=2):t===62?(l=53,u++):n&&(t===111||t===120)?(l=t===111?55:57,u++):l=59}}else if(c===46){let t=e.charCodeAt(u);if(t===46&&e.charCodeAt(u+1)===62)l=47,u+=2;else if(rq(t)){for(l=22;rq(e.charCodeAt(u));)u++;for(;iq(e.charCodeAt(u));)u++}else l=30}else if(c===60){if(e.charCodeAt(u)===60){if(t.push(48),n.push(a),r.push(a+2),o=!1,a+=2,a>=i)break;if(e.charCodeAt(a)===62&&e.charCodeAt(a+1)===62)l=49,u=a+2;else{let o=a,s=!1;for(;o<i;o++){let t=e.charCodeAt(o);if(t===10||t===13)break;if(t===62&&e.charCodeAt(o+1)===62){s=!0;break}}if(s&&e.slice(a,o).trim()!==``)t.push(50),n.push(a),r.push(o),l=49,a=o,u=o+2;else{for(;o<i&&e.charCodeAt(o)!==10&&e.charCodeAt(o)!==13;)o++;if(o===a){for(;o<i&&(e.charCodeAt(o)===10||e.charCodeAt(o)===13);)o++;throw ZAt(e,a,o-a)}l=51,u=o}}}else if(e.charCodeAt(u)===45&&e.charCodeAt(u+1)===45)for(l=54,u+=2;e.charCodeAt(u)===45;)u++;else l=33}else if(c===58)e.charCodeAt(u)===58&&e.charCodeAt(u+1)===58?(l=52,u+=2):l=25;else if(c===64)e.charCodeAt(u)===123?(l=60,u++):l=23;else if(c===123)l=61;else if(c===125)l=62;else if(c===91)l=63;else if(c===93)l=64;else if(c===40)l=65;else if(c===41)l=66;else if(c===44)l=24;else if(c===35){for(;Hft(e.charCodeAt(u));)u++;l=u>a+1?26:32}else if(c===92)e.charCodeAt(u)===44?(l=28,u++):l=33;else if(c<127&&c>32)l=(A0[c]&GAt)===0?33:32;else for(l=34;u<i;){let t=e.charCodeAt(u);if(t>=32&&t<127||t===9||t===10||t===13)break;u++}t.push(l),n.push(a),r.push(u),a=u,o=d}for(let e=0;e<3;e++)t.push(0),n.push(i),r.push(i);return{types:t,starts:n,ends:r}}function $At(){return{type:`usecase`,actors:/* @__PURE__ */ new Map,useCases:/* @__PURE__ */ new Map,systemBoundaries:/* @__PURE__ */ new Map,relationships:[],notes:/* @__PURE__ */ new Map,jsonNodes:/* @__PURE__ */ new Map,classDefs:/* @__PURE__ */ new Map,direction:`LR`,title:void 0,accTitle:``,accDescr:``,accDescription:``,source:``,headerSpan:[0,0],statements:[]}}function ejt(){return{elements:[],boundaries:[],jsons:[],relationships:[],notes:[],metadata:[],classes:[],styles:[],classDefs:[],direction:void 0,accTitle:``,accDescription:``}}function P0(e,t){if(t.length===0)return;let n=new Set(e);for(let r of t)n.has(r)||(n.add(r),e.push(r))}function tjt(e){let t=/* @__PURE__ */ new Set([`actor`,`usecase`,`boundary`,`edge`]);for(let{key:n,value:r}of e)if(n===`icon`)t.clear(),t.add(`actor`);else if(n===`animate`||n===`animation`)t.clear(),t.add(`edge`);else if(n===`type`)t.clear(),r===`rect`||r===`package`?t.add(`boundary`):(r===`normal`||r===`hollow`||r===`awesome`)&&t.add(`actor`);else if(n===`business`)t.delete(`boundary`),t.delete(`edge`);else return;return t.size===1?[...t][0]:void 0}function njt(e,t,n,r,i){let a=$At(),{actors:o,useCases:s,systemBoundaries:c}=a,l=/* @__PURE__ */ new Map,u=/* @__PURE__ */ new Map,d=/* @__PURE__ */ new Map,f=/* @__PURE__ */ new Map,p=/* @__PURE__ */ new Map,m=t=>JAt(e,t[0],t[1]),h=(t,n)=>{let[r,i]=N0(e,n[0]);return new NK(t,`semantic`,{type:`usecase`,line:r,column:i})},g=(e,t)=>{throw h(`${e} at ${m(t)}`,t)},_=(e,t,n,r,i)=>{let a=e=>e===void 0?``:` (label "${e}")`;throw h(`${e} at ${m(t)}${a(r)}; previous declaration at ${m(n)}${a(i)}`,t)},v=(e,t,n)=>g(`Metadata property '${n.key}' is invalid for ${t} '${e}'`,n.keySpan),y=(e,t)=>{let n=p.get(e);(n===void 0||t<n)&&p.set(e,t)},b=e=>[...e].sort((e,t)=>(p.get(e.id)??0)-(p.get(t.id)??0)),x=(e,t)=>{l.set(e.id,{kind:t,span:e.span,generated:e.generated,label:e.label.text})},S=(e,t)=>{let n=l.get(e.id);if(!n)return;let r=e.generated?e.label.text:void 0,i=n.generated?n.label:void 0;n.kind!==t&&_(`ID '${e.id}' is declared as both ${n.kind} and ${t}`,e.span,n.span,r,i),(n.generated||e.generated)&&_(`Generated ID '${e.id}' collides with another declaration`,e.span,n.span,r,i)},C=(e,t,n)=>{let r=l.get(e);r&&_(`ID '${e}' is declared more than once (${r.kind} and ${t})`,n,r.span,void 0,r.generated?r.label:void 0),l.set(e,{kind:t,span:n,generated:!1})},w=(e,t,n)=>{let{key:r,value:i}=t,a=a=>{!n&&a!==void 0&&a!==i&&_(`Actor '${e.id}' has conflicting ${r} metadata`,t.keySpan,e.span)};r===`type`&&(i===`normal`||i===`hollow`||i===`awesome`)?(a(e.actorType),e.actorType=i):r===`icon`&&typeof i==`string`?(a(e.icon),e.icon=i):r===`business`&&typeof i==`boolean`?(a(e.business),e.business=i):v(e.id,`actor`,t)},T=(e,t,n)=>{for(let r of t??[])e.kind===`actor`?w(e,r,n):r.key===`business`&&typeof r.value==`boolean`?(!n&&e.business!==void 0&&e.business!==r.value&&_(`Use case '${e.id}' has conflicting business metadata`,r.keySpan,e.span),e.business=r.value):v(e.id,`usecase`,r)},E=e=>{let t;if(e.kind===`actor`){s.delete(e.id);let n={id:e.id,label:e.label.text,labelType:e.label.type,business:e.business??!1,classes:[...e.classes],type:e.icon?`icon`:e.actorType??`normal`,styles:o.get(e.id)?.styles??[]};e.icon&&(n.icon=e.icon),o.set(e.id,n),t=n}else o.delete(e.id),t={id:e.id,label:e.label.text,labelType:e.label.type,business:e.business??!1,classes:[...e.classes],shape:e.shape??`ellipse`,styles:s.get(e.id)?.styles??[]},s.set(e.id,t);e.stereotype&&(t.stereotype=e.stereotype),e.parent?.id&&(t.parentId=e.parent.id)},D=e=>{S(e,e.kind);let t=e.parent?.id?e.parent:void 0,n=u.get(e.id);if(n)(n.label.text!==e.label.text||n.label.type!==e.label.type)&&_(`ID '${e.id}' has conflicting labels`,e.span,n.span),e.shape&&n.shape&&e.shape!==n.shape&&_(`Use case '${e.id}' has conflicting shapes`,e.span,n.span),t&&n.parent?.id&&t.id!==n.parent.id&&_(`Element '${e.id}' belongs to more than one system boundary`,t.span,n.parent.span),e.stereotype&&n.stereotype&&e.stereotype!==n.stereotype&&_(`Element '${e.id}' has conflicting stereotypes`,e.span,n.stereotypeSpan??n.span),n.shape??=e.shape,n.parent??=e.parent,n.stereotype??=e.stereotype,n.stereotypeSpan??=e.stereotype?e.span:void 0,P0(n.classes,e.classes),T(n,e.metadata,!1);else{let n={kind:e.kind,id:e.id,label:e.label,span:e.span,generated:e.generated,classes:[...e.classes],parent:t,shape:e.shape,stereotype:e.stereotype,stereotypeSpan:e.stereotype?e.span:void 0};T(n,e.metadata,!1),u.set(e.id,n),x(e,e.kind)}},O=e=>{S(e,`boundary`);let t=d.get(e.id);t?((t.label.text!==e.label.text||t.label.type!==e.label.type)&&_(`Boundary '${e.id}' has conflicting titles`,e.span,t.span),P0(t.classes,e.classes)):(d.set(e.id,{...e,classes:[...e.classes],members:[]}),x(e,`boundary`))},k=e=>{e.classed&&!e.declares&&g(`Relationship endpoint '${e.id}' uses ::: without declaring the node`,e.span);let t=l.get(e.id);return t?t.kind:(u.set(e.id,{...e,kind:`usecase`,shape:`ellipse`,classes:[]}),x(e,`usecase`),y(e.id,e.span[0]),`usecase`)},A=(e,t)=>{let n=l.get(e)?.kind;return(n===`actor`?o.get(e):n===`usecase`?s.get(e):n===`boundary`?c.get(e):n===`json`?a.jsonNodes.get(e):f.get(e))??g(`Class/style target '${e}' is unresolved or anonymous`,t)},j=[];for(let{source:e,target:n}of t.relationships)y(e.id,e.span[0]),y(n.id,n.span[0]);for(let e of t.elements)y(e.id,e.span[0]),j.push({offset:e.span[0],run:()=>D(e)});for(let e of t.boundaries)y(e.id,e.span[0]),j.push({offset:e.span[0],run:()=>O(e)});for(let e of t.jsons)y(e.id,e.span[0]),j.push({offset:e.span[0],run:()=>C(e.id,`json`,e.span)});for(let{id:e,idSpan:n}of t.relationships)e&&n&&j.push({offset:n[0],run:()=>C(e,`edge`,n)});j.sort((e,t)=>e.offset-t.offset);for(let e of j)e.run();for(let e of b(u.values()))E(e);for(let e of b(d.values()))c.set(e.id,{id:e.id,label:e.label.text,labelType:e.label.type,type:`rect`,members:[],classes:[],styles:[]});for(let e of b(t.jsons))a.jsonNodes.set(e.id,{id:e.id,value:e.value,propertyOrder:e.propertyOrder,classes:[...e.classes],styles:[]});let M=0;for(let e of t.relationships){let{source:t,target:n,type:r}=e,i=k(t),o=k(n),s=e=>e===`actor`||e===`usecase`||e===`json`;s(i)||_(`Relationship source '${t.id}' cannot be ${i}`,t.span,l.get(t.id).span),s(o)||_(`Relationship target '${n.id}' cannot be ${o}`,n.span,l.get(n.id).span),r!==`include`&&r!==`extend`||i===`usecase`&&o===`usecase`||g(`${r} relationship requires use-case endpoints`,e.span),r===`generalization`&&(i===`json`||i!==o)&&g(`Generalization requires actor-to-actor or use-case-to-use-case endpoints`,e.span),r===`association`&&(i===`json`||o===`json`)&&e.arrowType>2&&g(`JSON relationship '${t.id}' to '${n.id}' permits only point, reversed-point, or markerless solid association`,e.span);let c=e.id??`edge-${M++}`,u={id:c,explicitId:!!e.id,source:t.id,target:n.id,type:r,arrowType:e.arrowType,minlen:e.minlen,classes:[],styles:[],animate:!1};e.label&&(u.label=e.label.text,u.labelType=e.label.type),a.relationships.push(u),f.set(c,u)}let N=new Map(o),P=new Map(s);o.clear(),s.clear();for(let e of b(u.values())){let t=N.get(e.id),n=P.get(e.id);t?o.set(e.id,t):n?s.set(e.id,n):E(e)}for(let{target:e,span:n,properties:r,statement:i}of t.metadata){let t=l.get(e);if(!t){let t=tjt(r);return g(`Metadata target '${e}' is unresolved${t?` (metadata implies ${t})`:``}`,n)}let a=t.kind;a===`actor`||a===`usecase`?T(u.get(e),r,!0):a===`edge`&&(i.kind=`edgeMetadata`,i.edges=[{id:e,span:i.span,idSpan:n,metadata:i.metadata}],delete i.nodes);let o=d.get(e),s=f.get(e);for(let t of a===`actor`||a===`usecase`?[]:r){let{key:n,value:r}=t;a===`boundary`&&o&&n===`type`&&(r===`rect`||r===`package`)?o.type=r:a===`edge`&&s&&n===`animate`&&typeof r==`boolean`?s.animate=r:a===`edge`&&s&&n===`animation`&&(r===`fast`||r===`slow`)?(s.animation=r,s.animate=!0):v(e,a,t)}}for(let e of a.relationships)e.animation&&(e.animate=!0);for(let e of u.values())e.kind===`actor`?(e.icon&&e.actorType&&e.actorType!==`normal`&&g(`Actor '${e.id}' cannot combine icon with type '${e.actorType}'`,e.span),e.business&&(e.icon||e.actorType===`awesome`)&&g(`Business actor '${e.id}' must use normal or hollow geometry`,e.span)):e.shape===`rect`&&e.business&&g(`Rectangular use case '${e.id}' cannot be a business use case`,e.span),E(e);for(let e of[...t.elements].sort((e,t)=>e.span[0]-t.span[0])){if(!e.parent?.id)continue;let t=d.get(e.parent.id).members;t.includes(e.id)||t.push(e.id)}for(let e of d.values()){let t=c.get(e.id);t.type=e.type??`rect`,t.members=e.members,t.classes=[...e.classes]}let F=0;for(let e of t.notes){let t=l.get(e.target);if(!t)return g(`Note target '${e.target}' is unresolved`,e.span);t.kind!==`actor`&&t.kind!==`usecase`&&_(`Note target '${e.target}' must be an actor or use case, not ${t.kind}`,e.span,t.span);let n=`note-${F++}`;a.notes.set(n,{id:n,target:e.target,label:e.label.text,labelType:e.label.type})}for(let e of t.classDefs)for(let t of e.ids)a.classDefs.set(t,{id:t,styles:[...e.styles]});for(let e of t.classes)for(let t of e.targets)P0(A(t.id,t.span).classes,e.classes);for(let e of t.styles)A(e.target,e.span).styles.push(...e.styles);return a.direction=t.direction??a.direction,a.title=i,a.accTitle=t.accTitle,a.accDescription=t.accDescription,a.accDescr=t.accDescription.replace(/\n\s+/g,`
|
|
1065
1065
|
`),a.source=e,a.headerSpan=n,a.statements=r,a}var F0=class extends Error{constructor(e){super(`Invalid JSON token`),this.offset=e}offset};function rjt(e){let t=/* @__PURE__ */ new Map,n=[],r=[],i=e.length,a=0,o=``,s=0,c=()=>{for(;a<i;){let t=e.charCodeAt(a);if(t!==32&&t!==9&&t!==10&&t!==13)return;a++}},l=t=>{a++;let n=``;for(;a<i;){let r=a,i=e[a++];if(i===`"`)return n;if(i.charCodeAt(0)<32)throw new F0(r);if(i!==`\\`){t&&(n+=i);continue}let o=a,s=e[a++],c;if(s===`"`||s===`\\`||s===`/`)c=s;else if(s===`b`)c=`\b`;else if(s===`f`)c=`\f`;else if(s===`n`)c=`
|
|
1066
1066
|
`;else if(s===`r`)c=`\r`;else if(s===`t`)c=` `;else if(s===`u`){let t=e.slice(a,a+4);if(!/^[\dA-Fa-f]{4}$/.test(t))throw new F0(a);c=String.fromCharCode(parseInt(t,16)),a+=4}else throw new F0(o);t&&(n+=c)}throw new F0(a)},u=t=>{for(let n=0;n<t.length;n++)if(e[a+n]!==t[n])throw new F0(a+n);a+=t.length},d=()=>{if(e.charCodeAt(a)===45&&a++,e.charCodeAt(a)===48)a++;else if(rq(e.charCodeAt(a)))for(;rq(e.charCodeAt(a));)a++;else throw new F0(a);if(e.charCodeAt(a)===46){if(a++,!rq(e.charCodeAt(a)))throw new F0(a);for(;rq(e.charCodeAt(a));)a++}if((e.charCodeAt(a)|32)==101){if(a++,(e.charCodeAt(a)===43||e.charCodeAt(a)===45)&&a++,!rq(e.charCodeAt(a)))throw new F0(a);for(;rq(e.charCodeAt(a));)a++}};for(c();;)if(s===0){c();let i=e.charCodeAt(a);if(s=2,i===123){a++;let i=[];t.set(o,i),n.push(o),c(),e.charCodeAt(a)===125?a++:(r.push({object:!0,pointer:o,keys:i,ranges:/* @__PURE__ */ new Map,key:``,from:0,index:0}),s=1)}else if(i===91)a++,c(),e.charCodeAt(a)===93?a++:(r.push({object:!1,pointer:o,keys:[],ranges:/* @__PURE__ */ new Map,key:``,from:0,index:0}),o+=`/0`,s=0);else if(i===34)l(!1);else if(i===116)u(`true`);else if(i===102)u(`false`);else if(i===110)u(`null`);else if(i===45||rq(i))d();else throw new F0(a)}else if(s===1){let i=r[r.length-1];if(e.charCodeAt(a)!==34)throw new F0(a);let u=l(!0),d=i.ranges.get(u);if(d===void 0)i.keys.push(u);else for(let e=d[0];e<d[1];e++)t.delete(n[e]);if(i.key=u,i.from=n.length,c(),e.charCodeAt(a)!==58)throw new F0(a);a++,o=`${i.pointer}/${u.replaceAll(`~`,`~0`).replaceAll(`/`,`~1`)}`,s=0}else{let t=r[r.length-1];if(t===void 0)break;t.object?t.ranges.set(t.key,[t.from,n.length]):t.index++,c();let i=e.charCodeAt(a);if(i===(t.object?125:93))a++,r.pop();else{if(i!==44)throw new F0(a);a++,c(),o=`${t.pointer}/${t.index}`,s=+!!t.object}}if(c(),a!==i)throw new F0(a);return t}function I0(e,t,n,r){let i=Math.min(Math.max(t,0),e.length);for(let t=0;t<i;t++){let i=e.charCodeAt(t);i===13?(n++,r=1):i===10?(t===0||e.charCodeAt(t-1)!==13)&&(n++,r=1):r++}return[n,r]}function ijt(e,t,n,r){let i=/\bposition (\d+)\b/.exec(e);if(i)return I0(t,parseInt(i[1],10),n,r);let a=/\bline (\d+) column (\d+)\b/.exec(e);if(a){let e=parseInt(a[1],10),t=parseInt(a[2],10);return[n+e-1,e===1?r+t-1:t]}if(/unexpected end|end of json input/i.test(e))return I0(t,t.length,n,r)}function ajt(e,t,n){return new NK(`${e} (line ${t}, column ${n})`,`syntax`,{type:`usecase`,line:t,column:n})}function ojt(e,t){let n;try{n=JSON.parse(e)}catch(n){let r=n instanceof Error?n.message:String(n),[i,a]=t(),o=ijt(r,e,i,a);if(!o){let t=0;try{rjt(e)}catch(e){e instanceof F0&&(t=e.offset)}o=I0(e,t,i,a)}throw ajt(`Invalid JSON: ${r}`,o[0],o[1])}if(typeof n!=`object`||!n||Array.isArray(n)){let[e,n]=t();throw ajt(`JSON value must have an object root`,e,n)}return{value:n,propertyOrder:rjt(e)}}var sjt=1,L0=2,R0=4,cjt=8,ljt=16,ujt=32,djt=64,z0=`DEPENDENCY_ARROW|GENERALIZATION|FORWARD_SOLID|BACKWARD_SOLID|MARKERLESS_SOLID|FORWARD_CIRCLE|BACKWARD_CIRCLE|FORWARD_CROSS|BACKWARD_CROSS`,B0=`IDENTIFIER|PLAIN_STRING|MARKDOWN_STRING`,fjt=`PLAIN_STRING|MARKDOWN_STRING|LABEL_TEXT`,pjt=`ACC_TITLE_LINE|ACC_DESCR_LINE|ACC_DESCR_BLOCK|DIRECTION|ACTOR|SYSTEM_BOUNDARY|NOTE|JSON_DECLARATION_START|CLASS_DEF|CLASS|STYLE`,mjt=`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`,V0=/* @__PURE__ */ new Uint8Array(67);function H0(e,t){for(let n of e.split(`|`))if(n===`WORD`)for(let e=1;e<=21;e++)V0[e]|=t;else V0[WAt.indexOf(n)]|=t}H0(`NEWLINE|COMMENT|${pjt}|${B0}`,sjt),H0(`IDENTIFIER|${z0}`,L0),H0(mjt,R0),H0(`STEREOTYPE_START|CLASS_SEPARATOR|IDENTIFIER|${z0}|NEWLINE|EOF`,cjt),H0(`NEWLINE|COMMENT|ACTOR|${B0}`,ljt),H0(`FORWARD_SOLID|MARKERLESS_SOLID|FORWARD_CIRCLE|FORWARD_CROSS`,ujt),H0(`NEWLINE|IDENTIFIER|PLAIN_STRING|RBRACE`,djt);var hjt=/* @__PURE__ */ new Set([`allowmixing`,`newpage`,`package`,`rectangle`,`skinparam`]),U0=``,W0=[],G0=[],K0=[],q0=0,gjt=0,J0,Y0,X0=[],_jt=0,vjt=0;function Z0(e){return U0.slice(G0[e],K0[e])}function Q0(e){return[G0[e],K0[e]]}function $0(e){let[t,n]=N0(U0,G0[q0]);throw new NK(`Error parsing usecase diagram: ${e} at line ${t}, column ${n} [${G0[q0]},${K0[q0]})`,`syntax`,{type:`usecase`,line:t,column:n})}function yjt(e){$0(`Expecting token of type --> ${e} <-- but found --> '${Z0(q0)}' <--`)}function e2(e){return W0[q0]!==e&&yjt(WAt[e]),q0++}function t2(e){$0(`Expecting: one of these possible Token sequences:
|
|
1067
1067
|
${e.split(`|`).map((e,t)=>` ${t+1}. [${e}]`).join(`
|
|
1068
1068
|
`)}
|
|
1069
1069
|
but found: '${Z0(q0)}'`)}function bjt(){let e=B0.split(`|`),t=e.flatMap(e=>[`NEWLINE`,`IDENTIFIER`,`PLAIN_STRING`,`RBRACE`].map(t=>`${e}, METADATA_START, ${t}`)),n=`STEREOTYPE_START|CLASS_SEPARATOR|IDENTIFIER|${z0}|NEWLINE|EOF`.split(`|`),r=e.flatMap((e,t)=>(t===0?[`LPAREN`,`LBRACKET`,...n]:n).map(t=>`${e}, ${t}`));return[pjt,...t,...r,...t].join(`|`)}function xjt(e){return e>=1&&e<=21}function Sjt(e){return e>=1&&e<=34}function n2(){gjt=K0[q0-1],W0[q0]===39?q0++:W0[q0]!==0&&t2(`NEWLINE|EOF`)}function r2(e){let t=W0[e]===36?2:+(W0[e]===35);return[G0[e]+t,K0[e]-t]}function i2(e){let t=r2(e);return{text:U0.slice(t[0],t[1]),type:W0[e]===36?`markdown`:`text`,span:t}}function Cjt(e){return e.replace(/\W/g,`_`)}function a2(){let e=W0[q0];if(e===35||e===36)return i2(q0++);Sjt(e)||t2(fjt);let t=q0;for(;Sjt(W0[q0]);)q0++;let n=[G0[t],K0[q0-1]];return{text:U0.slice(n[0],n[1]),type:`text`,span:n}}function o2(e){return e===21||e===35}function wjt(){let e=q0;o2(W0[q0])||t2(`IDENTIFIER|PLAIN_STRING`),q0++,e2(25);let t=q0,n=W0[q0];!o2(n)&&n!==19&&n!==20&&t2(`IDENTIFIER|PLAIN_STRING|TRUE|FALSE`),q0++;let r=r2(e),i=r2(t);return{key:U0.slice(r[0],r[1]),value:n===19||n!==20&&U0.slice(i[0],i[1]),span:[G0[e],K0[t]],keySpan:r,valueSpan:i}}function Tjt(){let e=W0[q0],t=W0[q0+1],n=W0[q0+2];return e===24?o2(t)||t===39&&(n===39||o2(n)):e===39?t===24||o2(t)||t===39&&(n===39||n===24||o2(n)):!1}function s2(){e2(60);let e=[];for(;W0[q0]===39;)q0++;if(o2(W0[q0])){for(e.push(wjt());Tjt();){if(W0[q0]===24)q0++;else{for(;W0[q0]===39;)q0++;W0[q0]===24&&q0++}for(;W0[q0]===39;)q0++;e.push(wjt())}for(W0[q0]===24&&q0++;W0[q0]===39;)q0++}return e2(62),e}function c2(e){return e.map(({key:e,span:t,keySpan:n,valueSpan:r})=>({key:e,span:t,keySpan:n,valueSpan:r}))}function l2(e,t){do{q0++;let n=e2(21);e.push(Z0(n)),t.push(Q0(n))}while(W0[q0]===24)}function Ejt(e){let t=q0,n=W0[q0],r={id:``,label:void 0,span:r2(t),generated:n!==21,classes:[],classSpans:[],explicit:!1,nodeSpan:[0,0]};if(n===21){q0++,r.id=Z0(t);let n=W0[q0];n===65||e&&n===63?(q0++,r.label=a2(),e2(n===65?66:64),r.shape=n===65?`ellipse`:`rect`):r.label=i2(t)}else n===35||n===36?(q0++,r.label=i2(t),r.id=Cjt(r.label.text)):t2(B0);return r}function u2(e){let t=q0,n=Ejt(!e);if(e&&(n.shape=void 0),W0[q0]===60&&(n.metadata=s2()),W0[q0]===48){q0++;let e=e2(50);e2(49),n.stereotype=Z0(e).trim(),n.stereotypeSpan=Q0(e)}return W0[q0]===52&&l2(n.classes,n.classSpans),n.explicit=!!(n.shape||n.metadata||n.stereotype),n.nodeSpan=[G0[t],K0[q0-1]],n}function d2(e,t){return{id:e.id,kind:t,label:e.label,span:e.span,generated:e.generated,parent:Y0,shape:e.shape,metadata:e.metadata,stereotype:e.stereotype,classes:e.classes}}function Djt(e,t){return{id:e.id,label:e.label,span:e.span,generated:e.generated,declares:t,classed:e.classes.length>0}}function f2(e,t){let n={id:e.id,span:e.nodeSpan,idSpan:e.span,labelSpan:e.label.span};return t&&(n.defines=!0),e.stereotypeSpan&&(n.stereotypeSpan=e.stereotypeSpan),e.metadata&&(n.metadata=c2(e.metadata)),e.classSpans.length>0&&(n.classSpans=e.classSpans),n}function p2(e){if(W0[q0]<1||W0[q0]>36)return!1;for(let t=q0+1;;t++){let n=W0[t];if(n===59||(V0[n]&e)!==0)return!0;if(n<1||n>36)return!1}}function m2(e){let t=K0[e]-G0[e]-(W0[e]===59?0:1);return Math.max(1,t-1)}function Ojt(){let e=q0,t={type:`association`,arrowType:0,minlen:1,target:void 0,span:[0,0]};W0[q0]===21&&W0[q0+1]===23&&(t.explicitId=Z0(q0),t.explicitIdSpan=Q0(q0),q0+=2);let n=q0,r=W0[q0++];if(r===47)e2(25),W0[q0]!==17&&W0[q0]!==18&&t2(`INCLUDE|EXTEND`),t.type=W0[q0]===17?`include`:`extend`,t.label={text:t.type,type:`text`,span:Q0(q0)},q0++;else if(r===46)t.type=`generalization`;else if(r===53)t.minlen=m2(n);else if(r===54)t.arrowType=1,K0[n]-G0[n]===3&&p2(0)?(t.label=a2(),t.minlen=m2(e2(59))):t.minlen=m2(n);else if(r===59){if(t.arrowType=2,K0[n]-G0[n]===2&&p2(ujt)){t.label=a2();let e=W0[q0];e===53?t.arrowType=0:e===55?t.arrowType=3:e===57?t.arrowType=4:e!==59&&t2(`FORWARD_SOLID|MARKERLESS_SOLID|FORWARD_CIRCLE|FORWARD_CROSS`),(t.arrowType===0||t.arrowType===2)&&(t.minlen=m2(q0)),q0++}else t.minlen=m2(n)}else r===55?t.arrowType=3:r===57?t.arrowType=4:r===56||r===58?(t.arrowType=r===56?5:6,p2(0)&&(t.label=a2(),e2(59))):(q0--,t2(z0));return t.target=u2(!1),t.span=[G0[e],K0[q0-1]],t}function h2(e){return{kind:e,span:[0,0]}}function kjt(e,t,n,r){let i=n.target;i.explicit&&J0.elements.push(d2(i,`usecase`)),J0.relationships.push({source:Djt(e,t),target:Djt(i,i.explicit),span:n.span,id:n.explicitId,idSpan:n.explicitIdSpan,type:n.type,arrowType:n.arrowType,label:n.label,minlen:n.minlen}),r.push(f2(i,i.explicit));let a=h2(`edge`);return a.nodes=r,a.edges=[{id:n.explicitId??`edge-${_jt++}`,span:a.span}],n.explicitIdSpan&&(a.edges[0].idSpan=n.explicitIdSpan),n.label&&(a.edges[0].labelSpan=n.label.span),a}function Ajt(e){let t=h2(`node`);return t.nodes=e,t}function jjt(e){q0++;let t=[u2(!0)],n;if(W0[q0]===24)do q0++,t.push(u2(!0));while(W0[q0]===24);else e&&(V0[W0[q0]]&L0)!==0&&(n=Ojt());n2();for(let e of t)J0.elements.push(d2(e,`actor`));let r=t.map(e=>f2(e,!0));return n?kjt(t[0],!0,n,r):Ajt(r)}function Mjt(e){let t=u2(!1),n=e&&(V0[W0[q0]]&L0)!==0?Ojt():void 0;n2(),n||(t.explicit=!0,t.shape??=`ellipse`),t.explicit&&J0.elements.push(d2(t,`usecase`));let r=[f2(t,t.explicit)];return n?kjt(t,t.explicit,n,r):Ajt(r)}function Njt(){q0++;let e=Ejt(!0),t={id:e.id,label:e.label,span:e.span,generated:e.generated,classes:e.classes},n=W0[q0]===60?s2():void 0;W0[q0]===52&&l2(e.classes,e.classSpans),n2(),J0.boundaries.push(t),Y0=t;let r=[];for(;(V0[W0[q0]]&ljt)!==0;)r.push(Ljt(!1));Y0=void 0;let i=e2(4);n2();let a=h2(`group`);return a.group=t.id,a.idSpan=t.span,a.titleSpan=t.label.span,a.endSpan=Q0(i),a.classSpans=e.classSpans,r.length>0&&(a.children=r),n&&(a.metadata=c2(n),J0.metadata.push({target:t.id,span:t.span,properties:n,statement:a})),a}function Pjt(){let e=q0,t=W0[q0];for(xjt(t)||t===27?q0++:t===59?(q0++,xjt(W0[q0])||yjt(`WORD`),q0++):t2(`WORD|CSS_IDENTIFIER|MARKERLESS_SOLID`),e2(25),(V0[W0[q0]]&R0)===0&&$0(`Expecting: expecting at least one iteration which starts with one of these possible Token sequences::
|
|
1070
1070
|
<[${mjt.replaceAll(`|`,`] ,[`)}]>
|
|
1071
|
-
but found: '${Z0(q0)}'`);(V0[W0[q0]]&R0)!==0;)q0++;return U0.slice(G0[e],K0[q0-1]).replaceAll(`\\,`,`,`)}function Fjt(){let e=[Pjt()];for(;W0[q0]===24;)q0++,e.push(Pjt());return e}function g2(){let e=[e2(21)];for(;W0[q0]===24;)q0++,e.push(e2(21));return e}function _2(e){let t=r2(e);return{id:Z0(e),span:t,idSpan:t}}function Ijt(){let e=q0,t=W0[q0],n;if(t===41||t===42||t===40){q0++;let r=Z0(e);t===40?J0.accDescription=r.slice(r.indexOf(`{`)+1,r.lastIndexOf(`}`)).trim():t===42?J0.accDescription=r.slice(r.indexOf(`:`)+1).trim():J0.accTitle=r.slice(r.indexOf(`:`)+1).trim(),n=h2(t===41?`accTitle`:`accDescr`)}else if(t===5){q0++;let e=W0[q0];(e<6||e>10)&&t2(`TD|TB|BT|LR|RL`),J0.direction=e===6?`TB`:Z0(q0),q0++,n=h2(`direction`)}else{if(t===2)return jjt(!0);if(t===3)return Njt();if(t===11){q0++,e2(12);let e=e2(21),t=a2();J0.notes.push({target:Z0(e),span:Q0(e),label:t}),n=h2(`note`),n.ref=`note-${vjt++}`,n.refSpan=t.span,n.nodes=[_2(e)]}else if(t===43){q0++;let t=e2(44),r=[],i=[];W0[q0]===52&&l2(r,i);let a=G0[e]+4;for(;U0.charCodeAt(a)===32||U0.charCodeAt(a)===9;)a++;let o=a;for(;/\w/.test(U0.charAt(o));)o++;let s={id:U0.slice(a,o),value:{},propertyOrder:/* @__PURE__ */ new Map,span:[a,o],classes:r};J0.jsons.push(s),X0.push([s,t]),n=h2(`json`),n.nodes=[{id:s.id,span:s.span,idSpan:s.span,defines:!0,classSpans:i}],n.classSpans=i}else if(t===14){q0++;let e=g2();J0.classDefs.push({ids:e.map(Z0),styles:Fjt()}),n=h2(`classDef`),n.ref=Z0(e[0]),n.refSpan=Q0(e[0])}else if(t===15){q0++;let e=g2(),t=g2();J0.classes.push({targets:e.map(e=>({id:Z0(e),span:Q0(e)})),classes:t.map(Z0)}),n=h2(`classAssign`),n.ref=Z0(t[0]),n.refSpan=Q0(t[0]),n.nodes=e.map(_2)}else if(t===16){q0++;let e=e2(21);J0.styles.push({target:Z0(e),span:Q0(e),styles:Fjt()}),n=h2(`style`),n.nodes=[_2(e)]}else{let r=W0[q0+1];if(r===60){(V0[W0[q0+2]]&djt)===0&&t2(bjt()),q0++;let r=_2(e);t!==21&&(r.id=Cjt(U0.slice(r.span[0],r.span[1])));let i=s2();n=h2(`metadata`),n.nodes=[r],n.metadata=c2(i),J0.metadata.push({target:r.id,span:r.span,properties:i,statement:n})}else return((V0[r]&cjt)===0&&(t!==21||r!==65&&r!==63)||t===21&&hjt.has(Z0(e).toLowerCase()))&&t2(bjt()),Mjt(!0)}}return n2(),n}function Ljt(e){let t=q0,n=W0[q0];if(n===39)return q0++,{kind:`blank`,span:Q0(t)};if(n===38)return q0++,n2(),{kind:`comment`,span:Q0(t)};let r=e?Ijt():n===2?jjt(!1):Mjt(!1);if(r.span=[G0[t],gjt],r.edges)for(let e of r.edges)e.span=r.span;return r}function Rjt(e,t){U0=e,{types:W0,starts:G0,ends:K0}=QAt(e),q0=0,J0=ejt(),Y0=void 0,X0=[],_jt=0,vjt=0;try{let n=e2(1);n2();let r=[];for(;(V0[W0[q0]]&sjt)!==0;)r.push(Ljt(!0));W0[q0]!==0&&$0(`Redundant input, expecting EOF but found: ${Z0(q0)}`);for(let[t,n]of X0){let r=ojt(Z0(n),()=>N0(e,G0[n]));t.value=r.value,t.propertyOrder=r.propertyOrder}return njt(e,J0,Q0(n),r,t)}finally{U0=``,W0=G0=K0=X0=[]}}var zjt={normal:`usecaseActor`,hollow:`usecaseActorHollow`,awesome:`usecaseActorAwesome`,icon:`usecaseActorIcon`},v2=[[`none`,`arrow_point`],[`arrow_point`,`none`],[`none`,`none`],[`none`,`arrow_circle`],[`none`,`arrow_cross`],[`arrow_circle`,`none`],[`arrow_cross`,`none`]];function Bjt(e){return typeof e==`string`?e:e===null?`null`:String(e)}function Vjt(e){let t=[],n=[[e.value,``,``]],r=[];for(;n.length>0;){let[i,a,o]=n.pop();if(r.length=0,Array.isArray(i))i.length===0?t.push({key:a,accessibleKey:a,value:`[]`}):i.every(e=>typeof e!=`object`||!e)?i.forEach((e,n)=>t.push({key:n===0?a:``,accessibleKey:a,value:Bjt(e)})):i.forEach((e,t)=>r.push([e,`${a}[${t}]`,`${o}/${t}`]));else if(typeof i==`object`&&i){let n=i,s=e.propertyOrder.get(o)??Object.keys(n);s.length===0&&t.push({key:a,accessibleKey:a,value:`{}`});for(let e of s)r.push([Object.prototype.hasOwnProperty.call(n,e)?n[e]:void 0,a?`${a}.${e}`:e,`${o}/${e.replaceAll(`~`,`~0`).replaceAll(`/`,`~1`)}`])}else t.push({key:a,accessibleKey:a,value:Bjt(i)});for(let e=r.length-1;e>=0;e--)n.push(r[e])}return t}function y2(...e){return e.filter(Boolean).join(` `)}function Hjt(e){return e.type===`generalization`?[`none`,`extension`]:e.type===`association`?v2[e.arrowType]??v2[2]:v2[0]}function Ujt(e){let t=[],n=[],r=t=>{let n=/* @__PURE__ */ new Map;for(let r of[`default`,...t]){let t=e.classDefs.get(r);if(t)for(let e of t.styles){let t=e.trim(),r=t.indexOf(`:`),i=(r===-1?t:t.slice(0,r)).trim();i&&n.set(i,t)}}return[...n.values()]};for(let n of e.actors.values())t.push({id:n.id,label:n.label,labelType:n.labelType,shape:zjt[n.type],isGroup:!1,padding:10,cssClasses:y2(`default`,`usecase-actor`,`usecase-actor-${n.type}`,n.business&&`usecase-business`,...n.classes),cssStyles:[...n.styles],cssCompiledStyles:r(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 e.useCases.values()){let e=n.shape===`ellipse`;t.push({id:n.id,label:n.label,labelType:n.labelType,shape:e?n.business?`usecaseBusiness`:`usecaseEllipse`:`rect`,isGroup:!1,padding:e?20:10,cssClasses:y2(`default`,`usecase-element`,`usecase-${n.shape}`,n.business&&`usecase-business`,...n.classes),cssStyles:[...n.styles],cssCompiledStyles:r(n.classes),business:n.business,stereotype:n.stereotype||void 0,parentId:n.parentId||void 0})}for(let n of e.notes.values())t.push({id:n.id,label:n.label,labelType:n.labelType,shape:`note`,isGroup:!1,padding:10,cssClasses:`default usecase-note`,cssStyles:[],cssCompiledStyles:r([]),noteTarget:n.target});for(let n of e.jsonNodes.values())t.push({id:n.id,label:n.id,labelType:`text`,shape:`usecaseJsonTable`,isGroup:!1,padding:10,cssClasses:y2(`default`,`usecase-json-table`,...n.classes),cssStyles:[...n.styles],cssCompiledStyles:r(n.classes),jsonRows:Vjt(n)});for(let n of e.systemBoundaries.values())t.push({id:n.id,label:n.label,labelType:n.labelType,shape:`usecaseSystemBoundary`,isGroup:!0,padding:20,cssClasses:y2(`default`,`system-boundary`,`system-boundary-${n.type}`,...n.classes),cssStyles:[...n.styles],cssCompiledStyles:r(n.classes),boundaryType:n.type});for(let t of e.relationships){let e=t.type===`include`||t.type===`extend`,[i,a]=Hjt(t),o=t.animate||t.animation!==void 0,s={id:t.id,start:t.source,end:t.target,relationshipType:t.type,pattern:e?`dotted`:`solid`,arrowTypeStart:i,arrowTypeEnd:a,classes:y2(`default`,`relationship`,`relationship-${t.type}`,...t.classes,o&&`edge-animation-${t.animation??`fast`}`),style:[...t.styles],cssCompiledStyles:r(t.classes),animate:t.animate,animation:t.animation,minlen:t.minlen,explicitId:t.explicitId,internal:!1};e?(s.label=t.type,s.labelType=`text`):t.type===`association`&&(t.label&&(s.label=t.label),t.labelType&&(s.labelType=t.labelType)),n.push(s)}for(let t of e.notes.values())n.push({id:`${t.id}-edge`,start:t.id,end:t.target,relationshipType:`note`,pattern:`dotted`,arrowTypeStart:`none`,arrowTypeEnd:`none`,classes:`default relationship relationship-note`,style:[],cssCompiledStyles:r([]),animate:!1,minlen:1,explicitId:!1,internal:!0});return{nodes:t,edges:n}}var Wjt=32,Gjt=16,Kjt=72,b2=20,x2=26,S2=40,C2=60,qjt=6,w2=6,T2=10,E2=8,D2=9,O2=12,Jjt=14,k2=` fill="var(--_s)" stroke="var(--_b)"`;function Yjt(e,t,n){let r=e.usecase?.[t];return typeof r==`number`&&r>0?Math.min(r,2e3):n}function Xjt(e){return e.replace(/[&<>\\]/g,e=>`&#${e.charCodeAt(0)};`)}function A2(e,t,n,r,i,a=0){return WJ(e&&!t?Xjt(e):e,t,n,r,i,a)}function j2(e,t,n,r){let i=n===1||n===2?1:-1,a=n===1||n===3,o=(a?e.w:e.h)/2,s=0;if(e.kind===0)a?(o=S2/2+3,s=(C2-e.h)/2):o+=2;else if(e.kind===1){let t=(a?e.h:e.w)/2;o*=Math.sqrt(Math.max(1-(r/t)**2,0))}return a?[t.x+i*o,t.y+s+r]:[t.x+r,t.y+i*o]}function Zjt(e,t){let n=t===1||t===3;if(e.kind===0)return n?C2*.5:S2*.6;let r=n?e.h:e.w;return e.kind===1?r*.6:r-16}function Qjt(e,t,n){let r=/* @__PURE__ */ new Map,i=(e,n,i,a)=>{let o=t[e];if(o.isGroup)return;let s=n[i]-o.x,c=n[i+1]-o.y,l;if(Math.abs(Math.abs(c)-o.h/2)<.5)l=c<0?0:2;else if(Math.abs(Math.abs(s)-o.w/2)<.5)l=s<0?3:1;else return;let u=e*4+l,d={route:n,at:i,toward:n[a+(l&1?1:0)]},f=r.get(u);f?f.push(d):r.set(u,[d])};for(let t of e){let e=t.route.length-3;t.src===t.dst||e<3||(i(t.src,t.route,0,3),i(t.dst,t.route,e,e-3))}for(let[e,i]of r){let r=e>>2,a=e&3,o=n[r],s=i.length>1?Math.min(Jjt,Zjt(o,a)/(i.length-1)):0;i.sort((e,t)=>e.toward-t.toward);for(let e=0;e<i.length;e++){let[n,c]=j2(o,t[r],a,(e-(i.length-1)/2)*s);i[e].route[i[e].at]=n,i[e].route[i[e].at+1]=c}}}function $jt(e,t,n,r,i){let a=e-n*O2,o=t-r*O2,s=O2*.5;return`<path class="pele-marker" d="M${K(e)},${K(t)}L${K(a-r*s)},${K(o+n*s)}L${K(a+r*s)},${K(o-n*s)}Z" fill="var(--_bg)" stroke="${i}" stroke-linejoin="round"/>`}function M2(e){return e===`extension`?O2:sJ(e)}function eMt(e,t,n,r,i,a){return e===`extension`?$jt(t,n,r,i,a):cJ(e,t,n,r,i,a)}function tMt(e,t){let n=e.node,r=e.style.shape,i=` fill="none" stroke="var(--_b)"${e.style.line}`,a=-21,o=9,s;return n.actorType===`hollow`?(o=8,s=`<circle cy="-21" r="8" fill="var(--_bg)" stroke="var(--_b)"${r}/><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"${r}/>`):n.actorType===`awesome`?s=`<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)"${r}/>`:n.actorType===`icon`?(a=-14,o=12,s=`<rect x="-22" y="-26" width="44" height="44" rx="${fJ}"${k2}${r}/><svg class="pele-icon" data-icon="${mq(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">${t?.(n.icon??``)??``}</svg>`):s=`<circle cy="-21" r="9"${k2}${r}/><path d="M0,-12V10M-14,-3H14M0,10L-12,30M0,10L12,30"${i}/>`,n.business&&(s+=`<path class="pele-business" d="M${K(.12*o)},${K(a+.99*o)}L${K(.92*o)},${K(a-.39*o)}"${i}/>`),s}function nMt(e,t,n){return YJ(e.direction)?JJ(n,r=>rMt(e,t,n,r)):rMt(e,t,n,!1)}function rMt(e,t,n,r){let i=Ujt(e),a=n.fontSize??16,o=Math.round(a*.875),s=Math.round(a*.8125),c=n.measurer??fq(n.fontFamily),l=n.padding??8,u=n.icons,d=r?`TB`:Xq(e.direction),f=d===`LR`||d===`RL`,p=/* @__PURE__ */ new Map,m=[],h=[];i.nodes.forEach((e,t)=>p.set(e.id,t));for(let e of i.nodes){let t=mJ(e.cssStyles.length>0?e.cssCompiledStyles.concat(e.cssStyles):e.cssCompiledStyles),n=+!!t.bold|(t.italic?2:0),r=t.fontSize??a,i=e.labelType===`markdown`,l=A2(e.stereotype&&`«${e.stereotype}»`,!1,c,s,200,n),u={node:e,kind:2,style:t,label:l,stereotype:l,w:0,h:0,rows:[],keyW:0,headH:0,loops:0},d;if(e.isGroup){u.kind=4,u.label=A2(e.label,i,c,r,4e3,n);let t=u.label.height;d=Qq(0,0),d.isGroup=!0,d.padX=b2,d.padBottom=b2,d.padTop=e.boundaryType===`package`?t+2*w2+16:t>0?t+16:b2,d.minW=u.label.width+2*b2}else{if(e.jsonRows){u.kind=3,u.label=A2(e.label,!1,c,r,4e3,n|1);let t=0;for(let r of e.jsonRows){let e=A2(r.key,!1,c,o,4e3,n),i=A2(r.value,!1,c,o,260,n);u.rows.push([e,i]),u.keyW=Math.max(u.keyW,e.width),t=Math.max(t,i.width),u.h+=Math.max(i.height,Math.round(o*1.5))+E2}u.keyW>0&&(u.keyW+=2*T2),u.headH=Math.max(u.label.height,Math.round(r*1.5))+E2,u.w=Math.max(u.label.width+2*T2,u.rows.length>0?u.keyW+t+2*T2:0,72),u.h+=u.headH}else if(e.actorType)u.kind=0,u.label=A2(e.label,i,c,r,140,n),u.w=Math.max(S2,u.label.width,l.width),u.h=C2+qjt+l.height+u.label.height;else{u.label=A2(e.label,i,c,e.shape===`note`?o:r,180,n);let t=Math.max(u.label.width,l.width),a=u.label.height+l.height;e.shape===`usecaseEllipse`||e.shape===`usecaseBusiness`?(u.kind=1,u.w=Math.max(t+2*e.padding+(e.business?16:4),88),u.h=Math.max(a+28,48)):e.shape===`note`?(u.w=t+2*e.padding+6,u.h=a+18):(u.w=Math.max(t+2*e.padding+12,80),u.h=Math.max(a+24,44))}d=Qq(u.w,u.h)}d.seq=m.length,m.push(u),h.push(d)}i.nodes.forEach((e,t)=>{h[t].parent=e.parentId===void 0?-1:p.get(e.parentId)??-1});let g=[],_=[],v=[];for(let e of i.edges){let t=p.get(e.start),n=p.get(e.end);if(t===void 0||n===void 0)continue;let r=A2(e.relationshipType===`include`||e.relationshipType===`extend`?`«${e.label}»`:e.label,e.labelType===`markdown`,c,o,200);t===n&&(m[t].loops++,f?h[t].h+=2*(x2+(r.height>0?r.height+8:0)):h[t].w+=2*(x2+(r.width>0?r.width+12:0))),v.push(e),_.push(r),g.push({src:t,dst:n,minlen:e.minlen,labelW:r.width>0?r.width+12:0,labelH:r.height>0?r.height+4:0,route:[],labelX:0,labelY:0})}let y=eJ(h,g,d,{nodeSep:Yjt(t,`nodeSpacing`,Wjt),edgeSep:Gjt,rankSep:Yjt(t,`rankSpacing`,Kjt),portSep:20}),b=WJ(e.title,!1,c,a,4e3,1),x=b.height>0?b.height+12:0,S=Math.max(y.width,b.width);Zq(h,g,l+(S-y.width)/2,l+x);let C=Math.ceil(S+2*l),w=Math.ceil(y.height+x+2*l),T=/* @__PURE__ */ new Map;for(let e of g)tJ(T,e.route);Qjt(g,h,m);let E=``,D=``;for(let e=0;e<m.length;e++){let t=m[e],n=h[e],r=t.node,i=hJ(r.cssClasses.replace(/^default\s?/,``)),a=mq(r.id),c=t.style.text,l=t.style.shape,d=t.w,f=t.h;if(t.kind===4){let e=n.x-n.w/2,o=n.y-n.h/2,s=` fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${l}`,d=` class="pele-cluster-label" fill="var(--_m)"${c}`,f;if(r.boundaryType===`package`){let r=Math.min(t.label.width+2*w2+8,n.w),i=t.label.height+2*w2;f=`<rect class="pele-boundary-tab" x="${K(e)}" y="${K(o)}" width="${K(r)}" height="${K(i)}"${s}/><rect x="${K(e)}" y="${K(o+i)}" width="${K(n.w)}" height="${K(n.h-i)}"${s}/>`+gq(t.label,e+r/2,o+i/2,d,u)}else f=`<rect x="${K(e)}" y="${K(o)}" width="${K(n.w)}" height="${K(n.h)}" rx="${fJ}"${s}/>`+gq(t.label,iMt(n,t.label.width,T),o+8+t.label.height/2,d,u);E+=`<g class="pele-cluster pele-boundary${i}" data-id="${a}">${f}</g>`;continue}let p,g;if(t.kind===0){g=`pele-actor`;let e=-f/2,n=e+C2+qjt+t.stereotype.height/2;p=`<g class="pele-actor-figure" transform="translate(0,${K(e+C2/2)})">${tMt(t,u)}</g>`+gq(t.stereotype,0,n,` class="pele-stereotype" font-size="${s}" fill="var(--_m)"`,u)+gq(t.label,0,f/2-t.label.height/2,` class="pele-label"${c}`,u)}else if(t.kind===3){g=`pele-json`;let e=-d/2,n=-f/2+t.headH,r=``,i=`M${K(e)},${K(n)}H${K(e+d)}`;t.keyW>0&&(i+=`M${K(e+t.keyW)},${K(n)}V${K(f/2)}`);for(let[i,a]of t.rows){let s=Math.max(a.height,Math.round(o*1.5))+E2;r+=gq(i,e+T2+i.width/2,n+s/2,` class="pele-json-key" fill="var(--_m)"`,u)+aMt(a,e+t.keyW+T2,n+s/2,` class="pele-json-value"${c}`,u),n+=s}p=`<rect x="${K(e)}" y="${K(-f/2)}" width="${K(d)}" height="${K(f)}" rx="${fJ}"${k2}${l}/><path class="pele-json-lines" d="${i}" fill="none" stroke="var(--_b)"${t.style.line}/>`+gq(t.label,0,-f/2+t.headH/2,` class="pele-label" font-weight="var(--_hw)"${c}`,u)+`<g font-size="${o}">${r}</g>`}else{let e=t.stereotype.height/2,n;if(t.kind===1){if(g=`pele-usecase`,n=`<ellipse rx="${K(d/2)}" ry="${K(f/2)}"${k2}${l}/>`,r.business){let e=d/2-15,r=d/2-5,i=e=>f/2*Math.sqrt(1-(e/(d/2))**2);n+=`<path class="pele-business" d="M${K(e)},${K(i(e))}L${K(r)},${K(-i(r))}" fill="none" stroke="var(--_b)"${t.style.line}/>`}}else if(r.shape===`note`){g=`pele-note`;let e=d/2,r=f/2;n=`<path d="M${K(-e)},${K(-r)}H${K(e-D2)}L${K(e)},${K(D2-r)}V${K(r)}H${K(-e)}Z" fill="var(--_a)" stroke="var(--_b)" stroke-linejoin="round"${l}/><path d="M${K(e-D2)},${K(-r)}V${K(D2-r)}H${K(e)}" fill="none" stroke="var(--_b)" stroke-linejoin="round"${t.style.line}/>`}else g=`pele-usecase`,n=`<rect x="${K(-d/2)}" y="${K(-f/2)}" width="${K(d)}" height="${K(f)}" rx="${fJ}"${k2}${l}/>`;p=n+gq(t.stereotype,0,-t.label.height/2,` class="pele-stereotype" font-size="${s}" fill="var(--_m)"`,u)+gq(t.label,0,e,` class="pele-label"${r.shape===`note`?` font-size="${o}"`:``}${c}`,u)}D+=`<g class="pele-node ${g}${i}" data-id="${a}" transform="translate(${K(n.x)},${K(n.y)})">${p}</g>`}let O=``,k=``,A=/* @__PURE__ */ new Map;for(let e=0;e<g.length;e++){let t=g[e],n=v[e],r=_[e],i=n.style.length>0||n.cssCompiledStyles.length>0?mJ(n.cssCompiledStyles.concat(n.style)):void 0,a=n.arrowTypeStart,o=n.arrowTypeEnd,s;if(t.src===t.dst){let e=h[t.src],n=m[t.src],i=A.get(t.src)??0;A.set(t.src,i+1);let c=f?2:1,l=Math.min(Zjt(n,c)/2,8+i*6),u=x2+i*8,[d,p]=j2(n,e,c,-l),[g,_]=j2(n,e,c,l),v=Math.hypot(u,l)||1,y=f?l/v:u/v,b=f?u/v:l/v,x=M2(a),S=M2(o),C=(e,t,n,r)=>f?`${K(e+n*l*+!!r)},${K(t+r)}`:`${K(e+r)},${K(t+n*l*+!!r)}`,w=f?d-y*x:d+y*x,T=f?p+b*x:p-b*x,E=g+y*S,D=_+b*S;s={d:`M${K(w)},${K(T)}C${C(d,p,-1,u)} ${C(g,_,1,u)} ${K(E)},${K(D)}`,sx:d,sy:p,sdx:f?y:-y,sdy:f?-b:b,ex:g,ey:_,edx:-y,edy:-b},f?(t.labelX=e.x,t.labelY=Math.max(p,_)+u*.75+6+r.height/2):(t.labelX=Math.max(d,g)+u*.75+8+r.width/2,t.labelY=e.y)}else{if(t.route.length<6)continue;s=oJ(t.route,void 0,M2(a),M2(o))}let c=i?.stroke?pq(i.stroke):`var(--_l)`,l=n.internal?`2 3`:n.pattern===`dotted`?`5 4`:n.animate?`9 5`:``;if(O+=`<g class="pele-edge pele-${n.relationshipType}${hJ(n.classes.replace(/^default relationship relationship-\S+\s?/,``))}" data-id="${mq(n.id)}"${i?.line??``}><path d="${s.d}"${l?` stroke-dasharray="${l}"`:``}/>`+eMt(a,s.sx,s.sy,s.sdx,s.sdy,c)+eMt(o,s.ex,s.ey,s.edx,s.edy,c)+`</g>`,r.width>0){let e=t.labelX,a=t.labelY,o=n.relationshipType===`include`||n.relationshipType===`extend`;k+=lJ(n.id,r,e,a,(o?` fill="var(--_m)"`:``)+(i?.text??``),u)}}return{svg:vJ(`usecase`,C,w,a,n,e,gq(b,C/2,l+b.height/2,` class="pele-title" font-weight="var(--_tw)"`)+(E?`<g class="pele-clusters">${E}</g>`:``)+(O?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${O}</g>`:``)+(k?`<g class="pele-edge-labels" font-size="${o}">${k}</g>`:``)+`<g class="pele-nodes">${D}</g>`),width:C,height:w,links:[]}}function iMt(e,t,n){let r=n.get(Math.round(e.y-e.h/2));if(t===0||r===void 0)return e.x;let i=e.x-e.w/2+6,a=e.x+e.w/2-6,o=r.filter(e=>e>i&&e<a).sort((e,t)=>e-t);o.push(a);let s=t/2+6,c=e.x,l=1/0,u=0,d=i;for(let t of o){if(t-d>=2*s){let n=Math.min(Math.max(e.x,d+s),t-s);Math.abs(n-e.x)<l&&(l=Math.abs(n-e.x),c=n)}else l===1/0&&t-d>u&&(u=t-d,c=(d+t)/2);d=t}return c}function aMt(e,t,n,r,i){if(e.lines.length<2)return gq(e,t+e.width/2,n,r,i);let a=``;for(let o=0;o<e.lines.length;o++){let s={...e,lines:[e.lines[o]],widths:[e.widths[o]],height:e.lineHeight};a+=gq(s,t+e.widths[o]/2,n-e.height/2+(o+.5)*e.lineHeight,r,i)}return a}var oMt={type:`usecase`,parse:(e,t,n)=>Rjt(e,n),render:nMt};function N2(e){let t=e.trim();return t.length>=2&&t.startsWith(`"`)&&t.endsWith(`"`)?t.slice(1,-1):t}function P2(e){return e.map(N2).sort()}var sMt=class{type=`venn`;title;subsets=[];textNodes=[];styles=[];known=/* @__PURE__ */ new Set;current;indent=!1;setDiagramTitle(e){this.title=e}addSubsetData(e,t,n){let r=P2(e);this.current=r,r.length===1&&this.known.add(r[0]),this.subsets.push({sets:r,size:n??10/e.length**2,label:t?N2(t):void 0})}addTextData(e,t,n){this.textNodes.push({sets:P2(e),id:N2(t),label:n?N2(n):void 0})}addStyleData(e,t){let n=/* @__PURE__ */ new Map;for(let[e,r]of t)n.set(e,r&&N2(r));this.styles.push({targets:P2(e),styles:n})}validateUnionIdentifiers(e){let t=e.map(N2).filter(e=>!this.known.has(e));if(t.length>0)throw new NK(`unknown set identifier: ${t.join(`, `)}`,`semantic`,{type:`venn`})}getCurrentSets(){return this.current}getIndentMode(){return this.indent}setIndentMode(e){this.indent=e}},cMt=[`$end`,`INVALID`,`EOF`,`NEWLINE`,`VENN`,`TITLE`,`SET`,`UNION`,`TEXT`,`INDENT_TEXT`,`STYLE`,`BRACKET_LABEL`,`NUMERIC`,`HEXCOLOR`,`RGBCOLOR`,`RGBACOLOR`,`IDENTIFIER`,`STRING`,`COMMA`,`COLON`],lMt=[[`venn-beta`,4],[`set`,6],[`union`,7],[`text`,8],[`style`,10]],uMt=class{constructor(e,t){this.src=e,this.host=t}src;host;text=``;start=0;at=0;lineStart=!1;ended=!1;word(e,t){let n=this.src;for(let r=0;r<t.length;r++){let i=n.charCodeAt(e+r),a=t.charCodeAt(r);if(i!==a&&(i+32!==a||i<65||i>90))return!1}return!0}keyword(e,t){return this.word(e,t)&&!aq(this.src.charCodeAt(e+t.length))}color(e,t){let n=this.src,r=e+1;for(let e=0;e<t;e++){for(;eq(n.charCodeAt(r));)r++;let i=r;for(;rq(n.charCodeAt(r))||n.charCodeAt(r)===46;)r++;if(r===i)return-1;for(;eq(n.charCodeAt(r));)r++;if(n.charCodeAt(r)!==(e===t-1?41:44))return-1;r++}return r}lineEnd(e){let t=this.src.indexOf(`
|
|
1072
|
-
`,e);return t===-1?this.src.length:t}next(){let e=this.src,t=e.length;for(;;){let n=this.at;if(this.start=n,this.text=``,n>=t)return this.ended?0:(this.ended=!0,2);let r=e.charCodeAt(n);if(r===37&&e.charCodeAt(n+1)===37&&e.charCodeAt(n+2)!==123||r!==125&&e.charCodeAt(n+1)===37&&e.charCodeAt(n+2)===37)this.at=this.lineEnd(n+2);else{if(this.lineStart){if(r===32||r===9){let t=n+1;for(;e.charCodeAt(t)===32||e.charCodeAt(t)===9;)t++;if(this.at=t,this.keyword(t,`text`)&&this.host.getIndentMode())return this.at=t+4,this.lineStart=!1,this.text=e.slice(n,t),9;continue}r!==10&&r!==13&&(this.host.setIndentMode(!1),this.lineStart=!1)}if(r===10||r===13){for(n++;e.charCodeAt(n)===10||e.charCodeAt(n)===13;)n++;return this.lineStart=!0,this.token(3,n)}if(r===37&&e.charCodeAt(n+1)===37)this.at=this.lineEnd(n);else if(r===32||r===9){for(n++;e.charCodeAt(n)===32||e.charCodeAt(n)===9;)n++;this.at=n}else{if((r|32)>=97&&(r|32)<=122||r===95){if(this.word(n,`title`)&&eq(e.charCodeAt(n+5))){let r=n+6;for(;r<t;){let t=e.charCodeAt(r);if(t===35||t===10||t===59)break;r++}if(r>n+6)return this.token(5,r)}for(let[e,t]of lMt)if(this.keyword(n,e))return this.token(t,n+e.length);if(this.word(n,`rgb`)){let t=(e.charCodeAt(n+3)|32)==97,r=n+(t?4:3),i=e.charCodeAt(r)===40?this.color(r,t?4:3):-1;if(i!==-1)return this.token(t?15:14,i)}for(n++;aq(e.charCodeAt(n))||e.charCodeAt(n)===45;)n++;return this.token(16,n)}if(r===91){if(e.charCodeAt(n+1)===34){let t=e.indexOf(`"`,n+2);return t===-1||e.charCodeAt(t+1)!==93?1:(this.at=t+2,this.text=e.slice(n+2,t),11)}let r=n+1;for(;r<t&&e.charCodeAt(r)!==93&&e.charCodeAt(r)!==34;)r++;return r===n+1||e.charCodeAt(r)!==93?1:(this.at=r+1,this.text=e.slice(n+1,r).trim(),11)}if(rq(r)||r===46||r===43||r===45){(r===43||r===45)&&n++;let t=n;for(;rq(e.charCodeAt(n));)n++;if(n>t){if(e.charCodeAt(n)===46&&rq(e.charCodeAt(n+1)))for(n+=2;rq(e.charCodeAt(n));)n++}else if(e.charCodeAt(n)===46&&rq(e.charCodeAt(n+1)))for(n+=2;rq(e.charCodeAt(n));)n++;else return 1;return this.token(12,n)}if(r===35){let t=n+1;for(;t<n+9&&Hft(e.charCodeAt(t));)t++;return t>=n+4?this.token(13,t):1}if(r===34){let t=e.indexOf(`"`,n+1);return t===-1?1:this.token(17,t+1)}return r===44?this.token(18,n+1):r===58?this.token(19,n+1):1}}}}token(e,t){return this.text=this.src.slice(this.at,t),this.at=t,e}},dMt=`'EOF', 'NEWLINE', 'TITLE', 'SET', 'UNION', 'TEXT', 'INDENT_TEXT', 'STYLE'`,fMt=`'NUMERIC', 'IDENTIFIER', 'STRING', 'HEXCOLOR', 'RGBCOLOR', 'RGBACOLOR'`;function pMt(e,t){let n=new uMt(e,t),r=-1,i=()=>r===-1?r=n.next():r,a=t=>{throw i()===1?FK(`venn`,e,n.start,``,!0):FK(`venn`,e,n.start,`Expecting ${t}, got '${cMt[r]}'`)},o=()=>(r=-1,n.text),s=e=>(i()!==e&&a(`'${cMt[e]}'`),o()),c=()=>(i()!==16&&r!==17&&a(`'IDENTIFIER', 'STRING'`),o()),l=()=>{let e=[c()];for(;i()===18;)o(),e.push(c());return e},u=(e,n)=>{let r=i()===11?o():void 0,a;if(i()===19&&(o(),a=parseFloat(s(12))),n){if(e.length<2)throw new NK(`union requires multiple identifiers`,`semantic`,{type:`venn`});t.validateUnionIdentifiers(e)}t.addSubsetData(e,r,a),t.setIndentMode(!0)},d=e=>{let n=i();n!==16&&n!==17&&n!==12&&a(`'NUMERIC', 'IDENTIFIER', 'STRING'`);let r=o(),s=n!==12&&i()===11?o():void 0;t.addTextData(e(),r,s)},f=()=>{let e=l(),n=[];for(;;){let e=s(16);s(19);let t;if(i()===17)t=o();else{let e=[];for(;i()===16||r>=12&&r<=15;)e.push(o());e.length===0&&a(fMt),t=e.join(` `)}if(n.push([e,t]),i()!==18)break;o()}t.addStyleData(e,n)};for(;i()===3;)o();for(s(4);;){let e=i();if(e===2)return;if((e<3||e>10||e===4)&&a(dMt),o(),e===5)t.setDiagramTitle(n.text.slice(6));else if(e===6)u([c()],!1);else if(e===7)u(l(),!0);else if(e===8){let e=l();d(()=>e)}else e===9?d(()=>{let e=t.getCurrentSets();if(!e)throw new NK(`text requires set`,`semantic`,{type:`venn`});return e}):e===10&&f()}}var F2=Math.PI*2;function mMt(e){let t=/* @__PURE__ */ new Set,n=/* @__PURE__ */ new Map;for(let r of e)t.add(JSON.stringify([...r.sets].sort())),r.sets.length===1&&n.set(r.sets[0],r.size);let r=[];for(let i of e){if(i.sets.length<3)continue;let e=[...i.sets].sort();for(let i=0;i<e.length-1;i++)for(let a=i+1;a<e.length;a++){let o=[e[i],e[a]],s=JSON.stringify(o);if(t.has(s))continue;t.add(s);let c=n.get(o[0]),l=n.get(o[1]);r.push({sets:o,size:c!==void 0&&l!==void 0?Math.min(c,l)/4:2.5,label:``})}}return r.length>0?[...e,...r]:e}function hMt(e,t,n){if(n>=e+t)return 0;let r=Math.min(e,t);if(n<=Math.abs(e-t))return Math.PI*r*r;let i=e*e*Math.acos((n*n+e*e-t*t)/(2*n*e)),a=t*t*Math.acos((n*n+t*t-e*e)/(2*n*t)),o=.5*Math.sqrt(Math.max((-n+e+t)*(n+e-t)*(n-e+t)*(n+e+t),0));return i+a-o}function gMt(e,t,n){let r=Math.abs(e-t),i=e+t;if(!(n>0))return i;if(n>=Math.PI*Math.min(e,t)**2)return r;for(let a=0;a<48;a++){let a=(r+i)/2;hMt(e,t,a)>n?r=a:i=a}return(r+i)/2}function _Mt(e,t,n,r,i,a){let o=1/0;for(let n of t){let t=e[n],s=r-t.x,c=i-t.y,l=t.r-Math.sqrt(s*s+c*c);if(l<o){if(l<a)return l;o=l}}for(let t of n){let n=e[t],s=r-n.x,c=i-n.y,l=Math.sqrt(s*s+c*c)-n.r;if(l<o){if(l<a)return l;o=l}}return o}function I2(e,t,n){let r=0,i=0,a=e[t[0]];for(let n of t){let o=e[n];r+=o.x/t.length,i+=o.y/t.length,o.r<a.r&&(a=o)}let o=a.r,s=r,c=i,l=_Mt(e,t,n,s,c,-1/0),u=0,d=(a,d)=>{let f=_Mt(e,t,n,a,d,l-o*1e-9);if(!(f>l-o*1e-9))return!1;let p=Math.hypot(a-r,d-i);return f>l+o*1e-9||p<u-o*1e-9?(l=f,u=p,s=a,c=d,!0):!1};for(let e=-10;e<=10;e++)for(let t=-10;t<=10;t++)t*t+e*e<=100&&d(a.x+t*o/10,a.y+e*o/10);let f=o/10;for(let e=0;e<40&&f>o*1e-6;e++){let e=!1;for(let t=0;t<8;t++){let n=t*F2/8;d(s+Math.cos(n)*f,c+Math.sin(n)*f)&&(e=!0)}e||(f/=2)}return{x:s,y:c,margin:l}}function vMt(e){let t=/* @__PURE__ */ new Map;for(let n of e)for(let e of n.sets)t.has(e)||t.set(e,10);for(let n of e)n.sets.length===1&&t.set(n.sets[0],n.size);let n=/* @__PURE__ */ new Map,r=[],i=0;for(let e of t.values())Number.isFinite(e)&&e>i&&(i=e);i===0&&(i=10);let a=Math.sqrt(i/Math.PI);for(let[e,i]of t){n.set(e,r.length);let t=Number.isFinite(i)&&i>0?Math.sqrt(i/Math.PI):0;r.push({id:e,x:0,y:0,r:Math.max(t,a*.3)})}let o=r.length;if(o<2)return r;let s=/* @__PURE__ */ new Map;for(let t of mMt(e)){if(t.sets.length!==2)continue;let e=n.get(t.sets[0]),r=n.get(t.sets[1]);e!==r&&s.set(Math.min(e,r)*o+Math.max(e,r),t.size)}let c=/* @__PURE__ */ new Map;for(let[e,t]of s)c.set(e,gMt(r[Math.floor(e/o)].r,r[e%o].r,t));let l=a*.15,u=(e,t)=>c.get(e*o+t)??r[e].r+r[t].r+l;if(o===2)return r[1].x=u(0,1),r;if(o===3){let t=u(0,1),n=u(0,2),i=u(1,2),o=e.some(e=>new Set(e.sets).size===3);for(let e=0;e<40;e++){let e=t>0?(t*t+n*n-i*i)/(2*t):0;if(r[1].x=t,r[2].x=Math.max(-n,Math.min(n,e)),r[2].y=Math.sqrt(Math.max(n*n-e*e,0)),!o||I2(r,[0,1,2],[]).margin>a*.12)break;t*=.94,n*=.94,i*=.94}return r}let d=0;for(let e of r)d+=2*e.r+l;let f=Math.min(300,Math.floor(3e6/(o*o)));if(o<=64){let e=d/F2;r.forEach((t,n)=>{let r=n*F2/o-Math.PI/2;t.x=Math.cos(r)*e,t.y=Math.sin(r)*e})}else{let e=Math.ceil(Math.sqrt(o)),t=2*a+l;r.forEach((n,r)=>{n.x=r%e*t,n.y=Math.floor(r/e)*t})}let p=new Float64Array(o),m=new Float64Array(o),h=new Int32Array(o);for(let e=0;e<f;e++){p.fill(0),m.fill(0),h.fill(0);for(let e=0;e<o;e++)for(let t=e+1;t<o;t++){let n=c.get(e*o+t),i=r[e].r+r[t].r+l,a=r[t].x-r[e].x,s=r[t].y-r[e].y,u=Math.hypot(a,s);if(n===void 0&&u>=i)continue;u<1e-9&&(a=Math.cos(e+t),s=Math.sin(e+t),u=1);let d=(u-(n??i))/2/u;p[e]+=a*d,m[e]+=s*d,p[t]-=a*d,m[t]-=s*d,h[e]++,h[t]++}for(let e=0;e<o;e++)h[e]!==0&&(r[e].x+=p[e]/h[e],r[e].y+=m[e]/h[e])}return r}function yMt(e,t){let n=e=>`M${t(e.x-e.r)},${t(e.y)}A${t(e.r)},${t(e.r)} 0 1 1 ${t(e.x+e.r)},${t(e.y)}A${t(e.r)},${t(e.r)} 0 1 1 ${t(e.x-e.r)},${t(e.y)}Z`;if(e.length===1)return n(e[0]);let r=(t,n,r,i)=>{for(let a of e)if(a!==r&&a!==i&&Math.hypot(t-a.x,n-a.y)>a.r*(1+1e-9))return!1;return!0},i=[];for(let t=0;t<e.length;t++)for(let n=t+1;n<e.length;n++){let a=e[t],o=e[n],s=Math.hypot(o.x-a.x,o.y-a.y);if(s>=a.r+o.r||s<=Math.abs(a.r-o.r)||s===0)continue;let c=(a.r*a.r-o.r*o.r+s*s)/(2*s),l=Math.sqrt(Math.max(a.r*a.r-c*c,0)),u=a.x+(o.x-a.x)*c/s,d=a.y+(o.y-a.y)*c/s;for(let e of[1,-1]){let t=u+e*l*(o.y-a.y)/s,n=d-e*l*(o.x-a.x)/s;r(t,n,a,o)&&i.push({x:t,y:n,a,b:o})}}if(i.length<2){let t=e[0];for(let n of e)n.r<t.r&&(t=n);for(let n of e)if(n!==t&&Math.hypot(n.x-t.x,n.y-t.y)+t.r>n.r*(1+1e-9))return``;return n(t)}let a=0,o=0;for(let e of i)a+=e.x/i.length,o+=e.y/i.length;i.sort((e,t)=>Math.atan2(e.y-o,e.x-a)-Math.atan2(t.y-o,t.x-a));let s=``;for(let e=0;e<i.length;e++){let n=i[e],r=i[(e+1)%i.length];e===0&&(s=`M${t(n.x)},${t(n.y)}`);let a,o=0,c=1/0;for(let e of[n.a,n.b]){if(e!==r.a&&e!==r.b)continue;let t=Math.atan2(n.y-e.y,n.x-e.x),i=Math.atan2(r.y-e.y,r.x-e.x)-t;i<=0&&(i+=F2);let s=e.x+e.r*Math.cos(t+i/2),l=e.y+e.r*Math.sin(t+i/2),u=Math.hypot(s-(n.x+r.x)/2,l-(n.y+r.y)/2);u<c&&(c=u,a=e,o=+(i>Math.PI))}s+=a===void 0?`L${t(r.x)},${t(r.y)}`:`A${t(a.r)},${t(a.r)} 0 ${o} 1 ${t(r.x)},${t(r.y)}`}return s+`Z`}var bMt=100,xMt=1.6,SMt=mJ([]);function L2(e){return e.length===1?e[0]:JSON.stringify(e)}function CMt(e,t,n){let r=n.fontSize??16,i=Math.round(r*.875),a=Math.round(r*.8125),o=n.measurer??fq(n.fontFamily),s=n.padding??8,c=vMt(e.subsets),l=/* @__PURE__ */ new Map;c.forEach((e,t)=>l.set(e.id,t));let u=/* @__PURE__ */ new Map;for(let{targets:t,styles:n}of e.styles){let e=L2(t),r=u.get(e);r||u.set(e,r=/* @__PURE__ */ new Map);for(let[e,t]of n)r.set(e,t)}let d=e=>{let t=u.get(e);if(!t)return SMt;let n=[];for(let[e,r]of t)n.push(`${e}:${r}`);return mJ(n)},f=c.map(()=>[]);for(let e=0;e<c.length;e++)for(let t=e+1;t<c.length;t++)Math.hypot(c[e].x-c[t].x,c[e].y-c[t].y)<c[e].r+c[t].r&&(f[e].push(t),f[t].push(e));let p=/* @__PURE__ */ new Map;for(let t of e.subsets)p.set(L2(t.sets),t);let m=/* @__PURE__ */ new Map;for(let[e,t]of p){let n=[...new Set(t.sets)],a=n.map(e=>l.get(e)),s=new Set(a),u=a[0];for(let e of a)c[e].r<c[u].r&&(u=e);let p=d(e),h=t.label??(t.sets.length===1?t.sets[0]:void 0),g=+!!p.bold|(p.italic?2:0),_=I2(c,a,f[u].filter(e=>!s.has(e)));_.margin<c[u].r*.2&&(_=I2(c,a,[]));let v={sets:n,inside:a,spot:_,lines:[],style:p};if(h){let e=n.length===1?r:i;v.lines.push({id:void 0,raw:h,size:e,base:g,label:WJ(h,!1,o,e,4e3,g)})}m.set(e,v)}for(let t of e.textNodes){let e=t.label??t.id;m.get(L2(t.sets))?.lines.push({id:t.id,raw:e,size:a,base:0,label:WJ(e,!1,o,a,4e3)})}let h=0;for(let e of c)e.r>h&&(h=e.r);let g=h>0?bMt/h:1,_=1;for(let e of m.values()){if(e.spot.margin<=0)continue;let t=0,n=0;for(let r of e.lines)t=Math.max(t,r.label.width),n+=r.label.height;let r=Math.hypot(t,n)/2+4;_=Math.max(_,Math.min(r/(e.spot.margin*g),xMt))}g*=_;for(let e of m.values()){let t=Math.max(e.spot.margin*g*1.8,72);for(let n of e.lines)n.label.width>t&&(n.label=WJ(n.raw,!1,o,n.size,t,n.base))}let v=1/0,y=1/0,b=-1/0,x=-1/0;for(let e of c)v=Math.min(v,(e.x-e.r)*g),y=Math.min(y,(e.y-e.r)*g),b=Math.max(b,(e.x+e.r)*g),x=Math.max(x,(e.y+e.r)*g);for(let e of m.values()){let t=0,n=0;for(let r of e.lines)t=Math.max(t,r.label.width),n+=r.label.height;v=Math.min(v,e.spot.x*g-t/2),b=Math.max(b,e.spot.x*g+t/2),y=Math.min(y,e.spot.y*g-n/2),x=Math.max(x,e.spot.y*g+n/2)}c.length===0&&(v=y=b=x=0);let S=WJ(e.title&&N2(e.title),!1,o,r,4e3,1),C=S.height>0?S.height+12:0,w=Math.max(b-v,S.width),T=s+(w-(b-v))/2-v,E=s+C-y,D=Math.ceil(w+2*s),O=Math.ceil(x-y+C+2*s),k=c.map(e=>({id:e.id,x:e.x*g+T,y:e.y*g+E,r:e.r*g})),A=``;k.forEach((e,t)=>{let n=gJ(t),r=m.get(e.id)?.style??SMt;A+=`<circle class="pele-venn-set" data-id="${mq(e.id)}" cx="${K(e.x)}" cy="${K(e.y)}" r="${K(e.r)}" fill="${n}" fill-opacity="0.2" stroke="${n}"${r.shape}/>`});let j=``,M=``;for(let e of m.values()){let t=mq(e.sets.join(`|`));if(e.sets.length>1&&e.style.shape!==``){let n=yMt(e.inside.map(e=>k[e]),K);n!==``&&(j+=`<path class="pele-venn-overlap" data-id="${t}" d="${n}" fill="none"${e.style.shape}/>`)}let n=0;for(let t of e.lines)n+=t.label.height;if(n===0)continue;let i=e.spot.x*g+T,o=e.spot.y*g+E-n/2,s=``;for(let t of e.lines){let n=t.id===void 0?` class="pele-label"${t.size===r?``:` font-size="${t.size}"`}${e.style.text}`:` class="pele-venn-text" data-id="${mq(t.id)}" font-size="${a}" fill="var(--_m)"${d(t.id).text}`;s+=gq(t.label,i,o+t.label.height/2,n),o+=t.label.height}M+=`<g class="pele-venn-region" data-id="${t}">${s}</g>`}return{svg:vJ(`venn`,D,O,r,n,{},gq(S,D/2,s+S.height/2,` class="pele-title" font-weight="var(--_tw)"`)+`<g class="pele-venn-sets">${A}</g>`+(j?`<g class="pele-venn-overlaps">${j}</g>`:``)+(M?`<g class="pele-venn-labels">${M}</g>`:``)),width:D,height:O,links:[]}}var wMt={type:`venn`,parse(e,t,n){let r=new sMt;return n&&(r.title=n),pMt(e,r),r},render:CMt},TMt=class{nodes=/* @__PURE__ */ new Map;labels;links=[];trends=/* @__PURE__ */ new Map;pipelines=/* @__PURE__ */ new Map;annotations=[];notes=[];accelerators=[];deaccelerators=[];annotationsBox;axes={};size;addNode(e){let t=this.nodes.get(e.id)??{id:e.id,label:e.label};this.nodes.set(e.id,{...t,...e,className:e.className??t.className,labelOffsetX:e.labelOffsetX??t.labelOffsetX,labelOffsetY:e.labelOffsetY??t.labelOffsetY}),this.labels=void 0}addLink(e){this.links.push(e)}addTrend(e){this.trends.set(e.nodeId,e)}startPipeline(e){this.pipelines.set(e,{nodeId:e,componentIds:[]});let t=this.nodes.get(e);t&&(t.isPipelineParent=!0)}addPipelineComponent(e,t){this.pipelines.get(e)?.componentIds.push(t);let n=this.nodes.get(t);n&&(n.inPipeline=!0)}addAnnotation(e){this.annotations.push(e)}addNote(e){this.notes.push(e)}addAccelerator(e){this.accelerators.push(e)}addDeaccelerator(e){this.deaccelerators.push(e)}setAnnotationsBox(e,t){this.annotationsBox={x:e,y:t}}setAxes(e){this.axes={...this.axes,...e}}setSize(e,t){this.size={width:e,height:t}}getNode(e){return this.nodes.get(e)}resolveNodeId(e){if(this.nodes.has(e))return e;if(!this.labels){this.labels=/* @__PURE__ */ new Map;for(let[e,t]of this.nodes)this.labels.has(t.label)||this.labels.set(t.label,e)}return this.labels.get(e)??e}build(){let e=[];for(let t of this.nodes.values()){if(typeof t.x!=`number`||typeof t.y!=`number`)throw new NK(`Node "${t.label}" is missing coordinates`,`semantic`,{type:`wardley`});e.push(t)}return{nodes:e,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 R2(e,t){let n=e<=1?e*100:e;if(n<0||n>100)throw new NK(`${t} must be between 0-1 (decimal) or 0-100 (percentage). Received: ${e}`,`semantic`,{type:`wardley`});return n}function z2(e,t,n){return{x:R2(t,`${n} evolution`),y:R2(e,`${n} visibility`)}}function EMt(e){return e===`+<>`?`bidirectional`:e===`+<`?`backward`:e===`+>`?`forward`:void 0}function DMt(e){if(!e?.startsWith(`+`))return{};let t=e.indexOf(`'`,2),n=e[1]===`'`&&t!==-1?e.slice(2,t):void 0;return e.includes(`<>`)?{flow:`bidirectional`,label:n}:e.includes(`<`)?{flow:`backward`,label:n}:e.includes(`>`)?{flow:`forward`,label:n}:{label:n}}function OMt(e){return e?[(e.negX?-1:1)*e.offsetX,(e.negY?-1:1)*e.offsetY]:[void 0,void 0]}function kMt(e,t){e.size&&t.setSize(e.size.width,e.size.height),e.evolution&&t.setAxes({stages:e.evolution.stages.map(e=>e.secondName?`${e.name.trim()} / ${e.secondName.trim()}`:e.name.trim()),stageBoundaries:e.evolution.stages.filter(e=>e.boundary!==void 0).map(e=>e.boundary)});for(let n of e.anchors){let e=z2(n.visibility,n.evolution,`Anchor "${n.name}"`);t.addNode({id:n.name,label:n.name,x:e.x,y:e.y,className:`anchor`})}for(let n of e.components){let e=z2(n.visibility,n.evolution,`Component "${n.name}"`),[r,i]=OMt(n.label);t.addNode({id:n.name,label:n.name,x:e.x,y:e.y,className:`component`,labelOffsetX:r,labelOffsetY:i,inertia:n.inertia,sourceStrategy:n.decorator?.strategy})}for(let n of e.notes){let e=z2(n.visibility,n.evolution,`Note "${n.text}"`);t.addNote({text:n.text,x:e.x,y:e.y})}for(let n of e.pipelines){let e=t.getNode(n.parent);if(!e||typeof e.y!=`number`)throw new NK(`Pipeline "${n.parent}" must reference an existing component with coordinates.`,`semantic`,{type:`wardley`});let r=e.y;t.startPipeline(n.parent);for(let e of n.components){let i=`${n.parent}_${e.name}`,[a,o]=OMt(e.label),s=R2(e.evolution,`Pipeline component "${e.name}" evolution`);t.addNode({id:i,label:e.name,x:s,y:r,className:`pipeline-component`,labelOffsetX:a,labelOffsetY:o,inertia:void 0,sourceStrategy:void 0}),t.addPipelineComponent(n.parent,i)}}for(let n of e.links){let e=!!n.arrow&&(n.arrow.includes(`-.->`)||n.arrow.includes(`.-.`)),r=DMt(n.arrow),i=EMt(n.fromPort)??EMt(n.toPort)??r.flow;t.addLink({source:t.resolveNodeId(n.from),target:t.resolveNodeId(n.to),dashed:e,label:r.label??n.linkLabel,flow:i})}for(let n of e.evolves){let e=t.getNode(n.component);e?.y!==void 0&&t.addTrend({nodeId:n.component,targetX:R2(n.target,`Evolve target for "${n.component}"`),targetY:e.y})}if(e.annotations.length>0){let n=z2(e.annotations[0].x,e.annotations[0].y,`Annotations box`);t.setAnnotationsBox(n.x,n.y)}for(let n of e.annotation){let e=z2(n.x,n.y,`Annotation ${n.number}`);t.addAnnotation({number:n.number,coordinates:[{x:e.x,y:e.y}],text:n.text})}for(let n of e.accelerators){let e=z2(n.x,n.y,`Accelerator "${n.name}"`);t.addAccelerator({name:n.name,x:e.x,y:e.y})}for(let n of e.deaccelerators){let e=z2(n.x,n.y,`Deaccelerator "${n.name}"`);t.addDeaccelerator({name:n.name,x:e.x,y:e.y})}}function AMt(e,t){let n=new TMt;return kMt(e,n),{type:`wardley`,title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,``):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
|
|
1073
|
-
`):void 0,...n.build()}}function jMt(e,t){let n=t;for(let t=e.charCodeAt(n);t>=48&&t<=57;t=e.charCodeAt(n))n++;return n}function MMt(){let e=0,t=0;return(n,r)=>{if((r<e||r>=t)&&(e=r,t=jMt(n,r)),t===r||n.charCodeAt(t)!==46)return-1;let i=jMt(n,t+1);return i>t+1?i:-1}}var NMt={name:`ARROW`,pattern:/->/y,first:`-`},PMt={name:`LINK_ARROW`,pattern:/-->|-\.->|>|\+'[^']*'<>|\+'[^']*'<|\+'[^']*'>/y,first:`->+`},B2=(e,t)=>({name:e,pattern:new RegExp(t,`y`),first:t[0]}),FMt=[{name:`[`,pattern:`[`},{name:`,`,pattern:`,`},{name:`]`,pattern:`]`},{name:`@`,pattern:`@`},{name:`/`,pattern:`/`},{name:`(`,pattern:`(`},{name:`)`,pattern:`)`},{name:`-`,pattern:`-`,longer:[NMt,PMt,fY]},{name:`{`,pattern:`{`},{name:`}`,pattern:`}`},{name:`WARDLEY_NUMBER`,pattern:/[0-9]+\.[0-9]+/y,first:`0123456789`,scanner:MMt},NMt,{name:`LINK_PORT`,pattern:/\+<>|\+>|\+</y,first:`+`},PMt,{name:`LINK_LABEL`,pattern:/;[^\n\r]+/y,first:`;`},{name:`STRATEGY`,pattern:/build|buy|outsource|market/y,first:`bom`},B2(`KW_WARDLEY`,`wardley-beta`),B2(`KW_SIZE`,`size`),B2(`KW_EVOLUTION`,`evolution`),B2(`KW_ANCHOR`,`anchor`),B2(`KW_COMPONENT`,`component`),B2(`KW_LABEL`,`label`),B2(`KW_INERTIA`,`inertia`),B2(`KW_EVOLVE`,`evolve`),B2(`KW_PIPELINE`,`pipeline`),B2(`KW_NOTE`,`note`),B2(`KW_ANNOTATIONS`,`annotations`),B2(`KW_ANNOTATION`,`annotation`),B2(`KW_ACCELERATOR`,`accelerator`),B2(`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:` `},gZ(),sY,cY,{name:`INT`,pattern:/0|[1-9][0-9]*(?!\.)/y,first:`0123456789`},lY,{name:`ID`,pattern:/[\w]([-\w]*\w)?/y,first:`_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`},uY,dY,fY,pY,mY];function IMt(e){let t=new xY(aY(e,FMt,`wardley`),FMt,`wardley`),n={$type:`Wardley`,anchors:[],components:[],links:[],evolves:[],pipelines:[],notes:[],annotations:[],annotation:[],accelerators:[],deaccelerators:[]},r=e=>t.kinds[t.i]===e,i=()=>r(36)||r(37)||r(30),a=()=>r(36)?bY(t.take()):r(37)||r(30)?t.take():t.fail(`a name`),o=()=>Number(t.expect(10)),s=()=>parseInt(t.expect(35)),c=()=>r(10)?Number(t.take()):parseInt(t.expect(35)),l=()=>{if(!r(-1))for(r(38)||t.fail(`a line break or the end of input`);r(38);)t.i++},u=e=>{t.expect(0);let n=e();t.expect(1);let r=e();return t.expect(2),[n,r]},d=()=>{t.expect(21),t.expect(0);let e=t.accept(7),n=s();t.expect(1);let r=t.accept(7),i=s();return t.expect(2),{$type:`Label`,negX:e,offsetX:n,negY:r,offsetY:i}},f=()=>{let e={$type:`EvolutionStage`,name:a()};return t.accept(3)&&(e.boundary=o()),t.accept(4)&&(e.secondName=a()),e};for(;r(38);)t.i++;for(t.expect(16);!r(-1);)switch(t.kind){case 38:t.i++;break;case 32:n.accDescr=yY(t.take()),l();break;case 33:n.accTitle=vY(t.take()),l();break;case 34:n.title=_Y(t.take()),l();break;case 17:{t.i++;let[e,r]=u(s);l(),n.size={$type:`Size`,width:e,height:r};break}case 18:{t.i++;let e=[f()];for(t.expect(11),e.push(f());t.accept(11);)e.push(f());l(),n.evolution={$type:`Evolution`,stages:e};break}case 19:{t.i++;let e=a(),[r,i]=u(o);l(),n.anchors.push({$type:`Anchor`,name:e,visibility:r,evolution:i});break}case 20:{t.i++;let e={$type:`Component`,name:a(),visibility:0,evolution:0,inertia:!1};[e.visibility,e.evolution]=u(o),r(21)&&(e.label=d()),r(5)&&t.kinds[t.i+1]===15&&(t.i++,e.decorator={$type:`Decorator`,strategy:t.take()},t.expect(6)),t.accept(22)?e.inertia=!0:t.accept(5)&&(t.expect(22),t.expect(6),e.inertia=!0),l(),n.components.push(e);break}case 23:{t.i++;let e=a(),r=o();l(),n.evolves.push({$type:`Evolve`,component:e,target:r});break}case 24:{t.i++;let e=a();for(t.expect(8),t.expect(38);r(38);)t.i++;let i=[];do{t.expect(20);let e={$type:`PipelineComponent`,name:a(),evolution:0};t.expect(0),e.evolution=o(),t.expect(2),r(21)&&(e.label=d()),l(),i.push(e)}while(r(20));t.expect(9),l(),n.pipelines.push({$type:`Pipeline`,parent:e,components:i});break}case 25:{t.i++;let e=bY(t.expect(36)),[r,i]=u(o);l(),n.notes.push({$type:`Note`,text:e,visibility:r,evolution:i});break}case 26:{t.i++;let[e,r]=u(c);l(),n.annotations.push({$type:`Annotations`,x:e,y:r});break}case 27:{t.i++;let e=s();t.expect(1);let[r,i]=u(c),a=bY(t.expect(36));l(),n.annotation.push({$type:`Annotation`,number:e,x:r,y:i,text:a});break}case 28:case 29:{let e=t.kind===29;t.i++;let r=a(),[i,s]=u(o);l(),e?n.deaccelerators.push({$type:`Deaccelerator`,name:r,x:i,y:s}):n.accelerators.push({$type:`Accelerator`,name:r,x:i,y:s});break}default:{i()||t.fail(`a statement`);let e={$type:`Link`,from:a(),to:``};r(12)&&(e.fromPort=t.take()),(r(13)||r(11))&&(e.arrow=t.take()),e.to=a(),r(12)&&(e.toPort=t.take()),r(14)&&(e.linkLabel=t.take().substring(1).trim()),l(),n.links.push(e)}}return n}var LMt=[`Genesis`,`Custom Built`,`Product`,`Commodity`],RMt=48,V2=6,H2=10,zMt=8,U2=15,W2=60,BMt=30,VMt=20,G2=`var(--_c)`,K2=`var(--_l)`;function HMt(e,t,n,r,i){let a=e[`wardley-beta`]?.[t];return typeof a==`number`&&a>=r&&a<=i?a:n}function q2(e,t,n){return e<t?t:e>n?n:e}function UMt(e,t,n,r){let i=vq(e),a=``,o=n;for(let n of e.lines){let r=!0;for(let e of n){if(e.icon!==void 0)continue;let n=_q(e.style&~i);a+=`<tspan${r?` x="${K(t)}" y="${K(o)}"`:``}${n}>${pq(e.text)}</tspan>`,r=!1}o+=e.lineHeight}return a===``?``:`<text${yq(r,i)} xml:space="preserve">${a}</text>`}function WMt(e,t,n,r){return q2(typeof t==`number`&&Number.isFinite(t)?t:HMt(e,n,r,1,1e6),200,1e4)-2*RMt}function GMt(e,t,n){let r=WMt(t,e.size?.width,`width`,900);return GJ(n,r,160,(i,a)=>KMt(e,t,n,i,r,a))}function KMt(e,t,n,r,i,a){let o=n.fontSize??16,s=Math.round(o*.8125),c=Math.round(o*.6875),l=n.measurer??fq(n.fontFamily),u=n.padding??8,d=WMt(t,e.size?.height,`height`,600)*Math.max(.75,r/i),f=t[`wardley-beta`]?.showGrid===!0,p=0,m=0,h=r,g=d,_=(e,t,n,r)=>{e<p&&(p=e),t<m&&(m=t),n>h&&(h=n),r>g&&(g=r)},v=(e,t,r,i)=>(_(t-e.width/2,r-e.height/2,t+e.width/2,r+e.height/2),gq(e,t,r,i,n.icons)),y=(e,t,n,r)=>(_(t,n-e.size,t+e.width,n-e.size+e.height+4),UMt(e,t,n,r)),b=(e,t,n=a?Math.max(64,Math.min(120,r/2)):4e3,i=0)=>WJ(e,!1,l,t,n,i),x=e=>e/100*r,S=e=>d-e/100*d,C=e.axes.stages&&e.axes.stages.length>0?e.axes.stages:LMt,w=e.axes.stageBoundaries,T=w!==void 0&&w.length===C.length,E=``,D=``,O=d,k=0;if(C.forEach((e,t)=>{let n=T?k:t/C.length,i=T?q2(w[t],0,1):(t+1)/C.length;k=i,t>0&&(E+=`<path class="pele-wardley-stage" d="M${K(n*r)},0V${K(d)}" stroke="var(--_b)" stroke-dasharray="4 4"/>`);let a=b(e,s,Math.max(48,Math.abs(i-n)*r-12));D+=v(a,(n+i)/2*r,d+8+a.height/2,` class="pele-wardley-stage-label" font-size="${s}" fill="var(--_m)"`),O=Math.max(O,d+8+a.height)}),f)for(let e=1;e<4;e++)E+=`<path class="pele-wardley-grid" d="M${K(r*e/4)},0V${K(d)}M0,${K(d*e/4)}H${K(r)}" stroke="var(--_b)" stroke-dasharray="2 6"/>`;E+=`<path class="pele-wardley-axis" d="M0,0V${K(d)}H${K(r)}" stroke="${K2}"/>`;let A=b(e.axes.xLabel??`Evolution`,s),j=b(e.axes.yLabel??`Visibility`,s),M=` class="pele-wardley-axis-label" font-size="${s}" font-weight="var(--_hw)"`,N=v(A,r/2,O+6+A.height/2,M)+gq(j,-16,d/2,`${M} transform="rotate(-90 -16 ${K(d/2)})"`);_(-16-j.height/2,0,0,0);let P=O+6+A.height+10,F=/* @__PURE__ */ new Map;for(let t of e.nodes)F.set(t.id,{x:x(t.x),y:S(t.y),node:t});let ee=``,te=/* @__PURE__ */ new Map;for(let t of e.pipelines){te.set(t.nodeId,new Set(t.componentIds));let e=[];for(let n of t.componentIds){let t=F.get(n);t&&e.push(t)}if(e.length===0)continue;e.sort((e,t)=>e.x-t.x);let n=e[0].x,r=e[e.length-1].x,i=e[0].y,a=i-2*V2,o=F.get(t.nodeId);o&&(o.x=(n+r)/2,o.y=a-H2/6),_(n-U2,a,r+U2,a+4*V2),ee+=`<g class="pele-wardley-pipeline" data-id="${mq(t.nodeId)}"><rect x="${K(n-U2)}" y="${K(a)}" width="${K(r-n+2*U2)}" height="${K(4*V2)}" rx="${fJ}" fill="var(--_s)" stroke="var(--_b)"/>`+(e.length>1?`<path d="M${K(n)},${K(i)}H${K(r)}" stroke="${K2}" stroke-dasharray="4 4"/>`:``)+`</g>`}let I=/* @__PURE__ */ new Map,ne=(e,t,n)=>{let i=e.node;if(i.className===`anchor`){let e=I.get(i);return e||I.set(i,e=b(i.label,s,a?Math.max(64,r/2):4e3,1)),1/Math.hypot(t/(e.width/2+5),n/(s*.8))}return i.isPipelineParent?H2/Math.SQRT2:i.sourceStrategy?2*V2:V2},re=/* @__PURE__ */ new Map,ie=(e,t,n)=>{Math.abs(t)<.25||Math.abs(n)<.25||re.set(e,(re.get(e)??0)|(t>0?n<0?1:2:n<0?4:8))},ae=``;for(let t of e.links){let e=F.get(t.source),n=F.get(t.target);if(!e||!n||e===n||te.get(t.target)?.has(t.source))continue;let r=n.x-e.x,i=n.y-e.y,a=Math.hypot(r,i);if(a<.01)continue;let o=r/a,s=i/a,l=ne(e,o,s),u=ne(n,o,s);if(l+u>=a)continue;ie(e,o,s),ie(n,-o,-s);let d=e.x+o*l,f=e.y+s*l,p=n.x-o*u,m=n.y-s*u,h=``;(t.flow===`forward`||t.flow===`bidirectional`)&&(h+=cJ(`arrow_point`,p,m,o,s,K2),p-=o*sJ(`arrow_point`),m-=s*sJ(`arrow_point`)),(t.flow===`backward`||t.flow===`bidirectional`)&&(h+=cJ(`arrow_point`,d,f,-o,-s,K2),d+=o*sJ(`arrow_point`),f+=s*sJ(`arrow_point`));let g=``;if(t.label){let r=b(t.label,c+1,200),i=o>=0?1:-1,a=s*i,l=-o*i,u=5+Math.abs(a)*r.width/2+Math.abs(l)*r.height/2;g=v(r,(e.x+n.x)/2+a*u,(e.y+n.y)/2+l*u,` class="pele-edge-label" font-size="${c+1}" fill="var(--_m)"`)}ae+=`<g class="pele-edge${t.dashed?` pele-wardley-dashed`:``}" data-id="${mq(t.source)}-${mq(t.target)}"><path d="M${K(d)},${K(f)}L${K(p)},${K(m)}" stroke="${K2}"${t.dashed?` stroke-dasharray="6 6"`:``}/>`+h+g+`</g>`}let L=``;for(let t of e.trends){let e=F.get(t.nodeId);if(!e)continue;let n=x(t.targetX),r=S(t.targetY),i=n-e.x,a=r-e.y,o=Math.hypot(i,a),s=``,c=o>0?ne(e,i/o,a/o):0;if(o>c+V2+4){let t=i/o,l=a/o,u=n-t*(V2+2),d=r-l*(V2+2);s=`<path d="M${K(e.x+t*c)},${K(e.y+l*c)}L${K(u-t*sJ(`arrow_point`))},${K(d-l*sJ(`arrow_point`))}" stroke="${G2}" stroke-dasharray="4 4"/>`+cJ(`arrow_point`,u,d,t,l,G2)}_(n-V2,r-V2,n+V2,r+V2),L+=`<g class="pele-wardley-trend" data-id="${mq(t.nodeId)}">${s}<circle cx="${K(n)}" cy="${K(r)}" r="${V2}" fill="var(--_bg)" stroke="${G2}"/></g>`}let oe=``,se=1.2*V2,ce=.7*V2;for(let e of F.values()){let t=e.node,{x:n,y:i}=e,o=t.className===`anchor`,c=t.sourceStrategy,l=``;if(c){let e=c===`outsource`?`var(--_m)`:c===`buy`?`var(--_a)`:c===`build`?`var(--_s)`:`var(--_bg)`;l+=`<circle class="pele-wardley-${c}" cx="${K(n)}" cy="${K(i)}" r="${2*V2}" fill="${e}" stroke="${K2}"/>`}if(c===`market`){let e=se*Math.cos(Math.PI/6),t=i+se*Math.sin(Math.PI/6);l+=`<path d="M${K(n)},${K(i-se)}L${K(n-e)},${K(t)}H${K(n+e)}Z" fill="none" stroke="${K2}"/>`;for(let[r,a]of[[n,i-se],[n-e,t],[n+e,t]])l+=`<circle cx="${K(r)}" cy="${K(a)}" r="${K(ce)}" fill="var(--_bg)" stroke="${K2}"/>`}else t.isPipelineParent?l+=`<rect x="${K(n-H2/2)}" y="${K(i-H2/2)}" width="${H2}" height="${H2}" fill="var(--_bg)" stroke="${K2}"/>`:o||(l+=`<circle cx="${K(n)}" cy="${K(i)}" r="${V2}" fill="var(--_bg)" stroke="${K2}"/>`);if(t.inertia===!0){let e=(t.isPipelineParent?H2/2:V2)+10+(c?V2+4:0);l+=`<rect class="pele-wardley-inertia" x="${K(n+e)}" y="${K(i-V2)}" width="4" height="${2*V2}" fill="${K2}"/>`}let u=t.labelOffsetX===void 0?void 0:q2(t.labelOffsetX,-5e3,5e3),d=t.labelOffsetY===void 0?void 0:q2(t.labelOffsetY,-5e3,5e3),f;if(o)f=v(I.get(t)??b(t.label,s,a?Math.max(64,r/2):4e3,1),n+(u??0),i+(d??-3),` class="pele-label" font-size="${s}" font-weight="var(--_hw)"`);else{let r=b(t.label,s),a=` class="pele-label" font-size="${s}"`,o=zMt+(c?10:0);if(u!==void 0||d!==void 0)f=y(r,n+(u??o),i+(d??-o),a);else if(t.inPipeline)f=v(r,n,i+2*V2+4+r.height/2,a);else{let t=re.get(e)??0,c=t&1?t&2?t&4?t&8?1:8:4:2:1,l=c===1||c===2,u=c===1||c===4;f=y(r,l?n+o:n-o-r.width,u?i-o:i+o+s*.75,a)}}_(n-2*V2,i-2*V2,n+2*V2+20,i+2*V2),oe+=`<g class="pele-node pele-wardley-${o?`anchor`:t.isPipelineParent?`pipeline-parent`:t.inPipeline?`pipeline-component`:`component`}" data-id="${mq(t.id)}">${l}${f}</g>`}let le=``;for(let t of e.annotations){let e=b(String(t.number),c,4e3,1),n=``;for(let r of t.coordinates){let t=x(r.x),i=S(r.y),a=Math.max(10,e.width/2+4);_(t-a,i-a,t+a,i+a),n+=`<circle cx="${K(t)}" cy="${K(i)}" r="${K(a)}" fill="var(--_bg)" stroke="${K2}"/>`+gq(e,t,i,` font-size="${c}" font-weight="var(--_hw)"`)}le+=`<g class="pele-wardley-annotation" data-id="${mq(String(t.number))}">${n}</g>`}let ue=e.annotations.filter(e=>e.text).sort((e,t)=>e.number-t.number);if(ue.length>0){let t=ue.map(e=>b(`${e.number}. ${e.text}`,s,a?Math.max(80,r-20):320)),n=0,i=0;for(let e of t)n=Math.max(n,e.width),i+=e.height;n+=20,i+=14;let o=e.annotationsBox,c=o?q2(x(o.x),0,Math.max(0,r-n)):0,l=o?q2(S(o.y),0,Math.max(0,d-i)):P;_(c,l,c+n,l+i);let u=``,f=l+7;for(let e of t)u+=UMt(e,c+10,f+e.lineHeight/2+s*.35,` font-size="${s}"`),f+=e.height;le+=`<g class="pele-wardley-annotations"><rect x="${K(c)}" y="${K(l)}" width="${K(n)}" height="${K(i)}" rx="${fJ}" fill="var(--_bg)" stroke="var(--_b)"/>${u}</g>`}let de=``;for(let t of e.notes)de+=y(b(t.text,s,Math.min(360,r*.6),1),x(t.x),S(t.y),` class="pele-wardley-note" font-size="${s}" font-weight="var(--_hw)"`);let fe=``,pe=(e,t,n,r)=>{let i=x(t),a=S(n),o=BMt/2,s=r?i+W2:i,l=r?i:i+W2,u=r?i+W2-VMt:i+VMt,d=`M${K(l)},${K(a-o)}H${K(u)}V${K(a-o-8)}L${K(s)},${K(a)}L${K(u)},${K(a+o+8)}V${K(a+o)}H${K(l)}Z`;_(i,a-o-8,i+W2,a+o+8),fe+=`<g class="pele-wardley-${r?`accelerator`:`deaccelerator`}" data-id="${mq(e)}"><path d="${d}" fill="var(--_s)" stroke="${K2}"/>`+v(b(e,c+1,160,1),i+W2/2,a+o+8+12,` font-size="${c+1}" font-weight="var(--_hw)"`)+`</g>`};for(let t of e.accelerators)pe(t.name,t.x,t.y,!0);for(let t of e.deaccelerators)pe(t.name,t.x,t.y,!1);let me=WJ(e.title,!1,l,o,a?Math.max(80,r):4e3,1),he=me.height>0?me.height+12:0,ge=Math.min(p,r/2-me.width/2),_e=Math.max(h,r/2+me.width/2),ve=u-ge,ye=u+he-m,be=Math.ceil(_e-ge+2*u),xe=Math.ceil(g-m+he+2*u);return{svg:vJ(`wardley`,be,xe,o,n,e,gq(me,ve+r/2,u+me.height/2,` class="pele-title" font-weight="var(--_tw)"`)+`<g transform="translate(${K(ve)},${K(ye)})"><g class="pele-wardley-frame" fill="none">${E}</g>`+D+N+ee+(ae?`<g class="pele-edges" fill="none">${ae}</g>`:``)+(L?`<g class="pele-wardley-trends" fill="none">${L}</g>`:``)+oe+le+de+fe+`</g>`),width:be,height:xe,links:[]}}var qMt={type:`wardley`,section:`wardley-beta`,parse:(e,t,n)=>AMt(IMt(e),n),render:GMt},JMt=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(e){this.orientation=e===`horizontal`?`horizontal`:`vertical`}setXAxisTitle(e){this.xAxis.title=e.text.trim()}setXAxisRangeData(e,t){this.xAxis={type:`linear`,title:this.xAxis.title,min:e,max:t},this.hasSetXAxis=!0}setXAxisBand(e){this.xAxis={type:`band`,title:this.xAxis.title,categories:e.map(e=>e.text.trim())},this.hasSetXAxis=!0}setYAxisTitle(e){this.yAxis.title=e.text.trim()}setYAxisRangeData(e,t){this.yAxis={type:`linear`,title:this.yAxis.title,min:e,max:t},this.hasSetYAxis=!0}plotData(e){if(e.length===0)return[];this.hasSetXAxis||this.setXAxisRangeData(1,e.length);let t=this.xAxis;if(t.type===`band`&&e.length>t.categories.length&&(e=e.slice(0,t.categories.length)),!this.hasSetYAxis){let{min:t,max:n}=this.yAxis;for(let r of e)r<t&&(t=r),r>n&&(n=r);this.yAxis={type:`linear`,title:this.yAxis.title,min:t,max:n}}if(t.type===`band`)return t.categories.map((t,n)=>[t,e[n]]);if(e.length===1)return[[`${t.min}`,e[0]]];let n=(t.max-t.min)/(e.length-1);return e.map((e,r)=>[`${t.min+r*n}`,e])}addPlot(e,t,n){let r={type:e,title:t.text.trim(),data:this.plotData(n.map(e=>e.value))};e===`line`&&n.some(e=>e.label.trim()!==``)&&(r.pointLabels=n.map(e=>e.label.trim())),this.plots.push(r)}setLineData(e,t){this.addPlot(`line`,e,t)}setBarData(e,t){this.addPlot(`bar`,e,t)}setDiagramTitle(e){this.title=e}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,``)}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
1071
|
+
but found: '${Z0(q0)}'`);(V0[W0[q0]]&R0)!==0;)q0++;return U0.slice(G0[e],K0[q0-1]).replaceAll(`\\,`,`,`)}function Fjt(){let e=[Pjt()];for(;W0[q0]===24;)q0++,e.push(Pjt());return e}function g2(){let e=[e2(21)];for(;W0[q0]===24;)q0++,e.push(e2(21));return e}function _2(e){let t=r2(e);return{id:Z0(e),span:t,idSpan:t}}function Ijt(){let e=q0,t=W0[q0],n;if(t===41||t===42||t===40){q0++;let r=Z0(e);t===40?J0.accDescription=r.slice(r.indexOf(`{`)+1,r.lastIndexOf(`}`)).trim():t===42?J0.accDescription=r.slice(r.indexOf(`:`)+1).trim():J0.accTitle=r.slice(r.indexOf(`:`)+1).trim(),n=h2(t===41?`accTitle`:`accDescr`)}else if(t===5){q0++;let e=W0[q0];(e<6||e>10)&&t2(`TD|TB|BT|LR|RL`),J0.direction=e===6?`TB`:Z0(q0),q0++,n=h2(`direction`)}else{if(t===2)return jjt(!0);if(t===3)return Njt();if(t===11){q0++,e2(12);let e=e2(21),t=a2();J0.notes.push({target:Z0(e),span:Q0(e),label:t}),n=h2(`note`),n.ref=`note-${vjt++}`,n.refSpan=t.span,n.nodes=[_2(e)]}else if(t===43){q0++;let t=e2(44),r=[],i=[];W0[q0]===52&&l2(r,i);let a=G0[e]+4;for(;U0.charCodeAt(a)===32||U0.charCodeAt(a)===9;)a++;let o=a;for(;/\w/.test(U0.charAt(o));)o++;let s={id:U0.slice(a,o),value:{},propertyOrder:/* @__PURE__ */ new Map,span:[a,o],classes:r};J0.jsons.push(s),X0.push([s,t]),n=h2(`json`),n.nodes=[{id:s.id,span:s.span,idSpan:s.span,defines:!0,classSpans:i}],n.classSpans=i}else if(t===14){q0++;let e=g2();J0.classDefs.push({ids:e.map(Z0),styles:Fjt()}),n=h2(`classDef`),n.ref=Z0(e[0]),n.refSpan=Q0(e[0])}else if(t===15){q0++;let e=g2(),t=g2();J0.classes.push({targets:e.map(e=>({id:Z0(e),span:Q0(e)})),classes:t.map(Z0)}),n=h2(`classAssign`),n.ref=Z0(t[0]),n.refSpan=Q0(t[0]),n.nodes=e.map(_2)}else if(t===16){q0++;let e=e2(21);J0.styles.push({target:Z0(e),span:Q0(e),styles:Fjt()}),n=h2(`style`),n.nodes=[_2(e)]}else{let r=W0[q0+1];if(r===60){(V0[W0[q0+2]]&djt)===0&&t2(bjt()),q0++;let r=_2(e);t!==21&&(r.id=Cjt(U0.slice(r.span[0],r.span[1])));let i=s2();n=h2(`metadata`),n.nodes=[r],n.metadata=c2(i),J0.metadata.push({target:r.id,span:r.span,properties:i,statement:n})}else return((V0[r]&cjt)===0&&(t!==21||r!==65&&r!==63)||t===21&&hjt.has(Z0(e).toLowerCase()))&&t2(bjt()),Mjt(!0)}}return n2(),n}function Ljt(e){let t=q0,n=W0[q0];if(n===39)return q0++,{kind:`blank`,span:Q0(t)};if(n===38)return q0++,n2(),{kind:`comment`,span:Q0(t)};let r=e?Ijt():n===2?jjt(!1):Mjt(!1);if(r.span=[G0[t],gjt],r.edges)for(let e of r.edges)e.span=r.span;return r}function Rjt(e,t){U0=e,{types:W0,starts:G0,ends:K0}=QAt(e),q0=0,J0=ejt(),Y0=void 0,X0=[],_jt=0,vjt=0;try{let n=e2(1);n2();let r=[];for(;(V0[W0[q0]]&sjt)!==0;)r.push(Ljt(!0));W0[q0]!==0&&$0(`Redundant input, expecting EOF but found: ${Z0(q0)}`);for(let[t,n]of X0){let r=ojt(Z0(n),()=>N0(e,G0[n]));t.value=r.value,t.propertyOrder=r.propertyOrder}return njt(e,J0,Q0(n),r,t)}finally{U0=``,W0=G0=K0=X0=[]}}var zjt={normal:`usecaseActor`,hollow:`usecaseActorHollow`,awesome:`usecaseActorAwesome`,icon:`usecaseActorIcon`},v2=[[`none`,`arrow_point`],[`arrow_point`,`none`],[`none`,`none`],[`none`,`arrow_circle`],[`none`,`arrow_cross`],[`arrow_circle`,`none`],[`arrow_cross`,`none`]];function Bjt(e){return typeof e==`string`?e:e===null?`null`:String(e)}function Vjt(e){let t=[],n=[[e.value,``,``]],r=[];for(;n.length>0;){let[i,a,o]=n.pop();if(r.length=0,Array.isArray(i))i.length===0?t.push({key:a,accessibleKey:a,value:`[]`}):i.every(e=>typeof e!=`object`||!e)?i.forEach((e,n)=>t.push({key:n===0?a:``,accessibleKey:a,value:Bjt(e)})):i.forEach((e,t)=>r.push([e,`${a}[${t}]`,`${o}/${t}`]));else if(typeof i==`object`&&i){let n=i,s=e.propertyOrder.get(o)??Object.keys(n);s.length===0&&t.push({key:a,accessibleKey:a,value:`{}`});for(let e of s)r.push([Object.prototype.hasOwnProperty.call(n,e)?n[e]:void 0,a?`${a}.${e}`:e,`${o}/${e.replaceAll(`~`,`~0`).replaceAll(`/`,`~1`)}`])}else t.push({key:a,accessibleKey:a,value:Bjt(i)});for(let e=r.length-1;e>=0;e--)n.push(r[e])}return t}function y2(...e){return e.filter(Boolean).join(` `)}function Hjt(e){return e.type===`generalization`?[`none`,`extension`]:e.type===`association`?v2[e.arrowType]??v2[2]:v2[0]}function Ujt(e){let t=[],n=[],r=t=>{let n=/* @__PURE__ */ new Map;for(let r of[`default`,...t]){let t=e.classDefs.get(r);if(t)for(let e of t.styles){let t=e.trim(),r=t.indexOf(`:`),i=(r===-1?t:t.slice(0,r)).trim();i&&n.set(i,t)}}return[...n.values()]};for(let n of e.actors.values())t.push({id:n.id,label:n.label,labelType:n.labelType,shape:zjt[n.type],isGroup:!1,padding:10,cssClasses:y2(`default`,`usecase-actor`,`usecase-actor-${n.type}`,n.business&&`usecase-business`,...n.classes),cssStyles:[...n.styles],cssCompiledStyles:r(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 e.useCases.values()){let e=n.shape===`ellipse`;t.push({id:n.id,label:n.label,labelType:n.labelType,shape:e?n.business?`usecaseBusiness`:`usecaseEllipse`:`rect`,isGroup:!1,padding:e?20:10,cssClasses:y2(`default`,`usecase-element`,`usecase-${n.shape}`,n.business&&`usecase-business`,...n.classes),cssStyles:[...n.styles],cssCompiledStyles:r(n.classes),business:n.business,stereotype:n.stereotype||void 0,parentId:n.parentId||void 0})}for(let n of e.notes.values())t.push({id:n.id,label:n.label,labelType:n.labelType,shape:`note`,isGroup:!1,padding:10,cssClasses:`default usecase-note`,cssStyles:[],cssCompiledStyles:r([]),noteTarget:n.target});for(let n of e.jsonNodes.values())t.push({id:n.id,label:n.id,labelType:`text`,shape:`usecaseJsonTable`,isGroup:!1,padding:10,cssClasses:y2(`default`,`usecase-json-table`,...n.classes),cssStyles:[...n.styles],cssCompiledStyles:r(n.classes),jsonRows:Vjt(n)});for(let n of e.systemBoundaries.values())t.push({id:n.id,label:n.label,labelType:n.labelType,shape:`usecaseSystemBoundary`,isGroup:!0,padding:20,cssClasses:y2(`default`,`system-boundary`,`system-boundary-${n.type}`,...n.classes),cssStyles:[...n.styles],cssCompiledStyles:r(n.classes),boundaryType:n.type});for(let t of e.relationships){let e=t.type===`include`||t.type===`extend`,[i,a]=Hjt(t),o=t.animate||t.animation!==void 0,s={id:t.id,start:t.source,end:t.target,relationshipType:t.type,pattern:e?`dotted`:`solid`,arrowTypeStart:i,arrowTypeEnd:a,classes:y2(`default`,`relationship`,`relationship-${t.type}`,...t.classes,o&&`edge-animation-${t.animation??`fast`}`),style:[...t.styles],cssCompiledStyles:r(t.classes),animate:t.animate,animation:t.animation,minlen:t.minlen,explicitId:t.explicitId,internal:!1};e?(s.label=t.type,s.labelType=`text`):t.type===`association`&&(t.label&&(s.label=t.label),t.labelType&&(s.labelType=t.labelType)),n.push(s)}for(let t of e.notes.values())n.push({id:`${t.id}-edge`,start:t.id,end:t.target,relationshipType:`note`,pattern:`dotted`,arrowTypeStart:`none`,arrowTypeEnd:`none`,classes:`default relationship relationship-note`,style:[],cssCompiledStyles:r([]),animate:!1,minlen:1,explicitId:!1,internal:!0});return{nodes:t,edges:n}}var Wjt=32,Gjt=16,Kjt=72,b2=20,x2=26,S2=40,C2=60,qjt=6,w2=6,T2=10,E2=8,D2=9,O2=12,Jjt=14,k2=` fill="var(--_s)" stroke="var(--_b)"`;function Yjt(e,t,n){let r=e.usecase?.[t];return typeof r==`number`&&r>0?Math.min(r,2e3):n}function Xjt(e){return e.replace(/[&<>\\]/g,e=>`&#${e.charCodeAt(0)};`)}function A2(e,t,n,r,i,a=0){return UJ(e&&!t?Xjt(e):e,t,n,r,i,a)}function j2(e,t,n,r){let i=n===1||n===2?1:-1,a=n===1||n===3,o=(a?e.w:e.h)/2,s=0;if(e.kind===0)a?(o=S2/2+3,s=(C2-e.h)/2):o+=2;else if(e.kind===1){let t=(a?e.h:e.w)/2;o*=Math.sqrt(Math.max(1-(r/t)**2,0))}return a?[t.x+i*o,t.y+s+r]:[t.x+r,t.y+i*o]}function Zjt(e,t){let n=t===1||t===3;if(e.kind===0)return n?C2*.5:S2*.6;let r=n?e.h:e.w;return e.kind===1?r*.6:r-16}function Qjt(e,t,n){let r=/* @__PURE__ */ new Map,i=(e,n,i,a)=>{let o=t[e];if(o.isGroup)return;let s=n[i]-o.x,c=n[i+1]-o.y,l;if(Math.abs(Math.abs(c)-o.h/2)<.5)l=c<0?0:2;else if(Math.abs(Math.abs(s)-o.w/2)<.5)l=s<0?3:1;else return;let u=e*4+l,d={route:n,at:i,toward:n[a+(l&1?1:0)]},f=r.get(u);f?f.push(d):r.set(u,[d])};for(let t of e){let e=t.route.length-3;t.src===t.dst||e<3||(i(t.src,t.route,0,3),i(t.dst,t.route,e,e-3))}for(let[e,i]of r){let r=e>>2,a=e&3,o=n[r],s=i.length>1?Math.min(Jjt,Zjt(o,a)/(i.length-1)):0;i.sort((e,t)=>e.toward-t.toward);for(let e=0;e<i.length;e++){let[n,c]=j2(o,t[r],a,(e-(i.length-1)/2)*s);i[e].route[i[e].at]=n,i[e].route[i[e].at+1]=c}}}function $jt(e,t,n,r,i){let a=e-n*O2,o=t-r*O2,s=O2*.5;return`<path class="pele-marker" d="M${K(e)},${K(t)}L${K(a-r*s)},${K(o+n*s)}L${K(a+r*s)},${K(o-n*s)}Z" fill="var(--_bg)" stroke="${i}" stroke-linejoin="round"/>`}function M2(e){return e===`extension`?O2:sJ(e)}function eMt(e,t,n,r,i,a){return e===`extension`?$jt(t,n,r,i,a):cJ(e,t,n,r,i,a)}function tMt(e,t){let n=e.node,r=e.style.shape,i=` fill="none" stroke="var(--_b)"${e.style.line}`,a=-21,o=9,s;return n.actorType===`hollow`?(o=8,s=`<circle cy="-21" r="8" fill="var(--_bg)" stroke="var(--_b)"${r}/><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"${r}/>`):n.actorType===`awesome`?s=`<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)"${r}/>`:n.actorType===`icon`?(a=-14,o=12,s=`<rect x="-22" y="-26" width="44" height="44" rx="${dJ}"${k2}${r}/><svg class="pele-icon" data-icon="${mq(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">${t?.(n.icon??``)??``}</svg>`):s=`<circle cy="-21" r="9"${k2}${r}/><path d="M0,-12V10M-14,-3H14M0,10L-12,30M0,10L12,30"${i}/>`,n.business&&(s+=`<path class="pele-business" d="M${K(.12*o)},${K(a+.99*o)}L${K(.92*o)},${K(a-.39*o)}"${i}/>`),s}function nMt(e,t,n){return JJ(e.direction)?qJ(n,r=>rMt(e,t,n,r)):rMt(e,t,n,!1)}function rMt(e,t,n,r){let i=Ujt(e),a=n.fontSize??16,o=Math.round(a*.875),s=Math.round(a*.8125),c=n.measurer??fq(n.fontFamily),l=n.padding??8,u=n.icons,d=r?`TB`:Xq(e.direction),f=d===`LR`||d===`RL`,p=/* @__PURE__ */ new Map,m=[],h=[];i.nodes.forEach((e,t)=>p.set(e.id,t));for(let e of i.nodes){let t=pJ(e.cssStyles.length>0?e.cssCompiledStyles.concat(e.cssStyles):e.cssCompiledStyles),n=+!!t.bold|(t.italic?2:0),r=t.fontSize??a,i=e.labelType===`markdown`,l=A2(e.stereotype&&`«${e.stereotype}»`,!1,c,s,200,n),u={node:e,kind:2,style:t,label:l,stereotype:l,w:0,h:0,rows:[],keyW:0,headH:0,loops:0},d;if(e.isGroup){u.kind=4,u.label=A2(e.label,i,c,r,4e3,n);let t=u.label.height;d=Qq(0,0),d.isGroup=!0,d.padX=b2,d.padBottom=b2,d.padTop=e.boundaryType===`package`?t+2*w2+16:t>0?t+16:b2,d.minW=u.label.width+2*b2}else{if(e.jsonRows){u.kind=3,u.label=A2(e.label,!1,c,r,4e3,n|1);let t=0;for(let r of e.jsonRows){let e=A2(r.key,!1,c,o,4e3,n),i=A2(r.value,!1,c,o,260,n);u.rows.push([e,i]),u.keyW=Math.max(u.keyW,e.width),t=Math.max(t,i.width),u.h+=Math.max(i.height,Math.round(o*1.5))+E2}u.keyW>0&&(u.keyW+=2*T2),u.headH=Math.max(u.label.height,Math.round(r*1.5))+E2,u.w=Math.max(u.label.width+2*T2,u.rows.length>0?u.keyW+t+2*T2:0,72),u.h+=u.headH}else if(e.actorType)u.kind=0,u.label=A2(e.label,i,c,r,140,n),u.w=Math.max(S2,u.label.width,l.width),u.h=C2+qjt+l.height+u.label.height;else{u.label=A2(e.label,i,c,e.shape===`note`?o:r,180,n);let t=Math.max(u.label.width,l.width),a=u.label.height+l.height;e.shape===`usecaseEllipse`||e.shape===`usecaseBusiness`?(u.kind=1,u.w=Math.max(t+2*e.padding+(e.business?16:4),88),u.h=Math.max(a+28,48)):e.shape===`note`?(u.w=t+2*e.padding+6,u.h=a+18):(u.w=Math.max(t+2*e.padding+12,80),u.h=Math.max(a+24,44))}d=Qq(u.w,u.h)}d.seq=m.length,m.push(u),h.push(d)}i.nodes.forEach((e,t)=>{h[t].parent=e.parentId===void 0?-1:p.get(e.parentId)??-1});let g=[],_=[],v=[];for(let e of i.edges){let t=p.get(e.start),n=p.get(e.end);if(t===void 0||n===void 0)continue;let r=A2(e.relationshipType===`include`||e.relationshipType===`extend`?`«${e.label}»`:e.label,e.labelType===`markdown`,c,o,200);t===n&&(m[t].loops++,f?h[t].h+=2*(x2+(r.height>0?r.height+8:0)):h[t].w+=2*(x2+(r.width>0?r.width+12:0))),v.push(e),_.push(r),g.push({src:t,dst:n,minlen:e.minlen,labelW:r.width>0?r.width+12:0,labelH:r.height>0?r.height+4:0,route:[],labelX:0,labelY:0})}let y=eJ(h,g,d,{nodeSep:Yjt(t,`nodeSpacing`,Wjt),edgeSep:Gjt,rankSep:Yjt(t,`rankSpacing`,Kjt),portSep:20}),b=UJ(e.title,!1,c,a,4e3,1),x=b.height>0?b.height+12:0,S=Math.max(y.width,b.width);Zq(h,g,l+(S-y.width)/2,l+x);let C=Math.ceil(S+2*l),w=Math.ceil(y.height+x+2*l),T=/* @__PURE__ */ new Map;for(let e of g)tJ(T,e.route);Qjt(g,h,m);let E=``,D=``;for(let e=0;e<m.length;e++){let t=m[e],n=h[e],r=t.node,i=mJ(r.cssClasses.replace(/^default\s?/,``)),a=mq(r.id),c=t.style.text,l=t.style.shape,d=t.w,f=t.h;if(t.kind===4){let e=n.x-n.w/2,o=n.y-n.h/2,s=` fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${l}`,d=` class="pele-cluster-label" fill="var(--_m)"${c}`,f;if(r.boundaryType===`package`){let r=Math.min(t.label.width+2*w2+8,n.w),i=t.label.height+2*w2;f=`<rect class="pele-boundary-tab" x="${K(e)}" y="${K(o)}" width="${K(r)}" height="${K(i)}"${s}/><rect x="${K(e)}" y="${K(o+i)}" width="${K(n.w)}" height="${K(n.h-i)}"${s}/>`+gq(t.label,e+r/2,o+i/2,d,u)}else f=`<rect x="${K(e)}" y="${K(o)}" width="${K(n.w)}" height="${K(n.h)}" rx="${dJ}"${s}/>`+gq(t.label,iMt(n,t.label.width,T),o+8+t.label.height/2,d,u);E+=`<g class="pele-cluster pele-boundary${i}" data-id="${a}">${f}</g>`;continue}let p,g;if(t.kind===0){g=`pele-actor`;let e=-f/2,n=e+C2+qjt+t.stereotype.height/2;p=`<g class="pele-actor-figure" transform="translate(0,${K(e+C2/2)})">${tMt(t,u)}</g>`+gq(t.stereotype,0,n,` class="pele-stereotype" font-size="${s}" fill="var(--_m)"`,u)+gq(t.label,0,f/2-t.label.height/2,` class="pele-label"${c}`,u)}else if(t.kind===3){g=`pele-json`;let e=-d/2,n=-f/2+t.headH,r=``,i=`M${K(e)},${K(n)}H${K(e+d)}`;t.keyW>0&&(i+=`M${K(e+t.keyW)},${K(n)}V${K(f/2)}`);for(let[i,a]of t.rows){let s=Math.max(a.height,Math.round(o*1.5))+E2;r+=gq(i,e+T2+i.width/2,n+s/2,` class="pele-json-key" fill="var(--_m)"`,u)+aMt(a,e+t.keyW+T2,n+s/2,` class="pele-json-value"${c}`,u),n+=s}p=`<rect x="${K(e)}" y="${K(-f/2)}" width="${K(d)}" height="${K(f)}" rx="${dJ}"${k2}${l}/><path class="pele-json-lines" d="${i}" fill="none" stroke="var(--_b)"${t.style.line}/>`+gq(t.label,0,-f/2+t.headH/2,` class="pele-label" font-weight="var(--_hw)"${c}`,u)+`<g font-size="${o}">${r}</g>`}else{let e=t.stereotype.height/2,n;if(t.kind===1){if(g=`pele-usecase`,n=`<ellipse rx="${K(d/2)}" ry="${K(f/2)}"${k2}${l}/>`,r.business){let e=d/2-15,r=d/2-5,i=e=>f/2*Math.sqrt(1-(e/(d/2))**2);n+=`<path class="pele-business" d="M${K(e)},${K(i(e))}L${K(r)},${K(-i(r))}" fill="none" stroke="var(--_b)"${t.style.line}/>`}}else if(r.shape===`note`){g=`pele-note`;let e=d/2,r=f/2;n=`<path d="M${K(-e)},${K(-r)}H${K(e-D2)}L${K(e)},${K(D2-r)}V${K(r)}H${K(-e)}Z" fill="var(--_a)" stroke="var(--_b)" stroke-linejoin="round"${l}/><path d="M${K(e-D2)},${K(-r)}V${K(D2-r)}H${K(e)}" fill="none" stroke="var(--_b)" stroke-linejoin="round"${t.style.line}/>`}else g=`pele-usecase`,n=`<rect x="${K(-d/2)}" y="${K(-f/2)}" width="${K(d)}" height="${K(f)}" rx="${dJ}"${k2}${l}/>`;p=n+gq(t.stereotype,0,-t.label.height/2,` class="pele-stereotype" font-size="${s}" fill="var(--_m)"`,u)+gq(t.label,0,e,` class="pele-label"${r.shape===`note`?` font-size="${o}"`:``}${c}`,u)}D+=`<g class="pele-node ${g}${i}" data-id="${a}" transform="translate(${K(n.x)},${K(n.y)})">${p}</g>`}let O=``,k=``,A=/* @__PURE__ */ new Map;for(let e=0;e<g.length;e++){let t=g[e],n=v[e],r=_[e],i=n.style.length>0||n.cssCompiledStyles.length>0?pJ(n.cssCompiledStyles.concat(n.style)):void 0,a=n.arrowTypeStart,o=n.arrowTypeEnd,s;if(t.src===t.dst){let e=h[t.src],n=m[t.src],i=A.get(t.src)??0;A.set(t.src,i+1);let c=f?2:1,l=Math.min(Zjt(n,c)/2,8+i*6),u=x2+i*8,[d,p]=j2(n,e,c,-l),[g,_]=j2(n,e,c,l),v=Math.hypot(u,l)||1,y=f?l/v:u/v,b=f?u/v:l/v,x=M2(a),S=M2(o),C=(e,t,n,r)=>f?`${K(e+n*l*+!!r)},${K(t+r)}`:`${K(e+r)},${K(t+n*l*+!!r)}`,w=f?d-y*x:d+y*x,T=f?p+b*x:p-b*x,E=g+y*S,D=_+b*S;s={d:`M${K(w)},${K(T)}C${C(d,p,-1,u)} ${C(g,_,1,u)} ${K(E)},${K(D)}`,sx:d,sy:p,sdx:f?y:-y,sdy:f?-b:b,ex:g,ey:_,edx:-y,edy:-b},f?(t.labelX=e.x,t.labelY=Math.max(p,_)+u*.75+6+r.height/2):(t.labelX=Math.max(d,g)+u*.75+8+r.width/2,t.labelY=e.y)}else{if(t.route.length<6)continue;s=oJ(t.route,void 0,M2(a),M2(o))}let c=i?.stroke?pq(i.stroke):`var(--_l)`,l=n.internal?`2 3`:n.pattern===`dotted`?`5 4`:n.animate?`9 5`:``;if(O+=`<g class="pele-edge pele-${n.relationshipType}${mJ(n.classes.replace(/^default relationship relationship-\S+\s?/,``))}" data-id="${mq(n.id)}"${i?.line??``}><path d="${s.d}"${l?` stroke-dasharray="${l}"`:``}/>`+eMt(a,s.sx,s.sy,s.sdx,s.sdy,c)+eMt(o,s.ex,s.ey,s.edx,s.edy,c)+`</g>`,r.width>0){let e=t.labelX,a=t.labelY,o=n.relationshipType===`include`||n.relationshipType===`extend`;k+=lJ(n.id,r,e,a,(o?` fill="var(--_m)"`:``)+(i?.text??``),u)}}return{svg:_J(`usecase`,C,w,a,n,e,gq(b,C/2,l+b.height/2,` class="pele-title" font-weight="var(--_tw)"`)+(E?`<g class="pele-clusters">${E}</g>`:``)+(O?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${O}</g>`:``)+(k?`<g class="pele-edge-labels" font-size="${o}">${k}</g>`:``)+`<g class="pele-nodes">${D}</g>`),width:C,height:w,links:[]}}function iMt(e,t,n){let r=n.get(Math.round(e.y-e.h/2));if(t===0||r===void 0)return e.x;let i=e.x-e.w/2+6,a=e.x+e.w/2-6,o=r.filter(e=>e>i&&e<a).sort((e,t)=>e-t);o.push(a);let s=t/2+6,c=e.x,l=1/0,u=0,d=i;for(let t of o){if(t-d>=2*s){let n=Math.min(Math.max(e.x,d+s),t-s);Math.abs(n-e.x)<l&&(l=Math.abs(n-e.x),c=n)}else l===1/0&&t-d>u&&(u=t-d,c=(d+t)/2);d=t}return c}function aMt(e,t,n,r,i){if(e.lines.length<2)return gq(e,t+e.width/2,n,r,i);let a=``;for(let o=0;o<e.lines.length;o++){let s={...e,lines:[e.lines[o]],widths:[e.widths[o]],height:e.lineHeight};a+=gq(s,t+e.widths[o]/2,n-e.height/2+(o+.5)*e.lineHeight,r,i)}return a}var oMt={type:`usecase`,parse:(e,t,n)=>Rjt(e,n),render:nMt};function N2(e){let t=e.trim();return t.length>=2&&t.startsWith(`"`)&&t.endsWith(`"`)?t.slice(1,-1):t}function P2(e){return e.map(N2).sort()}var sMt=class{type=`venn`;title;subsets=[];textNodes=[];styles=[];known=/* @__PURE__ */ new Set;current;indent=!1;setDiagramTitle(e){this.title=e}addSubsetData(e,t,n){let r=P2(e);this.current=r,r.length===1&&this.known.add(r[0]),this.subsets.push({sets:r,size:n??10/e.length**2,label:t?N2(t):void 0})}addTextData(e,t,n){this.textNodes.push({sets:P2(e),id:N2(t),label:n?N2(n):void 0})}addStyleData(e,t){let n=/* @__PURE__ */ new Map;for(let[e,r]of t)n.set(e,r&&N2(r));this.styles.push({targets:P2(e),styles:n})}validateUnionIdentifiers(e){let t=e.map(N2).filter(e=>!this.known.has(e));if(t.length>0)throw new NK(`unknown set identifier: ${t.join(`, `)}`,`semantic`,{type:`venn`})}getCurrentSets(){return this.current}getIndentMode(){return this.indent}setIndentMode(e){this.indent=e}},cMt=[`$end`,`INVALID`,`EOF`,`NEWLINE`,`VENN`,`TITLE`,`SET`,`UNION`,`TEXT`,`INDENT_TEXT`,`STYLE`,`BRACKET_LABEL`,`NUMERIC`,`HEXCOLOR`,`RGBCOLOR`,`RGBACOLOR`,`IDENTIFIER`,`STRING`,`COMMA`,`COLON`],lMt=[[`venn-beta`,4],[`set`,6],[`union`,7],[`text`,8],[`style`,10]],uMt=class{constructor(e,t){this.src=e,this.host=t}src;host;text=``;start=0;at=0;lineStart=!1;ended=!1;word(e,t){let n=this.src;for(let r=0;r<t.length;r++){let i=n.charCodeAt(e+r),a=t.charCodeAt(r);if(i!==a&&(i+32!==a||i<65||i>90))return!1}return!0}keyword(e,t){return this.word(e,t)&&!aq(this.src.charCodeAt(e+t.length))}color(e,t){let n=this.src,r=e+1;for(let e=0;e<t;e++){for(;eq(n.charCodeAt(r));)r++;let i=r;for(;rq(n.charCodeAt(r))||n.charCodeAt(r)===46;)r++;if(r===i)return-1;for(;eq(n.charCodeAt(r));)r++;if(n.charCodeAt(r)!==(e===t-1?41:44))return-1;r++}return r}lineEnd(e){let t=this.src.indexOf(`
|
|
1072
|
+
`,e);return t===-1?this.src.length:t}next(){let e=this.src,t=e.length;for(;;){let n=this.at;if(this.start=n,this.text=``,n>=t)return this.ended?0:(this.ended=!0,2);let r=e.charCodeAt(n);if(r===37&&e.charCodeAt(n+1)===37&&e.charCodeAt(n+2)!==123||r!==125&&e.charCodeAt(n+1)===37&&e.charCodeAt(n+2)===37)this.at=this.lineEnd(n+2);else{if(this.lineStart){if(r===32||r===9){let t=n+1;for(;e.charCodeAt(t)===32||e.charCodeAt(t)===9;)t++;if(this.at=t,this.keyword(t,`text`)&&this.host.getIndentMode())return this.at=t+4,this.lineStart=!1,this.text=e.slice(n,t),9;continue}r!==10&&r!==13&&(this.host.setIndentMode(!1),this.lineStart=!1)}if(r===10||r===13){for(n++;e.charCodeAt(n)===10||e.charCodeAt(n)===13;)n++;return this.lineStart=!0,this.token(3,n)}if(r===37&&e.charCodeAt(n+1)===37)this.at=this.lineEnd(n);else if(r===32||r===9){for(n++;e.charCodeAt(n)===32||e.charCodeAt(n)===9;)n++;this.at=n}else{if((r|32)>=97&&(r|32)<=122||r===95){if(this.word(n,`title`)&&eq(e.charCodeAt(n+5))){let r=n+6;for(;r<t;){let t=e.charCodeAt(r);if(t===35||t===10||t===59)break;r++}if(r>n+6)return this.token(5,r)}for(let[e,t]of lMt)if(this.keyword(n,e))return this.token(t,n+e.length);if(this.word(n,`rgb`)){let t=(e.charCodeAt(n+3)|32)==97,r=n+(t?4:3),i=e.charCodeAt(r)===40?this.color(r,t?4:3):-1;if(i!==-1)return this.token(t?15:14,i)}for(n++;aq(e.charCodeAt(n))||e.charCodeAt(n)===45;)n++;return this.token(16,n)}if(r===91){if(e.charCodeAt(n+1)===34){let t=e.indexOf(`"`,n+2);return t===-1||e.charCodeAt(t+1)!==93?1:(this.at=t+2,this.text=e.slice(n+2,t),11)}let r=n+1;for(;r<t&&e.charCodeAt(r)!==93&&e.charCodeAt(r)!==34;)r++;return r===n+1||e.charCodeAt(r)!==93?1:(this.at=r+1,this.text=e.slice(n+1,r).trim(),11)}if(rq(r)||r===46||r===43||r===45){(r===43||r===45)&&n++;let t=n;for(;rq(e.charCodeAt(n));)n++;if(n>t){if(e.charCodeAt(n)===46&&rq(e.charCodeAt(n+1)))for(n+=2;rq(e.charCodeAt(n));)n++}else if(e.charCodeAt(n)===46&&rq(e.charCodeAt(n+1)))for(n+=2;rq(e.charCodeAt(n));)n++;else return 1;return this.token(12,n)}if(r===35){let t=n+1;for(;t<n+9&&Hft(e.charCodeAt(t));)t++;return t>=n+4?this.token(13,t):1}if(r===34){let t=e.indexOf(`"`,n+1);return t===-1?1:this.token(17,t+1)}return r===44?this.token(18,n+1):r===58?this.token(19,n+1):1}}}}token(e,t){return this.text=this.src.slice(this.at,t),this.at=t,e}},dMt=`'EOF', 'NEWLINE', 'TITLE', 'SET', 'UNION', 'TEXT', 'INDENT_TEXT', 'STYLE'`,fMt=`'NUMERIC', 'IDENTIFIER', 'STRING', 'HEXCOLOR', 'RGBCOLOR', 'RGBACOLOR'`;function pMt(e,t){let n=new uMt(e,t),r=-1,i=()=>r===-1?r=n.next():r,a=t=>{throw i()===1?FK(`venn`,e,n.start,``,!0):FK(`venn`,e,n.start,`Expecting ${t}, got '${cMt[r]}'`)},o=()=>(r=-1,n.text),s=e=>(i()!==e&&a(`'${cMt[e]}'`),o()),c=()=>(i()!==16&&r!==17&&a(`'IDENTIFIER', 'STRING'`),o()),l=()=>{let e=[c()];for(;i()===18;)o(),e.push(c());return e},u=(e,n)=>{let r=i()===11?o():void 0,a;if(i()===19&&(o(),a=parseFloat(s(12))),n){if(e.length<2)throw new NK(`union requires multiple identifiers`,`semantic`,{type:`venn`});t.validateUnionIdentifiers(e)}t.addSubsetData(e,r,a),t.setIndentMode(!0)},d=e=>{let n=i();n!==16&&n!==17&&n!==12&&a(`'NUMERIC', 'IDENTIFIER', 'STRING'`);let r=o(),s=n!==12&&i()===11?o():void 0;t.addTextData(e(),r,s)},f=()=>{let e=l(),n=[];for(;;){let e=s(16);s(19);let t;if(i()===17)t=o();else{let e=[];for(;i()===16||r>=12&&r<=15;)e.push(o());e.length===0&&a(fMt),t=e.join(` `)}if(n.push([e,t]),i()!==18)break;o()}t.addStyleData(e,n)};for(;i()===3;)o();for(s(4);;){let e=i();if(e===2)return;if((e<3||e>10||e===4)&&a(dMt),o(),e===5)t.setDiagramTitle(n.text.slice(6));else if(e===6)u([c()],!1);else if(e===7)u(l(),!0);else if(e===8){let e=l();d(()=>e)}else e===9?d(()=>{let e=t.getCurrentSets();if(!e)throw new NK(`text requires set`,`semantic`,{type:`venn`});return e}):e===10&&f()}}var F2=Math.PI*2;function mMt(e){let t=/* @__PURE__ */ new Set,n=/* @__PURE__ */ new Map;for(let r of e)t.add(JSON.stringify([...r.sets].sort())),r.sets.length===1&&n.set(r.sets[0],r.size);let r=[];for(let i of e){if(i.sets.length<3)continue;let e=[...i.sets].sort();for(let i=0;i<e.length-1;i++)for(let a=i+1;a<e.length;a++){let o=[e[i],e[a]],s=JSON.stringify(o);if(t.has(s))continue;t.add(s);let c=n.get(o[0]),l=n.get(o[1]);r.push({sets:o,size:c!==void 0&&l!==void 0?Math.min(c,l)/4:2.5,label:``})}}return r.length>0?[...e,...r]:e}function hMt(e,t,n){if(n>=e+t)return 0;let r=Math.min(e,t);if(n<=Math.abs(e-t))return Math.PI*r*r;let i=e*e*Math.acos((n*n+e*e-t*t)/(2*n*e)),a=t*t*Math.acos((n*n+t*t-e*e)/(2*n*t)),o=.5*Math.sqrt(Math.max((-n+e+t)*(n+e-t)*(n-e+t)*(n+e+t),0));return i+a-o}function gMt(e,t,n){let r=Math.abs(e-t),i=e+t;if(!(n>0))return i;if(n>=Math.PI*Math.min(e,t)**2)return r;for(let a=0;a<48;a++){let a=(r+i)/2;hMt(e,t,a)>n?r=a:i=a}return(r+i)/2}function _Mt(e,t,n,r,i,a){let o=1/0;for(let n of t){let t=e[n],s=r-t.x,c=i-t.y,l=t.r-Math.sqrt(s*s+c*c);if(l<o){if(l<a)return l;o=l}}for(let t of n){let n=e[t],s=r-n.x,c=i-n.y,l=Math.sqrt(s*s+c*c)-n.r;if(l<o){if(l<a)return l;o=l}}return o}function I2(e,t,n){let r=0,i=0,a=e[t[0]];for(let n of t){let o=e[n];r+=o.x/t.length,i+=o.y/t.length,o.r<a.r&&(a=o)}let o=a.r,s=r,c=i,l=_Mt(e,t,n,s,c,-1/0),u=0,d=(a,d)=>{let f=_Mt(e,t,n,a,d,l-o*1e-9);if(!(f>l-o*1e-9))return!1;let p=Math.hypot(a-r,d-i);return f>l+o*1e-9||p<u-o*1e-9?(l=f,u=p,s=a,c=d,!0):!1};for(let e=-10;e<=10;e++)for(let t=-10;t<=10;t++)t*t+e*e<=100&&d(a.x+t*o/10,a.y+e*o/10);let f=o/10;for(let e=0;e<40&&f>o*1e-6;e++){let e=!1;for(let t=0;t<8;t++){let n=t*F2/8;d(s+Math.cos(n)*f,c+Math.sin(n)*f)&&(e=!0)}e||(f/=2)}return{x:s,y:c,margin:l}}function vMt(e){let t=/* @__PURE__ */ new Map;for(let n of e)for(let e of n.sets)t.has(e)||t.set(e,10);for(let n of e)n.sets.length===1&&t.set(n.sets[0],n.size);let n=/* @__PURE__ */ new Map,r=[],i=0;for(let e of t.values())Number.isFinite(e)&&e>i&&(i=e);i===0&&(i=10);let a=Math.sqrt(i/Math.PI);for(let[e,i]of t){n.set(e,r.length);let t=Number.isFinite(i)&&i>0?Math.sqrt(i/Math.PI):0;r.push({id:e,x:0,y:0,r:Math.max(t,a*.3)})}let o=r.length;if(o<2)return r;let s=/* @__PURE__ */ new Map;for(let t of mMt(e)){if(t.sets.length!==2)continue;let e=n.get(t.sets[0]),r=n.get(t.sets[1]);e!==r&&s.set(Math.min(e,r)*o+Math.max(e,r),t.size)}let c=/* @__PURE__ */ new Map;for(let[e,t]of s)c.set(e,gMt(r[Math.floor(e/o)].r,r[e%o].r,t));let l=a*.15,u=(e,t)=>c.get(e*o+t)??r[e].r+r[t].r+l;if(o===2)return r[1].x=u(0,1),r;if(o===3){let t=u(0,1),n=u(0,2),i=u(1,2),o=e.some(e=>new Set(e.sets).size===3);for(let e=0;e<40;e++){let e=t>0?(t*t+n*n-i*i)/(2*t):0;if(r[1].x=t,r[2].x=Math.max(-n,Math.min(n,e)),r[2].y=Math.sqrt(Math.max(n*n-e*e,0)),!o||I2(r,[0,1,2],[]).margin>a*.12)break;t*=.94,n*=.94,i*=.94}return r}let d=0;for(let e of r)d+=2*e.r+l;let f=Math.min(300,Math.floor(3e6/(o*o)));if(o<=64){let e=d/F2;r.forEach((t,n)=>{let r=n*F2/o-Math.PI/2;t.x=Math.cos(r)*e,t.y=Math.sin(r)*e})}else{let e=Math.ceil(Math.sqrt(o)),t=2*a+l;r.forEach((n,r)=>{n.x=r%e*t,n.y=Math.floor(r/e)*t})}let p=new Float64Array(o),m=new Float64Array(o),h=new Int32Array(o);for(let e=0;e<f;e++){p.fill(0),m.fill(0),h.fill(0);for(let e=0;e<o;e++)for(let t=e+1;t<o;t++){let n=c.get(e*o+t),i=r[e].r+r[t].r+l,a=r[t].x-r[e].x,s=r[t].y-r[e].y,u=Math.hypot(a,s);if(n===void 0&&u>=i)continue;u<1e-9&&(a=Math.cos(e+t),s=Math.sin(e+t),u=1);let d=(u-(n??i))/2/u;p[e]+=a*d,m[e]+=s*d,p[t]-=a*d,m[t]-=s*d,h[e]++,h[t]++}for(let e=0;e<o;e++)h[e]!==0&&(r[e].x+=p[e]/h[e],r[e].y+=m[e]/h[e])}return r}function yMt(e,t){let n=e=>`M${t(e.x-e.r)},${t(e.y)}A${t(e.r)},${t(e.r)} 0 1 1 ${t(e.x+e.r)},${t(e.y)}A${t(e.r)},${t(e.r)} 0 1 1 ${t(e.x-e.r)},${t(e.y)}Z`;if(e.length===1)return n(e[0]);let r=(t,n,r,i)=>{for(let a of e)if(a!==r&&a!==i&&Math.hypot(t-a.x,n-a.y)>a.r*(1+1e-9))return!1;return!0},i=[];for(let t=0;t<e.length;t++)for(let n=t+1;n<e.length;n++){let a=e[t],o=e[n],s=Math.hypot(o.x-a.x,o.y-a.y);if(s>=a.r+o.r||s<=Math.abs(a.r-o.r)||s===0)continue;let c=(a.r*a.r-o.r*o.r+s*s)/(2*s),l=Math.sqrt(Math.max(a.r*a.r-c*c,0)),u=a.x+(o.x-a.x)*c/s,d=a.y+(o.y-a.y)*c/s;for(let e of[1,-1]){let t=u+e*l*(o.y-a.y)/s,n=d-e*l*(o.x-a.x)/s;r(t,n,a,o)&&i.push({x:t,y:n,a,b:o})}}if(i.length<2){let t=e[0];for(let n of e)n.r<t.r&&(t=n);for(let n of e)if(n!==t&&Math.hypot(n.x-t.x,n.y-t.y)+t.r>n.r*(1+1e-9))return``;return n(t)}let a=0,o=0;for(let e of i)a+=e.x/i.length,o+=e.y/i.length;i.sort((e,t)=>Math.atan2(e.y-o,e.x-a)-Math.atan2(t.y-o,t.x-a));let s=``;for(let e=0;e<i.length;e++){let n=i[e],r=i[(e+1)%i.length];e===0&&(s=`M${t(n.x)},${t(n.y)}`);let a,o=0,c=1/0;for(let e of[n.a,n.b]){if(e!==r.a&&e!==r.b)continue;let t=Math.atan2(n.y-e.y,n.x-e.x),i=Math.atan2(r.y-e.y,r.x-e.x)-t;i<=0&&(i+=F2);let s=e.x+e.r*Math.cos(t+i/2),l=e.y+e.r*Math.sin(t+i/2),u=Math.hypot(s-(n.x+r.x)/2,l-(n.y+r.y)/2);u<c&&(c=u,a=e,o=+(i>Math.PI))}s+=a===void 0?`L${t(r.x)},${t(r.y)}`:`A${t(a.r)},${t(a.r)} 0 ${o} 1 ${t(r.x)},${t(r.y)}`}return s+`Z`}var bMt=100,xMt=1.6,SMt=pJ([]);function L2(e){return e.length===1?e[0]:JSON.stringify(e)}function CMt(e,t,n){let r=n.fontSize??16,i=Math.round(r*.875),a=Math.round(r*.8125),o=n.measurer??fq(n.fontFamily),s=n.padding??8,c=vMt(e.subsets),l=/* @__PURE__ */ new Map;c.forEach((e,t)=>l.set(e.id,t));let u=/* @__PURE__ */ new Map;for(let{targets:t,styles:n}of e.styles){let e=L2(t),r=u.get(e);r||u.set(e,r=/* @__PURE__ */ new Map);for(let[e,t]of n)r.set(e,t)}let d=e=>{let t=u.get(e);if(!t)return SMt;let n=[];for(let[e,r]of t)n.push(`${e}:${r}`);return pJ(n)},f=c.map(()=>[]);for(let e=0;e<c.length;e++)for(let t=e+1;t<c.length;t++)Math.hypot(c[e].x-c[t].x,c[e].y-c[t].y)<c[e].r+c[t].r&&(f[e].push(t),f[t].push(e));let p=/* @__PURE__ */ new Map;for(let t of e.subsets)p.set(L2(t.sets),t);let m=/* @__PURE__ */ new Map;for(let[e,t]of p){let n=[...new Set(t.sets)],a=n.map(e=>l.get(e)),s=new Set(a),u=a[0];for(let e of a)c[e].r<c[u].r&&(u=e);let p=d(e),h=t.label??(t.sets.length===1?t.sets[0]:void 0),g=+!!p.bold|(p.italic?2:0),_=I2(c,a,f[u].filter(e=>!s.has(e)));_.margin<c[u].r*.2&&(_=I2(c,a,[]));let v={sets:n,inside:a,spot:_,lines:[],style:p};if(h){let e=n.length===1?r:i;v.lines.push({id:void 0,raw:h,size:e,base:g,label:UJ(h,!1,o,e,4e3,g)})}m.set(e,v)}for(let t of e.textNodes){let e=t.label??t.id;m.get(L2(t.sets))?.lines.push({id:t.id,raw:e,size:a,base:0,label:UJ(e,!1,o,a,4e3)})}let h=0;for(let e of c)e.r>h&&(h=e.r);let g=h>0?bMt/h:1,_=1;for(let e of m.values()){if(e.spot.margin<=0)continue;let t=0,n=0;for(let r of e.lines)t=Math.max(t,r.label.width),n+=r.label.height;let r=Math.hypot(t,n)/2+4;_=Math.max(_,Math.min(r/(e.spot.margin*g),xMt))}g*=_;for(let e of m.values()){let t=Math.max(e.spot.margin*g*1.8,72);for(let n of e.lines)n.label.width>t&&(n.label=UJ(n.raw,!1,o,n.size,t,n.base))}let v=1/0,y=1/0,b=-1/0,x=-1/0;for(let e of c)v=Math.min(v,(e.x-e.r)*g),y=Math.min(y,(e.y-e.r)*g),b=Math.max(b,(e.x+e.r)*g),x=Math.max(x,(e.y+e.r)*g);for(let e of m.values()){let t=0,n=0;for(let r of e.lines)t=Math.max(t,r.label.width),n+=r.label.height;v=Math.min(v,e.spot.x*g-t/2),b=Math.max(b,e.spot.x*g+t/2),y=Math.min(y,e.spot.y*g-n/2),x=Math.max(x,e.spot.y*g+n/2)}c.length===0&&(v=y=b=x=0);let S=UJ(e.title&&N2(e.title),!1,o,r,4e3,1),C=S.height>0?S.height+12:0,w=Math.max(b-v,S.width),T=s+(w-(b-v))/2-v,E=s+C-y,D=Math.ceil(w+2*s),O=Math.ceil(x-y+C+2*s),k=c.map(e=>({id:e.id,x:e.x*g+T,y:e.y*g+E,r:e.r*g})),A=``;k.forEach((e,t)=>{let n=hJ(t),r=m.get(e.id)?.style??SMt;A+=`<circle class="pele-venn-set" data-id="${mq(e.id)}" cx="${K(e.x)}" cy="${K(e.y)}" r="${K(e.r)}" fill="${n}" fill-opacity="0.2" stroke="${n}"${r.shape}/>`});let j=``,M=``;for(let e of m.values()){let t=mq(e.sets.join(`|`));if(e.sets.length>1&&e.style.shape!==``){let n=yMt(e.inside.map(e=>k[e]),K);n!==``&&(j+=`<path class="pele-venn-overlap" data-id="${t}" d="${n}" fill="none"${e.style.shape}/>`)}let n=0;for(let t of e.lines)n+=t.label.height;if(n===0)continue;let i=e.spot.x*g+T,o=e.spot.y*g+E-n/2,s=``;for(let t of e.lines){let n=t.id===void 0?` class="pele-label"${t.size===r?``:` font-size="${t.size}"`}${e.style.text}`:` class="pele-venn-text" data-id="${mq(t.id)}" font-size="${a}" fill="var(--_m)"${d(t.id).text}`;s+=gq(t.label,i,o+t.label.height/2,n),o+=t.label.height}M+=`<g class="pele-venn-region" data-id="${t}">${s}</g>`}return{svg:_J(`venn`,D,O,r,n,{},gq(S,D/2,s+S.height/2,` class="pele-title" font-weight="var(--_tw)"`)+`<g class="pele-venn-sets">${A}</g>`+(j?`<g class="pele-venn-overlaps">${j}</g>`:``)+(M?`<g class="pele-venn-labels">${M}</g>`:``)),width:D,height:O,links:[]}}var wMt={type:`venn`,parse(e,t,n){let r=new sMt;return n&&(r.title=n),pMt(e,r),r},render:CMt},TMt=class{nodes=/* @__PURE__ */ new Map;labels;links=[];trends=/* @__PURE__ */ new Map;pipelines=/* @__PURE__ */ new Map;annotations=[];notes=[];accelerators=[];deaccelerators=[];annotationsBox;axes={};size;addNode(e){let t=this.nodes.get(e.id)??{id:e.id,label:e.label};this.nodes.set(e.id,{...t,...e,className:e.className??t.className,labelOffsetX:e.labelOffsetX??t.labelOffsetX,labelOffsetY:e.labelOffsetY??t.labelOffsetY}),this.labels=void 0}addLink(e){this.links.push(e)}addTrend(e){this.trends.set(e.nodeId,e)}startPipeline(e){this.pipelines.set(e,{nodeId:e,componentIds:[]});let t=this.nodes.get(e);t&&(t.isPipelineParent=!0)}addPipelineComponent(e,t){this.pipelines.get(e)?.componentIds.push(t);let n=this.nodes.get(t);n&&(n.inPipeline=!0)}addAnnotation(e){this.annotations.push(e)}addNote(e){this.notes.push(e)}addAccelerator(e){this.accelerators.push(e)}addDeaccelerator(e){this.deaccelerators.push(e)}setAnnotationsBox(e,t){this.annotationsBox={x:e,y:t}}setAxes(e){this.axes={...this.axes,...e}}setSize(e,t){this.size={width:e,height:t}}getNode(e){return this.nodes.get(e)}resolveNodeId(e){if(this.nodes.has(e))return e;if(!this.labels){this.labels=/* @__PURE__ */ new Map;for(let[e,t]of this.nodes)this.labels.has(t.label)||this.labels.set(t.label,e)}return this.labels.get(e)??e}build(){let e=[];for(let t of this.nodes.values()){if(typeof t.x!=`number`||typeof t.y!=`number`)throw new NK(`Node "${t.label}" is missing coordinates`,`semantic`,{type:`wardley`});e.push(t)}return{nodes:e,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 R2(e,t){let n=e<=1?e*100:e;if(n<0||n>100)throw new NK(`${t} must be between 0-1 (decimal) or 0-100 (percentage). Received: ${e}`,`semantic`,{type:`wardley`});return n}function z2(e,t,n){return{x:R2(t,`${n} evolution`),y:R2(e,`${n} visibility`)}}function EMt(e){return e===`+<>`?`bidirectional`:e===`+<`?`backward`:e===`+>`?`forward`:void 0}function DMt(e){if(!e?.startsWith(`+`))return{};let t=e.indexOf(`'`,2),n=e[1]===`'`&&t!==-1?e.slice(2,t):void 0;return e.includes(`<>`)?{flow:`bidirectional`,label:n}:e.includes(`<`)?{flow:`backward`,label:n}:e.includes(`>`)?{flow:`forward`,label:n}:{label:n}}function OMt(e){return e?[(e.negX?-1:1)*e.offsetX,(e.negY?-1:1)*e.offsetY]:[void 0,void 0]}function kMt(e,t){e.size&&t.setSize(e.size.width,e.size.height),e.evolution&&t.setAxes({stages:e.evolution.stages.map(e=>e.secondName?`${e.name.trim()} / ${e.secondName.trim()}`:e.name.trim()),stageBoundaries:e.evolution.stages.filter(e=>e.boundary!==void 0).map(e=>e.boundary)});for(let n of e.anchors){let e=z2(n.visibility,n.evolution,`Anchor "${n.name}"`);t.addNode({id:n.name,label:n.name,x:e.x,y:e.y,className:`anchor`})}for(let n of e.components){let e=z2(n.visibility,n.evolution,`Component "${n.name}"`),[r,i]=OMt(n.label);t.addNode({id:n.name,label:n.name,x:e.x,y:e.y,className:`component`,labelOffsetX:r,labelOffsetY:i,inertia:n.inertia,sourceStrategy:n.decorator?.strategy})}for(let n of e.notes){let e=z2(n.visibility,n.evolution,`Note "${n.text}"`);t.addNote({text:n.text,x:e.x,y:e.y})}for(let n of e.pipelines){let e=t.getNode(n.parent);if(!e||typeof e.y!=`number`)throw new NK(`Pipeline "${n.parent}" must reference an existing component with coordinates.`,`semantic`,{type:`wardley`});let r=e.y;t.startPipeline(n.parent);for(let e of n.components){let i=`${n.parent}_${e.name}`,[a,o]=OMt(e.label),s=R2(e.evolution,`Pipeline component "${e.name}" evolution`);t.addNode({id:i,label:e.name,x:s,y:r,className:`pipeline-component`,labelOffsetX:a,labelOffsetY:o,inertia:void 0,sourceStrategy:void 0}),t.addPipelineComponent(n.parent,i)}}for(let n of e.links){let e=!!n.arrow&&(n.arrow.includes(`-.->`)||n.arrow.includes(`.-.`)),r=DMt(n.arrow),i=EMt(n.fromPort)??EMt(n.toPort)??r.flow;t.addLink({source:t.resolveNodeId(n.from),target:t.resolveNodeId(n.to),dashed:e,label:r.label??n.linkLabel,flow:i})}for(let n of e.evolves){let e=t.getNode(n.component);e?.y!==void 0&&t.addTrend({nodeId:n.component,targetX:R2(n.target,`Evolve target for "${n.component}"`),targetY:e.y})}if(e.annotations.length>0){let n=z2(e.annotations[0].x,e.annotations[0].y,`Annotations box`);t.setAnnotationsBox(n.x,n.y)}for(let n of e.annotation){let e=z2(n.x,n.y,`Annotation ${n.number}`);t.addAnnotation({number:n.number,coordinates:[{x:e.x,y:e.y}],text:n.text})}for(let n of e.accelerators){let e=z2(n.x,n.y,`Accelerator "${n.name}"`);t.addAccelerator({name:n.name,x:e.x,y:e.y})}for(let n of e.deaccelerators){let e=z2(n.x,n.y,`Deaccelerator "${n.name}"`);t.addDeaccelerator({name:n.name,x:e.x,y:e.y})}}function AMt(e,t){let n=new TMt;return kMt(e,n),{type:`wardley`,title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,``):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
|
|
1073
|
+
`):void 0,...n.build()}}function jMt(e,t){let n=t;for(let t=e.charCodeAt(n);t>=48&&t<=57;t=e.charCodeAt(n))n++;return n}function MMt(){let e=0,t=0;return(n,r)=>{if((r<e||r>=t)&&(e=r,t=jMt(n,r)),t===r||n.charCodeAt(t)!==46)return-1;let i=jMt(n,t+1);return i>t+1?i:-1}}var NMt={name:`ARROW`,pattern:/->/y,first:`-`},PMt={name:`LINK_ARROW`,pattern:/-->|-\.->|>|\+'[^']*'<>|\+'[^']*'<|\+'[^']*'>/y,first:`->+`},B2=(e,t)=>({name:e,pattern:new RegExp(t,`y`),first:t[0]}),FMt=[{name:`[`,pattern:`[`},{name:`,`,pattern:`,`},{name:`]`,pattern:`]`},{name:`@`,pattern:`@`},{name:`/`,pattern:`/`},{name:`(`,pattern:`(`},{name:`)`,pattern:`)`},{name:`-`,pattern:`-`,longer:[NMt,PMt,dY]},{name:`{`,pattern:`{`},{name:`}`,pattern:`}`},{name:`WARDLEY_NUMBER`,pattern:/[0-9]+\.[0-9]+/y,first:`0123456789`,scanner:MMt},NMt,{name:`LINK_PORT`,pattern:/\+<>|\+>|\+</y,first:`+`},PMt,{name:`LINK_LABEL`,pattern:/;[^\n\r]+/y,first:`;`},{name:`STRATEGY`,pattern:/build|buy|outsource|market/y,first:`bom`},B2(`KW_WARDLEY`,`wardley-beta`),B2(`KW_SIZE`,`size`),B2(`KW_EVOLUTION`,`evolution`),B2(`KW_ANCHOR`,`anchor`),B2(`KW_COMPONENT`,`component`),B2(`KW_LABEL`,`label`),B2(`KW_INERTIA`,`inertia`),B2(`KW_EVOLVE`,`evolve`),B2(`KW_PIPELINE`,`pipeline`),B2(`KW_NOTE`,`note`),B2(`KW_ANNOTATIONS`,`annotations`),B2(`KW_ANNOTATION`,`annotation`),B2(`KW_ACCELERATOR`,`accelerator`),B2(`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:` `},gZ(),oY,sY,{name:`INT`,pattern:/0|[1-9][0-9]*(?!\.)/y,first:`0123456789`},cY,{name:`ID`,pattern:/[\w]([-\w]*\w)?/y,first:`_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`},lY,uY,dY,fY,pY];function IMt(e){let t=new bY(iY(e,FMt,`wardley`),FMt,`wardley`),n={$type:`Wardley`,anchors:[],components:[],links:[],evolves:[],pipelines:[],notes:[],annotations:[],annotation:[],accelerators:[],deaccelerators:[]},r=e=>t.kinds[t.i]===e,i=()=>r(36)||r(37)||r(30),a=()=>r(36)?yY(t.take()):r(37)||r(30)?t.take():t.fail(`a name`),o=()=>Number(t.expect(10)),s=()=>parseInt(t.expect(35)),c=()=>r(10)?Number(t.take()):parseInt(t.expect(35)),l=()=>{if(!r(-1))for(r(38)||t.fail(`a line break or the end of input`);r(38);)t.i++},u=e=>{t.expect(0);let n=e();t.expect(1);let r=e();return t.expect(2),[n,r]},d=()=>{t.expect(21),t.expect(0);let e=t.accept(7),n=s();t.expect(1);let r=t.accept(7),i=s();return t.expect(2),{$type:`Label`,negX:e,offsetX:n,negY:r,offsetY:i}},f=()=>{let e={$type:`EvolutionStage`,name:a()};return t.accept(3)&&(e.boundary=o()),t.accept(4)&&(e.secondName=a()),e};for(;r(38);)t.i++;for(t.expect(16);!r(-1);)switch(t.kind){case 38:t.i++;break;case 32:n.accDescr=vY(t.take()),l();break;case 33:n.accTitle=_Y(t.take()),l();break;case 34:n.title=gY(t.take()),l();break;case 17:{t.i++;let[e,r]=u(s);l(),n.size={$type:`Size`,width:e,height:r};break}case 18:{t.i++;let e=[f()];for(t.expect(11),e.push(f());t.accept(11);)e.push(f());l(),n.evolution={$type:`Evolution`,stages:e};break}case 19:{t.i++;let e=a(),[r,i]=u(o);l(),n.anchors.push({$type:`Anchor`,name:e,visibility:r,evolution:i});break}case 20:{t.i++;let e={$type:`Component`,name:a(),visibility:0,evolution:0,inertia:!1};[e.visibility,e.evolution]=u(o),r(21)&&(e.label=d()),r(5)&&t.kinds[t.i+1]===15&&(t.i++,e.decorator={$type:`Decorator`,strategy:t.take()},t.expect(6)),t.accept(22)?e.inertia=!0:t.accept(5)&&(t.expect(22),t.expect(6),e.inertia=!0),l(),n.components.push(e);break}case 23:{t.i++;let e=a(),r=o();l(),n.evolves.push({$type:`Evolve`,component:e,target:r});break}case 24:{t.i++;let e=a();for(t.expect(8),t.expect(38);r(38);)t.i++;let i=[];do{t.expect(20);let e={$type:`PipelineComponent`,name:a(),evolution:0};t.expect(0),e.evolution=o(),t.expect(2),r(21)&&(e.label=d()),l(),i.push(e)}while(r(20));t.expect(9),l(),n.pipelines.push({$type:`Pipeline`,parent:e,components:i});break}case 25:{t.i++;let e=yY(t.expect(36)),[r,i]=u(o);l(),n.notes.push({$type:`Note`,text:e,visibility:r,evolution:i});break}case 26:{t.i++;let[e,r]=u(c);l(),n.annotations.push({$type:`Annotations`,x:e,y:r});break}case 27:{t.i++;let e=s();t.expect(1);let[r,i]=u(c),a=yY(t.expect(36));l(),n.annotation.push({$type:`Annotation`,number:e,x:r,y:i,text:a});break}case 28:case 29:{let e=t.kind===29;t.i++;let r=a(),[i,s]=u(o);l(),e?n.deaccelerators.push({$type:`Deaccelerator`,name:r,x:i,y:s}):n.accelerators.push({$type:`Accelerator`,name:r,x:i,y:s});break}default:{i()||t.fail(`a statement`);let e={$type:`Link`,from:a(),to:``};r(12)&&(e.fromPort=t.take()),(r(13)||r(11))&&(e.arrow=t.take()),e.to=a(),r(12)&&(e.toPort=t.take()),r(14)&&(e.linkLabel=t.take().substring(1).trim()),l(),n.links.push(e)}}return n}var LMt=[`Genesis`,`Custom Built`,`Product`,`Commodity`],RMt=48,V2=6,H2=10,zMt=8,U2=15,W2=60,BMt=30,VMt=20,G2=`var(--_c)`,K2=`var(--_l)`;function HMt(e,t,n,r,i){let a=e[`wardley-beta`]?.[t];return typeof a==`number`&&a>=r&&a<=i?a:n}function q2(e,t,n){return e<t?t:e>n?n:e}function UMt(e,t,n,r){let i=vq(e),a=``,o=n;for(let n of e.lines){let r=!0;for(let e of n){if(e.icon!==void 0)continue;let n=_q(e.style&~i);a+=`<tspan${r?` x="${K(t)}" y="${K(o)}"`:``}${n}>${pq(e.text)}</tspan>`,r=!1}o+=e.lineHeight}return a===``?``:`<text${yq(r,i)} xml:space="preserve">${a}</text>`}function WMt(e,t,n,r){return q2(typeof t==`number`&&Number.isFinite(t)?t:HMt(e,n,r,1,1e6),200,1e4)-2*RMt}function GMt(e,t,n){let r=WMt(t,e.size?.width,`width`,900);return WJ(n,r,160,(i,a)=>KMt(e,t,n,i,r,a))}function KMt(e,t,n,r,i,a){let o=n.fontSize??16,s=Math.round(o*.8125),c=Math.round(o*.6875),l=n.measurer??fq(n.fontFamily),u=n.padding??8,d=WMt(t,e.size?.height,`height`,600)*Math.max(.75,r/i),f=t[`wardley-beta`]?.showGrid===!0,p=0,m=0,h=r,g=d,_=(e,t,n,r)=>{e<p&&(p=e),t<m&&(m=t),n>h&&(h=n),r>g&&(g=r)},v=(e,t,r,i)=>(_(t-e.width/2,r-e.height/2,t+e.width/2,r+e.height/2),gq(e,t,r,i,n.icons)),y=(e,t,n,r)=>(_(t,n-e.size,t+e.width,n-e.size+e.height+4),UMt(e,t,n,r)),b=(e,t,n=a?Math.max(64,Math.min(120,r/2)):4e3,i=0)=>UJ(e,!1,l,t,n,i),x=e=>e/100*r,S=e=>d-e/100*d,C=e.axes.stages&&e.axes.stages.length>0?e.axes.stages:LMt,w=e.axes.stageBoundaries,T=w!==void 0&&w.length===C.length,E=``,D=``,O=d,k=0;if(C.forEach((e,t)=>{let n=T?k:t/C.length,i=T?q2(w[t],0,1):(t+1)/C.length;k=i,t>0&&(E+=`<path class="pele-wardley-stage" d="M${K(n*r)},0V${K(d)}" stroke="var(--_b)" stroke-dasharray="4 4"/>`);let a=b(e,s,Math.max(48,Math.abs(i-n)*r-12));D+=v(a,(n+i)/2*r,d+8+a.height/2,` class="pele-wardley-stage-label" font-size="${s}" fill="var(--_m)"`),O=Math.max(O,d+8+a.height)}),f)for(let e=1;e<4;e++)E+=`<path class="pele-wardley-grid" d="M${K(r*e/4)},0V${K(d)}M0,${K(d*e/4)}H${K(r)}" stroke="var(--_b)" stroke-dasharray="2 6"/>`;E+=`<path class="pele-wardley-axis" d="M0,0V${K(d)}H${K(r)}" stroke="${K2}"/>`;let A=b(e.axes.xLabel??`Evolution`,s),j=b(e.axes.yLabel??`Visibility`,s),M=` class="pele-wardley-axis-label" font-size="${s}" font-weight="var(--_hw)"`,N=v(A,r/2,O+6+A.height/2,M)+gq(j,-16,d/2,`${M} transform="rotate(-90 -16 ${K(d/2)})"`);_(-16-j.height/2,0,0,0);let P=O+6+A.height+10,F=/* @__PURE__ */ new Map;for(let t of e.nodes)F.set(t.id,{x:x(t.x),y:S(t.y),node:t});let ee=``,te=/* @__PURE__ */ new Map;for(let t of e.pipelines){te.set(t.nodeId,new Set(t.componentIds));let e=[];for(let n of t.componentIds){let t=F.get(n);t&&e.push(t)}if(e.length===0)continue;e.sort((e,t)=>e.x-t.x);let n=e[0].x,r=e[e.length-1].x,i=e[0].y,a=i-2*V2,o=F.get(t.nodeId);o&&(o.x=(n+r)/2,o.y=a-H2/6),_(n-U2,a,r+U2,a+4*V2),ee+=`<g class="pele-wardley-pipeline" data-id="${mq(t.nodeId)}"><rect x="${K(n-U2)}" y="${K(a)}" width="${K(r-n+2*U2)}" height="${K(4*V2)}" rx="${dJ}" fill="var(--_s)" stroke="var(--_b)"/>`+(e.length>1?`<path d="M${K(n)},${K(i)}H${K(r)}" stroke="${K2}" stroke-dasharray="4 4"/>`:``)+`</g>`}let I=/* @__PURE__ */ new Map,ne=(e,t,n)=>{let i=e.node;if(i.className===`anchor`){let e=I.get(i);return e||I.set(i,e=b(i.label,s,a?Math.max(64,r/2):4e3,1)),1/Math.hypot(t/(e.width/2+5),n/(s*.8))}return i.isPipelineParent?H2/Math.SQRT2:i.sourceStrategy?2*V2:V2},re=/* @__PURE__ */ new Map,ie=(e,t,n)=>{Math.abs(t)<.25||Math.abs(n)<.25||re.set(e,(re.get(e)??0)|(t>0?n<0?1:2:n<0?4:8))},ae=``;for(let t of e.links){let e=F.get(t.source),n=F.get(t.target);if(!e||!n||e===n||te.get(t.target)?.has(t.source))continue;let r=n.x-e.x,i=n.y-e.y,a=Math.hypot(r,i);if(a<.01)continue;let o=r/a,s=i/a,l=ne(e,o,s),u=ne(n,o,s);if(l+u>=a)continue;ie(e,o,s),ie(n,-o,-s);let d=e.x+o*l,f=e.y+s*l,p=n.x-o*u,m=n.y-s*u,h=``;(t.flow===`forward`||t.flow===`bidirectional`)&&(h+=cJ(`arrow_point`,p,m,o,s,K2),p-=o*sJ(`arrow_point`),m-=s*sJ(`arrow_point`)),(t.flow===`backward`||t.flow===`bidirectional`)&&(h+=cJ(`arrow_point`,d,f,-o,-s,K2),d+=o*sJ(`arrow_point`),f+=s*sJ(`arrow_point`));let g=``;if(t.label){let r=b(t.label,c+1,200),i=o>=0?1:-1,a=s*i,l=-o*i,u=5+Math.abs(a)*r.width/2+Math.abs(l)*r.height/2;g=v(r,(e.x+n.x)/2+a*u,(e.y+n.y)/2+l*u,` class="pele-edge-label" font-size="${c+1}" fill="var(--_m)"`)}ae+=`<g class="pele-edge${t.dashed?` pele-wardley-dashed`:``}" data-id="${mq(t.source)}-${mq(t.target)}"><path d="M${K(d)},${K(f)}L${K(p)},${K(m)}" stroke="${K2}"${t.dashed?` stroke-dasharray="6 6"`:``}/>`+h+g+`</g>`}let L=``;for(let t of e.trends){let e=F.get(t.nodeId);if(!e)continue;let n=x(t.targetX),r=S(t.targetY),i=n-e.x,a=r-e.y,o=Math.hypot(i,a),s=``,c=o>0?ne(e,i/o,a/o):0;if(o>c+V2+4){let t=i/o,l=a/o,u=n-t*(V2+2),d=r-l*(V2+2);s=`<path d="M${K(e.x+t*c)},${K(e.y+l*c)}L${K(u-t*sJ(`arrow_point`))},${K(d-l*sJ(`arrow_point`))}" stroke="${G2}" stroke-dasharray="4 4"/>`+cJ(`arrow_point`,u,d,t,l,G2)}_(n-V2,r-V2,n+V2,r+V2),L+=`<g class="pele-wardley-trend" data-id="${mq(t.nodeId)}">${s}<circle cx="${K(n)}" cy="${K(r)}" r="${V2}" fill="var(--_bg)" stroke="${G2}"/></g>`}let oe=``,se=1.2*V2,ce=.7*V2;for(let e of F.values()){let t=e.node,{x:n,y:i}=e,o=t.className===`anchor`,c=t.sourceStrategy,l=``;if(c){let e=c===`outsource`?`var(--_m)`:c===`buy`?`var(--_a)`:c===`build`?`var(--_s)`:`var(--_bg)`;l+=`<circle class="pele-wardley-${c}" cx="${K(n)}" cy="${K(i)}" r="${2*V2}" fill="${e}" stroke="${K2}"/>`}if(c===`market`){let e=se*Math.cos(Math.PI/6),t=i+se*Math.sin(Math.PI/6);l+=`<path d="M${K(n)},${K(i-se)}L${K(n-e)},${K(t)}H${K(n+e)}Z" fill="none" stroke="${K2}"/>`;for(let[r,a]of[[n,i-se],[n-e,t],[n+e,t]])l+=`<circle cx="${K(r)}" cy="${K(a)}" r="${K(ce)}" fill="var(--_bg)" stroke="${K2}"/>`}else t.isPipelineParent?l+=`<rect x="${K(n-H2/2)}" y="${K(i-H2/2)}" width="${H2}" height="${H2}" fill="var(--_bg)" stroke="${K2}"/>`:o||(l+=`<circle cx="${K(n)}" cy="${K(i)}" r="${V2}" fill="var(--_bg)" stroke="${K2}"/>`);if(t.inertia===!0){let e=(t.isPipelineParent?H2/2:V2)+10+(c?V2+4:0);l+=`<rect class="pele-wardley-inertia" x="${K(n+e)}" y="${K(i-V2)}" width="4" height="${2*V2}" fill="${K2}"/>`}let u=t.labelOffsetX===void 0?void 0:q2(t.labelOffsetX,-5e3,5e3),d=t.labelOffsetY===void 0?void 0:q2(t.labelOffsetY,-5e3,5e3),f;if(o)f=v(I.get(t)??b(t.label,s,a?Math.max(64,r/2):4e3,1),n+(u??0),i+(d??-3),` class="pele-label" font-size="${s}" font-weight="var(--_hw)"`);else{let r=b(t.label,s),a=` class="pele-label" font-size="${s}"`,o=zMt+(c?10:0);if(u!==void 0||d!==void 0)f=y(r,n+(u??o),i+(d??-o),a);else if(t.inPipeline)f=v(r,n,i+2*V2+4+r.height/2,a);else{let t=re.get(e)??0,c=t&1?t&2?t&4?t&8?1:8:4:2:1,l=c===1||c===2,u=c===1||c===4;f=y(r,l?n+o:n-o-r.width,u?i-o:i+o+s*.75,a)}}_(n-2*V2,i-2*V2,n+2*V2+20,i+2*V2),oe+=`<g class="pele-node pele-wardley-${o?`anchor`:t.isPipelineParent?`pipeline-parent`:t.inPipeline?`pipeline-component`:`component`}" data-id="${mq(t.id)}">${l}${f}</g>`}let le=``;for(let t of e.annotations){let e=b(String(t.number),c,4e3,1),n=``;for(let r of t.coordinates){let t=x(r.x),i=S(r.y),a=Math.max(10,e.width/2+4);_(t-a,i-a,t+a,i+a),n+=`<circle cx="${K(t)}" cy="${K(i)}" r="${K(a)}" fill="var(--_bg)" stroke="${K2}"/>`+gq(e,t,i,` font-size="${c}" font-weight="var(--_hw)"`)}le+=`<g class="pele-wardley-annotation" data-id="${mq(String(t.number))}">${n}</g>`}let ue=e.annotations.filter(e=>e.text).sort((e,t)=>e.number-t.number);if(ue.length>0){let t=ue.map(e=>b(`${e.number}. ${e.text}`,s,a?Math.max(80,r-20):320)),n=0,i=0;for(let e of t)n=Math.max(n,e.width),i+=e.height;n+=20,i+=14;let o=e.annotationsBox,c=o?q2(x(o.x),0,Math.max(0,r-n)):0,l=o?q2(S(o.y),0,Math.max(0,d-i)):P;_(c,l,c+n,l+i);let u=``,f=l+7;for(let e of t)u+=UMt(e,c+10,f+e.lineHeight/2+s*.35,` font-size="${s}"`),f+=e.height;le+=`<g class="pele-wardley-annotations"><rect x="${K(c)}" y="${K(l)}" width="${K(n)}" height="${K(i)}" rx="${dJ}" fill="var(--_bg)" stroke="var(--_b)"/>${u}</g>`}let de=``;for(let t of e.notes)de+=y(b(t.text,s,Math.min(360,r*.6),1),x(t.x),S(t.y),` class="pele-wardley-note" font-size="${s}" font-weight="var(--_hw)"`);let fe=``,pe=(e,t,n,r)=>{let i=x(t),a=S(n),o=BMt/2,s=r?i+W2:i,l=r?i:i+W2,u=r?i+W2-VMt:i+VMt,d=`M${K(l)},${K(a-o)}H${K(u)}V${K(a-o-8)}L${K(s)},${K(a)}L${K(u)},${K(a+o+8)}V${K(a+o)}H${K(l)}Z`;_(i,a-o-8,i+W2,a+o+8),fe+=`<g class="pele-wardley-${r?`accelerator`:`deaccelerator`}" data-id="${mq(e)}"><path d="${d}" fill="var(--_s)" stroke="${K2}"/>`+v(b(e,c+1,160,1),i+W2/2,a+o+8+12,` font-size="${c+1}" font-weight="var(--_hw)"`)+`</g>`};for(let t of e.accelerators)pe(t.name,t.x,t.y,!0);for(let t of e.deaccelerators)pe(t.name,t.x,t.y,!1);let me=UJ(e.title,!1,l,o,a?Math.max(80,r):4e3,1),he=me.height>0?me.height+12:0,ge=Math.min(p,r/2-me.width/2),_e=Math.max(h,r/2+me.width/2),ve=u-ge,ye=u+he-m,be=Math.ceil(_e-ge+2*u),xe=Math.ceil(g-m+he+2*u);return{svg:_J(`wardley`,be,xe,o,n,e,gq(me,ve+r/2,u+me.height/2,` class="pele-title" font-weight="var(--_tw)"`)+`<g transform="translate(${K(ve)},${K(ye)})"><g class="pele-wardley-frame" fill="none">${E}</g>`+D+N+ee+(ae?`<g class="pele-edges" fill="none">${ae}</g>`:``)+(L?`<g class="pele-wardley-trends" fill="none">${L}</g>`:``)+oe+le+de+fe+`</g>`),width:be,height:xe,links:[]}}var qMt={type:`wardley`,section:`wardley-beta`,parse:(e,t,n)=>AMt(IMt(e),n),render:GMt},JMt=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(e){this.orientation=e===`horizontal`?`horizontal`:`vertical`}setXAxisTitle(e){this.xAxis.title=e.text.trim()}setXAxisRangeData(e,t){this.xAxis={type:`linear`,title:this.xAxis.title,min:e,max:t},this.hasSetXAxis=!0}setXAxisBand(e){this.xAxis={type:`band`,title:this.xAxis.title,categories:e.map(e=>e.text.trim())},this.hasSetXAxis=!0}setYAxisTitle(e){this.yAxis.title=e.text.trim()}setYAxisRangeData(e,t){this.yAxis={type:`linear`,title:this.yAxis.title,min:e,max:t},this.hasSetYAxis=!0}plotData(e){if(e.length===0)return[];this.hasSetXAxis||this.setXAxisRangeData(1,e.length);let t=this.xAxis;if(t.type===`band`&&e.length>t.categories.length&&(e=e.slice(0,t.categories.length)),!this.hasSetYAxis){let{min:t,max:n}=this.yAxis;for(let r of e)r<t&&(t=r),r>n&&(n=r);this.yAxis={type:`linear`,title:this.yAxis.title,min:t,max:n}}if(t.type===`band`)return t.categories.map((t,n)=>[t,e[n]]);if(e.length===1)return[[`${t.min}`,e[0]]];let n=(t.max-t.min)/(e.length-1);return e.map((e,r)=>[`${t.min+r*n}`,e])}addPlot(e,t,n){let r={type:e,title:t.text.trim(),data:this.plotData(n.map(e=>e.value))};e===`line`&&n.some(e=>e.label.trim()!==``)&&(r.pointLabels=n.map(e=>e.label.trim())),this.plots.push(r)}setLineData(e,t){this.addPlot(`line`,e,t)}setBarData(e,t){this.addPlot(`bar`,e,t)}setDiagramTitle(e){this.title=e}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,``)}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
1074
1074
|
`)}},YMt=/* @__PURE__ */ `$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`.split(`.`),XMt=[33,33,33,33,33,19,5,7,8],ZMt="`)"+` `.repeat(36)+`{ this.pushstate(md_string); }
|
|
1075
1075
|
<md_string>(?:(?!\`").)+`+` `.repeat(18)+`{ return md_str; }
|
|
1076
1076
|
<md_string>(?:\``,J2=/* @__PURE__ */ new Uint8Array(128);for(let[e,t]of[[`:`,21],[`+`,22],[`,`,23],[`=`,24],[`*`,25],[`#`,26],[`_`,27],[`.`,28],[`&`,29],[`-`,30],[`;`,32]])J2[e.charCodeAt(0)]=t;function QMt(e){let t=e.length,n=[],r=[],i=[],a=[],o=0,s=0,c=(t,a,o)=>{n.push(t),r.push(e.slice(a,o)),i.push(a),s=o},l=e=>{a.push(o),o=e},u=()=>{a.length>0&&(o=a.pop())},d=n=>{let r=e.indexOf(`
|
|
1077
|
-
`,n);return r===-1?t:r},f=n=>{for(;n<t&&eq(e.charCodeAt(n));)n++;return n},p=t=>{for(;rq(e.charCodeAt(t));)t++;return t},m=t=>C$(e,s,t)&&!aq(e.charCodeAt(s+t.length));for(;s<t;){let n=e.charCodeAt(s);if(o===5){if(n===34)s++,u();else{let n=e.indexOf(`"`,s);c(19,s,n===-1?t:n)}continue}if(o===6||o===7){c(XMt[o],s,d(s)),u();continue}if(o===8){if(n===125)s++,u();else{let n=e.indexOf(`}`,s);c(8,s,n===-1?t:n)}continue}let r=e.charCodeAt(s+1);if(n===37&&r===37)s=d(s+2);else if(n!==125&&r===37&&e.charCodeAt(s+2)===37)s=d(s+3);else if(n===10||n===13){if((o===1||o===3)&&(n===10||r===10)){c(2,s,n===10?s+1:s+2),u();continue}let t=s+1;for(let n=e.charCodeAt(t);n===10||n===13;n=e.charCodeAt(++t));c(2,s,t)}else{switch(n|32){case 116:if(m(`title`)){c(3,s,s+5);continue}break;case 97:if(C$(e,s,`acc`)){let t=C$(e,s+3,`descr`);if(t||C$(e,s+3,`title`)){let n=f(s+8),r=e.charCodeAt(n);if(r===58){c(t?6:4,s,f(n+1)),l(t?7:6);continue}if(r===123&&t){s=f(n+1),l(8);continue}}}break;case 120:if(m(`xychart-beta`)){c(9,s,s+12);continue}if(m(`xychart`)){c(9,s,s+7);continue}if(m(`x-axis`)){c(11,s,s+6),l(1);continue}break;case 121:if(m(`y-axis`)){c(12,s,s+6),l(1);continue}break;case 118:if(C$(e,s,`vertical`)){c(10,s,s+8);continue}break;case 104:if(C$(e,s,`horizontal`)){c(10,s,s+10);continue}break;case 108:if(m(`line`)){c(14,s,s+4),l(3);continue}break;case 98:if(m(`bar`)){c(15,s,s+3),l(3);continue}}if(n===91)o===1?l(2):o===3&&l(4),c(17,s,s+1);else if(n===93)(o===4||o===2)&&u(),c(18,s,s+1);else if(o===1&&n===45&&r===45&&e.charCodeAt(s+2)===62)c(13,s,s+3);else{if(o===1||o===4){let t=n===43||n===45?s+1:s,r=e.charCodeAt(t),i=-1;if(rq(r)?(i=p(t+1),e.charCodeAt(i)===46&&rq(e.charCodeAt(i+1))&&(i=p(i+2))):r===46&&rq(e.charCodeAt(t+1))&&(i=p(t+2)),i!==-1){c(16,s,i);continue}}if(n===96&&C$(e,s,ZMt))s+=ZMt.length,u();else if(n===34)s++,l(5);else if(iq(n)){let t=s+1;for(;iq(e.charCodeAt(t));)t++;c(20,s,t)}else if(rq(n))c(31,s,p(s+1));else if(eq(n))s=f(s+1);else if(n<128&&J2[n]!==0)c(J2[n],s,s+1);else break}}}return s<t?(n.push(1),r.push(``),i.push(s),{types:n,texts:r,starts:i}):(n.push(XMt[o]),r.push(``),i.push(t),n.push(0),r.push(``),i.push(t),{types:n,texts:r,starts:i})}function $Mt(...e){let t=/* @__PURE__ */ new Uint8Array(34);for(let n of e)t[n]=1;return t}var eNt=$Mt(29,31,20,22,24,25,28,26,30,27),tNt=$Mt(2,32,33);function nNt(e,t){let{types:n,texts:r,starts:i}=QMt(e),a=0,o=t=>{let r=n[a];throw r===1?FK(`xychart`,e,i[a],``,!0):FK(`xychart`,e,i[a],`Expecting ${t}, got '${YMt[r]}'`)},s=e=>(n[a]!==e&&o(`'${YMt[e]}'`),r[a++]),c=e=>e===19||eNt[e]===1,l=()=>{c(n[a])||o(`'STR', 'ALPHA', 'NUM'`);let e=r[a++];if(n[a-1]!==19)for(;eNt[n[a]]===1;)e+=r[a++];return{text:e,type:`text`}},u=()=>{let e=Number(s(16));return s(13),[e,Number(s(16))]},d=()=>{let e=[];for(s(17);;){let t=Number(s(16));if(e.push({value:t,label:n[a]===19?r[a++]:``}),n[a]!==23)break;a++}return s(18),e};for(;;)if(tNt[n[a]]===1)a++;else{if(n[a]!==9)break;n[++a]===10&&t.setOrientation(r[a++])}for(;n[a]!==0;){let e=n[a++];switch(e){case 3:t.setDiagramTitle(l().text.trim());break;case 11:case 12:{let r=c(n[a])?l():void 0;if(e===11&&n[a]===17){let e=[];do a++,e.push(l());while(n[a]===23);s(18),t.setXAxisBand(e)}else if(n[a]===16||r===void 0){let[n,r]=u();e===11?t.setXAxisRangeData(n,r):t.setYAxisRangeData(n,r)}e===11?t.setXAxisTitle(r??{type:`text`,text:``}):t.setYAxisTitle(r??{type:`text`,text:``});break}case 14:case 15:{let r=n[a]===17?{text:``,type:`text`}:l(),i=d();e===14?t.setLineData(r,i):t.setBarData(r,i);break}case 4:t.setAccTitle(s(5).trim());break;case 6:t.setAccDescription(s(7).trim());break;case 8:t.setAccDescription(r[a-1].trim());break;default:a--,o(`'title', 'X_AXIS', 'Y_AXIS', 'LINE', 'BAR', 'acc_title', 'acc_descr', 'acc_descr_multiline_value'`)}for(;tNt[n[a]]===1;)a++}}function rNt(e,t){let n=e/Math.max(t,1),r=Math.floor(Math.log10(n)),i=n/10**r,a=i>=7.07?10:i>=3.16?5:i>=1.41?2:1;return r<0?-(10**-r)/a:a*10**r}function Y2(e,t){return e>0?t/e:t*-e}function X2(e,t){return e>0?t*e:t/-e}function iNt(e,t,n){let r=Math.round(Y2(n,e));X2(n,r)<e&&r++;let i=Math.round(Y2(n,t));X2(n,i)>t&&i--;let a=[];for(let e=r;e<=i&&a.length<100;e++)a.push(X2(n,e));return a}var aNt=4,Z2=12,oNt=26,sNt=24,cNt=1e300;function Q2(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function $2(e,t,n=!0){let r=e[t];return typeof r==`boolean`?r:n}function lNt(e,t){return typeof e==`number`&&e>0?Math.round(Math.min(Math.max(e,100),4e3)):t}function e4(e){return typeof e==`number`&&isFinite(e)?Math.min(Math.max(e,-cNt),cNt):void 0}function uNt(e){let t=0;for(let n of e)t=Math.max(t,n.label.width);return t}function t4(e,t,n,r){let i=e.lines.length===1?e.lines[0]:void 0;return i&&i.length===1&&i[0].icon===void 0&&i[0].style===0?`<text x="${K(t)}" y="${K(n+e.size*.35)}" text-anchor="${r}">${pq(i[0].text)}</text>`:gq(e,t+(r===`start`?e.width/2:r===`end`?-e.width/2:0),n,``)}function dNt(e,t,n){if(e.plots.length===0)throw new NK(`No Plot to render, please provide a plot with some data`,`semantic`,{type:`xychart`});let r=Q2(t.xyChart),i=n.fontSize??16,a=Math.round(i*.875),o=Math.round(i*.75),s=n.measurer??fq(n.fontFamily),c=n.padding??8,l=lNt(r.width,700),u=qJ(n,l,240),d=Math.round(lNt(r.height,500)*Math.max(.6,u/l)),f=(e.orientation??r.chartOrientation)===`horizontal`,p=$2(r,`showDataLabel`,!1),m=e.xAxis,h=e.plots,g=(e,t,n)=>WJ(e,!1,s,t,n),_=g(`0`,a,4e3).height,v=g(`0`,o,4e3).height,y=WJ($2(r,`showTitle`)?e.title:void 0,!1,s,i,u-2*c,1),b=y.height>0?y.height+12:0,x=[],S=0;$2(r,`showLegend`)&&h.forEach((e,t)=>{if(e.title===``)return;let n=g(e.title,a,u*.3);x.push({index:t,label:n}),S=Math.max(S,n.width+Z2+8)});let C=x.length>0?S+sNt:0,w=h.filter(e=>e.type===`bar`).length,T=e.yAxis.min,E=e.yAxis.max,D=e.hasSetYAxis&&isFinite(T)&&isFinite(E)&&T!==E;if(D)T=e4(T),E=e4(E);else{T=1/0,E=-1/0;for(let e of h)for(let[,t]of e.data){let e=e4(t);e!==void 0&&(e<T&&(T=e),e>E&&(E=e))}T>E&&(T=E=0),w>0&&(T=Math.min(T,0),E=Math.max(E,0)),T===E&&(T===0?E=1:(T-=Math.abs(T)/2,E+=Math.abs(E)/2))}let O=(e,t)=>{let n=rNt(Math.abs(E-T),Math.max(2,Math.min(10,Math.floor(e/t))));return D||(T=X2(n,Math.floor(Y2(n,T)+1e-9)),E=X2(n,Math.ceil(Y2(n,E)-1e-9))),iNt(Math.min(T,E),Math.max(T,E),n).map(e=>({at:(e-T)/(E-T),label:g(String(e),a,4e3)}))},k=1;if(m.type===`band`)k=Math.max(m.categories.length,1);else for(let e of h)k=Math.max(k,e.data.length);let A=1/k,j=m.type===`band`||w>0?A/2:0,M=e4(m.type===`linear`?m.min:void 0),N=e4(m.type===`linear`?m.max:void 0),P=M!==void 0&&N!==void 0&&M!==N,F=(e,t)=>m.type===`band`?(e+.5)*A:j+(t>1?e/(t-1):P?0:.5)*(1-2*j),ee=Q2(r.xAxis),te=Q2(r.yAxis),I=f?ee:te,ne=f?te:ee,re=g($2(I,`showTitle`)?f?m.title:e.yAxis.title:void 0,a,d*.8),ie=g($2(ne,`showTitle`)?f?e.yAxis.title:m.title:void 0,a,u*.8),ae=$2(I,`showTick`)?aNt:0,L=$2(ne,`showTick`)?aNt:0,oe=$2(I,`showLabel`),se=$2(ne,`showLabel`),ce=f?u*.3:Math.max(48,(u-2*c-64-C)*A-8),le=m.type===`band`&&$2(ee,`showLabel`)?m.categories.map(e=>g(e,a,ce)):[],ue=0,de=0;for(let e of le)ue=Math.max(ue,e.width),de=Math.max(de,e.height);let fe=e=>{let t=[];if(m.type===`band`){let n=le.length===0?8:f?de:ue+12,r=Math.max(1,Math.ceil(n/(e*A)));for(let e=0;e<m.categories.length;e+=r)t.push({at:(e+.5)*A,label:le[e]??g(void 0,a,0)})}else if(P){let n=rNt(Math.abs(N-M),Math.max(2,Math.min(10,Math.floor(e/(f?32:80)))));for(let e of iNt(Math.min(M,N),Math.max(M,N),n))t.push({at:j+(e-M)/(N-M)*(1-2*j),label:g(String(e),a,4e3)})}else M!==void 0&&t.push({at:.5,label:g(String(M),a,4e3)});return t},pe=0,me=0;for(let e of h){for(let t of e.pointLabels??[])pe=Math.max(pe,s.width(t,o,0));if(p&&f&&e.type===`bar`)for(let[,t]of e.data)me=Math.max(me,s.width(String(e4(t)??``),o,0))}let he=se?f||m.type!==`band`?_:de:0,ge=L+(he>0?he+4:0)+(ie.height>0?ie.height+4:0),_e=f?0:pe>0||p?v+4:oe?_/2:0,ve=c+b+_e,ye=Math.max(1,d-c-ge-ve),be=ve+ye,xe=f?fe(ye):O(ye,56),Se=oe?uNt(xe):0,Ce=c+(re.height>0?re.height+6:0)+(Se>0?Se+6:0)+ae,we=Math.max(pe>0?pe+12:0,me>0?me+8:0),Te=f?Math.min(u*.25,we):0,Ee=Math.max(1,u-c-Ce-C-Te),De=f?O(Ee,80):fe(Ee);if(se&&C+Te===0){let e=0;for(let t of De)e=Math.max(e,t.at*Ee+t.label.width/2-Ee);Ee=Math.max(1,Ee-e)}let Oe=Ce+Ee,ke=(e,t)=>f?Ce+t*Ee:Ce+e*Ee,Ae=(e,t)=>f?ve+e*ye:be-t*ye,je=e=>(e-T)/(E-T),Me=e=>Math.min(Math.max(e,0),1),Ne=e=>f?`M${K(ke(0,e))},${K(ve)}V${K(be)}`:`M${K(Ce)},${K(Ae(0,e))}H${K(Oe)}`,Pe=``;for(let e of f?De:xe)Pe+=Ne(e.at);let Fe=``,Ie=``;$2(I,`showAxisLine`)&&(Fe+=`M${K(Ce)},${K(ve)}V${K(be)}`),$2(ne,`showAxisLine`)&&(Fe+=`M${K(Ce)},${K(be)}H${K(Oe)}`);for(let e of xe){let t=f?ve+e.at*ye:be-e.at*ye;ae&&(Fe+=`M${K(Ce)},${K(t)}h${-ae}`),oe&&(Ie+=t4(e.label,Ce-ae-6,t,`end`))}for(let e of De){let t=Ce+e.at*Ee;L&&(Fe+=`M${K(t)},${K(be)}v${L}`),se&&(Ie+=t4(e.label,t,be+L+4+e.label.height/2,`middle`))}let Le=(f?ye:Ee)*A,Re=Le*.7/Math.max(w,1),ze=w>1?Math.min(2,Re*.2):0,Be=Me(je(0));w>0&&Be>0&&Be<1&&(Fe+=Ne(Be));let Ve=``,He=``,Ue=``,We=``,Ge=0;h.forEach((e,t)=>{let n=gJ(t),r=e.title?` data-id="${mq(e.title)}"`:``,i=m.type===`band`?Math.min(e.data.length,k):e.data.length;if(e.type===`bar`){let t=(Ge++-(w-1)/2)*Re-(Re-ze)/2,a=``;for(let n=0;n<i;n++){let r=e4(e.data[n][1]);if(r===void 0)continue;let c=F(n,i),l=Me(je(r)),u=Math.min(Be,l),d=Math.max(Be,l),m=f?ke(c,u):ke(c,0)+t,h=f?Ae(c,0)+t:Ae(c,d),g=f?(d-u)*Ee:Re-ze,_=f?Re-ze:(d-u)*ye;if(a+=`<rect x="${K(m)}" y="${K(h)}" width="${K(g)}" height="${K(_)}"/>`,!p)continue;let y=String(r),b=s.width(y,o,0),x=l>=Be?1:-1,S=m+g/2,C=h+_/2,T=`middle`;if(f){if(_<o)continue;S=(x>0?m+g:m)+x*6,T=x>0?`start`:`end`}else{if(b+2>Le/w)continue;C=(x>0?h:h+_)-x*(v/2+2)}Ue+=`<text x="${K(S)}" y="${K(C+o*.35)}" text-anchor="${T}">${y}</text>`}Ve+=`<g class="pele-series pele-bars"${r} fill="${n}">${a}</g>`;return}let a=``,c=``,l=!1,u=0,d=NaN;for(let t=0;t<i;t++){let n=e4(e.data[t][1]);if(n===void 0){d=NaN;continue}let r=F(t,i),s=je(n),p=s>=0&&s<=1;if(d!==d)p&&(a+=`M${K(ke(r,s))},${K(Ae(r,s))}`),l=p;else{let e=s-d,t=0,n=1;if(e!==0){let r=-d/e,i=(1-d)/e;t=Math.max(t,Math.min(r,i)),n=Math.min(n,Math.max(r,i))}else p||(t=2);if(t<=n){let i=u+(r-u)*t,o=d+e*t,s=u+(r-u)*n,c=d+e*n;(!l||t>0)&&(a+=`M${K(ke(i,o))},${K(Ae(i,o))}`),a+=`L${K(ke(s,c))},${K(Ae(s,c))}`}l=p}if(u=r,d=s,!p)continue;let m=ke(r,s),h=Ae(r,s);Le>=12&&(c+=`<circle cx="${K(m)}" cy="${K(h)}" r="3"/>`);let _=g(e.pointLabels?.[t],o,4e3);if(_.height>0){let e=_.width/2;We+=f?t4(_,m+10,h,`start`):t4(_,Math.max(Math.min(m,Oe-e),Ce+e),h-6-_.height/2,`middle`)}}He+=`<g class="pele-series pele-line"${r} fill="${n}">`+(a?`<path d="${a}" fill="none" stroke="${n}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>`:``)+c+`</g>`});let Ke=``;re.height>0&&(Ke+=`<g transform="translate(${K(c+re.height/2)},${K(ve+ye/2)}) rotate(-90)">${gq(re,0,0,``)}</g>`),Ke+=gq(ie,Ce+Ee/2,d-c-ie.height/2,``);let qe=``,Je=0;for(let e of x)Je+=Math.max(oNt,e.label.height+6);let Ye=ve+Math.max(0,(ye-Je)/2),Xe=Oe+Te+sNt;for(let{index:e,label:t}of x){let n=Math.max(oNt,t.height+6);if(Ye+n>d)break;let r=Ye+n/2,i=gJ(e);qe+=`<g class="pele-legend-item" data-id="${mq(h[e].title)}">`+(h[e].type===`bar`?`<rect x="${K(Xe)}" y="${K(r-Z2/2)}" width="${Z2}" height="${Z2}" rx="2" fill="${i}"/>`:`<path d="M${K(Xe)},${K(r)}h${Z2}" stroke="${i}" stroke-width="2" stroke-linecap="round"/>`)+gq(t,Xe+Z2+8+t.width/2,r,``)+`</g>`,Ye+=n}return{svg:vJ(`xychart`,u,d,i,n,e,gq(y,u/2,c+y.height/2,` class="pele-title" font-weight="var(--_tw)"`)+(Pe?`<path class="pele-grid" d="${Pe}" stroke="var(--_a)"/>`:``)+`<g class="pele-plot">${Ve}${He}</g>`+(Fe?`<path class="pele-axis" d="${Fe}" fill="none" stroke="var(--_b)"/>`:``)+(Ie?`<g class="pele-axis-labels" font-size="${a}" fill="var(--_m)">${Ie}</g>`:``)+(Ke?`<g class="pele-axis-titles" font-size="${a}">${Ke}</g>`:``)+(Ue?`<g class="pele-data-labels" font-size="${o}">${Ue}</g>`:``)+(We?`<g class="pele-point-labels" font-size="${o}">${We}</g>`:``)+(qe?`<g class="pele-legend" font-size="${a}">${qe}</g>`:``)),width:u,height:d,links:[]}}gpt(jxt,mTt,gbt,Xwt,Awt,Xkt,uwt,uyt,NTt,{type:`xychart`,section:`xyChart`,parse(e,t,n){let r=new JMt;return r.title=n,nNt(e,r),r},render:dNt},vkt,$St,Jgt,ODt,KDt,rTt,YTt,UAt,TCt,VOt,yCt,Mvt,B_t,XEt,vgt,AAt,jyt,qMt,Vbt,oMt,wMt,GCt,Ikt);
|
|
1077
|
+
`,n);return r===-1?t:r},f=n=>{for(;n<t&&eq(e.charCodeAt(n));)n++;return n},p=t=>{for(;rq(e.charCodeAt(t));)t++;return t},m=t=>C$(e,s,t)&&!aq(e.charCodeAt(s+t.length));for(;s<t;){let n=e.charCodeAt(s);if(o===5){if(n===34)s++,u();else{let n=e.indexOf(`"`,s);c(19,s,n===-1?t:n)}continue}if(o===6||o===7){c(XMt[o],s,d(s)),u();continue}if(o===8){if(n===125)s++,u();else{let n=e.indexOf(`}`,s);c(8,s,n===-1?t:n)}continue}let r=e.charCodeAt(s+1);if(n===37&&r===37)s=d(s+2);else if(n!==125&&r===37&&e.charCodeAt(s+2)===37)s=d(s+3);else if(n===10||n===13){if((o===1||o===3)&&(n===10||r===10)){c(2,s,n===10?s+1:s+2),u();continue}let t=s+1;for(let n=e.charCodeAt(t);n===10||n===13;n=e.charCodeAt(++t));c(2,s,t)}else{switch(n|32){case 116:if(m(`title`)){c(3,s,s+5);continue}break;case 97:if(C$(e,s,`acc`)){let t=C$(e,s+3,`descr`);if(t||C$(e,s+3,`title`)){let n=f(s+8),r=e.charCodeAt(n);if(r===58){c(t?6:4,s,f(n+1)),l(t?7:6);continue}if(r===123&&t){s=f(n+1),l(8);continue}}}break;case 120:if(m(`xychart-beta`)){c(9,s,s+12);continue}if(m(`xychart`)){c(9,s,s+7);continue}if(m(`x-axis`)){c(11,s,s+6),l(1);continue}break;case 121:if(m(`y-axis`)){c(12,s,s+6),l(1);continue}break;case 118:if(C$(e,s,`vertical`)){c(10,s,s+8);continue}break;case 104:if(C$(e,s,`horizontal`)){c(10,s,s+10);continue}break;case 108:if(m(`line`)){c(14,s,s+4),l(3);continue}break;case 98:if(m(`bar`)){c(15,s,s+3),l(3);continue}}if(n===91)o===1?l(2):o===3&&l(4),c(17,s,s+1);else if(n===93)(o===4||o===2)&&u(),c(18,s,s+1);else if(o===1&&n===45&&r===45&&e.charCodeAt(s+2)===62)c(13,s,s+3);else{if(o===1||o===4){let t=n===43||n===45?s+1:s,r=e.charCodeAt(t),i=-1;if(rq(r)?(i=p(t+1),e.charCodeAt(i)===46&&rq(e.charCodeAt(i+1))&&(i=p(i+2))):r===46&&rq(e.charCodeAt(t+1))&&(i=p(t+2)),i!==-1){c(16,s,i);continue}}if(n===96&&C$(e,s,ZMt))s+=ZMt.length,u();else if(n===34)s++,l(5);else if(iq(n)){let t=s+1;for(;iq(e.charCodeAt(t));)t++;c(20,s,t)}else if(rq(n))c(31,s,p(s+1));else if(eq(n))s=f(s+1);else if(n<128&&J2[n]!==0)c(J2[n],s,s+1);else break}}}return s<t?(n.push(1),r.push(``),i.push(s),{types:n,texts:r,starts:i}):(n.push(XMt[o]),r.push(``),i.push(t),n.push(0),r.push(``),i.push(t),{types:n,texts:r,starts:i})}function $Mt(...e){let t=/* @__PURE__ */ new Uint8Array(34);for(let n of e)t[n]=1;return t}var eNt=$Mt(29,31,20,22,24,25,28,26,30,27),tNt=$Mt(2,32,33);function nNt(e,t){let{types:n,texts:r,starts:i}=QMt(e),a=0,o=t=>{let r=n[a];throw r===1?FK(`xychart`,e,i[a],``,!0):FK(`xychart`,e,i[a],`Expecting ${t}, got '${YMt[r]}'`)},s=e=>(n[a]!==e&&o(`'${YMt[e]}'`),r[a++]),c=e=>e===19||eNt[e]===1,l=()=>{c(n[a])||o(`'STR', 'ALPHA', 'NUM'`);let e=r[a++];if(n[a-1]!==19)for(;eNt[n[a]]===1;)e+=r[a++];return{text:e,type:`text`}},u=()=>{let e=Number(s(16));return s(13),[e,Number(s(16))]},d=()=>{let e=[];for(s(17);;){let t=Number(s(16));if(e.push({value:t,label:n[a]===19?r[a++]:``}),n[a]!==23)break;a++}return s(18),e};for(;;)if(tNt[n[a]]===1)a++;else{if(n[a]!==9)break;n[++a]===10&&t.setOrientation(r[a++])}for(;n[a]!==0;){let e=n[a++];switch(e){case 3:t.setDiagramTitle(l().text.trim());break;case 11:case 12:{let r=c(n[a])?l():void 0;if(e===11&&n[a]===17){let e=[];do a++,e.push(l());while(n[a]===23);s(18),t.setXAxisBand(e)}else if(n[a]===16||r===void 0){let[n,r]=u();e===11?t.setXAxisRangeData(n,r):t.setYAxisRangeData(n,r)}e===11?t.setXAxisTitle(r??{type:`text`,text:``}):t.setYAxisTitle(r??{type:`text`,text:``});break}case 14:case 15:{let r=n[a]===17?{text:``,type:`text`}:l(),i=d();e===14?t.setLineData(r,i):t.setBarData(r,i);break}case 4:t.setAccTitle(s(5).trim());break;case 6:t.setAccDescription(s(7).trim());break;case 8:t.setAccDescription(r[a-1].trim());break;default:a--,o(`'title', 'X_AXIS', 'Y_AXIS', 'LINE', 'BAR', 'acc_title', 'acc_descr', 'acc_descr_multiline_value'`)}for(;tNt[n[a]]===1;)a++}}function rNt(e,t){let n=e/Math.max(t,1),r=Math.floor(Math.log10(n)),i=n/10**r,a=i>=7.07?10:i>=3.16?5:i>=1.41?2:1;return r<0?-(10**-r)/a:a*10**r}function Y2(e,t){return e>0?t/e:t*-e}function X2(e,t){return e>0?t*e:t/-e}function iNt(e,t,n){let r=Math.round(Y2(n,e));X2(n,r)<e&&r++;let i=Math.round(Y2(n,t));X2(n,i)>t&&i--;let a=[];for(let e=r;e<=i&&a.length<100;e++)a.push(X2(n,e));return a}var aNt=4,Z2=12,oNt=26,sNt=24,cNt=1e300;function Q2(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function $2(e,t,n=!0){let r=e[t];return typeof r==`boolean`?r:n}function lNt(e,t){return typeof e==`number`&&e>0?Math.round(Math.min(Math.max(e,100),4e3)):t}function e4(e){return typeof e==`number`&&isFinite(e)?Math.min(Math.max(e,-cNt),cNt):void 0}function uNt(e){let t=0;for(let n of e)t=Math.max(t,n.label.width);return t}function t4(e,t,n,r){let i=e.lines.length===1?e.lines[0]:void 0;return i&&i.length===1&&i[0].icon===void 0&&i[0].style===0?`<text x="${K(t)}" y="${K(n+e.size*.35)}" text-anchor="${r}">${pq(i[0].text)}</text>`:gq(e,t+(r===`start`?e.width/2:r===`end`?-e.width/2:0),n,``)}function dNt(e,t,n){if(e.plots.length===0)throw new NK(`No Plot to render, please provide a plot with some data`,`semantic`,{type:`xychart`});let r=Q2(t.xyChart),i=n.fontSize??16,a=Math.round(i*.875),o=Math.round(i*.75),s=n.measurer??fq(n.fontFamily),c=n.padding??8,l=lNt(r.width,700),u=KJ(n,l,240),d=Math.round(lNt(r.height,500)*Math.max(.6,u/l)),f=(e.orientation??r.chartOrientation)===`horizontal`,p=$2(r,`showDataLabel`,!1),m=e.xAxis,h=e.plots,g=(e,t,n)=>UJ(e,!1,s,t,n),_=g(`0`,a,4e3).height,v=g(`0`,o,4e3).height,y=UJ($2(r,`showTitle`)?e.title:void 0,!1,s,i,u-2*c,1),b=y.height>0?y.height+12:0,x=[],S=0;$2(r,`showLegend`)&&h.forEach((e,t)=>{if(e.title===``)return;let n=g(e.title,a,u*.3);x.push({index:t,label:n}),S=Math.max(S,n.width+Z2+8)});let C=x.length>0?S+sNt:0,w=h.filter(e=>e.type===`bar`).length,T=e.yAxis.min,E=e.yAxis.max,D=e.hasSetYAxis&&isFinite(T)&&isFinite(E)&&T!==E;if(D)T=e4(T),E=e4(E);else{T=1/0,E=-1/0;for(let e of h)for(let[,t]of e.data){let e=e4(t);e!==void 0&&(e<T&&(T=e),e>E&&(E=e))}T>E&&(T=E=0),w>0&&(T=Math.min(T,0),E=Math.max(E,0)),T===E&&(T===0?E=1:(T-=Math.abs(T)/2,E+=Math.abs(E)/2))}let O=(e,t)=>{let n=rNt(Math.abs(E-T),Math.max(2,Math.min(10,Math.floor(e/t))));return D||(T=X2(n,Math.floor(Y2(n,T)+1e-9)),E=X2(n,Math.ceil(Y2(n,E)-1e-9))),iNt(Math.min(T,E),Math.max(T,E),n).map(e=>({at:(e-T)/(E-T),label:g(String(e),a,4e3)}))},k=1;if(m.type===`band`)k=Math.max(m.categories.length,1);else for(let e of h)k=Math.max(k,e.data.length);let A=1/k,j=m.type===`band`||w>0?A/2:0,M=e4(m.type===`linear`?m.min:void 0),N=e4(m.type===`linear`?m.max:void 0),P=M!==void 0&&N!==void 0&&M!==N,F=(e,t)=>m.type===`band`?(e+.5)*A:j+(t>1?e/(t-1):P?0:.5)*(1-2*j),ee=Q2(r.xAxis),te=Q2(r.yAxis),I=f?ee:te,ne=f?te:ee,re=g($2(I,`showTitle`)?f?m.title:e.yAxis.title:void 0,a,d*.8),ie=g($2(ne,`showTitle`)?f?e.yAxis.title:m.title:void 0,a,u*.8),ae=$2(I,`showTick`)?aNt:0,L=$2(ne,`showTick`)?aNt:0,oe=$2(I,`showLabel`),se=$2(ne,`showLabel`),ce=f?u*.3:Math.max(48,(u-2*c-64-C)*A-8),le=m.type===`band`&&$2(ee,`showLabel`)?m.categories.map(e=>g(e,a,ce)):[],ue=0,de=0;for(let e of le)ue=Math.max(ue,e.width),de=Math.max(de,e.height);let fe=e=>{let t=[];if(m.type===`band`){let n=le.length===0?8:f?de:ue+12,r=Math.max(1,Math.ceil(n/(e*A)));for(let e=0;e<m.categories.length;e+=r)t.push({at:(e+.5)*A,label:le[e]??g(void 0,a,0)})}else if(P){let n=rNt(Math.abs(N-M),Math.max(2,Math.min(10,Math.floor(e/(f?32:80)))));for(let e of iNt(Math.min(M,N),Math.max(M,N),n))t.push({at:j+(e-M)/(N-M)*(1-2*j),label:g(String(e),a,4e3)})}else M!==void 0&&t.push({at:.5,label:g(String(M),a,4e3)});return t},pe=0,me=0;for(let e of h){for(let t of e.pointLabels??[])pe=Math.max(pe,s.width(t,o,0));if(p&&f&&e.type===`bar`)for(let[,t]of e.data)me=Math.max(me,s.width(String(e4(t)??``),o,0))}let he=se?f||m.type!==`band`?_:de:0,ge=L+(he>0?he+4:0)+(ie.height>0?ie.height+4:0),_e=f?0:pe>0||p?v+4:oe?_/2:0,ve=c+b+_e,ye=Math.max(1,d-c-ge-ve),be=ve+ye,xe=f?fe(ye):O(ye,56),Se=oe?uNt(xe):0,Ce=c+(re.height>0?re.height+6:0)+(Se>0?Se+6:0)+ae,we=Math.max(pe>0?pe+12:0,me>0?me+8:0),Te=f?Math.min(u*.25,we):0,Ee=Math.max(1,u-c-Ce-C-Te),De=f?O(Ee,80):fe(Ee);if(se&&C+Te===0){let e=0;for(let t of De)e=Math.max(e,t.at*Ee+t.label.width/2-Ee);Ee=Math.max(1,Ee-e)}let Oe=Ce+Ee,ke=(e,t)=>f?Ce+t*Ee:Ce+e*Ee,Ae=(e,t)=>f?ve+e*ye:be-t*ye,je=e=>(e-T)/(E-T),Me=e=>Math.min(Math.max(e,0),1),Ne=e=>f?`M${K(ke(0,e))},${K(ve)}V${K(be)}`:`M${K(Ce)},${K(Ae(0,e))}H${K(Oe)}`,Pe=``;for(let e of f?De:xe)Pe+=Ne(e.at);let Fe=``,Ie=``;$2(I,`showAxisLine`)&&(Fe+=`M${K(Ce)},${K(ve)}V${K(be)}`),$2(ne,`showAxisLine`)&&(Fe+=`M${K(Ce)},${K(be)}H${K(Oe)}`);for(let e of xe){let t=f?ve+e.at*ye:be-e.at*ye;ae&&(Fe+=`M${K(Ce)},${K(t)}h${-ae}`),oe&&(Ie+=t4(e.label,Ce-ae-6,t,`end`))}for(let e of De){let t=Ce+e.at*Ee;L&&(Fe+=`M${K(t)},${K(be)}v${L}`),se&&(Ie+=t4(e.label,t,be+L+4+e.label.height/2,`middle`))}let Le=(f?ye:Ee)*A,Re=Le*.7/Math.max(w,1),ze=w>1?Math.min(2,Re*.2):0,Be=Me(je(0));w>0&&Be>0&&Be<1&&(Fe+=Ne(Be));let Ve=``,He=``,Ue=``,We=``,Ge=0;h.forEach((e,t)=>{let n=hJ(t),r=e.title?` data-id="${mq(e.title)}"`:``,i=m.type===`band`?Math.min(e.data.length,k):e.data.length;if(e.type===`bar`){let t=(Ge++-(w-1)/2)*Re-(Re-ze)/2,a=``;for(let n=0;n<i;n++){let r=e4(e.data[n][1]);if(r===void 0)continue;let c=F(n,i),l=Me(je(r)),u=Math.min(Be,l),d=Math.max(Be,l),m=f?ke(c,u):ke(c,0)+t,h=f?Ae(c,0)+t:Ae(c,d),g=f?(d-u)*Ee:Re-ze,_=f?Re-ze:(d-u)*ye;if(a+=`<rect x="${K(m)}" y="${K(h)}" width="${K(g)}" height="${K(_)}"/>`,!p)continue;let y=String(r),b=s.width(y,o,0),x=l>=Be?1:-1,S=m+g/2,C=h+_/2,T=`middle`;if(f){if(_<o)continue;S=(x>0?m+g:m)+x*6,T=x>0?`start`:`end`}else{if(b+2>Le/w)continue;C=(x>0?h:h+_)-x*(v/2+2)}Ue+=`<text x="${K(S)}" y="${K(C+o*.35)}" text-anchor="${T}">${y}</text>`}Ve+=`<g class="pele-series pele-bars"${r} fill="${n}">${a}</g>`;return}let a=``,c=``,l=!1,u=0,d=NaN;for(let t=0;t<i;t++){let n=e4(e.data[t][1]);if(n===void 0){d=NaN;continue}let r=F(t,i),s=je(n),p=s>=0&&s<=1;if(d!==d)p&&(a+=`M${K(ke(r,s))},${K(Ae(r,s))}`),l=p;else{let e=s-d,t=0,n=1;if(e!==0){let r=-d/e,i=(1-d)/e;t=Math.max(t,Math.min(r,i)),n=Math.min(n,Math.max(r,i))}else p||(t=2);if(t<=n){let i=u+(r-u)*t,o=d+e*t,s=u+(r-u)*n,c=d+e*n;(!l||t>0)&&(a+=`M${K(ke(i,o))},${K(Ae(i,o))}`),a+=`L${K(ke(s,c))},${K(Ae(s,c))}`}l=p}if(u=r,d=s,!p)continue;let m=ke(r,s),h=Ae(r,s);Le>=12&&(c+=`<circle cx="${K(m)}" cy="${K(h)}" r="3"/>`);let _=g(e.pointLabels?.[t],o,4e3);if(_.height>0){let e=_.width/2;We+=f?t4(_,m+10,h,`start`):t4(_,Math.max(Math.min(m,Oe-e),Ce+e),h-6-_.height/2,`middle`)}}He+=`<g class="pele-series pele-line"${r} fill="${n}">`+(a?`<path d="${a}" fill="none" stroke="${n}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>`:``)+c+`</g>`});let Ke=``;re.height>0&&(Ke+=`<g transform="translate(${K(c+re.height/2)},${K(ve+ye/2)}) rotate(-90)">${gq(re,0,0,``)}</g>`),Ke+=gq(ie,Ce+Ee/2,d-c-ie.height/2,``);let qe=``,Je=0;for(let e of x)Je+=Math.max(oNt,e.label.height+6);let Ye=ve+Math.max(0,(ye-Je)/2),Xe=Oe+Te+sNt;for(let{index:e,label:t}of x){let n=Math.max(oNt,t.height+6);if(Ye+n>d)break;let r=Ye+n/2,i=hJ(e);qe+=`<g class="pele-legend-item" data-id="${mq(h[e].title)}">`+(h[e].type===`bar`?`<rect x="${K(Xe)}" y="${K(r-Z2/2)}" width="${Z2}" height="${Z2}" rx="2" fill="${i}"/>`:`<path d="M${K(Xe)},${K(r)}h${Z2}" stroke="${i}" stroke-width="2" stroke-linecap="round"/>`)+gq(t,Xe+Z2+8+t.width/2,r,``)+`</g>`,Ye+=n}return{svg:_J(`xychart`,u,d,i,n,e,gq(y,u/2,c+y.height/2,` class="pele-title" font-weight="var(--_tw)"`)+(Pe?`<path class="pele-grid" d="${Pe}" stroke="var(--_a)"/>`:``)+`<g class="pele-plot">${Ve}${He}</g>`+(Fe?`<path class="pele-axis" d="${Fe}" fill="none" stroke="var(--_b)"/>`:``)+(Ie?`<g class="pele-axis-labels" font-size="${a}" fill="var(--_m)">${Ie}</g>`:``)+(Ke?`<g class="pele-axis-titles" font-size="${a}">${Ke}</g>`:``)+(Ue?`<g class="pele-data-labels" font-size="${o}">${Ue}</g>`:``)+(We?`<g class="pele-point-labels" font-size="${o}">${We}</g>`:``)+(qe?`<g class="pele-legend" font-size="${a}">${qe}</g>`:``)),width:u,height:d,links:[]}}gpt(jxt,mTt,gbt,Xwt,Awt,Xkt,uwt,uyt,NTt,{type:`xychart`,section:`xyChart`,parse(e,t,n){let r=new JMt;return r.title=n,nNt(e,r),r},render:dNt},vkt,$St,Ygt,ODt,KDt,rTt,YTt,UAt,TCt,VOt,yCt,Mvt,V_t,XEt,ygt,AAt,jyt,qMt,Vbt,oMt,wMt,GCt,Ikt);
|
|
1078
1078
|
/*!
|
|
1079
1079
|
MIT License
|
|
1080
1080
|
|
|
@@ -1869,15 +1869,15 @@ function run(argv) {
|
|
|
1869
1869
|
Disallow: /
|
|
1870
1870
|
`);else if(i.kind===`runtime`)a9(e,n,i.rest,t.headers,`board`);else if(i.kind===`board`){let r=JV(e.root,`artboard`,i.address);!r||r.id===i.address?ae(n,404,`Not found`):a9(e,n,`artboard/${r.id}/${i.rest}`,t.headers,`board`)}else ae(n,404,`Not found`)}catch(e){n.headersSent?n.destroy():ae(n,500,e.message)}},AKt=/^\/api\/artboard\/([^/]+)\/comments$/,jKt=/^\/api\/verify\/([^/]+)\/comments$/,o9=async(e,t=262144)=>{let n=[],r=0;for await(let i of e)r+=i.length,r<=t&&n.push(i);if(r>t)return null;try{return JSON.parse(Buffer.concat(n).toString(`utf8`))}catch{return null}};async function MKt(e,t,n,r){if(!UV(n.root,`artboard`,r)){L(t,404,{error:`artboard/${r} not found`});return}let i=fet(await o9(e));if(!i)L(t,400,{error:`not a comment op`});else if(n.verdictPreparing(r,i))L(t,409,{error:`The recording evidence is still being prepared`});else try{L(t,200,n.boardComments.apply(r,i))}catch(e){L(t,400,{error:e.message})}}const NKt={path:AKt,methods:[`POST`],auth:`same-origin`,handle:(e,t,n,{match:r})=>MKt(e,t,n,r[1])};async function PKt(e,t,n,r){if(!UV(n.root,`verify`,r)){L(t,404,{error:`verify/${r} not found`});return}let i=Zdt(await o9(e));if(!i)L(t,400,{error:`not a report op`});else try{L(t,200,{...n.verify.apply(r,i),...n.verify.meta(r)})}catch(e){L(t,400,{error:e.message})}}const FKt={path:jKt,methods:[`POST`],auth:`same-origin`,handle:(e,t,n,{match:r})=>PKt(e,t,n,r[1])},IKt=/^\/api\/document\/([^/]+)\/state$/,LKt=/^\/api\/document\/([^/]+)\/(update|comments)$/;async function RKt(e,t,n){let r=UV(t.root,`document`,n)?await t.documents.open(n):null;r?L(e,200,await t.documentState(n,r)):L(e,404,{error:`document/${n} has no doc.xml`})}async function zKt(e,t,n,r){if(!UV(n.root,`document`,r)){L(t,404,{error:`document/${r} not found`});return}let i=tU(await o9(e));if(!i)L(t,400,{error:`not a comment op`});else try{L(t,200,{comments:await n.documents.applyCommentOp(r,i)})}catch(e){L(t,400,{error:e.message})}}async function BKt(e,t,n,r){let i=UV(n.root,`document`,r)?await n.documents.open(r):null;if(!i){L(t,404,{error:`document/${r} has no doc.xml`});return}if(Number(e.headers[`content-length`]??0)>8388608){e.resume(),ae(t,413,`Update too large`);return}let a=[],o=0;for await(let t of e)o+=t.length,o<=8388608&&a.push(t);if(o>8388608){ae(t,413,`Update too large`);return}let s=e.headers[`x-ryugi-document-features`],c=typeof s==`string`?s.split(`,`).map(e=>e.trim()):[];try{await i.importUpdate(new Uint8Array(Buffer.concat(a)),c),ae(t,204,``)}catch(e){L(t,e instanceof bV?409:400,{error:e.message})}}const VKt={path:IKt,auth:`viewer`,handle:(e,t,n,{match:r})=>RKt(t,n,r[1])},HKt={path:LKt,methods:[`POST`],auth:`same-origin`,handle:(e,t,n,{match:r})=>r[2]===`comments`?zKt(e,t,n,r[1]):BKt(e,t,n,r[1])},s9=2400,c9=e=>e.x+e.w/2,l9=e=>e.y+e.h/2,u9=e=>e===`left`||e===`right`;function d9(e,t,n){let r=e.boards[n],i=e.notes?.[n];return r&&i?null:r?.page===t?{id:n,board:!0,rect:{x:r.x,y:r.y-48,w:r.w,h:r.h+48}}:i?.kind===`condition`&&i.page===t?{id:n,board:!1,rect:Se(i)}:null}function UKt(e,t){let n=[...Object.keys(e.boards),...Object.keys(e.notes??{})];return[...new Set(n)].flatMap(n=>d9(e,t,n)??[])}function WKt(e,t,n){return t===`left`?{x:e.x,y:l9(e)+n}:t===`right`?{x:e.x+e.w,y:l9(e)+n}:t===`top`?{x:c9(e)+n,y:e.y}:{x:c9(e)+n,y:e.y+e.h}}function GKt(e,t,n){let r=Math.min(e.x,t.x),i=Math.max(e.x,t.x),a=Math.min(e.y,t.y),o=Math.max(e.y,t.y);return a===o?a>n.y&&a<n.y+n.h&&r<n.x+n.w&&i>n.x:r>n.x&&r<n.x+n.w&&a<n.y+n.h&&o>n.y}function KKt(e,t,n){return t.filter(t=>!n.has(t.id)&&e.some((n,r)=>r+1<e.length&&GKt(n,e[r+1],t.rect))).map(e=>e.id)}function qKt(e,t,n){let r=WKt(e.from.rect,e.fromSide,t),i=WKt(e.to.rect,e.toSide,n);if(u9(e.fromSide)!==u9(e.toSide))return[r,u9(e.fromSide)?{x:i.x,y:r.y}:{x:r.x,y:i.y},i];if(u9(e.fromSide)){if(Math.abs(r.y-i.y)<.5)return[r,{x:i.x,y:r.y}];let e=(r.x+i.x)/2;return[r,{x:e,y:r.y},{x:e,y:i.y},i]}if(Math.abs(r.x-i.x)<.5)return[r,{x:r.x,y:i.y}];let a=(r.y+i.y)/2;return[r,{x:r.x,y:a},{x:i.x,y:a},i]}function JKt(e,t,n){let r=e.rect,i=t.rect,a=c9(i)>=c9(r),o=l9(i)>=l9(r);if(r.y<i.y+i.h&&i.y<r.y+r.h)return a?[`right`,`left`]:[`left`,`right`];if(r.x<i.x+i.w&&i.x<r.x+r.w)return o?[`bottom`,`top`]:[`top`,`bottom`];let s=[[a?`right`:`left`,o?`top`:`bottom`],[o?`bottom`:`top`,a?`left`:`right`]],c=/* @__PURE__ */ new Set([e.id,t.id]),l=([r,i],a)=>{let o=qKt({from:e,to:t,fromSide:r,toSide:i},0,0),s=r===`top`&&e.board||i===`top`&&t.board,l=a===+!e.board;return KKt(o,n,c).length*100+(s?10:0)+ +!l};return l(s[0],0)<=l(s[1],1)?s[0]:s[1]}function YKt(e){let t=/* @__PURE__ */ new Map;for(let n of e)for(let[e,r,i,a]of[[`from`,n.from,n.fromSide,n.to],[`to`,n.to,n.toSide,n.from]]){let o=`${r.id}\n${i}`,s=u9(i),c=t.get(o)??[];c.push({key:`${n.id}\n${e}`,edge:n.id,along:s?l9(a.rect):c9(a.rect),length:s?r.rect.h:r.rect.w}),t.set(o,c)}let n=/* @__PURE__ */ new Map;for(let e of t.values()){e.sort((e,t)=>e.along-t.along||(e.edge<t.edge?-1:1));let t=e[0].length,r=Math.min(160,t/(e.length+1));e.forEach((i,a)=>{n.set(i.key,{offset:(a-(e.length-1)/2)*r,size:e.length,limit:t/2-r/2})})}return n}function XKt(e,t,n){let r=e.label?.trim();if(!r)return null;let i=!e.from.board,a=i?28:32,o=Math.ceil(ve(r,a)+32),s=Math.ceil(a*1.4),c=(e,t,r,i)=>{let a=r?i-48:s9,o={x:e-s9/2,y:t-s/2,w:s9,h:s};for(let{rect:t}of n){if(!Te(o,t))continue;let n=t.x>=e?t.x-e:e>=t.x+t.w?e-(t.x+t.w):0;a=Math.min(a,n*2-24)}return Math.max(0,a)},l=t.slice(0,-1).map((e,n)=>{let r=t[n+1];return{a:e,b:r,flat:e.y===r.y,length:Math.abs(e.x-r.x)+Math.abs(e.y-r.y)}}).sort((e,t)=>t.length-e.length),u=null;for(let{a:e,b:t,flat:n,length:a}of l){let l=(e.x+t.x)/2,d=(e.y+t.y)/2,f=n||a>=s+48?c(l,d,n,a):0,p={text:r,branch:i,x:l,y:d,w:o,h:s,room:f};if(f>=o)return p;(!u||f>u.room)&&(u=p)}return u}function ZKt(e,t){let n=Object.entries(e.edges??{});if(n.length===0)return[];let r=UKt(e,t),i=[];for(let[a,o]of n){if(o.from===o.to)continue;let n=d9(e,t,o.from),s=d9(e,t,o.to);if(!n||!s)continue;let[c,l]=JKt(n,s,r);i.push({id:a,from:n,to:s,fromSide:c,toSide:l,label:o.label})}let a=YKt(i);return i.map(e=>{let t=a.get(`${e.id}\nfrom`),n=a.get(`${e.id}\nto`),i=t.offset,o=n.offset,s=u9(e.fromSide);if(s===u9(e.toSide)&&(s?Math.abs(l9(e.from.rect)-l9(e.to.rect))<.5:Math.abs(c9(e.from.rect)-c9(e.to.rect))<.5)&&i!==o){let e=t.size>=n.size,r=e?i:o;Math.abs(r)<=(e?n:t).limit&&(i=r,o=r)}let c=qKt(e,i,o);return{id:e.id,points:c,label:XKt(e,c,r)}})}function QKt(e){let t=e.edges??{};if(Object.keys(t).length===0)return[];let n=[];for(let r of e.pages){let i=UKt(e,r.id).filter(e=>e.board);for(let a of ZKt(e,r.id)){let e=t[a.id];for(let t of KKt(a.points,i,/* @__PURE__ */ new Set([e.from,e.to])))n.push(`edge "${a.id}" crosses board "${t}"`)}}return n}const $Kt=/* @__PURE__ */ new Set([`arrow`,`line`]);function eqt(e){let t=zG(e),n=t.author??null;return{author:n,editedBy:t.lastBy&&t.lastBy!==n?t.lastBy:null}}function tqt(e,t={}){let n=e.elements.filter(e=>!e.isDeleted),r=/* @__PURE__ */ new Map;for(let e of n)e.type===`text`&&e.containerId&&typeof e.text==`string`&&r.set(e.containerId,e.text);let i=new Map(n.map(e=>[e.id,e.frameId??null])),a=e=>e.type===`richtext`?Yct(e.content)||null:e.type===`svg`?Qct(e.svg):typeof e.text==`string`?e.text:null,o=e=>({id:e.id,type:e.type,text:r.get(e.id)??a(e),sticky:e.type===`richtext`||e.type===`rectangle`&&e.backgroundColor===`#ffec99`,group:e.groupIds?.[0]??null,...eqt(e)}),s=n.filter(e=>e.type!==`frame`&&!$Kt.has(e.type)&&!(e.type===`text`&&e.containerId)),c=n.filter(e=>e.type===`frame`&&(!t.frame||e.id===t.frame)).map(e=>({id:e.id,name:typeof e.name==`string`?e.name:e.id,items:s.filter(t=>t.frameId===e.id).map(o)})),l=t.frame?[]:s.filter(e=>!e.frameId).map(o),u=e=>e!==null&&i.get(e)===t.frame;return{frames:c,loose:l,arrows:n.filter(e=>$Kt.has(e.type)).map(e=>({arrow:e,from:e.startBinding?.elementId??null,to:e.endBinding?.elementId??null})).filter(({arrow:e,from:n,to:r})=>!t.frame||e.frameId===t.frame||u(n)||u(r)).map(({arrow:e,from:t,to:n})=>({id:e.id,from:t,to:n,label:r.get(e.id)??null,...eqt(e)})),selected:t.selected??[]}}const nqt=e=>e.replaceAll(/\s*\n\s*/g,` / `),rqt=({author:e,editedBy:t})=>e?` · ${e}${t?`, ${t} edited`:``}`:``,iqt=e=>e.sticky?`sticky`:e.type===`svg`&&!e.text?`svg illustration`:e.type,aqt=e=>` ${e.id} ${iqt(e)}${e.text?` "${nqt(e.text)}"`:``}${rqt(e)}`;function oqt(e){let t=[];for(let n of e.frames)t.push(`frame ${n.id} "${n.name}" (${n.items.length})`),t.push(...n.items.map(aqt));if(e.loose.length&&(t.push(`not in a frame (${e.loose.length})`),t.push(...e.loose.map(aqt))),e.arrows.length){t.push(`arrows (${e.arrows.length})`);for(let n of e.arrows)t.push(` ${n.from??`?`} → ${n.to??`?`}${n.label?` ("${nqt(n.label)}")`:``}${rqt(n)}`)}return e.selected.length&&t.push(`selected: ${e.selected.join(`, `)}`),t}const sqt=/^\/api\/agent\/document\/([^/]+)\/comments$/,cqt=/^\/api\/agent\/document\/([^/]+)\/changes$/,lqt=/^\/api\/agent\/artboard\/([^/]+)\/comments$/,uqt=/^\/api\/agent\/whiteboard\/([^/]+)\/comments$/,dqt=/^\/api\/agent\/whiteboard\/([^/]+)\/scene$/,fqt=/^\/api\/agent\/([^/]+)\/([^/]+)\/check$/,f9=e=>typeof e.agent==`string`&&e.agent.length>0&&e.agent.length<=100?e.agent:void 0,pqt=async(e,t,n)=>{await(await e.documents.open(t))?.flush();let r=kE(f.default.readFileSync(m.default.join(n,`doc.xml`),`utf8`));return new Set(r.root.children.flatMap(e=>e.$?.blockId?[e.$.blockId]:[]))};async function mqt(e,t,n,r){let{root:i,documents:a}=n,o=UV(i,`document`,r);if(!o){L(t,404,{error:`document/${r} not found`});return}let s=await o9(e),c=typeof s==`object`&&s?s:{},l=f9(c);if(c.op===`list`){await kK(n,`document/${r}`),L(t,200,{type:`comments`,artifact:`document/${r}`,threads:a.listComments(r,l??`Agent`,c.all===!0),...await a.asks(r)});return}if(c.op===`answer`||c.op===`submit`||c.op===`note`){try{L(t,200,await a.agentAsk(r,hqt(c),l))}catch(e){L(t,400,{error:e.message})}return}let u=U9e(s);if(!u)L(t,400,{error:`not an agent comment op: use list, add {blockId, text}, reply {threadId, text} or resolve {threadId}; text must not be empty`});else{if(u.op===`add`){let e;try{e=await pqt(n,r,o)}catch(e){L(t,400,{error:`doc.xml could not be read: ${e.message}`});return}let i=(u.blockIds??[u.blockId]).find(t=>!e.has(t));if(i){L(t,400,{error:`no block ${i} in document/${r}`});return}}try{L(t,200,a.applyAgentCommentOp(r,u,l))}catch(e){L(t,400,{error:e.message})}}}const p9=e=>typeof e==`string`&&e.trim()?e:null;function hqt(e){if(e.op===`submit`){if(typeof e.submit!=`boolean`)throw Error(`submit needs {submit: true | false}`);return{op:`submit`,submit:e.submit}}if(!eU(e.ask))throw Error(`${String(e.op)} needs {ask}`);if(e.op===`note`){let t=p9(e.text);if(!t)throw Error(`a note needs {text}`);return{op:`note`,ask:e.ask,text:t}}return{op:`answer`,ask:e.ask,choice:p9(e.choice),answer:p9(e.answer)}}function gqt(e){let t=e.verdict;if(t!==`pass`&&t!==`reject`)throw Error(`verdict needs {verdict: "pass" | "reject"}`);if(e.all!==!0&&!eU(e.group))throw Error(`verdict needs {group} or {all: true}`);let n=typeof e.text==`string`?e.text.trim():``;if(t===`reject`&&!n)throw Error(`a reject needs a reason: pass {text}`);return{group:e.all===!0?null:e.group,verdict:t,text:n||`Pass`}}async function _qt(e,t,n,r){let{root:i,boardComments:a}=n,o=UV(i,`artboard`,r);if(!o){L(t,404,{error:`artboard/${r} not found`});return}let s=await o9(e),c=typeof s==`object`&&s?s:{},l=f9(c);if(c.op===`list`){await kK(n,`artboard/${r}`);let e=a.list(r,l??`Agent`,c.all===!0);L(t,200,{type:`comments`,artifact:`artboard/${r}`,threads:e,groups:a.groups(r),rounds:a.rounds(r)});return}if(c.op===`choose`||c.op===`submit`){try{if(c.op===`choose`){if(!eU(c.group)||c.board!==null&&!eU(c.board))throw Error(`choose needs {group, board} with board a board id or null`);L(t,200,a.agentChoose(r,c.group,c.board,l))}else{if(!eU(c.round)||typeof c.submit!=`boolean`)throw Error(`submit needs {round, submit: true | false}`);L(t,200,a.agentSubmit(r,c.round,c.submit,l))}}catch(e){L(t,400,{error:e.message})}return}if(c.op===`verdict`){try{L(t,200,a.agentVerdict(r,gqt(c),l))}catch(e){L(t,400,{error:e.message})}return}let u=get(s,oU(o));if(u&&`error`in u){L(t,400,{error:`${u.error} in artboard/${r}`});return}let d=u??pet(s);if(!d)L(t,400,{error:`not an agent comment op: use list, add {anchor: {page, board, x, y}, text}, reply {threadId, text} or resolve {threadId}; text must not be empty`});else if(d.op===`add`&&d.anchor.board&&!(d.anchor.board in het(o)))L(t,400,{error:`no board ${d.anchor.board} in artboard/${r}`});else try{L(t,200,a.applyAgent(r,d,l))}catch(e){L(t,400,{error:e.message})}}async function vqt(e,t,n,r,i=null){let{root:a,stateDir:o,documents:s,signatures:c}=t,l=WV(`${n}/${r}`),u=l&&UV(a,l.type,l.id);if(!l||!u){L(e,404,{error:`${n}/${r} not found in ${a}`});return}l.type===`whiteboard`&&t.whiteboards.sync(l.id);let d=l.type===`whiteboard`?t.whiteboards.livePages(l.id).map(e=>e.id):[];if(i!==null&&(l.type!==`whiteboard`||!d.includes(i))){L(e,404,{error:l.type===`whiteboard`?`page ${i} is not on whiteboard/${l.id}; pages: ${d.join(`, `)}`:`--page applies to whiteboards only`});return}let p=`${l.type}/${l.id}`;eH(t,l),l.type===`artboard`&&await s.opening();let h=!1;if(l.type===`document`){let e=await s.open(l.id),t=await f.default.promises.readFile(m.default.join(u,`doc.xml`),`utf8`).catch(()=>null);if(e&&t!==null){e.onFileText(t);let n=new Promise(e=>setTimeout(()=>e(`timeout`),6e4).unref());h=await Promise.race([e.settled(),n])===`timeout`}}let g=i===null?d:[i];l.type===`whiteboard`&&await bqt(t,l.id,g),eH(t,l);let _=t.writeState(l,u),v=JSON.parse(await f.default.promises.readFile(m.default.join(o,l.type,l.id,`warnings.json`),`utf8`)),y=i===null?v:{...v,..._lt({warnings:v.warnings??[],pending:v.pending??[]},i,d)},b=Object.values(y.dynamic??{}),x=l.type===`whiteboard`||l.type===`html`||l.type===`slides`||l.type===`report`||b.length>0||l.type===`artboard`&&`canvas`in _&&Object.values(_.canvas?.boards??{}).some(e=>!Ae(e)),S=l.type===`whiteboard`?g.every(e=>yqt(t,l.id,e)):l.type===`html`||l.type===`slides`||l.type===`report`||l.type===`artboard`?y.ran:b.length?b.every(e=>e.ran===!0):!x||void 0;L(e,200,{...y,...l.type===`artboard`?{pending:[...y.pending??[],...y.browserPending??[]]}:{},modules:eWt(m.default.dirname(a),p),...h?{merging:!0}:{},...l.type===`artboard`&&`canvas`in _&&_.canvas?{provenance:[...He(_.canvas),...QKt(_.canvas),...t.arranges.notices(l.id)]}:{},...l.type===`verify`&&`report`in _&&_.report?{provenance:Gdt(_.report)}:{},evidence:{required:x,observed:S,fresh:!h&&c.get(p)===GV(u,l.type)}})}function yqt(e,t,n){let r=e.whiteboards.scene(t,n);return r!==null&&e.whiteboards.geometry(t,n)?.sceneVersion===JG(r)}async function bqt(e,t,n){let r=()=>n.some(n=>{let r=e.whiteboards.scene(t,n),i=e.whiteboards.geometry(t,n);return r!==null&&i!==null&&i.sceneVersion!==JG(r)});for(let e=0;e<1e4&&r();e+=100)await new Promise(e=>setTimeout(e,100))}async function xqt(e,t,n,r){if(!UV(n.root,`document`,r)){L(t,404,{error:`document/${r} not found`});return}let i=await o9(e),a=typeof i==`object`&&i?i:{},o=await n.documents.changes(r,f9(a)??`Agent`,a.all===!0);o?L(t,200,{type:`changes`,artifact:`document/${r}`,...o}):L(t,404,{error:`document/${r} not found`})}const Sqt={path:cqt,methods:[`POST`],auth:`agent`,handle:(e,t,n,{match:r})=>xqt(e,t,n,r[1])},Cqt={path:sqt,methods:[`POST`],auth:`agent`,handle:(e,t,n,{match:r})=>mqt(e,t,n,r[1])},wqt={path:lqt,methods:[`POST`],auth:`agent`,handle:(e,t,n,{match:r})=>_qt(e,t,n,r[1])};async function Tqt(e,t,n,r){if(!UV(n.root,`whiteboard`,r)){L(t,404,{error:`whiteboard/${r} not found`});return}let i=await o9(e),a=typeof i==`object`&&i?i:{},o=f9(a);if(a.op===`list`){L(t,200,{type:`comments`,artifact:`whiteboard/${r}`,threads:n.whiteboardComments.list(r,o??`Agent`,a.all===!0)});return}let s=kHt(a);if(!s)L(t,400,{error:`not an agent comment op: use list, add {element | x, y, text}, reply {threadId, text} or resolve {threadId}; text must not be empty`});else try{L(t,200,n.whiteboardComments.applyAgent(r,s,o))}catch(e){L(t,400,{error:e.message})}}const Eqt={path:uqt,methods:[`POST`],auth:`agent`,handle:(e,t,n,{match:r})=>Tqt(e,t,n,r[1])};async function Dqt(e,t,n,r){if(!UV(n.root,`whiteboard`,r)){L(t,404,{error:`whiteboard/${r} not found`});return}n.whiteboards.sync(r);let i=await o9(e),a=typeof i==`object`&&i?i:{},o=typeof a.frame==`string`&&a.frame?a.frame:void 0,s=typeof a.page==`string`&&a.page?a.page:void 0,c=n.whiteboards.livePages(r);if(s&&!c.some(e=>e.id===s)){L(t,404,{error:`page ${s} is not on whiteboard/${r}; pages: ${c.map(e=>e.id).join(`, `)}`});return}let l=e=>{let t=n.whiteboards.scene(r,e),i=n.whiteboards.render(r,e),a=t?JG(t):0;return{sceneVersion:a,render:i?i.sceneVersion===a?`current`:`stale`:`none`,...i?{renderPath:n.whiteboards.renderPathOf(r,e),renderVersion:i.sceneVersion}:{}}};if(c.length>1&&!s&&!o){let e=c.map(e=>{let t=(n.whiteboards.scene(r,e.id)?.elements??[]).filter(e=>!e.isDeleted);return{id:e.id,name:e.name??null,frames:t.filter(e=>e.type===`frame`).map(e=>e.id),elements:t.length,...l(e.id)}}),i=new Set(e.map(e=>e.render));L(t,200,{artifact:`whiteboard/${r}`,sceneVersion:e.reduce((e,t)=>e+t.sceneVersion,0),render:i.size===1?[...i][0]:`stale`,problem:null,conflicts:[],pages:e,lines:e.map(e=>`page ${e.id}${e.name?` "${e.name}"`:``} · ${e.elements} elements · frames ${e.frames.join(`, `)||`none`} · render ${e.render}`)});return}let u=s??(o?n.whiteboards.elementPage(r,o):null)??`main`,d=n.whiteboards.scene(r,u);if(!d){L(t,404,{error:`whiteboard/${r} not found`});return}let f=Oqt(m.default.join(n.stateDir,`whiteboard`,r,`selection.json`)),p=tqt(d,{...o?{frame:o}:{},selected:f});L(t,200,{artifact:`whiteboard/${r}`,...c.length>1?{page:u}:{},...l(u),problem:n.whiteboards.problem(r,u),conflicts:n.whiteboards.conflicts(r,u),lines:oqt(p),summary:p})}function Oqt(e){try{return(JSON.parse(f.default.readFileSync(e,`utf8`)).selected??[]).flatMap(e=>typeof e.id==`string`?[e.id]:[])}catch{return[]}}const kqt={path:dqt,methods:[`POST`],auth:`agent`,handle:(e,t,n,{match:r})=>Dqt(e,t,n,r[1])},Aqt={path:fqt,methods:[`POST`],auth:`agent`,handle:(e,t,n,{match:r})=>vqt(t,n,r[1],r[2],new URL(e.url??`/`,`http://x`).searchParams.get(`page`))},jqt=e=>{if(typeof e!=`object`||!e)return!1;let t=e,n=(e,t)=>typeof e==`string`&&e.length>0&&e.length<=t;return(t.host===`claude`||t.host===`codex`)&&n(t.session,200)&&n(t.event,64)&&typeof t.at==`number`&&Number.isFinite(t.at)&&(t.tool===void 0||n(t.tool,64))&&(t.paths===void 0||Array.isArray(t.paths)&&t.paths.length<=64&&t.paths.every(e=>n(e,4096)))},Mqt={path:`/api/agent/event`,methods:[`POST`],auth:`agent`,handle:async(e,t,n)=>{let r=await o9(e);if(!jqt(r)){L(t,400,{error:`not an agent event: need host, session, event, at and optional paths`});return}let i=n.agentStatus.turnArtifacts(r.host,r.session);n.agentDirectory.record(r),n.agentStatus.apply(r)&&n.publishAgentStatus();let a=/* @__PURE__ */ new Set([...i,...n.agentStatus.turnArtifacts(r.host,r.session)]);for(let e of a){let t=WV(e);t&&eH(n,t)}ae(t,204,``)}},Nqt=/^[\da-f]{8}(?:-[\da-f]{4}){3}-[\da-f]{12}$/i;function Pqt(e,t,n,r){return Nqt.test(n)?h5e(e)?.subscribed(t,n,r)??!1:!1}function Fqt(e,t,n){return n.filter(n=>Pqt(e,n.host,n.id,t))}function Iqt(e,t,n,r,i){let a=h5e(t);return!Nqt.test(r)||!a?!1:(a.subscribe(n,r,i),!0)}function Lqt(e){let{artifact:t,explicitSession:n,projectRoot:r,sessions:i,stateDir:a}=e;if(n&&(n.host===`claude`||n.host===`antigravity`||n.host===`codex`))return Iqt(r,a,n.host,n.id,t)?{host:n.host,id:n.id}:null;let o=Fqt(a,t,i);if(o.length>0)return{host:o[0].host,id:o[0].id};if(i.length===1){let e=i[0];return Iqt(r,a,e.host,e.id,t)?{host:e.host,id:e.id}:null}return null}const Rqt=/^\/api\/preview-dev\/list$/,zqt=/^\/api\/preview-dev\/recent$/,Bqt=/^\/api\/preview-dev\/open$/,Vqt=/^\/api\/preview-dev\/([^/]+)\/state$/,Hqt=/^\/api\/preview-dev\/([^/]+)\/config$/,Uqt=/^\/api\/preview-dev\/([^/]+)\/comments$/,Wqt=/^\/api\/preview-dev\/([^/]+)\/selection$/,Gqt=/^\/api\/preview-dev\/([^/]+)\/marks\/([\w-]{1,100}-\d+\.jpg)$/,Kqt=/^\/api\/agent\/preview\/([^/]+)\/comments$/;function m9(e){return`http://${ie(e.options.urlHost)}:${e.port}`}function h9(e){return`${m9(e)}${e.contentPrefix}runtime/ryugi-preview-bridge.js`}function g9(e){return m.default.dirname(m.default.dirname(e.root))}const qqt={path:Rqt,methods:[`GET`],auth:`viewer`,handle(e,t,n){L(t,200,{previews:MLt(n.root).map(({id:e,payload:t})=>{let r=n.previewComments.comments(e).threads.filter(e=>e.status!==`resolved`).length;return{id:e,title:t.title,url:t.config?.url??null,path:t.config?.path??`/`,openThreads:r,href:`/preview/${encodeURIComponent(e)}?project=${encodeURIComponent(g9(n))}`}})})}},Jqt={path:Gqt,methods:[`GET`],auth:`viewer`,handle(e,t,n,{match:r}){let i=decodeURIComponent(r[1]),a=r[2],o=Z6(n.root,i);o?se(t,m.default.join(o,`marks`,a)):ae(t,404,`Not found`)}},Yqt={path:zqt,methods:[`GET`],auth:`viewer`,handle(e,t,n){L(t,200,{recent:FLt(n.stateDir),sessions:n.agentStatus.sessions()})}},Xqt={path:Bqt,methods:[`POST`],auth:`same-origin`,async handle(e,t,n){let r=await o9(e);if(!r||typeof r!=`object`){L(t,400,{error:`Expected JSON body with url`});return}let i=K6(typeof r.url==`string`?r.url:``);if(!i){L(t,400,{error:`Only local loopback http URLs are allowed (e.g. http://localhost:5173)`});return}let a=typeof r.id==`string`&&r.id.trim()?r.id.trim():`dev`;if(!Y6.test(a)){L(t,400,{error:`Preview id must use lowercase letters, digits, and hyphens`});return}let o=q6(r.path)??i.path,s=typeof r.title==`string`&&r.title.trim()?r.title.trim().slice(0,200):void 0,c=jLt(n.root,a),l=null;try{l=J6(f.default.readFileSync(m.default.join(c,`preview.json`),`utf8`)).config}catch{}let u={version:1,url:i.url,...s?{title:s}:l?.title?{title:l.title}:{},...o&&o!==`/`?{path:o}:{},...l?.viewport?{viewport:l.viewport}:{}};NLt(c,u),ILt(n.stateDir,{id:a,url:u.url,path:u.path});let d=await n.previewProxies.ensure({id:a,targetOrigin:u.url,viewerOrigin:m9(n),bridgeScriptUrl:h9(n)}),p=await e8(u.url);L(t,200,{id:a,artifact:`preview/${a}`,config:u,proxyUrl:d.origin,upstreamAlive:p,href:`/preview/${encodeURIComponent(a)}?project=${encodeURIComponent(g9(n))}`})}},Zqt={path:Vqt,methods:[`GET`],auth:`viewer`,async handle(e,t,n,{match:r}){let i=decodeURIComponent(r[1]),a=Z6(n.root,i);if(!a){L(t,404,{error:`preview/${i} not found`});return}let o=Q6(a,i),s=null,c=!1;o.config&&(s=(await n.previewProxies.ensure({id:i,targetOrigin:o.config.url,viewerOrigin:m9(n),bridgeScriptUrl:h9(n)})).origin,c=await e8(o.config.url));let l=n.agentStatus.sessions(),u=Fqt(n.stateDir,`preview/${i}`,l).map(e=>({host:e.host,id:e.id})),d=n.previewComments.state(i);L(t,200,{...o,contentBase:`/api/preview-dev/${encodeURIComponent(i)}/`,proxyUrl:s,upstreamAlive:c,comments:d.comments,listening:d.listening,sessions:l,subscribedSessions:u})}},Qqt={path:Hqt,methods:[`POST`],auth:`same-origin`,async handle(e,t,n,{match:r}){let i=decodeURIComponent(r[1]),a=Z6(n.root,i);if(!a){L(t,404,{error:`preview/${i} not found`});return}let o=await o9(e);if(!o||typeof o!=`object`){L(t,400,{error:`Expected JSON body`});return}let s=Q6(a,i).config,c=typeof o.url==`string`?o.url:s?.url,l=c?G6(c)??(K6(c)?.url?G6(K6(c).url):null):null;if(!l){L(t,400,{error:`url must be a valid local loopback http origin`});return}let u={version:1,url:l.origin,...s?.title?{title:s.title}:{},...s?.path?{path:s.path}:{},...s?.viewport?{viewport:s.viewport}:{}};o.title!==void 0&&(u.title=o.title),o.path!==void 0&&(u.path=o.path),o.viewport!==void 0&&(u.viewport=o.viewport);let{config:d,issues:f}=J6(JSON.stringify(u));if(!d){L(t,400,{error:f.join(`; `)});return}NLt(a,d),ILt(n.stateDir,{id:i,url:d.url,path:d.path});let p=await n.previewProxies.ensure({id:i,targetOrigin:d.url,viewerOrigin:m9(n),bridgeScriptUrl:h9(n)}),m=await e8(d.url);L(t,200,{config:d,proxyUrl:p.origin,upstreamAlive:m})}},$qt={path:Uqt,methods:[`POST`],auth:`same-origin`,async handle(e,t,n,{match:r}){let i=decodeURIComponent(r[1]);if(!Z6(n.root,i)){L(t,404,{error:`preview/${i} not found`});return}let a=zLt(await o9(e));if(!a){L(t,400,{error:`invalid preview comment operation`});return}let o=n.previewComments.applyHuman(i,a),s=null;a.op===`create`&&(s=Lqt({artifact:`preview/${i}`,explicitSession:a.session,projectRoot:g9(n),sessions:n.agentStatus.sessions(),stateDir:n.stateDir})),L(t,200,{...o,routedSession:s})}},eJt={path:Wqt,methods:[`POST`],auth:`same-origin`,async handle(e,t,n,{match:r}){let i=decodeURIComponent(r[1]);if(!Z6(n.root,i)){L(t,404,{error:`preview/${i} not found`});return}let a=await o9(e),o=m.default.join(n.stateDir,`preview`,i,`selection.json`);if(!a||a.selected===null){try{f.default.rmSync(o,{force:!0})}catch{}L(t,200,{ok:!0})}else vt(o,{artifact:`preview/${i}`,updatedAt:(/* @__PURE__ */ new Date()).toISOString(),selected:a.selected}),L(t,200,{ok:!0})}},tJt={path:Kqt,methods:[`POST`],auth:`agent`,async handle(e,t,n,{match:r}){let i=decodeURIComponent(r[1]);if(!Z6(n.root,i)){L(t,404,{error:`preview/${i} not found`});return}let a=await o9(e),o=typeof a==`object`&&a?a:{},s=f9(o);if(o.op===`list`){L(t,200,{type:`comments`,artifact:`preview/${i}`,threads:n.previewComments.list(i,s??`Agent`,o.all===!0)});return}let c=BLt(a);if(!c)L(t,400,{error:`not a preview agent comment op: use list, add {anchor, text}, reply {threadId, text} or resolve {threadId}`});else try{L(t,200,n.previewComments.applyAgent(i,c,s))}catch(e){L(t,400,{error:e.message})}}},nJt=/^\/api\/report\/([^/]+)\/refresh$/,rJt=/^\/api\/report\/([^/]+)\/history(?:\/(\d+))?$/,iJt=/^\/api\/report\/([^/]+)\/state$/,aJt=/^\/api\/report\/([^/]+)\/comments$/,oJt=/^\/api\/agent\/report\/([^/]+)\/comments$/,sJt=/^(?:127\.\d+\.\d+\.\d+|::1|::ffff:127\.\d+\.\d+\.\d+)$/,cJt=e=>sJt.test(e.socket.remoteAddress??``);function lJt(e,t){try{return Zut(JSON.parse(f.default.readFileSync(m.default.join(e,SW,`${t}.json`),`utf8`)))}catch{return null}}const uJt={path:nJt,auth:`viewer`,methods:[`POST`],handle:async(e,t,n,{match:r})=>{if(!cJt(e)){L(t,403,{error:`data sources only run from this machine`});return}let i=r[1],a=UV(n.root,`report`,i);if(!a){L(t,404,{error:`report/${i} not found`});return}let o=await o9(e),s=o&&typeof o==`object`&&typeof o.source==`string`?o.source:null,{sources:c,issues:l}=bW(a),u=s?[s]:c.map(e=>e.id),d=await Promise.all(u.map(e=>n.sourceRunner.run(a,`report/${i}`,e)));L(t,200,{issues:l,sources:u.map((e,t)=>({id:e,...d[t],shape:d[t].ok?lJt(a,e):null}))})}},dJt={path:iJt,auth:`viewer`,handle:(e,t,n,{match:r})=>{let i=r[1];UV(n.root,`report`,i)?L(t,200,n.reportComments.state(i)):L(t,404,{error:`report/${i} not found`})}},fJt={path:aJt,methods:[`POST`],auth:`same-origin`,handle:async(e,t,n,{match:r})=>{let i=r[1];if(!UV(n.root,`report`,i)){L(t,404,{error:`report/${i} not found`});return}let a=lRt(await o9(e));if(!a)L(t,400,{error:`not a report comment op`});else try{L(t,200,n.reportComments.apply(i,a))}catch(e){L(t,400,{error:e.message})}}},pJt={path:oJt,methods:[`POST`],auth:`agent`,handle:async(e,t,n,{match:r})=>{let i=r[1];if(!UV(n.root,`report`,i)){L(t,404,{error:`report/${i} not found`});return}let a=await o9(e),o=typeof a==`object`&&a?a:{},s=uRt(o);if(!s)L(t,400,{error:`not an agent comment op: use add {block, point?, row?, text}, reply {threadId, text} or resolve {threadId}; text must not be empty`});else try{L(t,200,n.reportComments.applyAgent(i,s,f9(o)))}catch(e){L(t,400,{error:e.message})}}},mJt={path:rJt,auth:`viewer`,handle:(e,t,n,{match:r})=>{let i=r[1],a=UV(n.root,`report`,i);if(!a){L(t,404,{error:`report/${i} not found`});return}if(r[2]===void 0){L(t,200,{entries:n.reportHistory.list(i,a)});return}let o=n.reportHistory.diff(i,Number(r[2]));o===null?L(t,404,{error:`no history entry ${r[2]}`}):L(t,200,{lines:o})}},hJt=/^\/api\/whiteboard\/([^/]+)\/scene$/,gJt=/^\/api\/whiteboard\/([^/]+)\/pages$/,_Jt=/^\/api\/whiteboard\/([^/]+)\/comments$/,vJt=/^\/api\/whiteboard\/([^/]+)\/(geometry|render)$/;async function _9(e,t){let n=[],r=0;for await(let i of e){if(r+=i.length,r>t)return null;n.push(i)}return Buffer.concat(n)}const yJt=(e,t,n)=>e.whiteboards.livePages(t).some(e=>e.id===n),bJt={path:hJt,auth:`viewer`,handle:(e,t,n,{match:r,url:i})=>{let a=r[1],o=i.searchParams.get(`page`)??`main`,s=yJt(n,a,o)?n.whiteboards.scene(a,o):null;s?L(t,200,{scene:s,page:o,pages:n.whiteboards.pages(a),problem:n.whiteboards.problem(a,o),comments:n.whiteboardComments.comments(a),stale:n.whiteboardComments.stale(a),orphans:n.whiteboardComments.orphans(a)}):L(t,404,{error:`whiteboard/${a} page ${o} not found`})}},xJt={path:gJt,auth:`viewer`,handle:(e,t,n,{match:r})=>{let i=r[1];if(!UV(n.root,`whiteboard`,i)){L(t,404,{error:`whiteboard/${i} not found`});return}let a={};for(let e of n.whiteboards.livePages(i))for(let t of n.whiteboards.scene(i,e.id)?.elements??[])t.type===`frame`&&!t.isDeleted&&!(t.id in a)&&(a[t.id]={name:typeof t.name==`string`?t.name:``,page:e.id});let o=n.whiteboards.scene(i)?.appState.name;L(t,200,{pages:n.whiteboards.pages(i),title:typeof o==`string`?o:``,frames:a})}},SJt={path:vJt,methods:[`POST`],auth:`same-origin`,handle:async(e,t,n,{match:r,url:i})=>{let[,a=``,o]=r,s=await _9(e,o===`render`?8388608:2097152);if(!s){ae(t,413,`Too large`);return}let c=i.searchParams.get(`page`)??`main`,l=!1;if(!yJt(n,a,c))l=!1;else if(o===`render`){let e=i.searchParams.get(`version`);l=e!==null&&/^\d+$/.test(e)?n.whiteboards.reportRender(a,s,Number(e),c):!1}else try{l=n.whiteboards.reportGeometry(a,JSON.parse(s.toString(`utf8`)),c)}catch{l=!1}if(!l){L(t,400,{error:`not a whiteboard ${o} report`});return}let u=UV(n.root,`whiteboard`,a);u&&n.writeState({type:`whiteboard`,id:a},u),ae(t,204,``)}},CJt={path:_Jt,methods:[`POST`],auth:`same-origin`,handle:async(e,t,n,{match:r})=>{let i=r[1];if(!UV(n.root,`whiteboard`,i)){L(t,404,{error:`whiteboard/${i} not found`});return}let a=OHt(await o9(e));if(!a)L(t,400,{error:`not a whiteboard comment op`});else try{L(t,200,{comments:n.whiteboardComments.apply(i,a),stale:n.whiteboardComments.stale(i),orphans:n.whiteboardComments.orphans(i)})}catch(e){L(t,400,{error:e.message})}}},wJt=e=>e.replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`),v9=(e,t)=>e.lastIndexOf(`
|
|
1871
1871
|
`,t-1)+1;function y9(e,t){let n=e.slice(v9(e,t),t);return/^[ \t]*$/.test(n)?n:null}const b9=(e,t)=>`${t}<notes>\n${e.map(e=>`${t} ${e}`).join(`<br/>
|
|
1872
|
-
`)}\n${t}</notes>`;function TJt(e,t,n){let{root:r,errors:i}=fU(e);if(!r||i.length>0)return null;let a=r.children.flatMap(e=>uU(e)&&e.name===`group`?e.children:[e]).find(e=>uU(e)&&e.name===`slide`&&e.attrs.get(`id`)===t);if(!a)return null;let o=a.children.find(e=>uU(e)&&e.name===`notes`),s=n.trim().split(/\r?\n/).map(e=>wJt(e.trim()));if(!n.trim()){if(!o)return e;let t=y9(e,o.start)!==null&&/^[ \t]*(?:\n|$)/.test(e.slice(o.end))?v9(e,o.start)-1:o.start;return e.slice(0,Math.max(t,0))+e.slice(o.end)}if(o){let t=y9(e,o.start),n=t===null?`<notes>${s.join(`<br/>`)}</notes>`:b9(s,t).trimStart();return e.slice(0,o.start)+n+e.slice(o.end)}if(a.selfClosing){let t=y9(e,a.start)??``,n=e.slice(a.start,a.end).replace(/\s*\/>$/,`>`);return`${e.slice(0,a.start)}${n}\n${b9(s,`${t} `)}\n${t}</slide>${e.slice(a.end)}`}let c=a.innerEnd,l=y9(e,c);if(l===null)return`${e.slice(0,c)}<notes>${s.join(`<br/>`)}</notes>${e.slice(c)}`;let u=v9(e,c)-1;return`${e.slice(0,u)}\n${b9(s,`${l} `)}${e.slice(u)}`}const EJt=/^\/api\/slides\/([^/]+)\/state$/,DJt=/^\/api\/slides\/([^/]+)\/comments$/,OJt=/^\/api\/slides\/([^/]+)\/notes$/,kJt=/^\/api\/slides\/([^/]+)\/structure$/,AJt=/^\/api\/slides\/([^/]+)\/sheet$/,jJt=/^\/api\/agent\/slides\/([^/]+)\/comments$/,MJt={path:EJt,auth:`viewer`,handle:(e,t,n,{match:r})=>{let i=r[1];UV(n.root,`slides`,i)?L(t,200,n.slidesComments.state(i)):L(t,404,{error:`slides/${i} not found`})}},NJt={path:DJt,methods:[`POST`],auth:`same-origin`,handle:async(e,t,n,{match:r})=>{let i=r[1];if(!UV(n.root,`slides`,i)){L(t,404,{error:`slides/${i} not found`});return}let a=Ftt(await o9(e));if(!a)L(t,400,{error:`not a slides comment op`});else try{n.slidesComments.apply(i,a),L(t,200,n.slidesComments.state(i))}catch(e){L(t,400,{error:e.message})}}},PJt={path:jJt,methods:[`POST`],auth:`agent`,handle:async(e,t,n,{match:r})=>{let i=r[1];if(!UV(n.root,`slides`,i)){L(t,404,{error:`slides/${i} not found`});return}let a=await o9(e),o=typeof a==`object`&&a?a:{},s=Itt(o);if(!s)L(t,400,{error:`not an agent comment op: use add {slide, text}, reply {threadId, text} or resolve {threadId}; text must not be empty`});else try{L(t,200,n.slidesComments.applyAgent(i,s,f9(o)))}catch(e){L(t,400,{error:e.message})}}},FJt={path:OJt,methods:[`POST`],auth:`same-origin`,handle:async(e,t,n,{match:r})=>{let i=r[1],a=UV(n.root,`slides`,i),o=a&&sK(a);if(!a||!o){L(t,404,{error:`slides/${i} not found`});return}let s=await o9(e),{slide:c,notes:l}=typeof s==`object`&&s?s:{};if(typeof c!=`string`||!c||c.length>DU.id||typeof l!=`string`||l.length>DU.notes){L(t,400,{error:`send {slide, notes}: a slide id and the notes as text`});return}let u=o.source===`xml`,d=u?ut(a,o.origins.get(c)??`deck.xml`):m.default.join(a,oK),p=d&&f.default.readFileSync(d,`utf8`),h=typeof p==`string`?(u?TJt:zzt)(p,c,l):null;!d||h===null?L(t,404,{error:`slides/${i} has no slide ${c}`}):(h!==p&&Bzt(d,h),L(t,200,{ok:!0}))}},IJt={path:kJt,methods:[`POST`],auth:`same-origin`,handle:async(e,t,n,{match:r})=>{let i=r[1],a=UV(n.root,`slides`,i);if(!a){L(t,404,{error:`slides/${i} not found`});return}let o=mBt(a,i,m.default.join(n.root,`.state`),await o9(e,50331648));o.status===200&&n.writeState({type:`slides`,id:i},a),L(t,o.status,o.body)}},LJt=e=>e!==null&&/^\d+$/.test(e)?Number(e):-1,RJt={path:AJt,methods:[`POST`],auth:`same-origin`,handle:async(e,t,n,{match:r,url:i})=>{let a=r[1],o=UV(n.root,`slides`,a);if(!o){L(t,404,{error:`slides/${a} not found`});return}let s=Number(i.searchParams.get(`version`)??NaN),c=i.searchParams.get(`failed`);if(c!==null&&Number.isFinite(s)){if(s!==mK(o,a).version){L(t,409,{error:`slides/${a} has changed since this sheet was drawn`});return}let e=c.replaceAll(/\p{Cc}+/gu,` `).trim();n.slidesSheets.fail(a,s,e.slice(0,DU.text)||`unknown`),n.writeState({type:`slides`,id:a},o),L(t,200,{ok:!0});return}let l=LJt(i.searchParams.get(`index`)),u=LJt(i.searchParams.get(`count`));if(!Number.isFinite(s)||u<1||u>DU.sheets||l<0||l>=u){L(t,400,{error:`send ?version=&index=&count= with a PNG as the body`});return}let d=await _9(e,DU.sheetBytes);if(!d){L(t,413,{error:`a sheet is at most 4 MB`});return}if(!xRt(d)){L(t,400,{error:`a sheet is a PNG`});return}if(s!==mK(o,a).version){L(t,409,{error:`slides/${a} has changed since this sheet was drawn`});return}let f=n.slidesSheets.put(a,{version:s,index:l,count:u},d);f&&n.writeState({type:`slides`,id:a},o),L(t,200,{ok:!0,complete:f})}},x9=e=>({status:400,body:{error:e}});function zJt(e,t,n,r){let{shot:i,hash:a,index:o,delta:s}=typeof r==`object`&&r?r:{};if(typeof i!=`string`||typeof a!=`string`)return x9(`send {shot, hash, index, delta}`);if(typeof o!=`number`||!Number.isInteger(o)||o<0)return x9(`index must be a whole number from 0`);if(typeof s!=`number`||!Number.isFinite(s)||Math.abs(s)>3600)return x9(`delta must be a number of seconds`);let c;try{c=f.default.readFileSync(m.default.join(e,De.storyboard),`utf8`)}catch{return{status:404,body:{error:`${De.storyboard} not found`}}}let l=IVt(WU(c).model?.shots.find(e=>e.id===i));if(!l)return x9(`shot ${i} does not show a page with overlays`);let u=m.default.join(e,l),d;try{d=f.default.readFileSync(u,`utf8`)}catch{return x9(`${l} not found`)}if(K5(d)!==a)return{status:409,body:{error:`${l} changed`,hash:K5(d)}};let p;try{p=kVt(d,o,s)}catch(e){return x9(e.message)}let h=W5(d)[o],g=W5(p)[o],_=g.start-h.start,v=`${u}.${process.pid}.${Date.now()}.tmp`;f.default.writeFileSync(v,p),f.default.renameSync(v,u);let y=e=>`${Math.round(e*1e3)/1e3}s`;return Q5(n,t).append([`moved the ${h.kind} overlay in shot "${i}" (${l}) from ${y(h.start)} to ${y(g.start)}`]),{status:200,body:{hash:K5(p),applied:Math.round(_*1e3)/1e3}}}const BJt=/^\/api\/storyboard\/([^/]+)\/voice$/,VJt=/^\/api\/storyboard\/([^/]+)\/cut$/,HJt=/^\/api\/storyboard\/([^/]+)\/state$/,UJt=/^\/api\/storyboard\/([^/]+)\/comments$/,WJt=/^\/api\/agent\/storyboard\/([^/]+)\/comments$/,GJt=/^\/api\/storyboard\/([^/]+)\/edit$/,KJt=/^\/api\/storyboard\/([^/]+)\/overlay$/,qJt=/^\/api\/storyboard\/([^/]+)\/sound$/,JJt=/^\/api\/storyboard\/([^/]+)\/export$/,YJt=/^\/api\/storyboard\/([^/]+)\/export\/snapshot$/,S9=262144,XJt=/^(?:127\.\d+\.\d+\.\d+|::1|::ffff:127\.\d+\.\d+\.\d+)$/,C9=e=>XJt.test(e.socket.remoteAddress??``),ZJt={path:BJt,auth:`viewer`,methods:[`POST`],handle:async(e,t,n,{match:r})=>{if(!C9(e)){L(t,403,{error:`voices are only made from this machine`});return}let i=r[1],a=UV(n.root,`storyboard`,i);if(!a){L(t,404,{error:`storyboard/${i} not found`});return}let o=await o9(e),s=typeof o==`object`&&o?o:{},c=await n.voiceRunner.synthesize(a,`storyboard/${i}`,{...typeof s.line==`string`?{line:s.line}:{},force:s.force===!0});L(t,c.error?409:200,c)}},QJt={path:GJt,methods:[`POST`],auth:`same-origin`,handle:async(e,t,n,{match:r})=>{let i=r[1],a=UV(n.root,`storyboard`,i);if(!a){L(t,404,{error:`storyboard/${i} not found`});return}let o=KVt(a,i,m.default.join(n.root,`.state`),await o9(e,S9));o.status===200&&n.writeState({type:`storyboard`,id:i},a),L(t,o.status,o.body)}},$Jt={path:KJt,methods:[`POST`],auth:`same-origin`,handle:async(e,t,n,{match:r})=>{let i=r[1],a=UV(n.root,`storyboard`,i);if(!a){L(t,404,{error:`storyboard/${i} not found`});return}let o=zJt(a,i,m.default.join(n.root,`.state`),await o9(e,S9));o.status===200&&n.writeState({type:`storyboard`,id:i},a),L(t,o.status,o.body)}},eYt={path:qJt,methods:[`POST`],auth:`same-origin`,handle:async(e,t,n,{match:r,url:i})=>{if(!C9(e)){L(t,403,{error:`sounds are only added from this machine`});return}let a=r[1],o=UV(n.root,`storyboard`,a);if(!o){L(t,404,{error:`storyboard/${a} not found`});return}let s=VVt(i.searchParams.get(`name`)??``);if(!s){L(t,400,{error:`send ?name= with an mp3, wav, m4a or ogg file name`});return}let c=Number(e.headers[`content-length`]??0)>52428800?null:await _9(e,52428800);if(!c){L(t,413,{error:`a sound file is at most 50 MB`});return}let l=HVt(o,s,c);n.writeState({type:`storyboard`,id:a},o),L(t,200,{file:l})}},tYt={path:JJt,auth:`viewer`,methods:[`GET`,`POST`,`DELETE`],handle:(e,t,n,{match:r})=>{if(!C9(e)){L(t,403,{error:`exports only run from this machine`});return}let i=r[1],a=`storyboard/${i}`,o=UV(n.root,`storyboard`,i);if(!o){L(t,404,{error:`${a} not found`});return}if(e.method===`DELETE`){L(t,n.exportRunner.cancel(a)?200:409,n.exportRunner.status(a)??{});return}if(e.method===`GET`){L(t,200,n.exportRunner.status(a)??{});return}let s=n.exportRunner.start(o,a);s.ok?L(t,202,n.exportRunner.status(a)):L(t,s.status,{error:s.error})}},nYt={path:YJt,auth:`viewer`,handle:(e,t,n,{match:r})=>{if(!C9(e)){L(t,403,{error:`exports only run from this machine`});return}let i=r[1],a=UV(n.root,`storyboard`,i),o=a?n.exportRunner.snapshot(`storyboard/${i}`):null;!a||!o?L(t,404,{error:`no export of storyboard/${i} is running`}):L(t,200,{...o,contentBase:`${n.contentPrefix}storyboard/${i}/`})}},rYt={path:HJt,auth:`viewer`,handle:(e,t,n,{match:r})=>{let i=r[1];UV(n.root,`storyboard`,i)?L(t,200,n.storyboardComments.state(i)):L(t,404,{error:`storyboard/${i} not found`})}},iYt={path:UJt,methods:[`POST`],auth:`same-origin`,handle:async(e,t,n,{match:r})=>{let i=r[1];if(!UV(n.root,`storyboard`,i)){L(t,404,{error:`storyboard/${i} not found`});return}let a=xnt(await o9(e,524288));if(!a)L(t,400,{error:`not a storyboard comment op`});else try{L(t,200,n.storyboardComments.apply(i,a))}catch(e){L(t,400,{error:e.message})}}},aYt={path:WJt,methods:[`POST`],auth:`agent`,handle:async(e,t,n,{match:r})=>{let i=r[1];if(!UV(n.root,`storyboard`,i)){L(t,404,{error:`storyboard/${i} not found`});return}let a=await o9(e),o=typeof a==`object`&&a?a:{},s=f9(o);if(o.op===`list`){L(t,200,{type:`comments`,artifact:`storyboard/${i}`,threads:n.storyboardComments.list(i,s??`Agent`,o.all===!0)});return}let c=wnt(o);if(!c)L(t,400,{error:`not an agent comment op: use list, add {shot, line? | at?} or {cut, at}, reply {threadId, text} or resolve {threadId}; text must not be empty`});else try{L(t,200,n.storyboardComments.applyAgent(i,c,s))}catch(e){L(t,400,{error:e.message})}}},oYt={path:VJt,auth:`viewer`,methods:[`POST`],handle:async(e,t,n,{match:r})=>{if(!C9(e)){L(t,403,{error:`cuts are only registered from this machine`});return}let i=r[1],a=UV(n.root,`storyboard`,i);if(!a){L(t,404,{error:`storyboard/${i} not found`});return}let o=await o9(e,S9),s=typeof o==`object`&&o?o:{};if(typeof s.file!=`string`||!m.default.isAbsolute(s.file))L(t,400,{error:`send {file, map?, master?} with an absolute file path`});else try{let e=vnt(a,{file:s.file,...s.map===void 0?{}:{map:s.map},...typeof s.master==`string`?{master:s.master}:{}});n.writeState({type:`storyboard`,id:i},a),L(t,200,e)}catch(e){if(e instanceof KU)L(t,400,{error:e.message});else throw e}}},sYt=/^\/api\/agent\/verify\/([^/]+)\/comments$/,w9=e=>typeof e==`string`?e:``;function cYt(e,t,n){let r=w9(n.agent).trim()||void 0;if(n.op===`list`)return{type:`report`,artifact:`verify/${t}`,...e.view(t),threads:e.threads(t).map(({id:e,anchor:t,status:n,stale:r,messages:i})=>({id:e,anchor:{...t,hash:void 0},status:n,stale:r,messages:i.map(({author:e,text:t,at:n})=>({author:e,text:t,at:n}))}))};if(n.op===`verdict`){if(n.verdict!==`pass`&&n.verdict!==`reject`)throw Error(`verdict needs {verdict: "pass" | "reject"}`);if(n.all!==!0&&!w9(n.claim))throw Error(`verdict needs {claim} or {all: true}`);return e.applyAgent(t,{op:`verdict`,verdict:n.verdict,text:w9(n.text),...n.all===!0?{all:!0}:{claim:w9(n.claim)}},r)}if(n.op===`waive`){if(!w9(n.gap))throw Error(`waive needs {gap}`);return e.applyAgent(t,{op:`waive`,gap:w9(n.gap)},r)}if(n.op===`reply`){if(!w9(n.threadId))throw Error(`reply needs {threadId}`);let i=e.applyAgent(t,{op:`reply`,threadId:w9(n.threadId),text:w9(n.text)},r);return{...i,threadId:i.threadIds[0]}}throw Error(`a report takes list, verdict, waive or reply`)}const lYt={path:sYt,methods:[`POST`],auth:`agent`,handle:async(e,t,n,{match:r})=>{let i=r[1];if(!UV(n.root,`verify`,i)){L(t,404,{error:`verify/${i} not found`});return}let a=await o9(e),o=typeof a==`object`&&a?a:{};try{L(t,200,cYt(n.verify,i,o))}catch(e){L(t,400,{error:e.message})}}};function uYt(e,t){if(e===`asks`)return e=>e.state===`submitted`;if(e===`rounds`)return e=>e.state===`open`||e.state===`submitted`;let n=new Set(t.filter(e=>e.state===`submitted`).map(e=>e.id));return e=>e.kind===`verify`?e.verdict===`reject`:n.has(e.round)}const T9=`ryugi.review/v1`,E9=e=>typeof e==`string`?e:void 0;function dYt(e,t){let n=e.filters&&typeof e.filters==`object`?e.filters:void 0,r={artifact:t,agent:typeof e.agent==`string`&&e.agent.length>0&&e.agent.length<=100?e.agent:`Agent`,limit:e.limit===void 0?void 0:Number(e.limit),cursor:E9(e.cursor),snapshot:E9(e.snapshot),detail:e.detail===!0,all:e.all===!0,thread:E9(e.thread),fields:Array.isArray(e.fields)&&e.fields.every(e=>typeof e==`string`)?e.fields:void 0,...n?{filters:n}:{}};if(r.limit!==void 0&&(!Number.isInteger(r.limit)||r.limit<1||r.limit>100))throw new H7(`E_ARGUMENT_INVALID`,`limit must be between 1 and 100.`);return r}function fYt(e){let t=e.session;if(typeof t!=`object`||!t)return null;let{host:n,id:r}=t;return n!==`claude`&&n!==`codex`||typeof r!=`string`?null:r.length>0&&r.length<=200?{host:n,id:r}:null}function pYt(e,t,n,r){let i=fYt(t);if(!i||!(n.detail||n.thread)||n.fields)return r;let a=r.items.flatMap(e=>typeof e.id==`string`?[e.id]:[]);return a.length&&e.deliverThreads(n.artifact,i.host,i.id,a),r}async function D9(e,t,n,r){if(t===`document`){await kK(e,`document/${n}`);let t=new Map(e.documents.listComments(n,r.agent,!0).map(e=>[e.id,e])),i=e.documents.comments(n);return e.agentReview.threads({...r,threads:i.threads.filter(e=>!bH(e)).map(e=>({...e,...t.get(e.id),messages:e.messages.map(({avatar:e,...t})=>t)}))})}if(t===`whiteboard`){let t=new Map(e.whiteboardComments.list(n,r.agent,!0).map(e=>[e.id,e]));return e.agentReview.threads({...r,threads:e.whiteboardComments.comments(n).threads.map(e=>({...e,...t.get(e.id),messages:e.messages.map(({avatar:e,...t})=>t)}))})}if(t===`report`){let t=new Map(e.reportComments.list(n,r.agent,!0).map(e=>[e.id,e]));return e.agentReview.threads({...r,threads:e.reportComments.comments(n).threads.map(e=>{let n=t.get(e.id);return{...e,...n,anchor:n?.dataChanged?{...e.anchor,dataChanged:!0}:e.anchor,messages:e.messages.map(({avatar:e,...t})=>t)}})})}if(t===`preview`){let t=e.previewComments.agentView(n);return e.agentReview.threads({...r,threads:e.previewComments.comments(n).threads.map(e=>{let n=t(e);return{...e,...n,anchor:{...e.anchor,...n.cropPath?{cropPath:n.cropPath}:{}},messages:n.messages}})})}if(t===`storyboard`){let t=e.storyboardComments.agentView(n);return e.agentReview.threads({...r,threads:e.storyboardComments.comments(n).threads.map(e=>{let n=t(e);return{...e,...n,anchor:{...e.anchor,...n.title===null?{deleted:!0}:{title:n.title,number:n.number},...n.lineText===null?{}:{lineText:n.lineText},...n.cropPath?{cropPath:n.cropPath}:{}},messages:n.messages}})})}if(t===`slides`){let t=new Map(e.slidesComments.list(n,r.agent,!0).map(e=>[e.id,e]));return e.agentReview.threads({...r,threads:e.slidesComments.comments(n).threads.map(e=>{let n=t.get(e.id);return{...e,...n,anchor:n&&n.number!==null?{...e.anchor,number:n.number,title:n.title}:e.anchor,messages:e.messages.map(({avatar:e,...t})=>t)}})})}await kK(e,`artboard/${n}`);let i=new Map(e.boardComments.list(n,r.agent,!0).map(e=>[e.id,e])),a=e.boardComments.comments(n);return e.agentReview.threads({...r,threads:a.threads.filter(e=>!zH(e)).map(e=>({...e,...i.get(e.id),messages:e.messages.map(({avatar:e,...t})=>t)}))})}async function O9(e,t,n,r,i){let a=[],o=[];return i===`asks`&&t===`document`?a=(await e.documents.asks(n)).asks.map(e=>({...e})):i===`groups`&&t===`artboard`?(a=e.boardComments.groups(n).map(e=>({...e})),o=e.boardComments.rounds(n).map(e=>({...e}))):i===`rounds`&&t===`artboard`&&(a=e.boardComments.rounds(n).map(e=>({...e}))),e.agentReview.state({...r,section:i,items:a,actionable:uYt(i,o)})}function mYt(e,t){let n=FGt({...e,section:t});if(n)throw new H7(`E_ARGUMENT_INVALID`,n)}async function hYt(e,t,n,r,i,a){try{if(!(r===`preview`?Z6(n.root,i):UV(n.root,r,i)))throw new H7(`E_ARTIFACT_NOT_FOUND`,`${r}/${i} not found.`,404);let o=await o9(e);if(!o||typeof o!=`object`||Array.isArray(o))throw new H7(`E_ARGUMENT_INVALID`,`Expected a review request.`);let s=o,c=dYt(s,`${r}/${i}`);if(s.op===`ack`){if(typeof s.receipt!=`string`)throw new H7(`E_ARGUMENT_INVALID`,`An acknowledgement receipt is required.`);let{to:e,...o}=n.agentReview.ack({...c,receipt:s.receipt,kind:a===`changes`?`changes`:`threads`});(r===`slides`||r===`storyboard`)&&a===`changes`&&e&&(r===`slides`?iBt(m.default.join(n.root,`.state`),i,e):Q5(m.default.join(n.root,`.state`),i).markSeen(e),n.writeState({type:r,id:i},UV(n.root,r,i))),n.reviewListeners.forEach(e=>e(c.artifact)),L(t,200,{schema:T9,artifact:c.artifact,receipt:s.receipt,...o});return}if(a===`changes`&&(r===`slides`||r===`storyboard`)){if(c.detail&&(c.limit!==void 0||c.cursor||c.fields))throw new H7(`E_ARGUMENT_INVALID`,`A complete diff cannot use pagination or fields.`);let e=m.default.join(n.root,`.state`),a=await n.agentReview.changes({...c,load:async t=>r===`slides`?aBt(e,i,t):Q5(e,i).since(t)});L(t,200,{schema:T9,artifact:c.artifact,...a});return}if(a===`changes`){if(r!==`document`)throw new H7(`E_ARGUMENT_INVALID`,`Changes apply to documents only.`);if(c.detail&&(c.limit!==void 0||c.cursor||c.fields))throw new H7(`E_ARGUMENT_INVALID`,`A complete diff cannot use pagination or fields.`);let e=await n.documents.open(i);if(!e)throw new H7(`E_ARTIFACT_NOT_FOUND`,`Document not found.`,404);let a=await n.agentReview.changes({...c,load:t=>e.changesSince(t)});L(t,200,{schema:T9,artifact:c.artifact,...a});return}let l=s.op===`read`?`threads`:E9(s.section);if(s.op!==`list`&&s.op!==`read`)throw new H7(`E_ARGUMENT_INVALID`,`Expected list, read or ack.`);if(s.op===`read`&&!c.thread)throw new H7(`E_ARGUMENT_INVALID`,`A thread ID is required.`);if(s.sections!==void 0){if(s.op!==`list`||!Array.isArray(s.sections)||!s.sections.every(e=>typeof e==`string`))throw new H7(`E_ARGUMENT_INVALID`,`sections requires a list of collection names and op=list.`);let e=PGt({...c,section:l,sections:s.sections},c.artifact);if(e)throw new H7(`E_ARGUMENT_INVALID`,e);let a={};for(let e of s.sections)a[e]=e===`threads`?pYt(n,s,c,await D9(n,r,i,c)):await O9(n,r,i,c,e);L(t,200,{schema:T9,artifact:c.artifact,sections:a});return}if(mYt(c,l),l===`threads`)L(t,200,{schema:T9,artifact:c.artifact,section:l,...pYt(n,s,c,await D9(n,r,i,c))});else if(l===`asks`||l===`groups`||l===`rounds`)L(t,200,{schema:T9,artifact:c.artifact,section:l,...await O9(n,r,i,c,l)});else{let e=await D9(n,r,i,{...c,limit:1}),a=await O9(n,r,i,c,`asks`),o=await O9(n,r,i,c,`groups`),s=await O9(n,r,i,c,`rounds`);L(t,200,{schema:T9,artifact:c.artifact,summary:{threads:e.page.total,waitingOnAgent:e.summary?.waitingOnAgent??0,asks:a.summary,groups:o.summary,rounds:s.summary}})}}catch(e){let n=e instanceof H7;L(t,n?e.status:500,{schema:T9,code:n?e.code:`E_REVIEW_FAILED`,error:e instanceof Error?e.message:String(e)})}}const gYt={path:/^\/api\/agent\/v1\/(document|artboard|whiteboard|slides|report|storyboard|preview)\/([^/]+)\/(review|changes)$/,methods:[`POST`],auth:`agent`,handle:(e,t,n,{match:r})=>hYt(e,t,n,r[1],r[2],r[3])},_Yt=`var(--ink)`,vYt=/^(#[0-9a-f]{3,8}|[a-z]{3,20})$/i,yYt=/* @__PURE__ */ new Set([`#000`,`#000000`,`#1e1e1e`,`#222`,`#222222`,`#333`,`#333333`,`black`]),bYt=e=>e.replaceAll(/[&<>"']/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`})[e]),k9=(e,t=0)=>typeof e==`number`&&Number.isFinite(e)&&Math.abs(e)<=1e7?e:t,A9=(e,t,n=!1)=>typeof e!=`string`||!vYt.test(e)?t:e===`transparent`?`none`:n&&yYt.has(e.toLowerCase())?_Yt:e,xYt=e=>Array.isArray(e.points)?e.points.filter(e=>Array.isArray(e)).map(([e,t])=>[k9(e),k9(t)]):[];function SYt(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e){let e=k9(a.x),o=k9(a.y),s=[[0,0],[k9(a.width),k9(a.height)],...xYt(a)];for(let[a,c]of s)t=Math.min(t,e+a),n=Math.min(n,o+c),r=Math.max(r,e+a),i=Math.max(i,o+c)}return Number.isFinite(t)?{minX:t,minY:n,maxX:r,maxY:i}:null}const j9=e=>Math.round(e*10)/10,M9=e=>[...e].reduce((e,t)=>e+(t.codePointAt(0)>=11904?1:.55),0);function CYt(e,t,n,r,i){let a=t.step*.5;return e.map((e,o)=>{if(!e.trim())return``;let s=Math.min(t.width,Math.max(a,n(e))),c=r===`center`?t.x+(t.width-s)/2:r===`right`?t.x+t.width-s:t.x,l=t.y+t.step*o+(t.step-a)/2;return`<rect x="${j9(c)}" y="${j9(l)}" width="${j9(s)}" height="${j9(a)}" rx="${j9(a/2)}" fill="${i}" fill-opacity=".28"/>`}).join(``)}function wYt(e,t){if(e.length<2)return``;let[n,r]=e.at(-2),[i,a]=e.at(-1),o=Math.atan2(a-r,i-n),s=7.5,c=Math.PI/6.5;return`<polyline points="${j9(i-s*Math.cos(o-c))},${j9(a-s*Math.sin(o-c))} ${i},${a} ${j9(i-s*Math.cos(o+c))},${j9(a-s*Math.sin(o+c))}" stroke="${t}" stroke-width="1.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/>`}function TYt(e,t,n){let r=k9(e.x),i=k9(e.y),a=k9(e.width)*n,o=k9(e.height)*n,s=A9(e.strokeColor,_Yt,!0),c=`stroke="${s}" stroke-width="1.5" fill="${A9(e.backgroundColor,`none`)}"`,[l,u]=t(r,i);switch(e.type){case`rectangle`:return`<rect x="${l}" y="${u}" width="${a}" height="${o}" rx="6" ${c}/>`;case`frame`:return`<rect x="${l}" y="${u}" width="${a}" height="${o}" rx="8" stroke="var(--border-strong)" stroke-width="1.1" stroke-dasharray="5 4" fill="none"/>`;case`ellipse`:return`<ellipse cx="${l+a/2}" cy="${u+o/2}" rx="${a/2}" ry="${o/2}" ${c}/>`;case`diamond`:return`<polygon points="${l+a/2},${u} ${l+a},${u+o/2} ${l+a/2},${u+o} ${l},${u+o/2}" ${c}/>`;case`arrow`:case`line`:case`freedraw`:{let n=xYt(e).map(([e,n])=>t(r+e,i+n));return n.length?`<polyline points="${n.map(e=>e.join(`,`)).join(` `)}" stroke="${s}" stroke-width="1.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/>${e.type===`arrow`?wYt(n,s):``}`:``}case`richtext`:{let t=`<rect x="${l}" y="${u}" width="${a}" height="${o}" rx="6" stroke="${A9(e.strokeColor,`var(--wb-sticky-edge)`,!0)}" stroke-width="1" fill="${A9(e.backgroundColor,`var(--wb-sticky)`)}" filter="url(#wb-lift)"/>`,r=Math.max(4,Math.min(16,14*n)),i=8*n,s=r*1.35,c=Math.max(1,Math.floor((o-i*2)/s));return t+CYt((e.text??``).split(`
|
|
1872
|
+
`)}\n${t}</notes>`;function TJt(e,t,n){let{root:r,errors:i}=fU(e);if(!r||i.length>0)return null;let a=r.children.flatMap(e=>uU(e)&&e.name===`group`?e.children:[e]).find(e=>uU(e)&&e.name===`slide`&&e.attrs.get(`id`)===t);if(!a)return null;let o=a.children.find(e=>uU(e)&&e.name===`notes`),s=n.trim().split(/\r?\n/).map(e=>wJt(e.trim()));if(!n.trim()){if(!o)return e;let t=y9(e,o.start)!==null&&/^[ \t]*(?:\n|$)/.test(e.slice(o.end))?v9(e,o.start)-1:o.start;return e.slice(0,Math.max(t,0))+e.slice(o.end)}if(o){let t=y9(e,o.start),n=t===null?`<notes>${s.join(`<br/>`)}</notes>`:b9(s,t).trimStart();return e.slice(0,o.start)+n+e.slice(o.end)}if(a.selfClosing){let t=y9(e,a.start)??``,n=e.slice(a.start,a.end).replace(/\s*\/>$/,`>`);return`${e.slice(0,a.start)}${n}\n${b9(s,`${t} `)}\n${t}</slide>${e.slice(a.end)}`}let c=a.innerEnd,l=y9(e,c);if(l===null)return`${e.slice(0,c)}<notes>${s.join(`<br/>`)}</notes>${e.slice(c)}`;let u=v9(e,c)-1;return`${e.slice(0,u)}\n${b9(s,`${l} `)}${e.slice(u)}`}const EJt=/^\/api\/slides\/([^/]+)\/state$/,DJt=/^\/api\/slides\/([^/]+)\/comments$/,OJt=/^\/api\/slides\/([^/]+)\/notes$/,kJt=/^\/api\/slides\/([^/]+)\/structure$/,AJt=/^\/api\/slides\/([^/]+)\/sheet$/,jJt=/^\/api\/agent\/slides\/([^/]+)\/comments$/,MJt={path:EJt,auth:`viewer`,handle:(e,t,n,{match:r})=>{let i=r[1];UV(n.root,`slides`,i)?L(t,200,n.slidesComments.state(i)):L(t,404,{error:`slides/${i} not found`})}},NJt={path:DJt,methods:[`POST`],auth:`same-origin`,handle:async(e,t,n,{match:r})=>{let i=r[1];if(!UV(n.root,`slides`,i)){L(t,404,{error:`slides/${i} not found`});return}let a=Ftt(await o9(e));if(!a)L(t,400,{error:`not a slides comment op`});else try{n.slidesComments.apply(i,a),L(t,200,n.slidesComments.state(i))}catch(e){L(t,400,{error:e.message})}}},PJt={path:jJt,methods:[`POST`],auth:`agent`,handle:async(e,t,n,{match:r})=>{let i=r[1];if(!UV(n.root,`slides`,i)){L(t,404,{error:`slides/${i} not found`});return}let a=await o9(e),o=typeof a==`object`&&a?a:{},s=Itt(o);if(!s)L(t,400,{error:`not an agent comment op: use add {slide, text}, reply {threadId, text} or resolve {threadId}; text must not be empty`});else try{L(t,200,n.slidesComments.applyAgent(i,s,f9(o)))}catch(e){L(t,400,{error:e.message})}}},FJt={path:OJt,methods:[`POST`],auth:`same-origin`,handle:async(e,t,n,{match:r})=>{let i=r[1],a=UV(n.root,`slides`,i),o=a&&sK(a);if(!a||!o){L(t,404,{error:`slides/${i} not found`});return}let s=await o9(e),{slide:c,notes:l}=typeof s==`object`&&s?s:{};if(typeof c!=`string`||!c||c.length>DU.id||typeof l!=`string`||l.length>DU.notes){L(t,400,{error:`send {slide, notes}: a slide id and the notes as text`});return}let u=o.source===`xml`,d=u?ut(a,o.origins.get(c)??`deck.xml`):m.default.join(a,oK),p=d&&f.default.readFileSync(d,`utf8`),h=typeof p==`string`?(u?TJt:zzt)(p,c,l):null;!d||h===null?L(t,404,{error:`slides/${i} has no slide ${c}`}):(h!==p&&Bzt(d,h),L(t,200,{ok:!0}))}},IJt=e=>{let t=e.undo?.files;return t?Object.keys(t):[]},LJt={path:kJt,methods:[`POST`],auth:`same-origin`,handle:async(e,t,n,{match:r})=>{let i=r[1],a=UV(n.root,`slides`,i);if(!a){L(t,404,{error:`slides/${i} not found`});return}let o=mBt(a,i,m.default.join(n.root,`.state`),await o9(e,50331648));if(o.status===200){let e=IJt(o.body);e.length>0?QV(n,{type:`slides`,id:i},e,{force:!0}):o.body.undo&&n.writeState({type:`slides`,id:i},a)}L(t,o.status,o.body)}},RJt=e=>e!==null&&/^\d+$/.test(e)?Number(e):-1,zJt={path:AJt,methods:[`POST`],auth:`same-origin`,handle:async(e,t,n,{match:r,url:i})=>{let a=r[1],o=UV(n.root,`slides`,a);if(!o){L(t,404,{error:`slides/${a} not found`});return}let s=Number(i.searchParams.get(`version`)??NaN),c=i.searchParams.get(`failed`);if(c!==null&&Number.isFinite(s)){if(s!==mK(o,a).version){L(t,409,{error:`slides/${a} has changed since this sheet was drawn`});return}let e=c.replaceAll(/\p{Cc}+/gu,` `).trim();n.slidesSheets.fail(a,s,e.slice(0,DU.text)||`unknown`),n.writeState({type:`slides`,id:a},o),L(t,200,{ok:!0});return}let l=RJt(i.searchParams.get(`index`)),u=RJt(i.searchParams.get(`count`));if(!Number.isFinite(s)||u<1||u>DU.sheets||l<0||l>=u){L(t,400,{error:`send ?version=&index=&count= with a PNG as the body`});return}let d=await _9(e,DU.sheetBytes);if(!d){L(t,413,{error:`a sheet is at most 4 MB`});return}if(!xRt(d)){L(t,400,{error:`a sheet is a PNG`});return}if(s!==mK(o,a).version){L(t,409,{error:`slides/${a} has changed since this sheet was drawn`});return}let f=n.slidesSheets.put(a,{version:s,index:l,count:u},d);f&&n.writeState({type:`slides`,id:a},o),L(t,200,{ok:!0,complete:f})}},x9=e=>({status:400,body:{error:e}});function BJt(e,t,n,r){let{shot:i,hash:a,index:o,delta:s}=typeof r==`object`&&r?r:{};if(typeof i!=`string`||typeof a!=`string`)return x9(`send {shot, hash, index, delta}`);if(typeof o!=`number`||!Number.isInteger(o)||o<0)return x9(`index must be a whole number from 0`);if(typeof s!=`number`||!Number.isFinite(s)||Math.abs(s)>3600)return x9(`delta must be a number of seconds`);let c;try{c=f.default.readFileSync(m.default.join(e,De.storyboard),`utf8`)}catch{return{status:404,body:{error:`${De.storyboard} not found`}}}let l=IVt(WU(c).model?.shots.find(e=>e.id===i));if(!l)return x9(`shot ${i} does not show a page with overlays`);let u=m.default.join(e,l),d;try{d=f.default.readFileSync(u,`utf8`)}catch{return x9(`${l} not found`)}if(K5(d)!==a)return{status:409,body:{error:`${l} changed`,hash:K5(d)}};let p;try{p=kVt(d,o,s)}catch(e){return x9(e.message)}let h=W5(d)[o],g=W5(p)[o],_=g.start-h.start,v=`${u}.${process.pid}.${Date.now()}.tmp`;f.default.writeFileSync(v,p),f.default.renameSync(v,u);let y=e=>`${Math.round(e*1e3)/1e3}s`;return Q5(n,t).append([`moved the ${h.kind} overlay in shot "${i}" (${l}) from ${y(h.start)} to ${y(g.start)}`]),{status:200,body:{hash:K5(p),applied:Math.round(_*1e3)/1e3}}}const VJt=/^\/api\/storyboard\/([^/]+)\/voice$/,HJt=/^\/api\/storyboard\/([^/]+)\/cut$/,UJt=/^\/api\/storyboard\/([^/]+)\/state$/,WJt=/^\/api\/storyboard\/([^/]+)\/comments$/,GJt=/^\/api\/agent\/storyboard\/([^/]+)\/comments$/,KJt=/^\/api\/storyboard\/([^/]+)\/edit$/,qJt=/^\/api\/storyboard\/([^/]+)\/overlay$/,JJt=/^\/api\/storyboard\/([^/]+)\/sound$/,YJt=/^\/api\/storyboard\/([^/]+)\/export$/,XJt=/^\/api\/storyboard\/([^/]+)\/export\/snapshot$/,S9=262144,ZJt=/^(?:127\.\d+\.\d+\.\d+|::1|::ffff:127\.\d+\.\d+\.\d+)$/,C9=e=>ZJt.test(e.socket.remoteAddress??``),QJt={path:VJt,auth:`viewer`,methods:[`POST`],handle:async(e,t,n,{match:r})=>{if(!C9(e)){L(t,403,{error:`voices are only made from this machine`});return}let i=r[1],a=UV(n.root,`storyboard`,i);if(!a){L(t,404,{error:`storyboard/${i} not found`});return}let o=await o9(e),s=typeof o==`object`&&o?o:{},c=await n.voiceRunner.synthesize(a,`storyboard/${i}`,{...typeof s.line==`string`?{line:s.line}:{},force:s.force===!0});L(t,c.error?409:200,c)}},$Jt={path:KJt,methods:[`POST`],auth:`same-origin`,handle:async(e,t,n,{match:r})=>{let i=r[1],a=UV(n.root,`storyboard`,i);if(!a){L(t,404,{error:`storyboard/${i} not found`});return}let o=KVt(a,i,m.default.join(n.root,`.state`),await o9(e,S9));o.status===200&&n.writeState({type:`storyboard`,id:i},a),L(t,o.status,o.body)}},eYt={path:qJt,methods:[`POST`],auth:`same-origin`,handle:async(e,t,n,{match:r})=>{let i=r[1],a=UV(n.root,`storyboard`,i);if(!a){L(t,404,{error:`storyboard/${i} not found`});return}let o=BJt(a,i,m.default.join(n.root,`.state`),await o9(e,S9));o.status===200&&n.writeState({type:`storyboard`,id:i},a),L(t,o.status,o.body)}},tYt={path:JJt,methods:[`POST`],auth:`same-origin`,handle:async(e,t,n,{match:r,url:i})=>{if(!C9(e)){L(t,403,{error:`sounds are only added from this machine`});return}let a=r[1],o=UV(n.root,`storyboard`,a);if(!o){L(t,404,{error:`storyboard/${a} not found`});return}let s=VVt(i.searchParams.get(`name`)??``);if(!s){L(t,400,{error:`send ?name= with an mp3, wav, m4a or ogg file name`});return}let c=Number(e.headers[`content-length`]??0)>52428800?null:await _9(e,52428800);if(!c){L(t,413,{error:`a sound file is at most 50 MB`});return}let l=HVt(o,s,c);n.writeState({type:`storyboard`,id:a},o),L(t,200,{file:l})}},nYt={path:YJt,auth:`viewer`,methods:[`GET`,`POST`,`DELETE`],handle:(e,t,n,{match:r})=>{if(!C9(e)){L(t,403,{error:`exports only run from this machine`});return}let i=r[1],a=`storyboard/${i}`,o=UV(n.root,`storyboard`,i);if(!o){L(t,404,{error:`${a} not found`});return}if(e.method===`DELETE`){L(t,n.exportRunner.cancel(a)?200:409,n.exportRunner.status(a)??{});return}if(e.method===`GET`){L(t,200,n.exportRunner.status(a)??{});return}let s=n.exportRunner.start(o,a);s.ok?L(t,202,n.exportRunner.status(a)):L(t,s.status,{error:s.error})}},rYt={path:XJt,auth:`viewer`,handle:(e,t,n,{match:r})=>{if(!C9(e)){L(t,403,{error:`exports only run from this machine`});return}let i=r[1],a=UV(n.root,`storyboard`,i),o=a?n.exportRunner.snapshot(`storyboard/${i}`):null;!a||!o?L(t,404,{error:`no export of storyboard/${i} is running`}):L(t,200,{...o,contentBase:`${n.contentPrefix}storyboard/${i}/`})}},iYt={path:UJt,auth:`viewer`,handle:(e,t,n,{match:r})=>{let i=r[1];UV(n.root,`storyboard`,i)?L(t,200,n.storyboardComments.state(i)):L(t,404,{error:`storyboard/${i} not found`})}},aYt={path:WJt,methods:[`POST`],auth:`same-origin`,handle:async(e,t,n,{match:r})=>{let i=r[1];if(!UV(n.root,`storyboard`,i)){L(t,404,{error:`storyboard/${i} not found`});return}let a=xnt(await o9(e,524288));if(!a)L(t,400,{error:`not a storyboard comment op`});else try{L(t,200,n.storyboardComments.apply(i,a))}catch(e){L(t,400,{error:e.message})}}},oYt={path:GJt,methods:[`POST`],auth:`agent`,handle:async(e,t,n,{match:r})=>{let i=r[1];if(!UV(n.root,`storyboard`,i)){L(t,404,{error:`storyboard/${i} not found`});return}let a=await o9(e),o=typeof a==`object`&&a?a:{},s=f9(o);if(o.op===`list`){L(t,200,{type:`comments`,artifact:`storyboard/${i}`,threads:n.storyboardComments.list(i,s??`Agent`,o.all===!0)});return}let c=wnt(o);if(!c)L(t,400,{error:`not an agent comment op: use list, add {shot, line? | at?} or {cut, at}, reply {threadId, text} or resolve {threadId}; text must not be empty`});else try{L(t,200,n.storyboardComments.applyAgent(i,c,s))}catch(e){L(t,400,{error:e.message})}}},sYt={path:HJt,auth:`viewer`,methods:[`POST`],handle:async(e,t,n,{match:r})=>{if(!C9(e)){L(t,403,{error:`cuts are only registered from this machine`});return}let i=r[1],a=UV(n.root,`storyboard`,i);if(!a){L(t,404,{error:`storyboard/${i} not found`});return}let o=await o9(e,S9),s=typeof o==`object`&&o?o:{};if(typeof s.file!=`string`||!m.default.isAbsolute(s.file))L(t,400,{error:`send {file, map?, master?} with an absolute file path`});else try{let e=vnt(a,{file:s.file,...s.map===void 0?{}:{map:s.map},...typeof s.master==`string`?{master:s.master}:{}});n.writeState({type:`storyboard`,id:i},a),L(t,200,e)}catch(e){if(e instanceof KU)L(t,400,{error:e.message});else throw e}}},cYt=/^\/api\/agent\/verify\/([^/]+)\/comments$/,w9=e=>typeof e==`string`?e:``;function lYt(e,t,n){let r=w9(n.agent).trim()||void 0;if(n.op===`list`)return{type:`report`,artifact:`verify/${t}`,...e.view(t),threads:e.threads(t).map(({id:e,anchor:t,status:n,stale:r,messages:i})=>({id:e,anchor:{...t,hash:void 0},status:n,stale:r,messages:i.map(({author:e,text:t,at:n})=>({author:e,text:t,at:n}))}))};if(n.op===`verdict`){if(n.verdict!==`pass`&&n.verdict!==`reject`)throw Error(`verdict needs {verdict: "pass" | "reject"}`);if(n.all!==!0&&!w9(n.claim))throw Error(`verdict needs {claim} or {all: true}`);return e.applyAgent(t,{op:`verdict`,verdict:n.verdict,text:w9(n.text),...n.all===!0?{all:!0}:{claim:w9(n.claim)}},r)}if(n.op===`waive`){if(!w9(n.gap))throw Error(`waive needs {gap}`);return e.applyAgent(t,{op:`waive`,gap:w9(n.gap)},r)}if(n.op===`reply`){if(!w9(n.threadId))throw Error(`reply needs {threadId}`);let i=e.applyAgent(t,{op:`reply`,threadId:w9(n.threadId),text:w9(n.text)},r);return{...i,threadId:i.threadIds[0]}}throw Error(`a report takes list, verdict, waive or reply`)}const uYt={path:cYt,methods:[`POST`],auth:`agent`,handle:async(e,t,n,{match:r})=>{let i=r[1];if(!UV(n.root,`verify`,i)){L(t,404,{error:`verify/${i} not found`});return}let a=await o9(e),o=typeof a==`object`&&a?a:{};try{L(t,200,lYt(n.verify,i,o))}catch(e){L(t,400,{error:e.message})}}};function dYt(e,t){if(e===`asks`)return e=>e.state===`submitted`;if(e===`rounds`)return e=>e.state===`open`||e.state===`submitted`;let n=new Set(t.filter(e=>e.state===`submitted`).map(e=>e.id));return e=>e.kind===`verify`?e.verdict===`reject`:n.has(e.round)}const T9=`ryugi.review/v1`,E9=e=>typeof e==`string`?e:void 0;function fYt(e,t){let n=e.filters&&typeof e.filters==`object`?e.filters:void 0,r={artifact:t,agent:typeof e.agent==`string`&&e.agent.length>0&&e.agent.length<=100?e.agent:`Agent`,limit:e.limit===void 0?void 0:Number(e.limit),cursor:E9(e.cursor),snapshot:E9(e.snapshot),detail:e.detail===!0,all:e.all===!0,thread:E9(e.thread),fields:Array.isArray(e.fields)&&e.fields.every(e=>typeof e==`string`)?e.fields:void 0,...n?{filters:n}:{}};if(r.limit!==void 0&&(!Number.isInteger(r.limit)||r.limit<1||r.limit>100))throw new H7(`E_ARGUMENT_INVALID`,`limit must be between 1 and 100.`);return r}function pYt(e){let t=e.session;if(typeof t!=`object`||!t)return null;let{host:n,id:r}=t;return n!==`claude`&&n!==`codex`||typeof r!=`string`?null:r.length>0&&r.length<=200?{host:n,id:r}:null}function mYt(e,t,n,r){let i=pYt(t);if(!i||!(n.detail||n.thread)||n.fields)return r;let a=r.items.flatMap(e=>typeof e.id==`string`?[e.id]:[]);return a.length&&e.deliverThreads(n.artifact,i.host,i.id,a),r}async function D9(e,t,n,r){if(t===`document`){await kK(e,`document/${n}`);let t=new Map(e.documents.listComments(n,r.agent,!0).map(e=>[e.id,e])),i=e.documents.comments(n);return e.agentReview.threads({...r,threads:i.threads.filter(e=>!bH(e)).map(e=>({...e,...t.get(e.id),messages:e.messages.map(({avatar:e,...t})=>t)}))})}if(t===`whiteboard`){let t=new Map(e.whiteboardComments.list(n,r.agent,!0).map(e=>[e.id,e]));return e.agentReview.threads({...r,threads:e.whiteboardComments.comments(n).threads.map(e=>({...e,...t.get(e.id),messages:e.messages.map(({avatar:e,...t})=>t)}))})}if(t===`report`){let t=new Map(e.reportComments.list(n,r.agent,!0).map(e=>[e.id,e]));return e.agentReview.threads({...r,threads:e.reportComments.comments(n).threads.map(e=>{let n=t.get(e.id);return{...e,...n,anchor:n?.dataChanged?{...e.anchor,dataChanged:!0}:e.anchor,messages:e.messages.map(({avatar:e,...t})=>t)}})})}if(t===`preview`){let t=e.previewComments.agentView(n);return e.agentReview.threads({...r,threads:e.previewComments.comments(n).threads.map(e=>{let n=t(e);return{...e,...n,anchor:{...e.anchor,...n.cropPath?{cropPath:n.cropPath}:{}},messages:n.messages}})})}if(t===`storyboard`){let t=e.storyboardComments.agentView(n);return e.agentReview.threads({...r,threads:e.storyboardComments.comments(n).threads.map(e=>{let n=t(e);return{...e,...n,anchor:{...e.anchor,...n.title===null?{deleted:!0}:{title:n.title,number:n.number},...n.lineText===null?{}:{lineText:n.lineText},...n.cropPath?{cropPath:n.cropPath}:{}},messages:n.messages}})})}if(t===`slides`){let t=new Map(e.slidesComments.list(n,r.agent,!0).map(e=>[e.id,e]));return e.agentReview.threads({...r,threads:e.slidesComments.comments(n).threads.map(e=>{let n=t.get(e.id);return{...e,...n,anchor:n&&n.number!==null?{...e.anchor,number:n.number,title:n.title}:e.anchor,messages:e.messages.map(({avatar:e,...t})=>t)}})})}await kK(e,`artboard/${n}`);let i=new Map(e.boardComments.list(n,r.agent,!0).map(e=>[e.id,e])),a=e.boardComments.comments(n);return e.agentReview.threads({...r,threads:a.threads.filter(e=>!zH(e)).map(e=>({...e,...i.get(e.id),messages:e.messages.map(({avatar:e,...t})=>t)}))})}async function O9(e,t,n,r,i){let a=[],o=[];return i===`asks`&&t===`document`?a=(await e.documents.asks(n)).asks.map(e=>({...e})):i===`groups`&&t===`artboard`?(a=e.boardComments.groups(n).map(e=>({...e})),o=e.boardComments.rounds(n).map(e=>({...e}))):i===`rounds`&&t===`artboard`&&(a=e.boardComments.rounds(n).map(e=>({...e}))),e.agentReview.state({...r,section:i,items:a,actionable:dYt(i,o)})}function hYt(e,t){let n=FGt({...e,section:t});if(n)throw new H7(`E_ARGUMENT_INVALID`,n)}async function gYt(e,t,n,r,i,a){try{if(!(r===`preview`?Z6(n.root,i):UV(n.root,r,i)))throw new H7(`E_ARTIFACT_NOT_FOUND`,`${r}/${i} not found.`,404);let o=await o9(e);if(!o||typeof o!=`object`||Array.isArray(o))throw new H7(`E_ARGUMENT_INVALID`,`Expected a review request.`);let s=o,c=fYt(s,`${r}/${i}`);if(s.op===`ack`){if(typeof s.receipt!=`string`)throw new H7(`E_ARGUMENT_INVALID`,`An acknowledgement receipt is required.`);let{to:e,...o}=n.agentReview.ack({...c,receipt:s.receipt,kind:a===`changes`?`changes`:`threads`});(r===`slides`||r===`storyboard`)&&a===`changes`&&e&&(r===`slides`?iBt(m.default.join(n.root,`.state`),i,e):Q5(m.default.join(n.root,`.state`),i).markSeen(e),n.writeState({type:r,id:i},UV(n.root,r,i))),n.reviewListeners.forEach(e=>e(c.artifact)),L(t,200,{schema:T9,artifact:c.artifact,receipt:s.receipt,...o});return}if(a===`changes`&&(r===`slides`||r===`storyboard`)){if(c.detail&&(c.limit!==void 0||c.cursor||c.fields))throw new H7(`E_ARGUMENT_INVALID`,`A complete diff cannot use pagination or fields.`);let e=m.default.join(n.root,`.state`),a=await n.agentReview.changes({...c,load:async t=>r===`slides`?aBt(e,i,t):Q5(e,i).since(t)});L(t,200,{schema:T9,artifact:c.artifact,...a});return}if(a===`changes`){if(r!==`document`)throw new H7(`E_ARGUMENT_INVALID`,`Changes apply to documents only.`);if(c.detail&&(c.limit!==void 0||c.cursor||c.fields))throw new H7(`E_ARGUMENT_INVALID`,`A complete diff cannot use pagination or fields.`);let e=await n.documents.open(i);if(!e)throw new H7(`E_ARTIFACT_NOT_FOUND`,`Document not found.`,404);let a=await n.agentReview.changes({...c,load:t=>e.changesSince(t)});L(t,200,{schema:T9,artifact:c.artifact,...a});return}let l=s.op===`read`?`threads`:E9(s.section);if(s.op!==`list`&&s.op!==`read`)throw new H7(`E_ARGUMENT_INVALID`,`Expected list, read or ack.`);if(s.op===`read`&&!c.thread)throw new H7(`E_ARGUMENT_INVALID`,`A thread ID is required.`);if(s.sections!==void 0){if(s.op!==`list`||!Array.isArray(s.sections)||!s.sections.every(e=>typeof e==`string`))throw new H7(`E_ARGUMENT_INVALID`,`sections requires a list of collection names and op=list.`);let e=PGt({...c,section:l,sections:s.sections},c.artifact);if(e)throw new H7(`E_ARGUMENT_INVALID`,e);let a={};for(let e of s.sections)a[e]=e===`threads`?mYt(n,s,c,await D9(n,r,i,c)):await O9(n,r,i,c,e);L(t,200,{schema:T9,artifact:c.artifact,sections:a});return}if(hYt(c,l),l===`threads`)L(t,200,{schema:T9,artifact:c.artifact,section:l,...mYt(n,s,c,await D9(n,r,i,c))});else if(l===`asks`||l===`groups`||l===`rounds`)L(t,200,{schema:T9,artifact:c.artifact,section:l,...await O9(n,r,i,c,l)});else{let e=await D9(n,r,i,{...c,limit:1}),a=await O9(n,r,i,c,`asks`),o=await O9(n,r,i,c,`groups`),s=await O9(n,r,i,c,`rounds`);L(t,200,{schema:T9,artifact:c.artifact,summary:{threads:e.page.total,waitingOnAgent:e.summary?.waitingOnAgent??0,asks:a.summary,groups:o.summary,rounds:s.summary}})}}catch(e){let n=e instanceof H7;L(t,n?e.status:500,{schema:T9,code:n?e.code:`E_REVIEW_FAILED`,error:e instanceof Error?e.message:String(e)})}}const _Yt={path:/^\/api\/agent\/v1\/(document|artboard|whiteboard|slides|report|storyboard|preview)\/([^/]+)\/(review|changes)$/,methods:[`POST`],auth:`agent`,handle:(e,t,n,{match:r})=>gYt(e,t,n,r[1],r[2],r[3])},vYt=`var(--ink)`,yYt=/^(#[0-9a-f]{3,8}|[a-z]{3,20})$/i,bYt=/* @__PURE__ */ new Set([`#000`,`#000000`,`#1e1e1e`,`#222`,`#222222`,`#333`,`#333333`,`black`]),xYt=e=>e.replaceAll(/[&<>"']/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`})[e]),k9=(e,t=0)=>typeof e==`number`&&Number.isFinite(e)&&Math.abs(e)<=1e7?e:t,A9=(e,t,n=!1)=>typeof e!=`string`||!yYt.test(e)?t:e===`transparent`?`none`:n&&bYt.has(e.toLowerCase())?vYt:e,SYt=e=>Array.isArray(e.points)?e.points.filter(e=>Array.isArray(e)).map(([e,t])=>[k9(e),k9(t)]):[];function CYt(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e){let e=k9(a.x),o=k9(a.y),s=[[0,0],[k9(a.width),k9(a.height)],...SYt(a)];for(let[a,c]of s)t=Math.min(t,e+a),n=Math.min(n,o+c),r=Math.max(r,e+a),i=Math.max(i,o+c)}return Number.isFinite(t)?{minX:t,minY:n,maxX:r,maxY:i}:null}const j9=e=>Math.round(e*10)/10,M9=e=>[...e].reduce((e,t)=>e+(t.codePointAt(0)>=11904?1:.55),0);function wYt(e,t,n,r,i){let a=t.step*.5;return e.map((e,o)=>{if(!e.trim())return``;let s=Math.min(t.width,Math.max(a,n(e))),c=r===`center`?t.x+(t.width-s)/2:r===`right`?t.x+t.width-s:t.x,l=t.y+t.step*o+(t.step-a)/2;return`<rect x="${j9(c)}" y="${j9(l)}" width="${j9(s)}" height="${j9(a)}" rx="${j9(a/2)}" fill="${i}" fill-opacity=".28"/>`}).join(``)}function TYt(e,t){if(e.length<2)return``;let[n,r]=e.at(-2),[i,a]=e.at(-1),o=Math.atan2(a-r,i-n),s=7.5,c=Math.PI/6.5;return`<polyline points="${j9(i-s*Math.cos(o-c))},${j9(a-s*Math.sin(o-c))} ${i},${a} ${j9(i-s*Math.cos(o+c))},${j9(a-s*Math.sin(o+c))}" stroke="${t}" stroke-width="1.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/>`}function EYt(e,t,n){let r=k9(e.x),i=k9(e.y),a=k9(e.width)*n,o=k9(e.height)*n,s=A9(e.strokeColor,vYt,!0),c=`stroke="${s}" stroke-width="1.5" fill="${A9(e.backgroundColor,`none`)}"`,[l,u]=t(r,i);switch(e.type){case`rectangle`:return`<rect x="${l}" y="${u}" width="${a}" height="${o}" rx="6" ${c}/>`;case`frame`:return`<rect x="${l}" y="${u}" width="${a}" height="${o}" rx="8" stroke="var(--border-strong)" stroke-width="1.1" stroke-dasharray="5 4" fill="none"/>`;case`ellipse`:return`<ellipse cx="${l+a/2}" cy="${u+o/2}" rx="${a/2}" ry="${o/2}" ${c}/>`;case`diamond`:return`<polygon points="${l+a/2},${u} ${l+a},${u+o/2} ${l+a/2},${u+o} ${l},${u+o/2}" ${c}/>`;case`arrow`:case`line`:case`freedraw`:{let n=SYt(e).map(([e,n])=>t(r+e,i+n));return n.length?`<polyline points="${n.map(e=>e.join(`,`)).join(` `)}" stroke="${s}" stroke-width="1.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/>${e.type===`arrow`?TYt(n,s):``}`:``}case`richtext`:{let t=`<rect x="${l}" y="${u}" width="${a}" height="${o}" rx="6" stroke="${A9(e.strokeColor,`var(--wb-sticky-edge)`,!0)}" stroke-width="1" fill="${A9(e.backgroundColor,`var(--wb-sticky)`)}" filter="url(#wb-lift)"/>`,r=Math.max(4,Math.min(16,14*n)),i=8*n,s=r*1.35,c=Math.max(1,Math.floor((o-i*2)/s));return t+wYt((e.text??``).split(`
|
|
1873
1873
|
`).slice(0,c),{x:l+i,y:u+i,width:a-i*2,step:s},e=>M9(e)*r,`left`,`var(--wb-sticky-ink)`)}case`svg`:return e.svg?`<image href="data:image/svg+xml,${encodeURIComponent(e.svg)}" x="${l}" y="${u}" width="${a}" height="${o}"/>`:`<rect x="${l}" y="${u}" width="${a}" height="${o}" rx="4" stroke="var(--border-strong)" fill="none"/>`;case`text`:{let t=(e.text??``).split(`
|
|
1874
|
-
`).slice(0,40),r=Math.max(.55,...t.map(M9));return
|
|
1875
|
-
`);for(let e of a){let a=e.match(/[\u2E80-\uFFFF]|[^\s\u2E80-\uFFFF]+\s?|\s/g)??[],o=``,s=0,c=()=>{i.push(o.trimEnd()),o=``,s=0};for(let e of a){let a=z9(e,t);if(s+a<=n)o+=e,s+=a;else if(o&&a<=n){if(i.length===r-1)return i.push(`${o.trimEnd()}…`),i;c();let n=e.trimStart();o=n,s=z9(n,t)}else for(let a of e){let e=OYt(a,t);if(s+e>n){if(i.length===r-1)return i.push(`${o.trimEnd()}…`),i;c()}o+=a,s+=e}}if(o||a.length===0){if(i.length===r)return i[r-1]=`${i[r-1].trimEnd()}…`,i;c()}if(i.length>=r)return i.slice(0,r)}return i}function V9(e){let t=[e],n=[];for(let e=0;t.length&&e<300;e++){let e=t.pop();typeof e.text==`string`?n.push(e.text.slice(0,4e3)):t.push(...F9(e.children).reverse())}return n.join(``).slice(0,4e3)}const H9=(e,t=8,n=14,r=`.11`)=>`<filter id="${e}" x="-18%" y="-18%" width="136%" height="145%"><feDropShadow dx="0" dy="${t}" stdDeviation="${n}" flood-color="var(--shadow)" flood-opacity="${r}"/></filter>`;function kYt(e,t){let n=F9(N9(N9(t.state).root).children),r=[`<rect x="64" y="20" width="472" height="520" rx="8" fill="var(--paper)" stroke="var(--edge)" filter="url(#doc-lift)"/>`,`<rect x="96" y="48" width="28" height="3" rx="1.5" fill="var(--accent)"/>`],i=76,a=(e,t,n,a=0,o=400,s=`var(--ink)`)=>{for(let c of B9(e,t,408-a,n))r.push(R9(96+a,i,c,t,s,o)),i+=t*1.5};n[0]?.type!==`heading`&&(a(e,18,2,0,650),i+=6);for(let e of n.slice(0,18)){if(i>332)break;let t=P9(e.type);if(t===`heading`){let t=e.tag===`h1`?18:11.5;i+=e.tag===`h1`?0:8,a(V9(e),t,2,0,650),i+=6}else if(t===`table`){let t=F9(e.children).slice(0,5),n=408/Math.max(1,...t.map(e=>F9(e.children).length));t.forEach((e,t)=>{F9(e.children).forEach((e,a)=>{r.push(L9(96+a*n,i-8+t*22,n,22,t===0?`var(--block)`:`var(--paper)`,`var(--border)`)),r.push(R9(102+a*n,i+6+t*22,B9(V9(e),7.5,n-12,1)[0]??``,7.5,t===0?`var(--ink-soft)`:`var(--ink)`,t===0?600:400))})}),i+=t.length*22+10}else if(t===`list`)F9(e.children).slice(0,4).forEach((t,n)=>{r.push(R9(96,i,e.listType===`number`?`${n+1}.`:`•`,9,`var(--muted)`)),a(V9(t),9,2,13,400,`var(--ink-soft)`)}),i+=8;else if(t===`alert-quote`){let t=B9(F9(N9(N9(e.content).root).children).map(V9).join(` `),9,382,3);r.push(L9(96,i-8,408,t.length*14+16,`var(--alert)`,`none`,4),L9(96,i-8,3,t.length*14+16,`var(--alert-bar)`,`none`,1.5)),t.forEach(e=>{r.push(R9(110,i+7,e,9,`var(--ink-soft)`)),i+=14}),i+=20}else if(t===`code-block`){let t=B9(P9(e.code),8,386,4);r.push(L9(96,i-8,408,t.length*12+18,`var(--block)`,`var(--border)`,4)),t.forEach(e=>{r.push(R9(106,i+6,e,8,`var(--ink-soft)`)),i+=12}),i+=20}else t===`paragraph`||t===`quote`?(a(V9(e),9,3,0,400,`var(--ink-soft)`),i+=7):(r.push(L9(96,i-8,408,28,`var(--block)`,`none`,4),R9(106,i+10,t.toUpperCase().slice(0,30),8,`var(--muted)`)),i+=38)}return`${L9(0,0,600,360,`var(--desk)`)}<defs>${H9(`doc-lift`,8,14,`.11`)}</defs><g transform="rotate(-2 300 260)"><g transform="translate(0 8)">${r.join(``)}</g></g>`}function U9(e){let t=N9(e);return[t.x,t.y,t.w,t.h].every(I9)&&t.w>0&&t.h>0?t:null}function AYt(e,t){let n={};for(let[r,i]of Object.entries(N9(e.boards)).slice(0,2e3)){let e=U9(i);e&&N9(i).page===t&&(n[r]={x:e.x,y:e.y,w:e.w,h:e.h,page:t,file:``})}let r={};for(let[n,i]of Object.entries(N9(e.notes)).slice(0,200)){let e=N9(i);e.kind===`condition`&&e.page===t&&I9(e.x)&&I9(e.y)&&(r[n]={kind:`condition`,page:t,x:e.x,y:e.y,text:P9(e.text).slice(0,200)})}let i={};for(let[t,n]of Object.entries(N9(e.edges)).slice(0,200)){let e=N9(n);typeof e.from==`string`&&typeof e.to==`string`&&(i[t]={from:e.from,to:e.to})}return{version:1,pages:[{id:t,name:t}],boards:n,notes:r,edges:i}}const W9=(e,t,n,r,i=`var(--muted)`,a=`.34`)=>n>0&&r>0?`<rect x="${e}" y="${t}" width="${n}" height="${r}" rx="${r/2}" fill="${i}" fill-opacity="${a}"/>`:``;function jYt(e){let t=N9(e.canvas),n=P9(t.activePage)||P9(F9(t.pages)[0]?.id),r=N9(N9(N9(e.layout).pages)[n]),i=Object.values(N9(t.boards)).slice(0,2e3).map(N9).filter(e=>e.page===n&&U9(e)),a=N9(r.notes),o=N9(r.groups),s=N9(r.bounds),c=s.minX,l=s.minY,u=s.maxX,d=s.maxY;if(![c,l,u,d].every(I9)||u<=c||d<=l){if(!i.length)return`${L9(0,0,600,360,`var(--bg)`)}<defs><pattern id="dots" width="16" height="16" patternUnits="userSpaceOnUse"><circle cx="1.5" cy="1.5" r=".9" fill="var(--dot)"/></pattern></defs>${L9(0,0,600,360,`url(#dots)`)}`;c=Math.min(...i.map(e=>e.x)),l=Math.min(...i.map(e=>e.y)),u=Math.max(...i.map(e=>e.x+e.w)),d=Math.max(...i.map(e=>e.y+e.h))}let f=Math.max(1,u-c),p=Math.max(1,d-l),m=Math.min(544/f,304/p),h=(600-f*m)/2-c*m,g=(360-p*m)/2-l*m,_=[];for(let[e,n]of Object.entries(o).slice(0,200)){let r=U9(n);if(!r)continue;_.push(`<rect x="${r.x}" y="${r.y}" width="${r.w}" height="${r.h}" rx="${6/m}" fill="var(--paper)" fill-opacity=".35" stroke="var(--border-strong)" stroke-dasharray="${4/m} ${3/m}"/>`);let i=P9(N9(N9(t.groups)[e]).title).trim();if(i&&r.w*m>50){let e=4.5/m,t=Math.min(r.w-24/m,Math.max(24/m,z9(i,7/m)));_.push(W9(r.x+12/m,r.y+12/m,t,e,`var(--muted)`,`.36`))}}for(let e of ZKt(AYt(t,n),n)){let t=e.points.map(e=>`${e.x},${e.y}`).join(` `);_.push(`<polyline points="${t}" fill="none" stroke="var(--muted)" stroke-width="1.2" vector-effect="non-scaling-stroke"/>`);let n=e.points.at(-1);n&&_.push(`<circle cx="${n.x}" cy="${n.y}" r="${2.2/m}" fill="var(--muted)"/>`)}for(let e of i){let t=U9(e),n=t.w*m,r=t.h*m,i=Math.min(5,Math.min(n,r)*.12)/m;if(_.push(`<rect x="${t.x}" y="${t.y}" width="${t.w}" height="${t.h}" rx="${i}" fill="var(--paper)" stroke="var(--border-strong)" filter="url(#ab-lift)"/>`),n>42&&r>34){let e=10/m,n=7/m,r=t.w-n*2;_.push(`<rect x="${t.x}" y="${t.y}" width="${t.w}" height="${e}" rx="${i}" fill="var(--paper-subtle)"/>`,`<line x1="${t.x}" y1="${t.y+e}" x2="${t.x+t.w}" y2="${t.y+e}" stroke="var(--border)" stroke-width=".7" vector-effect="non-scaling-stroke"/>`,`<rect x="${t.x+n}" y="${t.y+e+6/m}" width="${r*.48}" height="${4.5/m}" rx="${2/m}" fill="var(--border-strong)"/>`,`<rect x="${t.x+n}" y="${t.y+e+14/m}" width="${r}" height="${Math.max(8/m,(t.h-e-22/m)*.48)}" rx="${2.5/m}" fill="var(--block)"/>`)}let a=P9(e.title).trim();if(a&&n>42){let e=3.5/m,n=Math.min(t.w*.72,Math.max(18/m,z9(a,6/m)));_.push(W9(t.x,t.y-8/m,n,e,`var(--muted)`,`.34`))}}for(let[e,r]of Object.entries(N9(t.notes)).slice(0,200)){let t=N9(r),i=U9(a[e]);if(t.page===n&&i){if(t.kind===`condition`){_.push(`<rect x="${i.x}" y="${i.y}" width="${i.w}" height="${i.h}" rx="${i.h/2}" fill="var(--paper)" stroke="var(--muted)"/>`);let e=P9(t.text).trim();if(e&&i.w*m>26){let t=Math.min(i.h*.36,3.5/m),n=Math.min(i.w*.65,Math.max(12/m,z9(e,5.5/m)));_.push(W9(i.x+(i.w-n)/2,i.y+(i.h-t)/2,n,t,`var(--muted)`,`.38`))}}else if(t.kind===`sticky`){let e=/^#[\da-f]{3}(?:[\da-f]{3})?$/i.test(P9(t.color))?P9(t.color):`var(--wb-sticky)`;_.push(`<rect x="${i.x}" y="${i.y}" width="${i.w}" height="${i.h}" rx="${4/m}" fill="${e}" stroke="var(--wb-sticky-edge)" filter="url(#ab-lift)"/>`);let n=P9(t.text).trim();if(n&&i.w*m>28){let e=6/m,t=Math.max(0,i.w-e*2),r=3.2/m,a=6.5/m;B9(n,5/m,t,3).forEach((n,o)=>{let s=i.y+e+o*a;if(s+r>i.y+i.h-e/2)return;let c=Math.min(t,Math.max(r*2,z9(n,5/m)));_.push(W9(i.x+e,s,c,r,`#514a37`,o===0?`.42`:`.26`))})}}else{let e=I9(t.size)&&t.size>0?t.size:96,n=P9(t.text).trim();if(n&&e*m>3){let t=Math.max(3/m,e*.42),r=Math.min(i.w,Math.max(t*2.5,z9(n,e*.65)));_.push(W9(i.x,i.y+(i.h-t)/2,r,t,`var(--muted)`,`.38`))}}}}return L9(0,0,600,360,`var(--bg)`)+`<defs>${H9(`ab-lift`,4,7,`.09`)}<pattern id="dots" width="16" height="16" patternUnits="userSpaceOnUse"><circle cx="1.5" cy="1.5" r=".9" fill="var(--dot)"/></pattern></defs>`+L9(0,0,600,360,`url(#dots)`)+`<g transform="translate(${h} ${g}) scale(${m})">${_.join(``)}</g>`}function MYt(e,t){let n=N9(t.report),r=F9(n.items),i=0,a=0,o=[];for(let e of r){let t=P9(e.kind);if(t===`gap`)a+=1,o.length<5&&o.push({kind:`gap`,title:P9(e.title)||`Unverified gap`,tag:`gap`});else if(t===`row`)i+=1,o.length<5&&o.push({kind:`row`,title:`${P9(e.artboard)} / ${P9(e.group)}`.replace(/^ \/ $/,`Artboard verify`),tag:`board`});else if(t===`claim`){i+=1;let t=F9(e.evidence).some(e=>P9(e.kind)===`output`);o.length<5&&o.push({kind:`claim`,title:P9(e.title)||`Claim`,tag:t?`output`:`evidence`})}}let s=B9(e,15.5,430,1),c=[],l=84,u=(e,t,n,r=!0)=>{let i=Math.max(66,Math.round(z9(e,9.5)+(r?30:22)));c.push(L9(l,94,i,22,t,`none`,11)),r&&c.push(`<circle cx="${l+13}" cy="105" r="3.5" fill="${n}"/>`),c.push(R9(r?l+22:l+i/2,108.5,e,9.5,n,600,r?``:` text-anchor="middle"`)),l+=i+8};u(i>0?`${i} checked`:`Verified`,`var(--pass-bg)`,`var(--pass)`,!0),a>0&&u(`${a} gap${a>1?`s`:``}`,`var(--warn-bg)`,`var(--warn)`,!0),r.length>0&&u(`${r.length} items`,`var(--block)`,`var(--muted)`,!1);let d=o.map((e,t)=>{let n=158+t*42,r=e.kind===`gap`,i=r?`<circle cx="96" cy="${n}" r="7.5" fill="var(--warn-bg)"/><rect x="95.1" y="${n-4}" width="1.8" height="4.8" rx=".9" fill="var(--warn)"/><circle cx="96" cy="${n+3.2}" r="1.1" fill="var(--warn)"/>`:`<circle cx="96" cy="${n}" r="7.5" fill="var(--pass-bg)"/><path d="M 92.5 ${n} L 95.2 ${n+2.7} L 100 ${n-2.6}" fill="none" stroke="var(--pass)" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/>`,a=B9(e.title,10.5,326,1)[0]??``;return i+R9(114,n+3.5,a,10.5,`var(--ink)`,500)+L9(454,n-9,62,18,r?`var(--warn-bg)`:`var(--block)`,`none`,9)+R9(485,n+3,e.tag,8,r?`var(--warn)`:`var(--muted)`,600,` text-anchor="middle"`)+`<line x1="84" y1="${n+21}" x2="516" y2="${n+21}" stroke="var(--border)" stroke-width=".7"/>`}).join(``),f=o.length===0?[0,1,2].map(e=>{let t=158+e*44;return`<circle cx="96" cy="${t}" r="7.5" fill="var(--pass-bg)"/><path d="M 92.5 ${t} L 95.2 ${t+2.7} L 100 ${t-2.6}" fill="none" stroke="var(--pass)" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/>`+L9(114,t-4,240-e*36,8,`var(--block)`,`none`,4)+L9(454,t-8,62,16,`var(--block)`,`none`,8)}).join(``):``;return L9(0,0,600,360,`var(--desk-verify)`)+`<defs>${H9(`vf-lift`,8,14,`.1`)}</defs><rect x="56" y="24" width="488" height="352" rx="10" fill="var(--paper)" stroke="var(--edge)" filter="url(#vf-lift)"/>`+R9(84,56,`VERIFY REPORT`,9,`var(--pass)`,650,` letter-spacing="0.06em"`)+R9(84,80,s[0]??e,15.5,`var(--ink)`,650)+c.join(``)+`<line x1="56" y1="130" x2="544" y2="130" stroke="var(--border)" stroke-width="1"/>`+d+f}function NYt(e,t,n,r,i){if(e===`two-cols`){let e=(r-14)/2;return L9(t,n,e,i,`var(--paper-subtle)`,`var(--border)`,5)+W9(t+12,n+14,e*.55,6,`var(--border-strong)`,`1`)+W9(t+12,n+28,e-24,5,`var(--block)`,`1`)+W9(t+12,n+40,e*.72,5,`var(--block)`,`1`)+L9(t+e+14,n,e,i,`var(--paper-subtle)`,`var(--border)`,5)+W9(t+e+26,n+14,e*.55,6,`var(--border-strong)`,`1`)+W9(t+e+26,n+28,e-24,5,`var(--block)`,`1`)+W9(t+e+26,n+40,e*.65,5,`var(--block)`,`1`)}if(e===`code`)return L9(t,n,r,i,`var(--block)`,`var(--border)`,6)+W9(t+14,n+14,74,5,`var(--accent)`,`.75`)+W9(t+26,n+28,176,5,`var(--muted)`,`.42`)+W9(t+26,n+40,132,5,`var(--muted)`,`.34`)+W9(t+14,n+52,92,5,`var(--muted)`,`.38`);if(e===`image`){let e=r*.44,a=t+e+14,o=r-e-14;return W9(t,n+10,e*.85,6,`var(--border-strong)`,`1`)+W9(t,n+24,e*.95,5,`var(--block)`,`1`)+W9(t,n+36,e*.75,5,`var(--block)`,`1`)+L9(a,n,o,i,`var(--block)`,`var(--border)`,6)+`<circle cx="${a+o*.28}" cy="${n+i*.34}" r="6" fill="var(--border-strong)"/><path d="M ${a+10} ${n+i-8} L ${a+o*.45} ${n+i*.46} L ${a+o*.7} ${n+i*.72} L ${a+o*.85} ${n+i*.56} L ${a+o-10} ${n+i-8} Z" fill="var(--border-strong)" fill-opacity=".65"/>`}return e===`quote`?L9(t,n+4,3.5,i-8,`var(--accent)`,`none`,1.75)+W9(t+16,n+12,r*.82,7,`var(--ink-soft)`,`.32`)+W9(t+16,n+28,r*.68,7,`var(--ink-soft)`,`.26`)+W9(t+16,n+48,84,5,`var(--muted)`,`.35`):e===`fact`?L9(t,n,128,i,`var(--accent-soft)`,`none`,6)+W9(t+18,n+i*.36,92,16,`var(--accent)`,`.82`)+W9(t+146,n+16,r-160,6,`var(--border-strong)`,`1`)+W9(t+146,n+30,(r-160)*.8,5,`var(--block)`,`1`)+W9(t+146,n+42,(r-160)*.6,5,`var(--block)`,`1`):e===`statement`||e===`section`||e===`end`?W9(t+r*.2,n+18,r*.6,7,`var(--border-strong)`,`.9`)+W9(t+r*.32,n+34,r*.36,5,`var(--block)`,`1`):``}function PYt(e,t,n){return e===`two-cols`?L9(t+5,n+6,14,12,`var(--block)`,`none`,1.5)+L9(t+22,n+6,14,12,`var(--block)`,`none`,1.5):e===`code`?L9(t+5,n+6,32,12,`var(--block)`,`none`,2)+L9(t+8,n+9,14,2,`var(--accent)`,`none`,1):e===`image`?L9(t+5,n+7,13,3,`var(--border-strong)`,`none`,1)+L9(t+5,n+12,10,2,`var(--block)`,`none`,1)+L9(t+21,n+6,16,12,`var(--block)`,`none`,2):e===`fact`?L9(t+5,n+6,14,12,`var(--accent-soft)`,`none`,2)+L9(t+22,n+8,14,3,`var(--border-strong)`,`none`,1)+L9(t+22,n+13,10,2,`var(--block)`,`none`,1):e===`quote`?L9(t+6,n+6,2,12,`var(--accent)`,`none`,1)+L9(t+11,n+8,22,2.5,`var(--border-strong)`,`none`,1)+L9(t+11,n+13,16,2,`var(--block)`,`none`,1):e===`section`||e===`statement`||e===`end`?L9(t+11,n+10,20,3.5,`var(--border-strong)`,`none`,1.5):L9(t+5,n+6,18,3,`var(--border-strong)`,`none`,1)+L9(t+5,n+12,28,2,`var(--block)`,`none`,1)+L9(t+5,n+16,22,2,`var(--block)`,`none`,1)}function FYt(e,t){let n=Array.isArray(t.outline)?t.outline.map(N9):F9(N9(t.outline).slides),r=n.length,i=P9(n[0]?.layout)||`cover`,a=r>0?`DECK · ${r} SLIDE${r===1?``:`S`}`:`SLIDES DECK`,o=B9(e,20.5,384,2),s=NYt(i,108,202,384,68),c=n.map(e=>P9(e.title)).filter(Boolean).slice(0,3),l=s||(c.length>0?c.map((e,t)=>{let n=216+t*20,r=B9(e,9.5,356,1)[0]??``;return R9(108,n,String(t+1).padStart(2,`0`),9.5,t===0?`var(--accent)`:`var(--muted)`,600)+R9(128,n,r,9.5,t===0?`var(--ink-soft)`:`var(--muted)`,400)}).join(``):L9(108,210,236,7,`var(--block)`,`none`,3.5)+L9(108,226,184,7,`var(--block)`,`none`,3.5)+L9(108,242,140,7,`var(--block)`,`none`,3.5)),u=Math.min(4,Math.max(3,r||4)),d=Array.from({length:u},(e,t)=>{let r=204+t*50,i=t===0,a=P9(n[t]?.layout)||(t===0?`cover`:`default`);return`<g${i?``:` opacity="${(.86-t*.12).toFixed(2)}"`}><rect x="${r}" y="308" width="42" height="24" rx="4" fill="var(--paper)" stroke="${i?`var(--accent)`:`var(--border-strong)`}" stroke-width="${i?`1.5`:`.8`}"/>`+PYt(a,r,308)+`</g>`}).join(``),f=r>0?R9(204+u*50+6,324,`1 / ${r}`,9.5,`var(--muted)`,600):``;return L9(0,0,600,360,`var(--desk-slides)`)+`<defs>${H9(`sl-lift`,10,16,`.12`)}</defs>`+L9(104,22,392,220,`var(--slide-back)`,`var(--border)`,8)+`<rect x="76" y="36" width="448" height="252" rx="8" fill="var(--paper)" stroke="var(--border-strong)" filter="url(#sl-lift)"/>`+L9(108,66,36,4,`var(--accent)`,`none`,2)+R9(108,94,a,9,`var(--muted)`,650,` letter-spacing="0.08em"`)+o.map((e,t)=>R9(108,130+t*28,e,20.5,`var(--ink)`,700)).join(``)+`<line x1="108" y1="192" x2="492" y2="192" stroke="var(--border)" stroke-width=".8"/>`+l+d+f}function G9(e,t,n,r,i){if(e===`cards`){let e=r>280?3:2,a=(r-10*(e-1))/e;return Array.from({length:e},(e,r)=>{let o=t+r*(a+10);return L9(o,n,a,i,`var(--paper-subtle)`,`var(--border)`,6)+W9(o+10,n+12,a*.52,5.5,`var(--border-strong)`,`1`)+W9(o+10,n+24,a-20,4.5,`var(--block)`,`1`)+W9(o+10,n+34,a*.65,4.5,`var(--block)`,`1`)}).join(``)}if(e===`table`){let e=Math.max(2,Math.min(4,Math.floor(i/18))),a=i/e;return L9(t,n,r,i,`var(--paper)`,`var(--border)`,5)+L9(t,n,r,a,`var(--block)`,`none`,5)+Array.from({length:e},(e,i)=>{let o=n+i*a;return(i>0?`<line x1="${t}" y1="${o}" x2="${t+r}" y2="${o}" stroke="var(--border)" stroke-width=".7"/>`:``)+W9(t+10,o+a*.35,r*.24,4.5,i===0?`var(--muted)`:`var(--border-strong)`,i===0?`.5`:`.8`)+W9(t+r*.42,o+a*.35,r*.28,4.5,`var(--block)`,`1`)+W9(t+r*.78,o+a*.35,r*.14,4.5,`var(--block)`,`1`)}).join(``)}if(e===`code`)return L9(t,n,r,i,`var(--block)`,`var(--border)`,6)+W9(t+14,n+12,r*.28,5,`var(--accent)`,`.75`)+W9(t+26,n+24,r*.56,4.5,`var(--muted)`,`.42`)+W9(t+26,n+35,r*.42,4.5,`var(--muted)`,`.34`);if(e===`form`){let e=Math.min(r*.62,240);return L9(t,n,r,i,`var(--paper-subtle)`,`var(--border)`,6)+L9(t+12,n+10,e,18,`var(--paper)`,`var(--border)`,4)+L9(t+12,n+34,e,18,`var(--paper)`,`var(--border)`,4)+L9(t+e+22,n+34,Math.min(72,r-e-34),18,`var(--accent)`,`none`,4)}if(e===`chart`){let e=[.38,.62,.5,.82,.68,.94,.72],a=Math.min(26,(r-28-8*(e.length-1))/e.length);return L9(t,n,r,i,`var(--paper-subtle)`,`var(--border)`,6)+e.map((e,r)=>{let o=Math.max(8,(i-20)*e);return L9(t+14+r*(a+8),n+i-8-o,a,o,r===5?`var(--accent)`:`var(--chart-bar-mid)`,`none`,3)}).join(``)}if(e===`list`){let e=Math.max(2,Math.min(3,Math.floor(i/16)));return Array.from({length:e},(e,i)=>{let a=n+6+i*16;return`<circle cx="${t+5}" cy="${a+2.5}" r="2.5" fill="var(--accent)"/>`+W9(t+16,a,r*(.78-i*.14),5,`var(--border-strong)`,`.85`)}).join(``)}return W9(t,n+6,r*.92,5.5,`var(--border-strong)`,`.8`)+W9(t,n+19,r*.84,5,`var(--block)`,`1`)+W9(t,n+31,r*.62,5,`var(--block)`,`1`)}function IYt(e){let t=e.boxes.map(t=>{if(t.kind===`text`){let n=Math.max(3,Math.min(t.h*.65,14)),r=Math.round((t.y+(t.h-n)/2)*10)/10,i=n>=9?`.62`:`.36`;return`<rect x="${t.x}" y="${r}" width="${t.w}" height="${Math.round(n*10)/10}" rx="${Math.round(n/2*10)/10}" fill="${t.bg??e.ink??`var(--ink)`}" fill-opacity="${i}"/>`}let n=t.r??(t.kind===`control`?4:3),r=t.bg??`none`,i=t.border??`none`,a=`<rect x="${t.x}" y="${t.y}" width="${t.w}" height="${t.h}"${n>0?` rx="${n}"`:``} fill="${r}" stroke="${i}"/>`;if(t.kind===`media`&&t.w>=36&&t.h>=24){let n=Math.round((t.x+t.w*.3)*10)/10,r=Math.round((t.y+t.h*.34)*10)/10,i=Math.max(2.5,Math.min(6,Math.min(t.w,t.h)*.12));return`${a}<circle cx="${n}" cy="${r}" r="${Math.round(i*10)/10}" fill="${e.ink??`var(--muted)`}" fill-opacity=".2"/>`}return a}).join(``);return`<clipPath id="ht-vp"><rect x="45" y="60" width="510" height="300"/></clipPath><g clip-path="url(#ht-vp)"><rect x="45" y="60" width="510" height="300" fill="${e.bg}"/><g transform="translate(45 60) scale(0.85 0.8333)">${t}</g></g>`}function LYt(e,t,n){let r=e.project?.split(`/`).at(-1),i=r?`${r} / HTML`:`index.html`,a=pK(n.domSnapshot);if(a)return L9(0,0,600,360,`var(--cover)`)+`<defs>${H9(`ht-lift`,8,14,`.1`)}</defs><rect x="44" y="26" width="512" height="352" rx="10" fill="var(--paper)" stroke="var(--border-strong)" filter="url(#ht-lift)"/><path d="M 45 36 Q 45 27 54 27 L 546 27 Q 555 27 555 36 L 555 60 L 45 60 Z" fill="var(--paper-subtle)"/><line x1="44" y1="60" x2="556" y2="60" stroke="var(--border)" stroke-width="1"/><circle cx="64" cy="43.5" r="4" fill="var(--border-strong)"/><circle cx="78" cy="43.5" r="4" fill="var(--border-strong)"/><circle cx="92" cy="43.5" r="4" fill="var(--border-strong)"/>`+L9(176,34,248,19,`var(--block)`,`none`,9.5)+R9(300,46.5,B9(i,9,224,1)[0]??i,9,`var(--muted)`,500,` text-anchor="middle"`)+R9(536,47,`</>`,10.5,`var(--muted)`,600,` text-anchor="end"`)+IYt(a);let o=N9(n.skeleton),s=o.hasNav===!0,c=o.hasSidebar===!0,l=Array.isArray(o.blocks)?o.blocks.filter(e=>typeof e==`string`&&[`cards`,`chart`,`code`,`form`,`list`,`table`,`text`].includes(e)):[],u=P9(o.heading)||t,d=c?168:74,f=c?358:452,p=60,m=[];s&&(m.push(L9(45,60,510,26,`var(--paper)`,`none`),`<line x1="44" y1="86" x2="556" y2="86" stroke="var(--border)" stroke-width=".7"/>`,`<circle cx="66" cy="73" r="4.5" fill="var(--accent)"/>`,W9(78,70.5,44,5,`var(--ink-soft)`,`.55`),W9(366,71,32,4,`var(--muted)`,`.35`),W9(408,71,32,4,`var(--muted)`,`.35`),W9(450,71,32,4,`var(--muted)`,`.35`),L9(494,66,42,14,`var(--accent-soft)`,`none`,7)),p=86),c&&m.push(L9(45,p,108,378-p,`var(--paper-subtle)`,`none`),`<line x1="153" y1="${p}" x2="153" y2="378" stroke="var(--border)" stroke-width=".8"/>`,W9(60,p+18,56,5.5,`var(--border-strong)`,`.95`),L9(56,p+34,84,18,`var(--accent-soft)`,`none`,4),W9(64,p+40.5,48,5,`var(--accent)`,`.75`),W9(64,p+64,62,4.5,`var(--muted)`,`.34`),W9(64,p+80,52,4.5,`var(--muted)`,`.34`),W9(64,p+96,68,4.5,`var(--muted)`,`.34`),W9(64,p+112,44,4.5,`var(--muted)`,`.28`));let h=p+26,g=B9(u,18,f,2);m.push(g.map((e,t)=>R9(d,h+t*24,e,18,`var(--ink)`,650)).join(``));let _=h+g.length*24+10;if(l.length>0){let e=Math.max(60,344-_),t=l.slice(0,2),n=Math.min(82,(e-12*(t.length-1))/t.length);t.forEach((e,t)=>{m.push(G9(e,d,_+t*(n+12),f,n))})}else m.push(G9(`cards`,d,_,f,66),G9(`text`,d,_+78,f,44));return L9(0,0,600,360,`var(--cover)`)+`<defs>${H9(`ht-lift`,8,14,`.1`)}</defs><rect x="44" y="26" width="512" height="352" rx="10" fill="var(--paper)" stroke="var(--border-strong)" filter="url(#ht-lift)"/><path d="M 45 36 Q 45 27 54 27 L 546 27 Q 555 27 555 36 L 555 60 L 45 60 Z" fill="var(--paper-subtle)"/><line x1="44" y1="60" x2="556" y2="60" stroke="var(--border)" stroke-width="1"/><circle cx="64" cy="43.5" r="4" fill="var(--border-strong)"/><circle cx="78" cy="43.5" r="4" fill="var(--border-strong)"/><circle cx="92" cy="43.5" r="4" fill="var(--border-strong)"/>`+L9(176,34,248,19,`var(--block)`,`none`,9.5)+R9(300,46.5,B9(i,9,224,1)[0]??i,9,`var(--muted)`,500,` text-anchor="middle"`)+R9(536,47,`</>`,10.5,`var(--muted)`,600,` text-anchor="end"`)+m.join(``)}function RYt(e){let t=B9(e,16,444,1),n=[44,62,54,82,74,108,92,122,98].map((e,t)=>{let n=96+t*46,r=324-e;return L9(n,r,28,e,t===7?`var(--accent)`:t>=5?`var(--chart-bar-mid)`:`var(--chart-bar)`,`none`,4)}).join(``);return L9(0,0,600,360,`var(--desk-report)`)+`<defs>${H9(`rp-lift`,8,14,`.1`)}</defs><rect x="48" y="24" width="504" height="352" rx="10" fill="var(--paper)" stroke="var(--edge)" filter="url(#rp-lift)"/>`+R9(78,54,`DATA REPORT`,9,`var(--muted)`,650,` letter-spacing="0.06em"`)+R9(78,78,t[0]??e,16,`var(--ink)`,650)+L9(78,96,138,58,`var(--paper-subtle)`,`var(--border)`,6)+L9(92,110,46,5,`var(--border-strong)`,`none`,2.5)+`<rect x="92" y="124" width="76" height="14" rx="3" fill="var(--ink)" fill-opacity=".78"/>`+L9(230,96,138,58,`var(--paper-subtle)`,`var(--border)`,6)+L9(244,110,52,5,`var(--border-strong)`,`none`,2.5)+`<rect x="244" y="124" width="64" height="14" rx="3" fill="var(--accent)" fill-opacity=".88"/>`+L9(382,96,140,58,`var(--paper-subtle)`,`var(--border)`,6)+L9(396,110,58,5,`var(--border-strong)`,`none`,2.5)+`<rect x="396" y="124" width="70" height="14" rx="3" fill="var(--pass)" fill-opacity=".8"/><line x1="78" y1="202" x2="522" y2="202" stroke="var(--border)" stroke-width=".6" stroke-dasharray="3 3"/><line x1="78" y1="242" x2="522" y2="242" stroke="var(--border)" stroke-width=".6" stroke-dasharray="3 3"/><line x1="78" y1="282" x2="522" y2="282" stroke="var(--border)" stroke-width=".6" stroke-dasharray="3 3"/><line x1="78" y1="324" x2="522" y2="324" stroke="var(--border-strong)" stroke-width="1"/>`+n}function zYt(e){let t=B9(e,16,444,1),n=[0,1,2,3].map(e=>{let t=78+e*114;return L9(t,112,102,58,e===1?`var(--ink)`:`var(--paper-subtle)`,`var(--border)`,5)+L9(t+10,182,62,5,`var(--border-strong)`,`none`,2.5)+L9(t+10,194,44,5,`var(--border)`,`none`,2.5)}).join(``),r=[70,120,60,110,84].reduce((e,t,n)=>({x:e.x+t+4,svg:e.svg+L9(e.x,300,t,14,n===1?`var(--ink)`:`var(--block)`,`none`,3)}),{x:78,svg:``}).svg;return L9(0,0,600,360,`var(--cover)`)+`<defs>${H9(`sb-lift`,8,14,`.1`)}</defs><rect x="48" y="24" width="504" height="352" rx="10" fill="var(--paper)" stroke="var(--edge)" filter="url(#sb-lift)"/>`+R9(78,54,`STORYBOARD`,9,`var(--muted)`,650,` letter-spacing="0.06em"`)+R9(78,78,t[0]??e,16,`var(--ink)`,650)+n+`<line x1="78" y1="240" x2="522" y2="240" stroke="var(--border)" stroke-width=".6" stroke-dasharray="3 3"/>`+L9(78,258,300,6,`var(--border-strong)`,`none`,3)+L9(78,272,220,6,`var(--border)`,`none`,3)+r+`<line x1="190" y1="294" x2="190" y2="320" stroke="var(--accent)" stroke-width="2"/>`}function BYt(e,t){let n=e.title??e.id,r;if(e.type===`document`)r=kYt(n,N9(t));else if(e.type===`artboard`)r=jYt(N9(t));else if(e.type===`whiteboard`){let e=N9(t).scene;r=EYt(n,Array.isArray(e)?e:[])}else r=e.type===`verify`?MYt(n,N9(t)):e.type===`slides`?FYt(n,N9(t)):e.type===`report`?RYt(n):e.type===`storyboard`?zYt(n):LYt(e,n,N9(t));return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 600 360"><title>${DYt(n)}</title><style>:root{--ink:#1f1e1b;--ink-soft:#4c4943;--muted:#7e7a72;--paper:#ffffff;--paper-subtle:#f9f8f5;--bg:#f3f2ee;--border:#dedbd4;--border-strong:#ccc8be;--block:#f2f0eb;--alert:#f9f1e9;--alert-bar:#c65d3b;--accent:#c65d3b;--accent-soft:#f6e6df;--desk:#eeece7;--edge:#dedbd4;--dot:#d4d0c7;--shadow:#1a1814;--desk-wb:#f7f6f2;--wb-grid:#e7e5de;--wb-sticky:#fef2bd;--wb-sticky-edge:#e6d48a;--wb-sticky-ink:#5c4e24;--desk-verify:#edf2ee;--pass:#2b8a57;--pass-bg:#e4f4eb;--warn:#b87216;--warn-bg:#fbf0dc;--desk-slides:#e9ebef;--slide-back:#d8dce3;--cover:#eaf0f3;--desk-report:#eef0f3;--chart-bar:#d3d8e0;--chart-bar-mid:#b5becb}@media (prefers-color-scheme: dark){:root{--ink:#eceae4;--ink-soft:#c2bfb8;--muted:#8f8c84;--paper:#252522;--paper-subtle:#2c2c29;--bg:#191917;--border:#3a3a35;--border-strong:#4b4b45;--block:#30302c;--alert:#362d26;--alert-bar:#e07a57;--accent:#e07a57;--accent-soft:#3b2922;--desk:#1b1b19;--edge:#3a3a35;--dot:#363631;--shadow:#000000;--desk-wb:#1e1e1c;--wb-grid:#2b2b27;--wb-sticky:#3d3520;--wb-sticky-edge:#574a28;--wb-sticky-ink:#f0df9e;--desk-verify:#19201b;--pass:#4cc38a;--pass-bg:#1d3327;--warn:#e5a94c;--warn-bg:#352b1a;--desk-slides:#181a1f;--slide-back:#2d313a;--cover:#181e22;--desk-report:#191c20;--chart-bar:#343942;--chart-bar-mid:#48505e}}text{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,PingFang SC,sans-serif}rect{stroke-width:.8;vector-effect:non-scaling-stroke}</style>${r}</svg>`}const VYt=/^\/api\/artifacts\/([^/]+)\/([^/]+)$/,HYt=/^\/api\/preview\/([^/]+)\/([^/]+)$/,UYt=/^\/api\/thumbnail\/([^/]+)\/([^/]+)\.svg$/,WYt={path:`/api/artifacts`,auth:`viewer`,handle:(e,t,n)=>{let{artifacts:r,warnings:i}=P5e(n),a=r.map(e=>{let t=TV(e.dir);if(e.type===`html`)try{let r=f.default.statSync(m.default.join(n.stateDir,`html`,e.id,`dom-skeleton.json`));t=Math.max(t,Math.floor(r.mtimeMs))}catch{}return{type:e.type,id:e.id,url:qV(n.root,e.type,e.id),title:n9(n.readArtifact(e.dir,e)),updatedAt:t}});L(t,200,{project:r9(n),artifacts:a,warnings:i})}},GYt={path:HHt,auth:`viewer`,handle:(e,t,n,{match:r})=>{n.avatars.load(r[1],r[2]).then(({status:e,type:n,body:r})=>{r&&n?ae(t,e,r,{"Content-Type":n,"Cache-Control":`private, max-age=86400`}):ae(t,e,`No avatar`)})}},KYt={path:HYt,auth:`viewer`,handle:(e,t,n,{match:r})=>{let[,i=``,a=``]=r,o=UV(n.root,i,a),s=WV(`${i}/${a}`);if(!o||!s)L(t,404,{error:`Artifact not found`});else try{let e=n.readArtifact(o,s),r=n9(e);L(t,200,{...OK(s,o,r,e),title:r,warnings:e.warnings,contentBase:`${n.contentPrefix}${i}/${a}/`})}catch{L(t,422,{error:`Preview unavailable`})}}},qYt={path:UYt,auth:`viewer`,handle:(e,t,n,{match:r})=>{let i=WV(`${r[1]}/${r[2]}`,an),a;try{a=i&&JV(n.root,i.type,i.id)}catch{a=null}if(!a)ae(t,404,`Artifact not found`);else try{let e={type:a.type,id:a.id},r=n.readArtifact(a.dir,e),i=n9(r);ae(t,200,BYt({id:e.id,type:e.type,title:i,project:r9(n)},OK(e,a.dir,i,r)),{"Content-Type":`image/svg+xml`,"Cache-Control":`private, max-age=31536000, immutable`,"Content-Security-Policy":`sandbox; default-src 'none'; style-src 'unsafe-inline'`,"X-Content-Type-Options":`nosniff`})}catch{ae(t,422,`Thumbnail unavailable`)}}},JYt={path:VYt,auth:`viewer`,handle:(e,t,n,{match:r})=>{let[,i=``,a=``]=r,o=UV(n.root,i,a);if(!o){L(t,404,{warnings:[`artifact ${i}/${a} not found`]});return}let s=WV(`${i}/${a}`);eH(n,s),L(t,200,{...n.artifactMeta(s,o),...s.type===`artboard`&&n.boardPort?{boardPort:n.boardPort,boardPath:`/c${qV(n.root,`artboard`,s.id)}/`}:{}})}},YYt={path:(e,t)=>t.cloud&&e===`/api/cloud/callback`?[e]:null,auth:`public`,handle:(e,t,n,{url:r})=>n.cloud.handleCallback(r,t,u7(d7(e.headers[`accept-language`])))},XYt={path:(e,t)=>t.cloud&&e===`/api/cloud/callback/auto-publish`?[e]:null,auth:`public`,handle:(e,t,n)=>n.cloud.handleCallbackAutoPublish(e,t,u7(d7(e.headers[`accept-language`])))},ZYt={path:`/api/cloud/flush`,methods:[`POST`],auth:`agent`,handle:(e,t,n,{url:r})=>{let{autoPublisher:i,cloud:a}=n;if(!i){L(t,404,{error:`cloud publishing is not configured`});return}P5e(n);let o=i.flush().then(()=>a?.syncModules());r.searchParams.get(`wait`)===`1`?o.then(()=>L(t,200,{flushed:!0})):L(t,202,{queued:!0})}},QYt={path:(e,t)=>t.cloud?.match(e)??null,auth:`cloud`,handle:(e,t,n,{match:r})=>{let[,i,a,o]=r,s=(i===`reserve`||i===`publish`&&e.method===`POST`)&&a&&o?WV(`${a}/${o}`):null;s&&eH(n,s),n.cloud.handle(e,t,r)}},$Yt={path:`/api/agent/daemon`,methods:[`POST`],auth:`same-origin`,handle:async(e,t,n)=>{let r=n.options.agentDaemon;if(!r){L(t,404,{error:`this computer has no daemon`});return}let i=await o9(e),{artifact:a,...o}=typeof i==`object`&&i?i:{};if(typeof a!=`string`||!WV(a))L(t,400,{error:`need an artifact`});else try{L(t,200,{ok:!0,data:await r.request(a,o,n.loopback)})}catch(e){L(t,409,{ok:!1,error:e.message})}}},eXt=/^\/relay\/a\/([\w-]{1,64})$/,tXt=RegExp(`(?:^|/)(${Ee.join(`|`)})/([\\w-]+)`);function nXt(e,t){let n=t===null?null:tXt.exec(t);if(!n)return null;let r=n[1],i=n[2];if(UV(e,r,i))return`${r}/${i}`;try{return`${r}/${JV(e,r,i)?.id??i}`}catch{return`${r}/${i}`}}const rXt={path:eXt,auth:`direct-relay`,handle:(e,t,n,{match:r,clientKey:i})=>{let a=n.servedArtifacts().get(r[1]);a?n.direct.accept(t,i,a):ZV(t,404,`Not Found`)}},iXt={path:`/ws`,auth:`socket`,handle:(e,t,n,{clientKey:r})=>{D5e(t,r),n.clients.add(t);let i=nXt(n.root,new URL(e.url??`/`,`http://x`).searchParams.get(`at`)),a=i?[e9,i]:[e9,uKt];a.forEach(n.viewed.viewerJoined),t.write(n.agentStatusFrame());for(let e of n.threadActivityFrames())t.write(e);O5e(t,e=>But(n,t,e));let o=()=>{n.clients.delete(t)&&(n.selections.drop(t),a.forEach(n.viewed.viewerLeft))};t.on(`end`,()=>{o(),t.end()}),t.on(`close`,o),t.on(`error`,o),n.touch()}},aXt={artboard:{fill:`M9.3 9a1.3 1.3 0 1 1-2.6 0a1.3 1.3 0 1 1 2.6 0z M13.3 7a1.3 1.3 0 1 1-2.6 0a1.3 1.3 0 1 1 2.6 0z M17.3 9.5a1.3 1.3 0 1 1-2.6 0a1.3 1.3 0 1 1 2.6 0z M8.8 13a1.3 1.3 0 1 1-2.6 0a1.3 1.3 0 1 1 2.6 0z`,stroke:`M12 3.5c-5 0-8.5 3.8-8.5 8.5s3.6 8.5 7.6 8.5c1.2 0 1.6-.8 1.6-1.9v-1.3c0-1.3 1-2.3 2.3-2.3h2.3c2.2 0 3.7-1.5 3.7-3.6 0-4.4-4-7.9-9-7.9z`},document:{fill:``,stroke:`M7 3h10a2.5 2.5 0 0 1 2.5 2.5v13a2.5 2.5 0 0 1-2.5 2.5H7a2.5 2.5 0 0 1-2.5-2.5v-13A2.5 2.5 0 0 1 7 3z M8.5 8.5h7M8.5 12h7M8.5 15.5h4`},html:{fill:``,stroke:`M8 7.5 3.5 12 8 16.5M16 7.5l4.5 4.5-4.5 4.5M13.5 5.5l-3 13`},whiteboard:{fill:``,stroke:`M5 4.5h14a1.5 1.5 0 0 1 1.5 1.5v10a1.5 1.5 0 0 1-1.5 1.5H5A1.5 1.5 0 0 1 3.5 16V6A1.5 1.5 0 0 1 5 4.5z M7 13.5c1.5-2.5 3-3.5 4-2s2.5 1 4.5-2 M9 17.5l-1.5 3M15 17.5l1.5 3`},verify:{fill:``,stroke:`M7 3h10a2.5 2.5 0 0 1 2.5 2.5v13a2.5 2.5 0 0 1-2.5 2.5H7a2.5 2.5 0 0 1-2.5-2.5v-13A2.5 2.5 0 0 1 7 3z M8.5 9l1.5 1.5 3-3M8.5 15l1.5 1.5 3-3M15 9.5h1M15 15.5h1`},slides:{fill:``,stroke:`M3.5 4.5h17M5 4.5V14a1.5 1.5 0 0 0 1.5 1.5h11A1.5 1.5 0 0 0 19 14V4.5M12 15.5v2.5M8.5 20.5l3.5-2.5 3.5 2.5M9 8.5h6M9 11.5h3.5`},report:{fill:``,stroke:`M4 20h16M7 16.5v-4M11 16.5v-8M15 16.5v-6M19 16.5V5.5`},storyboard:{fill:``,stroke:`M4 10h16v8.5a1.5 1.5 0 0 1-1.5 1.5h-13A1.5 1.5 0 0 1 4 18.5V10z M4 10l-.6-3a1.3 1.3 0 0 1 1-1.5l12.7-2.4a1.3 1.3 0 0 1 1.5 1l.5 2.6L4 10z M8.4 4.9l2.5 3.2M12.9 4l2.5 3.2`}},oXt=`#C65D3B`;function sXt(e){let{fill:t,stroke:n}=aXt[e],r=[`<svg xmlns="http://www.w3.org/2000/svg" viewBox="-2 -2 28 28">`,`<rect x="-2" y="-2" width="28" height="28" rx="6" fill="#FBEDE6"/>`,t&&`<path d="${t}" fill="${oXt}"/>`,`<path d="${n}" fill="none" stroke="${oXt}" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round"/>`,`</svg>`].join(``);return`data:image/svg+xml,${encodeURIComponent(r)}`}const K9=e=>e.replaceAll(/[&<>"']/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`})[e]);function cXt(e,t){let n=t.locale??`en`,r={robots:`noindex, nofollow`,"og:locale":n===`zh`?`zh_CN`:`en_US`,description:t.description,"og:title":t.title,"og:description":t.description,"twitter:title":t.title,"twitter:description":t.description};return e.replace(/<html\b([^>]*)>/i,(e,r)=>`<html${r.replace(/\slang="[^"]*"/i,``)} lang="${mUt[n]}"${t.artifactId?` data-ryugi-artifact-id="${K9(t.artifactId)}"`:``}${t.project?` data-ryugi-project="${K9(t.project)}"`:``}${t.embedParent?` data-ryugi-embed-parent="${K9(t.embedParent)}"`:``}>`).replace(/<title\b[^>]*>[\s\S]*?<\/title>/i,()=>`<title>${K9(t.title)}</title>`).replace(/(<link\b[^>]+\brel="icon"[^>]*\bhref=")[^"]*(")/i,(e,n,r)=>t.icon?`${n}${K9(t.icon)}${r}`:e).replaceAll(/(<meta\b[^>]+\b(?:name|property)="([^"]+)"[^>]*\bcontent=")([^"]*)("[^>]*>)/gi,(e,n,i,a,o)=>{let s=r[i]??(i===`og:image`||i===`twitter:image`?new URL(a,t.url).href:void 0);return s===void 0?e:`${n}${K9(s)}${o}`}).replace(/<\/head>/i,()=>`<link rel="canonical" href="${K9(t.url)}">\n<meta property="og:url" content="${K9(t.url)}">\n</head>`)}const lXt=/<script\b(?![^>]+\bsrc=)[^>]*>([\s\S]*?)<\/script>/gi;function uXt(e,t){let n=[...t.matchAll(lXt)].map(([,e])=>`'sha256-${(0,d.createHash)(`sha256`).update(e).digest(`base64`)}'`);return n.length?e.replace(/script-src [^;]*/,e=>`${e} ${n.join(` `)}`):e}const dXt=RegExp(`^/(?:(${Ee.join(`|`)})/([^/]+)/?)?$`),fXt=RegExp(`^/preview/(artboard|document|html)/${Yt}/?$`),pXt=/^\/preview\/([a-z0-9][a-z0-9-]{0,63})\/?$/,mXt=/^\/storyboard\/([^/]+)\/render\/?$/,hXt=/^\/embed\/(artboard|document|whiteboard|verify|slides)\/([\w-]{1,64})\/?$/,q9=e=>[`default-src 'self'`,`script-src 'self' 'wasm-unsafe-eval'`,`style-src 'self' 'unsafe-inline'`,`img-src 'self' data: blob:`,`font-src 'self' data:`,`connect-src 'self' ${e.join(` `)}`,`frame-src 'self' ${e.join(` `)}`,`base-uri 'self'`,`form-action 'none'`,`frame-ancestors 'none'`].join(`; `);function J9(e,t,n,{pathname:r,key:i},a){let{root:o,options:s,loopback:c,viewerDir:l}=n,u=a!==null,d=fXt.test(r),p=d?null:pXt.exec(r),h=a||(p?null:WV(r.replace(d?/^\/preview\//:/^\//,``).replace(/\/$/,``).replace(/^(storyboard\/[^/]+)\/render$/,`$1`),an)),g=h&&JV(o,h.type,h.id),_=g??h,v=g?.dir,y=r9(n),b=p?`${p[1]} · Preview · ${y}`:_?v?n9(n.readArtifact(v,_)):_.id:`${y} · Artifacts`,x=u7(d7(e.headers[`accept-language`])),S=p7(x),C=_?S(`meta.artifact`,{project:y,title:b,type:{artboard:`Artboard`,document:`Document`,html:`HTML`,whiteboard:`Whiteboard`,verify:`Verify report`,report:`Report`,slides:`Slides`,storyboard:`Storyboard`}[_.type]}):S(`meta.library`,{project:y}),w=p?`/preview/${p[1]}`:_?v?qV(o,_.type,_.id):`/${_.type}/${_.id}`:`/`,T=`http://${ie(s.urlHost)}:${n.port}${d?`/preview`:``}${w}`,E=p?[...n.boardOrigins(),`http://localhost:*`,`http://127.0.0.1:*`]:n.boardOrigins(),D=u?q9(E).replace(`frame-ancestors 'none'`,`frame-ancestors 'self'${s.cloud?` ${s.cloud.origin}`:``}`):d?q9(E).replace(`frame-ancestors 'none'`,`frame-ancestors 'self'`):q9(E),O={"Content-Type":`text/html; charset=utf-8`};(_||p)&&(O[`Referrer-Policy`]=`same-origin`),i!==null&&!c&&(O[`Set-Cookie`]=`${n.cookieName}=${n.token}; HttpOnly; SameSite=Strict; Path=/`);let k=d&&f.default.existsSync(m.default.join(l,`preview.html`))?`preview.html`:`index.html`;f.default.promises.readFile(m.default.join(l,k),`utf8`).then(n=>{let r=cXt(n,{title:b,description:C,locale:x,url:T,icon:_?sXt(_.type):void 0,artifactId:g?.id,project:y,embedParent:u&&e.headers[`sec-fetch-site`]!==`same-origin`?s.cloud?.origin:void 0});ae(t,200,r,{...O,"Content-Security-Policy":uXt(D,r)})}).catch(e=>ae(t,e.code===`ENOENT`?404:500,`Viewer unavailable`))}const gXt=[EKt,DKt,OKt,YYt,XYt,WYt,GYt,KYt,qYt,ZYt,QYt,gYt,Cqt,Sqt,wqt,lYt,Eqt,PJt,kqt,Aqt,$Yt,Mqt,NKt,FKt,VKt,HKt,bJt,xJt,SJt,CJt,MJt,NJt,FJt,IJt,RJt,uJt,dJt,mJt,fJt,pJt,ZJt,QJt,$Jt,eYt,tYt,nYt,rYt,iYt,aYt,oYt,qqt,Jqt,Yqt,Xqt,Zqt,Qqt,$qt,eJt,tJt,JYt,{path:/^\/embed\//,auth:`viewer`,handle:(e,t,n,r)=>{let i=hXt.exec(r.pathname),a=i&&n.embedTarget(i[1],i[2]);a?J9(e,t,n,r,a):ae(t,404,`Not found`)}},{path:e=>e===`/`||e===`/index.html`?[e]:null,auth:`navigation`,handle:(e,t,n,r)=>J9(e,t,n,r,null)},{path:e=>dXt.exec(e)??fXt.exec(e)??pXt.exec(e)??mXt.exec(e),auth:`viewer`,handle:(e,t,n,r)=>J9(e,t,n,r,null)},{path:e=>[e],auth:`viewer`,handle:(e,t,n,{pathname:r})=>{let i=rt(n.viewerDir,r.slice(1));i?se(t,i,{"Content-Security-Policy":q9(n.boardOrigins())}):ae(t,404,`Not found`)}}],_Xt=[rXt,iXt],vXt=`Forbidden: agent calls need ?key=`,yXt={public:{gated:!1,denied:`Forbidden`,allow:()=>!0},key:{gated:!1,denied:vXt,allow:(e,t,n)=>t.isAuthorized(e,n)},viewer:{gated:!0,denied:`Forbidden`,allow:()=>!0},navigation:{gated:!0,denied:`Forbidden`,allow:(e,t)=>!t.loopback||H8e(e.headers[`sec-fetch-site`])},agent:{gated:!0,denied:vXt,allow:(e,t,n)=>t.agentOk(e,n)},"same-origin":{gated:!0,denied:`Forbidden`,allow:(e,t)=>t.sameOrigin(e)},cloud:{gated:!0,denied:`Forbidden`,allow:(e,t,n)=>e.method===`GET`||t.keyOk(n)||t.sameOrigin(e)}},bXt={"direct-relay":(e,t,n)=>{let r=t.options.cloud!==void 0&&e.headers.origin===t.options.cloud.origin;return t.keyOk(n)&&(r||t.sameOrigin(e))},socket:(e,t,n)=>t.isAuthorized(e,n)&&t.sameOrigin(e)};function xXt(e,t,n){return typeof e==`string`?e===t?[t]:null:e instanceof RegExp?e.exec(t):e(t,n)}function SXt({auth:e,methods:t},n,r,i){let a=yXt[e];if(a.gated){if(r.loopback&&!AV(r.policy,n.headers.origin))return`Forbidden origin`;if(!r.isAuthorized(n,i))return`Forbidden: open the full artifact link including ?key=`}return t&&!t.includes(n.method??``)?a.denied:a.allow(n,r,i)?null:a.denied}function CXt(e,t,n,r){if(n.setHeader(`X-Robots-Tag`,`noindex, nofollow`),!kV(r.policy,t.headers.host)){ae(n,403,`Forbidden host`);return}let i=new URL(t.url??`/`,`http://artifacts.local`),a=i.searchParams.get(`key`),o=(e,o)=>{for(let s of e){let e=xXt(s.path,o,r);if(!e)continue;let c=SXt(s,t,r,a);if(c!==null)return ae(n,403,c),!0;let l=s.handle(t,n,r,{key:a,match:e,pathname:o,url:i});return l instanceof Promise&&l.catch(e=>{n.headersSent||ae(n,500,`Artifacts error: ${e.message}`)}),!0}return!1};if(o(e.filter(e=>e.raw),i.pathname))return;r.touch();let s;try{s=decodeURIComponent(i.pathname)}catch{ae(n,400,`Bad request`);return}o(e.filter(e=>!e.raw),s)||ae(n,404,`Not found`)}function wXt(e,t,n,r){if(!kV(r.policy,t.headers.host)){ZV(n,403,`Forbidden`);return}let i=new URL(t.url??`/`,`http://artifacts.local`),a=t.headers[`sec-websocket-key`],o=i.searchParams.get(`key`);if(typeof a!=`string`)ZV(n,400,`Bad Request`);else{for(let s of e){let e=xXt(s.path,i.pathname,r);if(e){if(!bXt[s.auth](t,r,o)){ZV(n,403,`Forbidden`);return}s.handle(t,n,r,{key:o,match:e,pathname:i.pathname,url:i,clientKey:a});return}}ZV(n,400,`Bad Request`)}}async function TXt(e){let t=_Kt(e),{root:n,stateDir:r,mount:i,loopback:a,token:o,cloud:s,autoPublisher:c,clients:l}=t,u=(e,n)=>CXt(gXt,e,n,t),d=_.default.createServer((e,t)=>{try{u(e,t)}catch(e){t.headersSent||ae(t,500,`Artifacts error: ${e.message}`)}}),p=(e,n)=>wXt(_Xt,e,n,t);if(d.on(`upgrade`,p),i)t.port=i.port;else{let n=Number(ne(t.portFile));try{t.port=await re(d,e.host,Number.isInteger(n)&&n>0?n:0)}catch{t.port=await re(d,e.host,0)}f.default.writeFileSync(t.portFile,`${t.port}\n`,{mode:384})}let h=t.port;t.cookieName=`ryugi_artifacts_${h}`;let g=kKt(t),v=_.default.createServer(g);if(i)t.boardPort=i.boardPort;else if(a){let n=m.default.join(r,`.last-board-port`),i=Number(ne(n));try{t.boardPort=await re(v,e.host,Number.isInteger(i)&&i>0&&i!==h?i:0)}catch{t.boardPort=await re(v,e.host,0)}f.default.writeFileSync(n,`${t.boardPort}\n`,{mode:384})}let y=t.boardPort;t.policy=OV({host:e.host,urlHost:e.urlHost,ports:y?[h,y]:[h],cloudOrigin:e.cloud?.origin});let b=`http://${ie(e.urlHost)}:${h}`,x=a?`${b}/`:`${b}/?key=${o}`,S=(e,t)=>`${b}${qV(n,e,t)}${a?``:`?key=${o}`}`,C=t.signatureBaseline(),w=[],T=HV(n).artifacts;for(let e of T){let r=`${e.type}/${e.id}`,i=GV(e.dir,e.type);C&&C.get(r)!==i&&w.push({type:e.type,id:e.id}),t.signatures.set(r,i);try{qV(n,e.type,e.id)}catch{}e.type===`slides`&&t.refreshState(e,e.dir)}let E=new Set(T.map(e=>`${e.type}/${e.id}`));for(let e of C?.keys()??[]){let t=WV(e);t&&!E.has(e)&&w.push(t)}t.saveSignatures(),vt(m.default.join(r,`server-info`),{type:`server-started`,url:x,port:h,boardPort:y,root:n}),t.relay=i?{emit:(e,n)=>t.relayListeners.forEach(t=>t(e,n)),close:()=>{}}:e.relay&&e.cloud?Z5e({...e.relay,token:()=>xt(e.cloud.credentialsFile,e.cloud.origin)?.token??null,served:t.servedArtifacts,local:()=>({hostId:x7(e.cloud.credentialsFile),port:h,...a?{embed:!0,embedDocument:!0}:{key:o}}),handle:(e,n,r)=>AK(t,e,n,r),onActivity:t.touch,onWatch:e=>sft(t,e)}):null;for(let e of w)QV(t,e,[],{force:!0});let D=t.memory.stateWritten?[]:T.map(({type:e,id:t})=>({type:e,id:t})),O,k=()=>{for(let e of D.splice(0,4))eH(t,e);D.length?O=setImmediate(k):(O=void 0,t.memory.stateWritten=!0)};O=setImmediate(k);let A=0;return t.deckFiles.changed=e=>j5e(t,e),{port:h,boardPort:y,token:o,contentToken:t.contentToken,url:x,root:n,linkFor:S,handleRequest:(e,n)=>{A+=1,t.lastActivity=Date.now(),n.once(`close`,()=>{--A,t.lastActivity=Date.now()});try{u(e,n)}catch(e){n.headersSent||ae(n,500,`Artifacts error: ${e.message}`)}},busy:()=>A>0||l.size>0||t.relayViewers.size>0||t.relayWatched.size>0||t.direct.size()>0||t.documents.openIds().length>0||(c?.active()??!1)||t.recordings.active()||t.voiceRunner.active()||t.sourceRunner.active(),lastActiveAt:()=>t.lastActivity,watch:e=>{let n=e?[e]:[e9,uKt];n.forEach(t.viewed.viewerJoined);let r=!0;return()=>{r&&(r=!1,n.forEach(t.viewed.viewerLeft))}},watching:()=>t.viewed.watching(),handleUpgrade:p,handleBoardRequest:g,handleRelay:(e,n,r)=>AK(t,e,n,r),dropRelayViewer:e=>oft(t,e),flushDocuments:()=>t.documents.flushAll(),served:t.servedArtifacts,onRelayEvent:e=>t.relayListeners.push(e),onReview:e=>t.reviewListeners.push(e),deliverThreads:(e,n,r,i)=>t.deliverThreads(e,n,r,i),relayWatch:e=>sft(t,e),liveClients:()=>l.size,agentSessions:()=>t.agentStatus.sessions(),publishAgentStatus:()=>t.publishAgentStatus(),resolve:(e,t)=>an(t)?JV(n,e,t)?.id??null:null,cloudLinkFor:async(t,n)=>{if(!s||!e.cloud||!xt(e.cloud.credentialsFile,e.cloud.origin))return null;let{url:r}=await s.reserve({type:t,id:n});return r?S5e(r,x7(e.cloud.credentialsFile)):null},onArtifactChange:e=>{t.changeListeners.push(e)},*currentPayloads(e){let r=e?[WV(e)]:HV(n).artifacts.map(({type:e,id:t})=>({type:e,id:t}));for(let e of r){let n=e&&N5e(t,e);e&&n&&(yield{ref:e,payload:n})}},onActivity:e=>t.activityListeners.push(e),close:async()=>{z5e(),O&&clearImmediate(O),clearInterval(t.listeningTimer),await t.recordings.close(),await new Promise(e=>{t.viewed.close(),t.deckDeps.close(),c?.close(),t.relay?.close(),t.direct.close(),t.selections.clearAll();for(let e of l)e.destroy();v.close(),v.closeAllConnections(),d.close(()=>e()),d.closeAllConnections()}),await t.documents.close().catch(()=>void 0),await t.previewProxies.close().catch(()=>void 0),t.whiteboards.close(),t.leaveAgentDirectory(),t.voiceRunner.close(),t.exportRunner.close()}}}const EXt=e=>TXt(e);function DXt(e=process.env,t=p.default.homedir()){let n=e.RYUGI_SERVER_HOME||m.default.join(t,`.ryugi`,`server`);return{home:n,pid:m.default.join(n,`server.pid`),serverId:m.default.join(n,`server-instance-id`),info:m.default.join(n,`server-info`),log:m.default.join(n,`server.log`),version:m.default.join(n,`server-version`),lock:m.default.join(n,`start.lock`),key:m.default.join(n,`key`),projects:m.default.join(n,`projects.json`),settings:m.default.join(n,`settings.json`),stopped:m.default.join(n,`server-stopped`)}}function OXt(e){f.default.mkdirSync(e,{recursive:!0,mode:448}),f.default.chmodSync(e,448)}const kXt=e=>{try{return f.default.realpathSync(m.default.resolve(e))}catch{return m.default.resolve(e)}},AXt=e=>{let t=e;return!!t&&typeof t.dir==`string`&&m.default.isAbsolute(t.dir)&&Number.isFinite(t.registeredAt)&&Number.isFinite(t.lastUsedAt)};function Y9(e){try{let t=JSON.parse(f.default.readFileSync(e,`utf8`));return Array.isArray(t.projects)?t.projects.filter(AXt):[]}catch{return[]}}function X9(e,t){OXt(m.default.dirname(e));let n=`${e}.${process.pid}.tmp`;f.default.writeFileSync(n,`${JSON.stringify({projects:t},null,2)}\n`,{mode:384}),f.default.renameSync(n,e)}function jXt(e,t,n=Date.now()){let r=kXt(t),i=Y9(e),a=i.find(e=>e.dir===r);return a?a.lastUsedAt=n:i.push({dir:r,registeredAt:n,lastUsedAt:n}),X9(e,i),a??i.at(-1)}function MXt(e,t){let n=kXt(t),r=Y9(e),i=r.filter(e=>e.dir!==n);i.length!==r.length&&X9(e,i)}const Z9=e=>m.default.join(e,`.ryugi`,`artifacts`);function NXt(e){let t=Y9(e),n=t.filter(e=>f.default.existsSync(Z9(e.dir)));return n.length!==t.length&&X9(e,n),n}const PXt=(e,t=Date.now())=>t-e.lastUsedAt>6048e5,FXt=e=>{try{let t=f.default.readFileSync(m.default.join(e,`.artifact-id`),`utf8`).trim();return rn(t)?t:null}catch{return null}},IXt=e=>{try{return f.default.statSync(e).mtimeMs}catch{return 0}};function LXt(e,t={}){let n=t.rescanAfterMs??1e3,r=t.now??Date.now,i=[],a=-1/0,o=()=>{i=e().flatMap(e=>HV(Z9(e)).artifacts.map(t=>({project:e,type:t.type,id:t.id,address:FXt(t.dir),mtimeMs:IXt(t.dir)}))),a=r()},s=(t,n)=>{let r=e(),a=i.find(e=>e.type===t&&e.address===n);if(a)return a;let o=i.filter(e=>e.type===t&&e.id===n);return o.sort((e,t)=>r.indexOf(e.project)-r.indexOf(t.project)),o[0]??null};return{find(e,t){if(!an(t))return null;a===-1/0&&o();let i=s(e,t);return!i&&r()-a>=n&&(o(),i=s(e,t)),i?{project:i.project,id:i.id}:null},owners(e,t){let n=this.find(e,t);if(!n)return[];if(i.some(n=>n.type===e&&n.address===t))return[n.project];let r=i.filter(n=>n.type===e&&n.id===t).map(e=>e.project);return[...new Set(r)]},list(e=0){return r()-a>=e&&o(),i},rescan:o}}const RXt=e=>e.replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`),Q9=e=>String(e).padStart(2,`0`);function zXt(e){return`${e.getUTCFullYear()}${Q9(e.getUTCMonth()+1)}${Q9(e.getUTCDate())}-${Q9(e.getUTCHours())}${Q9(e.getUTCMinutes())}`}const BXt=()=>Array.from(crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(4)),e=>`abcdefghijkmnpqrstuvwxyz23456789`[e%32]).join(``);function VXt(e,t){let n=e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean),r=n[0]??``,i=(r.toLowerCase().match(/[a-z0-9]+/g)??[]).slice(0,5),a=[`task`,zXt(t),...i,BXt()].join(`-`),o=`新任务:${[...r].length>40?`${[...r].slice(0,40).join(``)}…`:r}`,s=n.map(e=>` <p>${RXt(e)}</p>`).join(`
|
|
1876
|
-
`);return{slug:a,title:o,xml:`<doc>\n <h1>${
|
|
1877
|
-
${e}`,n),u5e(n)&&setImmediate(()=>A.trigger(t,e))}),e.onReview(e=>setImmediate(()=>A.trigger(t,e))),h.set(t,m5e(m.default.join(Z9(t),`.state`),{subscribe:(e,n,r)=>A.subscribe(e,n,t,r),subscribed:(e,n,r)=>O.subscriptions(e,n).some(e=>e.project===t&&e.artifact===r)})),Te?.state().connected)for(let n of F(t).values())
|
|
1874
|
+
`).slice(0,40),r=Math.max(.55,...t.map(M9));return wYt(t,{x:l,y:u,width:a,step:(o||12*n)/t.length},e=>M9(e)/r*a,e.textAlign,s)}default:return``}}function DYt(e,t){let n=CYt(t),r=`<defs><pattern id="wb-grid" width="24" height="24" patternUnits="userSpaceOnUse"><path d="M 24 0 L 0 0 0 24" fill="none" stroke="var(--wb-grid)" stroke-width="0.7"/></pattern><filter id="wb-lift" x="-18%" y="-18%" width="136%" height="145%"><feDropShadow dx="0" dy="3" stdDeviation="6" flood-color="var(--shadow)" flood-opacity=".1"/></filter></defs><rect x="0" y="0" width="600" height="360" fill="var(--desk-wb)"/><rect x="0" y="0" width="600" height="360" fill="url(#wb-grid)"/>`;if(!n)return`${r}<rect x="56" y="48" width="488" height="264" rx="10" fill="none" stroke="var(--border-strong)" stroke-width="1.2" stroke-dasharray="5 4"/><text x="300" y="186" font-size="22" fill="var(--ink)" font-weight="600" text-anchor="middle">${xYt(e)}</text>`;let i=Math.min(536/Math.max(1,n.maxX-n.minX),296/Math.max(1,n.maxY-n.minY),2),a=(600-(n.maxX-n.minX)*i)/2,o=(360-(n.maxY-n.minY)*i)/2,s=(e,t)=>[Math.round((e-n.minX)*i+a),Math.round((t-n.minY)*i+o)];return r+t.map(e=>EYt(e,s,i)).join(``)}const N9=e=>typeof e==`object`&&e&&!Array.isArray(e)?e:{},P9=e=>typeof e==`string`?e:``,F9=e=>Array.isArray(e)?e.slice(0,200).map(N9):[],OYt=e=>e.replaceAll(/[&<>"']/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`})[e]),I9=e=>typeof e==`number`&&Number.isFinite(e)&&Math.abs(e)<=1e9,L9=(e,t,n,r,i=`var(--paper)`,a=`none`,o=0)=>`<rect x="${e}" y="${t}" width="${n}" height="${r}"${o>0?` rx="${o}"`:``} fill="${i}" stroke="${a}"/>`,R9=(e,t,n,r=9,i=`var(--ink)`,a=400,o=``)=>`<text x="${e}" y="${t}" font-size="${r}" fill="${i}" font-weight="${a}"${o}>${OYt(n)}</text>`,kYt=(e,t)=>t*(e.codePointAt(0)>=11904?1:.55),z9=(e,t)=>{let n=0;for(let r of e)n+=kYt(r,t);return n};function B9(e,t,n,r){let i=[],a=e.slice(0,4e3).split(`
|
|
1875
|
+
`);for(let e of a){let a=e.match(/[\u2E80-\uFFFF]|[^\s\u2E80-\uFFFF]+\s?|\s/g)??[],o=``,s=0,c=()=>{i.push(o.trimEnd()),o=``,s=0};for(let e of a){let a=z9(e,t);if(s+a<=n)o+=e,s+=a;else if(o&&a<=n){if(i.length===r-1)return i.push(`${o.trimEnd()}…`),i;c();let n=e.trimStart();o=n,s=z9(n,t)}else for(let a of e){let e=kYt(a,t);if(s+e>n){if(i.length===r-1)return i.push(`${o.trimEnd()}…`),i;c()}o+=a,s+=e}}if(o||a.length===0){if(i.length===r)return i[r-1]=`${i[r-1].trimEnd()}…`,i;c()}if(i.length>=r)return i.slice(0,r)}return i}function V9(e){let t=[e],n=[];for(let e=0;t.length&&e<300;e++){let e=t.pop();typeof e.text==`string`?n.push(e.text.slice(0,4e3)):t.push(...F9(e.children).reverse())}return n.join(``).slice(0,4e3)}const H9=(e,t=8,n=14,r=`.11`)=>`<filter id="${e}" x="-18%" y="-18%" width="136%" height="145%"><feDropShadow dx="0" dy="${t}" stdDeviation="${n}" flood-color="var(--shadow)" flood-opacity="${r}"/></filter>`;function AYt(e,t){let n=F9(N9(N9(t.state).root).children),r=[`<rect x="64" y="20" width="472" height="520" rx="8" fill="var(--paper)" stroke="var(--edge)" filter="url(#doc-lift)"/>`,`<rect x="96" y="48" width="28" height="3" rx="1.5" fill="var(--accent)"/>`],i=76,a=(e,t,n,a=0,o=400,s=`var(--ink)`)=>{for(let c of B9(e,t,408-a,n))r.push(R9(96+a,i,c,t,s,o)),i+=t*1.5};n[0]?.type!==`heading`&&(a(e,18,2,0,650),i+=6);for(let e of n.slice(0,18)){if(i>332)break;let t=P9(e.type);if(t===`heading`){let t=e.tag===`h1`?18:11.5;i+=e.tag===`h1`?0:8,a(V9(e),t,2,0,650),i+=6}else if(t===`table`){let t=F9(e.children).slice(0,5),n=408/Math.max(1,...t.map(e=>F9(e.children).length));t.forEach((e,t)=>{F9(e.children).forEach((e,a)=>{r.push(L9(96+a*n,i-8+t*22,n,22,t===0?`var(--block)`:`var(--paper)`,`var(--border)`)),r.push(R9(102+a*n,i+6+t*22,B9(V9(e),7.5,n-12,1)[0]??``,7.5,t===0?`var(--ink-soft)`:`var(--ink)`,t===0?600:400))})}),i+=t.length*22+10}else if(t===`list`)F9(e.children).slice(0,4).forEach((t,n)=>{r.push(R9(96,i,e.listType===`number`?`${n+1}.`:`•`,9,`var(--muted)`)),a(V9(t),9,2,13,400,`var(--ink-soft)`)}),i+=8;else if(t===`alert-quote`){let t=B9(F9(N9(N9(e.content).root).children).map(V9).join(` `),9,382,3);r.push(L9(96,i-8,408,t.length*14+16,`var(--alert)`,`none`,4),L9(96,i-8,3,t.length*14+16,`var(--alert-bar)`,`none`,1.5)),t.forEach(e=>{r.push(R9(110,i+7,e,9,`var(--ink-soft)`)),i+=14}),i+=20}else if(t===`code-block`){let t=B9(P9(e.code),8,386,4);r.push(L9(96,i-8,408,t.length*12+18,`var(--block)`,`var(--border)`,4)),t.forEach(e=>{r.push(R9(106,i+6,e,8,`var(--ink-soft)`)),i+=12}),i+=20}else t===`paragraph`||t===`quote`?(a(V9(e),9,3,0,400,`var(--ink-soft)`),i+=7):(r.push(L9(96,i-8,408,28,`var(--block)`,`none`,4),R9(106,i+10,t.toUpperCase().slice(0,30),8,`var(--muted)`)),i+=38)}return`${L9(0,0,600,360,`var(--desk)`)}<defs>${H9(`doc-lift`,8,14,`.11`)}</defs><g transform="rotate(-2 300 260)"><g transform="translate(0 8)">${r.join(``)}</g></g>`}function U9(e){let t=N9(e);return[t.x,t.y,t.w,t.h].every(I9)&&t.w>0&&t.h>0?t:null}function jYt(e,t){let n={};for(let[r,i]of Object.entries(N9(e.boards)).slice(0,2e3)){let e=U9(i);e&&N9(i).page===t&&(n[r]={x:e.x,y:e.y,w:e.w,h:e.h,page:t,file:``})}let r={};for(let[n,i]of Object.entries(N9(e.notes)).slice(0,200)){let e=N9(i);e.kind===`condition`&&e.page===t&&I9(e.x)&&I9(e.y)&&(r[n]={kind:`condition`,page:t,x:e.x,y:e.y,text:P9(e.text).slice(0,200)})}let i={};for(let[t,n]of Object.entries(N9(e.edges)).slice(0,200)){let e=N9(n);typeof e.from==`string`&&typeof e.to==`string`&&(i[t]={from:e.from,to:e.to})}return{version:1,pages:[{id:t,name:t}],boards:n,notes:r,edges:i}}const W9=(e,t,n,r,i=`var(--muted)`,a=`.34`)=>n>0&&r>0?`<rect x="${e}" y="${t}" width="${n}" height="${r}" rx="${r/2}" fill="${i}" fill-opacity="${a}"/>`:``;function MYt(e){let t=N9(e.canvas),n=P9(t.activePage)||P9(F9(t.pages)[0]?.id),r=N9(N9(N9(e.layout).pages)[n]),i=Object.values(N9(t.boards)).slice(0,2e3).map(N9).filter(e=>e.page===n&&U9(e)),a=N9(r.notes),o=N9(r.groups),s=N9(r.bounds),c=s.minX,l=s.minY,u=s.maxX,d=s.maxY;if(![c,l,u,d].every(I9)||u<=c||d<=l){if(!i.length)return`${L9(0,0,600,360,`var(--bg)`)}<defs><pattern id="dots" width="16" height="16" patternUnits="userSpaceOnUse"><circle cx="1.5" cy="1.5" r=".9" fill="var(--dot)"/></pattern></defs>${L9(0,0,600,360,`url(#dots)`)}`;c=Math.min(...i.map(e=>e.x)),l=Math.min(...i.map(e=>e.y)),u=Math.max(...i.map(e=>e.x+e.w)),d=Math.max(...i.map(e=>e.y+e.h))}let f=Math.max(1,u-c),p=Math.max(1,d-l),m=Math.min(544/f,304/p),h=(600-f*m)/2-c*m,g=(360-p*m)/2-l*m,_=[];for(let[e,n]of Object.entries(o).slice(0,200)){let r=U9(n);if(!r)continue;_.push(`<rect x="${r.x}" y="${r.y}" width="${r.w}" height="${r.h}" rx="${6/m}" fill="var(--paper)" fill-opacity=".35" stroke="var(--border-strong)" stroke-dasharray="${4/m} ${3/m}"/>`);let i=P9(N9(N9(t.groups)[e]).title).trim();if(i&&r.w*m>50){let e=4.5/m,t=Math.min(r.w-24/m,Math.max(24/m,z9(i,7/m)));_.push(W9(r.x+12/m,r.y+12/m,t,e,`var(--muted)`,`.36`))}}for(let e of ZKt(jYt(t,n),n)){let t=e.points.map(e=>`${e.x},${e.y}`).join(` `);_.push(`<polyline points="${t}" fill="none" stroke="var(--muted)" stroke-width="1.2" vector-effect="non-scaling-stroke"/>`);let n=e.points.at(-1);n&&_.push(`<circle cx="${n.x}" cy="${n.y}" r="${2.2/m}" fill="var(--muted)"/>`)}for(let e of i){let t=U9(e),n=t.w*m,r=t.h*m,i=Math.min(5,Math.min(n,r)*.12)/m;if(_.push(`<rect x="${t.x}" y="${t.y}" width="${t.w}" height="${t.h}" rx="${i}" fill="var(--paper)" stroke="var(--border-strong)" filter="url(#ab-lift)"/>`),n>42&&r>34){let e=10/m,n=7/m,r=t.w-n*2;_.push(`<rect x="${t.x}" y="${t.y}" width="${t.w}" height="${e}" rx="${i}" fill="var(--paper-subtle)"/>`,`<line x1="${t.x}" y1="${t.y+e}" x2="${t.x+t.w}" y2="${t.y+e}" stroke="var(--border)" stroke-width=".7" vector-effect="non-scaling-stroke"/>`,`<rect x="${t.x+n}" y="${t.y+e+6/m}" width="${r*.48}" height="${4.5/m}" rx="${2/m}" fill="var(--border-strong)"/>`,`<rect x="${t.x+n}" y="${t.y+e+14/m}" width="${r}" height="${Math.max(8/m,(t.h-e-22/m)*.48)}" rx="${2.5/m}" fill="var(--block)"/>`)}let a=P9(e.title).trim();if(a&&n>42){let e=3.5/m,n=Math.min(t.w*.72,Math.max(18/m,z9(a,6/m)));_.push(W9(t.x,t.y-8/m,n,e,`var(--muted)`,`.34`))}}for(let[e,r]of Object.entries(N9(t.notes)).slice(0,200)){let t=N9(r),i=U9(a[e]);if(t.page===n&&i){if(t.kind===`condition`){_.push(`<rect x="${i.x}" y="${i.y}" width="${i.w}" height="${i.h}" rx="${i.h/2}" fill="var(--paper)" stroke="var(--muted)"/>`);let e=P9(t.text).trim();if(e&&i.w*m>26){let t=Math.min(i.h*.36,3.5/m),n=Math.min(i.w*.65,Math.max(12/m,z9(e,5.5/m)));_.push(W9(i.x+(i.w-n)/2,i.y+(i.h-t)/2,n,t,`var(--muted)`,`.38`))}}else if(t.kind===`sticky`){let e=/^#[\da-f]{3}(?:[\da-f]{3})?$/i.test(P9(t.color))?P9(t.color):`var(--wb-sticky)`;_.push(`<rect x="${i.x}" y="${i.y}" width="${i.w}" height="${i.h}" rx="${4/m}" fill="${e}" stroke="var(--wb-sticky-edge)" filter="url(#ab-lift)"/>`);let n=P9(t.text).trim();if(n&&i.w*m>28){let e=6/m,t=Math.max(0,i.w-e*2),r=3.2/m,a=6.5/m;B9(n,5/m,t,3).forEach((n,o)=>{let s=i.y+e+o*a;if(s+r>i.y+i.h-e/2)return;let c=Math.min(t,Math.max(r*2,z9(n,5/m)));_.push(W9(i.x+e,s,c,r,`#514a37`,o===0?`.42`:`.26`))})}}else{let e=I9(t.size)&&t.size>0?t.size:96,n=P9(t.text).trim();if(n&&e*m>3){let t=Math.max(3/m,e*.42),r=Math.min(i.w,Math.max(t*2.5,z9(n,e*.65)));_.push(W9(i.x,i.y+(i.h-t)/2,r,t,`var(--muted)`,`.38`))}}}}return L9(0,0,600,360,`var(--bg)`)+`<defs>${H9(`ab-lift`,4,7,`.09`)}<pattern id="dots" width="16" height="16" patternUnits="userSpaceOnUse"><circle cx="1.5" cy="1.5" r=".9" fill="var(--dot)"/></pattern></defs>`+L9(0,0,600,360,`url(#dots)`)+`<g transform="translate(${h} ${g}) scale(${m})">${_.join(``)}</g>`}function NYt(e,t){let n=N9(t.report),r=F9(n.items),i=0,a=0,o=[];for(let e of r){let t=P9(e.kind);if(t===`gap`)a+=1,o.length<5&&o.push({kind:`gap`,title:P9(e.title)||`Unverified gap`,tag:`gap`});else if(t===`row`)i+=1,o.length<5&&o.push({kind:`row`,title:`${P9(e.artboard)} / ${P9(e.group)}`.replace(/^ \/ $/,`Artboard verify`),tag:`board`});else if(t===`claim`){i+=1;let t=F9(e.evidence).some(e=>P9(e.kind)===`output`);o.length<5&&o.push({kind:`claim`,title:P9(e.title)||`Claim`,tag:t?`output`:`evidence`})}}let s=B9(e,15.5,430,1),c=[],l=84,u=(e,t,n,r=!0)=>{let i=Math.max(66,Math.round(z9(e,9.5)+(r?30:22)));c.push(L9(l,94,i,22,t,`none`,11)),r&&c.push(`<circle cx="${l+13}" cy="105" r="3.5" fill="${n}"/>`),c.push(R9(r?l+22:l+i/2,108.5,e,9.5,n,600,r?``:` text-anchor="middle"`)),l+=i+8};u(i>0?`${i} checked`:`Verified`,`var(--pass-bg)`,`var(--pass)`,!0),a>0&&u(`${a} gap${a>1?`s`:``}`,`var(--warn-bg)`,`var(--warn)`,!0),r.length>0&&u(`${r.length} items`,`var(--block)`,`var(--muted)`,!1);let d=o.map((e,t)=>{let n=158+t*42,r=e.kind===`gap`,i=r?`<circle cx="96" cy="${n}" r="7.5" fill="var(--warn-bg)"/><rect x="95.1" y="${n-4}" width="1.8" height="4.8" rx=".9" fill="var(--warn)"/><circle cx="96" cy="${n+3.2}" r="1.1" fill="var(--warn)"/>`:`<circle cx="96" cy="${n}" r="7.5" fill="var(--pass-bg)"/><path d="M 92.5 ${n} L 95.2 ${n+2.7} L 100 ${n-2.6}" fill="none" stroke="var(--pass)" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/>`,a=B9(e.title,10.5,326,1)[0]??``;return i+R9(114,n+3.5,a,10.5,`var(--ink)`,500)+L9(454,n-9,62,18,r?`var(--warn-bg)`:`var(--block)`,`none`,9)+R9(485,n+3,e.tag,8,r?`var(--warn)`:`var(--muted)`,600,` text-anchor="middle"`)+`<line x1="84" y1="${n+21}" x2="516" y2="${n+21}" stroke="var(--border)" stroke-width=".7"/>`}).join(``),f=o.length===0?[0,1,2].map(e=>{let t=158+e*44;return`<circle cx="96" cy="${t}" r="7.5" fill="var(--pass-bg)"/><path d="M 92.5 ${t} L 95.2 ${t+2.7} L 100 ${t-2.6}" fill="none" stroke="var(--pass)" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/>`+L9(114,t-4,240-e*36,8,`var(--block)`,`none`,4)+L9(454,t-8,62,16,`var(--block)`,`none`,8)}).join(``):``;return L9(0,0,600,360,`var(--desk-verify)`)+`<defs>${H9(`vf-lift`,8,14,`.1`)}</defs><rect x="56" y="24" width="488" height="352" rx="10" fill="var(--paper)" stroke="var(--edge)" filter="url(#vf-lift)"/>`+R9(84,56,`VERIFY REPORT`,9,`var(--pass)`,650,` letter-spacing="0.06em"`)+R9(84,80,s[0]??e,15.5,`var(--ink)`,650)+c.join(``)+`<line x1="56" y1="130" x2="544" y2="130" stroke="var(--border)" stroke-width="1"/>`+d+f}function PYt(e,t,n,r,i){if(e===`two-cols`){let e=(r-14)/2;return L9(t,n,e,i,`var(--paper-subtle)`,`var(--border)`,5)+W9(t+12,n+14,e*.55,6,`var(--border-strong)`,`1`)+W9(t+12,n+28,e-24,5,`var(--block)`,`1`)+W9(t+12,n+40,e*.72,5,`var(--block)`,`1`)+L9(t+e+14,n,e,i,`var(--paper-subtle)`,`var(--border)`,5)+W9(t+e+26,n+14,e*.55,6,`var(--border-strong)`,`1`)+W9(t+e+26,n+28,e-24,5,`var(--block)`,`1`)+W9(t+e+26,n+40,e*.65,5,`var(--block)`,`1`)}if(e===`code`)return L9(t,n,r,i,`var(--block)`,`var(--border)`,6)+W9(t+14,n+14,74,5,`var(--accent)`,`.75`)+W9(t+26,n+28,176,5,`var(--muted)`,`.42`)+W9(t+26,n+40,132,5,`var(--muted)`,`.34`)+W9(t+14,n+52,92,5,`var(--muted)`,`.38`);if(e===`image`){let e=r*.44,a=t+e+14,o=r-e-14;return W9(t,n+10,e*.85,6,`var(--border-strong)`,`1`)+W9(t,n+24,e*.95,5,`var(--block)`,`1`)+W9(t,n+36,e*.75,5,`var(--block)`,`1`)+L9(a,n,o,i,`var(--block)`,`var(--border)`,6)+`<circle cx="${a+o*.28}" cy="${n+i*.34}" r="6" fill="var(--border-strong)"/><path d="M ${a+10} ${n+i-8} L ${a+o*.45} ${n+i*.46} L ${a+o*.7} ${n+i*.72} L ${a+o*.85} ${n+i*.56} L ${a+o-10} ${n+i-8} Z" fill="var(--border-strong)" fill-opacity=".65"/>`}return e===`quote`?L9(t,n+4,3.5,i-8,`var(--accent)`,`none`,1.75)+W9(t+16,n+12,r*.82,7,`var(--ink-soft)`,`.32`)+W9(t+16,n+28,r*.68,7,`var(--ink-soft)`,`.26`)+W9(t+16,n+48,84,5,`var(--muted)`,`.35`):e===`fact`?L9(t,n,128,i,`var(--accent-soft)`,`none`,6)+W9(t+18,n+i*.36,92,16,`var(--accent)`,`.82`)+W9(t+146,n+16,r-160,6,`var(--border-strong)`,`1`)+W9(t+146,n+30,(r-160)*.8,5,`var(--block)`,`1`)+W9(t+146,n+42,(r-160)*.6,5,`var(--block)`,`1`):e===`statement`||e===`section`||e===`end`?W9(t+r*.2,n+18,r*.6,7,`var(--border-strong)`,`.9`)+W9(t+r*.32,n+34,r*.36,5,`var(--block)`,`1`):``}function FYt(e,t,n){return e===`two-cols`?L9(t+5,n+6,14,12,`var(--block)`,`none`,1.5)+L9(t+22,n+6,14,12,`var(--block)`,`none`,1.5):e===`code`?L9(t+5,n+6,32,12,`var(--block)`,`none`,2)+L9(t+8,n+9,14,2,`var(--accent)`,`none`,1):e===`image`?L9(t+5,n+7,13,3,`var(--border-strong)`,`none`,1)+L9(t+5,n+12,10,2,`var(--block)`,`none`,1)+L9(t+21,n+6,16,12,`var(--block)`,`none`,2):e===`fact`?L9(t+5,n+6,14,12,`var(--accent-soft)`,`none`,2)+L9(t+22,n+8,14,3,`var(--border-strong)`,`none`,1)+L9(t+22,n+13,10,2,`var(--block)`,`none`,1):e===`quote`?L9(t+6,n+6,2,12,`var(--accent)`,`none`,1)+L9(t+11,n+8,22,2.5,`var(--border-strong)`,`none`,1)+L9(t+11,n+13,16,2,`var(--block)`,`none`,1):e===`section`||e===`statement`||e===`end`?L9(t+11,n+10,20,3.5,`var(--border-strong)`,`none`,1.5):L9(t+5,n+6,18,3,`var(--border-strong)`,`none`,1)+L9(t+5,n+12,28,2,`var(--block)`,`none`,1)+L9(t+5,n+16,22,2,`var(--block)`,`none`,1)}function IYt(e,t){let n=Array.isArray(t.outline)?t.outline.map(N9):F9(N9(t.outline).slides),r=n.length,i=P9(n[0]?.layout)||`cover`,a=r>0?`DECK · ${r} SLIDE${r===1?``:`S`}`:`SLIDES DECK`,o=B9(e,20.5,384,2),s=PYt(i,108,202,384,68),c=n.map(e=>P9(e.title)).filter(Boolean).slice(0,3),l=s||(c.length>0?c.map((e,t)=>{let n=216+t*20,r=B9(e,9.5,356,1)[0]??``;return R9(108,n,String(t+1).padStart(2,`0`),9.5,t===0?`var(--accent)`:`var(--muted)`,600)+R9(128,n,r,9.5,t===0?`var(--ink-soft)`:`var(--muted)`,400)}).join(``):L9(108,210,236,7,`var(--block)`,`none`,3.5)+L9(108,226,184,7,`var(--block)`,`none`,3.5)+L9(108,242,140,7,`var(--block)`,`none`,3.5)),u=Math.min(4,Math.max(3,r||4)),d=Array.from({length:u},(e,t)=>{let r=204+t*50,i=t===0,a=P9(n[t]?.layout)||(t===0?`cover`:`default`);return`<g${i?``:` opacity="${(.86-t*.12).toFixed(2)}"`}><rect x="${r}" y="308" width="42" height="24" rx="4" fill="var(--paper)" stroke="${i?`var(--accent)`:`var(--border-strong)`}" stroke-width="${i?`1.5`:`.8`}"/>`+FYt(a,r,308)+`</g>`}).join(``),f=r>0?R9(204+u*50+6,324,`1 / ${r}`,9.5,`var(--muted)`,600):``;return L9(0,0,600,360,`var(--desk-slides)`)+`<defs>${H9(`sl-lift`,10,16,`.12`)}</defs>`+L9(104,22,392,220,`var(--slide-back)`,`var(--border)`,8)+`<rect x="76" y="36" width="448" height="252" rx="8" fill="var(--paper)" stroke="var(--border-strong)" filter="url(#sl-lift)"/>`+L9(108,66,36,4,`var(--accent)`,`none`,2)+R9(108,94,a,9,`var(--muted)`,650,` letter-spacing="0.08em"`)+o.map((e,t)=>R9(108,130+t*28,e,20.5,`var(--ink)`,700)).join(``)+`<line x1="108" y1="192" x2="492" y2="192" stroke="var(--border)" stroke-width=".8"/>`+l+d+f}function G9(e,t,n,r,i){if(e===`cards`){let e=r>280?3:2,a=(r-10*(e-1))/e;return Array.from({length:e},(e,r)=>{let o=t+r*(a+10);return L9(o,n,a,i,`var(--paper-subtle)`,`var(--border)`,6)+W9(o+10,n+12,a*.52,5.5,`var(--border-strong)`,`1`)+W9(o+10,n+24,a-20,4.5,`var(--block)`,`1`)+W9(o+10,n+34,a*.65,4.5,`var(--block)`,`1`)}).join(``)}if(e===`table`){let e=Math.max(2,Math.min(4,Math.floor(i/18))),a=i/e;return L9(t,n,r,i,`var(--paper)`,`var(--border)`,5)+L9(t,n,r,a,`var(--block)`,`none`,5)+Array.from({length:e},(e,i)=>{let o=n+i*a;return(i>0?`<line x1="${t}" y1="${o}" x2="${t+r}" y2="${o}" stroke="var(--border)" stroke-width=".7"/>`:``)+W9(t+10,o+a*.35,r*.24,4.5,i===0?`var(--muted)`:`var(--border-strong)`,i===0?`.5`:`.8`)+W9(t+r*.42,o+a*.35,r*.28,4.5,`var(--block)`,`1`)+W9(t+r*.78,o+a*.35,r*.14,4.5,`var(--block)`,`1`)}).join(``)}if(e===`code`)return L9(t,n,r,i,`var(--block)`,`var(--border)`,6)+W9(t+14,n+12,r*.28,5,`var(--accent)`,`.75`)+W9(t+26,n+24,r*.56,4.5,`var(--muted)`,`.42`)+W9(t+26,n+35,r*.42,4.5,`var(--muted)`,`.34`);if(e===`form`){let e=Math.min(r*.62,240);return L9(t,n,r,i,`var(--paper-subtle)`,`var(--border)`,6)+L9(t+12,n+10,e,18,`var(--paper)`,`var(--border)`,4)+L9(t+12,n+34,e,18,`var(--paper)`,`var(--border)`,4)+L9(t+e+22,n+34,Math.min(72,r-e-34),18,`var(--accent)`,`none`,4)}if(e===`chart`){let e=[.38,.62,.5,.82,.68,.94,.72],a=Math.min(26,(r-28-8*(e.length-1))/e.length);return L9(t,n,r,i,`var(--paper-subtle)`,`var(--border)`,6)+e.map((e,r)=>{let o=Math.max(8,(i-20)*e);return L9(t+14+r*(a+8),n+i-8-o,a,o,r===5?`var(--accent)`:`var(--chart-bar-mid)`,`none`,3)}).join(``)}if(e===`list`){let e=Math.max(2,Math.min(3,Math.floor(i/16)));return Array.from({length:e},(e,i)=>{let a=n+6+i*16;return`<circle cx="${t+5}" cy="${a+2.5}" r="2.5" fill="var(--accent)"/>`+W9(t+16,a,r*(.78-i*.14),5,`var(--border-strong)`,`.85`)}).join(``)}return W9(t,n+6,r*.92,5.5,`var(--border-strong)`,`.8`)+W9(t,n+19,r*.84,5,`var(--block)`,`1`)+W9(t,n+31,r*.62,5,`var(--block)`,`1`)}function LYt(e){let t=e.boxes.map(t=>{if(t.kind===`text`){let n=Math.max(3,Math.min(t.h*.65,14)),r=Math.round((t.y+(t.h-n)/2)*10)/10,i=n>=9?`.62`:`.36`;return`<rect x="${t.x}" y="${r}" width="${t.w}" height="${Math.round(n*10)/10}" rx="${Math.round(n/2*10)/10}" fill="${t.bg??e.ink??`var(--ink)`}" fill-opacity="${i}"/>`}let n=t.r??(t.kind===`control`?4:3),r=t.bg??`none`,i=t.border??`none`,a=`<rect x="${t.x}" y="${t.y}" width="${t.w}" height="${t.h}"${n>0?` rx="${n}"`:``} fill="${r}" stroke="${i}"/>`;if(t.kind===`media`&&t.w>=36&&t.h>=24){let n=Math.round((t.x+t.w*.3)*10)/10,r=Math.round((t.y+t.h*.34)*10)/10,i=Math.max(2.5,Math.min(6,Math.min(t.w,t.h)*.12));return`${a}<circle cx="${n}" cy="${r}" r="${Math.round(i*10)/10}" fill="${e.ink??`var(--muted)`}" fill-opacity=".2"/>`}return a}).join(``);return`<clipPath id="ht-vp"><rect x="45" y="60" width="510" height="300"/></clipPath><g clip-path="url(#ht-vp)"><rect x="45" y="60" width="510" height="300" fill="${e.bg}"/><g transform="translate(45 60) scale(0.85 0.8333)">${t}</g></g>`}function RYt(e,t,n){let r=e.project?.split(`/`).at(-1),i=r?`${r} / HTML`:`index.html`,a=pK(n.domSnapshot);if(a)return L9(0,0,600,360,`var(--cover)`)+`<defs>${H9(`ht-lift`,8,14,`.1`)}</defs><rect x="44" y="26" width="512" height="352" rx="10" fill="var(--paper)" stroke="var(--border-strong)" filter="url(#ht-lift)"/><path d="M 45 36 Q 45 27 54 27 L 546 27 Q 555 27 555 36 L 555 60 L 45 60 Z" fill="var(--paper-subtle)"/><line x1="44" y1="60" x2="556" y2="60" stroke="var(--border)" stroke-width="1"/><circle cx="64" cy="43.5" r="4" fill="var(--border-strong)"/><circle cx="78" cy="43.5" r="4" fill="var(--border-strong)"/><circle cx="92" cy="43.5" r="4" fill="var(--border-strong)"/>`+L9(176,34,248,19,`var(--block)`,`none`,9.5)+R9(300,46.5,B9(i,9,224,1)[0]??i,9,`var(--muted)`,500,` text-anchor="middle"`)+R9(536,47,`</>`,10.5,`var(--muted)`,600,` text-anchor="end"`)+LYt(a);let o=N9(n.skeleton),s=o.hasNav===!0,c=o.hasSidebar===!0,l=Array.isArray(o.blocks)?o.blocks.filter(e=>typeof e==`string`&&[`cards`,`chart`,`code`,`form`,`list`,`table`,`text`].includes(e)):[],u=P9(o.heading)||t,d=c?168:74,f=c?358:452,p=60,m=[];s&&(m.push(L9(45,60,510,26,`var(--paper)`,`none`),`<line x1="44" y1="86" x2="556" y2="86" stroke="var(--border)" stroke-width=".7"/>`,`<circle cx="66" cy="73" r="4.5" fill="var(--accent)"/>`,W9(78,70.5,44,5,`var(--ink-soft)`,`.55`),W9(366,71,32,4,`var(--muted)`,`.35`),W9(408,71,32,4,`var(--muted)`,`.35`),W9(450,71,32,4,`var(--muted)`,`.35`),L9(494,66,42,14,`var(--accent-soft)`,`none`,7)),p=86),c&&m.push(L9(45,p,108,378-p,`var(--paper-subtle)`,`none`),`<line x1="153" y1="${p}" x2="153" y2="378" stroke="var(--border)" stroke-width=".8"/>`,W9(60,p+18,56,5.5,`var(--border-strong)`,`.95`),L9(56,p+34,84,18,`var(--accent-soft)`,`none`,4),W9(64,p+40.5,48,5,`var(--accent)`,`.75`),W9(64,p+64,62,4.5,`var(--muted)`,`.34`),W9(64,p+80,52,4.5,`var(--muted)`,`.34`),W9(64,p+96,68,4.5,`var(--muted)`,`.34`),W9(64,p+112,44,4.5,`var(--muted)`,`.28`));let h=p+26,g=B9(u,18,f,2);m.push(g.map((e,t)=>R9(d,h+t*24,e,18,`var(--ink)`,650)).join(``));let _=h+g.length*24+10;if(l.length>0){let e=Math.max(60,344-_),t=l.slice(0,2),n=Math.min(82,(e-12*(t.length-1))/t.length);t.forEach((e,t)=>{m.push(G9(e,d,_+t*(n+12),f,n))})}else m.push(G9(`cards`,d,_,f,66),G9(`text`,d,_+78,f,44));return L9(0,0,600,360,`var(--cover)`)+`<defs>${H9(`ht-lift`,8,14,`.1`)}</defs><rect x="44" y="26" width="512" height="352" rx="10" fill="var(--paper)" stroke="var(--border-strong)" filter="url(#ht-lift)"/><path d="M 45 36 Q 45 27 54 27 L 546 27 Q 555 27 555 36 L 555 60 L 45 60 Z" fill="var(--paper-subtle)"/><line x1="44" y1="60" x2="556" y2="60" stroke="var(--border)" stroke-width="1"/><circle cx="64" cy="43.5" r="4" fill="var(--border-strong)"/><circle cx="78" cy="43.5" r="4" fill="var(--border-strong)"/><circle cx="92" cy="43.5" r="4" fill="var(--border-strong)"/>`+L9(176,34,248,19,`var(--block)`,`none`,9.5)+R9(300,46.5,B9(i,9,224,1)[0]??i,9,`var(--muted)`,500,` text-anchor="middle"`)+R9(536,47,`</>`,10.5,`var(--muted)`,600,` text-anchor="end"`)+m.join(``)}function zYt(e){let t=B9(e,16,444,1),n=[44,62,54,82,74,108,92,122,98].map((e,t)=>{let n=96+t*46,r=324-e;return L9(n,r,28,e,t===7?`var(--accent)`:t>=5?`var(--chart-bar-mid)`:`var(--chart-bar)`,`none`,4)}).join(``);return L9(0,0,600,360,`var(--desk-report)`)+`<defs>${H9(`rp-lift`,8,14,`.1`)}</defs><rect x="48" y="24" width="504" height="352" rx="10" fill="var(--paper)" stroke="var(--edge)" filter="url(#rp-lift)"/>`+R9(78,54,`DATA REPORT`,9,`var(--muted)`,650,` letter-spacing="0.06em"`)+R9(78,78,t[0]??e,16,`var(--ink)`,650)+L9(78,96,138,58,`var(--paper-subtle)`,`var(--border)`,6)+L9(92,110,46,5,`var(--border-strong)`,`none`,2.5)+`<rect x="92" y="124" width="76" height="14" rx="3" fill="var(--ink)" fill-opacity=".78"/>`+L9(230,96,138,58,`var(--paper-subtle)`,`var(--border)`,6)+L9(244,110,52,5,`var(--border-strong)`,`none`,2.5)+`<rect x="244" y="124" width="64" height="14" rx="3" fill="var(--accent)" fill-opacity=".88"/>`+L9(382,96,140,58,`var(--paper-subtle)`,`var(--border)`,6)+L9(396,110,58,5,`var(--border-strong)`,`none`,2.5)+`<rect x="396" y="124" width="70" height="14" rx="3" fill="var(--pass)" fill-opacity=".8"/><line x1="78" y1="202" x2="522" y2="202" stroke="var(--border)" stroke-width=".6" stroke-dasharray="3 3"/><line x1="78" y1="242" x2="522" y2="242" stroke="var(--border)" stroke-width=".6" stroke-dasharray="3 3"/><line x1="78" y1="282" x2="522" y2="282" stroke="var(--border)" stroke-width=".6" stroke-dasharray="3 3"/><line x1="78" y1="324" x2="522" y2="324" stroke="var(--border-strong)" stroke-width="1"/>`+n}function BYt(e){let t=B9(e,16,444,1),n=[0,1,2,3].map(e=>{let t=78+e*114;return L9(t,112,102,58,e===1?`var(--ink)`:`var(--paper-subtle)`,`var(--border)`,5)+L9(t+10,182,62,5,`var(--border-strong)`,`none`,2.5)+L9(t+10,194,44,5,`var(--border)`,`none`,2.5)}).join(``),r=[70,120,60,110,84].reduce((e,t,n)=>({x:e.x+t+4,svg:e.svg+L9(e.x,300,t,14,n===1?`var(--ink)`:`var(--block)`,`none`,3)}),{x:78,svg:``}).svg;return L9(0,0,600,360,`var(--cover)`)+`<defs>${H9(`sb-lift`,8,14,`.1`)}</defs><rect x="48" y="24" width="504" height="352" rx="10" fill="var(--paper)" stroke="var(--edge)" filter="url(#sb-lift)"/>`+R9(78,54,`STORYBOARD`,9,`var(--muted)`,650,` letter-spacing="0.06em"`)+R9(78,78,t[0]??e,16,`var(--ink)`,650)+n+`<line x1="78" y1="240" x2="522" y2="240" stroke="var(--border)" stroke-width=".6" stroke-dasharray="3 3"/>`+L9(78,258,300,6,`var(--border-strong)`,`none`,3)+L9(78,272,220,6,`var(--border)`,`none`,3)+r+`<line x1="190" y1="294" x2="190" y2="320" stroke="var(--accent)" stroke-width="2"/>`}function VYt(e,t){let n=e.title??e.id,r;if(e.type===`document`)r=AYt(n,N9(t));else if(e.type===`artboard`)r=MYt(N9(t));else if(e.type===`whiteboard`){let e=N9(t).scene;r=DYt(n,Array.isArray(e)?e:[])}else r=e.type===`verify`?NYt(n,N9(t)):e.type===`slides`?IYt(n,N9(t)):e.type===`report`?zYt(n):e.type===`storyboard`?BYt(n):RYt(e,n,N9(t));return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 600 360"><title>${OYt(n)}</title><style>:root{--ink:#1f1e1b;--ink-soft:#4c4943;--muted:#7e7a72;--paper:#ffffff;--paper-subtle:#f9f8f5;--bg:#f3f2ee;--border:#dedbd4;--border-strong:#ccc8be;--block:#f2f0eb;--alert:#f9f1e9;--alert-bar:#c65d3b;--accent:#c65d3b;--accent-soft:#f6e6df;--desk:#eeece7;--edge:#dedbd4;--dot:#d4d0c7;--shadow:#1a1814;--desk-wb:#f7f6f2;--wb-grid:#e7e5de;--wb-sticky:#fef2bd;--wb-sticky-edge:#e6d48a;--wb-sticky-ink:#5c4e24;--desk-verify:#edf2ee;--pass:#2b8a57;--pass-bg:#e4f4eb;--warn:#b87216;--warn-bg:#fbf0dc;--desk-slides:#e9ebef;--slide-back:#d8dce3;--cover:#eaf0f3;--desk-report:#eef0f3;--chart-bar:#d3d8e0;--chart-bar-mid:#b5becb}@media (prefers-color-scheme: dark){:root{--ink:#eceae4;--ink-soft:#c2bfb8;--muted:#8f8c84;--paper:#252522;--paper-subtle:#2c2c29;--bg:#191917;--border:#3a3a35;--border-strong:#4b4b45;--block:#30302c;--alert:#362d26;--alert-bar:#e07a57;--accent:#e07a57;--accent-soft:#3b2922;--desk:#1b1b19;--edge:#3a3a35;--dot:#363631;--shadow:#000000;--desk-wb:#1e1e1c;--wb-grid:#2b2b27;--wb-sticky:#3d3520;--wb-sticky-edge:#574a28;--wb-sticky-ink:#f0df9e;--desk-verify:#19201b;--pass:#4cc38a;--pass-bg:#1d3327;--warn:#e5a94c;--warn-bg:#352b1a;--desk-slides:#181a1f;--slide-back:#2d313a;--cover:#181e22;--desk-report:#191c20;--chart-bar:#343942;--chart-bar-mid:#48505e}}text{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,PingFang SC,sans-serif}rect{stroke-width:.8;vector-effect:non-scaling-stroke}</style>${r}</svg>`}const HYt=/^\/api\/artifacts\/([^/]+)\/([^/]+)$/,UYt=/^\/api\/preview\/([^/]+)\/([^/]+)$/,WYt=/^\/api\/thumbnail\/([^/]+)\/([^/]+)\.svg$/,GYt={path:`/api/artifacts`,auth:`viewer`,handle:(e,t,n)=>{let{artifacts:r,warnings:i}=P5e(n),a=r.map(e=>{let t=TV(e.dir);if(e.type===`html`)try{let r=f.default.statSync(m.default.join(n.stateDir,`html`,e.id,`dom-skeleton.json`));t=Math.max(t,Math.floor(r.mtimeMs))}catch{}return{type:e.type,id:e.id,url:qV(n.root,e.type,e.id),title:n9(n.readArtifact(e.dir,e)),updatedAt:t}});L(t,200,{project:r9(n),artifacts:a,warnings:i})}},KYt={path:HHt,auth:`viewer`,handle:(e,t,n,{match:r})=>{n.avatars.load(r[1],r[2]).then(({status:e,type:n,body:r})=>{r&&n?ae(t,e,r,{"Content-Type":n,"Cache-Control":`private, max-age=86400`}):ae(t,e,`No avatar`)})}},qYt={path:UYt,auth:`viewer`,handle:(e,t,n,{match:r})=>{let[,i=``,a=``]=r,o=UV(n.root,i,a),s=WV(`${i}/${a}`);if(!o||!s)L(t,404,{error:`Artifact not found`});else try{let e=n.readArtifact(o,s),r=n9(e);L(t,200,{...OK(s,o,r,e),title:r,warnings:e.warnings,contentBase:`${n.contentPrefix}${i}/${a}/`})}catch{L(t,422,{error:`Preview unavailable`})}}},JYt={path:WYt,auth:`viewer`,handle:(e,t,n,{match:r})=>{let i=WV(`${r[1]}/${r[2]}`,an),a;try{a=i&&JV(n.root,i.type,i.id)}catch{a=null}if(!a)ae(t,404,`Artifact not found`);else try{let e={type:a.type,id:a.id},r=n.readArtifact(a.dir,e),i=n9(r);ae(t,200,VYt({id:e.id,type:e.type,title:i,project:r9(n)},OK(e,a.dir,i,r)),{"Content-Type":`image/svg+xml`,"Cache-Control":`private, max-age=31536000, immutable`,"Content-Security-Policy":`sandbox; default-src 'none'; style-src 'unsafe-inline'`,"X-Content-Type-Options":`nosniff`})}catch{ae(t,422,`Thumbnail unavailable`)}}},YYt={path:HYt,auth:`viewer`,handle:(e,t,n,{match:r})=>{let[,i=``,a=``]=r,o=UV(n.root,i,a);if(!o){L(t,404,{warnings:[`artifact ${i}/${a} not found`]});return}let s=WV(`${i}/${a}`);eH(n,s),L(t,200,{...n.artifactMeta(s,o),...s.type===`artboard`&&n.boardPort?{boardPort:n.boardPort,boardPath:`/c${qV(n.root,`artboard`,s.id)}/`}:{}})}},XYt={path:(e,t)=>t.cloud&&e===`/api/cloud/callback`?[e]:null,auth:`public`,handle:(e,t,n,{url:r})=>n.cloud.handleCallback(r,t,u7(d7(e.headers[`accept-language`])))},ZYt={path:(e,t)=>t.cloud&&e===`/api/cloud/callback/auto-publish`?[e]:null,auth:`public`,handle:(e,t,n)=>n.cloud.handleCallbackAutoPublish(e,t,u7(d7(e.headers[`accept-language`])))},QYt={path:`/api/cloud/flush`,methods:[`POST`],auth:`agent`,handle:(e,t,n,{url:r})=>{let{autoPublisher:i,cloud:a}=n;if(!i){L(t,404,{error:`cloud publishing is not configured`});return}P5e(n);let o=i.flush().then(()=>a?.syncModules());r.searchParams.get(`wait`)===`1`?o.then(()=>L(t,200,{flushed:!0})):L(t,202,{queued:!0})}},$Yt={path:(e,t)=>t.cloud?.match(e)??null,auth:`cloud`,handle:(e,t,n,{match:r})=>{let[,i,a,o]=r,s=(i===`reserve`||i===`publish`&&e.method===`POST`)&&a&&o?WV(`${a}/${o}`):null;s&&eH(n,s),n.cloud.handle(e,t,r)}},eXt={path:`/api/agent/daemon`,methods:[`POST`],auth:`same-origin`,handle:async(e,t,n)=>{let r=n.options.agentDaemon;if(!r){L(t,404,{error:`this computer has no daemon`});return}let i=await o9(e),{artifact:a,...o}=typeof i==`object`&&i?i:{};if(typeof a!=`string`||!WV(a))L(t,400,{error:`need an artifact`});else try{L(t,200,{ok:!0,data:await r.request(a,o,n.loopback)})}catch(e){L(t,409,{ok:!1,error:e.message})}}},tXt=/^\/relay\/a\/([\w-]{1,64})$/,nXt=RegExp(`(?:^|/)(${Ee.join(`|`)})/([\\w-]+)`);function rXt(e,t){let n=t===null?null:nXt.exec(t);if(!n)return null;let r=n[1],i=n[2];if(UV(e,r,i))return`${r}/${i}`;try{return`${r}/${JV(e,r,i)?.id??i}`}catch{return`${r}/${i}`}}const iXt={path:tXt,auth:`direct-relay`,handle:(e,t,n,{match:r,clientKey:i})=>{let a=n.servedArtifacts().get(r[1]);a?n.direct.accept(t,i,a):ZV(t,404,`Not Found`)}},aXt={path:`/ws`,auth:`socket`,handle:(e,t,n,{clientKey:r})=>{D5e(t,r),n.clients.add(t);let i=rXt(n.root,new URL(e.url??`/`,`http://x`).searchParams.get(`at`)),a=i?[e9,i]:[e9,uKt];a.forEach(n.viewed.viewerJoined),t.write(n.agentStatusFrame());for(let e of n.threadActivityFrames())t.write(e);O5e(t,e=>But(n,t,e));let o=()=>{n.clients.delete(t)&&(n.selections.drop(t),a.forEach(n.viewed.viewerLeft))};t.on(`end`,()=>{o(),t.end()}),t.on(`close`,o),t.on(`error`,o),n.touch()}},oXt={artboard:{fill:`M9.3 9a1.3 1.3 0 1 1-2.6 0a1.3 1.3 0 1 1 2.6 0z M13.3 7a1.3 1.3 0 1 1-2.6 0a1.3 1.3 0 1 1 2.6 0z M17.3 9.5a1.3 1.3 0 1 1-2.6 0a1.3 1.3 0 1 1 2.6 0z M8.8 13a1.3 1.3 0 1 1-2.6 0a1.3 1.3 0 1 1 2.6 0z`,stroke:`M12 3.5c-5 0-8.5 3.8-8.5 8.5s3.6 8.5 7.6 8.5c1.2 0 1.6-.8 1.6-1.9v-1.3c0-1.3 1-2.3 2.3-2.3h2.3c2.2 0 3.7-1.5 3.7-3.6 0-4.4-4-7.9-9-7.9z`},document:{fill:``,stroke:`M7 3h10a2.5 2.5 0 0 1 2.5 2.5v13a2.5 2.5 0 0 1-2.5 2.5H7a2.5 2.5 0 0 1-2.5-2.5v-13A2.5 2.5 0 0 1 7 3z M8.5 8.5h7M8.5 12h7M8.5 15.5h4`},html:{fill:``,stroke:`M8 7.5 3.5 12 8 16.5M16 7.5l4.5 4.5-4.5 4.5M13.5 5.5l-3 13`},whiteboard:{fill:``,stroke:`M5 4.5h14a1.5 1.5 0 0 1 1.5 1.5v10a1.5 1.5 0 0 1-1.5 1.5H5A1.5 1.5 0 0 1 3.5 16V6A1.5 1.5 0 0 1 5 4.5z M7 13.5c1.5-2.5 3-3.5 4-2s2.5 1 4.5-2 M9 17.5l-1.5 3M15 17.5l1.5 3`},verify:{fill:``,stroke:`M7 3h10a2.5 2.5 0 0 1 2.5 2.5v13a2.5 2.5 0 0 1-2.5 2.5H7a2.5 2.5 0 0 1-2.5-2.5v-13A2.5 2.5 0 0 1 7 3z M8.5 9l1.5 1.5 3-3M8.5 15l1.5 1.5 3-3M15 9.5h1M15 15.5h1`},slides:{fill:``,stroke:`M3.5 4.5h17M5 4.5V14a1.5 1.5 0 0 0 1.5 1.5h11A1.5 1.5 0 0 0 19 14V4.5M12 15.5v2.5M8.5 20.5l3.5-2.5 3.5 2.5M9 8.5h6M9 11.5h3.5`},report:{fill:``,stroke:`M4 20h16M7 16.5v-4M11 16.5v-8M15 16.5v-6M19 16.5V5.5`},storyboard:{fill:``,stroke:`M4 10h16v8.5a1.5 1.5 0 0 1-1.5 1.5h-13A1.5 1.5 0 0 1 4 18.5V10z M4 10l-.6-3a1.3 1.3 0 0 1 1-1.5l12.7-2.4a1.3 1.3 0 0 1 1.5 1l.5 2.6L4 10z M8.4 4.9l2.5 3.2M12.9 4l2.5 3.2`}},sXt=`#C65D3B`;function cXt(e){let{fill:t,stroke:n}=oXt[e],r=[`<svg xmlns="http://www.w3.org/2000/svg" viewBox="-2 -2 28 28">`,`<rect x="-2" y="-2" width="28" height="28" rx="6" fill="#FBEDE6"/>`,t&&`<path d="${t}" fill="${sXt}"/>`,`<path d="${n}" fill="none" stroke="${sXt}" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round"/>`,`</svg>`].join(``);return`data:image/svg+xml,${encodeURIComponent(r)}`}const K9=e=>e.replaceAll(/[&<>"']/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`})[e]);function lXt(e,t){let n=t.locale??`en`,r={robots:`noindex, nofollow`,"og:locale":n===`zh`?`zh_CN`:`en_US`,description:t.description,"og:title":t.title,"og:description":t.description,"twitter:title":t.title,"twitter:description":t.description};return e.replace(/<html\b([^>]*)>/i,(e,r)=>`<html${r.replace(/\slang="[^"]*"/i,``)} lang="${mUt[n]}"${t.artifactId?` data-ryugi-artifact-id="${K9(t.artifactId)}"`:``}${t.project?` data-ryugi-project="${K9(t.project)}"`:``}${t.embedParent?` data-ryugi-embed-parent="${K9(t.embedParent)}"`:``}>`).replace(/<title\b[^>]*>[\s\S]*?<\/title>/i,()=>`<title>${K9(t.title)}</title>`).replace(/(<link\b[^>]+\brel="icon"[^>]*\bhref=")[^"]*(")/i,(e,n,r)=>t.icon?`${n}${K9(t.icon)}${r}`:e).replaceAll(/(<meta\b[^>]+\b(?:name|property)="([^"]+)"[^>]*\bcontent=")([^"]*)("[^>]*>)/gi,(e,n,i,a,o)=>{let s=r[i]??(i===`og:image`||i===`twitter:image`?new URL(a,t.url).href:void 0);return s===void 0?e:`${n}${K9(s)}${o}`}).replace(/<\/head>/i,()=>`<link rel="canonical" href="${K9(t.url)}">\n<meta property="og:url" content="${K9(t.url)}">\n</head>`)}const uXt=/<script\b(?![^>]+\bsrc=)[^>]*>([\s\S]*?)<\/script>/gi;function dXt(e,t){let n=[...t.matchAll(uXt)].map(([,e])=>`'sha256-${(0,d.createHash)(`sha256`).update(e).digest(`base64`)}'`);return n.length?e.replace(/script-src [^;]*/,e=>`${e} ${n.join(` `)}`):e}const fXt=RegExp(`^/(?:(${Ee.join(`|`)})/([^/]+)/?)?$`),pXt=RegExp(`^/preview/(artboard|document|html)/${Yt}/?$`),mXt=/^\/preview\/([a-z0-9][a-z0-9-]{0,63})\/?$/,hXt=/^\/storyboard\/([^/]+)\/render\/?$/,gXt=/^\/embed\/(artboard|document|whiteboard|verify|slides)\/([\w-]{1,64})\/?$/,q9=e=>[`default-src 'self'`,`script-src 'self' 'wasm-unsafe-eval'`,`style-src 'self' 'unsafe-inline'`,`img-src 'self' data: blob:`,`font-src 'self' data:`,`connect-src 'self' ${e.join(` `)}`,`frame-src 'self' ${e.join(` `)}`,`base-uri 'self'`,`form-action 'none'`,`frame-ancestors 'none'`].join(`; `);function J9(e,t,n,{pathname:r,key:i},a){let{root:o,options:s,loopback:c,viewerDir:l}=n,u=a!==null,d=pXt.test(r),p=d?null:mXt.exec(r),h=a||(p?null:WV(r.replace(d?/^\/preview\//:/^\//,``).replace(/\/$/,``).replace(/^(storyboard\/[^/]+)\/render$/,`$1`),an)),g=h&&JV(o,h.type,h.id),_=g??h,v=g?.dir,y=r9(n),b=p?`${p[1]} · Preview · ${y}`:_?v?n9(n.readArtifact(v,_)):_.id:`${y} · Artifacts`,x=u7(d7(e.headers[`accept-language`])),S=p7(x),C=_?S(`meta.artifact`,{project:y,title:b,type:{artboard:`Artboard`,document:`Document`,html:`HTML`,whiteboard:`Whiteboard`,verify:`Verify report`,report:`Report`,slides:`Slides`,storyboard:`Storyboard`}[_.type]}):S(`meta.library`,{project:y}),w=p?`/preview/${p[1]}`:_?v?qV(o,_.type,_.id):`/${_.type}/${_.id}`:`/`,T=`http://${ie(s.urlHost)}:${n.port}${d?`/preview`:``}${w}`,E=p?[...n.boardOrigins(),`http://localhost:*`,`http://127.0.0.1:*`]:n.boardOrigins(),D=u?q9(E).replace(`frame-ancestors 'none'`,`frame-ancestors 'self'${s.cloud?` ${s.cloud.origin}`:``}`):d?q9(E).replace(`frame-ancestors 'none'`,`frame-ancestors 'self'`):q9(E),O={"Content-Type":`text/html; charset=utf-8`};(_||p)&&(O[`Referrer-Policy`]=`same-origin`),i!==null&&!c&&(O[`Set-Cookie`]=`${n.cookieName}=${n.token}; HttpOnly; SameSite=Strict; Path=/`);let k=d&&f.default.existsSync(m.default.join(l,`preview.html`))?`preview.html`:`index.html`;f.default.promises.readFile(m.default.join(l,k),`utf8`).then(n=>{let r=lXt(n,{title:b,description:C,locale:x,url:T,icon:_?cXt(_.type):void 0,artifactId:g?.id,project:y,embedParent:u&&e.headers[`sec-fetch-site`]!==`same-origin`?s.cloud?.origin:void 0});ae(t,200,r,{...O,"Content-Security-Policy":dXt(D,r)})}).catch(e=>ae(t,e.code===`ENOENT`?404:500,`Viewer unavailable`))}const _Xt=[EKt,DKt,OKt,XYt,ZYt,GYt,KYt,qYt,JYt,QYt,$Yt,_Yt,Cqt,Sqt,wqt,uYt,Eqt,PJt,kqt,Aqt,eXt,Mqt,NKt,FKt,VKt,HKt,bJt,xJt,SJt,CJt,MJt,NJt,FJt,LJt,zJt,uJt,dJt,mJt,fJt,pJt,QJt,$Jt,eYt,tYt,nYt,rYt,iYt,aYt,oYt,sYt,qqt,Jqt,Yqt,Xqt,Zqt,Qqt,$qt,eJt,tJt,YYt,{path:/^\/embed\//,auth:`viewer`,handle:(e,t,n,r)=>{let i=gXt.exec(r.pathname),a=i&&n.embedTarget(i[1],i[2]);a?J9(e,t,n,r,a):ae(t,404,`Not found`)}},{path:e=>e===`/`||e===`/index.html`?[e]:null,auth:`navigation`,handle:(e,t,n,r)=>J9(e,t,n,r,null)},{path:e=>fXt.exec(e)??pXt.exec(e)??mXt.exec(e)??hXt.exec(e),auth:`viewer`,handle:(e,t,n,r)=>J9(e,t,n,r,null)},{path:e=>[e],auth:`viewer`,handle:(e,t,n,{pathname:r})=>{let i=rt(n.viewerDir,r.slice(1));i?se(t,i,{"Content-Security-Policy":q9(n.boardOrigins())}):ae(t,404,`Not found`)}}],vXt=[iXt,aXt],yXt=`Forbidden: agent calls need ?key=`,bXt={public:{gated:!1,denied:`Forbidden`,allow:()=>!0},key:{gated:!1,denied:yXt,allow:(e,t,n)=>t.isAuthorized(e,n)},viewer:{gated:!0,denied:`Forbidden`,allow:()=>!0},navigation:{gated:!0,denied:`Forbidden`,allow:(e,t)=>!t.loopback||H8e(e.headers[`sec-fetch-site`])},agent:{gated:!0,denied:yXt,allow:(e,t,n)=>t.agentOk(e,n)},"same-origin":{gated:!0,denied:`Forbidden`,allow:(e,t)=>t.sameOrigin(e)},cloud:{gated:!0,denied:`Forbidden`,allow:(e,t,n)=>e.method===`GET`||t.keyOk(n)||t.sameOrigin(e)}},xXt={"direct-relay":(e,t,n)=>{let r=t.options.cloud!==void 0&&e.headers.origin===t.options.cloud.origin;return t.keyOk(n)&&(r||t.sameOrigin(e))},socket:(e,t,n)=>t.isAuthorized(e,n)&&t.sameOrigin(e)};function SXt(e,t,n){return typeof e==`string`?e===t?[t]:null:e instanceof RegExp?e.exec(t):e(t,n)}function CXt({auth:e,methods:t},n,r,i){let a=bXt[e];if(a.gated){if(r.loopback&&!AV(r.policy,n.headers.origin))return`Forbidden origin`;if(!r.isAuthorized(n,i))return`Forbidden: open the full artifact link including ?key=`}return t&&!t.includes(n.method??``)?a.denied:a.allow(n,r,i)?null:a.denied}function wXt(e,t,n,r){if(n.setHeader(`X-Robots-Tag`,`noindex, nofollow`),!kV(r.policy,t.headers.host)){ae(n,403,`Forbidden host`);return}let i=new URL(t.url??`/`,`http://artifacts.local`),a=i.searchParams.get(`key`),o=(e,o)=>{for(let s of e){let e=SXt(s.path,o,r);if(!e)continue;let c=CXt(s,t,r,a);if(c!==null)return ae(n,403,c),!0;let l=s.handle(t,n,r,{key:a,match:e,pathname:o,url:i});return l instanceof Promise&&l.catch(e=>{n.headersSent||ae(n,500,`Artifacts error: ${e.message}`)}),!0}return!1};if(o(e.filter(e=>e.raw),i.pathname))return;r.touch();let s;try{s=decodeURIComponent(i.pathname)}catch{ae(n,400,`Bad request`);return}o(e.filter(e=>!e.raw),s)||ae(n,404,`Not found`)}function TXt(e,t,n,r){if(!kV(r.policy,t.headers.host)){ZV(n,403,`Forbidden`);return}let i=new URL(t.url??`/`,`http://artifacts.local`),a=t.headers[`sec-websocket-key`],o=i.searchParams.get(`key`);if(typeof a!=`string`)ZV(n,400,`Bad Request`);else{for(let s of e){let e=SXt(s.path,i.pathname,r);if(e){if(!xXt[s.auth](t,r,o)){ZV(n,403,`Forbidden`);return}s.handle(t,n,r,{key:o,match:e,pathname:i.pathname,url:i,clientKey:a});return}}ZV(n,400,`Bad Request`)}}async function EXt(e){let t=_Kt(e),{root:n,stateDir:r,mount:i,loopback:a,token:o,cloud:s,autoPublisher:c,clients:l}=t,u=(e,n)=>wXt(_Xt,e,n,t),d=_.default.createServer((e,t)=>{try{u(e,t)}catch(e){t.headersSent||ae(t,500,`Artifacts error: ${e.message}`)}}),p=(e,n)=>TXt(vXt,e,n,t);if(d.on(`upgrade`,p),i)t.port=i.port;else{let n=Number(ne(t.portFile));try{t.port=await re(d,e.host,Number.isInteger(n)&&n>0?n:0)}catch{t.port=await re(d,e.host,0)}f.default.writeFileSync(t.portFile,`${t.port}\n`,{mode:384})}let h=t.port;t.cookieName=`ryugi_artifacts_${h}`;let g=kKt(t),v=_.default.createServer(g);if(i)t.boardPort=i.boardPort;else if(a){let n=m.default.join(r,`.last-board-port`),i=Number(ne(n));try{t.boardPort=await re(v,e.host,Number.isInteger(i)&&i>0&&i!==h?i:0)}catch{t.boardPort=await re(v,e.host,0)}f.default.writeFileSync(n,`${t.boardPort}\n`,{mode:384})}let y=t.boardPort;t.policy=OV({host:e.host,urlHost:e.urlHost,ports:y?[h,y]:[h],cloudOrigin:e.cloud?.origin});let b=`http://${ie(e.urlHost)}:${h}`,x=a?`${b}/`:`${b}/?key=${o}`,S=(e,t)=>`${b}${qV(n,e,t)}${a?``:`?key=${o}`}`,C=t.signatureBaseline(),w=[],T=HV(n).artifacts;for(let e of T){let r=`${e.type}/${e.id}`,i=GV(e.dir,e.type);C&&C.get(r)!==i&&w.push({type:e.type,id:e.id}),t.signatures.set(r,i);try{qV(n,e.type,e.id)}catch{}e.type===`slides`&&t.refreshState(e,e.dir)}let E=new Set(T.map(e=>`${e.type}/${e.id}`));for(let e of C?.keys()??[]){let t=WV(e);t&&!E.has(e)&&w.push(t)}t.saveSignatures(),vt(m.default.join(r,`server-info`),{type:`server-started`,url:x,port:h,boardPort:y,root:n}),t.relay=i?{emit:(e,n)=>t.relayListeners.forEach(t=>t(e,n)),close:()=>{}}:e.relay&&e.cloud?Z5e({...e.relay,token:()=>xt(e.cloud.credentialsFile,e.cloud.origin)?.token??null,served:t.servedArtifacts,local:()=>({hostId:x7(e.cloud.credentialsFile),port:h,...a?{embed:!0,embedDocument:!0}:{key:o}}),handle:(e,n,r)=>AK(t,e,n,r),onActivity:t.touch,onWatch:e=>sft(t,e)}):null;for(let e of w)QV(t,e,[],{force:!0});let D=t.memory.stateWritten?[]:T.map(({type:e,id:t})=>({type:e,id:t})),O,k=()=>{for(let e of D.splice(0,4))eH(t,e);D.length?O=setImmediate(k):(O=void 0,t.memory.stateWritten=!0)};O=setImmediate(k);let A=0;return t.deckFiles.changed=e=>j5e(t,e),{port:h,boardPort:y,token:o,contentToken:t.contentToken,url:x,root:n,linkFor:S,handleRequest:(e,n)=>{A+=1,t.lastActivity=Date.now(),n.once(`close`,()=>{--A,t.lastActivity=Date.now()});try{u(e,n)}catch(e){n.headersSent||ae(n,500,`Artifacts error: ${e.message}`)}},busy:()=>A>0||l.size>0||t.relayViewers.size>0||t.relayWatched.size>0||t.direct.size()>0||t.documents.openIds().length>0||(c?.active()??!1)||t.recordings.active()||t.voiceRunner.active()||t.sourceRunner.active(),lastActiveAt:()=>t.lastActivity,watch:e=>{let n=e?[e]:[e9,uKt];n.forEach(t.viewed.viewerJoined);let r=!0;return()=>{r&&(r=!1,n.forEach(t.viewed.viewerLeft))}},watching:()=>t.viewed.watching(),handleUpgrade:p,handleBoardRequest:g,handleRelay:(e,n,r)=>AK(t,e,n,r),dropRelayViewer:e=>oft(t,e),flushDocuments:()=>t.documents.flushAll(),served:t.servedArtifacts,onRelayEvent:e=>t.relayListeners.push(e),onReview:e=>t.reviewListeners.push(e),deliverThreads:(e,n,r,i)=>t.deliverThreads(e,n,r,i),relayWatch:e=>sft(t,e),liveClients:()=>l.size,agentSessions:()=>t.agentStatus.sessions(),publishAgentStatus:()=>t.publishAgentStatus(),resolve:(e,t)=>an(t)?JV(n,e,t)?.id??null:null,cloudLinkFor:async(t,n)=>{if(!s||!e.cloud||!xt(e.cloud.credentialsFile,e.cloud.origin))return null;let{url:r}=await s.reserve({type:t,id:n});return r?S5e(r,x7(e.cloud.credentialsFile)):null},onArtifactChange:e=>{t.changeListeners.push(e)},*currentPayloads(e){let r=e?[WV(e)]:HV(n).artifacts.map(({type:e,id:t})=>({type:e,id:t}));for(let e of r){let n=e&&N5e(t,e);e&&n&&(yield{ref:e,payload:n})}},onActivity:e=>t.activityListeners.push(e),close:async()=>{z5e(),O&&clearImmediate(O),clearInterval(t.listeningTimer),await t.recordings.close(),await new Promise(e=>{t.viewed.close(),t.deckDeps.close(),c?.close(),t.relay?.close(),t.direct.close(),t.selections.clearAll();for(let e of l)e.destroy();v.close(),v.closeAllConnections(),d.close(()=>e()),d.closeAllConnections()}),await t.documents.close().catch(()=>void 0),await t.previewProxies.close().catch(()=>void 0),t.whiteboards.close(),t.leaveAgentDirectory(),t.voiceRunner.close(),t.exportRunner.close()}}}const DXt=e=>EXt(e);function OXt(e=process.env,t=p.default.homedir()){let n=e.RYUGI_SERVER_HOME||m.default.join(t,`.ryugi`,`server`);return{home:n,pid:m.default.join(n,`server.pid`),serverId:m.default.join(n,`server-instance-id`),info:m.default.join(n,`server-info`),log:m.default.join(n,`server.log`),version:m.default.join(n,`server-version`),lock:m.default.join(n,`start.lock`),key:m.default.join(n,`key`),projects:m.default.join(n,`projects.json`),settings:m.default.join(n,`settings.json`),stopped:m.default.join(n,`server-stopped`)}}function kXt(e){f.default.mkdirSync(e,{recursive:!0,mode:448}),f.default.chmodSync(e,448)}const AXt=e=>{try{return f.default.realpathSync(m.default.resolve(e))}catch{return m.default.resolve(e)}},jXt=e=>{let t=e;return!!t&&typeof t.dir==`string`&&m.default.isAbsolute(t.dir)&&Number.isFinite(t.registeredAt)&&Number.isFinite(t.lastUsedAt)};function Y9(e){try{let t=JSON.parse(f.default.readFileSync(e,`utf8`));return Array.isArray(t.projects)?t.projects.filter(jXt):[]}catch{return[]}}function X9(e,t){kXt(m.default.dirname(e));let n=`${e}.${process.pid}.tmp`;f.default.writeFileSync(n,`${JSON.stringify({projects:t},null,2)}\n`,{mode:384}),f.default.renameSync(n,e)}function MXt(e,t,n=Date.now()){let r=AXt(t),i=Y9(e),a=i.find(e=>e.dir===r);return a?a.lastUsedAt=n:i.push({dir:r,registeredAt:n,lastUsedAt:n}),X9(e,i),a??i.at(-1)}function NXt(e,t){let n=AXt(t),r=Y9(e),i=r.filter(e=>e.dir!==n);i.length!==r.length&&X9(e,i)}const Z9=e=>m.default.join(e,`.ryugi`,`artifacts`);function PXt(e){let t=Y9(e),n=t.filter(e=>f.default.existsSync(Z9(e.dir)));return n.length!==t.length&&X9(e,n),n}const FXt=(e,t=Date.now())=>t-e.lastUsedAt>6048e5,IXt=e=>{try{let t=f.default.readFileSync(m.default.join(e,`.artifact-id`),`utf8`).trim();return rn(t)?t:null}catch{return null}},LXt=e=>{try{return f.default.statSync(e).mtimeMs}catch{return 0}};function RXt(e,t={}){let n=t.rescanAfterMs??1e3,r=t.now??Date.now,i=[],a=-1/0,o=()=>{i=e().flatMap(e=>HV(Z9(e)).artifacts.map(t=>({project:e,type:t.type,id:t.id,address:IXt(t.dir),mtimeMs:LXt(t.dir)}))),a=r()},s=(t,n)=>{let r=e(),a=i.find(e=>e.type===t&&e.address===n);if(a)return a;let o=i.filter(e=>e.type===t&&e.id===n);return o.sort((e,t)=>r.indexOf(e.project)-r.indexOf(t.project)),o[0]??null};return{find(e,t){if(!an(t))return null;a===-1/0&&o();let i=s(e,t);return!i&&r()-a>=n&&(o(),i=s(e,t)),i?{project:i.project,id:i.id}:null},owners(e,t){let n=this.find(e,t);if(!n)return[];if(i.some(n=>n.type===e&&n.address===t))return[n.project];let r=i.filter(n=>n.type===e&&n.id===t).map(e=>e.project);return[...new Set(r)]},list(e=0){return r()-a>=e&&o(),i},rescan:o}}const zXt=e=>e.replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`),Q9=e=>String(e).padStart(2,`0`);function BXt(e){return`${e.getUTCFullYear()}${Q9(e.getUTCMonth()+1)}${Q9(e.getUTCDate())}-${Q9(e.getUTCHours())}${Q9(e.getUTCMinutes())}`}const VXt=()=>Array.from(crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(4)),e=>`abcdefghijkmnpqrstuvwxyz23456789`[e%32]).join(``);function HXt(e,t){let n=e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean),r=n[0]??``,i=(r.toLowerCase().match(/[a-z0-9]+/g)??[]).slice(0,5),a=[`task`,BXt(t),...i,VXt()].join(`-`),o=`新任务:${[...r].length>40?`${[...r].slice(0,40).join(``)}…`:r}`,s=n.map(e=>` <p>${zXt(e)}</p>`).join(`
|
|
1876
|
+
`);return{slug:a,title:o,xml:`<doc>\n <h1>${zXt(o)}</h1>\n <h2>需求</h2>\n${s}\n</doc>\n`}}function UXt(e){let{daemon:t}=e,n=async e=>{if(!(await t.call(`devices.check`,{deviceId:e}))?.trusted)throw Error(`device not trusted by this machine`)};return{async info(){let n;try{n=await t.call(`status`,{})??{}}catch{return null}let r=e.lastHarness();return{hostId:e.hostId,name:e.name,daemon:!0,remote:n.remote===!0,sessions:n.sessions??0,queued:n.queued??0,projects:e.projects().map(({name:e,dir:t})=>r[t]?{name:e,lastHarness:r[t]}:{name:e})}},async handle(r){let{deviceId:i}=r;switch(r.op){case`sessions.list`:return t.call(`sessions.list`,{deviceId:i});case`sessions.screen`:return t.call(`sessions.screen`,{deviceId:i,sessionId:r.sessionId});case`tasks.create`:{await n(i);let a=e.projects().find(e=>e.name===r.project);if(!a)throw Error(`no project ${r.project} on this machine`);let o=await e.createTask(a.dir,r.text),s=await t.call(`tasks.start`,{deviceId:i,projectDir:a.dir,harness:r.harness,artifact:o.artifact});return e.rememberHarness(a.dir,r.harness),s?.taskId&&e.recordSession(a.dir,o.artifact,{origin:`daemon`,taskId:s.taskId,sessionId:s.sessionId??null,harness:r.harness}),{...o,state:s?.state===`queued`?`queued`:`starting`}}}}}}function WXt(e,t,n){let r=/* @__PURE__ */ new Map;for(let i of e){let e=t(i);r.has(e)||r.set(e,{name:e,dir:n(i)})}return[...r.values()]}async function GXt(e,t,{waitMs:n=8e3,stepMs:r=400}={}){let i=()=>e.cloudLinkFor(`document`,t).catch(()=>null),a=await i();if(a)return a;await e.handleRelay(`document/${t}`,{op:`publish`},`daemon`).catch(()=>null);for(let a=0;a<n;a+=r){await new Promise(e=>setTimeout(e,r));let n=await i();if(n)return n;let a=await e.handleRelay(`document/${t}`,{op:`publication`},`daemon`).catch(()=>null);if(!a||a.phase===`failed`||a.phase===`not-ready`)return null}return null}async function KXt(e,t,n,r,i){let{slug:a,xml:o}=HXt(t,n);return qV(e,`document`,a),f.default.writeFileSync(m.default.join(e,`document`,a,`doc.xml`),o,{flag:`wx`}),{artifact:`document/${a}`,url:await GXt(r,a,i)}}const qXt=/* @__PURE__ */ new Set([`queued`,`running`,`starting`]);function JXt(e){let{daemon:t,sessions:n}=e,r=/* @__PURE__ */ new Set,i=async({dir:r,key:i,deviceId:a})=>{let o=n.get(r,i);if(e.liveSession(r,i,o)||o&&(await t.call(`sessions.list`,{deviceId:a}))?.sessions?.some(e=>e.taskId===o.taskId&&qXt.has(e.state??``)))return`live`;if(o?.harness===`claude`&&o.sessionId){let e=await t.call(`sessions.resume`,{deviceId:a,taskId:o.taskId,sessionId:o.sessionId,projectDir:r,artifact:i,harness:`claude`});return n.set(r,i,{...o,taskId:e?.taskId??o.taskId,sessionId:e?.sessionId??o.sessionId}),`resumed`}let s=o?.harness??e.lastHarness(r)??`claude`,c=await t.call(`tasks.start`,{deviceId:a,projectDir:r,harness:s,artifact:i,reason:`comment`});return c?.taskId&&n.set(r,i,{origin:`daemon`,taskId:c.taskId,sessionId:c.sessionId??null,harness:s}),`started`};return{async onHumanInput(e){let t=`${e.dir}\0${e.key}`;if(r.has(t))return`busy`;r.add(t);try{return await i(e)}catch{return`refused`}finally{r.delete(t)}}}}function YXt(e){let t=()=>{try{return JSON.parse(f.default.readFileSync(e(),`utf8`))}catch{return{}}};return{get(e,n){return t()[e]?.[n]??null},set(n,r,i){let a=t();vt(e(),{...a,[n]:{...a[n],[r]:i}})}}}const XXt=(e,t)=>t.map(t=>e.boards[t]?.page).find(e=>!!e);function ZXt(e){let t=e.canvas;if(!t||e.warnings.length>0)return!1;let n=Object.entries(t.boards);if(n.length===0)return!1;if(t.building===!0)return!0;let r=new Set(e.pending),i=n=>{let i=t.boards[n];return i?(e.versions[i.file]??0)>0&&!r.has(n):!1};if(n.every(([e])=>i(e)))return!0;let a=t.focus?.target,o=a&&t.boards[a]?a:void 0,s=a?t.groups?.[a]?a:o?Object.entries(t.groups??{}).find(([,e])=>e.boards.includes(o))?.[0]:void 0:void 0,c=s?t.groups?.[s]:void 0;if(c&&c.boards.length>0)return c.boards.every(i);let l=(o?t.boards[o].page:void 0)??(c?XXt(t,c.boards):void 0)??t.activePage??t.pages[0]?.id;if(!l)return!1;let u=Object.entries(t.groups??{}).filter(([,e])=>e.boards.some(e=>t.boards[e]?.page===l));for(let[,e]of u)if(e.boards.length>0&&e.boards.every(i))return!0;if(u.length>0)return!1;let d=n.filter(([,e])=>e.page===l);return d.length===1?i(d[0][0]):d.filter(([e])=>i(e)).length>=2}const QXt=`host`,$Xt=/^(document|artboard)\//,eZt=/^(?:document|artboard|whiteboard|slides|storyboard|report|preview)\/[a-z0-9][a-z0-9-]*$/,tZt=/^\/api\/hub\/(?:stop|restart|upgrade|log)$/,nZt=RegExp(`(?:^|/)(${Ee.join(`|`)})/([\\w-]+)`),rZt=/^\/preview\/([a-z0-9][a-z0-9-]{0,63})\/?$/,iZt=/^\/c\/([^/]+)\//,aZt=/^\/relay\/a\/([\w-]{1,64})$/,oZt=/^(?:artboard|document|html)\/[a-z0-9][a-z0-9-]*$/,$9=e=>{try{return f.default.realpathSync(m.default.resolve(e))}catch{return null}};function sZt(e){return new Promise((t,n)=>{let r=0,i=[];e.on(`data`,t=>{r+=t.length,r>65536?(n(/* @__PURE__ */ Error(`body too large`)),e.destroy()):i.push(t)}),e.on(`end`,()=>{try{t(JSON.parse(Buffer.concat(i).toString(`utf8`)||`{}`))}catch{n(/* @__PURE__ */ Error(`body is not JSON`))}}),e.on(`error`,n)})}const cZt=e=>{if(typeof e!=`object`||!e)return!1;let{op:t,comment:n}=e;return t===`comment`&&(n?.op===`create`||n?.op===`reply`)};function lZt(){if(process.platform===`darwin`)try{let e=(0,u.execFileSync)(`scutil`,[`--get`,`ComputerName`],{encoding:`utf8`,timeout:1e3}).trim();if(e)return e}catch{return p.default.hostname().replace(/\.local$/,``)}return p.default.hostname().replace(/\.local$/,``)}async function uZt(e){let t=DV(e.host),n=e.paths.projects;PXt(n);let r=()=>Y9(n).sort((e,t)=>t.lastUsedAt-e.lastUsedAt),i=e=>r().some(t=>t.dir===e),a=RXt(()=>r().map(e=>e.dir),{rescanAfterMs:0}),o=_.default.createServer(),s=_.default.createServer(),c=await ue(o,e.host,e.ports),l=t?await ue(s,e.host,e.boardPorts):0,d=OV({host:e.host,urlHost:e.urlHost,ports:l?[c,l]:[c],cloudOrigin:e.cloud?.origin}),p=/* @__PURE__ */ new Map,h=/* @__PURE__ */ new Map,g=/* @__PURE__ */ new Map,v=e.documentHostFile?R8e({hostFile:e.documentHostFile}):null,y=v?({fillRefs:e,...t})=>v.open(t):void 0,b=/* @__PURE__ */ new Map,x=e=>{let t=b.get(e);return t||(t=pKt(Z9(e)),S.register(t.agentStatus),b.set(e,t)),t},S=AGt(),C=/* @__PURE__ */ new Map,w=!1,T=t=>{if(w)return Promise.reject(/* @__PURE__ */ Error(`Artifacts server is stopping`));let n=p.get(t);return n||(n=DXt({root:Z9(t),viewerDir:e.viewerDir,runtimeDir:e.runtimeDir,host:e.host,urlHost:e.urlHost,configFile:m.default.join(t,`.ryugi`,`config.json`),cloud:e.cloud,fetch:e.fetch,debounceMs:e.debounceMs,agentDirectory:S,agentDaemon:gGt({dir:t,bridge:_e,panel:e=>he(t,e,!0),task:e=>me(t,e),screen:e=>de.call(`sessions.screen`,{local:!0,sessionId:e})}),memory:x(t),openDocument:y,mount:{port:c,boardPort:l,token:e.token,version:e.version}}).then(e=>{C.set(t,e);let n=g.get(t);if(n?.size&&e.relayWatch(n),e.onRelayEvent((e,n)=>{Te?.emit(`${t}
|
|
1877
|
+
${e}`,n),u5e(n)&&setImmediate(()=>A.trigger(t,e))}),e.onReview(e=>setImmediate(()=>A.trigger(t,e))),h.set(t,m5e(m.default.join(Z9(t),`.state`),{subscribe:(e,n,r)=>A.subscribe(e,n,t,r),subscribed:(e,n,r)=>O.subscriptions(e,n).some(e=>e.project===t&&e.artifact===r)})),Te?.state().connected)for(let n of F(t).values())$Xt.test(n)&&e.handleRelay(n,{op:`inbox`},QXt).catch(()=>void 0);return e}),n.catch(()=>p.delete(t)),p.set(t,n)),n},O=v5e(e.paths.home),k=null,A=d5e({store:O,send:(e,t)=>k?.send(e,t),watch:(e,t)=>{if(!f.default.existsSync(Z9(e)))return()=>{};let n,r=!1;return T(e).then(e=>{r||(n=e.watch(t))}).catch(()=>void 0),()=>{r=!0,n?.()}},delivered:(e,t,n,r,i)=>C.get(e)?.deliverThreads(t,n,r,i),listening:(e,t)=>f5e(m.default.join(Z9(e),`.state`),t)}),M;if(e.agentSocket){let t=e.agentSocket,n=!1,r=()=>j({socketPath:t,version:e.version,onHello:e=>A.hello(e),onDelivered:(e,t)=>A.ack(e,t.id),onUnsubscribe:e=>A.unsubscribe(e),onClose:e=>A.close(e)}).catch(e=>(n||console.error(JSON.stringify({type:`agent-channel`,event:`error`,message:e.message})),n=!0,null));if(k=await r(),!k){let t=!1;M=setInterval(async()=>{t||k||(t=!0,k=await r(),t=!1,k&&clearInterval(M))},e.agentSocketRetryMs??3e4),M.unref()}}let N=e=>m.default.join(e,`.ryugi`,`config.json`),P=t=>!!e.cloud&&!!xt(e.cloud.credentialsFile,e.cloud.origin)&&FWt({globalFile:MWt(e.cloud.credentialsFile),projectFile:N(t)}),F=e=>{let t=C.get(e);if(t)return t.served();let n=/* @__PURE__ */ new Map;for(let[t,r]of Object.entries(y7(N(e)).config.artifacts))r.cloud&&n.set(r.cloud.id,t);return n},ee=()=>{let e=/* @__PURE__ */ new Map;for(let t of r())for(let[n,r]of F(t.dir))e.has(n)||e.set(n,`${t.dir}
|
|
1878
1878
|
${r}`);return e},I=e=>{let t=e.lastIndexOf(`
|
|
1879
|
-
`);return{project:e.slice(0,t),key:e.slice(t+1)}},ne=/* @__PURE__ */ new Map,re=e=>{let t=ne.get(e);if(t)return t;try{let n=(0,u.execFileSync)(`git`,[`-C`,e,`rev-parse`,`--path-format=absolute`,`--git-common-dir`],{encoding:`utf8`,timeout:2e3,stdio:[`ignore`,`pipe`,`ignore`]}).trim();t=m.default.basename(n)===`.git`?m.default.dirname(n):e}catch{t=e}return ne.set(e,t),t},oe=/* @__PURE__ */ new Map,se=e=>{let t=oe.get(e);return t||oe.set(e,t=bGt(e)),t},ce=m.default.join(m.default.dirname(n),`daemon-harness.json`),le=()=>{try{let e=JSON.parse(f.default.readFileSync(ce,`utf8`));return Object.fromEntries(Object.entries(e).filter(e=>Vt(e[1])))}catch{return{}}},de=Et(e.daemonSocket??Tt()),fe=
|
|
1880
|
-
`).filter(Boolean);return r<e&&a.shift(),a.filter(e=>!t||e.includes(t)).slice(-500)}finally{f.default.closeSync(n)}}catch{return[]}},nt=(t,n,r)=>{let i=r.pathname.slice(9);if(i===`log`){t.method===`GET`?L(n,200,{lines:tt(r.searchParams.get(`project`))}):ae(n,405,`Method not allowed`);return}let a=e.control;t.method===`POST`?a?i===`stop`?(L(n,202,{stopping:!0}),setImmediate(a.stop)):i===`upgrade`&&!e.latest?.()?L(n,409,{error:`up to date`}):a.relaunch(i===`upgrade`)?L(n,202,{restarting:!0}):L(n,409,{error:`cannot relaunch`}):ae(n,409,`Not available`):ae(n,405,`Method not allowed`)},rt=async(e,t,n)=>{if(n.pathname===`/api/agent/subscribe`){if(!Le(e,n))return ae(t,403,`Forbidden: agent calls need ?key=`),!0;if(e.method!==`POST`)return ae(t,405,`Method not allowed`),!0;let{host:r,session:i,project:a,artifact:o}=await
|
|
1879
|
+
`);return{project:e.slice(0,t),key:e.slice(t+1)}},ne=/* @__PURE__ */ new Map,re=e=>{let t=ne.get(e);if(t)return t;try{let n=(0,u.execFileSync)(`git`,[`-C`,e,`rev-parse`,`--path-format=absolute`,`--git-common-dir`],{encoding:`utf8`,timeout:2e3,stdio:[`ignore`,`pipe`,`ignore`]}).trim();t=m.default.basename(n)===`.git`?m.default.dirname(n):e}catch{t=e}return ne.set(e,t),t},oe=/* @__PURE__ */ new Map,se=e=>{let t=oe.get(e);return t||oe.set(e,t=bGt(e)),t},ce=m.default.join(m.default.dirname(n),`daemon-harness.json`),le=()=>{try{let e=JSON.parse(f.default.readFileSync(ce,`utf8`));return Object.fromEntries(Object.entries(e).filter(e=>Vt(e[1])))}catch{return{}}},de=Et(e.daemonSocket??Tt()),fe=YXt(()=>m.default.join(m.default.dirname(n),`daemon-sessions.json`)),pe=JXt({daemon:de,sessions:fe,lastHarness:e=>le()[e],liveSession:(e,t,n)=>n?.sessionId&&S.lookup(n.harness,n.sessionId)?!0:!!C.get(e)?.agentSessions().some(e=>e.artifacts.includes(t))}),me=async(e,t)=>{let n=fe.get(e,t);if(!n)return null;let r=(await de.call(`sessions.local`,{}).catch(()=>null))?.sessions?.find(e=>e.taskId===n.taskId)?.state??`ended`;return{taskId:n.taskId,harness:n.harness,state:r}},he=async(e,t,n)=>{let r=(await T(e)).agentSessions().filter(e=>e.artifacts.includes(t)).map(e=>({agent:e.agent,state:e.state,since:e.since,turn:S.lookup(e.host,e.id)?.turn??null})),i=await me(e,t);return{agents:r,daemon:i?{...i,attention:_e.attention(i.taskId)}:null,trusted:n}},ge=async(e,t,n)=>{if(!n)throw Error(`the terminal opens only on a trusted device`);let r=await me(e,t);if(!r)throw Error(`no daemon session works on this artifact`);return de.call(`sessions.screen`,{deviceId:n,sessionId:r.taskId})},_e=dGt({call:de.call,hookFor:fGt(S,e=>C.get(e)?.agentSessions()??[]),now:Date.now,onChange:e=>C.get(e)?.publishAgentStatus()}),ve=setInterval(()=>void _e.tick().catch(()=>{}),e.relay?.pollMs??5e3);ve.unref?.();let ye=async e=>e!==void 0&&((await de.call(`devices.check`,{deviceId:e}).catch(()=>null))?.trusted??!1),be=async(e,t,n,r)=>{if(!r)throw Error(`replies come only from a trusted device`);let i=await me(e,t);if(!i)throw Error(`no daemon session works on this artifact`);return await _e.input(i.taskId,pGt(n),{device:r}),{sent:!0}},xe=e.relay&&e.cloud?UXt({daemon:de,recordSession:(e,t,n)=>fe.set(e,t,n),hostId:x7(e.cloud.credentialsFile),name:lZt(),projects:()=>WXt(r().map(e=>e.dir),se,re),lastHarness:le,rememberHarness:(e,t)=>vt(ce,{...le(),[e]:t}),createTask:async(e,t)=>(i(e)||await Ye(e),KXt(Z9(e),t,/* @__PURE__ */ new Date,await T(e)))}):null,Se=null,Ce=async()=>{xe&&!w&&(Se=await xe.info(),Te?.refresh())},we=xe?setInterval(()=>void Ce(),e.relay?.pollMs??5e3):void 0;we?.unref?.();let Te=e.relay&&e.cloud?Z5e({...e.relay,token:()=>xt(e.cloud.credentialsFile,e.cloud.origin)?.token??null,served:ee,refusedFile:m.default.join(e.paths.home,`relay-refused.json`),local:()=>({hostId:x7(e.cloud.credentialsFile),port:c,...t?{embed:!0,embedDocument:!0}:{key:e.token}}),handle:async(e,t,n,r)=>{let{project:i,key:a}=I(e),o=t?.op;if(o===`agent-sessions`)return he(i,a,await ye(r));if(o===`agent-screen`)return ge(i,a,r);if(o===`agent-input`)return be(i,a,t,r);if(n===QXt&&!C.has(i))return{applied:0};let s=await(await T(i)).handleRelay(a,t,n);return r&&cZt(t)&&pe.onHumanInput({dir:i,key:a,deviceId:r}),s},onActivity:()=>{},...xe?{machine:{info:()=>Se,handle:e=>xe.handle(e)}}:{},onWatch:e=>{let t=/* @__PURE__ */ new Map;for(let n of e){let{project:e,key:r}=I(n);t.set(e,(t.get(e)??/* @__PURE__ */ new Set).add(r))}g=t;for(let[e,n]of C)n.relayWatch(t.get(e)??/* @__PURE__ */ new Set);for(let[e,n]of t)C.has(e)||T(e).then(t=>t.relayWatch(g.get(e)??n)).catch(()=>void 0)}}):null,Ee=`http://${ie(e.urlHost)}:${c}`,De=t?`${Ee}/`:`${Ee}/?key=${e.token}`,Oe=e=>m.default.join(Z9(e),`.state`,`server-info`),ke=e=>{try{f.default.mkdirSync(m.default.dirname(Oe(e)),{recursive:!0,mode:448}),vt(Oe(e),{type:`server-started`,url:De,port:c,boardPort:l,root:Z9(e)})}catch{}},Ae=Date.now(),je=Ae,Me=()=>{let e=/* @__PURE__ */ new Map;for(let t of a.list(1e4))e.set(t.project,(e.get(t.project)??0)+1);return r().map(t=>({dir:t.dir,name:m.default.basename(t.dir),lastUsedAt:t.lastUsedAt,dormant:FXt(t),artifacts:e.get(t.dir)??0}))},Ne=()=>{let e=[],t=[];for(let n of r()){let r=Z9(n.dir),i=HV(r);for(let e of i.warnings)t.push(`${m.default.basename(n.dir)}: ${e}`);for(let t of i.artifacts)try{let i=TV(t.dir);if(t.type===`html`)try{let e=f.default.statSync(m.default.join(r,`.state`,`html`,t.id,`dom-skeleton.json`));i=Math.max(i,Math.floor(e.mtimeMs))}catch{}e.push({project:n.dir,type:t.type,id:t.id,url:qV(r,t.type,t.id),title:n9(mKt(t.dir,t)),updatedAt:i})}catch{}}return e.sort((e,t)=>t.updatedAt-e.updatedAt),{projects:Me(),artifacts:e,warnings:t}},Pe=()=>{let t=Te?.state(),n=[...C.values()].reduce((e,t)=>e+t.liveClients(),0);return{pid:process.pid,version:e.version,latest:e.latest?.()??null,startedAt:Ae,lastActivity:je,clients:n,port:c,boardPort:l,url:De,relay:{connected:t?.connected??!1,announced:t?.announced??0,...t?.refused&&e.cloud?{refused:t.refused,upgradeUrl:`${e.cloud.origin}/billing`}:{}},live:{local:n,relay:t?.watched??0},projects:Me()}},Fe=n=>{let r=n.searchParams.get(`key`);return t||r!==null&&te(r,e.token)},Ie=(t,n)=>Fe(n)||(t.headers.cookie??``).split(`;`).some(t=>te(t.trim(),`ryugi_artifacts_${c}=${e.token}`)),Le=(e,t)=>e.headers.origin===void 0&&Fe(t),Re=(e,t)=>{let n=e.headers[`x-ryugi-project`];if(typeof n!=`string`||!Le(e,t))return null;let r=Ke(n),a=r===null?null:$9(r);return a&&i(a)?a:null},ze=e=>e.startsWith(`/api/preview-dev/`)||rZt.test(e),Be=(e,t=e.pathname)=>{if(!ze(t))return null;let n=e.searchParams.get(`project`);if(!n)return null;let r=$9(n);return r&&i(r)?r:null},Ve=(e,t)=>{try{let{artifacts:n}=y7(m.default.join(e,`.ryugi`,`config.json`)).config;return Object.values(n).some(e=>e.cloud?.id===t)}catch{return!1}},He=e=>{for(let[t,n]of C)if(n.served().has(e))return t;return r().find(t=>Ve(t.dir,e))?.dir??null},Ue=e=>{let t=iZt.exec(e);if(t){for(let[e,n]of b)if(n.contentToken===t[1])return e;return null}let n=aZt.exec(e);if(n)return He(n[1]);let i=rZt.exec(e);if(i){let e=i[1];return r().find(t=>f.default.existsSync(m.default.join(t.dir,`.ryugi`,`preview`,e,`preview.json`)))?.dir??null}let o=nZt.exec(e);if(o){let e=a.owners(o[1],o[2]);return e.length>1?{artifact:`${o[1]}/${o[2]}`,projects:e}:e[0]??He(o[2])}return null},We=e=>{let t=e===null?null:Ue(e);return typeof t==`string`?t:null},Ge=e=>{try{let t=new URL(e.headers.referer??``);return t.host===e.headers.host?Be(t)??We(Ke(t.pathname)):null}catch{return null}},Ke=e=>{try{return decodeURIComponent(e)}catch{return null}},qe=async(e,t,n)=>{let i=t.searchParams.get(`at`),a=Re(e,t)??Be(t,n)??We(i&&Ke(i));if(a)return T(a);let o=Ue(n);if(o!==null&&typeof o!=`string`)return o;let s=o??Ge(e)??r()[0]?.dir??null;return s?T(s):null},Je=(n,r)=>{let i=e.open,{artifact:a,openCmd:o}=r;if(!i||!t)return;let s=!1,c=n.watch(a),l=(e,t)=>{if(s||a&&`${e.type}/${e.id}`!==a||(`canvas`in t?!ZXt(t):t.warnings.length>0))return;s=!0,c();let r=n.linkFor(e.type,e.id);n.cloudLinkFor(e.type,e.id).catch(()=>null).then(e=>i(e??r,r,o)).catch(()=>void 0)};n.onArtifactChange(l);for(let{ref:e,payload:t}of n.currentPayloads(a))if(l(e,t),s)break},Ye=async(e,t)=>{let r=$9(e);if(!r)throw Error(`Project directory not found: ${e}`);f.default.mkdirSync(Z9(r),{recursive:!0});let i=MXt(n,r);a.rescan(),ke(r);let o=await T(r);return t&&Je(o,t),Te?.refresh(),i},Xe=async e=>{let t=p.get(e);p.delete(e),C.delete(e),await(await t?.catch(()=>null))?.close()},Ze=e.idle?.unmountAfterMs??6e5,Qe=async e=>{let t=[...C].filter(([t,n])=>!g.get(t)?.size&&!A.pinned(t)&&!n.busy()&&e-n.lastActiveAt()>=Ze);await Promise.all(t.map(([e])=>Xe(e))),O.sweep((e,t)=>A.connected(e,t));for(let[t,n]of b)C.has(t)||n.agentStatus.expire(e)},$e=setInterval(()=>void Qe(Date.now()),e.idle?.sweepMs??6e4);$e.unref();let et=async e=>{let t=$9(e)??m.default.resolve(e);NXt(n,t),a.rescan(),f.default.rmSync(Oe(t),{force:!0});let r=p.get(t);p.delete(t),C.delete(t),await(await r)?.close()},tt=t=>{try{let n=f.default.openSync(e.paths.log,`r`);try{let e=f.default.fstatSync(n).size,r=Math.min(e,262144),i=Buffer.alloc(r);f.default.readSync(n,i,0,r,e-r);let a=i.toString(`utf8`).split(`
|
|
1880
|
+
`).filter(Boolean);return r<e&&a.shift(),a.filter(e=>!t||e.includes(t)).slice(-500)}finally{f.default.closeSync(n)}}catch{return[]}},nt=(t,n,r)=>{let i=r.pathname.slice(9);if(i===`log`){t.method===`GET`?L(n,200,{lines:tt(r.searchParams.get(`project`))}):ae(n,405,`Method not allowed`);return}let a=e.control;t.method===`POST`?a?i===`stop`?(L(n,202,{stopping:!0}),setImmediate(a.stop)):i===`upgrade`&&!e.latest?.()?L(n,409,{error:`up to date`}):a.relaunch(i===`upgrade`)?L(n,202,{restarting:!0}):L(n,409,{error:`cannot relaunch`}):ae(n,409,`Not available`):ae(n,405,`Method not allowed`)},rt=async(e,t,n)=>{if(n.pathname===`/api/agent/subscribe`){if(!Le(e,n))return ae(t,403,`Forbidden: agent calls need ?key=`),!0;if(e.method!==`POST`)return ae(t,405,`Method not allowed`),!0;let{host:r,session:i,project:a,artifact:o}=await sZt(e);if(typeof r!=`string`||!E.test(r)||typeof i!=`string`||!D.test(i)||typeof a!=`string`||typeof o!=`string`||!eZt.test(o))return L(t,400,{error:`needs {host, session, project, artifact}`}),!0;let s=$9(a);return s?(A.subscribe(r,i,s,o),L(t,200,{subscribed:!0}),!0):(L(t,404,{error:`no such project directory`}),!0)}if(n.pathname!==`/api/hub/projects`)return!1;let i=e.method===`DELETE`&&e.headers.origin!==void 0&&Ie(e,n)&&AV(d,e.headers.origin);if(!Le(e,n)&&!i)return ae(t,403,`Forbidden: agent calls need ?key=`),!0;if(e.method===`GET`)return L(t,200,{projects:r()}),!0;let a=await sZt(e);if(typeof a.dir!=`string`)return L(t,400,{error:`needs {dir}`}),!0;if(e.method===`POST`){let e=typeof a.openCmd==`string`&&a.openCmd?a.openCmd:void 0,n=a.open===!0?{artifact:null,openCmd:e}:typeof a.open==`string`&&oZt.test(a.open)?{artifact:a.open,openCmd:e}:void 0,r=await Ye(a.dir,n);L(t,200,{project:r.dir,root:Z9(r.dir)})}else e.method===`DELETE`?(await et(a.dir),L(t,200,{removed:!0})):ae(t,405,`Method not allowed`);return!0};o.on(`request`,(e,t)=>{(async()=>{if(!kV(d,e.headers.host)){ae(t,403,`Forbidden host`);return}let n=new URL(e.url??`/`,`http://artifacts.local`);if(n.pathname===`/api/status`){Ie(e,n)?L(t,200,Pe()):ae(t,403,`Forbidden: agent calls need ?key=`);return}if(tZt.test(n.pathname)){!Ie(e,n)||!AV(d,e.headers.origin)?ae(t,403,`Forbidden`):nt(e,t,n);return}if(n.pathname===`/api/hub/artifacts`){!Ie(e,n)||!AV(d,e.headers.origin)?ae(t,403,`Forbidden`):L(t,200,Ne());return}if(je=Date.now(),await rt(e,t,n))return;let r=Ke(n.pathname);if(r===null){ae(t,400,`Bad request`);return}let i=await qe(e,n,r);i?`projects`in i?L(t,409,{error:`ambiguous_slug`,...i}):i.handleRequest(e,t):ae(t,404,`Not found`)})().catch(e=>{t.headersSent||ae(t,w?503:500,`Artifacts error: ${e.message}`)})}),o.on(`upgrade`,(e,t,n)=>{(async()=>{let r=new URL(e.url??`/`,`http://artifacts.local`),i=Ke(r.pathname)??`/`,a=await qe(e,r,i);!a||`projects`in a?t.destroy():a.handleUpgrade(e,t,n)})().catch(()=>t.destroy())}),s.on(`request`,(e,t)=>{(async()=>{let n=fn(e,Ke(new URL(e.url??`/`,`http://board.local`).pathname)??`/`),i=n.kind===`board`?a.find(`artboard`,n.address)?.project??null:r()[0]?.dir??null,o=i?await T(i):null;o?o.handleBoardRequest(e,t):ae(t,404,`Not found`)})().catch(e=>{t.headersSent||ae(t,500,e.message)})});let it=[];for(let e of r())ke(e.dir),P(e.dir)&&XHt(m.default.join(Z9(e.dir),`.state`,`auto-publish.json`))&&it.push(T(e.dir).catch(()=>void 0));return await Promise.all(it),{port:c,boardPort:l,token:e.token,url:De,status:Pe,projects:r,mounted:()=>[...C.values()],unmount:Xe,sweepIdle:Qe,documentProcess:()=>v?.pid()??null,flushDocuments:async e=>{let t=Promise.all([...C.values()].map(e=>e.flushDocuments().catch(()=>void 0)));await Promise.race([t,new Promise(t=>setTimeout(t,e).unref())])},mountOf:T,register:Ye,remove:et,linkFor:async(e,t,n)=>(await T(e)).linkFor(t,n),close:async()=>{w=!0,clearInterval(M),A.closeAll(),await k?.close();for(let e of h.values())e();z5e(),clearInterval($e),clearInterval(we),clearInterval(ve);let e=[o,s].map(e=>new Promise(t=>e.close(t)));Te?.close();let t=[...p.values()];p.clear(),C.clear(),await Promise.all(t.map(async e=>(await e.catch(()=>null))?.close())),await v?.close();for(let e of r())f.default.rmSync(Oe(e.dir),{force:!0});for(let e of[o,s])e.closeAllConnections();await Promise.all(e)}}}const dZt=/^node "(.+)"$/;function fZt(e,t){let n=dZt.exec(e.RYUGI_ARTIFACTS_LAUNCHER??``)?.[1];if(n)return[process.execPath,n];let r=m.default.join(t,`cli.cjs`);return f.default.existsSync(r)?[process.execPath,r]:null}function pZt(e,t,n,r=Date.now()){let i=m.default.join(e.XDG_CACHE_HOME||m.default.join(t,`.cache`),`ryugi`,`artifacts`);f.default.mkdirSync(i,{recursive:!0});let a=m.default.join(i,`latest.json`),o=`${a}.${process.pid}`;f.default.writeFileSync(o,JSON.stringify({version:n,checkedAt:r})),f.default.renameSync(o,a)}function mZt(e,t,n=process.env){let[r,...i]=t;r&&(0,u.spawn)(process.execPath,[...w(`relaunch`),`-e`,`
|
|
1881
1881
|
const [pid, file, ...args] = process.argv.slice(1);
|
|
1882
1882
|
const gone = () => { try { process.kill(Number(pid), 0); return false; } catch { return true; } };
|
|
1883
1883
|
const tick = () => {
|
|
@@ -1885,4 +1885,4 @@ const tick = () => {
|
|
|
1885
1885
|
require('child_process').spawn(file, args, { detached: true, stdio: 'ignore', windowsHide: true }).unref();
|
|
1886
1886
|
};
|
|
1887
1887
|
tick();
|
|
1888
|
-
`,String(e),r,...i],{detached:!0,stdio:`ignore`,windowsHide:!0,env:n}).unref()}const
|
|
1888
|
+
`,String(e),r,...i],{detached:!0,stdio:`ignore`,windowsHide:!0,env:n}).unref()}const hZt=/* @__PURE__ */ new Set([`stop`,`stale_pid`]),gZt=/* @__PURE__ */ new Set([`SIGTERM`,`SIGINT`,`SIGHUP`]);function _Zt(e){try{return JSON.parse(f.default.readFileSync(e,`utf8`)).reason}catch{return null}}function vZt(e,t){let n=_Zt(e);gZt.has(t)&&typeof n==`string`&&hZt.has(n)||vt(e,{reason:t,timestamp:Date.now()})}function yZt(e){let t=setInterval(()=>{let n;try{n=f.default.readFileSync(e.file,`utf8`).trim()}catch{return}n&&n!==e.serverId&&(clearInterval(t),e.onSuperseded(n))},e.intervalMs??1e3);return t.unref(),()=>clearInterval(t)}function bZt(e,t){let n=e.split(/[.-]/).slice(0,3).map(Number),r=t.split(/[.-]/).slice(0,3).map(Number);for(let e=0;e<3;e++){let t=(n[e]||0)-(r[e]||0);if(t)return t>0}return!1}function xZt(e){try{let t=JSON.parse(f.default.readFileSync(e,`utf8`));return typeof t.version==`string`&&Number.isFinite(t.checkedAt)?t:null}catch{return null}}function SZt(e){let t=e.now??Date.now,n=e.fetch??fetch,r=xZt(e.cacheFile),i=/^\d+\.\d+\.\d+/.test(e.current);return{latest(){return!i||!r?null:bZt(r.version,e.current)?r.version:null},async refresh(){if(i&&!(r&&t()-r.checkedAt<864e5))try{let{version:i}=await(await n(`https://registry.npmjs.org/ryugi-artifacts/latest`,{signal:AbortSignal.timeout(5e3)})).json();if(typeof i!=`string`)return;r={version:i,checkedAt:t()},f.default.writeFileSync(e.cacheFile,`${JSON.stringify(r)}\n`,{mode:384})}catch{}}}}async function CZt(e){if(!nee[process.platform]?.includes(process.arch))return;let t=await zt({arch:process.arch,fetch,home:p.default.homedir(),configHome:process.env.XDG_CONFIG_HOME||void 0,run:(e,t)=>{let n=(0,u.spawnSync)(e,t,{encoding:`utf8`});return{status:n.status,stderr:n.stderr||(n.error?.message??``),stdout:n.stdout??``}},platform:process.platform,serverHome:e,uid:process.getuid?.()??0,version:b},Et(Tt())).catch(e=>({status:`failed`,error:e.message}));t.status!==`not-installed`&&t.status!==`other-hub`&&console.info(JSON.stringify({type:`daemon-update`,...t,at:(/* @__PURE__ */ new Date()).toISOString()}))}function wZt(e){try{let t=f.default.readFileSync(e,`utf8`).trim();if(/^[a-f0-9]{48}$/.test(t))return t}catch{}let t=d.default.randomBytes(24).toString(`hex`);return f.default.writeFileSync(e,`${t}\n`,{mode:384}),t}async function TZt(){let e=fe(process.env,process.argv.slice(2));process.platform!==`linux`&&C(`hub`,...e.serverId?[`--artifacts-server-id=${e.serverId}`]:[]);let t=OXt();kXt(t.home);let n=SZt({cacheFile:m.default.join(t.home,`latest.json`),current:b}),r=await uZt({host:e.host,urlHost:e.urlHost,viewerDir:m.default.join(__dirname,`viewer`),documentHostFile:m.default.join(__dirname,`document-host.cjs`),agentSocket:O(),runtimeDir:m.default.join(__dirname,`runtime`),ports:e.ports,boardPorts:e.boardPorts,paths:t,token:wZt(t.key),version:b,latest:()=>n.latest(),cloud:{origin:e.cloudOrigin,credentialsFile:eee(process.env,process.platform,p.default.homedir())},relay:{url:`${e.cloudOrigin.replace(/^http/,`ws`)}/api/relay/host`,version:b},control:{stop:()=>void a(`stop`),relaunch:e=>s(e)},open:async(t,n,r)=>{let i=r??e.openCmd;i?(0,u.exec)(`${i} ${JSON.stringify(t)}`,()=>{}):await ge(t,[n]).catch(e=>{console.error(JSON.stringify({type:`browser-open-error`,error:e.message}))})}});process.env.RYUGI_NO_UPDATE_CHECK!==`1`&&(n.refresh(),setInterval(()=>void n.refresh(),36e5).unref());let i=!1;async function a(e,n=!0){i||(i=!0,console.info(JSON.stringify({type:`server-stopped`,reason:e,at:(/* @__PURE__ */ new Date()).toISOString()})),f.default.rmSync(t.info,{force:!0}),n&&vZt(t.stopped,e),await r.close(),process.exit(0))}function o(){try{return f.default.readFileSync(t.version,`utf8`).trim()||b}catch{return b}}function s(t){let i=fZt(process.env,__dirname),s=r.projects()[0]?.dir,c=n.latest(),l=!!process.env.RYUGI_ARTIFACTS_LAUNCHER;if(!i||!s||t&&(!c||!l))return!1;try{t&&c&&pZt(process.env,p.default.homedir(),c)}catch{return!1}let u={...process.env};return delete u.CODEX_CI,l||(u.RYUGI_ARTIFACTS_VERSION=o()),mZt(process.pid,[...i,`start`,`--json`,`--no-open`,`--project-dir`,s,`--host`,e.host,`--url-host`,e.urlHost,`--port`,String(r.port)],u),setImmediate(()=>void a(t?`upgrade`:`restart`,!1)),!0}e.serverId&&yZt({file:t.serverId,serverId:e.serverId,onSuperseded:e=>{console.info(JSON.stringify({type:`server-superseded`,by:e,at:(/* @__PURE__ */ new Date()).toISOString()})),r.flushDocuments(2e3).finally(()=>process.exit(0))}}),process.on(`SIGTERM`,()=>void a(`SIGTERM`)),process.on(`SIGINT`,()=>void a(`SIGINT`)),process.on(`SIGHUP`,()=>void a(`SIGHUP`)),f.default.rmSync(t.stopped,{force:!0});let c={type:`server-started`,url:r.url,port:r.port,boardPort:r.boardPort,version:b,pid:process.pid,host:e.host,urlHost:e.urlHost,cloudOrigin:e.cloudOrigin};vt(t.info,c),console.info(JSON.stringify({...c,at:(/* @__PURE__ */ new Date()).toISOString()})),CZt(t.home)}TZt().catch(e=>{console.info(JSON.stringify({type:`server-error`,error:e.message})),process.exit(1)});
|