braian 0.0.5 → 0.0.7
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/bin/braian.mjs +2 -0
- package/bin/node-version.mjs +72 -0
- package/dist/agent/graph-agent.service.js +43 -0
- package/dist/app.module.js +2 -0
- package/dist/auth/auth.controller.js +2 -2
- package/dist/auth/auth.guard.js +34 -5
- package/dist/auth/auth.module.js +13 -2
- package/dist/auth/auth.service.js +8 -2
- package/dist/auth/link-route-policies.js +267 -0
- package/dist/auth/link-route-policy.js +27 -0
- package/dist/auth/vault-access-denied.filter.js +30 -0
- package/dist/auth/vault-access.interceptor.js +45 -0
- package/dist/auth/vault-link-principal.js +15 -0
- package/dist/auth/vault-link-sessions.service.js +186 -0
- package/dist/bootstrap.js +6 -1
- package/dist/collab/collab.service.js +12 -2
- package/dist/desktop/exposure.js +7 -1
- package/dist/entity/entity.controller.js +9 -1
- package/dist/events/vault-events.service.js +17 -4
- package/dist/files/dto/vault-files.dto.js +113 -6
- package/dist/files/file-url-signer.js +37 -11
- package/dist/files/files-http-error.js +1 -1
- package/dist/files/vault-file-archive.service.js +19 -4
- package/dist/files/vault-file-content.controller.js +29 -1
- package/dist/files/vault-file-content.service.js +18 -2
- package/dist/http/api-controllers.js +6 -0
- package/dist/http/log-redaction.js +23 -0
- package/dist/http/published-page-address.js +58 -0
- package/dist/http/request-guards.js +51 -1
- package/dist/http/security-headers.js +2 -1
- package/dist/journal/active-journal.dto.js +4 -3
- package/dist/logging/logging.middleware.js +3 -3
- package/dist/navigation/navigation.service.js +16 -1
- package/dist/providers/claude-messages-model.js +2 -2
- package/dist/providers/model-provider.service.js +71 -8
- package/dist/providers/provider-catalog-storage.js +4 -3
- package/dist/providers/provider-model-catalog.js +46 -0
- package/dist/providers/provider.controller.js +83 -0
- package/dist/rss/rss-profiles.dto.js +4 -3
- package/dist/search/search-database.service.js +40 -24
- package/dist/search/search-embedding-settings.controller.js +82 -0
- package/dist/search/search-embedding.service.js +33 -28
- package/dist/search/search-index-health.js +1 -1
- package/dist/search/search-sync.service.js +8 -0
- package/dist/search/search.controller.js +34 -54
- package/dist/search/search.module.js +3 -3
- package/dist/sessions/agent-runs.controller.js +3 -3
- package/dist/sessions/dto/graph-session.dto.js +6 -5
- package/dist/sessions/sessions.service.js +33 -1
- package/dist/settings/settings.controller.js +11 -0
- package/dist/settings/settings.dto.js +29 -24
- package/dist/settings/settings.service.js +6 -0
- package/dist/shares/share-http-error.js +2 -2
- package/dist/shares/share.dto.js +74 -16
- package/dist/shares/shared-webpage-headers.js +45 -0
- package/dist/shares/shared-webpage.controller.js +179 -0
- package/dist/shares/shares.controller.js +3 -3
- package/dist/shares/shares.module.js +2 -1
- package/dist/shares/shares.service.js +11 -4
- package/dist/sqlite-files/vault-sqlite.service.js +1 -0
- package/dist/vault-access/vault-access.controller.js +73 -0
- package/dist/vault-access/vault-access.dto.js +28 -0
- package/dist/vault-access/vault-access.module.js +19 -0
- package/dist/vault-access/vault-access.service.js +49 -0
- package/dist/vaults/vault.controller.js +20 -0
- package/dist/vaults/vault.dto.js +114 -50
- package/dist/vaults/vaults.service.js +30 -2
- package/dist/versioning/versioning.service.js +47 -8
- package/node_modules/@braian/ai-providers/dist/index.js +10 -3
- package/node_modules/@braian/ai-providers/dist/openrouter-catalog.js +57 -0
- package/node_modules/@braian/ai-providers/dist/provider-catalog.js +47 -2
- package/node_modules/@braian/ai-providers/dist/providers-models.js +27 -7
- package/node_modules/@braian/graph-agent/assets/agent-instructions/default/26-schema.md +1 -1
- package/node_modules/@braian/graph-agent/dist/agent-features.js +1 -1
- package/node_modules/@braian/graph-agent/dist/agent-profiles/registry.js +9 -0
- package/node_modules/@braian/graph-agent/dist/agent-runs/run-registry.js +1 -1
- package/node_modules/@braian/graph-agent/dist/auth-registry.js +29 -0
- package/node_modules/@braian/graph-agent/dist/boards/boards-settings.js +20 -0
- package/node_modules/@braian/graph-agent/dist/boards/index.js +5 -0
- package/node_modules/@braian/graph-agent/dist/data-workspace.js +127 -14
- package/node_modules/@braian/graph-agent/dist/feature-switch.js +6 -2
- package/node_modules/@braian/graph-agent/dist/files-settings.js +10 -2
- package/node_modules/@braian/graph-agent/dist/ide/ide-settings.js +58 -0
- package/node_modules/@braian/graph-agent/dist/ide/index.js +6 -0
- package/node_modules/@braian/graph-agent/dist/ide-layout.js +1 -1
- package/node_modules/@braian/graph-agent/dist/index.js +30 -13
- package/node_modules/@braian/graph-agent/dist/journal-reflection.js +2 -1
- package/node_modules/@braian/graph-agent/dist/locked-graph-store.js +11 -2
- package/node_modules/@braian/graph-agent/dist/mentioned-notes-input.js +1 -1
- package/node_modules/@braian/graph-agent/dist/navigation-settings.js +20 -14
- package/node_modules/@braian/graph-agent/dist/note-collab-policy.js +4 -1
- package/node_modules/@braian/graph-agent/dist/note-collab-projection.js +4 -3
- package/node_modules/@braian/graph-agent/dist/note-collab-registry.js +12 -9
- package/node_modules/@braian/graph-agent/dist/note-collab-session.js +2 -1
- package/node_modules/@braian/graph-agent/dist/note-editor/index.js +13 -0
- package/node_modules/@braian/graph-agent/dist/note-editor/note-editor-settings.js +98 -0
- package/node_modules/@braian/graph-agent/dist/note-key-settings.js +34 -2
- package/node_modules/@braian/graph-agent/dist/rss/index.js +3 -1
- package/node_modules/@braian/graph-agent/dist/rss/rss-feed-parse.js +18 -1
- package/node_modules/@braian/graph-agent/dist/rss/rss-profile-store.js +9 -0
- package/node_modules/@braian/graph-agent/dist/rss/rss-profile-use-cases.js +2 -0
- package/node_modules/@braian/graph-agent/dist/rss/rss-settings.js +15 -0
- package/node_modules/@braian/graph-agent/dist/screen-context-input.js +1 -1
- package/node_modules/@braian/graph-agent/dist/secret-masking.js +54 -15
- package/node_modules/@braian/graph-agent/dist/secret-vault.js +48 -3
- package/node_modules/@braian/graph-agent/dist/session-registry.js +3 -2
- package/node_modules/@braian/graph-agent/dist/settings-registry.js +21 -178
- package/node_modules/@braian/graph-agent/dist/settings-reset/index.js +9 -0
- package/node_modules/@braian/graph-agent/dist/settings-reset/settings-reset.js +85 -0
- package/node_modules/@braian/graph-agent/dist/share-edit-references.js +15 -14
- package/node_modules/@braian/graph-agent/dist/share-policy.js +86 -21
- package/node_modules/@braian/graph-agent/dist/share-registry.js +18 -11
- package/node_modules/@braian/graph-agent/dist/share-target-description.js +6 -0
- package/node_modules/@braian/graph-agent/dist/share-use-cases.js +99 -3
- package/node_modules/@braian/graph-agent/dist/share-webpage-links.js +40 -0
- package/node_modules/@braian/graph-agent/dist/shared-dashboard-view.js +2 -1
- package/node_modules/@braian/graph-agent/dist/spotlight-settings.js +2 -15
- package/node_modules/@braian/graph-agent/dist/standalone-pages.js +111 -0
- package/node_modules/@braian/graph-agent/dist/tools.js +4 -2
- package/node_modules/@braian/graph-agent/dist/types.js +7 -0
- package/node_modules/@braian/graph-agent/dist/vault-access/index.js +36 -0
- package/node_modules/@braian/graph-agent/dist/vault-access/vault-access-policy.js +127 -0
- package/node_modules/@braian/graph-agent/dist/vault-access/vault-access-scope.js +60 -0
- package/node_modules/@braian/graph-agent/dist/vault-access/vault-link-features.js +48 -0
- package/node_modules/@braian/graph-agent/dist/vault-access/vault-link-grant.js +47 -0
- package/node_modules/@braian/graph-agent/dist/vault-access/vault-settings-access.js +44 -0
- package/node_modules/@braian/graph-agent/dist/vault-files.js +73 -14
- package/node_modules/@braian/graph-agent/dist/vault-settings-operations.js +41 -12
- package/node_modules/@braian/graph-agent/dist/vault-settings-registry.js +111 -20
- package/node_modules/@braian/html-standalone/dist/css.js +44 -0
- package/node_modules/@braian/html-standalone/dist/data-uri.js +48 -0
- package/node_modules/@braian/html-standalone/dist/html.js +118 -0
- package/node_modules/@braian/html-standalone/dist/index.js +9 -0
- package/node_modules/@braian/html-standalone/dist/local-reference.js +64 -0
- package/node_modules/@braian/html-standalone/dist/standalone.js +143 -0
- package/node_modules/@braian/html-standalone/package.json +22 -0
- package/node_modules/@braian/sqlite-browser/dist/execute.js +47 -2
- package/node_modules/@braian/vault-fs-sdk/dist/fs-vault-strategy.js +23 -0
- package/node_modules/@braian/vault-fs-sdk/dist/index.js +5 -1
- package/node_modules/@braian/vault-fs-sdk/dist/vault-index.js +5 -0
- package/package.json +5 -2
- package/public/assets/{ArrowClockwise.es-DWqWLk15.js → ArrowClockwise.es-3-WDmIeI.js} +1 -1
- package/public/assets/{ArrowDown.es-COHGTGu_.js → ArrowDown.es--soRLxEp.js} +1 -1
- package/public/assets/{ArrowLeft.es-Dvz_4AVp.js → ArrowLeft.es-CbZG51Gr.js} +1 -1
- package/public/assets/{ArrowSquareOut.es-ssfQ7LE-.js → ArrowSquareOut.es-yh2fX_Cs.js} +1 -1
- package/public/assets/{ArrowUp.es-DflnZKsA.js → ArrowUp.es-CIIkDrf9.js} +1 -1
- package/public/assets/{ArrowsClockwise.es-DSXy5pW3.js → ArrowsClockwise.es-D0399ubU.js} +1 -1
- package/public/assets/{ArrowsIn.es-B4Aie-uw.js → ArrowsIn.es-B54L_O6A.js} +1 -1
- package/public/assets/Browser.es-BqZU_2qv.js +1 -0
- package/public/assets/Circle.es-j7f1_WI9.js +1 -0
- package/public/assets/{Clock.es-D6bs8ZLR.js → Clock.es-DkUjmG8U.js} +1 -1
- package/public/assets/{Copy.es-CglRiQSZ.js → Copy.es-DfOdr0jv.js} +1 -1
- package/public/assets/CopySimple.es-BBthx5Du.js +1 -0
- package/public/assets/CornersOut.es-Cd9DgMlt.js +1 -0
- package/public/assets/Crosshair.es-9qdLaRA1.js +1 -0
- package/public/assets/{Desktop.es-DVtEXtRb.js → Desktop.es-DSRSg0hy.js} +1 -1
- package/public/assets/{DotsSixVertical.es-B7kGbvvH.js → DotsSixVertical.es-Cg2wLxmG.js} +1 -1
- package/public/assets/{Eye.es-DKoV8w-8.js → Eye.es-CxGbwLRS.js} +1 -1
- package/public/assets/{EyeSlash.es-C_H7lJGL.js → EyeSlash.es-DfTto7s1.js} +1 -1
- package/public/assets/{File.es-47KQbmb4.js → File.es-D3fdUSmS.js} +1 -1
- package/public/assets/FloppyDisk.es-CVEXDdFf.js +1 -0
- package/public/assets/{Folder.es-DKrkcRQj.js → Folder.es-BUMi6qzZ.js} +1 -1
- package/public/assets/{FolderOpen.es-DaW9wv8-.js → FolderOpen.es-FcjULnXZ.js} +1 -1
- package/public/assets/{FolderPlus.es-D0scempH.js → FolderPlus.es-Deuvtys5.js} +1 -1
- package/public/assets/GearSix.es-CWRB8Up2.js +1 -0
- package/public/assets/List.es-C0rMRBfB.js +1 -0
- package/public/assets/{ListBullets.es-DGeupXZ3.js → ListBullets.es-B7JvZb2M.js} +1 -1
- package/public/assets/{LockSimple.es-DiQO6y_F.js → LockSimple.es-D5Ul9U6c.js} +1 -1
- package/public/assets/LockSimpleOpen.es-C2JGRKEE.js +1 -0
- package/public/assets/{MagnifyingGlass.es-CHks7m9E.js → MagnifyingGlass.es-BPnvTl_3.js} +1 -1
- package/public/assets/{Microphone.es-CQat-MJ8.js → Microphone.es-BXBLW9YD.js} +1 -1
- package/public/assets/{Play.es-h1Fhb5wo.js → Play.es-BT5cMJ7L.js} +1 -1
- package/public/assets/{Plus.es-B-svcAlu.js → Plus.es-aakfbgmy.js} +1 -1
- package/public/assets/{Prohibit.es-M5ljYyQ3.js → Prohibit.es-pwiGfWLj.js} +1 -1
- package/public/assets/{QrCode.es-CVlyfpjq.js → QrCode.es-DCPGPGYZ.js} +1 -1
- package/public/assets/ShareNetwork-CTDRol5F.css +1 -0
- package/public/assets/ShareNetwork.es-Do0IWaE9.js +3 -0
- package/public/assets/SidebarSimple.es-UdNMyfL-.js +1 -0
- package/public/assets/{SlidersHorizontal.es-DkPz8o7o.js → SlidersHorizontal.es-957OxRrd.js} +1 -1
- package/public/assets/{TextAa.es-CymAJ91v.js → TextAa.es-8d8-rRe1.js} +1 -1
- package/public/assets/{Trash.es-B7UVM9v_.js → Trash.es-chxTwNhO.js} +1 -1
- package/public/assets/WarningCircle.es-CF4lQ1bU.js +1 -0
- package/public/assets/advanced-security-B_SegWCz.js +1 -0
- package/public/assets/agent-profiles-settings-DZv5BUzj.js +1 -0
- package/public/assets/appearance-settings-module-DlOVkZXP.js +1 -0
- package/public/assets/{ar-SA-G6X2FPQ2-R9ND2Rw0.js → ar-SA-G6X2FPQ2-DZP7qz6u.js} +1 -1
- package/public/assets/{attachment-embed-Bt5qCuKC.css → attachment-embed-CJkoG50a.css} +1 -1
- package/public/assets/attachment-embed-DVbcGTLJ.js +1 -0
- package/public/assets/attachments-settings-BuqoRFuK.js +1 -0
- package/public/assets/az-AZ-76LH7QW2-ByX_zd4F.js +1 -0
- package/public/assets/{bg-BG-XCXSNQG7-WKBfRf7q.js → bg-BG-XCXSNQG7-wxiUF1_6.js} +1 -1
- package/public/assets/blue-pgMgVzKw.css +1 -0
- package/public/assets/{bn-BD-2XOGV67Q-BmT7jnvl.js → bn-BD-2XOGV67Q-BBIhV1oq.js} +1 -1
- package/public/assets/{board-workspace-D9prroo0.css → board-workspace-CUeGZca9.css} +1 -1
- package/public/assets/board-workspace-pt2JAfWJ.js +1 -0
- package/public/assets/boards-settings-module-CaOcLdGN.js +1 -0
- package/public/assets/{boards-view-3JR36W_w.js → boards-view-DEVAYmzH.js} +1 -1
- package/public/assets/{ca-ES-6MX7JW3Y-CBR9ytrG.js → ca-ES-6MX7JW3Y-CKplVKfE.js} +1 -1
- package/public/assets/calendar-view-B-w_4BV-.js +1 -0
- package/public/assets/calendar-workspace-BiPYwfJr.js +1 -0
- package/public/assets/{calendars-settings-module-BWI1k_YA.js → calendars-settings-module-DuwhjpAm.js} +1 -1
- package/public/assets/card-fields-BJ9YVWI0.css +1 -0
- package/public/assets/{card-fields-eo7dqj1P.js → card-fields-iDvc1GXx.js} +1 -1
- package/public/assets/{chat-composer-editor-DCmWVP16.js → chat-composer-editor-CPfqqfXn.js} +1 -1
- package/public/assets/{chat-message-list-DPXjDBw1.js → chat-message-list-Ds52ru39.js} +1 -1
- package/public/assets/chunk-6U3AYISY-C6-Mtja1.js +12 -0
- package/public/assets/{chunk-EIO257PC-Bfdsn_q8.js → chunk-EIO257PC-DvUJi4Nw.js} +1 -1
- package/public/assets/chunk-K2UTITRG-ZTIxemJp.js +41 -0
- package/public/assets/chunk-SRAX5OIU-wzfotNc-.js +1 -0
- package/public/assets/chunk-Z3N5DIM6-D9TMVU7m.js +1 -0
- package/public/assets/{code-editor-CxLqzVwa.js → code-editor-BTcitmHE.js} +1 -1
- package/public/assets/code-editor-DIB7VOIc.css +1 -0
- package/public/assets/{color-picker-Cmg2HIDb.css → color-picker-BV0aOd4w.css} +1 -1
- package/public/assets/{color-picker-DK8V_DI0.js → color-picker-WHiWktCJ.js} +1 -1
- package/public/assets/{contents-view-DHRWEBwV.js → contents-view-DOVe1FVg.js} +1 -1
- package/public/assets/contents-view-XuasBH0m.css +1 -0
- package/public/assets/{conversation-debug-panel-zsrBEMxW.js → conversation-debug-panel-C73_GL9P.js} +1 -1
- package/public/assets/{settings-view-Bd65kLGK.css → core-settings-module-DNS3W-dj.css} +1 -1
- package/public/assets/core-settings-module-_wQSD6hP.js +4 -0
- package/public/assets/create-note-popup-B-wM8Q5O.js +1 -0
- package/public/assets/{cs-CZ-2BRQDIVT-fiabtlu1.js → cs-CZ-2BRQDIVT-CHlJO48i.js} +1 -1
- package/public/assets/{cypher-editor-ef6RdDgm.js → cypher-editor-M9g--02t.js} +1 -1
- package/public/assets/{da-DK-5WZEPLOC-C-5tRCvs.js → da-DK-5WZEPLOC-B2KbOKlk.js} +1 -1
- package/public/assets/daily-notes-settings-CrgXHhLI.js +1 -0
- package/public/assets/{dashboard-grid-DKMK4z_a.js → dashboard-grid-BZ8kYdV4.js} +2 -2
- package/public/assets/dashboard-workspace-CIhpZ3rj.js +4 -0
- package/public/assets/dashboard-workspace-ChhR6uFw.css +1 -0
- package/public/assets/{dashboards-settings-module-DmE0Krje.js → dashboards-settings-module-CUyrJjUX.js} +1 -1
- package/public/assets/dashboards-view-CkheD5RG.js +1 -0
- package/public/assets/{de-DE-XR44H4JA-4wneKMQi.js → de-DE-XR44H4JA-CraH52sB.js} +1 -1
- package/public/assets/{desktop-server-settings-DDd8PcxW.js → desktop-server-settings-CDuPB2R6.js} +1 -1
- package/public/assets/discovery-create-popup-aCpL7caq.js +1 -0
- package/public/assets/discovery-import-popup-qmw9XOW8.js +1 -0
- package/public/assets/{discovery-settings-module-DQMZismj.js → discovery-settings-module-BiY4ib2N.js} +1 -1
- package/public/assets/discovery-view-CPYP4CTN.js +1 -0
- package/public/assets/discovery-workspace-COn6jS_C.js +2 -0
- package/public/assets/{dist-B58c6eJE.js → dist-BmY58onI.js} +1 -1
- package/public/assets/drag-preview-i140CAXv.js +1 -0
- package/public/assets/{drawing-note-BytzAih9.js → drawing-note-CZIRcZb4.js} +1 -1
- package/public/assets/{el-GR-BZB4AONW-BUDxOK9m.js → el-GR-BZB4AONW-hWxkjrdo.js} +1 -1
- package/public/assets/en-B4ZKOASM-CDD2_KUt.js +1 -0
- package/public/assets/{es-ES-U4NZUMDT-gXLOOlpz.js → es-ES-U4NZUMDT-D3W7yrM9.js} +1 -1
- package/public/assets/{esm-BSlSeh8A.js → esm-BwVJXUDM.js} +1 -1
- package/public/assets/{eu-ES-A7QVB2H4-4kiV_opo.js → eu-ES-A7QVB2H4-C6t3pMxo.js} +1 -1
- package/public/assets/export-formats-BEyzF7fr.js +1 -0
- package/public/assets/{fa-IR-HGAKTJCU-C7F0Dl4h.js → fa-IR-HGAKTJCU-DJOOVnVh.js} +1 -1
- package/public/assets/{feature-switch-section-617S6UWP.js → feature-switch-section-DWkHmh9Q.js} +1 -1
- package/public/assets/{fi-FI-Z5N7JZ37-DEUSwc4a.js → fi-FI-Z5N7JZ37-DEhnpOQb.js} +1 -1
- package/public/assets/file-editor-BMcxRFx_.css +1 -0
- package/public/assets/file-editor-WXaKLCia.js +3 -0
- package/public/assets/{file-language-DjeubQk3.js → file-language-BAXzYrUs.js} +1 -1
- package/public/assets/file-picker-Bo4sE6ud.css +1 -0
- package/public/assets/file-picker-DalNc5HP.js +1 -0
- package/public/assets/file-preview-B2sjiYV9.css +1 -0
- package/public/assets/file-preview-CBXgB9qm.js +1 -0
- package/public/assets/{file-preview-media-DL2hGeeZ.js → file-preview-media-D5_7dD-7.js} +1 -1
- package/public/assets/file-references-api-IoK82adM.js +1 -0
- package/public/assets/files-settings-module-DTmzlXAF.js +1 -0
- package/public/assets/files-view-D7awxVSV.js +3 -0
- package/public/assets/{files-view-B6_Mlm9V.css → files-view-DyPI1vLx.css} +1 -1
- package/public/assets/{format-panel-value-vueBm4DQ.js → format-panel-value-Qry4ewBT.js} +1 -1
- package/public/assets/format-rules-BFnbjJsr.js +1 -0
- package/public/assets/{fr-FR-RHASNOE6-BKLo10bn.js → fr-FR-RHASNOE6-D9pFTuqa.js} +1 -1
- package/public/assets/{gl-ES-HMX3MZ6V-D_nHnidC.js → gl-ES-HMX3MZ6V-CIK6mfAj.js} +1 -1
- package/public/assets/graph-explorer-DEddRhZU.js +329 -0
- package/public/assets/graph-settings-module-CdwcXpWv.js +1 -0
- package/public/assets/{he-IL-6SHJWFNN-BXKK7JWx.js → he-IL-6SHJWFNN-sIPLWf4m.js} +1 -1
- package/public/assets/{hi-IN-IWLTKZ5I-D2utCBQM.js → hi-IN-IWLTKZ5I-BUJucdSj.js} +1 -1
- package/public/assets/{hu-HU-A5ZG7DT2-BENIngFF.js → hu-HU-A5ZG7DT2-B29-4soS.js} +1 -1
- package/public/assets/icons-BQSaMzmI.js +1 -0
- package/public/assets/{id-ID-SAP4L64H-Bw77jJOj.js → id-ID-SAP4L64H-CyIfHt3t.js} +1 -1
- package/public/assets/ide-settings-module-DmJJdyaW.js +1 -0
- package/public/assets/ide-view-BhQVUYYS.js +1 -0
- package/public/assets/ide-view-Cou_U3E6.css +1 -0
- package/public/assets/image-GAAHSSAO-BxryKUrU.js +1 -0
- package/public/assets/imap-accounts-my6l8ble.js +1 -0
- package/public/assets/index-CfVw4gte.js +9 -0
- package/public/assets/index-CuWXx5Sr.css +1 -0
- package/public/assets/{it-IT-JPQ66NNP-DiG4G8vQ.js → it-IT-JPQ66NNP-Dq23HshR.js} +1 -1
- package/public/assets/{ja-JP-DBVTYXUO-CILN9NGs.js → ja-JP-DBVTYXUO-8NNxRVWb.js} +1 -1
- package/public/assets/journal-create-popup-DsFTus7q.js +1 -0
- package/public/assets/journal-day-route-BX4-KaSl.js +1 -0
- package/public/assets/journal-folder-field-hSCfQuop.js +1 -0
- package/public/assets/journal-page-CoLcbMGG.css +1 -0
- package/public/assets/journal-page-CuUs4DCL.js +2 -0
- package/public/assets/journal-settings-BeM9sz5z.js +1 -0
- package/public/assets/journal-typography-BB4TqmXu.js +1 -0
- package/public/assets/journal-writing-route-Ba7mqWJS.js +1 -0
- package/public/assets/journals-view-Cf89lTyQ.js +1 -0
- package/public/assets/kaa-6HZHGXH3-DWQlZzTI.js +1 -0
- package/public/assets/{kab-KAB-ZGHBKWFO-yPJB-J7N.js → kab-KAB-ZGHBKWFO-BCP7pvXg.js} +1 -1
- package/public/assets/kk-KZ-P5N5QNE5-xOkOQsTw.js +1 -0
- package/public/assets/{km-KH-HSX4SM5Z-CSZjabru.js → km-KH-HSX4SM5Z-D0xjNROe.js} +1 -1
- package/public/assets/{ko-KR-MTYHY66A-CGEXYXZz.js → ko-KR-MTYHY66A-E5aEyLj-.js} +1 -1
- package/public/assets/{ku-TR-6OUDTVRD-DOfuZRKI.js → ku-TR-6OUDTVRD-CDQOo-yR.js} +1 -1
- package/public/assets/link-choices-CRTxLpuA.js +1 -0
- package/public/assets/link-entry-route-C1tWLndS.js +1 -0
- package/public/assets/link-file-browser-RuO2yY0g.js +1 -0
- package/public/assets/{link-kind-icon-BMfHfR_C.js → link-kind-icon-BgeZ5N-E.js} +1 -1
- package/public/assets/link-picker-CWK41zM0.js +2 -0
- package/public/assets/locked-shares-prompt-eH6sWg93.js +1 -0
- package/public/assets/{logging-settings-contribution-BLHCBnwO.js → logging-settings-contribution-Btq9ioZn.js} +1 -1
- package/public/assets/logic-CiFwn-O5.js +28 -0
- package/public/assets/long-press-C_vMz2E6.js +1 -0
- package/public/assets/{lt-LT-XHIRWOB4-CmbJTJAh.js → lt-LT-XHIRWOB4-CZPudjgc.js} +1 -1
- package/public/assets/{lv-LV-5QDEKY6T-Br-VqxTs.js → lv-LV-5QDEKY6T-BFIvtooB.js} +1 -1
- package/public/assets/markdown-message-BmuXZdEl.js +3 -0
- package/public/assets/markdown-message-CEFw-l9n.css +1 -0
- package/public/assets/markdown-task-toggle-BdNMBrC0.css +1 -0
- package/public/assets/markdown-task-toggle-j4VvSqsD.js +4 -0
- package/public/assets/{matrices-settings-module-DKGdrCad.js → matrices-settings-module-CoOYPwEU.js} +1 -1
- package/public/assets/matrices-view-CcjCls3L.js +1 -0
- package/public/assets/matrix-workspace-98WdHTfO.js +1 -0
- package/public/assets/{maximize-2-DATMN9kx.js → maximize-2-BOW9VTPW.js} +1 -1
- package/public/assets/mermaid-diagram-kld9fHwj.js +1 -0
- package/public/assets/{mobile-file-text-meniSeto.js → mobile-file-text-BqyOwF0N.js} +1 -1
- package/public/assets/mobile-note-content-editor-BPxespTd.js +2 -0
- package/public/assets/{mobile-panel-layer-2EcEm-JB.js → mobile-panel-layer-CA_yph77.js} +1 -1
- package/public/assets/model-provider-settings-contribution-CECr7FiG.js +1 -0
- package/public/assets/model-providers-Ptlz_trq.js +1 -0
- package/public/assets/move-destination-2AXvBdlJ.js +1 -0
- package/public/assets/move-entries-dialog-BEJJSv8J.js +1 -0
- package/public/assets/{mr-IN-CRQNXWMA-DwF8SFQB.js → mr-IN-CRQNXWMA-DmnSBhlL.js} +1 -1
- package/public/assets/my-MM-5M5IBNSE-DDu4zmzX.js +1 -0
- package/public/assets/{nb-NO-T6EIAALU-BelWzTQs.js → nb-NO-T6EIAALU-BLzt9sXj.js} +1 -1
- package/public/assets/{nl-NL-IS3SIHDZ-Ce06PPL4.js → nl-NL-IS3SIHDZ-FtFhrALS.js} +1 -1
- package/public/assets/{nn-NO-6E72VCQL-BbXlzJzR.js → nn-NO-6E72VCQL-B_SymEE5.js} +1 -1
- package/public/assets/note-body-focus-d1lrm6Vw.js +1 -0
- package/public/assets/note-collab-provider-B5sEpjH1.js +1 -0
- package/public/assets/note-collab-transport-HTl4Zdug.js +1 -0
- package/public/assets/note-create-settings-module-iEVdyRFV.js +1 -0
- package/public/assets/{note-documents-CcJDTkta.js → note-documents-BPTwtsVi.js} +2 -2
- package/public/assets/note-editor-container-Ct9S4xJq.css +1 -0
- package/public/assets/note-editor-container-DzXoYKkT.js +2 -0
- package/public/assets/note-editor-settings-module-BZalej3y.js +1 -0
- package/public/assets/note-excalidraw-editor-CYHK-nyq.js +118 -0
- package/public/assets/note-excalidraw-editor-DVHMAsgJ.css +1 -0
- package/public/assets/{note-export-api-CwuXGV0y.js → note-export-api-Cdb5DLzA.js} +1 -1
- package/public/assets/note-export-flow-CfLnfRzg.js +1 -0
- package/public/assets/{note-filter-rule-rows-DFSWBwql.js → note-filter-rule-rows-DmVis2Dw.js} +1 -1
- package/public/assets/note-folds-settings-module-DeVre4gm.js +1 -0
- package/public/assets/note-frontmatter-summary-DNdQjzv5.js +1 -0
- package/public/assets/note-history-retention-B5aE8fKh.js +1 -0
- package/public/assets/note-link-list-C2i2SrSh.css +1 -0
- package/public/assets/note-link-list-DD4FzeUb.js +2 -0
- package/public/assets/note-markdown-editor-BlWCUXb9.js +26 -0
- package/public/assets/note-markdown-editor-Dp1k8dWQ.css +1 -0
- package/public/assets/{note-outline-BFidIp-8.js → note-outline-C-dPTJrB.js} +2 -2
- package/public/assets/note-outline-DTpLzjGU.css +1 -0
- package/public/assets/note-page-content-CZH9UDn0.js +2 -0
- package/public/assets/{note-page-editor-BgcMK_4q.css → note-page-editor-D7Wt_Giv.css} +1 -1
- package/public/assets/{note-page-editor-DpVUxkCx.js → note-page-editor-D8M6gjmG.js} +4 -4
- package/public/assets/note-path-breadcrumb-CLfo-0XG.js +1 -0
- package/public/assets/{note-path-breadcrumb-YC4bHnwX.css → note-path-breadcrumb-Drkebhvm.css} +1 -1
- package/public/assets/{note-picker-B5i41l1u.js → note-picker-DIFcqGgZ.js} +1 -1
- package/public/assets/note-picker-KBB6aonj.css +1 -0
- package/public/assets/{note-picker-popover-B9VTeHiM.js → note-picker-popover-CoT73GG-.js} +1 -1
- package/public/assets/note-shares-popup-CmUAI6V-.js +1 -0
- package/public/assets/note-side-panel-BFno3955.js +1 -0
- package/public/assets/note-side-panel-DLOy2dVw.css +1 -0
- package/public/assets/note-side-panel-host-iIfi_4c4.js +1 -0
- package/public/assets/note-source-editor-CVo_ZXww.js +1 -0
- package/public/assets/{note-type-grid-CRCfpYZy.js → note-type-grid-Bfdc8U-T.js} +2 -2
- package/public/assets/{note-type-grid-BM33ZYF-.css → note-type-grid-BzMZLAzW.css} +1 -1
- package/public/assets/{note-values-6D6wWXPg.js → note-values-C4A12_CE.js} +1 -1
- package/public/assets/notes-settings-module-DBSeNBYj.js +1 -0
- package/public/assets/notes-view-C_mX24NH.js +1 -0
- package/public/assets/notes-view-D212ymqf.css +1 -0
- package/public/assets/{oc-FR-POXYY2M6-CyRgkETq.js → oc-FR-POXYY2M6-DM9hsX9Q.js} +1 -1
- package/public/assets/{open-journal-writing-Bub8Zn13.js → open-journal-writing-Da9CBYtR.js} +1 -1
- package/public/assets/{pa-IN-N4M65BXN-A1_Q9748.js → pa-IN-N4M65BXN-CJJQ9oPk.js} +1 -1
- package/public/assets/page-content-27iX_YpJ.js +1 -0
- package/public/assets/page-content-CdioJybS.css +1 -0
- package/public/assets/page-export-api-BqvyvK1O.js +1 -0
- package/public/assets/page-export-flow-HzZ0AmjW.js +1 -0
- package/public/assets/page-files-C30eoBCR.js +1 -0
- package/public/assets/page-note-7Oo1OmH0.js +1 -0
- package/public/assets/pane-layout-BaHTn1Oz.js +1 -0
- package/public/assets/{panel-columns-fields-ZlW6A4My.js → panel-columns-fields-B9Biz8Xm.js} +1 -1
- package/public/assets/pdf-view-B5Y12R4H.js +1 -0
- package/public/assets/pdf-view-X71jeHKm.css +1 -0
- package/public/assets/{pencil-xxFNyZzr.js → pencil-BQzjBcpa.js} +1 -1
- package/public/assets/percentages-BXMCSKIN-DRPvI3O-.js +1 -0
- package/public/assets/{phone-numbers-BQgyhfcH.js → phone-numbers-lV_IC3Pq.js} +1 -1
- package/public/assets/{pl-PL-T2D74RX3-DaINIVjz.js → pl-PL-T2D74RX3-BLAcchR-.js} +1 -1
- package/public/assets/progress-bar-BxjnW3uQ.js +1 -0
- package/public/assets/provider-configuration-DBW3Pa0C.js +8 -0
- package/public/assets/provider-configuration-dpnYrEZm.css +1 -0
- package/public/assets/provider-use-select-C0EI8kSQ.js +1 -0
- package/public/assets/{pt-BR-5N22H2LF-ENVHjTz_.js → pt-BR-5N22H2LF-BiLQ-V_W.js} +1 -1
- package/public/assets/{pt-PT-UZXXM6DQ-D5Uqv0Vz.js → pt-PT-UZXXM6DQ-DKEXacg3.js} +1 -1
- package/public/assets/qr-code-DgTUKCej.js +2 -0
- package/public/assets/{qr-code-svg-8ENstC8b.js → qr-code-svg-DdWw4ovA.js} +1 -1
- package/public/assets/qr-defaults-settings-BbbzxV5k.js +1 -0
- package/public/assets/qr-settings-fields-C8GCAxa_.js +1 -0
- package/public/assets/qr-viewer-DTCnaLOP.js +1 -0
- package/public/assets/queryOptions-Dfvzj6n2.js +1 -0
- package/public/assets/{reader-clock-7x7Yvzv1.js → reader-clock-s4x6Qtz_.js} +1 -1
- package/public/assets/{recording-bar-BcuvYwhh.js → recording-bar-C5jkIsLX.js} +1 -1
- package/public/assets/{recording-setup-D_MgrYb7.js → recording-setup-fZ6fe1MX.js} +1 -1
- package/public/assets/{recordings-api-Ds77lFsk.js → recordings-api-CxuXFNaM.js} +1 -1
- package/public/assets/{resource-overview-card-BainFWKz.js → resource-overview-card-CAxT9QxY.js} +1 -1
- package/public/assets/{ro-RO-JPDTUUEW-Dq_ouOp1.js → ro-RO-JPDTUUEW-DPtQ18Fr.js} +1 -1
- package/public/assets/rss-settings-module-Bg7BBsC4.js +1 -0
- package/public/assets/rss-view-DeSvhXEa.js +3 -0
- package/public/assets/{ru-RU-B4JR7IUQ-CqqISqJC.js → ru-RU-B4JR7IUQ-n-7DhzM7.js} +1 -1
- package/public/assets/{safe-block-copy-BOVhmncw.js → safe-block-copy-B7NrP_YX.js} +1 -1
- package/public/assets/{safe-block-qr-button-CD7cJG3N.js → safe-block-qr-button-DomQCK7l.js} +1 -1
- package/public/assets/safe-block-reader-BGmIVIwN.js +1 -0
- package/public/assets/safe-folder-conversion-Re-4B3nf.js +1 -0
- package/public/assets/{safe-folders-DmvM6dtV.js → safe-folders-B4zJo8qB.js} +1 -1
- package/public/assets/{safe-move-leaving-BT5e1h3p.js → safe-move-leaving-D4dKIwTJ.js} +1 -1
- package/public/assets/{safe-note-locked-BDCeVwpK.js → safe-note-locked-BGUjggd4.js} +1 -1
- package/public/assets/safe-notes-settings-module-zJbcwdU7.js +1 -0
- package/public/assets/{markdown-task-toggle-CuRdtBn0.css → safe-text-B4Q6DSRg.css} +1 -1
- package/public/assets/safe-text-MPRw9KNQ.js +2 -0
- package/public/assets/search-settings-module-CMWbEyvZ.js +1 -0
- package/public/assets/{secret-form-B-YAlbZf.js → secret-form-DoNXw27T.js} +1 -1
- package/public/assets/secret-popup-Vn5Xkv4s.js +1 -0
- package/public/assets/section-navigation-1mCyY2Gm.js +1 -0
- package/public/assets/{security-settings-contribution-BmcZq1hf.js → security-settings-contribution-BrPrGp5q.js} +1 -1
- package/public/assets/settings-CxK-AM0A.js +1 -0
- package/public/assets/settings-actions-DnTiS3-h.js +1 -0
- package/public/assets/{settings-edit-dialog-C_AeTz9Y.js → settings-edit-dialog-CE5ZTszW.js} +1 -1
- package/public/assets/settings-panel-BF5baIMl.js +1 -0
- package/public/assets/settings-surface-CDwMuN24.js +3 -0
- package/public/assets/settings-surface-DzW4lcds.css +1 -0
- package/public/assets/{setup-prompt-BbpHVdla.js → setup-prompt-Bmv_QxoH.js} +1 -1
- package/public/assets/{share-access-control-CzAVEv6b.js → share-access-control-CB7J42Dn.js} +1 -1
- package/public/assets/shared-board-CLRkwNKE.js +1 -0
- package/public/assets/shared-board-lanes-OZo3pA9j.js +1 -0
- package/public/assets/{shared-calendar-view-DTzDjSs0.js → shared-calendar-view-BSmK0NDE.js} +1 -1
- package/public/assets/shared-note-route-CnykVAYu.css +1 -0
- package/public/assets/shared-note-route-DtZVqLMu.js +4 -0
- package/public/assets/shared-note-text-C6nccM7z.js +1 -0
- package/public/assets/{shares-settings-module-pIdBLmCq.js → shares-settings-module-gI5s2PT6.js} +1 -1
- package/public/assets/si-LK-N5RQ5JYF-BpI-kBDz.js +1 -0
- package/public/assets/{sk-SK-C5VTKIMK-YiOZ-xKA.js → sk-SK-C5VTKIMK-BRXRBgRU.js} +1 -1
- package/public/assets/{sl-SI-NN7IZMDC-BKb37Hlu.js → sl-SI-NN7IZMDC-BXKt0fnN.js} +1 -1
- package/public/assets/{spaces-settings-module-BLU1RsTS.js → spaces-settings-module-BOkTwY_Z.js} +1 -1
- package/public/assets/spaces-view-K5_OKPoW.js +2 -0
- package/public/assets/sqlite-browser-BVA27ofB.css +1 -0
- package/public/assets/sqlite-browser-DCKBF2SI.js +2 -0
- package/public/assets/stack-widgets-CLUFu_vQ.js +1 -0
- package/public/assets/store-attachments-DQ63HVZo.js +1 -0
- package/public/assets/stored-color-picker-BLs1gClm.css +1 -0
- package/public/assets/stored-color-picker-CZ66rDog.js +1 -0
- package/public/assets/style-DPV_jdGg.css +1 -0
- package/public/assets/subset-shared.chunk-DYH4c2c2.js +1 -0
- package/public/assets/subset-worker.chunk-yCTTgC3G.js +1 -0
- package/public/assets/{sv-SE-XGPEYMSR-VT0snW-T.js → sv-SE-XGPEYMSR-nBH8YjQ4.js} +1 -1
- package/public/assets/{ta-IN-2NMHFXQM--MqIf2Jf.js → ta-IN-2NMHFXQM-f0oprEqN.js} +1 -1
- package/public/assets/{text-diff-BmKfp7mY.js → text-diff-BMS8apwf.js} +1 -1
- package/public/assets/th-TH-HPSO5L25-CUOH0u8u.js +2 -0
- package/public/assets/{theme-colors-zbTaiYL0.js → theme-colors-BcoD3SUn.js} +1 -1
- package/public/assets/{toolbar-items-DLi0bl0c.js → toolbar-items-DtGvJf3U.js} +1 -1
- package/public/assets/{topology-code-editor-CNnSyUQ3.js → topology-code-editor-ClyHjN--.js} +1 -1
- package/public/assets/topology-designer-DmhzdlOY.js +1 -0
- package/public/assets/{topology-editor-DUaww3cM.css → topology-editor-CZnvLbBi.css} +1 -1
- package/public/assets/topology-editor-YK_2uGkR.js +8 -0
- package/public/assets/{topology-folder-migration-popup-C0Wc3ViK.js → topology-folder-migration-popup-AZFR8-44.js} +1 -1
- package/public/assets/{tr-TR-DEFEU3FU-BVLSiyVW.js → tr-TR-DEFEU3FU-CTsS8Qy-.js} +1 -1
- package/public/assets/{transcription-settings-BldPwHO7.js → transcription-settings-D7_ViMfp.js} +2 -2
- package/public/assets/tree-header-CmCmDZKG.js +1 -0
- package/public/assets/tree-header-DlATpadF.css +1 -0
- package/public/assets/types-settings-module-L4wPTMty.js +1 -0
- package/public/assets/{uk-UA-QMV73CPH-DQ4YsZml.js → uk-UA-QMV73CPH-BJo17WQM.js} +1 -1
- package/public/assets/{unlock-prompt-CkkcVo9g.js → unlock-prompt-BQVrb-4k.js} +1 -1
- package/public/assets/{use-candidate-notes-jH4-EW29.js → use-candidate-notes-YOxWyJCJ.js} +1 -1
- package/public/assets/{directory-picker-columns-BpDkvDO0.css → use-directory-columns-DILivjwk.css} +1 -1
- package/public/assets/use-directory-columns-DYequGsf.js +1 -0
- package/public/assets/use-directory-listing-Bj3F5kA3.js +1 -0
- package/public/assets/use-folding-enabled-N7w9iIqy.js +1 -0
- package/public/assets/use-heading-location-BZ9wUH2j.js +1 -0
- package/public/assets/{use-live-document-D4PkZrbU.js → use-live-document-4fc8FCW3.js} +1 -1
- package/public/assets/use-mobile-layer-navigation-Il_7QdXn.js +1 -0
- package/public/assets/{use-note-attachments-Bew073Hl.js → use-note-attachments-DAFyHvYo.js} +1 -1
- package/public/assets/{use-note-delete-fFNH1Glk.js → use-note-delete-JQISrVQ4.js} +1 -1
- package/public/assets/{use-note-editor-session-R1wm0xDf.js → use-note-editor-session-BlLoBd41.js} +1 -1
- package/public/assets/use-note-maximize-offer-DpU6Ms0_.js +1 -0
- package/public/assets/use-note-side-column-CFBvrpKH.css +1 -0
- package/public/assets/use-note-side-column-CVs74c26.js +1 -0
- package/public/assets/use-provider-dialogs-BRoAomhX.css +1 -0
- package/public/assets/use-provider-dialogs-HkxDcuJv.js +1 -0
- package/public/assets/{use-reflection-request-C1DxtaYX.js → use-reflection-request-BuFnMuQC.js} +4 -4
- package/public/assets/use-safe-folder-moves-CjbmSWSM.js +1 -0
- package/public/assets/use-safe-folders-apply-D_7a5l_T.js +1 -0
- package/public/assets/{use-screen-source-CF-48NnC.js → use-screen-source-BZ0GGtml.js} +1 -1
- package/public/assets/use-share-actions-DBYaF7Wp.css +1 -0
- package/public/assets/use-share-actions-Tfr6NI4j.js +1 -0
- package/public/assets/use-tab-style-B5YK0cIz.js +2 -0
- package/public/assets/use-tab-style-CRx5AnD1.css +1 -0
- package/public/assets/use-vault-file-link-BCQahdir.js +1 -0
- package/public/assets/{use-voice-questions-DGVQlAST.js → use-voice-questions-DmxYfc8M.js} +1 -1
- package/public/assets/vault-entries-api-CZHdxv7-.js +1 -0
- package/public/assets/vault-file-links-D1RzhVkx.js +1 -0
- package/public/assets/vault-folder-field-C5b24MNS.js +1 -0
- package/public/assets/vault-folder-field-X-B1weCe.css +1 -0
- package/public/assets/vault-links-popup-zkFCHyoP.js +1 -0
- package/public/assets/vault-manager-CZnYayEU.js +1 -0
- package/public/assets/{vault-settings-module-CCMMSy4B.js → vault-settings-module-CL2DHG69.js} +1 -1
- package/public/assets/vault-shares-popup-Cnew0vMQ.js +1 -0
- package/public/assets/vault-workspace-settings-module-D_n4aQfC.js +1 -0
- package/public/assets/{versioning-preferences-DrNq-y_0.js → versioning-preferences-BK-mZYhi.js} +1 -1
- package/public/assets/{versioning-settings-module-Ddug486c.js → versioning-settings-module-lq4k7b3C.js} +1 -1
- package/public/assets/versioning-view-BdEZaF8n.js +2 -0
- package/public/assets/{vi-VN-M7AON7JQ-B-fHV7o8.js → vi-VN-M7AON7JQ-DpgVSDWc.js} +1 -1
- package/public/assets/video-recording-dialog-ByevPvCN.js +1 -0
- package/public/assets/{video-recording-settings-B2iE6IdW.js → video-recording-settings-Ce2plgiG.js} +1 -1
- package/public/assets/widget-frame-DzlpiABF.js +1 -0
- package/public/assets/widget-layouts-DS7nWc80.js +1 -0
- package/public/assets/workspace-layout-3hjN1Wng.js +1 -0
- package/public/assets/{zh-CN-LNUGB5OW-CUgxiiUV.js → zh-CN-LNUGB5OW-Cfb6--Ow.js} +1 -1
- package/public/assets/zh-HK-E62DVLB3-vaMRVwdL.js +1 -0
- package/public/assets/{zh-TW-RAJ6MFWO-BVaf47B6.js → zh-TW-RAJ6MFWO-CNUUB_PG.js} +1 -1
- package/public/index.html +6 -6
- package/dist/search/embedding-connection-migration.js +0 -57
- package/node_modules/@braian/ai-providers/dist/legacy-embedding-migration.js +0 -21
- package/public/assets/FileText.es-4c63tWmA.js +0 -1
- package/public/assets/TerminalWindow.es-DwLjQ_88.js +0 -1
- package/public/assets/Warning.es-4HWtj9Nt.js +0 -1
- package/public/assets/agent-profiles-settings-yElCnMJo.js +0 -1
- package/public/assets/appearance-settings-module-BFDKE-mZ.js +0 -1
- package/public/assets/attachment-embed-BX0XSPNZ.js +0 -1
- package/public/assets/attachments-settings-CSEjOoFg.js +0 -1
- package/public/assets/az-AZ-76LH7QW2-DpGlptKS.js +0 -1
- package/public/assets/blue-ezN0uv0j.css +0 -1
- package/public/assets/board-workspace-CmetKvXF.js +0 -1
- package/public/assets/boards-settings-module-Bh5dh9jG.js +0 -1
- package/public/assets/calendar-view-Cr1VSpj0.js +0 -1
- package/public/assets/calendar-workspace-B-2Himdy.js +0 -1
- package/public/assets/card-fields-C1JCmDVz.css +0 -1
- package/public/assets/code-editor-wFimHbMT.css +0 -1
- package/public/assets/contents-view-EQyMaey-.css +0 -1
- package/public/assets/create-note-popup-C9IB_IZr.js +0 -1
- package/public/assets/daily-notes-settings-CCotd1Iq.js +0 -1
- package/public/assets/dashboard-workspace-4u-QaXby.js +0 -4
- package/public/assets/dashboard-workspace-CW4tbadO.css +0 -1
- package/public/assets/dashboards-view-DxUAl6zg.js +0 -1
- package/public/assets/directory-picker-columns-CqPZNMT8.js +0 -1
- package/public/assets/discovery-create-popup-BSOSYM4o.js +0 -1
- package/public/assets/discovery-import-popup-NodFxSW1.js +0 -1
- package/public/assets/discovery-view-PiwStXSa.js +0 -1
- package/public/assets/discovery-workspace-BTrjBF19.js +0 -2
- package/public/assets/drag-preview-D61OK7zr.js +0 -1
- package/public/assets/en-B4ZKOASM-jB7I34Md.js +0 -1
- package/public/assets/file-editor-B-9eXvH3.css +0 -1
- package/public/assets/file-editor-DvP7rRI9.js +0 -3
- package/public/assets/file-preview-AkYowAab.js +0 -1
- package/public/assets/file-preview-Dynm8laQ.css +0 -1
- package/public/assets/file-references-api-C2G0bSy9.js +0 -1
- package/public/assets/files-settings-module-DsylYhrR.js +0 -1
- package/public/assets/files-view-DPSrj_WW.js +0 -3
- package/public/assets/folder-picker-dialog-CxiRBtQb.css +0 -1
- package/public/assets/folder-picker-dialog-D_VCqm_i.js +0 -1
- package/public/assets/format-rules-GzYB7Vvh.js +0 -1
- package/public/assets/graph-explorer-CHz-bFkx.js +0 -329
- package/public/assets/graph-settings-module-9hY9bkdT.js +0 -1
- package/public/assets/icons-CxH3_W-q.js +0 -1
- package/public/assets/ide-settings-module-BbIX3okW.js +0 -1
- package/public/assets/ide-view-0vK2duKI.js +0 -2
- package/public/assets/ide-view-isgMvraA.css +0 -1
- package/public/assets/image-GAAHSSAO-D4NDL8F6.js +0 -1
- package/public/assets/imap-accounts-BRbnITJv.js +0 -1
- package/public/assets/index-BVDhmwI8.js +0 -11
- package/public/assets/index-DjUUY3gd.css +0 -1
- package/public/assets/journal-create-popup-39y9ieVG.js +0 -1
- package/public/assets/journal-day-route-CYlyL-u0.js +0 -1
- package/public/assets/journal-folder-field-B8yNmuTt.css +0 -1
- package/public/assets/journal-folder-field-BfO-_ied.js +0 -1
- package/public/assets/journal-page-CAXrq4hj.css +0 -1
- package/public/assets/journal-page-TgyVFaPE.js +0 -2
- package/public/assets/journal-settings-CfjXOXzF.js +0 -1
- package/public/assets/journal-typography-D3O3AK2U.js +0 -1
- package/public/assets/journal-writing-route-CYhXzipC.js +0 -1
- package/public/assets/journals-view-DNomC0nF.js +0 -1
- package/public/assets/kaa-6HZHGXH3-BUua-YiR.js +0 -1
- package/public/assets/kk-KZ-P5N5QNE5-CAitSjw5.js +0 -1
- package/public/assets/link-file-browser-A_Mappx0.js +0 -1
- package/public/assets/link-picker-BfwWXJZg.js +0 -2
- package/public/assets/locked-shares-prompt-BsM-ai_V.js +0 -1
- package/public/assets/logic-DtHJ5GlU.js +0 -28
- package/public/assets/markdown-message-BIo2pHhE.js +0 -3
- package/public/assets/markdown-message-C2w22wrW.css +0 -1
- package/public/assets/markdown-task-toggle-9k1EldDD.js +0 -5
- package/public/assets/matrices-view-DYF7e5ES.js +0 -1
- package/public/assets/matrix-workspace-JZhH-HQ5.js +0 -1
- package/public/assets/mermaid-diagram-gUL2-JyE.js +0 -1
- package/public/assets/mobile-note-content-editor-C6TUyA4F.js +0 -2
- package/public/assets/model-provider-settings-contribution-CfHiu3nS.js +0 -1
- package/public/assets/model-providers-cQOCMmwX.js +0 -1
- package/public/assets/my-MM-5M5IBNSE-BEiMo9eJ.js +0 -1
- package/public/assets/note-body-focus-BKKGEgBj.js +0 -1
- package/public/assets/note-collab-provider-B9DpnE58.js +0 -1
- package/public/assets/note-collab-transport-BHZ891IL.js +0 -1
- package/public/assets/note-create-settings-module-rIZc1DjQ.js +0 -1
- package/public/assets/note-editor-container-8DkvXTPN.css +0 -1
- package/public/assets/note-editor-container-DL3yLdYs.js +0 -2
- package/public/assets/note-editor-settings-module-DI0jRyPy.js +0 -1
- package/public/assets/note-excalidraw-editor-CKSC5Oww.css +0 -1
- package/public/assets/note-excalidraw-editor-fDQ1JVBh.js +0 -168
- package/public/assets/note-export-flow-DcBoI5Pp.js +0 -1
- package/public/assets/note-folds-settings-module-CFfVg1Cp.js +0 -1
- package/public/assets/note-frontmatter-summary-iubFPHA_.js +0 -1
- package/public/assets/note-link-list-CI9-GM_3.js +0 -1
- package/public/assets/note-link-list-hmCbBMA2.css +0 -1
- package/public/assets/note-markdown-editor-DlBj1yv3.css +0 -1
- package/public/assets/note-markdown-editor-lG6gZT9i.js +0 -26
- package/public/assets/note-outline-CAyXKuOh.css +0 -1
- package/public/assets/note-page-content-8gzPBWMV.js +0 -2
- package/public/assets/note-path-breadcrumb-HmtWyYZP.js +0 -1
- package/public/assets/note-picker-BURTnmWF.css +0 -1
- package/public/assets/note-shares-popup-aUO1SNLN.js +0 -1
- package/public/assets/note-source-editor-BXPR_-41.js +0 -1
- package/public/assets/notes-settings-module-DcP9Hid-.js +0 -1
- package/public/assets/page-content-B3fNjwr-.js +0 -1
- package/public/assets/page-content-lnIaLh4X.css +0 -1
- package/public/assets/page-files-CSqFupDZ.js +0 -1
- package/public/assets/page-note-nmiinGCs.js +0 -1
- package/public/assets/pane-keys-DiGU3yVB.css +0 -1
- package/public/assets/pane-keys-osajBGnu.js +0 -1
- package/public/assets/pdf-view-BATpBLO5.js +0 -1
- package/public/assets/pdf-view-BK5qKL4y.css +0 -1
- package/public/assets/percentages-BXMCSKIN-DzsiA6IB.js +0 -1
- package/public/assets/provider-configuration-CSnNV6ps.css +0 -1
- package/public/assets/provider-configuration-DaFovElx.js +0 -8
- package/public/assets/provider-use-select-D-lJiZ2W.js +0 -1
- package/public/assets/qr-code-CDBCi1Cu.js +0 -2
- package/public/assets/qr-defaults-settings-C_8ybA4R.js +0 -1
- package/public/assets/qr-settings-fields-C2-DGF6a.js +0 -1
- package/public/assets/qr-viewer-DAOzDI8d.js +0 -1
- package/public/assets/rss-preferences-BafuZ3Ku.js +0 -1
- package/public/assets/rss-settings-module-Df-YS9tr.js +0 -1
- package/public/assets/rss-view-BORHnuIQ.js +0 -3
- package/public/assets/safe-block-reader-BkilW4Hj.js +0 -1
- package/public/assets/safe-folder-conversion-DWTRwvTH.js +0 -1
- package/public/assets/safe-notes-settings-module-BrZreYgf.js +0 -1
- package/public/assets/search-settings-module-CPnculiI.js +0 -1
- package/public/assets/secret-popup-CoVpeLZV.js +0 -1
- package/public/assets/settings-CU8YR8di.js +0 -1
- package/public/assets/settings-panel-Ds7lOtnD.js +0 -1
- package/public/assets/settings-view-BTz2XbnW.js +0 -4
- package/public/assets/share-label-CbjQ9iMF.js +0 -1
- package/public/assets/shared-board-lanes-CAbJAFk6.js +0 -1
- package/public/assets/shared-note-route-B5rcAeES.css +0 -1
- package/public/assets/shared-note-route-B_gfX0Nl.js +0 -4
- package/public/assets/shared-note-text-DFBEyL8Z.js +0 -1
- package/public/assets/si-LK-N5RQ5JYF-DmhE8IT5.js +0 -1
- package/public/assets/spaces-view-BhWD3mAw.js +0 -2
- package/public/assets/sqlite-browser-BKjuAUqe.css +0 -1
- package/public/assets/sqlite-browser-C98PFoRG.js +0 -2
- package/public/assets/store-attachments-DbqF7LgE.js +0 -1
- package/public/assets/stored-color-picker-BoVzUatG.css +0 -1
- package/public/assets/stored-color-picker-DLX-e5Nq.js +0 -1
- package/public/assets/style-DLioOiRN.css +0 -1
- package/public/assets/subset-shared.chunk-D8M638AI.js +0 -1
- package/public/assets/subset-worker.chunk-B9ZhBm-P.js +0 -1
- package/public/assets/th-TH-HPSO5L25-CTKAmQrO.js +0 -2
- package/public/assets/topology-designer-T54LYLYv.js +0 -1
- package/public/assets/topology-editor-aGtCktzA.js +0 -8
- package/public/assets/topology-settings-module-Dp-Sm37Z.js +0 -1
- package/public/assets/use-directory-listing-Cn9t21ra.js +0 -1
- package/public/assets/use-folding-enabled-DKvri2UA.js +0 -1
- package/public/assets/use-mobile-layer-navigation-BIC7HlT_.js +0 -1
- package/public/assets/use-note-export-flow-Dm7yhW5s.js +0 -2
- package/public/assets/use-provider-dialogs-CrxN9JCo.js +0 -1
- package/public/assets/use-safe-folder-moves-DjQUnMvz.js +0 -1
- package/public/assets/use-safe-folders-apply-B1V8l7WU.js +0 -1
- package/public/assets/use-share-actions-RxO2M3y0.css +0 -1
- package/public/assets/use-share-actions-kb7uFat_.js +0 -1
- package/public/assets/use-vault-file-link-B-ZRcKDu.js +0 -1
- package/public/assets/vault-entries-api-pFsJiGnJ.js +0 -1
- package/public/assets/vault-manager-YKz_Ib18.js +0 -1
- package/public/assets/vault-shares-popup-CaGnEIJA.js +0 -1
- package/public/assets/versioning-view-PR4R4gks.js +0 -2
- package/public/assets/video-recording-dialog-CxRs1eLE.js +0 -1
- package/public/assets/widget-frame-DiF4946k.js +0 -1
- package/public/assets/zh-HK-E62DVLB3-D-87W8QH.js +0 -1
- /package/public/assets/{blue-CDYoCZOg.js → blue-DQyE4k0K.js} +0 -0
- /package/public/assets/{use-safe-folders-apply-DGWTaX5A.css → progress-bar-DGWTaX5A.css} +0 -0
- /package/public/assets/{style-DA65Bz1d.js → style-CXzDJL_q.js} +0 -0
|
@@ -1,329 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/cypher-editor-ef6RdDgm.js","assets/rolldown-runtime-COiEfhsA.js","assets/codemirror-BqrpJAnL.js","assets/react-B3NTyEzE.js","assets/code-editor-CxLqzVwa.js","assets/index-BVDhmwI8.js","assets/state-9kAy-W2i.js","assets/icons-CxH3_W-q.js","assets/logic-DtHJ5GlU.js","assets/interaction-BeNMN0Kn.js","assets/motion-DVTefdmR.js","assets/index-DjUUY3gd.css","assets/file-language-DjeubQk3.js","assets/dist-B58c6eJE.js","assets/code-editor-wFimHbMT.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{i as e,n as t,t as n}from"./rolldown-runtime-COiEfhsA.js";import{m as r,t as i}from"./react-B3NTyEzE.js";import{Cr as a,Gt as o,In as s,Sr as c,Wt as l,_r as u,fr as d,hr as f,sr as p,vr as m,xr as h}from"./index-BVDhmwI8.js";import{Bs as g,Ol as _,Rs as v,Ws as y,ad as b,nc as x,od as S,sd as C,st as w}from"./logic-DtHJ5GlU.js";import{t as T}from"./ArrowsIn.es-B4Aie-uw.js";import{L as ee,T as te,z as ne}from"./icons-CxH3_W-q.js";import{t as re}from"./MagnifyingGlass.es-CHks7m9E.js";import{t as ie}from"./SlidersHorizontal.es-DkPz8o7o.js";import{t as ae}from"./ListBullets.es-DGeupXZ3.js";import{t as oe}from"./Play.es-h1Fhb5wo.js";import{t as se}from"./theme-colors-zbTaiYL0.js";import{t as ce}from"./note-open-intent-l6SCo3MI.js";var le=n(((e,t)=>{var n=typeof Reflect==`object`?Reflect:null,r=n&&typeof n.apply==`function`?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)},i=n&&typeof n.ownKeys==`function`?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};function a(e){console&&console.warn&&console.warn(e)}var o=Number.isNaN||function(e){return e!==e};function s(){s.init.call(this)}t.exports=s,t.exports.once=y,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var c=10;function l(e){if(typeof e!=`function`)throw TypeError(`The "listener" argument must be of type Function. Received type `+typeof e)}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(e){if(typeof e!=`number`||e<0||o(e))throw RangeError(`The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received `+e+`.`);c=e}}),s.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(e){if(typeof e!=`number`||e<0||o(e))throw RangeError(`The value of "n" is out of range. It must be a non-negative number. Received `+e+`.`);return this._maxListeners=e,this};function u(e){return e._maxListeners===void 0?s.defaultMaxListeners:e._maxListeners}s.prototype.getMaxListeners=function(){return u(this)},s.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i=e===`error`,a=this._events;if(a!==void 0)i&&=a.error===void 0;else if(!i)return!1;if(i){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var s=Error(`Unhandled error.`+(o?` (`+o.message+`)`:``));throw s.context=o,s}var c=a[e];if(c===void 0)return!1;if(typeof c==`function`)r(c,this,t);else for(var l=c.length,u=g(c,l),n=0;n<l;++n)r(u[n],this,t);return!0};function d(e,t,n,r){var i,o,s;if(l(n),o=e._events,o===void 0?(o=e._events=Object.create(null),e._eventsCount=0):(o.newListener!==void 0&&(e.emit(`newListener`,t,n.listener?n.listener:n),o=e._events),s=o[t]),s===void 0)s=o[t]=n,++e._eventsCount;else if(typeof s==`function`?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),i=u(e),i>0&&s.length>i&&!s.warned){s.warned=!0;var c=Error(`Possible EventEmitter memory leak detected. `+s.length+` `+String(t)+` listeners added. Use emitter.setMaxListeners() to increase limit`);c.name=`MaxListenersExceededWarning`,c.emitter=e,c.type=t,c.count=s.length,a(c)}return e}s.prototype.addListener=function(e,t){return d(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return d(this,e,t,!0)};function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=f.bind(r);return i.listener=n,r.wrapFn=i,i}s.prototype.once=function(e,t){return l(t),this.on(e,p(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return l(t),this.prependListener(e,p(this,e,t)),this},s.prototype.removeListener=function(e,t){var n,r,i,a,o;if(l(t),r=this._events,r===void 0||(n=r[e],n===void 0))return this;if(n===t||n.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit(`removeListener`,e,n.listener||t));else if(typeof n!=`function`){for(i=-1,a=n.length-1;a>=0;a--)if(n[a]===t||n[a].listener===t){o=n[a].listener,i=a;break}if(i<0)return this;i===0?n.shift():_(n,i),n.length===1&&(r[e]=n[0]),r.removeListener!==void 0&&this.emit(`removeListener`,e,o||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,n=this._events,r;if(n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var i=Object.keys(n),a;for(r=0;r<i.length;++r)a=i[r],a!==`removeListener`&&this.removeAllListeners(a);return this.removeAllListeners(`removeListener`),this._events=Object.create(null),this._eventsCount=0,this}if(t=n[e],typeof t==`function`)this.removeListener(e,t);else if(t!==void 0)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this};function m(e,t,n){var r=e._events;if(r===void 0)return[];var i=r[t];return i===void 0?[]:typeof i==`function`?n?[i.listener||i]:[i]:n?v(i):g(i,i.length)}s.prototype.listeners=function(e){return m(this,e,!0)},s.prototype.rawListeners=function(e){return m(this,e,!1)},s.listenerCount=function(e,t){return typeof e.listenerCount==`function`?e.listenerCount(t):h.call(e,t)},s.prototype.listenerCount=h;function h(e){var t=this._events;if(t!==void 0){var n=t[e];if(typeof n==`function`)return 1;if(n!==void 0)return n.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]};function g(e,t){for(var n=Array(t),r=0;r<t;++r)n[r]=e[r];return n}function _(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function v(e){for(var t=Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function y(e,t){return new Promise(function(n,r){function i(n){e.removeListener(t,a),r(n)}function a(){typeof e.removeListener==`function`&&e.removeListener(`error`,i),n([].slice.call(arguments))}x(e,t,a,{once:!0}),t!==`error`&&b(e,i,{once:!0})})}function b(e,t,n){typeof e.on==`function`&&x(e,`error`,t,n)}function x(e,t,n,r){if(typeof e.on==`function`)r.once?e.once(t,n):e.on(t,n);else if(typeof e.addEventListener==`function`)e.addEventListener(t,function i(a){r.once&&e.removeEventListener(t,i),n(a)});else throw TypeError(`The "emitter" argument must be of type EventEmitter. Received type `+typeof e)}})),E=e(r(),1),ue=le();function de(){let e=arguments[0];for(let t=1,n=arguments.length;t<n;t++)if(arguments[t])for(let n in arguments[t])e[n]=arguments[t][n];return e}var D=de;typeof Object.assign==`function`&&(D=Object.assign);function fe(e,t,n,r){let i=e._nodes.get(t),a=null;return i&&(a=r===`mixed`?i.out&&i.out[n]||i.undirected&&i.undirected[n]:r===`directed`?i.out&&i.out[n]:i.undirected&&i.undirected[n]),a}function pe(e){return typeof e==`object`&&!!e}function me(e){let t;for(t in e)return!1;return!0}function he(e,t,n){Object.defineProperty(e,t,{enumerable:!1,configurable:!1,writable:!0,value:n})}function ge(e,t,n){let r={enumerable:!0,configurable:!0};typeof n==`function`?r.get=n:(r.value=n,r.writable=!1),Object.defineProperty(e,t,r)}function _e(e){return!(!pe(e)||e.attributes&&!Array.isArray(e.attributes))}function ve(){let e=Math.floor(Math.random()*256)&255;return()=>e++}function ye(){let e=arguments,t=null,n=-1;return{[Symbol.iterator](){return this},next(){let r=null;do{if(t===null){if(n++,n>=e.length)return{done:!0};t=e[n][Symbol.iterator]()}if(r=t.next(),r.done)t=null;else break}while(1);return r}}}function be(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}var xe=class extends Error{constructor(e){super(),this.name=`GraphError`,this.message=e}},O=class e extends xe{constructor(t){super(t),this.name=`InvalidArgumentsGraphError`,typeof Error.captureStackTrace==`function`&&Error.captureStackTrace(this,e.prototype.constructor)}},k=class e extends xe{constructor(t){super(t),this.name=`NotFoundGraphError`,typeof Error.captureStackTrace==`function`&&Error.captureStackTrace(this,e.prototype.constructor)}},A=class e extends xe{constructor(t){super(t),this.name=`UsageGraphError`,typeof Error.captureStackTrace==`function`&&Error.captureStackTrace(this,e.prototype.constructor)}};function Se(e,t){this.key=e,this.attributes=t,this.clear()}Se.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}};function Ce(e,t){this.key=e,this.attributes=t,this.clear()}Ce.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function we(e,t){this.key=e,this.attributes=t,this.clear()}we.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function Te(e,t,n,r,i){this.key=t,this.attributes=i,this.undirected=e,this.source=n,this.target=r}Te.prototype.attach=function(){let e=`out`,t=`in`;this.undirected&&(e=t=`undirected`);let n=this.source.key,r=this.target.key;this.source[e][r]=this,this.undirected&&n===r||(this.target[t][n]=this)},Te.prototype.attachMulti=function(){let e=`out`,t=`in`,n=this.source.key,r=this.target.key;this.undirected&&(e=t=`undirected`);let i=this.source[e],a=i[r];a===void 0?(i[r]=this,this.undirected&&n===r||(this.target[t][n]=this)):(a.previous=this,this.next=a,i[r]=this,this.target[t][n]=this)},Te.prototype.detach=function(){let e=this.source.key,t=this.target.key,n=`out`,r=`in`;this.undirected&&(n=r=`undirected`),delete this.source[n][t],delete this.target[r][e]},Te.prototype.detachMulti=function(){let e=this.source.key,t=this.target.key,n=`out`,r=`in`;this.undirected&&(n=r=`undirected`),this.previous===void 0?this.next===void 0?(delete this.source[n][t],delete this.target[r][e]):(this.next.previous=void 0,this.source[n][t]=this.next,this.target[r][e]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};var Ee=0,De=1,Oe=2,ke=3;function Ae(e,t,n,r,i,a,o){let s,c,l,u;if(r=``+r,n===Ee){if(s=e._nodes.get(r),!s)throw new k(`Graph.${t}: could not find the "${r}" node in the graph.`);l=i,u=a}else if(n===ke){if(i=``+i,c=e._edges.get(i),!c)throw new k(`Graph.${t}: could not find the "${i}" edge in the graph.`);let n=c.source.key,d=c.target.key;if(r===n)s=c.target;else if(r===d)s=c.source;else throw new k(`Graph.${t}: the "${r}" node is not attached to the "${i}" edge (${n}, ${d}).`);l=a,u=o}else{if(c=e._edges.get(r),!c)throw new k(`Graph.${t}: could not find the "${r}" edge in the graph.`);s=n===De?c.source:c.target,l=i,u=a}return[s,l,u]}function je(e,t,n){e.prototype[t]=function(e,r,i){let[a,o]=Ae(this,t,n,e,r,i);return a.attributes[o]}}function Me(e,t,n){e.prototype[t]=function(e,r){let[i]=Ae(this,t,n,e,r);return i.attributes}}function Ne(e,t,n){e.prototype[t]=function(e,r,i){let[a,o]=Ae(this,t,n,e,r,i);return a.attributes.hasOwnProperty(o)}}function Pe(e,t,n){e.prototype[t]=function(e,r,i,a){let[o,s,c]=Ae(this,t,n,e,r,i,a);return o.attributes[s]=c,this.emit(`nodeAttributesUpdated`,{key:o.key,type:`set`,attributes:o.attributes,name:s}),this}}function Fe(e,t,n){e.prototype[t]=function(e,r,i,a){let[o,s,c]=Ae(this,t,n,e,r,i,a);if(typeof c!=`function`)throw new O(`Graph.${t}: updater should be a function.`);let l=o.attributes;return l[s]=c(l[s]),this.emit(`nodeAttributesUpdated`,{key:o.key,type:`set`,attributes:o.attributes,name:s}),this}}function Ie(e,t,n){e.prototype[t]=function(e,r,i){let[a,o]=Ae(this,t,n,e,r,i);return delete a.attributes[o],this.emit(`nodeAttributesUpdated`,{key:a.key,type:`remove`,attributes:a.attributes,name:o}),this}}function Le(e,t,n){e.prototype[t]=function(e,r,i){let[a,o]=Ae(this,t,n,e,r,i);if(!pe(o))throw new O(`Graph.${t}: provided attributes are not a plain object.`);return a.attributes=o,this.emit(`nodeAttributesUpdated`,{key:a.key,type:`replace`,attributes:a.attributes}),this}}function Re(e,t,n){e.prototype[t]=function(e,r,i){let[a,o]=Ae(this,t,n,e,r,i);if(!pe(o))throw new O(`Graph.${t}: provided attributes are not a plain object.`);return D(a.attributes,o),this.emit(`nodeAttributesUpdated`,{key:a.key,type:`merge`,attributes:a.attributes,data:o}),this}}function ze(e,t,n){e.prototype[t]=function(e,r,i){let[a,o]=Ae(this,t,n,e,r,i);if(typeof o!=`function`)throw new O(`Graph.${t}: provided updater is not a function.`);return a.attributes=o(a.attributes),this.emit(`nodeAttributesUpdated`,{key:a.key,type:`update`,attributes:a.attributes}),this}}var Be=[{name:e=>`get${e}Attribute`,attacher:je},{name:e=>`get${e}Attributes`,attacher:Me},{name:e=>`has${e}Attribute`,attacher:Ne},{name:e=>`set${e}Attribute`,attacher:Pe},{name:e=>`update${e}Attribute`,attacher:Fe},{name:e=>`remove${e}Attribute`,attacher:Ie},{name:e=>`replace${e}Attributes`,attacher:Le},{name:e=>`merge${e}Attributes`,attacher:Re},{name:e=>`update${e}Attributes`,attacher:ze}];function Ve(e){Be.forEach(function({name:t,attacher:n}){n(e,t(`Node`),Ee),n(e,t(`Source`),De),n(e,t(`Target`),Oe),n(e,t(`Opposite`),ke)})}function He(e,t,n){e.prototype[t]=function(e,r){let i;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new A(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new A(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=``+e,o=``+r;if(r=arguments[2],i=fe(this,a,o,n),!i)throw new k(`Graph.${t}: could not find an edge for the given path ("${a}" - "${o}").`)}else{if(n!==`mixed`)throw new A(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,i=this._edges.get(e),!i)throw new k(`Graph.${t}: could not find the "${e}" edge in the graph.`)}return i.attributes[r]}}function Ue(e,t,n){e.prototype[t]=function(e){let r;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new A(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new A(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let i=``+e,a=``+arguments[1];if(r=fe(this,i,a,n),!r)throw new k(`Graph.${t}: could not find an edge for the given path ("${i}" - "${a}").`)}else{if(n!==`mixed`)throw new A(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,r=this._edges.get(e),!r)throw new k(`Graph.${t}: could not find the "${e}" edge in the graph.`)}return r.attributes}}function We(e,t,n){e.prototype[t]=function(e,r){let i;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new A(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new A(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=``+e,o=``+r;if(r=arguments[2],i=fe(this,a,o,n),!i)throw new k(`Graph.${t}: could not find an edge for the given path ("${a}" - "${o}").`)}else{if(n!==`mixed`)throw new A(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,i=this._edges.get(e),!i)throw new k(`Graph.${t}: could not find the "${e}" edge in the graph.`)}return i.attributes.hasOwnProperty(r)}}function Ge(e,t,n){e.prototype[t]=function(e,r,i){let a;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new A(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new A(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let o=``+e,s=``+r;if(r=arguments[2],i=arguments[3],a=fe(this,o,s,n),!a)throw new k(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!==`mixed`)throw new A(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,a=this._edges.get(e),!a)throw new k(`Graph.${t}: could not find the "${e}" edge in the graph.`)}return a.attributes[r]=i,this.emit(`edgeAttributesUpdated`,{key:a.key,type:`set`,attributes:a.attributes,name:r}),this}}function Ke(e,t,n){e.prototype[t]=function(e,r,i){let a;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new A(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new A(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let o=``+e,s=``+r;if(r=arguments[2],i=arguments[3],a=fe(this,o,s,n),!a)throw new k(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!==`mixed`)throw new A(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,a=this._edges.get(e),!a)throw new k(`Graph.${t}: could not find the "${e}" edge in the graph.`)}if(typeof i!=`function`)throw new O(`Graph.${t}: updater should be a function.`);return a.attributes[r]=i(a.attributes[r]),this.emit(`edgeAttributesUpdated`,{key:a.key,type:`set`,attributes:a.attributes,name:r}),this}}function qe(e,t,n){e.prototype[t]=function(e,r){let i;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new A(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new A(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=``+e,o=``+r;if(r=arguments[2],i=fe(this,a,o,n),!i)throw new k(`Graph.${t}: could not find an edge for the given path ("${a}" - "${o}").`)}else{if(n!==`mixed`)throw new A(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,i=this._edges.get(e),!i)throw new k(`Graph.${t}: could not find the "${e}" edge in the graph.`)}return delete i.attributes[r],this.emit(`edgeAttributesUpdated`,{key:i.key,type:`remove`,attributes:i.attributes,name:r}),this}}function Je(e,t,n){e.prototype[t]=function(e,r){let i;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new A(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new A(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=``+e,o=``+r;if(r=arguments[2],i=fe(this,a,o,n),!i)throw new k(`Graph.${t}: could not find an edge for the given path ("${a}" - "${o}").`)}else{if(n!==`mixed`)throw new A(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,i=this._edges.get(e),!i)throw new k(`Graph.${t}: could not find the "${e}" edge in the graph.`)}if(!pe(r))throw new O(`Graph.${t}: provided attributes are not a plain object.`);return i.attributes=r,this.emit(`edgeAttributesUpdated`,{key:i.key,type:`replace`,attributes:i.attributes}),this}}function Ye(e,t,n){e.prototype[t]=function(e,r){let i;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new A(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new A(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=``+e,o=``+r;if(r=arguments[2],i=fe(this,a,o,n),!i)throw new k(`Graph.${t}: could not find an edge for the given path ("${a}" - "${o}").`)}else{if(n!==`mixed`)throw new A(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,i=this._edges.get(e),!i)throw new k(`Graph.${t}: could not find the "${e}" edge in the graph.`)}if(!pe(r))throw new O(`Graph.${t}: provided attributes are not a plain object.`);return D(i.attributes,r),this.emit(`edgeAttributesUpdated`,{key:i.key,type:`merge`,attributes:i.attributes,data:r}),this}}function Xe(e,t,n){e.prototype[t]=function(e,r){let i;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new A(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new A(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=``+e,o=``+r;if(r=arguments[2],i=fe(this,a,o,n),!i)throw new k(`Graph.${t}: could not find an edge for the given path ("${a}" - "${o}").`)}else{if(n!==`mixed`)throw new A(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,i=this._edges.get(e),!i)throw new k(`Graph.${t}: could not find the "${e}" edge in the graph.`)}if(typeof r!=`function`)throw new O(`Graph.${t}: provided updater is not a function.`);return i.attributes=r(i.attributes),this.emit(`edgeAttributesUpdated`,{key:i.key,type:`update`,attributes:i.attributes}),this}}var Ze=[{name:e=>`get${e}Attribute`,attacher:He},{name:e=>`get${e}Attributes`,attacher:Ue},{name:e=>`has${e}Attribute`,attacher:We},{name:e=>`set${e}Attribute`,attacher:Ge},{name:e=>`update${e}Attribute`,attacher:Ke},{name:e=>`remove${e}Attribute`,attacher:qe},{name:e=>`replace${e}Attributes`,attacher:Je},{name:e=>`merge${e}Attributes`,attacher:Ye},{name:e=>`update${e}Attributes`,attacher:Xe}];function Qe(e){Ze.forEach(function({name:t,attacher:n}){n(e,t(`Edge`),`mixed`),n(e,t(`DirectedEdge`),`directed`),n(e,t(`UndirectedEdge`),`undirected`)})}var $e=[{name:`edges`,type:`mixed`},{name:`inEdges`,type:`directed`,direction:`in`},{name:`outEdges`,type:`directed`,direction:`out`},{name:`inboundEdges`,type:`mixed`,direction:`in`},{name:`outboundEdges`,type:`mixed`,direction:`out`},{name:`directedEdges`,type:`directed`},{name:`undirectedEdges`,type:`undirected`}];function et(e,t,n,r){let i=!1;for(let a in t){if(a===r)continue;let o=t[a];if(i=n(o.key,o.attributes,o.source.key,o.target.key,o.source.attributes,o.target.attributes,o.undirected),e&&i)return o.key}}function tt(e,t,n,r){let i,a,o,s=!1;for(let c in t)if(c!==r){i=t[c];do{if(a=i.source,o=i.target,s=n(i.key,i.attributes,a.key,o.key,a.attributes,o.attributes,i.undirected),e&&s)return i.key;i=i.next}while(i!==void 0)}}function nt(e,t){let n=Object.keys(e),r=n.length,i,a=0;return{[Symbol.iterator](){return this},next(){do if(i)i=i.next;else{if(a>=r)return{done:!0};let o=n[a++];if(o===t){i=void 0;continue}i=e[o]}while(!i);return{done:!1,value:{edge:i.key,attributes:i.attributes,source:i.source.key,target:i.target.key,sourceAttributes:i.source.attributes,targetAttributes:i.target.attributes,undirected:i.undirected}}}}}function rt(e,t,n,r){let i=t[n];if(!i)return;let a=i.source,o=i.target;if(r(i.key,i.attributes,a.key,o.key,a.attributes,o.attributes,i.undirected)&&e)return i.key}function it(e,t,n,r){let i=t[n];if(!i)return;let a=!1;do{if(a=r(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),e&&a)return i.key;i=i.next}while(i!==void 0)}function at(e,t){let n=e[t];if(n.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!n)return{done:!0};let e={edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected};return n=n.next,{done:!1,value:e}}};let r=!1;return{[Symbol.iterator](){return this},next(){return r===!0?{done:!0}:(r=!0,{done:!1,value:{edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected}})}}}function ot(e,t){if(e.size===0)return[];if(t===`mixed`||t===e.type)return Array.from(e._edges.keys());let n=t===`undirected`?e.undirectedSize:e.directedSize,r=Array(n),i=t===`undirected`,a=e._edges.values(),o=0,s,c;for(;s=a.next(),s.done!==!0;)c=s.value,c.undirected===i&&(r[o++]=c.key);return r}function st(e,t,n,r){if(t.size===0)return;let i=n!==`mixed`&&n!==t.type,a=n===`undirected`,o,s,c=!1,l=t._edges.values();for(;o=l.next(),o.done!==!0;){if(s=o.value,i&&s.undirected!==a)continue;let{key:t,attributes:n,source:l,target:u}=s;if(c=r(t,n,l.key,u.key,l.attributes,u.attributes,s.undirected),e&&c)return t}}function ct(e,t){if(e.size===0)return be();let n=t!==`mixed`&&t!==e.type,r=t===`undirected`,i=e._edges.values();return{[Symbol.iterator](){return this},next(){let e,t;for(;;){if(e=i.next(),e.done)return e;if(t=e.value,!(n&&t.undirected!==r))break}return{value:{edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected},done:!1}}}}function lt(e,t,n,r,i,a){let o=t?tt:et,s;if(n!==`undirected`&&(r!==`out`&&(s=o(e,i.in,a),e&&s)||r!==`in`&&(s=o(e,i.out,a,r?void 0:i.key),e&&s))||n!==`directed`&&(s=o(e,i.undirected,a),e&&s))return s}function ut(e,t,n,r){let i=[];return lt(!1,e,t,n,r,function(e){i.push(e)}),i}function dt(e,t,n){let r=be();return e!==`undirected`&&(t!==`out`&&n.in!==void 0&&(r=ye(r,nt(n.in))),t!==`in`&&n.out!==void 0&&(r=ye(r,nt(n.out,t?void 0:n.key)))),e!==`directed`&&n.undirected!==void 0&&(r=ye(r,nt(n.undirected))),r}function ft(e,t,n,r,i,a,o){let s=n?it:rt,c;if(t!==`undirected`&&(i.in!==void 0&&r!==`out`&&(c=s(e,i.in,a,o),e&&c)||i.out!==void 0&&r!==`in`&&(r||i.key!==a)&&(c=s(e,i.out,a,o),e&&c))||t!==`directed`&&i.undirected!==void 0&&(c=s(e,i.undirected,a,o),e&&c))return c}function pt(e,t,n,r,i){let a=[];return ft(!1,e,t,n,r,i,function(e){a.push(e)}),a}function mt(e,t,n,r){let i=be();return e!==`undirected`&&(n.in!==void 0&&t!==`out`&&r in n.in&&(i=ye(i,at(n.in,r))),n.out!==void 0&&t!==`in`&&r in n.out&&(t||n.key!==r)&&(i=ye(i,at(n.out,r)))),e!==`directed`&&n.undirected!==void 0&&r in n.undirected&&(i=ye(i,at(n.undirected,r))),i}function ht(e,t){let{name:n,type:r,direction:i}=t;e.prototype[n]=function(e,t){if(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)return[];if(!arguments.length)return ot(this,r);if(arguments.length===1){e=``+e;let t=this._nodes.get(e);if(t===void 0)throw new k(`Graph.${n}: could not find the "${e}" node in the graph.`);return ut(this.multi,r===`mixed`?this.type:r,i,t)}if(arguments.length===2){e=``+e,t=``+t;let a=this._nodes.get(e);if(!a)throw new k(`Graph.${n}: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new k(`Graph.${n}: could not find the "${t}" target node in the graph.`);return pt(r,this.multi,i,a,t)}throw new O(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function gt(e,t){let{name:n,type:r,direction:i}=t,a=`forEach`+n[0].toUpperCase()+n.slice(1,-1);e.prototype[a]=function(e,t,n){if(r===`mixed`||this.type===`mixed`||r===this.type){if(arguments.length===1)return n=e,st(!1,this,r,n);if(arguments.length===2){e=``+e,n=t;let o=this._nodes.get(e);if(o===void 0)throw new k(`Graph.${a}: could not find the "${e}" node in the graph.`);return lt(!1,this.multi,r===`mixed`?this.type:r,i,o,n)}if(arguments.length===3){e=``+e,t=``+t;let o=this._nodes.get(e);if(!o)throw new k(`Graph.${a}: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new k(`Graph.${a}: could not find the "${t}" target node in the graph.`);return ft(!1,r,this.multi,i,o,t,n)}throw new O(`Graph.${a}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};let o=`map`+n[0].toUpperCase()+n.slice(1);e.prototype[o]=function(){let e=Array.prototype.slice.call(arguments),t=e.pop(),n;if(e.length===0){let i=0;r!==`directed`&&(i+=this.undirectedSize),r!==`undirected`&&(i+=this.directedSize),n=Array(i);let a=0;e.push((e,r,i,o,s,c,l)=>{n[a++]=t(e,r,i,o,s,c,l)})}else n=[],e.push((e,r,i,a,o,s,c)=>{n.push(t(e,r,i,a,o,s,c))});return this[a].apply(this,e),n};let s=`filter`+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(){let e=Array.prototype.slice.call(arguments),t=e.pop(),n=[];return e.push((e,r,i,a,o,s,c)=>{t(e,r,i,a,o,s,c)&&n.push(e)}),this[a].apply(this,e),n};let c=`reduce`+n[0].toUpperCase()+n.slice(1);e.prototype[c]=function(){let e=Array.prototype.slice.call(arguments);if(e.length<2||e.length>4)throw new O(`Graph.${c}: invalid number of arguments (expecting 2, 3 or 4 and got ${e.length}).`);if(typeof e[e.length-1]==`function`&&typeof e[e.length-2]!=`function`)throw new O(`Graph.${c}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let t,n;e.length===2?(t=e[0],n=e[1],e=[]):e.length===3?(t=e[1],n=e[2],e=[e[0]]):e.length===4&&(t=e[2],n=e[3],e=[e[0],e[1]]);let r=n;return e.push((e,n,i,a,o,s,c)=>{r=t(r,e,n,i,a,o,s,c)}),this[a].apply(this,e),r}}function _t(e,t){let{name:n,type:r,direction:i}=t,a=`find`+n[0].toUpperCase()+n.slice(1,-1);e.prototype[a]=function(e,t,n){if(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)return!1;if(arguments.length===1)return n=e,st(!0,this,r,n);if(arguments.length===2){e=``+e,n=t;let o=this._nodes.get(e);if(o===void 0)throw new k(`Graph.${a}: could not find the "${e}" node in the graph.`);return lt(!0,this.multi,r===`mixed`?this.type:r,i,o,n)}if(arguments.length===3){e=``+e,t=``+t;let o=this._nodes.get(e);if(!o)throw new k(`Graph.${a}: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new k(`Graph.${a}: could not find the "${t}" target node in the graph.`);return ft(!0,r,this.multi,i,o,t,n)}throw new O(`Graph.${a}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};let o=`some`+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(){let e=Array.prototype.slice.call(arguments),t=e.pop();return e.push((e,n,r,i,a,o,s)=>t(e,n,r,i,a,o,s)),!!this[a].apply(this,e)};let s=`every`+n[0].toUpperCase()+n.slice(1,-1);e.prototype[s]=function(){let e=Array.prototype.slice.call(arguments),t=e.pop();return e.push((e,n,r,i,a,o,s)=>!t(e,n,r,i,a,o,s)),!this[a].apply(this,e)}}function vt(e,t){let{name:n,type:r,direction:i}=t,a=n.slice(0,-1)+`Entries`;e.prototype[a]=function(e,t){if(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)return be();if(!arguments.length)return ct(this,r);if(arguments.length===1){e=``+e;let t=this._nodes.get(e);if(!t)throw new k(`Graph.${a}: could not find the "${e}" node in the graph.`);return dt(r,i,t)}if(arguments.length===2){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new k(`Graph.${a}: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new k(`Graph.${a}: could not find the "${t}" target node in the graph.`);return mt(r,i,n,t)}throw new O(`Graph.${a}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function yt(e){$e.forEach(t=>{ht(e,t),gt(e,t),_t(e,t),vt(e,t)})}var bt=[{name:`neighbors`,type:`mixed`},{name:`inNeighbors`,type:`directed`,direction:`in`},{name:`outNeighbors`,type:`directed`,direction:`out`},{name:`inboundNeighbors`,type:`mixed`,direction:`in`},{name:`outboundNeighbors`,type:`mixed`,direction:`out`},{name:`directedNeighbors`,type:`directed`},{name:`undirectedNeighbors`,type:`undirected`}];function xt(){this.A=null,this.B=null}xt.prototype.wrap=function(e){this.A===null?this.A=e:this.B===null&&(this.B=e)},xt.prototype.has=function(e){return this.A!==null&&e in this.A||this.B!==null&&e in this.B};function St(e,t,n,r,i){for(let a in r){let o=r[a],s=o.source,c=o.target,l=s===n?c:s;if(t&&t.has(l.key))continue;let u=i(l.key,l.attributes);if(e&&u)return l.key}}function Ct(e,t,n,r,i){if(t!==`mixed`){if(t===`undirected`)return St(e,null,r,r.undirected,i);if(typeof n==`string`)return St(e,null,r,r[n],i)}let a=new xt,o;if(t!==`undirected`){if(n!==`out`){if(o=St(e,null,r,r.in,i),e&&o)return o;a.wrap(r.in)}if(n!==`in`){if(o=St(e,a,r,r.out,i),e&&o)return o;a.wrap(r.out)}}if(t!==`directed`&&(o=St(e,a,r,r.undirected,i),e&&o))return o}function wt(e,t,n){if(e!==`mixed`){if(e===`undirected`)return Object.keys(n.undirected);if(typeof t==`string`)return Object.keys(n[t])}let r=[];return Ct(!1,e,t,n,function(e){r.push(e)}),r}function Tt(e,t,n){let r=Object.keys(n),i=r.length,a=0;return{[Symbol.iterator](){return this},next(){let o=null;do{if(a>=i)return e&&e.wrap(n),{done:!0};let s=n[r[a++]],c=s.source,l=s.target;o=c===t?l:c,e&&e.has(o.key)&&(o=null)}while(o===null);return{done:!1,value:{neighbor:o.key,attributes:o.attributes}}}}}function Et(e,t,n){if(e!==`mixed`){if(e===`undirected`)return Tt(null,n,n.undirected);if(typeof t==`string`)return Tt(null,n,n[t])}let r=be(),i=new xt;return e!==`undirected`&&(t!==`out`&&(r=ye(r,Tt(i,n,n.in))),t!==`in`&&(r=ye(r,Tt(i,n,n.out)))),e!==`directed`&&(r=ye(r,Tt(i,n,n.undirected))),r}function Dt(e,t){let{name:n,type:r,direction:i}=t;e.prototype[n]=function(e){if(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)return[];e=``+e;let t=this._nodes.get(e);if(t===void 0)throw new k(`Graph.${n}: could not find the "${e}" node in the graph.`);return wt(r===`mixed`?this.type:r,i,t)}}function Ot(e,t){let{name:n,type:r,direction:i}=t,a=`forEach`+n[0].toUpperCase()+n.slice(1,-1);e.prototype[a]=function(e,t){if(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)return;e=``+e;let n=this._nodes.get(e);if(n===void 0)throw new k(`Graph.${a}: could not find the "${e}" node in the graph.`);Ct(!1,r===`mixed`?this.type:r,i,n,t)};let o=`map`+n[0].toUpperCase()+n.slice(1);e.prototype[o]=function(e,t){let n=[];return this[a](e,(e,r)=>{n.push(t(e,r))}),n};let s=`filter`+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(e,t){let n=[];return this[a](e,(e,r)=>{t(e,r)&&n.push(e)}),n};let c=`reduce`+n[0].toUpperCase()+n.slice(1);e.prototype[c]=function(e,t,n){if(arguments.length<3)throw new O(`Graph.${c}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let r=n;return this[a](e,(e,n)=>{r=t(r,e,n)}),r}}function kt(e,t){let{name:n,type:r,direction:i}=t,a=n[0].toUpperCase()+n.slice(1,-1),o=`find`+a;e.prototype[o]=function(e,t){if(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)return;e=``+e;let n=this._nodes.get(e);if(n===void 0)throw new k(`Graph.${o}: could not find the "${e}" node in the graph.`);return Ct(!0,r===`mixed`?this.type:r,i,n,t)};let s=`some`+a;e.prototype[s]=function(e,t){return!!this[o](e,t)};let c=`every`+a;e.prototype[c]=function(e,t){return!this[o](e,(e,n)=>!t(e,n))}}function At(e,t){let{name:n,type:r,direction:i}=t,a=n.slice(0,-1)+`Entries`;e.prototype[a]=function(e){if(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)return be();e=``+e;let t=this._nodes.get(e);if(t===void 0)throw new k(`Graph.${a}: could not find the "${e}" node in the graph.`);return Et(r===`mixed`?this.type:r,i,t)}}function jt(e){bt.forEach(t=>{Dt(e,t),Ot(e,t),kt(e,t),At(e,t)})}function Mt(e,t,n,r,i){let a=r._nodes.values(),o=r.type,s,c,l,u,d,f,p;for(;s=a.next(),s.done!==!0;){let r=!1;if(c=s.value,o!==`undirected`)for(l in u=c.out,u){d=u[l];do{if(f=d.target,r=!0,p=i(c.key,f.key,c.attributes,f.attributes,d.key,d.attributes,d.undirected),e&&p)return d;d=d.next}while(d)}if(o!==`directed`){for(l in u=c.undirected,u)if(!(t&&c.key>l)){d=u[l];do{if(f=d.target,f.key!==l&&(f=d.source),r=!0,p=i(c.key,f.key,c.attributes,f.attributes,d.key,d.attributes,d.undirected),e&&p)return d;d=d.next}while(d)}}if(n&&!r&&(p=i(c.key,null,c.attributes,null,null,null,null),e&&p))return null}}function Nt(e,t){let n={key:e};return me(t.attributes)||(n.attributes=D({},t.attributes)),n}function Pt(e,t,n){let r={key:t,source:n.source.key,target:n.target.key};return me(n.attributes)||(r.attributes=D({},n.attributes)),e===`mixed`&&n.undirected&&(r.undirected=!0),r}function Ft(e){if(!pe(e))throw new O(`Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.`);if(!(`key`in e))throw new O(`Graph.import: serialized node is missing its key.`);if(`attributes`in e&&(!pe(e.attributes)||e.attributes===null))throw new O(`Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.`)}function It(e){if(!pe(e))throw new O(`Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.`);if(!(`source`in e))throw new O(`Graph.import: serialized edge is missing its source.`);if(!(`target`in e))throw new O(`Graph.import: serialized edge is missing its target.`);if(`attributes`in e&&(!pe(e.attributes)||e.attributes===null))throw new O(`Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.`);if(`undirected`in e&&typeof e.undirected!=`boolean`)throw new O(`Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.`)}var Lt=ve(),Rt=new Set([`directed`,`undirected`,`mixed`]),zt=new Set([`domain`,`_events`,`_eventsCount`,`_maxListeners`]),Bt=[{name:e=>`${e}Edge`,generateKey:!0},{name:e=>`${e}DirectedEdge`,generateKey:!0,type:`directed`},{name:e=>`${e}UndirectedEdge`,generateKey:!0,type:`undirected`},{name:e=>`${e}EdgeWithKey`},{name:e=>`${e}DirectedEdgeWithKey`,type:`directed`},{name:e=>`${e}UndirectedEdgeWithKey`,type:`undirected`}],Vt={allowSelfLoops:!0,multi:!1,type:`mixed`};function Ht(e,t,n){if(n&&!pe(n))throw new O(`Graph.addNode: invalid attributes. Expecting an object but got "${n}"`);if(t=``+t,n||={},e._nodes.has(t))throw new A(`Graph.addNode: the "${t}" node already exist in the graph.`);let r=new e.NodeDataClass(t,n);return e._nodes.set(t,r),e.emit(`nodeAdded`,{key:t,attributes:n}),r}function Ut(e,t,n){let r=new e.NodeDataClass(t,n);return e._nodes.set(t,r),e.emit(`nodeAdded`,{key:t,attributes:n}),r}function Wt(e,t,n,r,i,a,o,s){if(!r&&e.type===`undirected`)throw new A(`Graph.${t}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(r&&e.type===`directed`)throw new A(`Graph.${t}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(s&&!pe(s))throw new O(`Graph.${t}: invalid attributes. Expecting an object but got "${s}"`);if(a=``+a,o=``+o,s||={},!e.allowSelfLoops&&a===o)throw new A(`Graph.${t}: source & target are the same ("${a}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let c=e._nodes.get(a),l=e._nodes.get(o);if(!c)throw new k(`Graph.${t}: source node "${a}" not found.`);if(!l)throw new k(`Graph.${t}: target node "${o}" not found.`);let u={key:null,undirected:r,source:a,target:o,attributes:s};if(n)i=e._edgeKeyGenerator();else if(i=``+i,e._edges.has(i))throw new A(`Graph.${t}: the "${i}" edge already exists in the graph.`);if(!e.multi&&(r?c.undirected[o]!==void 0:c.out[o]!==void 0))throw new A(`Graph.${t}: an edge linking "${a}" to "${o}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);let d=new Te(r,i,c,l,s);e._edges.set(i,d);let f=a===o;return r?(c.undirectedDegree++,l.undirectedDegree++,f&&(c.undirectedLoops++,e._undirectedSelfLoopCount++)):(c.outDegree++,l.inDegree++,f&&(c.directedLoops++,e._directedSelfLoopCount++)),e.multi?d.attachMulti():d.attach(),r?e._undirectedSize++:e._directedSize++,u.key=i,e.emit(`edgeAdded`,u),i}function Gt(e,t,n,r,i,a,o,s,c){if(!r&&e.type===`undirected`)throw new A(`Graph.${t}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(r&&e.type===`directed`)throw new A(`Graph.${t}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(s){if(c){if(typeof s!=`function`)throw new O(`Graph.${t}: invalid updater function. Expecting a function but got "${s}"`)}else if(!pe(s))throw new O(`Graph.${t}: invalid attributes. Expecting an object but got "${s}"`)}a=``+a,o=``+o;let l;if(c&&(l=s,s=void 0),!e.allowSelfLoops&&a===o)throw new A(`Graph.${t}: source & target are the same ("${a}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let u=e._nodes.get(a),d=e._nodes.get(o),f,p;if(!n&&(f=e._edges.get(i),f)){if((f.source.key!==a||f.target.key!==o)&&(!r||f.source.key!==o||f.target.key!==a))throw new A(`Graph.${t}: inconsistency detected when attempting to merge the "${i}" edge with "${a}" source & "${o}" target vs. ("${f.source.key}", "${f.target.key}").`);p=f}if(!p&&!e.multi&&u&&(p=r?u.undirected[o]:u.out[o]),p){let t=[p.key,!1,!1,!1];if(c?!l:!s)return t;if(c){let t=p.attributes;p.attributes=l(t),e.emit(`edgeAttributesUpdated`,{type:`replace`,key:p.key,attributes:p.attributes})}else D(p.attributes,s),e.emit(`edgeAttributesUpdated`,{type:`merge`,key:p.key,attributes:p.attributes,data:s});return t}s||={},c&&l&&(s=l(s));let m={key:null,undirected:r,source:a,target:o,attributes:s};if(n)i=e._edgeKeyGenerator();else if(i=``+i,e._edges.has(i))throw new A(`Graph.${t}: the "${i}" edge already exists in the graph.`);let h=!1,g=!1;u||(u=Ut(e,a,{}),h=!0,a===o&&(d=u,g=!0)),d||(d=Ut(e,o,{}),g=!0),f=new Te(r,i,u,d,s),e._edges.set(i,f);let _=a===o;return r?(u.undirectedDegree++,d.undirectedDegree++,_&&(u.undirectedLoops++,e._undirectedSelfLoopCount++)):(u.outDegree++,d.inDegree++,_&&(u.directedLoops++,e._directedSelfLoopCount++)),e.multi?f.attachMulti():f.attach(),r?e._undirectedSize++:e._directedSize++,m.key=i,e.emit(`edgeAdded`,m),[i,!0,h,g]}function Kt(e,t){e._edges.delete(t.key);let{source:n,target:r,attributes:i}=t,a=t.undirected,o=n===r;a?(n.undirectedDegree--,r.undirectedDegree--,o&&(n.undirectedLoops--,e._undirectedSelfLoopCount--)):(n.outDegree--,r.inDegree--,o&&(n.directedLoops--,e._directedSelfLoopCount--)),e.multi?t.detachMulti():t.detach(),a?e._undirectedSize--:e._directedSize--,e.emit(`edgeDropped`,{key:t.key,attributes:i,source:n.key,target:r.key,undirected:a})}var j=class e extends ue.EventEmitter{constructor(e){if(super(),e=D({},Vt,e),typeof e.multi!=`boolean`)throw new O(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${e.multi}".`);if(!Rt.has(e.type))throw new O(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${e.type}".`);if(typeof e.allowSelfLoops!=`boolean`)throw new O(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${e.allowSelfLoops}".`);let t=e.type===`mixed`?Se:e.type===`directed`?Ce:we;he(this,`NodeDataClass`,t);let n=`geid_`+Lt()+`_`,r=0;he(this,`_attributes`,{}),he(this,`_nodes`,new Map),he(this,`_edges`,new Map),he(this,`_directedSize`,0),he(this,`_undirectedSize`,0),he(this,`_directedSelfLoopCount`,0),he(this,`_undirectedSelfLoopCount`,0),he(this,`_edgeKeyGenerator`,()=>{let e;do e=n+r++;while(this._edges.has(e));return e}),he(this,`_options`,e),zt.forEach(e=>he(this,e,this[e])),ge(this,`order`,()=>this._nodes.size),ge(this,`size`,()=>this._edges.size),ge(this,`directedSize`,()=>this._directedSize),ge(this,`undirectedSize`,()=>this._undirectedSize),ge(this,`selfLoopCount`,()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),ge(this,`directedSelfLoopCount`,()=>this._directedSelfLoopCount),ge(this,`undirectedSelfLoopCount`,()=>this._undirectedSelfLoopCount),ge(this,`multi`,this._options.multi),ge(this,`type`,this._options.type),ge(this,`allowSelfLoops`,this._options.allowSelfLoops),ge(this,`implementation`,()=>`graphology`)}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(e){return this._nodes.has(``+e)}hasDirectedEdge(e,t){if(this.type===`undirected`)return!1;if(arguments.length===1){let t=``+e,n=this._edges.get(t);return!!n&&!n.undirected}if(arguments.length===2){e=``+e,t=``+t;let n=this._nodes.get(e);return n?n.out.hasOwnProperty(t):!1}throw new O(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasUndirectedEdge(e,t){if(this.type===`directed`)return!1;if(arguments.length===1){let t=``+e,n=this._edges.get(t);return!!n&&n.undirected}if(arguments.length===2){e=``+e,t=``+t;let n=this._nodes.get(e);return n?n.undirected.hasOwnProperty(t):!1}throw new O(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasEdge(e,t){if(arguments.length===1){let t=``+e;return this._edges.has(t)}if(arguments.length===2){e=``+e,t=``+t;let n=this._nodes.get(e);return n?n.out!==void 0&&n.out.hasOwnProperty(t)||n.undirected!==void 0&&n.undirected.hasOwnProperty(t):!1}throw new O(`Graph.hasEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}directedEdge(e,t){if(this.type===`undirected`)return;if(e=``+e,t=``+t,this.multi)throw new A(`Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.`);let n=this._nodes.get(e);if(!n)throw new k(`Graph.directedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new k(`Graph.directedEdge: could not find the "${t}" target node in the graph.`);let r=n.out&&n.out[t]||void 0;if(r)return r.key}undirectedEdge(e,t){if(this.type===`directed`)return;if(e=``+e,t=``+t,this.multi)throw new A(`Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.`);let n=this._nodes.get(e);if(!n)throw new k(`Graph.undirectedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new k(`Graph.undirectedEdge: could not find the "${t}" target node in the graph.`);let r=n.undirected&&n.undirected[t]||void 0;if(r)return r.key}edge(e,t){if(this.multi)throw new A(`Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.`);e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new k(`Graph.edge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new k(`Graph.edge: could not find the "${t}" target node in the graph.`);let r=n.out&&n.out[t]||n.undirected&&n.undirected[t]||void 0;if(r)return r.key}areDirectedNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new k(`Graph.areDirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type===`undirected`?!1:t in n.in||t in n.out}areOutNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new k(`Graph.areOutNeighbors: could not find the "${e}" node in the graph.`);return this.type!==`undirected`&&t in n.out}areInNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new k(`Graph.areInNeighbors: could not find the "${e}" node in the graph.`);return this.type!==`undirected`&&t in n.in}areUndirectedNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new k(`Graph.areUndirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type!==`directed`&&t in n.undirected}areNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new k(`Graph.areNeighbors: could not find the "${e}" node in the graph.`);return this.type!==`undirected`&&(t in n.in||t in n.out)||this.type!==`directed`&&t in n.undirected}areInboundNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new k(`Graph.areInboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!==`undirected`&&t in n.in||this.type!==`directed`&&t in n.undirected}areOutboundNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new k(`Graph.areOutboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!==`undirected`&&t in n.out||this.type!==`directed`&&t in n.undirected}inDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new k(`Graph.inDegree: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.inDegree}outDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new k(`Graph.outDegree: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.outDegree}directedDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new k(`Graph.directedDegree: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.inDegree+t.outDegree}undirectedDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new k(`Graph.undirectedDegree: could not find the "${e}" node in the graph.`);return this.type===`directed`?0:t.undirectedDegree}inboundDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new k(`Graph.inboundDegree: could not find the "${e}" node in the graph.`);let n=0;return this.type!==`directed`&&(n+=t.undirectedDegree),this.type!==`undirected`&&(n+=t.inDegree),n}outboundDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new k(`Graph.outboundDegree: could not find the "${e}" node in the graph.`);let n=0;return this.type!==`directed`&&(n+=t.undirectedDegree),this.type!==`undirected`&&(n+=t.outDegree),n}degree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new k(`Graph.degree: could not find the "${e}" node in the graph.`);let n=0;return this.type!==`directed`&&(n+=t.undirectedDegree),this.type!==`undirected`&&(n+=t.inDegree+t.outDegree),n}inDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new k(`Graph.inDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.inDegree-t.directedLoops}outDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new k(`Graph.outDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.outDegree-t.directedLoops}directedDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new k(`Graph.directedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.inDegree+t.outDegree-t.directedLoops*2}undirectedDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new k(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type===`directed`?0:t.undirectedDegree-t.undirectedLoops*2}inboundDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new k(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,r=0;return this.type!==`directed`&&(n+=t.undirectedDegree,r+=t.undirectedLoops*2),this.type!==`undirected`&&(n+=t.inDegree,r+=t.directedLoops),n-r}outboundDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new k(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,r=0;return this.type!==`directed`&&(n+=t.undirectedDegree,r+=t.undirectedLoops*2),this.type!==`undirected`&&(n+=t.outDegree,r+=t.directedLoops),n-r}degreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new k(`Graph.degreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,r=0;return this.type!==`directed`&&(n+=t.undirectedDegree,r+=t.undirectedLoops*2),this.type!==`undirected`&&(n+=t.inDegree+t.outDegree,r+=t.directedLoops*2),n-r}source(e){e=``+e;let t=this._edges.get(e);if(!t)throw new k(`Graph.source: could not find the "${e}" edge in the graph.`);return t.source.key}target(e){e=``+e;let t=this._edges.get(e);if(!t)throw new k(`Graph.target: could not find the "${e}" edge in the graph.`);return t.target.key}extremities(e){e=``+e;let t=this._edges.get(e);if(!t)throw new k(`Graph.extremities: could not find the "${e}" edge in the graph.`);return[t.source.key,t.target.key]}opposite(e,t){e=``+e,t=``+t;let n=this._edges.get(t);if(!n)throw new k(`Graph.opposite: could not find the "${t}" edge in the graph.`);let r=n.source.key,i=n.target.key;if(e===r)return i;if(e===i)return r;throw new k(`Graph.opposite: the "${e}" node is not attached to the "${t}" edge (${r}, ${i}).`)}hasExtremity(e,t){e=``+e,t=``+t;let n=this._edges.get(e);if(!n)throw new k(`Graph.hasExtremity: could not find the "${e}" edge in the graph.`);return n.source.key===t||n.target.key===t}isUndirected(e){e=``+e;let t=this._edges.get(e);if(!t)throw new k(`Graph.isUndirected: could not find the "${e}" edge in the graph.`);return t.undirected}isDirected(e){e=``+e;let t=this._edges.get(e);if(!t)throw new k(`Graph.isDirected: could not find the "${e}" edge in the graph.`);return!t.undirected}isSelfLoop(e){e=``+e;let t=this._edges.get(e);if(!t)throw new k(`Graph.isSelfLoop: could not find the "${e}" edge in the graph.`);return t.source===t.target}addNode(e,t){return Ht(this,e,t).key}mergeNode(e,t){if(t&&!pe(t))throw new O(`Graph.mergeNode: invalid attributes. Expecting an object but got "${t}"`);e=``+e,t||={};let n=this._nodes.get(e);return n?(t&&(D(n.attributes,t),this.emit(`nodeAttributesUpdated`,{type:`merge`,key:e,attributes:n.attributes,data:t})),[e,!1]):(n=new this.NodeDataClass(e,t),this._nodes.set(e,n),this.emit(`nodeAdded`,{key:e,attributes:t}),[e,!0])}updateNode(e,t){if(t&&typeof t!=`function`)throw new O(`Graph.updateNode: invalid updater function. Expecting a function but got "${t}"`);e=``+e;let n=this._nodes.get(e);if(n){if(t){let r=n.attributes;n.attributes=t(r),this.emit(`nodeAttributesUpdated`,{type:`replace`,key:e,attributes:n.attributes})}return[e,!1]}let r=t?t({}):{};return n=new this.NodeDataClass(e,r),this._nodes.set(e,n),this.emit(`nodeAdded`,{key:e,attributes:r}),[e,!0]}dropNode(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new k(`Graph.dropNode: could not find the "${e}" node in the graph.`);let n;if(this.type!==`undirected`){for(let e in t.out){n=t.out[e];do Kt(this,n),n=n.next;while(n)}for(let e in t.in){n=t.in[e];do Kt(this,n),n=n.next;while(n)}}if(this.type!==`directed`)for(let e in t.undirected){n=t.undirected[e];do Kt(this,n),n=n.next;while(n)}this._nodes.delete(e),this.emit(`nodeDropped`,{key:e,attributes:t.attributes})}dropEdge(e){let t;if(arguments.length>1){let e=``+arguments[0],n=``+arguments[1];if(t=fe(this,e,n,this.type),!t)throw new k(`Graph.dropEdge: could not find the "${e}" -> "${n}" edge in the graph.`)}else if(e=``+e,t=this._edges.get(e),!t)throw new k(`Graph.dropEdge: could not find the "${e}" edge in the graph.`);return Kt(this,t),this}dropDirectedEdge(e,t){if(arguments.length<2)throw new A(`Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.`);if(this.multi)throw new A(`Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.`);e=``+e,t=``+t;let n=fe(this,e,t,`directed`);if(!n)throw new k(`Graph.dropDirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return Kt(this,n),this}dropUndirectedEdge(e,t){if(arguments.length<2)throw new A(`Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.`);if(this.multi)throw new A(`Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.`);let n=fe(this,e,t,`undirected`);if(!n)throw new k(`Graph.dropUndirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return Kt(this,n),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit(`cleared`)}clearEdges(){let e=this._nodes.values(),t;for(;t=e.next(),t.done!==!0;)t.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit(`edgesCleared`)}getAttribute(e){return this._attributes[e]}getAttributes(){return this._attributes}hasAttribute(e){return this._attributes.hasOwnProperty(e)}setAttribute(e,t){return this._attributes[e]=t,this.emit(`attributesUpdated`,{type:`set`,attributes:this._attributes,name:e}),this}updateAttribute(e,t){if(typeof t!=`function`)throw new O(`Graph.updateAttribute: updater should be a function.`);let n=this._attributes[e];return this._attributes[e]=t(n),this.emit(`attributesUpdated`,{type:`set`,attributes:this._attributes,name:e}),this}removeAttribute(e){return delete this._attributes[e],this.emit(`attributesUpdated`,{type:`remove`,attributes:this._attributes,name:e}),this}replaceAttributes(e){if(!pe(e))throw new O(`Graph.replaceAttributes: provided attributes are not a plain object.`);return this._attributes=e,this.emit(`attributesUpdated`,{type:`replace`,attributes:this._attributes}),this}mergeAttributes(e){if(!pe(e))throw new O(`Graph.mergeAttributes: provided attributes are not a plain object.`);return D(this._attributes,e),this.emit(`attributesUpdated`,{type:`merge`,attributes:this._attributes,data:e}),this}updateAttributes(e){if(typeof e!=`function`)throw new O(`Graph.updateAttributes: provided updater is not a function.`);return this._attributes=e(this._attributes),this.emit(`attributesUpdated`,{type:`update`,attributes:this._attributes}),this}updateEachNodeAttributes(e,t){if(typeof e!=`function`)throw new O(`Graph.updateEachNodeAttributes: expecting an updater function.`);if(t&&!_e(t))throw new O(`Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}`);let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)i=r.value,i.attributes=e(i.key,i.attributes);this.emit(`eachNodeAttributesUpdated`,{hints:t||null})}updateEachEdgeAttributes(e,t){if(typeof e!=`function`)throw new O(`Graph.updateEachEdgeAttributes: expecting an updater function.`);if(t&&!_e(t))throw new O(`Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}`);let n=this._edges.values(),r,i,a,o;for(;r=n.next(),r.done!==!0;)i=r.value,a=i.source,o=i.target,i.attributes=e(i.key,i.attributes,a.key,o.key,a.attributes,o.attributes,i.undirected);this.emit(`eachEdgeAttributesUpdated`,{hints:t||null})}forEachAdjacencyEntry(e){if(typeof e!=`function`)throw new O(`Graph.forEachAdjacencyEntry: expecting a callback.`);Mt(!1,!1,!1,this,e)}forEachAdjacencyEntryWithOrphans(e){if(typeof e!=`function`)throw new O(`Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.`);Mt(!1,!1,!0,this,e)}forEachAssymetricAdjacencyEntry(e){if(typeof e!=`function`)throw new O(`Graph.forEachAssymetricAdjacencyEntry: expecting a callback.`);Mt(!1,!0,!1,this,e)}forEachAssymetricAdjacencyEntryWithOrphans(e){if(typeof e!=`function`)throw new O(`Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.`);Mt(!1,!0,!0,this,e)}nodes(){return Array.from(this._nodes.keys())}forEachNode(e){if(typeof e!=`function`)throw new O(`Graph.forEachNode: expecting a callback.`);let t=this._nodes.values(),n,r;for(;n=t.next(),n.done!==!0;)r=n.value,e(r.key,r.attributes)}findNode(e){if(typeof e!=`function`)throw new O(`Graph.findNode: expecting a callback.`);let t=this._nodes.values(),n,r;for(;n=t.next(),n.done!==!0;)if(r=n.value,e(r.key,r.attributes))return r.key}mapNodes(e){if(typeof e!=`function`)throw new O(`Graph.mapNode: expecting a callback.`);let t=this._nodes.values(),n,r,i=Array(this.order),a=0;for(;n=t.next(),n.done!==!0;)r=n.value,i[a++]=e(r.key,r.attributes);return i}someNode(e){if(typeof e!=`function`)throw new O(`Graph.someNode: expecting a callback.`);let t=this._nodes.values(),n,r;for(;n=t.next(),n.done!==!0;)if(r=n.value,e(r.key,r.attributes))return!0;return!1}everyNode(e){if(typeof e!=`function`)throw new O(`Graph.everyNode: expecting a callback.`);let t=this._nodes.values(),n,r;for(;n=t.next(),n.done!==!0;)if(r=n.value,!e(r.key,r.attributes))return!1;return!0}filterNodes(e){if(typeof e!=`function`)throw new O(`Graph.filterNodes: expecting a callback.`);let t=this._nodes.values(),n,r,i=[];for(;n=t.next(),n.done!==!0;)r=n.value,e(r.key,r.attributes)&&i.push(r.key);return i}reduceNodes(e,t){if(typeof e!=`function`)throw new O(`Graph.reduceNodes: expecting a callback.`);if(arguments.length<2)throw new O(`Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let n=t,r=this._nodes.values(),i,a;for(;i=r.next(),i.done!==!0;)a=i.value,n=e(n,a.key,a.attributes);return n}nodeEntries(){let e=this._nodes.values();return{[Symbol.iterator](){return this},next(){let t=e.next();if(t.done)return t;let n=t.value;return{value:{node:n.key,attributes:n.attributes},done:!1}}}}export(){let e=Array(this._nodes.size),t=0;this._nodes.forEach((n,r)=>{e[t++]=Nt(r,n)});let n=Array(this._edges.size);return t=0,this._edges.forEach((e,r)=>{n[t++]=Pt(this.type,r,e)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:n}}import(t,n=!1){if(t instanceof e)return t.forEachNode((e,t)=>{n?this.mergeNode(e,t):this.addNode(e,t)}),t.forEachEdge((e,t,r,i,a,o,s)=>{n?s?this.mergeUndirectedEdgeWithKey(e,r,i,t):this.mergeDirectedEdgeWithKey(e,r,i,t):s?this.addUndirectedEdgeWithKey(e,r,i,t):this.addDirectedEdgeWithKey(e,r,i,t)}),this;if(!pe(t))throw new O(`Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.`);if(t.attributes){if(!pe(t.attributes))throw new O(`Graph.import: invalid attributes. Expecting a plain object.`);n?this.mergeAttributes(t.attributes):this.replaceAttributes(t.attributes)}let r,i,a,o,s;if(t.nodes){if(a=t.nodes,!Array.isArray(a))throw new O(`Graph.import: invalid nodes. Expecting an array.`);for(r=0,i=a.length;r<i;r++){o=a[r],Ft(o);let{key:e,attributes:t}=o;n?this.mergeNode(e,t):this.addNode(e,t)}}if(t.edges){let e=!1;if(this.type===`undirected`&&(e=!0),a=t.edges,!Array.isArray(a))throw new O(`Graph.import: invalid edges. Expecting an array.`);for(r=0,i=a.length;r<i;r++){s=a[r],It(s);let{source:t,target:i,attributes:o,undirected:c=e}=s,l;`key`in s?(l=n?c?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:c?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,l.call(this,s.key,t,i,o)):(l=n?c?this.mergeUndirectedEdge:this.mergeDirectedEdge:c?this.addUndirectedEdge:this.addDirectedEdge,l.call(this,t,i,o))}}return this}nullCopy(t){let n=new e(D({},this._options,t));return n.replaceAttributes(D({},this.getAttributes())),n}emptyCopy(e){let t=this.nullCopy(e);return this._nodes.forEach((e,n)=>{let r=D({},e.attributes);e=new t.NodeDataClass(n,r),t._nodes.set(n,e)}),t}copy(e){if(e||={},typeof e.type==`string`&&e.type!==this.type&&e.type!==`mixed`)throw new A(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${e.type}" because this would mean losing information about the current graph.`);if(typeof e.multi==`boolean`&&e.multi!==this.multi&&e.multi!==!0)throw new A(`Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.`);if(typeof e.allowSelfLoops==`boolean`&&e.allowSelfLoops!==this.allowSelfLoops&&e.allowSelfLoops!==!0)throw new A(`Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.`);let t=this.emptyCopy(e),n=this._edges.values(),r,i;for(;r=n.next(),r.done!==!0;)i=r.value,Wt(t,`copy`,!1,i.undirected,i.key,i.source.key,i.target.key,D({},i.attributes));return t}toJSON(){return this.export()}toString(){return`[object Graph]`}inspect(){let e={};this._nodes.forEach((t,n)=>{e[n]=t.attributes});let t={},n={};this._edges.forEach((e,r)=>{let i=e.undirected?`--`:`->`,a=``,o=e.source.key,s=e.target.key,c;e.undirected&&o>s&&(c=o,o=s,s=c);let l=`(${o})${i}(${s})`;r.startsWith(`geid_`)?this.multi&&(n[l]===void 0?n[l]=0:n[l]++,a+=`${n[l]}. `):a+=`[${r}]: `,a+=l,t[a]=e.attributes});let r={};for(let e in this)this.hasOwnProperty(e)&&!zt.has(e)&&typeof this[e]!=`function`&&typeof e!=`symbol`&&(r[e]=this[e]);return r.attributes=this._attributes,r.nodes=e,r.edges=t,he(r,`constructor`,this.constructor),r}};typeof Symbol<`u`&&(j.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=j.prototype.inspect),Bt.forEach(e=>{[`add`,`merge`,`update`].forEach(t=>{let n=e.name(t),r=t===`add`?Wt:Gt;e.generateKey?j.prototype[n]=function(i,a,o){return r(this,n,!0,(e.type||this.type)===`undirected`,null,i,a,o,t===`update`)}:j.prototype[n]=function(i,a,o,s){return r(this,n,!1,(e.type||this.type)===`undirected`,i,a,o,s,t===`update`)}})}),Ve(j),Qe(j),yt(j),jt(j);var qt=class extends j{constructor(e){let t=D({type:`directed`},e);if(`multi`in t&&t.multi!==!1)throw new O(`DirectedGraph.from: inconsistent indication that the graph should be multi in given options!`);if(t.type!==`directed`)throw new O(`DirectedGraph.from: inconsistent "`+t.type+`" type in given options!`);super(t)}},Jt=class extends j{constructor(e){let t=D({type:`undirected`},e);if(`multi`in t&&t.multi!==!1)throw new O(`UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!`);if(t.type!==`undirected`)throw new O(`UndirectedGraph.from: inconsistent "`+t.type+`" type in given options!`);super(t)}},Yt=class extends j{constructor(e){let t=D({multi:!0},e);if(`multi`in t&&t.multi!==!0)throw new O(`MultiGraph.from: inconsistent indication that the graph should be simple in given options!`);super(t)}},Xt=class extends j{constructor(e){let t=D({type:`directed`,multi:!0},e);if(`multi`in t&&t.multi!==!0)throw new O(`MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!`);if(t.type!==`directed`)throw new O(`MultiDirectedGraph.from: inconsistent "`+t.type+`" type in given options!`);super(t)}},Zt=class extends j{constructor(e){let t=D({type:`undirected`,multi:!0},e);if(`multi`in t&&t.multi!==!0)throw new O(`MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!`);if(t.type!==`undirected`)throw new O(`MultiUndirectedGraph.from: inconsistent "`+t.type+`" type in given options!`);super(t)}};function Qt(e){e.from=function(t,n){let r=new e(D({},t.options,n));return r.import(t),r}}Qt(j),Qt(qt),Qt(Jt),Qt(Yt),Qt(Xt),Qt(Zt),j.Graph=j,j.DirectedGraph=qt,j.UndirectedGraph=Jt,j.MultiGraph=Yt,j.MultiDirectedGraph=Xt,j.MultiUndirectedGraph=Zt,j.InvalidArgumentsGraphError=O,j.NotFoundGraphError=k,j.UsageGraphError=A;function $t(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function en(e){var t=$t(e,`string`);return typeof t==`symbol`?t:t+``}function tn(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function nn(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,en(r.key),r)}}function rn(e,t,n){return t&&nn(e.prototype,t),n&&nn(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function an(e){return an=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},an(e)}function on(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(on=function(){return!!e})()}function sn(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function cn(e,t){if(t&&(typeof t==`object`||typeof t==`function`))return t;if(t!==void 0)throw TypeError(`Derived constructors may only return object or undefined`);return sn(e)}function ln(e,t,n){return t=an(t),cn(e,on()?Reflect.construct(t,n||[],an(e).constructor):t.apply(e,n))}function un(e,t){return un=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},un(e,t)}function dn(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&un(e,t)}function fn(e){if(Array.isArray(e))return e}function pn(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function mn(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function hn(e,t){if(e){if(typeof e==`string`)return mn(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?mn(e,t):void 0}}function gn(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
3
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _n(e,t){return fn(e)||pn(e,t)||hn(e,t)||gn()}var vn={black:`#000000`,silver:`#C0C0C0`,gray:`#808080`,grey:`#808080`,white:`#FFFFFF`,maroon:`#800000`,red:`#FF0000`,purple:`#800080`,fuchsia:`#FF00FF`,green:`#008000`,lime:`#00FF00`,olive:`#808000`,yellow:`#FFFF00`,navy:`#000080`,blue:`#0000FF`,teal:`#008080`,aqua:`#00FFFF`,darkblue:`#00008B`,mediumblue:`#0000CD`,darkgreen:`#006400`,darkcyan:`#008B8B`,deepskyblue:`#00BFFF`,darkturquoise:`#00CED1`,mediumspringgreen:`#00FA9A`,springgreen:`#00FF7F`,cyan:`#00FFFF`,midnightblue:`#191970`,dodgerblue:`#1E90FF`,lightseagreen:`#20B2AA`,forestgreen:`#228B22`,seagreen:`#2E8B57`,darkslategray:`#2F4F4F`,darkslategrey:`#2F4F4F`,limegreen:`#32CD32`,mediumseagreen:`#3CB371`,turquoise:`#40E0D0`,royalblue:`#4169E1`,steelblue:`#4682B4`,darkslateblue:`#483D8B`,mediumturquoise:`#48D1CC`,indigo:`#4B0082`,darkolivegreen:`#556B2F`,cadetblue:`#5F9EA0`,cornflowerblue:`#6495ED`,rebeccapurple:`#663399`,mediumaquamarine:`#66CDAA`,dimgray:`#696969`,dimgrey:`#696969`,slateblue:`#6A5ACD`,olivedrab:`#6B8E23`,slategray:`#708090`,slategrey:`#708090`,lightslategray:`#778899`,lightslategrey:`#778899`,mediumslateblue:`#7B68EE`,lawngreen:`#7CFC00`,chartreuse:`#7FFF00`,aquamarine:`#7FFFD4`,skyblue:`#87CEEB`,lightskyblue:`#87CEFA`,blueviolet:`#8A2BE2`,darkred:`#8B0000`,darkmagenta:`#8B008B`,saddlebrown:`#8B4513`,darkseagreen:`#8FBC8F`,lightgreen:`#90EE90`,mediumpurple:`#9370DB`,darkviolet:`#9400D3`,palegreen:`#98FB98`,darkorchid:`#9932CC`,yellowgreen:`#9ACD32`,sienna:`#A0522D`,brown:`#A52A2A`,darkgray:`#A9A9A9`,darkgrey:`#A9A9A9`,lightblue:`#ADD8E6`,greenyellow:`#ADFF2F`,paleturquoise:`#AFEEEE`,lightsteelblue:`#B0C4DE`,powderblue:`#B0E0E6`,firebrick:`#B22222`,darkgoldenrod:`#B8860B`,mediumorchid:`#BA55D3`,rosybrown:`#BC8F8F`,darkkhaki:`#BDB76B`,mediumvioletred:`#C71585`,indianred:`#CD5C5C`,peru:`#CD853F`,chocolate:`#D2691E`,tan:`#D2B48C`,lightgray:`#D3D3D3`,lightgrey:`#D3D3D3`,thistle:`#D8BFD8`,orchid:`#DA70D6`,goldenrod:`#DAA520`,palevioletred:`#DB7093`,crimson:`#DC143C`,gainsboro:`#DCDCDC`,plum:`#DDA0DD`,burlywood:`#DEB887`,lightcyan:`#E0FFFF`,lavender:`#E6E6FA`,darksalmon:`#E9967A`,violet:`#EE82EE`,palegoldenrod:`#EEE8AA`,lightcoral:`#F08080`,khaki:`#F0E68C`,aliceblue:`#F0F8FF`,honeydew:`#F0FFF0`,azure:`#F0FFFF`,sandybrown:`#F4A460`,wheat:`#F5DEB3`,beige:`#F5F5DC`,whitesmoke:`#F5F5F5`,mintcream:`#F5FFFA`,ghostwhite:`#F8F8FF`,salmon:`#FA8072`,antiquewhite:`#FAEBD7`,linen:`#FAF0E6`,lightgoldenrodyellow:`#FAFAD2`,oldlace:`#FDF5E6`,magenta:`#FF00FF`,deeppink:`#FF1493`,orangered:`#FF4500`,tomato:`#FF6347`,hotpink:`#FF69B4`,coral:`#FF7F50`,darkorange:`#FF8C00`,lightsalmon:`#FFA07A`,orange:`#FFA500`,lightpink:`#FFB6C1`,pink:`#FFC0CB`,gold:`#FFD700`,peachpuff:`#FFDAB9`,navajowhite:`#FFDEAD`,moccasin:`#FFE4B5`,bisque:`#FFE4C4`,mistyrose:`#FFE4E1`,blanchedalmond:`#FFEBCD`,papayawhip:`#FFEFD5`,lavenderblush:`#FFF0F5`,seashell:`#FFF5EE`,cornsilk:`#FFF8DC`,lemonchiffon:`#FFFACD`,floralwhite:`#FFFAF0`,snow:`#FFFAFA`,lightyellow:`#FFFFE0`,ivory:`#FFFFF0`},yn=new Int8Array(4),bn=new Int32Array(yn.buffer,0,1),xn=new Float32Array(yn.buffer,0,1),Sn=/^\s*rgba?\s*\(/,Cn=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function wn(e){var t=0,n=0,r=0,i=1;if(e[0]===`#`)e.length===4?(t=parseInt(e.charAt(1)+e.charAt(1),16),n=parseInt(e.charAt(2)+e.charAt(2),16),r=parseInt(e.charAt(3)+e.charAt(3),16)):(t=parseInt(e.charAt(1)+e.charAt(2),16),n=parseInt(e.charAt(3)+e.charAt(4),16),r=parseInt(e.charAt(5)+e.charAt(6),16)),e.length===9&&(i=parseInt(e.charAt(7)+e.charAt(8),16)/255);else if(Sn.test(e)){var a=e.match(Cn);a&&(t=+a[1],n=+a[2],r=+a[3],a[4]&&(i=+a[4]))}return{r:t,g:n,b:r,a:i}}var Tn={};for(var En in vn)Tn[En]=On(vn[En]),Tn[vn[En]]=Tn[En];function Dn(e,t,n,r,i){return bn[0]=r<<24|n<<16|t<<8|e,i&&(bn[0]&=4278190079),xn[0]}function On(e){if(e=e.toLowerCase(),Tn[e]!==void 0)return Tn[e];var t=wn(e),n=t.r,r=t.g,i=t.b,a=t.a;a=a*255|0;var o=Dn(n,r,i,a,!0);return Tn[e]=o,o}var kn={};function An(e){if(kn[e]!==void 0)return kn[e];var t=Dn((e&16711680)>>>16,(e&65280)>>>8,e&255,255,!0);return kn[e]=t,t}function jn(e,t,n,r){return n+(t<<8)+(e<<16)}function Mn(e,t,n,r,i,a){var o=Math.floor(n/a*i),s=Math.floor(e.drawingBufferHeight/a-r/a*i),c=new Uint8Array(4);e.bindFramebuffer(e.FRAMEBUFFER,t),e.readPixels(o,s,1,1,e.RGBA,e.UNSIGNED_BYTE,c);var l=_n(c,4);return[l[0],l[1],l[2],l[3]]}function M(e,t,n){return(t=en(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Nn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function N(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Nn(Object(n),!0).forEach(function(t){M(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Nn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Pn(e,t){for(;!{}.hasOwnProperty.call(e,t)&&(e=an(e))!==null;);return e}function Fn(){return Fn=typeof Reflect<`u`&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=Pn(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},Fn.apply(null,arguments)}function In(e,t,n,r){var i=Fn(an(1&r?e.prototype:e),t,n);return 2&r&&typeof i==`function`?function(e){return i.apply(n,e)}:i}function Ln(e){return e.normalized?1:e.size}function Rn(e){var t=0;return e.forEach(function(e){return t+=Ln(e)}),t}function zn(e,t,n){var r=e===`VERTEX`?t.VERTEX_SHADER:t.FRAGMENT_SHADER,i=t.createShader(r);if(i===null)throw Error(`loadShader: error while creating the shader`);if(t.shaderSource(i,n),t.compileShader(i),!t.getShaderParameter(i,t.COMPILE_STATUS)){var a=t.getShaderInfoLog(i);throw t.deleteShader(i),Error(`loadShader: error while compiling the shader:
|
|
4
|
-
${a}
|
|
5
|
-
${n}`)}return i}function Bn(e,t){return zn(`VERTEX`,e,t)}function Vn(e,t){return zn(`FRAGMENT`,e,t)}function Hn(e,t){var n=e.createProgram();if(n===null)throw Error(`loadProgram: error while creating the program.`);for(var r=0,i=t.length;r<i;r++)e.attachShader(n,t[r]);if(e.linkProgram(n),!e.getProgramParameter(n,e.LINK_STATUS)){var a=e.getProgramInfoLog(n);throw e.deleteProgram(n),Error(`loadProgram: error while linking the program: ${a}`)}return n}function Un(e){var t=e.gl,n=e.buffer,r=e.program,i=e.vertexShader,a=e.fragmentShader;t.deleteShader(i),t.deleteShader(a),t.deleteProgram(r),t.deleteBuffer(n)}var Wn=`#define PICKING_MODE
|
|
6
|
-
`,Gn=M(M(M(M(M(M(M(M({},WebGL2RenderingContext.BOOL,1),WebGL2RenderingContext.BYTE,1),WebGL2RenderingContext.UNSIGNED_BYTE,1),WebGL2RenderingContext.SHORT,2),WebGL2RenderingContext.UNSIGNED_SHORT,2),WebGL2RenderingContext.INT,4),WebGL2RenderingContext.UNSIGNED_INT,4),WebGL2RenderingContext.FLOAT,4),Kn=function(){function e(t,n,r){tn(this,e),M(this,`array`,new Float32Array),M(this,`constantArray`,new Float32Array),M(this,`capacity`,0),M(this,`verticesCount`,0);var i=this.getDefinition();if(this.VERTICES=i.VERTICES,this.VERTEX_SHADER_SOURCE=i.VERTEX_SHADER_SOURCE,this.FRAGMENT_SHADER_SOURCE=i.FRAGMENT_SHADER_SOURCE,this.UNIFORMS=i.UNIFORMS,this.ATTRIBUTES=i.ATTRIBUTES,this.METHOD=i.METHOD,this.CONSTANT_ATTRIBUTES=`CONSTANT_ATTRIBUTES`in i?i.CONSTANT_ATTRIBUTES:[],this.CONSTANT_DATA=`CONSTANT_DATA`in i?i.CONSTANT_DATA:[],this.isInstanced=`CONSTANT_ATTRIBUTES`in i,this.ATTRIBUTES_ITEMS_COUNT=Rn(this.ATTRIBUTES),this.STRIDE=this.VERTICES*this.ATTRIBUTES_ITEMS_COUNT,this.renderer=r,this.normalProgram=this.getProgramInfo(`normal`,t,i.VERTEX_SHADER_SOURCE,i.FRAGMENT_SHADER_SOURCE,null),this.pickProgram=n?this.getProgramInfo(`pick`,t,Wn+i.VERTEX_SHADER_SOURCE,Wn+i.FRAGMENT_SHADER_SOURCE,n):null,this.isInstanced){var a=Rn(this.CONSTANT_ATTRIBUTES);if(this.CONSTANT_DATA.length!==this.VERTICES)throw Error(`Program: error while getting constant data (expected ${this.VERTICES} items, received ${this.CONSTANT_DATA.length} instead)`);this.constantArray=new Float32Array(this.CONSTANT_DATA.length*a);for(var o=0;o<this.CONSTANT_DATA.length;o++){var s=this.CONSTANT_DATA[o];if(s.length!==a)throw Error(`Program: error while getting constant data (one vector has ${s.length} items instead of ${a})`);for(var c=0;c<s.length;c++)this.constantArray[o*a+c]=s[c]}this.STRIDE=this.ATTRIBUTES_ITEMS_COUNT}}return rn(e,[{key:`kill`,value:function(){Un(this.normalProgram),this.pickProgram&&=(Un(this.pickProgram),null)}},{key:`getProgramInfo`,value:function(e,t,n,r,i){var a=this.getDefinition(),o=t.createBuffer();if(o===null)throw Error(`Program: error while creating the WebGL buffer.`);var s=Bn(t,n),c=Vn(t,r),l=Hn(t,[s,c]),u={};a.UNIFORMS.forEach(function(e){var n=t.getUniformLocation(l,e);n&&(u[e]=n)});var d={};a.ATTRIBUTES.forEach(function(e){d[e.name]=t.getAttribLocation(l,e.name)});var f;if(`CONSTANT_ATTRIBUTES`in a&&(a.CONSTANT_ATTRIBUTES.forEach(function(e){d[e.name]=t.getAttribLocation(l,e.name)}),f=t.createBuffer(),f===null))throw Error(`Program: error while creating the WebGL constant buffer.`);return{name:e,program:l,gl:t,frameBuffer:i,buffer:o,constantBuffer:f||{},uniformLocations:u,attributeLocations:d,isPicking:e===`pick`,vertexShader:s,fragmentShader:c}}},{key:`bindProgram`,value:function(e){var t=this,n=0,r=e.gl,i=e.buffer;this.isInstanced?(r.bindBuffer(r.ARRAY_BUFFER,e.constantBuffer),n=0,this.CONSTANT_ATTRIBUTES.forEach(function(r){return n+=t.bindAttribute(r,e,n,!1)}),r.bufferData(r.ARRAY_BUFFER,this.constantArray,r.STATIC_DRAW),r.bindBuffer(r.ARRAY_BUFFER,e.buffer),n=0,this.ATTRIBUTES.forEach(function(r){return n+=t.bindAttribute(r,e,n,!0)}),r.bufferData(r.ARRAY_BUFFER,this.array,r.DYNAMIC_DRAW)):(r.bindBuffer(r.ARRAY_BUFFER,i),n=0,this.ATTRIBUTES.forEach(function(r){return n+=t.bindAttribute(r,e,n)}),r.bufferData(r.ARRAY_BUFFER,this.array,r.DYNAMIC_DRAW)),r.bindBuffer(r.ARRAY_BUFFER,null)}},{key:`unbindProgram`,value:function(e){var t=this;this.isInstanced?(this.CONSTANT_ATTRIBUTES.forEach(function(n){return t.unbindAttribute(n,e,!1)}),this.ATTRIBUTES.forEach(function(n){return t.unbindAttribute(n,e,!0)})):this.ATTRIBUTES.forEach(function(n){return t.unbindAttribute(n,e)})}},{key:`bindAttribute`,value:function(e,t,n,r){var i=Gn[e.type];if(typeof i!=`number`)throw Error(`Program.bind: yet unsupported attribute type "${e.type}"`);var a=t.attributeLocations[e.name],o=t.gl;if(a!==-1){o.enableVertexAttribArray(a);var s=this.isInstanced?(r?this.ATTRIBUTES_ITEMS_COUNT:Rn(this.CONSTANT_ATTRIBUTES))*Float32Array.BYTES_PER_ELEMENT:this.ATTRIBUTES_ITEMS_COUNT*Float32Array.BYTES_PER_ELEMENT;if(o.vertexAttribPointer(a,e.size,e.type,e.normalized||!1,s,n),this.isInstanced&&r){if(o instanceof WebGL2RenderingContext)o.vertexAttribDivisor(a,1);else{var c=o.getExtension(`ANGLE_instanced_arrays`);c&&c.vertexAttribDivisorANGLE(a,1)}}}return e.size*i}},{key:`unbindAttribute`,value:function(e,t,n){var r=t.attributeLocations[e.name],i=t.gl;if(r!==-1&&(i.disableVertexAttribArray(r),this.isInstanced&&n)){if(i instanceof WebGL2RenderingContext)i.vertexAttribDivisor(r,0);else{var a=i.getExtension(`ANGLE_instanced_arrays`);a&&a.vertexAttribDivisorANGLE(r,0)}}}},{key:`reallocate`,value:function(e){e!==this.capacity&&(this.capacity=e,this.verticesCount=this.VERTICES*e,this.array=new Float32Array(this.isInstanced?this.capacity*this.ATTRIBUTES_ITEMS_COUNT:this.verticesCount*this.ATTRIBUTES_ITEMS_COUNT))}},{key:`hasNothingToRender`,value:function(){return this.verticesCount===0}},{key:`renderProgram`,value:function(e,t){var n=t.gl,r=t.program;n.enable(n.BLEND),n.useProgram(r),this.setUniforms(e,t),this.drawWebGL(this.METHOD,t)}},{key:`render`,value:function(e){this.hasNothingToRender()||(this.pickProgram&&(this.pickProgram.gl.viewport(0,0,e.width*e.pixelRatio/e.downSizingRatio,e.height*e.pixelRatio/e.downSizingRatio),this.bindProgram(this.pickProgram),this.renderProgram(N(N({},e),{},{pixelRatio:e.pixelRatio/e.downSizingRatio}),this.pickProgram),this.unbindProgram(this.pickProgram)),this.normalProgram.gl.viewport(0,0,e.width*e.pixelRatio,e.height*e.pixelRatio),this.bindProgram(this.normalProgram),this.renderProgram(e,this.normalProgram),this.unbindProgram(this.normalProgram))}},{key:`drawWebGL`,value:function(e,t){var n=t.gl,r=t.frameBuffer;if(n.bindFramebuffer(n.FRAMEBUFFER,r),!this.isInstanced)n.drawArrays(e,0,this.verticesCount);else if(n instanceof WebGL2RenderingContext)n.drawArraysInstanced(e,0,this.VERTICES,this.capacity);else{var i=n.getExtension(`ANGLE_instanced_arrays`);i&&i.drawArraysInstancedANGLE(e,0,this.VERTICES,this.capacity)}}}])}(),qn=function(e){function t(){return tn(this,t),ln(this,t,arguments)}return dn(t,e),rn(t,[{key:`kill`,value:function(){In(t,`kill`,this,3)([])}},{key:`process`,value:function(e,t,n){var r=t*this.STRIDE;if(n.hidden)for(var i=r+this.STRIDE;r<i;r++)this.array[r]=0;else return this.processVisibleItem(An(e),r,n)}}])}(Kn),Jn=function(e){function t(){var e;tn(this,t);var n=[...arguments];return e=ln(this,t,[].concat(n)),M(e,`drawLabel`,void 0),e}return dn(t,e),rn(t,[{key:`kill`,value:function(){In(t,`kill`,this,3)([])}},{key:`process`,value:function(e,t,n,r,i){var a=t*this.STRIDE;if(i.hidden||n.hidden||r.hidden)for(var o=a+this.STRIDE;a<o;a++)this.array[a]=0;else return this.processVisibleItem(An(e),a,n,r,i)}}])}(Kn);function Yn(e,t){return function(){function n(r,i,a){tn(this,n),M(this,`drawLabel`,t),this.programs=e.map(function(e){return new e(r,i,a)})}return rn(n,[{key:`reallocate`,value:function(e){this.programs.forEach(function(t){return t.reallocate(e)})}},{key:`process`,value:function(e,t,n,r,i){this.programs.forEach(function(a){return a.process(e,t,n,r,i)})}},{key:`render`,value:function(e){this.programs.forEach(function(t){return t.render(e)})}},{key:`kill`,value:function(){this.programs.forEach(function(e){return e.kill()})}}])}()}function Xn(e,t,n,r,i){var a=i.edgeLabelSize,o=i.edgeLabelFont,s=i.edgeLabelWeight,c=i.edgeLabelColor.attribute?t[i.edgeLabelColor.attribute]||i.edgeLabelColor.color||`#000`:i.edgeLabelColor.color,l=t.label;if(l){e.fillStyle=c,e.font=`${s} ${a}px ${o}`;var u=n.size,d=r.size,f=n.x,p=n.y,m=r.x,h=r.y,g=(f+m)/2,_=(p+h)/2,v=m-f,y=h-p,b=Math.sqrt(v*v+y*y);if(!(b<u+d)){f+=v*u/b,p+=y*u/b,m-=v*d/b,h-=y*d/b,g=(f+m)/2,_=(p+h)/2,v=m-f,y=h-p,b=Math.sqrt(v*v+y*y);var x=e.measureText(l).width;if(x>b){var S=`…`;for(l+=S,x=e.measureText(l).width;x>b&&l.length>1;)l=l.slice(0,-2)+S,x=e.measureText(l).width;if(l.length<4)return}var C=v>0?y>0?Math.acos(v/b):Math.asin(y/b):y>0?Math.acos(v/b)+Math.PI:Math.asin(v/b)+Math.PI/2;e.save(),e.translate(g,_),e.rotate(C),e.fillText(l,-x/2,t.size/2+a),e.restore()}}}function Zn(e,t,n){if(t.label){var r=n.labelSize,i=n.labelFont,a=n.labelWeight;e.fillStyle=n.labelColor.attribute?t[n.labelColor.attribute]||n.labelColor.color||`#000`:n.labelColor.color,e.font=`${a} ${r}px ${i}`,e.fillText(t.label,t.x+t.size+3,t.y+r/3)}}function Qn(e,t,n){var r=n.labelSize,i=n.labelFont;e.font=`${n.labelWeight} ${r}px ${i}`,e.fillStyle=`#FFF`,e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=8,e.shadowColor=`#000`;var a=2;if(typeof t.label==`string`){var o=e.measureText(t.label).width,s=Math.round(o+5),c=Math.round(r+2*a),l=Math.max(t.size,r/2)+a,u=Math.asin(c/2/l),d=Math.sqrt(Math.abs(l**2-(c/2)**2));e.beginPath(),e.moveTo(t.x+d,t.y+c/2),e.lineTo(t.x+l+s,t.y+c/2),e.lineTo(t.x+l+s,t.y-c/2),e.lineTo(t.x+d,t.y-c/2),e.arc(t.x,t.y,l,u,-u),e.closePath(),e.fill()}else e.beginPath(),e.arc(t.x,t.y,t.size+a,0,Math.PI*2),e.closePath(),e.fill();e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=0,Zn(e,t,n)}var $n=`
|
|
7
|
-
precision highp float;
|
|
8
|
-
|
|
9
|
-
varying vec4 v_color;
|
|
10
|
-
varying vec2 v_diffVector;
|
|
11
|
-
varying float v_radius;
|
|
12
|
-
|
|
13
|
-
uniform float u_correctionRatio;
|
|
14
|
-
|
|
15
|
-
const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
|
|
16
|
-
|
|
17
|
-
void main(void) {
|
|
18
|
-
float border = u_correctionRatio * 2.0;
|
|
19
|
-
float dist = length(v_diffVector) - v_radius + border;
|
|
20
|
-
|
|
21
|
-
// No antialiasing for picking mode:
|
|
22
|
-
#ifdef PICKING_MODE
|
|
23
|
-
if (dist > border)
|
|
24
|
-
gl_FragColor = transparent;
|
|
25
|
-
else
|
|
26
|
-
gl_FragColor = v_color;
|
|
27
|
-
|
|
28
|
-
#else
|
|
29
|
-
float t = 0.0;
|
|
30
|
-
if (dist > border)
|
|
31
|
-
t = 1.0;
|
|
32
|
-
else if (dist > 0.0)
|
|
33
|
-
t = dist / border;
|
|
34
|
-
|
|
35
|
-
gl_FragColor = mix(v_color, transparent, t);
|
|
36
|
-
#endif
|
|
37
|
-
}
|
|
38
|
-
`,er=`
|
|
39
|
-
attribute vec4 a_id;
|
|
40
|
-
attribute vec4 a_color;
|
|
41
|
-
attribute vec2 a_position;
|
|
42
|
-
attribute float a_size;
|
|
43
|
-
attribute float a_angle;
|
|
44
|
-
|
|
45
|
-
uniform mat3 u_matrix;
|
|
46
|
-
uniform float u_sizeRatio;
|
|
47
|
-
uniform float u_correctionRatio;
|
|
48
|
-
|
|
49
|
-
varying vec4 v_color;
|
|
50
|
-
varying vec2 v_diffVector;
|
|
51
|
-
varying float v_radius;
|
|
52
|
-
varying float v_border;
|
|
53
|
-
|
|
54
|
-
const float bias = 255.0 / 254.0;
|
|
55
|
-
|
|
56
|
-
void main() {
|
|
57
|
-
float size = a_size * u_correctionRatio / u_sizeRatio * 4.0;
|
|
58
|
-
vec2 diffVector = size * vec2(cos(a_angle), sin(a_angle));
|
|
59
|
-
vec2 position = a_position + diffVector;
|
|
60
|
-
gl_Position = vec4(
|
|
61
|
-
(u_matrix * vec3(position, 1)).xy,
|
|
62
|
-
0,
|
|
63
|
-
1
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
v_diffVector = diffVector;
|
|
67
|
-
v_radius = size / 2.0;
|
|
68
|
-
|
|
69
|
-
#ifdef PICKING_MODE
|
|
70
|
-
// For picking mode, we use the ID as the color:
|
|
71
|
-
v_color = a_id;
|
|
72
|
-
#else
|
|
73
|
-
// For normal mode, we use the color:
|
|
74
|
-
v_color = a_color;
|
|
75
|
-
#endif
|
|
76
|
-
|
|
77
|
-
v_color.a *= bias;
|
|
78
|
-
}
|
|
79
|
-
`,tr=WebGLRenderingContext,nr=tr.UNSIGNED_BYTE,rr=tr.FLOAT,ir=[`u_sizeRatio`,`u_correctionRatio`,`u_matrix`],ar=function(e){function t(){return tn(this,t),ln(this,t,arguments)}return dn(t,e),rn(t,[{key:`getDefinition`,value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:er,FRAGMENT_SHADER_SOURCE:$n,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:ir,ATTRIBUTES:[{name:`a_position`,size:2,type:rr},{name:`a_size`,size:1,type:rr},{name:`a_color`,size:4,type:nr,normalized:!0},{name:`a_id`,size:4,type:nr,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:`a_angle`,size:1,type:rr}],CONSTANT_DATA:[[t.ANGLE_1],[t.ANGLE_2],[t.ANGLE_3]]}}},{key:`processVisibleItem`,value:function(e,t,n){var r=this.array,i=On(n.color);r[t++]=n.x,r[t++]=n.y,r[t++]=n.size,r[t++]=i,r[t++]=e}},{key:`setUniforms`,value:function(e,t){var n=t.gl,r=t.uniformLocations,i=r.u_sizeRatio,a=r.u_correctionRatio,o=r.u_matrix;n.uniform1f(a,e.correctionRatio),n.uniform1f(i,e.sizeRatio),n.uniformMatrix3fv(o,!1,e.matrix)}}])}(qn);M(ar,`ANGLE_1`,0),M(ar,`ANGLE_2`,2*Math.PI/3),M(ar,`ANGLE_3`,4*Math.PI/3);var or=`
|
|
80
|
-
precision mediump float;
|
|
81
|
-
|
|
82
|
-
varying vec4 v_color;
|
|
83
|
-
|
|
84
|
-
void main(void) {
|
|
85
|
-
gl_FragColor = v_color;
|
|
86
|
-
}
|
|
87
|
-
`,sr=`
|
|
88
|
-
attribute vec2 a_position;
|
|
89
|
-
attribute vec2 a_normal;
|
|
90
|
-
attribute float a_radius;
|
|
91
|
-
attribute vec3 a_barycentric;
|
|
92
|
-
|
|
93
|
-
#ifdef PICKING_MODE
|
|
94
|
-
attribute vec4 a_id;
|
|
95
|
-
#else
|
|
96
|
-
attribute vec4 a_color;
|
|
97
|
-
#endif
|
|
98
|
-
|
|
99
|
-
uniform mat3 u_matrix;
|
|
100
|
-
uniform float u_sizeRatio;
|
|
101
|
-
uniform float u_correctionRatio;
|
|
102
|
-
uniform float u_minEdgeThickness;
|
|
103
|
-
uniform float u_lengthToThicknessRatio;
|
|
104
|
-
uniform float u_widenessToThicknessRatio;
|
|
105
|
-
|
|
106
|
-
varying vec4 v_color;
|
|
107
|
-
|
|
108
|
-
const float bias = 255.0 / 254.0;
|
|
109
|
-
|
|
110
|
-
void main() {
|
|
111
|
-
float minThickness = u_minEdgeThickness;
|
|
112
|
-
|
|
113
|
-
float normalLength = length(a_normal);
|
|
114
|
-
vec2 unitNormal = a_normal / normalLength;
|
|
115
|
-
|
|
116
|
-
// These first computations are taken from edge.vert.glsl and
|
|
117
|
-
// edge.clamped.vert.glsl. Please read it to get better comments on what's
|
|
118
|
-
// happening:
|
|
119
|
-
float pixelsThickness = max(normalLength / u_sizeRatio, minThickness);
|
|
120
|
-
float webGLThickness = pixelsThickness * u_correctionRatio;
|
|
121
|
-
float webGLNodeRadius = a_radius * 2.0 * u_correctionRatio / u_sizeRatio;
|
|
122
|
-
float webGLArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
|
|
123
|
-
float webGLArrowHeadThickness = webGLThickness * u_widenessToThicknessRatio;
|
|
124
|
-
|
|
125
|
-
float da = a_barycentric.x;
|
|
126
|
-
float db = a_barycentric.y;
|
|
127
|
-
float dc = a_barycentric.z;
|
|
128
|
-
|
|
129
|
-
vec2 delta = vec2(
|
|
130
|
-
da * (webGLNodeRadius * unitNormal.y)
|
|
131
|
-
+ db * ((webGLNodeRadius + webGLArrowHeadLength) * unitNormal.y + webGLArrowHeadThickness * unitNormal.x)
|
|
132
|
-
+ dc * ((webGLNodeRadius + webGLArrowHeadLength) * unitNormal.y - webGLArrowHeadThickness * unitNormal.x),
|
|
133
|
-
|
|
134
|
-
da * (-webGLNodeRadius * unitNormal.x)
|
|
135
|
-
+ db * (-(webGLNodeRadius + webGLArrowHeadLength) * unitNormal.x + webGLArrowHeadThickness * unitNormal.y)
|
|
136
|
-
+ dc * (-(webGLNodeRadius + webGLArrowHeadLength) * unitNormal.x - webGLArrowHeadThickness * unitNormal.y)
|
|
137
|
-
);
|
|
138
|
-
|
|
139
|
-
vec2 position = (u_matrix * vec3(a_position + delta, 1)).xy;
|
|
140
|
-
|
|
141
|
-
gl_Position = vec4(position, 0, 1);
|
|
142
|
-
|
|
143
|
-
#ifdef PICKING_MODE
|
|
144
|
-
// For picking mode, we use the ID as the color:
|
|
145
|
-
v_color = a_id;
|
|
146
|
-
#else
|
|
147
|
-
// For normal mode, we use the color:
|
|
148
|
-
v_color = a_color;
|
|
149
|
-
#endif
|
|
150
|
-
|
|
151
|
-
v_color.a *= bias;
|
|
152
|
-
}
|
|
153
|
-
`,cr=WebGLRenderingContext,lr=cr.UNSIGNED_BYTE,ur=cr.FLOAT,dr=[`u_matrix`,`u_sizeRatio`,`u_correctionRatio`,`u_minEdgeThickness`,`u_lengthToThicknessRatio`,`u_widenessToThicknessRatio`],fr={extremity:`target`,lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function pr(e){var t=N(N({},fr),e||{});return function(e){function n(){return tn(this,n),ln(this,n,arguments)}return dn(n,e),rn(n,[{key:`getDefinition`,value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:sr,FRAGMENT_SHADER_SOURCE:or,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:dr,ATTRIBUTES:[{name:`a_position`,size:2,type:ur},{name:`a_normal`,size:2,type:ur},{name:`a_radius`,size:1,type:ur},{name:`a_color`,size:4,type:lr,normalized:!0},{name:`a_id`,size:4,type:lr,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:`a_barycentric`,size:3,type:ur}],CONSTANT_DATA:[[1,0,0],[0,1,0],[0,0,1]]}}},{key:`processVisibleItem`,value:function(e,n,r,i,a){if(t.extremity===`source`){var o=[i,r];r=o[0],i=o[1]}var s=a.size||1,c=i.size||1,l=r.x,u=r.y,d=i.x,f=i.y,p=On(a.color),m=d-l,h=f-u,g=m*m+h*h,_=0,v=0;g&&(g=1/Math.sqrt(g),_=-h*g*s,v=m*g*s);var y=this.array;y[n++]=d,y[n++]=f,y[n++]=-_,y[n++]=-v,y[n++]=c,y[n++]=p,y[n++]=e}},{key:`setUniforms`,value:function(e,n){var r=n.gl,i=n.uniformLocations,a=i.u_matrix,o=i.u_sizeRatio,s=i.u_correctionRatio,c=i.u_minEdgeThickness,l=i.u_lengthToThicknessRatio,u=i.u_widenessToThicknessRatio;r.uniformMatrix3fv(a,!1,e.matrix),r.uniform1f(o,e.sizeRatio),r.uniform1f(s,e.correctionRatio),r.uniform1f(c,e.minEdgeThickness),r.uniform1f(l,t.lengthToThicknessRatio),r.uniform1f(u,t.widenessToThicknessRatio)}}])}(Jn)}pr();var mr=`
|
|
154
|
-
precision mediump float;
|
|
155
|
-
|
|
156
|
-
varying vec4 v_color;
|
|
157
|
-
varying vec2 v_normal;
|
|
158
|
-
varying float v_thickness;
|
|
159
|
-
varying float v_feather;
|
|
160
|
-
|
|
161
|
-
const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
|
|
162
|
-
|
|
163
|
-
void main(void) {
|
|
164
|
-
// We only handle antialiasing for normal mode:
|
|
165
|
-
#ifdef PICKING_MODE
|
|
166
|
-
gl_FragColor = v_color;
|
|
167
|
-
#else
|
|
168
|
-
float dist = length(v_normal) * v_thickness;
|
|
169
|
-
|
|
170
|
-
float t = smoothstep(
|
|
171
|
-
v_thickness - v_feather,
|
|
172
|
-
v_thickness,
|
|
173
|
-
dist
|
|
174
|
-
);
|
|
175
|
-
|
|
176
|
-
gl_FragColor = mix(v_color, transparent, t);
|
|
177
|
-
#endif
|
|
178
|
-
}
|
|
179
|
-
`,hr=`
|
|
180
|
-
attribute vec4 a_id;
|
|
181
|
-
attribute vec4 a_color;
|
|
182
|
-
attribute vec2 a_normal;
|
|
183
|
-
attribute float a_normalCoef;
|
|
184
|
-
attribute vec2 a_positionStart;
|
|
185
|
-
attribute vec2 a_positionEnd;
|
|
186
|
-
attribute float a_positionCoef;
|
|
187
|
-
attribute float a_radius;
|
|
188
|
-
attribute float a_radiusCoef;
|
|
189
|
-
|
|
190
|
-
uniform mat3 u_matrix;
|
|
191
|
-
uniform float u_zoomRatio;
|
|
192
|
-
uniform float u_sizeRatio;
|
|
193
|
-
uniform float u_pixelRatio;
|
|
194
|
-
uniform float u_correctionRatio;
|
|
195
|
-
uniform float u_minEdgeThickness;
|
|
196
|
-
uniform float u_lengthToThicknessRatio;
|
|
197
|
-
uniform float u_feather;
|
|
198
|
-
|
|
199
|
-
varying vec4 v_color;
|
|
200
|
-
varying vec2 v_normal;
|
|
201
|
-
varying float v_thickness;
|
|
202
|
-
varying float v_feather;
|
|
203
|
-
|
|
204
|
-
const float bias = 255.0 / 254.0;
|
|
205
|
-
|
|
206
|
-
void main() {
|
|
207
|
-
float minThickness = u_minEdgeThickness;
|
|
208
|
-
|
|
209
|
-
float radius = a_radius * a_radiusCoef;
|
|
210
|
-
vec2 normal = a_normal * a_normalCoef;
|
|
211
|
-
vec2 position = a_positionStart * (1.0 - a_positionCoef) + a_positionEnd * a_positionCoef;
|
|
212
|
-
|
|
213
|
-
float normalLength = length(normal);
|
|
214
|
-
vec2 unitNormal = normal / normalLength;
|
|
215
|
-
|
|
216
|
-
// These first computations are taken from edge.vert.glsl. Please read it to
|
|
217
|
-
// get better comments on what's happening:
|
|
218
|
-
float pixelsThickness = max(normalLength, minThickness * u_sizeRatio);
|
|
219
|
-
float webGLThickness = pixelsThickness * u_correctionRatio / u_sizeRatio;
|
|
220
|
-
|
|
221
|
-
// Here, we move the point to leave space for the arrow head:
|
|
222
|
-
float direction = sign(radius);
|
|
223
|
-
float webGLNodeRadius = direction * radius * 2.0 * u_correctionRatio / u_sizeRatio;
|
|
224
|
-
float webGLArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
|
|
225
|
-
|
|
226
|
-
vec2 compensationVector = vec2(-direction * unitNormal.y, direction * unitNormal.x) * (webGLNodeRadius + webGLArrowHeadLength);
|
|
227
|
-
|
|
228
|
-
// Here is the proper position of the vertex
|
|
229
|
-
gl_Position = vec4((u_matrix * vec3(position + unitNormal * webGLThickness + compensationVector, 1)).xy, 0, 1);
|
|
230
|
-
|
|
231
|
-
v_thickness = webGLThickness / u_zoomRatio;
|
|
232
|
-
|
|
233
|
-
v_normal = unitNormal;
|
|
234
|
-
|
|
235
|
-
v_feather = u_feather * u_correctionRatio / u_zoomRatio / u_pixelRatio * 2.0;
|
|
236
|
-
|
|
237
|
-
#ifdef PICKING_MODE
|
|
238
|
-
// For picking mode, we use the ID as the color:
|
|
239
|
-
v_color = a_id;
|
|
240
|
-
#else
|
|
241
|
-
// For normal mode, we use the color:
|
|
242
|
-
v_color = a_color;
|
|
243
|
-
#endif
|
|
244
|
-
|
|
245
|
-
v_color.a *= bias;
|
|
246
|
-
}
|
|
247
|
-
`,gr=WebGLRenderingContext,_r=gr.UNSIGNED_BYTE,vr=gr.FLOAT,yr=[`u_matrix`,`u_zoomRatio`,`u_sizeRatio`,`u_correctionRatio`,`u_pixelRatio`,`u_feather`,`u_minEdgeThickness`,`u_lengthToThicknessRatio`],br={lengthToThicknessRatio:fr.lengthToThicknessRatio};function xr(e){var t=N(N({},br),e||{});return function(e){function n(){return tn(this,n),ln(this,n,arguments)}return dn(n,e),rn(n,[{key:`getDefinition`,value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:hr,FRAGMENT_SHADER_SOURCE:mr,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:yr,ATTRIBUTES:[{name:`a_positionStart`,size:2,type:vr},{name:`a_positionEnd`,size:2,type:vr},{name:`a_normal`,size:2,type:vr},{name:`a_color`,size:4,type:_r,normalized:!0},{name:`a_id`,size:4,type:_r,normalized:!0},{name:`a_radius`,size:1,type:vr}],CONSTANT_ATTRIBUTES:[{name:`a_positionCoef`,size:1,type:vr},{name:`a_normalCoef`,size:1,type:vr},{name:`a_radiusCoef`,size:1,type:vr}],CONSTANT_DATA:[[0,1,0],[0,-1,0],[1,1,1],[1,1,1],[0,-1,0],[1,-1,-1]]}}},{key:`processVisibleItem`,value:function(e,t,n,r,i){var a=i.size||1,o=n.x,s=n.y,c=r.x,l=r.y,u=On(i.color),d=c-o,f=l-s,p=r.size||1,m=d*d+f*f,h=0,g=0;m&&(m=1/Math.sqrt(m),h=-f*m*a,g=d*m*a);var _=this.array;_[t++]=o,_[t++]=s,_[t++]=c,_[t++]=l,_[t++]=h,_[t++]=g,_[t++]=u,_[t++]=e,_[t++]=p}},{key:`setUniforms`,value:function(e,n){var r=n.gl,i=n.uniformLocations,a=i.u_matrix,o=i.u_zoomRatio,s=i.u_feather,c=i.u_pixelRatio,l=i.u_correctionRatio,u=i.u_sizeRatio,d=i.u_minEdgeThickness,f=i.u_lengthToThicknessRatio;r.uniformMatrix3fv(a,!1,e.matrix),r.uniform1f(o,e.zoomRatio),r.uniform1f(u,e.sizeRatio),r.uniform1f(l,e.correctionRatio),r.uniform1f(c,e.pixelRatio),r.uniform1f(s,e.antiAliasingFeather),r.uniform1f(d,e.minEdgeThickness),r.uniform1f(f,t.lengthToThicknessRatio)}}])}(Jn)}xr();function Sr(e){return Yn([xr(e),pr(e)])}var Cr=Sr(),wr=`
|
|
248
|
-
attribute vec4 a_id;
|
|
249
|
-
attribute vec4 a_color;
|
|
250
|
-
attribute vec2 a_normal;
|
|
251
|
-
attribute float a_normalCoef;
|
|
252
|
-
attribute vec2 a_positionStart;
|
|
253
|
-
attribute vec2 a_positionEnd;
|
|
254
|
-
attribute float a_positionCoef;
|
|
255
|
-
|
|
256
|
-
uniform mat3 u_matrix;
|
|
257
|
-
uniform float u_sizeRatio;
|
|
258
|
-
uniform float u_zoomRatio;
|
|
259
|
-
uniform float u_pixelRatio;
|
|
260
|
-
uniform float u_correctionRatio;
|
|
261
|
-
uniform float u_minEdgeThickness;
|
|
262
|
-
uniform float u_feather;
|
|
263
|
-
|
|
264
|
-
varying vec4 v_color;
|
|
265
|
-
varying vec2 v_normal;
|
|
266
|
-
varying float v_thickness;
|
|
267
|
-
varying float v_feather;
|
|
268
|
-
|
|
269
|
-
const float bias = 255.0 / 254.0;
|
|
270
|
-
|
|
271
|
-
void main() {
|
|
272
|
-
float minThickness = u_minEdgeThickness;
|
|
273
|
-
|
|
274
|
-
vec2 normal = a_normal * a_normalCoef;
|
|
275
|
-
vec2 position = a_positionStart * (1.0 - a_positionCoef) + a_positionEnd * a_positionCoef;
|
|
276
|
-
|
|
277
|
-
float normalLength = length(normal);
|
|
278
|
-
vec2 unitNormal = normal / normalLength;
|
|
279
|
-
|
|
280
|
-
// We require edges to be at least "minThickness" pixels thick *on screen*
|
|
281
|
-
// (so we need to compensate the size ratio):
|
|
282
|
-
float pixelsThickness = max(normalLength, minThickness * u_sizeRatio);
|
|
283
|
-
|
|
284
|
-
// Then, we need to retrieve the normalized thickness of the edge in the WebGL
|
|
285
|
-
// referential (in a ([0, 1], [0, 1]) space), using our "magic" correction
|
|
286
|
-
// ratio:
|
|
287
|
-
float webGLThickness = pixelsThickness * u_correctionRatio / u_sizeRatio;
|
|
288
|
-
|
|
289
|
-
// Here is the proper position of the vertex
|
|
290
|
-
gl_Position = vec4((u_matrix * vec3(position + unitNormal * webGLThickness, 1)).xy, 0, 1);
|
|
291
|
-
|
|
292
|
-
// For the fragment shader though, we need a thickness that takes the "magic"
|
|
293
|
-
// correction ratio into account (as in webGLThickness), but so that the
|
|
294
|
-
// antialiasing effect does not depend on the zoom level. So here's yet
|
|
295
|
-
// another thickness version:
|
|
296
|
-
v_thickness = webGLThickness / u_zoomRatio;
|
|
297
|
-
|
|
298
|
-
v_normal = unitNormal;
|
|
299
|
-
|
|
300
|
-
v_feather = u_feather * u_correctionRatio / u_zoomRatio / u_pixelRatio * 2.0;
|
|
301
|
-
|
|
302
|
-
#ifdef PICKING_MODE
|
|
303
|
-
// For picking mode, we use the ID as the color:
|
|
304
|
-
v_color = a_id;
|
|
305
|
-
#else
|
|
306
|
-
// For normal mode, we use the color:
|
|
307
|
-
v_color = a_color;
|
|
308
|
-
#endif
|
|
309
|
-
|
|
310
|
-
v_color.a *= bias;
|
|
311
|
-
}
|
|
312
|
-
`,Tr=WebGLRenderingContext,Er=Tr.UNSIGNED_BYTE,Dr=Tr.FLOAT,Or=[`u_matrix`,`u_zoomRatio`,`u_sizeRatio`,`u_correctionRatio`,`u_pixelRatio`,`u_feather`,`u_minEdgeThickness`],kr=function(e){function t(){return tn(this,t),ln(this,t,arguments)}return dn(t,e),rn(t,[{key:`getDefinition`,value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:wr,FRAGMENT_SHADER_SOURCE:mr,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Or,ATTRIBUTES:[{name:`a_positionStart`,size:2,type:Dr},{name:`a_positionEnd`,size:2,type:Dr},{name:`a_normal`,size:2,type:Dr},{name:`a_color`,size:4,type:Er,normalized:!0},{name:`a_id`,size:4,type:Er,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:`a_positionCoef`,size:1,type:Dr},{name:`a_normalCoef`,size:1,type:Dr}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[1,1],[0,-1],[1,-1]]}}},{key:`processVisibleItem`,value:function(e,t,n,r,i){var a=i.size||1,o=n.x,s=n.y,c=r.x,l=r.y,u=On(i.color),d=c-o,f=l-s,p=d*d+f*f,m=0,h=0;p&&(p=1/Math.sqrt(p),m=-f*p*a,h=d*p*a);var g=this.array;g[t++]=o,g[t++]=s,g[t++]=c,g[t++]=l,g[t++]=m,g[t++]=h,g[t++]=u,g[t++]=e}},{key:`setUniforms`,value:function(e,t){var n=t.gl,r=t.uniformLocations,i=r.u_matrix,a=r.u_zoomRatio,o=r.u_feather,s=r.u_pixelRatio,c=r.u_correctionRatio,l=r.u_sizeRatio,u=r.u_minEdgeThickness;n.uniformMatrix3fv(i,!1,e.matrix),n.uniform1f(a,e.zoomRatio),n.uniform1f(l,e.sizeRatio),n.uniform1f(c,e.correctionRatio),n.uniform1f(s,e.pixelRatio),n.uniform1f(o,e.antiAliasingFeather),n.uniform1f(u,e.minEdgeThickness)}}])}(Jn),Ar=function(e){function t(){var e;return tn(this,t),e=ln(this,t),e.rawEmitter=e,e}return dn(t,e),rn(t)}(ue.EventEmitter),jr=n(((e,t)=>{t.exports=function(e){return typeof e==`object`&&!!e&&typeof e.addUndirectedEdgeWithKey==`function`&&typeof e.dropNode==`function`&&typeof e.multi==`boolean`}})),Mr=e(jr()),Nr={linear:function(e){return e},quadraticIn:function(e){return e*e},quadraticOut:function(e){return e*(2-e)},quadraticInOut:function(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)},cubicIn:function(e){return e*e*e},cubicOut:function(e){return--e*e*e+1},cubicInOut:function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)}},Pr={easing:`quadraticInOut`,duration:150};function Fr(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function Ir(e,t,n){return e[0]=t,e[4]=typeof n==`number`?n:t,e}function Lr(e,t){var n=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=n,e[3]=-n,e[4]=r,e}function Rr(e,t,n){return e[6]=t,e[7]=n,e}function zr(e,t){var n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],s=e[5],c=e[6],l=e[7],u=e[8],d=t[0],f=t[1],p=t[2],m=t[3],h=t[4],g=t[5],_=t[6],v=t[7],y=t[8];return e[0]=d*n+f*a+p*c,e[1]=d*r+f*o+p*l,e[2]=d*i+f*s+p*u,e[3]=m*n+h*a+g*c,e[4]=m*r+h*o+g*l,e[5]=m*i+h*s+g*u,e[6]=_*n+v*a+y*c,e[7]=_*r+v*o+y*l,e[8]=_*i+v*s+y*u,e}function Br(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,r=e[0],i=e[1],a=e[3],o=e[4],s=e[6],c=e[7],l=t.x,u=t.y;return{x:l*r+u*a+s*n,y:l*i+u*o+c*n}}function Vr(e,t){var n=e.height/e.width,r=t.height/t.width;return n<1&&r>1||n>1&&r<1?1:Math.min(Math.max(r,1/r),Math.max(1/n,n))}function Hr(e,t,n,r,i){var a=e.angle,o=e.ratio,s=e.x,c=e.y,l=t.width,u=t.height,d=Fr(),f=Math.min(l,u)-2*r,p=Vr(t,n);return i?(zr(d,Rr(Fr(),s,c)),zr(d,Ir(Fr(),o)),zr(d,Lr(Fr(),a)),zr(d,Ir(Fr(),l/f/2/p,u/f/2/p))):(zr(d,Ir(Fr(),f/l*2*p,f/u*2*p)),zr(d,Lr(Fr(),-a)),zr(d,Ir(Fr(),1/o)),zr(d,Rr(Fr(),-s,-c))),d}function Ur(e,t,n){var r=Br(e,{x:Math.cos(t.angle),y:Math.sin(t.angle)},0),i=r.x,a=r.y;return 1/Math.sqrt(i**2+a**2)/n.width}function Wr(e){if(!e.order)return{x:[0,1],y:[0,1]};var t=1/0,n=-1/0,r=1/0,i=-1/0;return e.forEachNode(function(e,a){var o=a.x,s=a.y;o<t&&(t=o),o>n&&(n=o),s<r&&(r=s),s>i&&(i=s)}),{x:[t,n],y:[r,i]}}function Gr(e){if(!(0,Mr.default)(e))throw Error(`Sigma: invalid graph instance.`);e.forEachNode(function(e,t){if(!Number.isFinite(t.x)||!Number.isFinite(t.y))throw Error(`Sigma: Coordinates of node ${e} are invalid. A node must have a numeric 'x' and 'y' attribute.`)})}function Kr(e,t,n){var r=document.createElement(e);if(t)for(var i in t)r.style[i]=t[i];if(n)for(var a in n)r.setAttribute(a,n[a]);return r}function qr(){return window.devicePixelRatio===void 0?1:window.devicePixelRatio}function Jr(e,t,n){return n.sort(function(e,n){var r=t(e)||0,i=t(n)||0;return r<i?-1:+(r>i)})}function Yr(e){var t=_n(e.x,2),n=t[0],r=t[1],i=_n(e.y,2),a=i[0],o=i[1],s=Math.max(r-n,o-a),c=(r+n)/2,l=(o+a)/2;(s===0||Math.abs(s)===1/0||isNaN(s))&&(s=1),isNaN(c)&&(c=0),isNaN(l)&&(l=0);var u=function(e){return{x:.5+(e.x-c)/s,y:.5+(e.y-l)/s}};return u.applyTo=function(e){e.x=.5+(e.x-c)/s,e.y=.5+(e.y-l)/s},u.inverse=function(e){return{x:c+s*(e.x-.5),y:l+s*(e.y-.5)}},u.ratio=s,u}function Xr(e){"@babel/helpers - typeof";return Xr=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Xr(e)}function Zr(e,t){var n=t.size;if(n!==0){var r=e.length;e.length+=n;var i=0;t.forEach(function(t){e[r+i]=t,i++})}}function Qr(e){e||={};for(var t=0,n=arguments.length<=1?0:arguments.length-1;t<n;t++){var r=t+1<1||arguments.length<=t+1?void 0:arguments[t+1];r&&Object.assign(e,r)}return e}var $r={hideEdgesOnMove:!1,hideLabelsOnMove:!1,renderLabels:!0,renderEdgeLabels:!1,enableEdgeEvents:!1,defaultNodeColor:`#999`,defaultNodeType:`circle`,defaultEdgeColor:`#ccc`,defaultEdgeType:`line`,labelFont:`Arial`,labelSize:14,labelWeight:`normal`,labelColor:{color:`#000`},edgeLabelFont:`Arial`,edgeLabelSize:14,edgeLabelWeight:`normal`,edgeLabelColor:{attribute:`color`},stagePadding:30,defaultDrawEdgeLabel:Xn,defaultDrawNodeLabel:Zn,defaultDrawNodeHover:Qn,minEdgeThickness:1.7,antiAliasingFeather:1,dragTimeout:100,draggedEventsTolerance:3,inertiaDuration:200,inertiaRatio:3,zoomDuration:250,zoomingRatio:1.7,doubleClickTimeout:300,doubleClickZoomingRatio:2.2,doubleClickZoomingDuration:200,tapMoveTolerance:10,zoomToSizeRatioFunction:Math.sqrt,itemSizesReference:`screen`,autoRescale:!0,autoCenter:!0,labelDensity:1,labelGridCellSize:100,labelRenderedSizeThreshold:6,nodeReducer:null,edgeReducer:null,zIndex:!1,minCameraRatio:null,maxCameraRatio:null,enableCameraZooming:!0,enableCameraPanning:!0,enableCameraRotation:!0,cameraPanBoundaries:null,allowInvalidContainer:!1,nodeProgramClasses:{},nodeHoverProgramClasses:{},edgeProgramClasses:{}},ei={circle:ar},ti={arrow:Cr,line:kr};function ni(e){if(typeof e.labelDensity!=`number`||e.labelDensity<0)throw Error("Settings: invalid `labelDensity`. Expecting a positive number.");var t=e.minCameraRatio,n=e.maxCameraRatio;if(typeof t==`number`&&typeof n==`number`&&n<t)throw Error("Settings: invalid camera ratio boundaries. Expecting `maxCameraRatio` to be greater than `minCameraRatio`.")}function ri(e){var t=Qr({},$r,e);return t.nodeProgramClasses=Qr({},ei,t.nodeProgramClasses),t.edgeProgramClasses=Qr({},ti,t.edgeProgramClasses),t}var ii=1.5,ai=function(e){function t(){var e;return tn(this,t),e=ln(this,t),M(e,`x`,.5),M(e,`y`,.5),M(e,`angle`,0),M(e,`ratio`,1),M(e,`minRatio`,null),M(e,`maxRatio`,null),M(e,`enabledZooming`,!0),M(e,`enabledPanning`,!0),M(e,`enabledRotation`,!0),M(e,`clean`,null),M(e,`nextFrame`,null),M(e,`previousState`,null),M(e,`enabled`,!0),e.previousState=e.getState(),e}return dn(t,e),rn(t,[{key:`enable`,value:function(){return this.enabled=!0,this}},{key:`disable`,value:function(){return this.enabled=!1,this}},{key:`getState`,value:function(){return{x:this.x,y:this.y,angle:this.angle,ratio:this.ratio}}},{key:`hasState`,value:function(e){return this.x===e.x&&this.y===e.y&&this.ratio===e.ratio&&this.angle===e.angle}},{key:`getPreviousState`,value:function(){var e=this.previousState;return e?{x:e.x,y:e.y,angle:e.angle,ratio:e.ratio}:null}},{key:`getBoundedRatio`,value:function(e){var t=e;return typeof this.minRatio==`number`&&(t=Math.max(t,this.minRatio)),typeof this.maxRatio==`number`&&(t=Math.min(t,this.maxRatio)),t}},{key:`validateState`,value:function(e){var t={};return this.enabledPanning&&typeof e.x==`number`&&(t.x=e.x),this.enabledPanning&&typeof e.y==`number`&&(t.y=e.y),this.enabledZooming&&typeof e.ratio==`number`&&(t.ratio=this.getBoundedRatio(e.ratio)),this.enabledRotation&&typeof e.angle==`number`&&(t.angle=e.angle),this.clean?this.clean(N(N({},this.getState()),t)):t}},{key:`isAnimated`,value:function(){return!!this.nextFrame}},{key:`setState`,value:function(e){if(!this.enabled)return this;this.previousState=this.getState();var t=this.validateState(e);return typeof t.x==`number`&&(this.x=t.x),typeof t.y==`number`&&(this.y=t.y),typeof t.ratio==`number`&&(this.ratio=t.ratio),typeof t.angle==`number`&&(this.angle=t.angle),this.hasState(this.previousState)||this.emit(`updated`,this.getState()),this}},{key:`updateState`,value:function(e){return this.setState(e(this.getState())),this}},{key:`animate`,value:function(e){var t=this,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0;if(!r)return new Promise(function(r){return t.animate(e,n,r)});if(this.enabled){var i=N(N({},Pr),n),a=this.validateState(e),o=typeof i.easing==`function`?i.easing:Nr[i.easing],s=Date.now(),c=this.getState(),l=function(){var e=(Date.now()-s)/i.duration;if(e>=1)t.nextFrame=null,t.setState(a),t.animationCallback&&=(t.animationCallback.call(null),void 0);else{var n=o(e),r={};typeof a.x==`number`&&(r.x=c.x+(a.x-c.x)*n),typeof a.y==`number`&&(r.y=c.y+(a.y-c.y)*n),t.enabledRotation&&typeof a.angle==`number`&&(r.angle=c.angle+(a.angle-c.angle)*n),typeof a.ratio==`number`&&(r.ratio=c.ratio+(a.ratio-c.ratio)*n),t.setState(r),t.nextFrame=requestAnimationFrame(l)}};this.nextFrame?(cancelAnimationFrame(this.nextFrame),this.animationCallback&&this.animationCallback.call(null),this.nextFrame=requestAnimationFrame(l)):l(),this.animationCallback=r}}},{key:`animatedZoom`,value:function(e){return e?typeof e==`number`?this.animate({ratio:this.ratio/e}):this.animate({ratio:this.ratio/(e.factor||ii)},e):this.animate({ratio:this.ratio/ii})}},{key:`animatedUnzoom`,value:function(e){return e?typeof e==`number`?this.animate({ratio:this.ratio*e}):this.animate({ratio:this.ratio*(e.factor||ii)},e):this.animate({ratio:this.ratio*ii})}},{key:`animatedReset`,value:function(e){return this.animate({x:.5,y:.5,ratio:1,angle:0},e)}},{key:`copy`,value:function(){return t.from(this.getState())}}],[{key:`from`,value:function(e){return new t().setState(e)}}])}(Ar);function oi(e,t){var n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}}function si(e,t){var n=N(N({},oi(e,t)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0},original:e});return n}function ci(e){var t=`x`in e?e:N(N({},e.touches[0]||e.previousTouches[0]),{},{original:e.original,sigmaDefaultPrevented:e.sigmaDefaultPrevented,preventSigmaDefault:function(){e.sigmaDefaultPrevented=!0,t.sigmaDefaultPrevented=!0}});return t}function li(e,t){return N(N({},si(e,t)),{},{delta:pi(e)})}var ui=2;function di(e){for(var t=[],n=0,r=Math.min(e.length,ui);n<r;n++)t.push(e[n]);return t}function fi(e,t,n){var r={touches:di(e.touches).map(function(e){return oi(e,n)}),previousTouches:t.map(function(e){return oi(e,n)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){r.sigmaDefaultPrevented=!0},original:e};return r}function pi(e){if(e.deltaY!==void 0)return e.deltaY*-3/360;if(e.detail!==void 0)return e.detail/-9;throw Error(`Captor: could not extract delta from event.`)}var mi=function(e){function t(e,n){var r;return tn(this,t),r=ln(this,t),r.container=e,r.renderer=n,r}return dn(t,e),rn(t)}(Ar),hi=[`doubleClickTimeout`,`doubleClickZoomingDuration`,`doubleClickZoomingRatio`,`dragTimeout`,`draggedEventsTolerance`,`inertiaDuration`,`inertiaRatio`,`zoomDuration`,`zoomingRatio`].reduce(function(e,t){return N(N({},e),{},M({},t,$r[t]))},{}),gi=function(e){function t(e,n){var r;return tn(this,t),r=ln(this,t,[e,n]),M(r,`enabled`,!0),M(r,`draggedEvents`,0),M(r,`downStartTime`,null),M(r,`lastMouseX`,null),M(r,`lastMouseY`,null),M(r,`isMouseDown`,!1),M(r,`isMoving`,!1),M(r,`movingTimeout`,null),M(r,`startCameraState`,null),M(r,`clicks`,0),M(r,`doubleClickTimeout`,null),M(r,`currentWheelDirection`,0),M(r,`settings`,hi),r.handleClick=r.handleClick.bind(r),r.handleRightClick=r.handleRightClick.bind(r),r.handleDown=r.handleDown.bind(r),r.handleUp=r.handleUp.bind(r),r.handleMove=r.handleMove.bind(r),r.handleWheel=r.handleWheel.bind(r),r.handleLeave=r.handleLeave.bind(r),r.handleEnter=r.handleEnter.bind(r),e.addEventListener(`click`,r.handleClick,{capture:!1}),e.addEventListener(`contextmenu`,r.handleRightClick,{capture:!1}),e.addEventListener(`mousedown`,r.handleDown,{capture:!1}),e.addEventListener(`wheel`,r.handleWheel,{capture:!1}),e.addEventListener(`mouseleave`,r.handleLeave,{capture:!1}),e.addEventListener(`mouseenter`,r.handleEnter,{capture:!1}),document.addEventListener(`mousemove`,r.handleMove,{capture:!1}),document.addEventListener(`mouseup`,r.handleUp,{capture:!1}),r}return dn(t,e),rn(t,[{key:`kill`,value:function(){var e=this.container;e.removeEventListener(`click`,this.handleClick),e.removeEventListener(`contextmenu`,this.handleRightClick),e.removeEventListener(`mousedown`,this.handleDown),e.removeEventListener(`wheel`,this.handleWheel),e.removeEventListener(`mouseleave`,this.handleLeave),e.removeEventListener(`mouseenter`,this.handleEnter),document.removeEventListener(`mousemove`,this.handleMove),document.removeEventListener(`mouseup`,this.handleUp)}},{key:`handleClick`,value:function(e){var t=this;if(this.enabled){if(this.clicks++,this.clicks===2)return this.clicks=0,typeof this.doubleClickTimeout==`number`&&(clearTimeout(this.doubleClickTimeout),this.doubleClickTimeout=null),this.handleDoubleClick(e);setTimeout(function(){t.clicks=0,t.doubleClickTimeout=null},this.settings.doubleClickTimeout),this.draggedEvents<this.settings.draggedEventsTolerance&&this.emit(`click`,si(e,this.container))}}},{key:`handleRightClick`,value:function(e){this.enabled&&this.emit(`rightClick`,si(e,this.container))}},{key:`handleDoubleClick`,value:function(e){if(this.enabled){e.preventDefault(),e.stopPropagation();var t=si(e,this.container);if(this.emit(`doubleClick`,t),!t.sigmaDefaultPrevented){var n=this.renderer.getCamera(),r=n.getBoundedRatio(n.getState().ratio/this.settings.doubleClickZoomingRatio);n.animate(this.renderer.getViewportZoomedState(oi(e,this.container),r),{easing:`quadraticInOut`,duration:this.settings.doubleClickZoomingDuration})}}}},{key:`handleDown`,value:function(e){if(this.enabled){if(e.button===0){this.startCameraState=this.renderer.getCamera().getState();var t=oi(e,this.container),n=t.x,r=t.y;this.lastMouseX=n,this.lastMouseY=r,this.draggedEvents=0,this.downStartTime=Date.now(),this.isMouseDown=!0}this.emit(`mousedown`,si(e,this.container))}}},{key:`handleUp`,value:function(e){var t=this;if(this.enabled&&this.isMouseDown){var n=this.renderer.getCamera();this.isMouseDown=!1,typeof this.movingTimeout==`number`&&(clearTimeout(this.movingTimeout),this.movingTimeout=null);var r=oi(e,this.container),i=r.x,a=r.y,o=n.getState(),s=n.getPreviousState()||{x:0,y:0};this.isMoving?n.animate({x:o.x+this.settings.inertiaRatio*(o.x-s.x),y:o.y+this.settings.inertiaRatio*(o.y-s.y)},{duration:this.settings.inertiaDuration,easing:`quadraticOut`}):(this.lastMouseX!==i||this.lastMouseY!==a)&&n.setState({x:o.x,y:o.y}),this.isMoving=!1,setTimeout(function(){var e=t.draggedEvents>0;t.draggedEvents=0,e&&t.renderer.getSetting(`hideEdgesOnMove`)&&t.renderer.refresh()},0),this.emit(`mouseup`,si(e,this.container))}}},{key:`handleMove`,value:function(e){var t=this;if(this.enabled){var n=si(e,this.container);if(this.emit(`mousemovebody`,n),(e.target===this.container||e.composedPath()[0]===this.container)&&this.emit(`mousemove`,n),!n.sigmaDefaultPrevented&&this.isMouseDown){this.isMoving=!0,this.draggedEvents++,typeof this.movingTimeout==`number`&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){t.movingTimeout=null,t.isMoving=!1},this.settings.dragTimeout);var r=this.renderer.getCamera(),i=oi(e,this.container),a=i.x,o=i.y,s=this.renderer.viewportToFramedGraph({x:this.lastMouseX,y:this.lastMouseY}),c=this.renderer.viewportToFramedGraph({x:a,y:o}),l=s.x-c.x,u=s.y-c.y,d=r.getState(),f=d.x+l,p=d.y+u;r.setState({x:f,y:p}),this.lastMouseX=a,this.lastMouseY=o,e.preventDefault(),e.stopPropagation()}}}},{key:`handleLeave`,value:function(e){this.emit(`mouseleave`,si(e,this.container))}},{key:`handleEnter`,value:function(e){this.emit(`mouseenter`,si(e,this.container))}},{key:`handleWheel`,value:function(e){var t=this,n=this.renderer.getCamera();if(this.enabled&&n.enabledZooming){var r=pi(e);if(r){var i=li(e,this.container);if(this.emit(`wheel`,i),i.sigmaDefaultPrevented)e.preventDefault(),e.stopPropagation();else{var a=n.getState().ratio,o=r>0?1/this.settings.zoomingRatio:this.settings.zoomingRatio,s=n.getBoundedRatio(a*o),c=r>0?1:-1,l=Date.now();a!==s&&(e.preventDefault(),e.stopPropagation(),this.currentWheelDirection===c&&this.lastWheelTriggerTime&&l-this.lastWheelTriggerTime<this.settings.zoomDuration/5||(n.animate(this.renderer.getViewportZoomedState(oi(e,this.container),s),{easing:`quadraticOut`,duration:this.settings.zoomDuration},function(){t.currentWheelDirection=0}),this.currentWheelDirection=c,this.lastWheelTriggerTime=l))}}}}},{key:`setSettings`,value:function(e){this.settings=e}}])}(mi),_i=[`dragTimeout`,`inertiaDuration`,`inertiaRatio`,`doubleClickTimeout`,`doubleClickZoomingRatio`,`doubleClickZoomingDuration`,`tapMoveTolerance`].reduce(function(e,t){return N(N({},e),{},M({},t,$r[t]))},{}),vi=function(e){function t(e,n){var r;return tn(this,t),r=ln(this,t,[e,n]),M(r,`enabled`,!0),M(r,`isMoving`,!1),M(r,`hasMoved`,!1),M(r,`touchMode`,0),M(r,`startTouchesPositions`,[]),M(r,`lastTouches`,[]),M(r,`lastTap`,null),M(r,`settings`,_i),r.handleStart=r.handleStart.bind(r),r.handleLeave=r.handleLeave.bind(r),r.handleMove=r.handleMove.bind(r),e.addEventListener(`touchstart`,r.handleStart,{capture:!1}),e.addEventListener(`touchcancel`,r.handleLeave,{capture:!1}),document.addEventListener(`touchend`,r.handleLeave,{capture:!1,passive:!1}),document.addEventListener(`touchmove`,r.handleMove,{capture:!1,passive:!1}),r}return dn(t,e),rn(t,[{key:`kill`,value:function(){var e=this.container;e.removeEventListener(`touchstart`,this.handleStart),e.removeEventListener(`touchcancel`,this.handleLeave),document.removeEventListener(`touchend`,this.handleLeave),document.removeEventListener(`touchmove`,this.handleMove)}},{key:`getDimensions`,value:function(){return{width:this.container.offsetWidth,height:this.container.offsetHeight}}},{key:`handleStart`,value:function(e){var t=this;if(this.enabled){e.preventDefault();var n=di(e.touches);if(this.touchMode=n.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=n.map(function(e){return oi(e,t.container)}),this.touchMode===2){var r=_n(this.startTouchesPositions,2),i=r[0],a=i.x,o=i.y,s=r[1],c=s.x,l=s.y;this.startTouchesAngle=Math.atan2(l-o,c-a),this.startTouchesDistance=Math.sqrt((c-a)**2+(l-o)**2)}this.emit(`touchdown`,fi(e,this.lastTouches,this.container)),this.lastTouches=n,this.lastTouchesPositions=this.startTouchesPositions}}},{key:`handleLeave`,value:function(e){if(this.enabled&&this.startTouchesPositions.length){switch(e.cancelable&&e.preventDefault(),this.movingTimeout&&(this.isMoving=!1,clearTimeout(this.movingTimeout)),this.touchMode){case 2:if(e.touches.length===1){this.handleStart(e),e.preventDefault();break}case 1:if(this.isMoving){var t=this.renderer.getCamera(),n=t.getState(),r=t.getPreviousState()||{x:0,y:0};t.animate({x:n.x+this.settings.inertiaRatio*(n.x-r.x),y:n.y+this.settings.inertiaRatio*(n.y-r.y)},{duration:this.settings.inertiaDuration,easing:`quadraticOut`})}this.hasMoved=!1,this.isMoving=!1,this.touchMode=0}if(this.emit(`touchup`,fi(e,this.lastTouches,this.container)),!e.touches.length){var i=oi(this.lastTouches[0],this.container),a=this.startTouchesPositions[0],o=(i.x-a.x)**2+(i.y-a.y)**2;if(!e.touches.length&&o<this.settings.tapMoveTolerance**2){if(this.lastTap&&Date.now()-this.lastTap.time<this.settings.doubleClickTimeout){var s=fi(e,this.lastTouches,this.container);if(this.emit(`doubletap`,s),this.lastTap=null,!s.sigmaDefaultPrevented){var c=this.renderer.getCamera(),l=c.getBoundedRatio(c.getState().ratio/this.settings.doubleClickZoomingRatio);c.animate(this.renderer.getViewportZoomedState(i,l),{easing:`quadraticInOut`,duration:this.settings.doubleClickZoomingDuration})}}else{var u=fi(e,this.lastTouches,this.container);this.emit(`tap`,u),this.lastTap={time:Date.now(),position:u.touches[0]||u.previousTouches[0]}}}}this.lastTouches=di(e.touches),this.startTouchesPositions=[]}}},{key:`handleMove`,value:function(e){var t=this;if(this.enabled&&this.startTouchesPositions.length){e.preventDefault();var n=di(e.touches),r=n.map(function(e){return oi(e,t.container)}),i=this.lastTouches;this.lastTouches=n,this.lastTouchesPositions=r;var a=fi(e,i,this.container);if(this.emit(`touchmove`,a),!a.sigmaDefaultPrevented&&(this.hasMoved||=r.some(function(e,n){var r=t.startTouchesPositions[n];return r&&(e.x!==r.x||e.y!==r.y)}),this.hasMoved)){this.isMoving=!0,this.movingTimeout&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){t.isMoving=!1},this.settings.dragTimeout);var o=this.renderer.getCamera(),s=this.startCameraState,c=this.renderer.getSetting(`stagePadding`);switch(this.touchMode){case 1:var l=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0]),u=l.x,d=l.y,f=this.renderer.viewportToFramedGraph(r[0]),p=f.x,m=f.y;o.setState({x:s.x+u-p,y:s.y+d-m});break;case 2:var h={x:.5,y:.5,angle:0,ratio:1},g=r[0],_=g.x,v=g.y,y=r[1],b=y.x,x=y.y,S=Math.atan2(x-v,b-_)-this.startTouchesAngle,C=Math.hypot(x-v,b-_)/this.startTouchesDistance,w=o.getBoundedRatio(s.ratio/C);h.ratio=w,h.angle=s.angle+S;var T=this.getDimensions(),ee=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:s}),te=Math.min(T.width,T.height)-2*c,ne=te/T.width,re=te/T.height,ie=w/te,ae=_-te/2/ne,oe=v-te/2/re,se=[ae*Math.cos(-h.angle)-oe*Math.sin(-h.angle),oe*Math.cos(-h.angle)+ae*Math.sin(-h.angle)];ae=se[0],oe=se[1],h.x=ee.x-ae*ie,h.y=ee.y+oe*ie,o.setState(h)}}}}},{key:`setSettings`,value:function(e){this.settings=e}}])}(mi);function yi(e){if(Array.isArray(e))return mn(e)}function bi(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function xi(){throw TypeError(`Invalid attempt to spread non-iterable instance.
|
|
313
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function P(e){return yi(e)||bi(e)||hn(e)||xi()}function F(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Si(e,t){if(e==null)return{};var n,r,i=F(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var Ci=function(){function e(t,n){tn(this,e),this.key=t,this.size=n}return rn(e,null,[{key:`compare`,value:function(e,t){return e.size>t.size?-1:e.size<t.size||e.key>t.key?1:-1}}])}(),wi=function(){function e(){tn(this,e),M(this,`width`,0),M(this,`height`,0),M(this,`cellSize`,0),M(this,`columns`,0),M(this,`rows`,0),M(this,`cells`,{})}return rn(e,[{key:`resizeAndClear`,value:function(e,t){this.width=e.width,this.height=e.height,this.cellSize=t,this.columns=Math.ceil(e.width/t),this.rows=Math.ceil(e.height/t),this.cells={}}},{key:`getIndex`,value:function(e){var t=Math.floor(e.x/this.cellSize);return Math.floor(e.y/this.cellSize)*this.columns+t}},{key:`add`,value:function(e,t,n){var r=new Ci(e,t),i=this.getIndex(n),a=this.cells[i];a||(a=[],this.cells[i]=a),a.push(r)}},{key:`organize`,value:function(){for(var e in this.cells)this.cells[e].sort(Ci.compare)}},{key:`getLabelsToDisplay`,value:function(e,t){var n=this.cellSize*this.cellSize,r=n/e/e*t/n,i=Math.ceil(r),a=[];for(var o in this.cells)for(var s=this.cells[o],c=0;c<Math.min(i,s.length);c++)a.push(s[c].key);return a}}])}();function I(e){var t=e.graph,n=e.hoveredNode,r=e.highlightedNodes,i=e.displayedNodeLabels,a=[];return t.forEachEdge(function(e,t,o,s){(o===n||s===n||r.has(o)||r.has(s)||i.has(o)&&i.has(s))&&a.push(e)}),a}var L=150,Ti=50,Ei=Object.prototype.hasOwnProperty;function Di(e,t,n){if(!Ei.call(n,`x`)||!Ei.call(n,`y`))throw Error(`Sigma: could not find a valid position (x, y) for node "${t}". All your nodes must have a number "x" and "y". Maybe your forgot to apply a layout or your "nodeReducer" is not returning the correct data?`);return n.color||=e.defaultNodeColor,!n.label&&n.label!==``&&(n.label=null),n.label=n.label!==void 0&&n.label!==null?``+n.label:null,n.size||=2,Ei.call(n,`hidden`)||(n.hidden=!1),Ei.call(n,`highlighted`)||(n.highlighted=!1),Ei.call(n,`forceLabel`)||(n.forceLabel=!1),n.type&&n.type!==``||(n.type=e.defaultNodeType),n.zIndex||=0,n}function Oi(e,t,n){return n.color||=e.defaultEdgeColor,n.label||=``,n.size||=.5,Ei.call(n,`hidden`)||(n.hidden=!1),Ei.call(n,`forceLabel`)||(n.forceLabel=!1),n.type&&n.type!==``||(n.type=e.defaultEdgeType),n.zIndex||=0,n}var R=function(e){function t(e,n){var r,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(tn(this,t),r=ln(this,t),M(r,`elements`,{}),M(r,`canvasContexts`,{}),M(r,`webGLContexts`,{}),M(r,`pickingLayers`,new Set),M(r,`textures`,{}),M(r,`frameBuffers`,{}),M(r,`activeListeners`,{}),M(r,`labelGrid`,new wi),M(r,`nodeDataCache`,{}),M(r,`edgeDataCache`,{}),M(r,`nodeProgramIndex`,{}),M(r,`edgeProgramIndex`,{}),M(r,`nodesWithForcedLabels`,new Set),M(r,`edgesWithForcedLabels`,new Set),M(r,`nodeExtent`,{x:[0,1],y:[0,1]}),M(r,`nodeZExtent`,[1/0,-1/0]),M(r,`edgeZExtent`,[1/0,-1/0]),M(r,`matrix`,Fr()),M(r,`invMatrix`,Fr()),M(r,`correctionRatio`,1),M(r,`customBBox`,null),M(r,`normalizationFunction`,Yr({x:[0,1],y:[0,1]})),M(r,`graphToViewportRatio`,1),M(r,`itemIDsIndex`,{}),M(r,`nodeIndices`,{}),M(r,`edgeIndices`,{}),M(r,`width`,0),M(r,`height`,0),M(r,`pixelRatio`,qr()),M(r,`pickingDownSizingRatio`,2*r.pixelRatio),M(r,`displayedNodeLabels`,new Set),M(r,`displayedEdgeLabels`,new Set),M(r,`highlightedNodes`,new Set),M(r,`hoveredNode`,null),M(r,`hoveredEdge`,null),M(r,`renderFrame`,null),M(r,`renderHighlightedNodesFrame`,null),M(r,`needToProcess`,!1),M(r,`checkEdgesEventsFrame`,null),M(r,`nodePrograms`,{}),M(r,`nodeHoverPrograms`,{}),M(r,`edgePrograms`,{}),r.settings=ri(i),ni(r.settings),Gr(e),!(n instanceof HTMLElement))throw Error(`Sigma: container should be an html element.`);for(var a in r.graph=e,r.container=n,r.createWebGLContext(`edges`,{picking:i.enableEdgeEvents}),r.createCanvasContext(`edgeLabels`),r.createWebGLContext(`nodes`,{picking:!0}),r.createCanvasContext(`labels`),r.createCanvasContext(`hovers`),r.createWebGLContext(`hoverNodes`),r.createCanvasContext(`mouse`,{style:{touchAction:`none`,userSelect:`none`}}),r.resize(),r.settings.nodeProgramClasses)r.registerNodeProgram(a,r.settings.nodeProgramClasses[a],r.settings.nodeHoverProgramClasses[a]);for(var o in r.settings.edgeProgramClasses)r.registerEdgeProgram(o,r.settings.edgeProgramClasses[o]);return r.camera=new ai,r.bindCameraHandlers(),r.mouseCaptor=new gi(r.elements.mouse,r),r.mouseCaptor.setSettings(r.settings),r.touchCaptor=new vi(r.elements.mouse,r),r.touchCaptor.setSettings(r.settings),r.bindEventHandlers(),r.bindGraphHandlers(),r.handleSettingsUpdate(),r.refresh(),r}return dn(t,e),rn(t,[{key:`registerNodeProgram`,value:function(e,t,n){return this.nodePrograms[e]&&this.nodePrograms[e].kill(),this.nodeHoverPrograms[e]&&this.nodeHoverPrograms[e].kill(),this.nodePrograms[e]=new t(this.webGLContexts.nodes,this.frameBuffers.nodes,this),this.nodeHoverPrograms[e]=new(n||t)(this.webGLContexts.hoverNodes,null,this),this}},{key:`registerEdgeProgram`,value:function(e,t){return this.edgePrograms[e]&&this.edgePrograms[e].kill(),this.edgePrograms[e]=new t(this.webGLContexts.edges,this.frameBuffers.edges,this),this}},{key:`unregisterNodeProgram`,value:function(e){if(this.nodePrograms[e]){var t=this.nodePrograms,n=t[e],r=Si(t,[e].map(en));n.kill(),this.nodePrograms=r}if(this.nodeHoverPrograms[e]){var i=this.nodeHoverPrograms,a=i[e],o=Si(i,[e].map(en));a.kill(),this.nodePrograms=o}return this}},{key:`unregisterEdgeProgram`,value:function(e){if(this.edgePrograms[e]){var t=this.edgePrograms,n=t[e],r=Si(t,[e].map(en));n.kill(),this.edgePrograms=r}return this}},{key:`resetWebGLTexture`,value:function(e){var t=this.webGLContexts[e],n=this.frameBuffers[e],r=this.textures[e];r&&t.deleteTexture(r);var i=t.createTexture();return t.bindFramebuffer(t.FRAMEBUFFER,n),t.bindTexture(t.TEXTURE_2D,i),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,this.width,this.height,0,t.RGBA,t.UNSIGNED_BYTE,null),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i,0),this.textures[e]=i,this}},{key:`bindCameraHandlers`,value:function(){var e=this;return this.activeListeners.camera=function(){e.scheduleRender()},this.camera.on(`updated`,this.activeListeners.camera),this}},{key:`unbindCameraHandlers`,value:function(){return this.camera.removeListener(`updated`,this.activeListeners.camera),this}},{key:`getNodeAtPosition`,value:function(e){var t=e.x,n=e.y,r=Mn(this.webGLContexts.nodes,this.frameBuffers.nodes,t,n,this.pixelRatio,this.pickingDownSizingRatio),i=jn.apply(void 0,P(r)),a=this.itemIDsIndex[i];return a&&a.type===`node`?a.id:null}},{key:`bindEventHandlers`,value:function(){var e=this;this.activeListeners.handleResize=function(){e.scheduleRefresh()},window.addEventListener(`resize`,this.activeListeners.handleResize),this.activeListeners.handleMove=function(t){var n=ci(t),r={event:n,preventSigmaDefault:function(){n.preventSigmaDefault()}},i=e.getNodeAtPosition(n);if(i&&e.hoveredNode!==i&&!e.nodeDataCache[i].hidden)e.hoveredNode&&e.emit(`leaveNode`,N(N({},r),{},{node:e.hoveredNode})),e.hoveredNode=i,e.emit(`enterNode`,N(N({},r),{},{node:i})),e.scheduleHighlightedNodesRender();else if(e.hoveredNode&&e.getNodeAtPosition(n)!==e.hoveredNode){var a=e.hoveredNode;e.hoveredNode=null,e.emit(`leaveNode`,N(N({},r),{},{node:a})),e.scheduleHighlightedNodesRender()}else if(e.settings.enableEdgeEvents){var o=e.hoveredNode?null:e.getEdgeAtPoint(r.event.x,r.event.y);o!==e.hoveredEdge&&(e.hoveredEdge&&e.emit(`leaveEdge`,N(N({},r),{},{edge:e.hoveredEdge})),o&&e.emit(`enterEdge`,N(N({},r),{},{edge:o})),e.hoveredEdge=o)}},this.activeListeners.handleMoveBody=function(t){var n=ci(t);e.emit(`moveBody`,{event:n,preventSigmaDefault:function(){n.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(t){var n=ci(t),r={event:n,preventSigmaDefault:function(){n.preventSigmaDefault()}};e.hoveredNode&&(e.emit(`leaveNode`,N(N({},r),{},{node:e.hoveredNode})),e.scheduleHighlightedNodesRender()),e.settings.enableEdgeEvents&&e.hoveredEdge&&(e.emit(`leaveEdge`,N(N({},r),{},{edge:e.hoveredEdge})),e.scheduleHighlightedNodesRender()),e.emit(`leaveStage`,N({},r))},this.activeListeners.handleEnter=function(t){var n=ci(t),r={event:n,preventSigmaDefault:function(){n.preventSigmaDefault()}};e.emit(`enterStage`,N({},r))};var t=function(t){return function(n){var r=ci(n),i={event:r,preventSigmaDefault:function(){r.preventSigmaDefault()}},a=e.getNodeAtPosition(r);if(a)return e.emit(`${t}Node`,N(N({},i),{},{node:a}));if(e.settings.enableEdgeEvents){var o=e.getEdgeAtPoint(r.x,r.y);if(o)return e.emit(`${t}Edge`,N(N({},i),{},{edge:o}))}return e.emit(`${t}Stage`,i)}};return this.activeListeners.handleClick=t(`click`),this.activeListeners.handleRightClick=t(`rightClick`),this.activeListeners.handleDoubleClick=t(`doubleClick`),this.activeListeners.handleWheel=t(`wheel`),this.activeListeners.handleDown=t(`down`),this.activeListeners.handleUp=t(`up`),this.mouseCaptor.on(`mousemove`,this.activeListeners.handleMove),this.mouseCaptor.on(`mousemovebody`,this.activeListeners.handleMoveBody),this.mouseCaptor.on(`click`,this.activeListeners.handleClick),this.mouseCaptor.on(`rightClick`,this.activeListeners.handleRightClick),this.mouseCaptor.on(`doubleClick`,this.activeListeners.handleDoubleClick),this.mouseCaptor.on(`wheel`,this.activeListeners.handleWheel),this.mouseCaptor.on(`mousedown`,this.activeListeners.handleDown),this.mouseCaptor.on(`mouseup`,this.activeListeners.handleUp),this.mouseCaptor.on(`mouseleave`,this.activeListeners.handleLeave),this.mouseCaptor.on(`mouseenter`,this.activeListeners.handleEnter),this.touchCaptor.on(`touchdown`,this.activeListeners.handleDown),this.touchCaptor.on(`touchdown`,this.activeListeners.handleMove),this.touchCaptor.on(`touchup`,this.activeListeners.handleUp),this.touchCaptor.on(`touchmove`,this.activeListeners.handleMove),this.touchCaptor.on(`tap`,this.activeListeners.handleClick),this.touchCaptor.on(`doubletap`,this.activeListeners.handleDoubleClick),this.touchCaptor.on(`touchmove`,this.activeListeners.handleMoveBody),this}},{key:`bindGraphHandlers`,value:function(){var e=this,t=this.graph,n=new Set([`x`,`y`,`zIndex`,`type`]);return this.activeListeners.eachNodeAttributesUpdatedGraphUpdate=function(r){var i=r.hints?.attributes;e.graph.forEachNode(function(t){return e.updateNode(t)});var a=!i||i.some(function(e){return n.has(e)});e.refresh({partialGraph:{nodes:t.nodes()},skipIndexation:!a,schedule:!0})},this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate=function(n){var r=n.hints?.attributes;e.graph.forEachEdge(function(t){return e.updateEdge(t)});var i=r&&[`zIndex`,`type`].some(function(e){return r?.includes(e)});e.refresh({partialGraph:{edges:t.edges()},skipIndexation:!i,schedule:!0})},this.activeListeners.addNodeGraphUpdate=function(t){var n=t.key;e.addNode(n),e.refresh({partialGraph:{nodes:[n]},skipIndexation:!1,schedule:!0})},this.activeListeners.updateNodeGraphUpdate=function(t){var n=t.key;e.refresh({partialGraph:{nodes:[n]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropNodeGraphUpdate=function(t){var n=t.key;e.removeNode(n),e.refresh({schedule:!0})},this.activeListeners.addEdgeGraphUpdate=function(t){var n=t.key;e.addEdge(n),e.refresh({partialGraph:{edges:[n]},schedule:!0})},this.activeListeners.updateEdgeGraphUpdate=function(t){var n=t.key;e.refresh({partialGraph:{edges:[n]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropEdgeGraphUpdate=function(t){var n=t.key;e.removeEdge(n),e.refresh({schedule:!0})},this.activeListeners.clearEdgesGraphUpdate=function(){e.clearEdgeState(),e.clearEdgeIndices(),e.refresh({schedule:!0})},this.activeListeners.clearGraphUpdate=function(){e.clearEdgeState(),e.clearNodeState(),e.clearEdgeIndices(),e.clearNodeIndices(),e.refresh({schedule:!0})},t.on(`nodeAdded`,this.activeListeners.addNodeGraphUpdate),t.on(`nodeDropped`,this.activeListeners.dropNodeGraphUpdate),t.on(`nodeAttributesUpdated`,this.activeListeners.updateNodeGraphUpdate),t.on(`eachNodeAttributesUpdated`,this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),t.on(`edgeAdded`,this.activeListeners.addEdgeGraphUpdate),t.on(`edgeDropped`,this.activeListeners.dropEdgeGraphUpdate),t.on(`edgeAttributesUpdated`,this.activeListeners.updateEdgeGraphUpdate),t.on(`eachEdgeAttributesUpdated`,this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),t.on(`edgesCleared`,this.activeListeners.clearEdgesGraphUpdate),t.on(`cleared`,this.activeListeners.clearGraphUpdate),this}},{key:`unbindGraphHandlers`,value:function(){var e=this.graph;e.removeListener(`nodeAdded`,this.activeListeners.addNodeGraphUpdate),e.removeListener(`nodeDropped`,this.activeListeners.dropNodeGraphUpdate),e.removeListener(`nodeAttributesUpdated`,this.activeListeners.updateNodeGraphUpdate),e.removeListener(`eachNodeAttributesUpdated`,this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),e.removeListener(`edgeAdded`,this.activeListeners.addEdgeGraphUpdate),e.removeListener(`edgeDropped`,this.activeListeners.dropEdgeGraphUpdate),e.removeListener(`edgeAttributesUpdated`,this.activeListeners.updateEdgeGraphUpdate),e.removeListener(`eachEdgeAttributesUpdated`,this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),e.removeListener(`edgesCleared`,this.activeListeners.clearEdgesGraphUpdate),e.removeListener(`cleared`,this.activeListeners.clearGraphUpdate)}},{key:`getEdgeAtPoint`,value:function(e,t){var n=Mn(this.webGLContexts.edges,this.frameBuffers.edges,e,t,this.pixelRatio,this.pickingDownSizingRatio),r=jn.apply(void 0,P(n)),i=this.itemIDsIndex[r];return i&&i.type===`edge`?i.id:null}},{key:`process`,value:function(){var e=this;this.emit(`beforeProcess`);var t=this.graph,n=this.settings,r=this.getDimensions();if(this.nodeExtent=Wr(this.graph),!this.settings.autoRescale){var i=r.width,a=r.height,o=this.nodeExtent,s=o.x,c=o.y;this.nodeExtent={x:[(s[0]+s[1])/2-i/2,(s[0]+s[1])/2+i/2],y:[(c[0]+c[1])/2-a/2,(c[0]+c[1])/2+a/2]}}this.normalizationFunction=Yr(this.customBBox||this.nodeExtent);var l=Hr(new ai().getState(),r,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(r,n.labelGridCellSize);for(var u={},d={},f={},p={},m=1,h=t.nodes(),g=0,_=h.length;g<_;g++){var v=h[g],y=this.nodeDataCache[v],b=t.getNodeAttributes(v);y.x=b.x,y.y=b.y,this.normalizationFunction.applyTo(y),typeof y.label==`string`&&!y.hidden&&this.labelGrid.add(v,y.size,this.framedGraphToViewport(y,{matrix:l})),u[y.type]=(u[y.type]||0)+1}for(var x in this.labelGrid.organize(),this.nodePrograms){if(!Ei.call(this.nodePrograms,x))throw Error(`Sigma: could not find a suitable program for node type "${x}"!`);this.nodePrograms[x].reallocate(u[x]||0),u[x]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(h=Jr(this.nodeZExtent,function(t){return e.nodeDataCache[t].zIndex},h));for(var S=0,C=h.length;S<C;S++){var w=h[S];d[w]=m,p[d[w]]={type:`node`,id:w},m++;var T=this.nodeDataCache[w];this.addNodeToProgram(w,d[w],u[T.type]++)}for(var ee={},te=t.edges(),ne=0,re=te.length;ne<re;ne++){var ie=te[ne],ae=this.edgeDataCache[ie];ee[ae.type]=(ee[ae.type]||0)+1}for(var oe in this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(te=Jr(this.edgeZExtent,function(t){return e.edgeDataCache[t].zIndex},te)),this.edgePrograms){if(!Ei.call(this.edgePrograms,oe))throw Error(`Sigma: could not find a suitable program for edge type "${oe}"!`);this.edgePrograms[oe].reallocate(ee[oe]||0),ee[oe]=0}for(var se=0,ce=te.length;se<ce;se++){var le=te[se];f[le]=m,p[f[le]]={type:`edge`,id:le},m++;var E=this.edgeDataCache[le];this.addEdgeToProgram(le,f[le],ee[E.type]++)}return this.itemIDsIndex=p,this.nodeIndices=d,this.edgeIndices=f,this.emit(`afterProcess`),this}},{key:`handleSettingsUpdate`,value:function(e){var t=this,n=this.settings;if(this.camera.minRatio=n.minCameraRatio,this.camera.maxRatio=n.maxCameraRatio,this.camera.enabledZooming=n.enableCameraZooming,this.camera.enabledPanning=n.enableCameraPanning,this.camera.enabledRotation=n.enableCameraRotation,n.cameraPanBoundaries?this.camera.clean=function(e){return t.cleanCameraState(e,n.cameraPanBoundaries&&Xr(n.cameraPanBoundaries)===`object`?n.cameraPanBoundaries:{})}:this.camera.clean=null,this.camera.setState(this.camera.validateState(this.camera.getState())),e){if(e.edgeProgramClasses!==n.edgeProgramClasses){for(var r in n.edgeProgramClasses)n.edgeProgramClasses[r]!==e.edgeProgramClasses[r]&&this.registerEdgeProgram(r,n.edgeProgramClasses[r]);for(var i in e.edgeProgramClasses)n.edgeProgramClasses[i]||this.unregisterEdgeProgram(i)}if(e.nodeProgramClasses!==n.nodeProgramClasses||e.nodeHoverProgramClasses!==n.nodeHoverProgramClasses){for(var a in n.nodeProgramClasses)(n.nodeProgramClasses[a]!==e.nodeProgramClasses[a]||n.nodeHoverProgramClasses[a]!==e.nodeHoverProgramClasses[a])&&this.registerNodeProgram(a,n.nodeProgramClasses[a],n.nodeHoverProgramClasses[a]);for(var o in e.nodeProgramClasses)n.nodeProgramClasses[o]||this.unregisterNodeProgram(o)}}return this.mouseCaptor.setSettings(this.settings),this.touchCaptor.setSettings(this.settings),this}},{key:`cleanCameraState`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t.tolerance,r=n===void 0?0:n,i=t.boundaries,a=N({},e),o=i||this.nodeExtent,s=_n(o.x,2),c=s[0],l=s[1],u=_n(o.y,2),d=u[0],f=u[1],p=[this.graphToViewport({x:c,y:d},{cameraState:e}),this.graphToViewport({x:l,y:d},{cameraState:e}),this.graphToViewport({x:c,y:f},{cameraState:e}),this.graphToViewport({x:l,y:f},{cameraState:e})],m=1/0,h=-1/0,g=1/0,_=-1/0;p.forEach(function(e){var t=e.x,n=e.y;m=Math.min(m,t),h=Math.max(h,t),g=Math.min(g,n),_=Math.max(_,n)});var v=h-m,y=_-g,b=this.getDimensions(),x=b.width,S=b.height,C=0,w=0;if(v>=x?h<x-r?C=h-(x-r):m>r&&(C=m-r):h>x+r?C=h-(x+r):m<-r&&(C=m+r),y>=S?_<S-r?w=_-(S-r):g>r&&(w=g-r):_>S+r?w=_-(S+r):g<-r&&(w=g+r),C||w){var T=this.viewportToFramedGraph({x:0,y:0},{cameraState:e}),ee=this.viewportToFramedGraph({x:C,y:w},{cameraState:e});C=ee.x-T.x,w=ee.y-T.y,a.x+=C,a.y+=w}return a}},{key:`renderLabels`,value:function(){if(!this.settings.renderLabels)return this;var e=this.camera.getState(),t=this.labelGrid.getLabelsToDisplay(e.ratio,this.settings.labelDensity);Zr(t,this.nodesWithForcedLabels),this.displayedNodeLabels=new Set;for(var n=this.canvasContexts.labels,r=0,i=t.length;r<i;r++){var a=t[r],o=this.nodeDataCache[a];if(!this.displayedNodeLabels.has(a)&&!o.hidden){var s=this.framedGraphToViewport(o),c=s.x,l=s.y,u=this.scaleSize(o.size);if(!(!o.forceLabel&&u<this.settings.labelRenderedSizeThreshold)&&!(c<-L||c>this.width+L||l<-Ti||l>this.height+Ti)){this.displayedNodeLabels.add(a);var d=this.settings.defaultDrawNodeLabel;(this.nodePrograms[o.type]?.drawLabel||d)(n,N(N({key:a},o),{},{size:u,x:c,y:l}),this.settings)}}}return this}},{key:`renderEdgeLabels`,value:function(){if(!this.settings.renderEdgeLabels)return this;var e=this.canvasContexts.edgeLabels;e.clearRect(0,0,this.width,this.height);var t=I({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});Zr(t,this.edgesWithForcedLabels);for(var n=new Set,r=0,i=t.length;r<i;r++){var a=t[r],o=this.graph.extremities(a),s=this.nodeDataCache[o[0]],c=this.nodeDataCache[o[1]],l=this.edgeDataCache[a];if(!n.has(a)&&!(l.hidden||s.hidden||c.hidden)){var u=this.settings.defaultDrawEdgeLabel;(this.edgePrograms[l.type]?.drawLabel||u)(e,N(N({key:a},l),{},{size:this.scaleSize(l.size)}),N(N(N({key:o[0]},s),this.framedGraphToViewport(s)),{},{size:this.scaleSize(s.size)}),N(N(N({key:o[1]},c),this.framedGraphToViewport(c)),{},{size:this.scaleSize(c.size)}),this.settings),n.add(a)}}return this.displayedEdgeLabels=n,this}},{key:`renderHighlightedNodes`,value:function(){var e=this,t=this.canvasContexts.hovers;t.clearRect(0,0,this.width,this.height);var n=function(n){var r=e.nodeDataCache[n],i=e.framedGraphToViewport(r),a=i.x,o=i.y,s=e.scaleSize(r.size),c=e.settings.defaultDrawNodeHover;(e.nodePrograms[r.type]?.drawHover||c)(t,N(N({key:n},r),{},{size:s,x:a,y:o}),e.settings)},r=[];this.hoveredNode&&!this.nodeDataCache[this.hoveredNode].hidden&&r.push(this.hoveredNode),this.highlightedNodes.forEach(function(t){t!==e.hoveredNode&&r.push(t)}),r.forEach(function(e){return n(e)});var i={};for(var a in r.forEach(function(t){var n=e.nodeDataCache[t].type;i[n]=(i[n]||0)+1}),this.nodeHoverPrograms)this.nodeHoverPrograms[a].reallocate(i[a]||0),i[a]=0;r.forEach(function(t){var n=e.nodeDataCache[t];e.nodeHoverPrograms[n.type].process(0,i[n.type]++,n)}),this.webGLContexts.hoverNodes.clear(this.webGLContexts.hoverNodes.COLOR_BUFFER_BIT);var o=this.getRenderParams();for(var s in this.nodeHoverPrograms)this.nodeHoverPrograms[s].render(o)}},{key:`scheduleHighlightedNodesRender`,value:function(){var e=this;this.renderHighlightedNodesFrame||this.renderFrame||(this.renderHighlightedNodesFrame=requestAnimationFrame(function(){e.renderHighlightedNodesFrame=null,e.renderHighlightedNodes(),e.renderEdgeLabels()}))}},{key:`render`,value:function(){var e=this;this.emit(`beforeRender`);var t=function(){return e.emit(`afterRender`),e};if(this.renderFrame&&=(cancelAnimationFrame(this.renderFrame),null),this.resize(),this.needToProcess&&this.process(),this.needToProcess=!1,this.clear(),this.pickingLayers.forEach(function(t){return e.resetWebGLTexture(t)}),!this.graph.order)return t();var n=this.mouseCaptor,r=this.camera.isAnimated()||n.isMoving||n.draggedEvents||n.currentWheelDirection,i=this.camera.getState(),a=this.getDimensions(),o=this.getGraphDimensions(),s=this.getStagePadding();this.matrix=Hr(i,a,o,s),this.invMatrix=Hr(i,a,o,s,!0),this.correctionRatio=Ur(this.matrix,i,a),this.graphToViewportRatio=this.getGraphToViewportRatio();var c=this.getRenderParams();for(var l in this.nodePrograms)this.nodePrograms[l].render(c);if(!this.settings.hideEdgesOnMove||!r)for(var u in this.edgePrograms)this.edgePrograms[u].render(c);return this.settings.hideLabelsOnMove&&r||(this.renderLabels(),this.renderEdgeLabels(),this.renderHighlightedNodes()),t()}},{key:`addNode`,value:function(e){var t=Object.assign({},this.graph.getNodeAttributes(e));this.settings.nodeReducer&&(t=this.settings.nodeReducer(e,t));var n=Di(this.settings,e,t);this.nodeDataCache[e]=n,this.nodesWithForcedLabels.delete(e),n.forceLabel&&!n.hidden&&this.nodesWithForcedLabels.add(e),this.highlightedNodes.delete(e),n.highlighted&&!n.hidden&&this.highlightedNodes.add(e),this.settings.zIndex&&(n.zIndex<this.nodeZExtent[0]&&(this.nodeZExtent[0]=n.zIndex),n.zIndex>this.nodeZExtent[1]&&(this.nodeZExtent[1]=n.zIndex))}},{key:`updateNode`,value:function(e){this.addNode(e);var t=this.nodeDataCache[e];this.normalizationFunction.applyTo(t)}},{key:`removeNode`,value:function(e){delete this.nodeDataCache[e],delete this.nodeProgramIndex[e],this.highlightedNodes.delete(e),this.hoveredNode===e&&(this.hoveredNode=null),this.nodesWithForcedLabels.delete(e)}},{key:`addEdge`,value:function(e){var t=Object.assign({},this.graph.getEdgeAttributes(e));this.settings.edgeReducer&&(t=this.settings.edgeReducer(e,t));var n=Oi(this.settings,e,t);this.edgeDataCache[e]=n,this.edgesWithForcedLabels.delete(e),n.forceLabel&&!n.hidden&&this.edgesWithForcedLabels.add(e),this.settings.zIndex&&(n.zIndex<this.edgeZExtent[0]&&(this.edgeZExtent[0]=n.zIndex),n.zIndex>this.edgeZExtent[1]&&(this.edgeZExtent[1]=n.zIndex))}},{key:`updateEdge`,value:function(e){this.addEdge(e)}},{key:`removeEdge`,value:function(e){delete this.edgeDataCache[e],delete this.edgeProgramIndex[e],this.hoveredEdge===e&&(this.hoveredEdge=null),this.edgesWithForcedLabels.delete(e)}},{key:`clearNodeIndices`,value:function(){this.labelGrid=new wi,this.nodeExtent={x:[0,1],y:[0,1]},this.nodeDataCache={},this.edgeProgramIndex={},this.nodesWithForcedLabels=new Set,this.nodeZExtent=[1/0,-1/0],this.highlightedNodes=new Set}},{key:`clearEdgeIndices`,value:function(){this.edgeDataCache={},this.edgeProgramIndex={},this.edgesWithForcedLabels=new Set,this.edgeZExtent=[1/0,-1/0]}},{key:`clearIndices`,value:function(){this.clearEdgeIndices(),this.clearNodeIndices()}},{key:`clearNodeState`,value:function(){this.displayedNodeLabels=new Set,this.highlightedNodes=new Set,this.hoveredNode=null}},{key:`clearEdgeState`,value:function(){this.displayedEdgeLabels=new Set,this.highlightedNodes=new Set,this.hoveredEdge=null}},{key:`clearState`,value:function(){this.clearEdgeState(),this.clearNodeState()}},{key:`addNodeToProgram`,value:function(e,t,n){var r=this.nodeDataCache[e],i=this.nodePrograms[r.type];if(!i)throw Error(`Sigma: could not find a suitable program for node type "${r.type}"!`);i.process(t,n,r),this.nodeProgramIndex[e]=n}},{key:`addEdgeToProgram`,value:function(e,t,n){var r=this.edgeDataCache[e],i=this.edgePrograms[r.type];if(!i)throw Error(`Sigma: could not find a suitable program for edge type "${r.type}"!`);var a=this.graph.extremities(e),o=this.nodeDataCache[a[0]],s=this.nodeDataCache[a[1]];i.process(t,n,o,s,r),this.edgeProgramIndex[e]=n}},{key:`getRenderParams`,value:function(){return{matrix:this.matrix,invMatrix:this.invMatrix,width:this.width,height:this.height,pixelRatio:this.pixelRatio,zoomRatio:this.camera.ratio,cameraAngle:this.camera.angle,sizeRatio:1/this.scaleSize(),correctionRatio:this.correctionRatio,downSizingRatio:this.pickingDownSizingRatio,minEdgeThickness:this.settings.minEdgeThickness,antiAliasingFeather:this.settings.antiAliasingFeather}}},{key:`getStagePadding`,value:function(){var e=this.settings,t=e.stagePadding;return e.autoRescale&&t||0}},{key:`createLayer`,value:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(this.elements[e])throw Error(`Sigma: a layer named "${e}" already exists`);var r=Kr(t,{position:`absolute`},{class:`sigma-${e}`});return n.style&&Object.assign(r.style,n.style),this.elements[e]=r,`beforeLayer`in n&&n.beforeLayer?this.elements[n.beforeLayer].before(r):`afterLayer`in n&&n.afterLayer?this.elements[n.afterLayer].after(r):this.container.appendChild(r),r}},{key:`createCanvas`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.createLayer(e,`canvas`,t)}},{key:`createCanvasContext`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=this.createCanvas(e,t),r={preserveDrawingBuffer:!1,antialias:!1};return this.canvasContexts[e]=n.getContext(`2d`,r),this}},{key:`createWebGLContext`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t?.canvas||this.createCanvas(e,t);t.hidden&&n.remove();var r=N({preserveDrawingBuffer:!1,antialias:!1},t),i=n.getContext(`webgl2`,r);i||=n.getContext(`webgl`,r),i||=n.getContext(`experimental-webgl`,r);var a=i;if(this.webGLContexts[e]=a,a.blendFunc(a.ONE,a.ONE_MINUS_SRC_ALPHA),t.picking){this.pickingLayers.add(e);var o=a.createFramebuffer();if(!o)throw Error(`Sigma: cannot create a new frame buffer for layer ${e}`);this.frameBuffers[e]=o}return a}},{key:`killLayer`,value:function(e){var t=this.elements[e];if(!t)throw Error(`Sigma: cannot kill layer ${e}, which does not exist`);if(this.webGLContexts[e]){var n;(n=this.webGLContexts[e].getExtension(`WEBGL_lose_context`))==null||n.loseContext(),delete this.webGLContexts[e]}else this.canvasContexts[e]&&delete this.canvasContexts[e];return t.remove(),delete this.elements[e],this}},{key:`getCamera`,value:function(){return this.camera}},{key:`setCamera`,value:function(e){this.unbindCameraHandlers(),this.camera=e,this.bindCameraHandlers()}},{key:`getContainer`,value:function(){return this.container}},{key:`getGraph`,value:function(){return this.graph}},{key:`setGraph`,value:function(e){e!==this.graph&&(this.hoveredNode&&!e.hasNode(this.hoveredNode)&&(this.hoveredNode=null),this.hoveredEdge&&!e.hasEdge(this.hoveredEdge)&&(this.hoveredEdge=null),this.unbindGraphHandlers(),this.checkEdgesEventsFrame!==null&&(cancelAnimationFrame(this.checkEdgesEventsFrame),this.checkEdgesEventsFrame=null),this.graph=e,this.bindGraphHandlers(),this.refresh())}},{key:`getMouseCaptor`,value:function(){return this.mouseCaptor}},{key:`getTouchCaptor`,value:function(){return this.touchCaptor}},{key:`getDimensions`,value:function(){return{width:this.width,height:this.height}}},{key:`getGraphDimensions`,value:function(){var e=this.customBBox||this.nodeExtent;return{width:e.x[1]-e.x[0]||1,height:e.y[1]-e.y[0]||1}}},{key:`getNodeDisplayData`,value:function(e){var t=this.nodeDataCache[e];return t?Object.assign({},t):void 0}},{key:`getEdgeDisplayData`,value:function(e){var t=this.edgeDataCache[e];return t?Object.assign({},t):void 0}},{key:`getNodeDisplayedLabels`,value:function(){return new Set(this.displayedNodeLabels)}},{key:`getEdgeDisplayedLabels`,value:function(){return new Set(this.displayedEdgeLabels)}},{key:`getSettings`,value:function(){return N({},this.settings)}},{key:`getSetting`,value:function(e){return this.settings[e]}},{key:`setSetting`,value:function(e,t){var n=N({},this.settings);return this.settings[e]=t,ni(this.settings),this.handleSettingsUpdate(n),this.scheduleRefresh(),this}},{key:`updateSetting`,value:function(e,t){return this.setSetting(e,t(this.settings[e])),this}},{key:`setSettings`,value:function(e){var t=N({},this.settings);return this.settings=N(N({},this.settings),e),ni(this.settings),this.handleSettingsUpdate(t),this.scheduleRefresh(),this}},{key:`resize`,value:function(e){var t=this.width,n=this.height;if(this.width=this.container.offsetWidth,this.height=this.container.offsetHeight,this.pixelRatio=qr(),this.width===0){if(this.settings.allowInvalidContainer)this.width=1;else throw Error(`Sigma: Container has no width. You can set the allowInvalidContainer setting to true to stop seeing this error.`)}if(this.height===0){if(this.settings.allowInvalidContainer)this.height=1;else throw Error(`Sigma: Container has no height. You can set the allowInvalidContainer setting to true to stop seeing this error.`)}if(!e&&t===this.width&&n===this.height)return this;for(var r in this.elements){var i=this.elements[r];i.style.width=this.width+`px`,i.style.height=this.height+`px`}for(var a in this.canvasContexts)this.elements[a].setAttribute(`width`,this.width*this.pixelRatio+`px`),this.elements[a].setAttribute(`height`,this.height*this.pixelRatio+`px`),this.pixelRatio!==1&&this.canvasContexts[a].scale(this.pixelRatio,this.pixelRatio);for(var o in this.webGLContexts){this.elements[o].setAttribute(`width`,this.width*this.pixelRatio+`px`),this.elements[o].setAttribute(`height`,this.height*this.pixelRatio+`px`);var s=this.webGLContexts[o];if(s.viewport(0,0,this.width*this.pixelRatio,this.height*this.pixelRatio),this.pickingLayers.has(o)){var c=this.textures[o];c&&s.deleteTexture(c)}}return this.emit(`resize`),this}},{key:`clear`,value:function(){return this.emit(`beforeClear`),this.webGLContexts.nodes.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.nodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.edges.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.edges.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.hoverNodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.canvasContexts.labels.clearRect(0,0,this.width,this.height),this.canvasContexts.hovers.clearRect(0,0,this.width,this.height),this.canvasContexts.edgeLabels.clearRect(0,0,this.width,this.height),this.emit(`afterClear`),this}},{key:`refresh`,value:function(e){var t=this,n=e?.skipIndexation!==void 0&&e?.skipIndexation,r=e?.schedule!==void 0&&e.schedule,i=!e||!e.partialGraph;if(i)this.clearEdgeIndices(),this.clearNodeIndices(),this.graph.forEachNode(function(e){return t.addNode(e)}),this.graph.forEachEdge(function(e){return t.addEdge(e)});else{for(var a,o=e.partialGraph?.nodes||[],s=0,c=o?.length||0;s<c;s++){var l=o[s];if(this.updateNode(l),n){var u=this.nodeProgramIndex[l];if(u===void 0)throw Error(`Sigma: node "${l}" can't be repaint`);this.addNodeToProgram(l,this.nodeIndices[l],u)}}for(var d=(e==null||(a=e.partialGraph)==null?void 0:a.edges)||[],f=0,p=d.length;f<p;f++){var m=d[f];if(this.updateEdge(m),n){var h=this.edgeProgramIndex[m];if(h===void 0)throw Error(`Sigma: edge "${m}" can't be repaint`);this.addEdgeToProgram(m,this.edgeIndices[m],h)}}}return(i||!n)&&(this.needToProcess=!0),r?this.scheduleRender():this.render(),this}},{key:`scheduleRender`,value:function(){var e=this;return this.renderFrame||=requestAnimationFrame(function(){e.render()}),this}},{key:`scheduleRefresh`,value:function(e){return this.refresh(N(N({},e),{},{schedule:!0}))}},{key:`getViewportZoomedState`,value:function(e,t){var n=this.camera.getState(),r=n.ratio,i=n.angle,a=n.x,o=n.y,s=this.settings,c=s.minCameraRatio,l=s.maxCameraRatio;typeof l==`number`&&(t=Math.min(t,l)),typeof c==`number`&&(t=Math.max(t,c));var u=t/r,d={x:this.width/2,y:this.height/2},f=this.viewportToFramedGraph(e),p=this.viewportToFramedGraph(d);return{angle:i,x:(f.x-p.x)*(1-u)+a,y:(f.y-p.y)*(1-u)+o,ratio:t}}},{key:`viewRectangle`,value:function(){var e=this.viewportToFramedGraph({x:0,y:0}),t=this.viewportToFramedGraph({x:this.width,y:0}),n=this.viewportToFramedGraph({x:0,y:this.height});return{x1:e.x,y1:e.y,x2:t.x,y2:t.y,height:t.y-n.y}}},{key:`framedGraphToViewport`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=!!t.cameraState||!!t.viewportDimensions||!!t.graphDimensions,r=Br(t.matrix?t.matrix:n?Hr(t.cameraState||this.camera.getState(),t.viewportDimensions||this.getDimensions(),t.graphDimensions||this.getGraphDimensions(),t.padding||this.getStagePadding()):this.matrix,e);return{x:(1+r.x)*this.width/2,y:(1-r.y)*this.height/2}}},{key:`viewportToFramedGraph`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=!!t.cameraState||!!t.viewportDimensions||!t.graphDimensions,r=Br(t.matrix?t.matrix:n?Hr(t.cameraState||this.camera.getState(),t.viewportDimensions||this.getDimensions(),t.graphDimensions||this.getGraphDimensions(),t.padding||this.getStagePadding(),!0):this.invMatrix,{x:e.x/this.width*2-1,y:1-e.y/this.height*2});return isNaN(r.x)&&(r.x=0),isNaN(r.y)&&(r.y=0),r}},{key:`viewportToGraph`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.normalizationFunction.inverse(this.viewportToFramedGraph(e,t))}},{key:`graphToViewport`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.framedGraphToViewport(this.normalizationFunction(e),t)}},{key:`getGraphToViewportRatio`,value:function(){var e={x:0,y:0},t={x:1,y:1},n=Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2),r=this.graphToViewport(e),i=this.graphToViewport(t);return Math.sqrt((r.x-i.x)**2+(r.y-i.y)**2)/n}},{key:`getBBox`,value:function(){return this.nodeExtent}},{key:`getCustomBBox`,value:function(){return this.customBBox}},{key:`setCustomBBox`,value:function(e){return this.customBBox=e,this.scheduleRender(),this}},{key:`kill`,value:function(){this.emit(`kill`),this.removeAllListeners(),this.unbindCameraHandlers(),window.removeEventListener(`resize`,this.activeListeners.handleResize),this.mouseCaptor.kill(),this.touchCaptor.kill(),this.unbindGraphHandlers(),this.clearIndices(),this.clearState(),this.nodeDataCache={},this.edgeDataCache={},this.highlightedNodes.clear(),this.renderFrame&&=(cancelAnimationFrame(this.renderFrame),null),this.renderHighlightedNodesFrame&&=(cancelAnimationFrame(this.renderHighlightedNodesFrame),null);for(var e=this.container;e.firstChild;)e.removeChild(e.firstChild);for(var t in this.nodePrograms)this.nodePrograms[t].kill();for(var n in this.nodeHoverPrograms)this.nodeHoverPrograms[n].kill();for(var r in this.edgePrograms)this.edgePrograms[r].kill();for(var i in this.nodePrograms={},this.nodeHoverPrograms={},this.edgePrograms={},this.elements)this.killLayer(i);this.canvasContexts={},this.webGLContexts={},this.elements={}}},{key:`scaleSize`,value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.camera.ratio;return e/this.settings.zoomToSizeRatioFunction(t)*(this.getSetting(`itemSizesReference`)===`positions`?t*this.graphToViewportRatio:1)}},{key:`getCanvases`,value:function(){var e={};for(var t in this.elements)this.elements[t]instanceof HTMLCanvasElement&&(e[t]=this.elements[t]);return e}}])}(Ar),ki=(0,E.createContext)(null),Ai=ki.Provider;function ji(){let e=(0,E.useContext)(ki);if(e==null)throw Error(`No context provided: useSigmaContext() can only be used in a descendant of <SigmaContainer>`);return e}function Mi(){return ji().sigma}function Ni(){let{sigma:e}=ji();return(0,E.useCallback)((t=>{e&&Object.keys(t).forEach((n=>{e.setSetting(n,t[n])}))}),[e])}function z(e){return new Set(Object.keys(e))}var Pi=z({clickNode:!0,rightClickNode:!0,downNode:!0,enterNode:!0,leaveNode:!0,doubleClickNode:!0,wheelNode:!0,clickEdge:!0,rightClickEdge:!0,downEdge:!0,enterEdge:!0,leaveEdge:!0,doubleClickEdge:!0,wheelEdge:!0,clickStage:!0,rightClickStage:!0,downStage:!0,doubleClickStage:!0,wheelStage:!0,beforeRender:!0,afterRender:!0,kill:!0,upStage:!0,upEdge:!0,upNode:!0,enterStage:!0,leaveStage:!0,resize:!0,afterClear:!0,afterProcess:!0,beforeClear:!0,beforeProcess:!0,moveBody:!0}),Fi=z({click:!0,rightClick:!0,doubleClick:!0,mouseup:!0,mousedown:!0,mousemove:!0,mousemovebody:!0,mouseleave:!0,mouseenter:!0,wheel:!0}),Ii=z({touchup:!0,touchdown:!0,touchmove:!0,touchmovebody:!0,tap:!0,doubletap:!0}),Li=z({updated:!0});function Ri(){let e=Mi(),t=Ni(),[n,r]=(0,E.useState)({});return(0,E.useEffect)((()=>{if(!e||!n)return;let t=n,r=Object.keys(t);return r.forEach((n=>{let r=t[n];Pi.has(n)&&e.on(n,r),Fi.has(n)&&e.getMouseCaptor().on(n,r),Ii.has(n)&&e.getTouchCaptor().on(n,r),Li.has(n)&&e.getCamera().on(n,r)})),()=>{e&&r.forEach((n=>{let r=t[n];Pi.has(n)&&e.off(n,r),Fi.has(n)&&e.getMouseCaptor().off(n,r),Ii.has(n)&&e.getTouchCaptor().off(n,r),Li.has(n)&&e.getCamera().off(n,r)}))}}),[e,n,t]),r}function zi(e,t){if(e===t)return!0;if(typeof e==`object`&&e&&typeof t==`object`&&t){if(Object.keys(e).length!=Object.keys(t).length)return!1;for(let n in e)if(!Object.hasOwn(t,n)||!zi(e[n],t[n]))return!1;return!0}return!1}function Bi(e){let t=Mi(),[n,r]=(0,E.useState)(e||{});return(0,E.useEffect)((()=>{r((t=>zi(t,e||{})?t:e||{}))}),[e]),{zoomIn:(0,E.useCallback)((e=>{t.getCamera().animatedZoom(Object.assign(Object.assign({},n),e))}),[t,n]),zoomOut:(0,E.useCallback)((e=>{t.getCamera().animatedUnzoom(Object.assign(Object.assign({},n),e))}),[t,n]),reset:(0,E.useCallback)((e=>{t.getCamera().animatedReset(Object.assign(Object.assign({},n),e))}),[t,n]),goto:(0,E.useCallback)(((e,r)=>{t.getCamera().animate(e,Object.assign(Object.assign({},n),r))}),[t,n]),gotoNode:(0,E.useCallback)(((e,r)=>{let i=t.getNodeDisplayData(e);i?t.getCamera().animate(i,Object.assign(Object.assign({},n),r)):console.warn(`Node ${e} not found`)}),[t,n])}}var Vi=(0,E.forwardRef)((({graph:e,id:t,className:n,style:r,settings:i={},children:a},o)=>{let s=(0,E.useRef)(null),c=(0,E.useRef)(null),l={className:`react-sigma ${n||``}`,id:t,style:r},[u,d]=(0,E.useState)(null),[f,p]=(0,E.useState)(i);(0,E.useEffect)((()=>{p((e=>zi(e,i)?e:i))}),[i]),(0,E.useEffect)((()=>{let t=null;if(c.current!==null){let n=new j;e&&(n=typeof e==`function`?new e:e),t=new R(n,c.current,f),d((e=>{let n=null;return e&&(n=e.getCamera().getState()),n&&t.getCamera().setState(n),t}))}return()=>{t&&t.kill()}}),[c,e,f]),(0,E.useImperativeHandle)(o,(()=>u),[u]);let m=(0,E.useMemo)((()=>u&&s.current?{sigma:u,container:s.current}:null),[u,s]),h=m===null?null:E.createElement(Ai,{value:m},a);return E.createElement(`div`,Object.assign({},l,{ref:s}),E.createElement(`div`,{className:`sigma-container`,ref:c}),h)}));async function Hi(e,t=fetch){return b(S(e.vault,`graph/visualization`,{centerId:e.centerId,depth:e.depth,limit:e.limit}),t)}var Ui=new Map([[`bold`,E.createElement(E.Fragment,null,E.createElement(`path`,{d:`M220,48V96a12,12,0,0,1-24,0V77l-35.51,35.52a12,12,0,0,1-17-17L179,60H160a12,12,0,0,1,0-24h48A12,12,0,0,1,220,48ZM95.51,143.51,60,179V160a12,12,0,0,0-24,0v48a12,12,0,0,0,12,12H96a12,12,0,0,0,0-24H77l35.52-35.51a12,12,0,0,0-17-17ZM208,148a12,12,0,0,0-12,12v19l-35.51-35.52a12,12,0,0,0-17,17L179,196H160a12,12,0,0,0,0,24h48a12,12,0,0,0,12-12V160A12,12,0,0,0,208,148ZM77,60H96a12,12,0,0,0,0-24H48A12,12,0,0,0,36,48V96a12,12,0,0,0,24,0V77l35.51,35.52a12,12,0,0,0,17-17Z`}))],[`duotone`,E.createElement(E.Fragment,null,E.createElement(`path`,{d:`M208,48V208H48V48Z`,opacity:`0.2`}),E.createElement(`path`,{d:`M216,48V96a8,8,0,0,1-16,0V67.31l-42.34,42.35a8,8,0,0,1-11.32-11.32L188.69,56H160a8,8,0,0,1,0-16h48A8,8,0,0,1,216,48ZM98.34,146.34,56,188.69V160a8,8,0,0,0-16,0v48a8,8,0,0,0,8,8H96a8,8,0,0,0,0-16H67.31l42.35-42.34a8,8,0,0,0-11.32-11.32ZM208,152a8,8,0,0,0-8,8v28.69l-42.34-42.35a8,8,0,0,0-11.32,11.32L188.69,200H160a8,8,0,0,0,0,16h48a8,8,0,0,0,8-8V160A8,8,0,0,0,208,152ZM67.31,56H96a8,8,0,0,0,0-16H48a8,8,0,0,0-8,8V96a8,8,0,0,0,16,0V67.31l42.34,42.35a8,8,0,0,0,11.32-11.32Z`}))],[`fill`,E.createElement(E.Fragment,null,E.createElement(`path`,{d:`M109.66,146.34a8,8,0,0,1,0,11.32L83.31,184l18.35,18.34A8,8,0,0,1,96,216H48a8,8,0,0,1-8-8V160a8,8,0,0,1,13.66-5.66L72,172.69l26.34-26.35A8,8,0,0,1,109.66,146.34ZM83.31,72l18.35-18.34A8,8,0,0,0,96,40H48a8,8,0,0,0-8,8V96a8,8,0,0,0,13.66,5.66L72,83.31l26.34,26.35a8,8,0,0,0,11.32-11.32ZM208,40H160a8,8,0,0,0-5.66,13.66L172.69,72,146.34,98.34a8,8,0,0,0,11.32,11.32L184,83.31l18.34,18.35A8,8,0,0,0,216,96V48A8,8,0,0,0,208,40Zm3.06,112.61a8,8,0,0,0-8.72,1.73L184,172.69l-26.34-26.35a8,8,0,0,0-11.32,11.32L172.69,184l-18.35,18.34A8,8,0,0,0,160,216h48a8,8,0,0,0,8-8V160A8,8,0,0,0,211.06,152.61Z`}))],[`light`,E.createElement(E.Fragment,null,E.createElement(`path`,{d:`M214,48V96a6,6,0,0,1-12,0V62.48l-45.76,45.76a6,6,0,0,1-8.48-8.48L193.52,54H160a6,6,0,0,1,0-12h48A6,6,0,0,1,214,48ZM99.76,147.76,54,193.52V160a6,6,0,0,0-12,0v48a6,6,0,0,0,6,6H96a6,6,0,0,0,0-12H62.48l45.76-45.76a6,6,0,0,0-8.48-8.48ZM208,154a6,6,0,0,0-6,6v33.52l-45.76-45.76a6,6,0,0,0-8.48,8.48L193.52,202H160a6,6,0,0,0,0,12h48a6,6,0,0,0,6-6V160A6,6,0,0,0,208,154ZM62.48,54H96a6,6,0,0,0,0-12H48a6,6,0,0,0-6,6V96a6,6,0,0,0,12,0V62.48l45.76,45.76a6,6,0,0,0,8.48-8.48Z`}))],[`regular`,E.createElement(E.Fragment,null,E.createElement(`path`,{d:`M216,48V96a8,8,0,0,1-16,0V67.31l-42.34,42.35a8,8,0,0,1-11.32-11.32L188.69,56H160a8,8,0,0,1,0-16h48A8,8,0,0,1,216,48ZM98.34,146.34,56,188.69V160a8,8,0,0,0-16,0v48a8,8,0,0,0,8,8H96a8,8,0,0,0,0-16H67.31l42.35-42.34a8,8,0,0,0-11.32-11.32ZM208,152a8,8,0,0,0-8,8v28.69l-42.34-42.35a8,8,0,0,0-11.32,11.32L188.69,200H160a8,8,0,0,0,0,16h48a8,8,0,0,0,8-8V160A8,8,0,0,0,208,152ZM67.31,56H96a8,8,0,0,0,0-16H48a8,8,0,0,0-8,8V96a8,8,0,0,0,16,0V67.31l42.34,42.35a8,8,0,0,0,11.32-11.32Z`}))],[`thin`,E.createElement(E.Fragment,null,E.createElement(`path`,{d:`M212,48V96a4,4,0,0,1-8,0V57.66l-49.17,49.17a4,4,0,0,1-5.66-5.66L198.34,52H160a4,4,0,0,1,0-8h48A4,4,0,0,1,212,48ZM101.17,149.17,52,198.34V160a4,4,0,0,0-8,0v48a4,4,0,0,0,4,4H96a4,4,0,0,0,0-8H57.66l49.17-49.17a4,4,0,0,0-5.66-5.66ZM208,156a4,4,0,0,0-4,4v38.34l-49.17-49.17a4,4,0,0,0-5.66,5.66L198.34,204H160a4,4,0,0,0,0,8h48a4,4,0,0,0,4-4V160A4,4,0,0,0,208,156ZM57.66,52H96a4,4,0,0,0,0-8H48a4,4,0,0,0-4,4V96a4,4,0,0,0,8,0V57.66l49.17,49.17a4,4,0,0,0,5.66-5.66Z`}))]]),Wi=E.forwardRef((e,t)=>E.createElement(ne,{ref:t,...e,weights:Ui}));Wi.displayName=`ArrowsOutIcon`;var Gi=new Map([[`bold`,E.createElement(E.Fragment,null,E.createElement(`path`,{d:`M232,116h-4.72A100.21,100.21,0,0,0,140,28.72V24a12,12,0,0,0-24,0v4.72A100.21,100.21,0,0,0,28.72,116H24a12,12,0,0,0,0,24h4.72A100.21,100.21,0,0,0,116,227.28V232a12,12,0,0,0,24,0v-4.72A100.21,100.21,0,0,0,227.28,140H232a12,12,0,0,0,0-24Zm-92,87v-3a12,12,0,0,0-24,0v3a76.15,76.15,0,0,1-63-63h3a12,12,0,0,0,0-24H53a76.15,76.15,0,0,1,63-63v3a12,12,0,0,0,24,0V53a76.15,76.15,0,0,1,63,63h-3a12,12,0,0,0,0,24h3A76.15,76.15,0,0,1,140,203ZM128,84a44,44,0,1,0,44,44A44.05,44.05,0,0,0,128,84Zm0,64a20,20,0,1,1,20-20A20,20,0,0,1,128,148Z`}))],[`duotone`,E.createElement(E.Fragment,null,E.createElement(`path`,{d:`M160,128a32,32,0,1,1-32-32A32,32,0,0,1,160,128Z`,opacity:`0.2`}),E.createElement(`path`,{d:`M232,120h-8.34A96.14,96.14,0,0,0,136,32.34V24a8,8,0,0,0-16,0v8.34A96.14,96.14,0,0,0,32.34,120H24a8,8,0,0,0,0,16h8.34A96.14,96.14,0,0,0,120,223.66V232a8,8,0,0,0,16,0v-8.34A96.14,96.14,0,0,0,223.66,136H232a8,8,0,0,0,0-16Zm-96,87.6V200a8,8,0,0,0-16,0v7.6A80.15,80.15,0,0,1,48.4,136H56a8,8,0,0,0,0-16H48.4A80.15,80.15,0,0,1,120,48.4V56a8,8,0,0,0,16,0V48.4A80.15,80.15,0,0,1,207.6,120H200a8,8,0,0,0,0,16h7.6A80.15,80.15,0,0,1,136,207.6ZM128,88a40,40,0,1,0,40,40A40,40,0,0,0,128,88Zm0,64a24,24,0,1,1,24-24A24,24,0,0,1,128,152Z`}))],[`fill`,E.createElement(E.Fragment,null,E.createElement(`path`,{d:`M232,120h-8.34A96.14,96.14,0,0,0,136,32.34V24a8,8,0,0,0-16,0v8.34A96.14,96.14,0,0,0,32.34,120H24a8,8,0,0,0,0,16h8.34A96.14,96.14,0,0,0,120,223.66V232a8,8,0,0,0,16,0v-8.34A96.14,96.14,0,0,0,223.66,136H232a8,8,0,0,0,0-16Zm-32,16h7.6A80.15,80.15,0,0,1,136,207.6V200a8,8,0,0,0-16,0v7.6A80.15,80.15,0,0,1,48.4,136H56a8,8,0,0,0,0-16H48.4A80.15,80.15,0,0,1,120,48.4V56a8,8,0,0,0,16,0V48.4A80.15,80.15,0,0,1,207.6,120H200a8,8,0,0,0,0,16Zm-32-8a40,40,0,1,1-40-40A40,40,0,0,1,168,128Z`}))],[`light`,E.createElement(E.Fragment,null,E.createElement(`path`,{d:`M232,122H221.8A94.13,94.13,0,0,0,134,34.2V24a6,6,0,0,0-12,0V34.2A94.13,94.13,0,0,0,34.2,122H24a6,6,0,0,0,0,12H34.2A94.13,94.13,0,0,0,122,221.8V232a6,6,0,0,0,12,0V221.8A94.13,94.13,0,0,0,221.8,134H232a6,6,0,0,0,0-12Zm-98,87.76V200a6,6,0,0,0-12,0v9.76A82.09,82.09,0,0,1,46.24,134H56a6,6,0,0,0,0-12H46.24A82.09,82.09,0,0,1,122,46.24V56a6,6,0,0,0,12,0V46.24A82.09,82.09,0,0,1,209.76,122H200a6,6,0,0,0,0,12h9.76A82.09,82.09,0,0,1,134,209.76ZM128,90a38,38,0,1,0,38,38A38,38,0,0,0,128,90Zm0,64a26,26,0,1,1,26-26A26,26,0,0,1,128,154Z`}))],[`regular`,E.createElement(E.Fragment,null,E.createElement(`path`,{d:`M232,120h-8.34A96.14,96.14,0,0,0,136,32.34V24a8,8,0,0,0-16,0v8.34A96.14,96.14,0,0,0,32.34,120H24a8,8,0,0,0,0,16h8.34A96.14,96.14,0,0,0,120,223.66V232a8,8,0,0,0,16,0v-8.34A96.14,96.14,0,0,0,223.66,136H232a8,8,0,0,0,0-16Zm-96,87.6V200a8,8,0,0,0-16,0v7.6A80.15,80.15,0,0,1,48.4,136H56a8,8,0,0,0,0-16H48.4A80.15,80.15,0,0,1,120,48.4V56a8,8,0,0,0,16,0V48.4A80.15,80.15,0,0,1,207.6,120H200a8,8,0,0,0,0,16h7.6A80.15,80.15,0,0,1,136,207.6ZM128,88a40,40,0,1,0,40,40A40,40,0,0,0,128,88Zm0,64a24,24,0,1,1,24-24A24,24,0,0,1,128,152Z`}))],[`thin`,E.createElement(E.Fragment,null,E.createElement(`path`,{d:`M232,124H219.91A92.13,92.13,0,0,0,132,36.09V24a4,4,0,0,0-8,0V36.09A92.13,92.13,0,0,0,36.09,124H24a4,4,0,0,0,0,8H36.09A92.13,92.13,0,0,0,124,219.91V232a4,4,0,0,0,8,0V219.91A92.13,92.13,0,0,0,219.91,132H232a4,4,0,0,0,0-8ZM132,211.9V200a4,4,0,0,0-8,0v11.9A84.11,84.11,0,0,1,44.1,132H56a4,4,0,0,0,0-8H44.1A84.11,84.11,0,0,1,124,44.1V56a4,4,0,0,0,8,0V44.1A84.11,84.11,0,0,1,211.9,124H200a4,4,0,0,0,0,8h11.9A84.11,84.11,0,0,1,132,211.9ZM128,92a36,36,0,1,0,36,36A36,36,0,0,0,128,92Zm0,64a28,28,0,1,1,28-28A28,28,0,0,1,128,156Z`}))]]),Ki=E.forwardRef((e,t)=>E.createElement(ne,{ref:t,...e,weights:Gi}));Ki.displayName=`CrosshairIcon`;var B=i();function qi(e){let{zoomIn:t,zoomOut:n,reset:r}=Bi({duration:180}),[i,a]=(0,E.useState)(!1),[o,s]=(0,E.useState)(!1),[c,l]=(0,E.useState)(``),[g,_]=(0,E.useState)(0),v=(0,E.useRef)(null),y=e.selectedNode,b=(0,E.useMemo)(()=>{let t=c.trim().toLocaleLowerCase();return t?e.data.nodes.filter(e=>`${e.label}\n${e.id}`.toLocaleLowerCase().includes(t)).slice(0,20):e.data.nodes.slice(0,20)},[e.data.nodes,c]);function x(t){e.onLocate(t),a(!1)}function S(e){!e.nativeEvent.isComposing&&b.length&&(e.key===`ArrowDown`||e.key===`ArrowUp`?(e.preventDefault(),_(t=>(t+(e.key===`ArrowDown`?1:-1)+b.length)%b.length)):e.key===`Enter`&&(e.preventDefault(),x(b[Math.min(g,b.length-1)].id)))}return(0,B.jsxs)(`div`,{className:`graph-control-dock`,"aria-label":`Graph controls`,children:[(0,B.jsxs)(h,{open:i,onOpenChange:e=>{a(e),e&&(_(0),requestAnimationFrame(()=>v.current?.focus()))},label:`Find a graph node`,placement:`top-start`,mobileMode:`sheet`,className:`graph-search-popover`,trigger:(0,B.jsx)(m,{variant:`ghost`,size:`small`,"aria-label":`Search graph`,"data-keyboard-item":`true`,children:(0,B.jsx)(re,{"aria-hidden":`true`})}),children:[(0,B.jsx)(d,{ref:v,"data-popover-autofocus":`true`,type:`search`,value:c,"aria-label":`Search notes and graph objects`,placeholder:`Search the graph`,onChange:e=>{l(e.target.value),_(0)},onKeyDown:S}),(0,B.jsxs)(`div`,{className:`graph-search-results`,role:`listbox`,"aria-label":`Graph search results`,children:[b.map((e,t)=>(0,B.jsxs)(u,{variant:`ghost`,size:`small`,role:`option`,"aria-selected":t===g,className:t===g?`active`:``,onPointerMove:()=>_(t),onClick:()=>x(e.id),children:[(0,B.jsx)(`strong`,{children:e.label}),(0,B.jsx)(`span`,{className:`graph-result-id`,children:e.id})]},e.id)),!b.length&&(0,B.jsx)(p,{as:`div`,tone:`muted`,children:`No matching nodes.`})]})]}),(0,B.jsx)(m,{ref:e.queryToggleRef,variant:`ghost`,size:`small`,"aria-label":`Cypher query`,"aria-pressed":e.queryOpen,"data-keyboard-item":`true`,className:e.queryActive?`graph-query-toggle-active`:``,onClick:e.onToggleQuery,children:(0,B.jsx)(te,{"aria-hidden":`true`})}),(0,B.jsx)(m,{variant:`ghost`,size:`small`,"aria-label":`Zoom in`,"data-keyboard-item":`true`,onClick:()=>t(),children:`+`}),(0,B.jsx)(m,{variant:`ghost`,size:`small`,"aria-label":`Zoom out`,"data-keyboard-item":`true`,onClick:()=>n(),children:`−`}),(0,B.jsx)(m,{variant:`ghost`,size:`small`,"aria-label":`Fit graph`,"data-keyboard-item":`true`,onClick:()=>r(),children:(0,B.jsx)(T,{"aria-hidden":`true`})}),y&&y.id!==e.data.scope.centerId&&(0,B.jsx)(m,{variant:`ghost`,size:`small`,"aria-label":`Local graph around ${y.label}`,"data-keyboard-item":`true`,onClick:()=>e.onShowLocalGraph(y.id),children:(0,B.jsx)(Ki,{"aria-hidden":`true`})}),(0,B.jsxs)(h,{open:o,onOpenChange:s,label:`Graph display settings`,placement:`top-start`,mobileMode:`sheet`,className:`graph-settings-popover`,trigger:(0,B.jsx)(m,{variant:`ghost`,size:`small`,"aria-label":`Graph display settings`,"data-keyboard-item":`true`,children:(0,B.jsx)(ie,{"aria-hidden":`true`})}),children:[(0,B.jsxs)(`header`,{children:[(0,B.jsx)(`strong`,{children:`Display`}),(0,B.jsxs)(`span`,{children:[e.data.meta.returnedNodes.toLocaleString(),` loaded nodes`]})]}),(0,B.jsx)(f,{checked:e.showIsolated,onCheckedChange:e.onShowIsolatedChange,children:`Show unconnected notes`}),(0,B.jsx)(f,{checked:e.showLabels,onCheckedChange:e.onShowLabelsChange,children:`Show labels while exploring`}),(0,B.jsxs)(`div`,{className:`graph-settings-actions`,children:[(0,B.jsx)(u,{size:`small`,onClick:e.onShowAllCategories,children:`Show all`}),(0,B.jsx)(u,{size:`small`,onClick:e.onShowNotesOnly,children:`Notes only`})]}),(0,B.jsx)(`div`,{className:`graph-category-list`,children:e.categories.map(t=>(0,B.jsxs)(f,{checked:!e.hiddenCategories.has(t.id),onCheckedChange:()=>e.onToggleCategory(t.id),children:[(0,B.jsx)(`i`,{style:{background:t.color}}),` `,(0,B.jsx)(`span`,{children:t.label}),(0,B.jsx)(`span`,{className:`graph-category-count`,children:t.count.toLocaleString()})]},t.id))})]}),e.localMode&&(0,B.jsx)(m,{variant:`ghost`,size:`small`,"aria-label":`Return to full graph`,"data-keyboard-item":`true`,onClick:e.onShowFull,children:(0,B.jsx)(Wi,{"aria-hidden":`true`})})]})}var Ji=class{original;value;constructor(e,t){this.original=e,this.value=t}accept(e,t){return e.visitLiteral(this,t)}},Yi=class{lang;id;operands;constructor(e,t,n){this.lang=e,this.id=t,this.operands=n}accept(e,t){return e.visitOperator(this,t)}},Xi=class{lang;id;args;constructor(e,t,n){this.lang=e,this.id=t,this.args=n}accept(e,t){return e.visitFunction(this,t)}},Zi=Symbol(`all attrs`),Qi=Symbol(`bound param`),V=class e{aggregate;parts=[];[Symbol.iterator](){return this.parts[Symbol.iterator]()}accept(e,t){return e.visitIdentifier(this,t)}static fromParts(t){let n=new e;return n.parts=t,n}equals(e){if(this.parts.length!==e.parts.length)return!1;for(let t=0;t<this.parts.length;t++)if(this.parts[t]!==e.parts[t])return!1;return!0}},$i=class{lang;node;constructor(e,t){if(this.lang=e,t.length!==1)throw Error(`LangSwitch must contain exactly one statement`);this.node=t[0]}accept(e,t){return e.visitLangSwitch(this,t)}};function ea(e){return e}function ta(e,t){return t}function na(e){return e[0]}function ra(e){return e[1]}function ia(e){return[e,e]}function aa(e){return e instanceof _o}function oa(e){return e instanceof V}function sa(e){return e!==null}function ca(e){return e.clone()}function la(e){return e&&(Array.isArray(e)?[la(e[0]),e[1]]:e instanceof V?e:e.clone())}function ua(e,t){return e&&(Array.isArray(e)?[ua(e[0],t),e[1]]:e instanceof V?e:go in e||e instanceof ho?e.clone(t):e.clone())}function da(e){return Array.isArray(e)?e:Array.from(e)}function H(e){if(e.length===0)return null;if(e.length>1)throw Error(`More than one element in sequence`);return e[0]}function fa(e,t){for(let n of t)e=e?.[n];return e}function pa(e,...t){let n={};for(let r=0;r<t.length;r++)n[e[r]]=t[r];return n}function ma(e,t){let n=[];for(let r of t)n.push(e[r]);return n}var ha=typeof globalThis==`object`&&globalThis||typeof window==`object`&&window||typeof self==`object`&&self||typeof global==`object`&&global||(function(){return this})();function ga(){}function _a(e){return e==null||typeof e!=`object`&&typeof e!=`function`}function va(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function ya(e){return ha.Buffer!==void 0&&ha.Buffer.isBuffer(e)}function ba(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}function xa(e){return e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e)}var Sa=`[object RegExp]`,Ca=`[object String]`,wa=`[object Number]`,Ta=`[object Boolean]`,Ea=`[object Arguments]`,Da=`[object Symbol]`,Oa=`[object Date]`,ka=`[object Map]`,Aa=`[object Set]`,ja=`[object Array]`,U=`[object Function]`,Ma=`[object ArrayBuffer]`,Na=`[object Object]`,Pa=`[object Error]`,Fa=`[object DataView]`,Ia=`[object Uint8Array]`,La=`[object Uint8ClampedArray]`,Ra=`[object Uint16Array]`,za=`[object Uint32Array]`,Ba=`[object BigUint64Array]`,Va=`[object Int8Array]`,Ha=`[object Int16Array]`,Ua=`[object Int32Array]`,Wa=`[object BigInt64Array]`,Ga=`[object Float32Array]`,Ka=`[object Float64Array]`;function qa(e,t,n,r=new Map,i=void 0){let a=i?.(e,t,n,r);if(a!==void 0)return a;if(_a(e))return e;if(r.has(e))return r.get(e);if(Array.isArray(e)){let t=Array(e.length);r.set(e,t);for(let a=0;a<e.length;a++)t[a]=qa(e[a],a,n,r,i);return Object.hasOwn(e,`index`)&&(t.index=e.index),Object.hasOwn(e,`input`)&&(t.input=e.input),t}if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp){let t=new RegExp(e.source,e.flags);return t.lastIndex=e.lastIndex,t}if(e instanceof Map){let t=new Map;r.set(e,t);for(let[a,o]of e)t.set(a,qa(o,a,n,r,i));return t}if(e instanceof Set){let t=new Set;r.set(e,t);for(let a of e)t.add(qa(a,void 0,n,r,i));return t}if(ya(e))return e.subarray();if(va(e)){let t=new(Object.getPrototypeOf(e)).constructor(e.length);r.set(e,t);for(let a=0;a<e.length;a++)t[a]=qa(e[a],a,n,r,i);return t}if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer)return e.slice(0);if(e instanceof DataView){let t=new DataView(e.buffer.slice(0),e.byteOffset,e.byteLength);return r.set(e,t),Ja(t,e,n,r,i),t}if(typeof File<`u`&&e instanceof File){let t=new File([e],e.name,{type:e.type});return r.set(e,t),Ja(t,e,n,r,i),t}if(typeof Blob<`u`&&e instanceof Blob){let t=new Blob([e],{type:e.type});return r.set(e,t),Ja(t,e,n,r,i),t}if(e instanceof Error){let t=structuredClone(e);return r.set(e,t),t.message=e.message,t.name=e.name,t.stack=e.stack,t.cause=e.cause,t.constructor=e.constructor,Ja(t,e,n,r,i),t}if(e instanceof Boolean){let t=new Boolean(e.valueOf());return r.set(e,t),Ja(t,e,n,r,i),t}if(e instanceof Number){let t=new Number(e.valueOf());return r.set(e,t),Ja(t,e,n,r,i),t}if(e instanceof String){let t=new String(e.valueOf());return r.set(e,t),Ja(t,e,n,r,i),t}if(typeof e==`object`&&Ya(e)){let t=Object.create(Object.getPrototypeOf(e));return r.set(e,t),Ja(t,e,n,r,i),t}return e}function Ja(e,t,n=e,r,i){let a=[...Object.keys(t),...ba(t)];for(let o=0;o<a.length;o++){let s=a[o],c=Object.getOwnPropertyDescriptor(e,s);(c==null||c.writable)&&(e[s]=qa(t[s],s,n,r,i))}}function Ya(e){switch(xa(e)){case Ea:case ja:case Ma:case Fa:case Ta:case Oa:case Ga:case Ka:case Va:case Ha:case Ua:case ka:case wa:case Na:case Sa:case Aa:case Ca:case Da:case Ia:case La:case Ra:case za:return!0;default:return!1}}function Xa(e){return qa(e,void 0,e,new Map,void 0)}function Za(e){if(!e||typeof e!=`object`)return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null?!1:Object.prototype.toString.call(e)===`[object Object]`}function Qa(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function $a(e,t,n){return eo(e,t,void 0,void 0,void 0,void 0,n)}function eo(e,t,n,r,i,a,o){let s=o(e,t,n,r,i,a);if(s!==void 0)return s;if(typeof e==typeof t)switch(typeof e){case`bigint`:case`string`:case`boolean`:case`symbol`:case`undefined`:return e===t;case`number`:return e===t||Object.is(e,t);case`function`:return e===t;case`object`:return to(e,t,a,o)}return to(e,t,a,o)}function to(e,t,n,r){if(Object.is(e,t))return!0;let i=xa(e),a=xa(t);if(i===`[object Arguments]`&&(i=Na),a===`[object Arguments]`&&(a=Na),i!==a)return!1;switch(i){case Ca:return e.toString()===t.toString();case wa:return Qa(e.valueOf(),t.valueOf());case Ta:case Oa:case Da:return Object.is(e.valueOf(),t.valueOf());case Sa:return e.source===t.source&&e.flags===t.flags;case U:return e===t}n??=new Map;let o=n.get(e),s=n.get(t);if(o!=null&&s!=null)return o===t;n.set(e,t),n.set(t,e);try{switch(i){case ka:if(e.size!==t.size)return!1;for(let[i,a]of e.entries())if(!t.has(i)||!eo(a,t.get(i),i,e,t,n,r))return!1;return!0;case Aa:{if(e.size!==t.size)return!1;let i=Array.from(e.values()),a=Array.from(t.values());for(let o=0;o<i.length;o++){let s=i[o],c=a.findIndex(i=>eo(s,i,void 0,e,t,n,r));if(c===-1)return!1;a.splice(c,1)}return!0}case ja:case Ia:case La:case Ra:case za:case Ba:case Va:case Ha:case Ua:case Wa:case Ga:case Ka:if(ya(e)!==ya(t)||e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!eo(e[i],t[i],i,e,t,n,r))return!1;return!0;case Ma:return e.byteLength===t.byteLength&&to(new Uint8Array(e),new Uint8Array(t),n,r);case Fa:return e.byteLength!==t.byteLength||e.byteOffset!==t.byteOffset?!1:to(new Uint8Array(e),new Uint8Array(t),n,r);case Pa:return e.name===t.name&&e.message===t.message;case Na:{if(!(to(e.constructor,t.constructor,n,r)||Za(e)&&Za(t)))return!1;let i=[...Object.keys(e),...ba(e)],a=[...Object.keys(t),...ba(t)];if(i.length!==a.length)return!1;for(let a=0;a<i.length;a++){let o=i[a],s=e[o];if(!Object.hasOwn(t,o))return!1;let c=t[o];if(!eo(s,c,o,e,t,n,r))return!1}return!0}default:return!1}}finally{n.delete(e),n.delete(t)}}function no(e,t){return $a(e,t,ga)}var ro=Symbol(`SENTINEL`),W=class e{root=new Map;get size(){return this._size}_size=0;constructor(e){if(e){if(Symbol.iterator in e)for(let t of e)this.add(t);else{for(let t in e)this.set([t],e[t]);for(let t of Object.getOwnPropertySymbols(e))this.set([t],e[t])}}}add(e){this.set(e,!0)}set(e,t){let n=this.root;for(let t of e)n.has(t)||n.set(t,new Map),n=n.get(t);n.has(ro)||this._size++,n.set(ro,t)}has(e){let t=this.root;for(let n of e){if(!t.has(n))return!1;t=t.get(n)}return t.has(ro)}get(e,t){let n=this.root;for(let r of e){if(!n.has(r)){if(t!==void 0)n.set(r,new Map);else return}n=n.get(r)}return t!==void 0&&!n.has(ro)?(n.set(ro,t),this._size++,t):n.get(ro)}delete(e){let t=this.deleteRecursive(this.root,e);return t&&this._size--,t}deleteRecursive(e,t){if(t.length===0)return e.delete(ro);let[n,...r]=t,i=e.get(n);if(i){let t=this.deleteRecursive(i,r);return i.size===0&&e.delete(n),t}return!1}clear(){this.root.clear(),this._size=0}prefixAll(e){if(e.length===0||!this.size)return;let t=this.root;this.root=new Map;let n=this.root;for(let t=0;t<e.length-1;t++)n.set(e[t],n=new Map);n.set(e.at(-1),t)}[Symbol.iterator](){return this.keys()}*keys(e=[]){let t=this.root;for(let n of e){if(!t.has(n))return;t=t.get(n)}yield*this.iterTrieInner(t,e)}*entries(e=[]){let t=this.root;for(let n of e){if(!t.has(n))return;t=t.get(n)}yield*this.iterTrieInnerEntries(t,e)}*iterTrieInner(e,t){for(let[n,r]of e)n===ro?yield t:r&&(yield*this.iterTrieInner(r,t.concat(n)))}*iterTrieInnerEntries(e,t){for(let[n,r]of e)n===ro?yield[t,e.get(ro)]:r&&(yield*this.iterTrieInnerEntries(r,t.concat(n)))}clone(t=!1){let n=t?Xa(this.root):this.shallowClone(this.root),r=new e;return r.root=n,r._size=this._size,r}shallowClone(e){let t=new Map;for(let[n,r]of e)n===ro?t.set(n,r):t.set(n,this.shallowClone(r));return t}};function io(e){let t=new W;for(let n of e)t.add(n.parts);return t}function G(...e){let t=new W;for(let n of e)if(Array.isArray(n))for(let e of n)t.add(e.parts);else for(let e of n)t.add(e);return t}function ao(e,...t){let n=new W;for(let t of e)n.add(t);for(let e of t)for(let t of e)n.delete(t);return n}function oo(e,t){let n=new W;if(Array.isArray(t))for(let r of t)e.has(r.parts)&&n.add(r.parts);else for(let r of t)e.has(r)&&n.add(r);return n}function so(e,t){if(Array.isArray(t)){for(let n of t)if(!e.has(n.parts))return!1}else for(let n of t)if(!e.has(n))return!1;return!0}function co(e,t){if(Array.isArray(t)){for(let n of t)if(e.has(n.parts))return!0}else for(let n of t)if(e.has(n))return!0;return!1}function lo(e){let t=new W;for(let[n,r]of e.entries())t.set(r,n);return t}var K=class{schema;schemaSet;lang;parent;addToSchema(e){if(Array.isArray(e))for(let t of e)this.schemaSet.has(t.parts)||(this.schema.push(t),this.schemaSet.add(t.parts));else if(e instanceof W)for(let t of e)this.schemaSet.has(t)||(this.schema.push(V.fromParts(t)),this.schemaSet.add(t));else this.schemaSet.has(e.parts)||(this.schema.push(e),this.schemaSet.add(e.parts))}removeFromSchema(e){let t=!1;if(Array.isArray(e))for(let n of e)t=this.schemaSet.delete(n.parts)||t;else if(e instanceof W)for(let n of e)t=this.schemaSet.delete(n)||t;else t=this.schemaSet.delete(e.parts);if(t){let e=this.schema.filter(e=>this.schemaSet.has(e.parts));this.schema.length=0,this.schema.push(...e)}return t}clearSchema(){this.schema.length=0,this.schemaSet.clear()}getDependencies(){return new W}};function uo(e,t){for(let n of e)n instanceof V||(n.parent=t)}var fo=class e extends K{name;constructor(e,t){super(),this.name=t,this.lang=e,this.schema=[],this.schemaSet=new W}accept(e,t){return e[this.lang].visitTupleSource(this,t)}replaceChild(e,t){throw Error(`Method not implemented.`)}getChildren(){return[]}clone(){let t=new e(this.lang,this.name);return t.schema=this.schema.slice(),t.schemaSet=this.schemaSet.clone(),t}},po=class e extends K{args;impl;name;constructor(e,t,n,r){super(),this.args=t,this.impl=n,this.name=r,this.lang=e,this.schema=[],this.schemaSet=new W,uo(this.args,this)}accept(e,t){return e[this.lang].visitTupleFnSource(this,t)}replaceChild(e,t){t.parent=this;let n=this.args.indexOf(e);this.args[n]=t}getChildren(){return this.args.filter(aa)}clone(){let t=new e(this.lang,this.args.map(la),this.impl,this.name);return t.schema=this.schema.slice(),t.schemaSet=this.schemaSet.clone(),t}getDependencies(){return io(this.args.filter(oa))}},mo=class e extends fo{index;access;fromItemKey;constructor(e,t,n,r,i){super(e,t),this.index=n,this.access=r,this.fromItemKey=i,this.access.parent=this}accept(e,t){return e[this.lang].visitIndexScan(this,t)}replaceChild(e,t){t.parent=this,this.access=t}getChildren(){return[this.access]}clone(){let t=new e(this.lang,this.name,this.index,this.access.clone(),this.fromItemKey);return t.schema=this.schema.slice(),t.schemaSet=this.schemaSet.clone(),t}},ho=class e{lang;args;impl;fieldName;postGroupOp;get postGroupSource(){return this._postGSource}_postGSource;parent;constructor(e,t,n,r){this.lang=e,this.args=t,this.impl=n,this.fieldName=r,uo(this.args,this),this._postGSource=new fo(e,V.fromParts([`<partition>`])),this.postGroupOp=this._postGSource,this.fieldName.aggregate=this}accept(e,t){return e[this.lang].visitAggregate(this,t)}replaceChild(e,t){t.parent=this;for(let n=0;n<this.args.length;n++)if(this.args[n]===e){this.args[n]=t;return}}getChildren(){return this.args.filter(aa)}clone(t){let n=this.args.map(la),r=new e(this.lang,n,this.impl,V.fromParts(this.fieldName.parts)),i=[],a=this._postGSource;for(;a!==this.postGroupOp;){let e=a.parent.getChildren();i.push(e.indexOf(a)),a=a.parent}r.postGroupOp=this.postGroupOp.clone();let o=r.postGroupOp;for(let e=i.length-1;e>=0;e--)o=o.getChildren()[i[e]];r._postGSource=o;for(let e of t??[])e.aggregate===this&&(e.aggregate=r);return r}getDependencies(){return io(this.args.filter(oa))}},go=Symbol(`CalcIntermediate`),_o=class e{lang;impl;args;argMeta;original;aggregates;literal;parent;constructor(e,t,n,r,i,a=[],o=!1){this.lang=e,this.impl=t,this.args=n,this.argMeta=r,this.original=i,this.aggregates=a,this.literal=o,uo(n,this),uo(a,this)}accept(e,t){return e[this.lang].visitCalculation(this,t)}replaceChild(e,t){t.parent=this;let n;if(e instanceof ho?(n=this.aggregates.indexOf(e),this.aggregates[n]=t,n=this.argMeta.findIndex(t=>t.aggregate===e),this.argMeta[n].aggregate=t):(n=this.args.indexOf(e),this.args[n]=t),e===this.original)this.original=t;else{let e=this.argMeta[n].originalLocations;if(!e.length)return;e[0].obj[e[0].key]=t;for(let n=1;n<e.length;n++)e[n].obj[e[n].key]=t.clone()}}getChildren(){let e=[];for(let t of this.args)t instanceof V||e.push(t);return e}clone(){let t=this.argMeta.map(e=>({...e,originalLocations:e.originalLocations.map(e=>({...e}))}));if(this.original&&(go in this.original||this.original instanceof ho)){let n=this.original.clone(t),r=t.filter(e=>e.aggregate).map(e=>e.aggregate),i=t.map(e=>{let t=e.originalLocations[0];return t.obj[t.key]});return new e(this.lang,this.impl,i,t,n,r,this.literal)}let n=this.original?.clone();return new e(this.lang,this.impl,this.args[0]===this.original&&this.args.length===1?[n]:this.args.map(la),t,n,this.aggregates.map(ca),this.literal)}getDependencies(){return io(this.args.filter(oa))}},q=class e{lang;args;impl;pure;[go]=!0;constructor(e,t,n,r=!1){this.lang=e,this.args=t,this.impl=n,this.pure=r;for(let e of t)`op`in e&&(e.op.parent=this)}accept(e,t){return e[this.lang].visitFnCall(this,t)}replaceChild(e,t){for(let n of this.args)if(`op`in n&&n.op===e){n.op=t,t.parent=this;return}}getChildren(){let e=[];for(let t of this.args)`op`in t&&e.push(t.op);return e}clone(t){let n=new e(this.lang,this.args.map(e=>`op`in e?{...e,op:go in e.op||e.op instanceof ho?e.op.clone(t):e.op.clone()}:e),this.impl,this.pure);for(let e of t??[])for(let t of e.originalLocations){if(t.op===this)t.op=n;else continue;if(t.obj===this.args)t.obj=n.args;else{let e=this.args.indexOf(t.obj);e!==-1&&(t.obj=n.args[e])}}return n}getDependencies(){return io(this.args.filter(oa))}},vo=class e{lang;name;parent;constructor(e,t){this.lang=e,this.name=t}accept(e,t){return e[this.lang].visitItemSource(this,t)}replaceChild(e,t){throw Error(`Method not implemented.`)}getChildren(){return[]}clone(){return new e(this.lang,this.name)}getDependencies(){return new W}},yo=class e{lang;args;impl;name;parent;constructor(e,t,n,r){this.lang=e,this.args=t,this.impl=n,this.name=r,uo(this.args,this)}accept(e,t){return e[this.lang].visitItemFnSource(this,t)}replaceChild(e,t){t.parent=this;let n=this.args.indexOf(e);this.args[n]=t}getChildren(){return this.args.filter(aa)}clone(){return new e(this.lang,this.args.map(la),this.impl,this.name)}getDependencies(){return io(this.args.filter(oa))}},bo=class e{lang;value;[go]=!0;constructor(e,t){this.lang=e,this.value=t}accept(e,t){return e[this.lang].visitLiteral(this,t)}replaceChild(e,t){throw Error(`Method not implemented.`)}getChildren(){return[]}clone(t){return new e(this.lang,this.value)}getDependencies(){return new W}},J=class e extends K{attrs;source;renames=new W;renamesInv=new W;constructor(e,t,n){super(),this.attrs=t,this.source=n,this.lang=e,this.schema=t.map(ra),this.schemaSet=io(this.schema),n.parent=this;for(let[e,t]of this.attrs)e instanceof V?(this.renames.set(e.parts,t.parts),this.renamesInv.set(t.parts,e.parts)):e.parent=this}accept(e,t){return e[this.lang].visitProjection(this,t)}replaceChild(e,t){let n=t instanceof V;if(n||(t.parent=this),e===this.source){if(n)throw Error(`cannot replace source with identifier`);this.source=t}else this.attrs.find(t=>t[0]===e)[0]=t}getChildren(){let e=this.attrs.map(na).filter(aa);return e.push(this.source),e}clone(){return new e(this.lang,this.attrs.map(la),this.source.clone())}getDependencies(){return io(this.attrs.map(na).filter(oa))}},xo=class e extends K{mapping;outer;source;emptyVal=new W;validateSingleValue=!1;constructor(e,t,n,r){super(),this.mapping=t,this.outer=n,this.source=r,this.lang=e,this.schema=r.schema.filter(e=>!t.schemaSet.has(e.parts)).concat(t.schema),this.schemaSet=io(this.schema),t.parent=this,r.parent=this}accept(e,t){return e[this.lang].visitProjectionConcat(this,t)}replaceChild(e,t){t.parent=this,e===this.mapping?this.mapping=t:this.source=t,this.clearSchema(),this.addToSchema(this.source.schema),this.removeFromSchema(this.mapping.schema),this.addToSchema(this.mapping.schema)}getChildren(){return[this.source,this.mapping]}clone(){let t=new e(this.lang,this.mapping.clone(),this.outer,this.source.clone());return t.emptyVal=this.emptyVal.clone(),t.validateSingleValue=this.validateSingleValue,t}},So=class e extends K{indexCol;source;constructor(e,t,n){super(),this.indexCol=t,this.source=n,this.lang=e,this.schema=[...n.schema.filter(e=>!e.equals(t)),t],this.schemaSet=io(this.schema),n.parent=this}accept(e,t){return e[this.lang].visitProjectionIndex(this,t)}replaceChild(e,t){t.parent=this,this.source=t,this.clearSchema(),this.addToSchema(t.schema.filter(e=>!e.equals(this.indexCol))),this.addToSchema(this.indexCol)}getChildren(){return[this.source]}clone(){return new e(this.lang,this.indexCol,this.source.clone())}};function Co(e,t){let n=new q(t,[e],ea);return new _o(t,ea,[e],[{originalLocations:[{obj:n.args,key:0,idAsFnArg:!0,op:n}]}],n,[],!1)}function wo(e,t,n){if(e.args.length===0)return e;let r=[e.args[0]],i=[e.argMeta[0]],a=[0];outer:for(let o=1;o<e.args.length;o++){let s=t[e.args[o]instanceof V?n:e.args[o].lang];for(let t=0;t<o;t++)if(r[t]&&s.areEqual(e.args[o],r[t])){a.push(t),i[t].usedMultipleTimes=!0,i[t].originalLocations.push(...e.argMeta[o].originalLocations),i[t].maybeSkipped&&=e.argMeta[o]?.maybeSkipped;continue outer}r.push(e.args[o]),a.push(r.length-1),i.push(e.argMeta[o])}if(r.length===e.args.length)return e;let o={args:r,impl:(...t)=>{let n=[];for(let e of a)n.push(t[e]);return e.impl.apply(null,n)},argMeta:i,literal:e.literal};return e.aggregates?.length&&(o.aggregates=i.filter(e=>e?.aggregate instanceof ho).map(e=>e.aggregate)),o}function To(e,t,n){let r=e.accept(t);return r=wo(r,n,e.lang),new _o(e.lang,r.impl,r.args,r.argMeta,e,r.aggregates,r.literal)}var Y=class e extends K{source;condition;constructor(e,t,n){super(),this.source=n,this.lang=e,this.schema=n.schema,this.schemaSet=n.schemaSet,this.condition=t instanceof _o?t:Co(t,e),this.condition.parent=this,n.parent=this}accept(e,t){return e[this.lang].visitSelection(this,t)}replaceChild(e,t){t instanceof V&&(t=Co(t,this.lang)),t.parent=this,e===this.condition?this.condition=t:this.source=t}getChildren(){return[this.source,this.condition]}clone(){return new e(this.lang,this.condition.clone(),this.source.clone())}},Eo=class e{lang;condition;whenThens;defaultCase;[go]=!0;constructor(e,t,n,r){this.lang=e,this.condition=t,this.whenThens=n,this.defaultCase=r;let i=n.flat();t&&i.push(t),r&&i.push(r);for(let e of i)e instanceof V||(e.parent=this)}accept(e,t){return e[this.lang].visitConditional(this,t)}replaceChild(e,t){if(t.parent=this,this.condition===e)this.condition=t;else if(this.defaultCase===e)this.defaultCase=t;else for(let n of this.whenThens){if(n[0]===e){n[0]=t;return}if(n[1]===e){n[1]=t;return}}}getChildren(){return[this.condition,...this.whenThens.flat(),this.defaultCase].filter(e=>e&&!(e instanceof V))}clone(t){let n=new e(this.lang,ua(this.condition,t),this.whenThens.map(e=>[ua(e[0],t),ua(e[1],t)]),ua(this.defaultCase,t));for(let e of t??[])for(let t of e.originalLocations){if(t.op===this)t.op=n;else continue;if(t.obj===this)t.obj=n;else{let e=this.whenThens.indexOf(t.obj);e!==-1&&(t.obj=n.whenThens[e])}}return n}getDependencies(){let e=new W,t=this.whenThens.flat();this.condition&&t.push(this.condition),this.defaultCase&&t.push(this.defaultCase);for(let n of t)n instanceof V&&e.add(n.parts);return e}},Do=class e extends K{left;right;validateSingleValue=!1;constructor(e,t,n){super(),this.left=t,this.right=n,this.lang=e,this.schema=t.schema&&n.schema?t.schema.filter(e=>!n.schemaSet.has(e.parts)).concat(n.schema):t.schema||n.schema||[],this.schemaSet=io(this.schema),t.parent=this,n.parent=this}accept(e,t){return e[this.lang].visitCartesianProduct(this,t)}replaceChild(e,t){t.parent=this,e===this.left?this.left=t:this.right=t,this.clearSchema(),this.addToSchema(this.left.schema),this.addToSchema(this.right.schema)}getChildren(){return[this.left,this.right]}clone(){let t=new e(this.lang,this.left.clone(),this.right.clone());return t.validateSingleValue=this.validateSingleValue,t}},Oo=class e extends Do{conditions;leftOuter=!1;rightOuter=!1;constructor(e,t,n,r){super(e,t,n),this.conditions=r,uo(this.conditions,this)}accept(e,t){return e[this.lang].visitJoin(this,t)}replaceChild(e,t){t.parent=this;for(let n=0;n<this.conditions.length;n++)if(this.conditions[n]===e){this.conditions[n]=t;return}super.replaceChild(e,t)}getChildren(){return[this.left,this.right,...this.conditions]}clone(){let t=new e(this.lang,this.left.clone(),this.right.clone(),this.conditions.map(ca));return t.leftOuter=this.leftOuter,t.rightOuter=this.rightOuter,t}},ko=class e{lang;key;source;parent;constructor(e,t,n){this.lang=e,this.key=t,this.source=n,t||(this.key=n.schema?.length===1?n.schema[0]:V.fromParts([Zi])),n.parent=this}accept(e,t){return e[this.lang].visitMapToItem(this,t)}replaceChild(e,t){t.parent=this,this.source=t}getChildren(){return[this.source]}clone(){return new e(this.lang,this.key,this.source.clone())}getDependencies(){return new W([this.key.parts])}},Ao=class e extends K{key;source;constructor(e,t,n){super(),this.key=t,this.source=n,this.lang=e,this.schema=[t],this.schemaSet=io(this.schema),n.parent=this}accept(e,t){return e[this.lang].visitMapFromItem(this,t)}replaceChild(e,t){t.parent=this,this.source=t}getChildren(){return[this.source]}clone(){return new e(this.lang,this.key,this.source.clone())}};function jo(e){return e.key}var Mo=class e extends K{orders;source;constructor(e,t,n){super(),this.orders=t,this.source=n,this.lang=e,this.schema=n.schema,this.schemaSet=n.schemaSet,n.parent=this,uo(t.map(jo),this)}accept(e,t){return e[this.lang].visitOrderBy(this,t)}replaceChild(e,t){let n=t instanceof V;if(n||(t.parent=this),e===this.source){if(n)throw Error(`cannot replace source with an identifier`);this.source=t}else this.orders.find(t=>t.key===e).key=t}getChildren(){let e=this.orders.map(jo).filter(aa);return e.push(this.source),e}clone(){return new e(this.lang,this.orders.map(e=>({key:la(e.key),ascending:e.ascending,nullsFirst:e.nullsFirst})),this.source.clone())}getDependencies(){return io(this.orders.map(jo).filter(oa))}},No=class e extends K{keys;aggs;source;constructor(e,t,n,r){super(),this.keys=t,this.aggs=n,this.source=r,this.lang=e,this.schemaSet=io(r.schema.concat(n.map(e=>e.fieldName)).concat(t.map(ra))),this.schema=Array.from(this.schemaSet.keys(),e=>V.fromParts(e)),r.parent=this,uo(t.map(na),this),uo(n,this);for(let e of this.aggs)e.postGroupSource.clearSchema(),e.postGroupSource.addToSchema(this.source.schema.concat(this.keys.map(ra)))}accept(e,t){return e[this.lang].visitGroupBy(this,t)}replaceChild(e,t){let n=t instanceof V;if(n||(t.parent=this),e===this.source){if(n)throw Error(`Cannot replace source with an identifier`);this.source=t}else if(e instanceof ho){if(n)throw Error(`Cannot replace aggregate with an identifier`);let r=this.aggs.indexOf(e);this.aggs[r]=t}else this.keys.find(t=>t[0]===e)[0]=t}getChildren(){let e=[this.source];for(let t of this.keys)t[0]instanceof _o&&e.push(t[0]);return e.push(...this.aggs),e}clone(){return new e(this.lang,this.keys.map(la),this.aggs.map(ca),this.source.clone())}getDependencies(){return io(this.keys.map(na).filter(oa))}},Po=class e extends K{skip;limit;source;constructor(e,t,n,r){super(),this.skip=t,this.limit=n,this.source=r,this.lang=e,this.schema=r.schema,this.schemaSet=r.schemaSet,r.parent=this}accept(e,t){return e[this.lang].visitLimit(this,t)}replaceChild(e,t){t.parent=this,this.source=t}getChildren(){return[this.source]}clone(){return new e(this.lang,this.skip,this.limit,this.source.clone())}},Fo=class extends K{left;right;constructor(e,t,n){if(super(),this.left=t,this.right=n,this.lang=e,t instanceof K!=n instanceof K)throw Error(`Both sides of a set operator must be either tuple or non-tuple operators`);t instanceof K&&(this.schema=t.schema,this.schemaSet=t.schemaSet),t.parent=this,n.parent=this}replaceChild(e,t){t.parent=this,this.left===e?this.left=t:this.right=t}getChildren(){return[this.left,this.right]}},Io=class e extends Fo{accept(e,t){return e[this.lang].visitUnion(this,t)}clone(){return new e(this.lang,this.left.clone(),this.right.clone())}},Lo=class e extends Fo{accept(e,t){return e[this.lang].visitIntersection(this,t)}clone(){return new e(this.lang,this.left.clone(),this.right.clone())}},Ro=class e extends Fo{accept(e,t){return e[this.lang].visitDifference(this,t)}clone(){return new e(this.lang,this.left.clone(),this.right.clone())}},zo=class e extends K{attrs;source;constructor(e,t,n){super(),this.attrs=t,this.source=n,this.lang=e,this.schema=n.schema,this.schemaSet=n.schemaSet,n.parent=this}accept(e,t){return e[this.lang].visitDistinct(this,t)}replaceChild(e,t){let n=t instanceof V;if(n||(t.parent=this),this.source===e){if(n)throw Error(`Cannot replace source with an identifier`);this.source=t}else{let n=this.attrs.indexOf(e);this.attrs[n]=t}}getChildren(){let e=[this.source];return this.attrs!==Zi&&e.push(...this.attrs.filter(aa)),e}clone(){return new e(this.lang,this.attrs===Zi?this.attrs:this.attrs.map(la),this.source.clone())}getDependencies(){return this.attrs===Zi?new W([[Zi]]):io(this.attrs.filter(oa))}},Bo=class e extends K{constructor(e){super(),this.lang=e,this.schema=[],this.schemaSet=new W}accept(e,t){return e[this.lang].visitNullSource(this,t)}replaceChild(e,t){throw Error(`Method not implemented.`)}getChildren(){return[]}clone(){return new e(this.lang)}},Vo=function(e){return e.ALL=`all`,e.ANY=`any`,e}({}),Ho=class e{lang;type;query;[go]=!0;constructor(e,t,n){this.lang=e,this.type=t,this.query=n,this.query.parent=this}accept(e,t){return e[this.lang].visitQuantifier(this,t)}replaceChild(e,t){t.parent=this,this.query=t}getChildren(){return[this.query]}clone(t){let n=new e(this.lang,this.type,this.query.clone());for(let e of t??[])for(let t of e.originalLocations){if(t.op===this)t.op=n;else continue;t.obj===this&&(t.obj=n)}return n}getDependencies(){return new W}},Uo=class e extends K{min;max;condition;source;distinctKeys;constructor(e,t,n,r,i,a=[]){super(),this.min=t,this.max=n,this.condition=r,this.source=i,this.distinctKeys=a,this.lang=e,this.schema=i.schema,this.schemaSet=i.schemaSet,r&&(r.parent=this),i.parent=this,uo(this.distinctKeys,this)}accept(e,t){return e[this.lang].visitRecursion(this,t)}replaceChild(e,t){t.parent=this;for(let n=0;n<this.distinctKeys.length;n++)if(this.distinctKeys[n]===e){this.distinctKeys[n]=t;return}e===this.condition?this.condition=t:this.source=t}getChildren(){return[this.source,this.condition,...this.distinctKeys.filter(aa)]}clone(){return new e(this.lang,this.min,this.max,this.condition.clone(),this.source.clone(),this.distinctKeys.map(la))}getDependencies(){return io(this.distinctKeys.filter(oa))}},X=class e extends K{min;max;mapping;source;distinctKeys;constructor(e,t,n,r,i,a=[]){super(),this.min=t,this.max=n,this.mapping=r,this.source=i,this.distinctKeys=a,this.lang=e,this.schema=i.schema,this.schemaSet=i.schemaSet,r.parent=this,i.parent=this,uo(this.distinctKeys,this)}accept(e,t){return e[this.lang].visitIndexedRecursion(this,t)}replaceChild(e,t){t.parent=this;for(let n=0;n<this.distinctKeys.length;n++)if(this.distinctKeys[n]===e){this.distinctKeys[n]=t;return}e===this.mapping?this.mapping=t:this.source=t}getChildren(){return[this.source,this.mapping,...this.distinctKeys.filter(aa)]}clone(){return new e(this.lang,this.min,this.max,this.mapping.clone(),this.source.clone(),this.distinctKeys.map(la))}getDependencies(){return io(this.distinctKeys.filter(oa))}},Wo=class e extends K{min;max;mappingFwd;mappingRev;target;source;constructor(e,t,n,r,i,a,o){super(),this.min=t,this.max=n,this.mappingFwd=r,this.mappingRev=i,this.target=a,this.source=o,this.lang=e,this.schema=o.schema.concat(a.schema.filter(e=>!o.schemaSet.has(e.parts))),this.schemaSet=io(this.schema),r.parent=this,i.parent=this,o.parent=this,a.parent=this}accept(e,t){return e[this.lang].visitBidirectionalRecursion(this,t)}replaceChild(e,t){t.parent=this,e===this.mappingFwd?this.mappingFwd=t:e===this.mappingRev?this.mappingRev=t:e===this.target?this.target=t:this.source=t}getChildren(){return[this.source,this.target,this.mappingFwd,this.mappingRev]}clone(){return new e(this.lang,this.min,this.max,this.mappingFwd.clone(),this.mappingRev.clone(),this.target.clone(),this.source.clone())}},Go=class{vmap;db;tdepsVmap;constructor(e,t){this.vmap=e,this.db=t,this.tdepsVmap=this.db.langMgr.getVisitorMap(`transitiveDependencies`)}canRename(e,t){let n=lo(t);return e.accept(this.vmap,{renames:n,renamesInv:t})}checkHorizontal(e,t,n){let r=ao(e.accept(this.tdepsVmap),t);return co(r,n.renamesInv)||co(r,n.renames)&&co(t,n.renamesInv)?!1:e.accept(this.vmap,n)}checkHorizontalArray(e,t,n){for(let r of e)if(!(r instanceof V)&&!this.checkHorizontal(r,t,n))return!1;return!0}checkAttrs(e,t,n){return!e.some(e=>n.renamesInv.has(e[1].parts)&&(!(e[0]instanceof V)||!e[0].equals(e[1])))&&this.checkHorizontalArray(e.map(na),t,n)}checkVerticalArray(e,t){for(let n of e)if(!(n instanceof V)&&!n.accept(this.vmap,t))return!1;return!0}visitRecursion(e,t){return this.checkHorizontal(e.condition,e.source.schemaSet,t)&&this.checkHorizontalArray(e.distinctKeys,e.source.schemaSet,t)&&e.source.accept(this.vmap,t)}visitProjection(e,t){return this.checkAttrs(e.attrs,e.source.schemaSet,t)&&e.source.accept(this.vmap,t)}visitSelection(e,t){return this.checkHorizontal(e.condition,e.source.schemaSet,t)&&e.source.accept(this.vmap,t)}visitTupleSource(e,t){return!0}visitItemSource(e,t){return!0}visitFnCall(e,t){return this.checkVerticalArray(e.args.map(e=>`op`in e?e.op:e),t)}visitLiteral(e,t){return!0}visitCalculation(e,t){return this.checkVerticalArray(e.args,t)}visitConditional(e,t){return this.checkVerticalArray(e.whenThens.flat(),t)&&this.checkVerticalArray([e.condition,e.defaultCase].filter(e=>!!e),t)}visitCartesianProduct(e,t){return e.left.accept(this.vmap,t)&&e.right.accept(this.vmap,t)}visitJoin(e,t){return this.checkHorizontalArray(e.conditions,G(e.left.schemaSet,e.right.schemaSet),t)&&this.visitCartesianProduct(e,t)}visitProjectionConcat(e,t){return this.checkHorizontal(e.mapping,e.source.schemaSet,t)&&e.source.accept(this.vmap,t)}visitMapToItem(e,t){return e.source.accept(this.vmap,t)}visitMapFromItem(e,t){return!t.renamesInv.has(e.key.parts)&&e.source.accept(this.vmap,t)}visitProjectionIndex(e,t){return!t.renamesInv.has(e.indexCol.parts)&&e.source.accept(this.vmap,t)}visitOrderBy(e,t){return this.checkHorizontalArray(e.orders.map(jo),e.source.schemaSet,t)&&e.source.accept(this.vmap,t)}visitGroupBy(e,t){return this.checkAttrs(e.keys,e.source.schemaSet,t)&&this.checkHorizontalArray(e.aggs,e.source.schemaSet,t)&&e.source.accept(this.vmap,t)}visitLimit(e,t){return e.source.accept(this.vmap,t)}visitSetOp(e,t){return e.left.accept(this.vmap,t)&&e.right.accept(this.vmap,t)}visitUnion(e,t){return this.visitSetOp(e,t)}visitIntersection(e,t){return this.visitSetOp(e,t)}visitDifference(e,t){return this.visitSetOp(e,t)}visitDistinct(e,t){return Array.isArray(e.attrs)&&!this.checkHorizontalArray(e.attrs,e.source.schemaSet,t)?!1:e.source.accept(this.vmap,t)}visitNullSource(e,t){return!0}visitAggregate(e,t){return!t.renamesInv.has(e.fieldName.parts)&&this.checkVerticalArray(e.args,t)&&e.postGroupOp.accept(this.vmap,t)}visitItemFnSource(e,t){return this.checkVerticalArray(e.args,t)}visitTupleFnSource(e,t){return this.checkVerticalArray(e.args,t)}visitQuantifier(e,t){return e.query.accept(this.vmap,t)}visitIndexScan(e,t){return this.checkHorizontal(e.access,e.schemaSet,t)}visitIndexedRecursion(e,t){return this.checkHorizontal(e.mapping,e.source.schemaSet,t)&&this.checkHorizontalArray(e.distinctKeys,e.source.schemaSet,t)&&e.source.accept(this.vmap,t)}visitBidirectionalRecursion(e,t){return this.checkHorizontal(e.mappingFwd,e.source.schemaSet,t)&&this.checkHorizontal(e.mappingRev,e.source.schemaSet,t)&&e.source.accept(this.vmap,t)&&e.target.accept(this.vmap,t)}},Ko=class{vmap;db;tdepsVmap;varMappers;constructor(e,t){this.vmap=e,this.db=t,this.tdepsVmap=this.db.langMgr.getVisitorMap(`transitiveDependencies`),this.varMappers=this.db.langMgr.getVisitorMap(`variableMapper`)}rename(e,t){let n=this.prepareVarMapCtx(t);e.accept(this.varMappers,n);let r=this.prepareTranslations(n,t);e.accept(this.vmap,r),this.tdepsVmap[e.lang].invalidateCacheUpstream(e)}prepareVarMapCtx(e){let t=new W,n=0;for(let r of e.keys())t.set(r,V.fromParts([n++]));return{scopeStack:[new W,t],currentIndex:n,variableNames:[],translations:new Map,calcIntermediates:!0}}prepareTranslations(e,t){let n=new Map;for(let[r,{scope:i,external:a}]of e.translations.entries()){let e=new W;for(let[t,n]of a.entries())e.set(n.parts,V.fromParts(t));for(let[t,n]of i.entries())e.set(n.parts,V.fromParts(t));let o=0;for(let n of t.keys())e.set([o++],V.fromParts(t.get(n)));n.set(r,e)}return n}renameIdentifier(e,t){let n=t.get(e.parts);if(!n)throw Error(`No translation found for ${e.parts.join(`.`)}`);return e.aggregate&&(n=V.fromParts([...n.parts]),n.aggregate=e.aggregate),n}processArray(e,t,n,r){let i=t.get(n);for(let n=0;n<e.length;n++){let a=e[n];if(a instanceof V){let t=this.renameIdentifier(a,i);r?r(t,n):e[n]=t}else a.accept(this.vmap,t)}}processItem(e,t,n,r){let i=e[t];if(i instanceof V){let a=n.get(r);e[t]=this.renameIdentifier(i,a)}else i.accept(this.vmap,n)}visitRecursion(e,t){e.source.accept(this.vmap,t),this.processArray(e.distinctKeys,t,e),e.condition.accept(this.vmap,t)}visitProjection(e,t){let n=t.get(e);e.source.accept(this.vmap,t),e.renames=new W,e.renamesInv=new W;for(let r of e.attrs)r[1]=this.renameIdentifier(r[1],n),r[0]instanceof V?(r[0]=this.renameIdentifier(r[0],n),e.renames.set(r[0].parts,r[1].parts),e.renamesInv.set(r[1].parts,r[0].parts)):r[0].accept(this.vmap,t)}visitSelection(e,t){e.source.accept(this.vmap,t),e.condition.accept(this.vmap,t)}visitTupleSource(e,t){}visitItemSource(e,t){}visitFnCall(e,t){let n=t.get(e);for(let r=0;r<e.args.length;r++){let i=e.args[r];if(i instanceof V){let t=this.renameIdentifier(i,n);e.args[r]=t}else go in i.op&&i.op.accept(this.vmap,t)}}visitLiteral(e,t){}visitCalculation(e,t){this.processArray(e.args,t,e),e.original&&e.original.accept(this.vmap,t)}visitConditional(e,t){let n=t.get(e);for(let r of[`condition`,`defaultCase`]){let i=e[r];if(i instanceof V){let t=this.renameIdentifier(i,n);t&&(e[r]=t)}else go in i&&i.accept(this.vmap,t)}for(let r of e.whenThens)for(let e of[0,1]){let i=r[e];if(i instanceof V){let t=this.renameIdentifier(i,n);t&&(r[e]=t)}else go in i&&i.accept(this.vmap,t)}}visitCartesianProduct(e,t){e.left.accept(this.vmap,t),e.right.accept(this.vmap,t)}visitJoin(e,t){this.visitCartesianProduct(e,t),this.processArray(e.conditions,t,e)}visitProjectionConcat(e,t){e.source.accept(this.vmap,t),this.processItem(e,`mapping`,t,e)}visitMapToItem(e,t){e.key=t.get(e).get(e.key.parts),e.source.accept(this.vmap,t)}visitMapFromItem(e,t){e.key=t.get(e).get(e.key.parts),e.source.accept(this.vmap,t)}visitProjectionIndex(e,t){e.indexCol=t.get(e).get(e.indexCol.parts),e.source.accept(this.vmap,t)}visitOrderBy(e,t){e.source.accept(this.vmap,t),this.processArray(e.orders.map(jo),t,e,(t,n)=>e.orders[n].key=t)}visitGroupBy(e,t){e.source.accept(this.vmap,t),this.processArray(e.keys.map(na),t,e,(t,n)=>e.keys[n][0]=t),this.processArray(e.keys.map(ra),t,e,(t,n)=>e.keys[n][1]=t),this.processArray(e.aggs,t,e)}visitLimit(e,t){e.source.accept(this.vmap,t)}visitSetOp(e,t){e.left.accept(this.vmap,t),e.right.accept(this.vmap,t)}visitUnion(e,t){this.visitSetOp(e,t)}visitIntersection(e,t){this.visitSetOp(e,t)}visitDifference(e,t){this.visitSetOp(e,t)}visitDistinct(e,t){Array.isArray(e.attrs)&&this.processArray(e.attrs,t,e),e.source.accept(this.vmap,t)}visitNullSource(e,t){}visitAggregate(e,t){e.postGroupOp.accept(this.vmap,t),e.fieldName=t.get(e).get(e.fieldName.parts),this.processArray(e.args,t,e)}visitItemFnSource(e,t){this.processArray(e.args,t,e)}visitTupleFnSource(e,t){this.processArray(e.args,t,e)}visitQuantifier(e,t){}visitIndexScan(e,t){e.fromItemKey&&=t.get(e).get(e.fromItemKey.parts),e.access.accept(this.vmap,t)}visitIndexedRecursion(e,t){e.source.accept(this.vmap,t),this.processArray(e.distinctKeys,t,e),this.processItem(e,`mapping`,t,e)}visitBidirectionalRecursion(e,t){e.source.accept(this.vmap,t),e.target.accept(this.vmap,t),this.processItem(e,`mappingFwd`,t,e),this.processItem(e,`mappingRev`,t,e)}};function qo(e,t){let n=0,r=[];for(let i of t)i instanceof V?r.push(e[n++]):r.push(i.impl(...e.slice(n,n+=i.args.length)));return r}function Jo(e,t){if(!e||!(e instanceof _o)||!e.literal)return!1;let n=e.impl();return!t||typeof t==`string`?typeof n===t:n instanceof t}var Z=function(e){return e[e.modified=0]=`modified`,e[e.renamed=1]=`renamed`,e[e.unchanged=2]=`unchanged`,e}({});function Yo(e,t){let n=!0;for(let r of e)if(t.schemaSet.has(r)){if(!t.renamesInv.has(r))return 0;n&&!Xo(t.renamesInv.get(r),r)&&(n=!1)}return n?2:1}function Xo(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Zo(e,t,n,r,i){let a=[];e instanceof V?a.push(new q(i,[e],ea)):Qo(e,ns,a);for(let e of a){let a=e.accept(n);a=wo(a,r,i),t=new Y(i,new _o(i,a.impl,a.args,a.argMeta,e,a.aggregates,a.literal),t)}return t}function Qo(e,t,n=[]){return!(e instanceof q)||e.impl!==t.impl?(n.push(e),n):(Qo(e.args[0]instanceof V?new q(e.lang,[e.args[0]],ea):e.args[0].op,t,n),Qo(e.args[1]instanceof V?new q(e.lang,[e.args[1]],ea):e.args[1].op,t,n),n)}function $o(e=`.`){return function(t,n,r){if(!(r instanceof K))return{data:t};let i=r.schema.map(t=>t.parts.map(e=>e.toString()).join(e)),a=r.schema.map(e=>e.parts.at(-1)===Zi),o=n.getKeys(r);return{schema:i,data:Iterator.from(t).map(e=>{let t={};for(let n=0;n<o.length;n++){let r=e[o[n]];a[n]?Object.assign(t,r):t[i[n]]=r}return t})}}}function es(e){let t=[];for(let n of e)n instanceof ho?t.push(n):n instanceof _o?t.push(...n.aggregates):n instanceof V&&n.aggregate&&t.push(n.aggregate);return t.map(ca)}function Q(e,t=null){return(...n)=>{for(let e of n)if(e==null)return t;return e(...n)}}var ts={name:`or`,impl:(e,t)=>e||t||(e===null?e:t)},ns={name:`and`,impl:(e,t)=>e&&t||(t===!1?t:e)},rs={name:`not`,impl:Q(e=>!e)},is={name:`neg`,impl:e=>!e};function as(e){return e.literal}function os(e){return e.impl()}function ss(e){return e instanceof V?e:e.args}function cs(e){return(e instanceof V?null:e.aggregates)??[]}function ls(e,t,n,r,i){if(e instanceof V)return[{originalLocations:[{obj:t,key:n,op:r,idAsFnArg:i}]}];for(let i of e.argMeta)i.originalLocations.length===0&&i.originalLocations.push(`op`in t[n]?{obj:t[n],key:`op`,op:r}:{obj:t,key:n,op:r});return e.argMeta}function us(e){return[ss(e[0]),ss(e[1])]}function ds(e){return[cs(e[0]),cs(e[1])]}function fs(e,t,n){return[ls(e[0],t,0,n),ls(e[1],t,1,n)]}function*ps(e){if(e.length===0)return[];for(let t of e[0])if(e.length===1)yield[t];else for(let n of ps(e.slice(1)))yield[t,...n]}function ms(e){return e.op instanceof Ho}function hs(e,t){return e.map(ta).filter(n=>!(e[n]instanceof V)&&e[n].op instanceof Ho&&e[n].op.type===t)}var gs=class{vmap;db;constructor(e,t){this.vmap=e,this.db=t,this.processItem=this.processItem.bind(this),this.processFnArg=this.processFnArg.bind(this),this.processWhenThen=this.processWhenThen.bind(this)}toItem(e){let t=e.parent,n=new ko(e.lang,null,e);return t&&t.replaceChild(e,n),n}visitProjection(e){return{args:[this.toItem(e)],impl:H,argMeta:[{originalLocations:[]}]}}visitSelection(e){return{args:[this.toItem(e)],impl:H,argMeta:[{originalLocations:[]}]}}visitTupleSource(e){return{args:[this.toItem(e)],impl:H,argMeta:[{originalLocations:[]}]}}visitItemSource(e){return{args:[e],impl:H,argMeta:[{originalLocations:[]}]}}processItem(e){return e instanceof V?e:e instanceof q&&e.impl===ea?this.processItem(e.args[0]instanceof V?e.args[0]:e.args[0].op):e.accept(this.vmap)}processQuantifiedFn(e,t){return(...n)=>{let r=qo(n,t),i=hs(e.args,Vo.ANY),a=hs(e.args,Vo.ALL),o=i.map(e=>r[e]),s=a.map(e=>r[e]);anyLoop:for(let t of o.length?ps(o):[[]]){for(let n of s.length?ps(s):[[]]){for(let e=0;e<i.length;e++)r[i[e]]=t[e];for(let e=0;e<a.length;e++)r[a[e]]=n[e];if(!e.impl(...r))continue anyLoop}return!0}return!o.length}}processFnArg(e){if(e instanceof V)return e;let t=e.op.accept(this.vmap);return(e.acceptSequence||ms(e))&&t.impl===H&&(t.impl=ea),t}visitFnCall(e){e.args.forEach((t,n)=>{let r=t.op;r instanceof q&&r.impl===ea&&(e.args[n]=r.args[0])});let t=e.args.map(this.processFnArg);if(e.pure&&t.every(as)){let n=t.map(os),r=e.impl(...n);return{args:[],impl:()=>r,literal:!0,argMeta:[]}}let n=t.map((t,n)=>ls(t,e.args,n,e,!0));for(let t=0;t<n.length;t++)!(e.args[t]instanceof V)&&!(go in e.args[t].op)&&(n[t][0].acceptSequence=e.args[t].acceptSequence??!1);let r=n.flat();if(e.impl===ts.impl)for(let e=n[0].length;e<r.length;e++)r[e].maybeSkipped=!0;return{args:t.flatMap(ss),impl:e.args.some(ms)?this.processQuantifiedFn(e,t):(...n)=>{let r=qo(n,t);return e.impl(...r)},argMeta:r,aggregates:t.flatMap(cs)}}visitLiteral(e){return{args:[],impl:()=>e.value,literal:!0,argMeta:[]}}visitCalculation(e){return{args:[e],impl:ea,argMeta:[{originalLocations:[]}]}}processWhenThen(e){return[this.processItem(e[0]),this.processItem(e[1])]}visitConditional(e){let t=e.whenThens.map(this.processWhenThen),n=e.condition&&this.processItem(e.condition),r=e.defaultCase&&this.processItem(e.defaultCase),i=t.map(us),a=t.map(ds),o=t.map((t,n)=>fs(t,e.whenThens[n],e)).flat(2);r&&(i.push(ss(r)),a.push(cs(r)),o.push(...ls(r,e,`defaultCase`,e)));for(let e of o)e&&(e.maybeSkipped=!0);if(n&&(i.unshift(ss(n)),a.push(cs(n)),o.unshift(...ls(n,e,`condition`,e))),n?.literal){let e=this.processLiteralConditional(n,t,r);if(e)return e}return{args:i.flat(2),argMeta:o,impl:(...e)=>{let i=0,a=t=>t instanceof V?e[i++]:t.impl(...e.slice(i,i+=t.args.length)),o=!n||a(n),s=t.findIndex(([e,t])=>{let n=a(e)===o;return i+=t instanceof V?1:t.args.length,n});if(s===-1)return r?a(r):null;let c=t[s][1];return i-=c instanceof V?1:c.args.length,a(c)},aggregates:a.flat(2)}}processLiteralConditional(e,t,n){let r=e.impl(),i=!1;for(let[e,n]of t)if(e.literal){if(r===e.impl()){if(n.literal){let e=n.impl();return{args:[],impl:()=>e,literal:!0,argMeta:[]}}i=!0;break}}else{i=!0;break}if(!i&&n&&n.literal){let e=n.impl();return{args:[],impl:()=>e,literal:!0,argMeta:[]}}return null}visitCartesianProduct(e){return{args:[this.toItem(e)],impl:H,argMeta:[{originalLocations:[]}]}}visitJoin(e){return{args:[this.toItem(e)],impl:H,argMeta:[{originalLocations:[]}]}}visitProjectionConcat(e){return{args:[this.toItem(e)],impl:H,argMeta:[{originalLocations:[]}]}}visitMapToItem(e){return{args:[e],impl:H,argMeta:[{originalLocations:[]}]}}visitMapFromItem(e){return{args:[this.toItem(e)],impl:H,argMeta:[{originalLocations:[]}]}}visitProjectionIndex(e){return{args:[this.toItem(e)],impl:H,argMeta:[{originalLocations:[]}]}}visitOrderBy(e){return{args:[this.toItem(e)],impl:H,argMeta:[{originalLocations:[]}]}}visitGroupBy(e){return{args:[this.toItem(e)],impl:H,argMeta:[{originalLocations:[]}]}}visitLimit(e){return{args:[e.source instanceof K?this.toItem(e):e],impl:H,argMeta:[{originalLocations:[]}]}}visitUnion(e){return{args:[e.left instanceof K?this.toItem(e):e],impl:H,argMeta:[{originalLocations:[]}]}}visitIntersection(e){return{args:[e.left instanceof K?this.toItem(e):e],impl:H,argMeta:[{originalLocations:[]}]}}visitDifference(e){return{args:[e.left instanceof K?this.toItem(e):e],impl:H,argMeta:[{originalLocations:[]}]}}visitDistinct(e){return{args:[this.toItem(e)],impl:H,argMeta:[{originalLocations:[]}]}}visitNullSource(e){return{args:[e],impl:H,argMeta:[{originalLocations:[]}]}}visitAggregate(e){return{args:[e.fieldName],impl:ea,aggregates:[e],argMeta:[{aggregate:e,originalLocations:[]}]}}visitItemFnSource(e){return{args:[e],impl:H,argMeta:[{originalLocations:[]}]}}visitTupleFnSource(e){return{args:[this.toItem(e)],impl:H,argMeta:[{originalLocations:[]}]}}visitQuantifier(e){let t=e.query.accept(this.vmap);return t.argMeta[0].acceptSequence=!0,t.argMeta[0].originalLocations=[{obj:e,key:`query`,op:e}],t}visitRecursion(e){return{args:[this.toItem(e)],impl:H,argMeta:[{originalLocations:[]}]}}visitIndexScan(e){return{args:[this.toItem(e)],impl:H,argMeta:[{originalLocations:[]}]}}visitIndexedRecursion(e){return{args:[this.toItem(e)],impl:H,argMeta:[{originalLocations:[]}]}}visitBidirectionalRecursion(e){return{args:[this.toItem(e)],impl:H,argMeta:[{originalLocations:[]}]}}},_s=class{vmap;constructor(e){this.vmap=e}maybeRename(e,t){let n=t?.get(e.parts);return n?V.fromParts(n):e}processItem(e,{other:t,ignoreLang:n,renameMap:r}){return e instanceof V&&t instanceof V?e.equals(this.maybeRename(t,r)):e.constructor===t.constructor?!n&&e.lang!==t.lang?!1:e.accept(this.vmap,{other:t,ignoreLang:n,renameMap:r}):!!(e instanceof V&&t instanceof q&&t.impl===ea&&t.args.length===1&&t.args[0]instanceof V&&this.maybeRename(t.args[0],r).equals(e)||t instanceof V&&e instanceof q&&e.impl===ea&&e.args.length===1&&e.args[0]instanceof V&&e.args[0].equals(this.maybeRename(t,r)))}processArray(e,t,n){return e.length===t.length&&e.every((e,r)=>this.processItem(e,{...n,other:t[r]}))}areEqual(e,t,n){let r=n?.ignoreLang??!1,i=n?.renameMap;return this.processItem(e,{other:t,ignoreLang:r,renameMap:i})}visitRecursion(e,t){let n=t.other;return e.min===n.min&&e.max===n.max&&this.processItem(e.condition,{...t,other:n.condition})&&this.processArray(e.distinctKeys,n.distinctKeys,t)&&this.processItem(e.source,{...t,other:n.source})}visitProjection(e,t){let n=t.other;return e.attrs.length===n.attrs.length&&e.attrs.every((e,r)=>{let i=n.attrs[r];return e[1].equals(i[1])&&this.processItem(e[0],{...t,other:i[0]})})&&this.processItem(e.source,{...t,other:n.source})}visitSelection(e,t){let n=t.other;return this.processItem(e.condition,{...t,other:n.condition})&&this.processItem(e.source,{...t,other:n.source})}visitTupleSource(e,t){return this.visitItemSource(e,t)}visitItemSource(e,t){let n=t.other;return Array.isArray(e.name)?Array.isArray(n.name)&&e.name[0].equals(n.name[0])&&e.name[1].equals(n.name[1]):!Array.isArray(n.name)&&e.name.equals(n.name)}visitFnCall(e,t){let n=t.other;return e.impl===n.impl&&e.args.length===n.args.length&&e.args.every((e,r)=>{let i=n.args[r];return this.processItem(`op`in e?e.op:e,{...t,other:`op`in i?i.op:i})})}visitLiteral(e,t){let n=t.other;return no(e.value,n.value)}visitCalculation(e,t){let n=t.other;return this.processArray(e.args,n.args,t)&&!!e.original==!!n.original&&(e.original?this.processItem(e.original,{...t,other:n.original}):e.impl===n.impl)}visitConditional(e,t){let n=t.other;return this.processArray(e.whenThens.map(na),n.whenThens.map(na),t)&&this.processArray(e.whenThens.map(ra),n.whenThens.map(ra),t)&&(e.condition?!!n.condition&&this.processItem(e.condition,{...t,other:n.condition}):!n.condition)&&(e.defaultCase?!!n.defaultCase&&this.processItem(e.defaultCase,{...t,other:n.defaultCase}):!n.defaultCase)}visitCartesianProduct(e,t){let n=t.other;return this.processItem(e.left,{...t,other:n.left})&&this.processItem(e.right,{...t,other:n.right})}visitJoin(e,t){let n=t.other;return e.leftOuter===n.leftOuter&&e.rightOuter===n.rightOuter&&this.processArray(e.conditions,n.conditions,t)&&this.visitCartesianProduct(e,t)}visitProjectionConcat(e,t){let n=t.other;return e.outer===n.outer&&e.emptyVal.size===n.emptyVal.size&&so(e.emptyVal,n.emptyVal)&&this.processItem(e.mapping,{...t,other:n.mapping})&&this.processItem(e.source,{...t,other:n.source})}visitMapToItem(e,t){let n=t.other;return e.key.equals(n.key)&&this.processItem(e.source,{...t,other:n.source})}visitMapFromItem(e,t){let n=t.other;return e.key.equals(n.key)&&this.processItem(e.source,{...t,other:n.source})}visitProjectionIndex(e,t){let n=t.other;return e.indexCol.equals(n.indexCol)&&this.processItem(e.source,{...t,other:n.source})}visitOrderBy(e,t){let n=t.other;return e.orders.length===n.orders.length&&e.orders.every((e,r)=>{let i=n.orders[r];return e.ascending===i.ascending&&e.nullsFirst===i.nullsFirst&&this.processItem(e.key,{...t,other:i.key})})&&this.processItem(e.source,{...t,other:n.source})}visitGroupBy(e,t){let n=t.other;return e.keys.length===n.keys.length&&e.keys.every((e,r)=>{let i=n.keys[r];return e[1].equals(i[1])&&this.processItem(e[0],{...t,other:i[0]})})&&this.processArray(e.aggs,n.aggs,t)&&this.processItem(e.source,{...t,other:n.source})}visitLimit(e,t){let n=t.other;return e.limit===n.limit&&e.skip===n.skip&&this.processItem(e.source,{...t,other:n.source})}visitSetOp(e,t){let n=t.other;return this.processItem(e.left,{...t,other:n.left})&&this.processItem(e.right,{...t,other:n.right})}visitUnion(e,t){return this.visitSetOp(e,t)}visitIntersection(e,t){return this.visitSetOp(e,t)}visitDifference(e,t){return this.visitSetOp(e,t)}visitDistinct(e,t){let n=t.other;for(let[t,r]of[[e,n],[n,e]])if(t.attrs===Zi&&r.attrs!==Zi){let e=r.attrs.filter(oa);if(e.length!==r.attrs.length||e.length!==t.schema.length||!so(t.schemaSet,e))return!1}return e.attrs!==Zi&&!this.processArray(e.attrs,n.attrs,t)?!1:this.processItem(e.source,{...t,other:n.source})}visitNullSource(e,t){return!0}visitAggregate(e,t){let n=t.other;return e.impl===n.impl&&e.fieldName.equals(n.fieldName)&&this.processItem(e.postGroupOp,{...t,other:n.postGroupOp})&&this.processArray(e.args,n.args,t)}visitItemFnSource(e,t){let n=t.other;return e.impl===n.impl&&this.processArray(e.args,n.args,t)}visitTupleFnSource(e,t){let n=t.other;return e.impl===n.impl&&this.processArray(e.args,n.args,t)}visitQuantifier(e,t){let n=t.other;return e.type===n.type&&this.processItem(e.query,{...t,other:n.query})}visitIndexScan(e,t){let n=t.other;return this.visitTupleSource(e,t)&&this.processItem(e.access,{...t,other:n.access})}visitIndexedRecursion(e,t){let n=t.other;return e.min===n.min&&e.max===n.max&&this.processArray(e.distinctKeys,n.distinctKeys,t)&&this.processItem(e.mapping,{...t,other:n.mapping})&&this.processItem(e.source,{...t,other:n.source})}visitBidirectionalRecursion(e,t){let n=t.other;return e.min===n.min&&e.max===n.max&&this.processItem(e.mappingFwd,{...t,other:n.mappingFwd})&&this.processItem(e.mappingRev,{...t,other:n.mappingRev})&&this.processItem(e.source,{...t,other:n.source})&&this.processItem(e.target,{...t,other:n.target})}},$=new WeakMap,vs=class{vmap;constructor(e){this.vmap=e,this.processNode=this.processNode.bind(this)}onlyExternal(e,t){let n=e.clone();for(let e of t.schema)n.delete(e.parts);return n}processNode(e){return e.accept(this.vmap)}getCache(){return $}visitRecursion(e){if($.has(e))return $.get(e);let t=G(this.onlyExternal(G(this.visitCalculation(e.condition),...e.distinctKeys.filter(aa).map(this.processNode)??[]),e),e.source.accept(this.vmap));return $.set(e,t),t}visitProjection(e){if($.has(e))return $.get(e);let t=G(this.onlyExternal(G(...e.attrs.map(na).filter(aa).map(this.processNode),e.getDependencies()),e.source),e.source.accept(this.vmap));return $.set(e,t),t}visitSelection(e){if($.has(e))return $.get(e);let t=G(this.onlyExternal(this.visitCalculation(e.condition),e),e.source.accept(this.vmap));return $.set(e,t),t}visitTupleSource(e){return e.getDependencies()}visitItemSource(e){return e.getDependencies()}visitFnCall(e){if($.has(e))return $.get(e);let t=G(...e.args.filter(e=>`op`in e).map(e=>this.processNode(e.op)),e.getDependencies());return $.set(e,t),t}visitLiteral(e){return e.getDependencies()}visitCalculation(e){if($.has(e))return $.get(e);let t=G(...e.args.filter(e=>!oa(e)).map(this.processNode),e.getDependencies());return $.set(e,t),t}visitConditional(e){if($.has(e))return $.get(e);let t=G(...e.getChildren().map(this.processNode),e.getDependencies());return $.set(e,t),t}visitCartesianProduct(e){if($.has(e))return $.get(e);let t=G(e.left.accept(this.vmap),e.right.accept(this.vmap));return $.set(e,t),t}visitJoin(e){if($.has(e))return $.get(e);let t=G(this.onlyExternal(G(...e.conditions.map(this.processNode)),e),e.left.accept(this.vmap),e.right.accept(this.vmap));return $.set(e,t),t}visitProjectionConcat(e){if($.has(e))return $.get(e);let t=G(this.onlyExternal(e.mapping.accept(this.vmap),e),e.source.accept(this.vmap));return $.set(e,t),t}visitMapToItem(e){if($.has(e))return $.get(e);let t=e.source.accept(this.vmap);return $.set(e,t),t}visitMapFromItem(e){if($.has(e))return $.get(e);let t=e.source.accept(this.vmap);return $.set(e,t),t}visitProjectionIndex(e){if($.has(e))return $.get(e);let t=e.source.accept(this.vmap);return $.set(e,t),t}visitOrderBy(e){if($.has(e))return $.get(e);let t=G(this.onlyExternal(G(...e.orders.map(jo).filter(aa).map(this.processNode),e.getDependencies()),e),e.source.accept(this.vmap));return $.set(e,t),t}visitGroupBy(e){if($.has(e))return $.get(e);let t=G(this.onlyExternal(G(...e.keys.map(na).filter(aa).map(this.processNode),...e.aggs.map(this.processNode),e.getDependencies()),e),e.source.accept(this.vmap));return $.set(e,t),t}visitLimit(e){return $.has(e)?$.get(e):e.source.accept(this.vmap)}visitSetOp(e){if($.has(e))return $.get(e);let t=G(e.left.accept(this.vmap),e.right.accept(this.vmap));return $.set(e,t),t}visitUnion(e){return this.visitSetOp(e)}visitIntersection(e){return this.visitSetOp(e)}visitDifference(e){return this.visitSetOp(e)}visitDistinct(e){if($.has(e))return $.get(e);let t=G(e.attrs===Zi?e.getDependencies():this.onlyExternal(G(...e.attrs.filter(aa).map(this.processNode),e.getDependencies()),e),e.source.accept(this.vmap));return $.set(e,t),t}visitNullSource(e){return e.getDependencies()}visitAggregate(e){if($.has(e))return $.get(e);let t=G(...e.args.filter(aa).map(this.processNode),e.getDependencies(),e.postGroupOp.accept(this.vmap));return $.set(e,t),t}visitItemFnSource(e){if($.has(e))return $.get(e);let t=G(...e.args.filter(aa).map(this.processNode),e.getDependencies());return $.set(e,t),t}visitTupleFnSource(e){if($.has(e))return $.get(e);let t=G(...e.args.filter(aa).map(this.processNode),e.getDependencies());return $.set(e,t),t}visitQuantifier(e){if($.has(e))return $.get(e);let t=e.query.accept(this.vmap);return $.set(e,t),t}visitIndexScan(e){if($.has(e))return $.get(e);let t=this.onlyExternal(this.visitCalculation(e.access),e);return $.set(e,t),t}visitIndexedRecursion(e){if($.has(e))return $.get(e);let t=G(this.onlyExternal(G(e.mapping.accept(this.vmap),...e.distinctKeys.filter(aa).map(this.processNode)??[]),e),e.source.accept(this.vmap));return $.set(e,t),t}visitBidirectionalRecursion(e){if($.has(e))return $.get(e);let t=G(this.onlyExternal(G(e.mappingFwd.accept(this.vmap),e.mappingRev.accept(this.vmap)),e),e.source.accept(this.vmap),e.target.accept(this.vmap));return $.set(e,t),t}clearCache(){$=new WeakMap}invalidateCacheDownstream(e){for(;e;)$.delete(e),e=e.parent}invalidateCacheUpstream(e){$.delete(e);for(let t of e.getChildren())this.invalidateCacheUpstream(t)}invalidateCacheElement(e){$.delete(e)}},ys=class{vmap;constructor(e){this.vmap=e}mapVariables(e){let t={scopeStack:[new W],currentIndex:0,variableNames:[],translations:new Map};return e.accept(this.vmap,t),t}translate(e,t,n=t.scopeStack.length){let r=e.parts[0]===Qi,i=Math.max(0,t.scopeStack.length-n),a;for(let n=r?0:t.scopeStack.length-1;n>=i&&(a=t.scopeStack[n].get(e.parts),a===void 0);n--);return a||(a=V.fromParts([t.currentIndex]),t.scopeStack.at(r?0:-1).set(e.parts,a),t.variableNames[t.currentIndex++]=e),e.aggregate&&(a=V.fromParts([...a.parts]),a.aggregate=e.aggregate),a}removeFromCurrScope(e,t){t.scopeStack.at(-1).delete(e.parts)}translateArray(e,t){for(let n=0;n<e.length;n++){let r=e[n];r instanceof V?e[n]=this.translate(r,t):r.accept(this.vmap,t)}}union(e,...t){let n=new W;for(let[t,r]of e.entries())n.set(t,r);for(let e of t)for(let[t,r]of e.entries())n.set(t,r);return n}setTranslations(e,t){t.translations.set(e,{external:this.union(...t.scopeStack),scope:t.scopeStack.at(-1)})}visitRecursion(e,t){e.source.accept(this.vmap,t),this.setTranslations(e,t),this.translateArray(e.distinctKeys,t),this.visitCalculation(e.condition,t);for(let n of e.schema)this.translate(n,t,0)}visitProjection(e,t){e.source.accept(this.vmap,t);for(let n of e.attrs)n[0]instanceof V?(e.renames.delete(n[0].parts),e.renamesInv.delete(n[1].parts),n[0]=this.translate(n[0],t)):this.visitCalculation(n[0],t);let n=t.scopeStack.pop();t.scopeStack.push(n.clone());for(let n of e.source.schema)e.schemaSet.has(n.parts)||this.removeFromCurrScope(n,t);t.scopeStack.push(new W);for(let n of e.attrs)n[1]=this.translate(n[1],t,n[0]instanceof V&&n[0].equals(n[1])?2:1),n[0]instanceof V&&(e.renames.set(n[0].parts,n[1].parts),e.renamesInv.set(n[1].parts,n[0].parts));let r=t.scopeStack.pop(),i=this.union(t.scopeStack.pop(),r);t.currentIndex=Math.max(...Array.from(i.entries(),e=>e[1].parts[0]))+1,t.scopeStack.push(i),this.setTranslations(e,t);let a=t.translations.get(e);a.external=this.union(a.external,n)}visitSelection(e,t){e.source.accept(this.vmap,t),this.setTranslations(e,t),this.visitCalculation(e.condition,t)}visitTupleSource(e,t){let n=new W;t.scopeStack.push(n),this.setTranslations(e,t);for(let r of e.schema)t.variableNames[t.currentIndex]=r,n.set(r.parts,V.fromParts([t.currentIndex++]))}visitItemSource(e,t){this.setTranslations(e,t)}visitFnCall(e,t){for(let n=0;n<e.args.length;n++){let r=e.args[n];r instanceof V?e.args[n]=this.translate(r,t):go in r.op&&r.op.accept(this.vmap,t)}this.setTranslations(e,t)}visitLiteral(e,t){this.setTranslations(e,t)}visitCalculation(e,t){this.setTranslations(e,t),this.translateArray(e.args,t),e.original&&t.calcIntermediates&&e.original.accept(this.vmap,t)}visitConditional(e,t){for(let n of[`condition`,`defaultCase`]){let r=e[n];r&&(r instanceof V?e[n]=this.translate(r,t):go in r&&r.accept(this.vmap,t))}for(let n of e.whenThens)for(let e of[0,1])n[e]instanceof V?n[e]=this.translate(n[e],t):go in n[e]&&n[e].accept(this.vmap,t);this.setTranslations(e,t)}visitCartesianProduct(e,t){e.left.accept(this.vmap,t);let n=t.scopeStack.pop();e.right.accept(this.vmap,t);let r=t.scopeStack.pop(),i=this.union(r,n);t.scopeStack.push(i),this.setTranslations(e,t),t.currentIndex=Math.max(...Array.from(i.entries(),e=>e[1].parts[0]))+1}visitJoin(e,t){this.visitCartesianProduct(e,t);for(let n of e.conditions)this.visitCalculation(n,t)}visitProjectionConcat(e,t){e.source.accept(this.vmap,t),e.mapping.accept(this.vmap,t);let n=t.scopeStack.pop(),r=t.scopeStack.pop(),i=this.union(n,r);if(e.outer){let n=e.emptyVal;e.emptyVal=new W;for(let[r,i]of n.entries())e.emptyVal.set(t.scopeStack.at(-1).get(r).parts,i)}t.scopeStack.push(i),this.setTranslations(e,t),t.currentIndex=Math.max(...Array.from(i.entries(),e=>e[1].parts[0]))+1}visitMapToItem(e,t){e.source.accept(this.vmap,t),this.setTranslations(e,t),e.key=this.translate(e.key,t),t.currentIndex-=t.scopeStack.pop().size}visitMapFromItem(e,t){e.source.accept(this.vmap,t),t.scopeStack.push(new W),this.setTranslations(e,t),e.key=this.translate(e.key,t,1)}visitProjectionIndex(e,t){e.source.accept(this.vmap,t),this.setTranslations(e,t),e.indexCol=this.translate(e.indexCol,t,1)}visitOrderBy(e,t){e.source.accept(this.vmap,t),this.setTranslations(e,t);for(let n of e.orders)n.key instanceof V?n.key=this.translate(n.key,t):this.visitCalculation(n.key,t)}visitAggregate(e,t){e.postGroupOp.accept(this.vmap,t),this.setTranslations(e,t);for(let n=0;n<e.args.length;n++){let r=e.args[n];r instanceof V?e.args[n]=this.translate(r,t):this.visitCalculation(r,t)}t.currentIndex-=t.scopeStack.pop().size}visitGroupBy(e,t){e.source.accept(this.vmap,t),this.setTranslations(e,t);for(let n of e.keys)n[0]instanceof V?n[0]=this.translate(n[0],t):this.visitCalculation(n[0],t);for(let n of e.keys)n[1]=this.translate(n[1],t,1);for(let n of e.aggs)n.fieldName=this.translate(n.fieldName,t,1);for(let n of e.aggs)this.visitAggregate(n,t)}visitLimit(e,t){e.source.accept(this.vmap,t),this.setTranslations(e,t)}visitSetOp(e,t){e.left.accept(this.vmap,t),this.setTranslations(e,t);let n;e.left instanceof K&&e.left.schema&&(n=t.scopeStack.pop(),t.currentIndex-=n.size),e.right.accept(this.vmap,t),e.right instanceof K&&e.right.schema&&(t.currentIndex-=t.scopeStack.pop().size-n.size,t.scopeStack.push(n))}visitUnion(e,t){this.visitSetOp(e,t)}visitIntersection(e,t){this.visitSetOp(e,t)}visitDifference(e,t){this.visitSetOp(e,t)}visitDistinct(e,t){if(e.source.accept(this.vmap,t),this.setTranslations(e,t),e.attrs!==Zi)for(let n=0;n<e.attrs.length;n++){let r=e.attrs[n];r instanceof V?e.attrs[n]=this.translate(r,t):this.visitCalculation(r,t)}}visitNullSource(e,t){t.scopeStack.push(new W),this.setTranslations(e,t)}visitItemFnSource(e,t){this.setTranslations(e,t);for(let n=0;n<e.args.length;n++){let r=e.args[n];r instanceof V?e.args[n]=this.translate(r,t):this.visitCalculation(r,t)}}visitTupleFnSource(e,t){let n=new W;t.scopeStack.push(n),this.setTranslations(e,t);for(let n=0;n<e.args.length;n++){let r=e.args[n];r instanceof V?e.args[n]=this.translate(r,t):this.visitCalculation(r,t)}for(let r of e.schema)t.variableNames[t.currentIndex]=r,n.set(r.parts,V.fromParts([t.currentIndex++]))}visitQuantifier(e,t){this.setTranslations(e,t)}visitIndexScan(e,t){this.visitTupleSource(e,t),e.fromItemKey&&=this.translate(e.fromItemKey,t,1),this.visitCalculation(e.access,t)}visitIndexedRecursion(e,t){e.source.accept(this.vmap,t),e.mapping.accept(this.vmap,t),t.currentIndex-=t.scopeStack.pop().size,t.scopeStack.push(new W);for(let n of e.schema)this.translate(n,t,1);this.translateArray(e.distinctKeys,t);let n=t.scopeStack.pop(),r=this.union(t.scopeStack.pop(),n);t.currentIndex=Math.max(...Array.from(r.entries(),e=>e[1].parts[0]))+1,t.scopeStack.push(r),this.setTranslations(e,t)}visitBidirectionalRecursion(e,t){e.source.accept(this.vmap,t),e.target.accept(this.vmap,t);let n=t.scopeStack.pop(),r=t.scopeStack.pop(),i=this.union(r,n);t.scopeStack.push(i),this.setTranslations(e,t),t.currentIndex=Math.max(...Array.from(i.entries(),e=>e[1].parts[0]))+1;for(let n of[`mappingFwd`,`mappingRev`])e[n].accept(this.vmap,t),t.currentIndex-=t.scopeStack.pop().size}},bs=class{variableValues=[];variableNames=[];translations=new Map;get(e){return this.variableValues[e.parts[0]]}set(e,t){this.variableValues[e.parts[0]]=t}setTuple(e,t){for(let n of t)this.variableValues[n]=e[n];return e}getKeys(e){let t=this.translations.get(e);return e.schema.map(e=>t.scope.get(e.parts)?.parts[0]??t.external.get(e.parts).parts[0])}getTranslation(e,t){let n=this.translations.get(e);return(n.scope.get(t)??n.external.get(t)).parts[0]}getRenames(e,t){let n=this.translations.get(e),r=this.translations.get(t);return e.schema.map(e=>(r.scope.get(e.parts)??n.scope.get(e.parts)??n.external.get(e.parts)).parts[0])}},xs=n((e=>{e.ARRAY_BUFFER_SUPPORT=typeof ArrayBuffer<`u`,e.SYMBOL_SUPPORT=typeof Symbol<`u`})),Ss=n(((e,t)=>{var n=xs(),r=n.ARRAY_BUFFER_SUPPORT,i=n.SYMBOL_SUPPORT;t.exports=function(e,t){var n,a,o,s,c;if(!e)throw Error(`obliterator/forEach: invalid iterable.`);if(typeof t!=`function`)throw Error(`obliterator/forEach: expecting a callback.`);if(Array.isArray(e)||r&&ArrayBuffer.isView(e)||typeof e==`string`||e.toString()===`[object Arguments]`)for(o=0,s=e.length;o<s;o++)t(e[o],o);else if(typeof e.forEach==`function`)e.forEach(t);else if(i&&Symbol.iterator in e&&typeof e.next!=`function`&&(e=e[Symbol.iterator]()),typeof e.next==`function`)for(n=e,o=0;c=n.next(),c.done!==!0;)t(c.value,o),o++;else for(a in e)e.hasOwnProperty(a)&&t(e[a],a)}})),Cs=n(((e,t)=>{function n(e){if(typeof e!=`function`)throw Error(`obliterator/iterator: expecting a function!`);this.next=e}typeof Symbol<`u`&&(n.prototype[Symbol.iterator]=function(){return this}),n.of=function(){var e=arguments,t=e.length,r=0;return new n(function(){return r>=t?{done:!0}:{done:!1,value:e[r++]}})},n.empty=function(){return new n(function(){return{done:!0}})},n.fromSequence=function(e){var t=0,r=e.length;return new n(function(){return t>=r?{done:!0}:{done:!1,value:e[t++]}})},n.is=function(e){return e instanceof n||typeof e==`object`&&!!e&&typeof e.next==`function`},t.exports=n})),ws=e(n(((e,t)=>{var n=Cs(),r=Ss();function i(){this.clear()}i.prototype.clear=function(){this.items=[],this.offset=0,this.size=0},i.prototype.enqueue=function(e){return this.items.push(e),++this.size},i.prototype.dequeue=function(){if(this.size){var e=this.items[this.offset];return++this.offset*2>=this.items.length&&(this.items=this.items.slice(this.offset),this.offset=0),this.size--,e}},i.prototype.peek=function(){if(this.size)return this.items[this.offset]},i.prototype.forEach=function(e,t){t=arguments.length>1?t:this;for(var n=this.offset,r=0,i=this.items.length;n<i;n++,r++)e.call(t,this.items[n],r,this)},i.prototype.toArray=function(){return this.items.slice(this.offset)},i.prototype.values=function(){var e=this.items,t=this.offset;return new n(function(){if(t>=e.length)return{done:!0};var n=e[t];return t++,{value:n,done:!1}})},i.prototype.entries=function(){var e=this.items,t=this.offset,r=0;return new n(function(){if(t>=e.length)return{done:!0};var n=e[t];return t++,{value:[r++,n],done:!1}})},typeof Symbol<`u`&&(i.prototype[Symbol.iterator]=i.prototype.values),i.prototype.toString=function(){return this.toArray().join(`,`)},i.prototype.toJSON=function(){return this.toArray()},i.prototype.inspect=function(){var e=this.toArray();return Object.defineProperty(e,"constructor",{value:i,enumerable:!1}),e},typeof Symbol<`u`&&(i.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=i.prototype.inspect),i.from=function(e){var t=new i;return r(e,function(e){t.enqueue(e)}),t},i.of=function(){return i.from(arguments)},t.exports=i}))(),1),Ts=class{value;next;constructor(e,t=null){this.value=e,this.next=t}};function Es(e,t,n){let r=[];for(let e of t)r[e]=[];for(;e.next;){for(let n of t)r[n].push(e.value[n]);e=e.next}if(n)for(let t of n)r[t]=e.value[t];for(let n of t)r[n].push(e.value[n]),r[n].reverse();return r}function Ds(e,t){return n=>{let r=[];for(let i=0;i<e.length;i++)r[t[i]]=n[e[i]];return r}}var Os=class{lang;vmap;db;serialize;tdeps={};calcBuilders;eqCheckers;indexCache=new Map;constructor(e,t,n){this.lang=e,this.vmap=t,this.db=n,this.serialize=this.db.langMgr.getLang(this.lang).serialize,this.tdeps=n.langMgr.getVisitorMap(`transitiveDependencies`),this.calcBuilders=n.langMgr.getVisitorMap(`calculationBuilder`),this.eqCheckers=n.langMgr.getVisitorMap(`equalityChecker`)}execute(e,t,n){let r=new bs;if(n){let e=t.scopeStack[0];for(let[t,i]of Object.entries(n)){let n=e.get([Qi,t]);if(!n)throw Error(`Bound parameter ${t} not found`);r.set(n,i)}}r.translations=t.translations,r.variableNames=t.variableNames;let i=e.accept(this.vmap,r);return this.indexCache.clear(),{result:i,ctx:r}}processItem(e,t){return e instanceof V?t.get(e):this.visitCalculation(e,t)[0]}renameKeys(e,t,n){let r=[];for(let i=0;i<t.length;i++)r[n[i]]=e[t[i]];return r}*visitRecursion(e,t){if(e.min>e.max||e.max===0)return;let n=new ws.default,r=[],i=t.getKeys(e),a=t.getKeys(e.source),o=Ds(a,t.getRenames(e.source,e)),s=new W,c=e.distinctKeys.length>0;for(let l of e.source.accept(this.vmap,t)){r.push(l);let u=new Ts([]);for(let e of a)u.value[e]=l[e];if(e.min<=1||c){let n=t.setTuple(Es(u,a),a);if(c&&!this.distinctCheck(e.distinctKeys,s,t))continue;e.min<=1&&(yield t.setTuple(o(n),i))}e.max>1&&n.enqueue(u)}let l=1;for(;n.size>0;){l++;let u=n.size;for(let d=0;d<u;d++){let u=n.dequeue();for(let d of r){let r=Es(u,a);for(let e of a)t.variableValues[e]=[r[e],d[e]];if(this.visitCalculation(e.condition,t)[0]){if(l>=e.min||c){for(let e of a)r[e].push(d[e]);if(t.setTuple(r,a),c&&!this.distinctCheck(e.distinctKeys,s,t))continue;l>=e.min&&(yield t.setTuple(o(r),i))}if(l<e.max){let e=new Ts([],u);for(let t of a)e.value[t]=d[t];n.enqueue(e)}}}}}}*visitIndexedRecursion(e,t){if(e.min>e.max||e.max===0)return;let n=new ws.default,r=t.getKeys(e),i=t.getKeys(e.source),a=t.getRenames(e.source,e.mapping),o=Ds(i,t.getRenames(e.source,e)),s=e.distinctKeys.length>0,c=new W;for(let a of e.source.accept(this.vmap,t)){let l=new Ts([]);for(let e of i)l.value[e]=a[e];if(e.min<=1||s){let n=t.setTuple(o(Es(l,i)),r);if(s&&!this.distinctCheck(e.distinctKeys,c,t))continue;e.min<=1&&(yield n)}e.max>1&&n.enqueue(l)}let l=1;for(;n.size>0;){l++;let u=n.size;for(let d=0;d<u;d++){let u=n.dequeue();t.setTuple(Es(u,i),i);for(let d of e.mapping.accept(this.vmap,t)){if(l>=e.min||s){let n=Es(u,i);for(let e=0;e<i.length;e++)n[i[e]].push(d[a[e]]);if(n=t.setTuple(o(n),r),s&&!this.distinctCheck(e.distinctKeys,c,t))continue;l>=e.min&&(yield n)}if(l<e.max){let e=new Ts([],u);for(let t=0;t<i.length;t++)e.value[i[t]]=d[a[t]];n.enqueue(e)}}}}}*expandBidiFrontier(e,t,n,r,i,a,o,s,c,l,u,d){let f=e.size;for(let p=0;p<f;p++){let f=e.dequeue(),p=Es(f,c,l);a.setTuple(p,c),a.setTuple(p,l);for(let p of i(a)){let i=new Ts(p,f),m=ma(p,c);if(!d||d.has(m)){if(r>=o){let e=t.get(m);e&&(yield*this.joinBidiPaths(u?[i]:e,u?e:[i],a,c,l))}r<=s&&(e.enqueue(i),n.get(m,[]).push(i))}}}}*joinBidiPaths(e,t,n,r,i){let a=r.concat(i);for(let o of e){let e=Es(o,r,i);for(let t of r)e[t].pop();for(let o of t){for(;o.next;){for(let t of r)e[t].push(o.value[t]);o=o.next}for(let t of r)e[t].push(o.value[t]);for(let t of i)e[t]??=o.value[t];yield n.setTuple(e,a)}}}getBidiKeys(e,t){let n=Array.from(ao(e.schemaSet,e.mappingFwd.schemaSet)).map(n=>t.getTranslation(e,n)),r=e.mappingFwd.schema.map(n=>t.getTranslation(e,n.parts)),i=t.getRenames(e.mappingFwd,e),a=t.getRenames(e.mappingRev,e),o=t.getRenames(e.target,e),s=t.getRenames(e.source,e),c=t.getKeys(e.mappingFwd),l=t.getKeys(e.mappingRev),u=t.getKeys(e.target),d=t.getKeys(e.source);return{keys:r,initialKeys:n,fwdRenamer:Ds(c,i),revRenamer:Ds(l,a),tgtRenamer:Ds(u,o),srcRenamer:Ds(d,s)}}getBidiGroups(e,t,n){let r=e.target.accept(this.tdeps),i=Array.from(r).map(n=>t.getTranslation(e,n));if(r.size===0){let r=new ws.default;for(let i of e.source.accept(this.vmap,t)){let e=new Ts(n(i));r.enqueue(e)}return r.size?[r]:[]}let a=new W;for(let r of e.source.accept(this.vmap,t)){let e=new Ts(n(r)),t=ma(e.value,i),o=a.get(t);o?o.enqueue(e):(o=ws.default.of(e),a.set(t,o))}return Array.from(a.entries()).map(([e,t])=>t)}*initBidiFrontiers(e,t,n,r,i,a,o,s,c){let l=n.peek();t.setTuple(l.value,s),t.setTuple(l.value,o);for(let e of n){let t=ma(e.value,o);i.get(t,[]).push(e)}for(let n of e.target.accept(this.vmap,t)){let l=new Ts(c(n));r.enqueue(l);let u=ma(l.value,o);a.get(u,[]).push(l);let d=i.get(u);e.min<=1&&d&&(yield*this.joinBidiPaths(d,[l],t,o,s))}}bfsCheckSide(e,t,n,r,i,a,o){let s=new W;for(let t of e){let e=ma(t.value,r);(!o||o.has(e))&&s.add(e)}let c=0;for(;e.size>0;){let l=e.size;c++;for(let u=0;u<l;u++){let l=e.dequeue(),u=Es(l,r,i);n.setTuple(u,r),n.setTuple(u,i);for(let i of t(n)){let t=new Ts(i,l),n=ma(i,r);s.has(n)||o&&!o.has(n)||c<=a&&(e.enqueue(t),s.add(n))}}}return s}bfsCheck(e,t,n,r,i,a,o,s){let c=this.bfsCheckSide(e,n,i,a,o,s);return this.bfsCheckSide(t,r,i,a,o,s,c)}*visitBidirectionalRecursion(e,t){if(e.min>e.max||e.max===0)return;let{keys:n,initialKeys:r,fwdRenamer:i,revRenamer:a,tgtRenamer:o,srcRenamer:s}=this.getBidiKeys(e,t),c=new ws.default,l=new W,u=new W,d=this.getBidiGroups(e,t,s);for(let s of d){if(yield*this.initBidiFrontiers(e,t,s,c,l,u,n,r,o),e.max===1)return;let d=t=>Iterator.from(e.mappingFwd.accept(this.vmap,t)).map(i),f=t=>Iterator.from(e.mappingRev.accept(this.vmap,t)).map(a),p=null,m=1;for(;(s.size&&(c.size||u.size)||c.size&&(s.size||l.size))&&m<e.max;){if(m>=4&&!p&&(p=this.bfsCheck(ws.default.from(s),ws.default.from(c),d,f,t,n,r,e.max),p.size===0))return;s.size>0&&(c.size===0||s.size<=c.size)?(m++,l=new W,yield*this.expandBidiFrontier(s,u,l,m,d,t,e.min,e.max,n,r,!0,p)):c.size>0&&(s.size===0||c.size<=s.size)&&(m++,u=new W,yield*this.expandBidiFrontier(c,l,u,m,f,t,e.min,e.max,n,r,!1,p))}}}*visitProjection(e,t){let n=e.attrs.map(e=>e[1].parts[0]);for(let r of e.source.accept(this.vmap,t)){let r=[];for(let n of e.attrs)r[n[1].parts[0]]=this.processItem(n[0],t);yield t.setTuple(r,n)}}*visitSelection(e,t){for(let n of e.source.accept(this.vmap,t))this.visitCalculation(e.condition,t)[0]&&(yield n)}visitTupleSource(e,t){let n=this.db.getSource(e.name.parts);return this.generateTuplesFromValues(n,e,t)}visitItemSource(e,t){throw Error(`Method not implemented.`)}visitFnCall(e,t){throw Error(`Method not implemented.`)}visitLiteral(e,t){throw Error(`Method not implemented.`)}visitCalculation(e,t){return[e.impl(...e.args.map(e=>e instanceof V?t.get(e):da(e.accept(this.vmap,t))))]}visitConditional(e,t){throw Error(`Method not implemented.`)}*visitCartesianProduct(e,t){let n=da(e.right.accept(this.vmap,t));if(n.length===0)return;let r=t.getKeys(e.right),i=e.left.accept(this.vmap,t),a=t.getKeys(e.left),o=t.getKeys(e),s=t.getRenames(e.right,e);for(let c of i)for(let i of this.validateSingleValue(e,n)){let e=[];for(let t of a)e[t]=c[t];for(let t=0;t<r.length;t++)e[s[t]]=i[r[t]];yield t.setTuple(e,o)}}*visitJoin(e,t){!e.leftOuter&&!e.rightOuter?yield*this.visitInnerJoin(e,t):e.leftOuter&&!e.rightOuter?yield*this.visitLeftJoin(e.left,e.right,e,t):!e.leftOuter&&e.rightOuter?yield*this.visitLeftJoin(e.right,e.left,e,t):yield*this.visitFullJoin(e,t)}*visitInnerJoin(e,t){let n=t.getKeys(e.right),r=t.getKeys(e.left),i=t.getRenames(e.right,e),a=t.getKeys(e),[o,s]=this.joinValues(e.left,e.right,e,t);for(let[c,l]of s)yield*this.validateSingleValue(e,Iterator.from(l).map(e=>{let o=[];for(let e of r)o[e]=c[e];for(let t=0;t<n.length;t++)o[i[t]]=e[n[t]];return t.setTuple(o,a)}).filter(()=>o.every(e=>this.visitCalculation(e,t)[0])))}*visitLeftJoin(e,t,n,r){let i=r.getKeys(t),a=r.getKeys(e),o=r.getRenames(t,n),s=r.getKeys(n),[c,l]=this.joinValues(e,t,n,r);for(let[e,t]of l){let l=!1;if(yield*this.validateSingleValue(n,Iterator.from(t).map(t=>{let n=[];for(let t of a)n[t]=e[t];for(let e=0;e<i.length;e++)n[o[e]]=t[i[e]];if(r.setTuple(n,s),c.every(e=>this.visitCalculation(e,r)[0]))return l=!0,n}).filter(e=>e)),!l){let t=[];for(let n of a)t[n]=e[n];for(let e of o)t[e]=null;yield r.setTuple(t,s)}}}*visitFullJoin(e,t){let n=t.getKeys(e.right),r=t.getKeys(e.left),i=t.getRenames(e.right,e),a=t.getKeys(e),[o,s,c]=this.joinValues(e.left,e.right,e,t),l=new Set(c);for(let[c,u]of s){let s=!1;if(yield*this.validateSingleValue(e,Iterator.from(u).map(e=>{let u=[];for(let e of r)u[e]=c[e];for(let t=0;t<n.length;t++)u[i[t]]=e[n[t]];if(t.setTuple(u,a),o.every(e=>this.visitCalculation(e,t)[0]))return s=!0,l.delete(e),u}).filter(e=>e)),!s){let e=[];for(let t of r)e[t]=c[t];for(let t of i)e[t]=null;yield t.setTuple(e,a)}}for(let e of l){let o=[];for(let e of r)o[e]=null;for(let t=0;t<n.length;t++)o[i[t]]=e[n[t]];yield t.setTuple(o,a)}}joinValues(e,t,n,r){let i=this.getBestJoinIndex(e,t,n,r);return i?this.hashJoinValues(e,t,n,r,...i):[n.conditions,...this.nestedLoopJoinValues(e,t,r)]}hashJoinValues(e,t,n,r,i,a,o){let s=new o(i,this.db),c=s.createAccessor(a);c.args.forEach((e,t)=>{e instanceof V&&(c.args[t]=V.fromParts([r.getTranslation(n,e.parts)]))});let l=n.conditions.filter(e=>!a.some(t=>t.containingFn===e.original)),u=Iterator.from(t.accept(this.vmap,r));return s.reindex(u.map(e=>({value:e,keys:i.map(e=>this.visitCalculation(e,r)[0])}))),[l,Iterator.from(e.accept(this.vmap,r)).map(e=>[e,this.visitCalculation(c,r)[0]]),s.allValues()]}getIndexMatchInputs(e,t){return t.conditions.filter(e=>e.original instanceof q).flatMap(e=>e.original.args.map((t,n)=>({expr:t instanceof V?t:t.op,containingFn:e.original,i:n}))).filter(({expr:t})=>t instanceof V?!e.schemaSet.has(t.parts):!co(e.schemaSet,t.accept(this.tdeps)))}findIndexableExpressions(e,t){return this.db.config.executor?.hashJoinIndices.map(n=>{let r=n.canIndex(e);return r=r?.filter(n=>{let i=e[n].containingFn;for(let n=0;n<i.args.length;n++){if(r.some(t=>e[t].i===n&&e[t].containingFn===i))continue;let a=i.args[n];if(a instanceof V){if(t.schemaSet.has(a.parts))return!1}else if(co(t.schemaSet,a.op.accept(this.tdeps)))return!1}return!0}),[r??[],n]}).filter(([e])=>e.length>0)}getBestJoinIndex(e,t,n,r){if(this.indexCache.has(n))return this.indexCache.get(n);if(this.db.config.executor?.hashJoinIndices===void 0)return null;let i=this.getIndexMatchInputs(e,n),a=this.findIndexableExpressions(i,t);if(!a?.length)return null;let o=a[0];for(let e=1;e<a.length;e++)a[e][0].length>o[0].length&&(o=a[e]);let s=o[0].map(e=>{let t=i[e].expr;return To(t instanceof V?new q(n.lang,[t],ea):t,this.calcBuilders,this.eqCheckers)});for(let e of s)e.args.forEach((t,i)=>{t instanceof V&&(e.args[i]=V.fromParts([r.getTranslation(n,t.parts)]))});let c=[s,o[0].map(e=>i[e]),o[1]];return this.indexCache.set(n,c),c}nestedLoopJoinValues(e,t,n){let r=da(t.accept(this.vmap,n));return[Iterator.from(e.accept(this.vmap,n)).map(e=>[e,r]),r]}*visitProjectionConcat(e,t){let n=t.getKeys(e.mapping),r=[];for(let t of n)r[t]=e.emptyVal.get([t],null);let i=e.source.accept(this.vmap,t),a=t.getKeys(e.source),o=t.getKeys(e),s=t.getRenames(e.mapping,e),c=(e,r)=>{let i=[];for(let t of a)i[t]=e[t];for(let e=0;e<n.length;e++)i[s[e]]=r[n[e]];return t.setTuple(i,o)};for(let n of i){let i=e.mapping.accept(this.vmap,t)[Symbol.iterator](),a=i.next();if(a.done)e.outer&&(yield c(n,r));else{if(yield c(n,a.value),a=i.next(),e.validateSingleValue&&!a.done)throw Error(`Mapping returned more than one value`);if(!a.done)do yield c(n,a.value);while(!(a=i.next()).done)}}}validateSingleValue(e,t){if(e.validateSingleValue){let e=t[Symbol.iterator](),n=e.next();if(n.done)return[];let r=n.value;if(!e.next().done)throw Error(`Operator returned more than one value`);return[r]}return t}*visitMapToItem(e,t){let n=e.source.accept(this.vmap,t),r=e.key.parts[0];if(t.translations.get(e).scope.get([Zi])?.parts[0]===r)yield*this.serialize(n,t,e.source).data;else for(let e of n)yield e[r]}*visitMapFromItem(e,t){let n=e.source.accept(this.vmap,t),r=e.key.parts[0];for(let e of n){let n=[];n[r]=t.variableValues[r]=e,yield n}}*visitProjectionIndex(e,t){let n=1,r=t.getKeys(e.source),i=e.indexCol.parts[0];for(let a of e.source.accept(this.vmap,t)){let e=[];for(let t of r)e[t]=a[t];t.variableValues[i]=n,e[i]=n++,yield e}}*visitOrderBy(e,t){let n=[],r=Symbol(`indexCol`),i=[],a=t.getKeys(e),o=0;for(let a of e.source.accept(this.vmap,t)){n.push(a);let s=e.orders.map(e=>this.processItem(e.key,t));s[r]=o++,i.push(s)}i.sort((t,n)=>{for(let r=0;r<e.orders.length;r++){let i=e.orders[r],a=t[r],o=n[r];if(a!==o)return a===null?i.nullsFirst?-1:1:o===null?i.nullsFirst?1:-1:a<o?i.ascending?-1:1:i.ascending?1:-1}return 0});for(let e of i)yield t.setTuple(n[e[r]],a)}*visitGroupBy(e,t){let n=new W,r=t.getKeys(e.source),i=e.aggs.map(n=>Ds(r,t.getRenames(e.source,n.postGroupSource))),a=e.aggs.map(e=>t.getKeys(e.postGroupSource)),o=t.getKeys(e),s=e.keys.map(e=>e[1].parts[0]);for(let r of e.source.accept(this.vmap,t)){let i=e.keys.map(e=>this.processItem(e[0],t)),a=n.get(i);a||(a=[],n.set(i,a)),a.push(r)}let c=e.aggs.map(e=>e.postGroupSource.accept),l=this.prepareAggNullChecks(e,t);for(let[c,u]of n.size===0&&e.keys.length===0?[[[],[]]]:n.entries()){let n=[];for(let e=0;e<s.length;e++)n[s[e]]=c[e];if(u.length>0)for(let e of r)n[e]=u[0][e];for(let r=0;r<e.aggs.length;r++){let o=e.aggs[r];o.postGroupSource.accept=()=>Iterator.from(u).map(e=>t.setTuple(i[r](e),a[r]));let s=o.impl.init(),c=!o.impl.includeNulls;for(let e of o.postGroupOp.accept(this.vmap,t)){let e=o.args.map(e=>this.processItem(e,t));c&&e.some(l[r])||(s=o.impl.step(s,...e))}n[o.fieldName.parts[0]]=o.impl.result(s)}yield t.setTuple(n,o)}for(let t=0;t<e.aggs.length;t++)e.aggs[t].postGroupSource.accept=c[t]}prepareAggNullChecks(e,t){let n=e.aggs.map(e=>{let n=[];for(let[r,i]of t.translations.get(e.postGroupSource).scope.entries())n[i.parts[0]]=r.at(-1);return e.args.map(e=>e instanceof V&&n[e.parts[0]]===Zi)});return e.aggs.map((e,t)=>(e,r)=>e==null&&!n[t][r])}*visitLimit(e,t){let n=e.source.accept(this.vmap,t),r=0;if(Array.isArray(n))yield*n.slice(e.skip,e.limit+e.skip);else for(let t of n){if(r++,r>e.limit+e.skip)break;r>e.skip&&(yield t)}}*visitUnion(e,t){if(yield*e.left.accept(this.vmap,t),!(e.right instanceof K)){yield*e.right.accept(this.vmap,t);return}let n=t.getKeys(e),r=t.getKeys(e.right);for(let i of e.right.accept(this.vmap,t))yield t.setTuple(this.renameKeys(i,r,n),n)}*visitIntersection(e,t){if(!(e.left instanceof K)){yield*this.visitIntersectionItems(e.left.accept(this.vmap,t),e.right.accept(this.vmap,t));return}let n=t.getKeys(e.left),r=t.getKeys(e.right),i=e.left.accept(this.vmap,t),a=new W;for(let e of i)a.add(n.map(t=>e[t]));for(let i of e.right.accept(this.vmap,t)){let e=r.map(e=>i[e]);a.has(e)&&(yield t.setTuple(this.renameKeys(i,r,n),n))}}*visitIntersectionItems(e,t){let n=new Set(e);for(let e of t)n.has(e)&&(yield e)}*visitDifference(e,t){if(!(e.left instanceof K)){yield*this.visitDifferenceItems(e.left.accept(this.vmap,t),e.right.accept(this.vmap,t));return}let n=t.getKeys(e.left),r=t.getKeys(e.right),i=e.right.accept(this.vmap,t),a=new W;for(let e of i)a.add(r.map(t=>e[t]));for(let r of e.left.accept(this.vmap,t)){let e=n.map(e=>r[e]);a.has(e)||(yield r)}}*visitDifferenceItems(e,t){let n=new Set(t);for(let t of e)n.has(t)||(yield t)}*distinctStream(e,t,n,r){for(let i of e)this.distinctCheck(t,n,r)&&(yield i)}distinctCheck(e,t,n){let r=e.map(e=>this.processItem(e,n));return!t.has(r)&&(t.add(r),!0)}visitDistinct(e,t){let n=new W,r=e.source.accept(this.vmap,t),i=e.attrs===Zi?t.getKeys(e).map(e=>V.fromParts([e])):e.attrs;return this.distinctStream(r,i,n,t)}visitNullSource(e,t){return[null]}visitAggregate(e,t){throw Error(`Method not implemented.`)}visitItemFnSource(e,t){return e.impl(...e.args.map(e=>this.processItem(e,t)))}visitTupleFnSource(e,t){let n=e.impl(...e.args.map(e=>this.processItem(e,t)));return this.generateTuplesFromValues(n,e,t)}visitQuantifier(e,t){throw Error(`Method not implemented.`)}*visitIndexScan(e,t){let n=this.visitCalculation(e.access,t)[0];if(e.fromItemKey){let r=e.fromItemKey.parts[0];for(let e of n){let n=[];n[r]=t.variableValues[r]=e,yield n}}else yield*this.generateTuplesFromValues(n,e,t)}generateTuplesFromValues(e,t,n){throw Error(`Method not implemented.`)}},ks=Symbol(`toInfer`),As={logicalPlan:{calculationBuilder:gs,transitiveDependencies:vs,attributeRenamer:Ko,attributeRenameChecker:Go,equalityChecker:_s,variableMapper:ys,executor:null}},js=class e{db;langs={};static allLangs=Symbol(`allLangs`);operators=new W;functions=new W;aggregates=new W;castables=new W;constructor(e){this.db=e}registerExtension(t){let n=t.scope??[e.allLangs],r=[`operators`,`functions`,`aggregates`,`castables`];for(let e of n)for(let n of r)for(let r of t[n]??[])this[n].set([e,r.schema??t.schema,r.name],r)}registerLang(e){this.langs[e.name.toLowerCase()]=e,this.registerExtension({...e,scope:[e.name]})}getLang(e){return this.langs[e.toLowerCase()]}getVisitorMap(e){let t={};for(let n in this.langs)t[n]=new(this.langs[n].visitors[e]??As.logicalPlan[e])(t,this.db);return t}getOp(e,t,n){return this.getImplementation(`operators`,e,t,n)}getFn(e,t,n){return this.getImplementation(`functions`,e,t,n)}getAggr(e,t,n){return this.getImplementation(`aggregates`,e,t,n)}getCast(e,t,n){return this.getImplementation(`castables`,e,t,n)}getFnOrAggr(e,t,n){let r=this.getImplementation(`functions`,e,t,n,!1)??this.getImplementation(`aggregates`,e,t,n,!1);if(!r)throw Error(`Function or aggregate not found: [${e}] ${n?n.toString():`<default>`}.${t}`);return r}getImplementation(t,n,r,i,a=!0){let o=this[t].get([n,i,r])??this[t].get([n,i,r.toLowerCase()]);if(o??=this[t].get([e.allLangs,i,r])??this[t].get([e.allLangs,i,r.toLowerCase()]),!o&&a)throw Error(`${t.slice(0,-1)} not found: [${n}] ${i?i.toString():`<default>`}.${r}`);return o}},Ms={name:`count`,init:()=>0,step:e=>e+1,stepInverse:e=>e-1,result:e=>e},Ns={name:`sum`,init:()=>null,step:(e,t)=>e===null?t:e+t,stepInverse:(e,t)=>e-t,result:e=>e},Ps={name:`avg`,init:()=>({sum:0,count:0}),step:(e,t)=>(e.sum+=t,e.count++,e),stepInverse:(e,t)=>(e.sum-=t,e.count--,e),result:e=>e.count===0?null:e.sum/e.count},Fs={name:`min`,init:()=>null,step:(e,t)=>e===null||t<e?t:e,result:e=>e},Is={name:`max`,init:()=>null,step:(e,t)=>e===null||t>e?t:e,result:e=>e},Ls={name:`collect`,init:()=>[],step:(e,t)=>(e.push(t),e),stepInverse:(e,t)=>(e.shift(),e),result:e=>e,includeNulls:!0},Rs=t({avg:()=>Ps,collect:()=>Ls,count:()=>Ms,max:()=>Is,min:()=>Fs,sum:()=>Ns}),zs={name:`string`,pure:!0,convert:Q(e=>String(e))},Bs={name:`number`,pure:!0,convert(e){let t=+e;return isNaN(t)?null:t}},Vs={name:`boolean`,pure:!0,convert(e){return!!e}},Hs={name:`date`,pure:!0,convert:Q(e=>{let t=new Date(e);return isNaN(t.getTime())?null:t})},Us={name:`json`,convert:Q(e=>{try{return JSON.parse(e)}catch{return null}})},Ws=t({toBool:()=>Vs,toDate:()=>Hs,toJson:()=>Us,toNumber:()=>Bs,toStr:()=>zs}),Gs={name:`+`,impl:Q((e,t)=>t===void 0?+e:e+t)},Ks={name:`-`,impl:Q((e,t)=>t===void 0?-e:e-t)},qs={name:`*`,impl:Q((e,t)=>e*t)},Js={name:`/`,impl:Q((e,t)=>e/t)},Ys={name:`//`,impl:Q((e,t)=>Math.floor(e/t))},Xs={name:`%`,impl:Q((e,t)=>e%t)},Zs={name:`^`,impl:Q((e,t)=>e**+t)},Qs={name:`=`,impl:Q((e,t)=>e==t)},$s={name:`!=`,impl:Q((e,t)=>e!=t)},ec={name:`<>`,impl:$s.impl},tc={name:`>`,impl:Q((e,t)=>e>t)},nc={name:`<`,impl:Q((e,t)=>e<t)},rc={name:`>=`,impl:Q((e,t)=>e>=t)},ic={name:`<=`,impl:Q((e,t)=>e<=t)},ac={name:`is`,impl:(e,t)=>e===t},oc=t({add:()=>Gs,and:()=>ns,divide:()=>Js,eq:()=>Qs,ge:()=>rc,gt:()=>tc,idivide:()=>Ys,isOp:()=>ac,le:()=>ic,lt:()=>nc,mod:()=>Xs,multiply:()=>qs,neg:()=>is,neq:()=>$s,neq2:()=>ec,not:()=>rs,or:()=>ts,pow:()=>Zs,subtract:()=>Ks}),sc={name:`unwind`,impl:e=>Array.isArray(e)?e:e==null?[]:[e]},cc={name:`substr`,impl:Q((e,t,n)=>n===void 0?e.slice(t):e.slice(t,t+n)),pure:!0},lc={name:`slice`,impl:Q((e,t,n)=>e.slice(t,n)),pure:!0},uc=t({slice:()=>lc,substr:()=>cc,unwind:()=>sc}),dc={operators:Object.values(oc),functions:Object.values(uc),aggregates:Object.values(Rs),castables:Object.values(Ws)},fc=class{db;rules;config;constructor(e,t){this.db=t,this.reconfigure(e)}reconfigure(e){this.config=e,this.rules=e.rules.map(e=>typeof e==`function`?new e(this.db):e)}optimize(e){this.breakReferences(e);let t=new Po(`dummy`,0,1,e);for(let e of this.rules)this.visitOperator(t.source,e);let n=t.source;return n.parent=null,n}visitOperator(e,t){if(t.operator===null||e.constructor===t.operator||Array.isArray(t.operator)&&t.operator.includes(e.constructor)){let n=t.match(e);if(n!==null){let r=e.parent,i=t.transform(e,n.bindings);i!==e&&(r.replaceChild(e,i),e=i)}}for(let n of e.getChildren()){if(n.parent!==e)throw console.log(`Parent mismatch (op, child)`,e,n),Error(`Parent mismatch`);this.visitOperator(n,t)}}breakReferences(e){e instanceof K&&e.parent instanceof K&&e.schema===e.parent.schema&&(e.parent.schema=e.schema.slice(),e.parent.schemaSet=e.schemaSet.clone());for(let t of e.getChildren())this.breakReferences(t)}},pc=Symbol(`fromItemIndexKey`),mc=class{config;langMgr=null;registeredSources=new W;optimizer;indices=new W;friendInterface={langMgr:null,optimizer:null,getSource:e=>this.registeredSources.get(e),indices:this.indices,config:null};constructor(e){this.config=e,this.langMgr=this.friendInterface.langMgr=new js(this.friendInterface),this.friendInterface.langMgr=this.langMgr,this.langMgr.registerExtension(dc),this.langMgr.registerLang(e.mainLang),this.config.additionalLangs?.forEach(e=>this.langMgr.registerLang(e)),this.optimizer=new fc(e.optimizer,this.friendInterface),this.friendInterface.optimizer=this.optimizer,this.config.extensions?.forEach(e=>this.langMgr.registerExtension(e)),this.friendInterface.config=e}parse(e,t){return this.langMgr.getLang(t?.mainLang??this.config.mainLang.name).createParser(this.langMgr).parse(e).value}buildPlan(e,t){let n=this.langMgr.getLang(t?.mainLang??this.config.mainLang.name).visitors.logicalPlanBuilder,r=new n(this.friendInterface).buildPlan(e,new W,{});return this.optimizer.optimize(r.plan)}query(e,t){let n=this.parse(e,t),r=this.buildPlan(n.at(-1),t),i=this.executePlan(r,t?.boundParams);return{data:da(i.data),schema:i.schema}}executePlan(e,t){let n=this.langMgr.getVisitorMap(`variableMapper`),r=this.langMgr.getVisitorMap(`executor`),i=this.langMgr.getVisitorMap(`transitiveDependencies`),a=this.langMgr.getLang(e.lang).serialize;e.accept(i);let o=n[e.lang].mapVariables(e),{result:s,ctx:c}=r[e.lang].execute(e,o,t);return a(s,c,e)}registerSource(e,t){this.registeredSources.set(e,t)}createIndex(e,t,n,r){let i=r?.mainLang??this.config.mainLang.name,a=this.langMgr.getLang(i).createParser(this.langMgr),o=new n(t.map(e=>{let t=a.parseExpr(e),n=this.langMgr.getLang(r?.mainLang??this.config.mainLang.name).visitors.logicalPlanBuilder,o=new n(this.friendInterface).buildPlan(t.value[0],new W(r?.fromItemKey?[r.fromItemKey]:[]),{}),s=this.optimizer.optimize(o.plan),c=s instanceof J?s.attrs[0][0]:s;if(c instanceof _o){if(c.getChildren().length)throw Error(`Expression cannot contain subqueries`);return r?.fromItemKey&&this.renameItemIndexExpr(c,r.fromItemKey),c}return Co(r?.fromItemKey?V.fromParts([pc]):c,i)}),this.friendInterface),s=this.indices.get(e);s?s.push(o):this.indices.set(e,[o]),this.fillIndex(o,e,!!r?.fromItemKey)}renameItemIndexExpr(e,t){if(e.getDependencies().size===0)return;if(e.original){let n=this.langMgr.getVisitorMap(`attributeRenamer`),r=new W;r.set(t,[pc]),n[e.lang].rename(e.original,r)}let n=V.fromParts([pc]);e.args=e.args.map(()=>n)}fillIndex(e,t,n=!1){if(e.expressions.length===0)return;let r=e.expressions[0].lang,i=this.langMgr.getVisitorMap(`variableMapper`),a=this.langMgr.getVisitorMap(`executor`),o=e.expressions.map((e,t)=>[e.clone(),V.fromParts([t])]),s=n?V.fromParts([pc]):V.fromParts([Zi]);o.unshift([s,s]);let c=new J(r,o,n?new Ao(r,s,new vo(r,V.fromParts(t))):new fo(r,V.fromParts(t)));if(!n){for(let t of e.expressions)c.source.addToSchema(t.getDependencies());c.source.addToSchema(s)}let l=i[r].mapVariables(c),{result:u,ctx:d}=a[r].execute(c,l),[f,...p]=d.getKeys(c);e.reindex(Iterator.from(u).map(e=>({value:e[f],keys:p.map(t=>e[t])})))}},hc=class extends Error{constructor(e){super(e),this.name=`UnsupportedError`}};function gc(e){let t=e.filter(e=>e.containingFn.impl!==ts.impl),n=new Set(e.filter(e=>e.containingFn.impl===ts.impl).map(e=>e.containingFn));if(!n.size)return{nonOr:e,alternatives:new Map};let r=Array.from(n).map(e=>[e,Qo(e,ts)]).filter(([,e])=>e.every(e=>e instanceof q)).map(([e,t])=>[e,t.map(e=>e.args.map(t=>({expr:`op`in t?t.op:t,containingFn:e})))]);return{nonOr:t,alternatives:new Map(r)}}var _c=class{db;calcBuilders;eqCheckers;constructor(e){this.db=e,this.calcBuilders=e.langMgr.getVisitorMap(`calculationBuilder`),this.eqCheckers=e.langMgr.getVisitorMap(`equalityChecker`)}match(e){if(e.parent.constructor===Y)return null;let t={selections:e.condition.original instanceof q?[e]:[],source:null,index:null,accessor:null};for(;e.source.constructor===Y;)e.source.condition.original instanceof q&&t.selections.push(e.source),e=e.source;if(e.source.constructor!==fo&&(e.source.constructor!==Ao||e.source.source.constructor!==vo))return null;t.source=e.source.constructor===fo?e.source:e.source.source;let n=this.db.indices.get((Array.isArray(t.source.name)?t.source.name[0]:t.source.name).parts)??[],r=this.getExprCandidates(t.selections),i;e.source instanceof Ao&&(i=new W,i.set(e.source.key.parts,[pc]));for(let e of n){let n=this.matchIndex(e,r,i);if(n)return r=n.candidates,t.selections=t.selections.filter((e,t)=>r.some(e=>e.sIndex===t)),t.index=e,t.accessor=n.accessor,{bindings:t}}return null}matchIndex(e,t,n){let r=e.match(t,n);if(r)return t=t.filter((e,t)=>r.includes(t)),{candidates:t,accessor:e.createAccessor(t)};let{alternatives:i}=gc(t);for(let[r,a]of i){let i=a.map(t=>e.match(t,n));if(!i.every(ea))continue;let o=i.map((t,n)=>e.createAccessor(t.map(e=>a[n][e])));return{accessor:To(new q(o[0].lang,o.map(e=>({op:e.original??e})),function*(...e){let t=new W;for(let n of e)for(let e of n)t.has([e])||(t.add([e]),yield e)}),this.calcBuilders,this.eqCheckers),candidates:t.filter(e=>e.containingFn===r)}}return null}getExprCandidates(e){return e.flatMap((e,t)=>e.condition.original.args.map(n=>({sIndex:t,containingFn:e.condition.original,expr:n instanceof V?n:n.op})))}transform(e,t){let{selections:n,source:r,index:i,accessor:a}=t,o=n[0]===e;for(let e=+!!o;e<n.length;e++){let t=n[e];t.parent.replaceChild(t,t.source)}if(r instanceof fo){let t=new mo(r.lang,r.name,i,a);return t.schemaSet=r.schemaSet,t.schema=r.schema,r.parent.replaceChild(r,t),o?e.source:e}let s=new mo(r.lang,r.name,i,a,r.parent.key);return s.addToSchema(r.parent.key),r.parent.parent.replaceChild(r.parent,s),o?e.source:e}operator=Y},vc=class{db;operator=Oo;tdepsVmap;renamerVmap;renameCheckerVmap;constructor(e){this.db=e,this.tdepsVmap=this.db.langMgr.getVisitorMap(`transitiveDependencies`),this.renamerVmap=this.db.langMgr.getVisitorMap(`attributeRenamer`),this.renameCheckerVmap=this.db.langMgr.getVisitorMap(`attributeRenameChecker`)}match(e){for(let t of[`right`,`left`]){if(t===`left`&&e.leftOuter||t===`right`&&e.rightOuter)continue;let n=this.traverseSide(e[t]);if(!n)continue;let r=n.projections.length?this.findValidAttrs(n.projections):e[t].schemaSet,i=this.getExprCandidates(e.conditions,r);if(!i.length)continue;let a=this.db.indices.get((Array.isArray(n.source.name)?n.source.name[0]:n.source.name).parts)??[],o=this.prepareRenameMap(n.projections),s;n.source instanceof vo?(s=o?o.clone():new W,s.set(n.source.parent.key.parts,[pc])):s=o;for(let r of a){let a=this.matchIndex(r,i,e.conditions,s);if(a)return{bindings:{side:t,renameMap:o,indexMatch:a.map(e=>i[e][0]),source:n.source}}}}return null}prepareRenameMap(e){if(!e.length)return null;let t=e[0].renamesInv.clone();for(let n=1;n<e.length;n++)for(let[r,i]of t.entries())t.set(r,e[n].renamesInv.get(i)??i);return t}matchIndex(e,t,n,r){let i=t.map(([e,t])=>{let r=n[e].original;return{containingFn:r,expr:r.args[t]instanceof V?r.args[t]:r.args[t].op}}),a=e.match(i,r);if(a)return a;let{alternatives:o}=gc(i);for(let[t,n]of o)if(n.every(t=>e.match(t,r))){let e=i.findIndex(e=>e.containingFn===t);return[e,e+1]}return a}findValidAttrs(e){let t=e.at(-1).source.schemaSet.clone();for(let n=e.length-1;n>=0;n--)t=new W([...e[n].renames.entries()].filter(([e,n])=>t.has(e)).map(([e,t])=>t));return t}getExprCandidates(e,t){let n=[];for(let r=0;r<e.length;r++){let i=e[r];if(i.original instanceof q){let e=i.original.args;for(let i=0;i<e.length;i++)e[i]instanceof V?t.has(e[i].parts)&&n.push([r,i]):n.push([r,i])}}return n}traverseSide(e){let t=[];for(;[J,Y,Mo,Uo,X].includes(e.constructor);)e.constructor===J&&t.push(e),e=e.source;if(e.constructor===Ao){if(e.source.constructor===vo)return{projections:t,source:e.source}}else if(e.constructor===fo)return{projections:t,source:e};return null}transform(e,t){let n=t.side===`left`?`right`:`left`,r=Symbol(`external`),i=new J(e.lang,e[n].schema.map(e=>[e,V.fromParts([r,...e.parts])]),e[n]);for(let t of e.conditions)this.renamerVmap[t.lang].rename(t,i.renames);let a=t.source instanceof fo?t.source:t.source.parent;for(let n of new Set(t.indexMatch)){let r=e.conditions[n];t.renameMap&&this.renamerVmap[r.lang].rename(r,t.renameMap),a.parent.replaceChild(a,new Y(r.lang,r,a))}for(let n=0;n<e.conditions.length;n++){let r=e.conditions[n];t.indexMatch.includes(n)||e.replaceChild(e[t.side],new Y(r.lang,r,e[t.side]))}let o=new xo(e.lang,e[t.side],e[`${t.side===`left`?`right`:`left`}Outer`],i);return new J(e.lang,o.schema.map(e=>e.parts[0]===r?[e,V.fromParts(e.parts.slice(1))]:[e,e]),o)}},yc=class{db;operator=J;tdepsVmap;calcBuilderVmap;eqCheckersVmap;constructor(e){this.db=e,this.tdepsVmap=this.db.langMgr.getVisitorMap(`transitiveDependencies`),this.calcBuilderVmap=this.db.langMgr.getVisitorMap(`calculationBuilder`),this.eqCheckersVmap=this.db.langMgr.getVisitorMap(`equalityChecker`)}match(e){if(e.parent.constructor===J)return null;let t=[e];for(;e.source.constructor===J;)t.push(e.source),e=e.source;return t.length>1?{bindings:t}:null}transform(e,t){let n=e;for(let e=1;e<t.length;e++)n=this.mergeProjections(n,t[e]);return this.tdepsVmap[e.lang].clearCache(),e}mergeProjections(e,t){let n=new W,r=new Map(e.attrs.filter(e=>e[0]instanceof _o).map(e=>[e[0],this.getCalcInputDeps(e[0])])),[i,a]=this.canMergeIntoOne(e,t,n,r);if(!i)return t=new J(t.lang,a,t.source),t.parent=e,e.source=t,t;e.source=t.source,t.source.parent=e;for(let t of e.attrs)t[0]=t[0]instanceof _o?this.getNewCalc(t[0],n):n.get(t[0].parts)??t[0],t[0]instanceof _o&&(t[0].parent=e);return e}calcToFnCall(e,t){return new q(e.lang,t.map((t,n)=>{let r=e.argMeta[n];return r?.aggregate?{op:r.aggregate,acceptSequence:r.acceptSequence}:t instanceof V?t:{op:t,acceptSequence:r.acceptSequence}}),e.impl,e.literal)}getNewCalc(e,t){for(let n=0;n<e.args.length;n++){let r=e.args[n];if(r instanceof V){let i=t.get(r.parts);if(i)for(let t of e.argMeta[n].originalLocations){let{obj:e,key:n,idAsFnArg:r,op:a}=t;i instanceof _o?(e[n]=r?{op:i.original}:i.original,i.original.parent=a):e[n]=i}}}return To(e.original,this.calcBuilderVmap,this.eqCheckersVmap)}canMergeIntoOne(e,t,n,r){let i=!0,a=t.attrs.filter(([t,a])=>{let o=0;for(let[s,c]of e.attrs)if(s instanceof _o){if(s.original||(i=!1),r.get(s).has(a.parts))return i=!1,!0;if(s.getDependencies().has(a.parts)){let e=s.args.findIndex(e=>e instanceof V&&e.equals(a));if(o+=s.argMeta[e]?.usedMultipleTimes?2:1,t instanceof _o&&(t.original||(i=!1),o>1))return i=!1,!0;n.set(a.parts,t)}}else if(s.equals(a)){if(o++,t instanceof _o&&(t.original||(i=!1),o>1))return i=!1,!0;n.set(a.parts,t)}return o>0});return[i,a]}getCalcInputDeps(e){return G(...e.args.filter(e=>!oa(e)).map(e=>e.accept(this.tdepsVmap)))}},bc={operator:Y,match:function(e){let t={selections:[e],product:null};for(;e.source.constructor===Y;)t.selections.push(e.source),e=e.source;if(e.source.constructor===Do)t.product=e.source;else return null;return{bindings:t}},transform:function(e,t){return new Oo(t.product.lang,t.product.left,t.product.right,t.selections.map(e=>e.condition))}},xc=class{db;operator=xo;tdepsVmap;constructor(e){this.db=e,this.tdepsVmap=this.db.langMgr.getVisitorMap(`transitiveDependencies`)}match(e){return co(e.mapping.accept(this.tdepsVmap),e.source.schema)?null:{bindings:{}}}transform(e,t){let n;return e.outer?(n=new Oo(e.lang,e.source,e.mapping,[]),n.leftOuter=!0):n=new Do(e.lang,e.source,e.mapping),n.validateSingleValue=e.validateSingleValue,n}},Sc=class{db;operator=Y;alwaysSwap=[Mo,zo];setOps=[Io,Lo,Ro];tdepsVmap;renamerVmap;renameCheckerVmap;constructor(e){this.db=e,this.tdepsVmap=this.db.langMgr.getVisitorMap(`transitiveDependencies`),this.renamerVmap=this.db.langMgr.getVisitorMap(`attributeRenamer`),this.renameCheckerVmap=this.db.langMgr.getVisitorMap(`attributeRenameChecker`),this.cloneSelection=this.cloneSelection.bind(this)}match(e){if(e.parent.constructor===Y)return null;let t={selections:[e],source:null};for(;e.source.constructor===Y;)t.selections.push(e.source),e=e.source;return t.source=e.source,this.alwaysSwap.includes(t.source.constructor)?{bindings:t}:this.setOps.includes(t.source.constructor)&&t.source.schema?this.matchSetOp(t):t.source.constructor===J?this.matchProjection(t):t.source.constructor===Oo||t.source.constructor===Do?this.matchJoins(t):t.source.constructor===xo?this.matchProjectionConcat(t):t.source.constructor===No?this.matchGroupBy(t):null}matchGroupBy(e){let t=e.source,n=io(t.keys.map(ra));for(let r of e.selections)if(so(n,oo(this.getSelectionDeps(r),t.schemaSet)))return{bindings:e};return null}matchJoins(e){let t=e.source;for(let n of e.selections){let r=oo(this.getSelectionDeps(n),t.schemaSet);if(!t.rightOuter&&so(t.left.schemaSet,r)||!t.leftOuter&&so(t.right.schemaSet,r))return{bindings:e}}return null}matchProjectionConcat(e){let t=e.source;for(let n of e.selections){let r=oo(this.getSelectionDeps(n),t.schemaSet);if(so(t.source.schemaSet,r)||!t.outer&&so(t.mapping.schemaSet,r))return{bindings:e}}return null}matchProjection(e){for(let t of e.selections)if(this.checkProjection(t,e.source))return{bindings:e};return null}matchSetOp(e){let t=e.source;if(t.right.schema.every((e,n)=>e.equals(t.left.schema[n])))return{bindings:e};let n=new W;for(let e=0;e<t.right.schema.length;e++)n.set(t.right.schema[e].parts,t.left.schema[e].parts);for(let t of e.selections)if(this.renameCheckerVmap[t.lang].canRename(t.condition,n))return{bindings:e};return null}getSelectionDeps(e){return this.tdepsVmap[e.lang].visitCalculation(e.condition)}transform(e,t){let{selections:n,source:r}=t,i=n.at(-1),a;a=this.alwaysSwap.includes(r.constructor)?this.transformBasic(r,e,i):this.setOps.includes(r.constructor)?this.tranformSetOp(r,n):r.constructor===J?this.transformProjection(r,n):r.constructor===Do||r.constructor===Oo?this.transformJoin(r,n):r.constructor===xo?this.transformProjectionConcat(r,n):r.constructor===No?this.transformGroupBy(r,n):e;for(let e of n)this.tdepsVmap[e.lang].invalidateCacheElement(e);return this.tdepsVmap[e.lang].invalidateCacheElement(r),a}transformBasic(e,t,n){return n.source=e.source,e.source.parent=n,e.source=t,t.parent=e,e}transformGroupBy(e,t){let n=[],r=[],i=new Set,a=io(e.keys.map(ra)),o=new W;for(let[t,n]of e.keys)t instanceof V&&!t.equals(n)&&o.set(n.parts,t.parts);for(let s of t){let t=oo(this.getSelectionDeps(s),e.schemaSet);so(a,t)?(n.push(s),o.size&&co(o,t)&&i.add(s)):r.push(s)}for(let e=0;e<r.length-1;e++)r[e].source=r[e+1],r[e+1].parent=r[e];for(let e=0;e<n.length-1;e++){let t=n[e];t.source=n[e+1],n[e+1].parent=t,i.has(t)&&this.renamerVmap[t.lang].rename(t.condition,o)}for(let t of n)t.schema=e.source.schema.slice(),t.schemaSet=e.source.schemaSet.clone();let s=n.at(-1);return s.source=e.source,e.source.parent=s,e.source=n[0],n[0].parent=e,i.has(s)&&this.renamerVmap[s.lang].rename(s.condition,o),r.length?(r.at(-1).source=e,e.parent=r.at(-1),r[0]):e}tranformSetOp(e,t){let n=[],r=[],i=new Set,a=new W;if(e.left.schema.every((t,n)=>t.equals(e.right.schema[n])))n=t;else{for(let t=0;t<e.right.schema.length;t++)a.set(e.right.schema[t].parts,e.left.schema[t].parts);for(let e of t)this.renameCheckerVmap[e.lang].canRename(e.condition,a)?(n.push(e),i.add(e)):r.push(e)}let o=lo(a),s=n.map(this.cloneSelection);for(let e=0;e<r.length-1;e++)r[e].source=r[e+1],r[e+1].parent=r[e];for(let e=0;e<n.length-1;e++){let t=n[e];t.source=n[e+1],n[e+1].parent=t,i.has(t)&&this.renamerVmap[t.lang].rename(t.condition,o),s[e].source=s[e+1],s[e+1].parent=s[e]}for(let t of n)t.schema=e.right.schema.slice(),t.schemaSet=e.right.schemaSet.clone();for(let t of s)t.schema=e.left.schema.slice(),t.schemaSet=e.left.schemaSet.clone();let c=n.at(-1);c.source=e.right,e.right.parent=c,e.right=n[0],n[0].parent=e,i.has(c)&&this.renamerVmap[c.lang].rename(c.condition,o);let l=s.at(-1);return l.source=e.left,e.left.parent=l,e.left=s[0],s[0].parent=e,r.length?(r.at(-1).source=e,e.parent=r.at(-1),r[0]):e}transformProjection(e,t){let n=[],r=[],i=new Set;for(let a of t)this.checkProjection(a,e,i)?n.push(a):r.push(a);for(let e=0;e<r.length-1;e++)r[e].source=r[e+1],r[e+1].parent=r[e];for(let t=0;t<n.length-1;t++){let r=n[t];r.source=n[t+1],n[t+1].parent=r,i.has(r)&&this.renamerVmap[r.lang].rename(r.condition,e.renamesInv)}for(let t of n)t.schema=e.source.schema.slice(),t.schemaSet=e.source.schemaSet.clone();let a=n.at(-1);return a.source=e.source,e.source.parent=a,e.source=n[0],n[0].parent=e,i.has(a)&&this.renamerVmap[a.lang].rename(a.condition,e.renamesInv),r.length?(r.at(-1).source=e,e.parent=r.at(-1),r[0]):e}transformJoin(e,t){let n=[],r=[],i=[];for(let a of t){let t=oo(this.getSelectionDeps(a),e.schemaSet),o=!1;!e.rightOuter&&so(e.left.schemaSet,t)&&(n.push(a),o=!0),!e.leftOuter&&so(e.right.schemaSet,t)?o?r.push(this.cloneSelection(a)):r.push(a):o||i.push(a)}for(let e of[n,r,i])for(let t=0;t<e.length-1;t++)e[t].source=e[t+1],e[t+1].parent=e[t];return this.pushSelectionsUnder(n,`left`,e),this.pushSelectionsUnder(r,`right`,e),i.length?(i.at(-1).source=e,e.parent=i.at(-1),i[0]):e}transformProjectionConcat(e,t){let n=[],r=[],i=[];for(let a of t){let t=!1,o=oo(this.getSelectionDeps(a),e.schemaSet);!e.outer&&so(e.mapping.schemaSet,o)&&(n.push(a),t=!0),so(e.source.schemaSet,o)?t?r.push(this.cloneSelection(a)):r.push(a):t||i.push(a)}for(let e of[n,r,i])for(let t=0;t<e.length-1;t++)e[t].source=e[t+1],e[t+1].parent=e[t];return this.pushSelectionsUnder(n,`mapping`,e),this.pushSelectionsUnder(r,`source`,e),i.length?(i.at(-1).source=e,e.parent=i.at(-1),i[0]):e}cloneSelection(e){let t=new Y(e.lang,e.condition.clone(),e.source);return t.schema=t.schema.slice(),t.schemaSet=t.schemaSet.clone(),t}checkProjection(e,t,n){let r=this.getSelectionDeps(e),i=Yo(r,t);return i===Z.modified?!1:i===Z.unchanged?!0:this.renameCheckerVmap[e.condition.lang].canRename(e.condition,t.renames)?!co(ao(r,t.schemaSet),t.renames)&&(n&&n.add(e),!0):!1}pushSelectionsUnder(e,t,n){if(e.length){for(let r of e)r.schema=n[t].schema.slice(),r.schemaSet=n[t].schemaSet.clone();e.at(-1).source=n[t],n[t].parent=e.at(-1),n[t]=e[0],e[0].parent=n}}},Cc={operator:ko,match:e=>e.source.constructor===Ao&&e.key.equals(e.source.key)?{bindings:{}}:null,transform:e=>e.source.source},wc={operator:Ao,match:e=>e.source.constructor===ko&&e.source.key.parts.at(-1)!==Zi?{bindings:{}}:null,transform:e=>{let t=e.source;return new J(e.lang,[[t.key,e.key]],t.source)}},Tc=Symbol(`unnested`),Ec=[class{db;operator=[J,Y,No,zo,Mo];tdepsVmap;calcBuilders;eqCheckers;constructor(e){this.db=e,this.tdepsVmap=this.db.langMgr.getVisitorMap(`transitiveDependencies`),this.calcBuilders=this.db.langMgr.getVisitorMap(`calculationBuilder`),this.eqCheckers=this.db.langMgr.getVisitorMap(`equalityChecker`)}match(e){let t=e.getChildren().map(e=>{if(!(e instanceof _o&&e.original))return null;let t=e.args.map((t,n)=>{if(t instanceof V)return null;let r=e.argMeta[n];return!r.acceptSequence&&!r.maybeSkipped?n:null}).filter(sa);return t.length?[e,t]:null}).filter(sa);return t.length?{bindings:{subqueries:t}}:null}transform(e,t){let n=0,r=this.tdepsVmap[e.lang];r.invalidateCacheElement(e);let i=e.schema.map(ia);for(let[i,a]of t.subqueries){r.invalidateCacheElement(i);for(let t of a){let r=V.fromParts([Tc,n+++``]),a=i.args[t];this.removeSubq(i,t,r);let o=new xo(e.lang,new Ao(e.lang,r,a),!this.isGuaranteedValue(a),e.source);o.parent=e,e.source=o,o.validateSingleValue=!0,e instanceof J||e.addToSchema(r)}}return r.clearCache(),new J(e.lang,i,e)}removeSubq(e,t,n){if(this.tdepsVmap[e.lang].invalidateCacheUpstream(e.args[t]),e.impl===H)e.parent.replaceChild(e,n);else{e.replaceChild(e.args[t],new q(e.lang,[n],ea));let r=e.original.accept(this.calcBuilders);r=wo(r,this.eqCheckers,e.lang),e.impl=r.impl,e.aggregates=r.aggregates,e.argMeta=r.argMeta,e.literal=r.literal,e.args=r.args}}isGuaranteedValue(e){switch(e.constructor){case ko:case Ao:case J:case So:case Mo:return this.isGuaranteedValue(e.source);case Io:return this.isGuaranteedValue(e.left)||this.isGuaranteedValue(e.right);case Do:return this.isGuaranteedValue(e.left)&&this.isGuaranteedValue(e.right);case xo:return e.outer?this.isGuaranteedValue(e.source):!1;case Oo:{let t=e;if(!t.leftOuter&&!t.rightOuter)return!1;if(t.leftOuter&&t.rightOuter)return!0;let n=t.leftOuter?t.left:t.right;return this.isGuaranteedValue(n)}case Po:return!e.skip&&(e.limit??1/0)>0&&this.isGuaranteedValue(e.source);case Bo:return!0;case No:return!e.keys.length||this.isGuaranteedValue(e.source);default:return!1}}},Cc,wc,Sc,xc,bc,vc,_c,yc],Dc=class{fn;distinct;yieldItems;where;procedure=!1;constructor(e,t){this.fn=e,this.distinct=t}accept(e,t){return e.visitFnCallWrapper(this,t)}},Oc=class{query;pattern;where;constructor(e,t,n){this.query=e,this.pattern=t,this.where=n}accept(e,t){return e.visitExistsSubquery(this,t)}},kc=function(e){return e.ANY=`any`,e.ALL=`all`,e.SINGLE=`single`,e.NONE=`none`,e}({}),Ac=class{variable;expr;where;quantifier;constructor(e,t,n,r=null){this.variable=t,this.expr=n,this.where=r,this.quantifier=e.toLowerCase()}accept(e,t){return e.visitQuantifiedExpr(this,t)}},jc=class{pattern;where;expr;constructor(e,t,n){this.pattern=e,this.where=t,this.expr=n}accept(e,t){return e.visitPatternComprehension(this,t)}},Mc=class{variable;source;where;expr;constructor(e,t,n=null,r=null){this.variable=e,this.source=t,this.where=n,this.expr=r}accept(e,t){return e.visitListComprehension(this,t)}},Nc=class{expr;whenThens;elseExpr;constructor(e,t,n){this.expr=e,this.whenThens=t,this.elseExpr=n}accept(e,t){return e.visitCaseExpr(this,t)}},Pc=class{constructor(){}accept(e,t){return e.visitCountAll(this,t)}},Fc=class{expr;labels;constructor(e,t){this.expr=e,this.labels=t}accept(e,t){return e.visitLabelFilterExpr(this,t)}},Ic=class{expr;subscript;constructor(e,t){this.expr=e,this.subscript=t}accept(e,t){return e.visitSubscriptExpr(this,t)}},Lc=class{expr;prop;constructor(e,t){this.expr=e,this.prop=t}accept(e,t){return e.visitPropLookup(this,t)}};function Rc(e){let t=``,n=/^([bfnrt\\'"]|x[0-9a-f]{2}|u[0-9a-f]{4}|u[0-9a-f]{8}|[0-7]{1,3})/i;for(let r=1;r<e.length-1;r++){let i=e[r],a;i===`\\`&&(a=e.slice(r+1).match(n))?(r+=a[0].length,t+=zc(a[0])):t+=i}return t}function zc(e){let t;switch(e=e.toLowerCase(),e[0]){case`b`:return`\b`;case`f`:return`\f`;case`n`:return`
|
|
314
|
-
`;case`r`:return`\r`;case`t`:return` `;case`\\`:return`\\`;case`x`:return t=parseInt(e.slice(1),16),String.fromCharCode(t);case`u`:return t=parseInt(e.slice(1),16),String.fromCodePoint(t);default:return t=parseInt(e,8),isNaN(t)?e:String.fromCharCode(t)}}var Bc=class extends V{idOriginal;constructor(e){super(),this.idOriginal=e;let t=this.splitId(e);this.parts=t.map(e=>this.parseId(e))}accept(e,t){return e.visitCypherIdentifier(this,t)}parseId(e){return e.startsWith("`")&&e.endsWith("`")?e.replaceAll("`",``):e}splitId(e){if(e[0]!=="`"){let t=e.indexOf(`.`);return t===-1?[e]:[e.slice(0,t),...this.splitId(e.slice(t+1))]}for(let t=1;t<e.length-1;t++)if(e[t]==="`"){if(e[t+1]==="`")t++;else return[e.slice(0,t),...this.splitId(e.slice(t+2))]}return[e]}},Vc=class extends Ji{constructor(e){super(e,null),this.value=Rc(e)}accept(e,t){return e.visitStringLiteral(this,t)}},Hc=class extends Ji{constructor(e){super(e,+e)}accept(e,t){return e.visitNumberLiteral(this,t)}},Uc=class{items;constructor(e){this.items=e}accept(e,t){return e.visitListLiteral(this,t)}},Wc=class{items;constructor(e){this.items=e}accept(e,t){return e.visitMapLiteral(this,t)}},Gc=class extends Ji{constructor(e){super(e,null),this.value=this.parse(e)}accept(e,t){return e.visitBooleanLiteral(this,t)}parse(e){let t=e.toLowerCase();return t===`true`||t!==`false`&&null}},Kc=class{chain;variable=null;constructor(e){this.chain=Array.isArray(e)?e:[e]}accept(e,t){return e.visitPatternElChain(this,t)}},qc=class{variable;labels;props;constructor(e,t=[],n=null){this.variable=e,this.labels=t,this.props=n}accept(e,t){return e.visitNodePattern(this,t)}},Jc=class{pointsLeft;pointsRight;variable;types;range;props;constructor(e=!1,t=!1,n=null,r=[],i=null,a=null){this.pointsLeft=e,this.pointsRight=t,this.variable=n,this.types=r,this.range=i,this.props=a}accept(e,t){return e.visitRelPattern(this,t)}},Yc=function(e){return e.UNION=`union`,e.UNIONALL=`unionall`,e}({}),Xc=class{type;next;constructor(e,t){this.type=e,this.next=t}accept(e,t){return e.visitSetOp(this,t)}},Zc=class{statements;setOp;from;constructor(e){this.statements=e}accept(e,t){return e.visitQuery(this,t)}},Qc=class{pattern;where;optional=!1;constructor(e,t){this.pattern=e,this.where=t}accept(e,t){return e.visitMatchClause(this,t)}},$c=class{expr;variable;constructor(e,t){this.expr=e,this.variable=t}accept(e,t){return e.visitUnwindClause(this,t)}},el=class{pattern;constructor(e){this.pattern=e}accept(e,t){return e.visitCreateClause(this,t)}},tl=class{pattern;onCreate=[];onMatch=[];constructor(e,t){this.pattern=e;for(let e of t)e.trigger===`create`?this.onCreate.push(...e.set.items):this.onMatch.push(...e.set.items)}accept(e,t){return e.visitMergeClause(this,t)}},nl=class{trigger;set;constructor(e,t){this.trigger=e,this.set=t}},rl=class{items;constructor(e){this.items=e}accept(e,t){return e.visitSetClause(this,t)}},il=class{key;value;add=!1;constructor(e,t){this.key=e,this.value=t}accept(e,t){return e.visitSetItem(this,t)}},al=class{items;constructor(e){this.items=e}accept(e,t){return e.visitRemoveClause(this,t)}},ol=class{key;labels;constructor(e,t){this.key=e,this.labels=t}accept(e,t){return e.visitRemoveItem(this,t)}},sl=class{exprs;detach;constructor(e,t=!1){this.exprs=e,this.detach=t}accept(e,t){return e.visitDeleteClause(this,t)}},cl=class{items;order;skip;limit;distinct;constructor(e,t=null,n=null,r=null,i=!1){this.items=e,this.order=t,this.skip=n,this.limit=r,this.distinct=i}accept(e,t){return e.visitProjectionBody(this,t)}},ll=class{expr;ascending;constructor(e,t=!0){this.expr=e,this.ascending=t}accept(e,t){return e.visitOrderItem(this,t)}},ul=class{body;constructor(e){this.body=e}accept(e,t){return e.visitReturnClause(this,t)}},dl=class{body;where;constructor(e,t){this.body=e,this.where=t}accept(e,t){return e.visitWithClause(this,t)}},fl=t({ASTBooleanLiteral:()=>Gc,ASTListLiteral:()=>Uc,ASTMapLiteral:()=>Wc,ASTNumberLiteral:()=>Hc,ASTStringLiteral:()=>Vc,CaseExpr:()=>Nc,CountAll:()=>Pc,CreateClause:()=>el,CypherIdentifier:()=>Bc,DeleteClause:()=>sl,ExistsSubquery:()=>Oc,FnCallWrapper:()=>Dc,LabelFilterExpr:()=>Fc,ListComprehension:()=>Mc,MatchClause:()=>Qc,MergeAction:()=>nl,MergeClause:()=>tl,NodePattern:()=>qc,OrderItem:()=>ll,PatternComprehension:()=>jc,PatternElChain:()=>Kc,ProjectionBody:()=>cl,PropLookup:()=>Lc,QuantifiedExpr:()=>Ac,Quantifier:()=>kc,Query:()=>Zc,RelPattern:()=>Jc,RemoveClause:()=>al,RemoveItem:()=>ol,ReturnClause:()=>ul,SetClause:()=>rl,SetItem:()=>il,SetOp:()=>Xc,SetOpType:()=>Yc,SubscriptExpr:()=>Ic,UnwindClause:()=>$c,WithClause:()=>dl}),pl=class{uniqueId=0;constructor(){this.processNode=this.processNode.bind(this),this.visitSchemaPart=this.visitSchemaPart.bind(this),this.processAttr=this.processAttr.bind(this),this.processNodeOrAttr=this.processNodeOrAttr.bind(this)}processNode(e){return e.accept(this)}processNodeOrAttr(e){return e===`*`?e:e instanceof Array?this.processAttr(e):this.processNode(e)}processAttr(e){return`${e[0].accept(this)} AS ${e[1].accept(this)}`}visitSchemaPart(e){return typeof e==`symbol`||typeof e==`number`?e===Zi?`*`:e.toString():this.addQuotes(e,"`")}visitIdentifier(e){return e.parts.map(this.visitSchemaPart).join(`.`)}visitCypherIdentifier(e){return this.visitIdentifier(e)}addQuotes(e,t){return t+e.replaceAll(t,t+t)+t}visitStringLiteral(e){return this.addQuotes(e.value,`'`)}visitNumberLiteral(e){return e.value.toString()}visitListLiteral(e){return`[${e.items.map(this.processNode)}]`}visitMapLiteral(e){return`{${e.items.map(([e,t])=>`${t.accept(this)}: ${e.accept(this)}`)}}`}visitBooleanLiteral(e){return e?.toString()??`null`}visitFnCallWrapper(e){let t=e.fn.id.accept(this)+`(`;return e.distinct&&(t+=`DISTINCT `),t+=e.fn.args.map(this.processNode),t+=`)`,e.yieldItems&&(t+=`YIELD `,e.yieldItems===`*`?t+=`*`:t+=e.yieldItems.map(this.processNodeOrAttr)),e.where&&(t+=` WHERE `+e.where.accept(this)),t}visitExistsSubquery(e){return`EXISTS {${e.query.accept(this)}}`}visitQuantifiedExpr(e){let t=`${e.quantifier} (${e.variable.accept(this)} IN ${e.expr.accept(this)}`;return e.where&&(t+=` WHERE `+e.where.accept(this)),t+`)`}visitPatternElChain(e){let t=e.chain.map(this.processNode).join(``);return e.variable&&(t=e.variable.accept(this)+`=`+t),t}visitNodePattern(e){let t=`(`;return e.variable&&(t+=e.variable.accept(this)),e.labels.length&&(t+=`:`+e.labels.map(this.processNode).join(`:`)),e.props&&(t+=` `+e.props.accept(this)),t+`)`}visitRange(e){let[t,n]=e,r=t?t.accept(this):``;return e.length===2?r+`..`+(n?n.accept(this):``):r}visitRelPattern(e){let t=`-[`;return e.pointsLeft&&(t=`<`+t),e.variable&&(t+=e.variable.accept(this)),e.types.length&&(t+=`:`+e.types.map(this.processNode).join(`:`)),e.range&&(t+=`*`+this.visitRange(e.range)),t+=e.range.map(e=>e?this.processNode(e):``).join(`..`),e.props&&(t+=` `+e.props.accept(this)),t+(e.pointsRight?`]->`:`]-`)}visitPatternComprehension(e){let t=`[`+e.pattern.accept(this);return e.where&&(t+=` WHERE `+e.where.accept(this)),t+=` | `+e.expr.accept(this)+`]`,t}visitListComprehension(e){let t=`[`+e.expr.accept(this)+` IN `+e.source.accept(this);return e.where&&(t+=` WHERE `+e.where.accept(this)),e.expr&&(t+=` | `+e.expr.accept(this)),t+`]`}visitCaseExpr(e){return`CASE ${e.expr?.accept(this)??``} ${e.whenThens.map(([e,t])=>`WHEN ${e.accept(this)} THEN ${t.accept(this)}`).join(` `)} ${e.elseExpr?` ELSE `+e.elseExpr.accept(this):``} END`}visitCountAll(e){return`COUNT(*)`}visitLabelFilterExpr(e){return`${e.expr.accept(this)}:${e.labels.map(this.processNode).join(`:`)}`}visitSubscriptExpr(e){return e.expr.accept(this)+`[`+this.visitRange(e.subscript)+`]`}visitPropLookup(e){return e.expr.accept(this)+`.`+e.prop.accept(this)}visitSetOp(e){return e.type+` `+e.next.accept(this)}visitQuery(e){let t=e.from?`FROM `+e.from.accept(this):``;for(let n of e.statements)t+=` `+n.accept(this);return e.setOp&&(t+=` `+e.setOp.accept(this)),t}visitMatchClause(e){let t=`MATCH `+e.pattern.map(this.processNode);return e.where&&(t+=` WHERE `+e.where.accept(this)),e.optional&&(t=`OPTIONAL `+t),t}visitUnwindClause(e){return`UNWIND ${e.expr.accept(this)} AS ${e.variable.accept(this)}`}visitCreateClause(e){return`CREATE ${e.pattern.map(this.processNode)}`}visitMergeClause(e){let t=`MERGE `+this.visitPatternElChain(e.pattern);return e.onMatch&&(t+=` ON MATCH SET `+e.onMatch.map(this.processNode)),e.onCreate&&(t+=` ON CREATE SET `+e.onCreate.map(this.processNode)),t}visitSetClause(e){return`SET `+e.items.map(this.processNode)}visitSetItem(e){let t=e.key.accept(this);return Array.isArray(e.value)?t+`:`+e.value.map(this.processNode).join(`:`):(t+=e.add?`+=`:`=`,t+e.value.accept(this))}visitRemoveClause(e){return`REMOVE `+e.items.map(this.processNode)}visitRemoveItem(e){let t=e.key.accept(this);return e.labels?.length&&(t+=`:`+e.labels.map(this.processNode).join(`:`)),t}visitDeleteClause(e){let t=`DELETE `+e.exprs.map(this.processNode);return e.detach?` DETACH `+t:t}visitProjectionBody(e){let t=e.items.map(e=>e===`*`?`*`:this.processNodeOrAttr(e)).join(`,`);return e.distinct&&(t=`DISTINCT `+t),e.order&&(t+=` ORDER BY `+e.order.map(this.processNode)),e.skip&&(t+=` SKIP `+e.skip.accept(this)),e.limit&&(t+=` LIMIT `+e.limit.accept(this)),t}visitOrderItem(e){return e.expr.accept(this)+(e.ascending?``:` DESC`)}visitWithClause(e){let t=`WITH ${this.visitProjectionBody(e.body)}`;return e.where?t+` WHERE `+e.where.accept(this):t}visitReturnClause(e){return`RETURN `+this.visitProjectionBody(e.body)}visitLiteral(e){throw Error(`Method not implemented.`)}visitOperator(e){return`${e.id.accept(this)}(${e.operands.map(this.processNode)})`}visitFunction(e){throw Error(`Method not implemented.`)}visitLangSwitch(e){return`lang_${e.lang}_${this.uniqueId++}`}};function ml(e){return e!==null&&(typeof e==`object`||typeof e==`function`)}function hl(e,t,n){return typeof n==`function`?gl(e,t,function e(t,r,i,a,o,s){let c=n(t,r,i,a,o,s);return c===void 0?gl(t,r,e,s,!1):!!c},new Map,!0):hl(e,t,()=>void 0)}function gl(e,t,n,r,i=!1){if(t===e)return!0;switch(typeof t){case`object`:return _l(e,t,n,r,i);case`function`:return Object.keys(t).length>0?gl(e,{...t},n,r,i):Qa(e,t);default:return ml(e)&&i?typeof t!=`string`||t===``:Qa(e,t)}}function _l(e,t,n,r,i=!1){if(t==null)return!0;if(Array.isArray(t))return yl(e,t,n,r);if(t instanceof Map)return vl(e,t,n,r);if(t instanceof Set)return bl(e,t,n,r);let a=Object.keys(t);if(e==null)return i&&a.length===0;if(i)_a(e)&&(e=Object(e));else{let t=xa(e);if(t!==`[object Object]`&&t!==`[object Arguments]`)return!1}if(a.length===0)return!0;if(r?.has(t))return r.get(t)===e;r?.set(t,e);try{for(let i=0;i<a.length;i++){let o=a[i];if(!(o in e)||t[o]===void 0&&e[o]!==void 0||t[o]===null&&e[o]!==null||!n(e[o],t[o],o,e,t,r))return!1}return!0}finally{r?.delete(t)}}function vl(e,t,n,r){if(t.size===0)return!0;if(!(e instanceof Map))return!1;for(let[i,a]of t.entries())if(n(e.get(i),a,i,e,t,r)===!1)return!1;return!0}function yl(e,t,n,r){if(t.length===0)return!0;if(!Array.isArray(e))return!1;let i=new Set;for(let a=0;a<t.length;a++){let o=t[a],s=!1;for(let c=0;c<e.length;c++){if(i.has(c))continue;let l=e[c],u=!1;if(n(l,o,a,e,t,r)&&(u=!0),u){i.add(c),s=!0;break}}if(!s)return!1}return!0}function bl(e,t,n,r){return t.size===0||e instanceof Set&&yl([...e],[...t],n,r)}function xl(e,t){return hl(e,t,()=>void 0)}function Sl(e){return[e.parts.at(-1),e.parts.at(-2)]}function Cl(e){return V.fromParts([e])}function wl(e,t){return e.parts[0]!==Qi&&!t.ctx.has(e.parts)&&e.parts.length>1&&t.ctx.has([e.parts[0],ks])&&t.inferred.add(e.parts),e}function Tl(){}function El(e){return e.parts[0]}var Dl=class{db;calcBuilders;eqCheckers;stringifier=new pl;dataAdapter;langCtx;constructor(e){this.db=e,this.calcBuilders=e.langMgr.getVisitorMap(`calculationBuilder`),this.eqCheckers=e.langMgr.getVisitorMap(`equalityChecker`);let t=e.langMgr.getLang(`cypher`);this.dataAdapter=t.dataAdapter}maybeId(e,t){if(!(e instanceof Lc))return e;let n=[e.prop.parts[0]],r=e.expr;for(;r instanceof Lc;)n.push(r.prop.parts[0]),r=r.expr;return r instanceof V&&r.parts[0]!==Qi&&!t.ctx.has(r.parts)?(n.push(r.parts[0]),n.reverse(),V.fromParts(n)):e}toCalc(e,t){if(e=this.maybeId(e,t),e instanceof V)return wl(e,t);let n=e.accept(this,t);return n instanceof ho?n.fieldName:To(n,this.calcBuilders,this.eqCheckers)}processFnArg(e,t){return e=this.maybeId(e,t),e instanceof V?wl(e,t):{op:e.accept(this,t)}}processAttr(e,t){if(Array.isArray(e)?e[0]=this.maybeId(e[0],t):e=this.maybeId(e,t),e instanceof V)return[wl(e,t),e];if(Array.isArray(e))return[this.toCalc(e[0],t),e[1]];let n=Cl(e.accept(this.stringifier));return[this.toCalc(e,t),n]}processNode(e,t){return e=this.maybeId(e,t),e instanceof V?wl(e,t):e.accept(this,t)}buildPlan(e,t,n){this.langCtx=n;let r=new W,i=e.accept(this,{ctx:t,inferred:r,graphName:this.db.langMgr.getLang(`cypher`).defaultGraph});return e instanceof $i&&i instanceof ko&&i.lang===`cypher`&&(i=i.source),{plan:i,inferred:r}}visitCypherIdentifier(e,t){return this.visitIdentifier(e,t)}visitStringLiteral(e){return new bo(`cypher`,e.value)}visitNumberLiteral(e){return new bo(`cypher`,e.value)}visitListLiteral(e,t){return new q(`cypher`,e.items.map(e=>this.processFnArg(e,t)),Array.of)}visitMapLiteral(e,t){let n=e.items.map(e=>e[1].parts[0]),r=e.items.map(e=>this.processFnArg(e[0],t));return r.unshift({op:new bo(`cypher`,n)}),new q(`cypher`,r,pa)}visitBooleanLiteral(e){return new bo(`cypher`,e.value)}visitFnCallWrapper(e,t){if(e.procedure)return this.visitProcedure(e,t);let[n,r]=Sl(e.fn.id),i;try{i=this.db.langMgr.getFnOrAggr(`cypher`,n,r)}catch(e){let t=this.db.langMgr.getCast(`cypher`,n,r);if(t)i={name:t.name,impl:t.convert,pure:t.pure};else throw e}if(`init`in i){let n=new ho(`cypher`,e.fn.args.map(e=>this.toCalc(e,t)),i,V.fromParts([this.stringifier.visitFnCallWrapper(e)]));return e.distinct&&(n.postGroupOp=new zo(`cypher`,n.args,n.postGroupOp)),n}let a=e.fn.args.map(e=>this.processFnArg(e,t));if(i.addAdapterCtx){let e=this.db.getSource(t.graphName.parts);a.unshift({op:new bo(`cypher`,{adapter:this.dataAdapter,graph:e})})}return new q(`cypher`,a,i.impl,i.pure)}visitProcedure(e,t){let[n,r]=Sl(e.fn.id),i=this.db.langMgr.getFn(`cypher`,n,r),a=e.fn.args.map(e=>this.toCalc(e,t));if(i.addAdapterCtx){let e=this.db.getSource(t.graphName.parts),n={adapter:this.dataAdapter,graph:e};a.unshift(new _o(`cypher`,()=>n,[],[],new bo(`cypher`,n)))}let o=new po(`cypher`,a,i.impl,e.fn.id);return i.outputSchema&&o.addToSchema(i.outputSchema),e.yieldItems&&e.yieldItems!==`*`&&(o=new J(`cypher`,e.yieldItems.map(e=>this.processAttr(e,t)),o)),e.where&&(o=Zo(this.processNode(e.where,t),o,this.calcBuilders,this.eqCheckers,`cypher`)),o}visitExistsSubquery(e,t){let n;e.query?(n=e.query.accept(this,t),n instanceof K||(n=new Ao(`cypher`,Cl(`exists`),n))):n=this.visitMatchClause(e,t),n=new Po(`cypher`,0,1,n);let r=Cl(`count`);return n=new No(`cypher`,[],[new ho(`cypher`,[Cl(Zi)],this.db.langMgr.getAggr(`cypher`,`count`),r)],n),n=new ko(`cypher`,r,n),new q(`cypher`,[{op:n}],e=>e>0)}visitQuantifiedExpr(e,t){let n=new Ao(`cypher`,e.variable,new yo(`cypher`,[this.toCalc(e.expr,t)],sc.impl,Cl(`unwind`))),r=e.quantifier===kc.ALL,i=e.quantifier===kc.ANY,a=this.toCalc(e.where??e.variable,t);if(r){if(a instanceof V)a=new _o(`cypher`,e=>!e,[a],[void 0]);else{let e=a.impl;a.impl=(...t)=>!e(...t)}}return n=new Y(`cypher`,a,n),e.quantifier===kc.SINGLE?(n=new No(`cypher`,[],[new ho(`cypher`,[e.variable],this.db.langMgr.getAggr(`cypher`,`count`),e.variable)],n),new q(`cypher`,[{op:new ko(`cypher`,e.variable,n)}],e=>e===1)):(n=new Po(`cypher`,0,1,n),n=new J(`cypher`,[[new _o(`cypher`,()=>i,[],[]),e.variable]],n),new q(`cypher`,[{op:n}],t=>t===null?e.quantifier===kc.ALL||e.quantifier===kc.NONE:t))}preparePatternRefs(e,t,n,r){if(e.length){let i=r.src??new J(`cypher`,e.map(ia),new Bo(`cypher`));for(let a=0,o=0;a<t.length;a++)n[a]&&(i=this.patternToSelection(i,e[o++],t[a],r));return i}return r.src}patternToSelection(e,t,n,r){if(!n.props)return e;if(n.props instanceof V)return new Y(`cypher`,To(new q(`cypher`,[t,this.processFnArg(n.props,r)],xl),this.calcBuilders,this.eqCheckers),e);for(let i of n.props.items)e=new Y(`cypher`,To(new q(`cypher`,[{op:new q(`cypher`,[t,{op:new bo(`cypher`,[i[1].parts[0]])}],fa,!0)},this.processFnArg(i[0],r)],Qs.impl),this.calcBuilders,this.eqCheckers),e);return e}setupChainSelections(e,t,n,r,i,a){for(let o=i;o<=a;o+=2){let i=e[o];if(i.range)continue;let a=i.pointsLeft?`in`:i.pointsRight?`out`:`any`,s=i.pointsLeft?`out`:i.pointsRight?`in`:`any`;n=this.isEdgeConnected(n,a,t[o-1],t[o],r),n=this.isEdgeConnected(n,s,t[o+1],t[o],r),a===`any`&&(n=this.checkCorrectAnyEdge(t[o-1],t[o],t[o+1],r,n))}let o=t.filter((e,t)=>t%2==1);for(let t=i;t<=a;t+=2){let r=!!e[t].range;t===1||r||(n=new Y(`cypher`,To(new q(`cypher`,o.slice(0,t/2+1),(...t)=>{let n=t.pop();return t.every((t,r)=>e[r*2+1].range?!t.includes(n):t!==n)}),this.calcBuilders,this.eqCheckers),n))}return n}checkAnyRecEdge(e,t,n){return(e[n]!==e[n-1]&&e[n]!==t[n-1]||e[n]!==e[n+1]&&e[n]!==t[n+1]||e[n]===t[n])&&(t[n]!==e[n-1]&&t[n]!==t[n-1]||t[n]!==e[n+1]&&t[n]!==t[n+1]||e[n]===t[n])}checkCorrectAnyRecursion(e,t,n,r){let i=this.db.getSource(t.parts);return new Y(`cypher`,To(new q(`cypher`,[e[n-1],e[n],e[n+1]],(e,t,n)=>{let r=t.map(e=>this.dataAdapter.getEdgeNode(i,e,`source`)),a=t.map(e=>this.dataAdapter.getEdgeNode(i,e,`target`));if(t.length===1)return r[0]===e!=(r[0]===n)||r[0]===a[0];if(r[0]!==e&&r[0]!==r[1]&&r[0]!==a[1]||a[0]!==e&&a[0]!==r[1]&&a[0]!==a[1]||r.at(-1)!==n&&r.at(-1)!==r.at(-2)&&r.at(-1)!==a.at(-2)||a.at(-1)!==n&&a.at(-1)!==r.at(-2)&&a.at(-1)!==a.at(-2))return!1;for(let e=1;e<t.length-1;e++)if(!this.checkAnyRecEdge(r,a,e))return!1;return!0}),this.calcBuilders,this.eqCheckers),r)}checkCorrectAnyEdge(e,t,n,r,i){let a=this.db.getSource(r.parts);return new Y(`cypher`,To(new q(`cypher`,[e,t,n],(e,t,n)=>{let r=this.dataAdapter.getEdgeNode(a,t,`source`),i=this.dataAdapter.getEdgeNode(a,t,`target`);return r===e!=(r===n)||r===i}),this.calcBuilders,this.eqCheckers),i)}isEdgeConnected(e,t,n,r,i){return new Y(`cypher`,To(new q(`cypher`,[{op:new bo(`cypher`,this.db.getSource(i.parts))},n,r,{op:new bo(`cypher`,t)}],this.dataAdapter.isConnected),this.calcBuilders,this.eqCheckers),e)}setupVarsAndRefs(e,t){let n=Symbol(`unnamed`),r=e.chain.map((e,t)=>e.variable??V.fromParts([n,t+``])),i=e.chain.map(e=>e.variable?(wl(e.variable,t),e.variable.parts[0]===Qi||t.ctx.has(e.variable.parts)||t.src?.schemaSet.has(e.variable.parts)||e.variable.parts.at(-1)===ks):!1),a=t.src?G(t.ctx,t.src.schema):t.ctx;return{variables:r,isRef:i,ctx:a,res:this.preparePatternRefs(r.filter((e,t)=>i[t]),e.chain,i,{...t,ctx:a,src:t.optional?null:t.src}),varPrefix:n}}processChainPart(e,t,n,r,i){return e.chain[t].accept(this,{...r,variable:n[t],ctx:i})}joinNodesEdges(e,t,n,r,i,a){let o=-1,s=e.findIndex(e=>!e);if(s>-1){r||(r=t.chain[s].accept(this,{...i,variable:n[s],ctx:a}),s++);for(let c=s;c<t.chain.length;c++){if(e[c])continue;let s=t.chain[c];if(s instanceof Jc&&s.range){r=this.setupChainSelections(t.chain,n,r,i.graphName,o+2,c),o=c;let e=this.processChainPart(t,c+1,n,i,a);r=this.addRecursion(r,e,t.chain,n,c,{...i,ctx:a}),c++}else r=new xo(`cypher`,this.processChainPart(t,c,n,i,a),!1,r)}}return r=this.setupChainSelections(t.chain,n,r,i.graphName,o+2,t.chain.length-1),r}visitPatternElChain(e,t){let n=this.setupVarsAndRefs(e,t),{variables:r,isRef:i,ctx:a,varPrefix:o}=n,s=n.res;s=this.joinNodesEdges(i,e,r,s,t,a);let c=s.schema.filter(e=>e.parts[0]!==o).map(e=>[e,e]);if(!e.variable&&c.length===s.schema.length)return s;if(e.variable&&c.push([new _o(`cypher`,(...e)=>e,r,r.map(Tl)),e.variable]),s=new J(`cypher`,c,s),t.optional){let e=t.src??new Bo(`cypher`);s=new J(`cypher`,s.schema.filter(t=>!e.schemaSet.has(t.parts)).map(ia),s),s=new xo(`cypher`,s,!0,e)}return s}visitNodePattern(e,t){let n=t.graphName.parts,r=new vo(`cypher`,V.fromParts(n.concat(`nodes`))),i=new Ao(`cypher`,t.variable,r);return i=this.addNodeSelections(i,e,t),i}addNodeSelections(e,t,n){let r=n.graphName.parts,i=this.db.getSource(r);return t.labels.length&&(e=new Y(`cypher`,To(new q(`cypher`,[{op:new bo(`cypher`,i)},n.variable,{op:new bo(`cypher`,t.labels.map(El))}],this.dataAdapter.hasLabels),this.calcBuilders,this.eqCheckers),e)),t.props&&(e=this.patternToSelection(e,n.variable,t,n)),e}visitRelPattern(e,t){let n=t.graphName.parts,r=this.db.getSource(n),i=new vo(`cypher`,V.fromParts(n.concat(`edges`))),a=new Ao(`cypher`,t.variable,i);return e.types.length&&(a=new Y(`cypher`,To(new q(`cypher`,[{op:new bo(`cypher`,r)},t.variable,{op:new bo(`cypher`,e.types.map(El))}],this.dataAdapter.hasAnyType),this.calcBuilders,this.eqCheckers),a)),e.props&&(a=this.patternToSelection(a,t.variable,e,t)),a}prepareBidiRecInput(e,t,n,r,i,a,o,s){let c=this.db.getSource(s.graphName.parts),l=this.createRecursionMapping(i,c,n,e.clone(),a,o),u=new xo(`cypher`,e.clone(),!1,t);return u=this.isEdgeConnected(u,n,i[o],i[a],s.graphName),a>1&&(u=new Y(`cypher`,To(new q(`cypher`,i.filter((e,t)=>t%2==1).slice(0,a/2+1),(...e)=>{let t=e.pop();return e.every((e,n)=>r[n*2+1].range?!e.includes(t):e!==t)}),this.calcBuilders,this.eqCheckers),u)),[u,l]}addRecursion(e,t,n,r,i,a){let o=n[i],s=o.range[0]?.value??0,c=o.range[1]?.value??1/0,l=o.pointsLeft?`in`:o.pointsRight?`out`:`any`,u=l===`in`?`out`:l===`out`?`in`:`any`,d=this.visitRelPattern(o,{...a,variable:r[i]}),f,p,m=e;[e,f]=this.prepareBidiRecInput(d,e,l,n,r,i,i-1,a),[t,p]=this.prepareBidiRecInput(d,t,u,n,r,i,i+1,a);let h=new Wo(`cypher`,s||1,c,f,p,t,e);return h=new Y(`cypher`,To(new q(`cypher`,[r[i]],e=>{for(let t=0;t<e.length;t++)for(let n=t+1;n<e.length;n++)if(e[t]===e[n])return!1;return!0}),this.calcBuilders,this.eqCheckers),h),l===`any`&&(h=this.checkCorrectAnyRecursion(r,a.graphName,i,h)),s===0&&(h=this.handleRecursionZeroCase(m,n,r,i,h,a)),h}handleRecursionZeroCase(e,t,n,r,i,a){let o=new Bo(`cypher`);o=new J(`cypher`,e.schema.map(ia),o);let s=o.clone(),c=new bo(`cypher`,[]);return o=new J(`cypher`,[...o.attrs.map(e=>e.slice()),[To(c,this.calcBuilders,this.eqCheckers),n[r]],[n[r-1],n[r+1]]],o),o=this.addNodeSelections(o,t[r+1],{...a,variable:n[r+1]}),e.parent.replaceChild(e,s),new xo(`cypher`,new Io(`cypher`,o,i),!1,e)}createRecursionMapping(e,t,n,r,i,a){let o=new yo(`cypher`,[e[i],e[a]],(e,r)=>{let i=[];if(n===`any`){let n=this.dataAdapter.getEdgeNode(t,e.at(-1),`source`),a=this.dataAdapter.getEdgeNode(t,e.at(-1),`target`);e.length===1?i.push(n===r?a:n):this.dataAdapter.isConnected(t,n,e.at(-2),`any`)?i.push(a):i.push(n)}else n===`in`?i.push(this.dataAdapter.getEdgeNode(t,e.at(-1),`source`)):i.push(this.dataAdapter.getEdgeNode(t,e.at(-1),`target`));return Iterator.from(i).flatMap(r=>this.dataAdapter.filterNodeEdges(t,r,n,(t,n,r)=>!e.includes(r)))},Cl(`connectedEdges`)),s=r.source;for(;!(s instanceof vo);)s=s.source;return s.parent.replaceChild(s,o),r}visitPatternComprehension(e,t){let n=e.pattern.accept(this,{...t,src:void 0}),r=Cl(`pattern`);return e.where&&(n=Zo(this.processNode(e.where,{...t,ctx:G(t.ctx,n.schema)}),n,this.calcBuilders,this.eqCheckers,`cypher`)),n=new J(`cypher`,[[this.toCalc(e.expr,{...t,ctx:G(t.ctx,n.schema)}),r]],n),n=new No(`cypher`,[],[new ho(`cypher`,[r],Ls,r)],n),new ko(`cypher`,r,n)}visitListComprehension(e,t){let n=new Ao(`cypher`,e.variable,new yo(`cypher`,[this.toCalc(e.source,t)],sc.impl,Cl(`unwind`)));return e.where&&(n=Zo(this.processNode(e.where,{...t,ctx:G(t.ctx,[e.variable])}),n,this.calcBuilders,this.eqCheckers,`cypher`)),e.expr&&(n=new J(`cypher`,[[this.toCalc(e.expr,{...t,ctx:G(t.ctx,[e.variable])}),e.variable]],n)),n=new No(`cypher`,[],[new ho(`cypher`,[e.variable],Ls,e.variable)],n),new ko(`cypher`,e.variable,n)}visitCaseExpr(e,t){return new Eo(`cypher`,e.expr&&this.processNode(e.expr,t),e.whenThens.map(([e,n])=>[this.processNode(e,t),this.processNode(n,t)]),e.elseExpr&&this.processNode(e.elseExpr,t))}visitCountAll(e,t){throw Error(`Method not implemented.`)}visitLabelFilterExpr(e,t){return new q(`cypher`,[{op:new bo(`cypher`,this.db.getSource(t.graphName.parts))},this.processFnArg(e.expr,t),{op:new bo(`cypher`,e.labels.map(El))}],Q(this.dataAdapter.hasLabels))}visitSubscriptExpr(e,t){let n=e.subscript.filter(ea).map(e=>this.processFnArg(e,t));return n.unshift(this.processFnArg(e.expr,t)),new q(`cypher`,n,Q(e.subscript.length===2?(e,t,n)=>e.slice(t??0,n??e.length):(e,t)=>`at`in e?e.at(t):e[t]))}visitPropLookup(e,t){return new q(`cypher`,[this.processFnArg(e.expr,t),{op:new bo(`cypher`,e.prop.parts)}],fa)}visitSetOp(e,t){let n=e.next.accept(this,{...t,src:null});return n=new Io(`cypher`,t.src,n),e.type===Yc.UNION&&(n=new zo(`cypher`,Zi,n)),n}visitQuery(e,t){if(e.from)t={...t,graphName:e.from};else if(!t.graphName)throw Error(`No graph specified`);let n=e.statements[0].accept(this,t);for(let r=1;r<e.statements.length;r++)n=e.statements[r].accept(this,{...t,src:n});return e.setOp&&(n=this.visitSetOp(e.setOp,{...t,src:n})),n}visitMatchClause(e,t){let n=this.visitPatternElChain(e.pattern[0],{...t,optional:e.optional});for(let r=1;r<e.pattern.length;r++)n=this.visitPatternElChain(e.pattern[r],{...t,src:n,optional:e.optional});return e.where&&(n=Zo(this.processNode(e.where,{...t,ctx:G(t.ctx,n.schema)}),n,this.calcBuilders,this.eqCheckers,`cypher`)),n}visitUnwindClause(e,t){let n=this.processNode(e.expr,{...t,ctx:G(t.ctx,t.src?.schema??[])});go in n&&(n=To(n,this.calcBuilders,this.eqCheckers));let r;r=n instanceof V||n instanceof _o?new yo(`cypher`,[n],sc.impl,Cl(`unwind`)):n instanceof K?new ko(`cypher`,V.fromParts([Zi]),n):n;let i=new Ao(`cypher`,e.variable,r);return t.src?new xo(`cypher`,i,!1,t.src):i}visitCreateClause(e,t){throw new hc(`Only read operations are supported`)}visitMergeClause(e,t){throw new hc(`Only read operations are supported`)}visitSetClause(e,t){throw new hc(`Only read operations are supported`)}visitSetItem(e,t){throw Error(`Method not implemented.`)}visitRemoveClause(e,t){throw new hc(`Only read operations are supported`)}visitRemoveItem(e,t){throw Error(`Method not implemented.`)}visitDeleteClause(e,t){throw new hc(`Only read operations are supported`)}visitProjectionBody(e,t){let n=t.src??new Bo(`cypher`),r=n.schema,i=G(t.ctx,n.schema),a=[];for(let n of e.items)n===`*`?a.push(...r.map(ia)):a.push(this.processAttr(n,{...t,ctx:i}));let o=es(a.map(na)),s=e.distinct||o.length>0;if(e.order?.length&&(n=this.processOrderBy(e,n,{...t,ctx:i,bodyChangesCardinality:s,bodyAttrs:a})),!e.order?.length&&o.length&&(n=this.processGroupBy(n,o,a)),!s||!e.order?.length){if(e.order?.length)for(let e of a)e[0]instanceof _o&&n.schemaSet.has(e[1].parts)&&(e[0]=e[1]);n=new J(`cypher`,a,n)}return e.distinct&&(n=new zo(`cypher`,Zi,n)),(e.limit||e.skip)&&(n=this.buildLimit(e,n,t)),n}processOrderBy(e,t,n){let r=n.bodyChangesCardinality?[]:t.schema.map(ia);r.push(...n.bodyAttrs.map(la));let i=[];for(let t of e.order){let e=this.toCalc(t.expr,n);if(e instanceof _o){let n=Cl(t.expr.accept(this.stringifier));r.push([e,n]),i.push({ascending:t.ascending,key:n,nullsFirst:!1})}else i.push({ascending:t.ascending,key:e,nullsFirst:!1})}let a=es(r.map(na));return a.length?t=this.processGroupBy(t,a,r):n.bodyChangesCardinality||(t=new J(`cypher`,r,t)),n.bodyChangesCardinality&&(t=new J(`cypher`,n.bodyAttrs,t)),new Mo(`cypher`,i,t)}processGroupBy(e,t,n){let r=io(t.map(e=>e.fieldName)),i=[];for(let e of n)e[0]instanceof V?r.has(e[0].parts)||i.push(e.slice()):e[0].aggregates.length||i.push([e[0].clone(),e[1]]);for(let n of t)n.postGroupSource.addToSchema(e.schema);return new No(`cypher`,i,t,e)}buildLimit(e,t,n){let r=e.limit!==null&&this.toCalc(e.limit,n),i=e.skip!==null&&this.toCalc(e.skip,n);if(r&&!Jo(r,`number`))throw Error(`Limit must be a number constant`);if(i&&!Jo(i,`number`))throw Error(`Offset must be a number constant`);return new Po(`cypher`,i?i.impl():0,r?r.impl():1/0,t)}visitOrderItem(e,t){throw Error(`Method not implemented.`)}visitWithClause(e,t){let n=this.visitProjectionBody(e.body,{...t});return e.where&&(n=Zo(this.processNode(e.where,{...t,ctx:G(t.ctx,n.schemaSet)}),n,this.calcBuilders,this.eqCheckers,`cypher`)),n}visitReturnClause(e,t){return this.visitProjectionBody(e.body,{...t})}visitLiteral(e,t){return new bo(`cypher`,e.value)}visitOperator(e,t){let n=this.db.langMgr.getOp(e.lang,...Sl(e.id));return new q(e.lang,e.operands.map(e=>({op:e.accept(this,t)})),n.impl,!0)}visitFunction(e,t){throw Error(`Method not implemented.`)}visitLangSwitch(e,t){let n=new(this.db.langMgr.getLang(e.lang)).visitors.logicalPlanBuilder(this.db).buildPlan(e.node,t.ctx,this.langCtx);for(let e of n.inferred)t.inferred.add(e);return n.plan instanceof K?new ko(`cypher`,null,n.plan):n.plan}visitIdentifier(e,t){return wl(e,t),new q(`cypher`,[e],ea)}},Ol=class extends SyntaxError{constructor(e,t,n,r){super(e),this.expected=t,this.found=n,this.location=r,this.name=`SyntaxError`}format(e){let t=`Error: `+this.message;if(this.location){let n=null,r=e.find(e=>e.source===this.location.source);r&&(n=r.text.split(/\r\n|\n|\r/g));let i=this.location.start,a=this.location.source&&typeof this.location.source.offset==`function`?this.location.source.offset(i):i,o=this.location.source+`:`+a.line+`:`+a.column;if(n){let e=this.location.end,r=``.padEnd(a.line.toString().length,` `),s=n[i.line-1],c=(i.line===e.line?e.column:s.length+1)-i.column||1;t+=`
|
|
315
|
-
--> `+o+`
|
|
316
|
-
`+r+` |
|
|
317
|
-
`+a.line+` | `+s+`
|
|
318
|
-
`+r+` | `+``.padEnd(i.column-1,` `)+``.padEnd(c,`^`)}else t+=`
|
|
319
|
-
at `+o}return t}static buildMessage(e,t){function n(e){return e.codePointAt(0).toString(16).toUpperCase()}let r=Object.prototype.hasOwnProperty.call(RegExp.prototype,`unicode`)?RegExp(`[\\p{C}\\p{Mn}\\p{Mc}]`,`gu`):null;function i(e){return r?e.replace(r,e=>`\\u{`+n(e)+`}`):e}function a(e){return i(e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/\0/g,`\\0`).replace(/\t/g,`\\t`).replace(/\n/g,`\\n`).replace(/\r/g,`\\r`).replace(/[\x00-\x0F]/g,e=>`\\x0`+n(e)).replace(/[\x10-\x1F\x7F-\x9F]/g,e=>`\\x`+n(e)))}function o(e){return i(e.replace(/\\/g,`\\\\`).replace(/\]/g,`\\]`).replace(/\^/g,`\\^`).replace(/-/g,`\\-`).replace(/\0/g,`\\0`).replace(/\t/g,`\\t`).replace(/\n/g,`\\n`).replace(/\r/g,`\\r`).replace(/[\x00-\x0F]/g,e=>`\\x0`+n(e)).replace(/[\x10-\x1F\x7F-\x9F]/g,e=>`\\x`+n(e)))}let s={literal(e){return`"`+a(e.text)+`"`},class(e){let t=e.parts.map(e=>Array.isArray(e)?o(e[0])+`-`+o(e[1]):o(e));return`[`+(e.inverted?`^`:``)+t.join(``)+`]`+(e.unicode?`u`:``)},any(){return`any character`},end(){return`end of input`},other(e){return e.description}};function c(e){return s[e.type](e)}function l(e){let t=e.map(c);if(t.sort(),t.length>0){let e=1;for(let n=1;n<t.length;n++)t[n-1]!==t[n]&&(t[e]=t[n],e++);t.length=e}switch(t.length){case 1:return t[0];case 2:return t[0]+` or `+t[1];default:return t.slice(0,-1).join(`, `)+`, or `+t[t.length-1]}}function u(e){return e?`"`+a(e)+`"`:`end of input`}return`Expected `+l(e)+` but `+u(t)+` found.`}};function kl(e,t){t=t===void 0?{}:t;let n={},r=t.grammarSource,i={Cypher:Fi},a=Fi,o=`lang`,s=`union`,c=`optional`,l=`match`,u=`unwind`,d=`merge`,f=`create`,p=`detach`,m=`delete`,h=`remove`,g=`call`,_=`yield`,v=`with`,y=`return`,b=`distinct`,x=`order`,S=`skip`,C=`limit`,w=`ascending`,T=`descending`,ee=`desc`,te=`where`,ne=`starts`,re=`ends`,ie=`contains`,ae=`null`,oe=`count`,se=`case`,ce=`else`,le=`when`,E=`then`,ue=`none`,de=`single`,D=`exists`,fe=`true`,pe=`false`,me=/^[)\]}]/,he=/^[<>]/,ge=/^[+\-]/,_e=/^[%*\/]/,ve=/^[0-9a-z_$]/i,ye=/^[01]/,be=/^[a-f]/i,xe=/^[0-9]/,O=/^[1-9]/,k=/^[0-7]/,A=/^[^"\\]/,Se=/^[^'\\]/,Ce=/^[\p{ID_Start}\p{Pc}]/u,we=/^[\p{ID_Continue}\p{Sc}]/u,Te=/^[^`]/,Ee=/^[\p{White_Space}]/u,De=/^[^*]/,Oe=/^[^\/]/,ke=/^[^\r\n]/,Ae=/^[<\u27E8\u3008\uFE64\uFF1C]/,je=/^[>\u27E9\u3009\uFE65\uFF1E]/,Me=/^[\-\xAD\u2010\u2011\u2012\u2013\u2014\u2015\u2212\uFE58\uFE63\uFF0D]/,Ne=R(`;`,!1),Pe=Ai(),Fe=R(`lang`,!0),Ie=R(`exit`,!0),Le=ki([`)`,`]`,`}`],!1,!1,!1),Re=R(`FROM`,!0),ze=R(`UNION`,!0),Be=R(`ALL`,!0),Ve=R(`OPTIONAL`,!0),He=R(`MATCH`,!0),Ue=R(`UNWIND`,!0),We=R(`AS`,!0),Ge=R(`MERGE`,!0),Ke=R(`ON`,!0),qe=R(`CREATE`,!0),Je=R(`SET`,!0),Ye=R(`,`,!1),Xe=R(`=`,!1),Ze=R(`+=`,!1),Qe=R(`DETACH`,!0),$e=R(`DELETE`,!0),et=R(`REMOVE`,!0),tt=R(`CALL`,!0),nt=R(`YIELD`,!0),rt=R(`*`,!1),it=R(`WITH`,!0),at=R(`RETURN`,!0),ot=R(`DISTINCT`,!0),st=R(`ORDER`,!0),ct=R(`BY`,!0),lt=R(`SKIP`,!0),ut=R(`LIMIT`,!0),dt=R(`ASCENDING`,!0),ft=R(`ASC`,!0),pt=R(`DESCENDING`,!0),mt=R(`DESC`,!0),ht=R(`WHERE`,!0),gt=R(`(`,!1),_t=R(`)`,!1),vt=R(`[`,!1),yt=R(`]`,!1),bt=R(`:`,!1),xt=R(`|`,!1),St=R(`..`,!1),Ct=R(`OR`,!0),wt=R(`XOR`,!0),Tt=R(`AND`,!0),Et=R(`NOT`,!0),Dt=R(`<>`,!1),Ot=R(`<=`,!1),kt=R(`>=`,!1),At=ki([`<`,`>`],!1,!1,!1),jt=R(`STARTS`,!0),Mt=R(`ENDS`,!0),Nt=R(`CONTAINS`,!0),Pt=R(`IN`,!0),Ft=R(`IS`,!0),It=R(`NULL`,!0),Lt=ki([`+`,`-`],!1,!1,!1),Rt=ki([`%`,`*`,`/`],!1,!1,!1),zt=R(`^`,!1),Bt=R(`.`,!1),Vt=R(`COUNT`,!0),Ht=R(`LANG`,!0),Ut=ki([[`0`,`9`],[`a`,`z`],`_`,`$`],!1,!0,!1),Wt=R(`CASE`,!0),Gt=R(`ELSE`,!0),Kt=R(`END`,!0),j=R(`WHEN`,!0),qt=R(`THEN`,!0),Jt=R(`ANY`,!0),Yt=R(`NONE`,!0),Xt=R(`SINGLE`,!0),Zt=R(`EXISTS`,!0),Qt=R(`{`,!1),$t=R(`}`,!1),en=R(`TRUE`,!0),tn=R(`FALSE`,!0),nn=R(`0x`,!1),rn=R(`0o`,!1),an=R(`0b`,!1),on=ki([`0`,`1`],!1,!1,!1),sn=ki([[`a`,`f`]],!1,!0,!1),cn=ki([[`0`,`9`]],!1,!1,!1),ln=ki([[`1`,`9`]],!1,!1,!1),un=ki([[`0`,`7`]],!1,!1,!1),dn=R(`0`,!1),fn=R(`E`,!0),pn=R(`-`,!1),mn=R(`"`,!1),hn=ki([`"`,`\\`],!0,!1,!1),gn=R(`'`,!1),_n=ki([`'`,`\\`],!0,!1,!1),vn=R(`\\`,!1),yn=R(`$`,!1),bn=R(`CONSTRAINT`,!0),xn=R(`DO`,!0),Sn=R(`FOR`,!0),Cn=R(`REQUIRE`,!0),wn=R(`UNIQUE`,!0),Tn=R(`MANDATORY`,!0),En=R(`SCALAR`,!0),Dn=R(`OF`,!0),On=R(`ADD`,!0),kn=R(`DROP`,!0),An=R(`FILTER`,!0),jn=R(`EXTRACT`,!0),Mn=ki([`\\p{ID_Start}`,`\\p{Pc}`],!1,!1,!0),M=ki([`\\p{ID_Continue}`,`\\p{Sc}`],!1,!1,!0),Nn=R("`",!1),N=ki(["`"],!0,!1,!1),Pn=ki([`\\p{White_Space}`],!1,!1,!0),Fn=R(`/*`,!1),In=ki([`*`],!0,!1,!1),Ln=ki([`/`],!0,!1,!1),Rn=R(`*/`,!1),zn=R(`//`,!1),Bn=ki([`\r`,`
|
|
320
|
-
`],!0,!1,!1),Vn=R(`\r`,!1),Hn=R(`
|
|
321
|
-
`,!1),Un=ki([`<`,`⟨`,`〈`,`﹤`,`<`],!1,!1,!1),Wn=ki([`>`,`⟩`,`〉`,`﹥`,`>`],!1,!1,!1),Gn=ki([`-`,``,`‐`,`‑`,`‒`,`–`,`—`,`―`,`−`,`﹘`,`﹣`,`-`],!1,!1,!1);function Kn(t){return{value:t,remainingInput:e.slice(Di().end.offset)}}function qn(t){return{value:t,remainingInput:e.slice(Di().end.offset)}}function Jn(t){return{value:t,remainingInput:e.slice(Di().end.offset)}}function Yn(e,t,n){t.from=e;let r=t;for(let[e,t]of n)r.setOp=new Z.SetOp(e,t),r=t;return t}function Xn(){return`unionall`}function Zn(){return`union`}function Qn(e,t){return e.push(t),new Z.Query(e)}function $n(e,t,n){return new Z.Query([...e,...t,n])}function er(e,t){return t.statements=[e,t.statements].flat(1/0),t}function tr(e,t,n){return[e,t,n]}function nr(e,t,n){let r=new Z.MatchClause(t,n);return r.optional=!!e,r}function rr(e,t){return new Z.UnwindClause(e,t)}function ir(e,t){return new Z.MergeClause(e,t)}function ar(e){return new yy.ast.MergeAction(`match`,e.items)}function or(e){return new yy.ast.MergeAction(`create`,e.items)}function sr(e){return new Z.CreateClause(e)}function cr(e){return new Z.SetClause(e)}function lr(e,t){return new Z.SetItem(e,t)}function ur(e,t){return new Z.SetItem(e,t)}function dr(e,t){let n=new Z.SetItem(e,t);return n.add=!0,n}function fr(e,t){return new Z.SetItem(e,t)}function pr(e,t){return new Z.DeleteClause(t,!!e)}function mr(e){return new Z.RemoveClause(e)}function hr(e,t){return new Z.RemoveItem(e,t)}function gr(e){return new Z.RemoveItem(e)}function _r(e,t){let n=e;return e.where=t[0],e.yieldItems=t[1],n}function vr(e,t){let n=e;return e.where=t[0],e.yieldItems=t[1],n}function yr(e,t){return new Z.WithClause(e,t)}function br(e){return new Z.ReturnClause(e)}function xr(e,t,n,r,i){return new Z.ProjectionBody(t,n,r,i,!!e)}function Sr(e){return[`*`,...e]}function Cr(e,t){let n=!t||t[0]===`a`||t[0]===`A`;return new Z.OrderItem(e,n)}function wr(e,t){return t.variable=e,t}function Tr(e,t){return new Z.PatternElChain([e,t].flat(1/0))}function Er(e,t,n){return new Z.NodePattern(e,t??[],n)}function Dr(e){return e??=new Z.RelPattern,e.pointsLeft=!0,e}function Or(e){return e??=new Z.RelPattern,e.pointsRight=!0,e}function kr(e){return e??new Z.RelPattern}function Ar(e,t,n,r){return new Z.RelPattern(!1,!1,e,t??[],n,r)}function jr(e,t){e=e===null?void 0:new Z.ASTNumberLiteral(e);let n=t?t[1]===null?void 0:new Z.ASTNumberLiteral(t[1]):e;return[e,n]}function Mr(e,t){for(let n of t)e=new Z.PropLookup(e,n);return e}function Nr(e,t){return Yo(e,`or`,t)}function Pr(e,t){return Yo(e,`xor`,t)}function Fr(e,t){return Yo(e,`and`,t)}function Ir(e,n){for(let r=0;r<e.length;r++)n=t.makeOp(`not`,[n]);return n}function Lr(e,n){if(!n.length)return e;let[r,...i]=n;e=t.makeOp(r[0],[e,r[1]]);for(let[n,r]of i)e=t.makeOp(`and`,[e,t.makeOp(n,[e.operands[1],r])]);return e}function Rr(e,n){for(let[r,i]of n)e=t.makeOp(r,i?[e,i]:[e]);return e}function zr(){return`startswith`}function Br(){return`endswith`}function Vr(){return`isnull`}function Hr(){return`isnotnull`}function Ur(e,n){for(let[r,i]of n)e=t.makeOp(r,[e,i]);return e}function Wr(e,n){for(let[r,i]of n)e=t.makeOp(r,[e,i]);return e}function Gr(e,t){return Yo(e,`^`,t)}function Kr(e,n){return t.makeOp(e,[n])}function qr(e,t){return t?new Z.LabelFilterExpr(e,t):e}function Jr(e,t){for(let n of t)e=Array.isArray(n)?new Z.SubscriptExpr(e,n):new Z.PropLookup(e,n);return e}function Yr(e){return[e]}function Xr(){return t.wrapFn(Z.ASTIdentifier.fromParts([`count`]),[Z.ASTIdentifier.fromParts([Z.allAttrs])])}function Zr(n){n=n.toLowerCase();let r=t.langMgr.getLang(n);if(!r)throw Error(`Unknown language: ${n}`);let i=Di().end.offset,a=r.createParser(t.langMgr),o=`
|
|
322
|
-
`.repeat(Di().end.line-1)+` `.repeat(Di().end.column-1),s=a.parse(o+e.slice(i));return e=e.slice(0,i)+e.slice(i,e.length-s.remainingInput.length).replace(/[^\n]/g,` `)+s.remainingInput,new Z.LangSwitch(n,s.value)}function Qr(e,t){return new Z.CaseExpr(void 0,e,t)}function $r(e,t,n){return new Z.CaseExpr(e,t,n)}function ei(e,t){return new Z.ListComprehension(e.v,e.expr,e.where,t)}function ti(e,t,n,r){return t=new Z.PatternElChain(t.flat(1/0)),t.variable=e,new Z.PatternComprehension(t,n,r)}function ni(e,t){return new Z.QuantifiedExpr(e.toLowerCase(),t.v,t.expr,t.where)}function ri(e,t){return{where:t,v:e[0],expr:e[1]}}function ii(e){let t=new Z.PatternElChain(e.flat(1/0));return new Z.ExistsSubquery(null,[t])}function ai(e,n,r){return t.wrapFn(e,r??[],!!n)}function oi(){return new Z.CypherIdentifier(Ei())}function si(e){return new Z.ExistsSubquery(e)}function ci(e,t){return new Z.ExistsSubquery(null,e,t)}function li(e){return new Z.ExistsSubquery(e)}function ui(e,n){let r=new t.wrapFn(e,n??[]);return r.procedure=!0,r}function di(e){let n=new t.wrapFn(e);return n.procedure=!0,n}function fi(){return new Z.CypherIdentifier(Ei())}function pi(e){return new Z.ASTBooleanLiteral(e)}function mi(e){return new Z.ASTBooleanLiteral(e)}function hi(e){return new Z.ASTNumberLiteral(e)}function gi(e){return new Z.ASTStringLiteral(e)}function _i(e){return new Z.ASTListLiteral(e??[])}function vi(e){return e??=[],new Z.ASTMapLiteral(e.map(([e,t])=>[t,e]))}function yi(e){let t=new Z.CypherIdentifier(e);return t.parts.unshift(Z.boundParam),t}function bi(e){return new Z.CypherIdentifier(e)}function xi(){return new Z.CypherIdentifier(Ei())}let P=t.peg$currPos|0,F=P,Si=[{line:1,column:1}],Ci=P,wi=t.peg$maxFailExpected||[],I=t.peg$silentFails|0,L={},Ti;if(t.startRule){if(!(t.startRule in i))throw Error(`Can't start parsing from rule "`+t.startRule+`".`);a=i[t.startRule]}function Ei(){return e.substring(F,P)}function Di(){return Ni(F,P)}function Oi(t=P){let n=e.codePointAt(t);return n===void 0?``:String.fromCodePoint(n)}function R(e,t){return{type:`literal`,text:e,ignoreCase:t}}function ki(e,t,n,r){return{type:`class`,parts:e,inverted:t,ignoreCase:n,unicode:r}}function Ai(){return{type:`any`}}function ji(){return{type:`end`}}function Mi(t){let n=Si[t],r;if(n)return n;if(t>=Si.length)r=Si.length-1;else for(r=t;!Si[--r];);for(n=Si[r],n={line:n.line,column:n.column};r<t;)e.charCodeAt(r)===10?(n.line++,n.column=1):n.column++,r++;return Si[t]=n,n}function Ni(e,t,n){let i=Mi(e),a=Mi(t),o={source:r,start:{offset:e,line:i.line,column:i.column},end:{offset:t,line:a.line,column:a.column}};return n&&r&&typeof r.offset==`function`&&(o.start=r.offset(o.start),o.end=r.offset(o.end)),o}function z(e){P<Ci||(P>Ci&&(Ci=P,wi=[]),wi.push(e))}function Pi(e,t,n){return new Ol(Ol.buildMessage(e,t),e,t,n)}function Fi(){let t,r,i,a,s,c,l,u,d=P*132+0,f=L[d];return f?(P=f.nextPos,f.result):(t=P,r=X(),r===n&&(r=null),i=Ii(),i===n?(P=t,t=n):(a=P,s=X(),s===n&&(s=null),e.charCodeAt(P)===59?(c=`;`,P++):(c=n,I===0&&z(Ne)),c===n?(P=a,a=n):(s=[s,c],a=s),a===n&&(a=null),s=X(),s===n&&(s=null),c=P,I++,e.length>P?(l=e.charAt(P),P++):(l=n,I===0&&z(Pe)),I--,l===n?c=void 0:(P=c,c=n),c===n?(P=t,t=n):(F=t,t=Kn(i))),t===n&&(t=P,r=X(),r===n&&(r=null),i=Ii(),i===n?(P=t,t=n):(a=P,s=X(),s===n&&(s=null),e.charCodeAt(P)===59?(c=`;`,P++):(c=n,I===0&&z(Ne)),c===n?(P=a,a=n):(s=[s,c],a=s),a===n&&(a=null),s=X(),s===n&&(s=null),c=P,I++,l=Li(),I--,l===n?c=n:(P=c,c=void 0),c===n?(P=t,t=n):(F=t,t=qn(i))),t===n&&(t=P,r=X(),r===n&&(r=null),i=Ii(),i===n?(P=t,t=n):(a=P,s=X(),s===n&&(s=null),e.charCodeAt(P)===59?(c=`;`,P++):(c=n,I===0&&z(Ne)),c===n?(P=a,a=n):(s=[s,c],a=s),a===n&&(a=null),s=X(),s===n&&(s=null),c=e.substr(P,4),c.toLowerCase()===o?P+=4:(c=n,I===0&&z(Fe)),c===n?(P=t,t=n):(l=X(),l===n?(P=t,t=n):(u=e.substr(P,4),u.toLowerCase()===`exit`?P+=4:(u=n,I===0&&z(Ie)),u===n?(P=t,t=n):(F=t,t=Jn(i))))))),L[d]={nextPos:P,result:t},t)}function Ii(){let e,t=P*132+1,r=L[t];return r?(P=r.nextPos,r.result):(e=no(),e===n&&(e=Ri()),L[t]={nextPos:P,result:e},e)}function Li(){let t,r=P*132+2,i=L[r];return i?(P=i.nextPos,i.result):(t=e.charAt(P),me.test(t)?P++:(t=n,I===0&&z(Le)),L[r]={nextPos:P,result:t},t)}function Ri(){let e,t=P*132+3,r=L[t];return r?(P=r.nextPos,r.result):(e=zi(),e===n&&(e=ia()),L[t]={nextPos:P,result:e},e)}function zi(){let e,t,r,i,a,o,s,c=P*132+4,l=L[c];if(l)return P=l.nextPos,l.result;if(e=P,t=P,r=Bi(),r===n?(P=t,t=n):(i=X(),i===n?(P=t,t=n):t=r),t===n&&(t=null),r=Ui(),r!==n){for(i=[],a=P,o=X(),o===n&&(o=null),s=Vi(),s===n?(P=a,a=n):a=s;a!==n;)i.push(a),a=P,o=X(),o===n&&(o=null),s=Vi(),s===n?(P=a,a=n):a=s;F=e,e=Yn(t,r,i)}else P=e,e=n;return L[c]={nextPos:P,result:e},e}function Bi(){let t,r,i,a,o=P*132+5,s=L[o];return s?(P=s.nextPos,s.result):(t=P,r=e.substr(P,4),r.toLowerCase()===`from`?P+=4:(r=n,I===0&&z(Re)),r===n?(P=t,t=n):(i=X(),i===n?(P=t,t=n):(a=zo(),a===n?(P=t,t=n):t=a)),L[o]={nextPos:P,result:t},t)}function Vi(){let e,t,r,i=P*132+6,a=L[i];return a?(P=a.nextPos,a.result):(e=P,t=Hi(),t===n?(P=e,e=n):(r=Ui(),r===n?(P=e,e=n):(t=[t,r],e=t)),L[i]={nextPos:P,result:e},e)}function Hi(){let t,r,i,a,o,c=P*132+7,l=L[c];return l?(P=l.nextPos,l.result):(t=P,r=e.substr(P,5),r.toLowerCase()===s?P+=5:(r=n,I===0&&z(ze)),r===n?(P=t,t=n):(i=X(),i===n?(P=t,t=n):(a=e.substr(P,3),a.toLowerCase()===`all`?P+=3:(a=n,I===0&&z(Be)),a===n?(P=t,t=n):(o=X(),o===n&&(o=null),F=t,t=Xn()))),t===n&&(t=P,r=e.substr(P,5),r.toLowerCase()===s?P+=5:(r=n,I===0&&z(ze)),r===n?(P=t,t=n):(i=X(),i===n&&(i=null),F=t,t=Zn())),L[c]={nextPos:P,result:t},t)}function Ui(){let e,t=P*132+8,r=L[t];return r?(P=r.nextPos,r.result):(e=Wi(),e===n&&(e=Gi()),L[t]={nextPos:P,result:e},e)}function Wi(){let e,t,r,i,a,o,s,c,l=P*132+9,u=L[l];if(u)return P=u.nextPos,u.result;for(e=P,t=[],r=qi();r!==n;)t.push(r),r=P,i=X(),i===n&&(i=null),i=qi(),i===n?(P=r,r=n):r=i;if(r=X(),r===n&&(r=null),i=ua(),i===n?(P=e,e=n):(F=e,e=Qn(t,i)),e===n){for(e=P,t=[],r=qi();r!==n;)t.push(r),r=P,i=X(),i===n&&(i=null),i=qi(),i===n?(P=r,r=n):r=i;for(r=X(),r===n&&(r=null),i=P,a=[],o=B();o!==n;)a.push(o),o=P,s=X(),s===n&&(s=null),s=B(),s===n?(P=o,o=n):o=s;a.length<1?(P=i,i=n):i=a,i===n?(P=e,e=n):(a=X(),a===n&&(a=null),o=P,s=X(),s===n&&(s=null),c=ua(),c===n?(P=o,o=n):o=c,o===n&&(o=null),F=e,e=$n(t,i,o))}return L[l]={nextPos:P,result:e},e}function Gi(){let e,t,r,i=P*132+10,a=L[i];if(a)return P=a.nextPos,a.result;if(e=P,t=[],r=Ki(),r!==n)for(;r!==n;)t.push(r),r=Ki();else t=n;return t===n?(P=e,e=n):(r=Wi(),r===n?(P=e,e=n):(F=e,e=er(t,r))),L[i]={nextPos:P,result:e},e}function Ki(){let e,t,r,i,a,o,s,c=P*132+11,l=L[c];if(l)return P=l.nextPos,l.result;for(e=P,t=[],r=qi();r!==n;)t.push(r),r=P,i=X(),i===n&&(i=null),i=qi(),i===n?(P=r,r=n):r=i;for(r=X(),r===n&&(r=null),i=[],a=B();a!==n;)i.push(a),a=P,o=X(),o===n&&(o=null),o=B(),o===n?(P=a,a=n):a=o;return a=X(),a===n&&(a=null),o=la(),o===n?(P=e,e=n):(s=X(),s===n&&(s=null),F=e,e=tr(t,i,o)),L[c]={nextPos:P,result:e},e}function B(){let e,t=P*132+12,r=L[t];return r?(P=r.nextPos,r.result):(e=Qi(),e===n&&(e=Xi(),e===n&&(e=ea(),e===n&&(e=V(),e===n&&(e=ta())))),L[t]={nextPos:P,result:e},e)}function qi(){let e,t=P*132+13,r=L[t];return r?(P=r.nextPos,r.result):(e=Ji(),e===n&&(e=Yi(),e===n&&(e=ra())),L[t]={nextPos:P,result:e},e)}function Ji(){let t,r,i,a,o,s,u,d,f=P*132+14,p=L[f];return p?(P=p.nextPos,p.result):(t=P,r=P,i=e.substr(P,8),i.toLowerCase()===c?P+=8:(i=n,I===0&&z(Ve)),i===n?(P=r,r=n):(a=X(),a===n?(P=r,r=n):r=i),r===n&&(r=null),i=e.substr(P,5),i.toLowerCase()===l?P+=5:(i=n,I===0&&z(He)),i===n?(P=t,t=n):(a=X(),a===n&&(a=null),o=va(),o===n?(P=t,t=n):(s=P,u=X(),u===n&&(u=null),d=_a(),d===n?(P=s,s=n):s=d,s===n&&(s=null),F=t,t=nr(r,o,s))),L[f]={nextPos:P,result:t},t)}function Yi(){let t,r,i,a,o,s,c,l,d=P*132+15,f=L[d];return f?(P=f.nextPos,f.result):(t=P,r=e.substr(P,6),r.toLowerCase()===u?P+=6:(r=n,I===0&&z(Ue)),r===n?(P=t,t=n):(i=X(),i===n?(P=t,t=n):(a=U(),a===n?(P=t,t=n):(o=X(),o===n?(P=t,t=n):(s=e.substr(P,2),s.toLowerCase()===`as`?P+=2:(s=n,I===0&&z(We)),s===n?(P=t,t=n):(c=X(),c===n?(P=t,t=n):(l=zo(),l===n?(P=t,t=n):(F=t,t=rr(a,l)))))))),L[d]={nextPos:P,result:t},t)}function Xi(){let t,r,i,a,o,s,c,l,u=P*132+16,f=L[u];if(f)return P=f.nextPos,f.result;if(t=P,r=e.substr(P,5),r.toLowerCase()===d?P+=5:(r=n,I===0&&z(Ge)),r!==n){if(i=X(),i===n&&(i=null),a=ya(),a!==n){for(o=[],s=P,c=X(),c===n?(P=s,s=n):(l=Zi(),l===n?(P=s,s=n):s=l);s!==n;)o.push(s),s=P,c=X(),c===n?(P=s,s=n):(l=Zi(),l===n?(P=s,s=n):s=l);F=t,t=ir(a,o)}else P=t,t=n}else P=t,t=n;return L[u]={nextPos:P,result:t},t}function Zi(){let t,r,i,a,o,s,c=P*132+17,u=L[c];return u?(P=u.nextPos,u.result):(t=P,r=e.substr(P,2),r.toLowerCase()===`on`?P+=2:(r=n,I===0&&z(Ke)),r===n?(P=t,t=n):(i=X(),i===n?(P=t,t=n):(a=e.substr(P,5),a.toLowerCase()===l?P+=5:(a=n,I===0&&z(He)),a===n?(P=t,t=n):(o=X(),o===n?(P=t,t=n):(s=V(),s===n?(P=t,t=n):(F=t,t=ar(s)))))),t===n&&(t=P,r=e.substr(P,2),r.toLowerCase()===`on`?P+=2:(r=n,I===0&&z(Ke)),r===n?(P=t,t=n):(i=X(),i===n?(P=t,t=n):(a=e.substr(P,6),a.toLowerCase()===f?P+=6:(a=n,I===0&&z(qe)),a===n?(P=t,t=n):(o=X(),o===n?(P=t,t=n):(s=V(),s===n?(P=t,t=n):(F=t,t=or(s))))))),L[c]={nextPos:P,result:t},t)}function Qi(){let t,r,i,a,o=P*132+18,s=L[o];return s?(P=s.nextPos,s.result):(t=P,r=e.substr(P,6),r.toLowerCase()===f?P+=6:(r=n,I===0&&z(qe)),r===n?(P=t,t=n):(i=X(),i===n&&(i=null),a=va(),a===n?(P=t,t=n):(F=t,t=sr(a))),L[o]={nextPos:P,result:t},t)}function V(){let t,r,i,a,o,s,c,l,u,d,f=P*132+19,p=L[f];if(p)return P=p.nextPos,p.result;if(t=P,r=e.substr(P,3),r.toLowerCase()===`set`?P+=3:(r=n,I===0&&z(Je)),r!==n){for(i=X(),i===n&&(i=null),a=P,o=[],s=$i();s!==n;)o.push(s),s=P,c=P,l=X(),l===n&&(l=null),e.charCodeAt(P)===44?(u=`,`,P++):(u=n,I===0&&z(Ye)),u===n?(P=c,c=n):(d=X(),d===n&&(d=null),l=[l,u,d],c=l),c===n?s=c:(c=$i(),c===n?(P=s,s=n):s=c);o.length<1?(P=a,a=n):a=o,a===n?(P=t,t=n):(F=t,t=cr(a))}else P=t,t=n;return L[f]={nextPos:P,result:t},t}function $i(){let t,r,i,a,o,s,c=P*132+20,l=L[c];return l?(P=l.nextPos,l.result):(t=P,r=ja(),r===n?(P=t,t=n):(i=X(),i===n&&(i=null),e.charCodeAt(P)===61?(a=`=`,P++):(a=n,I===0&&z(Xe)),a===n?(P=t,t=n):(o=X(),o===n&&(o=null),s=U(),s===n?(P=t,t=n):(F=t,t=lr(r,s)))),t===n&&(t=P,r=zo(),r===n?(P=t,t=n):(i=X(),i===n&&(i=null),e.charCodeAt(P)===61?(a=`=`,P++):(a=n,I===0&&z(Xe)),a===n?(P=t,t=n):(o=X(),o===n&&(o=null),s=U(),s===n?(P=t,t=n):(F=t,t=ur(r,s)))),t===n&&(t=P,r=zo(),r===n?(P=t,t=n):(i=X(),i===n&&(i=null),e.substr(P,2)===`+=`?(a=`+=`,P+=2):(a=n,I===0&&z(Ze)),a===n?(P=t,t=n):(o=X(),o===n&&(o=null),s=U(),s===n?(P=t,t=n):(F=t,t=dr(r,s)))),t===n&&(t=P,r=zo(),r===n?(P=t,t=n):(i=X(),i===n&&(i=null),a=Oa(),a===n?(P=t,t=n):(F=t,t=fr(r,a)))))),L[c]={nextPos:P,result:t},t)}function ea(){let t,r,i,a,o,s,c,l,u,d,f,h=P*132+21,g=L[h];if(g)return P=g.nextPos,g.result;if(t=P,r=P,i=e.substr(P,6),i.toLowerCase()===p?P+=6:(i=n,I===0&&z(Qe)),i===n?(P=r,r=n):(a=X(),a===n?(P=r,r=n):r=i),r===n&&(r=null),i=e.substr(P,6),i.toLowerCase()===m?P+=6:(i=n,I===0&&z($e)),i!==n){for(a=X(),a===n&&(a=null),o=P,s=[],c=U();c!==n;)s.push(c),c=P,l=P,u=X(),u===n&&(u=null),e.charCodeAt(P)===44?(d=`,`,P++):(d=n,I===0&&z(Ye)),d===n?(P=l,l=n):(f=X(),f===n&&(f=null),u=[u,d,f],l=u),l===n?c=l:(l=U(),l===n?(P=c,c=n):c=l);s.length<1?(P=o,o=n):o=s,o===n?(P=t,t=n):(F=t,t=pr(r,o))}else P=t,t=n;return L[h]={nextPos:P,result:t},t}function ta(){let t,r,i,a,o,s,c,l,u,d,f=P*132+22,p=L[f];if(p)return P=p.nextPos,p.result;if(t=P,r=e.substr(P,6),r.toLowerCase()===h?P+=6:(r=n,I===0&&z(et)),r!==n){if(i=X(),i!==n){for(a=P,o=[],s=na();s!==n;)o.push(s),s=P,c=P,l=X(),l===n&&(l=null),e.charCodeAt(P)===44?(u=`,`,P++):(u=n,I===0&&z(Ye)),u===n?(P=c,c=n):(d=X(),d===n&&(d=null),l=[l,u,d],c=l),c===n?s=c:(c=na(),c===n?(P=s,s=n):s=c);o.length<1?(P=a,a=n):a=o,a===n?(P=t,t=n):(F=t,t=mr(a))}else P=t,t=n}else P=t,t=n;return L[f]={nextPos:P,result:t},t}function na(){let e,t,r,i=P*132+23,a=L[i];return a?(P=a.nextPos,a.result):(e=P,t=zo(),t===n?(P=e,e=n):(r=Oa(),r===n?(P=e,e=n):(F=e,e=hr(t,r))),e===n&&(e=P,t=ja(),t!==n&&(F=e,t=gr(t)),e=t),L[i]={nextPos:P,result:e},e)}function ra(){let t,r,i,a,o,s,c,l,u,d=P*132+24,f=L[d];return f?(P=f.nextPos,f.result):(t=P,r=e.substr(P,4),r.toLowerCase()===g?P+=4:(r=n,I===0&&z(tt)),r===n?(P=t,t=n):(i=X(),i===n?(P=t,t=n):(a=mo(),a===n?(P=t,t=n):(o=P,s=X(),s===n&&(s=null),c=e.substr(P,5),c.toLowerCase()===_?P+=5:(c=n,I===0&&z(nt)),c===n?(P=o,o=n):(l=X(),l===n?(P=o,o=n):(u=sa(),u===n?(P=o,o=n):o=u)),o===n&&(o=null),F=t,t=_r(a,o)))),L[d]={nextPos:P,result:t},t)}function ia(){let t,r,i,a,o,s,c,l,u,d=P*132+25,f=L[d];return f?(P=f.nextPos,f.result):(t=P,r=e.substr(P,4),r.toLowerCase()===g?P+=4:(r=n,I===0&&z(tt)),r===n?(P=t,t=n):(i=X(),i===n?(P=t,t=n):(a=aa(),a===n?(P=t,t=n):(o=P,s=X(),s===n&&(s=null),c=e.substr(P,5),c.toLowerCase()===_?P+=5:(c=n,I===0&&z(nt)),c===n?(P=o,o=n):(l=X(),l===n?(P=o,o=n):(u=oa(),u===n?(P=o,o=n):(s=[s,c,l,u],o=s))),o===n&&(o=null),F=t,t=vr(a,o)))),L[d]={nextPos:P,result:t},t)}function aa(){let e,t=P*132+26,r=L[t];return r?(P=r.nextPos,r.result):(e=mo(),e===n&&(e=ho()),L[t]={nextPos:P,result:e},e)}function oa(){let t,r=P*132+27,i=L[r];return i?(P=i.nextPos,i.result):(e.charCodeAt(P)===42?(t=`*`,P++):(t=n,I===0&&z(rt)),t===n&&(t=sa()),L[r]={nextPos:P,result:t},t)}function sa(){let t,r,i,a,o,s,c,l,u=P*132+28,d=L[u];if(d)return P=d.nextPos,d.result;for(t=P,r=P,i=[],a=ca();a!==n;)i.push(a),a=P,o=P,s=X(),s===n&&(s=null),e.charCodeAt(P)===44?(c=`,`,P++):(c=n,I===0&&z(Ye)),c===n?(P=o,o=n):(l=X(),l===n&&(l=null),s=[s,c,l],o=s),o===n?a=o:(o=ca(),o===n?(P=a,a=n):a=o);return i.length<1?(P=r,r=n):r=i,r===n?(P=t,t=n):(i=P,a=X(),a===n&&(a=null),o=_a(),o===n?(P=i,i=n):i=o,i===n&&(i=null),r=[r,i],t=r),L[u]={nextPos:P,result:t},t}function ca(){let t,r,i,a,o,s,c=P*132+29,l=L[c];return l?(P=l.nextPos,l.result):(t=P,r=P,i=zo(),i===n?(P=r,r=n):(a=X(),a===n?(P=r,r=n):(o=e.substr(P,2),o.toLowerCase()===`as`?P+=2:(o=n,I===0&&z(We)),o===n?(P=r,r=n):(s=X(),s===n?(P=r,r=n):r=i))),r===n&&(r=null),i=zo(),i===n?(P=t,t=n):(r=[r,i],t=r),L[c]={nextPos:P,result:t},t)}function la(){let t,r,i,a,o,s,c=P*132+30,l=L[c];return l?(P=l.nextPos,l.result):(t=P,r=e.substr(P,4),r.toLowerCase()===v?P+=4:(r=n,I===0&&z(it)),r===n?(P=t,t=n):(i=da(),i===n?(P=t,t=n):(a=P,o=X(),o===n&&(o=null),s=_a(),s===n?(P=a,a=n):a=s,a===n&&(a=null),F=t,t=yr(i,a))),L[c]={nextPos:P,result:t},t)}function ua(){let t,r,i,a=P*132+31,o=L[a];return o?(P=o.nextPos,o.result):(t=P,r=e.substr(P,6),r.toLowerCase()===y?P+=6:(r=n,I===0&&z(at)),r===n?(P=t,t=n):(i=da(),i===n?(P=t,t=n):(F=t,t=br(i))),L[a]={nextPos:P,result:t},t)}function da(){let t,r,i,a,o,s,c,l,u,d=P*132+32,f=L[d];return f?(P=f.nextPos,f.result):(t=P,r=P,i=X(),i===n&&(i=null),a=e.substr(P,8),a.toLowerCase()===b?P+=8:(a=n,I===0&&z(ot)),a===n?(P=r,r=n):r=a,r===n&&(r=null),i=X(),i===n?(P=t,t=n):(a=H(),a===n?(P=t,t=n):(o=P,s=X(),s===n?(P=o,o=n):(c=pa(),c===n?(P=o,o=n):o=c),o===n&&(o=null),s=P,c=X(),c===n?(P=s,s=n):(l=ma(),l===n?(P=s,s=n):s=l),s===n&&(s=null),c=P,l=X(),l===n?(P=c,c=n):(u=ha(),u===n?(P=c,c=n):c=u),c===n&&(c=null),F=t,t=xr(r,a,o,s,c))),L[d]={nextPos:P,result:t},t)}function H(){let t,r,i,a,o,s,c,l,u=P*132+33,d=L[u];if(d)return P=d.nextPos,d.result;if(t=P,e.charCodeAt(P)===42?(r=`*`,P++):(r=n,I===0&&z(rt)),r!==n){for(i=[],a=P,o=X(),o===n&&(o=null),e.charCodeAt(P)===44?(s=`,`,P++):(s=n,I===0&&z(Ye)),s===n?(P=a,a=n):(c=X(),c===n&&(c=null),l=fa(),l===n?(P=a,a=n):a=l);a!==n;)i.push(a),a=P,o=X(),o===n&&(o=null),e.charCodeAt(P)===44?(s=`,`,P++):(s=n,I===0&&z(Ye)),s===n?(P=a,a=n):(c=X(),c===n&&(c=null),l=fa(),l===n?(P=a,a=n):a=l);F=t,t=Sr(i)}else P=t,t=n;if(t===n){for(t=P,r=[],i=fa();i!==n;)r.push(i),i=P,a=P,o=X(),o===n&&(o=null),e.charCodeAt(P)===44?(s=`,`,P++):(s=n,I===0&&z(Ye)),s===n?(P=a,a=n):(c=X(),c===n&&(c=null),o=[o,s,c],a=o),a===n?i=a:(a=fa(),a===n?(P=i,i=n):i=a);r.length<1?(P=t,t=n):t=r}return L[u]={nextPos:P,result:t},t}function fa(){let t,r,i,a,o,s,c=P*132+34,l=L[c];return l?(P=l.nextPos,l.result):(t=P,r=U(),r===n?(P=t,t=n):(i=X(),i===n?(P=t,t=n):(a=e.substr(P,2),a.toLowerCase()===`as`?P+=2:(a=n,I===0&&z(We)),a===n?(P=t,t=n):(o=X(),o===n?(P=t,t=n):(s=zo(),s===n?(P=t,t=n):t=[r,s])))),t===n&&(t=U()),L[c]={nextPos:P,result:t},t)}function pa(){let t,r,i,a,o,s,c,l,u,d,f,p,m=P*132+35,h=L[m];if(h)return P=h.nextPos,h.result;if(t=P,r=e.substr(P,5),r.toLowerCase()===x?P+=5:(r=n,I===0&&z(st)),r!==n){if(i=X(),i!==n){if(a=e.substr(P,2),a.toLowerCase()===`by`?P+=2:(a=n,I===0&&z(ct)),a!==n){if(o=X(),o!==n){for(s=P,c=[],l=ga();l!==n;)c.push(l),l=P,u=P,d=X(),d===n&&(d=null),e.charCodeAt(P)===44?(f=`,`,P++):(f=n,I===0&&z(Ye)),f===n?(P=u,u=n):(p=X(),p===n&&(p=null),d=[d,f,p],u=d),u===n?l=u:(u=ga(),u===n?(P=l,l=n):l=u);c.length<1?(P=s,s=n):s=c,s===n?(P=t,t=n):t=s}else P=t,t=n}else P=t,t=n}else P=t,t=n}else P=t,t=n;return L[m]={nextPos:P,result:t},t}function ma(){let t,r,i,a,o=P*132+36,s=L[o];return s?(P=s.nextPos,s.result):(t=P,r=e.substr(P,4),r.toLowerCase()===S?P+=4:(r=n,I===0&&z(lt)),r===n?(P=t,t=n):(i=X(),i===n?(P=t,t=n):(a=U(),a===n?(P=t,t=n):t=a)),L[o]={nextPos:P,result:t},t)}function ha(){let t,r,i,a,o=P*132+37,s=L[o];return s?(P=s.nextPos,s.result):(t=P,r=e.substr(P,5),r.toLowerCase()===C?P+=5:(r=n,I===0&&z(ut)),r===n?(P=t,t=n):(i=X(),i===n?(P=t,t=n):(a=U(),a===n?(P=t,t=n):t=a)),L[o]={nextPos:P,result:t},t)}function ga(){let t,r,i,a,o,s=P*132+38,c=L[s];return c?(P=c.nextPos,c.result):(t=P,r=U(),r===n?(P=t,t=n):(i=P,a=X(),a===n&&(a=null),o=e.substr(P,9),o.toLowerCase()===w?P+=9:(o=n,I===0&&z(dt)),o===n&&(o=e.substr(P,3),o.toLowerCase()===`asc`?P+=3:(o=n,I===0&&z(ft)),o===n&&(o=e.substr(P,10),o.toLowerCase()===T?P+=10:(o=n,I===0&&z(pt)),o===n&&(o=e.substr(P,4),o.toLowerCase()===ee?P+=4:(o=n,I===0&&z(mt))))),o===n?(P=i,i=n):i=o,i===n&&(i=null),F=t,t=Cr(r,i)),L[s]={nextPos:P,result:t},t)}function _a(){let t,r,i,a,o=P*132+39,s=L[o];return s?(P=s.nextPos,s.result):(t=P,r=e.substr(P,5),r.toLowerCase()===te?P+=5:(r=n,I===0&&z(ht)),r===n?(P=t,t=n):(i=X(),i===n?(P=t,t=n):(a=U(),a===n?(P=t,t=n):t=a)),L[o]={nextPos:P,result:t},t)}function va(){let t,r,i,a,o,s,c,l=P*132+40,u=L[l];if(u)return P=u.nextPos,u.result;for(t=P,r=[],i=ya();i!==n;)r.push(i),i=P,a=P,o=X(),o===n&&(o=null),e.charCodeAt(P)===44?(s=`,`,P++):(s=n,I===0&&z(Ye)),s===n?(P=a,a=n):(c=X(),c===n&&(c=null),o=[o,s,c],a=o),a===n?i=a:(a=ya(),a===n?(P=i,i=n):i=a);return r.length<1?(P=t,t=n):t=r,L[l]={nextPos:P,result:t},t}function ya(){let t,r,i,a,o,s,c=P*132+41,l=L[c];return l?(P=l.nextPos,l.result):(t=P,r=zo(),r===n?(P=t,t=n):(i=X(),i===n&&(i=null),e.charCodeAt(P)===61?(a=`=`,P++):(a=n,I===0&&z(Xe)),a===n?(P=t,t=n):(o=X(),o===n&&(o=null),s=ba(),s===n?(P=t,t=n):(F=t,t=wr(r,s)))),t===n&&(t=ba()),L[c]={nextPos:P,result:t},t)}function ba(){let t,r,i,a,o,s,c=P*132+42,l=L[c];if(l)return P=l.nextPos,l.result;if(t=P,r=Sa(),r!==n){for(i=[],a=P,o=X(),o===n&&(o=null),s=Ca(),s===n?(P=a,a=n):a=s;a!==n;)i.push(a),a=P,o=X(),o===n&&(o=null),s=Ca(),s===n?(P=a,a=n):a=s;F=t,t=Tr(r,i)}else P=t,t=n;return t===n&&(t=P,e.charCodeAt(P)===40?(r=`(`,P++):(r=n,I===0&&z(gt)),r===n?(P=t,t=n):(i=ba(),i===n?(P=t,t=n):(e.charCodeAt(P)===41?(a=`)`,P++):(a=n,I===0&&z(_t)),a===n?(P=t,t=n):t=i))),L[c]={nextPos:P,result:t},t}function xa(){let e,t,r,i,a,o,s=P*132+43,c=L[s];if(c)return P=c.nextPos,c.result;if(e=P,t=Sa(),t!==n){if(r=[],i=P,a=X(),a===n&&(a=null),o=Ca(),o===n?(P=i,i=n):i=o,i!==n)for(;i!==n;)r.push(i),i=P,a=X(),a===n&&(a=null),o=Ca(),o===n?(P=i,i=n):i=o;else r=n;r===n?(P=e,e=n):e=[t,r]}else P=e,e=n;return L[s]={nextPos:P,result:e},e}function Sa(){let t,r,i,a,o,s,c,l,u=P*132+44,d=L[u];return d?(P=d.nextPos,d.result):(t=P,e.charCodeAt(P)===40?(r=`(`,P++):(r=n,I===0&&z(gt)),r===n?(P=t,t=n):(i=X(),i===n&&(i=null),a=P,o=zo(),o===n?(P=a,a=n):(s=X(),s===n&&(s=null),a=o),a===n&&(a=null),o=P,s=Oa(),s===n?(P=o,o=n):(c=X(),c===n&&(c=null),o=s),o===n&&(o=null),s=P,c=Ea(),c===n?(P=s,s=n):(l=X(),l===n&&(l=null),s=c),s===n&&(s=null),e.charCodeAt(P)===41?(c=`)`,P++):(c=n,I===0&&z(_t)),c===n?(P=t,t=n):(F=t,t=Er(a,o,s))),L[u]={nextPos:P,result:t},t)}function Ca(){let e,t,r,i,a=P*132+45,o=L[a];return o?(P=o.nextPos,o.result):(e=P,t=wa(),t===n?(P=e,e=n):(r=X(),r===n&&(r=null),i=Sa(),i===n?(P=e,e=n):e=[t,i]),L[a]={nextPos:P,result:e},e)}function wa(){let e,t,r,i,a,o,s,c,l=P*132+46,u=L[l];return u?(P=u.nextPos,u.result):(e=P,t=Ko(),t===n?(P=e,e=n):(r=X(),r===n&&(r=null),i=Jo(),i===n?(P=e,e=n):(a=X(),a===n&&(a=null),o=Ta(),o===n&&(o=null),s=X(),s===n&&(s=null),c=Jo(),c===n?(P=e,e=n):(F=e,e=Dr(o)))),e===n&&(e=P,t=Jo(),t===n?(P=e,e=n):(r=X(),r===n&&(r=null),i=Ta(),i===n&&(i=null),a=X(),a===n&&(a=null),o=Jo(),o===n?(P=e,e=n):(s=X(),s===n&&(s=null),c=qo(),c===n?(P=e,e=n):(F=e,e=Or(i)))),e===n&&(e=P,t=Jo(),t===n?(P=e,e=n):(r=X(),r===n&&(r=null),i=Ta(),i===n&&(i=null),a=X(),a===n&&(a=null),o=Jo(),o===n?(P=e,e=n):(F=e,e=kr(i))))),L[l]={nextPos:P,result:e},e)}function Ta(){let t,r,i,a,o,s,c,l,u,d=P*132+47,f=L[d];return f?(P=f.nextPos,f.result):(t=P,e.charCodeAt(P)===91?(r=`[`,P++):(r=n,I===0&&z(vt)),r===n?(P=t,t=n):(i=X(),i===n&&(i=null),a=P,o=zo(),o===n?(P=a,a=n):(s=X(),s===n&&(s=null),a=o),a===n&&(a=null),o=P,s=Da(),s===n?(P=o,o=n):(c=X(),c===n&&(c=null),o=s),o===n&&(o=null),s=Aa(),s===n&&(s=null),c=P,l=Ea(),l===n?(P=c,c=n):(u=X(),u===n&&(u=null),c=l),c===n&&(c=null),e.charCodeAt(P)===93?(l=`]`,P++):(l=n,I===0&&z(yt)),l===n?(P=t,t=n):(F=t,t=Ar(a,o,s,c))),L[d]={nextPos:P,result:t},t)}function Ea(){let e,t=P*132+48,r=L[t];return r?(P=r.nextPos,r.result):(e=Fo(),e===n&&(e=Io()),L[t]={nextPos:P,result:e},e)}function Da(){let t,r,i,a,o,s,c,l=P*132+49,u=L[l];if(u)return P=u.nextPos,u.result;for(t=P,r=[],i=P,e.charCodeAt(P)===58?(a=`:`,P++):(a=n,I===0&&z(bt)),a===n?(P=i,i=n):(o=X(),o===n&&(o=null),s=Lo(),s===n?(P=i,i=n):i=s);i!==n;)r.push(i),i=P,a=P,o=X(),o===n&&(o=null),e.charCodeAt(P)===124?(s=`|`,P++):(s=n,I===0&&z(xt)),s===n?(P=a,a=n):(c=X(),c===n&&(c=null),o=[o,s,c],a=o),a===n?i=a:(a=P,e.charCodeAt(P)===58?(o=`:`,P++):(o=n,I===0&&z(bt)),o===n?(P=a,a=n):(s=X(),s===n&&(s=null),c=Lo(),c===n?(P=a,a=n):a=c),a===n?(P=i,i=n):i=a);return r.length<1?(P=t,t=n):t=r,L[l]={nextPos:P,result:t},t}function Oa(){let e,t,r,i,a=P*132+50,o=L[a];if(o)return P=o.nextPos,o.result;for(e=P,t=[],r=ka();r!==n;)t.push(r),r=P,i=X(),i===n&&(i=null),i=ka(),i===n?(P=r,r=n):r=i;return t.length<1?(P=e,e=n):e=t,L[a]={nextPos:P,result:e},e}function ka(){let t,r,i,a,o=P*132+51,s=L[o];return s?(P=s.nextPos,s.result):(t=P,e.charCodeAt(P)===58?(r=`:`,P++):(r=n,I===0&&z(bt)),r===n?(P=t,t=n):(i=X(),i===n&&(i=null),a=Lo(),a===n?(P=t,t=n):t=a),L[o]={nextPos:P,result:t},t)}function Aa(){let t,r,i,a,o,s,c,l,u,d,f=P*132+52,p=L[f];return p?(P=p.nextPos,p.result):(t=P,e.charCodeAt(P)===42?(r=`*`,P++):(r=n,I===0&&z(rt)),r===n?(P=t,t=n):(i=X(),i===n&&(i=null),a=P,o=P,s=bo(),o=s===n?s:e.substring(o,P),o===n?(P=a,a=n):(s=X(),s===n&&(s=null),a=o),a===n&&(a=null),o=P,e.substr(P,2)===`..`?(s=`..`,P+=2):(s=n,I===0&&z(St)),s===n?(P=o,o=n):(c=X(),c===n&&(c=null),l=P,u=P,d=bo(),u=d===n?d:e.substring(u,P),u===n?(P=l,l=n):(d=X(),d===n&&(d=null),l=u),l===n&&(l=null),o=[s,l]),o===n&&(o=null),F=t,t=jr(a,o)),L[f]={nextPos:P,result:t},t)}function ja(){let e,t,r,i,a,o,s=P*132+53,c=L[s];if(c)return P=c.nextPos,c.result;if(e=P,t=to(),t!==n){if(r=[],i=P,a=X(),a===n&&(a=null),o=eo(),o===n?(P=i,i=n):i=o,i!==n)for(;i!==n;)r.push(i),i=P,a=X(),a===n&&(a=null),o=eo(),o===n?(P=i,i=n):i=o;else r=n;r===n?(P=e,e=n):(F=e,e=Mr(t,r))}else P=e,e=n;return L[s]={nextPos:P,result:e},e}function U(){let t,r,i,a,o,s,c,l,u=P*132+54,d=L[u];if(d)return P=d.nextPos,d.result;if(t=P,r=Ma(),r!==n){for(i=[],a=P,o=X(),o===n?(P=a,a=n):(s=e.substr(P,2),s.toLowerCase()===`or`?P+=2:(s=n,I===0&&z(Ct)),s===n?(P=a,a=n):(c=X(),c===n?(P=a,a=n):(l=Ma(),l===n?(P=a,a=n):a=l)));a!==n;)i.push(a),a=P,o=X(),o===n?(P=a,a=n):(s=e.substr(P,2),s.toLowerCase()===`or`?P+=2:(s=n,I===0&&z(Ct)),s===n?(P=a,a=n):(c=X(),c===n?(P=a,a=n):(l=Ma(),l===n?(P=a,a=n):a=l)));F=t,t=Nr(r,i)}else P=t,t=n;return L[u]={nextPos:P,result:t},t}function Ma(){let t,r,i,a,o,s,c,l,u=P*132+55,d=L[u];if(d)return P=d.nextPos,d.result;if(t=P,r=Na(),r!==n){for(i=[],a=P,o=X(),o===n?(P=a,a=n):(s=e.substr(P,3),s.toLowerCase()===`xor`?P+=3:(s=n,I===0&&z(wt)),s===n?(P=a,a=n):(c=X(),c===n?(P=a,a=n):(l=Na(),l===n?(P=a,a=n):a=l)));a!==n;)i.push(a),a=P,o=X(),o===n?(P=a,a=n):(s=e.substr(P,3),s.toLowerCase()===`xor`?P+=3:(s=n,I===0&&z(wt)),s===n?(P=a,a=n):(c=X(),c===n?(P=a,a=n):(l=Na(),l===n?(P=a,a=n):a=l)));F=t,t=Pr(r,i)}else P=t,t=n;return L[u]={nextPos:P,result:t},t}function Na(){let t,r,i,a,o,s,c,l,u=P*132+56,d=L[u];if(d)return P=d.nextPos,d.result;if(t=P,r=Pa(),r!==n){for(i=[],a=P,o=X(),o===n?(P=a,a=n):(s=e.substr(P,3),s.toLowerCase()===`and`?P+=3:(s=n,I===0&&z(Tt)),s===n?(P=a,a=n):(c=X(),c===n?(P=a,a=n):(l=Pa(),l===n?(P=a,a=n):a=l)));a!==n;)i.push(a),a=P,o=X(),o===n?(P=a,a=n):(s=e.substr(P,3),s.toLowerCase()===`and`?P+=3:(s=n,I===0&&z(Tt)),s===n?(P=a,a=n):(c=X(),c===n?(P=a,a=n):(l=Pa(),l===n?(P=a,a=n):a=l)));F=t,t=Fr(r,i)}else P=t,t=n;return L[u]={nextPos:P,result:t},t}function Pa(){let t,r,i,a,o,s=P*132+57,c=L[s];if(c)return P=c.nextPos,c.result;for(t=P,r=[],i=P,a=e.substr(P,3),a.toLowerCase()===`not`?P+=3:(a=n,I===0&&z(Et)),a===n?(P=i,i=n):(o=X(),o===n&&(o=null),i=a);i!==n;)r.push(i),i=P,a=e.substr(P,3),a.toLowerCase()===`not`?P+=3:(a=n,I===0&&z(Et)),a===n?(P=i,i=n):(o=X(),o===n&&(o=null),i=a);return i=Fa(),i===n?(P=t,t=n):(F=t,t=Ir(r,i)),L[s]={nextPos:P,result:t},t}function Fa(){let e,t,r,i,a,o,s=P*132+58,c=L[s];if(c)return P=c.nextPos,c.result;if(e=P,t=Ra(),t!==n){for(r=[],i=P,a=X(),a===n&&(a=null),o=Ia(),o===n?(P=i,i=n):i=o;i!==n;)r.push(i),i=P,a=X(),a===n&&(a=null),o=Ia(),o===n?(P=i,i=n):i=o;F=e,e=Lr(t,r)}else P=e,e=n;return L[s]={nextPos:P,result:e},e}function Ia(){let e,t,r,i,a=P*132+59,o=L[a];return o?(P=o.nextPos,o.result):(e=P,t=La(),t===n?(P=e,e=n):(r=X(),r===n&&(r=null),i=Ra(),i===n?(P=e,e=n):e=[t,i]),L[a]={nextPos:P,result:e},e)}function La(){let t,r=P*132+60,i=L[r];return i?(P=i.nextPos,i.result):(e.charCodeAt(P)===61?(t=`=`,P++):(t=n,I===0&&z(Xe)),t===n&&(e.substr(P,2)===`<>`?(t=`<>`,P+=2):(t=n,I===0&&z(Dt)),t===n&&(e.substr(P,2)===`<=`?(t=`<=`,P+=2):(t=n,I===0&&z(Ot)),t===n&&(e.substr(P,2)===`>=`?(t=`>=`,P+=2):(t=n,I===0&&z(kt)),t===n&&(t=e.charAt(P),he.test(t)?P++:(t=n,I===0&&z(At)))))),L[r]={nextPos:P,result:t},t)}function Ra(){let e,t,r,i,a=P*132+61,o=L[a];if(o)return P=o.nextPos,o.result;if(e=P,t=Wa(),t!==n){for(r=[],i=za();i!==n;)r.push(i),i=za();F=e,e=Rr(t,r)}else P=e,e=n;return L[a]={nextPos:P,result:e},e}function za(){let e,t=P*132+62,r=L[t];return r?(P=r.nextPos,r.result):(e=Ba(),e===n&&(e=Ha(),e===n&&(e=Ua())),L[t]={nextPos:P,result:e},e)}function Ba(){let e,t,r,i,a=P*132+63,o=L[a];return o?(P=o.nextPos,o.result):(e=P,t=Va(),t===n?(P=e,e=n):(r=X(),r===n&&(r=null),i=Wa(),i===n?(P=e,e=n):e=[t,i]),L[a]={nextPos:P,result:e},e)}function Va(){let t,r,i,a,o,s=P*132+64,c=L[s];return c?(P=c.nextPos,c.result):(t=P,r=X(),r===n?(P=t,t=n):(i=e.substr(P,6),i.toLowerCase()===ne?P+=6:(i=n,I===0&&z(jt)),i===n?(P=t,t=n):(a=X(),a===n?(P=t,t=n):(o=e.substr(P,4),o.toLowerCase()===v?P+=4:(o=n,I===0&&z(it)),o===n?(P=t,t=n):(F=t,t=zr())))),t===n&&(t=P,r=X(),r===n?(P=t,t=n):(i=e.substr(P,4),i.toLowerCase()===re?P+=4:(i=n,I===0&&z(Mt)),i===n?(P=t,t=n):(a=X(),a===n?(P=t,t=n):(o=e.substr(P,4),o.toLowerCase()===v?P+=4:(o=n,I===0&&z(it)),o===n?(P=t,t=n):(F=t,t=Br())))),t===n&&(t=P,r=X(),r===n?(P=t,t=n):(i=e.substr(P,8),i.toLowerCase()===ie?P+=8:(i=n,I===0&&z(Nt)),i===n?(P=t,t=n):t=i))),L[s]={nextPos:P,result:t},t)}function Ha(){let t,r,i,a,o,s=P*132+65,c=L[s];return c?(P=c.nextPos,c.result):(t=P,r=X(),r===n?(P=t,t=n):(i=e.substr(P,2),i.toLowerCase()===`in`?P+=2:(i=n,I===0&&z(Pt)),i===n?(P=t,t=n):(a=X(),a===n&&(a=null),o=Wa(),o===n?(P=t,t=n):t=[i,o])),L[s]={nextPos:P,result:t},t)}function Ua(){let t,r,i,a,o,s,c,l=P*132+66,u=L[l];return u?(P=u.nextPos,u.result):(t=P,r=X(),r===n?(P=t,t=n):(i=e.substr(P,2),i.toLowerCase()===`is`?P+=2:(i=n,I===0&&z(Ft)),i===n?(P=t,t=n):(a=X(),a===n?(P=t,t=n):(o=e.substr(P,4),o.toLowerCase()===ae?P+=4:(o=n,I===0&&z(It)),o===n?(P=t,t=n):(F=t,t=Vr())))),t===n&&(t=P,r=X(),r===n?(P=t,t=n):(i=e.substr(P,2),i.toLowerCase()===`is`?P+=2:(i=n,I===0&&z(Ft)),i===n?(P=t,t=n):(a=X(),a===n?(P=t,t=n):(o=e.substr(P,3),o.toLowerCase()===`not`?P+=3:(o=n,I===0&&z(Et)),o===n?(P=t,t=n):(s=X(),s===n?(P=t,t=n):(c=e.substr(P,4),c.toLowerCase()===ae?P+=4:(c=n,I===0&&z(It)),c===n?(P=t,t=n):(F=t,t=Hr()))))))),L[l]={nextPos:P,result:t},t)}function Wa(){let e,t,r,i,a,o,s,c,l=P*132+67,u=L[l];if(u)return P=u.nextPos,u.result;if(e=P,t=Ka(),t!==n){for(r=[],i=P,a=X(),a===n&&(a=null),o=Ga(),o===n?(P=i,i=n):(s=X(),s===n&&(s=null),c=Ka(),c===n?(P=i,i=n):i=[o,c]);i!==n;)r.push(i),i=P,a=X(),a===n&&(a=null),o=Ga(),o===n?(P=i,i=n):(s=X(),s===n&&(s=null),c=Ka(),c===n?(P=i,i=n):i=[o,c]);F=e,e=Ur(t,r)}else P=e,e=n;return L[l]={nextPos:P,result:e},e}function Ga(){let t,r=P*132+68,i=L[r];return i?(P=i.nextPos,i.result):(t=e.charAt(P),ge.test(t)?P++:(t=n,I===0&&z(Lt)),L[r]={nextPos:P,result:t},t)}function Ka(){let e,t,r,i,a,o,s,c,l=P*132+69,u=L[l];if(u)return P=u.nextPos,u.result;if(e=P,t=Ja(),t!==n){for(r=[],i=P,a=X(),a===n&&(a=null),o=qa(),o===n?(P=i,i=n):(s=X(),s===n&&(s=null),c=Ja(),c===n?(P=i,i=n):i=[o,c]);i!==n;)r.push(i),i=P,a=X(),a===n&&(a=null),o=qa(),o===n?(P=i,i=n):(s=X(),s===n&&(s=null),c=Ja(),c===n?(P=i,i=n):i=[o,c]);F=e,e=Wr(t,r)}else P=e,e=n;return L[l]={nextPos:P,result:e},e}function qa(){let t,r=P*132+70,i=L[r];return i?(P=i.nextPos,i.result):(t=e.charAt(P),_e.test(t)?P++:(t=n,I===0&&z(Rt)),L[r]={nextPos:P,result:t},t)}function Ja(){let t,r,i,a,o,s,c,l,u=P*132+71,d=L[u];if(d)return P=d.nextPos,d.result;if(t=P,r=Ya(),r!==n){for(i=[],a=P,o=X(),o===n&&(o=null),e.charCodeAt(P)===94?(s=`^`,P++):(s=n,I===0&&z(zt)),s===n?(P=a,a=n):(c=X(),c===n&&(c=null),l=Ya(),l===n?(P=a,a=n):a=l);a!==n;)i.push(a),a=P,o=X(),o===n&&(o=null),e.charCodeAt(P)===94?(s=`^`,P++):(s=n,I===0&&z(zt)),s===n?(P=a,a=n):(c=X(),c===n&&(c=null),l=Ya(),l===n?(P=a,a=n):a=l);F=t,t=Gr(r,i)}else P=t,t=n;return L[u]={nextPos:P,result:t},t}function Ya(){let e,t,r,i,a=P*132+72,o=L[a];return o?(P=o.nextPos,o.result):(e=Xa(),e===n&&(e=P,t=Ga(),t===n?(P=e,e=n):(r=X(),r===n&&(r=null),i=Xa(),i===n?(P=e,e=n):(F=e,e=Kr(t,i)))),L[a]={nextPos:P,result:e},e)}function Xa(){let e,t,r,i,a,o=P*132+73,s=L[o];return s?(P=s.nextPos,s.result):(e=P,t=Qa(),t===n?(P=e,e=n):(r=P,i=X(),i===n&&(i=null),a=Oa(),a===n?(P=r,r=n):r=a,r===n&&(r=null),F=e,e=qr(t,r)),L[o]={nextPos:P,result:e},e)}function Za(){let e,t=P*132+74,r=L[t];return r?(P=r.nextPos,r.result):(e=$a(),e===n&&(e=eo()),L[t]={nextPos:P,result:e},e)}function Qa(){let e,t,r,i,a,o,s=P*132+75,c=L[s];if(c)return P=c.nextPos,c.result;if(e=P,t=to(),t!==n){for(r=[],i=P,a=X(),a===n&&(a=null),o=Za(),o===n?(P=i,i=n):i=o;i!==n;)r.push(i),i=P,a=X(),a===n&&(a=null),o=Za(),o===n?(P=i,i=n):i=o;F=e,e=Jr(t,r)}else P=e,e=n;return L[s]={nextPos:P,result:e},e}function $a(){let t,r,i,a,o,s,c=P*132+76,l=L[c];return l?(P=l.nextPos,l.result):(t=P,e.charCodeAt(P)===91?(r=`[`,P++):(r=n,I===0&&z(vt)),r===n?(P=t,t=n):(i=U(),i===n?(P=t,t=n):(e.charCodeAt(P)===93?(a=`]`,P++):(a=n,I===0&&z(yt)),a===n?(P=t,t=n):(F=t,t=Yr(i)))),t===n&&(t=P,e.charCodeAt(P)===91?(r=`[`,P++):(r=n,I===0&&z(vt)),r===n?(P=t,t=n):(i=U(),i===n&&(i=null),e.substr(P,2)===`..`?(a=`..`,P+=2):(a=n,I===0&&z(St)),a===n?(P=t,t=n):(o=U(),o===n&&(o=null),e.charCodeAt(P)===93?(s=`]`,P++):(s=n,I===0&&z(yt)),s===n?(P=t,t=n):t=[i,o]))),L[c]={nextPos:P,result:t},t)}function eo(){let t,r,i,a,o=P*132+77,s=L[o];return s?(P=s.nextPos,s.result):(t=P,e.charCodeAt(P)===46?(r=`.`,P++):(r=n,I===0&&z(Bt)),r===n?(P=t,t=n):(i=X(),i===n&&(i=null),a=Lo(),a===n?(P=t,t=n):t=a),L[o]={nextPos:P,result:t},t)}function to(){let t,r,i,a,o,s,c,l,u=P*132+78,d=L[u];return d?(P=d.nextPos,d.result):(t=q(),t===n&&(t=no(),t===n&&(t=Io(),t===n&&(t=ro(),t===n&&(t=P,r=e.substr(P,5),r.toLowerCase()===oe?P+=5:(r=n,I===0&&z(Vt)),r===n?(P=t,t=n):(i=X(),i===n&&(i=null),e.charCodeAt(P)===40?(a=`(`,P++):(a=n,I===0&&z(gt)),a===n?(P=t,t=n):(o=X(),o===n&&(o=null),e.charCodeAt(P)===42?(s=`*`,P++):(s=n,I===0&&z(rt)),s===n?(P=t,t=n):(c=X(),c===n&&(c=null),e.charCodeAt(P)===41?(l=`)`,P++):(l=n,I===0&&z(_t)),l===n?(P=t,t=n):(F=t,t=Xr())))),t===n&&(t=io(),t===n&&(t=G(),t===n&&(t=ao(),t===n&&(t=co(),t===n&&(t=lo(),t===n&&(t=uo(),t===n&&(t=po(),t===n&&(t=zo())))))))))))),L[u]={nextPos:P,result:t},t)}function no(){let t,r,i,a,s,c,l=P*132+79,u=L[l];if(u)return P=u.nextPos,u.result;if(t=P,r=e.substr(P,4),r.toLowerCase()===o?P+=4:(r=n,I===0&&z(Ht)),r!==n){if(i=X(),i!==n){if(a=P,s=[],c=e.charAt(P),ve.test(c)?P++:(c=n,I===0&&z(Ut)),c!==n)for(;c!==n;)s.push(c),c=e.charAt(P),ve.test(c)?P++:(c=n,I===0&&z(Ut));else s=n;a=s===n?s:e.substring(a,P),a===n?(P=t,t=n):(F=t,t=Zr(a))}else P=t,t=n}else P=t,t=n;return L[l]={nextPos:P,result:t},t}function ro(){let t,r,i,a,o,s,c,l,u,d,f=P*132+80,p=L[f];if(p)return P=p.nextPos,p.result;if(t=P,r=e.substr(P,4),r.toLowerCase()===se?P+=4:(r=n,I===0&&z(Wt)),r!==n){if(i=[],a=P,o=X(),o===n&&(o=null),s=W(),s===n?(P=a,a=n):a=s,a!==n)for(;a!==n;)i.push(a),a=P,o=X(),o===n&&(o=null),s=W(),s===n?(P=a,a=n):a=s;else i=n;i===n?(P=t,t=n):(a=P,o=X(),o===n&&(o=null),s=e.substr(P,4),s.toLowerCase()===ce?P+=4:(s=n,I===0&&z(Gt)),s===n?(P=a,a=n):(c=X(),c===n&&(c=null),l=U(),l===n?(P=a,a=n):a=l),a===n&&(a=null),o=X(),o===n&&(o=null),s=e.substr(P,3),s.toLowerCase()===`end`?P+=3:(s=n,I===0&&z(Kt)),s===n?(P=t,t=n):(F=t,t=Qr(i,a)))}else P=t,t=n;if(t===n){if(t=P,r=e.substr(P,4),r.toLowerCase()===se?P+=4:(r=n,I===0&&z(Wt)),r!==n){if(i=X(),i===n&&(i=null),a=U(),a!==n){if(o=[],s=P,c=X(),c===n&&(c=null),l=W(),l===n?(P=s,s=n):s=l,s!==n)for(;s!==n;)o.push(s),s=P,c=X(),c===n&&(c=null),l=W(),l===n?(P=s,s=n):s=l;else o=n;o===n?(P=t,t=n):(s=P,c=X(),c===n&&(c=null),l=e.substr(P,4),l.toLowerCase()===ce?P+=4:(l=n,I===0&&z(Gt)),l===n?(P=s,s=n):(u=X(),u===n&&(u=null),d=U(),d===n?(P=s,s=n):s=d),s===n&&(s=null),c=X(),c===n&&(c=null),l=e.substr(P,3),l.toLowerCase()===`end`?P+=3:(l=n,I===0&&z(Kt)),l===n?(P=t,t=n):(F=t,t=$r(a,o,s)))}else P=t,t=n}else P=t,t=n}return L[f]={nextPos:P,result:t},t}function W(){let t,r,i,a,o,s,c,l,u=P*132+81,d=L[u];return d?(P=d.nextPos,d.result):(t=P,r=e.substr(P,4),r.toLowerCase()===le?P+=4:(r=n,I===0&&z(j)),r===n?(P=t,t=n):(i=X(),i===n&&(i=null),a=U(),a===n?(P=t,t=n):(o=X(),o===n&&(o=null),s=e.substr(P,4),s.toLowerCase()===E?P+=4:(s=n,I===0&&z(qt)),s===n?(P=t,t=n):(c=X(),c===n&&(c=null),l=U(),l===n?(P=t,t=n):t=[a,l]))),L[u]={nextPos:P,result:t},t)}function io(){let t,r,i,a,o,s,c,l,u,d=P*132+82,f=L[d];return f?(P=f.nextPos,f.result):(t=P,e.charCodeAt(P)===91?(r=`[`,P++):(r=n,I===0&&z(vt)),r===n?(P=t,t=n):(i=X(),i===n&&(i=null),a=so(),a===n?(P=t,t=n):(o=P,s=X(),s===n&&(s=null),e.charCodeAt(P)===124?(c=`|`,P++):(c=n,I===0&&z(xt)),c===n?(P=o,o=n):(l=X(),l===n&&(l=null),u=U(),u===n?(P=o,o=n):o=u),o===n&&(o=null),s=X(),s===n&&(s=null),e.charCodeAt(P)===93?(c=`]`,P++):(c=n,I===0&&z(yt)),c===n?(P=t,t=n):(F=t,t=ei(a,o)))),L[d]={nextPos:P,result:t},t)}function G(){let t,r,i,a,o,s,c,l,u,d,f,p,m=P*132+83,h=L[m];return h?(P=h.nextPos,h.result):(t=P,e.charCodeAt(P)===91?(r=`[`,P++):(r=n,I===0&&z(vt)),r===n?(P=t,t=n):(i=X(),i===n&&(i=null),a=P,o=zo(),o===n?(P=a,a=n):(s=X(),s===n&&(s=null),e.charCodeAt(P)===61?(c=`=`,P++):(c=n,I===0&&z(Xe)),c===n?(P=a,a=n):(l=X(),l===n&&(l=null),a=o)),a===n&&(a=null),o=xa(),o===n?(P=t,t=n):(s=X(),s===n&&(s=null),c=P,l=_a(),l===n?(P=c,c=n):(u=X(),u===n&&(u=null),c=l),c===n&&(c=null),e.charCodeAt(P)===124?(l=`|`,P++):(l=n,I===0&&z(xt)),l===n?(P=t,t=n):(u=X(),u===n&&(u=null),d=U(),d===n?(P=t,t=n):(f=X(),f===n&&(f=null),e.charCodeAt(P)===93?(p=`]`,P++):(p=n,I===0&&z(yt)),p===n?(P=t,t=n):(F=t,t=ti(a,o,c,d)))))),L[m]={nextPos:P,result:t},t)}function ao(){let t,r,i,a,o,s,c,l,u=P*132+84,d=L[u];return d?(P=d.nextPos,d.result):(t=P,r=oo(),r===n?(P=t,t=n):(i=X(),i===n&&(i=null),e.charCodeAt(P)===40?(a=`(`,P++):(a=n,I===0&&z(gt)),a===n?(P=t,t=n):(o=X(),o===n&&(o=null),s=so(),s===n?(P=t,t=n):(c=X(),c===n&&(c=null),e.charCodeAt(P)===41?(l=`)`,P++):(l=n,I===0&&z(_t)),l===n?(P=t,t=n):(F=t,t=ni(r,s))))),L[u]={nextPos:P,result:t},t)}function oo(){let t,r=P*132+85,i=L[r];return i?(P=i.nextPos,i.result):(t=e.substr(P,3),t.toLowerCase()===`all`?P+=3:(t=n,I===0&&z(Be)),t===n&&(t=e.substr(P,3),t.toLowerCase()===`any`?P+=3:(t=n,I===0&&z(Jt)),t===n&&(t=e.substr(P,4),t.toLowerCase()===ue?P+=4:(t=n,I===0&&z(Yt)),t===n&&(t=e.substr(P,6),t.toLowerCase()===de?P+=6:(t=n,I===0&&z(Xt))))),L[r]={nextPos:P,result:t},t)}function so(){let e,t,r,i,a,o=P*132+86,s=L[o];return s?(P=s.nextPos,s.result):(e=P,t=K(),t===n?(P=e,e=n):(r=P,i=X(),i===n&&(i=null),a=_a(),a===n?(P=r,r=n):r=a,r===n&&(r=null),F=e,e=ri(t,r)),L[o]={nextPos:P,result:e},e)}function co(){let e,t,r=P*132+87,i=L[r];return i?(P=i.nextPos,i.result):(e=P,t=xa(),t!==n&&(F=e,t=ii(t)),e=t,L[r]={nextPos:P,result:e},e)}function lo(){let t,r,i,a,o,s,c=P*132+88,l=L[c];return l?(P=l.nextPos,l.result):(t=P,e.charCodeAt(P)===40?(r=`(`,P++):(r=n,I===0&&z(gt)),r===n?(P=t,t=n):(i=X(),i===n&&(i=null),a=U(),a===n?(P=t,t=n):(o=X(),o===n&&(o=null),e.charCodeAt(P)===41?(s=`)`,P++):(s=n,I===0&&z(_t)),s===n?(P=t,t=n):t=a)),L[c]={nextPos:P,result:t},t)}function K(){let t,r,i,a,o,s,c=P*132+89,l=L[c];return l?(P=l.nextPos,l.result):(t=P,r=zo(),r===n?(P=t,t=n):(i=X(),i===n?(P=t,t=n):(a=e.substr(P,2),a.toLowerCase()===`in`?P+=2:(a=n,I===0&&z(Pt)),a===n?(P=t,t=n):(o=X(),o===n?(P=t,t=n):(s=U(),s===n?(P=t,t=n):t=[r,s])))),L[c]={nextPos:P,result:t},t)}function uo(){let t,r,i,a,o,s,c,l,u,d,f,p,m,h,g=P*132+90,_=L[g];if(_)return P=_.nextPos,_.result;if(t=P,r=fo(),r!==n){if(i=X(),i===n&&(i=null),e.charCodeAt(P)===40?(a=`(`,P++):(a=n,I===0&&z(gt)),a!==n){for(o=X(),o===n&&(o=null),s=P,c=e.substr(P,8),c.toLowerCase()===b?P+=8:(c=n,I===0&&z(ot)),c===n?(P=s,s=n):(l=X(),l===n&&(l=null),s=c),s===n&&(s=null),c=P,l=P,u=[],d=U();d!==n;)u.push(d),d=P,f=P,p=X(),p===n&&(p=null),e.charCodeAt(P)===44?(m=`,`,P++):(m=n,I===0&&z(Ye)),m===n?(P=f,f=n):(h=X(),h===n&&(h=null),p=[p,m,h],f=p),f===n?d=f:(f=U(),f===n?(P=d,d=n):d=f);u.length<1?(P=l,l=n):l=u,l===n?(P=c,c=n):(u=X(),u===n&&(u=null),c=l),c===n&&(c=null),e.charCodeAt(P)===41?(l=`)`,P++):(l=n,I===0&&z(_t)),l===n?(P=t,t=n):(F=t,t=ai(r,s,c))}else P=t,t=n}else P=t,t=n;return L[g]={nextPos:P,result:t},t}function fo(){let e,t,r=P*132+91,i=L[r];return i?(P=i.nextPos,i.result):(e=P,_o(),t=zo(),t===n?(P=e,e=n):(F=e,e=oi()),L[r]={nextPos:P,result:e},e)}function po(){let t,r,i,a,o,s,c,l,u,d=P*132+92,f=L[d];return f?(P=f.nextPos,f.result):(t=P,r=e.substr(P,6),r.toLowerCase()===D?P+=6:(r=n,I===0&&z(Zt)),r===n?(P=t,t=n):(i=X(),i===n&&(i=null),e.charCodeAt(P)===123?(a=`{`,P++):(a=n,I===0&&z(Qt)),a===n?(P=t,t=n):(o=X(),o===n&&(o=null),s=zi(),s===n?(P=t,t=n):(c=X(),c===n&&(c=null),e.charCodeAt(P)===125?(l=`}`,P++):(l=n,I===0&&z($t)),l===n?(P=t,t=n):(F=t,t=si(s))))),t===n&&(t=P,r=e.substr(P,6),r.toLowerCase()===D?P+=6:(r=n,I===0&&z(Zt)),r===n?(P=t,t=n):(i=X(),i===n&&(i=null),e.charCodeAt(P)===123?(a=`{`,P++):(a=n,I===0&&z(Qt)),a===n?(P=t,t=n):(o=X(),o===n&&(o=null),s=va(),s===n?(P=t,t=n):(c=P,l=X(),l===n&&(l=null),u=_a(),u===n?(P=c,c=n):c=u,c===n&&(c=null),l=X(),l===n&&(l=null),e.charCodeAt(P)===125?(u=`}`,P++):(u=n,I===0&&z($t)),u===n?(P=t,t=n):(F=t,t=ci(s,c))))),t===n&&(t=P,r=e.substr(P,6),r.toLowerCase()===D?P+=6:(r=n,I===0&&z(Zt)),r===n?(P=t,t=n):(i=X(),i===n&&(i=null),e.charCodeAt(P)===123?(a=`{`,P++):(a=n,I===0&&z(Qt)),a===n?(P=t,t=n):(o=X(),o===n&&(o=null),s=no(),s===n?(P=t,t=n):(c=X(),c===n&&(c=null),e.charCodeAt(P)===125?(l=`}`,P++):(l=n,I===0&&z($t)),l===n?(P=t,t=n):(F=t,t=li(s))))))),L[d]={nextPos:P,result:t},t)}function mo(){let t,r,i,a,o,s,c,l,u,d,f,p,m,h=P*132+93,g=L[h];if(g)return P=g.nextPos,g.result;if(t=P,r=go(),r!==n){if(i=X(),i===n&&(i=null),e.charCodeAt(P)===40?(a=`(`,P++):(a=n,I===0&&z(gt)),a!==n){for(o=X(),o===n&&(o=null),s=P,c=P,l=[],u=U();u!==n;)l.push(u),u=P,d=P,f=X(),f===n&&(f=null),e.charCodeAt(P)===44?(p=`,`,P++):(p=n,I===0&&z(Ye)),p===n?(P=d,d=n):(m=X(),m===n&&(m=null),f=[f,p,m],d=f),d===n?u=d:(d=U(),d===n?(P=u,u=n):u=d);l.length<1?(P=c,c=n):c=l,c===n?(P=s,s=n):(l=X(),l===n&&(l=null),s=c),s===n&&(s=null),e.charCodeAt(P)===41?(c=`)`,P++):(c=n,I===0&&z(_t)),c===n?(P=t,t=n):(F=t,t=ui(r,s))}else P=t,t=n}else P=t,t=n;return L[h]={nextPos:P,result:t},t}function ho(){let e,t,r=P*132+94,i=L[r];return i?(P=i.nextPos,i.result):(e=P,t=go(),t!==n&&(F=e,t=di(t)),e=t,L[r]={nextPos:P,result:e},e)}function go(){let e,t,r=P*132+95,i=L[r];return i?(P=i.nextPos,i.result):(e=P,_o(),t=zo(),t===n?(P=e,e=n):(F=e,e=fi()),L[r]={nextPos:P,result:e},e)}function _o(){let t,r,i,a,o=P*132+96,s=L[o];if(s)return P=s.nextPos,s.result;for(t=[],r=P,i=zo(),i===n?(P=r,r=n):(e.charCodeAt(P)===46?(a=`.`,P++):(a=n,I===0&&z(Bt)),a===n?(P=r,r=n):(i=[i,a],r=i));r!==n;)t.push(r),r=P,i=zo(),i===n?(P=r,r=n):(e.charCodeAt(P)===46?(a=`.`,P++):(a=n,I===0&&z(Bt)),a===n?(P=r,r=n):(i=[i,a],r=i));return L[o]={nextPos:P,result:t},t}function q(){let t,r,i,a=P*132+97,o=L[a];return o?(P=o.nextPos,o.result):(t=P,r=vo(),r!==n&&(F=t,r=pi(r)),t=r,t===n&&(t=P,r=e.substr(P,4),r.toLowerCase()===ae?P+=4:(r=n,I===0&&z(It)),r!==n&&(F=t,r=mi(r)),t=r,t===n&&(t=P,r=P,i=yo(),r=i===n?i:e.substring(r,P),r!==n&&(F=t,r=hi(r)),t=r,t===n&&(t=P,r=P,i=Mo(),r=i===n?i:e.substring(r,P),r!==n&&(F=t,r=gi(r)),t=r,t===n&&(t=Po(),t===n&&(t=Fo()))))),L[a]={nextPos:P,result:t},t)}function vo(){let t,r=P*132+98,i=L[r];return i?(P=i.nextPos,i.result):(t=e.substr(P,4),t.toLowerCase()===fe?P+=4:(t=n,I===0&&z(en)),t===n&&(t=e.substr(P,5),t.toLowerCase()===pe?P+=5:(t=n,I===0&&z(tn))),L[r]={nextPos:P,result:t},t)}function yo(){let e,t=P*132+99,r=L[t];return r?(P=r.nextPos,r.result):(e=ko(),e===n&&(e=bo()),L[t]={nextPos:P,result:e},e)}function bo(){let e,t=P*132+100,r=L[t];return r?(P=r.nextPos,r.result):(e=J(),e===n&&(e=So(),e===n&&(e=Co(),e===n&&(e=xo()))),L[t]={nextPos:P,result:e},e)}function J(){let t,r,i,a,o=P*132+101,s=L[o];if(s)return P=s.nextPos,s.result;if(t=P,e.substr(P,2)===`0x`?(r=`0x`,P+=2):(r=n,I===0&&z(nn)),r!==n){if(i=[],a=To(),a!==n)for(;a!==n;)i.push(a),a=To();else i=n;i===n?(P=t,t=n):(r=[r,i],t=r)}else P=t,t=n;return L[o]={nextPos:P,result:t},t}function xo(){let e,t,r,i,a=P*132+102,o=L[a];if(o)return P=o.nextPos,o.result;if(e=Oo(),e===n){if(e=P,t=Eo(),t!==n){for(r=[],i=Y();i!==n;)r.push(i),i=Y();t=[t,r],e=t}else P=e,e=n}return L[a]={nextPos:P,result:e},e}function So(){let t,r,i,a,o=P*132+103,s=L[o];if(s)return P=s.nextPos,s.result;if(t=P,e.substr(P,2)===`0o`?(r=`0o`,P+=2):(r=n,I===0&&z(rn)),r!==n){if(i=[],a=Do(),a!==n)for(;a!==n;)i.push(a),a=Do();else i=n;i===n?(P=t,t=n):(r=[r,i],t=r)}else P=t,t=n;return L[o]={nextPos:P,result:t},t}function Co(){let t,r,i,a,o=P*132+104,s=L[o];if(s)return P=s.nextPos,s.result;if(t=P,e.substr(P,2)===`0b`?(r=`0b`,P+=2):(r=n,I===0&&z(an)),r!==n){if(i=[],a=e.charAt(P),ye.test(a)?P++:(a=n,I===0&&z(on)),a!==n)for(;a!==n;)i.push(a),a=e.charAt(P),ye.test(a)?P++:(a=n,I===0&&z(on));else i=n;i===n?(P=t,t=n):(r=[r,i],t=r)}else P=t,t=n;return L[o]={nextPos:P,result:t},t}function wo(){let t,r=P*132+105,i=L[r];return i?(P=i.nextPos,i.result):(t=e.charAt(P),be.test(t)?P++:(t=n,I===0&&z(sn)),L[r]={nextPos:P,result:t},t)}function To(){let e,t=P*132+106,r=L[t];return r?(P=r.nextPos,r.result):(e=Y(),e===n&&(e=wo()),L[t]={nextPos:P,result:e},e)}function Y(){let t,r=P*132+107,i=L[r];return i?(P=i.nextPos,i.result):(t=e.charAt(P),xe.test(t)?P++:(t=n,I===0&&z(cn)),L[r]={nextPos:P,result:t},t)}function Eo(){let t,r=P*132+108,i=L[r];return i?(P=i.nextPos,i.result):(t=e.charAt(P),O.test(t)?P++:(t=n,I===0&&z(ln)),L[r]={nextPos:P,result:t},t)}function Do(){let t,r=P*132+109,i=L[r];return i?(P=i.nextPos,i.result):(t=e.charAt(P),k.test(t)?P++:(t=n,I===0&&z(un)),L[r]={nextPos:P,result:t},t)}function Oo(){let t,r=P*132+110,i=L[r];return i?(P=i.nextPos,i.result):(e.charCodeAt(P)===48?(t=`0`,P++):(t=n,I===0&&z(dn)),L[r]={nextPos:P,result:t},t)}function ko(){let e,t=P*132+111,r=L[t];return r?(P=r.nextPos,r.result):(e=Ao(),e===n&&(e=jo()),L[t]={nextPos:P,result:e},e)}function Ao(){let t,r,i,a,o,s,c,l,u=P*132+112,d=L[u];if(d)return P=d.nextPos,d.result;if(t=P,r=[],i=Y(),i!==n)for(;i!==n;)r.push(i),i=Y();else r=n;if(r!==n){if(i=e.charAt(P),i.toLowerCase()===`e`?P++:(i=n,I===0&&z(fn)),i!==n){if(e.charCodeAt(P)===45?(a=`-`,P++):(a=n,I===0&&z(pn)),a===n&&(a=null),o=[],s=Y(),s!==n)for(;s!==n;)o.push(s),s=Y();else o=n;o===n?(P=t,t=n):(r=[r,i,a,o],t=r)}else P=t,t=n}else P=t,t=n;if(t===n){for(t=P,r=[],i=Y();i!==n;)r.push(i),i=Y();if(e.charCodeAt(P)===46?(i=`.`,P++):(i=n,I===0&&z(Bt)),i!==n){if(a=[],o=Y(),o!==n)for(;o!==n;)a.push(o),o=Y();else a=n;if(a!==n){if(o=e.charAt(P),o.toLowerCase()===`e`?P++:(o=n,I===0&&z(fn)),o!==n){if(e.charCodeAt(P)===45?(s=`-`,P++):(s=n,I===0&&z(pn)),s===n&&(s=null),c=[],l=Y(),l!==n)for(;l!==n;)c.push(l),l=Y();else c=n;c===n?(P=t,t=n):(r=[r,i,a,o,s,c],t=r)}else P=t,t=n}else P=t,t=n}else P=t,t=n}return L[u]={nextPos:P,result:t},t}function jo(){let t,r,i,a,o,s=P*132+113,c=L[s];if(c)return P=c.nextPos,c.result;for(t=P,r=[],i=Y();i!==n;)r.push(i),i=Y();if(e.charCodeAt(P)===46?(i=`.`,P++):(i=n,I===0&&z(Bt)),i!==n){if(a=[],o=Y(),o!==n)for(;o!==n;)a.push(o),o=Y();else a=n;a===n?(P=t,t=n):(r=[r,i,a],t=r)}else P=t,t=n;return L[s]={nextPos:P,result:t},t}function Mo(){let t,r,i,a,o=P*132+114,s=L[o];if(s)return P=s.nextPos,s.result;if(t=P,e.charCodeAt(P)===34?(r=`"`,P++):(r=n,I===0&&z(mn)),r!==n){for(i=[],a=e.charAt(P),A.test(a)?P++:(a=n,I===0&&z(hn)),a===n&&(a=No());a!==n;)i.push(a),a=e.charAt(P),A.test(a)?P++:(a=n,I===0&&z(hn)),a===n&&(a=No());e.charCodeAt(P)===34?(a=`"`,P++):(a=n,I===0&&z(mn)),a===n?(P=t,t=n):(r=[r,i,a],t=r)}else P=t,t=n;if(t===n){if(t=P,e.charCodeAt(P)===39?(r=`'`,P++):(r=n,I===0&&z(gn)),r!==n){for(i=[],a=e.charAt(P),Se.test(a)?P++:(a=n,I===0&&z(_n)),a===n&&(a=No());a!==n;)i.push(a),a=e.charAt(P),Se.test(a)?P++:(a=n,I===0&&z(_n)),a===n&&(a=No());e.charCodeAt(P)===39?(a=`'`,P++):(a=n,I===0&&z(gn)),a===n?(P=t,t=n):(r=[r,i,a],t=r)}else P=t,t=n}return L[o]={nextPos:P,result:t},t}function No(){let t,r,i,a=P*132+115,o=L[a];return o?(P=o.nextPos,o.result):(t=P,e.charCodeAt(P)===92?(r=`\\`,P++):(r=n,I===0&&z(vn)),r===n?(P=t,t=n):(e.length>P?(i=e.charAt(P),P++):(i=n,I===0&&z(Pe)),i===n?(P=t,t=n):(r=[r,i],t=r)),L[a]={nextPos:P,result:t},t)}function Po(){let t,r,i,a,o,s,c,l,u,d,f,p=P*132+116,m=L[p];if(m)return P=m.nextPos,m.result;if(t=P,e.charCodeAt(P)===91?(r=`[`,P++):(r=n,I===0&&z(vt)),r!==n){for(i=X(),i===n&&(i=null),a=P,o=P,s=[],c=U();c!==n;)s.push(c),c=P,l=P,u=X(),u===n&&(u=null),e.charCodeAt(P)===44?(d=`,`,P++):(d=n,I===0&&z(Ye)),d===n?(P=l,l=n):(f=X(),f===n&&(f=null),u=[u,d,f],l=u),l===n?c=l:(l=U(),l===n?(P=c,c=n):c=l);s.length<1?(P=o,o=n):o=s,o===n?(P=a,a=n):(s=X(),s===n&&(s=null),a=o),a===n&&(a=null),e.charCodeAt(P)===93?(o=`]`,P++):(o=n,I===0&&z(yt)),o===n?(P=t,t=n):(F=t,t=_i(a))}else P=t,t=n;return L[p]={nextPos:P,result:t},t}function Fo(){let t,r,i,a,o,s,c,l,u,d,f,p,m,h=P*132+117,g=L[h];if(g)return P=g.nextPos,g.result;if(t=P,e.charCodeAt(P)===123?(r=`{`,P++):(r=n,I===0&&z(Qt)),r!==n){for(i=X(),i===n&&(i=null),a=P,o=P,s=[],c=P,l=Lo(),l===n?(P=c,c=n):(u=X(),u===n&&(u=null),e.charCodeAt(P)===58?(d=`:`,P++):(d=n,I===0&&z(bt)),d===n?(P=c,c=n):(f=X(),f===n&&(f=null),p=U(),p===n?(P=c,c=n):c=[l,p]));c!==n;)s.push(c),c=P,l=P,u=X(),u===n&&(u=null),e.charCodeAt(P)===44?(d=`,`,P++):(d=n,I===0&&z(Ye)),d===n?(P=l,l=n):(f=X(),f===n&&(f=null),u=[u,d,f],l=u),l===n?c=l:(l=P,u=Lo(),u===n?(P=l,l=n):(d=X(),d===n&&(d=null),e.charCodeAt(P)===58?(f=`:`,P++):(f=n,I===0&&z(bt)),f===n?(P=l,l=n):(p=X(),p===n&&(p=null),m=U(),m===n?(P=l,l=n):l=[u,m])),l===n?(P=c,c=n):c=l);s.length<1?(P=o,o=n):o=s,o===n?(P=a,a=n):(s=X(),s===n&&(s=null),a=o),a===n&&(a=null),e.charCodeAt(P)===125?(o=`}`,P++):(o=n,I===0&&z($t)),o===n?(P=t,t=n):(F=t,t=vi(a))}else P=t,t=n;return L[h]={nextPos:P,result:t},t}function Io(){let t,r,i,a,o=P*132+118,s=L[o];return s?(P=s.nextPos,s.result):(t=P,e.charCodeAt(P)===36?(r=`$`,P++):(r=n,I===0&&z(yn)),r===n?(P=t,t=n):(i=P,a=zo(),a===n&&(a=xo()),i=a===n?a:e.substring(i,P),i===n?(P=t,t=n):(F=t,t=yi(i))),L[o]={nextPos:P,result:t},t)}function Lo(){let e,t,r=P*132+119,i=L[r];return i?(P=i.nextPos,i.result):(e=zo(),e===n&&(e=P,t=Ro(),t!==n&&(F=e,t=bi(t)),e=t),L[r]={nextPos:P,result:e},e)}function Ro(){let t,r=P*132+120,i=L[r];return i?(P=i.nextPos,i.result):(t=e.substr(P,3),t.toLowerCase()===`all`?P+=3:(t=n,I===0&&z(Be)),t===n&&(t=e.substr(P,3),t.toLowerCase()===`asc`?P+=3:(t=n,I===0&&z(ft)),t===n&&(t=e.substr(P,9),t.toLowerCase()===w?P+=9:(t=n,I===0&&z(dt)),t===n&&(t=e.substr(P,2),t.toLowerCase()===`by`?P+=2:(t=n,I===0&&z(ct)),t===n&&(t=e.substr(P,6),t.toLowerCase()===f?P+=6:(t=n,I===0&&z(qe)),t===n&&(t=e.substr(P,6),t.toLowerCase()===m?P+=6:(t=n,I===0&&z($e)),t===n&&(t=e.substr(P,4),t.toLowerCase()===ee?P+=4:(t=n,I===0&&z(mt)),t===n&&(t=e.substr(P,10),t.toLowerCase()===T?P+=10:(t=n,I===0&&z(pt)),t===n&&(t=e.substr(P,6),t.toLowerCase()===p?P+=6:(t=n,I===0&&z(Qe)),t===n&&(t=e.substr(P,6),t.toLowerCase()===D?P+=6:(t=n,I===0&&z(Zt)),t===n&&(t=e.substr(P,5),t.toLowerCase()===C?P+=5:(t=n,I===0&&z(ut)),t===n&&(t=e.substr(P,5),t.toLowerCase()===l?P+=5:(t=n,I===0&&z(He)),t===n&&(t=e.substr(P,5),t.toLowerCase()===d?P+=5:(t=n,I===0&&z(Ge)),t===n&&(t=e.substr(P,2),t.toLowerCase()===`on`?P+=2:(t=n,I===0&&z(Ke)),t===n&&(t=e.substr(P,8),t.toLowerCase()===c?P+=8:(t=n,I===0&&z(Ve)),t===n&&(t=e.substr(P,5),t.toLowerCase()===x?P+=5:(t=n,I===0&&z(st)),t===n&&(t=e.substr(P,6),t.toLowerCase()===h?P+=6:(t=n,I===0&&z(et)),t===n&&(t=e.substr(P,6),t.toLowerCase()===y?P+=6:(t=n,I===0&&z(at)),t===n&&(t=e.substr(P,3),t.toLowerCase()===`set`?P+=3:(t=n,I===0&&z(Je)),t===n&&(t=e.substr(P,4),t.toLowerCase()===S?P+=4:(t=n,I===0&&z(lt)),t===n&&(t=e.substr(P,5),t.toLowerCase()===te?P+=5:(t=n,I===0&&z(ht)),t===n&&(t=e.substr(P,4),t.toLowerCase()===v?P+=4:(t=n,I===0&&z(it)),t===n&&(t=e.substr(P,5),t.toLowerCase()===s?P+=5:(t=n,I===0&&z(ze)),t===n&&(t=e.substr(P,6),t.toLowerCase()===u?P+=6:(t=n,I===0&&z(Ue)),t===n&&(t=e.substr(P,3),t.toLowerCase()===`and`?P+=3:(t=n,I===0&&z(Tt)),t===n&&(t=e.substr(P,2),t.toLowerCase()===`as`?P+=2:(t=n,I===0&&z(We)),t===n&&(t=e.substr(P,8),t.toLowerCase()===ie?P+=8:(t=n,I===0&&z(Nt)),t===n&&(t=e.substr(P,8),t.toLowerCase()===b?P+=8:(t=n,I===0&&z(ot)),t===n&&(t=e.substr(P,4),t.toLowerCase()===re?P+=4:(t=n,I===0&&z(Mt)),t===n&&(t=e.substr(P,2),t.toLowerCase()===`in`?P+=2:(t=n,I===0&&z(Pt)),t===n&&(t=e.substr(P,2),t.toLowerCase()===`is`?P+=2:(t=n,I===0&&z(Ft)),t===n&&(t=e.substr(P,3),t.toLowerCase()===`not`?P+=3:(t=n,I===0&&z(Et)),t===n&&(t=e.substr(P,2),t.toLowerCase()===`or`?P+=2:(t=n,I===0&&z(Ct)),t===n&&(t=e.substr(P,6),t.toLowerCase()===ne?P+=6:(t=n,I===0&&z(jt)),t===n&&(t=e.substr(P,3),t.toLowerCase()===`xor`?P+=3:(t=n,I===0&&z(wt)),t===n&&(t=e.substr(P,5),t.toLowerCase()===pe?P+=5:(t=n,I===0&&z(tn)),t===n&&(t=e.substr(P,4),t.toLowerCase()===fe?P+=4:(t=n,I===0&&z(en)),t===n&&(t=e.substr(P,4),t.toLowerCase()===ae?P+=4:(t=n,I===0&&z(It)),t===n&&(t=e.substr(P,10),t.toLowerCase()===`constraint`?P+=10:(t=n,I===0&&z(bn)),t===n&&(t=e.substr(P,2),t.toLowerCase()===`do`?P+=2:(t=n,I===0&&z(xn)),t===n&&(t=e.substr(P,3),t.toLowerCase()===`for`?P+=3:(t=n,I===0&&z(Sn)),t===n&&(t=e.substr(P,7),t.toLowerCase()===`require`?P+=7:(t=n,I===0&&z(Cn)),t===n&&(t=e.substr(P,6),t.toLowerCase()===`unique`?P+=6:(t=n,I===0&&z(wn)),t===n&&(t=e.substr(P,4),t.toLowerCase()===se?P+=4:(t=n,I===0&&z(Wt)),t===n&&(t=e.substr(P,4),t.toLowerCase()===le?P+=4:(t=n,I===0&&z(j)),t===n&&(t=e.substr(P,4),t.toLowerCase()===E?P+=4:(t=n,I===0&&z(qt)),t===n&&(t=e.substr(P,4),t.toLowerCase()===ce?P+=4:(t=n,I===0&&z(Gt)),t===n&&(t=e.substr(P,3),t.toLowerCase()===`end`?P+=3:(t=n,I===0&&z(Kt)),t===n&&(t=e.substr(P,9),t.toLowerCase()===`mandatory`?P+=9:(t=n,I===0&&z(Tn)),t===n&&(t=e.substr(P,6),t.toLowerCase()===`scalar`?P+=6:(t=n,I===0&&z(En)),t===n&&(t=e.substr(P,2),t.toLowerCase()===`of`?P+=2:(t=n,I===0&&z(Dn)),t===n&&(t=e.substr(P,3),t.toLowerCase()===`add`?P+=3:(t=n,I===0&&z(On)),t===n&&(t=e.substr(P,4),t.toLowerCase()===`drop`?P+=4:(t=n,I===0&&z(kn)))))))))))))))))))))))))))))))))))))))))))))))))))))),L[r]={nextPos:P,result:t},t)}function zo(){let t,r,i=P*132+121,a=L[i];return a?(P=a.nextPos,a.result):(t=P,r=Bo(),r===n&&(r=Uo(),r===n&&(r=e.substr(P,5),r.toLowerCase()===oe?P+=5:(r=n,I===0&&z(Vt)),r===n&&(r=e.substr(P,6),r.toLowerCase()===`filter`?P+=6:(r=n,I===0&&z(An)),r===n&&(r=e.substr(P,7),r.toLowerCase()===`extract`?P+=7:(r=n,I===0&&z(jn)),r===n&&(r=e.substr(P,3),r.toLowerCase()===`any`?P+=3:(r=n,I===0&&z(Jt)),r===n&&(r=e.substr(P,4),r.toLowerCase()===ue?P+=4:(r=n,I===0&&z(Yt)),r===n&&(r=e.substr(P,6),r.toLowerCase()===de?P+=6:(r=n,I===0&&z(Xt))))))))),r!==n&&(F=t,r=xi()),t=r,L[i]={nextPos:P,result:t},t)}function Bo(){let e,t,r,i,a=P*132+122,o=L[a];if(o)return P=o.nextPos,o.result;if(e=P,t=Vo(),t!==n){for(r=[],i=Ho();i!==n;)r.push(i),i=Ho();t=[t,r],e=t}else P=e,e=n;return L[a]={nextPos:P,result:e},e}function Vo(){let e,t=P*132+123,r=L[t];return r?(P=r.nextPos,r.result):(e=Oi(),Ce.test(e)?P+=e.length:(e=n,I===0&&z(Mn)),L[t]={nextPos:P,result:e},e)}function Ho(){let e,t=P*132+124,r=L[t];return r?(P=r.nextPos,r.result):(e=Oi(),we.test(e)?P+=e.length:(e=n,I===0&&z(M)),L[t]={nextPos:P,result:e},e)}function Uo(){let t,r,i,a,o,s=P*132+125,c=L[s];if(c)return P=c.nextPos,c.result;if(t=[],r=P,e.charCodeAt(P)===96?(i="`",P++):(i=n,I===0&&z(Nn)),i!==n){for(a=[],o=e.charAt(P),Te.test(o)?P++:(o=n,I===0&&z(N));o!==n;)a.push(o),o=e.charAt(P),Te.test(o)?P++:(o=n,I===0&&z(N));e.charCodeAt(P)===96?(o="`",P++):(o=n,I===0&&z(Nn)),o===n?(P=r,r=n):(i=[i,a,o],r=i)}else P=r,r=n;if(r!==n)for(;r!==n;)if(t.push(r),r=P,e.charCodeAt(P)===96?(i="`",P++):(i=n,I===0&&z(Nn)),i!==n){for(a=[],o=e.charAt(P),Te.test(o)?P++:(o=n,I===0&&z(N));o!==n;)a.push(o),o=e.charAt(P),Te.test(o)?P++:(o=n,I===0&&z(N));e.charCodeAt(P)===96?(o="`",P++):(o=n,I===0&&z(Nn)),o===n?(P=r,r=n):(i=[i,a,o],r=i)}else P=r,r=n;else t=n;return L[s]={nextPos:P,result:t},t}function X(){let e,t,r=P*132+126,i=L[r];if(i)return P=i.nextPos,i.result;if(e=[],t=Wo(),t!==n)for(;t!==n;)e.push(t),t=Wo();else e=n;return L[r]={nextPos:P,result:e},e}function Wo(){let e,t=P*132+127,r=L[t];return r?(P=r.nextPos,r.result):(e=Oi(),Ee.test(e)?P+=e.length:(e=n,I===0&&z(Pn)),e===n&&(e=Go()),L[t]={nextPos:P,result:e},e)}function Go(){let t,r,i,a,o,s,c=P*132+128,l=L[c];if(l)return P=l.nextPos,l.result;if(t=P,e.substr(P,2)===`/*`?(r=`/*`,P+=2):(r=n,I===0&&z(Fn)),r!==n){for(i=[],a=e.charAt(P),De.test(a)?P++:(a=n,I===0&&z(In)),a===n&&(a=P,e.charCodeAt(P)===42?(o=`*`,P++):(o=n,I===0&&z(rt)),o===n?(P=a,a=n):(s=e.charAt(P),Oe.test(s)?P++:(s=n,I===0&&z(Ln)),s===n?(P=a,a=n):(o=[o,s],a=o)));a!==n;)i.push(a),a=e.charAt(P),De.test(a)?P++:(a=n,I===0&&z(In)),a===n&&(a=P,e.charCodeAt(P)===42?(o=`*`,P++):(o=n,I===0&&z(rt)),o===n?(P=a,a=n):(s=e.charAt(P),Oe.test(s)?P++:(s=n,I===0&&z(Ln)),s===n?(P=a,a=n):(o=[o,s],a=o)));e.substr(P,2)===`*/`?(a=`*/`,P+=2):(a=n,I===0&&z(Rn)),a===n?(P=t,t=n):(r=[r,i,a],t=r)}else P=t,t=n;if(t===n){if(t=P,e.substr(P,2)===`//`?(r=`//`,P+=2):(r=n,I===0&&z(zn)),r!==n){for(i=[],a=e.charAt(P),ke.test(a)?P++:(a=n,I===0&&z(Bn));a!==n;)i.push(a),a=e.charAt(P),ke.test(a)?P++:(a=n,I===0&&z(Bn));e.charCodeAt(P)===13?(a=`\r`,P++):(a=n,I===0&&z(Vn)),a===n&&(a=null),e.charCodeAt(P)===10?(o=`
|
|
323
|
-
`,P++):(o=n,I===0&&z(Hn)),o===n&&(o=P,I++,e.length>P?(s=e.charAt(P),P++):(s=n,I===0&&z(Pe)),I--,s===n?o=void 0:(P=o,o=n)),o===n?(P=t,t=n):(r=[r,i,a,o],t=r)}else P=t,t=n}return L[c]={nextPos:P,result:t},t}function Ko(){let t,r=P*132+129,i=L[r];return i?(P=i.nextPos,i.result):(t=e.charAt(P),Ae.test(t)?P++:(t=n,I===0&&z(Un)),L[r]={nextPos:P,result:t},t)}function qo(){let t,r=P*132+130,i=L[r];return i?(P=i.nextPos,i.result):(t=e.charAt(P),je.test(t)?P++:(t=n,I===0&&z(Wn)),L[r]={nextPos:P,result:t},t)}function Jo(){let t,r=P*132+131,i=L[r];return i?(P=i.nextPos,i.result):(t=e.charAt(P),Me.test(t)?P++:(t=n,I===0&&z(Gn)),L[r]={nextPos:P,result:t},t)}let Z=t.ast;function Yo(e,t,n){let r=e,i=typeof t==`string`?new Z.CypherIdentifier(t.toLowerCase()):t;for(let e of n)r=new Z.ASTOperator(`cypher`,i,[r,e]);return r}Ti=a();let Xo=Ti!==n&&P===e.length;function Zo(){throw Ti!==n&&P<e.length&&z(ji()),Pi(wi,Ci<e.length?Oi(Ci):null,Ci<e.length?Ni(Ci,Ci+1):Ni(Ci,Ci))}if(t.peg$library)return{peg$result:Ti,peg$currPos:P,peg$FAILED:n,peg$maxFailExpected:wi,peg$maxFailPos:Ci,peg$success:Xo,peg$throw:Xo?void 0:Zo};if(Xo)return Ti;Zo()}function Al(e){let t={langMgr:e,makeOp:(e,t)=>typeof e==`string`?new Yi(`cypher`,new Bc(e.toLowerCase()),t):new Yi(`cypher`,e,t),wrapFn:(e,t=[],n=!1)=>new Dc(new Xi(`cypher`,e,t),n),ast:{...fl,ASTLiteral:Ji,ASTOperator:Yi,ASTFunction:Xi,ASTIdentifier:V,LangSwitch:$i,allAttrs:Zi,boundParam:Qi}};return{parse(e){let n=kl(e,{peg$library:!0,...t});return n.peg$result===n.peg$FAILED&&n.peg$throw(),{value:[n.peg$result.value],remainingInput:n.peg$result.remainingInput}},parseExpr(e){return this.parse(`RETURN ${e}`)}}}var jl=class extends Os{adapter=this.db.langMgr.getLang(`cypher`).dataAdapter;constructor(e,t){super(`cypher`,e,t)}visitItemSource(e,t){let n=e.name,r=this.db.getSource(n.parts.slice(0,-1));return n.parts.at(-1)===`nodes`?this.adapter.filterNodes(r):this.adapter.filterEdges(r)}},Ml={name:`startNode`,addAdapterCtx:!0,pure:!0,impl:Q((e,t)=>e.adapter.getEdgeNode(e.graph,t,`source`))},Nl={name:`endNode`,addAdapterCtx:!0,pure:!0,impl:Q((e,t)=>e.adapter.getEdgeNode(e.graph,t,`target`))},Pl={name:`labels`,addAdapterCtx:!0,pure:!0,impl:Q((e,t)=>e.adapter.getLabels(e.graph,t))},Fl={name:`type`,addAdapterCtx:!0,pure:!0,impl:Q((e,t)=>e.adapter.getType(e.graph,t))},Il=t({endNode:()=>Nl,labels:()=>Pl,startNode:()=>Ml,type:()=>Fl}),Ll={name:`+`,impl:Q((e,t)=>Array.isArray(e)&&Array.isArray(t)?[...e,...t]:e+t)},Rl=t({add:()=>Ll}),zl=Symbol(`nodeOrEdgeId`),Bl=Symbol(`labelsOrType`),Vl=`__symbol__labelsOrType`,Hl=(e,t)=>{for(let n of e)if(!t.includes(n))return!1;return!0},Ul=class{convertNode(e,t){return t[zl]=e,t}convertEdge(e,t){return t[zl]=e,t}*getNodesByLabels(e,...t){for(let{node:n,attributes:r}of e.nodeEntries())Hl(t,r[Bl]??[])&&(yield this.convertNode(n,r))}*filterNodes(e,t){if(!t)yield*e.mapNodes(this.convertNode);else for(let{node:n,attributes:r}of e.nodeEntries()){let e=this.convertNode(n,r);t(e)&&(yield e)}}*getEdgesByType(e,t){for(let{edge:n,attributes:r}of e.edgeEntries())r[Bl]===t&&(yield this.convertEdge(n,r))}*filterEdges(e,t){if(t)for(let n of e.edgeEntries()){let e=this.convertEdge(n.edge,n.attributes);t(this.convertNode(n.source,n.sourceAttributes),this.convertNode(n.target,n.targetAttributes),e)&&(yield e)}else for(let{edge:t,attributes:n}of e.edgeEntries())yield this.convertEdge(t,n)}*getNodeEdgesByType(e,t,n,r){for(let{edge:i,attributes:a}of e[r===`in`?`inEdgeEntries`:r===`out`?`outEdgeEntries`:`edgeEntries`](t[zl]))a[Bl]===n&&(yield this.convertEdge(i,a))}*filterNodeEdges(e,t,n,r){for(let i of e[n===`in`?`inEdgeEntries`:n===`out`?`outEdgeEntries`:`edgeEntries`](t[zl])){let e=this.convertEdge(i.edge,i.attributes);r?r(this.convertNode(i.source,i.sourceAttributes),this.convertNode(i.target,i.targetAttributes),e)&&(yield e):yield e}}isConnected(e,t,n,r){let i=n[zl];return e[r===`in`?`someInboundEdge`:r===`out`?`someOutboundEdge`:`someEdge`](t[zl],e=>e===i)}hasLabels(e,t,n){return Hl(n,t[Bl]??[])}getLabels(e,t){return t==null?null:t[Bl]??[]}hasAnyType(e,t,n){return n.includes(t[Bl])}getType(e,t){return t==null?null:t[Bl]}getEdgeNode(e,t,n){let r=e[n](t[zl]);return this.convertNode(r,e.getNodeAttributes(r))}static import(e){for(let t of e.nodes)t.attributes[Bl]=t.attributes[Vl],delete t.attributes[Vl];for(let t of e.edges)t.attributes[Bl]=t.attributes[Vl],delete t.attributes[Vl];return new Xt().import(e)}static export(e){let t=e.export();for(let n of t.nodes)n.attributes??={},n.attributes[Vl]=e.getNodeAttributes(n.key)[Bl];for(let n of t.edges)n.attributes??={},n.attributes[Vl]=e.getEdgeAttributes(n.key)[Bl];return t}};function Wl(e){return{name:`cypher`,operators:[...Object.values(Rl)],aggregates:[],functions:[...Object.values(Il)],castables:[],visitors:{logicalPlanBuilder:Dl,executor:jl},createParser:Al,dataAdapter:e?.adapter??new Ul,defaultGraph:e?.defaultGraph&&V.fromParts([e.defaultGraph]),serialize:e?.serialize??$o()}}var Gl=class{expressions;eqCheckers;calcBuilders;adapter;constructor(e,t){this.expressions=e,this.eqCheckers=t.langMgr.getVisitorMap(`equalityChecker`),this.calcBuilders=t.langMgr.getVisitorMap(`calculationBuilder`),this.adapter=t.langMgr.getLang(`cypher`).dataAdapter}reindex(e){}match(e,t){for(let n=0;n<e.length;n++)if(e[n].containingFn.impl===this.adapter.isConnected){let r=e[n].expr;if(this.matchesFromItemKey(r,t))return[n]}return null}matchesFromItemKey(e,t){for(let n of e instanceof V?[e.parts]:e.getDependencies())if(t?.get(n)?.[0]===pc)return!0;return!1}createAccessor(e){let t=e[0],n=t.expr instanceof V?t.containingFn.args[2]instanceof V&&t.expr.equals(t.containingFn.args[2]):t.expr===t.containingFn.args[2].op;return To(new q(t.containingFn.lang,[t.containingFn.args[0],t.containingFn.args[n?1:2],t.containingFn.args[3]],n?(e,t,n)=>this.adapter.filterNodeEdges(e,t,n):(e,t,n)=>{let r=[];return(n===`any`||n===`in`)&&r.push(this.adapter.getEdgeNode(e,t,`target`)),(n===`any`||n===`out`)&&r.push(this.adapter.getEdgeNode(e,t,`source`)),r}),this.calcBuilders,this.eqCheckers)}},Kl=`vault`,ql=200,Jl={operators:[{name:`in`,impl:(e,t)=>Array.isArray(t)&&e!=null?t.includes(e):null},{name:`contains`,impl:(e,t)=>typeof e==`string`&&typeof t==`string`?e.includes(t):null},{name:`startswith`,impl:(e,t)=>typeof e==`string`&&typeof t==`string`?e.startsWith(t):null},{name:`endswith`,impl:(e,t)=>typeof e==`string`&&typeof t==`string`?e.endsWith(t):null}],functions:[{name:`toLower`,pure:!0,impl:e=>typeof e==`string`?e.toLowerCase():null},{name:`toUpper`,pure:!0,impl:e=>typeof e==`string`?e.toUpperCase():null},{name:`trim`,pure:!0,impl:e=>typeof e==`string`?e.trim():null},{name:`size`,pure:!0,impl:e=>typeof e==`string`||Array.isArray(e)?e.length:null}]},Yl=[`avg`,`collect`,`count`,`endNode`,`labels`,`max`,`min`,`size`,`startNode`,`sum`,`toLower`,`toUpper`,`trim`,`type`];function Xl(e){let t=new mc({mainLang:Wl({defaultGraph:Kl}),extensions:[Jl],optimizer:{rules:Ec}});return t.registerSource([Kl],e.graph),t.createIndex([Kl,`nodes`],[],Gl),{run(n){if(!n.trim())return{status:`error`,message:`Write a query to run.`};let r=performance.now();try{let i=t.query(n),a=i.schema??Object.keys(i.data[0]??{}),o=Zl(i.data,e);return{status:`ok`,columns:a.map($l),rows:i.data.slice(0,ql).map(e=>a.map(t=>e[t])),totalRows:i.data.length,nodeIds:[...o.nodes],edgeIds:[...o.edges],elapsedMs:performance.now()-r}}catch(e){return eu(e)}}}}function Zl(e,t){let n=new Set,r=new Set,i=new WeakSet,a=e=>{if(!e||typeof e!=`object`||i.has(e))return;i.add(e);let o=t.nodeIds.get(e);if(o){n.add(o);return}let s=t.edgeIds.get(e);s?r.add(s):Object.values(e).forEach(a)};return e.forEach(a),{nodes:n,edges:r}}function Ql(e,t){return e==null?`null`:typeof e==`object`?t.nodeIds.has(e)?String(e.title??t.nodeIds.get(e)):t.edgeIds.has(e)?`:${String(e[Bl])}`:Array.isArray(e)?`[${e.map(e=>Ql(e,t)).join(`, `)}]`:e instanceof Date?e.toISOString():`{${Object.entries(e).map(([e,n])=>`${e}: ${Ql(n,t)}`).join(`, `)}}`:typeof e==`string`?e:String(e)}function $l(e){return e.replace(/`/g,``)}function eu(e){let t=e instanceof Error?e.message:String(e),n=e?.location;if(n?.start){let e=n.end??n.start;return{status:`error`,message:`Syntax error: ${t}`,location:{line:n.start.line,column:n.start.column,endLine:e.line,endColumn:Math.max(e.column,n.start.column+1)}}}return/only read operations/i.test(t)?{status:`error`,message:`Only read queries run here: CREATE, MERGE, SET, REMOVE and DELETE are not supported.`}:{status:`error`,message:t}}function tu({result:e,source:t}){return(0,B.jsxs)(`div`,{className:`graph-query-rows`,children:[(0,B.jsxs)(`table`,{children:[(0,B.jsx)(`thead`,{children:(0,B.jsx)(`tr`,{children:e.columns.map(e=>(0,B.jsx)(`th`,{scope:`col`,children:e},e))})}),(0,B.jsx)(`tbody`,{children:e.rows.map((e,n)=>(0,B.jsx)(`tr`,{children:e.map((e,n)=>(0,B.jsx)(`td`,{children:Ql(e,t)},n))},n))})]}),e.totalRows>e.rows.length&&(0,B.jsxs)(p,{as:`p`,size:`small`,tone:`muted`,children:[`Showing `,e.rows.length.toLocaleString(),` of `,e.totalRows.toLocaleString(),` rows.`]})]})}var nu=(e,t,n=`${t}s`)=>`${e.toLocaleString()} ${e===1?t:n}`;function ru(e,t){if(!t)return{tone:`muted`,text:`Loading note properties…`};if(!e)return{tone:`muted`,text:`Run a query to show only the notes it returns. ⌘↵ runs, esc closes.`};if(e.status===`error`){let t=e.location?` (line ${e.location.line}, column ${e.location.column})`:``;return{tone:`error`,text:`${e.message}${t}`}}let n=[nu(e.nodeIds.length,`node`),nu(e.edgeIds.length,`relationship`),nu(e.totalRows,`row`)],r=e.nodeIds.length===0?` · no nodes returned, so the graph is empty`:``;return{tone:`ok`,text:`${n.join(` · `)} · ${Math.max(1,Math.round(e.elapsedMs))} ms${r}`}}var iu=(0,E.lazy)(async()=>({default:(await _(async()=>{let{CypherEditor:e}=await import(`./cypher-editor-ef6RdDgm.js`);return{CypherEditor:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]))).CypherEditor}));function au({draft:e,result:t,schema:n,source:r,ready:i,examples:o,onDraftChange:s,onRun:l,onClear:d,onClose:f}){let[h,g]=(0,E.useState)(!1),_=ru(t,i),v=t?.status===`ok`&&t.rows.length>0&&t.nodeIds.length===0;return(0,B.jsxs)(`section`,{className:`graph-query-bar`,"aria-label":`Cypher query`,children:[(0,B.jsx)(`div`,{className:`graph-query-editor`,children:(0,B.jsx)(E.Suspense,{fallback:(0,B.jsx)(p,{as:`div`,tone:`muted`,className:`graph-query-editor-fallback`,children:`Loading editor…`}),children:(0,B.jsx)(iu,{value:e,schema:n,functions:Yl,autoFocus:!0,error:t?.status===`error`?t:void 0,onChange:s,onRun:()=>l(),onEscape:f})})}),(0,B.jsxs)(`footer`,{className:`graph-query-footer`,children:[(0,B.jsx)(p,{as:`p`,size:`small`,tone:_.tone===`error`?`danger`:`muted`,className:`graph-query-status graph-query-status-${_.tone}`,role:`status`,children:_.text}),(0,B.jsxs)(`div`,{className:`graph-query-actions`,children:[(0,B.jsx)(c,{open:h,onOpenChange:g,label:`Example queries`,placement:`bottom-end`,trigger:(0,B.jsxs)(u,{variant:`ghost`,size:`small`,children:[(0,B.jsx)(ae,{"aria-hidden":`true`}),` Examples`]}),children:o.map(e=>(0,B.jsx)(a,{label:e.title,description:e.query.replace(/\s*\n\s*/g,` `),onClick:()=>{g(!1),l(e.query)}},e.title))}),t&&(0,B.jsx)(u,{variant:`ghost`,size:`small`,onClick:d,children:`Clear`}),(0,B.jsxs)(u,{variant:`primary`,size:`small`,hint:`⌘↵`,disabled:!i||!e.trim(),onClick:()=>l(),children:[(0,B.jsx)(oe,{"aria-hidden":`true`,weight:`fill`}),` Run`]}),(0,B.jsx)(m,{variant:`ghost`,size:`small`,"aria-label":`Close query bar`,onClick:f,children:(0,B.jsx)(ee,{"aria-hidden":`true`})})]})]}),v&&r&&(0,B.jsx)(tu,{result:t,source:r})]})}var ou={note:`Note`,board:`Board`,"board-column":`BoardColumn`,"board-card":`Card`,calendar:`Calendar`,"calendar-entry":`CalendarEntry`,"calendar-occurrence":`CalendarOccurrence`,matrix:`Matrix`,"matrix-card":`MatrixCard`},su=40;function cu(e){let t=ou[e.kind]??`Node`;return e.entityType&&e.entityType!==t?[e.entityType,t]:[t]}function lu(e,t){return{...t,id:e.id,title:e.label,kind:e.kind,...e.entityType?{type:e.entityType}:{},exists:e.exists,degree:e.degree}}function uu(e){let t=new Xt,n=new WeakMap,r=new WeakMap;for(let r of e.nodes){let i={...lu(r,e.frontmatter.get(r.id)),[Bl]:cu(r)};t.addNode(r.id,i),n.set(i,r.id)}return e.edges.forEach((e,n)=>{if(!t.hasNode(e.source)||!t.hasNode(e.target))return;let i=du(e),a=String(n);t.addDirectedEdgeWithKey(a,e.source,e.target,i),r.set(i,a)}),{graph:t,nodeIds:n,edgeIds:r}}function du(e){return{[Bl]:e.relation,...e.provider?{provider:e.provider}:{}}}function fu(e){let t=new Set,n=new Map;for(let r of e.nodes){cu(r).forEach(e=>t.add(e));for(let[t,i]of Object.entries(lu(r,e.frontmatter.get(r.id)))){let e=n.get(t)??new Set;n.set(t,e),(typeof i==`string`&&i.length<=80||typeof i==`number`||typeof i==`boolean`)&&e.size<su&&e.add(typeof i==`string`?JSON.stringify(i):String(i))}}let r=(e,t)=>e.localeCompare(t);return{labels:[...t].sort(r),relationshipTypes:[...new Set(e.edges.map(e=>e.relation))].sort(r),propertyKeys:[...n.keys()].sort(r),propertyValues:Object.fromEntries([...n].map(([e,t])=>[e,[...t].sort(r)]))}}var pu=v({scope:`vault`,name:`graphQuery`,fallback:``,parse:e=>e.length<=2e4?e:void 0});function mu(e){return g(pu,{vaultId:e})}function hu(e,t){y(pu,t,{vaultId:e})}var gu={labels:[],relationshipTypes:[],propertyKeys:[],propertyValues:{}};function _u(e,t,n){let[r,i]=(0,E.useState)(!1),[a,o]=(0,E.useState)(()=>mu(e)),[s,c]=(0,E.useState)(),[l,u]=(0,E.useState)();(0,E.useEffect)(()=>{o(mu(e)),c(void 0),u(void 0)},[e]);let d=r||s!==void 0;(0,E.useEffect)(()=>{if(!d)return;let t=new AbortController;return x(e,void 0,(e,n)=>C(e,{...n,signal:t.signal})).then(e=>u(new Map(e.map(e=>[e.id,e.frontmatter])))).catch(()=>{t.signal.aborted||u(new Map)}),()=>t.abort()},[d,n,e]);let f=(0,E.useMemo)(()=>t&&l?{nodes:t.nodes,edges:t.edges,frontmatter:l}:void 0,[t,l]),p=(0,E.useMemo)(()=>f?uu(f):void 0,[f]),m=(0,E.useMemo)(()=>p?Xl(p):void 0,[p]),h=(0,E.useMemo)(()=>f?fu(f):gu,[f]),g=(0,E.useMemo)(()=>s!==void 0&&m?m.run(s):void 0,[s,m]);function _(t){o(t),hu(e,t)}return{open:r,draft:a,result:g,appliedQuery:s,schema:h,source:p,ready:!!m,setOpen:i,setDraft:_,run:(e=a)=>{e!==a&&_(e),c(e)},clear:()=>c(void 0)}}var vu=/^[A-Z]/;function yu(e){let t=e.labels.filter(e=>!vu.test(e))[0]??`Note`,n=e.relationshipTypes.find(e=>e!==`bodyLink`)??e.relationshipTypes[0],r=Object.entries(e.propertyValues).find(([e,t])=>![`id`,`title`,`kind`,`type`,`exists`,`degree`].includes(e)&&!e.startsWith(`_`)&&t.length>1&&t.length<12&&t[0].startsWith(`"`));return[{title:`Every ${t}`,query:`MATCH (n:${t})\nRETURN n`},...n?[{title:`Notes joined by ${n}`,query:`MATCH (a)-[r:${n}]->(b)\nRETURN a, r, b`}]:[],...r?[{title:`Filter on ${r[0]}`,query:`MATCH (n:Note)\nWHERE n.${r[0]} = ${r[1][0]}\nRETURN n`}]:[],{title:`Title contains a word`,query:`MATCH (n:Note)
|
|
324
|
-
WHERE toLower(n.title) CONTAINS "plan"
|
|
325
|
-
RETURN n`},{title:`Two steps around a ${t}`,query:`MATCH p = (n:${t})-[*1..2]-(m)\nRETURN p\nLIMIT 200`},{title:`Unconnected notes`,query:`MATCH (n:Note)
|
|
326
|
-
WHERE n.degree = 0
|
|
327
|
-
RETURN n`},{title:`Notes per type (table)`,query:`MATCH (n:Note)
|
|
328
|
-
RETURN n.type AS type, count(n) AS notes
|
|
329
|
-
ORDER BY notes DESC, type`}]}function bu(e,t){let n=new Set(t);return{...e,nodes:e.nodes.filter(e=>n.has(e.id)),edges:e.edges.filter(e=>n.has(e.source)&&n.has(e.target))}}var xu=n((e=>{function t(e){return typeof e!=`number`||isNaN(e)?1:e}function n(e,t){var n={},r=function(e){return e===void 0?t:e};typeof t==`function`&&(r=t);var i=function(t){return r(t[e])},a=function(){return r(void 0)};return typeof e==`string`?(n.fromAttributes=i,n.fromGraph=function(e,t){return i(e.getNodeAttributes(t))},n.fromEntry=function(e,t){return i(t)}):typeof e==`function`?(n.fromAttributes=function(){throw Error(`graphology-utils/getters/createNodeValueGetter: irrelevant usage.`)},n.fromGraph=function(t,n){return r(e(n,t.getNodeAttributes(n)))},n.fromEntry=function(t,n){return r(e(t,n))}):(n.fromAttributes=a,n.fromGraph=a,n.fromEntry=a),n}function r(e,t){var n={},r=function(e){return e===void 0?t:e};typeof t==`function`&&(r=t);var i=function(t){return r(t[e])},a=function(){return r(void 0)};return typeof e==`string`?(n.fromAttributes=i,n.fromGraph=function(e,t){return i(e.getEdgeAttributes(t))},n.fromEntry=function(e,t){return i(t)},n.fromPartialEntry=n.fromEntry,n.fromMinimalEntry=n.fromEntry):typeof e==`function`?(n.fromAttributes=function(){throw Error(`graphology-utils/getters/createEdgeValueGetter: irrelevant usage.`)},n.fromGraph=function(t,n){var i=t.extremities(n);return r(e(n,t.getEdgeAttributes(n),i[0],i[1],t.getNodeAttributes(i[0]),t.getNodeAttributes(i[1]),t.isUndirected(n)))},n.fromEntry=function(t,n,i,a,o,s,c){return r(e(t,n,i,a,o,s,c))},n.fromPartialEntry=function(t,n,i,a){return r(e(t,n,i,a))},n.fromMinimalEntry=function(t,n){return r(e(t,n))}):(n.fromAttributes=a,n.fromGraph=a,n.fromEntry=a,n.fromMinimalEntry=a),n}e.createNodeValueGetter=n,e.createEdgeValueGetter=r,e.createEdgeWeightGetter=function(e){return r(e,t)}})),Su=n(((e,t)=>{t.exports=function(e,t,n){var r,i,a,o,s,c,l,u,d,f,p=t.length,m=n.length,h=e.adjustSizes,g=e.barnesHutTheta*e.barnesHutTheta,_,v,y,b,x,S,C,w=[];for(a=0;a<p;a+=10)t[a+4]=t[a+2],t[a+5]=t[a+3],t[a+2]=0,t[a+3]=0;if(e.outboundAttractionDistribution){for(_=0,a=0;a<p;a+=10)_+=t[a+6];_/=p/10}if(e.barnesHutOptimize){var T=1/0,ee=-1/0,te=1/0,ne=-1/0,re,ie,ae;for(a=0;a<p;a+=10)T=Math.min(T,t[a+0]),ee=Math.max(ee,t[a+0]),te=Math.min(te,t[a+1]),ne=Math.max(ne,t[a+1]);var oe=ee-T,se=ne-te;for(oe>se?(te-=(oe-se)/2,ne=te+oe):(T-=(se-oe)/2,ee=T+se),w[0]=-1,w[1]=(T+ee)/2,w[2]=(te+ne)/2,w[3]=Math.max(ee-T,ne-te),w[4]=-1,w[5]=-1,w[6]=0,w[7]=0,w[8]=0,r=1,a=0;a<p;a+=10)for(i=0,ae=3;;)if(w[i+5]>=0){re=t[a+0]<w[i+1]?t[a+1]<w[i+2]?w[i+5]:w[i+5]+9:t[a+1]<w[i+2]?w[i+5]+18:w[i+5]+27,w[i+7]=(w[i+7]*w[i+6]+t[a+0]*t[a+6])/(w[i+6]+t[a+6]),w[i+8]=(w[i+8]*w[i+6]+t[a+1]*t[a+6])/(w[i+6]+t[a+6]),w[i+6]+=t[a+6],i=re;continue}else if(w[i+0]<0){w[i+0]=a;break}else{if(w[i+5]=r*9,u=w[i+3]/2,d=w[i+5],w[d+0]=-1,w[d+1]=w[i+1]-u,w[d+2]=w[i+2]-u,w[d+3]=u,w[d+4]=d+9,w[d+5]=-1,w[d+6]=0,w[d+7]=0,w[d+8]=0,d+=9,w[d+0]=-1,w[d+1]=w[i+1]-u,w[d+2]=w[i+2]+u,w[d+3]=u,w[d+4]=d+9,w[d+5]=-1,w[d+6]=0,w[d+7]=0,w[d+8]=0,d+=9,w[d+0]=-1,w[d+1]=w[i+1]+u,w[d+2]=w[i+2]-u,w[d+3]=u,w[d+4]=d+9,w[d+5]=-1,w[d+6]=0,w[d+7]=0,w[d+8]=0,d+=9,w[d+0]=-1,w[d+1]=w[i+1]+u,w[d+2]=w[i+2]+u,w[d+3]=u,w[d+4]=w[i+4],w[d+5]=-1,w[d+6]=0,w[d+7]=0,w[d+8]=0,r+=4,re=t[w[i+0]+0]<w[i+1]?t[w[i+0]+1]<w[i+2]?w[i+5]:w[i+5]+9:t[w[i+0]+1]<w[i+2]?w[i+5]+18:w[i+5]+27,w[i+6]=t[w[i+0]+6],w[i+7]=t[w[i+0]+0],w[i+8]=t[w[i+0]+1],w[re+0]=w[i+0],w[i+0]=-1,ie=t[a+0]<w[i+1]?t[a+1]<w[i+2]?w[i+5]:w[i+5]+9:t[a+1]<w[i+2]?w[i+5]+18:w[i+5]+27,re===ie){if(ae--){i=re;continue}ae=3;break}w[ie+0]=a;break}}if(e.barnesHutOptimize)for(v=e.scalingRatio,a=0;a<p;a+=10)for(i=0;;)if(w[i+5]>=0){if(S=(t[a+0]-w[i+7])**2+(t[a+1]-w[i+8])**2,f=w[i+3],4*f*f/S<g){if(y=t[a+0]-w[i+7],b=t[a+1]-w[i+8],h===!0?S>0?(C=v*t[a+6]*w[i+6]/S,t[a+2]+=y*C,t[a+3]+=b*C):S<0&&(C=-v*t[a+6]*w[i+6]/Math.sqrt(S),t[a+2]+=y*C,t[a+3]+=b*C):S>0&&(C=v*t[a+6]*w[i+6]/S,t[a+2]+=y*C,t[a+3]+=b*C),i=w[i+4],i<0)break;continue}i=w[i+5];continue}else{if(c=w[i+0],c>=0&&c!==a&&(y=t[a+0]-t[c+0],b=t[a+1]-t[c+1],S=y*y+b*b,h===!0?S>0?(C=v*t[a+6]*t[c+6]/S,t[a+2]+=y*C,t[a+3]+=b*C):S<0&&(C=-v*t[a+6]*t[c+6]/Math.sqrt(S),t[a+2]+=y*C,t[a+3]+=b*C):S>0&&(C=v*t[a+6]*t[c+6]/S,t[a+2]+=y*C,t[a+3]+=b*C)),i=w[i+4],i<0)break;continue}else for(v=e.scalingRatio,o=0;o<p;o+=10)for(s=0;s<o;s+=10)y=t[o+0]-t[s+0],b=t[o+1]-t[s+1],h===!0?(S=Math.sqrt(y*y+b*b)-t[o+8]-t[s+8],S>0?(C=v*t[o+6]*t[s+6]/S/S,t[o+2]+=y*C,t[o+3]+=b*C,t[s+2]-=y*C,t[s+3]-=b*C):S<0&&(C=100*v*t[o+6]*t[s+6],t[o+2]+=y*C,t[o+3]+=b*C,t[s+2]-=y*C,t[s+3]-=b*C)):(S=Math.sqrt(y*y+b*b),S>0&&(C=v*t[o+6]*t[s+6]/S/S,t[o+2]+=y*C,t[o+3]+=b*C,t[s+2]-=y*C,t[s+3]-=b*C));for(d=e.gravity/e.scalingRatio,v=e.scalingRatio,a=0;a<p;a+=10)C=0,y=t[a+0],b=t[a+1],S=Math.sqrt(y**2+b**2),e.strongGravityMode?S>0&&(C=v*t[a+6]*d):S>0&&(C=v*t[a+6]*d/S),t[a+2]-=y*C,t[a+3]-=b*C;for(v=1*(e.outboundAttractionDistribution?_:1),l=0;l<m;l+=3)o=n[l+0],s=n[l+1],u=n[l+2],x=u**+e.edgeWeightInfluence,y=t[o+0]-t[s+0],b=t[o+1]-t[s+1],h===!0?(S=Math.sqrt(y*y+b*b)-t[o+8]-t[s+8],e.linLogMode?e.outboundAttractionDistribution?S>0&&(C=-v*x*Math.log(1+S)/S/t[o+6]):S>0&&(C=-v*x*Math.log(1+S)/S):e.outboundAttractionDistribution?S>0&&(C=-v*x/t[o+6]):S>0&&(C=-v*x)):(S=Math.sqrt(y**2+b**2),e.linLogMode?e.outboundAttractionDistribution?S>0&&(C=-v*x*Math.log(1+S)/S/t[o+6]):S>0&&(C=-v*x*Math.log(1+S)/S):e.outboundAttractionDistribution?(S=1,C=-v*x/t[o+6]):(S=1,C=-v*x)),S>0&&(t[o+2]+=y*C,t[o+3]+=b*C,t[s+2]-=y*C,t[s+3]-=b*C);var ce,le,E,ue,de,D;if(h===!0)for(a=0;a<p;a+=10)t[a+9]!==1&&(ce=Math.sqrt(t[a+2]**2+t[a+3]**2),ce>10&&(t[a+2]=t[a+2]*10/ce,t[a+3]=t[a+3]*10/ce),le=t[a+6]*Math.sqrt((t[a+4]-t[a+2])*(t[a+4]-t[a+2])+(t[a+5]-t[a+3])*(t[a+5]-t[a+3])),E=Math.sqrt((t[a+4]+t[a+2])*(t[a+4]+t[a+2])+(t[a+5]+t[a+3])*(t[a+5]+t[a+3]))/2,ue=.1*Math.log(1+E)/(1+Math.sqrt(le)),de=t[a+0]+t[a+2]*(ue/e.slowDown),t[a+0]=de,D=t[a+1]+t[a+3]*(ue/e.slowDown),t[a+1]=D);else for(a=0;a<p;a+=10)t[a+9]!==1&&(le=t[a+6]*Math.sqrt((t[a+4]-t[a+2])*(t[a+4]-t[a+2])+(t[a+5]-t[a+3])*(t[a+5]-t[a+3])),E=Math.sqrt((t[a+4]+t[a+2])*(t[a+4]+t[a+2])+(t[a+5]+t[a+3])*(t[a+5]+t[a+3]))/2,ue=t[a+7]*Math.log(1+E)/(1+Math.sqrt(le)),t[a+7]=Math.min(1,Math.sqrt(ue*(t[a+2]**2+t[a+3]**2)/(1+Math.sqrt(le)))),de=t[a+0]+t[a+2]*(ue/e.slowDown),t[a+0]=de,D=t[a+1]+t[a+3]*(ue/e.slowDown),t[a+1]=D);return{}}})),Cu=n((e=>{e.assign=function(e){e||={};for(var t=Array.prototype.slice.call(arguments).slice(1),n=0,r,i=t.length;n<i;n++)if(t[n])for(r in t[n])e[r]=t[n][r];return e},e.validateSettings=function(e){return`linLogMode`in e&&typeof e.linLogMode!=`boolean`?{message:"the `linLogMode` setting should be a boolean."}:`outboundAttractionDistribution`in e&&typeof e.outboundAttractionDistribution!=`boolean`?{message:"the `outboundAttractionDistribution` setting should be a boolean."}:`adjustSizes`in e&&typeof e.adjustSizes!=`boolean`?{message:"the `adjustSizes` setting should be a boolean."}:`edgeWeightInfluence`in e&&typeof e.edgeWeightInfluence!=`number`?{message:"the `edgeWeightInfluence` setting should be a number."}:`scalingRatio`in e&&!(typeof e.scalingRatio==`number`&&e.scalingRatio>=0)?{message:"the `scalingRatio` setting should be a number >= 0."}:`strongGravityMode`in e&&typeof e.strongGravityMode!=`boolean`?{message:"the `strongGravityMode` setting should be a boolean."}:`gravity`in e&&!(typeof e.gravity==`number`&&e.gravity>=0)?{message:"the `gravity` setting should be a number >= 0."}:`slowDown`in e&&!(typeof e.slowDown==`number`||e.slowDown>=0)?{message:"the `slowDown` setting should be a number >= 0."}:`barnesHutOptimize`in e&&typeof e.barnesHutOptimize!=`boolean`?{message:"the `barnesHutOptimize` setting should be a boolean."}:`barnesHutTheta`in e&&!(typeof e.barnesHutTheta==`number`&&e.barnesHutTheta>=0)?{message:"the `barnesHutTheta` setting should be a number >= 0."}:null},e.graphToByteArrays=function(e,t){var n=e.order,r=e.size,i={},a,o=new Float32Array(n*10),s=new Float32Array(r*3);return a=0,e.forEachNode(function(e,t){i[e]=a,o[a]=t.x,o[a+1]=t.y,o[a+2]=0,o[a+3]=0,o[a+4]=0,o[a+5]=0,o[a+6]=1,o[a+7]=1,o[a+8]=t.size||1,o[a+9]=+!!t.fixed,a+=10}),a=0,e.forEachEdge(function(e,n,r,c,l,u,d){var f=i[r],p=i[c],m=t(e,n,r,c,l,u,d);o[f+6]+=m,o[p+6]+=m,s[a]=f,s[a+1]=p,s[a+2]=m,a+=3}),{nodes:o,edges:s}},e.assignLayoutChanges=function(e,t,n){var r=0;e.updateEachNodeAttributes(function(e,i){return i.x=t[r],i.y=t[r+1],r+=10,n?n(e,i):i})},e.readGraphPositions=function(e,t){var n=0;e.forEachNode(function(e,r){t[n]=r.x,t[n+1]=r.y,n+=10})},e.collectLayoutChanges=function(e,t,n){for(var r=e.nodes(),i={},a=0,o=0,s=t.length;a<s;a+=10){if(n){var c=Object.assign({},e.getNodeAttributes(r[o]));c.x=t[a],c.y=t[a+1],c=n(r[o],c),i[r[o]]={x:c.x,y:c.y}}else i[r[o]]={x:t[a],y:t[a+1]};o++}return i},e.createWorker=function(e){var t=window.URL||window.webkitURL,n=e.toString(),r=t.createObjectURL(new Blob([`(`+n+`).call(this);`],{type:`text/javascript`})),i=new Worker(r);return t.revokeObjectURL(r),i}})),wu=n(((e,t)=>{t.exports={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:1,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5}})),Tu=n(((e,t)=>{var n=jr(),r=xu().createEdgeWeightGetter,i=Su(),a=Cu(),o=wu();function s(e,t,s){if(!n(t))throw Error(`graphology-layout-forceatlas2: the given graph is not a valid graphology instance.`);typeof s==`number`&&(s={iterations:s});var c=s.iterations;if(typeof c!=`number`)throw Error(`graphology-layout-forceatlas2: invalid number of iterations.`);if(c<=0)throw Error(`graphology-layout-forceatlas2: you should provide a positive number of iterations.`);var l=r(`getEdgeWeight`in s?s.getEdgeWeight:`weight`).fromEntry,u=typeof s.outputReducer==`function`?s.outputReducer:null,d=a.assign({},o,s.settings),f=a.validateSettings(d);if(f)throw Error(`graphology-layout-forceatlas2: `+f.message);for(var p=a.graphToByteArrays(t,l),m=0;m<c;m++)i(d,p.nodes,p.edges);if(e)a.assignLayoutChanges(t,p.nodes,u);else return a.collectLayoutChanges(t,p.nodes)}function c(e){var t=typeof e==`number`?e:e.order;return{barnesHutOptimize:t>2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(t)}}var l=s.bind(null,!1);l.assign=s.bind(null,!0),l.inferSettings=c,t.exports=l})),Eu=n(((e,t)=>{function n(e){return!e||typeof e!=`object`||typeof e==`function`||Array.isArray(e)||e instanceof Set||e instanceof Map||e instanceof RegExp||e instanceof Date}function r(e,t){e||={};var i={};for(var a in t){var o=e[a],s=t[a];i[a]=n(s)?o===void 0?s:o:r(o,s)}return i}t.exports=r})),Du=n(((e,t)=>{var n=Eu(),r=jr(),i={dimensions:[`x`,`y`],center:.5,rng:Math.random,scale:1};function a(e,t,a){if(!r(t))throw Error(`graphology-layout/random: the given graph is not a valid graphology instance.`);a=n(a,i);var o=a.dimensions;if(!Array.isArray(o)||o.length<1)throw Error(`graphology-layout/random: given dimensions are invalid.`);var s=o.length,c=a.center,l=a.rng,u=a.scale,d=(c-.5)*u;function f(e){for(var t=0;t<s;t++)e[o[t]]=l()*u+d;return e}if(!e){var p={};return t.forEachNode(function(e){p[e]=f({})}),p}t.updateEachNodeAttributes(function(e,t){return f(t),t},{attributes:o})}var o=a.bind(null,!1);o.assign=a.bind(null,!0),t.exports=o})),Ou=e(Tu(),1),ku=e(Du(),1),Au=[`#34d058`,`#58a6ff`,`#d29922`,`#bc8cff`,`#39c5bb`,`#f0883e`,`#db61a2`,`#7ee787`],ju={note:`#87929d`,board:`#39c5bb`,"board-column":`#bc8cff`,"board-card":`#d29922`,calendar:`#58a6ff`,"calendar-entry":`#f0883e`,"calendar-occurrence":`#d6a15a`,matrix:`#db61a2`,"matrix-card":`#7ee787`},Mu={missing:`#59616a`,label:`#aeb7c0`,edge:`#2e3942`};function Nu(e){return e.kind===`note`&&e.entityType?`entity:${e.entityType}`:`kind:${e.kind}`}function Pu(e){let t=new Map;for(let n of e.nodes){let e=Nu(n),r=t.get(e);if(r){r.count+=1;continue}let i=e.startsWith(`entity:`),a=i?e.slice(7):n.kind;t.set(e,{id:e,label:i?Qu(a):n.kind===`note`?`Untyped notes`:Qu(a),color:i?Xu(a):ju[n.kind],count:1})}return[...t.values()].sort((e,t)=>e.label.localeCompare(t.label))}function Fu(e,t){let n=new Map;for(let r of e){if(r.source===r.target||!t.has(r.source)||!t.has(r.target))continue;let[e,i]=r.source<r.target?[r.source,r.target]:[r.target,r.source],a=`${e}\u0000${i}`,o=n.get(a)??{id:`visual:${n.size}`,source:e,target:i,relations:[],providers:[],count:0};o.count+=1,o.relations.includes(r.relation)||o.relations.push(r.relation),r.provider&&!o.providers.includes(r.provider)&&o.providers.push(r.provider),n.set(a,o)}return[...n.values()]}function Iu(e,t){let n=Pu(e),r=new Map(n.map(e=>[e.id,e])),i=e.nodes.filter(e=>!t.hiddenCategories.has(Nu(e))),a=new Set(i.map(e=>e.id)),o=Fu(e.edges,a),s=new Set(o.flatMap(e=>[e.source,e.target])),c=t.showIsolated?i:i.filter(e=>s.has(e.id)),l=new Set(c.map(e=>e.id));return o=o.filter(e=>l.has(e.source)&&l.has(e.target)),{visible:c,edges:o,categories:n,categoryById:r}}function Lu(e){return{...Mu,...Object.fromEntries(Object.entries(e.neutrals??{}).filter(([,e])=>e))}}function Ru(e,t,n){let r=Nu(e);return{label:e.label,fullLabel:e.id,kind:e.kind,entityType:e.entityType,category:r,color:e.exists?t.get(r)?.color??ju.note:n.missing,labelColor:n.label,exists:e.exists,provider:e.provider,reference:e.reference}}function zu(e,t){return{label:e.relations.join(`, `),relations:e.relations,providers:e.providers,count:e.count,color:t.edge,size:Math.min(.32,.1+Math.log2(e.count+1)*.06)}}function Bu(e,t){e.forEachNode(n=>{let r=e.degree(n);e.mergeNodeAttributes(n,{size:r?Math.min(10,1.8+Math.log2(r+1)*1.25):t??1.35})})}function Vu(e,t){return{graph:e,categories:t,visibleNodes:e.order,isolatedNodes:e.filterNodes(t=>e.degree(t)===0).length}}function Hu(e,t){let n=Lu(t),{visible:r,edges:i,categories:a,categoryById:o}=Iu(e,t),s=new Jt;for(let e of r)s.addNode(e.id,{...Ru(e,o,n),size:1.6});for(let e of i)s.addUndirectedEdgeWithKey(e.id,e.source,e.target,zu(e,n));return Bu(s,t.isolatedNodeSize),Gu(s,e.vaultId),Vu(s,a)}function Uu(e,t,n){let{visible:r,edges:i}=Iu(t,n),{graph:a}=e;return a.order!==r.length||a.size!==i.length?!1:r.every(e=>a.hasNode(e.id))&&i.every(e=>a.hasEdge(e.source,e.target))}function Wu(e,t,n){let r=Lu(n),{visible:i,edges:a,categories:o,categoryById:s}=Iu(t,n),{graph:c}=e;for(let e of i)c.mergeNodeAttributes(e.id,Ru(e,s,r));for(let e of a){let t=c.edge(e.source,e.target);t!==void 0&&c.mergeEdgeAttributes(t,zu(e,r))}return Bu(c,n.isolatedNodeSize),Vu(c,o)}function Gu(e,t){if(!e.order)return;let n=Ku(e),r=n.filter(e=>e.length>1),i=n.filter(e=>e.length===1).flat(),a=[];r.forEach((n,r)=>{let i=qu(e,n);ku.default.assign(i,{rng:$u(`${t}:${n[0]}`),scale:Math.max(4,Math.sqrt(n.length))}),i.size&&Ou.default.assign(i,{iterations:n.length<=30?180:n.length<=150?220:260,settings:{...Ou.default.inferSettings(i),adjustSizes:!0,barnesHutOptimize:n.length>50,gravity:.08,linLogMode:n.length>8,scalingRatio:18,slowDown:6}});let o=Math.max(7,Math.sqrt(n.length)*3.2),s=r===0?{x:0,y:0}:Yu(o,a);Ju(i,e,s.x,s.y,o),a.push({...s,radius:o})});let o=a.reduce((e,t)=>Math.max(e,Math.hypot(t.x,t.y)+t.radius),0),s=o?o+10:0,c=Math.PI*(3-Math.sqrt(5));i.forEach((t,n)=>{let r=s+Math.sqrt(n)*3.4,i=n*c;e.mergeNodeAttributes(t,{x:Math.cos(i)*r,y:Math.sin(i)*r})})}function Ku(e){let t=new Set(e.nodes()),n=[];for(;t.size;){let r=t.values().next().value,i=[],a=[r];t.delete(r);for(let n=0;n<a.length;n+=1){let r=a[n];i.push(r);for(let n of e.neighbors(r))t.delete(n)&&a.push(n)}n.push(i)}return n.sort((e,t)=>t.length-e.length||e[0].localeCompare(t[0]))}function qu(e,t){let n=new Jt,r=new Set(t);return t.forEach(t=>n.addNode(t,e.getNodeAttributes(t))),e.forEachEdge((e,t,i,a)=>{r.has(i)&&r.has(a)&&n.addUndirectedEdgeWithKey(e,i,a,t)}),n}function Ju(e,t,n,r,i){let a=e.mapNodes((e,t)=>({node:e,x:Number(t.x)||0,y:Number(t.y)||0})),o=Math.min(...a.map(({x:e})=>e)),s=Math.max(...a.map(({x:e})=>e)),c=Math.min(...a.map(({y:e})=>e)),l=Math.max(...a.map(({y:e})=>e)),u=(o+s)/2,d=(c+l)/2,f=Math.max(s-o,l-c,1),p=i*2/f;a.forEach(({node:e,x:i,y:a})=>t.mergeNodeAttributes(e,{x:n+(i-u)*p,y:r+(a-d)*p}))}function Yu(e,t){let n=Math.PI*(3-Math.sqrt(5));for(let r=1;r<2e4;r+=1){let i=Math.sqrt(r)*4.5,a={x:Math.cos(r*n)*i,y:Math.sin(r*n)*i};if(t.every(t=>Math.hypot(a.x-t.x,a.y-t.y)>=e+t.radius+6))return a}return{x:t.reduce((e,t)=>Math.max(e,t.x+t.radius),0)+e+6,y:0}}function Xu(e){return Au[Zu(e)%Au.length]}function Zu(e){return[...e].reduce((e,t)=>Math.imul(e^t.charCodeAt(0),16777619)>>>0,2166136261)}function Qu(e){return e.replace(/[-_]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function $u(e){let t=Zu(e);return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}function ed(e,t){let[n,r]=(0,E.useState)(e);return(0,E.useEffect)(()=>{if(Object.is(n,e))return;let i=setTimeout(()=>r(e),t);return()=>clearTimeout(i)},[t,n,e]),n}var td=Object.freeze({hiddenCategories:[],showIsolated:!1,showLabels:!0}),nd=v({scope:`vault`,name:`graphPreferences`,fallback:{...td},parse:e=>{let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))return;let n=t;return{hiddenCategories:Array.isArray(n.hiddenCategories)?n.hiddenCategories.filter(e=>typeof e==`string`):[],showIsolated:n.showIsolated===!0,showLabels:n.showLabels!==!1}}});function rd(e){return{...g(nd,{vaultId:e})}}function id(e,t){y(nd,t,{vaultId:e})}var ad=[`--ui-text-muted`,`--border-strong`,`--text-soft`,`--surface-active`,`--text-faint`,`--surface`,`--accent`,`--accent-border-soft`,`--ui-text-strong`,`--text-disabled`];function od(e){return e.enabled===!1?(0,B.jsx)(`main`,{className:`main-content content-full-size graph-view`,children:(0,B.jsx)(l,{feature:w,vaultId:e.vaultId,children:`Enable Graph for this vault to explore its notes and links as a graph.`})}):(0,B.jsx)(sd,{...e})}function sd({vaultId:e,entityRevision:t,onSummaryChange:n,onOpenNote:r}){let i=s(),[a,c]=(0,E.useState)(),[l,d]=(0,E.useState)(()=>rd(e)),[f,p]=(0,E.useState)(!0),[m,h]=(0,E.useState)(),[g,_]=(0,E.useState)(),[v,y]=(0,E.useState)();(0,E.useEffect)(()=>{d(rd(e)),y(void 0),_(void 0),ie.current=void 0},[e]);let b=ed(t,1500);(0,E.useEffect)(()=>{let t=new AbortController;return p(!0),h(void 0),Hi({vault:e,centerId:v,depth:2,limit:v?1500:4e3},(e,n)=>C(e,{...n,signal:t.signal})).then(e=>{c(e),n(`${e.scope.mode===`neighborhood`?`Local graph · `:``}${e.meta.returnedNodes.toLocaleString()} nodes · ${e.meta.returnedEdges.toLocaleString()} relationships`)}).catch(e=>{t.signal.aborted||h(e instanceof Error?e.message:String(e))}).finally(()=>{t.signal.aborted||p(!1)}),()=>t.abort()},[v,b,n,e]);let x=_u(e,a,b),S=(0,E.useRef)(null),w=(0,E.useMemo)(()=>yu(x.schema),[x.schema]),T=x.result?.status===`ok`?x.result:void 0,ee=(0,E.useMemo)(()=>a&&T?bu(a,T.nodeIds):a,[a,T]),te=(0,E.useMemo)(()=>new Set(l.hiddenCategories),[l.hiddenCategories]),ne=se(ad),re=(0,E.useMemo)(()=>({missing:ne[`--text-disabled`],label:ne[`--text-soft`],edge:ne[`--border-strong`]}),[ne]),ie=(0,E.useRef)(void 0),ae=(0,E.useMemo)(()=>{if(!ee)return;let e={hiddenCategories:te,showIsolated:!!T||l.showIsolated,neutrals:re,...T?{isolatedNodeSize:5}:{}},t=ie.current,n=t&&Uu(t,ee,e)?Wu(t,ee,e):Hu(ee,e);return ie.current=n,n},[ee,te,l.showIsolated,T,re]),oe=a?.nodes.find(e=>e.id===g),ce=[...a?.meta.truncated?[`Limited to ${a.scope.limit.toLocaleString()} nodes.`]:[],...a?.providerErrors?.map(e=>`${e.provider}: ${e.message}`)??[]];function le(t){d(n=>{let r={...n,...t};return id(e,r),r})}function ue(e){let t=new Set(te);t.has(e)?t.delete(e):t.add(e),le({hiddenCategories:[...t]})}function de(e,t){_(e);let n=a?.nodes.find(t=>t.id===e);n?.exists&&n.provider===`notes`&&n.kind===`note`?r(e,t):i.warning(n?.exists?`The ${n.kind} node '${n.label}' has no note to edit.`:`The unresolved node '${e}' has no note to edit.`)}function D(e){_(e),y(e)}function fe(e){let t=a?.nodes.find(t=>t.id===e);if(t){let e=t.kind===`note`&&t.entityType?`entity:${t.entityType}`:`kind:${t.kind}`,n=l.hiddenCategories.filter(t=>t!==e),r=t.degree===0&&!l.showIsolated;(n.length!==l.hiddenCategories.length||r)&&le({hiddenCategories:n,showIsolated:l.showIsolated||r})}_(e)}function pe(){x.setOpen(!1),requestAnimationFrame(()=>S.current?.focus())}return(0,B.jsx)(`main`,{className:`main-content content-full-size graph-view`,children:(0,B.jsxs)(`section`,{className:`graph-stage`,"aria-label":`Knowledge graph visualization`,children:[a&&ee&&ae&&ae.graph.order>0&&(0,B.jsxs)(Vi,{graph:ae.graph,className:`sigma-container`,settings:{defaultNodeColor:ne[`--ui-text-muted`],defaultEdgeColor:ne[`--border-strong`],labelColor:{attribute:`labelColor`,color:ne[`--text-soft`]},labelFont:`Inter, ui-sans-serif, system-ui, sans-serif`,labelSize:10,labelDensity:.3,labelGridCellSize:110,labelRenderedSizeThreshold:l.showLabels?4:2**53-1,hideLabelsOnMove:!0,itemSizesReference:`screen`,defaultDrawNodeHover:(e,t,n)=>ld(e,t,n,ne),renderEdgeLabels:!1,zIndex:!0,minCameraRatio:.04,maxCameraRatio:12},children:[(0,B.jsx)(cd,{focusedNodeId:g,colors:ne,onActivate:de,onClear:()=>_(void 0)}),(0,B.jsx)(qi,{data:ee,categories:ae.categories,hiddenCategories:te,showIsolated:l.showIsolated,showLabels:l.showLabels,localMode:a.scope.mode===`neighborhood`,selectedNode:oe,onLocate:fe,onShowLocalGraph:D,onShowFull:()=>y(void 0),onShowIsolatedChange:e=>le({showIsolated:e}),onShowLabelsChange:e=>le({showLabels:e}),onToggleCategory:ue,onShowAllCategories:()=>le({hiddenCategories:[]}),onShowNotesOnly:()=>le({hiddenCategories:ae.categories.filter(e=>!e.id.startsWith(`entity:`)&&e.id!==`kind:note`).map(e=>e.id)}),queryOpen:x.open,queryActive:!!x.result,queryToggleRef:S,onToggleQuery:()=>x.open?pe():x.setOpen(!0)})]},`${e}:${a.scope.mode}:${a.scope.centerId??`full`}:${T?x.appliedQuery:``}`),f&&!a?(0,B.jsxs)(o,{status:`loading`,className:`graph-state`,children:[(0,B.jsx)(`span`,{className:`graph-loader`}),`Laying out graph…`]}):m?(0,B.jsx)(o,{status:`error`,className:`graph-state`,children:m}):a&&ae?.graph.order===0?T?(0,B.jsx)(o,{status:`empty`,className:`graph-state`,action:!x.open&&(0,B.jsx)(u,{size:`small`,onClick:()=>x.setOpen(!0),children:`Edit query`}),children:`The query returned no nodes to show.`}):(0,B.jsx)(o,{status:`empty`,className:`graph-state`,children:`No nodes match the current graph filters.`}):null,(0,B.jsxs)(`div`,{className:`graph-overlay-stack`,children:[x.open&&a&&(0,B.jsx)(au,{draft:x.draft,result:x.result,schema:x.schema,source:x.source,ready:x.ready,examples:w,onDraftChange:x.setDraft,onRun:x.run,onClear:x.clear,onClose:pe}),a&&ae&&!f&&!x.open&&(0,B.jsxs)(`p`,{className:`graph-layout-summary`,children:[ae.visibleNodes.toLocaleString(),` shown`,T?` · filtered by a query`:!l.showIsolated&&a.meta.isolatedNodes?` · ${a.meta.isolatedNodes.toLocaleString()} unconnected hidden`:``]}),ce.length>0&&(0,B.jsx)(`div`,{className:`graph-warning-stack`,role:`status`,"aria-label":`Graph warnings`,children:ce.map(e=>(0,B.jsx)(`p`,{className:`graph-warning`,children:e},e))})]})]})})}function cd({focusedNodeId:e,colors:t,onActivate:n,onClear:r}){let i=Ri(),a=Ni(),o=Mi(),{gotoNode:s}=Bi({duration:220}),[c,l]=(0,E.useState)();return(0,E.useEffect)(()=>{if(!e||!o.getGraph().hasNode(e))return;let t=0,n=requestAnimationFrame(()=>{t=requestAnimationFrame(()=>s(e))});return()=>{cancelAnimationFrame(n),cancelAnimationFrame(t)}},[e,s,o]),(0,E.useEffect)(()=>{let n=c??e;if(!n||!o.getGraph().hasNode(n)){a({nodeReducer:null,edgeReducer:null});return}let r=o.getGraph(),i=new Set(r.neighbors(n)),s=new Set([...i].sort((e,t)=>r.degree(t)-r.degree(e)||e.localeCompare(t)).slice(0,20));a({nodeReducer:(e,r)=>{let a=r;return e===n?{...a,size:Math.max(5,a.size*1.5),highlighted:!0,forceLabel:!0,zIndex:2}:i.has(e)?{...a,size:a.size*1.2,forceLabel:s.has(e),zIndex:1}:{...a,size:a.size*.78,color:t[`--surface-active`],labelColor:t[`--text-faint`]}},edgeReducer:(e,i)=>{let a=i,[o,s]=r.extremities(e);return o===n||s===n?{...a,color:`${t[`--accent`]}cc`,size:Math.max(1.25,a.size*3),zIndex:1}:{...a,color:`${t[`--border-strong`]}40`,size:Math.max(.12,a.size*.6)}}})},[t,e,c,a,o]),(0,E.useEffect)(()=>i({clickNode:({node:e,event:t})=>n(e,ce(t.original)),clickStage:r,enterNode:({node:e})=>l(e),leaveNode:()=>l(void 0)}),[n,r,i]),null}function ld(e,t,n,r){let i=typeof t.label==`string`?t.label:``,a=Math.max(11,n.labelSize+1),o=n.labelColor.color??r[`--ui-text-strong`];e.save(),e.font=`${n.labelWeight} ${a}px ${n.labelFont}`;let s=i?e.measureText(i).width:0,c=t.x+t.size+7,l=t.y-(a+8)/2;e.beginPath(),e.arc(t.x,t.y,t.size+2,0,Math.PI*2),e.fillStyle=`${r[`--surface`]}e8`,e.fill(),e.lineWidth=1.5,e.strokeStyle=t.color??r[`--accent`],e.stroke(),i&&(e.beginPath(),e.roundRect(c,l,s+14,a+8,5),e.fillStyle=`${r[`--surface`]}f2`,e.fill(),e.lineWidth=1,e.strokeStyle=`${r[`--accent-border-soft`]}33`,e.stroke(),e.fillStyle=o,e.fillText(i,c+7,t.y+a*.35)),e.restore()}export{od as GraphExplorer};
|