@superwall/studio 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/index-GB-RwJI6.js +11 -0
- package/dist/assets/index-Sz7S5UsH.css +1 -0
- package/dist/index.html +2 -2
- package/dist/lib/components/DownloadScreenshot.d.ts +6 -0
- package/dist/lib/components/PreviewOnDevice.d.ts +6 -0
- package/dist/lib/components/Tooltip.d.ts +5 -0
- package/dist/lib/index.d.ts +4 -0
- package/dist/lib/index.js +2168 -1153
- package/dist/lib/lib/actions.d.ts +1 -0
- package/dist/lib/lib/notify.d.ts +4 -0
- package/dist/lib/lib/project.d.ts +1 -0
- package/dist/lib/lib/scheme.d.ts +11 -0
- package/dist/lib/lib/surfaces.d.ts +3 -0
- package/dist/lib/studio.css +1 -1
- package/package.json +3 -2
- package/src/components/DownloadScreenshot.tsx +106 -0
- package/src/components/OpenInApp.tsx +5 -25
- package/src/components/PaywallToasts.tsx +1 -1
- package/src/components/PreviewOnDevice.tsx +133 -0
- package/src/components/SurfaceCard.tsx +1 -1
- package/src/components/Tooltip.tsx +27 -0
- package/src/components/menus/ActionMenu.tsx +8 -8
- package/src/components/menus/CompareMenu.tsx +1 -1
- package/src/components/panels/MissingProducts.tsx +1 -1
- package/src/index.ts +4 -0
- package/src/lib/actions.ts +7 -0
- package/src/lib/notify.tsx +31 -0
- package/src/lib/project.ts +2 -0
- package/src/lib/scheme.ts +31 -0
- package/src/lib/surfaces.ts +3 -0
- package/src/screens/SurfaceEditor.tsx +4 -0
- package/src/screens/SurfaceList.tsx +2 -2
- package/src/styles.css +43 -8
- package/dist/assets/index-CEz-HnIH.js +0 -11
- package/dist/assets/index-_HCp6gCi.css +0 -1
package/dist/lib/index.js
CHANGED
|
@@ -1,53 +1,54 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
4
|
-
|
|
1
|
+
import { jsx as s, jsxs as f, Fragment as G } from "react/jsx-runtime";
|
|
2
|
+
import * as w from "react";
|
|
3
|
+
import M from "react";
|
|
4
|
+
import { toast as J, Toaster as Jt } from "sonner";
|
|
5
|
+
const Xt = ({
|
|
5
6
|
children: e,
|
|
6
7
|
position: t = "fixed"
|
|
7
|
-
}) => /* @__PURE__ */
|
|
8
|
+
}) => /* @__PURE__ */ s(
|
|
8
9
|
"div",
|
|
9
10
|
{
|
|
10
11
|
className: `sw-studio bg-ink text-cream ${t} inset-0 flex flex-col font-sans text-[0.9375rem] tracking-[-0.01em] antialiased`,
|
|
11
12
|
children: e
|
|
12
13
|
}
|
|
13
|
-
),
|
|
14
|
+
), Zt = { experimentId: "0", variantId: "0", campaignId: "0" }, X = (e) => Object.fromEntries(Object.entries(e).filter(([, t]) => t !== void 0)), ut = (e = {}) => ({
|
|
14
15
|
paywallId: e.paywallId ?? "0",
|
|
15
16
|
paywallIdentifier: e.paywallIdentifier ?? "paywall",
|
|
16
|
-
device:
|
|
17
|
-
user:
|
|
18
|
-
params:
|
|
17
|
+
device: X(e.device ?? {}),
|
|
18
|
+
user: X(e.user ?? {}),
|
|
19
|
+
params: X(e.params ?? {}),
|
|
19
20
|
products: e.products ?? [],
|
|
20
|
-
experiment: e.experiment ??
|
|
21
|
+
experiment: e.experiment ?? Zt,
|
|
21
22
|
...e.introductoryOfferEligible === void 0 ? {} : { introductoryOfferEligible: e.introductoryOfferEligible }
|
|
22
|
-
}),
|
|
23
|
-
const
|
|
23
|
+
}), Ge = (e, t) => {
|
|
24
|
+
const n = {
|
|
24
25
|
...e,
|
|
25
26
|
paywallId: t.paywallId ?? e.paywallId,
|
|
26
27
|
paywallIdentifier: t.paywallIdentifier ?? e.paywallIdentifier,
|
|
27
|
-
device: t.device ?
|
|
28
|
-
user: t.user ?
|
|
29
|
-
params: t.params ?
|
|
28
|
+
device: t.device ? X({ ...e.device, ...t.device }) : e.device,
|
|
29
|
+
user: t.user ? X({ ...e.user, ...t.user }) : e.user,
|
|
30
|
+
params: t.params ? X({ ...e.params, ...t.params }) : e.params,
|
|
30
31
|
products: t.products ?? e.products,
|
|
31
32
|
experiment: t.experiment ?? e.experiment
|
|
32
33
|
};
|
|
33
|
-
return "introductoryOfferEligible" in t && (t.introductoryOfferEligible === void 0 ? delete
|
|
34
|
-
},
|
|
35
|
-
const
|
|
36
|
-
let
|
|
37
|
-
for (const
|
|
38
|
-
|
|
39
|
-
return
|
|
40
|
-
},
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
return
|
|
47
|
-
},
|
|
48
|
-
const t = e.variables.trialPeriodDays,
|
|
49
|
-
return Number.isFinite(
|
|
50
|
-
},
|
|
34
|
+
return "introductoryOfferEligible" in t && (t.introductoryOfferEligible === void 0 ? delete n.introductoryOfferEligible : n.introductoryOfferEligible = t.introductoryOfferEligible), n;
|
|
35
|
+
}, Te = (e, t) => JSON.stringify(e) === JSON.stringify(t), _e = (e, t) => {
|
|
36
|
+
const n = {};
|
|
37
|
+
let a = !1;
|
|
38
|
+
for (const l of /* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(t)]))
|
|
39
|
+
l in t ? Te(e[l], t[l]) || (n[l] = t[l], a = !0) : (n[l] = void 0, a = !0);
|
|
40
|
+
return a ? n : void 0;
|
|
41
|
+
}, en = (e, t) => {
|
|
42
|
+
const n = {}, a = _e(e.device, t.device);
|
|
43
|
+
a && (n.device = a);
|
|
44
|
+
const l = _e(e.user, t.user);
|
|
45
|
+
l && (n.user = l);
|
|
46
|
+
const c = _e(e.params, t.params);
|
|
47
|
+
return c && (n.params = c), Te(e.products, t.products) || (n.products = t.products), e.introductoryOfferEligible !== t.introductoryOfferEligible && (n.introductoryOfferEligible = t.introductoryOfferEligible), e.paywallId !== t.paywallId && (n.paywallId = t.paywallId), e.paywallIdentifier !== t.paywallIdentifier && (n.paywallIdentifier = t.paywallIdentifier), Te(e.experiment, t.experiment) || (n.experiment = t.experiment), n;
|
|
48
|
+
}, ht = (e) => {
|
|
49
|
+
const t = e.variables.trialPeriodDays, n = typeof t == "number" ? t : typeof t == "string" ? Number(t) : 0;
|
|
50
|
+
return Number.isFinite(n) ? n : 0;
|
|
51
|
+
}, re = (e) => e.introductoryOfferEligible ?? e.products.some((t) => ht(t) > 0), mt = (e) => ({
|
|
51
52
|
event_name: "template_variables",
|
|
52
53
|
variables: {
|
|
53
54
|
device: e.device,
|
|
@@ -55,69 +56,69 @@ const It = ({
|
|
|
55
56
|
params: e.params,
|
|
56
57
|
...e.products.length > 0 ? { products: e.products.map((t) => ({ [t.reference]: t.variables })) } : {}
|
|
57
58
|
}
|
|
58
|
-
}),
|
|
59
|
+
}), pt = (e) => ({
|
|
59
60
|
event_name: "experiment",
|
|
60
61
|
experimentId: e.experiment.experimentId,
|
|
61
62
|
variantId: e.experiment.variantId,
|
|
62
63
|
campaignId: e.experiment.campaignId
|
|
63
|
-
}),
|
|
64
|
+
}), ft = (e) => ({
|
|
64
65
|
event_name: "products",
|
|
65
66
|
products: e.products.map((t) => ({
|
|
66
67
|
product: t.reference,
|
|
67
68
|
productId: t.productId
|
|
68
69
|
}))
|
|
69
|
-
}),
|
|
70
|
+
}), bt = (e) => ({
|
|
70
71
|
event_name: "template_substitutions_prefix",
|
|
71
|
-
prefix:
|
|
72
|
-
}),
|
|
72
|
+
prefix: re(e) ? "freeTrial" : "default"
|
|
73
|
+
}), tn = (e) => ({
|
|
73
74
|
event_name: "paywall_open",
|
|
74
75
|
paywall_id: e.paywallId,
|
|
75
76
|
paywall_identifier: e.paywallIdentifier
|
|
76
|
-
}),
|
|
77
|
+
}), nn = (e) => ({
|
|
77
78
|
event_name: "paywall_close",
|
|
78
79
|
paywall_id: e.paywallId,
|
|
79
80
|
paywall_identifier: e.paywallIdentifier
|
|
80
|
-
}),
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
],
|
|
81
|
+
}), rn = (e) => [
|
|
82
|
+
mt(e),
|
|
83
|
+
pt(e),
|
|
84
|
+
ft(e),
|
|
85
|
+
bt(e),
|
|
86
|
+
tn(e)
|
|
87
|
+
], ve = (e) => ({
|
|
87
88
|
product: e.reference,
|
|
88
89
|
product_identifier: e.productId
|
|
89
|
-
}),
|
|
90
|
+
}), sn = (e) => ({
|
|
90
91
|
event_name: "transaction_start",
|
|
91
|
-
...
|
|
92
|
-
}),
|
|
92
|
+
...ve(e)
|
|
93
|
+
}), an = (e) => ({
|
|
93
94
|
event_name: "transaction_complete",
|
|
94
|
-
...
|
|
95
|
-
}),
|
|
95
|
+
...ve(e)
|
|
96
|
+
}), on = (e) => ({
|
|
96
97
|
event_name: "transaction_abandon",
|
|
97
|
-
...
|
|
98
|
-
}),
|
|
98
|
+
...ve(e)
|
|
99
|
+
}), Ke = (e) => ({
|
|
99
100
|
event_name: "transaction_fail",
|
|
100
|
-
...
|
|
101
|
-
}),
|
|
101
|
+
...ve(e)
|
|
102
|
+
}), ln = () => ({
|
|
102
103
|
event_name: "transaction_restore"
|
|
103
|
-
}),
|
|
104
|
+
}), cn = (e, t) => ({
|
|
104
105
|
event_name: "freeTrial_start",
|
|
105
106
|
product_identifier: e.productId,
|
|
106
107
|
trial_end_date: t
|
|
107
|
-
}),
|
|
108
|
+
}), dn = () => ({ event_name: "restore_start" }), un = () => ({
|
|
108
109
|
event_name: "restore_complete"
|
|
109
|
-
}),
|
|
110
|
+
}), Ye = () => ({ event_name: "restore_fail" }), hn = (e) => ({
|
|
110
111
|
event_name: "permission_result",
|
|
111
112
|
permission_type: e.permissionType,
|
|
112
113
|
request_id: e.requestId,
|
|
113
114
|
status: e.status
|
|
114
|
-
}),
|
|
115
|
+
}), mn = (e) => ({
|
|
115
116
|
event_name: "callback_result",
|
|
116
117
|
request_id: e.requestId,
|
|
117
118
|
name: e.name,
|
|
118
119
|
status: e.status,
|
|
119
120
|
...e.data === void 0 ? {} : { data: e.data }
|
|
120
|
-
}),
|
|
121
|
+
}), pn = () => ({
|
|
121
122
|
event: () => {
|
|
122
123
|
},
|
|
123
124
|
purchase: () => "completed",
|
|
@@ -132,124 +133,124 @@ const It = ({
|
|
|
132
133
|
},
|
|
133
134
|
permission: () => "granted",
|
|
134
135
|
callback: () => ({ status: "success" })
|
|
135
|
-
}),
|
|
136
|
-
new Promise((
|
|
137
|
-
},
|
|
136
|
+
}), fn = 1440 * 60 * 1e3, ye = (e, t, n) => {
|
|
137
|
+
new Promise((a) => a(e())).then(t, n);
|
|
138
|
+
}, xe = (e, t) => {
|
|
138
139
|
console.error(`[superwall host] ${e}`, t);
|
|
139
|
-
},
|
|
140
|
+
}, bn = (e, t, n) => e.products.find((a) => a.reference === t) ?? e.products.find((a) => a.productId === n) ?? {
|
|
140
141
|
reference: t,
|
|
141
|
-
productId:
|
|
142
|
+
productId: n ?? t,
|
|
142
143
|
variables: {}
|
|
143
|
-
},
|
|
144
|
-
const { delegate:
|
|
145
|
-
|
|
146
|
-
() =>
|
|
147
|
-
(
|
|
148
|
-
if (
|
|
149
|
-
const p =
|
|
150
|
-
|
|
151
|
-
} else
|
|
144
|
+
}, wn = (e, t) => {
|
|
145
|
+
const { delegate: n, send: a, now: l } = e, c = bn(e.state(), t.product, t.product_identifier);
|
|
146
|
+
a([sn(c)]), ye(
|
|
147
|
+
() => n.purchase(c),
|
|
148
|
+
(h) => {
|
|
149
|
+
if (h === "completed") {
|
|
150
|
+
const p = ht(c), r = [an(c)];
|
|
151
|
+
re(e.state()) && p > 0 && r.push(cn(c, l() + p * fn)), a(r);
|
|
152
|
+
} else a(h === "abandoned" ? [on(c)] : [Ke(c)]);
|
|
152
153
|
},
|
|
153
|
-
(
|
|
154
|
-
|
|
154
|
+
(h) => {
|
|
155
|
+
xe("purchase delegate threw", h), a([Ke(c)]);
|
|
155
156
|
}
|
|
156
157
|
);
|
|
157
|
-
},
|
|
158
|
-
const { delegate: t, send:
|
|
159
|
-
|
|
158
|
+
}, gn = (e) => {
|
|
159
|
+
const { delegate: t, send: n } = e;
|
|
160
|
+
n([dn()]), ye(
|
|
160
161
|
() => t.restore(),
|
|
161
|
-
(
|
|
162
|
-
a
|
|
162
|
+
(a) => {
|
|
163
|
+
n(a === "restored" ? [ln(), un()] : [Ye()]);
|
|
163
164
|
},
|
|
164
|
-
(
|
|
165
|
-
|
|
165
|
+
(a) => {
|
|
166
|
+
xe("restore delegate threw", a), n([Ye()]);
|
|
166
167
|
}
|
|
167
168
|
);
|
|
168
|
-
},
|
|
169
|
-
const { delegate:
|
|
170
|
-
|
|
169
|
+
}, vn = (e, t) => {
|
|
170
|
+
const { delegate: n, send: a } = e, l = (c) => a([
|
|
171
|
+
hn({
|
|
171
172
|
permissionType: t.permission_type,
|
|
172
173
|
requestId: t.request_id,
|
|
173
|
-
status:
|
|
174
|
+
status: c
|
|
174
175
|
})
|
|
175
176
|
]);
|
|
176
|
-
|
|
177
|
-
() =>
|
|
178
|
-
|
|
179
|
-
(
|
|
180
|
-
|
|
177
|
+
ye(
|
|
178
|
+
() => n.permission(t.permission_type),
|
|
179
|
+
l,
|
|
180
|
+
(c) => {
|
|
181
|
+
xe("permission delegate threw", c), l("denied");
|
|
181
182
|
}
|
|
182
183
|
);
|
|
183
|
-
},
|
|
184
|
-
const { delegate:
|
|
185
|
-
|
|
184
|
+
}, yn = (e, t) => {
|
|
185
|
+
const { delegate: n, send: a } = e, l = (c) => a([
|
|
186
|
+
mn({
|
|
186
187
|
requestId: t.request_id,
|
|
187
188
|
name: t.name,
|
|
188
|
-
status:
|
|
189
|
-
...
|
|
189
|
+
status: c.status,
|
|
190
|
+
...c.data === void 0 ? {} : { data: c.data }
|
|
190
191
|
})
|
|
191
192
|
]);
|
|
192
|
-
|
|
193
|
-
() =>
|
|
194
|
-
|
|
195
|
-
(
|
|
196
|
-
|
|
193
|
+
ye(
|
|
194
|
+
() => n.callback(t.name, t.variables ?? {}),
|
|
195
|
+
l,
|
|
196
|
+
(c) => {
|
|
197
|
+
xe("callback delegate threw", c), l({ status: "failure" });
|
|
197
198
|
}
|
|
198
199
|
);
|
|
199
|
-
},
|
|
200
|
+
}, qe = (e) => JSON.stringify([
|
|
200
201
|
e.device,
|
|
201
202
|
e.user,
|
|
202
203
|
e.params,
|
|
203
204
|
e.products.map((t) => [t.reference, t.variables])
|
|
204
|
-
]),
|
|
205
|
-
let t =
|
|
206
|
-
const { delegate:
|
|
205
|
+
]), Je = (e) => JSON.stringify(e.products.map((t) => [t.reference, t.productId])), Xe = (e) => JSON.stringify(e.experiment), xn = (e) => {
|
|
206
|
+
let t = ut(e.state);
|
|
207
|
+
const { delegate: n, send: a } = e, l = {
|
|
207
208
|
state: () => t,
|
|
208
|
-
delegate:
|
|
209
|
-
send:
|
|
209
|
+
delegate: n,
|
|
210
|
+
send: a,
|
|
210
211
|
now: e.now ?? Date.now
|
|
211
|
-
},
|
|
212
|
-
switch (
|
|
212
|
+
}, c = (r) => {
|
|
213
|
+
switch (r.event_name) {
|
|
213
214
|
case "ping":
|
|
214
|
-
|
|
215
|
+
a(rn(t));
|
|
215
216
|
return;
|
|
216
217
|
case "purchase":
|
|
217
|
-
|
|
218
|
+
wn(l, r);
|
|
218
219
|
return;
|
|
219
220
|
case "restore":
|
|
220
|
-
|
|
221
|
+
gn(l);
|
|
221
222
|
return;
|
|
222
223
|
case "close":
|
|
223
|
-
|
|
224
|
+
n.close(), a([nn(t)]);
|
|
224
225
|
return;
|
|
225
226
|
case "open_url":
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
227
|
+
n.openUrl(
|
|
228
|
+
r.url,
|
|
229
|
+
r.browser_type === "payment_sheet" ? "payment_sheet" : "in_app"
|
|
229
230
|
);
|
|
230
231
|
return;
|
|
231
232
|
case "open_url_external":
|
|
232
|
-
|
|
233
|
+
n.openUrl(r.url, "external");
|
|
233
234
|
return;
|
|
234
235
|
case "open_deep_link":
|
|
235
|
-
|
|
236
|
+
n.openUrl(r.link, "deep_link");
|
|
236
237
|
return;
|
|
237
238
|
case "custom":
|
|
238
|
-
|
|
239
|
+
n.custom(r.data);
|
|
239
240
|
return;
|
|
240
241
|
case "custom_placement":
|
|
241
|
-
|
|
242
|
+
n.customPlacement(r.name, r.params);
|
|
242
243
|
return;
|
|
243
244
|
case "user_attribute_updated":
|
|
244
|
-
t =
|
|
245
|
-
user: Object.fromEntries(
|
|
245
|
+
t = Ge(t, {
|
|
246
|
+
user: Object.fromEntries(r.attributes.map((i) => [i.key, i.value]))
|
|
246
247
|
});
|
|
247
248
|
return;
|
|
248
249
|
case "request_permission":
|
|
249
|
-
|
|
250
|
+
vn(l, r);
|
|
250
251
|
return;
|
|
251
252
|
case "request_callback":
|
|
252
|
-
|
|
253
|
+
yn(l, r);
|
|
253
254
|
return;
|
|
254
255
|
default:
|
|
255
256
|
return;
|
|
@@ -259,80 +260,80 @@ const It = ({
|
|
|
259
260
|
get state() {
|
|
260
261
|
return t;
|
|
261
262
|
},
|
|
262
|
-
receive: (
|
|
263
|
-
for (const
|
|
264
|
-
|
|
263
|
+
receive: (r) => {
|
|
264
|
+
for (const i of r)
|
|
265
|
+
n.event(i), c(i);
|
|
265
266
|
},
|
|
266
|
-
update: (
|
|
267
|
-
const
|
|
268
|
-
t =
|
|
269
|
-
const
|
|
270
|
-
|
|
267
|
+
update: (r) => {
|
|
268
|
+
const i = t;
|
|
269
|
+
t = Ge(t, r);
|
|
270
|
+
const o = [];
|
|
271
|
+
qe(i) !== qe(t) && o.push(mt(t)), Xe(i) !== Xe(t) && o.push(pt(t)), Je(i) !== Je(t) && o.push(ft(t)), re(i) !== re(t) && o.push(bt(t)), o.length > 0 && a(o);
|
|
271
272
|
},
|
|
272
|
-
send:
|
|
273
|
+
send: a
|
|
273
274
|
};
|
|
274
|
-
},
|
|
275
|
+
}, Nn = () => typeof localStorage < "u" && localStorage.getItem("SW_DEBUG_TRANSPORT") === "true", Sn = {
|
|
275
276
|
WebKit: "#9C27B0",
|
|
276
277
|
Android: "#4CAF50",
|
|
277
278
|
Editor: "#2196F3",
|
|
278
279
|
Transport: "#FF9800"
|
|
279
|
-
},
|
|
280
|
-
const t =
|
|
281
|
-
if (!
|
|
282
|
-
const
|
|
283
|
-
switch (
|
|
280
|
+
}, En = (e) => {
|
|
281
|
+
const t = Sn[e], n = (a, l, ...c) => {
|
|
282
|
+
if (!Nn() && a === "debug") return;
|
|
283
|
+
const h = `%c[${e}]%c ${l}`, p = [`color: ${t}; font-weight: bold`, "color: inherit"];
|
|
284
|
+
switch (a) {
|
|
284
285
|
case "error":
|
|
285
|
-
console.error(
|
|
286
|
+
console.error(h, ...p, ...c);
|
|
286
287
|
break;
|
|
287
288
|
case "warn":
|
|
288
|
-
console.warn(
|
|
289
|
+
console.warn(h, ...p, ...c);
|
|
289
290
|
break;
|
|
290
291
|
case "info":
|
|
291
|
-
console.info(
|
|
292
|
+
console.info(h, ...p, ...c);
|
|
292
293
|
break;
|
|
293
294
|
default:
|
|
294
|
-
console.log(
|
|
295
|
+
console.log(h, ...p, ...c);
|
|
295
296
|
}
|
|
296
297
|
};
|
|
297
298
|
return {
|
|
298
|
-
debug: (
|
|
299
|
-
info: (
|
|
300
|
-
warn: (
|
|
301
|
-
error: (
|
|
299
|
+
debug: (a, ...l) => n("debug", a, ...l),
|
|
300
|
+
info: (a, ...l) => n("info", a, ...l),
|
|
301
|
+
warn: (a, ...l) => n("warn", a, ...l),
|
|
302
|
+
error: (a, ...l) => n("error", a, ...l)
|
|
302
303
|
};
|
|
303
304
|
};
|
|
304
|
-
var
|
|
305
|
-
const
|
|
306
|
-
const
|
|
305
|
+
var je = /* @__PURE__ */ ((e) => (e.ToPaywall = "to_paywall", e.FromPaywall = "from_paywall", e.ToPaywallUi = "to_paywall_ui", e.FromPaywallUi = "from_paywall_ui", e))(je || {});
|
|
306
|
+
const Cn = (e, t) => {
|
|
307
|
+
const n = {
|
|
307
308
|
direction: t,
|
|
308
309
|
version: 1,
|
|
309
310
|
payload: { events: Array.isArray(e) ? e : [e] }
|
|
310
311
|
};
|
|
311
|
-
return JSON.stringify(
|
|
312
|
-
},
|
|
312
|
+
return JSON.stringify(n);
|
|
313
|
+
}, _n = () => ({
|
|
313
314
|
parse: (e) => e
|
|
314
|
-
}),
|
|
315
|
+
}), In = En("Transport"), Mn = (e, t, n = _n()) => {
|
|
315
316
|
try {
|
|
316
|
-
const
|
|
317
|
-
if (
|
|
317
|
+
const a = n.parse(JSON.parse(e));
|
|
318
|
+
if (a.direction !== t)
|
|
318
319
|
throw new Error("Message direction incorrect");
|
|
319
|
-
return
|
|
320
|
-
} catch (
|
|
321
|
-
return
|
|
320
|
+
return a.payload.events;
|
|
321
|
+
} catch (a) {
|
|
322
|
+
return In.error("Failed to parse incoming message", { message: e, error: a }), [];
|
|
322
323
|
}
|
|
323
|
-
},
|
|
324
|
-
e.postMessage(
|
|
325
|
-
},
|
|
326
|
-
const
|
|
327
|
-
if (
|
|
328
|
-
const
|
|
329
|
-
|
|
324
|
+
}, kn = (e) => (t) => {
|
|
325
|
+
e.postMessage(Cn([...t], je.ToPaywall), "*");
|
|
326
|
+
}, Pn = (e, t, n = {}) => {
|
|
327
|
+
const a = n.listen ?? window, l = (c) => {
|
|
328
|
+
if (c.source !== t || typeof c.data != "string") return;
|
|
329
|
+
const h = Mn(c.data, je.FromPaywall);
|
|
330
|
+
h.length > 0 && e.receive(h);
|
|
330
331
|
};
|
|
331
|
-
return
|
|
332
|
-
},
|
|
333
|
-
const { target: t, listen:
|
|
334
|
-
return { host:
|
|
335
|
-
},
|
|
332
|
+
return a.addEventListener("message", l), () => a.removeEventListener("message", l);
|
|
333
|
+
}, Rn = (e) => {
|
|
334
|
+
const { target: t, listen: n, ...a } = e, l = xn({ ...a, send: kn(t) }), c = Pn(l, t, n ? { listen: n } : {});
|
|
335
|
+
return { host: l, detach: c };
|
|
336
|
+
}, Ie = 1440 * 60 * 1e3, Me = 60 * 1e3, wt = -18e3, Le = {
|
|
336
337
|
publicApiKey: "pk_8d21d5122bb23839a2de6c8c76975e74f85b43ab4476c039",
|
|
337
338
|
platform: "iOS",
|
|
338
339
|
appUserId: "44dd573cd1e849a6997a5eaf98298e47",
|
|
@@ -345,7 +346,7 @@ const Qt = (e, t) => {
|
|
|
345
346
|
deviceLanguageCode: "en",
|
|
346
347
|
deviceCurrencyCode: "USD",
|
|
347
348
|
deviceCurrencySymbol: "$",
|
|
348
|
-
timezoneOffset:
|
|
349
|
+
timezoneOffset: wt,
|
|
349
350
|
radioType: "Wifi",
|
|
350
351
|
interfaceStyle: "Dark",
|
|
351
352
|
isLowPowerModeEnabled: 0,
|
|
@@ -353,295 +354,295 @@ const Qt = (e, t) => {
|
|
|
353
354
|
isMac: 0,
|
|
354
355
|
totalPaywallViews: 0,
|
|
355
356
|
interfaceType: "iphone"
|
|
356
|
-
},
|
|
357
|
-
const t = `${e.getUTCFullYear()}-${
|
|
358
|
-
return { date: t, time:
|
|
359
|
-
},
|
|
360
|
-
const
|
|
357
|
+
}, te = (e) => String(e).padStart(2, "0"), Ze = (e) => {
|
|
358
|
+
const t = `${e.getUTCFullYear()}-${te(e.getUTCMonth() + 1)}-${te(e.getUTCDate())}`, n = `${te(e.getUTCHours())}:${te(e.getUTCMinutes())}:${te(e.getUTCSeconds())}`;
|
|
359
|
+
return { date: t, time: n, dateTime: `${t}T${n}` };
|
|
360
|
+
}, On = (e, t = wt) => {
|
|
361
|
+
const n = e - 5 * Ie, a = e - 360 * Me, l = Ze(new Date(e)), c = Ze(new Date(e + t * 1e3));
|
|
361
362
|
return {
|
|
362
|
-
daysSinceInstall: Math.floor((e -
|
|
363
|
-
minutesSinceInstall: Math.floor((e -
|
|
364
|
-
appInstallDate: new Date(
|
|
365
|
-
daysSinceLastPaywallView: Math.floor((e -
|
|
366
|
-
minutesSinceLastPaywallView: Math.floor((e -
|
|
367
|
-
utcDate:
|
|
368
|
-
localDate:
|
|
369
|
-
utcTime:
|
|
370
|
-
localTime:
|
|
371
|
-
utcDateTime:
|
|
372
|
-
localDateTime:
|
|
363
|
+
daysSinceInstall: Math.floor((e - n) / Ie),
|
|
364
|
+
minutesSinceInstall: Math.floor((e - n) / Me),
|
|
365
|
+
appInstallDate: new Date(n).toISOString(),
|
|
366
|
+
daysSinceLastPaywallView: Math.floor((e - a) / Ie),
|
|
367
|
+
minutesSinceLastPaywallView: Math.floor((e - a) / Me),
|
|
368
|
+
utcDate: l.date,
|
|
369
|
+
localDate: c.date,
|
|
370
|
+
utcTime: l.time,
|
|
371
|
+
localTime: c.time,
|
|
372
|
+
utcDateTime: l.dateTime,
|
|
373
|
+
localDateTime: c.dateTime
|
|
373
374
|
};
|
|
374
|
-
},
|
|
375
|
-
...
|
|
376
|
-
...
|
|
377
|
-
}),
|
|
378
|
-
appUserId:
|
|
375
|
+
}, An = (e = Date.now()) => ({
|
|
376
|
+
...Le,
|
|
377
|
+
...On(e, Le.timezoneOffset)
|
|
378
|
+
}), Tn = {
|
|
379
|
+
appUserId: Le.appUserId,
|
|
379
380
|
email: "preview@example.com",
|
|
380
381
|
firstName: "John",
|
|
381
382
|
lastName: "Doe",
|
|
382
383
|
country: "US",
|
|
383
384
|
language: "en"
|
|
384
|
-
},
|
|
385
|
+
}, Ln = {
|
|
385
386
|
$event_name: "campaign_trigger",
|
|
386
387
|
event_name: "campaign_trigger",
|
|
387
388
|
$is_standard_event: !1,
|
|
388
389
|
$is_feature_gatable: !1
|
|
389
|
-
},
|
|
390
|
-
/* @__PURE__ */
|
|
391
|
-
/* @__PURE__ */
|
|
392
|
-
] }),
|
|
393
|
-
/* @__PURE__ */
|
|
394
|
-
/* @__PURE__ */
|
|
395
|
-
/* @__PURE__ */
|
|
396
|
-
] }),
|
|
397
|
-
/* @__PURE__ */
|
|
398
|
-
/* @__PURE__ */
|
|
399
|
-
] }),
|
|
400
|
-
/* @__PURE__ */
|
|
401
|
-
/* @__PURE__ */
|
|
402
|
-
] }),
|
|
403
|
-
/* @__PURE__ */
|
|
404
|
-
/* @__PURE__ */
|
|
405
|
-
] }),
|
|
406
|
-
/* @__PURE__ */
|
|
407
|
-
/* @__PURE__ */
|
|
408
|
-
] }),
|
|
409
|
-
/* @__PURE__ */
|
|
410
|
-
/* @__PURE__ */
|
|
411
|
-
/* @__PURE__ */
|
|
412
|
-
] }),
|
|
413
|
-
/* @__PURE__ */
|
|
414
|
-
/* @__PURE__ */
|
|
415
|
-
/* @__PURE__ */
|
|
416
|
-
] }),
|
|
417
|
-
/* @__PURE__ */
|
|
418
|
-
/* @__PURE__ */
|
|
419
|
-
/* @__PURE__ */
|
|
420
|
-
] }),
|
|
421
|
-
/* @__PURE__ */
|
|
422
|
-
/* @__PURE__ */
|
|
423
|
-
] }),
|
|
424
|
-
/* @__PURE__ */
|
|
425
|
-
/* @__PURE__ */
|
|
426
|
-
] }),
|
|
427
|
-
/* @__PURE__ */
|
|
428
|
-
/* @__PURE__ */
|
|
429
|
-
/* @__PURE__ */
|
|
430
|
-
] }),
|
|
390
|
+
}, k = ({ children: e }) => /* @__PURE__ */ s("svg", { className: "sw-icon", viewBox: "0 0 24 24", "aria-hidden": "true", children: e }), gt = () => /* @__PURE__ */ f(k, { children: [
|
|
391
|
+
/* @__PURE__ */ s("path", { d: "M21 12a9 9 0 1 1-2.64-6.36" }),
|
|
392
|
+
/* @__PURE__ */ s("path", { d: "M21 3v6h-6" })
|
|
393
|
+
] }), he = () => /* @__PURE__ */ f(k, { children: [
|
|
394
|
+
/* @__PURE__ */ s("path", { d: "M15 3h6v6" }),
|
|
395
|
+
/* @__PURE__ */ s("path", { d: "M10 14 21 3" }),
|
|
396
|
+
/* @__PURE__ */ s("path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" })
|
|
397
|
+
] }), $n = () => /* @__PURE__ */ f(k, { children: [
|
|
398
|
+
/* @__PURE__ */ s("circle", { cx: "12", cy: "12", r: "4" }),
|
|
399
|
+
/* @__PURE__ */ s("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" })
|
|
400
|
+
] }), Dn = () => /* @__PURE__ */ s(k, { children: /* @__PURE__ */ s("path", { d: "M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z" }) }), Fn = () => /* @__PURE__ */ f(k, { children: [
|
|
401
|
+
/* @__PURE__ */ s("path", { d: "M21 4h-7M10 4H3M21 12h-9M8 12H3M21 20h-5M12 20H3" }),
|
|
402
|
+
/* @__PURE__ */ s("path", { d: "M14 2v4M8 10v4M16 18v4" })
|
|
403
|
+
] }), vt = () => /* @__PURE__ */ s(k, { children: /* @__PURE__ */ s("path", { d: "M18 6 6 18M6 6l12 12" }) }), yt = () => /* @__PURE__ */ s(k, { children: /* @__PURE__ */ s("path", { d: "m6 9 6 6 6-6" }) }), Un = () => /* @__PURE__ */ f(k, { children: [
|
|
404
|
+
/* @__PURE__ */ s("rect", { x: "3", y: "4", width: "18", height: "16" }),
|
|
405
|
+
/* @__PURE__ */ s("path", { d: "M12 4v16" })
|
|
406
|
+
] }), me = () => /* @__PURE__ */ f(k, { children: [
|
|
407
|
+
/* @__PURE__ */ s("circle", { cx: "12", cy: "12", r: "9" }),
|
|
408
|
+
/* @__PURE__ */ s("path", { d: "m8.5 12 2.5 2.5 4.5-5" })
|
|
409
|
+
] }), pe = () => /* @__PURE__ */ f(k, { children: [
|
|
410
|
+
/* @__PURE__ */ s("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" }),
|
|
411
|
+
/* @__PURE__ */ s("path", { d: "M12 9v4" }),
|
|
412
|
+
/* @__PURE__ */ s("path", { d: "M12 17h.01" })
|
|
413
|
+
] }), xt = () => /* @__PURE__ */ f(k, { children: [
|
|
414
|
+
/* @__PURE__ */ s("circle", { cx: "12", cy: "12", r: "9" }),
|
|
415
|
+
/* @__PURE__ */ s("path", { d: "M12 11v5" }),
|
|
416
|
+
/* @__PURE__ */ s("path", { d: "M12 8h.01" })
|
|
417
|
+
] }), ce = () => /* @__PURE__ */ s(k, { children: /* @__PURE__ */ s("path", { d: "M13 2 4.5 13H11l-1 9 8.5-11H12l1-9Z" }) }), ke = () => /* @__PURE__ */ f(k, { children: [
|
|
418
|
+
/* @__PURE__ */ s("circle", { cx: "9", cy: "20", r: "1" }),
|
|
419
|
+
/* @__PURE__ */ s("circle", { cx: "18", cy: "20", r: "1" }),
|
|
420
|
+
/* @__PURE__ */ s("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" })
|
|
421
|
+
] }), Bn = () => /* @__PURE__ */ f(k, { children: [
|
|
422
|
+
/* @__PURE__ */ s("path", { d: "M18 8a6 6 0 1 0-12 0c0 6-2 8-2 8h16s-2-2-2-8" }),
|
|
423
|
+
/* @__PURE__ */ s("path", { d: "M13.7 21a2 2 0 0 1-3.4 0" })
|
|
424
|
+
] }), jn = () => /* @__PURE__ */ s(k, { children: /* @__PURE__ */ s("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" }) }), zn = () => /* @__PURE__ */ f(k, { children: [
|
|
425
|
+
/* @__PURE__ */ s("path", { d: "M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" }),
|
|
426
|
+
/* @__PURE__ */ s("circle", { cx: "12", cy: "7", r: "4" })
|
|
427
|
+
] }), Hn = () => /* @__PURE__ */ f(k, { children: [
|
|
428
|
+
/* @__PURE__ */ s("rect", { x: "4", y: "2", width: "10", height: "16", rx: "2" }),
|
|
429
|
+
/* @__PURE__ */ s("path", { d: "M17 12a5 5 0 0 1-5 9H9" }),
|
|
430
|
+
/* @__PURE__ */ s("path", { d: "m11 19-2 2 2 2" })
|
|
431
|
+
] }), be = {
|
|
431
432
|
push: ["link", "build", "assets", "push", "source"],
|
|
432
433
|
publish: ["link", "build", "assets", "push", "source", "promote"],
|
|
433
434
|
promote: ["link", "promote"]
|
|
434
|
-
},
|
|
435
|
+
}, Vn = {
|
|
435
436
|
link: "Find paywall",
|
|
436
437
|
build: "Build snapshot",
|
|
437
438
|
assets: "Sync assets",
|
|
438
439
|
push: "Push version",
|
|
439
440
|
source: "Push source",
|
|
440
441
|
promote: "Promote to live"
|
|
441
|
-
},
|
|
442
|
+
}, Nt = [
|
|
442
443
|
{ name: "push", label: "Push", hint: "New version, nothing live changes" },
|
|
443
|
-
{ name: "
|
|
444
|
-
{ name: "
|
|
445
|
-
],
|
|
444
|
+
{ name: "promote", label: "Promote", hint: "Make the latest push live" },
|
|
445
|
+
{ name: "publish", label: "Publish", hint: "Push and make it live" }
|
|
446
|
+
], $e = (e) => Nt.find((t) => t.name === e)?.label ?? e, St = {
|
|
446
447
|
push: "Pushing…",
|
|
447
448
|
publish: "Publishing…",
|
|
448
449
|
promote: "Promoting…"
|
|
449
|
-
},
|
|
450
|
-
const t =
|
|
451
|
-
return /* @__PURE__ */
|
|
452
|
-
/* @__PURE__ */
|
|
453
|
-
/* @__PURE__ */
|
|
454
|
-
/* @__PURE__ */
|
|
450
|
+
}, Qn = ({ state: e }) => e === "active" ? /* @__PURE__ */ s("span", { className: "bg-accent h-2 w-2 rounded-full animate-pulse" }) : e === "done" ? /* @__PURE__ */ s("span", { className: "bg-accent h-2 w-2 rounded-full" }) : e === "failed" ? /* @__PURE__ */ s("span", { className: "bg-red h-2 w-2 rounded-full" }) : /* @__PURE__ */ s("span", { className: "bg-cream/55 h-2 w-2 rounded-full" }), Wn = ({ progress: e }) => {
|
|
451
|
+
const t = be[e.action], n = t.filter((l) => e.steps[l] === "done").length, a = e.error !== void 0;
|
|
452
|
+
return /* @__PURE__ */ f("div", { className: "w-64", children: [
|
|
453
|
+
/* @__PURE__ */ f("div", { className: "border-b border-cream/10 px-3 py-2.5", children: [
|
|
454
|
+
/* @__PURE__ */ s("div", { className: "text-[0.8125rem] font-medium", children: a ? `${$e(e.action)} failed` : n === t.length ? `${$e(e.action)} complete` : St[e.action] }),
|
|
455
|
+
/* @__PURE__ */ s("div", { className: "mt-2 h-0.5 w-full bg-cream/10", children: /* @__PURE__ */ s(
|
|
455
456
|
"div",
|
|
456
457
|
{
|
|
457
|
-
className: `h-full transition-[width] duration-300 ease-out ${
|
|
458
|
-
style: { width: `${
|
|
458
|
+
className: `h-full transition-[width] duration-300 ease-out ${a ? "bg-red" : "bg-accent"}`,
|
|
459
|
+
style: { width: `${n / t.length * 100}%` }
|
|
459
460
|
}
|
|
460
461
|
) })
|
|
461
462
|
] }),
|
|
462
|
-
/* @__PURE__ */
|
|
463
|
-
const
|
|
464
|
-
return /* @__PURE__ */
|
|
465
|
-
/* @__PURE__ */
|
|
463
|
+
/* @__PURE__ */ s("ul", { className: "m-0 list-none px-3 py-2", children: t.map((l, c) => {
|
|
464
|
+
const h = e.steps[l] ?? "pending";
|
|
465
|
+
return /* @__PURE__ */ f("li", { className: "flex items-center gap-2.5 py-1.5", children: [
|
|
466
|
+
/* @__PURE__ */ s(
|
|
466
467
|
"span",
|
|
467
468
|
{
|
|
468
|
-
className: `w-4 font-mono text-[0.625rem] tabular-nums ${
|
|
469
|
-
children: String(
|
|
469
|
+
className: `w-4 font-mono text-[0.625rem] tabular-nums ${h === "pending" ? "text-cream/25" : "text-cream/55"}`,
|
|
470
|
+
children: String(c + 1).padStart(2, "0")
|
|
470
471
|
}
|
|
471
472
|
),
|
|
472
|
-
/* @__PURE__ */
|
|
473
|
+
/* @__PURE__ */ s(
|
|
473
474
|
"span",
|
|
474
475
|
{
|
|
475
|
-
className: `flex-1 text-[0.8125rem] ${
|
|
476
|
-
children:
|
|
476
|
+
className: `flex-1 text-[0.8125rem] ${h === "pending" ? "text-cream/40" : "text-cream"}`,
|
|
477
|
+
children: Vn[l]
|
|
477
478
|
}
|
|
478
479
|
),
|
|
479
|
-
/* @__PURE__ */
|
|
480
|
-
] },
|
|
480
|
+
/* @__PURE__ */ s(Qn, { state: h })
|
|
481
|
+
] }, l);
|
|
481
482
|
}) }),
|
|
482
|
-
e.error && /* @__PURE__ */
|
|
483
|
+
e.error && /* @__PURE__ */ s("div", { className: "text-red border-t border-cream/10 px-3 py-2.5 text-xs whitespace-pre-wrap", children: e.error })
|
|
483
484
|
] });
|
|
484
|
-
},
|
|
485
|
+
}, Gn = ({
|
|
485
486
|
progress: e,
|
|
486
487
|
blocked: t,
|
|
487
|
-
onRun:
|
|
488
|
-
onBlocked:
|
|
488
|
+
onRun: n,
|
|
489
|
+
onBlocked: a
|
|
489
490
|
}) => {
|
|
490
|
-
const [
|
|
491
|
-
return
|
|
492
|
-
if (!
|
|
493
|
-
const u = (
|
|
494
|
-
|
|
491
|
+
const [l, c] = w.useState("push"), [h, p] = w.useState(!1), r = w.useRef(null), i = t !== void 0, o = e !== void 0 && e.error === void 0 && be[e.action].some((u) => e.steps[u] !== "done"), d = e !== void 0;
|
|
492
|
+
return w.useEffect(() => {
|
|
493
|
+
if (!h) return;
|
|
494
|
+
const u = (m) => {
|
|
495
|
+
r.current && !m.composedPath().includes(r.current) && p(!1);
|
|
495
496
|
};
|
|
496
497
|
return window.addEventListener("mousedown", u), () => window.removeEventListener("mousedown", u);
|
|
497
|
-
}, [
|
|
498
|
-
/* @__PURE__ */
|
|
498
|
+
}, [h]), /* @__PURE__ */ f("div", { className: "relative flex", ref: r, children: [
|
|
499
|
+
/* @__PURE__ */ s(
|
|
499
500
|
"button",
|
|
500
501
|
{
|
|
501
502
|
type: "button",
|
|
502
|
-
className: "sw-btn sw-btn--primary disabled:cursor-not-allowed disabled:opacity-40",
|
|
503
|
-
disabled:
|
|
503
|
+
className: "sw-btn sw-btn--primary rounded-r-none disabled:cursor-not-allowed disabled:opacity-40",
|
|
504
|
+
disabled: o,
|
|
504
505
|
title: t,
|
|
505
|
-
onClick: () =>
|
|
506
|
-
children:
|
|
506
|
+
onClick: () => i ? a?.() : n(l),
|
|
507
|
+
children: o ? St[e.action] : $e(l)
|
|
507
508
|
}
|
|
508
509
|
),
|
|
509
|
-
/* @__PURE__ */
|
|
510
|
+
/* @__PURE__ */ s(
|
|
510
511
|
"button",
|
|
511
512
|
{
|
|
512
513
|
type: "button",
|
|
513
|
-
className: "sw-btn sw-btn--primary -ml-px w-6 !px-0 disabled:cursor-not-allowed disabled:opacity-40",
|
|
514
|
+
className: "sw-btn sw-btn--primary -ml-px w-6 rounded-l-none !px-0 disabled:cursor-not-allowed disabled:opacity-40",
|
|
514
515
|
"aria-label": "Choose action",
|
|
515
|
-
"aria-expanded":
|
|
516
|
+
"aria-expanded": h,
|
|
516
517
|
title: t,
|
|
517
|
-
disabled:
|
|
518
|
+
disabled: o,
|
|
518
519
|
onClick: () => p((u) => !u),
|
|
519
|
-
children: /* @__PURE__ */
|
|
520
|
+
children: /* @__PURE__ */ s(yt, {})
|
|
520
521
|
}
|
|
521
522
|
),
|
|
522
|
-
(
|
|
523
|
+
(d || h) && /* @__PURE__ */ s("div", { className: "bg-bar absolute top-full right-0 z-20 mt-1 overflow-hidden rounded border border-cream/20", children: d ? /* @__PURE__ */ s(Wn, { progress: e }) : /* @__PURE__ */ s("div", { className: "w-64", children: Nt.map((u) => /* @__PURE__ */ f(
|
|
523
524
|
"button",
|
|
524
525
|
{
|
|
525
526
|
type: "button",
|
|
526
527
|
className: "flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left transition-colors hover:bg-cream/5",
|
|
527
528
|
onClick: () => {
|
|
528
|
-
|
|
529
|
+
c(u.name), p(!1);
|
|
529
530
|
},
|
|
530
531
|
children: [
|
|
531
|
-
/* @__PURE__ */
|
|
532
|
-
/* @__PURE__ */
|
|
532
|
+
/* @__PURE__ */ s("span", { className: "text-[0.8125rem] font-medium", children: u.label }),
|
|
533
|
+
/* @__PURE__ */ s("span", { className: "text-xs text-cream/55", children: u.hint })
|
|
533
534
|
]
|
|
534
535
|
},
|
|
535
536
|
u.name
|
|
536
537
|
)) }) })
|
|
537
538
|
] });
|
|
538
|
-
},
|
|
539
|
+
}, Pe = ({
|
|
539
540
|
label: e,
|
|
540
541
|
hint: t,
|
|
541
|
-
selected:
|
|
542
|
-
onSelect:
|
|
543
|
-
}) => /* @__PURE__ */
|
|
542
|
+
selected: n,
|
|
543
|
+
onSelect: a
|
|
544
|
+
}) => /* @__PURE__ */ f(
|
|
544
545
|
"button",
|
|
545
546
|
{
|
|
546
547
|
type: "button",
|
|
547
548
|
className: "flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left transition-colors hover:bg-cream/5",
|
|
548
|
-
"aria-current":
|
|
549
|
-
onClick:
|
|
549
|
+
"aria-current": n || void 0,
|
|
550
|
+
onClick: a,
|
|
550
551
|
children: [
|
|
551
|
-
/* @__PURE__ */
|
|
552
|
-
/* @__PURE__ */
|
|
553
|
-
|
|
552
|
+
/* @__PURE__ */ f("span", { className: "flex max-w-full items-center gap-1.5 text-[0.8125rem] font-medium", children: [
|
|
553
|
+
/* @__PURE__ */ s("span", { className: "truncate", children: e }),
|
|
554
|
+
n && /* @__PURE__ */ s("span", { className: "bg-accent size-[5px] shrink-0 rounded-full", "aria-hidden": "true" })
|
|
554
555
|
] }),
|
|
555
|
-
/* @__PURE__ */
|
|
556
|
+
/* @__PURE__ */ s("span", { className: "max-w-full truncate text-xs text-cream/55", children: t })
|
|
556
557
|
]
|
|
557
558
|
}
|
|
558
|
-
),
|
|
559
|
+
), Kn = ({
|
|
559
560
|
active: e,
|
|
560
561
|
options: t,
|
|
561
|
-
onSelect:
|
|
562
|
+
onSelect: n
|
|
562
563
|
}) => {
|
|
563
|
-
const [
|
|
564
|
-
|
|
565
|
-
if (!
|
|
566
|
-
const
|
|
567
|
-
p.current && !
|
|
564
|
+
const [a, l] = w.useState(!1), [c, h] = w.useState(""), p = w.useRef(null);
|
|
565
|
+
w.useEffect(() => {
|
|
566
|
+
if (!a) return;
|
|
567
|
+
const m = (b) => {
|
|
568
|
+
p.current && !b.composedPath().includes(p.current) && l(!1);
|
|
568
569
|
};
|
|
569
|
-
return window.addEventListener("mousedown",
|
|
570
|
-
}, [
|
|
571
|
-
|
|
572
|
-
}, [
|
|
573
|
-
const
|
|
574
|
-
|
|
575
|
-
},
|
|
576
|
-
(
|
|
570
|
+
return window.addEventListener("mousedown", m), () => window.removeEventListener("mousedown", m);
|
|
571
|
+
}, [a]), w.useEffect(() => {
|
|
572
|
+
a || h("");
|
|
573
|
+
}, [a]);
|
|
574
|
+
const r = e && (e.type === "live" ? "live" : `surface:${e.surface.kind}/${e.surface.id}`), i = (m) => {
|
|
575
|
+
l(!1), n(m);
|
|
576
|
+
}, o = c.trim().toLowerCase(), d = t.filter((m) => m.key === "live"), u = t.filter((m) => m.key !== "live").filter(
|
|
577
|
+
(m) => o === "" || `${m.label} ${m.hint}`.toLowerCase().includes(o)
|
|
577
578
|
);
|
|
578
|
-
return /* @__PURE__ */
|
|
579
|
-
/* @__PURE__ */
|
|
579
|
+
return /* @__PURE__ */ f("div", { className: "relative flex", ref: p, children: [
|
|
580
|
+
/* @__PURE__ */ f(
|
|
580
581
|
"button",
|
|
581
582
|
{
|
|
582
583
|
type: "button",
|
|
583
584
|
className: "sw-btn",
|
|
584
585
|
"aria-pressed": e !== void 0,
|
|
585
|
-
"aria-expanded":
|
|
586
|
-
onClick: () =>
|
|
586
|
+
"aria-expanded": a,
|
|
587
|
+
onClick: () => l((m) => !m),
|
|
587
588
|
children: [
|
|
588
|
-
/* @__PURE__ */
|
|
589
|
+
/* @__PURE__ */ s(Un, {}),
|
|
589
590
|
"Compare"
|
|
590
591
|
]
|
|
591
592
|
}
|
|
592
593
|
),
|
|
593
|
-
|
|
594
|
-
/* @__PURE__ */
|
|
594
|
+
a && /* @__PURE__ */ f("div", { className: "bg-bar absolute bottom-full left-0 z-20 mb-1 flex w-72 flex-col overflow-hidden rounded border border-cream/20", children: [
|
|
595
|
+
/* @__PURE__ */ s("div", { className: "p-2", children: /* @__PURE__ */ s(
|
|
595
596
|
"input",
|
|
596
597
|
{
|
|
597
598
|
className: "sw-input",
|
|
598
599
|
type: "search",
|
|
599
|
-
value:
|
|
600
|
+
value: c,
|
|
600
601
|
placeholder: "Search paywalls",
|
|
601
602
|
"aria-label": "Search paywalls",
|
|
602
|
-
onChange: (
|
|
603
|
+
onChange: (m) => h(m.target.value)
|
|
603
604
|
}
|
|
604
605
|
) }),
|
|
605
|
-
/* @__PURE__ */
|
|
606
|
-
|
|
606
|
+
/* @__PURE__ */ s("div", { className: "max-h-64 overflow-y-auto", children: u.length === 0 ? /* @__PURE__ */ s("span", { className: "block px-3 pt-2 pb-4 text-[0.8125rem] text-cream/45", children: o === "" ? "No other paywalls here." : `Nothing matches “${c.trim()}”.` }) : u.map((m) => /* @__PURE__ */ s(
|
|
607
|
+
Pe,
|
|
607
608
|
{
|
|
608
|
-
label:
|
|
609
|
-
hint:
|
|
610
|
-
selected:
|
|
611
|
-
onSelect: () =>
|
|
609
|
+
label: m.label,
|
|
610
|
+
hint: m.hint,
|
|
611
|
+
selected: m.key === r,
|
|
612
|
+
onSelect: () => i(m.target)
|
|
612
613
|
},
|
|
613
|
-
|
|
614
|
+
m.key
|
|
614
615
|
)) }),
|
|
615
|
-
/* @__PURE__ */
|
|
616
|
-
|
|
617
|
-
|
|
616
|
+
/* @__PURE__ */ f("div", { className: "flex flex-col border-t border-cream/10", children: [
|
|
617
|
+
d.map((m) => /* @__PURE__ */ s(
|
|
618
|
+
Pe,
|
|
618
619
|
{
|
|
619
|
-
label:
|
|
620
|
-
hint:
|
|
621
|
-
selected:
|
|
622
|
-
onSelect: () =>
|
|
620
|
+
label: m.label,
|
|
621
|
+
hint: m.hint,
|
|
622
|
+
selected: m.key === r,
|
|
623
|
+
onSelect: () => i(m.target)
|
|
623
624
|
},
|
|
624
|
-
|
|
625
|
+
m.key
|
|
625
626
|
)),
|
|
626
|
-
/* @__PURE__ */
|
|
627
|
-
|
|
627
|
+
/* @__PURE__ */ s(
|
|
628
|
+
Pe,
|
|
628
629
|
{
|
|
629
630
|
label: "Off",
|
|
630
631
|
hint: "A single preview",
|
|
631
632
|
selected: e === void 0,
|
|
632
|
-
onSelect: () =>
|
|
633
|
+
onSelect: () => i(void 0)
|
|
633
634
|
}
|
|
634
635
|
)
|
|
635
636
|
] })
|
|
636
637
|
] })
|
|
637
638
|
] });
|
|
638
|
-
},
|
|
639
|
-
/* @__PURE__ */
|
|
640
|
-
/* @__PURE__ */
|
|
641
|
-
/* @__PURE__ */
|
|
642
|
-
/* @__PURE__ */
|
|
643
|
-
] }),
|
|
644
|
-
/* @__PURE__ */
|
|
639
|
+
}, Yn = () => /* @__PURE__ */ f("svg", { width: "19", height: "12", viewBox: "0 0 19 12", fill: "currentColor", "aria-hidden": "true", children: [
|
|
640
|
+
/* @__PURE__ */ s("rect", { x: "0", y: "7.5", width: "3.5", height: "4.5", rx: "1" }),
|
|
641
|
+
/* @__PURE__ */ s("rect", { x: "5", y: "5", width: "3.5", height: "7", rx: "1" }),
|
|
642
|
+
/* @__PURE__ */ s("rect", { x: "10", y: "2.5", width: "3.5", height: "9.5", rx: "1" }),
|
|
643
|
+
/* @__PURE__ */ s("rect", { x: "15", y: "0", width: "3.5", height: "12", rx: "1" })
|
|
644
|
+
] }), qn = () => /* @__PURE__ */ f("svg", { width: "27", height: "13", viewBox: "0 0 27 13", "aria-hidden": "true", children: [
|
|
645
|
+
/* @__PURE__ */ s(
|
|
645
646
|
"rect",
|
|
646
647
|
{
|
|
647
648
|
x: "0.5",
|
|
@@ -654,83 +655,83 @@ const Qt = (e, t) => {
|
|
|
654
655
|
strokeOpacity: "0.35"
|
|
655
656
|
}
|
|
656
657
|
),
|
|
657
|
-
/* @__PURE__ */
|
|
658
|
-
/* @__PURE__ */
|
|
659
|
-
] }),
|
|
660
|
-
/* @__PURE__ */
|
|
661
|
-
/* @__PURE__ */
|
|
662
|
-
/* @__PURE__ */
|
|
663
|
-
] }),
|
|
658
|
+
/* @__PURE__ */ s("path", { d: "M25 4.5v4a2.17 2.17 0 0 0 0-4Z", fill: "currentColor", fillOpacity: "0.4" }),
|
|
659
|
+
/* @__PURE__ */ s("rect", { x: "2", y: "2", width: "20", height: "9", rx: "2.5", fill: "currentColor" })
|
|
660
|
+
] }), Jn = () => /* @__PURE__ */ f("span", { className: "flex items-center gap-[7px]", children: [
|
|
661
|
+
/* @__PURE__ */ s(Yn, {}),
|
|
662
|
+
/* @__PURE__ */ s("span", { style: { fontSize: 12.5, fontWeight: 700, letterSpacing: "0.02em" }, children: "SW" }),
|
|
663
|
+
/* @__PURE__ */ s(qn, {})
|
|
664
|
+
] }), Xn = ({
|
|
664
665
|
spec: e,
|
|
665
666
|
width: t,
|
|
666
|
-
height:
|
|
667
|
-
landscape:
|
|
668
|
-
theme:
|
|
667
|
+
height: n,
|
|
668
|
+
landscape: a,
|
|
669
|
+
theme: l
|
|
669
670
|
}) => {
|
|
670
|
-
const
|
|
671
|
-
return /* @__PURE__ */
|
|
671
|
+
const c = l === "dark" ? "rgba(255,255,255,0.95)" : "rgba(0,0,0,0.95)", h = Math.max(28, e.radius * 0.6);
|
|
672
|
+
return /* @__PURE__ */ f(
|
|
672
673
|
"div",
|
|
673
674
|
{
|
|
674
675
|
className: "pointer-events-none absolute inset-0 select-none",
|
|
675
|
-
style: { width: t, height:
|
|
676
|
+
style: { width: t, height: n, color: c },
|
|
676
677
|
"data-testid": "device-chrome",
|
|
677
678
|
children: [
|
|
678
|
-
!
|
|
679
|
+
!a && /* @__PURE__ */ f(
|
|
679
680
|
"div",
|
|
680
681
|
{
|
|
681
682
|
className: "absolute inset-x-0 top-0 flex items-center justify-between",
|
|
682
683
|
style: {
|
|
683
684
|
height: e.statusBarHeight,
|
|
684
|
-
paddingLeft:
|
|
685
|
-
paddingRight:
|
|
685
|
+
paddingLeft: h,
|
|
686
|
+
paddingRight: h,
|
|
686
687
|
fontFamily: '-apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif',
|
|
687
688
|
fontSize: 15,
|
|
688
689
|
fontWeight: 600,
|
|
689
690
|
letterSpacing: "-0.2px"
|
|
690
691
|
},
|
|
691
692
|
children: [
|
|
692
|
-
/* @__PURE__ */
|
|
693
|
-
/* @__PURE__ */
|
|
693
|
+
/* @__PURE__ */ s("span", { children: "9:41" }),
|
|
694
|
+
/* @__PURE__ */ s(Jn, {})
|
|
694
695
|
]
|
|
695
696
|
}
|
|
696
697
|
),
|
|
697
|
-
e.cutout === "island" && (
|
|
698
|
+
e.cutout === "island" && (a ? /* @__PURE__ */ s(
|
|
698
699
|
"div",
|
|
699
700
|
{
|
|
700
701
|
className: "absolute rounded-full bg-black",
|
|
701
|
-
style: { left: 12, top: (
|
|
702
|
+
style: { left: 12, top: (n - 124) / 2, width: 36, height: 124 }
|
|
702
703
|
}
|
|
703
|
-
) : /* @__PURE__ */
|
|
704
|
+
) : /* @__PURE__ */ s(
|
|
704
705
|
"div",
|
|
705
706
|
{
|
|
706
707
|
className: "absolute rounded-full bg-black",
|
|
707
708
|
style: { left: (t - 124) / 2, top: 12, width: 124, height: 36 }
|
|
708
709
|
}
|
|
709
710
|
)),
|
|
710
|
-
e.cutout === "punch" && (
|
|
711
|
+
e.cutout === "punch" && (a ? /* @__PURE__ */ s(
|
|
711
712
|
"div",
|
|
712
713
|
{
|
|
713
714
|
className: "absolute rounded-full bg-black",
|
|
714
|
-
style: { left: 16, top: (
|
|
715
|
+
style: { left: 16, top: (n - 13) / 2, width: 13, height: 13 }
|
|
715
716
|
}
|
|
716
|
-
) : /* @__PURE__ */
|
|
717
|
+
) : /* @__PURE__ */ s(
|
|
717
718
|
"div",
|
|
718
719
|
{
|
|
719
720
|
className: "absolute rounded-full bg-black",
|
|
720
721
|
style: { left: (t - 13) / 2, top: 15, width: 13, height: 13 }
|
|
721
722
|
}
|
|
722
723
|
)),
|
|
723
|
-
e.homeIndicator && /* @__PURE__ */
|
|
724
|
+
e.homeIndicator && /* @__PURE__ */ s(
|
|
724
725
|
"div",
|
|
725
726
|
{
|
|
726
727
|
className: "absolute rounded-full",
|
|
727
728
|
style: {
|
|
728
|
-
width: Math.round(Math.min(t,
|
|
729
|
+
width: Math.round(Math.min(t, n) * 0.36),
|
|
729
730
|
height: 5,
|
|
730
731
|
left: "50%",
|
|
731
732
|
transform: "translateX(-50%)",
|
|
732
733
|
bottom: 8,
|
|
733
|
-
background:
|
|
734
|
+
background: c,
|
|
734
735
|
opacity: 0.9
|
|
735
736
|
}
|
|
736
737
|
}
|
|
@@ -738,119 +739,119 @@ const Qt = (e, t) => {
|
|
|
738
739
|
]
|
|
739
740
|
}
|
|
740
741
|
);
|
|
741
|
-
},
|
|
742
|
-
const
|
|
743
|
-
if (
|
|
744
|
-
const { host:
|
|
745
|
-
target:
|
|
746
|
-
state:
|
|
747
|
-
delegate:
|
|
742
|
+
}, Zn = (e, t) => {
|
|
743
|
+
const n = w.useRef(void 0), a = w.useRef({ hostState: e, delegate: t }), l = w.useCallback((c) => {
|
|
744
|
+
if (n.current?.detach(), n.current = void 0, !c?.contentWindow) return;
|
|
745
|
+
const { host: h, detach: p } = Rn({
|
|
746
|
+
target: c.contentWindow,
|
|
747
|
+
state: a.current.hostState,
|
|
748
|
+
delegate: a.current.delegate
|
|
748
749
|
});
|
|
749
|
-
|
|
750
|
+
n.current = { host: h, detach: p, sent: a.current.hostState };
|
|
750
751
|
}, []);
|
|
751
|
-
return
|
|
752
|
-
|
|
753
|
-
const
|
|
754
|
-
|
|
755
|
-
}, [e, t]),
|
|
756
|
-
},
|
|
757
|
-
const [
|
|
758
|
-
return
|
|
759
|
-
const
|
|
760
|
-
if (!
|
|
761
|
-
const
|
|
762
|
-
const
|
|
752
|
+
return w.useEffect(() => {
|
|
753
|
+
a.current = { hostState: e, delegate: t };
|
|
754
|
+
const c = n.current;
|
|
755
|
+
c && (c.host.update(en(c.sent, e)), c.sent = e);
|
|
756
|
+
}, [e, t]), l;
|
|
757
|
+
}, Et = ({ hostState: e, delegate: t, ...n }) => /* @__PURE__ */ s("iframe", { ...n, ref: Zn(e, t) }), et = 96, er = 250, Ct = (e, t, n) => {
|
|
758
|
+
const [a, l] = w.useState(1);
|
|
759
|
+
return w.useLayoutEffect(() => {
|
|
760
|
+
const c = e.current;
|
|
761
|
+
if (!c) return;
|
|
762
|
+
const h = () => {
|
|
763
|
+
const r = c.getBoundingClientRect(), i = Math.min(
|
|
763
764
|
1,
|
|
764
|
-
(
|
|
765
|
-
(
|
|
765
|
+
(r.width - et) / t,
|
|
766
|
+
(r.height - et) / n
|
|
766
767
|
);
|
|
767
|
-
|
|
768
|
+
l(Math.max(0.1, i));
|
|
768
769
|
};
|
|
769
|
-
if (
|
|
770
|
-
const p = new ResizeObserver(
|
|
771
|
-
return p.observe(
|
|
772
|
-
}, [e, t,
|
|
773
|
-
},
|
|
770
|
+
if (h(), typeof ResizeObserver > "u") return;
|
|
771
|
+
const p = new ResizeObserver(h);
|
|
772
|
+
return p.observe(c), () => p.disconnect();
|
|
773
|
+
}, [e, t, n]), a;
|
|
774
|
+
}, tr = ({
|
|
774
775
|
width: e,
|
|
775
776
|
height: t,
|
|
776
|
-
stageRef:
|
|
777
|
-
children:
|
|
777
|
+
stageRef: n,
|
|
778
|
+
children: a
|
|
778
779
|
}) => {
|
|
779
|
-
const
|
|
780
|
-
return /* @__PURE__ */
|
|
780
|
+
const l = Ct(n, e, t);
|
|
781
|
+
return /* @__PURE__ */ s(
|
|
781
782
|
"div",
|
|
782
783
|
{
|
|
783
784
|
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",
|
|
784
785
|
"data-testid": "device-placeholder",
|
|
785
|
-
style: { width: e *
|
|
786
|
-
children:
|
|
786
|
+
style: { width: e * l, height: t * l },
|
|
787
|
+
children: a
|
|
787
788
|
}
|
|
788
789
|
);
|
|
789
|
-
},
|
|
790
|
+
}, nr = ({
|
|
790
791
|
width: e,
|
|
791
792
|
height: t,
|
|
792
|
-
title:
|
|
793
|
-
src:
|
|
794
|
-
hostState:
|
|
795
|
-
delegate:
|
|
796
|
-
stageRef:
|
|
793
|
+
title: n,
|
|
794
|
+
src: a,
|
|
795
|
+
hostState: l,
|
|
796
|
+
delegate: c,
|
|
797
|
+
stageRef: h,
|
|
797
798
|
reloadKey: p = 0,
|
|
798
|
-
chrome:
|
|
799
|
-
landscape:
|
|
800
|
-
theme:
|
|
799
|
+
chrome: r,
|
|
800
|
+
landscape: i = !1,
|
|
801
|
+
theme: o = "light"
|
|
801
802
|
}) => {
|
|
802
|
-
const
|
|
803
|
-
|
|
804
|
-
if (!
|
|
805
|
-
|
|
803
|
+
const d = Ct(h, e, t), u = w.useRef(0), [m, b] = w.useState([{ src: a, generation: 0, ready: !0 }]), x = w.useRef(!1);
|
|
804
|
+
w.useEffect(() => {
|
|
805
|
+
if (!x.current) {
|
|
806
|
+
x.current = !0;
|
|
806
807
|
return;
|
|
807
808
|
}
|
|
808
809
|
u.current += 1;
|
|
809
|
-
const g = { src:
|
|
810
|
-
|
|
811
|
-
}, [
|
|
812
|
-
const
|
|
810
|
+
const g = { src: a, generation: u.current, ready: !1 };
|
|
811
|
+
b((S) => [...S.filter((C) => C.ready).slice(-1), g]);
|
|
812
|
+
}, [a, p]);
|
|
813
|
+
const v = (g) => {
|
|
813
814
|
window.setTimeout(() => {
|
|
814
|
-
|
|
815
|
-
},
|
|
816
|
-
},
|
|
817
|
-
return /* @__PURE__ */
|
|
815
|
+
b((S) => S.some((C) => C.generation === g) ? S.map((C) => C.generation === g ? { ...C, ready: !0 } : C).filter((C) => C.generation >= g) : S);
|
|
816
|
+
}, er);
|
|
817
|
+
}, P = m.findLast((g) => g.ready), E = r ? r.radius * d : 0;
|
|
818
|
+
return /* @__PURE__ */ f(
|
|
818
819
|
"div",
|
|
819
820
|
{
|
|
820
|
-
className: `bg-panel relative flex-none overflow-hidden ${
|
|
821
|
+
className: `bg-panel relative flex-none overflow-hidden ${r ? "shadow-[0_0_0_1px] shadow-cream/25" : "border border-cream/20"}`,
|
|
821
822
|
"data-testid": "device-frame",
|
|
822
|
-
style: { width: e *
|
|
823
|
+
style: { width: e * d, height: t * d, borderRadius: E },
|
|
823
824
|
children: [
|
|
824
|
-
|
|
825
|
-
|
|
825
|
+
m.map((g) => /* @__PURE__ */ s(
|
|
826
|
+
Et,
|
|
826
827
|
{
|
|
827
|
-
hostState:
|
|
828
|
-
delegate:
|
|
829
|
-
className: `absolute inset-0 origin-top-left border-0 bg-white transition-opacity duration-150 ${g ===
|
|
830
|
-
title:
|
|
828
|
+
hostState: l,
|
|
829
|
+
delegate: c,
|
|
830
|
+
className: `absolute inset-0 origin-top-left border-0 bg-white transition-opacity duration-150 ${g === P ? "opacity-100" : "opacity-0"}`,
|
|
831
|
+
title: n,
|
|
831
832
|
src: g.src,
|
|
832
833
|
width: e,
|
|
833
834
|
height: t,
|
|
834
|
-
style: { transform: `scale(${
|
|
835
|
+
style: { transform: `scale(${d})` },
|
|
835
836
|
onLoad: () => {
|
|
836
|
-
g.ready ||
|
|
837
|
+
g.ready || v(g.generation);
|
|
837
838
|
}
|
|
838
839
|
},
|
|
839
840
|
g.generation
|
|
840
841
|
)),
|
|
841
|
-
|
|
842
|
+
r && /* @__PURE__ */ s(
|
|
842
843
|
"div",
|
|
843
844
|
{
|
|
844
845
|
className: "pointer-events-none absolute inset-0 origin-top-left",
|
|
845
|
-
style: { width: e, height: t, transform: `scale(${
|
|
846
|
-
children: /* @__PURE__ */
|
|
847
|
-
|
|
846
|
+
style: { width: e, height: t, transform: `scale(${d})` },
|
|
847
|
+
children: /* @__PURE__ */ s(
|
|
848
|
+
Xn,
|
|
848
849
|
{
|
|
849
|
-
spec:
|
|
850
|
+
spec: r,
|
|
850
851
|
width: e,
|
|
851
852
|
height: t,
|
|
852
|
-
landscape:
|
|
853
|
-
theme:
|
|
853
|
+
landscape: i,
|
|
854
|
+
theme: o
|
|
854
855
|
}
|
|
855
856
|
)
|
|
856
857
|
}
|
|
@@ -858,37 +859,37 @@ const Qt = (e, t) => {
|
|
|
858
859
|
]
|
|
859
860
|
}
|
|
860
861
|
);
|
|
861
|
-
},
|
|
862
|
+
}, rr = ({
|
|
862
863
|
paywall: e,
|
|
863
864
|
missing: t,
|
|
864
|
-
onDismiss:
|
|
865
|
-
}) => /* @__PURE__ */
|
|
865
|
+
onDismiss: n
|
|
866
|
+
}) => /* @__PURE__ */ s(
|
|
866
867
|
"div",
|
|
867
868
|
{
|
|
868
869
|
className: "fixed inset-0 z-50 flex items-center justify-center bg-ink/70 p-6",
|
|
869
870
|
role: "dialog",
|
|
870
871
|
"aria-modal": "true",
|
|
871
872
|
"aria-labelledby": "sw-missing-products",
|
|
872
|
-
children: /* @__PURE__ */
|
|
873
|
-
/* @__PURE__ */
|
|
874
|
-
/* @__PURE__ */
|
|
875
|
-
/* @__PURE__ */
|
|
873
|
+
children: /* @__PURE__ */ f("div", { className: "bg-panel flex w-full max-w-md flex-col gap-4 rounded border border-cream/20 p-5", children: [
|
|
874
|
+
/* @__PURE__ */ f("div", { className: "flex flex-col gap-1.5", children: [
|
|
875
|
+
/* @__PURE__ */ s("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` }),
|
|
876
|
+
/* @__PURE__ */ s("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.` })
|
|
876
877
|
] }),
|
|
877
|
-
/* @__PURE__ */
|
|
878
|
-
/* @__PURE__ */
|
|
879
|
-
/* @__PURE__ */
|
|
880
|
-
] },
|
|
881
|
-
/* @__PURE__ */
|
|
878
|
+
/* @__PURE__ */ s("ul", { className: "flex flex-col gap-1.5 border-y border-cream/10 py-3", children: t.map((a) => /* @__PURE__ */ f("li", { className: "flex items-baseline justify-between gap-3", children: [
|
|
879
|
+
/* @__PURE__ */ s("span", { className: "font-mono text-[11px] text-cream/70", children: a.reference }),
|
|
880
|
+
/* @__PURE__ */ s("span", { className: "truncate font-mono text-[11px] text-cream/40", children: a.identifier })
|
|
881
|
+
] }, a.reference)) }),
|
|
882
|
+
/* @__PURE__ */ f("span", { className: "text-xs text-cream/45", children: [
|
|
882
883
|
"Add ",
|
|
883
884
|
t.length === 1 ? "it" : "them",
|
|
884
885
|
" in the Superwall dashboard, or point the config at",
|
|
885
886
|
t.length === 1 ? " a product" : " products",
|
|
886
887
|
" that exists. Pushing is refused until then."
|
|
887
888
|
] }),
|
|
888
|
-
/* @__PURE__ */
|
|
889
|
+
/* @__PURE__ */ s("button", { type: "button", className: "sw-btn sw-btn--primary self-end", onClick: n, children: "View anyway" })
|
|
889
890
|
] })
|
|
890
891
|
}
|
|
891
|
-
),
|
|
892
|
+
), sr = /* @__PURE__ */ new Set([
|
|
892
893
|
"ping",
|
|
893
894
|
"page_view",
|
|
894
895
|
"page_styles",
|
|
@@ -897,7 +898,7 @@ const Qt = (e, t) => {
|
|
|
897
898
|
"var_click",
|
|
898
899
|
"purchase",
|
|
899
900
|
"restore"
|
|
900
|
-
]),
|
|
901
|
+
]), ar = {
|
|
901
902
|
open_url: ["url"],
|
|
902
903
|
open_url_external: ["url"],
|
|
903
904
|
open_deep_link: ["link"],
|
|
@@ -907,101 +908,101 @@ const Qt = (e, t) => {
|
|
|
907
908
|
request_callback: ["name"],
|
|
908
909
|
schedule_notification: ["title"],
|
|
909
910
|
discount_redemption_result: ["code"]
|
|
910
|
-
},
|
|
911
|
+
}, or = /* @__PURE__ */ new Set(["close"]), ir = /* @__PURE__ */ new Set([
|
|
911
912
|
"stripe_checkout_complete",
|
|
912
913
|
"post_checkout_complete"
|
|
913
|
-
]),
|
|
914
|
-
for (const t of
|
|
915
|
-
const
|
|
916
|
-
if (typeof
|
|
914
|
+
]), lr = (e) => {
|
|
915
|
+
for (const t of ar[e.event_name] ?? []) {
|
|
916
|
+
const n = Reflect.get(e, t);
|
|
917
|
+
if (typeof n == "string" && n.length > 0) return n;
|
|
917
918
|
}
|
|
918
|
-
},
|
|
919
|
-
if (!
|
|
919
|
+
}, cr = (e) => {
|
|
920
|
+
if (!sr.has(e.event_name))
|
|
920
921
|
return {
|
|
921
922
|
action: e.event_name,
|
|
922
|
-
subject:
|
|
923
|
-
tone:
|
|
923
|
+
subject: lr(e),
|
|
924
|
+
tone: or.has(e.event_name) ? "warning" : ir.has(e.event_name) ? "success" : "info"
|
|
924
925
|
};
|
|
925
|
-
},
|
|
926
|
+
}, dr = {
|
|
926
927
|
info: "text-cream/45",
|
|
927
928
|
success: "text-accent",
|
|
928
929
|
warning: "text-red"
|
|
929
|
-
},
|
|
930
|
-
purchase:
|
|
931
|
-
transaction_complete:
|
|
932
|
-
freeTrial_start:
|
|
933
|
-
transaction_abandon:
|
|
934
|
-
transaction_fail:
|
|
935
|
-
close:
|
|
936
|
-
restore:
|
|
937
|
-
restore_complete:
|
|
938
|
-
restore_fail:
|
|
939
|
-
open_url:
|
|
940
|
-
open_url_external:
|
|
941
|
-
open_deep_link:
|
|
942
|
-
initiate_web_checkout:
|
|
943
|
-
open_payment_sheet:
|
|
944
|
-
custom_placement:
|
|
945
|
-
custom:
|
|
946
|
-
request_permission:
|
|
947
|
-
request_callback:
|
|
948
|
-
schedule_notification:
|
|
949
|
-
request_store_review:
|
|
950
|
-
user_attribute_updated:
|
|
951
|
-
},
|
|
930
|
+
}, ur = {
|
|
931
|
+
purchase: ke,
|
|
932
|
+
transaction_complete: me,
|
|
933
|
+
freeTrial_start: me,
|
|
934
|
+
transaction_abandon: pe,
|
|
935
|
+
transaction_fail: pe,
|
|
936
|
+
close: vt,
|
|
937
|
+
restore: gt,
|
|
938
|
+
restore_complete: me,
|
|
939
|
+
restore_fail: pe,
|
|
940
|
+
open_url: he,
|
|
941
|
+
open_url_external: he,
|
|
942
|
+
open_deep_link: he,
|
|
943
|
+
initiate_web_checkout: ke,
|
|
944
|
+
open_payment_sheet: ke,
|
|
945
|
+
custom_placement: ce,
|
|
946
|
+
custom: ce,
|
|
947
|
+
request_permission: ce,
|
|
948
|
+
request_callback: ce,
|
|
949
|
+
schedule_notification: Bn,
|
|
950
|
+
request_store_review: jn,
|
|
951
|
+
user_attribute_updated: zn
|
|
952
|
+
}, se = ({ children: e }) => /* @__PURE__ */ s("span", { className: "bg-accent/15 text-accent px-1.5 py-px font-mono text-xs whitespace-nowrap", children: e }), ze = ({
|
|
952
953
|
action: e,
|
|
953
954
|
tone: t,
|
|
954
|
-
children:
|
|
955
|
-
actions:
|
|
955
|
+
children: n,
|
|
956
|
+
actions: a
|
|
956
957
|
}) => {
|
|
957
|
-
const
|
|
958
|
-
return /* @__PURE__ */
|
|
959
|
-
/* @__PURE__ */
|
|
960
|
-
/* @__PURE__ */
|
|
961
|
-
|
|
958
|
+
const l = ur[e] ?? xt;
|
|
959
|
+
return /* @__PURE__ */ s("div", { className: "bg-panel font-sans w-[344px] rounded border border-cream/15 p-3", children: /* @__PURE__ */ f("div", { className: "grid grid-cols-[14px_1fr] items-start gap-x-2.5", children: [
|
|
960
|
+
/* @__PURE__ */ s("span", { className: `flex h-5 items-center justify-center ${dr[t]}`, children: /* @__PURE__ */ s(l, {}) }),
|
|
961
|
+
/* @__PURE__ */ s("span", { className: "text-[0.8125rem] leading-5 font-medium text-cream", children: n }),
|
|
962
|
+
a && /* @__PURE__ */ s("div", { className: "col-start-2 mt-2.5 flex justify-end gap-2", children: a })
|
|
962
963
|
] }) });
|
|
963
|
-
},
|
|
964
|
+
}, hr = ({ notice: e }) => /* @__PURE__ */ f(ze, { action: e.action, tone: e.tone, children: [
|
|
964
965
|
"Tap triggered a ",
|
|
965
|
-
/* @__PURE__ */
|
|
966
|
-
e.subject ? /* @__PURE__ */
|
|
966
|
+
/* @__PURE__ */ s(se, { children: e.action }),
|
|
967
|
+
e.subject ? /* @__PURE__ */ f(G, { children: [
|
|
967
968
|
" for ",
|
|
968
|
-
/* @__PURE__ */
|
|
969
|
+
/* @__PURE__ */ s(se, { children: e.subject })
|
|
969
970
|
] }) : " action",
|
|
970
971
|
"."
|
|
971
|
-
] }),
|
|
972
|
-
/* @__PURE__ */
|
|
972
|
+
] }), mr = ({ choice: e, subject: t }) => /* @__PURE__ */ f(ze, { action: e.action, tone: e.tone, children: [
|
|
973
|
+
/* @__PURE__ */ s(se, { children: t }),
|
|
973
974
|
" ",
|
|
974
975
|
e.done
|
|
975
|
-
] }),
|
|
976
|
+
] }), pr = ({
|
|
976
977
|
action: e,
|
|
977
978
|
verb: t,
|
|
978
|
-
subject:
|
|
979
|
-
choices:
|
|
980
|
-
onAnswer:
|
|
981
|
-
}) => /* @__PURE__ */
|
|
982
|
-
|
|
979
|
+
subject: n,
|
|
980
|
+
choices: a,
|
|
981
|
+
onAnswer: l
|
|
982
|
+
}) => /* @__PURE__ */ f(
|
|
983
|
+
ze,
|
|
983
984
|
{
|
|
984
985
|
action: e,
|
|
985
986
|
tone: "info",
|
|
986
|
-
actions:
|
|
987
|
+
actions: a.map((c) => /* @__PURE__ */ s(
|
|
987
988
|
"button",
|
|
988
989
|
{
|
|
989
990
|
type: "button",
|
|
990
|
-
className:
|
|
991
|
-
onClick: () =>
|
|
992
|
-
children:
|
|
991
|
+
className: c.primary ? "sw-btn sw-btn--primary" : "sw-btn",
|
|
992
|
+
onClick: () => l(c),
|
|
993
|
+
children: c.label
|
|
993
994
|
},
|
|
994
|
-
|
|
995
|
+
c.label
|
|
995
996
|
)),
|
|
996
997
|
children: [
|
|
997
998
|
"Tap triggered a ",
|
|
998
|
-
/* @__PURE__ */
|
|
999
|
+
/* @__PURE__ */ s(se, { children: t }),
|
|
999
1000
|
" for ",
|
|
1000
|
-
/* @__PURE__ */
|
|
1001
|
+
/* @__PURE__ */ s(se, { children: n }),
|
|
1001
1002
|
"."
|
|
1002
1003
|
]
|
|
1003
1004
|
}
|
|
1004
|
-
),
|
|
1005
|
+
), fr = [
|
|
1005
1006
|
{
|
|
1006
1007
|
label: "Abandon",
|
|
1007
1008
|
value: "abandoned",
|
|
@@ -1024,7 +1025,7 @@ const Qt = (e, t) => {
|
|
|
1024
1025
|
tone: "success",
|
|
1025
1026
|
done: "purchase completed."
|
|
1026
1027
|
}
|
|
1027
|
-
],
|
|
1028
|
+
], br = [
|
|
1028
1029
|
{
|
|
1029
1030
|
label: "Nothing",
|
|
1030
1031
|
value: "failed",
|
|
@@ -1040,7 +1041,7 @@ const Qt = (e, t) => {
|
|
|
1040
1041
|
tone: "success",
|
|
1041
1042
|
done: "restored."
|
|
1042
1043
|
}
|
|
1043
|
-
],
|
|
1044
|
+
], wr = [
|
|
1044
1045
|
{
|
|
1045
1046
|
label: "Deny",
|
|
1046
1047
|
value: "denied",
|
|
@@ -1056,7 +1057,7 @@ const Qt = (e, t) => {
|
|
|
1056
1057
|
tone: "success",
|
|
1057
1058
|
done: "granted."
|
|
1058
1059
|
}
|
|
1059
|
-
],
|
|
1060
|
+
], gr = [
|
|
1060
1061
|
{ label: "Fail", value: "failure", action: "request_callback", tone: "warning", done: "failed." },
|
|
1061
1062
|
{
|
|
1062
1063
|
label: "Succeed",
|
|
@@ -1067,31 +1068,31 @@ const Qt = (e, t) => {
|
|
|
1067
1068
|
done: "succeeded."
|
|
1068
1069
|
}
|
|
1069
1070
|
];
|
|
1070
|
-
let
|
|
1071
|
-
const
|
|
1072
|
-
const
|
|
1073
|
-
|
|
1074
|
-
() => /* @__PURE__ */
|
|
1075
|
-
|
|
1071
|
+
let vr = 0;
|
|
1072
|
+
const de = (e, t, n, a) => new Promise((l) => {
|
|
1073
|
+
const c = `${e}-${vr += 1}`;
|
|
1074
|
+
J.custom(
|
|
1075
|
+
() => /* @__PURE__ */ s(
|
|
1076
|
+
pr,
|
|
1076
1077
|
{
|
|
1077
1078
|
action: e,
|
|
1078
1079
|
verb: t,
|
|
1079
|
-
subject:
|
|
1080
|
-
choices:
|
|
1081
|
-
onAnswer: (
|
|
1082
|
-
|
|
1080
|
+
subject: n,
|
|
1081
|
+
choices: a,
|
|
1082
|
+
onAnswer: (h) => {
|
|
1083
|
+
J.dismiss(c), J.custom(() => /* @__PURE__ */ s(mr, { choice: h, subject: n })), l(h.value);
|
|
1083
1084
|
}
|
|
1084
1085
|
}
|
|
1085
1086
|
),
|
|
1086
|
-
{ id:
|
|
1087
|
+
{ id: c, duration: Number.POSITIVE_INFINITY }
|
|
1087
1088
|
);
|
|
1088
|
-
}),
|
|
1089
|
+
}), yr = () => ({
|
|
1089
1090
|
event: (e) => {
|
|
1090
|
-
const t =
|
|
1091
|
-
t &&
|
|
1091
|
+
const t = cr(e);
|
|
1092
|
+
t && J.custom(() => /* @__PURE__ */ s(hr, { notice: t }));
|
|
1092
1093
|
},
|
|
1093
|
-
purchase: (e) =>
|
|
1094
|
-
restore: () =>
|
|
1094
|
+
purchase: (e) => de("purchase", "purchase", e.reference, fr),
|
|
1095
|
+
restore: () => de("restore", "restore", "purchases", br),
|
|
1095
1096
|
close: () => {
|
|
1096
1097
|
},
|
|
1097
1098
|
openUrl: () => {
|
|
@@ -1100,15 +1101,15 @@ const K = (e, t, a, r) => new Promise((s) => {
|
|
|
1100
1101
|
},
|
|
1101
1102
|
customPlacement: () => {
|
|
1102
1103
|
},
|
|
1103
|
-
permission: (e) =>
|
|
1104
|
-
callback: (e) =>
|
|
1105
|
-
}),
|
|
1104
|
+
permission: (e) => de("request_permission", "permission", e, wr),
|
|
1105
|
+
callback: (e) => de("request_callback", "callback", e, gr).then((t) => ({ status: t }))
|
|
1106
|
+
}), xr = () => w.useMemo(yr, []), Nr = ({
|
|
1106
1107
|
surfaceKey: e,
|
|
1107
1108
|
raised: t = !1
|
|
1108
|
-
}) => (
|
|
1109
|
-
|
|
1110
|
-
}, [e]), /* @__PURE__ */
|
|
1111
|
-
|
|
1109
|
+
}) => (w.useEffect(() => {
|
|
1110
|
+
J.dismiss();
|
|
1111
|
+
}, [e]), /* @__PURE__ */ s(
|
|
1112
|
+
Jt,
|
|
1112
1113
|
{
|
|
1113
1114
|
position: "top-center",
|
|
1114
1115
|
swipeDirections: ["top"],
|
|
@@ -1118,303 +1119,1321 @@ const K = (e, t, a, r) => new Promise((s) => {
|
|
|
1118
1119
|
style: { zIndex: 5 },
|
|
1119
1120
|
toastOptions: { unstyled: !0, classNames: { toast: "w-full" } }
|
|
1120
1121
|
}
|
|
1121
|
-
)),
|
|
1122
|
+
)), Sr = ({ hint: e, children: t }) => {
|
|
1123
|
+
const [n, a] = w.useState(!1);
|
|
1124
|
+
return e === void 0 ? /* @__PURE__ */ s(G, { children: t }) : /* @__PURE__ */ f(
|
|
1125
|
+
"span",
|
|
1126
|
+
{
|
|
1127
|
+
className: "relative inline-flex",
|
|
1128
|
+
onMouseEnter: () => a(!0),
|
|
1129
|
+
onMouseLeave: () => a(!1),
|
|
1130
|
+
onFocus: () => a(!0),
|
|
1131
|
+
onBlur: () => a(!1),
|
|
1132
|
+
children: [
|
|
1133
|
+
t,
|
|
1134
|
+
n && /* @__PURE__ */ s(
|
|
1135
|
+
"span",
|
|
1136
|
+
{
|
|
1137
|
+
role: "tooltip",
|
|
1138
|
+
className: "bg-bar pointer-events-none absolute top-full right-0 z-50 mt-[calc(0.5rem+2px)] w-64 rounded border border-cream/10 px-3 py-2 text-left text-[0.75rem] leading-snug font-normal whitespace-normal text-cream/75",
|
|
1139
|
+
children: e
|
|
1140
|
+
}
|
|
1141
|
+
)
|
|
1142
|
+
]
|
|
1143
|
+
}
|
|
1144
|
+
);
|
|
1145
|
+
}, U = (e) => `${e.project ? `/${e.project}` : ""}/${e.kind}/${e.id}`, He = (e) => /[?&]transport=editor(?:&|$)/.test(e) ? e : `${e}${e.includes("?") ? "&" : "?"}transport=editor`, gs = (e) => He(`/preview${U(e)}`), vs = (e) => (t) => He(e(t)), Er = async (e, t, n) => {
|
|
1146
|
+
try {
|
|
1147
|
+
const a = await fetch("/__studio/action", {
|
|
1148
|
+
method: "POST",
|
|
1149
|
+
headers: { "Content-Type": "application/json" },
|
|
1150
|
+
body: JSON.stringify({
|
|
1151
|
+
action: t,
|
|
1152
|
+
kind: e.kind,
|
|
1153
|
+
id: e.id,
|
|
1154
|
+
project: e.project
|
|
1155
|
+
})
|
|
1156
|
+
});
|
|
1157
|
+
if (!a.body)
|
|
1158
|
+
return await a.json();
|
|
1159
|
+
const l = a.body.getReader(), c = new TextDecoder();
|
|
1160
|
+
let h = "", p;
|
|
1161
|
+
const r = (i) => {
|
|
1162
|
+
if (!i.trim()) return;
|
|
1163
|
+
const o = JSON.parse(i);
|
|
1164
|
+
o.result ? p = o.result : o.step && o.state && n?.(o.step, o.state);
|
|
1165
|
+
};
|
|
1166
|
+
for (; ; ) {
|
|
1167
|
+
const { done: i, value: o } = await l.read();
|
|
1168
|
+
if (i) break;
|
|
1169
|
+
h += c.decode(o, { stream: !0 });
|
|
1170
|
+
const d = h.split(`
|
|
1171
|
+
`);
|
|
1172
|
+
h = d.pop() ?? "";
|
|
1173
|
+
for (const u of d) r(u);
|
|
1174
|
+
}
|
|
1175
|
+
return r(h), p ?? { ok: !1, error: "The dev server closed without a result." };
|
|
1176
|
+
} catch (a) {
|
|
1177
|
+
return { ok: !1, error: a instanceof Error ? a.message : String(a) };
|
|
1178
|
+
}
|
|
1179
|
+
}, De = async (e) => {
|
|
1180
|
+
try {
|
|
1181
|
+
return await (await fetch(`/__studio/status${U(e)}`)).json();
|
|
1182
|
+
} catch (t) {
|
|
1183
|
+
return { unreachable: t instanceof Error ? t.message : String(t) };
|
|
1184
|
+
}
|
|
1185
|
+
}, Cr = async (e) => {
|
|
1186
|
+
const n = await (await fetch(`/__studio/screenshot${U(e)}`)).json();
|
|
1187
|
+
if (n.unreachable !== void 0) throw new Error(n.unreachable);
|
|
1188
|
+
return n.url;
|
|
1189
|
+
}, _r = async () => {
|
|
1190
|
+
try {
|
|
1191
|
+
const t = await (await fetch("/__studio/samples.json")).json();
|
|
1192
|
+
return typeof t == "object" && t !== null ? t : {};
|
|
1193
|
+
} catch (e) {
|
|
1194
|
+
return { unreachable: e instanceof Error ? e.message : String(e) };
|
|
1195
|
+
}
|
|
1196
|
+
}, Ir = {
|
|
1197
|
+
info: "text-cream/45",
|
|
1198
|
+
success: "text-accent",
|
|
1199
|
+
warning: "text-red"
|
|
1200
|
+
}, Mr = {
|
|
1201
|
+
info: xt,
|
|
1202
|
+
success: me,
|
|
1203
|
+
warning: pe
|
|
1204
|
+
}, kr = (e, t = "info") => {
|
|
1205
|
+
const n = Mr[t];
|
|
1206
|
+
J.custom(() => /* @__PURE__ */ s("div", { className: "bg-panel font-sans w-[344px] rounded border border-cream/15 p-3", children: /* @__PURE__ */ f("div", { className: "grid grid-cols-[14px_1fr] items-start gap-x-2.5", children: [
|
|
1207
|
+
/* @__PURE__ */ s("span", { className: `flex h-5 items-center justify-center ${Ir[t]}`, children: /* @__PURE__ */ s(n, {}) }),
|
|
1208
|
+
/* @__PURE__ */ s("span", { className: "text-[0.8125rem] leading-5 font-medium text-cream", children: e })
|
|
1209
|
+
] }) }));
|
|
1210
|
+
}, _t = w.createContext(void 0), It = () => {
|
|
1211
|
+
const e = w.useContext(_t);
|
|
1212
|
+
if (!e)
|
|
1213
|
+
throw new Error("Studio components must be rendered inside <StudioHostProvider>.");
|
|
1214
|
+
return e;
|
|
1215
|
+
}, Pr = ({
|
|
1216
|
+
mode: e,
|
|
1217
|
+
home: t,
|
|
1218
|
+
children: n
|
|
1219
|
+
}) => {
|
|
1220
|
+
const { href: a, navigate: l } = t, c = w.useMemo(
|
|
1221
|
+
() => ({ mode: e, home: { href: a, navigate: l } }),
|
|
1222
|
+
[e, a, l]
|
|
1223
|
+
);
|
|
1224
|
+
return /* @__PURE__ */ s(_t.Provider, { value: c, children: n });
|
|
1225
|
+
}, Ve = () => It().mode, Rr = () => It().home, Or = {
|
|
1226
|
+
checking: "Looking for a screenshot…",
|
|
1227
|
+
none: "This paywall has no live version yet. Screenshots are captured from the published document, so promote a pushed version before downloading one.",
|
|
1228
|
+
unreachable: "Couldn't reach the screenshot service."
|
|
1229
|
+
}, tt = (e, t) => {
|
|
1230
|
+
const n = document.createElement("a");
|
|
1231
|
+
n.href = e, t === void 0 ? (n.target = "_blank", n.rel = "noreferrer") : n.download = t, n.click();
|
|
1232
|
+
}, Ar = ({
|
|
1233
|
+
source: e,
|
|
1234
|
+
surface: t
|
|
1235
|
+
}) => {
|
|
1236
|
+
const n = Ve() === "hosted", [a, l] = w.useState({ status: "checking" }), c = n ? e.screenshotUrl : Cr;
|
|
1237
|
+
w.useEffect(() => {
|
|
1238
|
+
if (c === void 0) {
|
|
1239
|
+
l({ status: "none" });
|
|
1240
|
+
return;
|
|
1241
|
+
}
|
|
1242
|
+
let i = !1;
|
|
1243
|
+
return l({ status: "checking" }), c(t).then(
|
|
1244
|
+
(o) => {
|
|
1245
|
+
i || l(o === void 0 ? { status: "none" } : { status: "ready", url: o });
|
|
1246
|
+
},
|
|
1247
|
+
(o) => {
|
|
1248
|
+
i || l({
|
|
1249
|
+
status: "unreachable",
|
|
1250
|
+
reason: o instanceof Error ? o.message : String(o)
|
|
1251
|
+
});
|
|
1252
|
+
}
|
|
1253
|
+
), () => {
|
|
1254
|
+
i = !0;
|
|
1255
|
+
};
|
|
1256
|
+
}, [c, t]);
|
|
1257
|
+
const h = () => {
|
|
1258
|
+
if (a.status === "ready") {
|
|
1259
|
+
if (n) {
|
|
1260
|
+
tt(a.url), kr("Opened the screenshot in a new tab — save it from there.");
|
|
1261
|
+
return;
|
|
1262
|
+
}
|
|
1263
|
+
tt(`/__studio/screenshot${U(t)}?download=1`, `${t.id}.png`);
|
|
1264
|
+
}
|
|
1265
|
+
}, p = a.status !== "ready", r = a.status === "unreachable" ? a.reason : a.status === "ready" ? void 0 : Or[a.status];
|
|
1266
|
+
return /* @__PURE__ */ s(Sr, { hint: r, children: /* @__PURE__ */ s(
|
|
1267
|
+
"button",
|
|
1268
|
+
{
|
|
1269
|
+
className: `sw-btn sw-btn--icon${p ? " sw-btn--blocked" : ""}`,
|
|
1270
|
+
type: "button",
|
|
1271
|
+
"aria-label": "Download screenshot",
|
|
1272
|
+
"aria-disabled": p,
|
|
1273
|
+
onClick: h,
|
|
1274
|
+
children: /* @__PURE__ */ f("svg", { className: "sw-icon", viewBox: "0 0 24 24", "aria-hidden": "true", children: [
|
|
1275
|
+
/* @__PURE__ */ s("path", { d: "M12 3v12" }),
|
|
1276
|
+
/* @__PURE__ */ s("path", { d: "m7 10 5 5 5-5" }),
|
|
1277
|
+
/* @__PURE__ */ s("path", { d: "M5 21h14" })
|
|
1278
|
+
] })
|
|
1279
|
+
}
|
|
1280
|
+
) });
|
|
1281
|
+
};
|
|
1282
|
+
var Tr = Object.defineProperty, we = Object.getOwnPropertySymbols, Mt = Object.prototype.hasOwnProperty, kt = Object.prototype.propertyIsEnumerable, nt = (e, t, n) => t in e ? Tr(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, Fe = (e, t) => {
|
|
1283
|
+
for (var n in t || (t = {}))
|
|
1284
|
+
Mt.call(t, n) && nt(e, n, t[n]);
|
|
1285
|
+
if (we)
|
|
1286
|
+
for (var n of we(t))
|
|
1287
|
+
kt.call(t, n) && nt(e, n, t[n]);
|
|
1288
|
+
return e;
|
|
1289
|
+
}, Ue = (e, t) => {
|
|
1290
|
+
var n = {};
|
|
1291
|
+
for (var a in e)
|
|
1292
|
+
Mt.call(e, a) && t.indexOf(a) < 0 && (n[a] = e[a]);
|
|
1293
|
+
if (e != null && we)
|
|
1294
|
+
for (var a of we(e))
|
|
1295
|
+
t.indexOf(a) < 0 && kt.call(e, a) && (n[a] = e[a]);
|
|
1296
|
+
return n;
|
|
1297
|
+
};
|
|
1298
|
+
var K;
|
|
1299
|
+
((e) => {
|
|
1300
|
+
const t = class N {
|
|
1301
|
+
/*-- Constructor (low level) and fields --*/
|
|
1302
|
+
// Creates a new QR Code with the given version number,
|
|
1303
|
+
// error correction level, data codeword bytes, and mask number.
|
|
1304
|
+
// This is a low-level API that most users should not use directly.
|
|
1305
|
+
// A mid-level API is the encodeSegments() function.
|
|
1306
|
+
constructor(r, i, o, d) {
|
|
1307
|
+
if (this.version = r, this.errorCorrectionLevel = i, this.modules = [], this.isFunction = [], r < N.MIN_VERSION || r > N.MAX_VERSION)
|
|
1308
|
+
throw new RangeError("Version value out of range");
|
|
1309
|
+
if (d < -1 || d > 7)
|
|
1310
|
+
throw new RangeError("Mask value out of range");
|
|
1311
|
+
this.size = r * 4 + 17;
|
|
1312
|
+
let u = [];
|
|
1313
|
+
for (let b = 0; b < this.size; b++)
|
|
1314
|
+
u.push(!1);
|
|
1315
|
+
for (let b = 0; b < this.size; b++)
|
|
1316
|
+
this.modules.push(u.slice()), this.isFunction.push(u.slice());
|
|
1317
|
+
this.drawFunctionPatterns();
|
|
1318
|
+
const m = this.addEccAndInterleave(o);
|
|
1319
|
+
if (this.drawCodewords(m), d == -1) {
|
|
1320
|
+
let b = 1e9;
|
|
1321
|
+
for (let x = 0; x < 8; x++) {
|
|
1322
|
+
this.applyMask(x), this.drawFormatBits(x);
|
|
1323
|
+
const v = this.getPenaltyScore();
|
|
1324
|
+
v < b && (d = x, b = v), this.applyMask(x);
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
l(0 <= d && d <= 7), this.mask = d, this.applyMask(d), this.drawFormatBits(d), this.isFunction = [];
|
|
1328
|
+
}
|
|
1329
|
+
/*-- Static factory functions (high level) --*/
|
|
1330
|
+
// Returns a QR Code representing the given Unicode text string at the given error correction level.
|
|
1331
|
+
// As a conservative upper bound, this function is guaranteed to succeed for strings that have 738 or fewer
|
|
1332
|
+
// Unicode code points (not UTF-16 code units) if the low error correction level is used. The smallest possible
|
|
1333
|
+
// QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the
|
|
1334
|
+
// ecl argument if it can be done without increasing the version.
|
|
1335
|
+
static encodeText(r, i) {
|
|
1336
|
+
const o = e.QrSegment.makeSegments(r);
|
|
1337
|
+
return N.encodeSegments(o, i);
|
|
1338
|
+
}
|
|
1339
|
+
// Returns a QR Code representing the given binary data at the given error correction level.
|
|
1340
|
+
// This function always encodes using the binary segment mode, not any text mode. The maximum number of
|
|
1341
|
+
// bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output.
|
|
1342
|
+
// The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version.
|
|
1343
|
+
static encodeBinary(r, i) {
|
|
1344
|
+
const o = e.QrSegment.makeBytes(r);
|
|
1345
|
+
return N.encodeSegments([o], i);
|
|
1346
|
+
}
|
|
1347
|
+
/*-- Static factory functions (mid level) --*/
|
|
1348
|
+
// Returns a QR Code representing the given segments with the given encoding parameters.
|
|
1349
|
+
// The smallest possible QR Code version within the given range is automatically
|
|
1350
|
+
// chosen for the output. Iff boostEcl is true, then the ECC level of the result
|
|
1351
|
+
// may be higher than the ecl argument if it can be done without increasing the
|
|
1352
|
+
// version. The mask number is either between 0 to 7 (inclusive) to force that
|
|
1353
|
+
// mask, or -1 to automatically choose an appropriate mask (which may be slow).
|
|
1354
|
+
// This function allows the user to create a custom sequence of segments that switches
|
|
1355
|
+
// between modes (such as alphanumeric and byte) to encode text in less space.
|
|
1356
|
+
// This is a mid-level API; the high-level API is encodeText() and encodeBinary().
|
|
1357
|
+
static encodeSegments(r, i, o = 1, d = 40, u = -1, m = !0) {
|
|
1358
|
+
if (!(N.MIN_VERSION <= o && o <= d && d <= N.MAX_VERSION) || u < -1 || u > 7)
|
|
1359
|
+
throw new RangeError("Invalid value");
|
|
1360
|
+
let b, x;
|
|
1361
|
+
for (b = o; ; b++) {
|
|
1362
|
+
const g = N.getNumDataCodewords(b, i) * 8, S = h.getTotalBits(r, b);
|
|
1363
|
+
if (S <= g) {
|
|
1364
|
+
x = S;
|
|
1365
|
+
break;
|
|
1366
|
+
}
|
|
1367
|
+
if (b >= d)
|
|
1368
|
+
throw new RangeError("Data too long");
|
|
1369
|
+
}
|
|
1370
|
+
for (const g of [N.Ecc.MEDIUM, N.Ecc.QUARTILE, N.Ecc.HIGH])
|
|
1371
|
+
m && x <= N.getNumDataCodewords(b, g) * 8 && (i = g);
|
|
1372
|
+
let v = [];
|
|
1373
|
+
for (const g of r) {
|
|
1374
|
+
n(g.mode.modeBits, 4, v), n(g.numChars, g.mode.numCharCountBits(b), v);
|
|
1375
|
+
for (const S of g.getData())
|
|
1376
|
+
v.push(S);
|
|
1377
|
+
}
|
|
1378
|
+
l(v.length == x);
|
|
1379
|
+
const P = N.getNumDataCodewords(b, i) * 8;
|
|
1380
|
+
l(v.length <= P), n(0, Math.min(4, P - v.length), v), n(0, (8 - v.length % 8) % 8, v), l(v.length % 8 == 0);
|
|
1381
|
+
for (let g = 236; v.length < P; g ^= 253)
|
|
1382
|
+
n(g, 8, v);
|
|
1383
|
+
let E = [];
|
|
1384
|
+
for (; E.length * 8 < v.length; )
|
|
1385
|
+
E.push(0);
|
|
1386
|
+
return v.forEach((g, S) => E[S >>> 3] |= g << 7 - (S & 7)), new N(b, i, E, u);
|
|
1387
|
+
}
|
|
1388
|
+
/*-- Accessor methods --*/
|
|
1389
|
+
// Returns the color of the module (pixel) at the given coordinates, which is false
|
|
1390
|
+
// for light or true for dark. The top left corner has the coordinates (x=0, y=0).
|
|
1391
|
+
// If the given coordinates are out of bounds, then false (light) is returned.
|
|
1392
|
+
getModule(r, i) {
|
|
1393
|
+
return 0 <= r && r < this.size && 0 <= i && i < this.size && this.modules[i][r];
|
|
1394
|
+
}
|
|
1395
|
+
// Modified to expose modules for easy access
|
|
1396
|
+
getModules() {
|
|
1397
|
+
return this.modules;
|
|
1398
|
+
}
|
|
1399
|
+
/*-- Private helper methods for constructor: Drawing function modules --*/
|
|
1400
|
+
// Reads this object's version field, and draws and marks all function modules.
|
|
1401
|
+
drawFunctionPatterns() {
|
|
1402
|
+
for (let o = 0; o < this.size; o++)
|
|
1403
|
+
this.setFunctionModule(6, o, o % 2 == 0), this.setFunctionModule(o, 6, o % 2 == 0);
|
|
1404
|
+
this.drawFinderPattern(3, 3), this.drawFinderPattern(this.size - 4, 3), this.drawFinderPattern(3, this.size - 4);
|
|
1405
|
+
const r = this.getAlignmentPatternPositions(), i = r.length;
|
|
1406
|
+
for (let o = 0; o < i; o++)
|
|
1407
|
+
for (let d = 0; d < i; d++)
|
|
1408
|
+
o == 0 && d == 0 || o == 0 && d == i - 1 || o == i - 1 && d == 0 || this.drawAlignmentPattern(r[o], r[d]);
|
|
1409
|
+
this.drawFormatBits(0), this.drawVersion();
|
|
1410
|
+
}
|
|
1411
|
+
// Draws two copies of the format bits (with its own error correction code)
|
|
1412
|
+
// based on the given mask and this object's error correction level field.
|
|
1413
|
+
drawFormatBits(r) {
|
|
1414
|
+
const i = this.errorCorrectionLevel.formatBits << 3 | r;
|
|
1415
|
+
let o = i;
|
|
1416
|
+
for (let u = 0; u < 10; u++)
|
|
1417
|
+
o = o << 1 ^ (o >>> 9) * 1335;
|
|
1418
|
+
const d = (i << 10 | o) ^ 21522;
|
|
1419
|
+
l(d >>> 15 == 0);
|
|
1420
|
+
for (let u = 0; u <= 5; u++)
|
|
1421
|
+
this.setFunctionModule(8, u, a(d, u));
|
|
1422
|
+
this.setFunctionModule(8, 7, a(d, 6)), this.setFunctionModule(8, 8, a(d, 7)), this.setFunctionModule(7, 8, a(d, 8));
|
|
1423
|
+
for (let u = 9; u < 15; u++)
|
|
1424
|
+
this.setFunctionModule(14 - u, 8, a(d, u));
|
|
1425
|
+
for (let u = 0; u < 8; u++)
|
|
1426
|
+
this.setFunctionModule(this.size - 1 - u, 8, a(d, u));
|
|
1427
|
+
for (let u = 8; u < 15; u++)
|
|
1428
|
+
this.setFunctionModule(8, this.size - 15 + u, a(d, u));
|
|
1429
|
+
this.setFunctionModule(8, this.size - 8, !0);
|
|
1430
|
+
}
|
|
1431
|
+
// Draws two copies of the version bits (with its own error correction code),
|
|
1432
|
+
// based on this object's version field, iff 7 <= version <= 40.
|
|
1433
|
+
drawVersion() {
|
|
1434
|
+
if (this.version < 7)
|
|
1435
|
+
return;
|
|
1436
|
+
let r = this.version;
|
|
1437
|
+
for (let o = 0; o < 12; o++)
|
|
1438
|
+
r = r << 1 ^ (r >>> 11) * 7973;
|
|
1439
|
+
const i = this.version << 12 | r;
|
|
1440
|
+
l(i >>> 18 == 0);
|
|
1441
|
+
for (let o = 0; o < 18; o++) {
|
|
1442
|
+
const d = a(i, o), u = this.size - 11 + o % 3, m = Math.floor(o / 3);
|
|
1443
|
+
this.setFunctionModule(u, m, d), this.setFunctionModule(m, u, d);
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
// Draws a 9*9 finder pattern including the border separator,
|
|
1447
|
+
// with the center module at (x, y). Modules can be out of bounds.
|
|
1448
|
+
drawFinderPattern(r, i) {
|
|
1449
|
+
for (let o = -4; o <= 4; o++)
|
|
1450
|
+
for (let d = -4; d <= 4; d++) {
|
|
1451
|
+
const u = Math.max(Math.abs(d), Math.abs(o)), m = r + d, b = i + o;
|
|
1452
|
+
0 <= m && m < this.size && 0 <= b && b < this.size && this.setFunctionModule(m, b, u != 2 && u != 4);
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
// Draws a 5*5 alignment pattern, with the center module
|
|
1456
|
+
// at (x, y). All modules must be in bounds.
|
|
1457
|
+
drawAlignmentPattern(r, i) {
|
|
1458
|
+
for (let o = -2; o <= 2; o++)
|
|
1459
|
+
for (let d = -2; d <= 2; d++)
|
|
1460
|
+
this.setFunctionModule(r + d, i + o, Math.max(Math.abs(d), Math.abs(o)) != 1);
|
|
1461
|
+
}
|
|
1462
|
+
// Sets the color of a module and marks it as a function module.
|
|
1463
|
+
// Only used by the constructor. Coordinates must be in bounds.
|
|
1464
|
+
setFunctionModule(r, i, o) {
|
|
1465
|
+
this.modules[i][r] = o, this.isFunction[i][r] = !0;
|
|
1466
|
+
}
|
|
1467
|
+
/*-- Private helper methods for constructor: Codewords and masking --*/
|
|
1468
|
+
// Returns a new byte string representing the given data with the appropriate error correction
|
|
1469
|
+
// codewords appended to it, based on this object's version and error correction level.
|
|
1470
|
+
addEccAndInterleave(r) {
|
|
1471
|
+
const i = this.version, o = this.errorCorrectionLevel;
|
|
1472
|
+
if (r.length != N.getNumDataCodewords(i, o))
|
|
1473
|
+
throw new RangeError("Invalid argument");
|
|
1474
|
+
const d = N.NUM_ERROR_CORRECTION_BLOCKS[o.ordinal][i], u = N.ECC_CODEWORDS_PER_BLOCK[o.ordinal][i], m = Math.floor(N.getNumRawDataModules(i) / 8), b = d - m % d, x = Math.floor(m / d);
|
|
1475
|
+
let v = [];
|
|
1476
|
+
const P = N.reedSolomonComputeDivisor(u);
|
|
1477
|
+
for (let g = 0, S = 0; g < d; g++) {
|
|
1478
|
+
let C = r.slice(S, S + x - u + (g < b ? 0 : 1));
|
|
1479
|
+
S += C.length;
|
|
1480
|
+
const B = N.reedSolomonComputeRemainder(C, P);
|
|
1481
|
+
g < b && C.push(0), v.push(C.concat(B));
|
|
1482
|
+
}
|
|
1483
|
+
let E = [];
|
|
1484
|
+
for (let g = 0; g < v[0].length; g++)
|
|
1485
|
+
v.forEach((S, C) => {
|
|
1486
|
+
(g != x - u || C >= b) && E.push(S[g]);
|
|
1487
|
+
});
|
|
1488
|
+
return l(E.length == m), E;
|
|
1489
|
+
}
|
|
1490
|
+
// Draws the given sequence of 8-bit codewords (data and error correction) onto the entire
|
|
1491
|
+
// data area of this QR Code. Function modules need to be marked off before this is called.
|
|
1492
|
+
drawCodewords(r) {
|
|
1493
|
+
if (r.length != Math.floor(N.getNumRawDataModules(this.version) / 8))
|
|
1494
|
+
throw new RangeError("Invalid argument");
|
|
1495
|
+
let i = 0;
|
|
1496
|
+
for (let o = this.size - 1; o >= 1; o -= 2) {
|
|
1497
|
+
o == 6 && (o = 5);
|
|
1498
|
+
for (let d = 0; d < this.size; d++)
|
|
1499
|
+
for (let u = 0; u < 2; u++) {
|
|
1500
|
+
const m = o - u, x = (o + 1 & 2) == 0 ? this.size - 1 - d : d;
|
|
1501
|
+
!this.isFunction[x][m] && i < r.length * 8 && (this.modules[x][m] = a(r[i >>> 3], 7 - (i & 7)), i++);
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
l(i == r.length * 8);
|
|
1505
|
+
}
|
|
1506
|
+
// XORs the codeword modules in this QR Code with the given mask pattern.
|
|
1507
|
+
// The function modules must be marked and the codeword bits must be drawn
|
|
1508
|
+
// before masking. Due to the arithmetic of XOR, calling applyMask() with
|
|
1509
|
+
// the same mask value a second time will undo the mask. A final well-formed
|
|
1510
|
+
// QR Code needs exactly one (not zero, two, etc.) mask applied.
|
|
1511
|
+
applyMask(r) {
|
|
1512
|
+
if (r < 0 || r > 7)
|
|
1513
|
+
throw new RangeError("Mask value out of range");
|
|
1514
|
+
for (let i = 0; i < this.size; i++)
|
|
1515
|
+
for (let o = 0; o < this.size; o++) {
|
|
1516
|
+
let d;
|
|
1517
|
+
switch (r) {
|
|
1518
|
+
case 0:
|
|
1519
|
+
d = (o + i) % 2 == 0;
|
|
1520
|
+
break;
|
|
1521
|
+
case 1:
|
|
1522
|
+
d = i % 2 == 0;
|
|
1523
|
+
break;
|
|
1524
|
+
case 2:
|
|
1525
|
+
d = o % 3 == 0;
|
|
1526
|
+
break;
|
|
1527
|
+
case 3:
|
|
1528
|
+
d = (o + i) % 3 == 0;
|
|
1529
|
+
break;
|
|
1530
|
+
case 4:
|
|
1531
|
+
d = (Math.floor(o / 3) + Math.floor(i / 2)) % 2 == 0;
|
|
1532
|
+
break;
|
|
1533
|
+
case 5:
|
|
1534
|
+
d = o * i % 2 + o * i % 3 == 0;
|
|
1535
|
+
break;
|
|
1536
|
+
case 6:
|
|
1537
|
+
d = (o * i % 2 + o * i % 3) % 2 == 0;
|
|
1538
|
+
break;
|
|
1539
|
+
case 7:
|
|
1540
|
+
d = ((o + i) % 2 + o * i % 3) % 2 == 0;
|
|
1541
|
+
break;
|
|
1542
|
+
default:
|
|
1543
|
+
throw new Error("Unreachable");
|
|
1544
|
+
}
|
|
1545
|
+
!this.isFunction[i][o] && d && (this.modules[i][o] = !this.modules[i][o]);
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
// Calculates and returns the penalty score based on state of this QR Code's current modules.
|
|
1549
|
+
// This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score.
|
|
1550
|
+
getPenaltyScore() {
|
|
1551
|
+
let r = 0;
|
|
1552
|
+
for (let u = 0; u < this.size; u++) {
|
|
1553
|
+
let m = !1, b = 0, x = [0, 0, 0, 0, 0, 0, 0];
|
|
1554
|
+
for (let v = 0; v < this.size; v++)
|
|
1555
|
+
this.modules[u][v] == m ? (b++, b == 5 ? r += N.PENALTY_N1 : b > 5 && r++) : (this.finderPenaltyAddHistory(b, x), m || (r += this.finderPenaltyCountPatterns(x) * N.PENALTY_N3), m = this.modules[u][v], b = 1);
|
|
1556
|
+
r += this.finderPenaltyTerminateAndCount(m, b, x) * N.PENALTY_N3;
|
|
1557
|
+
}
|
|
1558
|
+
for (let u = 0; u < this.size; u++) {
|
|
1559
|
+
let m = !1, b = 0, x = [0, 0, 0, 0, 0, 0, 0];
|
|
1560
|
+
for (let v = 0; v < this.size; v++)
|
|
1561
|
+
this.modules[v][u] == m ? (b++, b == 5 ? r += N.PENALTY_N1 : b > 5 && r++) : (this.finderPenaltyAddHistory(b, x), m || (r += this.finderPenaltyCountPatterns(x) * N.PENALTY_N3), m = this.modules[v][u], b = 1);
|
|
1562
|
+
r += this.finderPenaltyTerminateAndCount(m, b, x) * N.PENALTY_N3;
|
|
1563
|
+
}
|
|
1564
|
+
for (let u = 0; u < this.size - 1; u++)
|
|
1565
|
+
for (let m = 0; m < this.size - 1; m++) {
|
|
1566
|
+
const b = this.modules[u][m];
|
|
1567
|
+
b == this.modules[u][m + 1] && b == this.modules[u + 1][m] && b == this.modules[u + 1][m + 1] && (r += N.PENALTY_N2);
|
|
1568
|
+
}
|
|
1569
|
+
let i = 0;
|
|
1570
|
+
for (const u of this.modules)
|
|
1571
|
+
i = u.reduce((m, b) => m + (b ? 1 : 0), i);
|
|
1572
|
+
const o = this.size * this.size, d = Math.ceil(Math.abs(i * 20 - o * 10) / o) - 1;
|
|
1573
|
+
return l(0 <= d && d <= 9), r += d * N.PENALTY_N4, l(0 <= r && r <= 2568888), r;
|
|
1574
|
+
}
|
|
1575
|
+
/*-- Private helper functions --*/
|
|
1576
|
+
// Returns an ascending list of positions of alignment patterns for this version number.
|
|
1577
|
+
// Each position is in the range [0,177), and are used on both the x and y axes.
|
|
1578
|
+
// This could be implemented as lookup table of 40 variable-length lists of integers.
|
|
1579
|
+
getAlignmentPatternPositions() {
|
|
1580
|
+
if (this.version == 1)
|
|
1581
|
+
return [];
|
|
1582
|
+
{
|
|
1583
|
+
const r = Math.floor(this.version / 7) + 2, i = this.version == 32 ? 26 : Math.ceil((this.version * 4 + 4) / (r * 2 - 2)) * 2;
|
|
1584
|
+
let o = [6];
|
|
1585
|
+
for (let d = this.size - 7; o.length < r; d -= i)
|
|
1586
|
+
o.splice(1, 0, d);
|
|
1587
|
+
return o;
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
// Returns the number of data bits that can be stored in a QR Code of the given version number, after
|
|
1591
|
+
// all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8.
|
|
1592
|
+
// The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table.
|
|
1593
|
+
static getNumRawDataModules(r) {
|
|
1594
|
+
if (r < N.MIN_VERSION || r > N.MAX_VERSION)
|
|
1595
|
+
throw new RangeError("Version number out of range");
|
|
1596
|
+
let i = (16 * r + 128) * r + 64;
|
|
1597
|
+
if (r >= 2) {
|
|
1598
|
+
const o = Math.floor(r / 7) + 2;
|
|
1599
|
+
i -= (25 * o - 10) * o - 55, r >= 7 && (i -= 36);
|
|
1600
|
+
}
|
|
1601
|
+
return l(208 <= i && i <= 29648), i;
|
|
1602
|
+
}
|
|
1603
|
+
// Returns the number of 8-bit data (i.e. not error correction) codewords contained in any
|
|
1604
|
+
// QR Code of the given version number and error correction level, with remainder bits discarded.
|
|
1605
|
+
// This stateless pure function could be implemented as a (40*4)-cell lookup table.
|
|
1606
|
+
static getNumDataCodewords(r, i) {
|
|
1607
|
+
return Math.floor(N.getNumRawDataModules(r) / 8) - N.ECC_CODEWORDS_PER_BLOCK[i.ordinal][r] * N.NUM_ERROR_CORRECTION_BLOCKS[i.ordinal][r];
|
|
1608
|
+
}
|
|
1609
|
+
// Returns a Reed-Solomon ECC generator polynomial for the given degree. This could be
|
|
1610
|
+
// implemented as a lookup table over all possible parameter values, instead of as an algorithm.
|
|
1611
|
+
static reedSolomonComputeDivisor(r) {
|
|
1612
|
+
if (r < 1 || r > 255)
|
|
1613
|
+
throw new RangeError("Degree out of range");
|
|
1614
|
+
let i = [];
|
|
1615
|
+
for (let d = 0; d < r - 1; d++)
|
|
1616
|
+
i.push(0);
|
|
1617
|
+
i.push(1);
|
|
1618
|
+
let o = 1;
|
|
1619
|
+
for (let d = 0; d < r; d++) {
|
|
1620
|
+
for (let u = 0; u < i.length; u++)
|
|
1621
|
+
i[u] = N.reedSolomonMultiply(i[u], o), u + 1 < i.length && (i[u] ^= i[u + 1]);
|
|
1622
|
+
o = N.reedSolomonMultiply(o, 2);
|
|
1623
|
+
}
|
|
1624
|
+
return i;
|
|
1625
|
+
}
|
|
1626
|
+
// Returns the Reed-Solomon error correction codeword for the given data and divisor polynomials.
|
|
1627
|
+
static reedSolomonComputeRemainder(r, i) {
|
|
1628
|
+
let o = i.map((d) => 0);
|
|
1629
|
+
for (const d of r) {
|
|
1630
|
+
const u = d ^ o.shift();
|
|
1631
|
+
o.push(0), i.forEach((m, b) => o[b] ^= N.reedSolomonMultiply(m, u));
|
|
1632
|
+
}
|
|
1633
|
+
return o;
|
|
1634
|
+
}
|
|
1635
|
+
// Returns the product of the two given field elements modulo GF(2^8/0x11D). The arguments and result
|
|
1636
|
+
// are unsigned 8-bit integers. This could be implemented as a lookup table of 256*256 entries of uint8.
|
|
1637
|
+
static reedSolomonMultiply(r, i) {
|
|
1638
|
+
if (r >>> 8 || i >>> 8)
|
|
1639
|
+
throw new RangeError("Byte out of range");
|
|
1640
|
+
let o = 0;
|
|
1641
|
+
for (let d = 7; d >= 0; d--)
|
|
1642
|
+
o = o << 1 ^ (o >>> 7) * 285, o ^= (i >>> d & 1) * r;
|
|
1643
|
+
return l(o >>> 8 == 0), o;
|
|
1644
|
+
}
|
|
1645
|
+
// Can only be called immediately after a light run is added, and
|
|
1646
|
+
// returns either 0, 1, or 2. A helper function for getPenaltyScore().
|
|
1647
|
+
finderPenaltyCountPatterns(r) {
|
|
1648
|
+
const i = r[1];
|
|
1649
|
+
l(i <= this.size * 3);
|
|
1650
|
+
const o = i > 0 && r[2] == i && r[3] == i * 3 && r[4] == i && r[5] == i;
|
|
1651
|
+
return (o && r[0] >= i * 4 && r[6] >= i ? 1 : 0) + (o && r[6] >= i * 4 && r[0] >= i ? 1 : 0);
|
|
1652
|
+
}
|
|
1653
|
+
// Must be called at the end of a line (row or column) of modules. A helper function for getPenaltyScore().
|
|
1654
|
+
finderPenaltyTerminateAndCount(r, i, o) {
|
|
1655
|
+
return r && (this.finderPenaltyAddHistory(i, o), i = 0), i += this.size, this.finderPenaltyAddHistory(i, o), this.finderPenaltyCountPatterns(o);
|
|
1656
|
+
}
|
|
1657
|
+
// Pushes the given value to the front and drops the last value. A helper function for getPenaltyScore().
|
|
1658
|
+
finderPenaltyAddHistory(r, i) {
|
|
1659
|
+
i[0] == 0 && (r += this.size), i.pop(), i.unshift(r);
|
|
1660
|
+
}
|
|
1661
|
+
};
|
|
1662
|
+
t.MIN_VERSION = 1, t.MAX_VERSION = 40, t.PENALTY_N1 = 3, t.PENALTY_N2 = 3, t.PENALTY_N3 = 40, t.PENALTY_N4 = 10, t.ECC_CODEWORDS_PER_BLOCK = [
|
|
1663
|
+
// Version: (note that index 0 is for padding, and is set to an illegal value)
|
|
1664
|
+
//0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
|
|
1665
|
+
[-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
|
|
1666
|
+
// Low
|
|
1667
|
+
[-1, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28],
|
|
1668
|
+
// Medium
|
|
1669
|
+
[-1, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
|
|
1670
|
+
// Quartile
|
|
1671
|
+
[-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]
|
|
1672
|
+
// High
|
|
1673
|
+
], t.NUM_ERROR_CORRECTION_BLOCKS = [
|
|
1674
|
+
// Version: (note that index 0 is for padding, and is set to an illegal value)
|
|
1675
|
+
//0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
|
|
1676
|
+
[-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25],
|
|
1677
|
+
// Low
|
|
1678
|
+
[-1, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49],
|
|
1679
|
+
// Medium
|
|
1680
|
+
[-1, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68],
|
|
1681
|
+
// Quartile
|
|
1682
|
+
[-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81]
|
|
1683
|
+
// High
|
|
1684
|
+
], e.QrCode = t;
|
|
1685
|
+
function n(p, r, i) {
|
|
1686
|
+
if (r < 0 || r > 31 || p >>> r)
|
|
1687
|
+
throw new RangeError("Value out of range");
|
|
1688
|
+
for (let o = r - 1; o >= 0; o--)
|
|
1689
|
+
i.push(p >>> o & 1);
|
|
1690
|
+
}
|
|
1691
|
+
function a(p, r) {
|
|
1692
|
+
return (p >>> r & 1) != 0;
|
|
1693
|
+
}
|
|
1694
|
+
function l(p) {
|
|
1695
|
+
if (!p)
|
|
1696
|
+
throw new Error("Assertion error");
|
|
1697
|
+
}
|
|
1698
|
+
const c = class _ {
|
|
1699
|
+
/*-- Constructor (low level) and fields --*/
|
|
1700
|
+
// Creates a new QR Code segment with the given attributes and data.
|
|
1701
|
+
// The character count (numChars) must agree with the mode and the bit buffer length,
|
|
1702
|
+
// but the constraint isn't checked. The given bit buffer is cloned and stored.
|
|
1703
|
+
constructor(r, i, o) {
|
|
1704
|
+
if (this.mode = r, this.numChars = i, this.bitData = o, i < 0)
|
|
1705
|
+
throw new RangeError("Invalid argument");
|
|
1706
|
+
this.bitData = o.slice();
|
|
1707
|
+
}
|
|
1708
|
+
/*-- Static factory functions (mid level) --*/
|
|
1709
|
+
// Returns a segment representing the given binary data encoded in
|
|
1710
|
+
// byte mode. All input byte arrays are acceptable. Any text string
|
|
1711
|
+
// can be converted to UTF-8 bytes and encoded as a byte mode segment.
|
|
1712
|
+
static makeBytes(r) {
|
|
1713
|
+
let i = [];
|
|
1714
|
+
for (const o of r)
|
|
1715
|
+
n(o, 8, i);
|
|
1716
|
+
return new _(_.Mode.BYTE, r.length, i);
|
|
1717
|
+
}
|
|
1718
|
+
// Returns a segment representing the given string of decimal digits encoded in numeric mode.
|
|
1719
|
+
static makeNumeric(r) {
|
|
1720
|
+
if (!_.isNumeric(r))
|
|
1721
|
+
throw new RangeError("String contains non-numeric characters");
|
|
1722
|
+
let i = [];
|
|
1723
|
+
for (let o = 0; o < r.length; ) {
|
|
1724
|
+
const d = Math.min(r.length - o, 3);
|
|
1725
|
+
n(parseInt(r.substring(o, o + d), 10), d * 3 + 1, i), o += d;
|
|
1726
|
+
}
|
|
1727
|
+
return new _(_.Mode.NUMERIC, r.length, i);
|
|
1728
|
+
}
|
|
1729
|
+
// Returns a segment representing the given text string encoded in alphanumeric mode.
|
|
1730
|
+
// The characters allowed are: 0 to 9, A to Z (uppercase only), space,
|
|
1731
|
+
// dollar, percent, asterisk, plus, hyphen, period, slash, colon.
|
|
1732
|
+
static makeAlphanumeric(r) {
|
|
1733
|
+
if (!_.isAlphanumeric(r))
|
|
1734
|
+
throw new RangeError("String contains unencodable characters in alphanumeric mode");
|
|
1735
|
+
let i = [], o;
|
|
1736
|
+
for (o = 0; o + 2 <= r.length; o += 2) {
|
|
1737
|
+
let d = _.ALPHANUMERIC_CHARSET.indexOf(r.charAt(o)) * 45;
|
|
1738
|
+
d += _.ALPHANUMERIC_CHARSET.indexOf(r.charAt(o + 1)), n(d, 11, i);
|
|
1739
|
+
}
|
|
1740
|
+
return o < r.length && n(_.ALPHANUMERIC_CHARSET.indexOf(r.charAt(o)), 6, i), new _(_.Mode.ALPHANUMERIC, r.length, i);
|
|
1741
|
+
}
|
|
1742
|
+
// Returns a new mutable list of zero or more segments to represent the given Unicode text string.
|
|
1743
|
+
// The result may use various segment modes and switch modes to optimize the length of the bit stream.
|
|
1744
|
+
static makeSegments(r) {
|
|
1745
|
+
return r == "" ? [] : _.isNumeric(r) ? [_.makeNumeric(r)] : _.isAlphanumeric(r) ? [_.makeAlphanumeric(r)] : [_.makeBytes(_.toUtf8ByteArray(r))];
|
|
1746
|
+
}
|
|
1747
|
+
// Returns a segment representing an Extended Channel Interpretation
|
|
1748
|
+
// (ECI) designator with the given assignment value.
|
|
1749
|
+
static makeEci(r) {
|
|
1750
|
+
let i = [];
|
|
1751
|
+
if (r < 0)
|
|
1752
|
+
throw new RangeError("ECI assignment value out of range");
|
|
1753
|
+
if (r < 128)
|
|
1754
|
+
n(r, 8, i);
|
|
1755
|
+
else if (r < 16384)
|
|
1756
|
+
n(2, 2, i), n(r, 14, i);
|
|
1757
|
+
else if (r < 1e6)
|
|
1758
|
+
n(6, 3, i), n(r, 21, i);
|
|
1759
|
+
else
|
|
1760
|
+
throw new RangeError("ECI assignment value out of range");
|
|
1761
|
+
return new _(_.Mode.ECI, 0, i);
|
|
1762
|
+
}
|
|
1763
|
+
// Tests whether the given string can be encoded as a segment in numeric mode.
|
|
1764
|
+
// A string is encodable iff each character is in the range 0 to 9.
|
|
1765
|
+
static isNumeric(r) {
|
|
1766
|
+
return _.NUMERIC_REGEX.test(r);
|
|
1767
|
+
}
|
|
1768
|
+
// Tests whether the given string can be encoded as a segment in alphanumeric mode.
|
|
1769
|
+
// A string is encodable iff each character is in the following set: 0 to 9, A to Z
|
|
1770
|
+
// (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon.
|
|
1771
|
+
static isAlphanumeric(r) {
|
|
1772
|
+
return _.ALPHANUMERIC_REGEX.test(r);
|
|
1773
|
+
}
|
|
1774
|
+
/*-- Methods --*/
|
|
1775
|
+
// Returns a new copy of the data bits of this segment.
|
|
1776
|
+
getData() {
|
|
1777
|
+
return this.bitData.slice();
|
|
1778
|
+
}
|
|
1779
|
+
// (Package-private) Calculates and returns the number of bits needed to encode the given segments at
|
|
1780
|
+
// the given version. The result is infinity if a segment has too many characters to fit its length field.
|
|
1781
|
+
static getTotalBits(r, i) {
|
|
1782
|
+
let o = 0;
|
|
1783
|
+
for (const d of r) {
|
|
1784
|
+
const u = d.mode.numCharCountBits(i);
|
|
1785
|
+
if (d.numChars >= 1 << u)
|
|
1786
|
+
return 1 / 0;
|
|
1787
|
+
o += 4 + u + d.bitData.length;
|
|
1788
|
+
}
|
|
1789
|
+
return o;
|
|
1790
|
+
}
|
|
1791
|
+
// Returns a new array of bytes representing the given string encoded in UTF-8.
|
|
1792
|
+
static toUtf8ByteArray(r) {
|
|
1793
|
+
r = encodeURI(r);
|
|
1794
|
+
let i = [];
|
|
1795
|
+
for (let o = 0; o < r.length; o++)
|
|
1796
|
+
r.charAt(o) != "%" ? i.push(r.charCodeAt(o)) : (i.push(parseInt(r.substring(o + 1, o + 3), 16)), o += 2);
|
|
1797
|
+
return i;
|
|
1798
|
+
}
|
|
1799
|
+
};
|
|
1800
|
+
c.NUMERIC_REGEX = /^[0-9]*$/, c.ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+.\/:-]*$/, c.ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
|
|
1801
|
+
let h = c;
|
|
1802
|
+
e.QrSegment = c;
|
|
1803
|
+
})(K || (K = {}));
|
|
1804
|
+
((e) => {
|
|
1805
|
+
((t) => {
|
|
1806
|
+
const n = class {
|
|
1807
|
+
// The QR Code can tolerate about 30% erroneous codewords
|
|
1808
|
+
/*-- Constructor and fields --*/
|
|
1809
|
+
constructor(l, c) {
|
|
1810
|
+
this.ordinal = l, this.formatBits = c;
|
|
1811
|
+
}
|
|
1812
|
+
};
|
|
1813
|
+
n.LOW = new n(0, 1), n.MEDIUM = new n(1, 0), n.QUARTILE = new n(2, 3), n.HIGH = new n(3, 2), t.Ecc = n;
|
|
1814
|
+
})(e.QrCode || (e.QrCode = {}));
|
|
1815
|
+
})(K || (K = {}));
|
|
1816
|
+
((e) => {
|
|
1817
|
+
((t) => {
|
|
1818
|
+
const n = class {
|
|
1819
|
+
/*-- Constructor and fields --*/
|
|
1820
|
+
constructor(l, c) {
|
|
1821
|
+
this.modeBits = l, this.numBitsCharCount = c;
|
|
1822
|
+
}
|
|
1823
|
+
/*-- Method --*/
|
|
1824
|
+
// (Package-private) Returns the bit width of the character count field for a segment in
|
|
1825
|
+
// this mode in a QR Code at the given version number. The result is in the range [0, 16].
|
|
1826
|
+
numCharCountBits(l) {
|
|
1827
|
+
return this.numBitsCharCount[Math.floor((l + 7) / 17)];
|
|
1828
|
+
}
|
|
1829
|
+
};
|
|
1830
|
+
n.NUMERIC = new n(1, [10, 12, 14]), n.ALPHANUMERIC = new n(2, [9, 11, 13]), n.BYTE = new n(4, [8, 16, 16]), n.KANJI = new n(8, [8, 10, 12]), n.ECI = new n(7, [0, 0, 0]), t.Mode = n;
|
|
1831
|
+
})(e.QrSegment || (e.QrSegment = {}));
|
|
1832
|
+
})(K || (K = {}));
|
|
1833
|
+
var q = K;
|
|
1834
|
+
var Lr = {
|
|
1835
|
+
L: q.QrCode.Ecc.LOW,
|
|
1836
|
+
M: q.QrCode.Ecc.MEDIUM,
|
|
1837
|
+
Q: q.QrCode.Ecc.QUARTILE,
|
|
1838
|
+
H: q.QrCode.Ecc.HIGH
|
|
1839
|
+
}, Pt = 128, Rt = "L", Ot = "#FFFFFF", At = "#000000", Tt = !1, Lt = 1, $r = 4, Dr = 0, Fr = 0.1;
|
|
1840
|
+
function $t(e, t = 0) {
|
|
1841
|
+
const n = [];
|
|
1842
|
+
return e.forEach(function(a, l) {
|
|
1843
|
+
let c = null;
|
|
1844
|
+
a.forEach(function(h, p) {
|
|
1845
|
+
if (!h && c !== null) {
|
|
1846
|
+
n.push(
|
|
1847
|
+
`M${c + t} ${l + t}h${p - c}v1H${c + t}z`
|
|
1848
|
+
), c = null;
|
|
1849
|
+
return;
|
|
1850
|
+
}
|
|
1851
|
+
if (p === a.length - 1) {
|
|
1852
|
+
if (!h)
|
|
1853
|
+
return;
|
|
1854
|
+
c === null ? n.push(`M${p + t},${l + t} h1v1H${p + t}z`) : n.push(
|
|
1855
|
+
`M${c + t},${l + t} h${p + 1 - c}v1H${c + t}z`
|
|
1856
|
+
);
|
|
1857
|
+
return;
|
|
1858
|
+
}
|
|
1859
|
+
h && c === null && (c = p);
|
|
1860
|
+
});
|
|
1861
|
+
}), n.join("");
|
|
1862
|
+
}
|
|
1863
|
+
function Dt(e, t) {
|
|
1864
|
+
return e.slice().map((n, a) => a < t.y || a >= t.y + t.h ? n : n.map((l, c) => c < t.x || c >= t.x + t.w ? l : !1));
|
|
1865
|
+
}
|
|
1866
|
+
function Ur(e, t, n, a) {
|
|
1867
|
+
if (a == null)
|
|
1868
|
+
return null;
|
|
1869
|
+
const l = e.length + n * 2, c = Math.floor(t * Fr), h = l / t, p = (a.width || c) * h, r = (a.height || c) * h, i = a.x == null ? e.length / 2 - p / 2 : a.x * h, o = a.y == null ? e.length / 2 - r / 2 : a.y * h, d = a.opacity == null ? 1 : a.opacity;
|
|
1870
|
+
let u = null;
|
|
1871
|
+
if (a.excavate) {
|
|
1872
|
+
let b = Math.floor(i), x = Math.floor(o), v = Math.ceil(p + i - b), P = Math.ceil(r + o - x);
|
|
1873
|
+
u = { x: b, y: x, w: v, h: P };
|
|
1874
|
+
}
|
|
1875
|
+
const m = a.crossOrigin;
|
|
1876
|
+
return { x: i, y: o, h: r, w: p, excavation: u, opacity: d, crossOrigin: m };
|
|
1877
|
+
}
|
|
1878
|
+
function Br(e, t) {
|
|
1879
|
+
return t != null ? Math.max(Math.floor(t), 0) : e ? $r : Dr;
|
|
1880
|
+
}
|
|
1881
|
+
function Ft({
|
|
1882
|
+
value: e,
|
|
1883
|
+
level: t,
|
|
1884
|
+
minVersion: n,
|
|
1885
|
+
includeMargin: a,
|
|
1886
|
+
marginSize: l,
|
|
1887
|
+
imageSettings: c,
|
|
1888
|
+
size: h,
|
|
1889
|
+
boostLevel: p
|
|
1890
|
+
}) {
|
|
1891
|
+
let r = M.useMemo(() => {
|
|
1892
|
+
const b = (Array.isArray(e) ? e : [e]).reduce((x, v) => (x.push(...q.QrSegment.makeSegments(v)), x), []);
|
|
1893
|
+
return q.QrCode.encodeSegments(
|
|
1894
|
+
b,
|
|
1895
|
+
Lr[t],
|
|
1896
|
+
n,
|
|
1897
|
+
void 0,
|
|
1898
|
+
void 0,
|
|
1899
|
+
p
|
|
1900
|
+
);
|
|
1901
|
+
}, [e, t, n, p]);
|
|
1902
|
+
const { cells: i, margin: o, numCells: d, calculatedImageSettings: u } = M.useMemo(() => {
|
|
1903
|
+
let m = r.getModules();
|
|
1904
|
+
const b = Br(a, l), x = m.length + b * 2, v = Ur(
|
|
1905
|
+
m,
|
|
1906
|
+
h,
|
|
1907
|
+
b,
|
|
1908
|
+
c
|
|
1909
|
+
);
|
|
1910
|
+
return {
|
|
1911
|
+
cells: m,
|
|
1912
|
+
margin: b,
|
|
1913
|
+
numCells: x,
|
|
1914
|
+
calculatedImageSettings: v
|
|
1915
|
+
};
|
|
1916
|
+
}, [r, h, c, a, l]);
|
|
1917
|
+
return {
|
|
1918
|
+
qrcode: r,
|
|
1919
|
+
margin: o,
|
|
1920
|
+
cells: i,
|
|
1921
|
+
numCells: d,
|
|
1922
|
+
calculatedImageSettings: u
|
|
1923
|
+
};
|
|
1924
|
+
}
|
|
1925
|
+
var jr = (function() {
|
|
1926
|
+
try {
|
|
1927
|
+
new Path2D().addPath(new Path2D());
|
|
1928
|
+
} catch {
|
|
1929
|
+
return !1;
|
|
1930
|
+
}
|
|
1931
|
+
return !0;
|
|
1932
|
+
})(), zr = M.forwardRef(
|
|
1933
|
+
function(t, n) {
|
|
1934
|
+
const a = t, {
|
|
1935
|
+
value: l,
|
|
1936
|
+
size: c = Pt,
|
|
1937
|
+
level: h = Rt,
|
|
1938
|
+
bgColor: p = Ot,
|
|
1939
|
+
fgColor: r = At,
|
|
1940
|
+
includeMargin: i = Tt,
|
|
1941
|
+
minVersion: o = Lt,
|
|
1942
|
+
boostLevel: d,
|
|
1943
|
+
marginSize: u,
|
|
1944
|
+
imageSettings: m
|
|
1945
|
+
} = a, x = Ue(a, [
|
|
1946
|
+
"value",
|
|
1947
|
+
"size",
|
|
1948
|
+
"level",
|
|
1949
|
+
"bgColor",
|
|
1950
|
+
"fgColor",
|
|
1951
|
+
"includeMargin",
|
|
1952
|
+
"minVersion",
|
|
1953
|
+
"boostLevel",
|
|
1954
|
+
"marginSize",
|
|
1955
|
+
"imageSettings"
|
|
1956
|
+
]), { style: v } = x, P = Ue(x, ["style"]), E = m?.src, g = M.useRef(null), S = M.useRef(null), C = M.useCallback(
|
|
1957
|
+
(F) => {
|
|
1958
|
+
g.current = F, typeof n == "function" ? n(F) : n && (n.current = F);
|
|
1959
|
+
},
|
|
1960
|
+
[n]
|
|
1961
|
+
), [B, Z] = M.useState(!1), { margin: V, cells: j, numCells: Q, calculatedImageSettings: R } = Ft({
|
|
1962
|
+
value: l,
|
|
1963
|
+
level: h,
|
|
1964
|
+
minVersion: o,
|
|
1965
|
+
boostLevel: d,
|
|
1966
|
+
includeMargin: i,
|
|
1967
|
+
marginSize: u,
|
|
1968
|
+
imageSettings: m,
|
|
1969
|
+
size: c
|
|
1970
|
+
});
|
|
1971
|
+
M.useEffect(() => {
|
|
1972
|
+
if (g.current != null) {
|
|
1973
|
+
const F = g.current, $ = F.getContext("2d");
|
|
1974
|
+
if (!$)
|
|
1975
|
+
return;
|
|
1976
|
+
let H = j;
|
|
1977
|
+
const T = S.current, Y = R != null && T !== null && T.complete && T.naturalHeight !== 0 && T.naturalWidth !== 0;
|
|
1978
|
+
Y && R.excavation != null && (H = Dt(
|
|
1979
|
+
j,
|
|
1980
|
+
R.excavation
|
|
1981
|
+
));
|
|
1982
|
+
const O = window.devicePixelRatio || 1;
|
|
1983
|
+
F.height = F.width = c * O;
|
|
1984
|
+
const oe = c / Q * O;
|
|
1985
|
+
$.scale(oe, oe), $.fillStyle = p, $.fillRect(0, 0, Q, Q), $.fillStyle = r, jr ? $.fill(new Path2D($t(H, V))) : j.forEach(function(ee, ie) {
|
|
1986
|
+
ee.forEach(function(Ne, Se) {
|
|
1987
|
+
Ne && $.fillRect(Se + V, ie + V, 1, 1);
|
|
1988
|
+
});
|
|
1989
|
+
}), R && ($.globalAlpha = R.opacity), Y && $.drawImage(
|
|
1990
|
+
T,
|
|
1991
|
+
R.x + V,
|
|
1992
|
+
R.y + V,
|
|
1993
|
+
R.w,
|
|
1994
|
+
R.h
|
|
1995
|
+
);
|
|
1996
|
+
}
|
|
1997
|
+
}), M.useEffect(() => {
|
|
1998
|
+
Z(!1);
|
|
1999
|
+
}, [E]);
|
|
2000
|
+
const ae = Fe({ height: c, width: c }, v);
|
|
2001
|
+
let z = null;
|
|
2002
|
+
return E != null && (z = /* @__PURE__ */ M.createElement(
|
|
2003
|
+
"img",
|
|
2004
|
+
{
|
|
2005
|
+
src: E,
|
|
2006
|
+
key: E,
|
|
2007
|
+
style: { display: "none" },
|
|
2008
|
+
onLoad: () => {
|
|
2009
|
+
Z(!0);
|
|
2010
|
+
},
|
|
2011
|
+
ref: S,
|
|
2012
|
+
crossOrigin: R?.crossOrigin
|
|
2013
|
+
}
|
|
2014
|
+
)), /* @__PURE__ */ M.createElement(M.Fragment, null, /* @__PURE__ */ M.createElement(
|
|
2015
|
+
"canvas",
|
|
2016
|
+
Fe({
|
|
2017
|
+
style: ae,
|
|
2018
|
+
height: c,
|
|
2019
|
+
width: c,
|
|
2020
|
+
ref: C,
|
|
2021
|
+
role: "img"
|
|
2022
|
+
}, P)
|
|
2023
|
+
), z);
|
|
2024
|
+
}
|
|
2025
|
+
);
|
|
2026
|
+
zr.displayName = "QRCodeCanvas";
|
|
2027
|
+
var Ut = M.forwardRef(
|
|
2028
|
+
function(t, n) {
|
|
2029
|
+
const a = t, {
|
|
2030
|
+
value: l,
|
|
2031
|
+
size: c = Pt,
|
|
2032
|
+
level: h = Rt,
|
|
2033
|
+
bgColor: p = Ot,
|
|
2034
|
+
fgColor: r = At,
|
|
2035
|
+
includeMargin: i = Tt,
|
|
2036
|
+
minVersion: o = Lt,
|
|
2037
|
+
boostLevel: d,
|
|
2038
|
+
title: u,
|
|
2039
|
+
marginSize: m,
|
|
2040
|
+
imageSettings: b
|
|
2041
|
+
} = a, x = Ue(a, [
|
|
2042
|
+
"value",
|
|
2043
|
+
"size",
|
|
2044
|
+
"level",
|
|
2045
|
+
"bgColor",
|
|
2046
|
+
"fgColor",
|
|
2047
|
+
"includeMargin",
|
|
2048
|
+
"minVersion",
|
|
2049
|
+
"boostLevel",
|
|
2050
|
+
"title",
|
|
2051
|
+
"marginSize",
|
|
2052
|
+
"imageSettings"
|
|
2053
|
+
]), { margin: v, cells: P, numCells: E, calculatedImageSettings: g } = Ft({
|
|
2054
|
+
value: l,
|
|
2055
|
+
level: h,
|
|
2056
|
+
minVersion: o,
|
|
2057
|
+
boostLevel: d,
|
|
2058
|
+
includeMargin: i,
|
|
2059
|
+
marginSize: m,
|
|
2060
|
+
imageSettings: b,
|
|
2061
|
+
size: c
|
|
2062
|
+
});
|
|
2063
|
+
let S = P, C = null;
|
|
2064
|
+
b != null && g != null && (g.excavation != null && (S = Dt(
|
|
2065
|
+
P,
|
|
2066
|
+
g.excavation
|
|
2067
|
+
)), C = /* @__PURE__ */ M.createElement(
|
|
2068
|
+
"image",
|
|
2069
|
+
{
|
|
2070
|
+
href: b.src,
|
|
2071
|
+
height: g.h,
|
|
2072
|
+
width: g.w,
|
|
2073
|
+
x: g.x + v,
|
|
2074
|
+
y: g.y + v,
|
|
2075
|
+
preserveAspectRatio: "none",
|
|
2076
|
+
opacity: g.opacity,
|
|
2077
|
+
crossOrigin: g.crossOrigin
|
|
2078
|
+
}
|
|
2079
|
+
));
|
|
2080
|
+
const B = $t(S, v);
|
|
2081
|
+
return /* @__PURE__ */ M.createElement(
|
|
2082
|
+
"svg",
|
|
2083
|
+
Fe({
|
|
2084
|
+
height: c,
|
|
2085
|
+
width: c,
|
|
2086
|
+
viewBox: `0 0 ${E} ${E}`,
|
|
2087
|
+
ref: n,
|
|
2088
|
+
role: "img"
|
|
2089
|
+
}, x),
|
|
2090
|
+
!!u && /* @__PURE__ */ M.createElement("title", null, u),
|
|
2091
|
+
/* @__PURE__ */ M.createElement(
|
|
2092
|
+
"path",
|
|
2093
|
+
{
|
|
2094
|
+
fill: p,
|
|
2095
|
+
d: `M0,0 h${E}v${E}H0z`,
|
|
2096
|
+
shapeRendering: "crispEdges"
|
|
2097
|
+
}
|
|
2098
|
+
),
|
|
2099
|
+
/* @__PURE__ */ M.createElement("path", { fill: r, d: B, shapeRendering: "crispEdges" }),
|
|
2100
|
+
C
|
|
2101
|
+
);
|
|
2102
|
+
}
|
|
2103
|
+
);
|
|
2104
|
+
Ut.displayName = "QRCodeSVG";
|
|
2105
|
+
const Bt = "superwall-device-scheme", jt = () => {
|
|
2106
|
+
try {
|
|
2107
|
+
return window.localStorage.getItem(Bt) ?? void 0;
|
|
2108
|
+
} catch {
|
|
2109
|
+
return;
|
|
2110
|
+
}
|
|
2111
|
+
}, zt = (e) => {
|
|
2112
|
+
try {
|
|
2113
|
+
window.localStorage.setItem(Bt, e);
|
|
2114
|
+
} catch {
|
|
2115
|
+
}
|
|
2116
|
+
}, Be = (e, t, n) => {
|
|
2117
|
+
const a = n === void 0 ? "" : `&superwall_dev_surface=${encodeURIComponent(n)}`;
|
|
2118
|
+
return `${e}://?superwall_dev=${encodeURIComponent(t)}${a}`;
|
|
2119
|
+
}, Hr = (e) => {
|
|
2120
|
+
const n = window.prompt("Your app's URL scheme, so this can open it:", e)?.trim();
|
|
2121
|
+
if (!(n === void 0 || n === ""))
|
|
2122
|
+
return zt(n), n;
|
|
2123
|
+
}, Vr = ({
|
|
2124
|
+
source: e,
|
|
2125
|
+
surface: t
|
|
2126
|
+
}) => {
|
|
2127
|
+
const n = Ve() === "hosted", [a, l] = w.useState(!1), [c, h] = w.useState(() => jt() ?? e.scheme), [p, r] = w.useState({ status: "loading" });
|
|
2128
|
+
return w.useEffect(() => {
|
|
2129
|
+
if (a) {
|
|
2130
|
+
if (n) {
|
|
2131
|
+
const i = e.previewLink;
|
|
2132
|
+
if (i === void 0) {
|
|
2133
|
+
r({ status: "unavailable", reason: "This studio cannot open paywalls on a device." });
|
|
2134
|
+
return;
|
|
2135
|
+
}
|
|
2136
|
+
let o = !1;
|
|
2137
|
+
return r({ status: "loading" }), i(t).then(
|
|
2138
|
+
(d) => {
|
|
2139
|
+
o || r({ status: "ready", url: d });
|
|
2140
|
+
},
|
|
2141
|
+
(d) => {
|
|
2142
|
+
o || r({ status: "unavailable", reason: String(d) });
|
|
2143
|
+
}
|
|
2144
|
+
), () => {
|
|
2145
|
+
o = !0;
|
|
2146
|
+
};
|
|
2147
|
+
}
|
|
2148
|
+
if (c === void 0) {
|
|
2149
|
+
r({ status: "unavailable", reason: "Set your app's URL scheme to build a link." });
|
|
2150
|
+
return;
|
|
2151
|
+
}
|
|
2152
|
+
r({
|
|
2153
|
+
status: "ready",
|
|
2154
|
+
url: Be(c, e.networkOrigin ?? window.location.origin, t.id)
|
|
2155
|
+
});
|
|
2156
|
+
}
|
|
2157
|
+
}, [a, n, c, e, t]), /* @__PURE__ */ f(G, { children: [
|
|
2158
|
+
/* @__PURE__ */ s("button", { className: "sw-btn", type: "button", onClick: () => l(!0), children: "Preview" }),
|
|
2159
|
+
a && /* @__PURE__ */ s(
|
|
2160
|
+
"div",
|
|
2161
|
+
{
|
|
2162
|
+
className: "fixed inset-0 z-50 flex items-center justify-center bg-ink/80 p-6",
|
|
2163
|
+
role: "dialog",
|
|
2164
|
+
"aria-modal": "true",
|
|
2165
|
+
"aria-label": "Preview on a device",
|
|
2166
|
+
onClick: () => l(!1),
|
|
2167
|
+
children: /* @__PURE__ */ f(
|
|
2168
|
+
"div",
|
|
2169
|
+
{
|
|
2170
|
+
className: "bg-bar flex w-[22rem] max-w-full flex-col items-center gap-4 rounded border border-cream/10 p-6 text-center",
|
|
2171
|
+
onClick: (i) => i.stopPropagation(),
|
|
2172
|
+
children: [
|
|
2173
|
+
/* @__PURE__ */ f("div", { className: "flex flex-col gap-1", children: [
|
|
2174
|
+
/* @__PURE__ */ s("span", { className: "text-[0.9375rem] font-medium", children: "Preview on a device" }),
|
|
2175
|
+
/* @__PURE__ */ s("span", { className: "text-[0.8125rem] text-cream/55", children: n ? "Scan with the device that has your app installed. It opens the live paywall in the SDK's debugger." : "Scan with the device that has your app installed. It opens this paywall against this machine's dev server." })
|
|
2176
|
+
] }),
|
|
2177
|
+
p.status === "ready" ? /* @__PURE__ */ f(G, { children: [
|
|
2178
|
+
/* @__PURE__ */ s("div", { className: "bg-cream rounded p-3", children: /* @__PURE__ */ s(Ut, { value: p.url, size: 192 }) }),
|
|
2179
|
+
/* @__PURE__ */ s("code", { className: "max-w-full font-mono text-[0.6875rem] break-all text-cream/55", children: p.url })
|
|
2180
|
+
] }) : /* @__PURE__ */ s("div", { className: "flex size-[216px] flex-none items-center justify-center rounded border border-cream/20 px-6 text-center text-[0.8125rem] text-cream/55", children: p.status === "loading" ? "Building a link…" : p.reason }),
|
|
2181
|
+
/* @__PURE__ */ f("div", { className: "flex items-center gap-2", children: [
|
|
2182
|
+
!n && /* @__PURE__ */ s(
|
|
2183
|
+
"button",
|
|
2184
|
+
{
|
|
2185
|
+
className: "sw-btn",
|
|
2186
|
+
type: "button",
|
|
2187
|
+
onClick: () => {
|
|
2188
|
+
const i = Hr(c ?? "");
|
|
2189
|
+
i !== void 0 && h(i);
|
|
2190
|
+
},
|
|
2191
|
+
children: c === void 0 ? "Set URL scheme" : "Edit URL scheme"
|
|
2192
|
+
}
|
|
2193
|
+
),
|
|
2194
|
+
/* @__PURE__ */ s("button", { className: "sw-btn", type: "button", onClick: () => l(!1), children: "Done" })
|
|
2195
|
+
] })
|
|
2196
|
+
]
|
|
2197
|
+
}
|
|
2198
|
+
)
|
|
2199
|
+
}
|
|
2200
|
+
)
|
|
2201
|
+
] });
|
|
2202
|
+
}, Qr = ({
|
|
1122
2203
|
value: e,
|
|
1123
2204
|
options: t,
|
|
1124
|
-
onChange:
|
|
1125
|
-
label:
|
|
1126
|
-
}) => /* @__PURE__ */
|
|
2205
|
+
onChange: n,
|
|
2206
|
+
label: a
|
|
2207
|
+
}) => /* @__PURE__ */ s("div", { className: "sw-segmented", role: "group", "aria-label": a, children: t.map((l) => /* @__PURE__ */ s(
|
|
1127
2208
|
"button",
|
|
1128
2209
|
{
|
|
1129
2210
|
type: "button",
|
|
1130
|
-
"aria-pressed":
|
|
1131
|
-
onClick: () =>
|
|
1132
|
-
children:
|
|
2211
|
+
"aria-pressed": l.value === e,
|
|
2212
|
+
onClick: () => n(l.value),
|
|
2213
|
+
children: l.label
|
|
1133
2214
|
},
|
|
1134
|
-
|
|
1135
|
-
)) }),
|
|
2215
|
+
l.value
|
|
2216
|
+
)) }), rt = ({
|
|
1136
2217
|
value: e,
|
|
1137
2218
|
options: t,
|
|
1138
|
-
onChange:
|
|
1139
|
-
label:
|
|
1140
|
-
}) => /* @__PURE__ */
|
|
2219
|
+
onChange: n,
|
|
2220
|
+
label: a
|
|
2221
|
+
}) => /* @__PURE__ */ s(
|
|
1141
2222
|
"select",
|
|
1142
2223
|
{
|
|
1143
2224
|
className: "sw-select",
|
|
1144
|
-
"aria-label":
|
|
2225
|
+
"aria-label": a,
|
|
1145
2226
|
value: e,
|
|
1146
|
-
onChange: (
|
|
1147
|
-
children: t.map((
|
|
2227
|
+
onChange: (l) => n(l.target.value),
|
|
2228
|
+
children: t.map((l) => /* @__PURE__ */ s("option", { value: l.value, children: l.label }, l.value))
|
|
1148
2229
|
}
|
|
1149
|
-
),
|
|
2230
|
+
), Wr = ({
|
|
1150
2231
|
checked: e,
|
|
1151
2232
|
onChange: t,
|
|
1152
|
-
label:
|
|
1153
|
-
}) => /* @__PURE__ */
|
|
2233
|
+
label: n
|
|
2234
|
+
}) => /* @__PURE__ */ s(
|
|
1154
2235
|
"button",
|
|
1155
2236
|
{
|
|
1156
2237
|
type: "button",
|
|
1157
2238
|
role: "switch",
|
|
1158
2239
|
"aria-checked": e,
|
|
1159
|
-
"aria-label":
|
|
2240
|
+
"aria-label": n,
|
|
1160
2241
|
className: "sw-switch",
|
|
1161
2242
|
onClick: () => t(!e)
|
|
1162
2243
|
}
|
|
1163
|
-
),
|
|
2244
|
+
), Gr = ({
|
|
1164
2245
|
open: e,
|
|
1165
2246
|
title: t,
|
|
1166
|
-
onClose:
|
|
1167
|
-
children:
|
|
1168
|
-
}) => /* @__PURE__ */
|
|
2247
|
+
onClose: n,
|
|
2248
|
+
children: a
|
|
2249
|
+
}) => /* @__PURE__ */ s(
|
|
1169
2250
|
"aside",
|
|
1170
2251
|
{
|
|
1171
2252
|
className: `flex-none overflow-hidden transition-[width] duration-200 ease-out motion-reduce:transition-none ${e ? "w-72" : "w-0"}`,
|
|
1172
2253
|
"aria-hidden": !e,
|
|
1173
2254
|
inert: !e,
|
|
1174
|
-
children: /* @__PURE__ */
|
|
1175
|
-
/* @__PURE__ */
|
|
1176
|
-
/* @__PURE__ */
|
|
1177
|
-
/* @__PURE__ */
|
|
2255
|
+
children: /* @__PURE__ */ f("div", { className: "bg-bar flex h-full w-72 flex-col border-l border-cream/10", children: [
|
|
2256
|
+
/* @__PURE__ */ f("div", { className: "flex h-11 flex-none items-center justify-between border-b border-cream/10 px-3", children: [
|
|
2257
|
+
/* @__PURE__ */ s("span", { className: "text-[0.8125rem] font-medium text-cream", children: t }),
|
|
2258
|
+
/* @__PURE__ */ s(
|
|
1178
2259
|
"button",
|
|
1179
2260
|
{
|
|
1180
2261
|
type: "button",
|
|
1181
2262
|
className: "sw-btn sw-btn--icon border-transparent",
|
|
1182
2263
|
"aria-label": `Close ${t.toLowerCase()}`,
|
|
1183
|
-
onClick:
|
|
1184
|
-
children: /* @__PURE__ */
|
|
2264
|
+
onClick: n,
|
|
2265
|
+
children: /* @__PURE__ */ s(vt, {})
|
|
1185
2266
|
}
|
|
1186
2267
|
)
|
|
1187
2268
|
] }),
|
|
1188
|
-
/* @__PURE__ */
|
|
2269
|
+
/* @__PURE__ */ s("div", { className: "flex-1 overflow-y-auto px-4 py-2", children: a })
|
|
1189
2270
|
] })
|
|
1190
2271
|
}
|
|
1191
|
-
),
|
|
1192
|
-
/* @__PURE__ */
|
|
2272
|
+
), Kr = ({ children: e }) => /* @__PURE__ */ s("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 }), ue = ({ label: e, children: t }) => /* @__PURE__ */ f("div", { className: "flex items-center gap-2.5", children: [
|
|
2273
|
+
/* @__PURE__ */ s("span", { className: "sw-tool-label", children: e }),
|
|
1193
2274
|
t
|
|
1194
|
-
] }),
|
|
1195
|
-
const e = d.useContext(ct);
|
|
1196
|
-
if (!e)
|
|
1197
|
-
throw new Error("Studio components must be rendered inside <StudioHostProvider>.");
|
|
1198
|
-
return e;
|
|
1199
|
-
}, na = ({
|
|
1200
|
-
mode: e,
|
|
1201
|
-
home: t,
|
|
1202
|
-
children: a
|
|
1203
|
-
}) => {
|
|
1204
|
-
const { href: r, navigate: s } = t, i = d.useMemo(
|
|
1205
|
-
() => ({ mode: e, home: { href: r, navigate: s } }),
|
|
1206
|
-
[e, r, s]
|
|
1207
|
-
);
|
|
1208
|
-
return /* @__PURE__ */ n(ct.Provider, { value: i, children: a });
|
|
1209
|
-
}, aa = () => dt().mode, ra = () => dt().home, pt = ({
|
|
2275
|
+
] }), st = () => /* @__PURE__ */ s("span", { className: "h-6 w-px bg-cream/10" }), Ht = ({
|
|
1210
2276
|
title: e,
|
|
1211
2277
|
actions: t,
|
|
1212
|
-
inset:
|
|
1213
|
-
label:
|
|
2278
|
+
inset: n = !1,
|
|
2279
|
+
label: a = "Studio"
|
|
1214
2280
|
}) => {
|
|
1215
|
-
const
|
|
1216
|
-
return /* @__PURE__ */
|
|
2281
|
+
const l = Rr();
|
|
2282
|
+
return /* @__PURE__ */ s("header", { className: "relative z-10 flex h-11 flex-none items-center border-b border-cream/10 bg-ink", children: /* @__PURE__ */ f(
|
|
1217
2283
|
"div",
|
|
1218
2284
|
{
|
|
1219
|
-
className: `flex h-full w-full items-center px-3 ${
|
|
2285
|
+
className: `flex h-full w-full items-center px-3 ${n ? "mx-auto max-w-[1080px] sm:px-0" : ""}`,
|
|
1220
2286
|
children: [
|
|
1221
|
-
/* @__PURE__ */
|
|
2287
|
+
/* @__PURE__ */ f(
|
|
1222
2288
|
"a",
|
|
1223
2289
|
{
|
|
1224
2290
|
className: "flex items-center gap-3 text-[0.9375rem] font-semibold tracking-[0.01em]",
|
|
1225
|
-
href:
|
|
1226
|
-
onClick: (
|
|
1227
|
-
|
|
2291
|
+
href: l.href,
|
|
2292
|
+
onClick: (c) => {
|
|
2293
|
+
c.button === 0 && (c.metaKey || c.ctrlKey || c.shiftKey || c.altKey || (c.preventDefault(), l.navigate()));
|
|
1228
2294
|
},
|
|
1229
2295
|
children: [
|
|
1230
|
-
/* @__PURE__ */
|
|
1231
|
-
/* @__PURE__ */
|
|
2296
|
+
/* @__PURE__ */ f("span", { className: "whitespace-nowrap", children: [
|
|
2297
|
+
/* @__PURE__ */ s("em", { className: "text-accent not-italic", children: "$UPER" }),
|
|
1232
2298
|
"WALL"
|
|
1233
2299
|
] }),
|
|
1234
|
-
/* @__PURE__ */
|
|
1235
|
-
/* @__PURE__ */
|
|
2300
|
+
/* @__PURE__ */ s("span", { className: "h-4 w-px bg-cream/20" }),
|
|
2301
|
+
/* @__PURE__ */ s("span", { className: "font-normal", children: a })
|
|
1236
2302
|
]
|
|
1237
2303
|
}
|
|
1238
2304
|
),
|
|
1239
|
-
/* @__PURE__ */
|
|
1240
|
-
/* @__PURE__ */
|
|
2305
|
+
/* @__PURE__ */ s("span", { className: "absolute left-1/2 hidden -translate-x-1/2 text-sm font-medium whitespace-nowrap sm:block", children: e }),
|
|
2306
|
+
/* @__PURE__ */ s("div", { className: "ml-auto flex items-center gap-2", children: t })
|
|
1241
2307
|
]
|
|
1242
2308
|
}
|
|
1243
2309
|
) });
|
|
1244
|
-
},
|
|
2310
|
+
}, Yr = [
|
|
1245
2311
|
{ key: "user", label: "User", blurb: "Attributes your app sets" },
|
|
1246
2312
|
{ key: "device", label: "Device", blurb: "Platform, locale, OS — the SDK fills these in" },
|
|
1247
2313
|
{ key: "params", label: "Params", blurb: "Passed in at the placement" },
|
|
1248
2314
|
{ key: "products", label: "Products", blurb: "Store data for this paywall's products" }
|
|
1249
|
-
],
|
|
2315
|
+
], at = (e) => e == null ? "" : typeof e == "string" ? e : JSON.stringify(e), qr = (e) => e === "true" ? !0 : e === "false" ? !1 : e.trim() !== "" && Number.isFinite(Number(e)) ? Number(e) : e, Re = (e) => e.slice(e.indexOf(".") + 1), Jr = ({
|
|
1250
2316
|
row: e,
|
|
1251
2317
|
override: t,
|
|
1252
|
-
onChange:
|
|
2318
|
+
onChange: n
|
|
1253
2319
|
}) => {
|
|
1254
|
-
const
|
|
1255
|
-
return /* @__PURE__ */
|
|
1256
|
-
/* @__PURE__ */
|
|
1257
|
-
/* @__PURE__ */
|
|
1258
|
-
|
|
2320
|
+
const a = t !== void 0, l = a ? t : e.value;
|
|
2321
|
+
return /* @__PURE__ */ f("div", { className: "flex flex-col gap-1 py-1.5", children: [
|
|
2322
|
+
/* @__PURE__ */ f("div", { className: "flex items-baseline justify-between gap-2", children: [
|
|
2323
|
+
/* @__PURE__ */ s("span", { className: "truncate font-mono text-[11px] text-cream/70", children: e.path }),
|
|
2324
|
+
a && /* @__PURE__ */ s(
|
|
1259
2325
|
"button",
|
|
1260
2326
|
{
|
|
1261
2327
|
type: "button",
|
|
1262
2328
|
className: "shrink-0 text-[11px] text-cream/40 hover:text-cream",
|
|
1263
2329
|
"aria-label": `Reset ${e.path}`,
|
|
1264
|
-
onClick: () =>
|
|
2330
|
+
onClick: () => n(void 0),
|
|
1265
2331
|
children: "Reset"
|
|
1266
2332
|
}
|
|
1267
2333
|
)
|
|
1268
2334
|
] }),
|
|
1269
|
-
typeof
|
|
2335
|
+
typeof l == "boolean" ? /* @__PURE__ */ s("span", { className: "flex h-7 items-center", children: /* @__PURE__ */ s(
|
|
1270
2336
|
"button",
|
|
1271
2337
|
{
|
|
1272
2338
|
type: "button",
|
|
1273
2339
|
className: "sw-switch",
|
|
1274
2340
|
role: "switch",
|
|
1275
|
-
"aria-checked":
|
|
2341
|
+
"aria-checked": l,
|
|
1276
2342
|
"aria-label": e.path,
|
|
1277
|
-
onClick: () =>
|
|
2343
|
+
onClick: () => n(!l)
|
|
1278
2344
|
}
|
|
1279
|
-
) }) : /* @__PURE__ */
|
|
2345
|
+
) }) : /* @__PURE__ */ s(
|
|
1280
2346
|
"input",
|
|
1281
2347
|
{
|
|
1282
2348
|
className: "sw-input w-full",
|
|
1283
2349
|
"aria-label": e.path,
|
|
1284
|
-
value:
|
|
1285
|
-
placeholder:
|
|
1286
|
-
onChange: (
|
|
1287
|
-
const
|
|
1288
|
-
|
|
2350
|
+
value: at(l),
|
|
2351
|
+
placeholder: at(e.value),
|
|
2352
|
+
onChange: (c) => {
|
|
2353
|
+
const h = c.target.value;
|
|
2354
|
+
n(h === "" ? void 0 : qr(h));
|
|
1289
2355
|
}
|
|
1290
2356
|
}
|
|
1291
2357
|
)
|
|
1292
2358
|
] });
|
|
1293
|
-
},
|
|
2359
|
+
}, Xr = ({
|
|
1294
2360
|
label: e,
|
|
1295
2361
|
blurb: t,
|
|
1296
|
-
rows:
|
|
1297
|
-
overrideOf:
|
|
1298
|
-
onChange:
|
|
2362
|
+
rows: n,
|
|
2363
|
+
overrideOf: a,
|
|
2364
|
+
onChange: l
|
|
1299
2365
|
}) => {
|
|
1300
|
-
const [
|
|
1301
|
-
return /* @__PURE__ */
|
|
1302
|
-
/* @__PURE__ */
|
|
2366
|
+
const [c, h] = w.useState(!1), p = n.filter((r) => a(r.path) !== void 0).length;
|
|
2367
|
+
return /* @__PURE__ */ f("section", { className: "border-b border-cream/10 last:border-b-0", children: [
|
|
2368
|
+
/* @__PURE__ */ f(
|
|
1303
2369
|
"button",
|
|
1304
2370
|
{
|
|
1305
2371
|
type: "button",
|
|
1306
2372
|
className: "flex w-full items-center gap-2 py-3 text-left",
|
|
1307
|
-
"aria-expanded":
|
|
1308
|
-
onClick: () =>
|
|
2373
|
+
"aria-expanded": c,
|
|
2374
|
+
onClick: () => h((r) => !r),
|
|
1309
2375
|
children: [
|
|
1310
|
-
/* @__PURE__ */
|
|
1311
|
-
/* @__PURE__ */
|
|
1312
|
-
/* @__PURE__ */
|
|
1313
|
-
/* @__PURE__ */
|
|
2376
|
+
/* @__PURE__ */ f("span", { className: "flex min-w-0 flex-col gap-0.5", children: [
|
|
2377
|
+
/* @__PURE__ */ f("span", { className: "flex items-baseline gap-2", children: [
|
|
2378
|
+
/* @__PURE__ */ s("span", { className: "text-[0.8125rem] font-medium text-cream", children: e }),
|
|
2379
|
+
/* @__PURE__ */ s("span", { className: "text-xs text-cream/40", children: p > 0 ? /* @__PURE__ */ s("span", { className: "text-accent", children: `${p} set` }) : n.length || null })
|
|
1314
2380
|
] }),
|
|
1315
|
-
/* @__PURE__ */
|
|
2381
|
+
/* @__PURE__ */ s("span", { className: "truncate text-xs text-cream/55", children: t })
|
|
1316
2382
|
] }),
|
|
1317
|
-
/* @__PURE__ */
|
|
2383
|
+
/* @__PURE__ */ s(
|
|
1318
2384
|
"span",
|
|
1319
2385
|
{
|
|
1320
|
-
className: `ml-auto shrink-0 text-cream/40 transition-transform ${
|
|
2386
|
+
className: `ml-auto shrink-0 text-cream/40 transition-transform ${c ? "" : "-rotate-90"}`,
|
|
1321
2387
|
"aria-hidden": "true",
|
|
1322
|
-
children: /* @__PURE__ */
|
|
2388
|
+
children: /* @__PURE__ */ s(yt, {})
|
|
1323
2389
|
}
|
|
1324
2390
|
)
|
|
1325
2391
|
]
|
|
1326
2392
|
}
|
|
1327
2393
|
),
|
|
1328
|
-
|
|
1329
|
-
|
|
2394
|
+
c && (n.length === 0 ? /* @__PURE__ */ s("span", { className: "block pb-3 text-xs text-cream/35", children: "Nothing here for this paywall." }) : /* @__PURE__ */ s("div", { className: "flex flex-col pb-2", children: n.map((r) => /* @__PURE__ */ s(
|
|
2395
|
+
Jr,
|
|
1330
2396
|
{
|
|
1331
|
-
row:
|
|
1332
|
-
override: r
|
|
1333
|
-
onChange: (
|
|
2397
|
+
row: r,
|
|
2398
|
+
override: a(r.path),
|
|
2399
|
+
onChange: (i) => l(r.path, i)
|
|
1334
2400
|
},
|
|
1335
|
-
|
|
2401
|
+
r.path
|
|
1336
2402
|
)) }))
|
|
1337
2403
|
] });
|
|
1338
|
-
},
|
|
2404
|
+
}, Zr = ({
|
|
1339
2405
|
overrides: e,
|
|
1340
2406
|
groups: t,
|
|
1341
|
-
onChange:
|
|
2407
|
+
onChange: n
|
|
1342
2408
|
}) => {
|
|
1343
|
-
const
|
|
1344
|
-
if (
|
|
1345
|
-
const
|
|
1346
|
-
|
|
2409
|
+
const a = (l, c, h) => {
|
|
2410
|
+
if (l !== "products") {
|
|
2411
|
+
const d = { ...e[l] };
|
|
2412
|
+
h === void 0 ? delete d[Re(c)] : d[Re(c)] = h, n({ ...e, [l]: d });
|
|
1347
2413
|
return;
|
|
1348
2414
|
}
|
|
1349
|
-
const [, p = "",
|
|
1350
|
-
|
|
1351
|
-
const
|
|
1352
|
-
Object.keys(
|
|
2415
|
+
const [, p = "", r = ""] = c.split("."), i = { ...e.products?.[p] };
|
|
2416
|
+
h === void 0 ? delete i[r] : i[r] = h;
|
|
2417
|
+
const o = { ...e.products, [p]: i };
|
|
2418
|
+
Object.keys(i).length === 0 && delete o[p], n({ ...e, products: o });
|
|
1353
2419
|
};
|
|
1354
|
-
return /* @__PURE__ */
|
|
1355
|
-
|
|
2420
|
+
return /* @__PURE__ */ s("div", { className: "flex flex-col", children: Yr.map((l) => /* @__PURE__ */ s(
|
|
2421
|
+
Xr,
|
|
1356
2422
|
{
|
|
1357
|
-
label:
|
|
1358
|
-
blurb:
|
|
1359
|
-
rows: t[
|
|
1360
|
-
overrideOf: (
|
|
1361
|
-
onChange: (
|
|
2423
|
+
label: l.label,
|
|
2424
|
+
blurb: l.blurb,
|
|
2425
|
+
rows: t[l.key] ?? [],
|
|
2426
|
+
overrideOf: (c) => l.key === "products" ? e.products?.[c.split(".")[1] ?? ""]?.[c.split(".")[2] ?? ""] : e[l.key]?.[Re(c)],
|
|
2427
|
+
onChange: (c, h) => a(l.key, c, h)
|
|
1362
2428
|
},
|
|
1363
|
-
|
|
2429
|
+
l.key
|
|
1364
2430
|
)) });
|
|
1365
|
-
},
|
|
1366
|
-
try {
|
|
1367
|
-
const r = await fetch("/__studio/action", {
|
|
1368
|
-
method: "POST",
|
|
1369
|
-
headers: { "Content-Type": "application/json" },
|
|
1370
|
-
body: JSON.stringify({
|
|
1371
|
-
action: t,
|
|
1372
|
-
kind: e.kind,
|
|
1373
|
-
id: e.id,
|
|
1374
|
-
project: e.project
|
|
1375
|
-
})
|
|
1376
|
-
});
|
|
1377
|
-
if (!r.body)
|
|
1378
|
-
return await r.json();
|
|
1379
|
-
const s = r.body.getReader(), i = new TextDecoder();
|
|
1380
|
-
let o = "", p;
|
|
1381
|
-
const c = (h) => {
|
|
1382
|
-
if (!h.trim()) return;
|
|
1383
|
-
const m = JSON.parse(h);
|
|
1384
|
-
m.result ? p = m.result : m.step && m.state && a?.(m.step, m.state);
|
|
1385
|
-
};
|
|
1386
|
-
for (; ; ) {
|
|
1387
|
-
const { done: h, value: m } = await s.read();
|
|
1388
|
-
if (h) break;
|
|
1389
|
-
o += i.decode(m, { stream: !0 });
|
|
1390
|
-
const b = o.split(`
|
|
1391
|
-
`);
|
|
1392
|
-
o = b.pop() ?? "";
|
|
1393
|
-
for (const u of b) c(u);
|
|
1394
|
-
}
|
|
1395
|
-
return c(o), p ?? { ok: !1, error: "The dev server closed without a result." };
|
|
1396
|
-
} catch (r) {
|
|
1397
|
-
return { ok: !1, error: r instanceof Error ? r.message : String(r) };
|
|
1398
|
-
}
|
|
1399
|
-
}, Ne = async (e) => {
|
|
1400
|
-
try {
|
|
1401
|
-
return await (await fetch(`/__studio/status${O(e)}`)).json();
|
|
1402
|
-
} catch (t) {
|
|
1403
|
-
return { unreachable: t instanceof Error ? t.message : String(t) };
|
|
1404
|
-
}
|
|
1405
|
-
}, pa = async () => {
|
|
1406
|
-
try {
|
|
1407
|
-
const t = await (await fetch("/__studio/samples.json")).json();
|
|
1408
|
-
return typeof t == "object" && t !== null ? t : {};
|
|
1409
|
-
} catch (e) {
|
|
1410
|
-
return { unreachable: e instanceof Error ? e.message : String(e) };
|
|
1411
|
-
}
|
|
1412
|
-
}, ve = {
|
|
2431
|
+
}, Oe = {
|
|
1413
2432
|
radius: 54,
|
|
1414
2433
|
cutout: "island",
|
|
1415
2434
|
statusBarHeight: 64,
|
|
1416
2435
|
homeIndicator: !0
|
|
1417
|
-
},
|
|
2436
|
+
}, ge = [
|
|
1418
2437
|
{
|
|
1419
2438
|
id: "iphone-se",
|
|
1420
2439
|
name: "iPhone SE",
|
|
@@ -1429,7 +2448,7 @@ const K = (e, t, a, r) => new Promise((s) => {
|
|
|
1429
2448
|
width: 402,
|
|
1430
2449
|
height: 874,
|
|
1431
2450
|
device: { platform: "iOS", deviceModel: "iPhone18,3", osVersion: "26.0" },
|
|
1432
|
-
chrome:
|
|
2451
|
+
chrome: Oe
|
|
1433
2452
|
},
|
|
1434
2453
|
{
|
|
1435
2454
|
id: "iphone-air",
|
|
@@ -1437,7 +2456,7 @@ const K = (e, t, a, r) => new Promise((s) => {
|
|
|
1437
2456
|
width: 420,
|
|
1438
2457
|
height: 912,
|
|
1439
2458
|
device: { platform: "iOS", deviceModel: "iPhone18,4", osVersion: "26.0" },
|
|
1440
|
-
chrome:
|
|
2459
|
+
chrome: Oe
|
|
1441
2460
|
},
|
|
1442
2461
|
{
|
|
1443
2462
|
id: "iphone-17-pro-max",
|
|
@@ -1445,7 +2464,7 @@ const K = (e, t, a, r) => new Promise((s) => {
|
|
|
1445
2464
|
width: 440,
|
|
1446
2465
|
height: 956,
|
|
1447
2466
|
device: { platform: "iOS", deviceModel: "iPhone18,2", osVersion: "26.0" },
|
|
1448
|
-
chrome:
|
|
2467
|
+
chrome: Oe
|
|
1449
2468
|
},
|
|
1450
2469
|
{
|
|
1451
2470
|
id: "pixel-10",
|
|
@@ -1485,183 +2504,183 @@ const K = (e, t, a, r) => new Promise((s) => {
|
|
|
1485
2504
|
width: 1440,
|
|
1486
2505
|
height: 900
|
|
1487
2506
|
}
|
|
1488
|
-
],
|
|
1489
|
-
device:
|
|
1490
|
-
user:
|
|
1491
|
-
params:
|
|
1492
|
-
}),
|
|
2507
|
+
], Vt = "iphone-17", ot = "responsive", es = { width: 393, height: 852 }, ts = ge.find((e) => e.id === Vt) ?? ge[0], ns = (e) => ge.find((t) => t.id === e) ?? ts, Qt = () => ({
|
|
2508
|
+
device: An(),
|
|
2509
|
+
user: Tn,
|
|
2510
|
+
params: Ln
|
|
2511
|
+
}), Wt = ({
|
|
1493
2512
|
surface: e,
|
|
1494
2513
|
defaults: t,
|
|
1495
|
-
sourceSamples:
|
|
1496
|
-
samples:
|
|
1497
|
-
frame:
|
|
1498
|
-
theme:
|
|
1499
|
-
locale:
|
|
2514
|
+
sourceSamples: n,
|
|
2515
|
+
samples: a,
|
|
2516
|
+
frame: l,
|
|
2517
|
+
theme: c,
|
|
2518
|
+
locale: h,
|
|
1500
2519
|
edited: p
|
|
1501
2520
|
}) => {
|
|
1502
|
-
const
|
|
2521
|
+
const r = {
|
|
1503
2522
|
...t.device,
|
|
1504
|
-
...
|
|
1505
|
-
...
|
|
1506
|
-
...
|
|
1507
|
-
interfaceStyle:
|
|
1508
|
-
...
|
|
2523
|
+
...n?.device,
|
|
2524
|
+
...a.device,
|
|
2525
|
+
...l,
|
|
2526
|
+
interfaceStyle: c === "dark" ? "Dark" : "Light",
|
|
2527
|
+
...h ? { deviceLocale: h, deviceLanguageCode: h.split(/[-_]/)[0] } : {},
|
|
1509
2528
|
...p.device
|
|
1510
|
-
},
|
|
2529
|
+
}, i = {
|
|
1511
2530
|
...t.user,
|
|
1512
|
-
...
|
|
1513
|
-
...
|
|
2531
|
+
...n?.user,
|
|
2532
|
+
...a.user,
|
|
1514
2533
|
...p.user
|
|
1515
|
-
},
|
|
2534
|
+
}, o = {
|
|
1516
2535
|
...t.params,
|
|
1517
|
-
...
|
|
2536
|
+
...n?.params,
|
|
1518
2537
|
...p.params
|
|
1519
|
-
},
|
|
1520
|
-
([u,
|
|
2538
|
+
}, d = Object.entries(e.products ?? {}).map(
|
|
2539
|
+
([u, m]) => ({
|
|
1521
2540
|
reference: u,
|
|
1522
|
-
productId:
|
|
2541
|
+
productId: m,
|
|
1523
2542
|
variables: {
|
|
1524
|
-
...
|
|
2543
|
+
...a.products?.[m],
|
|
1525
2544
|
...p.products?.[u]
|
|
1526
2545
|
}
|
|
1527
2546
|
})
|
|
1528
2547
|
);
|
|
1529
|
-
return
|
|
2548
|
+
return ut({
|
|
1530
2549
|
paywallId: e.paywallId ?? "0",
|
|
1531
2550
|
paywallIdentifier: e.paywallIdentifier ?? e.id,
|
|
1532
|
-
device:
|
|
1533
|
-
user:
|
|
1534
|
-
params:
|
|
1535
|
-
products:
|
|
2551
|
+
device: r,
|
|
2552
|
+
user: i,
|
|
2553
|
+
params: o,
|
|
2554
|
+
products: d,
|
|
1536
2555
|
introductoryOfferEligible: p.introductoryOfferEligible
|
|
1537
2556
|
});
|
|
1538
|
-
},
|
|
2557
|
+
}, Gt = (e) => e.capabilities?.actions === !0, rs = (e, t) => Number.isFinite(e) ? Math.min(3e3, Math.max(200, Math.round(e))) : t, it = ({
|
|
1539
2558
|
label: e,
|
|
1540
2559
|
value: t,
|
|
1541
|
-
onCommit:
|
|
2560
|
+
onCommit: n
|
|
1542
2561
|
}) => {
|
|
1543
|
-
const [
|
|
1544
|
-
return
|
|
1545
|
-
|
|
1546
|
-
}, [t]), /* @__PURE__ */
|
|
2562
|
+
const [a, l] = w.useState(String(t));
|
|
2563
|
+
return w.useEffect(() => {
|
|
2564
|
+
l(String(t));
|
|
2565
|
+
}, [t]), /* @__PURE__ */ s(
|
|
1547
2566
|
"input",
|
|
1548
2567
|
{
|
|
1549
2568
|
className: "sw-input w-16 text-center",
|
|
1550
2569
|
type: "number",
|
|
1551
2570
|
"aria-label": e,
|
|
1552
|
-
value:
|
|
1553
|
-
onChange: (
|
|
2571
|
+
value: a,
|
|
2572
|
+
onChange: (h) => l(h.target.value),
|
|
1554
2573
|
onBlur: () => {
|
|
1555
|
-
const
|
|
1556
|
-
|
|
2574
|
+
const h = rs(Number(a), t);
|
|
2575
|
+
l(String(h)), n(h);
|
|
1557
2576
|
},
|
|
1558
|
-
onKeyDown: (
|
|
1559
|
-
|
|
2577
|
+
onKeyDown: (h) => {
|
|
2578
|
+
h.key === "Enter" && h.target.blur();
|
|
1560
2579
|
}
|
|
1561
2580
|
}
|
|
1562
2581
|
);
|
|
1563
|
-
},
|
|
2582
|
+
}, lt = ({
|
|
1564
2583
|
label: e,
|
|
1565
2584
|
width: t,
|
|
1566
|
-
height:
|
|
1567
|
-
title:
|
|
1568
|
-
src:
|
|
1569
|
-
hostState:
|
|
1570
|
-
delegate:
|
|
2585
|
+
height: n,
|
|
2586
|
+
title: a,
|
|
2587
|
+
src: l,
|
|
2588
|
+
hostState: c,
|
|
2589
|
+
delegate: h,
|
|
1571
2590
|
reloadKey: p,
|
|
1572
|
-
empty:
|
|
1573
|
-
chrome:
|
|
1574
|
-
landscape:
|
|
1575
|
-
theme:
|
|
2591
|
+
empty: r,
|
|
2592
|
+
chrome: i,
|
|
2593
|
+
landscape: o,
|
|
2594
|
+
theme: d
|
|
1576
2595
|
}) => {
|
|
1577
|
-
const u =
|
|
1578
|
-
return /* @__PURE__ */
|
|
1579
|
-
e && /* @__PURE__ */
|
|
1580
|
-
|
|
1581
|
-
|
|
2596
|
+
const u = w.useRef(null);
|
|
2597
|
+
return /* @__PURE__ */ s("div", { className: "flex min-h-0 min-w-0 flex-1 flex-col items-center justify-center", ref: u, children: /* @__PURE__ */ f("div", { className: "flex flex-col gap-2", children: [
|
|
2598
|
+
e && /* @__PURE__ */ s("span", { className: "text-xs text-cream/55", children: e }),
|
|
2599
|
+
l ? /* @__PURE__ */ s(
|
|
2600
|
+
nr,
|
|
1582
2601
|
{
|
|
1583
2602
|
width: t,
|
|
1584
|
-
height:
|
|
1585
|
-
title:
|
|
1586
|
-
src:
|
|
1587
|
-
hostState:
|
|
1588
|
-
delegate:
|
|
2603
|
+
height: n,
|
|
2604
|
+
title: a,
|
|
2605
|
+
src: l,
|
|
2606
|
+
hostState: c,
|
|
2607
|
+
delegate: h,
|
|
1589
2608
|
stageRef: u,
|
|
1590
2609
|
reloadKey: p,
|
|
1591
|
-
chrome:
|
|
1592
|
-
landscape:
|
|
1593
|
-
theme:
|
|
2610
|
+
chrome: i,
|
|
2611
|
+
landscape: o,
|
|
2612
|
+
theme: d
|
|
1594
2613
|
}
|
|
1595
|
-
) : /* @__PURE__ */
|
|
2614
|
+
) : /* @__PURE__ */ s(tr, { width: t, height: n, stageRef: u, children: r ?? "Nothing live yet — publish to compare against production." })
|
|
1596
2615
|
] }) });
|
|
1597
|
-
},
|
|
2616
|
+
}, Ae = (e) => e.label ?? `${e.kind}/${e.id}`, ss = ({
|
|
1598
2617
|
source: e,
|
|
1599
2618
|
surface: t,
|
|
1600
|
-
samples:
|
|
1601
|
-
actions:
|
|
2619
|
+
samples: n,
|
|
2620
|
+
actions: a
|
|
1602
2621
|
}) => {
|
|
1603
|
-
const [
|
|
1604
|
-
|
|
1605
|
-
const
|
|
1606
|
-
|
|
1607
|
-
if (!
|
|
1608
|
-
let
|
|
1609
|
-
return
|
|
1610
|
-
|
|
2622
|
+
const [l, c] = w.useState(Vt), [h, p] = w.useState(es), [r, i] = w.useState("light"), [o, d] = w.useState(void 0), [u, m] = w.useState({}), [b, x] = w.useState(!1), [v, P] = w.useState(void 0), [E, g] = w.useState(0), [S, C] = w.useState(!1), [B, Z] = w.useState({}), [V, j] = w.useState(void 0), Q = w.useRef(void 0);
|
|
2623
|
+
w.useEffect(() => () => window.clearTimeout(Q.current), []);
|
|
2624
|
+
const R = Gt(e), ae = xr(), z = w.useMemo(Qt, [t]), F = t.locales;
|
|
2625
|
+
w.useEffect(() => {
|
|
2626
|
+
if (!R) return;
|
|
2627
|
+
let y = !1;
|
|
2628
|
+
return De(t).then((I) => {
|
|
2629
|
+
y || Z(I);
|
|
1611
2630
|
}), () => {
|
|
1612
|
-
|
|
2631
|
+
y = !0;
|
|
1613
2632
|
};
|
|
1614
|
-
}, [
|
|
1615
|
-
const
|
|
1616
|
-
window.clearTimeout(
|
|
1617
|
-
const
|
|
1618
|
-
|
|
1619
|
-
(
|
|
1620
|
-
...
|
|
1621
|
-
steps: { ...
|
|
1622
|
-
} :
|
|
2633
|
+
}, [R, t]);
|
|
2634
|
+
const $ = async (y) => {
|
|
2635
|
+
window.clearTimeout(Q.current), j({ action: y, steps: {} });
|
|
2636
|
+
const I = await Er(t, y, (A, L) => {
|
|
2637
|
+
j(
|
|
2638
|
+
(D) => D?.action === y ? {
|
|
2639
|
+
...D,
|
|
2640
|
+
steps: { ...D.steps, [A]: L === "start" ? "active" : "done" }
|
|
2641
|
+
} : D
|
|
1623
2642
|
);
|
|
1624
2643
|
});
|
|
1625
|
-
if (
|
|
1626
|
-
const
|
|
1627
|
-
|
|
2644
|
+
if (I.ok) {
|
|
2645
|
+
const A = Object.fromEntries(
|
|
2646
|
+
be[y].map((L) => [L, "done"])
|
|
1628
2647
|
);
|
|
1629
|
-
|
|
2648
|
+
j({ action: y, steps: A }), Z(await De(t)), Q.current = window.setTimeout(() => j(void 0), 1600);
|
|
1630
2649
|
} else
|
|
1631
|
-
|
|
1632
|
-
if (!
|
|
1633
|
-
const
|
|
1634
|
-
for (const
|
|
1635
|
-
|
|
1636
|
-
return { ...
|
|
2650
|
+
j((A) => {
|
|
2651
|
+
if (!A) return A;
|
|
2652
|
+
const L = { ...A.steps };
|
|
2653
|
+
for (const D of be[y])
|
|
2654
|
+
L[D] === "active" && (L[D] = "failed");
|
|
2655
|
+
return { ...A, steps: L, error: I.error };
|
|
1637
2656
|
});
|
|
1638
|
-
},
|
|
1639
|
-
const
|
|
1640
|
-
if (
|
|
1641
|
-
if (
|
|
1642
|
-
window.open(
|
|
2657
|
+
}, H = l === ot, T = ns(l), Y = H ? h : { width: T.width, height: T.height }, O = S ? { width: Y.height, height: Y.width } : Y, oe = () => {
|
|
2658
|
+
const y = e.standaloneUrl?.(t);
|
|
2659
|
+
if (y === void 0) return;
|
|
2660
|
+
if (O.width > 768) {
|
|
2661
|
+
window.open(y, "_blank");
|
|
1643
2662
|
return;
|
|
1644
2663
|
}
|
|
1645
|
-
const
|
|
2664
|
+
const I = Math.max(0, window.screen.width / 2 - O.width / 2), A = Math.max(0, window.screen.height / 2 - O.height / 2);
|
|
1646
2665
|
window.open(
|
|
1647
|
-
|
|
2666
|
+
y,
|
|
1648
2667
|
"superwall-preview",
|
|
1649
|
-
`toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=${
|
|
1650
|
-
) || window.open(
|
|
1651
|
-
},
|
|
1652
|
-
() =>
|
|
2668
|
+
`toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=${O.width},height=${O.height},top=${A},left=${I}`
|
|
2669
|
+
) || window.open(y, "_blank");
|
|
2670
|
+
}, ee = w.useMemo(
|
|
2671
|
+
() => Wt({
|
|
1653
2672
|
surface: t,
|
|
1654
|
-
defaults:
|
|
2673
|
+
defaults: z,
|
|
1655
2674
|
sourceSamples: e.samples,
|
|
1656
|
-
samples:
|
|
1657
|
-
frame:
|
|
1658
|
-
theme:
|
|
1659
|
-
locale:
|
|
2675
|
+
samples: n,
|
|
2676
|
+
frame: H ? void 0 : T.device,
|
|
2677
|
+
theme: r,
|
|
2678
|
+
locale: o,
|
|
1660
2679
|
edited: u
|
|
1661
2680
|
}),
|
|
1662
|
-
[t,
|
|
1663
|
-
),
|
|
1664
|
-
...
|
|
2681
|
+
[t, z, e.samples, n, H, T.device, r, o, u]
|
|
2682
|
+
), ie = H ? void 0 : T.chrome, Ne = e.previewUrl(t), Se = B.liveUrl ? He(B.liveUrl) : void 0, Qe = [
|
|
2683
|
+
...R ? [
|
|
1665
2684
|
{
|
|
1666
2685
|
key: "live",
|
|
1667
2686
|
label: "Live version",
|
|
@@ -1669,158 +2688,160 @@ const K = (e, t, a, r) => new Promise((s) => {
|
|
|
1669
2688
|
target: { type: "live" }
|
|
1670
2689
|
}
|
|
1671
2690
|
] : [],
|
|
1672
|
-
...e.surfaces.map((
|
|
1673
|
-
key: `surface:${
|
|
1674
|
-
label:
|
|
2691
|
+
...e.surfaces.map((y, I) => ({
|
|
2692
|
+
key: `surface:${I}`,
|
|
2693
|
+
label: Ae(y),
|
|
1675
2694
|
hint: e.compareHint ?? "Local preview",
|
|
1676
|
-
target: { type: "surface", surface:
|
|
1677
|
-
})).filter((
|
|
1678
|
-
],
|
|
2695
|
+
target: { type: "surface", surface: y }
|
|
2696
|
+
})).filter((y) => y.target.surface !== t)
|
|
2697
|
+
], W = v && (v.type === "live" ? {
|
|
1679
2698
|
label: "Live",
|
|
1680
|
-
src:
|
|
2699
|
+
src: Se,
|
|
1681
2700
|
title: `${t.id} live`,
|
|
1682
|
-
empty:
|
|
2701
|
+
empty: B.unreachable ? `Couldn't read the live version — ${B.unreachable}` : void 0
|
|
1683
2702
|
} : {
|
|
1684
|
-
label:
|
|
1685
|
-
src: e.previewUrl(
|
|
1686
|
-
title: `${
|
|
1687
|
-
}),
|
|
1688
|
-
const
|
|
2703
|
+
label: Ae(v.surface),
|
|
2704
|
+
src: e.previewUrl(v.surface),
|
|
2705
|
+
title: `${Ae(v.surface)} preview`
|
|
2706
|
+
}), Kt = w.useMemo(() => {
|
|
2707
|
+
const y = (I, A) => Object.entries(A ?? {}).map(([L, D]) => ({ path: `${I}.${L}`, value: D })).toSorted((L, D) => L.path.localeCompare(D.path));
|
|
1689
2708
|
return {
|
|
1690
|
-
user:
|
|
1691
|
-
device:
|
|
1692
|
-
...
|
|
2709
|
+
user: y("user", { ...z.user, ...e.samples?.user, ...n.user }),
|
|
2710
|
+
device: y("device", {
|
|
2711
|
+
...z.device,
|
|
1693
2712
|
...e.samples?.device,
|
|
1694
|
-
...
|
|
1695
|
-
...
|
|
2713
|
+
...n.device,
|
|
2714
|
+
...T.device
|
|
1696
2715
|
}),
|
|
1697
|
-
params:
|
|
2716
|
+
params: y("params", { ...z.params, ...e.samples?.params }),
|
|
1698
2717
|
products: Object.entries(t.products ?? {}).flatMap(
|
|
1699
|
-
([
|
|
2718
|
+
([I, A]) => y(`products.${I}`, n.products?.[A])
|
|
1700
2719
|
)
|
|
1701
2720
|
};
|
|
1702
|
-
}, [
|
|
1703
|
-
|
|
1704
|
-
const
|
|
1705
|
-
return /* @__PURE__ */
|
|
1706
|
-
/* @__PURE__ */
|
|
1707
|
-
|
|
2721
|
+
}, [z, e.samples, n, T.device, t.products]), le = w.useMemo(() => n.products ? Object.entries(t.products ?? {}).filter(([, y]) => n.products?.[y] === void 0).map(([y, I]) => ({ reference: y, identifier: I })) : [], [n.products, t.products]), [Yt, Ee] = w.useState(!1);
|
|
2722
|
+
w.useEffect(() => Ee(!1), [t]);
|
|
2723
|
+
const Ce = n.unreachable, qt = le.length === 0, We = Object.keys(u.user ?? {}).length + Object.keys(u.params ?? {}).length + Object.keys(u.device ?? {}).length;
|
|
2724
|
+
return /* @__PURE__ */ f(G, { children: [
|
|
2725
|
+
/* @__PURE__ */ s(
|
|
2726
|
+
Nr,
|
|
1708
2727
|
{
|
|
1709
2728
|
surfaceKey: `${t.project ?? ""}/${t.id}`,
|
|
1710
|
-
raised: !!
|
|
2729
|
+
raised: !!Ce
|
|
1711
2730
|
}
|
|
1712
2731
|
),
|
|
1713
|
-
|
|
1714
|
-
|
|
2732
|
+
le.length > 0 && !Yt && /* @__PURE__ */ s(
|
|
2733
|
+
rr,
|
|
1715
2734
|
{
|
|
1716
2735
|
paywall: t.id,
|
|
1717
|
-
missing:
|
|
1718
|
-
onDismiss: () =>
|
|
2736
|
+
missing: le,
|
|
2737
|
+
onDismiss: () => Ee(!0)
|
|
1719
2738
|
}
|
|
1720
2739
|
),
|
|
1721
|
-
|
|
2740
|
+
Ce && /* @__PURE__ */ f("div", { className: "border-b border-cream/10 bg-red/10 px-4 py-1.5 text-[0.8125rem] text-cream/75", children: [
|
|
1722
2741
|
"Couldn't check this paywall's products — ",
|
|
1723
|
-
|
|
2742
|
+
Ce
|
|
1724
2743
|
] }),
|
|
1725
|
-
/* @__PURE__ */
|
|
1726
|
-
|
|
2744
|
+
/* @__PURE__ */ s(
|
|
2745
|
+
Ht,
|
|
1727
2746
|
{
|
|
1728
2747
|
title: `${t.project ?? e.title} / ${t.id}${t.label ? ` · ${t.label}` : ""}`,
|
|
1729
|
-
actions: /* @__PURE__ */
|
|
1730
|
-
|
|
1731
|
-
/* @__PURE__ */
|
|
2748
|
+
actions: /* @__PURE__ */ f(G, { children: [
|
|
2749
|
+
a,
|
|
2750
|
+
/* @__PURE__ */ s(
|
|
1732
2751
|
"button",
|
|
1733
2752
|
{
|
|
1734
2753
|
type: "button",
|
|
1735
2754
|
className: "sw-btn sw-btn--icon",
|
|
1736
2755
|
"aria-label": "Reload preview",
|
|
1737
|
-
onClick: () => g((
|
|
1738
|
-
children: /* @__PURE__ */
|
|
2756
|
+
onClick: () => g((y) => y + 1),
|
|
2757
|
+
children: /* @__PURE__ */ s(gt, {})
|
|
1739
2758
|
}
|
|
1740
2759
|
),
|
|
1741
|
-
e.standaloneUrl && /* @__PURE__ */
|
|
2760
|
+
e.standaloneUrl && /* @__PURE__ */ s(
|
|
1742
2761
|
"button",
|
|
1743
2762
|
{
|
|
1744
2763
|
type: "button",
|
|
1745
2764
|
className: "sw-btn sw-btn--icon",
|
|
1746
2765
|
"aria-label": "Open preview",
|
|
1747
|
-
onClick:
|
|
1748
|
-
children: /* @__PURE__ */
|
|
2766
|
+
onClick: oe,
|
|
2767
|
+
children: /* @__PURE__ */ s(he, {})
|
|
1749
2768
|
}
|
|
1750
2769
|
),
|
|
1751
|
-
|
|
1752
|
-
|
|
2770
|
+
/* @__PURE__ */ s(Ar, { source: e, surface: t }),
|
|
2771
|
+
/* @__PURE__ */ s(Vr, { source: e, surface: t }),
|
|
2772
|
+
R && /* @__PURE__ */ s(
|
|
2773
|
+
Gn,
|
|
1753
2774
|
{
|
|
1754
|
-
progress:
|
|
1755
|
-
blocked:
|
|
1756
|
-
onRun:
|
|
1757
|
-
onBlocked: () =>
|
|
2775
|
+
progress: V,
|
|
2776
|
+
blocked: qt ? void 0 : `Superwall has no product for ${le.map((y) => y.reference).join(", ")}`,
|
|
2777
|
+
onRun: $,
|
|
2778
|
+
onBlocked: () => Ee(!1)
|
|
1758
2779
|
}
|
|
1759
2780
|
)
|
|
1760
2781
|
] })
|
|
1761
2782
|
}
|
|
1762
2783
|
),
|
|
1763
|
-
/* @__PURE__ */
|
|
1764
|
-
/* @__PURE__ */
|
|
1765
|
-
|
|
1766
|
-
|
|
2784
|
+
/* @__PURE__ */ f("div", { className: "flex min-h-0 flex-1", children: [
|
|
2785
|
+
/* @__PURE__ */ f("div", { className: "flex min-w-0 flex-1", children: [
|
|
2786
|
+
W && /* @__PURE__ */ s(
|
|
2787
|
+
lt,
|
|
1767
2788
|
{
|
|
1768
|
-
label:
|
|
1769
|
-
width:
|
|
1770
|
-
height:
|
|
1771
|
-
title:
|
|
1772
|
-
src:
|
|
1773
|
-
hostState:
|
|
1774
|
-
delegate:
|
|
1775
|
-
reloadKey:
|
|
1776
|
-
empty: "empty" in
|
|
1777
|
-
chrome:
|
|
2789
|
+
label: W.label,
|
|
2790
|
+
width: O.width,
|
|
2791
|
+
height: O.height,
|
|
2792
|
+
title: W.title,
|
|
2793
|
+
src: W.src,
|
|
2794
|
+
hostState: ee,
|
|
2795
|
+
delegate: ae,
|
|
2796
|
+
reloadKey: E,
|
|
2797
|
+
empty: "empty" in W ? W.empty : void 0,
|
|
2798
|
+
chrome: ie,
|
|
1778
2799
|
landscape: S,
|
|
1779
|
-
theme:
|
|
2800
|
+
theme: r
|
|
1780
2801
|
}
|
|
1781
2802
|
),
|
|
1782
|
-
/* @__PURE__ */
|
|
1783
|
-
|
|
2803
|
+
/* @__PURE__ */ s(
|
|
2804
|
+
lt,
|
|
1784
2805
|
{
|
|
1785
|
-
label:
|
|
1786
|
-
width:
|
|
1787
|
-
height:
|
|
2806
|
+
label: W ? t.label ?? "Local" : void 0,
|
|
2807
|
+
width: O.width,
|
|
2808
|
+
height: O.height,
|
|
1788
2809
|
title: `${t.id} preview`,
|
|
1789
|
-
src:
|
|
1790
|
-
hostState:
|
|
1791
|
-
delegate:
|
|
1792
|
-
reloadKey:
|
|
1793
|
-
chrome:
|
|
2810
|
+
src: Ne,
|
|
2811
|
+
hostState: ee,
|
|
2812
|
+
delegate: ae,
|
|
2813
|
+
reloadKey: E,
|
|
2814
|
+
chrome: ie,
|
|
1794
2815
|
landscape: S,
|
|
1795
|
-
theme:
|
|
2816
|
+
theme: r
|
|
1796
2817
|
}
|
|
1797
2818
|
)
|
|
1798
2819
|
] }),
|
|
1799
|
-
/* @__PURE__ */
|
|
2820
|
+
/* @__PURE__ */ s(Gr, { open: b, title: "Variables", onClose: () => x(!1), children: /* @__PURE__ */ s(Zr, { overrides: u, groups: Kt, onChange: m }) })
|
|
1800
2821
|
] }),
|
|
1801
|
-
/* @__PURE__ */
|
|
1802
|
-
/* @__PURE__ */
|
|
1803
|
-
|
|
2822
|
+
/* @__PURE__ */ f(Kr, { children: [
|
|
2823
|
+
/* @__PURE__ */ s(ue, { label: "Intro offer", children: /* @__PURE__ */ s(
|
|
2824
|
+
Wr,
|
|
1804
2825
|
{
|
|
1805
2826
|
label: "Introductory offer",
|
|
1806
|
-
checked:
|
|
1807
|
-
onChange: (
|
|
2827
|
+
checked: re(ee),
|
|
2828
|
+
onChange: (y) => m((I) => ({ ...I, introductoryOfferEligible: y }))
|
|
1808
2829
|
}
|
|
1809
2830
|
) }),
|
|
1810
|
-
/* @__PURE__ */
|
|
1811
|
-
/* @__PURE__ */
|
|
1812
|
-
|
|
2831
|
+
/* @__PURE__ */ f(ue, { label: "Theme", children: [
|
|
2832
|
+
/* @__PURE__ */ s(
|
|
2833
|
+
Qr,
|
|
1813
2834
|
{
|
|
1814
2835
|
label: "Theme",
|
|
1815
|
-
value:
|
|
2836
|
+
value: r,
|
|
1816
2837
|
options: [
|
|
1817
|
-
{ value: "light", label: /* @__PURE__ */ n
|
|
1818
|
-
{ value: "dark", label: /* @__PURE__ */
|
|
2838
|
+
{ value: "light", label: /* @__PURE__ */ s($n, {}) },
|
|
2839
|
+
{ value: "dark", label: /* @__PURE__ */ s(Dn, {}) }
|
|
1819
2840
|
],
|
|
1820
|
-
onChange:
|
|
2841
|
+
onChange: i
|
|
1821
2842
|
}
|
|
1822
2843
|
),
|
|
1823
|
-
/* @__PURE__ */
|
|
2844
|
+
/* @__PURE__ */ s(
|
|
1824
2845
|
"button",
|
|
1825
2846
|
{
|
|
1826
2847
|
type: "button",
|
|
@@ -1828,411 +2849,405 @@ const K = (e, t, a, r) => new Promise((s) => {
|
|
|
1828
2849
|
"aria-label": "Rotate device",
|
|
1829
2850
|
"aria-pressed": S,
|
|
1830
2851
|
title: S ? "Back to portrait" : "Rotate to landscape",
|
|
1831
|
-
onClick: () =>
|
|
1832
|
-
children: /* @__PURE__ */
|
|
2852
|
+
onClick: () => C((y) => !y),
|
|
2853
|
+
children: /* @__PURE__ */ s(
|
|
1833
2854
|
"span",
|
|
1834
2855
|
{
|
|
1835
2856
|
className: `flex transition-transform duration-200 ${S ? "-rotate-90" : ""}`,
|
|
1836
|
-
children: /* @__PURE__ */
|
|
2857
|
+
children: /* @__PURE__ */ s(Hn, {})
|
|
1837
2858
|
}
|
|
1838
2859
|
)
|
|
1839
2860
|
}
|
|
1840
2861
|
)
|
|
1841
2862
|
] }),
|
|
1842
|
-
/* @__PURE__ */
|
|
1843
|
-
/* @__PURE__ */
|
|
1844
|
-
/* @__PURE__ */
|
|
1845
|
-
|
|
2863
|
+
/* @__PURE__ */ s(st, {}),
|
|
2864
|
+
/* @__PURE__ */ f(ue, { label: "Device", children: [
|
|
2865
|
+
/* @__PURE__ */ s(
|
|
2866
|
+
rt,
|
|
1846
2867
|
{
|
|
1847
2868
|
label: "Device",
|
|
1848
|
-
value:
|
|
2869
|
+
value: l,
|
|
1849
2870
|
options: [
|
|
1850
|
-
...
|
|
1851
|
-
{ value:
|
|
2871
|
+
...ge.map((y) => ({ value: y.id, label: y.name })),
|
|
2872
|
+
{ value: ot, label: "Responsive" }
|
|
1852
2873
|
],
|
|
1853
|
-
onChange:
|
|
2874
|
+
onChange: c
|
|
1854
2875
|
}
|
|
1855
2876
|
),
|
|
1856
|
-
|
|
1857
|
-
/* @__PURE__ */
|
|
1858
|
-
|
|
2877
|
+
H && /* @__PURE__ */ f("span", { className: "flex items-center gap-1.5", children: [
|
|
2878
|
+
/* @__PURE__ */ s(
|
|
2879
|
+
it,
|
|
1859
2880
|
{
|
|
1860
2881
|
label: "Preview width",
|
|
1861
|
-
value:
|
|
1862
|
-
onCommit: (
|
|
2882
|
+
value: O.width,
|
|
2883
|
+
onCommit: (y) => p((I) => ({ ...I, width: y }))
|
|
1863
2884
|
}
|
|
1864
2885
|
),
|
|
1865
|
-
/* @__PURE__ */
|
|
1866
|
-
/* @__PURE__ */
|
|
1867
|
-
|
|
2886
|
+
/* @__PURE__ */ s("span", { className: "text-cream/55", children: "×" }),
|
|
2887
|
+
/* @__PURE__ */ s(
|
|
2888
|
+
it,
|
|
1868
2889
|
{
|
|
1869
2890
|
label: "Preview height",
|
|
1870
|
-
value:
|
|
1871
|
-
onCommit: (
|
|
2891
|
+
value: O.height,
|
|
2892
|
+
onCommit: (y) => p((I) => ({ ...I, height: y }))
|
|
1872
2893
|
}
|
|
1873
2894
|
)
|
|
1874
2895
|
] })
|
|
1875
2896
|
] }),
|
|
1876
|
-
|
|
1877
|
-
|
|
2897
|
+
F.length > 1 && /* @__PURE__ */ s(ue, { label: "Locale", children: /* @__PURE__ */ s(
|
|
2898
|
+
rt,
|
|
1878
2899
|
{
|
|
1879
2900
|
label: "Locale",
|
|
1880
|
-
value:
|
|
2901
|
+
value: o ?? "default",
|
|
1881
2902
|
options: [
|
|
1882
2903
|
{ value: "default", label: "Device" },
|
|
1883
|
-
...
|
|
2904
|
+
...F.map((y) => ({ value: y, label: y }))
|
|
1884
2905
|
],
|
|
1885
|
-
onChange: (
|
|
2906
|
+
onChange: (y) => d(y === "default" ? void 0 : y)
|
|
1886
2907
|
}
|
|
1887
2908
|
) }),
|
|
1888
|
-
/* @__PURE__ */
|
|
1889
|
-
|
|
1890
|
-
/* @__PURE__ */
|
|
2909
|
+
/* @__PURE__ */ s(st, {}),
|
|
2910
|
+
Qe.length > 0 && /* @__PURE__ */ s(Kn, { active: v, options: Qe, onSelect: P }),
|
|
2911
|
+
/* @__PURE__ */ f(
|
|
1891
2912
|
"button",
|
|
1892
2913
|
{
|
|
1893
2914
|
type: "button",
|
|
1894
2915
|
className: "sw-btn",
|
|
1895
|
-
"aria-expanded":
|
|
1896
|
-
onClick: () =>
|
|
2916
|
+
"aria-expanded": b,
|
|
2917
|
+
onClick: () => x((y) => !y),
|
|
1897
2918
|
children: [
|
|
1898
|
-
/* @__PURE__ */
|
|
2919
|
+
/* @__PURE__ */ s(Fn, {}),
|
|
1899
2920
|
"Variables",
|
|
1900
|
-
|
|
2921
|
+
We > 0 && /* @__PURE__ */ s("span", { className: "text-accent", children: We })
|
|
1901
2922
|
]
|
|
1902
2923
|
}
|
|
1903
2924
|
)
|
|
1904
2925
|
] })
|
|
1905
2926
|
] });
|
|
1906
|
-
},
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
}
|
|
1912
|
-
|
|
1913
|
-
try {
|
|
1914
|
-
window.localStorage.setItem(bt, e);
|
|
1915
|
-
} catch {
|
|
1916
|
-
}
|
|
1917
|
-
}, We = (e, t) => `${e}://?superwall_dev=${encodeURIComponent(t)}`, ya = ({ origin: e, scheme: t }) => {
|
|
1918
|
-
const [a, r] = d.useState(va), s = a ?? t, i = (p) => {
|
|
1919
|
-
const h = window.prompt("Your app's URL scheme, so this can open it:", p)?.trim();
|
|
1920
|
-
if (!(h === void 0 || h === ""))
|
|
1921
|
-
return r(h), wa(h), h;
|
|
1922
|
-
}, o = (p) => {
|
|
1923
|
-
if (s !== void 0) return;
|
|
2927
|
+
}, as = ({ origin: e, scheme: t }) => {
|
|
2928
|
+
const [n, a] = w.useState(jt), l = n ?? t, c = (p) => {
|
|
2929
|
+
const i = window.prompt("Your app's URL scheme, so this can open it:", p)?.trim();
|
|
2930
|
+
if (!(i === void 0 || i === ""))
|
|
2931
|
+
return a(i), zt(i), i;
|
|
2932
|
+
}, h = (p) => {
|
|
2933
|
+
if (l !== void 0) return;
|
|
1924
2934
|
p.preventDefault();
|
|
1925
|
-
const
|
|
1926
|
-
|
|
2935
|
+
const r = c("");
|
|
2936
|
+
r !== void 0 && window.location.assign(Be(r, e));
|
|
1927
2937
|
};
|
|
1928
|
-
return /* @__PURE__ */
|
|
1929
|
-
|
|
2938
|
+
return /* @__PURE__ */ f("div", { className: "flex items-center gap-2", children: [
|
|
2939
|
+
l !== void 0 && /* @__PURE__ */ s(
|
|
1930
2940
|
"button",
|
|
1931
2941
|
{
|
|
1932
2942
|
className: "sw-btn sw-btn--icon",
|
|
1933
2943
|
type: "button",
|
|
1934
2944
|
"aria-label": "Edit app URL scheme",
|
|
1935
|
-
onClick: () =>
|
|
1936
|
-
children: /* @__PURE__ */
|
|
1937
|
-
/* @__PURE__ */
|
|
1938
|
-
/* @__PURE__ */
|
|
2945
|
+
onClick: () => c(l),
|
|
2946
|
+
children: /* @__PURE__ */ f("svg", { className: "sw-icon", viewBox: "0 0 24 24", "aria-hidden": "true", children: [
|
|
2947
|
+
/* @__PURE__ */ s("path", { d: "M12 20h9" }),
|
|
2948
|
+
/* @__PURE__ */ s("path", { d: "M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4Z" })
|
|
1939
2949
|
] })
|
|
1940
2950
|
}
|
|
1941
2951
|
),
|
|
1942
|
-
/* @__PURE__ */
|
|
2952
|
+
/* @__PURE__ */ s(
|
|
1943
2953
|
"a",
|
|
1944
2954
|
{
|
|
1945
2955
|
className: "sw-btn sw-btn--primary",
|
|
1946
|
-
href:
|
|
1947
|
-
onClick:
|
|
2956
|
+
href: l === void 0 ? "#" : Be(l, e),
|
|
2957
|
+
onClick: h,
|
|
1948
2958
|
children: "Open In App"
|
|
1949
2959
|
}
|
|
1950
2960
|
)
|
|
1951
2961
|
] });
|
|
1952
|
-
},
|
|
2962
|
+
}, os = [
|
|
1953
2963
|
[60, "second"],
|
|
1954
2964
|
[60, "minute"],
|
|
1955
2965
|
[24, "hour"],
|
|
1956
2966
|
[7, "day"],
|
|
1957
2967
|
[4.348, "week"],
|
|
1958
2968
|
[12, "month"]
|
|
1959
|
-
],
|
|
1960
|
-
const
|
|
1961
|
-
if (Number.isNaN(
|
|
1962
|
-
let
|
|
1963
|
-
const
|
|
1964
|
-
for (const [
|
|
1965
|
-
if (
|
|
1966
|
-
|
|
2969
|
+
], is = (e, t = Date.now()) => {
|
|
2970
|
+
const n = Date.parse(e);
|
|
2971
|
+
if (Number.isNaN(n)) return;
|
|
2972
|
+
let a = Math.max(0, (t - n) / 1e3);
|
|
2973
|
+
const l = new Intl.RelativeTimeFormat("en", { numeric: "auto" });
|
|
2974
|
+
for (const [c, h] of os) {
|
|
2975
|
+
if (a < c) return l.format(-Math.round(a), h);
|
|
2976
|
+
a /= c;
|
|
1967
2977
|
}
|
|
1968
|
-
return
|
|
1969
|
-
},
|
|
1970
|
-
const [t,
|
|
1971
|
-
return
|
|
1972
|
-
const
|
|
1973
|
-
if (!
|
|
1974
|
-
const
|
|
1975
|
-
if (
|
|
1976
|
-
const
|
|
1977
|
-
return
|
|
2978
|
+
return l.format(-Math.round(a), "year");
|
|
2979
|
+
}, ct = 390, ls = 844, cs = (e) => {
|
|
2980
|
+
const [t, n] = w.useState(0);
|
|
2981
|
+
return w.useLayoutEffect(() => {
|
|
2982
|
+
const a = e.current;
|
|
2983
|
+
if (!a) return;
|
|
2984
|
+
const l = () => n(a.getBoundingClientRect().width);
|
|
2985
|
+
if (l(), typeof ResizeObserver > "u") return;
|
|
2986
|
+
const c = new ResizeObserver(l);
|
|
2987
|
+
return c.observe(a), () => c.disconnect();
|
|
1978
2988
|
}, [e]), t;
|
|
1979
|
-
},
|
|
2989
|
+
}, ds = ({
|
|
1980
2990
|
surface: e,
|
|
1981
2991
|
status: t,
|
|
1982
|
-
previewSrc:
|
|
1983
|
-
hostState:
|
|
1984
|
-
onOpen:
|
|
1985
|
-
href:
|
|
2992
|
+
previewSrc: n,
|
|
2993
|
+
hostState: a,
|
|
2994
|
+
onOpen: l,
|
|
2995
|
+
href: c
|
|
1986
2996
|
}) => {
|
|
1987
|
-
const
|
|
1988
|
-
return /* @__PURE__ */
|
|
2997
|
+
const h = w.useRef(null), p = cs(h), r = p > 0 ? p / ct : 0, i = w.useMemo(pn, []);
|
|
2998
|
+
return /* @__PURE__ */ f(
|
|
1989
2999
|
"a",
|
|
1990
3000
|
{
|
|
1991
3001
|
className: "group block",
|
|
1992
|
-
href:
|
|
1993
|
-
onClick: (
|
|
1994
|
-
|
|
3002
|
+
href: c ?? U(e),
|
|
3003
|
+
onClick: (o) => {
|
|
3004
|
+
o.metaKey || o.ctrlKey || (o.preventDefault(), l());
|
|
1995
3005
|
},
|
|
1996
3006
|
children: [
|
|
1997
|
-
/* @__PURE__ */
|
|
3007
|
+
/* @__PURE__ */ s(
|
|
1998
3008
|
"div",
|
|
1999
3009
|
{
|
|
2000
|
-
className: "bg-panel relative aspect-[390/844] overflow-hidden border border-cream/20 transition-colors group-hover:border-cream/35",
|
|
2001
|
-
ref:
|
|
2002
|
-
children:
|
|
2003
|
-
|
|
3010
|
+
className: "bg-panel relative aspect-[390/844] overflow-hidden rounded border border-cream/20 transition-colors group-hover:border-cream/35",
|
|
3011
|
+
ref: h,
|
|
3012
|
+
children: r > 0 && /* @__PURE__ */ s(
|
|
3013
|
+
Et,
|
|
2004
3014
|
{
|
|
2005
|
-
hostState:
|
|
2006
|
-
delegate:
|
|
3015
|
+
hostState: a,
|
|
3016
|
+
delegate: i,
|
|
2007
3017
|
className: "pointer-events-none block origin-top-left border-0 bg-white",
|
|
2008
3018
|
title: `${e.project ? `${e.project}/` : ""}${e.id} preview`,
|
|
2009
|
-
src:
|
|
3019
|
+
src: n,
|
|
2010
3020
|
loading: "lazy",
|
|
2011
3021
|
tabIndex: -1,
|
|
2012
|
-
width:
|
|
2013
|
-
height:
|
|
2014
|
-
style: { transform: `scale(${
|
|
3022
|
+
width: ct,
|
|
3023
|
+
height: ls,
|
|
3024
|
+
style: { transform: `scale(${r})` }
|
|
2015
3025
|
}
|
|
2016
3026
|
)
|
|
2017
3027
|
}
|
|
2018
3028
|
),
|
|
2019
|
-
/* @__PURE__ */
|
|
2020
|
-
/* @__PURE__ */
|
|
2021
|
-
/* @__PURE__ */
|
|
2022
|
-
e.project && /* @__PURE__ */
|
|
3029
|
+
/* @__PURE__ */ f("div", { className: "flex items-center justify-between gap-2 pt-2.5", children: [
|
|
3030
|
+
/* @__PURE__ */ f("div", { className: "flex flex-col gap-0.5", children: [
|
|
3031
|
+
/* @__PURE__ */ f("span", { className: "text-sm font-medium", children: [
|
|
3032
|
+
e.project && /* @__PURE__ */ f("span", { className: "text-cream/45", children: [
|
|
2023
3033
|
e.project,
|
|
2024
3034
|
"/"
|
|
2025
3035
|
] }),
|
|
2026
3036
|
e.id,
|
|
2027
|
-
e.platforms && e.platforms.length > 0 && /* @__PURE__ */
|
|
3037
|
+
e.platforms && e.platforms.length > 0 && /* @__PURE__ */ f("span", { className: "text-cream/45", children: [
|
|
2028
3038
|
" · ",
|
|
2029
3039
|
e.platforms.join(" · ")
|
|
2030
3040
|
] })
|
|
2031
3041
|
] }),
|
|
2032
|
-
t && /* @__PURE__ */
|
|
3042
|
+
t && /* @__PURE__ */ s("span", { className: "text-xs text-cream/55", children: t.updatedAt ? `Edited ${is(t.updatedAt)}` : "Not published" })
|
|
2033
3043
|
] }),
|
|
2034
|
-
t?.paywallId && /* @__PURE__ */
|
|
3044
|
+
t?.paywallId && /* @__PURE__ */ s("span", { className: `text-xs ${t.active ? "text-accent" : "text-cream/55"}`, children: t.active ? "Active" : "Inactive" })
|
|
2035
3045
|
] })
|
|
2036
3046
|
]
|
|
2037
3047
|
}
|
|
2038
3048
|
);
|
|
2039
3049
|
};
|
|
2040
|
-
let
|
|
2041
|
-
const
|
|
3050
|
+
let dt = 0;
|
|
3051
|
+
const us = ({
|
|
2042
3052
|
source: e,
|
|
2043
3053
|
onOpen: t
|
|
2044
3054
|
}) => {
|
|
2045
|
-
const
|
|
2046
|
-
|
|
2047
|
-
if (!
|
|
2048
|
-
let
|
|
3055
|
+
const n = Ve() === "device", a = Gt(e), [l, c] = w.useState({}), h = w.useMemo(Qt, [e]);
|
|
3056
|
+
w.useEffect(() => {
|
|
3057
|
+
if (!a) return;
|
|
3058
|
+
let d = !1;
|
|
2049
3059
|
for (const u of e.surfaces)
|
|
2050
|
-
|
|
2051
|
-
|
|
3060
|
+
De(u).then((m) => {
|
|
3061
|
+
d || c((b) => ({ ...b, [U(u)]: m }));
|
|
2052
3062
|
});
|
|
2053
3063
|
return () => {
|
|
2054
|
-
|
|
3064
|
+
d = !0;
|
|
2055
3065
|
};
|
|
2056
|
-
}, [e,
|
|
2057
|
-
const [p,
|
|
2058
|
-
|
|
2059
|
-
const
|
|
2060
|
-
if (!
|
|
2061
|
-
|
|
3066
|
+
}, [e, a]);
|
|
3067
|
+
const [p, r] = w.useState({}), i = w.useRef(null);
|
|
3068
|
+
w.useLayoutEffect(() => {
|
|
3069
|
+
const d = i.current;
|
|
3070
|
+
if (!d) return;
|
|
3071
|
+
d.scrollTop = dt;
|
|
2062
3072
|
const u = () => {
|
|
2063
|
-
|
|
3073
|
+
dt = d.scrollTop;
|
|
2064
3074
|
};
|
|
2065
|
-
return
|
|
2066
|
-
u(),
|
|
3075
|
+
return d.addEventListener("scroll", u, { passive: !0 }), () => {
|
|
3076
|
+
u(), d.removeEventListener("scroll", u);
|
|
2067
3077
|
};
|
|
2068
3078
|
}, []);
|
|
2069
|
-
const
|
|
3079
|
+
const o = [
|
|
2070
3080
|
["Paywalls", "paywall"],
|
|
2071
3081
|
["Funnels", "funnel"]
|
|
2072
|
-
].map(([
|
|
2073
|
-
const
|
|
3082
|
+
].map(([d, u]) => {
|
|
3083
|
+
const m = e.surfaces.filter((x) => x.kind === u), b = (p[u] ?? "").trim().toLowerCase();
|
|
2074
3084
|
return {
|
|
2075
|
-
label:
|
|
3085
|
+
label: d,
|
|
2076
3086
|
kind: u,
|
|
2077
|
-
all:
|
|
2078
|
-
needle:
|
|
2079
|
-
surfaces:
|
|
2080
|
-
(
|
|
3087
|
+
all: m,
|
|
3088
|
+
needle: b,
|
|
3089
|
+
surfaces: m.filter(
|
|
3090
|
+
(x) => b === "" || `${x.project ?? ""} ${x.id}`.toLowerCase().includes(b)
|
|
2081
3091
|
)
|
|
2082
3092
|
};
|
|
2083
|
-
}).filter((
|
|
2084
|
-
return /* @__PURE__ */
|
|
2085
|
-
/* @__PURE__ */
|
|
2086
|
-
|
|
3093
|
+
}).filter((d) => d.all.length > 0);
|
|
3094
|
+
return /* @__PURE__ */ f(G, { children: [
|
|
3095
|
+
/* @__PURE__ */ s(
|
|
3096
|
+
Ht,
|
|
2087
3097
|
{
|
|
2088
3098
|
title: e.title,
|
|
2089
3099
|
inset: !0,
|
|
2090
|
-
label:
|
|
2091
|
-
actions:
|
|
3100
|
+
label: n ? "Preview" : void 0,
|
|
3101
|
+
actions: n ? /* @__PURE__ */ s(as, { origin: window.location.origin, scheme: e.scheme }) : void 0
|
|
2092
3102
|
}
|
|
2093
3103
|
),
|
|
2094
|
-
/* @__PURE__ */
|
|
2095
|
-
e.diagnostics && e.diagnostics.length > 0 && /* @__PURE__ */
|
|
3104
|
+
/* @__PURE__ */ s("div", { className: "flex-1 overflow-y-auto px-3 pt-6 pb-16 sm:px-6 sm:pt-10", ref: i, children: /* @__PURE__ */ f("div", { className: "mx-auto max-w-[1080px]", children: [
|
|
3105
|
+
e.diagnostics && e.diagnostics.length > 0 && /* @__PURE__ */ s("div", { className: "border-red bg-red/10 mb-6 rounded border-l-2 px-4 py-3 text-[0.8125rem] whitespace-pre-wrap", children: e.diagnostics.join(`
|
|
2096
3106
|
`) }),
|
|
2097
|
-
|
|
2098
|
-
/* @__PURE__ */
|
|
2099
|
-
/* @__PURE__ */
|
|
2100
|
-
/* @__PURE__ */
|
|
2101
|
-
|
|
3107
|
+
o.map((d) => /* @__PURE__ */ f("section", { className: "mt-10 first:mt-0", children: [
|
|
3108
|
+
/* @__PURE__ */ f("div", { className: "mb-4 flex items-center gap-2", children: [
|
|
3109
|
+
/* @__PURE__ */ s("span", { className: "text-[1.0625rem] font-medium", children: d.label }),
|
|
3110
|
+
/* @__PURE__ */ s("span", { className: "text-[0.8125rem] text-cream/55 tabular-nums", children: d.surfaces.length }),
|
|
3111
|
+
d.all.length > 1 && /* @__PURE__ */ s(
|
|
2102
3112
|
"input",
|
|
2103
3113
|
{
|
|
2104
3114
|
className: "sw-input ml-auto w-48",
|
|
2105
3115
|
type: "search",
|
|
2106
|
-
value: p[
|
|
2107
|
-
placeholder: `Search ${
|
|
2108
|
-
"aria-label": `Search ${
|
|
2109
|
-
onChange: (u) =>
|
|
3116
|
+
value: p[d.kind] ?? "",
|
|
3117
|
+
placeholder: `Search ${d.label.toLowerCase()}`,
|
|
3118
|
+
"aria-label": `Search ${d.label.toLowerCase()}`,
|
|
3119
|
+
onChange: (u) => r((m) => ({ ...m, [d.kind]: u.target.value }))
|
|
2110
3120
|
}
|
|
2111
3121
|
)
|
|
2112
3122
|
] }),
|
|
2113
|
-
/* @__PURE__ */
|
|
2114
|
-
|
|
3123
|
+
/* @__PURE__ */ s("div", { className: "grid grid-cols-2 gap-3 sm:grid-cols-[repeat(auto-fill,minmax(200px,1fr))] sm:gap-6", children: d.surfaces.map((u) => /* @__PURE__ */ s(
|
|
3124
|
+
ds,
|
|
2115
3125
|
{
|
|
2116
3126
|
surface: u,
|
|
2117
|
-
status:
|
|
3127
|
+
status: l[U(u)],
|
|
2118
3128
|
previewSrc: e.previewUrl(u),
|
|
2119
|
-
hostState:
|
|
3129
|
+
hostState: Wt({
|
|
2120
3130
|
surface: u,
|
|
2121
|
-
defaults:
|
|
3131
|
+
defaults: h,
|
|
2122
3132
|
sourceSamples: e.samples,
|
|
2123
3133
|
samples: {},
|
|
2124
3134
|
theme: "light",
|
|
2125
3135
|
edited: {}
|
|
2126
3136
|
}),
|
|
2127
3137
|
onOpen: () => t(u),
|
|
2128
|
-
href:
|
|
3138
|
+
href: n ? U(u) : void 0
|
|
2129
3139
|
},
|
|
2130
|
-
|
|
3140
|
+
U(u)
|
|
2131
3141
|
)) }),
|
|
2132
|
-
|
|
2133
|
-
] },
|
|
2134
|
-
e.surfaces.length === 0 && /* @__PURE__ */
|
|
3142
|
+
d.surfaces.length === 0 && /* @__PURE__ */ s("span", { className: "block text-[0.8125rem] text-cream/45", children: `Nothing matches “${(p[d.kind] ?? "").trim()}”.` })
|
|
3143
|
+
] }, d.kind)),
|
|
3144
|
+
e.surfaces.length === 0 && /* @__PURE__ */ f("div", { className: "rounded border border-dashed border-cream/20 p-12 text-center text-cream/55", children: [
|
|
2135
3145
|
"No paywalls yet — create",
|
|
2136
3146
|
" ",
|
|
2137
|
-
/* @__PURE__ */
|
|
3147
|
+
/* @__PURE__ */ s("code", { className: "font-mono text-[0.8125rem] text-cream", children: "superwall/paywalls/<id>/app/page.tsx" }),
|
|
2138
3148
|
" ",
|
|
2139
3149
|
"and it appears here."
|
|
2140
3150
|
] })
|
|
2141
3151
|
] }) }),
|
|
2142
|
-
!
|
|
3152
|
+
!n && /* @__PURE__ */ s("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." })
|
|
2143
3153
|
] });
|
|
2144
|
-
},
|
|
2145
|
-
const
|
|
2146
|
-
if (
|
|
3154
|
+
}, hs = (e, t) => {
|
|
3155
|
+
const n = t.match(/^\/(?:([a-z0-9-]+)\/)?(paywall|funnel)\/([a-z0-9-]+)\/?$/);
|
|
3156
|
+
if (n)
|
|
2147
3157
|
return e.find(
|
|
2148
|
-
(
|
|
3158
|
+
(a) => a.kind === n[2] && a.id === n[3] && (n[1] === void 0 || a.project === n[1])
|
|
2149
3159
|
);
|
|
2150
|
-
},
|
|
3160
|
+
}, Ns = ({
|
|
2151
3161
|
source: e,
|
|
2152
3162
|
mode: t = "local"
|
|
2153
3163
|
}) => {
|
|
2154
|
-
const [
|
|
2155
|
-
|
|
2156
|
-
const
|
|
2157
|
-
return window.addEventListener("popstate",
|
|
2158
|
-
}, []),
|
|
3164
|
+
const [n, a] = w.useState(() => window.location.pathname), [l, c] = w.useState({});
|
|
3165
|
+
w.useEffect(() => {
|
|
3166
|
+
const o = () => a(window.location.pathname);
|
|
3167
|
+
return window.addEventListener("popstate", o), () => window.removeEventListener("popstate", o);
|
|
3168
|
+
}, []), w.useEffect(() => {
|
|
2159
3169
|
if (e.capabilities?.actions !== !0) return;
|
|
2160
|
-
let
|
|
2161
|
-
return
|
|
2162
|
-
|
|
3170
|
+
let o = !1;
|
|
3171
|
+
return _r().then((d) => {
|
|
3172
|
+
o || c(d);
|
|
2163
3173
|
}), () => {
|
|
2164
|
-
|
|
3174
|
+
o = !0;
|
|
2165
3175
|
};
|
|
2166
3176
|
}, [e.capabilities?.actions]);
|
|
2167
|
-
const
|
|
2168
|
-
window.history.pushState(null, "",
|
|
2169
|
-
}, []),
|
|
2170
|
-
() => ({ href:
|
|
2171
|
-
[
|
|
2172
|
-
),
|
|
2173
|
-
return /* @__PURE__ */
|
|
2174
|
-
},
|
|
2175
|
-
if (!
|
|
3177
|
+
const h = t === "device" ? "/device" : "/", p = w.useCallback((o) => {
|
|
3178
|
+
window.history.pushState(null, "", o), a(o);
|
|
3179
|
+
}, []), r = w.useMemo(
|
|
3180
|
+
() => ({ href: h, navigate: () => p(h) }),
|
|
3181
|
+
[h, p]
|
|
3182
|
+
), i = hs(e.surfaces, n);
|
|
3183
|
+
return /* @__PURE__ */ s(Pr, { mode: t, home: r, children: /* @__PURE__ */ s(Xt, { children: i ? /* @__PURE__ */ s(ss, { source: e, surface: i, samples: l }) : /* @__PURE__ */ s(us, { source: e, onOpen: (o) => p(U(o)) }) }) });
|
|
3184
|
+
}, ms = (e) => typeof e == "object" && e !== null && !Array.isArray(e) && Object.values(e).every((t) => typeof t == "string"), ne = (e) => typeof e == "object" && e !== null && !Array.isArray(e), fe = (e) => Array.isArray(e) && e.every((t) => typeof t == "string"), ps = (e) => {
|
|
3185
|
+
if (!ne(e)) return;
|
|
2176
3186
|
const t = e.kind === "paywall" || e.kind === "funnel" ? e.kind : void 0;
|
|
2177
3187
|
if (!(!t || typeof e.id != "string"))
|
|
2178
3188
|
return {
|
|
2179
3189
|
kind: t,
|
|
2180
3190
|
id: e.id,
|
|
2181
3191
|
...typeof e.project == "string" ? { project: e.project } : {},
|
|
2182
|
-
routes:
|
|
2183
|
-
products:
|
|
2184
|
-
locales:
|
|
2185
|
-
...
|
|
3192
|
+
routes: fe(e.routes) ? e.routes : [],
|
|
3193
|
+
products: ms(e.products) ? e.products : {},
|
|
3194
|
+
locales: fe(e.locales) ? e.locales : [],
|
|
3195
|
+
...fe(e.platforms) ? { platforms: e.platforms } : {},
|
|
2186
3196
|
paywallId: typeof e.paywallId == "string" ? e.paywallId : void 0
|
|
2187
3197
|
};
|
|
2188
|
-
},
|
|
2189
|
-
if (!
|
|
3198
|
+
}, Ss = (e) => {
|
|
3199
|
+
if (!ne(e))
|
|
2190
3200
|
throw new Error("project payload is not an object");
|
|
2191
|
-
const t = Array.isArray(e.surfaces) ? e.surfaces.map(
|
|
3201
|
+
const t = Array.isArray(e.surfaces) ? e.surfaces.map(ps).filter((c) => c !== void 0) : [], n = ne(e.capabilities) ? e.capabilities : {}, a = ne(e.samples) ? e.samples : {}, l = (c) => ne(a[c]) ? a[c] : {};
|
|
2192
3202
|
return {
|
|
2193
3203
|
title: typeof e.title == "string" ? e.title : "superwall",
|
|
2194
3204
|
scheme: typeof e.scheme == "string" ? e.scheme : void 0,
|
|
3205
|
+
networkOrigin: typeof e.networkOrigin == "string" ? e.networkOrigin : void 0,
|
|
2195
3206
|
surfaces: t,
|
|
2196
|
-
diagnostics:
|
|
3207
|
+
diagnostics: fe(e.diagnostics) ? e.diagnostics : [],
|
|
2197
3208
|
samples: {
|
|
2198
|
-
device:
|
|
2199
|
-
user:
|
|
2200
|
-
params:
|
|
3209
|
+
device: l("device"),
|
|
3210
|
+
user: l("user"),
|
|
3211
|
+
params: l("params")
|
|
2201
3212
|
},
|
|
2202
|
-
capabilities: { actions:
|
|
3213
|
+
capabilities: { actions: n.actions === !0 }
|
|
2203
3214
|
};
|
|
2204
3215
|
};
|
|
2205
3216
|
export {
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
3217
|
+
Vt as DEFAULT_DEVICE_ID,
|
|
3218
|
+
nr as DeviceFrame,
|
|
3219
|
+
Ar as DownloadScreenshot,
|
|
3220
|
+
Et as HostedIframe,
|
|
3221
|
+
Nr as PaywallToasts,
|
|
3222
|
+
Vr as PreviewOnDevice,
|
|
3223
|
+
ge as STUDIO_DEVICES,
|
|
3224
|
+
Qr as Segmented,
|
|
3225
|
+
rt as Select,
|
|
3226
|
+
Ns as StudioApp,
|
|
3227
|
+
Pr as StudioHostProvider,
|
|
3228
|
+
Xt as StudioShell,
|
|
3229
|
+
ss as SurfaceEditor,
|
|
3230
|
+
us as SurfaceList,
|
|
3231
|
+
Wr as Switch,
|
|
3232
|
+
Sr as Tooltip,
|
|
3233
|
+
Ht as TopBar,
|
|
3234
|
+
Zr as VariablesPanel,
|
|
3235
|
+
gs as buildPreviewPath,
|
|
3236
|
+
ut as createHostState,
|
|
3237
|
+
yr as createStudioDelegate,
|
|
3238
|
+
Be as devServerLink,
|
|
3239
|
+
ns as deviceById,
|
|
3240
|
+
en as diffHostState,
|
|
3241
|
+
Gt as hasActions,
|
|
3242
|
+
re as hasIntroductoryOffer,
|
|
3243
|
+
Wt as hostStateFor,
|
|
3244
|
+
He as hostedUrl,
|
|
3245
|
+
Ss as parseProjectPayload,
|
|
3246
|
+
pn as silentDelegate,
|
|
3247
|
+
vs as snapshotPreviewUrl,
|
|
3248
|
+
Qt as studioDefaults,
|
|
3249
|
+
U as surfacePath,
|
|
3250
|
+
xr as useStudioDelegate,
|
|
3251
|
+
Rr as useStudioHome,
|
|
3252
|
+
Ve as useStudioMode
|
|
2238
3253
|
};
|