@monetize.software/sdk-extension 3.0.0-alpha.9 → 3.0.0-beta.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 (226) hide show
  1. package/dist/chunks/ar-CViBaj16.js +2 -0
  2. package/dist/chunks/ar-CViBaj16.js.map +1 -0
  3. package/dist/chunks/{ar-CHae8g-2.js → ar-ClwBmll7.js} +6 -2
  4. package/dist/chunks/ar-ClwBmll7.js.map +1 -0
  5. package/dist/chunks/{chrome-port-BzNV1ahF.js → chrome-port-BEMjZQAH.js} +2 -2
  6. package/dist/chunks/chrome-port-BEMjZQAH.js.map +1 -0
  7. package/dist/chunks/{chrome-port-rVd4zwU3.js → chrome-port-bfTUUDz_.js} +159 -123
  8. package/dist/chunks/chrome-port-bfTUUDz_.js.map +1 -0
  9. package/dist/chunks/{cs-eZTedzaK.js → cs-Cc_D0W4S.js} +6 -2
  10. package/dist/chunks/cs-Cc_D0W4S.js.map +1 -0
  11. package/dist/chunks/cs-DQJWP65K.js +2 -0
  12. package/dist/chunks/cs-DQJWP65K.js.map +1 -0
  13. package/dist/chunks/{da-Dca6j8fp.js → da-BtKcMSxH.js} +6 -2
  14. package/dist/chunks/da-BtKcMSxH.js.map +1 -0
  15. package/dist/chunks/da-Cyr_IXhb.js +2 -0
  16. package/dist/chunks/da-Cyr_IXhb.js.map +1 -0
  17. package/dist/chunks/de-BOCUj1pF.js +2 -0
  18. package/dist/chunks/de-BOCUj1pF.js.map +1 -0
  19. package/dist/chunks/{de-BCjn3PUI.js → de-iwQW5eYl.js} +6 -2
  20. package/dist/chunks/de-iwQW5eYl.js.map +1 -0
  21. package/dist/chunks/{el-BpXtDTez.js → el-BoH65CeJ.js} +6 -2
  22. package/dist/chunks/el-BoH65CeJ.js.map +1 -0
  23. package/dist/chunks/el-C6jLHiEF.js +2 -0
  24. package/dist/chunks/el-C6jLHiEF.js.map +1 -0
  25. package/dist/chunks/es-CARHLxHR.js +2 -0
  26. package/dist/chunks/es-CARHLxHR.js.map +1 -0
  27. package/dist/chunks/{es-B3P4nlMw.js → es-CkP16_8K.js} +6 -2
  28. package/dist/chunks/es-CkP16_8K.js.map +1 -0
  29. package/dist/chunks/fi-B8OhRbwY.js +2 -0
  30. package/dist/chunks/fi-B8OhRbwY.js.map +1 -0
  31. package/dist/chunks/{fi-BbQ_Bs0Z.js → fi-yUXSmK1E.js} +6 -2
  32. package/dist/chunks/fi-yUXSmK1E.js.map +1 -0
  33. package/dist/chunks/fr-CoM18zzM.js +2 -0
  34. package/dist/chunks/fr-CoM18zzM.js.map +1 -0
  35. package/dist/chunks/{fr-BKDUXceO.js → fr-DSZRGsxI.js} +6 -2
  36. package/dist/chunks/fr-DSZRGsxI.js.map +1 -0
  37. package/dist/chunks/he-DTDVc3lA.js +2 -0
  38. package/dist/chunks/he-DTDVc3lA.js.map +1 -0
  39. package/dist/chunks/{he-BVCHlTtT.js → he-ZUo7cQjk.js} +8 -4
  40. package/dist/chunks/he-ZUo7cQjk.js.map +1 -0
  41. package/dist/chunks/hi-BjnS9UeE.js +2 -0
  42. package/dist/chunks/hi-BjnS9UeE.js.map +1 -0
  43. package/dist/chunks/{hi-H_Hshh-7.js → hi-CEutBKiG.js} +6 -2
  44. package/dist/chunks/hi-CEutBKiG.js.map +1 -0
  45. package/dist/chunks/hu-CN06FMhV.js +2 -0
  46. package/dist/chunks/hu-CN06FMhV.js.map +1 -0
  47. package/dist/chunks/{hu-ZWiNfzvN.js → hu-DvEAWGS7.js} +6 -2
  48. package/dist/chunks/hu-DvEAWGS7.js.map +1 -0
  49. package/dist/chunks/id-BITgaBxq.js +2 -0
  50. package/dist/chunks/id-BITgaBxq.js.map +1 -0
  51. package/dist/chunks/{id-DeiRYsJ1.js → id-_eEMrYMW.js} +6 -2
  52. package/dist/chunks/id-_eEMrYMW.js.map +1 -0
  53. package/dist/chunks/{it-UH9OzFhg.js → it-BAmsQbIl.js} +6 -2
  54. package/dist/chunks/it-BAmsQbIl.js.map +1 -0
  55. package/dist/chunks/it-DVcsq015.js +2 -0
  56. package/dist/chunks/it-DVcsq015.js.map +1 -0
  57. package/dist/chunks/ja-Bim7Ok2e.js +2 -0
  58. package/dist/chunks/ja-Bim7Ok2e.js.map +1 -0
  59. package/dist/chunks/{ja-BYC8FRN8.js → ja-BqCZWVKK.js} +8 -4
  60. package/dist/chunks/ja-BqCZWVKK.js.map +1 -0
  61. package/dist/chunks/{ko-Bjs2ZRcF.js → ko-CkIzeOzb.js} +8 -4
  62. package/dist/chunks/ko-CkIzeOzb.js.map +1 -0
  63. package/dist/chunks/ko-DqEfcVCB.js +2 -0
  64. package/dist/chunks/ko-DqEfcVCB.js.map +1 -0
  65. package/dist/chunks/nl-DSNuJWIo.js +2 -0
  66. package/dist/chunks/nl-DSNuJWIo.js.map +1 -0
  67. package/dist/chunks/{nl-Ch5HFWQO.js → nl-Mu_KNzli.js} +6 -2
  68. package/dist/chunks/nl-Mu_KNzli.js.map +1 -0
  69. package/dist/chunks/{no-CljpinWz.js → no-9HMjljBs.js} +6 -2
  70. package/dist/chunks/no-9HMjljBs.js.map +1 -0
  71. package/dist/chunks/no-B5HY_A8_.js +2 -0
  72. package/dist/chunks/no-B5HY_A8_.js.map +1 -0
  73. package/dist/chunks/{pl-CUcSS0zZ.js → pl-Cbr2qDwv.js} +6 -2
  74. package/dist/chunks/pl-Cbr2qDwv.js.map +1 -0
  75. package/dist/chunks/pl-ChGLn9Sy.js +2 -0
  76. package/dist/chunks/pl-ChGLn9Sy.js.map +1 -0
  77. package/dist/chunks/port-name-CF4WQQ3-.js +2 -0
  78. package/dist/chunks/port-name-CF4WQQ3-.js.map +1 -0
  79. package/dist/chunks/port-name-ervLBWAQ.js +6 -0
  80. package/dist/chunks/port-name-ervLBWAQ.js.map +1 -0
  81. package/dist/chunks/pt-CDLEktT9.js +2 -0
  82. package/dist/chunks/pt-CDLEktT9.js.map +1 -0
  83. package/dist/chunks/{pt-BHK0LwkC.js → pt-_jirA6IR.js} +6 -2
  84. package/dist/chunks/pt-_jirA6IR.js.map +1 -0
  85. package/dist/chunks/ro-BHCHiXY3.js +2 -0
  86. package/dist/chunks/ro-BHCHiXY3.js.map +1 -0
  87. package/dist/chunks/{ro-Bj8cwU2n.js → ro-oZLxhwHc.js} +6 -2
  88. package/dist/chunks/ro-oZLxhwHc.js.map +1 -0
  89. package/dist/chunks/ru-B6HgmINj.js +2 -0
  90. package/dist/chunks/ru-B6HgmINj.js.map +1 -0
  91. package/dist/chunks/{ru-CgqNy0Gb.js → ru-C2-sqY7B.js} +6 -2
  92. package/dist/chunks/ru-C2-sqY7B.js.map +1 -0
  93. package/dist/chunks/sv-DoSs4a9n.js +2 -0
  94. package/dist/chunks/sv-DoSs4a9n.js.map +1 -0
  95. package/dist/chunks/{sv-H7jroOQ5.js → sv-y385MWVy.js} +6 -2
  96. package/dist/chunks/sv-y385MWVy.js.map +1 -0
  97. package/dist/chunks/{th-Dqm-gpGe.js → th-Bjbv4M1s.js} +6 -2
  98. package/dist/chunks/th-Bjbv4M1s.js.map +1 -0
  99. package/dist/chunks/th-UeweOhwg.js +2 -0
  100. package/dist/chunks/th-UeweOhwg.js.map +1 -0
  101. package/dist/chunks/tr-BbBr5tyB.js +2 -0
  102. package/dist/chunks/tr-BbBr5tyB.js.map +1 -0
  103. package/dist/chunks/{tr-D3zPcNtT.js → tr-DmHo9F8i.js} +8 -4
  104. package/dist/chunks/tr-DmHo9F8i.js.map +1 -0
  105. package/dist/chunks/uk-CJTA1SJK.js +2 -0
  106. package/dist/chunks/uk-CJTA1SJK.js.map +1 -0
  107. package/dist/chunks/{uk-CoIIs3QI.js → uk-DwvAoTe5.js} +6 -2
  108. package/dist/chunks/uk-DwvAoTe5.js.map +1 -0
  109. package/dist/chunks/{vi-C_fruIbh.js → vi-BEpwsVLR.js} +6 -2
  110. package/dist/chunks/vi-BEpwsVLR.js.map +1 -0
  111. package/dist/chunks/vi-ZvBo7PbB.js +2 -0
  112. package/dist/chunks/vi-ZvBo7PbB.js.map +1 -0
  113. package/dist/chunks/zh-CPZBEb3d.js +2 -0
  114. package/dist/chunks/zh-CPZBEb3d.js.map +1 -0
  115. package/dist/chunks/{zh-LDkEV2D9.js → zh-DrG18oGe.js} +7 -3
  116. package/dist/chunks/zh-DrG18oGe.js.map +1 -0
  117. package/dist/content/PaywallUI.d.ts +1 -1
  118. package/dist/content/RemoteAuthClient.d.ts +3 -3
  119. package/dist/content/RemoteBillingClient.d.ts +7 -3
  120. package/dist/content/RemoteBillingClient.d.ts.map +1 -1
  121. package/dist/content/RemoteTrialStore.d.ts +2 -2
  122. package/dist/content.cjs +3 -3
  123. package/dist/content.cjs.map +1 -1
  124. package/dist/content.js +1198 -766
  125. package/dist/content.js.map +1 -1
  126. package/dist/offscreen/server.d.ts +3 -3
  127. package/dist/offscreen/server.d.ts.map +1 -1
  128. package/dist/offscreen.cjs +1 -1
  129. package/dist/offscreen.cjs.map +1 -1
  130. package/dist/offscreen.js +9 -9
  131. package/dist/offscreen.js.map +1 -1
  132. package/dist/shared/messages.d.ts +4 -4
  133. package/dist/shared/port-name.d.ts +1 -0
  134. package/dist/shared/port-name.d.ts.map +1 -1
  135. package/dist/sw.cjs +1 -1
  136. package/dist/sw.cjs.map +1 -1
  137. package/dist/sw.js +14 -14
  138. package/dist/sw.js.map +1 -1
  139. package/package.json +3 -3
  140. package/dist/chunks/ar-CHae8g-2.js.map +0 -1
  141. package/dist/chunks/ar-E1mc8SO_.js +0 -2
  142. package/dist/chunks/ar-E1mc8SO_.js.map +0 -1
  143. package/dist/chunks/chrome-port-BzNV1ahF.js.map +0 -1
  144. package/dist/chunks/chrome-port-rVd4zwU3.js.map +0 -1
  145. package/dist/chunks/cs-Dccq6LAT.js +0 -2
  146. package/dist/chunks/cs-Dccq6LAT.js.map +0 -1
  147. package/dist/chunks/cs-eZTedzaK.js.map +0 -1
  148. package/dist/chunks/da-C_4MbEh5.js +0 -2
  149. package/dist/chunks/da-C_4MbEh5.js.map +0 -1
  150. package/dist/chunks/da-Dca6j8fp.js.map +0 -1
  151. package/dist/chunks/de-BCjn3PUI.js.map +0 -1
  152. package/dist/chunks/de-DulxcJj-.js +0 -2
  153. package/dist/chunks/de-DulxcJj-.js.map +0 -1
  154. package/dist/chunks/el-BpXtDTez.js.map +0 -1
  155. package/dist/chunks/el-CVG_1iKB.js +0 -2
  156. package/dist/chunks/el-CVG_1iKB.js.map +0 -1
  157. package/dist/chunks/es-B3P4nlMw.js.map +0 -1
  158. package/dist/chunks/es-ri0uKzUW.js +0 -2
  159. package/dist/chunks/es-ri0uKzUW.js.map +0 -1
  160. package/dist/chunks/fi-BbQ_Bs0Z.js.map +0 -1
  161. package/dist/chunks/fi-CNZqWHjw.js +0 -2
  162. package/dist/chunks/fi-CNZqWHjw.js.map +0 -1
  163. package/dist/chunks/fr-BKDUXceO.js.map +0 -1
  164. package/dist/chunks/fr-CfFOw4hD.js +0 -2
  165. package/dist/chunks/fr-CfFOw4hD.js.map +0 -1
  166. package/dist/chunks/he-BVCHlTtT.js.map +0 -1
  167. package/dist/chunks/he-DN2JEtQb.js +0 -2
  168. package/dist/chunks/he-DN2JEtQb.js.map +0 -1
  169. package/dist/chunks/hi-DxfOerNP.js +0 -2
  170. package/dist/chunks/hi-DxfOerNP.js.map +0 -1
  171. package/dist/chunks/hi-H_Hshh-7.js.map +0 -1
  172. package/dist/chunks/hu-BTImywuV.js +0 -2
  173. package/dist/chunks/hu-BTImywuV.js.map +0 -1
  174. package/dist/chunks/hu-ZWiNfzvN.js.map +0 -1
  175. package/dist/chunks/id-DeiRYsJ1.js.map +0 -1
  176. package/dist/chunks/id-YFuArJA6.js +0 -2
  177. package/dist/chunks/id-YFuArJA6.js.map +0 -1
  178. package/dist/chunks/it-UH9OzFhg.js.map +0 -1
  179. package/dist/chunks/it-mhkzXBM9.js +0 -2
  180. package/dist/chunks/it-mhkzXBM9.js.map +0 -1
  181. package/dist/chunks/ja-6l_z_G9k.js +0 -2
  182. package/dist/chunks/ja-6l_z_G9k.js.map +0 -1
  183. package/dist/chunks/ja-BYC8FRN8.js.map +0 -1
  184. package/dist/chunks/ko-Bjs2ZRcF.js.map +0 -1
  185. package/dist/chunks/ko-YAl4XwHu.js +0 -2
  186. package/dist/chunks/ko-YAl4XwHu.js.map +0 -1
  187. package/dist/chunks/nl-C-9zHtfb.js +0 -2
  188. package/dist/chunks/nl-C-9zHtfb.js.map +0 -1
  189. package/dist/chunks/nl-Ch5HFWQO.js.map +0 -1
  190. package/dist/chunks/no-CljpinWz.js.map +0 -1
  191. package/dist/chunks/no-qzPitLlx.js +0 -2
  192. package/dist/chunks/no-qzPitLlx.js.map +0 -1
  193. package/dist/chunks/pl-CUcSS0zZ.js.map +0 -1
  194. package/dist/chunks/pl-MAIYeuhW.js +0 -2
  195. package/dist/chunks/pl-MAIYeuhW.js.map +0 -1
  196. package/dist/chunks/port-name-BPfQKtdb.js +0 -5
  197. package/dist/chunks/port-name-BPfQKtdb.js.map +0 -1
  198. package/dist/chunks/port-name-qwB109u9.js +0 -2
  199. package/dist/chunks/port-name-qwB109u9.js.map +0 -1
  200. package/dist/chunks/pt-BHK0LwkC.js.map +0 -1
  201. package/dist/chunks/pt-DqDabE4v.js +0 -2
  202. package/dist/chunks/pt-DqDabE4v.js.map +0 -1
  203. package/dist/chunks/ro-BVs-lHH-.js +0 -2
  204. package/dist/chunks/ro-BVs-lHH-.js.map +0 -1
  205. package/dist/chunks/ro-Bj8cwU2n.js.map +0 -1
  206. package/dist/chunks/ru-CgqNy0Gb.js.map +0 -1
  207. package/dist/chunks/ru-DP7qDAmE.js +0 -2
  208. package/dist/chunks/ru-DP7qDAmE.js.map +0 -1
  209. package/dist/chunks/sv-B3QEYGgd.js +0 -2
  210. package/dist/chunks/sv-B3QEYGgd.js.map +0 -1
  211. package/dist/chunks/sv-H7jroOQ5.js.map +0 -1
  212. package/dist/chunks/th-Dqm-gpGe.js.map +0 -1
  213. package/dist/chunks/th-DzQau9aW.js +0 -2
  214. package/dist/chunks/th-DzQau9aW.js.map +0 -1
  215. package/dist/chunks/tr-D3zPcNtT.js.map +0 -1
  216. package/dist/chunks/tr-cG1YuE1E.js +0 -2
  217. package/dist/chunks/tr-cG1YuE1E.js.map +0 -1
  218. package/dist/chunks/uk-CoIIs3QI.js.map +0 -1
  219. package/dist/chunks/uk-Cvbo0IBW.js +0 -2
  220. package/dist/chunks/uk-Cvbo0IBW.js.map +0 -1
  221. package/dist/chunks/vi-BRtYSBUp.js +0 -2
  222. package/dist/chunks/vi-BRtYSBUp.js.map +0 -1
  223. package/dist/chunks/vi-C_fruIbh.js.map +0 -1
  224. package/dist/chunks/zh-CwczPMPp.js +0 -2
  225. package/dist/chunks/zh-CwczPMPp.js.map +0 -1
  226. package/dist/chunks/zh-LDkEV2D9.js.map +0 -1
