@bendyline/gezel-service 1.1.1 → 1.1.2

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.
Files changed (185) hide show
  1. package/dist/NOTICE.md +3 -3
  2. package/dist/bin/gezeld.js +8471 -5311
  3. package/dist/handboek-content/technical/building-connected-apps-with-gezel-app-sdk.md +78 -0
  4. package/dist/handboek-content/whats-new/{1.26250.md → 1.26251.md} +5 -5
  5. package/dist/index-store/static-index-worker.js +160 -51
  6. package/dist/index.d.ts +416 -71
  7. package/dist/index.js +8465 -5305
  8. package/dist/memory/embed-worker.js +132 -4
  9. package/dist/memory/image-embed-worker.js +14 -5
  10. package/dist/providers/mlx/python/cache_persist.py +52 -8
  11. package/dist/providers/mlx/python/gezel_mlx_server.py +44 -1
  12. package/dist/providers/mlx/python/qwen4_ple.py +159 -0
  13. package/dist/providers/mlx/python/spec_decode.py +73 -31
  14. package/dist/providers/mlx/python/tool_call_stream.py +10 -2
  15. package/dist/providers/mlx/python/tool_grammar.py +16 -0
  16. package/dist/ui/assets/{AmbientDashboardCard-DcVHxEdC.js → AmbientDashboardCard-_xnAQGnk.js} +1 -1
  17. package/dist/ui/assets/{AudioEngineSettings-BFM2S1mm.js → AudioEngineSettings-CgXgbX0i.js} +1 -1
  18. package/dist/ui/assets/{BenchmarksView-84-YeULA.js → BenchmarksView-BlExZpYA.js} +1 -1
  19. package/dist/ui/assets/CatalogBrowser-DYXUZQ_t.js +1 -0
  20. package/dist/ui/assets/{ChannelsSettings-7NAVUk4k.js → ChannelsSettings-EH27HcqZ.js} +1 -1
  21. package/dist/ui/assets/ChatTimelineView-Dn1TNyVn.js +7 -0
  22. package/dist/ui/assets/{ConnectedAppsPanel-CIgF4Q3R.js → ConnectedAppsPanel-BROry-Y0.js} +1 -1
  23. package/dist/ui/assets/CraftbookEditor-B2RNJnFf.js +1 -0
  24. package/dist/ui/assets/{CraftbookScriptEditorView-Ck5tzj3Y.js → CraftbookScriptEditorView-B-vySmHP.js} +1 -1
  25. package/dist/ui/assets/{CraftbookTabContent-BWg7FhK_.js → CraftbookTabContent-BW_2KC89.js} +1 -1
  26. package/dist/ui/assets/{CraftbookToolsetSetup-EuFOiUzR.js → CraftbookToolsetSetup-J7rEa835.js} +1 -1
  27. package/dist/ui/assets/{CraftbooksView-BIzQ1VVn.js → CraftbooksView-BjBUWPGF.js} +1 -1
  28. package/dist/ui/assets/DiffpackReviewView-CD4qJmgT.js +1 -0
  29. package/dist/ui/assets/DocumentDetail-SYozruTJ.js +1 -0
  30. package/dist/ui/assets/DocumentsView-DE7eL49Z.js +1 -0
  31. package/dist/ui/assets/{Ds4Settings-9soZCSeO.js → Ds4Settings-DGzc7JcD.js} +1 -1
  32. package/dist/ui/assets/{EmbeddedChat-Cce7nxXT.js → EmbeddedChat-D92TaJQ8.js} +1 -1
  33. package/dist/ui/assets/{FaceRecognitionCard-BVZyOwB8.js → FaceRecognitionCard-CB1Dt9X4.js} +1 -1
  34. package/dist/ui/assets/FileMapView-kVBG22FU.js +1 -0
  35. package/dist/ui/assets/FoldersSettings-BWFQU5B4.js +1 -0
  36. package/dist/ui/assets/GezelDetail-Br4v42Nv.js +1 -0
  37. package/dist/ui/assets/{GezelJsonEditor-DXXt165-.js → GezelJsonEditor-B9XEiW5Y.js} +1 -1
  38. package/dist/ui/assets/GezellenView-DheEBAy4.js +1 -0
  39. package/dist/ui/assets/{GildeUpdatesCard-CtY8mUTA.js → GildeUpdatesCard-BeIYv09f.js} +1 -1
  40. package/dist/ui/assets/{GithubSignInChip-DT3l6E0Q.js → GithubSignInChip-eEGCe9ar.js} +1 -1
  41. package/dist/ui/assets/{HandboekMediaProvider-ByJ4NAzz.js → HandboekMediaProvider-D0zcbbpf.js} +1 -1
  42. package/dist/ui/assets/HandboekView-p0BZT1rH.js +1 -0
  43. package/dist/ui/assets/{HistoryView-CkinzFEC.js → HistoryView-CKWcWW-Y.js} +1 -1
  44. package/dist/ui/assets/{HomeView-DNBrQnwy.js → HomeView-b_TT5oV3.js} +1 -1
  45. package/dist/ui/assets/{ImageEngineSettings-BfM9HSd_.js → ImageEngineSettings-CJfk4OJ4.js} +1 -1
  46. package/dist/ui/assets/{ImageRecognitionSettings-CaSQu5Br.js → ImageRecognitionSettings-DzbvZk5S.js} +1 -1
  47. package/dist/ui/assets/{IncompleteDownloads-C36lTCMG.js → IncompleteDownloads-C8_XyP8O.js} +1 -1
  48. package/dist/ui/assets/{KnowledgeCatalogsCard-CK9bqdf6.js → KnowledgeCatalogsCard-CHopG_j-.js} +1 -1
  49. package/dist/ui/assets/KnowledgeView-CXNKZUJq.js +1 -0
  50. package/dist/ui/assets/{LlamaCppSettings-CdNMHBbp.js → LlamaCppSettings-ohcM7kes.js} +1 -1
  51. package/dist/ui/assets/{MarkdownField-Dugmfr_e.js → MarkdownField-BX0qsaFq.js} +1 -1
  52. package/dist/ui/assets/{MemoriesTree-CgFqUNEr.js → MemoriesTree-BPj5Rod8.js} +1 -1
  53. package/dist/ui/assets/{MicrophoneSettings-DzDe9y1q.js → MicrophoneSettings-CWjeYnfI.js} +1 -1
  54. package/dist/ui/assets/MlxSettings-Dq6dRpcl.js +1 -0
  55. package/dist/ui/assets/{ModelPicker-BVkJhNAH.js → ModelPicker-0Ue-eEKj.js} +1 -1
  56. package/dist/ui/assets/NewPathDialog-BhAZm9dp.js +1 -0
  57. package/dist/ui/assets/{NewScriptDialog-TEAd0KLl.js → NewScriptDialog-DuryIe50.js} +1 -1
  58. package/dist/ui/assets/NewTaskDialog-BX24flMY.js +2 -0
  59. package/dist/ui/assets/{OllamaSettings-CPy2vxyZ.js → OllamaSettings-Boj8Nd1G.js} +1 -1
  60. package/dist/ui/assets/ProjectChat-Dhw_M5bq.js +5 -0
  61. package/dist/ui/assets/ProjectConnectionsTab-BwpMQNrg.js +1 -0
  62. package/dist/ui/assets/{ProjectGitStatusBar-BgHZ2ijN.js → ProjectGitStatusBar-BORGYx5l.js} +1 -1
  63. package/dist/ui/assets/{ProjectGithubView-BV2uTNU0.js → ProjectGithubView-CTP1BOMv.js} +1 -1
  64. package/dist/ui/assets/{ProjectMailTab-DLtJdXSL.js → ProjectMailTab-qFmAeV3M.js} +1 -1
  65. package/dist/ui/assets/{ProjectOverviewView-ZMs9nL5N.js → ProjectOverviewView-Cq1FsoaT.js} +1 -1
  66. package/dist/ui/assets/{ProjectTimeline-CTPcn4Kc.js → ProjectTimeline-Cqae2Z92.js} +1 -1
  67. package/dist/ui/assets/ProjectsView-D0uJjUB-.js +7 -0
  68. package/dist/ui/assets/{RecommendedBadge-iUoisQBi.js → RecommendedBadge-CN1jEmSn.js} +1 -1
  69. package/dist/ui/assets/{RemoteServersPanel-CTVJ0IRh.js → RemoteServersPanel-CMakvCCM.js} +1 -1
  70. package/dist/ui/assets/{ScriptEditorTabs-CCDFZjdC.js → ScriptEditorTabs-st6dJePd.js} +2 -2
  71. package/dist/ui/assets/{ScriptEditorView-CergLqKj.js → ScriptEditorView-BkySh57_.js} +2 -2
  72. package/dist/ui/assets/{ScriptsView-v7ckdhDi.js → ScriptsView-7uPKwjDB.js} +1 -1
  73. package/dist/ui/assets/{SecurityComplianceSettings-Bd0-66Gs.js → SecurityComplianceSettings-Tsv_pXfy.js} +1 -1
  74. package/dist/ui/assets/SessionSwitcher-D0fSeeHO.js +1 -0
  75. package/dist/ui/assets/SettingsView-cli_z8ZW.js +3 -0
  76. package/dist/ui/assets/{SquisqIntegration-C5l_OPvD.js → SquisqIntegration-BTZ1kBlg.js} +1 -1
  77. package/dist/ui/assets/{StorageCleanupDialog-3kv9-2mT.js → StorageCleanupDialog-CDBjl8JQ.js} +1 -1
  78. package/dist/ui/assets/{StorageUsageCard-7sWTrZFa.js → StorageUsageCard-DXY1j0dZ.js} +1 -1
  79. package/dist/ui/assets/TaskTabContent-C0P681SL.js +1 -0
  80. package/dist/ui/assets/TasksView-Ddwz10ri.js +1 -0
  81. package/dist/ui/assets/{TerminalCodeEditor-ChmdzmCz.js → TerminalCodeEditor-BkNQ6QoQ.js} +2 -2
  82. package/dist/ui/assets/ToolsetsEditor-KVigemfL.js +8 -0
  83. package/dist/ui/assets/{TransformToolbarButton-gzIxUBH7.js → TransformToolbarButton-8wfJR1bO.js} +2 -2
  84. package/dist/ui/assets/{UnrecognizedModels-0hptopv6.js → UnrecognizedModels-BzdU1clO.js} +1 -1
  85. package/dist/ui/assets/{VideoEngineSettings-BdNzCEdR.js → VideoEngineSettings-f79ff57u.js} +1 -1
  86. package/dist/ui/assets/{WorkspaceIndexPane-DnsOO916.js → WorkspaceIndexPane-fu5V6o1W.js} +1 -1
  87. package/dist/ui/assets/{api-C0I7spBl.js → api-CmrgM5Rf.js} +1 -1
  88. package/dist/ui/assets/chat-thread-memory-8MCtb17Q.js +1 -0
  89. package/dist/ui/assets/{chunk-6ECMNUIP-BvCy0HUI.js → chunk-6ECMNUIP-D5AA6ozp.js} +1 -1
  90. package/dist/ui/assets/{chunk-A6N6IN3I-ofeM4l8g.js → chunk-A6N6IN3I-BpxihS5H.js} +1 -1
  91. package/dist/ui/assets/{chunk-ATWVNF7D-CYuW1Yc6.js → chunk-ATWVNF7D-CKIWh7bN.js} +1 -1
  92. package/dist/ui/assets/{chunk-UBFT2CDQ-FexGDigd.js → chunk-CW24CH7I-BD0FIooX.js} +1 -1
  93. package/dist/ui/assets/{chunk-DXYWKZ52-zxe8pjH4.js → chunk-DXYWKZ52-DMKPZnpo.js} +1 -1
  94. package/dist/ui/assets/chunk-IIQYS2YH-BtDJt4Xr.js +1 -0
  95. package/dist/ui/assets/{chunk-KGWT454C-v5-l6U5m.js → chunk-KGWT454C-DsQOBuLg.js} +1 -1
  96. package/dist/ui/assets/{chunk-Q77KNJIN-BLuPdsQF.js → chunk-Q77KNJIN-BdWizq9s.js} +1 -1
  97. package/dist/ui/assets/{chunk-USU6HTKB-B_p-YcDp.js → chunk-USU6HTKB-DyGZplh4.js} +1 -1
  98. package/dist/ui/assets/{chunk-UXEANVBI-Bt0kX-0Z.js → chunk-UXEANVBI-BUBXvqyE.js} +1 -1
  99. package/dist/ui/assets/{chunk-O7JILDEF-CqcO1qaI.js → chunk-X7BNDUNI-D14WIvlD.js} +2 -2
  100. package/dist/ui/assets/{chunk-AE3IUKMM-mZjzzO8Z.js → chunk-ZSU5DJLX-CrjQf-vs.js} +1 -1
  101. package/dist/ui/assets/{container-BI8hxN1N.js → container-iFj1r6Hk.js} +1 -1
  102. package/dist/ui/assets/csv-Di411Mv-.js +1 -0
  103. package/dist/ui/assets/data-Q05qqAp4.js +1 -0
  104. package/dist/ui/assets/{dist-APSIK7H3.js → dist-1FNFiksd.js} +3 -3
  105. package/dist/ui/assets/dist-BMZhqfv7.js +2 -0
  106. package/dist/ui/assets/dist-CE5CbmDb.js +225 -0
  107. package/dist/ui/assets/doc-BHcGsJZd.js +587 -0
  108. package/dist/ui/assets/{document-import-DPK4r8Am.js → document-import-B2Ya6sbf.js} +1 -1
  109. package/dist/ui/assets/{docx-DRLuCTaC.js → docx-B8Pwz5Ih.js} +1 -1
  110. package/dist/ui/assets/{epub-a0p2Xb1b.js → epub-BQ4g8Q9j.js} +1 -1
  111. package/dist/ui/assets/{export-options-BqYFyzWx.js → export-options-Dylv69b3.js} +1 -1
  112. package/dist/ui/assets/file-browser-BLOPfnS0.js +5 -0
  113. package/dist/ui/assets/{html-BbQNmJ5X.js → html-BnA7qFwq.js} +1 -1
  114. package/dist/ui/assets/icons-CyM7Cg4E.js +1 -0
  115. package/dist/ui/assets/index-DW6qHqhU.css +1 -0
  116. package/dist/ui/assets/index-DivKnJyx.js +36 -0
  117. package/dist/ui/assets/{mail-link-CWfsP5Aq.js → mail-link-NtlcX5OE.js} +1 -1
  118. package/dist/ui/assets/{markdown-ryKA_OmY.js → markdown-CLKH_zzl.js} +1 -1
  119. package/dist/ui/assets/markdown-baseline-0dqv9qbV.js +1 -0
  120. package/dist/ui/assets/materialize-G4WC5UG3-xq2dcwS8.js +1 -0
  121. package/dist/ui/assets/{monaco-base-C0VTMpv-.js → monaco-base-BSvdAweA.js} +1 -1
  122. package/dist/ui/assets/{monaco-setup-CX8q88c5.js → monaco-setup-CT7LZ0o_.js} +1 -1
  123. package/dist/ui/assets/{new-project-meta-ZmDPGYzC.js → new-project-meta-5Y9Blozr.js} +1 -1
  124. package/dist/ui/assets/outside-in-Msmhxf_U.js +3 -0
  125. package/dist/ui/assets/{pdf-BHrygJa5.js → pdf-C4BhW3zg.js} +1 -1
  126. package/dist/ui/assets/{pending-drafts-27ujtQxX.js → pending-drafts-BD227X9H.js} +1 -1
  127. package/dist/ui/assets/{poppetje-CfaAvFkE.js → poppetje-DvCJO36y.js} +3 -3
  128. package/dist/ui/assets/{pptx-nDW64jAN.js → pptx-B6uaM2s7.js} +3 -3
  129. package/dist/ui/assets/{run-export-86KzLZ7R.js → run-export-TscWwR6y.js} +2 -2
  130. package/dist/ui/assets/{standalone-source-7QdiNsDW.js → standalone-source-Cw9SF7Zk.js} +1 -1
  131. package/dist/ui/assets/storage-Cmhlwx70.js +1 -0
  132. package/dist/ui/assets/styles-BjDaWeMA.css +1 -0
  133. package/dist/ui/assets/styles-CqO-rmOt.js +554 -0
  134. package/dist/ui/assets/{terminal-monaco-setup-Bar-sYKd.js → terminal-monaco-setup-me523-j-.js} +1 -1
  135. package/dist/ui/assets/{transform-CmAXy0Ck.js → transform-DxJCwK68.js} +1 -1
  136. package/dist/ui/assets/{use-local-model-manager-D1yiurrC.js → use-local-model-manager-8wvk-I-y.js} +1 -1
  137. package/dist/ui/assets/{useCompactLayout-BDtPQcDh.js → useCompactLayout-cm4E9Vja.js} +0 -0
  138. package/dist/ui/assets/{useCopilotAvailability-BHOfHrfT.js → useCopilotAvailability-D9hglSH_.js} +1 -1
  139. package/dist/ui/assets/{useDiffpacks-B0kYhlWQ.js → useDiffpacks-1BN2XJWg.js} +1 -1
  140. package/dist/ui/assets/{useGitSync-DOt-ODiw.js → useGitSync-7m9YA7h5.js} +1 -1
  141. package/dist/ui/assets/{useShowWorkInProgressFeatures-BtpredG7.js → useShowWorkInProgressFeatures-D6QOaTUT.js} +1 -1
  142. package/dist/ui/assets/{useTotalRamBytes-B8NFM27w.js → useTotalRamBytes-Durk383U.js} +1 -1
  143. package/dist/ui/assets/{xlsx-B_pu1ZvY.js → xlsx-BbHA9bxA.js} +1 -1
  144. package/dist/ui/index.html +15 -15
  145. package/package.json +12 -11
  146. package/dist/ui/assets/CatalogBrowser-7_jHy5Q3.js +0 -1
  147. package/dist/ui/assets/ChatTimelineView-Cg_kLK_U.js +0 -7
  148. package/dist/ui/assets/CraftbookEditor-BKAIsnXv.js +0 -1
  149. package/dist/ui/assets/DiffpackReviewView-B2a3zgE-.js +0 -1
  150. package/dist/ui/assets/DocumentDetail-GCYhwQqV.js +0 -1
  151. package/dist/ui/assets/DocumentsView-Cm3RaQ5N.js +0 -1
  152. package/dist/ui/assets/FileMapView-BKJovLcL.js +0 -1
  153. package/dist/ui/assets/FoldersSettings-CuJd2JdE.js +0 -1
  154. package/dist/ui/assets/GezelDetail-D_KIPDhQ.js +0 -1
  155. package/dist/ui/assets/GezellenView-BOOW1QQU.js +0 -1
  156. package/dist/ui/assets/HandboekView-gRzJcIbJ.js +0 -1
  157. package/dist/ui/assets/KnowledgeView-DJ3cJVHA.js +0 -1
  158. package/dist/ui/assets/MlxSettings-45mBFHbA.js +0 -1
  159. package/dist/ui/assets/NewTaskDialog-CIXVunZn.js +0 -2
  160. package/dist/ui/assets/ProjectChat-BiJRweob.js +0 -5
  161. package/dist/ui/assets/ProjectConnectionsTab-CQgaIzuv.js +0 -1
  162. package/dist/ui/assets/ProjectsView-BUdR76n6.js +0 -7
  163. package/dist/ui/assets/SessionSwitcher-BgZqyiRn.js +0 -1
  164. package/dist/ui/assets/SettingsView-DLhOYiR5.js +0 -3
  165. package/dist/ui/assets/TaskTabContent-CG2KmfwV.js +0 -1
  166. package/dist/ui/assets/TasksView-Dy5Ue4zS.js +0 -1
  167. package/dist/ui/assets/ToolsetsEditor-J9XxQ5Ms.js +0 -8
  168. package/dist/ui/assets/chat-thread-memory-CI2-giEq.js +0 -1
  169. package/dist/ui/assets/chunk-IIQYS2YH-DEkyBlHg.js +0 -1
  170. package/dist/ui/assets/csv-B0D9jJG2.js +0 -1
  171. package/dist/ui/assets/data-BIL84EaT.js +0 -1
  172. package/dist/ui/assets/dist-CJqyWK6E.js +0 -2
  173. package/dist/ui/assets/dist-DOqbRmFj.js +0 -225
  174. package/dist/ui/assets/doc-C2Ph2FWI.js +0 -584
  175. package/dist/ui/assets/document-companion-aDThLOwl.js +0 -1
  176. package/dist/ui/assets/file-browser-DVyWN0LD.js +0 -5
  177. package/dist/ui/assets/icons-DWaUNQbT.js +0 -1
  178. package/dist/ui/assets/index-DDu8nyO6.js +0 -34
  179. package/dist/ui/assets/index-DEDUSiCx.css +0 -1
  180. package/dist/ui/assets/markdown-baseline-9B52XlX2.js +0 -1
  181. package/dist/ui/assets/materialize-G4WC5UG3-BlZQe-88.js +0 -1
  182. package/dist/ui/assets/outside-in-BmIIeMid.js +0 -3
  183. package/dist/ui/assets/storage-B-vhjyV2.js +0 -1
  184. package/dist/ui/assets/styles-BvkZd-EV.js +0 -550
  185. package/dist/ui/assets/styles-IQ4adxWr.css +0 -1
