@tiun/react-native-sdk 0.3.0 → 0.5.0-staging.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.
package/dist/index.mjs CHANGED
@@ -1,13 +1,13 @@
1
- var Ne = Object.defineProperty;
2
- var Ce = (r, t, a) => t in r ? Ne(r, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : r[t] = a;
3
- var Te = (r, t, a) => (Ce(r, typeof t != "symbol" ? t + "" : t, a), a);
4
- import Ie, { forwardRef as Oe, useRef as P, useState as z, useEffect as oe, useImperativeHandle as Pe, createContext as ve, useCallback as K, useMemo as xe, useContext as _e } from "react";
5
- import { StyleSheet as ie, View as ne, Text as te, Pressable as Ae, useColorScheme as Ue, AppState as je, useWindowDimensions as $e, Platform as Fe, Linking as Ee } from "react-native";
6
- import { WebView as Le } from "react-native-webview";
7
- import { close as We, closeAuth as Ve, openAuth as Ye, open as be } from "react-native-inappbrowser-nitro";
8
- import { getPublicKey as me, generate as Be, sign as Ge, removeKey as He } from "react-native-secure-sign";
9
- import * as ae from "react-native-keychain";
10
- var de = { exports: {} }, X = {};
1
+ var Ce = Object.defineProperty;
2
+ var Ie = (n, r, a) => r in n ? Ce(n, r, { enumerable: !0, configurable: !0, writable: !0, value: a }) : n[r] = a;
3
+ var he = (n, r, a) => (Ie(n, typeof r != "symbol" ? r + "" : r, a), a);
4
+ import Ne, { forwardRef as Oe, useRef as C, useState as X, useEffect as ne, useImperativeHandle as Ae, createContext as me, useCallback as P, useMemo as xe, useContext as ve } from "react";
5
+ import { StyleSheet as ce, View as ae, Text as oe, Pressable as Ue, useColorScheme as je, AppState as $e, useWindowDimensions as Le, Platform as Fe, Linking as Ee } from "react-native";
6
+ import { WebView as We } from "react-native-webview";
7
+ import { close as qe, closeAuth as De, openAuth as Ve, open as be } from "react-native-inappbrowser-nitro";
8
+ import { getPublicKey as Se, generate as Ye, sign as Ge, removeKey as He } from "react-native-secure-sign";
9
+ import * as se from "react-native-keychain";
10
+ var de = { exports: {} }, Z = {};
11
11
  /**
12
12
  * @license React
13
13
  * react-jsx-runtime.production.js
@@ -17,31 +17,31 @@ var de = { exports: {} }, X = {};
17
17
  * This source code is licensed under the MIT license found in the
18
18
  * LICENSE file in the root directory of this source tree.
19
19
  */
20
- var ye;
21
- function De() {
22
- if (ye)
23
- return X;
24
- ye = 1;
25
- var r = Symbol.for("react.transitional.element"), t = Symbol.for("react.fragment");
26
- function a(l, o, u) {
27
- var d = null;
28
- if (u !== void 0 && (d = "" + u), o.key !== void 0 && (d = "" + o.key), "key" in o) {
29
- u = {};
30
- for (var h in o)
31
- h !== "key" && (u[h] = o[h]);
20
+ var _e;
21
+ function Be() {
22
+ if (_e)
23
+ return Z;
24
+ _e = 1;
25
+ var n = Symbol.for("react.transitional.element"), r = Symbol.for("react.fragment");
26
+ function a(u, o, h) {
27
+ var y = null;
28
+ if (h !== void 0 && (y = "" + h), o.key !== void 0 && (y = "" + o.key), "key" in o) {
29
+ h = {};
30
+ for (var p in o)
31
+ p !== "key" && (h[p] = o[p]);
32
32
  } else
33
- u = o;
34
- return o = u.ref, {
35
- $$typeof: r,
36
- type: l,
37
- key: d,
33
+ h = o;
34
+ return o = h.ref, {
35
+ $$typeof: n,
36
+ type: u,
37
+ key: y,
38
38
  ref: o !== void 0 ? o : null,
39
- props: u
39
+ props: h
40
40
  };
41
41
  }
42
- return X.Fragment = t, X.jsx = a, X.jsxs = a, X;
42
+ return Z.Fragment = r, Z.jsx = a, Z.jsxs = a, Z;
43
43
  }
44
- var Q = {};
44
+ var ee = {};
45
45
  /**
46
46
  * @license React
47
47
  * react-jsx-runtime.development.js
@@ -51,248 +51,248 @@ var Q = {};
51
51
  * This source code is licensed under the MIT license found in the
52
52
  * LICENSE file in the root directory of this source tree.
53
53
  */
54
- var we;
54
+ var ye;
55
55
  function Ke() {
56
- return we || (we = 1, process.env.NODE_ENV !== "production" && function() {
57
- function r(e) {
58
- if (e == null)
56
+ return ye || (ye = 1, process.env.NODE_ENV !== "production" && function() {
57
+ function n(t) {
58
+ if (t == null)
59
59
  return null;
60
- if (typeof e == "function")
61
- return e.$$typeof === _ ? null : e.displayName || e.name || null;
62
- if (typeof e == "string")
63
- return e;
64
- switch (e) {
65
- case E:
60
+ if (typeof t == "function")
61
+ return t.$$typeof === B ? null : t.displayName || t.name || null;
62
+ if (typeof t == "string")
63
+ return t;
64
+ switch (t) {
65
+ case L:
66
66
  return "Fragment";
67
- case V:
67
+ case D:
68
68
  return "Profiler";
69
- case k:
69
+ case b:
70
70
  return "StrictMode";
71
- case H:
71
+ case F:
72
72
  return "Suspense";
73
- case s:
73
+ case R:
74
74
  return "SuspenseList";
75
- case I:
75
+ case H:
76
76
  return "Activity";
77
77
  }
78
- if (typeof e == "object")
79
- switch (typeof e.tag == "number" && console.error(
78
+ if (typeof t == "object")
79
+ switch (typeof t.tag == "number" && console.error(
80
80
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
81
- ), e.$$typeof) {
82
- case M:
81
+ ), t.$$typeof) {
82
+ case q:
83
83
  return "Portal";
84
- case B:
85
- return (e.displayName || "Context") + ".Provider";
86
- case U:
87
- return (e._context.displayName || "Context") + ".Consumer";
84
+ case V:
85
+ return (t.displayName || "Context") + ".Provider";
86
+ case A:
87
+ return (t._context.displayName || "Context") + ".Consumer";
88
+ case Y:
89
+ var c = t.render;
90
+ return t = t.displayName, t || (t = c.displayName || c.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
88
91
  case G:
89
- var c = e.render;
90
- return e = e.displayName, e || (e = c.displayName || c.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
91
- case v:
92
- return c = e.displayName || null, c !== null ? c : r(e.type) || "Memo";
93
- case b:
94
- c = e._payload, e = e._init;
92
+ return c = t.displayName || null, c !== null ? c : n(t.type) || "Memo";
93
+ case W:
94
+ c = t._payload, t = t._init;
95
95
  try {
96
- return r(e(c));
96
+ return n(t(c));
97
97
  } catch {
98
98
  }
99
99
  }
100
100
  return null;
101
101
  }
102
- function t(e) {
103
- return "" + e;
102
+ function r(t) {
103
+ return "" + t;
104
104
  }
105
- function a(e) {
105
+ function a(t) {
106
106
  try {
107
- t(e);
107
+ r(t);
108
108
  var c = !1;
109
109
  } catch {
110
110
  c = !0;
111
111
  }
112
112
  if (c) {
113
113
  c = console;
114
- var f = c.error, y = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
115
- return f.call(
114
+ var T = c.error, w = typeof Symbol == "function" && Symbol.toStringTag && t[Symbol.toStringTag] || t.constructor.name || "Object";
115
+ return T.call(
116
116
  c,
117
117
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
118
- y
119
- ), t(e);
118
+ w
119
+ ), r(t);
120
120
  }
121
121
  }
122
- function l(e) {
123
- if (e === E)
122
+ function u(t) {
123
+ if (t === L)
124
124
  return "<>";
125
- if (typeof e == "object" && e !== null && e.$$typeof === b)
125
+ if (typeof t == "object" && t !== null && t.$$typeof === W)
126
126
  return "<...>";
127
127
  try {
128
- var c = r(e);
128
+ var c = n(t);
129
129
  return c ? "<" + c + ">" : "<...>";
130
130
  } catch {
131
131
  return "<...>";
132
132
  }
133
133
  }
134
134
  function o() {
135
- var e = i.A;
136
- return e === null ? null : e.getOwner();
135
+ var t = i.A;
136
+ return t === null ? null : t.getOwner();
137
137
  }
138
- function u() {
138
+ function h() {
139
139
  return Error("react-stack-top-frame");
140
140
  }
141
- function d(e) {
142
- if (n.call(e, "key")) {
143
- var c = Object.getOwnPropertyDescriptor(e, "key").get;
141
+ function y(t) {
142
+ if (e.call(t, "key")) {
143
+ var c = Object.getOwnPropertyDescriptor(t, "key").get;
144
144
  if (c && c.isReactWarning)
145
145
  return !1;
146
146
  }
147
- return e.key !== void 0;
147
+ return t.key !== void 0;
148
148
  }
149
- function h(e, c) {
150
- function f() {
151
- p || (p = !0, console.error(
149
+ function p(t, c) {
150
+ function T() {
151
+ l || (l = !0, console.error(
152
152
  "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
153
153
  c
154
154
  ));
155
155
  }
156
- f.isReactWarning = !0, Object.defineProperty(e, "key", {
157
- get: f,
156
+ T.isReactWarning = !0, Object.defineProperty(t, "key", {
157
+ get: T,
158
158
  configurable: !0
159
159
  });
160
160
  }
161
- function W() {
162
- var e = r(this.type);
163
- return g[e] || (g[e] = !0, console.error(
161
+ function U() {
162
+ var t = n(this.type);
163
+ return E[t] || (E[t] = !0, console.error(
164
164
  "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
165
- )), e = this.props.ref, e !== void 0 ? e : null;
165
+ )), t = this.props.ref, t !== void 0 ? t : null;
166
166
  }
167
- function x(e, c, f, y, L, O, ce, se) {
168
- return f = O.ref, e = {
169
- $$typeof: A,
170
- type: e,
167
+ function j(t, c, T, w, k, g, K, J) {
168
+ return T = g.ref, t = {
169
+ $$typeof: $,
170
+ type: t,
171
171
  key: c,
172
- props: O,
173
- _owner: L
174
- }, (f !== void 0 ? f : null) !== null ? Object.defineProperty(e, "ref", {
172
+ props: g,
173
+ _owner: k
174
+ }, (T !== void 0 ? T : null) !== null ? Object.defineProperty(t, "ref", {
175
175
  enumerable: !1,
176
- get: W
177
- }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
176
+ get: U
177
+ }) : Object.defineProperty(t, "ref", { enumerable: !1, value: null }), t._store = {}, Object.defineProperty(t._store, "validated", {
178
178
  configurable: !1,
179
179
  enumerable: !1,
180
180
  writable: !0,
181
181
  value: 0
182
- }), Object.defineProperty(e, "_debugInfo", {
182
+ }), Object.defineProperty(t, "_debugInfo", {
183
183
  configurable: !1,
184
184
  enumerable: !1,
185
185
  writable: !0,
186
186
  value: null
187
- }), Object.defineProperty(e, "_debugStack", {
187
+ }), Object.defineProperty(t, "_debugStack", {
188
188
  configurable: !1,
189
189
  enumerable: !1,
190
190
  writable: !0,
191
- value: ce
192
- }), Object.defineProperty(e, "_debugTask", {
191
+ value: K
192
+ }), Object.defineProperty(t, "_debugTask", {
193
193
  configurable: !1,
194
194
  enumerable: !1,
195
195
  writable: !0,
196
- value: se
197
- }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
196
+ value: J
197
+ }), Object.freeze && (Object.freeze(t.props), Object.freeze(t)), t;
198
198
  }
199
- function F(e, c, f, y, L, O, ce, se) {
200
- var w = c.children;
201
- if (w !== void 0)
202
- if (y)
203
- if (T(w)) {
204
- for (y = 0; y < w.length; y++)
205
- C(w[y]);
206
- Object.freeze && Object.freeze(w);
199
+ function O(t, c, T, w, k, g, K, J) {
200
+ var f = c.children;
201
+ if (f !== void 0)
202
+ if (w)
203
+ if (s(f)) {
204
+ for (w = 0; w < f.length; w++)
205
+ I(f[w]);
206
+ Object.freeze && Object.freeze(f);
207
207
  } else
208
208
  console.error(
209
209
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
210
210
  );
211
211
  else
212
- C(w);
213
- if (n.call(c, "key")) {
214
- w = r(e);
215
- var D = Object.keys(c).filter(function(ge) {
216
- return ge !== "key";
212
+ I(f);
213
+ if (e.call(c, "key")) {
214
+ f = n(t);
215
+ var _ = Object.keys(c).filter(function(Pe) {
216
+ return Pe !== "key";
217
217
  });
218
- y = 0 < D.length ? "{key: someKey, " + D.join(": ..., ") + ": ...}" : "{key: someKey}", j[w + y] || (D = 0 < D.length ? "{" + D.join(": ..., ") + ": ...}" : "{}", console.error(
218
+ w = 0 < _.length ? "{key: someKey, " + _.join(": ..., ") + ": ...}" : "{key: someKey}", Q[f + w] || (_ = 0 < _.length ? "{" + _.join(": ..., ") + ": ...}" : "{}", console.error(
219
219
  `A props object containing a "key" prop is being spread into JSX:
220
220
  let props = %s;
221
221
  <%s {...props} />
222
222
  React keys must be passed directly to JSX without using spread:
223
223
  let props = %s;
224
224
  <%s key={someKey} {...props} />`,
225
- y,
226
225
  w,
227
- D,
228
- w
229
- ), j[w + y] = !0);
226
+ f,
227
+ _,
228
+ f
229
+ ), Q[f + w] = !0);
230
230
  }
231
- if (w = null, f !== void 0 && (a(f), w = "" + f), d(c) && (a(c.key), w = "" + c.key), "key" in c) {
232
- f = {};
233
- for (var le in c)
234
- le !== "key" && (f[le] = c[le]);
231
+ if (f = null, T !== void 0 && (a(T), f = "" + T), y(c) && (a(c.key), f = "" + c.key), "key" in c) {
232
+ T = {};
233
+ for (var ue in c)
234
+ ue !== "key" && (T[ue] = c[ue]);
235
235
  } else
236
- f = c;
237
- return w && h(
236
+ T = c;
237
+ return f && p(
238
+ T,
239
+ typeof t == "function" ? t.displayName || t.name || "Unknown" : t
240
+ ), j(
241
+ t,
238
242
  f,
239
- typeof e == "function" ? e.displayName || e.name || "Unknown" : e
240
- ), x(
241
- e,
242
- w,
243
- O,
244
- L,
243
+ g,
244
+ k,
245
245
  o(),
246
- f,
247
- ce,
248
- se
246
+ T,
247
+ K,
248
+ J
249
249
  );
250
250
  }
251
- function C(e) {
252
- typeof e == "object" && e !== null && e.$$typeof === A && e._store && (e._store.validated = 1);
251
+ function I(t) {
252
+ typeof t == "object" && t !== null && t.$$typeof === $ && t._store && (t._store.validated = 1);
253
253
  }
254
- var R = Ie, A = Symbol.for("react.transitional.element"), M = Symbol.for("react.portal"), E = Symbol.for("react.fragment"), k = Symbol.for("react.strict_mode"), V = Symbol.for("react.profiler"), U = Symbol.for("react.consumer"), B = Symbol.for("react.context"), G = Symbol.for("react.forward_ref"), H = Symbol.for("react.suspense"), s = Symbol.for("react.suspense_list"), v = Symbol.for("react.memo"), b = Symbol.for("react.lazy"), I = Symbol.for("react.activity"), _ = Symbol.for("react.client.reference"), i = R.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, n = Object.prototype.hasOwnProperty, T = Array.isArray, m = console.createTask ? console.createTask : function() {
254
+ var S = Ne, $ = Symbol.for("react.transitional.element"), q = Symbol.for("react.portal"), L = Symbol.for("react.fragment"), b = Symbol.for("react.strict_mode"), D = Symbol.for("react.profiler"), A = Symbol.for("react.consumer"), V = Symbol.for("react.context"), Y = Symbol.for("react.forward_ref"), F = Symbol.for("react.suspense"), R = Symbol.for("react.suspense_list"), G = Symbol.for("react.memo"), W = Symbol.for("react.lazy"), H = Symbol.for("react.activity"), B = Symbol.for("react.client.reference"), i = S.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, e = Object.prototype.hasOwnProperty, s = Array.isArray, d = console.createTask ? console.createTask : function() {
255
255
  return null;
256
256
  };
257
- R = {
258
- "react-stack-bottom-frame": function(e) {
259
- return e();
257
+ S = {
258
+ "react-stack-bottom-frame": function(t) {
259
+ return t();
260
260
  }
261
261
  };
262
- var p, g = {}, N = R["react-stack-bottom-frame"].bind(
263
- R,
264
- u
265
- )(), Y = m(l(u)), j = {};
266
- Q.Fragment = E, Q.jsx = function(e, c, f, y, L) {
267
- var O = 1e4 > i.recentlyCreatedOwnerStacks++;
268
- return F(
269
- e,
262
+ var l, E = {}, m = S["react-stack-bottom-frame"].bind(
263
+ S,
264
+ h
265
+ )(), N = d(u(h)), Q = {};
266
+ ee.Fragment = L, ee.jsx = function(t, c, T, w, k) {
267
+ var g = 1e4 > i.recentlyCreatedOwnerStacks++;
268
+ return O(
269
+ t,
270
270
  c,
271
- f,
271
+ T,
272
272
  !1,
273
- y,
274
- L,
275
- O ? Error("react-stack-top-frame") : N,
276
- O ? m(l(e)) : Y
273
+ w,
274
+ k,
275
+ g ? Error("react-stack-top-frame") : m,
276
+ g ? d(u(t)) : N
277
277
  );
278
- }, Q.jsxs = function(e, c, f, y, L) {
279
- var O = 1e4 > i.recentlyCreatedOwnerStacks++;
280
- return F(
281
- e,
278
+ }, ee.jsxs = function(t, c, T, w, k) {
279
+ var g = 1e4 > i.recentlyCreatedOwnerStacks++;
280
+ return O(
281
+ t,
282
282
  c,
283
- f,
283
+ T,
284
284
  !0,
285
- y,
286
- L,
287
- O ? Error("react-stack-top-frame") : N,
288
- O ? m(l(e)) : Y
285
+ w,
286
+ k,
287
+ g ? Error("react-stack-top-frame") : m,
288
+ g ? d(u(t)) : N
289
289
  );
290
290
  };
291
- }()), Q;
291
+ }()), ee;
292
292
  }
293
- process.env.NODE_ENV === "production" ? de.exports = De() : de.exports = Ke();
294
- var S = de.exports;
295
- const qe = {
293
+ process.env.NODE_ENV === "production" ? de.exports = Be() : de.exports = Ke();
294
+ var v = de.exports;
295
+ const Je = {
296
296
  errorPillText: "Technical Error",
297
297
  errorNotificationTitle: "Technical error",
298
298
  errorNotificationSubtitle: "Please reload the page or contact our support.",
@@ -302,7 +302,7 @@ const qe = {
302
302
  connectionErrorTitle: "No connection",
303
303
  connectionErrorText: "We couldn’t reach tiun. Check your internet connection and try again.",
304
304
  connectionErrorCta: "Try again"
305
- }, Je = {
305
+ }, Me = {
306
306
  errorPillText: "Erreur Technique",
307
307
  errorNotificationTitle: "Erreur technique",
308
308
  errorNotificationSubtitle: "Veuillez recharger la page ou contacter notre support.",
@@ -322,7 +322,7 @@ const qe = {
322
322
  connectionErrorTitle: "Keine Verbindung",
323
323
  connectionErrorText: "tiun konnte nicht erreicht werden. Überprüfe deine Internetverbindung und versuche es erneut.",
324
324
  connectionErrorCta: "Erneut versuchen"
325
- }, Me = {
325
+ }, Xe = {
326
326
  errorPillText: "Technischer Fehler",
327
327
  errorNotificationTitle: "Technischer Fehler",
328
328
  errorNotificationSubtitle: "Bitte laden Sie die Seite neu, oder kontaktieren Sie unseren Support.",
@@ -333,17 +333,17 @@ const qe = {
333
333
  connectionErrorText: "tiun konnte nicht erreicht werden. Überprüfen Sie Ihre Internetverbindung und versuchen Sie es erneut.",
334
334
  connectionErrorCta: "Erneut versuchen"
335
335
  };
336
- function Xe(r, t = "informal") {
337
- switch ((r ?? "en").trim().toLowerCase()) {
336
+ function Qe(n, r = "informal") {
337
+ switch ((n ?? "en").trim().toLowerCase()) {
338
338
  case "de":
339
- return t === "formal" ? Me : ze;
339
+ return r === "formal" ? Xe : ze;
340
340
  case "fr":
341
- return Je;
341
+ return Me;
342
342
  default:
343
- return qe;
343
+ return Je;
344
344
  }
345
345
  }
346
- const q = {
346
+ const M = {
347
347
  // Web protocol (TIUN_EVENT) — consumer → snippet commands.
348
348
  start: "TIUN_START",
349
349
  checkout: "TIUN_CHECKOUT",
@@ -352,6 +352,12 @@ const q = {
352
352
  logout: "TIUN_LOGOUT",
353
353
  getVerificationToken: "TIUN_GET_VERIFICATION_TOKEN",
354
354
  setAppearance: "TIUN_SET_APPEARANCE",
355
+ listProducts: "TIUN_LIST_PRODUCTS",
356
+ getProduct: "TIUN_GET_PRODUCT",
357
+ listProductAccess: "TIUN_LIST_PRODUCT_ACCESS",
358
+ checkProductAccess: "TIUN_CHECK_PRODUCT_ACCESS",
359
+ // Web protocol (TIUN_EVENT) — snippet → consumer responses.
360
+ productResult: "TIUN_PRODUCT_RESULT",
355
361
  // Overlay (TIUN_OVERLAY) — snippet → native footprint signal.
356
362
  overlayChange: "TIUN_OVERLAY_CHANGE",
357
363
  // Native device bridge (TIUN_NATIVE) — snippet → native requests.
@@ -365,121 +371,121 @@ const q = {
365
371
  restoreToken: "TIUN_RESTORE_TOKEN",
366
372
  popSignResult: "TIUN_POP_SIGN_RESULT",
367
373
  resolveCheckout: "TIUN_RESOLVE_CHECKOUT"
368
- }, Qe = "__TIUN_NATIVE_CRYPTO__", Ze = "https://api.tiun.live";
369
- function fe(r) {
370
- return (r.host ?? Ze).replace(/\/$/, "");
374
+ }, Ze = "__TIUN_NATIVE_CRYPTO__", et = "https://api.tiun.live";
375
+ function fe(n) {
376
+ return (n.host ?? et).replace(/\/$/, "");
371
377
  }
372
- function re(r) {
373
- return `app.tiun.pop.${r.snippetId || "default"}`;
378
+ function ie(n) {
379
+ return `app.tiun.pop.${n.snippetId || "default"}`;
374
380
  }
375
- function Z(r) {
376
- return `app.tiun.token.${r.snippetId || "default"}`;
381
+ function te(n) {
382
+ return `app.tiun.token.${n.snippetId || "default"}`;
377
383
  }
378
- function et(r) {
379
- return `${`${fe(r)}/live_api/v2/snippets/${encodeURIComponent(r.snippetId)}/webview_return`}?to=${encodeURIComponent(r.returnUrl)}`;
384
+ function tt(n) {
385
+ return `${`${fe(n)}/live_api/v2/snippets/${encodeURIComponent(n.snippetId)}/webview_return`}?to=${encodeURIComponent(n.returnUrl)}`;
380
386
  }
381
- function tt(r) {
382
- const t = {
383
- language: r.language ?? "en"
384
- }, a = Object.entries(t).map(([o, u]) => `${encodeURIComponent(o)}=${encodeURIComponent(u)}`).join("&"), l = `${fe(r)}/live_api/v2/snippets/${encodeURIComponent(r.snippetId)}/webview_host`;
385
- return a ? `${l}?${a}` : l;
387
+ function rt(n) {
388
+ const r = {
389
+ language: n.language ?? "en"
390
+ }, a = Object.entries(r).map(([o, h]) => `${encodeURIComponent(o)}=${encodeURIComponent(h)}`).join("&"), u = `${fe(n)}/live_api/v2/snippets/${encodeURIComponent(n.snippetId)}/webview_host`;
391
+ return a ? `${u}?${a}` : u;
386
392
  }
387
- function Se(r) {
388
- const t = r.indexOf("?");
389
- if (!(t < 0))
390
- for (const a of r.slice(t + 1).split("&")) {
391
- const l = a.indexOf("=");
392
- if ((l < 0 ? a : a.slice(0, l)) === "status") {
393
- const u = l < 0 ? "" : a.slice(l + 1);
394
- return u ? decodeURIComponent(u) : void 0;
393
+ function Re(n) {
394
+ const r = n.indexOf("?");
395
+ if (!(r < 0))
396
+ for (const a of n.slice(r + 1).split("&")) {
397
+ const u = a.indexOf("=");
398
+ if ((u < 0 ? a : a.slice(0, u)) === "status") {
399
+ const h = u < 0 ? "" : a.slice(u + 1);
400
+ return h ? decodeURIComponent(h) : void 0;
395
401
  }
396
402
  }
397
403
  }
398
- function rt(r, t) {
399
- const a = r.returnUrl.split("?")[0];
400
- return t.startsWith(a);
404
+ function nt(n, r) {
405
+ const a = n.returnUrl.split("?")[0];
406
+ return r.startsWith(a);
401
407
  }
402
408
  const pe = "1005";
403
- function he(r) {
404
- return r == null ? void 0 : r.code;
409
+ function Te(n) {
410
+ return n == null ? void 0 : n.code;
405
411
  }
406
- async function nt(r) {
412
+ async function ot(n) {
407
413
  try {
408
- return await me(r);
409
- } catch (t) {
410
- if (he(t) === pe)
411
- return Be(r, { requireUserAuthentication: !1 });
412
- throw t;
414
+ return await Se(n);
415
+ } catch (r) {
416
+ if (Te(r) === pe)
417
+ return Ye(n, { requireUserAuthentication: !1 });
418
+ throw r;
413
419
  }
414
420
  }
415
- async function ot(r) {
421
+ async function it(n) {
416
422
  try {
417
- return await me(r);
418
- } catch (t) {
419
- if (he(t) === pe)
423
+ return await Se(n);
424
+ } catch (r) {
425
+ if (Te(r) === pe)
420
426
  return null;
421
- throw t;
427
+ throw r;
422
428
  }
423
429
  }
424
- function it(r, t) {
425
- return Ge(r, t);
430
+ function at(n, r) {
431
+ return Ge(n, r);
426
432
  }
427
- async function at(r) {
433
+ async function ct(n) {
428
434
  try {
429
- await He(r);
430
- } catch (t) {
431
- if (he(t) !== pe)
432
- throw t;
435
+ await He(n);
436
+ } catch (r) {
437
+ if (Te(r) !== pe)
438
+ throw r;
433
439
  }
434
440
  }
435
- const ct = "tiun_auth_token";
436
- async function st(r) {
437
- const t = await ae.getGenericPassword({ service: r });
438
- return t ? t.password : null;
441
+ const st = "tiun_auth_token";
442
+ async function ut(n) {
443
+ const r = await se.getGenericPassword({ service: n });
444
+ return r ? r.password : null;
439
445
  }
440
- async function lt(r, t) {
441
- await ae.setGenericPassword(ct, t, {
442
- service: r,
443
- accessible: ae.ACCESSIBLE.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY
446
+ async function lt(n, r) {
447
+ await se.setGenericPassword(st, r, {
448
+ service: n,
449
+ accessible: se.ACCESSIBLE.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY
444
450
  });
445
451
  }
446
- async function ue(r) {
447
- await ae.resetGenericPassword({ service: r });
452
+ async function le(n) {
453
+ await se.resetGenericPassword({ service: n });
448
454
  }
449
- function ut(r) {
450
- const t = Xe(r);
455
+ function dt(n) {
456
+ const r = Qe(n);
451
457
  return {
452
- title: t.connectionErrorTitle,
453
- text: t.connectionErrorText,
454
- cta: t.connectionErrorCta
458
+ title: r.connectionErrorTitle,
459
+ text: r.connectionErrorText,
460
+ cta: r.connectionErrorCta
455
461
  };
456
462
  }
457
- function dt({ language: r, dark: t, onRetry: a }) {
458
- const l = ut(r), o = t ? ft : null;
459
- return /* @__PURE__ */ S.jsxs(ne, { style: [$.container, o == null ? void 0 : o.container], children: [
460
- /* @__PURE__ */ S.jsxs(ne, { style: $.content, children: [
461
- /* @__PURE__ */ S.jsx(te, { style: [$.title, o == null ? void 0 : o.title], children: l.title }),
462
- /* @__PURE__ */ S.jsx(ne, { style: [$.iconBadge, o == null ? void 0 : o.iconBadge], children: /* @__PURE__ */ S.jsx(te, { style: [$.iconGlyph, o == null ? void 0 : o.iconGlyph], children: "!" }) }),
463
- /* @__PURE__ */ S.jsx(te, { style: [$.text, o == null ? void 0 : o.text], children: l.text })
463
+ function ft({ language: n, dark: r, onRetry: a }) {
464
+ const u = dt(n), o = r ? pt : null;
465
+ return /* @__PURE__ */ v.jsxs(ae, { style: [x.container, o == null ? void 0 : o.container], children: [
466
+ /* @__PURE__ */ v.jsxs(ae, { style: x.content, children: [
467
+ /* @__PURE__ */ v.jsx(oe, { style: [x.title, o == null ? void 0 : o.title], children: u.title }),
468
+ /* @__PURE__ */ v.jsx(ae, { style: [x.iconBadge, o == null ? void 0 : o.iconBadge], children: /* @__PURE__ */ v.jsx(oe, { style: [x.iconGlyph, o == null ? void 0 : o.iconGlyph], children: "!" }) }),
469
+ /* @__PURE__ */ v.jsx(oe, { style: [x.text, o == null ? void 0 : o.text], children: u.text })
464
470
  ] }),
465
- /* @__PURE__ */ S.jsx(
466
- Ae,
471
+ /* @__PURE__ */ v.jsx(
472
+ Ue,
467
473
  {
468
474
  accessibilityRole: "button",
469
475
  onPress: a,
470
- style: ({ pressed: u }) => [
471
- $.button,
476
+ style: ({ pressed: h }) => [
477
+ x.button,
472
478
  o == null ? void 0 : o.button,
473
- u && $.buttonPressed
479
+ h && x.buttonPressed
474
480
  ],
475
- children: /* @__PURE__ */ S.jsx(te, { style: [$.buttonText, o == null ? void 0 : o.buttonText], children: l.cta })
481
+ children: /* @__PURE__ */ v.jsx(oe, { style: [x.buttonText, o == null ? void 0 : o.buttonText], children: u.cta })
476
482
  }
477
483
  )
478
484
  ] });
479
485
  }
480
- const $ = ie.create({
486
+ const x = ce.create({
481
487
  container: {
482
- ...ie.absoluteFillObject,
488
+ ...ce.absoluteFillObject,
483
489
  backgroundColor: "#fff",
484
490
  padding: 24,
485
491
  justifyContent: "space-between"
@@ -533,7 +539,7 @@ const $ = ie.create({
533
539
  fontSize: 16,
534
540
  fontWeight: "500"
535
541
  }
536
- }), ft = ie.create({
542
+ }), pt = ce.create({
537
543
  container: { backgroundColor: "#0a0a0a" },
538
544
  title: { color: "#fafafa" },
539
545
  iconBadge: { backgroundColor: "#500724" },
@@ -544,132 +550,135 @@ const $ = ie.create({
544
550
  // zinc-400
545
551
  button: { backgroundColor: "#fafafa" },
546
552
  buttonText: { color: "#000" }
547
- }), pt = Le;
548
- function J(r) {
549
- return `try{window.tiunHost&&${r};}catch(e){}; true;`;
553
+ }), Tt = We;
554
+ function z(n) {
555
+ return `try{window.tiunHost&&${n};}catch(e){}; true;`;
550
556
  }
551
557
  const ht = Oe(
552
- function({ config: t, onEvent: a }, l) {
553
- const o = !!t.debug, u = Ue(), d = t.appearance === "dark" || t.appearance === "auto" && u === "dark" ? "dark" : "light", h = P(null), [W, x] = z(!1), [F, C] = z(!1), R = P(!1), A = P(!1), M = () => {
558
+ function({ config: r, onEvent: a }, u) {
559
+ const o = !!r.debug, h = je(), y = r.appearance === "dark" || r.appearance === "auto" && h === "dark" ? "dark" : "light", p = C(null), [U, j] = X(!1), [O, I] = X(!1), S = C(!1), $ = C(!1), q = () => {
554
560
  var i;
555
- C(!1), (i = h.current) == null || i.reload();
561
+ I(!1), (i = p.current) == null || i.reload();
556
562
  };
557
- oe(() => {
558
- if (!F)
563
+ ne(() => {
564
+ if (!O)
559
565
  return;
560
- const i = je.addEventListener("change", (n) => {
561
- var T;
562
- n === "active" && (C(!1), (T = h.current) == null || T.reload());
566
+ const i = $e.addEventListener("change", (e) => {
567
+ var s;
568
+ e === "active" && (I(!1), (s = p.current) == null || s.reload());
563
569
  });
564
570
  return () => i.remove();
565
- }, [F]);
566
- const E = `window.${Qe} = true;window.__TIUN_CONFIG__ = Object.assign({}, window.__TIUN_CONFIG__, { returnUrl: ${JSON.stringify(et(t))}, appearance: ${JSON.stringify(d)} });true;`, k = (i, ...n) => {
567
- var T;
568
- return (T = h.current) == null ? void 0 : T.injectJavaScript(
569
- J(
570
- `window.tiunHost.${i}(${n.map((m) => JSON.stringify(m) ?? "null").join(",")})`
571
+ }, [O]);
572
+ const L = `window.${Ze} = true;window.__TIUN_CONFIG__ = Object.assign({}, window.__TIUN_CONFIG__, { returnUrl: ${JSON.stringify(tt(r))}, appearance: ${JSON.stringify(y)} });true;`, b = (i, ...e) => {
573
+ var s;
574
+ return (s = p.current) == null ? void 0 : s.injectJavaScript(
575
+ z(
576
+ `window.tiunHost.${i}(${e.map((d) => JSON.stringify(d) ?? "null").join(",")})`
571
577
  )
572
578
  );
573
- }, V = P(d);
574
- oe(() => {
575
- d !== V.current && (V.current = d, k("setAppearance", d));
576
- }, [d]);
577
- const U = (i) => {
578
- var n;
579
- A.current || (A.current = !0, We().catch(() => {
580
- }), Ve().catch(() => {
581
- }), x(!0), (n = h.current) == null || n.injectJavaScript(
582
- J(
579
+ }, D = C(y);
580
+ ne(() => {
581
+ y !== D.current && (D.current = y, b("setAppearance", y));
582
+ }, [y]);
583
+ const A = (i) => {
584
+ var e;
585
+ $.current || ($.current = !0, qe().catch(() => {
586
+ }), De().catch(() => {
587
+ }), j(!0), (e = p.current) == null || e.injectJavaScript(
588
+ z(
583
589
  `window.tiunHost.resolveCheckout(${i ? JSON.stringify(i) : ""})`
584
590
  )
585
591
  ));
586
- }, B = (i) => {
587
- var n, T, m;
592
+ }, V = (i) => {
593
+ var e, s, d;
588
594
  switch (i.type) {
589
- case q.popPubKeyRequest:
590
- return nt(re(t)).then((p) => k("popPubKey", p)).catch((p) => {
591
- o && console.warn("[tiun] ensurePopKey failed:", p), k("popPubKey", null);
595
+ case M.popPubKeyRequest:
596
+ return ot(ie(r)).then((l) => b("popPubKey", l)).catch((l) => {
597
+ o && console.warn("[tiun] ensurePopKey failed:", l), b("popPubKey", null);
592
598
  }), !0;
593
- case q.tokenGet:
599
+ case M.tokenGet:
594
600
  return (async () => {
595
601
  try {
596
- const p = await st(Z(t));
597
- if (p && !await ot(re(t))) {
598
- await ue(Z(t)), k("restoreToken", null);
602
+ const l = await ut(te(r));
603
+ if (l && !await it(ie(r))) {
604
+ await le(te(r)), b("restoreToken", null);
599
605
  return;
600
606
  }
601
- k("restoreToken", p);
607
+ b("restoreToken", l);
602
608
  } catch {
603
- k("restoreToken", null);
609
+ b("restoreToken", null);
604
610
  }
605
611
  })(), !0;
606
- case q.popSignRequest: {
607
- const p = (n = i.payload) == null ? void 0 : n.requestId, g = (T = i.payload) == null ? void 0 : T.information;
608
- return it(re(t), g).then((N) => k("popSignResult", p, N, null)).catch((N) => {
609
- const Y = (N == null ? void 0 : N.code) ?? "sign_failed";
610
- o && console.warn("[tiun] popSign failed:", N), k("popSignResult", p, null, String(Y));
612
+ case M.popSignRequest: {
613
+ const l = (e = i.payload) == null ? void 0 : e.requestId, E = (s = i.payload) == null ? void 0 : s.information;
614
+ return at(ie(r), E).then((m) => b("popSignResult", l, m, null)).catch((m) => {
615
+ const N = (m == null ? void 0 : m.code) ?? "sign_failed";
616
+ o && console.warn("[tiun] popSign failed:", m), b("popSignResult", l, null, String(N));
611
617
  }), !0;
612
618
  }
613
- case q.tokenPersist: {
614
- const p = ((m = i.payload) == null ? void 0 : m.token) ?? null;
615
- return (p ? lt(Z(t), p) : ue(Z(t))).catch(
616
- (g) => o && console.warn("[tiun] token persist failed:", g)
619
+ case M.tokenPersist: {
620
+ const l = ((d = i.payload) == null ? void 0 : d.token) ?? null;
621
+ return (l ? lt(te(r), l) : le(te(r))).catch(
622
+ (E) => o && console.warn("[tiun] token persist failed:", E)
617
623
  ), !0;
618
624
  }
619
- case q.nativeReset:
625
+ case M.nativeReset:
620
626
  return Promise.allSettled([
621
- at(re(t)),
622
- ue(Z(t))
627
+ ct(ie(r)),
628
+ le(te(r))
623
629
  ]), !0;
624
630
  default:
625
631
  return !1;
626
632
  }
627
633
  };
628
- Pe(
629
- l,
634
+ Ae(
635
+ u,
630
636
  () => ({
631
637
  login: () => {
632
638
  var i;
633
- x(!0), (i = h.current) == null || i.injectJavaScript(
634
- J("window.tiunHost.login()")
639
+ j(!0), (i = p.current) == null || i.injectJavaScript(
640
+ z("window.tiunHost.login()")
635
641
  );
636
642
  },
637
- checkout: (i) => {
638
- var n;
639
- x(!0), R.current = !0, A.current = !1, (n = h.current) == null || n.injectJavaScript(
640
- J(
641
- `window.tiunHost.checkout(${i ? JSON.stringify(i) : ""})`
643
+ checkout: (i, e) => {
644
+ var d;
645
+ j(!0), S.current = !0, $.current = !1;
646
+ const s = e ? [i || null, e] : i ? [i] : [];
647
+ (d = p.current) == null || d.injectJavaScript(
648
+ z(
649
+ `window.tiunHost.checkout(${s.map((l) => JSON.stringify(l)).join(",")})`
642
650
  )
643
651
  );
644
652
  },
645
653
  logout: () => {
646
654
  var i;
647
- return (i = h.current) == null ? void 0 : i.injectJavaScript(
648
- J("window.tiunHost.logout()")
655
+ return (i = p.current) == null ? void 0 : i.injectJavaScript(
656
+ z("window.tiunHost.logout()")
649
657
  );
650
658
  },
651
659
  getVerificationToken: (i) => {
652
- var n;
653
- return (n = h.current) == null ? void 0 : n.injectJavaScript(
654
- J(
660
+ var e;
661
+ return (e = p.current) == null ? void 0 : e.injectJavaScript(
662
+ z(
655
663
  `window.tiunHost.getVerificationToken(${i ? JSON.stringify(i) : ""})`
656
664
  )
657
665
  );
658
666
  },
659
- resolveCheckout: U,
667
+ productRequest: (i, e, ...s) => b(i, e, ...s),
668
+ resolveCheckout: A,
660
669
  reload: () => {
661
670
  var i;
662
- return (i = h.current) == null ? void 0 : i.reload();
671
+ return (i = p.current) == null ? void 0 : i.reload();
663
672
  }
664
673
  }),
665
674
  // eslint-disable-next-line react-hooks/exhaustive-deps
666
675
  []
667
676
  );
668
- const G = (i) => {
669
- var T, m, p;
670
- let n = null;
677
+ const Y = (i) => {
678
+ var s, d, l;
679
+ let e = null;
671
680
  try {
672
- n = JSON.parse(i.nativeEvent.data);
681
+ e = JSON.parse(i.nativeEvent.data);
673
682
  } catch {
674
683
  o && console.warn(
675
684
  "[tiun] non-JSON bridge message:",
@@ -677,28 +686,28 @@ const ht = Oe(
677
686
  );
678
687
  return;
679
688
  }
680
- if (!(!n || typeof n.type != "string")) {
681
- if (n.type === "console") {
689
+ if (!(!e || typeof e.type != "string")) {
690
+ if (e.type === "console") {
682
691
  o && console.log(
683
692
  "[tiun webview]",
684
- (T = n.payload) == null ? void 0 : T.level,
685
- (m = n.payload) == null ? void 0 : m.message
693
+ (s = e.payload) == null ? void 0 : s.level,
694
+ (d = e.payload) == null ? void 0 : d.message
686
695
  );
687
696
  return;
688
697
  }
689
- if ((n.type === "cryptoCheck" || n.type === "hostBridgeReady") && C(!1), o && console.log("[tiun] <-", n.type, n.payload), !B(n)) {
690
- if (n.type === q.overlayChange) {
691
- const g = !!((p = n.payload) != null && p.overlay);
692
- x(g), g || (R.current = !1);
698
+ if ((e.type === "cryptoCheck" || e.type === "hostBridgeReady") && I(!1), o && console.log("[tiun] <-", e.type, e.payload), !V(e)) {
699
+ if (e.type === M.overlayChange) {
700
+ const E = !!((l = e.payload) != null && l.overlay);
701
+ j(E), E || (S.current = !1);
693
702
  }
694
- a(n);
703
+ a(e);
695
704
  }
696
705
  }
697
- }, H = (i) => {
698
- if (R.current = !1, Fe.OS === "ios") {
699
- Ye(i, t.returnUrl).then((n) => {
700
- n.type === "success" && n.url ? U(Se(n.url)) : n.type === "cancel" && U("cancelled");
701
- }).catch((n) => o && console.warn("[tiun] openAuth error:", n));
706
+ }, F = (i) => {
707
+ if (S.current = !1, Fe.OS === "ios") {
708
+ Ve(i, r.returnUrl).then((e) => {
709
+ e.type === "success" && e.url ? A(Re(e.url)) : e.type === "cancel" && A("cancelled");
710
+ }).catch((e) => o && console.warn("[tiun] openAuth error:", e));
702
711
  return;
703
712
  }
704
713
  be(i, {
@@ -706,73 +715,73 @@ const ht = Oe(
706
715
  enableUrlBarHiding: !1,
707
716
  enableDefaultShare: !1,
708
717
  forceCloseOnRedirection: !1
709
- }).then((n) => {
710
- n.type === "cancel" && U("cancelled");
718
+ }).then((e) => {
719
+ e.type === "cancel" && A("cancelled");
711
720
  }).catch(
712
- (n) => o && console.warn("[tiun] in-app browser open error:", n)
721
+ (e) => o && console.warn("[tiun] in-app browser open error:", e)
713
722
  );
714
- }, s = (i) => {
723
+ }, R = (i) => {
715
724
  be(i, {
716
725
  modalPresentationStyle: "fullScreen",
717
726
  modalEnabled: !0,
718
727
  animated: !0,
719
728
  enableBarCollapsing: !0
720
729
  }).catch(
721
- (n) => o && console.warn("[tiun] in-app browser open failed:", n)
730
+ (e) => o && console.warn("[tiun] in-app browser open failed:", e)
722
731
  );
723
- }, v = (i) => {
724
- var T;
725
- const n = (T = i.nativeEvent) == null ? void 0 : T.targetUrl;
726
- n && (R.current ? H(n) : s(n));
727
- }, b = (i) => {
728
- const n = i.url;
729
- return n.startsWith(fe(t)) || n.startsWith("about:") || n.startsWith("data:") || n === "about:blank" ? !0 : n.startsWith("http://") || n.startsWith("https://") ? (R.current && i.isTopFrame !== !1 ? H(n) : s(n), !1) : !0;
730
- }, { width: I, height: _ } = $e();
731
- return /* @__PURE__ */ S.jsxs(
732
- ne,
732
+ }, G = (i) => {
733
+ var s;
734
+ const e = (s = i.nativeEvent) == null ? void 0 : s.targetUrl;
735
+ e && (S.current ? F(e) : R(e));
736
+ }, W = (i) => {
737
+ const e = i.url;
738
+ return e.startsWith(fe(r)) || e.startsWith("about:") || e.startsWith("data:") || e === "about:blank" ? !0 : e.startsWith("http://") || e.startsWith("https://") ? (S.current && i.isTopFrame !== !1 ? F(e) : R(e), !1) : !0;
739
+ }, { width: H, height: B } = Le();
740
+ return /* @__PURE__ */ v.jsxs(
741
+ ae,
733
742
  {
734
- pointerEvents: W ? "auto" : "none",
743
+ pointerEvents: U ? "auto" : "none",
735
744
  style: [
736
- ee.container,
737
- { width: I, height: _ },
738
- W ? ee.visible : ee.hidden
745
+ re.container,
746
+ { width: H, height: B },
747
+ U ? re.visible : re.hidden
739
748
  ],
740
749
  children: [
741
- /* @__PURE__ */ S.jsx(
742
- pt,
750
+ /* @__PURE__ */ v.jsx(
751
+ Tt,
743
752
  {
744
- ref: h,
745
- source: { uri: tt(t) },
753
+ ref: p,
754
+ source: { uri: rt(r) },
746
755
  originWhitelist: ["*"],
747
- onMessage: G,
748
- onShouldStartLoadWithRequest: b,
749
- onOpenWindow: v,
750
- injectedJavaScriptBeforeContentLoaded: E,
756
+ onMessage: Y,
757
+ onShouldStartLoadWithRequest: W,
758
+ onOpenWindow: G,
759
+ injectedJavaScriptBeforeContentLoaded: L,
751
760
  javaScriptEnabled: !0,
752
761
  domStorageEnabled: !0,
753
- style: ee.webview,
754
- containerStyle: ee.webview,
762
+ style: re.webview,
763
+ containerStyle: re.webview,
755
764
  onError: (i) => {
756
- o && console.warn("[tiun] webview load error:", i.nativeEvent), C(!0);
765
+ o && console.warn("[tiun] webview load error:", i.nativeEvent), I(!0);
757
766
  },
758
767
  onHttpError: (i) => {
759
- o && console.warn("[tiun] webview http error:", i.nativeEvent), C(!0);
768
+ o && console.warn("[tiun] webview http error:", i.nativeEvent), I(!0);
760
769
  }
761
770
  }
762
771
  ),
763
- F && W ? /* @__PURE__ */ S.jsx(
764
- dt,
772
+ O && U ? /* @__PURE__ */ v.jsx(
773
+ ft,
765
774
  {
766
- language: t.language,
767
- dark: d === "dark",
768
- onRetry: M
775
+ language: r.language,
776
+ dark: y === "dark",
777
+ onRetry: q
769
778
  }
770
779
  ) : null
771
780
  ]
772
781
  }
773
782
  );
774
783
  }
775
- ), ee = ie.create({
784
+ ), re = ce.create({
776
785
  container: {
777
786
  position: "absolute",
778
787
  top: 0,
@@ -787,142 +796,206 @@ const ht = Oe(
787
796
  visible: { opacity: 1 },
788
797
  hidden: { opacity: 0 }
789
798
  });
790
- class Tt {
799
+ class Et {
791
800
  constructor() {
792
- Te(this, "listeners", /* @__PURE__ */ new Map());
801
+ he(this, "listeners", /* @__PURE__ */ new Map());
793
802
  }
794
- on(t, a) {
795
- let l = this.listeners.get(t);
796
- return l || (l = /* @__PURE__ */ new Set(), this.listeners.set(t, l)), l.add(a), () => {
803
+ on(r, a) {
804
+ let u = this.listeners.get(r);
805
+ return u || (u = /* @__PURE__ */ new Set(), this.listeners.set(r, u)), u.add(a), () => {
797
806
  var o;
798
- (o = this.listeners.get(t)) == null || o.delete(a);
807
+ (o = this.listeners.get(r)) == null || o.delete(a);
799
808
  };
800
809
  }
801
- emit(t, a) {
802
- const l = this.listeners.get(t);
803
- if (l)
804
- for (const o of l)
810
+ emit(r, a) {
811
+ const u = this.listeners.get(r);
812
+ if (u)
813
+ for (const o of u)
805
814
  try {
806
815
  o(a);
807
816
  } catch {
808
817
  }
809
818
  }
810
819
  }
811
- const Re = ve(null), ke = ve(null);
812
- function mt({ config: r, children: t }) {
813
- const a = P(null), l = P(!1), o = P([]), u = P(/* @__PURE__ */ new Map()), d = P(new Tt()).current, [h, W] = z(!1), [x, F] = z(null), [C, R] = z(!1), [A, M] = z(null), E = K((s) => {
814
- l.current ? s() : o.current.push(s);
815
- }, []), k = K(
816
- (s) => {
817
- var v, b, I, _, i, n, T, m, p, g, N, Y;
818
- switch (s.type) {
820
+ const bt = 1e4, we = () => Promise.reject({ code: "invalid_argument", message: "productId is required" }), ge = me(null), ke = me(null);
821
+ function Rt({ config: n, children: r }) {
822
+ const a = C(null), u = C(!1), o = C([]), h = C(/* @__PURE__ */ new Map()), y = C(/* @__PURE__ */ new Map()), p = C(new Et()).current, [U, j] = X(!1), [O, I] = X(null), [S, $] = X(!1), [q, L] = X(null), b = P((e) => {
823
+ u.current ? e() : o.current.push(e);
824
+ }, []), D = P(
825
+ (e) => {
826
+ var s, d, l, E, m, N, Q, t, c, T, w, k, g, K, J;
827
+ switch (e.type) {
819
828
  case "cryptoCheck":
820
- M(!!((v = s.payload) != null && v.subtle && ((b = s.payload) != null && b.secureContext)));
829
+ L(!!((s = e.payload) != null && s.subtle && ((d = e.payload) != null && d.secureContext)));
821
830
  break;
822
831
  case "TIUN_SNIPPET_INITIALIZED": {
823
- l.current = !0, R(!0), d.emit("ready", void 0);
824
- const j = o.current;
825
- o.current = [], j.forEach((e) => e());
832
+ u.current = !0, $(!0), p.emit("ready", void 0);
833
+ const f = o.current;
834
+ o.current = [], f.forEach((_) => _());
826
835
  break;
827
836
  }
828
837
  case "TIUN_USER_CHANGE": {
829
- const j = !!((I = s.payload) != null && I.isAuthenticated), e = ((_ = s.payload) == null ? void 0 : _.user) ?? null;
830
- W(j), F(e), d.emit("userChange", { isAuthenticated: j, user: e }), ((i = s.payload) == null ? void 0 : i.userEvent) === "login" && d.emit("login", { user: e }), ((n = s.payload) == null ? void 0 : n.userEvent) === "logout" && d.emit("logout", void 0);
838
+ const f = !!((l = e.payload) != null && l.isAuthenticated), _ = ((E = e.payload) == null ? void 0 : E.user) ?? null;
839
+ j(f), I(_), p.emit("userChange", { isAuthenticated: f, user: _ }), ((m = e.payload) == null ? void 0 : m.userEvent) === "login" && p.emit("login", { user: _ }), ((N = e.payload) == null ? void 0 : N.userEvent) === "logout" && p.emit("logout", void 0);
831
840
  break;
832
841
  }
833
842
  case "TIUN_VERIFICATION_TOKEN": {
834
- const j = ((T = s.payload) == null ? void 0 : T.token) ?? null, e = (m = s.payload) == null ? void 0 : m.requestId;
835
- e && u.current.has(e) && (u.current.get(e)(j), u.current.delete(e));
843
+ const f = ((Q = e.payload) == null ? void 0 : Q.token) ?? null, _ = (t = e.payload) == null ? void 0 : t.requestId;
844
+ _ && h.current.has(_) && (h.current.get(_)(f), h.current.delete(_));
845
+ break;
846
+ }
847
+ case "TIUN_PRODUCT_RESULT": {
848
+ const f = (c = e.payload) == null ? void 0 : c.requestId, _ = f ? y.current.get(f) : void 0;
849
+ if (!_)
850
+ break;
851
+ clearTimeout(_.timer), y.current.delete(f), (T = e.payload) != null && T.error ? _.reject(e.payload.error) : _.resolve((w = e.payload) == null ? void 0 : w.result);
836
852
  break;
837
853
  }
838
854
  case "TIUN_SHOW_PAYWALL":
839
- d.emit("paywallShow", { isConnected: !!((p = s.payload) != null && p.isConnected) });
855
+ p.emit("paywallShow", { isConnected: !!((k = e.payload) != null && k.isConnected) });
840
856
  break;
841
857
  case "TIUN_HIDE_PAYWALL":
842
- d.emit("paywallHide", {
843
- sessionId: ((g = s.payload) == null ? void 0 : g.sessionId) ?? "",
844
- isConnected: ((N = s.payload) == null ? void 0 : N.isConnected) ?? !0
858
+ p.emit("paywallHide", {
859
+ sessionId: ((g = e.payload) == null ? void 0 : g.sessionId) ?? "",
860
+ isConnected: ((K = e.payload) == null ? void 0 : K.isConnected) ?? !0
845
861
  });
846
862
  break;
847
863
  case "TIUN_ERROR":
848
- d.emit("error", ((Y = s.payload) == null ? void 0 : Y.error) ?? s.payload ?? {});
864
+ p.emit("error", ((J = e.payload) == null ? void 0 : J.error) ?? e.payload ?? {});
849
865
  break;
850
866
  }
851
867
  },
852
- [d]
868
+ [p]
853
869
  );
854
- oe(() => {
855
- const s = (b) => {
856
- if (!b || !rt(r, b))
870
+ ne(() => {
871
+ const e = (d) => {
872
+ if (!d || !nt(n, d))
857
873
  return;
858
- const I = Se(b);
859
- E(() => {
860
- var _;
861
- return (_ = a.current) == null ? void 0 : _.resolveCheckout(I);
874
+ const l = Re(d);
875
+ b(() => {
876
+ var E;
877
+ return (E = a.current) == null ? void 0 : E.resolveCheckout(l);
862
878
  });
863
- }, v = Ee.addEventListener("url", ({ url: b }) => s(b));
864
- return Ee.getInitialURL().then(s).catch(() => {
865
- }), () => v.remove();
866
- }, [r, E]);
867
- const V = K(() => E(() => {
868
- var s;
869
- return (s = a.current) == null ? void 0 : s.login();
870
- }), [E]), U = K(() => E(() => {
871
- var s;
872
- return (s = a.current) == null ? void 0 : s.logout();
873
- }), [E]), B = K(
874
- (s) => E(() => {
875
- var v;
876
- return (v = a.current) == null ? void 0 : v.checkout(s == null ? void 0 : s.productId);
879
+ }, s = Ee.addEventListener("url", ({ url: d }) => e(d));
880
+ return Ee.getInitialURL().then(e).catch(() => {
881
+ }), () => s.remove();
882
+ }, [n, b]);
883
+ const A = P(() => b(() => {
884
+ var e;
885
+ return (e = a.current) == null ? void 0 : e.login();
886
+ }), [b]), V = P(() => b(() => {
887
+ var e;
888
+ return (e = a.current) == null ? void 0 : e.logout();
889
+ }), [b]), Y = P(
890
+ (e) => b(() => {
891
+ var s;
892
+ return (s = a.current) == null ? void 0 : s.checkout(e == null ? void 0 : e.productId, e == null ? void 0 : e.referenceId);
877
893
  }),
878
- [E]
879
- ), G = K(
880
- () => new Promise((s) => {
881
- const v = `vt_${Math.random().toString(36).slice(2)}_${Date.now()}`;
882
- let b = !1;
883
- const I = (_) => {
884
- b || (b = !0, u.current.delete(v), s(_));
894
+ [b]
895
+ ), F = P(
896
+ () => new Promise((e) => {
897
+ const s = `vt_${Math.random().toString(36).slice(2)}_${Date.now()}`;
898
+ let d = !1;
899
+ const l = (E) => {
900
+ d || (d = !0, h.current.delete(s), e(E));
885
901
  };
886
- u.current.set(v, I), E(() => {
887
- var _;
888
- return (_ = a.current) == null ? void 0 : _.getVerificationToken(v);
889
- }), setTimeout(() => I(null), 5e3);
902
+ h.current.set(s, l), b(() => {
903
+ var E;
904
+ return (E = a.current) == null ? void 0 : E.getVerificationToken(s);
905
+ }), setTimeout(() => l(null), 5e3);
890
906
  }),
891
- [E]
892
- ), H = xe(
907
+ [b]
908
+ ), R = P(
909
+ (e, ...s) => new Promise((d, l) => {
910
+ const E = `pr_${Math.random().toString(36).slice(2)}_${Date.now()}`, m = {
911
+ resolve: d,
912
+ reject: l
913
+ };
914
+ y.current.set(E, m), b(() => {
915
+ var N;
916
+ y.current.get(E) === m && (m.timer = setTimeout(() => {
917
+ y.current.delete(E), l({ code: "timeout", message: `${e} timed out` });
918
+ }, bt), (N = a.current) == null || N.productRequest(e, E, ...s));
919
+ });
920
+ }),
921
+ [b]
922
+ );
923
+ ne(() => {
924
+ const e = y.current;
925
+ return () => {
926
+ e.forEach(({ reject: s, timer: d }) => {
927
+ clearTimeout(d), s({ code: "destroyed", message: "TiunProvider was unmounted" });
928
+ }), e.clear();
929
+ };
930
+ }, []);
931
+ const G = P(
932
+ () => R("listProducts"),
933
+ [R]
934
+ ), W = P(
935
+ (e) => e ? R("getProduct", e) : we(),
936
+ [R]
937
+ ), H = P(
938
+ () => R("listProductAccess"),
939
+ [R]
940
+ ), B = P(
941
+ (e, s) => e ? R(
942
+ "checkProductAccess",
943
+ e,
944
+ // Empty string means "no reference" — don't send a value the BE rejects.
945
+ (s == null ? void 0 : s.referenceId) || void 0
946
+ ) : we(),
947
+ [R]
948
+ ), i = xe(
893
949
  () => ({
894
- isAuthenticated: h,
895
- user: x,
896
- ready: C,
897
- cryptoOk: A,
898
- login: V,
899
- logout: U,
900
- checkout: B,
901
- getUserVerificationToken: G
950
+ isAuthenticated: U,
951
+ user: O,
952
+ ready: S,
953
+ cryptoOk: q,
954
+ login: A,
955
+ logout: V,
956
+ checkout: Y,
957
+ getUserVerificationToken: F,
958
+ listProducts: G,
959
+ getProduct: W,
960
+ listProductAccess: H,
961
+ checkProductAccess: B
902
962
  }),
903
- [h, x, C, A, V, U, B, G]
963
+ [
964
+ U,
965
+ O,
966
+ S,
967
+ q,
968
+ A,
969
+ V,
970
+ Y,
971
+ F,
972
+ G,
973
+ W,
974
+ H,
975
+ B
976
+ ]
904
977
  );
905
- return /* @__PURE__ */ S.jsx(Re.Provider, { value: H, children: /* @__PURE__ */ S.jsxs(ke.Provider, { value: d, children: [
906
- t,
907
- /* @__PURE__ */ S.jsx(ht, { ref: a, config: r, onEvent: k })
978
+ return /* @__PURE__ */ v.jsx(ge.Provider, { value: i, children: /* @__PURE__ */ v.jsxs(ke.Provider, { value: p, children: [
979
+ r,
980
+ /* @__PURE__ */ v.jsx(ht, { ref: a, config: n, onEvent: D })
908
981
  ] }) });
909
982
  }
910
- function St() {
911
- const r = _e(Re);
912
- if (!r)
983
+ function gt() {
984
+ const n = ve(ge);
985
+ if (!n)
913
986
  throw new Error("useTiun must be used within a <TiunProvider>");
914
- return r;
987
+ return n;
915
988
  }
916
- function Rt(r, t) {
917
- const a = _e(ke), l = P(t);
918
- l.current = t, oe(() => {
989
+ function kt(n, r) {
990
+ const a = ve(ke), u = C(r);
991
+ u.current = r, ne(() => {
919
992
  if (!a)
920
993
  throw new Error("useTiunEvent must be used within a <TiunProvider>");
921
- return a.on(r, (o) => l.current(o));
922
- }, [a, r]);
994
+ return a.on(n, (o) => u.current(o));
995
+ }, [a, n]);
923
996
  }
924
997
  export {
925
- mt as TiunProvider,
926
- St as useTiun,
927
- Rt as useTiunEvent
998
+ Rt as TiunProvider,
999
+ gt as useTiun,
1000
+ kt as useTiunEvent
928
1001
  };