@bendyline/squisq 0.1.2 → 1.0.1

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 (328) hide show
  1. package/dist/{themeLibrary-DySHPcgj.d.ts → Doc-1hmT1LZl.d.ts} +1 -42
  2. package/dist/__tests__/animationUtils.test.d.ts +2 -0
  3. package/dist/__tests__/animationUtils.test.d.ts.map +1 -0
  4. package/dist/__tests__/animationUtils.test.js +60 -0
  5. package/dist/__tests__/animationUtils.test.js.map +1 -0
  6. package/dist/__tests__/contentExtractor.test.d.ts +2 -0
  7. package/dist/__tests__/contentExtractor.test.d.ts.map +1 -0
  8. package/dist/__tests__/contentExtractor.test.js +151 -0
  9. package/dist/__tests__/contentExtractor.test.js.map +1 -0
  10. package/dist/__tests__/geohash.test.d.ts +2 -0
  11. package/dist/__tests__/geohash.test.d.ts.map +1 -0
  12. package/dist/__tests__/geohash.test.js +87 -0
  13. package/dist/__tests__/geohash.test.js.map +1 -0
  14. package/dist/__tests__/getLayers.test.d.ts +2 -0
  15. package/dist/__tests__/getLayers.test.d.ts.map +1 -0
  16. package/dist/__tests__/getLayers.test.js +167 -0
  17. package/dist/__tests__/getLayers.test.js.map +1 -0
  18. package/dist/__tests__/haversine.test.d.ts +2 -0
  19. package/dist/__tests__/haversine.test.d.ts.map +1 -0
  20. package/dist/__tests__/haversine.test.js +56 -0
  21. package/dist/__tests__/haversine.test.js.map +1 -0
  22. package/dist/__tests__/localForageAdapter.test.d.ts +8 -0
  23. package/dist/__tests__/localForageAdapter.test.d.ts.map +1 -0
  24. package/dist/__tests__/localForageAdapter.test.js +130 -0
  25. package/dist/__tests__/localForageAdapter.test.js.map +1 -0
  26. package/dist/__tests__/markdown.test.d.ts +2 -0
  27. package/dist/__tests__/markdown.test.d.ts.map +1 -0
  28. package/dist/__tests__/markdown.test.js +654 -0
  29. package/dist/__tests__/markdown.test.js.map +1 -0
  30. package/dist/__tests__/markdownToDoc.test.d.ts +2 -0
  31. package/dist/__tests__/markdownToDoc.test.d.ts.map +1 -0
  32. package/dist/__tests__/markdownToDoc.test.js +313 -0
  33. package/dist/__tests__/markdownToDoc.test.js.map +1 -0
  34. package/dist/__tests__/seededRandom.test.d.ts +2 -0
  35. package/dist/__tests__/seededRandom.test.d.ts.map +1 -0
  36. package/dist/__tests__/seededRandom.test.js +125 -0
  37. package/dist/__tests__/seededRandom.test.js.map +1 -0
  38. package/dist/__tests__/slideshowGenerator.test.d.ts +2 -0
  39. package/dist/__tests__/slideshowGenerator.test.d.ts.map +1 -0
  40. package/dist/__tests__/slideshowGenerator.test.js +114 -0
  41. package/dist/__tests__/slideshowGenerator.test.js.map +1 -0
  42. package/dist/__tests__/storage.test.d.ts +2 -0
  43. package/dist/__tests__/storage.test.d.ts.map +1 -0
  44. package/dist/__tests__/storage.test.js +51 -0
  45. package/dist/__tests__/storage.test.js.map +1 -0
  46. package/dist/__tests__/templates.test.d.ts +2 -0
  47. package/dist/__tests__/templates.test.d.ts.map +1 -0
  48. package/dist/__tests__/templates.test.js +217 -0
  49. package/dist/__tests__/templates.test.js.map +1 -0
  50. package/dist/__tests__/timing.test.d.ts +2 -0
  51. package/dist/__tests__/timing.test.d.ts.map +1 -0
  52. package/dist/__tests__/timing.test.js +131 -0
  53. package/dist/__tests__/timing.test.js.map +1 -0
  54. package/dist/chunk-3E5F2XMR.js +129 -0
  55. package/dist/chunk-3E5F2XMR.js.map +1 -0
  56. package/dist/chunk-6YJPI6VI.js +35 -0
  57. package/dist/chunk-6YJPI6VI.js.map +1 -0
  58. package/dist/chunk-FVTQSNR7.js +100 -0
  59. package/dist/chunk-FVTQSNR7.js.map +1 -0
  60. package/dist/chunk-V543AI2F.js +1 -0
  61. package/dist/chunk-V543AI2F.js.map +1 -0
  62. package/dist/chunk-VP5SZTZ2.js +792 -0
  63. package/dist/chunk-VP5SZTZ2.js.map +1 -0
  64. package/dist/doc/docToMarkdown.d.ts +41 -0
  65. package/dist/doc/docToMarkdown.d.ts.map +1 -0
  66. package/dist/doc/docToMarkdown.js +88 -0
  67. package/dist/doc/docToMarkdown.js.map +1 -0
  68. package/dist/doc/getLayers.d.ts +65 -0
  69. package/dist/doc/getLayers.d.ts.map +1 -0
  70. package/dist/doc/getLayers.js +103 -0
  71. package/dist/doc/getLayers.js.map +1 -0
  72. package/dist/doc/index.d.ts +9 -3
  73. package/dist/doc/index.d.ts.map +1 -0
  74. package/dist/doc/index.js +6 -125
  75. package/dist/doc/index.js.map +1 -1
  76. package/dist/doc/markdownToDoc.d.ts +68 -0
  77. package/dist/doc/markdownToDoc.d.ts.map +1 -0
  78. package/dist/doc/markdownToDoc.js +225 -0
  79. package/dist/doc/markdownToDoc.js.map +1 -0
  80. package/dist/doc/templates/accentImage.d.ts +59 -0
  81. package/dist/doc/templates/accentImage.d.ts.map +1 -0
  82. package/dist/doc/templates/accentImage.js +275 -0
  83. package/dist/doc/templates/accentImage.js.map +1 -0
  84. package/dist/doc/templates/captionUtils.d.ts +20 -0
  85. package/dist/doc/templates/captionUtils.d.ts.map +1 -0
  86. package/dist/doc/templates/captionUtils.js +29 -0
  87. package/dist/doc/templates/captionUtils.js.map +1 -0
  88. package/dist/doc/templates/comparisonBar.d.ts +13 -0
  89. package/dist/doc/templates/comparisonBar.d.ts.map +1 -0
  90. package/dist/doc/templates/comparisonBar.js +127 -0
  91. package/dist/doc/templates/comparisonBar.js.map +1 -0
  92. package/dist/doc/templates/coverBlock.d.ts +51 -0
  93. package/dist/doc/templates/coverBlock.d.ts.map +1 -0
  94. package/dist/doc/templates/coverBlock.js +125 -0
  95. package/dist/doc/templates/coverBlock.js.map +1 -0
  96. package/dist/doc/templates/dateEvent.d.ts +15 -0
  97. package/dist/doc/templates/dateEvent.d.ts.map +1 -0
  98. package/dist/doc/templates/dateEvent.js +110 -0
  99. package/dist/doc/templates/dateEvent.js.map +1 -0
  100. package/dist/doc/templates/definitionCard.d.ts +13 -0
  101. package/dist/doc/templates/definitionCard.d.ts.map +1 -0
  102. package/dist/doc/templates/definitionCard.js +114 -0
  103. package/dist/doc/templates/definitionCard.js.map +1 -0
  104. package/dist/doc/templates/factCard.d.ts +15 -0
  105. package/dist/doc/templates/factCard.d.ts.map +1 -0
  106. package/dist/doc/templates/factCard.js +100 -0
  107. package/dist/doc/templates/factCard.js.map +1 -0
  108. package/dist/doc/templates/fullBleedQuote.d.ts +13 -0
  109. package/dist/doc/templates/fullBleedQuote.d.ts.map +1 -0
  110. package/dist/doc/templates/fullBleedQuote.js +54 -0
  111. package/dist/doc/templates/fullBleedQuote.js.map +1 -0
  112. package/dist/doc/templates/imageWithCaption.d.ts +13 -0
  113. package/dist/doc/templates/imageWithCaption.d.ts.map +1 -0
  114. package/dist/doc/templates/imageWithCaption.js +142 -0
  115. package/dist/doc/templates/imageWithCaption.js.map +1 -0
  116. package/dist/doc/templates/index.d.ts +104 -0
  117. package/dist/doc/templates/index.d.ts.map +1 -0
  118. package/dist/doc/templates/index.js +442 -0
  119. package/dist/doc/templates/index.js.map +1 -0
  120. package/dist/doc/templates/listBlock.d.ts +13 -0
  121. package/dist/doc/templates/listBlock.d.ts.map +1 -0
  122. package/dist/doc/templates/listBlock.js +89 -0
  123. package/dist/doc/templates/listBlock.js.map +1 -0
  124. package/dist/doc/templates/mapBlock.d.ts +17 -0
  125. package/dist/doc/templates/mapBlock.d.ts.map +1 -0
  126. package/dist/doc/templates/mapBlock.js +112 -0
  127. package/dist/doc/templates/mapBlock.js.map +1 -0
  128. package/dist/doc/templates/persistentLayers.d.ts +39 -0
  129. package/dist/doc/templates/persistentLayers.d.ts.map +1 -0
  130. package/dist/doc/templates/persistentLayers.js +447 -0
  131. package/dist/doc/templates/persistentLayers.js.map +1 -0
  132. package/dist/doc/templates/photoGrid.d.ts +20 -0
  133. package/dist/doc/templates/photoGrid.d.ts.map +1 -0
  134. package/dist/doc/templates/photoGrid.js +172 -0
  135. package/dist/doc/templates/photoGrid.js.map +1 -0
  136. package/dist/doc/templates/pullQuote.d.ts +13 -0
  137. package/dist/doc/templates/pullQuote.d.ts.map +1 -0
  138. package/dist/doc/templates/pullQuote.js +109 -0
  139. package/dist/doc/templates/pullQuote.js.map +1 -0
  140. package/dist/doc/templates/quoteBlock.d.ts +15 -0
  141. package/dist/doc/templates/quoteBlock.d.ts.map +1 -0
  142. package/dist/doc/templates/quoteBlock.js +97 -0
  143. package/dist/doc/templates/quoteBlock.js.map +1 -0
  144. package/dist/doc/templates/sectionHeader.d.ts +14 -0
  145. package/dist/doc/templates/sectionHeader.d.ts.map +1 -0
  146. package/dist/doc/templates/sectionHeader.js +96 -0
  147. package/dist/doc/templates/sectionHeader.js.map +1 -0
  148. package/dist/doc/templates/statHighlight.d.ts +15 -0
  149. package/dist/doc/templates/statHighlight.d.ts.map +1 -0
  150. package/dist/doc/templates/statHighlight.js +99 -0
  151. package/dist/doc/templates/statHighlight.js.map +1 -0
  152. package/dist/doc/templates/titleBlock.d.ts +13 -0
  153. package/dist/doc/templates/titleBlock.d.ts.map +1 -0
  154. package/dist/doc/templates/titleBlock.js +92 -0
  155. package/dist/doc/templates/titleBlock.js.map +1 -0
  156. package/dist/doc/templates/twoColumn.d.ts +15 -0
  157. package/dist/doc/templates/twoColumn.d.ts.map +1 -0
  158. package/dist/doc/templates/twoColumn.js +219 -0
  159. package/dist/doc/templates/twoColumn.js.map +1 -0
  160. package/dist/doc/templates/videoPullQuote.d.ts +20 -0
  161. package/dist/doc/templates/videoPullQuote.d.ts.map +1 -0
  162. package/dist/doc/templates/videoPullQuote.js +118 -0
  163. package/dist/doc/templates/videoPullQuote.js.map +1 -0
  164. package/dist/doc/templates/videoWithCaption.d.ts +20 -0
  165. package/dist/doc/templates/videoWithCaption.d.ts.map +1 -0
  166. package/dist/doc/templates/videoWithCaption.js +104 -0
  167. package/dist/doc/templates/videoWithCaption.js.map +1 -0
  168. package/dist/doc/utils/animationUtils.d.ts +34 -0
  169. package/dist/doc/utils/animationUtils.d.ts.map +1 -0
  170. package/dist/doc/utils/animationUtils.js +110 -0
  171. package/dist/doc/utils/animationUtils.js.map +1 -0
  172. package/dist/doc/utils/themeUtils.d.ts +55 -0
  173. package/dist/doc/utils/themeUtils.d.ts.map +1 -0
  174. package/dist/doc/utils/themeUtils.js +109 -0
  175. package/dist/doc/utils/themeUtils.js.map +1 -0
  176. package/dist/generate/contentExtractor.d.ts +112 -0
  177. package/dist/generate/contentExtractor.d.ts.map +1 -0
  178. package/dist/generate/contentExtractor.js +638 -0
  179. package/dist/generate/contentExtractor.js.map +1 -0
  180. package/dist/generate/index.d.ts +7 -0
  181. package/dist/generate/index.d.ts.map +1 -0
  182. package/dist/generate/index.js +4 -0
  183. package/dist/generate/index.js.map +1 -0
  184. package/dist/generate/slideshowGenerator.d.ts +72 -0
  185. package/dist/generate/slideshowGenerator.d.ts.map +1 -0
  186. package/dist/generate/slideshowGenerator.js +159 -0
  187. package/dist/generate/slideshowGenerator.js.map +1 -0
  188. package/dist/generate/templateMapper.d.ts +23 -0
  189. package/dist/generate/templateMapper.d.ts.map +1 -0
  190. package/dist/generate/templateMapper.js +114 -0
  191. package/dist/generate/templateMapper.js.map +1 -0
  192. package/dist/index.d.ts +9 -8
  193. package/dist/index.d.ts.map +1 -0
  194. package/dist/index.js +8 -216
  195. package/dist/index.js.map +1 -1
  196. package/dist/markdown/convert.d.ts +71 -0
  197. package/dist/markdown/convert.d.ts.map +1 -0
  198. package/dist/markdown/convert.js +746 -0
  199. package/dist/markdown/convert.js.map +1 -0
  200. package/dist/markdown/htmlParse.d.ts +26 -0
  201. package/dist/markdown/htmlParse.d.ts.map +1 -0
  202. package/dist/markdown/htmlParse.js +195 -0
  203. package/dist/markdown/htmlParse.js.map +1 -0
  204. package/dist/markdown/index.d.ts +19 -225
  205. package/dist/markdown/index.d.ts.map +1 -0
  206. package/dist/markdown/index.js +33 -32
  207. package/dist/markdown/index.js.map +1 -1
  208. package/dist/markdown/parse.d.ts +27 -0
  209. package/dist/markdown/parse.d.ts.map +1 -0
  210. package/dist/markdown/parse.js +90 -0
  211. package/dist/markdown/parse.js.map +1 -0
  212. package/dist/markdown/stringify.d.ts +32 -0
  213. package/dist/markdown/stringify.d.ts.map +1 -0
  214. package/dist/markdown/stringify.js +108 -0
  215. package/dist/markdown/stringify.js.map +1 -0
  216. package/dist/markdown/types.d.ts +496 -0
  217. package/dist/markdown/types.d.ts.map +1 -0
  218. package/dist/markdown/types.js +17 -0
  219. package/dist/markdown/types.js.map +1 -0
  220. package/dist/markdown/utils.d.ts +78 -0
  221. package/dist/markdown/utils.d.ts.map +1 -0
  222. package/dist/markdown/utils.js +149 -0
  223. package/dist/markdown/utils.js.map +1 -0
  224. package/dist/random/SeededRandom.d.ts +50 -0
  225. package/dist/random/SeededRandom.d.ts.map +1 -0
  226. package/dist/random/SeededRandom.js +115 -0
  227. package/dist/random/SeededRandom.js.map +1 -0
  228. package/dist/random/index.d.ts +2 -0
  229. package/dist/random/index.d.ts.map +1 -0
  230. package/dist/random/index.js +2 -0
  231. package/dist/random/index.js.map +1 -0
  232. package/dist/schemas/BlockTemplates.d.ts +583 -0
  233. package/dist/schemas/BlockTemplates.d.ts.map +1 -0
  234. package/dist/schemas/BlockTemplates.js +72 -0
  235. package/dist/schemas/BlockTemplates.js.map +1 -0
  236. package/dist/schemas/Doc.d.ts +411 -0
  237. package/dist/schemas/Doc.d.ts.map +1 -0
  238. package/dist/schemas/Doc.js +90 -0
  239. package/dist/schemas/Doc.js.map +1 -0
  240. package/dist/schemas/LayoutStrategy.d.ts +84 -0
  241. package/dist/schemas/LayoutStrategy.d.ts.map +1 -0
  242. package/dist/schemas/LayoutStrategy.js +123 -0
  243. package/dist/schemas/LayoutStrategy.js.map +1 -0
  244. package/dist/schemas/MediaProvider.d.ts +65 -0
  245. package/dist/schemas/MediaProvider.d.ts.map +1 -0
  246. package/dist/schemas/MediaProvider.js +13 -0
  247. package/dist/schemas/MediaProvider.js.map +1 -0
  248. package/dist/schemas/Theme.d.ts +163 -0
  249. package/dist/schemas/Theme.d.ts.map +1 -0
  250. package/dist/schemas/Theme.js +62 -0
  251. package/dist/schemas/Theme.js.map +1 -0
  252. package/dist/schemas/Types.d.ts +14 -0
  253. package/dist/schemas/Types.d.ts.map +1 -0
  254. package/dist/schemas/Types.js +5 -0
  255. package/dist/schemas/Types.js.map +1 -0
  256. package/dist/schemas/Viewport.d.ts +74 -0
  257. package/dist/schemas/Viewport.d.ts.map +1 -0
  258. package/dist/schemas/Viewport.js +63 -0
  259. package/dist/schemas/Viewport.js.map +1 -0
  260. package/dist/schemas/index.d.ts +10 -70
  261. package/dist/schemas/index.d.ts.map +1 -0
  262. package/dist/schemas/index.js +7 -60
  263. package/dist/schemas/index.js.map +1 -1
  264. package/dist/schemas/themeLibrary.d.ts +41 -0
  265. package/dist/schemas/themeLibrary.d.ts.map +1 -0
  266. package/dist/schemas/themeLibrary.js +466 -0
  267. package/dist/schemas/themeLibrary.js.map +1 -0
  268. package/dist/spatial/Geohash.d.ts +85 -0
  269. package/dist/spatial/Geohash.d.ts.map +1 -0
  270. package/dist/spatial/Geohash.js +142 -0
  271. package/dist/spatial/Geohash.js.map +1 -0
  272. package/dist/spatial/Haversine.d.ts +24 -0
  273. package/dist/spatial/Haversine.d.ts.map +1 -0
  274. package/dist/spatial/Haversine.js +48 -0
  275. package/dist/spatial/Haversine.js.map +1 -0
  276. package/dist/spatial/index.d.ts +3 -111
  277. package/dist/spatial/index.d.ts.map +1 -0
  278. package/dist/spatial/index.js +2 -24
  279. package/dist/spatial/index.js.map +1 -1
  280. package/dist/storage/LocalForageAdapter.d.ts +36 -0
  281. package/dist/storage/LocalForageAdapter.d.ts.map +1 -0
  282. package/dist/storage/LocalForageAdapter.js +82 -0
  283. package/dist/storage/LocalForageAdapter.js.map +1 -0
  284. package/dist/storage/LocalStorageAdapter.d.ts +16 -0
  285. package/dist/storage/LocalStorageAdapter.d.ts.map +1 -0
  286. package/dist/storage/LocalStorageAdapter.js +50 -0
  287. package/dist/storage/LocalStorageAdapter.js.map +1 -0
  288. package/dist/storage/MemoryStorageAdapter.d.ts +15 -0
  289. package/dist/storage/MemoryStorageAdapter.d.ts.map +1 -0
  290. package/dist/storage/MemoryStorageAdapter.js +34 -0
  291. package/dist/storage/MemoryStorageAdapter.js.map +1 -0
  292. package/dist/storage/Storage.d.ts +23 -0
  293. package/dist/storage/Storage.d.ts.map +1 -0
  294. package/dist/storage/Storage.js +9 -0
  295. package/dist/storage/Storage.js.map +1 -0
  296. package/dist/storage/index.d.ts +6 -91
  297. package/dist/storage/index.d.ts.map +1 -0
  298. package/dist/storage/index.js +3 -10
  299. package/dist/storage/index.js.map +1 -1
  300. package/dist/story/index.d.ts +3 -2
  301. package/dist/themeLibrary-DR1VRo-8.d.ts +44 -0
  302. package/dist/timing/index.d.ts +4 -0
  303. package/dist/timing/index.d.ts.map +1 -0
  304. package/dist/timing/index.js +3 -0
  305. package/dist/timing/index.js.map +1 -0
  306. package/dist/timing/narrationTiming.d.ts +54 -0
  307. package/dist/timing/narrationTiming.d.ts.map +1 -0
  308. package/dist/timing/narrationTiming.js +190 -0
  309. package/dist/timing/narrationTiming.js.map +1 -0
  310. package/dist/timing/readingTime.d.ts +54 -0
  311. package/dist/timing/readingTime.d.ts.map +1 -0
  312. package/dist/timing/readingTime.js +49 -0
  313. package/dist/timing/readingTime.js.map +1 -0
  314. package/package.json +17 -3
  315. package/src/__tests__/contentExtractor.test.ts +183 -0
  316. package/src/__tests__/seededRandom.test.ts +142 -0
  317. package/src/__tests__/slideshowGenerator.test.ts +128 -0
  318. package/src/__tests__/timing.test.ts +167 -0
  319. package/src/generate/contentExtractor.ts +808 -0
  320. package/src/generate/index.ts +21 -0
  321. package/src/generate/slideshowGenerator.ts +273 -0
  322. package/src/generate/templateMapper.ts +170 -0
  323. package/src/index.ts +3 -0
  324. package/src/random/SeededRandom.ts +127 -0
  325. package/src/random/index.ts +1 -0
  326. package/src/timing/index.ts +17 -0
  327. package/src/timing/narrationTiming.ts +220 -0
  328. package/src/timing/readingTime.ts +94 -0
