@extenshi/pay 0.7.1 → 0.8.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.
Files changed (86) hide show
  1. package/README.md +11 -9
  2. package/dist/api/mock.d.ts +4 -0
  3. package/dist/api/mock.d.ts.map +1 -1
  4. package/dist/api/pay-api.d.ts +10 -3
  5. package/dist/api/pay-api.d.ts.map +1 -1
  6. package/dist/api/transport.d.ts.map +1 -1
  7. package/dist/core/config.d.ts.map +1 -1
  8. package/dist/core/extenshi-pay.d.ts +21 -2
  9. package/dist/core/extenshi-pay.d.ts.map +1 -1
  10. package/dist/core/locale.d.ts +13 -0
  11. package/dist/core/locale.d.ts.map +1 -0
  12. package/dist/core.d.mts +208 -113
  13. package/dist/core.d.ts +208 -113
  14. package/dist/core.js +204 -14
  15. package/dist/core.js.map +1 -1
  16. package/dist/core.mjs +204 -15
  17. package/dist/core.mjs.map +1 -1
  18. package/dist/extenshi-pay-lite.js +204 -14
  19. package/dist/extenshi-pay-lite.js.map +1 -1
  20. package/dist/extenshi-pay-lite.min.js +3 -2
  21. package/dist/extenshi-pay-lite.min.js.map +1 -1
  22. package/dist/extenshi-pay-lite.mjs +204 -15
  23. package/dist/extenshi-pay-lite.mjs.map +1 -1
  24. package/dist/extenshi-pay.cjs.js +1234 -180
  25. package/dist/extenshi-pay.cjs.js.map +1 -1
  26. package/dist/extenshi-pay.d.ts.map +1 -1
  27. package/dist/extenshi-pay.js +1234 -180
  28. package/dist/extenshi-pay.js.map +1 -1
  29. package/dist/extenshi-pay.min.js +3 -2
  30. package/dist/extenshi-pay.min.js.map +1 -1
  31. package/dist/extenshi-pay.min.mjs +3 -2
  32. package/dist/extenshi-pay.min.mjs.map +1 -1
  33. package/dist/extenshi-pay.mjs +1231 -181
  34. package/dist/extenshi-pay.mjs.map +1 -1
  35. package/dist/index.d.mts +268 -117
  36. package/dist/index.d.ts +268 -117
  37. package/dist/lite.d.mts +176 -82
  38. package/dist/lite.d.ts +176 -82
  39. package/dist/lite.d.ts.map +1 -1
  40. package/dist/payment/checkout.d.ts.map +1 -1
  41. package/dist/payment/recovery.d.ts +2 -0
  42. package/dist/payment/recovery.d.ts.map +1 -1
  43. package/dist/payment/withdrawal-waiver.d.ts +26 -0
  44. package/dist/payment/withdrawal-waiver.d.ts.map +1 -0
  45. package/dist/paywall/billing-profile-picker.d.ts +1 -1
  46. package/dist/paywall/billing-profile-picker.d.ts.map +1 -1
  47. package/dist/paywall/i18n.d.ts +94 -0
  48. package/dist/paywall/i18n.d.ts.map +1 -0
  49. package/dist/paywall/index.d.ts +2 -1
  50. package/dist/paywall/index.d.ts.map +1 -1
  51. package/dist/paywall/license-panel.d.ts +4 -1
  52. package/dist/paywall/license-panel.d.ts.map +1 -1
  53. package/dist/paywall/renderer.d.ts +16 -2
  54. package/dist/paywall/renderer.d.ts.map +1 -1
  55. package/dist/paywall/seller-details.d.ts +2 -1
  56. package/dist/paywall/seller-details.d.ts.map +1 -1
  57. package/dist/paywall/strings.d.ts +6 -4
  58. package/dist/paywall/strings.d.ts.map +1 -1
  59. package/dist/paywall.d.mts +93 -7
  60. package/dist/paywall.d.ts +93 -7
  61. package/dist/paywall.js +992 -41
  62. package/dist/paywall.js.map +1 -1
  63. package/dist/paywall.mjs +990 -42
  64. package/dist/paywall.mjs.map +1 -1
  65. package/dist/types/config.d.ts +6 -1
  66. package/dist/types/config.d.ts.map +1 -1
  67. package/dist/types/contract.d.ts +25 -0
  68. package/dist/types/contract.d.ts.map +1 -1
  69. package/dist/types/entitlement.d.ts +22 -0
  70. package/dist/types/entitlement.d.ts.map +1 -1
  71. package/dist/types/errors.d.ts +1 -0
  72. package/dist/types/errors.d.ts.map +1 -1
  73. package/dist/types/paywall.d.ts +15 -2
  74. package/dist/types/paywall.d.ts.map +1 -1
  75. package/dist/version.d.ts +1 -1
  76. package/package.json +2 -2
  77. package/dist/core.esm.js +0 -1681
  78. package/dist/core.esm.js.map +0 -1
  79. package/dist/extenshi-pay-lite.esm.js +0 -1664
  80. package/dist/extenshi-pay-lite.esm.js.map +0 -1
  81. package/dist/extenshi-pay.esm.js +0 -2496
  82. package/dist/extenshi-pay.esm.js.map +0 -1
  83. package/dist/extenshi-pay.esm.min.js +0 -7
  84. package/dist/extenshi-pay.esm.min.js.map +0 -1
  85. package/dist/paywall.esm.js +0 -442
  86. package/dist/paywall.esm.js.map +0 -1
