holosphere 2.0.0-alpha7 → 2.0.0-alpha9

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 (327) hide show
  1. package/CHANGELOG.md +446 -0
  2. package/FEATURES.md +431 -0
  3. package/LICENSE +29 -166
  4. package/LICENSE-AGPL.md +180 -0
  5. package/dist/cdn/holosphere.min.js +55 -0
  6. package/dist/cdn/holosphere.min.js.map +1 -0
  7. package/dist/cjs/holosphere.cjs +1 -1
  8. package/dist/esm/holosphere.js +1 -1
  9. package/dist/{index-C-IlLYlk.cjs → index-DDGt_V9o.cjs} +2 -2
  10. package/dist/{index-C-IlLYlk.cjs.map → index-DDGt_V9o.cjs.map} +1 -1
  11. package/dist/{index-d6f4RJBM.js → index-DJXftyvB.js} +2253 -387
  12. package/dist/index-DJXftyvB.js.map +1 -0
  13. package/dist/index-DMbdcMtK.cjs +18 -0
  14. package/dist/index-DMbdcMtK.cjs.map +1 -0
  15. package/dist/{index-jmTHEbR2.js → index-DeZ1xz_s.js} +2 -2
  16. package/dist/{index-jmTHEbR2.js.map → index-DeZ1xz_s.js.map} +1 -1
  17. package/dist/{indexeddb-storage-D8kOl0oK.js → indexeddb-storage-BFt6hMeF.js} +48 -4
  18. package/dist/indexeddb-storage-BFt6hMeF.js.map +1 -0
  19. package/dist/{indexeddb-storage-a8GipaDr.cjs → indexeddb-storage-BK5tv4Sh.cjs} +2 -2
  20. package/dist/indexeddb-storage-BK5tv4Sh.cjs.map +1 -0
  21. package/dist/{memory-storage-DBQK622V.js → memory-storage-C9HuoL2E.js} +44 -4
  22. package/dist/memory-storage-C9HuoL2E.js.map +1 -0
  23. package/dist/{memory-storage-gfRovk2O.cjs → memory-storage-Dao7jfYG.cjs} +2 -2
  24. package/dist/memory-storage-Dao7jfYG.cjs.map +1 -0
  25. package/dist/{secp256k1-BCAPF45D.cjs → secp256k1-BbKzbLtD.cjs} +2 -2
  26. package/dist/{secp256k1-BCAPF45D.cjs.map → secp256k1-BbKzbLtD.cjs.map} +1 -1
  27. package/dist/{secp256k1-DYm_CMqW.js → secp256k1-CreY7Pcl.js} +2 -2
  28. package/dist/{secp256k1-DYm_CMqW.js.map → secp256k1-CreY7Pcl.js.map} +1 -1
  29. package/docs/api/ai_aggregation.js.html +333 -0
  30. package/docs/api/ai_breakdown.js.html +524 -0
  31. package/docs/api/ai_classifier.js.html +231 -0
  32. package/docs/api/ai_council.js.html +246 -0
  33. package/docs/api/ai_embeddings.js.html +304 -0
  34. package/docs/api/ai_federation-ai.js.html +338 -0
  35. package/docs/api/ai_h3-ai.js.html +970 -0
  36. package/docs/api/ai_index.js.html +124 -0
  37. package/docs/api/ai_json-ops.js.html +241 -0
  38. package/docs/api/ai_llm-service.js.html +239 -0
  39. package/docs/api/ai_nl-query.js.html +236 -0
  40. package/docs/api/ai_relationships.js.html +367 -0
  41. package/docs/api/ai_schema-extractor.js.html +235 -0
  42. package/docs/api/ai_spatial.js.html +307 -0
  43. package/docs/api/ai_tts.js.html +214 -0
  44. package/docs/api/content_social-protocols.js.html +180 -0
  45. package/docs/api/core_holosphere.js.html +757 -0
  46. package/docs/api/crypto_nostr-utils.js.html +306 -0
  47. package/docs/api/crypto_secp256k1.js.html +267 -0
  48. package/docs/api/data/search.json +1 -0
  49. package/docs/api/federation_discovery.js.html +337 -0
  50. package/docs/api/federation_handshake.js.html +478 -0
  51. package/docs/api/federation_hologram.js.html +1053 -0
  52. package/docs/api/federation_registry.js.html +389 -0
  53. package/docs/api/fonts/Inconsolata-Regular.ttf +0 -0
  54. package/docs/api/fonts/OpenSans-Regular.ttf +0 -0
  55. package/docs/api/fonts/WorkSans-Bold.ttf +0 -0
  56. package/docs/api/global.html +3 -0
  57. package/docs/api/hierarchical_upcast.js.html +128 -0
  58. package/docs/api/index.html +265 -0
  59. package/docs/api/index.js.html +1868 -0
  60. package/docs/api/lib_ai-methods.js.html +660 -0
  61. package/docs/api/lib_contract-methods.js.html +445 -0
  62. package/docs/api/lib_errors.js.html +56 -0
  63. package/docs/api/lib_federation-methods.js.html +348 -0
  64. package/docs/api/lib_index.js.html +33 -0
  65. package/docs/api/module-ai.html +5 -0
  66. package/docs/api/module-ai_aggregation-SmartAggregation.html +6 -0
  67. package/docs/api/module-ai_aggregation.SmartAggregation.html +3 -0
  68. package/docs/api/module-ai_aggregation.html +3 -0
  69. package/docs/api/module-ai_breakdown-TaskBreakdown.html +5 -0
  70. package/docs/api/module-ai_breakdown.TaskBreakdown.html +3 -0
  71. package/docs/api/module-ai_breakdown.html +3 -0
  72. package/docs/api/module-ai_classifier-Classifier.html +6 -0
  73. package/docs/api/module-ai_classifier.Classifier.html +3 -0
  74. package/docs/api/module-ai_classifier.html +3 -0
  75. package/docs/api/module-ai_council-Council.html +6 -0
  76. package/docs/api/module-ai_council.Council.html +3 -0
  77. package/docs/api/module-ai_council.html +3 -0
  78. package/docs/api/module-ai_embeddings-Embeddings.html +5 -0
  79. package/docs/api/module-ai_embeddings.Embeddings.html +3 -0
  80. package/docs/api/module-ai_embeddings.html +3 -0
  81. package/docs/api/module-ai_federation-ai-FederationAdvisor.html +6 -0
  82. package/docs/api/module-ai_federation-ai.FederationAdvisor.html +3 -0
  83. package/docs/api/module-ai_federation-ai.html +3 -0
  84. package/docs/api/module-ai_h3-ai-H3AI.html +6 -0
  85. package/docs/api/module-ai_h3-ai.H3AI.html +3 -0
  86. package/docs/api/module-ai_h3-ai.html +3 -0
  87. package/docs/api/module-ai_json-ops-JSONOps.html +5 -0
  88. package/docs/api/module-ai_json-ops.JSONOps.html +3 -0
  89. package/docs/api/module-ai_json-ops.html +3 -0
  90. package/docs/api/module-ai_llm-service-LLMService.html +5 -0
  91. package/docs/api/module-ai_llm-service.LLMService.html +3 -0
  92. package/docs/api/module-ai_llm-service.html +3 -0
  93. package/docs/api/module-ai_nl-query-NLQuery.html +5 -0
  94. package/docs/api/module-ai_nl-query.NLQuery.html +3 -0
  95. package/docs/api/module-ai_nl-query.html +3 -0
  96. package/docs/api/module-ai_relationships-RelationshipDiscovery.html +6 -0
  97. package/docs/api/module-ai_relationships.RelationshipDiscovery.html +3 -0
  98. package/docs/api/module-ai_relationships.html +3 -0
  99. package/docs/api/module-ai_schema-extractor-SchemaExtractor.html +5 -0
  100. package/docs/api/module-ai_schema-extractor.SchemaExtractor.html +3 -0
  101. package/docs/api/module-ai_schema-extractor.html +3 -0
  102. package/docs/api/module-ai_spatial-SpatialAnalysis.html +6 -0
  103. package/docs/api/module-ai_spatial.SpatialAnalysis.html +3 -0
  104. package/docs/api/module-ai_spatial.html +3 -0
  105. package/docs/api/module-ai_tts-TTS.html +5 -0
  106. package/docs/api/module-ai_tts.TTS.html +3 -0
  107. package/docs/api/module-ai_tts.html +3 -0
  108. package/docs/api/module-content_social-protocols.html +3 -0
  109. package/docs/api/module-core_holosphere-HoloSphere.html +6 -0
  110. package/docs/api/module-core_holosphere.HoloSphere.html +3 -0
  111. package/docs/api/module-core_holosphere.html +3 -0
  112. package/docs/api/module-crypto_nostr-utils.html +3 -0
  113. package/docs/api/module-crypto_secp256k1.html +3 -0
  114. package/docs/api/module-federation_hologram.html +3 -0
  115. package/docs/api/module-hierarchical_upcast.html +3 -0
  116. package/docs/api/module-holosphere-HoloSphereBase.html +3 -0
  117. package/docs/api/module-holosphere.html +3 -0
  118. package/docs/api/module-lib_ai-methods.html +3 -0
  119. package/docs/api/module-lib_contract-methods.html +3 -0
  120. package/docs/api/module-lib_errors-AuthorizationError.html +3 -0
  121. package/docs/api/module-lib_errors-ValidationError.html +3 -0
  122. package/docs/api/module-lib_errors.AuthorizationError.html +3 -0
  123. package/docs/api/module-lib_errors.ValidationError.html +3 -0
  124. package/docs/api/module-lib_errors.html +3 -0
  125. package/docs/api/module-lib_federation-methods.html +3 -0
  126. package/docs/api/module-lib_index.html +3 -0
  127. package/docs/api/module-schema_validator-ValidationError.html +3 -0
  128. package/docs/api/module-schema_validator.ValidationError.html +3 -0
  129. package/docs/api/module-schema_validator.html +3 -0
  130. package/docs/api/module-spatial_h3-operations.html +4 -0
  131. package/docs/api/module-storage_backend-factory.BackendFactory.html +3 -0
  132. package/docs/api/module-storage_backend-factory.html +3 -0
  133. package/docs/api/module-storage_backend-interface-StorageBackend.html +3 -0
  134. package/docs/api/module-storage_backend-interface.StorageBackend.html +3 -0
  135. package/docs/api/module-storage_backend-interface.html +3 -0
  136. package/docs/api/module-storage_backends_activitypub-backend-ActivityPubBackend.html +7 -0
  137. package/docs/api/module-storage_backends_activitypub-backend.ActivityPubBackend.html +3 -0
  138. package/docs/api/module-storage_backends_activitypub-backend.html +3 -0
  139. package/docs/api/module-storage_backends_activitypub_server-ActivityPubServer.html +8 -0
  140. package/docs/api/module-storage_backends_activitypub_server.ActivityPubServer.html +3 -0
  141. package/docs/api/module-storage_backends_activitypub_server.html +3 -0
  142. package/docs/api/module-storage_backends_gundb-backend-GunDBBackend.html +7 -0
  143. package/docs/api/module-storage_backends_gundb-backend.GunDBBackend.html +3 -0
  144. package/docs/api/module-storage_backends_gundb-backend.html +3 -0
  145. package/docs/api/module-storage_backends_nostr-backend-NostrBackend.html +8 -0
  146. package/docs/api/module-storage_backends_nostr-backend.NostrBackend.html +3 -0
  147. package/docs/api/module-storage_backends_nostr-backend.html +3 -0
  148. package/docs/api/module-storage_filesystem-storage-FileSystemStorage.html +5 -0
  149. package/docs/api/module-storage_filesystem-storage-browser-FileSystemStorage.html +3 -0
  150. package/docs/api/module-storage_filesystem-storage-browser.FileSystemStorage.html +3 -0
  151. package/docs/api/module-storage_filesystem-storage-browser.html +3 -0
  152. package/docs/api/module-storage_filesystem-storage.FileSystemStorage.html +3 -0
  153. package/docs/api/module-storage_filesystem-storage.html +3 -0
  154. package/docs/api/module-storage_global-tables.html +3 -0
  155. package/docs/api/module-storage_gun-async.html +3 -0
  156. package/docs/api/module-storage_gun-auth-GunAuth.html +5 -0
  157. package/docs/api/module-storage_gun-auth.GunAuth.html +3 -0
  158. package/docs/api/module-storage_gun-auth.html +3 -0
  159. package/docs/api/module-storage_gun-federation.html +3 -0
  160. package/docs/api/module-storage_gun-references-GunReferenceHandler.html +5 -0
  161. package/docs/api/module-storage_gun-references.GunReferenceHandler.html +3 -0
  162. package/docs/api/module-storage_gun-references.html +3 -0
  163. package/docs/api/module-storage_gun-schema-GunSchemaValidator.html +5 -0
  164. package/docs/api/module-storage_gun-schema.GunSchemaValidator.html +3 -0
  165. package/docs/api/module-storage_gun-schema.html +3 -0
  166. package/docs/api/module-storage_gun-wrapper.html +11 -0
  167. package/docs/api/module-storage_indexeddb-storage-IndexedDBStorage.html +5 -0
  168. package/docs/api/module-storage_indexeddb-storage.IndexedDBStorage.html +3 -0
  169. package/docs/api/module-storage_indexeddb-storage.html +3 -0
  170. package/docs/api/module-storage_key-storage-simple.html +3 -0
  171. package/docs/api/module-storage_key-storage.html +4 -0
  172. package/docs/api/module-storage_memory-storage-MemoryStorage.html +5 -0
  173. package/docs/api/module-storage_memory-storage.MemoryStorage.html +3 -0
  174. package/docs/api/module-storage_memory-storage.html +3 -0
  175. package/docs/api/module-storage_migration-MigrationTool.html +6 -0
  176. package/docs/api/module-storage_migration.MigrationTool.html +3 -0
  177. package/docs/api/module-storage_migration.html +3 -0
  178. package/docs/api/module-storage_nostr-async.html +18 -0
  179. package/docs/api/module-storage_nostr-client-LRUCache.html +3 -0
  180. package/docs/api/module-storage_nostr-client-NostrClient.html +7 -0
  181. package/docs/api/module-storage_nostr-client.NostrClient.html +15 -0
  182. package/docs/api/module-storage_nostr-client.html +6 -0
  183. package/docs/api/module-storage_nostr-wrapper.html +3 -0
  184. package/docs/api/module-storage_outbox-queue-OutboxQueue.html +4 -0
  185. package/docs/api/module-storage_outbox-queue.OutboxQueue.html +3 -0
  186. package/docs/api/module-storage_outbox-queue.html +3 -0
  187. package/docs/api/module-storage_persistent-storage-PersistentStorage.html +3 -0
  188. package/docs/api/module-storage_persistent-storage.html +4 -0
  189. package/docs/api/module-storage_sync-service-SyncService.html +5 -0
  190. package/docs/api/module-storage_sync-service.SyncService.html +3 -0
  191. package/docs/api/module-storage_sync-service.html +3 -0
  192. package/docs/api/module-storage_unified-storage.html +3 -0
  193. package/docs/api/module-subscriptions_manager.SubscriptionRegistry.html +3 -0
  194. package/docs/api/module-subscriptions_manager.html +3 -0
  195. package/docs/api/schema_validator.js.html +113 -0
  196. package/docs/api/scripts/core.js +726 -0
  197. package/docs/api/scripts/core.min.js +23 -0
  198. package/docs/api/scripts/resize.js +90 -0
  199. package/docs/api/scripts/search.js +265 -0
  200. package/docs/api/scripts/search.min.js +6 -0
  201. package/docs/api/scripts/third-party/Apache-License-2.0.txt +202 -0
  202. package/docs/api/scripts/third-party/fuse.js +9 -0
  203. package/docs/api/scripts/third-party/hljs-line-num-original.js +369 -0
  204. package/docs/api/scripts/third-party/hljs-line-num.js +1 -0
  205. package/docs/api/scripts/third-party/hljs-original.js +5171 -0
  206. package/docs/api/scripts/third-party/hljs.js +1 -0
  207. package/docs/api/scripts/third-party/popper.js +5 -0
  208. package/docs/api/scripts/third-party/tippy.js +1 -0
  209. package/docs/api/scripts/third-party/tocbot.js +672 -0
  210. package/docs/api/scripts/third-party/tocbot.min.js +1 -0
  211. package/docs/api/spatial_h3-operations.js.html +129 -0
  212. package/docs/api/storage_backend-factory.js.html +133 -0
  213. package/docs/api/storage_backend-interface.js.html +164 -0
  214. package/docs/api/storage_backends_activitypub-backend.js.html +298 -0
  215. package/docs/api/storage_backends_activitypub_server.js.html +678 -0
  216. package/docs/api/storage_backends_gundb-backend.js.html +878 -0
  217. package/docs/api/storage_backends_nostr-backend.js.html +254 -0
  218. package/docs/api/storage_filesystem-storage-browser.js.html +83 -0
  219. package/docs/api/storage_filesystem-storage.js.html +207 -0
  220. package/docs/api/storage_global-tables.js.html +116 -0
  221. package/docs/api/storage_gun-async.js.html +344 -0
  222. package/docs/api/storage_gun-auth.js.html +376 -0
  223. package/docs/api/storage_gun-federation.js.html +788 -0
  224. package/docs/api/storage_gun-references.js.html +212 -0
  225. package/docs/api/storage_gun-schema.js.html +309 -0
  226. package/docs/api/storage_gun-wrapper.js.html +645 -0
  227. package/docs/api/storage_indexeddb-storage.js.html +224 -0
  228. package/docs/api/storage_key-storage-simple.js.html +102 -0
  229. package/docs/api/storage_key-storage.js.html +171 -0
  230. package/docs/api/storage_memory-storage.js.html +128 -0
  231. package/docs/api/storage_migration.js.html +354 -0
  232. package/docs/api/storage_nostr-async.js.html +1076 -0
  233. package/docs/api/storage_nostr-client.js.html +1598 -0
  234. package/docs/api/storage_nostr-wrapper.js.html +218 -0
  235. package/docs/api/storage_outbox-queue.js.html +248 -0
  236. package/docs/api/storage_persistent-storage.js.html +160 -0
  237. package/docs/api/storage_sync-service.js.html +201 -0
  238. package/docs/api/storage_unified-storage.js.html +157 -0
  239. package/docs/api/styles/clean-jsdoc-theme-base.css +1159 -0
  240. package/docs/api/styles/clean-jsdoc-theme-dark.css +412 -0
  241. package/docs/api/styles/clean-jsdoc-theme-light.css +482 -0
  242. package/docs/api/styles/clean-jsdoc-theme-scrollbar.css +30 -0
  243. package/docs/api/styles/clean-jsdoc-theme-without-scrollbar.min.css +1 -0
  244. package/docs/api/styles/clean-jsdoc-theme.min.css +1 -0
  245. package/docs/api/subscriptions_manager.js.html +162 -0
  246. package/examples/holosphere-widget.js +1242 -0
  247. package/examples/widget-demo.html +274 -0
  248. package/examples/widget.html +703 -0
  249. package/jsdoc.json +26 -0
  250. package/package.json +16 -3
  251. package/src/ai/aggregation.js +13 -2
  252. package/src/ai/breakdown.js +12 -2
  253. package/src/ai/classifier.js +14 -3
  254. package/src/ai/council.js +22 -7
  255. package/src/ai/embeddings.js +37 -15
  256. package/src/ai/federation-ai.js +13 -2
  257. package/src/ai/h3-ai.js +14 -2
  258. package/src/ai/index.js +16 -7
  259. package/src/ai/json-ops.js +18 -5
  260. package/src/ai/llm-service.js +62 -31
  261. package/src/ai/nl-query.js +12 -2
  262. package/src/ai/relationships.js +13 -2
  263. package/src/ai/schema-extractor.js +24 -10
  264. package/src/ai/spatial.js +13 -2
  265. package/src/ai/tts.js +25 -8
  266. package/src/cdn-entry.js +22 -0
  267. package/src/content/social-protocols.js +34 -25
  268. package/src/contracts/chain-manager.js +68 -40
  269. package/src/contracts/deployer.js +70 -42
  270. package/src/contracts/event-listener.js +61 -29
  271. package/src/contracts/holon-contracts.js +46 -31
  272. package/src/contracts/index.js +5 -6
  273. package/src/contracts/networks.js +19 -14
  274. package/src/contracts/operations.js +58 -41
  275. package/src/contracts/queries.js +70 -21
  276. package/src/core/holosphere.js +37 -8
  277. package/src/crypto/nostr-utils.js +105 -65
  278. package/src/crypto/secp256k1.js +7 -2
  279. package/src/federation/handshake.js +23 -11
  280. package/src/federation/hologram.js +9 -1
  281. package/src/hierarchical/upcast.js +34 -20
  282. package/src/index.js +671 -7
  283. package/src/lib/ai-methods.js +352 -3
  284. package/src/lib/contract-methods.js +152 -3
  285. package/src/lib/errors.js +31 -1
  286. package/src/lib/federation-methods.js +110 -3
  287. package/src/lib/index.js +9 -5
  288. package/src/schema/validator.js +22 -3
  289. package/src/spatial/h3-operations.js +17 -1
  290. package/src/storage/backend-factory.js +7 -2
  291. package/src/storage/backend-interface.js +21 -2
  292. package/src/storage/backends/activitypub/server.js +25 -3
  293. package/src/storage/backends/activitypub-backend.js +25 -2
  294. package/src/storage/backends/gundb-backend.js +322 -11
  295. package/src/storage/backends/nostr-backend.js +116 -1
  296. package/src/storage/filesystem-storage-browser.js +42 -2
  297. package/src/storage/filesystem-storage.js +72 -5
  298. package/src/storage/global-tables.js +7 -2
  299. package/src/storage/gun-async.js +20 -11
  300. package/src/storage/gun-auth.js +15 -4
  301. package/src/storage/gun-federation.js +14 -5
  302. package/src/storage/gun-references.js +16 -5
  303. package/src/storage/gun-schema.js +25 -10
  304. package/src/storage/gun-wrapper.js +160 -49
  305. package/src/storage/indexeddb-storage.js +65 -4
  306. package/src/storage/key-storage-simple.js +32 -9
  307. package/src/storage/key-storage.js +45 -13
  308. package/src/storage/memory-storage.js +65 -4
  309. package/src/storage/migration.js +20 -7
  310. package/src/storage/nostr-async.js +195 -90
  311. package/src/storage/nostr-client.js +173 -49
  312. package/src/storage/nostr-wrapper.js +6 -2
  313. package/src/storage/outbox-queue.js +55 -18
  314. package/src/storage/persistent-storage.js +56 -13
  315. package/src/storage/sync-service.js +51 -17
  316. package/src/storage/unified-storage.js +38 -3
  317. package/src/subscriptions/manager.js +33 -16
  318. package/vite.config.cdn.js +60 -0
  319. package/dist/index-Bvwyvd0T.cjs +0 -5
  320. package/dist/index-Bvwyvd0T.cjs.map +0 -1
  321. package/dist/index-d6f4RJBM.js.map +0 -1
  322. package/dist/indexeddb-storage-D8kOl0oK.js.map +0 -1
  323. package/dist/indexeddb-storage-a8GipaDr.cjs.map +0 -1
  324. package/dist/memory-storage-DBQK622V.js.map +0 -1
  325. package/dist/memory-storage-gfRovk2O.cjs.map +0 -1
  326. /package/{cleanup-test-data.js → scripts/cleanup-test-data.js} +0 -0
  327. /package/{test-ai-real-api.js → scripts/test-ai-real-api.js} +0 -0
