@superwall/studio 1.1.1 → 1.3.0-beta.3
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/README.md +61 -11
- package/dist/assets/index-DyLb5fiB.js +11 -0
- package/dist/assets/index-_HCp6gCi.css +1 -0
- package/dist/index.html +2 -2
- package/dist/lib/StudioApp.d.ts +6 -0
- package/dist/lib/components/OpenInApp.d.ts +5 -0
- package/dist/lib/components/PaywallToasts.d.ts +8 -0
- package/dist/lib/components/SurfaceCard.d.ts +11 -0
- package/dist/lib/components/chrome/StudioShell.d.ts +4 -0
- package/dist/lib/components/chrome/Toolbar.d.ts +6 -0
- package/dist/lib/components/chrome/TopBar.d.ts +8 -0
- package/dist/lib/components/controls.d.ts +24 -0
- package/dist/lib/components/icons.d.ts +18 -0
- package/dist/lib/components/menus/ActionMenu.d.ts +14 -0
- package/dist/lib/components/menus/CompareMenu.d.ts +13 -0
- package/dist/lib/components/panels/MissingProducts.d.ts +8 -0
- package/dist/lib/components/panels/SidePanel.d.ts +6 -0
- package/dist/lib/components/panels/VariablesPanel.d.ts +13 -0
- package/dist/lib/components/preview/DeviceChrome.d.ts +12 -0
- package/dist/lib/components/preview/DeviceFrame.d.ts +21 -0
- package/dist/lib/components/preview/HostedIframe.d.ts +7 -0
- package/dist/lib/icon.svg +5 -0
- package/dist/lib/index.d.ts +20 -0
- package/dist/lib/index.js +2268 -0
- package/dist/lib/lib/actions.d.ts +4 -0
- package/dist/lib/lib/contract.d.ts +33 -0
- package/dist/lib/lib/devices.d.ts +26 -0
- package/dist/lib/lib/host.d.ts +15 -0
- package/dist/lib/lib/notices.d.ts +9 -0
- package/dist/lib/lib/preview.d.ts +5 -0
- package/dist/lib/lib/products.d.ts +16 -0
- package/dist/lib/lib/project.d.ts +13 -0
- package/dist/lib/lib/steps.d.ts +5 -0
- package/dist/lib/lib/surfaces.d.ts +35 -0
- package/dist/lib/lib/time.d.ts +1 -0
- package/dist/lib/lib/variables.d.ts +12 -0
- package/dist/lib/products.js +65 -0
- package/dist/lib/screens/SurfaceEditor.d.ts +9 -0
- package/dist/lib/screens/SurfaceList.d.ts +7 -0
- package/dist/lib/studio.css +1 -0
- package/package.json +19 -4
- package/src/StudioApp.tsx +8 -11
- package/src/components/PaywallToasts.tsx +162 -85
- package/src/components/SurfaceCard.tsx +9 -2
- package/src/components/chrome/StudioShell.tsx +12 -0
- package/src/components/icons.tsx +0 -13
- package/src/components/{ActionMenu.tsx → menus/ActionMenu.tsx} +4 -4
- package/src/components/{CompareMenu.tsx → menus/CompareMenu.tsx} +3 -3
- package/src/components/{SidePanel.tsx → panels/SidePanel.tsx} +1 -1
- package/src/components/{VariablesPanel.tsx → panels/VariablesPanel.tsx} +4 -4
- package/src/components/{DeviceChrome.tsx → preview/DeviceChrome.tsx} +1 -1
- package/src/components/{DeviceFrame.tsx → preview/DeviceFrame.tsx} +14 -55
- package/src/components/preview/HostedIframe.tsx +46 -0
- package/src/index.ts +26 -6
- package/src/lib/actions.ts +1 -1
- package/src/lib/contract.ts +30 -0
- package/src/lib/devices.ts +5 -4
- package/src/lib/host.ts +80 -0
- package/src/lib/notices.ts +63 -0
- package/src/lib/preview.ts +11 -33
- package/src/lib/products.ts +116 -0
- package/src/lib/project.ts +2 -1
- package/src/lib/steps.ts +20 -0
- package/src/lib/surfaces.ts +41 -0
- package/src/lib/time.ts +1 -2
- package/src/lib/variables.ts +13 -0
- package/src/main.tsx +3 -3
- package/src/screens/SurfaceEditor.tsx +97 -67
- package/src/screens/SurfaceList.tsx +17 -7
- package/src/styles.css +8 -6
- package/src/vite-env.d.ts +1 -0
- package/dist/assets/index-CVKGrx00.js +0 -11
- package/dist/assets/index-D4RIpSbg.css +0 -1
- package/src/lib/events.ts +0 -77
- package/src/lib/types.ts +0 -85
- /package/src/components/{Toolbar.tsx → chrome/Toolbar.tsx} +0 -0
- /package/src/components/{TopBar.tsx → chrome/TopBar.tsx} +0 -0
- /package/src/components/{MissingProducts.tsx → panels/MissingProducts.tsx} +0 -0
|
@@ -0,0 +1,2268 @@
|
|
|
1
|
+
import { jsx as n, jsxs as c, Fragment as Z } from "react/jsx-runtime";
|
|
2
|
+
import * as p from "react";
|
|
3
|
+
import { toast as U, Toaster as _t } from "sonner";
|
|
4
|
+
const kt = ({
|
|
5
|
+
children: e,
|
|
6
|
+
position: t = "fixed"
|
|
7
|
+
}) => /* @__PURE__ */ n(
|
|
8
|
+
"div",
|
|
9
|
+
{
|
|
10
|
+
className: `sw-studio bg-ink text-cream ${t} inset-0 flex flex-col font-sans text-[0.9375rem] tracking-[-0.01em] antialiased`,
|
|
11
|
+
children: e
|
|
12
|
+
}
|
|
13
|
+
), It = { experimentId: "0", variantId: "0", campaignId: "0" }, T = (e) => Object.fromEntries(Object.entries(e).filter(([, t]) => t !== void 0)), Ge = (e = {}) => ({
|
|
14
|
+
paywallId: e.paywallId ?? "0",
|
|
15
|
+
paywallIdentifier: e.paywallIdentifier ?? "paywall",
|
|
16
|
+
device: T(e.device ?? {}),
|
|
17
|
+
user: T(e.user ?? {}),
|
|
18
|
+
params: T(e.params ?? {}),
|
|
19
|
+
products: e.products ?? [],
|
|
20
|
+
experiment: e.experiment ?? It,
|
|
21
|
+
...e.introductoryOfferEligible === void 0 ? {} : { introductoryOfferEligible: e.introductoryOfferEligible }
|
|
22
|
+
}), Me = (e, t) => {
|
|
23
|
+
const r = {
|
|
24
|
+
...e,
|
|
25
|
+
paywallId: t.paywallId ?? e.paywallId,
|
|
26
|
+
paywallIdentifier: t.paywallIdentifier ?? e.paywallIdentifier,
|
|
27
|
+
device: t.device ? T({ ...e.device, ...t.device }) : e.device,
|
|
28
|
+
user: t.user ? T({ ...e.user, ...t.user }) : e.user,
|
|
29
|
+
params: t.params ? T({ ...e.params, ...t.params }) : e.params,
|
|
30
|
+
products: t.products ?? e.products,
|
|
31
|
+
experiment: t.experiment ?? e.experiment
|
|
32
|
+
};
|
|
33
|
+
return "introductoryOfferEligible" in t && (t.introductoryOfferEligible === void 0 ? delete r.introductoryOfferEligible : r.introductoryOfferEligible = t.introductoryOfferEligible), r;
|
|
34
|
+
}, ye = (e, t) => JSON.stringify(e) === JSON.stringify(t), ce = (e, t) => {
|
|
35
|
+
const r = {};
|
|
36
|
+
let a = !1;
|
|
37
|
+
for (const s of /* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(t)]))
|
|
38
|
+
s in t ? ye(e[s], t[s]) || (r[s] = t[s], a = !0) : (r[s] = void 0, a = !0);
|
|
39
|
+
return a ? r : void 0;
|
|
40
|
+
}, Pt = (e, t) => {
|
|
41
|
+
const r = {}, a = ce(e.device, t.device);
|
|
42
|
+
a && (r.device = a);
|
|
43
|
+
const s = ce(e.user, t.user);
|
|
44
|
+
s && (r.user = s);
|
|
45
|
+
const i = ce(e.params, t.params);
|
|
46
|
+
return i && (r.params = i), ye(e.products, t.products) || (r.products = t.products), e.introductoryOfferEligible !== t.introductoryOfferEligible && (r.introductoryOfferEligible = t.introductoryOfferEligible), e.paywallId !== t.paywallId && (r.paywallId = t.paywallId), e.paywallIdentifier !== t.paywallIdentifier && (r.paywallIdentifier = t.paywallIdentifier), ye(e.experiment, t.experiment) || (r.experiment = t.experiment), r;
|
|
47
|
+
}, Ye = (e) => {
|
|
48
|
+
const t = e.variables.trialPeriodDays, r = typeof t == "number" ? t : typeof t == "string" ? Number(t) : 0;
|
|
49
|
+
return Number.isFinite(r) ? r : 0;
|
|
50
|
+
}, F = (e) => e.introductoryOfferEligible ?? e.products.some((t) => Ye(t) > 0), Ze = (e) => ({
|
|
51
|
+
event_name: "template_variables",
|
|
52
|
+
variables: {
|
|
53
|
+
device: e.device,
|
|
54
|
+
user: e.user,
|
|
55
|
+
params: e.params,
|
|
56
|
+
...e.products.length > 0 ? { products: e.products.map((t) => ({ [t.reference]: t.variables })) } : {}
|
|
57
|
+
}
|
|
58
|
+
}), Xe = (e) => ({
|
|
59
|
+
event_name: "experiment",
|
|
60
|
+
experimentId: e.experiment.experimentId,
|
|
61
|
+
variantId: e.experiment.variantId,
|
|
62
|
+
campaignId: e.experiment.campaignId
|
|
63
|
+
}), Qe = (e) => ({
|
|
64
|
+
event_name: "products",
|
|
65
|
+
products: e.products.map((t) => ({
|
|
66
|
+
product: t.reference,
|
|
67
|
+
productId: t.productId
|
|
68
|
+
}))
|
|
69
|
+
}), et = (e) => ({
|
|
70
|
+
event_name: "template_substitutions_prefix",
|
|
71
|
+
prefix: F(e) ? "freeTrial" : "default"
|
|
72
|
+
}), Et = (e) => ({
|
|
73
|
+
event_name: "paywall_open",
|
|
74
|
+
paywall_id: e.paywallId,
|
|
75
|
+
paywall_identifier: e.paywallIdentifier
|
|
76
|
+
}), Ct = (e) => ({
|
|
77
|
+
event_name: "paywall_close",
|
|
78
|
+
paywall_id: e.paywallId,
|
|
79
|
+
paywall_identifier: e.paywallIdentifier
|
|
80
|
+
}), $t = (e) => [
|
|
81
|
+
Ze(e),
|
|
82
|
+
Xe(e),
|
|
83
|
+
Qe(e),
|
|
84
|
+
et(e),
|
|
85
|
+
Et(e)
|
|
86
|
+
], ee = (e) => ({
|
|
87
|
+
product: e.reference,
|
|
88
|
+
product_identifier: e.productId
|
|
89
|
+
}), Ot = (e) => ({
|
|
90
|
+
event_name: "transaction_start",
|
|
91
|
+
...ee(e)
|
|
92
|
+
}), Mt = (e) => ({
|
|
93
|
+
event_name: "transaction_complete",
|
|
94
|
+
...ee(e)
|
|
95
|
+
}), Tt = (e) => ({
|
|
96
|
+
event_name: "transaction_abandon",
|
|
97
|
+
...ee(e)
|
|
98
|
+
}), Te = (e) => ({
|
|
99
|
+
event_name: "transaction_fail",
|
|
100
|
+
...ee(e)
|
|
101
|
+
}), Dt = () => ({
|
|
102
|
+
event_name: "transaction_restore"
|
|
103
|
+
}), At = (e, t) => ({
|
|
104
|
+
event_name: "freeTrial_start",
|
|
105
|
+
product_identifier: e.productId,
|
|
106
|
+
trial_end_date: t
|
|
107
|
+
}), Rt = () => ({ event_name: "restore_start" }), Lt = () => ({
|
|
108
|
+
event_name: "restore_complete"
|
|
109
|
+
}), De = () => ({ event_name: "restore_fail" }), jt = (e) => ({
|
|
110
|
+
event_name: "permission_result",
|
|
111
|
+
permission_type: e.permissionType,
|
|
112
|
+
request_id: e.requestId,
|
|
113
|
+
status: e.status
|
|
114
|
+
}), Ut = (e) => ({
|
|
115
|
+
event_name: "callback_result",
|
|
116
|
+
request_id: e.requestId,
|
|
117
|
+
name: e.name,
|
|
118
|
+
status: e.status,
|
|
119
|
+
...e.data === void 0 ? {} : { data: e.data }
|
|
120
|
+
}), Ft = () => ({
|
|
121
|
+
event: () => {
|
|
122
|
+
},
|
|
123
|
+
purchase: () => "completed",
|
|
124
|
+
restore: () => "restored",
|
|
125
|
+
close: () => {
|
|
126
|
+
},
|
|
127
|
+
openUrl: () => {
|
|
128
|
+
},
|
|
129
|
+
custom: () => {
|
|
130
|
+
},
|
|
131
|
+
customPlacement: () => {
|
|
132
|
+
},
|
|
133
|
+
permission: () => "granted",
|
|
134
|
+
callback: () => ({ status: "success" })
|
|
135
|
+
}), Bt = 1440 * 60 * 1e3, te = (e, t, r) => {
|
|
136
|
+
new Promise((a) => a(e())).then(t, r);
|
|
137
|
+
}, ne = (e, t) => {
|
|
138
|
+
console.error(`[superwall host] ${e}`, t);
|
|
139
|
+
}, Ht = (e, t, r) => e.products.find((a) => a.reference === t) ?? e.products.find((a) => a.productId === r) ?? {
|
|
140
|
+
reference: t,
|
|
141
|
+
productId: r ?? t,
|
|
142
|
+
variables: {}
|
|
143
|
+
}, Vt = (e, t) => {
|
|
144
|
+
const { delegate: r, send: a, now: s } = e, i = Ht(e.state(), t.product, t.product_identifier);
|
|
145
|
+
a([Ot(i)]), te(
|
|
146
|
+
() => r.purchase(i),
|
|
147
|
+
(o) => {
|
|
148
|
+
if (o === "completed") {
|
|
149
|
+
const u = Ye(i), l = [Mt(i)];
|
|
150
|
+
F(e.state()) && u > 0 && l.push(At(i, s() + u * Bt)), a(l);
|
|
151
|
+
} else a(o === "abandoned" ? [Tt(i)] : [Te(i)]);
|
|
152
|
+
},
|
|
153
|
+
(o) => {
|
|
154
|
+
ne("purchase delegate threw", o), a([Te(i)]);
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
}, Wt = (e) => {
|
|
158
|
+
const { delegate: t, send: r } = e;
|
|
159
|
+
r([Rt()]), te(
|
|
160
|
+
() => t.restore(),
|
|
161
|
+
(a) => {
|
|
162
|
+
r(a === "restored" ? [Dt(), Lt()] : [De()]);
|
|
163
|
+
},
|
|
164
|
+
(a) => {
|
|
165
|
+
ne("restore delegate threw", a), r([De()]);
|
|
166
|
+
}
|
|
167
|
+
);
|
|
168
|
+
}, zt = (e, t) => {
|
|
169
|
+
const { delegate: r, send: a } = e, s = (i) => a([
|
|
170
|
+
jt({
|
|
171
|
+
permissionType: t.permission_type,
|
|
172
|
+
requestId: t.request_id,
|
|
173
|
+
status: i
|
|
174
|
+
})
|
|
175
|
+
]);
|
|
176
|
+
te(
|
|
177
|
+
() => r.permission(t.permission_type),
|
|
178
|
+
s,
|
|
179
|
+
(i) => {
|
|
180
|
+
ne("permission delegate threw", i), s("denied");
|
|
181
|
+
}
|
|
182
|
+
);
|
|
183
|
+
}, qt = (e, t) => {
|
|
184
|
+
const { delegate: r, send: a } = e, s = (i) => a([
|
|
185
|
+
Ut({
|
|
186
|
+
requestId: t.request_id,
|
|
187
|
+
name: t.name,
|
|
188
|
+
status: i.status,
|
|
189
|
+
...i.data === void 0 ? {} : { data: i.data }
|
|
190
|
+
})
|
|
191
|
+
]);
|
|
192
|
+
te(
|
|
193
|
+
() => r.callback(t.name, t.variables ?? {}),
|
|
194
|
+
s,
|
|
195
|
+
(i) => {
|
|
196
|
+
ne("callback delegate threw", i), s({ status: "failure" });
|
|
197
|
+
}
|
|
198
|
+
);
|
|
199
|
+
}, Ae = (e) => JSON.stringify([
|
|
200
|
+
e.device,
|
|
201
|
+
e.user,
|
|
202
|
+
e.params,
|
|
203
|
+
e.products.map((t) => [t.reference, t.variables])
|
|
204
|
+
]), Re = (e) => JSON.stringify(e.products.map((t) => [t.reference, t.productId])), Le = (e) => JSON.stringify(e.experiment), Kt = (e) => {
|
|
205
|
+
let t = Ge(e.state);
|
|
206
|
+
const { delegate: r, send: a } = e, s = {
|
|
207
|
+
state: () => t,
|
|
208
|
+
delegate: r,
|
|
209
|
+
send: a,
|
|
210
|
+
now: e.now ?? Date.now
|
|
211
|
+
}, i = (l) => {
|
|
212
|
+
switch (l.event_name) {
|
|
213
|
+
case "ping":
|
|
214
|
+
a($t(t));
|
|
215
|
+
return;
|
|
216
|
+
case "purchase":
|
|
217
|
+
Vt(s, l);
|
|
218
|
+
return;
|
|
219
|
+
case "restore":
|
|
220
|
+
Wt(s);
|
|
221
|
+
return;
|
|
222
|
+
case "close":
|
|
223
|
+
r.close(), a([Ct(t)]);
|
|
224
|
+
return;
|
|
225
|
+
case "open_url":
|
|
226
|
+
r.openUrl(
|
|
227
|
+
l.url,
|
|
228
|
+
l.browser_type === "payment_sheet" ? "payment_sheet" : "in_app"
|
|
229
|
+
);
|
|
230
|
+
return;
|
|
231
|
+
case "open_url_external":
|
|
232
|
+
r.openUrl(l.url, "external");
|
|
233
|
+
return;
|
|
234
|
+
case "open_deep_link":
|
|
235
|
+
r.openUrl(l.link, "deep_link");
|
|
236
|
+
return;
|
|
237
|
+
case "custom":
|
|
238
|
+
r.custom(l.data);
|
|
239
|
+
return;
|
|
240
|
+
case "custom_placement":
|
|
241
|
+
r.customPlacement(l.name, l.params);
|
|
242
|
+
return;
|
|
243
|
+
case "user_attribute_updated":
|
|
244
|
+
t = Me(t, {
|
|
245
|
+
user: Object.fromEntries(l.attributes.map((m) => [m.key, m.value]))
|
|
246
|
+
});
|
|
247
|
+
return;
|
|
248
|
+
case "request_permission":
|
|
249
|
+
zt(s, l);
|
|
250
|
+
return;
|
|
251
|
+
case "request_callback":
|
|
252
|
+
qt(s, l);
|
|
253
|
+
return;
|
|
254
|
+
default:
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
return {
|
|
259
|
+
get state() {
|
|
260
|
+
return t;
|
|
261
|
+
},
|
|
262
|
+
receive: (l) => {
|
|
263
|
+
for (const m of l)
|
|
264
|
+
r.event(m), i(m);
|
|
265
|
+
},
|
|
266
|
+
update: (l) => {
|
|
267
|
+
const m = t;
|
|
268
|
+
t = Me(t, l);
|
|
269
|
+
const d = [];
|
|
270
|
+
Ae(m) !== Ae(t) && d.push(Ze(t)), Le(m) !== Le(t) && d.push(Xe(t)), Re(m) !== Re(t) && d.push(Qe(t)), F(m) !== F(t) && d.push(et(t)), d.length > 0 && a(d);
|
|
271
|
+
},
|
|
272
|
+
send: a
|
|
273
|
+
};
|
|
274
|
+
}, Jt = () => typeof localStorage < "u" && localStorage.getItem("SW_DEBUG_TRANSPORT") === "true", Gt = {
|
|
275
|
+
WebKit: "#9C27B0",
|
|
276
|
+
Android: "#4CAF50",
|
|
277
|
+
Editor: "#2196F3",
|
|
278
|
+
Transport: "#FF9800"
|
|
279
|
+
}, Yt = (e) => {
|
|
280
|
+
const t = Gt[e], r = (a, s, ...i) => {
|
|
281
|
+
if (!Jt() && a === "debug") return;
|
|
282
|
+
const o = `%c[${e}]%c ${s}`, u = [`color: ${t}; font-weight: bold`, "color: inherit"];
|
|
283
|
+
switch (a) {
|
|
284
|
+
case "error":
|
|
285
|
+
console.error(o, ...u, ...i);
|
|
286
|
+
break;
|
|
287
|
+
case "warn":
|
|
288
|
+
console.warn(o, ...u, ...i);
|
|
289
|
+
break;
|
|
290
|
+
case "info":
|
|
291
|
+
console.info(o, ...u, ...i);
|
|
292
|
+
break;
|
|
293
|
+
default:
|
|
294
|
+
console.log(o, ...u, ...i);
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
return {
|
|
298
|
+
debug: (a, ...s) => r("debug", a, ...s),
|
|
299
|
+
info: (a, ...s) => r("info", a, ...s),
|
|
300
|
+
warn: (a, ...s) => r("warn", a, ...s),
|
|
301
|
+
error: (a, ...s) => r("error", a, ...s)
|
|
302
|
+
};
|
|
303
|
+
};
|
|
304
|
+
var Se = /* @__PURE__ */ ((e) => (e.ToPaywall = "to_paywall", e.FromPaywall = "from_paywall", e.ToPaywallUi = "to_paywall_ui", e.FromPaywallUi = "from_paywall_ui", e))(Se || {});
|
|
305
|
+
const Zt = (e, t) => {
|
|
306
|
+
const r = {
|
|
307
|
+
direction: t,
|
|
308
|
+
version: 1,
|
|
309
|
+
payload: { events: Array.isArray(e) ? e : [e] }
|
|
310
|
+
};
|
|
311
|
+
return JSON.stringify(r);
|
|
312
|
+
}, Xt = () => ({
|
|
313
|
+
parse: (e) => e
|
|
314
|
+
}), Qt = Yt("Transport"), en = (e, t, r = Xt()) => {
|
|
315
|
+
try {
|
|
316
|
+
const a = r.parse(JSON.parse(e));
|
|
317
|
+
if (a.direction !== t)
|
|
318
|
+
throw new Error("Message direction incorrect");
|
|
319
|
+
return a.payload.events;
|
|
320
|
+
} catch (a) {
|
|
321
|
+
return Qt.error("Failed to parse incoming message", { message: e, error: a }), [];
|
|
322
|
+
}
|
|
323
|
+
}, tn = (e) => (t) => {
|
|
324
|
+
e.postMessage(Zt([...t], Se.ToPaywall), "*");
|
|
325
|
+
}, nn = (e, t, r = {}) => {
|
|
326
|
+
const a = r.listen ?? window, s = (i) => {
|
|
327
|
+
if (i.source !== t || typeof i.data != "string") return;
|
|
328
|
+
const o = en(i.data, Se.FromPaywall);
|
|
329
|
+
o.length > 0 && e.receive(o);
|
|
330
|
+
};
|
|
331
|
+
return a.addEventListener("message", s), () => a.removeEventListener("message", s);
|
|
332
|
+
}, rn = (e) => {
|
|
333
|
+
const { target: t, listen: r, ...a } = e, s = Kt({ ...a, send: tn(t) }), i = nn(s, t, r ? { listen: r } : {});
|
|
334
|
+
return { host: s, detach: i };
|
|
335
|
+
}, de = 1440 * 60 * 1e3, pe = 60 * 1e3, tt = -18e3, ge = {
|
|
336
|
+
publicApiKey: "pk_8d21d5122bb23839a2de6c8c76975e74f85b43ab4476c039",
|
|
337
|
+
platform: "iOS",
|
|
338
|
+
appUserId: "44dd573cd1e849a6997a5eaf98298e47",
|
|
339
|
+
aliases: ["$SuperwallAlias:00EB5C40-68A7-4778-B634-F3714D2010B9"],
|
|
340
|
+
vendorId: "86A1F395-D3A3-4A1C-914A-5912EF0363E2",
|
|
341
|
+
appVersion: "8.4",
|
|
342
|
+
osVersion: "15.5.0",
|
|
343
|
+
deviceLocale: "en_US",
|
|
344
|
+
deviceModel: "iPhone10",
|
|
345
|
+
deviceLanguageCode: "en",
|
|
346
|
+
deviceCurrencyCode: "USD",
|
|
347
|
+
deviceCurrencySymbol: "$",
|
|
348
|
+
timezoneOffset: tt,
|
|
349
|
+
radioType: "Wifi",
|
|
350
|
+
interfaceStyle: "Dark",
|
|
351
|
+
isLowPowerModeEnabled: 0,
|
|
352
|
+
bundleId: "com.jakemor.fitnessai",
|
|
353
|
+
isMac: 0,
|
|
354
|
+
totalPaywallViews: 0,
|
|
355
|
+
interfaceType: "iphone"
|
|
356
|
+
}, L = (e) => String(e).padStart(2, "0"), je = (e) => {
|
|
357
|
+
const t = `${e.getUTCFullYear()}-${L(e.getUTCMonth() + 1)}-${L(e.getUTCDate())}`, r = `${L(e.getUTCHours())}:${L(e.getUTCMinutes())}:${L(e.getUTCSeconds())}`;
|
|
358
|
+
return { date: t, time: r, dateTime: `${t}T${r}` };
|
|
359
|
+
}, an = (e, t = tt) => {
|
|
360
|
+
const r = e - 5 * de, a = e - 360 * pe, s = je(new Date(e)), i = je(new Date(e + t * 1e3));
|
|
361
|
+
return {
|
|
362
|
+
daysSinceInstall: Math.floor((e - r) / de),
|
|
363
|
+
minutesSinceInstall: Math.floor((e - r) / pe),
|
|
364
|
+
appInstallDate: new Date(r).toISOString(),
|
|
365
|
+
daysSinceLastPaywallView: Math.floor((e - a) / de),
|
|
366
|
+
minutesSinceLastPaywallView: Math.floor((e - a) / pe),
|
|
367
|
+
utcDate: s.date,
|
|
368
|
+
localDate: i.date,
|
|
369
|
+
utcTime: s.time,
|
|
370
|
+
localTime: i.time,
|
|
371
|
+
utcDateTime: s.dateTime,
|
|
372
|
+
localDateTime: i.dateTime
|
|
373
|
+
};
|
|
374
|
+
}, sn = (e = Date.now()) => ({
|
|
375
|
+
...ge,
|
|
376
|
+
...an(e, ge.timezoneOffset)
|
|
377
|
+
}), on = {
|
|
378
|
+
appUserId: ge.appUserId,
|
|
379
|
+
email: "preview@example.com",
|
|
380
|
+
firstName: "John",
|
|
381
|
+
lastName: "Doe",
|
|
382
|
+
country: "US",
|
|
383
|
+
language: "en"
|
|
384
|
+
}, ln = {
|
|
385
|
+
$event_name: "campaign_trigger",
|
|
386
|
+
event_name: "campaign_trigger",
|
|
387
|
+
$is_standard_event: !1,
|
|
388
|
+
$is_feature_gatable: !1
|
|
389
|
+
}, nt = {
|
|
390
|
+
currencyCode: "USD",
|
|
391
|
+
currencySymbol: "$",
|
|
392
|
+
dailyPrice: "$0.25",
|
|
393
|
+
languageCode: "en",
|
|
394
|
+
locale: "en_US@currency=USD",
|
|
395
|
+
monthlyPrice: "$7.50",
|
|
396
|
+
period: "year",
|
|
397
|
+
periodAlt: "1 yr",
|
|
398
|
+
periodDays: 365,
|
|
399
|
+
periodly: "yearly",
|
|
400
|
+
periodMonths: 12,
|
|
401
|
+
periodWeeks: 52,
|
|
402
|
+
periodYears: 1,
|
|
403
|
+
localizedPeriod: "year",
|
|
404
|
+
price: "$89.99",
|
|
405
|
+
rawPrice: 89.99,
|
|
406
|
+
trialPeriodDays: 7,
|
|
407
|
+
trialPeriodMonths: 0,
|
|
408
|
+
trialPeriodText: "7-day",
|
|
409
|
+
trialPeriodWeeks: 1,
|
|
410
|
+
trialPeriodYears: 0,
|
|
411
|
+
rawTrialPeriodPrice: 0,
|
|
412
|
+
trialPeriodPrice: "$0.00",
|
|
413
|
+
trialPeriodDailyPrice: "$0.00",
|
|
414
|
+
trialPeriodWeeklyPrice: "$0.00",
|
|
415
|
+
trialPeriodMonthlyPrice: "$0.00",
|
|
416
|
+
trialPeriodYearlyPrice: "$0.00",
|
|
417
|
+
weeklyPrice: "$1.73",
|
|
418
|
+
yearlyPrice: "$89.99"
|
|
419
|
+
}, cn = (e) => Object.fromEntries(
|
|
420
|
+
Object.entries(e).filter(([t]) => !t.toLowerCase().includes("trial"))
|
|
421
|
+
);
|
|
422
|
+
cn(nt);
|
|
423
|
+
const y = ({ children: e }) => /* @__PURE__ */ n("svg", { className: "sw-icon", viewBox: "0 0 24 24", "aria-hidden": "true", children: e }), rt = () => /* @__PURE__ */ c(y, { children: [
|
|
424
|
+
/* @__PURE__ */ n("path", { d: "M21 12a9 9 0 1 1-2.64-6.36" }),
|
|
425
|
+
/* @__PURE__ */ n("path", { d: "M21 3v6h-6" })
|
|
426
|
+
] }), G = () => /* @__PURE__ */ c(y, { children: [
|
|
427
|
+
/* @__PURE__ */ n("path", { d: "M15 3h6v6" }),
|
|
428
|
+
/* @__PURE__ */ n("path", { d: "M10 14 21 3" }),
|
|
429
|
+
/* @__PURE__ */ n("path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" })
|
|
430
|
+
] }), dn = () => /* @__PURE__ */ c(y, { children: [
|
|
431
|
+
/* @__PURE__ */ n("circle", { cx: "12", cy: "12", r: "4" }),
|
|
432
|
+
/* @__PURE__ */ n("path", { d: "M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4" })
|
|
433
|
+
] }), pn = () => /* @__PURE__ */ n(y, { children: /* @__PURE__ */ n("path", { d: "M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z" }) }), un = () => /* @__PURE__ */ c(y, { children: [
|
|
434
|
+
/* @__PURE__ */ n("path", { d: "M21 4h-7M10 4H3M21 12h-9M8 12H3M21 20h-5M12 20H3" }),
|
|
435
|
+
/* @__PURE__ */ n("path", { d: "M14 2v4M8 10v4M16 18v4" })
|
|
436
|
+
] }), at = () => /* @__PURE__ */ n(y, { children: /* @__PURE__ */ n("path", { d: "M18 6 6 18M6 6l12 12" }) }), st = () => /* @__PURE__ */ n(y, { children: /* @__PURE__ */ n("path", { d: "m6 9 6 6 6-6" }) }), mn = () => /* @__PURE__ */ c(y, { children: [
|
|
437
|
+
/* @__PURE__ */ n("rect", { x: "3", y: "4", width: "18", height: "16" }),
|
|
438
|
+
/* @__PURE__ */ n("path", { d: "M12 4v16" })
|
|
439
|
+
] }), ue = () => /* @__PURE__ */ c(y, { children: [
|
|
440
|
+
/* @__PURE__ */ n("circle", { cx: "12", cy: "12", r: "9" }),
|
|
441
|
+
/* @__PURE__ */ n("path", { d: "m8.5 12 2.5 2.5 4.5-5" })
|
|
442
|
+
] }), me = () => /* @__PURE__ */ c(y, { children: [
|
|
443
|
+
/* @__PURE__ */ n("path", { d: "M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0Z" }),
|
|
444
|
+
/* @__PURE__ */ n("path", { d: "M12 9v4" }),
|
|
445
|
+
/* @__PURE__ */ n("path", { d: "M12 17h.01" })
|
|
446
|
+
] }), hn = () => /* @__PURE__ */ c(y, { children: [
|
|
447
|
+
/* @__PURE__ */ n("circle", { cx: "12", cy: "12", r: "9" }),
|
|
448
|
+
/* @__PURE__ */ n("path", { d: "M12 11v5" }),
|
|
449
|
+
/* @__PURE__ */ n("path", { d: "M12 8h.01" })
|
|
450
|
+
] }), q = () => /* @__PURE__ */ n(y, { children: /* @__PURE__ */ n("path", { d: "M13 2 4.5 13H11l-1 9 8.5-11H12l1-9Z" }) }), he = () => /* @__PURE__ */ c(y, { children: [
|
|
451
|
+
/* @__PURE__ */ n("circle", { cx: "9", cy: "20", r: "1" }),
|
|
452
|
+
/* @__PURE__ */ n("circle", { cx: "18", cy: "20", r: "1" }),
|
|
453
|
+
/* @__PURE__ */ n("path", { d: "M2 3h2.5l2.2 11.2a2 2 0 0 0 2 1.6h8.4a2 2 0 0 0 2-1.6L21 7H5.4" })
|
|
454
|
+
] }), fn = () => /* @__PURE__ */ c(y, { children: [
|
|
455
|
+
/* @__PURE__ */ n("path", { d: "M18 8a6 6 0 1 0-12 0c0 6-2 8-2 8h16s-2-2-2-8" }),
|
|
456
|
+
/* @__PURE__ */ n("path", { d: "M13.7 21a2 2 0 0 1-3.4 0" })
|
|
457
|
+
] }), bn = () => /* @__PURE__ */ n(y, { children: /* @__PURE__ */ n("path", { d: "m12 3 2.7 5.6 6.1.9-4.4 4.3 1 6.1-5.4-2.9-5.4 2.9 1-6.1L3.2 9.5l6.1-.9L12 3Z" }) }), wn = () => /* @__PURE__ */ c(y, { children: [
|
|
458
|
+
/* @__PURE__ */ n("path", { d: "M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" }),
|
|
459
|
+
/* @__PURE__ */ n("circle", { cx: "12", cy: "7", r: "4" })
|
|
460
|
+
] }), vn = () => /* @__PURE__ */ c(y, { children: [
|
|
461
|
+
/* @__PURE__ */ n("rect", { x: "4", y: "2", width: "10", height: "16", rx: "2" }),
|
|
462
|
+
/* @__PURE__ */ n("path", { d: "M17 12a5 5 0 0 1-5 9H9" }),
|
|
463
|
+
/* @__PURE__ */ n("path", { d: "m11 19-2 2 2 2" })
|
|
464
|
+
] }), X = {
|
|
465
|
+
push: ["link", "build", "assets", "push", "source"],
|
|
466
|
+
publish: ["link", "build", "assets", "push", "source", "promote"],
|
|
467
|
+
promote: ["link", "promote"]
|
|
468
|
+
}, yn = {
|
|
469
|
+
link: "Find paywall",
|
|
470
|
+
build: "Build snapshot",
|
|
471
|
+
assets: "Sync assets",
|
|
472
|
+
push: "Push version",
|
|
473
|
+
source: "Push source",
|
|
474
|
+
promote: "Promote to live"
|
|
475
|
+
}, it = [
|
|
476
|
+
{ name: "push", label: "Push", hint: "New version, nothing live changes" },
|
|
477
|
+
{ name: "publish", label: "Publish", hint: "Push and make it live" },
|
|
478
|
+
{ name: "promote", label: "Promote", hint: "Make the latest push live" }
|
|
479
|
+
], xe = (e) => it.find((t) => t.name === e)?.label ?? e, ot = {
|
|
480
|
+
push: "Pushing…",
|
|
481
|
+
publish: "Publishing…",
|
|
482
|
+
promote: "Promoting…"
|
|
483
|
+
}, gn = ({ state: e }) => e === "active" ? /* @__PURE__ */ n("span", { className: "bg-accent h-2 w-2 animate-pulse" }) : e === "done" ? /* @__PURE__ */ n("span", { className: "bg-accent h-2 w-2" }) : e === "failed" ? /* @__PURE__ */ n("span", { className: "bg-red h-2 w-2" }) : /* @__PURE__ */ n("span", { className: "bg-cream/55 h-2 w-2" }), xn = ({ progress: e }) => {
|
|
484
|
+
const t = X[e.action], r = t.filter((s) => e.steps[s] === "done").length, a = e.error !== void 0;
|
|
485
|
+
return /* @__PURE__ */ c("div", { className: "w-64", children: [
|
|
486
|
+
/* @__PURE__ */ c("div", { className: "border-b border-cream/10 px-3 py-2.5", children: [
|
|
487
|
+
/* @__PURE__ */ n("div", { className: "text-[0.8125rem] font-medium", children: a ? `${xe(e.action)} failed` : r === t.length ? `${xe(e.action)} complete` : ot[e.action] }),
|
|
488
|
+
/* @__PURE__ */ n("div", { className: "mt-2 h-0.5 w-full bg-cream/10", children: /* @__PURE__ */ n(
|
|
489
|
+
"div",
|
|
490
|
+
{
|
|
491
|
+
className: `h-full transition-[width] duration-300 ease-out ${a ? "bg-red" : "bg-accent"}`,
|
|
492
|
+
style: { width: `${r / t.length * 100}%` }
|
|
493
|
+
}
|
|
494
|
+
) })
|
|
495
|
+
] }),
|
|
496
|
+
/* @__PURE__ */ n("ul", { className: "m-0 list-none px-3 py-2", children: t.map((s, i) => {
|
|
497
|
+
const o = e.steps[s] ?? "pending";
|
|
498
|
+
return /* @__PURE__ */ c("li", { className: "flex items-center gap-2.5 py-1.5", children: [
|
|
499
|
+
/* @__PURE__ */ n(
|
|
500
|
+
"span",
|
|
501
|
+
{
|
|
502
|
+
className: `w-4 font-mono text-[0.625rem] tabular-nums ${o === "pending" ? "text-cream/25" : "text-cream/55"}`,
|
|
503
|
+
children: String(i + 1).padStart(2, "0")
|
|
504
|
+
}
|
|
505
|
+
),
|
|
506
|
+
/* @__PURE__ */ n(
|
|
507
|
+
"span",
|
|
508
|
+
{
|
|
509
|
+
className: `flex-1 text-[0.8125rem] ${o === "pending" ? "text-cream/40" : "text-cream"}`,
|
|
510
|
+
children: yn[s]
|
|
511
|
+
}
|
|
512
|
+
),
|
|
513
|
+
/* @__PURE__ */ n(gn, { state: o })
|
|
514
|
+
] }, s);
|
|
515
|
+
}) }),
|
|
516
|
+
e.error && /* @__PURE__ */ n("div", { className: "text-red border-t border-cream/10 px-3 py-2.5 text-xs whitespace-pre-wrap", children: e.error })
|
|
517
|
+
] });
|
|
518
|
+
}, Nn = ({
|
|
519
|
+
progress: e,
|
|
520
|
+
blocked: t,
|
|
521
|
+
onRun: r,
|
|
522
|
+
onBlocked: a
|
|
523
|
+
}) => {
|
|
524
|
+
const [s, i] = p.useState("push"), [o, u] = p.useState(!1), l = p.useRef(null), m = t !== void 0, d = e !== void 0 && e.error === void 0 && X[e.action].some((w) => e.steps[w] !== "done"), b = e !== void 0;
|
|
525
|
+
return p.useEffect(() => {
|
|
526
|
+
if (!o) return;
|
|
527
|
+
const w = (f) => {
|
|
528
|
+
l.current && !f.composedPath().includes(l.current) && u(!1);
|
|
529
|
+
};
|
|
530
|
+
return window.addEventListener("mousedown", w), () => window.removeEventListener("mousedown", w);
|
|
531
|
+
}, [o]), /* @__PURE__ */ c("div", { className: "relative flex", ref: l, children: [
|
|
532
|
+
/* @__PURE__ */ n(
|
|
533
|
+
"button",
|
|
534
|
+
{
|
|
535
|
+
type: "button",
|
|
536
|
+
className: "sw-btn sw-btn--primary disabled:cursor-not-allowed disabled:opacity-40",
|
|
537
|
+
disabled: d,
|
|
538
|
+
title: t,
|
|
539
|
+
onClick: () => m ? a?.() : r(s),
|
|
540
|
+
children: d ? ot[e.action] : xe(s)
|
|
541
|
+
}
|
|
542
|
+
),
|
|
543
|
+
/* @__PURE__ */ n(
|
|
544
|
+
"button",
|
|
545
|
+
{
|
|
546
|
+
type: "button",
|
|
547
|
+
className: "sw-btn sw-btn--primary -ml-px w-6 !px-0 disabled:cursor-not-allowed disabled:opacity-40",
|
|
548
|
+
"aria-label": "Choose action",
|
|
549
|
+
"aria-expanded": o,
|
|
550
|
+
title: t,
|
|
551
|
+
disabled: d,
|
|
552
|
+
onClick: () => u((w) => !w),
|
|
553
|
+
children: /* @__PURE__ */ n(st, {})
|
|
554
|
+
}
|
|
555
|
+
),
|
|
556
|
+
(b || o) && /* @__PURE__ */ n("div", { className: "bg-bar absolute top-full right-0 z-20 mt-1 border border-cream/20", children: b ? /* @__PURE__ */ n(xn, { progress: e }) : /* @__PURE__ */ n("div", { className: "w-64", children: it.map((w) => /* @__PURE__ */ c(
|
|
557
|
+
"button",
|
|
558
|
+
{
|
|
559
|
+
type: "button",
|
|
560
|
+
className: "flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left transition-colors hover:bg-cream/5",
|
|
561
|
+
onClick: () => {
|
|
562
|
+
i(w.name), u(!1);
|
|
563
|
+
},
|
|
564
|
+
children: [
|
|
565
|
+
/* @__PURE__ */ n("span", { className: "text-[0.8125rem] font-medium", children: w.label }),
|
|
566
|
+
/* @__PURE__ */ n("span", { className: "text-xs text-cream/55", children: w.hint })
|
|
567
|
+
]
|
|
568
|
+
},
|
|
569
|
+
w.name
|
|
570
|
+
)) }) })
|
|
571
|
+
] });
|
|
572
|
+
}, fe = ({
|
|
573
|
+
label: e,
|
|
574
|
+
hint: t,
|
|
575
|
+
selected: r,
|
|
576
|
+
onSelect: a
|
|
577
|
+
}) => /* @__PURE__ */ c(
|
|
578
|
+
"button",
|
|
579
|
+
{
|
|
580
|
+
type: "button",
|
|
581
|
+
className: "flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left transition-colors hover:bg-cream/5",
|
|
582
|
+
"aria-current": r || void 0,
|
|
583
|
+
onClick: a,
|
|
584
|
+
children: [
|
|
585
|
+
/* @__PURE__ */ c("span", { className: "flex max-w-full items-center gap-1.5 text-[0.8125rem] font-medium", children: [
|
|
586
|
+
/* @__PURE__ */ n("span", { className: "truncate", children: e }),
|
|
587
|
+
r && /* @__PURE__ */ n("span", { className: "bg-accent size-[5px] shrink-0 rounded-full", "aria-hidden": "true" })
|
|
588
|
+
] }),
|
|
589
|
+
/* @__PURE__ */ n("span", { className: "max-w-full truncate text-xs text-cream/55", children: t })
|
|
590
|
+
]
|
|
591
|
+
}
|
|
592
|
+
), Sn = ({
|
|
593
|
+
active: e,
|
|
594
|
+
options: t,
|
|
595
|
+
onSelect: r
|
|
596
|
+
}) => {
|
|
597
|
+
const [a, s] = p.useState(!1), [i, o] = p.useState(""), u = p.useRef(null);
|
|
598
|
+
p.useEffect(() => {
|
|
599
|
+
if (!a) return;
|
|
600
|
+
const f = (S) => {
|
|
601
|
+
u.current && !S.composedPath().includes(u.current) && s(!1);
|
|
602
|
+
};
|
|
603
|
+
return window.addEventListener("mousedown", f), () => window.removeEventListener("mousedown", f);
|
|
604
|
+
}, [a]), p.useEffect(() => {
|
|
605
|
+
a || o("");
|
|
606
|
+
}, [a]);
|
|
607
|
+
const l = e && (e.type === "live" ? "live" : `surface:${e.surface.kind}/${e.surface.id}`), m = (f) => {
|
|
608
|
+
s(!1), r(f);
|
|
609
|
+
}, d = i.trim().toLowerCase(), b = t.filter((f) => f.key === "live"), w = t.filter((f) => f.key !== "live").filter(
|
|
610
|
+
(f) => d === "" || `${f.label} ${f.hint}`.toLowerCase().includes(d)
|
|
611
|
+
);
|
|
612
|
+
return /* @__PURE__ */ c("div", { className: "relative flex", ref: u, children: [
|
|
613
|
+
/* @__PURE__ */ c(
|
|
614
|
+
"button",
|
|
615
|
+
{
|
|
616
|
+
type: "button",
|
|
617
|
+
className: "sw-btn",
|
|
618
|
+
"aria-pressed": e !== void 0,
|
|
619
|
+
"aria-expanded": a,
|
|
620
|
+
onClick: () => s((f) => !f),
|
|
621
|
+
children: [
|
|
622
|
+
/* @__PURE__ */ n(mn, {}),
|
|
623
|
+
"Compare"
|
|
624
|
+
]
|
|
625
|
+
}
|
|
626
|
+
),
|
|
627
|
+
a && /* @__PURE__ */ c("div", { className: "bg-bar absolute bottom-full left-0 z-20 mb-1 flex w-72 flex-col border border-cream/20", children: [
|
|
628
|
+
/* @__PURE__ */ n("div", { className: "p-2", children: /* @__PURE__ */ n(
|
|
629
|
+
"input",
|
|
630
|
+
{
|
|
631
|
+
className: "sw-input",
|
|
632
|
+
type: "search",
|
|
633
|
+
value: i,
|
|
634
|
+
placeholder: "Search paywalls",
|
|
635
|
+
"aria-label": "Search paywalls",
|
|
636
|
+
onChange: (f) => o(f.target.value)
|
|
637
|
+
}
|
|
638
|
+
) }),
|
|
639
|
+
/* @__PURE__ */ n("div", { className: "max-h-64 overflow-y-auto", children: w.length === 0 ? /* @__PURE__ */ n("span", { className: "block px-3 pt-2 pb-4 text-[0.8125rem] text-cream/45", children: d === "" ? "No other paywalls here." : `Nothing matches “${i.trim()}”.` }) : w.map((f) => /* @__PURE__ */ n(
|
|
640
|
+
fe,
|
|
641
|
+
{
|
|
642
|
+
label: f.label,
|
|
643
|
+
hint: f.hint,
|
|
644
|
+
selected: f.key === l,
|
|
645
|
+
onSelect: () => m(f.target)
|
|
646
|
+
},
|
|
647
|
+
f.key
|
|
648
|
+
)) }),
|
|
649
|
+
/* @__PURE__ */ c("div", { className: "flex flex-col border-t border-cream/10", children: [
|
|
650
|
+
b.map((f) => /* @__PURE__ */ n(
|
|
651
|
+
fe,
|
|
652
|
+
{
|
|
653
|
+
label: f.label,
|
|
654
|
+
hint: f.hint,
|
|
655
|
+
selected: f.key === l,
|
|
656
|
+
onSelect: () => m(f.target)
|
|
657
|
+
},
|
|
658
|
+
f.key
|
|
659
|
+
)),
|
|
660
|
+
/* @__PURE__ */ n(
|
|
661
|
+
fe,
|
|
662
|
+
{
|
|
663
|
+
label: "Off",
|
|
664
|
+
hint: "A single preview",
|
|
665
|
+
selected: e === void 0,
|
|
666
|
+
onSelect: () => m(void 0)
|
|
667
|
+
}
|
|
668
|
+
)
|
|
669
|
+
] })
|
|
670
|
+
] })
|
|
671
|
+
] });
|
|
672
|
+
}, _n = () => /* @__PURE__ */ c("svg", { width: "19", height: "12", viewBox: "0 0 19 12", fill: "currentColor", "aria-hidden": "true", children: [
|
|
673
|
+
/* @__PURE__ */ n("rect", { x: "0", y: "7.5", width: "3.5", height: "4.5", rx: "1" }),
|
|
674
|
+
/* @__PURE__ */ n("rect", { x: "5", y: "5", width: "3.5", height: "7", rx: "1" }),
|
|
675
|
+
/* @__PURE__ */ n("rect", { x: "10", y: "2.5", width: "3.5", height: "9.5", rx: "1" }),
|
|
676
|
+
/* @__PURE__ */ n("rect", { x: "15", y: "0", width: "3.5", height: "12", rx: "1" })
|
|
677
|
+
] }), kn = () => /* @__PURE__ */ c("svg", { width: "27", height: "13", viewBox: "0 0 27 13", "aria-hidden": "true", children: [
|
|
678
|
+
/* @__PURE__ */ n(
|
|
679
|
+
"rect",
|
|
680
|
+
{
|
|
681
|
+
x: "0.5",
|
|
682
|
+
y: "0.5",
|
|
683
|
+
width: "23",
|
|
684
|
+
height: "12",
|
|
685
|
+
rx: "3.8",
|
|
686
|
+
fill: "none",
|
|
687
|
+
stroke: "currentColor",
|
|
688
|
+
strokeOpacity: "0.35"
|
|
689
|
+
}
|
|
690
|
+
),
|
|
691
|
+
/* @__PURE__ */ n("path", { d: "M25 4.5v4a2.17 2.17 0 0 0 0-4Z", fill: "currentColor", fillOpacity: "0.4" }),
|
|
692
|
+
/* @__PURE__ */ n("rect", { x: "2", y: "2", width: "20", height: "9", rx: "2.5", fill: "currentColor" })
|
|
693
|
+
] }), In = () => /* @__PURE__ */ c("span", { className: "flex items-center gap-[7px]", children: [
|
|
694
|
+
/* @__PURE__ */ n(_n, {}),
|
|
695
|
+
/* @__PURE__ */ n("span", { style: { fontSize: 12.5, fontWeight: 700, letterSpacing: "0.02em" }, children: "SW" }),
|
|
696
|
+
/* @__PURE__ */ n(kn, {})
|
|
697
|
+
] }), Pn = ({
|
|
698
|
+
spec: e,
|
|
699
|
+
width: t,
|
|
700
|
+
height: r,
|
|
701
|
+
landscape: a,
|
|
702
|
+
theme: s
|
|
703
|
+
}) => {
|
|
704
|
+
const i = s === "dark" ? "rgba(255,255,255,0.95)" : "rgba(0,0,0,0.95)", o = Math.max(28, e.radius * 0.6);
|
|
705
|
+
return /* @__PURE__ */ c(
|
|
706
|
+
"div",
|
|
707
|
+
{
|
|
708
|
+
className: "pointer-events-none absolute inset-0 select-none",
|
|
709
|
+
style: { width: t, height: r, color: i },
|
|
710
|
+
"data-testid": "device-chrome",
|
|
711
|
+
children: [
|
|
712
|
+
!a && /* @__PURE__ */ c(
|
|
713
|
+
"div",
|
|
714
|
+
{
|
|
715
|
+
className: "absolute inset-x-0 top-0 flex items-center justify-between",
|
|
716
|
+
style: {
|
|
717
|
+
height: e.statusBarHeight,
|
|
718
|
+
paddingLeft: o,
|
|
719
|
+
paddingRight: o,
|
|
720
|
+
fontFamily: '-apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif',
|
|
721
|
+
fontSize: 15,
|
|
722
|
+
fontWeight: 600,
|
|
723
|
+
letterSpacing: "-0.2px"
|
|
724
|
+
},
|
|
725
|
+
children: [
|
|
726
|
+
/* @__PURE__ */ n("span", { children: "9:41" }),
|
|
727
|
+
/* @__PURE__ */ n(In, {})
|
|
728
|
+
]
|
|
729
|
+
}
|
|
730
|
+
),
|
|
731
|
+
e.cutout === "island" && (a ? /* @__PURE__ */ n(
|
|
732
|
+
"div",
|
|
733
|
+
{
|
|
734
|
+
className: "absolute rounded-full bg-black",
|
|
735
|
+
style: { left: 12, top: (r - 124) / 2, width: 36, height: 124 }
|
|
736
|
+
}
|
|
737
|
+
) : /* @__PURE__ */ n(
|
|
738
|
+
"div",
|
|
739
|
+
{
|
|
740
|
+
className: "absolute rounded-full bg-black",
|
|
741
|
+
style: { left: (t - 124) / 2, top: 12, width: 124, height: 36 }
|
|
742
|
+
}
|
|
743
|
+
)),
|
|
744
|
+
e.cutout === "punch" && (a ? /* @__PURE__ */ n(
|
|
745
|
+
"div",
|
|
746
|
+
{
|
|
747
|
+
className: "absolute rounded-full bg-black",
|
|
748
|
+
style: { left: 16, top: (r - 13) / 2, width: 13, height: 13 }
|
|
749
|
+
}
|
|
750
|
+
) : /* @__PURE__ */ n(
|
|
751
|
+
"div",
|
|
752
|
+
{
|
|
753
|
+
className: "absolute rounded-full bg-black",
|
|
754
|
+
style: { left: (t - 13) / 2, top: 15, width: 13, height: 13 }
|
|
755
|
+
}
|
|
756
|
+
)),
|
|
757
|
+
e.homeIndicator && /* @__PURE__ */ n(
|
|
758
|
+
"div",
|
|
759
|
+
{
|
|
760
|
+
className: "absolute rounded-full",
|
|
761
|
+
style: {
|
|
762
|
+
width: Math.round(Math.min(t, r) * 0.36),
|
|
763
|
+
height: 5,
|
|
764
|
+
left: "50%",
|
|
765
|
+
transform: "translateX(-50%)",
|
|
766
|
+
bottom: 8,
|
|
767
|
+
background: i,
|
|
768
|
+
opacity: 0.9
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
)
|
|
772
|
+
]
|
|
773
|
+
}
|
|
774
|
+
);
|
|
775
|
+
}, En = (e, t) => {
|
|
776
|
+
const r = p.useRef(void 0), a = p.useRef({ hostState: e, delegate: t }), s = p.useCallback((i) => {
|
|
777
|
+
if (r.current?.detach(), r.current = void 0, !i?.contentWindow) return;
|
|
778
|
+
const { host: o, detach: u } = rn({
|
|
779
|
+
target: i.contentWindow,
|
|
780
|
+
state: a.current.hostState,
|
|
781
|
+
delegate: a.current.delegate
|
|
782
|
+
});
|
|
783
|
+
r.current = { host: o, detach: u, sent: a.current.hostState };
|
|
784
|
+
}, []);
|
|
785
|
+
return p.useEffect(() => {
|
|
786
|
+
a.current = { hostState: e, delegate: t };
|
|
787
|
+
const i = r.current;
|
|
788
|
+
i && (i.host.update(Pt(i.sent, e)), i.sent = e);
|
|
789
|
+
}, [e, t]), s;
|
|
790
|
+
}, lt = ({ hostState: e, delegate: t, ...r }) => /* @__PURE__ */ n("iframe", { ...r, ref: En(e, t) }), Ue = 96, Cn = 250, ct = (e, t, r) => {
|
|
791
|
+
const [a, s] = p.useState(1);
|
|
792
|
+
return p.useLayoutEffect(() => {
|
|
793
|
+
const i = e.current;
|
|
794
|
+
if (!i) return;
|
|
795
|
+
const o = () => {
|
|
796
|
+
const l = i.getBoundingClientRect(), m = Math.min(
|
|
797
|
+
1,
|
|
798
|
+
(l.width - Ue) / t,
|
|
799
|
+
(l.height - Ue) / r
|
|
800
|
+
);
|
|
801
|
+
s(Math.max(0.1, m));
|
|
802
|
+
};
|
|
803
|
+
if (o(), typeof ResizeObserver > "u") return;
|
|
804
|
+
const u = new ResizeObserver(o);
|
|
805
|
+
return u.observe(i), () => u.disconnect();
|
|
806
|
+
}, [e, t, r]), a;
|
|
807
|
+
}, $n = ({
|
|
808
|
+
width: e,
|
|
809
|
+
height: t,
|
|
810
|
+
stageRef: r,
|
|
811
|
+
children: a
|
|
812
|
+
}) => {
|
|
813
|
+
const s = ct(r, e, t);
|
|
814
|
+
return /* @__PURE__ */ n(
|
|
815
|
+
"div",
|
|
816
|
+
{
|
|
817
|
+
className: "flex flex-none items-center justify-center overflow-hidden border border-dashed border-cream/20 p-6 text-center text-sm text-cream/55",
|
|
818
|
+
"data-testid": "device-placeholder",
|
|
819
|
+
style: { width: e * s, height: t * s },
|
|
820
|
+
children: a
|
|
821
|
+
}
|
|
822
|
+
);
|
|
823
|
+
}, On = ({
|
|
824
|
+
width: e,
|
|
825
|
+
height: t,
|
|
826
|
+
title: r,
|
|
827
|
+
src: a,
|
|
828
|
+
hostState: s,
|
|
829
|
+
delegate: i,
|
|
830
|
+
stageRef: o,
|
|
831
|
+
reloadKey: u = 0,
|
|
832
|
+
chrome: l,
|
|
833
|
+
landscape: m = !1,
|
|
834
|
+
theme: d = "light"
|
|
835
|
+
}) => {
|
|
836
|
+
const b = ct(o, e, t), w = p.useRef(0), [f, S] = p.useState([{ src: a, generation: 0, ready: !0 }]), D = p.useRef(!1);
|
|
837
|
+
p.useEffect(() => {
|
|
838
|
+
if (!D.current) {
|
|
839
|
+
D.current = !0;
|
|
840
|
+
return;
|
|
841
|
+
}
|
|
842
|
+
w.current += 1;
|
|
843
|
+
const g = { src: a, generation: w.current, ready: !1 };
|
|
844
|
+
S((C) => [...C.filter((x) => x.ready).slice(-1), g]);
|
|
845
|
+
}, [a, u]);
|
|
846
|
+
const H = (g) => {
|
|
847
|
+
window.setTimeout(() => {
|
|
848
|
+
S((C) => C.some((x) => x.generation === g) ? C.map((x) => x.generation === g ? { ...x, ready: !0 } : x).filter((x) => x.generation >= g) : C);
|
|
849
|
+
}, Cn);
|
|
850
|
+
}, P = f.findLast((g) => g.ready), re = l ? l.radius * b : 0;
|
|
851
|
+
return /* @__PURE__ */ c(
|
|
852
|
+
"div",
|
|
853
|
+
{
|
|
854
|
+
className: `bg-panel relative flex-none overflow-hidden ${l ? "shadow-[0_0_0_1px] shadow-cream/25" : "border border-cream/20"}`,
|
|
855
|
+
"data-testid": "device-frame",
|
|
856
|
+
style: { width: e * b, height: t * b, borderRadius: re },
|
|
857
|
+
children: [
|
|
858
|
+
f.map((g) => /* @__PURE__ */ n(
|
|
859
|
+
lt,
|
|
860
|
+
{
|
|
861
|
+
hostState: s,
|
|
862
|
+
delegate: i,
|
|
863
|
+
className: `absolute inset-0 origin-top-left border-0 bg-white transition-opacity duration-150 ${g === P ? "opacity-100" : "opacity-0"}`,
|
|
864
|
+
title: r,
|
|
865
|
+
src: g.src,
|
|
866
|
+
width: e,
|
|
867
|
+
height: t,
|
|
868
|
+
style: { transform: `scale(${b})` },
|
|
869
|
+
onLoad: () => {
|
|
870
|
+
g.ready || H(g.generation);
|
|
871
|
+
}
|
|
872
|
+
},
|
|
873
|
+
g.generation
|
|
874
|
+
)),
|
|
875
|
+
l && /* @__PURE__ */ n(
|
|
876
|
+
"div",
|
|
877
|
+
{
|
|
878
|
+
className: "pointer-events-none absolute inset-0 origin-top-left",
|
|
879
|
+
style: { width: e, height: t, transform: `scale(${b})` },
|
|
880
|
+
children: /* @__PURE__ */ n(
|
|
881
|
+
Pn,
|
|
882
|
+
{
|
|
883
|
+
spec: l,
|
|
884
|
+
width: e,
|
|
885
|
+
height: t,
|
|
886
|
+
landscape: m,
|
|
887
|
+
theme: d
|
|
888
|
+
}
|
|
889
|
+
)
|
|
890
|
+
}
|
|
891
|
+
)
|
|
892
|
+
]
|
|
893
|
+
}
|
|
894
|
+
);
|
|
895
|
+
}, Mn = ({
|
|
896
|
+
paywall: e,
|
|
897
|
+
missing: t,
|
|
898
|
+
onDismiss: r
|
|
899
|
+
}) => /* @__PURE__ */ n(
|
|
900
|
+
"div",
|
|
901
|
+
{
|
|
902
|
+
className: "fixed inset-0 z-50 flex items-center justify-center bg-ink/70 p-6",
|
|
903
|
+
role: "dialog",
|
|
904
|
+
"aria-modal": "true",
|
|
905
|
+
"aria-labelledby": "sw-missing-products",
|
|
906
|
+
children: /* @__PURE__ */ c("div", { className: "bg-panel flex w-full max-w-md flex-col gap-4 border border-cream/20 p-5", children: [
|
|
907
|
+
/* @__PURE__ */ c("div", { className: "flex flex-col gap-1.5", children: [
|
|
908
|
+
/* @__PURE__ */ n("span", { id: "sw-missing-products", className: "text-[0.9375rem] font-medium text-cream", children: t.length === 1 ? "A product is missing" : `${t.length} products are missing` }),
|
|
909
|
+
/* @__PURE__ */ n("span", { className: "text-[0.8125rem] leading-relaxed text-cream/60", children: `${e} declares ${t.length === 1 ? "a product" : "products"} Superwall has no record of. Every variable on ${t.length === 1 ? "it" : "them"} will be undefined here and on device.` })
|
|
910
|
+
] }),
|
|
911
|
+
/* @__PURE__ */ n("ul", { className: "flex flex-col gap-1.5 border-y border-cream/10 py-3", children: t.map((a) => /* @__PURE__ */ c("li", { className: "flex items-baseline justify-between gap-3", children: [
|
|
912
|
+
/* @__PURE__ */ n("span", { className: "font-mono text-[11px] text-cream/70", children: a.reference }),
|
|
913
|
+
/* @__PURE__ */ n("span", { className: "truncate font-mono text-[11px] text-cream/40", children: a.identifier })
|
|
914
|
+
] }, a.reference)) }),
|
|
915
|
+
/* @__PURE__ */ c("span", { className: "text-xs text-cream/45", children: [
|
|
916
|
+
"Add ",
|
|
917
|
+
t.length === 1 ? "it" : "them",
|
|
918
|
+
" in the Superwall dashboard, or point the config at",
|
|
919
|
+
t.length === 1 ? " a product" : " products",
|
|
920
|
+
" that exists. Pushing is refused until then."
|
|
921
|
+
] }),
|
|
922
|
+
/* @__PURE__ */ n("button", { type: "button", className: "sw-btn sw-btn--primary self-end", onClick: r, children: "View anyway" })
|
|
923
|
+
] })
|
|
924
|
+
}
|
|
925
|
+
), Tn = /* @__PURE__ */ new Set([
|
|
926
|
+
"ping",
|
|
927
|
+
"page_view",
|
|
928
|
+
"page_styles",
|
|
929
|
+
"has_set_dom",
|
|
930
|
+
"haptic_feedback",
|
|
931
|
+
"var_click",
|
|
932
|
+
"purchase",
|
|
933
|
+
"restore"
|
|
934
|
+
]), Dn = {
|
|
935
|
+
open_url: ["url"],
|
|
936
|
+
open_url_external: ["url"],
|
|
937
|
+
open_deep_link: ["link"],
|
|
938
|
+
custom_placement: ["name"],
|
|
939
|
+
custom: ["name", "data"],
|
|
940
|
+
request_permission: ["permission_type"],
|
|
941
|
+
request_callback: ["name"],
|
|
942
|
+
schedule_notification: ["title"],
|
|
943
|
+
discount_redemption_result: ["code"]
|
|
944
|
+
}, An = /* @__PURE__ */ new Set(["close"]), Rn = /* @__PURE__ */ new Set([
|
|
945
|
+
"stripe_checkout_complete",
|
|
946
|
+
"post_checkout_complete"
|
|
947
|
+
]), Ln = (e) => {
|
|
948
|
+
for (const t of Dn[e.event_name] ?? []) {
|
|
949
|
+
const r = Reflect.get(e, t);
|
|
950
|
+
if (typeof r == "string" && r.length > 0) return r;
|
|
951
|
+
}
|
|
952
|
+
}, jn = (e) => {
|
|
953
|
+
if (!Tn.has(e.event_name))
|
|
954
|
+
return {
|
|
955
|
+
action: e.event_name,
|
|
956
|
+
subject: Ln(e),
|
|
957
|
+
tone: An.has(e.event_name) ? "warning" : Rn.has(e.event_name) ? "success" : "info"
|
|
958
|
+
};
|
|
959
|
+
}, Un = {
|
|
960
|
+
info: "text-cream/45",
|
|
961
|
+
success: "text-accent",
|
|
962
|
+
warning: "text-red"
|
|
963
|
+
}, Fn = {
|
|
964
|
+
purchase: he,
|
|
965
|
+
transaction_complete: ue,
|
|
966
|
+
freeTrial_start: ue,
|
|
967
|
+
transaction_abandon: me,
|
|
968
|
+
transaction_fail: me,
|
|
969
|
+
close: at,
|
|
970
|
+
restore: rt,
|
|
971
|
+
restore_complete: ue,
|
|
972
|
+
restore_fail: me,
|
|
973
|
+
open_url: G,
|
|
974
|
+
open_url_external: G,
|
|
975
|
+
open_deep_link: G,
|
|
976
|
+
initiate_web_checkout: he,
|
|
977
|
+
open_payment_sheet: he,
|
|
978
|
+
custom_placement: q,
|
|
979
|
+
custom: q,
|
|
980
|
+
request_permission: q,
|
|
981
|
+
request_callback: q,
|
|
982
|
+
schedule_notification: fn,
|
|
983
|
+
request_store_review: bn,
|
|
984
|
+
user_attribute_updated: wn
|
|
985
|
+
}, B = ({ children: e }) => /* @__PURE__ */ n("span", { className: "bg-accent/15 text-accent px-1.5 py-px font-mono text-xs whitespace-nowrap", children: e }), _e = ({
|
|
986
|
+
action: e,
|
|
987
|
+
tone: t,
|
|
988
|
+
children: r,
|
|
989
|
+
actions: a
|
|
990
|
+
}) => {
|
|
991
|
+
const s = Fn[e] ?? hn;
|
|
992
|
+
return /* @__PURE__ */ n("div", { className: "bg-panel font-sans w-[344px] border border-cream/15 p-3 shadow-[0_8px_24px_-8px] shadow-black/60", children: /* @__PURE__ */ c("div", { className: "grid grid-cols-[14px_1fr] items-start gap-x-2.5", children: [
|
|
993
|
+
/* @__PURE__ */ n("span", { className: `flex h-5 items-center justify-center ${Un[t]}`, children: /* @__PURE__ */ n(s, {}) }),
|
|
994
|
+
/* @__PURE__ */ n("span", { className: "text-[0.8125rem] leading-5 font-medium text-cream", children: r }),
|
|
995
|
+
a && /* @__PURE__ */ n("div", { className: "col-start-2 mt-2.5 flex justify-end gap-2", children: a })
|
|
996
|
+
] }) });
|
|
997
|
+
}, Bn = ({ notice: e }) => /* @__PURE__ */ c(_e, { action: e.action, tone: e.tone, children: [
|
|
998
|
+
"Tap triggered a ",
|
|
999
|
+
/* @__PURE__ */ n(B, { children: e.action }),
|
|
1000
|
+
e.subject ? /* @__PURE__ */ c(Z, { children: [
|
|
1001
|
+
" for ",
|
|
1002
|
+
/* @__PURE__ */ n(B, { children: e.subject })
|
|
1003
|
+
] }) : " action",
|
|
1004
|
+
"."
|
|
1005
|
+
] }), Hn = ({ choice: e, subject: t }) => /* @__PURE__ */ c(_e, { action: e.action, tone: e.tone, children: [
|
|
1006
|
+
/* @__PURE__ */ n(B, { children: t }),
|
|
1007
|
+
" ",
|
|
1008
|
+
e.done
|
|
1009
|
+
] }), Vn = ({
|
|
1010
|
+
action: e,
|
|
1011
|
+
verb: t,
|
|
1012
|
+
subject: r,
|
|
1013
|
+
choices: a,
|
|
1014
|
+
onAnswer: s
|
|
1015
|
+
}) => /* @__PURE__ */ c(
|
|
1016
|
+
_e,
|
|
1017
|
+
{
|
|
1018
|
+
action: e,
|
|
1019
|
+
tone: "info",
|
|
1020
|
+
actions: a.map((i) => /* @__PURE__ */ n(
|
|
1021
|
+
"button",
|
|
1022
|
+
{
|
|
1023
|
+
type: "button",
|
|
1024
|
+
className: i.primary ? "sw-btn sw-btn--primary" : "sw-btn",
|
|
1025
|
+
onClick: () => s(i),
|
|
1026
|
+
children: i.label
|
|
1027
|
+
},
|
|
1028
|
+
i.label
|
|
1029
|
+
)),
|
|
1030
|
+
children: [
|
|
1031
|
+
"Tap triggered a ",
|
|
1032
|
+
/* @__PURE__ */ n(B, { children: t }),
|
|
1033
|
+
" for ",
|
|
1034
|
+
/* @__PURE__ */ n(B, { children: r }),
|
|
1035
|
+
"."
|
|
1036
|
+
]
|
|
1037
|
+
}
|
|
1038
|
+
), Wn = [
|
|
1039
|
+
{
|
|
1040
|
+
label: "Abandon",
|
|
1041
|
+
value: "abandoned",
|
|
1042
|
+
action: "transaction_abandon",
|
|
1043
|
+
tone: "warning",
|
|
1044
|
+
done: "purchase abandoned."
|
|
1045
|
+
},
|
|
1046
|
+
{
|
|
1047
|
+
label: "Fail",
|
|
1048
|
+
value: "failed",
|
|
1049
|
+
action: "transaction_fail",
|
|
1050
|
+
tone: "warning",
|
|
1051
|
+
done: "purchase failed."
|
|
1052
|
+
},
|
|
1053
|
+
{
|
|
1054
|
+
label: "Complete",
|
|
1055
|
+
value: "completed",
|
|
1056
|
+
primary: !0,
|
|
1057
|
+
action: "transaction_complete",
|
|
1058
|
+
tone: "success",
|
|
1059
|
+
done: "purchase completed."
|
|
1060
|
+
}
|
|
1061
|
+
], zn = [
|
|
1062
|
+
{
|
|
1063
|
+
label: "Nothing",
|
|
1064
|
+
value: "failed",
|
|
1065
|
+
action: "restore_fail",
|
|
1066
|
+
tone: "warning",
|
|
1067
|
+
done: "nothing to restore."
|
|
1068
|
+
},
|
|
1069
|
+
{
|
|
1070
|
+
label: "Restore",
|
|
1071
|
+
value: "restored",
|
|
1072
|
+
primary: !0,
|
|
1073
|
+
action: "restore_complete",
|
|
1074
|
+
tone: "success",
|
|
1075
|
+
done: "restored."
|
|
1076
|
+
}
|
|
1077
|
+
], qn = [
|
|
1078
|
+
{
|
|
1079
|
+
label: "Deny",
|
|
1080
|
+
value: "denied",
|
|
1081
|
+
action: "request_permission",
|
|
1082
|
+
tone: "warning",
|
|
1083
|
+
done: "denied."
|
|
1084
|
+
},
|
|
1085
|
+
{
|
|
1086
|
+
label: "Grant",
|
|
1087
|
+
value: "granted",
|
|
1088
|
+
primary: !0,
|
|
1089
|
+
action: "request_permission",
|
|
1090
|
+
tone: "success",
|
|
1091
|
+
done: "granted."
|
|
1092
|
+
}
|
|
1093
|
+
], Kn = [
|
|
1094
|
+
{ label: "Fail", value: "failure", action: "request_callback", tone: "warning", done: "failed." },
|
|
1095
|
+
{
|
|
1096
|
+
label: "Succeed",
|
|
1097
|
+
value: "success",
|
|
1098
|
+
primary: !0,
|
|
1099
|
+
action: "request_callback",
|
|
1100
|
+
tone: "success",
|
|
1101
|
+
done: "succeeded."
|
|
1102
|
+
}
|
|
1103
|
+
];
|
|
1104
|
+
let Jn = 0;
|
|
1105
|
+
const K = (e, t, r, a) => new Promise((s) => {
|
|
1106
|
+
const i = `${e}-${Jn += 1}`;
|
|
1107
|
+
U.custom(
|
|
1108
|
+
() => /* @__PURE__ */ n(
|
|
1109
|
+
Vn,
|
|
1110
|
+
{
|
|
1111
|
+
action: e,
|
|
1112
|
+
verb: t,
|
|
1113
|
+
subject: r,
|
|
1114
|
+
choices: a,
|
|
1115
|
+
onAnswer: (o) => {
|
|
1116
|
+
U.dismiss(i), U.custom(() => /* @__PURE__ */ n(Hn, { choice: o, subject: r })), s(o.value);
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
),
|
|
1120
|
+
{ id: i, duration: Number.POSITIVE_INFINITY }
|
|
1121
|
+
);
|
|
1122
|
+
}), Gn = () => ({
|
|
1123
|
+
event: (e) => {
|
|
1124
|
+
const t = jn(e);
|
|
1125
|
+
t && U.custom(() => /* @__PURE__ */ n(Bn, { notice: t }));
|
|
1126
|
+
},
|
|
1127
|
+
purchase: (e) => K("purchase", "purchase", e.reference, Wn),
|
|
1128
|
+
restore: () => K("restore", "restore", "purchases", zn),
|
|
1129
|
+
close: () => {
|
|
1130
|
+
},
|
|
1131
|
+
openUrl: () => {
|
|
1132
|
+
},
|
|
1133
|
+
custom: () => {
|
|
1134
|
+
},
|
|
1135
|
+
customPlacement: () => {
|
|
1136
|
+
},
|
|
1137
|
+
permission: (e) => K("request_permission", "permission", e, qn),
|
|
1138
|
+
callback: (e) => K("request_callback", "callback", e, Kn).then((t) => ({ status: t }))
|
|
1139
|
+
}), Yn = () => p.useMemo(Gn, []), Zn = ({
|
|
1140
|
+
surfaceKey: e,
|
|
1141
|
+
raised: t = !1
|
|
1142
|
+
}) => (p.useEffect(() => {
|
|
1143
|
+
U.dismiss();
|
|
1144
|
+
}, [e]), /* @__PURE__ */ n(
|
|
1145
|
+
_t,
|
|
1146
|
+
{
|
|
1147
|
+
position: "top-center",
|
|
1148
|
+
swipeDirections: ["top"],
|
|
1149
|
+
offset: t ? 84 : 52,
|
|
1150
|
+
gap: 8,
|
|
1151
|
+
visibleToasts: 3,
|
|
1152
|
+
style: { zIndex: 5 },
|
|
1153
|
+
toastOptions: { unstyled: !0, classNames: { toast: "w-full" } }
|
|
1154
|
+
}
|
|
1155
|
+
)), Xn = ({
|
|
1156
|
+
value: e,
|
|
1157
|
+
options: t,
|
|
1158
|
+
onChange: r,
|
|
1159
|
+
label: a
|
|
1160
|
+
}) => /* @__PURE__ */ n("div", { className: "sw-segmented", role: "group", "aria-label": a, children: t.map((s) => /* @__PURE__ */ n(
|
|
1161
|
+
"button",
|
|
1162
|
+
{
|
|
1163
|
+
type: "button",
|
|
1164
|
+
"aria-pressed": s.value === e,
|
|
1165
|
+
onClick: () => r(s.value),
|
|
1166
|
+
children: s.label
|
|
1167
|
+
},
|
|
1168
|
+
s.value
|
|
1169
|
+
)) }), Fe = ({
|
|
1170
|
+
value: e,
|
|
1171
|
+
options: t,
|
|
1172
|
+
onChange: r,
|
|
1173
|
+
label: a
|
|
1174
|
+
}) => /* @__PURE__ */ n(
|
|
1175
|
+
"select",
|
|
1176
|
+
{
|
|
1177
|
+
className: "sw-select",
|
|
1178
|
+
"aria-label": a,
|
|
1179
|
+
value: e,
|
|
1180
|
+
onChange: (s) => r(s.target.value),
|
|
1181
|
+
children: t.map((s) => /* @__PURE__ */ n("option", { value: s.value, children: s.label }, s.value))
|
|
1182
|
+
}
|
|
1183
|
+
), Qn = ({
|
|
1184
|
+
checked: e,
|
|
1185
|
+
onChange: t,
|
|
1186
|
+
label: r
|
|
1187
|
+
}) => /* @__PURE__ */ n(
|
|
1188
|
+
"button",
|
|
1189
|
+
{
|
|
1190
|
+
type: "button",
|
|
1191
|
+
role: "switch",
|
|
1192
|
+
"aria-checked": e,
|
|
1193
|
+
"aria-label": r,
|
|
1194
|
+
className: "sw-switch",
|
|
1195
|
+
onClick: () => t(!e)
|
|
1196
|
+
}
|
|
1197
|
+
), er = ({
|
|
1198
|
+
open: e,
|
|
1199
|
+
title: t,
|
|
1200
|
+
onClose: r,
|
|
1201
|
+
children: a
|
|
1202
|
+
}) => /* @__PURE__ */ n(
|
|
1203
|
+
"aside",
|
|
1204
|
+
{
|
|
1205
|
+
className: `flex-none overflow-hidden transition-[width] duration-200 ease-out motion-reduce:transition-none ${e ? "w-72" : "w-0"}`,
|
|
1206
|
+
"aria-hidden": !e,
|
|
1207
|
+
inert: !e,
|
|
1208
|
+
children: /* @__PURE__ */ c("div", { className: "bg-bar flex h-full w-72 flex-col border-l border-cream/10", children: [
|
|
1209
|
+
/* @__PURE__ */ c("div", { className: "flex h-11 flex-none items-center justify-between border-b border-cream/10 px-3", children: [
|
|
1210
|
+
/* @__PURE__ */ n("span", { className: "text-[0.8125rem] font-medium text-cream", children: t }),
|
|
1211
|
+
/* @__PURE__ */ n(
|
|
1212
|
+
"button",
|
|
1213
|
+
{
|
|
1214
|
+
type: "button",
|
|
1215
|
+
className: "sw-btn sw-btn--icon border-transparent",
|
|
1216
|
+
"aria-label": `Close ${t.toLowerCase()}`,
|
|
1217
|
+
onClick: r,
|
|
1218
|
+
children: /* @__PURE__ */ n(at, {})
|
|
1219
|
+
}
|
|
1220
|
+
)
|
|
1221
|
+
] }),
|
|
1222
|
+
/* @__PURE__ */ n("div", { className: "flex-1 overflow-y-auto px-4 py-2", children: a })
|
|
1223
|
+
] })
|
|
1224
|
+
}
|
|
1225
|
+
), tr = ({ children: e }) => /* @__PURE__ */ n("div", { className: "bg-bar z-10 flex min-h-14 flex-none flex-wrap items-center justify-center gap-3 border-t border-cream/10 px-4 py-2.5", children: e }), J = ({ label: e, children: t }) => /* @__PURE__ */ c("div", { className: "flex items-center gap-2.5", children: [
|
|
1226
|
+
/* @__PURE__ */ n("span", { className: "sw-tool-label", children: e }),
|
|
1227
|
+
t
|
|
1228
|
+
] }), Be = () => /* @__PURE__ */ n("span", { className: "h-6 w-px bg-cream/10" }), dt = ({
|
|
1229
|
+
title: e,
|
|
1230
|
+
onHome: t,
|
|
1231
|
+
actions: r,
|
|
1232
|
+
inset: a = !1,
|
|
1233
|
+
label: s = "Studio"
|
|
1234
|
+
}) => /* @__PURE__ */ n("header", { className: "relative z-10 flex h-11 flex-none items-center border-b border-cream/10 bg-ink", children: /* @__PURE__ */ c(
|
|
1235
|
+
"div",
|
|
1236
|
+
{
|
|
1237
|
+
className: `flex h-full w-full items-center px-3 ${a ? "mx-auto max-w-[1080px] sm:px-0" : ""}`,
|
|
1238
|
+
children: [
|
|
1239
|
+
/* @__PURE__ */ c(
|
|
1240
|
+
"a",
|
|
1241
|
+
{
|
|
1242
|
+
className: "flex items-center gap-3 text-[0.9375rem] font-semibold tracking-[0.01em]",
|
|
1243
|
+
href: "/",
|
|
1244
|
+
onClick: (i) => {
|
|
1245
|
+
i.metaKey || i.ctrlKey || (i.preventDefault(), t());
|
|
1246
|
+
},
|
|
1247
|
+
children: [
|
|
1248
|
+
/* @__PURE__ */ c("span", { className: "whitespace-nowrap", children: [
|
|
1249
|
+
/* @__PURE__ */ n("em", { className: "text-accent not-italic", children: "$UPER" }),
|
|
1250
|
+
"WALL"
|
|
1251
|
+
] }),
|
|
1252
|
+
/* @__PURE__ */ n("span", { className: "h-4 w-px bg-cream/20" }),
|
|
1253
|
+
/* @__PURE__ */ n("span", { className: "font-normal", children: s })
|
|
1254
|
+
]
|
|
1255
|
+
}
|
|
1256
|
+
),
|
|
1257
|
+
/* @__PURE__ */ n("span", { className: "absolute left-1/2 hidden -translate-x-1/2 text-sm font-medium whitespace-nowrap sm:block", children: e }),
|
|
1258
|
+
/* @__PURE__ */ n("div", { className: "ml-auto flex items-center gap-2", children: r })
|
|
1259
|
+
]
|
|
1260
|
+
}
|
|
1261
|
+
) }), nr = [
|
|
1262
|
+
{ key: "user", label: "User", blurb: "Attributes your app sets" },
|
|
1263
|
+
{ key: "device", label: "Device", blurb: "Platform, locale, OS — the SDK fills these in" },
|
|
1264
|
+
{ key: "params", label: "Params", blurb: "Passed in at the placement" },
|
|
1265
|
+
{ key: "products", label: "Products", blurb: "Store data for this paywall's products" }
|
|
1266
|
+
], He = (e) => e == null ? "" : typeof e == "string" ? e : JSON.stringify(e), rr = (e) => e === "true" ? !0 : e === "false" ? !1 : e.trim() !== "" && Number.isFinite(Number(e)) ? Number(e) : e, be = (e) => e.slice(e.indexOf(".") + 1), ar = ({
|
|
1267
|
+
row: e,
|
|
1268
|
+
override: t,
|
|
1269
|
+
onChange: r
|
|
1270
|
+
}) => {
|
|
1271
|
+
const a = t !== void 0, s = a ? t : e.value;
|
|
1272
|
+
return /* @__PURE__ */ c("div", { className: "flex flex-col gap-1 py-1.5", children: [
|
|
1273
|
+
/* @__PURE__ */ c("div", { className: "flex items-baseline justify-between gap-2", children: [
|
|
1274
|
+
/* @__PURE__ */ n("span", { className: "truncate font-mono text-[11px] text-cream/70", children: e.path }),
|
|
1275
|
+
a && /* @__PURE__ */ n(
|
|
1276
|
+
"button",
|
|
1277
|
+
{
|
|
1278
|
+
type: "button",
|
|
1279
|
+
className: "shrink-0 text-[11px] text-cream/40 hover:text-cream",
|
|
1280
|
+
"aria-label": `Reset ${e.path}`,
|
|
1281
|
+
onClick: () => r(void 0),
|
|
1282
|
+
children: "Reset"
|
|
1283
|
+
}
|
|
1284
|
+
)
|
|
1285
|
+
] }),
|
|
1286
|
+
typeof s == "boolean" ? /* @__PURE__ */ n("span", { className: "flex h-7 items-center", children: /* @__PURE__ */ n(
|
|
1287
|
+
"button",
|
|
1288
|
+
{
|
|
1289
|
+
type: "button",
|
|
1290
|
+
className: "sw-switch",
|
|
1291
|
+
role: "switch",
|
|
1292
|
+
"aria-checked": s,
|
|
1293
|
+
"aria-label": e.path,
|
|
1294
|
+
onClick: () => r(!s)
|
|
1295
|
+
}
|
|
1296
|
+
) }) : /* @__PURE__ */ n(
|
|
1297
|
+
"input",
|
|
1298
|
+
{
|
|
1299
|
+
className: "sw-input w-full",
|
|
1300
|
+
"aria-label": e.path,
|
|
1301
|
+
value: He(s),
|
|
1302
|
+
placeholder: He(e.value),
|
|
1303
|
+
onChange: (i) => {
|
|
1304
|
+
const o = i.target.value;
|
|
1305
|
+
r(o === "" ? void 0 : rr(o));
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
)
|
|
1309
|
+
] });
|
|
1310
|
+
}, sr = ({
|
|
1311
|
+
label: e,
|
|
1312
|
+
blurb: t,
|
|
1313
|
+
rows: r,
|
|
1314
|
+
overrideOf: a,
|
|
1315
|
+
onChange: s
|
|
1316
|
+
}) => {
|
|
1317
|
+
const [i, o] = p.useState(!1), u = r.filter((l) => a(l.path) !== void 0).length;
|
|
1318
|
+
return /* @__PURE__ */ c("section", { className: "border-b border-cream/10 last:border-b-0", children: [
|
|
1319
|
+
/* @__PURE__ */ c(
|
|
1320
|
+
"button",
|
|
1321
|
+
{
|
|
1322
|
+
type: "button",
|
|
1323
|
+
className: "flex w-full items-center gap-2 py-3 text-left",
|
|
1324
|
+
"aria-expanded": i,
|
|
1325
|
+
onClick: () => o((l) => !l),
|
|
1326
|
+
children: [
|
|
1327
|
+
/* @__PURE__ */ c("span", { className: "flex min-w-0 flex-col gap-0.5", children: [
|
|
1328
|
+
/* @__PURE__ */ c("span", { className: "flex items-baseline gap-2", children: [
|
|
1329
|
+
/* @__PURE__ */ n("span", { className: "text-[0.8125rem] font-medium text-cream", children: e }),
|
|
1330
|
+
/* @__PURE__ */ n("span", { className: "text-xs text-cream/40", children: u > 0 ? /* @__PURE__ */ n("span", { className: "text-accent", children: `${u} set` }) : r.length || null })
|
|
1331
|
+
] }),
|
|
1332
|
+
/* @__PURE__ */ n("span", { className: "truncate text-xs text-cream/55", children: t })
|
|
1333
|
+
] }),
|
|
1334
|
+
/* @__PURE__ */ n(
|
|
1335
|
+
"span",
|
|
1336
|
+
{
|
|
1337
|
+
className: `ml-auto shrink-0 text-cream/40 transition-transform ${i ? "" : "-rotate-90"}`,
|
|
1338
|
+
"aria-hidden": "true",
|
|
1339
|
+
children: /* @__PURE__ */ n(st, {})
|
|
1340
|
+
}
|
|
1341
|
+
)
|
|
1342
|
+
]
|
|
1343
|
+
}
|
|
1344
|
+
),
|
|
1345
|
+
i && (r.length === 0 ? /* @__PURE__ */ n("span", { className: "block pb-3 text-xs text-cream/35", children: "Nothing here for this paywall." }) : /* @__PURE__ */ n("div", { className: "flex flex-col pb-2", children: r.map((l) => /* @__PURE__ */ n(
|
|
1346
|
+
ar,
|
|
1347
|
+
{
|
|
1348
|
+
row: l,
|
|
1349
|
+
override: a(l.path),
|
|
1350
|
+
onChange: (m) => s(l.path, m)
|
|
1351
|
+
},
|
|
1352
|
+
l.path
|
|
1353
|
+
)) }))
|
|
1354
|
+
] });
|
|
1355
|
+
}, ir = ({
|
|
1356
|
+
overrides: e,
|
|
1357
|
+
groups: t,
|
|
1358
|
+
onChange: r
|
|
1359
|
+
}) => {
|
|
1360
|
+
const a = (s, i, o) => {
|
|
1361
|
+
if (s !== "products") {
|
|
1362
|
+
const b = { ...e[s] };
|
|
1363
|
+
o === void 0 ? delete b[be(i)] : b[be(i)] = o, r({ ...e, [s]: b });
|
|
1364
|
+
return;
|
|
1365
|
+
}
|
|
1366
|
+
const [, u = "", l = ""] = i.split("."), m = { ...e.products?.[u] };
|
|
1367
|
+
o === void 0 ? delete m[l] : m[l] = o;
|
|
1368
|
+
const d = { ...e.products, [u]: m };
|
|
1369
|
+
Object.keys(m).length === 0 && delete d[u], r({ ...e, products: d });
|
|
1370
|
+
};
|
|
1371
|
+
return /* @__PURE__ */ n("div", { className: "flex flex-col", children: nr.map((s) => /* @__PURE__ */ n(
|
|
1372
|
+
sr,
|
|
1373
|
+
{
|
|
1374
|
+
label: s.label,
|
|
1375
|
+
blurb: s.blurb,
|
|
1376
|
+
rows: t[s.key] ?? [],
|
|
1377
|
+
overrideOf: (i) => s.key === "products" ? e.products?.[i.split(".")[1] ?? ""]?.[i.split(".")[2] ?? ""] : e[s.key]?.[be(i)],
|
|
1378
|
+
onChange: (i, o) => a(s.key, i, o)
|
|
1379
|
+
},
|
|
1380
|
+
s.key
|
|
1381
|
+
)) });
|
|
1382
|
+
}, E = (e) => `${e.project ? `/${e.project}` : ""}/${e.kind}/${e.id}`, ke = (e) => /[?&]transport=editor(?:&|$)/.test(e) ? e : `${e}${e.includes("?") ? "&" : "?"}transport=editor`, Er = (e) => ke(`/preview${E(e)}`), Cr = (e) => (t) => ke(e(t)), or = async (e, t, r) => {
|
|
1383
|
+
try {
|
|
1384
|
+
const a = await fetch("/__studio/action", {
|
|
1385
|
+
method: "POST",
|
|
1386
|
+
headers: { "Content-Type": "application/json" },
|
|
1387
|
+
body: JSON.stringify({
|
|
1388
|
+
action: t,
|
|
1389
|
+
kind: e.kind,
|
|
1390
|
+
id: e.id,
|
|
1391
|
+
project: e.project
|
|
1392
|
+
})
|
|
1393
|
+
});
|
|
1394
|
+
if (!a.body)
|
|
1395
|
+
return await a.json();
|
|
1396
|
+
const s = a.body.getReader(), i = new TextDecoder();
|
|
1397
|
+
let o = "", u;
|
|
1398
|
+
const l = (m) => {
|
|
1399
|
+
if (!m.trim()) return;
|
|
1400
|
+
const d = JSON.parse(m);
|
|
1401
|
+
d.result ? u = d.result : d.step && d.state && r?.(d.step, d.state);
|
|
1402
|
+
};
|
|
1403
|
+
for (; ; ) {
|
|
1404
|
+
const { done: m, value: d } = await s.read();
|
|
1405
|
+
if (m) break;
|
|
1406
|
+
o += i.decode(d, { stream: !0 });
|
|
1407
|
+
const b = o.split(`
|
|
1408
|
+
`);
|
|
1409
|
+
o = b.pop() ?? "";
|
|
1410
|
+
for (const w of b) l(w);
|
|
1411
|
+
}
|
|
1412
|
+
return l(o), u ?? { ok: !1, error: "The dev server closed without a result." };
|
|
1413
|
+
} catch (a) {
|
|
1414
|
+
return { ok: !1, error: a instanceof Error ? a.message : String(a) };
|
|
1415
|
+
}
|
|
1416
|
+
}, Ne = async (e) => {
|
|
1417
|
+
try {
|
|
1418
|
+
return await (await fetch(`/__studio/status${E(e)}`)).json();
|
|
1419
|
+
} catch (t) {
|
|
1420
|
+
return { unreachable: t instanceof Error ? t.message : String(t) };
|
|
1421
|
+
}
|
|
1422
|
+
}, lr = async () => {
|
|
1423
|
+
try {
|
|
1424
|
+
const t = await (await fetch("/__studio/samples.json")).json();
|
|
1425
|
+
return typeof t == "object" && t !== null ? t : {};
|
|
1426
|
+
} catch (e) {
|
|
1427
|
+
return { unreachable: e instanceof Error ? e.message : String(e) };
|
|
1428
|
+
}
|
|
1429
|
+
}, we = {
|
|
1430
|
+
radius: 54,
|
|
1431
|
+
cutout: "island",
|
|
1432
|
+
statusBarHeight: 64,
|
|
1433
|
+
homeIndicator: !0
|
|
1434
|
+
}, Q = [
|
|
1435
|
+
{
|
|
1436
|
+
id: "iphone-se",
|
|
1437
|
+
name: "iPhone SE",
|
|
1438
|
+
width: 375,
|
|
1439
|
+
height: 667,
|
|
1440
|
+
device: { platform: "iOS", deviceModel: "iPhone14,6", osVersion: "26.0" },
|
|
1441
|
+
chrome: { radius: 0, statusBarHeight: 20, homeIndicator: !1 }
|
|
1442
|
+
},
|
|
1443
|
+
{
|
|
1444
|
+
id: "iphone-17",
|
|
1445
|
+
name: "iPhone 17",
|
|
1446
|
+
width: 402,
|
|
1447
|
+
height: 874,
|
|
1448
|
+
device: { platform: "iOS", deviceModel: "iPhone18,3", osVersion: "26.0" },
|
|
1449
|
+
chrome: we
|
|
1450
|
+
},
|
|
1451
|
+
{
|
|
1452
|
+
id: "iphone-air",
|
|
1453
|
+
name: "iPhone Air",
|
|
1454
|
+
width: 420,
|
|
1455
|
+
height: 912,
|
|
1456
|
+
device: { platform: "iOS", deviceModel: "iPhone18,4", osVersion: "26.0" },
|
|
1457
|
+
chrome: we
|
|
1458
|
+
},
|
|
1459
|
+
{
|
|
1460
|
+
id: "iphone-17-pro-max",
|
|
1461
|
+
name: "iPhone 17 Pro Max",
|
|
1462
|
+
width: 440,
|
|
1463
|
+
height: 956,
|
|
1464
|
+
device: { platform: "iOS", deviceModel: "iPhone18,2", osVersion: "26.0" },
|
|
1465
|
+
chrome: we
|
|
1466
|
+
},
|
|
1467
|
+
{
|
|
1468
|
+
id: "pixel-10",
|
|
1469
|
+
name: "Pixel 10",
|
|
1470
|
+
width: 412,
|
|
1471
|
+
height: 915,
|
|
1472
|
+
device: { platform: "Android", deviceModel: "Pixel 10", osVersion: "16" },
|
|
1473
|
+
chrome: { radius: 28, cutout: "punch", statusBarHeight: 48, homeIndicator: !0 }
|
|
1474
|
+
},
|
|
1475
|
+
{
|
|
1476
|
+
id: "galaxy-s25",
|
|
1477
|
+
name: "Galaxy S25",
|
|
1478
|
+
width: 360,
|
|
1479
|
+
height: 780,
|
|
1480
|
+
device: { platform: "Android", deviceModel: "SM-S931B", osVersion: "15" },
|
|
1481
|
+
chrome: { radius: 26, cutout: "punch", statusBarHeight: 40, homeIndicator: !0 }
|
|
1482
|
+
},
|
|
1483
|
+
{
|
|
1484
|
+
id: "ipad-mini",
|
|
1485
|
+
name: "iPad mini",
|
|
1486
|
+
width: 744,
|
|
1487
|
+
height: 1133,
|
|
1488
|
+
device: { platform: "iOS", deviceModel: "iPad14,1", osVersion: "26.0" },
|
|
1489
|
+
chrome: { radius: 21, statusBarHeight: 24, homeIndicator: !0 }
|
|
1490
|
+
},
|
|
1491
|
+
{
|
|
1492
|
+
id: "ipad-pro-11",
|
|
1493
|
+
name: "iPad Pro 11″",
|
|
1494
|
+
width: 834,
|
|
1495
|
+
height: 1194,
|
|
1496
|
+
device: { platform: "iOS", deviceModel: "iPad16,3", osVersion: "26.0" },
|
|
1497
|
+
chrome: { radius: 18, statusBarHeight: 24, homeIndicator: !0 }
|
|
1498
|
+
},
|
|
1499
|
+
{
|
|
1500
|
+
id: "desktop",
|
|
1501
|
+
name: "Desktop",
|
|
1502
|
+
width: 1440,
|
|
1503
|
+
height: 900
|
|
1504
|
+
}
|
|
1505
|
+
], pt = "iphone-17", Ve = "responsive", cr = { width: 393, height: 852 }, dr = Q.find((e) => e.id === pt) ?? Q[0], pr = (e) => Q.find((t) => t.id === e) ?? dr, ut = () => ({
|
|
1506
|
+
device: sn(),
|
|
1507
|
+
user: on,
|
|
1508
|
+
params: ln
|
|
1509
|
+
}), mt = ({
|
|
1510
|
+
surface: e,
|
|
1511
|
+
defaults: t,
|
|
1512
|
+
sourceSamples: r,
|
|
1513
|
+
samples: a,
|
|
1514
|
+
frame: s,
|
|
1515
|
+
theme: i,
|
|
1516
|
+
locale: o,
|
|
1517
|
+
edited: u
|
|
1518
|
+
}) => {
|
|
1519
|
+
const l = {
|
|
1520
|
+
...t.device,
|
|
1521
|
+
...r?.device,
|
|
1522
|
+
...a.device,
|
|
1523
|
+
...s,
|
|
1524
|
+
interfaceStyle: i === "dark" ? "Dark" : "Light",
|
|
1525
|
+
...o ? { deviceLocale: o, deviceLanguageCode: o.split(/[-_]/)[0] } : {},
|
|
1526
|
+
...u.device
|
|
1527
|
+
}, m = {
|
|
1528
|
+
...t.user,
|
|
1529
|
+
...r?.user,
|
|
1530
|
+
...a.user,
|
|
1531
|
+
...u.user
|
|
1532
|
+
}, d = {
|
|
1533
|
+
...t.params,
|
|
1534
|
+
...r?.params,
|
|
1535
|
+
...u.params
|
|
1536
|
+
}, b = Object.entries(e.products ?? {}).map(
|
|
1537
|
+
([w, f]) => ({
|
|
1538
|
+
reference: w,
|
|
1539
|
+
productId: f,
|
|
1540
|
+
variables: {
|
|
1541
|
+
...a.products?.[f] ?? nt,
|
|
1542
|
+
...u.products?.[w]
|
|
1543
|
+
}
|
|
1544
|
+
})
|
|
1545
|
+
);
|
|
1546
|
+
return Ge({
|
|
1547
|
+
paywallId: e.paywallId ?? "0",
|
|
1548
|
+
paywallIdentifier: e.paywallIdentifier ?? e.id,
|
|
1549
|
+
device: l,
|
|
1550
|
+
user: m,
|
|
1551
|
+
params: d,
|
|
1552
|
+
products: b,
|
|
1553
|
+
introductoryOfferEligible: u.introductoryOfferEligible
|
|
1554
|
+
});
|
|
1555
|
+
}, ur = (e, t) => Number.isFinite(e) ? Math.min(3e3, Math.max(200, Math.round(e))) : t, We = ({
|
|
1556
|
+
label: e,
|
|
1557
|
+
value: t,
|
|
1558
|
+
onCommit: r
|
|
1559
|
+
}) => {
|
|
1560
|
+
const [a, s] = p.useState(String(t));
|
|
1561
|
+
return p.useEffect(() => {
|
|
1562
|
+
s(String(t));
|
|
1563
|
+
}, [t]), /* @__PURE__ */ n(
|
|
1564
|
+
"input",
|
|
1565
|
+
{
|
|
1566
|
+
className: "sw-input w-16 text-center",
|
|
1567
|
+
type: "number",
|
|
1568
|
+
"aria-label": e,
|
|
1569
|
+
value: a,
|
|
1570
|
+
onChange: (o) => s(o.target.value),
|
|
1571
|
+
onBlur: () => {
|
|
1572
|
+
const o = ur(Number(a), t);
|
|
1573
|
+
s(String(o)), r(o);
|
|
1574
|
+
},
|
|
1575
|
+
onKeyDown: (o) => {
|
|
1576
|
+
o.key === "Enter" && o.target.blur();
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
);
|
|
1580
|
+
}, ze = ({
|
|
1581
|
+
label: e,
|
|
1582
|
+
width: t,
|
|
1583
|
+
height: r,
|
|
1584
|
+
title: a,
|
|
1585
|
+
src: s,
|
|
1586
|
+
hostState: i,
|
|
1587
|
+
delegate: o,
|
|
1588
|
+
reloadKey: u,
|
|
1589
|
+
empty: l,
|
|
1590
|
+
chrome: m,
|
|
1591
|
+
landscape: d,
|
|
1592
|
+
theme: b
|
|
1593
|
+
}) => {
|
|
1594
|
+
const w = p.useRef(null);
|
|
1595
|
+
return /* @__PURE__ */ n("div", { className: "flex min-h-0 min-w-0 flex-1 flex-col items-center justify-center", ref: w, children: /* @__PURE__ */ c("div", { className: "flex flex-col gap-2", children: [
|
|
1596
|
+
e && /* @__PURE__ */ n("span", { className: "text-xs text-cream/55", children: e }),
|
|
1597
|
+
s ? /* @__PURE__ */ n(
|
|
1598
|
+
On,
|
|
1599
|
+
{
|
|
1600
|
+
width: t,
|
|
1601
|
+
height: r,
|
|
1602
|
+
title: a,
|
|
1603
|
+
src: s,
|
|
1604
|
+
hostState: i,
|
|
1605
|
+
delegate: o,
|
|
1606
|
+
stageRef: w,
|
|
1607
|
+
reloadKey: u,
|
|
1608
|
+
chrome: m,
|
|
1609
|
+
landscape: d,
|
|
1610
|
+
theme: b
|
|
1611
|
+
}
|
|
1612
|
+
) : /* @__PURE__ */ n($n, { width: t, height: r, stageRef: w, children: l ?? "Nothing live yet — publish to compare against production." })
|
|
1613
|
+
] }) });
|
|
1614
|
+
}, ve = (e) => e.label ?? `${e.kind}/${e.id}`, mr = ({
|
|
1615
|
+
source: e,
|
|
1616
|
+
surface: t,
|
|
1617
|
+
samples: r,
|
|
1618
|
+
onBack: a,
|
|
1619
|
+
actions: s
|
|
1620
|
+
}) => {
|
|
1621
|
+
const [i, o] = p.useState(pt), [u, l] = p.useState(cr), [m, d] = p.useState("light"), [b, w] = p.useState(void 0), [f, S] = p.useState({}), [D, H] = p.useState(!1), [P, re] = p.useState(void 0), [g, C] = p.useState(0), [x, ft] = p.useState(!1), [V, Ie] = p.useState({}), [bt, A] = p.useState(void 0), ae = p.useRef(void 0);
|
|
1622
|
+
p.useEffect(() => () => window.clearTimeout(ae.current), []);
|
|
1623
|
+
const W = e.capabilities?.actions === !0, Pe = Yn(), M = p.useMemo(ut, [t]), Ee = t.locales;
|
|
1624
|
+
p.useEffect(() => {
|
|
1625
|
+
if (!W) return;
|
|
1626
|
+
let h = !1;
|
|
1627
|
+
return Ne(t).then((v) => {
|
|
1628
|
+
h || Ie(v);
|
|
1629
|
+
}), () => {
|
|
1630
|
+
h = !0;
|
|
1631
|
+
};
|
|
1632
|
+
}, [W, t]);
|
|
1633
|
+
const wt = async (h) => {
|
|
1634
|
+
window.clearTimeout(ae.current), A({ action: h, steps: {} });
|
|
1635
|
+
const v = await or(t, h, (N, _) => {
|
|
1636
|
+
A(
|
|
1637
|
+
(I) => I?.action === h ? {
|
|
1638
|
+
...I,
|
|
1639
|
+
steps: { ...I.steps, [N]: _ === "start" ? "active" : "done" }
|
|
1640
|
+
} : I
|
|
1641
|
+
);
|
|
1642
|
+
});
|
|
1643
|
+
if (v.ok) {
|
|
1644
|
+
const N = Object.fromEntries(
|
|
1645
|
+
X[h].map((_) => [_, "done"])
|
|
1646
|
+
);
|
|
1647
|
+
A({ action: h, steps: N }), Ie(await Ne(t)), ae.current = window.setTimeout(() => A(void 0), 1600);
|
|
1648
|
+
} else
|
|
1649
|
+
A((N) => {
|
|
1650
|
+
if (!N) return N;
|
|
1651
|
+
const _ = { ...N.steps };
|
|
1652
|
+
for (const I of X[h])
|
|
1653
|
+
_[I] === "active" && (_[I] = "failed");
|
|
1654
|
+
return { ...N, steps: _, error: v.error };
|
|
1655
|
+
});
|
|
1656
|
+
}, R = i === Ve, $ = pr(i), se = R ? u : { width: $.width, height: $.height }, k = x ? { width: se.height, height: se.width } : se, vt = () => {
|
|
1657
|
+
const h = e.standaloneUrl?.(t);
|
|
1658
|
+
if (h === void 0) return;
|
|
1659
|
+
if (k.width > 768) {
|
|
1660
|
+
window.open(h, "_blank");
|
|
1661
|
+
return;
|
|
1662
|
+
}
|
|
1663
|
+
const v = Math.max(0, window.screen.width / 2 - k.width / 2), N = Math.max(0, window.screen.height / 2 - k.height / 2);
|
|
1664
|
+
window.open(
|
|
1665
|
+
h,
|
|
1666
|
+
"superwall-preview",
|
|
1667
|
+
`toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=${k.width},height=${k.height},top=${N},left=${v}`
|
|
1668
|
+
) || window.open(h, "_blank");
|
|
1669
|
+
}, ie = p.useMemo(
|
|
1670
|
+
() => mt({
|
|
1671
|
+
surface: t,
|
|
1672
|
+
defaults: M,
|
|
1673
|
+
sourceSamples: e.samples,
|
|
1674
|
+
samples: r,
|
|
1675
|
+
frame: R ? void 0 : $.device,
|
|
1676
|
+
theme: m,
|
|
1677
|
+
locale: b,
|
|
1678
|
+
edited: f
|
|
1679
|
+
}),
|
|
1680
|
+
[t, M, e.samples, r, R, $.device, m, b, f]
|
|
1681
|
+
), Ce = R ? void 0 : $.chrome, yt = e.previewUrl(t), gt = V.liveUrl ? ke(V.liveUrl) : void 0, $e = [
|
|
1682
|
+
...W ? [
|
|
1683
|
+
{
|
|
1684
|
+
key: "live",
|
|
1685
|
+
label: "Live version",
|
|
1686
|
+
hint: "What SDKs receive today",
|
|
1687
|
+
target: { type: "live" }
|
|
1688
|
+
}
|
|
1689
|
+
] : [],
|
|
1690
|
+
...e.surfaces.map((h, v) => ({
|
|
1691
|
+
key: `surface:${v}`,
|
|
1692
|
+
label: ve(h),
|
|
1693
|
+
hint: e.compareHint ?? "Local preview",
|
|
1694
|
+
target: { type: "surface", surface: h }
|
|
1695
|
+
})).filter((h) => h.target.surface !== t)
|
|
1696
|
+
], O = P && (P.type === "live" ? {
|
|
1697
|
+
label: "Live",
|
|
1698
|
+
src: gt,
|
|
1699
|
+
title: `${t.id} live`,
|
|
1700
|
+
empty: V.unreachable ? `Couldn't read the live version — ${V.unreachable}` : void 0
|
|
1701
|
+
} : {
|
|
1702
|
+
label: ve(P.surface),
|
|
1703
|
+
src: e.previewUrl(P.surface),
|
|
1704
|
+
title: `${ve(P.surface)} preview`
|
|
1705
|
+
}), xt = p.useMemo(() => {
|
|
1706
|
+
const h = (v, N) => Object.entries(N ?? {}).map(([_, I]) => ({ path: `${v}.${_}`, value: I })).toSorted((_, I) => _.path.localeCompare(I.path));
|
|
1707
|
+
return {
|
|
1708
|
+
user: h("user", { ...M.user, ...e.samples?.user, ...r.user }),
|
|
1709
|
+
device: h("device", {
|
|
1710
|
+
...M.device,
|
|
1711
|
+
...e.samples?.device,
|
|
1712
|
+
...r.device,
|
|
1713
|
+
...$.device
|
|
1714
|
+
}),
|
|
1715
|
+
params: h("params", { ...M.params, ...e.samples?.params }),
|
|
1716
|
+
products: Object.entries(t.products ?? {}).flatMap(
|
|
1717
|
+
([v, N]) => h(`products.${v}`, r.products?.[N])
|
|
1718
|
+
)
|
|
1719
|
+
};
|
|
1720
|
+
}, [M, e.samples, r, $.device, t.products]), z = p.useMemo(() => r.products ? Object.entries(t.products ?? {}).filter(([, h]) => r.products?.[h] === void 0).map(([h, v]) => ({ reference: h, identifier: v })) : [], [r.products, t.products]), [Nt, oe] = p.useState(!1);
|
|
1721
|
+
p.useEffect(() => oe(!1), [t]);
|
|
1722
|
+
const le = r.unreachable, St = z.length === 0, Oe = Object.keys(f.user ?? {}).length + Object.keys(f.params ?? {}).length + Object.keys(f.device ?? {}).length;
|
|
1723
|
+
return /* @__PURE__ */ c(Z, { children: [
|
|
1724
|
+
/* @__PURE__ */ n(
|
|
1725
|
+
Zn,
|
|
1726
|
+
{
|
|
1727
|
+
surfaceKey: `${t.project ?? ""}/${t.id}`,
|
|
1728
|
+
raised: !!le
|
|
1729
|
+
}
|
|
1730
|
+
),
|
|
1731
|
+
z.length > 0 && !Nt && /* @__PURE__ */ n(
|
|
1732
|
+
Mn,
|
|
1733
|
+
{
|
|
1734
|
+
paywall: t.id,
|
|
1735
|
+
missing: z,
|
|
1736
|
+
onDismiss: () => oe(!0)
|
|
1737
|
+
}
|
|
1738
|
+
),
|
|
1739
|
+
le && /* @__PURE__ */ c("div", { className: "border-b border-cream/10 bg-red/10 px-4 py-1.5 text-[0.8125rem] text-cream/75", children: [
|
|
1740
|
+
"Couldn't check this paywall's products — ",
|
|
1741
|
+
le
|
|
1742
|
+
] }),
|
|
1743
|
+
/* @__PURE__ */ n(
|
|
1744
|
+
dt,
|
|
1745
|
+
{
|
|
1746
|
+
title: `${t.project ?? e.title} / ${t.id}${t.label ? ` · ${t.label}` : ""}`,
|
|
1747
|
+
onHome: a,
|
|
1748
|
+
actions: /* @__PURE__ */ c(Z, { children: [
|
|
1749
|
+
s,
|
|
1750
|
+
/* @__PURE__ */ n(
|
|
1751
|
+
"button",
|
|
1752
|
+
{
|
|
1753
|
+
type: "button",
|
|
1754
|
+
className: "sw-btn sw-btn--icon",
|
|
1755
|
+
"aria-label": "Reload preview",
|
|
1756
|
+
onClick: () => C((h) => h + 1),
|
|
1757
|
+
children: /* @__PURE__ */ n(rt, {})
|
|
1758
|
+
}
|
|
1759
|
+
),
|
|
1760
|
+
e.standaloneUrl && /* @__PURE__ */ n(
|
|
1761
|
+
"button",
|
|
1762
|
+
{
|
|
1763
|
+
type: "button",
|
|
1764
|
+
className: "sw-btn sw-btn--icon",
|
|
1765
|
+
"aria-label": "Open preview",
|
|
1766
|
+
onClick: vt,
|
|
1767
|
+
children: /* @__PURE__ */ n(G, {})
|
|
1768
|
+
}
|
|
1769
|
+
),
|
|
1770
|
+
W && /* @__PURE__ */ n(
|
|
1771
|
+
Nn,
|
|
1772
|
+
{
|
|
1773
|
+
progress: bt,
|
|
1774
|
+
blocked: St ? void 0 : `Superwall has no product for ${z.map((h) => h.reference).join(", ")}`,
|
|
1775
|
+
onRun: wt,
|
|
1776
|
+
onBlocked: () => oe(!1)
|
|
1777
|
+
}
|
|
1778
|
+
)
|
|
1779
|
+
] })
|
|
1780
|
+
}
|
|
1781
|
+
),
|
|
1782
|
+
/* @__PURE__ */ c("div", { className: "flex min-h-0 flex-1", children: [
|
|
1783
|
+
/* @__PURE__ */ c("div", { className: "flex min-w-0 flex-1", children: [
|
|
1784
|
+
O && /* @__PURE__ */ n(
|
|
1785
|
+
ze,
|
|
1786
|
+
{
|
|
1787
|
+
label: O.label,
|
|
1788
|
+
width: k.width,
|
|
1789
|
+
height: k.height,
|
|
1790
|
+
title: O.title,
|
|
1791
|
+
src: O.src,
|
|
1792
|
+
hostState: ie,
|
|
1793
|
+
delegate: Pe,
|
|
1794
|
+
reloadKey: g,
|
|
1795
|
+
empty: "empty" in O ? O.empty : void 0,
|
|
1796
|
+
chrome: Ce,
|
|
1797
|
+
landscape: x,
|
|
1798
|
+
theme: m
|
|
1799
|
+
}
|
|
1800
|
+
),
|
|
1801
|
+
/* @__PURE__ */ n(
|
|
1802
|
+
ze,
|
|
1803
|
+
{
|
|
1804
|
+
label: O ? t.label ?? "Local" : void 0,
|
|
1805
|
+
width: k.width,
|
|
1806
|
+
height: k.height,
|
|
1807
|
+
title: `${t.id} preview`,
|
|
1808
|
+
src: yt,
|
|
1809
|
+
hostState: ie,
|
|
1810
|
+
delegate: Pe,
|
|
1811
|
+
reloadKey: g,
|
|
1812
|
+
chrome: Ce,
|
|
1813
|
+
landscape: x,
|
|
1814
|
+
theme: m
|
|
1815
|
+
}
|
|
1816
|
+
)
|
|
1817
|
+
] }),
|
|
1818
|
+
/* @__PURE__ */ n(er, { open: D, title: "Variables", onClose: () => H(!1), children: /* @__PURE__ */ n(ir, { overrides: f, groups: xt, onChange: S }) })
|
|
1819
|
+
] }),
|
|
1820
|
+
/* @__PURE__ */ c(tr, { children: [
|
|
1821
|
+
/* @__PURE__ */ n(J, { label: "Intro offer", children: /* @__PURE__ */ n(
|
|
1822
|
+
Qn,
|
|
1823
|
+
{
|
|
1824
|
+
label: "Introductory offer",
|
|
1825
|
+
checked: F(ie),
|
|
1826
|
+
onChange: (h) => S((v) => ({ ...v, introductoryOfferEligible: h }))
|
|
1827
|
+
}
|
|
1828
|
+
) }),
|
|
1829
|
+
/* @__PURE__ */ c(J, { label: "Theme", children: [
|
|
1830
|
+
/* @__PURE__ */ n(
|
|
1831
|
+
Xn,
|
|
1832
|
+
{
|
|
1833
|
+
label: "Theme",
|
|
1834
|
+
value: m,
|
|
1835
|
+
options: [
|
|
1836
|
+
{ value: "light", label: /* @__PURE__ */ n(dn, {}) },
|
|
1837
|
+
{ value: "dark", label: /* @__PURE__ */ n(pn, {}) }
|
|
1838
|
+
],
|
|
1839
|
+
onChange: d
|
|
1840
|
+
}
|
|
1841
|
+
),
|
|
1842
|
+
/* @__PURE__ */ n(
|
|
1843
|
+
"button",
|
|
1844
|
+
{
|
|
1845
|
+
type: "button",
|
|
1846
|
+
className: "sw-btn sw-btn--icon",
|
|
1847
|
+
"aria-label": "Rotate device",
|
|
1848
|
+
"aria-pressed": x,
|
|
1849
|
+
title: x ? "Back to portrait" : "Rotate to landscape",
|
|
1850
|
+
onClick: () => ft((h) => !h),
|
|
1851
|
+
children: /* @__PURE__ */ n(
|
|
1852
|
+
"span",
|
|
1853
|
+
{
|
|
1854
|
+
className: `flex transition-transform duration-200 ${x ? "-rotate-90" : ""}`,
|
|
1855
|
+
children: /* @__PURE__ */ n(vn, {})
|
|
1856
|
+
}
|
|
1857
|
+
)
|
|
1858
|
+
}
|
|
1859
|
+
)
|
|
1860
|
+
] }),
|
|
1861
|
+
/* @__PURE__ */ n(Be, {}),
|
|
1862
|
+
/* @__PURE__ */ c(J, { label: "Device", children: [
|
|
1863
|
+
/* @__PURE__ */ n(
|
|
1864
|
+
Fe,
|
|
1865
|
+
{
|
|
1866
|
+
label: "Device",
|
|
1867
|
+
value: i,
|
|
1868
|
+
options: [
|
|
1869
|
+
...Q.map((h) => ({ value: h.id, label: h.name })),
|
|
1870
|
+
{ value: Ve, label: "Responsive" }
|
|
1871
|
+
],
|
|
1872
|
+
onChange: o
|
|
1873
|
+
}
|
|
1874
|
+
),
|
|
1875
|
+
R && /* @__PURE__ */ c("span", { className: "flex items-center gap-1.5", children: [
|
|
1876
|
+
/* @__PURE__ */ n(
|
|
1877
|
+
We,
|
|
1878
|
+
{
|
|
1879
|
+
label: "Preview width",
|
|
1880
|
+
value: k.width,
|
|
1881
|
+
onCommit: (h) => l((v) => ({ ...v, width: h }))
|
|
1882
|
+
}
|
|
1883
|
+
),
|
|
1884
|
+
/* @__PURE__ */ n("span", { className: "text-cream/55", children: "×" }),
|
|
1885
|
+
/* @__PURE__ */ n(
|
|
1886
|
+
We,
|
|
1887
|
+
{
|
|
1888
|
+
label: "Preview height",
|
|
1889
|
+
value: k.height,
|
|
1890
|
+
onCommit: (h) => l((v) => ({ ...v, height: h }))
|
|
1891
|
+
}
|
|
1892
|
+
)
|
|
1893
|
+
] })
|
|
1894
|
+
] }),
|
|
1895
|
+
Ee.length > 1 && /* @__PURE__ */ n(J, { label: "Locale", children: /* @__PURE__ */ n(
|
|
1896
|
+
Fe,
|
|
1897
|
+
{
|
|
1898
|
+
label: "Locale",
|
|
1899
|
+
value: b ?? "default",
|
|
1900
|
+
options: [
|
|
1901
|
+
{ value: "default", label: "Device" },
|
|
1902
|
+
...Ee.map((h) => ({ value: h, label: h }))
|
|
1903
|
+
],
|
|
1904
|
+
onChange: (h) => w(h === "default" ? void 0 : h)
|
|
1905
|
+
}
|
|
1906
|
+
) }),
|
|
1907
|
+
/* @__PURE__ */ n(Be, {}),
|
|
1908
|
+
$e.length > 0 && /* @__PURE__ */ n(Sn, { active: P, options: $e, onSelect: re }),
|
|
1909
|
+
/* @__PURE__ */ c(
|
|
1910
|
+
"button",
|
|
1911
|
+
{
|
|
1912
|
+
type: "button",
|
|
1913
|
+
className: "sw-btn",
|
|
1914
|
+
"aria-expanded": D,
|
|
1915
|
+
onClick: () => H((h) => !h),
|
|
1916
|
+
children: [
|
|
1917
|
+
/* @__PURE__ */ n(un, {}),
|
|
1918
|
+
"Variables",
|
|
1919
|
+
Oe > 0 && /* @__PURE__ */ n("span", { className: "text-accent", children: Oe })
|
|
1920
|
+
]
|
|
1921
|
+
}
|
|
1922
|
+
)
|
|
1923
|
+
] })
|
|
1924
|
+
] });
|
|
1925
|
+
}, ht = "superwall-device-scheme", hr = () => {
|
|
1926
|
+
try {
|
|
1927
|
+
return window.localStorage.getItem(ht) ?? void 0;
|
|
1928
|
+
} catch {
|
|
1929
|
+
return;
|
|
1930
|
+
}
|
|
1931
|
+
}, fr = (e) => {
|
|
1932
|
+
try {
|
|
1933
|
+
window.localStorage.setItem(ht, e);
|
|
1934
|
+
} catch {
|
|
1935
|
+
}
|
|
1936
|
+
}, qe = (e, t) => `${e}://?superwall_dev=${encodeURIComponent(t)}`, br = ({ origin: e, scheme: t }) => {
|
|
1937
|
+
const [r, a] = p.useState(hr), s = r ?? t, i = (u) => {
|
|
1938
|
+
const m = window.prompt("Your app's URL scheme, so this can open it:", u)?.trim();
|
|
1939
|
+
if (!(m === void 0 || m === ""))
|
|
1940
|
+
return a(m), fr(m), m;
|
|
1941
|
+
}, o = (u) => {
|
|
1942
|
+
if (s !== void 0) return;
|
|
1943
|
+
u.preventDefault();
|
|
1944
|
+
const l = i("");
|
|
1945
|
+
l !== void 0 && window.location.assign(qe(l, e));
|
|
1946
|
+
};
|
|
1947
|
+
return /* @__PURE__ */ c("div", { className: "flex items-center gap-2", children: [
|
|
1948
|
+
s !== void 0 && /* @__PURE__ */ n(
|
|
1949
|
+
"button",
|
|
1950
|
+
{
|
|
1951
|
+
className: "sw-btn sw-btn--icon",
|
|
1952
|
+
type: "button",
|
|
1953
|
+
"aria-label": "Edit app URL scheme",
|
|
1954
|
+
onClick: () => i(s),
|
|
1955
|
+
children: /* @__PURE__ */ c("svg", { className: "sw-icon", viewBox: "0 0 24 24", "aria-hidden": "true", children: [
|
|
1956
|
+
/* @__PURE__ */ n("path", { d: "M12 20h9" }),
|
|
1957
|
+
/* @__PURE__ */ n("path", { d: "M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4Z" })
|
|
1958
|
+
] })
|
|
1959
|
+
}
|
|
1960
|
+
),
|
|
1961
|
+
/* @__PURE__ */ n(
|
|
1962
|
+
"a",
|
|
1963
|
+
{
|
|
1964
|
+
className: "sw-btn sw-btn--primary",
|
|
1965
|
+
href: s === void 0 ? "#" : qe(s, e),
|
|
1966
|
+
onClick: o,
|
|
1967
|
+
children: "Open In App"
|
|
1968
|
+
}
|
|
1969
|
+
)
|
|
1970
|
+
] });
|
|
1971
|
+
}, wr = [
|
|
1972
|
+
[60, "second"],
|
|
1973
|
+
[60, "minute"],
|
|
1974
|
+
[24, "hour"],
|
|
1975
|
+
[7, "day"],
|
|
1976
|
+
[4.348, "week"],
|
|
1977
|
+
[12, "month"]
|
|
1978
|
+
], vr = (e, t = Date.now()) => {
|
|
1979
|
+
const r = Date.parse(e);
|
|
1980
|
+
if (Number.isNaN(r)) return;
|
|
1981
|
+
let a = Math.max(0, (t - r) / 1e3);
|
|
1982
|
+
const s = new Intl.RelativeTimeFormat("en", { numeric: "auto" });
|
|
1983
|
+
for (const [i, o] of wr) {
|
|
1984
|
+
if (a < i) return s.format(-Math.round(a), o);
|
|
1985
|
+
a /= i;
|
|
1986
|
+
}
|
|
1987
|
+
return s.format(-Math.round(a), "year");
|
|
1988
|
+
}, Ke = 390, yr = 844, gr = (e) => {
|
|
1989
|
+
const [t, r] = p.useState(0);
|
|
1990
|
+
return p.useLayoutEffect(() => {
|
|
1991
|
+
const a = e.current;
|
|
1992
|
+
if (!a) return;
|
|
1993
|
+
const s = () => r(a.getBoundingClientRect().width);
|
|
1994
|
+
if (s(), typeof ResizeObserver > "u") return;
|
|
1995
|
+
const i = new ResizeObserver(s);
|
|
1996
|
+
return i.observe(a), () => i.disconnect();
|
|
1997
|
+
}, [e]), t;
|
|
1998
|
+
}, xr = ({
|
|
1999
|
+
surface: e,
|
|
2000
|
+
status: t,
|
|
2001
|
+
previewSrc: r,
|
|
2002
|
+
hostState: a,
|
|
2003
|
+
onOpen: s,
|
|
2004
|
+
href: i
|
|
2005
|
+
}) => {
|
|
2006
|
+
const o = p.useRef(null), u = gr(o), l = u > 0 ? u / Ke : 0, m = p.useMemo(Ft, []);
|
|
2007
|
+
return /* @__PURE__ */ c(
|
|
2008
|
+
"a",
|
|
2009
|
+
{
|
|
2010
|
+
className: "group block",
|
|
2011
|
+
href: i ?? E(e),
|
|
2012
|
+
onClick: (d) => {
|
|
2013
|
+
d.metaKey || d.ctrlKey || (d.preventDefault(), s());
|
|
2014
|
+
},
|
|
2015
|
+
children: [
|
|
2016
|
+
/* @__PURE__ */ n(
|
|
2017
|
+
"div",
|
|
2018
|
+
{
|
|
2019
|
+
className: "bg-panel relative aspect-[390/844] overflow-hidden border border-cream/20 transition-colors group-hover:border-cream/35",
|
|
2020
|
+
ref: o,
|
|
2021
|
+
children: l > 0 && /* @__PURE__ */ n(
|
|
2022
|
+
lt,
|
|
2023
|
+
{
|
|
2024
|
+
hostState: a,
|
|
2025
|
+
delegate: m,
|
|
2026
|
+
className: "pointer-events-none block origin-top-left border-0 bg-white",
|
|
2027
|
+
title: `${e.project ? `${e.project}/` : ""}${e.id} preview`,
|
|
2028
|
+
src: r,
|
|
2029
|
+
loading: "lazy",
|
|
2030
|
+
tabIndex: -1,
|
|
2031
|
+
width: Ke,
|
|
2032
|
+
height: yr,
|
|
2033
|
+
style: { transform: `scale(${l})` }
|
|
2034
|
+
}
|
|
2035
|
+
)
|
|
2036
|
+
}
|
|
2037
|
+
),
|
|
2038
|
+
/* @__PURE__ */ c("div", { className: "flex items-center justify-between gap-2 pt-2.5", children: [
|
|
2039
|
+
/* @__PURE__ */ c("div", { className: "flex flex-col gap-0.5", children: [
|
|
2040
|
+
/* @__PURE__ */ c("span", { className: "text-sm font-medium", children: [
|
|
2041
|
+
e.project && /* @__PURE__ */ c("span", { className: "text-cream/45", children: [
|
|
2042
|
+
e.project,
|
|
2043
|
+
"/"
|
|
2044
|
+
] }),
|
|
2045
|
+
e.id,
|
|
2046
|
+
e.platforms && e.platforms.length > 0 && /* @__PURE__ */ c("span", { className: "text-cream/45", children: [
|
|
2047
|
+
" · ",
|
|
2048
|
+
e.platforms.join(" · ")
|
|
2049
|
+
] })
|
|
2050
|
+
] }),
|
|
2051
|
+
t && /* @__PURE__ */ n("span", { className: "text-xs text-cream/55", children: t.updatedAt ? `Edited ${vr(t.updatedAt)}` : "Not published" })
|
|
2052
|
+
] }),
|
|
2053
|
+
t?.paywallId && /* @__PURE__ */ n("span", { className: `text-xs ${t.active ? "text-accent" : "text-cream/55"}`, children: t.active ? "Active" : "Inactive" })
|
|
2054
|
+
] })
|
|
2055
|
+
]
|
|
2056
|
+
}
|
|
2057
|
+
);
|
|
2058
|
+
};
|
|
2059
|
+
let Je = 0;
|
|
2060
|
+
const Nr = ({
|
|
2061
|
+
source: e,
|
|
2062
|
+
onOpen: t,
|
|
2063
|
+
device: r = !1
|
|
2064
|
+
}) => {
|
|
2065
|
+
const [a, s] = p.useState({}), i = p.useMemo(ut, [e]);
|
|
2066
|
+
p.useEffect(() => {
|
|
2067
|
+
if (e.capabilities?.actions !== !0) return;
|
|
2068
|
+
let d = !1;
|
|
2069
|
+
for (const b of e.surfaces)
|
|
2070
|
+
Ne(b).then((w) => {
|
|
2071
|
+
d || s((f) => ({ ...f, [E(b)]: w }));
|
|
2072
|
+
});
|
|
2073
|
+
return () => {
|
|
2074
|
+
d = !0;
|
|
2075
|
+
};
|
|
2076
|
+
}, [e]);
|
|
2077
|
+
const [o, u] = p.useState({}), l = p.useRef(null);
|
|
2078
|
+
p.useLayoutEffect(() => {
|
|
2079
|
+
const d = l.current;
|
|
2080
|
+
if (!d) return;
|
|
2081
|
+
d.scrollTop = Je;
|
|
2082
|
+
const b = () => {
|
|
2083
|
+
Je = d.scrollTop;
|
|
2084
|
+
};
|
|
2085
|
+
return d.addEventListener("scroll", b, { passive: !0 }), () => {
|
|
2086
|
+
b(), d.removeEventListener("scroll", b);
|
|
2087
|
+
};
|
|
2088
|
+
}, []);
|
|
2089
|
+
const m = [
|
|
2090
|
+
["Paywalls", "paywall"],
|
|
2091
|
+
["Funnels", "funnel"]
|
|
2092
|
+
].map(([d, b]) => {
|
|
2093
|
+
const w = e.surfaces.filter((S) => S.kind === b), f = (o[b] ?? "").trim().toLowerCase();
|
|
2094
|
+
return {
|
|
2095
|
+
label: d,
|
|
2096
|
+
kind: b,
|
|
2097
|
+
all: w,
|
|
2098
|
+
needle: f,
|
|
2099
|
+
surfaces: w.filter(
|
|
2100
|
+
(S) => f === "" || `${S.project ?? ""} ${S.id}`.toLowerCase().includes(f)
|
|
2101
|
+
)
|
|
2102
|
+
};
|
|
2103
|
+
}).filter((d) => d.all.length > 0);
|
|
2104
|
+
return /* @__PURE__ */ c(Z, { children: [
|
|
2105
|
+
/* @__PURE__ */ n(
|
|
2106
|
+
dt,
|
|
2107
|
+
{
|
|
2108
|
+
title: e.title,
|
|
2109
|
+
onHome: () => {
|
|
2110
|
+
},
|
|
2111
|
+
inset: !0,
|
|
2112
|
+
label: r ? "Preview" : void 0,
|
|
2113
|
+
actions: r ? /* @__PURE__ */ n(br, { origin: window.location.origin, scheme: e.scheme }) : void 0
|
|
2114
|
+
}
|
|
2115
|
+
),
|
|
2116
|
+
/* @__PURE__ */ n("div", { className: "flex-1 overflow-y-auto px-3 pt-6 pb-16 sm:px-6 sm:pt-10", ref: l, children: /* @__PURE__ */ c("div", { className: "mx-auto max-w-[1080px]", children: [
|
|
2117
|
+
e.diagnostics && e.diagnostics.length > 0 && /* @__PURE__ */ n("div", { className: "border-red bg-red/10 mb-6 border-l-2 px-4 py-3 text-[0.8125rem] whitespace-pre-wrap", children: e.diagnostics.join(`
|
|
2118
|
+
`) }),
|
|
2119
|
+
m.map((d) => /* @__PURE__ */ c("section", { className: "mt-10 first:mt-0", children: [
|
|
2120
|
+
/* @__PURE__ */ c("div", { className: "mb-4 flex items-center gap-2", children: [
|
|
2121
|
+
/* @__PURE__ */ n("span", { className: "text-[1.0625rem] font-medium", children: d.label }),
|
|
2122
|
+
/* @__PURE__ */ n("span", { className: "text-[0.8125rem] text-cream/55 tabular-nums", children: d.surfaces.length }),
|
|
2123
|
+
d.all.length > 1 && /* @__PURE__ */ n(
|
|
2124
|
+
"input",
|
|
2125
|
+
{
|
|
2126
|
+
className: "sw-input ml-auto w-48",
|
|
2127
|
+
type: "search",
|
|
2128
|
+
value: o[d.kind] ?? "",
|
|
2129
|
+
placeholder: `Search ${d.label.toLowerCase()}`,
|
|
2130
|
+
"aria-label": `Search ${d.label.toLowerCase()}`,
|
|
2131
|
+
onChange: (b) => u((w) => ({ ...w, [d.kind]: b.target.value }))
|
|
2132
|
+
}
|
|
2133
|
+
)
|
|
2134
|
+
] }),
|
|
2135
|
+
/* @__PURE__ */ n("div", { className: "grid grid-cols-2 gap-3 sm:grid-cols-[repeat(auto-fill,minmax(200px,1fr))] sm:gap-6", children: d.surfaces.map((b) => /* @__PURE__ */ n(
|
|
2136
|
+
xr,
|
|
2137
|
+
{
|
|
2138
|
+
surface: b,
|
|
2139
|
+
status: a[E(b)],
|
|
2140
|
+
previewSrc: e.previewUrl(b),
|
|
2141
|
+
hostState: mt({
|
|
2142
|
+
surface: b,
|
|
2143
|
+
defaults: i,
|
|
2144
|
+
sourceSamples: e.samples,
|
|
2145
|
+
samples: {},
|
|
2146
|
+
theme: "light",
|
|
2147
|
+
edited: {}
|
|
2148
|
+
}),
|
|
2149
|
+
onOpen: () => t(b),
|
|
2150
|
+
href: r ? E(b) : void 0
|
|
2151
|
+
},
|
|
2152
|
+
E(b)
|
|
2153
|
+
)) }),
|
|
2154
|
+
d.surfaces.length === 0 && /* @__PURE__ */ n("span", { className: "block text-[0.8125rem] text-cream/45", children: `Nothing matches “${(o[d.kind] ?? "").trim()}”.` })
|
|
2155
|
+
] }, d.kind)),
|
|
2156
|
+
e.surfaces.length === 0 && /* @__PURE__ */ c("div", { className: "border border-dashed border-cream/20 p-12 text-center text-cream/55", children: [
|
|
2157
|
+
"No paywalls yet — create",
|
|
2158
|
+
" ",
|
|
2159
|
+
/* @__PURE__ */ n("code", { className: "font-mono text-[0.8125rem] text-cream", children: "superwall/paywalls/<id>/app/page.tsx" }),
|
|
2160
|
+
" ",
|
|
2161
|
+
"and it appears here."
|
|
2162
|
+
] })
|
|
2163
|
+
] }) }),
|
|
2164
|
+
!r && /* @__PURE__ */ n("footer", { className: "bg-bar flex h-11 flex-none items-center justify-center border-t border-cream/10 text-xs text-cream/55", children: "Previews run against a real SDK host — you choose the outcomes. Edit files under superwall/ and they update live." })
|
|
2165
|
+
] });
|
|
2166
|
+
}, Sr = (e, t) => {
|
|
2167
|
+
const r = t.match(/^\/(?:([a-z0-9-]+)\/)?(paywall|funnel)\/([a-z0-9-]+)\/?$/);
|
|
2168
|
+
if (r)
|
|
2169
|
+
return e.find(
|
|
2170
|
+
(a) => a.kind === r[2] && a.id === r[3] && (r[1] === void 0 || a.project === r[1])
|
|
2171
|
+
);
|
|
2172
|
+
}, $r = ({
|
|
2173
|
+
source: e,
|
|
2174
|
+
device: t = !1
|
|
2175
|
+
}) => {
|
|
2176
|
+
const [r, a] = p.useState(() => window.location.pathname), [s, i] = p.useState({});
|
|
2177
|
+
p.useEffect(() => {
|
|
2178
|
+
const l = () => a(window.location.pathname);
|
|
2179
|
+
return window.addEventListener("popstate", l), () => window.removeEventListener("popstate", l);
|
|
2180
|
+
}, []), p.useEffect(() => {
|
|
2181
|
+
if (e.capabilities?.actions !== !0) return;
|
|
2182
|
+
let l = !1;
|
|
2183
|
+
return lr().then((m) => {
|
|
2184
|
+
l || i(m);
|
|
2185
|
+
}), () => {
|
|
2186
|
+
l = !0;
|
|
2187
|
+
};
|
|
2188
|
+
}, [e.capabilities?.actions]);
|
|
2189
|
+
const o = (l) => {
|
|
2190
|
+
window.history.pushState(null, "", l), a(l);
|
|
2191
|
+
}, u = Sr(e.surfaces, r);
|
|
2192
|
+
return /* @__PURE__ */ n(kt, { children: u ? /* @__PURE__ */ n(
|
|
2193
|
+
mr,
|
|
2194
|
+
{
|
|
2195
|
+
source: e,
|
|
2196
|
+
surface: u,
|
|
2197
|
+
samples: s,
|
|
2198
|
+
onBack: () => o(t ? "/device" : "/")
|
|
2199
|
+
}
|
|
2200
|
+
) : /* @__PURE__ */ n(
|
|
2201
|
+
Nr,
|
|
2202
|
+
{
|
|
2203
|
+
source: e,
|
|
2204
|
+
device: t,
|
|
2205
|
+
onOpen: (l) => o(E(l))
|
|
2206
|
+
}
|
|
2207
|
+
) });
|
|
2208
|
+
}, _r = (e) => typeof e == "object" && e !== null && !Array.isArray(e) && Object.values(e).every((t) => typeof t == "string"), j = (e) => typeof e == "object" && e !== null && !Array.isArray(e), Y = (e) => Array.isArray(e) && e.every((t) => typeof t == "string"), kr = (e) => {
|
|
2209
|
+
if (!j(e)) return;
|
|
2210
|
+
const t = e.kind === "paywall" || e.kind === "funnel" ? e.kind : void 0;
|
|
2211
|
+
if (!(!t || typeof e.id != "string"))
|
|
2212
|
+
return {
|
|
2213
|
+
kind: t,
|
|
2214
|
+
id: e.id,
|
|
2215
|
+
...typeof e.project == "string" ? { project: e.project } : {},
|
|
2216
|
+
routes: Y(e.routes) ? e.routes : [],
|
|
2217
|
+
products: _r(e.products) ? e.products : {},
|
|
2218
|
+
locales: Y(e.locales) ? e.locales : [],
|
|
2219
|
+
...Y(e.platforms) ? { platforms: e.platforms } : {},
|
|
2220
|
+
paywallId: typeof e.paywallId == "string" ? e.paywallId : void 0
|
|
2221
|
+
};
|
|
2222
|
+
}, Or = (e) => {
|
|
2223
|
+
if (!j(e))
|
|
2224
|
+
throw new Error("project payload is not an object");
|
|
2225
|
+
const t = Array.isArray(e.surfaces) ? e.surfaces.map(kr).filter((i) => i !== void 0) : [], r = j(e.capabilities) ? e.capabilities : {}, a = j(e.samples) ? e.samples : {}, s = (i) => j(a[i]) ? a[i] : {};
|
|
2226
|
+
return {
|
|
2227
|
+
title: typeof e.title == "string" ? e.title : "superwall",
|
|
2228
|
+
scheme: typeof e.scheme == "string" ? e.scheme : void 0,
|
|
2229
|
+
surfaces: t,
|
|
2230
|
+
diagnostics: Y(e.diagnostics) ? e.diagnostics : [],
|
|
2231
|
+
samples: {
|
|
2232
|
+
device: s("device"),
|
|
2233
|
+
user: s("user"),
|
|
2234
|
+
params: s("params")
|
|
2235
|
+
},
|
|
2236
|
+
capabilities: { actions: r.actions === !0 }
|
|
2237
|
+
};
|
|
2238
|
+
};
|
|
2239
|
+
export {
|
|
2240
|
+
pt as DEFAULT_DEVICE_ID,
|
|
2241
|
+
On as DeviceFrame,
|
|
2242
|
+
lt as HostedIframe,
|
|
2243
|
+
Zn as PaywallToasts,
|
|
2244
|
+
Q as STUDIO_DEVICES,
|
|
2245
|
+
Xn as Segmented,
|
|
2246
|
+
Fe as Select,
|
|
2247
|
+
$r as StudioApp,
|
|
2248
|
+
kt as StudioShell,
|
|
2249
|
+
mr as SurfaceEditor,
|
|
2250
|
+
Nr as SurfaceList,
|
|
2251
|
+
Qn as Switch,
|
|
2252
|
+
dt as TopBar,
|
|
2253
|
+
ir as VariablesPanel,
|
|
2254
|
+
Er as buildPreviewPath,
|
|
2255
|
+
Ge as createHostState,
|
|
2256
|
+
Gn as createStudioDelegate,
|
|
2257
|
+
pr as deviceById,
|
|
2258
|
+
Pt as diffHostState,
|
|
2259
|
+
F as hasIntroductoryOffer,
|
|
2260
|
+
mt as hostStateFor,
|
|
2261
|
+
ke as hostedUrl,
|
|
2262
|
+
Or as parseProjectPayload,
|
|
2263
|
+
Ft as silentDelegate,
|
|
2264
|
+
Cr as snapshotPreviewUrl,
|
|
2265
|
+
ut as studioDefaults,
|
|
2266
|
+
E as surfacePath,
|
|
2267
|
+
Yn as useStudioDelegate
|
|
2268
|
+
};
|