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