@@ -0,0 +1,672 @@
1
+ /* eslint no-var: off */
2
+ var defaultOptions = {
3
+ ignoreSelector: '.js-toc-ignore',
4
+ linkClass: 'toc-link',
5
+ extraLinkClasses: '',
6
+ activeLinkClass: 'is-active-link',
7
+ listClass: 'toc-list',
8
+ extraListClasses: '',
9
+ isCollapsedClass: 'is-collapsed',
10
+ collapsibleClass: 'is-collapsible',
11
+ listItemClass: 'toc-list-item',
12
+ activeListItemClass: 'is-active-li',
13
+ collapseDepth: 0,
14
+ scrollSmooth: true,
15
+ scrollSmoothDuration: 420,
16
+ scrollSmoothOffset: 0,
17
+ scrollEndCallback: function (e) { },
18
+ throttleTimeout: 50,
19
+ positionFixedSelector: null,
20
+ positionFixedClass: 'is-position-fixed',
21
+ fixedSidebarOffset: 'auto',
22
+ includeHtml: false,
23
+ includeTitleTags: false,
24
+ orderedList: true,
25
+ scrollContainer: null,
26
+ skipRendering: false,
27
+ headingLabelCallback: false,
28
+ ignoreHiddenElements: false,
29
+ headingObjectCallback: null,
30
+ basePath: '',
31
+ disableTocScrollSync: false
32
+ }
33
+
34
+ function ParseContent(options) {
35
+ var reduce = [].reduce
36
+
37
+ /**
38
+ * Get the last item in an array and return a reference to it.
39
+ * @param {Array} array
40
+ * @return {Object}
41
+ */
42
+ function getLastItem(array) {
43
+ return array[array.length - 1]
44
+ }
45
+
46
+ /**
47
+ * Get heading level for a heading dom node.
48
+ * @param {HTMLElement} heading
49
+ * @return {Number}
50
+ */
51
+ function getHeadingLevel(heading) {
52
+ return +heading.nodeName.toUpperCase().replace('H', '')
53
+ }
54
+
55
+ /**
56
+ * Get important properties from a heading element and store in a plain object.
57
+ * @param {HTMLElement} heading
58
+ * @return {Object}
59
+ */
60
+ function getHeadingObject(heading) {
61
+ // each node is processed twice by this method because nestHeadingsArray() and addNode() calls it
62
+ // first time heading is real DOM node element, second time it is obj
63
+ // that is causing problem so I am processing only original DOM node
64
+ if (!(heading instanceof window.HTMLElement)) return heading
65
+
66
+ if (options.ignoreHiddenElements && (!heading.offsetHeight || !heading.offsetParent)) {
67
+ return null
68
+ }
69
+
70
+ const headingLabel = heading.getAttribute('data-heading-label') ||
71
+ (options.headingLabelCallback ? String(options.headingLabelCallback(heading.textContent)) : heading.textContent.trim())
72
+ var obj = {
73
+ id: heading.id,
74
+ children: [],
75
+ nodeName: heading.nodeName,
76
+ headingLevel: getHeadingLevel(heading),
77
+ textContent: headingLabel
78
+ }
79
+
80
+ if (options.includeHtml) {
81
+ obj.childNodes = heading.childNodes
82
+ }
83
+
84
+ if (options.headingObjectCallback) {
85
+ return options.headingObjectCallback(obj, heading)
86
+ }
87
+
88
+ return obj
89
+ }
90
+
91
+ /**
92
+ * Add a node to the nested array.
93
+ * @param {Object} node
94
+ * @param {Array} nest
95
+ * @return {Array}
96
+ */
97
+ function addNode(node, nest) {
98
+ var obj = getHeadingObject(node)
99
+ var level = obj.headingLevel
100
+ var array = nest
101
+ var lastItem = getLastItem(array)
102
+ var lastItemLevel = lastItem
103
+ ? lastItem.headingLevel
104
+ : 0
105
+ var counter = level - lastItemLevel
106
+
107
+ while (counter > 0) {
108
+ lastItem = getLastItem(array)
109
+ // Handle case where there are multiple h5+ in a row.
110
+ if (lastItem && level === lastItem.headingLevel) {
111
+ break
112
+ } else if (lastItem && lastItem.children !== undefined) {
113
+ array = lastItem.children
114
+ }
115
+ counter--
116
+ }
117
+
118
+ if (level >= options.collapseDepth) {
119
+ obj.isCollapsed = true
120
+ }
121
+
122
+ array.push(obj)
123
+ return array
124
+ }
125
+
126
+ /**
127
+ * Select headings in content area, exclude any selector in options.ignoreSelector
128
+ * @param {HTMLElement} contentElement
129
+ * @param {Array} headingSelector
130
+ * @return {Array}
131
+ */
132
+ function selectHeadings(contentElement, headingSelector) {
133
+ var selectors = headingSelector
134
+ if (options.ignoreSelector) {
135
+ selectors = headingSelector.split(',')
136
+ .map(function mapSelectors(selector) {
137
+ return selector.trim() + ':not(' + options.ignoreSelector + ')'
138
+ })
139
+ }
140
+ try {
141
+ return contentElement.querySelectorAll(selectors)
142
+ } catch (e) {
143
+ console.warn('Headers not found with selector: ' + selectors); // eslint-disable-line
144
+ return null
145
+ }
146
+ }
147
+
148
+ /**
149
+ * Nest headings array into nested arrays with 'children' property.
150
+ * @param {Array} headingsArray
151
+ * @return {Object}
152
+ */
153
+ function nestHeadingsArray(headingsArray) {
154
+ return reduce.call(headingsArray, function reducer(prev, curr) {
155
+ var currentHeading = getHeadingObject(curr)
156
+ if (currentHeading) {
157
+ addNode(currentHeading, prev.nest)
158
+ }
159
+ return prev
160
+ }, {
161
+ nest: []
162
+ })
163
+ }
164
+
165
+ return {
166
+ nestHeadingsArray: nestHeadingsArray,
167
+ selectHeadings: selectHeadings
168
+ }
169
+ }
170
+
171
+ function BuildHtml(options) {
172
+ var forEach = [].forEach
173
+ var some = [].some
174
+ var body = document.body
175
+ var tocElement
176
+ var mainContainer = document.querySelector(options.contentSelector)
177
+ var currentlyHighlighting = true
178
+ var SPACE_CHAR = ' '
179
+
180
+ /**
181
+ * Create link and list elements.
182
+ * @param {Object} d
183
+ * @param {HTMLElement} container
184
+ * @return {HTMLElement}
185
+ */
186
+ function createEl(d, container) {
187
+ var link = container.appendChild(createLink(d))
188
+ if (d.children.length) {
189
+ var list = createList(d.isCollapsed)
190
+ d.children.forEach(function (child) {
191
+ createEl(child, list)
192
+ })
193
+ link.appendChild(list)
194
+ }
195
+ }
196
+
197
+ /**
198
+ * Render nested heading array data into a given element.
199
+ * @param {HTMLElement} parent Optional. If provided updates the {@see tocElement} to match.
200
+ * @param {Array} data
201
+ * @return {HTMLElement}
202
+ */
203
+ function render(parent, data) {
204
+ var collapsed = false
205
+ var container = createList(collapsed)
206
+
207
+ data.forEach(function (d) {
208
+ createEl(d, container)
209
+ })
210
+
211
+ // Return if no TOC element is provided or known.
212
+ tocElement = parent || tocElement
213
+ if (tocElement === null) {
214
+ return
215
+ }
216
+
217
+ // Remove existing child if it exists.
218
+ if (tocElement.firstChild) {
219
+ tocElement.removeChild(tocElement.firstChild)
220
+ }
221
+
222
+ // Just return the parent and don't append the list if no links are found.
223
+ if (data.length === 0) {
224
+ return tocElement
225
+ }
226
+
227
+ // Append the Elements that have been created
228
+ return tocElement.appendChild(container)
229
+ }
230
+
231
+ /**
232
+ * Create link element.
233
+ * @param {Object} data
234
+ * @return {HTMLElement}
235
+ */
236
+ function createLink(data) {
237
+ var item = document.createElement('li')
238
+ var a = document.createElement('a')
239
+ if (options.listItemClass) {
240
+ item.setAttribute('class', options.listItemClass)
241
+ }
242
+
243
+ if (options.onClick) {
244
+ a.onclick = options.onClick
245
+ }
246
+
247
+ if (options.includeTitleTags) {
248
+ a.setAttribute('title', data.textContent)
249
+ }
250
+
251
+ if (options.includeHtml && data.childNodes.length) {
252
+ forEach.call(data.childNodes, function (node) {
253
+ a.appendChild(node.cloneNode(true))
254
+ })
255
+ } else {
256
+ // Default behavior.
257
+ a.textContent = data.textContent
258
+ }
259
+ a.setAttribute('href', options.basePath + '#' + data.id)
260
+ a.setAttribute('class', options.linkClass +
261
+ SPACE_CHAR + 'node-name--' + data.nodeName +
262
+ SPACE_CHAR + options.extraLinkClasses)
263
+ item.appendChild(a)
264
+ return item
265
+ }
266
+
267
+ /**
268
+ * Create list element.
269
+ * @param {Boolean} isCollapsed
270
+ * @return {HTMLElement}
271
+ */
272
+ function createList(isCollapsed) {
273
+ var listElement = (options.orderedList) ? 'ol' : 'ul'
274
+ var list = document.createElement(listElement)
275
+ var classes = options.listClass +
276
+ SPACE_CHAR + options.extraListClasses
277
+ if (isCollapsed) {
278
+ classes += SPACE_CHAR + options.collapsibleClass
279
+ classes += SPACE_CHAR + options.isCollapsedClass
280
+ }
281
+ list.setAttribute('class', classes)
282
+ return list
283
+ }
284
+
285
+ /**
286
+ * Update fixed sidebar class.
287
+ * @return {HTMLElement}
288
+ */
289
+ function updateFixedSidebarClass() {
290
+ if (options.scrollContainer && document.querySelector(options.scrollContainer)) {
291
+ var top
292
+ top = document.querySelector(options.scrollContainer).scrollTop
293
+ } else {
294
+ top = document.documentElement.scrollTop || body.scrollTop
295
+ }
296
+ var posFixedEl = document.querySelector(options.positionFixedSelector)
297
+
298
+ if (options.fixedSidebarOffset === 'auto') {
299
+ options.fixedSidebarOffset = tocElement.offsetTop
300
+ }
301
+
302
+ if (top > options.fixedSidebarOffset) {
303
+ if (posFixedEl.className.indexOf(options.positionFixedClass) === -1) {
304
+ posFixedEl.className += SPACE_CHAR + options.positionFixedClass
305
+ }
306
+ } else {
307
+ posFixedEl.className = posFixedEl.className.split(SPACE_CHAR + options.positionFixedClass).join('')
308
+ }
309
+ }
310
+
311
+ /**
312
+ * Get top position of heading
313
+ * @param {HTMLElement} obj
314
+ * @return {int} position
315
+ */
316
+ function getHeadingTopPos(obj) {
317
+ var position = 0
318
+ if (obj !== null) {
319
+ position = obj.offsetTop
320
+ if (options.hasInnerContainers) { position += getHeadingTopPos(obj.offsetParent) }
321
+ }
322
+ return position
323
+ }
324
+
325
+
326
+ function updateListActiveElement(topHeader) {
327
+ var forEach = [].forEach
328
+
329
+ var tocLinks = tocElement
330
+ .querySelectorAll('.' + options.linkClass)
331
+ forEach.call(tocLinks, function (tocLink) {
332
+ tocLink.className = tocLink.className.split(SPACE_CHAR + options.activeLinkClass).join('')
333
+ })
334
+ var tocLis = tocElement
335
+ .querySelectorAll('.' + options.listItemClass)
336
+ forEach.call(tocLis, function (tocLi) {
337
+ tocLi.className = tocLi.className.split(SPACE_CHAR + options.activeListItemClass).join('')
338
+ })
339
+
340
+ // Add the active class to the active tocLink.
341
+ var activeTocLink = tocElement
342
+ .querySelector('.' + options.linkClass +
343
+ '.node-name--' + topHeader.nodeName +
344
+ '[href="' + options.basePath + '#' + topHeader.id.replace(/([ #;&,.+*~':"!^$[\]()=>|/@])/g, '\\$1') + '"]')
345
+ if (activeTocLink && activeTocLink.className.indexOf(options.activeLinkClass) === -1) {
346
+ activeTocLink.className += SPACE_CHAR + options.activeLinkClass
347
+ }
348
+ var li = activeTocLink && activeTocLink.parentNode
349
+ if (li && li.className.indexOf(options.activeListItemClass) === -1) {
350
+ li.className += SPACE_CHAR + options.activeListItemClass
351
+ }
352
+
353
+ var tocLists = tocElement
354
+ .querySelectorAll('.' + options.listClass + '.' + options.collapsibleClass)
355
+
356
+ // Collapse the other collapsible lists.
357
+ forEach.call(tocLists, function (list) {
358
+ if (list.className.indexOf(options.isCollapsedClass) === -1) {
359
+ list.className += SPACE_CHAR + options.isCollapsedClass
360
+ }
361
+ })
362
+
363
+ // Expand the active link's collapsible list and its sibling if applicable.
364
+ if (activeTocLink && activeTocLink.nextSibling && activeTocLink.nextSibling.className.indexOf(options.isCollapsedClass) !== -1) {
365
+ activeTocLink.nextSibling.className = activeTocLink.nextSibling.className.split(SPACE_CHAR + options.isCollapsedClass).join('')
366
+ }
367
+ removeCollapsedFromParents(activeTocLink && activeTocLink.parentNode.parentNode)
368
+ }
369
+
370
+ /**
371
+ * Update TOC highlighting and collpased groupings.
372
+ */
373
+ function updateToc(headingsArray) {
374
+ // If a fixed content container was set
375
+ if (options.scrollContainer && document.querySelector(options.scrollContainer)) {
376
+ var top
377
+ top = document.querySelector(options.scrollContainer).scrollTop
378
+ } else {
379
+ top = document.documentElement.scrollTop || body.scrollTop
380
+ }
381
+
382
+ // Add fixed class at offset
383
+ if (options.positionFixedSelector) {
384
+ updateFixedSidebarClass()
385
+ }
386
+
387
+ // Get the top most heading currently visible on the page so we know what to highlight.
388
+ var headings = headingsArray
389
+ var topHeader
390
+ // Using some instead of each so that we can escape early.
391
+ if (currentlyHighlighting &&
392
+ tocElement !== null &&
393
+ headings.length > 0) {
394
+ some.call(headings, function (heading, i) {
395
+ var modifiedTopOffset = top + 10
396
+ if (mainContainer) {
397
+ modifiedTopOffset += mainContainer.clientHeight * (mainContainer.scrollTop) / (mainContainer.scrollHeight - mainContainer.clientHeight)
398
+ }
399
+ if (getHeadingTopPos(heading) > modifiedTopOffset) {
400
+ // Don't allow negative index value.
401
+ var index = (i === 0) ? i : i - 1
402
+ topHeader = headings[index]
403
+ return true
404
+ } else if (i === headings.length - 1) {
405
+ // This allows scrolling for the last heading on the page.
406
+ topHeader = headings[headings.length - 1]
407
+ return true
408
+ }
409
+ })
410
+
411
+ // Remove the active class from the other tocLinks.
412
+ updateListActiveElement(topHeader)
413
+ }
414
+ }
415
+
416
+ /**
417
+ * Remove collpased class from parent elements.
418
+ * @param {HTMLElement} element
419
+ * @return {HTMLElement}
420
+ */
421
+ function removeCollapsedFromParents(element) {
422
+ if (element && element.className.indexOf(options.collapsibleClass) !== -1 && element.className.indexOf(options.isCollapsedClass) !== -1) {
423
+ element.className = element.className.split(SPACE_CHAR + options.isCollapsedClass).join('')
424
+ return removeCollapsedFromParents(element.parentNode.parentNode)
425
+ }
426
+ return element
427
+ }
428
+
429
+ /**
430
+ * Disable TOC Animation when a link is clicked.
431
+ * @param {Event} event
432
+ */
433
+ function disableTocAnimation(event) {
434
+ var target = event.target || event.srcElement
435
+ if (typeof target.className !== 'string' || target.className.indexOf(options.linkClass) === -1) {
436
+ return
437
+ }
438
+ // Bind to tocLink clicks to temporarily disable highlighting
439
+ // while smoothScroll is animating.
440
+ currentlyHighlighting = false
441
+ }
442
+
443
+ /**
444
+ * Enable TOC Animation.
445
+ */
446
+ function enableTocAnimation() {
447
+ currentlyHighlighting = true
448
+ }
449
+
450
+ return {
451
+ enableTocAnimation: enableTocAnimation,
452
+ disableTocAnimation: disableTocAnimation,
453
+ render: render,
454
+ updateToc: updateToc,
455
+ updateListActiveElement: updateListActiveElement
456
+ }
457
+ }
458
+
459
+ function updateTocScroll(options) {
460
+ var toc = options.tocElement || document.querySelector(options.tocSelector)
461
+ if (toc && toc.scrollHeight > toc.clientHeight) {
462
+ var activeItem = toc.querySelector('.' + options.activeListItemClass)
463
+ if (activeItem) {
464
+ var topOffset = toc.getBoundingClientRect().top
465
+ toc.scrollTop = activeItem.offsetTop - topOffset
466
+ }
467
+ }
468
+ }
469
+
470
+ (function (root, factory) {
471
+ if (typeof define === 'function' && define.amd) {
472
+ define([], factory(root))
473
+ } else if (typeof exports === 'object') {
474
+ module.exports = factory(root)
475
+ } else {
476
+ root.tocbot = factory(root)
477
+ }
478
+ })(typeof global !== 'undefined' ? global : this.window || this.global, function (root) {
479
+ 'use strict'
480
+
481
+ var options = {}
482
+ var tocbot = {}
483
+ var buildHtml
484
+ var parseContent
485
+
486
+ // Just return if its not a browser.
487
+ var supports = !!root && !!root.document && !!root.document.querySelector && !!root.addEventListener // Feature test
488
+ if (typeof window === 'undefined' && !supports) {
489
+ return
490
+ }
491
+ var headingsArray
492
+
493
+ // From: https://github.com/Raynos/xtend
494
+ var hasOwnProperty = Object.prototype.hasOwnProperty
495
+ function extend() {
496
+ var target = {}
497
+ for (var i = 0; i < arguments.length; i++) {
498
+ var source = arguments[i]
499
+ for (var key in source) {
500
+ if (hasOwnProperty.call(source, key)) {
501
+ target[key] = source[key]
502
+ }
503
+ }
504
+ }
505
+ return target
506
+ }
507
+
508
+ // From: https://remysharp.com/2010/07/21/throttling-function-calls
509
+ function throttle(fn, threshhold, scope) {
510
+ threshhold || (threshhold = 250)
511
+ var last
512
+ var deferTimer
513
+ return function () {
514
+ var context = scope || this
515
+ var now = +new Date()
516
+ var args = arguments
517
+ if (last && now < last + threshhold) {
518
+ // hold on to it
519
+ clearTimeout(deferTimer)
520
+ deferTimer = setTimeout(function () {
521
+ last = now
522
+ fn.apply(context, args)
523
+ }, threshhold)
524
+ } else {
525
+ last = now
526
+ fn.apply(context, args)
527
+ }
528
+ }
529
+ }
530
+
531
+ function getContentElement(options) {
532
+ try {
533
+ return options.contentElement || document.querySelector(options.contentSelector)
534
+ } catch (e) {
535
+ console.warn('Contents element not found: ' + options.contentSelector) // eslint-disable-line
536
+ return null
537
+ }
538
+ }
539
+
540
+ function getTocElement(options) {
541
+ try {
542
+ return options.tocElement || document.querySelector(options.tocSelector)
543
+ } catch (e) {
544
+ console.warn('TOC element not found: ' + options.tocSelector) // eslint-disable-line
545
+ return null
546
+ }
547
+ }
548
+
549
+ /**
550
+ * Destroy tocbot.
551
+ */
552
+ tocbot.destroy = function () {
553
+ var tocElement = getTocElement(options)
554
+ if (tocElement === null) {
555
+ return
556
+ }
557
+
558
+ if (!options.skipRendering) {
559
+ // Clear HTML.
560
+ if (tocElement) {
561
+ tocElement.innerHTML = ''
562
+ }
563
+ }
564
+
565
+ // Remove event listeners.
566
+ if (options.scrollContainer && document.querySelector(options.scrollContainer)) {
567
+ document.querySelector(options.scrollContainer).removeEventListener('scroll', this._scrollListener, false)
568
+ document.querySelector(options.scrollContainer).removeEventListener('resize', this._scrollListener, false)
569
+ } else {
570
+ document.removeEventListener('scroll', this._scrollListener, false)
571
+ document.removeEventListener('resize', this._scrollListener, false)
572
+ }
573
+ }
574
+
575
+ /**
576
+ * Initialize tocbot.
577
+ * @param {object} customOptions
578
+ */
579
+ tocbot.init = function (customOptions) {
580
+ // feature test
581
+ if (!supports) {
582
+ return
583
+ }
584
+
585
+ // Merge defaults with user options.
586
+ // Set to options variable at the top.
587
+ options = extend(defaultOptions, customOptions || {})
588
+ this.options = options
589
+ this.state = {}
590
+
591
+ // Init smooth scroll if enabled (default).
592
+ if (options.scrollSmooth) {
593
+ options.duration = options.scrollSmoothDuration
594
+ options.offset = options.scrollSmoothOffset
595
+ }
596
+
597
+ // Pass options to these modules.
598
+ buildHtml = BuildHtml(options)
599
+ parseContent = ParseContent(options)
600
+
601
+ // For testing purposes.
602
+ this._buildHtml = buildHtml
603
+ this._parseContent = parseContent
604
+ this._headingsArray = headingsArray
605
+ this.updateTocListActiveElement = buildHtml.updateListActiveElement
606
+
607
+ // Destroy it if it exists first.
608
+ tocbot.destroy()
609
+
610
+ var contentElement = getContentElement(options)
611
+ if (contentElement === null) {
612
+ return
613
+ }
614
+
615
+ var tocElement = getTocElement(options)
616
+ if (tocElement === null) {
617
+ return
618
+ }
619
+
620
+ // Get headings array.
621
+ headingsArray = parseContent.selectHeadings(contentElement, options.headingSelector)
622
+ // Return if no headings are found.
623
+ if (headingsArray === null) {
624
+ return
625
+ }
626
+
627
+ // Build nested headings array.
628
+ var nestedHeadingsObj = parseContent.nestHeadingsArray(headingsArray)
629
+ var nestedHeadings = nestedHeadingsObj.nest
630
+
631
+ // Render.
632
+ if (!options.skipRendering) {
633
+ buildHtml.render(tocElement, nestedHeadings)
634
+ }
635
+
636
+ // Update Sidebar and bind listeners.
637
+ this._scrollListener = throttle(function (e) {
638
+ buildHtml.updateToc(headingsArray)
639
+ !options.disableTocScrollSync && updateTocScroll(options)
640
+ var isTop = e && e.target && e.target.scrollingElement && e.target.scrollingElement.scrollTop === 0
641
+ if ((e && (e.eventPhase === 0 || e.currentTarget === null)) || isTop) {
642
+ buildHtml.updateToc(headingsArray)
643
+ if (options.scrollEndCallback) {
644
+ options.scrollEndCallback(e)
645
+ }
646
+ }
647
+ }, options.throttleTimeout)
648
+ this._scrollListener()
649
+ if (options.scrollContainer && document.querySelector(options.scrollContainer)) {
650
+ document.querySelector(options.scrollContainer).addEventListener('scroll', this._scrollListener, false)
651
+ document.querySelector(options.scrollContainer).addEventListener('resize', this._scrollListener, false)
652
+ } else {
653
+ document.addEventListener('scroll', this._scrollListener, false)
654
+ document.addEventListener('resize', this._scrollListener, false)
655
+ }
656
+
657
+ return this
658
+ }
659
+
660
+ /**
661
+ * Refresh tocbot.
662
+ */
663
+ tocbot.refresh = function (customOptions) {
664
+ tocbot.destroy()
665
+ tocbot.init(customOptions || this.options)
666
+ }
667
+
668
+ // Make tocbot available globally.
669
+ root.tocbot = tocbot
670
+
671
+ return tocbot
672
+ })
@@ -0,0 +1 @@
1
+ var defaultOptions={ignoreSelector:".js-toc-ignore",linkClass:"toc-link",extraLinkClasses:"",activeLinkClass:"is-active-link",listClass:"toc-list",extraListClasses:"",isCollapsedClass:"is-collapsed",collapsibleClass:"is-collapsible",listItemClass:"toc-list-item",activeListItemClass:"is-active-li",collapseDepth:0,scrollSmooth:!0,scrollSmoothDuration:420,scrollSmoothOffset:0,scrollEndCallback:function(e){},throttleTimeout:50,positionFixedSelector:null,positionFixedClass:"is-position-fixed",fixedSidebarOffset:"auto",includeHtml:!1,includeTitleTags:!1,orderedList:!0,scrollContainer:null,skipRendering:!1,headingLabelCallback:!1,ignoreHiddenElements:!1,headingObjectCallback:null,basePath:"",disableTocScrollSync:!1};function ParseContent(r){var t=[].reduce;function a(e){return e[e.length-1]}function c(e){if(!(e instanceof window.HTMLElement))return e;if(r.ignoreHiddenElements&&(!e.offsetHeight||!e.offsetParent))return null;var t=e.getAttribute("data-heading-label")||(r.headingLabelCallback?String(r.headingLabelCallback(e.textContent)):e.textContent.trim()),t={id:e.id,children:[],nodeName:e.nodeName,headingLevel:+e.nodeName.toUpperCase().replace("H",""),textContent:t};return r.includeHtml&&(t.childNodes=e.childNodes),r.headingObjectCallback?r.headingObjectCallback(t,e):t}return{nestHeadingsArray:function(e){return t.call(e,function(e,t){t=c(t);if(t){for(var l=e.nest,n=(t=c(t)).headingLevel,o=l,s=a(o),i=n-(s?s.headingLevel:0);0<i&&(!(s=a(o))||n!==s.headingLevel);)s&&void 0!==s.children&&(o=s.children),i--;n>=r.collapseDepth&&(t.isCollapsed=!0),o.push(t)}return e},{nest:[]})},selectHeadings:function(e,t){var l=t;r.ignoreSelector&&(l=t.split(",").map(function(e){return e.trim()+":not("+r.ignoreSelector+")"}));try{return e.querySelectorAll(l)}catch(e){return console.warn("Headers not found with selector: "+l),null}}}}function BuildHtml(i){var r,n=[].forEach,a=[].some,c=document.body,d=document.querySelector(i.contentSelector),u=!0,m=" ";function o(e,t){var l,t=t.appendChild(function(e){var t=document.createElement("li"),l=document.createElement("a");i.listItemClass&&t.setAttribute("class",i.listItemClass);i.onClick&&(l.onclick=i.onClick);i.includeTitleTags&&l.setAttribute("title",e.textContent);i.includeHtml&&e.childNodes.length?n.call(e.childNodes,function(e){l.appendChild(e.cloneNode(!0))}):l.textContent=e.textContent;return l.setAttribute("href",i.basePath+"#"+e.id),l.setAttribute("class",i.linkClass+m+"node-name--"+e.nodeName+m+i.extraLinkClasses),t.appendChild(l),t}(e));e.children.length&&(l=s(e.isCollapsed),e.children.forEach(function(e){o(e,l)}),t.appendChild(l))}function s(e){var t=i.orderedList?"ol":"ul",t=document.createElement(t),l=i.listClass+m+i.extraListClasses;return e&&(l=(l+=m+i.collapsibleClass)+(m+i.isCollapsedClass)),t.setAttribute("class",l),t}function f(e){var t=[].forEach,l=r.querySelectorAll("."+i.linkClass),l=(t.call(l,function(e){e.className=e.className.split(m+i.activeLinkClass).join("")}),r.querySelectorAll("."+i.listItemClass)),l=(t.call(l,function(e){e.className=e.className.split(m+i.activeListItemClass).join("")}),r.querySelector("."+i.linkClass+".node-name--"+e.nodeName+'[href="'+i.basePath+"#"+e.id.replace(/([ #;&,.+*~':"!^$[\]()=>|/@])/g,"\\$1")+'"]')),e=(l&&-1===l.className.indexOf(i.activeLinkClass)&&(l.className+=m+i.activeLinkClass),l&&l.parentNode),e=(e&&-1===e.className.indexOf(i.activeListItemClass)&&(e.className+=m+i.activeListItemClass),r.querySelectorAll("."+i.listClass+"."+i.collapsibleClass));t.call(e,function(e){-1===e.className.indexOf(i.isCollapsedClass)&&(e.className+=m+i.isCollapsedClass)}),l&&l.nextSibling&&-1!==l.nextSibling.className.indexOf(i.isCollapsedClass)&&(l.nextSibling.className=l.nextSibling.className.split(m+i.isCollapsedClass).join("")),function e(t){if(t&&-1!==t.className.indexOf(i.collapsibleClass)&&-1!==t.className.indexOf(i.isCollapsedClass))return t.className=t.className.split(m+i.isCollapsedClass).join(""),e(t.parentNode.parentNode);return t}(l&&l.parentNode.parentNode)}return{enableTocAnimation:function(){u=!0},disableTocAnimation:function(e){"string"==typeof(e=e.target||e.srcElement).className&&-1!==e.className.indexOf(i.linkClass)&&(u=!1)},render:function(e,t){var l=s(!1);if(t.forEach(function(e){o(e,l)}),null!==(r=e||r))return r.firstChild&&r.removeChild(r.firstChild),0===t.length?r:r.appendChild(l)},updateToc:function(e){n=i.scrollContainer&&document.querySelector(i.scrollContainer)?document.querySelector(i.scrollContainer).scrollTop:document.documentElement.scrollTop||c.scrollTop,i.positionFixedSelector&&(t=i.scrollContainer&&document.querySelector(i.scrollContainer)?document.querySelector(i.scrollContainer).scrollTop:document.documentElement.scrollTop||c.scrollTop,l=document.querySelector(i.positionFixedSelector),"auto"===i.fixedSidebarOffset&&(i.fixedSidebarOffset=r.offsetTop),t>i.fixedSidebarOffset?-1===l.className.indexOf(i.positionFixedClass)&&(l.className+=m+i.positionFixedClass):l.className=l.className.split(m+i.positionFixedClass).join(""));var n,t,l,o,s=e;u&&null!==r&&0<s.length&&(a.call(s,function(e,t){var l=n+10;return d&&(l+=d.clientHeight*d.scrollTop/(d.scrollHeight-d.clientHeight)),function e(t){var l=0;return null!==t&&(l=t.offsetTop,i.hasInnerContainers&&(l+=e(t.offsetParent))),l}(e)>l?(o=s[0===t?t:t-1],!0):t===s.length-1?(o=s[s.length-1],!0):void 0}),f(o))},updateListActiveElement:f}}function updateTocScroll(e){var t,l=e.tocElement||document.querySelector(e.tocSelector);l&&l.scrollHeight>l.clientHeight&&((e=l.querySelector("."+e.activeListItemClass))&&(t=l.getBoundingClientRect().top,l.scrollTop=e.offsetTop-t))}!function(e,t){"function"==typeof define&&define.amd?define([],t(e)):"object"==typeof exports?module.exports=t(e):e.tocbot=t(e)}("undefined"!=typeof global?global:this.window||this.global,function(e){"use strict";var l,a,c,d,u={},m={},f=!!(e&&e.document&&e.document.querySelector&&e.addEventListener);if("undefined"!=typeof window||f)return d=Object.prototype.hasOwnProperty,m.destroy=function(){var e=C(u);null!==e&&(u.skipRendering||e&&(e.innerHTML=""),u.scrollContainer&&document.querySelector(u.scrollContainer)?(document.querySelector(u.scrollContainer).removeEventListener("scroll",this._scrollListener,!1),document.querySelector(u.scrollContainer).removeEventListener("resize",this._scrollListener,!1)):(document.removeEventListener("scroll",this._scrollListener,!1),document.removeEventListener("resize",this._scrollListener,!1)))},m.init=function(e){if(f){u=function(){for(var e={},t=0;t<arguments.length;t++){var l,n=arguments[t];for(l in n)d.call(n,l)&&(e[l]=n[l])}return e}(defaultOptions,e||{}),this.options=u,this.state={},u.scrollSmooth&&(u.duration=u.scrollSmoothDuration,u.offset=u.scrollSmoothOffset),l=BuildHtml(u),a=ParseContent(u),this._buildHtml=l,this._parseContent=a,this._headingsArray=c,this.updateTocListActiveElement=l.updateListActiveElement,m.destroy();e=function(t){try{return t.contentElement||document.querySelector(t.contentSelector)}catch(e){return console.warn("Contents element not found: "+t.contentSelector),null}}(u);if(null!==e){var n,o,s,i,r,t=C(u);if(null!==t)if(null!==(c=a.selectHeadings(e,u.headingSelector)))return e=a.nestHeadingsArray(c).nest,u.skipRendering||l.render(t,e),this._scrollListener=(n=function(e){l.updateToc(c),u.disableTocScrollSync||updateTocScroll(u);var t=e&&e.target&&e.target.scrollingElement&&0===e.target.scrollingElement.scrollTop;(e&&(0===e.eventPhase||null===e.currentTarget)||t)&&(l.updateToc(c),u.scrollEndCallback&&u.scrollEndCallback(e))},o=(o=u.throttleTimeout)||250,function(){var e=s||this,t=+new Date,l=arguments;i&&t<i+o?(clearTimeout(r),r=setTimeout(function(){i=t,n.apply(e,l)},o)):(i=t,n.apply(e,l))}),this._scrollListener(),u.scrollContainer&&document.querySelector(u.scrollContainer)?(document.querySelector(u.scrollContainer).addEventListener("scroll",this._scrollListener,!1),document.querySelector(u.scrollContainer).addEventListener("resize",this._scrollListener,!1)):(document.addEventListener("scroll",this._scrollListener,!1),document.addEventListener("resize",this._scrollListener,!1)),this}}},m.refresh=function(e){m.destroy(),m.init(e||this.options)},e.tocbot=m;function C(t){try{return t.tocElement||document.querySelector(t.tocSelector)}catch(e){return console.warn("TOC element not found: "+t.tocSelector),null}}});