@tiun/react-native-sdk 0.4.0 → 0.5.0-staging.0

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