@@ -0,0 +1,587 @@
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-X7BNDUNI-D14WIvlD.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 j,t as M,v as N,w as P,y as F}from"./chunk-GAZKTT4R-w1SNypWQ.js";import{C as I,D as L,E as ee,I as te,L as ne,M as re,P as R,R as ie,S as ae,T as oe,j as se,k as ce,n as le,w as ue,z as de}from"./chunk-CW24CH7I-BD0FIooX.js";import{i as fe,n as pe,r as me,t as he}from"./chunk-XRW6P7IF-BeQQgMVK.js";import{r as ge}from"./chunk-7ZAAICW4-BsCpYJH6.js";var _e=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 z(e){return Math.round(e*10)/10}function B(e){if(e.length===0)return``;let[t,...n]=e;return`${`M ${z(t[0])} ${z(t[1])}`} ${n.map(([e,t])=>`L ${z(e)} ${z(t)}`).join(` `)} Z`}function ve(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 ye(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 be(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 B([[a,n],[l,u],[t,u]]);case`right-triangle`:return B([[t,n],[t,u],[l,u]]);case`diamond`:return B([[a,n],[l,o],[a,u],[t,o]]);case`pentagon`:return B(ve(a,o,s,c,5,-Math.PI/2));case`hexagon`:{let e=r*.25;return B([[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 B([[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 B(ye(a,o,s,c,5,.4));case`star4`:return B(ye(a,o,s,c,4,.4));case`star6`:return B(ye(a,o,s,c,6,.5));case`parallelogram`:{let e=r*.25;return B([[t+e,n],[l,n],[l-e,u],[t,u]])}case`trapezoid`:{let e=r*.25;return B([[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 B([[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 B([[t,n],[l-e,n],[l,o],[l-e,u],[t,u],[t+e,o]])}case`arrow-right`:return xe(t,n,r,i,`right`);case`arrow-left`:return xe(t,n,r,i,`left`);case`arrow-up`:return xe(t,n,r,i,`up`);case`arrow-down`:return xe(t,n,r,i,`down`);case`double-arrow`:{let e=r*.3,a=i*.4,s=o-a/2,c=o+a/2;return B([[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 ${z(t)} ${z(n)} L ${z(l)} ${z(n)} L ${z(l)} ${z(e)} L ${z(a+r*.12)} ${z(e)} L ${z(a)} ${z(u)} L ${z(a-r*.02)} ${z(e)} L ${z(t)} ${z(e)} Z`}case`cylinder`:{let e=i*.16;return`M ${z(t)} ${z(n+e)} A ${z(s)} ${z(e)} 0 0 1 ${z(l)} ${z(n+e)} L ${z(l)} ${z(u-e)} A ${z(s)} ${z(e)} 0 0 1 ${z(t)} ${z(u-e)} Z M ${z(t)} ${z(n+e)} A ${z(s)} ${z(e)} 0 0 0 ${z(l)} ${z(n+e)}`}case`cloud`:{let e=i*.5;return`M ${z(t+r*.2)} ${z(u)} A ${z(r*.2)} ${z(e)} 0 0 1 ${z(t+r*.15)} ${z(o)} A ${z(r*.2)} ${z(e)} 0 0 1 ${z(t+r*.45)} ${z(n+i*.2)} A ${z(r*.2)} ${z(e)} 0 0 1 ${z(t+r*.8)} ${z(n+i*.25)} A ${z(r*.18)} ${z(e)} 0 0 1 ${z(t+r*.85)} ${z(u)} Z`}case`heart`:{let e=n+i*.3;return`M ${z(a)} ${z(u)} C ${z(t-r*.1)} ${z(o)} ${z(t)} ${z(n)} ${z(a)} ${z(e)} C ${z(l)} ${z(n)} ${z(l+r*.1)} ${z(o)} ${z(a)} ${z(u)} Z`}case`lightning`:return B([[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 xe(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 B(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 B(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 Se(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 Ce(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 we(e,t){return{start:Ce(e,t),end:Ce(t,e)}}function Te(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 Ee(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 De(e,t){let n=Te(e)[0],r=1/0;for(let i of Te(e)){let e=ke(i,t)+Ae(i.port);e<r&&(n=i,r=e)}return n}function Oe(e,t){let n=Te(e)[0],r=Te(t)[0],i=1/0;for(let a of Te(e))for(let e of Te(t)){let t=ke(a,e)+Ae(a.port)+Ae(e.port);t<i&&(n=a,r=e,i=t)}return{start:n,end:r}}function ke(e,t){let n=e.x-t.x,r=e.y-t.y;return n*n+r*r}function Ae(e){return e.includes(`-`)?.02:0}function je(e,t,n){if(e===`straight`)return`M ${z(t.x)} ${z(t.y)} L ${z(n.x)} ${z(n.y)}`;if(e===`orthogonal`){let e=Me(t.port),r=Me(n.port);if(e===`vertical`&&r===`vertical`){let e=(t.y+n.y)/2;return`M ${z(t.x)} ${z(t.y)} L ${z(t.x)} ${z(e)} L ${z(n.x)} ${z(e)} L ${z(n.x)} ${z(n.y)}`}if(e===`vertical`&&r===`horizontal`)return`M ${z(t.x)} ${z(t.y)} L ${z(t.x)} ${z(n.y)} L ${z(n.x)} ${z(n.y)}`;if(e===`horizontal`&&r===`vertical`)return`M ${z(t.x)} ${z(t.y)} L ${z(n.x)} ${z(t.y)} L ${z(n.x)} ${z(n.y)}`;let i=(t.x+n.x)/2;return`M ${z(t.x)} ${z(t.y)} L ${z(i)} ${z(t.y)} L ${z(i)} ${z(n.y)} L ${z(n.x)} ${z(n.y)}`}let r=Math.hypot(n.x-t.x,n.y-t.y),i=Math.max(40,r/2),a=Ne(t.port,{x:1,y:0}),o=Ne(n.port,{x:-1,y:0});return`M ${z(t.x)} ${z(t.y)} C ${z(t.x+a.x*i)} ${z(t.y+a.y*i)}, ${z(n.x+o.x*i)} ${z(n.y+o.y*i)}, ${z(n.x)} ${z(n.y)}`}function Me(e){return e===`top`||e===`bottom`?`vertical`:e===`left`||e===`right`?`horizontal`:null}function Ne(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 Pe(e){switch(e?.toLowerCase()){case`dashed`:case`dash`:return`8 6`;case`dotted`:case`dot`:return`2 6`;default:return}}var Fe=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;function Ie(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+=Fe[c>>>18&63],t+=Fe[c>>>12&63],t+=i?Fe[c>>>6&63]:`=`,t+=a?Fe[c&63]:`=`}return t}function Le(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=Fe.indexOf(t[e]),a=Fe.indexOf(t[e+1]),o=t[e+2]===`=`?0:Fe.indexOf(t[e+2]),s=t[e+3]===`=`?0:Fe.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 Re(e){return new TextDecoder().decode(Le(e))}function ze(e){return Array.from(e)}function Be(e){return ze(e).length}var Ve=new Set([`┌`,`╭`,`┏`,`╔`]),He=new Set([`┐`,`╮`,`┓`,`╗`]),Ue=new Set([`└`,`╰`,`┗`,`╚`]),We=new Set([`┘`,`╯`,`┛`,`╝`]),Ge=new Set([`─`,`━`,`═`,`-`]),Ke=new Set([`│`,`┃`,`║`,`|`]),qe=new Set([`├`,`┤`,`┬`,`┴`,`┼`,`┣`,`┫`,`┳`,`┻`,`╋`,`╠`,`╣`,`╦`,`╩`,`╬`,`╞`,`╡`,`╥`,`╨`,`╫`,`╪`]),Je=new Set([`├`,`┤`,`┼`,`┣`,`┫`,`╋`,`╠`,`╣`,`╬`,`╞`,`╡`,`╫`,`╪`]),Ye=new Set([`┬`,`┴`,`┼`,`┳`,`┻`,`╋`,`╦`,`╩`,`╬`,`╥`,`╨`,`╫`,`╪`]),Xe=new Set([`▲`,`↑`]),Ze=new Set([`▼`,`↓`]),Qe=new Set([`◄`,`←`,`◀`]),$e=new Set([`►`,`→`,`▶`]);function et(e){return Ve.has(e)}function tt(e){return He.has(e)}function nt(e){return Ue.has(e)}function rt(e){return We.has(e)}function it(e){return Ve.has(e)||He.has(e)||Ue.has(e)||We.has(e)}function at(e){return Ge.has(e)}function ot(e){return Ke.has(e)}function st(e){return qe.has(e)}function ct(e){return e===`+`}function lt(e){return at(e)||Ye.has(e)||ct(e)}function ut(e){return ot(e)||Je.has(e)||ct(e)}function V(e){return Xe.has(e)?`up`:Ze.has(e)?`down`:Qe.has(e)?`left`:$e.has(e)?`right`:null}function dt(e){return e===`^`?`up`:e===`v`||e===`V`?`down`:e===`<`?`left`:e===`>`?`right`:null}function ft(e){return at(e)||ot(e)||st(e)||ct(e)||it(e)}function pt(e){let t=e.codePointAt(0)??0;return t>=9472&&t<=9599||Xe.has(e)||Ze.has(e)||e===`←`||e===`→`||e===`◄`||e===`►`||e===`◀`||e===`▶`}function mt(e){return e===`+`||e===`-`||e===`|`}var ht={tl:`┌`,tr:`┐`,bl:`└`,br:`┘`,h:`─`,v:`│`,stemDown:`┬`,stemUp:`┴`,stemLeft:`┤`,stemRight:`├`,cross:`┼`,arrowUp:`▲`,arrowDown:`▼`,arrowLeft:`◄`,arrowRight:`►`,turnDownRight:`┌`,turnDownLeft:`┐`,turnUpRight:`└`,turnUpLeft:`┘`},gt={tl:`+`,tr:`+`,bl:`+`,br:`+`,h:`-`,v:`|`,stemDown:`+`,stemUp:`+`,stemLeft:`+`,stemRight:`+`,cross:`+`,arrowUp:`^`,arrowDown:`v`,arrowLeft:`<`,arrowRight:`>`,turnDownRight:`+`,turnDownLeft:`+`,turnUpRight:`+`,turnUpLeft:`+`},_t=60,vt=10,yt=3,bt=10,xt=new Set([`┼`,`╋`,`╬`,`╫`,`╪`]);function St(e){return Ct(e).diagram}function Ct(e){let t=[],n=wt(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&&Tt(r)&&(o=!0)}o&&t.push(`wide-chars`);let s=Et(n),c=Lt(n,Dt(n),t),l=c.length,u=Kt(n,c);for(let e of u)c.push(e);let d=u.length;d>0&&t.push(`rail-labels(${d})`);let f=new Uint8Array(i*r),p=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]){f[r*i+n]=1;let t=p.get(r*i+n)??[];t.push(e),p.set(r*i+n,t)}for(let n=t.r0+1;n<=t.r1-1;n++)for(let r of[t.c0,t.c1]){f[n*i+r]=1;let t=p.get(n*i+r)??[];t.push(e),p.set(n*i+r,t)}}let m=c.map((e,t)=>c.some(e=>e.parentIdx===t));for(let e=0;e<c.length;e++){let t=c[e];if(m[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!==` `&&!ft(t)&&V(t)===null&&(f[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++)f[e*i+n]=1}let{edges:h,edgeCells:g}=qt(n,f,p,c,t),_=0,v=[];for(let e=0;e<r;e++){let t=``,r=()=>{t.trim().length>0&&v.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]!==` `&&!f[r]&&!g.has(r)};for(let o=0;o<i;o++)a(o)?(t+=n[e][o],_++):t!==``&&n[e][o]===` `&&a(o+1)?t+=` `:r();r()}for(let e of v.slice(0,vt))t.push(`loose-text ${e}`);return v.length>vt&&t.push(`loose-text (+${v.length-vt} more)`),{diagram:{nodes:c.map(e=>{let t=e.emit??e;return{id:e.id,label:e.labelLines.join(`
2
+ `),col:t.c0,row:t.r0,wCols:t.c1-t.c0+1,hRows:t.r1-t.r0+1,...e.parentIdx>=0?{containerId:c[e.parentIdx].id}:{}}}).sort((e,t)=>e.row-t.row||e.col-t.col),edges:h,style:s,warnings:t},stats:{totalNonSpaceCells:a,looseNonSpaceCells:_,hasWideChars:o,boxNodes:l,railNodes:d}}}function wt(e,t){let n=e.replace(/\r\n?/g,`
3
+ `).split(`
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 Tt(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 Et(e){let t=0,n=0;for(let r of e)for(let e of r)pt(e)?t++:mt(e)&&n++;return n>t?`ascii`:`unicode`}function Dt(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(!kt(e,a,n))continue;let r=At(e,a,n,t);r&&i.push(r)}return i}function Ot(e){return wt(e,[])}function kt(e,t,n){let r=e[t][n];if(et(r))return!0;if(!ct(r)&&!st(r))return!1;let i=e[t][n+1]??` `,a=e[t+1]?.[n]??` `,o=lt(i)||tt(i),s=ut(a)||nt(a);return o&&s}function At(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(tt(n)){if(o.push(r),ut(e[t+1]?.[r]??` `))break;continue}(ct(n)||st(n))&&o.push(r)}if(o.length===0)return null;let s=Nt(e,n,t,i,nt,r);if(s.length===0)return null;let c=new Set(s);for(let a of o){if(a<n+2)continue;let o=jt(e[t],n,a);if(!o.ok)continue;let s=Nt(e,a,t,i,rt,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(!lt(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++)Mt(e[r],n,l)&&u++,Mt(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 jt(e,t,n){let r=e=>lt(e)||V(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>_t)return{ok:!1};let o=e.slice(i,a+1).join(``).trim();return o.length>0?{ok:!0,title:o}:{ok:!0}}function Mt(e,t,n){for(let r=t-n;r<=t+n;r++){let t=e[r];if(t!==void 0&&ut(t))return!0}return!1}function Nt(e,t,n,r,i,a=!1){let o=[],s=a?bt:yt,c=0;for(let l=n+1;l<r;l++){let n=e[l][t];if(i(n)){o.push(l);break}if(ct(n)||st(n)){o.push(l),c=0;continue}if(ut(n)){c=0;continue}if(!a&&(ft(n)||V(n)!==null)||++c>s)break}return o}function Pt(e,t){return e.r0<t.r0&&e.c0<t.c0&&e.r1>t.r1&&e.c1>t.c1}function Ft(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 It(e){return(e.r1-e.r0+1)*(e.c1-e.c0+1)}function Lt(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||!Pt(r[a],e))continue;let o=It(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(Ft(r[e],r[t])&&!Pt(r[e],r[t])&&!Pt(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=>ft(e)||V(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(Rt(r))continue;let i=r.trim();i.length>0&&a.push(i)}let c=zt(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 Rt(e){if(e.length===0||e!==e.trim())return!1;let t=!1;for(let n of e)if(n!==` `){if(at(n)||st(n)||ct(n)){t=!0;continue}return!1}return t}function zt(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`node`}var Bt=3,Vt=1,Ht=2,Ut=3,Wt=2;function Gt(e,t,n){if(n){let n=e.r0*Ut,r=e.c0*Wt;return{r0:n,c0:r,r1:n+Math.max(3,t+2)-1,c1:r+Math.max(3,e.c1-e.c0+1+4)-1}}let r=Math.max(0,e.r0-Vt),i=Math.max(0,e.c0-Vt);return{r0:r,c0:i,r1:r+(e.r1-e.r0)+2*Vt,c1:i+(e.c1-e.c0)+2*Vt}}function Kt(e,t){let n=e.length,r=n>0?e[0].length:0;if(n===0||r===0)return[];let i=new Uint8Array(r*n);for(let e of t)for(let t=Math.max(0,e.r0);t<=Math.min(n-1,e.r1);t++)for(let n=Math.max(0,e.c0);n<=Math.min(r-1,e.c1);n++)i[t*r+n]=1;let a=(t,i)=>t>=0&&t<n&&i>=0&&i<r?e[t][i]:` `,o=e=>ft(e)||st(e)||ct(e)||it(e),s=e=>{let t=V(e);return o(e)||t===`up`||t===`down`},c=e=>{let t=V(e);return o(e)||t===`left`||t===`right`},l=[];for(let t=0;t<n;t++){let n=!1,i=!0;for(let a=0;a<r&&i;a++){let r=e[t][a];r!==` `&&(n=!0,!ft(r)&&V(r)===null&&(i=!1))}l.push(n&&i)}let u=(t,n)=>{let r=a(t,n);if(r===` `)return!1;if(V(r)!==null)return!0;let i=dt(r);if(i!==null&&Xt(e,t,n,i))return!0;if(!ft(r))return!1;if(l[t])return!0;let o=s(a(t-1,n))||s(a(t+1,n));if(ot(r))return o;let u=c(a(t,n-1))||c(a(t,n+1));return at(r)?u:o||u},d=(t,n)=>n>=0&&n<r&&e[t][n]!==` `&&!i[t*r+n]&&!u(t,n),f=[];for(let t=0;t<n;t++){let n=-1,i=-1,a=()=>{if(n>=0){let r=e[t].slice(n,i+1).join(``).trim();r.length>0&&f.push({row:t,c0:n,c1:i,text:r})}n=-1};for(let o=0;o<r;o++)if(d(t,o))n<0&&(n=o),i=o;else if(n>=0&&e[t][o]===` `&&d(t,o+1))continue;else a();a()}let p=e=>[-1,1].some(t=>{for(let n=1;n<=Bt;n++){let r=t<0?e.c0-n:e.c1+n;if(a(e.row,r)!==` `)return u(e.row,r)}return!1}),m=e=>t.some(t=>e.row>=t.r0&&e.row<=t.r1&&e.c0<=t.c1+Ht&&e.c1>=t.c0-Ht),h=f.filter(e=>/[a-z0-9]/i.test(e.text)&&!p(e)&&!m(e)),g=[],_=[];for(let e=0;e<n;e++){let t=h.filter(t=>t.row===e),n=[];for(let r of t){let t=_.find(t=>{let n=t[t.length-1];return n.row===e-1&&n.c0<=r.c1&&r.c0<=n.c1});if(t)t.push(r),n.push(t);else{let e=[r];g.push(e),n.push(e)}}_=n}let v=(t,a)=>{if(t<0||t>=n||i[t*r+a]===1||!u(t,a))return!1;let o=e[t][a],s=V(o)??dt(o);return ot(o)||st(o)||ct(o)||s===`up`||s===`down`},y=e=>e.some(e=>[e.row-1,e.row+1].some(t=>{for(let n=Math.max(0,e.c0-1);n<=Math.min(r-1,e.c1+1);n++)if(v(t,n))return!0;return!1})),b=new Map;for(let e of t)b.set(e.id,(b.get(e.id)??0)+1);let x=[];for(let e of g){if(!y(e))continue;let n=e.map(e=>e.text),r=e[0].row,i=e[e.length-1].row,a=Math.min(...e.map(e=>e.c0)),o=Math.max(...e.map(e=>e.c1)),s=zt(n[0]),c=b.get(s)??0;b.set(s,c+1),x.push({r0:r,c0:a,r1:i,c1:o,parentIdx:-1,labelLines:n,id:c===0?s:`${s}-${c+1}`,emit:Gt({r0:r,c0:a,r1:i,c1:o},n.length,t.length===0)})}return x}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=V(a);if(c){s.set(i,{arrow:c});continue}let l=dt(a);if(l&&Xt(e,n,r,l)){s.set(i,{arrow:l});continue}ft(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)||!at(e[n][r])){r++;continue}let a=r;for(;a+1<o&&s.has(n*o+a+1)&&at(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(at(r)){if(Jt(e,t,n,c,o))break;for(;c<o&&at(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&&at(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=>xt.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(!(!st(i)&&!ct(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})}if(d.size<2)for(let t of c){let n=Math.floor(t/o),r=t%o,i=e[n][r],a=ot(i)?[[-1,0],[1,0]]:at(i)?[[0,-1],[0,1]]:[];for(let[e,t]of a){let i=v(n+e,r+t);i!==null&&!d.has(i)&&d.set(i,{boxIdx:i,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=>ft(e)&&e!==`-`||V(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(ot(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&&at(e[n][a])&&!t[n*i+a];)a++;if(a>=i||t[n*i+a])return!0;let o=e[n][a];if(ft(o)||V(o)!==null)return!0;let s=dt(o);return s!==null&&Xt(e,n,a,s)}function Yt(e,t,n){let r=e[t][n];if(V(r)!==null)return!0;let i=dt(r);if(i!==null&&Xt(e,t,n,i))return!0;if(!ft(r))return!1;let a=e=>e!==void 0&&(ft(e)||V(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`?ot(i):at(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=/^[\s\u2500-\u257F+\-|^v<>\u25B2\u25BC\u25C0\u25B6\u25C4\u25BA\u2190\u2192\u2191\u2193]+$/,sn=/[│┃║┌┐└┘├┤┬┴┼╭╮╰╯┏┓┗┛╔╗╚╝┣┫┳┻╋╠╣╦╩╬╞╡╥╨╫╪]/;function cn(e){if(e==null)return!0;let t=e.trim().toLowerCase();return t===``||en.has(t)}function ln(e){return typeof e==`string`&&e.trim().toLowerCase()===`diagram`}function un(e,t={}){let n=t.explicit===!0,r=[],i=e.replace(/\r\n?/g,`
5
+ `).split(`
6
+ `);if(i.length<rn)return{isDiagram:!1,reasons:[`too-few-lines(${i.length})`]};if(i.length>tn)return{isDiagram:!1,reasons:[`too-many-lines(${i.length})`]};let a=0;for(let e of i)a=Math.max(a,e.length);if(a>nn)return{isDiagram:!1,reasons:[`too-wide(${a})`]};if(!n){let e=0;for(let t of i){let n=t.match(/[┌╭┏╔]|[├┬┼┣┳╋╠╦╬][─━═]/gu);e+=n?n.length:0;let r=t.match(/\+[-+]/g);e+=r?r.length:0}let t=i.filter(e=>e.trim().length>0&&on.test(e)).length;if(e<2&&t<2)return{isDiagram:!1,reasons:[`too-few-corner-candidates(${e}) routing-rows(${t})`]}}let o=i.filter(e=>e.trim().length>0),s=o.filter(e=>/^\s*\|.*\|\s*$/.test(e)).length,c=o.some(e=>/^\s*\|?[\s:|-]+\|?\s*$/.test(e)&&e.includes(`-`));if(s>o.length/2&&c)return{isDiagram:!1,reasons:[`markdown-table`]};let{diagram:l,stats:u}=Ct(e),d=n?1:2;if(l.nodes.length<d)return{isDiagram:!1,reasons:[`too-few-boxes(${l.nodes.length})`]};let f=l.nodes.filter(e=>sn.test(e.label)).length;if(f>0&&f>=l.nodes.length*.25)return{isDiagram:!1,reasons:[`garbled-labels(${f}/${l.nodes.length})`]};if(!n){if(u.boxNodes===0&&l.edges.length===0)return{isDiagram:!1,reasons:[`rail-labels-unconnected(${u.railNodes})`]};if(l.edges.length===0&&l.nodes.length>=4&&fn(l))return{isDiagram:!1,reasons:[`table-lattice`]};if(u.totalNonSpaceCells>0){let e=u.looseNonSpaceCells/u.totalNonSpaceCells;if(e>an)return{isDiagram:!1,reasons:[`loose-ratio(${e.toFixed(2)})`]}}}return r.push(`boxes(${l.nodes.length})`,`edges(${l.edges.length})`),n&&r.push(`explicit`),{isDiagram:!0,diagram:l,reasons:r}}function dn(e){return e.type!==`code`||!cn(e.lang)?!1:un(e.value,{explicit:ln(e.lang)}).isDiagram}function fn(e){let t=e.nodes.filter(e=>!e.containerId);if(t.length<4)return!1;let n=new Set(t.map(e=>e.row)),r=new Set(t.map(e=>e.col));return n.size<2||r.size<2?!1:t.every(e=>t.some(t=>{if(e===t)return!1;let n=e.row+e.hRows-1,r=e.col+e.wCols-1,i=t.row+t.hRows-1,a=t.col+t.wCols-1;return e.row===i||n===t.row||e.col===a||r===t.col}))}var pn=/[─━═-]{6,}/gu,mn=/[─━═│|►◄→←┌┐└┘├┤]/u,hn=/[►◄→←]/u,gn=/[◄←]/u,_n=/[►→]/u,vn=/^[\s─━═│|►◄→←┌┐└┘├┤]+$/u,yn=/^[A-Z][A-Z0-9 _/-]*(?:\s+\([^)]*\))?$/u;function bn(e){let t=e.replace(/\r\n?/g,`
7
+ `).split(`
8
+ `),n=Sn(t);if(!n||n.tracks.length<2)return null;let r=[],i=[],a=new Set,o=new Map,s=null,c=null,l=null,u=0,d=!1,f=!1,p=!1,m=!1,h=e=>{let t=On(e.text),n={id:An(t,a),label:t,trackIndex:e.trackIndex,order:r.length};return r.push(n),n},g=(e,t,n)=>{!e||!t||e===t||i.some(r=>r.source===e&&r.target===t&&r.label===n)||i.push({source:e,target:t,...n?{label:n}:{}})};for(let e=n.underlineRow+1;e<t.length;e++){let i=t[e];if(!i.trim())continue;if(vn.test(i)){p||=i.includes(`┐`),m||=i.includes(`┘`);continue}if(i.trim().startsWith(`(`)&&!hn.test(i)){let e=Tn(n.tracks,En(i)),t=o.get(e);if(!t)return null;s={eventId:t,text:On(i.replace(/[│|]+\s*$/u,``))};continue}let a=i,_=null;if(s){let e=Dn(a);if(e<0)return null;let t=On(Array.from(a).slice(0,e).join(``)),n=r.find(e=>e.id===s?.eventId);if(!n)return null;n.description=On(`${s.text} ${t}`),_=n.id,a=`${` `.repeat(e)}${Array.from(a).slice(e).join(``)}`,s=null}let v=wn(a,n.tracks);if(v.length===0||v.some(e=>!/[\p{L}\p{N}]/u.test(e.text)))return null;let y=new Map(o),b=v.map(h),x=[];for(let e=0;e<v.length-1;e++){let t=Array.from(a).slice(v[e].end+1,v[e+1].start).join(``),n=gn.test(t)?`left`:_n.test(t)?`right`:null;x.push(n),n&&u++,d||=n===`left`,f||=n===`right`,n===`left`&&g(b[e+1].id,b[e].id),n===`right`&&g(b[e].id,b[e+1].id)}let S=/^[\s│|]*[├└]/u.exec(i)?.[0]??``;S?(c||=y.get(b[0].trackIndex)??null,g(c??void 0,b[0].id),S.includes(`└`)&&(c=null)):c=null;let C=x.length>0&&x.every(e=>e===`left`),w=C?[...b].reverse():b,T=w[0];!S&&!i.includes(`┘`)&&g(y.get(T.trackIndex),T.id),_&&g(w[w.length-1]?.id,_);for(let e of w)o.set(e.trackIndex,e.id);if(i.includes(`┐`)&&(p=!0,l=b[b.length-1]?.id??null),i.includes(`┘`)){m=!0;let e=C?b[0]?.id:b[b.length-1]?.id;g(l??void 0,e)}}if(s||r.length<6||u<4||!d||!f||!p||!m||!jn(r,i))return null;let _=Mn(r,i),v=Math.max(10,..._.values()),y=n.tracks.map((e,t)=>{let n=r.filter(e=>e.trackIndex===t).sort((e,t)=>(_.get(e.id)??0)-(_.get(t.id)??0)||e.order-t.order),i=-1,a=n.map((e,t)=>{let n=_.get(e.id)??t*10,r=Math.max(i+1,n);return i=r,{id:e.id,label:e.label,...e.description?{description:e.description}:{},column:r,side:t%2==0?`above`:`below`,marker:`filled`}});return{id:e.id,label:e.label,row:e.row,startColumn:0,endColumn:v,events:a}}),b=Math.max(0,...t.map(e=>Array.from(e).length));return i.sort((e,t)=>e.source.localeCompare(t.source)||e.target.localeCompare(t.target)||(e.label??``).localeCompare(t.label??``)),{tracks:y,links:i,width:b,height:t.length,style:`unicode`,warnings:[]}}function xn(e){return bn(e)!==null}function Sn(e){for(let t=1;t<Math.min(e.length,5);t++){let n=Array.from(e[t].matchAll(pn)).map(e=>({start:e.index,end:(e.index??0)+Array.from(e[0]).length-1}));if(n.length<2)continue;let r=Cn(e[t-1]);if(!(r.length!==n.length||r.some(e=>!yn.test(e.text))))return{tracks:n.map((e,n)=>{let i=r[n];return{id:kn(i.text.replace(/\s+\([^)]*\)\s*$/u,``).trim()),label:i.text,row:t-1,start:e.start,end:e.end}}),underlineRow:t}}return null}function Cn(e){let t=Array.from(e),n=[],r=-1,i=0;for(let e=0;e<=t.length;e++){let a=t[e];if(a===` `){if(i++,r>=0&&i>=3){let a=e-i,o=t.slice(r,a+1).join(``).trim();o&&n.push({text:o,start:r,end:a}),r=-1}continue}if(i=0,a!==void 0&&r<0&&(r=e),a===void 0&&r>=0){let e=t.slice(r).join(``).trim();e&&n.push({text:e,start:r,end:t.length-1})}}return n}function wn(e,t){let n=Array.from(e),r=[],i=-1;for(let e=0;e<=n.length;e++){let a=e===n.length||mn.test(n[e]??``);if(!a&&i<0&&(i=e),!a||i<0)continue;let o=n.slice(i,e).join(``),s=o.length-o.trimStart().length,c=On(o);if(c){let e=i+s,n=e+Array.from(c).length-1;r.push({text:c,start:e,end:n,trackIndex:Tn(t,e)})}i=-1}return r}function Tn(e,t){for(let n=1;n<e.length;n++)if(t<e[n].start)return n-1;return e.length-1}function En(e){let t=Array.from(e).findIndex(e=>/[\p{L}\p{N}(]/u.test(e));return Math.max(0,t)}function Dn(e){return Array.from(e).findIndex(e=>hn.test(e))}function On(e){return e.normalize(`NFC`).replace(/^[\s:]+|[\s:]+$/gu,``).replace(/\s+/gu,` `).trim()}function kn(e){return e.normalize(`NFC`).toLowerCase().replace(/[^a-z0-9_.~-]+/gu,`-`).replace(/^-+|-+$/gu,``)||`event`}function An(e,t){let n=kn(e);if(!t.has(n))return t.add(n),n;let r=2;for(;t.has(`${n}-${r}`);)r++;let i=`${n}-${r}`;return t.add(i),i}function jn(e,t){let n=new Map(e.map(e=>[e.id,e.trackIndex]));return t.some(e=>n.get(e.source)!==n.get(e.target))}function Mn(e,t){let n=new Map,r=new Map(e.map(e=>[e.id,0]));for(let e of t)n.set(e.source,[...n.get(e.source)??[],e.target]),r.set(e.target,(r.get(e.target)??0)+1);let i=new Map(e.map(e=>[e.id,0])),a=e.filter(e=>r.get(e.id)===0).map(e=>e.id),o=0;for(;a.length>0;){let e=a.shift();o++;for(let t of n.get(e)??[]){i.set(t,Math.max(i.get(t)??0,(i.get(e)??0)+1));let n=(r.get(t)??1)-1;r.set(t,n),n===0&&a.push(t)}}if(o<e.length)for(let t of e)i.set(t.id,t.order);return new Map(Array.from(i,([e,t])=>[e,t*10]))}var Nn=new Set([`●`,`○`,`◉`,`◆`,`◇`,`•`]),Pn=new Set([`*`,`o`,`O`]),Fn=new Set([`─`,`━`,`═`,`╌`,`╍`,`┄`,`┅`,`┈`,`┉`,`-`]),In=new Set([`►`,`▶`,`▷`,`→`,`>`]),Ln=new Set([`▲`,`△`,`▼`,`▽`,`^`,`v`]),Rn=new Set([`└`,`┌`,`├`,`┬`,`┘`,`┐`,`╰`,`╭`,`╯`,`╮`]);function zn(e){return Bn(e).timeline}function Bn(e){let t=e.replace(/\r\n?/g,`
9
+ `).split(`
10
+ `),n=Math.max(0,...t.map(e=>Array.from(e).length)),r=bn(e);if(r){let t=r.tracks.reduce((e,t)=>e+t.events.length,0);return{timeline:r,stats:{axisLines:r.tracks.length,markerCount:t,strongMarkerCount:t,horizontalChars:Array.from(e).filter(e=>Fn.has(e)).length,pointerCount:0,branchDeclarations:r.links.length,wrappedFlow:!0}}}let i=mr(t),a=[],o=[];for(let e=0;e<t.length;e++){let n=Xn(t[e]);if(n){a.push(n);continue}let r=Hn(t[e],e,i);if(r){o.push(r);continue}let s=Un(t[e],e);s&&o.push(s)}let s=o.map((e,t)=>({id:e.id??fr(e.label||`track-${t+1}`),...e.label?{label:e.label}:{},...e.endLabel?{endLabel:e.endLabel}:{},row:e.row,startColumn:e.startColumn,endColumn:e.endColumn,events:e.markerColumns.map((t,n)=>{let r=e.inline[n];return{id:r.id??``,label:r.label??``,...r.description?{description:r.description}:{},column:r.column??t,...r.side?{side:r.side}:{},...r.descriptionSide?{descriptionSide:r.descriptionSide}:{},...r.callout===!1?{callout:!1}:{},marker:or(e.markerGlyphs[n])}})}));for(let e=0;e<o.length;e++){let n=o[e],r=s[e],i=ar(t,n.row-1);if(i>=0&&!o.some(e=>e.row===i)){let e=Zn(t[i]),n=r.events.filter(e=>!e.label),a=Vn(e,n);if(a){for(let e=0;e<n.length;e++)n[e].label=ur(a[e].text),n[e].side=`above`;let t=e.indexOf(a[0]),i=t>0?e[t-1]:void 0;i?.text.trim().endsWith(`:`)&&(r.label=dr(i.text),r.id=fr(r.label))}for(let t of r.events){if(t.label)continue;let n=ir(r.events,t.column),i=Math.max(3,Math.min(8,n*.38)),a=rr(e,t.column,i);a&&(t.label=ur(a.text),t.side=`above`)}}}let c=0;for(let e=0;e<t.length;e++){if(o.some(t=>t.row===e))continue;let n=Array.from(t[e]),r=n.map((e,t)=>({char:e,column:t})).filter(({column:e})=>er(n,e)).map(({column:e})=>e);for(let t=0;t<r.length;t++){let i=r[t],a=tr(s,e,i)??$n(s,e,i);if(!a)continue;c++;let o=r[t+1]??n.length,l=ur(n.slice(i+1,o).join(``)),u=t===0?ur(n.slice(0,i).join(``)):``,d=/\{[^{}]*#[^{}\s]+[^{}]*\}\s*$/u.test(l)?Wn(l):{label:l||void 0},f=dr(u)||d.label||l||`Event ${a.events.length+1}`,p=u&&l?l:d.description,m=d.side??(e<a.row?`above`:`below`),h=a.events.find(e=>!e.id&&Math.abs(e.column-i)<=1)??a.events.find(e=>e.callout!==!1&&Math.abs(e.column-i)<=1);h?(d.id&&(h.id=d.id),d.column!==void 0&&(h.column=d.column),h.label||=f,d.label&&(h.label=d.label),p&&!h.description&&(h.description=p),d.description&&(h.description=d.description),d.descriptionSide?h.descriptionSide=d.descriptionSide:p&&!d.id&&(h.descriptionSide??=m),d.callout!==void 0&&(h.callout=d.callout),h.side=m):a.events.push({id:d.id??``,label:f,...p?{description:p}:{},column:d.column??i,side:m,...d.descriptionSide?{descriptionSide:d.descriptionSide}:p&&!d.id?{descriptionSide:m}:{},...d.callout===void 0?{}:{callout:d.callout},marker:`hollow`})}}for(let e=0;e<t.length;e++){if(o.some(t=>t.row===e))continue;let n=Qn(t[e]),r=n.length>0?ur(Array.from(t[e]).slice(0,n[0].start).join(``)):``;for(let t=0;t<n.length;t++){let i=n[t],a=$n(s,e,i.start);if(!a||a.events.length===0)continue;let o=nr(a.events,i.start);if(!o)continue;let c=ur(i.text),l=t===0&&r?`${r} ${c}`:c;if(!(!l||l===o.label)){if(o.callout===!1){o.callout=!0,o.label=l,o.side=e<a.row?`above`:`below`;continue}o.description=o.description?`${o.description} ${l}`:l,o.descriptionSide??=e<a.row?`above`:`below`,o.side??=e<a.row?`above`:`below`}}}let l=[],u=new Map;for(let e of s)e.id=pr(e.id,u);let d=new Map;for(let e of s){e.events.sort((e,t)=>e.column-t.column);for(let t=0;t<e.events.length;t++){let n=e.events[t];n.label||(n.label=`Event ${t+1}`,l.push(`unlabeled-event(${e.id}:${n.column})`)),n.id=pr(n.id||fr(n.label),d),n.side??=t%2==0?`above`:`below`}}let f=new Set(s.flatMap(e=>e.events.map(e=>e.id))),p=new Map;for(let e of s)for(let t of e.events)p.set(fr(t.label),t.id),p.set(t.id,t.id);let m=[];for(let e of a){let t=p.get(fr(e.source))??e.source,n=p.get(fr(e.target))??e.target;if(!f.has(t)||!f.has(n)){l.push(`unresolved-link(${e.source}->${e.target})`);continue}m.push({source:t,target:n,...e.label?{label:e.label}:{}})}let h={axisLines:o.length,markerCount:o.reduce((e,t)=>e+t.markerColumns.length,0),strongMarkerCount:o.reduce((e,t)=>e+t.strongMarkerCount,0),horizontalChars:o.reduce((e,t)=>e+t.horizontalChars,0),pointerCount:c,branchDeclarations:a.length,wrappedFlow:!1};return{timeline:{tracks:s,links:m,width:n,height:t.length,style:i,warnings:l},stats:h}}function Vn(e,t){if(t.length<2||e.length<t.length)return;let n=e.slice(-t.length);if(n.some(e=>lr(e.text).length>40))return;let r=n.map((e,n)=>(e.start+e.end)/2-t[n].column);return Math.max(...r)-Math.min(...r)<=3?[...n]:void 0}function Hn(e,t,n){let r=Array.from(e),i=[],a=[],o=0,s=0;for(let e=0;e<r.length;e++){let t=r[e];Fn.has(t)&&o++,sr(r,e,n)&&(i.push(e),a.push(t),Nn.has(t)&&s++)}if(i.length===0||o<2)return null;let c=i[0],l=r.slice(0,c).lastIndexOf(`:`),u;if(l>=0)for(u=l+1;r[u]===` `;)u++;else{let e=c-1;for(;e>=0&&(Fn.has(r[e])||r[e]===` `);)e--;for(u=e+1;r[u]===` `;)u++}let d=i[i.length-1],f=d+1,p=r.findIndex((e,t)=>t>=f&&In.has(e)&&Jn(r,t,e===`>`?3:2)),m;if(p>=0)d=p,m=p;else{let e=Yn(r);d=Math.max(d,e),m=d+1}let h=Gn(dr(r.slice(0,u).join(``).trim())),g=ur(r.slice(d+1).join(``)),_=h.label,v=i.map((e,t)=>{let n=t+1<i.length?i[t+1]:m;return Wn(r.slice(e+1,n).join(``))});return{row:t,...h.id?{id:h.id}:{},startColumn:h.startColumn??u,endColumn:h.endColumn??Math.max(d,u+1),markerColumns:i,markerGlyphs:a,inline:v,..._?{label:_}:{},...g?{endLabel:g}:{},horizontalChars:o,strongMarkerCount:s}}function Un(e,t){let n=Array.from(e),r=n.indexOf(`:`);if(r<0)return null;let i=n.slice(0,r).join(``).trim();if(!i)return null;let a=[],o=r+1;for(;o<n.length;){for(;o<n.length&&/\s/u.test(n[o]);)o++;if(o>=n.length)break;let e=o;for(;o<n.length&&!/\s/u.test(n[o]);)o++;a.push({value:n.slice(e,o).join(``),column:e})}return a.length<4||a[0].value.length!==1||a.some(e=>e.value!==a[0].value)?null:{row:t,startColumn:a[0].column,endColumn:a[a.length-1].column,markerColumns:a.map(e=>e.column),markerGlyphs:a.map(()=>`○`),inline:a.map((e,t)=>({label:e.value,id:`${fr(i)}-${t+1}`,column:e.column,callout:!1})),label:i,horizontalChars:0,strongMarkerCount:0}}function Wn(e){let t=qn(e).replace(/\s+/g,` `).trim();if(!t)return{};let n,r,i,a,o,s=/\{([^{}]+)\}\s*$/.exec(t);if(s){let e=!1;for(let t of s[1].trim().split(/\s+/))if(t.startsWith(`#`)&&t.length>1)n=t.slice(1),e=!0;else if(t===`side=above`)i=`above`,e=!0;else if(t===`side=below`)i=`below`,e=!0;else if(t===`descriptionSide=above`)a=`above`,e=!0;else if(t===`descriptionSide=below`)a=`below`,e=!0;else if(t.startsWith(`column=`)){let n=Kn(t.slice(7));n!==void 0&&(r=n,e=!0)}else t===`callout=false`?(o=!1,e=!0):t===`callout=true`&&(o=!0,e=!0);e&&(t=t.slice(0,s.index).trim())}t.startsWith(`^ `)?(i=`above`,t=t.slice(2).trim()):/^[vV]\s+/.test(t)&&(i=`below`,t=t.slice(2).trim());let c=t.indexOf(`::`),l=(c>=0?t.slice(0,c):t).trim(),u=c>=0?t.slice(c+2).trim():void 0;return{...l?{label:l}:{},...u?{description:u}:{},...n?{id:n}:{},...r===void 0?{}:{column:r},...i?{side:i}:{},...a?{descriptionSide:a}:{},...o===void 0?{}:{callout:o}}}function Gn(e){let t=e.trim(),n,r,i,a=!1,o=/\{([^{}]+)\}\s*$/.exec(t);if(o){for(let e of o[1].trim().split(/\s+/))e.startsWith(`#`)&&e.length>1?(n=e.slice(1),a=!0):e.startsWith(`start=`)?(r=Kn(e.slice(6)),a||=r!==void 0):e.startsWith(`end=`)&&(i=Kn(e.slice(4)),a||=i!==void 0);a&&(t=t.slice(0,o.index).trim())}return{...t?{label:t}:{},...n?{id:n}:{},...r===void 0?{}:{startColumn:r},...i===void 0?{}:{endColumn:i},hasMetadata:a}}function Kn(e){if(!e.trim())return;let t=Number(e);return Number.isFinite(t)?t:void 0}function qn(e){let t=Array.from(e),n=0,r=t.length-1,i=0;for(;i<=r&&/\s/u.test(t[i]);)i++;let a=i;for(;a<=r&&Fn.has(t[a]);)a++;for(n=a>i&&(i===0||a>r||/\s/u.test(t[a]??``))?a:i;n<=r&&/\s/u.test(t[n]);)n++;for(;r>=n&&/\s/u.test(t[r]);)r--;let o=r;for(;r>=n&&Fn.has(t[r]);)r--;let s=r<o,c=s?t.slice(r+1,o+1):[];for(s&&(r<n||/\s/u.test(t[r]??``)||c.length>=3||c.some(e=>e!==`-`))||(r=o);r>=n&&/\s/u.test(t[r]);)r--;return t.slice(n,r+1).join(``)}function Jn(e,t,n){let r=t-1;for(;r>=0&&/\s/u.test(e[r]);)r--;let i=0;for(;r>=0&&Fn.has(e[r]);)i++,r--;return i>=n}function Yn(e){for(let t=e.length-1;t>=0;t--)if(!/\s/u.test(e[t]))return t;return-1}function Xn(e){let t=/^\s*(?:branch|link)\s*:\s*([^\s:]+)\s*(?:->|=>|→)\s*([^\s:]+)(?:\s*:\s*(.+))?\s*$/i.exec(e);return t?{source:t[1],target:t[2],...t[3]?.trim()?{label:t[3].trim()}:{}}:null}function Zn(e){let t=Array.from(e),n=[],r=-1,i=0;for(let e=0;e<=t.length;e++){let a=t[e];if(a===` `){if(i++,r>=0&&i>=2){let a=e-i,o=t.slice(r,a+1).join(``).trim();o&&n.push({start:r,end:a,text:o}),r=-1}continue}if(i=0,a!==void 0&&r<0&&(r=e),a===void 0&&r>=0){let e=t.slice(r).join(``).trim();e&&n.push({start:r,end:t.length-1,text:e})}}return n.filter(e=>lr(e.text).length>0)}function Qn(e){let t=Array.from(e),n=[];for(let e=0;e<t.length;e++){if(!Rn.has(t[e]))continue;let r=e+1,i=r;for(;r<t.length&&(Fn.has(t[r])||t[r]===` `);)r++;let a=r,o=t[r];if(o!==void 0&&!/\s/u.test(o)){let e=-1;for(let n=i;n<r;n++)Fn.has(t[n])&&t[n]!==`-`&&(e=n);e>=i&&e+1<r?r=e+1:e<0&&r-i>=3&&r--}let s=r;if(r<a)for(;r<t.length&&t[r]===`-`;)r++;for(;r<t.length&&!Fn.has(t[r])&&!Rn.has(t[r]);)r++;let c=t.slice(s,r).join(``).trim();c&&n.push({start:e,end:Math.max(e,r-1),text:c})}return n}function $n(e,t,n){return e.filter(e=>n>=e.startColumn-2&&n<=e.endColumn+2).sort((e,n)=>Math.abs(e.row-t)-Math.abs(n.row-t))[0]}function er(e,t){let n=e[t];return Ln.has(n)?n!==`^`&&n!==`v`||(t===0||/\s/u.test(e[t-1]??``))&&(t+1>=e.length||/\s/u.test(e[t+1]??``)):!1}function tr(e,t,n){return e.filter(e=>e.events.some(e=>!e.id&&Math.abs(e.column-n)<=1)).sort((e,n)=>Math.abs(e.row-t)-Math.abs(n.row-t))[0]}function nr(e,t){return[...e].sort((e,n)=>Math.abs(e.column-t)-Math.abs(n.column-t)||Number(e.callout===!1)-Number(n.callout===!1))[0]}function rr(e,t,n){return[...e].map(e=>({segment:e,distance:Math.abs((e.start+e.end)/2-t)})).filter(e=>e.distance<=n).sort((e,t)=>e.distance-t.distance)[0]?.segment}function ir(e,t){let n=e.filter(e=>e.column!==t).map(e=>Math.abs(e.column-t));return n.length>0?Math.min(...n):12}function ar(e,t){for(let n=t;n>=0;n--)if(e[n].trim())return n;return-1}function or(e){return e===`◆`||e===`◇`?`diamond`:e===`○`||e===`o`||e===`O`?`hollow`:`filled`}function sr(e,t,n){let r=e[t];if(Nn.has(r))return!0;if(n!==`ascii`||!Pn.has(r))return!1;let i=cr(e,t,-1),a=cr(e,t,1),o=/[\p{L}\p{N}_]/u.test(e[t-1]??``),s=/[\p{L}\p{N}_]/u.test(e[t+1]??``);return i>=2&&!s||a>=2&&!o}function cr(e,t,n){let r=0;for(let i=t+n;Fn.has(e[i]??``);i+=n)r++;return r}function lr(e){return e.replace(/^[\s│|└┌├┬┘┐╰╭╯╮─━═╌╍┄┅┈┉-]+/u,``).replace(/[\s│|└┌├┬┘┐╰╭╯╮─━═╌╍┄┅┈┉►▶▷→>-]+$/u,``).replace(/\s+/g,` `).trim()}function ur(e){return e.replace(/^[\s│|]+/u,``).replace(/[\s│|]+$/u,``).replace(/\s+/g,` `).trim()}function dr(e){return e.replace(/:\s*$/,``).trim()}function fr(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`event`}function pr(e,t){let n=t.get(e)??0;return t.set(e,n+1),n===0?e:`${e}-${n+1}`}function mr(e){for(let t of e)for(let e of t)if(Nn.has(e)||Fn.has(e)&&e!==`-`||[`►`,`▶`,`▷`,`→`].includes(e))return`unicode`;return`ascii`}var hr=new Set([`text`,`txt`,`plaintext`,`plain`,`ascii`,`timeline`]),gr=400,_r=2e3,vr=400,yr=4096,br=/[┌┏╔╭].*[┐┓╗╮]/u,xr=/\{#[^{}\s]+ start=[^{}\s]+ end=[^{}\s]+\}:\s/u;function Sr(e){if(e==null)return!0;let t=e.trim().toLowerCase();return t===``||hr.has(t)}function Cr(e){return typeof e==`string`&&e.trim().toLowerCase()===`timeline`}function wr(e,t={}){let n=t.explicit===!0,r=e.replace(/\r\n?/g,`
11
+ `).split(`
12
+ `),i=r.filter(e=>xr.test(e)).length,a=Math.min(_r,i*6+r.filter(e=>/^\s*(?:branch|link)\s*:/iu.test(e)).length+2);if(r.length>gr&&(i===0||r.length>a))return{isTimeline:!1,reasons:[`too-many-lines(${r.length})`]};let o=Math.max(0,...r.map(e=>Array.from(e).length)),s=i>0&&r.every(e=>Array.from(e).length<=vr||xr.test(e));if(o>(n||s?yr:vr))return{isTimeline:!1,reasons:[`too-wide(${o})`]};let c=r.filter(e=>e.trim().length>0),l=c.filter(e=>/^\s*\|.*\|\s*$/.test(e)).length,u=c.some(e=>/^\s*\|?[\s:|-]+\|?\s*$/.test(e)&&e.includes(`-`));if(l>c.length/2&&u)return{isTimeline:!1,reasons:[`markdown-table`]};if(!n&&r.some(e=>br.test(e)))return{isTimeline:!1,reasons:[`has-box-corners`]};let d=Ct(e).stats.boxNodes;if(d>=(n?2:1))return{isTimeline:!1,reasons:[`has-boxes(${d})`]};if(!n&&/^[ \t]*(?:[│|][ \t]*)*[├└+|`][─━═-]{1,4}[ \t]+[●○◉◆◇•]/mu.test(e))return{isTimeline:!1,reasons:[`tree-connector-prefix`]};let{timeline:f,stats:p}=Bn(e);return p.wrappedFlow?{isTimeline:!0,timeline:f,reasons:[`tracks(${p.axisLines})`,`events(${p.markerCount})`,`wrapped-flow`]}:p.axisLines===0?{isTimeline:!1,reasons:[`no-axis-lines`]}:!(n&&p.horizontalChars===0&&p.markerCount>=4)&&p.horizontalChars<(n?2:8)?{isTimeline:!1,reasons:[`too-few-horizontal(${p.horizontalChars})`]}:p.markerCount<(n?1:2)?{isTimeline:!1,reasons:[`too-few-markers(${p.markerCount})`]}:!n&&p.strongMarkerCount<2?{isTimeline:!1,reasons:[`too-few-strong-markers(${p.strongMarkerCount})`]}:{isTimeline:!0,timeline:f,reasons:[`tracks(${p.axisLines})`,`events(${p.markerCount+p.pointerCount})`,n?`explicit`:`strong-markers`]}}function Tr(e){return e.type!==`code`||!Sr(e.lang)?!1:wr(e.value,{explicit:Cr(e.lang)}).isTimeline}var Er=new Set([`│`,`┃`,`╎`,`╏`,`║`,`|`]),Dr=new Set([`├`,`┣`,`┠`,`┝`,`╠`,`╞`]),Or=new Set([`└`,`┗`,`╰`,`╚`,`╘`]),kr=new Set([`─`,`━`,`═`,`-`]);function Ar(e){return Er.has(e)}function jr(e){return Dr.has(e)}function Mr(e){return Or.has(e)}function Nr(e){return kr.has(e)}function Pr(e){return Dr.has(e)||Or.has(e)||e===`│`||e===`┃`||e===`─`||e===`━`}function Fr(e){return e===`|`||e==="`"||e===`+`||e===`-`}var Ir={tee:`├── `,elbow:`└── `,rail:`│ `,gap:` `},Lr={tee:`|-- `,elbow:"`-- ",rail:`| `,gap:` `};function Rr(e){return zr(e).tree}function zr(e){let t=[],n=e.replace(/\r\n?/g,`
13
+ `).split(`
14
+ `),r=Vr(n),i={contentLines:0,connectorLines:0,looseLines:0,indentLevels:0},a=new Set,o=[];for(let e of n){if(e.trim().length===0)continue;i.contentLines++;let t=Br(e);if(!t||t.label.length===0){i.looseLines++;continue}t.hadConnector&&i.connectorLines++,a.add(t.indent),o.push(t)}i.indentLevels=a.size;let s=[],c=[];for(let e of o){let t={id:``,label:e.label,children:[],...e.comment?{comment:e.comment}:{}};for(;c.length>0&&c[c.length-1].indent>=e.indent;)c.pop();c.length===0?s.push(t):c[c.length-1].node.children.push(t),c.push({indent:e.indent,node:t})}let l=new Map,u=e=>{e.isDir=e.label.endsWith(`/`)||e.children.length>0;let t=Ur(Hr(e.label)),n=l.get(t)??0;l.set(t,n+1),e.id=n===0?t:`${t}-${n+1}`;for(let t of e.children)u(t)};for(let e of s)u(e);return o.length>0&&i.looseLines>0&&t.push(`loose-lines(${i.looseLines})`),{tree:{roots:s,style:r,warnings:t},stats:i}}function Br(e){let t=Array.from(e),n=0,r=!1;for(;;){for(;n<t.length&&(t[n]===` `||t[n]===` `);)n++;let e=t[n];if(e===void 0)return null;if(Ar(e)&&!Nr(t[n+1]??``)){n++;continue}break}let i=t[n];if(i!==void 0)if(jr(i)||Mr(i)){for(n++;n<t.length&&(Nr(t[n])||Ar(t[n]));)n++;r=!0}else if((i===`|`||i==="`"||i===`+`)&&Nr(t[n+1]??``)){for(n++;n<t.length&&Nr(t[n]);)n++;r=!0}else(i===`-`||i===`*`||i===`+`)&&(t[n+1]??``)===` `&&(n++,r=!1);for(;n<t.length&&(t[n]===` `||t[n]===` `);)n++;let a=n,o=t.slice(n).join(``).replace(/\s+$/u,``);if(o.length===0)return null;let s,c=/\s{2,}(?:#|<--|\/\/)\s?(.*)$/.exec(o);return c&&(s=c[1].trim()||void 0,o=o.slice(0,c.index).replace(/\s+$/u,``)),o.length===0?null:{indent:a,label:o,hadConnector:r,...s?{comment:s}:{}}}function Vr(e){let t=0,n=0;for(let r of e)for(let e of r)Pr(e)?t++:Fr(e)&&n++;return n>t?`ascii`:`unicode`}function Hr(e){return e.endsWith(`/`)?e.slice(0,-1):e}function Ur(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`node`}var Wr=new Set([`text`,`txt`,`plaintext`,`plain`,`ascii`,`tree`]),Gr=400,Kr=2,qr=2,Jr=2,Yr=/[┌┐┘┏┓┛╔╗╝╭╮╯]/u;function Xr(e){if(e==null)return!0;let t=e.trim().toLowerCase();return t===``||Wr.has(t)}function Zr(e){return typeof e==`string`&&e.trim().toLowerCase()===`tree`}function Qr(e,t={}){let n=t.explicit===!0,r=e.replace(/\r\n?/g,`
15
+ `).split(`
16
+ `),i=r.filter(e=>e.trim().length>0),a=n?1:Kr;if(i.length<a)return{isTree:!1,reasons:[`too-few-lines(${i.length})`]};if(r.length>Gr)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(Yr.test(e))return{isTree:!1,reasons:[`has-box-corners`]};if(!n&&wr(e).isTimeline)return{isTree:!1,reasons:[`is-timeline`]};let c=Ct(e).stats.boxNodes;if(c>=2)return{isTree:!1,reasons:[`has-boxes(${c})`]};let{tree:l,stats:u}=zr(e),d=ei(l.roots);if(d<(n?1:Jr))return{isTree:!1,reasons:[`too-few-nodes(${d})`]};if(!n){if(u.connectorLines<qr)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 $r(e){return e.type!==`code`||!Xr(e.lang)?!1:Qr(e.value,{explicit:Zr(e.lang)}).isTree}function ei(e){let t=0;for(let n of e)t+=1+ei(n.children);return t}var ti=/(?:[$€£¥]\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 ni(e){let t=ti.exec(e);return!t||t.index===void 0?null:{value:t[0],index:t.index,end:t.index+t[0].length}}var ri=Object.freeze({hasImage:!1,imageCount:0,hasVideo:!1,hasBlockquote:!1,hasList:!1,hasTable:!1,hasDate:!1,hasNumberHighlight:!1,wordCount:0,hasCompoundBody:!1}),ii=[/\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],ai=/(youtube\.com|youtu\.be|vimeo\.com|wistia\.|loom\.com)/i;function oi(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 si(e){if(!e||e.length===0)return{...ri};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=oi(l,new Set([`img`]));t+=u.length;let d=oi(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(ai.test(t)){f=!0;break}}if(!f){let e=r(l,`link`);for(let t of e)if(t.url&&ai.test(t.url)){f=!0;break}}let p=c.join(` `).trim(),m=p?p.split(/\s+/).length:0,h=!1;for(let e of ii)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||!ni(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&&cn(v[0].lang)&&!s&&t===0&&!f){let e=Math.max(0,p.length-v[0].value.length),t=ln(v[0].lang);e<=400&&un(v[0].value,{explicit:t}).isDiagram&&(_=!0)}let y=!1;if(!_&&v.length===1&&Sr(v[0].lang)&&!s&&t===0&&!f){let e=Math.max(0,p.length-v[0].value.length),t=Cr(v[0].lang);e<=400&&wr(v[0].value,{explicit:t}).isTimeline&&(y=!0)}let b=!1;if(!_&&!y&&v.length===1&&Xr(v[0].lang)&&!s&&t===0&&!f){let e=Math.max(0,p.length-v[0].value.length),t=Zr(v[0].lang);e<=400&&Qr(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,hasCompoundBody:e.length>1&&e.some(e=>e.type!==`paragraph`),hasAsciiDiagram:_,hasTimeline:y,hasTree:b}}var ci=[`title`,`sectionHeader`,`content`,`factCard`,`twoColumn`];function li(e){if(e.hasCompoundBody)return[`content`];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`),t.add(`content`);else for(let e of ci)t.add(e);return Array.from(t)}function ui(e,t=0){if(!e.hasCompoundBody){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 di(e,t){let n=new Set(li(e)),r=[],i=[];for(let e of t)n.has(e)?r.push(e):i.push(e);return{recommended:r,rest:i}}var fi=200;function pi(e,t){let n=t?.wordsPerMinute,r=typeof n==`number`&&n>0?n:fi,i=e.split(/\s+/).filter(e=>e.length>0).length,a=i/r;return{words:i,minutes:a,seconds:Math.round(a*60)}}var mi={"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 hi(e){return{type:`shape`,id:`persistent-bg-solid`,content:{shape:`rect`,fill:e.color},position:{x:0,y:0,width:`100%`,height:`100%`}}}function gi(e){return{type:`shape`,id:`persistent-bg-gradient`,content:{shape:`rect`,fill:e.gradient??mi[e.preset??`dark-vignette`]},position:{x:0,y:0,width:`100%`,height:`100%`}}}function _i(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 vi(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 yi(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 bi(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 xi(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 Si(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 Ci(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 wi(e,t){if(!l(e))return[s(e)];let n=e.config;switch(n.type){case`solidBackground`:return[hi(n)];case`gradientBackground`:return[gi(n)];case`imageBackground`:return _i(n);case`patternBackground`:return[vi(n)];case`vignette`:return[yi(n)];case`ambientGradient`:return[bi(n,t)];case`titleCaption`:return xi(n);case`cornerBranding`:return[Si(n)];case`progressIndicator`:return[Ci(n)];default:return console.warn(`Unknown persistent layer template:`,n.type),[]}}function Ti(e,t){return!e||e.length===0?[]:e.reduce((e,n)=>e.concat(wi(n,t)),[])}function Ei(e){return e.persistentLayers??{}}function Di(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 Oi(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 ki={bg:`#1a365d`,text:`#63b3ed`,accent:`#90cdf4`};function H(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]]:ki}var Ai=`system-ui, -apple-system, "Segoe UI", Roboto, sans-serif`,ji=`Georgia, "Times New Roman", serif`,Mi=`Consolas, "Courier New", monospace`;function U(e,t){let{typography:n}=e.theme;switch(t){case`title`:return w(n.titleFont,ji);case`body`:return w(n.bodyFont,Ai);case`mono`:return w(n.monoFont,Mi)}}function W(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 Ni(e,t){return e*(t.theme.style.animationSpeed??1)}function Pi(e,t){let n=e.theme.renderStyle;return t===`text`?n.defaultTextAnimation:n.defaultImageAnimation}function G(e,t,n){let r=Pi(e,t);return!r||r===`slowZoom`||r===n.type?n:{...n,type:r}}function K(e){return e.theme.style.textShadow??!0}function Fi(e){return e.theme.style.overlayOpacity??.5}function Ii(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 Li(e,t=160){let{background:n,backgroundLight:r}=e.theme.colors;return`linear-gradient(${t}deg, ${r} 0%, ${b(n,.04)} 100%)`}function Ri(e,t){let n=t??Math.max(.55,Fi(e));return C(e.theme.colors.background,n)}function zi(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 Bi=/[.;:!?]+$/;function Vi(e){return e.replace(Bi,``).trim()}function Hi(e,t){return{type:`shape`,id:e,content:{shape:`rect`,fill:t},position:{x:0,y:0,width:`100%`,height:`100%`}}}function Ui(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 Wi(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 Gi(e,t,n){return e.split(`
17
+ `).reduce((e,r)=>e+Wi(r,t,n),0)}function q(e){let{text:t,baseFontSize:n,minFontSize:r,maxWidthPx:i,maxHeightPx:a,lineHeight:o}=e,s=Math.max(.5,e.step??2),c=Math.min(n,r),l=(e,t)=>e*t*o,u=[];for(let e=n;e>c;e-=s)u.push(e);u.push(c);for(let e of u){let n=Gi(t,e,i),r=l(n,e);if(r<=a)return{fontSize:e,lines:n,heightPx:r}}let d=Math.max(1,Math.floor(a/(c*o)));return{fontSize:c,lines:d,heightPx:l(d,c),maxLines:d}}var Ki=1.15,qi=1.5,Ji=56,Yi=56,Xi=.4,Zi=.5,Qi=.2,$i=7;function ea(e,t){let{title:n,subtitle:r,backgroundColor:i}=e,{theme:a,layout:o,viewport:s}=t,c=W(96,t,!0),l=W(36,t,!1),u=i||a.colors.primary,d=e=>e/s.height*100,f=parseFloat(o.maxTextWidth)/100*s.width,p=q({text:n,baseFontSize:c,minFontSize:Math.round(c*.55),maxWidthPx:f,maxHeightPx:s.height*(r?Xi:Zi),lineHeight:Ki,step:4}),m=p.heightPx,h=r?q({text:r,baseFontSize:l,minFontSize:Math.round(l*.7),maxWidthPx:f,maxHeightPx:s.height*Qi,lineHeight:qi,step:2}):void 0,g=h?.heightPx??0,_=Yi+(p.lines>1?p.fontSize*.25:0),v=m+(r?_+g:0),y=l*qi,b=(r?42+d((Yi+y)/2):48)-d(v/2),x=100-$i-d(v);b=Math.max($i,Math.min(b,x));let S=b,w=S+d(m/2),T=S+d(m+_)+d(g/2),E=[{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%`}}];return zi(t,`title`,`showAccentLine`,!0)&&E.push({type:`shape`,id:`accent-line`,content:{shape:`rect`,fill:C(a.colors.text,.3)},position:{x:`44%`,y:`${Math.max(2,S-d(Ji))}%`,width:`12%`,height:`3px`}}),E.push({type:`text`,id:`title`,content:{text:n,style:{fontSize:p.fontSize,fontFamily:U(t,`title`),fontWeight:`bold`,color:a.colors.text,textAlign:`center`,lineHeight:Ki,shadow:K(t),shrinkToFit:!0,...p.maxLines?{maxLines:p.maxLines}:{}}},position:{x:`50%`,y:`${w}%`,anchor:`center`,width:o.maxTextWidth,height:`${d(m)}%`},animation:G(t,`text`,{type:`fadeIn`,duration:2})}),r&&h&&E.push({type:`text`,id:`subtitle`,content:{text:r,style:{fontSize:h.fontSize,fontFamily:U(t,`body`),color:a.colors.textMuted,textAlign:`center`,lineHeight:qi,shrinkToFit:!0,...h.maxLines?{maxLines:h.maxLines}:{}}},position:{x:`50%`,y:`${T}%`,anchor:`center`,width:o.maxTextWidth,height:`${d(g)}%`},animation:{type:`fadeIn`,duration:1.5,delay:1}}),E}var ta=/^(\d+(?:\.\d+)?)\s*%?$/,na={textCenterX:`50%`,textWidth:`85%`,textYAdjust:0,adjustY:!1};function ra(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 ia=35,aa=ia,oa=`${aa}%`;function sa(e){switch(e){case`left-strip`:return{textCenterX:`${50+aa/2}%`,textWidth:`${100-aa-8}%`,textYAdjust:0,adjustY:!1};case`right-strip`:return{textCenterX:`${50-aa/2}%`,textWidth:`${100-aa-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 na}}function ca(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(la(i,a,`left`,t,s,c,l,n)),r.push(ua(`left`,t));break;case`right-strip`:r.push(la(i,a,`right`,t,s,c,l,n)),r.push(ua(`right`,t));break;case`bottom-strip`:r.push(da(i,a,t,s,c,l,n)),r.push(fa(t));break;case`corner-inset`:r.push(pa(i,a,t,s,c,l,n)),r.push(ma(t));break}return r}function la(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-aa}%`,y:0,width:oa,height:`100%`},animation:ra(i,15)}}function ua(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`?`${aa-8}%`:`${100-aa}%`,y:0,width:`10%`,height:`100%`}}}function da(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-aa}%`,width:`100%`,height:oa},animation:ra(r,15)}}function fa(e){return{type:`shape`,id:`${e}-accent-fade`,content:{shape:`rect`,fill:`url(#accent-gradient-bottom)`},position:{x:0,y:`${100-aa-8}%`,width:`100%`,height:`12%`}}}function pa(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:ra(r,15)??{type:`fadeIn`,duration:2,delay:.5}}}function ma(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 ha(e,t){if(!t.adjustY||t.textYAdjust===0)return typeof e==`number`?`${e}%`:e;let n=typeof e==`number`?`${e}`:e,r=n.match(ta);if(r){let e=parseFloat(r[1]);return`${Math.max(5,e+t.textYAdjust)}%`}return n}var ga=1.4,_a=40,va=.5;function ya(e,t){let{title:n=``,colorScheme:r=`blue`,imageSrc:i,imageAlt:a,ambientMotion:o}=e,{theme:s,layout:c,viewport:l}=t,u=Ii(t,e.imageTreatment),d=H(t,r),f=W(84,t,!0),p=parseFloat(c.maxTextWidth)/100*l.width,m=q({text:n,baseFontSize:f,minFontSize:Math.round(f*.55),maxWidthPx:p,maxHeightPx:l.height*va,lineHeight:ga,step:4}),h=m.heightPx,g=e=>e/l.height*100,_=Math.max(10,g(h/2+_a)),v=[];return i?(v.push({type:`image`,id:`bg-image`,content:{src:i,alt:a||n,fit:`cover`,...u?{treatment:u}:{}},position:{x:0,y:0,width:`100%`,height:`100%`},animation:ra(o,8)??{type:`slowZoom`,duration:8,direction:`in`}}),v.push({type:`shape`,id:`overlay`,content:{shape:`rect`,fill:Ri(t)},position:{x:0,y:0,width:`100%`,height:`100%`}})):(v.push({type:`shape`,id:`bg`,content:{shape:`rect`,fill:d.bg},position:{x:0,y:0,width:`100%`,height:`100%`}}),v.push({type:`shape`,id:`line-top`,content:{shape:`rect`,fill:C(d.text,.2)},position:{x:`50%`,y:`${50-_}%`,width:`20%`,height:`2px`,anchor:`center`}}),v.push({type:`shape`,id:`line-bottom`,content:{shape:`rect`,fill:C(d.text,.2)},position:{x:`50%`,y:`${50+_}%`,width:`20%`,height:`2px`,anchor:`center`}})),v.push({type:`text`,id:`title`,content:{text:n,style:{fontSize:m.fontSize,fontFamily:U(t,`title`),fontWeight:`bold`,color:i?s.colors.text:d.text,textAlign:`center`,lineHeight:ga,shadow:K(t),shrinkToFit:!0,...m.maxLines?{maxLines:m.maxLines}:{}}},position:{x:`50%`,y:`50%`,anchor:`center`,width:c.maxTextWidth,height:`${g(h)}%`},animation:G(t,`text`,{type:`fadeIn`,duration:1.5})}),v}var ba=1.05,xa=.92,Sa=.86,Ca=.62,wa=48;function Ta(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 Ea(e,t){let n=t.width*xa,r=t.height*Sa,i=e.trim().split(/\s+/).filter(Boolean).map(e=>e.length);if(i.length===0)return Math.floor(r/ba);let a=n/(Ca*Math.max(...i)),o=r/ba,s=e=>{let t=Math.max(1,Math.floor(n/(e*Ca)));return Ta(i,t)*e*ba<=r},c=wa,l=Math.min(a,o);if(l<=c)return Math.max(wa,Math.floor(l));if(!s(c))return wa;for(let e=0;e<24;e+=1){let e=(c+l)/2;s(e)?c=e:l=e}return Math.floor(c)}function Da(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 Oa(e,t){let{title:n=``,imageSrc:r,imageAlt:i,ambientMotion:a}=e,{theme:o,viewport:s}=t,c=Ii(t,e.imageTreatment),l=n.toUpperCase(),u=Ea(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:ra(a,8)??{type:`slowZoom`,duration:8,direction:`in`}},{type:`shape`,id:`bigtext-bloom`,content:{shape:`rect`,fill:Da(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:U(t,`title`),fontWeight:`bold`,color:o.colors.text,textAlign:`center`,lineHeight:ba,shadow:!!r,shrinkToFit:!0}},position:{x:`50%`,y:`50%`,anchor:`center`,width:`${xa*100}%`,height:`${Sa*100}%`},animation:G(t,`text`,{type:`fadeIn`,duration:1})}),d}var ka={gapX:260,gapY:140,gridPad:80,gridOriginX:80,gridOriginY:80};function Aa(e,t={}){let n={...ka,...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=ja(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 ja(e,t){return t.type?`${e}->${t.target}:${t.type}`:`${e}->${t.target}`}var Ma=14,Na=28;function Pa(e,t){return{x:e*14,y:t*28}}function Fa(e,t){return{col:Math.max(0,Math.round(e/14)),row:Math.max(0,Math.round(t/28))}}function Ia(e){let t=e.nodes.map(e=>({id:e.id,label:e.label,...Pa(e.col,e.row),w:e.wCols*14,h:e.hRows*28,...e.containerId?{container:e.containerId}:{}})),n=La(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 La(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 za(r,t,e,`source`),za(r,t,e,`target`),Ra(r,t,e),r}function Ra(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 za(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 Ba(e,t,n={}){let r=new Set(e.map(e=>e.id));return{nodes:e.map(e=>{let{col:t,row:n}=Fa(e.x,e.y),i=e.label.length>0?e.label.split(`
18
+ `):[],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 Va(e,t={}){let n=Aa(e),r=Ba(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 Ha(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:Ua((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 Ua(e){return Math.max(0,Math.min(1,e))}function Wa(e){return{items:e.roots.map(Ga)}}function Ga(e){return{id:e.id,label:e.label,...e.isDir?{isDir:!0}:{},...e.comment?{comment:e.comment}:{},children:e.children.map(Ga)}}function Ka(e,t={}){return{roots:e.map(qa),style:t.style??`unicode`,warnings:[]}}function qa(e){let t=Array.isArray(e.children)?e.children.map(qa):[];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 Ja(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 Ya(e){return e?.find(e=>e.type===`list`)}var Xa=/\.(?:webm|mp4|mov|m4v|ogv)(?:[?#].*)?$/i;function Za(e){return!e||e.length===0?``:e.filter(e=>!(e.type===`code`&&e.lang?.trim().toLowerCase()===`mermaid`)).map(e=>o(e)).join(`
19
+ `).trim()}function Qa(e){return io(e).map(e=>e.text)}function $a(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`)}function eo(e){return e.map(e=>{switch(e.type){case`text`:return $a(e.value);case`emphasis`:return`<em>${eo(e.children)}</em>`;case`strong`:return`<strong>${eo(e.children)}</strong>`;case`delete`:return`<del>${eo(e.children)}</del>`;case`superscript`:return`<sup>${eo(e.children)}</sup>`;case`subscript`:return`<sub>${eo(e.children)}</sub>`;case`inlineCode`:return`<code>${$a(e.value)}</code>`;case`link`:{let t=eo(e.children),n=te(e.url,`link`);if(!n)return t;let r=e.title?` title="${$a(e.title)}"`:``;return`<a href="${$a(n)}"${r}>${t}</a>`}case`break`:return`<br>`;case`image`:return $a(e.alt??``);case`inlineMath`:return $a(`$${e.value}$`);case`footnoteReference`:return $a(`[^${e.label??e.identifier}]`);case`linkReference`:case`textDirective`:return eo(e.children);case`imageReference`:return $a(e.alt??``);case`mention`:return $a(`@${e.displayName}`);case`inlineIcon`:return`<i class="fa-${e.family} fa-${e.name}" aria-hidden="true"></i>`;case`htmlInline`:return $a(e.rawHtml)}}).join(``)}function to(e){let t=e=>e.map((t,n)=>{let i=e[n-1],a=i?Math.max(0,no(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>${eo(e.children)}</p>`;case`heading`:return`<h${e.depth}>${eo(e.children)}</h${e.depth}>`;case`blockquote`:return`<blockquote>${t(e.children)}</blockquote>`;case`list`:return n(e);case`code`:return`<pre><code>${$a(e.value)}</code></pre>`;case`thematicBreak`:return`<hr>`;case`table`:{let[t,...n]=e.children,r=(t,n)=>`<tr>${t.map((t,r)=>{let i=n?`th`:`td`,a=e.align?.[r];return`<${i}${a?` align="${a}"`:``}>${eo(t.children)}</${i}>`}).join(``)}</tr>`;return`<div data-squisq-table-scroll role="region" aria-label="Scrollable data table"><table>${t?`<thead>${r(t.children,!0)}</thead>`:``}${n.length?`<tbody>${n.map(e=>r(e.children,!1)).join(``)}</tbody>`:``}</table></div>`}case`math`:return`<pre><code>${$a(e.value)}</code></pre>`;case`definition`:return``;default:{let t=o(e).trim();return t?`<p>${$a(t)}</p>`:``}}};return t(e)}function no(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 ro(e){return e.map(e=>e.type===`paragraph`||e.type===`heading`?eo(e.children):$a(o(e))).join(`<br>`)}function io(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=ro(e.children),i=$a(n).replace(/\r?\n/g,`<br>`);t.push({text:n,markdown:e.children,...r&&r!==i?{html:r}:{}})}return t}function ao(e){if(e===void 0)return;let t=parseFloat(e);return Number.isFinite(t)&&t>0?t:void 0}function oo(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:ao(t.width),height:ao(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 so(e){return oo(e,1)[0]??null}function co(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`]?re(e[`data-squisq-video-start-at`]):null,r=e?.[`data-squisq-video-clip-start`]?re(e[`data-squisq-video-clip-start`]):null,a=e?.[`data-squisq-video-clip-end`]?re(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`&&Xa.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 lo(e){return co(e,1)[0]??null}function uo(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 fo(e){if(!e)return``;for(let t of e)if(t.type===`blockquote`)return o(t).trim();return``}function po(e){if(!e)return null;let t=e.findIndex(e=>e.type===`paragraph`);return t<0?null:{node:e[t],index:t}}function mo(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 ho(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 go(e,t,n,r,i){return e?e.map((e,a)=>a===t?ho(n,r,i):o(e).trim()).filter(Boolean).join(`
20
+ `).trim():``}function _o(e,t,n){let r=po(t);if(r){let n=o(r.node).trim(),i=mo(r.node);if(i){let a=n.indexOf(i);return{stat:i,description:go(t,r.index,n,a,a+i.length)||e||i}}}let i=e.trim(),a=ni(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=ni(n);if(i){let a=go(t,r.index,n,i.index,i.end);return{stat:i.value,description:a||e||i.value}}}return{stat:e,description:n||e}}function vo(e){return e.replace(/\s+/g,` `).trim()}function yo(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=oo(n);if(e.length<2||e.length>4)return!1;let t=vo(Za(n)),r=vo(e.map(e=>e.alt).filter(Boolean).join(` `));return t===``||t===r}case`videoWithCaption`:{let e=co(n);return e.length===1&&vo(Za(n))===vo(e[0]?.alt??``)}case`leftFeature`:case`rightFeature`:case`statHighlight`:return n.length>0&&n.every(e=>e.type===`paragraph`);default:return!1}}function bo(e,t,n,r={}){let i=r.placeholders===!0,a=Za(n);switch(e){case`statHighlight`:{let e=_o(t,n,a);return r.preserveSourceHeading&&t&&e.stat!==t&&e.description!==t?{...e,description:t,...e.description?{detail:e.description}:{}}:e}case`transcript`:{let e=fo(n)||a;return!e&&!t?i?{speaker:`Speaker`,text:`Message`}:null:{speaker:t||(i?`Speaker`:``),text:e||(i?`Message`:``)}}case`quote`:{let e=fo(n)||a;return e?{quote:e,...t?{title:t}:{}}:{quote:t}}case`fullBleedQuote`:return{text:fo(n)||a||t};case`pullQuote`:{let e=fo(n)||a||t,r=so(n);return{text:e,...r?{backgroundImage:{src:r.src,alt:r.alt||t}}:{}}}case`videoPullQuote`:{let e=fo(n)||a||t,r=lo(n);return{text:e,...r?{backgroundVideo:{src:r.src,...r.posterSrc?{posterSrc:r.posterSrc}:{},alt:r.alt||t,...r.clipStart==null?{}:{clipStart:r.clipStart},...r.clipEnd==null?{}:{clipEnd:r.clipEnd}}}:{}}}case`factCard`:return{fact:t,explanation:a};case`twoColumn`:return t?{header:t}:i?{}:null;case`comparisonBar`:return i?{leftLabel:`A`,leftValue:60,rightLabel:`B`,rightValue:40}:null;case`list`:{let e=Qa(n),r=(n??[]).find(e=>e.type===`list`);return e.length>0?{items:e,ordered:r?.ordered===!0,...t?{title:t}:{}}:i?{items:[`Item 1`,`Item 2`,`Item 3`]}:null}case`definitionCard`:return{term:t,definition:a};case`dateEvent`:return{date:t,description:a};case`dataTable`:{let e=uo(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=uo(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=so(n);return e?{imageSrc:e.src,imageAlt:e.alt||t,caption:t}:i?{caption:t}:null}case`bigText`:{let e=so(n);return{title:t,...e?{imageSrc:e.src,imageAlt:e.alt||t}:{}}}case`photoGrid`:{let e=oo(n,4);return e.length<2?i?{}:null:{images:e.map(e=>({src:e.src,alt:e.alt})),caption:t}}case`videoWithCaption`:{let e=lo(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=so(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&&cn(e[0].lang)?e[0]:void 0,a=r?un(r.value,{explicit:ln(r.lang)}):void 0;if(!a?.isDiagram||!a.diagram)return i?{}:null;let{nodes:o,edges:s}=Ia(a.diagram);return{nodes:o,edges:s,...t?{title:t}:{}}}case`timeline`:{let e=(n??[]).filter(e=>e.type===`code`),r=e.length===1&&Sr(e[0].lang)?e[0]:void 0,a=r?wr(r.value,{explicit:!0}):void 0;if(!a?.isTimeline||!a.timeline)return i?{}:null;let{tracks:o,links:s}=Ha(a.timeline);return{tracks:o,links:s,...t?{title:t}:{}}}case`tree`:{let e=(n??[]).filter(e=>e.type===`code`),r=e.length===1&&Xr(e[0].lang)?e[0]:void 0;if(r){let e=Qr(r.value,{explicit:Zr(r.lang)});if(e.isTree&&e.tree){let{items:n}=Wa(e.tree);return{items:n,...t?{title:t}:{}}}}let a=Ya(n);if(a){let{items:e}=Wa(Ja(a));if(e.length>0)return{items:e,...t?{title:t}:{}}}return i?{}:null}default:return i?{}:null}}function xo(e){return(e.block?.contents??[]).filter(e=>!(e.type===`code`&&e.lang?.trim().toLowerCase()===`mermaid`))}function So(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(So(e,t+1));return c}).join(`
21
+ `)}function Co(e){return e.map((t,n)=>{let r=t.type===`list`?So(t):o(t);return n===0?r:`${`
22
+ `.repeat(no(e[n-1],t))}${r}`}).join(``).trim()}function wo(e,t){return W(e.length>1800?18:e.length>1100?21:e.length>650?24:28,t,!1)}function To(e,t){let{theme:n}=t,r=e.title??t.block?.title??``,i=xo(t),a=Co(i),o=to(i),s=[Hi(`bg`,n.colors.background)];return r&&s.push({type:`text`,id:`title`,content:{text:r,style:{fontSize:W(46,t,!0),fontFamily:U(t,`title`),fontWeight:`bold`,color:n.colors.text,textAlign:`left`,lineHeight:1.15,shadow:K(t)}},position:{x:`8%`,y:`9%`,width:`84%`,height:`10%`,anchor:`top-left`}}),a&&s.push({type:`text`,id:`body`,content:{text:a,...o?{html:o}:{},style:{fontSize:wo(a,t),fontFamily:U(t,`body`),color:n.colors.text,textAlign:`left`,lineHeight:1.35,shadow:K(t)}},position:{x:`8%`,y:r?`20%`:`10%`,width:`84%`,height:r?`72%`:`82%`,anchor:`top-left`}}),s}var Eo=.08,Do=.92,Oo=.47,ko=.38,Ao=1.1,jo=1.5,Mo=1.4;function No(e,t){let{stat:n,colorScheme:r=`blue`,accentImage:i}=e,{theme:a,viewport:o}=t,s=H(t,r),c=(e.description??``).trim(),l=c===n.trim()?``:c,u=(e.detail??``).trim(),d=i?sa(i.position):na,f=W(148,t,!0),p=W(32,t,!1),m=W(26,t,!1),h=[Hi(`bg`,Li(t,180))];i&&h.push(...ca(i,e.id,Ii(t,e.imageTreatment)));let g=o.height,_=parseFloat(d.textWidth)/100*o.width,v=Eo*g,y=(d.adjustY?Do+d.textYAdjust/100:Do)*g,b=Math.max(p*3,y-v),x=q({text:n,baseFontSize:f,minFontSize:Math.round(f*.4),maxWidthPx:_,maxHeightPx:b*ko,lineHeight:Ao}),S=x.heightPx+x.fontSize*.2,C=l||u?Math.round(x.fontSize*.3):0,w=u?q({text:u,baseFontSize:m,minFontSize:m,maxWidthPx:_,maxHeightPx:2*m*Mo,lineHeight:Mo}):null,T=w?w.heightPx+m*.3:0,E=w&&l?Math.round(p*.9):0,D=p*jo*.4,O=Math.max(p*jo,b*.95-S-C-E-T-D),k=l?q({text:l,baseFontSize:p,minFontSize:Math.max(18,Math.round(p*.6)),maxWidthPx:_,maxHeightPx:O,lineHeight:jo}):null,A=k?k.heightPx+D:0,j=S+C+A+E+T,M=Math.min(Math.max(v,Oo*g-j/2),Math.max(v,y-j)),N=M+S+C,P=N+A+E,F=e=>`${Number((e/g*100).toFixed(3))}%`,I=(e,t)=>({x:d.textCenterX,y:F(e+t/2),width:d.textWidth,height:F(t),anchor:`center`});return h.push({type:`text`,id:`stat`,content:{text:n,style:{fontSize:x.fontSize,fontFamily:U(t,`title`),fontWeight:`bold`,color:s.text,textAlign:`left`,lineHeight:Ao,shadow:K(t),shrinkToFit:!0,...x.maxLines?{maxLines:x.maxLines}:{}}},position:I(M,S),animation:zi(t,`statHighlight`,`entrance`,`subtle`)===`dramatic`?{type:`zoomIn`,duration:.4}:{type:`zoomIn`,duration:.6}}),k&&h.push({type:`text`,id:`description`,content:{text:l,style:{fontSize:k.fontSize,fontFamily:U(t,`body`),color:a.colors.textMuted,textAlign:`left`,lineHeight:jo,shadow:K(t),shrinkToFit:!0,...k.maxLines?{maxLines:k.maxLines}:{}}},position:I(N,A),animation:{type:`fadeIn`,duration:1,delay:.3}}),w&&h.push({type:`text`,id:`detail`,content:{text:u,style:{fontSize:w.fontSize,fontFamily:U(t,`body`),color:s.text,textAlign:`left`,lineHeight:Mo,shadow:K(t),shrinkToFit:!0,...w.maxLines?{maxLines:w.maxLines}:{}}},position:I(P,T),animation:{type:`fadeIn`,duration:1,delay:1}}),h}var Po=.11,Fo=.1,Io=.88,Lo=.5,Ro=.94,zo=90;function Bo(e,t){let{title:n,quote:r,attribution:i,accentImage:a}=e,{theme:o,viewport:s}=t,c=s.height,l=s.width,u=e=>`${Number((e/c*100).toFixed(3))}%`,d=a?sa(a.position):na,f=d.adjustY?d.textYAdjust/100*c:0,p=parseFloat(d.textWidth),m=parseFloat(d.textCenterX),h=`${Number((m-p/2).toFixed(3))}%`,g=p/100*l,_=W(48,t,!0),v=W(34,t,!0),y=W(26,t,!1),b=Math.max(o.typography.titleLineHeight??1.4,1.25),x=1.3,S=1.4,w=W(280,t,!0),T=[Hi(`bg`,Li(t,160))];a&&T.push(...ca(a,e.id,Ii(t,e.imageTreatment)));let E=Math.max(.05*c,(n?Po:Fo)*c+f),D=Io*c+f,O=E,k=E;if(n){let e=q({text:n,baseFontSize:v,minFontSize:Math.max(20,v*.7),maxWidthPx:g,maxHeightPx:.14*c,lineHeight:x});k=E+e.heightPx,O=k+.04*c,T.push({type:`text`,id:`quote-title`,content:{text:n,style:{fontSize:e.fontSize,fontFamily:U(t,`body`),fontWeight:`bold`,color:o.colors.textMuted,textAlign:`center`,lineHeight:x,shadow:K(t),shrinkToFit:!0,...e.maxLines?{maxLines:e.maxLines}:{}}},position:{x:h,y:u(E),width:d.textWidth,height:u(e.heightPx),anchor:`top-left`},animation:{type:`fadeIn`,duration:.8}})}let A=i?.035*c+.3*_:0,j=i?q({text:`\u2014 ${i}`,baseFontSize:y,minFontSize:Math.max(18,y*.75),maxWidthPx:g,maxHeightPx:.12*c,lineHeight:S}):null,M=j?j.heightPx:0,N=Math.max(_*b,(D-O-A-M)*Ro),P=q({text:r,baseFontSize:_,minFontSize:Math.max(22,_*.55),maxWidthPx:g,maxHeightPx:N,lineHeight:b}),F=P.heightPx+A+M,I=Math.min(Math.max(Lo*c+f-F/2,O),Math.max(O,D-F)),L=I+P.heightPx,ee=I-(n?k:Math.max(0,E-.05*c))-24,te=Math.min(w,ee/1.2);te>=zo&&T.push({type:`text`,id:`deco-quote`,content:{text:`“`,style:{fontSize:te,fontFamily:U(t,`title`),color:C(o.colors.text,.09),textAlign:`center`}},position:{x:d.textCenterX,y:u(I-12-te*.6),anchor:`center`}});let ne={type:`text`,id:`quote`,content:{text:r,style:{fontSize:P.fontSize,fontFamily:U(t,`title`),color:o.colors.text,textAlign:`center`,lineHeight:b,shadow:K(t),shrinkToFit:!0,...P.maxLines?{maxLines:P.maxLines}:{}}},position:{x:h,y:u(I),width:d.textWidth,height:u(P.heightPx),anchor:`top-left`},animation:G(t,`text`,{type:`fadeIn`,duration:2})};return T.push(ne),i&&j&&T.push({type:`text`,id:`attribution`,content:{text:`\u2014 ${i}`,style:{fontSize:j.fontSize,fontFamily:U(t,`body`),color:o.colors.textMuted,textAlign:`center`,lineHeight:S,shadow:K(t),shrinkToFit:!0,...j.maxLines?{maxLines:j.maxLines}:{}}},position:{x:h,y:u(L+A),width:d.textWidth,height:u(j.heightPx),anchor:`top-left`},animation:{type:`fadeIn`,duration:1,delay:1.5}}),T}var Vo=.08,Ho=.92,Uo=.47,Wo=.36,Go=1.3,Ko=1.5,qo=1.4;function Jo(e,t){let{fact:n,accentImage:r}=e,i=(e.explanation??``).trim(),a=(e.source??``).trim(),{theme:o,viewport:s}=t,c=r?sa(r.position):na,l=W(56,t,!0),u=W(34,t,!1),d=W(20,t,!1),f=[Hi(`bg`,Li(t,170))];r&&f.push(...ca(r,e.id,Ii(t,e.imageTreatment)));let p=s.height,m=parseFloat(c.textWidth)/100*s.width,h=Vo*p,g=(c.adjustY?Ho+c.textYAdjust/100:Ho)*p,_=Math.max(u*3,g-h),v=q({text:n,baseFontSize:l,minFontSize:Math.round(l*.5),maxWidthPx:m,maxHeightPx:_*Wo,lineHeight:Go}),y=v.heightPx+v.fontSize*.3,b=i?Math.round(v.fontSize*.8):0,x=a?q({text:a,baseFontSize:d,minFontSize:d,maxWidthPx:m,maxHeightPx:2*d*qo,lineHeight:qo}):null,S=x?x.heightPx+d*.3:0,C=x?Math.round(u*.9):0,w=u*Ko*.4,T=Math.max(u*Ko,_*.95-y-b-C-S-w),E=i?q({text:i,baseFontSize:u,minFontSize:Math.max(18,Math.round(u*.6)),maxWidthPx:m,maxHeightPx:T,lineHeight:Ko}):null,D=E?E.heightPx+w:0,O=y+b+D+C+S,k=Math.min(Math.max(h,Uo*p-O/2),Math.max(h,g-O)),A=k+y+b,j=A+D+C,M=e=>`${Number((e/p*100).toFixed(3))}%`,N=(e,t)=>({x:c.textCenterX,y:M(e+t/2),width:c.textWidth,height:M(t),anchor:`center`});return f.push({type:`text`,id:`fact`,content:{text:n,style:{fontSize:v.fontSize,fontFamily:U(t,`title`),fontWeight:`bold`,color:o.colors.text,textAlign:`left`,lineHeight:Go,shadow:K(t),shrinkToFit:!0,...v.maxLines?{maxLines:v.maxLines}:{}}},position:N(k,y),animation:G(t,`text`,{type:`fadeIn`,duration:1.5})}),E&&f.push({type:`text`,id:`explanation`,content:{text:i,style:{fontSize:E.fontSize,fontFamily:U(t,`body`),color:o.colors.textMuted,textAlign:`left`,lineHeight:Ko,shadow:K(t),shrinkToFit:!0,...E.maxLines?{maxLines:E.maxLines}:{}}},position:N(A,D),animation:G(t,`text`,{type:`fadeIn`,duration:1,delay:.8})}),x&&f.push({type:`text`,id:`source`,content:{text:a,style:{fontSize:x.fontSize,fontFamily:U(t,`body`),color:o.colors.textMuted,textAlign:`left`,lineHeight:qo,shadow:K(t),shrinkToFit:!0,...x.maxLines?{maxLines:x.maxLines}:{}}},position:N(j,S),animation:{type:`fadeIn`,duration:.8,delay:1.5}}),f}function Yo(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=H(t,a),f=H(t,o),p=c(u),m=l.stackColumns,h=m?`85%`:`42%`,g=W(36,t,!0),_=W(44,t,!0),v=W(22,t,!1),y=i&&!m?22:15,b=i&&!m?64:70,x=[{type:`shape`,id:`bg`,content:{shape:`rect`,fill:Li(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}%`}})}if(i){let{viewport:e}=t,n=m?3:4,r=m?13:y-2,a=1.2,o=q({text:i,baseFontSize:g,minFontSize:W(22,t,!0),maxWidthPx:90/100*e.width,maxHeightPx:(r-n)/100*e.height,lineHeight:a}),c=o.heightPx/e.height*100,l=n+Math.max(0,(r-n-c)/2);x.push({type:`text`,id:`header`,content:{text:i,style:{fontSize:o.fontSize,fontFamily:U(t,`title`),fontWeight:`bold`,color:s.colors.text,textAlign:`center`,lineHeight:a,...o.maxLines?{maxLines:o.maxLines}:{}}},position:{x:`${10/2}%`,y:`${l}%`,width:`90%`,anchor:`top-left`},animation:G(t,`text`,{type:`fadeIn`,duration:.8})})}let S,w,T,E;if(m)S=i?`30%`:`25%`,w=i?`40%`:`35%`,T=i?`60%`:`55%`,E=i?`70%`:`65%`;else{let e=y+b/2;S=`${e-4}%`,w=`${e+7}%`,T=`${e-4}%`,E=`${e+7}%`}x.push({type:`text`,id:`left-label`,content:{text:n.label,style:{fontSize:_,fontFamily:U(t,`body`),fontWeight:`bold`,color:d.text,textAlign:`left`,lineHeight:1.3}},position:{x:p.left.x,y:S,anchor:`center`,width:h},animation:G(t,`text`,{type:`fadeIn`,duration:1})}),n.sublabel&&x.push({type:`text`,id:`left-sublabel`,content:{text:n.sublabel,style:{fontSize:v,fontFamily:U(t,`body`),color:s.colors.textMuted,textAlign:`left`,lineHeight:1.4}},position:{x:p.left.x,y:w,anchor:`center`,width:h},animation:{type:`fadeIn`,duration:.8,delay:.3}});let D=W(64,t,!0),O=m?`48%`:`${y+b/2}%`,k=m?`↓`:`→`;return x.push({type:`text`,id:`connector`,content:{text:k,style:{fontSize:D,fontFamily:U(t,`title`),fontWeight:`bold`,color:C(s.colors.text,.45),textAlign:`center`}},position:{x:`50%`,y:O,anchor:`center`},animation:{type:`fadeIn`,duration:.6,delay:.4}}),x.push({type:`text`,id:`right-label`,content:{text:r.label,style:{fontSize:_,fontFamily:U(t,`body`),fontWeight:`bold`,color:f.text,textAlign:`left`,lineHeight:1.3}},position:{x:p.right.x,y:T,anchor:`center`,width:h},animation:G(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:U(t,`body`),color:s.colors.textMuted,textAlign:`left`,lineHeight:1.4}},position:{x:p.right.x,y:E,anchor:`center`,width:h},animation:{type:`fadeIn`,duration:.8,delay:.8}}),x}var Xo={neutral:`#63b3ed`,somber:`#e53e3e`,celebratory:`#68d391`},Zo=1.15,Qo=1.6,$o=1.4,es=.08,ts=.92,ns=.46,rs=.05,is=.28,as=.35;function os(e,t){let{date:n,description:r,footer:i,mood:a=`neutral`,accentImage:o}=e,{theme:s,viewport:c}=t,l=Xo[a],u=x(s.colors.background)>.5?b(l,.25):l,d=o?sa(o.position):na,f=parseFloat(d.textWidth)/100*c.width,p=es*c.height,m=(d.adjustY?(100-ia-3)/100*c.height:ts*c.height)-p,h=W(96,t,!0),g=W(30,t,!1),_=W(26,t,!1),v=q({text:n,baseFontSize:h,minFontSize:Math.round(h*.4),maxWidthPx:f,maxHeightPx:is*m,lineHeight:Zo}),y=v.heightPx,S=r.trim().length>0,C=i&&i.trim()?i:void 0,w=C?Gi(C,_,f)*_*$o:0,T=S||C?Math.round(h*.55):0,E=C?Math.round(g*1.1):0,D=Math.max(g*Qo,m-y-T-E-w-rs*c.height),O=S?q({text:r,baseFontSize:g,minFontSize:Math.max(18,Math.round(g*.6)),maxWidthPx:f,maxHeightPx:D,lineHeight:Qo}):null,k=O?O.heightPx:0,A=y+T+k+E+w,j=Math.max(p,p+ns*m-A/2),M=j+y+T,N=M+k+E,P=(e,t)=>{let n=Math.round(t);return{x:d.textCenterX,y:`${((e+n/2)/c.height*100).toFixed(3)}%`,width:d.textWidth,height:n,anchor:`center`}},F=[{type:`shape`,id:`bg`,content:{shape:`rect`,fill:Li(t,135)},position:{x:0,y:0,width:`100%`,height:`100%`}}];return o&&F.push(...ca(o,e.id,Ii(t,e.imageTreatment))),F.push({type:`text`,id:`date`,content:{text:n,style:{fontSize:v.fontSize,fontFamily:U(t,`title`),fontWeight:`bold`,color:u,textAlign:`left`,verticalAlign:`top`,lineHeight:Zo,shrinkToFit:!0,...v.maxLines?{maxLines:v.maxLines}:{},shadow:K(t)}},position:P(j,y+v.fontSize*as),animation:{type:`fadeIn`,duration:1.5}}),O&&F.push({type:`text`,id:`description`,content:{text:r,style:{fontSize:O.fontSize,fontFamily:U(t,`body`),color:s.colors.text,textAlign:`left`,verticalAlign:`top`,lineHeight:Qo,shrinkToFit:!0,...O.maxLines?{maxLines:O.maxLines}:{},shadow:K(t)}},position:P(M,k+O.fontSize*as),animation:{type:`fadeIn`,duration:2,delay:1}}),C&&F.push({type:`text`,id:`footer`,content:{text:C,style:{fontSize:_,fontFamily:U(t,`body`),color:s.colors.textMuted,textAlign:`left`,verticalAlign:`top`,lineHeight:$o,shrinkToFit:!0,shadow:K(t)}},position:P(N,w+_*as),animation:{type:`fadeIn`,duration:1,delay:3}}),F}function ss(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&&Vi(i),{theme:f,layout:p}=t,m=Ii(t,e.imageTreatment),h=W(30,t,!1),g=W(96,t,!0),_=W(36,t,!1),v=e.kenBurns,y=ra(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:U(t,`title`),fontWeight:`bold`,color:f.colors.text,textAlign:`center`,shadow:K(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:U(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:U(t,`body`),color:f.colors.text,textAlign:`center`,shadow:K(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}var cs=1.2,ls=1.5,us=.5,ds=.6,fs=1,ps=/[ᄀ-ᅟ⺀-〾ぁ-㏿㐀-䶿一-鿿ꀀ-꓏가-힣豈-﫿︰-﹏＀-⦆¢-₩]|\p{Extended_Pictographic}/u,ms=/mono|courier|consolas|menlo|fira code|source code/i;function hs(e){return ms.test(e)}function gs(e,t){let n=0;for(let r of e)n+=ps.test(r)?fs:t?ds:us;return n}function _s(e,t,n){let r=Math.floor(n/(t*us)),i=[];for(let t of e.split(`
23
+ `)){if(!t.trim()||r<=0){i.push(t);continue}let e=``;for(let n of t.split(/\s+/)){let t=e?`${e} ${n}`:n;if(t.length<=r){e=t;continue}e&&i.push(e);let a=n;for(;a.length>r;)i.push(a.slice(0,r)),a=a.slice(r);e=a}e&&i.push(e)}return i}function vs(e,t,n,r){let i=hs(r);if(!i&&!ps.test(e))return n;let a=n*.5,o=n*.02,s=n;for(;s>a;){let r=_s(e,t,s);if(Math.max(...r.map(e=>gs(e,i)))*t<=n)return s;s-=o}return a}function ys(e,t,n){let{imageSrc:r,imageAlt:i,imageWidth:a,imageHeight:o}=e,s=e.title?.trim()??``,c=e.body?.trim()??``,{theme:l,layout:u,viewport:d}=t,f=Ii(t,e.imageTreatment),p=(a??0)>0||(o??0)>0,m=u.stackColumns,h=U(t,`title`),g=U(t,`body`),_=W(48,t,!0),v=W(30,t,!0),y=W(24,t,!1),b=W(18,t,!1),x,S,C,w,T;m?(x=`0`,S=`0`,C=`100%`,w=`50%`,T=p?`contain`:`cover`):p?(x=`${n===`left`?5:55}%`,S=`5%`,C=`40%`,w=`90%`,T=`contain`):(x=n===`left`?`0`:`50%`,S=`0`,C=`50%`,w=`100%`,T=`cover`);let E=m?90:42,D=`${m?(100-E)/2:n===`left`?54:6}%`,O=E/100*d.width,k=`top-left`,A=`left`,j=(m?.56:.08)*d.height,M=(m?.92:.9)*d.height-j,N=s?vs(s,_,O,h):0,P=s?q({text:s,baseFontSize:_,minFontSize:v,maxWidthPx:N,maxHeightPx:M*.45,lineHeight:cs}):null,F=P?Math.min(Gi(s,P.fontSize,N),P.maxLines??1/0):0,I=P?F*P.fontSize*cs:0,L=s&&c?Math.round(_*.6):0,ee=c?vs(c,y,O,g):0,te=c?q({text:c,baseFontSize:y,minFontSize:b,maxWidthPx:ee,maxHeightPx:Math.max(b*ls,M-I-L),lineHeight:ls}):null,ne=te?.heightPx??0,re=I+L+ne,R=Math.max(j,j+(M-re)/2),ie=R,ae=R+I+L,oe=e=>`${(e/d.height*100).toFixed(2)}%`,se=e=>e>=O?`${E}%`:`${(e/d.width*100).toFixed(2)}%`,ce=[{type:`shape`,id:`feature-bg`,content:{shape:`rect`,fill:l.colors.background},position:{x:0,y:0,width:`100%`,height:`100%`}}];return r&&ce.push({type:`image`,id:`feature-image`,content:{src:r,alt:i??s,fit:T,...f?{treatment:f}:{}},position:{x,y:S,width:C,height:w}}),s&&P&&ce.push({type:`text`,id:`feature-title`,content:{text:s,style:{fontSize:P.fontSize,fontFamily:h,fontWeight:`bold`,color:l.colors.text,textAlign:A,lineHeight:cs,...P.maxLines?{maxLines:P.maxLines}:{}}},position:{x:D,y:oe(ie),anchor:k,width:se(N)},animation:G(t,`text`,{type:`fadeIn`,duration:.8})}),c&&te&&ce.push({type:`text`,id:`feature-body`,content:{text:c,style:{fontSize:te.fontSize,fontFamily:g,color:l.colors.textMuted,textAlign:A,lineHeight:ls,...te.maxLines?{maxLines:te.maxLines}:{}}},position:{x:D,y:oe(ae),anchor:k,width:se(ee)},animation:G(t,`text`,{type:`fadeIn`,duration:.8,delay:.2})}),ce}function bs(e,t){return ys(e,t,`left`)}function xs(e,t){return ys(e,t,`right`)}function Ss(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=W(64,t,!0),p=W(32,t,!1),m=ra(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:U(t,`title`),fontWeight:`bold`,color:u.colors.text,textAlign:`center`,shadow:K(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:U(t,`body`),color:u.colors.text,textAlign:`center`,shadow:K(t)}},position:{x:`50%`,y:d.captionY,anchor:`center`,width:d.maxTextWidth},animation:{type:`fadeIn`,duration:1,delay:.5}})),h}var Cs=.075,ws=.85,Ts=.1,Es=.9,Ds=.94,Os=1.2,ks=40,As=160,js=.6;function Ms(e){let t=e.trim().length;return t<=ks?1:1-Math.min(1,(t-ks)/(As-ks))*(1-js)}function Ns(e,t){let{text:n,colorScheme:r=`blue`}=e,{viewport:i}=t,a=H(t,r),o=i.height,s=i.width,c=e=>`${Number((e/o*100).toFixed(3))}%`,l=W(120,t,!0),u=Math.round(l*Ms(n)),d=(Es-Ts)*o,f=q({text:n,baseFontSize:u,minFontSize:Math.max(28,l/3),maxWidthPx:ws*s,maxHeightPx:d*Ds,lineHeight:Os}),p=Math.max(Ts*o,(Ts+(Es-Ts)/2)*o-f.heightPx/2);return[{type:`shape`,id:`bg`,content:{shape:`rect`,fill:`radial-gradient(ellipse at 50% 50%, ${a.bg} 0%, ${b(a.bg,.12)} 100%)`},position:{x:0,y:0,width:`100%`,height:`100%`}},{type:`text`,id:`impact-text`,content:{text:n,style:{fontSize:f.fontSize,fontFamily:U(t,`title`),fontWeight:`bold`,color:a.text,textAlign:`center`,lineHeight:Os,shadow:K(t),shrinkToFit:!0,...f.maxLines?{maxLines:f.maxLines}:{}}},position:{x:`${Cs*100}%`,y:c(p),width:`${ws*100}%`,height:c(f.heightPx),anchor:`top-left`},animation:zi(t,`fullBleedQuote`,`entrance`,`subtle`)===`dramatic`?{type:`zoomIn`,duration:.8}:{type:`fadeIn`,duration:1.5}}]}var Ps=1.2,Fs=34,Is=18,Ls=16,Rs=8,zs=2,Bs=20,Vs=34,Hs=26,Us=8,Ws=22,Gs=1.15;function Ks(e,t,n,r,i=!0){let a=i?`${n}.`:`•`,o=Math.max(e,a.length*e*.5),s=o+e*.35;return{markerWidthPx:o,bodyIndentPx:s,bodyWidthPx:Math.max(e,r-s),gapPx:e/t*Is}}function qs(e,t,n){let r=0;for(let i of e){let e=Gi(i,t,n.bodyWidthPx);r+=e*t*Ps+n.gapPx}return r}function Js(e,t){let{title:n,accentImage:r}=e,i=Array.isArray(e.items)?e.items:[],a=e.ordered!==!1,o=io(t.block?.contents),{theme:s}=t,c=r?sa(r.position):na,l=W(44,t,!0),u=W(Fs,t,!1),d=Math.min(u,W(Ls,t,!1)),f=[{type:`shape`,id:`bg`,content:{shape:`rect`,fill:`linear-gradient(155deg, ${s.colors.backgroundLight} 0%, ${s.colors.background} 100%)`},position:{x:0,y:0,width:`100%`,height:`100%`}}];r&&f.push(...ca(r,e.id,Ii(t,e.imageTreatment)));let p=parseFloat(c.textCenterX),m=parseFloat(c.textWidth),h=Number.isFinite(p)&&Number.isFinite(m)?p-m/2:8,g=`${h}%`,_=(Number.isFinite(m)?m/100:.85)*t.viewport.width,v=(r?.position===`bottom-strip`?100-ia-zs:100-Rs)-c.textYAdjust,y=Ks(u,u,i.length,_,a),b=n?Vs:Hs,x=b+qs(i,u,y)/t.viewport.height*100>v,S=Us-c.textYAdjust,C=x?S:Bs,w=b;x&&(w=S+(n?Wi(n,l,_)*l*Gs+Ws:0)/t.viewport.height*100),n&&f.push({type:`text`,id:`list-title`,content:{text:n,style:{fontSize:l,fontFamily:U(t,`title`),fontWeight:`bold`,color:s.colors.text,textAlign:`left`,shadow:K(t)}},position:{x:g,y:ha(`${C}%`,c),width:c.textWidth},animation:G(t,`text`,{type:`fadeIn`,duration:1})});let T=Math.max(0,(v-w)/100*t.viewport.height),E=u,D=y;for(;E>d&&qs(i,E,D)>T;)--E,D=Ks(E,u,i.length,_,a);let{markerWidthPx:O,bodyIndentPx:k,bodyWidthPx:A,gapPx:j}=D,M=`${h+k/t.viewport.width*100}%`,N=w;for(let e=0;e<i.length;e++){let n=i[e],r=o[e]?.text===n?o[e]?.html:void 0,l=Gi(n,E,A),u=G(t,`text`,{type:`fadeIn`,duration:.8,delay:.3+.3*e});f.push({type:`text`,id:`item-${e}-marker`,content:{text:a?`${e+1}.`:`•`,style:{fontSize:E,fontFamily:U(t,`body`),color:s.colors.text,textAlign:`right`,lineHeight:Ps,shadow:K(t)}},position:{x:g,y:ha(`${N}%`,c),width:O},animation:u}),f.push({type:`text`,id:`item-${e}`,content:{text:n,...r?{html:r}:{},style:{fontSize:E,fontFamily:U(t,`body`),color:s.colors.text,textAlign:`left`,lineHeight:Ps,shadow:K(t)}},position:{x:M,y:ha(`${N}%`,c),width:A,height:l*E*Ps+E*.5},animation:u});let d=l*E*Ps;N+=(d+j)/t.viewport.height*100}return f}var J=1.2;function Ys(e,t){let{images:n,caption:r,ambientMotion:i}=e;if(!n||n.length===0)return[];let a=r&&Vi(r),{theme:o,layout:s}=t,c=Ii(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=Xs(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=W(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:U(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 Xs(e,t,n){let r=50-J/2,i=t/2-J/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+J/2,w:100,h:i}]:[{x:0,y:0,w:r,h:t},{x:50+J/2,y:0,w:r,h:t}];case 3:{if(n){let e=t/3-J*2/3;return[{x:0,y:0,w:100,h:e},{x:0,y:t/3+J/3,w:100,h:e},{x:0,y:t*2/3+J*2/3,w:100,h:e}]}let e=60-J/2,r=40-J/2;return[{x:0,y:0,w:e,h:t},{x:60+J/2,y:0,w:r,h:i},{x:60+J/2,y:t/2+J/2,w:r,h:i}]}default:return[{x:0,y:0,w:r,h:i},{x:50+J/2,y:0,w:r,h:i},{x:0,y:t/2+J/2,w:r,h:i},{x:50+J/2,y:t/2+J/2,w:r,h:i}]}}var Zs=1.15,Qs=1.6,$s=1.4,ec=2,tc=.08,nc=.92,rc=.46,ic=.05,ac=.28,oc=.35;function sc(e,t){let{term:n,definition:r,origin:i,colorScheme:a=`blue`,accentImage:o}=e,{theme:s,viewport:c}=t,l=H(t,a),u=o?sa(o.position):na,d=parseFloat(u.textWidth),f=`${parseFloat(u.textCenterX)-d/2}%`,p=d/100*c.width,m=tc*c.height,h=(u.adjustY?(100-ia-3)/100*c.height:nc*c.height)-m,g=W(72,t,!0),_=W(32,t,!1),v=W(22,t,!1),y=q({text:n,baseFontSize:g,minFontSize:Math.round(g*.45),maxWidthPx:p,maxHeightPx:ac*h,lineHeight:Zs}),b=y.heightPx,x=r.trim().length>0,S=i&&i.trim()?i:void 0,C=S?Gi(S,v,p)*v*$s:0,w=Math.round(g*.4),T=x?Math.round(g*.4):0,E=S?Math.round(_*1):0,D=Math.max(_*Qs,h-b-w-ec-T-E-C-ic*c.height),O=x?q({text:r,baseFontSize:_,minFontSize:Math.max(18,Math.round(_*.6)),maxWidthPx:p,maxHeightPx:D,lineHeight:Qs}):null,k=O?O.heightPx:0,A=b+w+ec+T+k+E+C,j=Math.max(m,m+rc*h-A/2),M=j+b+w,N=M+ec+T,P=N+k+E,F=e=>`${(e/c.height*100).toFixed(3)}%`,I=(e,t)=>{let n=Math.round(t);return{x:u.textCenterX,y:F(e+n/2),width:u.textWidth,height:n,anchor:`center`}},L=[Hi(`bg`,Li(t,145))];return o&&L.push(...ca(o,e.id,Ii(t,e.imageTreatment))),L.push({type:`text`,id:`term`,content:{text:n,style:{fontSize:y.fontSize,fontFamily:U(t,`title`),fontWeight:`bold`,color:l.text,textAlign:`left`,verticalAlign:`top`,lineHeight:Zs,shrinkToFit:!0,...y.maxLines?{maxLines:y.maxLines}:{},shadow:K(t)}},position:I(j,b+y.fontSize*oc),animation:G(t,`text`,{type:`fadeIn`,duration:1.5})}),L.push({type:`shape`,id:`separator`,content:{shape:`rect`,fill:`${l.text}33`},position:{x:f,y:F(M),width:`30%`,height:`${ec}px`,anchor:`top-left`}}),O&&L.push({type:`text`,id:`definition`,content:{text:r,style:{fontSize:O.fontSize,fontFamily:U(t,`body`),color:s.colors.text,textAlign:`left`,verticalAlign:`top`,lineHeight:Qs,shrinkToFit:!0,...O.maxLines?{maxLines:O.maxLines}:{},shadow:K(t)}},position:I(N,k+O.fontSize*oc),animation:G(t,`text`,{type:`fadeIn`,duration:1,delay:.8})}),S&&L.push({type:`text`,id:`origin`,content:{text:S,style:{fontSize:v,fontFamily:U(t,`body`),color:s.colors.textMuted,textAlign:`left`,verticalAlign:`top`,lineHeight:$s,shrinkToFit:!0,shadow:K(t)}},position:I(P,C+v*oc),animation:{type:`fadeIn`,duration:.8,delay:1.5}}),L}function cc(e,t){let{leftLabel:n,rightLabel:r,unit:i,colorScheme:a=`blue`}=e,{theme:o,viewport:s}=t,c=H(t,a),l=Number.isFinite(e.leftValue)?e.leftValue:0,u=Number.isFinite(e.rightValue)?e.rightValue:0,d=W(28,t,!1),f=W(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:Li(t,180)},position:{x:0,y:0,width:`100%`,height:`100%`}},{type:`text`,id:`left-label`,content:{text:n,style:{fontSize:d,fontFamily:U(t,`body`),color:o.colors.textMuted}},position:{x:`15%`,y:`28%`}},{type:`text`,id:`left-value`,content:{text:m,style:{fontSize:f,fontFamily:U(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:U(t,`body`),color:o.colors.textMuted}},position:{x:`15%`,y:`50%`}},{type:`text`,id:`right-value`,content:{text:h,style:{fontSize:f,fontFamily:U(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}}]}var lc=14,uc=72,dc=10,fc=90,pc=.93,mc=1.35,hc=1.4;function gc(e,t){let{text:n,attribution:r,overMedia:i}=e,{theme:a,viewport:o}=t,s=e=>e/o.height*100,c=W(52,t,!0),l=Math.max(18,W(24,t,!0)),u=W(26,t,!1),d=W(200,t,!0),f=W(72,t,!0),p=uc/100*o.width,m=dc/100*o.height,h=(fc-dc)/100*o.height,g=r?`\u2014 ${r}`:``,_=r?Wi(g,u,p)*u*hc:0,v=r?c*.6:0,y=q({text:n,baseFontSize:c,minFontSize:l,maxWidthPx:p,maxHeightPx:Math.max(l*mc,(h-_-v)*pc),lineHeight:mc}),b=r?Math.max(16,y.fontSize*.6):0,x=y.heightPx+b+_,S=Math.max(m,o.height/2-x/2),w=s(S),T=s(S+y.heightPx+b),E=S-.03*o.height,D=Math.min(d,Math.floor(E/.6)),O=D>=f,k=w-s(D*.55),A=i?!0:K(t),j=i?`#ffffff`:a.colors.text,M=i?`rgba(255, 255, 255, 0.85)`:a.colors.textMuted,N=i?`rgba(255, 255, 255, 0.08)`:C(a.colors.text,.09),P={type:`text`,id:`quote-text`,content:{text:n,style:{fontSize:y.fontSize,fontFamily:U(t,`title`),color:j,textAlign:`center`,lineHeight:mc,shadow:A,shrinkToFit:!0,...y.maxLines?{maxLines:y.maxLines}:{}}},position:{x:`${lc}%`,y:`${w.toFixed(2)}%`,anchor:`top-left`,width:`${uc}%`},animation:G(t,`text`,{type:`fadeIn`,duration:2})},F=[];return O&&F.push({type:`text`,id:`deco-quote`,content:{text:`“`,style:{fontSize:D,fontFamily:U(t,`title`),color:N,textAlign:`center`}},position:{x:`50%`,y:`${k.toFixed(2)}%`,anchor:`center`}}),F.push(P),r&&F.push({type:`text`,id:`attribution`,content:{text:g,style:{fontSize:u,fontFamily:U(t,`body`),color:M,textAlign:`center`,lineHeight:hc,shadow:A}},position:{x:`${lc}%`,y:`${T.toFixed(2)}%`,anchor:`top-left`,width:`${uc}%`},animation:{type:`fadeIn`,duration:1,delay:1.5}}),F}function _c(){return Hi(`overlay`,`rgba(0, 0, 0, 0.55)`)}function vc(e,t){let{text:n,attribution:r,backgroundImage:i,ambientMotion:a}=e,o=Ii(t,e.imageTreatment),s=[];return i?.src?s.push({type:`image`,id:`bg-image`,content:{src:i.src,alt:i.alt,fit:`cover`,credit:i.credit,license:i.license,...o?{treatment:o}:{}},position:{x:0,y:0,width:`100%`,height:`100%`},animation:ra(a,15)},_c()):s.push(Hi(`bg`,Li(t,160))),s.push(...gc({text:n,attribution:r,overMedia:!!i?.src},t)),s}function yc(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&&Vi(c),{theme:p}=t,m=Math.max(a,o??a+Math.max(0,e.duration)),h=W(30,t,!1),g=W(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:U(t,`body`),color:p.colors.text,textAlign:`center`,shadow:K(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:U(t,`body`),color:C(p.colors.text,.65),textAlign:`right`}},position:{x:`96%`,y:`96%`,anchor:`bottom-right`}}),_}function bc(e,t){let{text:n,attribution:r,backgroundVideo:i}=e,a=[];return i?.src?a.push({type:`video`,id:`bg-video`,content:{src:i.src,posterSrc:i.posterSrc,alt:i.alt,fit:`cover`,clipStart:i.clipStart??0,clipEnd:i.clipEnd??(i.clipStart??0)+e.duration,credit:i.credit,license:i.license},position:{x:0,y:0,width:`100%`,height:`100%`}},_c()):a.push(Hi(`bg`,Li(t,160))),a.push(...gc({text:n,attribution:r,overMedia:!!i?.src},t)),a}var xc=10;function Sc(e,t){let{title:n,headers:r,rows:i,align:a,colorScheme:o}=e,{theme:s,viewport:c}=t,l=Array.isArray(r)?r:[],u=Array.isArray(i)?i:[],d=H(t,o),f=W(48,t,!0),p=W(28,t,!1),m=[Hi(`bg`,Li(t,170))],h=Math.max(1,Math.min(u.length,xc)+ +(l.length>0)),g=Math.min(74,h*p*2.4/c.height*100),_=n?f*2.2*100/c.height:0,v=Math.max(8,(100-_-g)/2);return n&&m.push({type:`text`,id:`title`,content:{text:n,style:{fontSize:f,fontFamily:U(t,`title`),fontWeight:`bold`,color:s.colors.text,textAlign:`center`,shadow:K(t)}},position:{x:`50%`,y:`${v+_/2}%`,width:`80%`,anchor:`center`},animation:{type:`fadeIn`,duration:.8}}),m.push({type:`table`,id:`table`,content:{headers:l,rows:u,maxVisibleRows:xc,align:a,style:{headerBackground:d.accent,headerColor:S(d.accent),cellBackground:C(s.colors.text,.04),cellColor:s.colors.text,borderColor:C(s.colors.text,.15),fontSize:p,fontFamily:U(t,`body`),headerFontFamily:U(t,`title`),borderRadius:8}},position:{x:`10%`,y:`${v+_}%`,width:`80%`,height:`${g}%`},animation:{type:`fadeIn`,duration:1,delay:n?.4:0}}),m}var Cc={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`}},wc={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`}},Tc={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`}},Ec={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:Cc},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:Cc},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:Cc},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:wc},content:{summary:`Preserves the complete heading and body; supplemental media receives a companion field.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:wc},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:wc},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:wc},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:wc},twoColumn:{summary:`Text comparison by default; supplemental media stacks below the dense two-column panel.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:Tc},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:wc},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:Cc},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:wc},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:wc},comparisonBar:{summary:`Data bars are primary; supplemental media stacks below to preserve horizontal scale.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:Tc},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:Tc},barChart:{summary:`The chart remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:Tc},columnChart:{summary:`The chart remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:Tc},pieChart:{summary:`The chart remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:Tc},donutChart:{summary:`The chart remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:Tc},lineChart:{summary:`The chart remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:Tc},areaChart:{summary:`The chart remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:Tc},scatterChart:{summary:`The chart remains wide; supplemental media stacks below the dense data region.`,noMedia:`template-default`,ownership:`supplemental`,unconsumedMedia:`reserved-slot`,variants:Tc},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 Dc(e){if(e)return Ec[e]}var Oc=1.25;function kc(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=Ac(e,o,i);for(;o>10&&s*o*1.25>a;)o--,s=Ac(e,o,i);return{fontSize:o,lineCount:s,firstLineOffset:s===1?0:-((s-1)*o*Oc)/2,textWidth:i}}function Ac(e,t,n){return e.split(`
24
+ `).reduce((e,r)=>e+jc(r,t,n),0)}function jc(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)}function Y(e,t,n,r,i){return{x:e.width*t,y:e.height*n,width:e.width*r,height:e.height*i}}function Mc(e,t){if(e>1)return`multiple`;let n=t[0]??16/9;return n<.8?`tall`:n>1.25?`wide`:`square`}function Nc(e,t){return t===`portrait`?{contentRect:Y(e,.06,.04,.88,.3),mediaRect:Y(e,.06,.39,.88,.55),fontScale:.76}:t===`square`?{contentRect:Y(e,.05,.04,.9,.33),mediaRect:Y(e,.07,.42,.86,.51),fontScale:.72}:{contentRect:Y(e,.04,.03,.92,.32),mediaRect:Y(e,.08,.4,.84,.52),fontScale:.72}}function Pc(e,t){let n=t===`square`;return{contentRect:Y(e,n?.05:.04,.05,n?.42:.43,.9),mediaRect:Y(e,n?.52:.53,.07,.43,.86),fontScale:.72}}function Fc(e,t,n){return t===`portrait`?{contentRect:Y(e,.06,.04,.88,n?.41:.36),mediaRect:Y(e,.06,n?.5:.45,.88,n?.44:.49),fontScale:n?.42:.44}:t===`square`?{contentRect:Y(e,.05,.04,.9,n?.43:.36),mediaRect:Y(e,.07,n?.52:.45,.86,n?.41:.48),fontScale:n?.45:.46}:{contentRect:Y(e,.05,.03,.9,n?.46:.35),mediaRect:Y(e,.07,n?.55:.43,.86,n?.38:.49),fontScale:n?.5:.48}}function Ic(e,t){let n=_(e);if(n===`portrait`)switch(t){case`tall`:return Y(e,.55,.5,.38,.44);case`square`:return Y(e,.49,.58,.44,.35);case`multiple`:return Y(e,.07,.67,.86,.27);case`wide`:return Y(e,.07,.71,.86,.23)}if(n===`square`)switch(t){case`tall`:return Y(e,.68,.1,.27,.8);case`square`:return Y(e,.55,.52,.4,.4);case`multiple`:return Y(e,.08,.62,.84,.31);case`wide`:return Y(e,.08,.68,.84,.27)}switch(t){case`tall`:return Y(e,.7,.1,.26,.8);case`square`:return Y(e,.62,.22,.34,.56);case`multiple`:return Y(e,.52,.5,.44,.42);case`wide`:return Y(e,.54,.58,.42,.34)}}function Lc(e,t){let n=_(t);switch(e){case`title-stack`:return Nc(t,n);case`split`:return Pc(t,n);case`text-stack`:return Fc(t,n,!1);case`dense-stack`:return Fc(t,n,!0)}}function Rc(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 zc(e){return e===0||e===`0`||e===`0%`}function Bc(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 zc(n.x)&&zc(n.y)&&r&&i}function Vc(e,t,n){let r={...e,x:t.x+Rc(e.x,n.width)/n.width*t.width,y:t.y+Rc(e.y,n.height)/n.height*t.height};return e.width!==void 0&&(r.width=Rc(e.width,n.width)/n.width*t.width),e.height!==void 0&&(r.height=Rc(e.height,n.height)/n.height*t.height),r}function Hc(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+Rc(e.position.x,t.width)*i,y:n.y+Rc(e.position.y,t.height)*a,...e.position.width===void 0?{}:{width:Rc(e.position.width,t.width)*i},...e.position.height===void 0?{}:{height:Rc(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:Uc(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 Uc(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 Wc(e,t,n,r,i){return Gc(e.map(e=>{if(Bc(e,n))return e;let i=Vc(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 Gc(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=Ui(o.content.text,p,l,o.content.style.lineHeight??1.15),t=c?Ui(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 Kc(e,t,n,r){let i=e.width?Rc(e.width,t.width):n,a=e.height?Rc(e.height,t.height):r,o=Rc(e.x,t.width),s=Rc(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 qc(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 Jc(e,t){let n=e.filter(e=>e.type!==`shape`&&e.type!==`path`&&e.type!==`mermaid`).map(e=>Kc(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?Y(t,.06,.08,.88,.84):[Y(t,.52,.12,.44,.76),Y(t,.04,.12,.44,.76),Y(t,.15,.53,.7,.41)].reduce((e,t)=>n.reduce((e,n)=>e+qc(t,n),0)<n.reduce((t,n)=>t+qc(e,n),0)?t:e)}function Yc(e,t,n,r,i){let a=Dc(t),o=Mc(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:Ic(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:Jc(e,n),framed:!1};let u=_(n),d=Lc(a.variants[u][o],n);return{layers:Wc(e,d.contentRect,n,d.fontScale,t??``),mediaRect:d.mediaRect,framed:!0}}var Xc=180,Zc=64,Qc=80,$c=Qc,el=1.15,tl=2,nl=36,rl=1.35,il=3,al=28,ol=.3,sl=.72,cl=1.8,ll=.35;function ul(e){let t=e?.contents;if(!t||t.length===0)return{count:0,aspectRatios:[]};let n=co(t),r=new Set(n.map(e=>e.src)),i=new Set,a=oo(t).filter(e=>r.has(e.src)||i.has(e.src)?!1:(i.add(e.src),!0)),o=t.filter(e=>e.type===`code`&&e.lang?.trim().toLowerCase()===`mermaid`&&e.value.trim().length>0),s=[...a.map(e=>e.width&&e.height?e.width/e.height:void 0),...n.map(()=>16/9),...o.map(()=>16/9)];return{count:s.length,aspectRatios:s}}function dl(e){let t=e?.contents;return t?t.filter(e=>e.type===`paragraph`||e.type===`blockquote`||e.type===`list`).map(e=>o(e).trim()).filter(Boolean).join(`
25
+ `).trim():``}function fl(e,t){let n={x:0,y:0,width:e.width,height:e.height};if(!t)return n;let r=[{x:0,y:0,width:e.width,height:t.y},{x:0,y:0,width:t.x,height:e.height},{x:0,y:t.y+t.height,width:e.width,height:e.height-(t.y+t.height)},{x:t.x+t.width,y:0,width:e.width-(t.x+t.width),height:e.height}].filter(t=>t.width>=e.width*ll&&t.height>=e.height*ll);return r.length===0?n:r.reduce((e,t)=>t.width*t.height>e.width*e.height?t:e)}function pl(e,t,n){let{viewport:r}=n,i=ul(n.block),a=i.count>0?Yc([],e,r,i.count,i.aspectRatios).mediaRect:void 0,o=fl(r,a),s=Math.max(1,o.width-Qc*2),c;if(t){let e=W(40,n,!0);c={...q({text:t,baseFontSize:e,minFontSize:Math.round(e*.7),maxWidthPx:s,maxHeightPx:tl*e*el,lineHeight:el}),widthPx:s}}let l,u=dl(n.block);if(u){let e=W(22,n,!1),t=Math.min(e,W(16,n,!1)),i=Math.min(s,r.width*sl);l={text:u,fit:q({text:u,baseFontSize:e,minFontSize:t,maxWidthPx:i,maxHeightPx:Math.min(il*e*rl,o.height*ol),lineHeight:rl}),widthPx:i}}let d=c?c.heightPx+nl:0,f=l?al+l.fit.heightPx:0;return{region:o,...c?{title:c}:{},...l?{description:l}:{},titleBlockPx:d,descriptionBlockPx:f,availW:s,availH:Math.max(1,o.height-Qc*2-d-f),...a?{mediaRect:a}:{}}}function ml(e,t,n){let r=Math.min(e.availW/t,e.availH/n,cl),i=t*r,a=n*r,o=e.titleBlockPx+a+e.descriptionBlockPx,s=e.region.y+Math.max(Qc/2,(e.region.height-o)/2),c=e.region.x+Qc+(e.availW-i)/2,l=s+e.titleBlockPx;return{scale:r,scaledW:i,scaledH:a,groupTop:s,offsetX:c,offsetY:l,descriptionY:l+a+al}}function hl(e,t,n,r,i){let a=n.title;if(a)return{type:`text`,id:e,content:{text:t,style:{fontSize:a.fontSize,fontFamily:U(i,`title`),fontWeight:`bold`,color:i.theme.colors.text,textAlign:`center`,lineHeight:el,maxLines:a.maxLines??tl,shrinkToFit:!0}},position:{x:n.region.x+Qc,y:r.groupTop,width:a.widthPx,anchor:`top-left`}}}function gl(e,t,n,r){let i=t.description;if(!i)return;let{fit:a,widthPx:o}=i;return{type:`text`,id:e,content:{text:i.text,style:{fontSize:a.fontSize,fontFamily:U(r,`body`),color:r.theme.colors.textMuted,textAlign:`center`,lineHeight:rl,maxLines:a.maxLines??Math.max(il,a.lines)}},position:{x:t.region.x+(t.region.width-o)/2,y:n.descriptionY,width:o,anchor:`top-left`}}}function _l(e){let t=Aa(e.children??[]);return{nodes:t.nodes.map(e=>({id:e.id,label:e.label,x:e.x,y:e.y,w:Xc,h:Zc,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 vl(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:Xc,h:typeof e.h==`number`&&Number.isFinite(e.h)&&e.h>0?e.h:Zc,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 yl(e,t){let{theme:n,viewport:r,children:i=[]}=t,a=e.colorScheme?H(t,e.colorScheme):void 0,o=i.length>0?_l(t):e.nodes&&e.nodes.length>0?vl(e):{nodes:[],edges:[]};if(o.nodes.length===0)return[{type:`text`,id:`diagram-empty`,content:{text:e.title??`Empty diagram`,style:{fontSize:W(36,t,!0),fontFamily:U(t,`title`),color:n.colors.textMuted,textAlign:`center`,maxLines:3,shrinkToFit:!0}},position:{x:`50%`,y:`50%`,anchor:`center`,width:r.width-Qc*2}}];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=pl(`diagram`,e.title,t),f=ml(d,Math.max(1,c-s),Math.max(1,u-l)),{scale:p,offsetX:m,offsetY:h}=f,g=Math.min(Math.max(p,1),1.5),_=Math.round(2*g),v=e=>({x:m+(e.x-s)*p,y:h+(e.y-l)*p,w:e.w*p,h:e.h*p}),y=[];if(e.title){let n=hl(`diagram-title`,e.title,d,f,t);n&&y.push(n)}let b=o.nodes.filter(e=>e.isContainer).sort((e,t)=>e.depth-t.depth||e.y-t.y||e.x-t.x),x=o.nodes.filter(e=>!e.isContainer);for(let e of b){let t=v(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,_-1),borderRadius:10},position:{x:t.x,y:t.y,width:t.w,height:t.h}};y.push(r)}let S=new Map;for(let e of o.nodes){let t=v(e);S.set(e.id,{cx:t.x+t.w/2,cy:t.y+t.h/2,rx:t.w/2,ry:t.h/2})}let C=e.startStyle??`none`,w=e.endStyle??`arrow`,T=Pe(e.lineStyle);for(let r of o.edges){let i=S.get(r.source),o=S.get(r.target);if(!i||!o)continue;let s=r.directed?w:`none`,c=Oe(i,o),l=r.sourceAnchor?Ee(i,r.sourceAnchor):c.start,u=r.targetAnchor?Ee(o,r.targetAnchor):c.end,d={type:`path`,id:`edge-${r.id}`,content:{d:je(r.routing??e.edgeStyle??`curved`,l,u),stroke:a?.text??n.colors.primary,strokeWidth:_,fill:`none`,...T?{dasharray:T}:{},...C===`none`?{}:{startMarker:C},...s===`none`?{}:{endMarker:s}},position:{x:0,y:0,width:`100%`,height:`100%`}};if(y.push(d),r.label){let e=(i.cx+o.cx)/2,a=(i.cy+o.cy)/2,s=W(Math.round(18*g),t,!1),c={type:`text`,id:`edge-label-${r.id}`,content:{text:r.label,style:{fontSize:s,fontFamily:U(t,`body`),color:n.colors.textMuted,textAlign:`center`}},position:{x:e,y:a-s*.9,anchor:`center`}};y.push(c)}}for(let r of x){let i=v(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:_,borderRadius:e.nodeShape===`pill`?i.h/2:10},position:{x:i.x,y:i.y,width:i.w,height:i.h}};y.push(o);let s=W(Math.round(22*g),t,!1),c=kc(r.label,i.w,i.h,s),l={type:`text`,id:`node-label-${r.id}`,content:{text:r.label,style:{fontSize:c.fontSize,fontFamily:U(t,`body`),fontWeight:`bold`,color:a?.text??n.colors.text,textAlign:`center`,lineHeight:Oc}},position:{x:i.x+i.w/2,y:i.y+i.h/2+c.firstLineOffset,anchor:`center`,width:c.textWidth}};y.push(l)}for(let e of b){let r=v(e),i=W(Math.round(20*g),t,!1),a={type:`text`,id:`node-label-${e.id}`,content:{text:e.label.split(`
26
+ `)[0]??``,style:{fontSize:i,fontFamily:U(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}};y.push(a)}let E=gl(`diagram-description`,d,f,t);return E&&y.push(E),y}function bl(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=bl(e.children);t.push({id:typeof e.id==`string`&&e.id?e.id:xl(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 xl(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`node`}function Sl(e,t){let{theme:n,viewport:r}=t,i=H(t,e.colorScheme),a=bl(e.items),o=W(48,t,!0),s=W(28,t,!1),c=[Hi(`bg`,Li(t,170))];if(a.length===0)return c.push({type:`text`,id:`tree-empty`,content:{text:e.title??`Empty tree`,style:{fontSize:o,fontFamily:U(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:U(t,`title`),fontWeight:`bold`,color:n.colors.text,textAlign:`center`,shadow:K(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:U(t,`body`),monoFontFamily:U(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 Cl=e=>Math.max(0,Math.min(1,e)),wl=(e,t,n)=>Math.max(t,Math.min(n,e));function Tl(e){return e.replace(/[^a-zA-Z0-9_-]+/g,`-`).replace(/^-+|-+$/g,``)||`item`}function El(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:Cl(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 Dl(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 Ol(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 kl(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 Al(e,t){let{theme:n,viewport:r}=t,i=H(t,e.colorScheme),a=El(e.tracks),o=[Hi(`bg`,Li(t,165))],s=W(44,t,!0),c=W(22,t,!1),l=W(24,t,!1),u=W(17,t,!1);if(e.title&&o.push({type:`text`,id:`timeline-title`,content:{text:e.title,style:{fontSize:s,fontFamily:U(t,`title`),fontWeight:`bold`,color:n.colors.text,textAlign:`center`,shadow:K(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:W(36,t,!0),fontFamily:U(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),j=a.map(e=>{let t=e.events.map(e=>Cl(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}),M=[],N=new Map;a.forEach((e,r)=>{let i=_+y*(r+.5),a=.12+r*.12,s=Tl(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:U(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:U(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*Cl(e.position),y:i};M.push(n),N.has(e.id)||N.set(e.id,n)})}),Dl(e.links,new Set(N.keys())).forEach((e,i)=>{let a=N.get(e.source),s=N.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-${Tl(e.source)}-${Tl(e.target)}-${i}`,content:{d:kl(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,Ui(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=wl(f,u/2+8,r.width-u/2-8),m=wl(m,A*1.5,r.height-12),o.push({type:`text`,id:`timeline-link-label-${i}`,content:{text:e.label,style:{fontSize:A,fontFamily:U(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 P=Math.min(78,Math.max(34,y*.2));for(let e of M){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*P,p=.28+a*.12+s*.07,m=`${Tl(i.id)}-${a}-${s}`,h=j[a]??b,g=wl(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*P,p+.03)}}let v=i.marker??`filled`;if(v===`diamond`)o.push(Ol(`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(Ui(i.label,k,D,e),k*e*2),s=Math.max(1,Math.round(a/(k*e))),c=wl(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:U(t,`body`),fontWeight:`bold`,color:n.colors.text,textAlign:`center`,lineHeight:e,shadow:K(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(Ui(i.description,A,D,f),A*f*h),v=Math.max(1,Math.round(_/(A*f))),y=l+d*P,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=wl(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:U(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 jl=`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(`.`),Ml={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 Nl(e){return e?Ml[e.toLowerCase()]??null:null}function Pl(e){return Nl(e)!=null}var Fl={gapX:180,gapY:140,gridPad:80,gridOriginX:80,gridOriginY:80},Il={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}},Ll={w:120,h:120};function Rl(e){return Il[e]??Ll}function zl(e,t={}){let n={...Fl,...t},r=[],i=[],a=[],o=[];for(let t of e){let e=Nl(t.template),n=t.templateOverrides??{},s=t.title??``,c=Yl(t);if(!e){r.push(`Child "${t.id}" is not a shape (annotation "${t.template??`—`}") and was skipped`);continue}let l=Bl(n,`from`),u=Bl(n,`to`);if((e===`line`||e===`arrow`)&&(l||u)){o.push({id:t.id,kind:e,from:l??``,to:u??``,...s?{label:s}:{},...Jl(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}:{},...Jl(n,`arrow`),source:t.id});let d=Rl(e),f=Vl(n,`x`)??(typeof t.x==`number`?t.x:void 0),p=Vl(n,`y`)??(typeof t.y==`number`?t.y:void 0),m={id:t.id,kind:e,x:f??0,y:p??0,width:Vl(n,`width`)??Vl(n,`w`)??d.w,height:Vl(n,`height`)??Vl(n,`h`)??d.h,pinned:f!=null&&p!=null,label:s,...c?{sublabel:c}:{},...Ul(n)};if(e===`path`){let e=Bl(n,`d`);e&&(m.d=e)}e===`text`&&(m.text=Bl(n,`text`)??s??c??``),Vl(n,`borderRadius`)!=null&&(m.borderRadius=Vl(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 Bl(e,t){let n=e[t];if(n==null)return;let r=n.replace(/,\s*$/,``).trim();return r.length>0?r:void 0}function Vl(e,t){let n=Bl(e,t);if(n==null)return;let r=Number(n);return Number.isFinite(r)?r:void 0}function Hl(e){let t={},n=Bl(e,`stroke`),r=Vl(e,`strokeWidth`),i=Bl(e,`dasharray`);return n&&(t.stroke=n),r!=null&&(t.strokeWidth=r),i&&(t.dasharray=i),t}function Ul(e){let t=Bl(e,`fill`);return{...Hl(e),...t?{fill:t}:{}}}var Wl={none:`none`,arrow:`arrow`,triangle:`arrow`,filled:`arrow`,open:`open`,v:`open`,diamond:`diamond`,circle:`circle`,dot:`circle`,square:`square`,box:`square`},Gl={straight:`straight`,direct:`straight`,orthogonal:`orthogonal`,elbow:`orthogonal`,step:`orthogonal`,curved:`curved`,curve:`curved`,bezier:`curved`};function Kl(e){return e?Wl[e.toLowerCase()]:void 0}function ql(e){return e?Gl[e.toLowerCase()]:void 0}function Jl(e,t){let n=Hl(e),r=n.dasharray??Pe(Bl(e,`lineStyle`));return{...n,...r?{dasharray:r}:{},startMarker:Kl(Bl(e,`startStyle`))??`none`,endMarker:Kl(Bl(e,`endStyle`))??(t===`arrow`?`arrow`:`none`),routing:ql(Bl(e,`routing`))??`straight`}}function Yl(e){return!e.contents||e.contents.length===0?``:e.contents.map(e=>o(e)).join(` `).trim()}var Xl=$c;function Zl(e,t){let{theme:n,children:r=[]}=t,i=H(t,e.colorScheme),a=e.stroke??i.text??n.colors.text,o=e.fill??`none`,s=zl(r);if(s.shapes.length===0&&s.connectors.length===0)return[tu(e,t)];let c=Math.min(...s.shapes.map(e=>e.x)),l=Math.max(...s.shapes.map(e=>e.x+e.width)),u=Math.min(...s.shapes.map(e=>e.y)),d=Math.max(...s.shapes.map(e=>e.y+e.height)),f=pl(`drawing`,e.title,t),p=ml(f,Math.max(1,l-c),Math.max(1,d-u)),{scale:m,offsetX:h,offsetY:g}=p,_=e=>h+(e-c)*m,v=e=>g+(e-u)*m,y=Math.min(Math.max(m,1),1.5),b=[];if(e.title){let n=hl(`drawing-title`,e.title,f,p,t);n&&b.push(n)}let x=new Map;for(let e of s.shapes){let t=_(e.x),n=v(e.y),r=e.width*m,i=e.height*m;x.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 s.connectors){let n=x.get(e.from),r=x.get(e.to);if(!n||!r)continue;let{start:i,end:o}=Oe(n,r),s={type:`path`,id:`connector-${e.id}`,content:{d:je(e.routing,i,o),stroke:e.stroke??a,strokeWidth:e.strokeWidth??Math.round(2*y),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%`}};b.push(s),e.label&&b.push(eu(e,n,r,t,y))}for(let e of s.shapes){let n=_(e.x),r=v(e.y),i=e.width*m,s=e.height*m;b.push(...Ql(e,n,r,i,s,t,a,o,y))}let S=gl(`drawing-description`,f,p,t);return S&&b.push(S),b}function Ql(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($l(`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 ${nu(t)} ${nu(n)} L ${nu(t+r)} ${nu(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=be(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($l(`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($l(`shape-sublabel-${e.id}`,e.sublabel,t+r/2,n+i+14*c,r,a,a.theme.colors.textMuted,!1,c)),l}function $l(e,t,n,r,i,a,o,s,c){return{type:`text`,id:e,content:{text:t,style:{fontSize:W(Math.round((s?22:18)*c),a,!1),fontFamily:U(a,`body`),...s?{fontWeight:`bold`}:{},color:o,textAlign:`center`}},position:{x:n,y:r,anchor:`center`,width:i}}}function eu(e,t,n,r,i){let a=W(Math.round(18*i),r,!1);return{type:`text`,id:`connector-label-${e.id}`,content:{text:e.label??``,style:{fontSize:a,fontFamily:U(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 tu(e,t){return{type:`text`,id:`drawing-empty`,content:{text:e.title??`Empty drawing`,style:{fontSize:W(36,t,!0),fontFamily:U(t,`title`),color:t.theme.colors.textMuted,textAlign:`center`,maxLines:3,shrinkToFit:!0}},position:{x:`50%`,y:`50%`,anchor:`center`,width:t.viewport.width-Xl*2}}}function nu(e){return Math.round(e*100)/100}var ru=`#1e293b`,iu={w:300,h:80},au={w:160,h:90},ou={w:320,h:240};function su(e,t,n={}){let r=n.ink??ru,i=[],a=[];for(let t of e){let e=t.templateOverrides??{},n=(t.template??``).toLowerCase(),o=Z(e,`x`)??0,s=Z(e,`y`)??0;if(n===`image`||n===`img`){let n=X(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:Z(e,`width`)??ou.w,height:Z(e,`height`)??ou.h},content:{src:n,alt:X(e,`alt`)??``,...X(e,`fit`)?{fit:X(e,`fit`)}:{}}};i.push(r);continue}let c=Nl(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=lu(t)||t.title||``,a={id:t.id,type:`text`,position:{x:o,y:s,width:Z(e,`width`)??iu.w,height:Z(e,`height`)??iu.h},content:{text:n,style:cu(e,r)}};i.push(a);continue}let l=Z(e,`width`)??Z(e,`w`)??au.w,u=Z(e,`height`)??Z(e,`h`)??au.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,...X(e,`fill`)?{fill:X(e,`fill`)}:{},...X(e,`stroke`)?{stroke:X(e,`stroke`)}:{},...Z(e,`strokeWidth`)==null?{}:{strokeWidth:Z(e,`strokeWidth`)},...X(e,`borderStyle`)?{borderStyle:X(e,`borderStyle`)}:{},...c===`rect`&&Z(e,`borderRadius`)!=null?{borderRadius:Z(e,`borderRadius`)}:{}}};i.push(n);continue}let d=`M ${uu(o)} ${uu(s)} L ${uu(o+l)} ${uu(s+u)}`,f=d,p=`none`,m=`none`;c===`path`?(f=X(e,`d`)??d,p=X(e,`fill`)??`none`):c===`arrow`?m=`arrow`:c!==`line`&&(f=be(c,o,s,l,u)??d,p=X(e,`fill`)??`none`);let h={id:t.id,type:`path`,position:{x:0,y:0,width:`100%`,height:`100%`},content:{d:f,stroke:X(e,`stroke`)??r,strokeWidth:Z(e,`strokeWidth`)??2,fill:p,...X(e,`dasharray`)?{dasharray:X(e,`dasharray`)}:{},...m===`none`?{}:{endMarker:m}}};i.push(h)}return{layers:i,warnings:a}}function cu(e,t){let n={fontSize:Z(e,`fontSize`)??32,color:X(e,`color`)??t},r=X(e,`fontFamily`);r&&(n.fontFamily=r);let i=X(e,`fontWeight`);(i===`bold`||i===`normal`)&&(n.fontWeight=i);let a=X(e,`fontStyle`);(a===`italic`||a===`normal`)&&(n.fontStyle=a);let o=X(e,`align`);(o===`left`||o===`center`||o===`right`)&&(n.textAlign=o);let s=X(e,`valign`);(s===`top`||s===`middle`||s===`bottom`)&&(n.verticalAlign=s);let c=Z(e,`lineHeight`);c!=null&&(n.lineHeight=c);let l=Z(e,`padding`);l!=null&&(n.padding=l);let u=X(e,`background`);return u&&(n.background=u),n}function X(e,t){let n=e[t];if(n==null)return;let r=n.replace(/,\s*$/,``).trim();return r.length>0?r:void 0}function Z(e,t){let n=X(e,t);if(n==null)return;let r=Number(n);return Number.isFinite(r)?r:void 0}function lu(e){return!e.contents||e.contents.length===0?``:e.contents.map(e=>o(e)).join(`
27
+ `).trim()}function uu(e){return Math.round(e*100)/100}function du(e,t){let{theme:n,viewport:r,children:i=[]}=t,{layers:a}=su(i,r,{ink:n.colors.text});return a.length>0?a:[fu(e,t)]}function fu(e,t){return{type:`text`,id:`layout-empty`,content:{text:e.title??`Empty layout`,style:{fontSize:m(36,t,!0),fontFamily:U(t,`title`),color:t.theme.colors.textMuted,textAlign:`center`}},position:{x:`50%`,y:`50%`,anchor:`center`}}}var pu=/\{(\w+)(?::([^}|]+))?(?:\|([^}]*))?\}/g,mu=/\{\{([^{}]*)\}\}/g,hu=` ESC_OPEN `,gu=` ESC_CLOSE `;function _u(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 vu(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 yu(e){return e.contents?e.contents.map(e=>o(e).trim()).filter(e=>e.length>0).join(` `):``}function bu(e){return!e.children||e.children.length===0?``:e.children.map(e=>e.title?.trim()).filter(e=>!!e).join(`, `)}function xu(e){return e.replace(mu,(e,t)=>hu+t+gu)}function Su(e){return e.replace(new RegExp(hu,`g`),`{`).replace(new RegExp(gu,`g`),`}`)}function Cu(e,t){return Su(xu(e).replace(pu,(e,n,r,i)=>{let a=t(n,r);return a==null?e:a===``&&i!==void 0?i:a}))}function wu(e,t,n,r,i){switch(e){case`title`:return n.title??``;case`content`:return yu(n);case`children`:return bu(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 Tu(e,t,n,r){return Cu(e,(e,i)=>wu(e,i,t,n,r))}function Eu(e,t,n,r){if(!e.includes(`{`))return e;let i=!1,a=xu(e).replace(pu,(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=wu(a,o,t,n,r);return c==null?e:c===``&&s!==void 0?s:c});return i?null:Su(a)}function Du(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 Ou(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 ku(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 vu(t).map((e,t)=>({text:e,label:e,index:t+1}));default:return[]}}function Au(e,t,n){let r=e.repeat;if(!r){let r=Mu(e,t,n,void 0);return r?[r]:[]}let i=ku(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=Ou(s.x,l):s.y=Ou(s.y,l);let u={...e,position:s,id:`${e.id}-${r}`};delete u.repeat;let d=Mu(u,t,n,i[r]);d&&c.push(d);let f=a===`row`?e.position.width:e.position.height;l+=Du(f)+o}return c}function ju(e,t){let n=_u(t),r=[];for(let i of e)if(i.repeat)r.push(...Au(i,t,n));else{let e=Mu(i,t,n,void 0);e&&r.push(e)}return r}function Mu(e,t,n,r){switch(e.type){case`text`:return{...e,content:{...e.content,text:Tu(e.content.text,t,n,r)}};case`image`:{let i=Eu(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=Tu(e.content.alt,t,n,r)),a}default:return e}}function Nu(e){return(t,n)=>{let r=n.block??t;return r?ju(e.layers,r):e.layers.slice()}}var Pu=.6;function Fu(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 Iu(e,t){let n=0,r=0;for(let i of e){let e=(i[t]??``).trim();e&&(n+=1,Fu(e)!==null&&(r+=1))}return r>0&&r/Math.max(1,n)>=Pu}function Lu(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 Ru(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=Lu(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=Lu(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&&Iu(r,e));return o.length===0?null:{labels:r.map(e=>(e[a]??``).trim()),labelHeader:n[a]??``,labelNumbers:r.map(e=>Fu(e[a]??``)),series:o.map(e=>({name:(n[e]??`Column ${e+1}`).trim()||`Column ${e+1}`,values:r.map(t=>Fu(t[e]??``))})),warnings:i}}function zu(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 Bu(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:zu(Math.abs(r),!0);r-=t,i+=t,e>=0&&r<0&&(r=0)}let a=Math.max(2,n),o=zu(zu(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 Vu(e,t){if(!Number.isFinite(e))return`—`;let n=e<0?`-`:``,r=Math.abs(e),i;return i=r>=1e6?`${n}${Hu((r/1e6).toFixed(1))}M`:r>=1e3?`${n}${Hu((r/1e3).toFixed(r>=1e4?0:1))}K`:`${n}${r.toLocaleString(`en-US`,{maximumFractionDigits:2})}`,t?`${i} ${t}`:i}function Hu(e){return e.replace(/\.0$/,``)}function Q(e){return Math.round(e*100)/100}function Uu(e,t,n,r){let i=(r-90)*Math.PI/180;return{x:Q(e+n*Math.cos(i)),y:Q(t+n*Math.sin(i))}}function Wu(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=Uu(e,t,n,i),u=Uu(e,t,n,s);if(r<=0)return[`M ${Q(e)} ${Q(t)}`,`L ${l.x} ${l.y}`,`A ${Q(n)} ${Q(n)} 0 ${c} 1 ${u.x} ${u.y}`,`Z`].join(` `);let d=Uu(e,t,r,i),f=Uu(e,t,r,s);return[`M ${l.x} ${l.y}`,`A ${Q(n)} ${Q(n)} 0 ${c} 1 ${u.x} ${u.y}`,`L ${f.x} ${f.y}`,`A ${Q(r)} ${Q(r)} 0 ${c} 0 ${d.x} ${d.y}`,`Z`].join(` `)}function Gu(e){return e.length===0?``:e.map((e,t)=>`${t===0?`M`:`L`} ${Q(e.x)} ${Q(e.y)}`).join(` `)}function Ku(e,t){if(e.length===0)return``;let n=Gu(e),r=e[0],i=e[e.length-1];return`${n} L ${Q(i.x)} ${Q(t)} L ${Q(r.x)} ${Q(t)} Z`}function qu(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 Ju(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 Yu(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 Xu(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 Zu={bar:`barChart`,column:`columnChart`,pie:`pieChart`,donut:`donutChart`,line:`lineChart`,area:`areaChart`,scatter:`scatterChart`};function Qu(e,t,n){let r=$u(t,n),i=r?Ru(r,t):null;if(!r||!i)return ed(t,n);let{theme:a,viewport:o}=n,s=Zu[e],c=(t.title??``).trim(),l=W(44,n,!0),u=W(20,n,!1),d=W(22,n,!1),f=W(22,n,!1),p=W(20,n,!1),m=U(n,`body`),h=e===`pie`||e===`donut`,g=td(e,t,i),_=nd(n,t.colorScheme,h?i.labels.length:i.series.length);if(h&&!i.series[0].values.some(e=>e!==null&&e>0))return ed(t,n);let v=o.width*.88,y=g.length>0?Yu(g,f,v):null,b=rd(e,i,t,n,u,d),x=qu({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=zi(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=[Hi(`bg`,Li(n,170))];switch(c&&x.titleBand&&T.push({type:`text`,id:`title`,content:{text:c,style:{fontSize:l,fontFamily:U(n,`title`),fontWeight:`bold`,color:a.colors.text,textAlign:`center`,shadow:K(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(...cd(w));break;case`column`:T.push(...sd(w));break;case`pie`:case`donut`:T.push(...ld(w));break;case`line`:case`area`:T.push(...ud(w));break;case`scatter`:T.push(...dd(w));break}return y&&x.legendBand&&T.push(...fd(w,y,x.legendBand,f)),t.showTable===!0&&x.tableBand&&T.push(md(r,x.tableBand,p,t,n)),T}function $u(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}:uo(e.contents??t.block?.contents)}function ed(e,t){return To({...e,template:`content`,title:e.title??t.block?.title??``},t)}function td(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 nd(e,t,n){let r=e.theme.colorSchemes,i=Object.keys(r),a=[H(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 rd(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=id(e,t,n).ticks.reduce((e,t)=>Math.max(e,Vu(t,n.unit).length),0);return{left:Math.max(i*2.5,o*i*.6+16),bottom:a*2.6}}function id(e,t,n){let r;r=(e===`bar`||e===`column`)&&n.stacked===!0?Ju(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)),Bu(i,a,5)}function ad(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:Vu(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 od(e,t){let{frame:n,data:r,labelFontSize:i,axisTextColor:a,bodyFont:o}=e,s=Xu(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 sd(e){let{frame:t,data:n,colors:r,input:i,entrance:a}=e,o=id(`column`,n,i),s=e=>t.plot.y+t.plot.height*(1-(e-o.niceMin)/(o.niceMax-o.niceMin)),c=ad(e,o,s),l=n.labels.length,u=t.plot.width/Math.max(1,l),d=u*.15;c.push(...od(e,e=>t.plot.x+(e+.5)*u));let f=i.stacked===!0&&n.series.length>1,p=f?Ju(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(pd(e,`val-${o}-${m}`,n,y+h/2,n>=0?_-e.axisFontSize*.9:_+v+e.axisFontSize*.9))})}),c}function cd(e){let{frame:t,data:n,colors:r,input:i,entrance:a,labelFontSize:o,axisFontSize:s,bodyFont:c,axisTextColor:l,gridColor:u}=e,d=id(`bar`,n,i),f=s*.6,p=e=>Vu(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:Vu(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?Ju(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(pd(e,`val-${i}-${o}`,n,r,u+E/2))}})}),v}function ld(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:Wu(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 ud(e){let{kind:t,frame:n,data:r,colors:i,input:a,entrance:o}=e,s=id(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=ad(e,s,c);f.push(...od(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:Ku(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:Gu(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(pd(e,`val-${s}-${n}`,t,d(n),c(t)-e.axisFontSize)))})}),f}function dd(e){let{frame:t,data:n,colors:r,input:i,entrance:a}=e,o=id(`scatter`,n,i),s=e=>t.plot.y+t.plot.height*(1-(e-o.niceMin)/(o.niceMax-o.niceMin)),c=ad(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=Bu(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:Vu(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(...od(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 fd(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 pd(e,t,n,r,i){return{type:`text`,id:t,content:{text:Vu(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 md(e,t,n,r,i){let{theme:a}=i,o=H(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:U(i,`body`),headerFontFamily:U(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 hd(e,t){return Qu(`bar`,e,t)}function gd(e,t){return Qu(`column`,e,t)}function _d(e,t){return Qu(`pie`,e,t)}function vd(e,t){return Qu(`donut`,e,t)}function yd(e,t){return Qu(`line`,e,t)}function bd(e,t){return Qu(`area`,e,t)}function xd(e,t){return Qu(`scatter`,e,t)}function Sd(e,t){let n={...e,speaker:e.speaker??e.title??`Speaker`,text:e.text??``},{theme:r}=t,i=H(t,n.colorScheme),a=n.variant??`speech`,o=n.side??`left`,s=typeof n.counterpartName==`string`&&n.counterpartName.length>0,c=U(t,`body`),l=U(t,`mono`),u=W(26,t,!1),d=W(32,t,!0),f=W(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=[Hi(`bg`,Li(t,160))];if(s)return[...h,...Cd(n,t,i.accent,m,p)];let g=o===`left`?`12%`:`88%`,_=o===`left`?`20%`:`18%`;h.push(...Td(`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:K(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,Ui(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:W(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:W(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 Cd(e,t,n,r,i){let{theme:a}=t,o=U(t,`body`),s=W(28,t,!1),c=W(32,t,!0),l=[...Td(`speaker`,e.speaker,e.speakerImage,`26%`,`28%`,t),...Td(`counterpart`,e.counterpartName??``,e.counterpartImage,`74%`,`28%`,t),wd(`speaker-name`,e.speaker,`26%`,s,o,a.colors.textMuted),wd(`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:W(22,t,!1),fontFamily:o,color:a.colors.textMuted}},position:{x:`96%`,y:`94%`,anchor:`bottom-right`}}),l}function wd(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 Td(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:W(44,a,!0),fontFamily:U(a,`body`),fontWeight:`bold`,color:o.colors.text,textAlign:`center`,verticalAlign:`middle`}},position:{x:r,y:i,width:`9%`,height:`16%`,anchor:`center`}}]}var Ed={title:ea,sectionHeader:ya,bigText:Oa,transcript:Sd,content:To,statHighlight:No,quote:Bo,factCard:Jo,twoColumn:Yo,dateEvent:os,imageWithCaption:ss,leftFeature:bs,rightFeature:xs,map:Ss,fullBleedQuote:Ns,list:Js,photoGrid:Ys,definitionCard:sc,comparisonBar:cc,pullQuote:vc,videoWithCaption:yc,videoPullQuote:bc,dataTable:Sc,barChart:hd,columnChart:gd,pieChart:_d,donutChart:vd,lineChart:yd,areaChart:bd,scatterChart:xd,diagram:yl,tree:Sl,timeline:Al,layout:du,drawing:Zl};function Dd(e){let t={...Ed};if(e)for(let n of e)t[n.name]||(t[n.name]=Nu(n));return t}var Od=[{type:`slowZoom`,direction:`in`},{type:`slowZoom`,direction:`out`},{type:`slowZoom`,panDirection:`left`},{type:`slowZoom`,panDirection:`right`}],kd=8;function Ad(e){return e===0||e===`0`||e===`0%`}function jd(e){if(e.type!==`image`&&e.type!==`video`)return!1;let{position:t}=e;if(!Ad(t.x)||!Ad(t.y)||t.width!==`100%`||t.height!==`100%`)return!1;let n=e.content.fit;return n===void 0||n===`cover`}function Md(e){return e.renderStyle.ambientMotion===!0}function Nd(e,t,n){let r=n.style.animationSpeed??1,i=Md(n);return r===1&&!i?e:e.map(e=>{let n=e.animation;return!n&&i&&jd(e)&&(n={...new he(pe(`${t.id}:${e.id}`)).pickRequired(Od),duration:Math.max(kd,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 Pd(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 Fd(e,t,n){let r=n?.maxDistance??2,i,a=1/0,o=e.toLowerCase();for(let e of t){let t=Pd(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 Id=[`zoomIn`,`zoomOut`,`panLeft`,`panRight`],Ld=[`bottom`,`top`,`center`],Rd=[`terrain`,`satellite`,`road`,`toner`,`watercolor`],zd=[`neutral`,`somber`,`celebratory`],Bd=`theme color-scheme name — e.g. 'blue', 'green'`;function Vd(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:Bd},{key:`headers`,description:`Header cells (normally derived from the table)`,coerce:`stringList`},{key:`rows`,description:`Table rows (supply via a data fence)`},...Hd(),{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 Hd(){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 Ud={key:`stacked`,description:`Stack series instead of grouping them side by side`,coerce:`boolean`},Wd=[{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`}],Gd={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:Bd},{key:`imageSrc`,description:`Optional background image path`},{key:`imageAlt`,description:`Alt text for the background image`},{key:`ambientMotion`,description:`Slow zoom/pan effect`,values:Id}],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:Id}],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:Bd}],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:Bd}],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:Bd},{key:`rightColor`,description:`Right column color scheme`,valueHint:Bd}],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:zd}],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:Ld},{key:`ambientMotion`,description:`Slow zoom/pan effect`,values:Id},{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:Kd(),rightFeature:Kd(),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:Rd},{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:Id}],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:Bd}],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:Bd},{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`},...Hd()],barChart:Vd([Ud]),columnChart:Vd([Ud]),pieChart:Vd(),donutChart:Vd(),lineChart:Vd(),areaChart:Vd(),scatterChart:Vd(),tree:[{key:`title`,description:`Optional title above the tree`},{key:`colorScheme`,description:`Folder-row color scheme`,valueHint:Bd},{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:Bd},{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:Ld},{key:`videoCredit`,description:`Video credit / artist name`},{key:`videoLicense`,description:`License identifier`}]};function Kd(){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 qd(e){let t=Gd[e];if(t)return[...t,...Wd]}function Jd(e){return new Map(e.map(e=>[e.key,e]))}function Yd(e,t){let n={},r=[],i=e?qd(R(e)):void 0,a=i?Jd(i):void 0;for(let[e,i]of Object.entries(t)){let{value:t,warning:o}=Xd(a?.get(e)?.coerce??`string`,i);o?(r.push(`"${e}": ${o}`),n[e]=i):n[e]=t}return{input:n,warnings:r}}function Xd(e,t){switch(e){case`number`:{let e=se(t);return e==null?{value:t,warning:`not a number (${JSON.stringify(t)})`}:{value:e}}case`boolean`:return Zd(t);case`latLng`:return Qd(t);case`labeledPair`:return{value:$d(t)};case`stringList`:return{value:ef(t)};default:return{value:t}}}function Zd(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 Qd(e){let t=e.split(`,`);if(t.length===2){let e=se(t[0]),n=se(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 $d(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 ef(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function tf(e,t){let n=R(e),r=Gd[n];if(!r)return[];let i=[],a=Jd([...r,...Wd]),o=new Set([...a.keys(),...Object.keys(I)]);for(let[e,r]of Object.entries(t)){let t=a.get(e);if(!t){if(o.has(e))continue;let t=Fd(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}=Xd(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 nf=600;function rf(e,t,n){let r=H(t,`blue`),{layout:i}=t,a=e.title??e.id??``,o=af(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:W(56,t,!0),fontFamily:U(t,`title`),fontWeight:`bold`,color:r.text,textAlign:`left`}},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:W(28,t),fontFamily:U(t,`body`),color:r.text,textAlign:`left`}},position:{x:`50%`,y:`55%`,anchor:`center`,width:i.maxTextWidth}}),s.push({type:`text`,id:`fallback-notice`,content:{text:`\u26A0 ${n}`,style:{fontSize:W(18,t),fontFamily:U(t,`body`),color:C(r.text,.6),textAlign:`center`}},position:{x:`50%`,y:`92%`,anchor:`center`,width:i.maxTextWidth}}),s}function af(e){if(!e.contents||e.contents.length===0)return``;let t=e.contents.map(e=>o(e)).join(`
28
+ `).trim();return t.length<=nf?t:`${t.slice(0,nf).trimEnd()}\u2026`}function of(e,t={}){return sf(e,t,{registry:t.customTemplates&&t.customTemplates.length>0?Dd(t.customTemplates):Ed})}function sf(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:vf(hf(s(l),e,r,i),e,r,c,n.expandedPersistentLayers),source:`authored`};if(!u(e)){let t=hf([],e,r,i);return{layers:vf(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=gf(e,d,n.registry);if(m.status===`ok`)return{layers:vf(hf(n.applyRenderStyle===!1?m.layers:Nd(m.layers,e,r),e,r,i),e,r,c,n.expandedPersistentLayers),source:`template`};let h=_f(e.template,m);if((t.failureMode??`fallback`)===`empty`){let t=hf([],e,r,i);return{layers:vf(t,e,r,c,n.expandedPersistentLayers),source:t.length>0?`rich-content`:`empty`,diagnostic:h}}return{layers:vf(hf(rf(e,d,h.message),e,r,i),e,r,c,n.expandedPersistentLayers),source:`fallback`,diagnostic:h}}function cf(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 lf(e){let t=e.template?R(e.template):void 0,n=(e.contents??[]).filter(e=>e.type===`code`),r=[];for(let e of n){if(t!==`diagram`&&cn(e.lang)){let t=un(e.value,{explicit:ln(e.lang)});if(t.isDiagram&&t.diagram){r.push({kind:`spatial`,template:`diagram`,data:Ia(t.diagram),aspectRatio:16/9});continue}}if(t!==`tree`&&Xr(e.lang)){let t=Qr(e.value,{explicit:Zr(e.lang)});if(t.isTree&&t.tree){r.push({kind:`spatial`,template:`tree`,data:Wa(t.tree),aspectRatio:3/4});continue}}if(t!==`timeline`&&Sr(e.lang)){let t=wr(e.value,{explicit:Cr(e.lang)});t.isTimeline&&t.timeline&&r.push({kind:`spatial`,template:`timeline`,data:Ha(t.timeline),aspectRatio:16/9})}}return r}function uf(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=co(t.contents),o=a.filter(e=>!r.has(e.src)),s=new Set(a.map(e=>e.src)),c=new Set(n),l=oo(t.contents).filter(e=>s.has(e.src)||c.has(e.src)?!1:(c.add(e.src),!0)),u=cf(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})),...lf(t)]}function df(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 ff(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 pf(e,t,n,r,i){if(e.kind===`image`){let a=ff(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 Hc(e.template===`timeline`?Al({...c,template:`timeline`},o):e.template===`tree`?Sl({...c,template:`tree`},o):yl({...c,template:`diagram`},o),a,t,`${n.id}-embedded-${e.template}-${i}`)}function mf(e,t){let n=new Map(co(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 hf(e,t,n,r){let i=mf(e,t),a=uf(i,t);if(a.length===0)return i;let o=Yc(i,t.template?R(t.template):void 0,r,a.length,a.map(e=>e.aspectRatio)),s=df(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,pf(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 gf(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[R(r.template)];if(!o)return{status:`unknown-template`,layers:[]};let{templateData:c,templateOverrides:l}=r,u=r,d=u.sourceHeading?bo(r.template,u.title??``,u.contents):null,f=Yd(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(R(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 _f(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 vf(e,t,n,r,i){return r?Oi(e,t,i?.bottomLayers??Ti(r.bottomLayers,n),i?.topLayers??Ti(r.topLayers,n)):e}var yf={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.`}},bf={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`}},xf=120,Sf=26,Cf=62;function wf(e){let t=e.trim().length;if(t<=Sf)return xf;let n=xf*Math.sqrt(Sf/t);return Math.max(Cf,Math.round(n))}function Tf(e){let{theme:t}=e;return t.id===`standard`&&x(t.colors.background)>.85}var Ef=[{pos:0,alpha:.95},{pos:38,alpha:.86},{pos:58,alpha:.4},{pos:78,alpha:.1},{pos:100,alpha:0}];function Df(e){return`linear-gradient(0deg, ${Ef.map(t=>`${C(e,t.alpha)} ${t.pos}%`).join(`, `)})`}function Of(e,t){let n=Ii(t,e.imageTreatment),{heroSrc:r,heroAlt:i,title:a,subtitle:o,ambientMotion:s,heroCredit:c,heroLicense:l}=e,{theme:u,layout:d,viewport:f}=t,p=!r&&Tf(t),m=W(wf(a),t,!0),h=W(40,t,!1),g=o?parseFloat(d.primaryY):50,_=parseFloat(d.maxTextWidth)/100*f.width,v=Ui(a,m,_,1.4),y=e=>e/f.height*100,b=g+y(v/2),x=b+y(40);if(o){let e=Ui(o,h,_,1.5),t=parseFloat(d.secondaryY)-y(e/2);x=Math.max(b,Math.min(x,(b+t)/2))}let S=[];if(r){let e=ra(s);S.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:Df(u.colors.background)},position:{x:0,y:0,width:`100%`,height:`100%`}})}else p?S.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%`}}):S.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%`}}),S.push({type:`shape`,id:`cover-accent`,content:{shape:`rect`,fill:p?C(u.colors.primary,.24):`rgba(255, 255, 255, 0.2)`},position:{x:`35%`,y:`${x}%`,width:`30%`,height:`2px`}});return S.push({type:`text`,id:`cover-title`,content:{text:a,style:{fontSize:m,fontFamily:U(t,`title`),fontWeight:`bold`,color:u.colors.text,textAlign:`center`,shadow:!p}},position:{x:`50%`,y:r?o?`70%`:`75%`:`${g}%`,anchor:`center`,width:d.maxTextWidth},animation:{type:`fadeIn`,duration:.8}}),o&&S.push({type:`text`,id:`cover-subtitle`,content:{text:o,style:{fontSize:h,fontFamily:U(t,`body`),fontWeight:p?`bold`:`normal`,color:p?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}}),S}function kf(e){return{heroSrc:e.heroSrc,heroAlt:e.heroAlt,title:e.title,subtitle:e.subtitle,ambientMotion:e.ambientMotion,heroCredit:e.heroCredit,heroLicense:e.heroLicense}}function Af(e,t,n=`cover`){let r=kf(e),i={id:`cover-block`,duration:0,audioSegment:-1};if(n===`title`)return ea({...i,template:`title`,title:r.title,subtitle:r.subtitle},t);if(n===`sectionHeader`)return ya({...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 Oa({...i,template:`bigText`,title:r.title,...e?{imageSrc:r.heroSrc,imageAlt:r.heroAlt??r.title,ambientMotion:r.ambientMotion}:{}},t)}return n===`imageWithCaption`?r.heroSrc?ss({...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):ea({...i,template:`title`,title:r.title,subtitle:r.subtitle},t):Of(r,t)}function jf(e,t,n,r,i,a,o,c,l,d){let f=sf(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 Mf(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?Dd(c):Ed,g=a===!1?void 0:a??r.persistentLayers,_=g?{bottomLayers:Ti(g.bottomLayers,r),topLayers:Ti(g.topLayers,r)}:void 0;if(!o||o.length===0){let t=0;return e.map((e,n)=>{let a=jf(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=jf(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=jf(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 Nf(){return Object.keys(Ed)}function Pf(e){return R(e)in Ed}var Ff={width:1920,height:1080},If={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`},Lf=Object.fromEntries(Object.entries(If).map(([e,t])=>[t,e]));function Rf(e,t){if(Array.isArray(e))return e.map(e=>Rf(e,t));if(e&&typeof e==`object`){let n={};for(let[r,i]of Object.entries(e))n[t[r]??r]=Rf(i,t);return n}return e}function zf(e){return!e||e.width===Ff.width&&e.height===Ff.height}function Bf(e){if(!e)return;let t=Gf(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??{...Ff},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 Vf(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),zf(t.viewport)||(e.vp=t.viewport),e.ly=Rf(t.layers,If),n[t.name]=e}return JSON.stringify(n,null,t?.pretty?2:void 0)}function Hf(e){return Object.entries(e).map(([e,t])=>{let n=t&&typeof t==`object`?t:{},r={name:e,label:n.lb,viewport:n.vp??{...Ff},layers:Rf(n.ly??[],Lf)};return typeof n.ds==`string`&&(r.description=n.ds),r})}function Uf(e){return Array.isArray(e)?e:e&&typeof e==`object`?Hf(e):null}function Wf(e){try{return JSON.parse(e)}catch{return}}function Gf(e){if(e==null)return null;if(Array.isArray(e))return e;if(typeof e==`object`)return Hf(e);if(typeof e!=`string`)return null;let t=Wf(e.trim());if(t!==void 0)return Uf(t);try{let t=Wf(Re(e));if(t!==void 0)return Uf(t)}catch{}return null}function Kf(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 qf(e){if(!e)return;let t=Kf(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 Jf(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 Yf=new Set([`json`,`yaml`,`yml`]);function Xf(e){if(!e.lang||!Yf.has(e.lang.toLowerCase()))return!1;let t=e.meta??``;return/\bdata\b/.test(t)}function Zf(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:np(e.value)}}catch(e){return{error:`invalid YAML: ${e instanceof Error?e.message:String(e)}`}}}function Qf(e,t){let n=JSON.stringify(t,null,2),r=e.findIndex(e=>e.type===`code`&&Xf(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 $f(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 ep(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 tp(e){let t=e.trim();return t.startsWith(`[`)&&t.endsWith(`]`)?ep(t.slice(1,-1)).map($f):$f(t)}function np(e){let t={},n=e.split(`
29
+ `),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(tp(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()]=tp(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]=tp(d)}return t}function rp(e){return e?.find(e=>e.type===`table`)}function ip(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 ap(e){let t=de(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=ie(t[e]);n&&(a[n.key]=n.value)}return{template:r,params:a}}function op(e){if(e.type!==`paragraph`)return null;let t=e.children??[];if(t.length!==1||t[0].type!==`text`)return null;let n=ce(t[0].value.trim());return!n||n.index!==0?null:ap(n.inner)}var sp=new Set([`audio`,`video`,`media`]);function cp(e){return e!=null&&sp.has(e)}function lp(e){return e==null?null:re(e)}function up(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 dp(e){return e!==`false`&&e!==`0`}function fp(e){return e===`small`||e===`large`?e:void 0}function pp(e){return e===`square`||e===`wide`?e:void 0}function mp(e){return e===`top-left`||e===`top-right`||e===`bottom-left`||e===`bottom-right`?e:void 0}function hp(e,t){let{template:n,params:r}=e;if(!n||!sp.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:lp(r.startAt??r.startTime)??0,anchor:o},c=a===`video`?up(r):void 0;c&&c!==`content`&&(s.placement=c);let l=fp(r.pipSize),u=pp(r.pipShape),d=mp(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=dp(r.lockToBlock);s.lockToBlock=e,s.anchor=e?`block`:`document`,e&&(s.startAt=0)}let f=lp(r.clipStart),p=lp(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 gp(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 _p(e){if(e.type===`htmlBlock`){if(!/^\s*<video\b/i.test(e.rawHtml))return null;let t=gp(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=gp(n.htmlChildren);if(e)return{element:e,raw:t.trim()}}return null}function vp(e,t){let n=_p(e);if(!n)return null;let{element:r}=n,i=up({placement:r.attributes[`data-squisq-video-placement`]??``});if(!i||i===`content`)return null;let a=r.attributes.src;if(!a)return null;let o=dp(r.attributes[`data-squisq-video-lock-to-block`]),s={id:t,src:a,kind:`video`,placement:i,lockToBlock:o,startAt:o?0:lp(r.attributes[`data-squisq-video-start-at`])??0,anchor:o?`block`:`document`},c=fp(r.attributes[`data-squisq-video-pip-size`]),l=pp(r.attributes[`data-squisq-video-pip-shape`]),u=mp(r.attributes[`data-squisq-video-pip-position`]);c&&(s.pipSize=c),l&&(s.pipShape=l),u&&(s.pipPosition=u);let d=lp(r.attributes[`data-squisq-video-clip-start`]),f=lp(r.attributes[`data-squisq-video-clip-end`]);return d!=null&&(s.clipStart=d),!o&&f!=null&&(s.clipEnd=f),s}function yp(e,t,n){let r=[],i=[],a=[],o=0,s=0;for(let c of e??[]){let e=op(c),l=e?hp(e,``):vp(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=_p(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 bp(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 xp(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:R(n),standaloneAnnotation:!0,sourceAnnotation:{template:n,...i?{params:r}:{}},...r.title?{title:r.title}:{}};return i&&(a.templateOverrides=r,bp(a,ee(r).blockMeta)),a}function Sp(e,t){let n=[],r=[],i=null;for(let a of e??[]){let e=op(a);if(e!=null&&e.template!=null&&!cp(e.template)){let n=xp(e,t);r.push(n),i=n}else i?(i.contents??=[]).push(a):n.push(a)}return{leading:n,blocks:r}}function Cp(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 wp(e){if(op(e)?.template)return!0;let t=Cp(e);if(t==null)return!1;let n=ce(t);return!!n&&n.index>0&&!!ap(n.inner).template}function Tp(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 Ep(e){if(!e||e.length===0)return null;let t=e.length-1,n=e[t],r=null,i=null,a=op(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=Cp(n),o=a==null?null:ce(a);if(a!=null&&o&&o.index>0){let n=ap(o.inner);n.template&&(r={template:n.template,params:n.params,origin:{kind:`trailing`,index:t,suffix:a.slice(o.index)}},i=Tp(e,t,o.index))}}if(!r||!i)return null;for(let n=0;n<t;n++)if(wp(e[n]))return null;return{data:r,strippedContents:i}}var Dp=/[^\w\s-]/g,Op=/[\s_]+/g,kp=/-+/g,Ap=/^-|-$/g;function jp(e){return e.toLowerCase().replace(Dp,``).replace(Op,`-`).replace(kp,`-`).replace(Ap,``)||`block`}function Mp(){let e=new Map,t=(t,n)=>{let r=jp(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=jp(t),r=e.get(n)??0;return e.set(n,r+1),r===0?n:`${n}-${r+1}`},t}function Np(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 Pp(e){if(!e)return{};let t=e.templateAnnotation?.params?ee(e.templateAnnotation.params).blockMeta:{},n=e.attributes?.blockMeta??{};return{...t,...n}}function Fp(e){return e.promotedBodyAnnotation?.params?ee(e.promotedBodyAnnotation.params).blockMeta:e.sourceHeading?Pp(e.sourceHeading):e.sourceAnnotation?.params?ee(e.sourceAnnotation.params).blockMeta:{}}function Ip(e){return Fp(e)}function Lp(e){for(let t of e){if(!t.sourceHeading||t.sourceHeading.templateAnnotation?.template)continue;let e=Ep(t.contents);if(!e)continue;let{template:n,params:r}=e.data;cp(n)||!Pf(n)||(t.template=R(n),Object.keys(r).length>0&&(t.templateOverrides=r,Np(t,ee(r).blockMeta)),t.contents=e.strippedContents,t.promotedBodyAnnotation=e.data)}}function Rp(e,t,n){let r=[];for(let i of e){i.children&&i.children.length>0&&(i.children=Rp(i.children,t,n));let{leading:e,blocks:a}=Sp(i.contents,{makeId:t,defaultDuration:n});if(a.length===0){r.push(i);continue}i.contents=e,(i.children?.length??0)>0&&!L(i.template)?(i.children=[...a,...i.children],r.push(i)):r.push(i,...a)}return r}function zp(e,t){let r=t?.articleId??`markdown-doc`,i=t?.defaultTemplate??`sectionHeader`,a=t?.defaultDuration??5,s=t?.generateId?null:Mp(),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:R(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,Np(p,ee(r.params).blockMeta));let m=e?.attributes;return m&&(m.blockMeta&&Np(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 Bp(l)){let{media:t,documentMedia:n,remaining:r}=yp(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(),Lp(Bp(l)),l=Rp(l,e=>{let t=e.params.title??e.template??`block`;return s?s.fromText(t):jp(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=Bp(l);for(let e of v)Gp(e,u);for(let e of v)Kp(e,u),Jp(e,u),qp(e,u);(t?.autoTemplates??!0)&&!Xp(e)&&Zp(l,R(i),{featureIndex:0});for(let e of v)Yp(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,...Wp(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,...Wp(e)});let b=[];for(let e of v){if(Fp(e).duration!=null)continue;let t=Qp(e);if(t.length>0){let n=pi(t);e.duration=Math.max(3,n.seconds)}else e.duration=a}let x=0;for(let e of v){Fp(e).startTime??(e.startTime=x);let t=Qp(e);if(t.length>0){let n=em(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=Bf(e.frontmatter),T=qf(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=am(e,l,t?.fileName);n&&(D.startBlock=n)}return D}function Bp(e){let t=[];for(let n of e)t.push(n),n.children&&t.push(...Bp(n.children));return t}function Vp(e){let t=[];for(let n of e)t.push(n),n.children&&!L(n.template)&&t.push(...Vp(n.children));return t}function Hp(e){let t=0;for(let n of e)t+=1,n.children&&(t+=Hp(n.children));return t}function Up(e){return e.sourceHeading?.depth??0}function Wp(e){let t=e.sourceHeading?.position?.start.line;return t==null?{}:{line:t}}function Gp(e,t){let n;for(let r of e.contents??[]){if(r.type!==`code`||!Xf(r))continue;let i=Zf(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}:Wp(e)});continue}n={...n,...i.data}}if(ue.has(R(e.template??``))){let t=t=>n&&t in n||e.templateOverrides&&t in e.templateOverrides;if(!t(`headers`)&&!t(`rows`)){let t=rp(e.contents);t&&(n={...ip(t),...n})}}n&&Object.keys(n).length>0&&(e.templateData=n)}function Kp(e,t){if(R(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||!cn(n[0].lang))return;let r=St(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}=Ia(r);e.templateData={nodes:i,edges:a,...e.templateData}}function qp(e,t){if(R(e.template??``)!==`tree`||e.templateData&&`items`in e.templateData)return;let n=bo(`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 Jp(e,t){if(R(e.template??``)!==`timeline`||e.templateData&&`tracks`in e.templateData)return;let n=bo(`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 Yp(e,t){if(R(e.template??``)!==`timeline`||!e.templateData||!(`tracks`in e.templateData))return;let n=(e.contents??[]).filter(e=>e.type===`code`&&Sr(e.lang));if(n.length===1)for(let r of zn(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 Xp(e){let t=e.frontmatter?.[`squisq-auto-templates`];return t===!1||t===`false`||t===`off`||t===`no`||t===0}function Zp(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=ui(si(r.contents??[]),n.featureIndex);if(e&&yo(e,r.contents)){let t=bo(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&&!L(r.template)&&Zp(r.children,t,n)}}function Qp(e){if(!e.contents||e.contents.length===0)return``;let t=R(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(`
30
+ `).trim()}var $p=12;function em(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>$p){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 tm(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=tm(t.children);if(e)return e}}function nm(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=tm(t.htmlChildren);if(e)return e}}if(`children`in e&&Array.isArray(e.children))for(let t of e.children){let e=nm(t);if(e)return e}}function rm(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 im(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 am(e,t,n){let r=typeof e.frontmatter?.title==`string`?e.frontmatter.title.trim():void 0,i=rm(t),a=i?i.title??o(i.sourceHeading):void 0,s=r||a||im(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=nm(e);return{title:s,...d?{subtitle:d}:{},...f?{heroSrc:f.url,heroAlt:f.alt??s}:{},ambientMotion:`zoomIn`}}var om=/^[.,!?;:'"()[\]{}]+|[.,!?;:'"()[\]{}]+$/g,sm=1.4;function cm(e){let t=e.replace(om,``);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(me(t)*sm))}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+=lm(e.replace(/'/g,``));return Math.max(1,r)}function lm(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 um(e,t){let n=t&&e.title?e.title.trim():``,r=Qp(e);return n&&r?`${n}
31
+ ${r}`:n||r}function dm(e,t){let n=t?.includeTitles??!0,r=t?.blockSeparator??`
32
+
33
+ `,i=[];for(let t of Vp(e.blocks)){let e=um(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=pm(u[0]);s.push({text:u[0],charOffset:e,charEnd:t,blockId:o[l]?.blockId??``,blockIndex:l,syllables:n?cm(u[0]):0,spokenWordEquiv:n?me(mm(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(`
34
+ `)?t.pauseAfter=2:hm(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 fm=/["')\]}»”’]+$/;function pm(e){return/[\p{L}\p{N}]/u.test(e)}function mm(e){return e.replace(/^[.,!?;:'"()[\]{}]+|[.,!?;:'"()[\]{}]+$/g,``)}function hm(e){let t=e.replace(fm,``),n=t.charAt(t.length-1);return n?n===`,`||n===`.`||n===`;`||n===`:`||n===`!`||n===`?`:!1}function gm(e,t,n){return e<t?t:e>n?n:e}function _m(e,t){let n=e.tokens.length;if(n===0)return 0;let r=gm(t,0,n),i=Math.floor(r);return i>=n?e.totalSyllables:e.cumulativeSyllables[i]+(r-i)*e.tokens[i].syllables}function vm(e,t){let n=e.tokens.length;if(n===0)return 0;let r=gm(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 ym(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 bm(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,...Sm(r?.cameraOffsetSec)?{cameraOffsetSec:r.cameraOffsetSec}:{},generator:{name:`squisq-teleprompter`,method:`dsp-align`,...r?.baseWpm===void 0?{}:{baseWpm:r.baseWpm}}}}function xm(e){return typeof e==`number`&&Number.isFinite(e)&&e>=0}function Sm(e){return typeof e==`number`&&Number.isFinite(e)}function Cm(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`||!xm(r.duration))return null;let i=Array.isArray(r.bookmarks)?r.bookmarks.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=e;return!xm(t.time)||!xm(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!xm(t.startSec)||!xm(t.endSec)||!xm(t.charStart)||!xm(t.charEnd)?[]:[{...typeof t.blockId==`string`?{blockId:t.blockId}:{},...typeof t.heading==`string`?{heading:t.heading}:{},blockIndex:xm(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,...Sm(r.cameraOffsetSec)?{cameraOffsetSec:r.cameraOffsetSec}:{},...typeof r.generator==`object`&&r.generator!==null?{generator:r.generator}:{}}}catch{return null}}function wm(e,t=0){return!e||e.type===`none`?{className:``,style:{}}:{className:Tm(e),style:Em(e)}}function Tm(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 Em(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 Dm(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 Om(e,t,n){if(e===`cut`)return``;let r=t?`enter`:`exit`;return`transition-${Am(e,n)}-${r}`}var km={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 Am(e,t){switch(e){case`randomBars`:case`randomBar`:return Mm(`randomBars`,t,e===`randomBar`?`Horizontal`:`Vertical`);case`comb`:return Mm(`comb`,t,`Horizontal`);case`blinds`:return Mm(`blinds`,t,`Horizontal`);case`split`:return Mm(`split`,t,`Horizontal`);case`push`:return jm(`push`,t,`Left`);case`wipe`:return jm(`wipe`,t,`Left`);case`cover`:return jm(`cover`,t,`Left`);case`uncover`:return jm(`uncover`,t,`Left`);case`pull`:return jm(`pull`,t,`Left`);case`reveal`:return jm(`reveal`,t,`Left`);case`strips`:return jm(`strips`,t,`Left`);case`pan`:return jm(`pan`,t,`Left`);default:return km[e]}}function jm(e,t,n){return`${e}${Nm(t,n)}`}function Mm(e,t,n){return`${e}${Pm(t,n)}`}function Nm(e,t){switch(e){case`right`:return`Right`;case`up`:return`Up`;case`down`:return`Down`;default:return t}}function Pm(e,t){switch(e){case`vertical`:case`up`:case`down`:return`Vertical`;case`horizontal`:case`left`:case`right`:return`Horizontal`;default:return t}}function Fm(e,t,n){let r=e.delay||0,i=e.duration||n;return t<r?0:t>=r+i?1:(t-r)/i}var Im=40,Lm=e=>Math.max(0,Math.min(1,e)),Rm=e=>Math.round(e*100)/100;function zm(e,t){let n=[];if(t!=null&&t>0&&n.push(`blur(${Math.round(t)}px)`),e&&e.type!==`none`){let t=Lm(e.strength??.6);switch(e.type){case`mono`:n.push(`grayscale(${Rm(t)})`,`contrast(${Rm(1+.05*t)})`);break;case`duotone`:{let r=F(e.color??`#3d5a80`);n.push(`grayscale(1)`,`sepia(${Rm(Math.max(.35,t))})`,`hue-rotate(${Math.round(r-Im)}deg)`,`saturate(${Rm(1+t)})`);break}case`warm`:n.push(`sepia(${Rm(.4*t)})`,`saturate(${Rm(1+.15*t)})`);break;case`cool`:n.push(`saturate(${Rm(1-.25*t)})`,`hue-rotate(${Math.round(-12*t)}deg)`,`contrast(${Rm(1+.06*t)})`);break}}return n.length>0?n.join(` `):void 0}var Bm=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}]),Vm=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`}}),Hm=Object.freeze({enabled:!0,template:`cover`,duration:2,playback:`preroll`});function Um(e,t){if(e)return Object.prototype.hasOwnProperty.call(e,t.canonical)?e[t.canonical]:e[t.legacy]}function Wm(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 Gm(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 Km(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 qm(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 Jm(e,t={}){let n={enabled:Wm(Um(e,Vm.enabled))??Hm.enabled,template:Gm(Um(e,Vm.template))??Hm.template,duration:Km(Um(e,Vm.duration))??Hm.duration,playback:qm(Um(e,Vm.playback))??Hm.playback};return{enabled:t.enabled??n.enabled,template:t.template??n.template,duration:Km(t.duration)??n.duration,playback:t.playback??n.playback}}var Ym=[`transition`,`transitionDuration`,`transitionDirection`],Xm=`sectionHeader`;function Zm(e,t={}){let n=R(t.defaultTemplate??Xm),r=[],i=new Set(Bp(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(th(e));function s(e){let t=e.promotedBodyAnnotation,i=t!==void 0&&!$m(e,t);if(e.sourceHeading)if(i)r.push(e.sourceHeading);else{let t=nh(e,e.sourceHeading,n);r.push(t)}else e.standaloneAnnotation&&r.push(Qm(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,th(t));for(let e of o.filter(e=>!e.origin).reverse())c.unshift(th(e))}if(i&&eh(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=Vf(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=Jf(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 Qm(e){return{type:`paragraph`,children:[{type:`text`,value:ne(e.sourceAnnotation?.template,e.templateOverrides)}]}}function $m(e,t){let n=R(e.template??``)===R(t.template),r=ah(e.templateOverrides??{},t.params??{});return!(n&&r)}function eh(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 th(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:ne(e.kind,t)}]}}function nh(e,t,n){let{attributes:r,transitionParams:i}=oh(e,t),a=t.templateAnnotation,o=rh(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}}),ih(a,c)&&(c=a),r===t.attributes&&c===t.templateAnnotation?t:{...t,children:[...t.children],attributes:r,templateAnnotation:c}}function rh(e,t,n){if(!e.template||e.autoTemplate===!0)return t?.template;let r=R(e.template);if(t?.template&&R(t.template)===r)return t.template;if(r!==n)return e.template}function ih(e,t){return e===t?!0:!e||!t?!1:e.template===t.template&&ah(e.params,t.params)}function ah(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 oh(e,t){let n=e.transition;if(!n)return{attributes:t.attributes,transitionParams:void 0};let r=sh(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 sh(e){if(!e?.params)return e;let t={...e.params};for(let e of Ym)delete t[e];return{...e,...Object.keys(t).length>0?{params:t}:{params:void 0}}}function ch(e){if(e.type===`inlineIcon`){let t=e;return ge(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`?`
35
+ `:``;return n.map(ch).join(r)}function lh(e){if(!e||e.length===0)return``;let t=[];for(let n of e)n.type===`code`&&n.lang?.trim().toLowerCase()===`mermaid`||t.push(ch(n));return t.join(`
36
+ `).trim()}function uh(e){if(e===void 0)return;let t=parseFloat(e);return Number.isFinite(t)&&t>0?t:void 0}function dh(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:uh(e?.width),height:uh(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 fh(e){let t=new Set,n=[];function r(e){for(let i of e){for(let e of dh(i.contents))t.has(e.src)||(t.add(e.src),n.push(e));i.children&&r(i.children)}}return r(e),n}function ph(e,t,n){let r=lh(n.contents);switch(e){case`statHighlight`:return bo(e,t,n.contents)??{stat:t,description:r||t};case`quote`:return{quote:r||t};case`fullBleedQuote`:case`pullQuote`:return bo(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`:return bo(e,t,n.contents)??{items:[`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=dh(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 mh(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=Pf(a)||s?a:`sectionHeader`,l=ph(c,i,e),u=_h(e.templateOverrides),d=u?Yd(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,...gh(e.templateData),...d}}var hh=new Set(Object.keys(I));function gh(e){if(!e)return e;let t=!1,n={};for(let r of Object.keys(e)){if(hh.has(r)){t=!0;continue}n[r]=e[r]}return t?n:e}function _h(e){if(!e)return e;let t=!1,n={};for(let r of Object.keys(e)){if(hh.has(r)){t=!0;continue}n[r]=e[r]}return t?n:e}var vh=[`zoomIn`,`zoomOut`,`panLeft`,`panRight`];function yh(e){return e?(e.split(/[\\/]/).pop()??``).replace(/\.[^.]+$/,``).trim():``}function bh(e,t){let n=e.frontmatter?.title;return typeof n==`string`&&n.trim()?n.trim():t?.trim()??``}function xh(e,t){let n=Vp(e.blocks),r=fh(e.blocks),i=new Set,a=e.customTemplates?new Set(e.customTemplates.map(e=>e.name)):void 0,o=bh(e,t?.documentTitle),s=[],c=0;for(let e=0;e<n.length;e++){let t=n[e],r=dh(t.contents),l=mh(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=vh[c++%vh.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:vh[c++%vh.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:vh[c++%vh.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 Sh(e,t,r){let i=t??e?.themeId??n(e?.frontmatter),a=e?.customThemes??qf(e?.frontmatter);return(i?a?.find(e=>e.id===i):void 0)||O(i,r)}function Ch(e){return e.sourceHeading?.templateAnnotation?.template||e.autoTemplate&&e.template?!0:!e.sourceHeading&&u(e)}function wh(e){return e.sourceHeading?.templateAnnotation?.template??e.template}function Th(e){if(!Ch(e))return{templated:!1};let t=e.sourceHeading?.templateAnnotation,n=wh(e)??`sectionHeader`,r=R(n),i=Yd(n,{...t?.params??{},...e.templateOverrides??{}}).input,a,s=null;if(t){let t=o(e.sourceHeading);s=bo(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 Eh(e){let t=e.contents;if(!t||t.length===0)return;let n=t.map(e=>o(e)).join(`
37
+ `).trim();return n?{text:n,markdown:t}:void 0}function Dh(e){if(e?.src)return{type:`image`,src:e.src,alt:e.alt??``,credit:e.credit,license:e.license}}function Oh(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 kh=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}},Ah=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}},jh=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}},Mh=e=>({kind:`prose`,slots:{title:e.title,body:Eh(e)}}),Nh=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}}},Ph=e=>{let t=e;return{kind:`stat-band`,variant:`single`,slots:{items:[{value:t.stat,title:t.description,body:t.detail}],media:Dh(t.accentImage)},emphasis:`strong`,colorScheme:t.colorScheme}},Fh=e=>{let t=e;return{kind:`quote-band`,variant:`plain`,slots:{title:t.title,body:{text:t.quote??``},attribution:t.attribution,media:Dh(t.accentImage)}}},Ih=e=>{let t=e;return{kind:`callout`,variant:`fact`,slots:{title:t.fact,body:{text:t.explanation??``},meta:t.source,media:Dh(t.accentImage)}}},Lh=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}]}}},Rh=e=>{let t=e;return{kind:`timeline-rail`,slots:{milestone:{date:t.date??``,description:t.description??``,footer:t.footer,mood:t.mood},media:Dh(t.accentImage)}}},zh=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 Bh(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 Vh=e=>Bh(e,`left`),Hh=e=>Bh(e,`right`),Uh=e=>{let t=e;return{kind:`quote-band`,variant:`display`,slots:{body:{text:t.text??``}},emphasis:`strong`,colorScheme:t.colorScheme}},Wh=e=>{let t=e,n=e.contents,r=io(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:Dh(t.accentImage)},colorScheme:t.colorScheme}},Gh=e=>{let t=e,n=t.images??[];return{kind:`gallery`,slots:{...n.length===0?{title:e.title,body:Eh(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}}))}}},Kh=e=>{let t=e;return{kind:`callout`,variant:`definition`,slots:{title:t.term,body:{text:t.definition??``},meta:t.origin,media:Dh(t.accentImage)},colorScheme:t.colorScheme}},qh=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}},Jh=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}},Yh=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}}},Xh=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}},Zh=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}},Qh=(e,t)=>{let n=e;return Array.isArray(n.headers)&&Array.isArray(n.rows)&&Ru({headers:n.headers,rows:n.rows},n)!==null?Oh(`chart`,t,e):Mh(e,t)},$h={title:kh,sectionHeader:Ah,bigText:jh,transcript:Nh,content:Mh,statHighlight:Ph,quote:Fh,factCard:Ih,twoColumn:Lh,dateEvent:Rh,imageWithCaption:zh,leftFeature:Vh,rightFeature:Hh,map:(e,t)=>Oh(`map`,t,e),fullBleedQuote:Uh,list:Wh,photoGrid:Gh,definitionCard:Kh,comparisonBar:qh,pullQuote:Jh,videoWithCaption:Yh,videoPullQuote:Xh,dataTable:Zh,barChart:Qh,columnChart:Qh,pieChart:Qh,donutChart:Qh,lineChart:Qh,areaChart:Qh,scatterChart:Qh,diagram:(e,t)=>Oh(`diagram`,t,e),tree:(e,t)=>Oh(`tree`,t,e),timeline:(e,t)=>Oh(`timeline`,t,e),layout:(e,t)=>Oh(`layout`,t,e),drawing:(e,t)=>Oh(`drawing`,t,e)};function eg(e,t){let n=e?.pageStyle??M(e??A);return!t?.spacing||t.spacing===n.tokens.sectionSpacing?n:{...n,tokens:{...n.tokens,sectionSpacing:t.spacing}}}var tg=new Set([`banner`,`stat-band`,`quote-band`,`callout`,`card-grid`,`item-list`,`timeline-rail`,`footer`]),ng=new Set([`banner`,`quote-band`,`stat-band`,`footer`]),rg=new Set([`callout`,`card-grid`,`stat-band`,`item-list`,`timeline-rail`,`table-section`]);function ig(e){return e.type===`code`&&e.lang?.trim().toLowerCase()===`mermaid`}function ag(e,t){if(ig(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 og(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)&&og(e.children))return!0}return!1}function sg(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)&&og(t.htmlChildren)?!0:Array.isArray(t.children)&&t.children.some(sg)}function cg(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=>ag(e,n)||!r&&sg(e));if(i.length!==0)return{text:i.map(e=>o(e)).join(`
38
+ `).trim(),markdown:i}}function lg(e,t,n){let r=cg(e,t,n);return r?{...t,slots:{...t.slots,richContent:r}}:t}function ug(e,t,n,r){if(Ch(e)){let i=Th(e),a=i.templateName,s=$h[a];if(s)return{draft:lg(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:lg(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:lg(e,{kind:`callout`,variant:`diagnostic`,slots:{title:(e.sourceHeading?o(e.sourceHeading):void 0)??l.message,body:{text:Za(e.contents)},meta:l.message},emphasis:`quiet`},r),source:`fallback`,templateName:a,diagnostic:l}}if(e.layers&&e.layers.length>0)return{draft:lg(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:Za(e.contents),markdown:e.contents}:void 0}},source:`prose`}}function dg(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 fg(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 pg(e,t){return t?e.colorSchemes?.[t]:void 0}function mg(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 hg(e,t={}){let n=t.theme??A,r=t.viewport??f.landscape,i=eg(n),a=ug(e,r,t.customTemplates,t.widgetFenceLangs),o=dg(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:pg(n,a.draft.colorScheme),role:`block`}:{role:i.accentRotation.strategy===`none`?`none`:`primary`};return{section:fg({...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 gg(e,t={}){let n=t.theme??A,r=t.viewport??f.landscape,i=eg(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=ug(i,r,a,t.widgetFenceLangs);s.push({...e,block:i,depth:n}),!(e.draft.kind===`canvas-embed`&&L(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(`
39
+ `).trim(),markdown:r},n.draft={...n.draft,slots:t}):s.splice(1,1)}}for(let e of s)e.override=dg(i,e.draft.kind,e.templateName);let l=s.length,u=i.tokens.backgroundRhythm,d=i.accentRotation.strategy,p=mg(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`&&ng.has(i)?a=`accent`:u===`tinted-panels`?a=rg.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:pg(n,r.draft.colorScheme),role:`block`};else if(tg.has(i)&&(d===`cycle`||d===`alternate-two`)&&m>0){let e=p[g%m];g++,o={schemeName:e,scheme:pg(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=fg(r,e,l,a,c,o);b.push({section:f,block:r.block,source:r.source,diagnostic:r.diagnostic})}return b}var _g=`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 vg(e,t){let n=e??A,r=t??eg(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 yg(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 bg=`
40
+ .squisq-page-hero-grid { grid-template-columns: 1fr; gap: 1.5rem; }
41
+ .squisq-page-feature { grid-template-columns: 1fr; }
42
+ .squisq-page-feature--media-right .squisq-page-feature-media { order: 0; }
43
+ .squisq-page-stats { flex-direction: column; gap: 1.75rem; }
44
+ .squisq-page-cards { grid-template-columns: 1fr; }
45
+ .squisq-page-gallery { grid-template-columns: repeat(2, 1fr); }
46
+ .squisq-page-milestone { grid-template-columns: 1fr; gap: 0.5rem; }
47
+ .squisq-page-milestone-rail { display: none; }
48
+ .squisq-page-section-inner { padding-inline: 18px; }
49
+ `,xg=`
50
+ /* \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 */
51
+ .squisq-page {
52
+ background: var(--squisq-page-bg);
53
+ color: var(--squisq-page-text);
54
+ font-family: var(--squisq-page-body-font);
55
+ line-height: var(--squisq-page-line-height);
56
+ --squisq-page-divider-color: color-mix(in srgb, var(--squisq-page-text) 16%, transparent);
57
+ --squisq-page-section-pad: 3.5rem;
58
+ --squisq-page-shadow: none;
59
+ }
60
+ .squisq-page *, .squisq-page *::before, .squisq-page *::after { box-sizing: border-box; }
61
+ .squisq-page img { max-width: 100%; height: auto; }
62
+ .squisq-page a {
63
+ color: var(--squisq-page-primary);
64
+ text-decoration-color: color-mix(in srgb, var(--squisq-page-primary) 40%, transparent);
65
+ }
66
+
67
+ /* Page pattern washes (very low intensity) */
68
+ .squisq-page[data-pattern='dots'] {
69
+ background-image: radial-gradient(color-mix(in srgb, var(--squisq-page-text) 7%, transparent) 1px, transparent 1px);
70
+ background-size: 22px 22px;
71
+ }
72
+ .squisq-page[data-pattern='grid'] {
73
+ background-image:
74
+ linear-gradient(color-mix(in srgb, var(--squisq-page-primary) 7%, transparent) 1px, transparent 1px),
75
+ linear-gradient(90deg, color-mix(in srgb, var(--squisq-page-primary) 7%, transparent) 1px, transparent 1px);
76
+ background-size: 44px 44px;
77
+ }
78
+ .squisq-page[data-pattern='diagonal'] {
79
+ background-image: repeating-linear-gradient(
80
+ -45deg,
81
+ color-mix(in srgb, var(--squisq-page-text) 4%, transparent) 0 1px,
82
+ transparent 1px 14px
83
+ );
84
+ }
85
+ .squisq-page[data-pattern='noise'] { background-image: ${_g}; }
86
+
87
+ /* Spacing scale */
88
+ .squisq-page[data-spacing='compact'] { --squisq-page-section-pad: 2.25rem; }
89
+ .squisq-page[data-spacing='comfortable'] { --squisq-page-section-pad: 3.5rem; }
90
+ .squisq-page[data-spacing='generous'] { --squisq-page-section-pad: 5.25rem; }
91
+
92
+ /* Shadow language */
93
+ .squisq-page[data-shadow='soft'] { --squisq-page-shadow: 0 14px 36px color-mix(in srgb, var(--squisq-page-text) 14%, transparent); }
94
+ .squisq-page[data-shadow='crisp'] { --squisq-page-shadow: 0 2px 10px color-mix(in srgb, var(--squisq-page-text) 26%, transparent); }
95
+ .squisq-page[data-shadow='heavy'] { --squisq-page-shadow: 10px 10px 0 color-mix(in srgb, var(--squisq-page-text) 82%, transparent); }
96
+
97
+ /* \u2500\u2500 Sections \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 */
98
+ .squisq-page-section { position: relative; padding-block: var(--squisq-page-section-pad); }
99
+ .squisq-page-section-inner {
100
+ max-width: var(--squisq-page-content-max);
101
+ margin-inline: auto;
102
+ padding-inline: 24px;
103
+ }
104
+ /* Backdrops anchor to the section; these content roots stack above them. */
105
+ .squisq-page-hero-body,
106
+ .squisq-page-banner-body,
107
+ .squisq-page-quote-figure { position: relative; }
108
+ .squisq-page-section--feature-split .squisq-page-section-inner,
109
+ .squisq-page-section--gallery .squisq-page-section-inner,
110
+ .squisq-page-section--table-section .squisq-page-section-inner,
111
+ .squisq-page-section--canvas-embed .squisq-page-section-inner,
112
+ .squisq-page-section--stat-band .squisq-page-section-inner,
113
+ .squisq-page-section--card-grid .squisq-page-section-inner,
114
+ .squisq-page-section--media-figure .squisq-page-section-inner,
115
+ .squisq-page-section--hero .squisq-page-section-inner {
116
+ max-width: var(--squisq-page-wide-max);
117
+ }
118
+
119
+ /* Background rhythm */
120
+ .squisq-page-section--bg-alternate { background: var(--squisq-page-bg-alt); }
121
+ .squisq-page-section--bg-accent {
122
+ background: var(--squisq-page-accent-bg);
123
+ color: var(--squisq-page-accent-text);
124
+ }
125
+ .squisq-page-section--bg-media { color: #ffffff; }
126
+
127
+ /* Dividers between adjacent sections */
128
+ .squisq-page[data-divider='hairline'] .squisq-page-section + .squisq-page-section { border-top: 1px solid var(--squisq-page-divider-color); }
129
+ .squisq-page[data-divider='thick-rule'] .squisq-page-section + .squisq-page-section { border-top: 3px solid var(--squisq-page-primary); }
130
+ .squisq-page[data-divider='double-rule'] .squisq-page-section + .squisq-page-section { border-top: 4px double var(--squisq-page-divider-color); }
131
+ .squisq-page[data-divider='dotted'] .squisq-page-section + .squisq-page-section { border-top: 2px dotted var(--squisq-page-divider-color); }
132
+ /* Banded sections carry their own edges; media sections never need rules. */
133
+ .squisq-page .squisq-page-section--bg-media,
134
+ .squisq-page .squisq-page-section--bg-media + .squisq-page-section,
135
+ .squisq-page .squisq-page-section--timeline-rail + .squisq-page-section--timeline-rail { border-top: none; }
136
+
137
+ /* \u2500\u2500 Headings, eyebrows \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 */
138
+ .squisq-page-section-title {
139
+ font-family: var(--squisq-page-title-font);
140
+ font-weight: var(--squisq-page-title-weight);
141
+ line-height: 1.15;
142
+ margin: 0 0 0.5em;
143
+ }
144
+ .squisq-page[data-heading-case='uppercase'] .squisq-page-section-title { text-transform: uppercase; letter-spacing: 0.03em; }
145
+ .squisq-page[data-underline='accent-bar'] .squisq-page-section-title::after {
146
+ content: '';
147
+ display: block;
148
+ width: 56px;
149
+ height: 4px;
150
+ margin-top: 0.4em;
151
+ border-radius: 2px;
152
+ background: var(--squisq-page-accent);
153
+ }
154
+ .squisq-page[data-underline='full-rule'] .squisq-page-section-title {
155
+ border-bottom: 1px solid var(--squisq-page-divider-color);
156
+ padding-bottom: 0.35em;
157
+ }
158
+
159
+ .squisq-page-eyebrow {
160
+ display: block;
161
+ font-size: 0.8125rem;
162
+ font-weight: 600;
163
+ letter-spacing: 0.14em;
164
+ text-transform: uppercase;
165
+ color: var(--squisq-page-accent);
166
+ margin: 0 0 0.9em;
167
+ }
168
+ .squisq-page[data-eyebrow='numbered'] .squisq-page-eyebrow::after { content: ' \u2014'; color: var(--squisq-page-text-muted); }
169
+ .squisq-page[data-eyebrow='mono-tag'] .squisq-page-eyebrow {
170
+ display: inline-block;
171
+ font-family: var(--squisq-page-mono-font);
172
+ text-transform: none;
173
+ letter-spacing: 0.06em;
174
+ border: 1px solid color-mix(in srgb, var(--squisq-page-accent) 55%, transparent);
175
+ border-radius: var(--squisq-page-radius);
176
+ padding: 0.15em 0.6em;
177
+ background: color-mix(in srgb, var(--squisq-page-accent) 10%, transparent);
178
+ }
179
+ .squisq-page[data-eyebrow='mono-tag'] .squisq-page-eyebrow::before { content: '['; opacity: 0.6; }
180
+ .squisq-page[data-eyebrow='mono-tag'] .squisq-page-eyebrow::after { content: ']'; opacity: 0.6; }
181
+
182
+ /* \u2500\u2500 Hero \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 */
183
+ .squisq-page-section--hero { padding-block: calc(var(--squisq-page-section-pad) * 1.5); }
184
+ .squisq-page-hero-title {
185
+ font-family: var(--squisq-page-title-font);
186
+ font-weight: var(--squisq-page-title-weight);
187
+ line-height: 1.08;
188
+ margin: 0;
189
+ font-size: 2.75rem;
190
+ }
191
+ .squisq-page[data-heading-scale='display'] .squisq-page-hero-title { font-size: 3.4rem; }
192
+ .squisq-page[data-heading-scale='oversized'] .squisq-page-hero-title { font-size: 4rem; font-size: clamp(3rem, 9cqw, 6rem); line-height: 1.02; }
193
+ .squisq-page[data-heading-case='uppercase'] .squisq-page-hero-title { text-transform: uppercase; letter-spacing: 0.02em; }
194
+ .squisq-page-hero-subtitle {
195
+ margin: 1.1em 0 0;
196
+ font-size: 1.25rem;
197
+ color: var(--squisq-page-text-muted);
198
+ max-width: 42em;
199
+ white-space: pre-line;
200
+ }
201
+ .squisq-page-section--bg-media .squisq-page-hero-subtitle { color: rgba(255, 255, 255, 0.88); }
202
+
203
+ /* Stacked (default): centered column */
204
+ .squisq-page[data-hero-style='stacked'] .squisq-page-hero-body { text-align: center; }
205
+ .squisq-page[data-hero-style='stacked'] .squisq-page-hero-subtitle { margin-inline: auto; }
206
+
207
+ /* Oversized type: hard left, no decoration */
208
+ .squisq-page[data-hero-style='oversized-type'] .squisq-page-hero-title { font-size: 4.25rem; font-size: clamp(3.25rem, 10cqw, 6.5rem); line-height: 0.98; }
209
+
210
+ /* Split: text and media side by side */
211
+ .squisq-page-hero-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3rem; align-items: center; }
212
+ .squisq-page-hero-grid .squisq-page-hero-media img { width: 100%; object-fit: cover; }
213
+
214
+ /* Full-bleed & letterbox: media behind text */
215
+ .squisq-page-section--hero-media {
216
+ padding-block: 0;
217
+ min-height: min(72svh, 620px);
218
+ display: flex;
219
+ align-items: flex-end;
220
+ }
221
+ .squisq-page[data-hero-style='letterbox'] .squisq-page-section--hero-media { min-height: min(52svh, 460px); }
222
+ .squisq-page-hero-backdrop { position: absolute; inset: 0; overflow: hidden; }
223
+ .squisq-page-hero-backdrop img { width: 100%; height: 100%; object-fit: cover; }
224
+ .squisq-page-hero-backdrop::after {
225
+ content: '';
226
+ position: absolute;
227
+ inset: 0;
228
+ background: linear-gradient(180deg, rgba(0, 0, 0, 0.1) 30%, rgba(0, 0, 0, 0.68) 100%);
229
+ }
230
+ .squisq-page[data-hero-style='letterbox'] .squisq-page-hero-backdrop img { filter: saturate(0.9); }
231
+ .squisq-page-section--hero-media .squisq-page-section-inner { padding-block: 3rem; width: 100%; }
232
+
233
+ /* \u2500\u2500 Banner (sectionHeader) \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 */
234
+ .squisq-page-banner-title { font-size: 2rem; }
235
+ .squisq-page[data-heading-scale='display'] .squisq-page-banner-title { font-size: 2.5rem; }
236
+ .squisq-page[data-heading-scale='oversized'] .squisq-page-banner-title { font-size: 3rem; font-size: clamp(2.25rem, 6cqw, 3.75rem); }
237
+ .squisq-page-section--banner.squisq-page-section--bg-media { padding-block: 0; min-height: 280px; display: flex; align-items: flex-end; }
238
+ .squisq-page-section--banner.squisq-page-section--bg-media .squisq-page-section-inner { padding-block: 2rem; width: 100%; }
239
+ .squisq-page-section--banner .squisq-page-section-title { margin-bottom: 0; }
240
+
241
+ /* \u2500\u2500 Stat band \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 */
242
+ .squisq-page-stats { display: flex; gap: 3rem; justify-content: center; text-align: center; flex-wrap: wrap; }
243
+ .squisq-page-stat { flex: 1 1 220px; max-width: 420px; }
244
+ .squisq-page-stat-value {
245
+ display: block;
246
+ font-family: var(--squisq-page-title-font);
247
+ font-weight: 700;
248
+ font-size: 3.25rem;
249
+ line-height: 1;
250
+ color: var(--squisq-page-accent);
251
+ }
252
+ .squisq-page[data-numerals='oversized'] .squisq-page-stat-value { font-size: 4.5rem; font-size: clamp(3.5rem, 8cqw, 5.5rem); }
253
+ .squisq-page[data-numerals='mono'] .squisq-page-stat-value { font-family: var(--squisq-page-mono-font); letter-spacing: -0.02em; }
254
+ .squisq-page[data-numerals='boxed'] .squisq-page-stat-value {
255
+ display: inline-block;
256
+ border: 2px solid var(--squisq-page-accent);
257
+ border-radius: var(--squisq-page-radius);
258
+ padding: 0.18em 0.4em;
259
+ }
260
+ .squisq-page-stat-title { display: block; margin-top: 0.9em; font-size: 1.125rem; font-weight: 600; }
261
+ .squisq-page-stat-body { display: block; margin-top: 0.45em; color: var(--squisq-page-text-muted); font-size: 0.95rem; }
262
+ .squisq-page-stat-meta { text-align: center; margin-top: 1.5rem; color: var(--squisq-page-text-muted); font-size: 0.85rem; }
263
+ .squisq-page-stat-bar { height: 10px; border-radius: 999px; background: var(--squisq-page-accent); margin-top: 0.8em; }
264
+ .squisq-page-stat--bars { text-align: left; }
265
+
266
+ /* \u2500\u2500 Quote band \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 */
267
+ .squisq-page-quote {
268
+ margin: 0;
269
+ font-family: var(--squisq-page-title-font);
270
+ font-size: 1.6rem;
271
+ line-height: 1.35;
272
+ white-space: pre-line;
273
+ }
274
+ .squisq-page-section--em-strong .squisq-page-quote { font-size: 2.1rem; }
275
+ .squisq-page-section--em-quiet .squisq-page-quote { font-size: 1.25rem; color: var(--squisq-page-text-muted); }
276
+ .squisq-page-quote-attribution { margin-top: 1.1em; font-family: var(--squisq-page-body-font); font-size: 0.95rem; color: var(--squisq-page-text-muted); }
277
+ .squisq-page-quote-attribution::before { content: '\u2014 '; }
278
+ .squisq-page[data-quote-mark='accent-bar'] .squisq-page-quote-figure { border-left: 4px solid var(--squisq-page-accent); padding-left: 1.5rem; }
279
+ .squisq-page[data-quote-mark='oversized-glyph'] .squisq-page-quote-figure { position: relative; padding-top: 1.25rem; }
280
+ .squisq-page[data-quote-mark='oversized-glyph'] .squisq-page-quote-figure::before {
281
+ content: '\\201C';
282
+ position: absolute;
283
+ top: -0.12em;
284
+ left: -0.05em;
285
+ font-family: var(--squisq-page-title-font);
286
+ font-size: 5.5rem;
287
+ line-height: 1;
288
+ color: color-mix(in srgb, var(--squisq-page-accent) 42%, transparent);
289
+ pointer-events: none;
290
+ }
291
+ .squisq-page-section--v-display .squisq-page-quote-figure { text-align: center; border-left: none; }
292
+ .squisq-page-section--v-display .squisq-page-quote { font-size: 2.4rem; font-size: clamp(1.9rem, 5cqw, 3rem); }
293
+ .squisq-page-section--v-editorial .squisq-page-quote-figure {
294
+ border-block: 3px solid var(--squisq-page-primary);
295
+ border-left: none;
296
+ padding: 2rem 0.5rem;
297
+ }
298
+ /* Full-bleed quote over media */
299
+ .squisq-page-section--quote-band.squisq-page-section--bg-media { padding-block: 0; min-height: 380px; display: flex; align-items: center; }
300
+ .squisq-page-section--quote-band.squisq-page-section--bg-media .squisq-page-section-inner { padding-block: 3.5rem; }
301
+ .squisq-page-quote-backdrop { position: absolute; inset: 0; overflow: hidden; }
302
+ .squisq-page-quote-backdrop img, .squisq-page-quote-backdrop video { width: 100%; height: 100%; object-fit: cover; }
303
+ .squisq-page-quote-backdrop::after { content: ''; position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); }
304
+ .squisq-page-section--quote-band[data-hint-vignette] .squisq-page-quote-backdrop::after {
305
+ background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.35) 0%, rgba(0, 0, 0, 0.75) 100%);
306
+ }
307
+ .squisq-page-section--quote-band.squisq-page-section--bg-media .squisq-page-quote-figure { border: none; text-align: center; }
308
+
309
+ /* \u2500\u2500 Feature split \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 */
310
+ .squisq-page-feature { display: grid; grid-template-columns: 1fr 1fr; gap: 3rem; align-items: center; }
311
+ .squisq-page-feature--media-right .squisq-page-feature-media { order: 2; }
312
+ .squisq-page-feature-media img { width: 100%; object-fit: cover; }
313
+ .squisq-page-feature-title { font-size: 1.75rem; }
314
+ .squisq-page-feature-body { color: var(--squisq-page-text-muted); font-size: 1.05rem; white-space: pre-line; margin: 0; }
315
+
316
+ /* \u2500\u2500 Media figure \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 */
317
+ .squisq-page-figure { margin: 0; }
318
+ .squisq-page-figure img, .squisq-page-figure video { width: 100%; display: block; }
319
+ .squisq-page-figure figcaption { margin-top: 0.9em; font-size: 0.9rem; color: var(--squisq-page-text-muted); text-align: center; }
320
+ .squisq-page-media-credit { font-size: 0.78rem; opacity: 0.75; }
321
+
322
+ /* Media frame treatment (figures, features, gallery tiles, cards) */
323
+ .squisq-page-media-frame { overflow: hidden; }
324
+ .squisq-page[data-framing='rounded'] .squisq-page-media-frame { border-radius: var(--squisq-page-radius); }
325
+ .squisq-page[data-framing='bordered'] .squisq-page-media-frame { border: 3px solid var(--squisq-page-text); }
326
+ .squisq-page[data-framing='polaroid'] .squisq-page-media-frame {
327
+ background: #ffffff;
328
+ padding: 10px 10px 16px;
329
+ border: 1px solid rgba(0, 0, 0, 0.12);
330
+ border-radius: 2px;
331
+ }
332
+ .squisq-page[data-framing='letterboxed'] .squisq-page-media-frame img { aspect-ratio: 21 / 9; object-fit: cover; }
333
+ .squisq-page[data-framing='circle-accent'] .squisq-page-media-frame { border-radius: calc(var(--squisq-page-radius) * 2); }
334
+ .squisq-page .squisq-page-media-frame { box-shadow: var(--squisq-page-shadow); }
335
+
336
+ /* Rich body nodes that the selected template did not consume. This universal
337
+ * supplement keeps diagrams/media visible without making every template
338
+ * duplicate the same preservation logic. */
339
+ .squisq-page-rich-content {
340
+ margin-top: clamp(1.5rem, 4vw, 3rem);
341
+ padding-top: clamp(1.25rem, 3vw, 2rem);
342
+ border-top: 1px solid var(--squisq-page-divider-color);
343
+ }
344
+ .squisq-page-rich-content :is(img, video) { display: block; max-width: 100%; height: auto; margin-inline: auto; }
345
+ .squisq-page-rich-content .squisq-md-mermaid { min-height: min(520px, 62vh); margin-block: 0; }
346
+
347
+ /* \u2500\u2500 Gallery \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 */
348
+ .squisq-page-gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.25rem; }
349
+ .squisq-page-gallery .squisq-page-media-frame img { width: 100%; height: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
350
+ .squisq-page-gallery-caption { margin-top: 1.1rem; text-align: center; font-size: 0.9rem; color: var(--squisq-page-text-muted); }
351
+
352
+ /* \u2500\u2500 Callout \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 */
353
+ .squisq-page-callout {
354
+ border-radius: var(--squisq-page-radius);
355
+ border: 1px solid color-mix(in srgb, var(--squisq-page-accent) 32%, transparent);
356
+ border-left: 5px solid var(--squisq-page-accent);
357
+ background: color-mix(in srgb, var(--squisq-page-accent) 7%, var(--squisq-page-bg));
358
+ padding: 1.75rem 2rem;
359
+ box-shadow: var(--squisq-page-shadow);
360
+ display: flex;
361
+ gap: 1.75rem;
362
+ align-items: flex-start;
363
+ }
364
+ .squisq-page-callout-title { font-family: var(--squisq-page-title-font); font-size: 1.35rem; font-weight: 700; margin: 0 0 0.5em; }
365
+ .squisq-page-callout-body { margin: 0; white-space: pre-line; }
366
+ .squisq-page-callout-meta { margin-top: 0.9em; font-size: 0.82rem; color: var(--squisq-page-text-muted); }
367
+ .squisq-page-callout .squisq-page-media-frame { flex: 0 0 132px; }
368
+ .squisq-page-callout .squisq-page-media-frame img { width: 132px; height: 132px; object-fit: cover; }
369
+ .squisq-page-callout[data-hint-framing='circle-accent'] .squisq-page-media-frame,
370
+ .squisq-page-callout[data-hint-framing='circle-accent'] .squisq-page-media-frame img { border-radius: 50%; }
371
+ .squisq-page-section--v-definition .squisq-page-callout-title { font-style: italic; }
372
+ .squisq-page-section--v-diagnostic .squisq-page-callout { border-left-color: var(--squisq-page-highlight); }
373
+
374
+ /* \u2500\u2500 Card grid \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 */
375
+ .squisq-page-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.5rem; }
376
+ .squisq-page-card {
377
+ border-radius: var(--squisq-page-radius);
378
+ background: var(--squisq-page-bg-alt);
379
+ border-top: 4px solid var(--squisq-page-card-accent, var(--squisq-page-accent));
380
+ padding: 1.75rem 1.75rem 1.9rem;
381
+ box-shadow: var(--squisq-page-shadow);
382
+ }
383
+ .squisq-page-card-title { font-family: var(--squisq-page-title-font); font-size: 1.3rem; margin: 0 0 0.4em; }
384
+ .squisq-page-card-body { margin: 0; color: var(--squisq-page-text-muted); white-space: pre-line; }
385
+ .squisq-page-cards-title { text-align: center; font-size: 1.9rem; margin-bottom: 1.75rem; }
386
+
387
+ /* \u2500\u2500 Item list \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 */
388
+ .squisq-page-items { list-style: none; margin: 0; padding: 0; counter-reset: squisq-item; max-width: 40em; }
389
+ .squisq-page-items li {
390
+ counter-increment: squisq-item;
391
+ /* Grid + baseline alignment keeps the marker locked to the first text line
392
+ regardless of marker size, body font, or line-height \u2014 an absolutely
393
+ positioned marker with a fixed top offset drifts as soon as either
394
+ changes. */
395
+ display: grid;
396
+ grid-template-columns: 3.4em 1fr;
397
+ align-items: baseline;
398
+ padding: 0.9em 0;
399
+ font-size: 1.1rem;
400
+ }
401
+ .squisq-page-items li + li { border-top: 1px solid var(--squisq-page-divider-color); }
402
+ .squisq-page-items li::before {
403
+ content: counter(squisq-item, decimal-leading-zero);
404
+ font-family: var(--squisq-page-title-font);
405
+ font-weight: 700;
406
+ color: var(--squisq-page-accent);
407
+ font-size: 1.15em;
408
+ }
409
+ /* Item bodies are rendered markdown: neutralize UA paragraph margins (which
410
+ would otherwise push the first line below the marker) and space blocks. */
411
+ .squisq-page-item-body { min-width: 0; }
412
+ .squisq-page-item-body > * { margin: 0; }
413
+ .squisq-page-item-body > * + * { margin-top: 0.6em; }
414
+ .squisq-page[data-numerals='mono'] .squisq-page-items li::before { font-family: var(--squisq-page-mono-font); }
415
+ .squisq-page-items-title { font-size: 1.9rem; }
416
+
417
+ /* \u2500\u2500 Timeline rail (dateEvent) \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 */
418
+ .squisq-page-section--timeline-rail { padding-block: 1.4rem; }
419
+ .squisq-page-section--timeline-rail:first-child { padding-top: var(--squisq-page-section-pad); }
420
+ .squisq-page-milestone { display: grid; grid-template-columns: 150px 1fr; gap: 2rem; align-items: baseline; position: relative; }
421
+ .squisq-page-milestone-date {
422
+ font-family: var(--squisq-page-title-font);
423
+ font-weight: 700;
424
+ color: var(--squisq-page-accent);
425
+ font-size: 1.05rem;
426
+ text-align: right;
427
+ }
428
+ .squisq-page-milestone-rail {
429
+ position: absolute;
430
+ left: 166px;
431
+ top: -1.4rem;
432
+ bottom: -1.4rem;
433
+ width: 2px;
434
+ background: color-mix(in srgb, var(--squisq-page-accent) 35%, transparent);
435
+ }
436
+ .squisq-page-milestone-rail::after {
437
+ content: '';
438
+ position: absolute;
439
+ left: 50%;
440
+ top: 0.55em;
441
+ width: 12px;
442
+ height: 12px;
443
+ border-radius: 50%;
444
+ transform: translateX(-50%);
445
+ background: var(--squisq-page-accent);
446
+ border: 2px solid var(--squisq-page-bg);
447
+ }
448
+ .squisq-page-milestone-body { padding-left: 2.25rem; white-space: pre-line; }
449
+ .squisq-page-milestone-footer { margin-top: 0.5em; font-size: 0.85rem; color: var(--squisq-page-text-muted); }
450
+
451
+ /* \u2500\u2500 Table section \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 */
452
+ .squisq-page-table-title { font-size: 1.9rem; }
453
+ .squisq-page-table-scroll { overflow-x: auto; border-radius: var(--squisq-page-radius); box-shadow: var(--squisq-page-shadow); }
454
+ .squisq-page-table { width: 100%; border-collapse: collapse; font-size: 0.98rem; }
455
+ .squisq-page-table th {
456
+ background: var(--squisq-page-accent-bg);
457
+ color: var(--squisq-page-accent-text);
458
+ font-family: var(--squisq-page-title-font);
459
+ text-align: left;
460
+ padding: 0.8em 1em;
461
+ }
462
+ .squisq-page-table td { padding: 0.7em 1em; border-top: 1px solid var(--squisq-page-divider-color); }
463
+ .squisq-page-table tbody tr:nth-child(even) { background: color-mix(in srgb, var(--squisq-page-text) 3.5%, transparent); }
464
+
465
+ /* \u2500\u2500 Canvas embed (spatial SVG) \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 */
466
+ .squisq-page-canvas {
467
+ width: 100%;
468
+ margin-inline: auto;
469
+ overflow: hidden;
470
+ border-radius: var(--squisq-page-radius);
471
+ }
472
+ .squisq-page-canvas svg { display: block; width: 100%; height: 100%; }
473
+ .squisq-page-canvas--framed { border: 1px solid var(--squisq-page-divider-color); box-shadow: var(--squisq-page-shadow); }
474
+ .squisq-page-canvas--terminal { border: 1px solid color-mix(in srgb, var(--squisq-page-accent) 45%, transparent); }
475
+ .squisq-page-canvas--terminal::before {
476
+ content: '\\25CF \\25CF \\25CF';
477
+ display: block;
478
+ font-size: 9px;
479
+ letter-spacing: 4px;
480
+ padding: 6px 12px;
481
+ color: color-mix(in srgb, var(--squisq-page-accent) 70%, transparent);
482
+ background: color-mix(in srgb, var(--squisq-page-accent) 9%, var(--squisq-page-bg));
483
+ border-bottom: 1px solid color-mix(in srgb, var(--squisq-page-accent) 30%, transparent);
484
+ }
485
+
486
+ /* \u2500\u2500 Prose \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 */
487
+ .squisq-page-section--prose { padding-block: calc(var(--squisq-page-section-pad) * 0.45); }
488
+ .squisq-page[data-divider] .squisq-page-section--prose + .squisq-page-section--prose { border-top: none; }
489
+ .squisq-page-prose { font-size: 1.05rem; }
490
+ .squisq-page-prose p { margin: 0; }
491
+ .squisq-page-prose p + p { margin-top: 1.25em; }
492
+ .squisq-page-prose > * + * { margin-top: 1.1em; }
493
+ .squisq-page-prose code { font-family: var(--squisq-page-mono-font); font-size: 0.9em; }
494
+ .squisq-page-prose :not(pre) > code { background: color-mix(in srgb, var(--squisq-page-text) 8%, transparent); border-radius: 4px; padding: 0.12em 0.35em; }
495
+ .squisq-page-prose pre { background: color-mix(in srgb, var(--squisq-page-text) 6%, transparent); border-radius: var(--squisq-page-radius); padding: 1em 1.25em; overflow-x: auto; }
496
+ .squisq-page-prose pre code { background: none; border-radius: 0; padding: 0; }
497
+ .squisq-page .squisq-md-code-frame { position: relative; margin: 1em 0; }
498
+ .squisq-page .squisq-md-code-frame > pre { margin: 0; padding-right: 5rem; }
499
+ .squisq-page .squisq-md-code-copy {
500
+ position: absolute;
501
+ z-index: 1;
502
+ top: 0.55rem;
503
+ right: 0.55rem;
504
+ min-width: 3.7rem;
505
+ padding: 0.28rem 0.5rem;
506
+ border: 1px solid color-mix(in srgb, var(--squisq-page-text) 20%, transparent);
507
+ border-radius: 5px;
508
+ background: color-mix(in srgb, var(--squisq-page-bg) 90%, transparent);
509
+ color: inherit;
510
+ font: 500 0.72rem/1.2 system-ui, sans-serif;
511
+ cursor: pointer;
512
+ opacity: 0.58;
513
+ transition: opacity 120ms ease, background-color 120ms ease;
514
+ }
515
+ .squisq-page .squisq-md-code-frame:hover > .squisq-md-code-copy,
516
+ .squisq-page .squisq-md-code-copy:focus-visible,
517
+ .squisq-page .squisq-md-code-copy[data-copy-state='copied'],
518
+ .squisq-page .squisq-md-code-copy[data-copy-state='failed'] { opacity: 1; }
519
+ .squisq-page .squisq-md-code-copy:hover { background: var(--squisq-page-bg); }
520
+ .squisq-page .squisq-md-code-copy:disabled { cursor: wait; }
521
+ .squisq-page-prose blockquote { margin: 0; border-left: 4px solid var(--squisq-page-accent); padding-left: 1.25em; color: var(--squisq-page-text-muted); }
522
+ .squisq-page-prose ul, .squisq-page-prose ol { padding-left: 1.5em; margin: 0; }
523
+ .squisq-page-prose li + li { margin-top: 0.4em; }
524
+ .squisq-page-prose hr { border: none; border-top: 1px solid var(--squisq-page-divider-color); }
525
+ .squisq-page-prose table { width: 100%; border-collapse: collapse; }
526
+ .squisq-page-prose th { font-family: var(--squisq-page-title-font); text-align: left; padding: 0.6em 0.8em; border-bottom: 2px solid var(--squisq-page-divider-color); }
527
+ .squisq-page-prose td { padding: 0.55em 0.8em; border-bottom: 1px solid var(--squisq-page-divider-color); }
528
+ .squisq-page-prose img { border-radius: var(--squisq-page-radius); }
529
+ .squisq-page-prose h1, .squisq-page-prose h2, .squisq-page-prose h3,
530
+ .squisq-page-prose h4, .squisq-page-prose h5, .squisq-page-prose h6 {
531
+ font-family: var(--squisq-page-title-font);
532
+ font-weight: var(--squisq-page-title-weight);
533
+ line-height: 1.2;
534
+ margin: 0 0 0.45em;
535
+ }
536
+ .squisq-page-prose h1 { font-size: 2.1rem; }
537
+ .squisq-page-prose h2 { font-size: 1.65rem; }
538
+ .squisq-page-prose h3 { font-size: 1.35rem; }
539
+ .squisq-page-prose h4, .squisq-page-prose h5, .squisq-page-prose h6 { font-size: 1.15rem; }
540
+ .squisq-page-section--prose[data-hint-drop-cap] .squisq-page-prose > p:first-child::first-letter {
541
+ font-family: var(--squisq-page-title-font);
542
+ font-size: 3.4em;
543
+ font-weight: 700;
544
+ float: left;
545
+ line-height: 0.85;
546
+ padding-right: 0.12em;
547
+ color: var(--squisq-page-accent);
548
+ }
549
+
550
+ /* \u2500\u2500 Footer band \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 */
551
+ .squisq-page-section--footer { text-align: center; }
552
+
553
+ /* \u2500\u2500 Thin-margin embedding (chat bubbles) \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 */
554
+ .squisq-page--thin .squisq-page-section-inner { padding-inline: 0; }
555
+ .squisq-page--thin .squisq-page-section { padding-block: 1.5rem; }
556
+
557
+ /* Thumbnail image mode */
558
+ .squisq-page--thumbnail-images .squisq-page-prose img,
559
+ .squisq-page--thumbnail-images .squisq-page-figure img { max-width: 100px; max-height: 100px; object-fit: cover; }
560
+
561
+ /* \u2500\u2500 Reveal animation (progressive enhancement) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
562
+ @media (prefers-reduced-motion: no-preference) {
563
+ .squisq-page-reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.55s ease, transform 0.55s ease; }
564
+ .squisq-page-reveal--in { opacity: 1; transform: none; }
565
+ }
566
+
567
+ /* \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 */
568
+ @container squisq-page (max-width: 720px) {
569
+ ${bg}
570
+ }
571
+ @supports not (container-type: inline-size) {
572
+ @media (max-width: 720px) {
573
+ ${bg}
574
+ }
575
+ }
576
+ `;function Sg(e){let t=vg(e);return`.squisq-page {
577
+ ${Object.entries(t).map(([e,t])=>` ${e}: ${t};`).join(`
578
+ `)}
579
+ }
580
+ ${xg}`}var Cg=[1,1.5,2];function wg(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 Cg.find(e=>Math.abs(e-n)<.001)}var Tg=new Set([`content`,`list`,`quote`,`definitionCard`,`factCard`,`dateEvent`]),Eg=160,Dg=360;function Og(e){return!e.template||!Tg.has(e.template)?1:e.textLength<Eg?2:e.textLength<Dg?1.5:1}function kg(e,t){let n=e.map(e=>e.explicit===void 0?t===`auto`?Og(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 Ag=32,jg=64,Mg=/^[a-z0-9][a-z0-9-]*$/;function Ng(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 Pg(e){return`${Math.round(e*1e3)/1e3}%`}function Fg(e,t,n){if(!e||typeof e!=`object`){n.push({path:t,message:`cell must be an object`});return}let r=e,i=Ng(r.x),a=Ng(r.y),o=Ng(r.width),s=Ng(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:Pg(i),y:Pg(a),width:Pg(o),height:Pg(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>jg){n.push({path:`${t}.block`,message:`block must be an integer between 1 and ${jg}`});return}c.block=e}if(r.zoom!==void 0){let e=wg(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 Ig(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>Ag){n.push({path:t,message:`must contain between 1 and ${Ag} cells`});return}let r=[];for(let i=0;i<e.length;i++){let a=Fg(e[i],`${t}[${i}]`,n);if(!a)return;r.push(a)}return r}function Lg(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=Ng(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:Pg(i)}}function Rg(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():``;Mg.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=Ig(a.landscape,`cells.landscape`,t),a.portrait!==void 0&&(s=Ig(a.portrait,`cells.portrait`,t)),a.square!==void 0&&(c=Ig(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=Lg(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 zg(e){return e.cells.landscape.length}function Bg(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 Vg(e,t,n){return(t===`portrait`?e.cells.portrait??Bg(e.cells.landscape):t===`square`?e.cells.square??e.cells.landscape:e.cells.landscape).map(e=>{let t=Ng(e.x)??0,r=Ng(e.y)??0,i=Ng(e.width)??0,a=Ng(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=wg(e.zoom);return s!==void 0&&(o.zoom=s),o})}var Hg=`squisq-dashboard-layouts`,Ug={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`},Wg=Object.fromEntries(Object.entries(Ug).map(([e,t])=>[t,e]));function Gg(e,t){if(Array.isArray(e))return e.map(e=>Gg(e,t));if(e&&typeof e==`object`){let n={};for(let[r,i]of Object.entries(e))n[t[r]??r]=Gg(i,t);return n}return e}function Kg(e){if(!e)return;let t=Zg(e[Hg]);if(!t)return;let n=[];for(let e of t){let t=Rg(e);t.layout&&n.push(t.layout)}return n.length>0?n:void 0}function qg(e,t){if(!e||e.length===0)return;let n={};for(let t of e){let{name:e,...r}=t;n[e]=Gg(r,Ug)}return JSON.stringify(n,null,t?.pretty?2:void 0)}function Jg(e){return Object.entries(e).map(([e,t])=>({name:e,...Gg(t&&typeof t==`object`?t:{},Wg)}))}function Yg(e){return Array.isArray(e)?e:e&&typeof e==`object`?Jg(e):null}function Xg(e){try{return JSON.parse(e)}catch{return}}function Zg(e){if(e==null)return null;if(Array.isArray(e))return e;if(typeof e==`object`)return Jg(e);if(typeof e!=`string`)return null;let t=Xg(e.trim());return t===void 0?null:Yg(t)}var Qg=2;function $(e){return`${Math.round(e*1e3)/1e3}%`}function $g(e,t,n=Qg){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:$(t*(r+n)),y:$(o*(i+n)),width:$(r),height:$(i)});return a}function e_(e,t,n=Qg){let r=e+n,i=100-r,a=(100-(t-1)*n)/t,o=[{x:`0%`,y:`0%`,width:$(e),height:`100%`}];for(let e=0;e<t;e++)o.push({x:$(r),y:$(e*(a+n)),width:$(i),height:$(a)});return o}function t_(e,t,n=Qg){let r=e+n,i=100-r,a=(100-(t-1)*n)/t,o=[{x:`0%`,y:`0%`,width:`100%`,height:$(e)}];for(let e=0;e<t;e++)o.push({x:$(e*(a+n)),y:$(r),width:$(a),height:$(i)});return o}function n_(e,t=Qg){let n=e+t,r=(100-n-t)/2,i=(100-t)/2,a=[{x:`0%`,y:`0%`,width:$(e),height:`100%`}];for(let e=0;e<2;e++)for(let o=0;o<2;o++)a.push({x:$(n+o*(r+t)),y:$(e*(i+t)),width:$(r),height:$(i)});return a}var r_=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:$g(2,1)}},{name:`hero-left`,label:`Hero + 2`,description:`A large lead block with two companions.`,cells:{landscape:e_(58,2),portrait:[{x:`0%`,y:`0%`,width:`100%`,height:$(46)},{x:`0%`,y:$(48),width:`100%`,height:$(25)},{x:`0%`,y:$(75),width:`100%`,height:$(25)}]}},{name:`grid-2x2`,label:`Grid 2×2`,description:`Four blocks in a balanced grid.`,cells:{landscape:$g(2,2)}},{name:`hero-top`,label:`Hero band`,description:`A wide lead band with three blocks below.`,cells:{landscape:t_(46,3),portrait:[{x:`0%`,y:`0%`,width:`100%`,height:$(40)},{x:`0%`,y:$(42),width:`100%`,height:$(18)},{x:`0%`,y:$(62),width:`100%`,height:$(18)},{x:`0%`,y:$(82),width:`100%`,height:$(18)}]},auto:!1},{name:`mosaic-5`,label:`Mosaic`,description:`A hero block beside a 2×2 grid.`,cells:{landscape:n_(58),portrait:[{x:`0%`,y:`0%`,width:`100%`,height:$(40)},{x:`0%`,y:$(42),width:$(49),height:$(27)},{x:$(51),y:$(42),width:$(49),height:$(27)},{x:`0%`,y:$(71),width:$(49),height:$(29)},{x:$(51),y:$(71),width:$(49),height:$(29)}]}},{name:`grid-3x2`,label:`Grid 3×2`,description:`Six blocks in three columns.`,cells:{landscape:$g(3,2)}},{name:`grid-3x3`,label:`Grid 3×3`,description:`Nine blocks in a square grid.`,cells:{landscape:$g(3,3),square:$g(3,3)}},{name:`grid-4x3`,label:`Grid 4×3`,description:`Twelve blocks in four columns.`,cells:{landscape:$g(4,3)}},{name:`grid-4x4`,label:`Grid 4×4`,description:`Sixteen blocks — the densest wall.`,cells:{landscape:$g(4,4)}}]);function i_(e,t){return{id:e.name,label:e.label,...e.description?{description:e.description}:{},capacity:zg(e),custom:t}}function a_(){return r_.map(e=>i_(e,!1))}function o_(e){let t=Kg(e?.frontmatter)??[],n=new Set(t.map(e=>e.name));return[...t.map(e=>i_(e,!0)),...r_.filter(e=>!n.has(e.name)).map(e=>i_(e,!1))]}var s_=`auto`;function c_(e,t){let n=e.trim().toLowerCase();if(n)return t?.find(e=>e.name===n)??r_.find(e=>e.name===n)}function l_(e,t,n){let r=[...(n??[]).filter(e=>e.auto!==!1),...r_.filter(e=>e.auto!==!1)].sort((e,t)=>zg(e)-zg(t)),i=Math.max(1,e),a=r.find(e=>zg(e)>=i);if(a)return a;let o=r.reduce((e,t)=>Math.max(e,zg(t)),0);return r.find(e=>zg(e)===o)??r_[0]}var u_=[`basic`,`card`,`panel`,`accent`],d_=`basic`,f_=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 p_(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`:u_.includes(t)?t:void 0}function m_(e,t,n){return Math.min(n,Math.max(t,e))}function h_(e){return x(e)>.45}function g_(e,t){let n=t.colors.background;return e===`basic`||e===`panel`?n:h_(n)?b(n,.05):P(n,.04)}function __(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 v_(e,t,n){let r=Math.max(1,Math.min(n.width,n.height)),i=t.style?.borderRadius??14;return e===`panel`?{edge:m_(r*.014,3,12),radius:m_(i*.45,0,r*.05)}:{edge:m_(r*.03,6,26),radius:m_(i,6,r*.1)}}function y_(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 b_(e,t){let{theme:n,rect:r,index:i}=t;if(e===`basic`)return null;let{edge:a,radius:o}=v_(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=__(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=y_(o,s);return g&&(h.contentRadiusPct=g),h}function x_(e){return e!==`basic`}function S_(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 C_=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`}}),w_=Object.freeze({layout:s_,showTitle:!0,zoom:`auto`,style:d_});function T_(e,t){if(e)return Object.prototype.hasOwnProperty.call(e,t.canonical)?e[t.canonical]:e[t.legacy]}function E_(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 D_(e){if(typeof e!=`string`)return;let t=e.trim().toLowerCase();if(t)return t===`auto`||t==="default"?s_:t}function O_(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 k_(e,t={}){let n={layout:D_(T_(e,C_.layout))??w_.layout,showTitle:E_(T_(e,C_.showTitle))??w_.showTitle,zoom:O_(T_(e,C_.zoom))??w_.zoom,style:p_(T_(e,C_.style))??w_.style};return{layout:D_(t.layout)??n.layout,showTitle:t.showTitle??n.showTitle,zoom:t.zoom??n.zoom,style:p_(t.style)??n.style}}var A_={placement:`top`,height:`9%`},j_=.015,M_=.02;function N_(e){let t=Number(e.trim().replace(/%$/,``));return Number.isFinite(t)?t:0}function P_(e,t){return`${Math.round(e/Math.max(1,t)*1e5)/1e3}%`}function F_(e,t){return{left:P_(e.x,t.width),top:P_(e.y,t.height),width:P_(e.width,t.width),height:P_(e.height,t.height)}}function I_(e,t){let n=e.frontmatter?.title;return typeof n==`string`&&n.trim()?n.trim():t?.trim()??``}function L_(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 R_(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:U(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 z_(e,t={}){let n=t.theme??A,r=t.viewport??f.landscape,i=_(r),a=t.customLayouts??Kg(e.frontmatter),o=t.customTemplates??e.customTemplates,s=[],c=k_(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=Rg(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=c_(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=xh(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?I_(e,t.documentTitle):``,g=h.length>0;g&&(m=L_(m,h)),u||(u=l_(m.length,i,a),d=`auto`);let v=M_*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??A_,t=Math.min(40,Math.max(2,N_(e.height)))/100*r.height,i=j_*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:F_(a,r),viewport:o,layers:R_(h,o,e,n,r,v)}}let x=Vg(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=kg(D.map(({candidateIndex:e,explicitZoom:t})=>{let n=m[e],r=typeof n.title==`string`?n.title:``;return{template:R(n.template??``),textLength:r.length+Qp(n).length,...t===void 0?{}:{explicit:t}}}),c.zoom),k=o&&o.length>0?Dd(o):Ed,j=D.map(({cellIndex:e,rect:i,candidateIndex:a},o)=>{let s=m[a],c=O[o],u=b_(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=sf(s,{theme:n,viewport:f,persistentLayers:!1,blockIndex:a,totalBlocks:m.length,failureMode:t.failureMode},{registry:k,templateContext:h}),_=x_(l)?S_(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:F_(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:F_(d,r),...v?{frame:v}:{},viewport:f,zoom:c,source:g.source,...g.diagnostic?{diagnostic:g.diagnostic}:{}}}),M=Di(e,n),N=g_(l,n),P={fill:N,bottomLayers:[{type:`shape`,id:`dashboard-backdrop`,content:{shape:`rect`,fill:N},position:{x:0,y:0,width:`100%`,height:`100%`}},...Ti(M?.bottomLayers,n)],topLayers:Ti(M?.topLayers,n)};return{layout:u,layoutSource:d,style:l,viewport:r,cells:j,title:b,backdrop:P,diagnostics:s}}function B_(e){let t=[...e.backdrop.bottomLayers];for(let n of e.cells)n.frame&&t.push(...Hc(n.frame.layers,n.frame.viewport,n.frame.rect,`cell-${n.index}-frame`)),t.push(...Hc(n.layers,n.viewport,n.rect,`cell-${n.index}`)),n.frame&&n.frame.overlayLayers.length>0&&t.push(...Hc(n.frame.overlayLayers,n.frame.overlayViewport,n.rect,`cell-${n.index}-overlay`));return e.title&&t.push(...Hc(e.title.layers,e.title.viewport,e.title.rect,`dashboard-title`)),t.push(...e.backdrop.topLayers),t}var V_=new Set([`answer`,`back`,`solution`,`explanation`,`correct answer`,`correct`,`distractor`,`option`]);function H_(e){return typeof e==`string`?e.trim().toLowerCase().replace(/[\s_-]+/g,``):``}function U_(e){let t=H_(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 W_(e){let t=U_(e.metadata?.study)??U_(e.metadata?.[`study-mode`]);if(t)return t;for(let t of e.classes??[]){let e=U_(t);if(e)return e}return U_(e.template)}function G_(e){return typeof e.title==`string`&&e.title.trim().length>0}function K_(e){return(e.contents?.length??0)>0||(e.media?.length??0)>0||(e.layers?.length??0)>0}function q_(e){return G_(e)||K_(e)}function J_(e){return G_(e)&&V_.has(e.title.trim().toLowerCase())}function Y_(e){let{children:t,...n}=e;return n}function X_(e){let{children:t,contents:n,media:r,layers:i,...a}=e;return a}function Z_(e){let{children:t,title:n,...r}=e;return r}function Q_(...e){return{blocks:e}}function $_(e){return e===!0||typeof e==`string`&&[`true`,`yes`,`on`,`1`,`correct`].includes(e.trim().toLowerCase())}function ev(e){return $_(e.metadata?.correct)||$_(e.metadata?.answer)||(e.classes??[]).some(e=>H_(e)===`correct`)}function tv(e){let t=W_(e);if(t===`group`)return!1;if(t===`basic`||t===`multiple-choice`)return!0;if(J_(e))return!1;let n=e.children??[];return n.length===0?G_(e)&&K_(e):n.length===1?q_(e)&&q_(n[0]):n.every(q_)}function nv(e){for(let t of e.children??[]){let e=W_(t);if(e===`basic`||e===`multiple-choice`||nv(t))return!0}return!1}function rv(e){let t=e.children??[];return t.length===0?!1:nv(e)?!0:K_(e)?!1:t.length===1?tv(t[0])&&!J_(t[0]):t.filter(tv).length>=2}function iv(e){return K_(e)?Q_(Z_(e)):void 0}function av(e,t){let n=e.children??[],r,i,a,o;if(n.length===0?(r=G_(e)?Q_(X_(e)):Q_(),i=K_(e)?Q_(Z_(e)):Q_()):n.length===1?(r=q_(e)?Q_(Y_(e)):Q_(),i=q_(n[0])?Q_(n[0]):Q_()):(r=q_(n[0])?Q_(n[0]):Q_(),i=Q_(...n.slice(1).filter(q_)),a=G_(e)?e.title.trim():void 0,o=iv(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 ov(e,t){let n=e.children??[],r=n[0],i=n.slice(1).filter(q_);if((!r||!q_(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||!q_(r)||i.length===0)return;let a=i.filter(ev);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:Q_(t),correct:t===o})),c=iv(e);return{id:e.id,sourceBlockId:e.id,kind:`multiple-choice`,...G_(e)?{label:e.title.trim()}:{},front:Q_(r),back:Q_(o),choices:s,...c?{explanation:c}:{}}}function sv(e){let t=e.frontmatter?.title;return typeof t==`string`&&t.trim()?t.trim():e.startBlock?.title?.trim()||void 0}function cv(e,t={}){let n=t.source??`auto`,r=[],i=[],a=e=>{let t=W_(e);if(t===`group`){for(let t of e.children??[])a(t);return}if(t===`basic`){let t=av(e,i);t&&r.push(t);return}if(t===`multiple-choice`){let t=ov(e,i);t&&r.push(t);return}if(n===`explicit`){for(let t of e.children??[])a(t);return}if(rv(e)){for(let t of e.children??[])a(t);return}if(tv(e)){let t=av(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=sv(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 lv=.5,uv=.8,dv=1;function fv(e){let t=e.title?e.title.trim():``,n=Qp(e);return t&&n?`${t}
581
+ ${n}`:t||n}function pv(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=yv(i,fv(t));e>=lv&&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 mv(e,t){let n=dm(e);if(n.blocks.length===0||yv(n.sourceText,t.sourceText)<uv)return null;let r=new Map,i=n.blocks.map(e=>fe(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 hv(e,t){return e.map(e=>{let n=t.ranges.get(e.id),r=Ip(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)>dv,l=r.startTime!=null&&Math.abs(r.startTime-a)>dv;(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=hv(e.children,t)),i})}async function gv(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=Cm(n);if(!i)continue;let a=Vp(e.blocks),o=i.blocks.length>0?pv(a,i):mv(e,i);if(!o||o.size===0)continue;let s={clipStart:r.startAt,ranges:o,diagnostics:[],cursor:0,shift:0},c=hv(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 _v(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 vv(e){let t=e.toLowerCase().replace(/[^\w\s]/g,` `).split(/\s+/).filter(e=>e.length>2);return new Set(t)}function yv(e,t){let n=vv(e),r=vv(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 bv(e){return e.toLowerCase().replace(/[^\w\s-]/g,``).replace(/\s+/g,`-`).replace(/-+/g,`-`).replace(/^-|-$/g,``)}function xv(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(`
582
+ `)}function Sv(e){let t=[];for(let n of e)n.children&&n.children.length>0?t.push(...Sv(n.children)):t.push(n);return t}var Cv=[`.mp3`,`.wav`,`.ogg`,`.m4a`],wv=[`.webm`,`.mp4`];function Tv(e){let t=e.toLowerCase();return Cv.some(e=>t.endsWith(e))?!0:wv.some(e=>t.endsWith(e))?t.startsWith(`audio/`):!1}function Ev(e){let t=e.toLowerCase();for(let n of[...Cv,...wv])if(t.endsWith(n))return e.slice(0,-n.length);return e}function Dv(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 Ov(e){let t=(await e.listFiles()).filter(e=>Tv(e.path)),n=[],r=null,i=await e.readFile(`timing.json`);i&&(r=Dv(i));for(let i of t){let t=i.path.split(`/`).pop()??i.path,a=null;if(r){let e=Ev(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=_v(n))}n.push({path:i.path,filename:t,timing:a})}return n}function kv(e,t){let n=[],r=Sv(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 Av=.35,jv=.5;function Mv(e,t){let n=Sv(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=xv(a);if(!o.trim())continue;let s=0;if(i.timing?.sourceText&&(s=yv(i.timing.sourceText,o)),s<Av&&a.title){let e=bv(a.title);bv(Ev(i.filename)).includes(e)&&e.length>=3&&(s=Math.max(s,jv+.1))}s>=Av&&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 Nv(e,t){let n=await gv(e,t);e=n.doc;let r=await Ov(t),i=new Set(j(e).map(e=>e.src)),a=r.filter(e=>!i.has(e.path));if(a.length===0)return e;let o=kv(e.blocks,a);if(o.length===0&&!n.applied&&(o=Mv(e.blocks,a).map(e=>({block:e.block,audio:e.audio}))),o.length===0)return e;let s=Sv(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=Pv(e.blocks,u);return{...e,blocks:f,duration:n.applied?Math.max(e.duration,d):d,audio:{segments:l}}}function Pv(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=Pv(e.children,t,r)),i})}var Fv=[`csv`,`tsv`,`xlsx`,`parquet`],Iv=new Set([`xlsx`]);function Lv(e){let t=e.split(`/`).pop()??e,n=t.lastIndexOf(`.`);return n>0?t.slice(n+1).toLowerCase():``}function Rv(e){return!e||/^(?:[a-z][a-z0-9+.-]*:|\/\/|\/)/i.test(e)?!1:Fv.includes(Lv(e))}function zv(e){return`${e}_files/data/`}var Bv=50;function Vv(e){let t=t=>!!(e.templateData&&t in e.templateData)||!!(e.templateOverrides&&t in e.templateOverrides);return t(`headers`)||t(`rows`)}function Hv(e){return!!e.templateOverrides?.src&&ue.has(R(e.template??``))}async function Uv(e,t,n){let r=[],i=n.maxPreviewRows??Bv,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=Lv(o);if(!Rv(o))return r.push({severity:`warning`,code:`data-src-no-reader`,message:`Block "${e.id}": src "${o}" is not a relative data-file path (.${Fv.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)&&!Iv.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)&&Iv.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;Hv(e)&&!Vv(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 Wv(e,t){return Gv(le(e),t)}function Gv(e,t){let n=zp(e),r=[...n.diagnostics??[]],i=Bp(n.blocks),a=Kv(n,t),o=new Set(n.customTemplates?.map(e=>e.name)??[]),s=(e,t)=>{Jv(e,t,a,r),Qv(e,t,r),$v(e,r),Yv(e,t,o,r),ty(e,r),qv(e)&&ey(e,r);for(let t of e.children??[])s(t,e)};for(let e of n.blocks)s(e,void 0);return ry(e,r),t?.assets&&cy(e,i,iy(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 Kv(e,t){return new Set([...Object.keys(Ed),...Object.keys(oe),...e.customTemplates?.map(e=>e.name)??[],...t?.extraTemplates??[]])}function qv(e){return R(e.template??``)===`drawing`}function Jv(e,t,n,r){let i=e.sourceHeading?.templateAnnotation?.template??e.sourceAnnotation?.template;if(!i)return;if(t&&qv(t)){if(Pl(i))return;let t=Fd(i,new Set(jl),{map:R});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,...uy(e)});return}if(Pl(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,...uy(e)});return}if(n.has(i)||n.has(R(i)))return;let a=Fd(i,n,{map:R});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,...uy(e)})}function Yv(e,t,n,r){let i=e.sourceHeading?.templateAnnotation?.template;if(!i||t&&qv(t)||Pl(i))return;let a=R(i);if(n.has(i)||n.has(a))return;let o=e.sourceHeading?.templateAnnotation?.params??{};for(let t of tf(a,o))t.kind===`missing-input`&&Xv(a,e,t.key)||r.push({severity:`warning`,code:t.kind,message:`Block "${e.id}": ${t.message}`,blockId:e.id,...uy(e)})}function Xv(e,t,n){if(t.templateData&&n in t.templateData||t[n]!=null)return!0;let r=bo(e,t.title??``,t.contents);return r!=null&&n in r}var Zv=[`x`,`y`,`width`,`height`,`w`,`h`,`strokeWidth`,`borderRadius`];function Qv(e,t,n){let r=e.sourceHeading?.attributes?.params;if(r){let{warnings:t}=ee(r);for(let r of t)n.push({severity:`warning`,code:`invalid-attribute`,message:`Block "${e.id}": ${r}`,blockId:e.id,...uy(e)})}if(t&&qv(t)&&Pl(e.template)){let t=e.templateOverrides??{};for(let r of Zv){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,...uy(e)})}}}function $v(e,t){let n=e.sourceHeading?.templateAnnotation?.params,r=e.sourceHeading?.attributes?.params;if(!(!n||!r))for(let i of Object.keys(I)){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,...uy(e)})}}function ey(e,t){let n=e.children??[],r=new Set(n.map(e=>e.id));for(let e of n){let n=Nl(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,...uy(e)})}}}function ty(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`||Xf(n))continue;let i=Zf(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}:uy(e)})}}var ny=/\{\[/;function ry(e,n){let r=(e,i,a)=>{if(e.type===`heading`){let t=e,r=o(t);ny.test(r)&&n.push({severity:`warning`,code:`unparsed-annotation`,message:`Heading "${dy(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=op(e);if(t&&t.template!=null)return}if(e.type===`text`&&ny.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 iy(e){return typeof e==`function`?e:t=>e.has(t)||e.has(t.replace(/^\.\//,``))}var ay=/^[a-z][a-z0-9+.-]*:/i;function oy(e){return e.length>0&&!ay.test(e)&&!e.startsWith(`//`)&&!e.startsWith(`#`)}var sy=[`src`,`imageSrc`,`videoSrc`,`poster`,`backgroundImage`];function cy(e,n,r,i){let a=(e,t,n)=>{!oy(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`)&&ly(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 sy){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 ly(e,t){for(let n of e)n.type===`htmlElement`&&(n.tagName===`img`&&n.attributes.src&&t(n.attributes.src),ly(n.children,t))}function uy(e){let t=e.sourceHeading?.position?.start.line;return t==null?{}:{line:t}}function dy(e,t=40){return e.length<=t?e:`${e.slice(0,t)}\u2026`}function fy(e){return e.split(`
583
+ `).map(e=>e.trim()).filter(e=>e.length>0)}function py(e){if(e===void 0)return;let t=e.replace(/\s+/gu,` `).trim();return t.length>0?t:void 0}function my(e){return e.length<=40}var hy=1;function gy(e,t={}){let n=(t.style??e.style)===`ascii`?gt:ht;if(e.nodes.length===0)return``;let r=vy(e.nodes,e.edges),i=new Sy,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)Cy(i,e,n);return wy(i,e.edges,r,n),i.emit()}function _y(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}=Ty(i(t),i(a));r.get(e.source)[o]++,r.get(e.target)[s]++}return r}function vy(e,t){let n=new Map;for(let t of e)n.set(t.id,t);let r=_y(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=by(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=>yy(n,e,hy));if(!t||r++>64)break;let a=t.c1+hy+1-n.c0,o=t.r1+hy+1-n.r0;a<o?(s(e,0,a),n=by(n,0,a)):(s(e,o,0),n=by(n,o,0))}i.push(n)}return i},l=(e,t)=>{let a=n.get(e),s=fy(a.label),u=i.get(e)??[];if(u.length===0){let n=s.reduce((e,t)=>Math.max(e,Be(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=xy(c(u,e=>l(e,t+1))),f=Math.max(0,s.length-1),p=Be(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,Be(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=by(e.rect,f,p);return o}function yy(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 by(e,t,n){return{r0:e.r0+t,c0:e.c0+n,r1:e.r1+t,c1:e.c1+n}}function xy(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 Sy=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(`
584
+ `)}};function Cy(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?ze(` ${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=ze(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 wy(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=Ty(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=Dy(o,n),c=[];o.forEach((t,i)=>Oy(e,t,i,n,s,r,(e,t)=>c.push({candidates:e,label:t})));for(let t of c){let n=ze(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 Ty(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 Ey(e){let t=new Set,n=e.rect.c1-e.rect.c0-1,r=e.isContainer?e.labelLines.slice(1):e.labelLines;for(let i of r){let r=ze(i),a=Math.max(0,Math.floor((n-r.length)/2));r.forEach((n,r)=>{ft(n)&&t.add(e.rect.c0+1+a+r)})}return t}function Dy(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,f=s?Ey(o):new Set,p=[],m=e=>{let t=e=>e>=c&&e<=l&&!f.has(e)&&p.every(t=>Math.abs(t-e)>=2);for(let n=0;n<=u;n++)for(let r of n===0?[e]:[e-n,e+n])if(t(r))return p.push(r),r;return p.push(e),e};if(d===1)r.set(i[0].key,{pos:m(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:m(Math.min(l,t+2*n)),index:n,count:d})})}}return r}function Oy(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:py(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`?jy(h,s,c,d,f,1):t.exitSide===`top`&&t.enterSide===`bottom`?jy(h,s,c,d,f,-1):t.exitSide===`right`&&t.enterSide===`left`?My(h,s,c,d,f,1):t.exitSide===`left`&&t.enterSide===`right`?My(h,s,c,d,f,-1):Ny(h,s,c,t.exitSide)}function ky(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 Ay(e,t,n){return Math.max(t,Math.min(n,e))}function jy(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=Ay(r,t.c0+1,t.c1-1),f=Ay(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(ky(h,g).map(e=>({row:e,col:i})),l));return}let y=Ay(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?ze(` ${l} `):null;if(f&&my(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 ky(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 ky(h,y-a))t.push({row:e,col:r});if(n>=1)for(let e of ky(y+a,g))t.push({row:e,col:i})}t.length>0&&e.deferSideLabel(t,l)}}function My(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?ze(` ${l} `):null;if(f&&my(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=Ay(r,t.r0+1,t.r1-1),i=Ay(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=Ay(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 Ny(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 Py=2,Fy=8,Iy=12,Ly=4,Ry=4;function zy(e){return!un(e).isDiagram&&Vy(Dt(Ot(e),!0)).length>=Py}function By(e){let t=Ot(e),n=Vy(Dt(t,!0));if(n.length<Py)return null;let r=Hy(t,n),i={nodes:r,edges:Ky(t,n,r),style:Zy(t),warnings:[`repaired`]};return{diagram:i,art:gy(i)}}function Vy(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 Hy(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(Uy).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=Uy(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+Ly}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)+Ry}let p=t.map((e,n)=>Wy(t,n)),m=new Map,h=t.map((e,t)=>{let n=Gy(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(`
585
+ `),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 Uy(e){let t=``;for(let n of e){let e=n.codePointAt(0)??0;e>=9472&&e<=9599||V(n)!==null?t+=` `:t+=n}return t.replace(/\s+/g,` `).trim()}function Wy(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 Gy(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`node`}function Ky(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=>ot(e)||at(e)||st(e)||V(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<=Fy&&s(r,i)){let s=Math.max(r.c0,i.c0),c=Math.min(r.c1,i.c1);if(qy(a,r.r1+1,i.r0-1,s-1,c+1,o)&&!Yy(t,e,n,s,c)){let t=Jy(a,r.r1+1,i.r0,s-1,c+1,`down`);d(e,n,t)}}if(r.c1<i.c0&&i.c0-r.c1<=Iy&&c(r,i)&&e<n){let o=Math.max(r.r0,i.r0),s=Math.min(r.r1,i.r1),c=Jy(a,o-1,s+1,r.c1+1,i.c0,`right`),l=Jy(a,o-1,s+1,r.c1+1,i.c0,`left`);(c||l)&&!Xy(t,e,n,o,s)&&(l&&!c?d(n,e,!0):d(e,n,!0))}}return l}function qy(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 Jy(e,t,n,r,i,a){for(let o=t;o<=n;o++)for(let t=r;t<=i;t++)if(V(e(o,t))===a)return!0;return!1}function Yy(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 Xy(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 Zy(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 Qy={rail:`─`,arrow:`►`,marker:{filled:`●`,hollow:`○`,diamond:`◆`}},$y={rail:`-`,arrow:`>`,marker:{filled:`*`,hollow:`o`,diamond:`*`}},eb=48,tb=64,nb=3,rb=3;function ib(e,t={}){let n=t.style??e.style,r=n===`ascii`?$y:Qy,{tracks:i,links:a}=fb(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(eb,Math.min(tb,Math.ceil(c)),...i.map(e=>e.events.length*nb)),u=i.map(e=>sb(e)),d=Math.max(...u.map(ub)),f=[];if(i.forEach((e,t)=>{t>0&&f.push(``),f.push(...ab(e,n,r,u[t],d,l,o,c))}),a.length>0){f.push(``);for(let e of a)f.push(db(e,n))}return f.join(`
586
+ `)}function ab(e,t,n,r,i,a,o,s){let c=`${r}${` `.repeat(Math.max(0,i-ub(r)))}`,l=cb(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:ob(e)})),f=t===`ascii`?{above:`^`,below:`v`}:{above:`▲`,below:`▼`},p=lb(d.filter(({event:e})=>e.side===`above`),f.above),m=lb(d.filter(({event:e})=>e.side===`below`),f.below),h=`${c}${u.join(``)}${n.rail.repeat(rb)}${n.arrow}${e.endLabel?` ${e.endLabel}`:``}`;return[...p,h,...m]}function ob(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=${xb(e.column)}${n}${r}}`}function sb(e){let t=`{#${e.id} start=${xb(e.startColumn)} end=${xb(e.endColumn)}}`;return e.label?`${e.label} ${t}: `:`${t}: `}function cb(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 lb(e,t){let n=[],r=[];for(let t of e){let e=t.column+2+ub(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 ub(e){return Array.from(e).length}function db(e,t){let n=t===`ascii`?`->`:`→`;return`branch: ${e.source} ${n} ${e.target}${e.label?` : ${e.label}`:``}`}function fb(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)=>yb(e.track.row,e.index)-yb(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=mb(e.label),l=mb(e.endLabel),u=_b(gb(e.id,gb(n,`track_${s.length+1}`)),r),d=e.events.map((e,t)=>({event:e,index:t})).sort((e,t)=>yb(e.event.column,e.index)-yb(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=mb(n.label)||r,l=_b(gb(n.id,gb(s,`event_${++c}`)),i),u=mb(n.description),p=u&&(n.descriptionSide===`above`||n.descriptionSide===`below`)?n.descriptionSide:void 0,m=bb(n.column,e),h=n.side===`below`?`below`:n.side===`above`||e%2==0?`above`:`below`,g=pb(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(vb(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:bb(e.startColumn,m),endColumn:bb(e.endColumn,h),events:f})}let l=e=>a.get(e)??o.get(vb(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=hb(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 pb(e,t){return e===`hollow`?`hollow`:e===`diamond`&&t!==`ascii`?`diamond`:`filled`}function mb(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 hb(e){return mb(e).replace(/\s+/g,` `).trim()}function gb(e,t){return(e??``).normalize(`NFC`).replace(/[\r\n\t\s]+/g,`_`).replace(/[^A-Za-z0-9_.~-]+/g,`_`).replace(/^_+|_+$/g,``)||t}function _b(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 vb(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`event`}function yb(e,t){return Number.isFinite(e)?e:t}function bb(e,t){let n=yb(e,t);return Math.max(0,Object.is(n,-0)?0:n)}function xb(e){return String(Object.is(e,-0)?0:e)}function Sb(e){return e.replace(/\s+/gu,` `).trim()}function Cb(e,t={}){let n=(t.style??e.style)===`ascii`?Lr:Ir,r=[],i=e=>{let t=Sb(e.label),n=e.comment?Sb(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(`
587
+ `)}var wb=e({ASCII_CHAR_H:()=>28,ASCII_CHAR_W:()=>14,ASCII_DIAGRAM_FENCE_LANGS:()=>en,ASCII_TIMELINE_FENCE_LANGS:()=>hr,BASE_INPUT_DESCRIPTORS:()=>Wd,BLOCK_MEDIA_LAYOUT_POLICIES:()=>Ec,BUILTIN_DASHBOARD_LAYOUTS:()=>r_,CONTAINER_TEMPLATES:()=>ae,COVER_SLIDE_FRONTMATTER_KEYS:()=>Vm,COVER_SLIDE_TEMPLATE_OPTIONS:()=>Bm,DASHBOARD_AUTO_LAYOUT_ID:()=>s_,DASHBOARD_FRONTMATTER_KEYS:()=>C_,DASHBOARD_STYLES:()=>f_,DASHBOARD_STYLE_IDS:()=>u_,DASHBOARD_ZOOM_LEVELS:()=>Cg,DATA_FILE_EXTENSIONS:()=>Fv,DEFAULT_COVER_SLIDE_SETTINGS:()=>Hm,DEFAULT_DASHBOARD_SETTINGS:()=>w_,DEFAULT_DASHBOARD_STYLE:()=>d_,DEFAULT_LAYOUT:()=>na,DEFAULT_THEME:()=>A,DIAGRAM_LABEL_HORIZONTAL_PADDING:()=>24,DIAGRAM_LABEL_LINE_HEIGHT:()=>Oc,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:()=>Hg,MAX_COVER_SLIDE_DURATION_SECONDS:()=>60,PAGE_BASE_CSS:()=>xg,PATH_SHAPE_KINDS:()=>_e,SHAPE_NAMES:()=>jl,TABLE_FED_TEMPLATES:()=>ue,TEMPLATE_AUTHORING_METADATA:()=>bf,TEMPLATE_INPUT_DESCRIPTORS:()=>Gd,TEMPLATE_METADATA:()=>yf,TREE_FENCE_LANGS:()=>Wr,VIEWPORT_PRESETS:()=>f,adjustY:()=>ha,anchorPoint:()=>Ee,applyNarrationTiming:()=>gv,applyRenderStyleToLayers:()=>Nd,asciiCellToCanvas:()=>Pa,asciiDiagramFromBlocks:()=>Va,asciiDiagramFromTemplateData:()=>Ba,asciiDiagramToTemplateData:()=>Ia,asciiTimelineToTemplateData:()=>Ha,autoTemplatePreservesContent:()=>yo,bigText:()=>Oa,buildDashboardCellChrome:()=>b_,buildPageCss:()=>Sg,buildPageCssVars:()=>vg,buildPreviewDoc:()=>xh,buildRegistry:()=>Dd,canvasToAsciiCell:()=>Fa,chooseDashboardLayout:()=>l_,clipEndpoints:()=>we,clipPoint:()=>Ce,coerceTemplateParams:()=>Yd,comparisonBar:()=>cc,composeDashboardLayers:()=>B_,computeDiagramLayout:()=>Aa,computeDrawingLayout:()=>zl,computeLayoutLayers:()=>su,connectorPath:()=>je,contentBlock:()=>To,countBlocks:()=>Hp,coverBlock:()=>Of,createAccentLayers:()=>ca,createTemplateContext:()=>p,cssFilterForTreatment:()=>zm,dashboardCanvasFill:()=>g_,dashboardCellAccent:()=>__,dataSidecarPrefix:()=>zv,dataTable:()=>Sc,dateEvent:()=>os,definitionCard:()=>sc,deriveTemplateInputs:()=>bo,desiredCellZoom:()=>Og,detectAsciiDiagram:()=>un,detectAsciiTimeline:()=>wr,detectTree:()=>Qr,diagramBlock:()=>yl,docToMarkdown:()=>Zm,documentTitleFromFileName:()=>yh,drawingBlock:()=>Zl,expandCoverBlock:()=>Af,expandDocBlocks:()=>Mf,expandPersistentLayers:()=>Ti,extractBlockquoteText:()=>fo,extractBodyPlainText:()=>Za,extractEmbeddedVideos:()=>co,extractFirstEmbeddedVideo:()=>lo,extractFirstImage:()=>so,extractImages:()=>oo,extractListItems:()=>Qa,extractRichListItems:()=>io,extractTableData:()=>ip,extractTableFromContents:()=>uo,factCard:()=>Jo,fallbackBlockLayers:()=>rf,findFirstList:()=>Ya,findFirstTable:()=>rp,fitBigTextSize:()=>Ea,fitDiagramLabel:()=>kc,flattenBlocks:()=>Bp,flattenRenderableBlocks:()=>Vp,fullBleedQuote:()=>Ns,getAccentLayout:()=>sa,getAnimationProgress:()=>Fm,getAnimationStyle:()=>wm,getAvailableTemplates:()=>Nf,getAvailableThemes:()=>T,getBlockBodyText:()=>Qp,getBlockDepth:()=>Up,getBlockMediaLayoutPolicy:()=>Dc,getDashboardLayoutSummaries:()=>a_,getDefaultAnimation:()=>Pi,getDefaultAnimationDuration:()=>Dm,getLayoutHints:()=>g,getOverlayOpacity:()=>Fi,getPersistentLayersFromTheme:()=>Ei,getPinnedBlockMeta:()=>Ip,getTemplateHint:()=>zi,getThemeFont:()=>U,getThemeSummaries:()=>N,getTransitionClass:()=>Om,getTwoColumnPositions:()=>c,getViewport:()=>d,getViewportOrientation:()=>_,hasTemplate:()=>Pf,imageWithCaption:()=>ss,isAsciiDiagramFence:()=>dn,isAsciiTimelineFence:()=>Tr,isContainerTemplate:()=>L,isDataFence:()=>Xf,isDataFilePath:()=>Rv,isEligibleAsciiFenceLang:()=>cn,isEligibleAsciiTimelineFenceLang:()=>Sr,isEligibleTreeFenceLang:()=>Xr,isExplicitDiagramLang:()=>ln,isExplicitTimelineLang:()=>Cr,isExplicitTreeLang:()=>Zr,isRepairableDiagram:()=>zy,isShapeName:()=>Pl,isTemplateBlock:()=>u,isTemplatedPageBlock:()=>Ch,isTreeFence:()=>$r,isWrappedFlowTimelineSource:()=>xn,layoutBlock:()=>du,layoutCapacity:()=>zg,leftFeature:()=>bs,lineStyleDasharray:()=>Pe,lintTemplateParams:()=>tf,listBlock:()=>Js,listDashboardLayouts:()=>o_,mapBlock:()=>Ss,markdownBlockSeparatorLines:()=>no,markdownToDoc:()=>zp,markerPath:()=>Se,materializeBlockLayers:()=>of,materializeDashboard:()=>z_,materializeFlashcards:()=>cv,materializePageSection:()=>hg,materializePageSections:()=>gg,nearestSnapPoint:()=>De,normalizeDashboardZoom:()=>wg,normalizeShapeKind:()=>Nl,pageStyleDataAttributes:()=>yg,parseAsciiDiagram:()=>St,parseAsciiTimeline:()=>zn,parseAsciiTimelineWithStats:()=>Bn,parseDataFence:()=>Zf,parseTree:()=>Rr,parseWrappedFlowTimeline:()=>bn,parseYamlSubset:()=>np,photoGrid:()=>Ys,pullQuote:()=>vc,quoteBlock:()=>Bo,readCustomTemplatesFromFrontmatter:()=>Bf,readCustomThemesFromFrontmatter:()=>qf,readDashboardLayoutsFromFrontmatter:()=>Kg,renderAsciiDiagram:()=>gy,renderAsciiTimeline:()=>ib,renderMarkdownBlocksHtml:()=>to,renderTree:()=>Cb,repairAsciiDiagram:()=>By,replaceDataFence:()=>Qf,resolveAudioMapping:()=>Nv,resolveColorScheme:()=>H,resolveCoverSlideSettings:()=>Jm,resolveDashboardLayoutDefinition:()=>c_,resolveDashboardSettings:()=>k_,resolveDashboardStyleId:()=>p_,resolveDashboardZooms:()=>kg,resolveDataReferences:()=>Uv,resolveFlashcardMarker:()=>W_,resolveLayoutCells:()=>Vg,resolvePageBlock:()=>Th,resolvePageStyle:()=>eg,resolvePersistentLayers:()=>Di,resolveTemplateName:()=>R,resolveTheme:()=>O,resolveThemeForDoc:()=>Sh,rightFeature:()=>xs,scaleAnimationDuration:()=>Ni,scaledFontSize:()=>m,scoreTextSimilarity:()=>yv,sectionExtractors:()=>$h,sectionHeader:()=>ya,shapePath:()=>be,shouldUseShadow:()=>K,snapEndpoints:()=>Oe,snapPoints:()=>Te,statHighlight:()=>No,stripBlockBackdropLayer:()=>S_,stripsBlockBackdrop:()=>x_,templateRegistry:()=>Ed,themeWantsAmbientMotion:()=>Md,themedEntrance:()=>G,themedFontSize:()=>W,themedImageTreatment:()=>Ii,themedScrim:()=>Ri,themedSurfaceGradient:()=>Li,timelineBlock:()=>Al,titleBlock:()=>ea,transposeCells:()=>Bg,treeBlock:()=>Sl,treeFromMarkdownList:()=>Ja,treeFromTemplateData:()=>Ka,treeToTemplateData:()=>Wa,twoColumn:()=>Yo,validateDashboardLayoutDefinition:()=>Rg,validateMarkdownDoc:()=>Gv,validateMarkdownSource:()=>Wv,videoPullQuote:()=>bc,videoWithCaption:()=>yc,wrapWithPersistentLayers:()=>Oi,writeCustomTemplatesToFrontmatter:()=>Vf,writeCustomThemesToFrontmatter:()=>Jf,writeDashboardLayoutsToFrontmatter:()=>qg});export{_m as $,Nv as A,xn as At,yf as B,De as Bt,cv as C,Qr as Ct,ib as D,ln as Dt,gy as E,Xr as Et,eg as F,di as Ft,bm as G,Ia as H,Oe as Ht,Sh as I,Ee as It,su as J,Fa as K,Na as L,Ie as Lt,p_ as M,zn as Mt,Uv as N,Rr as Nt,Cb as O,Cr as Ot,Th as P,si as Pt,Mf as Q,Ma as R,je as Rt,z_ as S,wr as St,yg as T,Sr as Tt,Ha as U,Pa as V,be as Vt,dm as W,bo as X,Hp as Y,Af as Z,wm as _,ym as _t,C_ as a,kc as at,zy as b,Jf as bt,w_ as c,Nf as ct,vg as d,Pf as dt,fo as et,xh as f,zp as ft,yh as g,Di as gt,Zm as h,qf as ht,s_ as i,uo as it,Jm as j,St as jt,By as k,Zr as kt,d_ as l,Qp as lt,zv as m,Bf as mt,Vm as n,oo as nt,f_ as o,Bp as ot,zm as p,of as pt,zl as q,Bm as r,Qa as rt,Hm as s,Vp as st,wb as t,Za as tt,xg as u,Ip as ut,Om as v,vm as vt,gg as w,cn as wt,o_ as x,un as xt,Rv as y,Vf as yt,Oc as z,Se as zt};