@qualified-salesforce/web 0.0.1-oidc-bootstrap

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 (560) hide show
  1. package/41842993ec71d6628e4949e9a22b146b.svg +3 -0
  2. package/7271f3433ed82fc7f56adcd9e30275f4.svg +17 -0
  3. package/LICENSE.txt +82 -0
  4. package/components/helpers/entriesStringValidations.js +69 -0
  5. package/components/helpers/languages.js +32 -0
  6. package/components/shared/assertUnreachable.js +5 -0
  7. package/components/shared/controls/imageCropperHelpers.js +43 -0
  8. package/components/shared/meetingLoadingProgressSpec.js +116 -0
  9. package/constants.generated.js +9883 -0
  10. package/css/widget/multimodal_v2/host.split-css.css +162 -0
  11. package/css/widget/multimodal_v2/index.split-css.panda.css +5240 -0
  12. package/css/widget/widget.split-css.css +100 -0
  13. package/fonts/inter/Inter-Black.woff +0 -0
  14. package/fonts/inter/Inter-Black.woff2 +0 -0
  15. package/fonts/inter/Inter-BlackItalic.woff +0 -0
  16. package/fonts/inter/Inter-BlackItalic.woff2 +0 -0
  17. package/fonts/inter/Inter-Bold.woff +0 -0
  18. package/fonts/inter/Inter-Bold.woff2 +0 -0
  19. package/fonts/inter/Inter-BoldItalic.woff +0 -0
  20. package/fonts/inter/Inter-BoldItalic.woff2 +0 -0
  21. package/fonts/inter/Inter-ExtraBold.woff +0 -0
  22. package/fonts/inter/Inter-ExtraBold.woff2 +0 -0
  23. package/fonts/inter/Inter-ExtraBoldItalic.woff +0 -0
  24. package/fonts/inter/Inter-ExtraBoldItalic.woff2 +0 -0
  25. package/fonts/inter/Inter-ExtraLight.woff +0 -0
  26. package/fonts/inter/Inter-ExtraLight.woff2 +0 -0
  27. package/fonts/inter/Inter-ExtraLightItalic.woff +0 -0
  28. package/fonts/inter/Inter-ExtraLightItalic.woff2 +0 -0
  29. package/fonts/inter/Inter-Italic.woff +0 -0
  30. package/fonts/inter/Inter-Italic.woff2 +0 -0
  31. package/fonts/inter/Inter-Light.woff +0 -0
  32. package/fonts/inter/Inter-Light.woff2 +0 -0
  33. package/fonts/inter/Inter-LightItalic.woff +0 -0
  34. package/fonts/inter/Inter-LightItalic.woff2 +0 -0
  35. package/fonts/inter/Inter-Medium.woff +0 -0
  36. package/fonts/inter/Inter-Medium.woff2 +0 -0
  37. package/fonts/inter/Inter-MediumItalic.woff +0 -0
  38. package/fonts/inter/Inter-MediumItalic.woff2 +0 -0
  39. package/fonts/inter/Inter-Regular.woff +0 -0
  40. package/fonts/inter/Inter-Regular.woff2 +0 -0
  41. package/fonts/inter/Inter-SemiBold.woff +0 -0
  42. package/fonts/inter/Inter-SemiBold.woff2 +0 -0
  43. package/fonts/inter/Inter-SemiBoldItalic.woff +0 -0
  44. package/fonts/inter/Inter-SemiBoldItalic.woff2 +0 -0
  45. package/fonts/inter/Inter-Thin.woff +0 -0
  46. package/fonts/inter/Inter-Thin.woff2 +0 -0
  47. package/fonts/inter/Inter-ThinItalic.woff +0 -0
  48. package/fonts/inter/Inter-ThinItalic.woff2 +0 -0
  49. package/fonts/inter/Inter-italic.var.woff2 +0 -0
  50. package/fonts/inter/Inter-roman.var.woff2 +0 -0
  51. package/images/close.js +63 -0
  52. package/images/logo.js +22 -0
  53. package/js/4101.js +19721 -0
  54. package/js/daily-esm.js +9948 -0
  55. package/js/date-fns.js +427 -0
  56. package/js/multimodal_v2.js +1653 -0
  57. package/js/runtime.js +109 -0
  58. package/media/Inter-Black.796be8d8bf.woff2 +0 -0
  59. package/media/Inter-Black.b254104c56.woff +0 -0
  60. package/media/Inter-BlackItalic.70306b0eae.woff +0 -0
  61. package/media/Inter-BlackItalic.752f1e0aaa.woff2 +0 -0
  62. package/media/Inter-Bold.579e0f95ca.woff2 +0 -0
  63. package/media/Inter-Bold.b1234477a5.woff +0 -0
  64. package/media/Inter-BoldItalic.3d0d804323.woff +0 -0
  65. package/media/Inter-BoldItalic.828a494e04.woff2 +0 -0
  66. package/media/Inter-ExtraBold.208a9e6c99.woff +0 -0
  67. package/media/Inter-ExtraBold.d65f028165.woff2 +0 -0
  68. package/media/Inter-ExtraBoldItalic.30429962ec.woff +0 -0
  69. package/media/Inter-ExtraBoldItalic.8c7eac5ce3.woff2 +0 -0
  70. package/media/Inter-ExtraLight.15c082a57d.woff +0 -0
  71. package/media/Inter-ExtraLight.6824177d1e.woff2 +0 -0
  72. package/media/Inter-ExtraLightItalic.05138dddf3.woff2 +0 -0
  73. package/media/Inter-ExtraLightItalic.3beee54f59.woff +0 -0
  74. package/media/Inter-Italic.9beab78452.woff +0 -0
  75. package/media/Inter-Italic.d593a8df79.woff2 +0 -0
  76. package/media/Inter-Light.27083fa637.woff2 +0 -0
  77. package/media/Inter-Light.91dfddd842.woff +0 -0
  78. package/media/Inter-LightItalic.0a783b89b3.woff2 +0 -0
  79. package/media/Inter-LightItalic.f8ccf2813f.woff +0 -0
  80. package/media/Inter-Medium.dc792b508e.woff2 +0 -0
  81. package/media/Inter-Medium.ec7dd2d9d8.woff +0 -0
  82. package/media/Inter-MediumItalic.17301e5b40.woff +0 -0
  83. package/media/Inter-MediumItalic.84d3493a9f.woff2 +0 -0
  84. package/media/Inter-Regular.f1f0c35b32.woff2 +0 -0
  85. package/media/Inter-Regular.f356e84aa0.woff +0 -0
  86. package/media/Inter-SemiBold.55027e4724.woff +0 -0
  87. package/media/Inter-SemiBold.fcb100c760.woff2 +0 -0
  88. package/media/Inter-SemiBoldItalic.ab9105ed3b.woff +0 -0
  89. package/media/Inter-SemiBoldItalic.d90f295d0c.woff2 +0 -0
  90. package/media/Inter-Thin.16325d9b0f.woff +0 -0
  91. package/media/Inter-Thin.dafaa44d99.woff2 +0 -0
  92. package/media/Inter-ThinItalic.4fc662b3cf.woff2 +0 -0
  93. package/media/Inter-ThinItalic.d3d8994788.woff +0 -0
  94. package/media/Inter-italic.var.958a0b9742.woff2 +0 -0
  95. package/media/Inter-roman.var.b2129c009c.woff2 +0 -0
  96. package/package.json +20 -0
  97. package/packs/widget/api/docking/docking_host.js +97 -0
  98. package/packs/widget/api/docking/index.js +294 -0
  99. package/packs/widget/api/docking/shared.js +164 -0
  100. package/packs/widget/api/docking/viewport_lock.js +488 -0
  101. package/packs/widget/api/docking/viewport_resize.js +1203 -0
  102. package/packs/widget/esm/fonts/Inter-Black.796be8d8bf.woff2 +0 -0
  103. package/packs/widget/esm/fonts/Inter-Black.b254104c56.woff +0 -0
  104. package/packs/widget/esm/fonts/Inter-BlackItalic.70306b0eae.woff +0 -0
  105. package/packs/widget/esm/fonts/Inter-BlackItalic.752f1e0aaa.woff2 +0 -0
  106. package/packs/widget/esm/fonts/Inter-Bold.579e0f95ca.woff2 +0 -0
  107. package/packs/widget/esm/fonts/Inter-Bold.b1234477a5.woff +0 -0
  108. package/packs/widget/esm/fonts/Inter-BoldItalic.3d0d804323.woff +0 -0
  109. package/packs/widget/esm/fonts/Inter-BoldItalic.828a494e04.woff2 +0 -0
  110. package/packs/widget/esm/fonts/Inter-ExtraBold.208a9e6c99.woff +0 -0
  111. package/packs/widget/esm/fonts/Inter-ExtraBold.d65f028165.woff2 +0 -0
  112. package/packs/widget/esm/fonts/Inter-ExtraBoldItalic.30429962ec.woff +0 -0
  113. package/packs/widget/esm/fonts/Inter-ExtraBoldItalic.8c7eac5ce3.woff2 +0 -0
  114. package/packs/widget/esm/fonts/Inter-ExtraLight.15c082a57d.woff +0 -0
  115. package/packs/widget/esm/fonts/Inter-ExtraLight.6824177d1e.woff2 +0 -0
  116. package/packs/widget/esm/fonts/Inter-ExtraLightItalic.05138dddf3.woff2 +0 -0
  117. package/packs/widget/esm/fonts/Inter-ExtraLightItalic.3beee54f59.woff +0 -0
  118. package/packs/widget/esm/fonts/Inter-Italic.9beab78452.woff +0 -0
  119. package/packs/widget/esm/fonts/Inter-Italic.d593a8df79.woff2 +0 -0
  120. package/packs/widget/esm/fonts/Inter-Light.27083fa637.woff2 +0 -0
  121. package/packs/widget/esm/fonts/Inter-Light.91dfddd842.woff +0 -0
  122. package/packs/widget/esm/fonts/Inter-LightItalic.0a783b89b3.woff2 +0 -0
  123. package/packs/widget/esm/fonts/Inter-LightItalic.f8ccf2813f.woff +0 -0
  124. package/packs/widget/esm/fonts/Inter-Medium.dc792b508e.woff2 +0 -0
  125. package/packs/widget/esm/fonts/Inter-Medium.ec7dd2d9d8.woff +0 -0
  126. package/packs/widget/esm/fonts/Inter-MediumItalic.17301e5b40.woff +0 -0
  127. package/packs/widget/esm/fonts/Inter-MediumItalic.84d3493a9f.woff2 +0 -0
  128. package/packs/widget/esm/fonts/Inter-Regular.f1f0c35b32.woff2 +0 -0
  129. package/packs/widget/esm/fonts/Inter-Regular.f356e84aa0.woff +0 -0
  130. package/packs/widget/esm/fonts/Inter-SemiBold.55027e4724.woff +0 -0
  131. package/packs/widget/esm/fonts/Inter-SemiBold.fcb100c760.woff2 +0 -0
  132. package/packs/widget/esm/fonts/Inter-SemiBoldItalic.ab9105ed3b.woff +0 -0
  133. package/packs/widget/esm/fonts/Inter-SemiBoldItalic.d90f295d0c.woff2 +0 -0
  134. package/packs/widget/esm/fonts/Inter-Thin.16325d9b0f.woff +0 -0
  135. package/packs/widget/esm/fonts/Inter-Thin.dafaa44d99.woff2 +0 -0
  136. package/packs/widget/esm/fonts/Inter-ThinItalic.4fc662b3cf.woff2 +0 -0
  137. package/packs/widget/esm/fonts/Inter-ThinItalic.d3d8994788.woff +0 -0
  138. package/packs/widget/esm/fonts/Inter-italic.var.958a0b9742.woff2 +0 -0
  139. package/packs/widget/esm/fonts/Inter-roman.var.b2129c009c.woff2 +0 -0
  140. package/packs/widget/esm/index.js +183 -0
  141. package/packs/widget/esm/qualified.css +5502 -0
  142. package/routes/app/offers/scripts/OfferMainScript.js +154 -0
  143. package/routes/app/offers/scripts/constants.js +71 -0
  144. package/routes/app/offers/scripts/main/ButtonManager.js +65 -0
  145. package/routes/app/offers/scripts/main/FormManager.js +325 -0
  146. package/routes/app/offers/scripts/main/MainContext.js +19 -0
  147. package/routes/app/offers/scripts/main/OfferManager.js +91 -0
  148. package/routes/app/offers/scripts/main/TriggerManager.js +125 -0
  149. package/routes/app/offers/scripts/rendering/ContentManager.js +53 -0
  150. package/routes/app/offers/scripts/rendering/LocationManager.js +83 -0
  151. package/routes/app/offers/scripts/rendering/RenderedOffer.js +188 -0
  152. package/routes/app/offers/scripts/rendering/Renderer.js +69 -0
  153. package/routes/app/offers/scripts/rendering/RenderingInitializer.js +62 -0
  154. package/routes/app/offers/scripts/rendering/animations/AnimationManager.js +31 -0
  155. package/routes/app/offers/scripts/rendering/animations/AnimationManagerFooter.js +81 -0
  156. package/routes/app/offers/scripts/rendering/animations/AnimationManagerHeader.js +81 -0
  157. package/routes/app/offers/scripts/rendering/animations/AnimationManagerModal.js +117 -0
  158. package/routes/app/offers/scripts/rendering/animations/AnimationManagerSidebar.js +75 -0
  159. package/routes/app/offers/scripts/rendering/animations/AnimationResult.js +43 -0
  160. package/routes/app/offers/scripts/rendering/animations/Animator.js +78 -0
  161. package/routes/app/offers/scripts/rendering/animations/BaseAnimationManager.js +25 -0
  162. package/routes/app/offers/scripts/rendering/lib/BaseComponent.js +106 -0
  163. package/routes/app/offers/scripts/rendering/lib/FormComponent.js +134 -0
  164. package/routes/app/offers/scripts/rendering/lib/OfferComponent.js +144 -0
  165. package/routes/app/offers/scripts/rendering/lib/ScrollbarWidth.js +27 -0
  166. package/routes/app/offers/scripts/rendering/lib/decorators.js +20 -0
  167. package/routes/app/offers/scripts/rendering/locations/CSSVarsManager.js +66 -0
  168. package/routes/app/offers/scripts/rendering/locations/ElementResizeObserver.js +49 -0
  169. package/routes/app/offers/scripts/rendering/locations/footer.js +53 -0
  170. package/routes/app/offers/scripts/rendering/locations/header/AsyncBatchProcessor.js +70 -0
  171. package/routes/app/offers/scripts/rendering/locations/header/CSSTransitionObserver.js +182 -0
  172. package/routes/app/offers/scripts/rendering/locations/header/ElementStyleChangeObserver.js +138 -0
  173. package/routes/app/offers/scripts/rendering/locations/header/ExternalStyleManager.js +110 -0
  174. package/routes/app/offers/scripts/rendering/locations/header/Header.js +353 -0
  175. package/routes/app/offers/scripts/rendering/locations/header/InlineStyleManager.js +105 -0
  176. package/routes/app/offers/scripts/rendering/locations/header/MatchingElementsObserver.js +107 -0
  177. package/routes/app/offers/scripts/rendering/locations/header/NewElementsObserver.js +129 -0
  178. package/routes/app/offers/scripts/rendering/locations/header/RuleWrapper.js +46 -0
  179. package/routes/app/offers/scripts/rendering/locations/header/SelectorObservable.js +23 -0
  180. package/routes/app/offers/scripts/rendering/locations/header/SelectorObserver.js +61 -0
  181. package/routes/app/offers/scripts/rendering/locations/header/ShiftedElementsManager.js +45 -0
  182. package/routes/app/offers/scripts/rendering/locations/header/StyleElementManager.js +37 -0
  183. package/routes/app/offers/scripts/rendering/locations/header/StyleElementWrapper.js +62 -0
  184. package/routes/app/offers/scripts/rendering/locations/header/StyleSelectorObserver/ObservedSelectorValue.js +45 -0
  185. package/routes/app/offers/scripts/rendering/locations/header/StyleSelectorObserver/ObservedSelectors.js +62 -0
  186. package/routes/app/offers/scripts/rendering/locations/header/StyleSelectorObserver/StyleSelectorObserver.js +294 -0
  187. package/routes/app/offers/scripts/rendering/locations/header/StyleSelectorObserver/constants.js +21 -0
  188. package/routes/app/offers/scripts/rendering/locations/header/WindowResizeObserver.js +43 -0
  189. package/routes/app/offers/scripts/rendering/locations/header/utils.js +25 -0
  190. package/routes/app/offers/scripts/rendering/locations/popup.js +66 -0
  191. package/routes/app/offers/scripts/rendering/locations/sidebar.js +21 -0
  192. package/routes/app/offers/scripts/rendering/variations/ButtonBanner.js +105 -0
  193. package/routes/app/offers/scripts/rendering/variations/ButtonModal.js +114 -0
  194. package/routes/app/offers/scripts/rendering/variations/FormBanner.js +214 -0
  195. package/routes/app/offers/scripts/rendering/variations/FormModal.js +325 -0
  196. package/routes/app/offers/scripts/rendering/variations/LinkBanner.js +105 -0
  197. package/routes/app/offers/scripts/rendering/variations/components/Body.js +29 -0
  198. package/routes/app/offers/scripts/rendering/variations/components/Button.js +128 -0
  199. package/routes/app/offers/scripts/rendering/variations/components/DismissButton.js +39 -0
  200. package/routes/app/offers/scripts/rendering/variations/components/ForegroundImageBanner.js +110 -0
  201. package/routes/app/offers/scripts/rendering/variations/components/ForegroundImageModal.js +128 -0
  202. package/routes/app/offers/scripts/rendering/variations/components/Headline.js +94 -0
  203. package/routes/app/offers/scripts/rendering/variations/components/MultiFieldForm.js +302 -0
  204. package/routes/app/offers/scripts/rendering/variations/components/Tooltip.js +74 -0
  205. package/routes/app/offers/scripts/rendering/variations/icons.js +15 -0
  206. package/routes/app/offers/scripts/utils.js +115 -0
  207. package/routes/app/offers/utils/HTMLUtils.js +10 -0
  208. package/routes/app/offers/utils/createTypeGuard.js +32 -0
  209. package/routes/app/offers/utils/promise-utils.js +22 -0
  210. package/routes/app/websiteBuilder/stores/storeHelpers.js +18 -0
  211. package/sounds/message-initial.mp3 +0 -0
  212. package/sounds/message-received.mp3 +0 -0
  213. package/sounds/message-sent.mp3 +0 -0
  214. package/src/arrays.js +15 -0
  215. package/src/audio.js +106 -0
  216. package/src/bounded-set.js +16 -0
  217. package/src/bounding_box_observer.js +129 -0
  218. package/src/decorators.js +29 -0
  219. package/src/dom.js +128 -0
  220. package/src/dom_roots.js +26 -0
  221. package/src/embedded_forms/EmbeddedForm.js +638 -0
  222. package/src/embedded_forms/QualifiedEmbeddedForm.js +51 -0
  223. package/src/embedded_forms/QualifiedFormField.js +137 -0
  224. package/src/embedded_forms/utils.js +17 -0
  225. package/src/graphql-types.js +1686 -0
  226. package/src/iframes.js +86 -0
  227. package/src/localstorage.js +43 -0
  228. package/src/mirror/Shipper.js +133 -0
  229. package/src/mirror/constants.generated.js +13 -0
  230. package/src/mirror/constants.js +238 -0
  231. package/src/mirror/shipper/ChangeQueue.js +155 -0
  232. package/src/mirror/shipper/DOMSerializer.js +392 -0
  233. package/src/mirror/shipper/observers.js +441 -0
  234. package/src/mirror/shipper/utils.js +98 -0
  235. package/src/mixins/disposable.js +125 -0
  236. package/src/mixins/injectable.js +37 -0
  237. package/src/personalizations/personalization-manager.js +110 -0
  238. package/src/personalizations/strategies/node-freezing-strategy.js +174 -0
  239. package/src/personalizations/utils.js +187 -0
  240. package/src/promises.js +107 -0
  241. package/src/proxy.js +144 -0
  242. package/src/qualified_root.js +35 -0
  243. package/src/query_params.js +55 -0
  244. package/src/shadow-dom-helper.js +63 -0
  245. package/src/singleton_host.js +39 -0
  246. package/src/smart_website/trigger.js +49 -0
  247. package/src/smart_website/utils.js +149 -0
  248. package/src/string.js +53 -0
  249. package/src/timezone.js +57 -0
  250. package/src/timing.js +49 -0
  251. package/src/type-utils.js +76 -0
  252. package/src/url-utils.js +102 -0
  253. package/src/url.js +50 -0
  254. package/src/utils.js +72 -0
  255. package/src/validation.js.js +29 -0
  256. package/src/validation_ts.js +6 -0
  257. package/vendor/actioncable/adapters.js +6 -0
  258. package/vendor/actioncable/connection.js +204 -0
  259. package/vendor/actioncable/connection_monitor.js +129 -0
  260. package/vendor/actioncable/consumer.js +91 -0
  261. package/vendor/actioncable/index.js +34 -0
  262. package/vendor/actioncable/internal.js +22 -0
  263. package/vendor/actioncable/logger.js +28 -0
  264. package/vendor/actioncable/subscription.js +93 -0
  265. package/vendor/actioncable/subscriptions.js +89 -0
  266. package/vendor/open-telemetry-idgenerator.js +43 -0
  267. package/widget/analytics/facebook_tracker.js +8 -0
  268. package/widget/analytics/google_analytics_tracker.js +83 -0
  269. package/widget/analytics/google_tag_manager_tracker.js +22 -0
  270. package/widget/analytics.js +58 -0
  271. package/widget/api_handler/api_handler.js +730 -0
  272. package/widget/api_handler/base_api_handler.js +249 -0
  273. package/widget/booker_intent_tracker.js +391 -0
  274. package/widget/booker_outcome_tracker.js +329 -0
  275. package/widget/capture_widget_exceptions.js +150 -0
  276. package/widget/channel.js +282 -0
  277. package/widget/composite_experience_adapter.js +101 -0
  278. package/widget/constants.generated.js +350 -0
  279. package/widget/constants.js +21 -0
  280. package/widget/container.js +193 -0
  281. package/widget/content_activity_emitter.js +36 -0
  282. package/widget/data360_visitor.js +67 -0
  283. package/widget/date_provider.js +11 -0
  284. package/widget/debug_mode_state.js +175 -0
  285. package/widget/dummy_module.js +9 -0
  286. package/widget/eloqua_visitor.js +17 -0
  287. package/widget/form_cta_booker_intent.js +246 -0
  288. package/widget/hubspot_visitor.js +39 -0
  289. package/widget/inline_meeting_booker_page.js +90 -0
  290. package/widget/local_state/abstract_local_state.js +38 -0
  291. package/widget/local_state/debug_state/abstract_debug_flow.js +29 -0
  292. package/widget/local_state/debug_state/custom_form_flow.js +14 -0
  293. package/widget/local_state/debug_state/hubspot_form_flow.js +19 -0
  294. package/widget/local_state/debug_state/hubspot_v4_form_flow.js +19 -0
  295. package/widget/local_state/debug_state/marketo_form_flow.js +20 -0
  296. package/widget/local_state/debug_state/pardot_form_flow.js +18 -0
  297. package/widget/local_state/debug_state.js +362 -0
  298. package/widget/local_state/trace_state.js +20 -0
  299. package/widget/location_provider.js +9 -0
  300. package/widget/marketo_visitor.js +39 -0
  301. package/widget/meetings/tracing/buttons_forms_triggering_tracer.js +124 -0
  302. package/widget/meetings/tracing/spans/button_spans.js +18 -0
  303. package/widget/meetings/tracing/spans/form_spans.js +11 -0
  304. package/widget/multimodal_v2/assets_preloader.js +97 -0
  305. package/widget/multimodal_v2/components/AppLayout.js +93 -0
  306. package/widget/multimodal_v2/components/CursorOverlay.js +93 -0
  307. package/widget/multimodal_v2/components/PointerRectOverlay.js +74 -0
  308. package/widget/multimodal_v2/components/app/Artifact.js +109 -0
  309. package/widget/multimodal_v2/components/app/Background.js +27 -0
  310. package/widget/multimodal_v2/components/app/CalendarLoadingContent.js +255 -0
  311. package/widget/multimodal_v2/components/app/Chat.js +39 -0
  312. package/widget/multimodal_v2/components/app/CookieConsentModal.js +149 -0
  313. package/widget/multimodal_v2/components/app/Foreground.js +48 -0
  314. package/widget/multimodal_v2/components/app/HiddenInput.js +41 -0
  315. package/widget/multimodal_v2/components/app/Input.js +72 -0
  316. package/widget/multimodal_v2/components/app/LightboxExperience.js +769 -0
  317. package/widget/multimodal_v2/components/app/LoadingOverlay.js +97 -0
  318. package/widget/multimodal_v2/components/app/Main.js +985 -0
  319. package/widget/multimodal_v2/components/app/MessengerButton.js +160 -0
  320. package/widget/multimodal_v2/components/app/Multimodal.js +17 -0
  321. package/widget/multimodal_v2/components/app/OverlayControls.js +79 -0
  322. package/widget/multimodal_v2/components/app/Preview.js +32 -0
  323. package/widget/multimodal_v2/components/app/PrivacyDisclosure.js +57 -0
  324. package/widget/multimodal_v2/components/app/RotateDeviceOverlay.js +70 -0
  325. package/widget/multimodal_v2/components/app/Toolbar.js +156 -0
  326. package/widget/multimodal_v2/components/chat/ChatComposer.js +129 -0
  327. package/widget/multimodal_v2/components/chat/ChatInputForm.js +398 -0
  328. package/widget/multimodal_v2/components/chat/ColdStartQuestions.js +354 -0
  329. package/widget/multimodal_v2/components/chat/ComposerErrorBanner.js +62 -0
  330. package/widget/multimodal_v2/components/chat/PostCallSurvey.js +359 -0
  331. package/widget/multimodal_v2/components/chat/preview/FieldRequestRenderer.js +41 -0
  332. package/widget/multimodal_v2/components/chat/preview/PreviewMessageRenderer.js +60 -0
  333. package/widget/multimodal_v2/components/chat/preview/SharedOfferRenderer.js +143 -0
  334. package/widget/multimodal_v2/components/chat/preview/TextRenderer.js +27 -0
  335. package/widget/multimodal_v2/components/chat/preview/TimelinePreview.js +254 -0
  336. package/widget/multimodal_v2/components/chat/timeline/CalendarEventOfferRenderer.js +103 -0
  337. package/widget/multimodal_v2/components/chat/timeline/CalendarEventPickRenderer.js +148 -0
  338. package/widget/multimodal_v2/components/chat/timeline/FieldEntryRenderer.js +84 -0
  339. package/widget/multimodal_v2/components/chat/timeline/FieldRequestRenderer.js +56 -0
  340. package/widget/multimodal_v2/components/chat/timeline/InlinePrivacyDisclosure.js +66 -0
  341. package/widget/multimodal_v2/components/chat/timeline/LinkPreviewCard.js +70 -0
  342. package/widget/multimodal_v2/components/chat/timeline/MessageEntry.js +88 -0
  343. package/widget/multimodal_v2/components/chat/timeline/PresentContentRenderer.js +30 -0
  344. package/widget/multimodal_v2/components/chat/timeline/PresentDeckRenderer.js +279 -0
  345. package/widget/multimodal_v2/components/chat/timeline/PresentVideoRenderer.js +131 -0
  346. package/widget/multimodal_v2/components/chat/timeline/ShareContentRenderer.js +59 -0
  347. package/widget/multimodal_v2/components/chat/timeline/SharedOfferRenderer.js +131 -0
  348. package/widget/multimodal_v2/components/chat/timeline/SystemRenderer.js +82 -0
  349. package/widget/multimodal_v2/components/chat/timeline/TextRenderer.js +66 -0
  350. package/widget/multimodal_v2/components/chat/timeline/Timeline.js +158 -0
  351. package/widget/multimodal_v2/components/debug/DebugMultimodalPanel.js +327 -0
  352. package/widget/multimodal_v2/components/decks/index.js +160 -0
  353. package/widget/multimodal_v2/components/field_request/BooleanField.js +77 -0
  354. package/widget/multimodal_v2/components/field_request/FieldComponents.js +69 -0
  355. package/widget/multimodal_v2/components/field_request/Form.js +87 -0
  356. package/widget/multimodal_v2/components/field_request/MultiPicklistField.js +240 -0
  357. package/widget/multimodal_v2/components/field_request/PicklistField.js +166 -0
  358. package/widget/multimodal_v2/components/field_request/SingleLineInputField.js +69 -0
  359. package/widget/multimodal_v2/components/field_request/TextField.js +37 -0
  360. package/widget/multimodal_v2/components/field_request/index.js +170 -0
  361. package/widget/multimodal_v2/components/helpers/AutoScroll.js +37 -0
  362. package/widget/multimodal_v2/components/helpers/ErrorBoundary.js +53 -0
  363. package/widget/multimodal_v2/components/helpers/FocusTrapDialog.js +26 -0
  364. package/widget/multimodal_v2/components/helpers/ImpressionTracker.js +94 -0
  365. package/widget/multimodal_v2/components/helpers/ListRenderer.js +37 -0
  366. package/widget/multimodal_v2/components/helpers/Localization.js +76 -0
  367. package/widget/multimodal_v2/components/helpers/Persisted.js +166 -0
  368. package/widget/multimodal_v2/components/helpers/RichText.js +358 -0
  369. package/widget/multimodal_v2/components/helpers/ScreenReaderHeading.js +17 -0
  370. package/widget/multimodal_v2/components/helpers/Thumbnail.js +190 -0
  371. package/widget/multimodal_v2/components/helpers/VisuallyHidden.js +41 -0
  372. package/widget/multimodal_v2/components/helpers/content_click_payloads.js +58 -0
  373. package/widget/multimodal_v2/components/helpers/useDraggable.js +103 -0
  374. package/widget/multimodal_v2/components/helpers/useTextOverflow.js +44 -0
  375. package/widget/multimodal_v2/components/lightbox_gather/index.js +741 -0
  376. package/widget/multimodal_v2/components/meetings/ArtifactEntryPoint.js +252 -0
  377. package/widget/multimodal_v2/components/meetings/MeetingAdditionalAttendees.js +325 -0
  378. package/widget/multimodal_v2/components/meetings/MeetingBookerEntry.js +100 -0
  379. package/widget/multimodal_v2/components/meetings/MeetingDetailsCard.js +99 -0
  380. package/widget/multimodal_v2/components/meetings/MeetingErrorBanner.js +62 -0
  381. package/widget/multimodal_v2/components/meetings/MeetingOfferEmailStep.js +239 -0
  382. package/widget/multimodal_v2/components/meetings/MeetingOfferFooter.js +104 -0
  383. package/widget/multimodal_v2/components/meetings/MeetingOfferSelectionStep.js +60 -0
  384. package/widget/multimodal_v2/components/meetings/MeetingRepHeader.js +222 -0
  385. package/widget/multimodal_v2/components/meetings/MeetingStepShell.js +92 -0
  386. package/widget/multimodal_v2/components/meetings/MeetingSummaryRail.js +515 -0
  387. package/widget/multimodal_v2/components/meetings/MeetingTimeSelector.js +603 -0
  388. package/widget/multimodal_v2/components/meetings/MonthDatePicker.js +422 -0
  389. package/widget/multimodal_v2/components/meetings/NavigationButtons.js +76 -0
  390. package/widget/multimodal_v2/components/meetings/TimeSlotHeader.js +357 -0
  391. package/widget/multimodal_v2/components/meetings/WeekViewHeader.js +20 -0
  392. package/widget/multimodal_v2/components/meetings/constants.js +7 -0
  393. package/widget/multimodal_v2/components/meetings/index.js +47 -0
  394. package/widget/multimodal_v2/components/meetings/utils.js +328 -0
  395. package/widget/multimodal_v2/components/multimodal/Audio.js +28 -0
  396. package/widget/multimodal_v2/components/multimodal/Controls.js +188 -0
  397. package/widget/multimodal_v2/components/multimodal/LiveVideo.js +63 -0
  398. package/widget/multimodal_v2/components/multimodal/MultiModalComponent.js +424 -0
  399. package/widget/multimodal_v2/components/multimodal/MultimodalAvatar.js +36 -0
  400. package/widget/multimodal_v2/components/multimodal/OrbAvatar.js +326 -0
  401. package/widget/multimodal_v2/components/multimodal/Status.js +220 -0
  402. package/widget/multimodal_v2/components/multimodal/VideoAvatar.js +24 -0
  403. package/widget/multimodal_v2/components/multimodal/VideoPreview.js +114 -0
  404. package/widget/multimodal_v2/components/multimodal/useAudioLevelMonitoring.js +96 -0
  405. package/widget/multimodal_v2/components/multimodal/useMultimodal.js +434 -0
  406. package/widget/multimodal_v2/components/presentations/index.js +372 -0
  407. package/widget/multimodal_v2/components/shared/Avatar.js +92 -0
  408. package/widget/multimodal_v2/components/shared/AvatarGroup.js +135 -0
  409. package/widget/multimodal_v2/components/shared/Button.js +245 -0
  410. package/widget/multimodal_v2/components/shared/ButtonGroup.js +133 -0
  411. package/widget/multimodal_v2/components/shared/ComposerForm.js +98 -0
  412. package/widget/multimodal_v2/components/shared/SpeakingIndicator.js +239 -0
  413. package/widget/multimodal_v2/components/shared/ThinkingAnimation.js +165 -0
  414. package/widget/multimodal_v2/components/shared/Tooltip.js +266 -0
  415. package/widget/multimodal_v2/components/shared/controls/Dropdown.js +79 -0
  416. package/widget/multimodal_v2/components/shared/controls/PillToggle.js +142 -0
  417. package/widget/multimodal_v2/components/shared/controls/TextArea.js +114 -0
  418. package/widget/multimodal_v2/components/shared/toolCallLabels.js +12 -0
  419. package/widget/multimodal_v2/components/slides/SlidesThumbnail.js +47 -0
  420. package/widget/multimodal_v2/components/slides/index.js +61 -0
  421. package/widget/multimodal_v2/constants.js +88 -0
  422. package/widget/multimodal_v2/host.split-css.js +2 -0
  423. package/widget/multimodal_v2/host.string.js +96 -0
  424. package/widget/multimodal_v2/images/icons.js +582 -0
  425. package/widget/multimodal_v2/images/posters/piper_low_res.jpg +0 -0
  426. package/widget/multimodal_v2/index.js +23 -0
  427. package/widget/multimodal_v2/index.panda.js +28 -0
  428. package/widget/multimodal_v2/index.split-css.panda.js +2 -0
  429. package/widget/multimodal_v2/inline_meeting_booker.js +182 -0
  430. package/widget/multimodal_v2/locales/cs.js +196 -0
  431. package/widget/multimodal_v2/locales/da.js +196 -0
  432. package/widget/multimodal_v2/locales/de.js +196 -0
  433. package/widget/multimodal_v2/locales/en.js +196 -0
  434. package/widget/multimodal_v2/locales/en_AU.js +197 -0
  435. package/widget/multimodal_v2/locales/en_GB.js +197 -0
  436. package/widget/multimodal_v2/locales/es.js +197 -0
  437. package/widget/multimodal_v2/locales/es_LA.js +196 -0
  438. package/widget/multimodal_v2/locales/fi.js +196 -0
  439. package/widget/multimodal_v2/locales/fr.js +197 -0
  440. package/widget/multimodal_v2/locales/fr_CA.js +196 -0
  441. package/widget/multimodal_v2/locales/id.js +196 -0
  442. package/widget/multimodal_v2/locales/index.js +48 -0
  443. package/widget/multimodal_v2/locales/it.js +196 -0
  444. package/widget/multimodal_v2/locales/ja.js +196 -0
  445. package/widget/multimodal_v2/locales/ko.js +196 -0
  446. package/widget/multimodal_v2/locales/nb.js +196 -0
  447. package/widget/multimodal_v2/locales/nl.js +196 -0
  448. package/widget/multimodal_v2/locales/pl.js +196 -0
  449. package/widget/multimodal_v2/locales/pt_BR.js +196 -0
  450. package/widget/multimodal_v2/locales/ru.js +196 -0
  451. package/widget/multimodal_v2/locales/sv.js +196 -0
  452. package/widget/multimodal_v2/locales/th.js +196 -0
  453. package/widget/multimodal_v2/locales/tr.js +196 -0
  454. package/widget/multimodal_v2/locales/vi.js +196 -0
  455. package/widget/multimodal_v2/locales/zh_CN.js +196 -0
  456. package/widget/multimodal_v2/locales/zh_TW.js +196 -0
  457. package/widget/multimodal_v2/multimodal.js +633 -0
  458. package/widget/multimodal_v2/multimodal_channel.js +195 -0
  459. package/widget/multimodal_v2/signals/active_conversation_signal.js +33 -0
  460. package/widget/multimodal_v2/signals/allowed_conversation_mode_signal.js +38 -0
  461. package/widget/multimodal_v2/signals/artifact_signal.js +22 -0
  462. package/widget/multimodal_v2/signals/layout_signal.js +98 -0
  463. package/widget/multimodal_v2/signals/messages_signal.js +207 -0
  464. package/widget/multimodal_v2/signals/ui_state_signal.js +128 -0
  465. package/widget/multimodal_v2/stable_bundle_src.js +44 -0
  466. package/widget/multimodal_v2/stores/ai_conversation_store.js +221 -0
  467. package/widget/multimodal_v2/stores/artifact_store.js +205 -0
  468. package/widget/multimodal_v2/stores/base_store.js +16 -0
  469. package/widget/multimodal_v2/stores/call_store.js +770 -0
  470. package/widget/multimodal_v2/stores/call_ui_adapter.js +225 -0
  471. package/widget/multimodal_v2/stores/debug_multimodal_scenario_store.js +471 -0
  472. package/widget/multimodal_v2/stores/decks_store.js +285 -0
  473. package/widget/multimodal_v2/stores/device_store.js +63 -0
  474. package/widget/multimodal_v2/stores/docking_store.js +62 -0
  475. package/widget/multimodal_v2/stores/field_request_store.js +326 -0
  476. package/widget/multimodal_v2/stores/meeting_store.js +477 -0
  477. package/widget/multimodal_v2/stores/participant_store.js +73 -0
  478. package/widget/multimodal_v2/stores/post_call_survey_store.js +160 -0
  479. package/widget/multimodal_v2/stores/pounce_tracking_store.js +163 -0
  480. package/widget/multimodal_v2/stores/pounce_tracking_store_v2.js +511 -0
  481. package/widget/multimodal_v2/stores/presentations_store.js +111 -0
  482. package/widget/multimodal_v2/stores/root_store.js +1919 -0
  483. package/widget/multimodal_v2/stores/screen_share_store.js +217 -0
  484. package/widget/multimodal_v2/stores/slides_store.js +21 -0
  485. package/widget/multimodal_v2/stores/translation_store.js +185 -0
  486. package/widget/multimodal_v2/stores/ui_store.js +496 -0
  487. package/widget/multimodal_v2/stores/waiting_store.js +159 -0
  488. package/widget/multimodal_v2/stores/website_navigation_store.js +767 -0
  489. package/widget/multimodal_v2/styled-system/css/conditions.js +34 -0
  490. package/widget/multimodal_v2/styled-system/css/css.js +48 -0
  491. package/widget/multimodal_v2/styled-system/css/cva.js +96 -0
  492. package/widget/multimodal_v2/styled-system/css/cx.js +13 -0
  493. package/widget/multimodal_v2/styled-system/css/index.js +15 -0
  494. package/widget/multimodal_v2/styled-system/css/sva.js +69 -0
  495. package/widget/multimodal_v2/styled-system/helpers.js +384 -0
  496. package/widget/multimodal_v2/styled-system/jsx/create-style-context.js +96 -0
  497. package/widget/multimodal_v2/styled-system/jsx/factory-helper.js +19 -0
  498. package/widget/multimodal_v2/styled-system/jsx/factory.js +111 -0
  499. package/widget/multimodal_v2/styled-system/jsx/index.js +12 -0
  500. package/widget/multimodal_v2/styled-system/jsx/is-valid-prop.js +22 -0
  501. package/widget/multimodal_v2/types.js +105 -0
  502. package/widget/multimodal_v2/utils/auto_scroller.js +157 -0
  503. package/widget/multimodal_v2/utils/flip_animation.js +124 -0
  504. package/widget/multimodal_v2/utils/focus_gate.js +237 -0
  505. package/widget/multimodal_v2/utils/locale.js +16 -0
  506. package/widget/multimodal_v2/utils/media_queries.js +30 -0
  507. package/widget/multimodal_v2/utils/multimodal_cache.js +19 -0
  508. package/widget/multimodal_v2/utils/mutation_effect.js +14 -0
  509. package/widget/multimodal_v2/utils/navigation_interceptor.js +205 -0
  510. package/widget/multimodal_v2/utils/navigation_strategies/dom_swap.js +393 -0
  511. package/widget/multimodal_v2/utils/navigation_strategies/index.js +12 -0
  512. package/widget/multimodal_v2/utils/navigation_strategies/lwr.js +61 -0
  513. package/widget/multimodal_v2/utils/navigation_strategies/navigation_utils.js +46 -0
  514. package/widget/multimodal_v2/utils/navigation_strategies/next_js.js +24 -0
  515. package/widget/multimodal_v2/utils/navigation_strategies/wouter_v3.js +15 -0
  516. package/widget/multimodal_v2/utils/objects_map.js +38 -0
  517. package/widget/multimodal_v2/utils/perceived_voice_turn_tracker.js +345 -0
  518. package/widget/multimodal_v2/utils/sanitize_html.js +132 -0
  519. package/widget/multimodal_v2/utils/signals.js +97 -0
  520. package/widget/multimodal_v2/utils/slide_zoom.js +114 -0
  521. package/widget/multimodal_v2/utils/theme_styles.js +137 -0
  522. package/widget/multimodal_v2/utils/url_observer.js +52 -0
  523. package/widget/multimodal_v2/utils/voice_onset_detector.js +127 -0
  524. package/widget/page_mirror.js +89 -0
  525. package/widget/page_view_activity_emitter.js +71 -0
  526. package/widget/pardot_visitor.js +137 -0
  527. package/widget/personalization_observer.js +96 -0
  528. package/widget/personalizations_config.js +160 -0
  529. package/widget/qualified_form/constants.js +23 -0
  530. package/widget/qualified_form/phone_utils.js +38 -0
  531. package/widget/qualified_form/qualified_form_action.js +91 -0
  532. package/widget/qualified_form/qualified_form_action_orchestrator.js +21 -0
  533. package/widget/qualified_form/qualified_form_api.js +471 -0
  534. package/widget/scroll_disabler.js +109 -0
  535. package/widget/server-logger.js +156 -0
  536. package/widget/smart_website_config.js +112 -0
  537. package/widget/telemetry/context.js +75 -0
  538. package/widget/telemetry/index.js +16 -0
  539. package/widget/telemetry/messenger_uptime.js +80 -0
  540. package/widget/telemetry/metrics.js +120 -0
  541. package/widget/telemetry/span.js +82 -0
  542. package/widget/telemetry/telemetry.js +180 -0
  543. package/widget/telemetry/tracer.js +41 -0
  544. package/widget/telemetry/tracing_store.js +310 -0
  545. package/widget/tracker.js +916 -0
  546. package/widget/utils/native_globals.js +129 -0
  547. package/widget/v1_adapter.js +50 -0
  548. package/widget/v2_adapter.js +368 -0
  549. package/widget/visitor/base_visitor_state.js +11 -0
  550. package/widget/visitor/cookie_visitor_state.js +128 -0
  551. package/widget/visitor/in_memory_visitor_state.js +29 -0
  552. package/widget/visitor/visitor_state.js +384 -0
  553. package/widget/visitor.js +356 -0
  554. package/widget/widget/linked_widget_v2.js +227 -0
  555. package/widget/widget/page_mirror_factory.js +22 -0
  556. package/widget/widget/sentry.js +130 -0
  557. package/widget/widget/widget.js +1698 -0
  558. package/widget/widget.split-css.js +2 -0
  559. package/widget/widget_bootstrap.js +97 -0
  560. package/widget/widget_object.js +73 -0
