@tiun/react-native-sdk 0.2.0 → 0.4.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 Oe, { forwardRef as Ie, 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 T in o)
31
+ T !== "key" && (u[T] = o[T]);
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,128 +52,128 @@ 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 === m ? 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 b:
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
- case s:
73
+ case c:
74
74
  return "SuspenseList";
75
- case n:
75
+ case O:
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;
88
+ case G:
89
+ var s = e.render;
90
+ return e = e.displayName, e || (e = s.displayName || s.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
91
+ case _:
92
+ return s = e.displayName || null, s !== null ? s : r(e.type) || "Memo";
91
93
  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;
94
+ s = e._payload, e = e._init;
95
95
  try {
96
- return t(e(a));
96
+ return r(e(s));
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 s = !1;
109
109
  } catch {
110
- a = !0;
110
+ s = !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";
115
- return f.call(
116
- a,
112
+ if (s) {
113
+ s = console;
114
+ var p = s.error, w = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
115
+ return p.call(
116
+ s,
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
+ w
119
+ ), t(e);
120
120
  }
121
121
  }
122
122
  function l(e) {
123
- if (e === T)
123
+ if (e === b)
124
124
  return "<>";
125
- if (typeof e == "object" && e !== null && e.$$typeof === o)
125
+ if (typeof e == "object" && e !== null && e.$$typeof === y)
126
126
  return "<...>";
127
127
  try {
128
- var a = t(e);
129
- return a ? "<" + a + ">" : "<...>";
128
+ var s = r(e);
129
+ return s ? "<" + s + ">" : "<...>";
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 s = Object.getOwnPropertyDescriptor(e, "key").get;
144
+ if (s && s.isReactWarning)
145
145
  return !1;
146
146
  }
147
147
  return e.key !== void 0;
148
148
  }
149
- function _(e, a) {
150
- function f() {
151
- L || (L = !0, console.error(
149
+ function T(e, s) {
150
+ function p() {
151
+ f || (f = !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
+ s
154
154
  ));
155
155
  }
156
- f.isReactWarning = !0, Object.defineProperty(e, "key", {
157
- get: f,
156
+ p.isReactWarning = !0, Object.defineProperty(e, "key", {
157
+ get: p,
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, s, p, w, L, I, ce, se) {
168
+ return p = I.ref, e = {
169
+ $$typeof: A,
170
170
  type: e,
171
- key: a,
172
- props: N,
173
- _owner: A
174
- }, (f !== void 0 ? f : null) !== null ? Object.defineProperty(e, "ref", {
171
+ key: s,
172
+ props: I,
173
+ _owner: L
174
+ }, (p !== void 0 ? p : 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, s, p, w, L, I, ce, se) {
200
+ var v = s.children;
201
+ if (v !== void 0)
202
+ if (w)
203
+ if (h(v)) {
204
+ for (w = 0; w < v.length; w++)
205
+ C(v[w]);
206
+ Object.freeze && Object.freeze(v);
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(v);
213
+ if (n.call(s, "key")) {
214
+ v = r(e);
215
+ var D = Object.keys(s).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
+ w = 0 < D.length ? "{key: someKey, " + D.join(": ..., ") + ": ...}" : "{key: someKey}", j[v + w] || (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
+ w,
226
+ v,
227
+ D,
228
+ v
229
+ ), j[v + w] = !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) {
232
- f = {};
233
- for (var ce in a)
234
- ce !== "key" && (f[ce] = a[ce]);
231
+ if (v = null, p !== void 0 && (a(p), v = "" + p), d(s) && (a(s.key), v = "" + s.key), "key" in s) {
232
+ p = {};
233
+ for (var le in s)
234
+ le !== "key" && (p[le] = s[le]);
235
235
  } else
236
- f = a;
237
- return b && _(
238
- f,
236
+ p = s;
237
+ return v && T(
238
+ p,
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(),
246
- f,
247
- ie,
248
- ae
242
+ v,
243
+ I,
244
+ L,
245
+ o(),
246
+ p,
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 = Oe, A = Symbol.for("react.transitional.element"), M = Symbol.for("react.portal"), b = 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"), c = Symbol.for("react.suspense_list"), _ = Symbol.for("react.memo"), y = Symbol.for("react.lazy"), O = Symbol.for("react.activity"), m = Symbol.for("react.client.reference"), i = R.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, n = Object.prototype.hasOwnProperty, h = Array.isArray, E = 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 f, 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 = E(l(u)), j = {};
266
+ Q.Fragment = b, Q.jsx = function(e, s, p, w, L) {
267
+ var I = 1e4 > i.recentlyCreatedOwnerStacks++;
268
+ return F(
269
269
  e,
270
- a,
271
- f,
270
+ s,
271
+ p,
272
272
  !1,
273
- E,
274
- A,
275
- N ? Error("react-stack-top-frame") : z,
276
- N ? m(l(e)) : M
273
+ w,
274
+ L,
275
+ I ? Error("react-stack-top-frame") : N,
276
+ I ? E(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, s, p, w, L) {
279
+ var I = 1e4 > i.recentlyCreatedOwnerStacks++;
280
+ return F(
281
281
  e,
282
- a,
283
- f,
282
+ s,
283
+ p,
284
284
  !0,
285
- E,
286
- A,
287
- N ? Error("react-stack-top-frame") : z,
288
- N ? m(l(e)) : M
285
+ w,
286
+ L,
287
+ I ? Error("react-stack-top-frame") : N,
288
+ I ? E(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 = Ie(
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", T = P(null), [W, x] = z(!1), [F, C] = z(!1), R = P(!1), A = P(!1), M = () => {
554
+ var i;
555
+ C(!1), (i = T.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 h;
562
+ n === "active" && (C(!1), (h = T.current) == null || h.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 b = `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 h;
568
+ return (h = T.current) == null ? void 0 : h.injectJavaScript(
569
+ J(
570
+ `window.tiunHost.${i}(${n.map((E) => JSON.stringify(E) ?? "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 = T.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, h, E;
588
+ switch (i.type) {
589
+ case q.popPubKeyRequest:
590
+ return nt(re(t)).then((f) => k("popPubKey", f)).catch((f) => {
591
+ o && console.warn("[tiun] ensurePopKey failed:", f), 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 f = await st(Z(t));
597
+ if (f && !await ot(re(t))) {
598
+ await ue(Z(t)), k("restoreToken", null);
579
599
  return;
580
600
  }
581
- S("restoreToken", p);
601
+ k("restoreToken", f);
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 f = (n = i.payload) == null ? void 0 : n.requestId, g = (h = i.payload) == null ? void 0 : h.information;
608
+ return it(re(t), g).then((N) => k("popSignResult", f, 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", f, 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 f = ((E = i.payload) == null ? void 0 : E.token) ?? null;
615
+ return (f ? lt(Z(t), f) : 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,152 @@ 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 = T.current) == null || i.injectJavaScript(
634
+ J("window.tiunHost.login()")
615
635
  );
616
636
  },
617
- checkout: (o) => {
618
- 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) : ""})`
637
+ checkout: (i, n) => {
638
+ var E;
639
+ x(!0), R.current = !0, A.current = !1;
640
+ const h = n ? [i || null, n] : i ? [i] : [];
641
+ (E = T.current) == null || E.injectJavaScript(
642
+ J(
643
+ `window.tiunHost.checkout(${h.map((f) => JSON.stringify(f)).join(",")})`
622
644
  )
623
645
  );
624
646
  },
625
647
  logout: () => {
626
- var o;
627
- return (o = u.current) == null ? void 0 : o.injectJavaScript(
628
- G("window.tiunHost.logout()")
648
+ var i;
649
+ return (i = T.current) == null ? void 0 : i.injectJavaScript(
650
+ J("window.tiunHost.logout()")
629
651
  );
630
652
  },
631
- getVerificationToken: (o) => {
653
+ getVerificationToken: (i) => {
632
654
  var n;
633
- return (n = u.current) == null ? void 0 : n.injectJavaScript(
634
- G(
635
- `window.tiunHost.getVerificationToken(${o ? JSON.stringify(o) : ""})`
655
+ return (n = T.current) == null ? void 0 : n.injectJavaScript(
656
+ J(
657
+ `window.tiunHost.getVerificationToken(${i ? JSON.stringify(i) : ""})`
636
658
  )
637
659
  );
638
660
  },
639
- resolveCheckout: T,
661
+ resolveCheckout: U,
640
662
  reload: () => {
641
- var o;
642
- return (o = u.current) == null ? void 0 : o.reload();
663
+ var i;
664
+ return (i = T.current) == null ? void 0 : i.reload();
643
665
  }
644
666
  }),
645
667
  // eslint-disable-next-line react-hooks/exhaustive-deps
646
668
  []
647
669
  );
648
- const W = (o) => {
649
- var d, w, p;
670
+ const G = (i) => {
671
+ var h, E, f;
650
672
  let n = null;
651
673
  try {
652
- n = JSON.parse(o.nativeEvent.data);
674
+ n = JSON.parse(i.nativeEvent.data);
653
675
  } catch {
654
- c && console.warn(
676
+ o && console.warn(
655
677
  "[tiun] non-JSON bridge message:",
656
- o.nativeEvent.data
678
+ i.nativeEvent.data
657
679
  );
658
680
  return;
659
681
  }
660
682
  if (!(!n || typeof n.type != "string")) {
661
683
  if (n.type === "console") {
662
- c && console.log(
684
+ o && console.log(
663
685
  "[tiun webview]",
664
- (d = n.payload) == null ? void 0 : d.level,
665
- (w = n.payload) == null ? void 0 : w.message
686
+ (h = n.payload) == null ? void 0 : h.level,
687
+ (E = n.payload) == null ? void 0 : E.message
666
688
  );
667
689
  return;
668
690
  }
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);
691
+ if ((n.type === "cryptoCheck" || n.type === "hostBridgeReady") && C(!1), o && console.log("[tiun] <-", n.type, n.payload), !B(n)) {
692
+ if (n.type === q.overlayChange) {
693
+ const g = !!((f = n.payload) != null && f.overlay);
694
+ x(g), g || (R.current = !1);
673
695
  }
674
- i(n);
696
+ a(n);
675
697
  }
676
698
  }
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));
699
+ }, H = (i) => {
700
+ if (R.current = !1, Fe.OS === "ios") {
701
+ Ye(i, t.returnUrl).then((n) => {
702
+ n.type === "success" && n.url ? U(Se(n.url)) : n.type === "cancel" && U("cancelled");
703
+ }).catch((n) => o && console.warn("[tiun] openAuth error:", n));
682
704
  return;
683
705
  }
684
- be(o, {
706
+ be(i, {
685
707
  showTitle: !1,
686
708
  enableUrlBarHiding: !1,
687
709
  enableDefaultShare: !1,
688
710
  forceCloseOnRedirection: !1
689
711
  }).then((n) => {
690
- n.type === "cancel" && T("cancelled");
712
+ n.type === "cancel" && U("cancelled");
691
713
  }).catch(
692
- (n) => c && console.warn("[tiun] in-app browser open error:", n)
714
+ (n) => o && console.warn("[tiun] in-app browser open error:", n)
693
715
  );
694
- }, F = (o) => {
695
- be(o, {
716
+ }, c = (i) => {
717
+ be(i, {
696
718
  modalPresentationStyle: "fullScreen",
697
719
  modalEnabled: !0,
698
720
  animated: !0,
699
721
  enableBarCollapsing: !0
700
722
  }).catch(
701
- (n) => c && console.warn("[tiun] in-app browser open failed:", n)
723
+ (n) => o && console.warn("[tiun] in-app browser open failed:", n)
702
724
  );
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(
725
+ }, _ = (i) => {
726
+ var h;
727
+ const n = (h = i.nativeEvent) == null ? void 0 : h.targetUrl;
728
+ n && (R.current ? H(n) : c(n));
729
+ }, y = (i) => {
730
+ const n = i.url;
731
+ 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) : c(n), !1) : !0;
732
+ }, { width: O, height: m } = $e();
733
+ return /* @__PURE__ */ S.jsxs(
712
734
  ne,
713
735
  {
714
- pointerEvents: h ? "auto" : "none",
736
+ pointerEvents: W ? "auto" : "none",
715
737
  style: [
716
738
  ee.container,
717
- { width: s, height: y },
718
- h ? ee.visible : ee.hidden
739
+ { width: O, height: m },
740
+ W ? ee.visible : ee.hidden
719
741
  ],
720
742
  children: [
721
- /* @__PURE__ */ v.jsx(
722
- dt,
743
+ /* @__PURE__ */ S.jsx(
744
+ pt,
723
745
  {
724
- ref: u,
725
- source: { uri: et(r) },
746
+ ref: T,
747
+ source: { uri: tt(t) },
726
748
  originWhitelist: ["*"],
727
- onMessage: W,
728
- onShouldStartLoadWithRequest: q,
729
- onOpenWindow: V,
730
- injectedJavaScriptBeforeContentLoaded: j,
749
+ onMessage: G,
750
+ onShouldStartLoadWithRequest: y,
751
+ onOpenWindow: _,
752
+ injectedJavaScriptBeforeContentLoaded: b,
731
753
  javaScriptEnabled: !0,
732
754
  domStorageEnabled: !0,
733
755
  style: ee.webview,
734
756
  containerStyle: ee.webview,
735
- onError: (o) => {
736
- c && console.warn("[tiun] webview load error:", o.nativeEvent), g(!0);
757
+ onError: (i) => {
758
+ o && console.warn("[tiun] webview load error:", i.nativeEvent), C(!0);
737
759
  },
738
- onHttpError: (o) => {
739
- c && console.warn("[tiun] webview http error:", o.nativeEvent), g(!0);
760
+ onHttpError: (i) => {
761
+ o && console.warn("[tiun] webview http error:", i.nativeEvent), C(!0);
740
762
  }
741
763
  }
742
764
  ),
743
- U && h ? /* @__PURE__ */ v.jsx(lt, { language: r.language, onRetry: x }) : null
765
+ F && W ? /* @__PURE__ */ S.jsx(
766
+ dt,
767
+ {
768
+ language: t.language,
769
+ dark: d === "dark",
770
+ onRetry: M
771
+ }
772
+ ) : null
744
773
  ]
745
774
  }
746
775
  );
747
776
  }
748
- ), ee = ue.create({
777
+ ), ee = ie.create({
749
778
  container: {
750
779
  position: "absolute",
751
780
  top: 0,
@@ -760,142 +789,142 @@ const ft = Ce(
760
789
  visible: { opacity: 1 },
761
790
  hidden: { opacity: 0 }
762
791
  });
763
- class pt {
792
+ class Tt {
764
793
  constructor() {
765
794
  Te(this, "listeners", /* @__PURE__ */ new Map());
766
795
  }
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);
796
+ on(t, a) {
797
+ let l = this.listeners.get(t);
798
+ return l || (l = /* @__PURE__ */ new Set(), this.listeners.set(t, l)), l.add(a), () => {
799
+ var o;
800
+ (o = this.listeners.get(t)) == null || o.delete(a);
772
801
  };
773
802
  }
774
- emit(r, i) {
775
- const l = this.listeners.get(r);
803
+ emit(t, a) {
804
+ const l = this.listeners.get(t);
776
805
  if (l)
777
- for (const c of l)
806
+ for (const o of l)
778
807
  try {
779
- c(i);
808
+ o(a);
780
809
  } catch {
781
810
  }
782
811
  }
783
812
  }
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(
789
- (s) => {
790
- var y, o, n, d, w, p, R, m, L, J, z, M;
791
- switch (s.type) {
813
+ const Re = ve(null), ke = ve(null);
814
+ function mt({ config: r, children: t }) {
815
+ const a = P(null), l = P(!1), o = P([]), u = P(/* @__PURE__ */ new Map()), d = P(new Tt()).current, [T, W] = z(!1), [x, F] = z(null), [C, R] = z(!1), [A, M] = z(null), b = K((c) => {
816
+ l.current ? c() : o.current.push(c);
817
+ }, []), k = K(
818
+ (c) => {
819
+ var _, y, O, m, i, n, h, E, f, g, N, Y;
820
+ switch (c.type) {
792
821
  case "cryptoCheck":
793
- S(!!((y = s.payload) != null && y.subtle && ((o = s.payload) != null && o.secureContext)));
822
+ M(!!((_ = c.payload) != null && _.subtle && ((y = c.payload) != null && y.secureContext)));
794
823
  break;
795
824
  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());
825
+ l.current = !0, R(!0), d.emit("ready", void 0);
826
+ const j = o.current;
827
+ o.current = [], j.forEach((e) => e());
799
828
  break;
800
829
  }
801
830
  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);
831
+ const j = !!((O = c.payload) != null && O.isAuthenticated), e = ((m = c.payload) == null ? void 0 : m.user) ?? null;
832
+ W(j), F(e), d.emit("userChange", { isAuthenticated: j, user: e }), ((i = c.payload) == null ? void 0 : i.userEvent) === "login" && d.emit("login", { user: e }), ((n = c.payload) == null ? void 0 : n.userEvent) === "logout" && d.emit("logout", void 0);
804
833
  break;
805
834
  }
806
835
  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));
836
+ const j = ((h = c.payload) == null ? void 0 : h.token) ?? null, e = (E = c.payload) == null ? void 0 : E.requestId;
837
+ e && u.current.has(e) && (u.current.get(e)(j), u.current.delete(e));
809
838
  break;
810
839
  }
811
840
  case "TIUN_SHOW_PAYWALL":
812
- h.emit("paywallShow", { isConnected: !!((L = s.payload) != null && L.isConnected) });
841
+ d.emit("paywallShow", { isConnected: !!((f = c.payload) != null && f.isConnected) });
813
842
  break;
814
843
  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
844
+ d.emit("paywallHide", {
845
+ sessionId: ((g = c.payload) == null ? void 0 : g.sessionId) ?? "",
846
+ isConnected: ((N = c.payload) == null ? void 0 : N.isConnected) ?? !0
818
847
  });
819
848
  break;
820
849
  case "TIUN_ERROR":
821
- h.emit("error", ((M = s.payload) == null ? void 0 : M.error) ?? s.payload ?? {});
850
+ d.emit("error", ((Y = c.payload) == null ? void 0 : Y.error) ?? c.payload ?? {});
822
851
  break;
823
852
  }
824
853
  },
825
- [h]
854
+ [d]
826
855
  );
827
- de(() => {
828
- const s = (o) => {
829
- if (!o || !tt(t, o))
856
+ oe(() => {
857
+ const c = (y) => {
858
+ if (!y || !rt(r, y))
830
859
  return;
831
- const n = Se(o);
832
- T(() => {
833
- var d;
834
- return (d = i.current) == null ? void 0 : d.resolveCheckout(n);
860
+ const O = Se(y);
861
+ b(() => {
862
+ var m;
863
+ return (m = a.current) == null ? void 0 : m.resolveCheckout(O);
835
864
  });
836
- }, y = Ee.addEventListener("url", ({ url: o }) => s(o));
837
- return Ee.getInitialURL().then(s).catch(() => {
838
- }), () => y.remove();
839
- }, [t, T]);
840
- const W = H(() => T(() => {
841
- var s;
842
- return (s = i.current) == null ? void 0 : s.login();
843
- }), [T]), $ = H(() => T(() => {
844
- 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);
865
+ }, _ = Ee.addEventListener("url", ({ url: y }) => c(y));
866
+ return Ee.getInitialURL().then(c).catch(() => {
867
+ }), () => _.remove();
868
+ }, [r, b]);
869
+ const V = K(() => b(() => {
870
+ var c;
871
+ return (c = a.current) == null ? void 0 : c.login();
872
+ }), [b]), U = K(() => b(() => {
873
+ var c;
874
+ return (c = a.current) == null ? void 0 : c.logout();
875
+ }), [b]), B = K(
876
+ (c) => b(() => {
877
+ var _;
878
+ return (_ = a.current) == null ? void 0 : _.checkout(c == null ? void 0 : c.productId, c == null ? void 0 : c.referenceId);
850
879
  }),
851
- [T]
852
- ), V = H(
853
- () => 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));
880
+ [b]
881
+ ), G = K(
882
+ () => new Promise((c) => {
883
+ const _ = `vt_${Math.random().toString(36).slice(2)}_${Date.now()}`;
884
+ let y = !1;
885
+ const O = (m) => {
886
+ y || (y = !0, u.current.delete(_), c(m));
858
887
  };
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);
888
+ u.current.set(_, O), b(() => {
889
+ var m;
890
+ return (m = a.current) == null ? void 0 : m.getVerificationToken(_);
891
+ }), setTimeout(() => O(null), 5e3);
863
892
  }),
864
- [T]
865
- ), q = xe(
893
+ [b]
894
+ ), H = xe(
866
895
  () => ({
867
- isAuthenticated: _,
868
- user: g,
869
- ready: I,
870
- cryptoOk: j,
871
- login: W,
872
- logout: $,
873
- checkout: F,
874
- getUserVerificationToken: V
896
+ isAuthenticated: T,
897
+ user: x,
898
+ ready: C,
899
+ cryptoOk: A,
900
+ login: V,
901
+ logout: U,
902
+ checkout: B,
903
+ getUserVerificationToken: G
875
904
  }),
876
- [_, g, I, j, W, $, F, V]
905
+ [T, x, C, A, V, U, B, G]
877
906
  );
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 })
907
+ return /* @__PURE__ */ S.jsx(Re.Provider, { value: H, children: /* @__PURE__ */ S.jsxs(ke.Provider, { value: d, children: [
908
+ t,
909
+ /* @__PURE__ */ S.jsx(ht, { ref: a, config: r, onEvent: k })
881
910
  ] }) });
882
911
  }
883
- function _t() {
884
- const t = _e(Re);
885
- if (!t)
912
+ function St() {
913
+ const r = _e(Re);
914
+ if (!r)
886
915
  throw new Error("useTiun must be used within a <TiunProvider>");
887
- return t;
916
+ return r;
888
917
  }
889
- function mt(t, r) {
890
- const i = _e(ge), l = P(r);
891
- l.current = r, de(() => {
892
- if (!i)
918
+ function Rt(r, t) {
919
+ const a = _e(ke), l = P(t);
920
+ l.current = t, oe(() => {
921
+ if (!a)
893
922
  throw new Error("useTiunEvent must be used within a <TiunProvider>");
894
- return i.on(t, (c) => l.current(c));
895
- }, [i, t]);
923
+ return a.on(r, (o) => l.current(o));
924
+ }, [a, r]);
896
925
  }
897
926
  export {
898
- vt as TiunProvider,
899
- _t as useTiun,
900
- mt as useTiunEvent
927
+ mt as TiunProvider,
928
+ St as useTiun,
929
+ Rt as useTiunEvent
901
930
  };