@@ -1,2496 +0,0 @@
1
- /*!
2
- * ExtenshiPay SDK v0.7.0
3
- * (c) 2026 Extenshi.io
4
- * Released under the MIT License.
5
- */
6
- /**
7
- * Wire contract between the SDK and catalog-bff `pay.*`.
8
- *
9
- * SOURCE OF TRUTH: `shared-types/pay.ts` in the extenshi.io monorepo. The SDK
10
- * ships with zero runtime dependencies and must not import that workspace, so
11
- * the types and constants it needs are copied here under identical names.
12
- * `canonicalJson` is copied VERBATIM: the BFF signs its output and the SDK
13
- * verifies it, so both sides must produce byte-identical strings
14
- * (pinned by tests/unit/canonical-json.test.ts). When `shared-types/pay.ts`
15
- * changes, mirror the change here.
16
- */
17
- /** Bumped only when an older SDK could misread the response. */
18
- const PAY_CONTRACT_VERSION = 1;
19
- const PAY_GATEWAYS = ['stripe', 'paddle', 'lemonsqueezy'];
20
- // ─── Publishable key ────────────────────────────────────────────────────────
21
- /**
22
- * The only credential an extension bundle carries. It is public by
23
- * construction (anyone can unzip the .crx), so it must grant nothing beyond
24
- * "read this project's offer" and "start a checkout for this project".
25
- */
26
- const PAY_PUBLISHABLE_KEY_PREFIX = 'pk_ext_';
27
- const PAY_PUBLISHABLE_KEY_HEX_LENGTH = 32;
28
- const PUBLISHABLE_KEY_RE = new RegExp(`^${PAY_PUBLISHABLE_KEY_PREFIX}[0-9a-f]{${PAY_PUBLISHABLE_KEY_HEX_LENGTH}}$`);
29
- function isPayPublishableKey(value) {
30
- return typeof value === 'string' && PUBLISHABLE_KEY_RE.test(value);
31
- }
32
- // ─── Offers ─────────────────────────────────────────────────────────────────
33
- const PAY_OFFER_KINDS = ['one_time', 'subscription', 'lifetime'];
34
- const PAY_OFFER_INTERVALS = ['month', 'year'];
35
- /** ISO-4217 lowercase, matching what every gateway returns. */
36
- const PAY_CURRENCIES = ['usd', 'eur', 'gbp'];
37
- /** `sku` is author-chosen and stable; it is what `requireFeature()` keys on. */
38
- const PAY_SKU_RE = /^[a-z0-9][a-z0-9_-]{1,39}$/;
39
- // ─── Projection ─────────────────────────────────────────────────────────────
40
- /**
41
- * active — paid and not expired
42
- * grace — subscription past_due: keep access for a short window so a card
43
- * hiccup does not lock a paying user out mid-session
44
- * expired — was active, no longer is
45
- * none — never had it
46
- */
47
- const PAY_ENTITLEMENT_STATUSES = ['active', 'grace', 'expired', 'none'];
48
- /**
49
- * The `endUserRef` an SDK mints on first run and keeps in `chrome.storage`.
50
- * Opaque, random, never derived from anything identifying.
51
- */
52
- const PAY_END_USER_REF_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
53
- /** Typed error codes the BFF throws; dojo and the SDK match on `cause.code`. */
54
- const PAY_ERRORS = {
55
- SELLER_NOT_CONNECTED: 'PAY_SELLER_NOT_CONNECTED',
56
- SELLER_NOT_ACTIVE: 'PAY_SELLER_NOT_ACTIVE',
57
- AGREEMENT_REQUIRED: 'PAY_AGREEMENT_REQUIRED',
58
- OFFER_NOT_FOUND: 'PAY_OFFER_NOT_FOUND',
59
- OFFER_LIMIT: 'PAY_OFFER_LIMIT',
60
- PRICE_TOO_LOW: 'PAY_PRICE_TOO_LOW',
61
- GATEWAY_UNAVAILABLE: 'PAY_GATEWAY_UNAVAILABLE',
62
- RATE_LIMITED: 'PAY_RATE_LIMITED',
63
- INVALID_KEY: 'PAY_INVALID_KEY',
64
- };
65
- /**
66
- * Canonical JSON for signing: keys sorted recursively, no whitespace. Both
67
- * the BFF (sign) and the SDK (verify) must produce byte-identical output for
68
- * the same payload, so the rule lives in the shared contract.
69
- */
70
- function canonicalJson(value) {
71
- if (value === null || typeof value !== 'object')
72
- return JSON.stringify(value);
73
- if (Array.isArray(value))
74
- return `[${value.map((item) => canonicalJson(item)).join(',')}]`;
75
- const entries = Object.entries(value)
76
- .filter(([, v]) => v !== undefined)
77
- .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
78
- return `{${entries.map(([k, v]) => `${JSON.stringify(k)}:${canonicalJson(v)}`).join(',')}}`;
79
- }
80
-
81
- const ERROR_CODES = {
82
- INVALID_CONFIG: 'INVALID_CONFIG',
83
- INVALID_REQUEST: 'INVALID_REQUEST',
84
- NETWORK_ERROR: 'NETWORK_ERROR',
85
- TIMEOUT: 'TIMEOUT',
86
- INVALID_RESPONSE: 'INVALID_RESPONSE',
87
- RATE_LIMITED: 'RATE_LIMITED',
88
- INVALID_KEY: 'INVALID_KEY',
89
- SELLER_NOT_ACTIVE: 'SELLER_NOT_ACTIVE',
90
- OFFER_NOT_FOUND: 'OFFER_NOT_FOUND',
91
- GATEWAY_UNAVAILABLE: 'GATEWAY_UNAVAILABLE',
92
- CHECKOUT_UNAVAILABLE: 'CHECKOUT_UNAVAILABLE',
93
- PAYWALL_UNAVAILABLE: 'PAYWALL_UNAVAILABLE',
94
- UNKNOWN: 'UNKNOWN',
95
- };
96
- class ExtenshiPayError extends Error {
97
- constructor(code, message, options = {}) {
98
- super(message);
99
- this.name = 'ExtenshiPayError';
100
- this.code = code;
101
- this.retryAfterSec = options.retryAfterSec;
102
- this.httpStatus = options.httpStatus;
103
- this.cause = options.cause;
104
- }
105
- static from(error, fallback = ERROR_CODES.UNKNOWN) {
106
- if (error instanceof ExtenshiPayError)
107
- return error;
108
- const message = error instanceof Error ? error.message : String(error);
109
- return new ExtenshiPayError(fallback, message, { cause: error });
110
- }
111
- }
112
-
113
- /**
114
- * `endUserRef` — the only identity the SDK has.
115
- *
116
- * A random UUID minted on first run and kept in the SDK's storage namespace.
117
- * It is never derived from anything identifying (no fingerprint, no e-mail,
118
- * no extension-supplied user id) and remains the installation identifier. Explicit recovery also sends a
119
- * random session ID and proof; it never derives identity from an email locally.
120
- */
121
- const END_USER_REF_STORAGE_KEY = 'extenshi-pay:endUserRef';
122
- function mintEndUserRef() {
123
- const cryptoApi = globalThis.crypto;
124
- if (!cryptoApi) {
125
- throw new ExtenshiPayError(ERROR_CODES.UNKNOWN, 'Web Crypto is not available in this context');
126
- }
127
- if (typeof cryptoApi.randomUUID === 'function')
128
- return cryptoApi.randomUUID();
129
- const bytes = cryptoApi.getRandomValues(new Uint8Array(16));
130
- bytes[6] = (bytes[6] & 0x0f) | 0x40;
131
- bytes[8] = (bytes[8] & 0x3f) | 0x80;
132
- const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
133
- return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
134
- }
135
- async function getOrCreateEndUserRef(storage) {
136
- const existing = await storage.get(END_USER_REF_STORAGE_KEY);
137
- if (typeof existing === 'string' && PAY_END_USER_REF_RE.test(existing))
138
- return existing;
139
- const ref = mintEndUserRef();
140
- await storage.set(END_USER_REF_STORAGE_KEY, ref);
141
- return ref;
142
- }
143
-
144
- /**
145
- * In-memory stand-in for the BFF, used when `mock: true`. Lets an extension be
146
- * developed with no backend: offers and entitlements come from `mockData`, a
147
- * mock checkout completes after `claimAfterPolls` polls and grants the SKU.
148
- */
149
- const DAY_MS = 24 * 60 * 60 * 1000;
150
- class MockTransport {
151
- constructor(data = {}) {
152
- this.sessions = new Map();
153
- this.entitlements = [...(data.entitlements ?? [])];
154
- this.offers = [...(data.offers ?? [])];
155
- this.projectName = data.projectName ?? 'Mock project';
156
- this.checkoutEnabled = data.checkoutEnabled ?? true;
157
- this.claimAfterPolls = data.claimAfterPolls ?? 1;
158
- }
159
- async call(procedure, _kind, input) {
160
- switch (procedure) {
161
- case 'pay.getOffer':
162
- return this.offerResponse();
163
- case 'pay.createCheckout':
164
- return this.createCheckout(String(input.sku));
165
- case 'pay.claimSession':
166
- return this.claim(String(input.sessionId), String(input.endUserRef));
167
- case 'pay.getEntitlement':
168
- return this.envelope(String(input.endUserRef));
169
- case 'pay.getPortalUrl':
170
- return { url: this.entitlements.length > 0 ? 'https://mock.extenshi.io/portal' : null };
171
- default:
172
- throw new ExtenshiPayError(ERROR_CODES.INVALID_REQUEST, `Unknown procedure ${procedure}`);
173
- }
174
- }
175
- /** Test/dev helpers. */
176
- setEntitlements(items) {
177
- this.entitlements = [...items];
178
- }
179
- cancelSession(sessionId) {
180
- const session = this.sessions.get(sessionId);
181
- if (session)
182
- session.state = 'canceled';
183
- }
184
- expireSession(sessionId) {
185
- const session = this.sessions.get(sessionId);
186
- if (session)
187
- session.state = 'expired';
188
- }
189
- offerResponse() {
190
- return {
191
- v: PAY_CONTRACT_VERSION,
192
- projectName: this.projectName,
193
- provider: 'stripe',
194
- checkoutEnabled: this.checkoutEnabled && this.offers.length > 0,
195
- offers: [...this.offers],
196
- entitlementPublicKey: null,
197
- };
198
- }
199
- createCheckout(sku) {
200
- if (!this.checkoutEnabled) {
201
- throw new ExtenshiPayError(ERROR_CODES.SELLER_NOT_ACTIVE, 'Mock seller cannot take payments');
202
- }
203
- if (!this.offers.some((offer) => offer.sku === sku)) {
204
- throw new ExtenshiPayError(ERROR_CODES.OFFER_NOT_FOUND, `Unknown mock offer ${sku}`);
205
- }
206
- const sessionId = mintEndUserRef();
207
- this.sessions.set(sessionId, { sku, polls: 0, state: 'open' });
208
- return {
209
- url: `https://mock.extenshi.io/checkout/${sessionId}`,
210
- sessionId,
211
- expiresAt: new Date(Date.now() + 30 * 60 * 1000).toISOString(),
212
- };
213
- }
214
- claim(sessionId, endUserRef) {
215
- const session = this.sessions.get(sessionId);
216
- if (!session)
217
- throw new ExtenshiPayError(ERROR_CODES.CHECKOUT_UNAVAILABLE, 'Unknown checkout session');
218
- if (session.state === 'canceled')
219
- return { state: 'canceled' };
220
- if (session.state === 'expired')
221
- return { state: 'expired' };
222
- if (session.state === 'open') {
223
- session.polls += 1;
224
- if (session.polls <= this.claimAfterPolls)
225
- return { state: 'pending' };
226
- session.state = 'complete';
227
- this.grant(session.sku);
228
- }
229
- return { state: 'complete', entitlement: this.envelope(endUserRef) };
230
- }
231
- grant(sku) {
232
- const offer = this.offers.find((o) => o.sku === sku);
233
- const expiresAt = offer?.kind === 'subscription'
234
- ? new Date(Date.now() + (offer.interval === 'year' ? 365 : 30) * DAY_MS).toISOString()
235
- : null;
236
- this.entitlements = [
237
- ...this.entitlements.filter((item) => item.sku !== sku),
238
- {
239
- sku,
240
- title: offer?.title,
241
- kind: offer?.kind,
242
- status: 'active',
243
- expiresAt,
244
- features: offer?.features ?? [],
245
- },
246
- ];
247
- }
248
- envelope(endUserRef) {
249
- return {
250
- payload: {
251
- v: PAY_CONTRACT_VERSION,
252
- endUserRef,
253
- entitlements: [...this.entitlements],
254
- issuedAt: new Date().toISOString(),
255
- },
256
- signature: null,
257
- alg: null,
258
- };
259
- }
260
- }
261
-
262
- /** Typed wrapper over the SDK-facing `pay.*` procedures. Nothing else is ever called. */
263
- class PayApi {
264
- constructor(transport, publishableKey) {
265
- this.transport = transport;
266
- this.publishableKey = publishableKey;
267
- }
268
- createRestoreSession(claimChallenge) {
269
- return this.transport.call('pay.createRestoreSession', 'mutation', {
270
- publishableKey: this.publishableKey,
271
- claimChallenge,
272
- });
273
- }
274
- claimRestoreSession(sessionId, claimSecret) {
275
- return this.transport.call('pay.claimRestoreSession', 'mutation', {
276
- publishableKey: this.publishableKey,
277
- sessionId,
278
- claimSecret,
279
- });
280
- }
281
- getOffer(locale) {
282
- return this.transport.call('pay.getOffer', 'query', {
283
- publishableKey: this.publishableKey,
284
- locale: locale ?? undefined,
285
- });
286
- }
287
- createCheckout(sku, endUserRef, locale) {
288
- return this.transport.call('pay.createCheckout', 'mutation', {
289
- publishableKey: this.publishableKey,
290
- sku,
291
- endUserRef,
292
- locale: locale ?? undefined,
293
- });
294
- }
295
- claimSession(sessionId, endUserRef) {
296
- return this.transport.call('pay.claimSession', 'query', {
297
- publishableKey: this.publishableKey,
298
- sessionId,
299
- endUserRef,
300
- });
301
- }
302
- getEntitlement(endUserRef) {
303
- return this.transport.call('pay.getEntitlement', 'query', {
304
- publishableKey: this.publishableKey,
305
- endUserRef,
306
- });
307
- }
308
- getPortalUrl(endUserRef, customerId) {
309
- return this.transport.call('pay.getPortalUrl', 'mutation', {
310
- publishableKey: this.publishableKey,
311
- endUserRef,
312
- ...(customerId ? { customerId } : {}),
313
- });
314
- }
315
- }
316
-
317
- const ORDER = { silent: 0, error: 1, warn: 2, info: 3, debug: 4 };
318
- class Logger {
319
- constructor() {
320
- this.level = 'warn';
321
- this.prefix = '[ExtenshiPay]';
322
- }
323
- configure(options) {
324
- if (options.logLevel)
325
- this.level = options.logLevel;
326
- if (options.debug)
327
- this.level = 'debug';
328
- }
329
- error(message, ...args) {
330
- if (this.enabled('error'))
331
- console.error(this.prefix, message, ...args);
332
- }
333
- warn(message, ...args) {
334
- if (this.enabled('warn'))
335
- console.warn(this.prefix, message, ...args);
336
- }
337
- info(message, ...args) {
338
- if (this.enabled('info'))
339
- console.info(this.prefix, message, ...args);
340
- }
341
- debug(message, ...args) {
342
- if (this.enabled('debug'))
343
- console.debug(this.prefix, message, ...args);
344
- }
345
- enabled(level) {
346
- return ORDER[level] <= ORDER[this.level];
347
- }
348
- }
349
- const logger = new Logger();
350
-
351
- /**
352
- * HTTP transport for the BFF's tRPC endpoint (`/api/trpc/<procedure>`).
353
- *
354
- * Queries are header-less GETs with `?input=<json>` (a CORS "simple request",
355
- * so no preflight); mutations POST a JSON body. The only things that leave the
356
- * extension are payment inputs and optional recovery session/proof inputs
357
- * and the browser's standard headers — `credentials: 'omit'` keeps cookies out.
358
- * Queries are retried on network / 5xx errors; mutations never are.
359
- */
360
- const TRPC_PATH = '/api/trpc';
361
- const DEFAULT_TIMEOUT_MS = 10000;
362
- const DEFAULT_RETRIES = 1;
363
- const RETRY_BASE_MS = 500;
364
- const RETRYABLE = new Set([
365
- ERROR_CODES.NETWORK_ERROR,
366
- ERROR_CODES.TIMEOUT,
367
- ERROR_CODES.GATEWAY_UNAVAILABLE,
368
- ]);
369
- /** `PAY_*` cause codes, when the BFF forwards them, map 1:1. */
370
- const CAUSE_TO_CODE = {
371
- [PAY_ERRORS.RATE_LIMITED]: ERROR_CODES.RATE_LIMITED,
372
- [PAY_ERRORS.INVALID_KEY]: ERROR_CODES.INVALID_KEY,
373
- [PAY_ERRORS.SELLER_NOT_CONNECTED]: ERROR_CODES.SELLER_NOT_ACTIVE,
374
- [PAY_ERRORS.SELLER_NOT_ACTIVE]: ERROR_CODES.SELLER_NOT_ACTIVE,
375
- [PAY_ERRORS.AGREEMENT_REQUIRED]: ERROR_CODES.SELLER_NOT_ACTIVE,
376
- [PAY_ERRORS.OFFER_NOT_FOUND]: ERROR_CODES.OFFER_NOT_FOUND,
377
- [PAY_ERRORS.GATEWAY_UNAVAILABLE]: ERROR_CODES.GATEWAY_UNAVAILABLE,
378
- };
379
- function parseRetryAfter(message) {
380
- const match = /retry in (\d+)s/i.exec(message);
381
- return match ? Number(match[1]) : undefined;
382
- }
383
- /**
384
- * The BFF's error formatter does not forward `cause` for `pay.*` errors, so the
385
- * tRPC code + message is the primary signal; `data.cause.code` is honoured when
386
- * present so a future BFF that forwards it needs no SDK change.
387
- */
388
- function trpcErrorToPayError(error, httpStatus) {
389
- const message = error.message ?? 'Request failed';
390
- const trpcCode = error.data?.code ?? '';
391
- const causeCode = error.data?.cause?.code;
392
- const retryAfterSec = error.data?.cause?.retryAfterSec ?? parseRetryAfter(message);
393
- const options = { retryAfterSec, httpStatus: error.data?.httpStatus ?? httpStatus };
394
- const mapped = causeCode ? CAUSE_TO_CODE[causeCode] : undefined;
395
- if (mapped)
396
- return new ExtenshiPayError(mapped, message, options);
397
- switch (trpcCode) {
398
- case 'TOO_MANY_REQUESTS':
399
- return new ExtenshiPayError(ERROR_CODES.RATE_LIMITED, message, options);
400
- case 'NOT_FOUND':
401
- if (/publishable key/i.test(message))
402
- return new ExtenshiPayError(ERROR_CODES.INVALID_KEY, message, options);
403
- if (/session/i.test(message))
404
- return new ExtenshiPayError(ERROR_CODES.CHECKOUT_UNAVAILABLE, message, options);
405
- return new ExtenshiPayError(ERROR_CODES.OFFER_NOT_FOUND, message, options);
406
- case 'PRECONDITION_FAILED':
407
- return new ExtenshiPayError(ERROR_CODES.SELLER_NOT_ACTIVE, message, options);
408
- case 'BAD_REQUEST':
409
- return new ExtenshiPayError(ERROR_CODES.INVALID_REQUEST, message, options);
410
- case 'INTERNAL_SERVER_ERROR':
411
- return new ExtenshiPayError(ERROR_CODES.GATEWAY_UNAVAILABLE, message, options);
412
- default:
413
- return new ExtenshiPayError(ERROR_CODES.UNKNOWN, message, options);
414
- }
415
- }
416
- function sleep(ms) {
417
- return new Promise((resolve) => setTimeout(resolve, ms));
418
- }
419
- class HttpTransport {
420
- constructor(options) {
421
- this.apiUrl = options.apiUrl.replace(/\/+$/, '');
422
- this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
423
- this.retries = options.retries ?? DEFAULT_RETRIES;
424
- this.fetchImpl = options.fetchImpl ?? ((input, init) => fetch(input, init));
425
- }
426
- async call(procedure, kind, input) {
427
- const base = `${this.apiUrl}${TRPC_PATH}/${procedure}`;
428
- const url = kind === 'query' ? `${base}?input=${encodeURIComponent(JSON.stringify(input))}` : base;
429
- const attempts = kind === 'query' ? this.retries + 1 : 1;
430
- let lastError = null;
431
- for (let attempt = 0; attempt < attempts; attempt++) {
432
- try {
433
- return await this.request(url, kind, input);
434
- }
435
- catch (error) {
436
- const err = ExtenshiPayError.from(error);
437
- if (!RETRYABLE.has(err.code) || attempt === attempts - 1)
438
- throw err;
439
- lastError = err;
440
- logger.debug(`${procedure} failed (${err.code}), retrying`);
441
- await sleep(RETRY_BASE_MS * 2 ** attempt);
442
- }
443
- }
444
- throw lastError ?? new ExtenshiPayError(ERROR_CODES.UNKNOWN, `${procedure} failed`);
445
- }
446
- async request(url, kind, input) {
447
- const controller = typeof AbortController === 'function' ? new AbortController() : null;
448
- const timer = controller ? setTimeout(() => controller.abort(), this.timeoutMs) : null;
449
- let response;
450
- try {
451
- response = await this.fetchImpl(url, {
452
- method: kind === 'query' ? 'GET' : 'POST',
453
- headers: kind === 'mutation' ? { 'Content-Type': 'application/json' } : undefined,
454
- body: kind === 'mutation' ? JSON.stringify(input) : undefined,
455
- signal: controller?.signal,
456
- credentials: 'omit',
457
- });
458
- }
459
- catch (error) {
460
- if (controller?.signal.aborted) {
461
- throw new ExtenshiPayError(ERROR_CODES.TIMEOUT, `Request timed out after ${this.timeoutMs}ms`);
462
- }
463
- throw new ExtenshiPayError(ERROR_CODES.NETWORK_ERROR, 'Network request failed', { cause: error });
464
- }
465
- finally {
466
- if (timer !== null)
467
- clearTimeout(timer);
468
- }
469
- let body = null;
470
- try {
471
- body = (await response.json());
472
- }
473
- catch {
474
- body = null;
475
- }
476
- if (body?.error)
477
- throw trpcErrorToPayError(body.error, response.status);
478
- if (!response.ok) {
479
- const code = response.status >= 500 ? ERROR_CODES.GATEWAY_UNAVAILABLE : ERROR_CODES.INVALID_RESPONSE;
480
- throw new ExtenshiPayError(code, `HTTP ${response.status}`, { httpStatus: response.status });
481
- }
482
- if (!body?.result || !('data' in body.result)) {
483
- throw new ExtenshiPayError(ERROR_CODES.INVALID_RESPONSE, 'Malformed response from the payment backend');
484
- }
485
- return body.result.data;
486
- }
487
- }
488
-
489
- /**
490
- * Hosted checkout flow.
491
- *
492
- * `pay.createCheckout` returns a URL on the seller's provider; the SDK opens
493
- * it in a new tab (`chrome.tabs.create`, falling back to `window.open`) and
494
- * polls `pay.claimSession` every 2 s for up to 10 min — and immediately when
495
- * the extension regains focus — until the webhook has landed. A pending
496
- * session is persisted so a restarted service worker / reopened popup can
497
- * finish the claim on the next `initialize()`.
498
- */
499
- const CHECKOUT_POLL_INTERVAL_MS = 2000;
500
- const CHECKOUT_TIMEOUT_MS = 10 * 60 * 1000;
501
- const MAX_ERROR_BACKOFF_MS = 30000;
502
- /** How long after `expiresAt` a persisted session is still worth one claim (webhook lag). */
503
- const PENDING_GRACE_MS = 60 * 60 * 1000;
504
- async function openInNewTab(url) {
505
- const g = globalThis;
506
- const tabs = g.chrome?.tabs ?? g.browser?.tabs;
507
- if (tabs && typeof tabs.create === 'function') {
508
- const result = tabs.create({ url });
509
- if (result && typeof result.then === 'function')
510
- await result;
511
- return;
512
- }
513
- if (typeof g.open === 'function') {
514
- g.open(url, '_blank', 'noopener,noreferrer');
515
- return;
516
- }
517
- throw new ExtenshiPayError(ERROR_CODES.CHECKOUT_UNAVAILABLE, 'Cannot open a checkout tab from this context');
518
- }
519
- /** Calls `onFocus` whenever the extension window/tab regains focus; returns a disposer. */
520
- function onFocusRegained(onFocus) {
521
- const g = globalThis;
522
- const disposers = [];
523
- if (typeof g.addEventListener === 'function' && typeof g.removeEventListener === 'function') {
524
- g.addEventListener('focus', onFocus);
525
- disposers.push(() => g.removeEventListener?.('focus', onFocus));
526
- }
527
- const doc = g.document;
528
- if (doc && typeof doc.addEventListener === 'function') {
529
- const onVisible = () => {
530
- if (doc.visibilityState === 'visible')
531
- onFocus();
532
- };
533
- doc.addEventListener('visibilitychange', onVisible);
534
- disposers.push(() => doc.removeEventListener('visibilitychange', onVisible));
535
- }
536
- const windows = g.chrome?.windows?.onFocusChanged;
537
- if (windows && typeof windows.addListener === 'function') {
538
- const onWindow = (windowId) => {
539
- if (windowId !== -1)
540
- onFocus();
541
- };
542
- windows.addListener(onWindow);
543
- disposers.push(() => windows.removeListener(onWindow));
544
- }
545
- return () => {
546
- for (const dispose of disposers)
547
- dispose();
548
- };
549
- }
550
- /** A sleep that can be cut short by `wake()`. */
551
- function interruptibleSleep() {
552
- let wake = null;
553
- return {
554
- sleep(ms) {
555
- return new Promise((resolve) => {
556
- const timer = setTimeout(() => {
557
- wake = null;
558
- resolve();
559
- }, ms);
560
- wake = () => {
561
- clearTimeout(timer);
562
- wake = null;
563
- resolve();
564
- };
565
- });
566
- },
567
- wake() {
568
- wake?.();
569
- },
570
- };
571
- }
572
- class CheckoutManager {
573
- constructor(options) {
574
- this.options = options;
575
- this.active = null;
576
- this.now = options.now ?? (() => Date.now());
577
- }
578
- get pendingKey() {
579
- return `extenshi-pay:${this.options.publishableKey}:pendingCheckout`;
580
- }
581
- isActive() {
582
- return this.active !== null;
583
- }
584
- async open(sku, options = {}) {
585
- if (this.active) {
586
- throw new ExtenshiPayError(ERROR_CODES.CHECKOUT_UNAVAILABLE, 'A checkout is already in progress');
587
- }
588
- const endUserRef = await this.options.getEndUserRef();
589
- const session = await this.options.api.createCheckout(sku, endUserRef, options.locale ?? this.options.locale);
590
- this.active = session.sessionId;
591
- try {
592
- const pending = { sessionId: session.sessionId, sku, expiresAt: session.expiresAt };
593
- await this.options.storage.set(this.pendingKey, pending);
594
- this.options.emit('checkout:started', { sku, sessionId: session.sessionId, url: session.url });
595
- await (options.openUrl ?? this.options.openUrl ?? openInNewTab)(session.url);
596
- return await this.poll(sku, session.sessionId, endUserRef, options);
597
- }
598
- finally {
599
- this.active = null;
600
- }
601
- }
602
- /** Finishes a checkout that was started before a restart; null when there is nothing to resume. */
603
- async resumePending() {
604
- const raw = (await this.options.storage.get(this.pendingKey));
605
- if (!raw || typeof raw.sessionId !== 'string' || typeof raw.sku !== 'string')
606
- return null;
607
- const expires = Date.parse(raw.expiresAt ?? '');
608
- if (!Number.isFinite(expires) || expires + PENDING_GRACE_MS < this.now()) {
609
- await this.options.storage.remove(this.pendingKey);
610
- return null;
611
- }
612
- const endUserRef = await this.options.getEndUserRef();
613
- let claim;
614
- try {
615
- claim = await this.options.api.claimSession(raw.sessionId, endUserRef);
616
- }
617
- catch (error) {
618
- logger.debug('could not resume pending checkout', error);
619
- return null;
620
- }
621
- return this.settle(claim, raw.sku, raw.sessionId);
622
- }
623
- async poll(sku, sessionId, endUserRef, options) {
624
- const interval = options.pollIntervalMs ?? CHECKOUT_POLL_INTERVAL_MS;
625
- const deadline = this.now() + (options.timeoutMs ?? CHECKOUT_TIMEOUT_MS);
626
- const sleeper = interruptibleSleep();
627
- const stopFocus = onFocusRegained(() => sleeper.wake());
628
- let delay = interval;
629
- let errorBackoff = 0;
630
- try {
631
- for (;;) {
632
- await sleeper.sleep(delay);
633
- if (this.now() >= deadline)
634
- return { state: 'timeout', sku, sessionId };
635
- let claim;
636
- try {
637
- claim = await this.options.api.claimSession(sessionId, endUserRef);
638
- }
639
- catch (error) {
640
- const err = ExtenshiPayError.from(error);
641
- if (err.code === ERROR_CODES.RATE_LIMITED) {
642
- delay = (err.retryAfterSec ?? 5) * 1000;
643
- }
644
- else if (err.code === ERROR_CODES.NETWORK_ERROR ||
645
- err.code === ERROR_CODES.TIMEOUT ||
646
- err.code === ERROR_CODES.GATEWAY_UNAVAILABLE) {
647
- errorBackoff = Math.min(errorBackoff ? errorBackoff * 2 : interval, MAX_ERROR_BACKOFF_MS);
648
- delay = errorBackoff;
649
- }
650
- else {
651
- await this.options.storage.remove(this.pendingKey);
652
- throw err;
653
- }
654
- continue;
655
- }
656
- errorBackoff = 0;
657
- delay = interval;
658
- const result = await this.settle(claim, sku, sessionId);
659
- if (result)
660
- return result;
661
- }
662
- }
663
- finally {
664
- stopFocus();
665
- }
666
- }
667
- async settle(claim, sku, sessionId) {
668
- switch (claim.state) {
669
- case 'pending':
670
- return null;
671
- case 'complete': {
672
- const entitlement = await this.options.onComplete(claim.entitlement);
673
- await this.options.storage.remove(this.pendingKey);
674
- this.options.emit('checkout:completed', { sku, sessionId, entitlement });
675
- return { state: 'complete', sku, sessionId, entitlement };
676
- }
677
- case 'canceled':
678
- await this.options.storage.remove(this.pendingKey);
679
- this.options.emit('checkout:canceled', { sku, sessionId });
680
- return { state: 'canceled', sku, sessionId };
681
- case 'expired':
682
- await this.options.storage.remove(this.pendingKey);
683
- this.options.emit('checkout:expired', { sku, sessionId });
684
- return { state: 'expired', sku, sessionId };
685
- default:
686
- throw new ExtenshiPayError(ERROR_CODES.INVALID_RESPONSE, 'Unknown checkout claim state');
687
- }
688
- }
689
- }
690
-
691
- var checkout = /*#__PURE__*/Object.freeze({
692
- __proto__: null,
693
- CHECKOUT_POLL_INTERVAL_MS: CHECKOUT_POLL_INTERVAL_MS,
694
- CHECKOUT_TIMEOUT_MS: CHECKOUT_TIMEOUT_MS,
695
- CheckoutManager: CheckoutManager,
696
- openInNewTab: openInNewTab
697
- });
698
-
699
- /** Pure helpers over the entitlement projection. Features come from the items' `features[]`. */
700
- const LIVE_STATUSES = new Set(['active', 'grace']);
701
- function isLive(item) {
702
- return LIVE_STATUSES.has(item.status);
703
- }
704
- /** An item past its `expiresAt` reads as expired without a network round-trip. */
705
- function applyLocalExpiry(items, now = Date.now()) {
706
- return items.map((item) => {
707
- if (!isLive(item) || !item.expiresAt)
708
- return item;
709
- const expires = Date.parse(item.expiresAt);
710
- return Number.isFinite(expires) && expires <= now ? { ...item, status: 'expired' } : item;
711
- });
712
- }
713
- function collectFeatures(items) {
714
- const features = new Set();
715
- for (const item of items) {
716
- if (!isLive(item))
717
- continue;
718
- for (const feature of item.features)
719
- features.add(feature);
720
- }
721
- return [...features];
722
- }
723
- function isEntitled(entitlement, sku) {
724
- return (!entitlement.requiresOnlineCheck &&
725
- entitlement.items.some((item) => isLive(item) && (sku === undefined || item.sku === sku)));
726
- }
727
- function hasFeature(entitlement, feature) {
728
- return entitlement.features.includes(feature);
729
- }
730
- function checkFeatures(entitlement, features) {
731
- const result = {};
732
- for (const feature of features)
733
- result[feature] = hasFeature(entitlement, feature);
734
- return result;
735
- }
736
- const EMPTY_ENTITLEMENT = Object.freeze({
737
- items: [],
738
- features: [],
739
- verified: false,
740
- issuedAt: null,
741
- fetchedAt: null,
742
- source: 'none',
743
- requiresOnlineCheck: false,
744
- offlineUntil: null,
745
- });
746
-
747
- /**
748
- * Ed25519 verification of the entitlement projection.
749
- *
750
- * Tamper resistance, not DRM: it stops "edit chrome.storage.local and unlock
751
- * the feature". The public key comes from `pay.getOffer` and is kept in memory
752
- * only. On browsers without Ed25519 in WebCrypto (Chrome < 113, Firefox < 130)
753
- * the envelope is accepted but reported as `unverified`; a signature that
754
- * fails to verify is `invalid` and must be discarded by the caller.
755
- */
756
- function base64ToBytes(base64) {
757
- const binary = atob(base64);
758
- const bytes = new Uint8Array(binary.length);
759
- for (let i = 0; i < binary.length; i++)
760
- bytes[i] = binary.charCodeAt(i);
761
- return bytes;
762
- }
763
- async function verifyEntitlementSignature(envelope, publicKeyBase64) {
764
- if (!envelope.signature || envelope.alg !== 'ed25519' || !publicKeyBase64)
765
- return 'unverified';
766
- const subtle = globalThis.crypto?.subtle;
767
- if (!subtle)
768
- return 'unverified';
769
- let key;
770
- try {
771
- key = await subtle.importKey('raw', base64ToBytes(publicKeyBase64), { name: 'Ed25519' }, false, [
772
- 'verify',
773
- ]);
774
- }
775
- catch {
776
- return 'unverified';
777
- }
778
- try {
779
- const data = new TextEncoder().encode(canonicalJson(envelope.payload));
780
- const ok = await subtle.verify('Ed25519', key, base64ToBytes(envelope.signature), data);
781
- return ok ? 'valid' : 'invalid';
782
- }
783
- catch {
784
- return 'invalid';
785
- }
786
- }
787
-
788
- /**
789
- * Entitlement cache + refresh.
790
- *
791
- * The cached envelope is a cache OF the server projection, never a second
792
- * source of truth: it is verified when stored and re-verified on load (once
793
- * the project's public key is known), served without a round-trip while the
794
- * TTL holds, served for up to 48 hours when the network is down, and expired
795
- * locally by `expiresAt`. Background refresh polls at most every 15 minutes
796
- * and backs off exponentially on errors.
797
- */
798
- const MIN_REFRESH_INTERVAL_MS = 15 * 60 * 1000;
799
- const MAX_REFRESH_BACKOFF_MS = 6 * 60 * 60 * 1000;
800
- const MAX_OFFLINE_AGE_MS = 48 * 60 * 60 * 1000;
801
- const CACHE_VERSION = 1;
802
- function isEnvelope(value) {
803
- if (!value || typeof value !== 'object')
804
- return false;
805
- const env = value;
806
- return (!!env.payload &&
807
- typeof env.payload === 'object' &&
808
- typeof env.payload.endUserRef === 'string' &&
809
- Array.isArray(env.payload.entitlements) &&
810
- typeof env.payload.issuedAt === 'string');
811
- }
812
- class EntitlementManager {
813
- constructor(options) {
814
- this.options = options;
815
- this.held = null;
816
- this.inflight = null;
817
- this.timer = null;
818
- this.refreshGeneration = 0;
819
- this.deadlineTimer = null;
820
- this.refreshIntervalMs = MIN_REFRESH_INTERVAL_MS;
821
- this.backoffMs = 0;
822
- this.autoRefresh = false;
823
- this.online = () => {
824
- void this.get({ force: true }).then(() => this.notifyIfChanged());
825
- };
826
- // Starts at the empty projection: a first load that finds nothing is not a
827
- // change, a first load that finds a paid entitlement is.
828
- this.lastFingerprint = canonicalJson({ items: [], requiresOnlineCheck: false });
829
- this.now = options.now ?? (() => Date.now());
830
- this.source = options.source ?? 'network';
831
- }
832
- get storageKey() {
833
- // Keep the real cache key stable for upgrades. Simulated grants must
834
- // neither consume nor overwrite that cache when developers switch modes.
835
- return `extenshi-pay:${this.options.publishableKey}:entitlement${this.source === 'mock' ? ':mock' : ''}`;
836
- }
837
- /** Loads the persisted envelope (unverified until `reverify()`); no network. */
838
- async load() {
839
- const raw = await this.options.storage.get(this.storageKey);
840
- const record = raw;
841
- if (!record ||
842
- record.v !== CACHE_VERSION ||
843
- !isEnvelope(record.envelope) ||
844
- typeof record.fetchedAt !== 'number' ||
845
- !Number.isFinite(record.fetchedAt)) {
846
- return null;
847
- }
848
- const endUserRef = await this.options.getEndUserRef();
849
- if (record.envelope.payload.endUserRef !== endUserRef) {
850
- await this.options.storage.remove(this.storageKey);
851
- return null;
852
- }
853
- this.held = {
854
- envelope: record.envelope,
855
- fetchedAt: record.fetchedAt,
856
- verified: false,
857
- source: this.source === 'mock' ? 'mock' : 'cache',
858
- };
859
- this.lastFingerprint = this.fingerprint();
860
- return this.snapshot();
861
- }
862
- /** Re-checks the loaded envelope against the project's key; discards it when the signature is invalid. */
863
- async reverify() {
864
- if (!this.held)
865
- return;
866
- const key = await this.safePublicKey();
867
- const verdict = await verifyEntitlementSignature(this.held.envelope, key);
868
- if (verdict === 'invalid') {
869
- logger.warn('cached entitlement failed signature verification; discarding');
870
- await this.discard();
871
- return;
872
- }
873
- this.held.verified = verdict === 'valid';
874
- }
875
- getCached() {
876
- return this.held ? this.snapshot() : null;
877
- }
878
- isFresh() {
879
- return (this.held !== null &&
880
- this.now() >= this.held.fetchedAt &&
881
- this.now() - this.held.fetchedAt < Math.min(this.options.cacheTtlMs, MAX_OFFLINE_AGE_MS));
882
- }
883
- async get(options = {}) {
884
- if (!options.force && this.isFresh())
885
- return this.snapshot();
886
- try {
887
- return await this.refresh();
888
- }
889
- catch (error) {
890
- const err = ExtenshiPayError.from(error);
891
- this.options.onError?.(err);
892
- if (this.held) {
893
- logger.debug('serving cached entitlement after refresh failure', err.code);
894
- return this.snapshot();
895
- }
896
- return EMPTY_ENTITLEMENT;
897
- }
898
- }
899
- /** Fetches the projection from the backend, verifies and stores it. */
900
- refresh() {
901
- if (!this.inflight) {
902
- this.inflight = (async () => {
903
- const endUserRef = await this.options.getEndUserRef();
904
- const envelope = await this.options.api.getEntitlement(endUserRef);
905
- return this.accept(envelope, this.source);
906
- })().finally(() => {
907
- this.inflight = null;
908
- });
909
- }
910
- return this.inflight;
911
- }
912
- /** Verifies and stores an envelope obtained elsewhere (e.g. from `claimSession`). */
913
- async accept(envelope, source = this.source) {
914
- if (!isEnvelope(envelope)) {
915
- throw new ExtenshiPayError(ERROR_CODES.INVALID_RESPONSE, 'Malformed entitlement envelope');
916
- }
917
- const endUserRef = await this.options.getEndUserRef();
918
- if (envelope.payload.endUserRef !== endUserRef) {
919
- throw new ExtenshiPayError(ERROR_CODES.INVALID_RESPONSE, 'Entitlement issued for a different endUserRef');
920
- }
921
- const verdict = await verifyEntitlementSignature(envelope, await this.safePublicKey());
922
- if (verdict === 'invalid') {
923
- await this.discard();
924
- throw new ExtenshiPayError(ERROR_CODES.INVALID_RESPONSE, 'Entitlement signature is invalid');
925
- }
926
- const fetchedAt = this.now();
927
- this.held = { envelope, fetchedAt, verified: verdict === 'valid', source };
928
- const record = { v: CACHE_VERSION, envelope, fetchedAt };
929
- await this.options.storage.set(this.storageKey, record);
930
- this.backoffMs = 0;
931
- this.scheduleDeadline();
932
- this.notifyIfChanged();
933
- return this.snapshot();
934
- }
935
- /** Drain an older installation refresh before changing identity. */
936
- async settleRefresh() {
937
- await this.inflight?.catch(() => undefined);
938
- }
939
- async clear() {
940
- this.held = null;
941
- this.scheduleDeadline();
942
- this.lastFingerprint = null;
943
- await this.options.storage.remove(this.storageKey);
944
- }
945
- startAutoRefresh(intervalMs = Math.max(this.options.cacheTtlMs, MIN_REFRESH_INTERVAL_MS)) {
946
- this.stopAutoRefresh();
947
- this.autoRefresh = true;
948
- globalThis.addEventListener?.('online', this.online);
949
- this.refreshIntervalMs = Math.max(intervalMs, MIN_REFRESH_INTERVAL_MS);
950
- this.schedule(this.refreshIntervalMs);
951
- this.scheduleDeadline();
952
- }
953
- stopAutoRefresh() {
954
- this.autoRefresh = false;
955
- globalThis.removeEventListener?.('online', this.online);
956
- this.refreshGeneration++;
957
- if (this.deadlineTimer !== null)
958
- clearTimeout(this.deadlineTimer);
959
- this.deadlineTimer = null;
960
- if (this.timer !== null)
961
- clearTimeout(this.timer);
962
- this.timer = null;
963
- }
964
- scheduleDeadline() {
965
- if (this.deadlineTimer !== null)
966
- clearTimeout(this.deadlineTimer);
967
- this.deadlineTimer = null;
968
- if (!this.autoRefresh || !this.held || this.source === 'mock')
969
- return;
970
- const remaining = this.held.fetchedAt + MAX_OFFLINE_AGE_MS - this.now();
971
- if (remaining <= 0)
972
- return;
973
- this.deadlineTimer = setTimeout(() => {
974
- this.deadlineTimer = null;
975
- this.notifyIfChanged();
976
- }, remaining);
977
- }
978
- schedule(delayMs) {
979
- const generation = this.refreshGeneration;
980
- this.timer = setTimeout(async () => {
981
- this.timer = null;
982
- try {
983
- await this.refresh();
984
- if (generation !== this.refreshGeneration)
985
- return;
986
- this.schedule(this.refreshIntervalMs);
987
- }
988
- catch (error) {
989
- if (generation !== this.refreshGeneration)
990
- return;
991
- this.options.onError?.(ExtenshiPayError.from(error));
992
- this.backoffMs = Math.min(this.backoffMs ? this.backoffMs * 2 : this.refreshIntervalMs, MAX_REFRESH_BACKOFF_MS);
993
- this.schedule(this.backoffMs);
994
- }
995
- }, delayMs);
996
- }
997
- async safePublicKey() {
998
- try {
999
- return await this.options.getPublicKey();
1000
- }
1001
- catch (error) {
1002
- logger.debug('public key unavailable; entitlement stays unverified', error);
1003
- return null;
1004
- }
1005
- }
1006
- async discard() {
1007
- this.held = null;
1008
- this.scheduleDeadline();
1009
- await this.options.storage.remove(this.storageKey);
1010
- this.notifyIfChanged();
1011
- }
1012
- fingerprint() {
1013
- const state = this.snapshot();
1014
- return canonicalJson({ items: state.items, requiresOnlineCheck: state.requiresOnlineCheck });
1015
- }
1016
- notifyIfChanged() {
1017
- const fingerprint = this.fingerprint();
1018
- if (fingerprint === this.lastFingerprint)
1019
- return;
1020
- this.lastFingerprint = fingerprint;
1021
- this.options.onChange?.(this.snapshot());
1022
- }
1023
- snapshot() {
1024
- if (!this.held)
1025
- return EMPTY_ENTITLEMENT;
1026
- const items = applyLocalExpiry(this.held.envelope.payload.entitlements, this.now());
1027
- const hasPaidAccess = collectFeatures(items).length > 0 ||
1028
- items.some((item) => item.status === 'active' || item.status === 'grace');
1029
- const offlineUntil = this.source === 'mock' || !hasPaidAccess ? null : this.held.fetchedAt + MAX_OFFLINE_AGE_MS;
1030
- const requiresOnlineCheck = offlineUntil !== null && (this.now() >= offlineUntil || this.now() < this.held.fetchedAt);
1031
- return {
1032
- items,
1033
- features: requiresOnlineCheck ? [] : collectFeatures(items),
1034
- requiresOnlineCheck,
1035
- offlineUntil,
1036
- verified: this.held.verified,
1037
- issuedAt: this.held.envelope.payload.issuedAt,
1038
- fetchedAt: this.held.fetchedAt,
1039
- source: this.held.source,
1040
- };
1041
- }
1042
- }
1043
-
1044
- /**
1045
- * Persistent key/value storage for the SDK's own namespace.
1046
- *
1047
- * Preference order: `chrome.storage.local` (Chrome/Edge), `browser.storage.local`
1048
- * (Firefox), `localStorage` (non-extension contexts such as a dev page), then
1049
- * memory. Both promise-returning (MV3, Firefox) and callback-only (MV2) storage
1050
- * APIs are supported.
1051
- */
1052
- function extensionGlobals() {
1053
- return globalThis;
1054
- }
1055
- function isThenable(value) {
1056
- return !!value && typeof value.then === 'function';
1057
- }
1058
- /** Runs a storage-area call that may either return a promise or expect a callback. */
1059
- function areaCall(direct, withCallback) {
1060
- const result = direct();
1061
- if (isThenable(result))
1062
- return result;
1063
- return new Promise((resolve, reject) => {
1064
- withCallback((value) => {
1065
- const lastError = extensionGlobals().chrome?.runtime?.lastError;
1066
- if (lastError)
1067
- reject(new Error(lastError.message ?? 'storage error'));
1068
- else
1069
- resolve(value);
1070
- });
1071
- });
1072
- }
1073
- class ExtensionStorage {
1074
- constructor(area) {
1075
- this.area = area;
1076
- }
1077
- async get(key) {
1078
- const items = await areaCall(() => this.area.get(key), (cb) => this.area.get(key, cb));
1079
- return items?.[key];
1080
- }
1081
- async set(key, value) {
1082
- await areaCall(() => this.area.set({ [key]: value }), (cb) => this.area.set({ [key]: value }, cb));
1083
- }
1084
- async remove(key) {
1085
- await areaCall(() => this.area.remove(key), (cb) => this.area.remove(key, cb));
1086
- }
1087
- }
1088
- class LocalStorageAdapter {
1089
- constructor(store) {
1090
- this.store = store;
1091
- }
1092
- async get(key) {
1093
- const raw = this.store.getItem(key);
1094
- if (raw === null)
1095
- return undefined;
1096
- try {
1097
- return JSON.parse(raw);
1098
- }
1099
- catch {
1100
- return undefined;
1101
- }
1102
- }
1103
- async set(key, value) {
1104
- this.store.setItem(key, JSON.stringify(value));
1105
- }
1106
- async remove(key) {
1107
- this.store.removeItem(key);
1108
- }
1109
- }
1110
- class MemoryStorage {
1111
- constructor() {
1112
- this.map = new Map();
1113
- }
1114
- async get(key) {
1115
- return this.map.get(key);
1116
- }
1117
- async set(key, value) {
1118
- this.map.set(key, value);
1119
- }
1120
- async remove(key) {
1121
- this.map.delete(key);
1122
- }
1123
- }
1124
- function createStorage() {
1125
- const g = extensionGlobals();
1126
- const area = g.chrome?.storage?.local ?? g.browser?.storage?.local;
1127
- if (area)
1128
- return new ExtensionStorage(area);
1129
- try {
1130
- const store = globalThis.localStorage;
1131
- if (store && typeof store.getItem === 'function')
1132
- return new LocalStorageAdapter(store);
1133
- }
1134
- catch {
1135
- // Access to localStorage can throw in sandboxed frames.
1136
- }
1137
- return new MemoryStorage();
1138
- }
1139
-
1140
- /** storage.local is exposed to content scripts by default. Never put a recovery proof there. */
1141
- function createRecoveryStorage() {
1142
- const g = globalThis;
1143
- const extension = g.chrome?.tabs ? g.chrome : g.browser?.tabs ? g.browser : null;
1144
- return extension?.storage?.session ? new ExtensionStorage(extension.storage.session) : new MemoryStorage();
1145
- }
1146
- class RecoveryManager {
1147
- constructor(options) {
1148
- this.options = options;
1149
- this.active = false;
1150
- this.stopped = false;
1151
- this.wake = null;
1152
- }
1153
- get pendingKey() {
1154
- return `extenshi-pay:${this.options.publishableKey}:pendingRestore`;
1155
- }
1156
- isActive() {
1157
- return this.active;
1158
- }
1159
- stop() {
1160
- this.stopped = true;
1161
- this.wake?.();
1162
- }
1163
- async open(options = {}) {
1164
- if (this.active)
1165
- throw new ExtenshiPayError(ERROR_CODES.INVALID_REQUEST, 'Recovery is already in progress');
1166
- this.active = true;
1167
- this.stopped = false;
1168
- try {
1169
- // A caller from a content script must route the action to its own background;
1170
- // never return this manager's internal state through that message bridge.
1171
- const g = globalThis;
1172
- if ((g.chrome?.runtime?.id || g.browser?.runtime?.id) && !(g.chrome?.tabs || g.browser?.tabs))
1173
- throw new ExtenshiPayError(ERROR_CODES.INVALID_REQUEST, 'Start recovery in an extension page or background context');
1174
- const cryptoApi = globalThis.crypto;
1175
- if (!cryptoApi?.subtle)
1176
- throw new ExtenshiPayError(ERROR_CODES.INVALID_REQUEST, 'Secure recovery is unavailable in this browser');
1177
- const secret = Array.from(cryptoApi.getRandomValues(new Uint8Array(32)), (b) => b.toString(16).padStart(2, '0')).join('');
1178
- const hash = await cryptoApi.subtle.digest('SHA-256', new TextEncoder().encode(secret));
1179
- const challenge = Array.from(new Uint8Array(hash), (b) => b.toString(16).padStart(2, '0')).join('');
1180
- const created = await this.options.api.createRestoreSession(challenge);
1181
- if (!Number.isFinite(Date.parse(created.expiresAt)))
1182
- throw new ExtenshiPayError(ERROR_CODES.INVALID_RESPONSE, 'Invalid recovery expiry');
1183
- const pending = { sessionId: created.sessionId, expiresAt: created.expiresAt, claimSecret: secret };
1184
- await this.options.storage.set(this.pendingKey, pending);
1185
- await (options.openUrl ?? this.options.openUrl ?? openInNewTab)(created.url);
1186
- return await this.poll(pending, options);
1187
- }
1188
- finally {
1189
- this.active = false;
1190
- }
1191
- }
1192
- async resumePending() {
1193
- if (this.active || this.stopped)
1194
- return null;
1195
- const raw = (await this.options.storage.get(this.pendingKey));
1196
- if (!raw || this.active || this.stopped)
1197
- return null;
1198
- if (typeof raw.sessionId !== 'string' ||
1199
- typeof raw.claimSecret !== 'string' ||
1200
- !/^[a-f0-9]{64}$/.test(raw.claimSecret) ||
1201
- !Number.isFinite(Date.parse(raw.expiresAt ?? ''))) {
1202
- await this.options.storage.remove(this.pendingKey);
1203
- return null;
1204
- }
1205
- this.active = true;
1206
- this.stopped = false;
1207
- try {
1208
- return await this.poll(raw, {});
1209
- }
1210
- finally {
1211
- this.active = false;
1212
- }
1213
- }
1214
- async poll(pending, options) {
1215
- const now = this.options.now ?? Date.now;
1216
- const expires = Date.parse(pending.expiresAt);
1217
- const deadline = Math.min(expires, now() + (options.timeoutMs ?? 10 * 60 * 1000));
1218
- let delay = 0;
1219
- while (!this.stopped && !options.signal?.aborted && now() < deadline) {
1220
- if (delay)
1221
- await new Promise((resolve) => {
1222
- const done = () => {
1223
- clearTimeout(timer);
1224
- options.signal?.removeEventListener('abort', done);
1225
- this.wake = null;
1226
- resolve();
1227
- };
1228
- const timer = setTimeout(done, Math.min(delay, Math.max(0, deadline - now())));
1229
- this.wake = done;
1230
- options.signal?.addEventListener('abort', done, { once: true });
1231
- });
1232
- if (this.stopped || options.signal?.aborted || now() >= deadline)
1233
- break;
1234
- try {
1235
- const claim = await this.options.api.claimRestoreSession(pending.sessionId, pending.claimSecret);
1236
- if (this.stopped || options.signal?.aborted)
1237
- break;
1238
- if (claim.state === 'complete') {
1239
- const entitlement = await this.options.onComplete(claim.endUserRef, claim.entitlement);
1240
- await this.options.storage.remove(this.pendingKey);
1241
- return { state: 'complete', entitlement };
1242
- }
1243
- if (claim.state !== 'pending')
1244
- throw new ExtenshiPayError(ERROR_CODES.INVALID_RESPONSE, 'Invalid recovery response');
1245
- delay = Math.max(100, options.pollIntervalMs ?? 2000);
1246
- }
1247
- catch (error) {
1248
- const err = ExtenshiPayError.from(error);
1249
- if (![
1250
- ERROR_CODES.NETWORK_ERROR,
1251
- ERROR_CODES.TIMEOUT,
1252
- ERROR_CODES.GATEWAY_UNAVAILABLE,
1253
- ERROR_CODES.RATE_LIMITED,
1254
- ].some((code) => code === err.code))
1255
- throw err;
1256
- delay = Math.max(2000, (err.retryAfterSec ?? 5) * 1000);
1257
- }
1258
- }
1259
- if (now() >= expires)
1260
- await this.options.storage.remove(this.pendingKey);
1261
- return {
1262
- state: this.stopped || options.signal?.aborted ? 'canceled' : now() >= expires ? 'expired' : 'timeout',
1263
- };
1264
- }
1265
- }
1266
-
1267
- const DEFAULT_API_URL = 'https://bff.extenshi.io';
1268
- const DEFAULT_CACHE_TTL_MS = 60 * 60 * 1000;
1269
- const MAX_CACHE_TTL_MS = 7 * 24 * 60 * 60 * 1000;
1270
-
1271
- /** Kept in sync with package.json by tests/unit/version.test.ts. */
1272
- const VERSION = '0.7.0';
1273
-
1274
- const ENVIRONMENTS = new Set(['production', 'sandbox', 'development']);
1275
- const LOG_LEVELS = new Set(['silent', 'error', 'warn', 'info', 'debug']);
1276
- const THEME_MODES = new Set(['light', 'dark', 'auto']);
1277
- /** Same shape the BFF accepts (`en`, `de-DE`, `zh-Hant`). */
1278
- const LOCALE_RE = /^[a-z]{2}(-[A-Za-z]{2,4})?$/;
1279
- function isHttpUrl(value) {
1280
- try {
1281
- const url = new URL(value);
1282
- return url.protocol === 'https:' || url.protocol === 'http:';
1283
- }
1284
- catch {
1285
- return false;
1286
- }
1287
- }
1288
- function resolveConfig(input) {
1289
- const errors = [];
1290
- if (!input || typeof input !== 'object') {
1291
- throw new ExtenshiPayError(ERROR_CODES.INVALID_CONFIG, 'ExtenshiPay config must be an object');
1292
- }
1293
- if (!isPayPublishableKey(input.publishableKey)) {
1294
- errors.push('publishableKey must look like pk_ext_<32 hex characters>');
1295
- }
1296
- const apiUrl = (input.apiUrl ?? DEFAULT_API_URL).replace(/\/+$/, '');
1297
- if (!isHttpUrl(apiUrl))
1298
- errors.push('apiUrl must be an http(s) URL');
1299
- const environment = input.environment ?? 'production';
1300
- if (!ENVIRONMENTS.has(environment))
1301
- errors.push('environment must be production, sandbox or development');
1302
- const logLevel = input.logLevel ?? 'warn';
1303
- if (!LOG_LEVELS.has(logLevel))
1304
- errors.push('logLevel must be silent, error, warn, info or debug');
1305
- const cacheTtlMs = input.cacheTtlMs ?? DEFAULT_CACHE_TTL_MS;
1306
- if (!Number.isFinite(cacheTtlMs) || cacheTtlMs < 0 || cacheTtlMs > MAX_CACHE_TTL_MS) {
1307
- errors.push(`cacheTtlMs must be between 0 and ${MAX_CACHE_TTL_MS}`);
1308
- }
1309
- const locale = input.locale ?? null;
1310
- if (locale !== null && !LOCALE_RE.test(locale))
1311
- errors.push('locale must be a BCP-47 tag such as en or de-DE');
1312
- const theme = input.theme ?? {};
1313
- if (theme.mode !== undefined && !THEME_MODES.has(theme.mode))
1314
- errors.push('theme.mode must be light, dark or auto');
1315
- if (input.mock &&
1316
- input.mockData !== undefined &&
1317
- (typeof input.mockData !== 'object' || input.mockData === null)) {
1318
- errors.push('mockData must be an object');
1319
- }
1320
- if (errors.length > 0) {
1321
- throw new ExtenshiPayError(ERROR_CODES.INVALID_CONFIG, `Invalid ExtenshiPay config: ${errors.join('; ')}`);
1322
- }
1323
- return {
1324
- publishableKey: input.publishableKey,
1325
- apiUrl,
1326
- environment,
1327
- debug: input.debug === true,
1328
- logLevel,
1329
- cacheTtlMs,
1330
- locale,
1331
- mock: input.mock === true,
1332
- mockData: input.mock ? (input.mockData ?? {}) : null,
1333
- theme,
1334
- };
1335
- }
1336
-
1337
- class EventEmitter {
1338
- constructor() {
1339
- this.listeners = new Map();
1340
- }
1341
- on(event, listener) {
1342
- let set = this.listeners.get(event);
1343
- if (!set) {
1344
- set = new Set();
1345
- this.listeners.set(event, set);
1346
- }
1347
- set.add(listener);
1348
- return () => this.off(event, listener);
1349
- }
1350
- once(event, listener) {
1351
- const off = this.on(event, (payload) => {
1352
- off();
1353
- listener(payload);
1354
- });
1355
- return off;
1356
- }
1357
- off(event, listener) {
1358
- this.listeners.get(event)?.delete(listener);
1359
- }
1360
- emit(event, payload) {
1361
- const set = this.listeners.get(event);
1362
- if (!set)
1363
- return;
1364
- for (const listener of [...set]) {
1365
- const fn = listener;
1366
- try {
1367
- fn(payload);
1368
- }
1369
- catch (error) {
1370
- logger.error(`listener for "${String(event)}" threw`, error);
1371
- }
1372
- }
1373
- }
1374
- removeAll() {
1375
- this.listeners.clear();
1376
- }
1377
- }
1378
-
1379
- /**
1380
- * `ExtenshiPayLite` — entitlement, feature gating and hosted checkout, without
1381
- * the paywall UI. This is what the `lite` bundle exports; the full `ExtenshiPay`
1382
- * extends it with `getOffer()` / `showPaywall()`.
1383
- *
1384
- * Data that leaves the extension: `publishableKey`, `endUserRef`, `sku`,
1385
- * `locale` and checkout session IDs. Explicit recovery also sends its session ID,
1386
- * challenge and claim secret (POST body). Email stays on the hosted page.
1387
- */
1388
- /** Server-side offer cache is 5 min; mirror it in memory. */
1389
- const OFFER_TTL_MS = 5 * 60 * 1000;
1390
- class ExtenshiPayLite {
1391
- constructor(config, deps = {}) {
1392
- this.emitter = new EventEmitter();
1393
- this.endUserRef = null;
1394
- this.endUserRefPromise = null;
1395
- this.offer = null;
1396
- this.offerInflight = null;
1397
- this.readyPromise = null;
1398
- this.destroyed = false;
1399
- this.config = resolveConfig(config);
1400
- logger.configure({ logLevel: this.config.logLevel, debug: this.config.debug });
1401
- this.now = deps.now ?? (() => Date.now());
1402
- this.storage = deps.storage ?? createStorage();
1403
- const transport = deps.transport ??
1404
- (this.config.mock
1405
- ? new MockTransport(this.config.mockData ?? {})
1406
- : new HttpTransport({ apiUrl: this.config.apiUrl, fetchImpl: deps.fetch }));
1407
- this.api = new PayApi(transport, this.config.publishableKey);
1408
- this.entitlements = new EntitlementManager({
1409
- api: this.api,
1410
- storage: this.storage,
1411
- publishableKey: this.config.publishableKey,
1412
- cacheTtlMs: this.config.cacheTtlMs,
1413
- source: this.config.mock ? 'mock' : 'network',
1414
- getEndUserRef: () => this.getEndUserRef(),
1415
- getPublicKey: () => this.getPublicKey(),
1416
- onChange: (entitlement) => this.emitter.emit('entitlement:changed', entitlement),
1417
- onError: (error) => this.reportError(error),
1418
- now: this.now,
1419
- });
1420
- this.checkout = new CheckoutManager({
1421
- api: this.api,
1422
- storage: this.storage,
1423
- publishableKey: this.config.publishableKey,
1424
- locale: this.config.locale,
1425
- getEndUserRef: () => this.getEndUserRef(),
1426
- onComplete: (envelope) => this.entitlements.accept(envelope),
1427
- emit: (event, payload) => this.emitter.emit(event, payload),
1428
- // Mock checkouts complete on their own; never open a tab to a mock URL.
1429
- openUrl: deps.openUrl ??
1430
- (this.config.mock ? (url) => logger.info('mock checkout (no tab opened)', url) : undefined),
1431
- now: this.now,
1432
- });
1433
- this.recovery = new RecoveryManager({
1434
- api: this.api,
1435
- publishableKey: this.config.publishableKey,
1436
- storage: deps.recoveryStorage ?? createRecoveryStorage(),
1437
- openUrl: deps.openUrl,
1438
- now: this.now,
1439
- onComplete: async (ref, envelope) => {
1440
- if (!PAY_END_USER_REF_RE.test(ref) ||
1441
- envelope?.payload?.endUserRef !== ref ||
1442
- (await verifyEntitlementSignature(envelope, await this.getPublicKey())) !== 'valid')
1443
- throw new ExtenshiPayError(ERROR_CODES.INVALID_RESPONSE, 'Recovery requires a verified entitlement for this installation');
1444
- this.entitlements.stopAutoRefresh();
1445
- try {
1446
- await this.entitlements.settleRefresh();
1447
- if (this.destroyed)
1448
- throw new ExtenshiPayError(ERROR_CODES.INVALID_REQUEST, 'Recovery was stopped');
1449
- await this.storage.set(END_USER_REF_STORAGE_KEY, ref);
1450
- this.endUserRef = ref;
1451
- this.endUserRefPromise = null;
1452
- await this.entitlements.clear();
1453
- return await this.entitlements.accept(envelope);
1454
- }
1455
- finally {
1456
- if (!this.destroyed)
1457
- this.entitlements.startAutoRefresh();
1458
- }
1459
- },
1460
- });
1461
- if (config.onError)
1462
- this.emitter.on('error', config.onError);
1463
- if (config.onReady)
1464
- this.emitter.once('ready', config.onReady);
1465
- }
1466
- get version() {
1467
- return VERSION;
1468
- }
1469
- /**
1470
- * Mints/loads `endUserRef`, loads the cached entitlement, re-verifies it and
1471
- * refreshes it when stale. Resolves once `isPaid()` can answer; network
1472
- * failures fall back to the cache and are reported through `error`.
1473
- */
1474
- initialize() {
1475
- if (!this.readyPromise)
1476
- this.readyPromise = this.doInitialize();
1477
- return this.readyPromise;
1478
- }
1479
- async doInitialize() {
1480
- const endUserRef = await this.getEndUserRef();
1481
- await this.entitlements.load();
1482
- try {
1483
- await this.entitlements.reverify();
1484
- }
1485
- catch (error) {
1486
- this.reportError(error);
1487
- }
1488
- if (!this.entitlements.isFresh())
1489
- await this.entitlements.get({ force: true });
1490
- this.emitter.emit('ready', { endUserRef });
1491
- void this.afterReady();
1492
- }
1493
- async afterReady() {
1494
- if (this.destroyed)
1495
- return;
1496
- try {
1497
- await this.checkout.resumePending();
1498
- if (this.destroyed)
1499
- return;
1500
- await this.recovery.resumePending();
1501
- }
1502
- catch (error) {
1503
- this.reportError(error);
1504
- }
1505
- if (!this.destroyed)
1506
- this.entitlements.startAutoRefresh();
1507
- }
1508
- /** The anonymous, random id this install is known by. */
1509
- getEndUserRef() {
1510
- if (this.endUserRef)
1511
- return Promise.resolve(this.endUserRef);
1512
- if (!this.endUserRefPromise) {
1513
- this.endUserRefPromise = getOrCreateEndUserRef(this.storage).then((ref) => {
1514
- this.endUserRef = ref;
1515
- return ref;
1516
- });
1517
- }
1518
- return this.endUserRefPromise;
1519
- }
1520
- getCachedEntitlement() {
1521
- return this.entitlements.getCached();
1522
- }
1523
- async getEntitlement(options = {}) {
1524
- await this.initialize();
1525
- return this.entitlements.get(options);
1526
- }
1527
- /** True when any active/grace entitlement exists, or the given `sku` is active/grace. */
1528
- async isPaid(sku) {
1529
- return isEntitled(await this.getEntitlement(), sku);
1530
- }
1531
- async hasFeature(feature) {
1532
- return hasFeature(await this.getEntitlement(), feature);
1533
- }
1534
- async checkFeatures(features) {
1535
- return checkFeatures(await this.getEntitlement(), features);
1536
- }
1537
- /** Resolves true when the feature is (or becomes) unlocked. */
1538
- async requireFeature(feature, options = {}) {
1539
- if (await this.hasFeature(feature)) {
1540
- options.onUnlock?.();
1541
- return true;
1542
- }
1543
- const unlocked = await this.onFeatureLocked(feature, options);
1544
- if (unlocked)
1545
- options.onUnlock?.();
1546
- else
1547
- options.onCancel?.();
1548
- return unlocked;
1549
- }
1550
- /** Lite has no UI: a locked feature stays locked. The full SDK shows the paywall here. */
1551
- async onFeatureLocked(_feature, _options) {
1552
- return false;
1553
- }
1554
- /** Opens hosted checkout for `sku` in a new tab and resolves when the session settles. */
1555
- async openCheckout(sku, options = {}) {
1556
- await this.initialize();
1557
- try {
1558
- if (this.recovery.isActive())
1559
- throw new ExtenshiPayError(ERROR_CODES.INVALID_REQUEST, 'Recovery is in progress');
1560
- return await this.checkout.open(sku, options);
1561
- }
1562
- catch (error) {
1563
- throw this.reportError(error);
1564
- }
1565
- }
1566
- /** Opens email verification on the hosted page. No email is collected inside the extension. */
1567
- async restorePurchase(options = {}) {
1568
- await this.initialize();
1569
- try {
1570
- if (this.checkout.isActive())
1571
- throw new ExtenshiPayError(ERROR_CODES.INVALID_REQUEST, 'Checkout is in progress');
1572
- return await this.recovery.open(options);
1573
- }
1574
- catch (error) {
1575
- throw this.reportError(error);
1576
- }
1577
- }
1578
- /** Read-only license view. Entitlements retain cache/signature/offline semantics. */
1579
- async getLicenseSummary(options = {}) {
1580
- await this.initialize();
1581
- let offer = null;
1582
- try {
1583
- offer = await this.fetchOffer(options.force);
1584
- }
1585
- catch {
1586
- /* Offline: do not invent seller details. */
1587
- }
1588
- return {
1589
- projectName: offer?.projectName ?? null,
1590
- seller: offer?.seller ?? null,
1591
- entitlement: await this.getEntitlement(options),
1592
- recoveryEnabled: offer?.recoveryEnabled === true,
1593
- };
1594
- }
1595
- /** Opens the provider's self-service portal; resolves null when the provider has none. */
1596
- async openCustomerPortal(options = {}) {
1597
- await this.initialize();
1598
- try {
1599
- const endUserRef = await this.getEndUserRef();
1600
- let result = await this.api.getPortalUrl(endUserRef);
1601
- if (this.destroyed)
1602
- return null;
1603
- if (result.accounts?.length) {
1604
- if (!options.selectAccount)
1605
- throw new ExtenshiPayError(ERROR_CODES.INVALID_REQUEST, 'Choose a billing profile using selectAccount');
1606
- const customerId = await options.selectAccount(result.accounts);
1607
- if (customerId === null || this.destroyed)
1608
- return null;
1609
- if (!result.accounts.some((a) => a.id === customerId))
1610
- throw new ExtenshiPayError(ERROR_CODES.INVALID_REQUEST, 'Invalid billing profile');
1611
- // Recovery may replace this installation while the selector is open.
1612
- if (endUserRef !== (await this.getEndUserRef()))
1613
- throw new ExtenshiPayError(ERROR_CODES.INVALID_REQUEST, 'Installation changed; open the portal again');
1614
- result = await this.api.getPortalUrl(endUserRef, customerId);
1615
- }
1616
- if (this.destroyed)
1617
- return null;
1618
- const { url } = result;
1619
- if (url)
1620
- await (options.openUrl ?? (await Promise.resolve().then(function () { return checkout; })).openInNewTab)(url);
1621
- return url;
1622
- }
1623
- catch (error) {
1624
- throw this.reportError(error);
1625
- }
1626
- }
1627
- on(event, listener) {
1628
- return this.emitter.on(event, listener);
1629
- }
1630
- once(event, listener) {
1631
- return this.emitter.once(event, listener);
1632
- }
1633
- off(event, listener) {
1634
- this.emitter.off(event, listener);
1635
- }
1636
- onEntitlementChange(listener) {
1637
- return this.emitter.on('entitlement:changed', listener);
1638
- }
1639
- async clearCache() {
1640
- this.offer = null;
1641
- await this.entitlements.clear();
1642
- }
1643
- /** Stops background refresh and drops listeners. */
1644
- destroy() {
1645
- this.destroyed = true;
1646
- this.recovery.stop();
1647
- this.entitlements.stopAutoRefresh();
1648
- this.emitter.removeAll();
1649
- }
1650
- /** Offer + signing key. Public in the full SDK (`getOffer`), internal here. */
1651
- fetchOffer(force = false) {
1652
- if (!force && this.offer && this.now() - this.offer.fetchedAt < OFFER_TTL_MS) {
1653
- return Promise.resolve(this.offer.value);
1654
- }
1655
- if (!this.offerInflight) {
1656
- this.offerInflight = this.api
1657
- .getOffer(this.config.locale)
1658
- .then((value) => {
1659
- this.offer = { value, fetchedAt: this.now() };
1660
- return value;
1661
- })
1662
- .finally(() => {
1663
- this.offerInflight = null;
1664
- });
1665
- }
1666
- return this.offerInflight;
1667
- }
1668
- async getPublicKey() {
1669
- return (await this.fetchOffer()).entitlementPublicKey;
1670
- }
1671
- reportError(error) {
1672
- const err = ExtenshiPayError.from(error);
1673
- logger.warn(`${err.code}: ${err.message}`);
1674
- this.emitter.emit('error', err);
1675
- return err;
1676
- }
1677
- }
1678
- ExtenshiPayLite.version = VERSION;
1679
-
1680
- /** Bundled UI only. Native dialog provides modal focus containment and Escape. */
1681
- class BillingProfilePicker {
1682
- constructor() {
1683
- this.dismiss = null;
1684
- }
1685
- hide() {
1686
- this.dismiss?.();
1687
- }
1688
- show(accounts) {
1689
- this.hide();
1690
- if (typeof document === 'undefined')
1691
- throw new ExtenshiPayError(ERROR_CODES.INVALID_REQUEST, 'Provide selectAccount outside an extension page');
1692
- const host = document.createElement('div');
1693
- host.className = 'extenshi-billing-profile-host';
1694
- const root = host.attachShadow({ mode: 'open' });
1695
- const style = document.createElement('style');
1696
- style.textContent = `
1697
- dialog{font:15px/1.5 system-ui,sans-serif;color:#172033;background:#fff;border:1px solid #dce1e8;border-radius:16px;padding:24px;width:min(440px,calc(100vw - 64px));max-height:80vh;box-shadow:0 20px 60px #0003}
1698
- dialog::backdrop{background:#10182880}h2{margin:0 0 8px;font-size:22px}p{margin:0 0 16px;color:#526078}
1699
- button{font:inherit;cursor:pointer;border:1px solid #dce1e8;border-radius:8px;background:#fff;color:inherit;padding:12px;text-align:left;width:100%;margin-top:10px}
1700
- button:hover{background:#f3f6fa}button:focus-visible{outline:3px solid #0ea5e9;outline-offset:2px}strong,small{display:block}small{color:#526078;margin-top:4px}
1701
- `;
1702
- const dialog = document.createElement('dialog');
1703
- dialog.setAttribute('aria-labelledby', 'billing-title');
1704
- dialog.setAttribute('aria-describedby', 'billing-description');
1705
- const title = document.createElement('h2');
1706
- title.id = 'billing-title';
1707
- title.textContent = 'Choose a billing profile';
1708
- const description = document.createElement('p');
1709
- description.id = 'billing-description';
1710
- description.textContent =
1711
- 'Separate purchases can have separate billing profiles. Choose one to manage its subscriptions and payment details.';
1712
- dialog.append(title, description);
1713
- root.append(style, dialog);
1714
- document.body.append(host);
1715
- if (typeof dialog.showModal !== 'function') {
1716
- host.remove();
1717
- throw new ExtenshiPayError(ERROR_CODES.INVALID_REQUEST, 'This browser needs a custom selectAccount callback');
1718
- }
1719
- return new Promise((resolve, reject) => {
1720
- const finish = (id) => {
1721
- this.dismiss = null;
1722
- dialog.close();
1723
- host.remove();
1724
- resolve(id);
1725
- };
1726
- this.dismiss = () => finish(null);
1727
- dialog.addEventListener('cancel', (event) => {
1728
- event.preventDefault();
1729
- finish(null);
1730
- });
1731
- for (const account of accounts) {
1732
- const button = document.createElement('button');
1733
- button.type = 'button';
1734
- const label = document.createElement('strong');
1735
- label.textContent = account.label;
1736
- const detail = document.createElement('small');
1737
- const recorded = new Date(account.createdAt);
1738
- detail.textContent = Number.isNaN(recorded.getTime())
1739
- ? ''
1740
- : `First recorded ${recorded.toLocaleDateString()}`;
1741
- button.append(label, detail);
1742
- for (const subscription of account.subscriptions) {
1743
- const line = document.createElement('small');
1744
- const end = subscription.currentPeriodEnd ? new Date(subscription.currentPeriodEnd) : null;
1745
- const cancellation = subscription.cancelAtPeriodEnd
1746
- ? ` · Renewal canceled${end && !Number.isNaN(end.getTime()) ? ` · Period ends ${end.toLocaleDateString()}` : ''}`
1747
- : '';
1748
- line.textContent = `${subscription.title} · ${subscription.status.replace(/_/g, ' ')}${cancellation}`;
1749
- button.append(line);
1750
- }
1751
- button.addEventListener('click', () => finish(account.id));
1752
- dialog.append(button);
1753
- }
1754
- const cancel = document.createElement('button');
1755
- cancel.type = 'button';
1756
- cancel.textContent = 'Cancel';
1757
- cancel.addEventListener('click', () => finish(null));
1758
- dialog.append(cancel);
1759
- try {
1760
- dialog.showModal();
1761
- }
1762
- catch (error) {
1763
- this.dismiss = null;
1764
- host.remove();
1765
- reject(error);
1766
- }
1767
- });
1768
- }
1769
- }
1770
-
1771
- /** Treat even server-provided links as untrusted; never render executable protocols. */
1772
- function publicContactUrl(value) {
1773
- try {
1774
- const url = new URL(value);
1775
- if (url.protocol === 'https:' && !url.username && !url.password)
1776
- return url.href;
1777
- }
1778
- catch {
1779
- /* A plain email address is allowed below. */
1780
- }
1781
- if (/^[^\s@?&#:]+@[^\s@?&#:]+\.[^\s@?&#:]+$/.test(value))
1782
- return `mailto:${encodeURIComponent(value)}`;
1783
- return null;
1784
- }
1785
- function sellerDetails(seller) {
1786
- const section = document.createElement('section');
1787
- section.className = 'extenshi-seller-details';
1788
- const name = document.createElement('p');
1789
- name.textContent = seller
1790
- ? `License provided by ${seller.displayName}`
1791
- : 'License provider details are unavailable.';
1792
- section.append(name);
1793
- const link = (label, value) => {
1794
- const href = value ? publicContactUrl(value) : null;
1795
- if (!href)
1796
- return;
1797
- const a = document.createElement('a');
1798
- a.textContent = label;
1799
- a.href = href;
1800
- a.target = '_blank';
1801
- a.rel = 'noopener noreferrer';
1802
- a.style.marginRight = '12px';
1803
- section.append(a);
1804
- };
1805
- if (seller) {
1806
- link('Extension support', seller.supportUrl);
1807
- link('License terms', seller.termsUrl);
1808
- }
1809
- const role = document.createElement('p');
1810
- role.textContent =
1811
- 'The author handles extension functionality and license commitments. Extenshi provides payment and license recovery tools.';
1812
- section.append(role);
1813
- return section;
1814
- }
1815
-
1816
- /**
1817
- * Every string the SDK adds on top of the templates. English only for now;
1818
- * iteration 12 T9 / 13 replaces this dictionary per locale. Do not add
1819
- * promotional claims here without marketing/legal review (see
1820
- * .claude/modules/paywall-templates.md).
1821
- */
1822
- const MOCK_PAYMENT_NOTICE = 'Development preview: licenses and payments are simulated. No payment will be taken.';
1823
- const DEFAULT_STRINGS = {
1824
- title: 'Unlock premium features',
1825
- description: 'Upgrade to get full access to this extension.',
1826
- upgrade: 'Upgrade',
1827
- cancel: 'Not now',
1828
- dismiss: 'Dismiss',
1829
- remindLater: 'Remind me later',
1830
- continueFree: 'Continue with the free version',
1831
- checkoutUnavailable: 'Purchases are temporarily unavailable',
1832
- periodMonth: '/month',
1833
- periodYear: '/year',
1834
- periodOnce: 'one-time',
1835
- footer: 'Secure checkout opens in a new tab.',
1836
- restorePurchase: 'Restore purchase',
1837
- };
1838
-
1839
- class LicensePanel {
1840
- constructor() {
1841
- this.dismiss = null;
1842
- }
1843
- hide() {
1844
- this.dismiss?.();
1845
- }
1846
- show(summary, actions) {
1847
- this.hide();
1848
- if (typeof document === 'undefined')
1849
- throw new ExtenshiPayError(ERROR_CODES.INVALID_REQUEST, 'Use getLicenseSummary outside an extension page');
1850
- const host = document.createElement('div');
1851
- host.className = 'extenshi-license-host';
1852
- const root = host.attachShadow({ mode: 'open' });
1853
- const style = document.createElement('style');
1854
- style.textContent = `dialog{font:15px/1.5 system-ui,sans-serif;color:#172033;background:#fff;border:1px solid #dce1e8;border-radius:16px;padding:24px;width:min(460px,calc(100vw - 64px));max-height:80vh}dialog::backdrop{background:#10182880}h2{margin:0}h3{font-size:16px;margin:0}article{border-block-end:1px solid #ddd;padding:16px 0}p{margin:8px 0}button{font:inherit;padding:10px 14px;margin:12px 8px 0 0;border:1px solid #cbd5e1;border-radius:8px;cursor:pointer;background:#fff;color:inherit}button:disabled{opacity:.5;cursor:wait}button:focus-visible,a:focus-visible{outline:3px solid #0ea5e9}a{color:#0369a1}.extenshi-seller-details{font-size:13px;margin-top:20px}`;
1855
- const dialog = document.createElement('dialog');
1856
- dialog.setAttribute('aria-label', 'Your license');
1857
- const title = document.createElement('h2');
1858
- title.textContent = 'Your license';
1859
- const content = document.createElement('div');
1860
- const feedback = document.createElement('p');
1861
- feedback.setAttribute('role', 'status');
1862
- const render = (state) => {
1863
- content.replaceChildren();
1864
- const note = document.createElement('p');
1865
- note.textContent = state.projectName ?? 'Extension license';
1866
- content.append(note);
1867
- if (!state.entitlement.items.length) {
1868
- const empty = document.createElement('p');
1869
- empty.textContent = 'No license found on this installation.';
1870
- content.append(empty);
1871
- }
1872
- for (const item of state.entitlement.items) {
1873
- const article = document.createElement('article');
1874
- const heading = document.createElement('h3');
1875
- heading.textContent = item.title ?? item.sku;
1876
- const status = document.createElement('p');
1877
- const kind = item.kind === 'one_time'
1878
- ? item.expiresAt
1879
- ? 'One-time purchase'
1880
- : 'Lifetime'
1881
- : item.kind === 'subscription'
1882
- ? 'Subscription'
1883
- : 'License';
1884
- status.textContent = `${kind} · ${item.status}`;
1885
- article.append(heading, status);
1886
- if (item.expiresAt) {
1887
- const date = new Date(item.expiresAt);
1888
- if (!Number.isNaN(date.getTime())) {
1889
- const expiry = document.createElement('p');
1890
- expiry.textContent = `${item.status === 'expired' ? 'Access ended' : item.status === 'active' || item.status === 'grace' ? 'Access until' : 'Recorded end date'} ${date.toLocaleString()}`;
1891
- article.append(expiry);
1892
- }
1893
- }
1894
- for (const sub of item.subscriptions ?? []) {
1895
- const row = document.createElement('p');
1896
- row.textContent = `Subscription: ${sub.status.replace(/_/g, ' ')}${sub.cancelAtPeriodEnd ? ' · Renewal canceled' : ''}`;
1897
- article.append(row);
1898
- }
1899
- content.append(article);
1900
- }
1901
- const freshness = document.createElement('p');
1902
- freshness.textContent = state.entitlement.requiresOnlineCheck
1903
- ? 'Connect to the internet to verify your license. Paid features are paused after 48 hours without a successful check. Your purchase has not expired.'
1904
- : state.entitlement.source === 'mock'
1905
- ? MOCK_PAYMENT_NOTICE
1906
- : state.entitlement.source === 'cache'
1907
- ? 'Showing saved license information.'
1908
- : 'Subscription information reflects the latest processed payment update.';
1909
- content.append(freshness, sellerDetails(state.seller));
1910
- };
1911
- render(summary);
1912
- dialog.append(title, content, feedback);
1913
- root.append(style, dialog);
1914
- document.body.append(host);
1915
- if (typeof dialog.showModal !== 'function') {
1916
- host.remove();
1917
- throw new ExtenshiPayError(ERROR_CODES.INVALID_REQUEST, 'This browser needs a custom license screen using getLicenseSummary');
1918
- }
1919
- return new Promise((resolve, reject) => {
1920
- let closed = false;
1921
- const close = () => {
1922
- closed = true;
1923
- this.dismiss = null;
1924
- dialog.close();
1925
- host.remove();
1926
- resolve();
1927
- };
1928
- this.dismiss = close;
1929
- dialog.addEventListener('cancel', (event) => {
1930
- event.preventDefault();
1931
- close();
1932
- });
1933
- const buttons = [];
1934
- const action = (label, run) => {
1935
- const button = document.createElement('button');
1936
- button.type = 'button';
1937
- button.textContent = label;
1938
- button.addEventListener('click', async () => {
1939
- buttons.forEach((b) => {
1940
- b.disabled = true;
1941
- });
1942
- feedback.textContent = '';
1943
- try {
1944
- await run();
1945
- }
1946
- catch {
1947
- if (!closed)
1948
- feedback.textContent =
1949
- 'Unable to complete the request. Please try again or contact extension support.';
1950
- }
1951
- finally {
1952
- if (!closed)
1953
- buttons.forEach((b) => {
1954
- b.disabled = false;
1955
- });
1956
- }
1957
- });
1958
- buttons.push(button);
1959
- dialog.append(button);
1960
- };
1961
- if (summary.recoveryEnabled)
1962
- action('Restore purchase', async () => {
1963
- const updated = await actions.restore();
1964
- if (!closed)
1965
- render(updated);
1966
- });
1967
- if (summary.entitlement.source !== 'mock')
1968
- action('Manage billing', async () => {
1969
- const url = await actions.manage();
1970
- if (!url && !closed)
1971
- feedback.textContent = 'No billing portal opened. You can retry or contact extension support.';
1972
- });
1973
- const done = document.createElement('button');
1974
- done.type = 'button';
1975
- done.textContent = 'Close';
1976
- done.addEventListener('click', close);
1977
- dialog.append(done);
1978
- try {
1979
- dialog.showModal();
1980
- }
1981
- catch (error) {
1982
- this.dismiss = null;
1983
- host.remove();
1984
- reject(error);
1985
- }
1986
- });
1987
- }
1988
- }
1989
-
1990
- function formatPrice(amountMinor, currency, locale) {
1991
- const value = amountMinor / 100;
1992
- const code = currency.toUpperCase();
1993
- try {
1994
- const formatter = new Intl.NumberFormat(locale ?? undefined, { style: 'currency', currency: code });
1995
- const parts = formatter.formatToParts(value);
1996
- return {
1997
- currency: parts
1998
- .filter((part) => part.type === 'currency')
1999
- .map((part) => part.value)
2000
- .join(''),
2001
- amount: parts
2002
- .filter((part) => part.type !== 'currency' && part.type !== 'literal')
2003
- .map((part) => part.value)
2004
- .join(''),
2005
- full: formatter.format(value),
2006
- };
2007
- }
2008
- catch {
2009
- const amount = value.toFixed(2);
2010
- return { currency: code, amount, full: `${amount} ${code}` };
2011
- }
2012
- }
2013
- function periodLabel(offer, strings) {
2014
- if (offer.kind !== 'subscription')
2015
- return strings.periodOnce;
2016
- return offer.interval === 'year' ? strings.periodYear : strings.periodMonth;
2017
- }
2018
-
2019
- var sharedCss = ":host{--ep-primary-50:#f0f9ff;--ep-primary-100:#e0f2fe;--ep-primary-200:#bae6fd;--ep-primary-300:#7dd3fc;--ep-primary-400:#38bdf8;--ep-primary-500:#0ea5e9;--ep-primary-600:#0284c7;--ep-primary-700:#0369a1;--ep-primary-800:#075985;--ep-primary-900:#0c4a6e;--ep-gray-50:#f9fafb;--ep-gray-100:#f3f4f6;--ep-gray-200:#e5e7eb;--ep-gray-300:#d1d5db;--ep-gray-400:#9ca3af;--ep-gray-500:#6b7280;--ep-gray-600:#4b5563;--ep-gray-700:#374151;--ep-gray-800:#1f2937;--ep-gray-900:#111827;--ep-success-500:#10b981;--ep-success-600:#059669;--ep-error-500:#ef4444;--ep-error-600:#dc2626;--ep-warning-500:#f59e0b;--ep-warning-600:#d97706;--ep-bg-primary:var(--ep-gray-50);--ep-bg-secondary:#ffffff;--ep-bg-tertiary:var(--ep-gray-100);--ep-text-primary:var(--ep-gray-900);--ep-text-secondary:var(--ep-gray-600);--ep-text-tertiary:var(--ep-gray-400);--ep-border-primary:var(--ep-gray-200);--ep-border-secondary:var(--ep-gray-300);--ep-shadow-sm:0 1px 2px 0 rgba(0,0,0,0.05);--ep-shadow-md:0 4px 6px -1px rgba(0,0,0,0.1),0 2px 4px -1px rgba(0,0,0,0.06);--ep-shadow-lg:0 10px 15px -3px rgba(0,0,0,0.1),0 4px 6px -2px rgba(0,0,0,0.05);--ep-shadow-xl:0 20px 25px -5px rgba(0,0,0,0.1),0 10px 10px -5px rgba(0,0,0,0.04);--ep-font-family-sans:-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,\"Helvetica Neue\",Arial,sans-serif;--ep-font-family-mono:\"SF Mono\",Monaco,\"Cascadia Code\",\"Roboto Mono\",Consolas,\"Courier New\",monospace;--ep-font-size-xs:0.75rem;--ep-font-size-sm:0.875rem;--ep-font-size-base:1rem;--ep-font-size-lg:1.125rem;--ep-font-size-xl:1.25rem;--ep-font-size-2xl:1.5rem;--ep-font-size-3xl:1.875rem;--ep-font-size-4xl:2.25rem;--ep-font-size-5xl:3rem;--ep-font-weight-normal:400;--ep-font-weight-medium:500;--ep-font-weight-semibold:600;--ep-font-weight-bold:700;--ep-line-height-tight:1.25;--ep-line-height-snug:1.375;--ep-line-height-normal:1.5;--ep-line-height-relaxed:1.625;--ep-space-1:0.25rem;--ep-space-2:0.5rem;--ep-space-3:0.75rem;--ep-space-4:1rem;--ep-space-5:1.25rem;--ep-space-6:1.5rem;--ep-space-8:2rem;--ep-space-10:2.5rem;--ep-space-12:3rem;--ep-space-16:4rem;--ep-space-20:5rem;--ep-space-24:6rem;--ep-radius-sm:0.125rem;--ep-radius-md:0.375rem;--ep-radius-lg:0.5rem;--ep-radius-xl:0.75rem;--ep-radius-2xl:1rem;--ep-radius-full:9999px;--ep-transition-fast:150ms ease-in-out;--ep-transition-normal:300ms ease-in-out;--ep-transition-slow:500ms ease-in-out;--ep-z-backdrop:1000;--ep-z-modal:1010;--ep-z-popover:1020;--ep-z-tooltip:1030}:host([data-theme=\"dark\"]){--ep-bg-primary:var(--ep-gray-900);--ep-bg-secondary:var(--ep-gray-800);--ep-bg-tertiary:var(--ep-gray-700);--ep-text-primary:var(--ep-gray-50);--ep-text-secondary:var(--ep-gray-300);--ep-text-tertiary:var(--ep-gray-400);--ep-border-primary:var(--ep-gray-700);--ep-border-secondary:var(--ep-gray-600);--ep-shadow-sm:0 1px 2px 0 rgba(0,0,0,0.3);--ep-shadow-md:0 4px 6px -1px rgba(0,0,0,0.4),0 2px 4px -1px rgba(0,0,0,0.3);--ep-shadow-lg:0 10px 15px -3px rgba(0,0,0,0.4),0 4px 6px -2px rgba(0,0,0,0.3);--ep-shadow-xl:0 20px 25px -5px rgba(0,0,0,0.4),0 10px 10px -5px rgba(0,0,0,0.3)}@media (prefers-contrast:high){:host{--ep-border-primary:var(--ep-gray-400);--ep-border-secondary:var(--ep-gray-500)}:host([data-theme=\"dark\"]){--ep-border-primary:var(--ep-gray-500);--ep-border-secondary:var(--ep-gray-400)}}@media (prefers-reduced-motion:reduce){:host{--ep-transition-fast:0ms;--ep-transition-normal:0ms;--ep-transition-slow:0ms}}@media print{:host{--ep-bg-primary:white;--ep-bg-secondary:white;--ep-bg-tertiary:white;--ep-text-primary:black;--ep-text-secondary:black;--ep-text-tertiary:black;--ep-shadow-sm:none;--ep-shadow-md:none;--ep-shadow-lg:none;--ep-shadow-xl:none}}*{box-sizing:border-box;margin:0;padding:0}:host{font-family:var(--ep-font-family-sans);font-size:var(--ep-font-size-base);line-height:var(--ep-line-height-normal);color:var(--ep-text-primary);background-color:var(--ep-bg-primary);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}*:focus{outline:2px solid var(--ep-primary-500);outline-offset:2px}*:focus:not(:focus-visible){outline:none}.ep-container{max-width:1200px;margin:0 auto;padding:0 var(--ep-space-4)}.ep-card{background-color:var(--ep-bg-secondary);border:1px solid var(--ep-border-primary);border-radius:var(--ep-radius-lg);box-shadow:var(--ep-shadow-sm);padding:var(--ep-space-6)}.ep-card-header{margin-bottom:var(--ep-space-6)}.ep-card-body{margin-bottom:var(--ep-space-6)}.ep-card-footer{margin-top:var(--ep-space-6);padding-top:var(--ep-space-6);border-top:1px solid var(--ep-border-primary)}.ep-heading-1{font-size:var(--ep-font-size-3xl);font-weight:var(--ep-font-weight-bold);line-height:var(--ep-line-height-tight);color:var(--ep-text-primary);margin-bottom:var(--ep-space-4)}.ep-heading-2{font-size:var(--ep-font-size-2xl);font-weight:var(--ep-font-weight-semibold);line-height:var(--ep-line-height-tight);color:var(--ep-text-primary);margin-bottom:var(--ep-space-3)}.ep-heading-3{font-size:var(--ep-font-size-xl);font-weight:var(--ep-font-weight-semibold);line-height:var(--ep-line-height-snug);color:var(--ep-text-primary);margin-bottom:var(--ep-space-2)}.ep-text-body{font-size:var(--ep-font-size-base);line-height:var(--ep-line-height-relaxed);color:var(--ep-text-secondary);margin-bottom:var(--ep-space-4)}.ep-text-sm{font-size:var(--ep-font-size-sm);line-height:var(--ep-line-height-normal);color:var(--ep-text-tertiary)}.ep-text-center{text-align:center}.ep-text-left{text-align:left}.ep-text-right{text-align:right}.ep-btn{display:inline-flex;align-items:center;justify-content:center;gap:var(--ep-space-2);padding:var(--ep-space-3) var(--ep-space-6);border:1px solid transparent;border-radius:var(--ep-radius-md);font-family:var(--ep-font-family-sans);font-size:var(--ep-font-size-base);font-weight:var(--ep-font-weight-medium);line-height:var(--ep-line-height-tight);text-decoration:none;cursor:pointer;transition:all var(--ep-transition-fast);user-select:none;white-space:nowrap}.ep-btn:disabled{opacity:0.5;cursor:not-allowed}.ep-btn-primary{background-color:var(--ep-primary-600);color:white;border-color:var(--ep-primary-600)}.ep-btn-primary:hover:not(:disabled){background-color:var(--ep-primary-700);border-color:var(--ep-primary-700)}.ep-btn-primary:active:not(:disabled){background-color:var(--ep-primary-800);border-color:var(--ep-primary-800)}.ep-btn-secondary{background-color:var(--ep-bg-secondary);color:var(--ep-text-primary);border-color:var(--ep-border-secondary)}.ep-btn-secondary:hover:not(:disabled){background-color:var(--ep-bg-tertiary);border-color:var(--ep-border-secondary)}.ep-btn-ghost{background-color:transparent;color:var(--ep-text-secondary);border-color:transparent}.ep-btn-ghost:hover:not(:disabled){background-color:var(--ep-bg-tertiary);color:var(--ep-text-primary)}.ep-btn-sm{padding:var(--ep-space-2) var(--ep-space-4);font-size:var(--ep-font-size-sm)}.ep-btn-lg{padding:var(--ep-space-4) var(--ep-space-8);font-size:var(--ep-font-size-lg)}.ep-btn-full{width:100%}.ep-input{width:100%;padding:var(--ep-space-3);border:1px solid var(--ep-border-primary);border-radius:var(--ep-radius-md);font-family:var(--ep-font-family-sans);font-size:var(--ep-font-size-base);line-height:var(--ep-line-height-normal);color:var(--ep-text-primary);background-color:var(--ep-bg-secondary);transition:border-color var(--ep-transition-fast)}.ep-input:focus{border-color:var(--ep-primary-500);outline:none;box-shadow:0 0 0 3px rgba(14,165,233,0.1)}.ep-input::placeholder{color:var(--ep-text-tertiary)}.ep-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.ep-hidden{display:none}.ep-flex{display:flex}.ep-flex-col{flex-direction:column}.ep-items-center{align-items:center}.ep-justify-center{justify-content:center}.ep-justify-between{justify-content:space-between}.ep-gap-2{gap:var(--ep-space-2)}.ep-gap-4{gap:var(--ep-space-4)}.ep-gap-6{gap:var(--ep-space-6)}.ep-w-full{width:100%}.ep-h-full{height:100%}.ep-mb-4{margin-bottom:var(--ep-space-4)}.ep-mb-6{margin-bottom:var(--ep-space-6)}.ep-p-4{padding:var(--ep-space-4)}.ep-p-6{padding:var(--ep-space-6)}@media (max-width:768px){.ep-container{padding:0 var(--ep-space-3)}.ep-heading-1{font-size:var(--ep-font-size-2xl)}.ep-heading-2{font-size:var(--ep-font-size-xl)}.ep-card{padding:var(--ep-space-4)}.ep-btn{padding:var(--ep-space-4) var(--ep-space-6)}}@media (max-width:480px){.ep-container{padding:0 var(--ep-space-2)}.ep-heading-1{font-size:var(--ep-font-size-xl)}.ep-card{padding:var(--ep-space-3)}}";
2020
-
2021
- const html$4 = "<div class=\"ep-fullscreen-paywall\" id=\"fullscreenPaywall\" role=\"dialog\" aria-labelledby=\"fullscreen-title\"><div class=\"ep-fullscreen-background\"><div class=\"ep-background-pattern\"></div></div><div class=\"ep-fullscreen-header\"><div class=\"ep-fullscreen-logo\"><svg width=\"40\" height=\"40\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M12 2L2 7l10 5 10-5-10-5z\"></path><path d=\"M2 17l10 5 10-5\"></path><path d=\"M2 12l10 5 10-5\"></path></svg><span class=\"ep-fullscreen-logo-text\">{{brandName}}</span></div><button class=\"ep-fullscreen-close\" aria-label=\"Close paywall\" data-ep-action=\"closeFullscreen\"><svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"></line><line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"></line></svg></button></div><div class=\"ep-fullscreen-content\"><div class=\"ep-fullscreen-container\"><div class=\"ep-fullscreen-hero\"><div class=\"ep-hero-icon\"><svg width=\"80\" height=\"80\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M12 2L2 7l10 5 10-5-10-5z\"></path><path d=\"M2 17l10 5 10-5\"></path><path d=\"M2 12l10 5 10-5\"></path></svg></div><h1 class=\"ep-heading-1\" id=\"fullscreen-title\">{{title}}</h1><p class=\"ep-hero-description\">{{description}}</p></div><div class=\"ep-fullscreen-features\"><div class=\"ep-features-grid\"><div class=\"ep-feature-card\"><div class=\"ep-feature-card-icon\"><svg width=\"32\" height=\"32\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M22 12h-4l-3 9L9 3l-3 9H2\"></path></svg></div><h3 class=\"ep-feature-card-title\">{{feature1Title}}</h3><p class=\"ep-feature-card-description\">{{feature1Description}}</p></div><div class=\"ep-feature-card\"><div class=\"ep-feature-card-icon\"><svg width=\"32\" height=\"32\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z\"></path></svg></div><h3 class=\"ep-feature-card-title\">{{feature2Title}}</h3><p class=\"ep-feature-card-description\">{{feature2Description}}</p></div><div class=\"ep-feature-card\"><div class=\"ep-feature-card-icon\"><svg width=\"32\" height=\"32\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M13 2L3 14h9l-1 8 10-12h-9l1-8z\"></path></svg></div><h3 class=\"ep-feature-card-title\">{{feature3Title}}</h3><p class=\"ep-feature-card-description\">{{feature3Description}}</p></div><div class=\"ep-feature-card\"><div class=\"ep-feature-card-icon\"><svg width=\"32\" height=\"32\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z\"></path><polyline points=\"7.5,4.21 12,6.81 16.5,4.21\"></polyline><polyline points=\"7.5,19.79 7.5,14.6 3,12\"></polyline><polyline points=\"21,12 16.5,14.6 16.5,19.79\"></polyline></svg></div><h3 class=\"ep-feature-card-title\">{{feature4Title}}</h3><p class=\"ep-feature-card-description\">{{feature4Description}}</p></div></div></div><div class=\"ep-fullscreen-pricing\"><div class=\"ep-pricing-header\"><h2 class=\"ep-heading-2\">Choose Your Plan</h2><p class=\"ep-pricing-subtitle\">{{pricingSubtitle}}</p></div><div class=\"ep-pricing-plans\"><div class=\"ep-pricing-plan\"><div class=\"ep-pricing-plan-header\"><h3 class=\"ep-pricing-plan-title\">Free</h3><div class=\"ep-pricing-plan-price\"><span class=\"ep-pricing-currency\">{{currency}}</span><span class=\"ep-pricing-amount\">0</span></div><p class=\"ep-pricing-plan-description\">{{freeDescription}}</p></div><ul class=\"ep-pricing-plan-features\"><li class=\"ep-pricing-feature\"><svg class=\"ep-pricing-feature-icon\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"20,6 9,17 4,12\"></polyline></svg> {{freeFeature1}} </li><li class=\"ep-pricing-feature\"><svg class=\"ep-pricing-feature-icon\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"20,6 9,17 4,12\"></polyline></svg> {{freeFeature2}} </li><li class=\"ep-pricing-feature ep-pricing-feature-disabled\"><svg class=\"ep-pricing-feature-icon\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"></line><line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"></line></svg> {{freeFeature3}} </li></ul><button class=\"ep-btn ep-btn-secondary ep-btn-full\" data-ep-action=\"continueFree\"> {{continueButtonText}} </button></div><div class=\"ep-pricing-plan ep-pricing-plan-premium\"><div class=\"ep-pricing-plan-badge\">{{premiumBadge}}</div><div class=\"ep-pricing-plan-header\"><h3 class=\"ep-pricing-plan-title\">Premium</h3><div class=\"ep-pricing-plan-price\"><span class=\"ep-pricing-currency\">{{currency}}</span><span class=\"ep-pricing-amount\">{{price}}</span><span class=\"ep-pricing-period\">{{period}}</span></div><p class=\"ep-pricing-plan-description\">{{premiumDescription}}</p></div><ul class=\"ep-pricing-plan-features\"><li class=\"ep-pricing-feature\"><svg class=\"ep-pricing-feature-icon\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"20,6 9,17 4,12\"></polyline></svg> {{premiumFeature1}} </li><li class=\"ep-pricing-feature\"><svg class=\"ep-pricing-feature-icon\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"20,6 9,17 4,12\"></polyline></svg> {{premiumFeature2}} </li><li class=\"ep-pricing-feature\"><svg class=\"ep-pricing-feature-icon\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"20,6 9,17 4,12\"></polyline></svg> {{premiumFeature3}} </li><li class=\"ep-pricing-feature\"><svg class=\"ep-pricing-feature-icon\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"20,6 9,17 4,12\"></polyline></svg> {{premiumFeature4}} </li></ul><button class=\"ep-btn ep-btn-primary ep-btn-lg ep-btn-full\" data-ep-action=\"upgradeNow\"> {{upgradeButtonText}} </button></div></div></div><div class=\"ep-fullscreen-trial\"><div class=\"ep-trial-card\"><div class=\"ep-trial-icon\"><svg width=\"32\" height=\"32\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M22 11.08V12a10 10 0 1 1-5.93-9.14\"></path><polyline points=\"22,4 12,14.01 9,11.01\"></polyline></svg></div><h3 class=\"ep-trial-title\">{{trialTitle}}</h3><p class=\"ep-trial-description\">{{trialDescription}}</p><button class=\"ep-btn ep-btn-secondary ep-btn-lg\" data-ep-action=\"startTrial\"> {{trialButtonText}} </button></div></div></div></div></div>";
2022
- const css$4 = ".ep-fullscreen-paywall{position:fixed;top:0;left:0;right:0;bottom:0;background-color:var(--ep-bg-primary);z-index:var(--ep-z-modal);display:flex;flex-direction:column;animation:ep-fullscreen-in var(--ep-transition-slow);overflow-y:auto}.ep-fullscreen-paywall.ep-fullscreen-closing{animation:ep-fullscreen-out var(--ep-transition-slow)}.ep-fullscreen-background{position:absolute;top:0;left:0;right:0;bottom:0;overflow:hidden;z-index:-1}.ep-background-pattern{position:absolute;top:-50%;left:-50%;width:200%;height:200%;background:linear-gradient(45deg,transparent 30%,rgba(14,165,233,0.03) 50%,transparent 70%);background-size:60px 60px;animation:ep-background-pattern var(--ep-transition-slow) infinite linear}:host([data-theme=\"dark\"]) .ep-background-pattern{background:linear-gradient(45deg,transparent 30%,rgba(14,165,233,0.05) 50%,transparent 70%)}.ep-fullscreen-header{display:flex;justify-content:space-between;align-items:center;padding:var(--ep-space-6) var(--ep-space-8);border-bottom:1px solid var(--ep-border-primary);background-color:var(--ep-bg-secondary);backdrop-filter:blur(10px);z-index:1}.ep-fullscreen-logo{display:flex;align-items:center;gap:var(--ep-space-3);color:var(--ep-primary-600)}.ep-fullscreen-logo-text{font-size:var(--ep-font-size-xl);font-weight:var(--ep-font-weight-bold);color:var(--ep-text-primary)}.ep-fullscreen-close{background:none;border:none;color:var(--ep-text-tertiary);cursor:pointer;padding:var(--ep-space-2);border-radius:var(--ep-radius-md);transition:all var(--ep-transition-fast)}.ep-fullscreen-close:hover{color:var(--ep-text-primary);background-color:var(--ep-bg-tertiary)}.ep-fullscreen-content{flex:1;padding:var(--ep-space-8);display:flex;align-items:center;justify-content:center}.ep-fullscreen-container{max-width:1200px;width:100%;margin:0 auto}.ep-fullscreen-hero{text-align:center;margin-bottom:var(--ep-space-16)}.ep-hero-icon{width:120px;height:120px;margin:0 auto var(--ep-space-6);background:linear-gradient(135deg,var(--ep-primary-500),var(--ep-primary-600));border-radius:var(--ep-radius-2xl);display:flex;align-items:center;justify-content:center;color:white;box-shadow:var(--ep-shadow-lg);animation:ep-hero-icon-in var(--ep-transition-slow) 0.2s both}.ep-fullscreen-hero .ep-heading-1{font-size:var(--ep-font-size-5xl);margin-bottom:var(--ep-space-6);background:linear-gradient(135deg,var(--ep-primary-600),var(--ep-primary-700));-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text;animation:ep-hero-title-in var(--ep-transition-slow) 0.3s both}.ep-hero-description{font-size:var(--ep-font-size-xl);color:var(--ep-text-secondary);max-width:600px;margin:0 auto;line-height:var(--ep-line-height-relaxed);animation:ep-hero-description-in var(--ep-transition-slow) 0.4s both}.ep-fullscreen-features{margin-bottom:var(--ep-space-16)}.ep-features-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:var(--ep-space-6)}.ep-feature-card{background-color:var(--ep-bg-secondary);border:1px solid var(--ep-border-primary);border-radius:var(--ep-radius-xl);padding:var(--ep-space-8);text-align:center;box-shadow:var(--ep-shadow-sm);transition:all var(--ep-transition-normal);opacity:0;transform:translateY(20px);animation:ep-feature-card-in var(--ep-transition-slow) both}.ep-feature-card:hover{transform:translateY(-4px);box-shadow:var(--ep-shadow-lg)}.ep-feature-card-icon{width:80px;height:80px;margin:0 auto var(--ep-space-4);background:linear-gradient(135deg,var(--ep-primary-500),var(--ep-primary-600));border-radius:var(--ep-radius-xl);display:flex;align-items:center;justify-content:center;color:white}.ep-feature-card-title{font-size:var(--ep-font-size-xl);font-weight:var(--ep-font-weight-semibold);color:var(--ep-text-primary);margin-bottom:var(--ep-space-3)}.ep-feature-card-description{color:var(--ep-text-secondary);line-height:var(--ep-line-height-relaxed);margin:0}.ep-fullscreen-pricing{margin-bottom:var(--ep-space-16)}.ep-pricing-header{text-align:center;margin-bottom:var(--ep-space-10)}.ep-pricing-header .ep-heading-2{font-size:var(--ep-font-size-4xl);margin-bottom:var(--ep-space-4)}.ep-pricing-subtitle{font-size:var(--ep-font-size-lg);color:var(--ep-text-secondary);margin:0}.ep-pricing-plans{display:grid;grid-template-columns:repeat(auto-fit,minmax(320px,1fr));gap:var(--ep-space-8);max-width:800px;margin:0 auto}.ep-pricing-plan{position:relative;background-color:var(--ep-bg-secondary);border:1px solid var(--ep-border-primary);border-radius:var(--ep-radius-xl);padding:var(--ep-space-8);box-shadow:var(--ep-shadow-md);transition:all var(--ep-transition-normal);opacity:0;transform:translateY(20px);animation:ep-pricing-plan-in var(--ep-transition-slow) both}.ep-pricing-plan:hover{transform:translateY(-4px);box-shadow:var(--ep-shadow-lg)}.ep-pricing-plan-premium{border-color:var(--ep-primary-300);box-shadow:var(--ep-shadow-xl);transform:scale(1.05)}.ep-pricing-plan-premium:hover{transform:scale(1.05) translateY(-4px)}.ep-pricing-plan-badge{position:absolute;top:-16px;left:50%;transform:translateX(-50%);background:linear-gradient(135deg,var(--ep-primary-500),var(--ep-primary-600));color:white;padding:var(--ep-space-2) var(--ep-space-6);border-radius:var(--ep-radius-full);font-size:var(--ep-font-size-sm);font-weight:var(--ep-font-weight-semibold);white-space:nowrap}.ep-pricing-plan-header{text-align:center;margin-bottom:var(--ep-space-8)}.ep-pricing-plan-title{font-size:var(--ep-font-size-2xl);font-weight:var(--ep-font-weight-bold);color:var(--ep-text-primary);margin-bottom:var(--ep-space-4)}.ep-pricing-plan-price{display:flex;align-items:baseline;justify-content:center;gap:var(--ep-space-2);margin-bottom:var(--ep-space-3)}.ep-pricing-currency{font-size:var(--ep-font-size-xl);font-weight:var(--ep-font-weight-medium);color:var(--ep-text-secondary)}.ep-pricing-amount{font-size:var(--ep-font-size-5xl);font-weight:var(--ep-font-weight-bold);color:var(--ep-text-primary)}.ep-pricing-period{font-size:var(--ep-font-size-xl);color:var(--ep-text-secondary)}.ep-pricing-plan-description{color:var(--ep-text-secondary);margin:0}.ep-pricing-plan-features{list-style:none;padding:0;margin:0 0 var(--ep-space-8) 0}.ep-pricing-feature{display:flex;align-items:center;gap:var(--ep-space-3);padding:var(--ep-space-3) 0;color:var(--ep-text-primary);font-size:var(--ep-font-size-base)}.ep-pricing-feature-disabled{color:var(--ep-text-tertiary)}.ep-pricing-feature-icon{color:var(--ep-success-500);flex-shrink:0}.ep-pricing-feature-disabled .ep-pricing-feature-icon{color:var(--ep-text-tertiary)}.ep-fullscreen-trial{text-align:center}.ep-trial-card{background:linear-gradient(135deg,var(--ep-success-50),var(--ep-success-100));border:1px solid var(--ep-success-200);border-radius:var(--ep-radius-xl);padding:var(--ep-space-8);max-width:600px;margin:0 auto;box-shadow:var(--ep-shadow-md)}:host([data-theme=\"dark\"]) .ep-trial-card{background:linear-gradient(135deg,rgba(16,185,129,0.1),rgba(16,185,129,0.15));border-color:rgba(16,185,129,0.3)}.ep-trial-icon{width:80px;height:80px;margin:0 auto var(--ep-space-4);background:linear-gradient(135deg,var(--ep-success-500),var(--ep-success-600));border-radius:var(--ep-radius-xl);display:flex;align-items:center;justify-content:center;color:white}.ep-trial-title{font-size:var(--ep-font-size-2xl);font-weight:var(--ep-font-weight-bold);color:var(--ep-success-700);margin-bottom:var(--ep-space-3)}:host([data-theme=\"dark\"]) .ep-trial-title{color:var(--ep-success-400)}.ep-trial-description{color:var(--ep-success-600);font-size:var(--ep-font-size-lg);line-height:var(--ep-line-height-relaxed);margin-bottom:var(--ep-space-6)}:host([data-theme=\"dark\"]) .ep-trial-description{color:var(--ep-success-300)}.ep-theme-toggle{position:fixed;top:var(--ep-space-4);right:var(--ep-space-4);z-index:var(--ep-z-tooltip)}@keyframes ep-fullscreen-in{from{opacity:0;transform:scale(0.98)}to{opacity:1;transform:scale(1)}}@keyframes ep-fullscreen-out{from{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(0.98)}}@keyframes ep-background-pattern{from{transform:translateX(0) translateY(0)}to{transform:translateX(-60px) translateY(-60px)}}@keyframes ep-hero-icon-in{from{opacity:0;transform:scale(0.8)}to{opacity:1;transform:scale(1)}}@keyframes ep-hero-title-in{from{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}@keyframes ep-hero-description-in{from{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}@keyframes ep-feature-card-in{from{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}@keyframes ep-pricing-plan-in{from{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}@media (max-width:1024px){.ep-fullscreen-content{padding:var(--ep-space-6)}.ep-fullscreen-hero{margin-bottom:var(--ep-space-12)}.ep-fullscreen-features{margin-bottom:var(--ep-space-12)}.ep-fullscreen-pricing{margin-bottom:var(--ep-space-12)}.ep-features-grid{grid-template-columns:repeat(auto-fit,minmax(250px,1fr));gap:var(--ep-space-4)}.ep-pricing-plans{gap:var(--ep-space-6)}}@media (max-width:768px){.ep-fullscreen-header{padding:var(--ep-space-4) var(--ep-space-6)}.ep-fullscreen-content{padding:var(--ep-space-4)}.ep-fullscreen-hero .ep-heading-1{font-size:var(--ep-font-size-3xl)}.ep-hero-description{font-size:var(--ep-font-size-lg)}.ep-hero-icon{width:80px;height:80px}.ep-features-grid{grid-template-columns:1fr}.ep-pricing-plans{grid-template-columns:1fr}.ep-pricing-plan-premium{transform:none}.ep-pricing-plan-premium:hover{transform:translateY(-4px)}.ep-feature-card{padding:var(--ep-space-6)}.ep-feature-card-icon{width:60px;height:60px}.ep-pricing-plan{padding:var(--ep-space-6)}.ep-pricing-amount{font-size:var(--ep-font-size-4xl)}}@media (max-width:480px){.ep-fullscreen-header{padding:var(--ep-space-3) var(--ep-space-4)}.ep-fullscreen-logo-text{font-size:var(--ep-font-size-lg)}.ep-fullscreen-content{padding:var(--ep-space-3)}.ep-fullscreen-hero .ep-heading-1{font-size:var(--ep-font-size-2xl)}.ep-hero-description{font-size:var(--ep-font-size-base)}.ep-hero-icon{width:60px;height:60px}.ep-pricing-header .ep-heading-2{font-size:var(--ep-font-size-2xl)}.ep-pricing-amount{font-size:var(--ep-font-size-3xl)}.ep-feature-card-icon{width:48px;height:48px}.ep-trial-icon{width:60px;height:60px}}@media (prefers-contrast:high){.ep-fullscreen-paywall{background-color:var(--ep-bg-primary)}.ep-feature-card{border:2px solid var(--ep-border-secondary)}.ep-pricing-plan{border:2px solid var(--ep-border-secondary)}.ep-pricing-plan-premium{border:2px solid var(--ep-primary-500)}.ep-trial-card{border:2px solid var(--ep-success-500)}}@media (prefers-reduced-motion:reduce){.ep-fullscreen-paywall{animation:none}.ep-background-pattern{animation:none}.ep-hero-icon{animation:none}.ep-fullscreen-hero .ep-heading-1{animation:none}.ep-hero-description{animation:none}.ep-feature-card{animation:none;opacity:1;transform:none}.ep-pricing-plan{animation:none;opacity:1;transform:none}.ep-pricing-plan-premium{transform:none}.ep-feature-card:hover{transform:none}.ep-pricing-plan:hover{transform:none}}";
2023
-
2024
- const html$3 = "<div class=\"ep-inline-paywall\" id=\"inlinePaywall\" role=\"region\" aria-labelledby=\"paywall-title\"><div class=\"ep-inline-header\"><div class=\"ep-inline-icon\"><svg width=\"32\" height=\"32\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M9 12l2 2 4-4\"></path><path d=\"M21 12c-1 0-3-1-3-3s2-3 3-3 3 1 3 3-2 3-3 3\"></path><path d=\"M3 12c1 0 3-1 3-3s-2-3-3-3-3 1-3 3 2 3 3 3\"></path></svg></div><div class=\"ep-inline-header-content\"><h3 class=\"ep-heading-3\" id=\"paywall-title\">{{title}}</h3><p class=\"ep-text-body\">{{description}}</p></div></div><div class=\"ep-inline-content\"><div class=\"ep-inline-features\"><div class=\"ep-feature-grid\"><div class=\"ep-feature-card\"><div class=\"ep-feature-card-icon\"><svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M22 12h-4l-3 9L9 3l-3 9H2\"></path></svg></div><h4 class=\"ep-feature-card-title\">{{feature1Title}}</h4><p class=\"ep-feature-card-description\">{{feature1Description}}</p></div><div class=\"ep-feature-card\"><div class=\"ep-feature-card-icon\"><svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z\"></path></svg></div><h4 class=\"ep-feature-card-title\">{{feature2Title}}</h4><p class=\"ep-feature-card-description\">{{feature2Description}}</p></div><div class=\"ep-feature-card\"><div class=\"ep-feature-card-icon\"><svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M13 2L3 14h9l-1 8 10-12h-9l1-8z\"></path></svg></div><h4 class=\"ep-feature-card-title\">{{feature3Title}}</h4><p class=\"ep-feature-card-description\">{{feature3Description}}</p></div></div></div><div class=\"ep-inline-pricing\"><div class=\"ep-pricing-comparison\"><div class=\"ep-pricing-plan\"><div class=\"ep-pricing-plan-header\"><h4 class=\"ep-pricing-plan-title\">Free</h4><div class=\"ep-pricing-plan-price\"><span class=\"ep-pricing-currency\">{{currency}}</span><span class=\"ep-pricing-amount\">0</span></div></div><ul class=\"ep-pricing-plan-features\"><li class=\"ep-pricing-feature\"><svg class=\"ep-pricing-feature-icon\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"20,6 9,17 4,12\"></polyline></svg> {{freeFeature1}} </li><li class=\"ep-pricing-feature\"><svg class=\"ep-pricing-feature-icon\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"20,6 9,17 4,12\"></polyline></svg> {{freeFeature2}} </li><li class=\"ep-pricing-feature ep-pricing-feature-disabled\"><svg class=\"ep-pricing-feature-icon\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"></line><line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"></line></svg> {{freeFeature3}} </li></ul></div><div class=\"ep-pricing-plan ep-pricing-plan-premium\"><div class=\"ep-pricing-plan-badge\">Most Popular</div><div class=\"ep-pricing-plan-header\"><h4 class=\"ep-pricing-plan-title\">Premium</h4><div class=\"ep-pricing-plan-price\"><span class=\"ep-pricing-currency\">{{currency}}</span><span class=\"ep-pricing-amount\">{{price}}</span><span class=\"ep-pricing-period\">{{period}}</span></div></div><ul class=\"ep-pricing-plan-features\"><li class=\"ep-pricing-feature\"><svg class=\"ep-pricing-feature-icon\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"20,6 9,17 4,12\"></polyline></svg> {{premiumFeature1}} </li><li class=\"ep-pricing-feature\"><svg class=\"ep-pricing-feature-icon\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"20,6 9,17 4,12\"></polyline></svg> {{premiumFeature2}} </li><li class=\"ep-pricing-feature\"><svg class=\"ep-pricing-feature-icon\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"20,6 9,17 4,12\"></polyline></svg> {{premiumFeature3}} </li></ul><button class=\"ep-btn ep-btn-primary ep-btn-full\" data-ep-action=\"upgradeNow\"> {{upgradeButtonText}} </button></div></div></div><div class=\"ep-inline-trial\"><div class=\"ep-trial-content\"><p class=\"ep-trial-text\">{{trialText}}</p><div class=\"ep-trial-actions\"><button class=\"ep-btn ep-btn-secondary\" data-ep-action=\"startTrial\"> {{trialButtonText}} </button><button class=\"ep-btn ep-btn-ghost ep-btn-sm\" data-ep-action=\"dismissPaywall\"> {{dismissButtonText}} </button></div></div></div></div></div>";
2025
- const css$3 = ".ep-inline-paywall{max-width:800px;margin:0 auto;background-color:var(--ep-bg-secondary);border:1px solid var(--ep-border-primary);border-radius:var(--ep-radius-lg);box-shadow:var(--ep-shadow-md);overflow:hidden;opacity:0;transform:translateY(20px);transition:all var(--ep-transition-slow)}.ep-inline-paywall.ep-inline-visible{opacity:1;transform:translateY(0)}.ep-inline-paywall.ep-inline-dismissing{opacity:0;transform:translateY(-20px);transition:all var(--ep-transition-normal)}.ep-inline-header{display:flex;align-items:center;gap:var(--ep-space-4);padding:var(--ep-space-6);background:linear-gradient(135deg,var(--ep-primary-50),var(--ep-primary-100));border-bottom:1px solid var(--ep-border-primary)}:host([data-theme=\"dark\"]) .ep-inline-header{background:linear-gradient(135deg,var(--ep-primary-900),var(--ep-primary-800))}.ep-inline-icon{width:64px;height:64px;background:linear-gradient(135deg,var(--ep-primary-500),var(--ep-primary-600));border-radius:var(--ep-radius-xl);display:flex;align-items:center;justify-content:center;color:white;flex-shrink:0}.ep-inline-header-content{flex:1;min-width:0}.ep-inline-header-content .ep-heading-3{margin-bottom:var(--ep-space-2);color:var(--ep-text-primary)}.ep-inline-header-content .ep-text-body{margin-bottom:0;color:var(--ep-text-secondary)}.ep-inline-content{padding:var(--ep-space-8)}.ep-inline-features{margin-bottom:var(--ep-space-8)}.ep-feature-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:var(--ep-space-4)}.ep-feature-card{background-color:var(--ep-bg-tertiary);border:1px solid var(--ep-border-primary);border-radius:var(--ep-radius-md);padding:var(--ep-space-4);text-align:center;transition:all var(--ep-transition-normal);opacity:0;transform:translateY(10px);animation:ep-feature-card-in var(--ep-transition-slow) forwards}.ep-feature-card:hover{transform:translateY(-2px);box-shadow:var(--ep-shadow-md)}.ep-feature-card-icon{width:48px;height:48px;margin:0 auto var(--ep-space-3);background:linear-gradient(135deg,var(--ep-primary-500),var(--ep-primary-600));border-radius:var(--ep-radius-lg);display:flex;align-items:center;justify-content:center;color:white}.ep-feature-card-title{font-size:var(--ep-font-size-lg);font-weight:var(--ep-font-weight-semibold);color:var(--ep-text-primary);margin-bottom:var(--ep-space-2)}.ep-feature-card-description{color:var(--ep-text-secondary);font-size:var(--ep-font-size-sm);line-height:var(--ep-line-height-relaxed);margin:0}.ep-inline-pricing{margin-bottom:var(--ep-space-8)}.ep-pricing-comparison{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:var(--ep-space-4);max-width:600px;margin:0 auto}.ep-pricing-plan{position:relative;background-color:var(--ep-bg-secondary);border:1px solid var(--ep-border-primary);border-radius:var(--ep-radius-lg);padding:var(--ep-space-6);transition:all var(--ep-transition-normal)}.ep-pricing-plan:hover{transform:translateY(-2px);box-shadow:var(--ep-shadow-md)}.ep-pricing-plan-premium{border-color:var(--ep-primary-300);box-shadow:var(--ep-shadow-lg)}.ep-pricing-plan-badge{position:absolute;top:-12px;left:50%;transform:translateX(-50%);background:linear-gradient(135deg,var(--ep-primary-500),var(--ep-primary-600));color:white;padding:var(--ep-space-1) var(--ep-space-4);border-radius:var(--ep-radius-full);font-size:var(--ep-font-size-sm);font-weight:var(--ep-font-weight-medium);white-space:nowrap}.ep-pricing-plan-header{text-align:center;margin-bottom:var(--ep-space-6)}.ep-pricing-plan-title{font-size:var(--ep-font-size-xl);font-weight:var(--ep-font-weight-semibold);color:var(--ep-text-primary);margin-bottom:var(--ep-space-3)}.ep-pricing-plan-price{display:flex;align-items:baseline;justify-content:center;gap:var(--ep-space-1)}.ep-pricing-currency{font-size:var(--ep-font-size-lg);font-weight:var(--ep-font-weight-medium);color:var(--ep-text-secondary)}.ep-pricing-amount{font-size:var(--ep-font-size-3xl);font-weight:var(--ep-font-weight-bold);color:var(--ep-text-primary)}.ep-pricing-period{font-size:var(--ep-font-size-lg);color:var(--ep-text-secondary)}.ep-pricing-plan-features{list-style:none;padding:0;margin:0 0 var(--ep-space-6) 0}.ep-pricing-feature{display:flex;align-items:center;gap:var(--ep-space-3);padding:var(--ep-space-2) 0;color:var(--ep-text-primary);font-size:var(--ep-font-size-sm)}.ep-pricing-feature-disabled{color:var(--ep-text-tertiary)}.ep-pricing-feature-icon{color:var(--ep-success-500);flex-shrink:0}.ep-pricing-feature-disabled .ep-pricing-feature-icon{color:var(--ep-text-tertiary)}.ep-inline-trial{background:linear-gradient(135deg,var(--ep-gray-50),var(--ep-gray-100));border:1px solid var(--ep-border-primary);border-radius:var(--ep-radius-md);padding:var(--ep-space-6);text-align:center}:host([data-theme=\"dark\"]) .ep-inline-trial{background:linear-gradient(135deg,var(--ep-gray-800),var(--ep-gray-700))}.ep-trial-content{max-width:400px;margin:0 auto}.ep-trial-text{color:var(--ep-text-primary);font-size:var(--ep-font-size-lg);font-weight:var(--ep-font-weight-medium);margin-bottom:var(--ep-space-6)}.ep-trial-actions{display:flex;flex-direction:column;gap:var(--ep-space-3);align-items:center}.ep-theme-toggle{position:fixed;top:var(--ep-space-4);right:var(--ep-space-4);z-index:var(--ep-z-tooltip)}@keyframes ep-feature-card-in{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}@media (max-width:768px){.ep-inline-paywall{margin:var(--ep-space-4)}.ep-inline-header{flex-direction:column;text-align:center;gap:var(--ep-space-3)}.ep-inline-content{padding:var(--ep-space-6)}.ep-feature-grid{grid-template-columns:1fr}.ep-pricing-comparison{grid-template-columns:1fr}.ep-pricing-plan{padding:var(--ep-space-4)}.ep-trial-actions{flex-direction:column;width:100%}.ep-trial-actions .ep-btn{width:100%}}@media (max-width:640px){.ep-inline-paywall{margin:var(--ep-space-2);border-radius:var(--ep-radius-md)}.ep-inline-header{padding:var(--ep-space-4)}.ep-inline-content{padding:var(--ep-space-4)}.ep-inline-icon{width:48px;height:48px}.ep-feature-card-icon{width:40px;height:40px}.ep-pricing-plan{padding:var(--ep-space-3)}.ep-pricing-amount{font-size:var(--ep-font-size-2xl)}}@media (prefers-contrast:high){.ep-inline-paywall{border:2px solid var(--ep-border-secondary)}.ep-feature-card{border:2px solid var(--ep-border-secondary)}.ep-pricing-plan{border:2px solid var(--ep-border-secondary)}.ep-pricing-plan-premium{border:2px solid var(--ep-primary-500)}}@media (prefers-reduced-motion:reduce){.ep-inline-paywall{transition:none;opacity:1;transform:none}.ep-feature-card{transition:none;animation:none;opacity:1;transform:none}.ep-feature-card:hover{transform:none}.ep-pricing-plan:hover{transform:none}}";
2026
-
2027
- const html$2 = "<div class=\"ep-minimal-paywall\" id=\"minimalPaywall\" role=\"dialog\" aria-labelledby=\"minimal-title\"><button class=\"ep-minimal-close\" aria-label=\"Close paywall\" data-ep-action=\"closeMinimal\"><svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"></line><line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"></line></svg></button><div class=\"ep-minimal-content\"><div class=\"ep-minimal-header\"><div class=\"ep-minimal-icon\"><svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M9 12l2 2 4-4\"></path><path d=\"M21 12c-1 0-3-1-3-3s2-3 3-3 3 1 3 3-2 3-3 3\"></path><path d=\"M3 12c1 0 3-1 3-3s-2-3-3-3-3 1-3 3 2 3 3 3\"></path></svg></div><h3 class=\"ep-minimal-title\" id=\"minimal-title\">{{title}}</h3><p class=\"ep-minimal-description\">{{description}}</p></div><div class=\"ep-minimal-pricing\"><div class=\"ep-minimal-price\"><span class=\"ep-minimal-currency\">{{currency}}</span><span class=\"ep-minimal-amount\">{{price}}</span><span class=\"ep-minimal-period\">{{period}}</span></div><p class=\"ep-minimal-price-description\">{{priceDescription}}</p></div><div class=\"ep-minimal-features\"><ul class=\"ep-minimal-feature-list\"><li class=\"ep-minimal-feature\"><svg class=\"ep-minimal-feature-icon\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"20,6 9,17 4,12\"></polyline></svg><span>{{feature1}}</span></li><li class=\"ep-minimal-feature\"><svg class=\"ep-minimal-feature-icon\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"20,6 9,17 4,12\"></polyline></svg><span>{{feature2}}</span></li><li class=\"ep-minimal-feature\"><svg class=\"ep-minimal-feature-icon\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"20,6 9,17 4,12\"></polyline></svg><span>{{feature3}}</span></li></ul></div><div class=\"ep-minimal-actions\"><button class=\"ep-btn ep-btn-primary ep-btn-full\" data-ep-action=\"upgradeNow\"> {{upgradeButtonText}} </button><button class=\"ep-btn ep-btn-ghost ep-btn-sm\" data-ep-action=\"closeMinimal\"> {{dismissButtonText}} </button></div><div class=\"ep-minimal-trial\"><p class=\"ep-minimal-trial-text\">{{trialText}}</p></div></div></div><div class=\"ep-minimal-backdrop\" id=\"minimalBackdrop\"></div>";
2028
- const css$2 = ".ep-minimal-backdrop{position:fixed;top:0;left:0;right:0;bottom:0;background-color:rgba(0,0,0,0.4);z-index:var(--ep-z-backdrop);opacity:0;visibility:hidden;transition:all var(--ep-transition-fast)}.ep-minimal-backdrop.ep-minimal-backdrop-visible{opacity:1;visibility:visible}.ep-minimal-paywall{position:fixed;top:50%;left:50%;transform:translate(-50%,-50%) scale(0.95);background-color:var(--ep-bg-secondary);border:1px solid var(--ep-border-primary);border-radius:var(--ep-radius-lg);box-shadow:var(--ep-shadow-xl);z-index:var(--ep-z-modal);max-width:400px;width:90vw;max-height:90vh;overflow-y:auto;opacity:0;visibility:hidden;transition:all var(--ep-transition-fast)}.ep-minimal-paywall.ep-minimal-visible{opacity:1;visibility:visible;transform:translate(-50%,-50%) scale(1)}.ep-minimal-close{position:absolute;top:var(--ep-space-3);right:var(--ep-space-3);background:none;border:none;color:var(--ep-text-tertiary);cursor:pointer;padding:var(--ep-space-2);border-radius:var(--ep-radius-sm);transition:all var(--ep-transition-fast);z-index:1}.ep-minimal-close:hover{color:var(--ep-text-primary);background-color:var(--ep-bg-tertiary)}.ep-minimal-content{padding:var(--ep-space-6);padding-top:var(--ep-space-8)}.ep-minimal-header{text-align:center;margin-bottom:var(--ep-space-6)}.ep-minimal-icon{width:48px;height:48px;margin:0 auto var(--ep-space-3);background:linear-gradient(135deg,var(--ep-primary-500),var(--ep-primary-600));border-radius:var(--ep-radius-lg);display:flex;align-items:center;justify-content:center;color:white}.ep-minimal-title{font-size:var(--ep-font-size-xl);font-weight:var(--ep-font-weight-semibold);color:var(--ep-text-primary);margin-bottom:var(--ep-space-2)}.ep-minimal-description{color:var(--ep-text-secondary);font-size:var(--ep-font-size-sm);line-height:var(--ep-line-height-relaxed);margin:0}.ep-minimal-pricing{text-align:center;margin-bottom:var(--ep-space-6);padding:var(--ep-space-4);background:linear-gradient(135deg,var(--ep-primary-50),var(--ep-primary-100));border:1px solid var(--ep-primary-200);border-radius:var(--ep-radius-md)}:host([data-theme=\"dark\"]) .ep-minimal-pricing{background:linear-gradient(135deg,var(--ep-primary-900),var(--ep-primary-800));border-color:var(--ep-primary-700)}.ep-minimal-price{display:flex;align-items:baseline;justify-content:center;gap:var(--ep-space-1);margin-bottom:var(--ep-space-2)}.ep-minimal-currency{font-size:var(--ep-font-size-base);font-weight:var(--ep-font-weight-medium);color:var(--ep-text-secondary)}.ep-minimal-amount{font-size:var(--ep-font-size-2xl);font-weight:var(--ep-font-weight-bold);color:var(--ep-text-primary)}.ep-minimal-period{font-size:var(--ep-font-size-base);color:var(--ep-text-secondary)}.ep-minimal-price-description{color:var(--ep-text-secondary);font-size:var(--ep-font-size-xs);margin:0}.ep-minimal-features{margin-bottom:var(--ep-space-6)}.ep-minimal-feature-list{list-style:none;padding:0;margin:0}.ep-minimal-feature{display:flex;align-items:center;gap:var(--ep-space-2);padding:var(--ep-space-2) 0;color:var(--ep-text-primary);font-size:var(--ep-font-size-sm);border-bottom:1px solid var(--ep-border-primary)}.ep-minimal-feature:last-child{border-bottom:none}.ep-minimal-feature-icon{color:var(--ep-success-500);flex-shrink:0}.ep-minimal-feature span{font-weight:var(--ep-font-weight-medium)}.ep-minimal-actions{display:flex;flex-direction:column;gap:var(--ep-space-2);margin-bottom:var(--ep-space-4)}.ep-minimal-trial{text-align:center;padding-top:var(--ep-space-4);border-top:1px solid var(--ep-border-primary)}.ep-minimal-trial-text{color:var(--ep-text-tertiary);font-size:var(--ep-font-size-xs);margin:0}.ep-theme-toggle{position:fixed;top:var(--ep-space-4);left:var(--ep-space-4);z-index:var(--ep-z-tooltip);display:flex;flex-direction:column;gap:var(--ep-space-2)}@media (max-width:480px){.ep-minimal-paywall{width:95vw;max-width:none}.ep-minimal-content{padding:var(--ep-space-4);padding-top:var(--ep-space-6)}.ep-minimal-close{top:var(--ep-space-2);right:var(--ep-space-2)}.ep-minimal-icon{width:40px;height:40px}.ep-minimal-title{font-size:var(--ep-font-size-lg)}.ep-minimal-amount{font-size:var(--ep-font-size-xl)}.ep-minimal-pricing{padding:var(--ep-space-3)}}@media (prefers-contrast:high){.ep-minimal-paywall{border:2px solid var(--ep-border-secondary)}.ep-minimal-pricing{border:2px solid var(--ep-primary-500)}.ep-minimal-backdrop{background-color:rgba(0,0,0,0.8)}}@media (prefers-reduced-motion:reduce){.ep-minimal-backdrop{transition:none}.ep-minimal-paywall{transition:none;transform:translate(-50%,-50%)}.ep-minimal-paywall.ep-minimal-visible{transform:translate(-50%,-50%)}}@media print{.ep-minimal-backdrop{display:none}.ep-minimal-paywall{position:static;transform:none;box-shadow:none;border:1px solid black;opacity:1;visibility:visible}.ep-minimal-close{display:none}}.ep-minimal-paywall *:focus{outline:2px solid var(--ep-primary-500);outline-offset:2px}.ep-minimal-paywall *:focus:not(:focus-visible){outline:none}.ep-minimal-paywall{animation:ep-minimal-entrance var(--ep-transition-normal) ease-out}@keyframes ep-minimal-entrance{from{opacity:0;transform:translate(-50%,-50%) scale(0.9)}to{opacity:1;transform:translate(-50%,-50%) scale(1)}}.ep-minimal-feature:hover{background-color:var(--ep-bg-tertiary);border-radius:var(--ep-radius-sm);margin:0 calc(-1 * var(--ep-space-2));padding:var(--ep-space-2)}.ep-minimal-pricing:hover{background:linear-gradient(135deg,var(--ep-primary-100),var(--ep-primary-200));border-color:var(--ep-primary-300)}:host([data-theme=\"dark\"]) .ep-minimal-pricing:hover{background:linear-gradient(135deg,var(--ep-primary-800),var(--ep-primary-700));border-color:var(--ep-primary-600)}";
2029
-
2030
- const html$1 = "<div class=\"ep-modal-backdrop\" id=\"paywallModal\" role=\"dialog\" aria-labelledby=\"paywall-title\" aria-describedby=\"paywall-description\"><div class=\"ep-modal-container\"><button class=\"ep-modal-close\" aria-label=\"Close paywall\" data-ep-action=\"closePaywall\"><svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"></line><line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"></line></svg></button><div class=\"ep-modal-content\"><div class=\"ep-modal-header\"><div class=\"ep-modal-icon\"><svg width=\"48\" height=\"48\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"3\" y=\"11\" width=\"18\" height=\"11\" rx=\"2\" ry=\"2\"></rect><path d=\"m7 11V7a5 5 0 0 1 10 0v4\"></path></svg></div><h2 class=\"ep-heading-2\" id=\"paywall-title\">{{title}}</h2><p class=\"ep-text-body\" id=\"paywall-description\">{{description}}</p></div><div class=\"ep-modal-features\"><h3 class=\"ep-heading-3\">Premium Features</h3><ul class=\"ep-feature-list\"><li class=\"ep-feature-item\"><svg class=\"ep-feature-icon\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"20,6 9,17 4,12\"></polyline></svg><span>{{feature1}}</span></li><li class=\"ep-feature-item\"><svg class=\"ep-feature-icon\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"20,6 9,17 4,12\"></polyline></svg><span>{{feature2}}</span></li><li class=\"ep-feature-item\"><svg class=\"ep-feature-icon\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"20,6 9,17 4,12\"></polyline></svg><span>{{feature3}}</span></li></ul></div><div class=\"ep-modal-pricing\"><div class=\"ep-pricing-card\"><div class=\"ep-pricing-header\"><div class=\"ep-pricing-price\"><span class=\"ep-pricing-currency\">{{currency}}</span><span class=\"ep-pricing-amount\">{{price}}</span><span class=\"ep-pricing-period\">{{period}}</span></div><p class=\"ep-pricing-description\">{{pricingDescription}}</p></div><div class=\"ep-trial-info\"><p class=\"ep-text-sm\">{{trialInfo}}</p></div></div></div><div class=\"ep-modal-actions\"><button class=\"ep-btn ep-btn-primary ep-btn-lg ep-btn-full\" data-ep-action=\"upgradeNow\"> {{upgradeButtonText}} </button><button class=\"ep-btn ep-btn-ghost ep-btn-sm\" data-ep-action=\"closePaywall\"> {{cancelButtonText}} </button></div><div class=\"ep-modal-footer\"><p class=\"ep-text-sm\">{{footerText}}</p></div></div></div></div>";
2031
- const css$1 = ".ep-modal-backdrop{position:fixed;top:0;left:0;right:0;bottom:0;background-color:rgba(0,0,0,0.75);backdrop-filter:blur(4px);z-index:var(--ep-z-modal);display:flex;align-items:center;justify-content:center;padding:var(--ep-space-4);animation:ep-modal-backdrop-in var(--ep-transition-normal)}.ep-modal-backdrop.ep-modal-closing{animation:ep-modal-backdrop-out var(--ep-transition-normal)}.ep-modal-container{position:relative;background-color:var(--ep-bg-secondary);border-radius:var(--ep-radius-xl);box-shadow:var(--ep-shadow-xl);max-width:480px;width:100%;max-height:90vh;overflow-y:auto;animation:ep-modal-container-in var(--ep-transition-normal)}.ep-modal-backdrop.ep-modal-closing .ep-modal-container{animation:ep-modal-container-out var(--ep-transition-normal)}.ep-modal-close{position:absolute;top:var(--ep-space-4);right:var(--ep-space-4);background:none;border:none;color:var(--ep-text-tertiary);cursor:pointer;padding:var(--ep-space-2);border-radius:var(--ep-radius-md);transition:all var(--ep-transition-fast);z-index:1}.ep-modal-close:hover{color:var(--ep-text-primary);background-color:var(--ep-bg-tertiary)}.ep-modal-close:focus{outline:2px solid var(--ep-primary-500);outline-offset:2px}.ep-modal-content{padding:var(--ep-space-8);padding-top:var(--ep-space-12)}.ep-modal-header{text-align:center;margin-bottom:var(--ep-space-8)}.ep-modal-icon{width:80px;height:80px;margin:0 auto var(--ep-space-4);background:linear-gradient(135deg,var(--ep-primary-500),var(--ep-primary-600));border-radius:var(--ep-radius-2xl);display:flex;align-items:center;justify-content:center;color:white}.ep-modal-header .ep-heading-2{margin-bottom:var(--ep-space-3)}.ep-modal-header .ep-text-body{margin-bottom:0;font-size:var(--ep-font-size-lg)}.ep-modal-features{margin-bottom:var(--ep-space-8)}.ep-modal-features .ep-heading-3{margin-bottom:var(--ep-space-4);text-align:center}.ep-feature-list{list-style:none;padding:0;margin:0}.ep-feature-item{display:flex;align-items:center;gap:var(--ep-space-3);padding:var(--ep-space-3) 0;border-bottom:1px solid var(--ep-border-primary)}.ep-feature-item:last-child{border-bottom:none}.ep-feature-icon{color:var(--ep-success-500);flex-shrink:0}.ep-feature-item span{color:var(--ep-text-primary);font-weight:var(--ep-font-weight-medium)}.ep-modal-pricing{margin-bottom:var(--ep-space-8)}.ep-pricing-card{background:linear-gradient(135deg,var(--ep-primary-50),var(--ep-primary-100));border:1px solid var(--ep-primary-200);border-radius:var(--ep-radius-lg);padding:var(--ep-space-6);text-align:center}:host([data-theme=\"dark\"]) .ep-pricing-card{background:linear-gradient(135deg,var(--ep-primary-900),var(--ep-primary-800));border-color:var(--ep-primary-700)}.ep-pricing-header{margin-bottom:var(--ep-space-4)}.ep-pricing-price{display:flex;align-items:baseline;justify-content:center;gap:var(--ep-space-1);margin-bottom:var(--ep-space-2)}.ep-pricing-currency{font-size:var(--ep-font-size-lg);font-weight:var(--ep-font-weight-medium);color:var(--ep-text-secondary)}.ep-pricing-amount{font-size:var(--ep-font-size-4xl);font-weight:var(--ep-font-weight-bold);color:var(--ep-text-primary)}.ep-pricing-period{font-size:var(--ep-font-size-lg);color:var(--ep-text-secondary)}.ep-pricing-description{color:var(--ep-text-secondary);margin:0}.ep-trial-info{background-color:var(--ep-success-50);border:1px solid var(--ep-success-200);border-radius:var(--ep-radius-md);padding:var(--ep-space-3);margin-top:var(--ep-space-4)}:host([data-theme=\"dark\"]) .ep-trial-info{background-color:rgba(16,185,129,0.1);border-color:rgba(16,185,129,0.3)}.ep-trial-info .ep-text-sm{color:var(--ep-success-700);margin:0;font-weight:var(--ep-font-weight-medium)}:host([data-theme=\"dark\"]) .ep-trial-info .ep-text-sm{color:var(--ep-success-400)}.ep-modal-actions{display:flex;flex-direction:column;gap:var(--ep-space-3);margin-bottom:var(--ep-space-6)}.ep-modal-footer{text-align:center;padding-top:var(--ep-space-6);border-top:1px solid var(--ep-border-primary)}.ep-modal-footer .ep-text-sm{margin:0}.ep-theme-toggle{position:fixed;top:var(--ep-space-4);left:var(--ep-space-4);z-index:var(--ep-z-tooltip)}@keyframes ep-modal-backdrop-in{from{opacity:0}to{opacity:1}}@keyframes ep-modal-backdrop-out{from{opacity:1}to{opacity:0}}@keyframes ep-modal-container-in{from{opacity:0;transform:scale(0.95) translateY(-10px)}to{opacity:1;transform:scale(1) translateY(0)}}@keyframes ep-modal-container-out{from{opacity:1;transform:scale(1) translateY(0)}to{opacity:0;transform:scale(0.95) translateY(-10px)}}@media (max-width:640px){.ep-modal-backdrop{padding:var(--ep-space-2)}.ep-modal-container{max-width:100%;border-radius:var(--ep-radius-lg)}.ep-modal-content{padding:var(--ep-space-6);padding-top:var(--ep-space-10)}.ep-modal-icon{width:60px;height:60px}.ep-modal-header .ep-heading-2{font-size:var(--ep-font-size-xl)}.ep-pricing-amount{font-size:var(--ep-font-size-3xl)}}@media (max-width:480px){.ep-modal-content{padding:var(--ep-space-4);padding-top:var(--ep-space-8)}.ep-modal-close{top:var(--ep-space-3);right:var(--ep-space-3)}}@media (prefers-contrast:high){.ep-modal-backdrop{background-color:rgba(0,0,0,0.9);backdrop-filter:none}.ep-modal-container{border:2px solid var(--ep-border-secondary)}.ep-pricing-card{background:var(--ep-bg-secondary);border:2px solid var(--ep-primary-500)}}@media (prefers-reduced-motion:reduce){.ep-modal-backdrop{animation:none}.ep-modal-container{animation:none}.ep-modal-backdrop.ep-modal-closing{animation:none}.ep-modal-backdrop.ep-modal-closing .ep-modal-container{animation:none}}";
2032
-
2033
- const html = "<div class=\"ep-sidebar-backdrop\" id=\"sidebarBackdrop\"></div><div class=\"ep-sidebar-paywall\" id=\"sidebarPaywall\" role=\"dialog\" aria-labelledby=\"sidebar-title\" aria-describedby=\"sidebar-description\"><div class=\"ep-sidebar-header\"><button class=\"ep-sidebar-close\" aria-label=\"Close paywall\" data-ep-action=\"closeSidebar\"><svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"></line><line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"></line></svg></button><div class=\"ep-sidebar-logo\"><svg width=\"32\" height=\"32\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M12 2L2 7l10 5 10-5-10-5z\"></path><path d=\"M2 17l10 5 10-5\"></path><path d=\"M2 12l10 5 10-5\"></path></svg><span class=\"ep-sidebar-logo-text\">{{brandName}}</span></div></div><div class=\"ep-sidebar-content\"><div class=\"ep-sidebar-title-section\"><h2 class=\"ep-heading-2\" id=\"sidebar-title\">{{title}}</h2><p class=\"ep-text-body\" id=\"sidebar-description\">{{description}}</p></div><div class=\"ep-sidebar-progress\"><div class=\"ep-progress-header\"><span class=\"ep-progress-label\">{{progressLabel}}</span><span class=\"ep-progress-value\">{{usageCount}}/{{usageLimit}}</span></div><div class=\"ep-progress-bar\"><div class=\"ep-progress-fill\" style=\"width: {{progressPercentage}}%\"></div></div><p class=\"ep-progress-text\">{{progressText}}</p></div><div class=\"ep-sidebar-features\"><h3 class=\"ep-heading-3\">Unlock Premium Features</h3><div class=\"ep-feature-list\"><div class=\"ep-feature-item\"><div class=\"ep-feature-icon\"><svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M12 2L2 7l10 5 10-5-10-5z\"></path><path d=\"M2 17l10 5 10-5\"></path><path d=\"M2 12l10 5 10-5\"></path></svg></div><div class=\"ep-feature-content\"><h4 class=\"ep-feature-title\">{{feature1Title}}</h4><p class=\"ep-feature-description\">{{feature1Description}}</p></div></div><div class=\"ep-feature-item\"><div class=\"ep-feature-icon\"><svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M22 12h-4l-3 9L9 3l-3 9H2\"></path></svg></div><div class=\"ep-feature-content\"><h4 class=\"ep-feature-title\">{{feature2Title}}</h4><p class=\"ep-feature-description\">{{feature2Description}}</p></div></div><div class=\"ep-feature-item\"><div class=\"ep-feature-icon\"><svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z\"></path></svg></div><div class=\"ep-feature-content\"><h4 class=\"ep-feature-title\">{{feature3Title}}</h4><p class=\"ep-feature-description\">{{feature3Description}}</p></div></div></div></div><div class=\"ep-sidebar-pricing\"><div class=\"ep-pricing-card\"><div class=\"ep-pricing-header\"><div class=\"ep-pricing-badge\">{{pricingBadge}}</div><div class=\"ep-pricing-price\"><span class=\"ep-pricing-currency\">{{currency}}</span><span class=\"ep-pricing-amount\">{{price}}</span><span class=\"ep-pricing-period\">{{period}}</span></div><p class=\"ep-pricing-description\">{{pricingDescription}}</p></div></div></div><div class=\"ep-sidebar-trial\"><div class=\"ep-trial-info\"><div class=\"ep-trial-icon\"><svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M22 11.08V12a10 10 0 1 1-5.93-9.14\"></path><polyline points=\"22,4 12,14.01 9,11.01\"></polyline></svg></div><div class=\"ep-trial-content\"><h4 class=\"ep-trial-title\">{{trialTitle}}</h4><p class=\"ep-trial-description\">{{trialDescription}}</p></div></div></div></div><div class=\"ep-sidebar-footer\"><button class=\"ep-btn ep-btn-primary ep-btn-lg ep-btn-full\" data-ep-action=\"startUpgrade\"> {{upgradeButtonText}} </button><button class=\"ep-btn ep-btn-secondary ep-btn-full\" data-ep-action=\"startTrial\"> {{trialButtonText}} </button><button class=\"ep-btn ep-btn-ghost ep-btn-sm\" data-ep-action=\"remindLater\"> {{remindLaterText}} </button></div></div>";
2034
- const css = ".ep-sidebar-backdrop{position:fixed;top:0;left:0;right:0;bottom:0;background-color:rgba(0,0,0,0.5);backdrop-filter:blur(2px);z-index:var(--ep-z-backdrop);opacity:0;visibility:hidden;transition:all var(--ep-transition-normal)}.ep-sidebar-backdrop.ep-sidebar-backdrop-visible{opacity:1;visibility:visible}.ep-sidebar-paywall{position:fixed;top:0;right:0;bottom:0;width:400px;max-width:90vw;background-color:var(--ep-bg-secondary);border-left:1px solid var(--ep-border-primary);box-shadow:var(--ep-shadow-xl);z-index:var(--ep-z-modal);display:flex;flex-direction:column;transform:translateX(100%);transition:transform var(--ep-transition-normal)}.ep-sidebar-paywall.ep-sidebar-visible{transform:translateX(0)}.ep-sidebar-header{display:flex;align-items:center;justify-content:space-between;padding:var(--ep-space-4) var(--ep-space-6);border-bottom:1px solid var(--ep-border-primary);background:linear-gradient(135deg,var(--ep-primary-50),var(--ep-primary-100))}:host([data-theme=\"dark\"]) .ep-sidebar-header{background:linear-gradient(135deg,var(--ep-primary-900),var(--ep-primary-800))}.ep-sidebar-close{background:none;border:none;color:var(--ep-text-tertiary);cursor:pointer;padding:var(--ep-space-2);border-radius:var(--ep-radius-md);transition:all var(--ep-transition-fast)}.ep-sidebar-close:hover{color:var(--ep-text-primary);background-color:var(--ep-bg-tertiary)}.ep-sidebar-logo{display:flex;align-items:center;gap:var(--ep-space-2);color:var(--ep-primary-600)}.ep-sidebar-logo-text{font-size:var(--ep-font-size-lg);font-weight:var(--ep-font-weight-semibold);color:var(--ep-text-primary)}.ep-sidebar-content{flex:1;padding:var(--ep-space-6);overflow-y:auto;display:flex;flex-direction:column;gap:var(--ep-space-6)}.ep-sidebar-title-section{text-align:center}.ep-sidebar-title-section .ep-heading-2{margin-bottom:var(--ep-space-3);color:var(--ep-text-primary)}.ep-sidebar-title-section .ep-text-body{margin-bottom:0;color:var(--ep-text-secondary)}.ep-sidebar-progress{background-color:var(--ep-bg-tertiary);border:1px solid var(--ep-border-primary);border-radius:var(--ep-radius-md);padding:var(--ep-space-4)}.ep-progress-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:var(--ep-space-3)}.ep-progress-label{font-size:var(--ep-font-size-sm);font-weight:var(--ep-font-weight-medium);color:var(--ep-text-primary)}.ep-progress-value{font-size:var(--ep-font-size-sm);font-weight:var(--ep-font-weight-semibold);color:var(--ep-primary-600)}.ep-progress-bar{height:8px;background-color:var(--ep-bg-primary);border-radius:var(--ep-radius-full);overflow:hidden;margin-bottom:var(--ep-space-2)}.ep-progress-fill{height:100%;background:linear-gradient(90deg,var(--ep-primary-500),var(--ep-primary-600));border-radius:var(--ep-radius-full);transition:width var(--ep-transition-normal)}.ep-progress-text{font-size:var(--ep-font-size-xs);color:var(--ep-text-tertiary);margin:0}.ep-sidebar-features .ep-heading-3{margin-bottom:var(--ep-space-4);text-align:center}.ep-feature-list{display:flex;flex-direction:column;gap:var(--ep-space-4)}.ep-feature-item{display:flex;align-items:flex-start;gap:var(--ep-space-3);padding:var(--ep-space-3);background-color:var(--ep-bg-tertiary);border:1px solid var(--ep-border-primary);border-radius:var(--ep-radius-md);opacity:0;transform:translateX(20px);transition:all var(--ep-transition-normal)}.ep-feature-item.ep-feature-item-visible{opacity:1;transform:translateX(0)}.ep-feature-icon{width:40px;height:40px;background:linear-gradient(135deg,var(--ep-primary-500),var(--ep-primary-600));border-radius:var(--ep-radius-lg);display:flex;align-items:center;justify-content:center;color:white;flex-shrink:0}.ep-feature-content{flex:1;min-width:0}.ep-feature-title{font-size:var(--ep-font-size-base);font-weight:var(--ep-font-weight-semibold);color:var(--ep-text-primary);margin-bottom:var(--ep-space-1)}.ep-feature-description{font-size:var(--ep-font-size-sm);color:var(--ep-text-secondary);line-height:var(--ep-line-height-relaxed);margin:0}.ep-sidebar-pricing{background:linear-gradient(135deg,var(--ep-primary-50),var(--ep-primary-100));border:1px solid var(--ep-primary-200);border-radius:var(--ep-radius-lg);padding:var(--ep-space-4)}:host([data-theme=\"dark\"]) .ep-sidebar-pricing{background:linear-gradient(135deg,var(--ep-primary-900),var(--ep-primary-800));border-color:var(--ep-primary-700)}.ep-pricing-card{text-align:center}.ep-pricing-header{margin-bottom:var(--ep-space-4)}.ep-pricing-badge{background:linear-gradient(135deg,var(--ep-primary-500),var(--ep-primary-600));color:white;padding:var(--ep-space-1) var(--ep-space-3);border-radius:var(--ep-radius-full);font-size:var(--ep-font-size-xs);font-weight:var(--ep-font-weight-medium);display:inline-block;margin-bottom:var(--ep-space-3)}.ep-pricing-price{display:flex;align-items:baseline;justify-content:center;gap:var(--ep-space-1);margin-bottom:var(--ep-space-2)}.ep-pricing-currency{font-size:var(--ep-font-size-base);font-weight:var(--ep-font-weight-medium);color:var(--ep-text-secondary)}.ep-pricing-amount{font-size:var(--ep-font-size-2xl);font-weight:var(--ep-font-weight-bold);color:var(--ep-text-primary)}.ep-pricing-period{font-size:var(--ep-font-size-base);color:var(--ep-text-secondary)}.ep-pricing-description{font-size:var(--ep-font-size-sm);color:var(--ep-text-secondary);margin:0}.ep-sidebar-trial{background-color:var(--ep-success-50);border:1px solid var(--ep-success-200);border-radius:var(--ep-radius-md);padding:var(--ep-space-4)}:host([data-theme=\"dark\"]) .ep-sidebar-trial{background-color:rgba(16,185,129,0.1);border-color:rgba(16,185,129,0.3)}.ep-trial-info{display:flex;align-items:flex-start;gap:var(--ep-space-3)}.ep-trial-icon{width:32px;height:32px;background:linear-gradient(135deg,var(--ep-success-500),var(--ep-success-600));border-radius:var(--ep-radius-lg);display:flex;align-items:center;justify-content:center;color:white;flex-shrink:0}.ep-trial-content{flex:1;min-width:0}.ep-trial-title{font-size:var(--ep-font-size-base);font-weight:var(--ep-font-weight-semibold);color:var(--ep-success-700);margin-bottom:var(--ep-space-1)}:host([data-theme=\"dark\"]) .ep-trial-title{color:var(--ep-success-400)}.ep-trial-description{font-size:var(--ep-font-size-sm);color:var(--ep-success-600);line-height:var(--ep-line-height-relaxed);margin:0}:host([data-theme=\"dark\"]) .ep-trial-description{color:var(--ep-success-300)}.ep-sidebar-footer{padding:var(--ep-space-6);border-top:1px solid var(--ep-border-primary);background-color:var(--ep-bg-tertiary);display:flex;flex-direction:column;gap:var(--ep-space-3)}.ep-theme-toggle{position:fixed;top:var(--ep-space-4);left:var(--ep-space-4);z-index:var(--ep-z-tooltip);display:flex;flex-direction:column;gap:var(--ep-space-2)}@media (max-width:768px){.ep-sidebar-paywall{width:100%;max-width:100%;border-left:none}.ep-sidebar-content{padding:var(--ep-space-4)}.ep-sidebar-footer{padding:var(--ep-space-4)}}@media (max-width:480px){.ep-sidebar-header{padding:var(--ep-space-3) var(--ep-space-4)}.ep-sidebar-content{padding:var(--ep-space-3);gap:var(--ep-space-4)}.ep-sidebar-footer{padding:var(--ep-space-3)}.ep-feature-item{padding:var(--ep-space-2)}.ep-feature-icon{width:32px;height:32px}.ep-pricing-amount{font-size:var(--ep-font-size-xl)}}@media (prefers-contrast:high){.ep-sidebar-paywall{border-left:2px solid var(--ep-border-secondary)}.ep-feature-item{border:2px solid var(--ep-border-secondary)}.ep-sidebar-pricing{border:2px solid var(--ep-primary-500)}.ep-sidebar-trial{border:2px solid var(--ep-success-500)}}@media (prefers-reduced-motion:reduce){.ep-sidebar-backdrop{transition:none}.ep-sidebar-paywall{transition:none}.ep-feature-item{transition:none;opacity:1;transform:none}.ep-progress-fill{transition:none}}";
2035
-
2036
- /**
2037
- * The five templates from `@extenshi-io/paywall-templates`, inlined at build
2038
- * time by build/paywall-templates-plugin.mjs. No runtime fetch, no
2039
- * `web_accessible_resources`, no remote code.
2040
- */
2041
- const PAYWALL_SHARED_CSS = sharedCss;
2042
- const PAYWALL_TEMPLATES = {
2043
- modal: { html: html$1, css: css$1 },
2044
- inline: { html: html$3, css: css$3 },
2045
- sidebar: { html: html, css: css },
2046
- fullscreen: { html: html$4, css: css$4 },
2047
- minimal: { html: html$2, css: css$2 },
2048
- };
2049
- const PAYWALL_MODES = Object.keys(PAYWALL_TEMPLATES);
2050
-
2051
- /**
2052
- * The one paywall renderer.
2053
- *
2054
- * Renders a template from `@extenshi-io/paywall-templates` into a Shadow DOM
2055
- * host so the templates' resets never leak into the extension page (and vice
2056
- * versa). Placeholders (`{{title}}`, `{{price}}` …) are filled from the offer
2057
- * and the strings dictionary, every value HTML-escaped; buttons are bound with
2058
- * `addEventListener` on `data-ep-action` (no inline handlers, no scripts).
2059
- */
2060
- const PAYWALL_HOST_CLASS = 'extenshi-paywall-host';
2061
- const UPGRADE_ACTIONS = new Set(['upgradeNow', 'startUpgrade']);
2062
- const CLOSE_ACTIONS = new Set([
2063
- 'closePaywall',
2064
- 'closeSidebar',
2065
- 'closeFullscreen',
2066
- 'closeMinimal',
2067
- 'dismissPaywall',
2068
- 'remindLater',
2069
- 'continueFree',
2070
- ]);
2071
- const ROOT_SELECTOR = {
2072
- modal: '.ep-modal-backdrop',
2073
- inline: '.ep-inline-paywall',
2074
- sidebar: '.ep-sidebar-paywall',
2075
- fullscreen: '.ep-fullscreen-paywall',
2076
- minimal: '.ep-minimal-paywall',
2077
- };
2078
- const BACKDROP_SELECTOR = {
2079
- modal: '.ep-modal-backdrop',
2080
- sidebar: '.ep-sidebar-backdrop',
2081
- minimal: '.ep-minimal-backdrop',
2082
- };
2083
- const VISIBLE_CLASSES = {
2084
- inline: [['.ep-inline-paywall', 'ep-inline-visible']],
2085
- sidebar: [
2086
- ['.ep-sidebar-paywall', 'ep-sidebar-visible'],
2087
- ['.ep-sidebar-backdrop', 'ep-sidebar-backdrop-visible'],
2088
- ],
2089
- minimal: [
2090
- ['.ep-minimal-paywall', 'ep-minimal-visible'],
2091
- ['.ep-minimal-backdrop', 'ep-minimal-backdrop-visible'],
2092
- ],
2093
- };
2094
- /** Template blocks the contract has no data for (trials, usage meters). */
2095
- const PRUNE_SELECTOR = '[class*="-trial"], .ep-sidebar-progress';
2096
- /**
2097
- * Templates stagger their feature rows in with this class from their demo
2098
- * script (sidebar, fullscreen); without it the rows sit at opacity 0.
2099
- */
2100
- const FEATURE_ITEM_VISIBLE = ['.ep-feature-item', 'ep-feature-item-visible'];
2101
- /** Containers of a single feature slot; dropped when the slot's placeholder is empty. */
2102
- const FEATURE_SLOT_SELECTOR = 'li, .ep-feature-card, .ep-feature-item, .ep-pricing-feature, .ep-feature';
2103
- const EMPTY_SLOT_MARK = 'data-ep-empty';
2104
- const FEATURE_KEY_RE = /^(feature\d+(Title)?|premiumFeature\d+|freeFeature\d+)$/;
2105
- function escapeHtml(value) {
2106
- return value
2107
- .replace(/&/g, '&amp;')
2108
- .replace(/</g, '&lt;')
2109
- .replace(/>/g, '&gt;')
2110
- .replace(/"/g, '&quot;')
2111
- .replace(/'/g, '&#039;');
2112
- }
2113
- function substitute(html, content) {
2114
- return html.replace(/\{\{(\w+)\}\}/g, (_match, key) => {
2115
- const value = content[key] ?? '';
2116
- if (value === '' && FEATURE_KEY_RE.test(key))
2117
- return `<i ${EMPTY_SLOT_MARK}></i>`;
2118
- return escapeHtml(value);
2119
- });
2120
- }
2121
- function buildContent(view, strings) {
2122
- const offer = view.offer;
2123
- const price = offer ? formatPrice(offer.amountMinor, offer.currency, view.locale) : null;
2124
- const content = {
2125
- title: view.title,
2126
- description: view.description,
2127
- brandName: view.brandName,
2128
- currency: price?.currency ?? '',
2129
- price: price?.amount ?? '',
2130
- period: offer ? periodLabel(offer, strings) : '',
2131
- pricingDescription: offer?.description ?? '',
2132
- priceDescription: offer?.description ?? '',
2133
- premiumDescription: offer?.description ?? '',
2134
- upgradeButtonText: view.checkoutEnabled && offer ? strings.upgrade : strings.checkoutUnavailable,
2135
- cancelButtonText: strings.cancel,
2136
- dismissButtonText: strings.dismiss,
2137
- remindLaterText: strings.remindLater,
2138
- continueButtonText: strings.continueFree,
2139
- footerText: strings.footer,
2140
- };
2141
- view.features.forEach((feature, index) => {
2142
- const n = index + 1;
2143
- content[`feature${n}`] = feature;
2144
- content[`feature${n}Title`] = feature;
2145
- content[`premiumFeature${n}`] = feature;
2146
- });
2147
- view.freeFeatures.forEach((feature, index) => {
2148
- content[`freeFeature${index + 1}`] = feature;
2149
- });
2150
- return content;
2151
- }
2152
- const CSS_VALUE_UNSAFE = /[;{}<>]/g;
2153
- function themeCss(theme) {
2154
- const declarations = [];
2155
- const safe = (value) => value.replace(CSS_VALUE_UNSAFE, '');
2156
- if (theme.primaryColor) {
2157
- const color = safe(theme.primaryColor);
2158
- declarations.push(`--ep-primary-500:${color}`, `--ep-primary-600:${color}`, `--ep-primary-700:${color}`);
2159
- }
2160
- if (theme.fontFamily)
2161
- declarations.push(`--ep-font-family-sans:${safe(theme.fontFamily)}`);
2162
- if (theme.borderRadius) {
2163
- const radius = safe(theme.borderRadius);
2164
- declarations.push(`--ep-radius-md:${radius}`, `--ep-radius-lg:${radius}`, `--ep-radius-xl:${radius}`);
2165
- }
2166
- const host = declarations.length > 0 ? `:host{${declarations.join(';')}}` : '';
2167
- return host + (theme.customCss ?? '');
2168
- }
2169
- function resolveThemeMode(theme) {
2170
- const mode = theme.mode ?? 'auto';
2171
- if (mode !== 'auto')
2172
- return mode;
2173
- const matchMedia = globalThis.matchMedia;
2174
- return typeof matchMedia === 'function' &&
2175
- matchMedia.call(globalThis, '(prefers-color-scheme: dark)').matches
2176
- ? 'dark'
2177
- : 'light';
2178
- }
2179
- class PaywallRenderer {
2180
- constructor(callbacks) {
2181
- this.callbacks = callbacks;
2182
- this.host = null;
2183
- this.keyHandler = null;
2184
- }
2185
- isVisible() {
2186
- return this.host !== null;
2187
- }
2188
- /** Returns the host element; its shadow root holds the rendered template. */
2189
- show(view) {
2190
- this.hide();
2191
- const doc = globalThis.document;
2192
- if (!doc || typeof doc.createElement !== 'function' || !doc.body) {
2193
- throw new ExtenshiPayError(ERROR_CODES.PAYWALL_UNAVAILABLE, 'The paywall needs a DOM; call showPaywall() from a popup, options page or content script');
2194
- }
2195
- const template = PAYWALL_TEMPLATES[view.mode];
2196
- if (!template)
2197
- throw new ExtenshiPayError(ERROR_CODES.INVALID_REQUEST, `Unknown paywall mode "${view.mode}"`);
2198
- const strings = { ...DEFAULT_STRINGS, ...view.strings };
2199
- if (view.mock) {
2200
- strings.upgrade = 'Simulate purchase';
2201
- strings.footer = MOCK_PAYMENT_NOTICE;
2202
- }
2203
- const host = doc.createElement('div');
2204
- host.className = PAYWALL_HOST_CLASS;
2205
- host.setAttribute('data-theme', resolveThemeMode(view.theme));
2206
- const root = typeof host.attachShadow === 'function' ? host.attachShadow({ mode: 'open' }) : host;
2207
- root.innerHTML =
2208
- `<style>${PAYWALL_SHARED_CSS}${template.css}${themeCss(view.theme)}</style>` +
2209
- substitute(template.html, buildContent(view, strings));
2210
- this.prune(root);
2211
- this.bind(root, view, doc);
2212
- const sellerMount = root.querySelector('[class*="-footer"], .ep-minimal-actions, .ep-inline-content, .ep-fullscreen-content');
2213
- if (sellerMount) {
2214
- const details = sellerDetails(view.seller ?? null);
2215
- details.style.cssText =
2216
- 'font-size:12px;line-height:1.5;margin-top:12px;text-align:left;white-space:normal';
2217
- // In the modal, disclose the provider before the purchase action,
2218
- // instead of below it in the scrollable footer.
2219
- const modalActions = root.querySelector('.ep-modal-actions');
2220
- if (modalActions)
2221
- modalActions.before(details);
2222
- else
2223
- sellerMount.append(details);
2224
- }
2225
- if (view.mock) {
2226
- const upgrade = root.querySelector('[data-ep-action="upgradeNow"], [data-ep-action="startUpgrade"]');
2227
- if (upgrade) {
2228
- const notice = doc.createElement('p');
2229
- notice.className = 'extenshi-payment-preview';
2230
- notice.textContent = MOCK_PAYMENT_NOTICE;
2231
- notice.style.cssText = 'font-size:13px;line-height:1.5;margin:12px 0;white-space:normal';
2232
- upgrade.before(notice);
2233
- }
2234
- }
2235
- if (view.recoveryEnabled && this.callbacks.onRestore) {
2236
- const footer = root.querySelector('[class*="-footer"], .ep-minimal-actions, .ep-inline-content, .ep-fullscreen-content');
2237
- if (footer) {
2238
- const button = doc.createElement('button');
2239
- button.type = 'button';
2240
- button.textContent = strings.restorePurchase;
2241
- button.style.cssText =
2242
- 'display:block;margin:12px auto 0;background:none;border:0;color:inherit;font:inherit;text-decoration:underline;cursor:pointer';
2243
- button.addEventListener('click', () => this.callbacks.onRestore?.());
2244
- footer.appendChild(button);
2245
- }
2246
- }
2247
- const mount = view.mode === 'inline' ? (view.container ?? doc.body) : doc.body;
2248
- mount.appendChild(host);
2249
- this.host = host;
2250
- this.reveal(root, view.mode);
2251
- return host;
2252
- }
2253
- hide() {
2254
- if (!this.host)
2255
- return;
2256
- if (this.keyHandler) {
2257
- this.host.ownerDocument.removeEventListener('keydown', this.keyHandler);
2258
- this.keyHandler = null;
2259
- }
2260
- this.host.remove();
2261
- this.host = null;
2262
- }
2263
- prune(root) {
2264
- for (const element of root.querySelectorAll(PRUNE_SELECTOR))
2265
- element.remove();
2266
- for (const mark of root.querySelectorAll(`[${EMPTY_SLOT_MARK}]`)) {
2267
- const slot = mark.parentElement?.closest(FEATURE_SLOT_SELECTOR) ?? mark.parentElement;
2268
- (slot ?? mark).remove();
2269
- }
2270
- // A button whose label placeholder the contract does not fill (trial
2271
- // CTAs on sidebar/fullscreen) would render as an empty pill; icon-only
2272
- // buttons (close) keep their SVG and stay.
2273
- for (const button of root.querySelectorAll('button')) {
2274
- if (!button.textContent?.trim() && !button.querySelector('svg'))
2275
- button.remove();
2276
- }
2277
- }
2278
- bind(root, view, doc) {
2279
- for (const element of root.querySelectorAll('[data-ep-action]')) {
2280
- const action = element.getAttribute('data-ep-action') ?? '';
2281
- if (UPGRADE_ACTIONS.has(action)) {
2282
- if (view.offer && view.checkoutEnabled) {
2283
- const sku = view.offer.sku;
2284
- element.addEventListener('click', (event) => {
2285
- event.preventDefault();
2286
- this.callbacks.onUpgrade(sku);
2287
- });
2288
- }
2289
- else {
2290
- element.setAttribute('disabled', '');
2291
- element.setAttribute('aria-disabled', 'true');
2292
- }
2293
- }
2294
- else if (CLOSE_ACTIONS.has(action)) {
2295
- element.addEventListener('click', (event) => {
2296
- event.preventDefault();
2297
- this.close();
2298
- });
2299
- }
2300
- else {
2301
- element.remove();
2302
- }
2303
- }
2304
- const backdropSelector = BACKDROP_SELECTOR[view.mode];
2305
- if (backdropSelector) {
2306
- root.querySelector(backdropSelector)?.addEventListener('click', (event) => {
2307
- if (event.target === event.currentTarget)
2308
- this.close();
2309
- });
2310
- }
2311
- if (view.mode !== 'inline') {
2312
- this.keyHandler = (event) => {
2313
- if (event.key === 'Escape')
2314
- this.close();
2315
- };
2316
- doc.addEventListener('keydown', this.keyHandler);
2317
- }
2318
- }
2319
- reveal(root, mode) {
2320
- const rootElement = root.querySelector(ROOT_SELECTOR[mode]);
2321
- if (rootElement && (mode === 'modal' || mode === 'fullscreen'))
2322
- rootElement.style.display = 'flex';
2323
- for (const [selector, className] of VISIBLE_CLASSES[mode] ?? []) {
2324
- root.querySelector(selector)?.classList.add(className);
2325
- }
2326
- for (const item of root.querySelectorAll(FEATURE_ITEM_VISIBLE[0]))
2327
- item.classList.add(FEATURE_ITEM_VISIBLE[1]);
2328
- }
2329
- close() {
2330
- this.hide();
2331
- this.callbacks.onClose();
2332
- }
2333
- }
2334
-
2335
- /** Full SDK: everything in `ExtenshiPayLite` plus the offer and the paywall UI. */
2336
- function pickOffer(offer, sku) {
2337
- if (!offer)
2338
- return null;
2339
- return offer.offers.find((candidate) => candidate.sku === sku) ?? offer.offers[0] ?? null;
2340
- }
2341
- class ExtenshiPay extends ExtenshiPayLite {
2342
- constructor() {
2343
- super(...arguments);
2344
- this.disposed = false;
2345
- this.licensePanel = new LicensePanel();
2346
- this.billingProfiles = new BillingProfilePicker();
2347
- this.paywall = null;
2348
- this.paywallSession = null;
2349
- }
2350
- async openCustomerPortal(options = {}) {
2351
- return super.openCustomerPortal({
2352
- ...options,
2353
- selectAccount: options.selectAccount ?? ((accounts) => this.billingProfiles.show(accounts)),
2354
- });
2355
- }
2356
- destroy() {
2357
- this.disposed = true;
2358
- this.licensePanel.hide();
2359
- this.billingProfiles.hide();
2360
- this.hidePaywall();
2361
- super.destroy();
2362
- }
2363
- async showLicense() {
2364
- // An explicit status check should see refunds/cancellations immediately.
2365
- // The entitlement manager still falls back to the verified cache offline.
2366
- const summary = await this.getLicenseSummary({ force: !this.config.mock });
2367
- if (this.disposed)
2368
- return;
2369
- return this.licensePanel.show(summary, {
2370
- restore: async () => {
2371
- await this.restorePurchase();
2372
- return this.getLicenseSummary({ force: true });
2373
- },
2374
- manage: () => this.openCustomerPortal(),
2375
- });
2376
- }
2377
- async getOffer(options = {}) {
2378
- await this.initialize();
2379
- try {
2380
- return await this.fetchOffer(options.force);
2381
- }
2382
- catch (error) {
2383
- throw this.reportError(error);
2384
- }
2385
- }
2386
- /**
2387
- * Renders the paywall and resolves `true` when a checkout started from it
2388
- * completes, `false` when the user closes it. The offer is fetched via
2389
- * `getOffer()`; if that fails the paywall still renders with checkout disabled.
2390
- */
2391
- async showPaywall(options = {}) {
2392
- await this.initialize();
2393
- let offer = null;
2394
- try {
2395
- offer = await this.fetchOffer();
2396
- }
2397
- catch (error) {
2398
- this.reportError(error);
2399
- }
2400
- const selected = pickOffer(offer, options.sku);
2401
- const view = {
2402
- mode: options.mode ?? 'modal',
2403
- title: options.title ?? selected?.title ?? DEFAULT_STRINGS.title,
2404
- description: options.description ?? selected?.description ?? DEFAULT_STRINGS.description,
2405
- features: options.features ?? selected?.features ?? [],
2406
- freeFeatures: options.freeFeatures ?? [],
2407
- brandName: offer?.projectName ?? '',
2408
- offer: selected,
2409
- checkoutEnabled: offer?.checkoutEnabled === true && selected !== null && offer.seller !== null,
2410
- mock: this.config.mock,
2411
- recoveryEnabled: offer?.recoveryEnabled === true,
2412
- seller: offer?.seller ?? null,
2413
- locale: this.config.locale,
2414
- theme: { ...this.config.theme, ...options.theme },
2415
- strings: options.strings ?? {},
2416
- container: options.container,
2417
- };
2418
- this.hidePaywall();
2419
- return new Promise((resolve) => {
2420
- this.paywallSession = { options, resolve };
2421
- try {
2422
- this.renderer().show(view);
2423
- }
2424
- catch (error) {
2425
- this.paywallSession = null;
2426
- this.reportError(error);
2427
- resolve(false);
2428
- }
2429
- });
2430
- }
2431
- hidePaywall() {
2432
- this.paywall?.hide();
2433
- this.settlePaywall(false);
2434
- }
2435
- isPaywallVisible() {
2436
- return this.paywall?.isVisible() === true;
2437
- }
2438
- async onFeatureLocked(_feature, options) {
2439
- if (options.showPaywall === false)
2440
- return false;
2441
- if ((await this.getEntitlement()).requiresOnlineCheck) {
2442
- await this.showLicense();
2443
- return false;
2444
- }
2445
- return this.showPaywall(options.paywall ?? {});
2446
- }
2447
- renderer() {
2448
- if (!this.paywall) {
2449
- this.paywall = new PaywallRenderer({
2450
- onUpgrade: (sku) => void this.handleUpgrade(sku),
2451
- onClose: () => this.settlePaywall(false),
2452
- onRestore: () => void this.handleRestore(),
2453
- });
2454
- }
2455
- return this.paywall;
2456
- }
2457
- async handleRestore() {
2458
- try {
2459
- const result = await this.restorePurchase();
2460
- if (result.state === 'complete' && isEntitled(result.entitlement)) {
2461
- this.paywall?.hide();
2462
- this.settlePaywall(true);
2463
- }
2464
- }
2465
- catch {
2466
- /* Reported through the error event; leave the paywall open for retry. */
2467
- }
2468
- }
2469
- async handleUpgrade(sku) {
2470
- this.paywallSession?.options.onUpgrade?.(sku);
2471
- try {
2472
- const result = await this.openCheckout(sku);
2473
- if (result.state === 'complete') {
2474
- this.paywall?.hide();
2475
- this.settlePaywall(true);
2476
- }
2477
- }
2478
- catch {
2479
- // Reported through the `error` event by openCheckout(); the paywall stays open for a retry.
2480
- }
2481
- }
2482
- settlePaywall(unlocked) {
2483
- const session = this.paywallSession;
2484
- if (!session)
2485
- return;
2486
- this.paywallSession = null;
2487
- if (!unlocked)
2488
- session.options.onClose?.();
2489
- session.resolve(unlocked);
2490
- }
2491
- }
2492
-
2493
- // Full SDK entry point: core + paywall UI.
2494
-
2495
- export { CHECKOUT_POLL_INTERVAL_MS, CHECKOUT_TIMEOUT_MS, CheckoutManager, DEFAULT_API_URL, DEFAULT_CACHE_TTL_MS, DEFAULT_STRINGS, EMPTY_ENTITLEMENT, END_USER_REF_STORAGE_KEY, ERROR_CODES, EntitlementManager, EventEmitter, ExtenshiPay, ExtenshiPayError, ExtenshiPayLite, ExtensionStorage, HttpTransport, LOCALE_RE, LocalStorageAdapter, Logger, MAX_CACHE_TTL_MS, MAX_REFRESH_BACKOFF_MS, MIN_REFRESH_INTERVAL_MS, MemoryStorage, MockTransport, PAYWALL_HOST_CLASS, PAYWALL_MODES, PAYWALL_SHARED_CSS, PAYWALL_TEMPLATES, PAY_CONTRACT_VERSION, PAY_CURRENCIES, PAY_END_USER_REF_RE, PAY_ENTITLEMENT_STATUSES, PAY_ERRORS, PAY_GATEWAYS, PAY_OFFER_INTERVALS, PAY_OFFER_KINDS, PAY_PUBLISHABLE_KEY_HEX_LENGTH, PAY_PUBLISHABLE_KEY_PREFIX, PAY_SKU_RE, PayApi, PaywallRenderer, RecoveryManager, TRPC_PATH, VERSION, applyLocalExpiry, base64ToBytes, buildContent, canonicalJson, checkFeatures, collectFeatures, createRecoveryStorage, createStorage, ExtenshiPay as default, escapeHtml, formatPrice, getOrCreateEndUserRef, hasFeature, isEntitled, isLive, isPayPublishableKey, logger, mintEndUserRef, openInNewTab, periodLabel, resolveConfig, resolveThemeMode, substitute, themeCss, trpcErrorToPayError, verifyEntitlementSignature };
2496
- //# sourceMappingURL=extenshi-pay.esm.js.map