@bendyline/gezel-service 1.0.7 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/gezeld.js +6253 -3616
- package/dist/handboek-content/whats-new/1.26224.md +1 -0
- package/dist/handboek-content/whats-new/1.26226.md +1 -0
- package/dist/handboek-content/whats-new/1.26231.md +1 -0
- package/dist/handboek-content/whats-new/1.26234.md +1 -0
- package/dist/handboek-content/whats-new/1.26237.md +1 -0
- package/dist/handboek-content/whats-new/1.26244.md +2 -1
- package/dist/handboek-content/whats-new/1.26247.md +88 -0
- package/dist/handboek-content/whats-new/whats-new-index.md +1 -0
- package/dist/index-store/static-index-worker.js +17 -1
- package/dist/index.d.ts +473 -209
- package/dist/index.js +6251 -3614
- package/dist/memory/embed-worker.js +58 -2
- package/dist/memory/image-embed-worker.js +8 -0
- package/dist/providers/llama-cpp/gguf-metadata-worker.js +2 -0
- package/dist/providers/mlx/python/gezel_mlx_server.py +18 -18
- package/dist/ui/assets/AmbientDashboardCard-Cf5fi_fY.js +1 -0
- package/dist/ui/assets/{AudioEngineSettings-BDrNIGGm.js → AudioEngineSettings-D3L7HOHe.js} +1 -1
- package/dist/ui/assets/{BenchmarksView-CHyujjs8.js → BenchmarksView-B68hrLCl.js} +1 -1
- package/dist/ui/assets/CatalogBrowser-DEM9t7Es.js +1 -0
- package/dist/ui/assets/{ChannelsSettings-Be_W1mr8.js → ChannelsSettings-DtK_k0Ul.js} +1 -1
- package/dist/ui/assets/ChatTimelineView-CQ4Sf4Ip.js +7 -0
- package/dist/ui/assets/ConfirmDialog-Dt1ed4Fh.js +1 -0
- package/dist/ui/assets/ConnectedAppsPanel-Cl8LEkrt.js +1 -0
- package/dist/ui/assets/CraftbookEditor-DEQRlQ2p.js +1 -0
- package/dist/ui/assets/{CraftbookScriptEditorView-DXIZYZT3.js → CraftbookScriptEditorView-DhXkkIdK.js} +1 -1
- package/dist/ui/assets/{CraftbookTabContent-Bm7t_b37.js → CraftbookTabContent-_oIdpQTG.js} +1 -1
- package/dist/ui/assets/{CraftbookToolsetSetup-DTEA-3K3.js → CraftbookToolsetSetup-BKg136L1.js} +1 -1
- package/dist/ui/assets/{CraftbooksView-C4X99TTe.js → CraftbooksView-Dm2zH-nW.js} +2 -2
- package/dist/ui/assets/{DiffpackReviewView-ClcNxtmF.js → DiffpackReviewView-EFLGJnwr.js} +1 -1
- package/dist/ui/assets/DocumentDetail-ClDRj2N-.js +1 -0
- package/dist/ui/assets/DocumentsView-ny9oieg2.js +1 -0
- package/dist/ui/assets/DropdownMenu-S4d9-3j3.js +1 -0
- package/dist/ui/assets/Ds4Settings-CeWlm5Vf.js +1 -0
- package/dist/ui/assets/EmbeddedChat-Hjrrgpao.js +1 -0
- package/dist/ui/assets/{FaceRecognitionCard-D3hdc7uU.js → FaceRecognitionCard-D7ufKqjI.js} +1 -1
- package/dist/ui/assets/FileMapView-DRjf59RH.js +1 -0
- package/dist/ui/assets/{FoldersSettings-BcNzl4vT.js → FoldersSettings-DDUhaFio.js} +1 -1
- package/dist/ui/assets/GezelDetail-Cph6pVGb.js +1 -0
- package/dist/ui/assets/{GezelJsonEditor-fOvYclu9.js → GezelJsonEditor-7vDGyBib.js} +1 -1
- package/dist/ui/assets/{GezellenView-BTzhHrxi.js → GezellenView-DQhcO1CP.js} +1 -1
- package/dist/ui/assets/{GildeUpdatesCard-Bq6XEpLP.js → GildeUpdatesCard-UKKNm_U8.js} +1 -1
- package/dist/ui/assets/{GithubSignInChip-CnlTCG8G.js → GithubSignInChip-DjM3qZsL.js} +1 -1
- package/dist/ui/assets/{HandboekMediaProvider-BfQW8_Nr.js → HandboekMediaProvider-DixaXTAH.js} +1 -1
- package/dist/ui/assets/HandboekView-BeNQqho9.js +1 -0
- package/dist/ui/assets/HistoryView-E2szGNGS.js +1 -0
- package/dist/ui/assets/{HomeView-CB_5TJIp.css → HomeView-CNeqCFPc.css} +1 -1
- package/dist/ui/assets/HomeView-CkiS3DXy.js +1 -0
- package/dist/ui/assets/{ImageEngineSettings-BpMfQy4f.js → ImageEngineSettings-BCKT7Gvi.js} +1 -1
- package/dist/ui/assets/{ImageRecognitionSettings-Ct-7-Oas.js → ImageRecognitionSettings-DD6syFez.js} +1 -1
- package/dist/ui/assets/IncompleteDownloads-BiPaaahS.js +1 -0
- package/dist/ui/assets/InstallProgressRow-DyKOI4MU.js +1 -0
- package/dist/ui/assets/KnowledgeCatalogsCard-B132vzRa.js +1 -0
- package/dist/ui/assets/KnowledgeView-CtPuIlN4.js +1 -0
- package/dist/ui/assets/LlamaCppSettings-D6zHcu4W.js +1 -0
- package/dist/ui/assets/{MarkdownField-D-0Zw7gM.js → MarkdownField-CK8K3fzj.js} +1 -1
- package/dist/ui/assets/MemoriesTree-DzjXzIrM.js +1 -0
- package/dist/ui/assets/{MicrophoneSettings-BIaFxyY_.js → MicrophoneSettings-1FH83SCq.js} +1 -1
- package/dist/ui/assets/MlxSettings-BYxUqFnJ.js +1 -0
- package/dist/ui/assets/ModelPicker-DoXPfQkQ.js +1 -0
- package/dist/ui/assets/{NewScriptDialog-D-gkY8TS.js → NewScriptDialog-C5X-7PMt.js} +1 -1
- package/dist/ui/assets/NewTaskDialog-Cyqtmigv.js +2 -0
- package/dist/ui/assets/{OllamaSettings-oIE2Mech.js → OllamaSettings-DkjmA-sB.js} +1 -1
- package/dist/ui/assets/ProjectChat-YEqUME6k.js +5 -0
- package/dist/ui/assets/{ProjectConnectionsTab-BZqp-oKI.js → ProjectConnectionsTab-dFCJpW93.js} +1 -1
- package/dist/ui/assets/ProjectGitStatusBar-CjZxG54t.js +1 -0
- package/dist/ui/assets/{ProjectGithubView-w8suLCsA.js → ProjectGithubView-CQ4-tmPx.js} +1 -1
- package/dist/ui/assets/{ProjectMailTab-DGo7eyB8.js → ProjectMailTab-NaScsZJf.js} +1 -1
- package/dist/ui/assets/ProjectOverviewView-ChjxbQas.js +1 -0
- package/dist/ui/assets/{ProjectTimeline-DRe3D9qY.js → ProjectTimeline-BZpdCisR.js} +1 -1
- package/dist/ui/assets/ProjectsView-J77ECk6V.js +7 -0
- package/dist/ui/assets/{RecommendedBadge-BKiDixnB.js → RecommendedBadge-D0m68PAu.js} +1 -1
- package/dist/ui/assets/{RemoteServersPanel-DGyl6-Rg.js → RemoteServersPanel-BdLOoORu.js} +1 -1
- package/dist/ui/assets/ScriptEditorTabs-BFvIiDFZ.js +2 -0
- package/dist/ui/assets/ScriptEditorView-B09rm1vz.js +5 -0
- package/dist/ui/assets/{ScriptsView-WQc28TmQ.js → ScriptsView-BvNAJXpo.js} +1 -1
- package/dist/ui/assets/{SecurityComplianceSettings-DsMEA4J3.js → SecurityComplianceSettings-DzGOnptO.js} +1 -1
- package/dist/ui/assets/SessionSwitcher-6okzcxT7.js +1 -0
- package/dist/ui/assets/SettingsView-Dur4dLhW.js +3 -0
- package/dist/ui/assets/SquisqIntegration-6v3yNOIP.js +2 -0
- package/dist/ui/assets/{StorageCleanupDialog-DHqwyMZZ.js → StorageCleanupDialog-OQlomMJD.js} +1 -1
- package/dist/ui/assets/{StorageUsageCard-CdT6SU51.js → StorageUsageCard-f6c6qTbM.js} +1 -1
- package/dist/ui/assets/Tabs-jE0Z5Tzd.js +1 -0
- package/dist/ui/assets/TaskTabContent-0w3kAUWR.js +1 -0
- package/dist/ui/assets/TasksView-BVMT4BAY.js +1 -0
- package/dist/ui/assets/{TerminalCodeEditor-77pBm6f3.js → TerminalCodeEditor-DO7zLKy-.js} +2 -2
- package/dist/ui/assets/ToolsetsEditor-Bb1wD5mV.js +8 -0
- package/dist/ui/assets/TransformToolbarButton-BWYkEB0d.js +5 -0
- package/dist/ui/assets/UnrecognizedModels-HtdMZUqK.js +1 -0
- package/dist/ui/assets/{VideoEngineSettings-DzMeINuv.js → VideoEngineSettings-Dq8Nw_tK.js} +1 -1
- package/dist/ui/assets/{WorkspaceIndexPane-DU4yd4Ai.js → WorkspaceIndexPane-fpDz4MwZ.js} +1 -1
- package/dist/ui/assets/{api-BX5xXiFs.js → api-BPraLwsh.js} +1 -1
- package/dist/ui/assets/chat-thread-memory-Be48zsyG.js +1 -0
- package/dist/ui/assets/chunk-6ECMNUIP-DDVjPyfK.js +15 -0
- package/dist/ui/assets/{chunk-6N2J7C2B-B5QIrD9m.js → chunk-6N2J7C2B-CsppiLVr.js} +1 -1
- package/dist/ui/assets/{chunk-A6N6IN3I-DXok09eC.js → chunk-A6N6IN3I-ofeM4l8g.js} +1 -1
- package/dist/ui/assets/chunk-B7GEAZBI-Divd2h1k.js +1 -0
- package/dist/ui/assets/chunk-DXYWKZ52-BXcAlClu.js +1 -0
- package/dist/ui/assets/chunk-FLR2ARKC-D7wrvQgT.js +2 -0
- package/dist/ui/assets/chunk-IIQYS2YH-DKZhWMpn.js +1 -0
- package/dist/ui/assets/{chunk-ILCJ3WFD-WRukZ7R1.js → chunk-ILCJ3WFD-CLZxw4Ge.js} +3 -3
- package/dist/ui/assets/chunk-OBADJV7C-CDVOcmYt.js +1 -0
- package/dist/ui/assets/chunk-Q77KNJIN-BIDRf0aP.js +6 -0
- package/dist/ui/assets/chunk-S5PCVMKU-Df5XzhSE.js +6 -0
- package/dist/ui/assets/chunk-UBFT2CDQ-FexGDigd.js +31 -0
- package/dist/ui/assets/{chunk-USU6HTKB-D5FmDzJU.js → chunk-USU6HTKB-B_p-YcDp.js} +1 -1
- package/dist/ui/assets/chunk-VKXOZTYP-BoVvWSBR.js +5 -0
- package/dist/ui/assets/{chunk-6RQOV3B3-CwvKotJw.js → chunk-VPWPEMZJ-DRKoa_j0.js} +1 -1
- package/dist/ui/assets/{chunk-WATAOG4Y-DXg2lov5.js → chunk-WATAOG4Y-C1EXVPmG.js} +1 -1
- package/dist/ui/assets/{container-B7jJtK5V.js → container-Ce94efbg.js} +1 -1
- package/dist/ui/assets/csv-62UGQMzZ.js +1 -0
- package/dist/ui/assets/data-B2kHjlc5.js +1 -0
- package/dist/ui/assets/dist-B9-VrAP8.js +2 -0
- package/dist/ui/assets/dist-BaHut5iX.js +2 -0
- package/dist/ui/assets/dist-BqGwkOe5.js +225 -0
- package/dist/ui/assets/dist-ZnIgkoEi.js +4 -0
- package/dist/ui/assets/{dist-BHl1ZAVG.js → dist-l6uUFZMV.js} +2 -2
- package/dist/ui/assets/dist-pLLFUPO-.js +1 -0
- package/dist/ui/assets/{doc-s6H7T0IO.js → doc-Dr5K49bx.js} +28 -28
- package/dist/ui/assets/document-companion-BQk2kS0F.js +1 -0
- package/dist/ui/assets/document-import-QoM9UxJr.js +1 -0
- package/dist/ui/assets/docx-sXa1Rf41.js +2 -0
- package/dist/ui/assets/{epub-B98SgHBz.js → epub-RopMP0ec.js} +4 -4
- package/dist/ui/assets/{export-options-Bu-tI6og.js → export-options-f7PKjEBb.js} +1 -1
- package/dist/ui/assets/extract-UTAOG7LV-4WDRw1o4.js +1 -0
- package/dist/ui/assets/file-browser-c2tf4MIb.js +5 -0
- package/dist/ui/assets/html-BGVOMhkv.js +253 -0
- package/dist/ui/assets/icons-DWaUNQbT.js +1 -0
- package/dist/ui/assets/images-JLBFCDD4-6JitW0hD.js +1 -0
- package/dist/ui/assets/index-B8NcxqcR.css +1 -0
- package/dist/ui/assets/index-C0DYtvfg.js +34 -0
- package/dist/ui/assets/index-J8TOMdvV.js +2 -0
- package/dist/ui/assets/{infer-kCLH1C8z.js → infer-LEGOsu64.js} +2 -2
- package/dist/ui/assets/ironcalc-BAi5gOlE.js +3 -0
- package/dist/ui/assets/layouts-2A7QNF6Y-CVwP7noP.js +1 -0
- package/dist/ui/assets/{mail-link-CI6YD6k2.js → mail-link-DXkmCd5b.js} +1 -1
- package/dist/ui/assets/markdown-baseline-9B52XlX2.js +1 -0
- package/dist/ui/assets/{markdown-Bi9b5f5Y.js → markdown-ryKA_OmY.js} +1 -1
- package/dist/ui/assets/materialize-A34OZGEU-xNNKzytx.js +1 -0
- package/dist/ui/assets/model-inventory-ykSm_IT5.js +1 -0
- package/dist/ui/assets/{model-quantization-BDzrELN_.js → model-quantization-CLO7XLoF.js} +1 -1
- package/dist/ui/assets/{monaco-base-BiVSa1J-.js → monaco-base-B1H1U1Sw.js} +1 -1
- package/dist/ui/assets/{monaco-setup-UeltVkg_.js → monaco-setup-DjhrGQui.js} +1 -1
- package/dist/ui/assets/{new-project-meta-0xhggGA_.js → new-project-meta-_f9sfcRX.js} +1 -1
- package/dist/ui/assets/outside-in-D73N1g_b.js +3 -0
- package/dist/ui/assets/{pdf-DgTjy3rN.js → pdf-BOjVDlCK.js} +3 -3
- package/dist/ui/assets/{pending-drafts-YVW6X55O.js → pending-drafts-B11MKQ9R.js} +1 -1
- package/dist/ui/assets/{poppetje-Ce-02Aqi.js → poppetje-DLB8uevw.js} +2 -2
- package/dist/ui/assets/pptx-BuxyNxQh.js +6 -0
- package/dist/ui/assets/primitives-CWrGZpPI.js +41 -0
- package/dist/ui/assets/run-export-ChaMXrKS.js +23 -0
- package/dist/ui/assets/squisq-formats-aAdypXoy.js +1 -0
- package/dist/ui/assets/standalone-source-q_Zzd1bd.js +11 -0
- package/dist/ui/assets/storage-D8pE2zg0.js +1 -0
- package/dist/ui/assets/styles-BhnF3s2q.css +1 -0
- package/dist/ui/assets/styles-CKVKwqoQ.js +550 -0
- package/dist/ui/assets/table-fcouR4db.js +1 -0
- package/dist/ui/assets/{terminal-monaco-setup-DNoK2tN4.js → terminal-monaco-setup-BAzrVzeR.js} +1 -1
- package/dist/ui/assets/{useCompactLayout-BarJPYcv.js → useCompactLayout-Dtolvzye.js} +0 -0
- package/dist/ui/assets/{useCopilotAvailability-BH1nLXQI.js → useCopilotAvailability-3xZvKgTF.js} +1 -1
- package/dist/ui/assets/{useDiffpacks-CK8W_OD_.js → useDiffpacks-Dsnr0wtX.js} +1 -1
- package/dist/ui/assets/{useGitSync-DWxX5-7K.js → useGitSync-BCTptQsp.js} +1 -1
- package/dist/ui/assets/{useShowWorkInProgressFeatures-DwwviLRO.js → useShowWorkInProgressFeatures-BhDNuQiU.js} +1 -1
- package/dist/ui/assets/{useTotalRamBytes-WoN_mi-V.js → useTotalRamBytes-DIx-_pf8.js} +1 -1
- package/dist/ui/assets/wasm-DdxEDD2H.js +1 -0
- package/dist/ui/assets/wasm_bg-DW9Xt_vt.wasm +0 -0
- package/dist/ui/assets/xlsx-DyBGuAO1.js +4 -0
- package/dist/ui/index.html +19 -18
- package/package.json +11 -11
- package/dist/ui/assets/AmbientDashboardCard-C1Ee-FKZ.js +0 -1
- package/dist/ui/assets/CatalogBrowser-Bz8ZtxPn.js +0 -1
- package/dist/ui/assets/ChatTimelineView-Do9EryEH.js +0 -7
- package/dist/ui/assets/ConfirmDialog-BHFs6vmJ.js +0 -1
- package/dist/ui/assets/ConnectedAppsPanel-BtMayq0R.js +0 -1
- package/dist/ui/assets/CraftbookEditor-D5jTzWwF.js +0 -1
- package/dist/ui/assets/DocumentDetail-CPU51d04.js +0 -1
- package/dist/ui/assets/DocumentsView-B6OyjvJ0.js +0 -1
- package/dist/ui/assets/DropdownMenu-D5fCzIrh.js +0 -1
- package/dist/ui/assets/Ds4Settings-CrUM_KGP.js +0 -1
- package/dist/ui/assets/EmbeddedChat-ue9ia-WY.js +0 -1
- package/dist/ui/assets/FileMapView-CxvfDLGA.js +0 -1
- package/dist/ui/assets/GezelDetail-DHuqBK55.js +0 -1
- package/dist/ui/assets/HandboekView-CPnnyj29.js +0 -1
- package/dist/ui/assets/HistoryView-B4VAfEMe.js +0 -1
- package/dist/ui/assets/HomeView-ccH60J6f.js +0 -1
- package/dist/ui/assets/KnowledgeCatalogsCard-Bi5Rx9Iz.js +0 -1
- package/dist/ui/assets/KnowledgeView-DAwjwLZo.js +0 -1
- package/dist/ui/assets/LlamaCppSettings-Ceyk9pDP.js +0 -1
- package/dist/ui/assets/MemoriesTree-BKZEPJpm.js +0 -1
- package/dist/ui/assets/MlxSettings-CG3wfuc3.js +0 -1
- package/dist/ui/assets/ModelPicker-CCBVjLMS.js +0 -1
- package/dist/ui/assets/NewPathDialog-D4jnNBfP.js +0 -1
- package/dist/ui/assets/NewTaskDialog-Ox9D612Z.js +0 -2
- package/dist/ui/assets/ProjectChat-DMwKnkW-.js +0 -5
- package/dist/ui/assets/ProjectGitStatusBar-C6bkCSby.js +0 -1
- package/dist/ui/assets/ProjectOverviewView-NNwXd_QQ.js +0 -1
- package/dist/ui/assets/ProjectsView-SBPgYOq8.js +0 -7
- package/dist/ui/assets/ScriptEditorTabs-paocQ6dj.js +0 -2
- package/dist/ui/assets/ScriptEditorView-N9zSLqqi.js +0 -5
- package/dist/ui/assets/SessionSwitcher-C8te7YSe.js +0 -1
- package/dist/ui/assets/SettingsView-Brl4JQkW.js +0 -3
- package/dist/ui/assets/Tabs-BAY1Q79B.js +0 -1
- package/dist/ui/assets/TaskTabContent-CNPJ4DQj.js +0 -1
- package/dist/ui/assets/TasksView-DuMjFS8S.js +0 -1
- package/dist/ui/assets/ToolsetsEditor-BdxHnIBj.js +0 -8
- package/dist/ui/assets/TransformToolbarButton-CVg5nz36.js +0 -5
- package/dist/ui/assets/UnrecognizedModels-Cw9Ku_bW.js +0 -1
- package/dist/ui/assets/chat-thread-memory-CZGcwgGo.js +0 -1
- package/dist/ui/assets/chunk-6ECMNUIP-C1kohb1U.js +0 -15
- package/dist/ui/assets/chunk-AONELFLA-Cv2nS9ga.js +0 -1
- package/dist/ui/assets/chunk-IIQYS2YH-Dxg6MAfT.js +0 -1
- package/dist/ui/assets/chunk-MIKKUKOD-XIkmalSN.js +0 -31
- package/dist/ui/assets/chunk-NNJLSQPW-DJA6camf.js +0 -5
- package/dist/ui/assets/chunk-S5PCVMKU-DbCZ5AUH.js +0 -6
- package/dist/ui/assets/csv-xmd1_Aqd.js +0 -4
- package/dist/ui/assets/dist-BPx-FyRH.js +0 -222
- package/dist/ui/assets/dist-Bvo52IGx.js +0 -1
- package/dist/ui/assets/dist-D5aoNQwk.js +0 -2
- package/dist/ui/assets/docx-Cj4A9MhC.js +0 -2
- package/dist/ui/assets/extract-UTAOG7LV-C4b7ycaL.js +0 -1
- package/dist/ui/assets/file-browser-80qWoVju.js +0 -5
- package/dist/ui/assets/html-C9TlzI57.js +0 -253
- package/dist/ui/assets/icons-C9dD-bDi.js +0 -1
- package/dist/ui/assets/images-ESPQKVTW-D7SgdVJ_.js +0 -1
- package/dist/ui/assets/index-D1m4Wx8V.css +0 -1
- package/dist/ui/assets/index-DXWR4qW1.js +0 -34
- package/dist/ui/assets/layouts-2A7QNF6Y-De2t-YXl.js +0 -1
- package/dist/ui/assets/markdown-baseline-HMqF2ChK.js +0 -1
- package/dist/ui/assets/outside-in-BFVUUcLa.js +0 -3
- package/dist/ui/assets/pptx-6ChgUEf4.js +0 -6
- package/dist/ui/assets/primitives-DEsn1shf.js +0 -41
- package/dist/ui/assets/run-export-BrYhHj1O.js +0 -23
- package/dist/ui/assets/standalone-source-D6mbpa3h.js +0 -11
- package/dist/ui/assets/storage-fn4FCEVK.js +0 -1
- package/dist/ui/assets/styles-C0EoNJbk.css +0 -1
- package/dist/ui/assets/styles-CKr_yrbn.js +0 -541
- package/dist/ui/assets/xlsx-DH7sTb3W.js +0 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{i as t,l as n,n as r,p as i,s as a,t as o}from"./chunk-O7JILDEF-CqcO1qaI.js";import{a as s,c,d as l,f as u,l as d,n as f,o as p,p as m,r as h,s as g,u as _}from"./chunk-BAOV476U-CEOFYt8X.js";import{o as v}from"./chunk-4VOD55SX-BFSSw0c8.js";import{A as y,C as b,D as x,E as S,M as C,O as w,_ as T,c as E,j as D,k as O,l as k,o as A,r as ee,t as te,v as ne,w as re,y as ie}from"./chunk-GAZKTT4R-BkP6-w3z.js";import{A as ae,C as oe,D as se,E as ce,F as le,I as ue,L as de,N as j,R as fe,S as pe,T as me,j as he,k as ge,n as _e,w as ve}from"./chunk-MIKKUKOD-XIkmalSN.js";import{i as ye,n as be,r as xe,t as Se}from"./chunk-XRW6P7IF-BeQQgMVK.js";import{r as Ce}from"./chunk-7ZAAICW4-BsCpYJH6.js";var we=new Set([`triangle`,`right-triangle`,`diamond`,`pentagon`,`hexagon`,`octagon`,`star`,`star4`,`star6`,`parallelogram`,`trapezoid`,`plus`,`chevron`,`arrow-right`,`arrow-left`,`arrow-up`,`arrow-down`,`double-arrow`,`callout`,`cylinder`,`cloud`,`heart`,`lightning`]);function M(e){return Math.round(e*10)/10}function N(e){if(e.length===0)return``;let[t,...n]=e;return`${`M ${M(t[0])} ${M(t[1])}`} ${n.map(([e,t])=>`L ${M(e)} ${M(t)}`).join(` `)} Z`}function Te(e,t,n,r,i,a){let o=[];for(let s=0;s<i;s++){let c=a+s*2*Math.PI/i;o.push([e+n*Math.cos(c),t+r*Math.sin(c)])}return o}function Ee(e,t,n,r,i,a){let o=[],s=-Math.PI/2;for(let c=0;c<i*2;c++){let l=c%2==0,u=s+c*Math.PI/i,d=l?n:n*a,f=l?r:r*a;o.push([e+d*Math.cos(u),t+f*Math.sin(u)])}return o}function De(e,t,n,r,i){let a=t+r/2,o=n+i/2,s=r/2,c=i/2,l=t+r,u=n+i;switch(e){case`triangle`:return N([[a,n],[l,u],[t,u]]);case`right-triangle`:return N([[t,n],[t,u],[l,u]]);case`diamond`:return N([[a,n],[l,o],[a,u],[t,o]]);case`pentagon`:return N(Te(a,o,s,c,5,-Math.PI/2));case`hexagon`:{let e=r*.25;return N([[t+e,n],[l-e,n],[l,o],[l-e,u],[t+e,u],[t,o]])}case`octagon`:{let e=Math.min(r,i)*.29;return N([[t+e,n],[l-e,n],[l,n+e],[l,u-e],[l-e,u],[t+e,u],[t,u-e],[t,n+e]])}case`star`:return N(Ee(a,o,s,c,5,.4));case`star4`:return N(Ee(a,o,s,c,4,.4));case`star6`:return N(Ee(a,o,s,c,6,.5));case`parallelogram`:{let e=r*.25;return N([[t+e,n],[l,n],[l-e,u],[t,u]])}case`trapezoid`:{let e=r*.25;return N([[t+e,n],[l-e,n],[l,u],[t,u]])}case`plus`:{let e=Math.min(r,i)/3,a=t+(r-e)/2,o=a+e,s=n+(i-e)/2,c=s+e;return N([[a,n],[o,n],[o,s],[l,s],[l,c],[o,c],[o,u],[a,u],[a,c],[t,c],[t,s],[a,s]])}case`chevron`:{let e=r*.25;return N([[t,n],[l-e,n],[l,o],[l-e,u],[t,u],[t+e,o]])}case`arrow-right`:return Oe(t,n,r,i,`right`);case`arrow-left`:return Oe(t,n,r,i,`left`);case`arrow-up`:return Oe(t,n,r,i,`up`);case`arrow-down`:return Oe(t,n,r,i,`down`);case`double-arrow`:{let e=r*.3,a=i*.4,s=o-a/2,c=o+a/2;return N([[t,o],[t+e,n],[t+e,s],[l-e,s],[l-e,n],[l,o],[l-e,u],[l-e,c],[t+e,c],[t+e,u]])}case`callout`:{let e=n+i*.78,a=t+r*.25;return`M ${M(t)} ${M(n)} L ${M(l)} ${M(n)} L ${M(l)} ${M(e)} L ${M(a+r*.12)} ${M(e)} L ${M(a)} ${M(u)} L ${M(a-r*.02)} ${M(e)} L ${M(t)} ${M(e)} Z`}case`cylinder`:{let e=i*.16;return`M ${M(t)} ${M(n+e)} A ${M(s)} ${M(e)} 0 0 1 ${M(l)} ${M(n+e)} L ${M(l)} ${M(u-e)} A ${M(s)} ${M(e)} 0 0 1 ${M(t)} ${M(u-e)} Z M ${M(t)} ${M(n+e)} A ${M(s)} ${M(e)} 0 0 0 ${M(l)} ${M(n+e)}`}case`cloud`:{let e=i*.5;return`M ${M(t+r*.2)} ${M(u)} A ${M(r*.2)} ${M(e)} 0 0 1 ${M(t+r*.15)} ${M(o)} A ${M(r*.2)} ${M(e)} 0 0 1 ${M(t+r*.45)} ${M(n+i*.2)} A ${M(r*.2)} ${M(e)} 0 0 1 ${M(t+r*.8)} ${M(n+i*.25)} A ${M(r*.18)} ${M(e)} 0 0 1 ${M(t+r*.85)} ${M(u)} Z`}case`heart`:{let e=n+i*.3;return`M ${M(a)} ${M(u)} C ${M(t-r*.1)} ${M(o)} ${M(t)} ${M(n)} ${M(a)} ${M(e)} C ${M(l)} ${M(n)} ${M(l+r*.1)} ${M(o)} ${M(a)} ${M(u)} Z`}case`lightning`:return N([[t+r*.55,n],[t+r*.2,n+i*.55],[t+r*.45,n+i*.55],[t+r*.3,u],[l,n+i*.4],[t+r*.55,n+i*.4]]);default:return null}}function Oe(e,t,n,r,i){let a=e+n,o=t+r,s=e+n/2,c=t+r/2;if(i===`right`||i===`left`){let s=n*.4,l=r*.5,u=c-l/2,d=c+l/2;return N(i===`right`?[[e,u],[a-s,u],[a-s,t],[a,c],[a-s,o],[a-s,d],[e,d]]:[[a,u],[e+s,u],[e+s,t],[e,c],[e+s,o],[e+s,d],[a,d]])}let l=r*.4,u=n*.5,d=s-u/2,f=s+u/2;return N(i===`down`?[[d,t],[f,t],[f,o-l],[a,o-l],[s,o],[e,o-l],[d,o-l]]:[[d,o],[f,o],[f,t+l],[a,t+l],[s,t],[e,t+l],[d,t+l]])}function ke(e,t){let n=t===`start`,r=e=>n?10-e:e,i=e=>`M ${r(0)} 0 L ${r(10)} 5 L ${r(0)} 10${e?` z`:``}`;switch(e){case`arrow`:return{d:i(!0),filled:!0};case`open`:return{d:i(!1),filled:!1};case`diamond`:return{d:`M 0 5 L 5 0 L 10 5 L 5 10 z`,filled:!0};case`square`:return{d:`M 1 1 L 9 1 L 9 9 L 1 9 z`,filled:!0};case`circle`:return{d:`M 0 5 A 5 5 0 1 0 10 5 A 5 5 0 1 0 0 5 z`,filled:!0};default:return null}}function Ae(e,t){let n=t.cx-e.cx,r=t.cy-e.cy;if(n===0&&r===0)return{x:e.cx,y:e.cy};let i=Math.abs(n)>0?e.rx/Math.abs(n):1/0,a=Math.abs(r)>0?e.ry/Math.abs(r):1/0,o=Math.min(i,a);return{x:e.cx+n*o,y:e.cy+r*o}}function je(e,t){return{start:Ae(e,t),end:Ae(t,e)}}function Me(e){let t=e.cx-e.rx,n=e.cx+e.rx,r=e.cy-e.ry,i=e.cy+e.ry;return[{port:`top`,x:e.cx,y:r},{port:`right`,x:n,y:e.cy},{port:`bottom`,x:e.cx,y:i},{port:`left`,x:t,y:e.cy},{port:`top-left`,x:t,y:r},{port:`top-right`,x:n,y:r},{port:`bottom-right`,x:n,y:i},{port:`bottom-left`,x:t,y:i}]}function Ne(e,t){let n=Math.max(0,Math.min(1,t.offset)),r=e.cx-e.rx,i=e.cx+e.rx,a=e.cy-e.ry,o=e.cy+e.ry;switch(t.side){case`top`:return{port:`top`,x:r+(i-r)*n,y:a};case`right`:return{port:`right`,x:i,y:a+(o-a)*n};case`bottom`:return{port:`bottom`,x:r+(i-r)*n,y:o};case`left`:return{port:`left`,x:r,y:a+(o-a)*n}}}function Pe(e,t){let n=Me(e)[0],r=1/0;for(let i of Me(e)){let e=Ie(i,t)+Le(i.port);e<r&&(n=i,r=e)}return n}function Fe(e,t){let n=Me(e)[0],r=Me(t)[0],i=1/0;for(let a of Me(e))for(let e of Me(t)){let t=Ie(a,e)+Le(a.port)+Le(e.port);t<i&&(n=a,r=e,i=t)}return{start:n,end:r}}function Ie(e,t){let n=e.x-t.x,r=e.y-t.y;return n*n+r*r}function Le(e){return e.includes(`-`)?.02:0}function Re(e,t,n){if(e===`straight`)return`M ${M(t.x)} ${M(t.y)} L ${M(n.x)} ${M(n.y)}`;if(e===`orthogonal`){let e=ze(t.port),r=ze(n.port);if(e===`vertical`&&r===`vertical`){let e=(t.y+n.y)/2;return`M ${M(t.x)} ${M(t.y)} L ${M(t.x)} ${M(e)} L ${M(n.x)} ${M(e)} L ${M(n.x)} ${M(n.y)}`}if(e===`vertical`&&r===`horizontal`)return`M ${M(t.x)} ${M(t.y)} L ${M(t.x)} ${M(n.y)} L ${M(n.x)} ${M(n.y)}`;if(e===`horizontal`&&r===`vertical`)return`M ${M(t.x)} ${M(t.y)} L ${M(n.x)} ${M(t.y)} L ${M(n.x)} ${M(n.y)}`;let i=(t.x+n.x)/2;return`M ${M(t.x)} ${M(t.y)} L ${M(i)} ${M(t.y)} L ${M(i)} ${M(n.y)} L ${M(n.x)} ${M(n.y)}`}let r=Math.hypot(n.x-t.x,n.y-t.y),i=Math.max(40,r/2),a=Be(t.port,{x:1,y:0}),o=Be(n.port,{x:-1,y:0});return`M ${M(t.x)} ${M(t.y)} C ${M(t.x+a.x*i)} ${M(t.y+a.y*i)}, ${M(n.x+o.x*i)} ${M(n.y+o.y*i)}, ${M(n.x)} ${M(n.y)}`}function ze(e){return e===`top`||e===`bottom`?`vertical`:e===`left`||e===`right`?`horizontal`:null}function Be(e,t){switch(e){case`top`:return{x:0,y:-1};case`right`:return{x:1,y:0};case`bottom`:return{x:0,y:1};case`left`:return{x:-1,y:0};default:return t}}function Ve(e){switch(e?.toLowerCase()){case`dashed`:case`dash`:return`8 6`;case`dotted`:case`dot`:return`2 6`;default:return}}var He=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;function Ue(e){let t=``;for(let n=0;n<e.length;n+=3){let r=e[n],i=n+1<e.length,a=n+2<e.length,o=i?e[n+1]:0,s=a?e[n+2]:0,c=r<<16|o<<8|s;t+=He[c>>>18&63],t+=He[c>>>12&63],t+=i?He[c>>>6&63]:`=`,t+=a?He[c&63]:`=`}return t}function We(e){let t=e.replace(/[\t\n\r ]/g,``);if(t.length%4!=0||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t))throw TypeError(`Invalid base64 data`);let n=t.endsWith(`==`)?2:+!!t.endsWith(`=`),r=new Uint8Array(t.length/4*3-n),i=0;for(let e=0;e<t.length;e+=4){let n=He.indexOf(t[e]),a=He.indexOf(t[e+1]),o=t[e+2]===`=`?0:He.indexOf(t[e+2]),s=t[e+3]===`=`?0:He.indexOf(t[e+3]),c=n<<18|a<<12|o<<6|s;i<r.length&&(r[i++]=c>>>16&255),i<r.length&&(r[i++]=c>>>8&255),i<r.length&&(r[i++]=c&255)}return r}function Ge(e){return new TextDecoder().decode(We(e))}function Ke(e){return Array.from(e)}function qe(e){return Ke(e).length}var Je=new Set([`┌`,`╭`,`┏`,`╔`]),Ye=new Set([`┐`,`╮`,`┓`,`╗`]),Xe=new Set([`└`,`╰`,`┗`,`╚`]),Ze=new Set([`┘`,`╯`,`┛`,`╝`]),Qe=new Set([`─`,`━`,`═`,`-`]),$e=new Set([`│`,`┃`,`║`,`|`]),et=new Set([`├`,`┤`,`┬`,`┴`,`┼`,`┣`,`┫`,`┳`,`┻`,`╋`,`╠`,`╣`,`╦`,`╩`,`╬`,`╞`,`╡`,`╥`,`╨`,`╫`,`╪`]),tt=new Set([`├`,`┤`,`┼`,`┣`,`┫`,`╋`,`╠`,`╣`,`╬`,`╞`,`╡`,`╫`,`╪`]),nt=new Set([`┬`,`┴`,`┼`,`┳`,`┻`,`╋`,`╦`,`╩`,`╬`,`╥`,`╨`,`╫`,`╪`]),rt=new Set([`▲`,`↑`]),it=new Set([`▼`,`↓`]),at=new Set([`◄`,`←`,`◀`]),ot=new Set([`►`,`→`,`▶`]);function st(e){return Je.has(e)}function ct(e){return Ye.has(e)}function lt(e){return Xe.has(e)}function ut(e){return Ze.has(e)}function dt(e){return Je.has(e)||Ye.has(e)||Xe.has(e)||Ze.has(e)}function ft(e){return Qe.has(e)}function pt(e){return $e.has(e)}function mt(e){return et.has(e)}function ht(e){return e===`+`}function gt(e){return ft(e)||nt.has(e)||ht(e)}function _t(e){return pt(e)||tt.has(e)||ht(e)}function P(e){return rt.has(e)?`up`:it.has(e)?`down`:at.has(e)?`left`:ot.has(e)?`right`:null}function vt(e){return e===`^`?`up`:e===`v`||e===`V`?`down`:e===`<`?`left`:e===`>`?`right`:null}function yt(e){return ft(e)||pt(e)||mt(e)||ht(e)||dt(e)}function bt(e){let t=e.codePointAt(0)??0;return t>=9472&&t<=9599||rt.has(e)||it.has(e)||e===`←`||e===`→`||e===`◄`||e===`►`||e===`◀`||e===`▶`}function xt(e){return e===`+`||e===`-`||e===`|`}var St={tl:`┌`,tr:`┐`,bl:`└`,br:`┘`,h:`─`,v:`│`,stemDown:`┬`,stemUp:`┴`,stemLeft:`┤`,stemRight:`├`,cross:`┼`,arrowUp:`▲`,arrowDown:`▼`,arrowLeft:`◄`,arrowRight:`►`,turnDownRight:`┌`,turnDownLeft:`┐`,turnUpRight:`└`,turnUpLeft:`┘`},Ct={tl:`+`,tr:`+`,bl:`+`,br:`+`,h:`-`,v:`|`,stemDown:`+`,stemUp:`+`,stemLeft:`+`,stemRight:`+`,cross:`+`,arrowUp:`^`,arrowDown:`v`,arrowLeft:`<`,arrowRight:`>`,turnDownRight:`+`,turnDownLeft:`+`,turnUpRight:`+`,turnUpLeft:`+`},wt=60,Tt=10,Et=3,Dt=10,Ot=new Set([`┼`,`╋`,`╬`,`╫`,`╪`]);function kt(e){return At(e).diagram}function At(e){let t=[],n=jt(e,t),r=n.length,i=r>0?n[0].length:0,a=0,o=!1;for(let e=0;e<r;e++)for(let t=0;t<i;t++){let r=n[e][t];r!==` `&&a++,!o&&Mt(r)&&(o=!0)}o&&t.push(`wide-chars`);let s=Nt(n),c=Wt(n,Pt(n),t),l=new Uint8Array(i*r),u=new Map;for(let e=0;e<c.length;e++){let t=c[e];for(let n=t.c0;n<=t.c1;n++)for(let r of[t.r0,t.r1]){l[r*i+n]=1;let t=u.get(r*i+n)??[];t.push(e),u.set(r*i+n,t)}for(let n=t.r0+1;n<=t.r1-1;n++)for(let r of[t.c0,t.c1]){l[n*i+r]=1;let t=u.get(n*i+r)??[];t.push(e),u.set(n*i+r,t)}}let d=c.map((e,t)=>c.some(e=>e.parentIdx===t));for(let e=0;e<c.length;e++){let t=c[e];if(d[e]){let r=Math.min(...c.filter(t=>t.parentIdx===e).map(e=>e.r0));for(let e=t.r0+1;e<r;e++)for(let r=t.c0+1;r<=t.c1-1;r++){let t=n[e][r];t!==` `&&!yt(t)&&P(t)===null&&(l[e*i+r]=1)}}else for(let e=t.r0+1;e<=t.r1-1;e++)for(let n=t.c0+1;n<=t.c1-1;n++)l[e*i+n]=1}let{edges:f,edgeCells:p}=qt(n,l,u,c,t),m=0,h=[];for(let e=0;e<r;e++){let t=``,r=()=>{t.trim().length>0&&h.push(`@${e}: ${$t(t.trim(),30)}`),t=``},a=t=>{if(t<0||t>=i)return!1;let r=e*i+t;return n[e][t]!==` `&&!l[r]&&!p.has(r)};for(let o=0;o<i;o++)a(o)?(t+=n[e][o],m++):t!==``&&n[e][o]===` `&&a(o+1)?t+=` `:r();r()}for(let e of h.slice(0,Tt))t.push(`loose-text ${e}`);return h.length>Tt&&t.push(`loose-text (+${h.length-Tt} more)`),{diagram:{nodes:c.map(e=>({id:e.id,label:e.labelLines.join(`
|
|
1
|
+
import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{i as t,l as n,n as r,p as i,s as a,t as o}from"./chunk-O7JILDEF-CqcO1qaI.js";import{a as s,c,d as l,f as u,l as d,n as f,o as p,p as m,r as h,s as g,u as _}from"./chunk-BAOV476U-CEOFYt8X.js";import{o as v}from"./chunk-4VOD55SX-BFSSw0c8.js";import{A as y,C as b,D as x,E as S,M as C,O as w,_ as T,c as E,j as D,k as O,l as k,o as A,r as ee,t as te,v as ne,w as re,y as ie}from"./chunk-GAZKTT4R-BkP6-w3z.js";import{C as ae,D as oe,E as se,I as ce,L as le,M as ue,P as j,R as de,S as fe,T as pe,j as me,k as he,n as ge,w as _e,z as ve}from"./chunk-UBFT2CDQ-FexGDigd.js";import{i as ye,n as be,r as xe,t as Se}from"./chunk-XRW6P7IF-BeQQgMVK.js";import{r as Ce}from"./chunk-7ZAAICW4-BsCpYJH6.js";var we=new Set([`triangle`,`right-triangle`,`diamond`,`pentagon`,`hexagon`,`octagon`,`star`,`star4`,`star6`,`parallelogram`,`trapezoid`,`plus`,`chevron`,`arrow-right`,`arrow-left`,`arrow-up`,`arrow-down`,`double-arrow`,`callout`,`cylinder`,`cloud`,`heart`,`lightning`]);function M(e){return Math.round(e*10)/10}function N(e){if(e.length===0)return``;let[t,...n]=e;return`${`M ${M(t[0])} ${M(t[1])}`} ${n.map(([e,t])=>`L ${M(e)} ${M(t)}`).join(` `)} Z`}function Te(e,t,n,r,i,a){let o=[];for(let s=0;s<i;s++){let c=a+s*2*Math.PI/i;o.push([e+n*Math.cos(c),t+r*Math.sin(c)])}return o}function Ee(e,t,n,r,i,a){let o=[],s=-Math.PI/2;for(let c=0;c<i*2;c++){let l=c%2==0,u=s+c*Math.PI/i,d=l?n:n*a,f=l?r:r*a;o.push([e+d*Math.cos(u),t+f*Math.sin(u)])}return o}function De(e,t,n,r,i){let a=t+r/2,o=n+i/2,s=r/2,c=i/2,l=t+r,u=n+i;switch(e){case`triangle`:return N([[a,n],[l,u],[t,u]]);case`right-triangle`:return N([[t,n],[t,u],[l,u]]);case`diamond`:return N([[a,n],[l,o],[a,u],[t,o]]);case`pentagon`:return N(Te(a,o,s,c,5,-Math.PI/2));case`hexagon`:{let e=r*.25;return N([[t+e,n],[l-e,n],[l,o],[l-e,u],[t+e,u],[t,o]])}case`octagon`:{let e=Math.min(r,i)*.29;return N([[t+e,n],[l-e,n],[l,n+e],[l,u-e],[l-e,u],[t+e,u],[t,u-e],[t,n+e]])}case`star`:return N(Ee(a,o,s,c,5,.4));case`star4`:return N(Ee(a,o,s,c,4,.4));case`star6`:return N(Ee(a,o,s,c,6,.5));case`parallelogram`:{let e=r*.25;return N([[t+e,n],[l,n],[l-e,u],[t,u]])}case`trapezoid`:{let e=r*.25;return N([[t+e,n],[l-e,n],[l,u],[t,u]])}case`plus`:{let e=Math.min(r,i)/3,a=t+(r-e)/2,o=a+e,s=n+(i-e)/2,c=s+e;return N([[a,n],[o,n],[o,s],[l,s],[l,c],[o,c],[o,u],[a,u],[a,c],[t,c],[t,s],[a,s]])}case`chevron`:{let e=r*.25;return N([[t,n],[l-e,n],[l,o],[l-e,u],[t,u],[t+e,o]])}case`arrow-right`:return Oe(t,n,r,i,`right`);case`arrow-left`:return Oe(t,n,r,i,`left`);case`arrow-up`:return Oe(t,n,r,i,`up`);case`arrow-down`:return Oe(t,n,r,i,`down`);case`double-arrow`:{let e=r*.3,a=i*.4,s=o-a/2,c=o+a/2;return N([[t,o],[t+e,n],[t+e,s],[l-e,s],[l-e,n],[l,o],[l-e,u],[l-e,c],[t+e,c],[t+e,u]])}case`callout`:{let e=n+i*.78,a=t+r*.25;return`M ${M(t)} ${M(n)} L ${M(l)} ${M(n)} L ${M(l)} ${M(e)} L ${M(a+r*.12)} ${M(e)} L ${M(a)} ${M(u)} L ${M(a-r*.02)} ${M(e)} L ${M(t)} ${M(e)} Z`}case`cylinder`:{let e=i*.16;return`M ${M(t)} ${M(n+e)} A ${M(s)} ${M(e)} 0 0 1 ${M(l)} ${M(n+e)} L ${M(l)} ${M(u-e)} A ${M(s)} ${M(e)} 0 0 1 ${M(t)} ${M(u-e)} Z M ${M(t)} ${M(n+e)} A ${M(s)} ${M(e)} 0 0 0 ${M(l)} ${M(n+e)}`}case`cloud`:{let e=i*.5;return`M ${M(t+r*.2)} ${M(u)} A ${M(r*.2)} ${M(e)} 0 0 1 ${M(t+r*.15)} ${M(o)} A ${M(r*.2)} ${M(e)} 0 0 1 ${M(t+r*.45)} ${M(n+i*.2)} A ${M(r*.2)} ${M(e)} 0 0 1 ${M(t+r*.8)} ${M(n+i*.25)} A ${M(r*.18)} ${M(e)} 0 0 1 ${M(t+r*.85)} ${M(u)} Z`}case`heart`:{let e=n+i*.3;return`M ${M(a)} ${M(u)} C ${M(t-r*.1)} ${M(o)} ${M(t)} ${M(n)} ${M(a)} ${M(e)} C ${M(l)} ${M(n)} ${M(l+r*.1)} ${M(o)} ${M(a)} ${M(u)} Z`}case`lightning`:return N([[t+r*.55,n],[t+r*.2,n+i*.55],[t+r*.45,n+i*.55],[t+r*.3,u],[l,n+i*.4],[t+r*.55,n+i*.4]]);default:return null}}function Oe(e,t,n,r,i){let a=e+n,o=t+r,s=e+n/2,c=t+r/2;if(i===`right`||i===`left`){let s=n*.4,l=r*.5,u=c-l/2,d=c+l/2;return N(i===`right`?[[e,u],[a-s,u],[a-s,t],[a,c],[a-s,o],[a-s,d],[e,d]]:[[a,u],[e+s,u],[e+s,t],[e,c],[e+s,o],[e+s,d],[a,d]])}let l=r*.4,u=n*.5,d=s-u/2,f=s+u/2;return N(i===`down`?[[d,t],[f,t],[f,o-l],[a,o-l],[s,o],[e,o-l],[d,o-l]]:[[d,o],[f,o],[f,t+l],[a,t+l],[s,t],[e,t+l],[d,t+l]])}function ke(e,t){let n=t===`start`,r=e=>n?10-e:e,i=e=>`M ${r(0)} 0 L ${r(10)} 5 L ${r(0)} 10${e?` z`:``}`;switch(e){case`arrow`:return{d:i(!0),filled:!0};case`open`:return{d:i(!1),filled:!1};case`diamond`:return{d:`M 0 5 L 5 0 L 10 5 L 5 10 z`,filled:!0};case`square`:return{d:`M 1 1 L 9 1 L 9 9 L 1 9 z`,filled:!0};case`circle`:return{d:`M 0 5 A 5 5 0 1 0 10 5 A 5 5 0 1 0 0 5 z`,filled:!0};default:return null}}function Ae(e,t){let n=t.cx-e.cx,r=t.cy-e.cy;if(n===0&&r===0)return{x:e.cx,y:e.cy};let i=Math.abs(n)>0?e.rx/Math.abs(n):1/0,a=Math.abs(r)>0?e.ry/Math.abs(r):1/0,o=Math.min(i,a);return{x:e.cx+n*o,y:e.cy+r*o}}function je(e,t){return{start:Ae(e,t),end:Ae(t,e)}}function Me(e){let t=e.cx-e.rx,n=e.cx+e.rx,r=e.cy-e.ry,i=e.cy+e.ry;return[{port:`top`,x:e.cx,y:r},{port:`right`,x:n,y:e.cy},{port:`bottom`,x:e.cx,y:i},{port:`left`,x:t,y:e.cy},{port:`top-left`,x:t,y:r},{port:`top-right`,x:n,y:r},{port:`bottom-right`,x:n,y:i},{port:`bottom-left`,x:t,y:i}]}function Ne(e,t){let n=Math.max(0,Math.min(1,t.offset)),r=e.cx-e.rx,i=e.cx+e.rx,a=e.cy-e.ry,o=e.cy+e.ry;switch(t.side){case`top`:return{port:`top`,x:r+(i-r)*n,y:a};case`right`:return{port:`right`,x:i,y:a+(o-a)*n};case`bottom`:return{port:`bottom`,x:r+(i-r)*n,y:o};case`left`:return{port:`left`,x:r,y:a+(o-a)*n}}}function Pe(e,t){let n=Me(e)[0],r=1/0;for(let i of Me(e)){let e=Ie(i,t)+Le(i.port);e<r&&(n=i,r=e)}return n}function Fe(e,t){let n=Me(e)[0],r=Me(t)[0],i=1/0;for(let a of Me(e))for(let e of Me(t)){let t=Ie(a,e)+Le(a.port)+Le(e.port);t<i&&(n=a,r=e,i=t)}return{start:n,end:r}}function Ie(e,t){let n=e.x-t.x,r=e.y-t.y;return n*n+r*r}function Le(e){return e.includes(`-`)?.02:0}function Re(e,t,n){if(e===`straight`)return`M ${M(t.x)} ${M(t.y)} L ${M(n.x)} ${M(n.y)}`;if(e===`orthogonal`){let e=ze(t.port),r=ze(n.port);if(e===`vertical`&&r===`vertical`){let e=(t.y+n.y)/2;return`M ${M(t.x)} ${M(t.y)} L ${M(t.x)} ${M(e)} L ${M(n.x)} ${M(e)} L ${M(n.x)} ${M(n.y)}`}if(e===`vertical`&&r===`horizontal`)return`M ${M(t.x)} ${M(t.y)} L ${M(t.x)} ${M(n.y)} L ${M(n.x)} ${M(n.y)}`;if(e===`horizontal`&&r===`vertical`)return`M ${M(t.x)} ${M(t.y)} L ${M(n.x)} ${M(t.y)} L ${M(n.x)} ${M(n.y)}`;let i=(t.x+n.x)/2;return`M ${M(t.x)} ${M(t.y)} L ${M(i)} ${M(t.y)} L ${M(i)} ${M(n.y)} L ${M(n.x)} ${M(n.y)}`}let r=Math.hypot(n.x-t.x,n.y-t.y),i=Math.max(40,r/2),a=Be(t.port,{x:1,y:0}),o=Be(n.port,{x:-1,y:0});return`M ${M(t.x)} ${M(t.y)} C ${M(t.x+a.x*i)} ${M(t.y+a.y*i)}, ${M(n.x+o.x*i)} ${M(n.y+o.y*i)}, ${M(n.x)} ${M(n.y)}`}function ze(e){return e===`top`||e===`bottom`?`vertical`:e===`left`||e===`right`?`horizontal`:null}function Be(e,t){switch(e){case`top`:return{x:0,y:-1};case`right`:return{x:1,y:0};case`bottom`:return{x:0,y:1};case`left`:return{x:-1,y:0};default:return t}}function Ve(e){switch(e?.toLowerCase()){case`dashed`:case`dash`:return`8 6`;case`dotted`:case`dot`:return`2 6`;default:return}}var He=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;function Ue(e){let t=``;for(let n=0;n<e.length;n+=3){let r=e[n],i=n+1<e.length,a=n+2<e.length,o=i?e[n+1]:0,s=a?e[n+2]:0,c=r<<16|o<<8|s;t+=He[c>>>18&63],t+=He[c>>>12&63],t+=i?He[c>>>6&63]:`=`,t+=a?He[c&63]:`=`}return t}function We(e){let t=e.replace(/[\t\n\r ]/g,``);if(t.length%4!=0||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t))throw TypeError(`Invalid base64 data`);let n=t.endsWith(`==`)?2:+!!t.endsWith(`=`),r=new Uint8Array(t.length/4*3-n),i=0;for(let e=0;e<t.length;e+=4){let n=He.indexOf(t[e]),a=He.indexOf(t[e+1]),o=t[e+2]===`=`?0:He.indexOf(t[e+2]),s=t[e+3]===`=`?0:He.indexOf(t[e+3]),c=n<<18|a<<12|o<<6|s;i<r.length&&(r[i++]=c>>>16&255),i<r.length&&(r[i++]=c>>>8&255),i<r.length&&(r[i++]=c&255)}return r}function Ge(e){return new TextDecoder().decode(We(e))}function Ke(e){return Array.from(e)}function qe(e){return Ke(e).length}var Je=new Set([`┌`,`╭`,`┏`,`╔`]),Ye=new Set([`┐`,`╮`,`┓`,`╗`]),Xe=new Set([`└`,`╰`,`┗`,`╚`]),Ze=new Set([`┘`,`╯`,`┛`,`╝`]),Qe=new Set([`─`,`━`,`═`,`-`]),$e=new Set([`│`,`┃`,`║`,`|`]),et=new Set([`├`,`┤`,`┬`,`┴`,`┼`,`┣`,`┫`,`┳`,`┻`,`╋`,`╠`,`╣`,`╦`,`╩`,`╬`,`╞`,`╡`,`╥`,`╨`,`╫`,`╪`]),tt=new Set([`├`,`┤`,`┼`,`┣`,`┫`,`╋`,`╠`,`╣`,`╬`,`╞`,`╡`,`╫`,`╪`]),nt=new Set([`┬`,`┴`,`┼`,`┳`,`┻`,`╋`,`╦`,`╩`,`╬`,`╥`,`╨`,`╫`,`╪`]),rt=new Set([`▲`,`↑`]),it=new Set([`▼`,`↓`]),at=new Set([`◄`,`←`,`◀`]),ot=new Set([`►`,`→`,`▶`]);function st(e){return Je.has(e)}function ct(e){return Ye.has(e)}function lt(e){return Xe.has(e)}function ut(e){return Ze.has(e)}function dt(e){return Je.has(e)||Ye.has(e)||Xe.has(e)||Ze.has(e)}function ft(e){return Qe.has(e)}function pt(e){return $e.has(e)}function mt(e){return et.has(e)}function ht(e){return e===`+`}function gt(e){return ft(e)||nt.has(e)||ht(e)}function _t(e){return pt(e)||tt.has(e)||ht(e)}function P(e){return rt.has(e)?`up`:it.has(e)?`down`:at.has(e)?`left`:ot.has(e)?`right`:null}function vt(e){return e===`^`?`up`:e===`v`||e===`V`?`down`:e===`<`?`left`:e===`>`?`right`:null}function yt(e){return ft(e)||pt(e)||mt(e)||ht(e)||dt(e)}function bt(e){let t=e.codePointAt(0)??0;return t>=9472&&t<=9599||rt.has(e)||it.has(e)||e===`←`||e===`→`||e===`◄`||e===`►`||e===`◀`||e===`▶`}function xt(e){return e===`+`||e===`-`||e===`|`}var St={tl:`┌`,tr:`┐`,bl:`└`,br:`┘`,h:`─`,v:`│`,stemDown:`┬`,stemUp:`┴`,stemLeft:`┤`,stemRight:`├`,cross:`┼`,arrowUp:`▲`,arrowDown:`▼`,arrowLeft:`◄`,arrowRight:`►`,turnDownRight:`┌`,turnDownLeft:`┐`,turnUpRight:`└`,turnUpLeft:`┘`},Ct={tl:`+`,tr:`+`,bl:`+`,br:`+`,h:`-`,v:`|`,stemDown:`+`,stemUp:`+`,stemLeft:`+`,stemRight:`+`,cross:`+`,arrowUp:`^`,arrowDown:`v`,arrowLeft:`<`,arrowRight:`>`,turnDownRight:`+`,turnDownLeft:`+`,turnUpRight:`+`,turnUpLeft:`+`},wt=60,Tt=10,Et=3,Dt=10,Ot=new Set([`┼`,`╋`,`╬`,`╫`,`╪`]);function kt(e){return At(e).diagram}function At(e){let t=[],n=jt(e,t),r=n.length,i=r>0?n[0].length:0,a=0,o=!1;for(let e=0;e<r;e++)for(let t=0;t<i;t++){let r=n[e][t];r!==` `&&a++,!o&&Mt(r)&&(o=!0)}o&&t.push(`wide-chars`);let s=Nt(n),c=Wt(n,Pt(n),t),l=new Uint8Array(i*r),u=new Map;for(let e=0;e<c.length;e++){let t=c[e];for(let n=t.c0;n<=t.c1;n++)for(let r of[t.r0,t.r1]){l[r*i+n]=1;let t=u.get(r*i+n)??[];t.push(e),u.set(r*i+n,t)}for(let n=t.r0+1;n<=t.r1-1;n++)for(let r of[t.c0,t.c1]){l[n*i+r]=1;let t=u.get(n*i+r)??[];t.push(e),u.set(n*i+r,t)}}let d=c.map((e,t)=>c.some(e=>e.parentIdx===t));for(let e=0;e<c.length;e++){let t=c[e];if(d[e]){let r=Math.min(...c.filter(t=>t.parentIdx===e).map(e=>e.r0));for(let e=t.r0+1;e<r;e++)for(let r=t.c0+1;r<=t.c1-1;r++){let t=n[e][r];t!==` `&&!yt(t)&&P(t)===null&&(l[e*i+r]=1)}}else for(let e=t.r0+1;e<=t.r1-1;e++)for(let n=t.c0+1;n<=t.c1-1;n++)l[e*i+n]=1}let{edges:f,edgeCells:p}=qt(n,l,u,c,t),m=0,h=[];for(let e=0;e<r;e++){let t=``,r=()=>{t.trim().length>0&&h.push(`@${e}: ${$t(t.trim(),30)}`),t=``},a=t=>{if(t<0||t>=i)return!1;let r=e*i+t;return n[e][t]!==` `&&!l[r]&&!p.has(r)};for(let o=0;o<i;o++)a(o)?(t+=n[e][o],m++):t!==``&&n[e][o]===` `&&a(o+1)?t+=` `:r();r()}for(let e of h.slice(0,Tt))t.push(`loose-text ${e}`);return h.length>Tt&&t.push(`loose-text (+${h.length-Tt} more)`),{diagram:{nodes:c.map(e=>({id:e.id,label:e.labelLines.join(`
|
|
2
2
|
`),col:e.c0,row:e.r0,wCols:e.c1-e.c0+1,hRows:e.r1-e.r0+1,...e.parentIdx>=0?{containerId:c[e.parentIdx].id}:{}})),edges:f,style:s,warnings:t},stats:{totalNonSpaceCells:a,looseNonSpaceCells:m,hasWideChars:o}}}function jt(e,t){let n=e.replace(/\r\n?/g,`
|
|
3
3
|
`).split(`
|
|
4
4
|
`),r=!1,i=n.map(e=>{let t=[];for(let n of e)if(n===` `){r=!0;do t.push(` `);while(t.length%4!=0)}else t.push(n);return t});r&&t.push(`tabs-expanded`);let a=0;for(let e of i)a=Math.max(a,e.length);for(let e of i)for(;e.length<a;)e.push(` `);return i}function Mt(e){let t=e.codePointAt(0)??0;return t>=4352&&t<=4447||t>=11904&&t<=12350||t>=12353&&t<=13311||t>=13312&&t<=19903||t>=19968&&t<=40959||t>=44032&&t<=55203||t>=63744&&t<=64255||t>=65072&&t<=65103||t>=65280&&t<=65376||t>=127744&&t<=129791}function Nt(e){let t=0,n=0;for(let r of e)for(let e of r)bt(e)?t++:xt(e)&&n++;return n>t?`ascii`:`unicode`}function Pt(e,t=!1){let n=e.length,r=n>0?e[0].length:0,i=[];for(let a=0;a<n;a++)for(let n=0;n<r;n++){if(!It(e,a,n))continue;let r=Lt(e,a,n,t);r&&i.push(r)}return i}function Ft(e){return jt(e,[])}function It(e,t,n){let r=e[t][n];if(st(r))return!0;if(!ht(r)&&!mt(r))return!1;let i=e[t][n+1]??` `,a=e[t+1]?.[n]??` `,o=gt(i)||ct(i),s=_t(a)||lt(a);return o&&s}function Lt(e,t,n,r=!1){let i=e.length,a=e[0]?.length??0,o=[];for(let r=n+1;r<a;r++){let n=e[t][r];if(ct(n)){if(o.push(r),_t(e[t+1]?.[r]??` `))break;continue}(ht(n)||mt(n))&&o.push(r)}if(o.length===0)return null;let s=Bt(e,n,t,i,lt,r);if(s.length===0)return null;let c=new Set(s);for(let a of o){if(a<n+2)continue;let o=Rt(e[t],n,a);if(!o.ok)continue;let s=Bt(e,a,t,i,ut,r);for(let i of s){if(i<t+2||!c.has(i))continue;let s=!0;for(let t=n+1;t<=a-1;t++)if(!gt(e[i][t])){s=!1;break}if(!s)continue;let l=+!!r,u=0,d=0;for(let r=t+1;r<=i-1;r++)zt(e[r],n,l)&&u++,zt(e[r],a,l)&&d++;if(!(u===0||d===0))return{r0:t,c0:n,r1:i,c1:a,...o.title?{borderTitle:o.title}:{}}}}return null}function Rt(e,t,n){let r=e=>gt(e)||P(e)!==null,i=t+1,a=n-1;for(;i<=a&&r(e[i]);)i++;for(;a>=i&&r(e[a]);)a--;if(i>a)return{ok:!0};if(a-i+1>wt)return{ok:!1};let o=e.slice(i,a+1).join(``).trim();return o.length>0?{ok:!0,title:o}:{ok:!0}}function zt(e,t,n){for(let r=t-n;r<=t+n;r++){let t=e[r];if(t!==void 0&&_t(t))return!0}return!1}function Bt(e,t,n,r,i,a=!1){let o=[],s=a?Dt:Et,c=0;for(let l=n+1;l<r;l++){let n=e[l][t];if(i(n)){o.push(l);break}if(ht(n)||mt(n)){o.push(l),c=0;continue}if(_t(n)){c=0;continue}if(!a&&(yt(n)||P(n)!==null)||++c>s)break}return o}function Vt(e,t){return e.r0<t.r0&&e.c0<t.c0&&e.r1>t.r1&&e.c1>t.c1}function Ht(e,t){return e.r0+1<=t.r1-1&&t.r0+1<=e.r1-1&&e.c0+1<=t.c1-1&&t.c0+1<=e.c1-1}function Ut(e){return(e.r1-e.r0+1)*(e.c1-e.c0+1)}function Wt(e,t,n){let r=[...t].sort((e,t)=>e.r0-t.r0||e.c0-t.c0),i=r.map((e,t)=>{let n=-1,i=1/0;for(let a=0;a<r.length;a++){if(a===t||!Vt(r[a],e))continue;let o=Ut(r[a]);o<i&&(i=o,n=a)}return n}),a=!1;for(let e=0;e<r.length&&!a;e++)for(let t=e+1;t<r.length;t++)if(Ht(r[e],r[t])&&!Vt(r[e],r[t])&&!Vt(r[t],r[e])){n.push(`overlapping-boxes`),a=!0;break}let o=r.map((e,t)=>i.includes(t)),s=new Map;return r.map((t,n)=>{let a=[];if(t.borderTitle&&a.push(t.borderTitle),o[n]){let o=Math.min(...r.filter((e,t)=>i[t]===n).map(e=>e.r0));for(let n=t.r0+1;n<o;n++){let r=e[n].slice(t.c0+1,t.c1).map(e=>yt(e)||P(e)!==null?` `:e).join(``).trim();r.length>0&&a.push(r)}}else for(let n=t.r0+1;n<=t.r1-1;n++){let r=e[n].slice(t.c0+1,t.c1).join(``);if(Gt(r))continue;let i=r.trim();i.length>0&&a.push(i)}let c=Kt(a[0]??``),l=s.get(c)??0;s.set(c,l+1);let u=l===0?c:`${c}-${l+1}`;return{...t,parentIdx:i[n],labelLines:a,id:u}})}function Gt(e){if(e.length===0||e!==e.trim())return!1;let t=!1;for(let n of e)if(n!==` `){if(ft(n)||mt(n)||ht(n)){t=!0;continue}return!1}return t}function Kt(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`node`}function qt(e,t,n,r,i){let a=e.length,o=a>0?e[0].length:0,s=new Map;for(let n=0;n<a;n++)for(let r=0;r<o;r++){let i=n*o+r;if(t[i])continue;let a=e[n][r],c=P(a);if(c){s.set(i,{arrow:c});continue}let l=vt(a);if(l&&Xt(e,n,r,l)){s.set(i,{arrow:l});continue}yt(a)&&s.set(i,{arrow:null})}for(let n=0;n<a;n++){let r=0;for(;r<o;){let i=n*o+r;if(!s.has(i)||!ft(e[n][r])){r++;continue}let a=r;for(;a+1<o&&s.has(n*o+a+1)&&ft(e[n][a+1]);)a++;let c=a+1,l=!1,u=!1;for(;c<o&&c-a-1<=40;){let r=e[n][c];if(t[n*o+c]){u=!0;break}if(ft(r)){if(Jt(e,t,n,c,o))break;for(;c<o&&ft(e[n][c]);)c++;l=!0;continue}if(Yt(e,n,c)){u=!0;break}r!==` `&&(l=!0),c++}if(!u&&c<o&&c>a+1&&l&&ft(e[n][c])&&!t[n*o+c]){let t=e[n].slice(a+1,c).join(``).trim();for(let e=a+1;e<c;e++)s.set(n*o+e,{arrow:null,bridgeLabel:t});r=c}else r=a+1}}let c=t=>Ot.has(e[Math.floor(t/o)][t%o]),l=(e,t)=>e*2+t,u=new Set,d=[],f=[];for(let e of s.keys())f.push([e,0]),c(e)&&f.push([e,1]);for(let[e,t]of f){if(u.has(l(e,t)))continue;let n=new Set,r=[[e,t]];for(u.add(l(e,t));r.length>0;){let[e,t]=r.pop();n.add(e);let i=Math.floor(e/o),d=e%o,f=c(e)&&t===1?[[i-1,d],[i+1,d]]:c(e)?[[i,d-1],[i,d+1]]:[[i-1,d],[i+1,d],[i,d-1],[i,d+1]];for(let[e,t]of f){if(e<0||e>=a||t<0||t>=o)continue;let n=e*o+t;if(!s.has(n))continue;let d=c(n)?e===i?0:1:0,f=l(n,d);u.has(f)||(u.add(f),r.push([n,d]))}}d.push([...n].sort((e,t)=>e-t))}d.sort((e,t)=>e[0]-t[0]);let p=[],m=new Set,h=!1,g=new Set,_=new Set;for(let c of d){let l=new Set(c),u=[];for(let e of c){let t=Math.floor(e/o),n=e%o,r=0;for(let[e,i]of[[t-1,n],[t+1,n],[t,n-1],[t,n+1]])l.has(e*o+i)&&r++;let i=s.get(e);(r<=1||i.arrow!==null)&&u.push(e)}let d=new Map,f=!1;for(let e of u){let t=Math.floor(e/o),i=e%o,c=s.get(e),l=Zt(t,i,c.arrow,n,r,o,a);if(l===null){f=!0;continue}let u=d.get(l);u?u.isArrowEnd=u.isArrowEnd||c.arrow!==null:d.set(l,{boxIdx:l,isArrowEnd:c.arrow!==null})}let v=(e,t)=>{let i=n.get(e*o+t)??[];return i.length===0?null:[...i].sort((e,t)=>r[e].r0-r[t].r0||r[e].c0-r[t].c0||e-t)[0]};for(let t of c){let n=Math.floor(t/o),r=t%o,i=e[n][r];if(!(!mt(i)&&!ht(i)))for(let[e,t]of[[-1,0],[1,0],[0,-1],[0,1]]){let i=v(n+e,r+t);i!==null&&!d.has(i)&&d.set(i,{boxIdx:i,isArrowEnd:!1})}}for(let e of c){let t=Math.floor(e/o),n=e%o,r=s.get(e);if(r.arrow===null)continue;let[i,a]=r.arrow===`down`?[-1,0]:r.arrow===`up`?[1,0]:r.arrow===`right`?[0,-1]:[0,1],c=v(t+i,n+a);c!==null&&!d.has(c)&&d.set(c,{boxIdx:c,isArrowEnd:!1})}let y=[...d.values()].sort((e,t)=>r[e.boxIdx].r0-r[t.boxIdx].r0||r[e.boxIdx].c0-r[t.boxIdx].c0);if(y.length===0){for(let e of c)g.add(e);i.push(`dangling-edge`);continue}if(y.length===1){i.push(`dangling-edge`);continue}f&&i.push(`dangling-edge`);let b=[];for(let e of c){let t=s.get(e);t.bridgeLabel&&!b.includes(t.bridgeLabel)&&b.push(t.bridgeLabel)}let x=e=>yt(e)&&e!==`-`||P(e)!==null,S=e=>/[a-z0-9]/i.test(e),C=b[0];if(!C)outer:for(let n of c){let r=Math.floor(n/o),i=n%o;if(pt(e[r][i])){if((e[r][i+1]??``)===` `){let n=i+2,a=``;for(;n<o;){let i=e[r][n];if(t[r*o+n]||x(i)||i===` `&&(e[r][n+1]??` `)===` `)break;a+=i,n++}let s=a.trim().replace(/^-+|-+$/g,``);if(s.length>0&&s.length<=40&&S(s)){C=s;for(let e=i+2;e<n;e++)_.add(r*o+e);break outer}}if((e[r][i-1]??``)===` `){let n=i-2,a=``;for(;n>=0;){let i=e[r][n];if(t[r*o+n]||x(i)||i===` `&&(e[r][n-1]??` `)===` `)break;a=i+a,n--}let s=a.trim().replace(/^-+|-+$/g,``);if(s.length>0&&s.length<=40&&S(s)){C=s;for(let e=n+1;e<=i-2;e++)_.add(r*o+e);break outer}}}}b.length>1&&i.push(`multiple-edge-labels`);let w=(e,t,n)=>{let i={source:r[e].id,target:r[t].id,...C?{label:C}:{},directed:n},a=`${i.source}|${i.target}|${i.directed}|${i.label??``}`;if(m.has(a)){h=!0;return}m.add(a),p.push(i)},T=y.filter(e=>e.isArrowEnd),E=y.filter(e=>!e.isArrowEnd);if(y.length===2){let[e,t]=y;if(T.length===2)w(e.boxIdx,t.boxIdx,!0),w(t.boxIdx,e.boxIdx,!0);else if(T.length===1){let n=T[0];w((e===n?t:e).boxIdx,n.boxIdx,!0)}else w(e.boxIdx,t.boxIdx,!1)}else if(E.length===1&&T.length>=1)for(let e of T)w(E[0].boxIdx,e.boxIdx,!0);else if(T.length===1&&E.length>=1)for(let e of E)w(e.boxIdx,T[0].boxIdx,!0);else if(T.length===0){i.push(`ambiguous-bus`);for(let e=1;e<y.length;e++)w(y[0].boxIdx,y[e].boxIdx,!1)}else{i.push(`ambiguous-bus`);for(let e of T)E.length>0&&w(E[0].boxIdx,e.boxIdx,!0)}}h&&i.push(`parallel-edges-merged`),p.sort((e,t)=>e.source.localeCompare(t.source)||e.target.localeCompare(t.target)||(e.label??``).localeCompare(t.label??``));let v=new Set;for(let e of d)for(let t of e)g.has(t)||v.add(t);for(let e of _)v.add(e);return{edges:p,edgeCells:v}}function Jt(e,t,n,r,i){let a=r;for(;a<i&&ft(e[n][a])&&!t[n*i+a];)a++;if(a>=i||t[n*i+a])return!0;let o=e[n][a];if(yt(o)||P(o)!==null)return!0;let s=vt(o);return s!==null&&Xt(e,n,a,s)}function Yt(e,t,n){let r=e[t][n];if(P(r)!==null)return!0;let i=vt(r);if(i!==null&&Xt(e,t,n,i))return!0;if(!yt(r))return!1;let a=e=>e!==void 0&&(yt(e)||P(e)!==null);return a(e[t-1]?.[n])||a(e[t+1]?.[n])}function Xt(e,t,n,r){let i=r===`down`?e[t-1]?.[n]:r===`up`?e[t+1]?.[n]:r===`right`?e[t]?.[n-1]:e[t]?.[n+1];return i===void 0?!1:r===`down`||r===`up`?pt(i):ft(i)}function Zt(e,t,n,r,i,a,o){let s=(e,t)=>e<0||e>=o||t<0||t>=a?[]:r.get(e*a+t)??[];if(n){let[r,a]=n===`down`?[1,0]:n===`up`?[-1,0]:n===`right`?[0,1]:[0,-1];for(let o of[1,2]){let c=s(e+r*o,t+a*o);if(c.length>0)return[...c].sort((s,c)=>{let l=Qt(i[s],e+r*o,t+a*o,n);return Qt(i[c],e+r*o,t+a*o,n)-l||s-c})[0]}}let c=new Map;for(let[n,r,i]of[[-1,0,0],[1,0,0],[0,-1,0],[0,1,0],[-1,-1,1],[-1,1,1],[1,-1,1],[1,1,1],[-2,0,2],[2,0,2],[0,-2,2],[0,2,2]])for(let a of s(e+n,t+r)){let e=c.get(a);(e===void 0||i<e)&&c.set(a,i)}return c.size===0?null:[...c.entries()].sort((e,t)=>e[1]-t[1]||i[e[0]].r0-i[t[0]].r0||i[e[0]].c0-i[t[0]].c0||e[0]-t[0])[0][0]}function Qt(e,t,n,r){switch(r){case`down`:return+(e.r0===t);case`up`:return+(e.r1===t);case`right`:return+(e.c0===n);case`left`:return+(e.c1===n)}}function $t(e,t){return e.length>t?`${e.slice(0,t-1)}\u2026`:e}var en=new Set([`text`,`txt`,`plaintext`,`plain`,`ascii`,`diagram`]),tn=400,nn=400,rn=3,an=.25,on=/[│┃║┌┐└┘├┤┬┴┼╭╮╰╯┏┓┗┛╔╗╚╝┣┫┳┻╋╠╣╦╩╬╞╡╥╨╫╪]/;function sn(e){if(e==null)return!0;let t=e.trim().toLowerCase();return t===``||en.has(t)}function cn(e){return typeof e==`string`&&e.trim().toLowerCase()===`diagram`}function ln(e,t={}){let n=t.explicit===!0,r=[],i=e.replace(/\r\n?/g,`
|
|
@@ -15,25 +15,25 @@ import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{i as t,l as n,n as r,p
|
|
|
15
15
|
`).split(`
|
|
16
16
|
`),i=r.filter(e=>e.trim().length>0),a=n?1:Gr;if(i.length<a)return{isTree:!1,reasons:[`too-few-lines(${i.length})`]};if(r.length>Wr)return{isTree:!1,reasons:[`too-many-lines(${r.length})`]};let o=i.filter(e=>/^\s*\|.*\|\s*$/.test(e)).length,s=i.some(e=>/^\s*\|?[\s:|-]+\|?\s*$/.test(e)&&e.includes(`-`));if(o>i.length/2&&s)return{isTree:!1,reasons:[`markdown-table`]};if(Jr.test(e))return{isTree:!1,reasons:[`has-box-corners`]};if(!n&&Cr(e).isTimeline)return{isTree:!1,reasons:[`is-timeline`]};let c=At(e).diagram.nodes.length;if(c>=2)return{isTree:!1,reasons:[`has-boxes(${c})`]};let{tree:l,stats:u}=Rr(e),d=$r(l.roots);if(d<(n?1:qr))return{isTree:!1,reasons:[`too-few-nodes(${d})`]};if(!n){if(u.connectorLines<Kr)return{isTree:!1,reasons:[`too-few-connectors(${u.connectorLines})`]};if(u.looseLines>u.contentLines*.25)return{isTree:!1,reasons:[`loose-ratio(${u.looseLines}/${u.contentLines})`]}}return{isTree:!0,tree:l,reasons:[`nodes(${d})`,n?`explicit`:`connectors(${u.connectorLines})`]}}function Qr(e){return e.type!==`code`||!Yr(e.lang)?!1:Zr(e.value,{explicit:Xr(e.lang)}).isTree}function $r(e){let t=0;for(let n of e)t+=1+$r(n.children);return t}var ei=/(?:[$€£¥]\s?\d+(?:[.,]\d+)*(?:\s?(?:[MBK]|million|billion|thousand))?|\d+(?:[.,]\d+)*\s?(?:%|‰|x|×|[MBK]|million|billion|thousand|percent|years?|days?|hours?)|\d{3,}(?:[.,]\d+)*)/i;function ti(e){let t=ei.exec(e);return!t||t.index===void 0?null:{value:t[0],index:t.index,end:t.index+t[0].length}}var ni=Object.freeze({hasImage:!1,imageCount:0,hasVideo:!1,hasBlockquote:!1,hasList:!1,hasTable:!1,hasDate:!1,hasNumberHighlight:!1,wordCount:0}),ri=[/\b(January|February|March|April|May|June|July|August|September|October|November|December)\s+(\d{1,2},?\s+)?\d{4}\b/i,/\b\d{1,2}\s+(January|February|March|April|May|June|July|August|September|October|November|December)\s+\d{4}\b/i,/\b(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Sept|Oct|Nov|Dec)\.?\s+\d{1,2},?\s+\d{4}\b/i,/\b\d{4}-\d{2}-\d{2}\b/,/\b\d{1,2}\/\d{1,2}\/\d{2,4}\b/,/\bQ[1-4]\s+\d{4}\b/,/\b\d{4}s\b/,/\b\d{1,2}(st|nd|rd|th)\s+century\b/i],ii=/(youtube\.com|youtu\.be|vimeo\.com|wistia\.|loom\.com)/i;function ai(e,t){let n=r(e,`htmlBlock`),i=r(e,`htmlInline`),a=[],o=e=>{if(e.type===`htmlElement`){t.has(e.tagName.toLowerCase())&&a.push(e);for(let t of e.children)o(t)}};for(let e of n)for(let t of e.htmlChildren)o(t);for(let e of i)if(Array.isArray(e.htmlChildren))for(let t of e.htmlChildren)o(t);return a}function oi(e){if(!e||e.length===0)return{...ni};let t=0,n=!1,a=!1,s=!1,c=[];for(let i of e)t+=r(i,`image`).length,t+=r(i,`imageReference`).length,r(i,`blockquote`).length>0&&(n=!0),r(i,`list`).length>0&&(a=!0),r(i,`table`).length>0&&(s=!0),c.push(o(i));let l={type:`document`,children:e},u=ai(l,new Set([`img`]));t+=u.length;let d=ai(l,new Set([`video`,`iframe`,`source`])),f=!1;for(let e of d){if(e.tagName.toLowerCase()===`video`){f=!0;break}let t=e.attributes.src||e.attributes.href||``;if(ii.test(t)){f=!0;break}}if(!f){let e=r(l,`link`);for(let t of e)if(t.url&&ii.test(t.url)){f=!0;break}}let p=c.join(` `).trim(),m=p?p.split(/\s+/).length:0,h=!1;for(let e of ri)if(e.test(p)){h=!0;break}let g=!1;i(l,e=>{if(g)return!0;if(e.type!==`paragraph`)return;let t=o(e).trim();return!t||!ti(t)||t.split(/\s+/).length<=8&&(g=!0),!0});let _=!1,v=[];for(let t of e)v.push(...r(t,`code`));if(v.length===1&&sn(v[0].lang)&&!s&&t===0&&!f){let e=Math.max(0,p.length-v[0].value.length),t=cn(v[0].lang);e<=400&&ln(v[0].value,{explicit:t}).isDiagram&&(_=!0)}let y=!1;if(!_&&v.length===1&&xr(v[0].lang)&&!s&&t===0&&!f){let e=Math.max(0,p.length-v[0].value.length),t=Sr(v[0].lang);e<=400&&Cr(v[0].value,{explicit:t}).isTimeline&&(y=!0)}let b=!1;if(!_&&!y&&v.length===1&&Yr(v[0].lang)&&!s&&t===0&&!f){let e=Math.max(0,p.length-v[0].value.length),t=Xr(v[0].lang);e<=400&&Zr(v[0].value,{explicit:t}).isTree&&(b=!0)}return{hasImage:t>0,imageCount:t,hasVideo:f,hasBlockquote:n,hasList:a,hasTable:s,hasDate:h,hasNumberHighlight:g,wordCount:m,hasAsciiDiagram:_,hasTimeline:y,hasTree:b}}var si=[`title`,`sectionHeader`,`factCard`,`twoColumn`];function ci(e){let t=new Set,n=!1;if(e.hasAsciiDiagram&&(n=!0,t.add(`diagram`)),e.hasTimeline&&(n=!0,t.add(`timeline`)),e.hasTree&&(n=!0,t.add(`tree`)),e.hasImage&&(n=!0,t.add(`imageWithCaption`),t.add(`leftFeature`),t.add(`rightFeature`),e.imageCount>=2&&t.add(`photoGrid`)),e.hasVideo&&(n=!0,t.add(`videoWithCaption`),e.hasBlockquote&&t.add(`videoPullQuote`)),e.hasBlockquote&&(n=!0,t.add(`quote`),t.add(`pullQuote`),t.add(`fullBleedQuote`)),e.hasList&&(n=!0,t.add(`list`)),e.hasTable&&(n=!0,t.add(`dataTable`),t.add(`comparisonBar`),t.add(`columnChart`),t.add(`barChart`),t.add(`lineChart`),t.add(`pieChart`)),e.hasDate&&(n=!0,t.add(`dateEvent`)),e.hasNumberHighlight&&(n=!0,t.add(`statHighlight`)),n)t.add(`title`),t.add(`sectionHeader`);else for(let e of si)t.add(e);return Array.from(t)}function li(e,t=0){if(e.hasAsciiDiagram)return`diagram`;if(e.hasTimeline)return`timeline`;if(e.hasTree)return`tree`;if(e.hasTable)return`dataTable`;if(e.hasVideo)return`videoWithCaption`;if(e.imageCount>=2)return`photoGrid`;if(e.hasImage)return t%2==0?`leftFeature`:`rightFeature`;if(e.hasBlockquote)return`quote`;if(e.hasNumberHighlight)return`statHighlight`;if(e.hasList)return`list`}function ui(e,t){let n=new Set(ci(e)),r=[],i=[];for(let e of t)n.has(e)?r.push(e):i.push(e);return{recommended:r,rest:i}}var di=200;function fi(e,t){let n=t?.wordsPerMinute,r=typeof n==`number`&&n>0?n:di,i=e.split(/\s+/).filter(e=>e.length>0).length,a=i/r;return{words:i,minutes:a,seconds:Math.round(a*60)}}var pi={"dark-vignette":`radial-gradient(ellipse at center, rgba(26,32,44,0.8) 0%, rgba(0,0,0,0.95) 100%)`,"radial-dark":`radial-gradient(ellipse at center, #1a202c 0%, #000000 100%)`,"warm-sunset":`linear-gradient(135deg, rgba(124,58,48,0.9) 0%, rgba(46,20,16,0.95) 100%)`,"cool-blue":`linear-gradient(135deg, rgba(26,54,93,0.9) 0%, rgba(26,32,44,0.95) 100%)`,"earth-tones":`linear-gradient(135deg, rgba(68,51,34,0.9) 0%, rgba(30,22,15,0.95) 100%)`};function mi(e){return{type:`shape`,id:`persistent-bg-solid`,content:{shape:`rect`,fill:e.color},position:{x:0,y:0,width:`100%`,height:`100%`}}}function hi(e){return{type:`shape`,id:`persistent-bg-gradient`,content:{shape:`rect`,fill:e.gradient??pi[e.preset??`dark-vignette`]},position:{x:0,y:0,width:`100%`,height:`100%`}}}function gi(e){let t=[],n=e.opacity??.4,r={type:`image`,id:`persistent-bg-image`,content:{src:e.src,alt:`Background`,fit:`cover`,...e.blur!=null&&e.blur>0?{blur:e.blur}:{}},position:{x:0,y:0,width:`100%`,height:`100%`},animation:e.ambientMotion?{type:e.ambientMotion,duration:30}:void 0};return t.push(r),t.push({type:`shape`,id:`persistent-bg-overlay`,content:{shape:`rect`,fill:`rgba(0,0,0,${.5+(1-n)*.3})`},position:{x:0,y:0,width:`100%`,height:`100%`}}),t}function _i(e){if(e.pattern===`noise`)return{type:`shape`,id:`persistent-grain`,content:{shape:`rect`,fill:`#000000`,filter:{type:`noise`,opacity:e.opacity??.05}},position:{x:0,y:0,width:`100%`,height:`100%`}};let t=e.opacity??.06;return{type:`shape`,id:`persistent-bg-pattern`,content:{shape:`rect`,pattern:{kind:e.pattern,color:e.color??`#ffffff`,size:Math.round(24*(e.scale??1)),opacity:t}},position:{x:0,y:0,width:`100%`,height:`100%`}}}function vi(e){let t=Math.max(0,Math.min(1,e.strength??.3)),n=e.color??`#000000`,r=C(n,t);return{type:`shape`,id:`persistent-vignette`,content:{shape:`rect`,fill:`radial-gradient(ellipse at center, ${C(n,0)} 55%, ${r} 100%)`},position:{x:0,y:0,width:`100%`,height:`100%`}}}function yi(e,t){return{type:`shape`,id:`persistent-ambient-gradient`,content:{shape:`rect`,fill:`linear-gradient(150deg, ${e.from??t?.colors.backgroundLight??`#1a202c`} 0%, ${e.to??(t?b(t.colors.background,.04):`#0f141d`)} 100%)`},position:{x:`-5%`,y:`-5%`,width:`110%`,height:`110%`},animation:{type:`slowZoom`,panDirection:`left`,duration:e.duration??40}}}function bi(e){let t=[],n=e.fontSize??18,r=!!e.subtitle,i=e.position.includes(`bottom`),a=e.position.includes(`left`),o=1.5,s=r?`15%`:`7%`,c=i?r?`78%`:`84%`:`2%`,l=e.showThumbnail?30:28,u=a?3:97-l,d=`${u}%`,f=r?6:5,p=`${f}%`,m=r?`10%`:`5%`,h=u+o,g=l-o*2,_=e.showThumbnail&&a?`${h+f+o}%`:`${h}%`,v=e.showThumbnail?`${g-f-o}%`:`${g}%`,y=i?r?`80%`:`86%`:`4%`;if(t.push({type:`shape`,id:`persistent-caption-bg`,content:{shape:`rect`,fill:`rgba(0,0,0,0.6)`,borderRadius:8},position:{x:d,y:c,width:`${l}%`,height:s}}),e.showThumbnail&&e.thumbnailSrc){let n=a?`${h}%`:`${u+l-o-f}%`,s=i?r?`79.5%`:`85%`:`3%`;t.push({type:`image`,id:`persistent-caption-thumb`,content:{src:e.thumbnailSrc,alt:`Article thumbnail`,fit:`cover`},position:{x:n,y:s,width:p,height:m}})}if(t.push({type:`text`,id:`persistent-caption-title`,content:{text:e.title,style:{fontSize:n,fontWeight:`bold`,color:`rgba(255,255,255,0.9)`,textAlign:a?`left`:`right`,maxLines:1}},position:{x:_,y,width:v}}),r){let n=i?`85.5%`:`8%`;t.push({type:`text`,id:`persistent-caption-subtitle`,content:{text:e.subtitle,style:{fontSize:18,fontWeight:`normal`,color:`rgba(255,255,255,0.55)`,textAlign:a?`left`:`right`}},position:{x:_,y:n,width:v}})}return t}function xi(e){let t=e.position.includes(`bottom`),n=e.position.includes(`left`)?`3%`:`90%`,r=t?`94%`:`3%`;return e.isImage?{type:`image`,id:`persistent-branding`,content:{src:e.content,alt:`Branding`,fit:`contain`},position:{x:n,y:r,width:`8%`,height:`4%`}}:{type:`text`,id:`persistent-branding`,content:{text:e.content,style:{fontSize:14,fontWeight:`normal`,color:`rgba(255,255,255,0.6)`}},position:{x:n,y:r}}}function Si(e){let t=e.color??`rgba(255,255,255,0.3)`,n=e.position===`top`?`1%`:`98%`;return{type:`shape`,id:`persistent-progress`,content:{shape:`rect`,fill:t,borderRadius:2},position:{x:`5%`,y:n,width:`90%`,height:`0.5%`}}}function Ci(e,t){if(!l(e))return[s(e)];let n=e.config;switch(n.type){case`solidBackground`:return[mi(n)];case`gradientBackground`:return[hi(n)];case`imageBackground`:return gi(n);case`patternBackground`:return[_i(n)];case`vignette`:return[vi(n)];case`ambientGradient`:return[yi(n,t)];case`titleCaption`:return bi(n);case`cornerBranding`:return[xi(n)];case`progressIndicator`:return[Si(n)];default:return console.warn(`Unknown persistent layer template:`,n.type),[]}}function wi(e,t){return!e||e.length===0?[]:e.reduce((e,n)=>e.concat(Ci(n,t)),[])}function Ti(e){return e.persistentLayers??{}}function Ei(e,t){let n=e.persistentLayers;if(n&&((n.bottomLayers?.length??0)>0||(n.topLayers?.length??0)>0))return n;let r=t.persistentLayers;return r&&((r.bottomLayers?.length??0)>0||(r.topLayers?.length??0)>0)?r:n}function Di(e,t,n,r){if(n.length===0&&r.length===0)return e;let i=t.useBottomLayer!==!1,a=t.useTopLayer!==!1;return[...i?n.map(e=>s(e)):[],...e,...a?r.map(e=>s(e)):[]]}var Oi={bg:`#1a365d`,text:`#63b3ed`,accent:`#90cdf4`};function F(e,t){let n=e.theme.colorSchemes;if(t&&t in n)return n[t];let r=Object.keys(n);return r.length>0?n[r[0]]:Oi}var ki=`system-ui, -apple-system, "Segoe UI", Roboto, sans-serif`,Ai=`Georgia, "Times New Roman", serif`,ji=`Consolas, "Courier New", monospace`;function I(e,t){let{typography:n}=e.theme;switch(t){case`title`:return w(n.titleFont,Ai);case`body`:return w(n.bodyFont,ki);case`mono`:return w(n.monoFont,ji)}}function L(e,t,n=!1){let{fontScale:r,layout:i,theme:a}=t,o=n?i.titleScale:i.bodyScale,s=n?a.typography.titleScale??1:a.typography.bodyScale??1;return Math.round(e*r*o*s)}function Mi(e,t){return e*(t.theme.style.animationSpeed??1)}function Ni(e,t){let n=e.theme.renderStyle;return t===`text`?n.defaultTextAnimation:n.defaultImageAnimation}function R(e,t,n){let r=Ni(e,t);return!r||r===`slowZoom`||r===n.type?n:{...n,type:r}}function z(e){return e.theme.style.textShadow??!0}function Pi(e){return e.theme.style.overlayOpacity??.5}function B(e,t){if(t===`none`)return;let n=e.theme.style.imageTreatment,r=t?{type:t,strength:n?.strength}:n;if(!(!r||r.type===`none`))return r.type===`duotone`&&!r.color?{...r,color:e.theme.colors.primary}:r}function V(e,t=160){let{background:n,backgroundLight:r}=e.theme.colors;return`linear-gradient(${t}deg, ${r} 0%, ${b(n,.04)} 100%)`}function Fi(e,t){let n=t??Math.max(.55,Pi(e));return C(e.theme.colors.background,n)}function Ii(e,t,n,r){let i=e.theme.renderStyle.templateHints;if(!i)return r;let a=i[t];return!a||!(n in a)?r:a[n]}var Li=/[.;:!?]+$/;function Ri(e){return e.replace(Li,``).trim()}function zi(e,t){return{type:`shape`,id:e,content:{shape:`rect`,fill:t},position:{x:0,y:0,width:`100%`,height:`100%`}}}function H(e,t,n,r){let i=t*.52,a=Math.max(8,Math.floor(n/i));return Math.max(1,Math.ceil(e.length/a))*t*r}function Bi(e,t){let{title:n,subtitle:r,backgroundColor:i}=e,{theme:a,layout:o,viewport:s}=t,c=L(96,t,!0),l=L(36,t,!1),u=i||a.colors.primary,d=parseFloat(o.maxTextWidth)/100*s.width,f=H(n,c,d,1.15),p=56+(Math.max(1,Math.round(f/(c*1.15)))>1?c*.25:0),m=r?42:48,h=e=>e/s.height*100,g=[{type:`shape`,id:`bg`,content:{shape:`rect`,fill:a.colors.background},position:{x:0,y:0,width:`100%`,height:`100%`}},{type:`shape`,id:`bg-tint`,content:{shape:`rect`,fill:`radial-gradient(ellipse at 50% 40%, ${C(u,.32)} 0%, ${C(u,0)} 75%)`},position:{x:0,y:0,width:`100%`,height:`100%`}}];if(Ii(t,`title`,`showAccentLine`,!0)&&g.push({type:`shape`,id:`accent-line`,content:{shape:`rect`,fill:C(a.colors.text,.3)},position:{x:`44%`,y:`${m-h(f/2+56)}%`,width:`12%`,height:`3px`}}),g.push({type:`text`,id:`title`,content:{text:n,style:{fontSize:c,fontFamily:I(t,`title`),fontWeight:`bold`,color:a.colors.text,textAlign:`center`,shadow:z(t)}},position:{x:`50%`,y:`${m}%`,anchor:`center`,width:o.maxTextWidth},animation:R(t,`text`,{type:`fadeIn`,duration:2})}),r){let e=H(r,l,d,1.5);g.push({type:`text`,id:`subtitle`,content:{text:r,style:{fontSize:l,fontFamily:I(t,`body`),color:a.colors.textMuted,textAlign:`center`,lineHeight:1.5}},position:{x:`50%`,y:`${m+h(f/2+p+e/2)}%`,anchor:`center`,width:o.maxTextWidth},animation:{type:`fadeIn`,duration:1.5,delay:1}})}return g}var Vi=/^(\d+(?:\.\d+)?)\s*%?$/,Hi={textCenterX:`50%`,textWidth:`85%`,textYAdjust:0,adjustY:!1};function Ui(e,t){if(!e)return;let n=t===void 0?{}:{duration:t};switch(e){case`zoomIn`:case`in`:return{type:`slowZoom`,direction:`in`,...n};case`zoomOut`:case`out`:return{type:`slowZoom`,direction:`out`,...n};case`panLeft`:case`left`:return{type:`slowZoom`,panDirection:`left`,...n};case`panRight`:case`right`:return{type:`slowZoom`,panDirection:`right`,...n};default:return}}var Wi=35,Gi=`${Wi}%`;function Ki(e){switch(e){case`left-strip`:return{textCenterX:`${50+Wi/2}%`,textWidth:`${100-Wi-8}%`,textYAdjust:0,adjustY:!1};case`right-strip`:return{textCenterX:`${50-Wi/2}%`,textWidth:`${100-Wi-8}%`,textYAdjust:0,adjustY:!1};case`bottom-strip`:return{textCenterX:`50%`,textWidth:`85%`,textYAdjust:-10,adjustY:!0};case`corner-inset`:return{textCenterX:`45%`,textWidth:`70%`,textYAdjust:0,adjustY:!1};default:return Hi}}function qi(e,t,n){let r=[],{src:i,alt:a,position:o,ambientMotion:s,credit:c,license:l}=e;switch(o){case`left-strip`:r.push(Ji(i,a,`left`,t,s,c,l,n)),r.push(Yi(`left`,t));break;case`right-strip`:r.push(Ji(i,a,`right`,t,s,c,l,n)),r.push(Yi(`right`,t));break;case`bottom-strip`:r.push(Xi(i,a,t,s,c,l,n)),r.push(Zi(t));break;case`corner-inset`:r.push(Qi(i,a,t,s,c,l,n)),r.push($i(t));break}return r}function Ji(e,t,n,r,i,a,o,s){return{type:`image`,id:`${r}-accent-img`,content:{src:e,alt:t,fit:`cover`,credit:a,license:o,...s?{treatment:s}:{}},position:{x:n===`left`?0:`${100-Wi}%`,y:0,width:Gi,height:`100%`},animation:Ui(i,15)}}function Yi(e,t){let n=e===`left`?`accent-gradient-left`:`accent-gradient-right`;return{type:`shape`,id:`${t}-accent-fade`,content:{shape:`rect`,fill:`url(#${n})`},position:{x:e===`left`?`${Wi-8}%`:`${100-Wi}%`,y:0,width:`10%`,height:`100%`}}}function Xi(e,t,n,r,i,a,o){return{type:`image`,id:`${n}-accent-img`,content:{src:e,alt:t,fit:`cover`,credit:i,license:a,...o?{treatment:o}:{}},position:{x:0,y:`${100-Wi}%`,width:`100%`,height:Gi},animation:Ui(r,15)}}function Zi(e){return{type:`shape`,id:`${e}-accent-fade`,content:{shape:`rect`,fill:`url(#accent-gradient-bottom)`},position:{x:0,y:`${100-Wi-8}%`,width:`100%`,height:`12%`}}}function Qi(e,t,n,r,i,a,o){return{type:`image`,id:`${n}-accent-img`,content:{src:e,alt:t,fit:`cover`,credit:i,license:a,...o?{treatment:o}:{}},position:{x:`70%`,y:`60%`,width:`28%`,height:`38%`,anchor:`top-left`},animation:Ui(r,15)??{type:`fadeIn`,duration:2,delay:.5}}}function $i(e){return{type:`shape`,id:`${e}-accent-vignette`,content:{shape:`rect`,fill:`url(#accent-vignette-corner)`,borderRadius:8},position:{x:`69%`,y:`59%`,width:`30%`,height:`40%`}}}function U(e,t){if(!t.adjustY||t.textYAdjust===0)return typeof e==`number`?`${e}%`:e;let n=typeof e==`number`?`${e}`:e,r=n.match(Vi);if(r){let e=parseFloat(r[1]);return`${Math.max(5,e+t.textYAdjust)}%`}return n}function ea(e,t){let{title:n=``,colorScheme:r=`blue`,imageSrc:i,imageAlt:a,ambientMotion:o}=e,{theme:s,layout:c}=t,l=B(t,e.imageTreatment),u=F(t,r),d=L(84,t,!0),f=[];return i?(f.push({type:`image`,id:`bg-image`,content:{src:i,alt:a||n,fit:`cover`,...l?{treatment:l}:{}},position:{x:0,y:0,width:`100%`,height:`100%`},animation:Ui(o,8)??{type:`slowZoom`,duration:8,direction:`in`}}),f.push({type:`shape`,id:`overlay`,content:{shape:`rect`,fill:Fi(t)},position:{x:0,y:0,width:`100%`,height:`100%`}})):(f.push({type:`shape`,id:`bg`,content:{shape:`rect`,fill:u.bg},position:{x:0,y:0,width:`100%`,height:`100%`}}),f.push({type:`shape`,id:`line-top`,content:{shape:`rect`,fill:C(u.text,.2)},position:{x:`50%`,y:`40%`,width:`20%`,height:`2px`,anchor:`center`}}),f.push({type:`shape`,id:`line-bottom`,content:{shape:`rect`,fill:C(u.text,.2)},position:{x:`50%`,y:`60%`,width:`20%`,height:`2px`,anchor:`center`}})),f.push({type:`text`,id:`title`,content:{text:n,style:{fontSize:d,fontFamily:I(t,`title`),fontWeight:`bold`,color:i?s.colors.text:u.text,textAlign:`center`,shadow:z(t)}},position:{x:`50%`,y:`50%`,anchor:`center`,width:c.maxTextWidth},animation:R(t,`text`,{type:`fadeIn`,duration:1.5})}),f}var ta=1.05,na=.92,ra=.86,ia=.62,aa=48;function oa(e,t){let n=1,r=0;for(let i of e){let e=r===0?i:r+1+i;e<=t?r=e:(n+=1,r=i)}return n}function sa(e,t){let n=t.width*na,r=t.height*ra,i=e.trim().split(/\s+/).filter(Boolean).map(e=>e.length);if(i.length===0)return Math.floor(r/ta);let a=n/(ia*Math.max(...i)),o=r/ta,s=e=>{let t=Math.max(1,Math.floor(n/(e*ia)));return oa(i,t)*e*ta<=r},c=aa,l=Math.min(a,o);if(l<=c)return Math.max(aa,Math.floor(l));if(!s(c))return aa;for(let e=0;e<24;e+=1){let e=(c+l)/2;s(e)?c=e:l=e}return Math.floor(c)}function ca(e){return`radial-gradient(ellipse at 50% 50%, ${C(e,.92)} 0%, ${C(e,.78)} 38%, ${C(e,.32)} 66%, ${C(e,0)} 88%)`}function la(e,t){let{title:n=``,imageSrc:r,imageAlt:i,ambientMotion:a}=e,{theme:o,viewport:s}=t,c=B(t,e.imageTreatment),l=n.toUpperCase(),u=sa(l,s),d=[];return r?d.push({type:`image`,id:`bigtext-image`,content:{src:r,alt:i||n,fit:`cover`,...c?{treatment:c}:{}},position:{x:0,y:0,width:`100%`,height:`100%`},animation:Ui(a,8)??{type:`slowZoom`,duration:8,direction:`in`}},{type:`shape`,id:`bigtext-bloom`,content:{shape:`rect`,fill:ca(o.colors.background)},position:{x:0,y:0,width:`100%`,height:`100%`}}):d.push({type:`shape`,id:`bigtext-bg`,content:{shape:`rect`,fill:o.colors.background},position:{x:0,y:0,width:`100%`,height:`100%`}},{type:`shape`,id:`bigtext-tint`,content:{shape:`rect`,fill:`radial-gradient(ellipse at 50% 50%, ${C(o.colors.primary,.38)} 0%, ${C(o.colors.primary,.14)} 48%, ${C(o.colors.primary,0)} 78%)`},position:{x:0,y:0,width:`100%`,height:`100%`}}),d.push({type:`text`,id:`bigtext-title`,content:{text:l,style:{fontSize:u,fontFamily:I(t,`title`),fontWeight:`bold`,color:o.colors.text,textAlign:`center`,lineHeight:ta,shadow:!!r,shrinkToFit:!0}},position:{x:`50%`,y:`50%`,anchor:`center`,width:`${na*100}%`,height:`${ra*100}%`},animation:R(t,`text`,{type:`fadeIn`,duration:1})}),d}var ua={gapX:260,gapY:140,gridPad:80,gridOriginX:80,gridOriginY:80};function da(e,t={}){let n={...ua,...t},r=[],i=[],a=[];for(let t=0;t<e.length;t++){let n=e[t],r=typeof n.x==`number`,o=typeof n.y==`number`;r&&o?i.push({child:n,pinned:!0,x:n.x,y:n.y}):(i.push({child:n,pinned:!1,x:0,y:0}),a.push(t))}if(a.length>0){let e=Math.max(1,Math.ceil(Math.sqrt(a.length))),t=n.gridOriginX,r=n.gridOriginY,o=i.filter(e=>e.pinned);if(o.length>0){let e=Math.min(...o.map(e=>e.x)),i=Math.max(...o.map(e=>e.y));t=e,r=i+n.gridPad+n.gapY}a.forEach((a,o)=>{let s=o%e,c=Math.floor(o/e);i[a].x=t+s*n.gapX,i[a].y=r+c*n.gapY})}let o=i.map(e=>({id:e.child.id,label:e.child.title??e.child.id,x:e.x,y:e.y,pinned:e.pinned,...e.child.classes&&e.child.classes.length>0?{classes:e.child.classes}:{}})),s=new Set(o.map(e=>e.id)),c=[],l=new Set;for(let t of e)if(t.connectsTo)for(let e of t.connectsTo){if(!s.has(e.target)){r.push(`Edge from "${t.id}" to "${e.target}" dropped: no such sibling node`);continue}let n=fa(t.id,e);l.has(n)||(l.add(n),c.push({id:n,source:t.id,target:e.target,...e.type?{type:e.type}:{}}))}return{nodes:o,edges:c,warnings:r}}function fa(e,t){return t.type?`${e}->${t.target}:${t.type}`:`${e}->${t.target}`}var pa=14,ma=28;function ha(e,t){return{x:e*14,y:t*28}}function ga(e,t){return{col:Math.max(0,Math.round(e/14)),row:Math.max(0,Math.round(t/28))}}function _a(e){let t=e.nodes.map(e=>({id:e.id,label:e.label,...ha(e.col,e.row),w:e.wCols*14,h:e.hRows*28,...e.containerId?{container:e.containerId}:{}})),n=va(t,e.edges);return{nodes:t,edges:e.edges.map((e,t)=>({source:e.source,target:e.target,...e.label?{label:e.label}:{},...e.directed?{}:{directed:!1},...n[t],routing:`orthogonal`}))}}function va(e,t){let n=new Map(e.map(e=>[e.id,e])),r=t.map(e=>{let t=n.get(e.source),r=n.get(e.target);if(!t||!r)return{sourceAnchor:{side:`right`,offset:.5},targetAnchor:{side:`left`,offset:.5}};let i=t.w??168,a=t.h??84,o=r.w??168,s=r.h??84,c=r.x+o/2-(t.x+i/2),l=r.y+s/2-(t.y+a/2),u=Math.abs(c)/Math.max(1,(i+o)/2);return Math.abs(l)/Math.max(1,(a+s)/2)>=u?l>=0?{sourceAnchor:{side:`bottom`,offset:.5},targetAnchor:{side:`top`,offset:.5}}:{sourceAnchor:{side:`top`,offset:.5},targetAnchor:{side:`bottom`,offset:.5}}:c>=0?{sourceAnchor:{side:`right`,offset:.5},targetAnchor:{side:`left`,offset:.5}}:{sourceAnchor:{side:`left`,offset:.5},targetAnchor:{side:`right`,offset:.5}}});return ba(r,t,e,`source`),ba(r,t,e,`target`),ya(r,t,e),r}function ya(e,t,n){let r=new Map(n.map(e=>[e.id,e])),i=new Map;t.forEach((e,t)=>{let n=i.get(e.source)??[];n.push(t),i.set(e.source,n)});for(let[n,a]of i){if(a.length<2)continue;let i=r.get(n),o=a.map(e=>r.get(t[e].target)).filter(e=>e!==void 0);if(!i||o.length!==a.length)continue;let s=i.w??168,c=i.h??84,l=i.x+s,u=i.y+c,d=e=>e.x+(e.w??168),f=e=>e.y+(e.h??84),p,m;if(o.every(e=>e.y>=u)?(p=`bottom`,m=`top`):o.every(e=>f(e)<=i.y)?(p=`top`,m=`bottom`):o.every(e=>e.x>=l)?(p=`right`,m=`left`):o.every(e=>d(e)<=i.x)&&(p=`left`,m=`right`),!(!p||!m))for(let t of a)e[t]={sourceAnchor:{side:p,offset:.5},targetAnchor:{side:m,offset:.5}}}}function ba(e,t,n,r){let i=new Map(n.map(e=>[e.id,e])),a=new Map;for(let n=0;n<t.length;n++){let i=t[n],o=r===`source`?e[n].sourceAnchor:e[n].targetAnchor,s=`${r===`source`?i.source:i.target}:${o.side}`,c=a.get(s)??[];c.push(n),a.set(s,c)}for(let n of a.values()){if(n.length<2)continue;let a=r===`source`?e[n[0]].sourceAnchor.side:e[n[0]].targetAnchor.side;n.sort((e,n)=>{let o=i.get(r===`source`?t[e].target:t[e].source),s=i.get(r===`source`?t[n].target:t[n].source);return(a===`top`||a===`bottom`?o?.x??0:o?.y??0)-(a===`top`||a===`bottom`?s?.x??0:s?.y??0)||e-n}),n.forEach((t,i)=>{let a=r===`source`?e[t].sourceAnchor:e[t].targetAnchor;a.offset=(i+1)/(n.length+1)})}}function xa(e,t,n={}){let r=new Set(e.map(e=>e.id));return{nodes:e.map(e=>{let{col:t,row:n}=ga(e.x,e.y),i=e.label.length>0?e.label.split(`
|
|
17
17
|
`):[],a=i.reduce((e,t)=>Math.max(e,t.length),0),o=typeof e.w==`number`?Math.max(3,Math.round(e.w/14)):a+4,s=typeof e.h==`number`?Math.max(3,Math.round(e.h/28)):i.length+2;return{id:e.id,label:e.label,col:t,row:n,wCols:Math.max(o,3),hRows:Math.max(s,3),...e.container&&r.has(e.container)&&e.container!==e.id?{containerId:e.container}:{}}}),edges:t.filter(e=>r.has(e.source)&&r.has(e.target)).map(e=>({source:e.source,target:e.target,...e.label?{label:e.label}:{},directed:e.directed!==!1})),style:n.style??`unicode`,warnings:[]}}function Sa(e,t={}){let n=da(e),r=xa(n.nodes.map(e=>({id:e.id,label:e.label,x:e.x,y:e.y})),n.edges.map(e=>({source:e.source,target:e.target,...e.type?{label:e.type}:{}})),t);return r.warnings.push(...n.warnings),r}function Ca(e){let t=e.tracks.length>0?Math.min(...e.tracks.map(e=>e.startColumn)):0,n=e.tracks.length>0?Math.max(...e.tracks.map(e=>e.endColumn)):1,r=Math.max(1,n-t);return{tracks:e.tracks.map(e=>({id:e.id,...e.label?{label:e.label}:{},...e.endLabel?{endLabel:e.endLabel}:{},events:e.events.map(e=>({id:e.id,label:e.label,...e.description?{description:e.description}:{},position:wa((e.column-t)/r),...e.side?{side:e.side}:{},...e.descriptionSide?{descriptionSide:e.descriptionSide}:{},...e.callout===!1?{callout:!1}:{},...e.marker?{marker:e.marker}:{}}))})),links:e.links.map(e=>({...e}))}}function wa(e){return Math.max(0,Math.min(1,e))}function Ta(e){return{items:e.roots.map(Ea)}}function Ea(e){return{id:e.id,label:e.label,...e.isDir?{isDir:!0}:{},...e.comment?{comment:e.comment}:{},children:e.children.map(Ea)}}function Da(e,t={}){return{roots:e.map(Oa),style:t.style??`unicode`,warnings:[]}}function Oa(e){let t=Array.isArray(e.children)?e.children.map(Oa):[];return{id:typeof e.id==`string`&&e.id?e.id:`node`,label:typeof e.label==`string`?e.label:``,children:t,isDir:e.isDir===!0||t.length>0,...e.comment?{comment:e.comment}:{}}}function ka(e){let t=new Map,n=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`node`,r=e=>{let r=n(e.replace(/\/$/,``)),i=t.get(r)??0;return t.set(r,i+1),i===0?r:`${r}-${i+1}`},i=e=>{let t=e.children.find(e=>e.type!==`list`),n=t?o(t).trim():``,a=e.children.filter(e=>e.type===`list`),s=[];for(let e of a)for(let t of e.children)s.push(i(t));return{id:r(n),label:n,children:s,isDir:n.endsWith(`/`)||s.length>0}};return{roots:e.children.map(i),style:`unicode`,warnings:[]}}function Aa(e){return e?.find(e=>e.type===`list`)}var ja=/\.(?:webm|mp4|mov|m4v|ogv)(?:[?#].*)?$/i;function Ma(e){return!e||e.length===0?``:e.filter(e=>!(e.type===`code`&&e.lang?.trim().toLowerCase()===`mermaid`)).map(e=>o(e)).join(`
|
|
18
|
-
`).trim()}function Na(e){return Ra(e).map(e=>e.text)}function W(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function Pa(e){return e.map(e=>{switch(e.type){case`text`:return W(e.value);case`emphasis`:return`<em>${Pa(e.children)}</em>`;case`strong`:return`<strong>${Pa(e.children)}</strong>`;case`delete`:return`<del>${Pa(e.children)}</del>`;case`superscript`:return`<sup>${Pa(e.children)}</sup>`;case`subscript`:return`<sub>${Pa(e.children)}</sub>`;case`inlineCode`:return`<code>${W(e.value)}</code>`;case`link`:{let t=Pa(e.children),n=
|
|
18
|
+
`).trim()}function Na(e){return Ra(e).map(e=>e.text)}function W(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function Pa(e){return e.map(e=>{switch(e.type){case`text`:return W(e.value);case`emphasis`:return`<em>${Pa(e.children)}</em>`;case`strong`:return`<strong>${Pa(e.children)}</strong>`;case`delete`:return`<del>${Pa(e.children)}</del>`;case`superscript`:return`<sup>${Pa(e.children)}</sup>`;case`subscript`:return`<sub>${Pa(e.children)}</sub>`;case`inlineCode`:return`<code>${W(e.value)}</code>`;case`link`:{let t=Pa(e.children),n=ce(e.url,`link`);if(!n)return t;let r=e.title?` title="${W(e.title)}"`:``;return`<a href="${W(n)}"${r}>${t}</a>`}case`break`:return`<br>`;case`image`:return W(e.alt??``);case`inlineMath`:return W(`$${e.value}$`);case`footnoteReference`:return W(`[^${e.label??e.identifier}]`);case`linkReference`:case`textDirective`:return Pa(e.children);case`imageReference`:return W(e.alt??``);case`mention`:return W(`@${e.displayName}`);case`inlineIcon`:return`<i class="fa-${e.family} fa-${e.name}" aria-hidden="true"></i>`;case`htmlInline`:return W(e.rawHtml)}}).join(``)}function Fa(e){let t=e=>e.map((t,n)=>{let i=e[n-1],a=i?Math.max(0,Ia(i,t)-2):0;return`${`<div data-squisq-source-gap aria-hidden="true"><br></div>`.repeat(a)}${r(t)}`}).join(``),n=e=>{let n=e.ordered?`ol`:`ul`;return`<${n}${e.ordered&&e.start!=null?` start="${e.start}"`:``}>${e.children.map(e=>`<li>${e.checked==null?``:`<span>${e.checked?`[x]`:`[ ]`} </span>`}${t(e.children)}</li>`).join(``)}</${n}>`},r=e=>{switch(e.type){case`paragraph`:return`<p>${Pa(e.children)}</p>`;case`heading`:return`<h${e.depth}>${Pa(e.children)}</h${e.depth}>`;case`blockquote`:return`<blockquote>${t(e.children)}</blockquote>`;case`list`:return n(e);case`code`:return`<pre><code>${W(e.value)}</code></pre>`;case`thematicBreak`:return`<hr>`;case`table`:{let[t,...n]=e.children,r=(e,t)=>`<tr>${e.map(e=>{let n=t?`th`:`td`;return`<${n}>${Pa(e.children)}</${n}>`}).join(``)}</tr>`;return`<table>${t?`<thead>${r(t.children,!0)}</thead>`:``}${n.length?`<tbody>${n.map(e=>r(e.children,!1)).join(``)}</tbody>`:``}</table>`}case`math`:return`<pre><code>${W(e.value)}</code></pre>`;case`definition`:return``;default:{let t=o(e).trim();return t?`<p>${W(t)}</p>`:``}}};return t(e)}function Ia(e,t){let n=e.position?.end.line,r=t.position?.start.line;return n==null||r==null||r<=n?2:Math.max(2,r-n)}function La(e){return e.map(e=>e.type===`paragraph`||e.type===`heading`?Pa(e.children):W(o(e))).join(`<br>`)}function Ra(e){if(!e)return[];let t=[];for(let n of e)if(n.type===`list`)for(let e of n.children){let n=o(e).trim();if(!n)continue;let r=La(e.children),i=W(n).replace(/\r?\n/g,`<br>`);t.push({text:n,markdown:e.children,...r&&r!==i?{html:r}:{}})}return t}function za(e){if(e===void 0)return;let t=parseFloat(e);return Number.isFinite(t)&&t>0?t:void 0}function Ba(e,t=1/0){if(!e||e.length===0)return[];let n=[];function r(e){for(let i of e){if(n.length>=t)return;if(!i||typeof i!=`object`)continue;let e=i;if(e.type===`htmlElement`&&e.tagName===`img`){let t=e.attributes;t&&typeof t.src==`string`&&t.src&&n.push({src:t.src,alt:typeof t.alt==`string`?t.alt:``,width:za(t.width),height:za(t.height)})}Array.isArray(e.children)&&r(e.children)}}function i(e){if(n.length>=t||!e||typeof e!=`object`)return;let a=e;if(a.type===`image`&&typeof a.url==`string`&&a.url){n.push({src:a.url,alt:typeof a.alt==`string`?a.alt:``});return}if((a.type===`htmlBlock`||a.type===`htmlInline`)&&Array.isArray(a.htmlChildren)&&r(a.htmlChildren),Array.isArray(a.children))for(let e of a.children)i(e)}for(let r of e){if(n.length>=t)break;i(r)}return n}function Va(e){return Ba(e,1)[0]??null}function Ha(e,t=1/0){if(!e||e.length===0)return[];let n=[],r=new Set,i=e=>{!e.src||n.length>=t||r.has(e.src)||(r.add(e.src),n.push(e))};function a(e){if(Array.isArray(e))for(let t of e){if(!t||typeof t!=`object`)continue;let e=t;if(e.tagName===`source`){let t=e.attributes;if(typeof t?.src==`string`&&t.src)return t.src}let n=a(e.children);if(n)return n}}function s(e){if(n.length>=t||!e||typeof e!=`object`)return;let r=e;if(r.type===`htmlElement`&&r.tagName===`video`){let e=r.attributes,t=e?.src||a(r.children);if(t){let n=e?.[`data-squisq-video-start-at`]?ue(e[`data-squisq-video-start-at`]):null,r=e?.[`data-squisq-video-clip-start`]?ue(e[`data-squisq-video-clip-start`]):null,a=e?.[`data-squisq-video-clip-end`]?ue(e[`data-squisq-video-clip-end`]):null;i({src:t,...e?.poster?{posterSrc:e.poster}:{},alt:e?.[`aria-label`]||e?.title||e?.alt||``,...n==null?{}:{startAt:n},...r==null?{}:{clipStart:r},...a==null?{}:{clipEnd:a}})}}else(r.type===`link`||r.type===`image`)&&typeof r.url==`string`&&ja.test(r.url)&&i({src:r.url,alt:typeof r.alt==`string`?r.alt:o(r).trim()});Array.isArray(r.children)&&r.children.forEach(s),Array.isArray(r.htmlChildren)&&r.htmlChildren.forEach(s)}return e.forEach(s),n}function Ua(e){return Ha(e,1)[0]??null}function Wa(e){if(!e)return null;for(let t of e)if(t.type===`table`){let e=t,[n,...r]=e.children;return n?{headers:n.children.map(e=>o(e).trim()),rows:r.map(e=>e.children.map(e=>o(e).trim())),align:e.align}:null}return null}function Ga(e){if(!e)return``;for(let t of e)if(t.type===`blockquote`)return o(t).trim();return``}function Ka(e){if(!e)return null;let t=e.findIndex(e=>e.type===`paragraph`);return t<0?null:{node:e[t],index:t}}function qa(e){for(let t of e.children)if(!(t.type===`text`&&t.value.trim()===``))return t.type===`strong`&&o(t).trim().match(/^(?:[$€£¥]\s*)?[+-]?\d+(?:[.,]\d+)*(?:\s?(?:[%‰x×]|[A-Za-z]+))?/)?.[0].trim()||null;return null}function Ja(e,t,n){let r=e.slice(0,t).trim(),i=e.slice(n);return i=r?i.trim():i.replace(/^\s*(?:[-–—:]\s*)?/,``),[r,i].filter(Boolean).join(` `).trim()}function Ya(e,t,n,r,i){return e?e.map((e,a)=>a===t?Ja(n,r,i):o(e).trim()).filter(Boolean).join(`
|
|
19
19
|
`).trim():``}function Xa(e,t,n){let r=Ka(t);if(r){let n=o(r.node).trim(),i=qa(r.node);if(i){let a=n.indexOf(i);return{stat:i,description:Ya(t,r.index,n,a,a+i.length)||e||i}}}let i=e.trim(),a=ti(i);if(a&&a.index===0&&a.end===i.length)return{stat:e,description:n||e};if(r){let n=o(r.node).trim(),i=ti(n);if(i){let a=Ya(t,r.index,n,i.index,i.end);return{stat:i.value,description:a||e||i.value}}}return{stat:e,description:n||e}}function Za(e){return e.replace(/\s+/g,` `).trim()}function Qa(e,t){let n=t??[];switch(e){case`quote`:return n.length===1&&n[0]?.type===`blockquote`;case`dataTable`:return n.length===1&&n[0]?.type===`table`;case`list`:return n.length===1&&n[0]?.type===`list`;case`diagram`:case`timeline`:return n.length===1&&n[0]?.type===`code`;case`tree`:return n.length===1&&(n[0]?.type===`code`||n[0]?.type===`list`);case`photoGrid`:{let e=Ba(n);if(e.length<2||e.length>4)return!1;let t=Za(Ma(n)),r=Za(e.map(e=>e.alt).filter(Boolean).join(` `));return t===``||t===r}case`videoWithCaption`:{let e=Ha(n);return e.length===1&&Za(Ma(n))===Za(e[0]?.alt??``)}case`leftFeature`:case`rightFeature`:case`statHighlight`:return!0;default:return!1}}function $a(e,t,n,r={}){let i=r.placeholders===!0,a=Ma(n);switch(e){case`statHighlight`:{let e=Xa(t,n,a);return r.preserveSourceHeading&&t&&e.stat!==t&&e.description!==t?{...e,description:t,...e.description?{detail:e.description}:{}}:e}case`quote`:{let e=Ga(n)||a;return e?{quote:e,...t?{title:t}:{}}:{quote:t}}case`fullBleedQuote`:case`pullQuote`:return{text:Ga(n)||a||t};case`factCard`:return{fact:t,explanation:a||t};case`comparisonBar`:return i?{leftLabel:`A`,leftValue:60,rightLabel:`B`,rightValue:40}:null;case`list`:{let e=Na(n);return e.length>0?{items:e,...t?{title:t}:{}}:i?{items:[`Item 1`,`Item 2`,`Item 3`]}:null}case`definitionCard`:return{term:t,definition:a||t};case`dateEvent`:return{date:t,description:a||t};case`dataTable`:{let e=Wa(n);return e?{...e,...t?{title:t}:{}}:i?{headers:[`Column`],rows:[[`Data`]]}:null}case`barChart`:case`columnChart`:case`pieChart`:case`donutChart`:case`lineChart`:case`areaChart`:case`scatterChart`:{let e=Wa(n);return e?{headers:e.headers,rows:e.rows,...t?{title:t}:{}}:i&&!a.trim()?{headers:[`Quarter`,`Revenue`,`Costs`],rows:[[`Q1`,`40`,`28`],[`Q2`,`55`,`31`],[`Q3`,`48`,`30`],[`Q4`,`62`,`35`]],...t?{title:t}:{}}:null}case`imageWithCaption`:{let e=Va(n);return e?{imageSrc:e.src,imageAlt:e.alt||t,caption:t}:i?{caption:t}:null}case`bigText`:{let e=Va(n);return{title:t,...e?{imageSrc:e.src,imageAlt:e.alt||t}:{}}}case`photoGrid`:{let e=Ba(n,4);return e.length<2?i?{}:null:{images:e.map(e=>({src:e.src,alt:e.alt})),caption:t}}case`videoWithCaption`:{let e=Ua(n);return e?{videoSrc:e.src,posterSrc:e.posterSrc,videoAlt:e.alt||t,caption:t}:i?{caption:t}:null}case`leftFeature`:case`rightFeature`:{let e=Va(n);return!e&&!i?null:{imageSrc:e?.src??``,imageAlt:e?.alt||t,imageWidth:e?.width,imageHeight:e?.height,title:t,body:a}}case`diagram`:{let e=(n??[]).filter(e=>e.type===`code`),r=e.length===1&&sn(e[0].lang)?e[0]:void 0,a=r?ln(r.value,{explicit:cn(r.lang)}):void 0;if(!a?.isDiagram||!a.diagram)return i?{}:null;let{nodes:o,edges:s}=_a(a.diagram);return{nodes:o,edges:s,...t?{title:t}:{}}}case`timeline`:{let e=(n??[]).filter(e=>e.type===`code`),r=e.length===1&&xr(e[0].lang)?e[0]:void 0,a=r?Cr(r.value,{explicit:!0}):void 0;if(!a?.isTimeline||!a.timeline)return i?{}:null;let{tracks:o,links:s}=Ca(a.timeline);return{tracks:o,links:s,...t?{title:t}:{}}}case`tree`:{let e=(n??[]).filter(e=>e.type===`code`),r=e.length===1&&Yr(e[0].lang)?e[0]:void 0;if(r){let e=Zr(r.value,{explicit:Xr(r.lang)});if(e.isTree&&e.tree){let{items:n}=Ta(e.tree);return{items:n,...t?{title:t}:{}}}}let a=Aa(n);if(a){let{items:e}=Ta(ka(a));if(e.length>0)return{items:e,...t?{title:t}:{}}}return i?{}:null}default:return i?{}:null}}function eo(e){return(e.block?.contents??[]).filter(e=>!(e.type===`code`&&e.lang?.trim().toLowerCase()===`mermaid`))}function to(e,t=0){let n=` `.repeat(t);return e.children.flatMap((r,i)=>{let a=r.children.filter(e=>e.type!==`list`).map(e=>o(e).trim()).filter(Boolean).join(` `),s=e.ordered?`${(e.start??1)+i}.`:`•`,c=a?[`${n}${s} ${a}`]:[];for(let e of r.children)e.type===`list`&&c.push(to(e,t+1));return c}).join(`
|
|
20
20
|
`)}function no(e){return e.map((t,n)=>{let r=t.type===`list`?to(t):o(t);return n===0?r:`${`
|
|
21
21
|
`.repeat(Ia(e[n-1],t))}${r}`}).join(``).trim()}function ro(e,t){return L(e.length>1800?18:e.length>1100?21:e.length>650?24:28,t,!1)}function io(e,t){let{theme:n}=t,r=e.title??t.block?.title??``,i=eo(t),a=no(i),o=Fa(i),s=[zi(`bg`,n.colors.background)];return r&&s.push({type:`text`,id:`title`,content:{text:r,style:{fontSize:L(46,t,!0),fontFamily:I(t,`title`),fontWeight:`bold`,color:n.colors.text,textAlign:`left`,lineHeight:1.15,shadow:z(t)}},position:{x:`8%`,y:`9%`,width:`84%`,height:`15%`,anchor:`top-left`}}),a&&s.push({type:`text`,id:`body`,content:{text:a,...o?{html:o}:{},style:{fontSize:ro(a,t),fontFamily:I(t,`body`),color:n.colors.text,textAlign:`left`,lineHeight:1.35,shadow:z(t)}},position:{x:`8%`,y:r?`28%`:`10%`,width:`84%`,height:r?`64%`:`82%`,anchor:`top-left`}}),s}function ao(e,t){let{stat:n,description:r,detail:i,colorScheme:a=`blue`,accentImage:o}=e,{theme:s}=t,c=F(t,a),l=o?Ki(o.position):Hi,u=L(148,t,!0),d=L(32,t,!1),f=L(26,t,!1),p=[zi(`bg`,V(t,180))];return o&&p.push(...qi(o,e.id,B(t,e.imageTreatment))),p.push({type:`text`,id:`stat`,content:{text:n,style:{fontSize:u,fontFamily:I(t,`title`),fontWeight:`bold`,color:c.text,shadow:z(t)}},position:{x:l.textCenterX,y:U(`36%`,l),anchor:`center`},animation:Ii(t,`statHighlight`,`entrance`,`subtle`)===`dramatic`?{type:`zoomIn`,duration:.4}:{type:`zoomIn`,duration:.6}}),p.push({type:`text`,id:`description`,content:{text:r,style:{fontSize:d,fontFamily:I(t,`body`),color:s.colors.textMuted,textAlign:`center`,lineHeight:1.5,shadow:z(t)}},position:{x:l.textCenterX,y:U(`54%`,l),width:l.textWidth,anchor:`center`},animation:{type:`fadeIn`,duration:1,delay:.3}}),i&&p.push({type:`text`,id:`detail`,content:{text:i,style:{fontSize:f,fontFamily:I(t,`body`),color:c.text,textAlign:`center`,shadow:z(t)}},position:{x:l.textCenterX,y:U(`66%`,l),width:l.textWidth,anchor:`center`},animation:{type:`fadeIn`,duration:1,delay:1}}),p}function oo(e,t){let{title:n,quote:r,attribution:i,accentImage:a}=e,{theme:o,viewport:s}=t,c=a?Ki(a.position):Hi,l=L(48,t,!0),u=L(34,t,!0),d=L(26,t,!1),f=Math.max(o.typography.titleLineHeight??1.4,1.25),p=L(280,t,!0),m=[zi(`bg`,V(t,160))];a&&m.push(...qi(a,e.id,B(t,e.imageTreatment))),n&&m.push({type:`text`,id:`quote-title`,content:{text:n,style:{fontSize:u,fontFamily:I(t,`body`),fontWeight:`bold`,color:o.colors.textMuted,textAlign:`center`,shadow:z(t)}},position:{x:c.textCenterX,y:U(`14%`,c),width:c.textWidth,anchor:`center`},animation:{type:`fadeIn`,duration:.8}}),m.push({type:`text`,id:`deco-quote`,content:{text:`“`,style:{fontSize:p,fontFamily:I(t,`title`),color:C(o.colors.text,.09),textAlign:`center`}},position:{x:c.textCenterX,y:U(`26%`,c),anchor:`center`}});let h=i?45:n?52:50;if(m.push({type:`text`,id:`quote`,content:{text:r,style:{fontSize:l,fontFamily:I(t,`title`),color:o.colors.text,textAlign:`center`,lineHeight:f,shadow:z(t)}},position:{x:c.textCenterX,y:U(`${h}%`,c),anchor:`center`,width:c.textWidth},animation:R(t,`text`,{type:`fadeIn`,duration:2})}),i){let e=H(r,l,parseFloat(c.textWidth)/100*s.width,f),n=l*1.7,a=Math.min(82,h+(e/2+n)/s.height*100);m.push({type:`text`,id:`attribution`,content:{text:`\u2014 ${i}`,style:{fontSize:d,fontFamily:I(t,`body`),color:o.colors.textMuted,textAlign:`center`,shadow:z(t)}},position:{x:c.textCenterX,y:U(`${a}%`,c),anchor:`center`},animation:{type:`fadeIn`,duration:1,delay:1.5}})}return m}function so(e,t){let{fact:n,explanation:r,source:i,accentImage:a}=e,{theme:o,viewport:s}=t,c=a?Ki(a.position):Hi,l=L(56,t,!0),u=L(34,t,!1),d=L(20,t,!1),f=[zi(`bg`,V(t,170))];a&&f.push(...qi(a,e.id,B(t,e.imageTreatment)));let p=parseFloat(c.textWidth)/100*s.width,m=H(n,l,p,1.3),h=H(r,u,p,1.5),g=i?d*1.4:0,_=l*.9,v=i?u*1.1:0,y=47-(m+_+h+v+g)/2/s.height*100,b=e=>y+e/s.height*100,x=b(m/2),S=b(m+_+h/2),C=b(m+_+h+v+g/2);return f.push({type:`text`,id:`fact`,content:{text:n,style:{fontSize:l,fontFamily:I(t,`title`),fontWeight:`bold`,color:o.colors.text,textAlign:`center`,lineHeight:1.3,shadow:z(t)}},position:{x:c.textCenterX,y:U(`${x}%`,c),width:c.textWidth,anchor:`center`},animation:R(t,`text`,{type:`fadeIn`,duration:1.5})}),f.push({type:`text`,id:`explanation`,content:{text:r,style:{fontSize:u,fontFamily:I(t,`body`),color:o.colors.textMuted,textAlign:`center`,lineHeight:1.5,shadow:z(t)}},position:{x:c.textCenterX,y:U(`${S}%`,c),width:c.textWidth,anchor:`center`},animation:R(t,`text`,{type:`fadeIn`,duration:1,delay:.8})}),i&&f.push({type:`text`,id:`source`,content:{text:i,style:{fontSize:d,fontFamily:I(t,`body`),color:o.colors.textMuted,textAlign:`center`,shadow:z(t)}},position:{x:c.textCenterX,y:U(`${C}%`,c),anchor:`center`},animation:{type:`fadeIn`,duration:.8,delay:1.5}}),f}function co(e,t){let{left:n,right:r,header:i,leftColor:a=`green`,rightColor:o=`blue`}=e;if(!n?.label||!r?.label)return[];let{theme:s,layout:l,orientation:u}=t,d=F(t,a),f=F(t,o),p=c(u),m=l.stackColumns,h=m?`85%`:`42%`,g=L(36,t,!0),_=L(44,t,!0),v=L(22,t,!1),y=i&&!m?22:15,b=i&&!m?64:70,x=[{type:`shape`,id:`bg`,content:{shape:`rect`,fill:V(t,135)},position:{x:0,y:0,width:`100%`,height:`100%`}}];if(!m){let e=C(s.colors.text,.05);x.push({type:`shape`,id:`left-panel`,content:{shape:`rect`,fill:e,borderRadius:12},position:{x:`3%`,y:`${y}%`,width:`44%`,height:`${b}%`}}),x.push({type:`shape`,id:`right-panel`,content:{shape:`rect`,fill:e,borderRadius:12},position:{x:`53%`,y:`${y}%`,width:`44%`,height:`${b}%`}})}let S=m?`8%`:`12%`;i&&x.push({type:`text`,id:`header`,content:{text:i,style:{fontSize:g,fontFamily:I(t,`title`),fontWeight:`bold`,color:s.colors.text,textAlign:`center`}},position:{x:`50%`,y:S,anchor:`center`},animation:R(t,`text`,{type:`fadeIn`,duration:.8})});let w,T,E,D;if(m)w=i?`30%`:`25%`,T=i?`40%`:`35%`,E=i?`60%`:`55%`,D=i?`70%`:`65%`;else{let e=y+b/2;w=`${e-4}%`,T=`${e+7}%`,E=`${e-4}%`,D=`${e+7}%`}x.push({type:`text`,id:`left-label`,content:{text:n.label,style:{fontSize:_,fontFamily:I(t,`body`),fontWeight:`bold`,color:d.text,textAlign:`center`,lineHeight:1.3}},position:{x:p.left.x,y:w,anchor:`center`,width:h},animation:R(t,`text`,{type:`fadeIn`,duration:1})}),n.sublabel&&x.push({type:`text`,id:`left-sublabel`,content:{text:n.sublabel,style:{fontSize:v,fontFamily:I(t,`body`),color:s.colors.textMuted,textAlign:`center`,lineHeight:1.4}},position:{x:p.left.x,y:T,anchor:`center`,width:h},animation:{type:`fadeIn`,duration:.8,delay:.3}});let O=L(64,t,!0),k=m?`48%`:`${y+b/2}%`,A=m?`↓`:`→`;return x.push({type:`text`,id:`connector`,content:{text:A,style:{fontSize:O,fontFamily:I(t,`title`),fontWeight:`bold`,color:C(s.colors.text,.45),textAlign:`center`}},position:{x:`50%`,y:k,anchor:`center`},animation:{type:`fadeIn`,duration:.6,delay:.4}}),x.push({type:`text`,id:`right-label`,content:{text:r.label,style:{fontSize:_,fontFamily:I(t,`body`),fontWeight:`bold`,color:f.text,textAlign:`center`,lineHeight:1.3}},position:{x:p.right.x,y:E,anchor:`center`,width:h},animation:R(t,`text`,{type:`fadeIn`,duration:1,delay:.5})}),r.sublabel&&x.push({type:`text`,id:`right-sublabel`,content:{text:r.sublabel,style:{fontSize:v,fontFamily:I(t,`body`),color:s.colors.textMuted,textAlign:`center`,lineHeight:1.4}},position:{x:p.right.x,y:D,anchor:`center`,width:h},animation:{type:`fadeIn`,duration:.8,delay:.8}}),x}var lo={neutral:`#63b3ed`,somber:`#e53e3e`,celebratory:`#68d391`};function uo(e,t){let{date:n,description:r,footer:i,mood:a=`neutral`,accentImage:o}=e,{theme:s}=t,c=lo[a],l=x(s.colors.background)>.5?b(c,.25):c,u=o?Ki(o.position):Hi,d=L(96,t,!0),f=L(30,t,!1),p=L(26,t,!1),m=[{type:`shape`,id:`bg`,content:{shape:`rect`,fill:V(t,135)},position:{x:0,y:0,width:`100%`,height:`100%`}}];return o&&m.push(...qi(o,e.id,B(t,e.imageTreatment))),m.push({type:`text`,id:`date`,content:{text:n,style:{fontSize:d,fontFamily:I(t,`title`),fontWeight:`bold`,color:l,shadow:z(t)}},position:{x:u.textCenterX,y:U(`35%`,u),anchor:`center`},animation:{type:`fadeIn`,duration:1.5}}),m.push({type:`text`,id:`description`,content:{text:r,style:{fontSize:f,fontFamily:I(t,`body`),color:s.colors.text,textAlign:`center`,lineHeight:1.6,shadow:z(t)}},position:{x:u.textCenterX,y:U(`58%`,u),width:u.textWidth,anchor:`center`},animation:{type:`fadeIn`,duration:2,delay:1}}),i&&m.push({type:`text`,id:`footer`,content:{text:i,style:{fontSize:p,fontFamily:I(t,`body`),color:s.colors.textMuted,shadow:z(t)}},position:{x:u.textCenterX,y:U(`72%`,u),anchor:`center`},animation:{type:`fadeIn`,duration:1,delay:3}}),m}function fo(e,t){let{imageSrc:n,imageAlt:r,caption:i,captionPosition:a=`bottom`,ambientMotion:o,isTitle:s,subtitle:c,imageCredit:l,imageLicense:u}=e,d=i&&Ri(i),{theme:f,layout:p}=t,m=B(t,e.imageTreatment),h=L(30,t,!1),g=L(96,t,!0),_=L(36,t,!1),v=e.kenBurns,y=Ui(o||v),b=[{type:`image`,id:`bg-image`,content:{src:n,alt:r,fit:`cover`,credit:l,license:u,...m?{treatment:m}:{}},position:{x:0,y:0,width:`100%`,height:`100%`},animation:y}],x=f.colors.background;if(s&&d)return b.push({type:`shape`,id:`title-gradient`,content:{shape:`rect`,fill:`linear-gradient(0deg, ${C(x,.85)} 0%, ${C(x,.45)} 40%, ${C(x,.1)} 70%, ${C(x,0)} 100%)`},position:{x:0,y:0,width:`100%`,height:`100%`}}),b.push({type:`text`,id:`title`,content:{text:d,style:{fontSize:g,fontFamily:I(t,`title`),fontWeight:`bold`,color:f.colors.text,textAlign:`center`,shadow:z(t)}},position:{x:`50%`,y:c?`70%`:`75%`,anchor:`center`,width:p.maxTextWidth},animation:{type:`fadeIn`,duration:.8}}),c&&b.push({type:`text`,id:`subtitle`,content:{text:c,style:{fontSize:_,fontFamily:I(t,`body`),color:f.colors.textMuted,textAlign:`center`,lineHeight:1.5}},position:{x:`50%`,y:`82%`,anchor:`center`,width:p.maxTextWidth},animation:{type:`fadeIn`,duration:.8,delay:.2}}),b;if(d){let e=a===`top`?`7%`:a===`center`?`42%`:`68%`,n=a===`top`?`13%`:a===`center`?`48%`:`74%`;b.push({type:`shape`,id:`caption-gradient`,content:{shape:`rect`,fill:`linear-gradient(90deg, ${C(x,0)}, ${C(x,.78)} 16%, ${C(x,.78)} 84%, ${C(x,0)})`},position:{x:0,y:e,width:`100%`,height:`16%`}}),b.push({type:`text`,id:`caption`,content:{text:d,style:{fontSize:h,fontFamily:I(t,`body`),color:f.colors.text,textAlign:`center`,shadow:z(t),lineHeight:1.18,maxLines:2}},position:{x:`50%`,y:n,anchor:`center`,width:`78%`},animation:{type:`fadeIn`,duration:1.5,delay:.5}})}return b}function po(e,t,n){let{imageSrc:r,imageAlt:i,imageWidth:a,imageHeight:o,title:s,body:c}=e,{theme:l,layout:u}=t,d=B(t,e.imageTreatment),f=(a??0)>0||(o??0)>0,p=u.stackColumns,m=L(48,t,!0),h=L(24,t,!1),g,_,v,y,b;p?(g=`0`,_=`0`,v=`100%`,y=`50%`,b=f?`contain`:`cover`):f?(g=`${n===`left`?5:55}%`,_=`5%`,v=`40%`,y=`90%`,b=`contain`):(g=n===`left`?`0`:`50%`,_=`0`,v=`50%`,y=`100%`,b=`cover`);let x=p?90:42,S=p?`${(100-x)/2}%`:n===`left`?`54%`:`6%`,C=p?`60%`:c?`42%`:`50%`,w=p?`78%`:s?`55%`:`50%`,T=`top-left`,E=`left`,D=[{type:`shape`,id:`feature-bg`,content:{shape:`rect`,fill:l.colors.background},position:{x:0,y:0,width:`100%`,height:`100%`}}];return r&&D.push({type:`image`,id:`feature-image`,content:{src:r,alt:i??s??``,fit:b,...d?{treatment:d}:{}},position:{x:g,y:_,width:v,height:y}}),s&&D.push({type:`text`,id:`feature-title`,content:{text:s,style:{fontSize:m,fontFamily:I(t,`title`),fontWeight:`bold`,color:l.colors.text,textAlign:E,lineHeight:1.2}},position:{x:S,y:C,anchor:T,width:`${x}%`},animation:R(t,`text`,{type:`fadeIn`,duration:.8})}),c&&D.push({type:`text`,id:`feature-body`,content:{text:c,style:{fontSize:h,fontFamily:I(t,`body`),color:l.colors.textMuted,textAlign:E,lineHeight:1.5}},position:{x:S,y:w,anchor:T,width:`${x}%`},animation:R(t,`text`,{type:`fadeIn`,duration:.8,delay:.2})}),D}function mo(e,t){return po(e,t,`left`)}function ho(e,t){return po(e,t,`right`)}function go(e,t){let{center:n,zoom:r,mapStyle:i=`terrain`,title:a,caption:o,markers:s,ambientMotion:c,staticSrc:l}=e,{theme:u,layout:d}=t,f=L(64,t,!0),p=L(32,t,!1),m=Ui(c),h=[{type:`map`,id:`map-bg`,content:{center:n,zoom:r,style:i,markers:s,showAttribution:!0,staticSrc:l},position:{x:0,y:0,width:`100%`,height:`100%`},animation:m}],g=u.colors.background;return a&&(h.push({type:`shape`,id:`title-overlay`,content:{shape:`rect`,fill:`linear-gradient(180deg, ${C(g,.85)} 0%, ${C(g,.6)} 70%, ${C(g,0)} 100%)`},position:{x:0,y:0,width:`100%`,height:`20%`}}),h.push({type:`text`,id:`title`,content:{text:a,style:{fontSize:f,fontFamily:I(t,`title`),fontWeight:`bold`,color:u.colors.text,textAlign:`center`,shadow:z(t)}},position:{x:`50%`,y:`9%`,anchor:`center`,width:d.maxTextWidth},animation:{type:`fadeIn`,duration:1,delay:.3}})),o&&(h.push({type:`shape`,id:`caption-overlay`,content:{shape:`rect`,fill:`linear-gradient(0deg, ${C(g,.85)} 0%, ${C(g,.6)} 70%, ${C(g,0)} 100%)`},position:{x:0,y:`80%`,width:`100%`,height:`20%`}}),h.push({type:`text`,id:`caption`,content:{text:o,style:{fontSize:p,fontFamily:I(t,`body`),color:u.colors.text,textAlign:`center`,shadow:z(t)}},position:{x:`50%`,y:d.captionY,anchor:`center`,width:d.maxTextWidth},animation:{type:`fadeIn`,duration:1,delay:.5}})),h}function _o(e,t){let{text:n,colorScheme:r=`blue`}=e,i=F(t,r),a=L(120,t,!0);return[{type:`shape`,id:`bg`,content:{shape:`rect`,fill:`radial-gradient(ellipse at 50% 50%, ${i.bg} 0%, ${b(i.bg,.12)} 100%)`},position:{x:0,y:0,width:`100%`,height:`100%`}},{type:`text`,id:`impact-text`,content:{text:n,style:{fontSize:a,fontFamily:I(t,`title`),fontWeight:`bold`,color:i.text,textAlign:`center`,lineHeight:1.2,shadow:z(t)}},position:{x:`50%`,y:`50%`,anchor:`center`,width:`85%`},animation:Ii(t,`fullBleedQuote`,`entrance`,`subtle`)===`dramatic`?{type:`zoomIn`,duration:.8}:{type:`fadeIn`,duration:1.5}}]}var vo=1.2,yo=18;function bo(e,t,n){if(!e.trim())return 1;let r=Math.floor(n/(t*.5));if(r<=0)return 1;let i=0,a=0;for(let t of e.split(/\s+/)){let e=a?a+1+t.length:t.length;if(e<=r){a=e;continue}a&&(i+=1);let n=t.length;for(;n>r;)i+=1,n-=r;a=n}return Math.max(1,i+ +!!a)}function xo(e,t){let{title:n,accentImage:r}=e,i=Array.isArray(e.items)?e.items:[],a=Ra(t.block?.contents),{theme:o}=t,s=r?Ki(r.position):Hi,c=L(44,t,!0),l=L(34,t,!1),u=[{type:`shape`,id:`bg`,content:{shape:`rect`,fill:`linear-gradient(155deg, ${o.colors.backgroundLight} 0%, ${o.colors.background} 100%)`},position:{x:0,y:0,width:`100%`,height:`100%`}}];r&&u.push(...qi(r,e.id,B(t,e.imageTreatment)));let d=parseFloat(s.textCenterX),f=parseFloat(s.textWidth),p=Number.isFinite(d)&&Number.isFinite(f)?d-f/2:8,m=`${p}%`,h=n?34:26;n&&u.push({type:`text`,id:`list-title`,content:{text:n,style:{fontSize:c,fontFamily:I(t,`title`),fontWeight:`bold`,color:o.colors.text,textAlign:`left`,shadow:z(t)}},position:{x:m,y:U(`20%`,s),width:s.textWidth},animation:R(t,`text`,{type:`fadeIn`,duration:1})});let g=(Number.isFinite(f)?f/100:.85)*t.viewport.width,_=`${i.length}.`,v=Math.max(l,_.length*l*.5),y=v+l*.35,b=`${p+y/t.viewport.width*100}%`,x=Math.max(l,g-y),S=h;for(let e=0;e<i.length;e++){let n=i[e],r=a[e]?.text===n?a[e]?.html:void 0,c=bo(n,l,x),d=R(t,`text`,{type:`fadeIn`,duration:.8,delay:.3+.3*e});u.push({type:`text`,id:`item-${e}-marker`,content:{text:`${e+1}.`,style:{fontSize:l,fontFamily:I(t,`body`),color:o.colors.text,textAlign:`right`,lineHeight:vo,shadow:z(t)}},position:{x:m,y:U(`${S}%`,s),width:v},animation:d}),u.push({type:`text`,id:`item-${e}`,content:{text:n,...r?{html:r}:{},style:{fontSize:l,fontFamily:I(t,`body`),color:o.colors.text,textAlign:`left`,lineHeight:vo,shadow:z(t)}},position:{x:b,y:U(`${S}%`,s),width:x},animation:d});let f=c*l*vo;S+=(f+yo)/t.viewport.height*100}return u}var G=1.2;function So(e,t){let{images:n,caption:r,ambientMotion:i}=e;if(!n||n.length===0)return[];let a=r&&Ri(r),{theme:o,layout:s}=t,c=B(t,e.imageTreatment),l=[{type:`shape`,id:`bg`,content:{shape:`rect`,fill:o.colors.background},position:{x:0,y:0,width:`100%`,height:`100%`}}],u=Co(n.length,100,s.stackColumns);for(let e=0;e<Math.min(n.length,4);e++){let t=n[e],r=u[e];l.push({type:`shape`,id:`grid-placeholder-${e}`,content:{shape:`rect`,fill:o.colors.background},position:{x:`${r.x}%`,y:`${r.y}%`,width:`${r.w}%`,height:`${r.h}%`}}),l.push({type:`image`,id:`grid-img-${e}`,content:{src:t.src,alt:t.alt,fit:`cover`,credit:t.credit,license:t.license,...c?{treatment:c}:{}},position:{x:`${r.x}%`,y:`${r.y}%`,width:`${r.w}%`,height:`${r.h}%`},animation:e===0&&i?{type:i,duration:15}:{type:`fadeIn`,duration:1,delay:.2*e}})}if(a){let e=L(s.stackColumns?24:26,t,!1),n=s.stackColumns?`78%`:`74%`,r=s.stackColumns?`72%`:`68%`,i=s.stackColumns?`13%`:`16%`,c=o.colors.background;l.push({type:`shape`,id:`caption-bg`,content:{shape:`rect`,fill:`linear-gradient(90deg, ${C(c,0)}, ${C(c,.78)} 16%, ${C(c,.78)} 84%, ${C(c,0)})`},position:{x:0,y:r,width:`100%`,height:i}}),l.push({type:`text`,id:`caption`,content:{text:a,style:{fontSize:e,fontFamily:I(t,`body`),color:o.colors.text,textAlign:`center`,shadow:!0,lineHeight:1.18,maxLines:s.stackColumns?2:1}},position:{x:`50%`,y:n,anchor:`center`,width:`78%`},animation:{type:`fadeIn`,duration:1,delay:.5}})}return l}function Co(e,t,n){let r=50-G/2,i=t/2-G/2;switch(e){case 1:return[{x:0,y:0,w:100,h:t}];case 2:return n?[{x:0,y:0,w:100,h:i},{x:0,y:t/2+G/2,w:100,h:i}]:[{x:0,y:0,w:r,h:t},{x:50+G/2,y:0,w:r,h:t}];case 3:{if(n){let e=t/3-G*2/3;return[{x:0,y:0,w:100,h:e},{x:0,y:t/3+G/3,w:100,h:e},{x:0,y:t*2/3+G*2/3,w:100,h:e}]}let e=60-G/2,r=40-G/2;return[{x:0,y:0,w:e,h:t},{x:60+G/2,y:0,w:r,h:i},{x:60+G/2,y:t/2+G/2,w:r,h:i}]}default:return[{x:0,y:0,w:r,h:i},{x:50+G/2,y:0,w:r,h:i},{x:0,y:t/2+G/2,w:r,h:i},{x:50+G/2,y:t/2+G/2,w:r,h:i}]}}function wo(e,t){let{term:n,definition:r,origin:i,colorScheme:a=`blue`,accentImage:o}=e,{theme:s}=t,c=F(t,a),l=o?Ki(o.position):Hi,u=L(72,t,!0),d=L(32,t,!1),f=L(22,t,!1),p=[zi(`bg`,V(t,145))];return o&&p.push(...qi(o,e.id,B(t,e.imageTreatment))),p.push({type:`text`,id:`term`,content:{text:n,style:{fontSize:u,fontFamily:I(t,`title`),fontWeight:`bold`,color:c.text,textAlign:`center`,shadow:z(t)}},position:{x:l.textCenterX,y:U(`30%`,l),anchor:`center`},animation:R(t,`text`,{type:`fadeIn`,duration:1.5})}),p.push({type:`shape`,id:`separator`,content:{shape:`rect`,fill:`${c.text}33`},position:{x:l.textCenterX,y:U(`42%`,l),width:`30%`,height:`2px`,anchor:`center`}}),p.push({type:`text`,id:`definition`,content:{text:r,style:{fontSize:d,fontFamily:I(t,`body`),color:s.colors.text,textAlign:`center`,lineHeight:1.6,maxLines:4,shadow:z(t)}},position:{x:l.textCenterX,y:U(`55%`,l),width:l.textWidth,anchor:`center`},animation:R(t,`text`,{type:`fadeIn`,duration:1,delay:.8})}),i&&p.push({type:`text`,id:`origin`,content:{text:i,style:{fontSize:f,fontFamily:I(t,`body`),color:s.colors.textMuted,textAlign:`center`,shadow:z(t)}},position:{x:l.textCenterX,y:U(`70%`,l),anchor:`center`},animation:{type:`fadeIn`,duration:.8,delay:1.5}}),p}function To(e,t){let{leftLabel:n,rightLabel:r,unit:i,colorScheme:a=`blue`}=e,{theme:o,viewport:s}=t,c=F(t,a),l=Number.isFinite(e.leftValue)?e.leftValue:0,u=Number.isFinite(e.rightValue)?e.rightValue:0,d=L(28,t,!1),f=L(48,t,!0),p=e=>Number.isFinite(e)?e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}K`:e.toLocaleString():`—`,m=i?`${p(l)} ${i}`:p(l),h=i?`${p(u)} ${i}`:p(u),g=Math.max(0,l),_=Math.max(0,u),v=Math.max(g,_,1),y=Math.max(m.length,h.length)*f*.58/s.width*100,b=Math.max(20,Math.min(65,81-y-2)),x=g/v*b,S=_/v*b;return[{type:`shape`,id:`bg`,content:{shape:`rect`,fill:V(t,180)},position:{x:0,y:0,width:`100%`,height:`100%`}},{type:`text`,id:`left-label`,content:{text:n,style:{fontSize:d,fontFamily:I(t,`body`),color:o.colors.textMuted}},position:{x:`15%`,y:`28%`}},{type:`text`,id:`left-value`,content:{text:m,style:{fontSize:f,fontFamily:I(t,`body`),fontWeight:`bold`,color:c.text}},position:{x:`${15+x+2}%`,y:`35%`},animation:{type:`fadeIn`,duration:.8,delay:.3}},{type:`shape`,id:`left-bar`,content:{shape:`rect`,fill:c.text,borderRadius:4},position:{x:`15%`,y:`36%`,width:`${x}%`,height:`6%`},animation:{type:`fadeIn`,duration:1}},{type:`text`,id:`right-label`,content:{text:r,style:{fontSize:d,fontFamily:I(t,`body`),color:o.colors.textMuted}},position:{x:`15%`,y:`50%`}},{type:`text`,id:`right-value`,content:{text:h,style:{fontSize:f,fontFamily:I(t,`body`),fontWeight:`bold`,color:c.accent}},position:{x:`${15+S+2}%`,y:`57%`},animation:{type:`fadeIn`,duration:.8,delay:.6}},{type:`shape`,id:`right-bar`,content:{shape:`rect`,fill:c.accent,borderRadius:4},position:{x:`15%`,y:`58%`,width:`${S}%`,height:`6%`},animation:{type:`fadeIn`,duration:1,delay:.3}}]}function Eo(e,t){let{text:n,attribution:r,backgroundImage:i,ambientMotion:a}=e,{viewport:o}=t,s=B(t,e.imageTreatment);if(!i?.src)return[];let c=L(52,t,!0),l=L(26,t,!1),u=L(200,t,!0),d=1.4,f=r?45:50,p=[{type:`image`,id:`bg-image`,content:{src:i.src,alt:i.alt,fit:`cover`,credit:i.credit,license:i.license,...s?{treatment:s}:{}},position:{x:0,y:0,width:`100%`,height:`100%`},animation:Ui(a,15)},{type:`shape`,id:`overlay`,content:{shape:`rect`,fill:`rgba(0, 0, 0, 0.55)`},position:{x:0,y:0,width:`100%`,height:`100%`}},{type:`text`,id:`deco-quote`,content:{text:`“`,style:{fontSize:u,fontFamily:I(t,`title`),color:`rgba(255, 255, 255, 0.08)`,textAlign:`center`}},position:{x:`50%`,y:`20%`,anchor:`center`}},{type:`text`,id:`quote-text`,content:{text:n,style:{fontSize:c,fontFamily:I(t,`title`),color:`#ffffff`,textAlign:`center`,lineHeight:d,shadow:!0}},position:{x:`50%`,y:`${f}%`,anchor:`center`,width:`72%`},animation:R(t,`text`,{type:`fadeIn`,duration:2})}];if(r){let e=H(n,c,.72*o.width,d),i=Math.min(82,f+(e/2+c*1.7)/o.height*100);p.push({type:`text`,id:`attribution`,content:{text:`\u2014 ${r}`,style:{fontSize:l,fontFamily:I(t,`body`),color:`rgba(255, 255, 255, 0.85)`,textAlign:`center`,shadow:!0}},position:{x:`50%`,y:`${i}%`,anchor:`center`},animation:{type:`fadeIn`,duration:1,delay:1.5}})}return p}function Do(e,t){let{videoSrc:n,posterSrc:r,videoAlt:i,clipStart:a=0,clipEnd:o,sourceDuration:s,caption:c,captionPosition:l=`bottom`,videoCredit:u,videoLicense:d}=e,f=c&&Ri(c),{theme:p}=t,m=Math.max(a,o??a+Math.max(0,e.duration)),h=L(30,t,!1),g=L(16,t,!1),_=[{type:`video`,id:`bg-video`,content:{src:n,posterSrc:r,alt:i,fit:`cover`,clipStart:a,clipEnd:m,sourceDuration:s,credit:u,license:d},position:{x:0,y:0,width:`100%`,height:`100%`}}];if(f){let e=p.colors.background,n=l===`top`?`7%`:l===`center`?`42%`:`68%`,r=l===`top`?`13%`:l===`center`?`48%`:`74%`;_.push({type:`shape`,id:`caption-gradient`,content:{shape:`rect`,fill:`linear-gradient(90deg, ${C(e,0)}, ${C(e,.78)} 16%, ${C(e,.78)} 84%, ${C(e,0)})`},position:{x:0,y:n,width:`100%`,height:`16%`}}),_.push({type:`text`,id:`caption`,content:{text:f,style:{fontSize:h,fontFamily:I(t,`body`),color:p.colors.text,textAlign:`center`,shadow:z(t),lineHeight:1.18,maxLines:2}},position:{x:`50%`,y:r,anchor:`center`,width:`78%`},animation:{type:`fadeIn`,duration:1.5,delay:.5}})}return u&&_.push({type:`text`,id:`credit`,content:{text:u,style:{fontSize:g,fontFamily:I(t,`body`),color:C(p.colors.text,.65),textAlign:`right`}},position:{x:`96%`,y:`96%`,anchor:`bottom-right`}}),_}function Oo(e,t){let{text:n,attribution:r,backgroundVideo:i}=e,{viewport:a}=t;if(!i?.src)return[];let o=L(52,t,!0),s=L(26,t,!1),c=L(200,t,!0),l=1.4,u=r?45:50,d=[{type:`video`,id:`bg-video`,content:{src:i.src,posterSrc:i.posterSrc,alt:i.alt,fit:`cover`,clipStart:i.clipStart,clipEnd:i.clipEnd,credit:i.credit,license:i.license},position:{x:0,y:0,width:`100%`,height:`100%`}},{type:`shape`,id:`overlay`,content:{shape:`rect`,fill:`rgba(0, 0, 0, 0.55)`},position:{x:0,y:0,width:`100%`,height:`100%`}},{type:`text`,id:`deco-quote`,content:{text:`“`,style:{fontSize:c,fontFamily:I(t,`title`),color:`rgba(255, 255, 255, 0.08)`,textAlign:`center`}},position:{x:`50%`,y:`20%`,anchor:`center`}},{type:`text`,id:`quote-text`,content:{text:n,style:{fontSize:o,fontFamily:I(t,`title`),color:`#ffffff`,textAlign:`center`,lineHeight:l,shadow:!0}},position:{x:`50%`,y:`${u}%`,anchor:`center`,width:`72%`},animation:R(t,`text`,{type:`fadeIn`,duration:2})}];if(r){let e=H(n,o,.72*a.width,l),i=Math.min(82,u+(e/2+o*1.7)/a.height*100);d.push({type:`text`,id:`attribution`,content:{text:`\u2014 ${r}`,style:{fontSize:s,fontFamily:I(t,`body`),color:`rgba(255, 255, 255, 0.85)`,textAlign:`center`,shadow:!0}},position:{x:`50%`,y:`${i}%`,anchor:`center`},animation:{type:`fadeIn`,duration:1,delay:1.5}})}return d}function ko(e,t){let{title:n,headers:r,rows:i,align:a,colorScheme:o}=e,{theme:s,viewport:c}=t,l=F(t,o),u=L(48,t,!0),d=L(28,t,!1),f=[zi(`bg`,V(t,170))],p=(Array.isArray(i)?i.length:0)+1,m=Math.min(74,p*d*2.4/c.height*100),h=n?u*2.2*100/c.height:0,g=Math.max(8,(100-h-m)/2);return n&&f.push({type:`text`,id:`title`,content:{text:n,style:{fontSize:u,fontFamily:I(t,`title`),fontWeight:`bold`,color:s.colors.text,textAlign:`center`,shadow:z(t)}},position:{x:`50%`,y:`${g+h/2}%`,width:`80%`,anchor:`center`},animation:{type:`fadeIn`,duration:.8}}),f.push({type:`table`,id:`table`,content:{headers:r,rows:i,align:a,style:{headerBackground:l.accent,headerColor:S(l.accent),cellBackground:C(s.colors.text,.04),cellColor:s.colors.text,borderColor:C(s.colors.text,.15),fontSize:d,fontFamily:I(t,`body`),headerFontFamily:I(t,`title`),borderRadius:8}},position:{x:`10%`,y:`${g+h}%`,width:`80%`,height:`${m}%`},animation:{type:`fadeIn`,duration:1,delay:n?.4:0}}),f}var Ao=1.25;function jo(e,t,n,r){let i=Math.max(1,t-24),a=Math.max(1,n-16),o=Math.max(10,Math.floor(r)),s=Mo(e,o,i);for(;o>10&&s*o*1.25>a;)o--,s=Mo(e,o,i);return{fontSize:o,lineCount:s,firstLineOffset:s===1?0:-((s-1)*o*Ao)/2,textWidth:i}}function Mo(e,t,n){return e.split(`
|
|
22
22
|
`).reduce((e,r)=>e+No(r,t,n),0)}function No(e,t,n){if(!e.trim())return 1;let r=Math.floor(n/(t*.5));if(r<=0)return 1;let i=0,a=0;for(let t of e.split(/\s+/)){let e=a>0?a+1+t.length:t.length;if(e<=r){a=e;continue}a>0&&i++,t.length>r?(i+=Math.floor((t.length-1)/r),a=t.length%r||r):a=t.length}return a>0&&i++,Math.max(1,i)}var Po=180,Fo=64,Io=80;function Lo(e){let t=da(e.children??[]);return{nodes:t.nodes.map(e=>({id:e.id,label:e.label,x:e.x,y:e.y,w:Po,h:Fo,depth:0,isContainer:!1})),edges:t.edges.map(e=>({id:e.id,source:e.source,target:e.target,...e.type?{label:e.type}:{},directed:!0}))}}function Ro(e){let t=(Array.isArray(e.nodes)?e.nodes:[]).filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`&&e.id.length>0&&typeof e.label==`string`&&typeof e.x==`number`&&Number.isFinite(e.x)&&typeof e.y==`number`&&Number.isFinite(e.y)),n=new Set(t.map(e=>e.id)),r=new Set(t.map(e=>e.container).filter(e=>typeof e==`string`&&n.has(e))),i=e=>{let r=0,i=e,a=new Set;for(;i?.container&&n.has(i.container)&&!a.has(i.id);)a.add(i.id),r++,i=t.find(e=>e.id===i?.container);return r};return{nodes:t.map(e=>({id:e.id,label:e.label,x:e.x,y:e.y,w:typeof e.w==`number`&&Number.isFinite(e.w)&&e.w>0?e.w:Po,h:typeof e.h==`number`&&Number.isFinite(e.h)&&e.h>0?e.h:Fo,depth:i(e),isContainer:r.has(e.id)})),edges:(Array.isArray(e.edges)?e.edges:[]).filter(e=>typeof e==`object`&&!!e&&typeof e.source==`string`&&typeof e.target==`string`&&n.has(e.source)&&n.has(e.target)).map((e,t)=>({id:e.label?`${e.source}->${e.target}:${e.label}`:`${e.source}->${e.target}-${t}`,source:e.source,target:e.target,...e.label?{label:e.label}:{},directed:e.directed!==!1,...e.sourceAnchor?{sourceAnchor:e.sourceAnchor}:{},...e.targetAnchor?{targetAnchor:e.targetAnchor}:{},...e.routing?{routing:e.routing}:{}}))}}function zo(e,t){let{theme:n,viewport:r,children:i=[]}=t,a=e.colorScheme?F(t,e.colorScheme):void 0,o=i.length>0?Lo(t):e.nodes&&e.nodes.length>0?Ro(e):{nodes:[],edges:[]};if(o.nodes.length===0)return[{type:`text`,id:`diagram-empty`,content:{text:e.title??`Empty diagram`,style:{fontSize:L(36,t,!0),fontFamily:I(t,`title`),color:n.colors.textMuted,textAlign:`center`}},position:{x:`50%`,y:`50%`,anchor:`center`}}];let s=Math.min(...o.nodes.map(e=>e.x)),c=Math.max(...o.nodes.map(e=>e.x+e.w)),l=Math.min(...o.nodes.map(e=>e.y)),u=Math.max(...o.nodes.map(e=>e.y+e.h)),d=e.title?120:0,f=Math.max(1,r.width-Io*2),p=Math.max(1,r.height-Io*2-d),m=Math.max(1,c-s),h=Math.max(1,u-l),g=Math.min(f/m,p/h,1.8),_=Math.min(Math.max(g,1),1.5),v=Math.round(2*_),y=m*g,b=h*g,x=Math.max(Io/2,(r.height-d-b)/2),S=Io+(f-y)/2,C=x+d,w=e=>({x:S+(e.x-s)*g,y:C+(e.y-l)*g,w:e.w*g,h:e.h*g}),T=[];e.title&&T.push({type:`text`,id:`diagram-title`,content:{text:e.title,style:{fontSize:L(40,t,!0),fontFamily:I(t,`title`),fontWeight:`bold`,color:n.colors.text,textAlign:`center`}},position:{x:`50%`,y:x+d/2-16,anchor:`center`}});let E=o.nodes.filter(e=>e.isContainer).sort((e,t)=>e.depth-t.depth||e.y-t.y||e.x-t.x),D=o.nodes.filter(e=>!e.isContainer);for(let e of E){let t=w(e),r={type:`shape`,id:`node-card-${e.id}`,content:{shape:`rect`,fill:a?.bg??n.colors.backgroundLight,fillOpacity:.25,stroke:a?.text??n.colors.primary,strokeWidth:Math.max(1,v-1),borderRadius:10},position:{x:t.x,y:t.y,width:t.w,height:t.h}};T.push(r)}let O=new Map;for(let e of o.nodes){let t=w(e);O.set(e.id,{cx:t.x+t.w/2,cy:t.y+t.h/2,rx:t.w/2,ry:t.h/2})}let k=e.startStyle??`none`,A=e.endStyle??`arrow`,ee=Ve(e.lineStyle);for(let r of o.edges){let i=O.get(r.source),o=O.get(r.target);if(!i||!o)continue;let s=r.directed?A:`none`,c=Fe(i,o),l=r.sourceAnchor?Ne(i,r.sourceAnchor):c.start,u=r.targetAnchor?Ne(o,r.targetAnchor):c.end,d={type:`path`,id:`edge-${r.id}`,content:{d:Re(r.routing??e.edgeStyle??`curved`,l,u),stroke:a?.text??n.colors.primary,strokeWidth:v,fill:`none`,...ee?{dasharray:ee}:{},...k===`none`?{}:{startMarker:k},...s===`none`?{}:{endMarker:s}},position:{x:0,y:0,width:`100%`,height:`100%`}};if(T.push(d),r.label){let e=(i.cx+o.cx)/2,a=(i.cy+o.cy)/2,s=L(Math.round(18*_),t,!1),c={type:`text`,id:`edge-label-${r.id}`,content:{text:r.label,style:{fontSize:s,fontFamily:I(t,`body`),color:n.colors.textMuted,textAlign:`center`}},position:{x:e,y:a-s*.9,anchor:`center`}};T.push(c)}}for(let r of D){let i=w(r),o={type:`shape`,id:`node-card-${r.id}`,content:{shape:`rect`,fill:a?.bg??n.colors.backgroundLight,stroke:a?.text??n.colors.primary,strokeWidth:v,borderRadius:e.nodeShape===`pill`?i.h/2:10},position:{x:i.x,y:i.y,width:i.w,height:i.h}};T.push(o);let s=L(Math.round(22*_),t,!1),c=jo(r.label,i.w,i.h,s),l={type:`text`,id:`node-label-${r.id}`,content:{text:r.label,style:{fontSize:c.fontSize,fontFamily:I(t,`body`),fontWeight:`bold`,color:a?.text??n.colors.text,textAlign:`center`,lineHeight:Ao}},position:{x:i.x+i.w/2,y:i.y+i.h/2+c.firstLineOffset,anchor:`center`,width:c.textWidth}};T.push(l)}for(let e of E){let r=w(e),i=L(Math.round(20*_),t,!1),a={type:`text`,id:`node-label-${e.id}`,content:{text:e.label.split(`
|
|
23
23
|
`)[0]??``,style:{fontSize:i,fontFamily:I(t,`body`),fontWeight:`bold`,color:n.colors.textMuted,textAlign:`center`}},position:{x:r.x+r.w/2,y:r.y+i,anchor:`center`,width:r.w}};T.push(a)}return T}function Bo(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`object`||!n)continue;let e=n;if(typeof e.label!=`string`)continue;let r=Bo(e.children);t.push({id:typeof e.id==`string`&&e.id?e.id:Vo(e.label),label:e.label,children:r,...e.isDir===!0||r.length>0?{isDir:!0}:{},...typeof e.comment==`string`&&e.comment?{comment:e.comment}:{}})}return t}function Vo(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`node`}function Ho(e,t){let{theme:n,viewport:r}=t,i=F(t,e.colorScheme),a=Bo(e.items),o=L(48,t,!0),s=L(28,t,!1),c=[zi(`bg`,V(t,170))];if(a.length===0)return c.push({type:`text`,id:`tree-empty`,content:{text:e.title??`Empty tree`,style:{fontSize:o,fontFamily:I(t,`title`),color:n.colors.textMuted,textAlign:`center`}},position:{x:`50%`,y:`50%`,anchor:`center`}}),c;let l=e.title?o*2.2*100/r.height:0;return e.title&&c.push({type:`text`,id:`title`,content:{text:e.title,style:{fontSize:o,fontFamily:I(t,`title`),fontWeight:`bold`,color:n.colors.text,textAlign:`center`,shadow:z(t)}},position:{x:`50%`,y:`${8+l/2}%`,width:`80%`,anchor:`center`},animation:{type:`fadeIn`,duration:.8}}),c.push({type:`tree`,id:`tree`,content:{items:a,style:{rowColor:n.colors.text,dirColor:i.accent??n.colors.primary,connectorColor:C(n.colors.text,.25),iconColor:i.accent??n.colors.primary,commentColor:n.colors.textMuted,fontSize:s,fontFamily:I(t,`body`),monoFontFamily:I(t,`mono`),indentPx:Math.round(s*1.4)}},position:{x:`10%`,y:`${8+l}%`,width:`80%`,height:`${Math.max(60,90-l)}%`},animation:{type:`fadeIn`,duration:1,delay:e.title?.4:0}}),c}var Uo=e=>Math.max(0,Math.min(1,e)),Wo=(e,t,n)=>Math.max(t,Math.min(n,e));function Go(e){return e.replace(/[^a-zA-Z0-9_-]+/g,`-`).replace(/^-+|-+$/g,``)||`item`}function Ko(e){if(!Array.isArray(e))return[];let t=[];return e.forEach((e,n)=>{if(typeof e!=`object`||!e)return;let r=e,i=typeof r.id==`string`&&r.id.trim()?r.id.trim():`track-${n+1}`,a=[];Array.isArray(r.events)&&r.events.forEach((e,t)=>{if(typeof e!=`object`||!e)return;let n=e;if(typeof n.label!=`string`)return;let r=typeof n.position==`number`?n.position:Number(n.position);if(!Number.isFinite(r))return;let o=typeof n.id==`string`&&n.id.trim()?n.id.trim():`${i}-event-${t+1}`,s=n.side===`above`||n.side===`below`?n.side:void 0,c=n.descriptionSide===`above`||n.descriptionSide===`below`?n.descriptionSide:void 0,l=n.marker===`filled`||n.marker===`hollow`||n.marker===`diamond`?n.marker:void 0;a.push({id:o,label:n.label,position:Uo(r),...typeof n.description==`string`&&n.description.trim()?{description:n.description.trim()}:{},...s?{side:s}:{},...c?{descriptionSide:c}:{},...n.callout===!1?{callout:!1}:{},...l?{marker:l}:{}})}),t.push({id:i,...typeof r.label==`string`&&r.label.trim()?{label:r.label.trim()}:{},...typeof r.endLabel==`string`&&r.endLabel.trim()?{endLabel:r.endLabel.trim()}:{},events:a})}),t}function qo(e,t){if(!Array.isArray(e))return[];let n=[];for(let r of e){if(typeof r!=`object`||!r)continue;let e=r;typeof e.source!=`string`||typeof e.target!=`string`||!t.has(e.source)||!t.has(e.target)||e.source===e.target||n.push({source:e.source,target:e.target,...typeof e.label==`string`&&e.label.trim()?{label:e.label.trim()}:{}})}return n}function Jo(e,t,n,r,i,a){return{type:`path`,id:e,content:{d:`M ${t} ${n-r} L ${t+r} ${n} L ${t} ${n+r} L ${t-r} ${n} Z`,fill:i,stroke:i,strokeWidth:2},position:{x:t-r,y:n-r,width:r*2,height:r*2},animation:{type:`zoomIn`,duration:.35,delay:a}}}function Yo(e,t,n){if(Math.abs(e.y-t.y)<1){let r=(e.event.side??(e.eventIndex%2==0?`above`:`below`))===`above`?1:-1,i=e.y+r*n;return`M ${e.x} ${e.y} C ${e.x} ${i}, ${t.x} ${i}, ${t.x} ${t.y}`}let r=(e.y+t.y)/2;return`M ${e.x} ${e.y} C ${e.x} ${r}, ${t.x} ${r}, ${t.x} ${t.y}`}function Xo(e,t){let{theme:n,viewport:r}=t,i=F(t,e.colorScheme),a=Ko(e.tracks),o=[zi(`bg`,V(t,165))],s=L(44,t,!0),c=L(22,t,!1),l=L(24,t,!1),u=L(17,t,!1);if(e.title&&o.push({type:`text`,id:`timeline-title`,content:{text:e.title,style:{fontSize:s,fontFamily:I(t,`title`),fontWeight:`bold`,color:n.colors.text,textAlign:`center`,shadow:z(t)}},position:{x:`50%`,y:Math.max(50,s*1.2),width:`82%`,anchor:`center`},animation:{type:`fadeIn`,duration:.7}}),a.length===0)return o.push({type:`text`,id:`timeline-empty`,content:{text:e.title?`No timeline events`:`Empty timeline`,style:{fontSize:L(36,t,!0),fontFamily:I(t,`title`),color:n.colors.textMuted,textAlign:`center`}},position:{x:`50%`,y:`50%`,width:`80%`,anchor:`center`}}),o;let d=a.some(e=>!!e.label),f=Math.max(48,r.width*.065),p=d?Math.min(280,r.width*.18):0,m=f+p,h=r.width-f,g=Math.max(1,h-m),_=e.title?Math.max(s*2.2,r.height*.2):r.height*.09,v=r.height*.91,y=Math.max(1,v-_)/a.length,b=Math.max(6,Math.min(11,Math.min(r.width,r.height)/105)),x=C(i.text??n.colors.primary,.72),S=i.accent??n.colors.primary,w=C(S,.78),T=C(n.colors.text,.48),E=Math.max(1,...a.map(e=>e.events.filter(e=>e.callout!==!1).length)),D=Math.max(Math.min(150,r.width*.2),Math.min(330,g/Math.min(E,4)*.86)),O=Math.min(r.width,r.height)/1080,k=Math.min(l,24*O),A=Math.min(u,17*O),ee=a.map(e=>{let t=e.events.map(e=>Uo(e.position)).sort((e,t)=>e-t),n=1/0;for(let e=1;e<t.length;e++)n=Math.min(n,(t[e]-t[e-1])*g);return Number.isFinite(n)?Math.min(b,Math.max(3,n*.32)):b}),te=[],ne=new Map;a.forEach((e,r)=>{let i=_+y*(r+.5),a=.12+r*.12,s=Go(e.id),l={type:`path`,id:`timeline-track-${s}-${r}`,content:{d:`M ${m} ${i} L ${h} ${i}`,stroke:x,strokeWidth:Math.max(2,b*.32),fill:`none`,endMarker:`arrow`},position:{x:m,y:i-b,width:g,height:b*2},animation:{type:`fadeIn`,duration:.65,delay:a}};if(o.push(l),e.label){let l={type:`text`,id:`timeline-track-label-${s}-${r}`,content:{text:e.label,style:{fontSize:c,fontFamily:I(t,`body`),fontWeight:`bold`,color:n.colors.textMuted,textAlign:`right`}},position:{x:f+p/2-16,y:i,width:Math.max(1,p-32),anchor:`center`},animation:{type:`fadeIn`,duration:.5,delay:a}};o.push(l)}e.endLabel&&o.push({type:`text`,id:`timeline-track-end-label-${s}-${r}`,content:{text:e.endLabel,style:{fontSize:A,fontFamily:I(t,`body`),color:n.colors.textMuted,textAlign:`left`,maxLines:2}},position:{x:h+b*1.6,y:i-A*.7,width:Math.max(48,f-b*2),anchor:`top-left`},animation:{type:`fadeIn`,duration:.5,delay:a}}),e.events.forEach((e,t)=>{let n={event:e,trackIndex:r,eventIndex:t,x:m+g*Uo(e.position),y:i};te.push(n),ne.has(e.id)||ne.set(e.id,n)})}),qo(e.links,new Set(ne.keys())).forEach((e,i)=>{let a=ne.get(e.source),s=ne.get(e.target);if(!a||!s)return;let c=Math.min(90,Math.max(42,y*.28));if(o.push({type:`path`,id:`timeline-link-${Go(e.source)}-${Go(e.target)}-${i}`,content:{d:Yo(a,s,c),stroke:w,strokeWidth:Math.max(2,b*.26),fill:`none`,endMarker:`arrow`},position:{x:0,y:0,width:`100%`,height:`100%`},animation:{type:`fadeIn`,duration:.6,delay:.45+i*.08}}),e.label){let l=a.trackIndex===s.trackIndex,u=Math.min(320,Math.max(150,e.label.length*A*.55+24)),d=Math.min(A*1.25*2+8,H(e.label,A,u,1.25)+8),f=(a.x+s.x)/2,p=(a.event.side??(a.eventIndex%2==0?`above`:`below`))===`above`?1:-1,m=l?a.y+p*(c+A*.6):(a.y+s.y)/2;if(!l){let e=s.x-a.x,t=s.y-a.y,n=Math.max(1,Math.hypot(e,t)),i=u*.56,o=f+-t/n*i,c=m+e/n*i,l=o>=u/2+8&&o<=r.width-u/2-8&&c>=A*1.5&&c<=r.height-12?1:-1;f+=l*(-t/n)*i,m+=e/n*l*i}f=Wo(f,u/2+8,r.width-u/2-8),m=Wo(m,A*1.5,r.height-12),o.push({type:`text`,id:`timeline-link-label-${i}`,content:{text:e.label,style:{fontSize:A,fontFamily:I(t,`body`),color:n.colors.textMuted,textAlign:`center`,background:n.colors.background,backgroundOpacity:.88,padding:4,maxLines:2,verticalAlign:`middle`}},position:{x:f,y:m,width:u,height:d,anchor:`center`},animation:{type:`fadeIn`,duration:.5,delay:.55+i*.08}})}});let re=Math.min(78,Math.max(34,y*.2));for(let e of te){let{event:i,trackIndex:a,eventIndex:s,x:c,y:l}=e,u=i.side??(s%2==0?`above`:`below`),d=u===`above`?-1:1,f=l+d*re,p=.28+a*.12+s*.07,m=`${Go(i.id)}-${a}-${s}`,h=ee[a]??b,g=Wo(c,D/2+8,r.width-D/2-8),_=(e,t,n)=>{o.push({type:`path`,id:e,content:{d:`M ${c} ${l} L ${g} ${t}`,stroke:T,strokeWidth:Math.max(1,b*.18),fill:`none`},position:{x:Math.min(c,g),y:Math.min(l,t),width:Math.max(2,Math.abs(g-c)),height:Math.max(2,Math.abs(t-l))},animation:{type:`fadeIn`,duration:.4,delay:n}})};if(i.callout!==!1){_(`timeline-stem-${m}`,f,p);let e=i.descriptionSide??u;if(i.description&&e!==u){let t=e===`above`?-1:1;_(`timeline-description-stem-${m}`,l+t*re,p+.03)}}let v=i.marker??`filled`;if(v===`diamond`)o.push(Jo(`timeline-marker-${m}`,c,l,h,S,p));else{let e={type:`shape`,id:`timeline-marker-${m}`,content:{shape:`circle`,fill:v===`hollow`?n.colors.background:S,stroke:S,strokeWidth:Math.max(1.5,h*.28)},position:{x:c-h,y:l-h,width:h*2,height:h*2},animation:{type:`zoomIn`,duration:.35,delay:p}};o.push(e)}if(i.callout!==!1){let e=1.2,a=Math.min(H(i.label,k,D,e),k*e*2),s=Math.max(1,Math.round(a/(k*e))),c=Wo(d>0?f+k*.9:f-(s-1)*k*e-k*.9,k,r.height-(s-1)*k*e-12);if(o.push({type:`text`,id:`timeline-event-label-${m}`,content:{text:i.label,style:{fontSize:k,fontFamily:I(t,`body`),fontWeight:`bold`,color:n.colors.text,textAlign:`center`,lineHeight:e,shadow:z(t),maxLines:2}},position:{x:g,y:c,width:D,anchor:`center`},animation:{type:`fadeIn`,duration:.5,delay:p+.08}}),i.description){let a=i.descriptionSide??u,d=a===`above`?-1:1,f=1.25,h=t.orientation===`portrait`?6:4,_=Math.min(H(i.description,A,D,f),A*f*h),v=Math.max(1,Math.round(_/(A*f))),y=l+d*re,b;b=a===u?d>0?c+s*k*e+A*.45:c-v*A*f-A*.45:d>0?y+A*.9:y-(v-1)*A*f-A*.9,b=Wo(b,A,r.height-(v-1)*A*f-12),o.push({type:`text`,id:`timeline-event-description-${m}`,content:{text:i.description,style:{fontSize:A,fontFamily:I(t,`body`),color:n.colors.textMuted,textAlign:`center`,lineHeight:f,maxLines:h}},position:{x:g,y:b,width:D,anchor:`center`},animation:{type:`fadeIn`,duration:.5,delay:p+.14}})}}}return o}var Zo=`rectangle.rect.square.circle.ellipse.oval.line.arrow.path.text.triangle.right-triangle.diamond.rhombus.pentagon.hexagon.octagon.star.star4.star6.parallelogram.trapezoid.plus.cross.chevron.arrow-right.arrow-left.arrow-up.arrow-down.double-arrow.callout.speech.cylinder.cloud.heart.lightning.bolt`.split(`.`),Qo={rectangle:`rect`,rect:`rect`,square:`rect`,circle:`circle`,ellipse:`circle`,oval:`circle`,line:`line`,arrow:`arrow`,path:`path`,text:`text`,label:`text`,triangle:`triangle`,"right-triangle":`right-triangle`,righttriangle:`right-triangle`,diamond:`diamond`,rhombus:`diamond`,pentagon:`pentagon`,hexagon:`hexagon`,octagon:`octagon`,star:`star`,star5:`star`,star4:`star4`,star6:`star6`,parallelogram:`parallelogram`,trapezoid:`trapezoid`,plus:`plus`,cross:`plus`,chevron:`chevron`,"arrow-right":`arrow-right`,arrowright:`arrow-right`,rightarrow:`arrow-right`,"arrow-left":`arrow-left`,arrowleft:`arrow-left`,leftarrow:`arrow-left`,"arrow-up":`arrow-up`,arrowup:`arrow-up`,uparrow:`arrow-up`,"arrow-down":`arrow-down`,arrowdown:`arrow-down`,downarrow:`arrow-down`,"double-arrow":`double-arrow`,doublearrow:`double-arrow`,callout:`callout`,speech:`callout`,bubble:`callout`,cylinder:`cylinder`,can:`cylinder`,cloud:`cloud`,heart:`heart`,lightning:`lightning`,bolt:`lightning`};function $o(e){return e?Qo[e.toLowerCase()]??null:null}function es(e){return $o(e)!=null}var ts={gapX:180,gapY:140,gridPad:80,gridOriginX:80,gridOriginY:80},ns={rect:{w:160,h:90},circle:{w:120,h:120},line:{w:160,h:0},arrow:{w:160,h:0},path:{w:160,h:120},text:{w:200,h:48}},rs={w:120,h:120};function is(e){return ns[e]??rs}function as(e,t={}){let n={...ts,...t},r=[],i=[],a=[],o=[];for(let t of e){let e=$o(t.template),n=t.templateOverrides??{},s=t.title??``,c=ms(t);if(!e){r.push(`Child "${t.id}" is not a shape (annotation "${t.template??`—`}") and was skipped`);continue}let l=K(n,`from`),u=K(n,`to`);if((e===`line`||e===`arrow`)&&(l||u)){o.push({id:t.id,kind:e,from:l??``,to:u??``,...s?{label:s}:{},...ps(n,e),source:t.id});continue}for(let e of t.connectsTo??[])o.push({id:`${t.id}->${e.target}${e.type?`:${e.type}`:``}`,kind:`arrow`,from:t.id,to:e.target,...e.type?{label:e.type}:{},...ps(n,`arrow`),source:t.id});let d=is(e),f=os(n,`x`)??(typeof t.x==`number`?t.x:void 0),p=os(n,`y`)??(typeof t.y==`number`?t.y:void 0),m={id:t.id,kind:e,x:f??0,y:p??0,width:os(n,`width`)??os(n,`w`)??d.w,height:os(n,`height`)??os(n,`h`)??d.h,pinned:f!=null&&p!=null,label:s,...c?{sublabel:c}:{},...cs(n)};if(e===`path`){let e=K(n,`d`);e&&(m.d=e)}e===`text`&&(m.text=K(n,`text`)??s??c??``),os(n,`borderRadius`)!=null&&(m.borderRadius=os(n,`borderRadius`)),i.push({shape:m,hasX:f!=null,hasY:p!=null}),(f==null||p==null)&&a.push(i.length-1)}if(a.length>0){let e=Math.max(1,Math.ceil(Math.sqrt(a.length))),t=Math.max(...a.map(e=>i[e].shape.width)),r=Math.max(...a.map(e=>i[e].shape.height)),o=Math.max(n.gapX,t+60),s=Math.max(n.gapY,r+50),c=n.gridOriginX,l=n.gridOriginY,u=i.filter(e=>e.shape.pinned);u.length>0&&(c=Math.min(...u.map(e=>e.shape.x)),l=Math.max(...u.map(e=>e.shape.y+e.shape.height))+n.gridPad),a.forEach((t,n)=>{let r=n%e,a=Math.floor(n/e);i[t].shape.x=c+r*o,i[t].shape.y=l+a*s})}let s=i.map(e=>e.shape),c=new Set(s.map(e=>e.id)),l=[],u=new Set;for(let e of o){if(!c.has(e.from)||!c.has(e.to)){let t=c.has(e.from)?e.to:e.from;r.push(`Connector "${e.source}" dropped: ${t?`no shape with id "${t}"`:`missing from/to`}`);continue}let t=`${e.kind}:${e.from}->${e.to}:${e.label??``}`;if(u.has(t))continue;u.add(t);let{source:n,...i}=e;l.push(i)}return{shapes:s,connectors:l,warnings:r}}function K(e,t){let n=e[t];if(n==null)return;let r=n.replace(/,\s*$/,``).trim();return r.length>0?r:void 0}function os(e,t){let n=K(e,t);if(n==null)return;let r=Number(n);return Number.isFinite(r)?r:void 0}function ss(e){let t={},n=K(e,`stroke`),r=os(e,`strokeWidth`),i=K(e,`dasharray`);return n&&(t.stroke=n),r!=null&&(t.strokeWidth=r),i&&(t.dasharray=i),t}function cs(e){let t=K(e,`fill`);return{...ss(e),...t?{fill:t}:{}}}var ls={none:`none`,arrow:`arrow`,triangle:`arrow`,filled:`arrow`,open:`open`,v:`open`,diamond:`diamond`,circle:`circle`,dot:`circle`,square:`square`,box:`square`},us={straight:`straight`,direct:`straight`,orthogonal:`orthogonal`,elbow:`orthogonal`,step:`orthogonal`,curved:`curved`,curve:`curved`,bezier:`curved`};function ds(e){return e?ls[e.toLowerCase()]:void 0}function fs(e){return e?us[e.toLowerCase()]:void 0}function ps(e,t){let n=ss(e),r=n.dasharray??Ve(K(e,`lineStyle`));return{...n,...r?{dasharray:r}:{},startMarker:ds(K(e,`startStyle`))??`none`,endMarker:ds(K(e,`endStyle`))??(t===`arrow`?`arrow`:`none`),routing:fs(K(e,`routing`))??`straight`}}function ms(e){return!e.contents||e.contents.length===0?``:e.contents.map(e=>o(e)).join(` `).trim()}var hs=80;function gs(e,t){let{theme:n,viewport:r,children:i=[]}=t,a=F(t,e.colorScheme),o=e.stroke??a.text??n.colors.text,s=e.fill??`none`,c=as(i);if(c.shapes.length===0&&c.connectors.length===0)return[bs(e,t)];let l=Math.min(...c.shapes.map(e=>e.x)),u=Math.max(...c.shapes.map(e=>e.x+e.width)),d=Math.min(...c.shapes.map(e=>e.y)),f=Math.max(...c.shapes.map(e=>e.y+e.height)),p=e.title?120:0,m=Math.max(1,r.width-hs*2),h=Math.max(1,r.height-hs*2-p),g=Math.max(1,u-l),_=Math.max(1,f-d),v=Math.min(m/g,h/_,1.8),y=g*v,b=_*v,x=Math.max(hs/2,(r.height-p-b)/2),S=hs+(m-y)/2,C=x+p,w=e=>S+(e-l)*v,T=e=>C+(e-d)*v,E=Math.min(Math.max(v,1),1.5),D=[];e.title&&D.push({type:`text`,id:`drawing-title`,content:{text:e.title,style:{fontSize:L(40,t,!0),fontFamily:I(t,`title`),fontWeight:`bold`,color:n.colors.text,textAlign:`center`}},position:{x:`50%`,y:x+p/2-16,anchor:`center`}});let O=new Map;for(let e of c.shapes){let t=w(e.x),n=T(e.y),r=e.width*v,i=e.height*v;O.set(e.id,{cx:t+r/2,cy:n+i/2,rx:Math.max(1,r/2),ry:Math.max(1,i/2)})}for(let e of c.connectors){let n=O.get(e.from),r=O.get(e.to);if(!n||!r)continue;let{start:i,end:a}=Fe(n,r),s={type:`path`,id:`connector-${e.id}`,content:{d:Re(e.routing,i,a),stroke:e.stroke??o,strokeWidth:e.strokeWidth??Math.round(2*E),fill:`none`,...e.dasharray?{dasharray:e.dasharray}:{},...e.startMarker===`none`?{}:{startMarker:e.startMarker},...e.endMarker===`none`?{}:{endMarker:e.endMarker}},position:{x:0,y:0,width:`100%`,height:`100%`}};D.push(s),e.label&&D.push(ys(e,n,r,t,E))}for(let e of c.shapes){let n=w(e.x),r=T(e.y),i=e.width*v,a=e.height*v;D.push(..._s(e,n,r,i,a,t,o,s,E))}return D}function _s(e,t,n,r,i,a,o,s,c){let l=[],u=e.stroke??o,d=e.fill??s;if(e.kind===`text`)return l.push(vs(`shape-${e.id}`,e.text??e.label??``,t+r/2,n+i/2,r,a,e.stroke??a.theme.colors.text,!0,c)),l;if(e.kind===`rect`||e.kind===`circle`){let a={type:`shape`,id:`shape-${e.id}`,content:{shape:e.kind,fill:d,stroke:u,strokeWidth:e.strokeWidth??Math.round(2*c),...e.kind===`rect`&&e.borderRadius!=null?{borderRadius:e.borderRadius}:{}},position:{x:t,y:n,width:r,height:i}};l.push(a)}else{let a=`M ${xs(t)} ${xs(n)} L ${xs(t+r)} ${xs(n+i)}`,o=a,s=`none`,f=`none`;e.kind===`path`?(o=e.d??a,s=d):e.kind===`arrow`?f=`arrow`:e.kind!==`line`&&(o=De(e.kind,t,n,r,i)??a,s=d);let p={type:`path`,id:`shape-${e.id}`,content:{d:o,stroke:u,strokeWidth:e.strokeWidth??Math.round(2*c),fill:s,...e.dasharray?{dasharray:e.dasharray}:{},...f===`none`?{}:{endMarker:f}},position:{x:0,y:0,width:`100%`,height:`100%`}};l.push(p)}return e.label&&l.push(vs(`shape-label-${e.id}`,e.label,t+r/2,n+i/2,r,a,e.stroke??a.theme.colors.text,!0,c)),e.sublabel&&l.push(vs(`shape-sublabel-${e.id}`,e.sublabel,t+r/2,n+i+14*c,r,a,a.theme.colors.textMuted,!1,c)),l}function vs(e,t,n,r,i,a,o,s,c){return{type:`text`,id:e,content:{text:t,style:{fontSize:L(Math.round((s?22:18)*c),a,!1),fontFamily:I(a,`body`),...s?{fontWeight:`bold`}:{},color:o,textAlign:`center`}},position:{x:n,y:r,anchor:`center`,width:i}}}function ys(e,t,n,r,i){let a=L(Math.round(18*i),r,!1);return{type:`text`,id:`connector-label-${e.id}`,content:{text:e.label??``,style:{fontSize:a,fontFamily:I(r,`body`),color:r.theme.colors.textMuted,textAlign:`center`}},position:{x:(t.cx+n.cx)/2,y:(t.cy+n.cy)/2-a*.9,anchor:`center`}}}function bs(e,t){return{type:`text`,id:`drawing-empty`,content:{text:e.title??`Empty drawing`,style:{fontSize:L(36,t,!0),fontFamily:I(t,`title`),color:t.theme.colors.textMuted,textAlign:`center`}},position:{x:`50%`,y:`50%`,anchor:`center`}}}function xs(e){return Math.round(e*100)/100}var Ss=`#1e293b`,Cs={w:300,h:80},ws={w:160,h:90},Ts={w:320,h:240};function Es(e,t,n={}){let r=n.ink??Ss,i=[],a=[];for(let t of e){let e=t.templateOverrides??{},n=(t.template??``).toLowerCase(),o=J(e,`x`)??0,s=J(e,`y`)??0;if(n===`image`||n===`img`){let n=q(e,`src`);if(!n){a.push(`Layout image "${t.id}" has no src= and was skipped`);continue}let r={id:t.id,type:`image`,position:{x:o,y:s,width:J(e,`width`)??Ts.w,height:J(e,`height`)??Ts.h},content:{src:n,alt:q(e,`alt`)??``,...q(e,`fit`)?{fit:q(e,`fit`)}:{}}};i.push(r);continue}let c=$o(t.template);if(!c){a.push(`Layout child "${t.id}" is not a layer (annotation "${t.template??`—`}") and was skipped`);continue}if(c===`text`){let n=Os(t)||t.title||``,a={id:t.id,type:`text`,position:{x:o,y:s,width:J(e,`width`)??Cs.w,height:J(e,`height`)??Cs.h},content:{text:n,style:Ds(e,r)}};i.push(a);continue}let l=J(e,`width`)??J(e,`w`)??ws.w,u=J(e,`height`)??J(e,`h`)??ws.h;if(c===`rect`||c===`circle`){let n={id:t.id,type:`shape`,position:{x:o,y:s,width:l,height:u},content:{shape:c,...q(e,`fill`)?{fill:q(e,`fill`)}:{},...q(e,`stroke`)?{stroke:q(e,`stroke`)}:{},...J(e,`strokeWidth`)==null?{}:{strokeWidth:J(e,`strokeWidth`)},...q(e,`borderStyle`)?{borderStyle:q(e,`borderStyle`)}:{},...c===`rect`&&J(e,`borderRadius`)!=null?{borderRadius:J(e,`borderRadius`)}:{}}};i.push(n);continue}let d=`M ${ks(o)} ${ks(s)} L ${ks(o+l)} ${ks(s+u)}`,f=d,p=`none`,m=`none`;c===`path`?(f=q(e,`d`)??d,p=q(e,`fill`)??`none`):c===`arrow`?m=`arrow`:c!==`line`&&(f=De(c,o,s,l,u)??d,p=q(e,`fill`)??`none`);let h={id:t.id,type:`path`,position:{x:0,y:0,width:`100%`,height:`100%`},content:{d:f,stroke:q(e,`stroke`)??r,strokeWidth:J(e,`strokeWidth`)??2,fill:p,...q(e,`dasharray`)?{dasharray:q(e,`dasharray`)}:{},...m===`none`?{}:{endMarker:m}}};i.push(h)}return{layers:i,warnings:a}}function Ds(e,t){let n={fontSize:J(e,`fontSize`)??32,color:q(e,`color`)??t},r=q(e,`fontFamily`);r&&(n.fontFamily=r);let i=q(e,`fontWeight`);(i===`bold`||i===`normal`)&&(n.fontWeight=i);let a=q(e,`fontStyle`);(a===`italic`||a===`normal`)&&(n.fontStyle=a);let o=q(e,`align`);(o===`left`||o===`center`||o===`right`)&&(n.textAlign=o);let s=q(e,`valign`);(s===`top`||s===`middle`||s===`bottom`)&&(n.verticalAlign=s);let c=J(e,`lineHeight`);c!=null&&(n.lineHeight=c);let l=J(e,`padding`);l!=null&&(n.padding=l);let u=q(e,`background`);return u&&(n.background=u),n}function q(e,t){let n=e[t];if(n==null)return;let r=n.replace(/,\s*$/,``).trim();return r.length>0?r:void 0}function J(e,t){let n=q(e,t);if(n==null)return;let r=Number(n);return Number.isFinite(r)?r:void 0}function Os(e){return!e.contents||e.contents.length===0?``:e.contents.map(e=>o(e)).join(`
|
|
24
|
-
`).trim()}function ks(e){return Math.round(e*100)/100}function As(e,t){let{theme:n,viewport:r,children:i=[]}=t,{layers:a}=Es(i,r,{ink:n.colors.text});return a.length>0?a:[js(e,t)]}function js(e,t){return{type:`text`,id:`layout-empty`,content:{text:e.title??`Empty layout`,style:{fontSize:m(36,t,!0),fontFamily:I(t,`title`),color:t.theme.colors.textMuted,textAlign:`center`}},position:{x:`50%`,y:`50%`,anchor:`center`}}}var Ms=/\{(\w+)(?::([^}|]+))?(?:\|([^}]*))?\}/g,Ns=/\{\{([^{}]*)\}\}/g,Ps=` ESC_OPEN `,Fs=` ESC_CLOSE `;function Is(e){if(!e.contents)return[];let t=[],n=e=>{if(e.type===`image`){let n=e;t.push({url:n.url??``,alt:n.alt??``})}};for(let t of e.contents)i(t,e=>{n(e)});return t}function Ls(e){if(!e.contents)return[];let t=[];for(let n of e.contents)i(n,e=>{if(e.type===`listItem`){let n=o(e).replace(/\s+/g,` `).trim();return n&&t.push(n),!0}});return t}function Rs(e){return e.contents?e.contents.map(e=>o(e).trim()).filter(e=>e.length>0).join(` `):``}function zs(e){return!e.children||e.children.length===0?``:e.children.map(e=>e.title?.trim()).filter(e=>!!e).join(`, `)}function Bs(e){return e.replace(Ns,(e,t)=>Ps+t+Fs)}function Vs(e){return e.replace(new RegExp(Ps,`g`),`{`).replace(new RegExp(Fs,`g`),`}`)}function Hs(e,t){return Vs(Bs(e).replace(Ms,(e,n,r,i)=>{let a=t(n,r);return a==null?e:a===``&&i!==void 0?i:a}))}function Us(e,t,n,r,i){switch(e){case`title`:return n.title??``;case`content`:return Rs(n);case`children`:return zs(n);case`attr`:{if(!t)return``;let e=n.templateOverrides?.[t]??n.templateData?.[t]??n.metadata?.[t];return e==null?``:String(e)}case`image`:{let e=t?parseInt(t,10):0;return!Number.isFinite(e)||e<0||e>=r.length?``:r[e].alt}case`item`:return i?t?t===`src`?i.src??``:t===`label`?i.label??``:``:i.text:null;case`index`:return i?String(i.index):null;default:return null}}function Ws(e,t,n,r){return Hs(e,(e,i)=>Us(e,i,t,n,r))}function Gs(e,t,n,r){if(!e.includes(`{`))return e;let i=!1,a=Bs(e).replace(Ms,(e,a,o,s)=>{if(a===`image`){let e=o?parseInt(o,10):0;return Number.isFinite(e)&&e>=0&&e<n.length?n[e].url:s===void 0?(i=!0,``):s}let c=Us(a,o,t,n,r);return c==null?e:c===``&&s!==void 0?s:c});return i?null:Vs(a)}function Ks(e){if(typeof e==`number`)return e;if(typeof e==`string`){let t=e.match(/-?\d*\.?\d+/);if(t)return parseFloat(t[0])}return 0}function qs(e,t){if(e==null)return t;if(typeof e==`number`)return e+t;let n=e.match(/^(\s*)(-?\d*\.?\d+)(.*)$/);if(n){let e=parseFloat(n[2])+t;return`${n[1]}${e}${n[3]}`}return e}function Js(e,t,n){switch(e){case`images`:return n.map((e,t)=>({text:e.alt,src:e.url,label:e.alt,index:t+1}));case`children`:return(t.children??[]).map((e,t)=>({text:e.title??``,label:e.title??``,index:t+1}));case`listItems`:return Ls(t).map((e,t)=>({text:e,label:e,index:t+1}));default:return[]}}function Ys(e,t,n){let r=e.repeat;if(!r){let r=Zs(e,t,n,void 0);return r?[r]:[]}let i=Js(r.source,t,n),a=r.direction??`column`,o=r.gap??24,s=r.max!=null&&r.max>=0?Math.min(r.max,i.length):i.length,c=[],l=0;for(let r=0;r<s;r++){let s={...e.position};a===`row`?s.x=qs(s.x,l):s.y=qs(s.y,l);let u={...e,position:s,id:`${e.id}-${r}`};delete u.repeat;let d=Zs(u,t,n,i[r]);d&&c.push(d);let f=a===`row`?e.position.width:e.position.height;l+=Ks(f)+o}return c}function Xs(e,t){let n=Is(t),r=[];for(let i of e)if(i.repeat)r.push(...Ys(i,t,n));else{let e=Zs(i,t,n,void 0);e&&r.push(e)}return r}function Zs(e,t,n,r){switch(e.type){case`text`:return{...e,content:{...e.content,text:Ws(e.content.text,t,n,r)}};case`image`:{let i=Gs(e.content.src,t,n,r);if(i==null)return null;let a={...e,content:{...e.content,src:i}};return e.content.alt&&e.content.alt.includes(`{`)&&(a.content.alt=Ws(e.content.alt,t,n,r)),a}default:return e}}function Qs(e){return(t,n)=>{let r=n.block??t;return r?Xs(e.layers,r):e.layers.slice()}}var $s=.6;function ec(e){if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;let n=!1,r=/^\((.*)\)$/.exec(t);if(r&&(n=!0,t=r[1].trim()),t=t.replace(/^([+-]?)\s*[$€£¥]\s*/,`$1`),t=t.replace(/%$/,``).trim(),t=t.replace(/,/g,``),/^[+-]?\d{1,3}(?: \d{3})+(?:\.\d+)?$/.test(t)&&(t=t.replace(/ /g,``)),!/^[+-]?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?$/i.test(t))return null;let i=Number(t);return Number.isFinite(i)?n?-i:i:null}function tc(e,t){let n=0,r=0;for(let i of e){let e=(i[t]??``).trim();e&&(n+=1,ec(e)!==null&&(r+=1))}return r>0&&r/Math.max(1,n)>=$s}function nc(e,t){let n=String(e).trim();if(!n)return null;let r=n.toLowerCase(),i=t.findIndex(e=>e.trim().toLowerCase()===r);if(i>=0)return i;if(/^\d+$/.test(n)){let e=Number(n);if(e<t.length)return e}return null}function rc(e,t={}){let n=Array.isArray(e.headers)?e.headers:[],r=Array.isArray(e.rows)?e.rows:[];if(n.length===0||r.length===0)return null;let i=[],a=0;if(t.labelColumn!==void 0&&String(t.labelColumn).trim()!==``){let e=nc(String(t.labelColumn),n);e===null?i.push(`labelColumn "${t.labelColumn}" matches no column; using the first column`):a=e}let o=[],s=(t.valueColumns??[]).map(e=>String(e)).filter(e=>e.trim()!==``);if(s.length>0)for(let e of s){let t=nc(e,n);t===null?i.push(`valueColumns entry "${e}" matches no column; skipped`):o.includes(t)||o.push(t)}else o=n.map((e,t)=>t).filter(e=>e!==a&&tc(r,e));return o.length===0?null:{labels:r.map(e=>(e[a]??``).trim()),labelHeader:n[a]??``,labelNumbers:r.map(e=>ec(e[a]??``)),series:o.map(e=>({name:(n[e]??`Column ${e+1}`).trim()||`Column ${e+1}`,values:r.map(t=>ec(t[e]??``))})),warnings:i}}function ic(e,t){let n=Math.floor(Math.log10(e)),r=e/10**n,i;return i=t?r<1.5?1:r<3?2:r<7?5:10:r<=1?1:r<=2?2:r<=5?5:10,i*10**n}function ac(e,t,n=5){let r=Number.isFinite(e)?e:0,i=Number.isFinite(t)?t:0;if(r>i&&([r,i]=[i,r]),r===i){let t=r===0?1:ic(Math.abs(r),!0);r-=t,i+=t,e>=0&&r<0&&(r=0)}let a=Math.max(2,n),o=ic(ic(i-r,!1)/(a-1),!0),s=Math.floor(r/o)*o,c=Math.ceil(i/o)*o,l=[];for(let e=s;e<=c+o*1e-6;e+=o)l.push(Math.abs(e)<o*1e-6?0:Number(e.toPrecision(12)));return{ticks:l,niceMin:s,niceMax:c,step:o}}function oc(e,t){if(!Number.isFinite(e))return`—`;let n=e<0?`-`:``,r=Math.abs(e),i;return i=r>=1e6?`${n}${sc((r/1e6).toFixed(1))}M`:r>=1e3?`${n}${sc((r/1e3).toFixed(r>=1e4?0:1))}K`:`${n}${r.toLocaleString(`en-US`,{maximumFractionDigits:2})}`,t?`${i} ${t}`:i}function sc(e){return e.replace(/\.0$/,``)}function Y(e){return Math.round(e*100)/100}function cc(e,t,n,r){let i=(r-90)*Math.PI/180;return{x:Y(e+n*Math.cos(i)),y:Y(t+n*Math.sin(i))}}function lc(e,t,n,r,i,a){let o=a-i;if(o<=0)return``;o>=359.9&&(o=359.9);let s=i+o,c=+(o>180),l=cc(e,t,n,i),u=cc(e,t,n,s);if(r<=0)return[`M ${Y(e)} ${Y(t)}`,`L ${l.x} ${l.y}`,`A ${Y(n)} ${Y(n)} 0 ${c} 1 ${u.x} ${u.y}`,`Z`].join(` `);let d=cc(e,t,r,i),f=cc(e,t,r,s);return[`M ${l.x} ${l.y}`,`A ${Y(n)} ${Y(n)} 0 ${c} 1 ${u.x} ${u.y}`,`L ${f.x} ${f.y}`,`A ${Y(r)} ${Y(r)} 0 ${c} 0 ${d.x} ${d.y}`,`Z`].join(` `)}function uc(e){return e.length===0?``:e.map((e,t)=>`${t===0?`M`:`L`} ${Y(e.x)} ${Y(e.y)}`).join(` `)}function dc(e,t){if(e.length===0)return``;let n=uc(e),r=e[0],i=e[e.length-1];return`${n} L ${Y(i.x)} ${Y(t)} L ${Y(r.x)} ${Y(t)} Z`}function fc(e){let t=e.viewportWidth,n=e.viewportHeight,r=t*.06,i=n*.06,a=t-r*2,o=i,s;e.hasTitle&&(s={x:r,y:o,width:a,height:e.titleFontSize*2.2},o=s.y+s.height);let c,l=0;e.tableRowCount>0&&(l=Math.min(n*.4,(e.tableRowCount+1)*e.tableFontSize*2.4));let u=e.legendRows>0?e.legendRows*e.legendRowHeight:0,d={x:r,y:o,width:a,height:Math.max(40,n-i-o-u-l)};o=d.y+d.height;let f;u>0&&(f={x:r,y:o,width:a,height:u},o+=u),l>0&&(c={x:r,y:o,width:a,height:l});let p={x:d.x+e.leftGutter,y:d.y,width:Math.max(20,d.width-e.leftGutter),height:Math.max(20,d.height-e.bottomGutter)};return{titleBand:s,chartArea:d,plot:p,legendBand:f,tableBand:c}}function pc(e){let t=e.reduce((e,t)=>Math.max(e,t.values.length),0),n=Array(t).fill(0),r=Array(t).fill(0);return e.map(e=>Array.from({length:t},(t,i)=>{let a=e.values[i];if(a==null||!Number.isFinite(a))return{y0:n[i],y1:n[i]};if(a>=0){let e=n[i];return n[i]+=a,{y0:e,y1:n[i]}}let o=r[i];return r[i]+=a,{y0:r[i],y1:o}}))}function mc(e,t,n){let r=t*.9,i=t*1.6,a=t*2,o=e.map(e=>r+t*.5+e.length*t*.58),s=[],c=[],l=0;o.forEach((e,t)=>{let r=c.length>0?i:0;c.length>0&&l+r+e>n&&(s.push(c),c=[],l=0),c.push(t),l+=(c.length>1?i:0)+e}),c.length>0&&s.push(c);let u=[];return s.forEach((t,s)=>{let c=t.reduce((e,t,n)=>e+o[t]+(n>0?i:0),0),l=Math.max(0,(n-c)/2);t.forEach(t=>{u.push({label:e[t],index:t,x:l,y:s*a,swatchSize:r}),l+=o[t]+i})}),{items:u,rows:s.length,rowHeight:a}}function hc(e,t,n){if(e<=1)return 1;let r=n*6,i=t/e;return Math.max(1,Math.ceil(r/Math.max(1,i)))}var gc={bar:`barChart`,column:`columnChart`,pie:`pieChart`,donut:`donutChart`,line:`lineChart`,area:`areaChart`,scatter:`scatterChart`};function _c(e,t,n){let r=vc(t,n),i=r?rc(r,t):null;if(!r||!i)return yc(t,n);let{theme:a,viewport:o}=n,s=gc[e],c=(t.title??``).trim(),l=L(44,n,!0),u=L(20,n,!1),d=L(22,n,!1),f=L(22,n,!1),p=L(20,n,!1),m=I(n,`body`),h=e===`pie`||e===`donut`,g=bc(e,t,i),_=xc(n,t.colorScheme,h?i.labels.length:i.series.length);if(h&&!i.series[0].values.some(e=>e!==null&&e>0))return yc(t,n);let v=o.width*.88,y=g.length>0?mc(g,f,v):null,b=Sc(e,i,t,n,u,d),x=fc({viewportWidth:o.width,viewportHeight:o.height,hasTitle:c.length>0,titleFontSize:l,leftGutter:b.left,bottomGutter:b.bottom,legendRows:y?.rows??0,legendRowHeight:f*2,tableRowCount:t.showTable===!0?r.rows.length:0,tableFontSize:p}),S=Ii(n,s,`entrance`,`staggered`),w={kind:e,input:t,context:n,data:i,frame:x,colors:_,axisFontSize:u,labelFontSize:d,bodyFont:m,gridColor:C(a.colors.text,.12),axisTextColor:a.colors.textMuted,entrance:e=>({type:`fadeIn`,duration:.6,delay:S===`subtle`?.1:Math.min(1.2,.2+e*.08)})},T=[zi(`bg`,V(n,170))];switch(c&&x.titleBand&&T.push({type:`text`,id:`title`,content:{text:c,style:{fontSize:l,fontFamily:I(n,`title`),fontWeight:`bold`,color:a.colors.text,textAlign:`center`,shadow:z(n)}},position:{x:x.titleBand.x+x.titleBand.width/2,y:x.titleBand.y+x.titleBand.height/2,width:x.titleBand.width,anchor:`center`},animation:{type:`fadeIn`,duration:.8}}),e){case`bar`:T.push(...Dc(w));break;case`column`:T.push(...Ec(w));break;case`pie`:case`donut`:T.push(...Oc(w));break;case`line`:case`area`:T.push(...kc(w));break;case`scatter`:T.push(...Ac(w));break}return y&&x.legendBand&&T.push(...jc(w,y,x.legendBand,f)),t.showTable===!0&&x.tableBand&&T.push(Nc(r,x.tableBand,p,t,n)),T}function vc(e,t){return Array.isArray(e.headers)&&e.headers.length>0&&Array.isArray(e.rows)&&e.rows.length>0?{headers:e.headers,rows:e.rows}:Wa(e.contents??t.block?.contents)}function yc(e,t){return io({...e,template:`content`,title:e.title??t.block?.title??``},t)}function bc(e,t,n){return t.showLegend===!1?[]:e===`pie`||e===`donut`?n.labels:n.series.length>1||t.showLegend===!0?n.series.map(e=>e.name):[]}function xc(e,t,n){let r=e.theme.colorSchemes,i=Object.keys(r),a=[F(e,t).accent],o=t&&i.includes(t)?i.indexOf(t):0;for(let e=1;e<i.length&&a.length<n;e++){let t=r[i[(o+e)%i.length]].accent;a.some(e=>e.toLowerCase()===t.toLowerCase())||a.push(t)}let s=a.length;for(let e=0;a.length<n;e++)a.push(C(a[e%s],.55));return a.slice(0,Math.max(1,n))}function Sc(e,t,n,r,i,a){if(e===`pie`||e===`donut`)return{left:0,bottom:0};if(e===`bar`){let e=t.labels.reduce((e,t)=>Math.max(e,t.length),0);return{left:Math.min(r.viewport.width*.24,Math.max(a*3,e*a*.58+16)),bottom:i*2.4}}let o=Cc(e,t,n).ticks.reduce((e,t)=>Math.max(e,oc(t,n.unit).length),0);return{left:Math.max(i*2.5,o*i*.6+16),bottom:a*2.6}}function Cc(e,t,n){let r;r=(e===`bar`||e===`column`)&&n.stacked===!0?pc(t.series).flat().flatMap(e=>[e.y0,e.y1]):t.series.flatMap(e=>e.values.filter(e=>e!==null)),r.length===0&&(r=[0,1]);let i=Math.min(...r),a=Math.max(...r);return e!==`line`&&e!==`scatter`&&(i=Math.min(0,i),a=Math.max(0,a)),ac(i,a,5)}function wc(e,t,n){let{frame:r,gridColor:i,axisTextColor:a,axisFontSize:o,bodyFont:s,input:c}=e,l=[];return t.ticks.forEach((t,u)=>{let d=n(t);l.push({type:`shape`,id:`grid-${u}`,content:{shape:`rect`,fill:t===0?C(e.context.theme.colors.text,.35):i},position:{x:r.plot.x,y:d-(t===0?1:.5),width:r.plot.width,height:t===0?2:1}}),l.push({type:`text`,id:`tick-${u}`,content:{text:oc(t,c.unit),style:{fontSize:o,fontFamily:s,color:a,textAlign:`center`}},position:{x:r.chartArea.x+(r.plot.x-r.chartArea.x)/2,y:d,anchor:`center`}})}),l}function Tc(e,t){let{frame:n,data:r,labelFontSize:i,axisTextColor:a,bodyFont:o}=e,s=hc(r.labels.length,n.plot.width,i),c=[];return r.labels.forEach((e,r)=>{r%s!==0||!e||c.push({type:`text`,id:`cat-${r}`,content:{text:e,style:{fontSize:i,fontFamily:o,color:a,textAlign:`center`}},position:{x:t(r),y:n.plot.y+n.plot.height+i*1.2,anchor:`center`}})}),c}function Ec(e){let{frame:t,data:n,colors:r,input:i,entrance:a}=e,o=Cc(`column`,n,i),s=e=>t.plot.y+t.plot.height*(1-(e-o.niceMin)/(o.niceMax-o.niceMin)),c=wc(e,o,s),l=n.labels.length,u=t.plot.width/Math.max(1,l),d=u*.15;c.push(...Tc(e,e=>t.plot.x+(e+.5)*u));let f=i.stacked===!0&&n.series.length>1,p=f?pc(n.series):null,m=u-d*2,h=f?m:Math.max(2,(m-4*(n.series.length-1))/n.series.length);return n.series.forEach((n,o)=>{n.values.forEach((n,m)=>{if(m>=l)return;let g=p?p[o][m]:n===null?null:{y0:Math.min(0,n),y1:Math.max(0,n)};if(!g||g.y0===g.y1)return;let _=s(g.y1),v=Math.max(1,s(g.y0)-_),y=f?t.plot.x+m*u+d:t.plot.x+m*u+d+o*(h+4);c.push({type:`shape`,id:`mark-${o}-${m}`,content:{shape:`rect`,fill:r[o],borderRadius:f?0:3},position:{x:y,y:_,width:h,height:v},animation:a(m+o)}),i.showValues===!0&&n!==null&&!f&&c.push(Mc(e,`val-${o}-${m}`,n,y+h/2,n>=0?_-e.axisFontSize*.9:_+v+e.axisFontSize*.9))})}),c}function Dc(e){let{frame:t,data:n,colors:r,input:i,entrance:a,labelFontSize:o,axisFontSize:s,bodyFont:c,axisTextColor:l,gridColor:u}=e,d=Cc(`bar`,n,i),f=s*.6,p=e=>oc(e,i.unit).length*s*.58,m=i.showValues===!0&&i.stacked!==!0,h=m?n.series.flatMap(e=>e.values).filter(e=>e!==null).reduce((e,t)=>Math.max(e,p(t)),0)+f:0,g=Math.max(20,t.plot.width-h),_=e=>t.plot.x+g*((e-d.niceMin)/(d.niceMax-d.niceMin)),v=[];d.ticks.forEach((n,r)=>{let a=_(n);v.push({type:`shape`,id:`grid-${r}`,content:{shape:`rect`,fill:n===0?C(e.context.theme.colors.text,.35):u},position:{x:a-(n===0?1:.5),y:t.plot.y,width:n===0?2:1,height:t.plot.height}}),v.push({type:`text`,id:`tick-${r}`,content:{text:oc(n,i.unit),style:{fontSize:s,fontFamily:c,color:l,textAlign:`center`}},position:{x:a,y:t.plot.y+t.plot.height+s*1.2,anchor:`center`}})});let y=n.labels.length,b=t.plot.height/Math.max(1,y),x=b*.15,S=i.stacked===!0&&n.series.length>1,w=S?pc(n.series):null,T=b-x*2,E=S?T:Math.max(2,(T-4*(n.series.length-1))/n.series.length);return n.labels.forEach((e,n)=>{e&&v.push({type:`text`,id:`cat-${n}`,content:{text:e,style:{fontSize:o,fontFamily:c,color:l,textAlign:`center`}},position:{x:t.chartArea.x+(t.plot.x-t.chartArea.x)/2,y:t.plot.y+(n+.5)*b,anchor:`center`}})}),n.series.forEach((n,i)=>{n.values.forEach((n,o)=>{if(o>=y)return;let s=w?w[i][o]:n===null?null:{y0:Math.min(0,n),y1:Math.max(0,n)};if(!s||s.y0===s.y1)return;let c=_(s.y0),l=Math.max(1,_(s.y1)-c),u=S?t.plot.y+o*b+x:t.plot.y+o*b+x+i*(E+4);if(v.push({type:`shape`,id:`mark-${i}-${o}`,content:{shape:`rect`,fill:r[i],borderRadius:S?0:3},position:{x:c,y:u,width:l,height:E},animation:a(o+i)}),m&&n!==null){let t=p(n)/2,r=n>=0?c+l+f+t:c-f-t;v.push(Mc(e,`val-${i}-${o}`,n,r,u+E/2))}})}),v}function Oc(e){let{kind:t,frame:n,data:r,colors:i,input:a,entrance:o,context:s}=e,c=r.labels.map((e,t)=>({label:e,value:r.series[0].values[t],index:t})).filter(e=>e.value!==null&&Number.isFinite(e.value)&&e.value>0),l=c.reduce((e,t)=>e+t.value,0),u=n.chartArea.x+n.chartArea.width/2,d=n.chartArea.y+n.chartArea.height/2,f=Math.min(n.chartArea.width,n.chartArea.height)*.42,p=t===`donut`?f*.55:0,m=[],h=0;return c.forEach((t,n)=>{let r=t.value/l*360;if(m.push({type:`path`,id:`mark-${t.index}`,content:{d:lc(u,d,f,p,h,h+r),fill:i[t.index%i.length],stroke:s.theme.colors.background,strokeWidth:2},position:{x:u-f,y:d-f,width:f*2,height:f*2},animation:o(n)}),a.showValues===!0&&r>=14){let a=(h+r/2-90)*Math.PI/180,s=p>0?(p+f)/2:f*.68,c=`${Math.round(t.value/l*100)}%`;m.push({type:`text`,id:`val-${t.index}`,content:{text:c,style:{fontSize:e.axisFontSize,fontFamily:e.bodyFont,fontWeight:`bold`,color:S(i[t.index%i.length]),textAlign:`center`}},position:{x:u+s*Math.cos(a),y:d+s*Math.sin(a),anchor:`center`},animation:o(n)})}h+=r}),m}function kc(e){let{kind:t,frame:n,data:r,colors:i,input:a,entrance:o}=e,s=Cc(t,r,a),c=e=>n.plot.y+n.plot.height*(1-(e-s.niceMin)/(s.niceMax-s.niceMin)),l=r.labels.length,u=n.plot.width/Math.max(1,l),d=e=>n.plot.x+(e+.5)*u,f=wc(e,s,c);f.push(...Tc(e,d));let p=c(Math.max(s.niceMin,Math.min(s.niceMax,0))),m=l<=30;return r.series.forEach((r,s)=>{let u=[],h=[];r.values.forEach((e,t)=>{if(!(t>=l)){if(e===null){h.length>0&&u.push(h),h=[];return}h.push({x:d(t),y:c(e)})}}),h.length>0&&u.push(h),u.forEach((e,r)=>{t===`area`&&e.length>1&&f.push({type:`path`,id:`area-${s}-${r}`,content:{d:dc(e,p),fill:i[s],fillOpacity:.25,stroke:`none`,strokeWidth:0},position:{x:n.plot.x,y:n.plot.y,width:n.plot.width,height:n.plot.height},animation:o(s)}),e.length>1&&f.push({type:`path`,id:`line-${s}-${r}`,content:{d:uc(e),stroke:i[s],strokeWidth:4,fill:`none`},position:{x:n.plot.x,y:n.plot.y,width:n.plot.width,height:n.plot.height},animation:o(s)})}),m&&r.values.forEach((t,n)=>{n>=l||t===null||(f.push({type:`shape`,id:`pt-${s}-${n}`,content:{shape:`circle`,fill:i[s]},position:{x:d(n)-5,y:c(t)-5,width:10,height:10},animation:o(s)}),a.showValues===!0&&f.push(Mc(e,`val-${s}-${n}`,t,d(n),c(t)-e.axisFontSize)))})}),f}function Ac(e){let{frame:t,data:n,colors:r,input:i,entrance:a}=e,o=Cc(`scatter`,n,i),s=e=>t.plot.y+t.plot.height*(1-(e-o.niceMin)/(o.niceMax-o.niceMin)),c=wc(e,o,s),l=n.labelNumbers.filter(e=>e!==null).length,u=n.labels.length>0&&l/n.labels.length>=.6,d;if(u){let r=n.labelNumbers.filter(e=>e!==null),i=ac(Math.min(...r),Math.max(...r),5),a=i.niceMax-i.niceMin;d=e=>{let r=n.labelNumbers[e];return r===null?null:t.plot.x+t.plot.width*((r-i.niceMin)/a)},i.ticks.forEach((n,r)=>{let o=t.plot.x+t.plot.width*((n-i.niceMin)/a);c.push({type:`shape`,id:`xgrid-${r}`,content:{shape:`rect`,fill:e.gridColor},position:{x:o-.5,y:t.plot.y,width:1,height:t.plot.height}}),c.push({type:`text`,id:`xtick-${r}`,content:{text:oc(n),style:{fontSize:e.axisFontSize,fontFamily:e.bodyFont,color:e.axisTextColor,textAlign:`center`}},position:{x:o,y:t.plot.y+t.plot.height+e.axisFontSize*1.2,anchor:`center`}})})}else{let r=t.plot.width/Math.max(1,n.labels.length);d=e=>t.plot.x+(e+.5)*r,c.push(...Tc(e,e=>t.plot.x+(e+.5)*r))}return n.series.forEach((e,t)=>{e.values.forEach((e,n)=>{if(e===null)return;let i=d(n);i!==null&&c.push({type:`shape`,id:`mark-${t}-${n}`,content:{shape:`circle`,fill:r[t],fillOpacity:.85},position:{x:i-7,y:s(e)-7,width:14,height:14},animation:a(Math.floor(n/3)+t)})})}),c}function jc(e,t,n,r){let i=[];return t.items.forEach((a,o)=>{let s=e.colors[a.index%e.colors.length],c=n.y+a.y+t.rowHeight/2;i.push({type:`shape`,id:`legend-swatch-${o}`,content:{shape:`rect`,fill:s,borderRadius:3},position:{x:n.x+a.x,y:c-a.swatchSize/2,width:a.swatchSize,height:a.swatchSize}}),i.push({type:`text`,id:`legend-label-${o}`,content:{text:a.label,style:{fontSize:r,fontFamily:e.bodyFont,color:e.context.theme.colors.text}},position:{x:n.x+a.x+a.swatchSize+r*.5,y:c-r*.62}})}),i}function Mc(e,t,n,r,i){return{type:`text`,id:t,content:{text:oc(n,e.input.unit),style:{fontSize:e.axisFontSize,fontFamily:e.bodyFont,fontWeight:`bold`,color:e.context.theme.colors.text,textAlign:`center`}},position:{x:r,y:i,anchor:`center`}}}function Nc(e,t,n,r,i){let{theme:a}=i,o=F(i,r.colorScheme);return{type:`table`,id:`table`,content:{headers:e.headers,rows:e.rows,align:e.align,style:{headerBackground:o.accent,headerColor:S(o.accent),cellBackground:C(a.colors.text,.04),cellColor:a.colors.text,borderColor:C(a.colors.text,.15),fontSize:n,fontFamily:I(i,`body`),headerFontFamily:I(i,`title`),borderRadius:8}},position:{x:t.x,y:t.y,width:t.width,height:t.height},animation:{type:`fadeIn`,duration:1,delay:.4}}}function Pc(e,t){return _c(`bar`,e,t)}function Fc(e,t){return _c(`column`,e,t)}function Ic(e,t){return _c(`pie`,e,t)}function Lc(e,t){return _c(`donut`,e,t)}function Rc(e,t){return _c(`line`,e,t)}function zc(e,t){return _c(`area`,e,t)}function Bc(e,t){return _c(`scatter`,e,t)}var Vc={title:Bi,sectionHeader:ea,bigText:la,content:io,statHighlight:ao,quote:oo,factCard:so,twoColumn:co,dateEvent:uo,imageWithCaption:fo,leftFeature:mo,rightFeature:ho,map:go,fullBleedQuote:_o,list:xo,photoGrid:So,definitionCard:wo,comparisonBar:To,pullQuote:Eo,videoWithCaption:Do,videoPullQuote:Oo,dataTable:ko,barChart:Pc,columnChart:Fc,pieChart:Ic,donutChart:Lc,lineChart:Rc,areaChart:zc,scatterChart:Bc,diagram:zo,tree:Ho,timeline:Xo,layout:As,drawing:gs};function Hc(e){let t={...Vc};if(e)for(let n of e)t[n.name]||(t[n.name]=Qs(n));return t}var Uc=[{type:`slowZoom`,direction:`in`},{type:`slowZoom`,direction:`out`},{type:`slowZoom`,panDirection:`left`},{type:`slowZoom`,panDirection:`right`}],Wc=8;function Gc(e){return e===0||e===`0`||e===`0%`}function Kc(e){if(e.type!==`image`&&e.type!==`video`)return!1;let{position:t}=e;if(!Gc(t.x)||!Gc(t.y)||t.width!==`100%`||t.height!==`100%`)return!1;let n=e.content.fit;return n===void 0||n===`cover`}function qc(e){return e.renderStyle.ambientMotion===!0}function Jc(e,t,n){let r=n.style.animationSpeed??1,i=qc(n);return r===1&&!i?e:e.map(e=>{let n=e.animation;return!n&&i&&Kc(e)&&(n={...new Se(be(`${t.id}:${e.id}`)).pickRequired(Uc),duration:Math.max(Wc,t.duration??0)}),!n||n.type===`none`||r!==1&&(n={...n,...n.duration==null?{}:{duration:n.duration*r},...n.delay==null?{}:{delay:n.delay*r}}),n===e.animation?e:{...e,animation:n}})}function Yc(e,t){if(e===t)return 0;let n=e.length,r=t.length;if(n===0)return r;if(r===0)return n;let i=Array(r+1),a=Array(r+1);for(let e=0;e<=r;e++)i[e]=e;for(let o=1;o<=n;o++){a[0]=o;for(let n=1;n<=r;n++){let r=e[o-1]===t[n-1]?0:1;a[n]=Math.min(i[n]+1,a[n-1]+1,i[n-1]+r)}[i,a]=[a,i]}return i[r]}function Xc(e,t,n){let r=n?.maxDistance??2,i,a=1/0,o=e.toLowerCase();for(let e of t){let t=Yc(o,e.toLowerCase());t<a&&(a=t,i=e)}if(i&&(a<=r||a<=Math.ceil(e.length*.4)))return n?.map?n.map(i):i}var Zc=[`zoomIn`,`zoomOut`,`panLeft`,`panRight`],Qc=[`bottom`,`top`,`center`],$c=[`terrain`,`satellite`,`road`,`toner`,`watercolor`],el=[`neutral`,`somber`,`celebratory`],tl=`theme color-scheme name — e.g. 'blue', 'green'`;function nl(e=[]){return[{key:`title`,description:`Optional title above the chart`},{key:`labelColumn`,description:`Category/label column`,valueHint:`header name or 0-based index`},{key:`valueColumns`,description:`Value columns to plot`,coerce:`stringList`,valueHint:`comma-separated header names or 0-based indexes`},{key:`showTable`,description:`Render the source table beneath the chart`,coerce:`boolean`},{key:`showLegend`,description:`Show a series legend`,coerce:`boolean`},{key:`showValues`,description:`Print numeric value labels on marks`,coerce:`boolean`},{key:`unit`,description:`Unit suffix for tick/value labels (e.g. "km")`},{key:`colorScheme`,description:`Color scheme seeding the series color rotation`,valueHint:tl},{key:`headers`,description:`Header cells (normally derived from the table)`,coerce:`stringList`},{key:`rows`,description:`Table rows (supply via a data fence)`},...e]}var rl={key:`stacked`,description:`Stack series instead of grouping them side by side`,coerce:`boolean`},il=[{key:`imageTreatment`,description:`Per-block photographic grade override ('none' opts out)`,values:[`none`,`mono`,`duotone`,`warm`,`cool`]},{key:`useBottomLayer`,description:`Show the doc's bottom persistent layers`,coerce:`boolean`},{key:`useTopLayer`,description:`Show the doc's top persistent layers`,coerce:`boolean`}],al={title:[{key:`title`,description:`Main title text`},{key:`subtitle`,description:`Subtitle or tagline`},{key:`backgroundColor`,description:`Background color`,valueHint:`CSS color`}],sectionHeader:[{key:`title`,description:`Section title`},{key:`colorScheme`,description:`Fallback background color scheme`,valueHint:tl},{key:`imageSrc`,description:`Optional background image path`},{key:`imageAlt`,description:`Alt text for the background image`},{key:`ambientMotion`,description:`Slow zoom/pan effect`,values:Zc}],bigText:[{key:`title`,description:`The display text (rendered uppercase)`},{key:`imageSrc`,description:`Optional full-bleed background image path`},{key:`imageAlt`,description:`Alt text for the background image`},{key:`ambientMotion`,description:`Slow zoom/pan effect`,values:Zc}],content:[{key:`title`,description:`Heading shown above the complete body`}],statHighlight:[{key:`stat`,description:`The statistic (e.g. "89%", "2x")`},{key:`description`,description:`What the stat means`},{key:`detail`,description:`Additional detail or context`},{key:`colorScheme`,description:`Color scheme for the stat`,valueHint:tl}],quote:[{key:`title`,description:`Optional heading above the quote`},{key:`quote`,description:`The quote text`},{key:`attribution`,description:`Attribution (author, source)`}],pullQuote:[{key:`text`,description:`Quote text`},{key:`attribution`,description:`Attribution`}],twoColumn:[{key:`left`,description:`Left column, as "label|sublabel"`,coerce:`labeledPair`,required:!0},{key:`right`,description:`Right column, as "label|sublabel"`,coerce:`labeledPair`,required:!0},{key:`header`,description:`Optional header above the columns`},{key:`leftColor`,description:`Left column color scheme`,valueHint:tl},{key:`rightColor`,description:`Right column color scheme`,valueHint:tl}],dateEvent:[{key:`date`,description:`The date (e.g. "July 14, 1974")`},{key:`description`,description:`What happened`},{key:`footer`,description:`Optional footer text`},{key:`mood`,description:`Emotional tone`,values:el}],imageWithCaption:[{key:`imageSrc`,description:`Path to the image file`,required:!0},{key:`imageAlt`,description:`Alt text for accessibility`},{key:`caption`,description:`Caption text`},{key:`captionPosition`,description:`Caption placement`,values:Qc},{key:`ambientMotion`,description:`Slow zoom/pan effect`,values:Zc},{key:`isTitle`,description:`Style the caption as a title`,coerce:`boolean`},{key:`subtitle`,description:`Subtitle (only when isTitle)`},{key:`imageCredit`,description:`Photo credit / artist name`},{key:`imageLicense`,description:`License identifier`}],leftFeature:ol(),rightFeature:ol(),map:[{key:`center`,description:`Map center as "lat,lng"`,coerce:`latLng`,required:!0},{key:`zoom`,description:`Zoom level (4-16)`,coerce:`number`},{key:`mapStyle`,description:`Map tile style`,values:$c},{key:`title`,description:`Optional title overlay`},{key:`caption`,description:`Optional caption`}],photoGrid:[{key:`images`,description:`Comma-separated image paths`,coerce:`stringList`},{key:`caption`,description:`Optional caption below the grid`},{key:`ambientMotion`,description:`Slow zoom/pan on the largest image`,values:Zc}],comparisonBar:[{key:`leftLabel`,description:`Left bar label`,required:!0},{key:`leftValue`,description:`Left bar numeric value`,coerce:`number`,required:!0},{key:`rightLabel`,description:`Right bar label`,required:!0},{key:`rightValue`,description:`Right bar numeric value`,coerce:`number`,required:!0},{key:`unit`,description:`Unit label (e.g. "km")`},{key:`colorScheme`,description:`Color scheme`,valueHint:tl}],dataTable:[{key:`title`,description:`Optional title above the table`},{key:`headers`,description:`Comma-separated header cells`,coerce:`stringList`},{key:`rows`,description:`Table rows (supply via a data fence)`},{key:`align`,description:`Per-column alignment (supply via a data fence)`},{key:`colorScheme`,description:`Header color scheme`,valueHint:tl},{key:`sheet`,description:`Source worksheet name (XLSX round-trip)`},{key:`anchor`,description:`Top-left cell of the region, e.g. 'B7'`},{key:`role`,description:`What the table holds within its region`,values:[`values`,`formulas`,`loose`]},{key:`headerRow`,description:`Whether row 1 of the source region is a header row`,coerce:`boolean`},{key:`titleAnchor`,description:`Cell this heading text was absorbed from`}],barChart:nl([rl]),columnChart:nl([rl]),pieChart:nl(),donutChart:nl(),lineChart:nl(),areaChart:nl(),scatterChart:nl(),tree:[{key:`title`,description:`Optional title above the tree`},{key:`colorScheme`,description:`Folder-row color scheme`,valueHint:tl},{key:`items`,description:`Tree items (derived from the tree fence)`}],timeline:[{key:`title`,description:`Optional title above the timeline`},{key:`colorScheme`,description:`Track and marker color scheme`,valueHint:tl},{key:`tracks`,description:`Timeline tracks and events (supply via template data)`},{key:`links`,description:`Branch links between event ids (supply via template data)`}],videoWithCaption:[{key:`videoSrc`,description:`Path to the video file`,required:!0},{key:`posterSrc`,description:`Poster frame path`},{key:`videoAlt`,description:`Alt text for accessibility`},{key:`clipStart`,description:`Clip start time (seconds)`,coerce:`number`},{key:`clipEnd`,description:`Clip end time (seconds)`,coerce:`number`},{key:`caption`,description:`Caption text`},{key:`captionPosition`,description:`Caption placement`,values:Qc},{key:`videoCredit`,description:`Video credit / artist name`},{key:`videoLicense`,description:`License identifier`}]};function ol(){return[{key:`imageSrc`,description:`Path to the feature image`,required:!0},{key:`imageAlt`,description:`Alt text for accessibility`},{key:`imageWidth`,description:`Explicit display width in px`,coerce:`number`},{key:`imageHeight`,description:`Explicit display height in px`,coerce:`number`},{key:`title`,description:`Heading text next to the image`},{key:`body`,description:`Body text below the title`}]}function sl(e){let t=al[e];if(t)return[...t,...il]}function cl(e){return new Map(e.map(e=>[e.key,e]))}function ll(e,t){let n={},r=[],i=e?sl(j(e)):void 0,a=i?cl(i):void 0;for(let[e,i]of Object.entries(t)){let{value:t,warning:o}=ul(a?.get(e)?.coerce??`string`,i);o?(r.push(`"${e}": ${o}`),n[e]=i):n[e]=t}return{input:n,warnings:r}}function ul(e,t){switch(e){case`number`:{let e=ae(t);return e==null?{value:t,warning:`not a number (${JSON.stringify(t)})`}:{value:e}}case`boolean`:return dl(t);case`latLng`:return fl(t);case`labeledPair`:return{value:pl(t)};case`stringList`:return{value:ml(t)};default:return{value:t}}}function dl(e){let t=e.trim().toLowerCase();return t===`true`||t===``?{value:!0}:t===`false`?{value:!1}:{value:e,warning:`not a boolean (${JSON.stringify(e)}) \u2014 expected true or false`}}function fl(e){let t=e.split(`,`);if(t.length===2){let e=ae(t[0]),n=ae(t[1]);if(e!=null&&n!=null)return{value:{lat:e,lng:n}}}return{value:e,warning:`not a "lat,lng" pair (${JSON.stringify(e)})`}}function pl(e){let t=e.indexOf(`|`);if(t<0)return{label:e.trim()};let n=e.slice(0,t).trim(),r=e.slice(t+1).trim();return r?{label:n,sublabel:r}:{label:n}}function ml(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function hl(e,t){let n=j(e),r=al[n];if(!r)return[];let i=[],a=cl([...r,...il]),o=new Set([...a.keys(),...Object.keys(oe)]);for(let[e,r]of Object.entries(t)){let t=a.get(e);if(!t){if(o.has(e))continue;let t=Xc(e,o);i.push({kind:`unknown-input`,key:e,message:`Unknown input "${e}" for template "${n}"`+(t?`. Did you mean "${t}"?`:``),...t?{suggestion:t}:{}});continue}if(t.values){let n=r.trim();n!==``&&!t.values.includes(n)&&i.push({kind:`invalid-input-value`,key:e,message:`Invalid value ${JSON.stringify(r)} for "${e}" \u2014 expected one of: ${t.values.join(`, `)}`})}else if(t.coerce&&t.coerce!==`string`){let{warning:n}=ul(t.coerce,r);n&&i.push({kind:`invalid-input-value`,key:e,message:`"${e}": ${n}`})}}for(let e of r)e.required&&t[e.key]==null&&i.push({kind:`missing-input`,key:e.key,message:`Missing required input "${e.key}" for template "${n}"`});return i}var gl=600;function _l(e,t,n){let r=F(t,`blue`),{layout:i}=t,a=e.title??e.id??``,o=vl(e),s=[{type:`shape`,id:`fallback-bg`,content:{shape:`rect`,fill:r.bg},position:{x:0,y:0,width:`100%`,height:`100%`}}];return a&&s.push({type:`text`,id:`fallback-title`,content:{text:a,style:{fontSize:L(56,t,!0),fontFamily:I(t,`title`),fontWeight:`bold`,color:r.text,textAlign:`center`}},position:{x:`50%`,y:o?`28%`:`50%`,anchor:`center`,width:i.maxTextWidth}}),o&&s.push({type:`text`,id:`fallback-body`,content:{text:o,style:{fontSize:L(28,t),fontFamily:I(t,`body`),color:r.text,textAlign:`center`}},position:{x:`50%`,y:`55%`,anchor:`center`,width:i.maxTextWidth}}),s.push({type:`text`,id:`fallback-notice`,content:{text:`\u26A0 ${n}`,style:{fontSize:L(18,t),fontFamily:I(t,`body`),color:C(r.text,.6),textAlign:`center`}},position:{x:`50%`,y:`92%`,anchor:`center`,width:i.maxTextWidth}}),s}function vl(e){if(!e.contents||e.contents.length===0)return``;let t=e.contents.map(e=>o(e)).join(`
|
|
25
|
-
`).trim();return t.length<=gl?t:`${t.slice(0,gl).trimEnd()}\u2026`}var yl={landscape:{wide:`title-stack`,tall:`split`,square:`title-stack`,multiple:`title-stack`},square:{wide:`title-stack`,tall:`split`,square:`title-stack`,multiple:`title-stack`},portrait:{wide:`title-stack`,tall:`title-stack`,square:`title-stack`,multiple:`title-stack`}},bl={landscape:{wide:`split`,tall:`split`,square:`split`,multiple:`split`},square:{wide:`text-stack`,tall:`split`,square:`text-stack`,multiple:`text-stack`},portrait:{wide:`text-stack`,tall:`text-stack`,square:`text-stack`,multiple:`text-stack`}},xl={landscape:{wide:`dense-stack`,tall:`dense-stack`,square:`dense-stack`,multiple:`dense-stack`},square:{wide:`dense-stack`,tall:`dense-stack`,square:`dense-stack`,multiple:`dense-stack`},portrait:{wide:`dense-stack`,tall:`dense-stack`,square:`dense-stack`,multiple:`dense-stack`}},Sl={title:{summary:`Text-only by default; supplemental media gets a title band plus a reserved field.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:yl},sectionHeader:{summary:`Uses its authored background image when present; otherwise supplemental media receives a title composition.`,noMedia:`template-without-optional-media`,ownership:`optional-native`,nativeLayout:`background-image`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`reserve-when-no-native-media`,variants:yl},bigText:{summary:`Uses its authored background image (behind a contrast bloom) when present; otherwise renders gigantic text on the theme surface.`,noMedia:`template-without-optional-media`,ownership:`optional-native`,nativeLayout:`background-image`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`reserve-when-no-native-media`,variants:yl},content:{summary:`Preserves the complete heading and body; supplemental media receives a companion field.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:bl},statHighlight:{summary:`Uses its optional accent image natively; otherwise supplemental media occupies a companion field.`,noMedia:`template-without-optional-media`,ownership:`optional-native`,nativeLayout:`accent-strip-or-inset`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`reserve-when-no-native-media`,variants:bl},quote:{summary:`Uses its optional accent image natively; otherwise supplemental media is paired with the quote.`,noMedia:`template-without-optional-media`,ownership:`optional-native`,nativeLayout:`accent-strip-or-inset`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`reserve-when-no-native-media`,variants:bl},factCard:{summary:`Uses its optional accent image natively; otherwise supplemental media is paired with the fact card.`,noMedia:`template-without-optional-media`,ownership:`optional-native`,nativeLayout:`accent-strip-or-inset`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`reserve-when-no-native-media`,variants:bl},twoColumn:{summary:`Text comparison by default; supplemental media stacks below the dense two-column panel.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:xl},dateEvent:{summary:`Uses its optional accent image natively; otherwise supplemental media is paired with the event.`,noMedia:`template-without-optional-media`,ownership:`optional-native`,nativeLayout:`accent-strip-or-inset`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`reserve-when-no-native-media`,variants:bl},imageWithCaption:{summary:`Requires one primary image and owns its full-bleed image/caption geometry.`,noMedia:`unsupported`,ownership:`required-native`,nativeLayout:`full-bleed-image`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},leftFeature:{summary:`Requires a primary image in the left feature cell; text occupies the right cell.`,noMedia:`unsupported`,ownership:`required-native`,nativeLayout:`feature-left`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},rightFeature:{summary:`Requires a primary image in the right feature cell; text occupies the left cell.`,noMedia:`unsupported`,ownership:`required-native`,nativeLayout:`feature-right`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},map:{summary:`The map canvas is the primary visual; other media must not reflow its geography.`,noMedia:`intrinsic-visual`,ownership:`intrinsic-visual`,nativeLayout:`map-canvas`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},fullBleedQuote:{summary:`Despite its name this is text-only; supplemental media receives the same dramatic title treatment.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:yl},list:{summary:`Uses its optional accent image natively; otherwise supplemental media is paired with the list.`,noMedia:`template-without-optional-media`,ownership:`optional-native`,nativeLayout:`accent-strip-or-inset`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`reserve-when-no-native-media`,variants:bl},photoGrid:{summary:`Requires a primary image collection and owns the complete tiled media field.`,noMedia:`unsupported`,ownership:`required-native`,nativeLayout:`photo-grid`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},definitionCard:{summary:`Uses its optional accent image natively; otherwise supplemental media is paired with the definition.`,noMedia:`template-without-optional-media`,ownership:`optional-native`,nativeLayout:`accent-strip-or-inset`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`reserve-when-no-native-media`,variants:bl},comparisonBar:{summary:`Data bars are primary; supplemental media stacks below to preserve horizontal scale.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:xl},pullQuote:{summary:`Requires and owns a full-bleed background image behind the quote lockup.`,noMedia:`unsupported`,ownership:`required-native`,nativeLayout:`full-bleed-image`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},videoWithCaption:{summary:`Requires one primary video and owns its full-bleed video/caption geometry.`,noMedia:`unsupported`,ownership:`required-native`,nativeLayout:`full-bleed-video`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},videoPullQuote:{summary:`Requires and owns a full-bleed video behind the quote lockup.`,noMedia:`unsupported`,ownership:`required-native`,nativeLayout:`full-bleed-video`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},dataTable:{summary:`The table remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:xl},barChart:{summary:`The chart remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:xl},columnChart:{summary:`The chart remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:xl},pieChart:{summary:`The chart remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:xl},donutChart:{summary:`The chart remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:xl},lineChart:{summary:`The chart remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:xl},areaChart:{summary:`The chart remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:xl},scatterChart:{summary:`The chart remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:xl},diagram:{summary:`The node-and-edge canvas is intrinsic media and retains its spatial coordinate system.`,noMedia:`intrinsic-visual`,ownership:`intrinsic-visual`,nativeLayout:`spatial-canvas`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},tree:{summary:`The interactive tree canvas is intrinsic media and retains its full layout region.`,noMedia:`intrinsic-visual`,ownership:`intrinsic-visual`,nativeLayout:`spatial-canvas`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},timeline:{summary:`The track canvas is intrinsic media and retains its shared horizontal time scale.`,noMedia:`intrinsic-visual`,ownership:`intrinsic-visual`,nativeLayout:`spatial-canvas`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},layout:{summary:`The authored layer canvas is intrinsic media and must preserve absolute placement.`,noMedia:`intrinsic-visual`,ownership:`intrinsic-visual`,nativeLayout:`freeform-canvas`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},drawing:{summary:`The drawing canvas is intrinsic media and must preserve authored geometry.`,noMedia:`intrinsic-visual`,ownership:`intrinsic-visual`,nativeLayout:`freeform-canvas`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`}};function Cl(e){if(e)return Sl[e]}function X(e,t,n,r,i){return{x:e.width*t,y:e.height*n,width:e.width*r,height:e.height*i}}function wl(e,t){if(e>1)return`multiple`;let n=t[0]??16/9;return n<.8?`tall`:n>1.25?`wide`:`square`}function Tl(e,t){return t===`portrait`?{contentRect:X(e,.06,.04,.88,.3),mediaRect:X(e,.06,.39,.88,.55),fontScale:.76}:t===`square`?{contentRect:X(e,.05,.04,.9,.33),mediaRect:X(e,.07,.42,.86,.51),fontScale:.72}:{contentRect:X(e,.04,.03,.92,.32),mediaRect:X(e,.08,.4,.84,.52),fontScale:.72}}function El(e,t){let n=t===`square`;return{contentRect:X(e,n?.05:.04,.05,n?.42:.43,.9),mediaRect:X(e,n?.52:.53,.07,.43,.86),fontScale:.72}}function Dl(e,t,n){return t===`portrait`?{contentRect:X(e,.06,.04,.88,n?.41:.36),mediaRect:X(e,.06,n?.5:.45,.88,n?.44:.49),fontScale:n?.42:.44}:t===`square`?{contentRect:X(e,.05,.04,.9,n?.43:.36),mediaRect:X(e,.07,n?.52:.45,.86,n?.41:.48),fontScale:n?.45:.46}:{contentRect:X(e,.05,.03,.9,n?.46:.35),mediaRect:X(e,.07,n?.55:.43,.86,n?.38:.49),fontScale:n?.5:.48}}function Ol(e,t){let n=_(e);if(n===`portrait`)switch(t){case`tall`:return X(e,.55,.5,.38,.44);case`square`:return X(e,.49,.58,.44,.35);case`multiple`:return X(e,.07,.67,.86,.27);case`wide`:return X(e,.07,.71,.86,.23)}if(n===`square`)switch(t){case`tall`:return X(e,.68,.1,.27,.8);case`square`:return X(e,.55,.52,.4,.4);case`multiple`:return X(e,.08,.62,.84,.31);case`wide`:return X(e,.08,.68,.84,.27)}switch(t){case`tall`:return X(e,.7,.1,.26,.8);case`square`:return X(e,.62,.22,.34,.56);case`multiple`:return X(e,.52,.5,.44,.42);case`wide`:return X(e,.54,.58,.42,.34)}}function kl(e,t){let n=_(t);switch(e){case`title-stack`:return Tl(t,n);case`split`:return El(t,n);case`text-stack`:return Dl(t,n,!1);case`dense-stack`:return Dl(t,n,!0)}}function Z(e,t){if(e===void 0)return 0;if(typeof e==`number`)return e;let n=e.match(/^\s*(-?\d+(?:\.\d+)?)%\s*$/);if(n)return Number(n[1])/100*t;let r=Number.parseFloat(e);return Number.isFinite(r)?r:0}function Al(e){return e===0||e===`0`||e===`0%`}function jl(e,t){if(e.type!==`shape`&&e.type!==`image`)return!1;let{position:n}=e,r=n.width===`100%`||n.width===t.width,i=n.height===`100%`||n.height===t.height;return Al(n.x)&&Al(n.y)&&r&&i}function Ml(e,t,n){let r={...e,x:t.x+Z(e.x,n.width)/n.width*t.width,y:t.y+Z(e.y,n.height)/n.height*t.height};return e.width!==void 0&&(r.width=Z(e.width,n.width)/n.width*t.width),e.height!==void 0&&(r.height=Z(e.height,n.height)/n.height*t.height),r}function Nl(e,t,n,r){let i=n.width/t.width,a=n.height/t.height,o=Math.min(i,a);return e.map(e=>{let s={...e.position,x:n.x+Z(e.position.x,t.width)*i,y:n.y+Z(e.position.y,t.height)*a,...e.position.width===void 0?{}:{width:Z(e.position.width,t.width)*i},...e.position.height===void 0?{}:{height:Z(e.position.height,t.height)*a}},c={...e,id:`${r}-${e.id}`,position:s};return e.type===`path`?{...c,type:`path`,content:{...e.content,d:Pl(e.content.d,i,a,n.x,n.y),...e.content.strokeWidth===void 0?{}:{strokeWidth:e.content.strokeWidth*o}}}:e.type===`text`&&o!==1?{...c,type:`text`,content:{...e.content,style:{...e.content.style,fontSize:Math.max(10,e.content.style.fontSize*o)}}}:c})}function Pl(e,t,n,r,i){let a=e.match(/[a-zA-Z]|[-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/gi);if(!a)return e;let o=``,s=0;return a.map(e=>{if(/^[a-zA-Z]$/.test(e))return o=e,s=0,e;let a=Number(e);if(!Number.isFinite(a)||o===o.toLowerCase())return s++,e;let c=s++,l=a;switch(o){case`M`:case`L`:case`T`:case`C`:case`S`:case`Q`:l=c%2==0?a*t+r:a*n+i;break;case`H`:l=a*t+r;break;case`V`:l=a*n+i;break;case`A`:{let e=c%7;e===0?l=a*t:e===1?l=a*n:e===5?l=a*t+r:e===6&&(l=a*n+i);break}}return String(Math.round(l*1e3)/1e3)}).join(` `)}function Fl(e,t,n,r,i){return Il(e.map(e=>{if(jl(e,n))return e;let i=Ml(e.position,t,n);return e.type===`text`?{...e,position:i,content:{...e.content,style:{...e.content.style,fontSize:Math.max(12,Math.round(e.content.style.fontSize*r)),...e.content.style.padding===void 0?{}:{padding:Math.round(e.content.style.padding*r)}}}}:{...e,position:i}}),i,t,n)}function Il(e,t,n,r){let i=n.x+n.width/2,a=n.y+n.height/2;if(t===`sectionHeader`)return e.map(e=>{if(e.id===`title`)return{...e,position:{...e.position,x:i,y:a,width:n.width*.9,anchor:`center`}};if(e.id===`line-top`||e.id===`line-bottom`){let t=e.id===`line-top`?-1:1;return{...e,position:{...e.position,x:i,y:a+t*n.height*.28,width:Math.min(n.width*.22,r.width*.2),height:2,anchor:`center`}}}return e});if(t!==`title`)return e;let o=e.find(e=>e.type===`text`&&e.id===`title`),s=e.find(e=>e.type===`text`&&e.id===`subtitle`);if(!o||o.type!==`text`)return e;let c=s?.type===`text`?s:void 0,l=n.width*.9,u=Math.max(12,Math.min(r.width,r.height)*.018),d=c?u:0,f=n.height*.78,p=o.content.style.fontSize,m=c?.content.style.fontSize??0,h=()=>{let e=H(o.content.text,p,l,o.content.style.lineHeight??1.15),t=c?H(c.content.text,m,l,c.content.style.lineHeight??1.5):0;return{titleHeight:e,subtitleHeight:t,total:e+d+t}},g=h();if(g.total>f){let e=Math.max(.5,f/g.total);p=Math.max(18,Math.round(p*e)),m=Math.max(14,Math.round(m*e)),g=h()}let _=n.y+(n.height-g.total)/2,v=_+g.titleHeight/2,y=_+g.titleHeight+d+g.subtitleHeight/2;return e.map(e=>e.id===`title`&&e.type===`text`?{...e,position:{...e.position,x:i,y:v,width:l,anchor:`center`},content:{...e.content,style:{...e.content.style,fontSize:p}}}:e.id===`subtitle`&&e.type===`text`?{...e,position:{...e.position,x:i,y,width:l,anchor:`center`},content:{...e.content,style:{...e.content.style,fontSize:m}}}:e.id===`accent-line`?{...e,position:{...e.position,x:i,y:Math.max(n.y+2,_-u*.75),width:Math.min(n.width*.18,r.width*.12),height:3,anchor:`center`}}:e)}function Ll(e,t,n,r){let i=e.width?Z(e.width,t.width):n,a=e.height?Z(e.height,t.height):r,o=Z(e.x,t.width),s=Z(e.y,t.height),c=e.anchor??`top-left`;return c===`center`?(o-=i/2,s-=a/2):(c.endsWith(`right`)&&(o-=i),c.startsWith(`bottom`)&&(s-=a)),{x:o,y:s,width:i,height:a}}function Rl(e,t){return Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))}function zl(e,t){let n=e.filter(e=>e.type!==`shape`&&e.type!==`path`&&e.type!==`mermaid`).map(e=>Ll(e.position,t,e.type===`text`?t.width*.45:t.width*.5,e.type===`text`?t.height*.2:t.height*.55));return n.length===0?X(t,.06,.08,.88,.84):[X(t,.52,.12,.44,.76),X(t,.04,.12,.44,.76),X(t,.15,.53,.7,.41)].reduce((e,t)=>n.reduce((e,n)=>e+Rl(t,n),0)<n.reduce((t,n)=>t+Rl(e,n),0)?t:e)}function Bl(e,t,n,r,i){let a=Cl(t),o=wl(r,i),s=e.some(e=>e.type===`image`||e.type===`video`||e.type===`map`||e.type===`mermaid`),c=a?.unconsumedMedia===`retain-native-layout`||a?.unconsumedMedia===`reserve-when-no-native-media`&&s;if(a?.additionalMediaLayout===`overlay-inset`&&c)return{layers:e,mediaRect:Ol(n,o),framed:!0};let l=a?.unconsumedMedia===`reserved-slot`||a?.unconsumedMedia===`reserve-when-no-native-media`&&!s;if(!a||!l||!a.variants)return{layers:e,mediaRect:zl(e,n),framed:!1};let u=_(n),d=kl(a.variants[u][o],n);return{layers:Fl(e,d.contentRect,n,d.fontScale,t??``),mediaRect:d.mediaRect,framed:!0}}function Vl(e,t={}){return Hl(e,t,{registry:t.customTemplates&&t.customTemplates.length>0?Hc(t.customTemplates):Vc})}function Hl(e,t,n){let r=t.theme??A,i=t.viewport??f.landscape,a=t.blockIndex??0,o=t.totalBlocks??1,c=t.persistentLayers===!1?void 0:t.persistentLayers??r.persistentLayers,l=e.layers;if(l&&l.length>0&&!u(e))return{layers:$l(Xl(s(l),e,r,i),e,r,c,n.expandedPersistentLayers),source:`authored`};if(!u(e)){let t=Xl([],e,r,i);return{layers:$l(t,e,r,c,n.expandedPersistentLayers),source:t.length>0?`rich-content`:`empty`}}let d=n.templateContext?s(n.templateContext):p(r,a,o,i);d.block=s(e);let m=Zl(e,d,n.registry);if(m.status===`ok`)return{layers:$l(Xl(n.applyRenderStyle===!1?m.layers:Jc(m.layers,e,r),e,r,i),e,r,c,n.expandedPersistentLayers),source:`template`};let h=Ql(e.template,m);if((t.failureMode??`fallback`)===`empty`){let t=Xl([],e,r,i);return{layers:$l(t,e,r,c,n.expandedPersistentLayers),source:t.length>0?`rich-content`:`empty`,diagnostic:h}}return{layers:$l(Xl(_l(e,d,h.message),e,r,i),e,r,c,n.expandedPersistentLayers),source:`fallback`,diagnostic:h}}function Ul(e){return(e.contents??[]).filter(e=>e.type===`code`&&e.lang?.trim().toLowerCase()===`mermaid`).map(e=>e.value).filter(e=>e.trim().length>0)}function Wl(e){let t=e.template?j(e.template):void 0,n=(e.contents??[]).filter(e=>e.type===`code`),r=[];for(let e of n){if(t!==`diagram`&&sn(e.lang)){let t=ln(e.value,{explicit:cn(e.lang)});if(t.isDiagram&&t.diagram){r.push({kind:`spatial`,template:`diagram`,data:_a(t.diagram),aspectRatio:16/9});continue}}if(t!==`tree`&&Yr(e.lang)){let t=Zr(e.value,{explicit:Xr(e.lang)});if(t.isTree&&t.tree){r.push({kind:`spatial`,template:`tree`,data:Ta(t.tree),aspectRatio:3/4});continue}}if(t!==`timeline`&&xr(e.lang)){let t=Cr(e.value,{explicit:Sr(e.lang)});t.isTimeline&&t.timeline&&r.push({kind:`spatial`,template:`timeline`,data:Ca(t.timeline),aspectRatio:16/9})}}return r}function Gl(e,t){let n=new Set(e.filter(e=>e.type===`image`).map(e=>e.content.src)),r=new Set(e.filter(e=>e.type===`video`).map(e=>e.content.src)),i=new Set(e.filter(e=>e.type===`mermaid`).map(e=>e.content.source)),a=Ha(t.contents),o=a.filter(e=>!r.has(e.src)),s=new Set(a.map(e=>e.src)),c=new Set(n),l=Ba(t.contents).filter(e=>s.has(e.src)||c.has(e.src)?!1:(c.add(e.src),!0)),u=Ul(t).filter(e=>!i.has(e));return[...l.map(e=>({kind:`image`,src:e.src,alt:e.alt,...e.width&&e.height?{aspectRatio:e.width/e.height}:{}})),...o.map(e=>({kind:`video`,src:e.src,...e.posterSrc?{posterSrc:e.posterSrc}:{},alt:e.alt,aspectRatio:16/9,...e.startAt==null?{}:{startAt:e.startAt},...e.clipStart==null?{}:{clipStart:e.clipStart},...e.clipEnd==null?{}:{clipEnd:e.clipEnd}})),...u.map(e=>({kind:`mermaid`,source:e,aspectRatio:16/9})),...Wl(t)]}function Kl(e,t,n,r){let i=Math.min(n.width,n.height),a=r?i*.025:0,o=t>1?i*.018:0,s={x:e.x+a,y:e.y+a,width:Math.max(0,e.width-a*2),height:Math.max(0,e.height-a*2)},c=Math.min(t,Math.max(1,Math.ceil(Math.sqrt(t*(s.width/Math.max(1,s.height)))))),l=Math.ceil(t/c),u=(s.width-o*(c-1))/c,d=(s.height-o*(l-1))/l;return Array.from({length:t},(e,t)=>({x:s.x+t%c*(u+o),y:s.y+Math.floor(t/c)*(d+o),width:u,height:d}))}function ql(e,t){let n=t.imageTreatment;if(n===`none`)return;let r=n?{type:n,strength:e.style.imageTreatment?.strength}:e.style.imageTreatment;if(!(!r||r.type===`none`))return r.type===`duotone`&&!r.color?{...r,color:e.colors.primary}:r}function Jl(e,t,n,r,i){if(e.kind===`image`){let a=ql(r,n);return[{id:`${n.id}-embedded-image-${i}`,type:`image`,position:t,content:{src:e.src,alt:e.alt||n.title||`Embedded image`,fit:`contain`,...a?{treatment:a}:{}}}]}if(e.kind===`video`){let r=Math.max(0,e.clipStart??0);return[{id:`${n.id}-embedded-video-${i}`,type:`video`,position:t,content:{src:e.src,...e.posterSrc?{posterSrc:e.posterSrc}:{},alt:e.alt||n.title||`Embedded video`,fit:`contain`,clipStart:r,clipEnd:Math.max(r,e.clipEnd??r+Math.max(0,n.duration)),...e.startAt==null?{}:{startAt:Math.max(0,e.startAt)}}}]}if(e.kind===`mermaid`)return[{id:`${n.id}-mermaid-${i}`,type:`mermaid`,position:t,content:{source:e.source,background:r.colors.backgroundLight,foreground:r.colors.text,padding:Math.max(12,Math.round(Math.min(t.width,t.height)*.025))}}];let a={width:t.width,height:t.height,name:`Embedded ${e.template}`},o=p(r,0,1,a);o.block=s(n);let c={id:`${n.id}-embedded-${e.template}-${i}`,duration:n.duration,audioSegment:n.audioSegment,...e.data};return Nl(e.template===`timeline`?Xo({...c,template:`timeline`},o):e.template===`tree`?Ho({...c,template:`tree`},o):zo({...c,template:`diagram`},o),a,t,`${n.id}-embedded-${e.template}-${i}`)}function Yl(e,t){let n=new Map(Ha(t.contents).filter(e=>e.startAt!=null||e.clipStart!=null||e.clipEnd!=null).map(e=>[e.src,e]));return n.size===0?e:e.map(e=>{if(e.type!==`video`)return e;let r=n.get(e.content.src);if(!r)return e;let i=Math.max(0,r.clipStart??e.content.clipStart);return{...e,content:{...e.content,clipStart:i,clipEnd:Math.max(i,r.clipEnd??(r.clipStart==null?e.content.clipEnd:i+Math.max(0,t.duration))),...r.startAt==null?{}:{startAt:Math.max(0,r.startAt)}}}})}function Xl(e,t,n,r){let i=Yl(e,t),a=Gl(i,t);if(a.length===0)return i;let o=Bl(i,t.template?j(t.template):void 0,r,a.length,a.map(e=>e.aspectRatio)),s=Kl(o.mediaRect,a.length,r,o.framed),c={image:0,video:0,mermaid:0,spatial:0},l=a.flatMap((e,r)=>(c[e.kind]+=1,Jl(e,s[r],t,n,c[e.kind]))),u=o.framed?{id:`${t.id}-rich-media-frame`,type:`shape`,position:o.mediaRect,content:{shape:`rect`,fill:n.colors.backgroundLight,stroke:C(n.colors.text,.14),strokeWidth:2,borderRadius:Math.max(12,Math.round(Math.min(r.width,r.height)*.018))}}:void 0;return[...o.layers,...u?[u]:[],...l]}function Zl(e,t,n){let r=s(e),i=s(t),a=r.children;(!i.children||i.children.length===0)&&a?.length&&(i.children=a);let o=n[j(r.template)];if(!o)return{status:`unknown-template`,layers:[]};let{templateData:c,templateOverrides:l}=r,u=r,d=u.sourceHeading?$a(r.template,u.title??``,u.contents):null,f=ll(r.template,l??{}).input,p=d||c||l?{...d,...r,...c,...f}:r,m=Object.prototype.hasOwnProperty.call(f,`quote`)?f.quote:Object.prototype.hasOwnProperty.call(c??{},`quote`)?c?.quote:Object.prototype.hasOwnProperty.call(r,`quote`)?r.quote:void 0;if(j(r.template)===`quote`&&d&&!Object.prototype.hasOwnProperty.call(d,`title`)&&!(typeof m==`string`&&m.trim())){let e=p;e.quote=d.quote,!Object.prototype.hasOwnProperty.call(c??{},`title`)&&!Object.prototype.hasOwnProperty.call(f,`title`)&&delete e.title}try{let e=o(p,i);return Array.isArray(e)?{status:`ok`,layers:s(e)}:{status:`invalid-result`,layers:[],receivedType:typeof e}}catch(e){return{status:`error`,layers:[],error:e}}}function Ql(e,t){return t.status===`unknown-template`?{code:`unknown-template`,template:e,message:`Unknown template "${e}"`}:t.status===`invalid-result`?{code:`invalid-template-result`,template:e,receivedType:t.receivedType,message:`Template "${e}" returned ${t.receivedType}, not a layer array`}:{code:`template-error`,template:e,cause:t.error,message:`Template "${e}" failed`}}function $l(e,t,n,r,i){return r?Di(e,t,i?.bottomLayers??wi(r.bottomLayers,n),i?.topLayers??wi(r.topLayers,n)):e}var eu={title:{label:`Title`,description:`A bold opening slide with large title text, perfect for covers and chapters.`},sectionHeader:{label:`Section Header`,description:`A clean section break with a prominent title and optional background image.`},bigText:{label:`Big Text`,description:`Gigantic uppercase display text — thumbnail-style — on a theme surface or over an image with a contrast bloom.`},content:{label:`Content`,description:`Shows a heading and the complete body in a loss-averse content-first layout.`},statHighlight:{label:`Stat Highlight`,description:`Showcases a single key number or metric with supporting context.`},quote:{label:`Quote`,description:`Displays a stylized pull quote with decorative marks and attribution.`},factCard:{label:`Fact Card`,description:`Presents a focused fact or insight with a labeled header and body text.`},twoColumn:{label:`Two Column`,description:`Divides the slide into two equal side-by-side content columns.`},dateEvent:{label:`Date Event`,description:`Highlights a date-based event or milestone with a prominent date display.`},imageWithCaption:{label:`Image with Caption`,description:`Displays a full-bleed image with an optional caption below.`},leftFeature:{label:`Left Feature`,description:`Image on the left, title and body text stacked on the right.`},rightFeature:{label:`Right Feature`,description:`Image on the right, title and body text stacked on the left.`},map:{label:`Map`,description:`Embeds an interactive map centered on a geographic location.`},fullBleedQuote:{label:`Full Bleed Quote`,description:`A full-width quote that spans the entire slide for maximum impact.`},list:{label:`List`,description:`Renders a bulleted or numbered list in a clean, card-style layout.`},photoGrid:{label:`Photo Grid`,description:`Arranges multiple photos in a 2×2 or 3×3 mosaic grid.`},definitionCard:{label:`Definition Card`,description:`Shows a term and its definition in a structured, dictionary-style card.`},comparisonBar:{label:`Comparison Bar`,description:`Visualizes two or more values side-by-side with labeled horizontal bars.`},pullQuote:{label:`Pull Quote`,description:`A stylized pull quote with large decorative marks and centered text.`},videoWithCaption:{label:`Video with Caption`,description:`Embeds a video player with an optional caption below.`},videoPullQuote:{label:`Video Pull Quote`,description:`Combines a video panel with a highlighted pull quote side-by-side.`},dataTable:{label:`Data Table`,description:`Renders tabular data in a clean, styled table with a header row.`},barChart:{label:`Bar Chart`,description:`Horizontal bars from the block's markdown table — one bar per row.`},columnChart:{label:`Column Chart`,description:`Vertical columns from the block's markdown table — one column per row.`},pieChart:{label:`Pie Chart`,description:`A pie of the block's markdown table — each row becomes a labeled slice.`},donutChart:{label:`Donut Chart`,description:`A donut of the block's markdown table — each row becomes a labeled slice.`},lineChart:{label:`Line Chart`,description:`Lines from the block's markdown table — one line per value column.`},areaChart:{label:`Area Chart`,description:`Filled area lines from the block's markdown table — one area per value column.`},scatterChart:{label:`Scatter Chart`,description:`An x/y scatter plot from the block's markdown table's numeric columns.`},diagram:{label:`Diagram`,description:`Renders sub-headings as connected nodes — edit visually as a node-and-edge diagram.`},tree:{label:`Tree`,description:`Renders an ASCII file-tree / outline fence as a filesystem-style treeview — edit as an outline.`},timeline:{label:`Timeline`,description:`Plots events across one or more horizontal tracks with callouts and optional branching links.`},layout:{label:`Layout`,description:`Free-form 2D canvas — drag layers into place. Use for one-off block layouts that don't fit a template.`},drawing:{label:`Drawing`,description:`Free-form sketches — draw shapes, paths, and text directly on a 2D surface.`}},tu={title:{role:`opener`,bodyPolicy:`ignored`,safeForContentFirst:!1,placement:`heading`},sectionHeader:{role:`divider`,bodyPolicy:`ignored`,safeForContentFirst:!1,placement:`heading`},bigText:{role:`opener`,bodyPolicy:`ignored`,safeForContentFirst:!1,placement:`heading`},content:{role:`content`,bodyPolicy:`complete`,safeForContentFirst:!0,placement:`heading`},statHighlight:{role:`highlight`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},quote:{role:`quote`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},factCard:{role:`highlight`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},twoColumn:{role:`comparison`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},dateEvent:{role:`event`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},imageWithCaption:{role:`media`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},leftFeature:{role:`media`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},rightFeature:{role:`media`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},map:{role:`spatial`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},fullBleedQuote:{role:`quote`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},list:{role:`content`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},photoGrid:{role:`media`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},definitionCard:{role:`content`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},comparisonBar:{role:`comparison`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},pullQuote:{role:`quote`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},videoWithCaption:{role:`media`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},videoPullQuote:{role:`media`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},dataTable:{role:`data`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},barChart:{role:`data`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},columnChart:{role:`data`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},pieChart:{role:`data`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},donutChart:{role:`data`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},lineChart:{role:`data`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},areaChart:{role:`data`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},scatterChart:{role:`data`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},diagram:{role:`spatial`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},tree:{role:`spatial`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},timeline:{role:`spatial`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},drawing:{role:`spatial`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},layout:{role:`spatial`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`}},nu=120,ru=26,iu=62;function au(e){let t=e.trim().length;if(t<=ru)return nu;let n=nu*Math.sqrt(ru/t);return Math.max(iu,Math.round(n))}function ou(e){let{theme:t}=e;return t.id===`standard`&&x(t.colors.background)>.85}var su=[{pos:0,alpha:.95},{pos:38,alpha:.86},{pos:58,alpha:.4},{pos:78,alpha:.1},{pos:100,alpha:0}];function cu(e){return`linear-gradient(0deg, ${su.map(t=>`${C(e,t.alpha)} ${t.pos}%`).join(`, `)})`}function lu(e,t){let n=B(t,e.imageTreatment),{heroSrc:r,heroAlt:i,title:a,subtitle:o,ambientMotion:s,heroCredit:c,heroLicense:l}=e,{theme:u,layout:d}=t,f=!r&&ou(t),p=L(au(a),t,!0),m=L(40,t,!1),h=[];if(r){let e=Ui(s);h.push({type:`image`,id:`cover-hero`,content:{src:r,alt:i||a,fit:`cover`,credit:c,license:l,...n?{treatment:n}:{}},position:{x:0,y:0,width:`100%`,height:`100%`},animation:e},{type:`shape`,id:`cover-gradient`,content:{shape:`rect`,fill:cu(u.colors.background)},position:{x:0,y:0,width:`100%`,height:`100%`}})}else f?h.push({type:`shape`,id:`cover-bg`,content:{shape:`rect`,fill:u.colors.background},position:{x:0,y:0,width:`100%`,height:`100%`}},{type:`shape`,id:`cover-bg-tint`,content:{shape:`rect`,fill:`radial-gradient(ellipse at 50% 40%, ${C(u.colors.primary,.16)} 0%, ${C(u.colors.primary,.07)} 38%, ${C(u.colors.primary,0)} 78%)`},position:{x:0,y:0,width:`100%`,height:`100%`}}):h.push({type:`shape`,id:`cover-bg`,content:{shape:`rect`,fill:`radial-gradient(ellipse at 50% 40%, ${u.colors.primary} 0%, ${u.colors.background} 100%)`},position:{x:0,y:0,width:`100%`,height:`100%`}}),h.push({type:`shape`,id:`cover-accent`,content:{shape:`rect`,fill:f?C(u.colors.primary,.24):`rgba(255, 255, 255, 0.2)`},position:{x:`35%`,y:o?`42%`:`58%`,width:`30%`,height:`2px`}});return h.push({type:`text`,id:`cover-title`,content:{text:a,style:{fontSize:p,fontFamily:I(t,`title`),fontWeight:`bold`,color:u.colors.text,textAlign:`center`,shadow:!f}},position:{x:`50%`,y:r?o?`70%`:`75%`:o?d.primaryY:`50%`,anchor:`center`,width:d.maxTextWidth},animation:{type:`fadeIn`,duration:.8}}),o&&h.push({type:`text`,id:`cover-subtitle`,content:{text:o,style:{fontSize:m,fontFamily:I(t,`body`),fontWeight:f?`bold`:`normal`,color:f?C(u.colors.text,.78):u.colors.textMuted,textAlign:`center`,lineHeight:1.5}},position:{x:`50%`,y:r?`82%`:d.secondaryY,anchor:`center`,width:d.maxTextWidth},animation:{type:`fadeIn`,duration:.8,delay:.2}}),h}function uu(e){return{heroSrc:e.heroSrc,heroAlt:e.heroAlt,title:e.title,subtitle:e.subtitle,ambientMotion:e.ambientMotion,heroCredit:e.heroCredit,heroLicense:e.heroLicense}}function du(e,t,n=`cover`){let r=uu(e),i={id:`cover-block`,duration:0,audioSegment:-1};if(n===`title`)return Bi({...i,template:`title`,title:r.title,subtitle:r.subtitle},t);if(n===`sectionHeader`)return ea({...i,template:`sectionHeader`,title:r.title,imageSrc:r.heroSrc,imageAlt:r.heroAlt,ambientMotion:r.ambientMotion},t);if(n===`bigText`||n===`bigTextImage`){let e=n===`bigTextImage`&&!!r.heroSrc;return la({...i,template:`bigText`,title:r.title,...e?{imageSrc:r.heroSrc,imageAlt:r.heroAlt??r.title,ambientMotion:r.ambientMotion}:{}},t)}return n===`imageWithCaption`?r.heroSrc?fo({...i,template:`imageWithCaption`,imageSrc:r.heroSrc,imageAlt:r.heroAlt??r.title,caption:r.title,subtitle:r.subtitle,ambientMotion:r.ambientMotion,imageCredit:r.heroCredit,imageLicense:r.heroLicense,isTitle:!0},t):Bi({...i,template:`title`,title:r.title,subtitle:r.subtitle},t):lu(r,t)}function fu(e,t,n,r,i,a,o,c,l,d){let f=Hl(e,{theme:r,viewport:i,persistentLayers:a??!1,blockIndex:t,totalBlocks:n,failureMode:l},{registry:c,expandedPersistentLayers:o});f.diagnostic&&d?.(f.diagnostic,e,t);let p=u(e)?{id:e.id,startTime:0,duration:e.duration,audioSegment:e.audioSegment,...f.layers.length>0?{layers:f.layers}:{},transition:e.transition,template:e.template}:{...s(e),...f.layers.length>0?{layers:f.layers}:{}},m=v(p,r,t);return m!==p.transition&&(p.transition=m),p}function pu(e,t={}){let n=t,r=n.theme??A,i=n.viewport??f.landscape,{persistentLayers:a,audioSegments:o,customTemplates:c,failureMode:l=`fallback`,onDiagnostic:u,splitLongBlocks:d=!0,mergeShortBlocks:p=!0}=n,m=e.length,h=c&&c.length>0?Hc(c):Vc,g=a===!1?void 0:a??r.persistentLayers,_=g?{bottomLayers:wi(g.bottomLayers,r),topLayers:wi(g.topLayers,r)}:void 0;if(!o||o.length===0){let t=0;return e.map((e,n)=>{let a=fu(e,n,m,r,i,g,_,h,l,u);return a.startTime=t,t+=a.duration,a})}let v=new Map;e.forEach((e,t)=>{let n=e.audioSegment??0;v.has(n)||v.set(n,[]),v.get(n).push({block:e,originalIndex:t})});let y=Array(e.length);for(let[e,t]of v){let n=o[e];if(!n){let e=0;for(let{block:n,originalIndex:a}of t){let t=fu(n,a,m,r,i,g,_,h,l,u);t.startTime=e,e+=t.duration,y[a]=t}continue}let a=[],c=[];for(let e of t)e.block.template===`sectionHeader`?a.push(e):c.push(e);let f=a.reduce((e,{block:t})=>e+(t.duration??0),0),v=c.reduce((e,{block:t})=>e+(t.duration??0),0),b=n.duration-f,x=v>0&&b>0?b/v:1,S=[];for(let{block:e,originalIndex:n}of t){let t=fu(e,n,m,r,i,g,_,h,l,u),a=e;S.push({block:t,originalIndex:n,templateBlock:a,hasSourceTiming:typeof a.sourceStartTime==`number`})}let C=S.some(e=>e.hasSourceTiming);S.sort((e,t)=>{if(C){let n=e.templateBlock.template===`sectionHeader`,r=t.templateBlock.template===`sectionHeader`;if(n&&!r)return-1;if(!n&&r)return 1;if(e.hasSourceTiming&&t.hasSourceTiming)return e.templateBlock.sourceStartTime-t.templateBlock.sourceStartTime;if(e.hasSourceTiming&&!t.hasSourceTiming)return-1;if(!e.hasSourceTiming&&t.hasSourceTiming)return 1}return e.originalIndex-t.originalIndex});let w=0;for(let e=0;e<S.length;e++){let t=S[e],{block:r,templateBlock:i}=t;if(t.hasSourceTiming){let e=i.sourceStartTime;r.startTime=n.startTime+e,typeof i.sourceDuration==`number`&&(r.duration=Math.max(5,i.sourceDuration)),w=e+r.duration}else if(i.template===`sectionHeader`)r.startTime=n.startTime+w,w+=r.duration;else{r.startTime=n.startTime+w;let e=r.duration*x;r.duration=e,w+=e}y[t.originalIndex]=r}let T=S.map(e=>y[e.originalIndex]).sort((e,t)=>e.startTime-t.startTime);for(let e=0;e<T.length-1;e++){let t=T[e],n=T[e+1],r=t.startTime+t.duration;r>n.startTime?t.duration=n.startTime-t.startTime:r<n.startTime-.5&&(t.duration=Math.max(.1,n.startTime-t.startTime))}let E=n.startTime+n.duration;for(;T.length>1;){let e=T[T.length-1],t=E-e.startTime;if(p&&t<5&&e.template!==`sectionHeader`){let t=T[T.length-2];t.duration=E-t.startTime,e.duration=0,e.startTime=E,T.pop()}else{e.startTime+e.duration<E&&(e.duration=E-e.startTime);break}}if(T.length===1){let e=T[0];e.startTime+e.duration<E&&(e.duration=E-e.startTime)}let D=p;for(;D;){D=!1;for(let e=T.length-1;e>=1;e--){let t=T[e];if(t.duration>0&&t.duration<5){let n=T[e-1];n.duration=t.startTime+t.duration-n.startTime,t.duration=0,t.startTime=E,T.splice(e,1),D=!0;break}}}if(d)for(let e=0;e<T.length;e++){let t=T[e];if(t.duration>20){let e=Math.ceil(t.duration/20),n=t.duration/e;if(n>=5){t.duration=n;for(let r=1;r<e;r++){let e={id:`${t.id}-split-${r}`,startTime:t.startTime+r*n,duration:n,audioSegment:t.audioSegment,layers:(t.layers??[]).map(e=>({...s(e),id:`${e.id}-split-${r}`})),transition:{type:`dissolve`,duration:1},template:t.template};y.push(e)}}}}}return p?y.filter(e=>e&&e.duration>0):y.filter(Boolean)}function mu(){return Object.keys(Vc)}function hu(e){return j(e)in Vc}var gu={width:1920,height:1080},_u={label:`lb`,description:`ds`,viewport:`vp`,layers:`ly`,name:`nm`,type:`ty`,position:`po`,content:`ct`,animation:`am`,width:`wd`,height:`hg`,anchor:`an`,text:`tx`,style:`sy`,fontSize:`fz`,fontFamily:`ff`,fontWeight:`fw`,color:`cl`,textAlign:`al`,verticalAlign:`vl`,lineHeight:`lh`,shadow:`sd`,background:`bg`,backgroundOpacity:`bo`,backgroundGradient:`bj`,borderColor:`bc`,borderWidth:`bw`,borderStyle:`bs`,padding:`pd`,maxLines:`mx`,shape:`sp`,fill:`fl`,fillOpacity:`fo`,gradient:`gr`,stroke:`sk`,strokeWidth:`sw`,borderRadius:`br`,shapeKind:`kd`,dasharray:`da`,arrow:`ar`,startMarker:`st`,endMarker:`em`,src:`sc`,alt:`at`,fit:`ft`,credit:`cr`,license:`lc`,from:`fr`,angle:`ag`},vu=Object.fromEntries(Object.entries(_u).map(([e,t])=>[t,e]));function yu(e,t){if(Array.isArray(e))return e.map(e=>yu(e,t));if(e&&typeof e==`object`){let n={};for(let[r,i]of Object.entries(e))n[t[r]??r]=yu(i,t);return n}return e}function bu(e){return!e||e.width===gu.width&&e.height===gu.height}function xu(e){if(!e)return;let t=Eu(e[E]);if(!t)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let t=e,r={name:t.name,label:t.label,viewport:t.viewport??{...gu},layers:t.layers};t.description!==void 0&&(r.description=t.description);let i=y(r);i.template&&n.push(i.template)}return n.length>0?n:void 0}function Su(e,t){if(!e||e.length===0)return;let n={};for(let t of e){let e={lb:t.label};t.description&&(e.ds=t.description),bu(t.viewport)||(e.vp=t.viewport),e.ly=yu(t.layers,_u),n[t.name]=e}return JSON.stringify(n,null,t?.pretty?2:void 0)}function Cu(e){return Object.entries(e).map(([e,t])=>{let n=t&&typeof t==`object`?t:{},r={name:e,label:n.lb,viewport:n.vp??{...gu},layers:yu(n.ly??[],vu)};return typeof n.ds==`string`&&(r.description=n.ds),r})}function wu(e){return Array.isArray(e)?e:e&&typeof e==`object`?Cu(e):null}function Tu(e){try{return JSON.parse(e)}catch{return}}function Eu(e){if(e==null)return null;if(Array.isArray(e))return e;if(typeof e==`object`)return Cu(e);if(typeof e!=`string`)return null;let t=Tu(e.trim());if(t!==void 0)return wu(t);try{let t=Tu(Ge(e));if(t!==void 0)return wu(t)}catch{}return null}function Du(e){if(e==null)return;let t=e;if(typeof t==`string`){let e=t.trim();if(!e)return;try{t=JSON.parse(e)}catch{return}}if(Array.isArray(t))return t;if(t&&typeof t==`object`)return Object.values(t)}function Ou(e){if(!e)return;let t=Du(e[k]);if(!t)return;let n=[];for(let e of t){let t=D(e);t.valid&&t.theme&&n.push(t.theme)}return n.length>0?n:void 0}function ku(e,t){if(!e||e.length===0)return;let n={};for(let t of e)n[t.id]=t;return JSON.stringify(n,null,t?.pretty?2:void 0)}var Au=new Set([`json`,`yaml`,`yml`]);function ju(e){if(!e.lang||!Au.has(e.lang.toLowerCase()))return!1;let t=e.meta??``;return/\bdata\b/.test(t)}function Mu(e){if(e.lang?.toLowerCase()===`json`)try{let t=JSON.parse(e.value);return typeof t!=`object`||!t||Array.isArray(t)?{error:`JSON data fence must contain a top-level object ({"key": …})`}:{data:t}}catch(e){return{error:`invalid JSON: ${e instanceof Error?e.message:String(e)}`}}try{return{data:Lu(e.value)}}catch(e){return{error:`invalid YAML: ${e instanceof Error?e.message:String(e)}`}}}function Nu(e,t){let n=JSON.stringify(t,null,2),r=e.findIndex(e=>e.type===`code`&&ju(e));if(r<0){let t={type:`code`,lang:`json`,meta:`data`,value:n};return[...e,t]}let i=[...e];return i[r]={...e[r],value:n},i}function Pu(e){let t=e.trim();if(t.length>=2){let e=t[0];if((e===`"`||e===`'`)&&t.endsWith(e))return t.slice(1,-1)}return t===`true`?!0:t===`false`?!1:t===`null`||t===`~`?null:t!==``&&!isNaN(Number(t))?Number(t):t}function Fu(e){let t=[],n=``,r=null;for(let i of e)r?(n+=i,i===r&&(r=null)):i===`"`||i===`'`?(r=i,n+=i):i===`,`?(t.push(n),n=``):n+=i;return t.push(n),t.map(e=>e.trim()).filter(e=>e!==``)}function Iu(e){let t=e.trim();return t.startsWith(`[`)&&t.endsWith(`]`)?Fu(t.slice(1,-1)).map(Pu):Pu(t)}function Lu(e){let t={},n=e.split(`
|
|
26
|
-
`),r=null,i=null,a=-1;for(let e=0;e<n.length;e++){let o=n[e],s=o.trim();if(!s||s.startsWith(`#`))continue;let c=o.length-o.trimStart().length;if(c>0){if(!r)throw Error(`line ${e+1}: unexpected indented line without a preceding "key:" line`);if(a<0&&(a=c),c>a)throw Error(`line ${e+1}: nesting deeper than one level is not supported \u2014 use a \`\`\`json data fence for nested input`);if(s.startsWith(`- `)){if(i===`map`)throw Error(`line ${e+1}: cannot mix list items and mapping keys under "${r}"`);i=`list`,t[r].push(Iu(s.slice(2)));continue}if(i===`list`)throw Error(`line ${e+1}: cannot mix mapping keys and list items under "${r}"`);let n=s.indexOf(`:`);if(n<1)throw Error(`line ${e+1}: expected "key: value"`);let o=s.slice(n+1).trim();if(o===``)throw Error(`line ${e+1}: nesting deeper than one level is not supported \u2014 use a \`\`\`json data fence for nested input`);i!==`map`&&(i=`map`,t[r]={}),t[r][s.slice(0,n).trim()]=Iu(o);continue}r=null,i=null,a=-1;let l=s.indexOf(`:`);if(l<1)throw Error(`line ${e+1}: expected "key: value"`);let u=s.slice(0,l).trim(),d=s.slice(l+1).trim();d===``?(t[u]=[],r=u):t[u]=Iu(d)}return t}function Ru(e){return e?.find(e=>e.type===`table`)}function zu(e){let t=e=>e.children.map(e=>o(e).trim()),[n,...r]=e.children;return{headers:n?t(n):[],rows:r.map(t),...e.align&&e.align.some(e=>e!=null)?{align:e.align}:{}}}function Bu(e){let t=fe(e.trim()),n=t.length>0&&t[0].indexOf(`=`)>0,r=n||t.length===0?void 0:t[0],i=+!n,a={};for(let e=i;e<t.length;e++){let n=de(t[e]);n&&(a[n.key]=n.value)}return{template:r,params:a}}function Vu(e){if(e.type!==`paragraph`)return null;let t=e.children??[];if(t.length!==1||t[0].type!==`text`)return null;let n=ge(t[0].value.trim());return!n||n.index!==0?null:Bu(n.inner)}var Hu=new Set([`audio`,`video`,`media`]);function Uu(e){return e!=null&&Hu.has(e)}function Wu(e){return e==null?null:he(e)}function Gu(e){let t=e.placement??e.presentation;if(t===`content`)return`content`;if(t===`pip`||t===`picture-in-picture`)return`picture-in-picture`;if(t===`overlay`||t===`full-frame`)return`overlay`;if(e.pip===``||e.pip===`true`)return`picture-in-picture`;if(e.overlay===``||e.overlay===`true`)return`overlay`}function Ku(e){return e!==`false`&&e!==`0`}function qu(e){return e===`small`||e===`large`?e:void 0}function Ju(e){return e===`square`||e===`wide`?e:void 0}function Yu(e){return e===`top-left`||e===`top-right`||e===`bottom-left`||e===`bottom-right`?e:void 0}function Xu(e,t){let{template:n,params:r}=e;if(!n||!Hu.has(n))return null;let i=r.src;if(!i)return null;let a=n===`video`?`video`:`audio`,o=r.anchor===`document`||r.span===`document`?`document`:`block`,s={id:t,src:i,kind:a,startAt:Wu(r.startAt??r.startTime)??0,anchor:o},c=a===`video`?Gu(r):void 0;c&&c!==`content`&&(s.placement=c);let l=qu(r.pipSize),u=Ju(r.pipShape),d=Yu(r.pipPosition);if(l&&(s.pipSize=l),u&&(s.pipShape=u),d&&(s.pipPosition=d),a===`video`&&c&&c!==`content`&&r.lockToBlock!=null){let e=Ku(r.lockToBlock);s.lockToBlock=e,s.anchor=e?`block`:`document`,e&&(s.startAt=0)}let f=Wu(r.clipStart),p=Wu(r.clipEnd);return f!=null&&(s.clipStart=f),p!=null&&(s.clipEnd=p),s.lockToBlock===!0&&delete s.clipEnd,(r.spillover===`true`||r.spillover===``)&&(s.spillover=!0),s}function Zu(e){let t=e=>{for(let n of e){if(n.type!==`htmlElement`)continue;if(n.tagName===`video`)return n;let e=t(n.children);if(e)return e}return null};return t(e)}function Qu(e){if(e.type===`htmlBlock`){if(!/^\s*<video\b/i.test(e.rawHtml))return null;let t=Zu(e.htmlChildren);return t?{element:t,raw:e.rawHtml.trim()}:null}if(e.type!==`paragraph`||!e.children.every(e=>e.type===`htmlInline`))return null;let t=e.children.map(e=>e.type===`htmlInline`?e.rawHtml:``).join(``);if(!/^\s*<video\b[\s\S]*<\/video>\s*$/i.test(t))return null;for(let n of e.children){if(n.type!==`htmlInline`)continue;let e=Zu(n.htmlChildren);if(e)return{element:e,raw:t.trim()}}return null}function $u(e,t){let n=Qu(e);if(!n)return null;let{element:r}=n,i=Gu({placement:r.attributes[`data-squisq-video-placement`]??``});if(!i||i===`content`)return null;let a=r.attributes.src;if(!a)return null;let o=Ku(r.attributes[`data-squisq-video-lock-to-block`]),s={id:t,src:a,kind:`video`,placement:i,lockToBlock:o,startAt:o?0:Wu(r.attributes[`data-squisq-video-start-at`])??0,anchor:o?`block`:`document`},c=qu(r.attributes[`data-squisq-video-pip-size`]),l=Ju(r.attributes[`data-squisq-video-pip-shape`]),u=Yu(r.attributes[`data-squisq-video-pip-position`]);c&&(s.pipSize=c),l&&(s.pipShape=l),u&&(s.pipPosition=u);let d=Wu(r.attributes[`data-squisq-video-clip-start`]),f=Wu(r.attributes[`data-squisq-video-clip-end`]);return d!=null&&(s.clipStart=d),!o&&f!=null&&(s.clipEnd=f),s}function ed(e,t,n){let r=[],i=[],a=[],o=0,s=0;for(let c of e??[]){let e=Vu(c),l=e?Xu(e,``):$u(c,``);if(l){l.id=t(l.src,o++);let e=c.position?.start.line;if(e!=null&&(l.sourceLine=e),n!==void 0){let e=Qu(c),t=c.type===`paragraph`&&c.children?.[0]?.type===`text`?c.children[0].value.trim():e?.raw;l.origin={blockId:n,index:s,...t===void 0?{}:{raw:t},...e?{format:`html`}:{}}}(l.anchor===`document`?i:r).push(l)}else a.push(c);s++}return{media:r,documentMedia:i,remaining:a}}function td(e,t){t.x!=null&&(e.x=t.x),t.y!=null&&(e.y=t.y),t.startTime!=null&&(e.startTime=t.startTime),t.duration!=null&&(e.duration=t.duration),t.connectsTo&&(e.connectsTo=t.connectsTo),t.transition&&(e.transition=t.transition)}function nd(e,t){let n=e.template,r=e.params,i=Object.keys(r).length>0,a={id:t.makeId(e),startTime:0,duration:t.defaultDuration,audioSegment:0,template:j(n),standaloneAnnotation:!0,sourceAnnotation:{template:n,...i?{params:r}:{}},...r.title?{title:r.title}:{}};return i&&(a.templateOverrides=r,td(a,ce(r).blockMeta)),a}function rd(e,t){let n=[],r=[],i=null;for(let a of e??[]){let e=Vu(a);if(e!=null&&e.template!=null&&!Uu(e.template)){let n=nd(e,t);r.push(n),i=n}else i?(i.contents??=[]).push(a):n.push(a)}return{leading:n,blocks:r}}function id(e){if(e.type!==`paragraph`)return null;let t=e.children;if(t.length===0)return null;let n=t[t.length-1];return n.type===`text`?n.value:null}function ad(e){if(Vu(e)?.template)return!0;let t=id(e);if(t==null)return!1;let n=ge(t);return!!n&&n.index>0&&!!Bu(n.inner).template}function od(e,t,n){let r=[...e],i=r[t];if(i.type!==`paragraph`)return r;let a=[...i.children],o=a[a.length-1];if(o.type!==`text`)return r;let s=o.value.slice(0,n);return s.length===0&&a.length===1?r.splice(t,1):(a[a.length-1]={...o,value:s},r[t]={...i,children:a}),r}function sd(e){if(!e||e.length===0)return null;let t=e.length-1,n=e[t],r=null,i=null,a=Vu(n);if(a?.template&&n.type===`paragraph`){let o=n.children[0];r={template:a.template,params:a.params,origin:{kind:`paragraph`,index:t,raw:o&&o.type===`text`?o.value.trim():``}},i=e.slice(0,t)}else{let a=id(n),o=a==null?null:ge(a);if(a!=null&&o&&o.index>0){let n=Bu(o.inner);n.template&&(r={template:n.template,params:n.params,origin:{kind:`trailing`,index:t,suffix:a.slice(o.index)}},i=od(e,t,o.index))}}if(!r||!i)return null;for(let n=0;n<t;n++)if(ad(e[n]))return null;return{data:r,strippedContents:i}}var cd=/[^\w\s-]/g,ld=/[\s_]+/g,ud=/-+/g,dd=/^-|-$/g;function fd(e){return e.toLowerCase().replace(cd,``).replace(ld,`-`).replace(ud,`-`).replace(dd,``)||`block`}function pd(){let e=new Map,t=(t,n)=>{let r=fd(o(t)),i=e.get(r)??0;return e.set(r,i+1),i===0?r:`${r}-${i+1}`};return t.reserve=t=>{e.set(t,Math.max(e.get(t)??0,1))},t.fromText=t=>{let n=fd(t),r=e.get(n)??0;return e.set(n,r+1),r===0?n:`${n}-${r+1}`},t}function md(e,t){t.x!=null&&(e.x=t.x),t.y!=null&&(e.y=t.y),t.startTime!=null&&(e.startTime=t.startTime),t.duration!=null&&(e.duration=t.duration),t.connectsTo&&(e.connectsTo=t.connectsTo),t.transition&&(e.transition=t.transition)}function hd(e){if(!e)return{};let t=e.templateAnnotation?.params?ce(e.templateAnnotation.params).blockMeta:{},n=e.attributes?.blockMeta??{};return{...t,...n}}function gd(e){return e.promotedBodyAnnotation?.params?ce(e.promotedBodyAnnotation.params).blockMeta:e.sourceHeading?hd(e.sourceHeading):e.sourceAnnotation?.params?ce(e.sourceAnnotation.params).blockMeta:{}}function _d(e){return gd(e)}function vd(e){for(let t of e){if(!t.sourceHeading||t.sourceHeading.templateAnnotation?.template)continue;let e=sd(t.contents);if(!e)continue;let{template:n,params:r}=e.data;Uu(n)||!hu(n)||(t.template=j(n),Object.keys(r).length>0&&(t.templateOverrides=r,md(t,ce(r).blockMeta)),t.contents=e.strippedContents,t.promotedBodyAnnotation=e.data)}}function yd(e,t,n){let r=[];for(let i of e){i.children&&i.children.length>0&&(i.children=yd(i.children,t,n));let{leading:e,blocks:a}=rd(i.contents,{makeId:t,defaultDuration:n});if(a.length===0){r.push(i);continue}i.contents=e,(i.children?.length??0)>0&&!se(i.template)?(i.children=[...a,...i.children],r.push(i)):r.push(i,...a)}return r}function bd(e,t){let r=t?.articleId??`markdown-doc`,i=t?.defaultTemplate??`sectionHeader`,a=t?.defaultDuration??5,s=t?.generateId?null:pd(),c=t?.generateId??s,l=[],u=[],d=0,f=[],p=[],m=null;function h(){m&&p.length>0&&(m.contents=(m.contents??[]).concat(p),p=[])}function g(e){let t=e?.attributes?.id,n=t||(e?c(e,d++):`preamble`);t&&s&&s.reserve(t);let r=e?.templateAnnotation,l=r?.template??(e?i:void 0),u=l==null?void 0:j(l),f=e?o(e):void 0,p={id:n,startTime:0,duration:a,audioSegment:0,template:u,...e?{sourceHeading:e}:{},...f?{title:f}:{}};r?.params&&(p.templateOverrides=r.params,md(p,ce(r.params).blockMeta));let m=e?.attributes;return m&&(m.blockMeta&&md(p,m.blockMeta),m.classes&&m.classes.length>0&&(p.classes=m.classes),m.metadata&&Object.keys(m.metadata).length>0&&(p.metadata=m.metadata)),p}for(let t of e.children)if(t.type===`heading`){let e=t,n=e.depth;h();let r=g(e);if(f.length===0)m&&!m.sourceHeading&&l.push(m),l.push(r),f.push({block:r,depth:n});else{for(;f.length>0&&f[f.length-1].depth>=n;)f.pop();if(f.length===0)l.push(r),f.push({block:r,depth:n});else{let e=f[f.length-1].block;e.children||=[],e.children.push(r),f.push({block:r,depth:n})}}m=r}else m||=g(null),p.push(t);h(),m&&!m.sourceHeading&&!l.includes(m)&&l.push(m);let _=[];for(let e of xd(l)){let{media:t,documentMedia:n,remaining:r}=ed(e.contents,(t,n)=>`${e.id}-media-${n}-${t.replace(/[^a-zA-Z0-9]+/g,`-`)}`,e.id);t.length>0&&(e.media=t),n.length>0&&_.push(...n),e.contents&&=r}l.length>0&&!l[0].sourceHeading&&(l[0].contents?.length??0)===0&&(l[0].children?.length??0)===0&&!l[0].media&&l.shift(),vd(xd(l)),l=yd(l,e=>{let t=e.params.title??e.template??`block`;return s?s.fromText(t):fd(t)},a),l.length>0&&!l[0].sourceHeading&&!l[0].standaloneAnnotation&&(l[0].contents?.length??0)===0&&(l[0].children?.length??0)===0&&!l[0].media&&l.shift();let v=xd(l);for(let e of v)Ed(e,u);for(let e of v)Dd(e,u),kd(e,u),Od(e,u);(t?.autoTemplates??!0)&&!jd(e)&&Md(l,j(i),{featureIndex:0});for(let e of v)Ad(e,u);let y=new Map;for(let e of v)y.has(e.id)?u.push({severity:`error`,code:`duplicate-id`,message:`Duplicate block id "${e.id}" \u2014 later connections and links are ambiguous`,blockId:e.id,...Td(e)}):y.set(e.id,e);for(let e of v)for(let t of e.connectsTo??[])y.has(t.target)||u.push({severity:`warning`,code:`unresolved-connection`,message:`Block "${e.id}" connects to unknown target "${t.target}"`,blockId:e.id,...Td(e)});let b=[];for(let e of v){if(gd(e).duration!=null)continue;let t=Nd(e);if(t.length>0){let n=fi(t);e.duration=Math.max(3,n.seconds)}else e.duration=a}let x=0;for(let e of v){gd(e).startTime??(e.startTime=x);let t=Nd(e);if(t.length>0){let n=Fd(t);if(n.length>0){let t=e.duration/n.length;for(let e=0;e<n.length;e++)b.push({text:n[e],startTime:x+e*t,endTime:x+(e+1)*t,audioSegment:0})}}x+=e.duration}let S=new Map(v.map(e=>[e.id,e]));for(let e of _)e.lockToBlock===!1&&e.origin?.format===`html`&&!/\bdata-squisq-video-start-at\s*=/i.test(e.origin.raw??``)&&(e.startAt=S.get(e.origin.blockId)?.startTime??0);let C=b.length>0?{phrases:b,...t?.captionsGeneratedAt?{generatedAt:t.captionsGeneratedAt}:{},version:1}:void 0,w=xu(e.frontmatter),T=Ou(e.frontmatter),E=n(e.frontmatter),D={articleId:r,duration:x,blocks:l,audio:{segments:[]},...C?{captions:C}:{},...e.frontmatter?{frontmatter:e.frontmatter}:{},...E?{themeId:E}:{},...w?{customTemplates:w}:{},...T?{customThemes:T}:{},...u.length>0?{diagnostics:u}:{},..._.length>0?{documentMedia:_}:{}};if(t?.generateCoverBlock??!0){let n=Bd(e,l,t?.fileName);n&&(D.startBlock=n)}return D}function xd(e){let t=[];for(let n of e)t.push(n),n.children&&t.push(...xd(n.children));return t}function Sd(e){let t=[];for(let n of e)t.push(n),n.children&&!se(n.template)&&t.push(...Sd(n.children));return t}function Cd(e){let t=0;for(let n of e)t+=1,n.children&&(t+=Cd(n.children));return t}function wd(e){return e.sourceHeading?.depth??0}function Td(e){let t=e.sourceHeading?.position?.start.line;return t==null?{}:{line:t}}function Ed(e,t){let n;for(let r of e.contents??[]){if(r.type!==`code`||!ju(r))continue;let i=Mu(r);if(i.error){t.push({severity:`error`,code:`data-fence-parse`,message:`Data fence in block "${e.id}": ${i.error}`,blockId:e.id,...r.position?{line:r.position.start.line}:Td(e)});continue}n={...n,...i.data}}if(ve.has(j(e.template??``))){let t=t=>n&&t in n||e.templateOverrides&&t in e.templateOverrides;if(!t(`headers`)&&!t(`rows`)){let t=Ru(e.contents);t&&(n={...zu(t),...n})}}n&&Object.keys(n).length>0&&(e.templateData=n)}function Dd(e,t){if(j(e.template??``)!==`diagram`||e.children&&e.children.length>0||e.templateData&&`nodes`in e.templateData)return;let n=(e.contents??[]).filter(e=>e.type===`code`);if(n.length!==1||!sn(n[0].lang))return;let r=kt(n[0].value);if(r.nodes.length===0){t.push({severity:`warning`,code:`ascii-diagram-parse`,message:`Diagram block "${e.id}": code fence did not parse as an ASCII diagram`,blockId:e.id});return}let{nodes:i,edges:a}=_a(r);e.templateData={nodes:i,edges:a,...e.templateData}}function Od(e,t){if(j(e.template??``)!==`tree`||e.templateData&&`items`in e.templateData)return;let n=$a(`tree`,e.title??``,e.contents);if(!n||!Array.isArray(n.items)||n.items.length===0){t.push({severity:`warning`,code:`tree-parse`,message:`Tree block "${e.id}": body did not parse as a tree`,blockId:e.id});return}e.templateData={...n,...e.templateData}}function kd(e,t){if(j(e.template??``)!==`timeline`||e.templateData&&`tracks`in e.templateData)return;let n=$a(`timeline`,e.title??``,e.contents);if(!n||!Array.isArray(n.tracks)||n.tracks.length===0){t.push({severity:`warning`,code:`timeline-parse`,message:`Timeline block "${e.id}": body did not parse as an ASCII timeline`,blockId:e.id});return}e.templateData={...n,...e.templateData}}function Ad(e,t){if(j(e.template??``)!==`timeline`||!e.templateData||!(`tracks`in e.templateData))return;let n=(e.contents??[]).filter(e=>e.type===`code`&&xr(e.lang));if(n.length===1)for(let r of Rn(n[0].value).warnings){let n=/^unresolved-link\((.+)\)$/.exec(r);t.push({severity:`warning`,code:n?`timeline-unresolved-link`:`timeline-parse-warning`,message:n?`Timeline block "${e.id}": unresolved branch ${n[1]}`:`Timeline block "${e.id}": ${r}`,blockId:e.id})}}function jd(e){let t=e.frontmatter?.[`squisq-auto-templates`];return t===!1||t===`false`||t===`off`||t===`no`||t===0}function Md(e,t,n){for(let r of e){let e=!!r.sourceHeading?.templateAnnotation?.template||!!r.promotedBodyAnnotation;if(r.sourceHeading&&!e&&r.template===t){let e=li(oi(r.contents??[]),n.featureIndex);if(e&&Qa(e,r.contents)){let t=$a(e,r.title??``,r.contents,{preserveSourceHeading:!0});t&&((e===`leftFeature`||e===`rightFeature`)&&(n.featureIndex+=1),r.template=e,r.autoTemplate=!0,r.templateData={...t,...r.templateData})}}r.children&&r.children.length>0&&!se(r.template)&&Md(r.children,t,n)}}function Nd(e){if(!e.contents||e.contents.length===0)return``;let t=j(e.template??``),n=t===`diagram`&&e.templateData!==void 0&&`nodes`in e.templateData||t===`timeline`&&e.templateData!==void 0&&`tracks`in e.templateData||t===`tree`&&e.templateData!==void 0&&`items`in e.templateData;return e.contents.filter(e=>!(n&&e.type===`code`)).map(e=>o(e)).join(`
|
|
27
|
-
`).trim()}var
|
|
28
|
-
${r}`:n||r}function
|
|
29
|
-
|
|
30
|
-
`,i=[];for(let t of
|
|
31
|
-
`)?t.pauseAfter=2:Xd(t.text)&&(t.pauseAfter=1)}let d=Array(s.length+1);d[0]=0;for(let e=0;e<s.length;e++)d[e+1]=d[e]+s[e].syllables;return{sourceText:a,tokens:s,blocks:o,totalSyllables:d[s.length],cumulativeSyllables:d}}var qd=/["')\]}»”’]+$/;function Jd(e){return/[\p{L}\p{N}]/u.test(e)}function Yd(e){return e.replace(/^[.,!?;:'"()[\]{}]+|[.,!?;:'"()[\]{}]+$/g,``)}function Xd(e){let t=e.replace(qd,``),n=t.charAt(t.length-1);return n?n===`,`||n===`.`||n===`;`||n===`:`||n===`!`||n===`?`:!1}function Zd(e,t,n){return e<t?t:e>n?n:e}function Qd(e,t){let n=e.tokens.length;if(n===0)return 0;let r=Zd(t,0,n),i=Math.floor(r);return i>=n?e.totalSyllables:e.cumulativeSyllables[i]+(r-i)*e.tokens[i].syllables}function $d(e,t){let n=e.tokens.length;if(n===0)return 0;let r=Zd(t,0,e.totalSyllables),i=0,a=n;for(;i<a;){let t=i+a+1>>1;e.cumulativeSyllables[t]<=r?i=t:a=t-1}if(i>=n)return n;let o=r-e.cumulativeSyllables[i],s=e.tokens[i].syllables;return i+(s>0?o/s:0)}function ef(e,t){if(e.length===0)return 0;let n=0,r=e.length-1;for(;n<r;){let i=n+r+1>>1;e[i].tSec<=t?n=i:r=i-1}return e[n].tSec<=t?n:0}function tf(e,t,n,r){let i=t.words.map(t=>{let n=e.tokens[t.tokenIndex];return{id:`word-${t.tokenIndex}`,time:t.tSec,charOffset:n?.charOffset??0,textFragment:n?.text??``}}),a=t.blocks.map(e=>({...e.blockId?{blockId:e.blockId}:{},...e.heading===void 0?{}:{heading:e.heading},blockIndex:e.blockIndex,charStart:e.charStart,charEnd:e.charEnd,startSec:e.startSec,endSec:e.endSec}));return{version:3,sourceText:e.sourceText,duration:Number.isFinite(n)&&n>=0?n:0,bookmarks:i,blocks:a,...rf(r?.cameraOffsetSec)?{cameraOffsetSec:r.cameraOffsetSec}:{},generator:{name:`squisq-teleprompter`,method:`dsp-align`,...r?.baseWpm===void 0?{}:{baseWpm:r.baseWpm}}}}function nf(e){return typeof e==`number`&&Number.isFinite(e)&&e>=0}function rf(e){return typeof e==`number`&&Number.isFinite(e)}function af(e){try{let t=typeof e==`string`?e:new TextDecoder().decode(e instanceof Uint8Array?e:new Uint8Array(e)),n=JSON.parse(t);if(typeof n!=`object`||!n)return null;let r=n;if(typeof r.sourceText!=`string`||!nf(r.duration))return null;let i=Array.isArray(r.bookmarks)?r.bookmarks.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=e;return!nf(t.time)||!nf(t.charOffset)?[]:[{id:typeof t.id==`string`?t.id:`bookmark-${t.charOffset}`,time:t.time,charOffset:t.charOffset,...typeof t.textFragment==`string`?{textFragment:t.textFragment}:{}}]}):[],a=Array.isArray(r.blocks)?r.blocks.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=e;return!nf(t.startSec)||!nf(t.endSec)||!nf(t.charStart)||!nf(t.charEnd)?[]:[{...typeof t.blockId==`string`?{blockId:t.blockId}:{},...typeof t.heading==`string`?{heading:t.heading}:{},blockIndex:nf(t.blockIndex)?t.blockIndex:0,charStart:t.charStart,charEnd:t.charEnd,startSec:t.startSec,endSec:Math.max(t.startSec,t.endSec)}]}):[];a=a.sort((e,t)=>e.startSec-t.startSec);let o=0;for(let e of a)e.startSec<o&&(e.startSec=o),e.endSec<e.startSec&&(e.endSec=e.startSec),o=e.startSec;return{version:3,sourceText:r.sourceText,duration:r.duration,bookmarks:i,blocks:a,...rf(r.cameraOffsetSec)?{cameraOffsetSec:r.cameraOffsetSec}:{},...typeof r.generator==`object`&&r.generator!==null?{generator:r.generator}:{}}}catch{return null}}function of(e,t=0){return!e||e.type===`none`?{className:``,style:{}}:{className:sf(e),style:cf(e)}}function sf(e){let{type:t,direction:n,panDirection:r}=e;switch(t){case`fadeIn`:return`anim-fadeIn`;case`fadeOut`:return`anim-fadeOut`;case`slowZoom`:return r===`left`?`anim-slowZoom-panLeft`:r===`right`?`anim-slowZoom-panRight`:n===`out`?`anim-slowZoom-out`:`anim-slowZoom-in`;case`zoomIn`:return`anim-zoomIn`;case`zoomOut`:return`anim-zoomOut`;case`panLeft`:return`anim-panLeft`;case`panRight`:return`anim-panRight`;case`typewriter`:return`anim-typewriter`;default:return``}}function cf(e){let t={};return e.duration!==void 0&&(t[`--anim-duration`]=`${e.duration}s`),e.delay!==void 0&&(t[`--anim-delay`]=`${e.delay}s`),e.easing&&(t[`--anim-easing`]=e.easing),t}function lf(e){switch(e){case`slowZoom`:case`panLeft`:case`panRight`:return 8;case`typewriter`:return 3;case`fadeIn`:case`fadeOut`:return 1;case`zoomIn`:case`zoomOut`:return .5;default:return 1}}function uf(e,t,n){if(e===`cut`)return``;let r=t?`enter`:`exit`;return`transition-${ff(e,n)}-${r}`}var df={airplane:`airplane`,blinds:`blindsHorizontal`,box:`box`,checker:`checkerboard`,checkerboard:`checkerboard`,circle:`shapeCircle`,clock:`clock`,comb:`combHorizontal`,conveyor:`conveyor`,cover:`coverLeft`,crush:`crush`,cube:`cube`,curtains:`curtains`,cut:`cut`,diamond:`shapeDiamond`,dissolve:`dissolve`,doors:`doors`,drape:`drape`,fade:`fade`,fallOver:`fallOver`,ferris:`ferrisWheel`,ferrisWheel:`ferrisWheel`,flash:`flash`,flip:`flip`,flyThrough:`flyThrough`,flythrough:`flyThrough`,fracture:`fracture`,gallery:`gallery`,glitter:`glitter`,honeycomb:`honeycomb`,morph:`morph`,newsflash:`newsflash`,orbit:`orbit`,origami:`origami`,pageCurl:`pageCurl`,pageCurlDouble:`pageCurlDouble`,pageCurlSingle:`pageCurlSingle`,pan:`panLeft`,peelOff:`peelOff`,plus:`shapePlus`,prestige:`prestige`,prism:`prism`,pull:`pullLeft`,push:`pushLeft`,random:`random`,randomBar:`randomBarsHorizontal`,randomBars:`randomBarsVertical`,reveal:`revealLeft`,ripple:`ripple`,rotate:`rotate`,shape:`shapeCircle`,shred:`shred`,slideDown:`slideDown`,slideLeft:`slideLeft`,slideRight:`slideRight`,slideUp:`slideUp`,split:`splitHorizontal`,strips:`stripsLeft`,switch:`switch`,uncover:`uncoverLeft`,vortex:`vortex`,warp:`warp`,wedge:`wedge`,wheel:`wheel`,wheelReverse:`wheelReverse`,wind:`wind`,window:`window`,wipe:`wipeLeft`,zoom:`zoom`};function ff(e,t){switch(e){case`randomBars`:case`randomBar`:return mf(`randomBars`,t,e===`randomBar`?`Horizontal`:`Vertical`);case`comb`:return mf(`comb`,t,`Horizontal`);case`blinds`:return mf(`blinds`,t,`Horizontal`);case`split`:return mf(`split`,t,`Horizontal`);case`push`:return pf(`push`,t,`Left`);case`wipe`:return pf(`wipe`,t,`Left`);case`cover`:return pf(`cover`,t,`Left`);case`uncover`:return pf(`uncover`,t,`Left`);case`pull`:return pf(`pull`,t,`Left`);case`reveal`:return pf(`reveal`,t,`Left`);case`strips`:return pf(`strips`,t,`Left`);case`pan`:return pf(`pan`,t,`Left`);default:return df[e]}}function pf(e,t,n){return`${e}${hf(t,n)}`}function mf(e,t,n){return`${e}${gf(t,n)}`}function hf(e,t){switch(e){case`right`:return`Right`;case`up`:return`Up`;case`down`:return`Down`;default:return t}}function gf(e,t){switch(e){case`vertical`:case`up`:case`down`:return`Vertical`;case`horizontal`:case`left`:case`right`:return`Horizontal`;default:return t}}function _f(e,t,n){let r=e.delay||0,i=e.duration||n;return t<r?0:t>=r+i?1:(t-r)/i}var vf=40,yf=e=>Math.max(0,Math.min(1,e)),bf=e=>Math.round(e*100)/100;function xf(e,t){let n=[];if(t!=null&&t>0&&n.push(`blur(${Math.round(t)}px)`),e&&e.type!==`none`){let t=yf(e.strength??.6);switch(e.type){case`mono`:n.push(`grayscale(${bf(t)})`,`contrast(${bf(1+.05*t)})`);break;case`duotone`:{let r=ie(e.color??`#3d5a80`);n.push(`grayscale(1)`,`sepia(${bf(Math.max(.35,t))})`,`hue-rotate(${Math.round(r-vf)}deg)`,`saturate(${bf(1+t)})`);break}case`warm`:n.push(`sepia(${bf(.4*t)})`,`saturate(${bf(1+.15*t)})`);break;case`cool`:n.push(`saturate(${bf(1-.25*t)})`,`hue-rotate(${Math.round(-12*t)}deg)`,`contrast(${bf(1+.06*t)})`);break}}return n.length>0?n.join(` `):void 0}var Sf=Object.freeze([{id:`cover`,label:`Hero cover`,description:`The classic Squisq cover with title, subtitle, and optional hero image.`},{id:`title`,label:`Title`,description:`A theme-led title card without a full-bleed image.`},{id:`sectionHeader`,label:`Section header`,description:`A bold section divider using the hero image when one is available.`},{id:`imageWithCaption`,label:`Image with title`,description:`A full-bleed image with the title and subtitle overlaid.`,requiresHeroImage:!0},{id:`bigText`,label:`Big text`,description:`The title in gigantic uppercase type on a clean theme surface — thumbnail-ready.`},{id:`bigTextImage`,label:`Big text on image`,description:`The title in gigantic uppercase type over the hero image, with a contrast bloom behind the text.`,requiresHeroImage:!0}]),Cf=Object.freeze({enabled:{canonical:`squisq-cover-slide`,legacy:`cover-slide`},template:{canonical:`squisq-cover-template`,legacy:`cover-template`},duration:{canonical:`squisq-cover-duration`,legacy:`cover-duration`},playback:{canonical:`squisq-cover-playback`,legacy:`cover-playback`}}),wf=Object.freeze({enabled:!0,template:`cover`,duration:2,playback:`preroll`});function Tf(e,t){if(e)return Object.prototype.hasOwnProperty.call(e,t.canonical)?e[t.canonical]:e[t.legacy]}function Ef(e){if(typeof e==`boolean`)return e;if(typeof e!=`string`)return;let t=e.trim().toLowerCase();if([`true`,`yes`,`on`,`show`,`visible`].includes(t))return!0;if([`false`,`no`,`off`,`hide`,`hidden`].includes(t))return!1}function Df(e){if(typeof e!=`string`)return;let t=e.trim().toLowerCase().replace(/[_\s-]+/g,``);if(t===`cover`||t===`hero`||t===`managedcover`)return`cover`;if(t===`title`||t===`titleblock`)return`title`;if(t===`sectionheader`||t===`section`)return`sectionHeader`;if(t===`imagewithcaption`||t===`imagetitle`||t===`fullbleedimage`)return`imageWithCaption`;if(t===`bigtextimage`||t===`largetextimage`||t===`bigtextonimage`)return`bigTextImage`;if(t===`bigtext`||t===`largetext`)return`bigText`}function Of(e){let t=typeof e==`number`?e:typeof e==`string`&&e.trim().length>0?Number(e):NaN;if(!(!Number.isFinite(t)||t<0||t>60))return t}function kf(e){if(typeof e!=`string`)return;let t=e.trim().toLowerCase().replace(/[_\s]+/g,`-`);if([`overlay`,`over`,`concurrent`,`play-over`].includes(t))return`overlay`;if([`preroll`,`pre-roll`,`delay`,`push`,`shift`].includes(t))return`preroll`}function Af(e,t={}){let n={enabled:Ef(Tf(e,Cf.enabled))??wf.enabled,template:Df(Tf(e,Cf.template))??wf.template,duration:Of(Tf(e,Cf.duration))??wf.duration,playback:kf(Tf(e,Cf.playback))??wf.playback};return{enabled:t.enabled??n.enabled,template:t.template??n.template,duration:Of(t.duration)??n.duration,playback:t.playback??n.playback}}var jf=[`transition`,`transitionDuration`,`transitionDirection`],Mf=`sectionHeader`;function Nf(e,t={}){let n=j(t.defaultTemplate??Mf),r=[],i=new Set(xd(e.blocks).map(e=>e.id)),a=new Map,o=[];for(let t of e.documentMedia??[])if(t.origin&&i.has(t.origin.blockId)){let e=a.get(t.origin.blockId)??[];e.push(t),a.set(t.origin.blockId,e)}else o.push(t);for(let e of o)r.push(Lf(e));function s(e){let t=e.promotedBodyAnnotation,i=t!==void 0&&!Ff(e,t);if(e.sourceHeading)if(i)r.push(e.sourceHeading);else{let t=Rf(e,e.sourceHeading,n);r.push(t)}else e.standaloneAnnotation&&r.push(Pf(e));let o=[...e.media??[],...a.get(e.id)??[]],c=[...e.contents??[]];if(o.length>0){let e=o.filter(e=>e.origin).sort((e,t)=>e.origin.index-t.origin.index);for(let t of e)c.splice(Math.min(t.origin.index,c.length),0,Lf(t));for(let e of o.filter(e=>!e.origin).reverse())c.unshift(Lf(e))}if(i&&If(c,t),r.push(...c),e.children)for(let t of e.children)s(t)}for(let t of e.blocks)s(t);let c=Su(e.customTemplates),l=e.frontmatter;if(c)l={...l??{},[E]:c};else if(l&&`squisq-custom-templates`in l){let{[E]:e,...t}=l;l=t}let u=ku(e.customThemes);if(u)l={...l??{},[k]:u};else if(l&&`squisq-custom-themes`in l){let{[k]:e,...t}=l;l=t}return{type:`document`,children:r,...l&&Object.keys(l).length>0?{frontmatter:l}:{}}}function Pf(e){return{type:`paragraph`,children:[{type:`text`,value:ue(e.sourceAnnotation?.template,e.templateOverrides)}]}}function Ff(e,t){let n=j(e.template??``)===j(t.template),r=Vf(e.templateOverrides??{},t.params??{});return!(n&&r)}function If(e,t){if(t.origin.kind===`paragraph`){e.push({type:`paragraph`,children:[{type:`text`,value:t.origin.raw}]});return}let n=e[e.length-1];if(n&&n.type===`paragraph`){let r=n.children??[],i=r[r.length-1];if(i&&i.type===`text`){let a=[...r];a[a.length-1]={...i,value:i.value+t.origin.suffix},e[e.length-1]={...n,children:a};return}}e.push({type:`paragraph`,children:[{type:`text`,value:t.origin.suffix.replace(/^\s+/,``)}]})}function Lf(e){if(e.origin?.format===`html`&&e.origin.raw)return{type:`htmlBlock`,rawHtml:e.origin.raw,htmlChildren:a(e.origin.raw)};if(e.origin?.raw)return{type:`paragraph`,children:[{type:`text`,value:e.origin.raw}]};let t={src:e.src};return e.placement&&(t.placement=e.placement),e.pipSize&&(t.pipSize=e.pipSize),e.pipShape&&(t.pipShape=e.pipShape),e.pipPosition&&(t.pipPosition=e.pipPosition),e.lockToBlock!=null&&(t.lockToBlock=String(e.lockToBlock)),e.anchor===`document`&&(t.anchor=`document`),e.startAt&&(t.startAt=String(e.startAt)),e.clipStart!=null&&(t.clipStart=String(e.clipStart)),e.clipEnd!=null&&(t.clipEnd=String(e.clipEnd)),e.spillover&&(t.spillover=`true`),{type:`paragraph`,children:[{type:`text`,value:ue(e.kind,t)}]}}function Rf(e,t,n){let{attributes:r,transitionParams:i}=Hf(e,t),a=t.templateAnnotation,o=zf(e,a,n),s=e.templateOverrides&&Object.keys(e.templateOverrides).length>0?e.templateOverrides:void 0,c;return(o!==void 0||s!==void 0)&&(c={...o===void 0?{}:{template:o},...s?{params:s}:{}}),i&&(c={...c??{},params:{...c?.params??{},...i}}),Bf(a,c)&&(c=a),r===t.attributes&&c===t.templateAnnotation?t:{...t,children:[...t.children],attributes:r,templateAnnotation:c}}function zf(e,t,n){if(!e.template||e.autoTemplate===!0)return t?.template;let r=j(e.template);if(t?.template&&j(t.template)===r)return t.template;if(r!==n)return e.template}function Bf(e,t){return e===t?!0:!e||!t?!1:e.template===t.template&&Vf(e.params,t.params)}function Vf(e,t){if(e===t)return!0;if(!e||!t)return!1;let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Object.prototype.hasOwnProperty.call(t,n)&&e[n]===t[n])}function Hf(e,t){let n=e.transition;if(!n)return{attributes:t.attributes,transitionParams:void 0};let r=Uf(t.attributes)??{};return{attributes:{...r,blockMeta:{...r.blockMeta??{},transition:n}},transitionParams:{transition:n.type,...n.duration===void 0?{}:{transitionDuration:String(n.duration)},...n.direction?{transitionDirection:n.direction}:{}}}}function Uf(e){if(!e?.params)return e;let t={...e.params};for(let e of jf)delete t[e];return{...e,...Object.keys(t).length>0?{params:t}:{params:void 0}}}function Wf(e){if(e.type===`inlineIcon`){let t=e;return Ce(t.family,t.name)}if(`value`in e&&typeof e.value==`string`)return e.value;let n=t(e),r=e.type===`list`||e.type===`listItem`?`
|
|
32
|
-
`:``;return n.map(
|
|
33
|
-
`).trim()}function
|
|
34
|
-
`).trim();return n?{text:n,markdown:t}:void 0}function
|
|
35
|
-
`).trim(),markdown:i}}function
|
|
36
|
-
`).trim(),markdown:r},n.draft={...n.draft,slots:t}):s.splice(1,1)}}for(let e of s)e.override
|
|
24
|
+
`).trim()}function ks(e){return Math.round(e*100)/100}function As(e,t){let{theme:n,viewport:r,children:i=[]}=t,{layers:a}=Es(i,r,{ink:n.colors.text});return a.length>0?a:[js(e,t)]}function js(e,t){return{type:`text`,id:`layout-empty`,content:{text:e.title??`Empty layout`,style:{fontSize:m(36,t,!0),fontFamily:I(t,`title`),color:t.theme.colors.textMuted,textAlign:`center`}},position:{x:`50%`,y:`50%`,anchor:`center`}}}var Ms=/\{(\w+)(?::([^}|]+))?(?:\|([^}]*))?\}/g,Ns=/\{\{([^{}]*)\}\}/g,Ps=` ESC_OPEN `,Fs=` ESC_CLOSE `;function Is(e){if(!e.contents)return[];let t=[],n=e=>{if(e.type===`image`){let n=e;t.push({url:n.url??``,alt:n.alt??``})}};for(let t of e.contents)i(t,e=>{n(e)});return t}function Ls(e){if(!e.contents)return[];let t=[];for(let n of e.contents)i(n,e=>{if(e.type===`listItem`){let n=o(e).replace(/\s+/g,` `).trim();return n&&t.push(n),!0}});return t}function Rs(e){return e.contents?e.contents.map(e=>o(e).trim()).filter(e=>e.length>0).join(` `):``}function zs(e){return!e.children||e.children.length===0?``:e.children.map(e=>e.title?.trim()).filter(e=>!!e).join(`, `)}function Bs(e){return e.replace(Ns,(e,t)=>Ps+t+Fs)}function Vs(e){return e.replace(new RegExp(Ps,`g`),`{`).replace(new RegExp(Fs,`g`),`}`)}function Hs(e,t){return Vs(Bs(e).replace(Ms,(e,n,r,i)=>{let a=t(n,r);return a==null?e:a===``&&i!==void 0?i:a}))}function Us(e,t,n,r,i){switch(e){case`title`:return n.title??``;case`content`:return Rs(n);case`children`:return zs(n);case`attr`:{if(!t)return``;let e=n.templateOverrides?.[t]??n.templateData?.[t]??n.metadata?.[t];return e==null?``:String(e)}case`image`:{let e=t?parseInt(t,10):0;return!Number.isFinite(e)||e<0||e>=r.length?``:r[e].alt}case`item`:return i?t?t===`src`?i.src??``:t===`label`?i.label??``:``:i.text:null;case`index`:return i?String(i.index):null;default:return null}}function Ws(e,t,n,r){return Hs(e,(e,i)=>Us(e,i,t,n,r))}function Gs(e,t,n,r){if(!e.includes(`{`))return e;let i=!1,a=Bs(e).replace(Ms,(e,a,o,s)=>{if(a===`image`){let e=o?parseInt(o,10):0;return Number.isFinite(e)&&e>=0&&e<n.length?n[e].url:s===void 0?(i=!0,``):s}let c=Us(a,o,t,n,r);return c==null?e:c===``&&s!==void 0?s:c});return i?null:Vs(a)}function Ks(e){if(typeof e==`number`)return e;if(typeof e==`string`){let t=e.match(/-?\d*\.?\d+/);if(t)return parseFloat(t[0])}return 0}function qs(e,t){if(e==null)return t;if(typeof e==`number`)return e+t;let n=e.match(/^(\s*)(-?\d*\.?\d+)(.*)$/);if(n){let e=parseFloat(n[2])+t;return`${n[1]}${e}${n[3]}`}return e}function Js(e,t,n){switch(e){case`images`:return n.map((e,t)=>({text:e.alt,src:e.url,label:e.alt,index:t+1}));case`children`:return(t.children??[]).map((e,t)=>({text:e.title??``,label:e.title??``,index:t+1}));case`listItems`:return Ls(t).map((e,t)=>({text:e,label:e,index:t+1}));default:return[]}}function Ys(e,t,n){let r=e.repeat;if(!r){let r=Zs(e,t,n,void 0);return r?[r]:[]}let i=Js(r.source,t,n),a=r.direction??`column`,o=r.gap??24,s=r.max!=null&&r.max>=0?Math.min(r.max,i.length):i.length,c=[],l=0;for(let r=0;r<s;r++){let s={...e.position};a===`row`?s.x=qs(s.x,l):s.y=qs(s.y,l);let u={...e,position:s,id:`${e.id}-${r}`};delete u.repeat;let d=Zs(u,t,n,i[r]);d&&c.push(d);let f=a===`row`?e.position.width:e.position.height;l+=Ks(f)+o}return c}function Xs(e,t){let n=Is(t),r=[];for(let i of e)if(i.repeat)r.push(...Ys(i,t,n));else{let e=Zs(i,t,n,void 0);e&&r.push(e)}return r}function Zs(e,t,n,r){switch(e.type){case`text`:return{...e,content:{...e.content,text:Ws(e.content.text,t,n,r)}};case`image`:{let i=Gs(e.content.src,t,n,r);if(i==null)return null;let a={...e,content:{...e.content,src:i}};return e.content.alt&&e.content.alt.includes(`{`)&&(a.content.alt=Ws(e.content.alt,t,n,r)),a}default:return e}}function Qs(e){return(t,n)=>{let r=n.block??t;return r?Xs(e.layers,r):e.layers.slice()}}var $s=.6;function ec(e){if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;let n=!1,r=/^\((.*)\)$/.exec(t);if(r&&(n=!0,t=r[1].trim()),t=t.replace(/^([+-]?)\s*[$€£¥]\s*/,`$1`),t=t.replace(/%$/,``).trim(),t=t.replace(/,/g,``),/^[+-]?\d{1,3}(?: \d{3})+(?:\.\d+)?$/.test(t)&&(t=t.replace(/ /g,``)),!/^[+-]?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?$/i.test(t))return null;let i=Number(t);return Number.isFinite(i)?n?-i:i:null}function tc(e,t){let n=0,r=0;for(let i of e){let e=(i[t]??``).trim();e&&(n+=1,ec(e)!==null&&(r+=1))}return r>0&&r/Math.max(1,n)>=$s}function nc(e,t){let n=String(e).trim();if(!n)return null;let r=n.toLowerCase(),i=t.findIndex(e=>e.trim().toLowerCase()===r);if(i>=0)return i;if(/^\d+$/.test(n)){let e=Number(n);if(e<t.length)return e}return null}function rc(e,t={}){let n=Array.isArray(e.headers)?e.headers:[],r=Array.isArray(e.rows)?e.rows:[];if(n.length===0||r.length===0)return null;let i=[],a=0;if(t.labelColumn!==void 0&&String(t.labelColumn).trim()!==``){let e=nc(String(t.labelColumn),n);e===null?i.push(`labelColumn "${t.labelColumn}" matches no column; using the first column`):a=e}let o=[],s=(t.valueColumns??[]).map(e=>String(e)).filter(e=>e.trim()!==``);if(s.length>0)for(let e of s){let t=nc(e,n);t===null?i.push(`valueColumns entry "${e}" matches no column; skipped`):o.includes(t)||o.push(t)}else o=n.map((e,t)=>t).filter(e=>e!==a&&tc(r,e));return o.length===0?null:{labels:r.map(e=>(e[a]??``).trim()),labelHeader:n[a]??``,labelNumbers:r.map(e=>ec(e[a]??``)),series:o.map(e=>({name:(n[e]??`Column ${e+1}`).trim()||`Column ${e+1}`,values:r.map(t=>ec(t[e]??``))})),warnings:i}}function ic(e,t){let n=Math.floor(Math.log10(e)),r=e/10**n,i;return i=t?r<1.5?1:r<3?2:r<7?5:10:r<=1?1:r<=2?2:r<=5?5:10,i*10**n}function ac(e,t,n=5){let r=Number.isFinite(e)?e:0,i=Number.isFinite(t)?t:0;if(r>i&&([r,i]=[i,r]),r===i){let t=r===0?1:ic(Math.abs(r),!0);r-=t,i+=t,e>=0&&r<0&&(r=0)}let a=Math.max(2,n),o=ic(ic(i-r,!1)/(a-1),!0),s=Math.floor(r/o)*o,c=Math.ceil(i/o)*o,l=[];for(let e=s;e<=c+o*1e-6;e+=o)l.push(Math.abs(e)<o*1e-6?0:Number(e.toPrecision(12)));return{ticks:l,niceMin:s,niceMax:c,step:o}}function oc(e,t){if(!Number.isFinite(e))return`—`;let n=e<0?`-`:``,r=Math.abs(e),i;return i=r>=1e6?`${n}${sc((r/1e6).toFixed(1))}M`:r>=1e3?`${n}${sc((r/1e3).toFixed(r>=1e4?0:1))}K`:`${n}${r.toLocaleString(`en-US`,{maximumFractionDigits:2})}`,t?`${i} ${t}`:i}function sc(e){return e.replace(/\.0$/,``)}function Y(e){return Math.round(e*100)/100}function cc(e,t,n,r){let i=(r-90)*Math.PI/180;return{x:Y(e+n*Math.cos(i)),y:Y(t+n*Math.sin(i))}}function lc(e,t,n,r,i,a){let o=a-i;if(o<=0)return``;o>=359.9&&(o=359.9);let s=i+o,c=+(o>180),l=cc(e,t,n,i),u=cc(e,t,n,s);if(r<=0)return[`M ${Y(e)} ${Y(t)}`,`L ${l.x} ${l.y}`,`A ${Y(n)} ${Y(n)} 0 ${c} 1 ${u.x} ${u.y}`,`Z`].join(` `);let d=cc(e,t,r,i),f=cc(e,t,r,s);return[`M ${l.x} ${l.y}`,`A ${Y(n)} ${Y(n)} 0 ${c} 1 ${u.x} ${u.y}`,`L ${f.x} ${f.y}`,`A ${Y(r)} ${Y(r)} 0 ${c} 0 ${d.x} ${d.y}`,`Z`].join(` `)}function uc(e){return e.length===0?``:e.map((e,t)=>`${t===0?`M`:`L`} ${Y(e.x)} ${Y(e.y)}`).join(` `)}function dc(e,t){if(e.length===0)return``;let n=uc(e),r=e[0],i=e[e.length-1];return`${n} L ${Y(i.x)} ${Y(t)} L ${Y(r.x)} ${Y(t)} Z`}function fc(e){let t=e.viewportWidth,n=e.viewportHeight,r=t*.06,i=n*.06,a=t-r*2,o=i,s;e.hasTitle&&(s={x:r,y:o,width:a,height:e.titleFontSize*2.2},o=s.y+s.height);let c,l=0;e.tableRowCount>0&&(l=Math.min(n*.4,(e.tableRowCount+1)*e.tableFontSize*2.4));let u=e.legendRows>0?e.legendRows*e.legendRowHeight:0,d={x:r,y:o,width:a,height:Math.max(40,n-i-o-u-l)};o=d.y+d.height;let f;u>0&&(f={x:r,y:o,width:a,height:u},o+=u),l>0&&(c={x:r,y:o,width:a,height:l});let p={x:d.x+e.leftGutter,y:d.y,width:Math.max(20,d.width-e.leftGutter),height:Math.max(20,d.height-e.bottomGutter)};return{titleBand:s,chartArea:d,plot:p,legendBand:f,tableBand:c}}function pc(e){let t=e.reduce((e,t)=>Math.max(e,t.values.length),0),n=Array(t).fill(0),r=Array(t).fill(0);return e.map(e=>Array.from({length:t},(t,i)=>{let a=e.values[i];if(a==null||!Number.isFinite(a))return{y0:n[i],y1:n[i]};if(a>=0){let e=n[i];return n[i]+=a,{y0:e,y1:n[i]}}let o=r[i];return r[i]+=a,{y0:r[i],y1:o}}))}function mc(e,t,n){let r=t*.9,i=t*1.6,a=t*2,o=e.map(e=>r+t*.5+e.length*t*.58),s=[],c=[],l=0;o.forEach((e,t)=>{let r=c.length>0?i:0;c.length>0&&l+r+e>n&&(s.push(c),c=[],l=0),c.push(t),l+=(c.length>1?i:0)+e}),c.length>0&&s.push(c);let u=[];return s.forEach((t,s)=>{let c=t.reduce((e,t,n)=>e+o[t]+(n>0?i:0),0),l=Math.max(0,(n-c)/2);t.forEach(t=>{u.push({label:e[t],index:t,x:l,y:s*a,swatchSize:r}),l+=o[t]+i})}),{items:u,rows:s.length,rowHeight:a}}function hc(e,t,n){if(e<=1)return 1;let r=n*6,i=t/e;return Math.max(1,Math.ceil(r/Math.max(1,i)))}var gc={bar:`barChart`,column:`columnChart`,pie:`pieChart`,donut:`donutChart`,line:`lineChart`,area:`areaChart`,scatter:`scatterChart`};function _c(e,t,n){let r=vc(t,n),i=r?rc(r,t):null;if(!r||!i)return yc(t,n);let{theme:a,viewport:o}=n,s=gc[e],c=(t.title??``).trim(),l=L(44,n,!0),u=L(20,n,!1),d=L(22,n,!1),f=L(22,n,!1),p=L(20,n,!1),m=I(n,`body`),h=e===`pie`||e===`donut`,g=bc(e,t,i),_=xc(n,t.colorScheme,h?i.labels.length:i.series.length);if(h&&!i.series[0].values.some(e=>e!==null&&e>0))return yc(t,n);let v=o.width*.88,y=g.length>0?mc(g,f,v):null,b=Sc(e,i,t,n,u,d),x=fc({viewportWidth:o.width,viewportHeight:o.height,hasTitle:c.length>0,titleFontSize:l,leftGutter:b.left,bottomGutter:b.bottom,legendRows:y?.rows??0,legendRowHeight:f*2,tableRowCount:t.showTable===!0?r.rows.length:0,tableFontSize:p}),S=Ii(n,s,`entrance`,`staggered`),w={kind:e,input:t,context:n,data:i,frame:x,colors:_,axisFontSize:u,labelFontSize:d,bodyFont:m,gridColor:C(a.colors.text,.12),axisTextColor:a.colors.textMuted,entrance:e=>({type:`fadeIn`,duration:.6,delay:S===`subtle`?.1:Math.min(1.2,.2+e*.08)})},T=[zi(`bg`,V(n,170))];switch(c&&x.titleBand&&T.push({type:`text`,id:`title`,content:{text:c,style:{fontSize:l,fontFamily:I(n,`title`),fontWeight:`bold`,color:a.colors.text,textAlign:`center`,shadow:z(n)}},position:{x:x.titleBand.x+x.titleBand.width/2,y:x.titleBand.y+x.titleBand.height/2,width:x.titleBand.width,anchor:`center`},animation:{type:`fadeIn`,duration:.8}}),e){case`bar`:T.push(...Dc(w));break;case`column`:T.push(...Ec(w));break;case`pie`:case`donut`:T.push(...Oc(w));break;case`line`:case`area`:T.push(...kc(w));break;case`scatter`:T.push(...Ac(w));break}return y&&x.legendBand&&T.push(...jc(w,y,x.legendBand,f)),t.showTable===!0&&x.tableBand&&T.push(Nc(r,x.tableBand,p,t,n)),T}function vc(e,t){return Array.isArray(e.headers)&&e.headers.length>0&&Array.isArray(e.rows)&&e.rows.length>0?{headers:e.headers,rows:e.rows}:Wa(e.contents??t.block?.contents)}function yc(e,t){return io({...e,template:`content`,title:e.title??t.block?.title??``},t)}function bc(e,t,n){return t.showLegend===!1?[]:e===`pie`||e===`donut`?n.labels:n.series.length>1||t.showLegend===!0?n.series.map(e=>e.name):[]}function xc(e,t,n){let r=e.theme.colorSchemes,i=Object.keys(r),a=[F(e,t).accent],o=t&&i.includes(t)?i.indexOf(t):0;for(let e=1;e<i.length&&a.length<n;e++){let t=r[i[(o+e)%i.length]].accent;a.some(e=>e.toLowerCase()===t.toLowerCase())||a.push(t)}let s=a.length;for(let e=0;a.length<n;e++)a.push(C(a[e%s],.55));return a.slice(0,Math.max(1,n))}function Sc(e,t,n,r,i,a){if(e===`pie`||e===`donut`)return{left:0,bottom:0};if(e===`bar`){let e=t.labels.reduce((e,t)=>Math.max(e,t.length),0);return{left:Math.min(r.viewport.width*.24,Math.max(a*3,e*a*.58+16)),bottom:i*2.4}}let o=Cc(e,t,n).ticks.reduce((e,t)=>Math.max(e,oc(t,n.unit).length),0);return{left:Math.max(i*2.5,o*i*.6+16),bottom:a*2.6}}function Cc(e,t,n){let r;r=(e===`bar`||e===`column`)&&n.stacked===!0?pc(t.series).flat().flatMap(e=>[e.y0,e.y1]):t.series.flatMap(e=>e.values.filter(e=>e!==null)),r.length===0&&(r=[0,1]);let i=Math.min(...r),a=Math.max(...r);return e!==`line`&&e!==`scatter`&&(i=Math.min(0,i),a=Math.max(0,a)),ac(i,a,5)}function wc(e,t,n){let{frame:r,gridColor:i,axisTextColor:a,axisFontSize:o,bodyFont:s,input:c}=e,l=[];return t.ticks.forEach((t,u)=>{let d=n(t);l.push({type:`shape`,id:`grid-${u}`,content:{shape:`rect`,fill:t===0?C(e.context.theme.colors.text,.35):i},position:{x:r.plot.x,y:d-(t===0?1:.5),width:r.plot.width,height:t===0?2:1}}),l.push({type:`text`,id:`tick-${u}`,content:{text:oc(t,c.unit),style:{fontSize:o,fontFamily:s,color:a,textAlign:`center`}},position:{x:r.chartArea.x+(r.plot.x-r.chartArea.x)/2,y:d,anchor:`center`}})}),l}function Tc(e,t){let{frame:n,data:r,labelFontSize:i,axisTextColor:a,bodyFont:o}=e,s=hc(r.labels.length,n.plot.width,i),c=[];return r.labels.forEach((e,r)=>{r%s!==0||!e||c.push({type:`text`,id:`cat-${r}`,content:{text:e,style:{fontSize:i,fontFamily:o,color:a,textAlign:`center`}},position:{x:t(r),y:n.plot.y+n.plot.height+i*1.2,anchor:`center`}})}),c}function Ec(e){let{frame:t,data:n,colors:r,input:i,entrance:a}=e,o=Cc(`column`,n,i),s=e=>t.plot.y+t.plot.height*(1-(e-o.niceMin)/(o.niceMax-o.niceMin)),c=wc(e,o,s),l=n.labels.length,u=t.plot.width/Math.max(1,l),d=u*.15;c.push(...Tc(e,e=>t.plot.x+(e+.5)*u));let f=i.stacked===!0&&n.series.length>1,p=f?pc(n.series):null,m=u-d*2,h=f?m:Math.max(2,(m-4*(n.series.length-1))/n.series.length);return n.series.forEach((n,o)=>{n.values.forEach((n,m)=>{if(m>=l)return;let g=p?p[o][m]:n===null?null:{y0:Math.min(0,n),y1:Math.max(0,n)};if(!g||g.y0===g.y1)return;let _=s(g.y1),v=Math.max(1,s(g.y0)-_),y=f?t.plot.x+m*u+d:t.plot.x+m*u+d+o*(h+4);c.push({type:`shape`,id:`mark-${o}-${m}`,content:{shape:`rect`,fill:r[o],borderRadius:f?0:3},position:{x:y,y:_,width:h,height:v},animation:a(m+o)}),i.showValues===!0&&n!==null&&!f&&c.push(Mc(e,`val-${o}-${m}`,n,y+h/2,n>=0?_-e.axisFontSize*.9:_+v+e.axisFontSize*.9))})}),c}function Dc(e){let{frame:t,data:n,colors:r,input:i,entrance:a,labelFontSize:o,axisFontSize:s,bodyFont:c,axisTextColor:l,gridColor:u}=e,d=Cc(`bar`,n,i),f=s*.6,p=e=>oc(e,i.unit).length*s*.58,m=i.showValues===!0&&i.stacked!==!0,h=m?n.series.flatMap(e=>e.values).filter(e=>e!==null).reduce((e,t)=>Math.max(e,p(t)),0)+f:0,g=Math.max(20,t.plot.width-h),_=e=>t.plot.x+g*((e-d.niceMin)/(d.niceMax-d.niceMin)),v=[];d.ticks.forEach((n,r)=>{let a=_(n);v.push({type:`shape`,id:`grid-${r}`,content:{shape:`rect`,fill:n===0?C(e.context.theme.colors.text,.35):u},position:{x:a-(n===0?1:.5),y:t.plot.y,width:n===0?2:1,height:t.plot.height}}),v.push({type:`text`,id:`tick-${r}`,content:{text:oc(n,i.unit),style:{fontSize:s,fontFamily:c,color:l,textAlign:`center`}},position:{x:a,y:t.plot.y+t.plot.height+s*1.2,anchor:`center`}})});let y=n.labels.length,b=t.plot.height/Math.max(1,y),x=b*.15,S=i.stacked===!0&&n.series.length>1,w=S?pc(n.series):null,T=b-x*2,E=S?T:Math.max(2,(T-4*(n.series.length-1))/n.series.length);return n.labels.forEach((e,n)=>{e&&v.push({type:`text`,id:`cat-${n}`,content:{text:e,style:{fontSize:o,fontFamily:c,color:l,textAlign:`center`}},position:{x:t.chartArea.x+(t.plot.x-t.chartArea.x)/2,y:t.plot.y+(n+.5)*b,anchor:`center`}})}),n.series.forEach((n,i)=>{n.values.forEach((n,o)=>{if(o>=y)return;let s=w?w[i][o]:n===null?null:{y0:Math.min(0,n),y1:Math.max(0,n)};if(!s||s.y0===s.y1)return;let c=_(s.y0),l=Math.max(1,_(s.y1)-c),u=S?t.plot.y+o*b+x:t.plot.y+o*b+x+i*(E+4);if(v.push({type:`shape`,id:`mark-${i}-${o}`,content:{shape:`rect`,fill:r[i],borderRadius:S?0:3},position:{x:c,y:u,width:l,height:E},animation:a(o+i)}),m&&n!==null){let t=p(n)/2,r=n>=0?c+l+f+t:c-f-t;v.push(Mc(e,`val-${i}-${o}`,n,r,u+E/2))}})}),v}function Oc(e){let{kind:t,frame:n,data:r,colors:i,input:a,entrance:o,context:s}=e,c=r.labels.map((e,t)=>({label:e,value:r.series[0].values[t],index:t})).filter(e=>e.value!==null&&Number.isFinite(e.value)&&e.value>0),l=c.reduce((e,t)=>e+t.value,0),u=n.chartArea.x+n.chartArea.width/2,d=n.chartArea.y+n.chartArea.height/2,f=Math.min(n.chartArea.width,n.chartArea.height)*.42,p=t===`donut`?f*.55:0,m=[],h=0;return c.forEach((t,n)=>{let r=t.value/l*360;if(m.push({type:`path`,id:`mark-${t.index}`,content:{d:lc(u,d,f,p,h,h+r),fill:i[t.index%i.length],stroke:s.theme.colors.background,strokeWidth:2},position:{x:u-f,y:d-f,width:f*2,height:f*2},animation:o(n)}),a.showValues===!0&&r>=14){let a=(h+r/2-90)*Math.PI/180,s=p>0?(p+f)/2:f*.68,c=`${Math.round(t.value/l*100)}%`;m.push({type:`text`,id:`val-${t.index}`,content:{text:c,style:{fontSize:e.axisFontSize,fontFamily:e.bodyFont,fontWeight:`bold`,color:S(i[t.index%i.length]),textAlign:`center`}},position:{x:u+s*Math.cos(a),y:d+s*Math.sin(a),anchor:`center`},animation:o(n)})}h+=r}),m}function kc(e){let{kind:t,frame:n,data:r,colors:i,input:a,entrance:o}=e,s=Cc(t,r,a),c=e=>n.plot.y+n.plot.height*(1-(e-s.niceMin)/(s.niceMax-s.niceMin)),l=r.labels.length,u=n.plot.width/Math.max(1,l),d=e=>n.plot.x+(e+.5)*u,f=wc(e,s,c);f.push(...Tc(e,d));let p=c(Math.max(s.niceMin,Math.min(s.niceMax,0))),m=l<=30;return r.series.forEach((r,s)=>{let u=[],h=[];r.values.forEach((e,t)=>{if(!(t>=l)){if(e===null){h.length>0&&u.push(h),h=[];return}h.push({x:d(t),y:c(e)})}}),h.length>0&&u.push(h),u.forEach((e,r)=>{t===`area`&&e.length>1&&f.push({type:`path`,id:`area-${s}-${r}`,content:{d:dc(e,p),fill:i[s],fillOpacity:.25,stroke:`none`,strokeWidth:0},position:{x:n.plot.x,y:n.plot.y,width:n.plot.width,height:n.plot.height},animation:o(s)}),e.length>1&&f.push({type:`path`,id:`line-${s}-${r}`,content:{d:uc(e),stroke:i[s],strokeWidth:4,fill:`none`},position:{x:n.plot.x,y:n.plot.y,width:n.plot.width,height:n.plot.height},animation:o(s)})}),m&&r.values.forEach((t,n)=>{n>=l||t===null||(f.push({type:`shape`,id:`pt-${s}-${n}`,content:{shape:`circle`,fill:i[s]},position:{x:d(n)-5,y:c(t)-5,width:10,height:10},animation:o(s)}),a.showValues===!0&&f.push(Mc(e,`val-${s}-${n}`,t,d(n),c(t)-e.axisFontSize)))})}),f}function Ac(e){let{frame:t,data:n,colors:r,input:i,entrance:a}=e,o=Cc(`scatter`,n,i),s=e=>t.plot.y+t.plot.height*(1-(e-o.niceMin)/(o.niceMax-o.niceMin)),c=wc(e,o,s),l=n.labelNumbers.filter(e=>e!==null).length,u=n.labels.length>0&&l/n.labels.length>=.6,d;if(u){let r=n.labelNumbers.filter(e=>e!==null),i=ac(Math.min(...r),Math.max(...r),5),a=i.niceMax-i.niceMin;d=e=>{let r=n.labelNumbers[e];return r===null?null:t.plot.x+t.plot.width*((r-i.niceMin)/a)},i.ticks.forEach((n,r)=>{let o=t.plot.x+t.plot.width*((n-i.niceMin)/a);c.push({type:`shape`,id:`xgrid-${r}`,content:{shape:`rect`,fill:e.gridColor},position:{x:o-.5,y:t.plot.y,width:1,height:t.plot.height}}),c.push({type:`text`,id:`xtick-${r}`,content:{text:oc(n),style:{fontSize:e.axisFontSize,fontFamily:e.bodyFont,color:e.axisTextColor,textAlign:`center`}},position:{x:o,y:t.plot.y+t.plot.height+e.axisFontSize*1.2,anchor:`center`}})})}else{let r=t.plot.width/Math.max(1,n.labels.length);d=e=>t.plot.x+(e+.5)*r,c.push(...Tc(e,e=>t.plot.x+(e+.5)*r))}return n.series.forEach((e,t)=>{e.values.forEach((e,n)=>{if(e===null)return;let i=d(n);i!==null&&c.push({type:`shape`,id:`mark-${t}-${n}`,content:{shape:`circle`,fill:r[t],fillOpacity:.85},position:{x:i-7,y:s(e)-7,width:14,height:14},animation:a(Math.floor(n/3)+t)})})}),c}function jc(e,t,n,r){let i=[];return t.items.forEach((a,o)=>{let s=e.colors[a.index%e.colors.length],c=n.y+a.y+t.rowHeight/2;i.push({type:`shape`,id:`legend-swatch-${o}`,content:{shape:`rect`,fill:s,borderRadius:3},position:{x:n.x+a.x,y:c-a.swatchSize/2,width:a.swatchSize,height:a.swatchSize}}),i.push({type:`text`,id:`legend-label-${o}`,content:{text:a.label,style:{fontSize:r,fontFamily:e.bodyFont,color:e.context.theme.colors.text}},position:{x:n.x+a.x+a.swatchSize+r*.5,y:c-r*.62}})}),i}function Mc(e,t,n,r,i){return{type:`text`,id:t,content:{text:oc(n,e.input.unit),style:{fontSize:e.axisFontSize,fontFamily:e.bodyFont,fontWeight:`bold`,color:e.context.theme.colors.text,textAlign:`center`}},position:{x:r,y:i,anchor:`center`}}}function Nc(e,t,n,r,i){let{theme:a}=i,o=F(i,r.colorScheme);return{type:`table`,id:`table`,content:{headers:e.headers,rows:e.rows,align:e.align,style:{headerBackground:o.accent,headerColor:S(o.accent),cellBackground:C(a.colors.text,.04),cellColor:a.colors.text,borderColor:C(a.colors.text,.15),fontSize:n,fontFamily:I(i,`body`),headerFontFamily:I(i,`title`),borderRadius:8}},position:{x:t.x,y:t.y,width:t.width,height:t.height},animation:{type:`fadeIn`,duration:1,delay:.4}}}function Pc(e,t){return _c(`bar`,e,t)}function Fc(e,t){return _c(`column`,e,t)}function Ic(e,t){return _c(`pie`,e,t)}function Lc(e,t){return _c(`donut`,e,t)}function Rc(e,t){return _c(`line`,e,t)}function zc(e,t){return _c(`area`,e,t)}function Bc(e,t){return _c(`scatter`,e,t)}function Vc(e,t){let n={...e,speaker:e.speaker??e.title??`Speaker`,text:e.text??``},{theme:r}=t,i=F(t,n.colorScheme),a=n.variant??`speech`,o=n.side??`left`,s=typeof n.counterpartName==`string`&&n.counterpartName.length>0,c=I(t,`body`),l=I(t,`mono`),u=L(26,t,!1),d=L(32,t,!0),f=L(22,t,!1),p=a===`thought`?C(r.colors.text,.05):a===`tool`?C(i.accent,.12):C(r.colors.text,.08),m=a===`thought`?r.colors.textMuted:r.colors.text,h=[zi(`bg`,V(t,160))];if(s)return[...h,...Hc(n,t,i.accent,m,p)];let g=o===`left`?`12%`:`88%`,_=o===`left`?`20%`:`18%`;h.push(...Wc(`speaker`,n.speaker,n.speakerImage,g,`34%`,t)),h.push({type:`text`,id:`speaker-name`,content:{text:n.speaker+(a===`thought`?` · thinking`:``),style:{fontSize:u,fontFamily:c,fontWeight:`bold`,color:r.colors.textMuted,textAlign:o===`left`?`left`:`right`,shadow:z(t)}},position:{x:_,y:`24%`,width:`62%`,anchor:`top-left`},animation:{type:`fadeIn`,duration:.4}});let v=57/100*t.viewport.width,y=Math.min(46,H(n.text,d,v,1.35)/t.viewport.height*100+8);return h.push({type:`shape`,id:`bubble`,content:{shape:`rect`,fill:p,borderRadius:18,...a===`tool`?{stroke:i.accent,strokeWidth:2}:{}},position:{x:_,y:`29%`,width:`62%`,height:`${Math.max(16,y)}%`,anchor:`top-left`},animation:{type:`fadeIn`,duration:.4,delay:.1}}),a===`tool`&&n.toolName&&h.push({type:`text`,id:`tool-name`,content:{text:n.toolName,style:{fontSize:L(28,t,!1),fontFamily:l,fontWeight:`bold`,color:i.accent}},position:{x:`${parseFloat(_)+2}%`,y:`32%`,anchor:`top-left`},animation:{type:`fadeIn`,duration:.4,delay:.15}}),h.push({type:`text`,id:`message`,content:{text:n.text,style:{fontSize:d,fontFamily:a===`tool`?l:c,fontStyle:a===`thought`?`italic`:`normal`,color:m,lineHeight:1.35,maxLines:7}},position:{x:`${parseFloat(_)+2}%`,y:a===`tool`&&n.toolName?`38%`:`32.5%`,width:`58%`,anchor:`top-left`},animation:{type:`typewriter`,duration:Math.min(2.5,.4+n.text.length/120)}}),a===`tool`&&n.resultText&&h.push({type:`text`,id:`tool-result`,content:{text:n.resultText,style:{fontSize:L(26,t,!1),fontFamily:l,color:r.colors.textMuted,lineHeight:1.3,maxLines:3}},position:{x:_,y:`78%`,width:`62%`,anchor:`top-left`},animation:{type:`fadeIn`,duration:.4,delay:.3}}),n.meta&&h.push({type:`text`,id:`meta`,content:{text:n.meta,style:{fontSize:f,fontFamily:c,color:r.colors.textMuted}},position:{x:`96%`,y:`94%`,anchor:`bottom-right`}}),h}function Hc(e,t,n,r,i){let{theme:a}=t,o=I(t,`body`),s=L(28,t,!1),c=L(32,t,!0),l=[...Wc(`speaker`,e.speaker,e.speakerImage,`26%`,`28%`,t),...Wc(`counterpart`,e.counterpartName??``,e.counterpartImage,`74%`,`28%`,t),Uc(`speaker-name`,e.speaker,`26%`,s,o,a.colors.textMuted),Uc(`counterpart-name`,e.counterpartName??``,`74%`,s,o,a.colors.textMuted),{type:`path`,id:`handoff-arrow`,content:{d:`M 0 0 L 100 0`,stroke:n,strokeWidth:4,endMarker:`arrow`},position:{x:`50%`,y:`28%`,width:`28%`,height:`1%`,anchor:`center`},animation:{type:`fadeIn`,duration:.4,delay:.2}}];return e.text.length>0&&l.push({type:`shape`,id:`bubble`,content:{shape:`rect`,fill:i,borderRadius:18},position:{x:`50%`,y:`66%`,width:`66%`,height:`32%`,anchor:`center`},animation:{type:`fadeIn`,duration:.4,delay:.3}},{type:`text`,id:`message`,content:{text:e.text,style:{fontSize:c,fontFamily:o,color:r,textAlign:`center`,lineHeight:1.35,maxLines:5}},position:{x:`50%`,y:`66%`,width:`60%`,height:`26%`,anchor:`center`},animation:{type:`typewriter`,duration:2,delay:.4}}),e.meta&&l.push({type:`text`,id:`meta`,content:{text:e.meta,style:{fontSize:L(22,t,!1),fontFamily:o,color:a.colors.textMuted}},position:{x:`96%`,y:`94%`,anchor:`bottom-right`}}),l}function Uc(e,t,n,r,i,a){return{type:`text`,id:e,content:{text:t,style:{fontSize:r,fontFamily:i,fontWeight:`bold`,color:a,textAlign:`center`}},position:{x:n,y:`42%`,anchor:`center`}}}function Wc(e,t,n,r,i,a){let{theme:o}=a;if(n)return[{type:`image`,id:`${e}-avatar`,content:{src:n,alt:t,fit:`contain`},position:{x:r,y:i,width:`9%`,height:`16%`,anchor:`center`}}];let s=t.split(/\s+/).map(e=>e[0]??``).join(``).slice(0,2).toUpperCase();return[{type:`shape`,id:`${e}-avatar-bg`,content:{shape:`circle`,fill:C(o.colors.text,.1),stroke:o.colors.textMuted,strokeWidth:2},position:{x:r,y:i,width:`9%`,height:`16%`,anchor:`center`}},{type:`text`,id:`${e}-avatar-initials`,content:{text:s||`?`,style:{fontSize:L(44,a,!0),fontFamily:I(a,`body`),fontWeight:`bold`,color:o.colors.text,textAlign:`center`,verticalAlign:`middle`}},position:{x:r,y:i,width:`9%`,height:`16%`,anchor:`center`}}]}var Gc={title:Bi,sectionHeader:ea,bigText:la,transcript:Vc,content:io,statHighlight:ao,quote:oo,factCard:so,twoColumn:co,dateEvent:uo,imageWithCaption:fo,leftFeature:mo,rightFeature:ho,map:go,fullBleedQuote:_o,list:xo,photoGrid:So,definitionCard:wo,comparisonBar:To,pullQuote:Eo,videoWithCaption:Do,videoPullQuote:Oo,dataTable:ko,barChart:Pc,columnChart:Fc,pieChart:Ic,donutChart:Lc,lineChart:Rc,areaChart:zc,scatterChart:Bc,diagram:zo,tree:Ho,timeline:Xo,layout:As,drawing:gs};function Kc(e){let t={...Gc};if(e)for(let n of e)t[n.name]||(t[n.name]=Qs(n));return t}var qc=[{type:`slowZoom`,direction:`in`},{type:`slowZoom`,direction:`out`},{type:`slowZoom`,panDirection:`left`},{type:`slowZoom`,panDirection:`right`}],Jc=8;function Yc(e){return e===0||e===`0`||e===`0%`}function Xc(e){if(e.type!==`image`&&e.type!==`video`)return!1;let{position:t}=e;if(!Yc(t.x)||!Yc(t.y)||t.width!==`100%`||t.height!==`100%`)return!1;let n=e.content.fit;return n===void 0||n===`cover`}function Zc(e){return e.renderStyle.ambientMotion===!0}function Qc(e,t,n){let r=n.style.animationSpeed??1,i=Zc(n);return r===1&&!i?e:e.map(e=>{let n=e.animation;return!n&&i&&Xc(e)&&(n={...new Se(be(`${t.id}:${e.id}`)).pickRequired(qc),duration:Math.max(Jc,t.duration??0)}),!n||n.type===`none`||r!==1&&(n={...n,...n.duration==null?{}:{duration:n.duration*r},...n.delay==null?{}:{delay:n.delay*r}}),n===e.animation?e:{...e,animation:n}})}function $c(e,t){if(e===t)return 0;let n=e.length,r=t.length;if(n===0)return r;if(r===0)return n;let i=Array(r+1),a=Array(r+1);for(let e=0;e<=r;e++)i[e]=e;for(let o=1;o<=n;o++){a[0]=o;for(let n=1;n<=r;n++){let r=e[o-1]===t[n-1]?0:1;a[n]=Math.min(i[n]+1,a[n-1]+1,i[n-1]+r)}[i,a]=[a,i]}return i[r]}function el(e,t,n){let r=n?.maxDistance??2,i,a=1/0,o=e.toLowerCase();for(let e of t){let t=$c(o,e.toLowerCase());t<a&&(a=t,i=e)}if(i&&(a<=r||a<=Math.ceil(e.length*.4)))return n?.map?n.map(i):i}var tl=[`zoomIn`,`zoomOut`,`panLeft`,`panRight`],nl=[`bottom`,`top`,`center`],rl=[`terrain`,`satellite`,`road`,`toner`,`watercolor`],il=[`neutral`,`somber`,`celebratory`],al=`theme color-scheme name — e.g. 'blue', 'green'`;function ol(e=[]){return[{key:`title`,description:`Optional title above the chart`},{key:`labelColumn`,description:`Category/label column`,valueHint:`header name or 0-based index`},{key:`valueColumns`,description:`Value columns to plot`,coerce:`stringList`,valueHint:`comma-separated header names or 0-based indexes`},{key:`showTable`,description:`Render the source table beneath the chart`,coerce:`boolean`},{key:`showLegend`,description:`Show a series legend`,coerce:`boolean`},{key:`showValues`,description:`Print numeric value labels on marks`,coerce:`boolean`},{key:`unit`,description:`Unit suffix for tick/value labels (e.g. "km")`},{key:`colorScheme`,description:`Color scheme seeding the series color rotation`,valueHint:al},{key:`headers`,description:`Header cells (normally derived from the table)`,coerce:`stringList`},{key:`rows`,description:`Table rows (supply via a data fence)`},...sl(),{key:`sheet`,description:`Worksheet inside the src workbook (XLSX src only)`},{key:`anchor`,description:`Top-left cell of the region inside the src workbook, e.g. 'B7'`},{key:`headerRow`,description:`Whether row 1 of the source region is a header row`,coerce:`boolean`},...e]}function sl(){return[{key:`src`,description:`Container path to a sidecar data file (.csv/.tsv/.xlsx/.parquet) supplying the table`},{key:`previewRows`,description:`Max data rows resolved from src for the bounded preview`,coerce:`number`},{key:`srcStats`,description:`Preview stats recorded by data-reference resolution`},{key:`sort`,description:`Sort order over src data: 'Col:desc,Other' (quote names containing , or :)`},{key:`filter`,description:`Row filter over src data: 'Col=value;Other>=10' (ops = != > < >= <= ~ !~; AND only)`}]}var cl={key:`stacked`,description:`Stack series instead of grouping them side by side`,coerce:`boolean`},ll=[{key:`imageTreatment`,description:`Per-block photographic grade override ('none' opts out)`,values:[`none`,`mono`,`duotone`,`warm`,`cool`]},{key:`useBottomLayer`,description:`Show the doc's bottom persistent layers`,coerce:`boolean`},{key:`useTopLayer`,description:`Show the doc's top persistent layers`,coerce:`boolean`}],ul={title:[{key:`title`,description:`Main title text`},{key:`subtitle`,description:`Subtitle or tagline`},{key:`backgroundColor`,description:`Background color`,valueHint:`CSS color`}],sectionHeader:[{key:`title`,description:`Section title`},{key:`colorScheme`,description:`Fallback background color scheme`,valueHint:al},{key:`imageSrc`,description:`Optional background image path`},{key:`imageAlt`,description:`Alt text for the background image`},{key:`ambientMotion`,description:`Slow zoom/pan effect`,values:tl}],bigText:[{key:`title`,description:`The display text (rendered uppercase)`},{key:`imageSrc`,description:`Optional full-bleed background image path`},{key:`imageAlt`,description:`Alt text for the background image`},{key:`ambientMotion`,description:`Slow zoom/pan effect`,values:tl}],content:[{key:`title`,description:`Heading shown above the complete body`}],transcript:[{key:`speaker`,description:`Speaker display name`},{key:`speakerImage`,description:`Avatar image path (missing → initials medallion)`},{key:`side`,description:`Speaker column side`,values:[`left`,`right`]},{key:`variant`,description:`Beat kind`,values:[`speech`,`thought`,`tool`]},{key:`text`,description:`The message body`},{key:`toolName`,description:`Tool variant: invoked tool name (mono chip)`},{key:`resultText`,description:`Tool variant: bounded result line`},{key:`counterpartName`,description:`Handoff form: receiving speaker name`},{key:`counterpartImage`,description:`Handoff form: receiving speaker avatar path`},{key:`meta`,description:`Muted corner line (timestamp, step)`},{key:`colorScheme`,description:`Accent scheme (tool chip, handoff arrow)`,valueHint:al}],statHighlight:[{key:`stat`,description:`The statistic (e.g. "89%", "2x")`},{key:`description`,description:`What the stat means`},{key:`detail`,description:`Additional detail or context`},{key:`colorScheme`,description:`Color scheme for the stat`,valueHint:al}],quote:[{key:`title`,description:`Optional heading above the quote`},{key:`quote`,description:`The quote text`},{key:`attribution`,description:`Attribution (author, source)`}],pullQuote:[{key:`text`,description:`Quote text`},{key:`attribution`,description:`Attribution`}],twoColumn:[{key:`left`,description:`Left column, as "label|sublabel"`,coerce:`labeledPair`,required:!0},{key:`right`,description:`Right column, as "label|sublabel"`,coerce:`labeledPair`,required:!0},{key:`header`,description:`Optional header above the columns`},{key:`leftColor`,description:`Left column color scheme`,valueHint:al},{key:`rightColor`,description:`Right column color scheme`,valueHint:al}],dateEvent:[{key:`date`,description:`The date (e.g. "July 14, 1974")`},{key:`description`,description:`What happened`},{key:`footer`,description:`Optional footer text`},{key:`mood`,description:`Emotional tone`,values:il}],imageWithCaption:[{key:`imageSrc`,description:`Path to the image file`,required:!0},{key:`imageAlt`,description:`Alt text for accessibility`},{key:`caption`,description:`Caption text`},{key:`captionPosition`,description:`Caption placement`,values:nl},{key:`ambientMotion`,description:`Slow zoom/pan effect`,values:tl},{key:`isTitle`,description:`Style the caption as a title`,coerce:`boolean`},{key:`subtitle`,description:`Subtitle (only when isTitle)`},{key:`imageCredit`,description:`Photo credit / artist name`},{key:`imageLicense`,description:`License identifier`}],leftFeature:dl(),rightFeature:dl(),map:[{key:`center`,description:`Map center as "lat,lng"`,coerce:`latLng`,required:!0},{key:`zoom`,description:`Zoom level (4-16)`,coerce:`number`},{key:`mapStyle`,description:`Map tile style`,values:rl},{key:`title`,description:`Optional title overlay`},{key:`caption`,description:`Optional caption`}],photoGrid:[{key:`images`,description:`Comma-separated image paths`,coerce:`stringList`},{key:`caption`,description:`Optional caption below the grid`},{key:`ambientMotion`,description:`Slow zoom/pan on the largest image`,values:tl}],comparisonBar:[{key:`leftLabel`,description:`Left bar label`,required:!0},{key:`leftValue`,description:`Left bar numeric value`,coerce:`number`,required:!0},{key:`rightLabel`,description:`Right bar label`,required:!0},{key:`rightValue`,description:`Right bar numeric value`,coerce:`number`,required:!0},{key:`unit`,description:`Unit label (e.g. "km")`},{key:`colorScheme`,description:`Color scheme`,valueHint:al}],dataTable:[{key:`title`,description:`Optional title above the table`},{key:`headers`,description:`Comma-separated header cells`,coerce:`stringList`},{key:`rows`,description:`Table rows (supply via a data fence)`},{key:`align`,description:`Per-column alignment (supply via a data fence)`},{key:`colorScheme`,description:`Header color scheme`,valueHint:al},{key:`sheet`,description:`Source worksheet name (XLSX round-trip)`},{key:`anchor`,description:`Top-left cell of the region, e.g. 'B7'`},{key:`role`,description:`What the table holds within its region`,values:[`values`,`formulas`,`loose`]},{key:`headerRow`,description:`Whether row 1 of the source region is a header row`,coerce:`boolean`},{key:`titleAnchor`,description:`Cell this heading text was absorbed from`},...sl()],barChart:ol([cl]),columnChart:ol([cl]),pieChart:ol(),donutChart:ol(),lineChart:ol(),areaChart:ol(),scatterChart:ol(),tree:[{key:`title`,description:`Optional title above the tree`},{key:`colorScheme`,description:`Folder-row color scheme`,valueHint:al},{key:`items`,description:`Tree items (derived from the tree fence)`}],timeline:[{key:`title`,description:`Optional title above the timeline`},{key:`colorScheme`,description:`Track and marker color scheme`,valueHint:al},{key:`tracks`,description:`Timeline tracks and events (supply via template data)`},{key:`links`,description:`Branch links between event ids (supply via template data)`}],videoWithCaption:[{key:`videoSrc`,description:`Path to the video file`,required:!0},{key:`posterSrc`,description:`Poster frame path`},{key:`videoAlt`,description:`Alt text for accessibility`},{key:`clipStart`,description:`Clip start time (seconds)`,coerce:`number`},{key:`clipEnd`,description:`Clip end time (seconds)`,coerce:`number`},{key:`caption`,description:`Caption text`},{key:`captionPosition`,description:`Caption placement`,values:nl},{key:`videoCredit`,description:`Video credit / artist name`},{key:`videoLicense`,description:`License identifier`}]};function dl(){return[{key:`imageSrc`,description:`Path to the feature image`,required:!0},{key:`imageAlt`,description:`Alt text for accessibility`},{key:`imageWidth`,description:`Explicit display width in px`,coerce:`number`},{key:`imageHeight`,description:`Explicit display height in px`,coerce:`number`},{key:`title`,description:`Heading text next to the image`},{key:`body`,description:`Body text below the title`}]}function fl(e){let t=ul[e];if(t)return[...t,...ll]}function pl(e){return new Map(e.map(e=>[e.key,e]))}function ml(e,t){let n={},r=[],i=e?fl(j(e)):void 0,a=i?pl(i):void 0;for(let[e,i]of Object.entries(t)){let{value:t,warning:o}=hl(a?.get(e)?.coerce??`string`,i);o?(r.push(`"${e}": ${o}`),n[e]=i):n[e]=t}return{input:n,warnings:r}}function hl(e,t){switch(e){case`number`:{let e=me(t);return e==null?{value:t,warning:`not a number (${JSON.stringify(t)})`}:{value:e}}case`boolean`:return gl(t);case`latLng`:return _l(t);case`labeledPair`:return{value:vl(t)};case`stringList`:return{value:yl(t)};default:return{value:t}}}function gl(e){let t=e.trim().toLowerCase();return t===`true`||t===``?{value:!0}:t===`false`?{value:!1}:{value:e,warning:`not a boolean (${JSON.stringify(e)}) \u2014 expected true or false`}}function _l(e){let t=e.split(`,`);if(t.length===2){let e=me(t[0]),n=me(t[1]);if(e!=null&&n!=null)return{value:{lat:e,lng:n}}}return{value:e,warning:`not a "lat,lng" pair (${JSON.stringify(e)})`}}function vl(e){let t=e.indexOf(`|`);if(t<0)return{label:e.trim()};let n=e.slice(0,t).trim(),r=e.slice(t+1).trim();return r?{label:n,sublabel:r}:{label:n}}function yl(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function bl(e,t){let n=j(e),r=ul[n];if(!r)return[];let i=[],a=pl([...r,...ll]),o=new Set([...a.keys(),...Object.keys(ae)]);for(let[e,r]of Object.entries(t)){let t=a.get(e);if(!t){if(o.has(e))continue;let t=el(e,o);i.push({kind:`unknown-input`,key:e,message:`Unknown input "${e}" for template "${n}"`+(t?`. Did you mean "${t}"?`:``),...t?{suggestion:t}:{}});continue}if(t.values){let n=r.trim();n!==``&&!t.values.includes(n)&&i.push({kind:`invalid-input-value`,key:e,message:`Invalid value ${JSON.stringify(r)} for "${e}" \u2014 expected one of: ${t.values.join(`, `)}`})}else if(t.coerce&&t.coerce!==`string`){let{warning:n}=hl(t.coerce,r);n&&i.push({kind:`invalid-input-value`,key:e,message:`"${e}": ${n}`})}}for(let e of r)e.required&&t[e.key]==null&&i.push({kind:`missing-input`,key:e.key,message:`Missing required input "${e.key}" for template "${n}"`});return i}var xl=600;function Sl(e,t,n){let r=F(t,`blue`),{layout:i}=t,a=e.title??e.id??``,o=Cl(e),s=[{type:`shape`,id:`fallback-bg`,content:{shape:`rect`,fill:r.bg},position:{x:0,y:0,width:`100%`,height:`100%`}}];return a&&s.push({type:`text`,id:`fallback-title`,content:{text:a,style:{fontSize:L(56,t,!0),fontFamily:I(t,`title`),fontWeight:`bold`,color:r.text,textAlign:`center`}},position:{x:`50%`,y:o?`28%`:`50%`,anchor:`center`,width:i.maxTextWidth}}),o&&s.push({type:`text`,id:`fallback-body`,content:{text:o,style:{fontSize:L(28,t),fontFamily:I(t,`body`),color:r.text,textAlign:`center`}},position:{x:`50%`,y:`55%`,anchor:`center`,width:i.maxTextWidth}}),s.push({type:`text`,id:`fallback-notice`,content:{text:`\u26A0 ${n}`,style:{fontSize:L(18,t),fontFamily:I(t,`body`),color:C(r.text,.6),textAlign:`center`}},position:{x:`50%`,y:`92%`,anchor:`center`,width:i.maxTextWidth}}),s}function Cl(e){if(!e.contents||e.contents.length===0)return``;let t=e.contents.map(e=>o(e)).join(`
|
|
25
|
+
`).trim();return t.length<=xl?t:`${t.slice(0,xl).trimEnd()}\u2026`}var wl={landscape:{wide:`title-stack`,tall:`split`,square:`title-stack`,multiple:`title-stack`},square:{wide:`title-stack`,tall:`split`,square:`title-stack`,multiple:`title-stack`},portrait:{wide:`title-stack`,tall:`title-stack`,square:`title-stack`,multiple:`title-stack`}},Tl={landscape:{wide:`split`,tall:`split`,square:`split`,multiple:`split`},square:{wide:`text-stack`,tall:`split`,square:`text-stack`,multiple:`text-stack`},portrait:{wide:`text-stack`,tall:`text-stack`,square:`text-stack`,multiple:`text-stack`}},El={landscape:{wide:`dense-stack`,tall:`dense-stack`,square:`dense-stack`,multiple:`dense-stack`},square:{wide:`dense-stack`,tall:`dense-stack`,square:`dense-stack`,multiple:`dense-stack`},portrait:{wide:`dense-stack`,tall:`dense-stack`,square:`dense-stack`,multiple:`dense-stack`}},Dl={title:{summary:`Text-only by default; supplemental media gets a title band plus a reserved field.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:wl},sectionHeader:{summary:`Uses its authored background image when present; otherwise supplemental media receives a title composition.`,noMedia:`template-without-optional-media`,ownership:`optional-native`,nativeLayout:`background-image`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`reserve-when-no-native-media`,variants:wl},bigText:{summary:`Uses its authored background image (behind a contrast bloom) when present; otherwise renders gigantic text on the theme surface.`,noMedia:`template-without-optional-media`,ownership:`optional-native`,nativeLayout:`background-image`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`reserve-when-no-native-media`,variants:wl},transcript:{summary:`Speaker avatars are native media (initials medallions when absent); other media stays supplemental.`,noMedia:`template-without-optional-media`,ownership:`optional-native`,nativeLayout:`accent-strip-or-inset`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`reserve-when-no-native-media`,variants:Tl},content:{summary:`Preserves the complete heading and body; supplemental media receives a companion field.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:Tl},statHighlight:{summary:`Uses its optional accent image natively; otherwise supplemental media occupies a companion field.`,noMedia:`template-without-optional-media`,ownership:`optional-native`,nativeLayout:`accent-strip-or-inset`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`reserve-when-no-native-media`,variants:Tl},quote:{summary:`Uses its optional accent image natively; otherwise supplemental media is paired with the quote.`,noMedia:`template-without-optional-media`,ownership:`optional-native`,nativeLayout:`accent-strip-or-inset`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`reserve-when-no-native-media`,variants:Tl},factCard:{summary:`Uses its optional accent image natively; otherwise supplemental media is paired with the fact card.`,noMedia:`template-without-optional-media`,ownership:`optional-native`,nativeLayout:`accent-strip-or-inset`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`reserve-when-no-native-media`,variants:Tl},twoColumn:{summary:`Text comparison by default; supplemental media stacks below the dense two-column panel.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:El},dateEvent:{summary:`Uses its optional accent image natively; otherwise supplemental media is paired with the event.`,noMedia:`template-without-optional-media`,ownership:`optional-native`,nativeLayout:`accent-strip-or-inset`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`reserve-when-no-native-media`,variants:Tl},imageWithCaption:{summary:`Requires one primary image and owns its full-bleed image/caption geometry.`,noMedia:`unsupported`,ownership:`required-native`,nativeLayout:`full-bleed-image`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},leftFeature:{summary:`Requires a primary image in the left feature cell; text occupies the right cell.`,noMedia:`unsupported`,ownership:`required-native`,nativeLayout:`feature-left`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},rightFeature:{summary:`Requires a primary image in the right feature cell; text occupies the left cell.`,noMedia:`unsupported`,ownership:`required-native`,nativeLayout:`feature-right`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},map:{summary:`The map canvas is the primary visual; other media must not reflow its geography.`,noMedia:`intrinsic-visual`,ownership:`intrinsic-visual`,nativeLayout:`map-canvas`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},fullBleedQuote:{summary:`Despite its name this is text-only; supplemental media receives the same dramatic title treatment.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:wl},list:{summary:`Uses its optional accent image natively; otherwise supplemental media is paired with the list.`,noMedia:`template-without-optional-media`,ownership:`optional-native`,nativeLayout:`accent-strip-or-inset`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`reserve-when-no-native-media`,variants:Tl},photoGrid:{summary:`Requires a primary image collection and owns the complete tiled media field.`,noMedia:`unsupported`,ownership:`required-native`,nativeLayout:`photo-grid`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},definitionCard:{summary:`Uses its optional accent image natively; otherwise supplemental media is paired with the definition.`,noMedia:`template-without-optional-media`,ownership:`optional-native`,nativeLayout:`accent-strip-or-inset`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`reserve-when-no-native-media`,variants:Tl},comparisonBar:{summary:`Data bars are primary; supplemental media stacks below to preserve horizontal scale.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:El},pullQuote:{summary:`Requires and owns a full-bleed background image behind the quote lockup.`,noMedia:`unsupported`,ownership:`required-native`,nativeLayout:`full-bleed-image`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},videoWithCaption:{summary:`Requires one primary video and owns its full-bleed video/caption geometry.`,noMedia:`unsupported`,ownership:`required-native`,nativeLayout:`full-bleed-video`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},videoPullQuote:{summary:`Requires and owns a full-bleed video behind the quote lockup.`,noMedia:`unsupported`,ownership:`required-native`,nativeLayout:`full-bleed-video`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},dataTable:{summary:`The table remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:El},barChart:{summary:`The chart remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:El},columnChart:{summary:`The chart remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:El},pieChart:{summary:`The chart remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:El},donutChart:{summary:`The chart remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:El},lineChart:{summary:`The chart remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:El},areaChart:{summary:`The chart remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:El},scatterChart:{summary:`The chart remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:El},diagram:{summary:`The node-and-edge canvas is intrinsic media and retains its spatial coordinate system.`,noMedia:`intrinsic-visual`,ownership:`intrinsic-visual`,nativeLayout:`spatial-canvas`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},tree:{summary:`The interactive tree canvas is intrinsic media and retains its full layout region.`,noMedia:`intrinsic-visual`,ownership:`intrinsic-visual`,nativeLayout:`spatial-canvas`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},timeline:{summary:`The track canvas is intrinsic media and retains its shared horizontal time scale.`,noMedia:`intrinsic-visual`,ownership:`intrinsic-visual`,nativeLayout:`spatial-canvas`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},layout:{summary:`The authored layer canvas is intrinsic media and must preserve absolute placement.`,noMedia:`intrinsic-visual`,ownership:`intrinsic-visual`,nativeLayout:`freeform-canvas`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`},drawing:{summary:`The drawing canvas is intrinsic media and must preserve authored geometry.`,noMedia:`intrinsic-visual`,ownership:`intrinsic-visual`,nativeLayout:`freeform-canvas`,additionalMediaLayout:`overlay-inset`,unconsumedMedia:`retain-native-layout`}};function Ol(e){if(e)return Dl[e]}function X(e,t,n,r,i){return{x:e.width*t,y:e.height*n,width:e.width*r,height:e.height*i}}function kl(e,t){if(e>1)return`multiple`;let n=t[0]??16/9;return n<.8?`tall`:n>1.25?`wide`:`square`}function Al(e,t){return t===`portrait`?{contentRect:X(e,.06,.04,.88,.3),mediaRect:X(e,.06,.39,.88,.55),fontScale:.76}:t===`square`?{contentRect:X(e,.05,.04,.9,.33),mediaRect:X(e,.07,.42,.86,.51),fontScale:.72}:{contentRect:X(e,.04,.03,.92,.32),mediaRect:X(e,.08,.4,.84,.52),fontScale:.72}}function jl(e,t){let n=t===`square`;return{contentRect:X(e,n?.05:.04,.05,n?.42:.43,.9),mediaRect:X(e,n?.52:.53,.07,.43,.86),fontScale:.72}}function Ml(e,t,n){return t===`portrait`?{contentRect:X(e,.06,.04,.88,n?.41:.36),mediaRect:X(e,.06,n?.5:.45,.88,n?.44:.49),fontScale:n?.42:.44}:t===`square`?{contentRect:X(e,.05,.04,.9,n?.43:.36),mediaRect:X(e,.07,n?.52:.45,.86,n?.41:.48),fontScale:n?.45:.46}:{contentRect:X(e,.05,.03,.9,n?.46:.35),mediaRect:X(e,.07,n?.55:.43,.86,n?.38:.49),fontScale:n?.5:.48}}function Nl(e,t){let n=_(e);if(n===`portrait`)switch(t){case`tall`:return X(e,.55,.5,.38,.44);case`square`:return X(e,.49,.58,.44,.35);case`multiple`:return X(e,.07,.67,.86,.27);case`wide`:return X(e,.07,.71,.86,.23)}if(n===`square`)switch(t){case`tall`:return X(e,.68,.1,.27,.8);case`square`:return X(e,.55,.52,.4,.4);case`multiple`:return X(e,.08,.62,.84,.31);case`wide`:return X(e,.08,.68,.84,.27)}switch(t){case`tall`:return X(e,.7,.1,.26,.8);case`square`:return X(e,.62,.22,.34,.56);case`multiple`:return X(e,.52,.5,.44,.42);case`wide`:return X(e,.54,.58,.42,.34)}}function Pl(e,t){let n=_(t);switch(e){case`title-stack`:return Al(t,n);case`split`:return jl(t,n);case`text-stack`:return Ml(t,n,!1);case`dense-stack`:return Ml(t,n,!0)}}function Z(e,t){if(e===void 0)return 0;if(typeof e==`number`)return e;let n=e.match(/^\s*(-?\d+(?:\.\d+)?)%\s*$/);if(n)return Number(n[1])/100*t;let r=Number.parseFloat(e);return Number.isFinite(r)?r:0}function Fl(e){return e===0||e===`0`||e===`0%`}function Il(e,t){if(e.type!==`shape`&&e.type!==`image`)return!1;let{position:n}=e,r=n.width===`100%`||n.width===t.width,i=n.height===`100%`||n.height===t.height;return Fl(n.x)&&Fl(n.y)&&r&&i}function Ll(e,t,n){let r={...e,x:t.x+Z(e.x,n.width)/n.width*t.width,y:t.y+Z(e.y,n.height)/n.height*t.height};return e.width!==void 0&&(r.width=Z(e.width,n.width)/n.width*t.width),e.height!==void 0&&(r.height=Z(e.height,n.height)/n.height*t.height),r}function Rl(e,t,n,r){let i=n.width/t.width,a=n.height/t.height,o=Math.min(i,a);return e.map(e=>{let s={...e.position,x:n.x+Z(e.position.x,t.width)*i,y:n.y+Z(e.position.y,t.height)*a,...e.position.width===void 0?{}:{width:Z(e.position.width,t.width)*i},...e.position.height===void 0?{}:{height:Z(e.position.height,t.height)*a}},c={...e,id:`${r}-${e.id}`,position:s};return e.type===`path`?{...c,type:`path`,content:{...e.content,d:zl(e.content.d,i,a,n.x,n.y),...e.content.strokeWidth===void 0?{}:{strokeWidth:e.content.strokeWidth*o}}}:e.type===`text`&&o!==1?{...c,type:`text`,content:{...e.content,style:{...e.content.style,fontSize:Math.max(10,e.content.style.fontSize*o)}}}:c})}function zl(e,t,n,r,i){let a=e.match(/[a-zA-Z]|[-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/gi);if(!a)return e;let o=``,s=0;return a.map(e=>{if(/^[a-zA-Z]$/.test(e))return o=e,s=0,e;let a=Number(e);if(!Number.isFinite(a)||o===o.toLowerCase())return s++,e;let c=s++,l=a;switch(o){case`M`:case`L`:case`T`:case`C`:case`S`:case`Q`:l=c%2==0?a*t+r:a*n+i;break;case`H`:l=a*t+r;break;case`V`:l=a*n+i;break;case`A`:{let e=c%7;e===0?l=a*t:e===1?l=a*n:e===5?l=a*t+r:e===6&&(l=a*n+i);break}}return String(Math.round(l*1e3)/1e3)}).join(` `)}function Bl(e,t,n,r,i){return Vl(e.map(e=>{if(Il(e,n))return e;let i=Ll(e.position,t,n);return e.type===`text`?{...e,position:i,content:{...e.content,style:{...e.content.style,fontSize:Math.max(12,Math.round(e.content.style.fontSize*r)),...e.content.style.padding===void 0?{}:{padding:Math.round(e.content.style.padding*r)}}}}:{...e,position:i}}),i,t,n)}function Vl(e,t,n,r){let i=n.x+n.width/2,a=n.y+n.height/2;if(t===`sectionHeader`)return e.map(e=>{if(e.id===`title`)return{...e,position:{...e.position,x:i,y:a,width:n.width*.9,anchor:`center`}};if(e.id===`line-top`||e.id===`line-bottom`){let t=e.id===`line-top`?-1:1;return{...e,position:{...e.position,x:i,y:a+t*n.height*.28,width:Math.min(n.width*.22,r.width*.2),height:2,anchor:`center`}}}return e});if(t!==`title`)return e;let o=e.find(e=>e.type===`text`&&e.id===`title`),s=e.find(e=>e.type===`text`&&e.id===`subtitle`);if(!o||o.type!==`text`)return e;let c=s?.type===`text`?s:void 0,l=n.width*.9,u=Math.max(12,Math.min(r.width,r.height)*.018),d=c?u:0,f=n.height*.78,p=o.content.style.fontSize,m=c?.content.style.fontSize??0,h=()=>{let e=H(o.content.text,p,l,o.content.style.lineHeight??1.15),t=c?H(c.content.text,m,l,c.content.style.lineHeight??1.5):0;return{titleHeight:e,subtitleHeight:t,total:e+d+t}},g=h();if(g.total>f){let e=Math.max(.5,f/g.total);p=Math.max(18,Math.round(p*e)),m=Math.max(14,Math.round(m*e)),g=h()}let _=n.y+(n.height-g.total)/2,v=_+g.titleHeight/2,y=_+g.titleHeight+d+g.subtitleHeight/2;return e.map(e=>e.id===`title`&&e.type===`text`?{...e,position:{...e.position,x:i,y:v,width:l,anchor:`center`},content:{...e.content,style:{...e.content.style,fontSize:p}}}:e.id===`subtitle`&&e.type===`text`?{...e,position:{...e.position,x:i,y,width:l,anchor:`center`},content:{...e.content,style:{...e.content.style,fontSize:m}}}:e.id===`accent-line`?{...e,position:{...e.position,x:i,y:Math.max(n.y+2,_-u*.75),width:Math.min(n.width*.18,r.width*.12),height:3,anchor:`center`}}:e)}function Hl(e,t,n,r){let i=e.width?Z(e.width,t.width):n,a=e.height?Z(e.height,t.height):r,o=Z(e.x,t.width),s=Z(e.y,t.height),c=e.anchor??`top-left`;return c===`center`?(o-=i/2,s-=a/2):(c.endsWith(`right`)&&(o-=i),c.startsWith(`bottom`)&&(s-=a)),{x:o,y:s,width:i,height:a}}function Ul(e,t){return Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))}function Wl(e,t){let n=e.filter(e=>e.type!==`shape`&&e.type!==`path`&&e.type!==`mermaid`).map(e=>Hl(e.position,t,e.type===`text`?t.width*.45:t.width*.5,e.type===`text`?t.height*.2:t.height*.55));return n.length===0?X(t,.06,.08,.88,.84):[X(t,.52,.12,.44,.76),X(t,.04,.12,.44,.76),X(t,.15,.53,.7,.41)].reduce((e,t)=>n.reduce((e,n)=>e+Ul(t,n),0)<n.reduce((t,n)=>t+Ul(e,n),0)?t:e)}function Gl(e,t,n,r,i){let a=Ol(t),o=kl(r,i),s=e.some(e=>e.type===`image`||e.type===`video`||e.type===`map`||e.type===`mermaid`),c=a?.unconsumedMedia===`retain-native-layout`||a?.unconsumedMedia===`reserve-when-no-native-media`&&s;if(a?.additionalMediaLayout===`overlay-inset`&&c)return{layers:e,mediaRect:Nl(n,o),framed:!0};let l=a?.unconsumedMedia===`reserved-slot`||a?.unconsumedMedia===`reserve-when-no-native-media`&&!s;if(!a||!l||!a.variants)return{layers:e,mediaRect:Wl(e,n),framed:!1};let u=_(n),d=Pl(a.variants[u][o],n);return{layers:Bl(e,d.contentRect,n,d.fontScale,t??``),mediaRect:d.mediaRect,framed:!0}}function Kl(e,t={}){return ql(e,t,{registry:t.customTemplates&&t.customTemplates.length>0?Kc(t.customTemplates):Gc})}function ql(e,t,n){let r=t.theme??A,i=t.viewport??f.landscape,a=t.blockIndex??0,o=t.totalBlocks??1,c=t.persistentLayers===!1?void 0:t.persistentLayers??r.persistentLayers,l=e.layers;if(l&&l.length>0&&!u(e))return{layers:iu(tu(s(l),e,r,i),e,r,c,n.expandedPersistentLayers),source:`authored`};if(!u(e)){let t=tu([],e,r,i);return{layers:iu(t,e,r,c,n.expandedPersistentLayers),source:t.length>0?`rich-content`:`empty`}}let d=n.templateContext?s(n.templateContext):p(r,a,o,i);d.block=s(e);let m=nu(e,d,n.registry);if(m.status===`ok`)return{layers:iu(tu(n.applyRenderStyle===!1?m.layers:Qc(m.layers,e,r),e,r,i),e,r,c,n.expandedPersistentLayers),source:`template`};let h=ru(e.template,m);if((t.failureMode??`fallback`)===`empty`){let t=tu([],e,r,i);return{layers:iu(t,e,r,c,n.expandedPersistentLayers),source:t.length>0?`rich-content`:`empty`,diagnostic:h}}return{layers:iu(tu(Sl(e,d,h.message),e,r,i),e,r,c,n.expandedPersistentLayers),source:`fallback`,diagnostic:h}}function Jl(e){return(e.contents??[]).filter(e=>e.type===`code`&&e.lang?.trim().toLowerCase()===`mermaid`).map(e=>e.value).filter(e=>e.trim().length>0)}function Yl(e){let t=e.template?j(e.template):void 0,n=(e.contents??[]).filter(e=>e.type===`code`),r=[];for(let e of n){if(t!==`diagram`&&sn(e.lang)){let t=ln(e.value,{explicit:cn(e.lang)});if(t.isDiagram&&t.diagram){r.push({kind:`spatial`,template:`diagram`,data:_a(t.diagram),aspectRatio:16/9});continue}}if(t!==`tree`&&Yr(e.lang)){let t=Zr(e.value,{explicit:Xr(e.lang)});if(t.isTree&&t.tree){r.push({kind:`spatial`,template:`tree`,data:Ta(t.tree),aspectRatio:3/4});continue}}if(t!==`timeline`&&xr(e.lang)){let t=Cr(e.value,{explicit:Sr(e.lang)});t.isTimeline&&t.timeline&&r.push({kind:`spatial`,template:`timeline`,data:Ca(t.timeline),aspectRatio:16/9})}}return r}function Xl(e,t){let n=new Set(e.filter(e=>e.type===`image`).map(e=>e.content.src)),r=new Set(e.filter(e=>e.type===`video`).map(e=>e.content.src)),i=new Set(e.filter(e=>e.type===`mermaid`).map(e=>e.content.source)),a=Ha(t.contents),o=a.filter(e=>!r.has(e.src)),s=new Set(a.map(e=>e.src)),c=new Set(n),l=Ba(t.contents).filter(e=>s.has(e.src)||c.has(e.src)?!1:(c.add(e.src),!0)),u=Jl(t).filter(e=>!i.has(e));return[...l.map(e=>({kind:`image`,src:e.src,alt:e.alt,...e.width&&e.height?{aspectRatio:e.width/e.height}:{}})),...o.map(e=>({kind:`video`,src:e.src,...e.posterSrc?{posterSrc:e.posterSrc}:{},alt:e.alt,aspectRatio:16/9,...e.startAt==null?{}:{startAt:e.startAt},...e.clipStart==null?{}:{clipStart:e.clipStart},...e.clipEnd==null?{}:{clipEnd:e.clipEnd}})),...u.map(e=>({kind:`mermaid`,source:e,aspectRatio:16/9})),...Yl(t)]}function Zl(e,t,n,r){let i=Math.min(n.width,n.height),a=r?i*.025:0,o=t>1?i*.018:0,s={x:e.x+a,y:e.y+a,width:Math.max(0,e.width-a*2),height:Math.max(0,e.height-a*2)},c=Math.min(t,Math.max(1,Math.ceil(Math.sqrt(t*(s.width/Math.max(1,s.height)))))),l=Math.ceil(t/c),u=(s.width-o*(c-1))/c,d=(s.height-o*(l-1))/l;return Array.from({length:t},(e,t)=>({x:s.x+t%c*(u+o),y:s.y+Math.floor(t/c)*(d+o),width:u,height:d}))}function Ql(e,t){let n=t.imageTreatment;if(n===`none`)return;let r=n?{type:n,strength:e.style.imageTreatment?.strength}:e.style.imageTreatment;if(!(!r||r.type===`none`))return r.type===`duotone`&&!r.color?{...r,color:e.colors.primary}:r}function $l(e,t,n,r,i){if(e.kind===`image`){let a=Ql(r,n);return[{id:`${n.id}-embedded-image-${i}`,type:`image`,position:t,content:{src:e.src,alt:e.alt||n.title||`Embedded image`,fit:`contain`,...a?{treatment:a}:{}}}]}if(e.kind===`video`){let r=Math.max(0,e.clipStart??0);return[{id:`${n.id}-embedded-video-${i}`,type:`video`,position:t,content:{src:e.src,...e.posterSrc?{posterSrc:e.posterSrc}:{},alt:e.alt||n.title||`Embedded video`,fit:`contain`,clipStart:r,clipEnd:Math.max(r,e.clipEnd??r+Math.max(0,n.duration)),...e.startAt==null?{}:{startAt:Math.max(0,e.startAt)}}}]}if(e.kind===`mermaid`)return[{id:`${n.id}-mermaid-${i}`,type:`mermaid`,position:t,content:{source:e.source,background:r.colors.backgroundLight,foreground:r.colors.text,padding:Math.max(12,Math.round(Math.min(t.width,t.height)*.025))}}];let a={width:t.width,height:t.height,name:`Embedded ${e.template}`},o=p(r,0,1,a);o.block=s(n);let c={id:`${n.id}-embedded-${e.template}-${i}`,duration:n.duration,audioSegment:n.audioSegment,...e.data};return Rl(e.template===`timeline`?Xo({...c,template:`timeline`},o):e.template===`tree`?Ho({...c,template:`tree`},o):zo({...c,template:`diagram`},o),a,t,`${n.id}-embedded-${e.template}-${i}`)}function eu(e,t){let n=new Map(Ha(t.contents).filter(e=>e.startAt!=null||e.clipStart!=null||e.clipEnd!=null).map(e=>[e.src,e]));return n.size===0?e:e.map(e=>{if(e.type!==`video`)return e;let r=n.get(e.content.src);if(!r)return e;let i=Math.max(0,r.clipStart??e.content.clipStart);return{...e,content:{...e.content,clipStart:i,clipEnd:Math.max(i,r.clipEnd??(r.clipStart==null?e.content.clipEnd:i+Math.max(0,t.duration))),...r.startAt==null?{}:{startAt:Math.max(0,r.startAt)}}}})}function tu(e,t,n,r){let i=eu(e,t),a=Xl(i,t);if(a.length===0)return i;let o=Gl(i,t.template?j(t.template):void 0,r,a.length,a.map(e=>e.aspectRatio)),s=Zl(o.mediaRect,a.length,r,o.framed),c={image:0,video:0,mermaid:0,spatial:0},l=a.flatMap((e,r)=>(c[e.kind]+=1,$l(e,s[r],t,n,c[e.kind]))),u=o.framed?{id:`${t.id}-rich-media-frame`,type:`shape`,position:o.mediaRect,content:{shape:`rect`,fill:n.colors.backgroundLight,stroke:C(n.colors.text,.14),strokeWidth:2,borderRadius:Math.max(12,Math.round(Math.min(r.width,r.height)*.018))}}:void 0;return[...o.layers,...u?[u]:[],...l]}function nu(e,t,n){let r=s(e),i=s(t),a=r.children;(!i.children||i.children.length===0)&&a?.length&&(i.children=a);let o=n[j(r.template)];if(!o)return{status:`unknown-template`,layers:[]};let{templateData:c,templateOverrides:l}=r,u=r,d=u.sourceHeading?$a(r.template,u.title??``,u.contents):null,f=ml(r.template,l??{}).input,p=d||c||l?{...d,...r,...c,...f}:r,m=Object.prototype.hasOwnProperty.call(f,`quote`)?f.quote:Object.prototype.hasOwnProperty.call(c??{},`quote`)?c?.quote:Object.prototype.hasOwnProperty.call(r,`quote`)?r.quote:void 0;if(j(r.template)===`quote`&&d&&!Object.prototype.hasOwnProperty.call(d,`title`)&&!(typeof m==`string`&&m.trim())){let e=p;e.quote=d.quote,!Object.prototype.hasOwnProperty.call(c??{},`title`)&&!Object.prototype.hasOwnProperty.call(f,`title`)&&delete e.title}try{let e=o(p,i);return Array.isArray(e)?{status:`ok`,layers:s(e)}:{status:`invalid-result`,layers:[],receivedType:typeof e}}catch(e){return{status:`error`,layers:[],error:e}}}function ru(e,t){return t.status===`unknown-template`?{code:`unknown-template`,template:e,message:`Unknown template "${e}"`}:t.status===`invalid-result`?{code:`invalid-template-result`,template:e,receivedType:t.receivedType,message:`Template "${e}" returned ${t.receivedType}, not a layer array`}:{code:`template-error`,template:e,cause:t.error,message:`Template "${e}" failed`}}function iu(e,t,n,r,i){return r?Di(e,t,i?.bottomLayers??wi(r.bottomLayers,n),i?.topLayers??wi(r.topLayers,n)):e}var au={title:{label:`Title`,description:`A bold opening slide with large title text, perfect for covers and chapters.`},sectionHeader:{label:`Section Header`,description:`A clean section break with a prominent title and optional background image.`},bigText:{label:`Big Text`,description:`Gigantic uppercase display text — thumbnail-style — on a theme surface or over an image with a contrast bloom.`},transcript:{label:`Transcript`,description:`A conversational beat: speaker avatar and message bubble, with thought, tool, and two-speaker handoff variants.`},content:{label:`Content`,description:`Shows a heading and the complete body in a loss-averse content-first layout.`},statHighlight:{label:`Stat Highlight`,description:`Showcases a single key number or metric with supporting context.`},quote:{label:`Quote`,description:`Displays a stylized pull quote with decorative marks and attribution.`},factCard:{label:`Fact Card`,description:`Presents a focused fact or insight with a labeled header and body text.`},twoColumn:{label:`Two Column`,description:`Divides the slide into two equal side-by-side content columns.`},dateEvent:{label:`Date Event`,description:`Highlights a date-based event or milestone with a prominent date display.`},imageWithCaption:{label:`Image with Caption`,description:`Displays a full-bleed image with an optional caption below.`},leftFeature:{label:`Left Feature`,description:`Image on the left, title and body text stacked on the right.`},rightFeature:{label:`Right Feature`,description:`Image on the right, title and body text stacked on the left.`},map:{label:`Map`,description:`Embeds an interactive map centered on a geographic location.`},fullBleedQuote:{label:`Full Bleed Quote`,description:`A full-width quote that spans the entire slide for maximum impact.`},list:{label:`List`,description:`Renders a bulleted or numbered list in a clean, card-style layout.`},photoGrid:{label:`Photo Grid`,description:`Arranges multiple photos in a 2×2 or 3×3 mosaic grid.`},definitionCard:{label:`Definition Card`,description:`Shows a term and its definition in a structured, dictionary-style card.`},comparisonBar:{label:`Comparison Bar`,description:`Visualizes two or more values side-by-side with labeled horizontal bars.`},pullQuote:{label:`Pull Quote`,description:`A stylized pull quote with large decorative marks and centered text.`},videoWithCaption:{label:`Video with Caption`,description:`Embeds a video player with an optional caption below.`},videoPullQuote:{label:`Video Pull Quote`,description:`Combines a video panel with a highlighted pull quote side-by-side.`},dataTable:{label:`Data Table`,description:`Renders tabular data in a clean, styled table with a header row.`},barChart:{label:`Bar Chart`,description:`Horizontal bars from the block's markdown table — one bar per row.`},columnChart:{label:`Column Chart`,description:`Vertical columns from the block's markdown table — one column per row.`},pieChart:{label:`Pie Chart`,description:`A pie of the block's markdown table — each row becomes a labeled slice.`},donutChart:{label:`Donut Chart`,description:`A donut of the block's markdown table — each row becomes a labeled slice.`},lineChart:{label:`Line Chart`,description:`Lines from the block's markdown table — one line per value column.`},areaChart:{label:`Area Chart`,description:`Filled area lines from the block's markdown table — one area per value column.`},scatterChart:{label:`Scatter Chart`,description:`An x/y scatter plot from the block's markdown table's numeric columns.`},diagram:{label:`Diagram`,description:`Renders sub-headings as connected nodes — edit visually as a node-and-edge diagram.`},tree:{label:`Tree`,description:`Renders an ASCII file-tree / outline fence as a filesystem-style treeview — edit as an outline.`},timeline:{label:`Timeline`,description:`Plots events across one or more horizontal tracks with callouts and optional branching links.`},layout:{label:`Layout`,description:`Free-form 2D canvas — drag layers into place. Use for one-off block layouts that don't fit a template.`},drawing:{label:`Drawing`,description:`Free-form sketches — draw shapes, paths, and text directly on a 2D surface.`}},ou={title:{role:`opener`,bodyPolicy:`ignored`,safeForContentFirst:!1,placement:`heading`},sectionHeader:{role:`divider`,bodyPolicy:`ignored`,safeForContentFirst:!1,placement:`heading`},bigText:{role:`opener`,bodyPolicy:`ignored`,safeForContentFirst:!1,placement:`heading`},content:{role:`content`,bodyPolicy:`complete`,safeForContentFirst:!0,placement:`heading`},transcript:{role:`content`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},statHighlight:{role:`highlight`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},quote:{role:`quote`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},factCard:{role:`highlight`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},twoColumn:{role:`comparison`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},dateEvent:{role:`event`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},imageWithCaption:{role:`media`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},leftFeature:{role:`media`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},rightFeature:{role:`media`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},map:{role:`spatial`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},fullBleedQuote:{role:`quote`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},list:{role:`content`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},photoGrid:{role:`media`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},definitionCard:{role:`content`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},comparisonBar:{role:`comparison`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},pullQuote:{role:`quote`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},videoWithCaption:{role:`media`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},videoPullQuote:{role:`media`,bodyPolicy:`derived`,safeForContentFirst:!1,placement:`heading`},dataTable:{role:`data`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},barChart:{role:`data`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},columnChart:{role:`data`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},pieChart:{role:`data`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},donutChart:{role:`data`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},lineChart:{role:`data`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},areaChart:{role:`data`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},scatterChart:{role:`data`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},diagram:{role:`spatial`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},tree:{role:`spatial`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},timeline:{role:`spatial`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},drawing:{role:`spatial`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`},layout:{role:`spatial`,bodyPolicy:`structured`,safeForContentFirst:!1,placement:`heading`}},su=120,cu=26,lu=62;function uu(e){let t=e.trim().length;if(t<=cu)return su;let n=su*Math.sqrt(cu/t);return Math.max(lu,Math.round(n))}function du(e){let{theme:t}=e;return t.id===`standard`&&x(t.colors.background)>.85}var fu=[{pos:0,alpha:.95},{pos:38,alpha:.86},{pos:58,alpha:.4},{pos:78,alpha:.1},{pos:100,alpha:0}];function pu(e){return`linear-gradient(0deg, ${fu.map(t=>`${C(e,t.alpha)} ${t.pos}%`).join(`, `)})`}function mu(e,t){let n=B(t,e.imageTreatment),{heroSrc:r,heroAlt:i,title:a,subtitle:o,ambientMotion:s,heroCredit:c,heroLicense:l}=e,{theme:u,layout:d}=t,f=!r&&du(t),p=L(uu(a),t,!0),m=L(40,t,!1),h=[];if(r){let e=Ui(s);h.push({type:`image`,id:`cover-hero`,content:{src:r,alt:i||a,fit:`cover`,credit:c,license:l,...n?{treatment:n}:{}},position:{x:0,y:0,width:`100%`,height:`100%`},animation:e},{type:`shape`,id:`cover-gradient`,content:{shape:`rect`,fill:pu(u.colors.background)},position:{x:0,y:0,width:`100%`,height:`100%`}})}else f?h.push({type:`shape`,id:`cover-bg`,content:{shape:`rect`,fill:u.colors.background},position:{x:0,y:0,width:`100%`,height:`100%`}},{type:`shape`,id:`cover-bg-tint`,content:{shape:`rect`,fill:`radial-gradient(ellipse at 50% 40%, ${C(u.colors.primary,.16)} 0%, ${C(u.colors.primary,.07)} 38%, ${C(u.colors.primary,0)} 78%)`},position:{x:0,y:0,width:`100%`,height:`100%`}}):h.push({type:`shape`,id:`cover-bg`,content:{shape:`rect`,fill:`radial-gradient(ellipse at 50% 40%, ${u.colors.primary} 0%, ${u.colors.background} 100%)`},position:{x:0,y:0,width:`100%`,height:`100%`}}),h.push({type:`shape`,id:`cover-accent`,content:{shape:`rect`,fill:f?C(u.colors.primary,.24):`rgba(255, 255, 255, 0.2)`},position:{x:`35%`,y:o?`42%`:`58%`,width:`30%`,height:`2px`}});return h.push({type:`text`,id:`cover-title`,content:{text:a,style:{fontSize:p,fontFamily:I(t,`title`),fontWeight:`bold`,color:u.colors.text,textAlign:`center`,shadow:!f}},position:{x:`50%`,y:r?o?`70%`:`75%`:o?d.primaryY:`50%`,anchor:`center`,width:d.maxTextWidth},animation:{type:`fadeIn`,duration:.8}}),o&&h.push({type:`text`,id:`cover-subtitle`,content:{text:o,style:{fontSize:m,fontFamily:I(t,`body`),fontWeight:f?`bold`:`normal`,color:f?C(u.colors.text,.78):u.colors.textMuted,textAlign:`center`,lineHeight:1.5}},position:{x:`50%`,y:r?`82%`:d.secondaryY,anchor:`center`,width:d.maxTextWidth},animation:{type:`fadeIn`,duration:.8,delay:.2}}),h}function hu(e){return{heroSrc:e.heroSrc,heroAlt:e.heroAlt,title:e.title,subtitle:e.subtitle,ambientMotion:e.ambientMotion,heroCredit:e.heroCredit,heroLicense:e.heroLicense}}function gu(e,t,n=`cover`){let r=hu(e),i={id:`cover-block`,duration:0,audioSegment:-1};if(n===`title`)return Bi({...i,template:`title`,title:r.title,subtitle:r.subtitle},t);if(n===`sectionHeader`)return ea({...i,template:`sectionHeader`,title:r.title,imageSrc:r.heroSrc,imageAlt:r.heroAlt,ambientMotion:r.ambientMotion},t);if(n===`bigText`||n===`bigTextImage`){let e=n===`bigTextImage`&&!!r.heroSrc;return la({...i,template:`bigText`,title:r.title,...e?{imageSrc:r.heroSrc,imageAlt:r.heroAlt??r.title,ambientMotion:r.ambientMotion}:{}},t)}return n===`imageWithCaption`?r.heroSrc?fo({...i,template:`imageWithCaption`,imageSrc:r.heroSrc,imageAlt:r.heroAlt??r.title,caption:r.title,subtitle:r.subtitle,ambientMotion:r.ambientMotion,imageCredit:r.heroCredit,imageLicense:r.heroLicense,isTitle:!0},t):Bi({...i,template:`title`,title:r.title,subtitle:r.subtitle},t):mu(r,t)}function _u(e,t,n,r,i,a,o,c,l,d){let f=ql(e,{theme:r,viewport:i,persistentLayers:a??!1,blockIndex:t,totalBlocks:n,failureMode:l},{registry:c,expandedPersistentLayers:o});f.diagnostic&&d?.(f.diagnostic,e,t);let p=u(e)?{id:e.id,startTime:0,duration:e.duration,audioSegment:e.audioSegment,...f.layers.length>0?{layers:f.layers}:{},transition:e.transition,template:e.template}:{...s(e),...f.layers.length>0?{layers:f.layers}:{}},m=v(p,r,t);return m!==p.transition&&(p.transition=m),p}function vu(e,t={}){let n=t,r=n.theme??A,i=n.viewport??f.landscape,{persistentLayers:a,audioSegments:o,customTemplates:c,failureMode:l=`fallback`,onDiagnostic:u,splitLongBlocks:d=!0,mergeShortBlocks:p=!0}=n,m=e.length,h=c&&c.length>0?Kc(c):Gc,g=a===!1?void 0:a??r.persistentLayers,_=g?{bottomLayers:wi(g.bottomLayers,r),topLayers:wi(g.topLayers,r)}:void 0;if(!o||o.length===0){let t=0;return e.map((e,n)=>{let a=_u(e,n,m,r,i,g,_,h,l,u);return a.startTime=t,t+=a.duration,a})}let v=new Map;e.forEach((e,t)=>{let n=e.audioSegment??0;v.has(n)||v.set(n,[]),v.get(n).push({block:e,originalIndex:t})});let y=Array(e.length);for(let[e,t]of v){let n=o[e];if(!n){let e=0;for(let{block:n,originalIndex:a}of t){let t=_u(n,a,m,r,i,g,_,h,l,u);t.startTime=e,e+=t.duration,y[a]=t}continue}let a=[],c=[];for(let e of t)e.block.template===`sectionHeader`?a.push(e):c.push(e);let f=a.reduce((e,{block:t})=>e+(t.duration??0),0),v=c.reduce((e,{block:t})=>e+(t.duration??0),0),b=n.duration-f,x=v>0&&b>0?b/v:1,S=[];for(let{block:e,originalIndex:n}of t){let t=_u(e,n,m,r,i,g,_,h,l,u),a=e;S.push({block:t,originalIndex:n,templateBlock:a,hasSourceTiming:typeof a.sourceStartTime==`number`})}let C=S.some(e=>e.hasSourceTiming);S.sort((e,t)=>{if(C){let n=e.templateBlock.template===`sectionHeader`,r=t.templateBlock.template===`sectionHeader`;if(n&&!r)return-1;if(!n&&r)return 1;if(e.hasSourceTiming&&t.hasSourceTiming)return e.templateBlock.sourceStartTime-t.templateBlock.sourceStartTime;if(e.hasSourceTiming&&!t.hasSourceTiming)return-1;if(!e.hasSourceTiming&&t.hasSourceTiming)return 1}return e.originalIndex-t.originalIndex});let w=0;for(let e=0;e<S.length;e++){let t=S[e],{block:r,templateBlock:i}=t;if(t.hasSourceTiming){let e=i.sourceStartTime;r.startTime=n.startTime+e,typeof i.sourceDuration==`number`&&(r.duration=Math.max(5,i.sourceDuration)),w=e+r.duration}else if(i.template===`sectionHeader`)r.startTime=n.startTime+w,w+=r.duration;else{r.startTime=n.startTime+w;let e=r.duration*x;r.duration=e,w+=e}y[t.originalIndex]=r}let T=S.map(e=>y[e.originalIndex]).sort((e,t)=>e.startTime-t.startTime);for(let e=0;e<T.length-1;e++){let t=T[e],n=T[e+1],r=t.startTime+t.duration;r>n.startTime?t.duration=n.startTime-t.startTime:r<n.startTime-.5&&(t.duration=Math.max(.1,n.startTime-t.startTime))}let E=n.startTime+n.duration;for(;T.length>1;){let e=T[T.length-1],t=E-e.startTime;if(p&&t<5&&e.template!==`sectionHeader`){let t=T[T.length-2];t.duration=E-t.startTime,e.duration=0,e.startTime=E,T.pop()}else{e.startTime+e.duration<E&&(e.duration=E-e.startTime);break}}if(T.length===1){let e=T[0];e.startTime+e.duration<E&&(e.duration=E-e.startTime)}let D=p;for(;D;){D=!1;for(let e=T.length-1;e>=1;e--){let t=T[e];if(t.duration>0&&t.duration<5){let n=T[e-1];n.duration=t.startTime+t.duration-n.startTime,t.duration=0,t.startTime=E,T.splice(e,1),D=!0;break}}}if(d)for(let e=0;e<T.length;e++){let t=T[e];if(t.duration>20){let e=Math.ceil(t.duration/20),n=t.duration/e;if(n>=5){t.duration=n;for(let r=1;r<e;r++){let e={id:`${t.id}-split-${r}`,startTime:t.startTime+r*n,duration:n,audioSegment:t.audioSegment,layers:(t.layers??[]).map(e=>({...s(e),id:`${e.id}-split-${r}`})),transition:{type:`dissolve`,duration:1},template:t.template};y.push(e)}}}}}return p?y.filter(e=>e&&e.duration>0):y.filter(Boolean)}function yu(){return Object.keys(Gc)}function bu(e){return j(e)in Gc}var xu={width:1920,height:1080},Su={label:`lb`,description:`ds`,viewport:`vp`,layers:`ly`,name:`nm`,type:`ty`,position:`po`,content:`ct`,animation:`am`,width:`wd`,height:`hg`,anchor:`an`,text:`tx`,style:`sy`,fontSize:`fz`,fontFamily:`ff`,fontWeight:`fw`,color:`cl`,textAlign:`al`,verticalAlign:`vl`,lineHeight:`lh`,shadow:`sd`,background:`bg`,backgroundOpacity:`bo`,backgroundGradient:`bj`,borderColor:`bc`,borderWidth:`bw`,borderStyle:`bs`,padding:`pd`,maxLines:`mx`,shape:`sp`,fill:`fl`,fillOpacity:`fo`,gradient:`gr`,stroke:`sk`,strokeWidth:`sw`,borderRadius:`br`,shapeKind:`kd`,dasharray:`da`,arrow:`ar`,startMarker:`st`,endMarker:`em`,src:`sc`,alt:`at`,fit:`ft`,credit:`cr`,license:`lc`,from:`fr`,angle:`ag`},Cu=Object.fromEntries(Object.entries(Su).map(([e,t])=>[t,e]));function wu(e,t){if(Array.isArray(e))return e.map(e=>wu(e,t));if(e&&typeof e==`object`){let n={};for(let[r,i]of Object.entries(e))n[t[r]??r]=wu(i,t);return n}return e}function Tu(e){return!e||e.width===xu.width&&e.height===xu.height}function Eu(e){if(!e)return;let t=ju(e[E]);if(!t)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let t=e,r={name:t.name,label:t.label,viewport:t.viewport??{...xu},layers:t.layers};t.description!==void 0&&(r.description=t.description);let i=y(r);i.template&&n.push(i.template)}return n.length>0?n:void 0}function Du(e,t){if(!e||e.length===0)return;let n={};for(let t of e){let e={lb:t.label};t.description&&(e.ds=t.description),Tu(t.viewport)||(e.vp=t.viewport),e.ly=wu(t.layers,Su),n[t.name]=e}return JSON.stringify(n,null,t?.pretty?2:void 0)}function Ou(e){return Object.entries(e).map(([e,t])=>{let n=t&&typeof t==`object`?t:{},r={name:e,label:n.lb,viewport:n.vp??{...xu},layers:wu(n.ly??[],Cu)};return typeof n.ds==`string`&&(r.description=n.ds),r})}function ku(e){return Array.isArray(e)?e:e&&typeof e==`object`?Ou(e):null}function Au(e){try{return JSON.parse(e)}catch{return}}function ju(e){if(e==null)return null;if(Array.isArray(e))return e;if(typeof e==`object`)return Ou(e);if(typeof e!=`string`)return null;let t=Au(e.trim());if(t!==void 0)return ku(t);try{let t=Au(Ge(e));if(t!==void 0)return ku(t)}catch{}return null}function Mu(e){if(e==null)return;let t=e;if(typeof t==`string`){let e=t.trim();if(!e)return;try{t=JSON.parse(e)}catch{return}}if(Array.isArray(t))return t;if(t&&typeof t==`object`)return Object.values(t)}function Nu(e){if(!e)return;let t=Mu(e[k]);if(!t)return;let n=[];for(let e of t){let t=D(e);t.valid&&t.theme&&n.push(t.theme)}return n.length>0?n:void 0}function Pu(e,t){if(!e||e.length===0)return;let n={};for(let t of e)n[t.id]=t;return JSON.stringify(n,null,t?.pretty?2:void 0)}var Fu=new Set([`json`,`yaml`,`yml`]);function Iu(e){if(!e.lang||!Fu.has(e.lang.toLowerCase()))return!1;let t=e.meta??``;return/\bdata\b/.test(t)}function Lu(e){if(e.lang?.toLowerCase()===`json`)try{let t=JSON.parse(e.value);return typeof t!=`object`||!t||Array.isArray(t)?{error:`JSON data fence must contain a top-level object ({"key": …})`}:{data:t}}catch(e){return{error:`invalid JSON: ${e instanceof Error?e.message:String(e)}`}}try{return{data:Hu(e.value)}}catch(e){return{error:`invalid YAML: ${e instanceof Error?e.message:String(e)}`}}}function Ru(e,t){let n=JSON.stringify(t,null,2),r=e.findIndex(e=>e.type===`code`&&Iu(e));if(r<0){let t={type:`code`,lang:`json`,meta:`data`,value:n};return[...e,t]}let i=[...e];return i[r]={...e[r],value:n},i}function zu(e){let t=e.trim();if(t.length>=2){let e=t[0];if((e===`"`||e===`'`)&&t.endsWith(e))return t.slice(1,-1)}return t===`true`?!0:t===`false`?!1:t===`null`||t===`~`?null:t!==``&&!isNaN(Number(t))?Number(t):t}function Bu(e){let t=[],n=``,r=null;for(let i of e)r?(n+=i,i===r&&(r=null)):i===`"`||i===`'`?(r=i,n+=i):i===`,`?(t.push(n),n=``):n+=i;return t.push(n),t.map(e=>e.trim()).filter(e=>e!==``)}function Vu(e){let t=e.trim();return t.startsWith(`[`)&&t.endsWith(`]`)?Bu(t.slice(1,-1)).map(zu):zu(t)}function Hu(e){let t={},n=e.split(`
|
|
26
|
+
`),r=null,i=null,a=-1;for(let e=0;e<n.length;e++){let o=n[e],s=o.trim();if(!s||s.startsWith(`#`))continue;let c=o.length-o.trimStart().length;if(c>0){if(!r)throw Error(`line ${e+1}: unexpected indented line without a preceding "key:" line`);if(a<0&&(a=c),c>a)throw Error(`line ${e+1}: nesting deeper than one level is not supported \u2014 use a \`\`\`json data fence for nested input`);if(s.startsWith(`- `)){if(i===`map`)throw Error(`line ${e+1}: cannot mix list items and mapping keys under "${r}"`);i=`list`,t[r].push(Vu(s.slice(2)));continue}if(i===`list`)throw Error(`line ${e+1}: cannot mix mapping keys and list items under "${r}"`);let n=s.indexOf(`:`);if(n<1)throw Error(`line ${e+1}: expected "key: value"`);let o=s.slice(n+1).trim();if(o===``)throw Error(`line ${e+1}: nesting deeper than one level is not supported \u2014 use a \`\`\`json data fence for nested input`);i!==`map`&&(i=`map`,t[r]={}),t[r][s.slice(0,n).trim()]=Vu(o);continue}r=null,i=null,a=-1;let l=s.indexOf(`:`);if(l<1)throw Error(`line ${e+1}: expected "key: value"`);let u=s.slice(0,l).trim(),d=s.slice(l+1).trim();d===``?(t[u]=[],r=u):t[u]=Vu(d)}return t}function Uu(e){return e?.find(e=>e.type===`table`)}function Wu(e){let t=e=>e.children.map(e=>o(e).trim()),[n,...r]=e.children;return{headers:n?t(n):[],rows:r.map(t),...e.align&&e.align.some(e=>e!=null)?{align:e.align}:{}}}function Gu(e){let t=ve(e.trim()),n=t.length>0&&t[0].indexOf(`=`)>0,r=n||t.length===0?void 0:t[0],i=+!n,a={};for(let e=i;e<t.length;e++){let n=de(t[e]);n&&(a[n.key]=n.value)}return{template:r,params:a}}function Ku(e){if(e.type!==`paragraph`)return null;let t=e.children??[];if(t.length!==1||t[0].type!==`text`)return null;let n=he(t[0].value.trim());return!n||n.index!==0?null:Gu(n.inner)}var qu=new Set([`audio`,`video`,`media`]);function Ju(e){return e!=null&&qu.has(e)}function Yu(e){return e==null?null:ue(e)}function Xu(e){let t=e.placement??e.presentation;if(t===`content`)return`content`;if(t===`pip`||t===`picture-in-picture`)return`picture-in-picture`;if(t===`overlay`||t===`full-frame`)return`overlay`;if(e.pip===``||e.pip===`true`)return`picture-in-picture`;if(e.overlay===``||e.overlay===`true`)return`overlay`}function Zu(e){return e!==`false`&&e!==`0`}function Qu(e){return e===`small`||e===`large`?e:void 0}function $u(e){return e===`square`||e===`wide`?e:void 0}function ed(e){return e===`top-left`||e===`top-right`||e===`bottom-left`||e===`bottom-right`?e:void 0}function td(e,t){let{template:n,params:r}=e;if(!n||!qu.has(n))return null;let i=r.src;if(!i)return null;let a=n===`video`?`video`:`audio`,o=r.anchor===`document`||r.span===`document`?`document`:`block`,s={id:t,src:i,kind:a,startAt:Yu(r.startAt??r.startTime)??0,anchor:o},c=a===`video`?Xu(r):void 0;c&&c!==`content`&&(s.placement=c);let l=Qu(r.pipSize),u=$u(r.pipShape),d=ed(r.pipPosition);if(l&&(s.pipSize=l),u&&(s.pipShape=u),d&&(s.pipPosition=d),a===`video`&&c&&c!==`content`&&r.lockToBlock!=null){let e=Zu(r.lockToBlock);s.lockToBlock=e,s.anchor=e?`block`:`document`,e&&(s.startAt=0)}let f=Yu(r.clipStart),p=Yu(r.clipEnd);return f!=null&&(s.clipStart=f),p!=null&&(s.clipEnd=p),s.lockToBlock===!0&&delete s.clipEnd,(r.spillover===`true`||r.spillover===``)&&(s.spillover=!0),s}function nd(e){let t=e=>{for(let n of e){if(n.type!==`htmlElement`)continue;if(n.tagName===`video`)return n;let e=t(n.children);if(e)return e}return null};return t(e)}function rd(e){if(e.type===`htmlBlock`){if(!/^\s*<video\b/i.test(e.rawHtml))return null;let t=nd(e.htmlChildren);return t?{element:t,raw:e.rawHtml.trim()}:null}if(e.type!==`paragraph`||!e.children.every(e=>e.type===`htmlInline`))return null;let t=e.children.map(e=>e.type===`htmlInline`?e.rawHtml:``).join(``);if(!/^\s*<video\b[\s\S]*<\/video>\s*$/i.test(t))return null;for(let n of e.children){if(n.type!==`htmlInline`)continue;let e=nd(n.htmlChildren);if(e)return{element:e,raw:t.trim()}}return null}function id(e,t){let n=rd(e);if(!n)return null;let{element:r}=n,i=Xu({placement:r.attributes[`data-squisq-video-placement`]??``});if(!i||i===`content`)return null;let a=r.attributes.src;if(!a)return null;let o=Zu(r.attributes[`data-squisq-video-lock-to-block`]),s={id:t,src:a,kind:`video`,placement:i,lockToBlock:o,startAt:o?0:Yu(r.attributes[`data-squisq-video-start-at`])??0,anchor:o?`block`:`document`},c=Qu(r.attributes[`data-squisq-video-pip-size`]),l=$u(r.attributes[`data-squisq-video-pip-shape`]),u=ed(r.attributes[`data-squisq-video-pip-position`]);c&&(s.pipSize=c),l&&(s.pipShape=l),u&&(s.pipPosition=u);let d=Yu(r.attributes[`data-squisq-video-clip-start`]),f=Yu(r.attributes[`data-squisq-video-clip-end`]);return d!=null&&(s.clipStart=d),!o&&f!=null&&(s.clipEnd=f),s}function ad(e,t,n){let r=[],i=[],a=[],o=0,s=0;for(let c of e??[]){let e=Ku(c),l=e?td(e,``):id(c,``);if(l){l.id=t(l.src,o++);let e=c.position?.start.line;if(e!=null&&(l.sourceLine=e),n!==void 0){let e=rd(c),t=c.type===`paragraph`&&c.children?.[0]?.type===`text`?c.children[0].value.trim():e?.raw;l.origin={blockId:n,index:s,...t===void 0?{}:{raw:t},...e?{format:`html`}:{}}}(l.anchor===`document`?i:r).push(l)}else a.push(c);s++}return{media:r,documentMedia:i,remaining:a}}function od(e,t){t.x!=null&&(e.x=t.x),t.y!=null&&(e.y=t.y),t.startTime!=null&&(e.startTime=t.startTime),t.duration!=null&&(e.duration=t.duration),t.connectsTo&&(e.connectsTo=t.connectsTo),t.transition&&(e.transition=t.transition)}function sd(e,t){let n=e.template,r=e.params,i=Object.keys(r).length>0,a={id:t.makeId(e),startTime:0,duration:t.defaultDuration,audioSegment:0,template:j(n),standaloneAnnotation:!0,sourceAnnotation:{template:n,...i?{params:r}:{}},...r.title?{title:r.title}:{}};return i&&(a.templateOverrides=r,od(a,se(r).blockMeta)),a}function cd(e,t){let n=[],r=[],i=null;for(let a of e??[]){let e=Ku(a);if(e!=null&&e.template!=null&&!Ju(e.template)){let n=sd(e,t);r.push(n),i=n}else i?(i.contents??=[]).push(a):n.push(a)}return{leading:n,blocks:r}}function ld(e){if(e.type!==`paragraph`)return null;let t=e.children;if(t.length===0)return null;let n=t[t.length-1];return n.type===`text`?n.value:null}function ud(e){if(Ku(e)?.template)return!0;let t=ld(e);if(t==null)return!1;let n=he(t);return!!n&&n.index>0&&!!Gu(n.inner).template}function dd(e,t,n){let r=[...e],i=r[t];if(i.type!==`paragraph`)return r;let a=[...i.children],o=a[a.length-1];if(o.type!==`text`)return r;let s=o.value.slice(0,n);return s.length===0&&a.length===1?r.splice(t,1):(a[a.length-1]={...o,value:s},r[t]={...i,children:a}),r}function fd(e){if(!e||e.length===0)return null;let t=e.length-1,n=e[t],r=null,i=null,a=Ku(n);if(a?.template&&n.type===`paragraph`){let o=n.children[0];r={template:a.template,params:a.params,origin:{kind:`paragraph`,index:t,raw:o&&o.type===`text`?o.value.trim():``}},i=e.slice(0,t)}else{let a=ld(n),o=a==null?null:he(a);if(a!=null&&o&&o.index>0){let n=Gu(o.inner);n.template&&(r={template:n.template,params:n.params,origin:{kind:`trailing`,index:t,suffix:a.slice(o.index)}},i=dd(e,t,o.index))}}if(!r||!i)return null;for(let n=0;n<t;n++)if(ud(e[n]))return null;return{data:r,strippedContents:i}}var pd=/[^\w\s-]/g,md=/[\s_]+/g,hd=/-+/g,gd=/^-|-$/g;function _d(e){return e.toLowerCase().replace(pd,``).replace(md,`-`).replace(hd,`-`).replace(gd,``)||`block`}function vd(){let e=new Map,t=(t,n)=>{let r=_d(o(t)),i=e.get(r)??0;return e.set(r,i+1),i===0?r:`${r}-${i+1}`};return t.reserve=t=>{e.set(t,Math.max(e.get(t)??0,1))},t.fromText=t=>{let n=_d(t),r=e.get(n)??0;return e.set(n,r+1),r===0?n:`${n}-${r+1}`},t}function yd(e,t){t.x!=null&&(e.x=t.x),t.y!=null&&(e.y=t.y),t.startTime!=null&&(e.startTime=t.startTime),t.duration!=null&&(e.duration=t.duration),t.connectsTo&&(e.connectsTo=t.connectsTo),t.transition&&(e.transition=t.transition)}function bd(e){if(!e)return{};let t=e.templateAnnotation?.params?se(e.templateAnnotation.params).blockMeta:{},n=e.attributes?.blockMeta??{};return{...t,...n}}function xd(e){return e.promotedBodyAnnotation?.params?se(e.promotedBodyAnnotation.params).blockMeta:e.sourceHeading?bd(e.sourceHeading):e.sourceAnnotation?.params?se(e.sourceAnnotation.params).blockMeta:{}}function Sd(e){return xd(e)}function Cd(e){for(let t of e){if(!t.sourceHeading||t.sourceHeading.templateAnnotation?.template)continue;let e=fd(t.contents);if(!e)continue;let{template:n,params:r}=e.data;Ju(n)||!bu(n)||(t.template=j(n),Object.keys(r).length>0&&(t.templateOverrides=r,yd(t,se(r).blockMeta)),t.contents=e.strippedContents,t.promotedBodyAnnotation=e.data)}}function wd(e,t,n){let r=[];for(let i of e){i.children&&i.children.length>0&&(i.children=wd(i.children,t,n));let{leading:e,blocks:a}=cd(i.contents,{makeId:t,defaultDuration:n});if(a.length===0){r.push(i);continue}i.contents=e,(i.children?.length??0)>0&&!oe(i.template)?(i.children=[...a,...i.children],r.push(i)):r.push(i,...a)}return r}function Td(e,t){let r=t?.articleId??`markdown-doc`,i=t?.defaultTemplate??`sectionHeader`,a=t?.defaultDuration??5,s=t?.generateId?null:vd(),c=t?.generateId??s,l=[],u=[],d=0,f=[],p=[],m=null;function h(){m&&p.length>0&&(m.contents=(m.contents??[]).concat(p),p=[])}function g(e){let t=e?.attributes?.id,n=t||(e?c(e,d++):`preamble`);t&&s&&s.reserve(t);let r=e?.templateAnnotation,l=r?.template??(e?i:void 0),u=l==null?void 0:j(l),f=e?o(e):void 0,p={id:n,startTime:0,duration:a,audioSegment:0,template:u,...e?{sourceHeading:e}:{},...f?{title:f}:{}};r?.params&&(p.templateOverrides=r.params,yd(p,se(r.params).blockMeta));let m=e?.attributes;return m&&(m.blockMeta&&yd(p,m.blockMeta),m.classes&&m.classes.length>0&&(p.classes=m.classes),m.metadata&&Object.keys(m.metadata).length>0&&(p.metadata=m.metadata)),p}for(let t of e.children)if(t.type===`heading`){let e=t,n=e.depth;h();let r=g(e);if(f.length===0)m&&!m.sourceHeading&&l.push(m),l.push(r),f.push({block:r,depth:n});else{for(;f.length>0&&f[f.length-1].depth>=n;)f.pop();if(f.length===0)l.push(r),f.push({block:r,depth:n});else{let e=f[f.length-1].block;e.children||=[],e.children.push(r),f.push({block:r,depth:n})}}m=r}else m||=g(null),p.push(t);h(),m&&!m.sourceHeading&&!l.includes(m)&&l.push(m);let _=[];for(let e of Ed(l)){let{media:t,documentMedia:n,remaining:r}=ad(e.contents,(t,n)=>`${e.id}-media-${n}-${t.replace(/[^a-zA-Z0-9]+/g,`-`)}`,e.id);t.length>0&&(e.media=t),n.length>0&&_.push(...n),e.contents&&=r}l.length>0&&!l[0].sourceHeading&&(l[0].contents?.length??0)===0&&(l[0].children?.length??0)===0&&!l[0].media&&l.shift(),Cd(Ed(l)),l=wd(l,e=>{let t=e.params.title??e.template??`block`;return s?s.fromText(t):_d(t)},a),l.length>0&&!l[0].sourceHeading&&!l[0].standaloneAnnotation&&(l[0].contents?.length??0)===0&&(l[0].children?.length??0)===0&&!l[0].media&&l.shift();let v=Ed(l);for(let e of v)jd(e,u);for(let e of v)Md(e,u),Pd(e,u),Nd(e,u);(t?.autoTemplates??!0)&&!Id(e)&&Ld(l,j(i),{featureIndex:0});for(let e of v)Fd(e,u);let y=new Map;for(let e of v)y.has(e.id)?u.push({severity:`error`,code:`duplicate-id`,message:`Duplicate block id "${e.id}" \u2014 later connections and links are ambiguous`,blockId:e.id,...Ad(e)}):y.set(e.id,e);for(let e of v)for(let t of e.connectsTo??[])y.has(t.target)||u.push({severity:`warning`,code:`unresolved-connection`,message:`Block "${e.id}" connects to unknown target "${t.target}"`,blockId:e.id,...Ad(e)});let b=[];for(let e of v){if(xd(e).duration!=null)continue;let t=Rd(e);if(t.length>0){let n=fi(t);e.duration=Math.max(3,n.seconds)}else e.duration=a}let x=0;for(let e of v){xd(e).startTime??(e.startTime=x);let t=Rd(e);if(t.length>0){let n=Bd(t);if(n.length>0){let t=e.duration/n.length;for(let e=0;e<n.length;e++)b.push({text:n[e],startTime:x+e*t,endTime:x+(e+1)*t,audioSegment:0})}}x+=e.duration}let S=new Map(v.map(e=>[e.id,e]));for(let e of _)e.lockToBlock===!1&&e.origin?.format===`html`&&!/\bdata-squisq-video-start-at\s*=/i.test(e.origin.raw??``)&&(e.startAt=S.get(e.origin.blockId)?.startTime??0);let C=b.length>0?{phrases:b,...t?.captionsGeneratedAt?{generatedAt:t.captionsGeneratedAt}:{},version:1}:void 0,w=Eu(e.frontmatter),T=Nu(e.frontmatter),E=n(e.frontmatter),D={articleId:r,duration:x,blocks:l,audio:{segments:[]},...C?{captions:C}:{},...e.frontmatter?{frontmatter:e.frontmatter}:{},...E?{themeId:E}:{},...w?{customTemplates:w}:{},...T?{customThemes:T}:{},...u.length>0?{diagnostics:u}:{},..._.length>0?{documentMedia:_}:{}};if(t?.generateCoverBlock??!0){let n=Gd(e,l,t?.fileName);n&&(D.startBlock=n)}return D}function Ed(e){let t=[];for(let n of e)t.push(n),n.children&&t.push(...Ed(n.children));return t}function Dd(e){let t=[];for(let n of e)t.push(n),n.children&&!oe(n.template)&&t.push(...Dd(n.children));return t}function Od(e){let t=0;for(let n of e)t+=1,n.children&&(t+=Od(n.children));return t}function kd(e){return e.sourceHeading?.depth??0}function Ad(e){let t=e.sourceHeading?.position?.start.line;return t==null?{}:{line:t}}function jd(e,t){let n;for(let r of e.contents??[]){if(r.type!==`code`||!Iu(r))continue;let i=Lu(r);if(i.error){t.push({severity:`error`,code:`data-fence-parse`,message:`Data fence in block "${e.id}": ${i.error}`,blockId:e.id,...r.position?{line:r.position.start.line}:Ad(e)});continue}n={...n,...i.data}}if(_e.has(j(e.template??``))){let t=t=>n&&t in n||e.templateOverrides&&t in e.templateOverrides;if(!t(`headers`)&&!t(`rows`)){let t=Uu(e.contents);t&&(n={...Wu(t),...n})}}n&&Object.keys(n).length>0&&(e.templateData=n)}function Md(e,t){if(j(e.template??``)!==`diagram`||e.children&&e.children.length>0||e.templateData&&`nodes`in e.templateData)return;let n=(e.contents??[]).filter(e=>e.type===`code`);if(n.length!==1||!sn(n[0].lang))return;let r=kt(n[0].value);if(r.nodes.length===0){t.push({severity:`warning`,code:`ascii-diagram-parse`,message:`Diagram block "${e.id}": code fence did not parse as an ASCII diagram`,blockId:e.id});return}let{nodes:i,edges:a}=_a(r);e.templateData={nodes:i,edges:a,...e.templateData}}function Nd(e,t){if(j(e.template??``)!==`tree`||e.templateData&&`items`in e.templateData)return;let n=$a(`tree`,e.title??``,e.contents);if(!n||!Array.isArray(n.items)||n.items.length===0){t.push({severity:`warning`,code:`tree-parse`,message:`Tree block "${e.id}": body did not parse as a tree`,blockId:e.id});return}e.templateData={...n,...e.templateData}}function Pd(e,t){if(j(e.template??``)!==`timeline`||e.templateData&&`tracks`in e.templateData)return;let n=$a(`timeline`,e.title??``,e.contents);if(!n||!Array.isArray(n.tracks)||n.tracks.length===0){t.push({severity:`warning`,code:`timeline-parse`,message:`Timeline block "${e.id}": body did not parse as an ASCII timeline`,blockId:e.id});return}e.templateData={...n,...e.templateData}}function Fd(e,t){if(j(e.template??``)!==`timeline`||!e.templateData||!(`tracks`in e.templateData))return;let n=(e.contents??[]).filter(e=>e.type===`code`&&xr(e.lang));if(n.length===1)for(let r of Rn(n[0].value).warnings){let n=/^unresolved-link\((.+)\)$/.exec(r);t.push({severity:`warning`,code:n?`timeline-unresolved-link`:`timeline-parse-warning`,message:n?`Timeline block "${e.id}": unresolved branch ${n[1]}`:`Timeline block "${e.id}": ${r}`,blockId:e.id})}}function Id(e){let t=e.frontmatter?.[`squisq-auto-templates`];return t===!1||t===`false`||t===`off`||t===`no`||t===0}function Ld(e,t,n){for(let r of e){let e=!!r.sourceHeading?.templateAnnotation?.template||!!r.promotedBodyAnnotation;if(r.sourceHeading&&!e&&r.template===t){let e=li(oi(r.contents??[]),n.featureIndex);if(e&&Qa(e,r.contents)){let t=$a(e,r.title??``,r.contents,{preserveSourceHeading:!0});t&&((e===`leftFeature`||e===`rightFeature`)&&(n.featureIndex+=1),r.template=e,r.autoTemplate=!0,r.templateData={...t,...r.templateData})}}r.children&&r.children.length>0&&!oe(r.template)&&Ld(r.children,t,n)}}function Rd(e){if(!e.contents||e.contents.length===0)return``;let t=j(e.template??``),n=t===`diagram`&&e.templateData!==void 0&&`nodes`in e.templateData||t===`timeline`&&e.templateData!==void 0&&`tracks`in e.templateData||t===`tree`&&e.templateData!==void 0&&`items`in e.templateData;return e.contents.filter(e=>!(n&&e.type===`code`)).map(e=>o(e)).join(`
|
|
27
|
+
`).trim()}var zd=12;function Bd(e){let t=e.split(/\n+/).map(e=>e.trim()).filter(e=>e.length>0),n=/(?<=[.!?])\s+/,r=[];for(let e of t){let t=e.split(n).map(e=>e.trim()).filter(e=>e.length>0);r.push(...t)}if(r.length===0)return[];let i=[];for(let e of r)if(e.split(/\s+/).length>zd){let t=Math.floor(e.length/2),n=/[,;]\s+|\s+—\s+|\s+-\s+/g,r=-1,a=1/0,o;for(;(o=n.exec(e))!==null;){let e=Math.abs(o.index-t);e<a&&(a=e,r=o.index+o[0].length)}r>0&&r<e.length-5?(i.push(e.slice(0,r).trim()),i.push(e.slice(r).trim())):i.push(e)}else i.push(e);let a=[i[0]];for(let e=1;e<i.length;e++)i[e].length<15&&a.length>0?a[a.length-1]+=` `+i[e]:a.push(i[e]);return a}function Vd(e){for(let t of e){if(t.type!==`htmlElement`)continue;if(t.tagName===`img`&&t.attributes.src)return{url:t.attributes.src,alt:t.attributes.alt};let e=Vd(t.children);if(e)return e}}function Hd(e){if(e.type===`image`){let t=e;return{url:t.url,alt:t.alt}}if(e.type===`htmlBlock`||e.type===`htmlInline`){let t=e;if(t.htmlChildren){let e=Vd(t.htmlChildren);if(e)return e}}if(`children`in e&&Array.isArray(e.children))for(let t of e.children){let e=Hd(t);if(e)return e}}function Ud(e){let t;for(let n of e){let e=n.sourceHeading?.depth;if(e!==void 0&&(n.title??o(n.sourceHeading))&&(!t||e<t.sourceHeading.depth)&&(t=n,e===1))break}return t}function Wd(e){if(!e)return;let t=(e.split(/[\\/]/).pop()??``).replace(/\.[^.]+$/,``).replace(/[-_]+/g,` `).replace(/\s+/g,` `).trim();if(t)return t.charAt(0).toUpperCase()+t.slice(1)}function Gd(e,t,n){let r=typeof e.frontmatter?.title==`string`?e.frontmatter.title.trim():void 0,i=Ud(t),a=i?i.title??o(i.sourceHeading):void 0,s=r||a||Wd(n);if(!s)return;let c=typeof e.frontmatter?.subtitle==`string`?e.frontmatter.subtitle.trim():void 0,l=i??t[0],u=l?.contents?.[0]?.type===`paragraph`?o(l.contents[0]):void 0,d=c||u,f=Hd(e);return{title:s,...d?{subtitle:d}:{},...f?{heroSrc:f.url,heroAlt:f.alt??s}:{},ambientMotion:`zoomIn`}}var Kd=/^[.,!?;:'"()[\]{}]+|[.,!?;:'"()[\]{}]+$/g,qd=1.4;function Jd(e){let t=e.replace(Kd,``);if(!t)return 1;if(/^[-+]?[\d.,]+$/.test(t)){let e=parseFloat(t.replace(/,/g,``));if(!Number.isNaN(e)&&Number.isFinite(e))return Math.max(1,Math.round(xe(t)*qd))}if(/^[A-Z]{2,5}$/.test(t)&&!/[AEIOUY]/.test(t))return t.length;let n=t.toLowerCase().split(/[^a-z']+/).filter(e=>e.length>0);if(n.length===0)return 1;let r=0;for(let e of n)r+=Yd(e.replace(/'/g,``));return Math.max(1,r)}function Yd(e){if(!e)return 0;let t=e.match(/[aeiouy]+/g),n=t?t.length:0;return n===0?1:(n>1&&/[^aeiouy]e$/.test(e)&&--n,n>1&&/[^aeiouy]ed$/.test(e)&&!/[td]ed$/.test(e)&&--n,n>1&&/[^aeiouy]es$/.test(e)&&!/(?:[sxz]|[cs]h)es$/.test(e)&&--n,/[^aeiouy]le$/.test(e)&&(n+=1),Math.max(1,n))}function Xd(e,t){let n=t&&e.title?e.title.trim():``,r=Rd(e);return n&&r?`${n}
|
|
28
|
+
${r}`:n||r}function Zd(e,t){let n=t?.includeTitles??!0,r=t?.blockSeparator??`
|
|
29
|
+
|
|
30
|
+
`,i=[];for(let t of Dd(e.blocks)){let e=Xd(t,n);e&&i.push({blockId:t.id,heading:t.title||void 0,text:e})}let a=``,o=[];for(let e=0;e<i.length;e++){e>0&&(a+=r);let t=a.length;a+=i[e].text,o.push({blockId:i[e].blockId,...i[e].heading===void 0?{}:{heading:i[e].heading},tokenStart:0,tokenEnd:0,charStart:t,charEnd:a.length})}let s=[],c=/\S+/g,l=0,u;for(;(u=c.exec(a))!==null;){let e=u.index,t=e+u[0].length;for(;l<o.length-1&&e>=o[l].charEnd;)l++;let n=$d(u[0]);s.push({text:u[0],charOffset:e,charEnd:t,blockId:o[l]?.blockId??``,blockIndex:l,syllables:n?Jd(u[0]):0,spokenWordEquiv:n?xe(ef(u[0])):0,pauseAfter:0,spoken:n})}for(let e of o)e.tokenStart=s.length,e.tokenEnd=0;for(let e=0;e<s.length;e++){let t=o[s[e].blockIndex];t&&(e<t.tokenStart&&(t.tokenStart=e),t.tokenEnd=e+1)}for(let e of o)e.tokenStart>e.tokenEnd&&(e.tokenStart=e.tokenEnd);for(let e=0;e<s.length;e++){let t=s[e],n=s[e+1];!n||n.blockIndex!==t.blockIndex?t.pauseAfter=3:a.slice(t.charEnd,n.charOffset).includes(`
|
|
31
|
+
`)?t.pauseAfter=2:tf(t.text)&&(t.pauseAfter=1)}let d=Array(s.length+1);d[0]=0;for(let e=0;e<s.length;e++)d[e+1]=d[e]+s[e].syllables;return{sourceText:a,tokens:s,blocks:o,totalSyllables:d[s.length],cumulativeSyllables:d}}var Qd=/["')\]}»”’]+$/;function $d(e){return/[\p{L}\p{N}]/u.test(e)}function ef(e){return e.replace(/^[.,!?;:'"()[\]{}]+|[.,!?;:'"()[\]{}]+$/g,``)}function tf(e){let t=e.replace(Qd,``),n=t.charAt(t.length-1);return n?n===`,`||n===`.`||n===`;`||n===`:`||n===`!`||n===`?`:!1}function nf(e,t,n){return e<t?t:e>n?n:e}function rf(e,t){let n=e.tokens.length;if(n===0)return 0;let r=nf(t,0,n),i=Math.floor(r);return i>=n?e.totalSyllables:e.cumulativeSyllables[i]+(r-i)*e.tokens[i].syllables}function af(e,t){let n=e.tokens.length;if(n===0)return 0;let r=nf(t,0,e.totalSyllables),i=0,a=n;for(;i<a;){let t=i+a+1>>1;e.cumulativeSyllables[t]<=r?i=t:a=t-1}if(i>=n)return n;let o=r-e.cumulativeSyllables[i],s=e.tokens[i].syllables;return i+(s>0?o/s:0)}function of(e,t){if(e.length===0)return 0;let n=0,r=e.length-1;for(;n<r;){let i=n+r+1>>1;e[i].tSec<=t?n=i:r=i-1}return e[n].tSec<=t?n:0}function sf(e,t,n,r){let i=t.words.map(t=>{let n=e.tokens[t.tokenIndex];return{id:`word-${t.tokenIndex}`,time:t.tSec,charOffset:n?.charOffset??0,textFragment:n?.text??``}}),a=t.blocks.map(e=>({...e.blockId?{blockId:e.blockId}:{},...e.heading===void 0?{}:{heading:e.heading},blockIndex:e.blockIndex,charStart:e.charStart,charEnd:e.charEnd,startSec:e.startSec,endSec:e.endSec}));return{version:3,sourceText:e.sourceText,duration:Number.isFinite(n)&&n>=0?n:0,bookmarks:i,blocks:a,...lf(r?.cameraOffsetSec)?{cameraOffsetSec:r.cameraOffsetSec}:{},generator:{name:`squisq-teleprompter`,method:`dsp-align`,...r?.baseWpm===void 0?{}:{baseWpm:r.baseWpm}}}}function cf(e){return typeof e==`number`&&Number.isFinite(e)&&e>=0}function lf(e){return typeof e==`number`&&Number.isFinite(e)}function uf(e){try{let t=typeof e==`string`?e:new TextDecoder().decode(e instanceof Uint8Array?e:new Uint8Array(e)),n=JSON.parse(t);if(typeof n!=`object`||!n)return null;let r=n;if(typeof r.sourceText!=`string`||!cf(r.duration))return null;let i=Array.isArray(r.bookmarks)?r.bookmarks.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=e;return!cf(t.time)||!cf(t.charOffset)?[]:[{id:typeof t.id==`string`?t.id:`bookmark-${t.charOffset}`,time:t.time,charOffset:t.charOffset,...typeof t.textFragment==`string`?{textFragment:t.textFragment}:{}}]}):[],a=Array.isArray(r.blocks)?r.blocks.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=e;return!cf(t.startSec)||!cf(t.endSec)||!cf(t.charStart)||!cf(t.charEnd)?[]:[{...typeof t.blockId==`string`?{blockId:t.blockId}:{},...typeof t.heading==`string`?{heading:t.heading}:{},blockIndex:cf(t.blockIndex)?t.blockIndex:0,charStart:t.charStart,charEnd:t.charEnd,startSec:t.startSec,endSec:Math.max(t.startSec,t.endSec)}]}):[];a=a.sort((e,t)=>e.startSec-t.startSec);let o=0;for(let e of a)e.startSec<o&&(e.startSec=o),e.endSec<e.startSec&&(e.endSec=e.startSec),o=e.startSec;return{version:3,sourceText:r.sourceText,duration:r.duration,bookmarks:i,blocks:a,...lf(r.cameraOffsetSec)?{cameraOffsetSec:r.cameraOffsetSec}:{},...typeof r.generator==`object`&&r.generator!==null?{generator:r.generator}:{}}}catch{return null}}function df(e,t=0){return!e||e.type===`none`?{className:``,style:{}}:{className:ff(e),style:pf(e)}}function ff(e){let{type:t,direction:n,panDirection:r}=e;switch(t){case`fadeIn`:return`anim-fadeIn`;case`fadeOut`:return`anim-fadeOut`;case`slowZoom`:return r===`left`?`anim-slowZoom-panLeft`:r===`right`?`anim-slowZoom-panRight`:n===`out`?`anim-slowZoom-out`:`anim-slowZoom-in`;case`zoomIn`:return`anim-zoomIn`;case`zoomOut`:return`anim-zoomOut`;case`panLeft`:return`anim-panLeft`;case`panRight`:return`anim-panRight`;case`typewriter`:return`anim-typewriter`;default:return``}}function pf(e){let t={};return e.duration!==void 0&&(t[`--anim-duration`]=`${e.duration}s`),e.delay!==void 0&&(t[`--anim-delay`]=`${e.delay}s`),e.easing&&(t[`--anim-easing`]=e.easing),t}function mf(e){switch(e){case`slowZoom`:case`panLeft`:case`panRight`:return 8;case`typewriter`:return 3;case`fadeIn`:case`fadeOut`:return 1;case`zoomIn`:case`zoomOut`:return .5;default:return 1}}function hf(e,t,n){if(e===`cut`)return``;let r=t?`enter`:`exit`;return`transition-${_f(e,n)}-${r}`}var gf={airplane:`airplane`,blinds:`blindsHorizontal`,box:`box`,checker:`checkerboard`,checkerboard:`checkerboard`,circle:`shapeCircle`,clock:`clock`,comb:`combHorizontal`,conveyor:`conveyor`,cover:`coverLeft`,crush:`crush`,cube:`cube`,curtains:`curtains`,cut:`cut`,diamond:`shapeDiamond`,dissolve:`dissolve`,doors:`doors`,drape:`drape`,fade:`fade`,fallOver:`fallOver`,ferris:`ferrisWheel`,ferrisWheel:`ferrisWheel`,flash:`flash`,flip:`flip`,flyThrough:`flyThrough`,flythrough:`flyThrough`,fracture:`fracture`,gallery:`gallery`,glitter:`glitter`,honeycomb:`honeycomb`,morph:`morph`,newsflash:`newsflash`,orbit:`orbit`,origami:`origami`,pageCurl:`pageCurl`,pageCurlDouble:`pageCurlDouble`,pageCurlSingle:`pageCurlSingle`,pan:`panLeft`,peelOff:`peelOff`,plus:`shapePlus`,prestige:`prestige`,prism:`prism`,pull:`pullLeft`,push:`pushLeft`,random:`random`,randomBar:`randomBarsHorizontal`,randomBars:`randomBarsVertical`,reveal:`revealLeft`,ripple:`ripple`,rotate:`rotate`,shape:`shapeCircle`,shred:`shred`,slideDown:`slideDown`,slideLeft:`slideLeft`,slideRight:`slideRight`,slideUp:`slideUp`,split:`splitHorizontal`,strips:`stripsLeft`,switch:`switch`,uncover:`uncoverLeft`,vortex:`vortex`,warp:`warp`,wedge:`wedge`,wheel:`wheel`,wheelReverse:`wheelReverse`,wind:`wind`,window:`window`,wipe:`wipeLeft`,zoom:`zoom`};function _f(e,t){switch(e){case`randomBars`:case`randomBar`:return yf(`randomBars`,t,e===`randomBar`?`Horizontal`:`Vertical`);case`comb`:return yf(`comb`,t,`Horizontal`);case`blinds`:return yf(`blinds`,t,`Horizontal`);case`split`:return yf(`split`,t,`Horizontal`);case`push`:return vf(`push`,t,`Left`);case`wipe`:return vf(`wipe`,t,`Left`);case`cover`:return vf(`cover`,t,`Left`);case`uncover`:return vf(`uncover`,t,`Left`);case`pull`:return vf(`pull`,t,`Left`);case`reveal`:return vf(`reveal`,t,`Left`);case`strips`:return vf(`strips`,t,`Left`);case`pan`:return vf(`pan`,t,`Left`);default:return gf[e]}}function vf(e,t,n){return`${e}${bf(t,n)}`}function yf(e,t,n){return`${e}${xf(t,n)}`}function bf(e,t){switch(e){case`right`:return`Right`;case`up`:return`Up`;case`down`:return`Down`;default:return t}}function xf(e,t){switch(e){case`vertical`:case`up`:case`down`:return`Vertical`;case`horizontal`:case`left`:case`right`:return`Horizontal`;default:return t}}function Sf(e,t,n){let r=e.delay||0,i=e.duration||n;return t<r?0:t>=r+i?1:(t-r)/i}var Cf=40,wf=e=>Math.max(0,Math.min(1,e)),Tf=e=>Math.round(e*100)/100;function Ef(e,t){let n=[];if(t!=null&&t>0&&n.push(`blur(${Math.round(t)}px)`),e&&e.type!==`none`){let t=wf(e.strength??.6);switch(e.type){case`mono`:n.push(`grayscale(${Tf(t)})`,`contrast(${Tf(1+.05*t)})`);break;case`duotone`:{let r=ie(e.color??`#3d5a80`);n.push(`grayscale(1)`,`sepia(${Tf(Math.max(.35,t))})`,`hue-rotate(${Math.round(r-Cf)}deg)`,`saturate(${Tf(1+t)})`);break}case`warm`:n.push(`sepia(${Tf(.4*t)})`,`saturate(${Tf(1+.15*t)})`);break;case`cool`:n.push(`saturate(${Tf(1-.25*t)})`,`hue-rotate(${Math.round(-12*t)}deg)`,`contrast(${Tf(1+.06*t)})`);break}}return n.length>0?n.join(` `):void 0}var Df=Object.freeze([{id:`cover`,label:`Hero cover`,description:`The classic Squisq cover with title, subtitle, and optional hero image.`},{id:`title`,label:`Title`,description:`A theme-led title card without a full-bleed image.`},{id:`sectionHeader`,label:`Section header`,description:`A bold section divider using the hero image when one is available.`},{id:`imageWithCaption`,label:`Image with title`,description:`A full-bleed image with the title and subtitle overlaid.`,requiresHeroImage:!0},{id:`bigText`,label:`Big text`,description:`The title in gigantic uppercase type on a clean theme surface — thumbnail-ready.`},{id:`bigTextImage`,label:`Big text on image`,description:`The title in gigantic uppercase type over the hero image, with a contrast bloom behind the text.`,requiresHeroImage:!0}]),Of=Object.freeze({enabled:{canonical:`squisq-cover-slide`,legacy:`cover-slide`},template:{canonical:`squisq-cover-template`,legacy:`cover-template`},duration:{canonical:`squisq-cover-duration`,legacy:`cover-duration`},playback:{canonical:`squisq-cover-playback`,legacy:`cover-playback`}}),kf=Object.freeze({enabled:!0,template:`cover`,duration:2,playback:`preroll`});function Af(e,t){if(e)return Object.prototype.hasOwnProperty.call(e,t.canonical)?e[t.canonical]:e[t.legacy]}function jf(e){if(typeof e==`boolean`)return e;if(typeof e!=`string`)return;let t=e.trim().toLowerCase();if([`true`,`yes`,`on`,`show`,`visible`].includes(t))return!0;if([`false`,`no`,`off`,`hide`,`hidden`].includes(t))return!1}function Mf(e){if(typeof e!=`string`)return;let t=e.trim().toLowerCase().replace(/[_\s-]+/g,``);if(t===`cover`||t===`hero`||t===`managedcover`)return`cover`;if(t===`title`||t===`titleblock`)return`title`;if(t===`sectionheader`||t===`section`)return`sectionHeader`;if(t===`imagewithcaption`||t===`imagetitle`||t===`fullbleedimage`)return`imageWithCaption`;if(t===`bigtextimage`||t===`largetextimage`||t===`bigtextonimage`)return`bigTextImage`;if(t===`bigtext`||t===`largetext`)return`bigText`}function Nf(e){let t=typeof e==`number`?e:typeof e==`string`&&e.trim().length>0?Number(e):NaN;if(!(!Number.isFinite(t)||t<0||t>60))return t}function Pf(e){if(typeof e!=`string`)return;let t=e.trim().toLowerCase().replace(/[_\s]+/g,`-`);if([`overlay`,`over`,`concurrent`,`play-over`].includes(t))return`overlay`;if([`preroll`,`pre-roll`,`delay`,`push`,`shift`].includes(t))return`preroll`}function Ff(e,t={}){let n={enabled:jf(Af(e,Of.enabled))??kf.enabled,template:Mf(Af(e,Of.template))??kf.template,duration:Nf(Af(e,Of.duration))??kf.duration,playback:Pf(Af(e,Of.playback))??kf.playback};return{enabled:t.enabled??n.enabled,template:t.template??n.template,duration:Nf(t.duration)??n.duration,playback:t.playback??n.playback}}var If=[`transition`,`transitionDuration`,`transitionDirection`],Lf=`sectionHeader`;function Rf(e,t={}){let n=j(t.defaultTemplate??Lf),r=[],i=new Set(Ed(e.blocks).map(e=>e.id)),a=new Map,o=[];for(let t of e.documentMedia??[])if(t.origin&&i.has(t.origin.blockId)){let e=a.get(t.origin.blockId)??[];e.push(t),a.set(t.origin.blockId,e)}else o.push(t);for(let e of o)r.push(Hf(e));function s(e){let t=e.promotedBodyAnnotation,i=t!==void 0&&!Bf(e,t);if(e.sourceHeading)if(i)r.push(e.sourceHeading);else{let t=Uf(e,e.sourceHeading,n);r.push(t)}else e.standaloneAnnotation&&r.push(zf(e));let o=[...e.media??[],...a.get(e.id)??[]],c=[...e.contents??[]];if(o.length>0){let e=o.filter(e=>e.origin).sort((e,t)=>e.origin.index-t.origin.index);for(let t of e)c.splice(Math.min(t.origin.index,c.length),0,Hf(t));for(let e of o.filter(e=>!e.origin).reverse())c.unshift(Hf(e))}if(i&&Vf(c,t),r.push(...c),e.children)for(let t of e.children)s(t)}for(let t of e.blocks)s(t);let c=Du(e.customTemplates),l=e.frontmatter;if(c)l={...l??{},[E]:c};else if(l&&`squisq-custom-templates`in l){let{[E]:e,...t}=l;l=t}let u=Pu(e.customThemes);if(u)l={...l??{},[k]:u};else if(l&&`squisq-custom-themes`in l){let{[k]:e,...t}=l;l=t}return{type:`document`,children:r,...l&&Object.keys(l).length>0?{frontmatter:l}:{}}}function zf(e){return{type:`paragraph`,children:[{type:`text`,value:le(e.sourceAnnotation?.template,e.templateOverrides)}]}}function Bf(e,t){let n=j(e.template??``)===j(t.template),r=Kf(e.templateOverrides??{},t.params??{});return!(n&&r)}function Vf(e,t){if(t.origin.kind===`paragraph`){e.push({type:`paragraph`,children:[{type:`text`,value:t.origin.raw}]});return}let n=e[e.length-1];if(n&&n.type===`paragraph`){let r=n.children??[],i=r[r.length-1];if(i&&i.type===`text`){let a=[...r];a[a.length-1]={...i,value:i.value+t.origin.suffix},e[e.length-1]={...n,children:a};return}}e.push({type:`paragraph`,children:[{type:`text`,value:t.origin.suffix.replace(/^\s+/,``)}]})}function Hf(e){if(e.origin?.format===`html`&&e.origin.raw)return{type:`htmlBlock`,rawHtml:e.origin.raw,htmlChildren:a(e.origin.raw)};if(e.origin?.raw)return{type:`paragraph`,children:[{type:`text`,value:e.origin.raw}]};let t={src:e.src};return e.placement&&(t.placement=e.placement),e.pipSize&&(t.pipSize=e.pipSize),e.pipShape&&(t.pipShape=e.pipShape),e.pipPosition&&(t.pipPosition=e.pipPosition),e.lockToBlock!=null&&(t.lockToBlock=String(e.lockToBlock)),e.anchor===`document`&&(t.anchor=`document`),e.startAt&&(t.startAt=String(e.startAt)),e.clipStart!=null&&(t.clipStart=String(e.clipStart)),e.clipEnd!=null&&(t.clipEnd=String(e.clipEnd)),e.spillover&&(t.spillover=`true`),{type:`paragraph`,children:[{type:`text`,value:le(e.kind,t)}]}}function Uf(e,t,n){let{attributes:r,transitionParams:i}=qf(e,t),a=t.templateAnnotation,o=Wf(e,a,n),s=e.templateOverrides&&Object.keys(e.templateOverrides).length>0?e.templateOverrides:void 0,c;return(o!==void 0||s!==void 0)&&(c={...o===void 0?{}:{template:o},...s?{params:s}:{}}),i&&(c={...c??{},params:{...c?.params??{},...i}}),Gf(a,c)&&(c=a),r===t.attributes&&c===t.templateAnnotation?t:{...t,children:[...t.children],attributes:r,templateAnnotation:c}}function Wf(e,t,n){if(!e.template||e.autoTemplate===!0)return t?.template;let r=j(e.template);if(t?.template&&j(t.template)===r)return t.template;if(r!==n)return e.template}function Gf(e,t){return e===t?!0:!e||!t?!1:e.template===t.template&&Kf(e.params,t.params)}function Kf(e,t){if(e===t)return!0;if(!e||!t)return!1;let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Object.prototype.hasOwnProperty.call(t,n)&&e[n]===t[n])}function qf(e,t){let n=e.transition;if(!n)return{attributes:t.attributes,transitionParams:void 0};let r=Jf(t.attributes)??{};return{attributes:{...r,blockMeta:{...r.blockMeta??{},transition:n}},transitionParams:{transition:n.type,...n.duration===void 0?{}:{transitionDuration:String(n.duration)},...n.direction?{transitionDirection:n.direction}:{}}}}function Jf(e){if(!e?.params)return e;let t={...e.params};for(let e of If)delete t[e];return{...e,...Object.keys(t).length>0?{params:t}:{params:void 0}}}function Yf(e){if(e.type===`inlineIcon`){let t=e;return Ce(t.family,t.name)}if(`value`in e&&typeof e.value==`string`)return e.value;let n=t(e),r=e.type===`list`||e.type===`listItem`?`
|
|
32
|
+
`:``;return n.map(Yf).join(r)}function Xf(e){if(!e||e.length===0)return``;let t=[];for(let n of e)n.type===`code`&&n.lang?.trim().toLowerCase()===`mermaid`||t.push(Yf(n));return t.join(`
|
|
33
|
+
`).trim()}function Zf(e){if(e===void 0)return;let t=parseFloat(e);return Number.isFinite(t)&&t>0?t:void 0}function Qf(e){if(!e||e.length===0)return[];let n=[];function r(e){if(!e||typeof e!=`object`)return;let t=e;if(t.type===`htmlElement`&&t.tagName.toLowerCase()===`img`){let e=t.attributes,r=e?.src;typeof r==`string`&&r&&n.push({src:r,alt:typeof e?.alt==`string`?e.alt:``,width:Zf(e?.width),height:Zf(e?.height)})}if(Array.isArray(t.children))for(let e of t.children)r(e)}function i(e){if(`type`in e&&e.type===`image`&&`url`in e){let t=e;t.url&&n.push({src:t.url,alt:t.alt??``})}if(`type`in e&&(e.type===`htmlBlock`||e.type===`htmlInline`)){let t=e;for(let e of t.htmlChildren??[])r(e)}for(let n of t(e))i(n)}for(let t of e)i(t);return n}function $f(e){let t=new Set,n=[];function r(e){for(let i of e){for(let e of Qf(i.contents))t.has(e.src)||(t.add(e.src),n.push(e));i.children&&r(i.children)}}return r(e),n}function ep(e){if(!e)return[];let t=[];for(let n of e)if(n.type===`list`)for(let e of n.children){let n=o(e).trim();n&&t.push(n)}return t}function tp(e,t,n){let r=Xf(n.contents);switch(e){case`statHighlight`:return $a(e,t,n.contents)??{stat:t,description:r||t};case`quote`:return{quote:r||t};case`fullBleedQuote`:case`pullQuote`:return $a(e,t,n.contents)??{text:r||t};case`factCard`:return{fact:t,explanation:r||t};case`comparisonBar`:return{leftLabel:`A`,leftValue:60,rightLabel:`B`,rightValue:40};case`list`:{let e=ep(n.contents);return{items:e.length>0?e:[`Item 1`,`Item 2`,`Item 3`]}}case`definitionCard`:return{term:t,definition:r||t};case`dateEvent`:return{date:t,description:r||t};case`leftFeature`:case`rightFeature`:{let e=Qf(n.contents)[0];return{imageSrc:e?.src??``,imageAlt:e?.alt||t,imageWidth:e?.width,imageHeight:e?.height,title:t,body:r||t}}default:return{}}}function np(e,t,n,r){let i=e.sourceHeading?o(e.sourceHeading):e.title||r||``,a=e.template===`sectionHeader`&&e.autoTemplate!==!0&&e.sourceHeading&&!e.sourceHeading.templateAnnotation?.template?`content`:e.template??`content`,s=n?.has(a)??!1,c=bu(a)||s?a:`sectionHeader`,l=tp(c,i,e),u=ap(e.templateOverrides),d=u?ml(c,u).input:void 0,{id:f,startTime:p,duration:m,audioSegment:h,layers:g,transition:_,template:v,title:y,children:b,contents:x,sourceHeading:S,templateOverrides:C,templateData:w,...T}=e;return{id:e.id,template:c,duration:e.duration,audioSegment:0,transition:e.transition??(t>0?{type:`fade`,duration:.5}:void 0),title:i,...e.contents?{contents:e.contents}:{},...s&&e.children?{children:e.children}:{},...l,...T,...ip(e.templateData),...d}}var rp=new Set(Object.keys(ae));function ip(e){if(!e)return e;let t=!1,n={};for(let r of Object.keys(e)){if(rp.has(r)){t=!0;continue}n[r]=e[r]}return t?n:e}function ap(e){if(!e)return e;let t=!1,n={};for(let r of Object.keys(e)){if(rp.has(r)){t=!0;continue}n[r]=e[r]}return t?n:e}var op=[`zoomIn`,`zoomOut`,`panLeft`,`panRight`];function sp(e){return e?(e.split(/[\\/]/).pop()??``).replace(/\.[^.]+$/,``).trim():``}function cp(e,t){let n=e.frontmatter?.title;return typeof n==`string`&&n.trim()?n.trim():t?.trim()??``}function lp(e,t){let n=Dd(e.blocks),r=$f(e.blocks),i=new Set,a=e.customTemplates?new Set(e.customTemplates.map(e=>e.name)):void 0,o=cp(e,t?.documentTitle),s=[],c=0;for(let e=0;e<n.length;e++){let t=n[e],r=Qf(t.contents),l=np(t,e,a,o);if(r.length>0&&l.template===`sectionHeader`){let e=r[0];i.add(e.src),l.template=`imageWithCaption`,l.imageSrc=e.src,l.imageAlt=e.alt,l.caption=l.title,l.captionPosition=`bottom`,l.ambientMotion=op[c++%op.length]}else if(r.length>0){let e=r[0];i.add(e.src),l.accentImage||={src:e.src,alt:e.alt,position:`left-strip`,ambientMotion:op[c++%op.length]}}s.push(l)}let l=t?.interleaveImages??!0?r.filter(e=>!i.has(e.src)):[];if(l.length>0&&s.length>0){let e=Math.max(2,Math.floor(s.length/(l.length+1))),t=0;for(let n=0;n<l.length;n++){let r=Math.min((n+1)*e+t,s.length),i=l[n];s.splice(r,0,{id:`img-interleave-${n}`,template:`imageWithCaption`,duration:5,audioSegment:0,imageSrc:i.src,imageAlt:i.alt,ambientMotion:op[c++%op.length],transition:{type:`fade`,duration:.5}}),t++}}let u=0;for(let e of s)e.startTime=u,u+=e.duration;let d=e.audio?.segments?.length>0?e.audio:{segments:u>0?[{src:``,name:`preview`,duration:u,startTime:0}]:[]};return{...e,duration:u,blocks:s,audio:d}}function up(e,t,r){let i=t??e?.themeId??n(e?.frontmatter),a=e?.customThemes??Nu(e?.frontmatter);return(i?a?.find(e=>e.id===i):void 0)||O(i,r)}function dp(e){return e.sourceHeading?.templateAnnotation?.template||e.autoTemplate&&e.template?!0:!e.sourceHeading&&u(e)}function fp(e){return e.sourceHeading?.templateAnnotation?.template??e.template}function pp(e){if(!dp(e))return{templated:!1};let t=e.sourceHeading?.templateAnnotation,n=fp(e)??`sectionHeader`,r=j(n),i=ml(n,{...t?.params??{},...e.templateOverrides??{}}).input,a,s=null;if(t){let t=o(e.sourceHeading);s=$a(n,t,e.contents,{placeholders:!0}),a={id:e.id,template:n,startTime:0,duration:1,audioSegment:0,title:t,contents:e.contents,children:e.children,...s??{}}}else a={...e,startTime:e.startTime??0,duration:e.duration??1,audioSegment:e.audioSegment??0,template:n};let c={...a,...e.templateData??{},...i},l=Object.prototype.hasOwnProperty.call(i,`quote`)?i.quote:e.templateData?.quote;if(r===`quote`&&s&&!Object.prototype.hasOwnProperty.call(s,`title`)&&!(typeof l==`string`&&l.trim())){let t=c;t.quote=s.quote,!Object.prototype.hasOwnProperty.call(e.templateData??{},`title`)&&!Object.prototype.hasOwnProperty.call(i,`title`)&&delete t.title}return{templated:!0,templateName:r,templateBlock:c}}function mp(e){let t=e.contents;if(!t||t.length===0)return;let n=t.map(e=>o(e)).join(`
|
|
34
|
+
`).trim();return n?{text:n,markdown:t}:void 0}function hp(e){if(e?.src)return{type:`image`,src:e.src,alt:e.alt??``,credit:e.credit,license:e.license}}function gp(e,t,n){return{kind:`canvas-embed`,variant:e,slots:{media:{type:`canvas`,spatial:e,block:n??t.block,aspect:{width:t.viewport.width,height:t.viewport.height}}}}}var _p=e=>{let t=e,n=e.contents?.find(e=>e.type===`paragraph`),r=t.subtitle??(n?o(n):void 0);return{kind:`hero`,variant:`title`,slots:{title:t.title,subtitle:r},emphasis:`lead`,hints:t.backgroundColor?{backgroundColor:t.backgroundColor}:void 0}},vp=e=>{let t=e,n=t.imageSrc?{type:`image`,src:t.imageSrc,alt:t.imageAlt??``}:void 0;return{kind:`banner`,slots:{title:t.title,media:n},colorScheme:t.colorScheme,mediaBackground:!!t.imageSrc}},yp=e=>{let t=e,n=t.imageSrc?{type:`image`,src:t.imageSrc,alt:t.imageAlt??``}:void 0;return{kind:`hero`,variant:n?`media`:`title`,slots:{title:t.title,media:n},emphasis:`lead`,mediaBackground:!!n}},bp=e=>({kind:`prose`,slots:{title:e.title,body:mp(e)}}),xp=e=>{let t=e,n=t.counterpartName?`${t.speaker} \u2192 ${t.counterpartName}`:t.speaker;return{kind:`quote-band`,variant:`plain`,slots:{title:t.variant===`tool`?t.toolName:void 0,body:{text:t.text??``},attribution:n}}},Sp=e=>{let t=e;return{kind:`stat-band`,variant:`single`,slots:{items:[{value:t.stat,title:t.description,body:t.detail}],media:hp(t.accentImage)},emphasis:`strong`,colorScheme:t.colorScheme}},Cp=e=>{let t=e;return{kind:`quote-band`,variant:`plain`,slots:{title:t.title,body:{text:t.quote??``},attribution:t.attribution,media:hp(t.accentImage)}}},wp=e=>{let t=e;return{kind:`callout`,variant:`fact`,slots:{title:t.fact,body:{text:t.explanation??``},meta:t.source,media:hp(t.accentImage)}}},Tp=e=>{let t=e;return{kind:`card-grid`,variant:`two-column`,slots:{title:t.header,items:[{title:t.left?.label,body:t.left?.sublabel,accentScheme:t.leftColor},{title:t.right?.label,body:t.right?.sublabel,accentScheme:t.rightColor}]}}},Ep=e=>{let t=e;return{kind:`timeline-rail`,slots:{milestone:{date:t.date??``,description:t.description??``,footer:t.footer,mood:t.mood},media:hp(t.accentImage)}}},Dp=e=>{let t=e,n={type:`image`,src:t.imageSrc,alt:t.imageAlt??``,credit:t.imageCredit,license:t.imageLicense};return t.isTitle?{kind:`hero`,variant:`media`,slots:{title:t.caption,subtitle:t.subtitle,media:n},emphasis:`lead`,mediaBackground:!0}:{kind:`media-figure`,variant:`image`,slots:{media:n,caption:t.caption}}};function Op(e,t){return{kind:`feature-split`,variant:t===`left`?`media-left`:`media-right`,slots:{title:e.title,body:e.body?{text:e.body}:void 0,media:{type:`image`,src:e.imageSrc,alt:e.imageAlt??``,width:e.imageWidth,height:e.imageHeight}}}}var kp=e=>Op(e,`left`),Ap=e=>Op(e,`right`),jp=e=>{let t=e;return{kind:`quote-band`,variant:`display`,slots:{body:{text:t.text??``}},emphasis:`strong`,colorScheme:t.colorScheme}},Mp=e=>{let t=e,n=e.contents,r=Ra(n);return{kind:`item-list`,slots:{title:t.title,items:(t.items??[]).map((e,t)=>({body:e,...r[t]?.text===e?{markdown:r[t].markdown}:{}})),media:hp(t.accentImage)},colorScheme:t.colorScheme}},Np=e=>{let t=e,n=t.images??[];return{kind:`gallery`,slots:{...n.length===0?{title:e.title,body:mp(e)}:void 0,caption:t.caption,items:n.map(e=>({media:{type:`image`,src:e.src,alt:e.alt??``,credit:e.credit,license:e.license}}))}}},Pp=e=>{let t=e;return{kind:`callout`,variant:`definition`,slots:{title:t.term,body:{text:t.definition??``},meta:t.origin,media:hp(t.accentImage)},colorScheme:t.colorScheme}},Fp=e=>{let t=e;return{kind:`stat-band`,variant:`comparison`,slots:{items:[{title:t.leftLabel,value:t.leftValue},{title:t.rightLabel,value:t.rightValue}],meta:t.unit},emphasis:`strong`,colorScheme:t.colorScheme}},Ip=e=>{let t=e,n=t.backgroundImage;return{kind:`quote-band`,variant:`full-bleed`,slots:{body:{text:t.text??``},attribution:t.attribution,media:n?.src?{type:`image`,src:n.src,alt:n.alt??``,credit:n.credit,license:n.license}:void 0},emphasis:`strong`,mediaBackground:!!n?.src}},Lp=e=>{let t=e;return{kind:`media-figure`,variant:`video`,slots:{media:{type:`video`,src:t.videoSrc,posterSrc:t.posterSrc,alt:t.videoAlt??``,clipStart:t.clipStart,clipEnd:t.clipEnd,credit:t.videoCredit,license:t.videoLicense},caption:t.caption}}},Rp=e=>{let t=e,n=t.backgroundVideo;return{kind:`quote-band`,variant:`full-bleed`,slots:{body:{text:t.text??``},attribution:t.attribution,media:n?.src?{type:`video`,src:n.src,posterSrc:n.posterSrc,alt:n.alt??``,clipStart:n.clipStart,clipEnd:n.clipEnd,credit:n.credit,license:n.license}:void 0},emphasis:`strong`,mediaBackground:!!n?.src}},zp=e=>{let t=e;return{kind:`table-section`,slots:{title:t.title,table:{headers:t.headers??[],rows:t.rows??[],align:t.align}},colorScheme:t.colorScheme}},Bp=(e,t)=>{let n=e;return Array.isArray(n.headers)&&Array.isArray(n.rows)&&rc({headers:n.headers,rows:n.rows},n)!==null?gp(`chart`,t,e):bp(e,t)},Vp={title:_p,sectionHeader:vp,bigText:yp,transcript:xp,content:bp,statHighlight:Sp,quote:Cp,factCard:wp,twoColumn:Tp,dateEvent:Ep,imageWithCaption:Dp,leftFeature:kp,rightFeature:Ap,map:(e,t)=>gp(`map`,t,e),fullBleedQuote:jp,list:Mp,photoGrid:Np,definitionCard:Pp,comparisonBar:Fp,pullQuote:Ip,videoWithCaption:Lp,videoPullQuote:Rp,dataTable:zp,barChart:Bp,columnChart:Bp,pieChart:Bp,donutChart:Bp,lineChart:Bp,areaChart:Bp,scatterChart:Bp,diagram:(e,t)=>gp(`diagram`,t,e),tree:(e,t)=>gp(`tree`,t,e),timeline:(e,t)=>gp(`timeline`,t,e),layout:(e,t)=>gp(`layout`,t,e),drawing:(e,t)=>gp(`drawing`,t,e)};function Hp(e,t){let n=e?.pageStyle??te(e??A);return!t?.spacing||t.spacing===n.tokens.sectionSpacing?n:{...n,tokens:{...n.tokens,sectionSpacing:t.spacing}}}var Up=new Set([`banner`,`stat-band`,`quote-band`,`callout`,`card-grid`,`item-list`,`timeline-rail`,`footer`]),Wp=new Set([`banner`,`quote-band`,`stat-band`,`footer`]),Gp=new Set([`callout`,`card-grid`,`stat-band`,`item-list`,`timeline-rail`,`table-section`]);function Kp(e){return e.type===`code`&&e.lang?.trim().toLowerCase()===`mermaid`}function qp(e,t){if(Kp(e))return!0;if(!t||t.length===0||e.type!==`code`)return!1;let n=e.lang?.trim().toLowerCase();return!!n&&t.includes(n)}function Jp(e){for(let t of e){if(!t||typeof t!=`object`)continue;let e=t;if(e.type===`htmlElement`&&typeof e.tagName==`string`&&[`img`,`video`,`audio`].includes(e.tagName.toLowerCase())||Array.isArray(e.children)&&Jp(e.children))return!0}return!1}function Yp(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.type===`image`||(t.type===`htmlBlock`||t.type===`htmlInline`)&&Array.isArray(t.htmlChildren)&&Jp(t.htmlChildren)?!0:Array.isArray(t.children)&&t.children.some(Yp)}function Xp(e,t,n){if(!e.contents||e.contents.length===0)return;let r=!!t.slots.media||!!t.slots.items?.some(e=>e.media!==void 0),i=e.contents.filter(e=>qp(e,n)||!r&&Yp(e));if(i.length!==0)return{text:i.map(e=>o(e)).join(`
|
|
35
|
+
`).trim(),markdown:i}}function Zp(e,t,n){let r=Xp(e,t,n);return r?{...t,slots:{...t.slots,richContent:r}}:t}function Qp(e,t,n,r){if(dp(e)){let i=pp(e),a=i.templateName,s=Vp[a];if(s)return{draft:Zp(e,s(i.templateBlock,{block:e,viewport:t}),r),source:`template`,templateName:a};let c=n?.find(e=>e.name===a);if(c)return{draft:Zp(e,{kind:`canvas-embed`,variant:`custom`,slots:{media:{type:`canvas`,spatial:`custom`,block:i.templateBlock,aspect:{width:c.viewport?.width??t.width,height:c.viewport?.height??t.height}}}},r),source:`custom-template`,templateName:a};let l={code:`unknown-template`,template:a,message:`Unknown template "${a}"`};return{draft:Zp(e,{kind:`callout`,variant:`diagnostic`,slots:{title:(e.sourceHeading?o(e.sourceHeading):void 0)??l.message,body:{text:Ma(e.contents)},meta:l.message},emphasis:`quiet`},r),source:`fallback`,templateName:a,diagnostic:l}}if(e.layers&&e.layers.length>0)return{draft:Zp(e,{kind:`canvas-embed`,variant:`authored`,slots:{media:{type:`canvas`,spatial:`authored`,block:e,aspect:{width:t.width,height:t.height}}}},r),source:`authored`};let i=e.sourceHeading;return{draft:{kind:`prose`,slots:{title:i?o(i):void 0,headingLevel:i?.depth,body:e.contents&&e.contents.length>0?{text:Ma(e.contents),markdown:e.contents}:void 0}},source:`prose`}}function $p(e,t,n){let r=n?e.templates?.[n]:void 0,i=e.sections?.[t];return r?i?{...i,...r,hints:{...i.hints,...r.hints}}:r:i}function em(e,t,n,r,i,a){let{draft:o,override:s}=e,c={...o.hints,...s?.hints},l={kind:s?.kind??o.kind,variant:s?.variant??o.variant,blockId:e.block?.id??`cover`,template:e.source===`template`||e.source===`custom-template`||e.source===`fallback`?e.templateName:void 0,slots:o.slots,emphasis:i,accent:a,background:r,index:t,totalSections:n,depth:e.depth,source:e.source};return e.diagnostic&&(l.diagnostic=e.diagnostic),Object.keys(c).length>0&&(l.hints=c),l}function tm(e,t){return t?e.colorSchemes?.[t]:void 0}function nm(e,t){let n=Object.keys(t.colorSchemes??{}),r=e.accentRotation.schemes;return!r||r.length===0?n:r.filter(e=>n.includes(e))}function rm(e,t={}){let n=t.theme??A,r=t.viewport??f.landscape,i=Hp(n),a=Qp(e,r,t.customTemplates,t.widgetFenceLangs),o=$p(i,a.draft.kind,a.templateName),s=o?.background??(a.draft.mediaBackground?`media`:`base`),c=o?.emphasis??a.draft.emphasis??`standard`,l=a.draft.colorScheme?{schemeName:a.draft.colorScheme,scheme:tm(n,a.draft.colorScheme),role:`block`}:{role:i.accentRotation.strategy===`none`?`none`:`primary`};return{section:em({...a,override:o,block:e,depth:0},t.blockIndex??0,t.totalBlocks??1,s,c,l),block:e,source:a.source,diagnostic:a.diagnostic}}function im(e,t={}){let n=t.theme??A,r=t.viewport??f.landscape,i=Hp(n,t.transformPage),a=t.customTemplates??e.customTemplates,s=[];if(t.cover){let e=t.cover;s.push({draft:{kind:`hero`,variant:`cover`,slots:{title:e.title,subtitle:e.subtitle,media:e.heroSrc?{type:`image`,src:e.heroSrc,alt:e.heroAlt??``,credit:e.heroCredit,license:e.heroLicense}:void 0},emphasis:`lead`,mediaBackground:!!e.heroSrc},source:`cover`,depth:0})}let c=(e,n)=>{for(let i of e){let e=Qp(i,r,a,t.widgetFenceLangs);s.push({...e,block:i,depth:n}),!(e.draft.kind===`canvas-embed`&&oe(e.templateName))&&i.children&&i.children.length>0&&c(i.children,n+1)}};if(c(e.blocks??[],0),t.cover&&s.length>1){let e=t.cover,n=s[1];if(n.draft.kind===`hero`&&n.draft.slots.title===e.title){let e=s[0].draft.slots.media;e&&!n.draft.slots.media&&(n.draft={...n.draft,slots:{...n.draft.slots,media:e},mediaBackground:!0}),s.splice(0,1)}else if(n.draft.kind===`prose`&&n.draft.slots.title===e.title){let t={...n.draft.slots};delete t.title,delete t.headingLevel;let r=t.body?.markdown;e.subtitle&&r&&r.length>0&&r[0].type===`paragraph`&&o(r[0])===e.subtitle&&(r=r.slice(1)),r&&r.length>0?(t.body={text:r.map(e=>o(e)).join(`
|
|
36
|
+
`).trim(),markdown:r},n.draft={...n.draft,slots:t}):s.splice(1,1)}}for(let e of s)e.override=$p(i,e.draft.kind,e.templateName);let l=s.length,u=i.tokens.backgroundRhythm,d=i.accentRotation.strategy,p=nm(i,n),m=d===`alternate-two`?Math.min(2,p.length):p.length,h=0,g=0,_=0,v=0,y=i.tokens.headingTreatment.eyebrow,b=[];for(let e=0;e<s.length;e++){let r=s[e],i=r.override?.kind??r.draft.kind,a;r.override?.background?a=r.override.background:r.draft.mediaBackground?a=`media`:i===`prose`||u===`flat`?a=`base`:u===`accent-bands`&&Wp.has(i)?a=`accent`:u===`tinted-panels`?a=Gp.has(i)?`alternate`:`base`:u===`alternate`||u===`accent-bands`?(a=h%2==1?`alternate`:`base`,h++):a=`base`;let o;if(r.draft.colorScheme)o={schemeName:r.draft.colorScheme,scheme:tm(n,r.draft.colorScheme),role:`block`};else if(Up.has(i)&&(d===`cycle`||d===`alternate-two`)&&m>0){let e=p[g%m];g++,o={schemeName:e,scheme:tm(n,e),role:`rotation`}}else o=d===`none`?{role:`none`}:{role:`primary`};let c=r.override?.emphasis??r.draft.emphasis??`standard`;t.transformPage?.emphasisCurve===`front-loaded`&&i!==`hero`&&i!==`prose`&&_<2&&(c===`standard`&&(c=`strong`),_++),(y===`numbered`||y===`mono-tag`)&&(i===`hero`||i===`banner`)&&(v++,r.draft.slots.eyebrow||(r.draft.slots={...r.draft.slots,eyebrow:String(v).padStart(2,`0`)}));let f=em(r,e,l,a,c,o);b.push({section:f,block:r.block,source:r.source,diagnostic:r.diagnostic})}return b}var am=`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.35'/%3E%3C/svg%3E")`;function om(e,t){let n=e??A,r=t??Hp(n),i=n.colors,a=n.typography;return{"--squisq-page-bg":i.background,"--squisq-page-bg-alt":i.backgroundLight,"--squisq-page-text":i.text,"--squisq-page-text-muted":i.textMuted,"--squisq-page-primary":i.primary,"--squisq-page-secondary":i.secondary,"--squisq-page-highlight":i.highlight,"--squisq-page-title-font":w(a.titleFont,`Georgia, serif`),"--squisq-page-body-font":w(a.bodyFont,`system-ui, sans-serif`),"--squisq-page-mono-font":w(a.monoFont,`ui-monospace, SFMono-Regular, Menlo, monospace`),"--squisq-page-line-height":String(a.lineHeight??1.65),"--squisq-page-title-weight":a.titleWeight===`normal`?`400`:`700`,"--squisq-page-content-max":`${r.tokens.contentMaxWidth}px`,"--squisq-page-wide-max":`${r.tokens.wideMaxWidth}px`,"--squisq-page-radius":`${r.tokens.cornerRadius}px`,"--squisq-page-accent":i.primary,"--squisq-page-accent-bg":i.backgroundLight,"--squisq-page-accent-text":i.text}}function sm(e){let t=e.tokens,n={"data-family":e.family,"data-spacing":t.sectionSpacing,"data-divider":t.divider,"data-rhythm":t.backgroundRhythm,"data-hero-style":t.heroStyle,"data-eyebrow":t.headingTreatment.eyebrow,"data-heading-scale":t.headingTreatment.scale,"data-framing":t.imageFraming,"data-shadow":t.shadow,"data-quote-mark":t.quoteMark,"data-numerals":t.numeralStyle};return t.headingTreatment.case&&t.headingTreatment.case!==`none`&&(n[`data-heading-case`]=t.headingTreatment.case),t.headingTreatment.underline&&t.headingTreatment.underline!==`none`&&(n[`data-underline`]=t.headingTreatment.underline),t.pattern&&t.pattern!==`none`&&(n[`data-pattern`]=t.pattern),n}var cm=`
|
|
37
37
|
.squisq-page-hero-grid { grid-template-columns: 1fr; gap: 1.5rem; }
|
|
38
38
|
.squisq-page-feature { grid-template-columns: 1fr; }
|
|
39
39
|
.squisq-page-feature--media-right .squisq-page-feature-media { order: 0; }
|
|
@@ -43,7 +43,7 @@ ${r}`:n||r}function Kd(e,t){let n=t?.includeTitles??!0,r=t?.blockSeparator??`
|
|
|
43
43
|
.squisq-page-milestone { grid-template-columns: 1fr; gap: 0.5rem; }
|
|
44
44
|
.squisq-page-milestone-rail { display: none; }
|
|
45
45
|
.squisq-page-section-inner { padding-inline: 18px; }
|
|
46
|
-
`,
|
|
46
|
+
`,lm=`
|
|
47
47
|
/* \u2500\u2500 Base \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
48
48
|
.squisq-page {
|
|
49
49
|
background: var(--squisq-page-bg);
|
|
@@ -79,7 +79,7 @@ ${r}`:n||r}function Kd(e,t){let n=t?.includeTitles??!0,r=t?.blockSeparator??`
|
|
|
79
79
|
transparent 1px 14px
|
|
80
80
|
);
|
|
81
81
|
}
|
|
82
|
-
.squisq-page[data-pattern='noise'] { background-image: ${
|
|
82
|
+
.squisq-page[data-pattern='noise'] { background-image: ${am}; }
|
|
83
83
|
|
|
84
84
|
/* Spacing scale */
|
|
85
85
|
.squisq-page[data-spacing='compact'] { --squisq-page-section-pad: 2.25rem; }
|
|
@@ -563,22 +563,22 @@ ${r}`:n||r}function Kd(e,t){let n=t?.includeTitles??!0,r=t?.blockSeparator??`
|
|
|
563
563
|
|
|
564
564
|
/* \u2500\u2500 Responsive \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
565
565
|
@container squisq-page (max-width: 720px) {
|
|
566
|
-
${
|
|
566
|
+
${cm}
|
|
567
567
|
}
|
|
568
568
|
@supports not (container-type: inline-size) {
|
|
569
569
|
@media (max-width: 720px) {
|
|
570
|
-
${
|
|
570
|
+
${cm}
|
|
571
571
|
}
|
|
572
572
|
}
|
|
573
|
-
`;function
|
|
573
|
+
`;function um(e){let t=om(e);return`.squisq-page {
|
|
574
574
|
${Object.entries(t).map(([e,t])=>` ${e}: ${t};`).join(`
|
|
575
575
|
`)}
|
|
576
576
|
}
|
|
577
|
-
${rm}`}var am=[1,1.5,2];function om(e){let t=typeof e==`number`?e:typeof e==`string`?Number(e.trim().replace(/%$/,``)):NaN;if(!Number.isFinite(t))return;let n=t>3?t/100:t;return am.find(e=>Math.abs(e-n)<.001)}var sm=new Set([`content`,`list`,`quote`,`definitionCard`,`factCard`,`dateEvent`]),cm=160,lm=360;function um(e){return!e.template||!sm.has(e.template)?1:e.textLength<cm?2:e.textLength<lm?1.5:1}function dm(e,t){let n=e.map(e=>e.explicit===void 0?t===`auto`?um(e):1:e.explicit),r=new Map;if(e.forEach((e,t)=>{let i=n[t];if(i===1)return;let a=e.explicit===void 0?1:2;r.set(i,(r.get(i)??0)+a)}),r.size<=1)return n;let i=2,a=-1;for(let[e,t]of r)(t>a||t===a&&e>i)&&(i=e,a=t);return e.map((e,t)=>e.explicit===void 0?n[t]===1?1:i:e.explicit)}var fm=32,pm=64,mm=/^[a-z0-9][a-z0-9-]*$/;function hm(e){if(typeof e==`number`)return Number.isFinite(e)?e:void 0;if(typeof e!=`string`)return;let t=e.trim().replace(/%$/,``);if(t.length===0)return;let n=Number(t);return Number.isFinite(n)?n:void 0}function gm(e){return`${Math.round(e*1e3)/1e3}%`}function _m(e,t,n){if(!e||typeof e!=`object`){n.push({path:t,message:`cell must be an object`});return}let r=e,i=hm(r.x),a=hm(r.y),o=hm(r.width),s=hm(r.height);if(i===void 0||i<0||i>100){n.push({path:`${t}.x`,message:`x must be a percent between 0 and 100`});return}if(a===void 0||a<0||a>100){n.push({path:`${t}.y`,message:`y must be a percent between 0 and 100`});return}if(o===void 0||o<=0||o>100){n.push({path:`${t}.width`,message:`width must be a percent greater than 0`});return}if(s===void 0||s<=0||s>100){n.push({path:`${t}.height`,message:`height must be a percent greater than 0`});return}let c={x:gm(i),y:gm(a),width:gm(o),height:gm(s)};if(r.block!==void 0){let e=typeof r.block==`string`?Number(r.block):r.block;if(typeof e!=`number`||!Number.isInteger(e)||e<1||e>pm){n.push({path:`${t}.block`,message:`block must be an integer between 1 and ${pm}`});return}c.block=e}if(r.zoom!==void 0){let e=om(r.zoom);if(e===void 0){n.push({path:`${t}.zoom`,message:`zoom must be 1, 1.5, or 2 (or 100/150/200 percent)`});return}c.zoom=e}return c}function vm(e,t,n){if(!Array.isArray(e)){n.push({path:t,message:`must be an array of cells`});return}if(e.length<1||e.length>fm){n.push({path:t,message:`must contain between 1 and ${fm} cells`});return}let r=[];for(let i=0;i<e.length;i++){let a=_m(e[i],`${t}[${i}]`,n);if(!a)return;r.push(a)}return r}function ym(e,t){if(!e||typeof e!=`object`){t.push({path:`titleSlot`,message:`titleSlot must be an object`});return}let n=e,r=n.placement===`bottom`?`bottom`:n.placement===`top`?`top`:void 0;if(r===void 0&&n.placement!==void 0){t.push({path:`titleSlot.placement`,message:`placement must be 'top' or 'bottom'`});return}let i=hm(n.height);if(i===void 0||i<=0||i>40){t.push({path:`titleSlot.height`,message:`height must be a percent between 0 and 40`});return}return{placement:r??`top`,height:gm(i)}}function bm(e){let t=[];if(!e||typeof e!=`object`)return{valid:!1,errors:[{path:``,message:`definition must be an object`}]};let n=e,r=typeof n.name==`string`?n.name.trim().toLowerCase():``;mm.test(r)||t.push({path:`name`,message:`name must be a slug (lowercase letters, digits, hyphens)`});let i=typeof n.label==`string`?n.label.trim():``;i.length===0&&t.push({path:`label`,message:`label must be a non-empty string`});let a=n.cells,o,s,c;!a||typeof a!=`object`?t.push({path:`cells`,message:`cells must be an object with a landscape array`}):(o=vm(a.landscape,`cells.landscape`,t),a.portrait!==void 0&&(s=vm(a.portrait,`cells.portrait`,t)),a.square!==void 0&&(c=vm(a.square,`cells.square`,t)),o&&(s&&s.length!==o.length&&t.push({path:`cells.portrait`,message:`portrait must define the same number of cells as landscape`}),c&&c.length!==o.length&&t.push({path:`cells.square`,message:`square must define the same number of cells as landscape`})));let l;if(n.titleSlot!==void 0&&(l=ym(n.titleSlot,t)),t.length>0||!o)return{valid:!1,errors:t};let u={name:r,label:i,cells:{landscape:o,...s?{portrait:s}:{},...c?{square:c}:{}}};return typeof n.description==`string`&&n.description.trim()&&(u.description=n.description.trim()),l&&(u.titleSlot=l),n.auto===!1&&(u.auto=!1),{valid:!0,errors:t,layout:u}}function xm(e){return e.cells.landscape.length}function Sm(e){return e.map(e=>({x:e.y,y:e.x,width:e.height,height:e.width,...e.block===void 0?{}:{block:e.block},...e.zoom===void 0?{}:{zoom:e.zoom}}))}function Cm(e,t,n){return(t===`portrait`?e.cells.portrait??Sm(e.cells.landscape):t===`square`?e.cells.square??e.cells.landscape:e.cells.landscape).map(e=>{let t=hm(e.x)??0,r=hm(e.y)??0,i=hm(e.width)??0,a=hm(e.height)??0,o={rect:{x:n.x+t/100*n.width,y:n.y+r/100*n.height,width:Math.max(1,i/100*n.width),height:Math.max(1,a/100*n.height)}};e.block!==void 0&&(o.block=e.block);let s=om(e.zoom);return s!==void 0&&(o.zoom=s),o})}var wm=`squisq-dashboard-layouts`,Tm={label:`lb`,description:`ds`,cells:`ce`,landscape:`ls`,portrait:`pt`,square:`sq`,width:`wd`,height:`hg`,block:`bk`,zoom:`zo`,titleSlot:`ts`,placement:`pl`,auto:`au`},Em=Object.fromEntries(Object.entries(Tm).map(([e,t])=>[t,e]));function Dm(e,t){if(Array.isArray(e))return e.map(e=>Dm(e,t));if(e&&typeof e==`object`){let n={};for(let[r,i]of Object.entries(e))n[t[r]??r]=Dm(i,t);return n}return e}function Om(e){if(!e)return;let t=Nm(e[wm]);if(!t)return;let n=[];for(let e of t){let t=bm(e);t.layout&&n.push(t.layout)}return n.length>0?n:void 0}function km(e,t){if(!e||e.length===0)return;let n={};for(let t of e){let{name:e,...r}=t;n[e]=Dm(r,Tm)}return JSON.stringify(n,null,t?.pretty?2:void 0)}function Am(e){return Object.entries(e).map(([e,t])=>({name:e,...Dm(t&&typeof t==`object`?t:{},Em)}))}function jm(e){return Array.isArray(e)?e:e&&typeof e==`object`?Am(e):null}function Mm(e){try{return JSON.parse(e)}catch{return}}function Nm(e){if(e==null)return null;if(Array.isArray(e))return e;if(typeof e==`object`)return Am(e);if(typeof e!=`string`)return null;let t=Mm(e.trim());return t===void 0?null:jm(t)}var Pm=2;function Q(e){return`${Math.round(e*1e3)/1e3}%`}function Fm(e,t,n=Pm){let r=(100-(e-1)*n)/e,i=(100-(t-1)*n)/t,a=[];for(let o=0;o<t;o++)for(let t=0;t<e;t++)a.push({x:Q(t*(r+n)),y:Q(o*(i+n)),width:Q(r),height:Q(i)});return a}function Im(e,t,n=Pm){let r=e+n,i=100-r,a=(100-(t-1)*n)/t,o=[{x:`0%`,y:`0%`,width:Q(e),height:`100%`}];for(let e=0;e<t;e++)o.push({x:Q(r),y:Q(e*(a+n)),width:Q(i),height:Q(a)});return o}function Lm(e,t,n=Pm){let r=e+n,i=100-r,a=(100-(t-1)*n)/t,o=[{x:`0%`,y:`0%`,width:`100%`,height:Q(e)}];for(let e=0;e<t;e++)o.push({x:Q(e*(a+n)),y:Q(r),width:Q(a),height:Q(i)});return o}function Rm(e,t=Pm){let n=e+t,r=(100-n-t)/2,i=(100-t)/2,a=[{x:`0%`,y:`0%`,width:Q(e),height:`100%`}];for(let e=0;e<2;e++)for(let o=0;o<2;o++)a.push({x:Q(n+o*(r+t)),y:Q(e*(i+t)),width:Q(r),height:Q(i)});return a}var zm=Object.freeze([{name:`focus-1`,label:`Focus`,description:`One block fills the dashboard.`,cells:{landscape:[{x:`0%`,y:`0%`,width:`100%`,height:`100%`}]}},{name:`split-2`,label:`Split`,description:`Two blocks side by side.`,cells:{landscape:Fm(2,1)}},{name:`hero-left`,label:`Hero + 2`,description:`A large lead block with two companions.`,cells:{landscape:Im(58,2),portrait:[{x:`0%`,y:`0%`,width:`100%`,height:Q(46)},{x:`0%`,y:Q(48),width:`100%`,height:Q(25)},{x:`0%`,y:Q(75),width:`100%`,height:Q(25)}]}},{name:`grid-2x2`,label:`Grid 2×2`,description:`Four blocks in a balanced grid.`,cells:{landscape:Fm(2,2)}},{name:`hero-top`,label:`Hero band`,description:`A wide lead band with three blocks below.`,cells:{landscape:Lm(46,3),portrait:[{x:`0%`,y:`0%`,width:`100%`,height:Q(40)},{x:`0%`,y:Q(42),width:`100%`,height:Q(18)},{x:`0%`,y:Q(62),width:`100%`,height:Q(18)},{x:`0%`,y:Q(82),width:`100%`,height:Q(18)}]},auto:!1},{name:`mosaic-5`,label:`Mosaic`,description:`A hero block beside a 2×2 grid.`,cells:{landscape:Rm(58),portrait:[{x:`0%`,y:`0%`,width:`100%`,height:Q(40)},{x:`0%`,y:Q(42),width:Q(49),height:Q(27)},{x:Q(51),y:Q(42),width:Q(49),height:Q(27)},{x:`0%`,y:Q(71),width:Q(49),height:Q(29)},{x:Q(51),y:Q(71),width:Q(49),height:Q(29)}]}},{name:`grid-3x2`,label:`Grid 3×2`,description:`Six blocks in three columns.`,cells:{landscape:Fm(3,2)}},{name:`grid-3x3`,label:`Grid 3×3`,description:`Nine blocks in a square grid.`,cells:{landscape:Fm(3,3),square:Fm(3,3)}},{name:`grid-4x3`,label:`Grid 4×3`,description:`Twelve blocks in four columns.`,cells:{landscape:Fm(4,3)}},{name:`grid-4x4`,label:`Grid 4×4`,description:`Sixteen blocks — the densest wall.`,cells:{landscape:Fm(4,4)}}]);function Bm(e,t){return{id:e.name,label:e.label,...e.description?{description:e.description}:{},capacity:xm(e),custom:t}}function Vm(){return zm.map(e=>Bm(e,!1))}function Hm(e){let t=Om(e?.frontmatter)??[],n=new Set(t.map(e=>e.name));return[...t.map(e=>Bm(e,!0)),...zm.filter(e=>!n.has(e.name)).map(e=>Bm(e,!1))]}var Um=`auto`;function Wm(e,t){let n=e.trim().toLowerCase();if(n)return t?.find(e=>e.name===n)??zm.find(e=>e.name===n)}function Gm(e,t,n){let r=[...(n??[]).filter(e=>e.auto!==!1),...zm.filter(e=>e.auto!==!1)].sort((e,t)=>xm(e)-xm(t)),i=Math.max(1,e),a=r.find(e=>xm(e)>=i);if(a)return a;let o=r.reduce((e,t)=>Math.max(e,xm(t)),0);return r.find(e=>xm(e)===o)??zm[0]}var Km=[`basic`,`card`,`panel`,`accent`],qm=`basic`,Jm=Object.freeze([{id:`basic`,label:`Basic`,description:`Blocks fill their cells edge to edge.`},{id:`card`,label:`Cards`,description:`Each block sits on a raised, rounded card.`},{id:`panel`,label:`Panels`,description:`Flat outlined panels with an accent rule.`},{id:`accent`,label:`Accent cards`,description:`Cards tinted with the theme's accent colors in rotation.`}]);function Ym(e){if(typeof e!=`string`)return;let t=e.trim().toLowerCase();if(t)return t===`none`||t==="default"||t===`flat`?`basic`:t===`cards`?`card`:t===`panels`||t===`outline`?`panel`:t===`accents`||t===`accent-cards`?`accent`:Km.includes(t)?t:void 0}function Xm(e,t,n){return Math.min(n,Math.max(t,e))}function Zm(e){return x(e)>.45}function Qm(e,t){let n=t.colors.background;return e===`basic`||e===`panel`?n:Zm(n)?b(n,.05):re(n,.04)}function $m(e,t){let n=Object.values(e.colorSchemes??{});if(n.length===0)return e.colors.primary;let r=n[(t%n.length+n.length)%n.length];return r.accent||r.text||e.colors.primary}function eh(e,t,n){let r=Math.max(1,Math.min(n.width,n.height)),i=t.style?.borderRadius??14;return e===`panel`?{edge:Xm(r*.014,3,12),radius:Xm(i*.45,0,r*.05)}:{edge:Xm(r*.03,6,26),radius:Xm(i,6,r*.1)}}function th(e,t){if(!(e<=0))return`${Math.round(e/Math.max(1,t.width)*1e5)/1e3}% / ${Math.round(e/Math.max(1,t.height)*1e5)/1e3}%`}function nh(e,t){let{theme:n,rect:r,index:i}=t;if(e===`basic`)return null;let{edge:a,radius:o}=eh(e,n,r),s={x:r.x+a,y:r.y+a,width:Math.max(1,r.width-a*2),height:Math.max(1,r.height-a*2)},c={x:a,y:a,width:s.width,height:s.height},l=Math.max(1,Math.min(r.width,r.height)),u=Math.max(1,Math.round(l*.004)),d=$m(n,i),f=[];e!==`panel`&&[{spread:.45,dy:.5,alpha:.05},{spread:.25,dy:.42,alpha:.05},{spread:.08,dy:.3,alpha:.06}].forEach((e,t)=>{let r=a*e.spread,i=a*e.dy;f.push({type:`shape`,id:`cell-shadow-${t}`,content:{shape:`rect`,fill:C(n.colors.text,e.alpha),borderRadius:o+r},position:{x:c.x-r,y:c.y-r+i,width:c.width+r*2,height:c.height+r*2}})}),f.push({type:`shape`,id:`cell-surface`,content:{shape:`rect`,fill:n.colors.background,borderRadius:o},position:{x:c.x,y:c.y,width:c.width,height:c.height}});let p=[];if(e===`accent`&&p.push({type:`shape`,id:`cell-accent-wash`,content:{shape:`rect`,fill:C(d,.1),borderRadius:o},position:{x:0,y:0,width:`100%`,height:`100%`}}),e===`accent`||e===`panel`){let e=Math.max(2,Math.round(l*.014));p.push({type:`shape`,id:`cell-accent-bar`,content:{shape:`rect`,fill:d},position:{x:0,y:0,width:`100%`,height:e}})}let m=e===`panel`?u:Math.max(1,u*.6);p.push({type:`shape`,id:`cell-border`,content:{shape:`rect`,fill:`none`,stroke:e===`panel`?C(d,.45):C(n.colors.text,.14),strokeWidth:m,borderRadius:o},position:{x:m/2,y:m/2,width:Math.max(1,c.width-m),height:Math.max(1,c.height-m)}});let h={cardRect:s,contentRect:s,layers:f,overlayLayers:p,radius:o},g=th(o,s);return g&&(h.contentRadiusPct=g),h}function rh(e){return e!==`basic`}function ih(e,t){let n=e[0];if(!n||n.type!==`shape`)return[...e];let{content:r,position:i}=n,a=typeof r.fill==`string`?r.fill.trim().toLowerCase():``;return!(r.shape===`rect`&&(i.x===0||i.x===`0%`)&&(i.y===0||i.y===`0%`)&&i.width===`100%`&&i.height===`100%`)||r.gradient||r.pattern||a!==t.colors.background.trim().toLowerCase()?[...e]:e.slice(1)}var ah=Object.freeze({layout:{canonical:`squisq-dashboard-layout`,legacy:`dashboard-layout`},showTitle:{canonical:`squisq-dashboard-title`,legacy:`dashboard-title`},zoom:{canonical:`squisq-dashboard-zoom`,legacy:`dashboard-zoom`},style:{canonical:`squisq-dashboard-style`,legacy:`dashboard-style`}}),oh=Object.freeze({layout:Um,showTitle:!0,zoom:`auto`,style:qm});function sh(e,t){if(e)return Object.prototype.hasOwnProperty.call(e,t.canonical)?e[t.canonical]:e[t.legacy]}function ch(e){if(typeof e==`boolean`)return e;if(typeof e!=`string`)return;let t=e.trim().toLowerCase();if([`true`,`yes`,`on`,`show`,`visible`].includes(t))return!0;if([`false`,`no`,`off`,`hide`,`hidden`].includes(t))return!1}function lh(e){if(typeof e!=`string`)return;let t=e.trim().toLowerCase();if(t)return t===`auto`||t==="default"?Um:t}function uh(e){if(typeof e==`boolean`)return e?`auto`:`off`;if(typeof e!=`string`)return;let t=e.trim().toLowerCase();if([`auto`,`on`,`true`,`yes`].includes(t))return`auto`;if([`off`,`false`,`no`,`none`,`100`,`100%`,`1`].includes(t))return`off`}function dh(e,t={}){let n={layout:lh(sh(e,ah.layout))??oh.layout,showTitle:ch(sh(e,ah.showTitle))??oh.showTitle,zoom:uh(sh(e,ah.zoom))??oh.zoom,style:Ym(sh(e,ah.style))??oh.style};return{layout:lh(t.layout)??n.layout,showTitle:t.showTitle??n.showTitle,zoom:t.zoom??n.zoom,style:Ym(t.style)??n.style}}var fh={placement:`top`,height:`9%`},ph=.015,mh=.02;function hh(e){let t=Number(e.trim().replace(/%$/,``));return Number.isFinite(t)?t:0}function gh(e,t){return`${Math.round(e/Math.max(1,t)*1e5)/1e3}%`}function _h(e,t){return{left:gh(e.x,t.width),top:gh(e.y,t.height),width:gh(e.width,t.width),height:gh(e.height,t.height)}}function vh(e,t){let n=e.frontmatter?.title;return typeof n==`string`&&n.trim()?n.trim():t?.trim()??``}function yh(e,t){if(e.length===0||!t)return e;let n=e[0],r=typeof n.title==`string`?n.title.trim().toLowerCase():``;if(!r||r!==t.trim().toLowerCase())return e;let i=n.template,a=i===`title`||i===`sectionHeader`||i===`cover`,o=Array.isArray(n.contents)&&n.contents.length>0;return a||!o?e.slice(1):e}function bh(e,t,n,r,i,a){let o=p(r,0,1,i),s=h(i),c=Math.min(44*s,t.height*.52),l=Math.max(4,Math.round(6*s)),u=a+l+Math.max(10,Math.round(l*2.5));return[{type:`shape`,id:`dashboard-title-accent`,content:{shape:`rect`,fill:r.colors.primary},position:{x:a,y:`26%`,width:l,height:`48%`}},{type:`text`,id:`dashboard-title-text`,content:{text:e,style:{fontSize:c,fontFamily:I(o,`title`),fontWeight:`bold`,color:r.colors.text,textAlign:`left`,verticalAlign:`middle`,maxLines:1}},position:{x:u,y:0,width:Math.max(1,t.width-u-a),height:`100%`}},{type:`shape`,id:`dashboard-title-rule`,content:{shape:`rect`,fill:C(r.colors.text,.14)},position:{x:0,y:n.placement===`bottom`?0:t.height-2,width:`100%`,height:2}}]}function xh(e,t={}){let n=t.theme??A,r=t.viewport??f.landscape,i=_(r),a=t.customLayouts??Om(e.frontmatter),o=t.customTemplates??e.customTemplates,s=[],c=dh(e.frontmatter,{layout:typeof t.layout==`string`?t.layout:void 0,showTitle:t.showTitle,zoom:t.zoom,...t.style===void 0?{}:{style:t.style}}),l=c.style,u,d=`auto`;if(t.layout&&typeof t.layout==`object`){let e=bm(t.layout);e.layout?(u=e.layout,d=`option`):s.push({type:`unknown-layout`,message:`Inline dashboard layout definition is invalid; falling back to auto.`,requestedLayout:t.layout.name})}else if(c.layout!==`auto`){let e=Wm(c.layout,a);e?(u=e,d=typeof t.layout==`string`&&t.layout.trim()?`option`:`frontmatter`):s.push({type:`unknown-layout`,message:`Unknown dashboard layout "${c.layout}"; falling back to auto.`,requestedLayout:c.layout})}let m=ip(e,{documentTitle:t.documentTitle,interleaveImages:!1}).blocks??[];m.length===0&&s.push({type:`empty-doc`,message:`The document has no renderable blocks; the dashboard has no cells.`});let h=c.showTitle?vh(e,t.documentTitle):``,g=h.length>0;g&&(m=yh(m,h)),u||(u=Gm(m.length,i,a),d=`auto`);let v=mh*Math.min(r.width,r.height),y={x:v,y:v,width:Math.max(1,r.width-v*2),height:Math.max(1,r.height-v*2)},b=null;if(g){let e=u.titleSlot??fh,t=Math.min(40,Math.max(2,hh(e.height)))/100*r.height,i=ph*r.height,a=e.placement===`bottom`?{x:0,y:r.height-t,width:r.width,height:t}:{x:0,y:0,width:r.width,height:t};y=e.placement===`bottom`?{x:v,y:v,width:Math.max(1,r.width-v*2),height:Math.max(1,r.height-t-i-v)}:{x:v,y:t+i,width:Math.max(1,r.width-v*2),height:Math.max(1,r.height-t-i-v)};let o={width:Math.max(1,Math.round(a.width)),height:Math.max(1,Math.round(a.height)),name:`Dashboard title`};b={text:h,rect:a,rectPct:_h(a,r),viewport:o,layers:bh(h,o,e,n,r,v)}}let x=Cm(u,i,y),S=[],C=new Set;x.forEach((e,t)=>{if(e.block===void 0)return;let n=e.block-1;if(n<0||n>=m.length){s.push({type:`invalid-cell-assignment`,message:`Cell ${t+1} of layout "${u.name}" requests block ${e.block}, but the document has ${m.length} block(s); the cell is left empty.`});return}C.add(n),S.push({cellIndex:t,rect:e.rect,candidateIndex:n,explicitZoom:e.zoom})});let w=new Set,T=0;x.forEach((e,t)=>{if(e.block===void 0){for(;T<m.length&&C.has(T);)T++;T>=m.length||(w.add(T),S.push({cellIndex:t,rect:e.rect,candidateIndex:T,explicitZoom:e.zoom}),T++)}});let E=[];for(let e=0;e<m.length;e++)!C.has(e)&&!w.has(e)&&E.push(e);E.length>0&&s.push({type:`overflow`,message:`${E.length} block(s) exceed the "${u.name}" layout's ${x.length} cell(s) and are not rendered.`,hiddenBlockIds:E.map(e=>String(m[e].id??e))});let D=S.sort((e,t)=>e.cellIndex-t.cellIndex),O=dm(D.map(({candidateIndex:e,explicitZoom:t})=>{let n=m[e],r=typeof n.title==`string`?n.title:``;return{template:j(n.template??``),textLength:r.length+Nd(n).length,...t===void 0?{}:{explicit:t}}}),c.zoom),k=o&&o.length>0?Hc(o):Vc,ee=D.map(({cellIndex:e,rect:i,candidateIndex:a},o)=>{let s=m[a],c=O[o],u=nh(l,{theme:n,rect:i,index:e}),d=u?u.contentRect:i,f={width:Math.max(1,Math.round(d.width)),height:Math.max(1,Math.round(d.height)),name:`Dashboard cell ${e+1}`},h=p(n,a,m.length,f);c!==1&&(h.fontScale*=c);let g=Hl(s,{theme:n,viewport:f,persistentLayers:!1,blockIndex:a,totalBlocks:m.length,failureMode:t.failureMode},{registry:k,templateContext:h}),_=rh(l)?ih(g.layers,n):g.layers,v;if(u){let t={width:Math.max(1,Math.round(i.width)),height:Math.max(1,Math.round(i.height)),name:`Dashboard cell ${e+1} frame`};v={rect:i,rectPct:_h(i,r),viewport:t,layers:u.layers,overlayLayers:u.overlayLayers,overlayViewport:{width:f.width,height:f.height,name:`Dashboard cell ${e+1} overlay`},...u.contentRadiusPct?{contentRadiusPct:u.contentRadiusPct}:{}}}return{index:e,block:s,blockIndex:a,layers:_,rect:d,rectPct:_h(d,r),...v?{frame:v}:{},viewport:f,zoom:c,source:g.source,...g.diagnostic?{diagnostic:g.diagnostic}:{}}}),te=Ei(e,n),ne=Qm(l,n),re={fill:ne,bottomLayers:[{type:`shape`,id:`dashboard-backdrop`,content:{shape:`rect`,fill:ne},position:{x:0,y:0,width:`100%`,height:`100%`}},...wi(te?.bottomLayers,n)],topLayers:wi(te?.topLayers,n)};return{layout:u,layoutSource:d,style:l,viewport:r,cells:ee,title:b,backdrop:re,diagnostics:s}}function Sh(e){let t=[...e.backdrop.bottomLayers];for(let n of e.cells)n.frame&&t.push(...Nl(n.frame.layers,n.frame.viewport,n.frame.rect,`cell-${n.index}-frame`)),t.push(...Nl(n.layers,n.viewport,n.rect,`cell-${n.index}`)),n.frame&&n.frame.overlayLayers.length>0&&t.push(...Nl(n.frame.overlayLayers,n.frame.overlayViewport,n.rect,`cell-${n.index}-overlay`));return e.title&&t.push(...Nl(e.title.layers,e.title.viewport,e.title.rect,`dashboard-title`)),t.push(...e.backdrop.topLayers),t}var Ch=new Set([`answer`,`back`,`solution`,`explanation`,`correct answer`,`correct`,`distractor`,`option`]);function wh(e){return typeof e==`string`?e.trim().toLowerCase().replace(/[\s_-]+/g,``):``}function Th(e){let t=wh(e);if(t===`flashcard`||t===`card`||t===`basicflashcard`)return`basic`;if(t===`multiplechoiceflashcard`||t===`multiplechoice`||t===`quiz`)return`multiple-choice`;if(t===`group`||t===`flashcardgroup`||t===`deck`)return`group`}function Eh(e){let t=Th(e.metadata?.study)??Th(e.metadata?.[`study-mode`]);if(t)return t;for(let t of e.classes??[]){let e=Th(t);if(e)return e}return Th(e.template)}function Dh(e){return typeof e.title==`string`&&e.title.trim().length>0}function Oh(e){return(e.contents?.length??0)>0||(e.media?.length??0)>0||(e.layers?.length??0)>0}function kh(e){return Dh(e)||Oh(e)}function Ah(e){return Dh(e)&&Ch.has(e.title.trim().toLowerCase())}function jh(e){let{children:t,...n}=e;return n}function Mh(e){let{children:t,contents:n,media:r,layers:i,...a}=e;return a}function Nh(e){let{children:t,title:n,...r}=e;return r}function $(...e){return{blocks:e}}function Ph(e){return e===!0||typeof e==`string`&&[`true`,`yes`,`on`,`1`,`correct`].includes(e.trim().toLowerCase())}function Fh(e){return Ph(e.metadata?.correct)||Ph(e.metadata?.answer)||(e.classes??[]).some(e=>wh(e)===`correct`)}function Ih(e){let t=Eh(e);if(t===`group`)return!1;if(t===`basic`||t===`multiple-choice`)return!0;if(Ah(e))return!1;let n=e.children??[];return n.length===0?Dh(e)&&Oh(e):n.length===1?kh(e)&&kh(n[0]):n.every(kh)}function Lh(e){for(let t of e.children??[]){let e=Eh(t);if(e===`basic`||e===`multiple-choice`||Lh(t))return!0}return!1}function Rh(e){let t=e.children??[];return t.length===0?!1:Lh(e)?!0:Oh(e)?!1:t.length===1?Ih(t[0])&&!Ah(t[0]):t.filter(Ih).length>=2}function zh(e){return Oh(e)?$(Nh(e)):void 0}function Bh(e,t){let n=e.children??[],r,i,a,o;if(n.length===0?(r=Dh(e)?$(Mh(e)):$(),i=Oh(e)?$(Nh(e)):$()):n.length===1?(r=kh(e)?$(jh(e)):$(),i=kh(n[0])?$(n[0]):$()):(r=kh(n[0])?$(n[0]):$(),i=$(...n.slice(1).filter(kh)),a=Dh(e)?e.title.trim():void 0,o=zh(e)),r.blocks.length===0&&t.push({severity:`error`,code:`empty-front`,message:`Flashcard "${e.id}" has no content for its front`,blockId:e.id}),i.blocks.length===0&&t.push({severity:`error`,code:`empty-back`,message:`Flashcard "${e.id}" has no content for its answer`,blockId:e.id}),!(r.blocks.length===0||i.blocks.length===0))return{id:e.id,sourceBlockId:e.id,kind:`basic`,...a?{label:a}:{},front:r,back:i,...o?{explanation:o}:{}}}function Vh(e,t){let n=e.children??[],r=n[0],i=n.slice(1).filter(kh);if((!r||!kh(r))&&t.push({severity:`error`,code:`empty-front`,message:`Multiple-choice flashcard "${e.id}" has no question block`,blockId:e.id}),i.length===0&&t.push({severity:`error`,code:`empty-back`,message:`Multiple-choice flashcard "${e.id}" has no answer choices`,blockId:e.id}),!r||!kh(r)||i.length===0)return;let a=i.filter(Fh);a.length>1&&t.push({severity:`warning`,code:`multiple-correct-answers`,message:`Multiple-choice flashcard "${e.id}" marks more than one answer correct; the first marker wins`,blockId:e.id});let o=a[0]??i[0];i.length<2&&t.push({severity:`warning`,code:`multiple-choice-needs-distractor`,message:`Multiple-choice flashcard "${e.id}" needs at least one distractor`,blockId:e.id});let s=i.map((t,n)=>({id:`${e.id}-choice-${n+1}`,sourceBlockId:t.id,content:$(t),correct:t===o})),c=zh(e);return{id:e.id,sourceBlockId:e.id,kind:`multiple-choice`,...Dh(e)?{label:e.title.trim()}:{},front:$(r),back:$(o),choices:s,...c?{explanation:c}:{}}}function Hh(e){let t=e.frontmatter?.title;return typeof t==`string`&&t.trim()?t.trim():e.startBlock?.title?.trim()||void 0}function Uh(e,t={}){let n=t.source??`auto`,r=[],i=[],a=e=>{let t=Eh(e);if(t===`group`){for(let t of e.children??[])a(t);return}if(t===`basic`){let t=Bh(e,i);t&&r.push(t);return}if(t===`multiple-choice`){let t=Vh(e,i);t&&r.push(t);return}if(n===`explicit`){for(let t of e.children??[])a(t);return}if(Rh(e)){for(let t of e.children??[])a(t);return}if(Ih(e)){let t=Bh(e,i);t&&r.push(t);return}for(let t of e.children??[])a(t)};for(let t of e.blocks)a(t);let o=Hh(e),s=typeof e.frontmatter?.title==`string`?e.frontmatter.title.trim():``,c=r[0]?.front.blocks[0]?.title?.trim(),l=o&&(s||o!==c)?o:void 0;return{...l?{title:l}:{},cards:r,diagnostics:i}}var Wh=.5,Gh=.8,Kh=1;function qh(e){let t=e.title?e.title.trim():``,n=Nd(e);return t&&n?`${t}
|
|
578
|
-
${n}`:t||n}function
|
|
579
|
-
`)}function rg(e){let t=[];for(let n of e)n.children&&n.children.length>0?t.push(...rg(n.children)):t.push(n);return t}var ig=[`.mp3`,`.wav`,`.ogg`,`.m4a`],ag=[`.webm`,`.mp4`];function og(e){let t=e.toLowerCase();return ig.some(e=>t.endsWith(e))?!0:ag.some(e=>t.endsWith(e))?t.startsWith(`audio/`):!1}function sg(e){let t=e.toLowerCase();for(let n of[...ig,...ag])if(t.endsWith(n))return e.slice(0,-n.length);return e}function cg(e){try{let t=new TextDecoder().decode(e),n=JSON.parse(t);return n&&n.version===2&&n.sections?n.sections:null}catch{return null}}async function lg(e){let t=(await e.listFiles()).filter(e=>og(e.path)),n=[],r=null,i=await e.readFile(`timing.json`);i&&(r=cg(i));for(let i of t){let t=i.path.split(`/`).pop()??i.path,a=null;if(r){let e=sg(t),n=``;for(let[t,i]of Object.entries(r))e.endsWith(`-${t}`)&&t.length>n.length&&(n=t,a=i)}if(!a){let t=`${i.path}.timing.json`,n=await e.readFile(t);n&&(a=Qh(n))}n.push({path:i.path,filename:t,timing:a})}return n}function ug(e,t){let n=[],r=rg(e);for(let e of r){let r=e.templateOverrides?.audio;if(!r)continue;let i=t.find(e=>e.filename===r||e.path===r||e.path.endsWith(`/${r}`));i&&n.push({block:e,audio:i})}return n}var dg=.35,fg=.5;function pg(e,t){let n=rg(e);if(n.length===0||t.length===0)return[];let r=[];for(let e=0;e<t.length;e++){let i=t[e];for(let t=0;t<n.length;t++){let a=n[t],o=ng(a);if(!o.trim())continue;let s=0;if(i.timing?.sourceText&&(s=eg(i.timing.sourceText,o)),s<dg&&a.title){let e=tg(a.title);tg(sg(i.filename)).includes(e)&&e.length>=3&&(s=Math.max(s,fg+.1))}s>=dg&&r.push({block:a,blockIndex:t,audio:i,audioIndex:e,score:s})}}r.sort((e,t)=>t.score-e.score);let i=new Set,a=new Set,o=[];for(let e of r)i.has(e.blockIndex)||a.has(e.audioIndex)||(i.add(e.blockIndex),a.add(e.audioIndex),o.push({block:e.block,audio:e.audio,score:e.score}));return o}async function mg(e,t){let n=await Zh(e,t);e=n.doc;let r=await lg(t),i=new Set(ee(e).map(e=>e.src)),a=r.filter(e=>!i.has(e.path));if(a.length===0)return e;let o=ug(e.blocks,a);if(o.length===0&&!n.applied&&(o=pg(e.blocks,a).map(e=>({block:e.block,audio:e.audio}))),o.length===0)return e;let s=rg(e.blocks),c=new Map(s.map((e,t)=>[e.id,t]));o.sort((e,t)=>(c.get(e.block.id)??0)-(c.get(t.block.id)??0));let l=[],u=new Map,d=0;for(let e=0;e<o.length;e++){let{block:t,audio:n}=o[e],r=n.timing?.duration??30;l.push({src:n.path,name:t.title??t.id,duration:r,startTime:d}),u.set(t.id,e),d+=r}let f=hg(e.blocks,u);return{...e,blocks:f,duration:n.applied?Math.max(e.duration,d):d,audio:{segments:l}}}function hg(e,t,n){return e.map(e=>{let r=t.get(e.id)??n??e.audioSegment,i={...e,audioSegment:r};return e.children&&(i.children=hg(e.children,t,r)),i})}function gg(e,t){return _g(_e(e),t)}function _g(e,t){let n=bd(e),r=[...n.diagnostics??[]],i=xd(n.blocks),a=vg(n,t),o=new Set(n.customTemplates?.map(e=>e.name)??[]),s=(e,t)=>{bg(e,t,a,r),wg(e,t,r),Tg(e,r),xg(e,t,o,r),Dg(e,r),yg(e)&&Eg(e,r);for(let t of e.children??[])s(t,e)};for(let e of n.blocks)s(e,void 0);return kg(e,r),t?.assets&&Pg(e,i,Ag(t.assets),r),r.sort((e,t)=>(e.line??2**53-1)-(t.line??2**53-1)),{diagnostics:r,errorCount:r.filter(e=>e.severity===`error`).length,warningCount:r.filter(e=>e.severity===`warning`).length,infoCount:r.filter(e=>e.severity===`info`).length,doc:n}}function vg(e,t){return new Set([...Object.keys(Vc),...Object.keys(me),...e.customTemplates?.map(e=>e.name)??[],...t?.extraTemplates??[]])}function yg(e){return j(e.template??``)===`drawing`}function bg(e,t,n,r){let i=e.sourceHeading?.templateAnnotation?.template??e.sourceAnnotation?.template;if(!i)return;if(t&&yg(t)){if(es(i))return;let t=Xc(i,new Set(Zo),{map:j});r.push({severity:`warning`,code:`unknown-shape`,message:`Unknown shape "${i}" in drawing \u2014 the child will be skipped`+(t?`. Did you mean "${t}"?`:``),blockId:e.id,...Ig(e)});return}if(es(i)){r.push({severity:`warning`,code:`shape-outside-drawing`,message:`Shape "${i}" is only recognized on a child heading of a {[drawing]} block`,blockId:e.id,...Ig(e)});return}if(n.has(i)||n.has(j(i)))return;let a=Xc(i,n,{map:j});r.push({severity:`warning`,code:`unknown-template`,message:`Unknown template "${i}" \u2014 the block will render as a plain fallback card`+(a?`. Did you mean "${a}"?`:``),blockId:e.id,...Ig(e)})}function xg(e,t,n,r){let i=e.sourceHeading?.templateAnnotation?.template;if(!i||t&&yg(t)||es(i))return;let a=j(i);if(n.has(i)||n.has(a))return;let o=e.sourceHeading?.templateAnnotation?.params??{};for(let t of hl(a,o))t.kind===`missing-input`&&Sg(a,e,t.key)||r.push({severity:`warning`,code:t.kind,message:`Block "${e.id}": ${t.message}`,blockId:e.id,...Ig(e)})}function Sg(e,t,n){if(t.templateData&&n in t.templateData||t[n]!=null)return!0;let r=$a(e,t.title??``,t.contents);return r!=null&&n in r}var Cg=[`x`,`y`,`width`,`height`,`w`,`h`,`strokeWidth`,`borderRadius`];function wg(e,t,n){let r=e.sourceHeading?.attributes?.params;if(r){let{warnings:t}=ce(r);for(let r of t)n.push({severity:`warning`,code:`invalid-attribute`,message:`Block "${e.id}": ${r}`,blockId:e.id,...Ig(e)})}if(t&&yg(t)&&es(e.template)){let t=e.templateOverrides??{};for(let r of Cg){let i=t[r];if(i==null)continue;let a=i.replace(/,\s*$/,``).trim();a!==``&&!Number.isFinite(Number(a))&&n.push({severity:`warning`,code:`invalid-attribute`,message:`Drawing shape "${e.id}": "${r}" is not a number (${JSON.stringify(i)})`,blockId:e.id,...Ig(e)})}}}function Tg(e,t){let n=e.sourceHeading?.templateAnnotation?.params,r=e.sourceHeading?.attributes?.params;if(!(!n||!r))for(let i of Object.keys(oe)){let a=n[i],o=r[i];a==null||o==null||a===o||t.push({severity:`info`,code:`conflicting-annotation-key`,message:`"${i}" is set in both {[\u2026]} (${a}) and {\u2026} (${o}) \u2014 the {\u2026} value wins.`,blockId:e.id,...Ig(e)})}}function Eg(e,t){let n=e.children??[],r=new Set(n.map(e=>e.id));for(let e of n){let n=$o(e.sourceHeading?.templateAnnotation?.template);if(n!==`line`&&n!==`arrow`)continue;let i=e.templateOverrides??{};for(let n of[`from`,`to`]){let a=i[n];if(a==null)continue;let o=a.replace(/,\s*$/,``).trim();o&&!r.has(o)&&t.push({severity:`warning`,code:`unresolved-connection`,message:`Drawing connector "${e.id}" references unknown ${n} "${o}"`,blockId:e.id,...Ig(e)})}}}function Dg(e,t){if(e.sourceHeading?.templateAnnotation?.template||e.sourceAnnotation?.template)for(let n of e.contents??[]){if(n.type!==`code`)continue;let r=n.lang?.toLowerCase();if(r!==`json`&&r!==`yaml`&&r!==`yml`||ju(n))continue;let i=Mu(n);!i.data||Object.keys(i.data).length===0||t.push({severity:`info`,code:`possible-data-fence`,message:`This ${r} block renders as code \u2014 add "data" to the fence (\`\`\`${r} data) if it's meant as template input.`,blockId:e.id,...n.position?{line:n.position.start.line}:Ig(e)})}}var Og=/\{\[/;function kg(e,n){let r=(e,i,a)=>{if(e.type===`heading`){let t=e,r=o(t);Og.test(r)&&n.push({severity:`warning`,code:`unparsed-annotation`,message:`Heading "${Lg(r)}" contains "{[\u2026]}" text that was not recognized \u2014 check the quoting, or whether the token is a known inline icon`,...t.position?{line:t.position.start.line}:{}});return}if(e.type===`paragraph`&&a){let t=Vu(e);if(t&&t.template!=null)return}if(e.type===`text`&&Og.test(e.value)){n.push({severity:`warning`,code:`unparsed-annotation`,message:`Body text contains "{[…]}" — template annotations are recognized on headings and as standalone paragraphs (or the token is not a known inline icon)`,...e.position?{line:e.position.start.line}:i==null?{}:{line:i}});return}if(e.type!==`code`)for(let n of t(e))r(n,i,!1)};for(let t of e.children)r(t,t.position?.start.line,!0)}function Ag(e){return typeof e==`function`?e:t=>e.has(t)||e.has(t.replace(/^\.\//,``))}var jg=/^[a-z][a-z0-9+.-]*:/i;function Mg(e){return e.length>0&&!jg.test(e)&&!e.startsWith(`//`)&&!e.startsWith(`#`)}var Ng=[`src`,`imageSrc`,`videoSrc`,`poster`,`backgroundImage`];function Pg(e,n,r,i){let a=(e,t,n)=>{!Mg(e)||r(e)||i.push({severity:`warning`,code:`missing-asset`,message:`Referenced asset "${e}" was not found in the bundle`,...n?{blockId:n}:{},...t==null?{}:{line:t}})},o=new Set,s=e=>{e.type===`image`&&(o.add(e.url),a(e.url,e.position?.start.line)),(e.type===`htmlBlock`||e.type===`htmlInline`)&&Fg(e.htmlChildren,t=>{o.add(t),a(t,e.position?.start.line)});for(let n of t(e))s(n)};for(let t of e.children)s(t);for(let e of n){let t=new Set,n=[{value:e.templateOverrides,derived:!1},{value:e.templateData,derived:!0}];for(let{value:r,derived:i}of n){if(!r)continue;for(let n of Ng){let s=r[n];typeof s==`string`&&(i||t.add(s),(!i||!o.has(s)&&!t.has(s))&&a(s,e.sourceHeading?.position?.start.line,e.id))}let n=r.images,s=typeof n==`string`?n.split(`,`).map(e=>e.trim()):Array.isArray(n)?n.filter(e=>typeof e==`string`):[];for(let n of s)i||t.add(n),(!i||!o.has(n)&&!t.has(n))&&a(n,e.sourceHeading?.position?.start.line,e.id)}}}function Fg(e,t){for(let n of e)n.type===`htmlElement`&&(n.tagName===`img`&&n.attributes.src&&t(n.attributes.src),Fg(n.children,t))}function Ig(e){let t=e.sourceHeading?.position?.start.line;return t==null?{}:{line:t}}function Lg(e,t=40){return e.length<=t?e:`${e.slice(0,t)}\u2026`}function Rg(e){return e.split(`
|
|
580
|
-
`).map(e=>e.trim()).filter(e=>e.length>0)}function
|
|
581
|
-
`)}};function Yg(e,t,n){let{rect:r,labelLines:i,isContainer:a}=t,o=r.c1-r.c0-1;e.set(r.r0,r.c0,n.tl,`border`),e.set(r.r0,r.c1,n.tr,`border`);let s=a&&i.length>0?Ke(` ${i[0]} `):null;if(s&&s.length<=o-2){let t=Math.floor((o-s.length)/2);for(let i=0;i<o;i++){let a=i>=t&&i<t+s.length,o=a?s[i-t]:n.h;e.set(r.r0,r.c0+1+i,o,a?`label`:`border`)}}else for(let t=r.c0+1;t<=r.c1-1;t++)e.set(r.r0,t,n.h,`border`);e.set(r.r1,r.c0,n.bl,`border`),e.set(r.r1,r.c1,n.br,`border`);for(let t=r.c0+1;t<=r.c1-1;t++)e.set(r.r1,t,n.h,`border`);for(let t=r.r0+1;t<=r.r1-1;t++)e.set(t,r.c0,n.v,`border`),e.set(t,r.c1,n.v,`border`);let c=a?i.slice(1):i;if(c.length>0){let t=r.r1-r.r0-1,n=a?r.r0+1:r.r0+1+Math.max(0,Math.floor((t-c.length)/2));c.forEach((t,i)=>{let a=Ke(t),s=Math.max(0,Math.floor((o-a.length)/2));for(let t=0;t<a.length&&s+t<o;t++)e.set(n+i,r.c0+1+s+t,a[t],`label`)})}}function Xg(e,t,n,r){let i=[...t].sort((e,t)=>e.source.localeCompare(t.source)||e.target.localeCompare(t.target)||(e.label??``).localeCompare(t.label??``)),a=new Set,o=[];for(let e=0;e<i.length;e++){if(a.has(e))continue;let t=i[e];if(!n.has(t.source)||!n.has(t.target))continue;let r=!1;if(t.directed){let n=i.findIndex((n,r)=>r>e&&!a.has(r)&&n.directed&&n.source===t.target&&n.target===t.source&&(n.label??``)===(t.label??``));n>=0&&(a.add(n),r=!0)}let s=Zg(n.get(t.source).rect,n.get(t.target).rect);o.push({edge:t,sourceId:t.source,targetId:t.target,exitSide:s.exit,enterSide:s.enter,biDir:r})}let s=Qg(o,n),c=[];o.forEach((t,i)=>$g(e,t,i,n,s,r,(e,t)=>c.push({candidates:e,label:t})));for(let t of c){let n=Ke(t.label),r=!1;for(let i of[`right`,`left`]){if(r)break;for(let{row:a,col:o}of t.candidates){if(e.kindAt(a,o)!==`line-v`)continue;let t=i===`right`?o+2:o-1-n.length;if(t<0)continue;let s=i===`right`?o+1:o-1,c=e.kindAt(a,s)===`empty`;for(let r=0;c&&r<n.length;r++)e.kindAt(a,t+r)!==`empty`&&(c=!1);if(c&&i===`left`&&t>0&&(c=e.kindAt(a,t-1)===`empty`),c){for(let r=0;r<n.length;r++)e.set(a,t+r,n[r],`label`);r=!0;break}}}}}function Zg(e,t){if(t.r0>e.r1)return{exit:`bottom`,enter:`top`};if(t.r1<e.r0)return{exit:`top`,enter:`bottom`};if(t.c0>e.c1)return{exit:`right`,enter:`left`};if(t.c1<e.c0)return{exit:`left`,enter:`right`};let n=[{side:`top`,gap:Math.abs(e.r0-t.r0)},{side:`bottom`,gap:Math.abs(t.r1-e.r1)},{side:`left`,gap:Math.abs(e.c0-t.c0)},{side:`right`,gap:Math.abs(t.c1-e.c1)}];return n.sort((e,t)=>e.gap-t.gap),{exit:n[0].side,enter:n[0].side}}function Qg(e,t){let n=new Map;e.forEach((e,t)=>{let r=`${e.sourceId}|${e.exitSide}`,i=`${e.targetId}|${e.enterSide}`;n.set(r,[...n.get(r)??[],{key:`${t}:exit`,otherId:e.targetId}]),n.set(i,[...n.get(i)??[],{key:`${t}:enter`,otherId:e.sourceId}])});let r=new Map;for(let[e,i]of[...n.entries()].sort((e,t)=>e[0].localeCompare(t[0]))){let[n,a]=e.split(`|`),o=t.get(n);i.sort((e,n)=>{let r=t.get(e.otherId).rect,i=t.get(n.otherId).rect;return r.r0-i.r0||r.c0-i.c0||e.otherId.localeCompare(n.otherId)});let s=a===`top`||a===`bottom`,c=s?o.rect.c0+1:o.rect.r0+1,l=s?o.rect.c1-1:o.rect.r1-1,u=Math.max(1,l-c+1),d=i.length;if(d===1)r.set(i[0].key,{pos:c+Math.floor((u-1)/2),index:0,count:1});else{let e=2*d-1,t=c+Math.max(0,Math.floor((u-e)/2));i.forEach((e,n)=>{r.set(e.key,{pos:Math.min(l,t+2*n),index:n,count:d})})}}return r}function $g(e,t,n,r,i,a,o){let s=r.get(t.sourceId).rect,c=r.get(t.targetId).rect,l=i.get(`${n}:exit`),u=i.get(`${n}:enter`),d=l.pos,f=u.pos,p=u.count>l.count?u:l,m=p.index-Math.floor((p.count-1)/2),h={canvas:e,directed:t.edge.directed,biDir:t.biDir,label:zg(t.edge.label),vocab:a,junction:(t,n,r)=>{let i=r===`top`?a.stemUp:r===`bottom`?a.stemDown:r===`left`?a.stemLeft:a.stemRight;e.set(t,n,i,`junction`)},stagger:m,deferSideLabel:o};t.exitSide===`bottom`&&t.enterSide===`top`?n_(h,s,c,d,f,1):t.exitSide===`top`&&t.enterSide===`bottom`?n_(h,s,c,d,f,-1):t.exitSide===`right`&&t.enterSide===`left`?r_(h,s,c,d,f,1):t.exitSide===`left`&&t.enterSide===`right`?r_(h,s,c,d,f,-1):i_(h,s,c,t.exitSide)}function e_(e,t){let n=Math.min(e,t),r=Math.max(e,t),i=[];for(let e=n;e<=r;e++)i.push(e);let a=Math.floor((n+r)/2);return i.sort((e,t)=>Math.abs(e-a)-Math.abs(t-a)||e-t)}function t_(e,t,n){return Math.max(t,Math.min(n,e))}function n_(e,t,n,r,i,a){let{canvas:o,directed:s,biDir:c,label:l,vocab:u,junction:d,stagger:f}=e,p=a===1?t.r1:t.r0,m=a===1?n.r0:n.r1,h=p+a,g=m-a,_=(g-h)*a+1,v=(e,t,n)=>{let r=Math.min(t,n),i=Math.max(t,n);for(let t=r;t<=i;t++)o.drawEdgeCell(t,e,u.v,`line-v`,u)};if(r>=n.c0+1&&r<=n.c1-1&&r>=t.c0+1&&r<=t.c1-1||_<2){let i=t_(r,t.c0+1,t.c1-1),f=t_(r,n.c0+1,n.c1-1);d(p,i,a===1?`bottom`:`top`),d(m,f,a===1?`top`:`bottom`),i===f&&_>=1&&(v(i,h,g),s&&o.drawEdgeCell(g,i,a===1?u.arrowDown:u.arrowUp,`arrow`,u),c&&_>=2&&o.drawEdgeCell(h,i,a===1?u.arrowUp:u.arrowDown,`arrow`,u),l&&e.deferSideLabel(e_(h,g).map(e=>({row:e,col:i})),l));return}let y=t_(Math.floor((p+m)/2)+f,Math.min(h,g),Math.max(h,g));d(p,r,a===1?`bottom`:`top`),d(m,i,a===1?`top`:`bottom`),Math.abs(y-p)>=2&&v(r,h,y-a),Math.abs(m-y)>=2&&v(i,y+a,g);let b=!1;if(r===i)o.drawEdgeCell(y,r,u.v,`line-v`,u);else{let e=i>r,t=a===1?e?u.turnUpRight:u.turnUpLeft:e?u.turnDownRight:u.turnDownLeft,n=a===1?e?u.turnDownLeft:u.turnDownRight:e?u.turnUpLeft:u.turnUpRight;o.drawEdgeCell(y,r,t,`turn`,u),o.drawEdgeCell(y,i,n,`turn`,u);let s=Math.min(r,i),c=Math.max(r,i),d=[];for(let e=s+1;e<=c-1;e++)d.push(u.h);let f=l?Ke(` ${l} `):null;if(f&&Bg(f)&&d.length>=f.length+2){let e=Math.floor((d.length-f.length)/2);d=d.map((t,n)=>n>=e&&n<e+f.length?f[n-e]:t),b=!0}d.forEach((e,t)=>{o.drawEdgeCell(y,s+1+t,e,e===u.h?`line-h`:`label`,u)})}if(s&&o.drawEdgeCell(g,i,a===1?u.arrowDown:u.arrowUp,`arrow`,u),c&&o.drawEdgeCell(h,r,a===1?u.arrowUp:u.arrowDown,`arrow`,u),l&&!b){let t=[];if(r===i)for(let e of e_(h,g))t.push({row:e,col:r});else{let e=(y-a-h)*a+1,n=(g-(y+a))*a+1;if(e>=1)for(let e of e_(h,y-a))t.push({row:e,col:r});if(n>=1)for(let e of e_(y+a,g))t.push({row:e,col:i})}t.length>0&&e.deferSideLabel(t,l)}}function r_(e,t,n,r,i,a){let{canvas:o,directed:s,biDir:c,label:l,vocab:u,junction:d}=e,f=a===1?t.c1:t.c0,p=a===1?n.c0:n.c1,m=f+a,h=p-a,g=(h-m)*a+1,_=(e,t,n,r,i=0,a=0)=>{let s=Math.min(t,n),c=Math.max(t,n),d=[];for(let e=s;e<=c;e++)d.push(u.h);let f=r&&l?Ke(` ${l} `):null;if(f&&Bg(f)){let e=i,t=d.length-1-a-e+1;if(t>=f.length+2){let n=e+Math.floor((t-f.length)/2);d=d.map((e,t)=>t>=n&&t<n+f.length?f[t-n]:e)}}d.forEach((t,n)=>{o.drawEdgeCell(e,s+n,t,t===u.h?`line-h`:`label`,u)})};if(r>=n.r0+1&&r<=n.r1-1&&r>=t.r0+1&&r<=t.r1-1||g<2){let e=t_(r,t.r0+1,t.r1-1),i=t_(r,n.r0+1,n.r1-1);d(e,f,a===1?`right`:`left`),d(i,p,a===1?`left`:`right`),e===i&&g>=1&&(_(e,m,h,!0,(a===1?c:s)?1:0,(a===1?s:c)?1:0),s&&o.drawEdgeCell(e,h,a===1?u.arrowRight:u.arrowLeft,`arrow`,u),c&&g>=2&&o.drawEdgeCell(e,m,a===1?u.arrowLeft:u.arrowRight,`arrow`,u));return}let v=t_(Math.floor((f+p)/2)+e.stagger,Math.min(m,h),Math.max(m,h));if(d(r,f,a===1?`right`:`left`),d(i,p,a===1?`left`:`right`),Math.abs(v-f)>=2&&_(r,m,v-a,!0,a===1&&c?1:0,a===-1&&c?1:0),Math.abs(p-v)>=2&&_(i,v+a,h,!1),r===i)o.drawEdgeCell(r,v,u.h,`line-h`,u);else{let e=i>r,t=a===1?e?u.turnDownLeft:u.turnUpLeft:e?u.turnDownRight:u.turnUpRight,n=a===1?e?u.turnUpRight:u.turnDownRight:e?u.turnUpLeft:u.turnDownLeft;o.drawEdgeCell(r,v,t,`turn`,u),o.drawEdgeCell(i,v,n,`turn`,u);let s=Math.min(r,i),c=Math.max(r,i);for(let e=s+1;e<=c-1;e++)o.drawEdgeCell(e,v,u.v,`line-v`,u)}s&&o.drawEdgeCell(i,h,a===1?u.arrowRight:u.arrowLeft,`arrow`,u),c&&o.drawEdgeCell(r,m,a===1?u.arrowLeft:u.arrowRight,`arrow`,u)}function i_(e,t,n,r){let{canvas:i,directed:a,vocab:o,junction:s}=e;if(r===`top`||r===`bottom`){let e=Math.max(t.c0+1,n.c0+1),c=Math.min(t.c1-1,n.c1-1);if(e>c)return;let l=Math.floor((e+c)/2),u=r===`top`?t.r0:t.r1,d=r===`top`?n.r0:n.r1;if(u===d)return;s(u,l,r),s(d,l,r);let f=Math.min(u,d),p=Math.max(u,d);for(let e=f+1;e<=p-1;e++)i.drawEdgeCell(e,l,o.v,`line-v`,o);if(a&&p-f>=2){let e=d>u?d-1:d+1;i.drawEdgeCell(e,l,d>u?o.arrowDown:o.arrowUp,`arrow`,o)}}else{let e=Math.max(t.r0+1,n.r0+1),c=Math.min(t.r1-1,n.r1-1);if(e>c)return;let l=Math.floor((e+c)/2),u=r===`left`?t.c0:t.c1,d=r===`left`?n.c0:n.c1;if(u===d)return;s(l,u,r),s(l,d,r);let f=Math.min(u,d),p=Math.max(u,d);for(let e=f+1;e<=p-1;e++)i.drawEdgeCell(l,e,o.h,`line-h`,o);if(a&&p-f>=2){let e=d>u?d-1:d+1;i.drawEdgeCell(l,e,d>u?o.arrowRight:o.arrowLeft,`arrow`,o)}}}var a_=2,o_=8,s_=12,c_=4,l_=4;function u_(e){return!ln(e).isDiagram&&f_(Pt(Ft(e),!0)).length>=a_}function d_(e){let t=Ft(e),n=f_(Pt(t,!0));if(n.length<a_)return null;let r=p_(t,n),i={nodes:r,edges:__(t,n,r),style:S_(t),warnings:[`repaired`]};return{diagram:i,art:Hg(i)}}function f_(e){let t=new Set,n=[];for(let r of e){let e=`${r.r0},${r.c0},${r.r1},${r.c1}`;t.has(e)||(t.add(e),n.push(r))}return n.sort((e,t)=>e.r0-t.r0||e.c0-t.c0)}function p_(e,t){let n=e[0]?.length??0,r=t.map(()=>[]),i=new Map(t.map((e,t)=>[e,t])),a=[];for(let e of t){let t=a.find(t=>t.some(t=>t.r0<=e.r1&&e.r0<=t.r1));t||(t=[],a.push(t)),t.push(e)}for(let t of a){t.sort((e,t)=>e.c0-t.c0);let a=Math.min(...t.map(e=>e.r0+1)),o=Math.max(...t.map(e=>e.r1-1));for(let s=a;s<=o;s++){let a=t.filter(e=>s>e.r0&&s<e.r1);if(a.length===0)continue;let o=e[s].join(``).split(/[│┃║]/).map(m_).filter(e=>e.length>0);if(o.length===a.length)a.forEach((e,t)=>{let n=i.get(e);n!==void 0&&o[t]&&r[n].push(o[t])});else for(let t of a){let a=i.get(t);if(a===void 0)continue;let o=m_(e[s].slice(t.c0+1,Math.min(t.c1,n)).join(``));o&&r[a].push(o)}}}let o=new Map,s=[...a].sort((e,t)=>Math.min(...e.map(e=>e.r0))-Math.min(...t.map(e=>e.r0))),c=0;for(let e of s){o.set(e,c);let t=Math.max(...e.map(e=>e.r1-e.r0+1));c+=t+c_}let l=new Map;for(let e of a)for(let t of e)l.set(t,e);let u=t.map((e,t)=>Math.max(e.c1-e.c0+1,...r[t].map(e=>e.length+4),3)),d=new Map(t.map((e,t)=>[e,t])),f=new Map;for(let e of a){let t=[...e].sort((e,t)=>e.c0-t.c0),n=Math.min(...e.map(e=>e.c0));for(let e of t)f.set(e,n),n+=(u[d.get(e)??0]??3)+l_}let p=t.map((e,n)=>h_(t,n)),m=new Map,h=t.map((e,t)=>{let n=g_(r[t][0]??``),i=m.get(n)??0;m.set(n,i+1),i>0&&(n=`${n}-${i+1}`);let a=l.get(e),s=p[t]>=0,c=a&&!s?o.get(a)??e.r0:e.r0,u=s?e.c0:f.get(e)??e.c0;return{id:n,label:r[t].join(`
|
|
582
|
-
`),col:u,row:c,wCols:e.c1-e.c0+1,hRows:e.r1-e.r0+1}});return h.forEach((e,t)=>{p[t]>=0&&(e.containerId=h[p[t]].id)}),h}function
|
|
583
|
-
`)}function
|
|
584
|
-
`)}var
|
|
577
|
+
${lm}`}var dm=[1,1.5,2];function fm(e){let t=typeof e==`number`?e:typeof e==`string`?Number(e.trim().replace(/%$/,``)):NaN;if(!Number.isFinite(t))return;let n=t>3?t/100:t;return dm.find(e=>Math.abs(e-n)<.001)}var pm=new Set([`content`,`list`,`quote`,`definitionCard`,`factCard`,`dateEvent`]),mm=160,hm=360;function gm(e){return!e.template||!pm.has(e.template)?1:e.textLength<mm?2:e.textLength<hm?1.5:1}function _m(e,t){let n=e.map(e=>e.explicit===void 0?t===`auto`?gm(e):1:e.explicit),r=new Map;if(e.forEach((e,t)=>{let i=n[t];if(i===1)return;let a=e.explicit===void 0?1:2;r.set(i,(r.get(i)??0)+a)}),r.size<=1)return n;let i=2,a=-1;for(let[e,t]of r)(t>a||t===a&&e>i)&&(i=e,a=t);return e.map((e,t)=>e.explicit===void 0?n[t]===1?1:i:e.explicit)}var vm=32,ym=64,bm=/^[a-z0-9][a-z0-9-]*$/;function xm(e){if(typeof e==`number`)return Number.isFinite(e)?e:void 0;if(typeof e!=`string`)return;let t=e.trim().replace(/%$/,``);if(t.length===0)return;let n=Number(t);return Number.isFinite(n)?n:void 0}function Sm(e){return`${Math.round(e*1e3)/1e3}%`}function Cm(e,t,n){if(!e||typeof e!=`object`){n.push({path:t,message:`cell must be an object`});return}let r=e,i=xm(r.x),a=xm(r.y),o=xm(r.width),s=xm(r.height);if(i===void 0||i<0||i>100){n.push({path:`${t}.x`,message:`x must be a percent between 0 and 100`});return}if(a===void 0||a<0||a>100){n.push({path:`${t}.y`,message:`y must be a percent between 0 and 100`});return}if(o===void 0||o<=0||o>100){n.push({path:`${t}.width`,message:`width must be a percent greater than 0`});return}if(s===void 0||s<=0||s>100){n.push({path:`${t}.height`,message:`height must be a percent greater than 0`});return}let c={x:Sm(i),y:Sm(a),width:Sm(o),height:Sm(s)};if(r.block!==void 0){let e=typeof r.block==`string`?Number(r.block):r.block;if(typeof e!=`number`||!Number.isInteger(e)||e<1||e>ym){n.push({path:`${t}.block`,message:`block must be an integer between 1 and ${ym}`});return}c.block=e}if(r.zoom!==void 0){let e=fm(r.zoom);if(e===void 0){n.push({path:`${t}.zoom`,message:`zoom must be 1, 1.5, or 2 (or 100/150/200 percent)`});return}c.zoom=e}return c}function wm(e,t,n){if(!Array.isArray(e)){n.push({path:t,message:`must be an array of cells`});return}if(e.length<1||e.length>vm){n.push({path:t,message:`must contain between 1 and ${vm} cells`});return}let r=[];for(let i=0;i<e.length;i++){let a=Cm(e[i],`${t}[${i}]`,n);if(!a)return;r.push(a)}return r}function Tm(e,t){if(!e||typeof e!=`object`){t.push({path:`titleSlot`,message:`titleSlot must be an object`});return}let n=e,r=n.placement===`bottom`?`bottom`:n.placement===`top`?`top`:void 0;if(r===void 0&&n.placement!==void 0){t.push({path:`titleSlot.placement`,message:`placement must be 'top' or 'bottom'`});return}let i=xm(n.height);if(i===void 0||i<=0||i>40){t.push({path:`titleSlot.height`,message:`height must be a percent between 0 and 40`});return}return{placement:r??`top`,height:Sm(i)}}function Em(e){let t=[];if(!e||typeof e!=`object`)return{valid:!1,errors:[{path:``,message:`definition must be an object`}]};let n=e,r=typeof n.name==`string`?n.name.trim().toLowerCase():``;bm.test(r)||t.push({path:`name`,message:`name must be a slug (lowercase letters, digits, hyphens)`});let i=typeof n.label==`string`?n.label.trim():``;i.length===0&&t.push({path:`label`,message:`label must be a non-empty string`});let a=n.cells,o,s,c;!a||typeof a!=`object`?t.push({path:`cells`,message:`cells must be an object with a landscape array`}):(o=wm(a.landscape,`cells.landscape`,t),a.portrait!==void 0&&(s=wm(a.portrait,`cells.portrait`,t)),a.square!==void 0&&(c=wm(a.square,`cells.square`,t)),o&&(s&&s.length!==o.length&&t.push({path:`cells.portrait`,message:`portrait must define the same number of cells as landscape`}),c&&c.length!==o.length&&t.push({path:`cells.square`,message:`square must define the same number of cells as landscape`})));let l;if(n.titleSlot!==void 0&&(l=Tm(n.titleSlot,t)),t.length>0||!o)return{valid:!1,errors:t};let u={name:r,label:i,cells:{landscape:o,...s?{portrait:s}:{},...c?{square:c}:{}}};return typeof n.description==`string`&&n.description.trim()&&(u.description=n.description.trim()),l&&(u.titleSlot=l),n.auto===!1&&(u.auto=!1),{valid:!0,errors:t,layout:u}}function Dm(e){return e.cells.landscape.length}function Om(e){return e.map(e=>({x:e.y,y:e.x,width:e.height,height:e.width,...e.block===void 0?{}:{block:e.block},...e.zoom===void 0?{}:{zoom:e.zoom}}))}function km(e,t,n){return(t===`portrait`?e.cells.portrait??Om(e.cells.landscape):t===`square`?e.cells.square??e.cells.landscape:e.cells.landscape).map(e=>{let t=xm(e.x)??0,r=xm(e.y)??0,i=xm(e.width)??0,a=xm(e.height)??0,o={rect:{x:n.x+t/100*n.width,y:n.y+r/100*n.height,width:Math.max(1,i/100*n.width),height:Math.max(1,a/100*n.height)}};e.block!==void 0&&(o.block=e.block);let s=fm(e.zoom);return s!==void 0&&(o.zoom=s),o})}var Am=`squisq-dashboard-layouts`,jm={label:`lb`,description:`ds`,cells:`ce`,landscape:`ls`,portrait:`pt`,square:`sq`,width:`wd`,height:`hg`,block:`bk`,zoom:`zo`,titleSlot:`ts`,placement:`pl`,auto:`au`},Mm=Object.fromEntries(Object.entries(jm).map(([e,t])=>[t,e]));function Nm(e,t){if(Array.isArray(e))return e.map(e=>Nm(e,t));if(e&&typeof e==`object`){let n={};for(let[r,i]of Object.entries(e))n[t[r]??r]=Nm(i,t);return n}return e}function Pm(e){if(!e)return;let t=zm(e[Am]);if(!t)return;let n=[];for(let e of t){let t=Em(e);t.layout&&n.push(t.layout)}return n.length>0?n:void 0}function Fm(e,t){if(!e||e.length===0)return;let n={};for(let t of e){let{name:e,...r}=t;n[e]=Nm(r,jm)}return JSON.stringify(n,null,t?.pretty?2:void 0)}function Im(e){return Object.entries(e).map(([e,t])=>({name:e,...Nm(t&&typeof t==`object`?t:{},Mm)}))}function Lm(e){return Array.isArray(e)?e:e&&typeof e==`object`?Im(e):null}function Rm(e){try{return JSON.parse(e)}catch{return}}function zm(e){if(e==null)return null;if(Array.isArray(e))return e;if(typeof e==`object`)return Im(e);if(typeof e!=`string`)return null;let t=Rm(e.trim());return t===void 0?null:Lm(t)}var Bm=2;function Q(e){return`${Math.round(e*1e3)/1e3}%`}function Vm(e,t,n=Bm){let r=(100-(e-1)*n)/e,i=(100-(t-1)*n)/t,a=[];for(let o=0;o<t;o++)for(let t=0;t<e;t++)a.push({x:Q(t*(r+n)),y:Q(o*(i+n)),width:Q(r),height:Q(i)});return a}function Hm(e,t,n=Bm){let r=e+n,i=100-r,a=(100-(t-1)*n)/t,o=[{x:`0%`,y:`0%`,width:Q(e),height:`100%`}];for(let e=0;e<t;e++)o.push({x:Q(r),y:Q(e*(a+n)),width:Q(i),height:Q(a)});return o}function Um(e,t,n=Bm){let r=e+n,i=100-r,a=(100-(t-1)*n)/t,o=[{x:`0%`,y:`0%`,width:`100%`,height:Q(e)}];for(let e=0;e<t;e++)o.push({x:Q(e*(a+n)),y:Q(r),width:Q(a),height:Q(i)});return o}function Wm(e,t=Bm){let n=e+t,r=(100-n-t)/2,i=(100-t)/2,a=[{x:`0%`,y:`0%`,width:Q(e),height:`100%`}];for(let e=0;e<2;e++)for(let o=0;o<2;o++)a.push({x:Q(n+o*(r+t)),y:Q(e*(i+t)),width:Q(r),height:Q(i)});return a}var Gm=Object.freeze([{name:`focus-1`,label:`Focus`,description:`One block fills the dashboard.`,cells:{landscape:[{x:`0%`,y:`0%`,width:`100%`,height:`100%`}]}},{name:`split-2`,label:`Split`,description:`Two blocks side by side.`,cells:{landscape:Vm(2,1)}},{name:`hero-left`,label:`Hero + 2`,description:`A large lead block with two companions.`,cells:{landscape:Hm(58,2),portrait:[{x:`0%`,y:`0%`,width:`100%`,height:Q(46)},{x:`0%`,y:Q(48),width:`100%`,height:Q(25)},{x:`0%`,y:Q(75),width:`100%`,height:Q(25)}]}},{name:`grid-2x2`,label:`Grid 2×2`,description:`Four blocks in a balanced grid.`,cells:{landscape:Vm(2,2)}},{name:`hero-top`,label:`Hero band`,description:`A wide lead band with three blocks below.`,cells:{landscape:Um(46,3),portrait:[{x:`0%`,y:`0%`,width:`100%`,height:Q(40)},{x:`0%`,y:Q(42),width:`100%`,height:Q(18)},{x:`0%`,y:Q(62),width:`100%`,height:Q(18)},{x:`0%`,y:Q(82),width:`100%`,height:Q(18)}]},auto:!1},{name:`mosaic-5`,label:`Mosaic`,description:`A hero block beside a 2×2 grid.`,cells:{landscape:Wm(58),portrait:[{x:`0%`,y:`0%`,width:`100%`,height:Q(40)},{x:`0%`,y:Q(42),width:Q(49),height:Q(27)},{x:Q(51),y:Q(42),width:Q(49),height:Q(27)},{x:`0%`,y:Q(71),width:Q(49),height:Q(29)},{x:Q(51),y:Q(71),width:Q(49),height:Q(29)}]}},{name:`grid-3x2`,label:`Grid 3×2`,description:`Six blocks in three columns.`,cells:{landscape:Vm(3,2)}},{name:`grid-3x3`,label:`Grid 3×3`,description:`Nine blocks in a square grid.`,cells:{landscape:Vm(3,3),square:Vm(3,3)}},{name:`grid-4x3`,label:`Grid 4×3`,description:`Twelve blocks in four columns.`,cells:{landscape:Vm(4,3)}},{name:`grid-4x4`,label:`Grid 4×4`,description:`Sixteen blocks — the densest wall.`,cells:{landscape:Vm(4,4)}}]);function Km(e,t){return{id:e.name,label:e.label,...e.description?{description:e.description}:{},capacity:Dm(e),custom:t}}function qm(){return Gm.map(e=>Km(e,!1))}function Jm(e){let t=Pm(e?.frontmatter)??[],n=new Set(t.map(e=>e.name));return[...t.map(e=>Km(e,!0)),...Gm.filter(e=>!n.has(e.name)).map(e=>Km(e,!1))]}var Ym=`auto`;function Xm(e,t){let n=e.trim().toLowerCase();if(n)return t?.find(e=>e.name===n)??Gm.find(e=>e.name===n)}function Zm(e,t,n){let r=[...(n??[]).filter(e=>e.auto!==!1),...Gm.filter(e=>e.auto!==!1)].sort((e,t)=>Dm(e)-Dm(t)),i=Math.max(1,e),a=r.find(e=>Dm(e)>=i);if(a)return a;let o=r.reduce((e,t)=>Math.max(e,Dm(t)),0);return r.find(e=>Dm(e)===o)??Gm[0]}var Qm=[`basic`,`card`,`panel`,`accent`],$m=`basic`,eh=Object.freeze([{id:`basic`,label:`Basic`,description:`Blocks fill their cells edge to edge.`},{id:`card`,label:`Cards`,description:`Each block sits on a raised, rounded card.`},{id:`panel`,label:`Panels`,description:`Flat outlined panels with an accent rule.`},{id:`accent`,label:`Accent cards`,description:`Cards tinted with the theme's accent colors in rotation.`}]);function th(e){if(typeof e!=`string`)return;let t=e.trim().toLowerCase();if(t)return t===`none`||t==="default"||t===`flat`?`basic`:t===`cards`?`card`:t===`panels`||t===`outline`?`panel`:t===`accents`||t===`accent-cards`?`accent`:Qm.includes(t)?t:void 0}function nh(e,t,n){return Math.min(n,Math.max(t,e))}function rh(e){return x(e)>.45}function ih(e,t){let n=t.colors.background;return e===`basic`||e===`panel`?n:rh(n)?b(n,.05):re(n,.04)}function ah(e,t){let n=Object.values(e.colorSchemes??{});if(n.length===0)return e.colors.primary;let r=n[(t%n.length+n.length)%n.length];return r.accent||r.text||e.colors.primary}function oh(e,t,n){let r=Math.max(1,Math.min(n.width,n.height)),i=t.style?.borderRadius??14;return e===`panel`?{edge:nh(r*.014,3,12),radius:nh(i*.45,0,r*.05)}:{edge:nh(r*.03,6,26),radius:nh(i,6,r*.1)}}function sh(e,t){if(!(e<=0))return`${Math.round(e/Math.max(1,t.width)*1e5)/1e3}% / ${Math.round(e/Math.max(1,t.height)*1e5)/1e3}%`}function ch(e,t){let{theme:n,rect:r,index:i}=t;if(e===`basic`)return null;let{edge:a,radius:o}=oh(e,n,r),s={x:r.x+a,y:r.y+a,width:Math.max(1,r.width-a*2),height:Math.max(1,r.height-a*2)},c={x:a,y:a,width:s.width,height:s.height},l=Math.max(1,Math.min(r.width,r.height)),u=Math.max(1,Math.round(l*.004)),d=ah(n,i),f=[];e!==`panel`&&[{spread:.45,dy:.5,alpha:.05},{spread:.25,dy:.42,alpha:.05},{spread:.08,dy:.3,alpha:.06}].forEach((e,t)=>{let r=a*e.spread,i=a*e.dy;f.push({type:`shape`,id:`cell-shadow-${t}`,content:{shape:`rect`,fill:C(n.colors.text,e.alpha),borderRadius:o+r},position:{x:c.x-r,y:c.y-r+i,width:c.width+r*2,height:c.height+r*2}})}),f.push({type:`shape`,id:`cell-surface`,content:{shape:`rect`,fill:n.colors.background,borderRadius:o},position:{x:c.x,y:c.y,width:c.width,height:c.height}});let p=[];if(e===`accent`&&p.push({type:`shape`,id:`cell-accent-wash`,content:{shape:`rect`,fill:C(d,.1),borderRadius:o},position:{x:0,y:0,width:`100%`,height:`100%`}}),e===`accent`||e===`panel`){let e=Math.max(2,Math.round(l*.014));p.push({type:`shape`,id:`cell-accent-bar`,content:{shape:`rect`,fill:d},position:{x:0,y:0,width:`100%`,height:e}})}let m=e===`panel`?u:Math.max(1,u*.6);p.push({type:`shape`,id:`cell-border`,content:{shape:`rect`,fill:`none`,stroke:e===`panel`?C(d,.45):C(n.colors.text,.14),strokeWidth:m,borderRadius:o},position:{x:m/2,y:m/2,width:Math.max(1,c.width-m),height:Math.max(1,c.height-m)}});let h={cardRect:s,contentRect:s,layers:f,overlayLayers:p,radius:o},g=sh(o,s);return g&&(h.contentRadiusPct=g),h}function lh(e){return e!==`basic`}function uh(e,t){let n=e[0];if(!n||n.type!==`shape`)return[...e];let{content:r,position:i}=n,a=typeof r.fill==`string`?r.fill.trim().toLowerCase():``;return!(r.shape===`rect`&&(i.x===0||i.x===`0%`)&&(i.y===0||i.y===`0%`)&&i.width===`100%`&&i.height===`100%`)||r.gradient||r.pattern||a!==t.colors.background.trim().toLowerCase()?[...e]:e.slice(1)}var dh=Object.freeze({layout:{canonical:`squisq-dashboard-layout`,legacy:`dashboard-layout`},showTitle:{canonical:`squisq-dashboard-title`,legacy:`dashboard-title`},zoom:{canonical:`squisq-dashboard-zoom`,legacy:`dashboard-zoom`},style:{canonical:`squisq-dashboard-style`,legacy:`dashboard-style`}}),fh=Object.freeze({layout:Ym,showTitle:!0,zoom:`auto`,style:$m});function ph(e,t){if(e)return Object.prototype.hasOwnProperty.call(e,t.canonical)?e[t.canonical]:e[t.legacy]}function mh(e){if(typeof e==`boolean`)return e;if(typeof e!=`string`)return;let t=e.trim().toLowerCase();if([`true`,`yes`,`on`,`show`,`visible`].includes(t))return!0;if([`false`,`no`,`off`,`hide`,`hidden`].includes(t))return!1}function hh(e){if(typeof e!=`string`)return;let t=e.trim().toLowerCase();if(t)return t===`auto`||t==="default"?Ym:t}function gh(e){if(typeof e==`boolean`)return e?`auto`:`off`;if(typeof e!=`string`)return;let t=e.trim().toLowerCase();if([`auto`,`on`,`true`,`yes`].includes(t))return`auto`;if([`off`,`false`,`no`,`none`,`100`,`100%`,`1`].includes(t))return`off`}function _h(e,t={}){let n={layout:hh(ph(e,dh.layout))??fh.layout,showTitle:mh(ph(e,dh.showTitle))??fh.showTitle,zoom:gh(ph(e,dh.zoom))??fh.zoom,style:th(ph(e,dh.style))??fh.style};return{layout:hh(t.layout)??n.layout,showTitle:t.showTitle??n.showTitle,zoom:t.zoom??n.zoom,style:th(t.style)??n.style}}var vh={placement:`top`,height:`9%`},yh=.015,bh=.02;function xh(e){let t=Number(e.trim().replace(/%$/,``));return Number.isFinite(t)?t:0}function Sh(e,t){return`${Math.round(e/Math.max(1,t)*1e5)/1e3}%`}function Ch(e,t){return{left:Sh(e.x,t.width),top:Sh(e.y,t.height),width:Sh(e.width,t.width),height:Sh(e.height,t.height)}}function wh(e,t){let n=e.frontmatter?.title;return typeof n==`string`&&n.trim()?n.trim():t?.trim()??``}function Th(e,t){if(e.length===0||!t)return e;let n=e[0],r=typeof n.title==`string`?n.title.trim().toLowerCase():``;if(!r||r!==t.trim().toLowerCase())return e;let i=n.template,a=i===`title`||i===`sectionHeader`||i===`cover`,o=Array.isArray(n.contents)&&n.contents.length>0;return a||!o?e.slice(1):e}function Eh(e,t,n,r,i,a){let o=p(r,0,1,i),s=h(i),c=Math.min(44*s,t.height*.52),l=Math.max(4,Math.round(6*s)),u=a+l+Math.max(10,Math.round(l*2.5));return[{type:`shape`,id:`dashboard-title-accent`,content:{shape:`rect`,fill:r.colors.primary},position:{x:a,y:`26%`,width:l,height:`48%`}},{type:`text`,id:`dashboard-title-text`,content:{text:e,style:{fontSize:c,fontFamily:I(o,`title`),fontWeight:`bold`,color:r.colors.text,textAlign:`left`,verticalAlign:`middle`,maxLines:1}},position:{x:u,y:0,width:Math.max(1,t.width-u-a),height:`100%`}},{type:`shape`,id:`dashboard-title-rule`,content:{shape:`rect`,fill:C(r.colors.text,.14)},position:{x:0,y:n.placement===`bottom`?0:t.height-2,width:`100%`,height:2}}]}function Dh(e,t={}){let n=t.theme??A,r=t.viewport??f.landscape,i=_(r),a=t.customLayouts??Pm(e.frontmatter),o=t.customTemplates??e.customTemplates,s=[],c=_h(e.frontmatter,{layout:typeof t.layout==`string`?t.layout:void 0,showTitle:t.showTitle,zoom:t.zoom,...t.style===void 0?{}:{style:t.style}}),l=c.style,u,d=`auto`;if(t.layout&&typeof t.layout==`object`){let e=Em(t.layout);e.layout?(u=e.layout,d=`option`):s.push({type:`unknown-layout`,message:`Inline dashboard layout definition is invalid; falling back to auto.`,requestedLayout:t.layout.name})}else if(c.layout!==`auto`){let e=Xm(c.layout,a);e?(u=e,d=typeof t.layout==`string`&&t.layout.trim()?`option`:`frontmatter`):s.push({type:`unknown-layout`,message:`Unknown dashboard layout "${c.layout}"; falling back to auto.`,requestedLayout:c.layout})}let m=lp(e,{documentTitle:t.documentTitle,interleaveImages:!1}).blocks??[];m.length===0&&s.push({type:`empty-doc`,message:`The document has no renderable blocks; the dashboard has no cells.`});let h=c.showTitle?wh(e,t.documentTitle):``,g=h.length>0;g&&(m=Th(m,h)),u||(u=Zm(m.length,i,a),d=`auto`);let v=bh*Math.min(r.width,r.height),y={x:v,y:v,width:Math.max(1,r.width-v*2),height:Math.max(1,r.height-v*2)},b=null;if(g){let e=u.titleSlot??vh,t=Math.min(40,Math.max(2,xh(e.height)))/100*r.height,i=yh*r.height,a=e.placement===`bottom`?{x:0,y:r.height-t,width:r.width,height:t}:{x:0,y:0,width:r.width,height:t};y=e.placement===`bottom`?{x:v,y:v,width:Math.max(1,r.width-v*2),height:Math.max(1,r.height-t-i-v)}:{x:v,y:t+i,width:Math.max(1,r.width-v*2),height:Math.max(1,r.height-t-i-v)};let o={width:Math.max(1,Math.round(a.width)),height:Math.max(1,Math.round(a.height)),name:`Dashboard title`};b={text:h,rect:a,rectPct:Ch(a,r),viewport:o,layers:Eh(h,o,e,n,r,v)}}let x=km(u,i,y),S=[],C=new Set;x.forEach((e,t)=>{if(e.block===void 0)return;let n=e.block-1;if(n<0||n>=m.length){s.push({type:`invalid-cell-assignment`,message:`Cell ${t+1} of layout "${u.name}" requests block ${e.block}, but the document has ${m.length} block(s); the cell is left empty.`});return}C.add(n),S.push({cellIndex:t,rect:e.rect,candidateIndex:n,explicitZoom:e.zoom})});let w=new Set,T=0;x.forEach((e,t)=>{if(e.block===void 0){for(;T<m.length&&C.has(T);)T++;T>=m.length||(w.add(T),S.push({cellIndex:t,rect:e.rect,candidateIndex:T,explicitZoom:e.zoom}),T++)}});let E=[];for(let e=0;e<m.length;e++)!C.has(e)&&!w.has(e)&&E.push(e);E.length>0&&s.push({type:`overflow`,message:`${E.length} block(s) exceed the "${u.name}" layout's ${x.length} cell(s) and are not rendered.`,hiddenBlockIds:E.map(e=>String(m[e].id??e))});let D=S.sort((e,t)=>e.cellIndex-t.cellIndex),O=_m(D.map(({candidateIndex:e,explicitZoom:t})=>{let n=m[e],r=typeof n.title==`string`?n.title:``;return{template:j(n.template??``),textLength:r.length+Rd(n).length,...t===void 0?{}:{explicit:t}}}),c.zoom),k=o&&o.length>0?Kc(o):Gc,ee=D.map(({cellIndex:e,rect:i,candidateIndex:a},o)=>{let s=m[a],c=O[o],u=ch(l,{theme:n,rect:i,index:e}),d=u?u.contentRect:i,f={width:Math.max(1,Math.round(d.width)),height:Math.max(1,Math.round(d.height)),name:`Dashboard cell ${e+1}`},h=p(n,a,m.length,f);c!==1&&(h.fontScale*=c);let g=ql(s,{theme:n,viewport:f,persistentLayers:!1,blockIndex:a,totalBlocks:m.length,failureMode:t.failureMode},{registry:k,templateContext:h}),_=lh(l)?uh(g.layers,n):g.layers,v;if(u){let t={width:Math.max(1,Math.round(i.width)),height:Math.max(1,Math.round(i.height)),name:`Dashboard cell ${e+1} frame`};v={rect:i,rectPct:Ch(i,r),viewport:t,layers:u.layers,overlayLayers:u.overlayLayers,overlayViewport:{width:f.width,height:f.height,name:`Dashboard cell ${e+1} overlay`},...u.contentRadiusPct?{contentRadiusPct:u.contentRadiusPct}:{}}}return{index:e,block:s,blockIndex:a,layers:_,rect:d,rectPct:Ch(d,r),...v?{frame:v}:{},viewport:f,zoom:c,source:g.source,...g.diagnostic?{diagnostic:g.diagnostic}:{}}}),te=Ei(e,n),ne=ih(l,n),re={fill:ne,bottomLayers:[{type:`shape`,id:`dashboard-backdrop`,content:{shape:`rect`,fill:ne},position:{x:0,y:0,width:`100%`,height:`100%`}},...wi(te?.bottomLayers,n)],topLayers:wi(te?.topLayers,n)};return{layout:u,layoutSource:d,style:l,viewport:r,cells:ee,title:b,backdrop:re,diagnostics:s}}function Oh(e){let t=[...e.backdrop.bottomLayers];for(let n of e.cells)n.frame&&t.push(...Rl(n.frame.layers,n.frame.viewport,n.frame.rect,`cell-${n.index}-frame`)),t.push(...Rl(n.layers,n.viewport,n.rect,`cell-${n.index}`)),n.frame&&n.frame.overlayLayers.length>0&&t.push(...Rl(n.frame.overlayLayers,n.frame.overlayViewport,n.rect,`cell-${n.index}-overlay`));return e.title&&t.push(...Rl(e.title.layers,e.title.viewport,e.title.rect,`dashboard-title`)),t.push(...e.backdrop.topLayers),t}var kh=new Set([`answer`,`back`,`solution`,`explanation`,`correct answer`,`correct`,`distractor`,`option`]);function Ah(e){return typeof e==`string`?e.trim().toLowerCase().replace(/[\s_-]+/g,``):``}function jh(e){let t=Ah(e);if(t===`flashcard`||t===`card`||t===`basicflashcard`)return`basic`;if(t===`multiplechoiceflashcard`||t===`multiplechoice`||t===`quiz`)return`multiple-choice`;if(t===`group`||t===`flashcardgroup`||t===`deck`)return`group`}function Mh(e){let t=jh(e.metadata?.study)??jh(e.metadata?.[`study-mode`]);if(t)return t;for(let t of e.classes??[]){let e=jh(t);if(e)return e}return jh(e.template)}function Nh(e){return typeof e.title==`string`&&e.title.trim().length>0}function Ph(e){return(e.contents?.length??0)>0||(e.media?.length??0)>0||(e.layers?.length??0)>0}function Fh(e){return Nh(e)||Ph(e)}function Ih(e){return Nh(e)&&kh.has(e.title.trim().toLowerCase())}function Lh(e){let{children:t,...n}=e;return n}function Rh(e){let{children:t,contents:n,media:r,layers:i,...a}=e;return a}function zh(e){let{children:t,title:n,...r}=e;return r}function $(...e){return{blocks:e}}function Bh(e){return e===!0||typeof e==`string`&&[`true`,`yes`,`on`,`1`,`correct`].includes(e.trim().toLowerCase())}function Vh(e){return Bh(e.metadata?.correct)||Bh(e.metadata?.answer)||(e.classes??[]).some(e=>Ah(e)===`correct`)}function Hh(e){let t=Mh(e);if(t===`group`)return!1;if(t===`basic`||t===`multiple-choice`)return!0;if(Ih(e))return!1;let n=e.children??[];return n.length===0?Nh(e)&&Ph(e):n.length===1?Fh(e)&&Fh(n[0]):n.every(Fh)}function Uh(e){for(let t of e.children??[]){let e=Mh(t);if(e===`basic`||e===`multiple-choice`||Uh(t))return!0}return!1}function Wh(e){let t=e.children??[];return t.length===0?!1:Uh(e)?!0:Ph(e)?!1:t.length===1?Hh(t[0])&&!Ih(t[0]):t.filter(Hh).length>=2}function Gh(e){return Ph(e)?$(zh(e)):void 0}function Kh(e,t){let n=e.children??[],r,i,a,o;if(n.length===0?(r=Nh(e)?$(Rh(e)):$(),i=Ph(e)?$(zh(e)):$()):n.length===1?(r=Fh(e)?$(Lh(e)):$(),i=Fh(n[0])?$(n[0]):$()):(r=Fh(n[0])?$(n[0]):$(),i=$(...n.slice(1).filter(Fh)),a=Nh(e)?e.title.trim():void 0,o=Gh(e)),r.blocks.length===0&&t.push({severity:`error`,code:`empty-front`,message:`Flashcard "${e.id}" has no content for its front`,blockId:e.id}),i.blocks.length===0&&t.push({severity:`error`,code:`empty-back`,message:`Flashcard "${e.id}" has no content for its answer`,blockId:e.id}),!(r.blocks.length===0||i.blocks.length===0))return{id:e.id,sourceBlockId:e.id,kind:`basic`,...a?{label:a}:{},front:r,back:i,...o?{explanation:o}:{}}}function qh(e,t){let n=e.children??[],r=n[0],i=n.slice(1).filter(Fh);if((!r||!Fh(r))&&t.push({severity:`error`,code:`empty-front`,message:`Multiple-choice flashcard "${e.id}" has no question block`,blockId:e.id}),i.length===0&&t.push({severity:`error`,code:`empty-back`,message:`Multiple-choice flashcard "${e.id}" has no answer choices`,blockId:e.id}),!r||!Fh(r)||i.length===0)return;let a=i.filter(Vh);a.length>1&&t.push({severity:`warning`,code:`multiple-correct-answers`,message:`Multiple-choice flashcard "${e.id}" marks more than one answer correct; the first marker wins`,blockId:e.id});let o=a[0]??i[0];i.length<2&&t.push({severity:`warning`,code:`multiple-choice-needs-distractor`,message:`Multiple-choice flashcard "${e.id}" needs at least one distractor`,blockId:e.id});let s=i.map((t,n)=>({id:`${e.id}-choice-${n+1}`,sourceBlockId:t.id,content:$(t),correct:t===o})),c=Gh(e);return{id:e.id,sourceBlockId:e.id,kind:`multiple-choice`,...Nh(e)?{label:e.title.trim()}:{},front:$(r),back:$(o),choices:s,...c?{explanation:c}:{}}}function Jh(e){let t=e.frontmatter?.title;return typeof t==`string`&&t.trim()?t.trim():e.startBlock?.title?.trim()||void 0}function Yh(e,t={}){let n=t.source??`auto`,r=[],i=[],a=e=>{let t=Mh(e);if(t===`group`){for(let t of e.children??[])a(t);return}if(t===`basic`){let t=Kh(e,i);t&&r.push(t);return}if(t===`multiple-choice`){let t=qh(e,i);t&&r.push(t);return}if(n===`explicit`){for(let t of e.children??[])a(t);return}if(Wh(e)){for(let t of e.children??[])a(t);return}if(Hh(e)){let t=Kh(e,i);t&&r.push(t);return}for(let t of e.children??[])a(t)};for(let t of e.blocks)a(t);let o=Jh(e),s=typeof e.frontmatter?.title==`string`?e.frontmatter.title.trim():``,c=r[0]?.front.blocks[0]?.title?.trim(),l=o&&(s||o!==c)?o:void 0;return{...l?{title:l}:{},cards:r,diagnostics:i}}var Xh=.5,Zh=.8,Qh=1;function $h(e){let t=e.title?e.title.trim():``,n=Rd(e);return t&&n?`${t}
|
|
578
|
+
${n}`:t||n}function eg(e,t){let n=new Map,r=new Set(e.map(e=>e.id)),i=[],a=new Map(e.map(e=>[e.id,e]));for(let e of t.blocks)e.blockId&&a.has(e.blockId)&&r.has(e.blockId)?(n.set(e.blockId,{startSec:e.startSec,endSec:e.endSec}),r.delete(e.blockId)):i.push(e);if(i.length>0&&r.size>0){let a=[];for(let n of i){let i=t.sourceText.slice(n.charStart,n.charEnd);for(let t of e){if(!r.has(t.id))continue;let e=og(i,$h(t));e>=Xh&&a.push({score:e,entry:n,blockId:t.id})}}a.sort((e,t)=>t.score-e.score||e.entry.blockIndex-t.entry.blockIndex);let o=new Set;for(let e of a)o.has(e.entry)||!r.has(e.blockId)||(n.set(e.blockId,{startSec:e.entry.startSec,endSec:e.entry.endSec}),o.add(e.entry),r.delete(e.blockId));let s=i.filter(e=>!o.has(e));if(s.length>0&&s.length===r.size){let t=e.filter(e=>r.has(e.id));s.sort((e,t)=>e.blockIndex-t.blockIndex),t.forEach((e,t)=>{let r=s[t];n.set(e.id,{startSec:r.startSec,endSec:r.endSec})})}}return n}function tg(e,t){let n=Zd(e);if(n.blocks.length===0||og(n.sourceText,t.sourceText)<Zh)return null;let r=new Map,i=n.blocks.map(e=>ye(n.sourceText,e.charStart,t.duration));return n.blocks.forEach((e,n)=>{r.set(e.blockId,{startSec:i[n],endSec:n+1<i.length?i[n+1]:t.duration})}),r}function ng(e,t){return e.map(e=>{let n=t.ranges.get(e.id),r=Sd(e),i={...e};if(n){let a=t.clipStart+n.startSec+t.shift,o=Math.max(0,n.endSec-n.startSec);i.startTime=r.startTime??a,i.duration=r.duration??o;let s=i.startTime+i.duration;t.shift=s-(t.clipStart+n.endSec);let c=r.duration!=null&&Math.abs(r.duration-o)>Qh,l=r.startTime!=null&&Math.abs(r.startTime-a)>Qh;(c||l)&&t.diagnostics.push({severity:`info`,code:`narration-pin-conflict`,message:`Block timing is pinned (duration=/startTime=) but the recorded narration says ~${o.toFixed(1)}s starting at ~${a.toFixed(1)}s. The pin wins and later blocks follow it, while the recorded voice keeps its own schedule \u2014 playback drifts from the take past this block. Remove the pin to follow the narration.`,blockId:e.id}),t.cursor=Math.max(t.cursor,s)}else i.startTime=t.cursor,t.cursor+=i.duration;return e.children&&e.children.length>0&&(i.children=ng(e.children,t)),i})}async function rg(e,t){let n=(e.documentMedia??[]).filter(e=>e.anchor===`document`);for(let r of n){if(!r.src)continue;let n=await t.readFile(`${r.src}.timing.json`);if(!n)continue;let i=uf(n);if(!i)continue;let a=Dd(e.blocks),o=i.blocks.length>0?eg(a,i):tg(e,i);if(!o||o.size===0)continue;let s={clipStart:r.startAt,ranges:o,diagnostics:[],cursor:0,shift:0},c=ng(e.blocks,s),l=Math.max(r.startAt+i.duration,s.cursor);return{doc:{...e,blocks:c,duration:l,...s.diagnostics.length>0?{diagnostics:[...e.diagnostics??[],...s.diagnostics]}:{}},applied:!0,clipSrc:r.src}}return{doc:e,applied:!1}}function ig(e){try{let t=new TextDecoder().decode(e),n=JSON.parse(t);return n&&typeof n.sourceText==`string`&&typeof n.duration==`number`?{sourceText:n.sourceText,bookmarks:Array.isArray(n.bookmarks)?n.bookmarks:[],duration:n.duration}:null}catch{return null}}function ag(e){let t=e.toLowerCase().replace(/[^\w\s]/g,` `).split(/\s+/).filter(e=>e.length>2);return new Set(t)}function og(e,t){let n=ag(e),r=ag(t);if(n.size===0||r.size===0)return 0;let i=0;for(let e of n)r.has(e)&&i++;let a=new Set([...n,...r]).size;return a>0?i/a:0}function sg(e){return e.toLowerCase().replace(/[^\w\s-]/g,``).replace(/\s+/g,`-`).replace(/-+/g,`-`).replace(/^-|-$/g,``)}function cg(e){let t=[];if(e.title&&t.push(e.title),e.contents)for(let n of e.contents)t.push(o(n));return t.join(`
|
|
579
|
+
`)}function lg(e){let t=[];for(let n of e)n.children&&n.children.length>0?t.push(...lg(n.children)):t.push(n);return t}var ug=[`.mp3`,`.wav`,`.ogg`,`.m4a`],dg=[`.webm`,`.mp4`];function fg(e){let t=e.toLowerCase();return ug.some(e=>t.endsWith(e))?!0:dg.some(e=>t.endsWith(e))?t.startsWith(`audio/`):!1}function pg(e){let t=e.toLowerCase();for(let n of[...ug,...dg])if(t.endsWith(n))return e.slice(0,-n.length);return e}function mg(e){try{let t=new TextDecoder().decode(e),n=JSON.parse(t);return n&&n.version===2&&n.sections?n.sections:null}catch{return null}}async function hg(e){let t=(await e.listFiles()).filter(e=>fg(e.path)),n=[],r=null,i=await e.readFile(`timing.json`);i&&(r=mg(i));for(let i of t){let t=i.path.split(`/`).pop()??i.path,a=null;if(r){let e=pg(t),n=``;for(let[t,i]of Object.entries(r))e.endsWith(`-${t}`)&&t.length>n.length&&(n=t,a=i)}if(!a){let t=`${i.path}.timing.json`,n=await e.readFile(t);n&&(a=ig(n))}n.push({path:i.path,filename:t,timing:a})}return n}function gg(e,t){let n=[],r=lg(e);for(let e of r){let r=e.templateOverrides?.audio;if(!r)continue;let i=t.find(e=>e.filename===r||e.path===r||e.path.endsWith(`/${r}`));i&&n.push({block:e,audio:i})}return n}var _g=.35,vg=.5;function yg(e,t){let n=lg(e);if(n.length===0||t.length===0)return[];let r=[];for(let e=0;e<t.length;e++){let i=t[e];for(let t=0;t<n.length;t++){let a=n[t],o=cg(a);if(!o.trim())continue;let s=0;if(i.timing?.sourceText&&(s=og(i.timing.sourceText,o)),s<_g&&a.title){let e=sg(a.title);sg(pg(i.filename)).includes(e)&&e.length>=3&&(s=Math.max(s,vg+.1))}s>=_g&&r.push({block:a,blockIndex:t,audio:i,audioIndex:e,score:s})}}r.sort((e,t)=>t.score-e.score);let i=new Set,a=new Set,o=[];for(let e of r)i.has(e.blockIndex)||a.has(e.audioIndex)||(i.add(e.blockIndex),a.add(e.audioIndex),o.push({block:e.block,audio:e.audio,score:e.score}));return o}async function bg(e,t){let n=await rg(e,t);e=n.doc;let r=await hg(t),i=new Set(ee(e).map(e=>e.src)),a=r.filter(e=>!i.has(e.path));if(a.length===0)return e;let o=gg(e.blocks,a);if(o.length===0&&!n.applied&&(o=yg(e.blocks,a).map(e=>({block:e.block,audio:e.audio}))),o.length===0)return e;let s=lg(e.blocks),c=new Map(s.map((e,t)=>[e.id,t]));o.sort((e,t)=>(c.get(e.block.id)??0)-(c.get(t.block.id)??0));let l=[],u=new Map,d=0;for(let e=0;e<o.length;e++){let{block:t,audio:n}=o[e],r=n.timing?.duration??30;l.push({src:n.path,name:t.title??t.id,duration:r,startTime:d}),u.set(t.id,e),d+=r}let f=xg(e.blocks,u);return{...e,blocks:f,duration:n.applied?Math.max(e.duration,d):d,audio:{segments:l}}}function xg(e,t,n){return e.map(e=>{let r=t.get(e.id)??n??e.audioSegment,i={...e,audioSegment:r};return e.children&&(i.children=xg(e.children,t,r)),i})}var Sg=[`csv`,`tsv`,`xlsx`,`parquet`],Cg=new Set([`xlsx`]);function wg(e){let t=e.split(`/`).pop()??e,n=t.lastIndexOf(`.`);return n>0?t.slice(n+1).toLowerCase():``}function Tg(e){return!e||/^(?:[a-z][a-z0-9+.-]*:|\/\/|\/)/i.test(e)?!1:Sg.includes(wg(e))}function Eg(e){return`${e}_files/data/`}var Dg=50;function Og(e){let t=t=>!!(e.templateData&&t in e.templateData)||!!(e.templateOverrides&&t in e.templateOverrides);return t(`headers`)||t(`rows`)}function kg(e){return!!e.templateOverrides?.src&&_e.has(j(e.template??``))}async function Ag(e,t,n){let r=[],i=n.maxPreviewRows??Dg,a=new Map;for(let e of n.readers)for(let t of e.extensions)a.set(t.toLowerCase(),e);let o=new Map,s=e=>{let n=o.get(e);return n||(n=t.readFile(e).catch(()=>null),o.set(e,n)),n},c=async e=>{let t=e.templateOverrides,o=t.src,c=wg(o);if(!Tg(o))return r.push({severity:`warning`,code:`data-src-no-reader`,message:`Block "${e.id}": src "${o}" is not a relative data-file path (.${Sg.join(`/.`)}).`,blockId:e.id}),null;let l=a.get(c);if(!l)return r.push({severity:`warning`,code:`data-src-no-reader`,message:`Block "${e.id}": no data reader registered for ".${c}" (src "${o}").`,blockId:e.id}),null;(t.sheet||t.anchor)&&!Cg.has(c)&&r.push({severity:`info`,code:`data-src-param-ignored`,message:`Block "${e.id}": sheet/anchor only address workbook sources; ignored for ".${c}".`,blockId:e.id});let u=await s(o);if(!u)return r.push({severity:`warning`,code:`data-src-missing`,message:`Block "${e.id}": data file "${o}" was not found in the document container.`,blockId:e.id}),null;let d=Number.parseInt(t.previewRows??``,10),f=Number.isFinite(d)&&d>0?d:i,p={...t.sheet?{sheet:t.sheet}:{},...t.anchor?{anchor:t.anchor}:{},...t.headerRow===void 0?{}:{headerRow:t.headerRow!==`false`},...t.sort?{sort:t.sort}:{},...t.filter?{filter:t.filter}:{},maxRows:f},m;try{let e=[o,p.sheet??``,p.anchor??``,String(p.headerRow??``),p.sort??``,p.filter??``,String(f)].join(`\0`),t=n.tableCache?.get(e);t||(t=l.read(u,p),n.tableCache?.set(e,t)),m=await t}catch(t){let n=t instanceof Error?t.message:String(t),i=/sheet|worksheet/i.test(n)&&Cg.has(c);return r.push({severity:i?`warning`:`error`,code:i?`data-src-sheet-missing`:`data-src-parse`,message:`Block "${e.id}": could not read "${o}": ${n}`,blockId:e.id}),null}for(let t of m.viewIssues??[])r.push({severity:`info`,code:t.code,message:`Block "${e.id}": ${t.message}`,blockId:e.id});let h={totalRows:m.totalRows,totalCols:m.totalCols,previewRows:m.rows.length,truncated:m.rows.length<m.totalRows,...m.unfilteredTotalRows===void 0?{}:{unfilteredTotalRows:m.unfilteredTotalRows}};return{...e,templateData:{headers:m.headers,rows:m.rows,...m.align?{align:m.align}:{},srcStats:h,...e.templateData}}},l=!1,u=async e=>{let t=await Promise.all(e.map(async e=>{let t=null;kg(e)&&!Og(e)&&(t=await c(e));let n=e.children;if(e.children&&e.children.length>0&&(n=await u(e.children)),!t&&n===e.children)return e;l=!0;let r=t??e;return n===e.children?r:{...r,children:n}}));return t.some((t,n)=>t!==e[n])?t:e},d=await u(e.blocks);return{doc:l?{...e,blocks:d}:e,diagnostics:r}}function jg(e,t){return Mg(ge(e),t)}function Mg(e,t){let n=Td(e),r=[...n.diagnostics??[]],i=Ed(n.blocks),a=Ng(n,t),o=new Set(n.customTemplates?.map(e=>e.name)??[]),s=(e,t)=>{Fg(e,t,a,r),zg(e,t,r),Bg(e,r),Ig(e,t,o,r),Hg(e,r),Pg(e)&&Vg(e,r);for(let t of e.children??[])s(t,e)};for(let e of n.blocks)s(e,void 0);return Wg(e,r),t?.assets&&Yg(e,i,Gg(t.assets),r),r.sort((e,t)=>(e.line??2**53-1)-(t.line??2**53-1)),{diagnostics:r,errorCount:r.filter(e=>e.severity===`error`).length,warningCount:r.filter(e=>e.severity===`warning`).length,infoCount:r.filter(e=>e.severity===`info`).length,doc:n}}function Ng(e,t){return new Set([...Object.keys(Gc),...Object.keys(pe),...e.customTemplates?.map(e=>e.name)??[],...t?.extraTemplates??[]])}function Pg(e){return j(e.template??``)===`drawing`}function Fg(e,t,n,r){let i=e.sourceHeading?.templateAnnotation?.template??e.sourceAnnotation?.template;if(!i)return;if(t&&Pg(t)){if(es(i))return;let t=el(i,new Set(Zo),{map:j});r.push({severity:`warning`,code:`unknown-shape`,message:`Unknown shape "${i}" in drawing \u2014 the child will be skipped`+(t?`. Did you mean "${t}"?`:``),blockId:e.id,...Zg(e)});return}if(es(i)){r.push({severity:`warning`,code:`shape-outside-drawing`,message:`Shape "${i}" is only recognized on a child heading of a {[drawing]} block`,blockId:e.id,...Zg(e)});return}if(n.has(i)||n.has(j(i)))return;let a=el(i,n,{map:j});r.push({severity:`warning`,code:`unknown-template`,message:`Unknown template "${i}" \u2014 the block will render as a plain fallback card`+(a?`. Did you mean "${a}"?`:``),blockId:e.id,...Zg(e)})}function Ig(e,t,n,r){let i=e.sourceHeading?.templateAnnotation?.template;if(!i||t&&Pg(t)||es(i))return;let a=j(i);if(n.has(i)||n.has(a))return;let o=e.sourceHeading?.templateAnnotation?.params??{};for(let t of bl(a,o))t.kind===`missing-input`&&Lg(a,e,t.key)||r.push({severity:`warning`,code:t.kind,message:`Block "${e.id}": ${t.message}`,blockId:e.id,...Zg(e)})}function Lg(e,t,n){if(t.templateData&&n in t.templateData||t[n]!=null)return!0;let r=$a(e,t.title??``,t.contents);return r!=null&&n in r}var Rg=[`x`,`y`,`width`,`height`,`w`,`h`,`strokeWidth`,`borderRadius`];function zg(e,t,n){let r=e.sourceHeading?.attributes?.params;if(r){let{warnings:t}=se(r);for(let r of t)n.push({severity:`warning`,code:`invalid-attribute`,message:`Block "${e.id}": ${r}`,blockId:e.id,...Zg(e)})}if(t&&Pg(t)&&es(e.template)){let t=e.templateOverrides??{};for(let r of Rg){let i=t[r];if(i==null)continue;let a=i.replace(/,\s*$/,``).trim();a!==``&&!Number.isFinite(Number(a))&&n.push({severity:`warning`,code:`invalid-attribute`,message:`Drawing shape "${e.id}": "${r}" is not a number (${JSON.stringify(i)})`,blockId:e.id,...Zg(e)})}}}function Bg(e,t){let n=e.sourceHeading?.templateAnnotation?.params,r=e.sourceHeading?.attributes?.params;if(!(!n||!r))for(let i of Object.keys(ae)){let a=n[i],o=r[i];a==null||o==null||a===o||t.push({severity:`info`,code:`conflicting-annotation-key`,message:`"${i}" is set in both {[\u2026]} (${a}) and {\u2026} (${o}) \u2014 the {\u2026} value wins.`,blockId:e.id,...Zg(e)})}}function Vg(e,t){let n=e.children??[],r=new Set(n.map(e=>e.id));for(let e of n){let n=$o(e.sourceHeading?.templateAnnotation?.template);if(n!==`line`&&n!==`arrow`)continue;let i=e.templateOverrides??{};for(let n of[`from`,`to`]){let a=i[n];if(a==null)continue;let o=a.replace(/,\s*$/,``).trim();o&&!r.has(o)&&t.push({severity:`warning`,code:`unresolved-connection`,message:`Drawing connector "${e.id}" references unknown ${n} "${o}"`,blockId:e.id,...Zg(e)})}}}function Hg(e,t){if(e.sourceHeading?.templateAnnotation?.template||e.sourceAnnotation?.template)for(let n of e.contents??[]){if(n.type!==`code`)continue;let r=n.lang?.toLowerCase();if(r!==`json`&&r!==`yaml`&&r!==`yml`||Iu(n))continue;let i=Lu(n);!i.data||Object.keys(i.data).length===0||t.push({severity:`info`,code:`possible-data-fence`,message:`This ${r} block renders as code \u2014 add "data" to the fence (\`\`\`${r} data) if it's meant as template input.`,blockId:e.id,...n.position?{line:n.position.start.line}:Zg(e)})}}var Ug=/\{\[/;function Wg(e,n){let r=(e,i,a)=>{if(e.type===`heading`){let t=e,r=o(t);Ug.test(r)&&n.push({severity:`warning`,code:`unparsed-annotation`,message:`Heading "${Qg(r)}" contains "{[\u2026]}" text that was not recognized \u2014 check the quoting, or whether the token is a known inline icon`,...t.position?{line:t.position.start.line}:{}});return}if(e.type===`paragraph`&&a){let t=Ku(e);if(t&&t.template!=null)return}if(e.type===`text`&&Ug.test(e.value)){n.push({severity:`warning`,code:`unparsed-annotation`,message:`Body text contains "{[…]}" — template annotations are recognized on headings and as standalone paragraphs (or the token is not a known inline icon)`,...e.position?{line:e.position.start.line}:i==null?{}:{line:i}});return}if(e.type!==`code`)for(let n of t(e))r(n,i,!1)};for(let t of e.children)r(t,t.position?.start.line,!0)}function Gg(e){return typeof e==`function`?e:t=>e.has(t)||e.has(t.replace(/^\.\//,``))}var Kg=/^[a-z][a-z0-9+.-]*:/i;function qg(e){return e.length>0&&!Kg.test(e)&&!e.startsWith(`//`)&&!e.startsWith(`#`)}var Jg=[`src`,`imageSrc`,`videoSrc`,`poster`,`backgroundImage`];function Yg(e,n,r,i){let a=(e,t,n)=>{!qg(e)||r(e)||i.push({severity:`warning`,code:`missing-asset`,message:`Referenced asset "${e}" was not found in the bundle`,...n?{blockId:n}:{},...t==null?{}:{line:t}})},o=new Set,s=e=>{e.type===`image`&&(o.add(e.url),a(e.url,e.position?.start.line)),(e.type===`htmlBlock`||e.type===`htmlInline`)&&Xg(e.htmlChildren,t=>{o.add(t),a(t,e.position?.start.line)});for(let n of t(e))s(n)};for(let t of e.children)s(t);for(let e of n){let t=new Set,n=[{value:e.templateOverrides,derived:!1},{value:e.templateData,derived:!0}];for(let{value:r,derived:i}of n){if(!r)continue;for(let n of Jg){let s=r[n];typeof s==`string`&&(i||t.add(s),(!i||!o.has(s)&&!t.has(s))&&a(s,e.sourceHeading?.position?.start.line,e.id))}let n=r.images,s=typeof n==`string`?n.split(`,`).map(e=>e.trim()):Array.isArray(n)?n.filter(e=>typeof e==`string`):[];for(let n of s)i||t.add(n),(!i||!o.has(n)&&!t.has(n))&&a(n,e.sourceHeading?.position?.start.line,e.id)}}}function Xg(e,t){for(let n of e)n.type===`htmlElement`&&(n.tagName===`img`&&n.attributes.src&&t(n.attributes.src),Xg(n.children,t))}function Zg(e){let t=e.sourceHeading?.position?.start.line;return t==null?{}:{line:t}}function Qg(e,t=40){return e.length<=t?e:`${e.slice(0,t)}\u2026`}function $g(e){return e.split(`
|
|
580
|
+
`).map(e=>e.trim()).filter(e=>e.length>0)}function e_(e){if(e===void 0)return;let t=e.replace(/\s+/gu,` `).trim();return t.length>0?t:void 0}function t_(e){return e.length<=40}var n_=1;function r_(e,t={}){let n=(t.style??e.style)===`ascii`?Ct:St;if(e.nodes.length===0)return``;let r=a_(e.nodes,e.edges),i=new l_,a=[...r.values()].sort((e,t)=>e.depth-t.depth||e.rect.r0-t.rect.r0||e.rect.c0-t.rect.c0);for(let e of a)u_(i,e,n);return d_(i,e.edges,r,n),i.emit()}function i_(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Map;for(let t of e)r.set(t.id,{top:0,bottom:0,left:0,right:0});let i=e=>({r0:e.row,c0:e.col,r1:e.row+e.hRows-1,c1:e.col+e.wCols-1});for(let e of t){let t=n.get(e.source),a=n.get(e.target);if(!t||!a||t===a)continue;let{exit:o,enter:s}=f_(i(t),i(a));r.get(e.source)[o]++,r.get(e.target)[s]++}return r}function a_(e,t){let n=new Map;for(let t of e)n.set(t.id,t);let r=i_(e,t),i=new Map,a=[];for(let t of e)if(t.containerId&&n.has(t.containerId)&&t.containerId!==t.id){let e=i.get(t.containerId)??[];e.push(t.id),i.set(t.containerId,e)}else a.push(t.id);let o=new Map,s=(e,t,n)=>{let r=o.get(e);r&&(r.rect=s_(r.rect,t,n));for(let r of i.get(e)??[])s(r,t,n)},c=(e,t)=>{let r=[...e].sort((e,t)=>{let r=n.get(e),i=n.get(t);return r.row-i.row||r.col-i.col||r.id.localeCompare(i.id)}),i=[];for(let e of r){let n=t(e),r=0;for(;;){let t=i.find(e=>o_(n,e,n_));if(!t||r++>64)break;let a=t.c1+n_+1-n.c0,o=t.r1+n_+1-n.r0;a<o?(s(e,0,a),n=s_(n,0,a)):(s(e,o,0),n=s_(n,o,0))}i.push(n)}return i},l=(e,t)=>{let a=n.get(e),s=$g(a.label),u=i.get(e)??[];if(u.length===0){let n=s.reduce((e,t)=>Math.max(e,qe(t)),0),i=r.get(e)??{top:0,bottom:0,left:0,right:0},c=Math.max(i.top,i.bottom),l=Math.max(i.left,i.right),u=Math.max(a.wCols,n+4,3,c>0?2*c+1:0),d=Math.max(a.hRows,s.length+2,3,l>0?2*l+1:0),f={r0:a.row,c0:a.col,r1:a.row+d-1,c1:a.col+u-1};return o.set(e,{node:a,rect:f,labelLines:s,isContainer:!1,depth:t}),f}let d=c_(c(u,e=>l(e,t+1))),f=Math.max(0,s.length-1),p=qe(s[0]??``),m={r0:d.r0-2-f,c0:d.c0-2,r1:d.r1+2,c1:d.c1+2},h=s.slice(1).reduce((e,t)=>Math.max(e,qe(t)),0),g=Math.max(p>0?p+6:3,h>0?h+4:3);return m.c1-m.c0+1<g&&(m.c1=m.c0+g-1),m.c1-m.c0+1<a.wCols&&(m.c1=m.c0+a.wCols-1),o.set(e,{node:a,rect:m,labelLines:s,isContainer:!0,depth:t}),m};c(a,e=>l(e,0));let u=1/0,d=1/0;for(let e of o.values())u=Math.min(u,e.rect.r0),d=Math.min(d,e.rect.c0);let f=u<0?-u:0,p=d<0?-d:0;if(f>0||p>0)for(let e of o.values())e.rect=s_(e.rect,f,p);return o}function o_(e,t,n){return e.r0-n<=t.r1&&t.r0-n<=e.r1&&e.c0-n<=t.c1&&t.c0-n<=e.c1}function s_(e,t,n){return{r0:e.r0+t,c0:e.c0+n,r1:e.r1+t,c1:e.c1+n}}function c_(e){return e.reduce((e,t)=>({r0:Math.min(e.r0,t.r0),c0:Math.min(e.c0,t.c0),r1:Math.max(e.r1,t.r1),c1:Math.max(e.c1,t.c1)}))}var l_=class{constructor(){this.rows=[],this.kinds=[]}ensure(e,t){for(;this.rows.length<=e;)this.rows.push([]),this.kinds.push([]);let n=this.rows[e],r=this.kinds[e];for(;n.length<=t;)n.push(` `),r.push(`empty`)}kindAt(e,t){return this.kinds[e]?.[t]??`empty`}set(e,t,n,r){e<0||t<0||(this.ensure(e,t),this.rows[e][t]=n,this.kinds[e][t]=r)}drawEdgeCell(e,t,n,r,i){if(e<0||t<0)return;this.ensure(e,t);let a=this.kinds[e][t];if(!(a===`border`||a===`label`||a===`junction`)){if(r===`arrow`){this.rows[e][t]=n,this.kinds[e][t]=r;return}if(a!==`arrow`){if(a===`line-h`&&r===`line-v`||a===`line-v`&&r===`line-h`){this.rows[e][t]=i.cross,this.kinds[e][t]=`turn`;return}a===`empty`&&(this.rows[e][t]=n,this.kinds[e][t]=r)}}}emit(){let e=this.rows.map(e=>e.join(``).replace(/\s+$/u,``));for(;e.length>0&&e[e.length-1]===``;)e.pop();return e.join(`
|
|
581
|
+
`)}};function u_(e,t,n){let{rect:r,labelLines:i,isContainer:a}=t,o=r.c1-r.c0-1;e.set(r.r0,r.c0,n.tl,`border`),e.set(r.r0,r.c1,n.tr,`border`);let s=a&&i.length>0?Ke(` ${i[0]} `):null;if(s&&s.length<=o-2){let t=Math.floor((o-s.length)/2);for(let i=0;i<o;i++){let a=i>=t&&i<t+s.length,o=a?s[i-t]:n.h;e.set(r.r0,r.c0+1+i,o,a?`label`:`border`)}}else for(let t=r.c0+1;t<=r.c1-1;t++)e.set(r.r0,t,n.h,`border`);e.set(r.r1,r.c0,n.bl,`border`),e.set(r.r1,r.c1,n.br,`border`);for(let t=r.c0+1;t<=r.c1-1;t++)e.set(r.r1,t,n.h,`border`);for(let t=r.r0+1;t<=r.r1-1;t++)e.set(t,r.c0,n.v,`border`),e.set(t,r.c1,n.v,`border`);let c=a?i.slice(1):i;if(c.length>0){let t=r.r1-r.r0-1,n=a?r.r0+1:r.r0+1+Math.max(0,Math.floor((t-c.length)/2));c.forEach((t,i)=>{let a=Ke(t),s=Math.max(0,Math.floor((o-a.length)/2));for(let t=0;t<a.length&&s+t<o;t++)e.set(n+i,r.c0+1+s+t,a[t],`label`)})}}function d_(e,t,n,r){let i=[...t].sort((e,t)=>e.source.localeCompare(t.source)||e.target.localeCompare(t.target)||(e.label??``).localeCompare(t.label??``)),a=new Set,o=[];for(let e=0;e<i.length;e++){if(a.has(e))continue;let t=i[e];if(!n.has(t.source)||!n.has(t.target))continue;let r=!1;if(t.directed){let n=i.findIndex((n,r)=>r>e&&!a.has(r)&&n.directed&&n.source===t.target&&n.target===t.source&&(n.label??``)===(t.label??``));n>=0&&(a.add(n),r=!0)}let s=f_(n.get(t.source).rect,n.get(t.target).rect);o.push({edge:t,sourceId:t.source,targetId:t.target,exitSide:s.exit,enterSide:s.enter,biDir:r})}let s=p_(o,n),c=[];o.forEach((t,i)=>m_(e,t,i,n,s,r,(e,t)=>c.push({candidates:e,label:t})));for(let t of c){let n=Ke(t.label),r=!1;for(let i of[`right`,`left`]){if(r)break;for(let{row:a,col:o}of t.candidates){if(e.kindAt(a,o)!==`line-v`)continue;let t=i===`right`?o+2:o-1-n.length;if(t<0)continue;let s=i===`right`?o+1:o-1,c=e.kindAt(a,s)===`empty`;for(let r=0;c&&r<n.length;r++)e.kindAt(a,t+r)!==`empty`&&(c=!1);if(c&&i===`left`&&t>0&&(c=e.kindAt(a,t-1)===`empty`),c){for(let r=0;r<n.length;r++)e.set(a,t+r,n[r],`label`);r=!0;break}}}}}function f_(e,t){if(t.r0>e.r1)return{exit:`bottom`,enter:`top`};if(t.r1<e.r0)return{exit:`top`,enter:`bottom`};if(t.c0>e.c1)return{exit:`right`,enter:`left`};if(t.c1<e.c0)return{exit:`left`,enter:`right`};let n=[{side:`top`,gap:Math.abs(e.r0-t.r0)},{side:`bottom`,gap:Math.abs(t.r1-e.r1)},{side:`left`,gap:Math.abs(e.c0-t.c0)},{side:`right`,gap:Math.abs(t.c1-e.c1)}];return n.sort((e,t)=>e.gap-t.gap),{exit:n[0].side,enter:n[0].side}}function p_(e,t){let n=new Map;e.forEach((e,t)=>{let r=`${e.sourceId}|${e.exitSide}`,i=`${e.targetId}|${e.enterSide}`;n.set(r,[...n.get(r)??[],{key:`${t}:exit`,otherId:e.targetId}]),n.set(i,[...n.get(i)??[],{key:`${t}:enter`,otherId:e.sourceId}])});let r=new Map;for(let[e,i]of[...n.entries()].sort((e,t)=>e[0].localeCompare(t[0]))){let[n,a]=e.split(`|`),o=t.get(n);i.sort((e,n)=>{let r=t.get(e.otherId).rect,i=t.get(n.otherId).rect;return r.r0-i.r0||r.c0-i.c0||e.otherId.localeCompare(n.otherId)});let s=a===`top`||a===`bottom`,c=s?o.rect.c0+1:o.rect.r0+1,l=s?o.rect.c1-1:o.rect.r1-1,u=Math.max(1,l-c+1),d=i.length;if(d===1)r.set(i[0].key,{pos:c+Math.floor((u-1)/2),index:0,count:1});else{let e=2*d-1,t=c+Math.max(0,Math.floor((u-e)/2));i.forEach((e,n)=>{r.set(e.key,{pos:Math.min(l,t+2*n),index:n,count:d})})}}return r}function m_(e,t,n,r,i,a,o){let s=r.get(t.sourceId).rect,c=r.get(t.targetId).rect,l=i.get(`${n}:exit`),u=i.get(`${n}:enter`),d=l.pos,f=u.pos,p=u.count>l.count?u:l,m=p.index-Math.floor((p.count-1)/2),h={canvas:e,directed:t.edge.directed,biDir:t.biDir,label:e_(t.edge.label),vocab:a,junction:(t,n,r)=>{let i=r===`top`?a.stemUp:r===`bottom`?a.stemDown:r===`left`?a.stemLeft:a.stemRight;e.set(t,n,i,`junction`)},stagger:m,deferSideLabel:o};t.exitSide===`bottom`&&t.enterSide===`top`?__(h,s,c,d,f,1):t.exitSide===`top`&&t.enterSide===`bottom`?__(h,s,c,d,f,-1):t.exitSide===`right`&&t.enterSide===`left`?v_(h,s,c,d,f,1):t.exitSide===`left`&&t.enterSide===`right`?v_(h,s,c,d,f,-1):y_(h,s,c,t.exitSide)}function h_(e,t){let n=Math.min(e,t),r=Math.max(e,t),i=[];for(let e=n;e<=r;e++)i.push(e);let a=Math.floor((n+r)/2);return i.sort((e,t)=>Math.abs(e-a)-Math.abs(t-a)||e-t)}function g_(e,t,n){return Math.max(t,Math.min(n,e))}function __(e,t,n,r,i,a){let{canvas:o,directed:s,biDir:c,label:l,vocab:u,junction:d,stagger:f}=e,p=a===1?t.r1:t.r0,m=a===1?n.r0:n.r1,h=p+a,g=m-a,_=(g-h)*a+1,v=(e,t,n)=>{let r=Math.min(t,n),i=Math.max(t,n);for(let t=r;t<=i;t++)o.drawEdgeCell(t,e,u.v,`line-v`,u)};if(r>=n.c0+1&&r<=n.c1-1&&r>=t.c0+1&&r<=t.c1-1||_<2){let i=g_(r,t.c0+1,t.c1-1),f=g_(r,n.c0+1,n.c1-1);d(p,i,a===1?`bottom`:`top`),d(m,f,a===1?`top`:`bottom`),i===f&&_>=1&&(v(i,h,g),s&&o.drawEdgeCell(g,i,a===1?u.arrowDown:u.arrowUp,`arrow`,u),c&&_>=2&&o.drawEdgeCell(h,i,a===1?u.arrowUp:u.arrowDown,`arrow`,u),l&&e.deferSideLabel(h_(h,g).map(e=>({row:e,col:i})),l));return}let y=g_(Math.floor((p+m)/2)+f,Math.min(h,g),Math.max(h,g));d(p,r,a===1?`bottom`:`top`),d(m,i,a===1?`top`:`bottom`),Math.abs(y-p)>=2&&v(r,h,y-a),Math.abs(m-y)>=2&&v(i,y+a,g);let b=!1;if(r===i)o.drawEdgeCell(y,r,u.v,`line-v`,u);else{let e=i>r,t=a===1?e?u.turnUpRight:u.turnUpLeft:e?u.turnDownRight:u.turnDownLeft,n=a===1?e?u.turnDownLeft:u.turnDownRight:e?u.turnUpLeft:u.turnUpRight;o.drawEdgeCell(y,r,t,`turn`,u),o.drawEdgeCell(y,i,n,`turn`,u);let s=Math.min(r,i),c=Math.max(r,i),d=[];for(let e=s+1;e<=c-1;e++)d.push(u.h);let f=l?Ke(` ${l} `):null;if(f&&t_(f)&&d.length>=f.length+2){let e=Math.floor((d.length-f.length)/2);d=d.map((t,n)=>n>=e&&n<e+f.length?f[n-e]:t),b=!0}d.forEach((e,t)=>{o.drawEdgeCell(y,s+1+t,e,e===u.h?`line-h`:`label`,u)})}if(s&&o.drawEdgeCell(g,i,a===1?u.arrowDown:u.arrowUp,`arrow`,u),c&&o.drawEdgeCell(h,r,a===1?u.arrowUp:u.arrowDown,`arrow`,u),l&&!b){let t=[];if(r===i)for(let e of h_(h,g))t.push({row:e,col:r});else{let e=(y-a-h)*a+1,n=(g-(y+a))*a+1;if(e>=1)for(let e of h_(h,y-a))t.push({row:e,col:r});if(n>=1)for(let e of h_(y+a,g))t.push({row:e,col:i})}t.length>0&&e.deferSideLabel(t,l)}}function v_(e,t,n,r,i,a){let{canvas:o,directed:s,biDir:c,label:l,vocab:u,junction:d}=e,f=a===1?t.c1:t.c0,p=a===1?n.c0:n.c1,m=f+a,h=p-a,g=(h-m)*a+1,_=(e,t,n,r,i=0,a=0)=>{let s=Math.min(t,n),c=Math.max(t,n),d=[];for(let e=s;e<=c;e++)d.push(u.h);let f=r&&l?Ke(` ${l} `):null;if(f&&t_(f)){let e=i,t=d.length-1-a-e+1;if(t>=f.length+2){let n=e+Math.floor((t-f.length)/2);d=d.map((e,t)=>t>=n&&t<n+f.length?f[t-n]:e)}}d.forEach((t,n)=>{o.drawEdgeCell(e,s+n,t,t===u.h?`line-h`:`label`,u)})};if(r>=n.r0+1&&r<=n.r1-1&&r>=t.r0+1&&r<=t.r1-1||g<2){let e=g_(r,t.r0+1,t.r1-1),i=g_(r,n.r0+1,n.r1-1);d(e,f,a===1?`right`:`left`),d(i,p,a===1?`left`:`right`),e===i&&g>=1&&(_(e,m,h,!0,(a===1?c:s)?1:0,(a===1?s:c)?1:0),s&&o.drawEdgeCell(e,h,a===1?u.arrowRight:u.arrowLeft,`arrow`,u),c&&g>=2&&o.drawEdgeCell(e,m,a===1?u.arrowLeft:u.arrowRight,`arrow`,u));return}let v=g_(Math.floor((f+p)/2)+e.stagger,Math.min(m,h),Math.max(m,h));if(d(r,f,a===1?`right`:`left`),d(i,p,a===1?`left`:`right`),Math.abs(v-f)>=2&&_(r,m,v-a,!0,a===1&&c?1:0,a===-1&&c?1:0),Math.abs(p-v)>=2&&_(i,v+a,h,!1),r===i)o.drawEdgeCell(r,v,u.h,`line-h`,u);else{let e=i>r,t=a===1?e?u.turnDownLeft:u.turnUpLeft:e?u.turnDownRight:u.turnUpRight,n=a===1?e?u.turnUpRight:u.turnDownRight:e?u.turnUpLeft:u.turnDownLeft;o.drawEdgeCell(r,v,t,`turn`,u),o.drawEdgeCell(i,v,n,`turn`,u);let s=Math.min(r,i),c=Math.max(r,i);for(let e=s+1;e<=c-1;e++)o.drawEdgeCell(e,v,u.v,`line-v`,u)}s&&o.drawEdgeCell(i,h,a===1?u.arrowRight:u.arrowLeft,`arrow`,u),c&&o.drawEdgeCell(r,m,a===1?u.arrowLeft:u.arrowRight,`arrow`,u)}function y_(e,t,n,r){let{canvas:i,directed:a,vocab:o,junction:s}=e;if(r===`top`||r===`bottom`){let e=Math.max(t.c0+1,n.c0+1),c=Math.min(t.c1-1,n.c1-1);if(e>c)return;let l=Math.floor((e+c)/2),u=r===`top`?t.r0:t.r1,d=r===`top`?n.r0:n.r1;if(u===d)return;s(u,l,r),s(d,l,r);let f=Math.min(u,d),p=Math.max(u,d);for(let e=f+1;e<=p-1;e++)i.drawEdgeCell(e,l,o.v,`line-v`,o);if(a&&p-f>=2){let e=d>u?d-1:d+1;i.drawEdgeCell(e,l,d>u?o.arrowDown:o.arrowUp,`arrow`,o)}}else{let e=Math.max(t.r0+1,n.r0+1),c=Math.min(t.r1-1,n.r1-1);if(e>c)return;let l=Math.floor((e+c)/2),u=r===`left`?t.c0:t.c1,d=r===`left`?n.c0:n.c1;if(u===d)return;s(l,u,r),s(l,d,r);let f=Math.min(u,d),p=Math.max(u,d);for(let e=f+1;e<=p-1;e++)i.drawEdgeCell(l,e,o.h,`line-h`,o);if(a&&p-f>=2){let e=d>u?d-1:d+1;i.drawEdgeCell(l,e,d>u?o.arrowRight:o.arrowLeft,`arrow`,o)}}}var b_=2,x_=8,S_=12,C_=4,w_=4;function T_(e){return!ln(e).isDiagram&&D_(Pt(Ft(e),!0)).length>=b_}function E_(e){let t=Ft(e),n=D_(Pt(t,!0));if(n.length<b_)return null;let r=O_(t,n),i={nodes:r,edges:M_(t,n,r),style:L_(t),warnings:[`repaired`]};return{diagram:i,art:r_(i)}}function D_(e){let t=new Set,n=[];for(let r of e){let e=`${r.r0},${r.c0},${r.r1},${r.c1}`;t.has(e)||(t.add(e),n.push(r))}return n.sort((e,t)=>e.r0-t.r0||e.c0-t.c0)}function O_(e,t){let n=e[0]?.length??0,r=t.map(()=>[]),i=new Map(t.map((e,t)=>[e,t])),a=[];for(let e of t){let t=a.find(t=>t.some(t=>t.r0<=e.r1&&e.r0<=t.r1));t||(t=[],a.push(t)),t.push(e)}for(let t of a){t.sort((e,t)=>e.c0-t.c0);let a=Math.min(...t.map(e=>e.r0+1)),o=Math.max(...t.map(e=>e.r1-1));for(let s=a;s<=o;s++){let a=t.filter(e=>s>e.r0&&s<e.r1);if(a.length===0)continue;let o=e[s].join(``).split(/[│┃║]/).map(k_).filter(e=>e.length>0);if(o.length===a.length)a.forEach((e,t)=>{let n=i.get(e);n!==void 0&&o[t]&&r[n].push(o[t])});else for(let t of a){let a=i.get(t);if(a===void 0)continue;let o=k_(e[s].slice(t.c0+1,Math.min(t.c1,n)).join(``));o&&r[a].push(o)}}}let o=new Map,s=[...a].sort((e,t)=>Math.min(...e.map(e=>e.r0))-Math.min(...t.map(e=>e.r0))),c=0;for(let e of s){o.set(e,c);let t=Math.max(...e.map(e=>e.r1-e.r0+1));c+=t+C_}let l=new Map;for(let e of a)for(let t of e)l.set(t,e);let u=t.map((e,t)=>Math.max(e.c1-e.c0+1,...r[t].map(e=>e.length+4),3)),d=new Map(t.map((e,t)=>[e,t])),f=new Map;for(let e of a){let t=[...e].sort((e,t)=>e.c0-t.c0),n=Math.min(...e.map(e=>e.c0));for(let e of t)f.set(e,n),n+=(u[d.get(e)??0]??3)+w_}let p=t.map((e,n)=>A_(t,n)),m=new Map,h=t.map((e,t)=>{let n=j_(r[t][0]??``),i=m.get(n)??0;m.set(n,i+1),i>0&&(n=`${n}-${i+1}`);let a=l.get(e),s=p[t]>=0,c=a&&!s?o.get(a)??e.r0:e.r0,u=s?e.c0:f.get(e)??e.c0;return{id:n,label:r[t].join(`
|
|
582
|
+
`),col:u,row:c,wCols:e.c1-e.c0+1,hRows:e.r1-e.r0+1}});return h.forEach((e,t)=>{p[t]>=0&&(e.containerId=h[p[t]].id)}),h}function k_(e){let t=``;for(let n of e){let e=n.codePointAt(0)??0;e>=9472&&e<=9599||P(n)!==null?t+=` `:t+=n}return t.replace(/\s+/g,` `).trim()}function A_(e,t){let n=e[t],r=-1,i=1/0;for(let a=0;a<e.length;a++){if(a===t)continue;let o=e[a];if(o.r0<n.r0&&o.c0<n.c0&&o.r1>n.r1&&o.c1>n.c1){let e=(o.r1-o.r0)*(o.c1-o.c0);e<i&&(i=e,r=a)}}return r}function j_(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`node`}function M_(e,t,n){let r=e.length,i=e[0]?.length??0,a=(t,n)=>t>=0&&t<r&&n>=0&&n<i?e[t][n]:` `,o=e=>pt(e)||ft(e)||mt(e)||P(e)!==null,s=(e,t)=>Math.max(e.c0,t.c0)<=Math.min(e.c1,t.c1),c=(e,t)=>Math.max(e.r0,t.r0)<=Math.min(e.r1,t.r1),l=[],u=new Set,d=(e,t,r)=>{if(e===t)return;let i=`${n[e].id}|${n[t].id}`;u.has(i)||(u.add(i),l.push({source:n[e].id,target:n[t].id,directed:r}))};for(let e=0;e<t.length;e++)for(let n=0;n<t.length;n++){if(e===n)continue;let r=t[e],i=t[n];if(r.r1<i.r0&&i.r0-r.r1<=x_&&s(r,i)){let s=Math.max(r.c0,i.c0),c=Math.min(r.c1,i.c1);if(N_(a,r.r1+1,i.r0-1,s-1,c+1,o)&&!F_(t,e,n,s,c)){let t=P_(a,r.r1+1,i.r0,s-1,c+1,`down`);d(e,n,t)}}if(r.c1<i.c0&&i.c0-r.c1<=S_&&c(r,i)&&e<n){let o=Math.max(r.r0,i.r0),s=Math.min(r.r1,i.r1),c=P_(a,o-1,s+1,r.c1+1,i.c0,`right`),l=P_(a,o-1,s+1,r.c1+1,i.c0,`left`);(c||l)&&!I_(t,e,n,o,s)&&(l&&!c?d(n,e,!0):d(e,n,!0))}}return l}function N_(e,t,n,r,i,a){for(let o=t;o<=n;o++)for(let t=r;t<=i;t++)if(a(e(o,t)))return!0;return!1}function P_(e,t,n,r,i,a){for(let o=t;o<=n;o++)for(let t=r;t<=i;t++)if(P(e(o,t))===a)return!0;return!1}function F_(e,t,n,r,i){let a=e[t],o=e[n];return e.some((e,s)=>s===t||s===n?!1:e.r0>a.r1&&e.r1<o.r0&&Math.max(e.c0,r)<=Math.min(e.c1,i))}function I_(e,t,n,r,i){let a=e[t],o=e[n];return e.some((e,s)=>s===t||s===n?!1:e.c0>a.c1&&e.c1<o.c0&&Math.max(e.r0,r)<=Math.min(e.r1,i))}function L_(e){let t=0,n=0;for(let r of e)for(let e of r){let r=e.codePointAt(0)??0;r>=9472&&r<=9599?t++:(e===`+`||e===`|`||e===`-`)&&n++}return n>t?`ascii`:`unicode`}var R_={rail:`─`,arrow:`►`,marker:{filled:`●`,hollow:`○`,diamond:`◆`}},z_={rail:`-`,arrow:`>`,marker:{filled:`*`,hollow:`o`,diamond:`*`}},B_=48,V_=64,H_=3,U_=3;function W_(e,t={}){let n=t.style??e.style,r=n===`ascii`?z_:R_,{tracks:i,links:a}=Q_(e,n);if(i.length===0)return``;let o=Math.min(...i.map(e=>e.startColumn)),s=Math.max(...i.map(e=>e.endColumn)),c=Math.max(1,s-o),l=Math.max(B_,Math.min(V_,Math.ceil(c)),...i.map(e=>e.events.length*H_)),u=i.map(e=>q_(e)),d=Math.max(...u.map(X_)),f=[];if(i.forEach((e,t)=>{t>0&&f.push(``),f.push(...G_(e,n,r,u[t],d,l,o,c))}),a.length>0){f.push(``);for(let e of a)f.push(Z_(e,n))}return f.join(`
|
|
583
|
+
`)}function G_(e,t,n,r,i,a,o,s){let c=`${r}${` `.repeat(Math.max(0,i-X_(r)))}`,l=J_(e.events,a,o,s),u=Array.from({length:a+1},()=>n.rail);for(let{event:e,offset:t}of l)u[t]=n.marker[e.marker];let d=l.map(({event:e,offset:t})=>({event:e,column:i+t,text:K_(e)})),f=t===`ascii`?{above:`^`,below:`v`}:{above:`▲`,below:`▼`},p=Y_(d.filter(({event:e})=>e.side===`above`),f.above),m=Y_(d.filter(({event:e})=>e.side===`below`),f.below),h=`${c}${u.join(``)}${n.rail.repeat(U_)}${n.arrow}${e.endLabel?` ${e.endLabel}`:``}`;return[...p,h,...m]}function K_(e){let t=e.description?`${e.label} :: ${e.description}`:e.label,n=e.descriptionSide?` descriptionSide=${e.descriptionSide}`:``,r=e.callout===!1?` callout=false`:``;return`${t} {#${e.id} column=${sv(e.column)}${n}${r}}`}function q_(e){let t=`{#${e.id} start=${sv(e.startColumn)} end=${sv(e.endColumn)}}`;return e.label?`${e.label} ${t}: `:`${t}: `}function J_(e,t,n,r){let i=-1;return e.map((a,o)=>{let s=Math.round((a.column-n)/r*t),c=e.length-o-1,l=Math.max(0,t-c),u=Math.max(i+1,Math.min(l,Math.max(0,s)));return i=u,{event:a,offset:u}})}function Y_(e,t){let n=[],r=[];for(let t of e){let e=t.column+2+X_(t.text),i=r.findIndex(e=>t.column>e+1);i<0&&(i=n.length,n.push([]),r.push(-1)),n[i].push(t),r[i]=e}return n.map(e=>{let n=[];for(let r of e){for(;n.length<r.column;)n.push(` `);n.push(t,` `,...Array.from(r.text))}return n.join(``).trimEnd()})}function X_(e){return Array.from(e).length}function Z_(e,t){let n=t===`ascii`?`->`:`→`;return`branch: ${e.source} ${n} ${e.target}${e.label?` : ${e.label}`:``}`}function Q_(e,t){let n=e.tracks.map((e,t)=>({track:e,index:t})).filter(({track:e})=>Array.isArray(e.events)&&e.events.length>0).sort((e,t)=>av(e.track.row,e.index)-av(t.track.row,t.index)||e.index-t.index||e.track.id.localeCompare(t.track.id)),r=new Set,i=new Set,a=new Map,o=new Map,s=[],c=0;for(let{track:e}of n){let n=ev(e.label),l=ev(e.endLabel),u=rv(nv(e.id,nv(n,`track_${s.length+1}`)),r),d=e.events.map((e,t)=>({event:e,index:t})).sort((e,t)=>av(e.event.column,e.index)-av(t.event.column,t.index)||e.index-t.index||e.event.id.localeCompare(t.event.id)),f=[];for(let e=0;e<d.length;e++){let n=d[e].event,r=`Event ${e+1}`,s=ev(n.label)||r,l=rv(nv(n.id,nv(s,`event_${++c}`)),i),u=ev(n.description),p=u&&(n.descriptionSide===`above`||n.descriptionSide===`below`)?n.descriptionSide:void 0,m=ov(n.column,e),h=n.side===`below`?`below`:n.side===`above`||e%2==0?`above`:`below`,g=$_(n.marker,t);f.push({id:l,label:s,...u?{description:u}:{},...p?{descriptionSide:p}:{},column:m,side:h,...n.callout===!1?{callout:!1}:{},marker:g}),n.id&&!a.has(n.id)&&a.set(n.id,l),a.set(l,l),o.set(iv(s),l)}let p=f.map(e=>e.column),m=p.length>0?Math.min(...p):0,h=p.length>0?Math.max(...p):m+1;s.push({id:u,...n?{label:n}:{},...l?{endLabel:l}:{},startColumn:ov(e.startColumn,m),endColumn:ov(e.endColumn,h),events:f})}let l=e=>a.get(e)??o.get(iv(e)),u=[];for(let t of Array.isArray(e.links)?e.links:[]){let e=l(t.source),n=l(t.target);if(!e||!n)continue;let r=tv(t.label);u.push({source:e,target:n,...r?{label:r}:{}})}return u.sort((e,t)=>e.source.localeCompare(t.source)||e.target.localeCompare(t.target)||(e.label??``).localeCompare(t.label??``)),{tracks:s,links:u}}function $_(e,t){return e===`hollow`?`hollow`:e===`diamond`&&t!==`ascii`?`diamond`:`filled`}function ev(e){return e?e.normalize(`NFC`).replace(/[\r\n\t]+/g,` `).replace(/[\u25cf\u25cb\u25c9\u25c6\u25c7\u2022]+/gu,`·`).replace(/\*/g,`∗`).replace(/::/g,`∶`).replace(/\s+/g,` `).trim().replace(/^[\u2500\u2501\u2550\u254c\u254d\u2504\u2505\u2508\u2509-]+/u,e=>Array.from(e,e=>e===`-`?`−`:`–`).join(``)):``}function tv(e){return ev(e).replace(/\s+/g,` `).trim()}function nv(e,t){return(e??``).normalize(`NFC`).replace(/[\r\n\t\s]+/g,`_`).replace(/[^A-Za-z0-9_.~-]+/g,`_`).replace(/^_+|_+$/g,``)||t}function rv(e,t){if(!t.has(e))return t.add(e),e;let n=2,r=`${e}_${n}`;for(;t.has(r);)r=`${e}_${++n}`;return t.add(r),r}function iv(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`event`}function av(e,t){return Number.isFinite(e)?e:t}function ov(e,t){let n=av(e,t);return Math.max(0,Object.is(n,-0)?0:n)}function sv(e){return String(Object.is(e,-0)?0:e)}function cv(e){return e.replace(/\s+/gu,` `).trim()}function lv(e,t={}){let n=(t.style??e.style)===`ascii`?Ir:Fr,r=[],i=e=>{let t=cv(e.label),n=e.comment?cv(e.comment):``;return n?`${t} # ${n}`:t},a=(e,t)=>{e.forEach((o,s)=>{let c=s===e.length-1;r.push(t+(c?n.elbow:n.tee)+i(o)),a(o.children,t+(c?n.gap:n.rail))})};for(let t of e.roots)r.push(i(t)),a(t.children,``);return r.join(`
|
|
584
|
+
`)}var uv=e({ASCII_CHAR_H:()=>28,ASCII_CHAR_W:()=>14,ASCII_DIAGRAM_FENCE_LANGS:()=>en,ASCII_TIMELINE_FENCE_LANGS:()=>mr,BASE_INPUT_DESCRIPTORS:()=>ll,BLOCK_MEDIA_LAYOUT_POLICIES:()=>Dl,BUILTIN_DASHBOARD_LAYOUTS:()=>Gm,CONTAINER_TEMPLATES:()=>fe,COVER_SLIDE_FRONTMATTER_KEYS:()=>Of,COVER_SLIDE_TEMPLATE_OPTIONS:()=>Df,DASHBOARD_AUTO_LAYOUT_ID:()=>Ym,DASHBOARD_FRONTMATTER_KEYS:()=>dh,DASHBOARD_STYLES:()=>eh,DASHBOARD_STYLE_IDS:()=>Qm,DASHBOARD_ZOOM_LEVELS:()=>dm,DATA_FILE_EXTENSIONS:()=>Sg,DEFAULT_COVER_SLIDE_SETTINGS:()=>kf,DEFAULT_DASHBOARD_SETTINGS:()=>fh,DEFAULT_DASHBOARD_STYLE:()=>$m,DEFAULT_LAYOUT:()=>Hi,DEFAULT_THEME:()=>A,DIAGRAM_LABEL_HORIZONTAL_PADDING:()=>24,DIAGRAM_LABEL_LINE_HEIGHT:()=>Ao,DIAGRAM_LABEL_MIN_FONT_SIZE:()=>10,DIAGRAM_LABEL_VERTICAL_PADDING:()=>16,FRONTMATTER_CUSTOM_TEMPLATES_KEY:()=>E,FRONTMATTER_CUSTOM_THEMES_KEY:()=>k,FRONTMATTER_DASHBOARD_LAYOUTS_KEY:()=>Am,MAX_COVER_SLIDE_DURATION_SECONDS:()=>60,PAGE_BASE_CSS:()=>lm,PATH_SHAPE_KINDS:()=>we,SHAPE_NAMES:()=>Zo,TABLE_FED_TEMPLATES:()=>_e,TEMPLATE_AUTHORING_METADATA:()=>ou,TEMPLATE_INPUT_DESCRIPTORS:()=>ul,TEMPLATE_METADATA:()=>au,TREE_FENCE_LANGS:()=>Ur,VIEWPORT_PRESETS:()=>f,adjustY:()=>U,anchorPoint:()=>Ne,applyNarrationTiming:()=>rg,applyRenderStyleToLayers:()=>Qc,asciiCellToCanvas:()=>ha,asciiDiagramFromBlocks:()=>Sa,asciiDiagramFromTemplateData:()=>xa,asciiDiagramToTemplateData:()=>_a,asciiTimelineToTemplateData:()=>Ca,autoTemplatePreservesContent:()=>Qa,bigText:()=>la,buildDashboardCellChrome:()=>ch,buildPageCss:()=>um,buildPageCssVars:()=>om,buildPreviewDoc:()=>lp,buildRegistry:()=>Kc,canvasToAsciiCell:()=>ga,chooseDashboardLayout:()=>Zm,clipEndpoints:()=>je,clipPoint:()=>Ae,coerceTemplateParams:()=>ml,comparisonBar:()=>To,composeDashboardLayers:()=>Oh,computeDiagramLayout:()=>da,computeDrawingLayout:()=>as,computeLayoutLayers:()=>Es,connectorPath:()=>Re,contentBlock:()=>io,countBlocks:()=>Od,coverBlock:()=>mu,createAccentLayers:()=>qi,createTemplateContext:()=>p,cssFilterForTreatment:()=>Ef,dashboardCanvasFill:()=>ih,dashboardCellAccent:()=>ah,dataSidecarPrefix:()=>Eg,dataTable:()=>ko,dateEvent:()=>uo,definitionCard:()=>wo,deriveTemplateInputs:()=>$a,desiredCellZoom:()=>gm,detectAsciiDiagram:()=>ln,detectAsciiTimeline:()=>Cr,detectTree:()=>Zr,diagramBlock:()=>zo,docToMarkdown:()=>Rf,documentTitleFromFileName:()=>sp,drawingBlock:()=>gs,expandCoverBlock:()=>gu,expandDocBlocks:()=>vu,expandPersistentLayers:()=>wi,extractBlockquoteText:()=>Ga,extractBodyPlainText:()=>Ma,extractEmbeddedVideos:()=>Ha,extractFirstEmbeddedVideo:()=>Ua,extractFirstImage:()=>Va,extractImages:()=>Ba,extractListItems:()=>Na,extractRichListItems:()=>Ra,extractTableData:()=>Wu,extractTableFromContents:()=>Wa,factCard:()=>so,fallbackBlockLayers:()=>Sl,findFirstList:()=>Aa,findFirstTable:()=>Uu,fitBigTextSize:()=>sa,fitDiagramLabel:()=>jo,flattenBlocks:()=>Ed,flattenRenderableBlocks:()=>Dd,fullBleedQuote:()=>_o,getAccentLayout:()=>Ki,getAnimationProgress:()=>Sf,getAnimationStyle:()=>df,getAvailableTemplates:()=>yu,getAvailableThemes:()=>T,getBlockBodyText:()=>Rd,getBlockDepth:()=>kd,getBlockMediaLayoutPolicy:()=>Ol,getDashboardLayoutSummaries:()=>qm,getDefaultAnimation:()=>Ni,getDefaultAnimationDuration:()=>mf,getLayoutHints:()=>g,getOverlayOpacity:()=>Pi,getPersistentLayersFromTheme:()=>Ti,getPinnedBlockMeta:()=>Sd,getTemplateHint:()=>Ii,getThemeFont:()=>I,getThemeSummaries:()=>ne,getTransitionClass:()=>hf,getTwoColumnPositions:()=>c,getViewport:()=>d,getViewportOrientation:()=>_,hasTemplate:()=>bu,imageWithCaption:()=>fo,isAsciiDiagramFence:()=>un,isAsciiTimelineFence:()=>wr,isContainerTemplate:()=>oe,isDataFence:()=>Iu,isDataFilePath:()=>Tg,isEligibleAsciiFenceLang:()=>sn,isEligibleAsciiTimelineFenceLang:()=>xr,isEligibleTreeFenceLang:()=>Yr,isExplicitDiagramLang:()=>cn,isExplicitTimelineLang:()=>Sr,isExplicitTreeLang:()=>Xr,isRepairableDiagram:()=>T_,isShapeName:()=>es,isTemplateBlock:()=>u,isTemplatedPageBlock:()=>dp,isTreeFence:()=>Qr,isWrappedFlowTimelineSource:()=>bn,layoutBlock:()=>As,layoutCapacity:()=>Dm,leftFeature:()=>mo,lineStyleDasharray:()=>Ve,lintTemplateParams:()=>bl,listBlock:()=>xo,listDashboardLayouts:()=>Jm,mapBlock:()=>go,markdownBlockSeparatorLines:()=>Ia,markdownToDoc:()=>Td,markerPath:()=>ke,materializeBlockLayers:()=>Kl,materializeDashboard:()=>Dh,materializeFlashcards:()=>Yh,materializePageSection:()=>rm,materializePageSections:()=>im,nearestSnapPoint:()=>Pe,normalizeDashboardZoom:()=>fm,normalizeShapeKind:()=>$o,pageStyleDataAttributes:()=>sm,parseAsciiDiagram:()=>kt,parseAsciiTimeline:()=>Rn,parseAsciiTimelineWithStats:()=>zn,parseDataFence:()=>Lu,parseTree:()=>Lr,parseWrappedFlowTimeline:()=>yn,parseYamlSubset:()=>Hu,photoGrid:()=>So,pullQuote:()=>Eo,quoteBlock:()=>oo,readCustomTemplatesFromFrontmatter:()=>Eu,readCustomThemesFromFrontmatter:()=>Nu,readDashboardLayoutsFromFrontmatter:()=>Pm,renderAsciiDiagram:()=>r_,renderAsciiTimeline:()=>W_,renderMarkdownBlocksHtml:()=>Fa,renderTree:()=>lv,repairAsciiDiagram:()=>E_,replaceDataFence:()=>Ru,resolveAudioMapping:()=>bg,resolveColorScheme:()=>F,resolveCoverSlideSettings:()=>Ff,resolveDashboardLayoutDefinition:()=>Xm,resolveDashboardSettings:()=>_h,resolveDashboardStyleId:()=>th,resolveDashboardZooms:()=>_m,resolveDataReferences:()=>Ag,resolveFlashcardMarker:()=>Mh,resolveLayoutCells:()=>km,resolvePageBlock:()=>pp,resolvePageStyle:()=>Hp,resolvePersistentLayers:()=>Ei,resolveTemplateName:()=>j,resolveTheme:()=>O,resolveThemeForDoc:()=>up,rightFeature:()=>ho,scaleAnimationDuration:()=>Mi,scaledFontSize:()=>m,scoreTextSimilarity:()=>og,sectionExtractors:()=>Vp,sectionHeader:()=>ea,shapePath:()=>De,shouldUseShadow:()=>z,snapEndpoints:()=>Fe,snapPoints:()=>Me,statHighlight:()=>ao,stripBlockBackdropLayer:()=>uh,stripsBlockBackdrop:()=>lh,templateRegistry:()=>Gc,themeWantsAmbientMotion:()=>Zc,themedEntrance:()=>R,themedFontSize:()=>L,themedImageTreatment:()=>B,themedScrim:()=>Fi,themedSurfaceGradient:()=>V,timelineBlock:()=>Xo,titleBlock:()=>Bi,transposeCells:()=>Om,treeBlock:()=>Ho,treeFromMarkdownList:()=>ka,treeFromTemplateData:()=>Da,treeToTemplateData:()=>Ta,twoColumn:()=>co,validateDashboardLayoutDefinition:()=>Em,validateMarkdownDoc:()=>Mg,validateMarkdownSource:()=>jg,videoPullQuote:()=>Oo,videoWithCaption:()=>Do,wrapWithPersistentLayers:()=>Di,writeCustomTemplatesToFrontmatter:()=>Du,writeCustomThemesToFrontmatter:()=>Pu,writeDashboardLayoutsToFrontmatter:()=>Fm});export{rf as $,bg as A,bn as At,au as B,Pe as Bt,Yh as C,Zr as Ct,W_ as D,cn as Dt,r_ as E,Yr as Et,Hp as F,ui as Ft,sf as G,_a as H,Fe as Ht,up as I,Ne as It,Es as J,ga as K,ma as L,Ue as Lt,th as M,Rn as Mt,Ag as N,Lr as Nt,lv as O,Sr as Ot,pp as P,oi as Pt,vu as Q,pa as R,Re as Rt,Dh as S,Cr as St,sm as T,xr as Tt,Ca as U,ha as V,De as Vt,Zd as W,$a as X,Od as Y,gu as Z,df as _,of as _t,dh as a,jo as at,T_ as b,Pu as bt,fh as c,yu as ct,om as d,bu as dt,Ga as et,lp as f,Td as ft,sp as g,Ei as gt,Rf as h,Nu as ht,Ym as i,Wa as it,Ff as j,kt as jt,E_ as k,Xr as kt,$m as l,Rd as lt,Eg as m,Eu as mt,Of as n,Ba as nt,eh as o,Ed as ot,Ef as p,Kl as pt,as as q,Df as r,Na as rt,kf as s,Dd as st,uv as t,Ma as tt,lm as u,Sd as ut,hf as v,af as vt,im as w,sn as wt,Jm as x,ln as xt,Tg as y,Du as yt,Ao as z,ke as zt};
|