flowgrid-sdk 1.2.1 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (312) hide show
  1. package/README.md +221 -250
  2. package/dist/237.flowgrid.min.js +2 -0
  3. package/dist/237.flowgrid.min.js.map +1 -0
  4. package/dist/546.flowgrid.min.js +3 -0
  5. package/dist/546.flowgrid.min.js.LICENSE.txt +14 -0
  6. package/dist/546.flowgrid.min.js.map +1 -0
  7. package/dist/EXAMPLE.d.ts +1 -0
  8. package/dist/EXAMPLE.js +55 -0
  9. package/dist/EXAMPLE.js.map +1 -0
  10. package/dist/browser.d.ts +46 -103
  11. package/dist/browser.js +102 -0
  12. package/dist/browser.js.map +1 -0
  13. package/dist/flowgrid.min.js +1 -1
  14. package/dist/flowgrid.min.js.map +1 -1
  15. package/dist/index.d.ts +7 -8
  16. package/dist/index.js +64 -1
  17. package/dist/index.js.map +1 -1
  18. package/dist/lib/client/transport.d.ts +14 -4
  19. package/dist/lib/client/transport.js +432 -0
  20. package/dist/lib/client/transport.js.map +1 -0
  21. package/dist/lib/consent/index.d.ts +0 -5
  22. package/dist/lib/consent/index.js +32 -0
  23. package/dist/lib/consent/index.js.map +1 -0
  24. package/dist/lib/consent/manager.js +336 -0
  25. package/dist/lib/consent/manager.js.map +1 -0
  26. package/dist/lib/consent/types.d.ts +3 -20
  27. package/dist/lib/consent/types.js +10 -0
  28. package/dist/lib/consent/types.js.map +1 -0
  29. package/dist/lib/features/analytics/attribution.d.ts +6 -47
  30. package/dist/lib/features/analytics/attribution.js +181 -0
  31. package/dist/lib/features/analytics/attribution.js.map +1 -0
  32. package/dist/lib/features/analytics/events.d.ts +1 -28
  33. package/dist/lib/features/analytics/events.js +256 -0
  34. package/dist/lib/features/analytics/events.js.map +1 -0
  35. package/dist/lib/features/analytics/funnels.js +260 -0
  36. package/dist/lib/features/analytics/funnels.js.map +1 -0
  37. package/dist/lib/features/analytics/heatmaps.d.ts +12 -19
  38. package/dist/lib/features/analytics/heatmaps.js +258 -0
  39. package/dist/lib/features/analytics/heatmaps.js.map +1 -0
  40. package/dist/lib/features/analytics/identify.d.ts +1 -21
  41. package/dist/lib/features/analytics/identify.js +213 -0
  42. package/dist/lib/features/analytics/identify.js.map +1 -0
  43. package/dist/lib/features/analytics/index.d.ts +2 -0
  44. package/dist/lib/features/analytics/index.js +15 -0
  45. package/dist/lib/features/analytics/index.js.map +1 -0
  46. package/dist/lib/features/analytics/page-views.d.ts +13 -30
  47. package/dist/lib/features/analytics/page-views.js +268 -0
  48. package/dist/lib/features/analytics/page-views.js.map +1 -0
  49. package/dist/lib/features/analytics/performance.d.ts +18 -24
  50. package/dist/lib/features/analytics/performance.js +232 -0
  51. package/dist/lib/features/analytics/performance.js.map +1 -0
  52. package/dist/lib/features/analytics/replay.d.ts +170 -0
  53. package/dist/lib/features/analytics/replay.js +381 -0
  54. package/dist/lib/features/analytics/replay.js.map +1 -0
  55. package/dist/lib/features/analytics/retention.d.ts +1 -76
  56. package/dist/lib/features/analytics/retention.js +135 -0
  57. package/dist/lib/features/analytics/retention.js.map +1 -0
  58. package/dist/lib/features/analytics/sessions.d.ts +12 -37
  59. package/dist/lib/features/analytics/sessions.js +213 -0
  60. package/dist/lib/features/analytics/sessions.js.map +1 -0
  61. package/dist/lib/features/core/activation.d.ts +1 -24
  62. package/dist/lib/features/core/activation.js +175 -0
  63. package/dist/lib/features/core/activation.js.map +1 -0
  64. package/dist/lib/features/core/experiment.d.ts +53 -21
  65. package/dist/lib/features/core/experiment.js +554 -0
  66. package/dist/lib/features/core/experiment.js.map +1 -0
  67. package/dist/lib/features/core/index.js +9 -0
  68. package/dist/lib/features/core/index.js.map +1 -0
  69. package/dist/lib/features/core/track-feature.d.ts +1 -8
  70. package/dist/lib/features/core/track-feature.js +119 -0
  71. package/dist/lib/features/core/track-feature.js.map +1 -0
  72. package/dist/lib/features/core/track-prompt.d.ts +5 -8
  73. package/dist/lib/features/core/track-prompt.js +181 -0
  74. package/dist/lib/features/core/track-prompt.js.map +1 -0
  75. package/dist/lib/features/ecommerce/cart.d.ts +1 -24
  76. package/dist/lib/features/ecommerce/cart.js +244 -0
  77. package/dist/lib/features/ecommerce/cart.js.map +1 -0
  78. package/dist/lib/features/ecommerce/checkout.d.ts +1 -28
  79. package/dist/lib/features/ecommerce/checkout.js +254 -0
  80. package/dist/lib/features/ecommerce/checkout.js.map +1 -0
  81. package/dist/lib/features/ecommerce/index.d.ts +0 -2
  82. package/dist/lib/features/ecommerce/index.js +15 -0
  83. package/dist/lib/features/ecommerce/index.js.map +1 -0
  84. package/dist/lib/features/ecommerce/ltv.d.ts +1 -69
  85. package/dist/lib/features/ecommerce/ltv.js +114 -0
  86. package/dist/lib/features/ecommerce/ltv.js.map +1 -0
  87. package/dist/lib/features/ecommerce/products.d.ts +1 -33
  88. package/dist/lib/features/ecommerce/products.js +223 -0
  89. package/dist/lib/features/ecommerce/products.js.map +1 -0
  90. package/dist/lib/features/ecommerce/promotions.d.ts +1 -30
  91. package/dist/lib/features/ecommerce/promotions.js +197 -0
  92. package/dist/lib/features/ecommerce/promotions.js.map +1 -0
  93. package/dist/lib/features/ecommerce/purchases.d.ts +1 -48
  94. package/dist/lib/features/ecommerce/purchases.js +193 -0
  95. package/dist/lib/features/ecommerce/purchases.js.map +1 -0
  96. package/dist/lib/features/ecommerce/refunds.d.ts +1 -27
  97. package/dist/lib/features/ecommerce/refunds.js +195 -0
  98. package/dist/lib/features/ecommerce/refunds.js.map +1 -0
  99. package/dist/lib/features/ecommerce/search.d.ts +1 -24
  100. package/dist/lib/features/ecommerce/search.js +156 -0
  101. package/dist/lib/features/ecommerce/search.js.map +1 -0
  102. package/dist/lib/features/ecommerce/subscriptions.d.ts +1 -28
  103. package/dist/lib/features/ecommerce/subscriptions.js +207 -0
  104. package/dist/lib/features/ecommerce/subscriptions.js.map +1 -0
  105. package/dist/lib/features/ecommerce/wishlist.d.ts +1 -28
  106. package/dist/lib/features/ecommerce/wishlist.js +186 -0
  107. package/dist/lib/features/ecommerce/wishlist.js.map +1 -0
  108. package/dist/lib/features/enterprise/acquisition.d.ts +2 -57
  109. package/dist/lib/features/enterprise/acquisition.js +166 -0
  110. package/dist/lib/features/enterprise/acquisition.js.map +1 -0
  111. package/dist/lib/features/enterprise/alerts.d.ts +1 -37
  112. package/dist/lib/features/enterprise/alerts.js +246 -0
  113. package/dist/lib/features/enterprise/alerts.js.map +1 -0
  114. package/dist/lib/features/enterprise/churn.d.ts +1 -42
  115. package/dist/lib/features/enterprise/churn.js +175 -0
  116. package/dist/lib/features/enterprise/churn.js.map +1 -0
  117. package/dist/lib/features/enterprise/cohorts.d.ts +1 -37
  118. package/dist/lib/features/enterprise/cohorts.js +201 -0
  119. package/dist/lib/features/enterprise/cohorts.js.map +1 -0
  120. package/dist/lib/features/enterprise/engagement.d.ts +40 -46
  121. package/dist/lib/features/enterprise/engagement.js +335 -0
  122. package/dist/lib/features/enterprise/engagement.js.map +1 -0
  123. package/dist/lib/features/enterprise/forecasting.d.ts +0 -50
  124. package/dist/lib/features/enterprise/forecasting.js +232 -0
  125. package/dist/lib/features/enterprise/forecasting.js.map +1 -0
  126. package/dist/lib/features/enterprise/index.d.ts +1 -1
  127. package/dist/lib/features/enterprise/index.js +76 -0
  128. package/dist/lib/features/enterprise/index.js.map +1 -0
  129. package/dist/lib/features/enterprise/monetization.d.ts +1 -60
  130. package/dist/lib/features/enterprise/monetization.js +146 -0
  131. package/dist/lib/features/enterprise/monetization.js.map +1 -0
  132. package/dist/lib/features/enterprise/multi-path-funnels.d.ts +1 -17
  133. package/dist/lib/features/enterprise/multi-path-funnels.js +205 -0
  134. package/dist/lib/features/enterprise/multi-path-funnels.js.map +1 -0
  135. package/dist/lib/features/enterprise/paths.d.ts +1 -56
  136. package/dist/lib/features/enterprise/paths.js +149 -0
  137. package/dist/lib/features/enterprise/paths.js.map +1 -0
  138. package/dist/lib/features/enterprise/security.d.ts +8 -57
  139. package/dist/lib/features/enterprise/security.js +202 -0
  140. package/dist/lib/features/enterprise/security.js.map +1 -0
  141. package/dist/lib/features/enterprise/support.d.ts +3 -42
  142. package/dist/lib/features/enterprise/support.js +162 -0
  143. package/dist/lib/features/enterprise/support.js.map +1 -0
  144. package/dist/lib/flowgrid.d.ts +278 -0
  145. package/dist/lib/flowgrid.js +323 -0
  146. package/dist/lib/flowgrid.js.map +1 -0
  147. package/dist/lib/frameworks/index.d.ts +13 -6
  148. package/dist/lib/frameworks/index.js +18 -0
  149. package/dist/lib/frameworks/index.js.map +1 -0
  150. package/dist/lib/frameworks/nextjs/client.js +355 -0
  151. package/dist/lib/frameworks/nextjs/client.js.map +1 -0
  152. package/dist/lib/frameworks/nextjs/index.js +31 -0
  153. package/dist/lib/frameworks/nextjs/index.js.map +1 -0
  154. package/dist/lib/frameworks/nextjs/server.js +259 -0
  155. package/dist/lib/frameworks/nextjs/server.js.map +1 -0
  156. package/dist/lib/frameworks/node/index.js +391 -0
  157. package/dist/lib/frameworks/node/index.js.map +1 -0
  158. package/dist/lib/frameworks/nuxt/index.js +288 -0
  159. package/dist/lib/frameworks/nuxt/index.js.map +1 -0
  160. package/dist/lib/frameworks/react/CookieBanner.js +166 -0
  161. package/dist/lib/frameworks/react/CookieBanner.js.map +1 -0
  162. package/dist/lib/frameworks/react/index.js +271 -0
  163. package/dist/lib/frameworks/react/index.js.map +1 -0
  164. package/dist/lib/frameworks/vue/CookieBanner.js +165 -0
  165. package/dist/lib/frameworks/vue/CookieBanner.js.map +1 -0
  166. package/dist/lib/frameworks/vue/index.js +390 -0
  167. package/dist/lib/frameworks/vue/index.js.map +1 -0
  168. package/dist/lib/tracking/analytics/attribution.d.ts +14 -0
  169. package/dist/lib/tracking/analytics/attribution.js +18 -0
  170. package/dist/lib/tracking/analytics/attribution.js.map +1 -0
  171. package/dist/lib/tracking/analytics/events.d.ts +26 -0
  172. package/dist/lib/tracking/analytics/events.js +30 -0
  173. package/dist/lib/tracking/analytics/events.js.map +1 -0
  174. package/dist/lib/tracking/analytics/funnels.d.ts +16 -0
  175. package/dist/lib/tracking/analytics/funnels.js +22 -0
  176. package/dist/lib/tracking/analytics/funnels.js.map +1 -0
  177. package/dist/lib/tracking/analytics/heatmaps.d.ts +27 -0
  178. package/dist/lib/tracking/analytics/heatmaps.js +22 -0
  179. package/dist/lib/tracking/analytics/heatmaps.js.map +1 -0
  180. package/dist/lib/tracking/analytics/identify.d.ts +16 -0
  181. package/dist/lib/tracking/analytics/identify.js +22 -0
  182. package/dist/lib/tracking/analytics/identify.js.map +1 -0
  183. package/dist/lib/tracking/analytics/index.d.ts +10 -0
  184. package/dist/lib/tracking/analytics/index.js +11 -0
  185. package/dist/lib/tracking/analytics/index.js.map +1 -0
  186. package/dist/lib/tracking/analytics/page-views.d.ts +29 -0
  187. package/dist/lib/tracking/analytics/page-views.js +50 -0
  188. package/dist/lib/tracking/analytics/page-views.js.map +1 -0
  189. package/dist/lib/tracking/analytics/performance.d.ts +22 -0
  190. package/dist/lib/tracking/analytics/performance.js +22 -0
  191. package/dist/lib/tracking/analytics/performance.js.map +1 -0
  192. package/dist/lib/tracking/analytics/replay.d.ts +34 -0
  193. package/dist/lib/tracking/analytics/replay.js +46 -0
  194. package/dist/lib/tracking/analytics/replay.js.map +1 -0
  195. package/dist/lib/tracking/analytics/retention.d.ts +10 -0
  196. package/dist/lib/tracking/analytics/retention.js +10 -0
  197. package/dist/lib/tracking/analytics/retention.js.map +1 -0
  198. package/dist/lib/tracking/analytics/sessions.d.ts +20 -0
  199. package/dist/lib/tracking/analytics/sessions.js +26 -0
  200. package/dist/lib/tracking/analytics/sessions.js.map +1 -0
  201. package/dist/lib/tracking/core/activation.d.ts +23 -0
  202. package/dist/lib/tracking/core/activation.js +33 -0
  203. package/dist/lib/tracking/core/activation.js.map +1 -0
  204. package/dist/lib/tracking/core/experiment.d.ts +122 -0
  205. package/dist/lib/tracking/core/experiment.js +150 -0
  206. package/dist/lib/tracking/core/experiment.js.map +1 -0
  207. package/dist/lib/tracking/core/feature.d.ts +13 -0
  208. package/dist/lib/tracking/core/feature.js +14 -0
  209. package/dist/lib/tracking/core/feature.js.map +1 -0
  210. package/dist/lib/tracking/core/index.d.ts +4 -0
  211. package/dist/lib/tracking/core/index.js +5 -0
  212. package/dist/lib/tracking/core/index.js.map +1 -0
  213. package/dist/lib/tracking/core/prompt.d.ts +18 -0
  214. package/dist/lib/tracking/core/prompt.js +26 -0
  215. package/dist/lib/tracking/core/prompt.js.map +1 -0
  216. package/dist/lib/tracking/ecommerce/cart.d.ts +17 -0
  217. package/dist/lib/tracking/ecommerce/cart.js +22 -0
  218. package/dist/lib/tracking/ecommerce/cart.js.map +1 -0
  219. package/dist/lib/tracking/ecommerce/checkout.d.ts +17 -0
  220. package/dist/lib/tracking/ecommerce/checkout.js +22 -0
  221. package/dist/lib/tracking/ecommerce/checkout.js.map +1 -0
  222. package/dist/lib/tracking/ecommerce/index.d.ts +10 -0
  223. package/dist/lib/tracking/ecommerce/index.js +11 -0
  224. package/dist/lib/tracking/ecommerce/index.js.map +1 -0
  225. package/dist/lib/tracking/ecommerce/ltv.d.ts +15 -0
  226. package/dist/lib/tracking/ecommerce/ltv.js +14 -0
  227. package/dist/lib/tracking/ecommerce/ltv.js.map +1 -0
  228. package/dist/lib/tracking/ecommerce/products.d.ts +15 -0
  229. package/dist/lib/tracking/ecommerce/products.js +18 -0
  230. package/dist/lib/tracking/ecommerce/products.js.map +1 -0
  231. package/dist/lib/tracking/ecommerce/promotions.d.ts +14 -0
  232. package/dist/lib/tracking/ecommerce/promotions.js +25 -0
  233. package/dist/lib/tracking/ecommerce/promotions.js.map +1 -0
  234. package/dist/lib/tracking/ecommerce/purchases.d.ts +11 -0
  235. package/dist/lib/tracking/ecommerce/purchases.js +10 -0
  236. package/dist/lib/tracking/ecommerce/purchases.js.map +1 -0
  237. package/dist/lib/tracking/ecommerce/refunds.d.ts +17 -0
  238. package/dist/lib/tracking/ecommerce/refunds.js +22 -0
  239. package/dist/lib/tracking/ecommerce/refunds.js.map +1 -0
  240. package/dist/lib/tracking/ecommerce/search.d.ts +24 -0
  241. package/dist/lib/tracking/ecommerce/search.js +22 -0
  242. package/dist/lib/tracking/ecommerce/search.js.map +1 -0
  243. package/dist/lib/tracking/ecommerce/subscriptions.d.ts +21 -0
  244. package/dist/lib/tracking/ecommerce/subscriptions.js +38 -0
  245. package/dist/lib/tracking/ecommerce/subscriptions.js.map +1 -0
  246. package/dist/lib/tracking/ecommerce/wishlist.d.ts +19 -0
  247. package/dist/lib/tracking/ecommerce/wishlist.js +26 -0
  248. package/dist/lib/tracking/ecommerce/wishlist.js.map +1 -0
  249. package/dist/lib/tracking/enterprise/acquisition.d.ts +25 -0
  250. package/dist/lib/tracking/enterprise/acquisition.js +22 -0
  251. package/dist/lib/tracking/enterprise/acquisition.js.map +1 -0
  252. package/dist/lib/tracking/enterprise/alerts.d.ts +32 -0
  253. package/dist/lib/tracking/enterprise/alerts.js +30 -0
  254. package/dist/lib/tracking/enterprise/alerts.js.map +1 -0
  255. package/dist/lib/tracking/enterprise/churn.d.ts +23 -0
  256. package/dist/lib/tracking/enterprise/churn.js +22 -0
  257. package/dist/lib/tracking/enterprise/churn.js.map +1 -0
  258. package/dist/lib/tracking/enterprise/cohorts.d.ts +18 -0
  259. package/dist/lib/tracking/enterprise/cohorts.js +18 -0
  260. package/dist/lib/tracking/enterprise/cohorts.js.map +1 -0
  261. package/dist/lib/tracking/enterprise/engagement.d.ts +31 -0
  262. package/dist/lib/tracking/enterprise/engagement.js +44 -0
  263. package/dist/lib/tracking/enterprise/engagement.js.map +1 -0
  264. package/dist/lib/tracking/enterprise/forecasting.d.ts +18 -0
  265. package/dist/lib/tracking/enterprise/forecasting.js +22 -0
  266. package/dist/lib/tracking/enterprise/forecasting.js.map +1 -0
  267. package/dist/lib/tracking/enterprise/index.d.ts +11 -0
  268. package/dist/lib/tracking/enterprise/index.js +12 -0
  269. package/dist/lib/tracking/enterprise/index.js.map +1 -0
  270. package/dist/lib/tracking/enterprise/monetization.d.ts +14 -0
  271. package/dist/lib/tracking/enterprise/monetization.js +10 -0
  272. package/dist/lib/tracking/enterprise/monetization.js.map +1 -0
  273. package/dist/lib/tracking/enterprise/multi-path-funnels.d.ts +20 -0
  274. package/dist/lib/tracking/enterprise/multi-path-funnels.js +18 -0
  275. package/dist/lib/tracking/enterprise/multi-path-funnels.js.map +1 -0
  276. package/dist/lib/tracking/enterprise/paths.d.ts +20 -0
  277. package/dist/lib/tracking/enterprise/paths.js +18 -0
  278. package/dist/lib/tracking/enterprise/paths.js.map +1 -0
  279. package/dist/lib/tracking/enterprise/security.d.ts +28 -0
  280. package/dist/lib/tracking/enterprise/security.js +26 -0
  281. package/dist/lib/tracking/enterprise/security.js.map +1 -0
  282. package/dist/lib/tracking/enterprise/support.d.ts +25 -0
  283. package/dist/lib/tracking/enterprise/support.js +22 -0
  284. package/dist/lib/tracking/enterprise/support.js.map +1 -0
  285. package/dist/lib/tracking/index.d.ts +4 -0
  286. package/dist/lib/tracking/index.js +5 -0
  287. package/dist/lib/tracking/index.js.map +1 -0
  288. package/dist/lib/types/analytics.d.ts +10 -2
  289. package/dist/lib/types/analytics.js +6 -0
  290. package/dist/lib/types/analytics.js.map +1 -0
  291. package/dist/lib/types/common.js +6 -0
  292. package/dist/lib/types/common.js.map +1 -0
  293. package/dist/lib/types/ecommerce.js +6 -0
  294. package/dist/lib/types/ecommerce.js.map +1 -0
  295. package/dist/lib/types/index.js +8 -0
  296. package/dist/lib/types/index.js.map +1 -0
  297. package/dist/lib/utils/browser.d.ts +16 -0
  298. package/dist/lib/utils/browser.js +32 -0
  299. package/dist/lib/utils/browser.js.map +1 -0
  300. package/dist/lib/utils/identity.js +346 -0
  301. package/dist/lib/utils/identity.js.map +1 -0
  302. package/dist/lib/utils/storage.js +105 -0
  303. package/dist/lib/utils/storage.js.map +1 -0
  304. package/dist/umd/237.index.js +2 -0
  305. package/dist/umd/237.index.js.map +1 -0
  306. package/dist/umd/546.index.js +3 -0
  307. package/dist/umd/546.index.js.LICENSE.txt +14 -0
  308. package/dist/umd/546.index.js.map +1 -0
  309. package/dist/umd/index.js +2 -0
  310. package/dist/umd/index.js.map +1 -0
  311. package/package.json +27 -80
  312. package/dist/lib/features/ecommerce/inventory.d.ts +0 -219