@@ -20,24 +20,24 @@ class P {
20
20
  n.set("Accept", "application/json"), n.set("X-SDK-Version", m), n.set("X-Paywall-Id", this.opts.paywallId), this.opts.capabilities?.length && n.set("X-SDK-Capabilities", this.opts.capabilities.join(","));
21
21
  const r = await this.opts.getAuthToken?.();
22
22
  r && n.set("Authorization", `Bearer ${r}`);
23
- const l = typeof FormData < "u" && e.body instanceof FormData;
24
- e.body && !n.has("Content-Type") && !l && n.set("Content-Type", "application/json");
25
- let d;
23
+ const h = typeof FormData < "u" && e.body instanceof FormData;
24
+ e.body && !n.has("Content-Type") && !h && n.set("Content-Type", "application/json");
25
+ let f;
26
26
  try {
27
- d = await a(s, {
27
+ f = await a(s, {
28
28
  ...e,
29
29
  headers: n,
30
30
  credentials: "omit"
31
31
  });
32
- } catch (h) {
33
- throw (h && typeof h == "object" && "name" in h ? h.name : void 0) === "AbortError" ? new o("aborted", "Request aborted", { cause: h }) : new o("network_error", "Network request failed", { cause: h });
32
+ } catch (c) {
33
+ throw (c && typeof c == "object" && "name" in c ? c.name : void 0) === "AbortError" ? new o("aborted", "Request aborted", { cause: c }) : new o("network_error", "Network request failed", { cause: c });
34
34
  }
35
- const y = (d.headers.get("content-type") ?? "").includes("application/json") ? await d.json().catch(() => null) : null;
36
- if (!d.ok) {
37
- const h = y && typeof y == "object" && "code" in y && String(y.code) || `http_${d.status}`, g = y && typeof y == "object" && "message" in y && String(y.message) || d.statusText || "Request failed";
38
- throw new o(h, g, { status: d.status, cause: y });
35
+ const d = (f.headers.get("content-type") ?? "").includes("application/json") ? await f.json().catch(() => null) : null;
36
+ if (!f.ok) {
37
+ const c = d && typeof d == "object" && "code" in d && String(d.code) || `http_${f.status}`, g = d && typeof d == "object" && "message" in d && String(d.message) || f.statusText || "Request failed";
38
+ throw new o(c, g, { status: f.status, cause: d });
39
39
  }
40
- return y;
40
+ return d;
41
41
  }
42
42
  }
43
43
  function x() {
@@ -101,18 +101,18 @@ const H = {
101
101
  };
102
102
  return window.addEventListener("storage", e), () => window.removeEventListener("storage", e);
103
103
  }
104
- }, S = /* @__PURE__ */ new Map(), V = {
104
+ }, I = /* @__PURE__ */ new Map(), V = {
105
105
  async getItem(i) {
106
- return S.get(i) ?? null;
106
+ return I.get(i) ?? null;
107
107
  },
108
108
  async setItem(i, t) {
109
- S.set(i, t);
109
+ I.set(i, t);
110
110
  },
111
111
  async removeItem(i) {
112
- S.delete(i);
112
+ I.delete(i);
113
113
  }
114
114
  };
115
- function R(i) {
115
+ function K(i) {
116
116
  return i || (x() ? H : typeof window < "u" && "localStorage" in window ? J : V);
117
117
  }
118
118
  const u = {
@@ -145,7 +145,7 @@ const u = {
145
145
  // (оптимистично через `decrementBalanceLocal`).
146
146
  balances: (i, t) => `pw-${i}-${t}-balances-v1`
147
147
  };
148
- function D() {
148
+ function R() {
149
149
  const i = typeof globalThis < "u" ? globalThis.crypto : void 0;
150
150
  if (i && typeof i.randomUUID == "function") return i.randomUUID();
151
151
  const t = new Uint8Array(16);
@@ -163,14 +163,14 @@ async function B(i) {
163
163
  if (e && typeof e == "string" && e.length >= 16) return e;
164
164
  } catch {
165
165
  }
166
- const t = D();
166
+ const t = R();
167
167
  try {
168
168
  await i.setItem(u.visitorId, t);
169
169
  } catch {
170
170
  }
171
171
  return t;
172
172
  }
173
- function M(i) {
173
+ function D(i) {
174
174
  const t = new Uint8Array(i), e = typeof globalThis < "u" ? globalThis.crypto : void 0;
175
175
  if (e && typeof e.getRandomValues == "function")
176
176
  e.getRandomValues(t);
@@ -184,17 +184,17 @@ function _(i) {
184
184
  return btoa(t).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
185
185
  }
186
186
  function j() {
187
- return _(M(64));
187
+ return _(D(64));
188
188
  }
189
- async function G(i) {
189
+ async function X(i) {
190
190
  const t = new TextEncoder().encode(i), e = globalThis.crypto;
191
191
  if (!e?.subtle?.digest)
192
192
  throw new Error("crypto.subtle is required for PKCE");
193
193
  const s = await e.subtle.digest("SHA-256", t);
194
194
  return _(new Uint8Array(s));
195
195
  }
196
- function X() {
197
- return _(M(16));
196
+ function G() {
197
+ return _(D(16));
198
198
  }
199
199
  const z = 6e4, Q = 600 * 1e3;
200
200
  class mt {
@@ -206,7 +206,7 @@ class mt {
206
206
  "invalid_config",
207
207
  "apiOrigin is required. Pass the paywall custom_domain configured in the platform."
208
208
  );
209
- this.paywallId = t.paywallId, this.apiOrigin = t.apiOrigin, this.storage = R(t.storage), this.api = new P({
209
+ this.paywallId = t.paywallId, this.apiOrigin = t.apiOrigin, this.storage = K(t.storage), this.api = new P({
210
210
  apiOrigin: this.apiOrigin,
211
211
  paywallId: t.paywallId,
212
212
  fetch: t.fetch
@@ -448,10 +448,8 @@ class mt {
448
448
  * когда сервер начнёт возвращать challenge_required в риск-сценариях,
449
449
  * SDK сможет передать proof-of-something обратно без breaking change.
450
450
  *
451
- * `forceCaptcha: true` пропускает шаги 1-2 и сразу делает /signin (создаёт
452
- * нового anon-юзера). Используется в switch-account flow. Имя поля исторически
453
- * остаётся `forceCaptcha`, хотя капчи там больше нет — менять имя ломает
454
- * host-сигнатуру; смысл «принудительно новая anon-сессия» сохранён.
451
+ * `forceNewAnon: true` пропускает шаги 1-2 и сразу делает /signin (создаёт
452
+ * нового anon-юзера). Используется в switch-account flow.
455
453
  *
456
454
  * Параллельные вызовы дедуплицируются через `inflightAnonSignin` — два
457
455
  * click'а на «Войти как гость» не создадут двух anon-юзеров (два /signup =
@@ -460,9 +458,9 @@ class mt {
460
458
  async signInAnonymously(t = {}) {
461
459
  if (this.inflightAnonSignin) return this.inflightAnonSignin;
462
460
  this.inflightAnonSignin = (async () => {
463
- if (await this.hydrated, !t.forceCaptcha && this.session?.user.is_anonymous === !0)
461
+ if (await this.hydrated, !t.forceNewAnon && this.session?.user.is_anonymous === !0)
464
462
  return this.session;
465
- if (!t.forceCaptcha) {
463
+ if (!t.forceNewAnon) {
466
464
  const r = await this.resumeAnonymous();
467
465
  if (r) return r;
468
466
  }
@@ -565,8 +563,8 @@ class mt {
565
563
  id: a.user.id,
566
564
  email: a.user.email,
567
565
  is_anonymous: a.user.is_anonymous ?? !1
568
- }, l = { ...n, user: r };
569
- return this.setSession(l, { event: "USER_UPDATED" }), await this.clearAnonRefreshToken(), { kind: "updated", session: l };
566
+ }, h = { ...n, user: r };
567
+ return this.setSession(h, { event: "USER_UPDATED" }), await this.clearAnonRefreshToken(), { kind: "updated", session: h };
570
568
  }
571
569
  /**
572
570
  * OAuth signin через popup с PKCE. Жизненный цикл:
@@ -623,9 +621,9 @@ class mt {
623
621
  */
624
622
  async startOAuthFlow(t) {
625
623
  await this.hydrated, this.gcOAuthFlows();
626
- const e = j(), s = await G(e), a = X(), n = {}, r = await this.getAccessToken().catch(() => null);
624
+ const e = j(), s = await X(e), a = G(), n = {}, r = await this.getAccessToken().catch(() => null);
627
625
  r && (n.Authorization = `Bearer ${r}`);
628
- const { authorize_url: l } = await this.api.request(
626
+ const { authorize_url: h } = await this.api.request(
629
627
  `/api/v1/paywall/${this.paywallId}/auth/oauth/init`,
630
628
  {
631
629
  method: "POST",
@@ -643,7 +641,7 @@ class mt {
643
641
  userMeta: t.userMeta,
644
642
  provider: t.provider,
645
643
  startedAt: Date.now()
646
- }), this.recordLastLoginMethod(t.provider), { authorize_url: l, state: a };
644
+ }), this.recordLastLoginMethod(t.provider), { authorize_url: h, state: a };
647
645
  }
648
646
  /**
649
647
  * Шаг 2 OAuth split-API: обменивает code (полученный из popup) на session,
@@ -958,19 +956,19 @@ function Z(i, t) {
958
956
  return new Promise((e, s) => {
959
957
  let a = !1;
960
958
  const n = () => {
961
- a = !0, window.removeEventListener("message", r), clearInterval(l), clearTimeout(d);
962
- }, r = (f) => {
959
+ a = !0, window.removeEventListener("message", r), clearInterval(h), clearTimeout(f);
960
+ }, r = (p) => {
963
961
  if (a) return;
964
- const c = f.data;
965
- if (!(!c || c.type !== "pw-oauth") && c.messageId === t) {
966
- if (c.status === "success" && c.code) {
962
+ const l = p.data;
963
+ if (!(!l || l.type !== "pw-oauth") && l.messageId === t) {
964
+ if (l.status === "success" && l.code) {
967
965
  n();
968
966
  try {
969
967
  i.close();
970
968
  } catch {
971
969
  }
972
- e(c.code);
973
- } else if (c.status === "error") {
970
+ e(l.code);
971
+ } else if (l.status === "error") {
974
972
  n();
975
973
  try {
976
974
  i.close();
@@ -979,21 +977,21 @@ function Z(i, t) {
979
977
  s(
980
978
  new o(
981
979
  "oauth_failed",
982
- c.description || c.error || "OAuth provider returned error"
980
+ l.description || l.error || "OAuth provider returned error"
983
981
  )
984
982
  );
985
983
  }
986
984
  }
987
- }, l = setInterval(() => {
985
+ }, h = setInterval(() => {
988
986
  if (a) return;
989
- let f;
987
+ let p;
990
988
  try {
991
- f = i.closed;
989
+ p = i.closed;
992
990
  } catch {
993
991
  return;
994
992
  }
995
- f && (n(), s(new o("oauth_cancelled", "auth popup was closed")));
996
- }, Y), d = setTimeout(() => {
993
+ p && (n(), s(new o("oauth_cancelled", "auth popup was closed")));
994
+ }, Y), f = setTimeout(() => {
997
995
  if (!a) {
998
996
  n();
999
997
  try {
@@ -1035,37 +1033,37 @@ class st {
1035
1033
  a.set("X-SDK-Version", m), a.set("X-Paywall-Id", this.paywallId), this.capabilities?.length && a.set("X-SDK-Capabilities", this.capabilities.join(","));
1036
1034
  const n = await this.auth?.getAccessToken();
1037
1035
  n ? a.set("Authorization", `Bearer ${n}`) : this.userId && a.set("X-User-ID", this.userId);
1038
- const r = typeof FormData < "u" && t.body instanceof FormData, l = typeof Blob < "u" && t.body instanceof Blob, d = typeof ReadableStream < "u" && t.body instanceof ReadableStream, f = typeof t.body == "string";
1036
+ const r = typeof FormData < "u" && t.body instanceof FormData, h = typeof Blob < "u" && t.body instanceof Blob, f = typeof ReadableStream < "u" && t.body instanceof ReadableStream, p = typeof t.body == "string";
1037
+ let l;
1038
+ t.body === void 0 || t.body === null ? l = void 0 : r || h || f || p ? l = t.body : (l = JSON.stringify(t.body), a.has("Content-Type") || a.set("Content-Type", "application/json"));
1039
+ const d = this.customFetch ?? fetch;
1039
1040
  let c;
1040
- t.body === void 0 || t.body === null ? c = void 0 : r || l || d || f ? c = t.body : (c = JSON.stringify(t.body), a.has("Content-Type") || a.set("Content-Type", "application/json"));
1041
- const y = this.customFetch ?? fetch;
1042
- let h;
1043
1041
  try {
1044
- h = await y(s.toString(), {
1042
+ c = await d(s.toString(), {
1045
1043
  method: t.method ?? "POST",
1046
1044
  headers: a,
1047
- body: c,
1045
+ body: l,
1048
1046
  signal: t.signal,
1049
1047
  credentials: "omit"
1050
1048
  });
1051
- } catch (p) {
1052
- const $ = p instanceof Error ? p.message : String(p);
1053
- throw new o("network_error", `Network request failed: ${$}`, { cause: p });
1049
+ } catch (y) {
1050
+ const $ = y instanceof Error ? y.message : String(y);
1051
+ throw new o("network_error", `Network request failed: ${$}`, { cause: y });
1054
1052
  }
1055
- if (h.status === 402) {
1056
- const p = await it(h);
1057
- throw this.onQuotaExceeded?.(p), p;
1053
+ if (c.status === 402) {
1054
+ const y = await it(c);
1055
+ throw this.onQuotaExceeded?.(y), y;
1058
1056
  }
1059
- if (!h.ok) {
1060
- const p = await at(h.clone());
1057
+ if (!c.ok) {
1058
+ const y = await at(c.clone());
1061
1059
  throw new o(
1062
- p ?? `http_${h.status}`,
1063
- h.statusText || "Gateway request failed",
1064
- { status: h.status }
1060
+ y ?? `http_${c.status}`,
1061
+ c.statusText || "Gateway request failed",
1062
+ { status: c.status }
1065
1063
  );
1066
1064
  }
1067
- const g = h.headers.get("X-Query-Type") ?? void 0;
1068
- return this.onChargeSuccess?.(g), h;
1065
+ const g = c.headers.get("X-Query-Type") ?? void 0;
1066
+ return this.onChargeSuccess?.(g), c;
1069
1067
  }
1070
1068
  }
1071
1069
  async function it(i) {
@@ -1095,7 +1093,7 @@ async function at(i) {
1095
1093
  return null;
1096
1094
  }
1097
1095
  }
1098
- const nt = 5e3, rt = 30 * 6e4, k = 60 * 6e4, ot = 5 * 6e4, I = {
1096
+ const nt = 5e3, rt = 30 * 6e4, k = 60 * 6e4, ot = 5 * 6e4, S = {
1099
1097
  has_active_subscription: !1,
1100
1098
  purchases: [],
1101
1099
  trial: null,
@@ -1108,14 +1106,14 @@ function ct(i, t) {
1108
1106
  return i === t ? !0 : !i || !t ? !1 : JSON.stringify(i) === JSON.stringify(t);
1109
1107
  }
1110
1108
  const ht = 5e3, T = 5 * 6e4, lt = 3e4;
1111
- function ut(i, t) {
1109
+ function dt(i, t) {
1112
1110
  if (i === t) return !0;
1113
1111
  if (!i || !t || i.length !== t.length) return !1;
1114
1112
  for (let e = 0; e < i.length; e++)
1115
1113
  if (i[e].type !== t[e].type || i[e].count !== t[e].count) return !1;
1116
1114
  return !0;
1117
1115
  }
1118
- class St {
1116
+ class It {
1119
1117
  constructor(t) {
1120
1118
  if (this.cachedBootstrap = null, this.cachedBootstrapAt = 0, this.inflightBootstrap = null, this.bootstrapListeners = /* @__PURE__ */ new Set(), this.bootstrapStorageUnwatch = null, this.authUnsubscribe = null, this.cachedUser = null, this.cachedUserAt = 0, this.inflightUser = null, this.userListeners = /* @__PURE__ */ new Set(), this.visitorIdPromise = null, this.visitorId = null, this.inflightCheckouts = /* @__PURE__ */ new Map(), this.cachedBalances = null, this.cachedBalancesAt = 0, this.balancesStorageUnwatch = null, this.inflightBalances = null, this.balanceListeners = /* @__PURE__ */ new Set(), this.previewVersionCounter = 0, !t.paywallId)
1121
1119
  throw new o("invalid_config", "paywallId is required");
@@ -1128,7 +1126,7 @@ class St {
1128
1126
  const e = t.auth?.getCachedUser();
1129
1127
  this.identity = t.identity ?? (e ? O(e) : void 0), this.apiKey = t.apiKey, this.fetchImpl = t.fetch, t.apiKey && typeof window < "u" && typeof window.document < "u" && console.error(
1130
1128
  "[paywall] SECURITY: BillingClient.apiKey detected in browser context. This is a server-SDK key and exposes your account. Remove apiKey or move BillingClient to a trusted backend."
1131
- ), this.storage = R(t.storage), this.api = new P({
1129
+ ), this.storage = K(t.storage), this.api = new P({
1132
1130
  apiOrigin: this.apiOrigin,
1133
1131
  paywallId: t.paywallId,
1134
1132
  capabilities: t.capabilities,
@@ -1139,7 +1137,7 @@ class St {
1139
1137
  getAuthToken: t.auth ? () => t.auth.getAccessToken() : void 0
1140
1138
  }), t.auth && (this.authUnsubscribe = t.auth.onAuthChange((s, a) => {
1141
1139
  const n = a ? O(a.user) : void 0;
1142
- dt(this.identity, n) || this.setIdentity(n);
1140
+ ut(this.identity, n) || this.setIdentity(n);
1143
1141
  })), this.hydrateUserFromStorage(), this.hydrateBootstrapFromStorage(), this.subscribeBootstrapStorage(), this.hydrateBalancesFromStorage(), this.subscribeBalancesStorage(), this.visitorIdPromise = B(this.storage).then((s) => (this.visitorId = s, s));
1144
1142
  }
1145
1143
  /**
@@ -1156,7 +1154,7 @@ class St {
1156
1154
  }
1157
1155
  setIdentity(t) {
1158
1156
  this.identity = t, this.cachedUser = null, this.cachedUserAt = 0, this.inflightUser = null, this.cachedBalances = null, this.cachedBalancesAt = 0, this.inflightBalances = null, this.balancesStorageUnwatch && (this.balancesStorageUnwatch(), this.balancesStorageUnwatch = null), this.hydrateBalancesFromStorage(), this.subscribeBalancesStorage(), this.hydrateUserFromStorage(), t ? this.getUser({ force: !0 }).catch(() => {
1159
- }) : (this.applyUser(I), this.applyBalances([]));
1157
+ }) : (this.applyUser(S), this.applyBalances([]));
1160
1158
  }
1161
1159
  /**
1162
1160
  * Отписаться от auth-event'ов и сбросить listener'ы. Вызывать когда
@@ -1354,6 +1352,15 @@ class St {
1354
1352
  getCachedPrices() {
1355
1353
  return this.cachedBootstrap?.prices ?? null;
1356
1354
  }
1355
+ /** Sync-снимок офферов из последнего bootstrap'а. null = bootstrap ещё не
1356
+ * загружали, пустой массив = бэк отдал пейвол без офферов. Бэк уже
1357
+ * применил серверный таргетинг (target_countries / target_emails /
1358
+ * targeting_mode из offer_settings) — наружу выезжает только то, что
1359
+ * применимо к текущему юзеру. Клиентская сторона остаётся ответственной
1360
+ * за price_id-matching и countdown (см. core/offer.ts → resolveOffer). */
1361
+ getCachedOffers() {
1362
+ return this.cachedBootstrap?.offers ?? null;
1363
+ }
1357
1364
  /**
1358
1365
  * Снимок того, какой язык SDK сейчас считает «языком юзера». Полезно для
1359
1366
  * синхронизации i18n хоста с тем, что фактически показывает пейвол — чтобы
@@ -1373,7 +1380,7 @@ class St {
1373
1380
  * есть `navigator.language`.
1374
1381
  */
1375
1382
  getUserLanguage() {
1376
- const t = typeof navigator < "u" && navigator.language ? navigator.language : null, e = this.cachedBootstrap?.settings.locale_default ?? null, s = this.cachedBootstrap ? q(this.cachedBootstrap) : null;
1383
+ const t = typeof navigator < "u" && navigator.language ? navigator.language : null, e = this.cachedBootstrap?.settings.locale_default ?? null, s = this.cachedBootstrap ? M(this.cachedBootstrap) : null;
1377
1384
  return { tag: s ?? t ?? e, applied: s, browserLanguage: t, countryLanguage: e };
1378
1385
  }
1379
1386
  /**
@@ -1388,7 +1395,7 @@ class St {
1388
1395
  return !t && this.cachedUser && Date.now() - this.cachedUserAt < nt ? this.cachedUser : this.inflightUser ? this.inflightUser : (this.inflightUser = (async () => {
1389
1396
  try {
1390
1397
  if (!this.identity?.email)
1391
- return this.applyUser(I), I;
1398
+ return this.applyUser(S), S;
1392
1399
  const s = await this.api.request(
1393
1400
  `/api/v1/paywall/${this.paywallId}/user-state`,
1394
1401
  { headers: { "X-User-Email": this.identity.email }, signal: e }
@@ -1598,7 +1605,7 @@ class St {
1598
1605
  });
1599
1606
  }
1600
1607
  applyBalances(t, { persist: e = !0 } = {}) {
1601
- const s = !ut(this.cachedBalances, t);
1608
+ const s = !dt(this.cachedBalances, t);
1602
1609
  if (this.cachedBalances = t, this.cachedBalancesAt = Date.now(), e && this.persistBalances(t), s)
1603
1610
  for (const a of this.balanceListeners)
1604
1611
  try {
@@ -1662,23 +1669,27 @@ class St {
1662
1669
  const e = t.idempotencyKey ?? `auto:${t.priceId}`, s = this.inflightCheckouts.get(e);
1663
1670
  if (s) return s;
1664
1671
  const n = {
1665
- "Idempotency-Key": t.idempotencyKey ?? D()
1672
+ "Idempotency-Key": t.idempotencyKey ?? R()
1666
1673
  };
1667
1674
  this.apiKey && (n["X-Api-Key"] = this.apiKey);
1668
- const r = this.cachedBootstrap?.settings, l = t.successUrl ?? r?.success_redirect_url ?? void 0, d = t.shopUrl ?? r?.checkout_shop_url ?? void 0, f = this.api.request(`/api/v1/paywall/${this.paywallId}/start-checkout`, {
1675
+ const r = this.cachedBootstrap?.settings, h = t.successUrl ?? r?.success_redirect_url ?? void 0, f = t.shopUrl ?? r?.checkout_shop_url ?? void 0, l = this.cachedBootstrap?.prices.find(
1676
+ (c) => c.id === t.priceId
1677
+ )?.local?.currency ?? void 0, d = this.api.request(`/api/v1/paywall/${this.paywallId}/start-checkout`, {
1669
1678
  method: "POST",
1670
1679
  headers: n,
1671
1680
  signal: t.signal,
1672
1681
  body: JSON.stringify({
1673
1682
  email: this.identity.email,
1674
1683
  priceId: Number(t.priceId),
1675
- successUrl: l,
1684
+ offerId: t.offerId,
1685
+ successUrl: h,
1676
1686
  errorUrl: t.errorUrl,
1677
- shopUrl: d,
1687
+ shopUrl: f,
1678
1688
  productName: r?.checkout_product_name ?? void 0,
1679
1689
  trial_days: t.trialDays,
1680
1690
  ignoreActivePurchase: t.ignoreActivePurchase ? !0 : void 0,
1681
- userMeta: this.identity.userId ? { userId: this.identity.userId } : void 0
1691
+ userMeta: this.identity.userId ? { userId: this.identity.userId } : void 0,
1692
+ localCurrency: l
1682
1693
  })
1683
1694
  }).then((c) => ({ url: c.checkoutUrl, acquiring: c.acquiring })).catch((c) => {
1684
1695
  throw c instanceof o && c.status === 409 && c.cause && typeof c.cause == "object" && c.cause.hasActivePurchase === !0 ? new o(
@@ -1687,10 +1698,10 @@ class St {
1687
1698
  { status: 409, cause: c.cause }
1688
1699
  ) : c;
1689
1700
  });
1690
- return this.inflightCheckouts.set(e, f), f.finally(() => {
1691
- this.inflightCheckouts.get(e) === f && this.inflightCheckouts.delete(e);
1701
+ return this.inflightCheckouts.set(e, d), d.finally(() => {
1702
+ this.inflightCheckouts.get(e) === d && this.inflightCheckouts.delete(e);
1692
1703
  }).catch(() => {
1693
- }), f;
1704
+ }), d;
1694
1705
  }
1695
1706
  /**
1696
1707
  * URL Stripe/Paddle/Chargebee customer portal — место, где залогиненный
@@ -1698,7 +1709,9 @@ class St {
1698
1709
  * инвойсы). Опен-флоу управляется host'ом:
1699
1710
  *
1700
1711
  * ```ts
1701
- * const { url } = await billing.getCustomerPortalUrl();
1712
+ * const { url } = await billing.getCustomerPortalUrl({
1713
+ * returnUrl: 'https://your-app.com/account'
1714
+ * });
1702
1715
  * window.open(url, '_blank');
1703
1716
  * ```
1704
1717
  *
@@ -1716,9 +1729,10 @@ class St {
1716
1729
  );
1717
1730
  const e = {};
1718
1731
  this.apiKey && (e["X-Api-Key"] = this.apiKey);
1719
- const s = this.auth && this.auth.getCachedSession() ? {} : {
1732
+ const s = this.auth && this.auth.getCachedSession() ? { returnUrl: t.returnUrl } : {
1720
1733
  email: this.identity?.email,
1721
- userMeta: this.identity?.userId ? { userId: this.identity.userId } : void 0
1734
+ userMeta: this.identity?.userId ? { userId: this.identity.userId } : void 0,
1735
+ returnUrl: t.returnUrl
1722
1736
  };
1723
1737
  return { url: (await this.api.request(
1724
1738
  `/api/v1/paywall/${this.paywallId}/get-customer-portal`,
@@ -1737,43 +1751,65 @@ class St {
1737
1751
  * `/api/v1/paywall/[id]/user` без unstable_cache, потому что list для UI
1738
1752
  * должен быть свежим после cancel-а.
1739
1753
  *
1740
- * Auth: Bearer обязателен (через AuthClient). Без Bearer — 401 от бэка,
1741
- * пробрасываем как PaywallError('http_401'). Гость пустой список.
1754
+ * Auth (два пути):
1755
+ * - Bearer (через AuthClient) — user.id резолвится из сессии, identity
1756
+ * в query игнорируется.
1757
+ * - `apiKey` + `identity.email`/`identity.userId` — server-SDK путь для
1758
+ * интеграций со своей авторизацией. Бэк проверяет, что identity линкована
1759
+ * к этому пейволу (защита от cross-paywall lookup).
1760
+ * Без auth и без apiKey+identity — `identity_required`.
1742
1761
  */
1743
1762
  async listPurchases(t = {}) {
1744
- if (!this.auth)
1763
+ const e = !!(this.identity?.email || this.identity?.userId);
1764
+ if (!this.auth && !(this.apiKey && e))
1745
1765
  throw new o(
1746
- "auth_required",
1747
- "listPurchases requires AuthClient (Bearer auth)"
1766
+ "identity_required",
1767
+ "listPurchases requires AuthClient (Bearer) or apiKey + identity.email/userId"
1748
1768
  );
1749
- return (await this.api.request(`/api/v1/paywall/${this.paywallId}/user`, {
1769
+ const s = {};
1770
+ this.apiKey && (s["X-Api-Key"] = this.apiKey);
1771
+ const a = new URLSearchParams();
1772
+ this.apiKey && this.identity?.email && a.set("email", this.identity.email), this.apiKey && this.identity?.userId && a.set("user_id", this.identity.userId);
1773
+ const n = a.toString(), r = n ? `/api/v1/paywall/${this.paywallId}/user?${n}` : `/api/v1/paywall/${this.paywallId}/user`;
1774
+ return (await this.api.request(r, {
1750
1775
  method: "GET",
1776
+ headers: s,
1751
1777
  signal: t.signal
1752
1778
  })).purchases ?? [];
1753
1779
  }
1754
1780
  /**
1755
- * Отменить подписку. Бэк проверит что subscription принадлежит auth-юзеру
1756
- * и сделает cancel у acquiring'а (Stripe/Paddle/Chargebee). По умолчанию
1757
- * cancel в конце текущего периода — юзер сохраняет access до renewal date'ы.
1781
+ * Отменить подписку. Бэк проверит, что subscription принадлежит юзеру
1782
+ * (Bearer-путь из сессии; apiKey-путь — из identity), и сделает cancel у
1783
+ * acquiring'а (Stripe/Paddle/Chargebee/Overpay). По умолчанию cancel в
1784
+ * конце текущего периода — юзер сохраняет access до renewal date'ы.
1758
1785
  *
1759
- * `reason` обязательна (валидация на бэке). Удобно собрать через select
1760
- * причин в host-UI, как в legacy customer portal'е.
1786
+ * `reason` обязательна (валидация на бэке).
1761
1787
  *
1762
- * Auth: Bearer обязателен.
1788
+ * Auth (два пути):
1789
+ * - Bearer (через AuthClient) — стандартный путь для UI customer-portal'a.
1790
+ * - `apiKey` + `identity.email`/`identity.userId` — для self-service UI на
1791
+ * бэке клиента со своей авторизацией. Бэк дополнительно фильтрует
1792
+ * subscription по paywall_id, чтобы owner пейвола A не отменил подписку
1793
+ * пейвола B.
1763
1794
  */
1764
1795
  async cancelSubscription(t) {
1765
- if (!this.auth)
1796
+ const e = !!(this.identity?.email || this.identity?.userId);
1797
+ if (!this.auth && !(this.apiKey && e))
1766
1798
  throw new o(
1767
- "auth_required",
1768
- "cancelSubscription requires AuthClient (Bearer auth)"
1799
+ "identity_required",
1800
+ "cancelSubscription requires AuthClient (Bearer) or apiKey + identity.email/userId"
1769
1801
  );
1770
- return this.api.request("/api/paywall/cancel-subscription", {
1802
+ const s = {};
1803
+ this.apiKey && (s["X-Api-Key"] = this.apiKey);
1804
+ const a = {
1805
+ subscriptionId: t.subscriptionId,
1806
+ paywallId: this.paywallId,
1807
+ cancellationReason: t.reason
1808
+ };
1809
+ return this.apiKey && this.identity?.email && (a.email = this.identity.email), this.apiKey && this.identity?.userId && (a.userId = this.identity.userId), this.api.request("/api/paywall/cancel-subscription", {
1771
1810
  method: "POST",
1772
- body: JSON.stringify({
1773
- subscriptionId: t.subscriptionId,
1774
- paywallId: this.paywallId,
1775
- cancellationReason: t.reason
1776
- }),
1811
+ headers: s,
1812
+ body: JSON.stringify(a),
1777
1813
  signal: t.signal
1778
1814
  });
1779
1815
  }
@@ -1809,7 +1845,7 @@ class St {
1809
1845
  function O(i) {
1810
1846
  return { email: i.email, userId: i.id };
1811
1847
  }
1812
- function dt(i, t) {
1848
+ function ut(i, t) {
1813
1849
  return i === t ? !0 : !i || !t ? !1 : i.email === t.email && i.userId === t.userId && i.anonymousId === t.anonymousId;
1814
1850
  }
1815
1851
  function U(i) {
@@ -1845,7 +1881,7 @@ function E(i, t) {
1845
1881
  ]
1846
1882
  };
1847
1883
  }
1848
- function q(i) {
1884
+ function M(i) {
1849
1885
  const t = i.locales;
1850
1886
  if (!t) return null;
1851
1887
  const e = [];
@@ -1861,7 +1897,7 @@ function q(i) {
1861
1897
  return null;
1862
1898
  }
1863
1899
  function w(i) {
1864
- const t = q(i);
1900
+ const t = M(i);
1865
1901
  if (!t) return;
1866
1902
  const e = i.locales?.[t];
1867
1903
  e && (e.layout && (i.layout = e.layout), e.prices && (i.prices = i.prices.map((s) => {
@@ -1872,7 +1908,7 @@ function w(i) {
1872
1908
  })));
1873
1909
  }
1874
1910
  const yt = 1500, pt = 20, L = 200;
1875
- class It {
1911
+ class St {
1876
1912
  constructor(t) {
1877
1913
  this.buffer = [], this.flushTimer = null, this.destroyed = !1, this.unloadHandler = null, this.visibilityHandler = null, this.opts = t, this.isEnabled() && this.attachUnloadHandlers();
1878
1914
  }
@@ -1977,7 +2013,7 @@ function v(i) {
1977
2013
  function b(i) {
1978
2014
  return `paywall-${i}-skip-times`;
1979
2015
  }
1980
- class K {
2016
+ class q {
1981
2017
  constructor(t, e, s) {
1982
2018
  this.storage = t, this.paywallId = e, this.config = s;
1983
2019
  }
@@ -2037,11 +2073,11 @@ class K {
2037
2073
  async recordOpens() {
2038
2074
  const t = this.config.payload, e = b(this.paywallId), s = await this.storage.getItem(e), a = s ? Number(s) : 0, n = Number.isFinite(a) ? a : 0, r = Math.min(t, n + 1);
2039
2075
  await this.storage.setItem(e, String(r));
2040
- const l = Math.max(0, t - r);
2076
+ const h = Math.max(0, t - r);
2041
2077
  return {
2042
2078
  mode: "opens",
2043
2079
  blocked: r < t,
2044
- remainingActions: l,
2080
+ remainingActions: h,
2045
2081
  totalActions: t
2046
2082
  };
2047
2083
  }
@@ -2051,7 +2087,7 @@ class gt {
2051
2087
  constructor(t, e, s) {
2052
2088
  N || (N = !0, console.warn(
2053
2089
  '[paywall] trial.storage="server" is not implemented yet — falling back to client storage. State lives in localStorage; users can reset trial by clearing site data.'
2054
- )), this.fallback = new K(t, e, s);
2090
+ )), this.fallback = new q(t, e, s);
2055
2091
  }
2056
2092
  check() {
2057
2093
  return this.fallback.check();
@@ -2064,7 +2100,7 @@ class gt {
2064
2100
  }
2065
2101
  }
2066
2102
  function vt(i, t, e) {
2067
- return e.storage === "server" ? new gt(i, t, e) : new K(i, t, e);
2103
+ return e.storage === "server" ? new gt(i, t, e) : new q(i, t, e);
2068
2104
  }
2069
2105
  const bt = 1;
2070
2106
  function _t(i) {
@@ -2096,7 +2132,7 @@ function Bt(i) {
2096
2132
  function wt(i) {
2097
2133
  let t = !1;
2098
2134
  const e = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), a = (r) => {
2099
- for (const l of e) l(r);
2135
+ for (const h of e) h(r);
2100
2136
  }, n = () => {
2101
2137
  if (!t) {
2102
2138
  t = !0;
@@ -2109,8 +2145,8 @@ function wt(i) {
2109
2145
  if (!t)
2110
2146
  try {
2111
2147
  i.postMessage(r);
2112
- } catch (l) {
2113
- throw n(), l;
2148
+ } catch (h) {
2149
+ throw n(), h;
2114
2150
  }
2115
2151
  },
2116
2152
  onMessage(r) {
@@ -2131,8 +2167,8 @@ function kt(i) {
2131
2167
  }
2132
2168
  export {
2133
2169
  mt as A,
2134
- St as B,
2135
- It as E,
2170
+ It as B,
2171
+ St as E,
2136
2172
  o as P,
2137
2173
  bt as a,
2138
2174
  kt as b,
@@ -2142,4 +2178,4 @@ export {
2142
2178
  _t as s,
2143
2179
  Z as w
2144
2180
  };
2145
- //# sourceMappingURL=chrome-port-rVd4zwU3.js.map
2181
+ //# sourceMappingURL=chrome-port-bfTUUDz_.js.map