bitsnap-react 1.12.1 → 1.14.0

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 (109) hide show
  1. package/README.md +19 -6
  2. package/dist/CartProvider-6D5WE2HA.js +2 -0
  3. package/dist/CartProvider-6D5WE2HA.js.map +1 -0
  4. package/dist/CartProvider-GLUQHAG3.mjs +2 -0
  5. package/dist/analytics.d.mts +2 -2
  6. package/dist/analytics.d.ts +2 -2
  7. package/dist/analytics.js +1 -1
  8. package/dist/analytics.js.map +1 -1
  9. package/dist/analytics.mjs +1 -1
  10. package/dist/catalog.d.mts +1 -1
  11. package/dist/catalog.d.ts +1 -1
  12. package/dist/catalog.js +1 -1
  13. package/dist/catalog.js.map +1 -1
  14. package/dist/catalog.mjs +1 -1
  15. package/dist/{chunk-HDLCLZOK.js → chunk-3N2VK426.js} +2 -2
  16. package/dist/chunk-3N2VK426.js.map +1 -0
  17. package/dist/{chunk-T2YSOHJM.mjs → chunk-3OEKRPWV.mjs} +2 -2
  18. package/dist/{chunk-T2YSOHJM.mjs.map → chunk-3OEKRPWV.mjs.map} +1 -1
  19. package/dist/{chunk-I6BRDRPB.js → chunk-5DDLYVBG.js} +2 -2
  20. package/dist/chunk-5DDLYVBG.js.map +1 -0
  21. package/dist/{chunk-4ZFIL5S7.js → chunk-7SYNGA3R.js} +2 -2
  22. package/dist/chunk-7SYNGA3R.js.map +1 -0
  23. package/dist/chunk-AWG5OAK7.js +2 -0
  24. package/dist/chunk-AWG5OAK7.js.map +1 -0
  25. package/dist/{chunk-G3VVAVG7.mjs → chunk-CYLZ5GYW.mjs} +2 -2
  26. package/dist/{chunk-STVEBT6M.js → chunk-FLDI3BPY.js} +2 -2
  27. package/dist/chunk-FLDI3BPY.js.map +1 -0
  28. package/dist/chunk-GKFET34B.mjs +2 -0
  29. package/dist/chunk-GKFET34B.mjs.map +1 -0
  30. package/dist/chunk-JSDGZ4NY.js.map +1 -1
  31. package/dist/{chunk-3ITTSNWG.js → chunk-JXVAT2ZE.js} +2 -2
  32. package/dist/chunk-JXVAT2ZE.js.map +1 -0
  33. package/dist/chunk-KOYBZORL.js.map +1 -1
  34. package/dist/chunk-MDCP5JNP.mjs +2 -0
  35. package/dist/chunk-MDCP5JNP.mjs.map +1 -0
  36. package/dist/{chunk-VF62KDNS.mjs → chunk-MVOJMCZG.mjs} +2 -2
  37. package/dist/{chunk-MZSLLGFS.js → chunk-PLS5RR27.js} +2 -2
  38. package/dist/chunk-PLS5RR27.js.map +1 -0
  39. package/dist/{chunk-VRL3IF5J.js → chunk-R2M6W4LD.js} +3 -3
  40. package/dist/chunk-R2M6W4LD.js.map +1 -0
  41. package/dist/{chunk-HBPSSGYN.mjs → chunk-SKFE6TUP.mjs} +2 -2
  42. package/dist/{chunk-GJNFDUJN.mjs → chunk-U5SAO2SH.mjs} +3 -3
  43. package/dist/chunk-U5SAO2SH.mjs.map +1 -0
  44. package/dist/{chunk-DRAKVCD7.mjs → chunk-VY7RNSFP.mjs} +2 -2
  45. package/dist/{chunk-VDLJW4JJ.mjs → chunk-VYYUTJZB.mjs} +2 -2
  46. package/dist/chunk-W3RGQYPD.js +2 -0
  47. package/dist/chunk-W3RGQYPD.js.map +1 -0
  48. package/dist/consent.js +4 -4
  49. package/dist/consent.js.map +1 -1
  50. package/dist/consent.mjs +4 -4
  51. package/dist/consent.mjs.map +1 -1
  52. package/dist/course.d.mts +2 -2
  53. package/dist/course.d.ts +2 -2
  54. package/dist/course.js +1 -1
  55. package/dist/course.js.map +1 -1
  56. package/dist/course.mjs +1 -1
  57. package/dist/embed/analytics.js +1 -1
  58. package/dist/embed/consent.js +4 -4
  59. package/dist/errors.js.map +1 -1
  60. package/dist/index.d.mts +20 -10
  61. package/dist/index.d.ts +20 -10
  62. package/dist/index.js +1 -1
  63. package/dist/index.js.map +1 -1
  64. package/dist/index.mjs +1 -1
  65. package/dist/index.mjs.map +1 -1
  66. package/dist/{instrument-CmxK7S4T.d.mts → instrument-BE8ktMUv.d.mts} +14 -0
  67. package/dist/{instrument-CmxK7S4T.d.ts → instrument-BE8ktMUv.d.ts} +14 -0
  68. package/dist/internal.js.map +1 -1
  69. package/dist/methods-N35A2OGE.mjs +2 -0
  70. package/dist/methods-WSICR2JH.js +2 -0
  71. package/dist/methods-WSICR2JH.js.map +1 -0
  72. package/dist/models.js.map +1 -1
  73. package/dist/returns.d.mts +1 -1
  74. package/dist/returns.d.ts +1 -1
  75. package/dist/returns.js +1 -1
  76. package/dist/returns.js.map +1 -1
  77. package/dist/returns.mjs +1 -1
  78. package/dist/{types-BnVWLcoB.d.mts → types-DP1vxo5E.d.mts} +1 -1
  79. package/dist/{types-i-IuN4Im.d.ts → types-u8VwmC3j.d.ts} +1 -1
  80. package/package.json +38 -13
  81. package/dist/CartProvider-WPJWECBS.mjs +0 -2
  82. package/dist/CartProvider-YPZ3HD7W.js +0 -2
  83. package/dist/CartProvider-YPZ3HD7W.js.map +0 -1
  84. package/dist/chunk-3ITTSNWG.js.map +0 -1
  85. package/dist/chunk-4BV5IUZH.js +0 -2
  86. package/dist/chunk-4BV5IUZH.js.map +0 -1
  87. package/dist/chunk-4ZFIL5S7.js.map +0 -1
  88. package/dist/chunk-ADYVTMGH.mjs +0 -2
  89. package/dist/chunk-ADYVTMGH.mjs.map +0 -1
  90. package/dist/chunk-GJNFDUJN.mjs.map +0 -1
  91. package/dist/chunk-HDLCLZOK.js.map +0 -1
  92. package/dist/chunk-I6BRDRPB.js.map +0 -1
  93. package/dist/chunk-MZSLLGFS.js.map +0 -1
  94. package/dist/chunk-STVEBT6M.js.map +0 -1
  95. package/dist/chunk-T3PAOMHI.mjs +0 -2
  96. package/dist/chunk-T3PAOMHI.mjs.map +0 -1
  97. package/dist/chunk-VRL3IF5J.js.map +0 -1
  98. package/dist/chunk-XIHGWNTS.js +0 -2
  99. package/dist/chunk-XIHGWNTS.js.map +0 -1
  100. package/dist/methods-FVDH6Y57.mjs +0 -2
  101. package/dist/methods-ISVX5JQ7.js +0 -2
  102. package/dist/methods-ISVX5JQ7.js.map +0 -1
  103. /package/dist/{CartProvider-WPJWECBS.mjs.map → CartProvider-GLUQHAG3.mjs.map} +0 -0
  104. /package/dist/{chunk-G3VVAVG7.mjs.map → chunk-CYLZ5GYW.mjs.map} +0 -0
  105. /package/dist/{chunk-VF62KDNS.mjs.map → chunk-MVOJMCZG.mjs.map} +0 -0
  106. /package/dist/{chunk-HBPSSGYN.mjs.map → chunk-SKFE6TUP.mjs.map} +0 -0
  107. /package/dist/{chunk-DRAKVCD7.mjs.map → chunk-VY7RNSFP.mjs.map} +0 -0
  108. /package/dist/{chunk-VDLJW4JJ.mjs.map → chunk-VYYUTJZB.mjs.map} +0 -0
  109. /package/dist/{methods-FVDH6Y57.mjs.map → methods-N35A2OGE.mjs.map} +0 -0
package/README.md CHANGED
@@ -154,7 +154,7 @@ built-in styles):
154
154
  | `countrySearch` | Country search field |
155
155
  | `countryOption` | Single country option |
156
156
  | `paymentButtons` | Apple Pay / Google Pay wrappers |
157
- | `paymentMethods` | "How would you like to pay?" group (online or transfer / BLIK to a phone) |
157
+ | `paymentMethods` | "How would you like to pay?" group (online, transfer / BLIK to a phone, cash on delivery) |
158
158
  | `paymentMethodOption`| Single payment method card |
159
159
  | `checkoutButton` | "Next step" button |
160
160
  | `emptyState` | Empty cart message |
@@ -361,9 +361,10 @@ Checkout keys (`CheckoutTexts`): `cart`, `emptyCart`, `total`, `delivery`,
361
361
  `paymentMethodOnline`, `paymentMethodOnlineDescription`,
362
362
  `paymentMethodManualTransfer`, `paymentMethodManualBlik`,
363
363
  `paymentMethodManualBoth`, `paymentMethodManualDescription`,
364
- `paymentMethodManualBlikNote`.
364
+ `paymentMethodManualBlikNote`, `paymentMethodCod`,
365
+ `paymentMethodCodDescription`, `paymentMethodCodUnavailable`.
365
366
 
366
- ### Paying online or by transfer / BLIK to a phone
367
+ ### Paying online, by transfer / BLIK to a phone or on delivery
367
368
 
368
369
  When the shop turned on manual payments with "show at checkout", the cart asks