@@ -0,0 +1,792 @@
1
+ import {
2
+ SeededRandom,
3
+ hashString
4
+ } from "./chunk-FVTQSNR7.js";
5
+ import {
6
+ estimateNarrationDuration
7
+ } from "./chunk-3E5F2XMR.js";
8
+
9
+ // src/generate/contentExtractor.ts
10
+ var STAT_PATTERNS = [
11
+ /\b(roughly |about |approximately |nearly |over |under |more than |less than )?([\d,]+(?:\.\d+)?)\s*%/gi,
12
+ /\b([\d,]+(?:\.\d+)?)\s*(million|billion|trillion|thousand|hundred)\b/gi,
13
+ /\b([\d,]+(?:\.\d+)?)\s*(miles?|feet|ft|meters?|m|kilometers?|km|acres?|square miles?|sq mi|hectares?)\b/gi,
14
+ /\b([\d,]+(?:\.\d+)?)\s*(x|times)\b/gi,
15
+ /\b([$€£¥])\s*([\d,]+(?:\.\d+)?)\s*(million|billion|thousand)?\b/gi,
16
+ /\b(\d+)(st|nd|rd|th)\s+(largest|smallest|oldest|newest|most|least)/gi
17
+ ];
18
+ var DATE_PATTERNS = [
19
+ /\b(January|February|March|April|May|June|July|August|September|October|November|December)\s+(\d{1,2},?\s+)?(\d{4})\b/gi,
20
+ /\b(\d{4})s\b|\b(\d{1,2})(st|nd|rd|th)\s+century\b/gi,
21
+ /\b(from\s+)?(\d{4})\s*(to|–|-|through)\s*(\d{4})\b/gi,
22
+ /\b(in|by|since|after|before|during)\s+(\d{4})\b/gi
23
+ ];
24
+ var QUOTE_PATTERNS = [
25
+ /"([^"]{15,200})"/g,
26
+ /\u201c([^\u201d]{15,200})\u201d/g,
27
+ /(\w+(?:\s+\w+)?)\s+(?:said|stated|wrote|noted|observed|commented),?\s*"([^"]+)"/gi
28
+ ];
29
+ var COMPARISON_PATTERNS = [
30
+ /from\s+(.{2,30})\s+to\s+(.{2,30})/gi,
31
+ /(.{2,30})\s+(?:vs\.?|versus)\s+(.{2,30})/gi,
32
+ /(.{2,30})\s+compared\s+to\s+(.{2,30})/gi
33
+ ];
34
+ var FACT_INDICATORS = [
35
+ "largest",
36
+ "smallest",
37
+ "oldest",
38
+ "newest",
39
+ "first",
40
+ "last",
41
+ "most",
42
+ "least",
43
+ "only",
44
+ "unique",
45
+ "rare",
46
+ "famous",
47
+ "important",
48
+ "significant",
49
+ "notable",
50
+ "remarkable",
51
+ "extraordinary",
52
+ "crucial",
53
+ "essential",
54
+ "critical",
55
+ "major",
56
+ "key",
57
+ "discovered",
58
+ "founded",
59
+ "established",
60
+ "created",
61
+ "built",
62
+ "invented",
63
+ "developed",
64
+ "introduced",
65
+ "pioneered",
66
+ "transformed",
67
+ "revolutionized",
68
+ "changed",
69
+ "shaped"
70
+ ];
71
+ var SOMBER_INDICATORS = [
72
+ "disaster",
73
+ "tragedy",
74
+ "death",
75
+ "died",
76
+ "killed",
77
+ "destroyed",
78
+ "devastated",
79
+ "collapsed",
80
+ "lost",
81
+ "abandoned",
82
+ "declined",
83
+ "war",
84
+ "battle",
85
+ "conflict",
86
+ "earthquake",
87
+ "fire",
88
+ "flood"
89
+ ];
90
+ var CELEBRATORY_INDICATORS = [
91
+ "celebration",
92
+ "victory",
93
+ "success",
94
+ "achievement",
95
+ "triumph",
96
+ "opened",
97
+ "completed",
98
+ "inaugurated",
99
+ "launched",
100
+ "won",
101
+ "record",
102
+ "breakthrough",
103
+ "milestone",
104
+ "golden",
105
+ "grand"
106
+ ];
107
+ var IMPACT_VERBS = [
108
+ "check",
109
+ "watch",
110
+ "stop",
111
+ "prepare",
112
+ "imagine",
113
+ "consider",
114
+ "look",
115
+ "listen",
116
+ "notice",
117
+ "remember",
118
+ "discover",
119
+ "explore",
120
+ "visit",
121
+ "try",
122
+ "experience",
123
+ "avoid",
124
+ "beware",
125
+ "enjoy"
126
+ ];
127
+ var LIST_PATTERNS = [
128
+ /(?:including|such as|namely|like|features?|offers?)\s+([^.]{10,150})/gi,
129
+ /(?:three|four|five|six|several|many|various)\s+(?:main|key|primary|notable|popular|important)?\s*\w+(?:\s+\w+)?:\s*([^.]{10,150})/gi
130
+ ];
131
+ var DEFINITION_PATTERNS = [
132
+ /\b([A-Z][a-z]+(?:\s+[A-Z]?[a-z]+){0,3})\s+is\s+(?:a|an|the)\s+([^.]{10,120})/g,
133
+ /known\s+as\s+([A-Z][a-z]+(?:\s+[A-Z]?[a-z]+){0,3}),\s+([^.]{10,120})/gi,
134
+ /\b([A-Z][a-z]+(?:\s+[A-Z]?[a-z]+){0,3})\s+refers?\s+to\s+([^.]{10,120})/g,
135
+ /called\s+([A-Z][a-z]+(?:\s+[A-Z]?[a-z]+){0,3}),?\s+(?:which|meaning|a)\s+([^.]{10,120})/gi
136
+ ];
137
+ function extractContent(text, options = {}) {
138
+ const {
139
+ minConfidence = 0.3,
140
+ types = ["stat", "date", "quote", "comparison", "fact", "impactLine", "list", "definition"],
141
+ maxPerType
142
+ } = options;
143
+ const elements = [];
144
+ if (types.includes("stat")) elements.push(...extractStats(text));
145
+ if (types.includes("date")) elements.push(...extractDates(text));
146
+ if (types.includes("quote")) elements.push(...extractQuotes(text));
147
+ if (types.includes("comparison")) elements.push(...extractComparisons(text));
148
+ if (types.includes("fact")) elements.push(...extractFacts(text));
149
+ if (types.includes("impactLine")) elements.push(...extractImpactLines(text));
150
+ if (types.includes("list")) elements.push(...extractLists(text));
151
+ if (types.includes("definition")) elements.push(...extractDefinitions(text));
152
+ let filtered = elements.filter((e) => e.confidence >= minConfidence);
153
+ if (maxPerType !== void 0) {
154
+ const byType = /* @__PURE__ */ new Map();
155
+ for (const elem of filtered) {
156
+ const list = byType.get(elem.type) || [];
157
+ list.push(elem);
158
+ byType.set(elem.type, list);
159
+ }
160
+ filtered = [];
161
+ for (const [, list] of byType) {
162
+ list.sort((a, b) => b.confidence - a.confidence);
163
+ filtered.push(...list.slice(0, maxPerType));
164
+ }
165
+ }
166
+ filtered.sort((a, b) => a.sourcePosition - b.sourcePosition);
167
+ filtered = deduplicateOverlapping(filtered);
168
+ return {
169
+ elements: filtered,
170
+ sourceLength: text.length,
171
+ stats: {
172
+ statCount: filtered.filter((e) => e.type === "stat").length,
173
+ dateCount: filtered.filter((e) => e.type === "date").length,
174
+ quoteCount: filtered.filter((e) => e.type === "quote").length,
175
+ comparisonCount: filtered.filter((e) => e.type === "comparison").length,
176
+ factCount: filtered.filter((e) => e.type === "fact").length,
177
+ impactLineCount: filtered.filter((e) => e.type === "impactLine").length,
178
+ listCount: filtered.filter((e) => e.type === "list").length,
179
+ definitionCount: filtered.filter((e) => e.type === "definition").length,
180
+ totalCount: filtered.length
181
+ }
182
+ };
183
+ }
184
+ function extractStats(text) {
185
+ const elements = [];
186
+ const seen = /* @__PURE__ */ new Set();
187
+ for (const pattern of STAT_PATTERNS) {
188
+ pattern.lastIndex = 0;
189
+ let match;
190
+ while ((match = pattern.exec(text)) !== null) {
191
+ const position = match.index;
192
+ if (seen.has(position)) continue;
193
+ seen.add(position);
194
+ const context = getSentenceContext(text, position, match[0].length);
195
+ const value = match[0].trim();
196
+ elements.push({
197
+ type: "stat",
198
+ text: context.sentence,
199
+ confidence: calculateStatConfidence(value, context.sentence),
200
+ sourcePosition: context.start,
201
+ endPosition: context.end,
202
+ data: { type: "stat", value, description: cleanDescription(context.sentence, value) }
203
+ });
204
+ }
205
+ }
206
+ return elements;
207
+ }
208
+ function extractDates(text) {
209
+ const elements = [];
210
+ const seen = /* @__PURE__ */ new Set();
211
+ for (const pattern of DATE_PATTERNS) {
212
+ pattern.lastIndex = 0;
213
+ let match;
214
+ while ((match = pattern.exec(text)) !== null) {
215
+ const position = match.index;
216
+ if (seen.has(position)) continue;
217
+ seen.add(position);
218
+ const context = getSentenceContext(text, position, match[0].length);
219
+ const dateStr = match[0].trim();
220
+ elements.push({
221
+ type: "date",
222
+ text: context.sentence,
223
+ confidence: calculateDateConfidence(dateStr, context.sentence),
224
+ sourcePosition: context.start,
225
+ endPosition: context.end,
226
+ data: {
227
+ type: "date",
228
+ date: dateStr,
229
+ description: cleanDescription(context.sentence, dateStr),
230
+ mood: detectMood(context.sentence)
231
+ }
232
+ });
233
+ }
234
+ }
235
+ return elements;
236
+ }
237
+ function extractQuotes(text) {
238
+ const elements = [];
239
+ const seen = /* @__PURE__ */ new Set();
240
+ for (const pattern of QUOTE_PATTERNS) {
241
+ pattern.lastIndex = 0;
242
+ let match;
243
+ while ((match = pattern.exec(text)) !== null) {
244
+ const position = match.index;
245
+ if (seen.has(position)) continue;
246
+ seen.add(position);
247
+ const quote = match.length > 2 ? match[2] : match[1];
248
+ const attribution = match.length > 2 ? match[1] : void 0;
249
+ if (quote.length < 15 || quote.length > 200) continue;
250
+ elements.push({
251
+ type: "quote",
252
+ text: match[0],
253
+ confidence: calculateQuoteConfidence(quote),
254
+ sourcePosition: position,
255
+ endPosition: position + match[0].length,
256
+ data: { type: "quote", quote: quote.trim(), attribution: attribution?.trim() }
257
+ });
258
+ }
259
+ }
260
+ return elements;
261
+ }
262
+ function extractComparisons(text) {
263
+ const elements = [];
264
+ const seen = /* @__PURE__ */ new Set();
265
+ for (const pattern of COMPARISON_PATTERNS) {
266
+ pattern.lastIndex = 0;
267
+ let match;
268
+ while ((match = pattern.exec(text)) !== null) {
269
+ const position = match.index;
270
+ if (seen.has(position)) continue;
271
+ seen.add(position);
272
+ const left = match[1].trim();
273
+ const right = match[2].trim();
274
+ if (left.length < 2 || left.length > 30) continue;
275
+ if (right.length < 2 || right.length > 30) continue;
276
+ const context = getSentenceContext(text, position, match[0].length);
277
+ elements.push({
278
+ type: "comparison",
279
+ text: context.sentence,
280
+ confidence: 0.6,
281
+ sourcePosition: context.start,
282
+ endPosition: context.end,
283
+ data: { type: "comparison", left: { label: left }, right: { label: right } }
284
+ });
285
+ }
286
+ }
287
+ return elements;
288
+ }
289
+ function forEachSentenceSpan(text, callback) {
290
+ const sentenceRegex = /[^.!?]+[.!?]*/g;
291
+ let match;
292
+ while ((match = sentenceRegex.exec(text)) !== null) {
293
+ const raw = match[0];
294
+ const rawStart = match.index;
295
+ const rawEnd = rawStart + raw.length;
296
+ let leading = 0;
297
+ while (leading < raw.length && /\s/.test(raw[leading])) {
298
+ leading++;
299
+ }
300
+ let trailing = 0;
301
+ while (trailing < raw.length - leading && /[\s.!?]/.test(raw[raw.length - 1 - trailing])) {
302
+ trailing++;
303
+ }
304
+ const start = rawStart + leading;
305
+ const end = rawEnd - trailing;
306
+ if (end <= start) continue;
307
+ const trimmed = text.slice(start, end);
308
+ if (!trimmed) continue;
309
+ callback(trimmed, start, end);
310
+ }
311
+ }
312
+ function extractFacts(text) {
313
+ const elements = [];
314
+ forEachSentenceSpan(text, (trimmed, start, end) => {
315
+ if (trimmed.length <= 20) return;
316
+ const score = scoreSentenceAsFact(trimmed);
317
+ if (score < 0.4) return;
318
+ elements.push({
319
+ type: "fact",
320
+ text: trimmed,
321
+ confidence: score,
322
+ sourcePosition: start,
323
+ endPosition: end,
324
+ data: { type: "fact", fact: trimmed }
325
+ });
326
+ });
327
+ return elements;
328
+ }
329
+ function extractImpactLines(text) {
330
+ const elements = [];
331
+ forEachSentenceSpan(text, (trimmed, start, end) => {
332
+ if (trimmed.length < 8 || trimmed.length > 60) return;
333
+ let score = 0.3;
334
+ const lower = trimmed.toLowerCase();
335
+ for (const verb of IMPACT_VERBS) {
336
+ if (lower.startsWith(verb)) {
337
+ score += 0.25;
338
+ break;
339
+ }
340
+ }
341
+ if (end < text.length && text[end] === "!") score += 0.15;
342
+ if (trimmed.length < 30) score += 0.1;
343
+ if (trimmed.includes(",")) score -= 0.1;
344
+ if (/^(and|but|or|the|a|an)\b/i.test(trimmed)) score -= 0.15;
345
+ if (score < 0.5) return;
346
+ elements.push({
347
+ type: "impactLine",
348
+ text: trimmed,
349
+ confidence: Math.min(1, score),
350
+ sourcePosition: start,
351
+ endPosition: end,
352
+ data: { type: "impactLine", text: trimmed }
353
+ });
354
+ });
355
+ return elements;
356
+ }
357
+ function extractLists(text) {
358
+ const elements = [];
359
+ const seen = /* @__PURE__ */ new Set();
360
+ for (const pattern of LIST_PATTERNS) {
361
+ pattern.lastIndex = 0;
362
+ let match;
363
+ while ((match = pattern.exec(text)) !== null) {
364
+ const position = match.index;
365
+ if (seen.has(position)) continue;
366
+ seen.add(position);
367
+ const listContent = match[1].trim();
368
+ const items = listContent.split(/,\s*(?:and|or)\s+|,\s+|\s+and\s+|\s+or\s+/).map((item) => item.trim()).filter((item) => item.length >= 2 && item.length <= 60);
369
+ if (items.length < 3 || items.length > 5) continue;
370
+ const context = getSentenceContext(text, position, match[0].length);
371
+ elements.push({
372
+ type: "list",
373
+ text: context.sentence,
374
+ confidence: 0.65,
375
+ sourcePosition: context.start,
376
+ endPosition: context.end,
377
+ data: { type: "list", items }
378
+ });
379
+ }
380
+ }
381
+ return elements;
382
+ }
383
+ function extractDefinitions(text) {
384
+ const elements = [];
385
+ const seen = /* @__PURE__ */ new Set();
386
+ for (const pattern of DEFINITION_PATTERNS) {
387
+ pattern.lastIndex = 0;
388
+ let match;
389
+ while ((match = pattern.exec(text)) !== null) {
390
+ const position = match.index;
391
+ if (seen.has(position)) continue;
392
+ seen.add(position);
393
+ const term = match[1].trim();
394
+ const definition = match[2].trim();
395
+ if (term.length < 3 || term.length > 30) continue;
396
+ if (definition.length < 10 || definition.length > 120) continue;
397
+ const context = getSentenceContext(text, position, match[0].length);
398
+ elements.push({
399
+ type: "definition",
400
+ text: context.sentence,
401
+ confidence: 0.6,
402
+ sourcePosition: context.start,
403
+ endPosition: context.end,
404
+ data: { type: "definition", term, definition }
405
+ });
406
+ }
407
+ }
408
+ return elements;
409
+ }
410
+ function getSentenceContext(text, matchStart, matchLength) {
411
+ let start = matchStart;
412
+ while (start > 0 && !/[.!?]/.test(text[start - 1])) start--;
413
+ while (start < matchStart && /\s/.test(text[start])) start++;
414
+ let end = matchStart + matchLength;
415
+ while (end < text.length && !/[.!?]/.test(text[end])) end++;
416
+ if (end < text.length) end++;
417
+ return { sentence: text.slice(start, end).trim(), start, end };
418
+ }
419
+ function calculateStatConfidence(value, context) {
420
+ let score = 0.5;
421
+ if (value.includes("%")) score += 0.2;
422
+ if (/million|billion|trillion/i.test(value)) score += 0.15;
423
+ if (/increased|decreased|grew|dropped|rose|fell/i.test(context)) score += 0.15;
424
+ if (context.length < 30) score -= 0.2;
425
+ return Math.min(1, Math.max(0, score));
426
+ }
427
+ function calculateDateConfidence(date, context) {
428
+ let score = 0.5;
429
+ if (/January|February|March|April|May|June|July|August|September|October|November|December/i.test(
430
+ date
431
+ ))
432
+ score += 0.2;
433
+ if (/founded|established|built|opened|discovered|created/i.test(context)) score += 0.2;
434
+ if (/happened|occurred|took place|began|ended/i.test(context)) score += 0.15;
435
+ return Math.min(1, Math.max(0, score));
436
+ }
437
+ function calculateQuoteConfidence(quote) {
438
+ let score = 0.5;
439
+ if (quote.length >= 30 && quote.length <= 150) score += 0.2;
440
+ if (/\b(I|we|our|my)\b/i.test(quote)) score += 0.1;
441
+ if (!/[.!?]$/.test(quote)) score -= 0.1;
442
+ return Math.min(1, Math.max(0, score));
443
+ }
444
+ function scoreSentenceAsFact(sentence) {
445
+ let score = 0.3;
446
+ const lower = sentence.toLowerCase();
447
+ for (const indicator of FACT_INDICATORS) {
448
+ if (lower.includes(indicator)) {
449
+ score += 0.1;
450
+ break;
451
+ }
452
+ }
453
+ const properNouns = sentence.match(/\b[A-Z][a-z]+\b/g);
454
+ if (properNouns && properNouns.length >= 2) score += 0.15;
455
+ if (/\d/.test(sentence)) score += 0.1;
456
+ if (sentence.endsWith("?")) score -= 0.3;
457
+ if (sentence.length > 200) score -= 0.15;
458
+ return Math.min(1, Math.max(0, score));
459
+ }
460
+ function detectMood(sentence) {
461
+ const lower = sentence.toLowerCase();
462
+ for (const word of SOMBER_INDICATORS) {
463
+ if (lower.includes(word)) return "somber";
464
+ }
465
+ for (const word of CELEBRATORY_INDICATORS) {
466
+ if (lower.includes(word)) return "celebratory";
467
+ }
468
+ return "neutral";
469
+ }
470
+ function cleanDescription(sentence, value) {
471
+ const prepositionPatterns = [
472
+ new RegExp(`\\b[Ii]n\\s+${escapeRegex(value)}[,.]?\\s*`, "g"),
473
+ new RegExp(`\\b[Oo]n\\s+${escapeRegex(value)}[,.]?\\s*`, "g"),
474
+ new RegExp(`\\b[Dd]uring\\s+${escapeRegex(value)}[,.]?\\s*`, "g"),
475
+ new RegExp(`\\b[Bb]y\\s+${escapeRegex(value)}[,.]?\\s*`, "g"),
476
+ new RegExp(`\\b[Ss]ince\\s+${escapeRegex(value)}[,.]?\\s*`, "g"),
477
+ new RegExp(`\\b[Ff]rom\\s+${escapeRegex(value)}[,.]?\\s*`, "g")
478
+ ];
479
+ let desc = sentence;
480
+ for (const pattern of prepositionPatterns) {
481
+ desc = desc.replace(pattern, "");
482
+ }
483
+ if (desc === sentence) {
484
+ desc = sentence.replace(value, "").trim();
485
+ }
486
+ desc = desc.replace(/^[,:\-–—]+\s*/, "").replace(/\s*[,:\-–—]+$/, "");
487
+ desc = desc.replace(
488
+ /\s+(?:of|on|in|at|by|to|for|from|with|about|over|under|between|than|into|onto|upon)\s*([,.])/gi,
489
+ "$1"
490
+ );
491
+ desc = desc.replace(
492
+ /\s+(?:for|of|to|in|at|by|with|from|about|over|under|between|than|into|onto|upon)\s*[.!?]?\s*$/i,
493
+ "."
494
+ );
495
+ desc = desc.replace(/\s{2,}/g, " ").replace(/\s+([,.])/g, "$1");
496
+ desc = desc.charAt(0).toUpperCase() + desc.slice(1);
497
+ return desc.trim();
498
+ }
499
+ function escapeRegex(str) {
500
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
501
+ }
502
+ var TYPE_SPECIFICITY = {
503
+ stat: 5,
504
+ date: 4,
505
+ quote: 3,
506
+ definition: 3,
507
+ comparison: 2,
508
+ list: 2,
509
+ impactLine: 2,
510
+ fact: 1
511
+ };
512
+ function deduplicateOverlapping(elements) {
513
+ if (elements.length <= 1) return elements;
514
+ const toRemove = /* @__PURE__ */ new Set();
515
+ for (let i = 0; i < elements.length; i++) {
516
+ if (toRemove.has(i)) continue;
517
+ const a = elements[i];
518
+ for (let j = i + 1; j < elements.length; j++) {
519
+ if (toRemove.has(j)) continue;
520
+ const b = elements[j];
521
+ if (elementsOverlap(a, b)) {
522
+ const aSpec = TYPE_SPECIFICITY[a.type];
523
+ const bSpec = TYPE_SPECIFICITY[b.type];
524
+ if (aSpec >= bSpec) {
525
+ toRemove.add(j);
526
+ } else {
527
+ toRemove.add(i);
528
+ break;
529
+ }
530
+ }
531
+ }
532
+ }
533
+ return elements.filter((_, index) => !toRemove.has(index));
534
+ }
535
+ function elementsOverlap(a, b) {
536
+ if (a.sourcePosition === b.sourcePosition) return true;
537
+ if (a.sourcePosition <= b.sourcePosition && a.endPosition >= b.endPosition) return true;
538
+ if (b.sourcePosition <= a.sourcePosition && b.endPosition >= a.endPosition) return true;
539
+ const overlapStart = Math.max(a.sourcePosition, b.sourcePosition);
540
+ const overlapEnd = Math.min(a.endPosition, b.endPosition);
541
+ if (overlapEnd > overlapStart) {
542
+ const overlapLength = overlapEnd - overlapStart;
543
+ const minLength = Math.min(a.endPosition - a.sourcePosition, b.endPosition - b.sourcePosition);
544
+ if (overlapLength > minLength * 0.5) return true;
545
+ }
546
+ return false;
547
+ }
548
+ function stripMarkdown(markdown) {
549
+ return markdown.replace(/```[\s\S]*?```/g, "").replace(/!\[([^\]]*)\]\([^)]+\)/g, "").replace(/\[([^\]]+)\]\([^)]+\)/g, "$1").replace(/^#{1,6}\s+/gm, "").replace(/\*\*([^*]+)\*\*/g, "$1").replace(/\*([^*]+)\*/g, "$1").replace(/__([^_]+)__/g, "$1").replace(/_([^_]+)_/g, "$1").replace(/`([^`]+)`/g, "$1").replace(/^>\s+/gm, "").replace(/^[-*_]{3,}$/gm, "").replace(/\n{3,}/g, "\n\n").trim();
550
+ }
551
+
552
+ // src/generate/templateMapper.ts
553
+ function mapElementToBlock(element, options) {
554
+ const base = {
555
+ id: options.id,
556
+ duration: options.duration,
557
+ audioSegment: options.audioSegment,
558
+ sourceStartTime: options.sourceStartTime,
559
+ sourceDuration: options.sourceDuration
560
+ };
561
+ switch (element.data.type) {
562
+ case "stat":
563
+ return mapStat(element.data, base, options);
564
+ case "date":
565
+ return mapDate(element.data, base, options);
566
+ case "quote":
567
+ return mapQuote(element.data, base, options);
568
+ case "comparison":
569
+ return mapComparison(element.data, base, options);
570
+ case "fact":
571
+ return mapFact(element.data, base, options);
572
+ case "impactLine":
573
+ return mapImpactLine(element.data, base, options);
574
+ case "list":
575
+ return mapList(element.data, base, options);
576
+ case "definition":
577
+ return mapDefinition(element.data, base, options);
578
+ }
579
+ }
580
+ function mapStat(data, base, opts) {
581
+ return {
582
+ ...base,
583
+ template: "statHighlight",
584
+ stat: data.value,
585
+ description: data.description,
586
+ colorScheme: opts.colorScheme,
587
+ accentImage: opts.accentImage
588
+ };
589
+ }
590
+ function mapDate(data, base, opts) {
591
+ return {
592
+ ...base,
593
+ template: "dateEvent",
594
+ date: data.date,
595
+ description: data.description,
596
+ mood: data.mood,
597
+ accentImage: opts.accentImage
598
+ };
599
+ }
600
+ function mapQuote(data, base, opts) {
601
+ return {
602
+ ...base,
603
+ template: "quoteBlock",
604
+ quote: data.quote,
605
+ attribution: data.attribution,
606
+ accentImage: opts.accentImage
607
+ };
608
+ }
609
+ function mapComparison(data, base, opts) {
610
+ return {
611
+ ...base,
612
+ template: "twoColumn",
613
+ left: data.left,
614
+ right: data.right,
615
+ header: data.header,
616
+ leftColor: opts.colorScheme
617
+ };
618
+ }
619
+ function mapFact(data, base, opts) {
620
+ return {
621
+ ...base,
622
+ template: "factCard",
623
+ fact: data.fact,
624
+ explanation: data.explanation ?? "",
625
+ accentImage: opts.accentImage
626
+ };
627
+ }
628
+ function mapImpactLine(data, base, opts) {
629
+ return {
630
+ ...base,
631
+ template: "fullBleedQuote",
632
+ text: data.text,
633
+ colorScheme: opts.colorScheme
634
+ };
635
+ }
636
+ function mapList(data, base, opts) {
637
+ return {
638
+ ...base,
639
+ template: "listBlock",
640
+ items: data.items,
641
+ title: data.title,
642
+ colorScheme: opts.colorScheme,
643
+ accentImage: opts.accentImage
644
+ };
645
+ }
646
+ function mapDefinition(data, base, opts) {
647
+ return {
648
+ ...base,
649
+ template: "definitionCard",
650
+ term: data.term,
651
+ definition: data.definition,
652
+ origin: data.origin,
653
+ colorScheme: opts.colorScheme,
654
+ accentImage: opts.accentImage
655
+ };
656
+ }
657
+
658
+ // src/generate/slideshowGenerator.ts
659
+ var DEFAULT_COLOR_SCHEMES = ["blue", "green", "purple", "orange", "red"];
660
+ var DEFAULT_AMBIENT_MOTIONS = [
661
+ "zoomIn",
662
+ "zoomOut",
663
+ "panLeft",
664
+ "panRight"
665
+ ];
666
+ var DEFAULT_ACCENT_POSITIONS = ["left-strip", "right-strip", "bottom-strip"];
667
+ function generateSlideshow(text, images = [], options = {}) {
668
+ const {
669
+ seed,
670
+ title,
671
+ subtitle,
672
+ duration: explicitDuration,
673
+ targetSlides,
674
+ colorSchemes = DEFAULT_COLOR_SCHEMES,
675
+ ambientMotions = DEFAULT_AMBIENT_MOTIONS,
676
+ accentPositions = DEFAULT_ACCENT_POSITIONS,
677
+ minSlideDuration = 4,
678
+ maxSlideDuration = 15,
679
+ themeId,
680
+ isMarkdown = false,
681
+ minConfidence = 0.3
682
+ } = options;
683
+ const plainText = isMarkdown ? stripMarkdown(text) : text;
684
+ const rng = new SeededRandom(seed ?? hashString(plainText));
685
+ const totalDuration = explicitDuration ?? estimateNarrationDuration(plainText);
686
+ const extraction = extractContent(plainText, { minConfidence });
687
+ const allElements = extraction.elements;
688
+ const slideBudget = targetSlides ?? computeSlideBudget(totalDuration, allElements.length);
689
+ const imageSlotCount = images.length > 0 ? Math.max(1, Math.round(slideBudget * 0.4)) : 0;
690
+ const contentSlotCount = Math.max(0, slideBudget - imageSlotCount - (title ? 1 : 0));
691
+ const sorted = [...allElements].sort((a, b) => b.confidence - a.confidence);
692
+ const selected = sorted.slice(0, contentSlotCount);
693
+ selected.sort((a, b) => a.sourcePosition - b.sourcePosition);
694
+ const blocks = [];
695
+ let slideIndex = 0;
696
+ let colorIdx = 0;
697
+ let accentIdx = 0;
698
+ const totalSlideCount = (title ? 1 : 0) + selected.length + Math.min(imageSlotCount, images.length);
699
+ const perSlide = totalSlideCount > 0 ? Math.min(maxSlideDuration, Math.max(minSlideDuration, totalDuration / totalSlideCount)) : minSlideDuration;
700
+ if (title) {
701
+ const titleBlock = {
702
+ id: `slide-${slideIndex++}`,
703
+ template: "titleBlock",
704
+ title,
705
+ subtitle,
706
+ duration: Math.min(perSlide, 6),
707
+ audioSegment: 0
708
+ };
709
+ blocks.push(titleBlock);
710
+ }
711
+ const standaloneImages = images.slice(0, Math.min(imageSlotCount, images.length));
712
+ const accentPool = images.length > standaloneImages.length ? images.slice(standaloneImages.length) : [...images];
713
+ const imageInterval = standaloneImages.length > 0 ? Math.max(1, Math.floor(selected.length / (standaloneImages.length + 1))) : Infinity;
714
+ let imgIdx = 0;
715
+ let sinceImage = 0;
716
+ for (let i = 0; i < selected.length; i++) {
717
+ if (sinceImage >= imageInterval && imgIdx < standaloneImages.length) {
718
+ blocks.push(
719
+ createImageSlide(standaloneImages[imgIdx], slideIndex++, perSlide, rng, ambientMotions)
720
+ );
721
+ imgIdx++;
722
+ sinceImage = 0;
723
+ }
724
+ const element = selected[i];
725
+ let accentImage;
726
+ if (accentPool.length > 0) {
727
+ const img = accentPool[i % accentPool.length];
728
+ accentImage = {
729
+ src: img.src,
730
+ alt: img.alt ?? "",
731
+ position: accentPositions[accentIdx % accentPositions.length],
732
+ ambientMotion: rng.pickRequired(ambientMotions),
733
+ credit: img.credit,
734
+ license: img.license
735
+ };
736
+ accentIdx++;
737
+ }
738
+ const block = mapElementToBlock(element, {
739
+ id: `slide-${slideIndex++}`,
740
+ duration: perSlide,
741
+ audioSegment: 0,
742
+ colorScheme: colorSchemes[colorIdx % colorSchemes.length],
743
+ accentImage
744
+ });
745
+ blocks.push(block);
746
+ colorIdx++;
747
+ sinceImage++;
748
+ }
749
+ while (imgIdx < standaloneImages.length) {
750
+ blocks.push(
751
+ createImageSlide(standaloneImages[imgIdx], slideIndex++, perSlide, rng, ambientMotions)
752
+ );
753
+ imgIdx++;
754
+ }
755
+ const doc = {
756
+ articleId: title ?? "slideshow",
757
+ duration: totalDuration,
758
+ blocks,
759
+ audio: {
760
+ segments: [{ src: "", name: "main", duration: totalDuration, startTime: 0 }]
761
+ },
762
+ themeId
763
+ };
764
+ return doc;
765
+ }
766
+ function computeSlideBudget(duration, elementCount) {
767
+ const byDuration = Math.round(duration / 60 * 5);
768
+ const budget = Math.min(byDuration, elementCount + 4);
769
+ return Math.max(3, Math.min(12, budget));
770
+ }
771
+ function createImageSlide(img, index, duration, rng, motions) {
772
+ return {
773
+ id: `slide-${index}`,
774
+ template: "imageWithCaption",
775
+ imageSrc: img.src,
776
+ imageAlt: img.alt ?? "",
777
+ caption: img.alt,
778
+ duration,
779
+ audioSegment: 0,
780
+ ambientMotion: rng.pickRequired(motions),
781
+ imageCredit: img.credit,
782
+ imageLicense: img.license
783
+ };
784
+ }
785
+
786
+ export {
787
+ extractContent,
788
+ stripMarkdown,
789
+ mapElementToBlock,
790
+ generateSlideshow
791
+ };
792
+ //# sourceMappingURL=chunk-VP5SZTZ2.js.map