- commit
- bc941fb54fee4b4f63ebb70f516ec94a3c6767e4
- parent
- c5417e62ec7026193fa0bf19ece477830b3f31dc
- author
- Dami <dami.etoile@gmail.com>
@@ -60,11 +60,11 @@ catalog engine.
6060 | --- | --- |6161 | Worker JavaScript | Bytefield, Nomnoml, Vega family (Vega and Vega-Lite → Vega), WaveDrom |6262 | Worker Python | BlockDiag family (BlockDiag, SeqDiag, ActDiag, NwDiag, PacketDiag, RackDiag); WireViz → DOT → GraphViz |63-| Worker WebAssembly | GraphViz family (GraphViz and ERD → DOT → GraphViz); Pikchr |63+| Worker WebAssembly | GraphViz family (GraphViz and ERD → DOT → GraphViz); Pikchr; Svgbob |6464 | Sandboxed browser unit | Mermaid, BPMN, Excalidraw |65-| Compatibility unit | 11 dependency units covering the remaining 12 engines |65+| Compatibility unit | 10 dependency units covering the remaining 11 engines |6666 67-The current split is 18/30 engines off Fly and 12/30 still dependent on it.67+The current split is 19/30 engines off Fly and 11/30 still dependent on it.6868 Compatibility units are extraction seams, not final runtimes or fallbacks for6969 an engine after cutover. DBML7070 currently proxies because its published package mixes module formats. GraphViz@@ -4,7 +4,7 @@ import { resolve } from 'node:path'
44 const units = [55 'plantuml-family', 'd2',66 'dbml', 'diagramsnet', 'ditaa', 'goat',7- 'structurizr', 'svgbob', 'symbolator', 'tikz', 'umlet',7+ 'structurizr', 'symbolator', 'tikz', 'umlet',88 ]99 const wrangler = resolve(import.meta.dirname, '../node_modules/.bin/wrangler')1010 const pending = [...units]@@ -8,6 +8,7 @@ const configs = [
88 'wrangler.units/wavedrom.jsonc',99 'wrangler.units/graphviz-family.jsonc',1010 'wrangler.units/pikchr.jsonc',11+ 'wrangler.units/svgbob.jsonc',1112 'wrangler.compatibility/plantuml-family.jsonc',1213 'wrangler.compatibility/d2.jsonc',1314 'wrangler.compatibility/dbml.jsonc',@@ -15,7 +16,6 @@ const configs = [
1516 'wrangler.compatibility/ditaa.jsonc',1617 'wrangler.compatibility/goat.jsonc',1718 'wrangler.compatibility/structurizr.jsonc',18- 'wrangler.compatibility/svgbob.jsonc',1919 'wrangler.compatibility/symbolator.jsonc',2020 'wrangler.compatibility/tikz.jsonc',2121 'wrangler.compatibility/umlet.jsonc',@@ -51,6 +51,7 @@ const sharedUnits = {
5151 const pythonEngines = new Set(['blockdiag', 'seqdiag', 'actdiag', 'nwdiag', 'packetdiag', 'rackdiag'])5252 const graphvizEngines = new Set(['graphviz', 'erd'])5353 const pikchrEngines = new Set(['pikchr'])54+const svgbobEngines = new Set(['svgbob'])5455 const wirevizEngines = new Set(['wireviz'])5556 5657 async function smoke([engine, filename]) {@@ -111,6 +112,14 @@ async function smoke([engine, filename]) {
111112 throw new Error(`${engine}: unexpected Pikchr Worker build ${response.headers.get('X-Renderer-Build')}`)112113 }113114 }115+ if (svgbobEngines.has(engine)) {116+ if (response.headers.get('X-Diagram-Renderer') !== 'edge-wasm') {117+ throw new Error(`${engine}: expected edge-wasm renderer, received ${response.headers.get('X-Diagram-Renderer')}`)118+ }119+ if (!response.headers.get('X-Renderer-Build')?.startsWith('svgbob-0.7.6-edge-wasm-')) {120+ throw new Error(`${engine}: unexpected Svgbob Worker build ${response.headers.get('X-Renderer-Build')}`)121+ }122+ }114123 if (wirevizEngines.has(engine)) {115124 if (response.headers.get('X-Diagram-Renderer') !== 'edge-python') {116125 throw new Error(`${engine}: expected edge-python renderer, received ${response.headers.get('X-Diagram-Renderer')}`)@@ -3,6 +3,7 @@ import { bytefieldAdapter } from './edge/bytefield'
33 import { erdAdapter } from './edge/erd'44 import { graphvizAdapter } from './edge/graphviz'55 import { nomnomlAdapter } from './edge/nomnoml'6+import { svgbobAdapter } from './edge/svgbob'67 import { vegaAdapter } from './edge/vega'78 import { vegaliteAdapter } from './edge/vegalite'89 import { wavedromAdapter } from './edge/wavedrom'@@ -13,6 +14,7 @@ const adapters: Record<EdgeEngineId, RendererAdapter> = {
1314 erd: erdAdapter,1415 graphviz: graphvizAdapter,1516 nomnoml: nomnomlAdapter,17+ svgbob: svgbobAdapter,1618 vega: vegaAdapter,1719 vegalite: vegaliteAdapter,1820 wavedrom: wavedromAdapter,@@ -0,0 +1,90 @@
1+import { RenderError } from '../../errors'2+import type { RendererAdapter } from '../../types'3+import { edgeResult } from './types'4+import { render as renderSvgbob } from '../../vendor/svgbob_wasm.js'5+6+const VERSION = 'svgbob@0.7.6/edge-wasm-1'7+const MAX_SOURCE_BYTES = 256 * 10248+const MAX_OPTION_BYTES = 2569+const DEFAULTS = {10+ background: 'white',11+ fillColor: 'black',12+ fontFamily: 'Iosevka Fixed, monospace',13+ fontSize: 14,14+ scale: 1,15+ strokeWidth: 2,16+} as const17+18+const STRING_OPTIONS = new Set(['background', 'fill-color', 'font-family'])19+const OPTION_STRIP = /[-"$/@*&=;:!\\]/g20+21+function optionString(options: Record<string, string>, name: string, fallback: string): string {22+ const value = options[name]23+ if (value === undefined) return fallback24+ const sanitized = value.replace(OPTION_STRIP, '')25+ if (sanitized.length === 0) throw new RenderError(400, 'invalid_options', `Svgbob option '${name}' cannot be empty.`)26+ if (new TextEncoder().encode(sanitized).byteLength > MAX_OPTION_BYTES) throw new RenderError(413, 'options_too_large', `Svgbob option '${name}' exceeds the 256 byte limit.`)27+ return sanitized28+}29+30+function optionNumber(options: Record<string, string>, name: string, fallback: number, integer = false): number {31+ const value = options[name]32+ if (value === undefined) return fallback33+ const parsed = Number(value)34+ if (!Number.isFinite(parsed) || (integer && !Number.isInteger(parsed)) || parsed <= 0 || parsed > 1000) {35+ throw new RenderError(400, 'invalid_options', `Svgbob option '${name}' must be a finite positive number.`)36+ }37+ return parsed38+}39+40+function optionsFor(options: Record<string, string>): {41+ background: string42+ fillColor: string43+ fontFamily: string44+ fontSize: number45+ scale: number46+ strokeWidth: number47+} {48+ for (const name of Object.keys(options)) {49+ if (!STRING_OPTIONS.has(name) && !['font-size', 'scale', 'stroke-width'].includes(name)) {50+ throw new RenderError(400, 'unsupported_options', `Unsupported Svgbob option: ${name}.`)51+ }52+ }53+ return {54+ background: optionString(options, 'background', DEFAULTS.background),55+ fillColor: optionString(options, 'fill-color', DEFAULTS.fillColor),56+ fontFamily: optionString(options, 'font-family', DEFAULTS.fontFamily),57+ fontSize: optionNumber(options, 'font-size', DEFAULTS.fontSize, true),58+ scale: optionNumber(options, 'scale', DEFAULTS.scale),59+ strokeWidth: optionNumber(options, 'stroke-width', DEFAULTS.strokeWidth),60+ }61+}62+63+export const svgbobAdapter: RendererAdapter = {64+ id: 'svgbob', runtime: 'edge-wasm', version: VERSION,65+ async render(request, signal) {66+ if (signal.aborted) throw signal.reason67+ if (new TextEncoder().encode(request.source).byteLength > MAX_SOURCE_BYTES) {68+ throw new RenderError(413, 'source_too_large', 'Svgbob source exceeds the 256 KiB limit.')69+ }70+ const settings = optionsFor(request.options)71+ if (signal.aborted) throw signal.reason72+ try {73+ const body = renderSvgbob(74+ request.source,75+ settings.background,76+ settings.fillColor,77+ settings.fontFamily,78+ settings.fontSize,79+ settings.scale,80+ settings.strokeWidth,81+ )82+ if (!body.includes('<svg')) throw new RenderError(422, 'render_failed', 'Svgbob returned no SVG.')83+ return edgeResult('svgbob', VERSION, body, 'edge-wasm')84+ } catch (error) {85+ if (error instanceof RenderError) throw error86+ const message = error instanceof Error ? error.message : String(error)87+ throw new RenderError(422, 'render_failed', message.slice(0, 500) || 'Svgbob could not render this source.')88+ }89+ },90+}@@ -1,7 +1,7 @@
11 import { RenderError } from '../../errors'22 import type { RenderResult } from '../../types'33 4-export type EdgeEngineId = 'bytefield' | 'erd' | 'graphviz' | 'nomnoml' | 'vega' | 'vegalite' | 'wavedrom'4+export type EdgeEngineId = 'bytefield' | 'erd' | 'graphviz' | 'nomnoml' | 'svgbob' | 'vega' | 'vegalite' | 'wavedrom'55 66 export function edgeResult(id: EdgeEngineId, version: string, body: string, runtime: 'edge-js' | 'edge-wasm' = 'edge-js'): RenderResult {77 if (typeof body !== 'string' || body.trim() === '') {@@ -59,6 +59,7 @@ const activeRuntime: Partial<Record<EngineId, EngineRuntime>> = {
5959 rackdiag: 'edge-python',6060 graphviz: 'edge-wasm',6161 pikchr: 'edge-wasm',62+ svgbob: 'edge-wasm',6263 erd: 'edge-wasm',6364 wireviz: 'edge-python',6465 }@@ -80,6 +81,7 @@ const versions: Partial<Record<EngineId, string>> = {
8081 rackdiag: 'rackdiag@3.0.0/python-worker-1',8182 graphviz: 'graphviz@15.1.1/edge-wasm-1',8283 pikchr: 'pikchr@85e65b9686/edge-wasm-1',84+ svgbob: 'svgbob@0.7.6/edge-wasm-1',8385 erd: 'erd@0.2.1.0+graphviz@15.1.1/edge-wasm-1',8486 wireviz: 'wireviz@0.3.2/python-translator-1',8587 }@@ -98,6 +100,11 @@ const losses: Partial<Record<EngineId, readonly string[]>> = {
98100 'Pikchr image/resource loading and renderer options are not exposed in the edge unit.',99101 'The edge build is compiled from the pinned Kroki Pikchr source revision 85e65b968651b342c46e6334f4772b45d6cbb4317c5cbaa95d207779a50c6709.',100102 ],103+ svgbob: [104+ 'Only SVG is supported.',105+ 'Kroki stroke-color is not exposed in the edge unit; the pure upstream library does not load external images or resources.',106+ 'The edge build is compiled from upstream svgbob 0.7.6 at pinned commit 04a9d85c4b1879051f205e9e434e058864c3d36f.',107+ ],101108 bytefield: ['Only SVG is in the v2 rendering contract.'],102109 dbml: ['The upstream package mixes ESM files into a CommonJS package and remains on the origin until it can be safely repackaged.'],103110 excalidraw: [@@ -0,0 +1,11 @@
1+import { svgbobAdapter } from '../adapters/edge/svgbob'2+import { createRendererUnit } from '../unit'3+4+export default createRendererUnit({5+ id: 'svgbob', kind: 'render', adapter: svgbobAdapter,6+ knownLosses: [7+ 'Only SVG is supported.',8+ 'Kroki stroke-color is not exposed in the edge unit; the pure upstream library does not load external images or resources.',9+ 'Compiled from upstream svgbob 0.7.6 at commit 04a9d85c4b1879051f205e9e434e058864c3d36f.',10+ ],11+})@@ -0,0 +1,202 @@
1+2+ Apache License3+ Version 2.0, January 20044+ http://www.apache.org/licenses/5+6+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION7+8+ 1. Definitions.9+10+ "License" shall mean the terms and conditions for use, reproduction,11+ and distribution as defined by Sections 1 through 9 of this document.12+13+ "Licensor" shall mean the copyright owner or entity authorized by14+ the copyright owner that is granting the License.15+16+ "Legal Entity" shall mean the union of the acting entity and all17+ other entities that control, are controlled by, or are under common18+ control with that entity. For the purposes of this definition,19+ "control" means (i) the power, direct or indirect, to cause the20+ direction or management of such entity, whether by contract or21+ otherwise, or (ii) ownership of fifty percent (50%) or more of the22+ outstanding shares, or (iii) beneficial ownership of such entity.23+24+ "You" (or "Your") shall mean an individual or Legal Entity25+ exercising permissions granted by this License.26+27+ "Source" form shall mean the preferred form for making modifications,28+ including but not limited to software source code, documentation29+ source, and configuration files.30+31+ "Object" form shall mean any form resulting from mechanical32+ transformation or translation of a Source form, including but33+ not limited to compiled object code, generated documentation,34+ and conversions to other media types.35+36+ "Work" shall mean the work of authorship, whether in Source or37+ Object form, made available under the License, as indicated by a38+ copyright notice that is included in or attached to the work39+ (an example is provided in the Appendix below).40+41+ "Derivative Works" shall mean any work, whether in Source or Object42+ form, that is based on (or derived from) the Work and for which the43+ editorial revisions, annotations, elaborations, or other modifications44+ represent, as a whole, an original work of authorship. For the purposes45+ of this License, Derivative Works shall not include works that remain46+ separable from, or merely link (or bind by name) to the interfaces of,47+ the Work and Derivative Works thereof.48+49+ "Contribution" shall mean any work of authorship, including50+ the original version of the Work and any modifications or additions51+ to that Work or Derivative Works thereof, that is intentionally52+ submitted to Licensor for inclusion in the Work by the copyright owner53+ or by an individual or Legal Entity authorized to submit on behalf of54+ the copyright owner. For the purposes of this definition, "submitted"55+ means any form of electronic, verbal, or written communication sent56+ to the Licensor or its representatives, including but not limited to57+ communication on electronic mailing lists, source code control systems,58+ and issue tracking systems that are managed by, or on behalf of, the59+ Licensor for the purpose of discussing and improving the Work, but60+ excluding communication that is conspicuously marked or otherwise61+ designated in writing by the copyright owner as "Not a Contribution."62+63+ "Contributor" shall mean Licensor and any individual or Legal Entity64+ on behalf of whom a Contribution has been received by Licensor and65+ subsequently incorporated within the Work.66+67+ 2. Grant of Copyright License. Subject to the terms and conditions of68+ this License, each Contributor hereby grants to You a perpetual,69+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable70+ copyright license to reproduce, prepare Derivative Works of,71+ publicly display, publicly perform, sublicense, and distribute the72+ Work and such Derivative Works in Source or Object form.73+74+ 3. Grant of Patent License. Subject to the terms and conditions of75+ this License, each Contributor hereby grants to You a perpetual,76+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable77+ (except as stated in this section) patent license to make, have made,78+ use, offer to sell, sell, import, and otherwise transfer the Work,79+ where such license applies only to those patent claims licensable80+ by such Contributor that are necessarily infringed by their81+ Contribution(s) alone or by combination of their Contribution(s)82+ with the Work to which such Contribution(s) was submitted. If You83+ institute patent litigation against any entity (including a84+ cross-claim or counterclaim in a lawsuit) alleging that the Work85+ or a Contribution incorporated within the Work constitutes direct86+ or contributory patent infringement, then any patent licenses87+ granted to You under this License for that Work shall terminate88+ as of the date such litigation is filed.89+90+ 4. Redistribution. You may reproduce and distribute copies of the91+ Work or Derivative Works thereof in any medium, with or without92+ modifications, and in Source or Object form, provided that You93+ meet the following conditions:94+95+ (a) You must give any other recipients of the Work or96+ Derivative Works a copy of this License; and97+98+ (b) You must cause any modified files to carry prominent notices99+ stating that You changed the files; and100+101+ (c) You must retain, in the Source form of any Derivative Works102+ that You distribute, all copyright, patent, trademark, and103+ attribution notices from the Source form of the Work,104+ excluding those notices that do not pertain to any part of105+ the Derivative Works; and106+107+ (d) If the Work includes a "NOTICE" text file as part of its108+ distribution, then any Derivative Works that You distribute must109+ include a readable copy of the attribution notices contained110+ within such NOTICE file, excluding those notices that do not111+ pertain to any part of the Derivative Works, in at least one112+ of the following places: within a NOTICE text file distributed113+ as part of the Derivative Works; within the Source form or114+ documentation, if provided along with the Derivative Works; or,115+ within a display generated by the Derivative Works, if and116+ wherever such third-party notices normally appear. The contents117+ of the NOTICE file are for informational purposes only and118+ do not modify the License. You may add Your own attribution119+ notices within Derivative Works that You distribute, alongside120+ or as an addendum to the NOTICE text from the Work, provided121+ that such additional attribution notices cannot be construed122+ as modifying the License.123+124+ You may add Your own copyright statement to Your modifications and125+ may provide additional or different license terms and conditions126+ for use, reproduction, or distribution of Your modifications, or127+ for any such Derivative Works as a whole, provided Your use,128+ reproduction, and distribution of the Work otherwise complies with129+ the conditions stated in this License.130+131+ 5. Submission of Contributions. Unless You explicitly state otherwise,132+ any Contribution intentionally submitted for inclusion in the Work133+ by You to the Licensor shall be under the terms and conditions of134+ this License, without any additional terms or conditions.135+ Notwithstanding the above, nothing herein shall supersede or modify136+ the terms of any separate license agreement you may have executed137+ with Licensor regarding such Contributions.138+139+ 6. Trademarks. This License does not grant permission to use the trade140+ names, trademarks, service marks, or product names of the Licensor,141+ except as required for reasonable and customary use in describing the142+ origin of the Work and reproducing the content of the NOTICE file.143+144+ 7. Disclaimer of Warranty. Unless required by applicable law or145+ agreed to in writing, Licensor provides the Work (and each146+ Contributor provides its Contributions) on an "AS IS" BASIS,147+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or148+ implied, including, without limitation, any warranties or conditions149+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A150+ PARTICULAR PURPOSE. You are solely responsible for determining the151+ appropriateness of using or redistributing the Work and assume any152+ risks associated with Your exercise of permissions under this License.153+154+ 8. Limitation of Liability. In no event and under no legal theory,155+ whether in tort (including negligence), contract, or otherwise,156+ unless required by applicable law (such as deliberate and grossly157+ negligent acts) or agreed to in writing, shall any Contributor be158+ liable to You for damages, including any direct, indirect, special,159+ incidental, or consequential damages of any character arising as a160+ result of this License or out of the use or inability to use the161+ Work (including but not limited to damages for loss of goodwill,162+ work stoppage, computer failure or malfunction, or any and all163+ other commercial damages or losses), even if such Contributor164+ has been advised of the possibility of such damages.165+166+ 9. Accepting Warranty or Additional Liability. While redistributing167+ the Work or Derivative Works thereof, You may choose to offer,168+ and charge a fee for, acceptance of support, warranty, indemnity,169+ or other liability obligations and/or rights consistent with this170+ License. However, in accepting such obligations, You may act only171+ on Your own behalf and on Your sole responsibility, not on behalf172+ of any other Contributor, and only if You agree to indemnify,173+ defend, and hold each Contributor harmless for any liability174+ incurred by, or claims asserted against, such Contributor by reason175+ of your accepting any such warranty or additional liability.176+177+ END OF TERMS AND CONDITIONS178+179+ APPENDIX: How to apply the Apache License to your work.180+181+ To apply the Apache License to your work, attach the following182+ boilerplate notice, with the fields enclosed by brackets "[]"183+ replaced with your own identifying information. (Don't include184+ the brackets!) The text should be enclosed in the appropriate185+ comment syntax for the file format. We also recommend that a186+ file or class name and description of purpose be included on the187+ same "printed page" as the copyright notice for easier188+ identification within third-party archives.189+190+ Copyright 2016 Jovansonlee B. Cesar191+192+ Licensed under the Apache License, Version 2.0 (the "License");193+ you may not use this file except in compliance with the License.194+ You may obtain a copy of the License at195+196+ http://www.apache.org/licenses/LICENSE-2.0197+198+ Unless required by applicable law or agreed to in writing, software199+ distributed under the License is distributed on an "AS IS" BASIS,200+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.201+ See the License for the specific language governing permissions and202+ limitations under the License.@@ -0,0 +1,35 @@
1+# Svgbob edge-Wasm provenance2+3+The vendored module is built from the upstream `svgbob` 0.7.6 release at4+commit `04a9d85c4b1879051f205e9e434e058864c3d36f` (the tag points at this5+commit). The wrapper source and locked dependency graph are in6+`diagramzip-render/svgbob-wasm/`.7+8+Builds use Docker image `rust:1.89-bookworm` pinned as9+`rust@sha256:948f9b08a66e7fe01b03a98ef1c7568292e07ec2e4fe90d88c07bb14563c84ff`:10+11+```sh12+docker run --rm -v "$PWD/diagramzip-render/svgbob-wasm:/build" -w /build \13+ rust@sha256:948f9b08a66e7fe01b03a98ef1c7568292e07ec2e4fe90d88c07bb14563c84ff \14+ bash -c 'rustup target add wasm32-unknown-unknown && \15+ cargo build --release --target wasm32-unknown-unknown && \16+ cargo install wasm-bindgen-cli --version 0.2.127 --locked && \17+ wasm-bindgen target/wasm32-unknown-unknown/release/svgbob_wasm.wasm \18+ --target bundler --out-dir /build/pkg'19+```20+21+The checked-in `svgbob_wasm_bg.js` and `svgbob_wasm_bg.wasm` files are copied22+from `/build/pkg`. `svgbob_wasm.js` replaces wasm-bindgen's bundler namespace23+import with a default `CompiledWasm` import and one explicit24+`WebAssembly.Instance`, then calls `__wbindgen_start` once. The wrapper calls25+only Svgbob's pure `Settings` and `to_svg_with_settings` APIs: it performs no26+filesystem, network, DOM, or runtime asset loading.27+28+Artifact SHA-256 digests:29+30+- `svgbob_wasm_bg.wasm`: `9fe54bd259a6c1d83dea684d48d6b90a07661d3d58ec57861fae363c9f4b45b2`31+- `svgbob_wasm_bg.js`: `cab37989e62bd5f00d9ac3dc87d83d4e29c1a47efac1d21909d021efca2b9443`32+- Worker import bridge `svgbob_wasm.js`: `d728d07acb9f24e867504dc6dd4e40a64603a67f6a075aaa1456502c87187c03`33+34+Svgbob 0.7.6 is licensed under Apache-2.0. The upstream license and notices35+are available at https://github.com/ivanceras/svgbob/tree/04a9d85c4b1879051f205e9e434e058864c3d36f.@@ -0,0 +1,11 @@
1+/* @ts-self-types="./svgbob_wasm.d.ts" */2+import wasmModule from "./svgbob_wasm_bg.wasm";3+import * as wasmImports from "./svgbob_wasm_bg.js";4+import { __wbg_set_wasm } from "./svgbob_wasm_bg.js";5+6+const wasm = new WebAssembly.Instance(wasmModule, { "./svgbob_wasm_bg.js": wasmImports }).exports;7+__wbg_set_wasm(wasm);8+wasm.__wbindgen_start();9+export {10+ render11+} from "./svgbob_wasm_bg.js";@@ -0,0 +1,135 @@
1+/**2+ * Render one ASCII source using svgbob's pure library API.3+ *4+ * The JavaScript adapter validates bounds and option syntax. Keeping this5+ * wrapper free of DOM, filesystem, and network APIs makes it usable in a6+ * Cloudflare Worker compiled-Wasm binding.7+ * @param {string} source8+ * @param {string} background9+ * @param {string} fill_color10+ * @param {string} font_family11+ * @param {number} font_size12+ * @param {number} scale13+ * @param {number} stroke_width14+ * @returns {string}15+ */16+export function render(source, background, fill_color, font_family, font_size, scale, stroke_width) {17+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);18+ const len0 = WASM_VECTOR_LEN;19+ const ptr1 = passStringToWasm0(background, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);20+ const len1 = WASM_VECTOR_LEN;21+ const ptr2 = passStringToWasm0(fill_color, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);22+ const len2 = WASM_VECTOR_LEN;23+ const ptr3 = passStringToWasm0(font_family, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);24+ const len3 = WASM_VECTOR_LEN;25+ const ret = wasm.render(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, font_size, scale, stroke_width);26+ var v5 = getCachedStringFromWasm0(ret[0], ret[1]);27+ if (ret[0] !== 0) { wasm.__wbindgen_free(ret[0], ret[1], 1); }28+ return v5;29+}30+export function __wbg___wbindgen_throw_bb96b2010945f0bc(arg0, arg1) {31+ var v0 = getCachedStringFromWasm0(arg0, arg1);32+ throw new Error(v0);33+}34+export function __wbindgen_init_externref_table() {35+ const table = wasm.__wbindgen_externrefs;36+ const offset = table.grow(4);37+ table.set(0, undefined);38+ table.set(offset + 0, undefined);39+ table.set(offset + 1, null);40+ table.set(offset + 2, true);41+ table.set(offset + 3, false);42+}43+function getCachedStringFromWasm0(ptr, len) {44+ if (ptr === 0) {45+ return getFromExternrefTable0(len);46+ } else {47+ return getStringFromWasm0(ptr, len);48+ }49+}50+51+function getFromExternrefTable0(idx) { return wasm.__wbindgen_externrefs.get(idx); }52+53+function getStringFromWasm0(ptr, len) {54+ return decodeText(ptr >>> 0, len);55+}56+57+let cachedUint8ArrayMemory0 = null;58+function getUint8ArrayMemory0() {59+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {60+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);61+ }62+ return cachedUint8ArrayMemory0;63+}64+65+function passStringToWasm0(arg, malloc, realloc) {66+ if (realloc === undefined) {67+ const buf = cachedTextEncoder.encode(arg);68+ const ptr = malloc(buf.length, 1) >>> 0;69+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);70+ WASM_VECTOR_LEN = buf.length;71+ return ptr;72+ }73+74+ let len = arg.length;75+ let ptr = malloc(len, 1) >>> 0;76+77+ const mem = getUint8ArrayMemory0();78+79+ let offset = 0;80+81+ for (; offset < len; offset++) {82+ const code = arg.charCodeAt(offset);83+ if (code > 0x7F) break;84+ mem[ptr + offset] = code;85+ }86+ if (offset !== len) {87+ if (offset !== 0) {88+ arg = arg.slice(offset);89+ }90+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;91+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);92+ const ret = cachedTextEncoder.encodeInto(arg, view);93+94+ offset += ret.written;95+ ptr = realloc(ptr, len, offset, 1) >>> 0;96+ }97+98+ WASM_VECTOR_LEN = offset;99+ return ptr;100+}101+102+let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });103+cachedTextDecoder.decode();104+const MAX_SAFARI_DECODE_BYTES = 2146435072;105+let numBytesDecoded = 0;106+function decodeText(ptr, len) {107+ numBytesDecoded += len;108+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {109+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });110+ cachedTextDecoder.decode();111+ numBytesDecoded = len;112+ }113+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));114+}115+116+const cachedTextEncoder = new TextEncoder();117+118+if (!('encodeInto' in cachedTextEncoder)) {119+ cachedTextEncoder.encodeInto = function (arg, view) {120+ const buf = cachedTextEncoder.encode(arg);121+ view.set(buf);122+ return {123+ read: arg.length,124+ written: buf.length125+ };126+ };127+}128+129+let WASM_VECTOR_LEN = 0;130+131+132+let wasm;133+export function __wbg_set_wasm(val) {134+ wasm = val;135+}Binary file.
@@ -0,0 +1,9 @@
1+/* tslint:disable */2+/* eslint-disable */3+export const memory: WebAssembly.Memory;4+export const render: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => [number, number];5+export const __wbindgen_externrefs: WebAssembly.Table;6+export const __wbindgen_malloc: (a: number, b: number) => number;7+export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;8+export const __wbindgen_free: (a: number, b: number, c: number) => void;9+export const __wbindgen_start: () => void;@@ -0,0 +1,877 @@
1+# This file is automatically @generated by Cargo.2+# It is not intended for manual editing.3+version = 44+5+[[package]]6+name = "allocator-api2"7+version = "0.2.21"8+source = "registry+https://github.com/rust-lang/crates.io-index"9+checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"10+11+[[package]]12+name = "approx"13+version = "0.5.1"14+source = "registry+https://github.com/rust-lang/crates.io-index"15+checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6"16+dependencies = [17+ "num-traits",18+]19+20+[[package]]21+name = "arrayvec"22+version = "0.7.8"23+source = "registry+https://github.com/rust-lang/crates.io-index"24+checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56"25+26+[[package]]27+name = "autocfg"28+version = "1.5.1"29+source = "registry+https://github.com/rust-lang/crates.io-index"30+checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"31+32+[[package]]33+name = "bitflags"34+version = "1.3.2"35+source = "registry+https://github.com/rust-lang/crates.io-index"36+checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"37+38+[[package]]39+name = "bstr"40+version = "1.13.1"41+source = "registry+https://github.com/rust-lang/crates.io-index"42+checksum = "6bb31b46c14244e20ee9984b11bf5c992b91fb6939fea616e3512c8baecdbe5f"43+dependencies = [44+ "memchr",45+ "regex-automata",46+ "serde_core",47+]48+49+[[package]]50+name = "bumpalo"51+version = "3.20.3"52+source = "registry+https://github.com/rust-lang/crates.io-index"53+checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649"54+55+[[package]]56+name = "bytemuck"57+version = "1.25.2"58+source = "registry+https://github.com/rust-lang/crates.io-index"59+checksum = "95832e849adfb21180ccb6826a99da14e5d266ae5c2e668e1602cf234f153797"60+61+[[package]]62+name = "cfg-if"63+version = "1.0.4"64+source = "registry+https://github.com/rust-lang/crates.io-index"65+checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"66+67+[[package]]68+name = "derive-where"69+version = "1.6.1"70+source = "registry+https://github.com/rust-lang/crates.io-index"71+checksum = "d08b3a0bcc0d079199cd476b2cae8435016ec11d1c0986c6901c5ac223041534"72+dependencies = [73+ "proc-macro2",74+ "quote",75+ "syn 2.0.119",76+]77+78+[[package]]79+name = "doc-comment"80+version = "0.3.4"81+source = "registry+https://github.com/rust-lang/crates.io-index"82+checksum = "780955b8b195a21ab8e4ac6b60dd1dbdcec1dc6c51c0617964b08c81785e12c9"83+84+[[package]]85+name = "downcast-rs"86+version = "1.2.1"87+source = "registry+https://github.com/rust-lang/crates.io-index"88+checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2"89+90+[[package]]91+name = "either"92+version = "1.18.0"93+source = "registry+https://github.com/rust-lang/crates.io-index"94+checksum = "252afb9ae5eaa683babdc6a068b3f5726eb19e05070c731f9b2a23a7c3e8ed34"95+96+[[package]]97+name = "equivalent"98+version = "1.0.2"99+source = "registry+https://github.com/rust-lang/crates.io-index"100+checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"101+102+[[package]]103+name = "foldhash"104+version = "0.2.0"105+source = "registry+https://github.com/rust-lang/crates.io-index"106+checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb"107+108+[[package]]109+name = "futures"110+version = "0.3.30"111+source = "registry+https://github.com/rust-lang/crates.io-index"112+checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0"113+dependencies = [114+ "futures-channel",115+ "futures-core",116+ "futures-executor",117+ "futures-io",118+ "futures-sink",119+ "futures-task",120+ "futures-util",121+]122+123+[[package]]124+name = "futures-channel"125+version = "0.3.34"126+source = "registry+https://github.com/rust-lang/crates.io-index"127+checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4"128+dependencies = [129+ "futures-core",130+ "futures-sink",131+]132+133+[[package]]134+name = "futures-core"135+version = "0.3.34"136+source = "registry+https://github.com/rust-lang/crates.io-index"137+checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e"138+139+[[package]]140+name = "futures-executor"141+version = "0.3.34"142+source = "registry+https://github.com/rust-lang/crates.io-index"143+checksum = "031b47cf1a3c6cc8bc2fc76cd437f521619387907d469316e7c0bc278f1f5432"144+dependencies = [145+ "futures-core",146+ "futures-task",147+ "futures-util",148+]149+150+[[package]]151+name = "futures-io"152+version = "0.3.34"153+source = "registry+https://github.com/rust-lang/crates.io-index"154+checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed"155+156+[[package]]157+name = "futures-macro"158+version = "0.3.34"159+source = "registry+https://github.com/rust-lang/crates.io-index"160+checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44"161+dependencies = [162+ "proc-macro2",163+ "quote",164+ "syn 3.0.3",165+]166+167+[[package]]168+name = "futures-sink"169+version = "0.3.34"170+source = "registry+https://github.com/rust-lang/crates.io-index"171+checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d"172+173+[[package]]174+name = "futures-task"175+version = "0.3.34"176+source = "registry+https://github.com/rust-lang/crates.io-index"177+checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd"178+179+[[package]]180+name = "futures-util"181+version = "0.3.34"182+source = "registry+https://github.com/rust-lang/crates.io-index"183+checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc"184+dependencies = [185+ "futures-channel",186+ "futures-core",187+ "futures-io",188+ "futures-macro",189+ "futures-sink",190+ "futures-task",191+ "memchr",192+ "pin-project-lite",193+ "slab",194+]195+196+[[package]]197+name = "hashbrown"198+version = "0.16.1"199+source = "registry+https://github.com/rust-lang/crates.io-index"200+checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"201+dependencies = [202+ "allocator-api2",203+ "equivalent",204+ "foldhash",205+]206+207+[[package]]208+name = "hashbrown"209+version = "0.17.1"210+source = "registry+https://github.com/rust-lang/crates.io-index"211+checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"212+213+[[package]]214+name = "indexmap"215+version = "2.14.0"216+source = "registry+https://github.com/rust-lang/crates.io-index"217+checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9"218+dependencies = [219+ "equivalent",220+ "hashbrown 0.17.1",221+]222+223+[[package]]224+name = "itertools"225+version = "0.11.0"226+source = "registry+https://github.com/rust-lang/crates.io-index"227+checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57"228+dependencies = [229+ "either",230+]231+232+[[package]]233+name = "js-sys"234+version = "0.3.104"235+source = "registry+https://github.com/rust-lang/crates.io-index"236+checksum = "0e0c1080212aad755ea003d18543e8768dd432c48819efd73a7bf1e39b7a5a3a"237+dependencies = [238+ "cfg-if",239+ "futures-util",240+ "wasm-bindgen",241+]242+243+[[package]]244+name = "libm"245+version = "0.2.16"246+source = "registry+https://github.com/rust-lang/crates.io-index"247+checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981"248+249+[[package]]250+name = "log"251+version = "0.4.33"252+source = "registry+https://github.com/rust-lang/crates.io-index"253+checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad"254+255+[[package]]256+name = "longest-increasing-subsequence"257+version = "0.1.0"258+source = "registry+https://github.com/rust-lang/crates.io-index"259+checksum = "b3bd0dd2cd90571056fdb71f6275fada10131182f84899f4b2a916e565d81d86"260+261+[[package]]262+name = "matrixmultiply"263+version = "0.3.11"264+source = "registry+https://github.com/rust-lang/crates.io-index"265+checksum = "3f607c237553f086e7043417a51df26b2eb899d3caff94e6a67592ff992fedc7"266+dependencies = [267+ "autocfg",268+ "rawpointer",269+]270+271+[[package]]272+name = "memchr"273+version = "2.8.3"274+source = "registry+https://github.com/rust-lang/crates.io-index"275+checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"276+277+[[package]]278+name = "nalgebra"279+version = "0.32.6"280+source = "registry+https://github.com/rust-lang/crates.io-index"281+checksum = "7b5c17de023a86f59ed79891b2e5d5a94c705dbe904a5b5c9c952ea6221b03e4"282+dependencies = [283+ "approx",284+ "matrixmultiply",285+ "nalgebra-macros",286+ "num-complex",287+ "num-rational",288+ "num-traits",289+ "simba",290+ "typenum",291+]292+293+[[package]]294+name = "nalgebra-macros"295+version = "0.2.2"296+source = "registry+https://github.com/rust-lang/crates.io-index"297+checksum = "254a5372af8fc138e36684761d3c0cdb758a4410e938babcff1c860ce14ddbfc"298+dependencies = [299+ "proc-macro2",300+ "quote",301+ "syn 2.0.119",302+]303+304+[[package]]305+name = "num-complex"306+version = "0.4.6"307+source = "registry+https://github.com/rust-lang/crates.io-index"308+checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495"309+dependencies = [310+ "num-traits",311+]312+313+[[package]]314+name = "num-derive"315+version = "0.4.2"316+source = "registry+https://github.com/rust-lang/crates.io-index"317+checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202"318+dependencies = [319+ "proc-macro2",320+ "quote",321+ "syn 2.0.119",322+]323+324+[[package]]325+name = "num-integer"326+version = "0.1.47"327+source = "registry+https://github.com/rust-lang/crates.io-index"328+checksum = "7ce2d95d4b3734dc35aa2f45e1aa22cd416814592a4f9d9205e11affd5b8e10b"329+dependencies = [330+ "num-traits",331+]332+333+[[package]]334+name = "num-rational"335+version = "0.4.2"336+source = "registry+https://github.com/rust-lang/crates.io-index"337+checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824"338+dependencies = [339+ "num-integer",340+ "num-traits",341+]342+343+[[package]]344+name = "num-traits"345+version = "0.2.19"346+source = "registry+https://github.com/rust-lang/crates.io-index"347+checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"348+dependencies = [349+ "autocfg",350+ "libm",351+]352+353+[[package]]354+name = "once_cell"355+version = "1.21.4"356+source = "registry+https://github.com/rust-lang/crates.io-index"357+checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"358+359+[[package]]360+name = "parry2d"361+version = "0.13.8"362+source = "registry+https://github.com/rust-lang/crates.io-index"363+checksum = "9fd94bf962ead112f14223469aac6f76e3c24e2c399e348f638924498b238c56"364+dependencies = [365+ "approx",366+ "arrayvec",367+ "bitflags",368+ "downcast-rs",369+ "either",370+ "nalgebra",371+ "num-derive",372+ "num-traits",373+ "rustc-hash",374+ "simba",375+ "slab",376+ "smallvec",377+ "spade",378+]379+380+[[package]]381+name = "paste"382+version = "1.0.15"383+source = "registry+https://github.com/rust-lang/crates.io-index"384+checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"385+386+[[package]]387+name = "phf"388+version = "0.11.3"389+source = "registry+https://github.com/rust-lang/crates.io-index"390+checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078"391+dependencies = [392+ "phf_macros",393+ "phf_shared",394+]395+396+[[package]]397+name = "phf_generator"398+version = "0.11.3"399+source = "registry+https://github.com/rust-lang/crates.io-index"400+checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d"401+dependencies = [402+ "phf_shared",403+ "rand",404+]405+406+[[package]]407+name = "phf_macros"408+version = "0.11.3"409+source = "registry+https://github.com/rust-lang/crates.io-index"410+checksum = "f84ac04429c13a7ff43785d75ad27569f2951ce0ffd30a3321230db2fc727216"411+dependencies = [412+ "phf_generator",413+ "phf_shared",414+ "proc-macro2",415+ "quote",416+ "syn 2.0.119",417+]418+419+[[package]]420+name = "phf_shared"421+version = "0.11.3"422+source = "registry+https://github.com/rust-lang/crates.io-index"423+checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5"424+dependencies = [425+ "siphasher",426+]427+428+[[package]]429+name = "pin-project-lite"430+version = "0.2.17"431+source = "registry+https://github.com/rust-lang/crates.io-index"432+checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"433+434+[[package]]435+name = "pom"436+version = "3.4.0"437+source = "registry+https://github.com/rust-lang/crates.io-index"438+checksum = "6c972d8f86e943ad532d0b04e8965a749ad1d18bb981a9c7b3ae72fe7fd7744b"439+dependencies = [440+ "bstr",441+]442+443+[[package]]444+name = "proc-macro-error"445+version = "1.0.4"446+source = "registry+https://github.com/rust-lang/crates.io-index"447+checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"448+dependencies = [449+ "proc-macro-error-attr",450+ "proc-macro2",451+ "quote",452+ "version_check",453+]454+455+[[package]]456+name = "proc-macro-error-attr"457+version = "1.0.4"458+source = "registry+https://github.com/rust-lang/crates.io-index"459+checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"460+dependencies = [461+ "proc-macro2",462+ "quote",463+ "version_check",464+]465+466+[[package]]467+name = "proc-macro2"468+version = "1.0.107"469+source = "registry+https://github.com/rust-lang/crates.io-index"470+checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"471+dependencies = [472+ "unicode-ident",473+]474+475+[[package]]476+name = "proc-macro2-diagnostics"477+version = "0.10.1"478+source = "registry+https://github.com/rust-lang/crates.io-index"479+checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8"480+dependencies = [481+ "proc-macro2",482+ "quote",483+ "syn 2.0.119",484+ "version_check",485+ "yansi",486+]487+488+[[package]]489+name = "quote"490+version = "1.0.47"491+source = "registry+https://github.com/rust-lang/crates.io-index"492+checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"493+dependencies = [494+ "proc-macro2",495+]496+497+[[package]]498+name = "rand"499+version = "0.8.7"500+source = "registry+https://github.com/rust-lang/crates.io-index"501+checksum = "22f6172bdec972074665ed81ed53b71da00bfc44b65a753cfde883ec4c702a1a"502+dependencies = [503+ "rand_core",504+]505+506+[[package]]507+name = "rand_core"508+version = "0.6.4"509+source = "registry+https://github.com/rust-lang/crates.io-index"510+checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"511+512+[[package]]513+name = "rawpointer"514+version = "0.2.1"515+source = "registry+https://github.com/rust-lang/crates.io-index"516+checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3"517+518+[[package]]519+name = "regex-automata"520+version = "0.4.18"521+source = "registry+https://github.com/rust-lang/crates.io-index"522+checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2"523+524+[[package]]525+name = "robust"526+version = "1.2.0"527+source = "registry+https://github.com/rust-lang/crates.io-index"528+checksum = "4e27ee8bb91ca0adcf0ecb116293afa12d393f9c2b9b9cd54d33e8078fe19839"529+530+[[package]]531+name = "rstml"532+version = "0.11.2"533+source = "registry+https://github.com/rust-lang/crates.io-index"534+checksum = "fe542870b8f59dd45ad11d382e5339c9a1047cde059be136a7016095bbdefa77"535+dependencies = [536+ "proc-macro2",537+ "proc-macro2-diagnostics",538+ "quote",539+ "syn 2.0.119",540+ "syn_derive",541+ "thiserror",542+]543+544+[[package]]545+name = "rustc-hash"546+version = "1.1.0"547+source = "registry+https://github.com/rust-lang/crates.io-index"548+checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"549+550+[[package]]551+name = "rustversion"552+version = "1.0.23"553+source = "registry+https://github.com/rust-lang/crates.io-index"554+checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"555+556+[[package]]557+name = "safe_arch"558+version = "0.7.4"559+source = "registry+https://github.com/rust-lang/crates.io-index"560+checksum = "96b02de82ddbe1b636e6170c21be622223aea188ef2e139be0a5b219ec215323"561+dependencies = [562+ "bytemuck",563+]564+565+[[package]]566+name = "sauron"567+version = "0.61.9"568+source = "registry+https://github.com/rust-lang/crates.io-index"569+checksum = "1ae1e6099fdd837e98f78b1365637aaf81e737a9441058b0c6a5f7cb1ec69f21"570+dependencies = [571+ "sauron-core",572+ "sauron-macro",573+]574+575+[[package]]576+name = "sauron-core"577+version = "0.61.9"578+source = "registry+https://github.com/rust-lang/crates.io-index"579+checksum = "af4146cee7056509846bad75dc3ee5d49af3eb22725723a2ebada4977a309888"580+dependencies = [581+ "cfg-if",582+ "derive-where",583+ "doc-comment",584+ "futures",585+ "indexmap",586+ "js-sys",587+ "log",588+ "longest-increasing-subsequence",589+ "once_cell",590+ "phf",591+ "serde-wasm-bindgen",592+ "thiserror",593+ "wasm-bindgen",594+ "wasm-bindgen-futures",595+ "web-sys",596+]597+598+[[package]]599+name = "sauron-macro"600+version = "0.61.9"601+source = "registry+https://github.com/rust-lang/crates.io-index"602+checksum = "cd37ab91758f25ea92a216dfed0e2f9103bdf7357d3af148b744cb8941e19d28"603+dependencies = [604+ "once_cell",605+ "phf",606+ "proc-macro2",607+ "quote",608+ "rstml",609+ "sauron-core",610+ "syn 2.0.119",611+]612+613+[[package]]614+name = "serde"615+version = "1.0.229"616+source = "registry+https://github.com/rust-lang/crates.io-index"617+checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"618+dependencies = [619+ "serde_core",620+]621+622+[[package]]623+name = "serde-wasm-bindgen"624+version = "0.5.0"625+source = "registry+https://github.com/rust-lang/crates.io-index"626+checksum = "f3b143e2833c57ab9ad3ea280d21fd34e285a42837aeb0ee301f4f41890fa00e"627+dependencies = [628+ "js-sys",629+ "serde",630+ "wasm-bindgen",631+]632+633+[[package]]634+name = "serde_core"635+version = "1.0.229"636+source = "registry+https://github.com/rust-lang/crates.io-index"637+checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"638+dependencies = [639+ "serde_derive",640+]641+642+[[package]]643+name = "serde_derive"644+version = "1.0.229"645+source = "registry+https://github.com/rust-lang/crates.io-index"646+checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"647+dependencies = [648+ "proc-macro2",649+ "quote",650+ "syn 3.0.3",651+]652+653+[[package]]654+name = "simba"655+version = "0.8.1"656+source = "registry+https://github.com/rust-lang/crates.io-index"657+checksum = "061507c94fc6ab4ba1c9a0305018408e312e17c041eb63bef8aa726fa33aceae"658+dependencies = [659+ "approx",660+ "num-complex",661+ "num-traits",662+ "paste",663+ "wide",664+]665+666+[[package]]667+name = "siphasher"668+version = "1.0.3"669+source = "registry+https://github.com/rust-lang/crates.io-index"670+checksum = "8ee5873ec9cce0195efcb7a4e9507a04cd49aec9c83d0389df45b1ef7ba2e649"671+672+[[package]]673+name = "slab"674+version = "0.4.12"675+source = "registry+https://github.com/rust-lang/crates.io-index"676+checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"677+678+[[package]]679+name = "smallvec"680+version = "1.15.2"681+source = "registry+https://github.com/rust-lang/crates.io-index"682+checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90"683+684+[[package]]685+name = "spade"686+version = "2.15.1"687+source = "registry+https://github.com/rust-lang/crates.io-index"688+checksum = "9699399fd9349b00b184f5635b074f9ec93afffef30c853f8c875b32c0f8c7fa"689+dependencies = [690+ "hashbrown 0.16.1",691+ "num-traits",692+ "robust",693+ "smallvec",694+]695+696+[[package]]697+name = "svgbob"698+version = "0.7.6"699+source = "git+https://github.com/ivanceras/svgbob?rev=04a9d85c4b1879051f205e9e434e058864c3d36f#04a9d85c4b1879051f205e9e434e058864c3d36f"700+dependencies = [701+ "indexmap",702+ "itertools",703+ "log",704+ "nalgebra",705+ "once_cell",706+ "parry2d",707+ "pom",708+ "sauron",709+ "unicode-width",710+]711+712+[[package]]713+name = "svgbob-wasm"714+version = "0.1.0"715+dependencies = [716+ "svgbob",717+ "wasm-bindgen",718+]719+720+[[package]]721+name = "syn"722+version = "2.0.119"723+source = "registry+https://github.com/rust-lang/crates.io-index"724+checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"725+dependencies = [726+ "proc-macro2",727+ "quote",728+ "unicode-ident",729+]730+731+[[package]]732+name = "syn"733+version = "3.0.3"734+source = "registry+https://github.com/rust-lang/crates.io-index"735+checksum = "53e9bae58849f64dfa4f5d5ae372c8341f7305f82a3868709269343628b659a3"736+dependencies = [737+ "proc-macro2",738+ "quote",739+ "unicode-ident",740+]741+742+[[package]]743+name = "syn_derive"744+version = "0.1.8"745+source = "registry+https://github.com/rust-lang/crates.io-index"746+checksum = "1329189c02ff984e9736652b1631330da25eaa6bc639089ed4915d25446cbe7b"747+dependencies = [748+ "proc-macro-error",749+ "proc-macro2",750+ "quote",751+ "syn 2.0.119",752+]753+754+[[package]]755+name = "thiserror"756+version = "1.0.69"757+source = "registry+https://github.com/rust-lang/crates.io-index"758+checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"759+dependencies = [760+ "thiserror-impl",761+]762+763+[[package]]764+name = "thiserror-impl"765+version = "1.0.69"766+source = "registry+https://github.com/rust-lang/crates.io-index"767+checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"768+dependencies = [769+ "proc-macro2",770+ "quote",771+ "syn 2.0.119",772+]773+774+[[package]]775+name = "typenum"776+version = "1.20.1"777+source = "registry+https://github.com/rust-lang/crates.io-index"778+checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"779+780+[[package]]781+name = "unicode-ident"782+version = "1.0.24"783+source = "registry+https://github.com/rust-lang/crates.io-index"784+checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"785+786+[[package]]787+name = "unicode-width"788+version = "0.1.14"789+source = "registry+https://github.com/rust-lang/crates.io-index"790+checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af"791+792+[[package]]793+name = "version_check"794+version = "0.9.5"795+source = "registry+https://github.com/rust-lang/crates.io-index"796+checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"797+798+[[package]]799+name = "wasm-bindgen"800+version = "0.2.127"801+source = "registry+https://github.com/rust-lang/crates.io-index"802+checksum = "1b70935747edd64d89de3efa29d73789b806c15798f8e7dca4d8ac356b50ce70"803+dependencies = [804+ "cfg-if",805+ "once_cell",806+ "rustversion",807+ "wasm-bindgen-macro",808+ "wasm-bindgen-shared",809+]810+811+[[package]]812+name = "wasm-bindgen-futures"813+version = "0.4.77"814+source = "registry+https://github.com/rust-lang/crates.io-index"815+checksum = "6b7777d5cc23d0e91404e53ce2d5e8ec7acae3026b16233dba62cd3246457950"816+dependencies = [817+ "js-sys",818+ "wasm-bindgen",819+]820+821+[[package]]822+name = "wasm-bindgen-macro"823+version = "0.2.127"824+source = "registry+https://github.com/rust-lang/crates.io-index"825+checksum = "77775f8f3f7217702089053b94958f8f54061a3f663417df76e19cbdcca29bc1"826+dependencies = [827+ "quote",828+ "wasm-bindgen-macro-support",829+]830+831+[[package]]832+name = "wasm-bindgen-macro-support"833+version = "0.2.127"834+source = "registry+https://github.com/rust-lang/crates.io-index"835+checksum = "e11d33f857dc2fb11b8bc75aee111aa9cbeb12cd9f25efd3d4c2a3dd4e235284"836+dependencies = [837+ "bumpalo",838+ "proc-macro2",839+ "quote",840+ "syn 2.0.119",841+ "wasm-bindgen-shared",842+]843+844+[[package]]845+name = "wasm-bindgen-shared"846+version = "0.2.127"847+source = "registry+https://github.com/rust-lang/crates.io-index"848+checksum = "7ef64dbcc55df09c7e5a46182d181c2cfa3e925f3da937ea764728b4bbb9dcbf"849+dependencies = [850+ "unicode-ident",851+]852+853+[[package]]854+name = "web-sys"855+version = "0.3.104"856+source = "registry+https://github.com/rust-lang/crates.io-index"857+checksum = "c435338968042f4f59a557f690a253676d47ce13ceb55d70100e7facf6620a30"858+dependencies = [859+ "js-sys",860+ "wasm-bindgen",861+]862+863+[[package]]864+name = "wide"865+version = "0.7.33"866+source = "registry+https://github.com/rust-lang/crates.io-index"867+checksum = "0ce5da8ecb62bcd8ec8b7ea19f69a51275e91299be594ea5cc6ef7819e16cd03"868+dependencies = [869+ "bytemuck",870+ "safe_arch",871+]872+873+[[package]]874+name = "yansi"875+version = "1.0.1"876+source = "registry+https://github.com/rust-lang/crates.io-index"877+checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049"@@ -0,0 +1,28 @@
1+use svgbob::{to_svg_with_settings, Settings};2+use wasm_bindgen::prelude::*;3+4+/// Render one ASCII source using svgbob's pure library API.5+///6+/// The JavaScript adapter validates bounds and option syntax. Keeping this7+/// wrapper free of DOM, filesystem, and network APIs makes it usable in a8+/// Cloudflare Worker compiled-Wasm binding.9+10+pub fn render(11+ source: &str,12+ background: &str,13+ fill_color: &str,14+ font_family: &str,15+ font_size: u32,16+ scale: f32,17+ stroke_width: f32,18+) -> String {19+ let mut settings = Settings::default();20+ settings.background = background.to_owned();21+ settings.fill_color = fill_color.to_owned();22+ settings.font_family = font_family.to_owned();23+ settings.font_size = font_size as usize;24+ // Kroki's `scale` is a multiplier over Svgbob's default scale (8.0).25+ settings.scale = 8.0 * scale;26+ settings.stroke_width = stroke_width;27+ to_svg_with_settings(source, &settings)28+}@@ -41,6 +41,12 @@ describe('engine catalog', () => {
4141 expect(pikchr.version).toContain('pikchr@85e65b9686')4242 })4343 44+ it('marks Svgbob as a dedicated edge-Wasm unit', () => {45+ const svgbob = ENGINE_CATALOG.find(engine => engine.id === 'svgbob')!46+ expect(svgbob.activeRuntime).toBe('edge-wasm')47+ expect(svgbob.version).toContain('svgbob@0.7.6')48+ })49+4450 it('does not retain a silent origin fallback for any engine', () => {4551 for (const engine of ENGINE_CATALOG) {4652 if (engine.activeRuntime === 'origin') expect(engine.version).toBe('compatibility-origin')@@ -5,7 +5,7 @@ const migrated = [
55 'mermaid', 'bpmn', 'excalidraw',66 'bytefield', 'nomnoml', 'vega', 'vegalite', 'wavedrom',77 'blockdiag', 'seqdiag', 'actdiag', 'nwdiag', 'packetdiag', 'rackdiag',8- 'graphviz', 'erd', 'pikchr', 'wireviz',8+ 'graphviz', 'erd', 'pikchr', 'svgbob', 'wireviz',99 ] as const1010 const env = {1111 ORIGIN_URL: 'https://diagram-zip.fly.dev',@@ -0,0 +1,50 @@
1+import { describe, expect, it } from 'vitest'2+import { svgbobAdapter } from '../src/adapters/edge/svgbob'3+import type { RenderRequest } from '../src/types'4+5+const request = (source: string, options: Record<string, string> = {}): RenderRequest => ({6+ engine: 'svgbob', source, format: 'svg', options,7+ metadata: { title: '', description: '' },8+ presentation: { background: '', padding: 0, frame: false },9+})10+const cloud = ` .-,( ),-.11+ ___ _ .-( )-.12+ [___]|=| -->( ) __________13+ /::/ |_| '-( ).-' --->[_...__... ]14+ '-.( ).-'15+ \\ ____ __16+ '--->| | |==|17+ |____| | |18+ /::::/ |__|`19+20+describe('Svgbob edge-Wasm adapter', () => {21+ it('renders ASCII source without trimming its leading whitespace', async () => {22+ const result = await svgbobAdapter.render(request(' +---+\n | A |\n +---+'), new AbortController().signal)23+ expect(result.runtime).toBe('edge-wasm')24+ expect(result.body).toContain('<svg')25+ expect(result.body).toContain('A')26+ })27+28+ it('maps the six Kroki settings to the pure library API', async () => {29+ const result = await svgbobAdapter.render(request('A -> B', {30+ background: '#f3f3f3', 'fill-color': '#123456', 'font-family': 'monospace',31+ 'font-size': '18', scale: '2', 'stroke-width': '3',32+ }), new AbortController().signal)33+ expect(result.body).toContain('#f3f3f3')34+ expect(result.body).toContain('#123456')35+ expect(result.body).toContain('font-size: 18px')36+ })37+38+ it('keeps upstream cloud fixture dimensions at 400x160 and scales to 600x240', async () => {39+ const defaultResult = await svgbobAdapter.render(request(cloud), new AbortController().signal)40+ const scaledResult = await svgbobAdapter.render(request(cloud, { scale: '1.5' }), new AbortController().signal)41+ expect(defaultResult.body).toMatch(/<svg[^>]*width="400"[^>]*height="160"/)42+ expect(scaledResult.body).toMatch(/<svg[^>]*width="600"[^>]*height="240"/)43+ })44+45+ it('rejects unknown, invalid, and oversized input before Wasm', async () => {46+ await expect(svgbobAdapter.render(request('A', { 'stroke-color': 'red' }), new AbortController().signal)).rejects.toMatchObject({ status: 400, code: 'unsupported_options' })47+ await expect(svgbobAdapter.render(request('A', { scale: 'NaN' }), new AbortController().signal)).rejects.toMatchObject({ status: 400, code: 'invalid_options' })48+ await expect(svgbobAdapter.render(request('é'.repeat(140_000)), new AbortController().signal)).rejects.toMatchObject({ status: 413, code: 'source_too_large' })49+ })50+})@@ -0,0 +1,10 @@
1+{2+ "$schema": "../node_modules/wrangler/config-schema.json",3+ "name": "diagramzip-render-svgbob",4+ "main": "../src/units/svgbob.ts",5+ "compatibility_date": "2026-08-20",6+ "rules": [{ "type": "CompiledWasm", "globs": ["**/*.wasm"], "fallthrough": false }],7+ "observability": { "enabled": true, "logs": { "head_sampling_rate": 1 } },8+ "vars": { "RENDERER_BUILD": "svgbob-0.7.6-edge-wasm-1" },9+ "routes": [{ "pattern": "svgbob.render.diagram.zip", "custom_domain": true }]10+}@@ -32,7 +32,7 @@ export const NO_GATEWAY_FALLBACK_ENGINES = Object.freeze([
3232 'mermaid', 'bpmn', 'excalidraw',3333 'bytefield', 'nomnoml', 'vega', 'vegalite', 'wavedrom',3434 'blockdiag', 'seqdiag', 'actdiag', 'nwdiag', 'packetdiag', 'rackdiag',35- 'graphviz', 'erd', 'pikchr', 'wireviz',35+ 'graphviz', 'erd', 'pikchr', 'svgbob', 'wireviz',3636 ])3737 3838 export function requiresDedicatedRenderer(engine) {@@ -23,7 +23,7 @@ test('requires every migrated engine to stay on its dedicated runtime', () => {
2323 'mermaid', 'bpmn', 'excalidraw',2424 'bytefield', 'nomnoml', 'vega', 'vegalite', 'wavedrom',2525 'blockdiag', 'seqdiag', 'actdiag', 'nwdiag', 'packetdiag', 'rackdiag',26- 'graphviz', 'erd', 'pikchr', 'wireviz',26+ 'graphviz', 'erd', 'pikchr', 'svgbob', 'wireviz',2727 ]) {2828 assert.equal(requiresDedicatedRenderer(engine), true)2929 }@@ -419,7 +419,7 @@ The origin is a compatibility bridge, not the target architecture for standardiz
419419 | WaveDrom | Edge JavaScript | Origin |420420 | WireViz | Upstream Python parser/model/DOT composer → GraphViz service binding | None after cutover |421421 422-The first coverage milestone puts all 30 catalog types behind one contract and keeps unsupported edge engines on the origin. Its first native cohort is Bytefield, Nomnoml, WaveDrom, Vega, and Vega-Lite. DBML remains on the origin because its published package mixes module formats. GraphViz now imports its WebAssembly as a precompiled Worker module, ERD lowers into that same runtime, and Pikchr has a separate precompiled WebAssembly unit. D2 and Svgbob move only after direct precompiled-Wasm adapters are proven. Seven engines can later move interactive preview into the browser: Mermaid, PlantUML, C4-PlantUML, BPMN, Excalidraw, diagrams.net, and UMLet.422+The first coverage milestone puts all 30 catalog types behind one contract and keeps unsupported edge engines on the origin. Its first native cohort is Bytefield, Nomnoml, WaveDrom, Vega, and Vega-Lite. DBML remains on the origin because its published package mixes module formats. GraphViz now imports its WebAssembly as a precompiled Worker module, ERD lowers into that same runtime, Pikchr has a separate precompiled WebAssembly unit, and Svgbob has a pinned Rust/Wasm unit. D2 remains only after a direct precompiled-Wasm adapter is proven. Seven engines can later move interactive preview into the browser: Mermaid, PlantUML, C4-PlantUML, BPMN, Excalidraw, diagrams.net, and UMLet.423423 424424 The upstream-reuse milestone moves all six BlockDiag-family types into one Python Worker, moves ERD to an upstream-guided TypeScript/GraphViz implementation, and preserves WireViz coverage in a dependency-isolated Python translator that reuses GraphViz through a service binding. Structurizr remains a later PlantUML translation target.425425 @@ -559,13 +559,13 @@ Use production traffic and latency data to choose the remaining rewrites. WireVi
559559 560560 ## Implementation status — 2026-08-20561561 562-The coverage plane is implemented across dedicated renderer hostnames. Eighteen562+The coverage plane is implemented across dedicated renderer hostnames. Nineteen563563 of 30 catalog engines no longer depend on Fly: five execute in JavaScript564564 Workers, six share the `blockdiag-family` Python Worker, GraphViz and ERD share565-the `graphviz-family` WebAssembly Worker, Pikchr in its dedicated WebAssembly Worker, and Mermaid, BPMN, and Excalidraw565+the `graphviz-family` WebAssembly Worker, Pikchr and Svgbob in dedicated WebAssembly Workers, and Mermaid, BPMN, and Excalidraw566566 render in sandboxed browser units. WireViz preserves its upstream Python parser567567 and DOT composer, then calls GraphViz through an internal service binding. The568-remaining 12 engines use 11568+remaining 11 engines use 10569569 dependency-grouped compatibility units. Repository and production smokes require570570 structurally valid SVG; pixel comparison remains intentionally deferred.571571 @@ -587,13 +587,18 @@ uses plaintext parser errors and bounded source input, rejects renderer options
587587 and assets, and frees all returned buffers. The browser fiddle's dynamic Wasm588588 loader is not used; the module is statically imported by the Worker.589589 590+The Svgbob unit compiles upstream 0.7.6 from its pinned commit through a591+small Rust/wasm-bindgen wrapper around the pure library API. It preserves ASCII592+whitespace, maps the six Kroki settings, uses explicit byte/resource limits,593+and removes the upstream backdrop when presentation background is applied.594+590595 The WireViz unit vendors the actual `yuzutech/WireViz` v0.3.3 release source,591596 whose own runtime version is 0.3.2, and stops before external `dot` execution.592597 It rejects filesystem images and raw GraphViz tweaks, bounds YAML expansion,593598 and forwards generated DOT to `graphviz-family`. BOM, HTML, and PNG sidecars594599 remain outside the SVG rendering contract.595600 596-The same hard boundary now applies to all eighteen migrated engines: direct601+The same hard boundary now applies to all nineteen migrated engines: direct597602 unit or client-renderer failure is surfaced to the editor, the gateway rejects598603 their engine IDs before consulting its cache or origin adapter, and every599604 catalog fallback is `null`.@@ -1644,7 +1644,7 @@ Rel(bob, tandem, "Completes tasks")
16441644 \r --�𐀀-`,e.S=` \r16451645 `,e.NAME_START_CHAR=`:A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-⁰-Ⰰ-、-豈-﷏ﷰ-�𐀀-`,e.NAME_CHAR=`-`+e.NAME_START_CHAR+`.0-9·̀-ͯ‿-⁀`,e.CHAR_RE=RegExp(`^[`+e.CHAR+`]$`,`u`),e.S_RE=RegExp(`^[`+e.S+`]+$`,`u`),e.NAME_START_CHAR_RE=RegExp(`^[`+e.NAME_START_CHAR+`]$`,`u`),e.NAME_CHAR_RE=RegExp(`^[`+e.NAME_CHAR+`]$`,`u`),e.NAME_RE=RegExp(`^[`+e.NAME_START_CHAR+`][`+e.NAME_CHAR+`]*$`,`u`),e.NMTOKEN_RE=RegExp(`^[`+e.NAME_CHAR+`]+$`,`u`);var t=9,n=10,r=13,i=32;e.S_LIST=[i,n,r,t];function a(e){return e>=i&&e<=55295||e===n||e===r||e===t||e>=57344&&e<=65533||e>=65536&&e<=1114111}e.isChar=a;function o(e){return e===i||e===n||e===r||e===t}e.isS=o;function s(e){return e>=65&&e<=90||e>=97&&e<=122||e===58||e===95||e===8204||e===8205||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=767||e>=880&&e<=893||e>=895&&e<=8191||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}e.isNameStartChar=s;function c(e){return s(e)||e>=48&&e<=57||e===45||e===46||e===183||e>=768&&e<=879||e>=8255&&e<=8256}e.isNameChar=c})),sw=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CHAR=`--�𐀀-`,e.RESTRICTED_CHAR=`-\b\v\f---`,e.S=` \r16461646 `,e.NAME_START_CHAR=`:A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-⁰-Ⰰ-、-豈-﷏ﷰ-�𐀀-`,e.NAME_CHAR=`-`+e.NAME_START_CHAR+`.0-9·̀-ͯ‿-⁀`,e.CHAR_RE=RegExp(`^[`+e.CHAR+`]$`,`u`),e.RESTRICTED_CHAR_RE=RegExp(`^[`+e.RESTRICTED_CHAR+`]$`,`u`),e.S_RE=RegExp(`^[`+e.S+`]+$`,`u`),e.NAME_START_CHAR_RE=RegExp(`^[`+e.NAME_START_CHAR+`]$`,`u`),e.NAME_CHAR_RE=RegExp(`^[`+e.NAME_CHAR+`]$`,`u`),e.NAME_RE=RegExp(`^[`+e.NAME_START_CHAR+`][`+e.NAME_CHAR+`]*$`,`u`),e.NMTOKEN_RE=RegExp(`^[`+e.NAME_CHAR+`]+$`,`u`);var t=9,n=10,r=13,i=32;e.S_LIST=[i,n,r,t];function a(e){return e>=1&&e<=55295||e>=57344&&e<=65533||e>=65536&&e<=1114111}e.isChar=a;function o(e){return e>=1&&e<=8||e===11||e===12||e>=14&&e<=31||e>=127&&e<=132||e>=134&&e<=159}e.isRestrictedChar=o;function s(e){return e===9||e===10||e===13||e>31&&e<127||e===133||e>159&&e<=55295||e>=57344&&e<=65533||e>=65536&&e<=1114111}e.isCharAndNotRestricted=s;function c(e){return e===i||e===n||e===r||e===t}e.isS=c;function l(e){return e>=65&&e<=90||e>=97&&e<=122||e===58||e===95||e===8204||e===8205||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=767||e>=880&&e<=893||e>=895&&e<=8191||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}e.isNameStartChar=l;function u(e){return l(e)||e>=48&&e<=57||e===45||e===46||e===183||e>=768&&e<=879||e>=8255&&e<=8256}e.isNameChar=u})),cw=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.NC_NAME_START_CHAR=`A-Z_a-zÀ-ÖØ-öø-˿Ͱ-ͽͿ--⁰-Ⰰ-、-豈-﷏ﷰ-�𐀀-`,e.NC_NAME_CHAR=`-`+e.NC_NAME_START_CHAR+`.0-9·̀-ͯ‿-⁀`,e.NC_NAME_START_CHAR_RE=RegExp(`^[`+e.NC_NAME_START_CHAR+`]$`,`u`),e.NC_NAME_CHAR_RE=RegExp(`^[`+e.NC_NAME_CHAR+`]$`,`u`),e.NC_NAME_RE=RegExp(`^[`+e.NC_NAME_START_CHAR+`][`+e.NC_NAME_CHAR+`]*$`,`u`);function t(e){return e>=65&&e<=90||e===95||e>=97&&e<=122||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=767||e>=880&&e<=893||e>=895&&e<=8191||e>=8204&&e<=8205||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}e.isNCNameStartChar=t;function n(e){return t(e)||e===45||e===46||e>=48&&e<=57||e===183||e>=768&&e<=879||e>=8255&&e<=8256}e.isNCNameChar=n})),lw=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SaxesParser=e.EVENTS=void 0;var t=ow(),n=sw(),r=cw(),i=t.isS,a=t.isChar,o=t.isNameStartChar,s=t.isNameChar,c=t.S_LIST,l=t.NAME_RE,u=n.isChar,d=r.isNCNameStartChar,f=r.isNCNameChar,p=r.NC_NAME_RE,m=`http://www.w3.org/XML/1998/namespace`,h=`http://www.w3.org/2000/xmlns/`,g={__proto__:null,xml:m,xmlns:h},_={__proto__:null,amp:`&`,gt:`>`,lt:`<`,quot:`"`,apos:`'`},v=-1,y=-2,ee=0,te=1,ne=2,re=3,b=4,ie=5,ae=6,x=7,oe=8,S=9,se=10,ce=11,le=12,C=13,w=14,ue=15,de=16,fe=17,pe=18,me=19,he=20,T=21,ge=22,_e=23,E=24,ve=25,ye=26,be=27,xe=28,Se=29,Ce=30,we=31,Te=32,Ee=33,De=34,Oe=35,ke=36,Ae=37,je=38,Me=39,Ne=40,Pe=41,Fe=42,Ie=43,Le=44,Re=9,ze=10,Be=13,Ve=32,He=33,Ue=34,We=38,D=39,O=45,Ge=47,Ke=59,qe=60,Je=61,k=62,A=63,Ye=91,Xe=93,j=133,Ze=8232,Qe=e=>e===Ue||e===D,$e=[Ue,D],et=[...$e,Ye,k],M=[...$e,qe,Xe],tt=[Je,A,...c],nt=[...c,k,We,qe];function rt(e,t,n){switch(t){case`xml`:n!==m&&e.fail(`xml prefix must be bound to ${m}.`);break;case`xmlns`:n!==h&&e.fail(`xmlns prefix must be bound to ${h}.`)}switch(n){case h:e.fail(t===``?`the default namespace may not be set to ${n}.`:`may not assign a prefix (even "xmlns") to the URI \1647-${h}.`);break;case m:switch(t){case`xml`:break;case``:e.fail(`the default namespace may not be set to ${n}.`);break;default:e.fail(`may not assign the xml namespace to another prefix.`)}}}function it(e,t){for(let n of Object.keys(t))rt(e,n,t[n])}var at=e=>p.test(e),ot=e=>l.test(e),N=0,st=1,ct=2;e.EVENTS=[`xmldecl`,`text`,`processinginstruction`,`doctype`,`comment`,`opentagstart`,`attribute`,`opentag`,`closetag`,`cdata`,`error`,`end`,`ready`];var lt={xmldecl:`xmldeclHandler`,text:`textHandler`,processinginstruction:`piHandler`,doctype:`doctypeHandler`,comment:`commentHandler`,opentagstart:`openTagStartHandler`,attribute:`attributeHandler`,opentag:`openTagHandler`,closetag:`closeTagHandler`,cdata:`cdataHandler`,error:`errorHandler`,end:`endHandler`,ready:`readyHandler`};e.SaxesParser=class{constructor(e){this.opt=e??{},this.fragmentOpt=!!this.opt.fragment;let t=this.xmlnsOpt=!!this.opt.xmlns;if(this.trackPosition=this.opt.position!==!1,this.fileName=this.opt.fileName,t){this.nameStartCheck=d,this.nameCheck=f,this.isName=at,this.processAttribs=this.processAttribsNS,this.pushAttrib=this.pushAttribNS,this.ns=Object.assign({__proto__:null},g);let e=this.opt.additionalNamespaces;e!=null&&(it(this,e),Object.assign(this.ns,e))}else this.nameStartCheck=o,this.nameCheck=s,this.isName=ot,this.processAttribs=this.processAttribsPlain,this.pushAttrib=this.pushAttribPlain;this.stateTable=[this.sBegin,this.sBeginWhitespace,this.sDoctype,this.sDoctypeQuote,this.sDTD,this.sDTDQuoted,this.sDTDOpenWaka,this.sDTDOpenWakaBang,this.sDTDComment,this.sDTDCommentEnding,this.sDTDCommentEnded,this.sDTDPI,this.sDTDPIEnding,this.sText,this.sEntity,this.sOpenWaka,this.sOpenWakaBang,this.sComment,this.sCommentEnding,this.sCommentEnded,this.sCData,this.sCDataEnding,this.sCDataEnding2,this.sPIFirstChar,this.sPIRest,this.sPIBody,this.sPIEnding,this.sXMLDeclNameStart,this.sXMLDeclName,this.sXMLDeclEq,this.sXMLDeclValueStart,this.sXMLDeclValue,this.sXMLDeclSeparator,this.sXMLDeclEnding,this.sOpenTag,this.sOpenTagSlash,this.sAttrib,this.sAttribName,this.sAttribNameSawWhite,this.sAttribValue,this.sAttribValueQuoted,this.sAttribValueClosed,this.sAttribValueUnquoted,this.sCloseTag,this.sCloseTagSawWhite],this._init()}get closed(){return this._closed}_init(){var e;this.openWakaBang=``,this.text=``,this.name=``,this.piTarget=``,this.entity=``,this.q=null,this.tags=[],this.tag=null,this.topNS=null,this.chunk=``,this.chunkPosition=0,this.i=0,this.prevI=0,this.carriedFromPrevious=void 0,this.forbiddenState=N,this.attribList=[];let{fragmentOpt:t}=this;this.state=t?C:ee,this.reportedTextBeforeRoot=this.reportedTextAfterRoot=this.closedRoot=this.sawRoot=t,this.xmlDeclPossible=!t,this.xmlDeclExpects=[`version`],this.entityReturnState=void 0;let{defaultXMLVersion:n}=this.opt;if(n===void 0){if(this.opt.forceXMLVersion===!0)throw Error(`forceXMLVersion set but defaultXMLVersion is not set`);n=`1.0`}this.setXMLVersion(n),this.positionAtNewLine=0,this.doctype=!1,this._closed=!1,this.xmlDecl={version:void 0,encoding:void 0,standalone:void 0},this.line=1,this.column=0,this.ENTITIES=Object.create(_),(e=this.readyHandler)==null||e.call(this)}get position(){return this.chunkPosition+this.i}get columnIndex(){return this.position-this.positionAtNewLine}on(e,t){this[lt[e]]=t}off(e){this[lt[e]]=void 0}makeError(e){let t=this.fileName??``;return this.trackPosition&&(t.length>0&&(t+=`:`),t+=`${this.line}:${this.column}`),t.length>0&&(t+=`: `),Error(t+e)}fail(e){let t=this.makeError(e),n=this.errorHandler;if(n===void 0)throw t;return n(t),this}write(e){if(this.closed)return this.fail(`cannot write after close; assign an onready handler.`);let t=!1;e===null?(t=!0,e=``):typeof e==`object`&&(e=e.toString()),this.carriedFromPrevious!==void 0&&(e=`${this.carriedFromPrevious}${e}`,this.carriedFromPrevious=void 0);let n=e.length,r=e.charCodeAt(n-1);!t&&(r===Be||r>=55296&&r<=56319)&&(this.carriedFromPrevious=e[n-1],n--,e=e.slice(0,n));let{stateTable:i}=this;for(this.chunk=e,this.i=0;this.i<n;)i[this.state].call(this);return this.chunkPosition+=n,t?this.end():this}close(){return this.write(null)}getCode10(){let{chunk:e,i:t}=this;if(this.prevI=t,this.i=t+1,t>=e.length)return v;let n=e.charCodeAt(t);if(this.column++,n<55296){if(n>=Ve||n===Re)return n;switch(n){case ze:return this.line++,this.column=0,this.positionAtNewLine=this.position,ze;case Be:return e.charCodeAt(t+1)===ze&&(this.i=t+2),this.line++,this.column=0,this.positionAtNewLine=this.position,y;default:return this.fail(`disallowed character.`),n}}if(n>56319)return n>=57344&&n<=65533||this.fail(`disallowed character.`),n;let r=65536+(n-55296)*1024+(e.charCodeAt(t+1)-56320);return this.i=t+2,r>1114111&&this.fail(`disallowed character.`),r}getCode11(){let{chunk:e,i:t}=this;if(this.prevI=t,this.i=t+1,t>=e.length)return v;let n=e.charCodeAt(t);if(this.column++,n<55296){if(n>31&&n<127||n>159&&n!==Ze||n===Re)return n;switch(n){case ze:return this.line++,this.column=0,this.positionAtNewLine=this.position,ze;case Be:{let n=e.charCodeAt(t+1);(n===ze||n===j)&&(this.i=t+2)}case j:case Ze:return this.line++,this.column=0,this.positionAtNewLine=this.position,y;default:return this.fail(`disallowed character.`),n}}if(n>56319)return n>=57344&&n<=65533||this.fail(`disallowed character.`),n;let r=65536+(n-55296)*1024+(e.charCodeAt(t+1)-56320);return this.i=t+2,r>1114111&&this.fail(`disallowed character.`),r}getCodeNorm(){let e=this.getCode();return e===y?ze:e}unget(){this.i=this.prevI,this.column--}captureTo(e){let{i:t}=this,{chunk:n}=this;for(;;){let r=this.getCode(),i=r===y,a=i?ze:r;if(a===v||e.includes(a))return this.text+=n.slice(t,this.prevI),a;i&&(this.text+=`${n.slice(t,this.prevI)}\n`,t=this.i)}}captureToChar(e){let{i:t}=this,{chunk:n}=this;for(;;){let r=this.getCode();switch(r){case y:this.text+=`${n.slice(t,this.prevI)}\n`,t=this.i,r=ze;break;case v:return this.text+=n.slice(t),!1}if(r===e)return this.text+=n.slice(t,this.prevI),!0}}captureNameChars(){let{chunk:e,i:t}=this;for(;;){let n=this.getCode();if(n===v)return this.name+=e.slice(t),v;if(!s(n))return this.name+=e.slice(t,this.prevI),n===y?ze:n}}skipSpaces(){for(;;){let e=this.getCodeNorm();if(e===v||!i(e))return e}}setXMLVersion(e){this.currentXMLVersion=e,e===`1.0`?(this.isChar=a,this.getCode=this.getCode10):(this.isChar=u,this.getCode=this.getCode11)}sBegin(){this.chunk.charCodeAt(0)===65279&&(this.i++,this.column++),this.state=te}sBeginWhitespace(){let e=this.i,t=this.skipSpaces();switch(this.prevI!==e&&(this.xmlDeclPossible=!1),t){case qe:if(this.state=ue,this.text.length!==0)throw Error(`no-empty text at start`);break;case v:break;default:this.unget(),this.state=C,this.xmlDeclPossible=!1}}sDoctype(){var e;let t=this.captureTo(et);switch(t){case k:(e=this.doctypeHandler)==null||e.call(this,this.text),this.text=``,this.state=C,this.doctype=!0;break;case v:break;default:this.text+=String.fromCodePoint(t),t===Ye?this.state=b:Qe(t)&&(this.state=re,this.q=t)}}sDoctypeQuote(){let e=this.q;this.captureToChar(e)&&(this.text+=String.fromCodePoint(e),this.q=null,this.state=ne)}sDTD(){let e=this.captureTo(M);e!==v&&(this.text+=String.fromCodePoint(e),e===Xe?this.state=ne:e===qe?this.state=ae:Qe(e)&&(this.state=ie,this.q=e))}sDTDQuoted(){let e=this.q;this.captureToChar(e)&&(this.text+=String.fromCodePoint(e),this.state=b,this.q=null)}sDTDOpenWaka(){let e=this.getCodeNorm();switch(this.text+=String.fromCodePoint(e),e){case He:this.state=x,this.openWakaBang=``;break;case A:this.state=ce;break;default:this.state=b}}sDTDOpenWakaBang(){let e=String.fromCodePoint(this.getCodeNorm()),t=this.openWakaBang+=e;this.text+=e,t!==`-`&&(this.state=t===`--`?oe:b,this.openWakaBang=``)}sDTDComment(){this.captureToChar(O)&&(this.text+=`-`,this.state=S)}sDTDCommentEnding(){let e=this.getCodeNorm();this.text+=String.fromCodePoint(e),this.state=e===O?se:oe}sDTDCommentEnded(){let e=this.getCodeNorm();this.text+=String.fromCodePoint(e),e===k?this.state=b:(this.fail(`malformed comment.`),this.state=oe)}sDTDPI(){this.captureToChar(A)&&(this.text+=`?`,this.state=le)}sDTDPIEnding(){let e=this.getCodeNorm();this.text+=String.fromCodePoint(e),e===k&&(this.state=b)}sText(){this.tags.length===0?this.handleTextOutsideRoot():this.handleTextInRoot()}sEntity(){let{i:e}=this,{chunk:t}=this;loop:for(;;)switch(this.getCode()){case y:this.entity+=`${t.slice(e,this.prevI)}\n`,e=this.i;break;case Ke:{let{entityReturnState:n}=this,r=this.entity+t.slice(e,this.prevI);this.state=n;let i;r===``?(this.fail(`empty entity name.`),i=`&;`):(i=this.parseEntity(r),this.entity=``),(n!==C||this.textHandler!==void 0)&&(this.text+=i);break loop}case v:this.entity+=t.slice(e);break loop}}sOpenWaka(){let e=this.getCode();if(o(e))this.state=De,this.unget(),this.xmlDeclPossible=!1;else switch(e){case Ge:this.state=Ie,this.xmlDeclPossible=!1;break;case He:this.state=de,this.openWakaBang=``,this.xmlDeclPossible=!1;break;case A:this.state=_e;break;default:this.fail(`disallowed character in tag name`),this.state=C,this.xmlDeclPossible=!1}}sOpenWakaBang(){switch(this.openWakaBang+=String.fromCodePoint(this.getCodeNorm()),this.openWakaBang){case`[CDATA[`:!this.sawRoot&&!this.reportedTextBeforeRoot&&(this.fail(`text data outside of root node.`),this.reportedTextBeforeRoot=!0),this.closedRoot&&!this.reportedTextAfterRoot&&(this.fail(`text data outside of root node.`),this.reportedTextAfterRoot=!0),this.state=he,this.openWakaBang=``;break;case`--`:this.state=fe,this.openWakaBang=``;break;case`DOCTYPE`:this.state=ne,(this.doctype||this.sawRoot)&&this.fail(`inappropriately located doctype declaration.`),this.openWakaBang=``;break;default:this.openWakaBang.length>=7&&this.fail(`incorrect syntax.`)}}sComment(){this.captureToChar(O)&&(this.state=pe)}sCommentEnding(){var e;let t=this.getCodeNorm();t===O?(this.state=me,(e=this.commentHandler)==null||e.call(this,this.text),this.text=``):(this.text+=`-${String.fromCodePoint(t)}`,this.state=fe)}sCommentEnded(){let e=this.getCodeNorm();e===k?this.state=C:(this.fail(`malformed comment.`),this.text+=`--${String.fromCodePoint(e)}`,this.state=fe)}sCData(){this.captureToChar(Xe)&&(this.state=T)}sCDataEnding(){let e=this.getCodeNorm();e===Xe?this.state=ge:(this.text+=`]${String.fromCodePoint(e)}`,this.state=he)}sCDataEnding2(){var e;let t=this.getCodeNorm();switch(t){case k:(e=this.cdataHandler)==null||e.call(this,this.text),this.text=``,this.state=C;break;case Xe:this.text+=`]`;break;default:this.text+=`]]${String.fromCodePoint(t)}`,this.state=he}}sPIFirstChar(){let e=this.getCodeNorm();this.nameStartCheck(e)?(this.piTarget+=String.fromCodePoint(e),this.state=E):e===A||i(e)?(this.fail(`processing instruction without a target.`),this.state=e===A?ye:ve):(this.fail(`disallowed character in processing instruction name.`),this.piTarget+=String.fromCodePoint(e),this.state=E)}sPIRest(){let{chunk:e,i:t}=this;for(;;){let n=this.getCodeNorm();if(n===v){this.piTarget+=e.slice(t);return}if(!this.nameCheck(n)){this.piTarget+=e.slice(t,this.prevI);let r=n===A;r||i(n)?this.piTarget===`xml`?(this.xmlDeclPossible||this.fail(`an XML declaration must be at the start of the document.`),this.state=r?Ee:be):this.state=r?ye:ve:(this.fail(`disallowed character in processing instruction name.`),this.piTarget+=String.fromCodePoint(n));break}}}sPIBody(){if(this.text.length===0){let e=this.getCodeNorm();e===A?this.state=ye:i(e)||(this.text=String.fromCodePoint(e))}else this.captureToChar(A)&&(this.state=ye)}sPIEnding(){var e;let t=this.getCodeNorm();if(t===k){let{piTarget:t}=this;t.toLowerCase()===`xml`&&this.fail(`the XML declaration must appear at the start of the document.`),(e=this.piHandler)==null||e.call(this,{target:t,body:this.text}),this.piTarget=this.text=``,this.state=C}else t===A?this.text+=`?`:(this.text+=`?${String.fromCodePoint(t)}`,this.state=ve);this.xmlDeclPossible=!1}sXMLDeclNameStart(){let e=this.skipSpaces();if(e===A){this.state=Ee;return}e!==v&&(this.state=xe,this.name=String.fromCodePoint(e))}sXMLDeclName(){let e=this.captureTo(tt);if(e===A){this.state=Ee,this.name+=this.text,this.text=``,this.fail(`XML declaration is incomplete.`);return}if(i(e)||e===Je){if(this.name+=this.text,this.text=``,!this.xmlDeclExpects.includes(this.name))switch(this.name.length){case 0:this.fail(`did not expect any more name/value pairs.`);break;case 1:this.fail(`expected the name ${this.xmlDeclExpects[0]}.`);break;default:this.fail(`expected one of ${this.xmlDeclExpects.join(`, `)}`)}this.state=e===Je?Ce:Se}}sXMLDeclEq(){let e=this.getCodeNorm();if(e===A){this.state=Ee,this.fail(`XML declaration is incomplete.`);return}i(e)||(e!==Je&&this.fail(`value required.`),this.state=Ce)}sXMLDeclValueStart(){let e=this.getCodeNorm();if(e===A){this.state=Ee,this.fail(`XML declaration is incomplete.`);return}i(e)||(Qe(e)?this.q=e:(this.fail(`value must be quoted.`),this.q=Ve),this.state=we)}sXMLDeclValue(){let e=this.captureTo([this.q,A]);if(e===A){this.state=Ee,this.text=``,this.fail(`XML declaration is incomplete.`);return}if(e===v)return;let t=this.text;switch(this.text=``,this.name){case`version`:{this.xmlDeclExpects=[`encoding`,`standalone`];let e=t;this.xmlDecl.version=e,/^1\.[0-9]+$/.test(e)?this.opt.forceXMLVersion||this.setXMLVersion(e):this.fail(`version number must match /^1\\.[0-9]+$/.`);break}case`encoding`:/^[A-Za-z][A-Za-z0-9._-]*$/.test(t)||this.fail(`encoding value must match /^[A-Za-z0-9][A-Za-z0-9._-]*$/.`),this.xmlDeclExpects=[`standalone`],this.xmlDecl.encoding=t;break;case`standalone`:t!==`yes`&&t!==`no`&&this.fail(`standalone value must match "yes" or "no".`),this.xmlDeclExpects=[],this.xmlDecl.standalone=t}this.name=``,this.state=Te}sXMLDeclSeparator(){let e=this.getCodeNorm();if(e===A){this.state=Ee;return}i(e)||(this.fail(`whitespace required.`),this.unget()),this.state=be}sXMLDeclEnding(){var e;this.getCodeNorm()===k?(this.piTarget===`xml`?this.name!==`version`&&this.xmlDeclExpects.includes(`version`)&&this.fail(`XML declaration must contain a version.`):this.fail(`processing instructions are not allowed before root.`),(e=this.xmldeclHandler)==null||e.call(this,this.xmlDecl),this.name=``,this.piTarget=this.text=``,this.state=C):this.fail(`The character ? is disallowed anywhere in XML declarations.`),this.xmlDeclPossible=!1}sOpenTag(){var e;let t=this.captureNameChars();if(t===v)return;let n=this.tag={name:this.name,attributes:Object.create(null)};switch(this.name=``,this.xmlnsOpt&&(this.topNS=n.ns=Object.create(null)),(e=this.openTagStartHandler)==null||e.call(this,n),this.sawRoot=!0,!this.fragmentOpt&&this.closedRoot&&this.fail(`documents may contain only one root.`),t){case k:this.openTag();break;case Ge:this.state=Oe;break;default:i(t)||this.fail(`disallowed character in tag name.`),this.state=ke}}sOpenTagSlash(){this.getCode()===k?this.openSelfClosingTag():(this.fail(`forward-slash in opening tag not followed by >.`),this.state=ke)}sAttrib(){let e=this.skipSpaces();e!==v&&(o(e)?(this.unget(),this.state=Ae):e===k?this.openTag():e===Ge?this.state=Oe:this.fail(`disallowed character in attribute name.`))}sAttribName(){let e=this.captureNameChars();e===Je?this.state=Me:i(e)?this.state=je:e===k?(this.fail(`attribute without value.`),this.pushAttrib(this.name,this.name),this.name=this.text=``,this.openTag()):e!==v&&this.fail(`disallowed character in attribute name.`)}sAttribNameSawWhite(){let e=this.skipSpaces();switch(e){case v:return;case Je:this.state=Me;break;default:this.fail(`attribute without value.`),this.text=``,this.name=``,e===k?this.openTag():o(e)?(this.unget(),this.state=Ae):(this.fail(`disallowed character in attribute name.`),this.state=ke)}}sAttribValue(){let e=this.getCodeNorm();Qe(e)?(this.q=e,this.state=Ne):i(e)||(this.fail(`unquoted attribute value.`),this.state=Fe,this.unget())}sAttribValueQuoted(){let{q:e,chunk:t}=this,{i:n}=this;for(;;)switch(this.getCode()){case e:this.pushAttrib(this.name,this.text+t.slice(n,this.prevI)),this.name=this.text=``,this.q=null,this.state=Pe;return;case We:this.text+=t.slice(n,this.prevI),this.state=w,this.entityReturnState=Ne;return;case ze:case y:case Re:this.text+=`${t.slice(n,this.prevI)} `,n=this.i;break;case qe:this.text+=t.slice(n,this.prevI),this.fail(`disallowed character.`);return;case v:this.text+=t.slice(n);return}}sAttribValueClosed(){let e=this.getCodeNorm();i(e)?this.state=ke:e===k?this.openTag():e===Ge?this.state=Oe:o(e)?(this.fail(`no whitespace between attributes.`),this.unget(),this.state=Ae):this.fail(`disallowed character in attribute name.`)}sAttribValueUnquoted(){let e=this.captureTo(nt);switch(e){case We:this.state=w,this.entityReturnState=Fe;break;case qe:this.fail(`disallowed character.`);break;case v:break;default:this.text.includes(`]]>`)&&this.fail(`the string "]]>" is disallowed in char data.`),this.pushAttrib(this.name,this.text),this.name=this.text=``,e===k?this.openTag():this.state=ke}}sCloseTag(){let e=this.captureNameChars();e===k?this.closeTag():i(e)?this.state=Le:e!==v&&this.fail(`disallowed character in closing tag.`)}sCloseTagSawWhite(){switch(this.skipSpaces()){case k:this.closeTag();break;case v:break;default:this.fail(`disallowed character in closing tag.`)}}handleTextInRoot(){let{i:e,forbiddenState:t}=this,{chunk:n,textHandler:r}=this;scanLoop:for(;;)switch(this.getCode()){case qe:if(this.state=ue,r!==void 0){let{text:t}=this,i=n.slice(e,this.prevI);t.length===0?i.length!==0&&r(i):(r(t+i),this.text=``)}t=N;break scanLoop;case We:this.state=w,this.entityReturnState=C,r!==void 0&&(this.text+=n.slice(e,this.prevI)),t=N;break scanLoop;case Xe:switch(t){case N:t=st;break;case st:t=ct;break;case ct:break;default:throw Error(`impossible state`)}break;case k:t===ct&&this.fail(`the string "]]>" is disallowed in char data.`),t=N;break;case y:r!==void 0&&(this.text+=`${n.slice(e,this.prevI)}\n`),e=this.i,t=N;break;case v:r!==void 0&&(this.text+=n.slice(e));break scanLoop;default:t=N}this.forbiddenState=t}handleTextOutsideRoot(){let{i:e}=this,{chunk:t,textHandler:n}=this,r=!1;outRootLoop:for(;;){let a=this.getCode();switch(a){case qe:if(this.state=ue,n!==void 0){let{text:r}=this,i=t.slice(e,this.prevI);r.length===0?i.length!==0&&n(i):(n(r+i),this.text=``)}break outRootLoop;case We:this.state=w,this.entityReturnState=C,n!==void 0&&(this.text+=t.slice(e,this.prevI)),r=!0;break outRootLoop;case y:n!==void 0&&(this.text+=`${t.slice(e,this.prevI)}\n`),e=this.i;break;case v:n!==void 0&&(this.text+=t.slice(e));break outRootLoop;default:i(a)||(r=!0)}}r&&(!this.sawRoot&&!this.reportedTextBeforeRoot&&(this.fail(`text data outside of root node.`),this.reportedTextBeforeRoot=!0),this.closedRoot&&!this.reportedTextAfterRoot&&(this.fail(`text data outside of root node.`),this.reportedTextAfterRoot=!0))}pushAttribNS(e,t){var n;let{prefix:r,local:i}=this.qname(e),a={name:e,prefix:r,local:i,value:t};if(this.attribList.push(a),(n=this.attributeHandler)==null||n.call(this,a),r===`xmlns`){let e=t.trim();this.currentXMLVersion===`1.0`&&e===``&&this.fail(`invalid attempt to undefine prefix in XML 1.0`),this.topNS[i]=e,rt(this,i,e)}else if(e===`xmlns`){let e=t.trim();this.topNS[``]=e,rt(this,``,e)}}pushAttribPlain(e,t){var n;let r={name:e,value:t};this.attribList.push(r),(n=this.attributeHandler)==null||n.call(this,r)}end(){var e,t;this.sawRoot||this.fail(`document must contain a root element.`);let{tags:n}=this;for(;n.length>0;){let e=n.pop();this.fail(`unclosed tag: ${e.name}`)}this.state!==ee&&this.state!==C&&this.fail(`unexpected end.`);let{text:r}=this;return r.length!==0&&((e=this.textHandler)==null||e.call(this,r),this.text=``),this._closed=!0,(t=this.endHandler)==null||t.call(this),this._init(),this}resolve(e){var t;let n=this.topNS[e];if(n!==void 0)return n;let{tags:r}=this;for(let t=r.length-1;t>=0;t--)if(n=r[t].ns[e],n!==void 0)return n;return n=this.ns[e],n===void 0?(t=this.opt).resolvePrefix?.call(t,e):n}qname(e){let t=e.indexOf(`:`);if(t===-1)return{prefix:``,local:e};let n=e.slice(t+1),r=e.slice(0,t);return(r===``||n===``||n.includes(`:`))&&this.fail(`malformed name: ${e}.`),{prefix:r,local:n}}processAttribsNS(){let{attribList:e}=this,t=this.tag;{let{prefix:e,local:n}=this.qname(t.name);t.prefix=e,t.local=n;let r=t.uri=this.resolve(e)??``;e!==``&&(e===`xmlns`&&this.fail(`tags may not have "xmlns" as prefix.`),r===``&&(this.fail(`unbound namespace prefix: ${JSON.stringify(e)}.`),t.uri=e))}if(e.length===0)return;let{attributes:n}=t,r=new Set;for(let t of e){let{name:e,prefix:i,local:a}=t,o,s;i===``?(o=e===`xmlns`?h:``,s=e):(o=this.resolve(i),o===void 0&&(this.fail(`unbound namespace prefix: ${JSON.stringify(i)}.`),o=i),s=`{${o}}${a}`),r.has(s)&&this.fail(`duplicate attribute: ${s}.`),r.add(s),t.uri=o,n[e]=t}this.attribList=[]}processAttribsPlain(){let{attribList:e}=this,t=this.tag.attributes;for(let{name:n,value:r}of e)t[n]!==void 0&&this.fail(`duplicate attribute: ${n}.`),t[n]=r;this.attribList=[]}openTag(){var e;this.processAttribs();let{tags:t}=this,n=this.tag;n.isSelfClosing=!1,(e=this.openTagHandler)==null||e.call(this,n),t.push(n),this.state=C,this.name=``}openSelfClosingTag(){var e,t;this.processAttribs();let{tags:n}=this,r=this.tag;r.isSelfClosing=!0,(e=this.openTagHandler)==null||e.call(this,r),(t=this.closeTagHandler)==null||t.call(this,r),(this.tag=n[n.length-1]??null)===null&&(this.closedRoot=!0),this.state=C,this.name=``}closeTag(){let{tags:e,name:t}=this;if(this.state=C,this.name=``,t===``){this.fail(`weird empty close tag.`),this.text+=`</>`;return}let n=this.closeTagHandler,r=e.length;for(;r-->0;){let r=this.tag=e.pop();if(this.topNS=r.ns,n?.(r),r.name===t)break;this.fail(`unexpected close tag.`)}r===0?this.closedRoot=!0:r<0&&(this.fail(`unmatched closing tag: ${t}.`),this.text+=`</${t}>`)}parseEntity(e){if(e[0]!==`#`){let t=this.ENTITIES[e];return t===void 0?(this.fail(this.isName(e)?`undefined entity.`:`disallowed character in entity name.`),`&${e};`):t}let t=NaN;return e[1]===`x`&&/^#x[0-9a-f]+$/i.test(e)?t=parseInt(e.slice(2),16):/^#[0-9]+$/.test(e)&&(t=parseInt(e.slice(1),10)),this.isChar(t)?String.fromCodePoint(t):(this.fail(`malformed character entity.`),`&${e};`)}}}))(),uw=4194304,dw=new Set([`script`,`iframe`,`object`,`embed`,`audio`,`video`]),fw=new Set([`foreignobject`,`div`,`span`,`p`,`br`,`b`,`strong`,`i`,`em`,`small`,`sub`,`sup`,`code`,`ul`,`ol`,`li`,`a`]),pw=/^data:image\/(?:png|jpeg|gif|webp);base64,[a-z0-9+/=\s]+$/i,mw=/^data:(?:font\/(?:woff2?|opentype|truetype)|application\/(?:x-)?font-woff2?);base64,[a-z0-9+/=\s]+$/i,hw=class extends Error{constructor(e){super(e),this.name=`ClientSvgError`}};function gw(e){let t=e.trim();return t.startsWith(`#`)||pw.test(t)||mw.test(t)}function _w(e){if(/@import|expression\s*\(|javascript\s*:|data\s*:\s*text\/html|behavior\s*:|-moz-binding/i.test(e))return!0;let t=/url\s*\(\s*(['"]?)(.*?)\1\s*\)/gi;for(let n of e.matchAll(t))if(!gw(n[2]??``))return!0;return/url\s*\(/i.test(e.replace(t,``))}function vw(e){let t=e.trim();return t.startsWith(`#`)||pw.test(t)}function yw(e,t){let n=e.toLowerCase();return n.startsWith(`on`)?!1:n===`href`||n===`xlink:href`||n===`src`?vw(t):[`style`,`filter`,`fill`,`stroke`,`clip-path`,`mask`].includes(n)?!_w(t):n!==`xml:base`&&!/javascript\s*:/i.test(t)}function bw(e){return e.replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`)}function xw(e){return bw(e).replaceAll(`"`,`"`)}function Sw(e){if(e.type===`text`)return bw(e.value);let t=[...e.attributes].map(([e,t])=>` ${e}="${xw(t)}"`).join(``);return`<${e.name}${t}>${e.children.map(Sw).join(``)}</${e.name}>`}function Cw(e){return e.name.toLowerCase().split(`:`).at(-1)??e.name.toLowerCase()}function ww(e){if(e===void 0||!/^-?\d+(?:\.\d+)?(?:px)?$/.test(e.trim()))return null;let t=Number.parseFloat(e);return Number.isFinite(t)&&t>0?t:null}function Tw(e){let t=e.attributes.get(`viewBox`)?.trim().split(/[\s,]+/).map(Number);if(t?.length===4&&t.every(Number.isFinite)&&t[2]>0&&t[3]>0)return t;let n=ww(e.attributes.get(`width`)),r=ww(e.attributes.get(`height`));return n!==null&&r!==null?[0,0,n,r]:null}function Ew(e,t){let n=e.attributes.get(`style`);if(!n)return null;for(let e of n.split(`;`)){let n=e.indexOf(`:`);if(n>=0&&e.slice(0,n).trim().toLowerCase()===t)return e.slice(n+1).trim()}return null}function Dw(e){let t=(e.attributes.get(`fill`)??Ew(e,`fill`)??``).replaceAll(` `,``).toLowerCase();return t===`white`||t===`#fff`||t===`#ffffff`||t===`rgb(255,255,255)`}function Ow(e){if(e===void 0||!/^-?\d+(?:\.\d+)?$/.test(e.trim()))return null;let t=Number(e);return Number.isFinite(t)?t:null}function kw(e,t){let n=e.attributes.get(`width`)?.trim(),r=e.attributes.get(`height`)?.trim();if(n===`100%`&&r===`100%`)return!0;let i=Ow(e.attributes.get(`x`)??`0`),a=Ow(e.attributes.get(`y`)??`0`),o=Ow(n),s=Ow(r);if([i,a,o,s].some(e=>e===null))return!1;let[c,l,u,d]=t,f=.01;return i<=c+f&&a<=l+f&&i+o>=c+u-f&&a+s>=l+d-f}function Aw(e,t,n){let r=Cw(e),i=new Set((e.attributes.get(`class`)??``).toLowerCase().split(/\s+/));return r===`rect`&&i.has(`backdrop`)||r===`rect`&&t!==null&&Dw(e)&&kw(e,t)?!0:n===`graphviz`&&r===`polygon`&&Dw(e)&&(e.attributes.get(`stroke`)??``).toLowerCase()===`none`}function jw(e,t,n){let r=Cw(e)===`svg`?Tw(e)??t:t;e.children=e.children.filter(e=>e.type===`text`||!Aw(e,r,n)&&(jw(e,r,n),!0))}function Mw(e,t){let n=(e.attributes.get(`style`)??``).split(`;`).map(e=>e.trim()).filter(Boolean).filter(e=>!/^background(?:-color)?\s*:/i.test(e));n.push(`background-color:${t}`),e.attributes.set(`style`,`${n.join(`;`)};`)}function Nw(e,t=[],n=[]){return{type:`element`,name:e,attributes:new Map(t),children:n}}function Pw(e,t,n,r){let i=[],a=null;t.title&&i.push(Nw(`title`,[],[{type:`text`,value:t.title}])),t.description&&i.push(Nw(`desc`,[],[{type:`text`,value:t.description}]));let o=Tw(e);if((n.padding||n.background||n.frame)&&o===null)throw new hw(`Renderer output has no usable SVG dimensions for presentation settings.`);if(o!==null){let[t,r,s,c]=o,l=n.padding,u=[t-l,r-l,s+l*2,c+l*2];e.attributes.set(`viewBox`,u.join(` `)),e.attributes.has(`width`)&&e.attributes.set(`width`,String(u[2])),e.attributes.has(`height`)&&e.attributes.set(`height`,String(u[3])),n.background&&i.push(Nw(`rect`,[[`x`,String(u[0])],[`y`,String(u[1])],[`width`,String(u[2])],[`height`,String(u[3])],[`fill`,n.background]])),n.frame&&(a=Nw(`rect`,[[`x`,String(u[0]+.5)],[`y`,String(u[1]+.5)],[`width`,String(Math.max(0,u[2]-1))],[`height`,String(Math.max(0,u[3]-1))],[`fill`,`none`],[`stroke`,`#000000`],[`stroke-width`,`1`],[`vector-effect`,`non-scaling-stroke`]]))}n.background&&(jw(e,o,r),Mw(e,n.background)),e.children.unshift(...i),a&&e.children.push(a)}function Fw(e,t,n,r){if(e.length>uw)throw new hw(`Rendered SVG is too large.`);let i=null,a=[],o=0,s=null,c=new lw.SaxesParser({xmlns:!0});c.on(`doctype`,e=>{e.includes(`[`)&&(s=Error(`Internal DOCTYPE subsets are not allowed`))}),c.on(`opentag`,e=>{let t=e.local.toLowerCase(),n=t===`foreignobject`||a.some(e=>Cw(e)===`foreignobject`);if(o>0||dw.has(t)||n&&!fw.has(t)){o++;return}let r=Nw(e.name);for(let t of Object.values(e.attributes))yw(t.name,t.value)&&r.attributes.set(t.name,t.value);let c=a.at(-1);c?c.children.push(r):i===null?i=r:s=Error(`Multiple root elements`),a.push(r)});let l=e=>{if(o>0||e===``)return;let t=a.at(-1);if(t){if(Cw(t)===`style`&&_w(e))throw new hw(`Renderer output contains unsafe CSS.`);t.children.push({type:`text`,value:e})}else e.trim()!==``&&(s=Error(`Text outside root element`))};c.on(`text`,l),c.on(`cdata`,l),c.on(`closetag`,()=>{o>0?o--:a.pop()}),c.on(`error`,e=>{s=e});try{c.write(e).close()}catch(e){if(e instanceof hw)throw e;s=e}if(s!==null||i===null||Cw(i)!==`svg`)throw new hw(`Renderer returned invalid SVG.`);return Pw(i,t,n,r),Sw(i)}var Iw=Object.freeze({plantuml:`https://plantuml.render.diagram.zip/v1/svg`,graphviz:`https://graphviz.render.diagram.zip/v1/svg`,d2:`https://d2.render.diagram.zip/v1/svg`,c4plantuml:`https://c4plantuml.render.diagram.zip/v1/svg`,blockdiag:`https://blockdiag.render.diagram.zip/v1/svg`,seqdiag:`https://seqdiag.render.diagram.zip/v1/svg`,actdiag:`https://actdiag.render.diagram.zip/v1/svg`,nwdiag:`https://nwdiag.render.diagram.zip/v1/svg`,packetdiag:`https://packetdiag.render.diagram.zip/v1/svg`,rackdiag:`https://rackdiag.render.diagram.zip/v1/svg`,bytefield:`https://bytefield.render.diagram.zip/v1/svg`,dbml:`https://dbml.render.diagram.zip/v1/svg`,diagramsnet:`https://diagramsnet.render.diagram.zip/v1/svg`,ditaa:`https://ditaa.render.diagram.zip/v1/svg`,erd:`https://erd.render.diagram.zip/v1/svg`,goat:`https://goat.render.diagram.zip/v1/svg`,nomnoml:`https://nomnoml.render.diagram.zip/v1/svg`,pikchr:`https://pikchr.render.diagram.zip/v1/svg`,structurizr:`https://structurizr.render.diagram.zip/v1/svg`,svgbob:`https://svgbob.render.diagram.zip/v1/svg`,symbolator:`https://symbolator.render.diagram.zip/v1/svg`,tikz:`https://tikz.render.diagram.zip/v1/svg`,umlet:`https://umlet.render.diagram.zip/v1/svg`,vega:`https://vega.render.diagram.zip/v1/svg`,vegalite:`https://vegalite.render.diagram.zip/v1/svg`,wavedrom:`https://wavedrom.render.diagram.zip/v1/svg`,wireviz:`https://wireviz.render.diagram.zip/v1/svg`}),Lw=Object.freeze([`mermaid`,`bpmn`,`excalidraw`,`bytefield`,`nomnoml`,`vega`,`vegalite`,`wavedrom`,`blockdiag`,`seqdiag`,`actdiag`,`nwdiag`,`packetdiag`,`rackdiag`,`graphviz`,`erd`,`pikchr`,`wireviz`]);function Rw(e){return Lw.includes(e)}function zw(e){return Iw[e]??null}function Bw(e,t,n){return Math.min(Math.max(e,t),n)}var Vw=class{constructor({stage:e,image:t,status:n,minimap:r,minimapImage:i,minimapViewport:a}){this.stage=e,this.image=t,this.status=n,this.minimap=r,this.minimapImage=i,this.minimapViewport=a,this.scale=1,this.x=0,this.y=0,this.objectUrl=null,this.abortController=null,this.requestNumber=0,this.pendingRender=null,this.renderLoop=null,this.latestRenderKey=null,this.latestSvgBlob=null,this.latestRendererIdentity=null,this.imageFallbackUrl=null,this.activeImageUrl=null,this.drag=null,this.image.addEventListener(`load`,()=>{this.image.src===this.activeImageUrl&&(this.imageFallbackUrl=null,this.setStatus(`Rendered`,`ready`),this.fit())}),this.image.addEventListener(`error`,()=>this.retryBlockedImage()),this.stage.addEventListener(`pointerdown`,e=>this.startPan(e)),this.stage.addEventListener(`pointermove`,e=>this.pan(e)),this.stage.addEventListener(`pointerup`,e=>this.endPan(e)),this.stage.addEventListener(`pointercancel`,e=>this.endPan(e)),this.stage.addEventListener(`wheel`,e=>this.wheelZoom(e),{passive:!1}),this.minimap.addEventListener(`pointerdown`,e=>this.moveFromMinimap(e)),new ResizeObserver(()=>this.updateTransform()).observe(this.stage)}render({type:e,source:t,options:n={},meta:r={},presentation:i={}}){if(!t.trim()){this.requestNumber++,this.pendingRender=null,this.abortController?.abort(),this.setStatus(`Write something to render.`,`idle`);return}let a=JSON.stringify({type:e,source:t,options:n,meta:r,presentation:i});return this.latestRenderKey===a&&this.latestSvgBlob?Promise.resolve():(this.pendingRender={type:e,source:t,options:n,meta:r,presentation:i,renderKey:a,requestNumber:++this.requestNumber},this.abortController?.abort(),this.renderLoop||=this.drainRenderQueue(),this.renderLoop)}async drainRenderQueue(){try{for(;this.pendingRender;){let e=this.pendingRender;this.pendingRender=null,await this.performRender(e)}}finally{this.renderLoop=null,this.pendingRender&&(this.renderLoop=this.drainRenderQueue())}}async performRender({type:e,source:t,options:n,meta:r,presentation:i,renderKey:a,requestNumber:o}){let s=new AbortController;this.abortController=s,this.setStatus(`Rendering…`,`loading`),this.stage.style.setProperty(`--render-background`,`var(--preview-bg)`);try{let c=aw(e),l;if(c)try{let a=await c.render({type:e,source:t,options:n},s.signal);l={body:Fw(a.body,r,i,e),identity:{unit:e,build:a.build||a.version,pipeline:Array.isArray(a.pipeline)?a.pipeline:[e]}},this.status.dataset.cache=`browser`,this.status.dataset.renderer=e}catch(a){if(a.name===`AbortError`||Rw(e))throw a;l=await this.renderThroughGateway({type:e,source:t,options:n,meta:r,presentation:i},s.signal)}else l=await this.renderThroughGateway({type:e,source:t,options:n,meta:r,presentation:i},s.signal);if(o!==this.requestNumber)return;let{blob:u,background:d}=this.normalizedSvgBlob(l.body);this.latestRenderKey=a,this.latestSvgBlob=u,this.latestRendererIdentity=l.identity,this.imageFallbackUrl=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(await u.text())}`,this.stage.style.setProperty(`--render-background`,d);let f=URL.createObjectURL(u),p=this.objectUrl;this.objectUrl=f,this.activeImageUrl=f,this.image.src=f,this.minimapImage.src=f,this.image.hidden=!1,this.setStatus(`Loading image…`,`loading`),p&&URL.revokeObjectURL(p)}catch(e){if(e.name===`AbortError`)return;this.setStatus(e.message||`Could not render this diagram.`,`error`)}finally{this.abortController===s&&(this.abortController=null)}}async renderThroughGateway({type:e,source:t,options:n,meta:r,presentation:i},a){let o=zw(e);if(o){try{let s=await this.renderRequest(o,{source:t,format:`svg`,options:n,metadata:r,presentation:i},a);if(s.ok||s.status<500)return await this.renderResponse(s,e);await s.body?.cancel()}catch(t){if(t.name===`AbortError`||Rw(e))throw t}if(Rw(e))throw Error(`The ${e} renderer unit is unavailable.`)}let s=await this.renderRequest(`/render/v1/svg`,{engine:e,source:t,format:`svg`,options:n,metadata:r,presentation:i},a);return this.renderResponse(s,e)}renderRequest(e,t,n){return fetch(e,{method:`POST`,headers:{Accept:`image/svg+xml`,"Content-Type":`application/json`},body:JSON.stringify(t),signal:n})}async renderResponse(e,t){if(!e.ok)throw Error(await this.errorMessage(e));this.status.dataset.cache=e.headers.get(`X-Diagram-Cache`)?.toLowerCase()??`miss`,this.status.dataset.renderer=e.headers.get(`X-Diagram-Unit`)?.toLowerCase()??e.headers.get(`X-Diagram-Renderer`)?.toLowerCase()??`gateway`;let n=e.headers.get(`X-Diagram-Unit`)?.toLowerCase()??e.headers.get(`X-Diagram-Engine`)?.toLowerCase()??t,r=e.headers.get(`X-Renderer-Build`)??e.headers.get(`X-Diagram-Engine-Version`)??`${n}-unknown`,i=(e.headers.get(`X-Diagram-Pipeline`)??n).split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean);return{body:await e.text(),identity:{unit:n,build:r,pipeline:i}}}retryBlockedImage(){if(this.image.src===this.activeImageUrl){if(this.imageFallbackUrl&&this.activeImageUrl.startsWith(`blob:`)){let e=this.imageFallbackUrl;this.imageFallbackUrl=null,this.objectUrl&&URL.revokeObjectURL(this.objectUrl),this.objectUrl=null,this.activeImageUrl=e,this.image.src=e,this.minimapImage.src=e;return}this.setStatus(`The rendered image was blocked or invalid.`,`error`)}}svgBlobFor(e){let{type:t,source:n,options:r={},meta:i={},presentation:a={}}=e,o=JSON.stringify({type:t,source:n,options:r,meta:i,presentation:a});return this.latestRenderKey===o?this.latestSvgBlob:null}rendererIdentityFor(e){let{type:t,source:n,options:r={},meta:i={},presentation:a={}}=e,o=JSON.stringify({type:t,source:n,options:r,meta:i,presentation:a});return this.latestRenderKey===o?this.latestRendererIdentity:null}async errorMessage(e){let t=await e.text();if(e.headers.get(`Content-Type`)?.includes(`application/json`))try{let e=JSON.parse(t);if(typeof e?.error?.message==`string`)return e.error.message}catch{}return new DOMParser().parseFromString(t,`text/html`).body.textContent.trim().replace(/\s+/g,` `)||`Render failed with HTTP ${e.status}.`}normalizedSvgBlob(e){let t=new DOMParser().parseFromString(e,`image/svg+xml`).documentElement,n=t.getAttribute(`viewBox`)?.trim().split(/[\s,]+/).map(Number);t.nodeName===`svg`&&n?.length===4&&n.every(Number.isFinite)&&(t.hasAttribute(`width`)||t.setAttribute(`width`,String(n[2])),t.hasAttribute(`height`)||t.setAttribute(`height`,String(n[3])),e=new XMLSerializer().serializeToString(t));let r=t.style.backgroundColor||t.style.background,i=r&&r!==`transparent`?r:`#ffffff`;return{blob:new Blob([e],{type:`image/svg+xml`}),background:i}}setStatus(e,t){this.status.textContent=e,this.status.dataset.state=t}zoom(e){if(this.image.hidden)return;let t=this.stage.getBoundingClientRect();this.zoomAt(e,t.width/2,t.height/2)}zoomAt(e,t,n){let r=Bw(this.scale*e,.1,8),i=(t-this.x)/this.scale,a=(n-this.y)/this.scale;this.x=t-i*r,this.y=n-a*r,this.scale=r,this.updateTransform()}wheelZoom(e){if(this.image.hidden||e.target.closest(`.preview-toolbar, .minimap`))return;e.preventDefault();let t=this.stage.getBoundingClientRect(),n=e.deltaY*(e.deltaMode===WheelEvent.DOM_DELTA_LINE?16:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?t.height:1);this.zoomAt(Math.exp(-Bw(n,-240,240)*.002),e.clientX-t.left,e.clientY-t.top)}oneToOne(){if(this.image.hidden)return;let e=this.stage.getBoundingClientRect();this.scale=1,this.x=(e.width-this.image.naturalWidth)/2,this.y=(e.height-this.image.naturalHeight)/2,this.updateTransform()}fit(){if(!this.image.naturalWidth||!this.image.naturalHeight)return;let e=this.stage.getBoundingClientRect(),t=Math.min(64,e.width*.12);this.scale=Bw(Math.min((e.width-t*2)/this.image.naturalWidth,(e.height-t*2)/this.image.naturalHeight),.1,2),this.x=(e.width-this.image.naturalWidth*this.scale)/2,this.y=(e.height-this.image.naturalHeight*this.scale)/2,this.updateTransform()}updateTransform(){this.image.style.transform=`translate(${this.x}px, ${this.y}px) scale(${this.scale})`,this.updateMinimap()}startPan(e){this.image.hidden||e.button!==0||e.target.closest(`.preview-toolbar, .minimap`)||(this.drag={pointerId:e.pointerId,x:e.clientX,y:e.clientY,originX:this.x,originY:this.y},this.stage.setPointerCapture(e.pointerId),this.stage.dataset.dragging=`true`)}pan(e){!this.drag||e.pointerId!==this.drag.pointerId||(this.x=this.drag.originX+e.clientX-this.drag.x,this.y=this.drag.originY+e.clientY-this.drag.y,this.updateTransform())}endPan(e){!this.drag||e.pointerId!==this.drag.pointerId||(this.drag=null,delete this.stage.dataset.dragging)}moveFromMinimap(e){if(!this.image.naturalWidth||!this.image.naturalHeight)return;let t=this.minimap.getBoundingClientRect(),n=Math.min(t.width/this.image.naturalWidth,t.height/this.image.naturalHeight),r=(t.width-this.image.naturalWidth*n)/2,i=(t.height-this.image.naturalHeight*n)/2,a=(e.clientX-t.left-r)/n,o=(e.clientY-t.top-i)/n,s=this.stage.getBoundingClientRect();this.x=s.width/2-a*this.scale,this.y=s.height/2-o*this.scale,this.updateTransform()}updateMinimap(){if(!this.image.naturalWidth||!this.image.naturalHeight)return;let e=this.stage.getBoundingClientRect(),t=this.image.naturalWidth*this.scale,n=this.image.naturalHeight*this.scale,r=this.x>=0&&this.y>=0&&this.x+t<=e.width&&this.y+n<=e.height;if(this.minimap.hidden=r,r)return;let i=this.minimap.getBoundingClientRect(),a=Math.min(i.width/this.image.naturalWidth,i.height/this.image.naturalHeight),o=(i.width-this.image.naturalWidth*a)/2,s=(i.height-this.image.naturalHeight*a)/2,c=Bw(-this.x/this.scale,0,this.image.naturalWidth),l=Bw(-this.y/this.scale,0,this.image.naturalHeight),u=Bw((e.width-this.x)/this.scale,0,this.image.naturalWidth),d=Bw((e.height-this.y)/this.scale,0,this.image.naturalHeight);this.minimapViewport.style.left=`${o+c*a}px`,this.minimapViewport.style.top=`${s+l*a}px`,this.minimapViewport.style.width=`${Math.max(4,(u-c)*a)}px`,this.minimapViewport.style.height=`${Math.max(4,(d-l)*a)}px`}},Hw=`diagram.zip:draft:local:v2`,Uw=`diagram.zip:draft:alias:v1:`,Ww=`diagram.zip:write:v1:`,Gw=new ke,Kw=new kC,qw,Jw=!1,Yw,Xw=!1,Zw=``,Q={aliasId:null,contentId:null,renderId:null,revision:null,mode:`open`,savedMode:null,writeCapability:null,savedState:null,savedSnapshot:null,bundleKey:null,keyEnvelope:null,encryptedContent:null,encryptedMetadata:null,keyEnvelopeDirty:!1,dirty:!0},Qw=new Map;document.querySelector(`#app`).innerHTML=`1647+${h}.`);break;case m:switch(t){case`xml`:break;case``:e.fail(`the default namespace may not be set to ${n}.`);break;default:e.fail(`may not assign the xml namespace to another prefix.`)}}}function it(e,t){for(let n of Object.keys(t))rt(e,n,t[n])}var at=e=>p.test(e),ot=e=>l.test(e),N=0,st=1,ct=2;e.EVENTS=[`xmldecl`,`text`,`processinginstruction`,`doctype`,`comment`,`opentagstart`,`attribute`,`opentag`,`closetag`,`cdata`,`error`,`end`,`ready`];var lt={xmldecl:`xmldeclHandler`,text:`textHandler`,processinginstruction:`piHandler`,doctype:`doctypeHandler`,comment:`commentHandler`,opentagstart:`openTagStartHandler`,attribute:`attributeHandler`,opentag:`openTagHandler`,closetag:`closeTagHandler`,cdata:`cdataHandler`,error:`errorHandler`,end:`endHandler`,ready:`readyHandler`};e.SaxesParser=class{constructor(e){this.opt=e??{},this.fragmentOpt=!!this.opt.fragment;let t=this.xmlnsOpt=!!this.opt.xmlns;if(this.trackPosition=this.opt.position!==!1,this.fileName=this.opt.fileName,t){this.nameStartCheck=d,this.nameCheck=f,this.isName=at,this.processAttribs=this.processAttribsNS,this.pushAttrib=this.pushAttribNS,this.ns=Object.assign({__proto__:null},g);let e=this.opt.additionalNamespaces;e!=null&&(it(this,e),Object.assign(this.ns,e))}else this.nameStartCheck=o,this.nameCheck=s,this.isName=ot,this.processAttribs=this.processAttribsPlain,this.pushAttrib=this.pushAttribPlain;this.stateTable=[this.sBegin,this.sBeginWhitespace,this.sDoctype,this.sDoctypeQuote,this.sDTD,this.sDTDQuoted,this.sDTDOpenWaka,this.sDTDOpenWakaBang,this.sDTDComment,this.sDTDCommentEnding,this.sDTDCommentEnded,this.sDTDPI,this.sDTDPIEnding,this.sText,this.sEntity,this.sOpenWaka,this.sOpenWakaBang,this.sComment,this.sCommentEnding,this.sCommentEnded,this.sCData,this.sCDataEnding,this.sCDataEnding2,this.sPIFirstChar,this.sPIRest,this.sPIBody,this.sPIEnding,this.sXMLDeclNameStart,this.sXMLDeclName,this.sXMLDeclEq,this.sXMLDeclValueStart,this.sXMLDeclValue,this.sXMLDeclSeparator,this.sXMLDeclEnding,this.sOpenTag,this.sOpenTagSlash,this.sAttrib,this.sAttribName,this.sAttribNameSawWhite,this.sAttribValue,this.sAttribValueQuoted,this.sAttribValueClosed,this.sAttribValueUnquoted,this.sCloseTag,this.sCloseTagSawWhite],this._init()}get closed(){return this._closed}_init(){var e;this.openWakaBang=``,this.text=``,this.name=``,this.piTarget=``,this.entity=``,this.q=null,this.tags=[],this.tag=null,this.topNS=null,this.chunk=``,this.chunkPosition=0,this.i=0,this.prevI=0,this.carriedFromPrevious=void 0,this.forbiddenState=N,this.attribList=[];let{fragmentOpt:t}=this;this.state=t?C:ee,this.reportedTextBeforeRoot=this.reportedTextAfterRoot=this.closedRoot=this.sawRoot=t,this.xmlDeclPossible=!t,this.xmlDeclExpects=[`version`],this.entityReturnState=void 0;let{defaultXMLVersion:n}=this.opt;if(n===void 0){if(this.opt.forceXMLVersion===!0)throw Error(`forceXMLVersion set but defaultXMLVersion is not set`);n=`1.0`}this.setXMLVersion(n),this.positionAtNewLine=0,this.doctype=!1,this._closed=!1,this.xmlDecl={version:void 0,encoding:void 0,standalone:void 0},this.line=1,this.column=0,this.ENTITIES=Object.create(_),(e=this.readyHandler)==null||e.call(this)}get position(){return this.chunkPosition+this.i}get columnIndex(){return this.position-this.positionAtNewLine}on(e,t){this[lt[e]]=t}off(e){this[lt[e]]=void 0}makeError(e){let t=this.fileName??``;return this.trackPosition&&(t.length>0&&(t+=`:`),t+=`${this.line}:${this.column}`),t.length>0&&(t+=`: `),Error(t+e)}fail(e){let t=this.makeError(e),n=this.errorHandler;if(n===void 0)throw t;return n(t),this}write(e){if(this.closed)return this.fail(`cannot write after close; assign an onready handler.`);let t=!1;e===null?(t=!0,e=``):typeof e==`object`&&(e=e.toString()),this.carriedFromPrevious!==void 0&&(e=`${this.carriedFromPrevious}${e}`,this.carriedFromPrevious=void 0);let n=e.length,r=e.charCodeAt(n-1);!t&&(r===Be||r>=55296&&r<=56319)&&(this.carriedFromPrevious=e[n-1],n--,e=e.slice(0,n));let{stateTable:i}=this;for(this.chunk=e,this.i=0;this.i<n;)i[this.state].call(this);return this.chunkPosition+=n,t?this.end():this}close(){return this.write(null)}getCode10(){let{chunk:e,i:t}=this;if(this.prevI=t,this.i=t+1,t>=e.length)return v;let n=e.charCodeAt(t);if(this.column++,n<55296){if(n>=Ve||n===Re)return n;switch(n){case ze:return this.line++,this.column=0,this.positionAtNewLine=this.position,ze;case Be:return e.charCodeAt(t+1)===ze&&(this.i=t+2),this.line++,this.column=0,this.positionAtNewLine=this.position,y;default:return this.fail(`disallowed character.`),n}}if(n>56319)return n>=57344&&n<=65533||this.fail(`disallowed character.`),n;let r=65536+(n-55296)*1024+(e.charCodeAt(t+1)-56320);return this.i=t+2,r>1114111&&this.fail(`disallowed character.`),r}getCode11(){let{chunk:e,i:t}=this;if(this.prevI=t,this.i=t+1,t>=e.length)return v;let n=e.charCodeAt(t);if(this.column++,n<55296){if(n>31&&n<127||n>159&&n!==Ze||n===Re)return n;switch(n){case ze:return this.line++,this.column=0,this.positionAtNewLine=this.position,ze;case Be:{let n=e.charCodeAt(t+1);(n===ze||n===j)&&(this.i=t+2)}case j:case Ze:return this.line++,this.column=0,this.positionAtNewLine=this.position,y;default:return this.fail(`disallowed character.`),n}}if(n>56319)return n>=57344&&n<=65533||this.fail(`disallowed character.`),n;let r=65536+(n-55296)*1024+(e.charCodeAt(t+1)-56320);return this.i=t+2,r>1114111&&this.fail(`disallowed character.`),r}getCodeNorm(){let e=this.getCode();return e===y?ze:e}unget(){this.i=this.prevI,this.column--}captureTo(e){let{i:t}=this,{chunk:n}=this;for(;;){let r=this.getCode(),i=r===y,a=i?ze:r;if(a===v||e.includes(a))return this.text+=n.slice(t,this.prevI),a;i&&(this.text+=`${n.slice(t,this.prevI)}\n`,t=this.i)}}captureToChar(e){let{i:t}=this,{chunk:n}=this;for(;;){let r=this.getCode();switch(r){case y:this.text+=`${n.slice(t,this.prevI)}\n`,t=this.i,r=ze;break;case v:return this.text+=n.slice(t),!1}if(r===e)return this.text+=n.slice(t,this.prevI),!0}}captureNameChars(){let{chunk:e,i:t}=this;for(;;){let n=this.getCode();if(n===v)return this.name+=e.slice(t),v;if(!s(n))return this.name+=e.slice(t,this.prevI),n===y?ze:n}}skipSpaces(){for(;;){let e=this.getCodeNorm();if(e===v||!i(e))return e}}setXMLVersion(e){this.currentXMLVersion=e,e===`1.0`?(this.isChar=a,this.getCode=this.getCode10):(this.isChar=u,this.getCode=this.getCode11)}sBegin(){this.chunk.charCodeAt(0)===65279&&(this.i++,this.column++),this.state=te}sBeginWhitespace(){let e=this.i,t=this.skipSpaces();switch(this.prevI!==e&&(this.xmlDeclPossible=!1),t){case qe:if(this.state=ue,this.text.length!==0)throw Error(`no-empty text at start`);break;case v:break;default:this.unget(),this.state=C,this.xmlDeclPossible=!1}}sDoctype(){var e;let t=this.captureTo(et);switch(t){case k:(e=this.doctypeHandler)==null||e.call(this,this.text),this.text=``,this.state=C,this.doctype=!0;break;case v:break;default:this.text+=String.fromCodePoint(t),t===Ye?this.state=b:Qe(t)&&(this.state=re,this.q=t)}}sDoctypeQuote(){let e=this.q;this.captureToChar(e)&&(this.text+=String.fromCodePoint(e),this.q=null,this.state=ne)}sDTD(){let e=this.captureTo(M);e!==v&&(this.text+=String.fromCodePoint(e),e===Xe?this.state=ne:e===qe?this.state=ae:Qe(e)&&(this.state=ie,this.q=e))}sDTDQuoted(){let e=this.q;this.captureToChar(e)&&(this.text+=String.fromCodePoint(e),this.state=b,this.q=null)}sDTDOpenWaka(){let e=this.getCodeNorm();switch(this.text+=String.fromCodePoint(e),e){case He:this.state=x,this.openWakaBang=``;break;case A:this.state=ce;break;default:this.state=b}}sDTDOpenWakaBang(){let e=String.fromCodePoint(this.getCodeNorm()),t=this.openWakaBang+=e;this.text+=e,t!==`-`&&(this.state=t===`--`?oe:b,this.openWakaBang=``)}sDTDComment(){this.captureToChar(O)&&(this.text+=`-`,this.state=S)}sDTDCommentEnding(){let e=this.getCodeNorm();this.text+=String.fromCodePoint(e),this.state=e===O?se:oe}sDTDCommentEnded(){let e=this.getCodeNorm();this.text+=String.fromCodePoint(e),e===k?this.state=b:(this.fail(`malformed comment.`),this.state=oe)}sDTDPI(){this.captureToChar(A)&&(this.text+=`?`,this.state=le)}sDTDPIEnding(){let e=this.getCodeNorm();this.text+=String.fromCodePoint(e),e===k&&(this.state=b)}sText(){this.tags.length===0?this.handleTextOutsideRoot():this.handleTextInRoot()}sEntity(){let{i:e}=this,{chunk:t}=this;loop:for(;;)switch(this.getCode()){case y:this.entity+=`${t.slice(e,this.prevI)}\n`,e=this.i;break;case Ke:{let{entityReturnState:n}=this,r=this.entity+t.slice(e,this.prevI);this.state=n;let i;r===``?(this.fail(`empty entity name.`),i=`&;`):(i=this.parseEntity(r),this.entity=``),(n!==C||this.textHandler!==void 0)&&(this.text+=i);break loop}case v:this.entity+=t.slice(e);break loop}}sOpenWaka(){let e=this.getCode();if(o(e))this.state=De,this.unget(),this.xmlDeclPossible=!1;else switch(e){case Ge:this.state=Ie,this.xmlDeclPossible=!1;break;case He:this.state=de,this.openWakaBang=``,this.xmlDeclPossible=!1;break;case A:this.state=_e;break;default:this.fail(`disallowed character in tag name`),this.state=C,this.xmlDeclPossible=!1}}sOpenWakaBang(){switch(this.openWakaBang+=String.fromCodePoint(this.getCodeNorm()),this.openWakaBang){case`[CDATA[`:!this.sawRoot&&!this.reportedTextBeforeRoot&&(this.fail(`text data outside of root node.`),this.reportedTextBeforeRoot=!0),this.closedRoot&&!this.reportedTextAfterRoot&&(this.fail(`text data outside of root node.`),this.reportedTextAfterRoot=!0),this.state=he,this.openWakaBang=``;break;case`--`:this.state=fe,this.openWakaBang=``;break;case`DOCTYPE`:this.state=ne,(this.doctype||this.sawRoot)&&this.fail(`inappropriately located doctype declaration.`),this.openWakaBang=``;break;default:this.openWakaBang.length>=7&&this.fail(`incorrect syntax.`)}}sComment(){this.captureToChar(O)&&(this.state=pe)}sCommentEnding(){var e;let t=this.getCodeNorm();t===O?(this.state=me,(e=this.commentHandler)==null||e.call(this,this.text),this.text=``):(this.text+=`-${String.fromCodePoint(t)}`,this.state=fe)}sCommentEnded(){let e=this.getCodeNorm();e===k?this.state=C:(this.fail(`malformed comment.`),this.text+=`--${String.fromCodePoint(e)}`,this.state=fe)}sCData(){this.captureToChar(Xe)&&(this.state=T)}sCDataEnding(){let e=this.getCodeNorm();e===Xe?this.state=ge:(this.text+=`]${String.fromCodePoint(e)}`,this.state=he)}sCDataEnding2(){var e;let t=this.getCodeNorm();switch(t){case k:(e=this.cdataHandler)==null||e.call(this,this.text),this.text=``,this.state=C;break;case Xe:this.text+=`]`;break;default:this.text+=`]]${String.fromCodePoint(t)}`,this.state=he}}sPIFirstChar(){let e=this.getCodeNorm();this.nameStartCheck(e)?(this.piTarget+=String.fromCodePoint(e),this.state=E):e===A||i(e)?(this.fail(`processing instruction without a target.`),this.state=e===A?ye:ve):(this.fail(`disallowed character in processing instruction name.`),this.piTarget+=String.fromCodePoint(e),this.state=E)}sPIRest(){let{chunk:e,i:t}=this;for(;;){let n=this.getCodeNorm();if(n===v){this.piTarget+=e.slice(t);return}if(!this.nameCheck(n)){this.piTarget+=e.slice(t,this.prevI);let r=n===A;r||i(n)?this.piTarget===`xml`?(this.xmlDeclPossible||this.fail(`an XML declaration must be at the start of the document.`),this.state=r?Ee:be):this.state=r?ye:ve:(this.fail(`disallowed character in processing instruction name.`),this.piTarget+=String.fromCodePoint(n));break}}}sPIBody(){if(this.text.length===0){let e=this.getCodeNorm();e===A?this.state=ye:i(e)||(this.text=String.fromCodePoint(e))}else this.captureToChar(A)&&(this.state=ye)}sPIEnding(){var e;let t=this.getCodeNorm();if(t===k){let{piTarget:t}=this;t.toLowerCase()===`xml`&&this.fail(`the XML declaration must appear at the start of the document.`),(e=this.piHandler)==null||e.call(this,{target:t,body:this.text}),this.piTarget=this.text=``,this.state=C}else t===A?this.text+=`?`:(this.text+=`?${String.fromCodePoint(t)}`,this.state=ve);this.xmlDeclPossible=!1}sXMLDeclNameStart(){let e=this.skipSpaces();if(e===A){this.state=Ee;return}e!==v&&(this.state=xe,this.name=String.fromCodePoint(e))}sXMLDeclName(){let e=this.captureTo(tt);if(e===A){this.state=Ee,this.name+=this.text,this.text=``,this.fail(`XML declaration is incomplete.`);return}if(i(e)||e===Je){if(this.name+=this.text,this.text=``,!this.xmlDeclExpects.includes(this.name))switch(this.name.length){case 0:this.fail(`did not expect any more name/value pairs.`);break;case 1:this.fail(`expected the name ${this.xmlDeclExpects[0]}.`);break;default:this.fail(`expected one of ${this.xmlDeclExpects.join(`, `)}`)}this.state=e===Je?Ce:Se}}sXMLDeclEq(){let e=this.getCodeNorm();if(e===A){this.state=Ee,this.fail(`XML declaration is incomplete.`);return}i(e)||(e!==Je&&this.fail(`value required.`),this.state=Ce)}sXMLDeclValueStart(){let e=this.getCodeNorm();if(e===A){this.state=Ee,this.fail(`XML declaration is incomplete.`);return}i(e)||(Qe(e)?this.q=e:(this.fail(`value must be quoted.`),this.q=Ve),this.state=we)}sXMLDeclValue(){let e=this.captureTo([this.q,A]);if(e===A){this.state=Ee,this.text=``,this.fail(`XML declaration is incomplete.`);return}if(e===v)return;let t=this.text;switch(this.text=``,this.name){case`version`:{this.xmlDeclExpects=[`encoding`,`standalone`];let e=t;this.xmlDecl.version=e,/^1\.[0-9]+$/.test(e)?this.opt.forceXMLVersion||this.setXMLVersion(e):this.fail(`version number must match /^1\\.[0-9]+$/.`);break}case`encoding`:/^[A-Za-z][A-Za-z0-9._-]*$/.test(t)||this.fail(`encoding value must match /^[A-Za-z0-9][A-Za-z0-9._-]*$/.`),this.xmlDeclExpects=[`standalone`],this.xmlDecl.encoding=t;break;case`standalone`:t!==`yes`&&t!==`no`&&this.fail(`standalone value must match "yes" or "no".`),this.xmlDeclExpects=[],this.xmlDecl.standalone=t}this.name=``,this.state=Te}sXMLDeclSeparator(){let e=this.getCodeNorm();if(e===A){this.state=Ee;return}i(e)||(this.fail(`whitespace required.`),this.unget()),this.state=be}sXMLDeclEnding(){var e;this.getCodeNorm()===k?(this.piTarget===`xml`?this.name!==`version`&&this.xmlDeclExpects.includes(`version`)&&this.fail(`XML declaration must contain a version.`):this.fail(`processing instructions are not allowed before root.`),(e=this.xmldeclHandler)==null||e.call(this,this.xmlDecl),this.name=``,this.piTarget=this.text=``,this.state=C):this.fail(`The character ? is disallowed anywhere in XML declarations.`),this.xmlDeclPossible=!1}sOpenTag(){var e;let t=this.captureNameChars();if(t===v)return;let n=this.tag={name:this.name,attributes:Object.create(null)};switch(this.name=``,this.xmlnsOpt&&(this.topNS=n.ns=Object.create(null)),(e=this.openTagStartHandler)==null||e.call(this,n),this.sawRoot=!0,!this.fragmentOpt&&this.closedRoot&&this.fail(`documents may contain only one root.`),t){case k:this.openTag();break;case Ge:this.state=Oe;break;default:i(t)||this.fail(`disallowed character in tag name.`),this.state=ke}}sOpenTagSlash(){this.getCode()===k?this.openSelfClosingTag():(this.fail(`forward-slash in opening tag not followed by >.`),this.state=ke)}sAttrib(){let e=this.skipSpaces();e!==v&&(o(e)?(this.unget(),this.state=Ae):e===k?this.openTag():e===Ge?this.state=Oe:this.fail(`disallowed character in attribute name.`))}sAttribName(){let e=this.captureNameChars();e===Je?this.state=Me:i(e)?this.state=je:e===k?(this.fail(`attribute without value.`),this.pushAttrib(this.name,this.name),this.name=this.text=``,this.openTag()):e!==v&&this.fail(`disallowed character in attribute name.`)}sAttribNameSawWhite(){let e=this.skipSpaces();switch(e){case v:return;case Je:this.state=Me;break;default:this.fail(`attribute without value.`),this.text=``,this.name=``,e===k?this.openTag():o(e)?(this.unget(),this.state=Ae):(this.fail(`disallowed character in attribute name.`),this.state=ke)}}sAttribValue(){let e=this.getCodeNorm();Qe(e)?(this.q=e,this.state=Ne):i(e)||(this.fail(`unquoted attribute value.`),this.state=Fe,this.unget())}sAttribValueQuoted(){let{q:e,chunk:t}=this,{i:n}=this;for(;;)switch(this.getCode()){case e:this.pushAttrib(this.name,this.text+t.slice(n,this.prevI)),this.name=this.text=``,this.q=null,this.state=Pe;return;case We:this.text+=t.slice(n,this.prevI),this.state=w,this.entityReturnState=Ne;return;case ze:case y:case Re:this.text+=`${t.slice(n,this.prevI)} `,n=this.i;break;case qe:this.text+=t.slice(n,this.prevI),this.fail(`disallowed character.`);return;case v:this.text+=t.slice(n);return}}sAttribValueClosed(){let e=this.getCodeNorm();i(e)?this.state=ke:e===k?this.openTag():e===Ge?this.state=Oe:o(e)?(this.fail(`no whitespace between attributes.`),this.unget(),this.state=Ae):this.fail(`disallowed character in attribute name.`)}sAttribValueUnquoted(){let e=this.captureTo(nt);switch(e){case We:this.state=w,this.entityReturnState=Fe;break;case qe:this.fail(`disallowed character.`);break;case v:break;default:this.text.includes(`]]>`)&&this.fail(`the string "]]>" is disallowed in char data.`),this.pushAttrib(this.name,this.text),this.name=this.text=``,e===k?this.openTag():this.state=ke}}sCloseTag(){let e=this.captureNameChars();e===k?this.closeTag():i(e)?this.state=Le:e!==v&&this.fail(`disallowed character in closing tag.`)}sCloseTagSawWhite(){switch(this.skipSpaces()){case k:this.closeTag();break;case v:break;default:this.fail(`disallowed character in closing tag.`)}}handleTextInRoot(){let{i:e,forbiddenState:t}=this,{chunk:n,textHandler:r}=this;scanLoop:for(;;)switch(this.getCode()){case qe:if(this.state=ue,r!==void 0){let{text:t}=this,i=n.slice(e,this.prevI);t.length===0?i.length!==0&&r(i):(r(t+i),this.text=``)}t=N;break scanLoop;case We:this.state=w,this.entityReturnState=C,r!==void 0&&(this.text+=n.slice(e,this.prevI)),t=N;break scanLoop;case Xe:switch(t){case N:t=st;break;case st:t=ct;break;case ct:break;default:throw Error(`impossible state`)}break;case k:t===ct&&this.fail(`the string "]]>" is disallowed in char data.`),t=N;break;case y:r!==void 0&&(this.text+=`${n.slice(e,this.prevI)}\n`),e=this.i,t=N;break;case v:r!==void 0&&(this.text+=n.slice(e));break scanLoop;default:t=N}this.forbiddenState=t}handleTextOutsideRoot(){let{i:e}=this,{chunk:t,textHandler:n}=this,r=!1;outRootLoop:for(;;){let a=this.getCode();switch(a){case qe:if(this.state=ue,n!==void 0){let{text:r}=this,i=t.slice(e,this.prevI);r.length===0?i.length!==0&&n(i):(n(r+i),this.text=``)}break outRootLoop;case We:this.state=w,this.entityReturnState=C,n!==void 0&&(this.text+=t.slice(e,this.prevI)),r=!0;break outRootLoop;case y:n!==void 0&&(this.text+=`${t.slice(e,this.prevI)}\n`),e=this.i;break;case v:n!==void 0&&(this.text+=t.slice(e));break outRootLoop;default:i(a)||(r=!0)}}r&&(!this.sawRoot&&!this.reportedTextBeforeRoot&&(this.fail(`text data outside of root node.`),this.reportedTextBeforeRoot=!0),this.closedRoot&&!this.reportedTextAfterRoot&&(this.fail(`text data outside of root node.`),this.reportedTextAfterRoot=!0))}pushAttribNS(e,t){var n;let{prefix:r,local:i}=this.qname(e),a={name:e,prefix:r,local:i,value:t};if(this.attribList.push(a),(n=this.attributeHandler)==null||n.call(this,a),r===`xmlns`){let e=t.trim();this.currentXMLVersion===`1.0`&&e===``&&this.fail(`invalid attempt to undefine prefix in XML 1.0`),this.topNS[i]=e,rt(this,i,e)}else if(e===`xmlns`){let e=t.trim();this.topNS[``]=e,rt(this,``,e)}}pushAttribPlain(e,t){var n;let r={name:e,value:t};this.attribList.push(r),(n=this.attributeHandler)==null||n.call(this,r)}end(){var e,t;this.sawRoot||this.fail(`document must contain a root element.`);let{tags:n}=this;for(;n.length>0;){let e=n.pop();this.fail(`unclosed tag: ${e.name}`)}this.state!==ee&&this.state!==C&&this.fail(`unexpected end.`);let{text:r}=this;return r.length!==0&&((e=this.textHandler)==null||e.call(this,r),this.text=``),this._closed=!0,(t=this.endHandler)==null||t.call(this),this._init(),this}resolve(e){var t;let n=this.topNS[e];if(n!==void 0)return n;let{tags:r}=this;for(let t=r.length-1;t>=0;t--)if(n=r[t].ns[e],n!==void 0)return n;return n=this.ns[e],n===void 0?(t=this.opt).resolvePrefix?.call(t,e):n}qname(e){let t=e.indexOf(`:`);if(t===-1)return{prefix:``,local:e};let n=e.slice(t+1),r=e.slice(0,t);return(r===``||n===``||n.includes(`:`))&&this.fail(`malformed name: ${e}.`),{prefix:r,local:n}}processAttribsNS(){let{attribList:e}=this,t=this.tag;{let{prefix:e,local:n}=this.qname(t.name);t.prefix=e,t.local=n;let r=t.uri=this.resolve(e)??``;e!==``&&(e===`xmlns`&&this.fail(`tags may not have "xmlns" as prefix.`),r===``&&(this.fail(`unbound namespace prefix: ${JSON.stringify(e)}.`),t.uri=e))}if(e.length===0)return;let{attributes:n}=t,r=new Set;for(let t of e){let{name:e,prefix:i,local:a}=t,o,s;i===``?(o=e===`xmlns`?h:``,s=e):(o=this.resolve(i),o===void 0&&(this.fail(`unbound namespace prefix: ${JSON.stringify(i)}.`),o=i),s=`{${o}}${a}`),r.has(s)&&this.fail(`duplicate attribute: ${s}.`),r.add(s),t.uri=o,n[e]=t}this.attribList=[]}processAttribsPlain(){let{attribList:e}=this,t=this.tag.attributes;for(let{name:n,value:r}of e)t[n]!==void 0&&this.fail(`duplicate attribute: ${n}.`),t[n]=r;this.attribList=[]}openTag(){var e;this.processAttribs();let{tags:t}=this,n=this.tag;n.isSelfClosing=!1,(e=this.openTagHandler)==null||e.call(this,n),t.push(n),this.state=C,this.name=``}openSelfClosingTag(){var e,t;this.processAttribs();let{tags:n}=this,r=this.tag;r.isSelfClosing=!0,(e=this.openTagHandler)==null||e.call(this,r),(t=this.closeTagHandler)==null||t.call(this,r),(this.tag=n[n.length-1]??null)===null&&(this.closedRoot=!0),this.state=C,this.name=``}closeTag(){let{tags:e,name:t}=this;if(this.state=C,this.name=``,t===``){this.fail(`weird empty close tag.`),this.text+=`</>`;return}let n=this.closeTagHandler,r=e.length;for(;r-->0;){let r=this.tag=e.pop();if(this.topNS=r.ns,n?.(r),r.name===t)break;this.fail(`unexpected close tag.`)}r===0?this.closedRoot=!0:r<0&&(this.fail(`unmatched closing tag: ${t}.`),this.text+=`</${t}>`)}parseEntity(e){if(e[0]!==`#`){let t=this.ENTITIES[e];return t===void 0?(this.fail(this.isName(e)?`undefined entity.`:`disallowed character in entity name.`),`&${e};`):t}let t=NaN;return e[1]===`x`&&/^#x[0-9a-f]+$/i.test(e)?t=parseInt(e.slice(2),16):/^#[0-9]+$/.test(e)&&(t=parseInt(e.slice(1),10)),this.isChar(t)?String.fromCodePoint(t):(this.fail(`malformed character entity.`),`&${e};`)}}}))(),uw=4194304,dw=new Set([`script`,`iframe`,`object`,`embed`,`audio`,`video`]),fw=new Set([`foreignobject`,`div`,`span`,`p`,`br`,`b`,`strong`,`i`,`em`,`small`,`sub`,`sup`,`code`,`ul`,`ol`,`li`,`a`]),pw=/^data:image\/(?:png|jpeg|gif|webp);base64,[a-z0-9+/=\s]+$/i,mw=/^data:(?:font\/(?:woff2?|opentype|truetype)|application\/(?:x-)?font-woff2?);base64,[a-z0-9+/=\s]+$/i,hw=class extends Error{constructor(e){super(e),this.name=`ClientSvgError`}};function gw(e){let t=e.trim();return t.startsWith(`#`)||pw.test(t)||mw.test(t)}function _w(e){if(/@import|expression\s*\(|javascript\s*:|data\s*:\s*text\/html|behavior\s*:|-moz-binding/i.test(e))return!0;let t=/url\s*\(\s*(['"]?)(.*?)\1\s*\)/gi;for(let n of e.matchAll(t))if(!gw(n[2]??``))return!0;return/url\s*\(/i.test(e.replace(t,``))}function vw(e){let t=e.trim();return t.startsWith(`#`)||pw.test(t)}function yw(e,t){let n=e.toLowerCase();return n.startsWith(`on`)?!1:n===`href`||n===`xlink:href`||n===`src`?vw(t):[`style`,`filter`,`fill`,`stroke`,`clip-path`,`mask`].includes(n)?!_w(t):n!==`xml:base`&&!/javascript\s*:/i.test(t)}function bw(e){return e.replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`)}function xw(e){return bw(e).replaceAll(`"`,`"`)}function Sw(e){if(e.type===`text`)return bw(e.value);let t=[...e.attributes].map(([e,t])=>` ${e}="${xw(t)}"`).join(``);return`<${e.name}${t}>${e.children.map(Sw).join(``)}</${e.name}>`}function Cw(e){return e.name.toLowerCase().split(`:`).at(-1)??e.name.toLowerCase()}function ww(e){if(e===void 0||!/^-?\d+(?:\.\d+)?(?:px)?$/.test(e.trim()))return null;let t=Number.parseFloat(e);return Number.isFinite(t)&&t>0?t:null}function Tw(e){let t=e.attributes.get(`viewBox`)?.trim().split(/[\s,]+/).map(Number);if(t?.length===4&&t.every(Number.isFinite)&&t[2]>0&&t[3]>0)return t;let n=ww(e.attributes.get(`width`)),r=ww(e.attributes.get(`height`));return n!==null&&r!==null?[0,0,n,r]:null}function Ew(e,t){let n=e.attributes.get(`style`);if(!n)return null;for(let e of n.split(`;`)){let n=e.indexOf(`:`);if(n>=0&&e.slice(0,n).trim().toLowerCase()===t)return e.slice(n+1).trim()}return null}function Dw(e){let t=(e.attributes.get(`fill`)??Ew(e,`fill`)??``).replaceAll(` `,``).toLowerCase();return t===`white`||t===`#fff`||t===`#ffffff`||t===`rgb(255,255,255)`}function Ow(e){if(e===void 0||!/^-?\d+(?:\.\d+)?$/.test(e.trim()))return null;let t=Number(e);return Number.isFinite(t)?t:null}function kw(e,t){let n=e.attributes.get(`width`)?.trim(),r=e.attributes.get(`height`)?.trim();if(n===`100%`&&r===`100%`)return!0;let i=Ow(e.attributes.get(`x`)??`0`),a=Ow(e.attributes.get(`y`)??`0`),o=Ow(n),s=Ow(r);if([i,a,o,s].some(e=>e===null))return!1;let[c,l,u,d]=t,f=.01;return i<=c+f&&a<=l+f&&i+o>=c+u-f&&a+s>=l+d-f}function Aw(e,t,n){let r=Cw(e),i=new Set((e.attributes.get(`class`)??``).toLowerCase().split(/\s+/));return r===`rect`&&i.has(`backdrop`)||r===`rect`&&t!==null&&Dw(e)&&kw(e,t)?!0:n===`graphviz`&&r===`polygon`&&Dw(e)&&(e.attributes.get(`stroke`)??``).toLowerCase()===`none`}function jw(e,t,n){let r=Cw(e)===`svg`?Tw(e)??t:t;e.children=e.children.filter(e=>e.type===`text`||!Aw(e,r,n)&&(jw(e,r,n),!0))}function Mw(e,t){let n=(e.attributes.get(`style`)??``).split(`;`).map(e=>e.trim()).filter(Boolean).filter(e=>!/^background(?:-color)?\s*:/i.test(e));n.push(`background-color:${t}`),e.attributes.set(`style`,`${n.join(`;`)};`)}function Nw(e,t=[],n=[]){return{type:`element`,name:e,attributes:new Map(t),children:n}}function Pw(e,t,n,r){let i=[],a=null;t.title&&i.push(Nw(`title`,[],[{type:`text`,value:t.title}])),t.description&&i.push(Nw(`desc`,[],[{type:`text`,value:t.description}]));let o=Tw(e);if((n.padding||n.background||n.frame)&&o===null)throw new hw(`Renderer output has no usable SVG dimensions for presentation settings.`);if(o!==null){let[t,r,s,c]=o,l=n.padding,u=[t-l,r-l,s+l*2,c+l*2];e.attributes.set(`viewBox`,u.join(` `)),e.attributes.has(`width`)&&e.attributes.set(`width`,String(u[2])),e.attributes.has(`height`)&&e.attributes.set(`height`,String(u[3])),n.background&&i.push(Nw(`rect`,[[`x`,String(u[0])],[`y`,String(u[1])],[`width`,String(u[2])],[`height`,String(u[3])],[`fill`,n.background]])),n.frame&&(a=Nw(`rect`,[[`x`,String(u[0]+.5)],[`y`,String(u[1]+.5)],[`width`,String(Math.max(0,u[2]-1))],[`height`,String(Math.max(0,u[3]-1))],[`fill`,`none`],[`stroke`,`#000000`],[`stroke-width`,`1`],[`vector-effect`,`non-scaling-stroke`]]))}n.background&&(jw(e,o,r),Mw(e,n.background)),e.children.unshift(...i),a&&e.children.push(a)}function Fw(e,t,n,r){if(e.length>uw)throw new hw(`Rendered SVG is too large.`);let i=null,a=[],o=0,s=null,c=new lw.SaxesParser({xmlns:!0});c.on(`doctype`,e=>{e.includes(`[`)&&(s=Error(`Internal DOCTYPE subsets are not allowed`))}),c.on(`opentag`,e=>{let t=e.local.toLowerCase(),n=t===`foreignobject`||a.some(e=>Cw(e)===`foreignobject`);if(o>0||dw.has(t)||n&&!fw.has(t)){o++;return}let r=Nw(e.name);for(let t of Object.values(e.attributes))yw(t.name,t.value)&&r.attributes.set(t.name,t.value);let c=a.at(-1);c?c.children.push(r):i===null?i=r:s=Error(`Multiple root elements`),a.push(r)});let l=e=>{if(o>0||e===``)return;let t=a.at(-1);if(t){if(Cw(t)===`style`&&_w(e))throw new hw(`Renderer output contains unsafe CSS.`);t.children.push({type:`text`,value:e})}else e.trim()!==``&&(s=Error(`Text outside root element`))};c.on(`text`,l),c.on(`cdata`,l),c.on(`closetag`,()=>{o>0?o--:a.pop()}),c.on(`error`,e=>{s=e});try{c.write(e).close()}catch(e){if(e instanceof hw)throw e;s=e}if(s!==null||i===null||Cw(i)!==`svg`)throw new hw(`Renderer returned invalid SVG.`);return Pw(i,t,n,r),Sw(i)}var Iw=Object.freeze({plantuml:`https://plantuml.render.diagram.zip/v1/svg`,graphviz:`https://graphviz.render.diagram.zip/v1/svg`,d2:`https://d2.render.diagram.zip/v1/svg`,c4plantuml:`https://c4plantuml.render.diagram.zip/v1/svg`,blockdiag:`https://blockdiag.render.diagram.zip/v1/svg`,seqdiag:`https://seqdiag.render.diagram.zip/v1/svg`,actdiag:`https://actdiag.render.diagram.zip/v1/svg`,nwdiag:`https://nwdiag.render.diagram.zip/v1/svg`,packetdiag:`https://packetdiag.render.diagram.zip/v1/svg`,rackdiag:`https://rackdiag.render.diagram.zip/v1/svg`,bytefield:`https://bytefield.render.diagram.zip/v1/svg`,dbml:`https://dbml.render.diagram.zip/v1/svg`,diagramsnet:`https://diagramsnet.render.diagram.zip/v1/svg`,ditaa:`https://ditaa.render.diagram.zip/v1/svg`,erd:`https://erd.render.diagram.zip/v1/svg`,goat:`https://goat.render.diagram.zip/v1/svg`,nomnoml:`https://nomnoml.render.diagram.zip/v1/svg`,pikchr:`https://pikchr.render.diagram.zip/v1/svg`,structurizr:`https://structurizr.render.diagram.zip/v1/svg`,svgbob:`https://svgbob.render.diagram.zip/v1/svg`,symbolator:`https://symbolator.render.diagram.zip/v1/svg`,tikz:`https://tikz.render.diagram.zip/v1/svg`,umlet:`https://umlet.render.diagram.zip/v1/svg`,vega:`https://vega.render.diagram.zip/v1/svg`,vegalite:`https://vegalite.render.diagram.zip/v1/svg`,wavedrom:`https://wavedrom.render.diagram.zip/v1/svg`,wireviz:`https://wireviz.render.diagram.zip/v1/svg`}),Lw=Object.freeze([`mermaid`,`bpmn`,`excalidraw`,`bytefield`,`nomnoml`,`vega`,`vegalite`,`wavedrom`,`blockdiag`,`seqdiag`,`actdiag`,`nwdiag`,`packetdiag`,`rackdiag`,`graphviz`,`erd`,`pikchr`,`svgbob`,`wireviz`]);function Rw(e){return Lw.includes(e)}function zw(e){return Iw[e]??null}function Bw(e,t,n){return Math.min(Math.max(e,t),n)}var Vw=class{constructor({stage:e,image:t,status:n,minimap:r,minimapImage:i,minimapViewport:a}){this.stage=e,this.image=t,this.status=n,this.minimap=r,this.minimapImage=i,this.minimapViewport=a,this.scale=1,this.x=0,this.y=0,this.objectUrl=null,this.abortController=null,this.requestNumber=0,this.pendingRender=null,this.renderLoop=null,this.latestRenderKey=null,this.latestSvgBlob=null,this.latestRendererIdentity=null,this.imageFallbackUrl=null,this.activeImageUrl=null,this.drag=null,this.image.addEventListener(`load`,()=>{this.image.src===this.activeImageUrl&&(this.imageFallbackUrl=null,this.setStatus(`Rendered`,`ready`),this.fit())}),this.image.addEventListener(`error`,()=>this.retryBlockedImage()),this.stage.addEventListener(`pointerdown`,e=>this.startPan(e)),this.stage.addEventListener(`pointermove`,e=>this.pan(e)),this.stage.addEventListener(`pointerup`,e=>this.endPan(e)),this.stage.addEventListener(`pointercancel`,e=>this.endPan(e)),this.stage.addEventListener(`wheel`,e=>this.wheelZoom(e),{passive:!1}),this.minimap.addEventListener(`pointerdown`,e=>this.moveFromMinimap(e)),new ResizeObserver(()=>this.updateTransform()).observe(this.stage)}render({type:e,source:t,options:n={},meta:r={},presentation:i={}}){if(!t.trim()){this.requestNumber++,this.pendingRender=null,this.abortController?.abort(),this.setStatus(`Write something to render.`,`idle`);return}let a=JSON.stringify({type:e,source:t,options:n,meta:r,presentation:i});return this.latestRenderKey===a&&this.latestSvgBlob?Promise.resolve():(this.pendingRender={type:e,source:t,options:n,meta:r,presentation:i,renderKey:a,requestNumber:++this.requestNumber},this.abortController?.abort(),this.renderLoop||=this.drainRenderQueue(),this.renderLoop)}async drainRenderQueue(){try{for(;this.pendingRender;){let e=this.pendingRender;this.pendingRender=null,await this.performRender(e)}}finally{this.renderLoop=null,this.pendingRender&&(this.renderLoop=this.drainRenderQueue())}}async performRender({type:e,source:t,options:n,meta:r,presentation:i,renderKey:a,requestNumber:o}){let s=new AbortController;this.abortController=s,this.setStatus(`Rendering…`,`loading`),this.stage.style.setProperty(`--render-background`,`var(--preview-bg)`);try{let c=aw(e),l;if(c)try{let a=await c.render({type:e,source:t,options:n},s.signal);l={body:Fw(a.body,r,i,e),identity:{unit:e,build:a.build||a.version,pipeline:Array.isArray(a.pipeline)?a.pipeline:[e]}},this.status.dataset.cache=`browser`,this.status.dataset.renderer=e}catch(a){if(a.name===`AbortError`||Rw(e))throw a;l=await this.renderThroughGateway({type:e,source:t,options:n,meta:r,presentation:i},s.signal)}else l=await this.renderThroughGateway({type:e,source:t,options:n,meta:r,presentation:i},s.signal);if(o!==this.requestNumber)return;let{blob:u,background:d}=this.normalizedSvgBlob(l.body);this.latestRenderKey=a,this.latestSvgBlob=u,this.latestRendererIdentity=l.identity,this.imageFallbackUrl=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(await u.text())}`,this.stage.style.setProperty(`--render-background`,d);let f=URL.createObjectURL(u),p=this.objectUrl;this.objectUrl=f,this.activeImageUrl=f,this.image.src=f,this.minimapImage.src=f,this.image.hidden=!1,this.setStatus(`Loading image…`,`loading`),p&&URL.revokeObjectURL(p)}catch(e){if(e.name===`AbortError`)return;this.setStatus(e.message||`Could not render this diagram.`,`error`)}finally{this.abortController===s&&(this.abortController=null)}}async renderThroughGateway({type:e,source:t,options:n,meta:r,presentation:i},a){let o=zw(e);if(o){try{let s=await this.renderRequest(o,{source:t,format:`svg`,options:n,metadata:r,presentation:i},a);if(s.ok||s.status<500)return await this.renderResponse(s,e);await s.body?.cancel()}catch(t){if(t.name===`AbortError`||Rw(e))throw t}if(Rw(e))throw Error(`The ${e} renderer unit is unavailable.`)}let s=await this.renderRequest(`/render/v1/svg`,{engine:e,source:t,format:`svg`,options:n,metadata:r,presentation:i},a);return this.renderResponse(s,e)}renderRequest(e,t,n){return fetch(e,{method:`POST`,headers:{Accept:`image/svg+xml`,"Content-Type":`application/json`},body:JSON.stringify(t),signal:n})}async renderResponse(e,t){if(!e.ok)throw Error(await this.errorMessage(e));this.status.dataset.cache=e.headers.get(`X-Diagram-Cache`)?.toLowerCase()??`miss`,this.status.dataset.renderer=e.headers.get(`X-Diagram-Unit`)?.toLowerCase()??e.headers.get(`X-Diagram-Renderer`)?.toLowerCase()??`gateway`;let n=e.headers.get(`X-Diagram-Unit`)?.toLowerCase()??e.headers.get(`X-Diagram-Engine`)?.toLowerCase()??t,r=e.headers.get(`X-Renderer-Build`)??e.headers.get(`X-Diagram-Engine-Version`)??`${n}-unknown`,i=(e.headers.get(`X-Diagram-Pipeline`)??n).split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean);return{body:await e.text(),identity:{unit:n,build:r,pipeline:i}}}retryBlockedImage(){if(this.image.src===this.activeImageUrl){if(this.imageFallbackUrl&&this.activeImageUrl.startsWith(`blob:`)){let e=this.imageFallbackUrl;this.imageFallbackUrl=null,this.objectUrl&&URL.revokeObjectURL(this.objectUrl),this.objectUrl=null,this.activeImageUrl=e,this.image.src=e,this.minimapImage.src=e;return}this.setStatus(`The rendered image was blocked or invalid.`,`error`)}}svgBlobFor(e){let{type:t,source:n,options:r={},meta:i={},presentation:a={}}=e,o=JSON.stringify({type:t,source:n,options:r,meta:i,presentation:a});return this.latestRenderKey===o?this.latestSvgBlob:null}rendererIdentityFor(e){let{type:t,source:n,options:r={},meta:i={},presentation:a={}}=e,o=JSON.stringify({type:t,source:n,options:r,meta:i,presentation:a});return this.latestRenderKey===o?this.latestRendererIdentity:null}async errorMessage(e){let t=await e.text();if(e.headers.get(`Content-Type`)?.includes(`application/json`))try{let e=JSON.parse(t);if(typeof e?.error?.message==`string`)return e.error.message}catch{}return new DOMParser().parseFromString(t,`text/html`).body.textContent.trim().replace(/\s+/g,` `)||`Render failed with HTTP ${e.status}.`}normalizedSvgBlob(e){let t=new DOMParser().parseFromString(e,`image/svg+xml`).documentElement,n=t.getAttribute(`viewBox`)?.trim().split(/[\s,]+/).map(Number);t.nodeName===`svg`&&n?.length===4&&n.every(Number.isFinite)&&(t.hasAttribute(`width`)||t.setAttribute(`width`,String(n[2])),t.hasAttribute(`height`)||t.setAttribute(`height`,String(n[3])),e=new XMLSerializer().serializeToString(t));let r=t.style.backgroundColor||t.style.background,i=r&&r!==`transparent`?r:`#ffffff`;return{blob:new Blob([e],{type:`image/svg+xml`}),background:i}}setStatus(e,t){this.status.textContent=e,this.status.dataset.state=t}zoom(e){if(this.image.hidden)return;let t=this.stage.getBoundingClientRect();this.zoomAt(e,t.width/2,t.height/2)}zoomAt(e,t,n){let r=Bw(this.scale*e,.1,8),i=(t-this.x)/this.scale,a=(n-this.y)/this.scale;this.x=t-i*r,this.y=n-a*r,this.scale=r,this.updateTransform()}wheelZoom(e){if(this.image.hidden||e.target.closest(`.preview-toolbar, .minimap`))return;e.preventDefault();let t=this.stage.getBoundingClientRect(),n=e.deltaY*(e.deltaMode===WheelEvent.DOM_DELTA_LINE?16:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?t.height:1);this.zoomAt(Math.exp(-Bw(n,-240,240)*.002),e.clientX-t.left,e.clientY-t.top)}oneToOne(){if(this.image.hidden)return;let e=this.stage.getBoundingClientRect();this.scale=1,this.x=(e.width-this.image.naturalWidth)/2,this.y=(e.height-this.image.naturalHeight)/2,this.updateTransform()}fit(){if(!this.image.naturalWidth||!this.image.naturalHeight)return;let e=this.stage.getBoundingClientRect(),t=Math.min(64,e.width*.12);this.scale=Bw(Math.min((e.width-t*2)/this.image.naturalWidth,(e.height-t*2)/this.image.naturalHeight),.1,2),this.x=(e.width-this.image.naturalWidth*this.scale)/2,this.y=(e.height-this.image.naturalHeight*this.scale)/2,this.updateTransform()}updateTransform(){this.image.style.transform=`translate(${this.x}px, ${this.y}px) scale(${this.scale})`,this.updateMinimap()}startPan(e){this.image.hidden||e.button!==0||e.target.closest(`.preview-toolbar, .minimap`)||(this.drag={pointerId:e.pointerId,x:e.clientX,y:e.clientY,originX:this.x,originY:this.y},this.stage.setPointerCapture(e.pointerId),this.stage.dataset.dragging=`true`)}pan(e){!this.drag||e.pointerId!==this.drag.pointerId||(this.x=this.drag.originX+e.clientX-this.drag.x,this.y=this.drag.originY+e.clientY-this.drag.y,this.updateTransform())}endPan(e){!this.drag||e.pointerId!==this.drag.pointerId||(this.drag=null,delete this.stage.dataset.dragging)}moveFromMinimap(e){if(!this.image.naturalWidth||!this.image.naturalHeight)return;let t=this.minimap.getBoundingClientRect(),n=Math.min(t.width/this.image.naturalWidth,t.height/this.image.naturalHeight),r=(t.width-this.image.naturalWidth*n)/2,i=(t.height-this.image.naturalHeight*n)/2,a=(e.clientX-t.left-r)/n,o=(e.clientY-t.top-i)/n,s=this.stage.getBoundingClientRect();this.x=s.width/2-a*this.scale,this.y=s.height/2-o*this.scale,this.updateTransform()}updateMinimap(){if(!this.image.naturalWidth||!this.image.naturalHeight)return;let e=this.stage.getBoundingClientRect(),t=this.image.naturalWidth*this.scale,n=this.image.naturalHeight*this.scale,r=this.x>=0&&this.y>=0&&this.x+t<=e.width&&this.y+n<=e.height;if(this.minimap.hidden=r,r)return;let i=this.minimap.getBoundingClientRect(),a=Math.min(i.width/this.image.naturalWidth,i.height/this.image.naturalHeight),o=(i.width-this.image.naturalWidth*a)/2,s=(i.height-this.image.naturalHeight*a)/2,c=Bw(-this.x/this.scale,0,this.image.naturalWidth),l=Bw(-this.y/this.scale,0,this.image.naturalHeight),u=Bw((e.width-this.x)/this.scale,0,this.image.naturalWidth),d=Bw((e.height-this.y)/this.scale,0,this.image.naturalHeight);this.minimapViewport.style.left=`${o+c*a}px`,this.minimapViewport.style.top=`${s+l*a}px`,this.minimapViewport.style.width=`${Math.max(4,(u-c)*a)}px`,this.minimapViewport.style.height=`${Math.max(4,(d-l)*a)}px`}},Hw=`diagram.zip:draft:local:v2`,Uw=`diagram.zip:draft:alias:v1:`,Ww=`diagram.zip:write:v1:`,Gw=new ke,Kw=new kC,qw,Jw=!1,Yw,Xw=!1,Zw=``,Q={aliasId:null,contentId:null,renderId:null,revision:null,mode:`open`,savedMode:null,writeCapability:null,savedState:null,savedSnapshot:null,bundleKey:null,keyEnvelope:null,encryptedContent:null,encryptedMetadata:null,keyEnvelopeDirty:!1,dirty:!0},Qw=new Map;document.querySelector(`#app`).innerHTML=`16481648 <main class="app-shell">16491649 <header class="app-header">16501650 <a class="brand" href="/" aria-label="New diagram"><img class="brand-mark" src="/diagram.zip/icon.svg" alt=""><span>diagram.zip</span></a>@@ -7,7 +7,7 @@
77 <meta name="description" content="Create diagrams from text and share them as a link.">88 <link rel="icon" href="/diagram.zip/icon.svg" type="image/svg+xml">99 <title>diagram.zip</title>10- <script type="module" crossorigin src="/diagram.zip/assets/index-584g8mpQ.js"></script>10+ <script type="module" crossorigin src="/diagram.zip/assets/index-DUEQ6AMT.js"></script>1111 <link rel="stylesheet" crossorigin href="/diagram.zip/assets/index-D7UQlw3g.css">1212 </head>1313 <body>