369
370
  the buyer how they want to pay before "Next step": online (card, BLIK code,
@@ -374,11 +375,23 @@ seller's account and phone number are shown only after the order is placed, on
374
375
  the Bitsnap payment page the cart redirects to; the order waits for the payment
375
376
  there and the cart is cleared.
376
377
 
378
+ When the shop offers cash on delivery and the cart qualifies (delivery to
379
+ Poland, at least one shipped product, no subscription), the cart lists
380
+ "Płatność przy odbiorze" / "Cash on delivery" last. The buyer pays the courier.
381
+ Like any order, the cart is kept until the buyer has finished the order's
382
+ details form: the order is then "placed" (or "paid" once the seller marks it)
383
+ and its lines leave the cart. A buyer who goes back from the form still has the
384
+ cart. The cart asks again when the buyer changes the country; until the answer
385
+ arrives it keeps showing the last choice without cash on delivery. If the shop refuses cash on delivery for the order
386
+ anyway, the cart shows `paymentMethodCodUnavailable` and asks for the methods
387
+ again.
388
+
377
389
  The cart asks `POST /public-commerce/payment-methods` (same body as `/buy`) once
378
390
  per cart content. `choice: null`, an error, a timeout (5 s) or an older
379
391
  bitsnap.pl that does not have the endpoint leave the cart as before: no choice
380
- and a plain `/buy`. `/buy` gets `paymentMethod: "online" | "manual"` only when
381
- the choice was shown. Apple Pay and Google Pay are online payments and do not
392
+ and a plain `/buy`. `/buy` gets `paymentMethod: "online" | "manual" | "cod"`
393
+ only when the choice was shown; the choice appears whenever the answer lists
394
+ two or more methods this version knows (others are ignored). Apple Pay and Google Pay are online payments and do not
382
395
  change.
383
396
 
384
397
  When "Next step" fails, the cart shows the text of the backend error code
@@ -1302,7 +1315,7 @@ The standalone file is `dist/embed/consent.js` (about 9 KB gzipped, no React). A
1302
1315
 
1303
1316
  For a live preview in a settings page, add `data-preview="on"`: the banner is shown on every load, nothing is read from or written to the cookie, and nothing is sent to the collect host. `data-title` and `data-description` replace the banner heading and text (the same options exist as `preview`, `title` and `description` in the core `ConsentOptions`).
1304
1317
 
1305
- With `data-project` the banner loads its config from `/api/consent/config` (3 s timeout, then defaults) and sends each choice to `<collect host>/consent`. Without it nothing leaves the page.
1318
+ With `data-project` the banner loads its config from `/api/consent/config` (3 s timeout, then defaults) and sends each choice to `<collect host>/consent`. When the banner opens on its own (no valid stored choice, or a newer banner version), it also sends one anonymous impression ping per page load, `{ k, action: "shown", bv, host, ts }`: no id, no choice, nothing stored, and none when the visitor reopens the settings. Without a project key nothing leaves the page.
1306
1319
 
1307
1320
  ### React
1308
1321
 
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkR2M6W4LDjs = require('./chunk-R2M6W4LD.js');require('./chunk-FLDI3BPY.js');require('./chunk-KOYBZORL.js');require('./chunk-5DDLYVBG.js');require('./chunk-7SYNGA3R.js');var _chunkAWG5OAK7js = require('./chunk-AWG5OAK7.js');require('./chunk-3N2VK426.js');require('./chunk-W3RGQYPD.js');require('./chunk-JSDGZ4NY.js');exports.MARKETING_AGREEMENT_ID = _chunkR2M6W4LDjs.L; exports.bitsnapProjectID = _chunkR2M6W4LDjs.M; exports.default = _chunkR2M6W4LDjs.T; exports.getCartLines = _chunkR2M6W4LDjs.Q; exports.getCheckoutMethods = _chunkR2M6W4LDjs.U; exports.getCheckoutSelection = _chunkR2M6W4LDjs.P; exports.getLocale = _chunkAWG5OAK7js.m; exports.getProjectID = _chunkR2M6W4LDjs.O; exports.reconcileOrderOfLastPayment = _chunkR2M6W4LDjs.R; exports.setLocale = _chunkAWG5OAK7js.l; exports.setProjectID = _chunkR2M6W4LDjs.N; exports.useCartProvider = _chunkR2M6W4LDjs.S;
2
+ //# sourceMappingURL=CartProvider-6D5WE2HA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/emems/.t3/worktrees/bitsnap-react/consent-shown/dist/CartProvider-6D5WE2HA.js"],"names":[],"mappings":"AAAA,+HAAsG,+BAA4B,+BAA4B,+BAA4B,+BAA4B,sDAA+C,+BAA4B,+BAA4B,+BAA4B,siBAAmQ","file":"/home/emems/.t3/worktrees/bitsnap-react/consent-shown/dist/CartProvider-6D5WE2HA.js"}
@@ -0,0 +1,2 @@
1
+ import{L as c,M as d,N as e,O as f,P as g,Q as h,R as i,S as j,T as k,U as l}from"./chunk-U5SAO2SH.mjs";import"./chunk-CYLZ5GYW.mjs";import"./chunk-KOVKUJAW.mjs";import"./chunk-SKFE6TUP.mjs";import"./chunk-MVOJMCZG.mjs";import{l as a,m as b}from"./chunk-GKFET34B.mjs";import"./chunk-3OEKRPWV.mjs";import"./chunk-MDCP5JNP.mjs";import"./chunk-U6FLIRIV.mjs";export{c as MARKETING_AGREEMENT_ID,d as bitsnapProjectID,k as default,h as getCartLines,l as getCheckoutMethods,g as getCheckoutSelection,b as getLocale,f as getProjectID,i as reconcileOrderOfLastPayment,a as setLocale,e as setProjectID,j as useCartProvider};
2
+ //# sourceMappingURL=CartProvider-GLUQHAG3.mjs.map
@@ -1,5 +1,5 @@
1
- import { T as Tracker, a as TrackerOptions, C as ClientEvent } from './instrument-CmxK7S4T.mjs';
2
- export { A as AnalyticsOption, d as AppEventName, B as BrowserEventName, e as Channel, D as DEFAULT_ENDPOINT, E as Env, f as EventName, h as EventProps, l as Instrument, I as InstrumentProvider, P as PageType, S as Source, j as StorefrontEventName, b as TrackExtra, c as createTracker, g as getTracker, i as initTracker, n as noopInstrument, r as resetTracker, s as scoreBucket, u as useInstrument, k as useInstrumentContext } from './instrument-CmxK7S4T.mjs';
1
+ import { T as Tracker, a as TrackerOptions, C as ClientEvent } from './instrument-BE8ktMUv.mjs';
2
+ export { A as AnalyticsOption, d as AppEventName, B as BrowserEventName, e as Channel, D as DEFAULT_ENDPOINT, E as Env, f as EventName, h as EventProps, l as Instrument, I as InstrumentProvider, P as PageType, S as Source, j as StorefrontEventName, b as TrackExtra, c as createTracker, g as getTracker, i as initTracker, n as noopInstrument, r as resetTracker, s as scoreBucket, u as useInstrument, k as useInstrumentContext } from './instrument-BE8ktMUv.mjs';
3
3
  import * as react from 'react';
4
4
  import { ReactNode } from 'react';
5
5
 
@@ -1,5 +1,5 @@
1
- import { T as Tracker, a as TrackerOptions, C as ClientEvent } from './instrument-CmxK7S4T.js';
2
- export { A as AnalyticsOption, d as AppEventName, B as BrowserEventName, e as Channel, D as DEFAULT_ENDPOINT, E as Env, f as EventName, h as EventProps, l as Instrument, I as InstrumentProvider, P as PageType, S as Source, j as StorefrontEventName, b as TrackExtra, c as createTracker, g as getTracker, i as initTracker, n as noopInstrument, r as resetTracker, s as scoreBucket, u as useInstrument, k as useInstrumentContext } from './instrument-CmxK7S4T.js';
1
+ import { T as Tracker, a as TrackerOptions, C as ClientEvent } from './instrument-BE8ktMUv.js';
2
+ export { A as AnalyticsOption, d as AppEventName, B as BrowserEventName, e as Channel, D as DEFAULT_ENDPOINT, E as Env, f as EventName, h as EventProps, l as Instrument, I as InstrumentProvider, P as PageType, S as Source, j as StorefrontEventName, b as TrackExtra, c as createTracker, g as getTracker, i as initTracker, n as noopInstrument, r as resetTracker, s as scoreBucket, u as useInstrument, k as useInstrumentContext } from './instrument-BE8ktMUv.js';
3
3
  import * as react from 'react';
4
4
  import { ReactNode } from 'react';
5
5
 
package/dist/analytics.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkHDLCLZOKjs = require('./chunk-HDLCLZOK.js');require('./chunk-XIHGWNTS.js');require('./chunk-JSDGZ4NY.js');exports.BitsnapAnalyticsProvider = _chunkHDLCLZOKjs.i; exports.DEFAULT_ENDPOINT = _chunkHDLCLZOKjs.c; exports.InstrumentProvider = _chunkHDLCLZOKjs.l; exports.createTracker = _chunkHDLCLZOKjs.d; exports.getTracker = _chunkHDLCLZOKjs.f; exports.initTracker = _chunkHDLCLZOKjs.e; exports.noopInstrument = _chunkHDLCLZOKjs.k; exports.resetTracker = _chunkHDLCLZOKjs.g; exports.scoreBucket = _chunkHDLCLZOKjs.r; exports.startAutoPageViews = _chunkHDLCLZOKjs.b; exports.useAnalytics = _chunkHDLCLZOKjs.j; exports.useInstrument = _chunkHDLCLZOKjs.n; exports.useInstrumentContext = _chunkHDLCLZOKjs.m;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk3N2VK426js = require('./chunk-3N2VK426.js');require('./chunk-W3RGQYPD.js');require('./chunk-JSDGZ4NY.js');exports.BitsnapAnalyticsProvider = _chunk3N2VK426js.i; exports.DEFAULT_ENDPOINT = _chunk3N2VK426js.c; exports.InstrumentProvider = _chunk3N2VK426js.l; exports.createTracker = _chunk3N2VK426js.d; exports.getTracker = _chunk3N2VK426js.f; exports.initTracker = _chunk3N2VK426js.e; exports.noopInstrument = _chunk3N2VK426js.k; exports.resetTracker = _chunk3N2VK426js.g; exports.scoreBucket = _chunk3N2VK426js.r; exports.startAutoPageViews = _chunk3N2VK426js.b; exports.useAnalytics = _chunk3N2VK426js.j; exports.useInstrument = _chunk3N2VK426js.n; exports.useInstrumentContext = _chunk3N2VK426js.m;
2
2
  //# sourceMappingURL=analytics.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/emems/.t3/worktrees/bitsnap-react/cart-payment-method/dist/analytics.js"],"names":[],"mappings":"AAAA,+HAAsH,+BAA4B,+BAA4B,klBAAsR","file":"/home/emems/.t3/worktrees/bitsnap-react/cart-payment-method/dist/analytics.js"}
1
+ {"version":3,"sources":["/home/emems/.t3/worktrees/bitsnap-react/consent-shown/dist/analytics.js"],"names":[],"mappings":"AAAA,+HAAsH,+BAA4B,+BAA4B,klBAAsR","file":"/home/emems/.t3/worktrees/bitsnap-react/consent-shown/dist/analytics.js"}
@@ -1,2 +1,2 @@
1
- import{b as e,c as t,d as r,e as n,f as o,g as a,i as s,j as p,k as c,l as i,m,n as u,r as v}from"./chunk-T2YSOHJM.mjs";import"./chunk-ADYVTMGH.mjs";import"./chunk-U6FLIRIV.mjs";export{s as BitsnapAnalyticsProvider,t as DEFAULT_ENDPOINT,i as InstrumentProvider,r as createTracker,o as getTracker,n as initTracker,c as noopInstrument,a as resetTracker,v as scoreBucket,e as startAutoPageViews,p as useAnalytics,u as useInstrument,m as useInstrumentContext};
1
+ import{b as e,c as t,d as r,e as n,f as o,g as a,i as s,j as p,k as c,l as i,m,n as u,r as v}from"./chunk-3OEKRPWV.mjs";import"./chunk-MDCP5JNP.mjs";import"./chunk-U6FLIRIV.mjs";export{s as BitsnapAnalyticsProvider,t as DEFAULT_ENDPOINT,i as InstrumentProvider,r as createTracker,o as getTracker,n as initTracker,c as noopInstrument,a as resetTracker,v as scoreBucket,e as startAutoPageViews,p as useAnalytics,u as useInstrument,m as useInstrumentContext};
2
2
  //# sourceMappingURL=analytics.mjs.map
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
- import { A as AnalyticsOption } from './instrument-CmxK7S4T.mjs';
3
+ import { A as AnalyticsOption } from './instrument-BE8ktMUv.mjs';
4
4
  import { S as SlotAppearance, A as AppearanceElements } from './appearance-core-Dt2grZdl.mjs';
5
5
  import { BitsnapModels } from './models.mjs';
6
6
  import 'zod';
package/dist/catalog.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
- import { A as AnalyticsOption } from './instrument-CmxK7S4T.js';
3
+ import { A as AnalyticsOption } from './instrument-BE8ktMUv.js';
4
4
  import { S as SlotAppearance, A as AppearanceElements } from './appearance-core-Dt2grZdl.js';
5
5
  import { BitsnapModels } from './models.js';
6
6
  import 'zod';
package/dist/catalog.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk3ITTSNWGjs = require('./chunk-3ITTSNWG.js');require('./chunk-KOYBZORL.js');require('./chunk-4BV5IUZH.js');require('./chunk-HDLCLZOK.js');require('./chunk-XIHGWNTS.js');require('./chunk-JSDGZ4NY.js');exports.PRODUCT_LIST_SLOT_NAMES = _chunk3ITTSNWGjs.a; exports.ProductList = _chunk3ITTSNWGjs.d; exports.formatProductPrice = _chunk3ITTSNWGjs.b; exports.useProducts = _chunk3ITTSNWGjs.c;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkJXVAT2ZEjs = require('./chunk-JXVAT2ZE.js');require('./chunk-KOYBZORL.js');require('./chunk-AWG5OAK7.js');require('./chunk-3N2VK426.js');require('./chunk-W3RGQYPD.js');require('./chunk-JSDGZ4NY.js');exports.PRODUCT_LIST_SLOT_NAMES = _chunkJXVAT2ZEjs.a; exports.ProductList = _chunkJXVAT2ZEjs.d; exports.formatProductPrice = _chunkJXVAT2ZEjs.b; exports.useProducts = _chunkJXVAT2ZEjs.c;
2
2
  //# sourceMappingURL=catalog.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/emems/.t3/worktrees/bitsnap-react/cart-payment-method/dist/catalog.js"],"names":[],"mappings":"AAAA,+HAA4D,+BAA4B,+BAA4B,+BAA4B,+BAA4B,+BAA4B,0LAA+F","file":"/home/emems/.t3/worktrees/bitsnap-react/cart-payment-method/dist/catalog.js"}
1
+ {"version":3,"sources":["/home/emems/.t3/worktrees/bitsnap-react/consent-shown/dist/catalog.js"],"names":[],"mappings":"AAAA,+HAA4D,+BAA4B,+BAA4B,+BAA4B,+BAA4B,+BAA4B,0LAA+F","file":"/home/emems/.t3/worktrees/bitsnap-react/consent-shown/dist/catalog.js"}
package/dist/catalog.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{a as o,b as r,c as e,d as f}from"./chunk-VDLJW4JJ.mjs";import"./chunk-KOVKUJAW.mjs";import"./chunk-T3PAOMHI.mjs";import"./chunk-T2YSOHJM.mjs";import"./chunk-ADYVTMGH.mjs";import"./chunk-U6FLIRIV.mjs";export{o as PRODUCT_LIST_SLOT_NAMES,f as ProductList,r as formatProductPrice,e as useProducts};
1
+ import{a as o,b as r,c as e,d as f}from"./chunk-VYYUTJZB.mjs";import"./chunk-KOVKUJAW.mjs";import"./chunk-GKFET34B.mjs";import"./chunk-3OEKRPWV.mjs";import"./chunk-MDCP5JNP.mjs";import"./chunk-U6FLIRIV.mjs";export{o as PRODUCT_LIST_SLOT_NAMES,f as ProductList,r as formatProductPrice,e as useProducts};
2
2
  //# sourceMappingURL=catalog.mjs.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkXIHGWNTSjs = require('./chunk-XIHGWNTS.js');var Oe=Symbol.for("bitsnap.pageViews");function ye(e){let t=e;return t[Oe]??={path:null,starters:new Set,watching:!1}}function De(e,t){let n=()=>{try{t()}catch (e2){}};for(let o of["pushState","replaceState"]){let a=e.history[o];e.history[o]=function(...i){let c=a.apply(this,i);return n(),c}}e.addEventListener("popstate",n)}function A(e,t=window){try{let n=ye(t),o=()=>e();n.watching||(n.watching=!0,De(t,()=>{let i=t.location.pathname;i===n.path||n.starters.size===0||(n.path=i,_optionalChain([n, 'access', _2 => _2.starters, 'access', _3 => _3.values, 'call', _4 => _4(), 'access', _5 => _5.next, 'call', _6 => _6(), 'access', _7 => _7.value, 'optionalCall', _8 => _8()]))})),n.starters.add(o);let a=t.location.pathname;return a!==n.path&&(n.path=a,o()),()=>void n.starters.delete(o)}catch (e3){return()=>{}}}function ge(e=window){let t=ye(e);t.path=null,t.starters.clear()}var ve="1.12.1";function I(e){let t=new Uint8Array(e),n=typeof crypto<"u"?crypto:void 0;if(n&&typeof n.getRandomValues=="function")n.getRandomValues(t);else for(let o=0;o<e;o++)t[o]=Math.floor(Math.random()*256);return t}var me="X-Bitsnap-Visitor",$e=390*24*60*60,Me=/^[A-Za-z0-9_-]{22}$/;function R(e){return e.BitsnapConsent}function je(e,t){for(let n of e.cookie.split(";")){let o=n.indexOf("=");if(o!==-1&&n.slice(0,o).trim()===t)return n.slice(o+1).trim()}return null}function He(e){let t=e.toLowerCase();return t==="bitsnap.pl"||t.endsWith(".bitsnap.pl")}function F(e,t){try{let n=R(e);if(!n)return!1;if(n.scope==="project")return n.projectKey===t;let o=He(e.location.hostname);return n.scope==="global"?!o:!1}catch (e4){return!1}}function J(e,t){try{return _optionalChain([R, 'call', _9 => _9(e), 'optionalAccess', _10 => _10.get, 'call', _11 => _11(), 'optionalAccess', _12 => _12.c, 'access', _13 => _13.analytics])===!0&&F(e,t)}catch (e5){return!1}}function he(){let e="";return I(16).forEach(t=>e+=String.fromCharCode(t)),btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Ee(e,t){try{return je(e,_chunkXIHGWNTSjs.f.call(void 0, t))}catch (e6){return null}}function B(e,t){let n=Ee(e,t);return n!==null&&Me.test(n)?n:null}function ke(e,t,n){try{let o=e.document,a=`${_chunkXIHGWNTSjs.f.call(void 0, t)}=${n}; Max-Age=${$e}; Path=/; SameSite=Lax`+(e.location.protocol==="https:"?"; Secure":"");for(let i of _chunkXIHGWNTSjs.n.call(void 0, e.location.hostname).reverse())if(o.cookie=`${a}; Domain=${i}`,B(o,t)===n)return;o.cookie=a}catch (e7){}}function be(e,t){try{let n=e.document;if(Ee(n,t)===null)return;let o=`${_chunkXIHGWNTSjs.f.call(void 0, t)}=; Max-Age=0; Path=/; SameSite=Lax`+(e.location.protocol==="https:"?"; Secure":"");n.cookie=o;for(let a of _chunkXIHGWNTSjs.n.call(void 0, e.location.hostname))n.cookie=`${o}; Domain=${a}`}catch (e8){}}function N(e,t){try{let n=e.navigator;return _optionalChain([n, 'optionalAccess', _14 => _14.globalPrivacyControl])===!0||_optionalChain([n, 'optionalAccess', _15 => _15.webdriver])===!0?null:J(e,t)?B(e.document,t):null}catch (e9){return null}}var Ue="https://collect.bitsnap.pl",Ke=5e3,Ge=20,Te=32*1024,ze=60*1024,xe=/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function _e(e){return typeof TextEncoder=="function"?new TextEncoder().encode(e).length:unescape(encodeURIComponent(e)).length}var y={track(){},page(){},clientId:()=>null,flush(){},setEnabled(){},onEvent:()=>()=>{},configure(){},destroy(){}};function Ye(e=Date.now()){let t=I(16),n=e;for(let a=5;a>=0;a--)t[a]=n%256,n=Math.floor(n/256);t[6]=t[6]&15|112,t[8]=t[8]&63|128;let o=Array.from(t,a=>a.toString(16).padStart(2,"0")).join("");return`${o.slice(0,8)}-${o.slice(8,12)}-${o.slice(12,16)}-${o.slice(16,20)}-${o.slice(20)}`}var Ce="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";function Fe(){return Array.from(I(16),e=>Ce[e%Ce.length]).join("")}function Je(e,t,n=!1){let o=_e(JSON.stringify({k:e,events:[]})),a=[],i=[],c=o,s=()=>{i.length>0&&a.push({body:JSON.stringify({k:e,events:i}),bytes:c,count:i.length}),i=[],c=o};for(let u of t){let l=_e(JSON.stringify(u));o+l>Te||((i.length>=_chunkXIHGWNTSjs.a.maxBatchEvents||c+l+(i.length>0?1:0)>Te)&&s(),c+=l+(i.length>0?1:0),i.push(u))}if(s(),n){let u=0,l=a.length;for(;l>0&&u+a[l-1].bytes<=ze;)u+=a[l-1].bytes,l--;a=a.slice(l)}return a}function Xe(e){try{return typeof window>"u"||typeof document>"u"?y:qe(e,window)}catch (e10){return y}}function qe(e,t){let n=_chunkXIHGWNTSjs.b.call(void 0, _nullishCoalesce(e.projectKey, () => (""))),o=!!e.debug,a=(...r)=>{o&&console.warn("[bitsnap analytics]",...r)};if(!n)return a("invalid projectKey, tracking is off"),y;let i=n,c=r=>`${(r||Ue).replace(/\/+$/,"")}/e`,s=c(e.endpoint),u=_nullishCoalesce(e.source, () => ("sdk_react")),l=_nullishCoalesce(e.channel, () => ("embed")),b=`bitsnap-react@${ve}`,M=Fe(),T=_chunkXIHGWNTSjs.d.call(void 0, t.location.href),j=_nullishCoalesce(e.env, () => ("live"));if(!e.env)try{new URLSearchParams(t.location.search).has("test")&&(j="test")}catch (e11){}let Le=_chunkXIHGWNTSjs.e.call(void 0, document.referrer),H=e.enabled!==!1,ee=null,Re=0,p=[],h=null,C=new Set;e.onEvent&&C.add(e.onEvent);let E=[],g,m=!0;function W(){let r=R(t);!r||r===g||(g=r,m=!r.ready,_optionalChain([r, 'access', _16 => _16.ready, 'optionalAccess', _17 => _17.then, 'call', _18 => _18(()=>{g===r&&(m=!0,re())},()=>{g===r&&(m=!0)})]))}function te(){W();try{if(!g)return!1;let r=g.get();return!!g.denied&&g.denied("analytics")||!!r&&r.c.analytics===!1}catch (e12){return!1}}function ne(r){C.forEach(f=>{try{f(r)}catch (e13){}})}function U(r){try{if(W(),!g||!F(t,i))return;J(t,i)?P()&&B(t.document,i)===null&&ke(t,i,he()):r&&be(t,i)}catch (e14){}}function re(){if(U(!0),te())p=[],E=[],w();else{if(m&&E.length>0){let r=E;E=[],r.forEach(ne)}p.length>0&&x()}}function P(){if(!H)return!1;let r=t.navigator;return r&&(r.globalPrivacyControl===!0||r.webdriver===!0)?!1:!te()}function w(){h!==null&&clearTimeout(h),h=null}function Be(){h===null&&(h=setTimeout(()=>{h=null,x()},Ke),_optionalChain([h, 'access', _19 => _19.unref, 'optionalCall', _20 => _20()]))}function Ne(r){try{if(typeof fetch=="function"){fetch(s,{method:"POST",body:r,keepalive:!0,credentials:"omit",headers:{"Content-Type":"text/plain"}}).catch(()=>{});return}}catch (e15){}try{let f=t.navigator;f&&typeof f.sendBeacon=="function"&&f.sendBeacon(s,new Blob([r],{type:"text/plain"}))}catch (e16){}}function x(r=!1){try{if(w(),p.length===0)return;if(!P()){p=[];return}if(!m)return;U(m);let f=N(t,i),d=f?p.map(k=>({...k,client_id:f})):p;p=[],Je(i,d,r).forEach(k=>Ne(k.body))}catch (e17){}}function oe(r,f,d){if(!P())return;let k=_chunkXIHGWNTSjs.g.call(void 0, r,f);if(!k.ok){a("dropped",r,k.reason);return}let se=_chunkXIHGWNTSjs.d.call(void 0, t.location.href),K={event_id:_optionalChain([d, 'optionalAccess', _21 => _21.event_id])&&xe.test(d.event_id)?d.event_id:Ye(),event:r,ts:Date.now(),schema_version:1,env:j,source:u,channel:l,sdk:b,page_id:M,page_type:_optionalChain([d, 'optionalAccess', _22 => _22.page_type])!==void 0?d.page_type:ee,host:_nullishCoalesce(_optionalChain([se, 'optionalAccess', _23 => _23.host]), () => (null)),path:_optionalChain([d, 'optionalAccess', _24 => _24.path])?_chunkXIHGWNTSjs.c.call(void 0, d.path.split(/[?#]/)[0]):_nullishCoalesce(_optionalChain([se, 'optionalAccess', _25 => _25.path]), () => (null)),referrer_host:Le,utm_source:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _26 => _26.utm_source]), () => (null)),utm_medium:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _27 => _27.utm_medium]), () => (null)),utm_campaign:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _28 => _28.utm_campaign]), () => (null)),utm_content:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _29 => _29.utm_content]), () => (null)),utm_term:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _30 => _30.utm_term]), () => (null)),ref_code:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _31 => _31.ref_code]), () => (null)),product_id:_nullishCoalesce(_optionalChain([d, 'optionalAccess', _32 => _32.product_id]), () => (null)),variant_id:_nullishCoalesce(_optionalChain([d, 'optionalAccess', _33 => _33.variant_id]), () => (null)),order_ref:_nullishCoalesce(_optionalChain([d, 'optionalAccess', _34 => _34.order_ref]), () => (null)),props:k.props};_optionalChain([d, 'optionalAccess', _35 => _35.event_id])&&!xe.test(d.event_id)&&a("ignored invalid event_id",r),u==="dashboard"&&e.visitorId&&(K.visitor_id=e.visitorId);let ce=_chunkXIHGWNTSjs.h.call(void 0, K);if(!ce.ok){a("dropped",r,ce.reason);return}let G=K;m?ne(G):E.push(G),p.push(G),p.length>=Ge?x():Be()}let ie=()=>x(!0),ae=()=>{document.visibilityState==="hidden"&&x(!0)},S=()=>re();return t.addEventListener("pagehide",ie),document.addEventListener("visibilitychange",ae),t.addEventListener("bitsnap:consent",S),t.addEventListener("bitsnap:consent:ready",S),W(),U(m),{track(r,f,d){try{oe(r,f,d)}catch (e18){}},page(r,f){try{r!==void 0&&(ee=r),oe("page_view",{landing:Re++===0},f)}catch (e19){}},clientId(r){try{return r!==void 0&&_chunkXIHGWNTSjs.b.call(void 0, r)!==i?null:P()?N(t,i):null}catch (e20){return null}},flush:()=>x(),setEnabled(r){H=!!r,H||(p=[],E=[],w())},configure(r){try{(r.env==="live"||r.env==="test")&&(j=r.env),typeof r.endpoint=="string"&&r.endpoint&&(s=c(r.endpoint))}catch (e21){}},onEvent(r){return C.add(r),()=>void C.delete(r)},destroy(){p=[],E=[],w(),C.clear(),t.removeEventListener("pagehide",ie),document.removeEventListener("visibilitychange",ae),t.removeEventListener("bitsnap:consent",S),t.removeEventListener("bitsnap:consent:ready",S)}}}var v,O=null;function D(e){if(!v){let t=Xe(e);return t===y||(v=t,O=_chunkXIHGWNTSjs.b.call(void 0, _nullishCoalesce(e.projectKey, () => ("")))),t}try{let t=_chunkXIHGWNTSjs.b.call(void 0, _nullishCoalesce(e.projectKey, () => ("")));t!==O&&e.debug&&console.warn("[bitsnap analytics]","tracker already started for another projectKey, ignoring",e.projectKey),t===O&&((e.env||e.endpoint)&&v.configure({env:e.env,endpoint:e.endpoint}),e.enabled!=null&&v.setEnabled(e.enabled))}catch (e22){}return v}function Ae(){return v}function xt(){typeof window<"u"&&ge(window),_optionalChain([v, 'optionalAccess', _36 => _36.destroy, 'call', _37 => _37()]),v=void 0,O=null}function _t(e){try{if(typeof window>"u")return{};let t=v,n=null;if(t)n=t.clientId(e);else{let o=e?_chunkXIHGWNTSjs.b.call(void 0, e):null;n=o?N(window,o):null}return n?{[me]:n}:{}}catch (e23){return{}}}var _react = require('react');var nt={track:y.track,page:y.page},Pe=_react.createContext.call(void 0, nt);function St({projectKey:e,env:t,enabled:n,endpoint:o,onEvent:a,autoPageViews:i,children:c}){let s=_react.useMemo.call(void 0, ()=>D({projectKey:e,env:t,endpoint:o,enabled:n}),[e,t,o]),u=_react.useRef.call(void 0, a);u.current=a,_chunkXIHGWNTSjs.p.call(void 0, ()=>{s.setEnabled(n!==!1)},[s,n]),_chunkXIHGWNTSjs.p.call(void 0, ()=>{if(!(i===!1||n===!1||s===y))return A(()=>s.page(null))},[s,i,n]),_chunkXIHGWNTSjs.p.call(void 0, ()=>s.onEvent(b=>_optionalChain([u, 'access', _38 => _38.current, 'optionalCall', _39 => _39(b)])),[s]);let l=_react.useMemo.call(void 0, ()=>({track:s.track.bind(s),page:s.page.bind(s)}),[s]);return _react.createElement.call(void 0, Pe.Provider,{value:l},c)}function we(){return _react.useContext.call(void 0, Pe)}var $={track(){}},X=null;function lt(e){let t=Symbol("bitsnap-instrument");function n(){if(typeof window>"u")return null;let{projectKey:i,analytics:c,provided:s}=e();return c===!1?null:s||(i?D({projectKey:i,source:"sdk_react",channel:"embed",env:typeof c=="object"?c.env:void 0}):null)}let o={track(i,c,s){try{let u=n();if(!u)return;let{analytics:l,pageType:b}=e(),M=b&&_optionalChain([s, 'optionalAccess', _40 => _40.page_type])===void 0?{...s,page_type:b}:s;X=typeof l=="object"&&l.onEvent?t:null,u.track(i,c,M)}catch (e24){}finally{X=null}}};function a(){try{if(!n())return()=>{};let i=Ae();if(!i)return()=>{};let c=e().provided?()=>{}:A(()=>i.page(_nullishCoalesce(e().pageType, () => (null)))),s=i.onEvent(u=>{if(X===t)try{let{analytics:l}=e();typeof l=="object"&&_optionalChain([l, 'access', _41 => _41.onEvent, 'optionalCall', _42 => _42(u)])}catch (e25){}});return()=>{c(),s()}}catch (e26){return()=>{}}}return{instrument:o,attach:a}}var Z=_react.createContext.call(void 0, null);function Nt({value:e,children:t}){return _react.createElement.call(void 0, Z.Provider,{value:e},t)}function Ot(){return _nullishCoalesce(_react.useContext.call(void 0, Z), () => ($))}function Dt(e,t,n){let o=_react.useContext.call(void 0, Z),a=we(),i=a.track===y.track?null:a,c=_react.useRef.call(void 0, {projectKey:e,analytics:t,pageType:n,provided:i});c.current={projectKey:e,analytics:t,pageType:n,provided:i};let s=_react.useMemo.call(void 0, ()=>lt(()=>c.current),[]),u=t===void 0&&o!==null,l=typeof t=="object"&&!!t.onEvent;return _react.useLayoutEffect.call(void 0, ()=>{if(!u)return s.attach()},[s,u,l,e]),u?o:s.instrument}var Q=$;function Se(e){Q=_nullishCoalesce(e, () => ($))}var q=0;function $t(){return q>0?$:Q}async function Mt(e){q++;try{return await e()}finally{q--}}function jt(e){_react.useEffect.call(void 0, ()=>(Se(e),()=>{Q===e&&Se(null)}),[e])}function Ht(e){let t=Number.isFinite(e)?Math.max(0,Math.min(100,e)):0;return t>=100?"100":t>=75?"75-99":t>=50?"50-74":t>=25?"25-49":"0-24"}function Wt(e,t){let n=[];for(let o of[25,50,75,100])e>=o&&!t.has(o)&&(t.add(o),n.push(o));return n}exports.a = ve; exports.b = A; exports.c = Ue; exports.d = Xe; exports.e = D; exports.f = Ae; exports.g = xt; exports.h = _t; exports.i = St; exports.j = we; exports.k = $; exports.l = Nt; exports.m = Ot; exports.n = Dt; exports.o = $t; exports.p = Mt; exports.q = jt; exports.r = Ht; exports.s = Wt;
2
- //# sourceMappingURL=chunk-HDLCLZOK.js.map
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkW3RGQYPDjs = require('./chunk-W3RGQYPD.js');var Oe=Symbol.for("bitsnap.pageViews");function ye(e){let t=e;return t[Oe]??={path:null,starters:new Set,watching:!1}}function De(e,t){let n=()=>{try{t()}catch (e2){}};for(let o of["pushState","replaceState"]){let a=e.history[o];e.history[o]=function(...i){let c=a.apply(this,i);return n(),c}}e.addEventListener("popstate",n)}function A(e,t=window){try{let n=ye(t),o=()=>e();n.watching||(n.watching=!0,De(t,()=>{let i=t.location.pathname;i===n.path||n.starters.size===0||(n.path=i,_optionalChain([n, 'access', _2 => _2.starters, 'access', _3 => _3.values, 'call', _4 => _4(), 'access', _5 => _5.next, 'call', _6 => _6(), 'access', _7 => _7.value, 'optionalCall', _8 => _8()]))})),n.starters.add(o);let a=t.location.pathname;return a!==n.path&&(n.path=a,o()),()=>void n.starters.delete(o)}catch (e3){return()=>{}}}function ge(e=window){let t=ye(e);t.path=null,t.starters.clear()}var ve="1.14.0";function I(e){let t=new Uint8Array(e),n=typeof crypto<"u"?crypto:void 0;if(n&&typeof n.getRandomValues=="function")n.getRandomValues(t);else for(let o=0;o<e;o++)t[o]=Math.floor(Math.random()*256);return t}var me="X-Bitsnap-Visitor",$e=390*24*60*60,Me=/^[A-Za-z0-9_-]{22}$/;function R(e){return e.BitsnapConsent}function je(e,t){for(let n of e.cookie.split(";")){let o=n.indexOf("=");if(o!==-1&&n.slice(0,o).trim()===t)return n.slice(o+1).trim()}return null}function He(e){let t=e.toLowerCase();return t==="bitsnap.pl"||t.endsWith(".bitsnap.pl")}function F(e,t){try{let n=R(e);if(!n)return!1;if(n.scope==="project")return n.projectKey===t;let o=He(e.location.hostname);return n.scope==="global"?!o:!1}catch (e4){return!1}}function J(e,t){try{return _optionalChain([R, 'call', _9 => _9(e), 'optionalAccess', _10 => _10.get, 'call', _11 => _11(), 'optionalAccess', _12 => _12.c, 'access', _13 => _13.analytics])===!0&&F(e,t)}catch (e5){return!1}}function he(){let e="";return I(16).forEach(t=>e+=String.fromCharCode(t)),btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Ee(e,t){try{return je(e,_chunkW3RGQYPDjs.g.call(void 0, t))}catch (e6){return null}}function B(e,t){let n=Ee(e,t);return n!==null&&Me.test(n)?n:null}function ke(e,t,n){try{let o=e.document,a=`${_chunkW3RGQYPDjs.g.call(void 0, t)}=${n}; Max-Age=${$e}; Path=/; SameSite=Lax`+(e.location.protocol==="https:"?"; Secure":"");for(let i of _chunkW3RGQYPDjs.o.call(void 0, e.location.hostname).reverse())if(o.cookie=`${a}; Domain=${i}`,B(o,t)===n)return;o.cookie=a}catch (e7){}}function be(e,t){try{let n=e.document;if(Ee(n,t)===null)return;let o=`${_chunkW3RGQYPDjs.g.call(void 0, t)}=; Max-Age=0; Path=/; SameSite=Lax`+(e.location.protocol==="https:"?"; Secure":"");n.cookie=o;for(let a of _chunkW3RGQYPDjs.o.call(void 0, e.location.hostname))n.cookie=`${o}; Domain=${a}`}catch (e8){}}function N(e,t){try{let n=e.navigator;return _optionalChain([n, 'optionalAccess', _14 => _14.globalPrivacyControl])===!0||_optionalChain([n, 'optionalAccess', _15 => _15.webdriver])===!0?null:J(e,t)?B(e.document,t):null}catch (e9){return null}}var Ue="https://collect.bitsnap.pl",Ke=5e3,Ge=20,Te=32*1024,ze=60*1024,xe=/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function _e(e){return typeof TextEncoder=="function"?new TextEncoder().encode(e).length:unescape(encodeURIComponent(e)).length}var y={track(){},page(){},clientId:()=>null,flush(){},setEnabled(){},onEvent:()=>()=>{},configure(){},destroy(){}};function Ye(e=Date.now()){let t=I(16),n=e;for(let a=5;a>=0;a--)t[a]=n%256,n=Math.floor(n/256);t[6]=t[6]&15|112,t[8]=t[8]&63|128;let o=Array.from(t,a=>a.toString(16).padStart(2,"0")).join("");return`${o.slice(0,8)}-${o.slice(8,12)}-${o.slice(12,16)}-${o.slice(16,20)}-${o.slice(20)}`}var Ce="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";function Fe(){return Array.from(I(16),e=>Ce[e%Ce.length]).join("")}function Je(e,t,n=!1){let o=_e(JSON.stringify({k:e,events:[]})),a=[],i=[],c=o,s=()=>{i.length>0&&a.push({body:JSON.stringify({k:e,events:i}),bytes:c,count:i.length}),i=[],c=o};for(let u of t){let l=_e(JSON.stringify(u));o+l>Te||((i.length>=_chunkW3RGQYPDjs.a.maxBatchEvents||c+l+(i.length>0?1:0)>Te)&&s(),c+=l+(i.length>0?1:0),i.push(u))}if(s(),n){let u=0,l=a.length;for(;l>0&&u+a[l-1].bytes<=ze;)u+=a[l-1].bytes,l--;a=a.slice(l)}return a}function Xe(e){try{return typeof window>"u"||typeof document>"u"?y:qe(e,window)}catch (e10){return y}}function qe(e,t){let n=_chunkW3RGQYPDjs.c.call(void 0, _nullishCoalesce(e.projectKey, () => (""))),o=!!e.debug,a=(...r)=>{o&&console.warn("[bitsnap analytics]",...r)};if(!n)return a("invalid projectKey, tracking is off"),y;let i=n,c=r=>`${(r||Ue).replace(/\/+$/,"")}/e`,s=c(e.endpoint),u=_nullishCoalesce(e.source, () => ("sdk_react")),l=_nullishCoalesce(e.channel, () => ("embed")),b=`bitsnap-react@${ve}`,M=Fe(),T=_chunkW3RGQYPDjs.e.call(void 0, t.location.href),j=_nullishCoalesce(e.env, () => ("live"));if(!e.env)try{new URLSearchParams(t.location.search).has("test")&&(j="test")}catch (e11){}let Le=_chunkW3RGQYPDjs.f.call(void 0, document.referrer),H=e.enabled!==!1,ee=null,Re=0,p=[],h=null,C=new Set;e.onEvent&&C.add(e.onEvent);let E=[],g,m=!0;function W(){let r=R(t);!r||r===g||(g=r,m=!r.ready,_optionalChain([r, 'access', _16 => _16.ready, 'optionalAccess', _17 => _17.then, 'call', _18 => _18(()=>{g===r&&(m=!0,re())},()=>{g===r&&(m=!0)})]))}function te(){W();try{if(!g)return!1;let r=g.get();return!!g.denied&&g.denied("analytics")||!!r&&r.c.analytics===!1}catch (e12){return!1}}function ne(r){C.forEach(f=>{try{f(r)}catch (e13){}})}function U(r){try{if(W(),!g||!F(t,i))return;J(t,i)?P()&&B(t.document,i)===null&&ke(t,i,he()):r&&be(t,i)}catch (e14){}}function re(){if(U(!0),te())p=[],E=[],w();else{if(m&&E.length>0){let r=E;E=[],r.forEach(ne)}p.length>0&&x()}}function P(){if(!H)return!1;let r=t.navigator;return r&&(r.globalPrivacyControl===!0||r.webdriver===!0)?!1:!te()}function w(){h!==null&&clearTimeout(h),h=null}function Be(){h===null&&(h=setTimeout(()=>{h=null,x()},Ke),_optionalChain([h, 'access', _19 => _19.unref, 'optionalCall', _20 => _20()]))}function Ne(r){try{if(typeof fetch=="function"){fetch(s,{method:"POST",body:r,keepalive:!0,credentials:"omit",headers:{"Content-Type":"text/plain"}}).catch(()=>{});return}}catch (e15){}try{let f=t.navigator;f&&typeof f.sendBeacon=="function"&&f.sendBeacon(s,new Blob([r],{type:"text/plain"}))}catch (e16){}}function x(r=!1){try{if(w(),p.length===0)return;if(!P()){p=[];return}if(!m)return;U(m);let f=N(t,i),d=f?p.map(k=>({...k,client_id:f})):p;p=[],Je(i,d,r).forEach(k=>Ne(k.body))}catch (e17){}}function oe(r,f,d){if(!P())return;let k=_chunkW3RGQYPDjs.h.call(void 0, r,f);if(!k.ok){a("dropped",r,k.reason);return}let se=_chunkW3RGQYPDjs.e.call(void 0, t.location.href),K={event_id:_optionalChain([d, 'optionalAccess', _21 => _21.event_id])&&xe.test(d.event_id)?d.event_id:Ye(),event:r,ts:Date.now(),schema_version:1,env:j,source:u,channel:l,sdk:b,page_id:M,page_type:_optionalChain([d, 'optionalAccess', _22 => _22.page_type])!==void 0?d.page_type:ee,host:_nullishCoalesce(_optionalChain([se, 'optionalAccess', _23 => _23.host]), () => (null)),path:_optionalChain([d, 'optionalAccess', _24 => _24.path])?_chunkW3RGQYPDjs.d.call(void 0, d.path.split(/[?#]/)[0]):_nullishCoalesce(_optionalChain([se, 'optionalAccess', _25 => _25.path]), () => (null)),referrer_host:Le,utm_source:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _26 => _26.utm_source]), () => (null)),utm_medium:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _27 => _27.utm_medium]), () => (null)),utm_campaign:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _28 => _28.utm_campaign]), () => (null)),utm_content:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _29 => _29.utm_content]), () => (null)),utm_term:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _30 => _30.utm_term]), () => (null)),ref_code:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _31 => _31.ref_code]), () => (null)),product_id:_nullishCoalesce(_optionalChain([d, 'optionalAccess', _32 => _32.product_id]), () => (null)),variant_id:_nullishCoalesce(_optionalChain([d, 'optionalAccess', _33 => _33.variant_id]), () => (null)),order_ref:_nullishCoalesce(_optionalChain([d, 'optionalAccess', _34 => _34.order_ref]), () => (null)),props:k.props};_optionalChain([d, 'optionalAccess', _35 => _35.event_id])&&!xe.test(d.event_id)&&a("ignored invalid event_id",r),u==="dashboard"&&e.visitorId&&(K.visitor_id=e.visitorId);let ce=_chunkW3RGQYPDjs.i.call(void 0, K);if(!ce.ok){a("dropped",r,ce.reason);return}let G=K;m?ne(G):E.push(G),p.push(G),p.length>=Ge?x():Be()}let ie=()=>x(!0),ae=()=>{document.visibilityState==="hidden"&&x(!0)},S=()=>re();return t.addEventListener("pagehide",ie),document.addEventListener("visibilitychange",ae),t.addEventListener("bitsnap:consent",S),t.addEventListener("bitsnap:consent:ready",S),W(),U(m),{track(r,f,d){try{oe(r,f,d)}catch (e18){}},page(r,f){try{r!==void 0&&(ee=r),oe("page_view",{landing:Re++===0},f)}catch (e19){}},clientId(r){try{return r!==void 0&&_chunkW3RGQYPDjs.c.call(void 0, r)!==i?null:P()?N(t,i):null}catch (e20){return null}},flush:()=>x(),setEnabled(r){H=!!r,H||(p=[],E=[],w())},configure(r){try{(r.env==="live"||r.env==="test")&&(j=r.env),typeof r.endpoint=="string"&&r.endpoint&&(s=c(r.endpoint))}catch (e21){}},onEvent(r){return C.add(r),()=>void C.delete(r)},destroy(){p=[],E=[],w(),C.clear(),t.removeEventListener("pagehide",ie),document.removeEventListener("visibilitychange",ae),t.removeEventListener("bitsnap:consent",S),t.removeEventListener("bitsnap:consent:ready",S)}}}var v,O=null;function D(e){if(!v){let t=Xe(e);return t===y||(v=t,O=_chunkW3RGQYPDjs.c.call(void 0, _nullishCoalesce(e.projectKey, () => ("")))),t}try{let t=_chunkW3RGQYPDjs.c.call(void 0, _nullishCoalesce(e.projectKey, () => ("")));t!==O&&e.debug&&console.warn("[bitsnap analytics]","tracker already started for another projectKey, ignoring",e.projectKey),t===O&&((e.env||e.endpoint)&&v.configure({env:e.env,endpoint:e.endpoint}),e.enabled!=null&&v.setEnabled(e.enabled))}catch (e22){}return v}function Ae(){return v}function xt(){typeof window<"u"&&ge(window),_optionalChain([v, 'optionalAccess', _36 => _36.destroy, 'call', _37 => _37()]),v=void 0,O=null}function _t(e){try{if(typeof window>"u")return{};let t=v,n=null;if(t)n=t.clientId(e);else{let o=e?_chunkW3RGQYPDjs.c.call(void 0, e):null;n=o?N(window,o):null}return n?{[me]:n}:{}}catch (e23){return{}}}var _react = require('react');var nt={track:y.track,page:y.page},Pe=_react.createContext.call(void 0, nt);function St({projectKey:e,env:t,enabled:n,endpoint:o,onEvent:a,autoPageViews:i,children:c}){let s=_react.useMemo.call(void 0, ()=>D({projectKey:e,env:t,endpoint:o,enabled:n}),[e,t,o]),u=_react.useRef.call(void 0, a);u.current=a,_chunkW3RGQYPDjs.q.call(void 0, ()=>{s.setEnabled(n!==!1)},[s,n]),_chunkW3RGQYPDjs.q.call(void 0, ()=>{if(!(i===!1||n===!1||s===y))return A(()=>s.page(null))},[s,i,n]),_chunkW3RGQYPDjs.q.call(void 0, ()=>s.onEvent(b=>_optionalChain([u, 'access', _38 => _38.current, 'optionalCall', _39 => _39(b)])),[s]);let l=_react.useMemo.call(void 0, ()=>({track:s.track.bind(s),page:s.page.bind(s)}),[s]);return _react.createElement.call(void 0, Pe.Provider,{value:l},c)}function we(){return _react.useContext.call(void 0, Pe)}var $={track(){}},X=null;function lt(e){let t=Symbol("bitsnap-instrument");function n(){if(typeof window>"u")return null;let{projectKey:i,analytics:c,provided:s}=e();return c===!1?null:s||(i?D({projectKey:i,source:"sdk_react",channel:"embed",env:typeof c=="object"?c.env:void 0}):null)}let o={track(i,c,s){try{let u=n();if(!u)return;let{analytics:l,pageType:b}=e(),M=b&&_optionalChain([s, 'optionalAccess', _40 => _40.page_type])===void 0?{...s,page_type:b}:s;X=typeof l=="object"&&l.onEvent?t:null,u.track(i,c,M)}catch (e24){}finally{X=null}}};function a(){try{if(!n())return()=>{};let i=Ae();if(!i)return()=>{};let c=e().provided?()=>{}:A(()=>i.page(_nullishCoalesce(e().pageType, () => (null)))),s=i.onEvent(u=>{if(X===t)try{let{analytics:l}=e();typeof l=="object"&&_optionalChain([l, 'access', _41 => _41.onEvent, 'optionalCall', _42 => _42(u)])}catch (e25){}});return()=>{c(),s()}}catch (e26){return()=>{}}}return{instrument:o,attach:a}}var Z=_react.createContext.call(void 0, null);function Nt({value:e,children:t}){return _react.createElement.call(void 0, Z.Provider,{value:e},t)}function Ot(){return _nullishCoalesce(_react.useContext.call(void 0, Z), () => ($))}function Dt(e,t,n){let o=_react.useContext.call(void 0, Z),a=we(),i=a.track===y.track?null:a,c=_react.useRef.call(void 0, {projectKey:e,analytics:t,pageType:n,provided:i});c.current={projectKey:e,analytics:t,pageType:n,provided:i};let s=_react.useMemo.call(void 0, ()=>lt(()=>c.current),[]),u=t===void 0&&o!==null,l=typeof t=="object"&&!!t.onEvent;return _react.useLayoutEffect.call(void 0, ()=>{if(!u)return s.attach()},[s,u,l,e]),u?o:s.instrument}var Q=$;function Se(e){Q=_nullishCoalesce(e, () => ($))}var q=0;function $t(){return q>0?$:Q}async function Mt(e){q++;try{return await e()}finally{q--}}function jt(e){_react.useEffect.call(void 0, ()=>(Se(e),()=>{Q===e&&Se(null)}),[e])}function Ht(e){let t=Number.isFinite(e)?Math.max(0,Math.min(100,e)):0;return t>=100?"100":t>=75?"75-99":t>=50?"50-74":t>=25?"25-49":"0-24"}function Wt(e,t){let n=[];for(let o of[25,50,75,100])e>=o&&!t.has(o)&&(t.add(o),n.push(o));return n}exports.a = ve; exports.b = A; exports.c = Ue; exports.d = Xe; exports.e = D; exports.f = Ae; exports.g = xt; exports.h = _t; exports.i = St; exports.j = we; exports.k = $; exports.l = Nt; exports.m = Ot; exports.n = Dt; exports.o = $t; exports.p = Mt; exports.q = jt; exports.r = Ht; exports.s = Wt;
2
+ //# sourceMappingURL=chunk-3N2VK426.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/emems/.t3/worktrees/bitsnap-react/consent-shown/dist/chunk-3N2VK426.js","../src/analytics/pageviews.ts","../src/version.ts","../src/analytics/random.ts","../src/analytics/visitor.ts"],"names":["REGISTRY","registry","win","holder","watchNavigation","onChange","check","name","original","args","result","startAutoPageViews","send","reg","starter","path","resetAutoPageViews","SDK_VERSION","randomBytes","n","bytes","c","i","VISITOR_HEADER","MAX_AGE_SECONDS","VISITOR_ID_RE","consentApi","readCookie","doc","part","index","isBitsnapHost","hostname","host","consentBelongsTo","projectKey","api","onBitsnap","analyticsGranted","newVisitorId","binary","byte","rawVisitorCookie","clientIdCookieName","readVisitorCookie","value","writeVisitorCookie","id","base"],"mappings":"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","file":"/home/emems/.t3/worktrees/bitsnap-react/consent-shown/dist/chunk-3N2VK426.js","sourcesContent":[null,"/**\n * Page-wide state of the automatic page views. It lives on `window`, so the\n * npm package, a second copy of it and the `analytics.js` script agree on who\n * reports a path and the history is patched once.\n */\ntype Registry = {\n /** Last path some starter reported. */\n path: string | null;\n starters: Set<() => void>;\n watching: boolean;\n};\n\nconst REGISTRY = Symbol.for(\"bitsnap.pageViews\");\n\nfunction registry(win: Window): Registry {\n const holder = win as unknown as Record<symbol, Registry | undefined>;\n return (holder[REGISTRY] ??= { path: null, starters: new Set(), watching: false });\n}\n\n/** Calls `onChange` when the path changes through `history.pushState`/`replaceState` or Back/Forward. */\nfunction watchNavigation(win: Window, onChange: () => void) {\n const check = () => {\n try {\n onChange();\n } catch {}\n };\n for (const name of [\"pushState\", \"replaceState\"] as const) {\n const original = win.history[name];\n win.history[name] = function (this: History, ...args: Parameters<History[typeof name]>) {\n const result = original.apply(this, args);\n check();\n return result;\n };\n }\n win.addEventListener(\"popstate\", check);\n}\n\n/**\n * Calls `send` for the current path and again on every path change, unless\n * another starter on the page already reported that path: the page gets one\n * `page_view` per path change however many providers, components and embeds\n * start it. Returns the function that stops this starter.\n */\nexport function startAutoPageViews(send: () => void, win: Window = window): () => void {\n try {\n const reg = registry(win);\n const starter = () => send();\n if (!reg.watching) {\n reg.watching = true;\n watchNavigation(win, () => {\n const path = win.location.pathname;\n // Nobody listening: leave the path unreported so the next starter sends it.\n if (path === reg.path || reg.starters.size === 0) return;\n reg.path = path;\n reg.starters.values().next().value?.();\n });\n }\n reg.starters.add(starter);\n const path = win.location.pathname;\n if (path !== reg.path) {\n reg.path = path;\n starter();\n }\n return () => void reg.starters.delete(starter);\n } catch {\n return () => {};\n }\n}\n\n/** Forgets the reported path and the starters (tests, hot reload). The history patch stays. */\nexport function resetAutoPageViews(win: Window = window) {\n const reg = registry(win);\n reg.path = null;\n reg.starters.clear();\n}\n","// Generated by scripts/write-version.mjs from package.json. Do not edit.\nexport const SDK_VERSION = \"1.14.0\";\n","export function randomBytes(n: number): Uint8Array {\n const bytes = new Uint8Array(n);\n const c = typeof crypto !== \"undefined\" ? crypto : undefined;\n if (c && typeof c.getRandomValues === \"function\") c.getRandomValues(bytes);\n else for (let i = 0; i < n; i++) bytes[i] = Math.floor(Math.random() * 256);\n return bytes;\n}\n","import { domainCandidates } from \"../consent/core/cookie\";\nimport { clientIdCookieName } from \"./contract\";\nimport { randomBytes } from \"./random\";\n\n/** The part of `window.BitsnapConsent` (`bitsnap-react/consent`) the tracker reads. */\nexport type ConsentLike = {\n /** Absent on a consent script older than 1.9.0, which never counts as the project's banner. */\n scope?: \"global\" | \"project\";\n projectKey?: string | null;\n get(): { c: { analytics?: boolean } } | null;\n /** Also true for a refusal made on an older banner version, which `get()` no longer returns. */\n denied?(category: \"analytics\"): boolean;\n ready?: Promise<unknown>;\n};\n\n/** Sent to the Bitsnap server on the requests that create a checkout or payment link. */\nexport const VISITOR_HEADER = \"X-Bitsnap-Visitor\";\n// 390 days, under the 13 months CNIL allows. Set once, never extended.\nconst MAX_AGE_SECONDS = 390 * 24 * 60 * 60;\nconst VISITOR_ID_RE = /^[A-Za-z0-9_-]{22}$/;\n\nexport function consentApi(win: Window): ConsentLike | undefined {\n return (win as unknown as { BitsnapConsent?: ConsentLike }).BitsnapConsent;\n}\n\nfunction readCookie(doc: Document, name: string): string | null {\n for (const part of doc.cookie.split(\";\")) {\n const index = part.indexOf(\"=\");\n if (index !== -1 && part.slice(0, index).trim() === name) return part.slice(index + 1).trim();\n }\n return null;\n}\n\n/** bitsnap.pl and its subdomains: many merchants share them, and the site-wide choice is bitsnap's own. */\nfunction isBitsnapHost(hostname: string): boolean {\n const host = hostname.toLowerCase();\n return host === \"bitsnap.pl\" || host.endsWith(\".bitsnap.pl\");\n}\n\n/**\n * Whether the page's consent banner speaks for `projectKey`: a project-scope banner of that\n * key, or a site-scope banner on a merchant's own site. On bitsnap.pl a site-scope choice is\n * bitsnap's own, so only a project-scope one counts.\n */\nexport function consentBelongsTo(win: Window, projectKey: string): boolean {\n try {\n const api = consentApi(win);\n if (!api) return false;\n if (api.scope === \"project\") return api.projectKey === projectKey;\n const onBitsnap = isBitsnapHost(win.location.hostname);\n if (api.scope === \"global\") return !onBitsnap;\n // A consent script from before the scope info: it cannot be told apart from another project's banner.\n return false;\n } catch {\n return false;\n }\n}\n\n/** `true` only while a banner that speaks for `projectKey` holds a valid choice that grants `analytics`. */\nexport function analyticsGranted(win: Window, projectKey: string): boolean {\n try {\n return consentApi(win)?.get()?.c.analytics === true && consentBelongsTo(win, projectKey);\n } catch {\n return false;\n }\n}\n\n/** 16 random bytes as 22 base64url characters. */\nexport function newVisitorId(): string {\n let binary = \"\";\n randomBytes(16).forEach((byte) => (binary += String.fromCharCode(byte)));\n return btoa(binary).replace(/\\+/g, \"-\").replace(/\\//g, \"_\").replace(/=+$/, \"\");\n}\n\n/** Value of the `bs_vid_<projectKey>` cookie, whatever it holds; `null` when it is absent. */\nfunction rawVisitorCookie(doc: Document, projectKey: string): string | null {\n try {\n return readCookie(doc, clientIdCookieName(projectKey));\n } catch {\n return null;\n }\n}\n\n/** The project's client id from its first-party cookie (`bs_vid_<projectKey>`), or `null` if absent or malformed. */\nexport function readVisitorCookie(doc: Document, projectKey: string): string | null {\n const value = rawVisitorCookie(doc, projectKey);\n return value !== null && VISITOR_ID_RE.test(value) ? value : null;\n}\n\n/**\n * Sets the cookie on the widest registrable domain the browser accepts\n * (shortest suffix with two labels first, so `shop.example.co.uk` skips the\n * refused `co.uk`), host-only where no domain sticks (localhost, IP hosts).\n */\nexport function writeVisitorCookie(win: Window, projectKey: string, id: string): void {\n try {\n const doc = win.document;\n const base =\n `${clientIdCookieName(projectKey)}=${id}; Max-Age=${MAX_AGE_SECONDS}; Path=/; SameSite=Lax` +\n (win.location.protocol === \"https:\" ? \"; Secure\" : \"\");\n for (const domain of domainCandidates(win.location.hostname).reverse()) {\n doc.cookie = `${base}; Domain=${domain}`;\n if (readVisitorCookie(doc, projectKey) === id) return;\n }\n doc.cookie = base;\n } catch {\n // cookies blocked (sandboxed frame)\n }\n}\n\n/** Expires the cookie on the host and on every parent domain it may have been set on. */\nexport function deleteVisitorCookie(win: Window, projectKey: string): void {\n try {\n const doc = win.document;\n // Present under any value: a malformed one must go too.\n if (rawVisitorCookie(doc, projectKey) === null) return;\n const base =\n `${clientIdCookieName(projectKey)}=; Max-Age=0; Path=/; SameSite=Lax` +\n (win.location.protocol === \"https:\" ? \"; Secure\" : \"\");\n doc.cookie = base;\n for (const domain of domainCandidates(win.location.hostname)) doc.cookie = `${base}; Domain=${domain}`;\n } catch {\n // best effort\n }\n}\n\n/**\n * The project's client id to send, or `null`: analytics consent is granted,\n * Global Privacy Control is off, the browser is not automated and the cookie exists.\n */\nexport function readVisitorId(win: Window, projectKey: string): string | null {\n try {\n const nav = win.navigator as { globalPrivacyControl?: boolean; webdriver?: boolean } | undefined;\n if (nav?.globalPrivacyControl === true || nav?.webdriver === true) return null;\n return analyticsGranted(win, projectKey) ? readVisitorCookie(win.document, projectKey) : null;\n } catch {\n return null;\n }\n}\n"]}
@@ -1,2 +1,2 @@
1
- import{a as le,b as _,c as ue,d as z,e as de,f as V,g as fe,h as pe,n as Y,p as L}from"./chunk-ADYVTMGH.mjs";var Oe=Symbol.for("bitsnap.pageViews");function ye(e){let t=e;return t[Oe]??={path:null,starters:new Set,watching:!1}}function De(e,t){let n=()=>{try{t()}catch{}};for(let o of["pushState","replaceState"]){let a=e.history[o];e.history[o]=function(...i){let c=a.apply(this,i);return n(),c}}e.addEventListener("popstate",n)}function A(e,t=window){try{let n=ye(t),o=()=>e();n.watching||(n.watching=!0,De(t,()=>{let i=t.location.pathname;i===n.path||n.starters.size===0||(n.path=i,n.starters.values().next().value?.())})),n.starters.add(o);let a=t.location.pathname;return a!==n.path&&(n.path=a,o()),()=>void n.starters.delete(o)}catch{return()=>{}}}function ge(e=window){let t=ye(e);t.path=null,t.starters.clear()}var ve="1.12.1";function I(e){let t=new Uint8Array(e),n=typeof crypto<"u"?crypto:void 0;if(n&&typeof n.getRandomValues=="function")n.getRandomValues(t);else for(let o=0;o<e;o++)t[o]=Math.floor(Math.random()*256);return t}var me="X-Bitsnap-Visitor",$e=390*24*60*60,Me=/^[A-Za-z0-9_-]{22}$/;function R(e){return e.BitsnapConsent}function je(e,t){for(let n of e.cookie.split(";")){let o=n.indexOf("=");if(o!==-1&&n.slice(0,o).trim()===t)return n.slice(o+1).trim()}return null}function He(e){let t=e.toLowerCase();return t==="bitsnap.pl"||t.endsWith(".bitsnap.pl")}function F(e,t){try{let n=R(e);if(!n)return!1;if(n.scope==="project")return n.projectKey===t;let o=He(e.location.hostname);return n.scope==="global"?!o:!1}catch{return!1}}function J(e,t){try{return R(e)?.get()?.c.analytics===!0&&F(e,t)}catch{return!1}}function he(){let e="";return I(16).forEach(t=>e+=String.fromCharCode(t)),btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Ee(e,t){try{return je(e,V(t))}catch{return null}}function B(e,t){let n=Ee(e,t);return n!==null&&Me.test(n)?n:null}function ke(e,t,n){try{let o=e.document,a=`${V(t)}=${n}; Max-Age=${$e}; Path=/; SameSite=Lax`+(e.location.protocol==="https:"?"; Secure":"");for(let i of Y(e.location.hostname).reverse())if(o.cookie=`${a}; Domain=${i}`,B(o,t)===n)return;o.cookie=a}catch{}}function be(e,t){try{let n=e.document;if(Ee(n,t)===null)return;let o=`${V(t)}=; Max-Age=0; Path=/; SameSite=Lax`+(e.location.protocol==="https:"?"; Secure":"");n.cookie=o;for(let a of Y(e.location.hostname))n.cookie=`${o}; Domain=${a}`}catch{}}function N(e,t){try{let n=e.navigator;return n?.globalPrivacyControl===!0||n?.webdriver===!0?null:J(e,t)?B(e.document,t):null}catch{return null}}var Ue="https://collect.bitsnap.pl",Ke=5e3,Ge=20,Te=32*1024,ze=60*1024,xe=/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function _e(e){return typeof TextEncoder=="function"?new TextEncoder().encode(e).length:unescape(encodeURIComponent(e)).length}var y={track(){},page(){},clientId:()=>null,flush(){},setEnabled(){},onEvent:()=>()=>{},configure(){},destroy(){}};function Ye(e=Date.now()){let t=I(16),n=e;for(let a=5;a>=0;a--)t[a]=n%256,n=Math.floor(n/256);t[6]=t[6]&15|112,t[8]=t[8]&63|128;let o=Array.from(t,a=>a.toString(16).padStart(2,"0")).join("");return`${o.slice(0,8)}-${o.slice(8,12)}-${o.slice(12,16)}-${o.slice(16,20)}-${o.slice(20)}`}var Ce="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";function Fe(){return Array.from(I(16),e=>Ce[e%Ce.length]).join("")}function Je(e,t,n=!1){let o=_e(JSON.stringify({k:e,events:[]})),a=[],i=[],c=o,s=()=>{i.length>0&&a.push({body:JSON.stringify({k:e,events:i}),bytes:c,count:i.length}),i=[],c=o};for(let u of t){let l=_e(JSON.stringify(u));o+l>Te||((i.length>=le.maxBatchEvents||c+l+(i.length>0?1:0)>Te)&&s(),c+=l+(i.length>0?1:0),i.push(u))}if(s(),n){let u=0,l=a.length;for(;l>0&&u+a[l-1].bytes<=ze;)u+=a[l-1].bytes,l--;a=a.slice(l)}return a}function Xe(e){try{return typeof window>"u"||typeof document>"u"?y:qe(e,window)}catch{return y}}function qe(e,t){let n=_(e.projectKey??""),o=!!e.debug,a=(...r)=>{o&&console.warn("[bitsnap analytics]",...r)};if(!n)return a("invalid projectKey, tracking is off"),y;let i=n,c=r=>`${(r||Ue).replace(/\/+$/,"")}/e`,s=c(e.endpoint),u=e.source??"sdk_react",l=e.channel??"embed",b=`bitsnap-react@${ve}`,M=Fe(),T=z(t.location.href),j=e.env??"live";if(!e.env)try{new URLSearchParams(t.location.search).has("test")&&(j="test")}catch{}let Le=de(document.referrer),H=e.enabled!==!1,ee=null,Re=0,p=[],h=null,C=new Set;e.onEvent&&C.add(e.onEvent);let E=[],g,m=!0;function W(){let r=R(t);!r||r===g||(g=r,m=!r.ready,r.ready?.then(()=>{g===r&&(m=!0,re())},()=>{g===r&&(m=!0)}))}function te(){W();try{if(!g)return!1;let r=g.get();return!!g.denied&&g.denied("analytics")||!!r&&r.c.analytics===!1}catch{return!1}}function ne(r){C.forEach(f=>{try{f(r)}catch{}})}function U(r){try{if(W(),!g||!F(t,i))return;J(t,i)?P()&&B(t.document,i)===null&&ke(t,i,he()):r&&be(t,i)}catch{}}function re(){if(U(!0),te())p=[],E=[],w();else{if(m&&E.length>0){let r=E;E=[],r.forEach(ne)}p.length>0&&x()}}function P(){if(!H)return!1;let r=t.navigator;return r&&(r.globalPrivacyControl===!0||r.webdriver===!0)?!1:!te()}function w(){h!==null&&clearTimeout(h),h=null}function Be(){h===null&&(h=setTimeout(()=>{h=null,x()},Ke),h.unref?.())}function Ne(r){try{if(typeof fetch=="function"){fetch(s,{method:"POST",body:r,keepalive:!0,credentials:"omit",headers:{"Content-Type":"text/plain"}}).catch(()=>{});return}}catch{}try{let f=t.navigator;f&&typeof f.sendBeacon=="function"&&f.sendBeacon(s,new Blob([r],{type:"text/plain"}))}catch{}}function x(r=!1){try{if(w(),p.length===0)return;if(!P()){p=[];return}if(!m)return;U(m);let f=N(t,i),d=f?p.map(k=>({...k,client_id:f})):p;p=[],Je(i,d,r).forEach(k=>Ne(k.body))}catch{}}function oe(r,f,d){if(!P())return;let k=fe(r,f);if(!k.ok){a("dropped",r,k.reason);return}let se=z(t.location.href),K={event_id:d?.event_id&&xe.test(d.event_id)?d.event_id:Ye(),event:r,ts:Date.now(),schema_version:1,env:j,source:u,channel:l,sdk:b,page_id:M,page_type:d?.page_type!==void 0?d.page_type:ee,host:se?.host??null,path:d?.path?ue(d.path.split(/[?#]/)[0]):se?.path??null,referrer_host:Le,utm_source:T?.utm_source??null,utm_medium:T?.utm_medium??null,utm_campaign:T?.utm_campaign??null,utm_content:T?.utm_content??null,utm_term:T?.utm_term??null,ref_code:T?.ref_code??null,product_id:d?.product_id??null,variant_id:d?.variant_id??null,order_ref:d?.order_ref??null,props:k.props};d?.event_id&&!xe.test(d.event_id)&&a("ignored invalid event_id",r),u==="dashboard"&&e.visitorId&&(K.visitor_id=e.visitorId);let ce=pe(K);if(!ce.ok){a("dropped",r,ce.reason);return}let G=K;m?ne(G):E.push(G),p.push(G),p.length>=Ge?x():Be()}let ie=()=>x(!0),ae=()=>{document.visibilityState==="hidden"&&x(!0)},S=()=>re();return t.addEventListener("pagehide",ie),document.addEventListener("visibilitychange",ae),t.addEventListener("bitsnap:consent",S),t.addEventListener("bitsnap:consent:ready",S),W(),U(m),{track(r,f,d){try{oe(r,f,d)}catch{}},page(r,f){try{r!==void 0&&(ee=r),oe("page_view",{landing:Re++===0},f)}catch{}},clientId(r){try{return r!==void 0&&_(r)!==i?null:P()?N(t,i):null}catch{return null}},flush:()=>x(),setEnabled(r){H=!!r,H||(p=[],E=[],w())},configure(r){try{(r.env==="live"||r.env==="test")&&(j=r.env),typeof r.endpoint=="string"&&r.endpoint&&(s=c(r.endpoint))}catch{}},onEvent(r){return C.add(r),()=>void C.delete(r)},destroy(){p=[],E=[],w(),C.clear(),t.removeEventListener("pagehide",ie),document.removeEventListener("visibilitychange",ae),t.removeEventListener("bitsnap:consent",S),t.removeEventListener("bitsnap:consent:ready",S)}}}var v,O=null;function D(e){if(!v){let t=Xe(e);return t===y||(v=t,O=_(e.projectKey??"")),t}try{let t=_(e.projectKey??"");t!==O&&e.debug&&console.warn("[bitsnap analytics]","tracker already started for another projectKey, ignoring",e.projectKey),t===O&&((e.env||e.endpoint)&&v.configure({env:e.env,endpoint:e.endpoint}),e.enabled!=null&&v.setEnabled(e.enabled))}catch{}return v}function Ae(){return v}function xt(){typeof window<"u"&&ge(window),v?.destroy(),v=void 0,O=null}function _t(e){try{if(typeof window>"u")return{};let t=v,n=null;if(t)n=t.clientId(e);else{let o=e?_(e):null;n=o?N(window,o):null}return n?{[me]:n}:{}}catch{return{}}}import{createContext as Ze,createElement as Qe,useContext as et,useMemo as Ie,useRef as tt}from"react";var nt={track:y.track,page:y.page},Pe=Ze(nt);function St({projectKey:e,env:t,enabled:n,endpoint:o,onEvent:a,autoPageViews:i,children:c}){let s=Ie(()=>D({projectKey:e,env:t,endpoint:o,enabled:n}),[e,t,o]),u=tt(a);u.current=a,L(()=>{s.setEnabled(n!==!1)},[s,n]),L(()=>{if(!(i===!1||n===!1||s===y))return A(()=>s.page(null))},[s,i,n]),L(()=>s.onEvent(b=>u.current?.(b)),[s]);let l=Ie(()=>({track:s.track.bind(s),page:s.page.bind(s)}),[s]);return Qe(Pe.Provider,{value:l},c)}function we(){return et(Pe)}import{createContext as rt,createElement as ot,useContext as Ve,useEffect as it,useLayoutEffect as at,useMemo as st,useRef as ct}from"react";var $={track(){}},X=null;function lt(e){let t=Symbol("bitsnap-instrument");function n(){if(typeof window>"u")return null;let{projectKey:i,analytics:c,provided:s}=e();return c===!1?null:s||(i?D({projectKey:i,source:"sdk_react",channel:"embed",env:typeof c=="object"?c.env:void 0}):null)}let o={track(i,c,s){try{let u=n();if(!u)return;let{analytics:l,pageType:b}=e(),M=b&&s?.page_type===void 0?{...s,page_type:b}:s;X=typeof l=="object"&&l.onEvent?t:null,u.track(i,c,M)}catch{}finally{X=null}}};function a(){try{if(!n())return()=>{};let i=Ae();if(!i)return()=>{};let c=e().provided?()=>{}:A(()=>i.page(e().pageType??null)),s=i.onEvent(u=>{if(X===t)try{let{analytics:l}=e();typeof l=="object"&&l.onEvent?.(u)}catch{}});return()=>{c(),s()}}catch{return()=>{}}}return{instrument:o,attach:a}}var Z=rt(null);function Nt({value:e,children:t}){return ot(Z.Provider,{value:e},t)}function Ot(){return Ve(Z)??$}function Dt(e,t,n){let o=Ve(Z),a=we(),i=a.track===y.track?null:a,c=ct({projectKey:e,analytics:t,pageType:n,provided:i});c.current={projectKey:e,analytics:t,pageType:n,provided:i};let s=st(()=>lt(()=>c.current),[]),u=t===void 0&&o!==null,l=typeof t=="object"&&!!t.onEvent;return at(()=>{if(!u)return s.attach()},[s,u,l,e]),u?o:s.instrument}var Q=$;function Se(e){Q=e??$}var q=0;function $t(){return q>0?$:Q}async function Mt(e){q++;try{return await e()}finally{q--}}function jt(e){it(()=>(Se(e),()=>{Q===e&&Se(null)}),[e])}function Ht(e){let t=Number.isFinite(e)?Math.max(0,Math.min(100,e)):0;return t>=100?"100":t>=75?"75-99":t>=50?"50-74":t>=25?"25-49":"0-24"}function Wt(e,t){let n=[];for(let o of[25,50,75,100])e>=o&&!t.has(o)&&(t.add(o),n.push(o));return n}export{ve as a,A as b,Ue as c,Xe as d,D as e,Ae as f,xt as g,_t as h,St as i,we as j,$ as k,Nt as l,Ot as m,Dt as n,$t as o,Mt as p,jt as q,Ht as r,Wt as s};
2
- //# sourceMappingURL=chunk-T2YSOHJM.mjs.map
1
+ import{a as le,c as _,d as ue,e as z,f as de,g as V,h as fe,i as pe,o as Y,q as L}from"./chunk-MDCP5JNP.mjs";var Oe=Symbol.for("bitsnap.pageViews");function ye(e){let t=e;return t[Oe]??={path:null,starters:new Set,watching:!1}}function De(e,t){let n=()=>{try{t()}catch{}};for(let o of["pushState","replaceState"]){let a=e.history[o];e.history[o]=function(...i){let c=a.apply(this,i);return n(),c}}e.addEventListener("popstate",n)}function A(e,t=window){try{let n=ye(t),o=()=>e();n.watching||(n.watching=!0,De(t,()=>{let i=t.location.pathname;i===n.path||n.starters.size===0||(n.path=i,n.starters.values().next().value?.())})),n.starters.add(o);let a=t.location.pathname;return a!==n.path&&(n.path=a,o()),()=>void n.starters.delete(o)}catch{return()=>{}}}function ge(e=window){let t=ye(e);t.path=null,t.starters.clear()}var ve="1.14.0";function I(e){let t=new Uint8Array(e),n=typeof crypto<"u"?crypto:void 0;if(n&&typeof n.getRandomValues=="function")n.getRandomValues(t);else for(let o=0;o<e;o++)t[o]=Math.floor(Math.random()*256);return t}var me="X-Bitsnap-Visitor",$e=390*24*60*60,Me=/^[A-Za-z0-9_-]{22}$/;function R(e){return e.BitsnapConsent}function je(e,t){for(let n of e.cookie.split(";")){let o=n.indexOf("=");if(o!==-1&&n.slice(0,o).trim()===t)return n.slice(o+1).trim()}return null}function He(e){let t=e.toLowerCase();return t==="bitsnap.pl"||t.endsWith(".bitsnap.pl")}function F(e,t){try{let n=R(e);if(!n)return!1;if(n.scope==="project")return n.projectKey===t;let o=He(e.location.hostname);return n.scope==="global"?!o:!1}catch{return!1}}function J(e,t){try{return R(e)?.get()?.c.analytics===!0&&F(e,t)}catch{return!1}}function he(){let e="";return I(16).forEach(t=>e+=String.fromCharCode(t)),btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Ee(e,t){try{return je(e,V(t))}catch{return null}}function B(e,t){let n=Ee(e,t);return n!==null&&Me.test(n)?n:null}function ke(e,t,n){try{let o=e.document,a=`${V(t)}=${n}; Max-Age=${$e}; Path=/; SameSite=Lax`+(e.location.protocol==="https:"?"; Secure":"");for(let i of Y(e.location.hostname).reverse())if(o.cookie=`${a}; Domain=${i}`,B(o,t)===n)return;o.cookie=a}catch{}}function be(e,t){try{let n=e.document;if(Ee(n,t)===null)return;let o=`${V(t)}=; Max-Age=0; Path=/; SameSite=Lax`+(e.location.protocol==="https:"?"; Secure":"");n.cookie=o;for(let a of Y(e.location.hostname))n.cookie=`${o}; Domain=${a}`}catch{}}function N(e,t){try{let n=e.navigator;return n?.globalPrivacyControl===!0||n?.webdriver===!0?null:J(e,t)?B(e.document,t):null}catch{return null}}var Ue="https://collect.bitsnap.pl",Ke=5e3,Ge=20,Te=32*1024,ze=60*1024,xe=/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function _e(e){return typeof TextEncoder=="function"?new TextEncoder().encode(e).length:unescape(encodeURIComponent(e)).length}var y={track(){},page(){},clientId:()=>null,flush(){},setEnabled(){},onEvent:()=>()=>{},configure(){},destroy(){}};function Ye(e=Date.now()){let t=I(16),n=e;for(let a=5;a>=0;a--)t[a]=n%256,n=Math.floor(n/256);t[6]=t[6]&15|112,t[8]=t[8]&63|128;let o=Array.from(t,a=>a.toString(16).padStart(2,"0")).join("");return`${o.slice(0,8)}-${o.slice(8,12)}-${o.slice(12,16)}-${o.slice(16,20)}-${o.slice(20)}`}var Ce="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";function Fe(){return Array.from(I(16),e=>Ce[e%Ce.length]).join("")}function Je(e,t,n=!1){let o=_e(JSON.stringify({k:e,events:[]})),a=[],i=[],c=o,s=()=>{i.length>0&&a.push({body:JSON.stringify({k:e,events:i}),bytes:c,count:i.length}),i=[],c=o};for(let u of t){let l=_e(JSON.stringify(u));o+l>Te||((i.length>=le.maxBatchEvents||c+l+(i.length>0?1:0)>Te)&&s(),c+=l+(i.length>0?1:0),i.push(u))}if(s(),n){let u=0,l=a.length;for(;l>0&&u+a[l-1].bytes<=ze;)u+=a[l-1].bytes,l--;a=a.slice(l)}return a}function Xe(e){try{return typeof window>"u"||typeof document>"u"?y:qe(e,window)}catch{return y}}function qe(e,t){let n=_(e.projectKey??""),o=!!e.debug,a=(...r)=>{o&&console.warn("[bitsnap analytics]",...r)};if(!n)return a("invalid projectKey, tracking is off"),y;let i=n,c=r=>`${(r||Ue).replace(/\/+$/,"")}/e`,s=c(e.endpoint),u=e.source??"sdk_react",l=e.channel??"embed",b=`bitsnap-react@${ve}`,M=Fe(),T=z(t.location.href),j=e.env??"live";if(!e.env)try{new URLSearchParams(t.location.search).has("test")&&(j="test")}catch{}let Le=de(document.referrer),H=e.enabled!==!1,ee=null,Re=0,p=[],h=null,C=new Set;e.onEvent&&C.add(e.onEvent);let E=[],g,m=!0;function W(){let r=R(t);!r||r===g||(g=r,m=!r.ready,r.ready?.then(()=>{g===r&&(m=!0,re())},()=>{g===r&&(m=!0)}))}function te(){W();try{if(!g)return!1;let r=g.get();return!!g.denied&&g.denied("analytics")||!!r&&r.c.analytics===!1}catch{return!1}}function ne(r){C.forEach(f=>{try{f(r)}catch{}})}function U(r){try{if(W(),!g||!F(t,i))return;J(t,i)?P()&&B(t.document,i)===null&&ke(t,i,he()):r&&be(t,i)}catch{}}function re(){if(U(!0),te())p=[],E=[],w();else{if(m&&E.length>0){let r=E;E=[],r.forEach(ne)}p.length>0&&x()}}function P(){if(!H)return!1;let r=t.navigator;return r&&(r.globalPrivacyControl===!0||r.webdriver===!0)?!1:!te()}function w(){h!==null&&clearTimeout(h),h=null}function Be(){h===null&&(h=setTimeout(()=>{h=null,x()},Ke),h.unref?.())}function Ne(r){try{if(typeof fetch=="function"){fetch(s,{method:"POST",body:r,keepalive:!0,credentials:"omit",headers:{"Content-Type":"text/plain"}}).catch(()=>{});return}}catch{}try{let f=t.navigator;f&&typeof f.sendBeacon=="function"&&f.sendBeacon(s,new Blob([r],{type:"text/plain"}))}catch{}}function x(r=!1){try{if(w(),p.length===0)return;if(!P()){p=[];return}if(!m)return;U(m);let f=N(t,i),d=f?p.map(k=>({...k,client_id:f})):p;p=[],Je(i,d,r).forEach(k=>Ne(k.body))}catch{}}function oe(r,f,d){if(!P())return;let k=fe(r,f);if(!k.ok){a("dropped",r,k.reason);return}let se=z(t.location.href),K={event_id:d?.event_id&&xe.test(d.event_id)?d.event_id:Ye(),event:r,ts:Date.now(),schema_version:1,env:j,source:u,channel:l,sdk:b,page_id:M,page_type:d?.page_type!==void 0?d.page_type:ee,host:se?.host??null,path:d?.path?ue(d.path.split(/[?#]/)[0]):se?.path??null,referrer_host:Le,utm_source:T?.utm_source??null,utm_medium:T?.utm_medium??null,utm_campaign:T?.utm_campaign??null,utm_content:T?.utm_content??null,utm_term:T?.utm_term??null,ref_code:T?.ref_code??null,product_id:d?.product_id??null,variant_id:d?.variant_id??null,order_ref:d?.order_ref??null,props:k.props};d?.event_id&&!xe.test(d.event_id)&&a("ignored invalid event_id",r),u==="dashboard"&&e.visitorId&&(K.visitor_id=e.visitorId);let ce=pe(K);if(!ce.ok){a("dropped",r,ce.reason);return}let G=K;m?ne(G):E.push(G),p.push(G),p.length>=Ge?x():Be()}let ie=()=>x(!0),ae=()=>{document.visibilityState==="hidden"&&x(!0)},S=()=>re();return t.addEventListener("pagehide",ie),document.addEventListener("visibilitychange",ae),t.addEventListener("bitsnap:consent",S),t.addEventListener("bitsnap:consent:ready",S),W(),U(m),{track(r,f,d){try{oe(r,f,d)}catch{}},page(r,f){try{r!==void 0&&(ee=r),oe("page_view",{landing:Re++===0},f)}catch{}},clientId(r){try{return r!==void 0&&_(r)!==i?null:P()?N(t,i):null}catch{return null}},flush:()=>x(),setEnabled(r){H=!!r,H||(p=[],E=[],w())},configure(r){try{(r.env==="live"||r.env==="test")&&(j=r.env),typeof r.endpoint=="string"&&r.endpoint&&(s=c(r.endpoint))}catch{}},onEvent(r){return C.add(r),()=>void C.delete(r)},destroy(){p=[],E=[],w(),C.clear(),t.removeEventListener("pagehide",ie),document.removeEventListener("visibilitychange",ae),t.removeEventListener("bitsnap:consent",S),t.removeEventListener("bitsnap:consent:ready",S)}}}var v,O=null;function D(e){if(!v){let t=Xe(e);return t===y||(v=t,O=_(e.projectKey??"")),t}try{let t=_(e.projectKey??"");t!==O&&e.debug&&console.warn("[bitsnap analytics]","tracker already started for another projectKey, ignoring",e.projectKey),t===O&&((e.env||e.endpoint)&&v.configure({env:e.env,endpoint:e.endpoint}),e.enabled!=null&&v.setEnabled(e.enabled))}catch{}return v}function Ae(){return v}function xt(){typeof window<"u"&&ge(window),v?.destroy(),v=void 0,O=null}function _t(e){try{if(typeof window>"u")return{};let t=v,n=null;if(t)n=t.clientId(e);else{let o=e?_(e):null;n=o?N(window,o):null}return n?{[me]:n}:{}}catch{return{}}}import{createContext as Ze,createElement as Qe,useContext as et,useMemo as Ie,useRef as tt}from"react";var nt={track:y.track,page:y.page},Pe=Ze(nt);function St({projectKey:e,env:t,enabled:n,endpoint:o,onEvent:a,autoPageViews:i,children:c}){let s=Ie(()=>D({projectKey:e,env:t,endpoint:o,enabled:n}),[e,t,o]),u=tt(a);u.current=a,L(()=>{s.setEnabled(n!==!1)},[s,n]),L(()=>{if(!(i===!1||n===!1||s===y))return A(()=>s.page(null))},[s,i,n]),L(()=>s.onEvent(b=>u.current?.(b)),[s]);let l=Ie(()=>({track:s.track.bind(s),page:s.page.bind(s)}),[s]);return Qe(Pe.Provider,{value:l},c)}function we(){return et(Pe)}import{createContext as rt,createElement as ot,useContext as Ve,useEffect as it,useLayoutEffect as at,useMemo as st,useRef as ct}from"react";var $={track(){}},X=null;function lt(e){let t=Symbol("bitsnap-instrument");function n(){if(typeof window>"u")return null;let{projectKey:i,analytics:c,provided:s}=e();return c===!1?null:s||(i?D({projectKey:i,source:"sdk_react",channel:"embed",env:typeof c=="object"?c.env:void 0}):null)}let o={track(i,c,s){try{let u=n();if(!u)return;let{analytics:l,pageType:b}=e(),M=b&&s?.page_type===void 0?{...s,page_type:b}:s;X=typeof l=="object"&&l.onEvent?t:null,u.track(i,c,M)}catch{}finally{X=null}}};function a(){try{if(!n())return()=>{};let i=Ae();if(!i)return()=>{};let c=e().provided?()=>{}:A(()=>i.page(e().pageType??null)),s=i.onEvent(u=>{if(X===t)try{let{analytics:l}=e();typeof l=="object"&&l.onEvent?.(u)}catch{}});return()=>{c(),s()}}catch{return()=>{}}}return{instrument:o,attach:a}}var Z=rt(null);function Nt({value:e,children:t}){return ot(Z.Provider,{value:e},t)}function Ot(){return Ve(Z)??$}function Dt(e,t,n){let o=Ve(Z),a=we(),i=a.track===y.track?null:a,c=ct({projectKey:e,analytics:t,pageType:n,provided:i});c.current={projectKey:e,analytics:t,pageType:n,provided:i};let s=st(()=>lt(()=>c.current),[]),u=t===void 0&&o!==null,l=typeof t=="object"&&!!t.onEvent;return at(()=>{if(!u)return s.attach()},[s,u,l,e]),u?o:s.instrument}var Q=$;function Se(e){Q=e??$}var q=0;function $t(){return q>0?$:Q}async function Mt(e){q++;try{return await e()}finally{q--}}function jt(e){it(()=>(Se(e),()=>{Q===e&&Se(null)}),[e])}function Ht(e){let t=Number.isFinite(e)?Math.max(0,Math.min(100,e)):0;return t>=100?"100":t>=75?"75-99":t>=50?"50-74":t>=25?"25-49":"0-24"}function Wt(e,t){let n=[];for(let o of[25,50,75,100])e>=o&&!t.has(o)&&(t.add(o),n.push(o));return n}export{ve as a,A as b,Ue as c,Xe as d,D as e,Ae as f,xt as g,_t as h,St as i,we as j,$ as k,Nt as l,Ot as m,Dt as n,$t as o,Mt as p,jt as q,Ht as r,Wt as s};
2
+ //# sourceMappingURL=chunk-3OEKRPWV.mjs.map