@@ -0,0 +1,1698 @@
1
+ import { __webpack_require__ } from "../../js/runtime.js";
2
+ import { esm_browser_v4, __metadata, _extends, isMobile, __decorate } from "../../js/4101.js";
3
+ import { isDomVisible, DOMReady, addEventListener } from "../../src/dom.js";
4
+ import { registerCustomElement } from "../../src/embedded_forms/QualifiedEmbeddedForm.js";
5
+ import { isDomainMatch, isIframed } from "../../src/iframes.js";
6
+ import { delay as timing_delay } from "../../src/timing.js";
7
+ import { normalizeURL, hasURLMatch } from "../../src/url-utils.js";
8
+ import { default as ApiHandler } from "../api_handler/api_handler.js";
9
+ import { captureWidgetExceptions } from "../capture_widget_exceptions.js";
10
+ import { default as channel } from "../channel.js";
11
+ import { default as Container } from "../container.js";
12
+ import { default as content_activity_emitter } from "../content_activity_emitter.js";
13
+ import { default as DebugModeState, showDebugBanner } from "../debug_mode_state.js";
14
+ import { pageOwnsInlineMeetingBooker } from "../inline_meeting_booker_page.js";
15
+ import { DebugState } from "../local_state/debug_state.js";
16
+ import { TraceState } from "../local_state/trace_state.js";
17
+ import { ButtonsFormsTriggeringTracer } from "../meetings/tracing/buttons_forms_triggering_tracer.js";
18
+ import { AssetsPreloader } from "../multimodal_v2/assets_preloader.js";
19
+ import { default as page_view_activity_emitter } from "../page_view_activity_emitter.js";
20
+ import { default as PersonalizationObserver } from "../personalization_observer.js";
21
+ import { serverLogger } from "../server-logger.js";
22
+ import "../telemetry/index.js";
23
+ import { MessengerUptimeTracker } from "../telemetry/messenger_uptime.js";
24
+ import { default as tracker } from "../tracker.js";
25
+ import { V2Adapter } from "../v2_adapter.js";
26
+ import { default as visitor } from "../visitor.js";
27
+ import { widgetBootstrap } from "../widget_bootstrap.js";
28
+ import { MAP_FORM_FIELD_DENY_LIST } from "../../constants.generated.js";
29
+ import { tryGet } from "../../src/utils.js";
30
+ import { observeBookerOutcome, disposeFormCtaBookerIntent, armFormCtaBookerIntent } from "../form_cta_booker_intent.js";
31
+ import { Sentry, getSentryClient, setSentryContext } from "./sentry.js";
32
+ import { inject, Injectable } from "../../src/mixins/injectable.js";
33
+ import { Disposable } from "../../src/mixins/disposable.js";
34
+ import { default as date_provider } from "../date_provider.js";
35
+ import { default as location_provider } from "../location_provider.js";
36
+ import { CompositeExperienceAdapter } from "../composite_experience_adapter.js";
37
+ import { V1Adapter } from "../v1_adapter.js";
38
+ import { browserIntlSupport, guessTimeZone } from "../../src/timezone.js";
39
+ import "../utils/native_globals.js";
40
+ import { isDefined } from "../../src/type-utils.js";
41
+ import { createBetterPromise } from "../../src/promises.js";
42
+ import { telemetry, withSpan, getTelemetryCtx } from "../telemetry/telemetry.js";
43
+ import { isWidgetBundleResource, widgetConsumer, resolveOriginTime } from "../telemetry/metrics.js";
44
+
45
+ const cloneDeep = __webpack_require__("39491");
46
+ var cloneDeep_default = /*#__PURE__*/__webpack_require__.n(cloneDeep);
47
+ /* provided dependency */ var __nativeWindowRemoveEventListener = __webpack_require__(68034).kZ;
48
+ /* provided dependency */ var __nativeWindowAddEventListener = __webpack_require__(68034).zh;
49
+ /* provided dependency */ var widget_clearInterval = __webpack_require__(68034).wm;
50
+ /* provided dependency */ var widget_setTimeout = __webpack_require__(68034).pS;
51
+ /* provided dependency */ var widget_setInterval = __webpack_require__(68034).LK;
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+ const LOOPBACK_HOSTS = new Set([
97
+ "localhost",
98
+ "127.0.0.1",
99
+ "::1",
100
+ "[::1]"
101
+ ]);
102
+ const MARKETO_REDIRECT_DEFAULT_TIMEOUT_MS = 500;
103
+ const MARKETO_REDIRECT_MOBILE_TIMEOUT_MS = 1000;
104
+ const MARKETO_LAST_VALID_REBROADCAST_THRESHOLD_MS = 5000;
105
+ const WIDGET_EVENTS = [
106
+ "apiReady",
107
+ "sessionCreated",
108
+ "widgetInitialized"
109
+ ];
110
+ function isLoopbackHost(host) {
111
+ try {
112
+ return LOOPBACK_HOSTS.has(new URL(host).hostname);
113
+ } catch (unused) {
114
+ return host.includes("localhost");
115
+ }
116
+ }
117
+ class IframedFormExperienceAdapter {
118
+ dispose() {}
119
+ showLightboxLoading() {}
120
+ showMessengerLoading() {}
121
+ showInlineLoading(_uuid) {}
122
+ closeLightbox() {}
123
+ openMessenger() {}
124
+ setChatIsVisible(_visible) {}
125
+ addMessengerEventsListener(_handler) {}
126
+ get apMessagesCount() {
127
+ return 0;
128
+ }
129
+ get autoRespondPounceCount() {
130
+ return 0;
131
+ }
132
+ get visitorResponded() {
133
+ return false;
134
+ }
135
+ get userResponded() {
136
+ return false;
137
+ }
138
+ get originalDocumentTitle() {
139
+ return null;
140
+ }
141
+ }
142
+ const ReadyState = {
143
+ None: 1,
144
+ Initializing: 2,
145
+ Ready: 3,
146
+ Failed: 4
147
+ };
148
+ const ConnectState = {
149
+ None: 0,
150
+ Connected: 1,
151
+ DelayConnect: 2
152
+ };
153
+ const FormStorageKey = "q_form_data";
154
+ class Widget extends Injectable(Disposable(Object)) {
155
+ static createContainer() {
156
+ const container = new Container();
157
+ container.register1("widget", this);
158
+ container.register1("channel", channel);
159
+ container.register1("tracker", tracker);
160
+ container.register1("apiHandler", ApiHandler);
161
+ container.register1("dateProvider", date_provider);
162
+ container.register1("locationProvider", location_provider);
163
+ container.register1("pageViewActivityEmitter", page_view_activity_emitter);
164
+ container.register1("contentActivityEmitter", content_activity_emitter);
165
+ container.set("heartbeatManager", {
166
+ blocked: false
167
+ });
168
+ container.register("visitor", visitor);
169
+ return container;
170
+ }
171
+ // Create all the widget objects. Returns the qualified(...) API function.
172
+ static start(envConfig) {
173
+ if (envConfig) {
174
+ this.environmentConfig = envConfig;
175
+ }
176
+ const container = this.createContainer();
177
+ window.__test_container_is_created == null ? void 0 : window.__test_container_is_created.call(window, container);
178
+ container.resolve("widget", this.environmentConfig);
179
+ window.__test_widget_is_created == null ? void 0 : window.__test_widget_is_created.call(window, container);
180
+ return window[window.QualifiedObject];
181
+ }
182
+ get visitor() {
183
+ if (this._visitor) return this._visitor;
184
+ throw new Error("Visitor not initialized on Widget");
185
+ }
186
+ get channel() {
187
+ if (this._channel) return this._channel;
188
+ throw new Error("Channel not initialized on Widget");
189
+ }
190
+ get tracker() {
191
+ if (this._tracker) return this._tracker;
192
+ throw new Error("Tracker not initialized on Widget");
193
+ }
194
+ get iframeManager() {
195
+ if (this._iframeManager) return this._iframeManager;
196
+ throw new Error("IframeManager not initialized on Widget");
197
+ }
198
+ /**
199
+ * Returns a CompositeExperienceAdapter: the V1Adapter (iframe) paired with a
200
+ * V2Adapter events bridge, so messenger-event handlers fire whether the iframe
201
+ * or multimodal owns the session. The bridge is a no-op until
202
+ * initializeMultimodalV2() binds it. Subclasses (e.g. LinkedWidgetV2) override
203
+ * this to return a bare V2Adapter. Called once during init().
204
+ */ createExperienceAdapter() {
205
+ return new CompositeExperienceAdapter(new V1Adapter(this._iframeManager), new V2Adapter());
206
+ }
207
+ /**
208
+ * Whether this widget should run the full init path (tracker, visitor,
209
+ * websocket channel) when rendered inside an iframe, rather than taking the
210
+ * iframed short-circuit in init(). Defaults to false; overridden by widgets
211
+ * that are themselves full pages a customer may embed (e.g. the meeting booker).
212
+ */ bootstrapsWhenIframed() {
213
+ return false;
214
+ }
215
+ get offerScript() {
216
+ return this._offerScript;
217
+ }
218
+ get multimodal() {
219
+ return this._multimodal;
220
+ }
221
+ get pageViewActivityEmitter() {
222
+ if (this._pageViewActivityEmitter) return this._pageViewActivityEmitter;
223
+ throw new Error("PageViewActivityEmitter not initialized on Widget");
224
+ }
225
+ get contentActivityEmitter() {
226
+ var _this__contentActivityEmitter;
227
+ return (_this__contentActivityEmitter = this._contentActivityEmitter) != null ? _this__contentActivityEmitter : this._contentActivityEmitter = this.container.resolve("contentActivityEmitter");
228
+ }
229
+ resourceUrl() {
230
+ for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
231
+ args[_key] = arguments[_key];
232
+ }
233
+ return serverLogger.resourceUrl(...args);
234
+ }
235
+ async isBlacklisted() {
236
+ var _this_config_blacklistPaths;
237
+ if ((_this_config_blacklistPaths = this.config.blacklistPaths) == null ? void 0 : _this_config_blacklistPaths.find((path)=>document.location.pathname.match("^" + path + "$"))) {
238
+ var _this_config_featureFlags;
239
+ const uuid = this.container.classFor("visitor").getUuid(this.config.token, (_this_config_featureFlags = this.config.featureFlags) == null ? void 0 : _this_config_featureFlags.websiteVisitorStateV2);
240
+ if (uuid) {
241
+ if (await fetch(this.resourceUrl("state/blacklisted", {
242
+ uuid
243
+ })).then((resp)=>resp.json())) {
244
+ this.container.resolve("visitor").reset();
245
+ return true;
246
+ }
247
+ } else {
248
+ return true;
249
+ }
250
+ return false;
251
+ }
252
+ }
253
+ // Checks a URL against the team's allowed domain list if configured.
254
+ isAllowedOrigin(url) {
255
+ var _this_config_domains;
256
+ let rv = false;
257
+ if (((_this_config_domains = this.config.domains) == null ? void 0 : _this_config_domains.length) === 0) {
258
+ rv = true;
259
+ } else if (isDomainMatch(this.config.domains || [], url)) {
260
+ rv = true;
261
+ }
262
+ if (rv) {
263
+ // here we are console logging isDomainMatch outcome when debug (q_debug url param) is turned on
264
+ this.debugLog("url " + url + " passed isDomainMatch check using " + this.config.domains);
265
+ } else {
266
+ this.debugLog("url " + url + " didn't pass isDomainMatch check using " + this.config.domains);
267
+ }
268
+ return rv;
269
+ }
270
+ async init(teamToken, config) {
271
+ if (config === void 0) config = {};
272
+ var _resolveOriginTime, _this_widgetId;
273
+ var _window_qualified_docking_setAbortStage, _window_qualified_docking, _window_qualified;
274
+ (_window_qualified = window.qualified) == null ? void 0 : (_window_qualified_docking = _window_qualified.docking) == null ? void 0 : (_window_qualified_docking_setAbortStage = _window_qualified_docking.setAbortStage) == null ? void 0 : _window_qualified_docking_setAbortStage.call(_window_qualified_docking, "socket_connection");
275
+ const ctx = getTelemetryCtx();
276
+ this.isDebug = new URLSearchParams(document.location.search).has("q_debug");
277
+ this.widgetInitializedAt = performance.now();
278
+ serverLogger.setConfig(this.config);
279
+ serverLogger.setWidgetId(this.widgetId || "");
280
+ if (this.readyState !== ReadyState.None && teamToken !== this.config.token) {
281
+ // qualified('initialize', ...) called with a different team token. This can happen on
282
+ // AppExchange as a visitor travels between listings.
283
+ const newApi = this.onTeardown();
284
+ newApi("initialize", teamToken, config);
285
+ return;
286
+ }
287
+ // this.loaded check ensures widget is only added to the page once
288
+ if (this.loaded || !teamToken) {
289
+ return this.abortInit();
290
+ }
291
+ // This needs to be set after the readyState check above, because of the comparison of
292
+ // `teamToken` with `this.config.token` above.
293
+ this.config.token = teamToken;
294
+ // Needs to come after setting the team token
295
+ const consumer = widgetConsumer();
296
+ this.widget.logTiming("Time to init widget", "widget_time_to_init_ms", this.widgetInitializedAt, {
297
+ consumer
298
+ });
299
+ // Origin is resolved lazily (not a module-eval snapshot): under npm our code is inlined into
300
+ // the consumer's content-hashed chunk, so there is no qualified.js resource entry — setup()
301
+ // records window._q_setupCalledAt and resolveOriginTime falls back to it. null (missing/evicted
302
+ // resource, or a consumer that never ran setup) becomes NaN so logTiming drops it. Tagged with
303
+ // the consumer so npm's "time from setup()" isn't mixed with the snippet's "time from page load".
304
+ this.widget.logTiming("Time to start downloading script", "script_time_to_start_ms", (_resolveOriginTime = resolveOriginTime()) != null ? _resolveOriginTime : NaN, {
305
+ consumer
306
+ });
307
+ // Needs to come after setting the team token. The clients themselves are
308
+ // created earlier (Sentry.init in the entrypoint); here we just supply the
309
+ // team-specific proxy URL so subsequent captures are sent. This is a no-op
310
+ // when the snippet already injected the proxy URL global before the bundle.
311
+ if (this.config.host && !isLoopbackHost(this.config.host)) {
312
+ Sentry.setProxyUrl(this.resourceUrl("sentry/proxy"));
313
+ }
314
+ // Synchronous initialization code goes here no await should go above this line
315
+ this.syncInit(config);
316
+ await telemetry.startActiveSpanAsync("Await DOMReady", {}, ctx, async (span)=>{
317
+ await DOMReady();
318
+ span.end();
319
+ });
320
+ if (!this.isIframed) this.widget.logTiming("Time to DOMReady", "widget_time_to_domready_ms");
321
+ // TODO: switch to Mitranim/posterus, thefrontside/effection, or something for structured
322
+ // concurrency. So that we don't need to litter everything with state checks after every
323
+ // await.
324
+ if (this.isDisposed) {
325
+ return;
326
+ }
327
+ // lastClientActivityAt is set on `window` and will be set already if
328
+ // this is a widget refresh; The conditional prevents clients from coming
329
+ // out of idle during refresh
330
+ if (!this.lastClientActivityAt) this.registerClientActivity();
331
+ // For AppEx and Customer hosted versions of our snippet, we need to grab the
332
+ // configuration via the web because it is not already compiled into the snippet
333
+ // like our CDN hosted version.
334
+ const shouldUseAppExchangeConfig = config.appexchange === true || this.appExchangeEnabled;
335
+ if (!config.isComplete || shouldUseAppExchangeConfig) {
336
+ // We're on appexchange, who also passes us `hasCookieConsent` and `appexchangeId` in config.
337
+ // Or we are on a customer hosted snippet, which does not come with this config built in.
338
+ const response = await fetch(this.resourceUrl("configuration", shouldUseAppExchangeConfig ? {
339
+ appexchange: true
340
+ } : undefined));
341
+ const teamConfig = await response.json();
342
+ if (this.isDisposed) {
343
+ return;
344
+ }
345
+ config = _extends({
346
+ noCookieDomainTest: true
347
+ }, config, teamConfig);
348
+ }
349
+ this.config = _extends({}, this.config, config);
350
+ this.config.requiresCookieConsent = this.config.hasCookieConsent !== undefined;
351
+ if (this.isIframed && !this.bootstrapsWhenIframed()) {
352
+ this.messengerUptime.dispose();
353
+ const iframeApiHandler = this.apiHandler;
354
+ const { hasQueuedEarlyIframeLocalApiCalls, markIframeLocalApiReady } = iframeApiHandler;
355
+ const shouldFlushIframeLocalApis = typeof hasQueuedEarlyIframeLocalApiCalls === "function" && typeof markIframeLocalApiReady === "function" && hasQueuedEarlyIframeLocalApiCalls.call(this.apiHandler);
356
+ if (shouldFlushIframeLocalApis) {
357
+ markIframeLocalApiReady.call(this.apiHandler);
358
+ } else {
359
+ this.apiHandler.markReady();
360
+ }
361
+ const searchParams = new URLSearchParams(document.location.search);
362
+ if (searchParams.has("q_trace")) {
363
+ const q_trace_value = searchParams.get("q_trace");
364
+ this.traceState.setIsTracing(true, q_trace_value);
365
+ }
366
+ if (!DebugModeState.isInDebugMode() && this.isDebug) {
367
+ DebugModeState.initializeDebugMode();
368
+ }
369
+ this.readyState = ReadyState.Ready;
370
+ try {
371
+ this.cursorPositionProvider = this.container.resolve("cursorPositionProvider");
372
+ } catch (unused) {
373
+ // CursorPositionProvider not registered (v2 bundle) — skip.
374
+ }
375
+ return;
376
+ }
377
+ if (!this.config.requiresCookieConsent && await this.isBlacklisted()) {
378
+ return this.abortInit();
379
+ }
380
+ if (this.isDisposed) {
381
+ return;
382
+ }
383
+ this.timezone = guessTimeZone();
384
+ this.resetWidgetId();
385
+ serverLogger.setWidgetId(this.widgetId || "");
386
+ // The point where this.visitor is initialized is sensitive
387
+ this._visitor = this.container.resolve("visitor");
388
+ serverLogger.setVisitorId(this.visitor.uuid);
389
+ setSentryContext({
390
+ visitorUuid: this.visitor.uuid,
391
+ widgetUuid: (_this_widgetId = this.widgetId) != null ? _this_widgetId : undefined
392
+ });
393
+ const searchParams = new URLSearchParams(document.location.search);
394
+ if (searchParams.has("q_trace")) {
395
+ const q_trace_value = searchParams.get("q_trace");
396
+ this.traceState.setIsTracing(true, q_trace_value);
397
+ }
398
+ if (!DebugModeState.isInDebugMode() && this.isDebug) {
399
+ DebugModeState.initializeDebugMode();
400
+ }
401
+ this.channel.on("refresh", this.onRefresh);
402
+ this.channel.on("widgetLongTasks", (entries)=>{
403
+ this.recordWidgetLongTaskSpans("Widget Long Task", JSON.parse(entries));
404
+ });
405
+ this.channel.on("startLightboxLoadingSpinner", ()=>{
406
+ ButtonsFormsTriggeringTracer.finishWaitForLightboxLoadingSpinnerSpan();
407
+ });
408
+ this.widget.logTiming("Time to visitor ready", "widget_time_to_visitor_ready_ms");
409
+ let connectState;
410
+ await telemetry.startActiveSpanAsync("Connect Cable", {}, ctx, async (span)=>{
411
+ connectState = await this.connectChannel(false);
412
+ span.end();
413
+ });
414
+ if (this.isDisposed) {
415
+ return;
416
+ }
417
+ if (connectState === ConnectState.DelayConnect) {
418
+ await telemetry.startActiveSpanAsync("Delay Init", {}, ctx, async (span)=>{
419
+ await this.delayInit();
420
+ span.end();
421
+ });
422
+ }
423
+ if (this.isDisposed) {
424
+ return;
425
+ }
426
+ if (connectState !== ConnectState.Connected) {
427
+ // Try again one more time.
428
+ await telemetry.startActiveSpanAsync("Connect Cable", {}, ctx, async (span)=>{
429
+ connectState = await this.connectChannel(false);
430
+ span.end();
431
+ });
432
+ }
433
+ if (this.isDisposed) {
434
+ return;
435
+ }
436
+ if (connectState !== ConnectState.Connected) {
437
+ return this.abortInit();
438
+ }
439
+ if (this.isDisposed) {
440
+ return;
441
+ }
442
+ this.widget.logTiming("Time to cable connected", "widget_time_to_cable_connected_ms");
443
+ this.initSpan = telemetry.startSpan("Init Widget", {}, widgetBootstrap.initSpan);
444
+ await withSpan(ctx, this.initSpan, async ()=>{
445
+ var _this_config_featureFlags;
446
+ const ctx = getTelemetryCtx();
447
+ this._pageViewActivityEmitter = this.container.resolve("pageViewActivityEmitter");
448
+ this._tracker = this.container.resolve("tracker");
449
+ try {
450
+ this._iframeManager = this.container.resolve("iframeManager");
451
+ } catch (unused) {
452
+ // IframeManager not registered (v2 bundle) — skip.
453
+ }
454
+ this.experienceAdapter = this.createExperienceAdapter();
455
+ this.apiHandler.markReady();
456
+ // This is the earliest point we can emit a widget event to the client-side api,
457
+ // because the apiHandler is marked as ready above
458
+ this.emitWidgetEvent("apiReady");
459
+ const item = this.visitor.formExperienceData;
460
+ if (this.tracker.config.hasSmartForms && item) {
461
+ const logEventData = {
462
+ formType: item.formType,
463
+ formId: item.formData.formId,
464
+ formActionUrl: item.formData.formActionUrl
465
+ };
466
+ const triggers = this.tracker.config.formBotTriggers[item.formType];
467
+ if (item.formData.formActionUrl && triggers && !triggers.includes(item.formData.formActionUrl.replace(/^https?:\/\//, ""))) {
468
+ this.debugState.logEvent("widget:formExperienceDataFound", "error", logEventData, 'Form experience data was found from previous page but "formData.formActionUrl" is not in the list of configured triggers');
469
+ } else {
470
+ var _item_formData_formActionUrl, _this_config_featureFlags1;
471
+ this.debugState.logEvent("widget:formExperienceDataFound", "success", logEventData);
472
+ this.tracker.setInitializationParams({
473
+ smart_form: {
474
+ form_type: item.formType,
475
+ field_values: {
476
+ email: item.formData.formEmail
477
+ },
478
+ form_data: {
479
+ raw: _extends({}, item.formData),
480
+ form_id: item.formData.formId,
481
+ form_action_url: (_item_formData_formActionUrl = item.formData.formActionUrl) == null ? void 0 : _item_formData_formActionUrl.replace(/^https?:\/\//, ""),
482
+ form_email: item.formData.formEmail
483
+ }
484
+ }
485
+ });
486
+ ButtonsFormsTriggeringTracer.startSubmitFormSpan({
487
+ "form.type": item.formType,
488
+ "form.with_redirect": true
489
+ });
490
+ // Pre-offer SLI: a submit that survived a page redirect, replayed here.
491
+ // The clock necessarily starts at the replay, not the original submit —
492
+ // the pre-redirect context is gone.
493
+ if ((_this_config_featureFlags1 = this.config.featureFlags) == null ? void 0 : _this_config_featureFlags1.bookerJourneySLI) {
494
+ // No experience name on this path: `FormExperienceData` carries only
495
+ // `formType` plus a `FormDataObject` of `formEmail` / `formId` /
496
+ // `formActionUrl`, so there is no `bot_api_name` to read. Left absent
497
+ // rather than guessed — the field is optional for exactly this case.
498
+ // (`item` comes from untyped visitor state, so the compiler could not
499
+ // catch the original wrong read.)
500
+ armFormCtaBookerIntent("form:" + item.formType);
501
+ }
502
+ this.experienceAdapter.showLightboxLoading();
503
+ this.visitor.clearFormExperienceData();
504
+ }
505
+ }
506
+ telemetry.startActiveSpanAsync("Init tracker", {}, ctx, async (span)=>{
507
+ await this.tracker.init();
508
+ span.end();
509
+ });
510
+ try {
511
+ this.debugState.logEvent("widget:initFormExperience", "success");
512
+ this.initFormExperience();
513
+ } catch (error) {
514
+ // can add the sentry report in the future, but just catch silently now.
515
+ this.debugState.logEvent("widget:initFormExperience", "error", {
516
+ error
517
+ });
518
+ }
519
+ if (this.tracker.config.hasWebsiteEmbeddedForms) {
520
+ this.initQualifiedForms();
521
+ }
522
+ this.exposeDebugging();
523
+ // TODO: uncomment the below when we remove the Promise Pollyfill
524
+ //
525
+ // const iframeSpan = await telemetry.startActiveSpanAsync(
526
+ // "Init Iframe",
527
+ // null,
528
+ // ctx,
529
+ // async (span) => {
530
+ // await this.iframeManager.init();
531
+ // span.end();
532
+ //
533
+ // await this.recordPerformanceEntries(span);
534
+ // }
535
+ // );
536
+ // TODO: Remove the below block when we remove the Promise Pollyfill
537
+ const iFrameInitSpan = telemetry.startSpan("Init Iframe", {}, this.initSpan);
538
+ this.widget.logTiming("Time to pre-multimodal init", "widget_time_to_pre_multimodal_ms");
539
+ // Start all initializations in parallel
540
+ const chunkedAssetsStart = performance.now();
541
+ const timeInit = (init, message, metric)=>Promise.resolve(init).finally(()=>this.widget.logTiming(message, metric, performance.now() - chunkedAssetsStart));
542
+ const promises = [
543
+ ...this._iframeManager ? [
544
+ timeInit(this._iframeManager.init(), "Iframe init time", "widget_iframe_init_ms")
545
+ ] : [],
546
+ timeInit(this.initializeAnalytics(), "Analytics init time", "widget_analytics_init_ms"),
547
+ timeInit(this.initializeMultimodalV2(), "Multimodal v2 init time", "widget_multimodal_init_ms")
548
+ ];
549
+ await Promise.all(promises);
550
+ iFrameInitSpan.end();
551
+ this.logTiming("Time to load chunked assets", "widget_chunked_assets_load_ms", performance.now() - chunkedAssetsStart);
552
+ if (this.isDisposed) {
553
+ return;
554
+ }
555
+ this.channel.startEmitter(); // Start sending channel events to Messenger
556
+ this.widget.logTiming("Time to channel emitter started", "widget_time_to_emitter_started_ms");
557
+ await this.recordPerformanceEntries(iFrameInitSpan);
558
+ this.readyState = ReadyState.Ready;
559
+ this.emitWidgetEvent("widgetInitialized");
560
+ // Test dynamic import and code splitting with dummy module
561
+ if ((_this_config_featureFlags = this.config.featureFlags) == null ? void 0 : _this_config_featureFlags.widgetUseShadowDynamicImport) {
562
+ await this.initializeDummyModule();
563
+ }
564
+ this.trackVisitedContentActivity();
565
+ });
566
+ }
567
+ syncInit(config) {
568
+ var _config_experimentSelectors;
569
+ this.loaded = true;
570
+ this.readyState = ReadyState.Initializing;
571
+ const normalizedCurrentURL = normalizeURL(window.location.href);
572
+ const validSelectors = (_config_experimentSelectors = config.experimentSelectors) == null ? void 0 : _config_experimentSelectors.filter((param)=>{
573
+ let { url } = param;
574
+ return hasURLMatch(normalizedCurrentURL, normalizeURL(url), url.endsWith("*"));
575
+ });
576
+ if (validSelectors && validSelectors.length > 0) {
577
+ this.personalizationObserver = new PersonalizationObserver(validSelectors);
578
+ this.personalizationObserver.start();
579
+ }
580
+ this._channel = this.container.resolve("channel");
581
+ this.debugState.channel = this._channel;
582
+ this.initTelemetry();
583
+ }
584
+ debugLog(msg, level, context) {
585
+ if (level === void 0) level = "info";
586
+ if (context === void 0) context = {};
587
+ try {
588
+ if (this.isDebug) {
589
+ const prefix = Object.keys(context).length > 0 ? "[" + Object.entries(context).map((param)=>{
590
+ let [key, value] = param;
591
+ return key + "=" + value;
592
+ }).join(" ") + "] " : "";
593
+ switch(level){
594
+ case "info":
595
+ // eslint-disable-next-line no-console
596
+ console.log("" + prefix + msg);
597
+ break;
598
+ case "error":
599
+ // eslint-disable-next-line no-console
600
+ console.error("" + prefix + msg);
601
+ break;
602
+ case "warn":
603
+ // eslint-disable-next-line no-console
604
+ console.warn("" + prefix + msg);
605
+ break;
606
+ default:
607
+ break;
608
+ }
609
+ }
610
+ } catch (e) {
611
+ // eslint-disable-next-line no-console
612
+ console.error(e);
613
+ }
614
+ }
615
+ serverLog() {
616
+ for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
617
+ args[_key] = arguments[_key];
618
+ }
619
+ // Single choke point every surface's SLI passes through, including the legacy
620
+ // booker's from inside the messenger iframe. Lets the host-side pre-offer
621
+ // tracker close its window on `booker_shown` without a new bridge event.
622
+ observeBookerOutcome(args[0]);
623
+ serverLogger.serverLog(...args);
624
+ }
625
+ async delayInit() {
626
+ this.messengerUptime.dispose();
627
+ const interacted = new Promise((resolve)=>{
628
+ const eventHandler = ()=>{
629
+ __nativeWindowRemoveEventListener("scroll", eventHandler);
630
+ __nativeWindowRemoveEventListener("mousemove", eventHandler);
631
+ resolve(true);
632
+ };
633
+ __nativeWindowAddEventListener("scroll", eventHandler);
634
+ __nativeWindowAddEventListener("mousemove", eventHandler);
635
+ });
636
+ await timing_delay(10000);
637
+ await interacted;
638
+ this.awaitedDelay = true;
639
+ }
640
+ async connectChannel(ignoreInvalidUuid) {
641
+ try {
642
+ await this.channel.connect();
643
+ } catch (reason) {
644
+ switch(reason){
645
+ case "clear_cookies":
646
+ this.visitor.reset();
647
+ this.onRefresh();
648
+ return ConnectState.None;
649
+ case "invalid_uuid":
650
+ // If this visitor's UUID is not unique, generate a new one and try
651
+ // initializing everything again. However, because it's possible
652
+ // that bots using a deterministic implementation random() will
653
+ // generate non-unique UUIDs, we'll limit to a single retry.
654
+ //
655
+ // See https://github.com/FatbearLabs/fireball/issues/1809
656
+ if (!ignoreInvalidUuid) {
657
+ // TODO: move this into init cause it's the one creating the Visitor
658
+ this.visitor.reset();
659
+ }
660
+ return ConnectState.None;
661
+ case "delay_connect":
662
+ var _window_qualified_docking, _window_qualified;
663
+ (_window_qualified = window.qualified) == null ? void 0 : (_window_qualified_docking = _window_qualified.docking) == null ? void 0 : _window_qualified_docking.cancelAbort();
664
+ return ConnectState.DelayConnect;
665
+ case "unauthorized":
666
+ var _window_qualified_docking1, _window_qualified1;
667
+ (_window_qualified1 = window.qualified) == null ? void 0 : (_window_qualified_docking1 = _window_qualified1.docking) == null ? void 0 : _window_qualified_docking1.cancelAbort();
668
+ return ConnectState.None;
669
+ default:
670
+ throw reason;
671
+ }
672
+ }
673
+ return ConnectState.Connected;
674
+ }
675
+ async initializeAnalytics() {
676
+ try {
677
+ if (this.isDisposed) return;
678
+ this.analytics = await this.loadAnalytics();
679
+ this.analytics.init();
680
+ } catch (error) {
681
+ var _getSentryClient;
682
+ const message = error instanceof Error ? error.message : String(error);
683
+ const errorMessage = new Error("Failed to initialize analytics with error: " + message);
684
+ (_getSentryClient = getSentryClient()) == null ? void 0 : _getSentryClient.captureException(errorMessage);
685
+ }
686
+ }
687
+ async initializeOffers() {
688
+ try {
689
+ if (this._offerScript) return;
690
+ this._offerScript = await this.loadOfferScript();
691
+ } catch (error) {
692
+ var _getSentryClient;
693
+ const message = error instanceof Error ? error.message : String(error);
694
+ const errorMessage = new Error("Failed to initialize offers with error: " + message);
695
+ (_getSentryClient = getSentryClient()) == null ? void 0 : _getSentryClient.captureException(errorMessage);
696
+ }
697
+ }
698
+ async initializePageMirror() {
699
+ try {
700
+ if (this.pageMirror) return;
701
+ const pageMirrorFactory = await this.loadPageMirrorFactory();
702
+ this.pageMirror = pageMirrorFactory.create();
703
+ } catch (error) {
704
+ var _getSentryClient;
705
+ const message = error instanceof Error ? error.message : String(error);
706
+ const errorMessage = new Error("Failed to initialize page mirror with error: " + message);
707
+ (_getSentryClient = getSentryClient()) == null ? void 0 : _getSentryClient.captureException(errorMessage);
708
+ }
709
+ }
710
+ async initializeMultimodalV2() {
711
+ var _window_qualified_docking_setAbortStage, _window_qualified_docking, _window_qualified;
712
+ (_window_qualified = window.qualified) == null ? void 0 : (_window_qualified_docking = _window_qualified.docking) == null ? void 0 : (_window_qualified_docking_setAbortStage = _window_qualified_docking.setAbortStage) == null ? void 0 : _window_qualified_docking_setAbortStage.call(_window_qualified_docking, "init_multimodal");
713
+ try {
714
+ if (this.isDisposed) {
715
+ this.multimodalReady.resolve(null);
716
+ return;
717
+ }
718
+ AssetsPreloader.preload(this.config);
719
+ this._multimodal = await this.loadMultimodalV2();
720
+ // dispose() may have run while the multimodal chunk was loading. Disposal
721
+ // already ran cleanup() (which tore down the experienceAdapter) and could
722
+ // not dispose _multimodal, which was unassigned until just now. Calling
723
+ // init() here would mount a RootStore + shadow host, and bindEventsBridge()
724
+ // below would re-subscribe the disposed adapter to that new RootStore —
725
+ // none of which anything would ever clean up. Loading the chunk already
726
+ // attached the multimodal's construction-time observers, so dispose it
727
+ // before bailing.
728
+ if (this.isDisposed) {
729
+ this._multimodal.tryDispose();
730
+ this.multimodalReady.resolve(null);
731
+ return;
732
+ }
733
+ this._multimodal.init();
734
+ this.multimodalReady.resolve(this._multimodal);
735
+ // Bind the events bridge so multimodal transitions reach messenger-event
736
+ // handlers. init() creates the RootStore synchronously.
737
+ this.bindMultimodalEventsBridge();
738
+ } catch (error) {
739
+ var _this_config_featureFlags;
740
+ var _getSentryClient, _this_config_featureFlags1;
741
+ (_getSentryClient = getSentryClient({
742
+ project: "multimodal"
743
+ })) == null ? void 0 : _getSentryClient.captureException(error);
744
+ if ((_this_config_featureFlags1 = this.config.featureFlags) == null ? void 0 : _this_config_featureFlags1.piperXAgent) {
745
+ this.serverLog({
746
+ message: "multimodal_client_error",
747
+ extra: {
748
+ method: "inc"
749
+ }
750
+ });
751
+ }
752
+ // When the page owns the inline meeting booker, the classic iframe lightbox
753
+ // was withheld in its favor (see pageOwnsInlineMeetingBooker), so a failed
754
+ // multimodal_v2 load leaves the visitor with no booking UI at all. Surface
755
+ // that distinctly so it is alertable rather than lost in generic load
756
+ // failures.
757
+ if (pageOwnsInlineMeetingBooker((_this_config_featureFlags = this.config.featureFlags) != null ? _this_config_featureFlags : {})) {
758
+ var _getSentryClient1;
759
+ const detail = error instanceof Error ? error.message : String(error);
760
+ (_getSentryClient1 = getSentryClient({
761
+ project: "multimodal"
762
+ })) == null ? void 0 : _getSentryClient1.captureException(new Error("inline_meeting_booker: multimodal_v2 failed to load; no booking UI rendered (" + detail + ")"));
763
+ }
764
+ this.multimodalReady.reject(error);
765
+ }
766
+ }
767
+ async initializeDummyModule() {
768
+ try {
769
+ const dummyModule = await this.loadDummyModule();
770
+ dummyModule.init();
771
+ } catch (error) {
772
+ var _getSentryClient;
773
+ const message = error instanceof Error ? error.message : String(error);
774
+ const errorMessage = new Error("Failed to initialize dummy module with error: " + message);
775
+ (_getSentryClient = getSentryClient()) == null ? void 0 : _getSentryClient.captureException(errorMessage);
776
+ }
777
+ }
778
+ // This method is overridden in chunked builds to load the appropriate javascript when needed
779
+ async loadAnalytics() {
780
+ return this.container.resolve("analytics");
781
+ }
782
+ // This method is overridden in chunked builds to load the appropriate javascript when needed
783
+ async loadOfferScript() {
784
+ return this.container.resolve("offerScript");
785
+ }
786
+ // This method is overridden in chunked builds to load the appropriate javascript when needed
787
+ async loadPageMirrorFactory() {
788
+ return this.container.resolve("pageMirrorFactory");
789
+ }
790
+ // This method is overridden in chunked builds to load the appropriate javascript when needed
791
+ async loadMultimodalV2() {
792
+ return this.container.resolve("multimodal_v2");
793
+ }
794
+ // This method is overridden in chunked builds to load the appropriate javascript when needed
795
+ async loadDummyModule() {
796
+ return this.container.load("dummyModule");
797
+ }
798
+ // TODO: remove once meeting link has its own pack
799
+ get isMeetingLink() {
800
+ return window.location.origin === this.config.meetingLinkHost;
801
+ }
802
+ // TODO: remove once meeting link has its own pack
803
+ get meetingLinkToken() {
804
+ if (!this.isMeetingLink) return;
805
+ const pathParts = window.location.pathname.replace(/^\//, "").split("-");
806
+ return pathParts[pathParts.length - 1];
807
+ }
808
+ get connectionParams() {
809
+ var _navigator;
810
+ // TODO: get keys from constants in ApplicationCable::Connection
811
+ const data = {
812
+ wv: this.config.version || "",
813
+ token: this.config.token || "",
814
+ vu: this.visitor.uuid,
815
+ wu: this.widgetId,
816
+ ca: this.lastClientActivityAt,
817
+ tz: this.timezone,
818
+ bis: browserIntlSupport(),
819
+ referrer: document.referrer,
820
+ pv: isDomVisible() ? 1 : 0,
821
+ fv: this.config.frontendVersion || "",
822
+ iml: this.isMeetingLink,
823
+ // TODO: remove once meeting link has its own pack
824
+ bl: ((_navigator = navigator) == null ? void 0 : _navigator.language) || null
825
+ };
826
+ const urlParams = new URLSearchParams(document.location.search);
827
+ const demoIp = urlParams.get("q_ip");
828
+ if (demoIp) {
829
+ data.demo_ip = demoIp;
830
+ }
831
+ if (urlParams.get("q_debug_gpt")) {
832
+ data.debug_gpt = true;
833
+ }
834
+ if (this.traceState.isTracing) {
835
+ data.q_trace = this.traceState.traceValue;
836
+ }
837
+ if (this.awaitedDelay) {
838
+ data.ad = 1;
839
+ }
840
+ if (this.appExchangeEnabled) {
841
+ data.hosted = true;
842
+ if (this.config.appexchangeId) {
843
+ data.appxid = this.config.appexchangeId;
844
+ }
845
+ }
846
+ return data;
847
+ }
848
+ get appExchangeEnabled() {
849
+ return this.config.appexchange === true;
850
+ }
851
+ exposeDebugging() {
852
+ // Expose everything for debugging
853
+ Object.assign(window[window.QualifiedObject] || {}, {
854
+ widget: this,
855
+ visitor: this.visitor,
856
+ tracker: this.tracker,
857
+ container: this.container
858
+ });
859
+ }
860
+ abortInit() {
861
+ this.messengerUptime.dispose();
862
+ this.readyState = ReadyState.Failed;
863
+ }
864
+ cleanup() {
865
+ var _this_experienceAdapter_dispose, _this_experienceAdapter, _this__iframeManager_tryDispose, _this__iframeManager, _this__multimodal_tryDispose, _this__multimodal, _this__tracker_tryDispose, _this__tracker, _this__channel_tryDispose, _this__channel, _this_analytics_tryDispose, _this_analytics, _this__visitor_tryDispose, _this__visitor, _this__offerScript_tryDispose, _this__offerScript, _this__pageViewActivityEmitter_tryDispose, _this__pageViewActivityEmitter, _this_cursorPositionProvider_tryDispose, _this_cursorPositionProvider;
866
+ this.messengerUptime.dispose();
867
+ (_this_experienceAdapter = this.experienceAdapter) == null ? void 0 : (_this_experienceAdapter_dispose = _this_experienceAdapter.dispose) == null ? void 0 : _this_experienceAdapter_dispose.call(_this_experienceAdapter);
868
+ (_this__iframeManager = this._iframeManager) == null ? void 0 : (_this__iframeManager_tryDispose = _this__iframeManager.tryDispose) == null ? void 0 : _this__iframeManager_tryDispose.call(_this__iframeManager);
869
+ (_this__multimodal = this._multimodal) == null ? void 0 : (_this__multimodal_tryDispose = _this__multimodal.tryDispose) == null ? void 0 : _this__multimodal_tryDispose.call(_this__multimodal);
870
+ (_this__tracker = this._tracker) == null ? void 0 : (_this__tracker_tryDispose = _this__tracker.tryDispose) == null ? void 0 : _this__tracker_tryDispose.call(_this__tracker);
871
+ if (this.pageMirror && "tryDispose" in this.pageMirror) {
872
+ this.pageMirror.tryDispose();
873
+ }
874
+ this.apiHandler.tryDispose == null ? void 0 : this.apiHandler.tryDispose.call(this.apiHandler);
875
+ (_this__channel = this._channel) == null ? void 0 : (_this__channel_tryDispose = _this__channel.tryDispose) == null ? void 0 : _this__channel_tryDispose.call(_this__channel);
876
+ (_this_analytics = this.analytics) == null ? void 0 : (_this_analytics_tryDispose = _this_analytics.tryDispose) == null ? void 0 : _this_analytics_tryDispose.call(_this_analytics);
877
+ (_this__visitor = this._visitor) == null ? void 0 : (_this__visitor_tryDispose = _this__visitor.tryDispose) == null ? void 0 : _this__visitor_tryDispose.call(_this__visitor);
878
+ (_this__offerScript = this._offerScript) == null ? void 0 : (_this__offerScript_tryDispose = _this__offerScript.tryDispose) == null ? void 0 : _this__offerScript_tryDispose.call(_this__offerScript);
879
+ (_this__pageViewActivityEmitter = this._pageViewActivityEmitter) == null ? void 0 : (_this__pageViewActivityEmitter_tryDispose = _this__pageViewActivityEmitter.tryDispose) == null ? void 0 : _this__pageViewActivityEmitter_tryDispose.call(_this__pageViewActivityEmitter);
880
+ (_this_cursorPositionProvider = this.cursorPositionProvider) == null ? void 0 : (_this_cursorPositionProvider_tryDispose = _this_cursorPositionProvider.tryDispose) == null ? void 0 : _this_cursorPositionProvider_tryDispose.call(_this_cursorPositionProvider);
881
+ this.hubspotFormSubmitListenerDisposers.forEach((disposer)=>disposer());
882
+ this.hubspotFormSubmitListenerDisposers = [];
883
+ this.hubspotV4PollIds.forEach((id)=>widget_clearInterval(id));
884
+ this.hubspotV4PollIds = [];
885
+ this.marketoFormBeforeUnloadDisposer == null ? void 0 : this.marketoFormBeforeUnloadDisposer.call(this);
886
+ this.marketoFormPageHideDisposer == null ? void 0 : this.marketoFormPageHideDisposer.call(this);
887
+ this.container.tryDispose();
888
+ this.loaded = false;
889
+ }
890
+ recordInitTelemetry() {
891
+ var _this_initSpan;
892
+ (_this_initSpan = this.initSpan) == null ? void 0 : _this_initSpan.end();
893
+ widgetBootstrap.endBootstrap();
894
+ }
895
+ initTelemetry() {
896
+ if (!this._channel) return;
897
+ // Arm the messenger uptime SLI for this init attempt; resolveSuccess() fires
898
+ // on the first initState below.
899
+ this.messengerUptime.start();
900
+ // TODO: this section badly needs refactoring
901
+ let botSelectionSpan;
902
+ this.channel.once("initTrackerCreatePageView", ()=>botSelectionSpan = telemetry.startSpan("Select Bot", {}, this.initSpan));
903
+ this.channel.once("initState", ()=>{
904
+ this.messengerUptime.resolveSuccess();
905
+ if (botSelectionSpan) {
906
+ botSelectionSpan.end();
907
+ }
908
+ this.recordInitTelemetry();
909
+ });
910
+ }
911
+ initFormExperience() {
912
+ var _this_config_featureFlags;
913
+ if (!this.tracker.config.hasSmartForms) {
914
+ this.debugState.logEvent("widget:hasSmartForms", "error");
915
+ return;
916
+ }
917
+ this.debugState.logEvent("widget:hasSmartForms", "success");
918
+ if (DebugModeState.isInDebugMode()) {
919
+ try {
920
+ showDebugBanner(this.config.host || "");
921
+ } catch (unused) {
922
+ // eslint-disable-next-line no-console
923
+ console.warn("Error showing debug banner!");
924
+ }
925
+ }
926
+ const _this = this;
927
+ if (typeof window.MktoForms2 !== "undefined") {
928
+ this.debugState.logEvent("widget:marketo:MktoForms2Found", "success");
929
+ this.initMarketoForms();
930
+ } else if (Object.hasOwn(window, "MktoForms2")) {
931
+ // NO-OP: Property exists - our trap is already set up from previous initialization, prevents "Cannot redefine property" errors.
932
+ } else {
933
+ this.debugState.logEvent("widget:marketo:MktoForms2Found", "error");
934
+ let _MktoForms2;
935
+ Object.defineProperty(window, "MktoForms2", {
936
+ get () {
937
+ return _MktoForms2;
938
+ },
939
+ set (value) {
940
+ _MktoForms2 = value;
941
+ widget_setTimeout(()=>{
942
+ try {
943
+ _this.initMarketoForms();
944
+ } catch (error) {
945
+ _this.debugState.logEvent("widget:marketo:initMarketoFormsComplete", "error", {
946
+ error
947
+ });
948
+ }
949
+ }, 0);
950
+ }
951
+ });
952
+ }
953
+ const windowsToCheck = [
954
+ window
955
+ ];
956
+ if ((_this_config_featureFlags = this.config.featureFlags) == null ? void 0 : _this_config_featureFlags.hubspotIframeFormInitialization) {
957
+ const iframeElements = Array.from(document.querySelectorAll("iframe"));
958
+ const iframeWindows = iframeElements.map((iframe)=>tryGet(()=>iframe.contentWindow)).filter(isDefined);
959
+ windowsToCheck.push(...iframeWindows);
960
+ }
961
+ windowsToCheck.forEach((contentWindow)=>{
962
+ // Iframes with cross-origin domains might throw error
963
+ try {
964
+ if (typeof contentWindow.hbspt !== "undefined") {
965
+ this.debugState.logEvent("widget:hubspot:hbsptFound", "success");
966
+ this.initHubspotForms(contentWindow);
967
+ } else if (Object.hasOwn(contentWindow, "hbspt")) {
968
+ // NO-OP: Property exists - our trap is already set up from previous initialization, prevents "Cannot redefine property" errors.
969
+ } else {
970
+ this.debugState.logEvent("widget:hubspot:hbsptFound", "error");
971
+ let _hbspt;
972
+ Object.defineProperty(contentWindow, "hbspt", {
973
+ get () {
974
+ return _hbspt;
975
+ },
976
+ set (value) {
977
+ _hbspt = value;
978
+ widget_setTimeout(()=>{
979
+ try {
980
+ _this.initHubspotForms(contentWindow);
981
+ } catch (error) {
982
+ _this.debugState.logEvent("widget:hubspot:initHubspotFormsComplete", "error", {
983
+ error
984
+ });
985
+ }
986
+ }, 0);
987
+ }
988
+ });
989
+ }
990
+ } catch (error) {
991
+ this.debugState.logEvent("widget:hubspot:window", "error", {
992
+ error
993
+ });
994
+ }
995
+ });
996
+ // HubSpot V4 Forms API - uses native DOM events
997
+ // Unlike V3 (hbspt), V4 uses Object.defineProperty internally and checks for
998
+ // existing properties on window. Using a getter/setter trap prevents HubSpot
999
+ // from initializing its API, so we poll instead.
1000
+ windowsToCheck.forEach((contentWindow)=>{
1001
+ try {
1002
+ if (typeof contentWindow.HubSpotFormsV4 !== "undefined") {
1003
+ this.initHubspotFormsV4(contentWindow);
1004
+ } else {
1005
+ const POLL_INTERVAL_MS = 200;
1006
+ const MAX_POLL_TIME_MS = 30000;
1007
+ let elapsed = 0;
1008
+ const pollId = widget_setInterval(()=>{
1009
+ elapsed += POLL_INTERVAL_MS;
1010
+ if (typeof contentWindow.HubSpotFormsV4 !== "undefined") {
1011
+ widget_clearInterval(pollId);
1012
+ try {
1013
+ _this.initHubspotFormsV4(contentWindow);
1014
+ } catch (error) {
1015
+ _this.debugState.logEvent("widget:hubspotV4:initComplete", "error", {
1016
+ error
1017
+ });
1018
+ }
1019
+ } else if (elapsed >= MAX_POLL_TIME_MS) {
1020
+ widget_clearInterval(pollId);
1021
+ _this.debugState.logEvent("widget:hubspotV4:pollTimeout", "error");
1022
+ }
1023
+ }, POLL_INTERVAL_MS);
1024
+ this.hubspotV4PollIds.push(pollId);
1025
+ }
1026
+ } catch (error) {
1027
+ this.debugState.logEvent("widget:hubspotV4:window", "error", {
1028
+ error
1029
+ });
1030
+ }
1031
+ });
1032
+ }
1033
+ initQualifiedForms() {
1034
+ try {
1035
+ // iframeManager getter throws on v2 (LinkedWidgetV2 doesn't register it).
1036
+ // Forms work without it — only follow-up question sendMessage needs it,
1037
+ // and that's already null-guarded with ?. in QualifiedFormApi (06-01).
1038
+ let iframeManager = null;
1039
+ try {
1040
+ iframeManager = this.iframeManager;
1041
+ } catch (unused) {
1042
+ // v2 path: iframeManager not available, forms work without it
1043
+ }
1044
+ registerCustomElement({
1045
+ channel: this.channel,
1046
+ iframeManager
1047
+ });
1048
+ this.debugState.logEvent("widget:qualifiedForms:initQualifiedForms", "success");
1049
+ } catch (error) {
1050
+ this.debugState.logEvent("widget:qualifiedForms:initQualifiedForms", "error", {
1051
+ error
1052
+ });
1053
+ }
1054
+ }
1055
+ initMarketoForms() {
1056
+ if (typeof window.MktoForms2 === "undefined") {
1057
+ this.debugState.logEvent("widget:marketo:MktoForms2Found", "error", {}, '"window.MktoForms" was previously defined, but is no longer present. This website may have executed javascript which is interfering with the Marketo Smart Form initialization process.');
1058
+ return;
1059
+ }
1060
+ window.MktoForms2.whenReady((mktoForm)=>{
1061
+ if (!this.tracker.config.formBotTriggers.marketo.includes(String(mktoForm.getId()))) return;
1062
+ this.debugState.logEvent("widget:marketo:configuredFormFound", "success", {
1063
+ formId: mktoForm.getId()
1064
+ });
1065
+ mktoForm.onSubmit((form)=>{
1066
+ this.initMarketoFormsRedirectListeners();
1067
+ const values = form.getValues();
1068
+ const formId = values.formid;
1069
+ const formEmail = values.Email;
1070
+ const lengthCheckedValues = this.excludeLongFieldValue(form.getValues(), "marketo");
1071
+ // Store these values temporarily on the instance
1072
+ this.marketoFormSubmitData = lengthCheckedValues;
1073
+ this.debugState.logEvent("widget:marketo:onSubmit", "success", {
1074
+ formId,
1075
+ formEmail
1076
+ });
1077
+ });
1078
+ mktoForm.onSuccess((values, followUpUrl)=>{
1079
+ this.marketoFormSucceededAt = Date.now();
1080
+ const formId = values.formid;
1081
+ const formEmail = values.Email;
1082
+ // Use the stored form data from onSubmit
1083
+ if (this.marketoFormSubmitData) {
1084
+ this.visitor.setFormExperienceDataWithExpiry({
1085
+ formType: "marketo",
1086
+ formData: _extends({}, this.marketoFormSubmitData, {
1087
+ formId,
1088
+ formEmail
1089
+ })
1090
+ });
1091
+ // Track marketo form fill for offers
1092
+ this.tracker.pageViewActivityEmitter.emitFormFill({
1093
+ formType: "marketo"
1094
+ });
1095
+ }
1096
+ this.debugState.logEvent("widget:marketo:onSuccess", "success", {
1097
+ formId
1098
+ });
1099
+ widget_setTimeout(()=>{
1100
+ if (this.marketoFormRedirecting) return;
1101
+ this.debugState.logEvent("widget:marketo:showExperienceForForm", "success", {
1102
+ formId
1103
+ });
1104
+ this.tracker.showExperienceForForm("marketo", {
1105
+ raw: _extends({}, values),
1106
+ formId,
1107
+ formEmail
1108
+ });
1109
+ this.visitor.clearFormExperienceData();
1110
+ this.visitor.setLastValidRebroadcastTime(this.dateProvider.new().getTime() + this.marketoLastValidRebroadcastThreshold);
1111
+ }, this.marketoRedirectThreshold);
1112
+ });
1113
+ this.debugState.logEvent("widget:marketo:configuredFormSetup", "success", {
1114
+ formId: mktoForm.getId()
1115
+ });
1116
+ });
1117
+ this.debugState.logEvent("widget:marketo:initMarketoFormsComplete", "success");
1118
+ }
1119
+ // A Marketo form's followUpUrl indicates there will be a redirect on success, but
1120
+ // customers often override this behavior using custom JS, causing followUpUrl to
1121
+ // be unreliable. Instead, we rely on event listeners to detect page redirects.
1122
+ // Desktop browsers should fire off both beforeunload and pagehide events, whereas
1123
+ // mobile browsers typically only fire the pagehide event. pagehide is more reliable
1124
+ // than beforeunload (source: https://developer.chrome.com/articles/page-lifecycle-api/)
1125
+ initMarketoFormsRedirectListeners() {
1126
+ // This ensures we don't add multiple listeners in case a visitor submits multiple forms
1127
+ if (!this.marketoFormBeforeUnloadDisposer && !this.marketoFormPageHideDisposer) {
1128
+ this.marketoFormBeforeUnloadDisposer = addEventListener(window, "beforeunload", (e)=>{
1129
+ this.logMarketoRedirectEvent("Preparing to navigate", "desktop", MARKETO_REDIRECT_DEFAULT_TIMEOUT_MS);
1130
+ this.marketoFormRedirecting = true;
1131
+ });
1132
+ this.marketoFormPageHideDisposer = addEventListener(window, "pagehide", (e)=>{
1133
+ this.logMarketoRedirectEvent("Navigated", "mobile", MARKETO_REDIRECT_MOBILE_TIMEOUT_MS);
1134
+ this.marketoFormRedirecting = true;
1135
+ });
1136
+ }
1137
+ }
1138
+ logMarketoRedirectEvent(redirectEventLabel, deviceForLogging, thresholdForLogging) {
1139
+ if (this.marketoFormSucceededAt) {
1140
+ const eventOccurredAt = Date.now() - this.marketoFormSucceededAt;
1141
+ // We use redirectEventLabel to abstract away specific names of page lifecycle events
1142
+ this.debugState.logEvent("widget:marketo:redirectEvent", "success", {
1143
+ redirectEventLabel,
1144
+ eventOccurredAt
1145
+ }, redirectEventLabel + " away from page " + eventOccurredAt + "ms after Marketo form submission");
1146
+ if (eventOccurredAt > thresholdForLogging) {
1147
+ this.debugState.logEvent("widget:marketo:redirectEvent", "error", {
1148
+ eventOccurredAt,
1149
+ thresholdForLogging,
1150
+ deviceForLogging
1151
+ }, eventOccurredAt + "ms exceeds the default threshold of " + thresholdForLogging + "ms we allow for form submission on " + deviceForLogging + ". This may prevent the form experience from firing on " + deviceForLogging);
1152
+ }
1153
+ } else {
1154
+ // Unlikely to occur, logging defensively
1155
+ this.debugState.logEvent("widget:marketo:redirectEvent", "error", {}, "Attempting to redirect before Marketo form successfully submitted");
1156
+ }
1157
+ }
1158
+ initHubspotForms(contentWindow) {
1159
+ if (contentWindow === void 0) contentWindow = window;
1160
+ if (typeof contentWindow.hbspt === "undefined") {
1161
+ this.debugState.logEvent("widget:hubspot:hbsptFound", "error", {}, "window.hbspt was previously defined, but is no longer present. This website may have executed javascript which is interfering with the HubSpot Smart Form initialization process.");
1162
+ return;
1163
+ }
1164
+ let formEmail = null;
1165
+ let values = {};
1166
+ const disposer = addEventListener(contentWindow, "message", (event)=>{
1167
+ var _event_data;
1168
+ if (event.origin !== window.location.origin || ((_event_data = event.data) == null ? void 0 : _event_data.type) !== "hsFormCallback" || !this.tracker.config.formBotTriggers.hubspot.includes(event.data.id)) return;
1169
+ if (event.data.eventName === "onFormSubmit") {
1170
+ const email = event.data.data.filter((field)=>field.name === "email");
1171
+ values = event.data.data.reduce((acc, field)=>{
1172
+ acc[field.name] = field.value;
1173
+ return acc;
1174
+ }, {});
1175
+ const lengthCheckedValues = this.excludeLongFieldValue(values, "hubspot");
1176
+ if (email) {
1177
+ formEmail = email[0].value;
1178
+ this.visitor.setFormExperienceDataWithExpiry({
1179
+ formType: "hubspot",
1180
+ formData: _extends({}, lengthCheckedValues, {
1181
+ formId: event.data.id,
1182
+ formEmail
1183
+ })
1184
+ });
1185
+ this.debugState.logEvent("widget:hubspot:onFormSubmit", "success", {
1186
+ formId: event.data.id,
1187
+ formEmail
1188
+ });
1189
+ // Track hubspot form fill for offers
1190
+ this.tracker.pageViewActivityEmitter.emitFormFill({
1191
+ formType: "hubspot"
1192
+ });
1193
+ }
1194
+ }
1195
+ if (event.data.eventName === "onFormSubmitted") {
1196
+ const followUpUrl = event.data.data.redirectUrl;
1197
+ const formId = event.data.id;
1198
+ const formType = "hubspot";
1199
+ if (!followUpUrl && formEmail) {
1200
+ this.tracker.showExperienceForForm(formType, {
1201
+ raw: _extends({}, values),
1202
+ formId,
1203
+ formEmail
1204
+ });
1205
+ this.visitor.clearFormExperienceData();
1206
+ }
1207
+ this.debugState.logEvent("widget:hubspot:onFormSubmitted", "success", {
1208
+ formId,
1209
+ formEmail
1210
+ });
1211
+ }
1212
+ });
1213
+ this.hubspotFormSubmitListenerDisposers.push(disposer);
1214
+ this.debugState.logEvent("widget:hubspot:initHubspotFormsComplete", "success");
1215
+ }
1216
+ // HubSpot V4 Forms API handler - uses native DOM events instead of postMessage
1217
+ initHubspotFormsV4(contentWindow) {
1218
+ if (contentWindow === void 0) contentWindow = window;
1219
+ if (typeof contentWindow.HubSpotFormsV4 === "undefined") {
1220
+ this.debugState.logEvent("widget:hubspotV4:HubSpotFormsV4Found", "error", {}, "window.HubSpotFormsV4 was previously defined, but is no longer present.");
1221
+ return;
1222
+ }
1223
+ this.debugState.logEvent("widget:hubspotV4:HubSpotFormsV4Found", "success");
1224
+ // Track processed submissions to prevent duplicates (in case legacy handler also fires)
1225
+ const processedSubmissions = new Set();
1226
+ const handleSubmissionSuccess = async (event)=>{
1227
+ const customEvent = event;
1228
+ const { formId, instanceId } = customEvent.detail;
1229
+ // Dedupe: create a unique key for this submission
1230
+ const submissionKey = formId + "-" + instanceId;
1231
+ if (processedSubmissions.has(submissionKey)) {
1232
+ return;
1233
+ }
1234
+ // Check if this form is configured in formBotTriggers
1235
+ if (!this.tracker.config.formBotTriggers.hubspot.includes(formId)) {
1236
+ return;
1237
+ }
1238
+ processedSubmissions.add(submissionKey);
1239
+ // Clean up old entries after 5 seconds to allow genuine re-submissions
1240
+ widget_setTimeout(()=>processedSubmissions.delete(submissionKey), 5000);
1241
+ try {
1242
+ const form = contentWindow.HubSpotFormsV4.getFormFromEvent(event);
1243
+ const fieldValues = await form.getFormFieldValues();
1244
+ const redirectUrl = form.getRedirectUrl();
1245
+ // Transform field values to our format (strip HubSpot's "0-1/" prefix from field names)
1246
+ const values = {};
1247
+ let formEmail = null;
1248
+ for (const field of fieldValues){
1249
+ /**
1250
+ * HubSpot V4 Form Field Prefix Pattern
1251
+ *
1252
+ * HubSpot V4 forms prefix field names with a pattern like "0-1/", "1-2/", etc.
1253
+ * This appears to be an internal HubSpot identifier format: {objectTypeId}-{propertyGroupId}/
1254
+ *
1255
+ * Examples observed:
1256
+ * - "0-1/email" -> "email"
1257
+ * - "0-1/firstname" -> "firstname"
1258
+ * - "1-2/company" -> "company"
1259
+ *
1260
+ * IMPORTANT: This pattern is based on observed behavior from HubSpot's V4 API
1261
+ * (as of January 2026) and is NOT explicitly documented by HubSpot. The format
1262
+ * may change in future HubSpot releases. If form field names stop matching,
1263
+ * check HubSpot's getFormFieldValues() response format for changes.
1264
+ *
1265
+ * @see https://developers.hubspot.com/docs/guides/cms/content/forms/global-form-events
1266
+ */ const fieldName = field.name.replace(/^\d+-\d+\//, "");
1267
+ const fieldValue = Array.isArray(field.value) ? field.value.join(", ") : field.value;
1268
+ values[fieldName] = fieldValue;
1269
+ if (fieldName === "email") {
1270
+ formEmail = fieldValue;
1271
+ }
1272
+ }
1273
+ const lengthCheckedValues = this.excludeLongFieldValue(values, "hubspot");
1274
+ if (formEmail) {
1275
+ if (redirectUrl) {
1276
+ // Store data for after redirect (will be processed on next page load)
1277
+ this.visitor.setFormExperienceDataWithExpiry({
1278
+ formType: "hubspot",
1279
+ formData: _extends({}, lengthCheckedValues, {
1280
+ formId,
1281
+ formEmail
1282
+ })
1283
+ });
1284
+ this.debugState.logEvent("widget:hubspotV4:onSubmissionSuccess", "success", {
1285
+ formId,
1286
+ formEmail,
1287
+ hasRedirect: true
1288
+ });
1289
+ } else {
1290
+ // Show experience immediately (no redirect)
1291
+ this.tracker.showExperienceForForm("hubspot", {
1292
+ raw: _extends({}, values),
1293
+ formId,
1294
+ formEmail
1295
+ });
1296
+ this.visitor.clearFormExperienceData();
1297
+ this.debugState.logEvent("widget:hubspotV4:onSubmissionSuccess", "success", {
1298
+ formId,
1299
+ formEmail,
1300
+ hasRedirect: false
1301
+ });
1302
+ }
1303
+ // Track form fill for offers
1304
+ this.tracker.pageViewActivityEmitter.emitFormFill({
1305
+ formType: "hubspot"
1306
+ });
1307
+ }
1308
+ } catch (error) {
1309
+ this.debugState.logEvent("widget:hubspotV4:onSubmissionSuccess", "error", {
1310
+ error
1311
+ });
1312
+ }
1313
+ };
1314
+ const disposer = addEventListener(contentWindow, "hs-form-event:on-submission:success", handleSubmissionSuccess);
1315
+ this.hubspotFormSubmitListenerDisposers.push(disposer);
1316
+ this.debugState.logEvent("widget:hubspotV4:initComplete", "success");
1317
+ }
1318
+ // Browsers typically limit individual cookies to 4096 bytes,
1319
+ // so we check if the whole size of form data exceeds MAP_FORM_DATA_OBJECT_SIZE_LIMIT,
1320
+ // and if it does, delete the values exceeding MAP_FORM_FIELD_SIZE_LIMIT.
1321
+ excludeLongFieldValue(data, formType, formElement) {
1322
+ try {
1323
+ const storedData = {};
1324
+ const exceededLimitKeys = [];
1325
+ let totalSize = 0;
1326
+ switch(formType){
1327
+ case "hubspot":
1328
+ case "marketo":
1329
+ Object.entries(data).forEach((param)=>{
1330
+ let [key, value] = param;
1331
+ if (!MAP_FORM_FIELD_DENY_LIST[formType].includes(key) && typeof value === "string") {
1332
+ storedData[key] = value;
1333
+ totalSize += value.length;
1334
+ if (value.length > (/* inlined export .MAP_FORM_FIELD_SIZE_LIMIT */100)) {
1335
+ exceededLimitKeys.push(key);
1336
+ }
1337
+ }
1338
+ });
1339
+ break;
1340
+ case "pardot":
1341
+ // For pardot, since the name on the input tag is an id and not the field name,
1342
+ // we need to get the field name from the class of the p or div element instead.
1343
+ // Besides, we also need to handle all different types of input.
1344
+ for(let i = 0; formElement && i < formElement.elements.length; i++){
1345
+ const input = formElement.elements[i];
1346
+ const outerTag = input.closest("p") || input.closest("div");
1347
+ if (outerTag && outerTag.className.includes("form-field")) {
1348
+ // The className for the .form-field p/div tag can either be
1349
+ // "form-field first_name pd-text required " (double spaces before field name) or
1350
+ // "form-field name first_name pd-text required ",
1351
+ // so we use "const fieldName = field.className.split(" ")[2];" to get the field name.
1352
+ const fieldName = outerTag.className.split(" ")[2];
1353
+ if (fieldName && !MAP_FORM_FIELD_DENY_LIST[formType].includes(fieldName)) {
1354
+ if (input.nodeName === "SELECT") {
1355
+ if (data[input.id]) {
1356
+ let selectedOptionText;
1357
+ const selectInput = input;
1358
+ for(let i = 0; i < selectInput.options.length; i++){
1359
+ if (selectInput.options[i].value === data[selectInput.id]) {
1360
+ selectedOptionText = selectInput.options[i].textContent;
1361
+ break;
1362
+ }
1363
+ }
1364
+ storedData[fieldName] = selectedOptionText || "";
1365
+ }
1366
+ } else if (input.type === "checkbox") {
1367
+ if (data[input.id]) {
1368
+ var _ref;
1369
+ var _closestLabel_textContent;
1370
+ const closestLabel = outerTag.querySelector('label[for="' + input.id + '"]');
1371
+ const fieldValue = (_ref = closestLabel == null ? void 0 : (_closestLabel_textContent = closestLabel.textContent) == null ? void 0 : _closestLabel_textContent.trim()) != null ? _ref : "";
1372
+ if (storedData[fieldName]) {
1373
+ storedData[fieldName] = storedData[fieldName] + "; " + fieldValue;
1374
+ } else {
1375
+ storedData[fieldName] = fieldValue;
1376
+ }
1377
+ }
1378
+ } else if (input.type === "radio") {
1379
+ var _ref1;
1380
+ var _closestLabel_textContent1;
1381
+ const closestLabel = outerTag.querySelector('label[for="' + input.id + '"]');
1382
+ storedData[fieldName] = (_ref1 = closestLabel == null ? void 0 : (_closestLabel_textContent1 = closestLabel.textContent) == null ? void 0 : _closestLabel_textContent1.trim()) != null ? _ref1 : "";
1383
+ } else {
1384
+ storedData[fieldName] = data[input.id];
1385
+ }
1386
+ const fieldLength = storedData[fieldName] ? storedData[fieldName].length : 0;
1387
+ totalSize += fieldLength;
1388
+ if (fieldLength > (/* inlined export .MAP_FORM_FIELD_SIZE_LIMIT */100)) {
1389
+ exceededLimitKeys.push(fieldName);
1390
+ }
1391
+ }
1392
+ }
1393
+ }
1394
+ break;
1395
+ default:
1396
+ this.debugLog("[Qualified] FormType is not one of the MAP forms.");
1397
+ }
1398
+ if (totalSize > (/* inlined export .MAP_FORM_DATA_OBJECT_SIZE_LIMIT */2048)) {
1399
+ exceededLimitKeys.forEach((key)=>{
1400
+ delete storedData[key];
1401
+ });
1402
+ }
1403
+ return storedData;
1404
+ } catch (e) {
1405
+ this.debugLog("[Qualified] Failed to exclude inputs with long value. Error: " + e);
1406
+ MAP_FORM_FIELD_DENY_LIST[formType].forEach((denyKey)=>{
1407
+ delete data[denyKey];
1408
+ });
1409
+ return data;
1410
+ }
1411
+ }
1412
+ recordPerformanceEntries(iframeSpan) {
1413
+ return new Promise((resolve)=>{
1414
+ // Add snippet download as span
1415
+ // Match by the shared bundle-name predicate rather than hardcoded hosted URLs, so
1416
+ // content-hashed self-hosted zips (qualified-<hash>.js) record their download span too.
1417
+ // npm has no bundle resource (inlined), so this stays empty there — correct.
1418
+ const snippetEntries = performance.getEntries().filter((p)=>p.initiatorType === "script" && isWidgetBundleResource(p.name));
1419
+ this.recordEntriesAsSpans("Download Snippet", snippetEntries, null);
1420
+ this.channel.pingPong("requestAssetPerformanceEntries", "assetPerformanceEntries", {
1421
+ cdnHost: this.config.cdnHost
1422
+ }, (entries)=>{
1423
+ // TODO: ADD Offset from iFrameSpan start
1424
+ this.recordEntriesAsSpans("Download Messenger Asset", JSON.parse(entries), iframeSpan);
1425
+ resolve();
1426
+ });
1427
+ });
1428
+ }
1429
+ recordEntriesAsSpans(name, entries, parentSpan) {
1430
+ if (entries.length === 0) return;
1431
+ entries.forEach((entry)=>{
1432
+ const attributes = {
1433
+ cached: entry.transferSize === 0,
1434
+ url: entry.name
1435
+ };
1436
+ telemetry.recordTimedSpan(name, attributes, parentSpan, entry.startTime, entry.responseEnd);
1437
+ });
1438
+ }
1439
+ recordWidgetLongTaskSpans(name, entries) {
1440
+ if (entries.length === 0) return;
1441
+ entries.forEach((entry)=>{
1442
+ this.channel.perform("record_long_task_spans", {
1443
+ spans: [
1444
+ {
1445
+ name,
1446
+ attributes: {
1447
+ name: entry.name
1448
+ },
1449
+ duration: entry.duration
1450
+ }
1451
+ ]
1452
+ });
1453
+ });
1454
+ }
1455
+ open() {
1456
+ this.experienceAdapter.openMessenger();
1457
+ }
1458
+ // Hide/show the legacy iframe when the session switches between the legacy and
1459
+ // multimodal messengers (e.g. another tab flips the shared session). No-op on
1460
+ // multimodal-only bundles, which have no iframe.
1461
+ hideLegacyMessenger() {
1462
+ var _this__iframeManager;
1463
+ (_this__iframeManager = this._iframeManager) == null ? void 0 : _this__iframeManager.hideMessenger();
1464
+ }
1465
+ showLegacyMessenger() {
1466
+ var _this__iframeManager;
1467
+ (_this__iframeManager = this._iframeManager) == null ? void 0 : _this__iframeManager.showMessenger();
1468
+ }
1469
+ // Record which presentation layer owns the session so the composite adapter
1470
+ // routes visible-behavior verbs/getters to it. Driven by MultimodalChannel on
1471
+ // every initState. No-op on multimodal-only bundles (bare V2Adapter).
1472
+ setMultimodalOwnsSession(owns) {
1473
+ if (this.experienceAdapter instanceof CompositeExperienceAdapter) {
1474
+ this.experienceAdapter.setMultimodalOwnsSession(owns);
1475
+ }
1476
+ }
1477
+ // (Re)bind the events bridge to the current multimodal RootStore. Called at
1478
+ // initial multimodal init AND again whenever multimodal re-owns the session
1479
+ // after a teardown/rebuild (multi-tab reswitch): teardownUI() disposes the
1480
+ // RootStore and ensureUI() builds a fresh one, so a bridge bound only at init
1481
+ // would keep targeting the disposed store for both events and visible-behavior
1482
+ // verbs/getters. bindRootStore() is idempotent — it tears down the previous
1483
+ // binding first — so repeat calls are safe. No-op on non-composite adapters
1484
+ // (bare V2Adapter v2-only bundles bind their RootStore directly) and before
1485
+ // the RootStore exists.
1486
+ bindMultimodalEventsBridge() {
1487
+ var _this__multimodal;
1488
+ const rootStore = (_this__multimodal = this._multimodal) == null ? void 0 : _this__multimodal.rootStore;
1489
+ if (rootStore && this.experienceAdapter instanceof CompositeExperienceAdapter) {
1490
+ this.experienceAdapter.bindEventsBridge(rootStore);
1491
+ }
1492
+ }
1493
+ endExperience() {
1494
+ this.channel.send({
1495
+ event: "endExperience"
1496
+ });
1497
+ }
1498
+ setCookieConsent(hasCookieConsent) {
1499
+ this.config.hasCookieConsent = hasCookieConsent;
1500
+ this.visitor.updatePersistence(hasCookieConsent);
1501
+ }
1502
+ startShipper() {
1503
+ this.iframeManager.startShipper();
1504
+ }
1505
+ stopShipper() {
1506
+ this.iframeManager.stopShipper();
1507
+ }
1508
+ requestKeyframe() {
1509
+ this.iframeManager.requestKeyframe();
1510
+ }
1511
+ registerClientActivity() {
1512
+ window._q_lastClientActivityAt = this.dateProvider.new().toISOString();
1513
+ }
1514
+ resetWidgetId() {
1515
+ this.widgetId = esm_browser_v4();
1516
+ }
1517
+ getSentryClient() {
1518
+ return getSentryClient();
1519
+ }
1520
+ // Returns a Promise that resolves when the widget is ready.
1521
+ // On v1, this waits for the Postmate iframe handshake (Promise<ParentAPI>).
1522
+ // On v2, LinkedWidgetV2 overrides this to return Promise.resolve() — no iframe handshake needed.
1523
+ // Callers only await this Promise; they never use the resolved value.
1524
+ get initialized() {
1525
+ if (this.isIframed) {
1526
+ return Promise.resolve();
1527
+ }
1528
+ return this.iframeManager.widgetHandshake;
1529
+ }
1530
+ // TODO: Maybe this needs some thought about who should own the cable or should there be a further
1531
+ // abstraction of Network or Messaging, etc.
1532
+ get cable() {
1533
+ return this.channel.cable;
1534
+ }
1535
+ get lastClientActivityAt() {
1536
+ return window._q_lastClientActivityAt;
1537
+ }
1538
+ get loaded() {
1539
+ return window._q_widgetInitialized;
1540
+ }
1541
+ set loaded(value) {
1542
+ window._q_widgetInitialized = value;
1543
+ }
1544
+ get widgetInitializedAt() {
1545
+ return window._q_widgetInitializedAt || 0;
1546
+ }
1547
+ set widgetInitializedAt(value) {
1548
+ window._q_widgetInitializedAt = value;
1549
+ }
1550
+ set widgetIdForInitOffers(value) {
1551
+ window._q_widgetIdForInitOffers = value;
1552
+ }
1553
+ get widgetIdForInitOffers() {
1554
+ return window._q_widgetIdForInitOffers;
1555
+ }
1556
+ // Track content activity whenever we land on a page with a content tracking param
1557
+ trackVisitedContentActivity() {
1558
+ const searchParams = new URLSearchParams(window.location.search);
1559
+ const trackingUuid = searchParams.get("q_ct");
1560
+ if (trackingUuid) {
1561
+ this.contentActivityEmitter.emitActivity({
1562
+ type: "visited",
1563
+ trackingUuid
1564
+ });
1565
+ }
1566
+ }
1567
+ constructor(injectionProps, envConfig){
1568
+ super(injectionProps), this.readyState = ReadyState.None, // `config` is initialized as just the EnvironmentConfig from `Widget.start()`, and then extended
1569
+ // later on by the team-level config in `init`
1570
+ this.config = {}, this.isIframed = false, this.isDebug = false, this.initSpan = null, this.awaitedDelay = false, this.isDisposed = false, this.multimodalReady = createBetterPromise(), // This is a reference to the widget instance itself, for use in captureWidgetExceptions
1571
+ this.widget = this, this.hubspotFormSubmitListenerDisposers = [], this.hubspotV4PollIds = [], this.marketoRedirectThreshold = isMobile().any ? MARKETO_REDIRECT_MOBILE_TIMEOUT_MS : MARKETO_REDIRECT_DEFAULT_TIMEOUT_MS, this.marketoLastValidRebroadcastThreshold = MARKETO_LAST_VALID_REBROADCAST_THRESHOLD_MS, this.marketoFormSucceededAt = null, this.marketoFormRedirecting = false, this.traceState = new TraceState(), this.debugState = new DebugState(), this.messengerUptime = new MessengerUptimeTracker(), this.widgetEventsListeners = [], this.marketoFormSubmitData = null, // Helper function to emit debugLog and serverlog for timing info
1572
+ this.logTiming = (debugMessage, metric, deltaOverride, tags)=>{
1573
+ try {
1574
+ // No NaN and no negative/zero values
1575
+ const validDelta = (num)=>!Number.isNaN(num) && num > 0;
1576
+ let delta;
1577
+ if (deltaOverride === undefined) {
1578
+ if (!validDelta(this.widget.widgetInitializedAt)) return;
1579
+ delta = performance.now() - this.widget.widgetInitializedAt;
1580
+ } else {
1581
+ if (!validDelta(deltaOverride)) return;
1582
+ delta = deltaOverride;
1583
+ }
1584
+ if (!validDelta(delta)) return;
1585
+ this.widget.debugLog(debugMessage, "info", {
1586
+ durationMs: delta
1587
+ });
1588
+ this.widget.serverLog({
1589
+ message: metric,
1590
+ type: "log",
1591
+ extra: _extends({
1592
+ method: "dist",
1593
+ operand: delta
1594
+ }, tags ? {
1595
+ tags
1596
+ } : {})
1597
+ });
1598
+ } catch (e) {
1599
+ // Wrap in a try/catch to prevent error-handling code from causing regressions
1600
+ console.warn("Qualified: An unexpected issue occurred in logTiming", e); // eslint-disable-line no-console
1601
+ }
1602
+ }, this.addWidgetEventsListener = (handler)=>{
1603
+ try {
1604
+ this.widgetEventsListeners.push(handler);
1605
+ } catch (e) {
1606
+ console.error("Qualified: Error in Widget#addWidgetEventsListener", e); // eslint-disable-line no-console
1607
+ }
1608
+ }, this.emitWidgetEvent = (eventName)=>{
1609
+ if (this.config.clientApiHandleWidgetEventsEnabled && WIDGET_EVENTS.includes(eventName)) {
1610
+ this.widgetEventsListeners.forEach((eventListener)=>{
1611
+ try {
1612
+ eventListener(eventName);
1613
+ } catch (e) {
1614
+ console.error("Qualified: Error when calling eventListener in Widget#emitWidgetEvent", e); // eslint-disable-line no-console
1615
+ }
1616
+ });
1617
+ }
1618
+ }, // When qualified('teardown') is used. Kills off all objects and re-creates them unintialized.
1619
+ this.onTeardown = ()=>{
1620
+ this.dispose();
1621
+ return this.constructor.start();
1622
+ }, // When backend sends a force refresh message
1623
+ this.onRefresh = ()=>{
1624
+ this.dispose();
1625
+ // npm/bundled consumers own the bundle: our code is inlined into their content-hashed chunk,
1626
+ // so there is no `qualified.js` script tag to remove and re-download. Re-fetching a script is
1627
+ // meaningless here (and previously no-oped silently). Surface it and stop — re-initialisation is
1628
+ // the consumer's call via setup(); this ticket does not add an npm refresh path.
1629
+ if (widgetConsumer() === "npm") {
1630
+ this.debugLog("[Qualified] Force refresh skipped: bundled (npm) consumer owns the widget bundle; " + "no hosted script to reload.");
1631
+ return;
1632
+ }
1633
+ widget_setTimeout(()=>{
1634
+ const oldScript = document.querySelector('script[src*="qualified.js"]');
1635
+ if (oldScript) {
1636
+ oldScript.parentNode.removeChild(oldScript);
1637
+ const newScript = document.createElement("script");
1638
+ newScript.src = oldScript.src + "&" + new Date().getTime();
1639
+ document.head.appendChild(newScript);
1640
+ } else {
1641
+ this.debugLog("[Qualified] Force refresh: no hosted qualified.js script tag found; skipping reload.");
1642
+ }
1643
+ }, Math.floor(Math.random() * 3000) // Delay up to 3s to give backend some breathing room.
1644
+ );
1645
+ };
1646
+ // Ensures that widget is added to the page only once
1647
+ if (this.loaded) {
1648
+ // eslint-disable-next-line no-console
1649
+ console.warn("Qualified widget already initialized. Aborting.");
1650
+ return;
1651
+ }
1652
+ this.config = cloneDeep_default()(envConfig);
1653
+ this.isIframed = isIframed();
1654
+ // The form/CTA pre-offer tracker is a module singleton, so nothing else
1655
+ // unhooks it — unlike the multimodal one, which `RootStore#dispose` owns.
1656
+ // Registered here rather than in `onTeardown` so every disposal path is
1657
+ // covered: `onRefresh` disposes too, and both then restart the widget.
1658
+ this.callOnDispose(disposeFormCtaBookerIntent);
1659
+ this.apiHandler.init();
1660
+ }
1661
+ }
1662
+ // TODO: rename to Supervisor, cause this is now widget/widget/widget.js
1663
+
1664
+ __decorate([
1665
+ captureWidgetExceptions,
1666
+ __metadata("design:type", Function),
1667
+ __metadata("design:paramtypes", [
1668
+ typeof EnvironmentConfig === "undefined" ? Object : EnvironmentConfig
1669
+ ]),
1670
+ __metadata("design:returntype", void 0)
1671
+ ], Widget, "start", null);
1672
+ __decorate([
1673
+ inject,
1674
+ __metadata("design:type", typeof BaseApiHandler === "undefined" ? Object : BaseApiHandler)
1675
+ ], Widget.prototype, "apiHandler", void 0);
1676
+ __decorate([
1677
+ inject,
1678
+ __metadata("design:type", typeof date_provider === "undefined" ? Object : date_provider)
1679
+ ], Widget.prototype, "dateProvider", void 0);
1680
+ __decorate([
1681
+ captureWidgetExceptions,
1682
+ __metadata("design:type", Function),
1683
+ __metadata("design:paramtypes", [
1684
+ String,
1685
+ typeof TeamConfig === "undefined" ? Object : TeamConfig
1686
+ ]),
1687
+ __metadata("design:returntype", Promise)
1688
+ ], Widget.prototype, "init", null);
1689
+ __decorate([
1690
+ captureWidgetExceptions(),
1691
+ __metadata("design:type", Function),
1692
+ __metadata("design:paramtypes", []),
1693
+ __metadata("design:returntype", void 0)
1694
+ ], Widget.prototype, "trackVisitedContentActivity", null);
1695
+
1696
+ var widget_FormStorageKey = /* unused export */ undefined;
1697
+ export { widget_FormStorageKey as FormStorageKey };
1698
+ export default Widget;