spell-ui 0.8.15 → 0.8.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README-components.md +4 -2
- package/README-runtime.md +26 -1
- package/README.md +2 -1
- package/dist/SliderScale-DunjyaDW.js +67 -0
- package/dist/SliderScale-DunjyaDW.js.map +1 -0
- package/dist/{ThemeDraft-CyX3YA_L.js → ThemeDraft-spaNC2dD.js} +2 -2
- package/dist/{ThemeDraft-CyX3YA_L.js.map → ThemeDraft-spaNC2dD.js.map} +1 -1
- package/dist/{UIInput-B3K0w4ow.js → UIInput-8s1aiaw1.js} +2 -2
- package/dist/UIInput-8s1aiaw1.js.map +1 -0
- package/dist/{UIRuntime-DCv4sy30.js → UIRuntime-BaokNnwk.js} +900 -158
- package/dist/UIRuntime-BaokNnwk.js.map +1 -0
- package/dist/_spell-element/UIComponent.d.ts +7 -0
- package/dist/_spell-element/elements.types.d.ts +6 -0
- package/dist/_spell-element/vocabulary.types.d.ts +27 -0
- package/dist/_util/dom.d.ts +7 -0
- package/dist/components/components.es.d.ts +1 -0
- package/dist/components/ui-dial/DialArc.d.ts +43 -0
- package/dist/components/ui-dial/UIDial.d.ts +263 -0
- package/dist/components/ui-dial/UIDial.en.d.ts +149 -0
- package/dist/components/ui-dial/UIDial.es.d.ts +25 -0
- package/dist/components/ui-dial/UIDial.fallback.d.ts +167 -0
- package/dist/components/ui-dial/UIDial.types.d.ts +11 -0
- package/dist/components/ui-dial/index.d.ts +3 -0
- package/dist/components/ui-graph/UIGraph.d.ts +17 -0
- package/dist/components/ui-graph/UIGraph.en.d.ts +17 -0
- package/dist/components/ui-graph/UIGraph.es.d.ts +6 -0
- package/dist/components/ui-input/UIInput.d.ts +46 -3
- package/dist/components/ui-input/UIInput.en.d.ts +6 -1
- package/dist/components/ui-input/UIInput.es.d.ts +1 -0
- package/dist/components/ui-input/UIInput.fallback.d.ts +6 -1
- package/dist/components/ui-json/UIJson.d.ts +5 -4
- package/dist/components/ui-modal/ChoiceRows.d.ts +61 -0
- package/dist/components/ui-modal/ModalDialogs.d.ts +15 -1
- package/dist/components/ui-modal/UIModal.d.ts +6 -2
- package/dist/components/ui-modal/UIModal.en.d.ts +6 -2
- package/dist/components/ui-modal/UIModal.es.d.ts +1 -0
- package/dist/components/ui-page-layout/UIPageLayout.d.ts +141 -8
- package/dist/components/ui-page-layout/UIPageLayout.en.d.ts +51 -2
- package/dist/components/ui-page-layout/UIPageLayout.es.d.ts +3 -0
- package/dist/components/ui-property-editor/UIProperty.d.ts +2 -2
- package/dist/components/ui-site-links/UISiteLinks.d.ts +124 -0
- package/dist/components/ui-site-links/UISiteLinks.en.d.ts +60 -0
- package/dist/components/ui-site-links/UISiteLinks.es.d.ts +26 -0
- package/dist/components/ui-site-links/index.d.ts +1 -0
- package/dist/components/ui-site-nav-button/UISiteNavButton.d.ts +12 -5
- package/dist/components/ui-site-nav-button/UISiteNavButton.en.d.ts +32 -12
- package/dist/components/ui-site-nav-button/UISiteNavButton.es.d.ts +3 -0
- package/dist/components/ui-site-tabs/UISiteTabs.d.ts +13 -0
- package/dist/components/ui-site-tabs/UISiteTabs.en.d.ts +9 -0
- package/dist/components/ui-slider/SliderScale.d.ts +26 -2
- package/dist/components/ui-slider/UISlider.d.ts +0 -2
- package/dist/components/ui-statistic/UIStatistic.d.ts +1 -0
- package/dist/components/ui-statistic/UIStatistic.en.d.ts +1 -0
- package/dist/components/ui-toc/TocIndex.d.ts +16 -1
- package/dist/components/ui-toc/UIToc.d.ts +27 -3
- package/dist/components/ui-toc/UIToc.en.d.ts +1 -1
- package/dist/components/ui-toc/UIToc.types.d.ts +5 -0
- package/dist/components/ui-tree/UITree.d.ts +38 -2
- package/dist/components/ui-tree/UITree.en.d.ts +9 -0
- package/dist/components/ui-tree/UITree.es.d.ts +4 -0
- package/dist/components/ui-uploader/UIUploader.d.ts +721 -0
- package/dist/components/ui-uploader/UIUploader.en.d.ts +394 -0
- package/dist/components/ui-uploader/UIUploader.es.d.ts +112 -0
- package/dist/components/ui-uploader/index.d.ts +1 -0
- package/dist/{components.es-DilRG1VO.js → components.es-jY2nBwuP.js} +249 -65
- package/dist/components.es-jY2nBwuP.js.map +1 -0
- package/dist/core.js +605 -571
- package/dist/core.js.map +1 -1
- package/dist/docs-components/docs-components.types.d.ts +2 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +101 -97
- package/dist/jsx.d.ts +1138 -21
- package/dist/runtime/DataTooltips.d.ts +10 -0
- package/dist/runtime/Modals.d.ts +7 -2
- package/dist/runtime/Styles.d.ts +7 -1
- package/dist/runtime/UIRuntime.d.ts +6 -0
- package/dist/runtime/runtime.types.d.ts +26 -1
- package/dist/sound-library/back.ogg +0 -0
- package/dist/sound-library/beep.ogg +0 -0
- package/dist/sound-library/bell.ogg +0 -0
- package/dist/sound-library/big-punch.ogg +0 -0
- package/dist/sound-library/bong.ogg +0 -0
- package/dist/sound-library/book-close.ogg +0 -0
- package/dist/sound-library/book-down.ogg +0 -0
- package/dist/sound-library/book-open.ogg +0 -0
- package/dist/sound-library/card-fan-2.ogg +0 -0
- package/dist/sound-library/card-fan.ogg +0 -0
- package/dist/sound-library/card-place-2.ogg +0 -0
- package/dist/sound-library/card-place-3.ogg +0 -0
- package/dist/sound-library/card-place.ogg +0 -0
- package/dist/sound-library/card-shove-2.ogg +0 -0
- package/dist/sound-library/card-shove.ogg +0 -0
- package/dist/sound-library/card-slide-2.ogg +0 -0
- package/dist/sound-library/card-slide-3.ogg +0 -0
- package/dist/sound-library/card-slide-4.ogg +0 -0
- package/dist/sound-library/card-slide.ogg +0 -0
- package/dist/sound-library/chip-down-2.ogg +0 -0
- package/dist/sound-library/chip-down.ogg +0 -0
- package/dist/sound-library/chips-collide.ogg +0 -0
- package/dist/sound-library/chips-handle.ogg +0 -0
- package/dist/sound-library/chips-stack-2.ogg +0 -0
- package/dist/sound-library/chips-stack.ogg +0 -0
- package/dist/sound-library/chop.ogg +0 -0
- package/dist/sound-library/click-2.ogg +0 -0
- package/dist/sound-library/click-3.ogg +0 -0
- package/dist/sound-library/click.ogg +0 -0
- package/dist/sound-library/close.ogg +0 -0
- package/dist/sound-library/cloth.ogg +0 -0
- package/dist/sound-library/coins-2.ogg +0 -0
- package/dist/sound-library/coins.ogg +0 -0
- package/dist/sound-library/confirm-2.ogg +0 -0
- package/dist/sound-library/confirm.ogg +0 -0
- package/dist/sound-library/creak.ogg +0 -0
- package/dist/sound-library/deck-open.ogg +0 -0
- package/dist/sound-library/deck-take-out.ogg +0 -0
- package/dist/sound-library/dice-grab.ogg +0 -0
- package/dist/sound-library/dice-shake-2.ogg +0 -0
- package/dist/sound-library/dice-shake.ogg +0 -0
- package/dist/sound-library/dice-throw-2.ogg +0 -0
- package/dist/sound-library/dice-throw.ogg +0 -0
- package/dist/sound-library/die-throw-2.ogg +0 -0
- package/dist/sound-library/die-throw.ogg +0 -0
- package/dist/sound-library/door-close.ogg +0 -0
- package/dist/sound-library/door-open.ogg +0 -0
- package/dist/sound-library/drop.ogg +0 -0
- package/dist/sound-library/error-2.ogg +0 -0
- package/dist/sound-library/error.ogg +0 -0
- package/dist/sound-library/fail.ogg +0 -0
- package/dist/sound-library/fall.ogg +0 -0
- package/dist/sound-library/glass-break.ogg +0 -0
- package/dist/sound-library/glass-clink.ogg +0 -0
- package/dist/sound-library/glass-tap.ogg +0 -0
- package/dist/sound-library/glass.ogg +0 -0
- package/dist/sound-library/glitch.ogg +0 -0
- package/dist/sound-library/grow.ogg +0 -0
- package/dist/sound-library/high-up.ogg +0 -0
- package/dist/sound-library/hover-2.ogg +0 -0
- package/dist/sound-library/hover.ogg +0 -0
- package/dist/sound-library/jingle-2.ogg +0 -0
- package/dist/sound-library/jingle-3.ogg +0 -0
- package/dist/sound-library/jingle-4.ogg +0 -0
- package/dist/sound-library/jingle.ogg +0 -0
- package/dist/sound-library/jump.ogg +0 -0
- package/dist/sound-library/knife-draw.ogg +0 -0
- package/dist/sound-library/knife-slice.ogg +0 -0
- package/dist/sound-library/laser-2.ogg +0 -0
- package/dist/sound-library/laser.ogg +0 -0
- package/dist/sound-library/latch.ogg +0 -0
- package/dist/sound-library/level-up.ogg +0 -0
- package/dist/sound-library/lose-2.ogg +0 -0
- package/dist/sound-library/lose-3.ogg +0 -0
- package/dist/sound-library/lose-4.ogg +0 -0
- package/dist/sound-library/lose.ogg +0 -0
- package/dist/sound-library/low-down.ogg +0 -0
- package/dist/sound-library/metal-clang.ogg +0 -0
- package/dist/sound-library/metal-click.ogg +0 -0
- package/dist/sound-library/metal-crash.ogg +0 -0
- package/dist/sound-library/metal-tap.ogg +0 -0
- package/dist/sound-library/mouse-click.ogg +0 -0
- package/dist/sound-library/mouse-release.ogg +0 -0
- package/dist/sound-library/open.ogg +0 -0
- package/dist/sound-library/orchestra-hit-2.ogg +0 -0
- package/dist/sound-library/orchestra-hit.ogg +0 -0
- package/dist/sound-library/page-turn-2.ogg +0 -0
- package/dist/sound-library/page-turn.ogg +0 -0
- package/dist/sound-library/pickaxe.ogg +0 -0
- package/dist/sound-library/piece-down-2.ogg +0 -0
- package/dist/sound-library/piece-down-3.ogg +0 -0
- package/dist/sound-library/piece-down.ogg +0 -0
- package/dist/sound-library/piece-take-2.ogg +0 -0
- package/dist/sound-library/piece-take.ogg +0 -0
- package/dist/sound-library/piece-tap-2.ogg +0 -0
- package/dist/sound-library/piece-tap.ogg +0 -0
- package/dist/sound-library/plank.ogg +0 -0
- package/dist/sound-library/plate.ogg +0 -0
- package/dist/sound-library/pluck.ogg +0 -0
- package/dist/sound-library/pot.ogg +0 -0
- package/dist/sound-library/power-up-2.ogg +0 -0
- package/dist/sound-library/power-up-3.ogg +0 -0
- package/dist/sound-library/power-up.ogg +0 -0
- package/dist/sound-library/punch.ogg +0 -0
- package/dist/sound-library/question.ogg +0 -0
- package/dist/sound-library/rise.ogg +0 -0
- package/dist/sound-library/scratch.ogg +0 -0
- package/dist/sound-library/scroll.ogg +0 -0
- package/dist/sound-library/select-2.ogg +0 -0
- package/dist/sound-library/select.ogg +0 -0
- package/dist/sound-library/shrink.ogg +0 -0
- package/dist/sound-library/shuffle.ogg +0 -0
- package/dist/sound-library/soft-thud-2.ogg +0 -0
- package/dist/sound-library/soft-thud.ogg +0 -0
- package/dist/sound-library/space-junk.ogg +0 -0
- package/dist/sound-library/step-2.ogg +0 -0
- package/dist/sound-library/step-on-carpet.ogg +0 -0
- package/dist/sound-library/step-on-grass.ogg +0 -0
- package/dist/sound-library/step-on-snow.ogg +0 -0
- package/dist/sound-library/step-on-stone.ogg +0 -0
- package/dist/sound-library/step-on-wood.ogg +0 -0
- package/dist/sound-library/step.ogg +0 -0
- package/dist/sound-library/switch-2.ogg +0 -0
- package/dist/sound-library/switch.ogg +0 -0
- package/dist/sound-library/tap-2.ogg +0 -0
- package/dist/sound-library/tap.ogg +0 -0
- package/dist/sound-library/three-tones.ogg +0 -0
- package/dist/sound-library/tick-2.ogg +0 -0
- package/dist/sound-library/tick.ogg +0 -0
- package/dist/sound-library/tin.ogg +0 -0
- package/dist/sound-library/toggle-2.ogg +0 -0
- package/dist/sound-library/toggle.ogg +0 -0
- package/dist/sound-library/two-tones.ogg +0 -0
- package/dist/sound-library/win-2.ogg +0 -0
- package/dist/sound-library/win-3.ogg +0 -0
- package/dist/sound-library/win-4.ogg +0 -0
- package/dist/sound-library/win.ogg +0 -0
- package/dist/sound-library/wood-thud.ogg +0 -0
- package/dist/sound-library/zap.ogg +0 -0
- package/dist/sounds/BuiltInSounds.d.ts +41 -0
- package/dist/sounds/index.d.ts +9 -0
- package/dist/sounds/sounds.types.d.ts +22 -0
- package/dist/ui-calendar.js +1 -1
- package/dist/ui-dial.editor-CjjdKi5L.js +5 -0
- package/dist/ui-dial.editor-CjjdKi5L.js.map +1 -0
- package/dist/ui-dial.js +467 -0
- package/dist/ui-dial.js.map +1 -0
- package/dist/ui-graph.js +22 -0
- package/dist/ui-graph.js.map +1 -1
- package/dist/{ui-input.editor-budoNoB0.js → ui-input.editor-D11iRgXR.js} +2 -2
- package/dist/ui-input.editor-D11iRgXR.js.map +1 -0
- package/dist/ui-input.js +84 -54
- package/dist/ui-input.js.map +1 -1
- package/dist/ui-json.js +8 -8
- package/dist/ui-json.js.map +1 -1
- package/dist/ui-modal.js +183 -97
- package/dist/ui-modal.js.map +1 -1
- package/dist/ui-page-layout.editor-IgDEveUY.js +5 -0
- package/dist/ui-page-layout.editor-IgDEveUY.js.map +1 -0
- package/dist/ui-page-layout.js +217 -72
- package/dist/ui-page-layout.js.map +1 -1
- package/dist/ui-popup.js +34 -34
- package/dist/ui-popup.js.map +1 -1
- package/dist/ui-property-editor.js +7 -4
- package/dist/ui-property-editor.js.map +1 -1
- package/dist/ui-root.js +71 -5
- package/dist/ui-root.js.map +1 -1
- package/dist/ui-search.js +1 -1
- package/dist/ui-section.js +97 -96
- package/dist/ui-section.js.map +1 -1
- package/dist/ui-site-links.editor-BME3sw5H.js +5 -0
- package/dist/ui-site-links.editor-BME3sw5H.js.map +1 -0
- package/dist/ui-site-links.js +150 -0
- package/dist/ui-site-links.js.map +1 -0
- package/dist/ui-site-nav-button.editor-ChY4xe1U.js +5 -0
- package/dist/ui-site-nav-button.editor-ChY4xe1U.js.map +1 -0
- package/dist/ui-site-nav-button.js +57 -18
- package/dist/ui-site-nav-button.js.map +1 -1
- package/dist/{ui-site-tabs.editor-DDvQfH6S.js → ui-site-tabs.editor-CdMIw4jw.js} +2 -2
- package/dist/ui-site-tabs.editor-CdMIw4jw.js.map +1 -0
- package/dist/ui-site-tabs.js +30 -14
- package/dist/ui-site-tabs.js.map +1 -1
- package/dist/ui-slider.js +75 -124
- package/dist/ui-slider.js.map +1 -1
- package/dist/ui-statistic.js +1 -0
- package/dist/ui-statistic.js.map +1 -1
- package/dist/ui-theme-editor.js +2 -2
- package/dist/{ui-theme-menu-BZYUMrHe.js → ui-theme-menu-BEBu6dyq.js} +3 -3
- package/dist/{ui-theme-menu-BZYUMrHe.js.map → ui-theme-menu-BEBu6dyq.js.map} +1 -1
- package/dist/ui-toc.js +159 -122
- package/dist/ui-toc.js.map +1 -1
- package/dist/ui-tree.js +142 -87
- package/dist/ui-tree.js.map +1 -1
- package/dist/ui-uploader.editor-DrE80KjL.js +5 -0
- package/dist/ui-uploader.editor-DrE80KjL.js.map +1 -0
- package/dist/ui-uploader.js +1442 -0
- package/dist/ui-uploader.js.map +1 -0
- package/dist/vocabulary/hooks.generated.d.ts +7 -0
- package/package.json +1 -1
- package/dist/UIInput-B3K0w4ow.js.map +0 -1
- package/dist/UIRuntime-DCv4sy30.js.map +0 -1
- package/dist/components.es-DilRG1VO.js.map +0 -1
- package/dist/ui-input.editor-budoNoB0.js.map +0 -1
- package/dist/ui-page-layout.editor-xtQW0FZk.js +0 -5
- package/dist/ui-page-layout.editor-xtQW0FZk.js.map +0 -1
- package/dist/ui-site-nav-button.editor-6J-zJLtZ.js +0 -5
- package/dist/ui-site-nav-button.editor-6J-zJLtZ.js.map +0 -1
- package/dist/ui-site-tabs.editor-DDvQfH6S.js.map +0 -1
package/dist/ui-graph.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui-graph.js","names":["this","x={isOpen ? x + GRAPH_METRICS.paddingX : x + width / 2 - (placed.hasChildren ? GRAPH_METRICS.toggleWidth / 2 : 0)}","y={isOpen ? y + GRAPH_METRICS.headerHeight / 2 : y + height / 2}","font-size={String(fontSize)}","<Show when={this.trail().length > 1}>{this.breadcrumbs()}</Show>","<div class={this.rootClass} part={this.partForName(\"graph\")}>\n <Show when={this.trail().length > 1}>{this.breadcrumbs()}</Show>\n <div class={TOOLBAR_CLASS} part={this.partForName(\"toolbar\")}>\n {this.toolButtons()}\n <button type=\"button\" onClick={() => this.fit()}>\n {this.translationForKey(\"graphFit\")}\n </button>\n </div>\n {this.overlay()}\n <svg\n ref={(svg) => this.svg = svg}\n class={CANVAS_CLASS}\n part={this.partForName(\"canvas\")}\n role=\"group\"\n aria-label={this.translationForKey(\"graphSummary\", { count: this.layout?.nodes.length ?? 0 })}\n onWheel={this.onWheel}\n onPointerDown={this.onPointerDown}\n onClick={this.onBackgroundClick}\n >\n <g transform={`translate(${this.view.x} ${this.view.y}) scale(${this.view.k})`}>\n <For each={this.containers}>{(placed) => this.node(placed)}</For>\n <For each={this.layout?.edges ?? []}>{(edge) => this.edge(edge)}</For>\n <For each={this.leaves}>{(placed) => this.node(placed)}</For>\n <For each={this.layout?.pins ?? []}>{(pin) => this.pin(pin)}</For>\n </g>\n </svg>\n <ui-modal\n ref={(element) => this.modalElement = element}\n size=\"large\"\n closable=\"\"\n heading={this.modalHeading()}\n visible={this.modalPath !== void 0 ? \"\" : void 0}\n >\n <div ref={(div) => this.modalBody = div} class={MODAL_BODY_CLASS} />\n </ui-modal>\n </div>","<div class={TOOLBAR_CLASS} part={this.partForName(\"toolbar\")}>\n {this.toolButtons()}\n <button type=\"button\" onClick={() => this.fit()}>\n {this.translationForKey(\"graphFit\")}\n </button>\n </div>","ref={(svg) => this.svg = svg}","<For each={this.containers}>{(placed) => this.node(placed)}</For>","<g transform={`translate(${this.view.x} ${this.view.y}) scale(${this.view.k})`}>\n <For each={this.containers}>{(placed) => this.node(placed)}</For>\n <For each={this.layout?.edges ?? []}>{(edge) => this.edge(edge)}</For>\n <For each={this.leaves}>{(placed) => this.node(placed)}</For>\n <For each={this.layout?.pins ?? []}>{(pin) => this.pin(pin)}</For>\n </g>","<For each={this.layout?.edges ?? []}>{(edge) => this.edge(edge)}</For>","<For each={this.leaves}>{(placed) => this.node(placed)}</For>","<For each={this.layout?.pins ?? []}>{(pin) => this.pin(pin)}</For>","ref={(element) => this.modalElement = element}","ref={(div) => this.modalBody = div}","part={this.partForName(\"graph\")}","class={TOOLBAR_CLASS}","part={this.partForName(\"toolbar\")}","class={CANVAS_CLASS}","part={this.partForName(\"canvas\")}","aria-label={this.translationForKey(\"graphSummary\", { count: this.layout?.nodes.length ?? 0 })}","transform={`translate(${this.view.x} ${this.view.y}) scale(${this.view.k})`}","heading={this.modalHeading()}","visible={this.modalPath !== void 0 ? \"\" : void 0}","class={MODAL_BODY_CLASS}","<For each={this.trail()}>\n {(crumb, index) => <ui-breadcrumb\n selected={index() === this.trail().length - 1 ? \"\" : void 0}\n onClick={() => {\n if (index() !== this.trail().length - 1) crumb.pick();\n }}\n >\n {crumb.label}\n </ui-breadcrumb>}\n </For>","part={this.partForName(\"breadcrumbs\")}","<ui-breadcrumbs class={BREADCRUMBS_CLASS} part={this.partForName(\"breadcrumbs\")} divider=\"›\">\n <For each={this.trail()}>\n {(crumb, index) => <ui-breadcrumb\n selected={index() === this.trail().length - 1 ? \"\" : void 0}\n onClick={() => {\n if (index() !== this.trail().length - 1) crumb.pick();\n }}\n >\n {crumb.label}\n </ui-breadcrumb>}\n </For>\n </ui-breadcrumbs>","<Show when={placed.node.title}>{(title) => <title>{title()}</title>}</Show>","<g\n class={[\n NODE_CLASS,\n kind && `kind-${kind}`,\n this.nodeClass(placed.node),\n {\n [CONTAINER_CLASS]: placed.isOpen,\n [LIT_CLASS]: this.lit.has(path),\n [SELECTED_CLASS]: this.selectedPath === path,\n [LOADING_CLASS]: !!placed.isLoading\n }\n ]}\n part={[this.partForName(\"node\"), placed.isOpen && this.partForName(\"container\"), kind && `kind-${kind}`].filter(Boolean).join(\" \")}\n data-path={path}\n onClick={(event) => this.choose({ kind: \"node\", id: placed.node.id, path }, placed.node, event)}\n onDblClick={(event) => {\n event.stopPropagation();\n this.nodeDoubleClicked(placed, event);\n }}\n onPointerEnter={() => this.hovered = { kind: \"node\", path }}\n onPointerLeave={() => this.unhover(path)}\n >\n <Show when={placed.node.title}>{(title) => <title>{title()}</title>}</Show>\n {this.renderNode(placed)}\n <For each={placed.ports}>{(port) => this.port(port, placed)}</For>\n <Show when={placed.hasChildren}>{this.toggleButton(placed)}</Show>\n </g>","<For each={placed.ports}>{(port) => this.port(port, placed)}</For>","<Show when={placed.hasChildren}>{this.toggleButton(placed)}</Show>","part={[this.partForName(\"node\"), placed.isOpen && this.partForName(\"container\"), kind && `kind-${kind}`].filter(Boolean).join(\" \")}","part={this.partForName(\"toggle\")}","aria-expanded={placed.isOpen ? \"true\" : \"false\"}","aria-label={label()}","class={TOGGLE_TARGET_CLASS}","class={TOGGLE_CIRCLE_CLASS}","class={TOGGLE_MARK_CLASS}","d={placed.isOpen ? MINUS_MARK : PLUS_MARK}","<g\n class={TOGGLE_CLASS}\n part={this.partForName(\"toggle\")}\n role=\"button\"\n tabindex=\"0\"\n aria-expanded={placed.isOpen ? \"true\" : \"false\"}\n aria-label={label()}\n transform={`translate(${cx} ${cy})`}\n onClick={(event) => this.toggle(placed, event)}\n onDblClick={(event) => event.stopPropagation()}\n onKeyDown={(event) => {\n if (event.key !== UIT.Key.enter && event.key !== UIT.Key.space) return;\n event.preventDefault();\n this.toggle(placed, event);\n }}\n >\n <title>{label()}</title>\n <circle class={TOGGLE_TARGET_CLASS} r={10} />\n <circle class={TOGGLE_CIRCLE_CLASS} r={6} />\n <path class={TOGGLE_MARK_CLASS} d={placed.isOpen ? MINUS_MARK : PLUS_MARK} />\n </g>","<Show when={label && !(owner.isOpen && (placed.side === \"left\" || placed.side === \"right\"))}>\n <text\n class={PORT_LABEL_CLASS}\n x={labelAt.x}\n y={labelAt.y}\n text-anchor={labelAt.anchor}\n font-size={String(GRAPH_METRICS.portFontSize)}\n >\n {label}\n </text>\n </Show>","x={labelAt.x}","y={labelAt.y}","text-anchor={labelAt.anchor}","font-size={String(GRAPH_METRICS.portFontSize)}","<text\n class={PORT_LABEL_CLASS}\n x={labelAt.x}\n y={labelAt.y}\n text-anchor={labelAt.anchor}\n font-size={String(GRAPH_METRICS.portFontSize)}\n >\n {label}\n </text>","part={[this.partForName(\"port\"), kind && `kind-${kind}`].filter(Boolean).join(\" \")}","class={PORT_DOT_CLASS}","cx={placed.x}","cy={placed.y}","<g\n class={[\n PORT_CLASS,\n kind && `kind-${kind}`,\n this.portClass(placed.port, owner.node),\n { [LIT_CLASS]: this.lit.has(placed.path), [SELECTED_CLASS]: this.selectedPath === placed.path }\n ]}\n part={[this.partForName(\"port\"), kind && `kind-${kind}`].filter(Boolean).join(\" \")}\n onClick={(event) => this.choose({ kind: \"port\", id: placed.port.id, path: placed.path }, placed.port, event)}\n onPointerEnter={(event) => {\n event.stopPropagation();\n this.hovered = { kind: \"port\", path: placed.path };\n }}\n onPointerLeave={() => this.hovered = { kind: \"node\", path: owner.path }}\n >\n <circle class={PORT_DOT_CLASS} cx={placed.x} cy={placed.y} r={r} />\n <Show when={label && !(owner.isOpen && (placed.side === \"left\" || placed.side === \"right\"))}>\n <text\n class={PORT_LABEL_CLASS}\n x={labelAt.x}\n y={labelAt.y}\n text-anchor={labelAt.anchor}\n font-size={String(GRAPH_METRICS.portFontSize)}\n >\n {label}\n </text>\n </Show>\n </g>","part={this.partForName(\"pin\")}","class={PIN_MARK_CLASS}","d={`M${pin.x - 5} ${pin.y - 5}h10v10h-10z`}","class={PORT_LABEL_CLASS}","x={pin.x}","y={pin.y - 10}","<g\n class={[PIN_CLASS, { [LIT_CLASS]: this.lit.has(pin.path) }]}\n part={this.partForName(\"pin\")}\n onPointerEnter={() => this.hovered = { kind: \"port\", path: pin.path }}\n onPointerLeave={() => this.unhover(pin.path)}\n onClick={(event) => this.choose({ kind: \"port\", id: pin.port.id, path: pin.path }, pin.port, event)}\n >\n <path class={PIN_MARK_CLASS} d={`M${pin.x - 5} ${pin.y - 5}h10v10h-10z`} />\n <text\n class={PORT_LABEL_CLASS}\n x={pin.x}\n y={pin.y - 10}\n text-anchor=\"middle\"\n font-size={String(GRAPH_METRICS.portFontSize)}\n >\n {label}\n </text>\n </g>","<Show when={label}>\n <text\n class={EDGE_LABEL_CLASS}\n part={this.partForName(\"edge-label\")}\n x={middle.x}\n y={middle.y - 4}\n text-anchor=\"middle\"\n font-size={String(GRAPH_METRICS.portFontSize)}\n >\n {label}\n </text>\n </Show>","when={label}","part={this.partForName(\"edge-label\")}","x={middle.x}","y={middle.y - 4}","<text\n class={EDGE_LABEL_CLASS}\n part={this.partForName(\"edge-label\")}\n x={middle.x}\n y={middle.y - 4}\n text-anchor=\"middle\"\n font-size={String(GRAPH_METRICS.portFontSize)}\n >\n {label}\n </text>","class={EDGE_HIT_CLASS}","class={EDGE_CLASS}","part={[this.partForName(\"edge\"), kind && `kind-${kind}`].filter(Boolean).join(\" \")}","<g\n class={[\n EDGE_GROUP_CLASS,\n kind && `kind-${kind}`,\n this.edgeClass(placed.edge),\n { [LIT_CLASS]: this.lit.has(placed.path), [SELECTED_CLASS]: this.selectedPath === placed.path }\n ]}\n onPointerEnter={() => this.hovered = { kind: \"edge\", path: placed.path }}\n onPointerLeave={() => this.unhover(placed.path)}\n onClick={select}\n >\n <path class={EDGE_HIT_CLASS} d={d} />\n <path\n class={EDGE_CLASS}\n part={[this.partForName(\"edge\"), kind && `kind-${kind}`].filter(Boolean).join(\" \")}\n d={d}\n />\n <Show when={label}>\n <text\n class={EDGE_LABEL_CLASS}\n part={this.partForName(\"edge-label\")}\n x={middle.x}\n y={middle.y - 4}\n text-anchor=\"middle\"\n font-size={String(GRAPH_METRICS.portFontSize)}\n >\n {label}\n </text>\n </Show>\n </g>","E.DOMElement","E.UIComponent","E.proto","E.protoMerged","E.state","E.derived","E.lazy","E.onChange","E.untracked","E.cssState","E.whileConnected","E.on","_$readShallow","_$setAttribute","_$getOwner","__name","graphCSS","Key","__decoratorStart","__publicField","__name$1","__decorateElement","__decoratorMetadata","__runInitializers","__privateAdd","TreeMeasure","getOwner$1","GraphPortSides","GraphChildViews","GRAPH_METRICS","GraphLayout","layout","options","prefix","level","graph","nodes","edges","margin","pins","pin","edge","points","d","i","p","q","reach","forward","c1x","c1y","fromSide","c2x","c2y","toSide","side","point","port","kind","votes","text","fontSize","node","m","byId","units","end","id","tally","key","path","unit","boundary","inside","boundarySides","links","from","to","index","layerCount","link","a","b","layer","dummy","layers","order","u","v","uOffset","vOffset","placedEdges","levelPins","width","label","ports","sides","sideOf","hasChildren","childGraph","labelWidth","child","insetX","tall","wide","along","each","role","out","inDegree","between","state","root","stack","top","list","next","seen","succ","pred","queue","topo","nexts","last","offset","centre","near","sum","round","crossings","x","y","tallest","used","wanted","all","blocks","height","gapAfter","block","previous","weight","ux","uy","depth","graphPath","container","value","graphVocabulary","UIGraph_default","_tmpl$","_tmpl$2","_tmpl$3","_tmpl$4","_tmpl$5","_tmpl$6","_tmpl$7","_tmpl$8","_tmpl$9","_tmpl$10","_tmpl$11","_tmpl$12","_onModalClosed_dec","_onModalPathChanged_dec","_watchSize_dec","_onLayoutChanged_dec","_onGraphChanged_dec","_fit_dec","_isPanningNow_dec","_isPanning_dec","_view_dec","_choose_dec","_lit_dec","_hovered_dec","_isDrilled_dec","_toggle_dec","_onPathChanged_dec","_fontFamily_dec","_layout_dec","_shownGraph_dec","_modalPath_dec","_drillPaths_dec","_openPaths_dec","_loadingPaths_dec","_loadedChildren_dec","_elementSetup_dec","_vocabulary_dec","_a","_init","_loadedChildren","_loadingPaths","_openPaths","_drillPaths","_modalPath","_hovered","_view","_isPanning","DOMElement","view","_UIGraph","UIComponent","proto","protoMerged","derived","lazy","onChange","untracked","cssState","whileConnected","on","box","px","event","py","k","svg","start","move","dx","moved","dy","DRAG_DISTANCE","up","soon","placed","selection","_self$","_el$","setAttribute","effect","readShallow","BOX_CLASS","_v$","_$p","_el$2","isOpen","insert","_c$","memo","LABEL_CLASS","className","_p$","o","at","children","openChildren","isServer","size","how","originalEvent","drilled","ids","trail","error","Warnings","loading","lit","hovered","nodeOf","selected","item","room","isReady","observer","inner","MODAL_GRAPH_CLASS","MODAL_GRAPH_HEIGHT","EMPTY","_self$2","_el$3","_el$4","_el$5","_el$6","_el$7","_el$8","_el$9","_el$10","_el$11","_el$12","_el$13","createComponent","Show","addEvent","ref","For","element","div","TOOLBAR_CLASS","CANVAS_CLASS","MODAL_BODY_CLASS","t","n","s","h","r","l","_self$3","_el$14","_el$15","crumb","BREADCRUMBS_CLASS","_self$4","_el$16","_el$17","_el$18","_el$19","_el$20","_el$21","title","NODE_CLASS","CONTAINER_CLASS","LIT_CLASS","SELECTED_CLASS","LOADING_CLASS","cx","cy","_self$5","_el$22","_el$23","_el$24","_el$25","_el$26","TOGGLE_CLASS","TOGGLE_TARGET_CLASS","TOGGLE_CIRCLE_CLASS","TOGGLE_MARK_CLASS","MINUS_MARK","PLUS_MARK","owner","labelAt","_self$6","_el$27","_el$28","_el$29","PORT_LABEL_CLASS","e","PORT_CLASS","PORT_DOT_CLASS","_self$7","_el$30","_el$31","_el$32","PIN_CLASS","PIN_MARK_CLASS","middle","select","_self$8","_el$33","_el$34","_el$35","_el$36","EDGE_LABEL_CLASS","EDGE_GROUP_CLASS","EDGE_HIT_CLASS","EDGE_CLASS","paths","word","family","UIGraph","delegateEvents"],"sources":["../src/components/ui-graph/UIGraph.types.ts","../src/components/ui-graph/GraphLayout.ts","../src/components/ui-graph/UIGraph.en.ts","../src/components/ui-graph/UIGraph.tsx","../src/components/ui-graph/index.ts"],"sourcesContent":["/**\n * The types and constants of the graph family: the data contract (`GraphData`, `GraphNode`, `GraphEdge` ...),\n * the layout's shapes and its metrics, shared by `GraphLayout` and the component.\n * - Data only: nothing here runs.\n * - GENERIC: any node / edge graph from plain data.\n * A subclass may draw one domain's graphs (a netlist, a pipeline ...); `ui` knows nothing about them.\n */\n\n////////////////\n// ## The data contract\n////////////////\n\n/** A graph `<ui-graph>` draws: its nodes, and the edges between them (or their ports). */\nexport type GraphData = {\n nodes: GraphNode[]\n edges?: GraphEdge[]\n}\n\n/** What a node's `children` may be: a graph, or a function giving one (or a promise of one), called on first open. */\nexport type GraphChildren = GraphData | (() => GraphData | Promise<GraphData>)\n\n/** One node of a graph. */\nexport type GraphNode = {\n /** Unique among its graph's nodes (not across levels: a node in a child graph is known by its `path`). */\n id: string\n /** The box's text; none: its `id`. */\n label?: string\n /** A word for what sort of node it is: its `<g>` is also class and part `kind-<word>`, for a page's own style. */\n kind?: string\n /** Where edges attach: drawn on the box's sides. */\n ports?: GraphPort[]\n /** A graph inside it, shown when it's opened: in place, in a modal or instead of the graph (`child-view`). */\n children?: GraphChildren\n /** How THIS node's children open; none: the element's `child-view`. */\n childView?: GraphChildView\n /** Starts open (`inline` only). */\n open?: boolean\n /** Hover text (an SVG `<title>`). */\n title?: string\n /** Anything the page wants to keep with the node: never read by the graph. */\n data?: unknown\n}\n\n/** A place on a node's side where edges attach. */\nexport type GraphPort = {\n /** Unique among its node's ports. */\n id: string\n /** Text beside it; none: no text. */\n label?: string\n /**\n * Which side it's on.\n * - None: `kind` `in` / `input` => `left`, `out` / `output` => `right`; else the side most of its edges come from.\n */\n side?: GraphPortSide\n /** A word for what sort of port it is: class and part `kind-<word>`. */\n kind?: string\n}\n\n/**\n * One end of an edge: a node, and optionally one of its ports.\n * - `node` `\"\"` (or left out) is the ENCLOSING node, the one whose `children` this graph is: `port` names ITS port.\n * Drawn on the container's side when opened in place, and as a pin on the graph's edge in a modal or drill view.\n */\nexport type GraphEnd = {\n node?: string\n port?: string\n}\n\n/** One edge, from one end to the other. */\nexport type GraphEdge = {\n /** Unique among its graph's edges; none: its index, `#3`. */\n id?: string\n from: GraphEnd\n to: GraphEnd\n /** A word for what sort of edge it is: class and part `kind-<word>`. */\n kind?: string\n /** Text at the edge's middle. */\n label?: string\n /** Anything the page wants to keep with it. */\n data?: unknown\n}\n\n/** A port's side. Above its type: the layout lists them. */\nexport const GraphPortSides = [\"left\", \"right\", \"top\", \"bottom\"] as const\nexport type GraphPortSide = (typeof GraphPortSides)[number]\n\n/** How a node's children are shown when it opens. Above its type: the vocabulary lists them. */\nexport const GraphChildViews = [\"inline\", \"modal\", \"drill\"] as const\nexport type GraphChildView = (typeof GraphChildViews)[number]\n\n/** What's selected: a node, an edge or a port, by `path` (a node's ids from the top, joined by `/`). */\nexport type GraphSelection = {\n kind: \"node\" | \"edge\" | \"port\"\n /** The item's own `id` (an edge without one: `#<index>`). */\n id: string\n /**\n * Where it is: the node's path (`cpu/alu`), the edge's graph path then `#` and its id (`cpu#e3`),\n * a port's node path then `:` and its id (`cpu/alu:a`).\n */\n path: string\n}\n\n////////////////\n// ## Layout\n////////////////\n\n/** A point in the drawing's user units. */\nexport type GraphPoint = { readonly x: number; readonly y: number }\n\n/** A port, placed: absolute, on its node's side. */\nexport type GraphPlacedPort = GraphPoint & {\n readonly port: GraphPort\n readonly side: GraphPortSide\n /** Its node's path, then `:` and its id. */\n readonly path: string\n}\n\n/** A node, placed: absolute user units, `x` / `y` its top left corner. */\nexport type GraphPlacedNode = {\n readonly node: GraphNode\n /** Its ids from the top, joined by `/`. */\n readonly path: string\n /** How deep it is: `0` for the shown graph's own nodes. */\n readonly depth: number\n readonly x: number\n readonly y: number\n readonly width: number\n readonly height: number\n readonly ports: readonly GraphPlacedPort[]\n /** It has children (loaded or not). */\n readonly hasChildren: boolean\n /** It's open in place: a container, its child graph drawn inside it. */\n readonly isOpen: boolean\n /** Its children are loading. */\n readonly isLoading?: boolean\n}\n\n/** An edge, placed: absolute points, from its start to its end, drawn as a smooth path through them. */\nexport type GraphPlacedEdge = {\n readonly edge: GraphEdge\n /** Its id, `#<index>` without one. */\n readonly id: string\n /** Its graph's path (`\"\"` at the top), then `#`, then its id. */\n readonly path: string\n /** The paths of what it joins: a node's path, or a port's (`node:port`). */\n readonly fromPath: string\n readonly toPath: string\n readonly points: readonly GraphPoint[]\n /** Which side of its start it leaves from, and which side of its end it enters by. */\n readonly fromSide: GraphPortSide\n readonly toSide: GraphPortSide\n readonly depth: number\n}\n\n/** A boundary pin: an enclosing node's port, drawn on the graph's own edge (modal and drill views). */\nexport type GraphPlacedPin = GraphPoint & {\n readonly port: GraphPort\n readonly side: GraphPortSide\n readonly path: string\n}\n\n/** A graph laid out: what `<ui-graph>` draws, every level flattened, in user units. */\nexport type GraphLayoutResult = {\n readonly width: number\n readonly height: number\n /** Every node, parents before their children. */\n readonly nodes: readonly GraphPlacedNode[]\n readonly edges: readonly GraphPlacedEdge[]\n /** The enclosing node's ports, at the top level's sides. */\n readonly pins: readonly GraphPlacedPin[]\n}\n\n/** What `GraphLayout` is told besides the graph. */\nexport type GraphLayoutOptions = {\n metrics?: GraphMetrics\n /** A text's width in user units at `fontSize`; default: estimated from its length. */\n textWidth?: (text: string, fontSize: number) => number\n /** A node's text; default: its label, else its id. */\n label?: (node: GraphNode) => string\n /** The child graph of each node open in place, by path. */\n openChildren?: ReadonlyMap<string, GraphData>\n /** Paths of nodes whose children are loading. */\n loading?: ReadonlySet<string>\n /** The enclosing node's ports: drawn as pins on the graph's sides. */\n boundary?: readonly GraphPort[]\n /** The shown graph's own path, `\"\"` at the top: what its nodes' paths start with. */\n prefix?: string\n}\n\n/** Sizes the layout works in, in user units. */\nexport const GRAPH_METRICS = {\n fontSize: 12,\n portFontSize: 10,\n /** Estimated advance of one character, per font size. */\n charWidth: 0.6,\n paddingX: 12,\n nodeHeight: 32,\n minNodeWidth: 48,\n /** Space between ports along a side. */\n portSpacing: 18,\n portRadius: 3.5,\n /** Space between layers. */\n layerGap: 56,\n /** Space between nodes in a layer. */\n nodeGap: 18,\n /** A container's header (its label and toggle), and the padding round its child graph. */\n headerHeight: 26,\n containerPadding: 14,\n /** Room for the toggle button, right of a label. */\n toggleWidth: 18,\n margin: 24\n} as const\n\nexport type GraphMetrics = { readonly [K in keyof typeof GRAPH_METRICS]: number }\n","import {\n GRAPH_METRICS,\n type GraphData,\n type GraphEdge,\n type GraphEnd,\n type GraphLayoutOptions,\n type GraphLayoutResult,\n type GraphMetrics,\n type GraphNode,\n type GraphPlacedEdge,\n type GraphPlacedNode,\n type GraphPlacedPin,\n type GraphPlacedPort,\n type GraphPoint,\n type GraphPort,\n type GraphPortSide\n} from \"./UIGraph.types\"\n\n/****************\n * ### `GraphLayout`\n * Lays a graph out left to right, in layers (a small Sugiyama): pure, numbers in, boxes and paths out.\n * - The steps, per level:\n * 1. each node's size, from its label and ports; a node open in place is laid out first, and grows round it\n * 2. cycles broken (depth first, back edges turned round), then layers by longest path, sources pulled right\n * 3. a dummy point per layer a long edge crosses, so it routes round the boxes\n * 4. order within each layer by barycentre sweeps (each box moved towards its neighbours' mean), ports counted\n * 5. x by layer; y pulled towards each box's neighbours, then pushed apart so nothing overlaps\n * - Edges come out as points; `pathFor()` turns them into a smooth SVG path, leaving and entering ports sideways.\n * - The enclosing node's ports (`boundary`) are pins in the first and last layers:\n * a container's own ports sit where its child graph's pins are.\n * - Measured: 200 nodes and 400 edges in one level lay out in tens of milliseconds (`UIGraph`'s docs page).\n * - GENERIC: imports only the family's types.\n ****************/\nexport class GraphLayout {\n /** `graph` laid out, every open level flattened into absolute boxes. */\n static of(graph: GraphData, options: GraphLayoutOptions = {}): GraphLayoutResult {\n const layout = new GraphLayout(options)\n const prefix = options.prefix ?? \"\"\n const level = layout.level(graph, prefix, options.boundary ?? [])\n const nodes: GraphPlacedNode[] = []\n const edges: GraphPlacedEdge[] = []\n const { margin } = layout.metrics\n layout.flatten(level, margin, margin, 0, nodes, edges)\n const pins: GraphPlacedPin[] = level.pins.map((pin) => ({\n port: pin.port,\n side: pin.side,\n path: `${prefix}:${pin.port.id}`,\n x: pin.x + margin,\n y: pin.y + margin\n }))\n return { width: level.width + 2 * margin, height: level.height + 2 * margin, nodes, edges, pins }\n }\n\n /** `d` of an edge's `<path>`: cubic curves through its points, leaving and entering along its sides. */\n static pathFor(edge: Pick<GraphPlacedEdge, \"points\" | \"fromSide\" | \"toSide\">): string {\n const { points, fromSide, toSide } = edge\n if (points.length < 2) return \"\"\n let d = `M${round(points[0].x)} ${round(points[0].y)}`\n for (let i = 1; i < points.length; i++) {\n const p = points[i - 1]\n const q = points[i]\n const reach = Math.max(16, Math.abs(q.x - p.x) / 2, Math.abs(q.y - p.y) / 4)\n const forward = Math.sign(q.x - p.x) || 1\n const [c1x, c1y] = i === 1 ? GraphLayout.toward(p, fromSide, reach) : [p.x + forward * reach, p.y]\n const [c2x, c2y] = i === points.length - 1 ? GraphLayout.toward(q, toSide, reach) : [q.x - forward * reach, q.y]\n d += `C${round(c1x)} ${round(c1y)} ${round(c2x)} ${round(c2y)} ${round(q.x)} ${round(q.y)}`\n }\n return d\n }\n\n /** A control point `reach` out of `point`, on `side`. */\n private static toward(point: GraphPoint, side: GraphPortSide, reach: number): [number, number] {\n switch (side) {\n case \"left\":\n return [point.x - reach, point.y]\n case \"right\":\n return [point.x + reach, point.y]\n case \"top\":\n return [point.x, point.y - reach]\n case \"bottom\":\n return [point.x, point.y + reach]\n }\n }\n\n /** The middle of an edge's path, for its label. */\n static middleOf(edge: Pick<GraphPlacedEdge, \"points\">): GraphPoint {\n const { points } = edge\n if (points.length % 2 === 1) return points[(points.length - 1) / 2]\n const p = points[points.length / 2 - 1]\n const q = points[points.length / 2]\n return { x: (p.x + q.x) / 2, y: (p.y + q.y) / 2 }\n }\n\n /** A port's side: its own, else its kind's, else where most of its edges are drawn from. */\n static sideOf(port: GraphPort, votes: { asSource: number; asTarget: number } | undefined): GraphPortSide {\n if (port.side) return port.side\n const kind = port.kind?.toLowerCase()\n if (kind === \"in\" || kind === \"input\") return \"left\"\n if (kind === \"out\" || kind === \"output\") return \"right\"\n if (!votes) return \"right\"\n return votes.asTarget > votes.asSource ? \"left\" : \"right\"\n }\n\n private readonly metrics: GraphMetrics\n private readonly options: GraphLayoutOptions\n\n private constructor(options: GraphLayoutOptions) {\n this.options = options\n this.metrics = options.metrics ?? GRAPH_METRICS\n }\n\n private textWidth(text: string, fontSize: number): number {\n return this.options.textWidth?.(text, fontSize) ?? text.length * fontSize * this.metrics.charWidth\n }\n\n private labelOf(node: GraphNode): string {\n return this.options.label?.(node) ?? node.label ?? node.id\n }\n\n ////////////////\n // ## One level\n ////////////////\n\n /** One graph laid out, its coordinates relative to its own top left. */\n private level(\n graph: GraphData,\n prefix: string,\n boundary: readonly GraphPort[],\n boundarySides?: ReadonlyMap<GraphPort, GraphPortSide>\n ): Level {\n const m = this.metrics\n const nodes = graph.nodes ?? []\n const byId = new Map<string, Unit>()\n const units: Unit[] = []\n const edges = graph.edges ?? []\n\n // Votes for each port's side: how often it starts an edge, and ends one.\n const votes = new Map<string, { asSource: number; asTarget: number }>()\n const vote = (end: GraphEnd, key: \"asSource\" | \"asTarget\") => {\n if (end.port === undefined) return\n const id = `${end.node ?? \"\"}:${end.port}`\n const tally = votes.get(id) ?? { asSource: 0, asTarget: 0 }\n tally[key]++\n votes.set(id, tally)\n }\n for (const edge of edges) {\n vote(edge.from, \"asSource\")\n vote(edge.to, \"asTarget\")\n }\n\n // 1. Sizes.\n for (const node of nodes) {\n if (!node || typeof node.id !== \"string\" || byId.has(node.id)) continue\n const path = prefix ? `${prefix}/${node.id}` : node.id\n const unit = this.box(node, path, (port) => GraphLayout.sideOf(port, votes.get(`${node.id}:${port.id}`)))\n byId.set(node.id, unit)\n units.push(unit)\n }\n\n // Pins: the enclosing node's ports. Inside, a left pin STARTS edges, so it's drawn facing right.\n const pins = new Map<string, Unit>()\n for (const port of boundary) {\n const inside = votes.get(`:${port.id}`)\n const side = boundarySides?.get(port) ?? GraphLayout.sideOf(port, inside && flip(inside))\n const pin: Unit = {\n kind: \"pin\",\n width: 0,\n height: m.portSpacing,\n layer: 0,\n order: 0,\n x: 0,\n y: 0,\n ports: [],\n pin: { port, side: side === \"left\" || side === \"top\" ? \"left\" : \"right\" }\n }\n pins.set(port.id, pin)\n units.push(pin)\n }\n\n // Resolve each edge's ends.\n const links: Link[] = []\n edges.forEach((edge, index) => {\n if (!edge?.from || !edge?.to) return\n const from = this.endOf(edge.from, \"from\", byId, pins, prefix)\n const to = this.endOf(edge.to, \"to\", byId, pins, prefix)\n if (!from || !to) return\n const id = edge.id ?? `#${index}`\n links.push({ edge, id, from, to, reversed: false, chain: [] })\n })\n\n // 2. Layers.\n this.assignLayers(units, links)\n\n // 3. Dummies along long edges.\n const layerCount = Math.max(0, ...units.map((unit) => unit.layer)) + 1\n for (const link of links) {\n const [a, b] = link.reversed ? [link.to, link.from] : [link.from, link.to]\n link.chain = [a.unit]\n for (let layer = a.unit.layer + 1; layer < b.unit.layer; layer++) {\n const dummy: Unit = { kind: \"dummy\", width: 0, height: 4, layer, order: 0, x: 0, y: 0, ports: [] }\n units.push(dummy)\n link.chain.push(dummy)\n }\n link.chain.push(b.unit)\n }\n\n const layers: Unit[][] = Array.from({ length: layerCount }, () => [])\n for (const unit of units) layers[unit.layer].push(unit)\n layers.forEach((layer) => layer.forEach((unit, order) => (unit.order = order)))\n\n // Neighbours, for the sweeps: each segment of each chain, with the y offset it attaches at on each side.\n for (const link of links) {\n const [a, b] = link.reversed ? [link.to, link.from] : [link.from, link.to]\n for (let i = 0; i + 1 < link.chain.length; i++) {\n const u = link.chain[i]\n const v = link.chain[i + 1]\n if (u.layer === v.layer) continue\n const uOffset = i === 0 ? a.dy : u.height / 2\n const vOffset = i + 1 === link.chain.length - 1 ? b.dy : v.height / 2\n ;(u.down ??= []).push({ unit: v, mine: uOffset, theirs: vOffset })\n ;(v.up ??= []).push({ unit: u, mine: vOffset, theirs: uOffset })\n }\n }\n\n // 4. Order.\n this.order(layers)\n\n // 5. Coordinates.\n const { width, height } = this.place(layers, links)\n\n // Points per edge.\n const placedEdges: LevelEdge[] = []\n for (const link of links) {\n const [a, b] = link.reversed ? [link.to, link.from] : [link.from, link.to]\n const points: GraphPoint[] = [{ x: a.unit.x + a.dx, y: a.unit.y + a.dy }]\n for (let i = 1; i < link.chain.length - 1; i++) {\n const dummy = link.chain[i]\n points.push({ x: dummy.x, y: dummy.y + dummy.height / 2 })\n }\n points.push({ x: b.unit.x + b.dx, y: b.unit.y + b.dy })\n if (link.reversed) points.reverse()\n placedEdges.push({\n edge: link.edge,\n id: link.id,\n points,\n fromSide: link.from.side,\n toSide: link.to.side,\n fromPath: link.from.path,\n toPath: link.to.path,\n fromPin: link.from.unit.kind === \"pin\" ? link.from.unit.pin!.port.id : undefined,\n toPin: link.to.unit.kind === \"pin\" ? link.to.unit.pin!.port.id : undefined\n })\n }\n\n const levelPins = [...pins.values()].map((pin) => ({\n port: pin.pin!.port,\n side: pin.pin!.side,\n x: pin.pin!.side === \"left\" ? 0 : width,\n y: pin.y + pin.height / 2\n }))\n\n return {\n width,\n height,\n units: units.filter((unit) => unit.kind === \"node\"),\n edges: placedEdges,\n pins: levelPins,\n prefix\n }\n }\n\n /** A node's box: a leaf sized to its label and ports, or a container round its laid out child graph. */\n private box(node: GraphNode, path: string, sideOf: (port: GraphPort) => GraphPortSide): Unit {\n const m = this.metrics\n const label = this.labelOf(node)\n const ports = (node.ports ?? []).filter((port) => port && typeof port.id === \"string\")\n const sides = new Map(ports.map((port) => [port, sideOf(port)]))\n const on = (side: GraphPortSide) => ports.filter((port) => sides.get(port) === side)\n const portLabelWidth = (side: GraphPortSide) =>\n Math.max(0, ...on(side).map((port) => (port.label ? this.textWidth(port.label, m.portFontSize) + 6 : 0)))\n const hasChildren = node.children !== undefined\n const childGraph = this.options.openChildren?.get(path)\n const labelWidth = this.textWidth(label, m.fontSize) + 2 * m.paddingX + (hasChildren ? m.toggleWidth : 0)\n\n const unit: Unit = {\n kind: \"node\",\n node,\n path,\n width: 0,\n height: 0,\n layer: 0,\n order: 0,\n x: 0,\n y: 0,\n ports: [],\n hasChildren,\n isLoading: this.options.loading?.has(path)\n }\n\n if (childGraph) {\n const child = this.level(childGraph, path, ports, sides)\n unit.child = child\n unit.width = Math.max(labelWidth, child.width + 2 * m.containerPadding)\n unit.height = m.headerHeight + child.height + m.containerPadding\n const insetX = (unit.width - child.width) / 2\n for (const pin of child.pins) {\n const side = pin.side\n unit.ports.push({\n port: pin.port,\n side,\n dx: side === \"left\" ? 0 : unit.width,\n dy: m.headerHeight + pin.y\n })\n }\n unit.childOffset = { x: insetX, y: m.headerHeight }\n this.spread(unit, on(\"top\"), \"top\")\n this.spread(unit, on(\"bottom\"), \"bottom\")\n return unit\n }\n\n const tall = Math.max(on(\"left\").length, on(\"right\").length)\n const wide = Math.max(on(\"top\").length, on(\"bottom\").length)\n unit.height = Math.max(m.nodeHeight, (tall + 1) * m.portSpacing)\n unit.width = Math.max(\n m.minNodeWidth,\n labelWidth + portLabelWidth(\"left\") + portLabelWidth(\"right\"),\n (wide + 1) * m.portSpacing\n )\n for (const side of [\"left\", \"right\", \"top\", \"bottom\"] as const) this.spread(unit, on(side), side)\n return unit\n }\n\n /** Place `ports` evenly along `unit`'s `side`. */\n private spread(unit: Unit, ports: GraphPort[], side: GraphPortSide) {\n ports.forEach((port, index) => {\n const along = (index + 1) / (ports.length + 1)\n if (side === \"left\" || side === \"right\")\n unit.ports.push({ port, side, dx: side === \"left\" ? 0 : unit.width, dy: along * unit.height })\n else unit.ports.push({ port, side, dx: along * unit.width, dy: side === \"top\" ? 0 : unit.height })\n })\n }\n\n /** Where an edge's end attaches; `undefined` for an end naming nothing in this graph. */\n private endOf(\n end: GraphEnd,\n role: \"from\" | \"to\",\n byId: Map<string, Unit>,\n pins: Map<string, Unit>,\n prefix: string\n ): End | undefined {\n if (!end.node) {\n const pin = end.port !== undefined ? pins.get(end.port) : undefined\n if (!pin) return undefined\n return {\n unit: pin,\n dx: 0,\n dy: pin.height / 2,\n side: pin.pin!.side === \"left\" ? \"right\" : \"left\",\n path: `${prefix}:${end.port}`\n }\n }\n const unit = byId.get(end.node)\n if (!unit) return undefined\n const port = end.port !== undefined ? unit.ports.find((each) => each.port.id === end.port) : undefined\n if (port) return { unit, dx: port.dx, dy: port.dy, side: port.side, path: `${unit.path}:${port.port.id}` }\n return role === \"from\"\n ? { unit, dx: unit.width, dy: unit.height / 2, side: \"right\", path: unit.path! }\n : { unit, dx: 0, dy: unit.height / 2, side: \"left\", path: unit.path! }\n }\n\n /** Layers: cycles broken, longest path from the sources, sources pulled next to what they feed; pins at the sides. */\n private assignLayers(units: Unit[], links: Link[]) {\n const nodes = units.filter((unit) => unit.kind === \"node\")\n const out = new Map<Unit, Link[]>(nodes.map((unit) => [unit, []]))\n const inDegree = new Map<Unit, number>(nodes.map((unit) => [unit, 0]))\n const between = links.filter((link) => link.from.unit.kind === \"node\" && link.to.unit.kind === \"node\")\n\n // Depth first, iteratively: an edge back to a node still on the stack is turned round.\n for (const link of between) out.get(link.from.unit)!.push(link)\n const state = new Map<Unit, 1 | 2>()\n for (const root of nodes) {\n if (state.has(root)) continue\n const stack: [Unit, number][] = [[root, 0]]\n state.set(root, 1)\n const outs = (unit: Unit) => out.get(unit)!\n while (stack.length) {\n const top = stack[stack.length - 1]\n const list = outs(top[0])\n if (top[1] >= list.length) {\n state.set(top[0], 2)\n stack.pop()\n continue\n }\n const link = list[top[1]++]\n const next = link.to.unit\n if (next === top[0]) continue\n const seen = state.get(next)\n if (seen === 1) link.reversed = true\n else if (!seen) {\n state.set(next, 1)\n stack.push([next, 0])\n }\n }\n }\n\n // Longest path, in topological order.\n const succ = new Map<Unit, Unit[]>(nodes.map((unit) => [unit, []]))\n const pred = new Map<Unit, Unit[]>(nodes.map((unit) => [unit, []]))\n for (const link of between) {\n const [a, b] = link.reversed ? [link.to.unit, link.from.unit] : [link.from.unit, link.to.unit]\n if (a === b) continue\n succ.get(a)!.push(b)\n pred.get(b)!.push(a)\n inDegree.set(b, inDegree.get(b)! + 1)\n }\n const queue = nodes.filter((unit) => inDegree.get(unit) === 0)\n const topo: Unit[] = []\n for (let i = 0; i < queue.length; i++) {\n const unit = queue[i]\n topo.push(unit)\n for (const next of succ.get(unit)!) {\n next.layer = Math.max(next.layer, unit.layer + 1)\n inDegree.set(next, inDegree.get(next)! - 1)\n if (inDegree.get(next) === 0) queue.push(next)\n }\n }\n // Sources pulled right, next to the nearest node they feed.\n for (let i = topo.length - 1; i >= 0; i--) {\n const unit = topo[i]\n const nexts = succ.get(unit)!\n if (pred.get(unit)!.length === 0 && nexts.length)\n unit.layer = Math.max(unit.layer, Math.min(...nexts.map((next) => next.layer)) - 1)\n }\n\n // Pins: left ones before every node, right ones after.\n const pins = units.filter((unit) => unit.kind === \"pin\")\n const hasLeft = pins.some((pin) => pin.pin!.side === \"left\")\n if (hasLeft) for (const unit of nodes) unit.layer++\n const last = Math.max(0, ...nodes.map((unit) => unit.layer))\n for (const pin of pins) pin.layer = pin.pin!.side === \"left\" ? 0 : last + (nodes.length ? 1 : 0)\n\n // Links between pins and nodes go forward or are turned round.\n for (const link of links)\n if (link.from.unit.kind === \"pin\" || link.to.unit.kind === \"pin\")\n link.reversed = link.from.unit.layer > link.to.unit.layer\n }\n\n /** Order within each layer: barycentre sweeps, down then up, keeping the best. */\n private order(layers: Unit[][]) {\n const position = (unit: Unit, offset: number) => unit.order + offset / Math.max(1, unit.height)\n const sweep = (layer: Unit[], side: \"up\" | \"down\") => {\n const centre = new Map<Unit, number>()\n for (const unit of layer) {\n const near = unit[side]\n if (!near?.length) centre.set(unit, unit.order)\n else centre.set(unit, near.reduce((sum, each) => sum + position(each.unit, each.theirs), 0) / near.length)\n }\n layer.sort((a, b) => centre.get(a)! - centre.get(b)! || a.order - b.order)\n layer.forEach((unit, order) => (unit.order = order))\n }\n for (let round = 0; round < 6; round++) {\n if (round % 2 === 0) for (let i = 1; i < layers.length; i++) sweep(layers[i], \"up\")\n else for (let i = layers.length - 2; i >= 0; i--) sweep(layers[i], \"down\")\n }\n }\n\n /** x by layer, y pulled towards neighbours without overlapping; the level's size. */\n private place(layers: Unit[][], links: Link[]): { width: number; height: number } {\n const m = this.metrics\n const gapAfter = (unit: Unit) => (unit.kind === \"dummy\" ? 6 : m.nodeGap)\n\n // x: each layer as wide as its widest box, boxes centred in it; busier gaps are wider.\n const crossings = new Array(layers.length).fill(0)\n for (const link of links) for (let i = 0; i + 1 < link.chain.length; i++) crossings[link.chain[i].layer]++\n let x = 0\n layers.forEach((layer, index) => {\n const width = Math.max(0, ...layer.map((unit) => unit.width))\n for (const unit of layer) unit.x = x + (width - unit.width) / 2\n x += width + m.layerGap + Math.min(60, Math.sqrt(crossings[index]) * 4)\n })\n\n // y: stacked, then pulled towards the neighbours' attachment points, in a few sweeps.\n for (const layer of layers) {\n let y = 0\n for (const unit of layer) {\n unit.y = y\n y += unit.height + gapAfter(unit)\n }\n }\n const tallest = Math.max(\n 0,\n ...layers.map((layer) => layer.reduce((sum, unit) => sum + unit.height + gapAfter(unit), 0))\n )\n for (const layer of layers) {\n const used = layer.reduce((sum, unit) => sum + unit.height + gapAfter(unit), 0)\n for (const unit of layer) unit.y += (tallest - used) / 2\n }\n const pull = (layer: Unit[], side: \"up\" | \"down\") => {\n const wanted = layer.map((unit) => {\n const near = [...(unit[side] ?? []), ...(unit[side === \"up\" ? \"down\" : \"up\"] ?? [])]\n if (!near.length) return unit.y\n return near.reduce((sum, each) => sum + each.unit.y + each.theirs - each.mine, 0) / near.length\n })\n GraphLayout.separate(layer, wanted, gapAfter)\n }\n for (let round = 0; round < 8; round++) {\n if (round % 2 === 0) for (let i = 1; i < layers.length; i++) pull(layers[i], \"up\")\n else for (let i = layers.length - 2; i >= 0; i--) pull(layers[i], \"down\")\n }\n\n // Normalised to start at 0.\n const all = layers.flat()\n const top = Math.min(0, ...all.map((unit) => unit.y))\n for (const unit of all) unit.y -= top\n const width = Math.max(0, ...all.map((unit) => unit.x + unit.width))\n const height = Math.max(0, ...all.map((unit) => unit.y + unit.height))\n return { width, height }\n }\n\n /** Put each unit of `layer` as near its `wanted` y as it can, in order, without overlaps. */\n private static separate(layer: Unit[], wanted: number[], gapAfter: (unit: Unit) => number) {\n // Blocks of units pushed together sit at the mean of what they want (pool adjacent violators).\n type Block = { start: number; end: number; top: number; height: number; weight: number; sum: number }\n const blocks: Block[] = []\n layer.forEach((unit, index) => {\n const height = unit.height + gapAfter(unit)\n let block: Block = { start: index, end: index, top: wanted[index], height, weight: 1, sum: wanted[index] }\n while (blocks.length) {\n const previous = blocks[blocks.length - 1]\n if (previous.top + previous.height <= block.top) break\n blocks.pop()\n const sum = previous.sum + block.sum - block.weight * previous.height\n const weight = previous.weight + block.weight\n block = {\n start: previous.start,\n end: block.end,\n top: sum / weight,\n height: previous.height + block.height,\n weight,\n sum\n }\n }\n blocks.push(block)\n })\n for (const block of blocks) {\n let y = block.top\n for (let i = block.start; i <= block.end; i++) {\n layer[i].y = y\n y += layer[i].height + gapAfter(layer[i])\n }\n }\n }\n\n ////////////////\n // ## Flattening\n ////////////////\n\n /** `level`'s boxes and edges, moved to `x`, `y`, into `nodes` and `edges`; open nodes' levels after them. */\n private flatten(\n level: Level,\n x: number,\n y: number,\n depth: number,\n nodes: GraphPlacedNode[],\n edges: GraphPlacedEdge[],\n container?: { unit: Unit; x: number; y: number }\n ) {\n for (const unit of level.units) {\n const ux = x + unit.x\n const uy = y + unit.y\n const ports: GraphPlacedPort[] = unit.ports.map((port) => ({\n port: port.port,\n side: port.side,\n path: `${unit.path}:${port.port.id}`,\n x: ux + port.dx,\n y: uy + port.dy\n }))\n nodes.push({\n node: unit.node!,\n path: unit.path!,\n depth,\n x: ux,\n y: uy,\n width: unit.width,\n height: unit.height,\n ports,\n hasChildren: !!unit.hasChildren,\n isOpen: !!unit.child,\n isLoading: unit.isLoading\n })\n if (unit.child && unit.childOffset)\n this.flatten(unit.child, ux + unit.childOffset.x, uy + unit.childOffset.y, depth + 1, nodes, edges, {\n unit,\n x: ux,\n y: uy\n })\n }\n const graphPath = level.prefix\n for (const edge of level.edges) {\n const points = edge.points.map((point) => ({ x: point.x + x, y: point.y + y }))\n // A pin inside a container reaches out to the container's own port, on its side.\n if (container) {\n const portAt = (id: string) => container.unit.ports.find((port) => port.port.id === id)\n const from = edge.fromPin !== undefined ? portAt(edge.fromPin) : undefined\n const to = edge.toPin !== undefined ? portAt(edge.toPin) : undefined\n if (from) points.unshift({ x: container.x + from.dx, y: container.y + from.dy })\n if (to) points.push({ x: container.x + to.dx, y: container.y + to.dy })\n }\n edges.push({\n edge: edge.edge,\n id: edge.id,\n path: `${graphPath}#${edge.id}`,\n fromPath: edge.fromPath,\n toPath: edge.toPath,\n points,\n fromSide: container && edge.fromPin !== undefined ? \"right\" : edge.fromSide,\n toSide: container && edge.toPin !== undefined ? \"left\" : edge.toSide,\n depth\n })\n }\n }\n}\n\n/** One box, dummy or pin in a level, while it's laid out. */\ntype Unit = {\n kind: \"node\" | \"dummy\" | \"pin\"\n node?: GraphNode\n path?: string\n width: number\n height: number\n layer: number\n order: number\n x: number\n y: number\n ports: { port: GraphPort; side: GraphPortSide; dx: number; dy: number }[]\n hasChildren?: boolean\n isLoading?: boolean\n child?: Level\n childOffset?: GraphPoint\n pin?: { port: GraphPort; side: \"left\" | \"right\" }\n up?: Neighbour[]\n down?: Neighbour[]\n}\n\n/** A unit in the next layer an edge segment reaches, and where it attaches on each. */\ntype Neighbour = { unit: Unit; mine: number; theirs: number }\n\n/** Where an edge attaches to a unit. */\ntype End = { unit: Unit; dx: number; dy: number; side: GraphPortSide; path: string }\n\n/** An edge while it's laid out. */\ntype Link = { edge: GraphEdge; id: string; from: End; to: End; reversed: boolean; chain: Unit[] }\n\n/** An edge of a level, relative to it. */\ntype LevelEdge = {\n edge: GraphEdge\n id: string\n points: GraphPoint[]\n fromSide: GraphPortSide\n toSide: GraphPortSide\n fromPath: string\n toPath: string\n fromPin?: string\n toPin?: string\n}\n\n/** One graph laid out, relative to its own top left. */\ntype Level = {\n width: number\n height: number\n units: Unit[]\n edges: LevelEdge[]\n pins: { port: GraphPort; side: \"left\" | \"right\"; x: number; y: number }[]\n prefix: string\n}\n\n/** A port's votes seen from inside: a boundary port that edges START from inside is an input, on the left. */\nfunction flip(votes: { asSource: number; asTarget: number }) {\n return { asSource: votes.asTarget, asTarget: votes.asSource }\n}\n\n/** A coordinate, to a tenth. */\nfunction round(value: number): number {\n return Math.round(value * 10) / 10\n}\n","/**\n * The English vocabulary of `<ui-graph>`: every name the tag uses.\n * - Its tag, attributes (each with its kind and allowed values), events, parts and texts.\n * The shape is `ComponentVocabulary` (`spell/ui/vocabulary`).\n * - Ours, not Fomantic's: GENERIC, any node / edge graph; netlists are one caller (a subclass restyles it).\n * - Rich properties: `graph`, `selected` and `boundary` (`UIGraph.types.ts`).\n * A static page may give `graph` as JSON in the attribute.\n * - NOT `children` for how children open, though that's the word: it would hide the platform's `Element.children`.\n * So `child-view`.\n */\n\nimport type { ComponentVocabulary } from \"spell/ui/vocabulary\"\nimport { GraphChildViews } from \"./UIGraph.types\"\n\n/****************\n * ### `graphVocabulary`\n * The names of `<ui-graph>`, a node / edge graph drawn as an SVG:\n * `<div class=\"ui graph\">` holding breadcrumbs (when drilled in), a toolbar and `<svg part=\"canvas\">`.\n ****************/\nexport const graphVocabulary = {\n tag: \"ui-graph\",\n icon: \"project diagram\",\n topics: [\"data display\", \"images\", \"views\"],\n aka: [\n \"graph\",\n \"node graph\",\n \"network diagram\",\n \"flow chart\",\n \"dataflow\",\n \"netlist\",\n \"schematic\",\n \"block diagram\",\n \"DAG\"\n ],\n skeleton: \"16 tall\",\n noun: \"graph\",\n description:\n \"A graph draws nodes joined by edges, laid out left to right. A node may hold a graph of its own, opened in place, in a modal, or in its stead.\",\n attributes: [\n {\n name: \"graph\",\n group: \"content\",\n kind: \"json\",\n reflect: false,\n description:\n \"The graph to draw, a `GraphData`: `nodes` (`id`, `label`, `kind`, `ports`, `children`, `data`) and `edges` \" +\n \"(`from` / `to` `{ node, port }`). An end with no `node` is the enclosing node's port. A JS property (JSON in \" +\n \"the attribute); set a NEW graph to redraw.\"\n },\n {\n name: \"child-view\",\n group: \"behaviour\",\n kind: \"enum\",\n values: GraphChildViews,\n default: \"inline\",\n description:\n \"How a node's children show when it's opened: `inline`, inside the node, which grows round them; `modal`, a \" +\n \"graph in a modal; `drill`, the graph replaced by them, with breadcrumbs back. A node's own `childView` wins.\"\n },\n {\n name: \"path\",\n group: \"behaviour\",\n kind: \"string\",\n default: \"\",\n description:\n 'The node whose child graph is shown, drilled to, by its ids from the top joined by `/` (`cpu/alu`); `\"\"`: ' +\n \"the top. Setting it drills there, loading lazy children on the way; drilling and the breadcrumbs set it back, \" +\n \"with `ui-changed` `{ kind: 'path', path }`.\"\n },\n {\n name: \"selected\",\n group: \"states\",\n kind: \"json\",\n reflect: false,\n description:\n \"PROPERTY: what's selected, `{ kind: 'node' | 'edge' | 'port', id, path }`; `undefined`: nothing. Clicks set it.\"\n },\n {\n name: \"boundary\",\n group: \"content\",\n kind: \"json\",\n reflect: false,\n description:\n \"PROPERTY: the enclosing node's ports, drawn as pins on the graph's sides, for edges with no `node`. Set by a \" +\n \"modal's graph; a page rarely needs it.\"\n }\n ],\n events: [\n {\n name: \"ui-selecting\",\n cancelable: true,\n detail: \"{ kind: 'node' | 'edge' | 'port', id: string, path: string, item: object, originalEvent?: Event }\",\n description: \"A node, edge or port is about to be selected by a click: cancel it to keep the selection.\"\n },\n {\n name: \"ui-changed\",\n detail:\n \"{ value: { kind: string, id: string, path: string } | undefined, kind?: string, id?: string, path?: string, item?: object, originalEvent?: Event } | { kind: 'path', path: string, originalEvent?: Event }\",\n description:\n \"What's selected changed: `value` is the new `selected`; `item` the node, edge or port itself. ALSO when \" +\n \"the graph shown changes by a drill or a breadcrumb: `{ kind: 'path', path }` (`path` the new `path`), so one \" +\n \"listener keeps a page in step with both.\"\n },\n {\n name: \"ui-node-toggled\",\n detail:\n \"{ node: object, path: string, open: boolean, view: 'inline' | 'modal' | 'drill', originalEvent?: Event }\",\n description: \"A node with children was opened or closed, by a person or by `open()` / `close()`.\"\n }\n ],\n slots: [],\n parts: [\n { name: \"graph\", description: \"The box round it all.\" },\n { name: \"canvas\", description: \"The `<svg>`.\" },\n { name: \"node\", description: \"Each node's `<g>`.\" },\n { name: \"container\", description: \"A node opened in place, its child graph inside; also part `node`.\" },\n { name: \"edge\", description: \"Each edge's `<path>`.\" },\n { name: \"edge-label\", description: \"Each edge's label.\" },\n { name: \"port\", description: \"Each port's `<g>`: its dot and label.\" },\n { name: \"pin\", description: \"Each pin, the enclosing node's port, on a modal or drilled graph's side.\" },\n { name: \"toggle\", description: \"Each node's open / close button.\" },\n { name: \"toolbar\", description: \"The buttons over the drawing (fit).\" },\n { name: \"breadcrumbs\", description: \"The trail back up, when drilled in.\" }\n ],\n states: [\n { name: \"drilled\", description: \"It shows a node's children instead of its graph.\" },\n { name: \"panning\", description: \"A drag is moving the view.\" }\n ],\n texts: [\n { key: \"graphSummary\", text: \"Graph: {count} nodes\", description: \"Name of the drawing.\" },\n { key: \"graphOpenNode\", text: \"Open {label}\", description: \"A closed node's toggle.\" },\n { key: \"graphCloseNode\", text: \"Close {label}\", description: \"An open node's toggle.\" },\n { key: \"graphFit\", text: \"Fit\", description: \"The button that fits the drawing to the view.\" },\n { key: \"graphTop\", text: \"Top\", description: \"The first breadcrumb, the graph itself.\" },\n { key: \"graphLoading\", text: \"Loading …\", description: \"A node whose children are loading.\" }\n ]\n} as const satisfies ComponentVocabulary\n","import { For, Show } from \"solid-js\"\nimport { isServer, type JSX } from \"@solidjs/web\"\n\nimport { E, UIT } from \"spell/ui/core\"\n// Import directly: the tree diagram's text measuring, shared by every drawing (one canvas a page)\nimport { TreeMeasure } from \"spell/ui/components/ui-tree-diagram/TreeMeasure\"\nimport { graphVocabulary } from \"./UIGraph.en\"\nimport { GraphLayout } from \"./GraphLayout\"\nimport {\n GRAPH_METRICS,\n GraphChildViews,\n type GraphChildView,\n type GraphData,\n type GraphEdge,\n type GraphLayoutResult,\n type GraphNode,\n type GraphPlacedEdge,\n type GraphPlacedNode,\n type GraphPlacedPin,\n type GraphPlacedPort,\n type GraphPort,\n type GraphSelection\n} from \"./UIGraph.types\"\n\nimport graphCSS from \"./UIGraph.css?inline\"\n\n/****************\n * ### `DOMGraphElement`\n * `<ui-graph>` itself: its script API, over its component.\n ****************/\nexport class DOMGraphElement extends E.DOMElement<UIGraph> {\n /** Fit the drawing to the view. */\n fit() {\n this.component?.fit()\n }\n\n /** Open the node at `path` (its ids from the top, joined by `/`), as `view`, else as its own or the graph's. */\n open(path: string, view?: GraphChildView): Promise<void> {\n return this.component?.openNode(path, view) ?? Promise.resolve()\n }\n\n /** Close the node at `path`, opened in place; or, drilled into, go back above it. */\n close(path: string) {\n this.component?.closeNode(path)\n }\n\n /** Show the graph at `path` instead of the top (drill); none: back to the top. */\n drillTo(path?: string): Promise<void> {\n return this.component?.drillTo(path) ?? Promise.resolve()\n }\n\n /** The graph as it's drawn now: every box and edge, in user units. */\n get layout(): GraphLayoutResult | undefined {\n return this.component?.layout\n }\n}\n\n/****************\n * ### `<ui-graph>`\n * The component behind `<ui-graph>`: a node / edge graph drawn as an SVG, laid out left to right in layers\n * (`GraphLayout`), with ports on the nodes' sides, smooth edges, pan, zoom and fit.\n *\n * - GENERIC: any graph from plain data (`GraphData`).\n * A subclass restyles and relabels it through the hooks below\n * (`nodeLabel()`, `nodeClass()`, `renderNode()`, `edgeClass()` ...), its parts and its `--ui-graph-*` tokens.\n * - A node with `children` has a toggle; opened, they show by `child-view` (or the node's `childView`):\n * - `inline`: the node grows into a container, its graph laid out inside it, recursively\n * - `modal`: a `<ui-modal>` holding another graph of the same tag\n * - `drill`: the drawing shows them instead, with `<ui-breadcrumbs>` back\n * - `children` given as a function (or a promise of a graph) is called the first time it opens.\n * - Paths: how a node, a port or an edge is known.\n * - a node: its ids from the top graph, joined by `/` (`cpu/alu`)\n * - a port: its node's path, `:` and its id\n * - an edge: its graph's path, `#` and its id\n * - So ids should hold none of `/`, `:` or `#`.\n * - Pan: drag; zoom: the wheel, round the pointer; fit: the toolbar's button, and by itself on a new graph.\n * - `path` (`a/b`): the node drilled to.\n * - Set it to drill there.\n * - A drill (double-click a node with children, or its toggle with `child-view=\"drill\"`) or a breadcrumb\n * sets it back, and sends `ui-changed` `{ kind: 'path', path }`.\n * - Click a node, an edge or a port to select it: `ui-selecting` (cancelable), then `ui-changed`.\n * Hovering an edge lights it and its two ends; hovering a node lights its edges.\n * - Text is measured in the graph's real font (`TreeMeasure`, the canvas the tree diagram measures with);\n * a static server render estimates from character counts.\n * - Spell UI's other drawings of boxes and lines, so nobody builds a fourth:\n * - `<ui-tree-diagram>`: a TREE, each node's children under (or beside) it\n * - `<ui-diagram>`: boxes in COLUMNS and the links between them, the NERD drawing, boxes dragged by hand\n * - this one: any GRAPH, cycles too, in layers left to right, with ports on the boxes' sides, wires between\n * them and nested graphs, panned and zoomed\n ****************/\nexport class UIGraph extends E.UIComponent<typeof graphVocabulary> {\n @E.proto static vocabulary = graphVocabulary\n @E.protoMerged static elementSetup = {\n styleSheets: { graph: graphCSS },\n delegatesFocus: false,\n DOMElement: DOMGraphElement\n } satisfies Partial<E.ElementSetup>\n\n ////////////////\n // ## Hooks: a subclass overrides these to restyle and relabel\n ////////////////\n\n /** A node's text. */\n nodeLabel(node: GraphNode): string {\n return node.label ?? node.id\n }\n\n /** Extra classes on a node's `<g>`; `kind-<kind>` is there already. */\n nodeClass(_node: GraphNode): string | undefined {\n return undefined\n }\n\n /** An edge's text, at its middle; none: no text. */\n edgeLabel(edge: GraphEdge): string | undefined {\n return edge.label\n }\n\n /** Extra classes on an edge's `<path>`. */\n edgeClass(_edge: GraphEdge): string | undefined {\n return undefined\n }\n\n /** A port's text, beside it inside its node. */\n portLabel(port: GraphPort, _node: GraphNode): string | undefined {\n return port.label\n }\n\n /** Extra classes on a port's `<g>`. */\n portClass(_port: GraphPort, _node: GraphNode): string | undefined {\n return undefined\n }\n\n /** The sizes the layout works in; a subclass may make its boxes taller, its layers wider apart ... */\n get metrics(): typeof GRAPH_METRICS {\n return GRAPH_METRICS\n }\n\n /**\n * The breadcrumbs, top first: each one's text, and what picking it does.\n * - None (or one): no breadcrumbs.\n * - Default: the top, then each node drilled into.\n * A subclass that shows its own levels gives its own trail.\n */\n trail(): { label: string; pick: () => void }[] {\n if (!this.drillPaths.length) return []\n return [\n { label: this.translationForKey(\"graphTop\"), pick: () => this.goToDrill(0) },\n ...this.drillPaths.map((path, index) => {\n const node = this.nodeAt(path)\n return { label: node ? this.nodeLabel(node) : path, pick: () => this.goToDrill(index + 1) }\n })\n ]\n }\n\n /** The least zoom Fit goes to: a graph bigger than that shows its start, the rest a pan away. `0`: no least. */\n get minFitZoom(): number {\n return 0\n }\n\n /** More buttons in the toolbar, before Fit. */\n toolButtons(): JSX.Element {\n return undefined\n }\n\n /** Something drawn over the canvas (a legend ...), positioned by the subclass's own sheet. */\n overlay(): JSX.Element {\n return undefined\n }\n\n /** A node was double-clicked: drilled into, when it has children. */\n nodeDoubleClicked(placed: GraphPlacedNode, event: MouseEvent) {\n if (placed.hasChildren) void this.openNode(placed.path, \"drill\", event)\n }\n\n /** The detail of the `ui-changed` a selection sends. */\n changedDetail(selection: GraphSelection, item: object, originalEvent: Event): object {\n return { value: selection, ...selection, item, originalEvent }\n }\n\n /**\n * What a node's `<g>` holds: its box and label; the ports and toggle are drawn after it.\n * - Override to draw a node another way; stay inside `placed`'s box, as the layout sized it.\n */\n renderNode(placed: GraphPlacedNode): JSX.Element {\n const { fontSize } = GRAPH_METRICS\n const { x, y, width, height, isOpen } = placed\n const label = this.nodeLabel(placed.node)\n return (\n <>\n <rect class={BOX_CLASS} x={x} y={y} width={width} height={height} />\n <text\n class={LABEL_CLASS}\n x={\n isOpen\n ? x + GRAPH_METRICS.paddingX\n : x + width / 2 - (placed.hasChildren ? GRAPH_METRICS.toggleWidth / 2 : 0)\n }\n y={isOpen ? y + GRAPH_METRICS.headerHeight / 2 : y + height / 2}\n text-anchor={isOpen ? \"start\" : \"middle\"}\n font-size={String(fontSize)}\n >\n {placed.isLoading ? `${label} ${this.translationForKey(\"graphLoading\")}` : label}\n </text>\n </>\n )\n }\n\n ////////////////\n // ## The graph shown\n ////////////////\n\n /** Children loaded from a function or promise, by the node's path. */\n @E.state accessor loadedChildren: ReadonlyMap<string, GraphData> = new Map()\n /** Paths whose children are loading. */\n @E.state accessor loadingPaths: ReadonlySet<string> = new Set()\n /** Paths of nodes open in place. */\n @E.state accessor openPaths: ReadonlySet<string> = new Set()\n /** The nodes drilled into, outermost first. */\n @E.state accessor drillPaths: readonly string[] = []\n /** The node whose children the modal shows. */\n @E.state accessor modalPath: string | undefined = undefined\n\n /** The `graph` property, checked; `undefined`: nothing to draw. */\n get topGraph(): GraphData | undefined {\n return UIGraph.graphFrom(this.graph)\n }\n\n /** The node at `path`, from the top; `undefined` when there's none, or its graph isn't loaded. */\n nodeAt(path: string): GraphNode | undefined {\n let graph = this.topGraph\n let at = \"\"\n let node: GraphNode | undefined\n for (const id of path.split(\"/\")) {\n if (!graph) return undefined\n node = graph.nodes.find((each) => each?.id === id)\n if (!node) return undefined\n at = at ? `${at}/${id}` : id\n graph = this.childrenOf(node, at)\n }\n return node\n }\n\n /** `node`'s child graph, when it's there: given as a graph, or loaded. */\n childrenOf(node: GraphNode, path: string): GraphData | undefined {\n const children = node.children\n if (children && typeof children === \"object\") return UIGraph.graphFrom(children)\n return this.loadedChildren.get(path)\n }\n\n /** The node drilled into last; `undefined` at the top. */\n get drillPath(): string | undefined {\n return this.drillPaths.at(-1)\n }\n\n /** The graph drawn: the top's, or the children of the node drilled into. */\n @E.derived\n get shownGraph(): GraphData | undefined {\n const path = this.drillPath\n if (path === undefined) return this.topGraph\n const node = this.nodeAt(path)\n return node && this.childrenOf(node, path)\n }\n\n /** The ports drawn as pins round the graph shown. */\n get shownBoundary(): readonly GraphPort[] {\n const path = this.drillPath\n if (path !== undefined) return this.nodeAt(path)?.ports ?? []\n return Array.isArray(this.boundary) ? (this.boundary as GraphPort[]) : []\n }\n\n /** The graph laid out; `undefined` with nothing to draw. `@derived`: lays out every node. */\n @E.derived\n get layout(): GraphLayoutResult | undefined {\n const graph = this.shownGraph\n if (!graph) return undefined\n const openChildren = new Map<string, GraphData>()\n for (const path of this.openPaths) {\n const node = this.nodeAt(path)\n const children = node && this.childrenOf(node, path)\n if (children) openChildren.set(path, children)\n }\n return GraphLayout.of(graph, {\n metrics: this.metrics,\n prefix: this.drillPath ?? \"\",\n openChildren,\n loading: this.loadingPaths,\n boundary: this.shownBoundary,\n label: (node) => this.nodeLabel(node),\n textWidth: isServer ? undefined : (text, size) => UIGraph.measure(text, size, this.fontFamily)\n })\n }\n\n /** The font the labels are drawn in, read once: what they're measured in. */\n @E.lazy\n private get fontFamily(): string {\n return getComputedStyle(this.domElement).fontFamily || \"sans-serif\"\n }\n\n /** The containers first (they're behind), then the boxes. */\n private get containers(): readonly GraphPlacedNode[] {\n return this.layout?.nodes.filter((placed) => placed.isOpen) ?? []\n }\n\n private get leaves(): readonly GraphPlacedNode[] {\n return this.layout?.nodes.filter((placed) => !placed.isOpen) ?? []\n }\n\n ////////////////\n // ## Opening and closing\n ////////////////\n\n /** Open the node at `path`: its children loaded first, then shown as `view`. */\n async openNode(path: string, view?: GraphChildView, originalEvent?: Event): Promise<void> {\n const node = this.nodeAt(path)\n if (!node?.children) return\n const how = view ?? UIGraph.viewFrom(node.childView) ?? UIGraph.viewFrom(this.childView) ?? \"inline\"\n if (!(await this.load(node, path))) return\n if (how === \"inline\") this.openPaths = new Set(this.openPaths).add(path)\n else if (how === \"modal\") this.modalPath = path\n else {\n this.drillPaths = [...this.drillPaths, path]\n this.needsFit = true\n this.drilled(originalEvent)\n }\n this.send(\"ui-node-toggled\", { node, path, open: true, view: how, originalEvent })\n }\n\n /** Close the node at `path`: in place, with every node open inside it; drilled into, back above it. */\n closeNode(path: string, originalEvent?: Event) {\n const node = this.nodeAt(path)\n const drilled = this.drillPaths.indexOf(path)\n if (drilled >= 0) {\n this.drillPaths = this.drillPaths.slice(0, drilled)\n this.needsFit = true\n this.drilled(originalEvent)\n } else {\n this.openPaths = new Set([...this.openPaths].filter((each) => each !== path && !each.startsWith(`${path}/`)))\n }\n if (node)\n this.send(\"ui-node-toggled\", { node, path, open: false, view: drilled >= 0 ? \"drill\" : \"inline\", originalEvent })\n }\n\n /** Show the graph inside the node at `path`; none: the top. */\n async drillTo(path?: string): Promise<void> {\n if (!path) {\n this.goToDrill(0)\n return\n }\n await this.openNode(path, \"drill\")\n }\n\n /** Back up to `depth` nodes drilled into (`0`: the top). */\n goToDrill(depth: number, originalEvent?: Event) {\n if (depth >= this.drillPaths.length) return\n this.drillPaths = this.drillPaths.slice(0, depth)\n this.needsFit = true\n this.drilled(originalEvent)\n }\n\n /** The graph shown changed by a drill: `path` follows, and `ui-changed` `{ kind: 'path', path }` says so. */\n private drilled(originalEvent?: Event) {\n const path = this.drillPath ?? \"\"\n if (path === (this.path ?? \"\")) return\n this.path = path as never\n this.send(\"ui-changed\", { kind: \"path\", path, originalEvent })\n }\n\n /** `path` was set: drill to it. */\n @E.onChange(\"path\")\n protected onPathChanged(path: string | undefined) {\n void this.applyPath(path ?? \"\")\n }\n\n /**\n * Show the graph inside the node at `path`, drilling through each node on the way and loading lazy children.\n * - `path`: `a/b`; `\"\"`: the top.\n * - Sends nothing: the page asked for it.\n * - A subclass with a path of its own overrides it.\n */\n async applyPath(path: string): Promise<void> {\n if (path === (this.drillPath ?? \"\")) return\n const ids = path ? path.split(\"/\") : []\n const trail: string[] = []\n for (let at = 0; at < ids.length; at++) {\n const prefix = ids.slice(0, at + 1).join(\"/\")\n const node = this.nodeAt(prefix)\n if (!node?.children) break\n if (!(await this.load(node, prefix))) break\n trail.push(prefix)\n }\n this.drillPaths = trail\n this.needsFit = true\n }\n\n /** `node`'s children, loaded if they're a function or a promise; false when they failed. */\n protected async load(node: GraphNode, path: string): Promise<boolean> {\n if (typeof node.children !== \"function\" || this.loadedChildren.has(path)) return true\n this.loadingPaths = new Set(this.loadingPaths).add(path)\n try {\n const graph = UIGraph.graphFrom(await node.children())\n if (!graph) return false\n this.loadedChildren = new Map(this.loadedChildren).set(path, graph)\n return true\n } catch (error) {\n E.Warnings.warn(`<${this.domElement.localName}>`, `${path}'s children failed to load`, error)\n return false\n } finally {\n const loading = new Set(this.loadingPaths)\n loading.delete(path)\n this.loadingPaths = loading\n }\n }\n\n /** A toggle was pressed. */\n @E.untracked\n private toggle(placed: GraphPlacedNode, event: Event) {\n event.stopPropagation()\n if (placed.isOpen) this.closeNode(placed.path, event)\n else void this.openNode(placed.path, undefined, event)\n }\n\n /** `drilled`: it shows a node's children. */\n @E.cssState(\"drilled\")\n get isDrilled(): boolean {\n return this.drillPaths.length > 0\n }\n\n ////////////////\n // ## Selection and hover\n ////////////////\n\n /** The path hovered: a node's, an edge's or a port's. */\n @E.state accessor hovered: { kind: GraphSelection[\"kind\"]; path: string } | undefined = undefined\n\n /** The paths lit: the hovered edge and its ends, or the hovered node and its edges. `@derived`: walks the edges. */\n @E.derived\n get lit(): ReadonlySet<string> {\n const lit = new Set<string>()\n const hovered = this.hovered\n const layout = this.layout\n if (!hovered || !layout) return lit\n lit.add(hovered.path)\n const nodeOf = (path: string) => path.split(\":\")[0]\n for (const edge of layout.edges) {\n const isIt =\n hovered.kind === \"edge\"\n ? edge.path === hovered.path\n : hovered.kind === \"port\"\n ? edge.fromPath === hovered.path || edge.toPath === hovered.path\n : nodeOf(edge.fromPath) === hovered.path || nodeOf(edge.toPath) === hovered.path\n if (!isIt) continue\n lit.add(edge.path)\n for (const end of [edge.fromPath, edge.toPath]) {\n lit.add(end)\n lit.add(nodeOf(end))\n }\n }\n return lit\n }\n\n /** The selected path; `undefined`: nothing. */\n get selectedPath(): string | undefined {\n const selected = this.selected as GraphSelection | undefined\n return selected && typeof selected === \"object\" ? selected.path : undefined\n }\n\n /** Select `selection`: `ui-selecting` (a page may cancel it), then `selected`, then `ui-changed`. */\n @E.untracked\n protected choose(selection: GraphSelection, item: object, originalEvent: Event) {\n originalEvent.stopPropagation()\n if (this.wasDragged) return\n if (!this.send(\"ui-selecting\", { ...selection, item, originalEvent })) return\n this.selected = selection as never\n this.send(\"ui-changed\", this.changedDetail(selection, item, originalEvent))\n }\n\n ////////////////\n // ## Pan, zoom and fit\n ////////////////\n\n /** The view: a shift in pixels, then a scale. */\n @E.state accessor view = { x: 0, y: 0, k: 1 }\n /** A drag is moving the view. */\n @E.state accessor isPanning = false\n /** The next layout is fitted to the view: a new graph, or a drill. */\n protected needsFit = true\n /** The view was last set by a fit, not by a person: a change of size fits again. */\n private isFitted = false\n /** The last pointer press moved far enough to be a drag: its click selects nothing. */\n private wasDragged = false\n /** The `<svg>`. Set as it draws. */\n private svg: SVGSVGElement | undefined\n\n @E.cssState(\"panning\")\n get isPanningNow(): boolean {\n return this.isPanning\n }\n\n /** Fit the drawing to the view: all of it, at most one and a half times its size. */\n @E.untracked\n fit() {\n const layout = this.layout\n // Its own size, not its drawn one: a modal opening scales it with a transform.\n const box = this.svg && { width: this.svg.clientWidth, height: this.svg.clientHeight }\n if (!layout || !box?.width || !box.height) return\n const k = Math.max(this.minFitZoom, Math.min(box.width / layout.width, box.height / layout.height, 1.5))\n // Centred, too big or not.\n // Too big at the least zoom: its middle shows, the rest a pan away\n // (the middle is where the nodes are; its edges are often empty pins and margins).\n const along = (room: number, size: number) => (room - size * k) / 2\n this.view = { x: along(box.width, layout.width), y: along(box.height, layout.height), k }\n this.isFitted = true\n }\n\n /** A new graph: fit it. */\n @E.onChange(\"graph\")\n protected onGraphChanged() {\n this.needsFit = true\n this.drillPaths = []\n this.openPaths = new Set(UIGraph.startOpen(this.topGraph))\n if (this.path) void this.applyPath(String(this.path))\n }\n\n /** Fit when asked to, once the drawing's there. */\n @E.onChange(\"layout\", \"isReady\")\n protected onLayoutChanged(layout: GraphLayoutResult | undefined, isReady: boolean) {\n if (!isReady || !layout || !this.needsFit || !this.svg?.getBoundingClientRect().width) return\n this.needsFit = false\n this.fit()\n }\n\n /** While it's in the page: fit again when it first gets a size. */\n @E.whileConnected\n protected watchSize() {\n const observer = new ResizeObserver(() => {\n if (this.needsFit || this.isFitted) this.fit()\n if (this.svg?.getBoundingClientRect().width) this.needsFit = false\n })\n if (this.svg) observer.observe(this.svg)\n return () => observer.disconnect()\n }\n\n private readonly onWheel = (event: WheelEvent) => {\n if (!this.svg) return\n event.preventDefault()\n const box = this.svg.getBoundingClientRect()\n const px = event.clientX - box.left\n const py = event.clientY - box.top\n const { x, y, k } = this.view\n const next = Math.min(4, Math.max(0.05, k * Math.exp(-event.deltaY * (event.ctrlKey ? 0.01 : 0.0015))))\n this.view = { x: px - ((px - x) * next) / k, y: py - ((py - y) * next) / k, k: next }\n this.isFitted = false\n }\n\n private readonly onPointerDown = (event: PointerEvent) => {\n if (event.button !== 0 || !this.svg) return\n const svg = this.svg\n const start = { x: event.clientX, y: event.clientY, view: this.view }\n this.wasDragged = false\n const move = (moved: PointerEvent) => {\n const dx = moved.clientX - start.x\n const dy = moved.clientY - start.y\n if (!this.wasDragged && Math.hypot(dx, dy) < DRAG_DISTANCE) return\n if (!this.wasDragged) {\n this.wasDragged = true\n this.isFitted = false\n this.isPanning = true\n svg.setPointerCapture(event.pointerId)\n }\n this.view = { ...start.view, x: start.view.x + dx, y: start.view.y + dy }\n }\n const up = () => {\n svg.removeEventListener(\"pointermove\", move)\n svg.removeEventListener(\"pointerup\", up)\n svg.removeEventListener(\"pointercancel\", up)\n this.isPanning = false\n // The click after a drag comes next: forget the drag after it.\n E.soon(() => (this.wasDragged = false))\n }\n svg.addEventListener(\"pointermove\", move)\n svg.addEventListener(\"pointerup\", up)\n svg.addEventListener(\"pointercancel\", up)\n }\n\n /** A click on the background clears the selection. */\n private readonly onBackgroundClick = (event: MouseEvent) => {\n if (this.wasDragged || !this.selected) return\n this.selected = undefined as never\n this.send(\"ui-changed\", { value: undefined, originalEvent: event })\n }\n\n ////////////////\n // ## The modal\n ////////////////\n\n /** The modal's box the child graph goes in. Set as it draws. */\n private modalBody: HTMLElement | undefined\n\n /** The modal shows the children of `modalPath`: in a new graph of this same tag (so a subclass's look carries). */\n @E.onChange(\"modalPath\", \"isReady\")\n protected onModalPathChanged(path: string | undefined, isReady: boolean) {\n if (!isReady || !this.modalBody) return\n if (path === undefined) {\n this.modalBody.replaceChildren()\n return\n }\n const node = this.nodeAt(path)\n const graph = node && this.childrenOf(node, path)\n const inner = document.createElement(this.domElement.localName) as HTMLElement & {\n graph?: GraphData\n boundary?: readonly GraphPort[]\n }\n inner.graph = graph\n inner.boundary = node?.ports ?? []\n if (this.childView) inner.setAttribute(\"child-view\", String(this.childView))\n inner.classList.add(MODAL_GRAPH_CLASS)\n // Set on the element, as a page would: a sheet here never declares a public token (Spell UI's AGENTS.md, \"CSS\")\n inner.style.setProperty(\"--ui-graph-height\", MODAL_GRAPH_HEIGHT)\n this.modalBody.replaceChildren(inner)\n }\n\n /** The modal closed. */\n @E.on(\"ui-closed\", { target: \"renderRoot\" })\n protected onModalClosed(event: Event) {\n if (event.target === this.modalElement) this.modalPath = undefined\n }\n\n private modalElement: HTMLElement | undefined\n\n ////////////////\n // ## Drawing\n ////////////////\n\n protected override get extraClass(): string | undefined {\n return this.topGraph ? undefined : EMPTY\n }\n\n render(): JSX.Element {\n return (\n <div class={this.rootClass} part={this.partForName(\"graph\")}>\n <Show when={this.trail().length > 1}>{this.breadcrumbs()}</Show>\n <div class={TOOLBAR_CLASS} part={this.partForName(\"toolbar\")}>\n {this.toolButtons()}\n <button type=\"button\" onClick={() => this.fit()}>\n {this.translationForKey(\"graphFit\")}\n </button>\n </div>\n {this.overlay()}\n <svg\n ref={(svg: SVGSVGElement) => (this.svg = svg)}\n class={CANVAS_CLASS}\n part={this.partForName(\"canvas\")}\n role=\"group\"\n aria-label={this.translationForKey(\"graphSummary\", { count: this.layout?.nodes.length ?? 0 })}\n onWheel={this.onWheel}\n onPointerDown={this.onPointerDown}\n onClick={this.onBackgroundClick}\n >\n <g transform={`translate(${this.view.x} ${this.view.y}) scale(${this.view.k})`}>\n <For each={this.containers}>{(placed) => this.node(placed)}</For>\n <For each={this.layout?.edges ?? []}>{(edge) => this.edge(edge)}</For>\n <For each={this.leaves}>{(placed) => this.node(placed)}</For>\n <For each={this.layout?.pins ?? []}>{(pin) => this.pin(pin)}</For>\n </g>\n </svg>\n <ui-modal\n ref={(element: HTMLElement) => (this.modalElement = element)}\n size=\"large\"\n closable=\"\"\n heading={this.modalHeading()}\n visible={this.modalPath !== undefined ? \"\" : undefined}\n >\n <div ref={(div: HTMLElement) => (this.modalBody = div)} class={MODAL_BODY_CLASS} />\n </ui-modal>\n </div>\n )\n }\n\n /** The modal's heading: the node's label. */\n private modalHeading(): string | undefined {\n const path = this.modalPath\n const node = path === undefined ? undefined : this.nodeAt(path)\n return node && this.nodeLabel(node)\n }\n\n /** The trail back up (`trail()`), when there's one. */\n private breadcrumbs(): JSX.Element {\n return (\n <ui-breadcrumbs class={BREADCRUMBS_CLASS} part={this.partForName(\"breadcrumbs\")} divider=\"›\">\n <For each={this.trail()}>\n {(crumb, index) => (\n <ui-breadcrumb\n selected={index() === this.trail().length - 1 ? \"\" : undefined}\n onClick={() => {\n if (index() !== this.trail().length - 1) crumb.pick()\n }}\n >\n {crumb.label}\n </ui-breadcrumb>\n )}\n </For>\n </ui-breadcrumbs>\n )\n }\n\n /** One node: its `<g>` (part `node`, a container's also `container`), what `renderNode()` draws, ports, toggle. */\n private node(placed: GraphPlacedNode): JSX.Element {\n const kind = UIGraph.wordFor(placed.node.kind)\n const path = placed.path\n return (\n <g\n class={[\n NODE_CLASS,\n kind && `kind-${kind}`,\n this.nodeClass(placed.node),\n {\n [CONTAINER_CLASS]: placed.isOpen,\n [LIT_CLASS]: this.lit.has(path),\n [SELECTED_CLASS]: this.selectedPath === path,\n [LOADING_CLASS]: !!placed.isLoading\n }\n ]}\n part={[this.partForName(\"node\"), placed.isOpen && this.partForName(\"container\"), kind && `kind-${kind}`]\n .filter(Boolean)\n .join(\" \")}\n data-path={path}\n onClick={(event: MouseEvent) => this.choose({ kind: \"node\", id: placed.node.id, path }, placed.node, event)}\n onDblClick={(event: MouseEvent) => {\n event.stopPropagation()\n this.nodeDoubleClicked(placed, event)\n }}\n onPointerEnter={() => (this.hovered = { kind: \"node\", path })}\n onPointerLeave={() => this.unhover(path)}\n >\n <Show when={placed.node.title}>{(title) => <title>{title()}</title>}</Show>\n {this.renderNode(placed)}\n <For each={placed.ports}>{(port) => this.port(port, placed)}</For>\n <Show when={placed.hasChildren}>{this.toggleButton(placed)}</Show>\n </g>\n )\n }\n\n /** A node's open / close button (part `toggle`), at its top right. */\n private toggleButton(placed: GraphPlacedNode): JSX.Element {\n const label = () =>\n this.translationForKey(placed.isOpen ? \"graphCloseNode\" : \"graphOpenNode\", { label: this.nodeLabel(placed.node) })\n const cx = placed.x + placed.width - GRAPH_METRICS.toggleWidth / 2 - 4\n const cy = placed.isOpen ? placed.y + GRAPH_METRICS.headerHeight / 2 : placed.y + placed.height / 2\n return (\n <g\n class={TOGGLE_CLASS}\n part={this.partForName(\"toggle\")}\n role=\"button\"\n tabindex=\"0\"\n aria-expanded={placed.isOpen ? \"true\" : \"false\"}\n aria-label={label()}\n transform={`translate(${cx} ${cy})`}\n onClick={(event: MouseEvent) => this.toggle(placed, event)}\n onDblClick={(event: MouseEvent) => event.stopPropagation()}\n onKeyDown={(event: KeyboardEvent) => {\n if (event.key !== UIT.Key.enter && event.key !== UIT.Key.space) return\n event.preventDefault()\n this.toggle(placed, event)\n }}\n >\n <title>{label()}</title>\n <circle class={TOGGLE_TARGET_CLASS} r={10} />\n <circle class={TOGGLE_CIRCLE_CLASS} r={6} />\n <path class={TOGGLE_MARK_CLASS} d={placed.isOpen ? MINUS_MARK : PLUS_MARK} />\n </g>\n )\n }\n\n /** A port: its dot and label (part `port`). */\n private port(placed: GraphPlacedPort, owner: GraphPlacedNode): JSX.Element {\n const kind = UIGraph.wordFor(placed.port.kind)\n const label = this.portLabel(placed.port, owner.node)\n const r = GRAPH_METRICS.portRadius\n const labelAt =\n placed.side === \"left\"\n ? { x: placed.x + r + 3, y: placed.y, anchor: \"start\" as const }\n : placed.side === \"right\"\n ? { x: placed.x - r - 3, y: placed.y, anchor: \"end\" as const }\n : { x: placed.x, y: placed.side === \"top\" ? placed.y + r + 7 : placed.y - r - 7, anchor: \"middle\" as const }\n return (\n <g\n class={[\n PORT_CLASS,\n kind && `kind-${kind}`,\n this.portClass(placed.port, owner.node),\n { [LIT_CLASS]: this.lit.has(placed.path), [SELECTED_CLASS]: this.selectedPath === placed.path }\n ]}\n part={[this.partForName(\"port\"), kind && `kind-${kind}`].filter(Boolean).join(\" \")}\n onClick={(event: MouseEvent) =>\n this.choose({ kind: \"port\", id: placed.port.id, path: placed.path }, placed.port, event)\n }\n onPointerEnter={(event: PointerEvent) => {\n event.stopPropagation()\n this.hovered = { kind: \"port\", path: placed.path }\n }}\n onPointerLeave={() => (this.hovered = { kind: \"node\", path: owner.path })}\n >\n <circle class={PORT_DOT_CLASS} cx={placed.x} cy={placed.y} r={r} />\n <Show when={label && !(owner.isOpen && (placed.side === \"left\" || placed.side === \"right\"))}>\n <text\n class={PORT_LABEL_CLASS}\n x={labelAt.x}\n y={labelAt.y}\n text-anchor={labelAt.anchor}\n font-size={String(GRAPH_METRICS.portFontSize)}\n >\n {label}\n </text>\n </Show>\n </g>\n )\n }\n\n /** A pin: the enclosing node's port, on the graph's side (part `pin`). */\n private pin(pin: GraphPlacedPin): JSX.Element {\n const label = pin.port.label ?? pin.port.id\n return (\n <g\n class={[PIN_CLASS, { [LIT_CLASS]: this.lit.has(pin.path) }]}\n part={this.partForName(\"pin\")}\n onPointerEnter={() => (this.hovered = { kind: \"port\", path: pin.path })}\n onPointerLeave={() => this.unhover(pin.path)}\n onClick={(event: MouseEvent) => this.choose({ kind: \"port\", id: pin.port.id, path: pin.path }, pin.port, event)}\n >\n <path class={PIN_MARK_CLASS} d={`M${pin.x - 5} ${pin.y - 5}h10v10h-10z`} />\n <text\n class={PORT_LABEL_CLASS}\n x={pin.x}\n y={pin.y - 10}\n text-anchor=\"middle\"\n font-size={String(GRAPH_METRICS.portFontSize)}\n >\n {label}\n </text>\n </g>\n )\n }\n\n /** One edge: a wide unseen path to hit, the line (part `edge`), its label (part `edge-label`). */\n private edge(placed: GraphPlacedEdge): JSX.Element {\n const d = GraphLayout.pathFor(placed)\n const kind = UIGraph.wordFor(placed.edge.kind)\n const label = this.edgeLabel(placed.edge)\n const middle = GraphLayout.middleOf(placed)\n const select = (event: MouseEvent) =>\n this.choose({ kind: \"edge\", id: placed.id, path: placed.path }, placed.edge, event)\n return (\n <g\n class={[\n EDGE_GROUP_CLASS,\n kind && `kind-${kind}`,\n this.edgeClass(placed.edge),\n { [LIT_CLASS]: this.lit.has(placed.path), [SELECTED_CLASS]: this.selectedPath === placed.path }\n ]}\n onPointerEnter={() => (this.hovered = { kind: \"edge\", path: placed.path })}\n onPointerLeave={() => this.unhover(placed.path)}\n onClick={select}\n >\n <path class={EDGE_HIT_CLASS} d={d} />\n <path\n class={EDGE_CLASS}\n part={[this.partForName(\"edge\"), kind && `kind-${kind}`].filter(Boolean).join(\" \")}\n d={d}\n />\n <Show when={label}>\n <text\n class={EDGE_LABEL_CLASS}\n part={this.partForName(\"edge-label\")}\n x={middle.x}\n y={middle.y - 4}\n text-anchor=\"middle\"\n font-size={String(GRAPH_METRICS.portFontSize)}\n >\n {label}\n </text>\n </Show>\n </g>\n )\n }\n\n /** The pointer left `path`: nothing's hovered, unless something else already is. */\n private unhover(path: string) {\n if (this.hovered?.path === path) this.hovered = undefined\n }\n\n ////////////////\n // ## Helpers\n ////////////////\n\n /** `value` when it's a graph (an object with a `nodes` list); else `undefined`. */\n static graphFrom(value: unknown): GraphData | undefined {\n if (!value || typeof value !== \"object\" || !Array.isArray((value as GraphData).nodes)) return undefined\n const graph = value as GraphData\n return { nodes: graph.nodes, edges: Array.isArray(graph.edges) ? graph.edges : [] }\n }\n\n /** `value` when it's a child view's name. */\n private static viewFrom(value: unknown): GraphChildView | undefined {\n return GraphChildViews.includes(value as GraphChildView) ? (value as GraphChildView) : undefined\n }\n\n /** The paths of the nodes that start open (`open`), with given (not lazy) children, all the way down. */\n private static startOpen(graph: GraphData | undefined, prefix = \"\"): string[] {\n const paths: string[] = []\n for (const node of graph?.nodes ?? []) {\n const path = prefix ? `${prefix}/${node.id}` : node.id\n if (node.open && node.children && typeof node.children === \"object\") {\n paths.push(path, ...UIGraph.startOpen(UIGraph.graphFrom(node.children), path))\n }\n }\n return paths\n }\n\n /** `word` when it's safe in a class and a part name; else `undefined`. */\n private static wordFor(word: string | undefined): string | undefined {\n return word && /^[\\w-]+$/.test(word) ? word : undefined\n }\n\n /** `text`'s width at `size`, in `family`: measured on the page's one canvas (`TreeMeasure`), else estimated. */\n private static measure(text: string, size: number, family: string): number {\n return TreeMeasure.widthOf(text, `${size}px ${family}`) ?? text.length * size * GRAPH_METRICS.charWidth\n }\n}\n\n/** The vocabulary getters, typed (`UIComponent`'s doc). */\nexport interface UIGraph extends E.AttributeValues<typeof graphVocabulary> {}\n\n/** How far a press moves before it's a drag, in pixels. */\nconst DRAG_DISTANCE = 4\n\n/** Class word before the noun when there's nothing to draw (`ui empty graph`). */\nconst EMPTY = \"empty\"\n\nconst TOOLBAR_CLASS = \"toolbar\"\nconst BREADCRUMBS_CLASS = \"breadcrumbs\"\nconst CANVAS_CLASS = \"canvas\"\nconst NODE_CLASS = \"node\"\nconst CONTAINER_CLASS = \"container\"\nconst BOX_CLASS = \"box\"\nconst LABEL_CLASS = \"label\"\nconst PORT_CLASS = \"port\"\nconst PORT_DOT_CLASS = \"port-dot\"\nconst PORT_LABEL_CLASS = \"port-label\"\nconst PIN_CLASS = \"pin\"\nconst PIN_MARK_CLASS = \"pin-mark\"\nconst EDGE_GROUP_CLASS = \"edge-group\"\nconst EDGE_CLASS = \"edge\"\nconst EDGE_HIT_CLASS = \"edge-hit\"\nconst EDGE_LABEL_CLASS = \"edge-label\"\nconst LIT_CLASS = \"lit\"\nconst SELECTED_CLASS = \"selected\"\nconst LOADING_CLASS = \"loading\"\nconst TOGGLE_CLASS = \"toggle\"\nconst TOGGLE_TARGET_CLASS = \"toggle-target\"\nconst TOGGLE_CIRCLE_CLASS = \"toggle-circle\"\nconst TOGGLE_MARK_CLASS = \"toggle-mark\"\nconst MODAL_BODY_CLASS = \"modal-graph-box\"\n/** The class of the graph in the modal, for a page's or a subclass's own sheet. */\nconst MODAL_GRAPH_CLASS = \"modal-graph\"\n/** How tall the graph in the modal is. */\nconst MODAL_GRAPH_HEIGHT = \"70vh\"\n\n/** The toggle's `+` and `-`. */\nconst PLUS_MARK = \"M-3 0H3M0 -3V3\"\nconst MINUS_MARK = \"M-3 0H3\"\n","/**\n * The graph family: defines `<ui-graph>`, and exports its component.\n * - SIDE EFFECT: importing it defines the tag, and `<ui-modal>` and `<ui-breadcrumbs>` (what it shows children in).\n * - Also the library's `spell/ui/ui-graph` entry.\n * - `GraphLayout` (the pure layout) is exported too, for a page that wants the numbers alone.\n */\n\nimport { GraphLayout } from \"./GraphLayout\"\nimport { DOMGraphElement, UIGraph } from \"./UIGraph\"\n\nimport \"spell/ui/components/ui-modal\"\nimport \"spell/ui/components/ui-breadcrumbs\"\n\nUIGraph.define()\n\nexport { DOMGraphElement, GraphLayout, UIGraph }\nexport { GRAPH_METRICS, GraphChildViews, GraphPortSides } from \"./UIGraph.types\"\nexport type {\n GraphChildren,\n GraphChildView,\n GraphData,\n GraphEdge,\n GraphEnd,\n GraphLayoutOptions,\n GraphLayoutResult,\n GraphMetrics,\n GraphNode,\n GraphPlacedEdge,\n GraphPlacedNode,\n GraphPlacedPin,\n GraphPlacedPort,\n GraphPoint,\n GraphPort,\n GraphPortSide,\n GraphSelection\n} from \"./UIGraph.types\"\n"],"mappings":";;;;;;;;AAmFA,IAAagG,KAAiB;CAAC;CAAQ;CAAS;CAAO;AAAQ,GAIlDC,IAAkB;CAAC;CAAU;CAAS;AAAO,GAuG7CC,IAAgB;CAC3B,UAAU;CACV,cAAc;CAEd,WAAW;CACX,UAAU;CACV,YAAY;CACZ,cAAc;CAEd,aAAa;CACb,YAAY;CAEZ,UAAU;CAEV,SAAS;CAET,cAAc;CACd,kBAAkB;CAElB,aAAa;CACb,QAAQ;AACV,GClLaC,IAAb,MAAa,YAAY;CAEvB,OAAO,GAAG,GAAkB,IAA8B,CAAC,GAAsB;EAC/E,IAAMC,IAAS,IAAI,YAAYC,CAAO,GAChCC,IAASD,EAAQ,UAAU,IAC3BE,IAAQH,EAAO,MAAMI,GAAOF,GAAQD,EAAQ,YAAY,CAAC,CAAC,GAC1DI,IAA2B,CAAC,GAC5BC,IAA2B,CAAC,GAC5B,EAAE,cAAWN,EAAO;EAC1B,EAAO,QAAQG,GAAOI,GAAQA,GAAQ,GAAGF,GAAOC,CAAK;EACrD,IAAME,IAAyBL,EAAM,KAAK,KAAK,OAAS;GACtD,MAAMM,EAAI;GACV,MAAMA,EAAI;GACV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AO,gBAAtBH,IAFWc,CAAA,GAANjL,EAAAsK,GAAMW,CAAA,GAAsDxL,EAAAwL,GAAA,SAAA,GACxDpL,EADEoL,GACK,cAAahL,EAApBqK,GAAA,IADEW,GACkBnD,EAAA,CAAA,GAApB7H,EAAAqK,GAAA,IADEW,CAAA,GAEIpL,EAFJoL,GAEW,gBAAehL,EAAtBqK,GAAA,IAFJW,GAE0B;CACnC,aAAa,EAAE,OAAOvL,GAAS;CAC/B,gBAAgB;CAChB,YAAY;AACd,CAAA,CAAA,GAJeO,EAAAqK,GAAA,IAFJW,CAAA;AAAN,IAAM+J,KAAN/J,GA20BDsB,KAAgB,GAGhB8C,KAAQ,SAERoB,KAAgB,WAChBa,KAAoB,eACpBZ,KAAe,UACfqB,KAAa,QACbC,KAAkB,aAClB/E,KAAY,OACZQ,KAAc,SACdiG,KAAa,QACbC,KAAiB,YACjBH,IAAmB,cACnBQ,KAAY,OACZC,KAAiB,YACjBS,KAAmB,cACnBE,KAAa,QACbD,KAAiB,YACjBF,KAAmB,cACnBxC,IAAY,OACZC,IAAiB,YACjBC,KAAgB,WAChBS,KAAe,UACfC,KAAsB,iBACtBC,KAAsB,iBACtBC,KAAoB,eACpBpC,KAAmB,mBAEnBxB,KAAoB,eAEpBC,KAAqB,QAGrB6D,KAAY,kBACZD,KAAa;;;;;;;A,IC57BnBgC,GAAQ,OAAO"}
|
|
1
|
+
{"version":3,"file":"ui-graph.js","names":["this","x={isOpen ? x + GRAPH_METRICS.paddingX : x + width / 2 - (placed.hasChildren ? GRAPH_METRICS.toggleWidth / 2 : 0)}","y={isOpen ? y + GRAPH_METRICS.headerHeight / 2 : y + height / 2}","font-size={String(fontSize)}","<Show when={this.trail().length > 1}>{this.breadcrumbs()}</Show>","<div class={this.rootClass} part={this.partForName(\"graph\")}>\n <Show when={this.trail().length > 1}>{this.breadcrumbs()}</Show>\n <div class={TOOLBAR_CLASS} part={this.partForName(\"toolbar\")}>\n {this.toolButtons()}\n <button type=\"button\" onClick={() => this.fit()}>\n {this.translationForKey(\"graphFit\")}\n </button>\n </div>\n {this.overlay()}\n <svg\n ref={(svg) => this.svg = svg}\n class={CANVAS_CLASS}\n part={this.partForName(\"canvas\")}\n role=\"group\"\n aria-label={this.translationForKey(\"graphSummary\", { count: this.layout?.nodes.length ?? 0 })}\n onWheel={this.onWheel}\n onPointerDown={this.onPointerDown}\n onClick={this.onBackgroundClick}\n >\n <g transform={`translate(${this.view.x} ${this.view.y}) scale(${this.view.k})`}>\n <For each={this.containers}>{(placed) => this.node(placed)}</For>\n <For each={this.layout?.edges ?? []}>{(edge) => this.edge(edge)}</For>\n <For each={this.leaves}>{(placed) => this.node(placed)}</For>\n <For each={this.layout?.pins ?? []}>{(pin) => this.pin(pin)}</For>\n </g>\n </svg>\n <ui-modal\n ref={(element) => this.modalElement = element}\n size=\"large\"\n closable=\"\"\n heading={this.modalHeading()}\n visible={this.modalPath !== void 0 ? \"\" : void 0}\n >\n <div ref={(div) => this.modalBody = div} class={MODAL_BODY_CLASS} />\n </ui-modal>\n </div>","<div class={TOOLBAR_CLASS} part={this.partForName(\"toolbar\")}>\n {this.toolButtons()}\n <button type=\"button\" onClick={() => this.fit()}>\n {this.translationForKey(\"graphFit\")}\n </button>\n </div>","ref={(svg) => this.svg = svg}","<For each={this.containers}>{(placed) => this.node(placed)}</For>","<g transform={`translate(${this.view.x} ${this.view.y}) scale(${this.view.k})`}>\n <For each={this.containers}>{(placed) => this.node(placed)}</For>\n <For each={this.layout?.edges ?? []}>{(edge) => this.edge(edge)}</For>\n <For each={this.leaves}>{(placed) => this.node(placed)}</For>\n <For each={this.layout?.pins ?? []}>{(pin) => this.pin(pin)}</For>\n </g>","<For each={this.layout?.edges ?? []}>{(edge) => this.edge(edge)}</For>","<For each={this.leaves}>{(placed) => this.node(placed)}</For>","<For each={this.layout?.pins ?? []}>{(pin) => this.pin(pin)}</For>","ref={(element) => this.modalElement = element}","ref={(div) => this.modalBody = div}","part={this.partForName(\"graph\")}","class={TOOLBAR_CLASS}","part={this.partForName(\"toolbar\")}","class={CANVAS_CLASS}","part={this.partForName(\"canvas\")}","aria-label={this.translationForKey(\"graphSummary\", { count: this.layout?.nodes.length ?? 0 })}","transform={`translate(${this.view.x} ${this.view.y}) scale(${this.view.k})`}","heading={this.modalHeading()}","visible={this.modalPath !== void 0 ? \"\" : void 0}","class={MODAL_BODY_CLASS}","<For each={this.trail()}>\n {(crumb, index) => <ui-breadcrumb\n selected={index() === this.trail().length - 1 ? \"\" : void 0}\n onClick={() => {\n if (index() !== this.trail().length - 1) crumb.pick();\n }}\n >\n {crumb.label}\n </ui-breadcrumb>}\n </For>","part={this.partForName(\"breadcrumbs\")}","<ui-breadcrumbs class={BREADCRUMBS_CLASS} part={this.partForName(\"breadcrumbs\")} divider=\"›\">\n <For each={this.trail()}>\n {(crumb, index) => <ui-breadcrumb\n selected={index() === this.trail().length - 1 ? \"\" : void 0}\n onClick={() => {\n if (index() !== this.trail().length - 1) crumb.pick();\n }}\n >\n {crumb.label}\n </ui-breadcrumb>}\n </For>\n </ui-breadcrumbs>","<Show when={placed.node.title}>{(title) => <title>{title()}</title>}</Show>","<g\n class={[\n NODE_CLASS,\n kind && `kind-${kind}`,\n this.nodeClass(placed.node),\n {\n [CONTAINER_CLASS]: placed.isOpen,\n [LIT_CLASS]: this.lit.has(path),\n [SELECTED_CLASS]: this.selectedPath === path,\n [LOADING_CLASS]: !!placed.isLoading\n }\n ]}\n part={[this.partForName(\"node\"), placed.isOpen && this.partForName(\"container\"), kind && `kind-${kind}`].filter(Boolean).join(\" \")}\n data-path={path}\n onClick={(event) => this.choose({ kind: \"node\", id: placed.node.id, path }, placed.node, event)}\n onDblClick={(event) => {\n event.stopPropagation();\n this.nodeDoubleClicked(placed, event);\n }}\n onPointerEnter={() => this.hovered = { kind: \"node\", path }}\n onPointerLeave={() => this.unhover(path)}\n >\n <Show when={placed.node.title}>{(title) => <title>{title()}</title>}</Show>\n {this.renderNode(placed)}\n <For each={placed.ports}>{(port) => this.port(port, placed)}</For>\n <Show when={placed.hasChildren}>{this.toggleButton(placed)}</Show>\n </g>","<For each={placed.ports}>{(port) => this.port(port, placed)}</For>","<Show when={placed.hasChildren}>{this.toggleButton(placed)}</Show>","part={[this.partForName(\"node\"), placed.isOpen && this.partForName(\"container\"), kind && `kind-${kind}`].filter(Boolean).join(\" \")}","part={this.partForName(\"toggle\")}","aria-expanded={placed.isOpen ? \"true\" : \"false\"}","aria-label={label()}","class={TOGGLE_TARGET_CLASS}","class={TOGGLE_CIRCLE_CLASS}","class={TOGGLE_MARK_CLASS}","d={placed.isOpen ? MINUS_MARK : PLUS_MARK}","<g\n class={TOGGLE_CLASS}\n part={this.partForName(\"toggle\")}\n role=\"button\"\n tabindex=\"0\"\n aria-expanded={placed.isOpen ? \"true\" : \"false\"}\n aria-label={label()}\n transform={`translate(${cx} ${cy})`}\n onClick={(event) => this.toggle(placed, event)}\n onDblClick={(event) => event.stopPropagation()}\n onKeyDown={(event) => {\n if (event.key !== UIT.Key.enter && event.key !== UIT.Key.space) return;\n event.preventDefault();\n this.toggle(placed, event);\n }}\n >\n <title>{label()}</title>\n <circle class={TOGGLE_TARGET_CLASS} r={10} />\n <circle class={TOGGLE_CIRCLE_CLASS} r={6} />\n <path class={TOGGLE_MARK_CLASS} d={placed.isOpen ? MINUS_MARK : PLUS_MARK} />\n </g>","<Show when={label && !(owner.isOpen && (placed.side === \"left\" || placed.side === \"right\"))}>\n <text\n class={PORT_LABEL_CLASS}\n x={labelAt.x}\n y={labelAt.y}\n text-anchor={labelAt.anchor}\n font-size={String(GRAPH_METRICS.portFontSize)}\n >\n {label}\n </text>\n </Show>","x={labelAt.x}","y={labelAt.y}","text-anchor={labelAt.anchor}","font-size={String(GRAPH_METRICS.portFontSize)}","<text\n class={PORT_LABEL_CLASS}\n x={labelAt.x}\n y={labelAt.y}\n text-anchor={labelAt.anchor}\n font-size={String(GRAPH_METRICS.portFontSize)}\n >\n {label}\n </text>","part={[this.partForName(\"port\"), kind && `kind-${kind}`].filter(Boolean).join(\" \")}","class={PORT_DOT_CLASS}","cx={placed.x}","cy={placed.y}","<g\n class={[\n PORT_CLASS,\n kind && `kind-${kind}`,\n this.portClass(placed.port, owner.node),\n { [LIT_CLASS]: this.lit.has(placed.path), [SELECTED_CLASS]: this.selectedPath === placed.path }\n ]}\n part={[this.partForName(\"port\"), kind && `kind-${kind}`].filter(Boolean).join(\" \")}\n onClick={(event) => this.choose({ kind: \"port\", id: placed.port.id, path: placed.path }, placed.port, event)}\n onPointerEnter={(event) => {\n event.stopPropagation();\n this.hovered = { kind: \"port\", path: placed.path };\n }}\n onPointerLeave={() => this.hovered = { kind: \"node\", path: owner.path }}\n >\n <circle class={PORT_DOT_CLASS} cx={placed.x} cy={placed.y} r={r} />\n <Show when={label && !(owner.isOpen && (placed.side === \"left\" || placed.side === \"right\"))}>\n <text\n class={PORT_LABEL_CLASS}\n x={labelAt.x}\n y={labelAt.y}\n text-anchor={labelAt.anchor}\n font-size={String(GRAPH_METRICS.portFontSize)}\n >\n {label}\n </text>\n </Show>\n </g>","part={this.partForName(\"pin\")}","class={PIN_MARK_CLASS}","d={`M${pin.x - 5} ${pin.y - 5}h10v10h-10z`}","class={PORT_LABEL_CLASS}","x={pin.x}","y={pin.y - 10}","<g\n class={[PIN_CLASS, { [LIT_CLASS]: this.lit.has(pin.path) }]}\n part={this.partForName(\"pin\")}\n onPointerEnter={() => this.hovered = { kind: \"port\", path: pin.path }}\n onPointerLeave={() => this.unhover(pin.path)}\n onClick={(event) => this.choose({ kind: \"port\", id: pin.port.id, path: pin.path }, pin.port, event)}\n >\n <path class={PIN_MARK_CLASS} d={`M${pin.x - 5} ${pin.y - 5}h10v10h-10z`} />\n <text\n class={PORT_LABEL_CLASS}\n x={pin.x}\n y={pin.y - 10}\n text-anchor=\"middle\"\n font-size={String(GRAPH_METRICS.portFontSize)}\n >\n {label}\n </text>\n </g>","<Show when={label}>\n <text\n class={EDGE_LABEL_CLASS}\n part={this.partForName(\"edge-label\")}\n x={middle.x}\n y={middle.y - 4}\n text-anchor=\"middle\"\n font-size={String(GRAPH_METRICS.portFontSize)}\n >\n {label}\n </text>\n </Show>","when={label}","part={this.partForName(\"edge-label\")}","x={middle.x}","y={middle.y - 4}","<text\n class={EDGE_LABEL_CLASS}\n part={this.partForName(\"edge-label\")}\n x={middle.x}\n y={middle.y - 4}\n text-anchor=\"middle\"\n font-size={String(GRAPH_METRICS.portFontSize)}\n >\n {label}\n </text>","class={EDGE_HIT_CLASS}","class={EDGE_CLASS}","part={[this.partForName(\"edge\"), kind && `kind-${kind}`].filter(Boolean).join(\" \")}","<g\n class={[\n EDGE_GROUP_CLASS,\n kind && `kind-${kind}`,\n this.edgeClass(placed.edge),\n { [LIT_CLASS]: this.lit.has(placed.path), [SELECTED_CLASS]: this.selectedPath === placed.path }\n ]}\n onPointerEnter={() => this.hovered = { kind: \"edge\", path: placed.path }}\n onPointerLeave={() => this.unhover(placed.path)}\n onClick={select}\n >\n <path class={EDGE_HIT_CLASS} d={d} />\n <path\n class={EDGE_CLASS}\n part={[this.partForName(\"edge\"), kind && `kind-${kind}`].filter(Boolean).join(\" \")}\n d={d}\n />\n <Show when={label}>\n <text\n class={EDGE_LABEL_CLASS}\n part={this.partForName(\"edge-label\")}\n x={middle.x}\n y={middle.y - 4}\n text-anchor=\"middle\"\n font-size={String(GRAPH_METRICS.portFontSize)}\n >\n {label}\n </text>\n </Show>\n </g>","E.DOMElement","E.UIComponent","E.proto","E.protoMerged","E.state","E.derived","E.lazy","E.onChange","E.untracked","E.cssState","E.whileConnected","E.on","_$readShallow","_$setAttribute","_$getOwner","__name","graphCSS","Key","__decoratorStart","__publicField","__name$1","__decorateElement","__decoratorMetadata","__runInitializers","__privateAdd","TreeMeasure","getOwner$1","GraphPortSides","GraphChildViews","GRAPH_METRICS","GraphLayout","layout","options","prefix","level","graph","nodes","edges","margin","pins","pin","edge","points","d","i","p","q","reach","forward","c1x","c1y","fromSide","c2x","c2y","toSide","side","point","port","kind","votes","text","fontSize","node","m","byId","units","end","id","tally","key","path","unit","boundary","inside","boundarySides","links","from","to","index","layerCount","link","a","b","layer","dummy","layers","order","u","v","uOffset","vOffset","placedEdges","levelPins","width","label","ports","sides","sideOf","hasChildren","childGraph","labelWidth","child","insetX","tall","wide","along","each","role","out","inDegree","between","state","root","stack","top","list","next","seen","succ","pred","queue","topo","nexts","last","offset","centre","near","sum","round","crossings","x","y","tallest","used","wanted","all","blocks","height","gapAfter","block","previous","weight","ux","uy","depth","graphPath","container","value","graphVocabulary","UIGraph_default","_tmpl$","_tmpl$2","_tmpl$3","_tmpl$4","_tmpl$5","_tmpl$6","_tmpl$7","_tmpl$8","_tmpl$9","_tmpl$10","_tmpl$11","_tmpl$12","_onModalClosed_dec","_onModalPathChanged_dec","_watchSize_dec","_onLayoutChanged_dec","_onGraphChanged_dec","_fit_dec","_isPanningNow_dec","_isPanning_dec","_view_dec","_choose_dec","_lit_dec","_hovered_dec","_isDrilled_dec","_toggle_dec","_onPathChanged_dec","_fontFamily_dec","_layout_dec","_shownGraph_dec","_modalPath_dec","_drillPaths_dec","_openPaths_dec","_loadingPaths_dec","_loadedChildren_dec","_elementSetup_dec","_vocabulary_dec","_a","_init","_loadedChildren","_loadingPaths","_openPaths","_drillPaths","_modalPath","_hovered","_view","_isPanning","DOMElement","view","_UIGraph","UIComponent","proto","protoMerged","derived","lazy","onChange","untracked","cssState","whileConnected","on","box","px","event","py","k","svg","start","move","dx","moved","dy","DRAG_DISTANCE","up","soon","placed","selection","_self$","_el$","setAttribute","effect","readShallow","BOX_CLASS","_v$","_$p","_el$2","isOpen","insert","_c$","memo","LABEL_CLASS","className","_p$","o","at","children","openChildren","isServer","size","how","originalEvent","drilled","ids","trail","error","Warnings","loading","lit","hovered","nodeOf","selected","item","room","isReady","observer","inner","MODAL_GRAPH_CLASS","MODAL_GRAPH_HEIGHT","EMPTY","_self$2","_el$3","_el$4","_el$5","_el$6","_el$7","_el$8","_el$9","_el$10","_el$11","_el$12","_el$13","createComponent","Show","addEvent","ref","For","element","div","TOOLBAR_CLASS","CANVAS_CLASS","MODAL_BODY_CLASS","t","n","s","h","r","l","_self$3","_el$14","_el$15","crumb","BREADCRUMBS_CLASS","_self$4","_el$16","_el$17","_el$18","_el$19","_el$20","_el$21","title","NODE_CLASS","CONTAINER_CLASS","LIT_CLASS","SELECTED_CLASS","LOADING_CLASS","cx","cy","_self$5","_el$22","_el$23","_el$24","_el$25","_el$26","TOGGLE_CLASS","TOGGLE_TARGET_CLASS","TOGGLE_CIRCLE_CLASS","TOGGLE_MARK_CLASS","MINUS_MARK","PLUS_MARK","owner","labelAt","_self$6","_el$27","_el$28","_el$29","PORT_LABEL_CLASS","e","PORT_CLASS","PORT_DOT_CLASS","_self$7","_el$30","_el$31","_el$32","PIN_CLASS","PIN_MARK_CLASS","middle","select","_self$8","_el$33","_el$34","_el$35","_el$36","EDGE_LABEL_CLASS","EDGE_GROUP_CLASS","EDGE_HIT_CLASS","EDGE_CLASS","paths","word","family","UIGraph","delegateEvents"],"sources":["../src/components/ui-graph/UIGraph.types.ts","../src/components/ui-graph/GraphLayout.ts","../src/components/ui-graph/UIGraph.en.ts","../src/components/ui-graph/UIGraph.tsx","../src/components/ui-graph/index.ts"],"sourcesContent":["/**\n * The types and constants of the graph family: the data contract (`GraphData`, `GraphNode`, `GraphEdge` ...),\n * the layout's shapes and its metrics, shared by `GraphLayout` and the component.\n * - Data only: nothing here runs.\n * - GENERIC: any node / edge graph from plain data.\n * A subclass may draw one domain's graphs (a netlist, a pipeline ...); `ui` knows nothing about them.\n */\n\n////////////////\n// ## The data contract\n////////////////\n\n/** A graph `<ui-graph>` draws: its nodes, and the edges between them (or their ports). */\nexport type GraphData = {\n nodes: GraphNode[]\n edges?: GraphEdge[]\n}\n\n/** What a node's `children` may be: a graph, or a function giving one (or a promise of one), called on first open. */\nexport type GraphChildren = GraphData | (() => GraphData | Promise<GraphData>)\n\n/** One node of a graph. */\nexport type GraphNode = {\n /** Unique among its graph's nodes (not across levels: a node in a child graph is known by its `path`). */\n id: string\n /** The box's text; none: its `id`. */\n label?: string\n /** A word for what sort of node it is: its `<g>` is also class and part `kind-<word>`, for a page's own style. */\n kind?: string\n /** Where edges attach: drawn on the box's sides. */\n ports?: GraphPort[]\n /** A graph inside it, shown when it's opened: in place, in a modal or instead of the graph (`child-view`). */\n children?: GraphChildren\n /** How THIS node's children open; none: the element's `child-view`. */\n childView?: GraphChildView\n /** Starts open (`inline` only). */\n open?: boolean\n /** Hover text (an SVG `<title>`). */\n title?: string\n /** Anything the page wants to keep with the node: never read by the graph. */\n data?: unknown\n}\n\n/** A place on a node's side where edges attach. */\nexport type GraphPort = {\n /** Unique among its node's ports. */\n id: string\n /** Text beside it; none: no text. */\n label?: string\n /**\n * Which side it's on.\n * - None: `kind` `in` / `input` => `left`, `out` / `output` => `right`; else the side most of its edges come from.\n */\n side?: GraphPortSide\n /** A word for what sort of port it is: class and part `kind-<word>`. */\n kind?: string\n}\n\n/**\n * One end of an edge: a node, and optionally one of its ports.\n * - `node` `\"\"` (or left out) is the ENCLOSING node, the one whose `children` this graph is: `port` names ITS port.\n * Drawn on the container's side when opened in place, and as a pin on the graph's edge in a modal or drill view.\n */\nexport type GraphEnd = {\n node?: string\n port?: string\n}\n\n/** One edge, from one end to the other. */\nexport type GraphEdge = {\n /** Unique among its graph's edges; none: its index, `#3`. */\n id?: string\n from: GraphEnd\n to: GraphEnd\n /** A word for what sort of edge it is: class and part `kind-<word>`. */\n kind?: string\n /** Text at the edge's middle. */\n label?: string\n /** Anything the page wants to keep with it. */\n data?: unknown\n}\n\n/** A port's side. Above its type: the layout lists them. */\nexport const GraphPortSides = [\"left\", \"right\", \"top\", \"bottom\"] as const\nexport type GraphPortSide = (typeof GraphPortSides)[number]\n\n/** How a node's children are shown when it opens. Above its type: the vocabulary lists them. */\nexport const GraphChildViews = [\"inline\", \"modal\", \"drill\"] as const\nexport type GraphChildView = (typeof GraphChildViews)[number]\n\n/** What's selected: a node, an edge or a port, by `path` (a node's ids from the top, joined by `/`). */\nexport type GraphSelection = {\n kind: \"node\" | \"edge\" | \"port\"\n /** The item's own `id` (an edge without one: `#<index>`). */\n id: string\n /**\n * Where it is: the node's path (`cpu/alu`), the edge's graph path then `#` and its id (`cpu#e3`),\n * a port's node path then `:` and its id (`cpu/alu:a`).\n */\n path: string\n}\n\n////////////////\n// ## Layout\n////////////////\n\n/** A point in the drawing's user units. */\nexport type GraphPoint = { readonly x: number; readonly y: number }\n\n/** A port, placed: absolute, on its node's side. */\nexport type GraphPlacedPort = GraphPoint & {\n readonly port: GraphPort\n readonly side: GraphPortSide\n /** Its node's path, then `:` and its id. */\n readonly path: string\n}\n\n/** A node, placed: absolute user units, `x` / `y` its top left corner. */\nexport type GraphPlacedNode = {\n readonly node: GraphNode\n /** Its ids from the top, joined by `/`. */\n readonly path: string\n /** How deep it is: `0` for the shown graph's own nodes. */\n readonly depth: number\n readonly x: number\n readonly y: number\n readonly width: number\n readonly height: number\n readonly ports: readonly GraphPlacedPort[]\n /** It has children (loaded or not). */\n readonly hasChildren: boolean\n /** It's open in place: a container, its child graph drawn inside it. */\n readonly isOpen: boolean\n /** Its children are loading. */\n readonly isLoading?: boolean\n}\n\n/** An edge, placed: absolute points, from its start to its end, drawn as a smooth path through them. */\nexport type GraphPlacedEdge = {\n readonly edge: GraphEdge\n /** Its id, `#<index>` without one. */\n readonly id: string\n /** Its graph's path (`\"\"` at the top), then `#`, then its id. */\n readonly path: string\n /** The paths of what it joins: a node's path, or a port's (`node:port`). */\n readonly fromPath: string\n readonly toPath: string\n readonly points: readonly GraphPoint[]\n /** Which side of its start it leaves from, and which side of its end it enters by. */\n readonly fromSide: GraphPortSide\n readonly toSide: GraphPortSide\n readonly depth: number\n}\n\n/** A boundary pin: an enclosing node's port, drawn on the graph's own edge (modal and drill views). */\nexport type GraphPlacedPin = GraphPoint & {\n readonly port: GraphPort\n readonly side: GraphPortSide\n readonly path: string\n}\n\n/** A graph laid out: what `<ui-graph>` draws, every level flattened, in user units. */\nexport type GraphLayoutResult = {\n readonly width: number\n readonly height: number\n /** Every node, parents before their children. */\n readonly nodes: readonly GraphPlacedNode[]\n readonly edges: readonly GraphPlacedEdge[]\n /** The enclosing node's ports, at the top level's sides. */\n readonly pins: readonly GraphPlacedPin[]\n}\n\n/** What `GraphLayout` is told besides the graph. */\nexport type GraphLayoutOptions = {\n metrics?: GraphMetrics\n /** A text's width in user units at `fontSize`; default: estimated from its length. */\n textWidth?: (text: string, fontSize: number) => number\n /** A node's text; default: its label, else its id. */\n label?: (node: GraphNode) => string\n /** The child graph of each node open in place, by path. */\n openChildren?: ReadonlyMap<string, GraphData>\n /** Paths of nodes whose children are loading. */\n loading?: ReadonlySet<string>\n /** The enclosing node's ports: drawn as pins on the graph's sides. */\n boundary?: readonly GraphPort[]\n /** The shown graph's own path, `\"\"` at the top: what its nodes' paths start with. */\n prefix?: string\n}\n\n/** Sizes the layout works in, in user units. */\nexport const GRAPH_METRICS = {\n fontSize: 12,\n portFontSize: 10,\n /** Estimated advance of one character, per font size. */\n charWidth: 0.6,\n paddingX: 12,\n nodeHeight: 32,\n minNodeWidth: 48,\n /** Space between ports along a side. */\n portSpacing: 18,\n portRadius: 3.5,\n /** Space between layers. */\n layerGap: 56,\n /** Space between nodes in a layer. */\n nodeGap: 18,\n /** A container's header (its label and toggle), and the padding round its child graph. */\n headerHeight: 26,\n containerPadding: 14,\n /** Room for the toggle button, right of a label. */\n toggleWidth: 18,\n margin: 24\n} as const\n\nexport type GraphMetrics = { readonly [K in keyof typeof GRAPH_METRICS]: number }\n","import {\n GRAPH_METRICS,\n type GraphData,\n type GraphEdge,\n type GraphEnd,\n type GraphLayoutOptions,\n type GraphLayoutResult,\n type GraphMetrics,\n type GraphNode,\n type GraphPlacedEdge,\n type GraphPlacedNode,\n type GraphPlacedPin,\n type GraphPlacedPort,\n type GraphPoint,\n type GraphPort,\n type GraphPortSide\n} from \"./UIGraph.types\"\n\n/****************\n * ### `GraphLayout`\n * Lays a graph out left to right, in layers (a small Sugiyama): pure, numbers in, boxes and paths out.\n * - The steps, per level:\n * 1. each node's size, from its label and ports; a node open in place is laid out first, and grows round it\n * 2. cycles broken (depth first, back edges turned round), then layers by longest path, sources pulled right\n * 3. a dummy point per layer a long edge crosses, so it routes round the boxes\n * 4. order within each layer by barycentre sweeps (each box moved towards its neighbours' mean), ports counted\n * 5. x by layer; y pulled towards each box's neighbours, then pushed apart so nothing overlaps\n * - Edges come out as points; `pathFor()` turns them into a smooth SVG path, leaving and entering ports sideways.\n * - The enclosing node's ports (`boundary`) are pins in the first and last layers:\n * a container's own ports sit where its child graph's pins are.\n * - Measured: 200 nodes and 400 edges in one level lay out in tens of milliseconds (`UIGraph`'s docs page).\n * - GENERIC: imports only the family's types.\n ****************/\nexport class GraphLayout {\n /** `graph` laid out, every open level flattened into absolute boxes. */\n static of(graph: GraphData, options: GraphLayoutOptions = {}): GraphLayoutResult {\n const layout = new GraphLayout(options)\n const prefix = options.prefix ?? \"\"\n const level = layout.level(graph, prefix, options.boundary ?? [])\n const nodes: GraphPlacedNode[] = []\n const edges: GraphPlacedEdge[] = []\n const { margin } = layout.metrics\n layout.flatten(level, margin, margin, 0, nodes, edges)\n const pins: GraphPlacedPin[] = level.pins.map((pin) => ({\n port: pin.port,\n side: pin.side,\n path: `${prefix}:${pin.port.id}`,\n x: pin.x + margin,\n y: pin.y + margin\n }))\n return { width: level.width + 2 * margin, height: level.height + 2 * margin, nodes, edges, pins }\n }\n\n /** `d` of an edge's `<path>`: cubic curves through its points, leaving and entering along its sides. */\n static pathFor(edge: Pick<GraphPlacedEdge, \"points\" | \"fromSide\" | \"toSide\">): string {\n const { points, fromSide, toSide } = edge\n if (points.length < 2) return \"\"\n let d = `M${round(points[0].x)} ${round(points[0].y)}`\n for (let i = 1; i < points.length; i++) {\n const p = points[i - 1]\n const q = points[i]\n const reach = Math.max(16, Math.abs(q.x - p.x) / 2, Math.abs(q.y - p.y) / 4)\n const forward = Math.sign(q.x - p.x) || 1\n const [c1x, c1y] = i === 1 ? GraphLayout.toward(p, fromSide, reach) : [p.x + forward * reach, p.y]\n const [c2x, c2y] = i === points.length - 1 ? GraphLayout.toward(q, toSide, reach) : [q.x - forward * reach, q.y]\n d += `C${round(c1x)} ${round(c1y)} ${round(c2x)} ${round(c2y)} ${round(q.x)} ${round(q.y)}`\n }\n return d\n }\n\n /** A control point `reach` out of `point`, on `side`. */\n private static toward(point: GraphPoint, side: GraphPortSide, reach: number): [number, number] {\n switch (side) {\n case \"left\":\n return [point.x - reach, point.y]\n case \"right\":\n return [point.x + reach, point.y]\n case \"top\":\n return [point.x, point.y - reach]\n case \"bottom\":\n return [point.x, point.y + reach]\n }\n }\n\n /** The middle of an edge's path, for its label. */\n static middleOf(edge: Pick<GraphPlacedEdge, \"points\">): GraphPoint {\n const { points } = edge\n if (points.length % 2 === 1) return points[(points.length - 1) / 2]\n const p = points[points.length / 2 - 1]\n const q = points[points.length / 2]\n return { x: (p.x + q.x) / 2, y: (p.y + q.y) / 2 }\n }\n\n /** A port's side: its own, else its kind's, else where most of its edges are drawn from. */\n static sideOf(port: GraphPort, votes: { asSource: number; asTarget: number } | undefined): GraphPortSide {\n if (port.side) return port.side\n const kind = port.kind?.toLowerCase()\n if (kind === \"in\" || kind === \"input\") return \"left\"\n if (kind === \"out\" || kind === \"output\") return \"right\"\n if (!votes) return \"right\"\n return votes.asTarget > votes.asSource ? \"left\" : \"right\"\n }\n\n private readonly metrics: GraphMetrics\n private readonly options: GraphLayoutOptions\n\n private constructor(options: GraphLayoutOptions) {\n this.options = options\n this.metrics = options.metrics ?? GRAPH_METRICS\n }\n\n private textWidth(text: string, fontSize: number): number {\n return this.options.textWidth?.(text, fontSize) ?? text.length * fontSize * this.metrics.charWidth\n }\n\n private labelOf(node: GraphNode): string {\n return this.options.label?.(node) ?? node.label ?? node.id\n }\n\n ////////////////\n // ## One level\n ////////////////\n\n /** One graph laid out, its coordinates relative to its own top left. */\n private level(\n graph: GraphData,\n prefix: string,\n boundary: readonly GraphPort[],\n boundarySides?: ReadonlyMap<GraphPort, GraphPortSide>\n ): Level {\n const m = this.metrics\n const nodes = graph.nodes ?? []\n const byId = new Map<string, Unit>()\n const units: Unit[] = []\n const edges = graph.edges ?? []\n\n // Votes for each port's side: how often it starts an edge, and ends one.\n const votes = new Map<string, { asSource: number; asTarget: number }>()\n const vote = (end: GraphEnd, key: \"asSource\" | \"asTarget\") => {\n if (end.port === undefined) return\n const id = `${end.node ?? \"\"}:${end.port}`\n const tally = votes.get(id) ?? { asSource: 0, asTarget: 0 }\n tally[key]++\n votes.set(id, tally)\n }\n for (const edge of edges) {\n vote(edge.from, \"asSource\")\n vote(edge.to, \"asTarget\")\n }\n\n // 1. Sizes.\n for (const node of nodes) {\n if (!node || typeof node.id !== \"string\" || byId.has(node.id)) continue\n const path = prefix ? `${prefix}/${node.id}` : node.id\n const unit = this.box(node, path, (port) => GraphLayout.sideOf(port, votes.get(`${node.id}:${port.id}`)))\n byId.set(node.id, unit)\n units.push(unit)\n }\n\n // Pins: the enclosing node's ports. Inside, a left pin STARTS edges, so it's drawn facing right.\n const pins = new Map<string, Unit>()\n for (const port of boundary) {\n const inside = votes.get(`:${port.id}`)\n const side = boundarySides?.get(port) ?? GraphLayout.sideOf(port, inside && flip(inside))\n const pin: Unit = {\n kind: \"pin\",\n width: 0,\n height: m.portSpacing,\n layer: 0,\n order: 0,\n x: 0,\n y: 0,\n ports: [],\n pin: { port, side: side === \"left\" || side === \"top\" ? \"left\" : \"right\" }\n }\n pins.set(port.id, pin)\n units.push(pin)\n }\n\n // Resolve each edge's ends.\n const links: Link[] = []\n edges.forEach((edge, index) => {\n if (!edge?.from || !edge?.to) return\n const from = this.endOf(edge.from, \"from\", byId, pins, prefix)\n const to = this.endOf(edge.to, \"to\", byId, pins, prefix)\n if (!from || !to) return\n const id = edge.id ?? `#${index}`\n links.push({ edge, id, from, to, reversed: false, chain: [] })\n })\n\n // 2. Layers.\n this.assignLayers(units, links)\n\n // 3. Dummies along long edges.\n const layerCount = Math.max(0, ...units.map((unit) => unit.layer)) + 1\n for (const link of links) {\n const [a, b] = link.reversed ? [link.to, link.from] : [link.from, link.to]\n link.chain = [a.unit]\n for (let layer = a.unit.layer + 1; layer < b.unit.layer; layer++) {\n const dummy: Unit = { kind: \"dummy\", width: 0, height: 4, layer, order: 0, x: 0, y: 0, ports: [] }\n units.push(dummy)\n link.chain.push(dummy)\n }\n link.chain.push(b.unit)\n }\n\n const layers: Unit[][] = Array.from({ length: layerCount }, () => [])\n for (const unit of units) layers[unit.layer].push(unit)\n layers.forEach((layer) => layer.forEach((unit, order) => (unit.order = order)))\n\n // Neighbours, for the sweeps: each segment of each chain, with the y offset it attaches at on each side.\n for (const link of links) {\n const [a, b] = link.reversed ? [link.to, link.from] : [link.from, link.to]\n for (let i = 0; i + 1 < link.chain.length; i++) {\n const u = link.chain[i]\n const v = link.chain[i + 1]\n if (u.layer === v.layer) continue\n const uOffset = i === 0 ? a.dy : u.height / 2\n const vOffset = i + 1 === link.chain.length - 1 ? b.dy : v.height / 2\n ;(u.down ??= []).push({ unit: v, mine: uOffset, theirs: vOffset })\n ;(v.up ??= []).push({ unit: u, mine: vOffset, theirs: uOffset })\n }\n }\n\n // 4. Order.\n this.order(layers)\n\n // 5. Coordinates.\n const { width, height } = this.place(layers, links)\n\n // Points per edge.\n const placedEdges: LevelEdge[] = []\n for (const link of links) {\n const [a, b] = link.reversed ? [link.to, link.from] : [link.from, link.to]\n const points: GraphPoint[] = [{ x: a.unit.x + a.dx, y: a.unit.y + a.dy }]\n for (let i = 1; i < link.chain.length - 1; i++) {\n const dummy = link.chain[i]\n points.push({ x: dummy.x, y: dummy.y + dummy.height / 2 })\n }\n points.push({ x: b.unit.x + b.dx, y: b.unit.y + b.dy })\n if (link.reversed) points.reverse()\n placedEdges.push({\n edge: link.edge,\n id: link.id,\n points,\n fromSide: link.from.side,\n toSide: link.to.side,\n fromPath: link.from.path,\n toPath: link.to.path,\n fromPin: link.from.unit.kind === \"pin\" ? link.from.unit.pin!.port.id : undefined,\n toPin: link.to.unit.kind === \"pin\" ? link.to.unit.pin!.port.id : undefined\n })\n }\n\n const levelPins = [...pins.values()].map((pin) => ({\n port: pin.pin!.port,\n side: pin.pin!.side,\n x: pin.pin!.side === \"left\" ? 0 : width,\n y: pin.y + pin.height / 2\n }))\n\n return {\n width,\n height,\n units: units.filter((unit) => unit.kind === \"node\"),\n edges: placedEdges,\n pins: levelPins,\n prefix\n }\n }\n\n /** A node's box: a leaf sized to its label and ports, or a container round its laid out child graph. */\n private box(node: GraphNode, path: string, sideOf: (port: GraphPort) => GraphPortSide): Unit {\n const m = this.metrics\n const label = this.labelOf(node)\n const ports = (node.ports ?? []).filter((port) => port && typeof port.id === \"string\")\n const sides = new Map(ports.map((port) => [port, sideOf(port)]))\n const on = (side: GraphPortSide) => ports.filter((port) => sides.get(port) === side)\n const portLabelWidth = (side: GraphPortSide) =>\n Math.max(0, ...on(side).map((port) => (port.label ? this.textWidth(port.label, m.portFontSize) + 6 : 0)))\n const hasChildren = node.children !== undefined\n const childGraph = this.options.openChildren?.get(path)\n const labelWidth = this.textWidth(label, m.fontSize) + 2 * m.paddingX + (hasChildren ? m.toggleWidth : 0)\n\n const unit: Unit = {\n kind: \"node\",\n node,\n path,\n width: 0,\n height: 0,\n layer: 0,\n order: 0,\n x: 0,\n y: 0,\n ports: [],\n hasChildren,\n isLoading: this.options.loading?.has(path)\n }\n\n if (childGraph) {\n const child = this.level(childGraph, path, ports, sides)\n unit.child = child\n unit.width = Math.max(labelWidth, child.width + 2 * m.containerPadding)\n unit.height = m.headerHeight + child.height + m.containerPadding\n const insetX = (unit.width - child.width) / 2\n for (const pin of child.pins) {\n const side = pin.side\n unit.ports.push({\n port: pin.port,\n side,\n dx: side === \"left\" ? 0 : unit.width,\n dy: m.headerHeight + pin.y\n })\n }\n unit.childOffset = { x: insetX, y: m.headerHeight }\n this.spread(unit, on(\"top\"), \"top\")\n this.spread(unit, on(\"bottom\"), \"bottom\")\n return unit\n }\n\n const tall = Math.max(on(\"left\").length, on(\"right\").length)\n const wide = Math.max(on(\"top\").length, on(\"bottom\").length)\n unit.height = Math.max(m.nodeHeight, (tall + 1) * m.portSpacing)\n unit.width = Math.max(\n m.minNodeWidth,\n labelWidth + portLabelWidth(\"left\") + portLabelWidth(\"right\"),\n (wide + 1) * m.portSpacing\n )\n for (const side of [\"left\", \"right\", \"top\", \"bottom\"] as const) this.spread(unit, on(side), side)\n return unit\n }\n\n /** Place `ports` evenly along `unit`'s `side`. */\n private spread(unit: Unit, ports: GraphPort[], side: GraphPortSide) {\n ports.forEach((port, index) => {\n const along = (index + 1) / (ports.length + 1)\n if (side === \"left\" || side === \"right\")\n unit.ports.push({ port, side, dx: side === \"left\" ? 0 : unit.width, dy: along * unit.height })\n else unit.ports.push({ port, side, dx: along * unit.width, dy: side === \"top\" ? 0 : unit.height })\n })\n }\n\n /** Where an edge's end attaches; `undefined` for an end naming nothing in this graph. */\n private endOf(\n end: GraphEnd,\n role: \"from\" | \"to\",\n byId: Map<string, Unit>,\n pins: Map<string, Unit>,\n prefix: string\n ): End | undefined {\n if (!end.node) {\n const pin = end.port !== undefined ? pins.get(end.port) : undefined\n if (!pin) return undefined\n return {\n unit: pin,\n dx: 0,\n dy: pin.height / 2,\n side: pin.pin!.side === \"left\" ? \"right\" : \"left\",\n path: `${prefix}:${end.port}`\n }\n }\n const unit = byId.get(end.node)\n if (!unit) return undefined\n const port = end.port !== undefined ? unit.ports.find((each) => each.port.id === end.port) : undefined\n if (port) return { unit, dx: port.dx, dy: port.dy, side: port.side, path: `${unit.path}:${port.port.id}` }\n return role === \"from\"\n ? { unit, dx: unit.width, dy: unit.height / 2, side: \"right\", path: unit.path! }\n : { unit, dx: 0, dy: unit.height / 2, side: \"left\", path: unit.path! }\n }\n\n /** Layers: cycles broken, longest path from the sources, sources pulled next to what they feed; pins at the sides. */\n private assignLayers(units: Unit[], links: Link[]) {\n const nodes = units.filter((unit) => unit.kind === \"node\")\n const out = new Map<Unit, Link[]>(nodes.map((unit) => [unit, []]))\n const inDegree = new Map<Unit, number>(nodes.map((unit) => [unit, 0]))\n const between = links.filter((link) => link.from.unit.kind === \"node\" && link.to.unit.kind === \"node\")\n\n // Depth first, iteratively: an edge back to a node still on the stack is turned round.\n for (const link of between) out.get(link.from.unit)!.push(link)\n const state = new Map<Unit, 1 | 2>()\n for (const root of nodes) {\n if (state.has(root)) continue\n const stack: [Unit, number][] = [[root, 0]]\n state.set(root, 1)\n const outs = (unit: Unit) => out.get(unit)!\n while (stack.length) {\n const top = stack[stack.length - 1]\n const list = outs(top[0])\n if (top[1] >= list.length) {\n state.set(top[0], 2)\n stack.pop()\n continue\n }\n const link = list[top[1]++]\n const next = link.to.unit\n if (next === top[0]) continue\n const seen = state.get(next)\n if (seen === 1) link.reversed = true\n else if (!seen) {\n state.set(next, 1)\n stack.push([next, 0])\n }\n }\n }\n\n // Longest path, in topological order.\n const succ = new Map<Unit, Unit[]>(nodes.map((unit) => [unit, []]))\n const pred = new Map<Unit, Unit[]>(nodes.map((unit) => [unit, []]))\n for (const link of between) {\n const [a, b] = link.reversed ? [link.to.unit, link.from.unit] : [link.from.unit, link.to.unit]\n if (a === b) continue\n succ.get(a)!.push(b)\n pred.get(b)!.push(a)\n inDegree.set(b, inDegree.get(b)! + 1)\n }\n const queue = nodes.filter((unit) => inDegree.get(unit) === 0)\n const topo: Unit[] = []\n for (let i = 0; i < queue.length; i++) {\n const unit = queue[i]\n topo.push(unit)\n for (const next of succ.get(unit)!) {\n next.layer = Math.max(next.layer, unit.layer + 1)\n inDegree.set(next, inDegree.get(next)! - 1)\n if (inDegree.get(next) === 0) queue.push(next)\n }\n }\n // Sources pulled right, next to the nearest node they feed.\n for (let i = topo.length - 1; i >= 0; i--) {\n const unit = topo[i]\n const nexts = succ.get(unit)!\n if (pred.get(unit)!.length === 0 && nexts.length)\n unit.layer = Math.max(unit.layer, Math.min(...nexts.map((next) => next.layer)) - 1)\n }\n\n // Pins: left ones before every node, right ones after.\n const pins = units.filter((unit) => unit.kind === \"pin\")\n const hasLeft = pins.some((pin) => pin.pin!.side === \"left\")\n if (hasLeft) for (const unit of nodes) unit.layer++\n const last = Math.max(0, ...nodes.map((unit) => unit.layer))\n for (const pin of pins) pin.layer = pin.pin!.side === \"left\" ? 0 : last + (nodes.length ? 1 : 0)\n\n // Links between pins and nodes go forward or are turned round.\n for (const link of links)\n if (link.from.unit.kind === \"pin\" || link.to.unit.kind === \"pin\")\n link.reversed = link.from.unit.layer > link.to.unit.layer\n }\n\n /** Order within each layer: barycentre sweeps, down then up, keeping the best. */\n private order(layers: Unit[][]) {\n const position = (unit: Unit, offset: number) => unit.order + offset / Math.max(1, unit.height)\n const sweep = (layer: Unit[], side: \"up\" | \"down\") => {\n const centre = new Map<Unit, number>()\n for (const unit of layer) {\n const near = unit[side]\n if (!near?.length) centre.set(unit, unit.order)\n else centre.set(unit, near.reduce((sum, each) => sum + position(each.unit, each.theirs), 0) / near.length)\n }\n layer.sort((a, b) => centre.get(a)! - centre.get(b)! || a.order - b.order)\n layer.forEach((unit, order) => (unit.order = order))\n }\n for (let round = 0; round < 6; round++) {\n if (round % 2 === 0) for (let i = 1; i < layers.length; i++) sweep(layers[i], \"up\")\n else for (let i = layers.length - 2; i >= 0; i--) sweep(layers[i], \"down\")\n }\n }\n\n /** x by layer, y pulled towards neighbours without overlapping; the level's size. */\n private place(layers: Unit[][], links: Link[]): { width: number; height: number } {\n const m = this.metrics\n const gapAfter = (unit: Unit) => (unit.kind === \"dummy\" ? 6 : m.nodeGap)\n\n // x: each layer as wide as its widest box, boxes centred in it; busier gaps are wider.\n const crossings = new Array(layers.length).fill(0)\n for (const link of links) for (let i = 0; i + 1 < link.chain.length; i++) crossings[link.chain[i].layer]++\n let x = 0\n layers.forEach((layer, index) => {\n const width = Math.max(0, ...layer.map((unit) => unit.width))\n for (const unit of layer) unit.x = x + (width - unit.width) / 2\n x += width + m.layerGap + Math.min(60, Math.sqrt(crossings[index]) * 4)\n })\n\n // y: stacked, then pulled towards the neighbours' attachment points, in a few sweeps.\n for (const layer of layers) {\n let y = 0\n for (const unit of layer) {\n unit.y = y\n y += unit.height + gapAfter(unit)\n }\n }\n const tallest = Math.max(\n 0,\n ...layers.map((layer) => layer.reduce((sum, unit) => sum + unit.height + gapAfter(unit), 0))\n )\n for (const layer of layers) {\n const used = layer.reduce((sum, unit) => sum + unit.height + gapAfter(unit), 0)\n for (const unit of layer) unit.y += (tallest - used) / 2\n }\n const pull = (layer: Unit[], side: \"up\" | \"down\") => {\n const wanted = layer.map((unit) => {\n const near = [...(unit[side] ?? []), ...(unit[side === \"up\" ? \"down\" : \"up\"] ?? [])]\n if (!near.length) return unit.y\n return near.reduce((sum, each) => sum + each.unit.y + each.theirs - each.mine, 0) / near.length\n })\n GraphLayout.separate(layer, wanted, gapAfter)\n }\n for (let round = 0; round < 8; round++) {\n if (round % 2 === 0) for (let i = 1; i < layers.length; i++) pull(layers[i], \"up\")\n else for (let i = layers.length - 2; i >= 0; i--) pull(layers[i], \"down\")\n }\n\n // Normalised to start at 0.\n const all = layers.flat()\n const top = Math.min(0, ...all.map((unit) => unit.y))\n for (const unit of all) unit.y -= top\n const width = Math.max(0, ...all.map((unit) => unit.x + unit.width))\n const height = Math.max(0, ...all.map((unit) => unit.y + unit.height))\n return { width, height }\n }\n\n /** Put each unit of `layer` as near its `wanted` y as it can, in order, without overlaps. */\n private static separate(layer: Unit[], wanted: number[], gapAfter: (unit: Unit) => number) {\n // Blocks of units pushed together sit at the mean of what they want (pool adjacent violators).\n type Block = { start: number; end: number; top: number; height: number; weight: number; sum: number }\n const blocks: Block[] = []\n layer.forEach((unit, index) => {\n const height = unit.height + gapAfter(unit)\n let block: Block = { start: index, end: index, top: wanted[index], height, weight: 1, sum: wanted[index] }\n while (blocks.length) {\n const previous = blocks[blocks.length - 1]\n if (previous.top + previous.height <= block.top) break\n blocks.pop()\n const sum = previous.sum + block.sum - block.weight * previous.height\n const weight = previous.weight + block.weight\n block = {\n start: previous.start,\n end: block.end,\n top: sum / weight,\n height: previous.height + block.height,\n weight,\n sum\n }\n }\n blocks.push(block)\n })\n for (const block of blocks) {\n let y = block.top\n for (let i = block.start; i <= block.end; i++) {\n layer[i].y = y\n y += layer[i].height + gapAfter(layer[i])\n }\n }\n }\n\n ////////////////\n // ## Flattening\n ////////////////\n\n /** `level`'s boxes and edges, moved to `x`, `y`, into `nodes` and `edges`; open nodes' levels after them. */\n private flatten(\n level: Level,\n x: number,\n y: number,\n depth: number,\n nodes: GraphPlacedNode[],\n edges: GraphPlacedEdge[],\n container?: { unit: Unit; x: number; y: number }\n ) {\n for (const unit of level.units) {\n const ux = x + unit.x\n const uy = y + unit.y\n const ports: GraphPlacedPort[] = unit.ports.map((port) => ({\n port: port.port,\n side: port.side,\n path: `${unit.path}:${port.port.id}`,\n x: ux + port.dx,\n y: uy + port.dy\n }))\n nodes.push({\n node: unit.node!,\n path: unit.path!,\n depth,\n x: ux,\n y: uy,\n width: unit.width,\n height: unit.height,\n ports,\n hasChildren: !!unit.hasChildren,\n isOpen: !!unit.child,\n isLoading: unit.isLoading\n })\n if (unit.child && unit.childOffset)\n this.flatten(unit.child, ux + unit.childOffset.x, uy + unit.childOffset.y, depth + 1, nodes, edges, {\n unit,\n x: ux,\n y: uy\n })\n }\n const graphPath = level.prefix\n for (const edge of level.edges) {\n const points = edge.points.map((point) => ({ x: point.x + x, y: point.y + y }))\n // A pin inside a container reaches out to the container's own port, on its side.\n if (container) {\n const portAt = (id: string) => container.unit.ports.find((port) => port.port.id === id)\n const from = edge.fromPin !== undefined ? portAt(edge.fromPin) : undefined\n const to = edge.toPin !== undefined ? portAt(edge.toPin) : undefined\n if (from) points.unshift({ x: container.x + from.dx, y: container.y + from.dy })\n if (to) points.push({ x: container.x + to.dx, y: container.y + to.dy })\n }\n edges.push({\n edge: edge.edge,\n id: edge.id,\n path: `${graphPath}#${edge.id}`,\n fromPath: edge.fromPath,\n toPath: edge.toPath,\n points,\n fromSide: container && edge.fromPin !== undefined ? \"right\" : edge.fromSide,\n toSide: container && edge.toPin !== undefined ? \"left\" : edge.toSide,\n depth\n })\n }\n }\n}\n\n/** One box, dummy or pin in a level, while it's laid out. */\ntype Unit = {\n kind: \"node\" | \"dummy\" | \"pin\"\n node?: GraphNode\n path?: string\n width: number\n height: number\n layer: number\n order: number\n x: number\n y: number\n ports: { port: GraphPort; side: GraphPortSide; dx: number; dy: number }[]\n hasChildren?: boolean\n isLoading?: boolean\n child?: Level\n childOffset?: GraphPoint\n pin?: { port: GraphPort; side: \"left\" | \"right\" }\n up?: Neighbour[]\n down?: Neighbour[]\n}\n\n/** A unit in the next layer an edge segment reaches, and where it attaches on each. */\ntype Neighbour = { unit: Unit; mine: number; theirs: number }\n\n/** Where an edge attaches to a unit. */\ntype End = { unit: Unit; dx: number; dy: number; side: GraphPortSide; path: string }\n\n/** An edge while it's laid out. */\ntype Link = { edge: GraphEdge; id: string; from: End; to: End; reversed: boolean; chain: Unit[] }\n\n/** An edge of a level, relative to it. */\ntype LevelEdge = {\n edge: GraphEdge\n id: string\n points: GraphPoint[]\n fromSide: GraphPortSide\n toSide: GraphPortSide\n fromPath: string\n toPath: string\n fromPin?: string\n toPin?: string\n}\n\n/** One graph laid out, relative to its own top left. */\ntype Level = {\n width: number\n height: number\n units: Unit[]\n edges: LevelEdge[]\n pins: { port: GraphPort; side: \"left\" | \"right\"; x: number; y: number }[]\n prefix: string\n}\n\n/** A port's votes seen from inside: a boundary port that edges START from inside is an input, on the left. */\nfunction flip(votes: { asSource: number; asTarget: number }) {\n return { asSource: votes.asTarget, asTarget: votes.asSource }\n}\n\n/** A coordinate, to a tenth. */\nfunction round(value: number): number {\n return Math.round(value * 10) / 10\n}\n","/**\n * The English vocabulary of `<ui-graph>`: every name the tag uses.\n * - Its tag, attributes (each with its kind and allowed values), events, parts and texts.\n * The shape is `ComponentVocabulary` (`spell/ui/vocabulary`).\n * - Ours, not Fomantic's: GENERIC, any node / edge graph; netlists are one caller (a subclass restyles it).\n * - Rich properties: `graph`, `selected` and `boundary` (`UIGraph.types.ts`).\n * A static page may give `graph` as JSON in the attribute.\n * - NOT `children` for how children open, though that's the word: it would hide the platform's `Element.children`.\n * So `child-view`.\n */\n\nimport type { ComponentVocabulary } from \"spell/ui/vocabulary\"\nimport { GraphChildViews } from \"./UIGraph.types\"\n\n/****************\n * ### `graphVocabulary`\n * The names of `<ui-graph>`, a node / edge graph drawn as an SVG:\n * `<div class=\"ui graph\">` holding breadcrumbs (when drilled in), a toolbar and `<svg part=\"canvas\">`.\n ****************/\nexport const graphVocabulary = {\n tag: \"ui-graph\",\n icon: \"project diagram\",\n topics: [\"data display\", \"images\", \"views\"],\n aka: [\n \"graph\",\n \"node graph\",\n \"network diagram\",\n \"flow chart\",\n \"dataflow\",\n \"netlist\",\n \"schematic\",\n \"block diagram\",\n \"DAG\"\n ],\n skeleton: \"16 tall\",\n noun: \"graph\",\n description:\n \"A graph draws nodes joined by edges, laid out left to right. A node may hold a graph of its own, opened in place, in a modal, or in its stead.\",\n attributes: [\n {\n name: \"graph\",\n group: \"content\",\n kind: \"json\",\n reflect: false,\n description:\n \"The graph to draw, a `GraphData`: `nodes` (`id`, `label`, `kind`, `ports`, `children`, `data`) and `edges` \" +\n \"(`from` / `to` `{ node, port }`). An end with no `node` is the enclosing node's port. A JS property (JSON in \" +\n \"the attribute); set a NEW graph to redraw.\"\n },\n {\n name: \"child-view\",\n group: \"behaviour\",\n kind: \"enum\",\n values: GraphChildViews,\n default: \"inline\",\n description:\n \"How a node's children show when it's opened: `inline`, inside the node, which grows round them; `modal`, a \" +\n \"graph in a modal; `drill`, the graph replaced by them, with breadcrumbs back. A node's own `childView` wins.\"\n },\n {\n name: \"path\",\n group: \"behaviour\",\n kind: \"string\",\n default: \"\",\n description:\n 'The node whose child graph is shown, drilled to, by its ids from the top joined by `/` (`cpu/alu`); `\"\"`: ' +\n \"the top. Setting it drills there, loading lazy children on the way; drilling and the breadcrumbs set it back, \" +\n \"with `ui-changed` `{ kind: 'path', path }`.\"\n },\n {\n name: \"selected\",\n group: \"states\",\n kind: \"json\",\n reflect: false,\n description:\n \"PROPERTY: what's selected, `{ kind: 'node' | 'edge' | 'port', id, path }`; `undefined`: nothing. Clicks set it.\"\n },\n {\n name: \"boundary\",\n group: \"content\",\n kind: \"json\",\n reflect: false,\n description:\n \"PROPERTY: the enclosing node's ports, drawn as pins on the graph's sides, for edges with no `node`. Set by a \" +\n \"modal's graph; a page rarely needs it.\"\n }\n ],\n events: [\n {\n name: \"ui-selecting\",\n cancelable: true,\n detail: \"{ kind: 'node' | 'edge' | 'port', id: string, path: string, item: object, originalEvent?: Event }\",\n description: \"A node, edge or port is about to be selected by a click: cancel it to keep the selection.\"\n },\n {\n name: \"ui-changed\",\n detail:\n \"{ value: { kind: string, id: string, path: string } | undefined, kind?: string, id?: string, path?: string, item?: object, originalEvent?: Event } | { kind: 'path', path: string, originalEvent?: Event }\",\n description:\n \"What's selected changed: `value` is the new `selected`; `item` the node, edge or port itself. ALSO when \" +\n \"the graph shown changes by a drill or a breadcrumb: `{ kind: 'path', path }` (`path` the new `path`), so one \" +\n \"listener keeps a page in step with both.\"\n },\n {\n name: \"ui-node-toggled\",\n detail:\n \"{ node: object, path: string, open: boolean, view: 'inline' | 'modal' | 'drill', originalEvent?: Event }\",\n description: \"A node with children was opened or closed, by a person or by `open()` / `close()`.\"\n }\n ],\n slots: [],\n parts: [\n { name: \"graph\", description: \"The box round it all.\" },\n { name: \"canvas\", description: \"The `<svg>`.\" },\n { name: \"node\", description: \"Each node's `<g>`.\" },\n { name: \"container\", description: \"A node opened in place, its child graph inside; also part `node`.\" },\n { name: \"edge\", description: \"Each edge's `<path>`.\" },\n { name: \"edge-label\", description: \"Each edge's label.\" },\n { name: \"port\", description: \"Each port's `<g>`: its dot and label.\" },\n { name: \"pin\", description: \"Each pin, the enclosing node's port, on a modal or drilled graph's side.\" },\n { name: \"toggle\", description: \"Each node's open / close button.\" },\n { name: \"toolbar\", description: \"The buttons over the drawing (fit).\" },\n { name: \"breadcrumbs\", description: \"The trail back up, when drilled in.\" }\n ],\n states: [\n { name: \"drilled\", description: \"It shows a node's children instead of its graph.\" },\n { name: \"panning\", description: \"A drag is moving the view.\" }\n ],\n texts: [\n { key: \"graphSummary\", text: \"Graph: {count} nodes\", description: \"Name of the drawing.\" },\n { key: \"graphOpenNode\", text: \"Open {label}\", description: \"A closed node's toggle.\" },\n { key: \"graphCloseNode\", text: \"Close {label}\", description: \"An open node's toggle.\" },\n { key: \"graphFit\", text: \"Fit\", description: \"The button that fits the drawing to the view.\" },\n { key: \"graphTop\", text: \"Top\", description: \"The first breadcrumb, the graph itself.\" },\n { key: \"graphLoading\", text: \"Loading …\", description: \"A node whose children are loading.\" }\n ],\n hooks: [\n {\n name: \"nodeLabel\",\n words: \"give the label of (a node)\",\n description: \"A node's text; by default its `label`, else its id.\"\n },\n {\n name: \"nodeClass\",\n words: \"give the class of (a node)\",\n description: \"Extra class names on a node, for the subclass's own sheet.\"\n },\n {\n name: \"edgeLabel\",\n words: \"give the label of (an edge)\",\n description: \"An edge's text, at its middle; none: no text.\"\n },\n {\n name: \"edgeClass\",\n words: \"give the class of (an edge)\",\n description: \"Extra class names on an edge, for the subclass's own sheet.\"\n }\n ]\n} as const satisfies ComponentVocabulary\n","import { For, Show } from \"solid-js\"\nimport { isServer, type JSX } from \"@solidjs/web\"\n\nimport { E, UIT } from \"spell/ui/core\"\n// Import directly: the tree diagram's text measuring, shared by every drawing (one canvas a page)\nimport { TreeMeasure } from \"spell/ui/components/ui-tree-diagram/TreeMeasure\"\nimport { graphVocabulary } from \"./UIGraph.en\"\nimport { GraphLayout } from \"./GraphLayout\"\nimport {\n GRAPH_METRICS,\n GraphChildViews,\n type GraphChildView,\n type GraphData,\n type GraphEdge,\n type GraphLayoutResult,\n type GraphNode,\n type GraphPlacedEdge,\n type GraphPlacedNode,\n type GraphPlacedPin,\n type GraphPlacedPort,\n type GraphPort,\n type GraphSelection\n} from \"./UIGraph.types\"\n\nimport graphCSS from \"./UIGraph.css?inline\"\n\n/****************\n * ### `DOMGraphElement`\n * `<ui-graph>` itself: its script API, over its component.\n ****************/\nexport class DOMGraphElement extends E.DOMElement<UIGraph> {\n /** Fit the drawing to the view. */\n fit() {\n this.component?.fit()\n }\n\n /** Open the node at `path` (its ids from the top, joined by `/`), as `view`, else as its own or the graph's. */\n open(path: string, view?: GraphChildView): Promise<void> {\n return this.component?.openNode(path, view) ?? Promise.resolve()\n }\n\n /** Close the node at `path`, opened in place; or, drilled into, go back above it. */\n close(path: string) {\n this.component?.closeNode(path)\n }\n\n /** Show the graph at `path` instead of the top (drill); none: back to the top. */\n drillTo(path?: string): Promise<void> {\n return this.component?.drillTo(path) ?? Promise.resolve()\n }\n\n /** The graph as it's drawn now: every box and edge, in user units. */\n get layout(): GraphLayoutResult | undefined {\n return this.component?.layout\n }\n}\n\n/****************\n * ### `<ui-graph>`\n * The component behind `<ui-graph>`: a node / edge graph drawn as an SVG, laid out left to right in layers\n * (`GraphLayout`), with ports on the nodes' sides, smooth edges, pan, zoom and fit.\n *\n * - GENERIC: any graph from plain data (`GraphData`).\n * A subclass restyles and relabels it through the hooks below\n * (`nodeLabel()`, `nodeClass()`, `renderNode()`, `edgeClass()` ...), its parts and its `--ui-graph-*` tokens.\n * - A node with `children` has a toggle; opened, they show by `child-view` (or the node's `childView`):\n * - `inline`: the node grows into a container, its graph laid out inside it, recursively\n * - `modal`: a `<ui-modal>` holding another graph of the same tag\n * - `drill`: the drawing shows them instead, with `<ui-breadcrumbs>` back\n * - `children` given as a function (or a promise of a graph) is called the first time it opens.\n * - Paths: how a node, a port or an edge is known.\n * - a node: its ids from the top graph, joined by `/` (`cpu/alu`)\n * - a port: its node's path, `:` and its id\n * - an edge: its graph's path, `#` and its id\n * - So ids should hold none of `/`, `:` or `#`.\n * - Pan: drag; zoom: the wheel, round the pointer; fit: the toolbar's button, and by itself on a new graph.\n * - `path` (`a/b`): the node drilled to.\n * - Set it to drill there.\n * - A drill (double-click a node with children, or its toggle with `child-view=\"drill\"`) or a breadcrumb\n * sets it back, and sends `ui-changed` `{ kind: 'path', path }`.\n * - Click a node, an edge or a port to select it: `ui-selecting` (cancelable), then `ui-changed`.\n * Hovering an edge lights it and its two ends; hovering a node lights its edges.\n * - Text is measured in the graph's real font (`TreeMeasure`, the canvas the tree diagram measures with);\n * a static server render estimates from character counts.\n * - Spell UI's other drawings of boxes and lines, so nobody builds a fourth:\n * - `<ui-tree-diagram>`: a TREE, each node's children under (or beside) it\n * - `<ui-diagram>`: boxes in COLUMNS and the links between them, the NERD drawing, boxes dragged by hand\n * - this one: any GRAPH, cycles too, in layers left to right, with ports on the boxes' sides, wires between\n * them and nested graphs, panned and zoomed\n ****************/\nexport class UIGraph extends E.UIComponent<typeof graphVocabulary> {\n @E.proto static vocabulary = graphVocabulary\n @E.protoMerged static elementSetup = {\n styleSheets: { graph: graphCSS },\n delegatesFocus: false,\n DOMElement: DOMGraphElement\n } satisfies Partial<E.ElementSetup>\n\n ////////////////\n // ## Hooks: a subclass overrides these to restyle and relabel\n ////////////////\n\n /** A node's text. */\n nodeLabel(node: GraphNode): string {\n return node.label ?? node.id\n }\n\n /** Extra classes on a node's `<g>`; `kind-<kind>` is there already. */\n nodeClass(_node: GraphNode): string | undefined {\n return undefined\n }\n\n /** An edge's text, at its middle; none: no text. */\n edgeLabel(edge: GraphEdge): string | undefined {\n return edge.label\n }\n\n /** Extra classes on an edge's `<path>`. */\n edgeClass(_edge: GraphEdge): string | undefined {\n return undefined\n }\n\n /** A port's text, beside it inside its node. */\n portLabel(port: GraphPort, _node: GraphNode): string | undefined {\n return port.label\n }\n\n /** Extra classes on a port's `<g>`. */\n portClass(_port: GraphPort, _node: GraphNode): string | undefined {\n return undefined\n }\n\n /** The sizes the layout works in; a subclass may make its boxes taller, its layers wider apart ... */\n get metrics(): typeof GRAPH_METRICS {\n return GRAPH_METRICS\n }\n\n /**\n * The breadcrumbs, top first: each one's text, and what picking it does.\n * - None (or one): no breadcrumbs.\n * - Default: the top, then each node drilled into.\n * A subclass that shows its own levels gives its own trail.\n */\n trail(): { label: string; pick: () => void }[] {\n if (!this.drillPaths.length) return []\n return [\n { label: this.translationForKey(\"graphTop\"), pick: () => this.goToDrill(0) },\n ...this.drillPaths.map((path, index) => {\n const node = this.nodeAt(path)\n return { label: node ? this.nodeLabel(node) : path, pick: () => this.goToDrill(index + 1) }\n })\n ]\n }\n\n /** The least zoom Fit goes to: a graph bigger than that shows its start, the rest a pan away. `0`: no least. */\n get minFitZoom(): number {\n return 0\n }\n\n /** More buttons in the toolbar, before Fit. */\n toolButtons(): JSX.Element {\n return undefined\n }\n\n /** Something drawn over the canvas (a legend ...), positioned by the subclass's own sheet. */\n overlay(): JSX.Element {\n return undefined\n }\n\n /** A node was double-clicked: drilled into, when it has children. */\n nodeDoubleClicked(placed: GraphPlacedNode, event: MouseEvent) {\n if (placed.hasChildren) void this.openNode(placed.path, \"drill\", event)\n }\n\n /** The detail of the `ui-changed` a selection sends. */\n changedDetail(selection: GraphSelection, item: object, originalEvent: Event): object {\n return { value: selection, ...selection, item, originalEvent }\n }\n\n /**\n * What a node's `<g>` holds: its box and label; the ports and toggle are drawn after it.\n * - Override to draw a node another way; stay inside `placed`'s box, as the layout sized it.\n */\n renderNode(placed: GraphPlacedNode): JSX.Element {\n const { fontSize } = GRAPH_METRICS\n const { x, y, width, height, isOpen } = placed\n const label = this.nodeLabel(placed.node)\n return (\n <>\n <rect class={BOX_CLASS} x={x} y={y} width={width} height={height} />\n <text\n class={LABEL_CLASS}\n x={\n isOpen\n ? x + GRAPH_METRICS.paddingX\n : x + width / 2 - (placed.hasChildren ? GRAPH_METRICS.toggleWidth / 2 : 0)\n }\n y={isOpen ? y + GRAPH_METRICS.headerHeight / 2 : y + height / 2}\n text-anchor={isOpen ? \"start\" : \"middle\"}\n font-size={String(fontSize)}\n >\n {placed.isLoading ? `${label} ${this.translationForKey(\"graphLoading\")}` : label}\n </text>\n </>\n )\n }\n\n ////////////////\n // ## The graph shown\n ////////////////\n\n /** Children loaded from a function or promise, by the node's path. */\n @E.state accessor loadedChildren: ReadonlyMap<string, GraphData> = new Map()\n /** Paths whose children are loading. */\n @E.state accessor loadingPaths: ReadonlySet<string> = new Set()\n /** Paths of nodes open in place. */\n @E.state accessor openPaths: ReadonlySet<string> = new Set()\n /** The nodes drilled into, outermost first. */\n @E.state accessor drillPaths: readonly string[] = []\n /** The node whose children the modal shows. */\n @E.state accessor modalPath: string | undefined = undefined\n\n /** The `graph` property, checked; `undefined`: nothing to draw. */\n get topGraph(): GraphData | undefined {\n return UIGraph.graphFrom(this.graph)\n }\n\n /** The node at `path`, from the top; `undefined` when there's none, or its graph isn't loaded. */\n nodeAt(path: string): GraphNode | undefined {\n let graph = this.topGraph\n let at = \"\"\n let node: GraphNode | undefined\n for (const id of path.split(\"/\")) {\n if (!graph) return undefined\n node = graph.nodes.find((each) => each?.id === id)\n if (!node) return undefined\n at = at ? `${at}/${id}` : id\n graph = this.childrenOf(node, at)\n }\n return node\n }\n\n /** `node`'s child graph, when it's there: given as a graph, or loaded. */\n childrenOf(node: GraphNode, path: string): GraphData | undefined {\n const children = node.children\n if (children && typeof children === \"object\") return UIGraph.graphFrom(children)\n return this.loadedChildren.get(path)\n }\n\n /** The node drilled into last; `undefined` at the top. */\n get drillPath(): string | undefined {\n return this.drillPaths.at(-1)\n }\n\n /** The graph drawn: the top's, or the children of the node drilled into. */\n @E.derived\n get shownGraph(): GraphData | undefined {\n const path = this.drillPath\n if (path === undefined) return this.topGraph\n const node = this.nodeAt(path)\n return node && this.childrenOf(node, path)\n }\n\n /** The ports drawn as pins round the graph shown. */\n get shownBoundary(): readonly GraphPort[] {\n const path = this.drillPath\n if (path !== undefined) return this.nodeAt(path)?.ports ?? []\n return Array.isArray(this.boundary) ? (this.boundary as GraphPort[]) : []\n }\n\n /** The graph laid out; `undefined` with nothing to draw. `@derived`: lays out every node. */\n @E.derived\n get layout(): GraphLayoutResult | undefined {\n const graph = this.shownGraph\n if (!graph) return undefined\n const openChildren = new Map<string, GraphData>()\n for (const path of this.openPaths) {\n const node = this.nodeAt(path)\n const children = node && this.childrenOf(node, path)\n if (children) openChildren.set(path, children)\n }\n return GraphLayout.of(graph, {\n metrics: this.metrics,\n prefix: this.drillPath ?? \"\",\n openChildren,\n loading: this.loadingPaths,\n boundary: this.shownBoundary,\n label: (node) => this.nodeLabel(node),\n textWidth: isServer ? undefined : (text, size) => UIGraph.measure(text, size, this.fontFamily)\n })\n }\n\n /** The font the labels are drawn in, read once: what they're measured in. */\n @E.lazy\n private get fontFamily(): string {\n return getComputedStyle(this.domElement).fontFamily || \"sans-serif\"\n }\n\n /** The containers first (they're behind), then the boxes. */\n private get containers(): readonly GraphPlacedNode[] {\n return this.layout?.nodes.filter((placed) => placed.isOpen) ?? []\n }\n\n private get leaves(): readonly GraphPlacedNode[] {\n return this.layout?.nodes.filter((placed) => !placed.isOpen) ?? []\n }\n\n ////////////////\n // ## Opening and closing\n ////////////////\n\n /** Open the node at `path`: its children loaded first, then shown as `view`. */\n async openNode(path: string, view?: GraphChildView, originalEvent?: Event): Promise<void> {\n const node = this.nodeAt(path)\n if (!node?.children) return\n const how = view ?? UIGraph.viewFrom(node.childView) ?? UIGraph.viewFrom(this.childView) ?? \"inline\"\n if (!(await this.load(node, path))) return\n if (how === \"inline\") this.openPaths = new Set(this.openPaths).add(path)\n else if (how === \"modal\") this.modalPath = path\n else {\n this.drillPaths = [...this.drillPaths, path]\n this.needsFit = true\n this.drilled(originalEvent)\n }\n this.send(\"ui-node-toggled\", { node, path, open: true, view: how, originalEvent })\n }\n\n /** Close the node at `path`: in place, with every node open inside it; drilled into, back above it. */\n closeNode(path: string, originalEvent?: Event) {\n const node = this.nodeAt(path)\n const drilled = this.drillPaths.indexOf(path)\n if (drilled >= 0) {\n this.drillPaths = this.drillPaths.slice(0, drilled)\n this.needsFit = true\n this.drilled(originalEvent)\n } else {\n this.openPaths = new Set([...this.openPaths].filter((each) => each !== path && !each.startsWith(`${path}/`)))\n }\n if (node)\n this.send(\"ui-node-toggled\", { node, path, open: false, view: drilled >= 0 ? \"drill\" : \"inline\", originalEvent })\n }\n\n /** Show the graph inside the node at `path`; none: the top. */\n async drillTo(path?: string): Promise<void> {\n if (!path) {\n this.goToDrill(0)\n return\n }\n await this.openNode(path, \"drill\")\n }\n\n /** Back up to `depth` nodes drilled into (`0`: the top). */\n goToDrill(depth: number, originalEvent?: Event) {\n if (depth >= this.drillPaths.length) return\n this.drillPaths = this.drillPaths.slice(0, depth)\n this.needsFit = true\n this.drilled(originalEvent)\n }\n\n /** The graph shown changed by a drill: `path` follows, and `ui-changed` `{ kind: 'path', path }` says so. */\n private drilled(originalEvent?: Event) {\n const path = this.drillPath ?? \"\"\n if (path === (this.path ?? \"\")) return\n this.path = path as never\n this.send(\"ui-changed\", { kind: \"path\", path, originalEvent })\n }\n\n /** `path` was set: drill to it. */\n @E.onChange(\"path\")\n protected onPathChanged(path: string | undefined) {\n void this.applyPath(path ?? \"\")\n }\n\n /**\n * Show the graph inside the node at `path`, drilling through each node on the way and loading lazy children.\n * - `path`: `a/b`; `\"\"`: the top.\n * - Sends nothing: the page asked for it.\n * - A subclass with a path of its own overrides it.\n */\n async applyPath(path: string): Promise<void> {\n if (path === (this.drillPath ?? \"\")) return\n const ids = path ? path.split(\"/\") : []\n const trail: string[] = []\n for (let at = 0; at < ids.length; at++) {\n const prefix = ids.slice(0, at + 1).join(\"/\")\n const node = this.nodeAt(prefix)\n if (!node?.children) break\n if (!(await this.load(node, prefix))) break\n trail.push(prefix)\n }\n this.drillPaths = trail\n this.needsFit = true\n }\n\n /** `node`'s children, loaded if they're a function or a promise; false when they failed. */\n protected async load(node: GraphNode, path: string): Promise<boolean> {\n if (typeof node.children !== \"function\" || this.loadedChildren.has(path)) return true\n this.loadingPaths = new Set(this.loadingPaths).add(path)\n try {\n const graph = UIGraph.graphFrom(await node.children())\n if (!graph) return false\n this.loadedChildren = new Map(this.loadedChildren).set(path, graph)\n return true\n } catch (error) {\n E.Warnings.warn(`<${this.domElement.localName}>`, `${path}'s children failed to load`, error)\n return false\n } finally {\n const loading = new Set(this.loadingPaths)\n loading.delete(path)\n this.loadingPaths = loading\n }\n }\n\n /** A toggle was pressed. */\n @E.untracked\n private toggle(placed: GraphPlacedNode, event: Event) {\n event.stopPropagation()\n if (placed.isOpen) this.closeNode(placed.path, event)\n else void this.openNode(placed.path, undefined, event)\n }\n\n /** `drilled`: it shows a node's children. */\n @E.cssState(\"drilled\")\n get isDrilled(): boolean {\n return this.drillPaths.length > 0\n }\n\n ////////////////\n // ## Selection and hover\n ////////////////\n\n /** The path hovered: a node's, an edge's or a port's. */\n @E.state accessor hovered: { kind: GraphSelection[\"kind\"]; path: string } | undefined = undefined\n\n /** The paths lit: the hovered edge and its ends, or the hovered node and its edges. `@derived`: walks the edges. */\n @E.derived\n get lit(): ReadonlySet<string> {\n const lit = new Set<string>()\n const hovered = this.hovered\n const layout = this.layout\n if (!hovered || !layout) return lit\n lit.add(hovered.path)\n const nodeOf = (path: string) => path.split(\":\")[0]\n for (const edge of layout.edges) {\n const isIt =\n hovered.kind === \"edge\"\n ? edge.path === hovered.path\n : hovered.kind === \"port\"\n ? edge.fromPath === hovered.path || edge.toPath === hovered.path\n : nodeOf(edge.fromPath) === hovered.path || nodeOf(edge.toPath) === hovered.path\n if (!isIt) continue\n lit.add(edge.path)\n for (const end of [edge.fromPath, edge.toPath]) {\n lit.add(end)\n lit.add(nodeOf(end))\n }\n }\n return lit\n }\n\n /** The selected path; `undefined`: nothing. */\n get selectedPath(): string | undefined {\n const selected = this.selected as GraphSelection | undefined\n return selected && typeof selected === \"object\" ? selected.path : undefined\n }\n\n /** Select `selection`: `ui-selecting` (a page may cancel it), then `selected`, then `ui-changed`. */\n @E.untracked\n protected choose(selection: GraphSelection, item: object, originalEvent: Event) {\n originalEvent.stopPropagation()\n if (this.wasDragged) return\n if (!this.send(\"ui-selecting\", { ...selection, item, originalEvent })) return\n this.selected = selection as never\n this.send(\"ui-changed\", this.changedDetail(selection, item, originalEvent))\n }\n\n ////////////////\n // ## Pan, zoom and fit\n ////////////////\n\n /** The view: a shift in pixels, then a scale. */\n @E.state accessor view = { x: 0, y: 0, k: 1 }\n /** A drag is moving the view. */\n @E.state accessor isPanning = false\n /** The next layout is fitted to the view: a new graph, or a drill. */\n protected needsFit = true\n /** The view was last set by a fit, not by a person: a change of size fits again. */\n private isFitted = false\n /** The last pointer press moved far enough to be a drag: its click selects nothing. */\n private wasDragged = false\n /** The `<svg>`. Set as it draws. */\n private svg: SVGSVGElement | undefined\n\n @E.cssState(\"panning\")\n get isPanningNow(): boolean {\n return this.isPanning\n }\n\n /** Fit the drawing to the view: all of it, at most one and a half times its size. */\n @E.untracked\n fit() {\n const layout = this.layout\n // Its own size, not its drawn one: a modal opening scales it with a transform.\n const box = this.svg && { width: this.svg.clientWidth, height: this.svg.clientHeight }\n if (!layout || !box?.width || !box.height) return\n const k = Math.max(this.minFitZoom, Math.min(box.width / layout.width, box.height / layout.height, 1.5))\n // Centred, too big or not.\n // Too big at the least zoom: its middle shows, the rest a pan away\n // (the middle is where the nodes are; its edges are often empty pins and margins).\n const along = (room: number, size: number) => (room - size * k) / 2\n this.view = { x: along(box.width, layout.width), y: along(box.height, layout.height), k }\n this.isFitted = true\n }\n\n /** A new graph: fit it. */\n @E.onChange(\"graph\")\n protected onGraphChanged() {\n this.needsFit = true\n this.drillPaths = []\n this.openPaths = new Set(UIGraph.startOpen(this.topGraph))\n if (this.path) void this.applyPath(String(this.path))\n }\n\n /** Fit when asked to, once the drawing's there. */\n @E.onChange(\"layout\", \"isReady\")\n protected onLayoutChanged(layout: GraphLayoutResult | undefined, isReady: boolean) {\n if (!isReady || !layout || !this.needsFit || !this.svg?.getBoundingClientRect().width) return\n this.needsFit = false\n this.fit()\n }\n\n /** While it's in the page: fit again when it first gets a size. */\n @E.whileConnected\n protected watchSize() {\n const observer = new ResizeObserver(() => {\n if (this.needsFit || this.isFitted) this.fit()\n if (this.svg?.getBoundingClientRect().width) this.needsFit = false\n })\n if (this.svg) observer.observe(this.svg)\n return () => observer.disconnect()\n }\n\n private readonly onWheel = (event: WheelEvent) => {\n if (!this.svg) return\n event.preventDefault()\n const box = this.svg.getBoundingClientRect()\n const px = event.clientX - box.left\n const py = event.clientY - box.top\n const { x, y, k } = this.view\n const next = Math.min(4, Math.max(0.05, k * Math.exp(-event.deltaY * (event.ctrlKey ? 0.01 : 0.0015))))\n this.view = { x: px - ((px - x) * next) / k, y: py - ((py - y) * next) / k, k: next }\n this.isFitted = false\n }\n\n private readonly onPointerDown = (event: PointerEvent) => {\n if (event.button !== 0 || !this.svg) return\n const svg = this.svg\n const start = { x: event.clientX, y: event.clientY, view: this.view }\n this.wasDragged = false\n const move = (moved: PointerEvent) => {\n const dx = moved.clientX - start.x\n const dy = moved.clientY - start.y\n if (!this.wasDragged && Math.hypot(dx, dy) < DRAG_DISTANCE) return\n if (!this.wasDragged) {\n this.wasDragged = true\n this.isFitted = false\n this.isPanning = true\n svg.setPointerCapture(event.pointerId)\n }\n this.view = { ...start.view, x: start.view.x + dx, y: start.view.y + dy }\n }\n const up = () => {\n svg.removeEventListener(\"pointermove\", move)\n svg.removeEventListener(\"pointerup\", up)\n svg.removeEventListener(\"pointercancel\", up)\n this.isPanning = false\n // The click after a drag comes next: forget the drag after it.\n E.soon(() => (this.wasDragged = false))\n }\n svg.addEventListener(\"pointermove\", move)\n svg.addEventListener(\"pointerup\", up)\n svg.addEventListener(\"pointercancel\", up)\n }\n\n /** A click on the background clears the selection. */\n private readonly onBackgroundClick = (event: MouseEvent) => {\n if (this.wasDragged || !this.selected) return\n this.selected = undefined as never\n this.send(\"ui-changed\", { value: undefined, originalEvent: event })\n }\n\n ////////////////\n // ## The modal\n ////////////////\n\n /** The modal's box the child graph goes in. Set as it draws. */\n private modalBody: HTMLElement | undefined\n\n /** The modal shows the children of `modalPath`: in a new graph of this same tag (so a subclass's look carries). */\n @E.onChange(\"modalPath\", \"isReady\")\n protected onModalPathChanged(path: string | undefined, isReady: boolean) {\n if (!isReady || !this.modalBody) return\n if (path === undefined) {\n this.modalBody.replaceChildren()\n return\n }\n const node = this.nodeAt(path)\n const graph = node && this.childrenOf(node, path)\n const inner = document.createElement(this.domElement.localName) as HTMLElement & {\n graph?: GraphData\n boundary?: readonly GraphPort[]\n }\n inner.graph = graph\n inner.boundary = node?.ports ?? []\n if (this.childView) inner.setAttribute(\"child-view\", String(this.childView))\n inner.classList.add(MODAL_GRAPH_CLASS)\n // Set on the element, as a page would: a sheet here never declares a public token (Spell UI's AGENTS.md, \"CSS\")\n inner.style.setProperty(\"--ui-graph-height\", MODAL_GRAPH_HEIGHT)\n this.modalBody.replaceChildren(inner)\n }\n\n /** The modal closed. */\n @E.on(\"ui-closed\", { target: \"renderRoot\" })\n protected onModalClosed(event: Event) {\n if (event.target === this.modalElement) this.modalPath = undefined\n }\n\n private modalElement: HTMLElement | undefined\n\n ////////////////\n // ## Drawing\n ////////////////\n\n protected override get extraClass(): string | undefined {\n return this.topGraph ? undefined : EMPTY\n }\n\n render(): JSX.Element {\n return (\n <div class={this.rootClass} part={this.partForName(\"graph\")}>\n <Show when={this.trail().length > 1}>{this.breadcrumbs()}</Show>\n <div class={TOOLBAR_CLASS} part={this.partForName(\"toolbar\")}>\n {this.toolButtons()}\n <button type=\"button\" onClick={() => this.fit()}>\n {this.translationForKey(\"graphFit\")}\n </button>\n </div>\n {this.overlay()}\n <svg\n ref={(svg: SVGSVGElement) => (this.svg = svg)}\n class={CANVAS_CLASS}\n part={this.partForName(\"canvas\")}\n role=\"group\"\n aria-label={this.translationForKey(\"graphSummary\", { count: this.layout?.nodes.length ?? 0 })}\n onWheel={this.onWheel}\n onPointerDown={this.onPointerDown}\n onClick={this.onBackgroundClick}\n >\n <g transform={`translate(${this.view.x} ${this.view.y}) scale(${this.view.k})`}>\n <For each={this.containers}>{(placed) => this.node(placed)}</For>\n <For each={this.layout?.edges ?? []}>{(edge) => this.edge(edge)}</For>\n <For each={this.leaves}>{(placed) => this.node(placed)}</For>\n <For each={this.layout?.pins ?? []}>{(pin) => this.pin(pin)}</For>\n </g>\n </svg>\n <ui-modal\n ref={(element: HTMLElement) => (this.modalElement = element)}\n size=\"large\"\n closable=\"\"\n heading={this.modalHeading()}\n visible={this.modalPath !== undefined ? \"\" : undefined}\n >\n <div ref={(div: HTMLElement) => (this.modalBody = div)} class={MODAL_BODY_CLASS} />\n </ui-modal>\n </div>\n )\n }\n\n /** The modal's heading: the node's label. */\n private modalHeading(): string | undefined {\n const path = this.modalPath\n const node = path === undefined ? undefined : this.nodeAt(path)\n return node && this.nodeLabel(node)\n }\n\n /** The trail back up (`trail()`), when there's one. */\n private breadcrumbs(): JSX.Element {\n return (\n <ui-breadcrumbs class={BREADCRUMBS_CLASS} part={this.partForName(\"breadcrumbs\")} divider=\"›\">\n <For each={this.trail()}>\n {(crumb, index) => (\n <ui-breadcrumb\n selected={index() === this.trail().length - 1 ? \"\" : undefined}\n onClick={() => {\n if (index() !== this.trail().length - 1) crumb.pick()\n }}\n >\n {crumb.label}\n </ui-breadcrumb>\n )}\n </For>\n </ui-breadcrumbs>\n )\n }\n\n /** One node: its `<g>` (part `node`, a container's also `container`), what `renderNode()` draws, ports, toggle. */\n private node(placed: GraphPlacedNode): JSX.Element {\n const kind = UIGraph.wordFor(placed.node.kind)\n const path = placed.path\n return (\n <g\n class={[\n NODE_CLASS,\n kind && `kind-${kind}`,\n this.nodeClass(placed.node),\n {\n [CONTAINER_CLASS]: placed.isOpen,\n [LIT_CLASS]: this.lit.has(path),\n [SELECTED_CLASS]: this.selectedPath === path,\n [LOADING_CLASS]: !!placed.isLoading\n }\n ]}\n part={[this.partForName(\"node\"), placed.isOpen && this.partForName(\"container\"), kind && `kind-${kind}`]\n .filter(Boolean)\n .join(\" \")}\n data-path={path}\n onClick={(event: MouseEvent) => this.choose({ kind: \"node\", id: placed.node.id, path }, placed.node, event)}\n onDblClick={(event: MouseEvent) => {\n event.stopPropagation()\n this.nodeDoubleClicked(placed, event)\n }}\n onPointerEnter={() => (this.hovered = { kind: \"node\", path })}\n onPointerLeave={() => this.unhover(path)}\n >\n <Show when={placed.node.title}>{(title) => <title>{title()}</title>}</Show>\n {this.renderNode(placed)}\n <For each={placed.ports}>{(port) => this.port(port, placed)}</For>\n <Show when={placed.hasChildren}>{this.toggleButton(placed)}</Show>\n </g>\n )\n }\n\n /** A node's open / close button (part `toggle`), at its top right. */\n private toggleButton(placed: GraphPlacedNode): JSX.Element {\n const label = () =>\n this.translationForKey(placed.isOpen ? \"graphCloseNode\" : \"graphOpenNode\", { label: this.nodeLabel(placed.node) })\n const cx = placed.x + placed.width - GRAPH_METRICS.toggleWidth / 2 - 4\n const cy = placed.isOpen ? placed.y + GRAPH_METRICS.headerHeight / 2 : placed.y + placed.height / 2\n return (\n <g\n class={TOGGLE_CLASS}\n part={this.partForName(\"toggle\")}\n role=\"button\"\n tabindex=\"0\"\n aria-expanded={placed.isOpen ? \"true\" : \"false\"}\n aria-label={label()}\n transform={`translate(${cx} ${cy})`}\n onClick={(event: MouseEvent) => this.toggle(placed, event)}\n onDblClick={(event: MouseEvent) => event.stopPropagation()}\n onKeyDown={(event: KeyboardEvent) => {\n if (event.key !== UIT.Key.enter && event.key !== UIT.Key.space) return\n event.preventDefault()\n this.toggle(placed, event)\n }}\n >\n <title>{label()}</title>\n <circle class={TOGGLE_TARGET_CLASS} r={10} />\n <circle class={TOGGLE_CIRCLE_CLASS} r={6} />\n <path class={TOGGLE_MARK_CLASS} d={placed.isOpen ? MINUS_MARK : PLUS_MARK} />\n </g>\n )\n }\n\n /** A port: its dot and label (part `port`). */\n private port(placed: GraphPlacedPort, owner: GraphPlacedNode): JSX.Element {\n const kind = UIGraph.wordFor(placed.port.kind)\n const label = this.portLabel(placed.port, owner.node)\n const r = GRAPH_METRICS.portRadius\n const labelAt =\n placed.side === \"left\"\n ? { x: placed.x + r + 3, y: placed.y, anchor: \"start\" as const }\n : placed.side === \"right\"\n ? { x: placed.x - r - 3, y: placed.y, anchor: \"end\" as const }\n : { x: placed.x, y: placed.side === \"top\" ? placed.y + r + 7 : placed.y - r - 7, anchor: \"middle\" as const }\n return (\n <g\n class={[\n PORT_CLASS,\n kind && `kind-${kind}`,\n this.portClass(placed.port, owner.node),\n { [LIT_CLASS]: this.lit.has(placed.path), [SELECTED_CLASS]: this.selectedPath === placed.path }\n ]}\n part={[this.partForName(\"port\"), kind && `kind-${kind}`].filter(Boolean).join(\" \")}\n onClick={(event: MouseEvent) =>\n this.choose({ kind: \"port\", id: placed.port.id, path: placed.path }, placed.port, event)\n }\n onPointerEnter={(event: PointerEvent) => {\n event.stopPropagation()\n this.hovered = { kind: \"port\", path: placed.path }\n }}\n onPointerLeave={() => (this.hovered = { kind: \"node\", path: owner.path })}\n >\n <circle class={PORT_DOT_CLASS} cx={placed.x} cy={placed.y} r={r} />\n <Show when={label && !(owner.isOpen && (placed.side === \"left\" || placed.side === \"right\"))}>\n <text\n class={PORT_LABEL_CLASS}\n x={labelAt.x}\n y={labelAt.y}\n text-anchor={labelAt.anchor}\n font-size={String(GRAPH_METRICS.portFontSize)}\n >\n {label}\n </text>\n </Show>\n </g>\n )\n }\n\n /** A pin: the enclosing node's port, on the graph's side (part `pin`). */\n private pin(pin: GraphPlacedPin): JSX.Element {\n const label = pin.port.label ?? pin.port.id\n return (\n <g\n class={[PIN_CLASS, { [LIT_CLASS]: this.lit.has(pin.path) }]}\n part={this.partForName(\"pin\")}\n onPointerEnter={() => (this.hovered = { kind: \"port\", path: pin.path })}\n onPointerLeave={() => this.unhover(pin.path)}\n onClick={(event: MouseEvent) => this.choose({ kind: \"port\", id: pin.port.id, path: pin.path }, pin.port, event)}\n >\n <path class={PIN_MARK_CLASS} d={`M${pin.x - 5} ${pin.y - 5}h10v10h-10z`} />\n <text\n class={PORT_LABEL_CLASS}\n x={pin.x}\n y={pin.y - 10}\n text-anchor=\"middle\"\n font-size={String(GRAPH_METRICS.portFontSize)}\n >\n {label}\n </text>\n </g>\n )\n }\n\n /** One edge: a wide unseen path to hit, the line (part `edge`), its label (part `edge-label`). */\n private edge(placed: GraphPlacedEdge): JSX.Element {\n const d = GraphLayout.pathFor(placed)\n const kind = UIGraph.wordFor(placed.edge.kind)\n const label = this.edgeLabel(placed.edge)\n const middle = GraphLayout.middleOf(placed)\n const select = (event: MouseEvent) =>\n this.choose({ kind: \"edge\", id: placed.id, path: placed.path }, placed.edge, event)\n return (\n <g\n class={[\n EDGE_GROUP_CLASS,\n kind && `kind-${kind}`,\n this.edgeClass(placed.edge),\n { [LIT_CLASS]: this.lit.has(placed.path), [SELECTED_CLASS]: this.selectedPath === placed.path }\n ]}\n onPointerEnter={() => (this.hovered = { kind: \"edge\", path: placed.path })}\n onPointerLeave={() => this.unhover(placed.path)}\n onClick={select}\n >\n <path class={EDGE_HIT_CLASS} d={d} />\n <path\n class={EDGE_CLASS}\n part={[this.partForName(\"edge\"), kind && `kind-${kind}`].filter(Boolean).join(\" \")}\n d={d}\n />\n <Show when={label}>\n <text\n class={EDGE_LABEL_CLASS}\n part={this.partForName(\"edge-label\")}\n x={middle.x}\n y={middle.y - 4}\n text-anchor=\"middle\"\n font-size={String(GRAPH_METRICS.portFontSize)}\n >\n {label}\n </text>\n </Show>\n </g>\n )\n }\n\n /** The pointer left `path`: nothing's hovered, unless something else already is. */\n private unhover(path: string) {\n if (this.hovered?.path === path) this.hovered = undefined\n }\n\n ////////////////\n // ## Helpers\n ////////////////\n\n /** `value` when it's a graph (an object with a `nodes` list); else `undefined`. */\n static graphFrom(value: unknown): GraphData | undefined {\n if (!value || typeof value !== \"object\" || !Array.isArray((value as GraphData).nodes)) return undefined\n const graph = value as GraphData\n return { nodes: graph.nodes, edges: Array.isArray(graph.edges) ? graph.edges : [] }\n }\n\n /** `value` when it's a child view's name. */\n private static viewFrom(value: unknown): GraphChildView | undefined {\n return GraphChildViews.includes(value as GraphChildView) ? (value as GraphChildView) : undefined\n }\n\n /** The paths of the nodes that start open (`open`), with given (not lazy) children, all the way down. */\n private static startOpen(graph: GraphData | undefined, prefix = \"\"): string[] {\n const paths: string[] = []\n for (const node of graph?.nodes ?? []) {\n const path = prefix ? `${prefix}/${node.id}` : node.id\n if (node.open && node.children && typeof node.children === \"object\") {\n paths.push(path, ...UIGraph.startOpen(UIGraph.graphFrom(node.children), path))\n }\n }\n return paths\n }\n\n /** `word` when it's safe in a class and a part name; else `undefined`. */\n private static wordFor(word: string | undefined): string | undefined {\n return word && /^[\\w-]+$/.test(word) ? word : undefined\n }\n\n /** `text`'s width at `size`, in `family`: measured on the page's one canvas (`TreeMeasure`), else estimated. */\n private static measure(text: string, size: number, family: string): number {\n return TreeMeasure.widthOf(text, `${size}px ${family}`) ?? text.length * size * GRAPH_METRICS.charWidth\n }\n}\n\n/** The vocabulary getters, typed (`UIComponent`'s doc). */\nexport interface UIGraph extends E.AttributeValues<typeof graphVocabulary> {}\n\n/** How far a press moves before it's a drag, in pixels. */\nconst DRAG_DISTANCE = 4\n\n/** Class word before the noun when there's nothing to draw (`ui empty graph`). */\nconst EMPTY = \"empty\"\n\nconst TOOLBAR_CLASS = \"toolbar\"\nconst BREADCRUMBS_CLASS = \"breadcrumbs\"\nconst CANVAS_CLASS = \"canvas\"\nconst NODE_CLASS = \"node\"\nconst CONTAINER_CLASS = \"container\"\nconst BOX_CLASS = \"box\"\nconst LABEL_CLASS = \"label\"\nconst PORT_CLASS = \"port\"\nconst PORT_DOT_CLASS = \"port-dot\"\nconst PORT_LABEL_CLASS = \"port-label\"\nconst PIN_CLASS = \"pin\"\nconst PIN_MARK_CLASS = \"pin-mark\"\nconst EDGE_GROUP_CLASS = \"edge-group\"\nconst EDGE_CLASS = \"edge\"\nconst EDGE_HIT_CLASS = \"edge-hit\"\nconst EDGE_LABEL_CLASS = \"edge-label\"\nconst LIT_CLASS = \"lit\"\nconst SELECTED_CLASS = \"selected\"\nconst LOADING_CLASS = \"loading\"\nconst TOGGLE_CLASS = \"toggle\"\nconst TOGGLE_TARGET_CLASS = \"toggle-target\"\nconst TOGGLE_CIRCLE_CLASS = \"toggle-circle\"\nconst TOGGLE_MARK_CLASS = \"toggle-mark\"\nconst MODAL_BODY_CLASS = \"modal-graph-box\"\n/** The class of the graph in the modal, for a page's or a subclass's own sheet. */\nconst MODAL_GRAPH_CLASS = \"modal-graph\"\n/** How tall the graph in the modal is. */\nconst MODAL_GRAPH_HEIGHT = \"70vh\"\n\n/** The toggle's `+` and `-`. */\nconst PLUS_MARK = \"M-3 0H3M0 -3V3\"\nconst MINUS_MARK = \"M-3 0H3\"\n","/**\n * The graph family: defines `<ui-graph>`, and exports its component.\n * - SIDE EFFECT: importing it defines the tag, and `<ui-modal>` and `<ui-breadcrumbs>` (what it shows children in).\n * - Also the library's `spell/ui/ui-graph` entry.\n * - `GraphLayout` (the pure layout) is exported too, for a page that wants the numbers alone.\n */\n\nimport { GraphLayout } from \"./GraphLayout\"\nimport { DOMGraphElement, UIGraph } from \"./UIGraph\"\n\nimport \"spell/ui/components/ui-modal\"\nimport \"spell/ui/components/ui-breadcrumbs\"\n\nUIGraph.define()\n\nexport { DOMGraphElement, GraphLayout, UIGraph }\nexport { GRAPH_METRICS, GraphChildViews, GraphPortSides } from \"./UIGraph.types\"\nexport type {\n GraphChildren,\n GraphChildView,\n GraphData,\n GraphEdge,\n GraphEnd,\n GraphLayoutOptions,\n GraphLayoutResult,\n GraphMetrics,\n GraphNode,\n GraphPlacedEdge,\n GraphPlacedNode,\n GraphPlacedPin,\n GraphPlacedPort,\n GraphPoint,\n GraphPort,\n GraphPortSide,\n GraphSelection\n} from \"./UIGraph.types\"\n"],"mappings":";;;;;;;;AAmFA,IAAagG,KAAiB;CAAC;CAAQ;CAAS;CAAO;AAAQ,GAIlDC,IAAkB;CAAC;CAAU;CAAS;AAAO,GAuG7CC,IAAgB;CAC3B,UAAU;CACV,cAAc;CAEd,WAAW;CACX,UAAU;CACV,YAAY;CACZ,cAAc;CAEd,aAAa;CACb,YAAY;CA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