ocean-brain 0.8.2 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/mcp.js +103 -105
- package/package.json +3 -2
- package/server/client/dist/assets/{ArrowRight.es-g2YZTklZ.js → ArrowRight.es-BEhnlwfe.js} +1 -1
- package/server/client/dist/assets/AuxiliaryPanelHeader-B1k7pZpn.js +1 -0
- package/server/client/dist/assets/Calendar-D7QJsAlg.js +25 -0
- package/server/client/dist/assets/{Callout-B_IPSF_5.js → Callout-BTd1BYtV.js} +1 -1
- package/server/client/dist/assets/{Copy.es-CNxe4ujr.js → Copy.es-BoLjilxv.js} +1 -1
- package/server/client/dist/assets/File.es-Ct7fscBg.js +1 -0
- package/server/client/dist/assets/Graph-DYUb7gQb.js +46 -0
- package/server/client/dist/assets/{Graph-D9GeO71k.js → Graph-LY_IgMYy.js} +1 -1
- package/server/client/dist/assets/{Image.es-DnON8cv2.js → Image.es-OYyN3BYt.js} +1 -1
- package/server/client/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/server/client/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/server/client/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/server/client/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/server/client/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/server/client/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/server/client/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/server/client/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/server/client/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/server/client/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/server/client/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/server/client/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/server/client/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/server/client/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/server/client/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/server/client/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/server/client/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/server/client/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/server/client/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/server/client/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/server/client/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/server/client/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/server/client/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/server/client/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/server/client/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/server/client/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/server/client/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/server/client/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/server/client/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/server/client/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/server/client/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/server/client/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/server/client/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/server/client/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/server/client/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/server/client/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/server/client/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/server/client/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/server/client/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/server/client/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/server/client/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/server/client/dist/assets/Note-DsMhwrHw.js +25 -0
- package/server/client/dist/assets/NotePropertiesPanel-aCKXAe5F.js +2 -0
- package/server/client/dist/assets/PencilLine.es-0JpEgxFY.js +1 -0
- package/server/client/dist/assets/{Plus.es-CQ8wn2is.js → Plus.es-DRfLW_bI.js} +1 -1
- package/server/client/dist/assets/Reminders-COr1OHvF.js +1 -0
- package/server/client/dist/assets/Search-Ctkx0BQk.js +31 -0
- package/server/client/dist/assets/SurfaceCard-t7pdfhEe.js +1 -0
- package/server/client/dist/assets/Tag-BjxtrIQW.js +1 -0
- package/server/client/dist/assets/TagNotes-DV_fdRbg.js +1 -0
- package/server/client/dist/assets/{Trash.es-0aPpA-3S.js → Trash.es-Bo1VyK9Q.js} +1 -1
- package/server/client/dist/assets/ViewChip-DlCkL4z4.js +1 -0
- package/server/client/dist/assets/ViewNotes-wWWeFJyU.js +1 -0
- package/server/client/dist/assets/ViewSectionDialog-DhH8harC.js +102 -0
- package/server/client/dist/assets/Views-CWE99SnI.js +1 -0
- package/server/client/dist/assets/abnfDiagram-VRR7QNED-CWlV5dXw.js +1 -0
- package/server/client/dist/assets/app-B9WZRrAH.css +1 -0
- package/server/client/dist/assets/app-BpSMjzET.js +26 -0
- package/server/client/dist/assets/arc-BV-n6RUX.js +1 -0
- package/server/client/dist/assets/architectureDiagram-ZJ3FMSHR-CekzMXdu.js +36 -0
- package/server/client/dist/assets/blockDiagram-677ZJIJ3-B49yHoxq.js +132 -0
- package/server/client/dist/assets/c4Diagram-LMCZKHZV-0AfB9NBC.js +10 -0
- package/server/client/dist/assets/channel-CigOulR-.js +1 -0
- package/server/client/dist/assets/chunk-2Q5K7J3B-DaPQAU1q.js +1 -0
- package/server/client/dist/assets/chunk-32BRIVSS-CfL3kZAg.js +1 -0
- package/server/client/dist/assets/chunk-5VM5RSS4-DeOwWPE_.js +15 -0
- package/server/client/dist/assets/chunk-EX3LRPZG-C3W1oc9y.js +231 -0
- package/server/client/dist/assets/chunk-JWPE2WC7-_Oqh79OY.js +1 -0
- package/server/client/dist/assets/chunk-MOJQB5TN-DDKNNzI6.js +88 -0
- package/server/client/dist/assets/chunk-RYQCIY6F-DCHah7CC.js +1 -0
- package/server/client/dist/assets/chunk-V7JOEXUC-uUOIzgxj.js +206 -0
- package/server/client/dist/assets/chunk-VR4S4FIN-DDVw2WPs.js +1 -0
- package/server/client/dist/assets/chunk-XXDRQBXY-Coo4UFm2.js +1 -0
- package/server/client/dist/assets/classDiagram-OUVF2IWQ-D13ISIOW.js +1 -0
- package/server/client/dist/assets/classDiagram-v2-EOCWNBFH-D13ISIOW.js +1 -0
- package/server/client/dist/assets/colors-Cc3OSVma.js +1 -0
- package/server/client/dist/assets/cose-bilkent-JH36ORCC-C3pHmHpD.js +1 -0
- package/server/client/dist/assets/cynefin-VYW2F7L2-DU_G4Atc.js +166 -0
- package/server/client/dist/assets/cynefinDiagram-TSTJHNR4-DZ6iiJFo.js +62 -0
- package/server/client/dist/assets/cytoscape.esm-D3_iZ_3b.js +321 -0
- package/server/client/dist/assets/dagre-VKFMJZFB-DNELbhwC.js +4 -0
- package/server/client/dist/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/server/client/dist/assets/diagram-FQU43EPY-CMEvZJ61.js +3 -0
- package/server/client/dist/assets/diagram-G47NLZAW-BYDtf6j9.js +24 -0
- package/server/client/dist/assets/diagram-NH7WQ7WH-CmXfcCQA.js +24 -0
- package/server/client/dist/assets/diagram-OA4YK3LP-BflTKJxU.js +30 -0
- package/server/client/dist/assets/diagram-WEI45ONY-KW3fKqna.js +41 -0
- package/server/client/dist/assets/ebnfDiagram-CCIWWBDH-CbyhY5Nj.js +1 -0
- package/server/client/dist/assets/erDiagram-Q63AITRT-CC2eZV8g.js +85 -0
- package/server/client/dist/assets/{floating-ui.react-dom-wWLZ1CdM.js → floating-ui.react-dom-BWTnA00G.js} +1 -1
- package/server/client/dist/assets/flowDiagram-23GEKE2U-unplo7Qm.js +156 -0
- package/server/client/dist/assets/ganttDiagram-NO4QXBWP-BcBK5HcZ.js +292 -0
- package/server/client/dist/assets/gitGraphDiagram-IHSO6WYX-DgVbbb5k.js +106 -0
- package/server/client/dist/assets/graph-C5DFNLrC.js +1 -0
- package/server/client/dist/assets/image-delete-confirmation-D7xrODQV.js +1 -0
- package/server/client/dist/assets/image.api-CyQisInP.js +17 -0
- package/server/client/dist/assets/index-B-E1Ilh9.js +1 -0
- package/server/client/dist/assets/infoDiagram-FWYZ7A6U-N_D9RdfG.js +2 -0
- package/server/client/dist/assets/init-Gi6I4Gst.js +1 -0
- package/server/client/dist/assets/isObject-U9U2HXiq.js +1 -0
- package/server/client/dist/assets/ishikawaDiagram-FXEZZL3T-BBKrzmB2.js +70 -0
- package/server/client/dist/assets/journeyDiagram-5HDEW3XC-NdCxLmQB.js +139 -0
- package/server/client/dist/assets/kanban-definition-HUTT4EX6-Ck7t4-tt.js +89 -0
- package/server/client/dist/assets/katex-DywYRkvg.css +1 -0
- package/server/client/dist/assets/katex-HP8lGamR.js +257 -0
- package/server/client/dist/assets/katex-x288kqHd.js +257 -0
- package/server/client/dist/assets/layout-Cz0MDlGi.js +1 -0
- package/server/client/dist/assets/linear-D6yRgDLq.js +1 -0
- package/server/client/dist/assets/manage-image-azmo5iVw.js +1 -0
- package/server/client/dist/assets/manage-image-detail-BF-uSqb_.js +1 -0
- package/server/client/dist/assets/map-Mm1V-_Na.js +1 -0
- package/server/client/dist/assets/{mcp-CT_9IV2c.js → mcp-CCaFd0zm.js} +4 -4
- package/server/client/dist/assets/{mcp-admin-adapter-xAuyZc_M.js → mcp-admin-adapter-PMmgPupc.js} +1 -1
- package/server/client/dist/assets/mermaid.core-B14ZAmWA.js +308 -0
- package/server/client/dist/assets/min-tv6RD-6E.js +1 -0
- package/server/client/dist/assets/mindmap-definition-LN4V7U3C-BTUqSdcP.js +96 -0
- package/server/client/dist/assets/{note-core-Buwzyxi7.js → note-core-DUTqUh5N.js} +2 -2
- package/server/client/dist/assets/{note-runtime-CPDVOFEo.js → note-runtime-zN5ddTba.js} +1 -1
- package/server/client/dist/assets/{note-ui-CHI-tzj-.js → note-ui-CtijppHK.js} +1 -1
- package/server/client/dist/assets/{note.api-D_00ZzJC.js → note.api-D3oJmG3q.js} +6 -6
- package/server/client/dist/assets/ordinal-Cboi1Yqb.js +1 -0
- package/server/client/dist/assets/pegDiagram-2B236MQR-Cjcu3mVz.js +1 -0
- package/server/client/dist/assets/pieDiagram-ENE6RG2P-BxI_c22Z.js +39 -0
- package/server/client/dist/assets/{placeholder-DbdGiYGL.js → placeholder-AusSo8p9.js} +4 -4
- package/server/client/dist/assets/properties-BrNJLkxR.js +1 -0
- package/server/client/dist/assets/quadrantDiagram-ABIIQ3AL-DGm0a-yR.js +7 -0
- package/server/client/dist/assets/railroadDiagram-RFXS5EU6-DmCDu89O.js +1 -0
- package/server/client/dist/assets/requirementDiagram-TGXJPOKE-CBpUt7Ig.js +84 -0
- package/server/client/dist/assets/route-preload.js +2 -2
- package/server/client/dist/assets/sankeyDiagram-HTMAVEWB-BjGnDZlp.js +40 -0
- package/server/client/dist/assets/search-D-xKTPdO.js +1 -0
- package/server/client/dist/assets/search-admin-adapter-CJnJmL6w.js +1 -0
- package/server/client/dist/assets/sequenceDiagram-DBY2YBRQ-B7rpCfS6.js +162 -0
- package/server/client/dist/assets/sizeCapture-X5ZJPWSS-CUJhD0uW.js +1 -0
- package/server/client/dist/assets/stateDiagram-2N3HPSRC-Y9-3XqRX.js +1 -0
- package/server/client/dist/assets/stateDiagram-v2-6OUMAXLB-DbHXhT02.js +1 -0
- package/server/client/dist/assets/swimlanes-5IMT3BWC-Cs1NO9ng.js +2 -0
- package/server/client/dist/assets/swimlanesDiagram-G3AALYLV-DQnrq2ZC.js +8 -0
- package/server/client/dist/assets/{tag.api-CX0SE06J.js → tag.api-DNSQpqwk.js} +3 -3
- package/server/client/dist/assets/time-D5LRMumI.js +9 -0
- package/server/client/dist/assets/timeline-definition-FHXFAJF6-8fqD4WNL.js +120 -0
- package/server/client/dist/assets/toNumber-DE3J3kMD.js +1 -0
- package/server/client/dist/assets/transform-BUB79_za.js +1 -0
- package/server/client/dist/assets/trash-D4-9sv8q.js +1 -0
- package/server/client/dist/assets/url-9nrbQs7Z.js +1 -0
- package/server/client/dist/assets/{useReminderMutate-CLK1tHvT.js → useReminderMutate-BrGO9M0o.js} +4 -4
- package/server/client/dist/assets/vennDiagram-L72KCM5P-BPqKkd5a.js +34 -0
- package/server/client/dist/assets/wardleyDiagram-EHGQE667-Cq11kU2M.js +78 -0
- package/server/client/dist/assets/xychartDiagram-FW5EYKEG-DJ6UzFj-.js +7 -0
- package/server/client/dist/index.html +7 -7
- package/server/dist/features/image/services/delete.js +25 -1
- package/server/dist/features/note/graphql/note.field.resolver.js +2 -0
- package/server/dist/features/note/graphql/note.mutation.resolver.js +54 -23
- package/server/dist/features/note/graphql/note.query.resolver.js +15 -5
- package/server/dist/features/note/graphql/note.type-defs.js +2 -1
- package/server/dist/features/note/http/mcp.js +1 -60
- package/server/dist/features/note/services/authoring.js +17 -80
- package/server/dist/features/note/services/markdown-patch.js +80 -8
- package/server/dist/features/note/services/note-reference-index.js +98 -0
- package/server/dist/features/note/services/properties.js +21 -1
- package/server/dist/features/note/services/property-restore.js +26 -0
- package/server/dist/features/note/services/search.js +5 -0
- package/server/dist/features/note/services/snapshot.js +82 -58
- package/server/dist/features/note/services/trash.js +18 -31
- package/server/dist/features/note/services/write.js +10 -3
- package/server/dist/features/search/embedding-api-key-store.js +57 -0
- package/server/dist/features/search/embedding-client.js +179 -0
- package/server/dist/features/search/graphql/index.js +6 -0
- package/server/dist/features/search/graphql/resolver.js +32 -0
- package/server/dist/features/search/graphql/type-defs.js +37 -0
- package/server/dist/features/search/http/handlers.js +108 -0
- package/server/dist/features/search/hybrid-ranking.js +57 -0
- package/server/dist/features/search/hybrid-search.js +176 -0
- package/server/dist/features/search/note-change.js +16 -0
- package/server/dist/features/search/note-chunking.js +75 -0
- package/server/dist/features/search/related-notes.js +186 -0
- package/server/dist/features/search/search-config.js +150 -0
- package/server/dist/features/search/search-manager.js +431 -0
- package/server/dist/features/search/semantic-indexer.js +138 -0
- package/server/dist/features/search/sqlite-vector-index.js +636 -0
- package/server/dist/features/search/url-normalization.js +10 -0
- package/server/dist/features/tag/services/organization.js +3 -0
- package/server/dist/features/view/services/workspace.js +1 -1
- package/server/dist/main.js +12 -3
- package/server/dist/modules/blocknote.js +4 -5
- package/server/dist/paths.js +7 -2
- package/server/dist/routes/api.js +37 -0
- package/server/dist/routes/mcp.js +0 -5
- package/server/dist/schema/index.js +3 -0
- package/server/prisma/migrations/20260728090000_0019_note_reference_index/migration.sql +15 -0
- package/server/prisma/schema.prisma +16 -0
- package/server/client/dist/assets/Calendar-BP6HTuSn.js +0 -25
- package/server/client/dist/assets/Graph-Xha3fwhp.js +0 -46
- package/server/client/dist/assets/Image-BLEjLUqd.js +0 -1
- package/server/client/dist/assets/Note-DjrCYtat.js +0 -24
- package/server/client/dist/assets/NotePropertiesPanel-2DgXEM4B.js +0 -2
- package/server/client/dist/assets/Reminders-B4l3KdlK.js +0 -1
- package/server/client/dist/assets/Search-BN5sf7bE.js +0 -1
- package/server/client/dist/assets/SurfaceCard-BZm73nyS.js +0 -1
- package/server/client/dist/assets/Tag-oSnmViVp.js +0 -1
- package/server/client/dist/assets/TagNotes-BDTCcJcL.js +0 -1
- package/server/client/dist/assets/ViewNotes-CiZtGJNE.js +0 -1
- package/server/client/dist/assets/ViewSectionDialog-Ctl_694Y.js +0 -102
- package/server/client/dist/assets/Views-D-zlatYD.js +0 -1
- package/server/client/dist/assets/app-DmqIOMWF.css +0 -1
- package/server/client/dist/assets/app-cTRcKMGc.js +0 -26
- package/server/client/dist/assets/image.api-CVuuvTBk.js +0 -17
- package/server/client/dist/assets/index-DKJChPr4.js +0 -1
- package/server/client/dist/assets/manage-image-BZjaxp-f.js +0 -1
- package/server/client/dist/assets/manage-image-detail-DPv0FQ2m.js +0 -1
- package/server/client/dist/assets/properties-D447wsWk.js +0 -1
- package/server/client/dist/assets/time-B3pt8vt4.js +0 -9
- package/server/client/dist/assets/trash-8sH7EZgc.js +0 -1
- package/server/client/dist/assets/url-BSnWpmJx.js +0 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import{p as Mt}from"./chunk-JWPE2WC7-_Oqh79OY.js";import{s as Nt,g as zt,o as Lt,n as Tt,a as At,b as Xt,_ as u,V as Et,y as Yt,A as J,l as Q,E as It,d as Bt,p as Ft,c as V}from"./mermaid.core-B14ZAmWA.js";import{p as Rt}from"./cynefin-VYW2F7L2-DU_G4Atc.js";import"./preload-helper-BXl3LOEh.js";import"./floating-ui.react-dom-BWTnA00G.js";import"./transform-BUB79_za.js";var G=u((o,r)=>{const e=o<=1?o*100:o;if(e<0||e>100)throw new Error(`${r} must be between 0-1 (decimal) or 0-100 (percentage). Received: ${o}`);return e},"toPercent"),A=u((o,r,e)=>({x:G(r,`${e} evolution`),y:G(o,`${e} visibility`)}),"toCoordinates"),K=u(o=>{if(o){if(o==="+<>")return"bidirectional";if(o==="+<")return"backward";if(o==="+>")return"forward"}},"getFlowFromPort"),Ot=u(o=>{if(!o?.startsWith("+"))return{};const e=/^\+'([^']*)'/.exec(o)?.[1];return o.includes("<>")?{flow:"bidirectional",label:e}:o.includes("<")?{flow:"backward",label:e}:o.includes(">")?{flow:"forward",label:e}:{label:e}},"extractFlowFromArrow"),Wt=u((o,r)=>{if(Mt(o,r),o.size&&r.setSize(o.size.width,o.size.height),o.evolution){const e=o.evolution.stages.map(a=>a.secondName?`${a.name.trim()} / ${a.secondName.trim()}`:a.name.trim()),h=o.evolution.stages.filter(a=>a.boundary!==void 0).map(a=>a.boundary);r.updateAxes({stages:e,stageBoundaries:h})}if(o.anchors.forEach(e=>{const h=A(e.visibility,e.evolution,`Anchor "${e.name}"`);r.addNode(e.name,e.name,h.x,h.y,"anchor")}),o.components.forEach(e=>{const h=A(e.visibility,e.evolution,`Component "${e.name}"`),a=e.label?(e.label.negX?-1:1)*e.label.offsetX:void 0,d=e.label?(e.label.negY?-1:1)*e.label.offsetY:void 0,w=e.decorator?.strategy;r.addNode(e.name,e.name,h.x,h.y,"component",a,d,e.inertia,w)}),o.notes.forEach(e=>{const h=A(e.visibility,e.evolution,`Note "${e.text}"`);r.addNote(e.text,h.x,h.y)}),o.pipelines.forEach(e=>{const h=r.getNode(e.parent);if(!h||typeof h.y!="number")throw new Error(`Pipeline "${e.parent}" must reference an existing component with coordinates.`);const a=h.y;r.startPipeline(e.parent),e.components.forEach(d=>{const w=`${e.parent}_${d.name}`,C=d.label?(d.label.negX?-1:1)*d.label.offsetX:void 0,g=d.label?(d.label.negY?-1:1)*d.label.offsetY:void 0,R=G(d.evolution,`Pipeline component "${d.name}" evolution`);r.addNode(w,d.name,R,a,"pipeline-component",C,g),r.addPipelineComponent(e.parent,w)})}),o.links.forEach(e=>{const h=!!e.arrow&&(e.arrow.includes("-.->")||e.arrow.includes(".-."));let a=K(e.fromPort)??K(e.toPort);const{flow:d,label:w}=Ot(e.arrow);!a&&d&&(a=d);const C=e.linkLabel,g=w??C;r.addLink(r.resolveNodeId(e.from),r.resolveNodeId(e.to),h,g,a)}),o.evolves.forEach(e=>{const h=r.getNode(e.component);if(h?.y!==void 0){const a=G(e.target,`Evolve target for "${e.component}"`);r.addTrend(e.component,a,h.y)}}),o.annotations.length>0){const e=o.annotations[0],h=A(e.x,e.y,"Annotations box");r.setAnnotationsBox(h.x,h.y)}o.annotation.forEach(e=>{const h=A(e.x,e.y,`Annotation ${e.number}`);r.addAnnotation(e.number,[{x:h.x,y:h.y}],e.text)}),o.accelerators.forEach(e=>{const h=A(e.x,e.y,`Accelerator "${e.name}"`);r.addAccelerator(e.name,h.x,h.y)}),o.deaccelerators.forEach(e=>{const h=A(e.x,e.y,`Deaccelerator "${e.name}"`);r.addDeaccelerator(e.name,h.x,h.y)})},"populateDb"),tt={parser:{yy:void 0},parse:u(async o=>{const r=await Rt("wardley",o);Q.debug(r);const e=tt.parser?.yy;if(!e||typeof e.addNode!="function")throw new Error("parser.parser?.yy was not a WardleyDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues.");Wt(r,e)},"parse")},E,Dt=(E=class{constructor(){this.nodes=new Map,this.links=[],this.trends=new Map,this.pipelines=new Map,this.annotations=[],this.notes=[],this.accelerators=[],this.deaccelerators=[],this.axes={}}addNode(r){const e=this.nodes.get(r.id)??{id:r.id,label:r.label},h={...e,...r,className:r.className??e.className,labelOffsetX:r.labelOffsetX??e.labelOffsetX,labelOffsetY:r.labelOffsetY??e.labelOffsetY};this.nodes.set(r.id,h)}addLink(r){this.links.push(r)}addTrend(r){this.trends.set(r.nodeId,r)}startPipeline(r){this.pipelines.set(r,{nodeId:r,componentIds:[]});const e=this.nodes.get(r);e&&(e.isPipelineParent=!0)}addPipelineComponent(r,e){const h=this.pipelines.get(r);h&&h.componentIds.push(e);const a=this.nodes.get(e);a&&(a.inPipeline=!0)}addAnnotation(r){this.annotations.push(r)}addNote(r){this.notes.push(r)}addAccelerator(r){this.accelerators.push(r)}addDeaccelerator(r){this.deaccelerators.push(r)}setAnnotationsBox(r,e){this.annotationsBox={x:r,y:e}}setAxes(r){this.axes={...this.axes,...r}}setSize(r,e){this.size={width:r,height:e}}getNode(r){return this.nodes.get(r)}resolveNodeId(r){if(this.nodes.has(r))return r;for(const[e,h]of this.nodes)if(h.label===r)return e;return r}build(){const r=[];for(const e of this.nodes.values()){if(typeof e.x!="number"||typeof e.y!="number")throw new Error(`Node "${e.label}" is missing coordinates`);r.push(e)}return{nodes:r,links:[...this.links],trends:[...this.trends.values()],pipelines:[...this.pipelines.values()],annotations:[...this.annotations],notes:[...this.notes],accelerators:[...this.accelerators],deaccelerators:[...this.deaccelerators],annotationsBox:this.annotationsBox,axes:{...this.axes},size:this.size}}clear(){this.nodes.clear(),this.links=[],this.trends.clear(),this.pipelines.clear(),this.annotations=[],this.notes=[],this.accelerators=[],this.deaccelerators=[],this.annotationsBox=void 0,this.axes={},this.size=void 0}},u(E,"WardleyBuilder"),E),k=new Dt;function et(){return V()["wardley-beta"]}u(et,"getConfig");function at(o,r,e,h,a,d,w,C,g){k.addNode({id:o,label:r,x:e,y:h,className:a,labelOffsetX:d,labelOffsetY:w,inertia:C,sourceStrategy:g})}u(at,"addNode");function rt(o,r,e=!1,h,a){k.addLink({source:o,target:r,dashed:e,label:h,flow:a})}u(rt,"addLink");function ot(o,r,e){k.addTrend({nodeId:o,targetX:r,targetY:e})}u(ot,"addTrend");function nt(o,r,e){k.addAnnotation({number:o,coordinates:r,text:e})}u(nt,"addAnnotation");function st(o,r,e){k.addNote({text:o,x:r,y:e})}u(st,"addNote");function it(o,r,e){k.addAccelerator({name:o,x:r,y:e})}u(it,"addAccelerator");function dt(o,r,e){k.addDeaccelerator({name:o,x:r,y:e})}u(dt,"addDeaccelerator");function lt(o,r){k.setAnnotationsBox(o,r)}u(lt,"setAnnotationsBox");function ct(o,r){k.setSize(o,r)}u(ct,"setSize");function pt(o){k.startPipeline(o)}u(pt,"startPipeline");function ft(o,r){k.addPipelineComponent(o,r)}u(ft,"addPipelineComponent");function ht(o){k.setAxes(o)}u(ht,"updateAxes");function xt(o){return k.getNode(o)}u(xt,"getNode");function gt(o){return k.resolveNodeId(o)}u(gt,"resolveNodeId");function yt(){return k.build()}u(yt,"getWardleyData");function ut(){k.clear(),Ft()}u(ut,"clear");var Gt={getConfig:et,addNode:at,addLink:rt,addTrend:ot,addAnnotation:nt,addNote:st,addAccelerator:it,addDeaccelerator:dt,setAnnotationsBox:lt,setSize:ct,startPipeline:pt,addPipelineComponent:ft,updateAxes:ht,getNode:xt,resolveNodeId:gt,getWardleyData:yt,clear:ut,setAccTitle:Xt,getAccTitle:At,setDiagramTitle:Tt,getDiagramTitle:Lt,getAccDescription:zt,setAccDescription:Nt},qt=["Genesis","Custom Built","Product","Commodity"],Ht=u(()=>{const{themeVariables:o}=V();return{backgroundColor:o.wardley?.backgroundColor??o.background??"#fff",axisColor:o.wardley?.axisColor??"#000",axisTextColor:o.wardley?.axisTextColor??o.primaryTextColor??"#222",gridColor:o.wardley?.gridColor??"rgba(100, 100, 100, 0.2)",componentFill:o.wardley?.componentFill??"#fff",componentStroke:o.wardley?.componentStroke??"#000",componentLabelColor:o.wardley?.componentLabelColor??o.primaryTextColor??"#222",linkStroke:o.wardley?.linkStroke??"#000",evolutionStroke:o.wardley?.evolutionStroke??"#dc3545",annotationStroke:o.wardley?.annotationStroke??"#000",annotationTextColor:o.wardley?.annotationTextColor??o.primaryTextColor??"#222",annotationFill:o.wardley?.annotationFill??o.background??"#fff"}},"getTheme"),jt=u(()=>{const o=V()["wardley-beta"];return{width:o?.width??900,height:o?.height??600,padding:o?.padding??48,nodeRadius:o?.nodeRadius??6,nodeLabelOffset:o?.nodeLabelOffset??8,axisFontSize:o?.axisFontSize??12,labelFontSize:o?.labelFontSize??10,showGrid:o?.showGrid??!1,useMaxWidth:o?.useMaxWidth??!0}},"getConfigValues"),Vt=u((o,r,e,h)=>{Q.debug(`Rendering Wardley map
|
|
2
|
+
`+o);const a=jt(),d=Ht(),w=a.nodeRadius*1.6,C=h.db,g=C.getWardleyData(),R=C.getDiagramTitle(),S=g.size?.width??a.width,b=g.size?.height??a.height,Y=It(r);Y.selectAll("*").remove(),Bt(Y,b,S,a.useMaxWidth),Y.attr("viewBox",`0 0 ${S} ${b}`);const v=Y.append("g").attr("class","wardley-map"),q=Y.append("defs");q.append("marker").attr("id",`arrow-${r}`).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerWidth",6).attr("markerHeight",6).attr("orient","auto-start-reverse").append("path").attr("d","M 0 0 L 10 5 L 0 10 z").attr("fill",d.evolutionStroke).attr("stroke","none"),q.append("marker").attr("id",`link-arrow-end-${r}`).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerWidth",5).attr("markerHeight",5).attr("orient","auto").append("path").attr("d","M 0 0 L 10 5 L 0 10 z").attr("fill",d.linkStroke).attr("stroke","none"),q.append("marker").attr("id",`link-arrow-start-${r}`).attr("viewBox","0 0 10 10").attr("refX",1).attr("refY",5).attr("markerWidth",5).attr("markerHeight",5).attr("orient","auto").append("path").attr("d","M 10 0 L 0 5 L 10 10 z").attr("fill",d.linkStroke).attr("stroke","none"),v.append("rect").attr("class","wardley-background").attr("width",S).attr("height",b).attr("fill",d.backgroundColor);const I=S-a.padding*2,B=b-a.padding*2;R&&v.append("text").attr("class","wardley-title").attr("x",S/2).attr("y",a.padding/2).attr("fill",d.axisTextColor).attr("font-size",a.axisFontSize*1.05).attr("font-weight","bold").attr("text-anchor","middle").attr("dominant-baseline","middle").text(R);const z=u(t=>a.padding+t/100*I,"projectX"),L=u(t=>b-a.padding-t/100*B,"projectY"),O=v.append("g").attr("class","wardley-axes");O.append("line").attr("x1",a.padding).attr("x2",S-a.padding).attr("y1",b-a.padding).attr("y2",b-a.padding).attr("stroke",d.axisColor).attr("stroke-width",1),O.append("line").attr("x1",a.padding).attr("x2",a.padding).attr("y1",a.padding).attr("y2",b-a.padding).attr("stroke",d.axisColor).attr("stroke-width",1);const wt=g.axes.xLabel??"Evolution",mt=g.axes.yLabel??"Visibility";O.append("text").attr("class","wardley-axis-label wardley-axis-label-x").attr("x",a.padding+I/2).attr("y",b-a.padding/4).attr("fill",d.axisTextColor).attr("font-size",a.axisFontSize).attr("font-weight","bold").attr("text-anchor","middle").text(wt),O.append("text").attr("class","wardley-axis-label wardley-axis-label-y").attr("x",a.padding/3).attr("y",a.padding+B/2).attr("fill",d.axisTextColor).attr("font-size",a.axisFontSize).attr("font-weight","bold").attr("text-anchor","middle").attr("transform",`rotate(-90 ${a.padding/3} ${a.padding+B/2})`).text(mt);const F=g.axes.stages&&g.axes.stages.length>0?g.axes.stages:qt;if(F.length>0){const t=v.append("g").attr("class","wardley-stages"),s=g.axes.stageBoundaries,n=[];if(s&&s.length===F.length){let i=0;s.forEach(p=>{n.push({start:i,end:p}),i=p})}else{const i=1/F.length;F.forEach((p,l)=>{n.push({start:l*i,end:(l+1)*i})})}F.forEach((i,p)=>{const l=n[p],f=a.padding+l.start*I,x=a.padding+l.end*I,y=(f+x)/2;p>0&&t.append("line").attr("x1",f).attr("x2",f).attr("y1",a.padding).attr("y2",b-a.padding).attr("stroke","#000").attr("stroke-width",1).attr("stroke-dasharray","5 5").attr("opacity",.8),t.append("text").attr("class","wardley-stage-label").attr("x",y).attr("y",b-a.padding/1.5).attr("fill",d.axisTextColor).attr("font-size",a.axisFontSize-2).attr("text-anchor","middle").text(i)})}if(a.showGrid){const t=v.append("g").attr("class","wardley-grid");for(let s=1;s<4;s++){const n=s/4,i=a.padding+I*n;t.append("line").attr("x1",i).attr("x2",i).attr("y1",a.padding).attr("y2",b-a.padding).attr("stroke",d.gridColor).attr("stroke-dasharray","2 6"),t.append("line").attr("x1",a.padding).attr("x2",S-a.padding).attr("y1",b-a.padding-B*n).attr("y2",b-a.padding-B*n).attr("stroke",d.gridColor).attr("stroke-dasharray","2 6")}}const c=new Map;if(g.nodes.forEach(t=>{c.set(t.id,{x:z(t.x),y:L(t.y),node:t})}),g.pipelines.length>0){const t=v.append("g").attr("class","wardley-pipelines"),s=v.append("g").attr("class","wardley-pipeline-links");g.pipelines.forEach(n=>{if(n.componentIds.length===0)return;const i=n.componentIds.map(x=>({id:x,pos:c.get(x),node:g.nodes.find(y=>y.id===x)})).filter(x=>x.pos&&x.node).sort((x,y)=>x.node.x-y.node.x);for(let x=0;x<i.length-1;x++){const y=i[x],m=i[x+1];s.append("line").attr("class","wardley-pipeline-evolution-link").attr("x1",y.pos.x).attr("y1",y.pos.y).attr("x2",m.pos.x).attr("y2",m.pos.y).attr("stroke",d.linkStroke).attr("stroke-width",1).attr("stroke-dasharray","4 4")}let p=1/0,l=-1/0,f=0;if(n.componentIds.forEach(x=>{const y=c.get(x);y&&(p=Math.min(p,y.x),l=Math.max(l,y.x),f=y.y)}),p!==1/0&&l!==-1/0){const y=a.nodeRadius*4,m=f-y/2,P=c.get(n.nodeId);if(P){const N=(p+l)/2;P.x=N,P.y=m-w/6}t.append("rect").attr("class","wardley-pipeline-box").attr("x",p-15).attr("y",m).attr("width",l-p+30).attr("height",y).attr("fill","none").attr("stroke",d.axisColor).attr("stroke-width",1.5).attr("rx",4).attr("ry",4)}})}const _=v.append("g").attr("class","wardley-links"),Z=new Map;g.pipelines.forEach(t=>{Z.set(t.nodeId,new Set(t.componentIds))});const U=g.links.filter(t=>!(!c.has(t.source)||!c.has(t.target)||Z.get(t.target)?.has(t.source)));_.selectAll("line").data(U).enter().append("line").attr("class",t=>`wardley-link${t.dashed?" wardley-link--dashed":""}`).attr("x1",t=>{const s=c.get(t.source),n=c.get(t.target),p=g.nodes.find(y=>y.id===t.source).isPipelineParent?w/Math.sqrt(2):a.nodeRadius,l=n.x-s.x,f=n.y-s.y,x=Math.sqrt(l*l+f*f);return s.x+l/x*p}).attr("y1",t=>{const s=c.get(t.source),n=c.get(t.target),p=g.nodes.find(y=>y.id===t.source).isPipelineParent?w/Math.sqrt(2):a.nodeRadius,l=n.x-s.x,f=n.y-s.y,x=Math.sqrt(l*l+f*f);return s.y+f/x*p}).attr("x2",t=>{const s=c.get(t.source),n=c.get(t.target),p=g.nodes.find(y=>y.id===t.target).isPipelineParent?w/Math.sqrt(2):a.nodeRadius,l=s.x-n.x,f=s.y-n.y,x=Math.sqrt(l*l+f*f);return n.x+l/x*p}).attr("y2",t=>{const s=c.get(t.source),n=c.get(t.target),p=g.nodes.find(y=>y.id===t.target).isPipelineParent?w/Math.sqrt(2):a.nodeRadius,l=s.x-n.x,f=s.y-n.y,x=Math.sqrt(l*l+f*f);return n.y+f/x*p}).attr("stroke",d.linkStroke).attr("stroke-width",1).attr("stroke-dasharray",t=>t.dashed?"6 6":null).attr("marker-end",t=>t.flow==="forward"||t.flow==="bidirectional"?`url(#link-arrow-end-${r})`:null).attr("marker-start",t=>t.flow==="backward"||t.flow==="bidirectional"?`url(#link-arrow-start-${r})`:null),_.selectAll("text").data(U.filter(t=>t.label)).enter().append("text").attr("class","wardley-link-label").attr("x",t=>{const s=c.get(t.source),n=c.get(t.target),i=(s.x+n.x)/2,p=n.y-s.y,l=n.x-s.x,f=Math.sqrt(l*l+p*p),x=8,y=p/f;return i+y*x}).attr("y",t=>{const s=c.get(t.source),n=c.get(t.target),i=(s.y+n.y)/2,p=n.x-s.x,l=n.y-s.y,f=Math.sqrt(p*p+l*l),x=8,y=-p/f;return i+y*x}).attr("fill",d.axisTextColor).attr("font-size",a.labelFontSize).attr("text-anchor","middle").attr("dominant-baseline","middle").attr("transform",t=>{const s=c.get(t.source),n=c.get(t.target),i=(s.x+n.x)/2,p=(s.y+n.y)/2,l=n.x-s.x,f=n.y-s.y,x=Math.sqrt(l*l+f*f),y=8,m=f/x,P=-l/x,N=i+m*y,W=p+P*y;let X=Math.atan2(f,l)*180/Math.PI;return(X>90||X<-90)&&(X+=180),`rotate(${X} ${N} ${W})`}).text(t=>t.label);const kt=v.append("g").attr("class","wardley-trends"),bt=g.trends.map(t=>{const s=c.get(t.nodeId);if(!s)return null;const n=z(t.targetX),i=L(t.targetY),p=n-s.x,l=i-s.y,f=Math.sqrt(p*p+l*l),x=a.nodeRadius+2,y=f>x?n-p/f*x:n,m=f>x?i-l/f*x:i;return{origin:s,targetX:n,targetY:i,adjustedX2:y,adjustedY2:m}}).filter(t=>t!==null);kt.selectAll("line").data(bt).enter().append("line").attr("class","wardley-trend").attr("x1",t=>t.origin.x).attr("y1",t=>t.origin.y).attr("x2",t=>t.adjustedX2).attr("y2",t=>t.adjustedY2).attr("stroke",d.evolutionStroke).attr("stroke-width",1).attr("stroke-dasharray","4 4").attr("marker-end",`url(#arrow-${r})`);const M=v.append("g").attr("class","wardley-nodes").selectAll("g").data(g.nodes).enter().append("g").attr("class",t=>["wardley-node",t.className?`wardley-node--${t.className}`:""].filter(Boolean).join(" "));M.filter(t=>t.sourceStrategy==="outsource").append("circle").attr("class","wardley-outsource-overlay").attr("cx",t=>c.get(t.id).x).attr("cy",t=>c.get(t.id).y).attr("r",a.nodeRadius*2).attr("fill","#666").attr("stroke",d.componentStroke).attr("stroke-width",1),M.filter(t=>t.sourceStrategy==="buy").append("circle").attr("class","wardley-buy-overlay").attr("cx",t=>c.get(t.id).x).attr("cy",t=>c.get(t.id).y).attr("r",a.nodeRadius*2).attr("fill","#ccc").attr("stroke",d.componentStroke).attr("stroke-width",1),M.filter(t=>t.sourceStrategy==="build").append("circle").attr("class","wardley-build-overlay").attr("cx",t=>c.get(t.id).x).attr("cy",t=>c.get(t.id).y).attr("r",a.nodeRadius*2).attr("fill","#eee").attr("stroke","#000").attr("stroke-width",1);const T=M.filter(t=>t.sourceStrategy==="market");T.append("circle").attr("class","wardley-market-overlay").attr("cx",t=>c.get(t.id).x).attr("cy",t=>c.get(t.id).y).attr("r",a.nodeRadius*2).attr("fill","white").attr("stroke",d.componentStroke).attr("stroke-width",1),M.filter(t=>!t.isPipelineParent&&t.sourceStrategy!=="market"&&t.className!=="anchor").append("circle").attr("cx",t=>c.get(t.id).x).attr("cy",t=>c.get(t.id).y).attr("r",a.nodeRadius).attr("fill",d.componentFill).attr("stroke",d.componentStroke).attr("stroke-width",1);const H=a.nodeRadius*.7,$=a.nodeRadius*1.2;if(T.append("line").attr("class","wardley-market-line").attr("x1",t=>c.get(t.id).x).attr("y1",t=>c.get(t.id).y-$).attr("x2",t=>c.get(t.id).x-$*Math.cos(Math.PI/6)).attr("y2",t=>c.get(t.id).y+$*Math.sin(Math.PI/6)).attr("stroke",d.componentStroke).attr("stroke-width",1),T.append("line").attr("class","wardley-market-line").attr("x1",t=>c.get(t.id).x-$*Math.cos(Math.PI/6)).attr("y1",t=>c.get(t.id).y+$*Math.sin(Math.PI/6)).attr("x2",t=>c.get(t.id).x+$*Math.cos(Math.PI/6)).attr("y2",t=>c.get(t.id).y+$*Math.sin(Math.PI/6)).attr("stroke",d.componentStroke).attr("stroke-width",1),T.append("line").attr("class","wardley-market-line").attr("x1",t=>c.get(t.id).x+$*Math.cos(Math.PI/6)).attr("y1",t=>c.get(t.id).y+$*Math.sin(Math.PI/6)).attr("x2",t=>c.get(t.id).x).attr("y2",t=>c.get(t.id).y-$).attr("stroke",d.componentStroke).attr("stroke-width",1),T.append("circle").attr("class","wardley-market-dot").attr("cx",t=>c.get(t.id).x).attr("cy",t=>c.get(t.id).y-$).attr("r",H).attr("fill","white").attr("stroke",d.componentStroke).attr("stroke-width",2),T.append("circle").attr("class","wardley-market-dot").attr("cx",t=>c.get(t.id).x-$*Math.cos(Math.PI/6)).attr("cy",t=>c.get(t.id).y+$*Math.sin(Math.PI/6)).attr("r",H).attr("fill","white").attr("stroke",d.componentStroke).attr("stroke-width",2),T.append("circle").attr("class","wardley-market-dot").attr("cx",t=>c.get(t.id).x+$*Math.cos(Math.PI/6)).attr("cy",t=>c.get(t.id).y+$*Math.sin(Math.PI/6)).attr("r",H).attr("fill","white").attr("stroke",d.componentStroke).attr("stroke-width",2),M.filter(t=>t.isPipelineParent===!0).append("rect").attr("x",t=>c.get(t.id).x-w/2).attr("y",t=>c.get(t.id).y-w/2).attr("width",w).attr("height",w).attr("fill",d.componentFill).attr("stroke",d.componentStroke).attr("stroke-width",1),M.filter(t=>t.inertia===!0).append("line").attr("class","wardley-inertia").attr("x1",t=>{const s=c.get(t.id);let n=t.isPipelineParent?w/2+15:a.nodeRadius+15;return t.sourceStrategy&&(n+=a.nodeRadius+10),s.x+n}).attr("y1",t=>{const s=c.get(t.id),n=t.isPipelineParent?w:a.nodeRadius*2;return s.y-n/2}).attr("x2",t=>{const s=c.get(t.id);let n=t.isPipelineParent?w/2+15:a.nodeRadius+15;return t.sourceStrategy&&(n+=a.nodeRadius+10),s.x+n}).attr("y2",t=>{const s=c.get(t.id),n=t.isPipelineParent?w:a.nodeRadius*2;return s.y+n/2}).attr("stroke",d.componentStroke).attr("stroke-width",6),M.append("text").attr("x",t=>{const s=c.get(t.id);if(t.className==="anchor")return t.labelOffsetX!==void 0?s.x+t.labelOffsetX:s.x;let n=a.nodeLabelOffset;t.sourceStrategy&&t.labelOffsetX===void 0&&(n+=10);const i=t.labelOffsetX??n;return s.x+i}).attr("y",t=>{const s=c.get(t.id);if(t.className==="anchor")return t.labelOffsetY!==void 0?s.y+t.labelOffsetY:s.y-3;let n=-a.nodeLabelOffset;t.sourceStrategy&&t.labelOffsetY===void 0&&(n-=10);const i=t.labelOffsetY??n;return s.y+i}).attr("class","wardley-node-label").attr("fill",t=>t.className==="evolved"?d.evolutionStroke:t.className==="anchor"?"#000":d.componentLabelColor).attr("font-size",a.labelFontSize).attr("font-weight",t=>t.className==="anchor"?"bold":"normal").attr("text-anchor",t=>t.className==="anchor"?"middle":"start").attr("dominant-baseline",t=>t.className==="anchor"?"middle":"auto").text(t=>t.label),g.annotations.length>0){const t=v.append("g").attr("class","wardley-annotations");if(g.annotations.forEach(s=>{const n=s.coordinates.map(i=>({x:z(i.x),y:L(i.y)}));if(n.length>1)for(let i=0;i<n.length-1;i++)t.append("line").attr("class","wardley-annotation-line").attr("x1",n[i].x).attr("y1",n[i].y).attr("x2",n[i+1].x).attr("y2",n[i+1].y).attr("stroke",d.axisColor).attr("stroke-width",1.5).attr("stroke-dasharray","4 4");n.forEach(i=>{const p=t.append("g").attr("class","wardley-annotation");p.append("circle").attr("cx",i.x).attr("cy",i.y).attr("r",10).attr("fill","white").attr("stroke",d.axisColor).attr("stroke-width",1.5),p.append("text").attr("x",i.x).attr("y",i.y).attr("text-anchor","middle").attr("dominant-baseline","central").attr("font-size",10).attr("fill",d.axisTextColor).attr("font-weight","bold").text(s.number)})}),g.annotationsBox){let s=z(g.annotationsBox.x),n=L(g.annotationsBox.y);const i=10,p=16,l=11,f=t.append("g").attr("class","wardley-annotations-box"),x=[...g.annotations].filter(m=>m.text).sort((m,P)=>m.number-P.number),y=[];if(x.forEach((m,P)=>{const N=f.append("text").attr("x",s+i).attr("y",n+i+(P+1)*p).attr("font-size",l).attr("fill",d.axisTextColor).attr("text-anchor","start").attr("dominant-baseline","middle").text(`${m.number}. ${m.text}`);y.push(N)}),y.length>0){let m=0,P=0;y.forEach(j=>{const D=j.node(),Ct=D.getComputedTextLength();m=Math.max(m,Ct);const St=D.getBBox();P=Math.max(P,St.height)});const N=m+i*2+105,W=x.length*p+i*2+P/2,X=a.padding,$t=S-a.padding-N,vt=a.padding,Pt=b-a.padding-W;s=Math.max(X,Math.min(s,$t)),n=Math.max(vt,Math.min(n,Pt)),y.forEach((j,D)=>{j.attr("x",s+i).attr("y",n+i+(D+1)*p)}),f.insert("rect","text").attr("x",s).attr("y",n).attr("width",N).attr("height",W).attr("fill","white").attr("stroke",d.axisColor).attr("stroke-width",1.5).attr("rx",4).attr("ry",4)}}}if(g.notes.length>0){const t=v.append("g").attr("class","wardley-notes");g.notes.forEach(s=>{const n=z(s.x),i=L(s.y);t.append("text").attr("x",n).attr("y",i).attr("text-anchor","start").attr("font-size",11).attr("fill",d.axisTextColor).attr("font-weight","bold").text(s.text)})}if(g.accelerators.length>0){const t=v.append("g").attr("class","wardley-accelerators");g.accelerators.forEach(s=>{const n=z(s.x),i=L(s.y),p=60,l=30,f=20,x=`
|
|
3
|
+
M ${n} ${i-l/2}
|
|
4
|
+
L ${n+p-f} ${i-l/2}
|
|
5
|
+
L ${n+p-f} ${i-l/2-8}
|
|
6
|
+
L ${n+p} ${i}
|
|
7
|
+
L ${n+p-f} ${i+l/2+8}
|
|
8
|
+
L ${n+p-f} ${i+l/2}
|
|
9
|
+
L ${n} ${i+l/2}
|
|
10
|
+
Z
|
|
11
|
+
`;t.append("path").attr("d",x).attr("fill","white").attr("stroke",d.componentStroke).attr("stroke-width",1),t.append("text").attr("x",n+p/2).attr("y",i+l/2+15).attr("text-anchor","middle").attr("font-size",10).attr("fill",d.axisTextColor).attr("font-weight","bold").text(s.name)})}if(g.deaccelerators.length>0){const t=v.append("g").attr("class","wardley-deaccelerators");g.deaccelerators.forEach(s=>{const n=z(s.x),i=L(s.y),p=60,l=30,f=20,x=`
|
|
12
|
+
M ${n+p} ${i-l/2}
|
|
13
|
+
L ${n+f} ${i-l/2}
|
|
14
|
+
L ${n+f} ${i-l/2-8}
|
|
15
|
+
L ${n} ${i}
|
|
16
|
+
L ${n+f} ${i+l/2+8}
|
|
17
|
+
L ${n+f} ${i+l/2}
|
|
18
|
+
L ${n+p} ${i+l/2}
|
|
19
|
+
Z
|
|
20
|
+
`;t.append("path").attr("d",x).attr("fill","white").attr("stroke",d.componentStroke).attr("stroke-width",1),t.append("text").attr("x",n+p/2).attr("y",i+l/2+15).attr("text-anchor","middle").attr("font-size",10).attr("fill",d.axisTextColor).attr("font-weight","bold").text(s.name)})}},"draw"),_t={draw:Vt},Zt=u(({wardley:o}={})=>{const r=Et(),e=Yt(),h=J(r,e.themeVariables),a=J(h.wardley,o);return`
|
|
21
|
+
.wardley-background {
|
|
22
|
+
fill: ${a.backgroundColor};
|
|
23
|
+
}
|
|
24
|
+
.wardley-axes line, .wardley-axes path {
|
|
25
|
+
stroke: ${a.axisColor};
|
|
26
|
+
}
|
|
27
|
+
.wardley-axis-label {
|
|
28
|
+
fill: ${a.axisTextColor};
|
|
29
|
+
}
|
|
30
|
+
.wardley-stage-label {
|
|
31
|
+
fill: ${a.axisTextColor};
|
|
32
|
+
}
|
|
33
|
+
.wardley-grid line {
|
|
34
|
+
stroke: ${a.gridColor};
|
|
35
|
+
}
|
|
36
|
+
.wardley-node circle {
|
|
37
|
+
fill: ${a.componentFill};
|
|
38
|
+
stroke: ${a.componentStroke};
|
|
39
|
+
}
|
|
40
|
+
.wardley-node-label {
|
|
41
|
+
fill: ${a.componentLabelColor};
|
|
42
|
+
}
|
|
43
|
+
.wardley-link {
|
|
44
|
+
stroke: ${a.linkStroke};
|
|
45
|
+
}
|
|
46
|
+
.wardley-link--dashed {
|
|
47
|
+
stroke-dasharray: 4 4;
|
|
48
|
+
}
|
|
49
|
+
.wardley-link-label {
|
|
50
|
+
fill: ${a.axisTextColor};
|
|
51
|
+
}
|
|
52
|
+
.wardley-trend line {
|
|
53
|
+
stroke: ${a.evolutionStroke};
|
|
54
|
+
}
|
|
55
|
+
.wardley-annotation-line {
|
|
56
|
+
stroke: ${a.annotationStroke};
|
|
57
|
+
}
|
|
58
|
+
.wardley-annotation circle {
|
|
59
|
+
fill: ${a.annotationFill};
|
|
60
|
+
stroke: ${a.annotationStroke};
|
|
61
|
+
}
|
|
62
|
+
.wardley-annotation text {
|
|
63
|
+
fill: ${a.annotationTextColor};
|
|
64
|
+
}
|
|
65
|
+
.wardley-annotations-box rect {
|
|
66
|
+
fill: ${a.annotationFill};
|
|
67
|
+
stroke: ${a.annotationStroke};
|
|
68
|
+
}
|
|
69
|
+
.wardley-annotations-box text {
|
|
70
|
+
fill: ${a.annotationTextColor};
|
|
71
|
+
}
|
|
72
|
+
.wardley-pipeline-box {
|
|
73
|
+
stroke: ${a.componentStroke};
|
|
74
|
+
}
|
|
75
|
+
.wardley-notes text {
|
|
76
|
+
fill: ${a.axisTextColor};
|
|
77
|
+
}
|
|
78
|
+
`},"styles"),re={parser:tt,db:Gt,renderer:_t,styles:Zt};export{re as diagram};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{s as xi,g as di,o as Yt,n as fi,a as pi,b as mi,_ as n,l as Nt,E as yi,d as bi,p as Ai,y as kt,h as wi,A as Ht,B as Ci,V as Si,ay as Ri,a6 as Ot}from"./mermaid.core-B14ZAmWA.js";import"./transform-BUB79_za.js";import{i as _i}from"./init-Gi6I4Gst.js";import{o as ki}from"./ordinal-Cboi1Yqb.js";import{l as Wt}from"./linear-D6yRgDLq.js";import"./preload-helper-BXl3LOEh.js";import"./floating-ui.react-dom-BWTnA00G.js";import"./defaultLocale-DX6XiGOO.js";function Ti(e,t,i){e=+e,t=+t,i=(a=arguments.length)<2?(t=e,e=0,1):a<3?1:+i;for(var s=-1,a=Math.max(0,Math.ceil((t-e)/i))|0,o=new Array(a);++s<a;)o[s]=e+s*i;return o}function wt(){var e=ki().unknown(void 0),t=e.domain,i=e.range,s=0,a=1,o,l,f=!1,d=0,k=0,T=.5;delete e.unknown;function _(){var b=t().length,E=a<s,L=E?a:s,P=E?s:a;o=(P-L)/Math.max(1,b-d+k*2),f&&(o=Math.floor(o)),L+=(P-L-o*(b-d))*T,l=o*(1-d),f&&(L=Math.round(L),l=Math.round(l));var I=Ti(b).map(function(m){return L+o*m});return i(E?I.reverse():I)}return e.domain=function(b){return arguments.length?(t(b),_()):t()},e.range=function(b){return arguments.length?([s,a]=b,s=+s,a=+a,_()):[s,a]},e.rangeRound=function(b){return[s,a]=b,s=+s,a=+a,f=!0,_()},e.bandwidth=function(){return l},e.step=function(){return o},e.round=function(b){return arguments.length?(f=!!b,_()):f},e.padding=function(b){return arguments.length?(d=Math.min(1,k=+b),_()):d},e.paddingInner=function(b){return arguments.length?(d=Math.min(1,b),_()):d},e.paddingOuter=function(b){return arguments.length?(k=+b,_()):k},e.align=function(b){return arguments.length?(T=Math.max(0,Math.min(1,b)),_()):T},e.copy=function(){return wt(t(),[s,a]).round(f).paddingInner(d).paddingOuter(k).align(T)},_i.apply(_(),arguments)}var Ct=(function(){var e=n(function(F,h,u,g){for(u=u||{},g=F.length;g--;u[F[g]]=h);return u},"o"),t=[1,10,12,14,16,18,19,21,23],i=[2,6],s=[1,3],a=[1,5],o=[1,6],l=[1,7],f=[1,5,10,12,14,16,18,19,21,23,36,37,38],d=[1,25],k=[1,26],T=[1,28],_=[1,29],b=[1,30],E=[1,31],L=[1,32],P=[1,33],I=[1,34],m=[1,35],D=[1,36],c=[1,37],z=[1,43],W=[1,42],X=[1,47],Y=[1,50],S=[1,10,12,14,16,18,19,21,23,36,37,38],H=[1,10,12,14,16,18,19,21,23,24,26,28,29,36,37,38],A=[1,10,12,14,16,18,19,21,23,24,26,28,29,36,37,38,42,43,44,45,46,47,48,49,50,51],w=[1,65],B=[26,28],R={trace:n(function(){},"trace"),yy:{},symbols_:{error:2,start:3,eol:4,XYCHART:5,chartConfig:6,document:7,CHART_ORIENTATION:8,statement:9,title:10,text:11,X_AXIS:12,parseXAxis:13,Y_AXIS:14,parseYAxis:15,LINE:16,plotData:17,BAR:18,acc_title:19,acc_title_value:20,acc_descr:21,acc_descr_value:22,acc_descr_multiline_value:23,SQUARE_BRACES_START:24,dataPoints:25,SQUARE_BRACES_END:26,dataPoint:27,COMMA:28,NUMBER_WITH_DECIMAL:29,STR:30,xAxisData:31,bandData:32,ARROW_DELIMITER:33,commaSeparatedTexts:34,yAxisData:35,NEWLINE:36,SEMI:37,EOF:38,alphaNum:39,MD_STR:40,alphaNumToken:41,AMP:42,NUM:43,ALPHA:44,PLUS:45,EQUALS:46,MULT:47,DOT:48,BRKT:49,MINUS:50,UNDERSCORE:51,$accept:0,$end:1},terminals_:{2:"error",5:"XYCHART",8:"CHART_ORIENTATION",10:"title",12:"X_AXIS",14:"Y_AXIS",16:"LINE",18:"BAR",19:"acc_title",20:"acc_title_value",21:"acc_descr",22:"acc_descr_value",23:"acc_descr_multiline_value",24:"SQUARE_BRACES_START",26:"SQUARE_BRACES_END",28:"COMMA",29:"NUMBER_WITH_DECIMAL",30:"STR",33:"ARROW_DELIMITER",36:"NEWLINE",37:"SEMI",38:"EOF",40:"MD_STR",42:"AMP",43:"NUM",44:"ALPHA",45:"PLUS",46:"EQUALS",47:"MULT",48:"DOT",49:"BRKT",50:"MINUS",51:"UNDERSCORE"},productions_:[0,[3,2],[3,3],[3,2],[3,1],[6,1],[7,0],[7,2],[9,2],[9,2],[9,2],[9,2],[9,2],[9,3],[9,2],[9,3],[9,2],[9,2],[9,1],[17,3],[25,3],[25,1],[27,2],[27,1],[13,1],[13,2],[13,1],[31,1],[31,3],[32,3],[34,3],[34,1],[15,1],[15,2],[15,1],[35,3],[4,1],[4,1],[4,1],[11,1],[11,1],[11,1],[39,1],[39,2],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1]],performAction:n(function(h,u,g,x,C,r,rt){var p=r.length-1;switch(C){case 5:x.setOrientation(r[p]);break;case 9:x.setDiagramTitle(r[p].text.trim());break;case 12:x.setLineData({text:"",type:"text"},r[p]);break;case 13:x.setLineData(r[p-1],r[p]);break;case 14:x.setBarData({text:"",type:"text"},r[p]);break;case 15:x.setBarData(r[p-1],r[p]);break;case 16:this.$=r[p].trim(),x.setAccTitle(this.$);break;case 17:case 18:this.$=r[p].trim(),x.setAccDescription(this.$);break;case 19:this.$=r[p-1];break;case 20:case 30:this.$=[r[p-2],...r[p]];break;case 21:case 31:this.$=[r[p]];break;case 22:this.$={value:Number(r[p-1]),label:r[p]};break;case 23:this.$={value:Number(r[p]),label:""};break;case 24:x.setXAxisTitle(r[p]);break;case 25:x.setXAxisTitle(r[p-1]);break;case 26:x.setXAxisTitle({type:"text",text:""});break;case 27:x.setXAxisBand(r[p]);break;case 28:x.setXAxisRangeData(Number(r[p-2]),Number(r[p]));break;case 29:this.$=r[p-1];break;case 32:x.setYAxisTitle(r[p]);break;case 33:x.setYAxisTitle(r[p-1]);break;case 34:x.setYAxisTitle({type:"text",text:""});break;case 35:x.setYAxisRangeData(Number(r[p-2]),Number(r[p]));break;case 39:this.$={text:r[p],type:"text"};break;case 40:this.$={text:r[p],type:"text"};break;case 41:this.$={text:r[p],type:"markdown"};break;case 42:this.$=r[p];break;case 43:this.$=r[p-1]+""+r[p];break}},"anonymous"),table:[e(t,i,{3:1,4:2,7:4,5:s,36:a,37:o,38:l}),{1:[3]},e(t,i,{4:2,7:4,3:8,5:s,36:a,37:o,38:l}),e(t,i,{4:2,7:4,6:9,3:10,5:s,8:[1,11],36:a,37:o,38:l}),{1:[2,4],9:12,10:[1,13],12:[1,14],14:[1,15],16:[1,16],18:[1,17],19:[1,18],21:[1,19],23:[1,20]},e(f,[2,36]),e(f,[2,37]),e(f,[2,38]),{1:[2,1]},e(t,i,{4:2,7:4,3:21,5:s,36:a,37:o,38:l}),{1:[2,3]},e(f,[2,5]),e(t,[2,7],{4:22,36:a,37:o,38:l}),{11:23,30:d,39:24,40:k,41:27,42:T,43:_,44:b,45:E,46:L,47:P,48:I,49:m,50:D,51:c},{11:39,13:38,24:z,29:W,30:d,31:40,32:41,39:24,40:k,41:27,42:T,43:_,44:b,45:E,46:L,47:P,48:I,49:m,50:D,51:c},{11:45,15:44,29:X,30:d,35:46,39:24,40:k,41:27,42:T,43:_,44:b,45:E,46:L,47:P,48:I,49:m,50:D,51:c},{11:49,17:48,24:Y,30:d,39:24,40:k,41:27,42:T,43:_,44:b,45:E,46:L,47:P,48:I,49:m,50:D,51:c},{11:52,17:51,24:Y,30:d,39:24,40:k,41:27,42:T,43:_,44:b,45:E,46:L,47:P,48:I,49:m,50:D,51:c},{20:[1,53]},{22:[1,54]},e(S,[2,18]),{1:[2,2]},e(S,[2,8]),e(S,[2,9]),e(H,[2,39],{41:55,42:T,43:_,44:b,45:E,46:L,47:P,48:I,49:m,50:D,51:c}),e(H,[2,40]),e(H,[2,41]),e(A,[2,42]),e(A,[2,44]),e(A,[2,45]),e(A,[2,46]),e(A,[2,47]),e(A,[2,48]),e(A,[2,49]),e(A,[2,50]),e(A,[2,51]),e(A,[2,52]),e(A,[2,53]),e(S,[2,10]),e(S,[2,24],{32:41,31:56,24:z,29:W}),e(S,[2,26]),e(S,[2,27]),{33:[1,57]},{11:59,30:d,34:58,39:24,40:k,41:27,42:T,43:_,44:b,45:E,46:L,47:P,48:I,49:m,50:D,51:c},e(S,[2,11]),e(S,[2,32],{35:60,29:X}),e(S,[2,34]),{33:[1,61]},e(S,[2,12]),{17:62,24:Y},{25:63,27:64,29:w},e(S,[2,14]),{17:66,24:Y},e(S,[2,16]),e(S,[2,17]),e(A,[2,43]),e(S,[2,25]),{29:[1,67]},{26:[1,68]},{26:[2,31],28:[1,69]},e(S,[2,33]),{29:[1,70]},e(S,[2,13]),{26:[1,71]},{26:[2,21],28:[1,72]},e(B,[2,23],{30:[1,73]}),e(S,[2,15]),e(S,[2,28]),e(S,[2,29]),{11:59,30:d,34:74,39:24,40:k,41:27,42:T,43:_,44:b,45:E,46:L,47:P,48:I,49:m,50:D,51:c},e(S,[2,35]),e(S,[2,19]),{25:75,27:64,29:w},e(B,[2,22]),{26:[2,30]},{26:[2,20]}],defaultActions:{8:[2,1],10:[2,3],21:[2,2],74:[2,30],75:[2,20]},parseError:n(function(h,u){if(u.recoverable)this.trace(h);else{var g=new Error(h);throw g.hash=u,g}},"parseError"),parse:n(function(h){var u=this,g=[0],x=[],C=[null],r=[],rt=this.table,p="",gt=0,Mt=0,li=2,Vt=1,ci=r.slice.call(arguments,1),v=Object.create(this.lexer),U={yy:{}};for(var mt in this.yy)Object.prototype.hasOwnProperty.call(this.yy,mt)&&(U.yy[mt]=this.yy[mt]);v.setInput(h,U.yy),U.yy.lexer=v,U.yy.parser=this,typeof v.yylloc>"u"&&(v.yylloc={});var yt=v.yylloc;r.push(yt);var ui=v.options&&v.options.ranges;typeof U.yy.parseError=="function"?this.parseError=U.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function gi(V){g.length=g.length-2*V,C.length=C.length-V,r.length=r.length-V}n(gi,"popStack");function zt(){var V;return V=x.pop()||v.lex()||Vt,typeof V!="number"&&(V instanceof Array&&(x=V,V=x.pop()),V=u.symbols_[V]||V),V}n(zt,"lex");for(var M,$,O,bt,G={},xt,N,Bt,dt;;){if($=g[g.length-1],this.defaultActions[$]?O=this.defaultActions[$]:((M===null||typeof M>"u")&&(M=zt()),O=rt[$]&&rt[$][M]),typeof O>"u"||!O.length||!O[0]){var At="";dt=[];for(xt in rt[$])this.terminals_[xt]&&xt>li&&dt.push("'"+this.terminals_[xt]+"'");v.showPosition?At="Parse error on line "+(gt+1)+`:
|
|
2
|
+
`+v.showPosition()+`
|
|
3
|
+
Expecting `+dt.join(", ")+", got '"+(this.terminals_[M]||M)+"'":At="Parse error on line "+(gt+1)+": Unexpected "+(M==Vt?"end of input":"'"+(this.terminals_[M]||M)+"'"),this.parseError(At,{text:v.match,token:this.terminals_[M]||M,line:v.yylineno,loc:yt,expected:dt})}if(O[0]instanceof Array&&O.length>1)throw new Error("Parse Error: multiple actions possible at state: "+$+", token: "+M);switch(O[0]){case 1:g.push(M),C.push(v.yytext),r.push(v.yylloc),g.push(O[1]),M=null,Mt=v.yyleng,p=v.yytext,gt=v.yylineno,yt=v.yylloc;break;case 2:if(N=this.productions_[O[1]][1],G.$=C[C.length-N],G._$={first_line:r[r.length-(N||1)].first_line,last_line:r[r.length-1].last_line,first_column:r[r.length-(N||1)].first_column,last_column:r[r.length-1].last_column},ui&&(G._$.range=[r[r.length-(N||1)].range[0],r[r.length-1].range[1]]),bt=this.performAction.apply(G,[p,Mt,gt,U.yy,O[1],C,r].concat(ci)),typeof bt<"u")return bt;N&&(g=g.slice(0,-1*N*2),C=C.slice(0,-1*N),r=r.slice(0,-1*N)),g.push(this.productions_[O[1]][0]),C.push(G.$),r.push(G._$),Bt=rt[g[g.length-2]][g[g.length-1]],g.push(Bt);break;case 3:return!0}}return!0},"parse")},ot=(function(){var F={EOF:1,parseError:n(function(u,g){if(this.yy.parser)this.yy.parser.parseError(u,g);else throw new Error(u)},"parseError"),setInput:n(function(h,u){return this.yy=u||this.yy||{},this._input=h,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:n(function(){var h=this._input[0];this.yytext+=h,this.yyleng++,this.offset++,this.match+=h,this.matched+=h;var u=h.match(/(?:\r\n?|\n).*/g);return u?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),h},"input"),unput:n(function(h){var u=h.length,g=h.split(/(?:\r\n?|\n)/g);this._input=h+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-u),this.offset-=u;var x=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),g.length-1&&(this.yylineno-=g.length-1);var C=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:g?(g.length===x.length?this.yylloc.first_column:0)+x[x.length-g.length].length-g[0].length:this.yylloc.first_column-u},this.options.ranges&&(this.yylloc.range=[C[0],C[0]+this.yyleng-u]),this.yyleng=this.yytext.length,this},"unput"),more:n(function(){return this._more=!0,this},"more"),reject:n(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
|
|
4
|
+
`+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:n(function(h){this.unput(this.match.slice(h))},"less"),pastInput:n(function(){var h=this.matched.substr(0,this.matched.length-this.match.length);return(h.length>20?"...":"")+h.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:n(function(){var h=this.match;return h.length<20&&(h+=this._input.substr(0,20-h.length)),(h.substr(0,20)+(h.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:n(function(){var h=this.pastInput(),u=new Array(h.length+1).join("-");return h+this.upcomingInput()+`
|
|
5
|
+
`+u+"^"},"showPosition"),test_match:n(function(h,u){var g,x,C;if(this.options.backtrack_lexer&&(C={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(C.yylloc.range=this.yylloc.range.slice(0))),x=h[0].match(/(?:\r\n?|\n).*/g),x&&(this.yylineno+=x.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:x?x[x.length-1].length-x[x.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+h[0].length},this.yytext+=h[0],this.match+=h[0],this.matches=h,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(h[0].length),this.matched+=h[0],g=this.performAction.call(this,this.yy,this,u,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),g)return g;if(this._backtrack){for(var r in C)this[r]=C[r];return!1}return!1},"test_match"),next:n(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var h,u,g,x;this._more||(this.yytext="",this.match="");for(var C=this._currentRules(),r=0;r<C.length;r++)if(g=this._input.match(this.rules[C[r]]),g&&(!u||g[0].length>u[0].length)){if(u=g,x=r,this.options.backtrack_lexer){if(h=this.test_match(g,C[r]),h!==!1)return h;if(this._backtrack){u=!1;continue}else return!1}else if(!this.options.flex)break}return u?(h=this.test_match(u,C[x]),h!==!1?h:!1):this._input===""?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+`. Unrecognized text.
|
|
6
|
+
`+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:n(function(){var u=this.next();return u||this.lex()},"lex"),begin:n(function(u){this.conditionStack.push(u)},"begin"),popState:n(function(){var u=this.conditionStack.length-1;return u>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:n(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},"_currentRules"),topState:n(function(u){return u=this.conditionStack.length-1-Math.abs(u||0),u>=0?this.conditionStack[u]:"INITIAL"},"topState"),pushState:n(function(u){this.begin(u)},"pushState"),stateStackSize:n(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:n(function(u,g,x,C){switch(x){case 0:break;case 1:break;case 2:return this.popState(),36;case 3:return this.popState(),36;case 4:return 36;case 5:break;case 6:return 10;case 7:return this.pushState("acc_title"),19;case 8:return this.popState(),"acc_title_value";case 9:return this.pushState("acc_descr"),21;case 10:return this.popState(),"acc_descr_value";case 11:this.pushState("acc_descr_multiline");break;case 12:this.popState();break;case 13:return"acc_descr_multiline_value";case 14:return 5;case 15:return 5;case 16:return 8;case 17:return this.pushState("axis_data"),"X_AXIS";case 18:return this.pushState("axis_data"),"Y_AXIS";case 19:return this.pushState("axis_band_data"),24;case 20:return 33;case 21:return this.pushState("data"),16;case 22:return this.pushState("data"),18;case 23:return this.pushState("data_inner"),24;case 24:return 29;case 25:return this.popState(),26;case 26:this.popState();break;case 27:this.pushState("string");break;case 28:this.popState();break;case 29:return"STR";case 30:return 24;case 31:return 26;case 32:return 44;case 33:return"COLON";case 34:return 45;case 35:return 28;case 36:return 46;case 37:return 47;case 38:return 49;case 39:return 51;case 40:return 48;case 41:return 42;case 42:return 50;case 43:return 43;case 44:break;case 45:return 37;case 46:return 38}},"anonymous"),rules:[/^(?:%%(?!\{)[^\n]*)/i,/^(?:[^\}]%%[^\n]*)/i,/^(?:(\r?\n))/i,/^(?:(\r?\n))/i,/^(?:[\n\r]+)/i,/^(?:%%[^\n]*)/i,/^(?:title\b)/i,/^(?:accTitle\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*\{\s*)/i,/^(?:\})/i,/^(?:[^\}]*)/i,/^(?:xychart-beta\b)/i,/^(?:xychart\b)/i,/^(?:(?:vertical|horizontal))/i,/^(?:x-axis\b)/i,/^(?:y-axis\b)/i,/^(?:\[)/i,/^(?:-->)/i,/^(?:line\b)/i,/^(?:bar\b)/i,/^(?:\[)/i,/^(?:[+-]?(?:\d+(?:\.\d+)?|\.\d+))/i,/^(?:\])/i,/^(?:(?:`\) \{ this\.pushState\(md_string\); \}\n<md_string>\(\?:\(\?!`"\)\.\)\+ \{ return MD_STR; \}\n<md_string>\(\?:`))/i,/^(?:["])/i,/^(?:["])/i,/^(?:[^"]*)/i,/^(?:\[)/i,/^(?:\])/i,/^(?:[A-Za-z]+)/i,/^(?::)/i,/^(?:\+)/i,/^(?:,)/i,/^(?:=)/i,/^(?:\*)/i,/^(?:#)/i,/^(?:[\_])/i,/^(?:\.)/i,/^(?:&)/i,/^(?:-)/i,/^(?:[0-9]+)/i,/^(?:\s+)/i,/^(?:;)/i,/^(?:$)/i],conditions:{data_inner:{rules:[0,1,4,5,6,7,9,11,14,15,16,17,18,21,22,24,25,26,27,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0},data:{rules:[0,1,3,4,5,6,7,9,11,14,15,16,17,18,21,22,23,26,27,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0},axis_band_data:{rules:[0,1,4,5,6,7,9,11,14,15,16,17,18,21,22,25,26,27,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0},axis_data:{rules:[0,1,2,4,5,6,7,9,11,14,15,16,17,18,19,20,21,22,24,26,27,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0},acc_descr_multiline:{rules:[12,13],inclusive:!1},acc_descr:{rules:[10],inclusive:!1},acc_title:{rules:[8],inclusive:!1},title:{rules:[],inclusive:!1},md_string:{rules:[],inclusive:!1},string:{rules:[28,29],inclusive:!1},INITIAL:{rules:[0,1,4,5,6,7,9,11,14,15,16,17,18,21,22,26,27,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0}}};return F})();R.lexer=ot;function q(){this.yy={}}return n(q,"Parser"),q.prototype=R,R.Parser=q,new q})();Ct.parser=Ct;var Di=Ct;function St(e){return e.type==="bar"}n(St,"isBarPlot");function ft(e){return e.type==="band"}n(ft,"isBandAxisData");function j(e){return e.type==="linear"}n(j,"isLinearAxisData");var Q,Ut=(Q=class{constructor(t){this.parentGroup=t}getMaxDimension(t,i){if(!this.parentGroup)return{width:t.reduce((o,l)=>Math.max(l.length,o),0)*i,height:i};const s={width:0,height:0},a=this.parentGroup.append("g").attr("visibility","hidden").attr("font-size",i);for(const o of t){const l=Ri(a,1,o),f=l?l.width:o.length*i,d=l?l.height:i;s.width=Math.max(s.width,f),s.height=Math.max(s.height,d)}return a.remove(),s}},n(Q,"TextDimensionCalculatorWithFont"),Q),Ft=.7,Xt=.2,K,$t=(K=class{constructor(t,i,s,a){this.axisConfig=t,this.title=i,this.textDimensionCalculator=s,this.axisThemeConfig=a,this.boundingRect={x:0,y:0,width:0,height:0},this.axisPosition="left",this.showTitle=!1,this.showLabel=!1,this.showTick=!1,this.showAxisLine=!1,this.outerPadding=0,this.titleTextHeight=0,this.labelTextHeight=0,this.normalizedLabelRotationInRad=0,this.range=[0,10],this.boundingRect={x:0,y:0,width:0,height:0},this.axisPosition="left",this.normalizedLabelRotationInRad=this.axisConfig.labelRotation>=-90&&this.axisConfig.labelRotation<=90?this.axisConfig.labelRotation*Math.PI/180:0}setRange(t){this.range=t,this.axisPosition==="left"||this.axisPosition==="right"?this.boundingRect.height=t[1]-t[0]:this.boundingRect.width=t[1]-t[0],this.recalculateScale()}getRange(){return[this.range[0]+this.outerPadding,this.range[1]-this.outerPadding]}setAxisPosition(t){this.axisPosition=t,this.setRange(this.range)}getTickDistance(){const t=this.getRange();return Math.abs(t[0]-t[1])/this.getTickValues().length}getAxisOuterPadding(){return this.outerPadding}getLabelDimension(){return this.textDimensionCalculator.getMaxDimension(this.getTickValues().map(t=>t.toString()),this.axisConfig.labelFontSize)}recalculateOuterPaddingToDrawBar(){Ft*this.getTickDistance()>this.outerPadding*2&&(this.outerPadding=Math.floor(Ft*this.getTickDistance()/2)),this.recalculateScale()}calculateSpaceIfDrawnHorizontally(t){let i=t.height;if(this.axisConfig.showAxisLine&&i>this.axisConfig.axisLineWidth&&(i-=this.axisConfig.axisLineWidth,this.showAxisLine=!0),this.axisConfig.showLabel){const s=this.getLabelDimension(),a=Xt*t.width;this.outerPadding=Math.min(s.width/2,a);let o=s.height;this.axisPosition==="bottom"&&this.normalizedLabelRotationInRad!==0&&(o=Math.max(o,Math.abs(Math.sin(this.normalizedLabelRotationInRad)*s.width)+Math.abs(Math.cos(this.normalizedLabelRotationInRad)*s.height))),o+=this.axisConfig.labelPadding*2,this.labelTextHeight=s.height,o<=i&&(i-=o,this.showLabel=!0)}if(this.axisConfig.showTick&&i>=this.axisConfig.tickLength&&(this.showTick=!0,i-=this.axisConfig.tickLength),this.axisConfig.showTitle&&this.title){const s=this.textDimensionCalculator.getMaxDimension([this.title],this.axisConfig.titleFontSize),a=s.height+this.axisConfig.titlePadding*2;this.titleTextHeight=s.height,a<=i&&(i-=a,this.showTitle=!0)}this.boundingRect.width=t.width,this.boundingRect.height=t.height-i}calculateSpaceIfDrawnVertical(t){let i=t.width;if(this.axisConfig.showAxisLine&&i>this.axisConfig.axisLineWidth&&(i-=this.axisConfig.axisLineWidth,this.showAxisLine=!0),this.axisConfig.showLabel){const s=this.getLabelDimension(),a=Xt*t.height;this.outerPadding=Math.min(s.height/2,a);const o=s.width+this.axisConfig.labelPadding*2;o<=i&&(i-=o,this.showLabel=!0)}if(this.axisConfig.showTick&&i>=this.axisConfig.tickLength&&(this.showTick=!0,i-=this.axisConfig.tickLength),this.axisConfig.showTitle&&this.title){const s=this.textDimensionCalculator.getMaxDimension([this.title],this.axisConfig.titleFontSize),a=s.height+this.axisConfig.titlePadding*2;this.titleTextHeight=s.height,a<=i&&(i-=a,this.showTitle=!0)}this.boundingRect.width=t.width-i,this.boundingRect.height=t.height}calculateSpace(t){return this.axisPosition==="left"||this.axisPosition==="right"?this.calculateSpaceIfDrawnVertical(t):this.calculateSpaceIfDrawnHorizontally(t),this.recalculateScale(),{width:this.boundingRect.width,height:this.boundingRect.height}}setBoundingBoxXY(t){this.boundingRect.x=t.x,this.boundingRect.y=t.y}calculateOffsetByRotation(t){const i=this.normalizedLabelRotationInRad;return i===0?0:Math.sin(i)*this.getLabelDimension()[t]/2}getDrawableElementsForLeftAxis(){const t=[];if(this.showAxisLine){const i=this.boundingRect.x+this.boundingRect.width-this.axisConfig.axisLineWidth/2;t.push({type:"path",groupTexts:["left-axis","axisl-line"],data:[{path:`M ${i},${this.boundingRect.y} L ${i},${this.boundingRect.y+this.boundingRect.height} `,strokeFill:this.axisThemeConfig.axisLineColor,strokeWidth:this.axisConfig.axisLineWidth}]})}if(this.showLabel&&t.push({type:"text",groupTexts:["left-axis","label"],data:this.getTickValues().map(i=>({text:i.toString(),x:this.boundingRect.x+this.boundingRect.width-(this.showLabel?this.axisConfig.labelPadding:0)-(this.showTick?this.axisConfig.tickLength:0)-(this.showAxisLine?this.axisConfig.axisLineWidth:0),y:this.getScaleValue(i),fill:this.axisThemeConfig.labelColor,fontSize:this.axisConfig.labelFontSize,rotation:0,verticalPos:"middle",horizontalPos:"right"}))}),this.showTick){const i=this.boundingRect.x+this.boundingRect.width-(this.showAxisLine?this.axisConfig.axisLineWidth:0);t.push({type:"path",groupTexts:["left-axis","ticks"],data:this.getTickValues().map(s=>({path:`M ${i},${this.getScaleValue(s)} L ${i-this.axisConfig.tickLength},${this.getScaleValue(s)}`,strokeFill:this.axisThemeConfig.tickColor,strokeWidth:this.axisConfig.tickWidth}))})}return this.showTitle&&t.push({type:"text",groupTexts:["left-axis","title"],data:[{text:this.title,x:this.boundingRect.x+this.axisConfig.titlePadding,y:this.boundingRect.y+this.boundingRect.height/2,fill:this.axisThemeConfig.titleColor,fontSize:this.axisConfig.titleFontSize,rotation:270,verticalPos:"top",horizontalPos:"center"}]}),t}getDrawableElementsForBottomAxis(){const t=[];if(this.showAxisLine){const i=this.boundingRect.y+this.axisConfig.axisLineWidth/2;t.push({type:"path",groupTexts:["bottom-axis","axis-line"],data:[{path:`M ${this.boundingRect.x},${i} L ${this.boundingRect.x+this.boundingRect.width},${i}`,strokeFill:this.axisThemeConfig.axisLineColor,strokeWidth:this.axisConfig.axisLineWidth}]})}if(this.showLabel&&t.push({type:"text",groupTexts:["bottom-axis","label"],data:this.getTickValues().map(i=>({text:i.toString(),x:this.getScaleValue(i)+this.calculateOffsetByRotation("height"),y:this.boundingRect.y+this.axisConfig.labelPadding+(this.showTick?this.axisConfig.tickLength:0)+(this.showAxisLine?this.axisConfig.axisLineWidth:0)+Math.abs(this.calculateOffsetByRotation("width")),fill:this.axisThemeConfig.labelColor,fontSize:this.axisConfig.labelFontSize,rotation:this.normalizedLabelRotationInRad*180/Math.PI,verticalPos:"top",horizontalPos:"center"}))}),this.showTick){const i=this.boundingRect.y+(this.showAxisLine?this.axisConfig.axisLineWidth:0);t.push({type:"path",groupTexts:["bottom-axis","ticks"],data:this.getTickValues().map(s=>({path:`M ${this.getScaleValue(s)},${i} L ${this.getScaleValue(s)},${i+this.axisConfig.tickLength}`,strokeFill:this.axisThemeConfig.tickColor,strokeWidth:this.axisConfig.tickWidth}))})}return this.showTitle&&t.push({type:"text",groupTexts:["bottom-axis","title"],data:[{text:this.title,x:this.range[0]+(this.range[1]-this.range[0])/2,y:this.boundingRect.y+this.boundingRect.height-this.axisConfig.titlePadding-this.titleTextHeight,fill:this.axisThemeConfig.titleColor,fontSize:this.axisConfig.titleFontSize,rotation:0,verticalPos:"top",horizontalPos:"center"}]}),t}getDrawableElementsForTopAxis(){const t=[];if(this.showAxisLine){const i=this.boundingRect.y+this.boundingRect.height-this.axisConfig.axisLineWidth/2;t.push({type:"path",groupTexts:["top-axis","axis-line"],data:[{path:`M ${this.boundingRect.x},${i} L ${this.boundingRect.x+this.boundingRect.width},${i}`,strokeFill:this.axisThemeConfig.axisLineColor,strokeWidth:this.axisConfig.axisLineWidth}]})}if(this.showLabel&&t.push({type:"text",groupTexts:["top-axis","label"],data:this.getTickValues().map(i=>({text:i.toString(),x:this.getScaleValue(i),y:this.boundingRect.y+(this.showTitle?this.titleTextHeight+this.axisConfig.titlePadding*2:0)+this.axisConfig.labelPadding,fill:this.axisThemeConfig.labelColor,fontSize:this.axisConfig.labelFontSize,rotation:0,verticalPos:"top",horizontalPos:"center"}))}),this.showTick){const i=this.boundingRect.y;t.push({type:"path",groupTexts:["top-axis","ticks"],data:this.getTickValues().map(s=>({path:`M ${this.getScaleValue(s)},${i+this.boundingRect.height-(this.showAxisLine?this.axisConfig.axisLineWidth:0)} L ${this.getScaleValue(s)},${i+this.boundingRect.height-this.axisConfig.tickLength-(this.showAxisLine?this.axisConfig.axisLineWidth:0)}`,strokeFill:this.axisThemeConfig.tickColor,strokeWidth:this.axisConfig.tickWidth}))})}return this.showTitle&&t.push({type:"text",groupTexts:["top-axis","title"],data:[{text:this.title,x:this.boundingRect.x+this.boundingRect.width/2,y:this.boundingRect.y+this.axisConfig.titlePadding,fill:this.axisThemeConfig.titleColor,fontSize:this.axisConfig.titleFontSize,rotation:0,verticalPos:"top",horizontalPos:"center"}]}),t}getDrawableElements(){if(this.axisPosition==="left")return this.getDrawableElementsForLeftAxis();if(this.axisPosition==="right")throw Error("Drawing of right axis is not implemented");return this.axisPosition==="bottom"?this.getDrawableElementsForBottomAxis():this.axisPosition==="top"?this.getDrawableElementsForTopAxis():[]}},n(K,"BaseAxis"),K),Z,vi=(Z=class extends $t{constructor(t,i,s,a,o){super(t,a,o,i),this.categories=s,this.scale=wt().domain(this.categories).range(this.getRange())}setRange(t){super.setRange(t)}recalculateScale(){this.scale=wt().domain(this.categories).range(this.getRange()).paddingInner(1).paddingOuter(0).align(.5),Nt.trace("BandAxis axis final categories, range: ",this.categories,this.getRange())}getTickValues(){return this.categories}getScaleValue(t){return this.scale(t)??this.getRange()[0]}},n(Z,"BandAxis"),Z),J,Li=(J=class extends $t{constructor(t,i,s,a,o){super(t,a,o,i),this.domain=s,this.scale=Wt().domain(this.domain).range(this.getRange())}getTickValues(){return this.scale.ticks()}recalculateScale(){const t=[...this.domain];this.axisPosition==="left"&&t.reverse(),this.scale=Wt().domain(t).range(this.getRange())}getScaleValue(t){return this.scale(t)}},n(J,"LinearAxis"),J);function Rt(e,t,i,s){const a=new Ut(s);return ft(e)?new vi(t,i,e.categories,e.title,a):new Li(t,i,[e.min,e.max],e.title,a)}n(Rt,"getAxis");var tt,Pi=(tt=class{constructor(t,i,s,a){this.textDimensionCalculator=t,this.chartConfig=i,this.chartData=s,this.chartThemeConfig=a,this.boundingRect={x:0,y:0,width:0,height:0},this.showChartTitle=!1}setBoundingBoxXY(t){this.boundingRect.x=t.x,this.boundingRect.y=t.y}calculateSpace(t){const i=this.textDimensionCalculator.getMaxDimension([this.chartData.title],this.chartConfig.titleFontSize),s=Math.max(i.width,t.width),a=i.height+2*this.chartConfig.titlePadding;return i.width<=s&&i.height<=a&&this.chartConfig.showTitle&&this.chartData.title&&(this.boundingRect.width=s,this.boundingRect.height=a,this.showChartTitle=!0),{width:this.boundingRect.width,height:this.boundingRect.height}}getDrawableElements(){const t=[];return this.showChartTitle&&t.push({groupTexts:["chart-title"],type:"text",data:[{fontSize:this.chartConfig.titleFontSize,text:this.chartData.title,verticalPos:"middle",horizontalPos:"center",x:this.boundingRect.x+this.boundingRect.width/2,y:this.boundingRect.y+this.boundingRect.height/2,fill:this.chartThemeConfig.titleColor,rotation:0}]}),t}},n(tt,"ChartTitle"),tt);function qt(e,t,i,s){const a=new Ut(s);return new Pi(a,e,t,i)}n(qt,"getChartTitleComponent");var it,Ei=(it=class{constructor(t,i,s,a,o){this.plotData=t,this.xAxis=i,this.yAxis=s,this.orientation=a,this.plotIndex=o}getDrawableElement(){const t=this.plotData.data.map(a=>[this.xAxis.getScaleValue(a[0]),this.yAxis.getScaleValue(a[1])]);let i;if(this.orientation==="horizontal"?i=Ot().y(a=>a[0]).x(a=>a[1])(t):i=Ot().x(a=>a[0]).y(a=>a[1])(t),!i)return[];const s=[{groupTexts:["plot",`line-plot-${this.plotIndex}`],type:"path",data:[{path:i,strokeFill:this.plotData.strokeFill,strokeWidth:this.plotData.strokeWidth}]}];if(this.plotData.pointLabels&&this.plotData.pointLabels.length>0){const l=[];for(const[f,[d,k]]of t.entries()){const T=this.plotData.pointLabels[f];T&&(this.orientation==="horizontal"?l.push({x:k+10,y:d,text:T,fill:this.plotData.strokeFill,verticalPos:"middle",horizontalPos:"left",fontSize:12,rotation:0}):l.push({x:d,y:k-10,text:T,fill:this.plotData.strokeFill,verticalPos:"middle",horizontalPos:"center",fontSize:12,rotation:0}))}l.length>0&&s.push({groupTexts:["plot",`line-plot-${this.plotIndex}`,"labels"],type:"text",data:l})}return s}},n(it,"LinePlot"),it),et,Ii=(et=class{constructor(t,i,s,a,o,l){this.barData=t,this.boundingRect=i,this.xAxis=s,this.yAxis=a,this.orientation=o,this.plotIndex=l}getDrawableElement(){const t=this.barData.data.map(o=>[this.xAxis.getScaleValue(o[0]),this.yAxis.getScaleValue(o[1])]),s=Math.min(this.xAxis.getAxisOuterPadding()*2,this.xAxis.getTickDistance())*(1-.05),a=s/2;return this.orientation==="horizontal"?[{groupTexts:["plot",`bar-plot-${this.plotIndex}`],type:"rect",data:t.map(o=>({x:this.boundingRect.x,y:o[0]-a,height:s,width:o[1]-this.boundingRect.x,fill:this.barData.fill,strokeWidth:0,strokeFill:this.barData.fill}))}]:[{groupTexts:["plot",`bar-plot-${this.plotIndex}`],type:"rect",data:t.map(o=>({x:o[0]-a,y:o[1],width:s,height:this.boundingRect.y+this.boundingRect.height-o[1],fill:this.barData.fill,strokeWidth:0,strokeFill:this.barData.fill}))}]}},n(et,"BarPlot"),et),st,Mi=(st=class{constructor(t,i,s){this.chartConfig=t,this.chartData=i,this.chartThemeConfig=s,this.boundingRect={x:0,y:0,width:0,height:0}}setAxes(t,i){this.xAxis=t,this.yAxis=i}setBoundingBoxXY(t){this.boundingRect.x=t.x,this.boundingRect.y=t.y}calculateSpace(t){return this.boundingRect.width=t.width,this.boundingRect.height=t.height,{width:this.boundingRect.width,height:this.boundingRect.height}}getDrawableElements(){if(!(this.xAxis&&this.yAxis))throw Error("Axes must be passed to render Plots");const t=[];for(const[i,s]of this.chartData.plots.entries())switch(s.type){case"line":{const a=new Ei(s,this.xAxis,this.yAxis,this.chartConfig.chartOrientation,i);t.push(...a.getDrawableElement())}break;case"bar":{const a=new Ii(s,this.boundingRect,this.xAxis,this.yAxis,this.chartConfig.chartOrientation,i);t.push(...a.getDrawableElement())}break}return t}},n(st,"BasePlot"),st);function Gt(e,t,i){return new Mi(e,t,i)}n(Gt,"getPlotComponent");var at,Vi=(at=class{constructor(t,i,s,a){this.chartConfig=t,this.chartData=i,this.componentStore={title:qt(t,i,s,a),plot:Gt(t,i,s),xAxis:Rt(i.xAxis,t.xAxis,{titleColor:s.xAxisTitleColor,labelColor:s.xAxisLabelColor,tickColor:s.xAxisTickColor,axisLineColor:s.xAxisLineColor},a),yAxis:Rt(i.yAxis,t.yAxis,{titleColor:s.yAxisTitleColor,labelColor:s.yAxisLabelColor,tickColor:s.yAxisTickColor,axisLineColor:s.yAxisLineColor},a)}}calculateVerticalSpace(){let t=this.chartConfig.width,i=this.chartConfig.height,s=0,a=0,o=Math.floor(t*this.chartConfig.plotReservedSpacePercent/100),l=Math.floor(i*this.chartConfig.plotReservedSpacePercent/100),f=this.componentStore.plot.calculateSpace({width:o,height:l});t-=f.width,i-=f.height,f=this.componentStore.title.calculateSpace({width:this.chartConfig.width,height:i}),a=f.height,i-=f.height,this.componentStore.xAxis.setAxisPosition("bottom"),f=this.componentStore.xAxis.calculateSpace({width:t,height:i}),i-=f.height,this.componentStore.yAxis.setAxisPosition("left"),f=this.componentStore.yAxis.calculateSpace({width:t,height:i}),s=f.width,t-=f.width,t>0&&(o+=t,t=0),i>0&&(l+=i,i=0),this.componentStore.plot.calculateSpace({width:o,height:l}),this.componentStore.plot.setBoundingBoxXY({x:s,y:a}),this.componentStore.xAxis.setRange([s,s+o]),this.componentStore.xAxis.setBoundingBoxXY({x:s,y:a+l}),this.componentStore.yAxis.setRange([a,a+l]),this.componentStore.yAxis.setBoundingBoxXY({x:0,y:a}),this.chartData.plots.some(d=>St(d))&&this.componentStore.xAxis.recalculateOuterPaddingToDrawBar()}calculateHorizontalSpace(){let t=this.chartConfig.width,i=this.chartConfig.height,s=0,a=0,o=0,l=Math.floor(t*this.chartConfig.plotReservedSpacePercent/100),f=Math.floor(i*this.chartConfig.plotReservedSpacePercent/100),d=this.componentStore.plot.calculateSpace({width:l,height:f});t-=d.width,i-=d.height,d=this.componentStore.title.calculateSpace({width:this.chartConfig.width,height:i}),s=d.height,i-=d.height,this.componentStore.xAxis.setAxisPosition("left"),d=this.componentStore.xAxis.calculateSpace({width:t,height:i}),t-=d.width,a=d.width,this.componentStore.yAxis.setAxisPosition("top"),d=this.componentStore.yAxis.calculateSpace({width:t,height:i}),i-=d.height,o=s+d.height,t>0&&(l+=t,t=0),i>0&&(f+=i,i=0),this.componentStore.plot.calculateSpace({width:l,height:f}),this.componentStore.plot.setBoundingBoxXY({x:a,y:o}),this.componentStore.yAxis.setRange([a,a+l]),this.componentStore.yAxis.setBoundingBoxXY({x:a,y:s}),this.componentStore.xAxis.setRange([o,o+f]),this.componentStore.xAxis.setBoundingBoxXY({x:0,y:o}),this.chartData.plots.some(k=>St(k))&&this.componentStore.xAxis.recalculateOuterPaddingToDrawBar()}calculateSpace(){this.chartConfig.chartOrientation==="horizontal"?this.calculateHorizontalSpace():this.calculateVerticalSpace()}getDrawableElement(){this.calculateSpace();const t=[];this.componentStore.plot.setAxes(this.componentStore.xAxis,this.componentStore.yAxis);for(const i of Object.values(this.componentStore))t.push(...i.getDrawableElements());return t}},n(at,"Orchestrator"),at),nt,zi=(nt=class{static build(t,i,s,a){return new Vi(t,i,s,a).getDrawableElement()}},n(nt,"XYChartBuilder"),nt),ht=0,jt,lt=vt(),ct=Dt(),y=Lt(),_t=ct.plotColorPalette.split(",").map(e=>e.trim()),pt=!1,Tt=!1;function Dt(){const e=Si(),t=kt();return Ht(e.xyChart,t.themeVariables.xyChart)}n(Dt,"getChartDefaultThemeConfig");function vt(){const e=kt();return Ht(Ci.xyChart,e.xyChart)}n(vt,"getChartDefaultConfig");function Lt(){return{yAxis:{type:"linear",title:"",min:1/0,max:-1/0},xAxis:{type:"band",title:"",categories:[]},title:"",plots:[]}}n(Lt,"getChartDefaultData");function ut(e){const t=kt();return wi(e.trim(),t)}n(ut,"textSanitizer");function Qt(e){jt=e}n(Qt,"setTmpSVGG");function Kt(e){e==="horizontal"?lt.chartOrientation="horizontal":lt.chartOrientation="vertical"}n(Kt,"setOrientation");function Zt(e){y.xAxis.title=ut(e.text)}n(Zt,"setXAxisTitle");function Pt(e,t){y.xAxis={type:"linear",title:y.xAxis.title,min:e,max:t},pt=!0}n(Pt,"setXAxisRangeData");function Jt(e){y.xAxis={type:"band",title:y.xAxis.title,categories:e.map(t=>ut(t.text))},pt=!0}n(Jt,"setXAxisBand");function ti(e){y.yAxis.title=ut(e.text)}n(ti,"setYAxisTitle");function ii(e,t){y.yAxis={type:"linear",title:y.yAxis.title,min:e,max:t},Tt=!0}n(ii,"setYAxisRangeData");function ei(e){const t=Math.min(...e),i=Math.max(...e),s=j(y.yAxis)?y.yAxis.min:1/0,a=j(y.yAxis)?y.yAxis.max:-1/0;y.yAxis={type:"linear",title:y.yAxis.title,min:Math.min(s,t),max:Math.max(a,i)}}n(ei,"setYAxisRangeFromPlotData");function Et(e){let t=[];if(e.length===0)return t;if(!pt){const i=j(y.xAxis)?y.xAxis.min:1/0,s=j(y.xAxis)?y.xAxis.max:-1/0;Pt(Math.min(i,1),Math.max(s,e.length))}if(ft(y.xAxis)&&e.length>y.xAxis.categories.length&&(e=e.slice(0,y.xAxis.categories.length)),Tt||ei(e),ft(y.xAxis)&&(t=y.xAxis.categories.map((i,s)=>[i,e[s]])),j(y.xAxis)){const i=y.xAxis.min,s=y.xAxis.max,a=(s-i)/(e.length-1),o=[];for(let l=i;l<=s;l+=a)o.push(`${l}`);t=o.map((l,f)=>[l,e[f]])}return t}n(Et,"transformDataWithoutCategory");function It(e){return _t[e===0?0:e%_t.length]}n(It,"getPlotColorFromPalette");function si(e,t){const i=t.map(l=>l.value),s=t.map(l=>l.label?ut(l.label):""),a=Et(i),o=s.some(l=>l!=="");y.plots.push({type:"line",strokeFill:It(ht),strokeWidth:2,data:a,...o?{pointLabels:s}:{}}),ht++}n(si,"setLineData");function ai(e,t){const i=t.map(a=>a.value),s=Et(i);y.plots.push({type:"bar",fill:It(ht),data:s}),ht++}n(ai,"setBarData");function ni(){if(y.plots.length===0)throw Error("No Plot to render, please provide a plot with some data");return y.title=Yt(),zi.build(lt,y,ct,jt)}n(ni,"getDrawableElem");function oi(){return ct}n(oi,"getChartThemeConfig");function ri(){return lt}n(ri,"getChartConfig");function hi(){return y}n(hi,"getXYChartData");var Bi=n(function(){Ai(),ht=0,lt=vt(),y=Lt(),ct=Dt(),_t=ct.plotColorPalette.split(",").map(e=>e.trim()),pt=!1,Tt=!1},"clear"),Oi={getDrawableElem:ni,clear:Bi,setAccTitle:mi,getAccTitle:pi,setDiagramTitle:fi,getDiagramTitle:Yt,getAccDescription:di,setAccDescription:xi,setOrientation:Kt,setXAxisTitle:Zt,setXAxisRangeData:Pt,setXAxisBand:Jt,setYAxisTitle:ti,setYAxisRangeData:ii,setLineData:si,setBarData:ai,setTmpSVGG:Qt,getChartThemeConfig:oi,getChartConfig:ri,getXYChartData:hi},Wi=n((e,t,i,s)=>{const a=s.db,o=a.getChartThemeConfig(),l=a.getChartConfig(),f=a.getXYChartData().plots[0].data.map(m=>m[1]);function d(m){return m==="top"?"text-before-edge":"middle"}n(d,"getDominantBaseLine");function k(m){return m==="left"?"start":m==="right"?"end":"middle"}n(k,"getTextAnchor");function T(m){return`translate(${m.x}, ${m.y}) rotate(${m.rotation||0})`}n(T,"getTextTransformation"),Nt.debug(`Rendering xychart chart
|
|
7
|
+
`+e);const _=yi(t),b=_.append("g").attr("class","main"),E=b.append("rect").attr("width",l.width).attr("height",l.height).attr("class","background");bi(_,l.height,l.width,!0),_.attr("viewBox",`0 0 ${l.width} ${l.height}`),E.attr("fill",o.backgroundColor),a.setTmpSVGG(_.append("g").attr("class","mermaid-tmp-group"));const L=a.getDrawableElem(),P={};function I(m){let D=b,c="";for(const[z]of m.entries()){let W=b;z>0&&P[c]&&(W=P[c]),c+=m[z],D=P[c],D||(D=P[c]=W.append("g").attr("class",m[z]))}return D}n(I,"getGroup");for(const m of L){if(m.data.length===0)continue;const D=I(m.groupTexts);switch(m.type){case"rect":if(D.selectAll("rect").data(m.data).enter().append("rect").attr("x",c=>c.x).attr("y",c=>c.y).attr("width",c=>c.width).attr("height",c=>c.height).attr("fill",c=>c.fill).attr("stroke",c=>c.strokeFill).attr("stroke-width",c=>c.strokeWidth),l.showDataLabel){const c=l.showDataLabelOutsideBar;if(l.chartOrientation==="horizontal"){let z=function(w,B){const{data:R,label:ot}=w;return B*ot.length*W<=R.width-X};n(z,"fitsHorizontally");const W=.7,X=10,Y=m.data.map((w,B)=>({data:w,label:f[B].toString()})).filter(w=>w.data.width>0&&w.data.height>0),S=Y.map(w=>{const{data:B}=w;let R=B.height*.7;for(;!z(w,R)&&R>0;)R-=1;return R}),H=Math.floor(Math.min(...S)),A=n(w=>c?w.data.x+w.data.width+X:w.data.x+w.data.width-X,"determineLabelXPosition");D.selectAll("text").data(Y).enter().append("text").attr("x",A).attr("y",w=>w.data.y+w.data.height/2).attr("text-anchor",c?"start":"end").attr("dominant-baseline","middle").attr("fill",o.dataLabelColor).attr("font-size",`${H}px`).text(w=>w.label)}else{let z=function(A,w,B){const{data:R,label:ot}=A,F=w*ot.length*.7,h=R.x+R.width/2,u=h-F/2,g=h+F/2,x=u>=R.x&&g<=R.x+R.width,C=R.y+B+w<=R.y+R.height;return x&&C};n(z,"fitsInBar");const W=10,X=m.data.map((A,w)=>({data:A,label:f[w].toString()})).filter(A=>A.data.width>0&&A.data.height>0),Y=X.map(A=>{const{data:w,label:B}=A;let R=w.width/(B.length*.7);for(;!z(A,R,W)&&R>0;)R-=1;return R}),S=Math.floor(Math.min(...Y)),H=n(A=>c?A.data.y-W:A.data.y+W,"determineLabelYPosition");D.selectAll("text").data(X).enter().append("text").attr("x",A=>A.data.x+A.data.width/2).attr("y",H).attr("text-anchor","middle").attr("dominant-baseline",c?"auto":"hanging").attr("fill",o.dataLabelColor).attr("font-size",`${S}px`).text(A=>A.label)}}break;case"text":D.selectAll("text").data(m.data).enter().append("text").attr("x",0).attr("y",0).attr("fill",c=>c.fill).attr("font-size",c=>c.fontSize).attr("dominant-baseline",c=>d(c.verticalPos)).attr("text-anchor",c=>k(c.horizontalPos)).attr("transform",c=>T(c)).text(c=>c.text);break;case"path":D.selectAll("path").data(m.data).enter().append("path").attr("d",c=>c.path).attr("fill",c=>c.fill?c.fill:"none").attr("stroke",c=>c.strokeFill).attr("stroke-width",c=>c.strokeWidth);break}}},"draw"),Fi={draw:Wi},ji={parser:Di,db:Oi,renderer:Fi};export{ji as diagram};
|
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
<link rel="icon" type="image/png" href="/icon.png" />
|
|
9
9
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
10
10
|
<title>Ocean Brain</title>
|
|
11
|
-
<script type="module" crossorigin src="/assets/app-
|
|
12
|
-
<link rel="modulepreload" crossorigin href="/assets/floating-ui.react-dom-
|
|
13
|
-
<link rel="modulepreload" crossorigin href="/assets/url-
|
|
14
|
-
<link rel="modulepreload" crossorigin href="/assets/note.api-
|
|
15
|
-
<link rel="modulepreload" crossorigin href="/assets/time-
|
|
11
|
+
<script type="module" crossorigin src="/assets/app-BpSMjzET.js"></script>
|
|
12
|
+
<link rel="modulepreload" crossorigin href="/assets/floating-ui.react-dom-BWTnA00G.js">
|
|
13
|
+
<link rel="modulepreload" crossorigin href="/assets/url-9nrbQs7Z.js">
|
|
14
|
+
<link rel="modulepreload" crossorigin href="/assets/note.api-D3oJmG3q.js">
|
|
15
|
+
<link rel="modulepreload" crossorigin href="/assets/time-D5LRMumI.js">
|
|
16
16
|
<link rel="modulepreload" crossorigin href="/assets/preload-helper-BXl3LOEh.js">
|
|
17
|
-
<link rel="modulepreload" crossorigin href="/assets/Graph-
|
|
18
|
-
<link rel="stylesheet" crossorigin href="/assets/app-
|
|
17
|
+
<link rel="modulepreload" crossorigin href="/assets/Graph-LY_IgMYy.js">
|
|
18
|
+
<link rel="stylesheet" crossorigin href="/assets/app-B9WZRrAH.css">
|
|
19
19
|
</head>
|
|
20
20
|
|
|
21
21
|
<body>
|
|
@@ -3,8 +3,32 @@ import fsPromises from "fs/promises";
|
|
|
3
3
|
import path from "path";
|
|
4
4
|
import models from "../../../models.js";
|
|
5
5
|
import { paths } from "../../../paths.js";
|
|
6
|
+
const PUBLIC_IMAGE_PATH_PREFIX = "/assets/images/";
|
|
7
|
+
const INVALID_STORED_IMAGE_PATH_MESSAGE = "Stored image URL must point to a file inside the image directory.";
|
|
8
|
+
const invalidStoredImagePath = () => new Error(INVALID_STORED_IMAGE_PATH_MESSAGE);
|
|
6
9
|
const resolveStoredImagePath = (url) => {
|
|
7
|
-
|
|
10
|
+
if (!url.startsWith(PUBLIC_IMAGE_PATH_PREFIX)) {
|
|
11
|
+
throw invalidStoredImagePath();
|
|
12
|
+
}
|
|
13
|
+
let relativePath;
|
|
14
|
+
try {
|
|
15
|
+
relativePath = decodeURIComponent(url.slice(PUBLIC_IMAGE_PATH_PREFIX.length));
|
|
16
|
+
} catch {
|
|
17
|
+
throw invalidStoredImagePath();
|
|
18
|
+
}
|
|
19
|
+
const pathSegments = relativePath.split("/");
|
|
20
|
+
const isCanonicalRelativePath = relativePath.length > 0 && !relativePath.includes("\\") && !relativePath.includes("\0") && !relativePath.includes("?") && !relativePath.includes("#") && pathSegments.every((segment) => segment.length > 0 && segment !== "." && segment !== "..");
|
|
21
|
+
if (!isCanonicalRelativePath) {
|
|
22
|
+
throw invalidStoredImagePath();
|
|
23
|
+
}
|
|
24
|
+
const imageDir = path.resolve(paths.imageDir);
|
|
25
|
+
const imagePath = path.resolve(imageDir, relativePath);
|
|
26
|
+
const relativeImagePath = path.relative(imageDir, imagePath);
|
|
27
|
+
const isInsideImageDir = relativeImagePath.length > 0 && relativeImagePath !== ".." && !relativeImagePath.startsWith(`..${path.sep}`) && !path.isAbsolute(relativeImagePath);
|
|
28
|
+
if (!isInsideImageDir) {
|
|
29
|
+
throw invalidStoredImagePath();
|
|
30
|
+
}
|
|
31
|
+
return imagePath;
|
|
8
32
|
};
|
|
9
33
|
const createImageDeleteService = (deps) => {
|
|
10
34
|
return {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { listNoteProperties } from "../../../features/note/services/properties.js";
|
|
2
|
+
import { buildNoteContentPreview } from "../../../features/note/services/search.js";
|
|
2
3
|
import { renderNoteSnapshotContentAsMarkdown } from "../../../features/note/services/snapshot.js";
|
|
3
4
|
import models from "../../../models.js";
|
|
4
5
|
const noteFieldResolvers = {
|
|
5
6
|
tags: async (note) => models.tag.findMany({ where: { notes: { some: { id: note.id } } } }),
|
|
6
7
|
properties: async (note) => listNoteProperties(note.id),
|
|
8
|
+
contentPreview: (note) => buildNoteContentPreview(note.content),
|
|
7
9
|
contentAsMarkdown: async (note) => {
|
|
8
10
|
const { blocksToMarkdown } = await import("../../../modules/blocknote.js");
|
|
9
11
|
return blocksToMarkdown(note.content);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { GraphQLError } from "graphql";
|
|
2
2
|
import { extractBlocksByType, parseNoteContent } from "../../../features/note/services/content-blocks.js";
|
|
3
|
+
import { replaceNoteReferences } from "../../../features/note/services/note-reference-index.js";
|
|
3
4
|
import {
|
|
4
5
|
createNotePropertyDefinition,
|
|
5
6
|
deleteNotePropertyDefinition,
|
|
@@ -17,6 +18,7 @@ import {
|
|
|
17
18
|
isMissingNoteVersionError,
|
|
18
19
|
isNoteVersionConflictError
|
|
19
20
|
} from "../../../features/note/services/write-conflict.js";
|
|
21
|
+
import { notifySemanticSearchNoteChanged } from "../../../features/search/note-change.js";
|
|
20
22
|
import models from "../../../models.js";
|
|
21
23
|
const PLACEHOLDER_PREFIX = "{%";
|
|
22
24
|
const PLACEHOLDER_SUFFIX = "%}";
|
|
@@ -62,24 +64,27 @@ const noteMutationResolvers = {
|
|
|
62
64
|
const replacedContent = await replacePlaceholders(note.content);
|
|
63
65
|
const parsedContent = replacedContent ? parseRequiredNoteContent(replacedContent) : null;
|
|
64
66
|
const blocks = parsedContent ? extractBlocksByType("tag", parsedContent) : [];
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
content: replacedContent,
|
|
69
|
-
...buildNoteSearchProjection({
|
|
67
|
+
const noteResult = await models.$transaction(async (tx) => {
|
|
68
|
+
const createdNote = await tx.note.create({
|
|
69
|
+
data: {
|
|
70
70
|
title: replacedTitle,
|
|
71
|
-
content: replacedContent
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
71
|
+
content: replacedContent,
|
|
72
|
+
...buildNoteSearchProjection({
|
|
73
|
+
title: replacedTitle,
|
|
74
|
+
content: replacedContent
|
|
75
|
+
}),
|
|
76
|
+
...note.layout && { layout: note.layout }
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
const noteResult2 = replacedContent ? await tx.note.update({
|
|
80
|
+
where: { id: createdNote.id },
|
|
81
|
+
data: { tags: { set: toTagConnections(blocks) } }
|
|
82
|
+
}) : createdNote;
|
|
83
|
+
await replaceNoteReferences(tx, createdNote.id, replacedContent);
|
|
84
|
+
return noteResult2;
|
|
82
85
|
});
|
|
86
|
+
notifySemanticSearchNoteChanged(noteResult.id);
|
|
87
|
+
return noteResult;
|
|
83
88
|
},
|
|
84
89
|
updateNote: async (_, {
|
|
85
90
|
id,
|
|
@@ -107,6 +112,7 @@ const noteMutationResolvers = {
|
|
|
107
112
|
if (!updatedNote) {
|
|
108
113
|
throw "NOT FOUND";
|
|
109
114
|
}
|
|
115
|
+
notifySemanticSearchNoteChanged(updatedNote.id);
|
|
110
116
|
return updatedNote;
|
|
111
117
|
} catch (error) {
|
|
112
118
|
if (isNoteVersionConflictError(error)) {
|
|
@@ -140,22 +146,46 @@ const noteMutationResolvers = {
|
|
|
140
146
|
if (!trashedNote) {
|
|
141
147
|
throw "NOT FOUND";
|
|
142
148
|
}
|
|
149
|
+
notifySemanticSearchNoteChanged(Number(id));
|
|
143
150
|
return true;
|
|
144
151
|
},
|
|
145
|
-
restoreNoteSnapshot: async (_, { id }, context) => {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
152
|
+
restoreNoteSnapshot: async (_, { id, expectedUpdatedAt }, context) => {
|
|
153
|
+
try {
|
|
154
|
+
const note = await restoreNoteSnapshot(Number(id), {
|
|
155
|
+
expectedUpdatedAt,
|
|
156
|
+
meta: createSnapshotMetaFromUserAgent(getRequestUserAgent(context.req))
|
|
157
|
+
});
|
|
158
|
+
if (!note) {
|
|
159
|
+
throw "NOT FOUND";
|
|
160
|
+
}
|
|
161
|
+
notifySemanticSearchNoteChanged(note.id);
|
|
162
|
+
return note;
|
|
163
|
+
} catch (error) {
|
|
164
|
+
if (isNoteVersionConflictError(error)) {
|
|
165
|
+
throw new GraphQLError(error.message, {
|
|
166
|
+
extensions: {
|
|
167
|
+
code: error.code,
|
|
168
|
+
currentUpdatedAt: error.currentUpdatedAt,
|
|
169
|
+
expectedUpdatedAt: error.expectedUpdatedAt
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
if (isInvalidNoteVersionError(error) || isMissingNoteVersionError(error)) {
|
|
174
|
+
throw new GraphQLError(error.message, {
|
|
175
|
+
extensions: {
|
|
176
|
+
code: error.code
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
throw error;
|
|
151
181
|
}
|
|
152
|
-
return note;
|
|
153
182
|
},
|
|
154
183
|
restoreTrashedNote: async (_, { id }) => {
|
|
155
184
|
const note = await restoreTrashedNoteById(Number(id));
|
|
156
185
|
if (!note) {
|
|
157
186
|
throw "NOT FOUND";
|
|
158
187
|
}
|
|
188
|
+
notifySemanticSearchNoteChanged(note.id);
|
|
159
189
|
return note;
|
|
160
190
|
},
|
|
161
191
|
purgeTrashedNote: async (_, { id }) => {
|
|
@@ -163,6 +193,7 @@ const noteMutationResolvers = {
|
|
|
163
193
|
if (!purgedNote) {
|
|
164
194
|
throw "NOT FOUND";
|
|
165
195
|
}
|
|
196
|
+
notifySemanticSearchNoteChanged(Number(id));
|
|
166
197
|
return true;
|
|
167
198
|
},
|
|
168
199
|
createNotePropertyKey: async (_, { input }) => {
|
|
@@ -194,12 +194,22 @@ const createAllNotesQueryResolver = (deps = {
|
|
|
194
194
|
};
|
|
195
195
|
};
|
|
196
196
|
const createBackReferencesQueryResolver = (deps = {
|
|
197
|
-
findCandidateNotes: (noteId) =>
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
197
|
+
findCandidateNotes: async (noteId) => {
|
|
198
|
+
const references = await models.noteReference.findMany({
|
|
199
|
+
where: { targetNoteId: noteId },
|
|
200
|
+
select: { sourceNoteId: true }
|
|
201
|
+
});
|
|
202
|
+
if (references.length === 0) {
|
|
203
|
+
return [];
|
|
201
204
|
}
|
|
202
|
-
|
|
205
|
+
return models.note.findMany({
|
|
206
|
+
orderBy: [{ pinned: "desc" }, { updatedAt: "desc" }],
|
|
207
|
+
where: {
|
|
208
|
+
id: { in: references.map((reference) => reference.sourceNoteId) },
|
|
209
|
+
NOT: { id: noteId }
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
}
|
|
203
213
|
}) => {
|
|
204
214
|
return async (_, { id }) => {
|
|
205
215
|
const notes = await deps.findCandidateNotes(Number(id));
|
|
@@ -98,6 +98,7 @@ const noteType = gql`
|
|
|
98
98
|
id: ID!
|
|
99
99
|
title: String!
|
|
100
100
|
content: String!
|
|
101
|
+
contentPreview: String!
|
|
101
102
|
contentAsMarkdown: String!
|
|
102
103
|
createdAt: String!
|
|
103
104
|
updatedAt: String!
|
|
@@ -291,7 +292,7 @@ const noteMutation = gql`
|
|
|
291
292
|
createNote(note: NoteInput!): Note!
|
|
292
293
|
updateNote(id: ID!, note: NoteInput!, editSessionId: String, expectedUpdatedAt: String, force: Boolean): Note!
|
|
293
294
|
deleteNote(id: ID!): Boolean!
|
|
294
|
-
restoreNoteSnapshot(id: ID!): Note!
|
|
295
|
+
restoreNoteSnapshot(id: ID!, expectedUpdatedAt: String!): Note!
|
|
295
296
|
restoreTrashedNote(id: ID!): Note!
|
|
296
297
|
purgeTrashedNote(id: ID!): Boolean!
|
|
297
298
|
createNotePropertyKey(input: NotePropertyDefinitionInput!): NotePropertyKey!
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createNoteFromMarkdown,
|
|
3
|
-
InvalidNoteAuthoringInputError,
|
|
4
|
-
updateNoteFromMarkdown
|
|
5
|
-
} from "../../../features/note/services/authoring.js";
|
|
1
|
+
import { createNoteFromMarkdown, InvalidNoteAuthoringInputError } from "../../../features/note/services/authoring.js";
|
|
6
2
|
import { deleteNoteById } from "../../../features/note/services/cleanup.js";
|
|
7
3
|
import {
|
|
8
4
|
appendNoteMarkdown,
|
|
@@ -10,7 +6,6 @@ import {
|
|
|
10
6
|
replaceNoteMarkdown,
|
|
11
7
|
updateNoteMetadata
|
|
12
8
|
} from "../../../features/note/services/markdown-intent-write.js";
|
|
13
|
-
import { MCP_SNAPSHOT_META } from "../../../features/note/services/snapshot.js";
|
|
14
9
|
import models from "../../../models.js";
|
|
15
10
|
import { createAppError } from "../../../modules/error-handler.js";
|
|
16
11
|
import { emitServerEvent } from "../../../modules/server-events.js";
|
|
@@ -268,59 +263,6 @@ const createMcpCreateNoteHandler = (createNote = createNoteFromMarkdown, emitEve
|
|
|
268
263
|
}
|
|
269
264
|
};
|
|
270
265
|
};
|
|
271
|
-
const createMcpUpdateNoteHandler = (updateNote = updateNoteFromMarkdown, emitEvent = emitServerEvent) => {
|
|
272
|
-
return async (req, res) => {
|
|
273
|
-
const { id, title, markdown, layout, editSessionId } = req.body ?? {};
|
|
274
|
-
const noteId = Number(id);
|
|
275
|
-
const resolvedLayout = resolveNoteLayout(layout);
|
|
276
|
-
if (!Number.isInteger(noteId) || noteId <= 0) {
|
|
277
|
-
throw createAppError(400, "INVALID_NOTE_ID", "A valid note id is required.");
|
|
278
|
-
}
|
|
279
|
-
if (title !== void 0 && typeof title !== "string") {
|
|
280
|
-
throw createAppError(400, "INVALID_NOTE_TITLE", "Note title must be a string.");
|
|
281
|
-
}
|
|
282
|
-
if (markdown !== void 0 && typeof markdown !== "string") {
|
|
283
|
-
throw createAppError(400, "INVALID_NOTE_MARKDOWN", "Note markdown must be a string.");
|
|
284
|
-
}
|
|
285
|
-
if (layout !== void 0 && resolvedLayout === null) {
|
|
286
|
-
throw createAppError(400, "INVALID_NOTE_LAYOUT", "Note layout must be one of narrow, wide, or full.");
|
|
287
|
-
}
|
|
288
|
-
if (editSessionId !== void 0 && typeof editSessionId !== "string") {
|
|
289
|
-
throw createAppError(400, "INVALID_EDIT_SESSION_ID", "Edit session id must be a string.");
|
|
290
|
-
}
|
|
291
|
-
if (title === void 0 && markdown === void 0 && layout === void 0) {
|
|
292
|
-
throw createAppError(400, "INVALID_NOTE_INPUT", "At least one note field must be provided for update.");
|
|
293
|
-
}
|
|
294
|
-
try {
|
|
295
|
-
const note = await updateNote({
|
|
296
|
-
id: noteId,
|
|
297
|
-
...title !== void 0 ? { title } : {},
|
|
298
|
-
...markdown !== void 0 ? { markdown } : {},
|
|
299
|
-
...resolvedLayout ? { layout: resolvedLayout } : {},
|
|
300
|
-
...editSessionId !== void 0 ? { editSessionId } : {},
|
|
301
|
-
snapshotMeta: MCP_SNAPSHOT_META
|
|
302
|
-
});
|
|
303
|
-
if (!note) {
|
|
304
|
-
throw createAppError(404, "NOTE_NOT_FOUND", "The requested note was not found.");
|
|
305
|
-
}
|
|
306
|
-
emitEvent({
|
|
307
|
-
type: "mcp.note.updated",
|
|
308
|
-
source: "mcp",
|
|
309
|
-
noteId: note.id,
|
|
310
|
-
updatedAt: note.updatedAt
|
|
311
|
-
});
|
|
312
|
-
res.status(200).json({
|
|
313
|
-
updated: true,
|
|
314
|
-
note
|
|
315
|
-
}).end();
|
|
316
|
-
} catch (error) {
|
|
317
|
-
if (error instanceof InvalidNoteAuthoringInputError) {
|
|
318
|
-
throw createAppError(400, "INVALID_NOTE_INPUT", error.message);
|
|
319
|
-
}
|
|
320
|
-
throw error;
|
|
321
|
-
}
|
|
322
|
-
};
|
|
323
|
-
};
|
|
324
266
|
const createMcpNoteWriteBaselineHandler = (findNoteBaseline = async (id) => models.note.findUnique({
|
|
325
267
|
where: { id },
|
|
326
268
|
select: {
|
|
@@ -520,6 +462,5 @@ export {
|
|
|
520
462
|
createMcpNoteWriteBaselineHandler,
|
|
521
463
|
createMcpPatchNoteMarkdownHandler,
|
|
522
464
|
createMcpReplaceNoteMarkdownHandler,
|
|
523
|
-
createMcpUpdateNoteHandler,
|
|
524
465
|
createMcpUpdateNoteMetadataHandler
|
|
525
466
|
};
|