@@ -0,0 +1,2 @@
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.FlowGridSDK=e():t.FlowGridSDK=e()}(this,()=>(()=>{"use strict";var t,e,i={},r={};function n(t){var e=r[t];if(void 0!==e)return e.exports;var s=r[t]={exports:{}};return i[t](s,s.exports,n),s.exports}n.m=i,n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.f={},n.e=t=>Promise.all(Object.keys(n.f).reduce((e,i)=>(n.f[i](t,e),e),[])),n.u=t=>t+".index.js",n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),t={},e="FlowGridSDK:",n.l=(i,r,s,a)=>{if(t[i])t[i].push(r);else{var o,c;if(void 0!==s)for(var u=document.getElementsByTagName("script"),p=0;p<u.length;p++){var d=u[p];if(d.getAttribute("src")==i||d.getAttribute("data-webpack")==e+s){o=d;break}}o||(c=!0,(o=document.createElement("script")).charset="utf-8",n.nc&&o.setAttribute("nonce",n.nc),o.setAttribute("data-webpack",e+s),o.src=i),t[i]=[r];var l=(e,r)=>{o.onerror=o.onload=null,clearTimeout(m);var n=t[i];if(delete t[i],o.parentNode&&o.parentNode.removeChild(o),n&&n.forEach(t=>t(r)),e)return e(r)},m=setTimeout(l.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=l.bind(null,o.onerror),o.onload=l.bind(null,o.onload),c&&document.head.appendChild(o)}},n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t;n.g.importScripts&&(t=n.g.location+"");var e=n.g.document;if(!t&&e&&(e.currentScript&&"SCRIPT"===e.currentScript.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){var i=e.getElementsByTagName("script");if(i.length)for(var r=i.length-1;r>-1&&(!t||!/^http(s?):/.test(t));)t=i[r--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=t})(),(()=>{var t={792:0};n.f.j=(e,i)=>{var r=n.o(t,e)?t[e]:void 0;if(0!==r)if(r)i.push(r[2]);else{var s=new Promise((i,n)=>r=t[e]=[i,n]);i.push(r[2]=s);var a=n.p+n.u(e),o=new Error;n.l(a,i=>{if(n.o(t,e)&&(0!==(r=t[e])&&(t[e]=void 0),r)){var s=i&&("load"===i.type?"missing":i.type),a=i&&i.target&&i.target.src;o.message="Loading chunk "+e+" failed.\n("+s+": "+a+")",o.name="ChunkLoadError",o.type=s,o.request=a,r[1](o)}},"chunk-"+e,e)}};var e=(e,i)=>{var r,s,[a,o,c]=i,u=0;if(a.some(e=>0!==t[e])){for(r in o)n.o(o,r)&&(n.m[r]=o[r]);c&&c(n)}for(e&&e(i);u<a.length;u++)s=a[u],n.o(t,s)&&t[s]&&t[s][0](),t[s]=0},i=this.webpackChunkFlowGridSDK=this.webpackChunkFlowGridSDK||[];i.forEach(e.bind(null,0)),i.push=e.bind(null,i.push.bind(i))})();var s={};n.d(s,{default:()=>Rt});class a{constructor(t,e,i,r,n,s){if(!t?.trim()||!e?.trim())throw new Error("SDK init failed: webId and endpoint are required.");this.webId=t.trim(),this.endpoint=this.normalizeEndpoint(e),this.apiKey=i,this.identityManager=n,this.visitorId=r??"",this.transportConfig={botDetection:s?.botDetection??"block",respectDNT:s?.respectDNT??!0,sampleRate:s?.sampleRate??1},this.drainEventBuffer()}static setConsent(t){Object.assign(a.consent,t)}static hasConsent(t){return a.consent[t]??!1}static isLikelyBot(){return!("undefined"==typeof navigator||!navigator.webdriver&&!/bot|crawl|spider|headless|phantom|puppeteer/i.test(navigator.userAgent))}isDNTEnabled(){return"undefined"!=typeof navigator&&(!!navigator.globalPrivacyControl||"1"===navigator.doNotTrack)}static getDeviceContext(){return"undefined"==typeof window||"undefined"==typeof navigator?{}:{_screen_width:window.screen?.width,_screen_height:window.screen?.height,_device_type:/Mobi|Android/i.test(navigator.userAgent)?"mobile":"desktop",_language:navigator.language}}sendViaBeacon(t,e={}){if("undefined"==typeof navigator||"function"!=typeof navigator.sendBeacon)return!1;const i=this.identityManager?this.identityManager.getVisitorId():this.visitorId??"",r=e.type||"event",n=`${this.endpoint}/api/v1/sdk/functions?call=${encodeURIComponent(r)}`,s=JSON.stringify({web_id:this.webId,visitor_id:i,event_name:t,properties:{...e,...a.getDeviceContext()}});return navigator.sendBeacon(n,new Blob([s],{type:"application/json"}))}async postRaw(t,e,i={}){if(!1===a.consent.analytics)return;if(!1!==this.transportConfig.respectDNT&&this.isDNTEnabled())return;const r=`${this.endpoint}/api/v1/sdk/functions?call=${encodeURIComponent(t)}`,n=this.identityManager?this.identityManager.getVisitorId():this.visitorId??"",s=JSON.stringify({web_id:this.webId,visitor_id:n,...e});if(i.useBeacon&&"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon)navigator.sendBeacon(r,new Blob([s],{type:"application/json"}));else try{await fetch(r,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:s,keepalive:!0})}catch{}}bufferEvent(t,e,i){if("undefined"!=typeof localStorage)try{const r=localStorage.getItem(a.EVENT_BUFFER_KEY),n=r?JSON.parse(r):[];if(n.length>=a.MAX_BUFFER_EVENTS)return;const s=JSON.stringify([...n,{url:t,method:e,body:i}]);if((new TextEncoder).encode(s).length>a.MAX_BUFFER_SIZE)return;n.push({url:t,method:e,body:i}),localStorage.setItem(a.EVENT_BUFFER_KEY,JSON.stringify(n))}catch{}}drainEventBuffer(){if("undefined"!=typeof localStorage)try{const t=localStorage.getItem(a.EVENT_BUFFER_KEY);if(!t)return;const e=JSON.parse(t);localStorage.removeItem(a.EVENT_BUFFER_KEY);for(const t of e)fetch(t.url,{method:t.method,headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:t.body}).catch(()=>{})}catch{}}async init(t,e={},i="POST"){if(!a.hasConsent("analytics"))return{};if(this.transportConfig.respectDNT&&this.isDNTEnabled())return{};if("block"===this.transportConfig.botDetection&&a.isLikelyBot())return{};this.validateInput(t,e),"tag"===this.transportConfig.botDetection&&a.isLikelyBot()&&(e={...e,_bot:!0});const r={...a.getDeviceContext(),...e},n=r.type||"event",s=`${this.endpoint}/api/v1/sdk/functions?call=${encodeURIComponent(n)}`,o=this.identityManager?this.identityManager.getVisitorId():this.visitorId??"",c=JSON.stringify({web_id:this.webId,visitor_id:o,event_name:t,properties:r});return this.executeRequest(s,i,"GET"===i?void 0:c)}async initFeature(t,e){if(this.validateInput(t,e),!e.type)throw new Error("Feature events must include a type property");const i=`${this.endpoint}/api/v1/sdk/functions?call=${encodeURIComponent(e.type)}`,r=this.identityManager?this.identityManager.getVisitorId():this.visitorId??"",n=JSON.stringify({web_id:this.webId,visitor_id:r,event_name:t,properties:e});return this.executeRequest(i,"POST",n)}async executeRequest(t,e,i,r){let n=0;for(;;){const s=new AbortController,o=setTimeout(()=>s.abort(),a.TIMEOUT_MS);try{const c=await fetch(t,{method:e,headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`,...r},body:i,signal:s.signal});if(clearTimeout(o),c.status>=500&&n<a.MAX_RETRIES){n++,await this.backoff(n);continue}if(!c.ok){const t=await this.safeRead(c);throw new Error(`SDK request failed (${c.status} ${c.statusText}) ${t}`)}return await c.json()}catch(r){if(clearTimeout(o),r instanceof Error&&("AbortError"===r.name||r.message.includes("fetch"))&&n<a.MAX_RETRIES){n++,await this.backoff(n);continue}if(n>=a.MAX_RETRIES&&(i&&"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon&&navigator.sendBeacon(t,new Blob([i],{type:"application/json"}))||this.bufferEvent(t,e,i)),r instanceof Error&&"AbortError"===r.name)throw new Error("SDK request timed out");throw r}}}backoff(t){const e=1e3*Math.pow(2,t-1);return new Promise(t=>setTimeout(t,e))}validateInput(t,e){if(!t||"string"!=typeof t||!t.trim())throw new Error("Event name must be a non-empty string");if(t.length>100)throw new Error("Event name must be less than 100 characters");let i;try{i=JSON.stringify({web_id:this.webId,visitor_id:this.visitorId??"",event_name:t,properties:e})}catch{throw new Error("Properties must be JSON serializable")}if((new TextEncoder).encode(i).length>a.MAX_PAYLOAD_SIZE)throw new Error("Event payload too large (max 10KB)");const r=["password","token","secret","apikey","authorization"],n=i.toLowerCase();for(const t of r)n.includes(t)&&console.warn(`SDK Warning: Properties may contain sensitive data (${t}).`)}normalizeEndpoint(t){let e=t.trim();return e.startsWith("http://")||e.startsWith("https://")||(e=`https://${e}`),e.replace(/\/+$/,"")}async safeRead(t){try{return await t.text()}catch{return""}}}function o(t){if("undefined"==typeof document)return null;const e=document.cookie.match(new RegExp("(^| )"+t+"=([^;]+)"));return e?e[2]:null}a.MAX_PAYLOAD_SIZE=1e4,a.TIMEOUT_MS=1e4,a.MAX_RETRIES=3,a.MAX_BUFFER_EVENTS=100,a.MAX_BUFFER_SIZE=5e4,a.EVENT_BUFFER_KEY="fg_event_buffer",a.consent={analytics:!0,marketing:!0};const c="fg_visitor_id",u="fg_session_id",p="fg_session_touch";class d{constructor(t){this.visitorId="",this.sessionId="",this.memoryStore={},this.config={visitorId:t?.visitorId??"",cookieDomain:t?.cookieDomain??"",visitorMaxAgeDays:t?.visitorMaxAgeDays??365,sessionTimeoutMinutes:t?.sessionTimeoutMinutes??30,storage:t?.storage??(this.detectBrowser()?"cookie":"memory"),serverCookies:t?.serverCookies,compat:t?.compat??!0},this.visitorId=this.resolveVisitorId(),this.sessionId=""}getVisitorId(){return this.visitorId||(this.visitorId=this.resolveVisitorId()),this.visitorId}getSessionId(){if("memory"===this.config.storage)return this.getMemorySessionId();if(!this.detectBrowser())return this.getMemorySessionId();try{const t=sessionStorage.getItem(u),e=sessionStorage.getItem(p);if(t&&e){if(Date.now()-parseInt(e,10)<60*this.config.sessionTimeoutMinutes*1e3)return sessionStorage.setItem(p,String(Date.now())),this.sessionId=t,t}const i=this.generateSessionId();return sessionStorage.setItem(u,i),sessionStorage.setItem(p,String(Date.now())),this.sessionId=i,i}catch{return this.getMemorySessionId()}}setVisitorId(t){this.visitorId=t,this.persistVisitorId(t)}clearSession(){if(this.sessionId="",delete this.memoryStore[u],delete this.memoryStore[p],this.detectBrowser())try{sessionStorage.removeItem(u),sessionStorage.removeItem(p)}catch{}}clearAll(){if(this.visitorId="",this.sessionId="",this.memoryStore={},this.detectBrowser())try{this.deleteCookie(this.visitorCookieName),this.deleteCookie(c),localStorage.removeItem(this.visitorCookieName),localStorage.removeItem(c),localStorage.removeItem("fg_exp_assignments"),sessionStorage.removeItem(u),sessionStorage.removeItem(p)}catch{}}isBrowser(){return this.detectBrowser()}get visitorCookieName(){return this.config.compat?"visitor_id":c}resolveVisitorId(){if(this.config.visitorId)return this.config.visitorId;if(this.detectBrowser()){const t=function(){try{return o("visitor_id")||localStorage.getItem("visitor_id")}catch{return o("visitor_id")}}();if(t){const e=this.readCookie(c)||this.readLocalStorage(c);return e&&e!==t&&this.removeLegacyCookie(),this.persistVisitorId(t),t}}if(this.config.compat){const t=this.readCookie(c)||this.readLocalStorage(c);if(t)return this.persistVisitorId(t),this.removeLegacyCookie(),t}const t=this.readCookie(this.visitorCookieName);if(t)return t;if(this.detectBrowser())try{const t=localStorage.getItem(this.visitorCookieName);if(t)return t}catch{}if(this.config.serverCookies){const t=this.readServerCookie(this.visitorCookieName);if(t)return t}if(this.memoryStore[this.visitorCookieName])return this.memoryStore[this.visitorCookieName];const e=this.generateVisitorId();return this.persistVisitorId(e),e}readLocalStorage(t){if(!this.detectBrowser())return null;try{return localStorage.getItem(t)}catch{return null}}removeLegacyCookie(){if(this.deleteCookie(c),this.detectBrowser())try{localStorage.removeItem(c)}catch{}}persistVisitorId(t){const e=this.visitorCookieName;if("memory"!==this.config.storage)if(this.detectBrowser()){this.writeCookie(e,t,this.config.visitorMaxAgeDays);try{localStorage.setItem(e,t)}catch{}}else this.memoryStore[e]=t;else this.memoryStore[e]=t}getMemorySessionId(){const t=this.memoryStore[u],e=this.memoryStore[p];if(t&&e&&Date.now()-parseInt(e,10)<60*this.config.sessionTimeoutMinutes*1e3)return this.memoryStore[p]=String(Date.now()),this.sessionId=t,t;const i=this.generateSessionId();return this.memoryStore[u]=i,this.memoryStore[p]=String(Date.now()),this.sessionId=i,i}readCookie(t){return this.config.serverCookies?this.readServerCookie(t):this.detectBrowser()?o(t):null}readServerCookie(t){if(!this.config.serverCookies)return null;const e=this.config.serverCookies.get(t);return e?"object"==typeof e&&"value"in e?e.value||null:"string"==typeof e&&e||null:null}writeCookie(t,e,i){if(!this.detectBrowser())return;const r=24*i*60*60,n=this.config.cookieDomain?`; Domain=${this.config.cookieDomain}`:"",s="https:"===location.protocol?"; Secure":"";document.cookie=`${t}=${encodeURIComponent(e)}; Path=/; Max-Age=${r}; SameSite=Lax${s}${n}`}deleteCookie(t){if(!this.detectBrowser())return;const e=this.config.cookieDomain?`; Domain=${this.config.cookieDomain}`:"";document.cookie=`${t}=; Path=/; Max-Age=0${e}`}generateVisitorId(){return`fg_${this.uuidV4()}`}generateSessionId(){return`fgs_${Date.now()}_${this.randomHex(8)}`}uuidV4(){return"undefined"!=typeof crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})}randomHex(t){const e=new Uint8Array(t);if("undefined"!=typeof crypto&&crypto.getRandomValues)crypto.getRandomValues(e);else for(let i=0;i<t;i++)e[i]=Math.floor(256*Math.random());return Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}detectBrowser(){return"undefined"!=typeof window&&"undefined"!=typeof document}}class l extends a{async create(t){return await this.init(t.eventName,{...t.properties,type:"activation",timestamp:(new Date).toISOString()})}async trackOnboardingStep(t){return await this.init("onboarding_step",{type:"activation",subtype:"onboarding_step",userId:t.userId,stepId:t.stepId,stepName:t.stepName,stepOrder:t.stepOrder,totalSteps:t.totalSteps,progress:Math.round(t.stepOrder/t.totalSteps*100),timeSpent:t.timeSpent,skipped:t.skipped||!1,...t.properties,timestamp:(new Date).toISOString()})}async completeOnboarding(t,e,i,r){return await this.init("onboarding_completed",{type:"activation",subtype:"onboarding_complete",userId:t,totalTimeSpent:e,stepsCompleted:i,stepsSkipped:r,completionRate:Math.round(i/(i+r)*100),timestamp:(new Date).toISOString()})}async trackFirstAction(t){return await this.init("first_action",{type:"activation",subtype:"first_action",userId:t.userId,actionName:t.actionName,timeSinceSignup:t.timeSinceSignup,source:t.source,...t.properties,timestamp:(new Date).toISOString()})}async trackSignup(t,e,i,r){return await this.init("signup_completed",{type:"activation",subtype:"signup",userId:t,method:e,source:i,...r,timestamp:(new Date).toISOString()})}}class m extends a{async create(t){return await this.init("create_tracking",{type:"feature_usage",subtype:"create_custom",userId:t.userId,category:t.category,action:t.action,...t.properties,timestamp:(new Date).toISOString()})}async trackUsage(t){return await this.init("feature_usage",{type:"feature_usage",subtype:t.action,featureId:t.featureId,featureName:t.featureName,userId:t.userId,action:t.action,duration:t.duration,success:t.success,category:t.category,...t.properties,timestamp:(new Date).toISOString()})}}class h extends a{async create(t){return await this.init(t.eventName,{...t.properties,type:"prompt",timestamp:(new Date).toISOString()})}async trackSubmission(t){return await this.init("prompt_submitted",{type:"prompt",subtype:"submission",promptId:t.promptId,userId:t.userId,promptType:t.promptType,model:t.model,inputTokens:t.inputTokens,conversationId:t.conversationId,...t.properties,timestamp:(new Date).toISOString()})}async trackResponse(t){return await this.init("prompt_response",{type:"prompt",subtype:"response",promptId:t.promptId,responseTime:t.responseTime,outputTokens:t.outputTokens,completed:t.completed,error:t.error,qualityScore:t.qualityScore,timestamp:(new Date).toISOString()})}async trackFeedback(t){return await this.init("prompt_feedback",{type:"prompt",subtype:"feedback",promptId:t.promptId,userId:t.userId,feedbackType:t.feedbackType,rating:t.rating,comment:t.comment,timestamp:(new Date).toISOString()})}async trackConversation(t,e,i,r){return await this.init("prompt_conversation",{type:"prompt",subtype:"conversation",conversationId:t,userId:e,turnCount:i,totalDuration:r,timestamp:(new Date).toISOString()})}}function y(t){let e=2166136261;for(let i=0;i<t.length;i++)e^=t.charCodeAt(i),e=16777619*e>>>0;return e}const g="fg_exp_assignments",I="fg_exp_assignments";class w extends a{constructor(){super(...arguments),this.experiments={},this.assignments={}}parseAssignmentCookie(t){if(!t)return{};try{const e=decodeURIComponent(t),i=JSON.parse(e);return i&&"object"==typeof i?i:{}}catch{return{}}}readAssignmentCookie(){return this.parseAssignmentCookie(o(I))}writeAssignmentCookie(){try{if("undefined"==typeof document)return;const t=encodeURIComponent(JSON.stringify(this.assignments)),e=31536e3,i="Lax",r="undefined"!=typeof location&&"https:"===location.protocol?"; Secure":"";document.cookie=`${I}=${t}; Path=/; Max-Age=${e}; SameSite=${i}${r}`}catch{}}loadAssignments(){try{if("undefined"!=typeof localStorage){const t=localStorage.getItem(g);if(t){const e=JSON.parse(t);if(e&&"object"==typeof e)return e}}}catch{}const t=this.readAssignmentCookie();return Object.keys(t).length>0?t:{}}saveAssignments(){try{"undefined"!=typeof localStorage&&localStorage.setItem(g,JSON.stringify(this.assignments))}catch{}this.writeAssignmentCookie()}injectAssignments(t){this.assignments={...this.assignments,...t}}getAssignments(){return{...this.assignments}}hydrateFromCookies(t){const e=t.get(I),i="string"==typeof e?e:e?.value??null,r=this.parseAssignmentCookie(i??null);Object.keys(r).length>0&&this.injectAssignments(r)}hydrateFromCookieHeader(t){if(!t)return;const e=t.split(/;\s*/),i=`${I}=`,r=e.find(t=>t.startsWith(i));if(!r)return;const n=this.parseAssignmentCookie(r.slice(i.length));Object.keys(n).length>0&&this.injectAssignments(n)}serializeAssignmentCookie(){const t=encodeURIComponent(JSON.stringify(this.assignments));return`${I}=${t}; Path=/; Max-Age=31536000; SameSite=Lax`}clearAssignments(){this.assignments={};try{"undefined"!=typeof localStorage&&localStorage.removeItem(g)}catch{}try{"undefined"!=typeof document&&(document.cookie=`${I}=; Path=/; Max-Age=0; SameSite=Lax`)}catch{}}getOrCreateAnonId(){try{if("undefined"!=typeof localStorage){const t=localStorage.getItem(w.ANON_ID_KEY);if(t)return t;const e="undefined"!=typeof crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)});return localStorage.setItem(w.ANON_ID_KEY,e),e}}catch{}return"anon_"+y(String(Math.random())).toString(36)}deterministicAssign(t,e,i){const r=y(t+e);let n=0;for(const t of i)n+=t.weight;const s=r%1e4/1e4*n;let a=0;for(const t of i)if(a+=t.weight,s<a)return t.id;return i[i.length-1].id}assignVariant(t,e){this.assignments=this.loadAssignments();const i=this.assignments[t];if(i&&e.some(t=>t.id===i))return;const r=this.identityManager?.getVisitorId?.()||this.visitorId||this.getOrCreateAnonId(),n=this.deterministicAssign(r,t,e);this.assignments[t]=n,this.saveAssignments(),this.init("experiment_assignment",{type:"experiment",subtype:"assignment",experimentId:t,userId:r,variantId:n,source:"random",assignmentSource:"sdk_init",timestamp:(new Date).toISOString()}).catch(()=>{})}async verifyExperiments(t){const e={web_id:this.webId,experiments:t.map(t=>({experiment_id:t.id,variants:t.variants,properties:t.properties||{}}))};try{const t=await fetch(`${this.endpoint}/api/v1/experiments/verify`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),i=await t.json();if(i.ok&&Array.isArray(i.data))for(const t of i.data)"error"!==t.action&&(this.experiments[t.experiment_id]={variants:t.variants,properties:t.properties??{},verified:!0},this.assignVariant(t.experiment_id,t.variants))}catch{for(const e of t)this.experiments[e.id]={variants:e.variants,properties:e.properties||{},verified:!1},this.assignVariant(e.id,e.variants)}}async initExperiments(t){this.assignments=this.loadAssignments(),t.length>0&&await this.verifyExperiments(t)}getLocalVariant(t){return this.assignments=this.loadAssignments(),this.assignments[t]??null}async trackLocalConversion(t,e="conversion",i=1){const r=this.getLocalVariant(t);if(!r)return;const n=this.identityManager?.getVisitorId?.()||this.visitorId||this.getOrCreateAnonId();await this.init("experiment_conversion",{type:"experiment",subtype:"conversion",experimentId:t,userId:n,variantId:r,metricName:e,value:i,timestamp:(new Date).toISOString()})}async track(t){return await this.init(t.eventName,{...t.properties,type:"experiment",subtype:"custom",variant:t.variant,timestamp:(new Date).toISOString()})}async define(t){return await this.init("experiment_definition",{type:"experiment",subtype:"definition",...t,timestamp:(new Date).toISOString()})}async assign(t){return await this.init("experiment_assignment",{type:"experiment",subtype:"assignment",experimentId:t.experimentId,userId:t.userId,variantId:t.variantId,source:t.source||"random",timestamp:(new Date).toISOString()})}async trackConversion(t){return await this.init("experiment_conversion",{type:"experiment",subtype:"conversion",experimentId:t.experimentId,userId:t.userId,variantId:t.variantId,metricName:t.metricName,value:t.value,timestamp:(new Date).toISOString()})}async trackExposure(t,e,i){return await this.init("experiment_exposure",{type:"experiment",subtype:"exposure",experimentId:t,userId:e,variantId:i,timestamp:(new Date).toISOString()})}}function f(){return"undefined"!=typeof window?window:void 0}function S(){return"undefined"!=typeof document?document:void 0}function v(){return"undefined"!=typeof window&&"undefined"!=typeof document}function _(...t){return()=>{for(const e of t)if("function"==typeof e)try{e()}catch{}}}w.ANON_ID_KEY="fg_anon_id";class k extends a{async track(t){return await this.init("page_view",{type:"page_view",url:t.url,path:t.path,title:t.title||"",referrer:t.referrer||"",userId:t.userId,sessionId:t.sessionId,...t.properties,timestamp:(new Date).toISOString()})}async trackScrollDepth(t){return await this.init("scroll_depth",{type:"scroll_depth",path:t.path,scrollDepth:Math.min(100,Math.max(0,t.scrollDepth)),timeAtDepth:t.timeAtDepth,timestamp:(new Date).toISOString()})}async trackTimeOnPage(t){return await this.init("time_on_page",{type:"time_on_page",path:t.path,duration:t.duration,engaged:t.engaged??!1,timestamp:(new Date).toISOString()})}async trackExit(t,e,i){return await this.init("page_exit",{type:"page_exit",path:t,duration:e,scrollDepth:i,timestamp:(new Date).toISOString()})}autoTrack(t={}){if(!v())return()=>{};const e=f(),i=S();let r=e.location.pathname,n=Date.now(),s=0;const a=new Set,o=()=>{this.track({url:e.location.href,path:e.location.pathname,title:i.title,referrer:i.referrer,userId:t.userId,sessionId:t.sessionId})},c=()=>{const t=Math.round((Date.now()-n)/1e3);t<=0||this.trackTimeOnPage({path:r,duration:t,engaged:s>10})},u=()=>{e.location.pathname!==r&&(c(),r=e.location.pathname,n=Date.now(),s=0,a.clear(),o())},p=e.history.pushState,d=e.history.replaceState;e.history.pushState=function(...t){const i=p.apply(this,t);return e.dispatchEvent(new Event("flowgrid:locationchange")),i},e.history.replaceState=function(...t){const i=d.apply(this,t);return e.dispatchEvent(new Event("flowgrid:locationchange")),i};const l=()=>u(),m=()=>u();e.addEventListener("popstate",l),e.addEventListener("flowgrid:locationchange",m);const h=()=>{const t=i.documentElement,n=e.scrollY||t.scrollTop,o=Math.max(1,t.scrollHeight-e.innerHeight),c=Math.min(100,Math.round(n/o*100));c>s&&(s=c);for(const t of[25,50,75,100])c>=t&&!a.has(t)&&(a.add(t),this.trackScrollDepth({path:r,scrollDepth:t}))};e.addEventListener("scroll",h,{passive:!0});const y=()=>{"hidden"===i.visibilityState&&c()};return i.addEventListener("visibilitychange",y),e.addEventListener("pagehide",c),o(),_(()=>e.removeEventListener("popstate",l),()=>e.removeEventListener("flowgrid:locationchange",m),()=>e.removeEventListener("scroll",h),()=>i.removeEventListener("visibilitychange",y),()=>e.removeEventListener("pagehide",c),()=>{e.history.pushState=p,e.history.replaceState=d})}}class b extends a{async start(t={}){return await this.init("session_start",{type:"session_start",user:t.user,device:t.device,location:t.location,source:t.source||t.utm?.utmSource,medium:t.medium||t.utm?.utmMedium,campaign:t.campaign||t.utm?.utmCampaign,utm:t.utm,landingPage:t.landingPage||("undefined"!=typeof window?window.location.href:""),referrer:t.referrer||("undefined"!=typeof document?document.referrer:""),...t.properties,timestamp:(new Date).toISOString()})}async update(t,e){return await this.init("session_update",{type:"session_update",sessionId:t,...e,timestamp:(new Date).toISOString()})}async end(t){return await this.init("session_end",{type:"session_end",sessionId:t,timestamp:(new Date).toISOString()})}async heartbeat(t){return await this.init("session_heartbeat",{type:"session_heartbeat",sessionId:t,timestamp:(new Date).toISOString()})}autoTrack(t={},e={}){if(!v())return()=>{};const i=f(),r=S(),n=e.heartbeatMs??3e4,s="flowgrid:sessionId";let a;try{a=i.sessionStorage.getItem(s)||void 0}catch{}const o=a?Promise.resolve(a):this.start(t).then(t=>{a=t.response.sessionId;try{i.sessionStorage.setItem(s,a)}catch{}return a}).catch(()=>{}),c=i.setInterval(()=>{a&&"visible"===r.visibilityState&&this.heartbeat(a)},n),u=()=>{a&&this.end(a)};return i.addEventListener("pagehide",u),_(()=>i.clearInterval(c),()=>i.removeEventListener("pagehide",u),()=>{o.then(()=>{a&&this.end(a)})},()=>{try{i.sessionStorage.removeItem(s)}catch{}})}}class D extends a{async track(t){return await this.init("custom_event",{type:"custom_event",eventName:t.eventName,category:t.category||"general",action:t.action,label:t.label,value:t.value,nonInteraction:t.nonInteraction||!1,userId:t.userId,sessionId:t.sessionId,...t.properties,timestamp:(new Date).toISOString()})}async trackBatch(t){const e=t.events.map(t=>({...t,timestamp:(new Date).toISOString()}));return await this.init("batch_events",{type:"batch_events",events:e,count:e.length,timestamp:(new Date).toISOString()})}async trackClick(t){return await this.init("click_event",{type:"click_event",...t,timestamp:(new Date).toISOString()})}async trackForm(t){return await this.init("form_event",{type:"form_event",...t,timestamp:(new Date).toISOString()})}async trackSearch(t){return await this.init("search_event",{type:"search_event",query:t.query,category:t.category,resultsCount:t.resultsCount,resultClicked:t.resultClicked,clickedPosition:t.clickedPosition,filters:t.filters,timestamp:(new Date).toISOString()})}async trackError(t){return await this.init("error_event",{type:"error_event",message:t.message,stack:t.stack,errorType:t.type,fatal:t.fatal||!1,context:t.context,userAction:t.userAction,timestamp:(new Date).toISOString()})}}class O extends a{async user(t){return await this.init("identify_user",{type:"identify",userId:t.userId,anonymousId:t.anonymousId,traits:t.traits||{},timestamp:(new Date).toISOString()})}async updateTraits(t,e){return await this.init("update_traits",{type:"update_traits",userId:t,traits:e,timestamp:(new Date).toISOString()})}async alias(t){return await this.init("alias_user",{type:"alias",previousId:t.previousId,userId:t.userId,timestamp:(new Date).toISOString()})}async group(t){return await this.init("group_user",{type:"group",userId:t.userId,groupId:t.groupId,traits:t.traits||{},timestamp:(new Date).toISOString()})}async reset(t){return await this.init("reset_identity",{type:"reset",userId:t,timestamp:(new Date).toISOString()})}}class x extends a{async define(t){return await this.init("define_funnel",{type:"define_funnel",funnelId:t.funnelId,name:t.name,description:t.description,steps:t.steps,timestamp:(new Date).toISOString()})}async trackStep(t){return await this.init("funnel_step",{type:"funnel_step",funnelId:t.funnelId,step:t.step,stepNumber:t.stepNumber,userId:t.userId,sessionId:t.sessionId,...t.properties,timestamp:(new Date).toISOString()})}async trackComplete(t,e,i){return await this.init("funnel_complete",{type:"funnel_complete",funnelId:t,userId:e,...i,timestamp:(new Date).toISOString()})}async trackAbandon(t,e,i,r){return await this.init("funnel_abandon",{type:"funnel_abandon",funnelId:t,lastStep:e,userId:i,reason:r,timestamp:(new Date).toISOString()})}async analyze(t,e){return await this.init("analyze_funnel",{type:"query",funnelId:t,filter:e||{range:"last30days"},timestamp:(new Date).toISOString()})}async compare(t,e,i){return await this.init("compare_funnel",{type:"query",funnelId:t,baselineFilter:e,comparisonFilter:i,timestamp:(new Date).toISOString()})}async list(){return await this.init("list_funnels",{type:"query",timestamp:(new Date).toISOString()})}}class C extends a{async trackActivity(t){return await this.init("user_activity",{type:"user_activity",userId:t.userId,action:t.action||"active",sessionId:t.sessionId,...t.properties,timestamp:(new Date).toISOString()})}async trackLifecycleChange(t,e,i){return await this.init("lifecycle_change",{type:"lifecycle_change",userId:t,stage:e,previousStage:i,timestamp:(new Date).toISOString()})}}class T extends a{async trackTouchpoint(t){return await this.init("attribution_touchpoint",{type:"attribution_touchpoint",userId:t.userId,channel:t.channel,campaign:t.campaign,medium:t.medium,source:t.source,content:t.content,term:t.term,referrer:t.referrer,landingPage:t.landingPage,...t.properties,timestamp:(new Date).toISOString()})}async recordConversion(t){return await this.init("attribution_conversion",{type:"attribution_conversion",userId:t.userId,conversionType:t.conversionType,value:t.value,conversionId:t.conversionId,...t.properties,timestamp:(new Date).toISOString()})}captureFromUrl(t){if(!v())return null;const e=f(),i=S();if(!e||!i)return null;const r=new URLSearchParams(e.location.search),n={utmSource:r.get("utm_source")??void 0,utmMedium:r.get("utm_medium")??void 0,utmCampaign:r.get("utm_campaign")??void 0,utmTerm:r.get("utm_term")??void 0,utmContent:r.get("utm_content")??void 0},s=i.referrer||void 0;if(!(n.utmSource||n.utmMedium||n.utmCampaign||s))return null;const a={userId:t,channel:n.utmSource||(s?"referral":"direct"),campaign:n.utmCampaign,medium:n.utmMedium,source:n.utmSource,content:n.utmContent,term:n.utmTerm,referrer:s,landingPage:e.location.pathname};return this.trackTouchpoint(a),a}}class E extends a{constructor(){super(...arguments),this.lastMovementTime=0,this.lastScrollTime=0}async trackClick(t){return await this.init("heatmap_click",{type:"heatmap_click",pageUrl:t.pageUrl,x:t.x,y:t.y,normalizedX:t.x/t.viewportWidth,normalizedY:t.y/t.viewportHeight,viewportWidth:t.viewportWidth,viewportHeight:t.viewportHeight,elementSelector:t.elementSelector,elementText:t.elementText?.substring(0,50),userId:t.userId,sessionId:t.sessionId,timestamp:(new Date).toISOString()})}async trackMovement(t){const e=Date.now();return e-this.lastMovementTime<E.MOVEMENT_THROTTLE_MS?{eventName:"heatmap_movement",properties:{},response:{recorded:!1,interactionId:""},timestamp:(new Date).toISOString()}:(this.lastMovementTime=e,await this.init("heatmap_movement",{type:"heatmap_movement",pageUrl:t.pageUrl,path:t.path,viewport:t.viewport,sessionId:t.sessionId,timestamp:(new Date).toISOString()}))}async trackScroll(t){const e=Date.now();return e-this.lastScrollTime<E.SCROLL_THROTTLE_MS?{eventName:"heatmap_scroll",properties:{},response:{recorded:!1,interactionId:""},timestamp:(new Date).toISOString()}:(this.lastScrollTime=e,await this.init("heatmap_scroll",{type:"heatmap_scroll",pageUrl:t.pageUrl,maxScrollDepth:t.maxScrollDepth,pageHeight:t.pageHeight,viewportHeight:t.viewportHeight,timeAtDepths:t.timeAtDepths,sessionId:t.sessionId,timestamp:(new Date).toISOString()}))}async trackRageClick(t,e,i,r){return await this.init("heatmap_rage_click",{type:"heatmap_rage_click",pageUrl:t,x:e,y:i,clickCount:r,timestamp:(new Date).toISOString()})}autoTrack(t={}){if(!v())return()=>{};const e=f(),i=S(),r=i=>{const r=i.target;var n;this.trackClick({pageUrl:e.location.pathname,x:i.clientX,y:i.clientY+e.scrollY,viewportWidth:e.innerWidth,viewportHeight:e.innerHeight,elementSelector:(n=r,n?n.id?`#${n.id}`:`${n.tagName.toLowerCase()}${n.className&&"string"==typeof n.className?"."+n.className.trim().split(/\s+/).slice(0,2).join("."):""}`:""),elementText:(r?.textContent||"").trim().slice(0,50),userId:t.userId,sessionId:t.sessionId})};i.addEventListener("click",r,{capture:!0,passive:!0});let n=0;const s=()=>{const r=i.documentElement,s=e.scrollY||r.scrollTop,a=Math.max(1,r.scrollHeight-e.innerHeight),o=Math.min(100,Math.round(s/a*100));o>n&&(n=o),this.trackScroll({pageUrl:e.location.pathname,maxScrollDepth:n,pageHeight:r.scrollHeight,viewportHeight:e.innerHeight,sessionId:t.sessionId})};let a;if(e.addEventListener("scroll",s,{passive:!0}),t.movement){let r=[];const n=Date.now(),s=i=>{if(r.push({x:i.clientX,y:i.clientY,t:Date.now()-n}),r.length>=50){const i=r;r=[],this.trackMovement({pageUrl:e.location.pathname,path:i,viewport:{width:e.innerWidth,height:e.innerHeight},sessionId:t.sessionId})}};i.addEventListener("mousemove",s,{passive:!0}),a=()=>i.removeEventListener("mousemove",s)}return _(()=>i.removeEventListener("click",r,{capture:!0}),()=>e.removeEventListener("scroll",s),a)}}E.MOVEMENT_THROTTLE_MS=100,E.SCROLL_THROTTLE_MS=500;class A extends a{async trackWebVitals(t){return await this.init("web_vitals",{type:"web_vitals",...t,timestamp:(new Date).toISOString()})}async trackPageLoad(t){return await this.init("page_load",{type:"page_load",...t,timestamp:(new Date).toISOString()})}async trackResource(t){return await this.init("resource_timing",{type:"resource_timing",...t,timestamp:(new Date).toISOString()})}async trackApiCall(t,e,i,r){return await this.init("api_timing",{type:"api_timing",endpoint:t,duration:e,success:i,statusCode:r,timestamp:(new Date).toISOString()})}autoTrack(t={}){if(!v())return()=>{};const e=f(),i=e.location.pathname,r=[];let s=!1;n.e(237).then(n.bind(n,237)).then(e=>{if(s)return;const r=e=>{const r=e.name.toLowerCase(),n={pageUrl:i,userId:t.userId};n[r]=e.value,this.trackWebVitals(n)};e.onLCP?.(r),e.onCLS?.(r),e.onINP?.(r),e.onFCP?.(r),e.onTTFB?.(r),e.onFID?.(r)}).catch(()=>{}),r.push(()=>{s=!0});const a=()=>{const t=e.performance?.getEntriesByType?.("navigation")?.[0];t&&this.trackPageLoad({pageUrl:i,dnsTime:Math.max(0,t.domainLookupEnd-t.domainLookupStart),tcpTime:Math.max(0,t.connectEnd-t.connectStart),ttfb:Math.max(0,t.responseStart-t.requestStart),domContentLoaded:t.domContentLoadedEventEnd,loadTime:t.loadEventEnd,domInteractive:t.domInteractive,transferSize:t.transferSize})};if("complete"===e.document.readyState)a();else{const t=()=>a();e.addEventListener("load",t,{once:!0}),r.push(()=>e.removeEventListener("load",t))}if(t.resources&&"function"==typeof e.PerformanceObserver){const n=t.minDuration??200,s=new e.PerformanceObserver(t=>{for(const e of t.getEntries()){if(e.duration<n)continue;const t=e.initiatorType;this.trackResource({resourceUrl:e.name,resourceType:["script","stylesheet","image","font","fetch","xhr"].includes(t)?t:"other",duration:Math.round(e.duration),transferSize:e.transferSize,pageUrl:i})}});try{s.observe({type:"resource",buffered:!0}),r.push(()=>s.disconnect())}catch{}}return _(...r)}}const F="flowgrid:replaySessionId",M="rrweb@2";class N extends a{constructor(){super(...arguments),this.disabled=!1,this.active=null,this.state="idle"}async start(t={}){if(!1===t.enabled||this.disabled)return this.setState("disabled",t),()=>{};if(this.active&&!this.active.stopped)return this.emitStatus(this.active.options),()=>this.stop("manual");if(!v())return()=>{};this.setState("starting",t);const e=t.sampleRate??1;if(e<1&&Math.random()>e)return this.setState("sampled_out",t),()=>{};let i;try{i=await n.e(546).then(n.bind(n,546))}catch(e){return this.handleError(this.toError(e),{phase:"import"},t),()=>{}}const r=S();if(!r)return()=>{};const s=t.sessionId??this.resolveSessionId(),a=this.normalizeOptions(t),o=Date.now(),c={sessionId:s,userId:t.userId??this.boundUserId,startedAtMs:o,startedAt:new Date(o).toISOString(),sequence:0,buffer:[],bufferBytes:0,totalBytes:0,droppedEvents:0,stopped:!1,flushTimer:setInterval(()=>{this.flush("interval")},a.flushIntervalMs),durationGuard:setTimeout(()=>this.stop("max_duration"),a.maxDurationMs),onVisibility:()=>{"hidden"===r.visibilityState&&this.flush("visibility_hidden",{useBeacon:!0})},onPageHide:()=>{this.flush("pagehide",{useBeacon:!0})},options:a};this.active=c;try{c.stopRecording=i.record({emit:t=>this.captureEvent(t),maskAllInputs:a.maskAllInputs,maskTextClass:a.maskTextClass??"fg-mask",blockClass:a.blockClass??"fg-block",ignoreClass:a.ignoreClass??"fg-ignore"})}catch(t){return this.handleError(this.toError(t),{phase:"record",sessionId:s},a),c.stopped=!0,this.cleanupActive("stop"),this.active=null,()=>{}}return r.addEventListener("visibilitychange",c.onVisibility),window.addEventListener("pagehide",c.onPageHide),this.setState("recording",a),()=>this.stop("manual")}enable(t={}){return this.disabled=!1,this.start({...t,enabled:!0})}disable(){this.disabled=!0,this.stop("manual"),this.setState("disabled",this.active?.options)}stop(t="stop"){const e=this.active;e&&!e.stopped&&(e.stopped=!0,this.cleanupActive(t),this.flush(t,{useBeacon:!0,isFinal:!0}),this.setState("stopped",e.options,t),this.active=null)}async flush(t="manual",e={}){const i=this.active;if(!i||0===i.buffer.length)return;const r=i.buffer,n=r.length,s=i.bufferBytes,a=i.sequence++;i.buffer=[],i.bufferBytes=0;const o=(new Date).toISOString(),c=this.createIdempotencyKey(i.sessionId,a,s),u={sessionId:i.sessionId,userId:i.userId,sequence:a,eventsCount:n,byteSize:s,reason:t,isFinal:!0===e.isFinal,droppedEvents:i.droppedEvents,capturedAt:o,idempotencyKey:c};try{await this.postReplayChunk(i.sessionId,r,{userId:i.userId,sequence:a,useBeacon:e.useBeacon,startedAt:i.startedAt,capturedAt:o,pageUrl:this.getPageUrl(),isFinal:u.isFinal,reason:t,privacy:this.createPrivacyMetadata(i.options,"sampled_in"),droppedEvents:i.droppedEvents,recorderVersion:M},c),i.options.onFlush?.(u),this.emitStatus(i.options,t)}catch(t){this.handleError(this.toError(t),{phase:"flush",sessionId:i.sessionId},i.options)}}identify(t){this.boundUserId=t,this.active&&(this.active.userId=t,this.emitStatus(this.active.options))}getStatus(){return this.createStatus(this.active?.options)}async sendChunk(t,e,i={}){0!==e.length&&await this.postReplayChunk(t,e,i)}async postReplayChunk(t,e,i,r=this.createIdempotencyKey(t,i.sequence??0,this.measureEvents(e))){await this.postRaw("replay_chunk",{type:"replay_chunk",session_id:t,user_id:i.userId,sequence:i.sequence??0,started_at:i.startedAt,captured_at:i.capturedAt??(new Date).toISOString(),events:e,page_url:i.pageUrl??this.getPageUrl(),idempotency_key:r,compression:"none",is_final:!0===i.isFinal,chunk_kind:i.isFinal?"final":"partial",flush_reason:i.reason??"manual",dropped_events:i.droppedEvents??0,recorder_version:i.recorderVersion??M,privacy:i.privacy??this.createPrivacyMetadata(void 0,"sampled_in")},{useBeacon:i.useBeacon})}captureEvent(t){const e=this.active;if(!e||e.stopped)return;let i=0;try{i=JSON.stringify(t).length}catch{return e.droppedEvents++,void e.options.onDrop?.({sessionId:e.sessionId,reason:"serialization_error",droppedEvents:e.droppedEvents})}if(e.totalBytes+i>e.options.maxBytes)return e.droppedEvents++,e.options.onDrop?.({sessionId:e.sessionId,reason:"max_bytes",droppedEvents:e.droppedEvents,byteSize:e.totalBytes+i,maxBytes:e.options.maxBytes}),void this.stop("max_bytes");e.totalBytes+=i,e.buffer.push(t),e.bufferBytes+=i,e.bufferBytes>=e.options.flushBytes&&this.flush("size")}cleanupActive(t){const e=this.active;if(!e)return;const i=S();clearInterval(e.flushTimer),clearTimeout(e.durationGuard),i?.removeEventListener("visibilitychange",e.onVisibility),window.removeEventListener("pagehide",e.onPageHide);try{e.stopRecording?.()}catch(t){this.handleError(this.toError(t),{phase:"stop",sessionId:e.sessionId},e.options)}this.emitStatus(e.options,t)}normalizeOptions(t){return{...t,flushIntervalMs:t.flushIntervalMs??5e3,flushBytes:t.flushBytes??524288,maxDurationMs:t.maxDurationMs??18e5,maxBytes:t.maxBytes??10485760,maskAllInputs:t.maskAllInputs??!0}}createStatus(t,e){const i=this.active;return{state:this.state,sessionId:i?.sessionId,userId:i?.userId??this.boundUserId,startedAt:i?.startedAt,sequence:i?.sequence??0,bufferedEvents:i?.buffer.length??0,bufferedBytes:i?.bufferBytes??0,totalBytes:i?.totalBytes??0,droppedEvents:i?.droppedEvents??0,recorderVersion:M,lastFlushReason:e,lastError:this.lastError}}setState(t,e,i){this.state=t,this.emitStatus(e,i)}emitStatus(t,e){t?.onStatus?.(this.createStatus(t,e))}handleError(t,e,i){this.lastError=t.message,this.state="error",i?.onError?.(t,e),this.emitStatus(i)}createPrivacyMetadata(t,e="sampled_in"){return{masking_mode:!1===t?.maskAllInputs?"selective":"all_inputs",blocked_selectors:this.selectorList(t?.blockClass??"fg-block"),redacted_fields:this.selectorList(t?.maskTextClass??"fg-mask"),consent_state:a.hasConsent("analytics")?"granted":"denied",sampling_state:e}}selectorList(t){return"string"==typeof t?[t]:[t.source]}getPageUrl(){try{return"undefined"!=typeof location?location.href:""}catch{return""}}createIdempotencyKey(t,e,i){return`${this.webId}:${t}:${e}:${i}`}measureEvents(t){try{return JSON.stringify(t).length}catch{return 0}}toError(t){return t instanceof Error?t:new Error(String(t))}resolveSessionId(){try{const t=sessionStorage.getItem(F);if(t)return t;const e=this.generateId();return sessionStorage.setItem(F,e),e}catch{return this.generateId()}}generateId(){const t="undefined"!=typeof crypto?crypto:void 0;return t?.randomUUID?t.randomUUID():`rep_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`}}class L extends a{async view(t){return await this.init("product_view",{type:"ecommerce",subtype:"product_view",product:{productId:t.productId,name:t.name,brand:t.brand,category:t.category,variant:t.variant,price:t.price,currency:t.currency,url:t.url,imageUrl:t.imageUrl,rating:t.rating,reviewCount:t.reviewCount,stockStatus:t.stockStatus,attributes:t.attributes},source:t.source,searchQuery:t.searchQuery,userId:t.userId,sessionId:t.sessionId,...t.properties,timestamp:(new Date).toISOString()})}async impression(t){return await this.init("product_impression",{type:"ecommerce",subtype:"product_impression",list:t.list,productCount:t.list.products.length,userId:t.userId,sessionId:t.sessionId,timestamp:(new Date).toISOString()})}async click(t){return await this.init("product_click",{type:"ecommerce",subtype:"product_click",product:t.product,listId:t.listId,position:t.position,userId:t.userId,timestamp:(new Date).toISOString()})}async quickView(t,e){return await this.init("product_quick_view",{type:"ecommerce",subtype:"product_quick_view",product:t,listId:e,timestamp:(new Date).toISOString()})}async interaction(t,e,i){return await this.init("product_interaction",{type:"ecommerce",subtype:"product_interaction",productId:t,action:e,...i,timestamp:(new Date).toISOString()})}}class U extends a{async addItem(t){const e=t.product.price*t.quantity-(t.product.discount||0);return await this.init("add_to_cart",{type:"ecommerce",subtype:"add_to_cart",product:t.product,quantity:t.quantity,lineTotal:e,cartId:t.cartId,userId:t.userId,source:t.source,...t.properties,timestamp:(new Date).toISOString()})}async removeItem(t){return await this.init("remove_from_cart",{type:"ecommerce",subtype:"remove_from_cart",product:t.product,quantity:t.quantity,cartId:t.cartId,userId:t.userId,reason:t.reason||"user_action",timestamp:(new Date).toISOString()})}async updateItem(t){return await this.init("update_cart_item",{type:"ecommerce",subtype:"update_cart_item",product:t.product,previousQuantity:t.previousQuantity,newQuantity:t.newQuantity,quantityChange:t.newQuantity-t.previousQuantity,cartId:t.cartId,timestamp:(new Date).toISOString()})}async view(t){return await this.init("view_cart",{type:"ecommerce",subtype:"view_cart",cart:t.cart,cartValue:t.cart.total,itemCount:t.cart.itemCount,userId:t.userId,timestamp:(new Date).toISOString()})}async abandon(t,e){return await this.init("cart_abandoned",{type:"ecommerce",subtype:"cart_abandoned",cart:t,cartValue:t.total,itemCount:t.itemCount,reason:e,timestamp:(new Date).toISOString()})}async applyCoupon(t,e,i,r){return await this.init("apply_coupon",{type:"ecommerce",subtype:"apply_coupon",cartId:t,couponCode:e,success:i,discount:r,timestamp:(new Date).toISOString()})}}class B extends a{async begin(t){return await this.init("begin_checkout",{type:"ecommerce",subtype:"begin_checkout",cart:t.cart,cartValue:t.cart.total,itemCount:t.cart.itemCount,userId:t.userId,sessionId:t.sessionId,...t.properties,timestamp:(new Date).toISOString()})}async step(t){return await this.init("checkout_step",{type:"ecommerce",subtype:"checkout_step",step:t.step,stepNumber:t.stepNumber,cart:t.cart,option:t.option,userId:t.userId,timestamp:(new Date).toISOString()})}async addShipping(t){return await this.init("add_shipping_info",{type:"ecommerce",subtype:"shipping_info",cart:t.cart,shipping:t.shipping,shippingMethod:t.shipping.method,shippingCost:t.shipping.cost,userId:t.userId,timestamp:(new Date).toISOString()})}async addPayment(t){return await this.init("add_payment_info",{type:"ecommerce",subtype:"payment_info",cart:t.cart,payment:t.payment,paymentMethod:t.payment.method,userId:t.userId,timestamp:(new Date).toISOString()})}async abandon(t,e,i){return await this.init("checkout_abandoned",{type:"ecommerce",subtype:"checkout_abandoned",cart:t,step:e,cartValue:t.total,reason:i,timestamp:(new Date).toISOString()})}async paymentAttempt(t,e,i,r){return await this.init("payment_attempt",{type:"ecommerce",subtype:"payment_attempt",success:t,cart:e,payment:i,errorCode:r,timestamp:(new Date).toISOString()})}}class R extends a{async track(t){const e=t.order;return await this.init("purchase",{type:"ecommerce",subtype:"purchase",order:{orderId:e.orderId,items:e.items,subtotal:e.subtotal,discountTotal:e.discountTotal,shippingTotal:e.shippingTotal,taxTotal:e.taxTotal,total:e.total,currency:e.currency,shipping:e.shipping,payment:e.payment,coupons:e.coupons,affiliation:e.affiliation},revenue:e.total,itemCount:e.items.reduce((t,e)=>t+e.quantity,0),userId:t.userId,sessionId:t.sessionId,attribution:t.attribution,...t.properties,timestamp:(new Date).toISOString()})}async statusChange(t,e,i){return await this.init("order_status_change",{type:"ecommerce",subtype:"order_status_change",orderId:t,newStatus:e,previousStatus:i,timestamp:(new Date).toISOString()})}async shipped(t,e){return await this.init("order_shipped",{type:"ecommerce",subtype:"order_shipped",orderId:t,shipping:e,timestamp:(new Date).toISOString()})}async delivered(t,e){return await this.init("order_delivered",{type:"ecommerce",subtype:"order_delivered",orderId:t,deliveredAt:e||(new Date).toISOString(),timestamp:(new Date).toISOString()})}}class P extends a{async track(t){return await this.init("refund",{type:"ecommerce",subtype:"refund",orderId:t.orderId,refundId:t.refundId,items:t.items,amount:t.amount,currency:t.currency,reason:t.reason,isFullRefund:t.isFullRefund,userId:t.userId,initiatedBy:t.initiatedBy,...t.properties,timestamp:(new Date).toISOString()})}async request(t,e,i){return await this.init("refund_requested",{type:"ecommerce",subtype:"refund_requested",orderId:t,items:e,reason:i,timestamp:(new Date).toISOString()})}async approve(t,e){return await this.init("refund_approved",{type:"ecommerce",subtype:"refund_approved",refundId:t,approvedAmount:e,timestamp:(new Date).toISOString()})}async deny(t,e){return await this.init("refund_denied",{type:"ecommerce",subtype:"refund_denied",refundId:t,denialReason:e,timestamp:(new Date).toISOString()})}async complete(t,e){return await this.init("refund_completed",{type:"ecommerce",subtype:"refund_completed",refundId:t,processedAmount:e,timestamp:(new Date).toISOString()})}}class V extends a{async view(t){return await this.init("promotion_view",{type:"ecommerce",subtype:"promotion_view",promotionId:t.promotionId,name:t.name,creative:t.creative,position:t.position,page:t.page,userId:t.userId,timestamp:(new Date).toISOString()})}async click(t){return await this.init("promotion_click",{type:"ecommerce",subtype:"promotion_click",promotionId:t.promotionId,name:t.name,creative:t.creative,position:t.position,destinationUrl:t.destinationUrl,userId:t.userId,timestamp:(new Date).toISOString()})}async couponUsed(t){return await this.init("coupon_used",{type:"ecommerce",subtype:"coupon_used",code:t.code,orderId:t.orderId,discountValue:t.discountValue,discountType:t.discountType,orderValueBefore:t.orderValueBefore,orderValueAfter:t.orderValueAfter,savings:t.orderValueBefore-t.orderValueAfter,userId:t.userId,timestamp:(new Date).toISOString()})}async couponAttempt(t,e,i){return await this.init("coupon_attempt",{type:"ecommerce",subtype:"coupon_attempt",code:t,success:e,failureReason:i,timestamp:(new Date).toISOString()})}}class q extends a{async add(t){return await this.init("add_to_wishlist",{type:"ecommerce",subtype:"add_to_wishlist",product:t.product,wishlistId:t.wishlistId,userId:t.userId,source:t.source,timestamp:(new Date).toISOString()})}async remove(t){return await this.init("remove_from_wishlist",{type:"ecommerce",subtype:"remove_from_wishlist",product:t.product,wishlistId:t.wishlistId,userId:t.userId,reason:t.reason||"user_action",timestamp:(new Date).toISOString()})}async view(t){return await this.init("view_wishlist",{type:"ecommerce",subtype:"view_wishlist",wishlistId:t.wishlistId,itemCount:t.items.length,timestamp:(new Date).toISOString()})}async moveToCart(t,e){return await this.init("wishlist_to_cart",{type:"ecommerce",subtype:"wishlist_to_cart",product:t,wishlistId:e,timestamp:(new Date).toISOString()})}async share(t,e){return await this.init("share_wishlist",{type:"ecommerce",subtype:"share_wishlist",wishlistId:t,method:e,timestamp:(new Date).toISOString()})}}class $ extends a{async recordAcquisitionCost(t){return await this.init("record_acquisition_cost",{type:"ecommerce",subtype:"acquisition_cost",userId:t.userId,cost:t.cost,channel:t.channel,campaign:t.campaign,timestamp:(new Date).toISOString()})}async updateSegment(t,e){return await this.init("update_customer_segment",{type:"ecommerce",subtype:"update_customer_segment",userId:t,segment:e,timestamp:(new Date).toISOString()})}}class j extends a{async track(t){return await this.init("site_search",{type:"ecommerce",subtype:"site_search",query:t.query,resultsCount:t.resultsCount,hasResults:t.resultsCount>0,category:t.category,filters:t.filters,sortBy:t.sortBy,page:t.page||1,userId:t.userId,sessionId:t.sessionId,timestamp:(new Date).toISOString()})}async trackClick(t){return await this.init("search_result_click",{type:"ecommerce",subtype:"search_result_click",query:t.query,product:t.product,position:t.position,page:t.page||1,timestamp:(new Date).toISOString()})}async trackRefinement(t,e,i){return await this.init("search_refinement",{type:"ecommerce",subtype:"search_refinement",originalQuery:t,refinedQuery:e,refinementType:i,timestamp:(new Date).toISOString()})}async trackSuggestion(t,e,i){return await this.init("search_suggestion",{type:"ecommerce",subtype:"search_suggestion",partialQuery:t,selectedSuggestion:e,suggestionPosition:i,timestamp:(new Date).toISOString()})}}class z extends a{async start(t){return await this.init("subscription_start",{type:"ecommerce",subtype:"subscription_start",subscriptionId:t.subscriptionId,userId:t.userId,plan:t.plan,mrr:t.mrr,billingCycle:t.billingCycle,trialDays:t.trialDays,coupon:t.coupon,isTrialing:(t.trialDays||0)>0,...t.properties,timestamp:(new Date).toISOString()})}async change(t){const e=t.newMrr.amount-t.previousMrr.amount;return await this.init("subscription_change",{type:"ecommerce",subtype:"subscription_change",subscriptionId:t.subscriptionId,userId:t.userId,previousPlan:t.previousPlan,newPlan:t.newPlan,previousMrr:t.previousMrr,newMrr:t.newMrr,mrrChange:e,changeType:t.changeType,timestamp:(new Date).toISOString()})}async cancel(t){return await this.init("subscription_cancel",{type:"ecommerce",subtype:"subscription_cancel",subscriptionId:t.subscriptionId,userId:t.userId,plan:t.plan,lostMrr:t.lostMrr,reason:t.reason,feedback:t.feedback,immediate:t.immediate,timestamp:(new Date).toISOString()})}async renew(t,e,i){return await this.init("subscription_renew",{type:"ecommerce",subtype:"subscription_renew",subscriptionId:t,userId:e,mrr:i,timestamp:(new Date).toISOString()})}async trialConverted(t,e,i,r){return await this.init("trial_converted",{type:"ecommerce",subtype:"trial_converted",subscriptionId:t,userId:e,plan:i,mrr:r,timestamp:(new Date).toISOString()})}async trialExpired(t,e){return await this.init("trial_expired",{type:"ecommerce",subtype:"trial_expired",subscriptionId:t,userId:e,timestamp:(new Date).toISOString()})}}class H extends a{async trackDwellTime(t){return await this.initFeature("engagement.dwell_time",{type:"engagement",featureId:t.featureId,userId:t.userId,sessionId:t.sessionId,dwellTimeMs:t.dwellTimeMs,wasActive:t.wasActive??!0,...t.properties,timestamp:(new Date).toISOString()})}async trackSessionDepth(t){const e=function(t,e,i){const r=30*Math.min(t/10,1),n=40*Math.min(e/5,1),s=30*Math.min(i/20,1);return Math.round(r+n+s)}(t.pagesVisited,t.featuresUsed,t.actionsTaken);return await this.initFeature("engagement.session_depth",{type:"engagement",sessionId:t.sessionId,userId:t.userId,pagesVisited:t.pagesVisited,featuresUsed:t.featuresUsed,actionsTaken:t.actionsTaken,durationMs:t.durationMs,depthScore:e,timestamp:(new Date).toISOString()})}async trackContentConsumption(t){return await this.initFeature("engagement.content_consumption",{type:"engagement",contentId:t.contentId,contentType:t.contentType,userId:t.userId,percentageConsumed:t.percentageConsumed,timeSpentMs:t.timeSpentMs,completed:t.completed??t.percentageConsumed>=90,...t.properties,timestamp:(new Date).toISOString()})}async trackUserActivity(t){return await this.initFeature("engagement.user_activity",{type:"engagement",userId:t.userId,activityType:t.activityType,durationMs:t.durationMs,sessionId:t.sessionId,timestamp:(new Date).toISOString()})}autoTrackDwell(t,e={}){if(!v())return()=>{};const i=S();if(!i)return()=>{};let r=0,n="visible"===i.visibilityState?Date.now():0;const s=()=>{const t=Date.now();"visible"===i.visibilityState?n=t:n&&(r+=t-n,n=0)};i.addEventListener("visibilitychange",s);let a=!1;return()=>{a||(a=!0,i.removeEventListener("visibilitychange",s),n&&(r+=Date.now()-n,n=0),r>0&&this.trackDwellTime({featureId:t,dwellTimeMs:r,userId:e.userId,sessionId:e.sessionId,wasActive:!0}))}}autoTrack(t={}){if(!v())return()=>{};const e=f(),i=S();if(!e||!i)return()=>{};const r=t.idleAfterMs??3e4,n=t.pollMs??5e3;let s=t.sessionId;if(!s)try{s=e.sessionStorage.getItem("flowgrid:sessionId")||void 0}catch{}s||(s=`eng_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`);const a=Date.now();let o=1;const c=new Set;let u=0,p=Date.now(),d="visible"===i.visibilityState?"active":"idle",l=Date.now();const m=e.history.pushState,h=e.history.replaceState,y=()=>{o++};e.history.pushState=function(...t){const e=m.apply(this,t);return y(),e},e.history.replaceState=function(...t){const e=h.apply(this,t);return y(),e},e.addEventListener("popstate",y);const g=t=>{u++,p=Date.now();const e=t.target,i=e?.closest?.("[data-flowgrid-feature]")?.getAttribute("data-flowgrid-feature");i&&c.add(i)};i.addEventListener("click",g,{capture:!0}),i.addEventListener("keydown",g,{capture:!0}),i.addEventListener("scroll",g,{capture:!0,passive:!0});const I=e=>{if(e===d)return;const i=Date.now(),r=i-l,n=d;d=e,l=i,r>0&&t.userId&&this.trackUserActivity({userId:t.userId,activityType:n,durationMs:r,sessionId:s})},w=()=>{const t=Date.now();let e;e="visible"!==i.visibilityState?"idle":t-p<r?"active":"passive",I(e)},k=e.setInterval(w,n),b=()=>w();i.addEventListener("visibilitychange",b);let D=!1;const O=()=>{if(D)return;D=!0,I("visible"===i.visibilityState?d:"idle");const e=Date.now()-a;e<=0||this.trackSessionDepth({sessionId:s,userId:t.userId,pagesVisited:o,featuresUsed:c.size,actionsTaken:u,durationMs:e})};return e.addEventListener("pagehide",O),_(()=>e.clearInterval(k),()=>i.removeEventListener("visibilitychange",b),()=>i.removeEventListener("click",g,!0),()=>i.removeEventListener("keydown",g,!0),()=>i.removeEventListener("scroll",g,!0),()=>e.removeEventListener("popstate",y),()=>e.removeEventListener("pagehide",O),()=>{e.history.pushState=m,e.history.replaceState=h},()=>O())}}class K extends a{async createCohort(t){const e=t.cohortId??t.name.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_|_$/g,"");return await this.initFeature("cohorts.create",{type:"cohorts",cohortId:e,name:t.name,description:t.description,cohortType:t.type,rules:t.rules,dynamic:t.dynamic??!0,timeWindow:t.timeWindow,timestamp:(new Date).toISOString()})}async updateCohort(t,e){const{type:i,...r}=e;return await this.initFeature("cohorts.update",{type:"cohorts",cohortId:t,cohortType:i,...r,timestamp:(new Date).toISOString()})}async deleteCohort(t){return await this.initFeature("cohorts.delete",{type:"cohorts",cohortId:t,timestamp:(new Date).toISOString()})}async listCohorts(t){return await this.initFeature("cohorts.list",{type:"cohorts",filter:t,timestamp:(new Date).toISOString()})}async isUserInCohort(t,e){return await this.initFeature("cohorts.check_membership",{type:"cohorts",userId:t,cohortId:e,timestamp:(new Date).toISOString()})}async createSegment(t){return await this.initFeature("cohorts.create_segment",{type:"cohorts",...t,timestamp:(new Date).toISOString()})}async compareCohorts(t){return await this.initFeature("cohorts.compare",{type:"cohorts",...t,timestamp:(new Date).toISOString()})}}class J extends a{async trackUsageDecay(t){return await this.initFeature("churn.usage_decay",{type:"churn",...t,timestamp:(new Date).toISOString()})}async trackNPS(t){return await this.initFeature("churn.nps",{type:"churn",...t,timestamp:(new Date).toISOString()})}async trackChurn(t){return await this.initFeature("churn.churn_event",{type:"churn",...t,timestamp:(new Date).toISOString()})}async trackPreventionAction(t){return await this.initFeature("churn.prevention_action",{type:"churn",...t,timestamp:(new Date).toISOString()})}async updatePreventionOutcome(t,e,i){return await this.initFeature("churn.update_prevention_outcome",{type:"churn",userId:t,actionType:e,outcome:i,timestamp:(new Date).toISOString()})}}class W extends a{async trackRevenue(t){const{type:e,...i}=t;return await this.initFeature("monetization.revenue",{type:"monetization",revenueType:e,...i,timestamp:(new Date).toISOString()})}async trackExpansion(t,e,i,r){return await this.initFeature("monetization.expansion",{type:"monetization",userId:t,fromPlan:e,toPlan:i,additionalRevenue:r,revenueType:"expansion",timestamp:(new Date).toISOString()})}async trackContraction(t,e,i,r){return await this.initFeature("monetization.contraction",{type:"monetization",userId:t,fromPlan:e,toPlan:i,reducedRevenue:r,revenueType:"downgrade",timestamp:(new Date).toISOString()})}}class Y extends a{async defineFunnel(t){const e=t.funnelId??t.name.toLowerCase().replace(/[^a-z0-9]+/g,"_"),i=t.paths.map(t=>{return{...t,pathId:t.pathId??(e=t.steps,e.join("_").toLowerCase().replace(/[^a-z0-9_]/g,""))};var e});return await this.initFeature("multi_path_funnels.define",{type:"multi_path_funnels",funnelId:e,name:t.name,description:t.description,paths:i,microConversions:t.microConversions,goalEvent:t.goalEvent,timestamp:(new Date).toISOString()})}async updateFunnel(t,e){return await this.initFeature("multi_path_funnels.update",{type:"multi_path_funnels",funnelId:t,...e,timestamp:(new Date).toISOString()})}async deleteFunnel(t){return await this.initFeature("multi_path_funnels.delete",{type:"multi_path_funnels",funnelId:t,timestamp:(new Date).toISOString()})}async trackStep(t){return await this.initFeature("multi_path_funnels.track_step",{type:"multi_path_funnels",...t,timestamp:(new Date).toISOString()})}async trackMicroConversion(t){return await this.initFeature("multi_path_funnels.track_micro_conversion",{type:"multi_path_funnels",...t,timestamp:(new Date).toISOString()})}async trackGoal(t,e,i){return await this.initFeature("multi_path_funnels.track_goal",{type:"multi_path_funnels",funnelId:t,userId:e,...i,timestamp:(new Date).toISOString()})}async analyzeFunnel(t){return await this.initFeature("multi_path_funnels.analyze",{type:"multi_path_funnels",...t,timestamp:(new Date).toISOString()})}async comparePaths(t,e){return await this.initFeature("multi_path_funnels.compare_paths",{type:"multi_path_funnels",funnelId:t,filter:e,timestamp:(new Date).toISOString()})}async listFunnels(){return await this.initFeature("multi_path_funnels.list",{type:"multi_path_funnels",timestamp:(new Date).toISOString()})}}class Q extends a{async trackTicket(t){return await this.initFeature("support.ticket_created",{type:"support",...t,status:"open",createdAt:(new Date).toISOString(),timestamp:(new Date).toISOString()})}async updateTicket(t){return await this.initFeature("support.ticket_updated",{type:"support",...t,timestamp:(new Date).toISOString()})}async trackResponse(t,e,i){return await this.initFeature("support.ticket_response",{type:"support",ticketId:t,agentId:e,responseTimeMs:i,timestamp:(new Date).toISOString()})}async trackResolution(t,e,i){return await this.initFeature("support.ticket_resolved",{type:"support",ticketId:t,resolutionTimeMs:e,interactionCount:i,firstContactResolution:1===i,timestamp:(new Date).toISOString()})}async trackCSAT(t){return await this.initFeature("support.csat",{type:"support",...t,timestamp:(new Date).toISOString()})}async trackFeatureComplaint(t){return await this.initFeature("support.feature_complaint",{type:"support",...t,timestamp:(new Date).toISOString()})}}class X extends a{async trackAcquisition(t){return await this.initFeature("acquisition.acquired",{type:"acquisition",...t,timestamp:(new Date).toISOString()})}async trackLifecycleTransition(t){return await this.initFeature("acquisition.lifecycle_transition",{type:"acquisition",...t,timestamp:(new Date).toISOString()})}async createCampaign(t){return await this.initFeature("acquisition.create_campaign",{type:"acquisition",...t,timestamp:(new Date).toISOString()})}async trackCampaignSpend(t){return await this.initFeature("acquisition.campaign_spend",{type:"acquisition",...t,timestamp:(new Date).toISOString()})}}class G extends a{async trackTransition(t){return await this.initFeature("paths.transition",{type:"paths",...t,timestamp:(new Date).toISOString()})}async trackFeatureSequence(t){return await this.initFeature("paths.feature_sequence",{type:"paths",...t,timestamp:(new Date).toISOString()})}async definePath(t){return await this.initFeature("paths.define_path",{type:"paths",...t,timestamp:(new Date).toISOString()})}async comparePaths(t,e){return await this.initFeature("paths.compare_paths",{type:"paths",paths:t,filter:e,timestamp:(new Date).toISOString()})}}class Z extends a{async createAlert(t){return await this.initFeature("alerts.create",{type:"alerts",...t,alertId:t.alertId??t.name.toLowerCase().replace(/[^a-z0-9]+/g,"_"),enabled:t.enabled??!0,timestamp:(new Date).toISOString()})}async updateAlert(t,e){return await this.initFeature("alerts.update",{type:"alerts",alertId:t,...e,timestamp:(new Date).toISOString()})}async deleteAlert(t){return await this.initFeature("alerts.delete",{type:"alerts",alertId:t,timestamp:(new Date).toISOString()})}async toggleAlert(t,e){return await this.initFeature("alerts.toggle",{type:"alerts",alertId:t,enabled:e,timestamp:(new Date).toISOString()})}async listAlerts(t){return await this.initFeature("alerts.list",{type:"alerts",enabled:t,timestamp:(new Date).toISOString()})}async acknowledgeAlert(t,e){return await this.initFeature("alerts.acknowledge",{type:"alerts",instanceId:t,acknowledgedBy:e,timestamp:(new Date).toISOString()})}async resolveAlert(t,e){return await this.initFeature("alerts.resolve",{type:"alerts",instanceId:t,notes:e,timestamp:(new Date).toISOString()})}async muteAlert(t,e){return await this.initFeature("alerts.mute",{type:"alerts",alertId:t,durationMinutes:e,timestamp:(new Date).toISOString()})}async detectAnomalies(t){return await this.initFeature("alerts.detect_anomalies",{type:"alerts",...t,timestamp:(new Date).toISOString()})}async configureNotification(t){return await this.initFeature("alerts.configure_notification",{type:"alerts",...t,timestamp:(new Date).toISOString()})}async testNotification(t){return await this.initFeature("alerts.test_notification",{type:"alerts",channel:t,timestamp:(new Date).toISOString()})}}class tt extends a{async trackLoginAttempt(t){const e=t.success?"login_success":"login_failure",i=function(t,e){return["suspicious_activity"].includes(t)?"critical":["role_change","permission_change","data_deletion","api_key_revoked"].includes(t)?"high":["login_failure","password_reset","data_export"].includes(t)?e?"medium":"high":"low"}(e,t.success);return await this.initFeature("security.login_attempt",{type:"security",...t,eventType:e,severity:i,timestamp:(new Date).toISOString()})}async trackLogout(t,e){return await this.initFeature("security.logout",{type:"security",userId:t,sessionId:e,eventType:"logout",timestamp:(new Date).toISOString()})}async trackPasswordChange(t,e=!1){return await this.initFeature("security.password_change",{type:"security",userId:t,forced:e,eventType:"password_change",timestamp:(new Date).toISOString()})}async trackRoleChange(t){return await this.initFeature("security.role_change",{type:"security",...t,eventType:"role_change",timestamp:(new Date).toISOString()})}async trackPermissionChange(t){return await this.initFeature("security.permission_change",{type:"security",...t,eventType:"permission_change",timestamp:(new Date).toISOString()})}async trackDataAccess(t){return await this.initFeature("security.data_access",{type:"security",...t,eventType:"data_access",timestamp:(new Date).toISOString()})}async trackDataExport(t,e,i){return await this.initFeature("security.data_export",{type:"security",userId:t,resourceType:e,recordCount:i,eventType:"data_export",timestamp:(new Date).toISOString()})}async trackSuspiciousActivity(t,e,i){return await this.initFeature("security.suspicious_activity",{type:"security",userId:t,activityType:e,details:i,eventType:"suspicious_activity",severity:"critical",timestamp:(new Date).toISOString()})}async trackComplianceEvent(t){return await this.initFeature("security.compliance_event",{type:"security",...t,timestamp:(new Date).toISOString()})}}class et extends a{async forecastActiveUsers(t){return await this.initFeature("forecasting.active_users",{type:"forecasting",...t,model:t.model??"ensemble",includeConfidence:t.includeConfidence??!0,timestamp:(new Date).toISOString()})}async forecastRevenue(t){return await this.initFeature("forecasting.revenue",{type:"forecasting",...t,metric:"revenue",currency:t.currency??"USD",timestamp:(new Date).toISOString()})}async forecastMRR(t){return await this.initFeature("forecasting.mrr",{type:"forecasting",...t,metric:"mrr",timestamp:(new Date).toISOString()})}async forecastFeatureAdoption(t){return await this.initFeature("forecasting.feature_adoption",{type:"forecasting",...t,metric:"feature_usage",timestamp:(new Date).toISOString()})}async forecastChurn(t){return await this.initFeature("forecasting.churn",{type:"forecasting",...t,metric:"churn_rate",timestamp:(new Date).toISOString()})}async forecastSignups(t){return await this.initFeature("forecasting.signups",{type:"forecasting",...t,metric:"signups",timestamp:(new Date).toISOString()})}async compareScenarios(t){return await this.initFeature("forecasting.scenarios",{type:"forecasting",...t,timestamp:(new Date).toISOString()})}async forecastCustomMetric(t,e){return await this.initFeature("forecasting.custom",{type:"forecasting",...e,metric:"custom",customMetricName:t,timestamp:(new Date).toISOString()})}}class it{constructor(t){this.client=t}signup(t,e,i,r){return this.client.trackSignup(t,e,i,r)}onboardingStep(t,e,i,r,n,s){return this.client.trackOnboardingStep({userId:t,stepId:e,stepName:i,stepOrder:r,totalSteps:n,...s})}onboardingComplete(t,e,i,r=0){return this.client.completeOnboarding(t,e,i,r)}firstAction(t,e,i,r){return this.client.trackFirstAction({userId:t,actionName:e,timeSinceSignup:i,properties:r})}event(t,e={}){return this.client.create({eventName:t,properties:e})}}class rt{constructor(t){this.client=t}used(t,e,i="used",r){return this.client.trackUsage({featureId:t,featureName:e,action:i,properties:r})}create(t,e,i,r){return this.client.create({userId:t,action:e,properties:{featureName:i,...r}})}}class nt{constructor(t){this.client=t}submitted(t,e,i){return this.client.trackSubmission({promptId:t,promptType:e,properties:i})}responded(t,e,i,r){return this.client.trackResponse({promptId:t,responseTime:e,completed:i,properties:r})}feedback(t,e,i){return this.client.trackFeedback({promptId:t,feedbackType:e,properties:i})}conversation(t,e,i,r){return this.client.trackConversation(t,e,i,r)}event(t,e={}){return this.client.create({eventName:t,properties:e})}}class st{constructor(t){this.client=t}define(t){return this.client.define(t)}init(t){return this.client.initExperiments(t)}variant(t){return this.client.getLocalVariant(t)}assign(t,e,i,r="targeted"){return this.client.assign({experimentId:t,userId:e,variantId:i,source:r})}exposure(t,e,i){return this.client.trackExposure(t,e,i)}conversion(t,e,i,r,n=1){return this.client.trackConversion({experimentId:t,userId:e,variantId:i,metricName:r,value:n})}localConversion(t,e="conversion",i=1){return this.client.trackLocalConversion(t,e,i)}hydrateFromCookies(t){this.client.hydrateFromCookies(t)}hydrateFromCookieHeader(t){this.client.hydrateFromCookieHeader(t)}injectAssignments(t){this.client.injectAssignments(t)}getAssignments(){return this.client.getAssignments()}serializeAssignmentCookie(){return this.client.serializeAssignmentCookie()}clearAssignments(){this.client.clearAssignments()}}class at{constructor(t){this.client=t}view(t,e,i){const r=function(){const t="undefined"!=typeof window&&"undefined"!=typeof document;return{url:t?window.location.href:"",path:t?window.location.pathname:"",title:t?document.title:void 0,referrer:t?document.referrer:void 0}}(),n=t&&/^https?:\/\//i.test(t),s=n?t:r.url,a=n?new URL(t).pathname:t??r.path;return this.client.track({url:s,path:a,title:i?.title??r.title,referrer:i?.referrer??r.referrer,userId:i?.userId,sessionId:i?.sessionId,properties:e})}scroll(t,e,i){return this.client.trackScrollDepth({path:t,scrollDepth:e,timeAtDepth:i})}time(t,e){return this.client.trackTimeOnPage({path:t,duration:e})}exit(t,e,i){return this.client.trackExit(t,e,i)}autoTrack(t){return this.client.autoTrack(t)}}class ot{constructor(t){this.client=t}start(t){return this.client.start(t)}update(t,e){return this.client.update(t,e)}end(t){return this.client.end(t)}heartbeat(t){return this.client.heartbeat(t)}autoTrack(t,e){return this.client.autoTrack(t,e)}}class ct{constructor(t){this.client=t}track(t,e,i){return this.client.track({eventName:t,properties:e,userId:i?.userId,sessionId:i?.sessionId})}batch(t){return this.client.trackBatch({events:t})}click(t,e,i){return this.client.trackClick({elementId:t,elementText:e,properties:i})}form(t,e,i){return this.client.trackForm({formId:t,formName:e,properties:i})}search(t,e,i){return this.client.trackSearch({query:t,category:e,properties:i})}error(t,e,i){return this.client.trackError({message:t,type:e,properties:i})}}class ut{constructor(t){this.client=t}user(t,e,i){return this.client.user({userId:t,anonymousId:i,traits:e})}updateTraits(t,e){return this.client.updateTraits(t,e)}alias(t,e){return this.client.alias({previousId:t,userId:e})}group(t,e,i){return this.client.group({userId:t,groupId:e,traits:i})}}class pt{constructor(t){this.client=t}define(t){return this.client.define(t)}step(t,e,i,r,n){return this.client.trackStep({funnelId:t,step:e,stepNumber:i,userId:r,properties:n})}complete(t,e,i){return this.client.trackComplete(t,e,i)}abandon(t,e,i,r){return this.client.trackAbandon(t,e,i,r)}}class dt{constructor(t){this.client=t}active(t,e){return this.client.trackActivity({userId:t,properties:e})}}class lt{constructor(t){this.client=t}touchpoint(t,e,i){return this.client.trackTouchpoint({userId:t,channel:e,properties:i})}conversion(t,e,i){return this.client.recordConversion({userId:t,conversionType:e,properties:i})}captureFromUrl(t){return this.client.captureFromUrl(t)}}class mt{constructor(t){this.client=t}click(t,e,i,r,n){return this.client.trackClick({pageUrl:t,x:e,y:i,viewportWidth:r,viewportHeight:n})}movement(t,e,i){return this.client.trackMovement({pageUrl:t,path:e,viewport:i})}scroll(t,e,i,r){return this.client.trackScroll({pageUrl:t,maxScrollDepth:e,pageHeight:i,viewportHeight:r})}autoTrack(t){return this.client.autoTrack(t)}}class ht{constructor(t){this.client=t}webVitals(t,e){return this.client.trackWebVitals({pageUrl:t,...e})}pageLoad(t,e){return this.client.trackPageLoad({pageUrl:t,...e})}resource(t,e,i,r){return this.client.trackResource({pageUrl:t,resourceUrl:e,resourceType:i,duration:r})}autoTrack(t){return this.client.autoTrack(t)}}class yt{constructor(t){this.client=t}start(t){return this.client.start(t??{})}enable(t){return this.client.enable(t??{})}disable(){this.client.disable()}stop(t){this.client.stop(t)}flush(t){return this.client.flush(t??"manual")}identify(t){this.client.identify(t)}status(){return this.client.getStatus()}sendChunk(t,e,i){return this.client.sendChunk(t,e,i??{})}}class gt{constructor(t){this.client=t}view(t,e){return this.client.view({...t,properties:e})}impression(t,e,i){return this.client.impression({list:{listId:t,listName:e,products:i}})}click(t,e,i){return this.client.click({product:t,listId:e,position:i})}}class It{constructor(t){this.client=t}add(t,e=1,i){return this.client.addItem({product:t,quantity:e,cartId:i})}remove(t,e=1,i){return this.client.removeItem({product:t,quantity:e,cartId:i})}update(t,e,i,r){return this.client.updateItem({product:t,previousQuantity:e,newQuantity:i,cartId:r})}view(t){return this.client.view({cart:t})}}class wt{constructor(t){this.client=t}begin(t){return this.client.begin({cart:t})}step(t,e,i){return this.client.step({step:t,stepNumber:e,cart:i})}shipping(t,e){return this.client.addShipping({cart:t,shipping:e})}payment(t,e){return this.client.addPayment({cart:t,payment:e})}}class ft{constructor(t){this.client=t}complete(t){return this.client.track({order:t})}}class St{constructor(t){this.client=t}request(t,e,i){return this.client.request(t,e,i)}approve(t,e){return this.client.approve(t,e)}deny(t,e){return this.client.deny(t,e)}complete(t,e,i,r,n,s=!1){return this.client.track({orderId:t,refundId:e,amount:i,currency:r,reason:n,isFullRefund:s})}}class vt{constructor(t){this.client=t}view(t,e,i,r){return this.client.view({promotionId:t,name:e,creative:i,position:r})}click(t,e,i,r){return this.client.click({promotionId:t,name:e,creative:i,position:r})}coupon(t,e,i,r,n,s){return this.client.couponUsed({code:t,orderId:e,discountValue:i,discountType:r,orderValueBefore:n,orderValueAfter:s})}}class _t{constructor(t){this.client=t}add(t,e){return this.client.add({product:t,wishlistId:e})}remove(t,e){return this.client.remove({product:t,wishlistId:e})}view(t){return this.client.view(t)}moveToCart(t,e){return this.client.moveToCart(t,e)}share(t,e){return this.client.share(t,e)}}class kt{constructor(t){this.client=t}acquisitionCost(t,e,i){return this.client.recordAcquisitionCost({userId:t,cost:e,channel:i})}segment(t,e){return this.client.updateSegment(t,e)}}class bt{constructor(t){this.client=t}query(t,e,i){return this.client.track({query:t,resultsCount:e,...i})}click(t,e,i){return this.client.trackClick({query:t,product:e,position:i})}refine(t,e,i){return this.client.trackRefinement(t,e,i)}suggestion(t,e,i){return this.client.trackSuggestion(t,e,i)}}class Dt{constructor(t){this.client=t}start(t,e,i,r,n){return this.client.start({subscriptionId:t,userId:e,plan:i,mrr:r,billingCycle:n})}change(t,e,i,r,n,s,a){return this.client.change({subscriptionId:t,userId:e,previousPlan:i,newPlan:r,previousMrr:n,newMrr:s,changeType:a})}cancel(t,e,i,r,n=!1){return this.client.cancel({subscriptionId:t,userId:e,plan:i,lostMrr:r,immediate:n})}renew(t,e,i){return this.client.renew(t,e,i)}trialConverted(t,e,i,r){return this.client.trialConverted(t,e,i,r)}trialExpired(t,e){return this.client.trialExpired(t,e)}}class Ot{constructor(t){this.client=t}dwell(t,e,i){return this.client.trackDwellTime({featureId:t,dwellTimeMs:e,properties:i})}sessionDepth(t,e,i,r,n){return this.client.trackSessionDepth({sessionId:t,pagesVisited:e,featuresUsed:i,actionsTaken:r,durationMs:n})}contentConsumption(t,e,i,r){return this.client.trackContentConsumption({contentId:t,contentType:e,percentageConsumed:i,timeSpentMs:r})}activity(t,e,i){return this.client.trackUserActivity({userId:t,activityType:e,durationMs:i})}autoTrackDwell(t,e){return this.client.autoTrackDwell(t,e)}autoTrack(t){return this.client.autoTrack(t)}}class xt{constructor(t){this.client=t}create(t){return this.client.createCohort(t)}segment(t){return this.client.createSegment(t)}isMember(t,e){return this.client.isUserInCohort(t,e)}}class Ct{constructor(t){this.client=t}decay(t,e,i){return this.client.trackUsageDecay({userId:t,metric:e,periods:i})}nps(t,e,i){return this.client.trackNPS({userId:t,score:e,feedback:i})}churned(t,e,i){return this.client.trackChurn({userId:t,churnType:e,reason:i})}prevention(t,e,i){return this.client.trackPreventionAction({userId:t,actionType:e,details:i})}}class Tt{constructor(t){this.client=t}revenue(t,e,i,r,n){return this.client.trackRevenue({userId:t,amount:e,currency:i,type:r,properties:n})}}class Et{constructor(t){this.client=t}define(t){return this.client.defineFunnel(t)}step(t,e,i,r){return this.client.trackStep({funnelId:t,step:e,userId:i,properties:r})}microConversion(t,e,i){return this.client.trackMicroConversion({conversionId:t,userId:e,properties:i})}}class At{constructor(t){this.client=t}ticket(t,e,i,r,n,s){return this.client.trackTicket({ticketId:t,userId:e,subject:i,category:r,priority:n,channel:s})}update(t,e,i){return this.client.updateTicket({ticketId:t,status:e,properties:i})}csat(t,e,i,r){return this.client.trackCSAT({ticketId:t,userId:e,score:i,feedback:r})}featureComplaint(t,e,i,r){return this.client.trackFeatureComplaint({userId:t,featureId:e,complaintType:i,severity:r})}}class Ft{constructor(t){this.client=t}acquired(t,e,i){return this.client.trackAcquisition({userId:t,source:e,properties:i})}campaign(t){return this.client.createCampaign(t)}spend(t,e,i){return this.client.trackCampaignSpend({campaignId:t,amount:e,date:i})}lifecycle(t,e,i){return this.client.trackLifecycleTransition({userId:t,fromStage:e,toStage:i})}}class Mt{constructor(t){this.client=t}transition(t,e,i,r){return this.client.trackTransition({userId:t,fromScreen:e,toScreen:i,properties:r})}sequence(t,e,i){return this.client.trackFeatureSequence({userId:t,feature:e,order:i})}define(t){return this.client.definePath(t)}}class Nt{constructor(t){this.client=t}create(t){return this.client.createAlert(t)}update(t,e){return this.client.updateAlert(t,e)}delete(t){return this.client.deleteAlert(t)}acknowledge(t,e){return this.client.acknowledgeAlert(t,e)}resolve(t,e){return this.client.resolveAlert(t,e)}mute(t,e){return this.client.muteAlert(t,e)}}class Lt{constructor(t){this.client=t}login(t,e,i){return this.client.trackLoginAttempt({userId:t,success:e,properties:i})}roleChange(t,e,i,r){return this.client.trackRoleChange({userId:t,changedBy:e,previousRole:i,newRole:r})}permissionChange(t,e,i,r){return this.client.trackPermissionChange({userId:t,changedBy:e,permission:i,action:r})}dataAccess(t,e,i,r){return this.client.trackDataAccess({userId:t,resourceType:e,accessType:i,properties:r})}compliance(t,e,i){return this.client.trackComplianceEvent({userId:t,eventType:e,properties:i})}}class Ut{constructor(t){this.client=t}activeUsers(t,e,i){return this.client.forecastActiveUsers({metric:t,periods:e,granularity:i})}revenue(t,e){return this.client.forecastRevenue({periods:t,granularity:e})}featureAdoption(t,e,i){return this.client.forecastFeatureAdoption({featureId:t,periods:e,granularity:i})}churn(t,e){return this.client.forecastChurn({periods:t,granularity:e})}}class Bt{static init(t){if(Bt._instance)return"undefined"!=typeof console&&console.warn("[FlowGrid] init() called more than once — returning existing instance."),Bt._instance;if(!t?.webId||!t?.apiKey)throw new Error("FlowGrid.init: `webId` and `apiKey` are required.");t.consent&&Bt.setConsent(t.consent);const e=new Bt(t.webId,t.endpoint??"https://core.flow-grid.xyz",t.apiKey,t.visitorId,t.identityManager,t.transport);Bt._instance=e,t.user?.userId&&e.identifyUser(t.user.userId,t.user.traits);const i=t.autoTrack,r=t.replay,n=!1===i?{sessions:!1,pageViews:!1,performance:!1,heatmaps:!1,attribution:!1,engagement:!1}:!0===i||void 0===i?{}:i;return void 0!==r&&void 0===n.replay&&(n.replay=r),e._autoTrackStop=e.autoTrack({...n,userId:t.user?.userId??n.userId}),e}static instance(){return Bt._instance}static reset(){if(Bt._instance?._autoTrackStop)try{Bt._instance._autoTrackStop()}catch{}Bt._instance=null}constructor(t,e,i,r,n,s){this._autoTrackStop=null,this._raw=new Map,this._wrapped=new Map,this.webId=t,this.endpoint=e,this.apiKey=i,this.visitorId=r,this.identityManager=n??new d(r?{visitorId:r}:void 0),this.config=s}raw(t,e){let i=this._raw.get(t);return i||(i=new e(this.webId,this.endpoint,this.apiKey,this.visitorId,this.identityManager,this.config),this._raw.set(t,i)),i}wrap(t,e,i){let r=this._wrapped.get(t);return r||(r=new i(this.raw(t,e)),this._wrapped.set(t,r)),r}get activation(){return this.wrap("activation",l,it)}get features(){return this.wrap("features",m,rt)}get prompts(){return this.wrap("prompts",h,nt)}get experiments(){return this.wrap("experiments",w,st)}get pageViews(){return this.wrap("pageViews",k,at)}get sessions(){return this.wrap("sessions",b,ot)}get events(){return this.wrap("events",D,ct)}get identify(){return this.wrap("identify",O,ut)}get funnels(){return this.wrap("funnels",x,pt)}get retention(){return this.wrap("retention",C,dt)}get attribution(){return this.wrap("attribution",T,lt)}get heatmaps(){return this.wrap("heatmaps",E,mt)}get performance(){return this.wrap("performance",A,ht)}get replay(){return this.wrap("replay",N,yt)}get products(){return this.wrap("products",L,gt)}get cart(){return this.wrap("cart",U,It)}get checkout(){return this.wrap("checkout",B,wt)}get purchases(){return this.wrap("purchases",R,ft)}get refunds(){return this.wrap("refunds",P,St)}get promotions(){return this.wrap("promotions",V,vt)}get wishlist(){return this.wrap("wishlist",q,_t)}get ltv(){return this.wrap("ltv",$,kt)}get search(){return this.wrap("search",j,bt)}get subscriptions(){return this.wrap("subscriptions",z,Dt)}get engagement(){return this.wrap("engagement",H,Ot)}get cohorts(){return this.wrap("cohorts",K,xt)}get churn(){return this.wrap("churn",J,Ct)}get monetization(){return this.wrap("monetization",W,Tt)}get multiPathFunnels(){return this.wrap("multiPathFunnels",Y,Et)}get support(){return this.wrap("support",Q,At)}get acquisition(){return this.wrap("acquisition",X,Ft)}get paths(){return this.wrap("paths",G,Mt)}get alerts(){return this.wrap("alerts",Z,Nt)}get security(){return this.wrap("security",tt,Lt)}get forecasting(){return this.wrap("forecasting",et,Ut)}track(t,e,i){return this.events.track(t,e,i)}experiment(t,e){return this.experiments.exposure(t,e.userId,e.variant)}identifyUser(t,e,i){return this.identify.user(t,e,i)}page(t,e,i){return this.pageViews.view(t,e,i)}autoTrack(t={}){const e=[],i={userId:t.userId};if(!1!==t.sessions&&e.push(this.sessions.autoTrack(i.userId?{user:{userId:i.userId}}:{})),!1!==t.pageViews&&e.push(this.pageViews.autoTrack(i)),!1!==t.performance){const r="object"==typeof t.performance?t.performance:{};e.push(this.performance.autoTrack({...r,userId:i.userId}))}if(!1!==t.heatmaps){const r="object"==typeof t.heatmaps?t.heatmaps:{};e.push(this.heatmaps.autoTrack({...r,userId:i.userId}))}if(!1!==t.engagement){const r="object"==typeof t.engagement?t.engagement:{};e.push(this.engagement.client.autoTrack({...r,userId:i.userId}))}if(!1!==t.attribution&&i.userId&&this.attribution.captureFromUrl(i.userId),t.replay){const r="object"==typeof t.replay?t.replay:{};let n=null,s=!1;this.replay.start({userId:i.userId,...r}).then(t=>{if(s)try{t()}catch{}else n=t}),e.push(()=>{if(s=!0,n)try{n()}catch{}})}return()=>{for(const t of e)try{t()}catch{}}}}Bt._instance=null,Bt.setConsent=a.setConsent.bind(a),Bt.hasConsent=a.hasConsent.bind(a);const Rt=Bt;return s.default})());
2
+ //# sourceMappingURL=index.js.map