@lockerverse/react 0.2.221 → 0.2.223-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MIGRATIONS.md +98 -5
- package/dist/booking-payment.d.ts +18 -0
- package/dist/booking-payment.d.ts.map +1 -0
- package/dist/booking-payment.js +2 -0
- package/dist/booking-payment.js.map +1 -0
- package/dist/bookings.d.ts +28 -0
- package/dist/bookings.d.ts.map +1 -0
- package/dist/bookings.js +2 -0
- package/dist/bookings.js.map +1 -0
- package/dist/lockerverse-donate-launcher.d.ts.map +1 -1
- package/dist/lockerverse-donate-launcher.js +1 -1
- package/dist/lockerverse-donate-launcher.js.map +1 -1
- package/dist/lockerverse-payment.js +1 -1
- package/dist/lockerverse-payment.js.map +1 -1
- package/guides/auctions.md +1 -1
- package/guides/bookings.md +84 -0
- package/guides/events.md +1 -1
- package/guides/integration.md +1 -1
- package/guides/payment-widgets.md +1 -1
- package/guides/signup.md +1 -1
- package/package.json +23 -3
package/MIGRATIONS.md
CHANGED
|
@@ -4,6 +4,18 @@ This file ships in both @lockerverse/sdk and @lockerverse/react. Use the copy in
|
|
|
4
4
|
the target installed release. This is an agent-run procedure, not an install
|
|
5
5
|
script. Installing a package does not edit host code or guarantee these steps ran.
|
|
6
6
|
|
|
7
|
+
## 0.2.223-dev.1 — optional bookings
|
|
8
|
+
|
|
9
|
+
- No change is required for existing checkout, signup, auction or event consumers.
|
|
10
|
+
- Booking hosts must import the separate `@lockerverse/sdk/bookings` and
|
|
11
|
+
`@lockerverse/react/bookings` entries and read `guides/bookings.md`.
|
|
12
|
+
- Load `@lockerverse/react/booking-payment` only when a recovered attempt can pay.
|
|
13
|
+
Follow the optional Stripe peers in the target package manifest.
|
|
14
|
+
- Move business credentials and payment/booking work to the Lockerverse backend.
|
|
15
|
+
Keep host access storage private and update the hook sessionKey on access changes.
|
|
16
|
+
- Do not release an unknown payment outcome by clearing local state. Recover the
|
|
17
|
+
saved server attempt before permitting another payment.
|
|
18
|
+
|
|
7
19
|
## Upgrade procedure
|
|
8
20
|
|
|
9
21
|
1. Before installation, record the resolved installed version of each package
|
|
@@ -36,6 +48,15 @@ If it cannot be found, report that limit and use the baseline review below. Do n
|
|
|
36
48
|
claim that every historical migration was applied. Read this file even if the
|
|
37
49
|
version already matches: a previous upgrade may have missed host adoption steps.
|
|
38
50
|
|
|
51
|
+
## 0.2.222 — shorter donation heading
|
|
52
|
+
|
|
53
|
+
- **Affected:** React donate launcher optional donation sections.
|
|
54
|
+
- **Automatic:** removes the helper sentence beneath Add a donation. The heading
|
|
55
|
+
and amount controls remain, with no change to selection or checkout behavior.
|
|
56
|
+
- **Required:** upgrade matching SDK/React packages and deploy the host. No prop
|
|
57
|
+
changes are needed.
|
|
58
|
+
- **Check:** the donation section shows its heading followed by amount choices.
|
|
59
|
+
|
|
39
60
|
## 0.2.221 — stock status beside product prices
|
|
40
61
|
|
|
41
62
|
- **Affected:** React donate launcher product availability labels.
|
|
@@ -305,7 +326,7 @@ No host prop change is required.
|
|
|
305
326
|
- **Check:** inspect a wide and a tall photo on desktop and mobile. Confirm all
|
|
306
327
|
edges remain visible in the item gallery, thumbnails, and full-screen viewer.
|
|
307
328
|
|
|
308
|
-
## 0.2.
|
|
329
|
+
## 0.2.192-dev.1 — auction item additional charges
|
|
309
330
|
|
|
310
331
|
- **Affected:** Core auction item data, purchase quotes, and React auction checkout.
|
|
311
332
|
- **Automatic:** optional `additionalCharge` charges the first-item amount plus the
|
|
@@ -323,7 +344,7 @@ No host prop change is required.
|
|
|
323
344
|
- **Check:** compare one, two, and maximum quantity totals with the server quote,
|
|
324
345
|
verify the per-order limit, and inspect the named charge row before payment.
|
|
325
346
|
|
|
326
|
-
## 0.2.
|
|
347
|
+
## 0.2.190-dev.1 — widget load recovery and Sentry releases
|
|
327
348
|
|
|
328
349
|
- **Affected:** Core widget loading and SDK failure reporting.
|
|
329
350
|
- **Automatic:** a widget GET retries once after a network failure or request
|
|
@@ -350,6 +371,7 @@ No host prop change is required.
|
|
|
350
371
|
- **Check:** select one, two, and the maximum allowed trigger quantity. Confirm the
|
|
351
372
|
local summary and server quote agree; removing all trigger items removes shipping.
|
|
352
373
|
|
|
374
|
+
|
|
353
375
|
## 0.2.184 — single focus boundary for form fields
|
|
354
376
|
|
|
355
377
|
- **Affected:** React form controls and the shared phone field in payment and signup.
|
|
@@ -369,7 +391,7 @@ Widgets can now use a private contact list for email eligibility, a fixed amount
|
|
|
369
391
|
Required shipping appears in `catalog.widget.requiredShipping`. Do not offer this product as a separate shopper choice. The SDK adds its quantity once when a trigger product is selected; the server also enforces this rule. Render authoritative quote line items and totals, including shipping. The built-in launcher and payment summary handle this automatically.
|
|
370
392
|
|
|
371
393
|
|
|
372
|
-
## 0.2.
|
|
394
|
+
## 0.2.176-dev.1 — Secure checkout loading recovery
|
|
373
395
|
|
|
374
396
|
- **Affected:** React payment widget Stripe fields.
|
|
375
397
|
- **Automatic:** failed field or script loads show a reload action. Fields that
|
|
@@ -381,9 +403,23 @@ Required shipping appears in `catalog.widget.requiredShipping`. Do not offer thi
|
|
|
381
403
|
- Reload is an explicit customer action and can clear unsaved form entries.
|
|
382
404
|
Saved payment recovery remains in session storage.
|
|
383
405
|
|
|
384
|
-
|
|
385
406
|
## 0.2.175 — Match Stripe Elements payment method configuration
|
|
386
407
|
|
|
408
|
+
- **Affected:** Core checkout submission and React payment widgets.
|
|
409
|
+
- **Automatic:** React configures explicit card, Link, and community-enabled bank
|
|
410
|
+
methods in Stripe Elements and marks the confirmation request with
|
|
411
|
+
`paymentMethodConfiguration: "explicit"`. This matches the backend's Stripe
|
|
412
|
+
PaymentIntent configuration.
|
|
413
|
+
- **Required:** deploy the backend that supports this optional marker before
|
|
414
|
+
upgrading React. Keep Core and React matched. Existing Core-only callers omit
|
|
415
|
+
the marker and retain automatic payment methods. Custom Elements integrations
|
|
416
|
+
must send the marker only when they use the explicit method list.
|
|
417
|
+
- **Check:** submit card and bank payments through Stripe Elements in test mode,
|
|
418
|
+
including recurring checkout. Confirm pending recovery and settlement.
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
## 0.2.174-dev.1 — Match Stripe Elements payment method configuration
|
|
422
|
+
|
|
387
423
|
- **Affected:** Core checkout submission and React payment widgets.
|
|
388
424
|
- **Automatic:** React configures explicit card, Link, and community-enabled bank
|
|
389
425
|
methods in Stripe Elements and marks the confirmation request with
|
|
@@ -457,7 +493,39 @@ Required shipping appears in `catalog.widget.requiredShipping`. Do not offer thi
|
|
|
457
493
|
verify a changed selection cannot discard it. Check both paid and free order
|
|
458
494
|
confirmation panels. Do not submit a live transaction for this check.
|
|
459
495
|
|
|
460
|
-
## 0.2.
|
|
496
|
+
## 0.2.172-dev.1 — Check pending payment status
|
|
497
|
+
|
|
498
|
+
- **Affected:** React payment widgets with unresolved payments.
|
|
499
|
+
- **Automatic behavior:** the existing pending-payment screen now offers Check
|
|
500
|
+
payment status. It checks the saved payment reference and cannot submit a new
|
|
501
|
+
payment. The control is disabled while the check runs.
|
|
502
|
+
- **Required host changes:** none. Update Core and React together.
|
|
503
|
+
- **Verification:** complete a test bank payment, return to its pending checkout,
|
|
504
|
+
and check its status. Confirm completion clears recovery storage.
|
|
505
|
+
|
|
506
|
+
## 0.2.171-dev.1 — SDK payment recovery and completion UI
|
|
507
|
+
|
|
508
|
+
- **Affected:** React payment widgets and custom hosts that persist payment recovery.
|
|
509
|
+
- **Optional adoption:** pass `recoveryStorageKey` to `LockerversePayment` to let
|
|
510
|
+
the SDK save and restore the pending payment in session storage. Use a stable
|
|
511
|
+
key scoped to the API environment, community, and widget. Remove the host's
|
|
512
|
+
storage code and recovery-driven component key. Do not combine automatic
|
|
513
|
+
persistence with a second host persistence writer.
|
|
514
|
+
- **Compatibility:** the SDK reads the hosted Next app's existing version 1
|
|
515
|
+
records when the same key is used. It writes version 2 records with widget
|
|
516
|
+
identity. It checks widget and selection identity before recovery and keeps
|
|
517
|
+
an unresolved record if those details differ. Recovery uses the saved connected
|
|
518
|
+
account even if current payment routing has changed. Storage is read after hydration,
|
|
519
|
+
before the payable form mounts. No contact details or payment tokens are saved.
|
|
520
|
+
- **Optional UI adoption:** use `completionView="summary"` for the SDK confirmation
|
|
521
|
+
panel and remove the host's duplicate success panel. Completion callbacks still
|
|
522
|
+
run. The default inline message and explicit `resumePayment` integrations remain
|
|
523
|
+
supported. Auctions and legacy custom checkout forms are unchanged.
|
|
524
|
+
- **Check:** reload a pending checkout and confirm the existing payment is checked;
|
|
525
|
+
verify a changed selection cannot discard it. Check both paid and free order
|
|
526
|
+
confirmation panels. Do not submit a live transaction for this check.
|
|
527
|
+
|
|
528
|
+
## 0.2.169-dev.1 — six-month payment widgets
|
|
461
529
|
|
|
462
530
|
Affected: @lockerverse/sdk checkout and @lockerverse/react payment widgets.
|
|
463
531
|
|
|
@@ -473,6 +541,31 @@ Affected: @lockerverse/sdk checkout and @lockerverse/react payment widgets.
|
|
|
473
541
|
submission. Do not submit a live payment for an integration check.
|
|
474
542
|
|
|
475
543
|
|
|
544
|
+
## 0.2.168-dev.1 — bank authorization terms
|
|
545
|
+
|
|
546
|
+
- **Affected:** React payment widgets with ACH enabled.
|
|
547
|
+
- **Automatic:** Stripe displays its bank authorization terms before payment confirmation.
|
|
548
|
+
- **Adoption:** update the matching SDK/React development pair. No prop changes are required.
|
|
549
|
+
- **Check:** confirm that the bank authorization text is visible when a bank account is selected.
|
|
550
|
+
|
|
551
|
+
## 0.2.167-dev.1 — widget ACH and subscription payment recovery
|
|
552
|
+
|
|
553
|
+
- **Affected:** Core checkout data and React payment widgets.
|
|
554
|
+
- **Automatic:** bank payment availability follows the organization default and
|
|
555
|
+
community override returned by the backend. Missing policy remains disabled.
|
|
556
|
+
Pending payments keep their existing payment reference. A failed subscription
|
|
557
|
+
invoice can return `action_required` with `requiresAction: false` and `retryUrl`;
|
|
558
|
+
React shows a link to pay the same invoice instead of creating a second subscription.
|
|
559
|
+
- **Required for custom payment UI:** preserve the reference for pending and
|
|
560
|
+
action-required results. Handle `retryUrl` by opening that invoice, and recover
|
|
561
|
+
status before permitting a new checkout. Do not treat submission as settlement.
|
|
562
|
+
- **Adoption:** deploy the matching backend policy and recovery contract before
|
|
563
|
+
enabling ACH. Existing React hosts need no component prop changes. Keep Core and
|
|
564
|
+
React versions matched when upgrading. Auction payment methods are unchanged.
|
|
565
|
+
- **Check:** verify disabled/inherited/enabled bank visibility and pending, bank
|
|
566
|
+
verification, invoice retry, success, and terminal failure in Stripe test mode.
|
|
567
|
+
Do not create a live transaction for this check.
|
|
568
|
+
|
|
476
569
|
## 0.2.166 — single dropdown arrow
|
|
477
570
|
|
|
478
571
|
- **Affected:** native single-select custom fields in React signup and payment forms.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { LockerverseBookingAttempt } from "@lockerverse/sdk/bookings";
|
|
3
|
+
//#region src/booking-payment.d.ts
|
|
4
|
+
type LockerverseBookingPaymentProps = {
|
|
5
|
+
publishableKey: string;
|
|
6
|
+
amountCents: number;
|
|
7
|
+
currency: "USD";
|
|
8
|
+
onConfirm: (confirmationToken: string) => Promise<LockerverseBookingAttempt> | Promise<void>;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
className?: string;
|
|
11
|
+
buttonClassName?: string;
|
|
12
|
+
buttonLabel?: ReactNode;
|
|
13
|
+
};
|
|
14
|
+
/** Import this entry only when the recovered attempt is ready for card entry. */
|
|
15
|
+
declare function LockerverseBookingPayment(props: LockerverseBookingPaymentProps): import("react").JSX.Element;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { LockerverseBookingPayment, type LockerverseBookingPaymentProps };
|
|
18
|
+
//# sourceMappingURL=booking-payment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"booking-payment.d.ts","names":[],"sources":["../src/booking-payment.tsx"],"mappings":";;;KAaY;EACV;EACA;EACA;EACA,YACE,8BACG,QAAQ,6BAA6B;EAC1C;EACA;EACA;EACA,cAAc;;;iBAwEA,0BACd,OAAO,iDAA8B,IAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{useEffect as e,useRef as t,useState as n}from"react";import{jsx as r,jsxs as i}from"react/jsx-runtime";import{Elements as a,PaymentElement as o,useElements as s,useStripe as c}from"@stripe/react-stripe-js";import{loadStripe as l}from"@stripe/stripe-js/pure/index.js";const u=/^pk_(?:test|live)_/;function d(e){let a=c(),l=s(),u=t(!1),d=t(!1),[f,p]=n(!1),[m,h]=n(!1),[g,_]=n(``);async function v(){if(!(!(a&&l&&m)||e.disabled||u.current||d.current)){u.current=!0,p(!0),_(``);try{if((await l.submit()).error){_(`Check your card details.`);return}let t=await a.createConfirmationToken({elements:l});if(t.error||!t.confirmationToken){_(`Card details could not be confirmed. No payment was submitted.`);return}d.current=!0,await e.onConfirm(t.confirmationToken.id)}catch{_(`Check the saved booking state before trying payment again.`)}finally{u.current=!1,p(!1)}}}return i(`div`,{className:e.className,children:[r(o,{onLoadError:()=>{h(!1),_(`Card entry could not load. Reload the page and recover this booking; do not start another payment.`)},onReady:()=>h(!0),options:{wallets:{applePay:`never`,googlePay:`never`}}}),!(m||g)&&r(`p`,{role:`status`,children:`Loading secure card entry…`}),g&&r(`p`,{role:`alert`,children:g}),r(`button`,{className:e.buttonClassName,disabled:!m||f||d.current||e.disabled,onClick:v,type:`button`,children:f?`Checking payment…`:e.buttonLabel??`Pay and book`})]})}function f(t){let[i,o]=n(null),[s,c]=n(!1),f=`${t.publishableKey}:${t.amountCents}:${t.currency}`,[p]=n(f);if(f!==p)throw Error(`Remount booking payment when its confirmed payment configuration changes.`);if(!(u.test(t.publishableKey)&&Number.isSafeInteger(t.amountCents))||t.amountCents<=0||t.currency!==`USD`)throw TypeError(`A valid server-provided booking payment configuration is required.`);return e(()=>{let e=!0;return l(t.publishableKey).then(t=>{e&&(o(t),c(!t))}).catch(()=>{e&&c(!0)}),()=>{e=!1}},[t.publishableKey]),s?r(`p`,{role:`alert`,children:`Secure card entry could not load. Recover this booking after reloading the page.`}):i?r(a,{options:{allowedPaymentMethodTypes:[`card`],amount:t.amountCents,currency:`usd`,mode:`payment`,setupFutureUsage:`off_session`},stripe:i,children:r(d,{...t})}):r(`p`,{role:`status`,children:`Loading secure card entry…`})}export{f as LockerverseBookingPayment};
|
|
2
|
+
//# sourceMappingURL=booking-payment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"booking-payment.js","names":[],"sources":["../src/booking-payment.tsx"],"sourcesContent":["import type { LockerverseBookingAttempt } from \"@lockerverse/sdk/bookings\";\nimport {\n Elements,\n PaymentElement,\n useElements,\n useStripe,\n} from \"@stripe/react-stripe-js\";\nimport type { Stripe } from \"@stripe/stripe-js\";\nimport { loadStripe } from \"@stripe/stripe-js/pure\";\nimport { type ReactNode, useEffect, useRef, useState } from \"react\";\n\nconst publishableKeyPattern = /^pk_(?:test|live)_/;\n\nexport type LockerverseBookingPaymentProps = {\n publishableKey: string;\n amountCents: number;\n currency: \"USD\";\n onConfirm: (\n confirmationToken: string\n ) => Promise<LockerverseBookingAttempt> | Promise<void>;\n disabled?: boolean;\n className?: string;\n buttonClassName?: string;\n buttonLabel?: ReactNode;\n};\n\nfunction BookingCardForm(props: LockerverseBookingPaymentProps) {\n const stripe = useStripe();\n const elements = useElements();\n const submitting = useRef(false);\n const sentToBackend = useRef(false);\n const [busy, setBusy] = useState(false);\n const [ready, setReady] = useState(false);\n const [error, setError] = useState(\"\");\n async function submit() {\n if (\n !(stripe && elements && ready) ||\n props.disabled ||\n submitting.current ||\n sentToBackend.current\n ) {\n return;\n }\n submitting.current = true;\n setBusy(true);\n setError(\"\");\n try {\n const submitted = await elements.submit();\n if (submitted.error) {\n setError(\"Check your card details.\");\n return;\n }\n const result = await stripe.createConfirmationToken({ elements });\n if (result.error || !result.confirmationToken) {\n setError(\n \"Card details could not be confirmed. No payment was submitted.\"\n );\n return;\n }\n sentToBackend.current = true;\n await props.onConfirm(result.confirmationToken.id);\n } catch {\n setError(\"Check the saved booking state before trying payment again.\");\n } finally {\n submitting.current = false;\n setBusy(false);\n }\n }\n return (\n <div className={props.className}>\n <PaymentElement\n onLoadError={() => {\n setReady(false);\n setError(\n \"Card entry could not load. Reload the page and recover this booking; do not start another payment.\"\n );\n }}\n onReady={() => setReady(true)}\n options={{ wallets: { applePay: \"never\", googlePay: \"never\" } }}\n />\n {!(ready || error) && <p role=\"status\">Loading secure card entry…</p>}\n {error && <p role=\"alert\">{error}</p>}\n <button\n className={props.buttonClassName}\n disabled={!ready || busy || sentToBackend.current || props.disabled}\n onClick={submit}\n type=\"button\"\n >\n {busy ? \"Checking payment…\" : (props.buttonLabel ?? \"Pay and book\")}\n </button>\n </div>\n );\n}\n\n/** Import this entry only when the recovered attempt is ready for card entry. */\nexport function LockerverseBookingPayment(\n props: LockerverseBookingPaymentProps\n) {\n const [stripe, setStripe] = useState<Stripe | null>(null);\n const [failed, setFailed] = useState(false);\n const identity = `${props.publishableKey}:${props.amountCents}:${props.currency}`;\n const [initialIdentity] = useState(identity);\n if (identity !== initialIdentity) {\n throw new Error(\n \"Remount booking payment when its confirmed payment configuration changes.\"\n );\n }\n if (\n !(\n publishableKeyPattern.test(props.publishableKey) &&\n Number.isSafeInteger(props.amountCents)\n ) ||\n props.amountCents <= 0 ||\n props.currency !== \"USD\"\n ) {\n throw new TypeError(\n \"A valid server-provided booking payment configuration is required.\"\n );\n }\n useEffect(() => {\n let active = true;\n loadStripe(props.publishableKey)\n .then((result) => {\n if (active) {\n setStripe(result);\n setFailed(!result);\n }\n })\n .catch(() => {\n if (active) {\n setFailed(true);\n }\n });\n return () => {\n active = false;\n };\n }, [props.publishableKey]);\n if (failed) {\n return (\n <p role=\"alert\">\n Secure card entry could not load. Recover this booking after reloading\n the page.\n </p>\n );\n }\n if (!stripe) {\n return <p role=\"status\">Loading secure card entry…</p>;\n }\n return (\n <Elements\n options={{\n allowedPaymentMethodTypes: [\"card\"],\n amount: props.amountCents,\n currency: \"usd\",\n mode: \"payment\",\n setupFutureUsage: \"off_session\",\n }}\n stripe={stripe}\n >\n <BookingCardForm {...props} />\n </Elements>\n );\n}\n"],"mappings":"kRAWA,MAAM,EAAwB,qBAe9B,SAAS,EAAgB,EAAuC,CAC9D,IAAM,EAAS,EAAU,EACnB,EAAW,EAAY,EACvB,EAAa,EAAO,EAAK,EACzB,EAAgB,EAAO,EAAK,EAC5B,CAAC,EAAM,GAAW,EAAS,EAAK,EAChC,CAAC,EAAO,GAAY,EAAS,EAAK,EAClC,CAAC,EAAO,GAAY,EAAS,EAAE,EACrC,eAAe,GAAS,CAEpB,OAAE,GAAU,GAAY,IACxB,EAAM,UACN,EAAW,SACX,EAAc,SAMhB,CAFA,EAAW,QAAU,GACrB,EAAQ,EAAI,EACZ,EAAS,EAAE,EACX,GAAI,CAEF,IAAI,MADoB,EAAS,OAAO,EAAA,CAC1B,MAAO,CACnB,EAAS,0BAA0B,EACnC,MACF,CACA,IAAM,EAAS,MAAM,EAAO,wBAAwB,CAAE,UAAS,CAAC,EAChE,GAAI,EAAO,OAAS,CAAC,EAAO,kBAAmB,CAC7C,EACE,gEACF,EACA,MACF,CACA,EAAc,QAAU,GACxB,MAAM,EAAM,UAAU,EAAO,kBAAkB,EAAE,CACnD,MAAQ,CACN,EAAS,4DAA4D,CACvE,QAAU,CACR,EAAW,QAAU,GACrB,EAAQ,EAAK,CACf,CArBW,CAsBb,CACA,OACE,EAAC,MAAD,CAAK,UAAW,EAAM,UAAtB,SAAA,CACE,EAAC,EAAD,CACE,gBAAmB,CACjB,EAAS,EAAK,EACd,EACE,oGACF,CACF,EACA,YAAe,EAAS,EAAI,EAC5B,QAAS,CAAE,QAAS,CAAE,SAAU,QAAS,UAAW,OAAQ,CAAE,CAC/D,CAAA,EACA,EAAE,GAAS,IAAU,EAAC,IAAD,CAAG,KAAK,SAAS,SAAA,4BAA6B,CAAA,EACnE,GAAS,EAAC,IAAD,CAAG,KAAK,QAAS,SAAA,CAAS,CAAA,EACpC,EAAC,SAAD,CACE,UAAW,EAAM,gBACjB,SAAU,CAAC,GAAS,GAAQ,EAAc,SAAW,EAAM,SAC3D,QAAS,EACT,KAAK,SAEJ,SAAA,EAAO,oBAAuB,EAAM,aAAe,cAC9C,CAAA,CACL,GAET,CAGA,SAAgB,EACd,EACA,CACA,GAAM,CAAC,EAAQ,GAAa,EAAwB,IAAI,EAClD,CAAC,EAAQ,GAAa,EAAS,EAAK,EACpC,EAAW,GAAG,EAAM,eAAe,GAAG,EAAM,YAAY,GAAG,EAAM,WACjE,CAAC,GAAmB,EAAS,CAAQ,EAC3C,GAAI,IAAa,EACf,MAAU,MACR,2EACF,EAEF,GACE,EACE,EAAsB,KAAK,EAAM,cAAc,GAC/C,OAAO,cAAc,EAAM,WAAW,IAExC,EAAM,aAAe,GACrB,EAAM,WAAa,MAEnB,MAAU,UACR,oEACF,EA+BF,OA7BA,MAAgB,CACd,IAAI,EAAS,GAab,OAZA,EAAW,EAAM,cAAc,CAAC,CAC7B,KAAM,GAAW,CACZ,IACF,EAAU,CAAM,EAChB,EAAU,CAAC,CAAM,EAErB,CAAC,CAAC,CACD,UAAY,CACP,GACF,EAAU,EAAI,CAElB,CAAC,MACU,CACX,EAAS,EACX,CACF,EAAG,CAAC,EAAM,cAAc,CAAC,EACrB,EAEA,EAAC,IAAD,CAAG,KAAK,QAAQ,SAAA,kFAGb,CAAA,EAGF,EAIH,EAAC,EAAD,CACE,QAAS,CACP,0BAA2B,CAAC,MAAM,EAClC,OAAQ,EAAM,YACd,SAAU,MACV,KAAM,UACN,iBAAkB,aACpB,EACQ,SAER,SAAA,EAAC,EAAD,CAAiB,GAAI,CAAQ,CAAA,CACrB,CAAA,EAdH,EAAC,IAAD,CAAG,KAAK,SAAS,SAAA,4BAA6B,CAAA,CAgBzD"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { LockerverseBookingAttempt, LockerverseBookingAttempt as LockerverseBookingAttempt$1, LockerverseBookingAvailability, LockerverseBookingBusiness, LockerverseBookingConfiguration, LockerverseBookingConfiguration as LockerverseBookingConfiguration$1, LockerverseBookingSelection, LockerverseBookingStatus, LockerverseBookingsClient, LockerverseSdkError } from "@lockerverse/sdk/bookings";
|
|
2
|
+
//#region src/use-lockerverse-bookings.d.ts
|
|
3
|
+
type UseLockerverseBookingsOptions = {
|
|
4
|
+
enabled?: boolean;
|
|
5
|
+
/** Non-secret generation value. Change it when the access session changes. */
|
|
6
|
+
sessionKey?: string | number;
|
|
7
|
+
};
|
|
8
|
+
type UseLockerverseBookingsResult = {
|
|
9
|
+
configuration: LockerverseBookingConfiguration$1 | null;
|
|
10
|
+
slots: string[];
|
|
11
|
+
availabilityMessage: string;
|
|
12
|
+
attempt: LockerverseBookingAttempt$1 | null;
|
|
13
|
+
busy: boolean;
|
|
14
|
+
recovering: boolean;
|
|
15
|
+
recovered: boolean;
|
|
16
|
+
error: LockerverseSdkError | null;
|
|
17
|
+
canPay: boolean;
|
|
18
|
+
refresh: () => Promise<void>;
|
|
19
|
+
findTimes: (date: string) => Promise<LockerverseBookingAvailability>;
|
|
20
|
+
initialize: (selection: LockerverseBookingSelection) => Promise<LockerverseBookingAttempt$1>;
|
|
21
|
+
confirm: (confirmationToken: string) => Promise<LockerverseBookingAttempt$1>;
|
|
22
|
+
recover: () => Promise<LockerverseBookingAttempt$1 | null>;
|
|
23
|
+
};
|
|
24
|
+
/** Recover the business-scoped attempt before permitting a payment submission. */
|
|
25
|
+
declare function useLockerverseBookings(client: LockerverseBookingsClient, { enabled, sessionKey }?: UseLockerverseBookingsOptions): UseLockerverseBookingsResult;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { type LockerverseBookingAttempt, type LockerverseBookingBusiness, type LockerverseBookingConfiguration, type LockerverseBookingStatus, type UseLockerverseBookingsOptions, type UseLockerverseBookingsResult, useLockerverseBookings };
|
|
28
|
+
//# sourceMappingURL=bookings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bookings.d.ts","names":[],"sources":["../src/use-lockerverse-bookings.ts"],"mappings":";;KAUY;EACV;;EAEA;;KAEU;EACV,eAAe;EACf;EACA;EACA,SAAS;EACT;EACA;EACA;EACA,OAAO;EACP;EACA,eAAe;EACf,YAAY,iBAAiB,QAAQ;EACrC,aACE,WAAW,gCACR,QAAQ;EACb,UAAU,8BAA8B,QAAQ;EAChD,eAAe,QAAQ;;;iBA4CT,uBACd,QAAQ,6BACN,SAAgB,eAAkB,gCACnC"}
|
package/dist/bookings.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{useCallback as e,useEffect as t,useRef as n,useState as r}from"react";import{LockerverseSdkError as i}from"@lockerverse/sdk/bookings";const a=()=>({attempt:null,availabilityMessage:``,busy:!1,configuration:null,error:null,recovered:!1,recovering:!1,slots:[]});function o(e){return new i({code:`booking_request_failed`,message:e,operation:`recover_booking`,recoveryRecommended:!0,reportable:!1})}function s(e){return e instanceof i?e:o(`The booking request could not be completed. Check the saved state before paying.`)}function c(i,{enabled:c=!0,sessionKey:l=0}={}){if(n(i).current!==i)throw Error(`Keep the booking client stable. Remount for another business.`);let[u,d]=r(a),f=n(u),p=n(0),m=n(!1),h=n(l),g=n(!1),_=e(e=>{f.current={...f.current,...e},d(f.current)},[]),v=e(async(e,t,n,r=!1)=>{if(!(c&&m.current)||h.current!==l||g.current)throw o(`A booking request is already in progress or access is disabled.`);g.current=!0;let i=p.current,a=()=>i===p.current;_({busy:!0,error:null,recovered:!n&&f.current.recovered,recovering:r});try{let n=await e();if(!a())throw o(`The booking access session changed. Recover the current session.`);return _(t(n)),n}catch(e){let t=s(e);throw a()&&_({error:t,recovered:!n&&f.current.recovered}),t}finally{i===p.current&&(g.current=!1,_({busy:!1,recovering:!1}))}},[_,c,l]),y=e(async()=>{await v(async()=>{let e=await i.configuration();return{attempt:await i.recover(),configuration:e}},e=>({...e,recovered:!0}),!0,!0)},[i,v]),b=e(()=>v(()=>i.recover(),e=>({attempt:e,recovered:!0}),!0,!0),[i,v]),x=e(e=>v(()=>i.availability(e),e=>({availabilityMessage:e.message,slots:e.slots}),!1),[i,v]),S=e(e=>{let t=f.current;return!(t.configuration?.ready&&t.recovered)||t.attempt?Promise.reject(o(`Recover the saved booking before selecting a new session.`)):v(()=>i.initialize(e),e=>({attempt:e,recovered:!0}),!0)},[i,v]),C=e(e=>{let t=f.current;return t.configuration?.ready&&t.recovered&&t.attempt?.status===`review`?v(()=>i.confirm(e),e=>({attempt:e,recovered:e.status!==`review`}),!0):Promise.reject(o(`Recover this attempt before submitting a payment.`))},[i,v]);return t(()=>(p.current+=1,g.current=!1,m.current=c,h.current=l,f.current=a(),d(f.current),c&&y().catch(()=>void 0),()=>{m.current=!1,p.current+=1}),[c,l,y]),{...u,canPay:!!(c&&h.current===l&&u.configuration?.ready&&u.recovered&&u.attempt?.status===`review`&&!u.busy),confirm:C,findTimes:x,initialize:S,recover:b,refresh:y}}export{c as useLockerverseBookings};
|
|
2
|
+
//# sourceMappingURL=bookings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bookings.js","names":[],"sources":["../src/use-lockerverse-bookings.ts"],"sourcesContent":["import {\n type LockerverseBookingAttempt,\n type LockerverseBookingAvailability,\n type LockerverseBookingConfiguration,\n type LockerverseBookingSelection,\n type LockerverseBookingsClient,\n LockerverseSdkError,\n} from \"@lockerverse/sdk/bookings\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\nexport type UseLockerverseBookingsOptions = {\n enabled?: boolean;\n /** Non-secret generation value. Change it when the access session changes. */\n sessionKey?: string | number;\n};\nexport type UseLockerverseBookingsResult = {\n configuration: LockerverseBookingConfiguration | null;\n slots: string[];\n availabilityMessage: string;\n attempt: LockerverseBookingAttempt | null;\n busy: boolean;\n recovering: boolean;\n recovered: boolean;\n error: LockerverseSdkError | null;\n canPay: boolean;\n refresh: () => Promise<void>;\n findTimes: (date: string) => Promise<LockerverseBookingAvailability>;\n initialize: (\n selection: LockerverseBookingSelection\n ) => Promise<LockerverseBookingAttempt>;\n confirm: (confirmationToken: string) => Promise<LockerverseBookingAttempt>;\n recover: () => Promise<LockerverseBookingAttempt | null>;\n};\n\ntype BookingState = Pick<\n UseLockerverseBookingsResult,\n | \"configuration\"\n | \"slots\"\n | \"availabilityMessage\"\n | \"attempt\"\n | \"busy\"\n | \"recovering\"\n | \"recovered\"\n | \"error\"\n>;\nconst initialState = (): BookingState => ({\n attempt: null,\n availabilityMessage: \"\",\n busy: false,\n configuration: null,\n error: null,\n recovered: false,\n recovering: false,\n slots: [],\n});\nfunction stateError(message: string) {\n return new LockerverseSdkError({\n code: \"booking_request_failed\",\n message,\n operation: \"recover_booking\",\n recoveryRecommended: true,\n reportable: false,\n });\n}\n\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- Promise rejection values are untrusted and are normalized here.\nfunction safeBookingError(error: unknown): LockerverseSdkError {\n return error instanceof LockerverseSdkError\n ? error\n : stateError(\n \"The booking request could not be completed. Check the saved state before paying.\"\n );\n}\n\n/** Recover the business-scoped attempt before permitting a payment submission. */\nexport function useLockerverseBookings(\n client: LockerverseBookingsClient,\n { enabled = true, sessionKey = 0 }: UseLockerverseBookingsOptions = {}\n): UseLockerverseBookingsResult {\n const identity = useRef(client);\n if (identity.current !== client) {\n throw new Error(\n \"Keep the booking client stable. Remount for another business.\"\n );\n }\n const [state, setState] = useState<BookingState>(initialState);\n const current = useRef(state);\n const generation = useRef(0);\n const active = useRef(false);\n const activeSession = useRef(sessionKey);\n const inFlight = useRef(false);\n const commit = useCallback((change: Partial<BookingState>) => {\n current.current = { ...current.current, ...change };\n setState(current.current);\n }, []);\n\n const run = useCallback(\n async <T>(\n operation: () => Promise<T>,\n accept: (result: T) => Partial<BookingState>,\n changesPaymentState: boolean,\n recovering = false\n ): Promise<T> => {\n if (\n !(enabled && active.current) ||\n activeSession.current !== sessionKey ||\n inFlight.current\n ) {\n throw stateError(\n \"A booking request is already in progress or access is disabled.\"\n );\n }\n inFlight.current = true;\n const version = generation.current;\n const isCurrent = () => version === generation.current;\n commit({\n busy: true,\n error: null,\n recovered: changesPaymentState ? false : current.current.recovered,\n recovering,\n });\n try {\n const result = await operation();\n if (!isCurrent()) {\n throw stateError(\n \"The booking access session changed. Recover the current session.\"\n );\n }\n commit(accept(result));\n return result;\n } catch (error) {\n const safeError = safeBookingError(error);\n if (isCurrent()) {\n commit({\n error: safeError,\n recovered: changesPaymentState ? false : current.current.recovered,\n });\n }\n throw safeError;\n } finally {\n if (version === generation.current) {\n inFlight.current = false;\n commit({ busy: false, recovering: false });\n }\n }\n },\n [commit, enabled, sessionKey]\n );\n\n const refresh = useCallback(async () => {\n await run(\n async () => {\n const configuration = await client.configuration();\n const attempt = await client.recover();\n return { attempt, configuration };\n },\n (result) => ({ ...result, recovered: true }),\n true,\n true\n );\n }, [client, run]);\n const recover = useCallback(\n () =>\n run(\n () => client.recover(),\n (attempt) => ({ attempt, recovered: true }),\n true,\n true\n ),\n [client, run]\n );\n const findTimes = useCallback(\n (date: string) =>\n run(\n () => client.availability(date),\n (result) => ({\n availabilityMessage: result.message,\n slots: result.slots,\n }),\n false\n ),\n [client, run]\n );\n const initialize = useCallback(\n (selection: LockerverseBookingSelection) => {\n const saved = current.current;\n if (!(saved.configuration?.ready && saved.recovered) || saved.attempt) {\n return Promise.reject(\n stateError(\n \"Recover the saved booking before selecting a new session.\"\n )\n );\n }\n return run(\n () => client.initialize(selection),\n (attempt) => ({ attempt, recovered: true }),\n true\n );\n },\n [client, run]\n );\n const confirm = useCallback(\n (confirmationToken: string) => {\n const saved = current.current;\n if (\n !(\n saved.configuration?.ready &&\n saved.recovered &&\n saved.attempt?.status === \"review\"\n )\n ) {\n return Promise.reject(\n stateError(\"Recover this attempt before submitting a payment.\")\n );\n }\n return run(\n () => client.confirm(confirmationToken),\n (attempt) => ({ attempt, recovered: attempt.status !== \"review\" }),\n true\n );\n },\n [client, run]\n );\n\n useEffect(() => {\n generation.current += 1;\n inFlight.current = false;\n active.current = enabled;\n activeSession.current = sessionKey;\n current.current = initialState();\n setState(current.current);\n if (enabled) {\n refresh().catch(() => undefined);\n }\n return () => {\n active.current = false;\n generation.current += 1;\n };\n }, [enabled, sessionKey, refresh]);\n\n return {\n ...state,\n canPay: Boolean(\n enabled &&\n activeSession.current === sessionKey &&\n state.configuration?.ready &&\n state.recovered &&\n state.attempt?.status === \"review\" &&\n !state.busy\n ),\n confirm,\n findTimes,\n initialize,\n recover,\n refresh,\n };\n}\n"],"mappings":"6IA6CA,MAAM,OAAoC,CACxC,QAAS,KACT,oBAAqB,GACrB,KAAM,GACN,cAAe,KACf,MAAO,KACP,UAAW,GACX,WAAY,GACZ,MAAO,CAAC,CACV,GACA,SAAS,EAAW,EAAiB,CACnC,OAAO,IAAI,EAAoB,CAC7B,KAAM,yBACN,UACA,UAAW,kBACX,oBAAqB,GACrB,WAAY,EACd,CAAC,CACH,CAGA,SAAS,EAAiB,EAAqC,CAC7D,OAAO,aAAiB,EACpB,EACA,EACE,kFACF,CACN,CAGA,SAAgB,EACd,EACA,CAAE,UAAU,GAAM,aAAa,GAAqC,CAAC,EACvC,CAE9B,GADiB,EAAO,CACb,CAAC,CAAC,UAAY,EACvB,MAAU,MACR,+DACF,EAEF,GAAM,CAAC,EAAO,GAAY,EAAuB,CAAY,EACvD,EAAU,EAAO,CAAK,EACtB,EAAa,EAAO,CAAC,EACrB,EAAS,EAAO,EAAK,EACrB,EAAgB,EAAO,CAAU,EACjC,EAAW,EAAO,EAAK,EACvB,EAAS,EAAa,GAAkC,CAC5D,EAAQ,QAAU,CAAE,GAAG,EAAQ,QAAS,GAAG,CAAO,EAClD,EAAS,EAAQ,OAAO,CAC1B,EAAG,CAAC,CAAC,EAEC,EAAM,EACV,MACE,EACA,EACA,EACA,EAAa,KACE,CACf,GACE,EAAE,GAAW,EAAO,UACpB,EAAc,UAAY,GAC1B,EAAS,QAET,MAAM,EACJ,iEACF,EAEF,EAAS,QAAU,GACnB,IAAM,EAAU,EAAW,QACrB,MAAkB,IAAY,E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EAAQ,CAAG,CACd,EACM,EAAU,EACb,GAA8B,CAC7B,IAAM,EAAQ,EAAQ,QAYtB,OATI,EAAM,eAAe,OACrB,EAAM,WACN,EAAM,SAAS,SAAW,SAOvB,MACC,EAAO,QAAQ,CAAiB,EACrC,IAAa,CAAE,UAAS,UAAW,EAAQ,SAAW,QAAS,GAChE,EACF,EARS,QAAQ,OACb,EAAW,mDAAmD,CAChE,CAOJ,EACA,CAAC,EAAQ,CAAG,CACd,EAkBA,OAhBA,OACE,EAAW,SAAW,EACtB,EAAS,QAAU,GACnB,EAAO,QAAU,EACjB,EAAc,QAAU,EACxB,EAAQ,QAAU,EAAa,EAC/B,EAAS,EAAQ,OAAO,EACpB,GACF,EAAQ,CAAC,CAAC,UAAY,IAAA,EAAS,MAEpB,CACX,EAAO,QAAU,GACjB,EAAW,SAAW,CACxB,GACC,CAAC,EAAS,EAAY,CAAO,CAAC,EAE1B,CACL,GAAG,EACH,OAAQ,GACN,GACE,EAAc,UAAY,GAC1B,EAAM,eAAe,OACrB,EAAM,WACN,EAAM,SAAS,SAAW,UAC1B,CAAC,EAAM,MAEX,UACA,YACA,aACA,UACA,SACF,CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lockerverse-donate-launcher.d.ts","names":[],"sources":["../src/lockerverse-donate-launcher.tsx"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"lockerverse-donate-launcher.d.ts","names":[],"sources":["../src/lockerverse-donate-launcher.tsx"],"mappings":";;;iBAquBgB,4BACd,aACA,UACA,cACA,iBACA,kBACA,YACA,iBACA,WACG,gBACF,sFAA8B,IAAA,UAAA,SAAA,aAAA,6DAAA,8BAAA,+CAAA,8BAAA,SAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e,t}from"./accent-contrast.js";import{n,t as r}from"./lockerverse-payment.js";import{createElement as i,useEffect as a,useMemo as o,useState as s}from"react";import{Fragment as c,jsx as l,jsxs as u}from"react/jsx-runtime";import{Dialog as d}from"@base-ui/react/dialog";import{getLockerverseMinimumCustomAmountCents as f}from"@lockerverse/sdk/checkout";function p(e,t,n={}){let r=e.availability.listings.find(e=>e.listingId===t.listingId),i=e.products.reduce((e,r)=>e+(r.id!==t.id&&r.listingId===t.listingId?n[r.id]??0:0),0),a=Math.min(t.maximumQuantity??1/0,t.inventoryQuantity??1/0,(r?.maxPurchasableQuantity??1/0)-i);if(r?.status===`sold_out`)return 0;for(let r of e.availability.sharedLimits){if(!r.listingIds.includes(t.listingId))continue;let i=e.products.reduce((e,i)=>e+(i.id!==t.id&&r.listingIds.includes(i.listingId)?n[i.id]??0:0),0);a=Math.min(a,r.status===`sold_out`?0:r.remainingQuantity-i)}return Math.max(0,a)}function m(e,t){let n={};for(let r of t){let t=e.products.find(e=>e.slug===r.productSlug);t&&(n[t.id]=`quantity`in r?r.quantity:1)}let r=e.widget.requiredShipping;return r&&r.triggerProductIds.some(e=>(n[e]??0)>0)&&(n[r.productId]=1),n}function h(e,t){return e.products.every(n=>(t[n.id]??0)<=p(e,n,t))}function g(e,t,n){return e.pricingMode!==`fixed`||!(`quantity`in t)||!Number.isSafeInteger(t.quantity)||t.quantity<=0?0:Math.min(n,Math.max(e.minimumQuantity??1,t.quantity))}function _(e,t){if(e.pricingMode===`custom`&&`amountCents`in t&&Number.isSafeInteger(t.amountCents)&&t.amountCents>=f(e))return(t.amountCents/100).toFixed(2)}function v(e,t){let n={},r={},i=null,a={};for(let o of t){let t=e.products.find(e=>e.slug===o.productSlug);if(!t||t.id===e.widget.requiredShipping?.productId)continue;let s=p(e,t,t.paymentOption===`one-time`?a:{});if(s<(t.minimumQuantity??1))continue;if(t.paymentOption!==`one-time`){if(!(`quantity`in o||`amountCents`in o)){i=t.id;break}continue}let c=g(t,o,s);c>0&&(n[t.id]=c,a[t.id]=c);let l=_(t,o);l!==void 0&&(r[t.id]=l,a[t.id]=1)}return i?{customAmounts:{},quantities:{},recurringProductId:i}:{customAmounts:r,quantities:n,recurringProductId:i}}function y(e,t){return!e||t===void 0?e:{...e,products:e.products.filter(n=>t.includes(n.id)||n.id===e.widget.requiredShipping?.productId)}}function b(e,t){return t||!e?e:{...e,widget:{...e.widget,description:null}}}const x=new Intl.NumberFormat(`en-US`,{currency:`USD`,style:`currency`}),S=/^(?:0|[1-9]\d*)(?:\.\d{1,2})?$/,C=[1e3,2500,5e3,1e4];function w(e){if(!S.test(e))return null;let t=Math.round(Number(e)*100);return Number.isSafeInteger(t)&&t>0?t:null}function T(e,t){let n=``;return t===`monthly`&&(n=`/month`),t===`annually`&&(n=`/year`),t===`every-six-months`&&(n=` every 6 months`),`${x.format(e/100)}${n}`}function E({maximum:e,product:t,quantities:n,setQuantities:r,setRecurringProductId:i}){let a=(n[t.id]??0)>0;return l(`span`,{className:`lockerverse-launcher__optional-control`,children:l(`input`,{"aria-label":t.name,checked:a,className:`lockerverse-launcher__optional-switch`,disabled:!a&&e<1,onChange:()=>{i(null),r(e=>({...e,[t.id]:(e[t.id]??0)>0?0:1}))},type:`checkbox`})})}function D({maximum:e,customAmounts:t,product:n,quantities:r,recurringProductId:i,setCustomAmounts:a,setQuantities:o,setRecurringProductId:s}){let c=r[n.id]??0;if(n.pricingMode===`fixed`&&n.paymentOption===`one-time`){let t=n.minimumQuantity??1;return u(`span`,{className:`lockerverse-launcher__quantity`,children:[l(`button`,{"aria-label":`Decrease ${n.name} quantity`,disabled:c===0,onClick:()=>{s(null),o(e=>{let r=e[n.id]??0;return{...e,[n.id]:r<=t?0:r-1}})},type:`button`,children:`−`}),l(`output`,{"aria-label":`${n.name} quantity`,children:c}),l(`button`,{"aria-label":`Increase ${n.name} quantity`,disabled:e<t||c>=e,onClick:()=>{s(null),o(e=>{let r=e[n.id]??0;return{...e,[n.id]:r===0?t:r+1}})},type:`button`,children:`+`})]})}return n.pricingMode===`custom`&&n.paymentOption===`one-time`?u(`span`,{className:`lockerverse-launcher__custom-amount`,children:[l(`span`,{"aria-hidden":`true`,children:`$`}),l(`input`,{"aria-label":`${n.name} amount`,min:f(n)/100,name:`amount-${n.slug}`,onChange:e=>{s(null),a(t=>({...t,[n.id]:e.target.value}))},placeholder:`0.00`,step:`0.01`,type:`number`,value:t[n.id]??``}),n.minimumAmountCents===null?null:u(`small`,{children:[`Minimum `,x.format(n.minimumAmountCents/100)]})]}):l(`button`,{"aria-label":`Select ${n.name}`,"aria-pressed":i===n.id,className:`lockerverse-launcher__select`,disabled:i!==n.id&&e<1,onClick:()=>{o({}),a({}),s(e=>e===n.id?null:n.id)},type:`button`,children:`Select`})}function O({variant:e=`default`,...t}){let{customAmounts:n,product:r,quantities:i,recurringProductId:a,unavailableLabel:o}=t,s=w(n[r.id]??``),c=a===r.id||r.paymentOption===`one-time`&&(r.pricingMode===`fixed`&&(i[r.id]??0)>0||r.pricingMode===`custom`&&s!==null&&s>=f(r));return u(`article`,{className:`lockerverse-launcher__product lockerverse-launcher__product--${e}`,"data-selected":c||void 0,"data-ticket":r.fulfillmentType===`event_admission`||void 0,children:[u(`span`,{className:`lockerverse-launcher__product-copy`,children:[l(`strong`,{className:`lockerverse-launcher__product-name`,children:r.name}),r.description?l(`small`,{children:r.description}):null,r.amountCents===null?null:l(`span`,{className:`lockerverse-launcher__product-price`,children:T(r.amountCents,r.paymentOption)})]}),u(`span`,{className:`lockerverse-launcher__product-control`,children:[o?l(`span`,{className:`lockerverse-launcher__availability`,children:o}):null,(o!==`Sold out`||c)&&(r.pricingMode===`fixed`&&r.paymentOption===`one-time`&&r.maximumQuantity===1&&(r.minimumQuantity??1)<=1?l(E,{...t}):l(D,{...t}))]})]})}function k({maximum:e,unavailableLabel:t,customAmounts:n,product:r,setCustomAmounts:i,setRecurringProductId:a}){let o=n[r.id]??``,s=w(o),c=C.filter(e=>e>=f(r)),d=c.includes(s??0),p=e=>{a(null),i(t=>({...t,[r.id]:e}))};return u(`div`,{className:`lockerverse-launcher__donation-option`,children:[t?l(`p`,{children:t}):null,u(`fieldset`,{className:`lockerverse-launcher__donation-choices`,children:[u(`legend`,{className:`lockerverse-launcher__sr-only`,children:[r.name,` amount`]}),l(`button`,{"aria-pressed":o===``,onClick:()=>p(``),type:`button`,children:`No thanks`}),c.map(t=>l(`button`,{"aria-pressed":s===t,disabled:e<1,onClick:()=>p(String(t/100)),type:`button`,children:x.format(t/100).replace(`.00`,``)},t)),l(`label`,{className:`lockerverse-launcher__donation-other`,"data-selected":o!==``&&!d||void 0,children:l(`input`,{"aria-label":`${r.name} amount`,disabled:e<1&&o===``,min:f(r)/100,name:`amount-${r.slug}`,onChange:e=>p(e.target.value),placeholder:`Other $`,step:`0.01`,type:`number`,value:d?``:o})})]})]})}function A({catalog:e,selectedQuantities:t,products:n,variant:r=`default`,...a}){return l(`div`,{className:`lockerverse-launcher__product-list`,children:n.map(n=>{let o=p(e,n,n.paymentOption===`one-time`?t:{}),s=n.minimumQuantity??1,c;return p(e,n)<s?c=`Sold out`:o<s&&(c=`Limit reached`),r===`donation`?i(k,{...a,key:n.id,maximum:o,product:n,unavailableLabel:c}):i(O,{...a,key:n.id,maximum:o,product:n,unavailableLabel:c,variant:r})})})}function j(e,t){let n=0,r=0;for(let i of t){let t=e.products.find(e=>e.slug===i.productSlug);if(t){if(`quantity`in i){n+=i.quantity,r+=(t.amountCents??0)*i.quantity;continue}n+=1,r+=`amountCents`in i?i.amountCents:t.amountCents??0}}let i=e.widget.requiredShipping,a=i?t.reduce((t,n)=>{let r=e.products.find(e=>e.slug===n.productSlug);return r&&i.triggerProductIds.includes(r.id)?t+(`quantity`in n?n.quantity:1):t},0):0,o=a>0;return i&&o&&(r+=(e.products.find(e=>e.id===i.productId)?.amountCents??0)+Math.max(0,a-1)*(i.additionalUnitAmountCents??0)),{amountCents:r,itemCount:n,needsShipping:o}}function M(){return l(`div`,{"aria-label":`Loading donation options`,className:`lockerverse-launcher__loading`,role:`status`,children:[0,1,2].map(e=>l(`span`,{"aria-hidden":`true`,className:`lockerverse-launcher__loading-row`},e))})}function N(e,t,n,r){if(r){let t=e.products.find(e=>e.id===r&&e.paymentOption!==`one-time`);return t?[{productSlug:t.slug}]:[]}return e.products.flatMap(e=>{let r=t[e.id]??0;if(e.pricingMode===`fixed`&&e.paymentOption===`one-time`&&r>0)return[{productSlug:e.slug,quantity:r}];let i=w(n[e.id]??``);return e.pricingMode===`custom`&&e.paymentOption===`one-time`&&i!==null&&i>=f(e)?[{amountCents:i,productSlug:e.slug}]:[]})}function P({catalog:e,onContinue:t,...n}){let r=N(e,n.quantities,n.customAmounts,n.recurringProductId),i=m(e,r),a=h(e,i),o=j(e,r),s=e.products.filter(e=>e.paymentOption===`one-time`&&e.pricingMode===`custom`),c=e.products.filter(t=>!s.includes(t)&&t.id!==e.widget.requiredShipping?.productId);return u(`form`,{className:`lockerverse-launcher__products`,onSubmit:e=>{e.preventDefault(),r.length>0&&a&&t(r)},children:[c.length>0?l(`section`,{className:`lockerverse-launcher__section`,children:l(A,{...n,catalog:e,products:c,selectedQuantities:i})}):null,s.length>0?u(`section`,{className:`lockerverse-launcher__donation`,children:[u(`header`,{className:`lockerverse-launcher__section-header`,children:[l(`h3`,{children:`Add a donation`}),l(`p`,{children:`Choose an amount to add to this order.`})]}),l(A,{...n,catalog:e,products:s,selectedQuantities:i,variant:`donation`})]}):null,c.length+s.length>0?u(`footer`,{className:`lockerverse-launcher__footer`,children:[u(`p`,{"aria-live":`polite`,className:`lockerverse-launcher__summary`,children:[l(`span`,{children:o.itemCount===0?`No items selected`:`${o.itemCount} ${o.itemCount===1?`item`:`items`} selected`}),o.itemCount===0?null:l(`strong`,{children:x.format(o.amountCents/100)})]}),o.needsShipping?l(`p`,{children:`Shipping is included once per order.`}):null,a?null:l(`p`,{children:`Some selected items are no longer available. Reduce their quantity to continue.`}),l(`button`,{className:`lockerverse-launcher__continue`,disabled:r.length===0||!a,type:`submit`,children:`Continue`})]}):l(`p`,{children:`No products are available for this link.`})]})}function F({presentation:e,onEdit:t,paymentProps:n,selection:i,style:a,widget:o}){return u(`div`,{className:`lockerverse-launcher__checkout`,children:[l(`header`,{className:`lockerverse-launcher__checkout-toolbar`,children:l(`button`,{className:`lockerverse-launcher__back`,onClick:t,type:`button`,children:`Edit order`})}),l(r,{...n,className:e===`page`?void 0:n.className,paymentSummaryPosition:n.paymentSummaryPosition??`bottom`,selection:i,style:a,widget:o})]})}function I({catalog:e,checkout:t,presentation:n=`dialog`,showDescription:r=!0}){let i=n===`page`?`h1`:d.Title,a=n===`page`?`p`:d.Description;return t&&n===`dialog`?u(c,{children:[l(i,{className:`lockerverse-launcher__sr-only`,children:`Checkout`}),l(a,{className:`lockerverse-launcher__sr-only`,children:`Review the order and complete payment.`})]}):e?u(`header`,{className:`lockerverse-launcher__header`,children:[e.community?u(`div`,{className:`lockerverse-launcher__brand`,children:[e.community.imageUrl?l(`img`,{alt:`${e.community.name} logo`,height:`28`,src:e.community.imageUrl,width:`28`}):null,l(`span`,{children:e.community.name})]}):null,l(i,{className:`lockerverse-launcher__title`,children:e.widget.title??e.widget.name}),l(a,{className:`lockerverse-launcher__description`,hidden:!r,children:e.widget.description??`Choose your options, then continue to checkout.`})]}):u(`header`,{className:`lockerverse-launcher__header`,children:[l(i,{className:`lockerverse-launcher__title`,children:`Donate`}),l(a,{className:`lockerverse-launcher__description`,hidden:!r,children:`Choose your options, then continue to checkout.`})]})}function L(e,t,n){return e===`page`&&t&&n!==void 0}const R=/^#([\da-f]{3}|[\da-f]{6})$/i;function z(t,n){let r=e(t??``);return n&&R.test(r)?`color-mix(in srgb, ${r} 18%, #f5f3ee)`:`#f5f3ee`}function B({buttonLabel:r=`Donate`,position:i=`inline`,presentation:c=`dialog`,loadingFallback:f,initialSelection:p=[],productIds:m,showDescription:h=!0,widget:g,..._}){let[x,S]=s(null),[C,w]=s({}),[T,E]=s({}),[D,O]=s(null),[k]=s(()=>({initialSelection:p.map(e=>({...e})),productIds:m?[...m]:void 0})),[A,j]=s(!1),{error:N,loading:R}=g,B=o(()=>b(g.catalog,h),[g.catalog,h]),V=y(g.catalog,k.productIds);a(()=>{if(A||!g.catalog)return;let e=y(g.catalog,k.productIds);if(!e)return;let t=v(e,k.initialSelection);E(t.quantities),w(t.customAmounts),O(t.recurringProductId),j(!0)},[A,g.catalog,k]);let H=e(_.style?.[`--lockerverse-accent`]??V?.community?.accentColor??`#38d77a`),U=t(H),W={..._.style,"--lockerverse-ticket-paper":z(g.catalog?.community?.accentColor,g.catalog?.widget.showCommunityBranding)};(_.style?.[`--lockerverse-accent`]!==void 0||V?.community?.accentColor)&&(W[`--lockerverse-accent`]=H),U&&_.style?.[`--lockerverse-accent-contrast`]===void 0&&(W[`--lockerverse-accent-contrast`]=U);let G=R||!(A||N),K;return K=G?l(M,{}):N?u(`div`,{role:`alert`,children:[l(`p`,{children:`Unable to load donation options.`}),l(`button`,{onClick:g.refresh,type:`button`,children:`Retry`})]}):V?l(P,{catalog:V,customAmounts:C,onContinue:S,quantities:T,recurringProductId:D,setCustomAmounts:w,setQuantities:E,setRecurringProductId:O}):l(M,{}),!(R||N)&&x&&V&&(K=l(F,{onEdit:()=>S(null),paymentProps:_,presentation:c,selection:x,style:W,widget:{...g,catalog:B}})),L(c,G,f)?f:c===`page`?u(`section`,{className:`lockerverse-launcher__dialog lockerverse-launcher__page ${_.className??``}`,"data-lockerverse-theme":_.theme??`dark`,style:W,children:[l(I,{catalog:V,checkout:x!==null,presentation:`page`,showDescription:h}),K]}):u(d.Root,{onOpenChange:e=>{e&&V&&_.stripeLoader===void 0&&requestAnimationFrame(()=>{n(V)})},children:[l(d.Trigger,{className:`lockerverse-launcher lockerverse-launcher--${i}`,"data-lockerverse-theme":_.theme??`dark`,style:W,children:r}),u(d.Portal,{children:[l(d.Backdrop,{className:`lockerverse-launcher__backdrop`}),l(d.Viewport,{className:`lockerverse-launcher__viewport`,children:u(d.Popup,{className:`lockerverse-launcher__dialog`,"data-lockerverse-theme":_.theme??`dark`,style:W,children:[l(I,{catalog:V,checkout:x!==null,showDescription:h}),l(d.Close,{"aria-label":`Close donation dialog`,className:`lockerverse-launcher__close`,children:l(`span`,{"aria-hidden":`true`,children:`×`})}),K]})})]})]})}export{B as t};
|
|
1
|
+
import{n as e,t}from"./accent-contrast.js";import{n,t as r}from"./lockerverse-payment.js";import{createElement as i,useEffect as a,useMemo as o,useState as s}from"react";import{Fragment as c,jsx as l,jsxs as u}from"react/jsx-runtime";import{Dialog as d}from"@base-ui/react/dialog";import{getLockerverseMinimumCustomAmountCents as f}from"@lockerverse/sdk/checkout";function p(e,t,n={}){let r=e.availability.listings.find(e=>e.listingId===t.listingId),i=e.products.reduce((e,r)=>e+(r.id!==t.id&&r.listingId===t.listingId?n[r.id]??0:0),0),a=Math.min(t.maximumQuantity??1/0,t.inventoryQuantity??1/0,(r?.maxPurchasableQuantity??1/0)-i);if(r?.status===`sold_out`)return 0;for(let r of e.availability.sharedLimits){if(!r.listingIds.includes(t.listingId))continue;let i=e.products.reduce((e,i)=>e+(i.id!==t.id&&r.listingIds.includes(i.listingId)?n[i.id]??0:0),0);a=Math.min(a,r.status===`sold_out`?0:r.remainingQuantity-i)}return Math.max(0,a)}function m(e,t){let n={};for(let r of t){let t=e.products.find(e=>e.slug===r.productSlug);t&&(n[t.id]=`quantity`in r?r.quantity:1)}let r=e.widget.requiredShipping;return r&&r.triggerProductIds.some(e=>(n[e]??0)>0)&&(n[r.productId]=1),n}function h(e,t){return e.products.every(n=>(t[n.id]??0)<=p(e,n,t))}function g(e,t,n){return e.pricingMode!==`fixed`||!(`quantity`in t)||!Number.isSafeInteger(t.quantity)||t.quantity<=0?0:Math.min(n,Math.max(e.minimumQuantity??1,t.quantity))}function _(e,t){if(e.pricingMode===`custom`&&`amountCents`in t&&Number.isSafeInteger(t.amountCents)&&t.amountCents>=f(e))return(t.amountCents/100).toFixed(2)}function v(e,t){let n={},r={},i=null,a={};for(let o of t){let t=e.products.find(e=>e.slug===o.productSlug);if(!t||t.id===e.widget.requiredShipping?.productId)continue;let s=p(e,t,t.paymentOption===`one-time`?a:{});if(s<(t.minimumQuantity??1))continue;if(t.paymentOption!==`one-time`){if(!(`quantity`in o||`amountCents`in o)){i=t.id;break}continue}let c=g(t,o,s);c>0&&(n[t.id]=c,a[t.id]=c);let l=_(t,o);l!==void 0&&(r[t.id]=l,a[t.id]=1)}return i?{customAmounts:{},quantities:{},recurringProductId:i}:{customAmounts:r,quantities:n,recurringProductId:i}}function y(e,t){return!e||t===void 0?e:{...e,products:e.products.filter(n=>t.includes(n.id)||n.id===e.widget.requiredShipping?.productId)}}function b(e,t){return t||!e?e:{...e,widget:{...e.widget,description:null}}}const x=new Intl.NumberFormat(`en-US`,{currency:`USD`,style:`currency`}),S=/^(?:0|[1-9]\d*)(?:\.\d{1,2})?$/,C=[1e3,2500,5e3,1e4];function w(e){if(!S.test(e))return null;let t=Math.round(Number(e)*100);return Number.isSafeInteger(t)&&t>0?t:null}function T(e,t){let n=``;return t===`monthly`&&(n=`/month`),t===`annually`&&(n=`/year`),t===`every-six-months`&&(n=` every 6 months`),`${x.format(e/100)}${n}`}function E({maximum:e,product:t,quantities:n,setQuantities:r,setRecurringProductId:i}){let a=(n[t.id]??0)>0;return l(`span`,{className:`lockerverse-launcher__optional-control`,children:l(`input`,{"aria-label":t.name,checked:a,className:`lockerverse-launcher__optional-switch`,disabled:!a&&e<1,onChange:()=>{i(null),r(e=>({...e,[t.id]:(e[t.id]??0)>0?0:1}))},type:`checkbox`})})}function D({maximum:e,customAmounts:t,product:n,quantities:r,recurringProductId:i,setCustomAmounts:a,setQuantities:o,setRecurringProductId:s}){let c=r[n.id]??0;if(n.pricingMode===`fixed`&&n.paymentOption===`one-time`){let t=n.minimumQuantity??1;return u(`span`,{className:`lockerverse-launcher__quantity`,children:[l(`button`,{"aria-label":`Decrease ${n.name} quantity`,disabled:c===0,onClick:()=>{s(null),o(e=>{let r=e[n.id]??0;return{...e,[n.id]:r<=t?0:r-1}})},type:`button`,children:`−`}),l(`output`,{"aria-label":`${n.name} quantity`,children:c}),l(`button`,{"aria-label":`Increase ${n.name} quantity`,disabled:e<t||c>=e,onClick:()=>{s(null),o(e=>{let r=e[n.id]??0;return{...e,[n.id]:r===0?t:r+1}})},type:`button`,children:`+`})]})}return n.pricingMode===`custom`&&n.paymentOption===`one-time`?u(`span`,{className:`lockerverse-launcher__custom-amount`,children:[l(`span`,{"aria-hidden":`true`,children:`$`}),l(`input`,{"aria-label":`${n.name} amount`,min:f(n)/100,name:`amount-${n.slug}`,onChange:e=>{s(null),a(t=>({...t,[n.id]:e.target.value}))},placeholder:`0.00`,step:`0.01`,type:`number`,value:t[n.id]??``}),n.minimumAmountCents===null?null:u(`small`,{children:[`Minimum `,x.format(n.minimumAmountCents/100)]})]}):l(`button`,{"aria-label":`Select ${n.name}`,"aria-pressed":i===n.id,className:`lockerverse-launcher__select`,disabled:i!==n.id&&e<1,onClick:()=>{o({}),a({}),s(e=>e===n.id?null:n.id)},type:`button`,children:`Select`})}function O({variant:e=`default`,...t}){let{customAmounts:n,product:r,quantities:i,recurringProductId:a,unavailableLabel:o}=t,s=w(n[r.id]??``),c=a===r.id||r.paymentOption===`one-time`&&(r.pricingMode===`fixed`&&(i[r.id]??0)>0||r.pricingMode===`custom`&&s!==null&&s>=f(r));return u(`article`,{className:`lockerverse-launcher__product lockerverse-launcher__product--${e}`,"data-selected":c||void 0,"data-ticket":r.fulfillmentType===`event_admission`||void 0,children:[u(`span`,{className:`lockerverse-launcher__product-copy`,children:[l(`strong`,{className:`lockerverse-launcher__product-name`,children:r.name}),r.description?l(`small`,{children:r.description}):null,r.amountCents===null?null:l(`span`,{className:`lockerverse-launcher__product-price`,children:T(r.amountCents,r.paymentOption)})]}),u(`span`,{className:`lockerverse-launcher__product-control`,children:[o?l(`span`,{className:`lockerverse-launcher__availability`,children:o}):null,(o!==`Sold out`||c)&&(r.pricingMode===`fixed`&&r.paymentOption===`one-time`&&r.maximumQuantity===1&&(r.minimumQuantity??1)<=1?l(E,{...t}):l(D,{...t}))]})]})}function k({maximum:e,unavailableLabel:t,customAmounts:n,product:r,setCustomAmounts:i,setRecurringProductId:a}){let o=n[r.id]??``,s=w(o),c=C.filter(e=>e>=f(r)),d=c.includes(s??0),p=e=>{a(null),i(t=>({...t,[r.id]:e}))};return u(`div`,{className:`lockerverse-launcher__donation-option`,children:[t?l(`p`,{children:t}):null,u(`fieldset`,{className:`lockerverse-launcher__donation-choices`,children:[u(`legend`,{className:`lockerverse-launcher__sr-only`,children:[r.name,` amount`]}),l(`button`,{"aria-pressed":o===``,onClick:()=>p(``),type:`button`,children:`No thanks`}),c.map(t=>l(`button`,{"aria-pressed":s===t,disabled:e<1,onClick:()=>p(String(t/100)),type:`button`,children:x.format(t/100).replace(`.00`,``)},t)),l(`label`,{className:`lockerverse-launcher__donation-other`,"data-selected":o!==``&&!d||void 0,children:l(`input`,{"aria-label":`${r.name} amount`,disabled:e<1&&o===``,min:f(r)/100,name:`amount-${r.slug}`,onChange:e=>p(e.target.value),placeholder:`Other $`,step:`0.01`,type:`number`,value:d?``:o})})]})]})}function A({catalog:e,selectedQuantities:t,products:n,variant:r=`default`,...a}){return l(`div`,{className:`lockerverse-launcher__product-list`,children:n.map(n=>{let o=p(e,n,n.paymentOption===`one-time`?t:{}),s=n.minimumQuantity??1,c;return p(e,n)<s?c=`Sold out`:o<s&&(c=`Limit reached`),r===`donation`?i(k,{...a,key:n.id,maximum:o,product:n,unavailableLabel:c}):i(O,{...a,key:n.id,maximum:o,product:n,unavailableLabel:c,variant:r})})})}function j(e,t){let n=0,r=0;for(let i of t){let t=e.products.find(e=>e.slug===i.productSlug);if(t){if(`quantity`in i){n+=i.quantity,r+=(t.amountCents??0)*i.quantity;continue}n+=1,r+=`amountCents`in i?i.amountCents:t.amountCents??0}}let i=e.widget.requiredShipping,a=i?t.reduce((t,n)=>{let r=e.products.find(e=>e.slug===n.productSlug);return r&&i.triggerProductIds.includes(r.id)?t+(`quantity`in n?n.quantity:1):t},0):0,o=a>0;return i&&o&&(r+=(e.products.find(e=>e.id===i.productId)?.amountCents??0)+Math.max(0,a-1)*(i.additionalUnitAmountCents??0)),{amountCents:r,itemCount:n,needsShipping:o}}function M(){return l(`div`,{"aria-label":`Loading donation options`,className:`lockerverse-launcher__loading`,role:`status`,children:[0,1,2].map(e=>l(`span`,{"aria-hidden":`true`,className:`lockerverse-launcher__loading-row`},e))})}function N(e,t,n,r){if(r){let t=e.products.find(e=>e.id===r&&e.paymentOption!==`one-time`);return t?[{productSlug:t.slug}]:[]}return e.products.flatMap(e=>{let r=t[e.id]??0;if(e.pricingMode===`fixed`&&e.paymentOption===`one-time`&&r>0)return[{productSlug:e.slug,quantity:r}];let i=w(n[e.id]??``);return e.pricingMode===`custom`&&e.paymentOption===`one-time`&&i!==null&&i>=f(e)?[{amountCents:i,productSlug:e.slug}]:[]})}function P({catalog:e,onContinue:t,...n}){let r=N(e,n.quantities,n.customAmounts,n.recurringProductId),i=m(e,r),a=h(e,i),o=j(e,r),s=e.products.filter(e=>e.paymentOption===`one-time`&&e.pricingMode===`custom`),c=e.products.filter(t=>!s.includes(t)&&t.id!==e.widget.requiredShipping?.productId);return u(`form`,{className:`lockerverse-launcher__products`,onSubmit:e=>{e.preventDefault(),r.length>0&&a&&t(r)},children:[c.length>0?l(`section`,{className:`lockerverse-launcher__section`,children:l(A,{...n,catalog:e,products:c,selectedQuantities:i})}):null,s.length>0?u(`section`,{className:`lockerverse-launcher__donation`,children:[l(`header`,{className:`lockerverse-launcher__section-header`,children:l(`h3`,{children:`Add a donation`})}),l(A,{...n,catalog:e,products:s,selectedQuantities:i,variant:`donation`})]}):null,c.length+s.length>0?u(`footer`,{className:`lockerverse-launcher__footer`,children:[u(`p`,{"aria-live":`polite`,className:`lockerverse-launcher__summary`,children:[l(`span`,{children:o.itemCount===0?`No items selected`:`${o.itemCount} ${o.itemCount===1?`item`:`items`} selected`}),o.itemCount===0?null:l(`strong`,{children:x.format(o.amountCents/100)})]}),o.needsShipping?l(`p`,{children:`Shipping is included once per order.`}):null,a?null:l(`p`,{children:`Some selected items are no longer available. Reduce their quantity to continue.`}),l(`button`,{className:`lockerverse-launcher__continue`,disabled:r.length===0||!a,type:`submit`,children:`Continue`})]}):l(`p`,{children:`No products are available for this link.`})]})}function F({presentation:e,onEdit:t,paymentProps:n,selection:i,style:a,widget:o}){return u(`div`,{className:`lockerverse-launcher__checkout`,children:[l(`header`,{className:`lockerverse-launcher__checkout-toolbar`,children:l(`button`,{className:`lockerverse-launcher__back`,onClick:t,type:`button`,children:`Edit order`})}),l(r,{...n,className:e===`page`?void 0:n.className,paymentSummaryPosition:n.paymentSummaryPosition??`bottom`,selection:i,style:a,widget:o})]})}function I({catalog:e,checkout:t,presentation:n=`dialog`,showDescription:r=!0}){let i=n===`page`?`h1`:d.Title,a=n===`page`?`p`:d.Description;return t&&n===`dialog`?u(c,{children:[l(i,{className:`lockerverse-launcher__sr-only`,children:`Checkout`}),l(a,{className:`lockerverse-launcher__sr-only`,children:`Review the order and complete payment.`})]}):e?u(`header`,{className:`lockerverse-launcher__header`,children:[e.community?u(`div`,{className:`lockerverse-launcher__brand`,children:[e.community.imageUrl?l(`img`,{alt:`${e.community.name} logo`,height:`28`,src:e.community.imageUrl,width:`28`}):null,l(`span`,{children:e.community.name})]}):null,l(i,{className:`lockerverse-launcher__title`,children:e.widget.title??e.widget.name}),l(a,{className:`lockerverse-launcher__description`,hidden:!r,children:e.widget.description??`Choose your options, then continue to checkout.`})]}):u(`header`,{className:`lockerverse-launcher__header`,children:[l(i,{className:`lockerverse-launcher__title`,children:`Donate`}),l(a,{className:`lockerverse-launcher__description`,hidden:!r,children:`Choose your options, then continue to checkout.`})]})}function L(e,t,n){return e===`page`&&t&&n!==void 0}const R=/^#([\da-f]{3}|[\da-f]{6})$/i;function z(t,n){let r=e(t??``);return n&&R.test(r)?`color-mix(in srgb, ${r} 18%, #f5f3ee)`:`#f5f3ee`}function B({buttonLabel:r=`Donate`,position:i=`inline`,presentation:c=`dialog`,loadingFallback:f,initialSelection:p=[],productIds:m,showDescription:h=!0,widget:g,..._}){let[x,S]=s(null),[C,w]=s({}),[T,E]=s({}),[D,O]=s(null),[k]=s(()=>({initialSelection:p.map(e=>({...e})),productIds:m?[...m]:void 0})),[A,j]=s(!1),{error:N,loading:R}=g,B=o(()=>b(g.catalog,h),[g.catalog,h]),V=y(g.catalog,k.productIds);a(()=>{if(A||!g.catalog)return;let e=y(g.catalog,k.productIds);if(!e)return;let t=v(e,k.initialSelection);E(t.quantities),w(t.customAmounts),O(t.recurringProductId),j(!0)},[A,g.catalog,k]);let H=e(_.style?.[`--lockerverse-accent`]??V?.community?.accentColor??`#38d77a`),U=t(H),W={..._.style,"--lockerverse-ticket-paper":z(g.catalog?.community?.accentColor,g.catalog?.widget.showCommunityBranding)};(_.style?.[`--lockerverse-accent`]!==void 0||V?.community?.accentColor)&&(W[`--lockerverse-accent`]=H),U&&_.style?.[`--lockerverse-accent-contrast`]===void 0&&(W[`--lockerverse-accent-contrast`]=U);let G=R||!(A||N),K;return K=G?l(M,{}):N?u(`div`,{role:`alert`,children:[l(`p`,{children:`Unable to load donation options.`}),l(`button`,{onClick:g.refresh,type:`button`,children:`Retry`})]}):V?l(P,{catalog:V,customAmounts:C,onContinue:S,quantities:T,recurringProductId:D,setCustomAmounts:w,setQuantities:E,setRecurringProductId:O}):l(M,{}),!(R||N)&&x&&V&&(K=l(F,{onEdit:()=>S(null),paymentProps:_,presentation:c,selection:x,style:W,widget:{...g,catalog:B}})),L(c,G,f)?f:c===`page`?u(`section`,{className:`lockerverse-launcher__dialog lockerverse-launcher__page ${_.className??``}`,"data-lockerverse-theme":_.theme??`dark`,style:W,children:[l(I,{catalog:V,checkout:x!==null,presentation:`page`,showDescription:h}),K]}):u(d.Root,{onOpenChange:e=>{e&&V&&_.stripeLoader===void 0&&requestAnimationFrame(()=>{n(V)})},children:[l(d.Trigger,{className:`lockerverse-launcher lockerverse-launcher--${i}`,"data-lockerverse-theme":_.theme??`dark`,style:W,children:r}),u(d.Portal,{children:[l(d.Backdrop,{className:`lockerverse-launcher__backdrop`}),l(d.Viewport,{className:`lockerverse-launcher__viewport`,children:u(d.Popup,{className:`lockerverse-launcher__dialog`,"data-lockerverse-theme":_.theme??`dark`,style:W,children:[l(I,{catalog:V,checkout:x!==null,showDescription:h}),l(d.Close,{"aria-label":`Close donation dialog`,className:`lockerverse-launcher__close`,children:l(`span`,{"aria-hidden":`true`,children:`×`})}),K]})})]})]})}export{B as t};
|
|
2
2
|
//# sourceMappingURL=lockerverse-donate-launcher.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lockerverse-donate-launcher.js","names":[],"sources":["../src/launcher-configuration.ts","../src/lockerverse-donate-launcher.tsx"],"sourcesContent":["import {\n getLockerverseMinimumCustomAmountCents,\n type LockerverseCatalog,\n type LockerverseProduct,\n} from \"@lockerverse/sdk/checkout\";\nimport type { LockerversePaymentSelectionItem } from \"./types.ts\";\n\nexport function getLauncherMaximumQuantity(\n catalog: LockerverseCatalog,\n product: LockerverseProduct,\n quantities: Record<string, number> = {}\n) {\n const listing = catalog.availability.listings.find(\n (entry) => entry.listingId === product.listingId\n );\n const sameListingQuantity = catalog.products.reduce(\n (total, other) =>\n total +\n (other.id !== product.id && other.listingId === product.listingId\n ? (quantities[other.id] ?? 0)\n : 0),\n 0\n );\n let maximum = Math.min(\n product.maximumQuantity ?? Number.POSITIVE_INFINITY,\n product.inventoryQuantity ?? Number.POSITIVE_INFINITY,\n (listing?.maxPurchasableQuantity ?? Number.POSITIVE_INFINITY) -\n sameListingQuantity\n );\n if (listing?.status === \"sold_out\") {\n return 0;\n }\n for (const limit of catalog.availability.sharedLimits) {\n if (!limit.listingIds.includes(product.listingId)) {\n continue;\n }\n const used = catalog.products.reduce(\n (total, other) =>\n total +\n (other.id !== product.id && limit.listingIds.includes(other.listingId)\n ? (quantities[other.id] ?? 0)\n : 0),\n 0\n );\n maximum = Math.min(\n maximum,\n limit.status === \"sold_out\" ? 0 : limit.remainingQuantity - used\n );\n }\n return Math.max(0, maximum);\n}\n\nexport function getLauncherSelectedQuantities(\n catalog: LockerverseCatalog,\n selection: LockerversePaymentSelectionItem[]\n) {\n const quantities: Record<string, number> = {};\n for (const item of selection) {\n const product = catalog.products.find(\n (entry) => entry.slug === item.productSlug\n );\n if (product) {\n quantities[product.id] = \"quantity\" in item ? item.quantity : 1;\n }\n }\n const shipping = catalog.widget.requiredShipping;\n if (!shipping) {\n return quantities;\n }\n if (shipping.triggerProductIds.some((id) => (quantities[id] ?? 0) > 0)) {\n quantities[shipping.productId] = 1;\n }\n return quantities;\n}\n\nexport function isLauncherSelectionAvailable(\n catalog: LockerverseCatalog,\n quantities: Record<string, number>\n) {\n return catalog.products.every(\n (product) =>\n (quantities[product.id] ?? 0) <=\n getLauncherMaximumQuantity(catalog, product, quantities)\n );\n}\n\nfunction getInitialQuantity(\n product: LockerverseProduct,\n item: LockerversePaymentSelectionItem,\n maximum: number\n) {\n if (\n product.pricingMode !== \"fixed\" ||\n !(\"quantity\" in item) ||\n !Number.isSafeInteger(item.quantity) ||\n item.quantity <= 0\n ) {\n return 0;\n }\n return Math.min(\n maximum,\n Math.max(product.minimumQuantity ?? 1, item.quantity)\n );\n}\n\nfunction getInitialCustomAmount(\n product: LockerverseProduct,\n item: LockerversePaymentSelectionItem\n) {\n if (\n product.pricingMode === \"custom\" &&\n \"amountCents\" in item &&\n Number.isSafeInteger(item.amountCents) &&\n item.amountCents >= getLockerverseMinimumCustomAmountCents(product)\n ) {\n return (item.amountCents / 100).toFixed(2);\n }\n}\n\nexport function getInitialChoices(\n catalog: LockerverseCatalog,\n selection: LockerversePaymentSelectionItem[]\n) {\n const quantities: Record<string, number> = {};\n const customAmounts: Record<string, string> = {};\n let recurringProductId: string | null = null;\n const selectedQuantities: Record<string, number> = {};\n for (const item of selection) {\n const product = catalog.products.find(\n (candidate) => candidate.slug === item.productSlug\n );\n if (!product || product.id === catalog.widget.requiredShipping?.productId) {\n continue;\n }\n const maximum = getLauncherMaximumQuantity(\n catalog,\n product,\n product.paymentOption === \"one-time\" ? selectedQuantities : {}\n );\n if (maximum < (product.minimumQuantity ?? 1)) {\n continue;\n }\n if (product.paymentOption !== \"one-time\") {\n if (!(\"quantity\" in item || \"amountCents\" in item)) {\n recurringProductId = product.id;\n break;\n }\n continue;\n }\n const quantity = getInitialQuantity(product, item, maximum);\n if (quantity > 0) {\n quantities[product.id] = quantity;\n selectedQuantities[product.id] = quantity;\n }\n const customAmount = getInitialCustomAmount(product, item);\n if (customAmount !== undefined) {\n customAmounts[product.id] = customAmount;\n selectedQuantities[product.id] = 1;\n }\n }\n return recurringProductId\n ? { customAmounts: {}, quantities: {}, recurringProductId }\n : { customAmounts, quantities, recurringProductId };\n}\n\nexport function filterLauncherCatalog(\n catalog: LockerverseCatalog | null,\n productIds: string[] | undefined\n) {\n if (!catalog || productIds === undefined) {\n return catalog;\n }\n return {\n ...catalog,\n products: catalog.products.filter(\n (product) =>\n productIds.includes(product.id) ||\n product.id === catalog.widget.requiredShipping?.productId\n ),\n };\n}\n\nexport function launcherPaymentCatalog(\n catalog: LockerverseCatalog | null,\n showDescription: boolean\n) {\n if (showDescription || !catalog) {\n return catalog;\n }\n return { ...catalog, widget: { ...catalog.widget, description: null } };\n}\n","import { Dialog } from \"@base-ui/react/dialog\";\nimport {\n getLockerverseMinimumCustomAmountCents,\n type LockerverseCatalog,\n type LockerverseProduct,\n} from \"@lockerverse/sdk/checkout\";\nimport {\n type Dispatch,\n type ReactNode,\n type SetStateAction,\n useEffect,\n useMemo,\n useState,\n} from \"react\";\nimport { getAccentContrast, normalizeAccentColor } from \"./accent-contrast.ts\";\nimport {\n filterLauncherCatalog,\n getInitialChoices,\n getLauncherMaximumQuantity,\n getLauncherSelectedQuantities,\n isLauncherSelectionAvailable,\n launcherPaymentCatalog,\n} from \"./launcher-configuration.ts\";\nimport { LockerversePayment } from \"./lockerverse-payment.tsx\";\nimport { preloadLockerversePayment } from \"./payment-form.tsx\";\nimport type {\n LockerverseDonateLauncherProps,\n LockerversePaymentProps,\n LockerversePaymentSelectionItem,\n LockerversePaymentStyle,\n} from \"./types.ts\";\nimport type { UseLockerverseWidgetResult } from \"./use-lockerverse-widget.ts\";\n\nconst usd = new Intl.NumberFormat(\"en-US\", {\n currency: \"USD\",\n style: \"currency\",\n});\nconst decimalAmountPattern = /^(?:0|[1-9]\\d*)(?:\\.\\d{1,2})?$/;\nconst suggestedDonationAmountsCents = [1000, 2500, 5000, 10_000];\n\nfunction parseAmountCents(value: string) {\n if (!decimalAmountPattern.test(value)) {\n return null;\n }\n const amountCents = Math.round(Number(value) * 100);\n return Number.isSafeInteger(amountCents) && amountCents > 0\n ? amountCents\n : null;\n}\n\nfunction formatProductPrice(\n amountCents: number,\n paymentOption: \"one-time\" | \"monthly\" | \"annually\" | \"every-six-months\"\n) {\n let cadence = \"\";\n if (paymentOption === \"monthly\") {\n cadence = \"/month\";\n }\n if (paymentOption === \"annually\") {\n cadence = \"/year\";\n }\n if (paymentOption === \"every-six-months\") {\n cadence = \" every 6 months\";\n }\n return `${usd.format(amountCents / 100)}${cadence}`;\n}\n\ntype LauncherProductControlProps = {\n maximum: number;\n unavailableLabel: string | undefined;\n customAmounts: Record<string, string>;\n product: LockerverseProduct;\n quantities: Record<string, number>;\n recurringProductId: string | null;\n setCustomAmounts: Dispatch<SetStateAction<Record<string, string>>>;\n setQuantities: Dispatch<SetStateAction<Record<string, number>>>;\n setRecurringProductId: Dispatch<SetStateAction<string | null>>;\n};\n\nfunction LauncherOptionalProduct({\n maximum,\n product,\n quantities,\n setQuantities,\n setRecurringProductId,\n}: LauncherProductControlProps) {\n const included = (quantities[product.id] ?? 0) > 0;\n return (\n <span className=\"lockerverse-launcher__optional-control\">\n <input\n aria-label={product.name}\n checked={included}\n className=\"lockerverse-launcher__optional-switch\"\n disabled={!included && maximum < 1}\n onChange={() => {\n setRecurringProductId(null);\n setQuantities((current) => ({\n ...current,\n [product.id]: (current[product.id] ?? 0) > 0 ? 0 : 1,\n }));\n }}\n type=\"checkbox\"\n />\n </span>\n );\n}\n\nfunction LauncherProductControl({\n maximum,\n customAmounts,\n product,\n quantities,\n recurringProductId,\n setCustomAmounts,\n setQuantities,\n setRecurringProductId,\n}: LauncherProductControlProps) {\n const quantity = quantities[product.id] ?? 0;\n if (product.pricingMode === \"fixed\" && product.paymentOption === \"one-time\") {\n const minimum = product.minimumQuantity ?? 1;\n return (\n <span className=\"lockerverse-launcher__quantity\">\n <button\n aria-label={`Decrease ${product.name} quantity`}\n disabled={quantity === 0}\n onClick={() => {\n setRecurringProductId(null);\n setQuantities((current) => {\n const currentQuantity = current[product.id] ?? 0;\n return {\n ...current,\n [product.id]:\n currentQuantity <= minimum ? 0 : currentQuantity - 1,\n };\n });\n }}\n type=\"button\"\n >\n −\n </button>\n <output aria-label={`${product.name} quantity`}>{quantity}</output>\n <button\n aria-label={`Increase ${product.name} quantity`}\n disabled={maximum < minimum || quantity >= maximum}\n onClick={() => {\n setRecurringProductId(null);\n setQuantities((current) => {\n const currentQuantity = current[product.id] ?? 0;\n return {\n ...current,\n [product.id]:\n currentQuantity === 0 ? minimum : currentQuantity + 1,\n };\n });\n }}\n type=\"button\"\n >\n +\n </button>\n </span>\n );\n }\n\n if (\n product.pricingMode === \"custom\" &&\n product.paymentOption === \"one-time\"\n ) {\n return (\n <span className=\"lockerverse-launcher__custom-amount\">\n <span aria-hidden=\"true\">$</span>\n <input\n aria-label={`${product.name} amount`}\n min={getLockerverseMinimumCustomAmountCents(product) / 100}\n name={`amount-${product.slug}`}\n onChange={(event) => {\n setRecurringProductId(null);\n setCustomAmounts((current) => ({\n ...current,\n [product.id]: event.target.value,\n }));\n }}\n placeholder=\"0.00\"\n step=\"0.01\"\n type=\"number\"\n value={customAmounts[product.id] ?? \"\"}\n />\n {product.minimumAmountCents === null ? null : (\n <small>Minimum {usd.format(product.minimumAmountCents / 100)}</small>\n )}\n </span>\n );\n }\n\n return (\n <button\n aria-label={`Select ${product.name}`}\n aria-pressed={recurringProductId === product.id}\n className=\"lockerverse-launcher__select\"\n disabled={recurringProductId !== product.id && maximum < 1}\n onClick={() => {\n setQuantities({});\n setCustomAmounts({});\n setRecurringProductId((current) =>\n current === product.id ? null : product.id\n );\n }}\n type=\"button\"\n >\n Select\n </button>\n );\n}\n\ntype LauncherProductOptionProps = LauncherProductControlProps & {\n variant?: \"default\" | \"donation\";\n};\n\nfunction LauncherProductOption({\n variant = \"default\",\n ...props\n}: LauncherProductOptionProps) {\n const {\n customAmounts,\n product,\n quantities,\n recurringProductId,\n unavailableLabel,\n } = props;\n const customAmount = parseAmountCents(customAmounts[product.id] ?? \"\");\n const isSelected =\n recurringProductId === product.id ||\n (product.paymentOption === \"one-time\" &&\n ((product.pricingMode === \"fixed\" && (quantities[product.id] ?? 0) > 0) ||\n (product.pricingMode === \"custom\" &&\n customAmount !== null &&\n customAmount >= getLockerverseMinimumCustomAmountCents(product))));\n return (\n <article\n className={`lockerverse-launcher__product lockerverse-launcher__product--${variant}`}\n data-selected={isSelected || undefined}\n data-ticket={product.fulfillmentType === \"event_admission\" || undefined}\n >\n <span className=\"lockerverse-launcher__product-copy\">\n <strong className=\"lockerverse-launcher__product-name\">\n {product.name}\n </strong>\n {product.description ? <small>{product.description}</small> : null}\n {product.amountCents === null ? null : (\n <span className=\"lockerverse-launcher__product-price\">\n {formatProductPrice(product.amountCents, product.paymentOption)}\n </span>\n )}\n </span>\n <span className=\"lockerverse-launcher__product-control\">\n {unavailableLabel ? (\n <span className=\"lockerverse-launcher__availability\">\n {unavailableLabel}\n </span>\n ) : null}\n {(unavailableLabel !== \"Sold out\" || isSelected) &&\n (product.pricingMode === \"fixed\" &&\n product.paymentOption === \"one-time\" &&\n product.maximumQuantity === 1 &&\n (product.minimumQuantity ?? 1) <= 1 ? (\n <LauncherOptionalProduct {...props} />\n ) : (\n <LauncherProductControl {...props} />\n ))}\n </span>\n </article>\n );\n}\n\nfunction LauncherDonationOption({\n maximum,\n unavailableLabel,\n customAmounts,\n product,\n setCustomAmounts,\n setRecurringProductId,\n}: LauncherProductControlProps) {\n const amount = customAmounts[product.id] ?? \"\";\n const amountCents = parseAmountCents(amount);\n const suggestions = suggestedDonationAmountsCents.filter(\n (suggestion) =>\n suggestion >= getLockerverseMinimumCustomAmountCents(product)\n );\n const isSuggestedAmount = suggestions.includes(amountCents ?? 0);\n const setAmount = (value: string) => {\n setRecurringProductId(null);\n setCustomAmounts((current) => ({\n ...current,\n [product.id]: value,\n }));\n };\n\n return (\n <div className=\"lockerverse-launcher__donation-option\">\n {unavailableLabel ? <p>{unavailableLabel}</p> : null}\n <fieldset className=\"lockerverse-launcher__donation-choices\">\n <legend className=\"lockerverse-launcher__sr-only\">\n {product.name} amount\n </legend>\n <button\n aria-pressed={amount === \"\"}\n onClick={() => setAmount(\"\")}\n type=\"button\"\n >\n No thanks\n </button>\n {suggestions.map((suggestion) => (\n <button\n aria-pressed={amountCents === suggestion}\n disabled={maximum < 1}\n key={suggestion}\n onClick={() => setAmount(String(suggestion / 100))}\n type=\"button\"\n >\n {usd.format(suggestion / 100).replace(\".00\", \"\")}\n </button>\n ))}\n <label\n className=\"lockerverse-launcher__donation-other\"\n data-selected={amount !== \"\" && !isSuggestedAmount ? true : undefined}\n >\n <input\n aria-label={`${product.name} amount`}\n disabled={maximum < 1 && amount === \"\"}\n min={getLockerverseMinimumCustomAmountCents(product) / 100}\n name={`amount-${product.slug}`}\n onChange={(event) => setAmount(event.target.value)}\n placeholder=\"Other $\"\n step=\"0.01\"\n type=\"number\"\n value={isSuggestedAmount ? \"\" : amount}\n />\n </label>\n </fieldset>\n </div>\n );\n}\n\ntype LauncherProductListProps = Omit<\n LauncherProductControlProps,\n \"maximum\" | \"product\" | \"unavailableLabel\"\n> & {\n catalog: LockerverseCatalog;\n selectedQuantities: Record<string, number>;\n products: LockerverseProduct[];\n variant?: LauncherProductOptionProps[\"variant\"];\n};\n\nfunction LauncherProductList({\n catalog,\n selectedQuantities,\n products,\n variant = \"default\",\n ...controlProps\n}: LauncherProductListProps) {\n return (\n <div className=\"lockerverse-launcher__product-list\">\n {products.map((product) => {\n const maximum = getLauncherMaximumQuantity(\n catalog,\n product,\n product.paymentOption === \"one-time\" ? selectedQuantities : {}\n );\n const minimum = product.minimumQuantity ?? 1;\n let unavailableLabel: string | undefined;\n if (getLauncherMaximumQuantity(catalog, product) < minimum) {\n unavailableLabel = \"Sold out\";\n } else if (maximum < minimum) {\n unavailableLabel = \"Limit reached\";\n }\n return variant === \"donation\" ? (\n <LauncherDonationOption\n {...controlProps}\n key={product.id}\n maximum={maximum}\n product={product}\n unavailableLabel={unavailableLabel}\n />\n ) : (\n <LauncherProductOption\n {...controlProps}\n key={product.id}\n maximum={maximum}\n product={product}\n unavailableLabel={unavailableLabel}\n variant={variant}\n />\n );\n })}\n </div>\n );\n}\n\nfunction getSelectionSummary(\n catalog: LockerverseCatalog,\n selection: LockerversePaymentSelectionItem[]\n) {\n let itemCount = 0;\n let amountCents = 0;\n for (const item of selection) {\n const product = catalog.products.find(\n (candidate) => candidate.slug === item.productSlug\n );\n if (!product) {\n continue;\n }\n if (\"quantity\" in item) {\n itemCount += item.quantity;\n amountCents += (product.amountCents ?? 0) * item.quantity;\n continue;\n }\n itemCount += 1;\n amountCents +=\n \"amountCents\" in item ? item.amountCents : (product.amountCents ?? 0);\n }\n const shipping = catalog.widget.requiredShipping;\n const triggerQuantity = shipping\n ? selection.reduce((total, item) => {\n const product = catalog.products.find(\n (candidate) => candidate.slug === item.productSlug\n );\n if (!(product && shipping.triggerProductIds.includes(product.id))) {\n return total;\n }\n return total + (\"quantity\" in item ? item.quantity : 1);\n }, 0)\n : 0;\n const needsShipping = triggerQuantity > 0;\n if (shipping && needsShipping) {\n amountCents +=\n (catalog.products.find((product) => product.id === shipping.productId)\n ?.amountCents ?? 0) +\n Math.max(0, triggerQuantity - 1) *\n (shipping.additionalUnitAmountCents ?? 0);\n }\n return { amountCents, itemCount, needsShipping };\n}\n\nfunction LauncherLoading() {\n return (\n <div\n aria-label=\"Loading donation options\"\n className=\"lockerverse-launcher__loading\"\n role=\"status\"\n >\n {[0, 1, 2].map((item) => (\n <span\n aria-hidden=\"true\"\n className=\"lockerverse-launcher__loading-row\"\n key={item}\n />\n ))}\n </div>\n );\n}\n\nfunction createLauncherSelection(\n catalog: LockerverseCatalog,\n quantities: Record<string, number>,\n customAmounts: Record<string, string>,\n recurringProductId: string | null\n): LockerversePaymentSelectionItem[] {\n if (recurringProductId) {\n const product = catalog.products.find(\n (candidate) =>\n candidate.id === recurringProductId &&\n candidate.paymentOption !== \"one-time\"\n );\n return product ? [{ productSlug: product.slug }] : [];\n }\n\n return catalog.products.flatMap(\n (product): LockerversePaymentSelectionItem[] => {\n const quantity = quantities[product.id] ?? 0;\n if (\n product.pricingMode === \"fixed\" &&\n product.paymentOption === \"one-time\" &&\n quantity > 0\n ) {\n return [{ productSlug: product.slug, quantity }];\n }\n const amountCents = parseAmountCents(customAmounts[product.id] ?? \"\");\n if (\n product.pricingMode === \"custom\" &&\n product.paymentOption === \"one-time\" &&\n amountCents !== null &&\n amountCents >= getLockerverseMinimumCustomAmountCents(product)\n ) {\n return [{ amountCents, productSlug: product.slug }];\n }\n return [];\n }\n );\n}\n\ntype LauncherSelectionStateProps = Omit<\n LauncherProductControlProps,\n \"maximum\" | \"product\" | \"unavailableLabel\"\n>;\n\ntype LauncherCatalogProps = LauncherSelectionStateProps & {\n catalog: LockerverseCatalog;\n onContinue: (selection: LockerversePaymentSelectionItem[]) => void;\n};\n\nfunction LauncherCatalog({\n catalog,\n onContinue,\n ...selectionState\n}: LauncherCatalogProps) {\n const draftSelection = createLauncherSelection(\n catalog,\n selectionState.quantities,\n selectionState.customAmounts,\n selectionState.recurringProductId\n );\n const selectedQuantities = getLauncherSelectedQuantities(\n catalog,\n draftSelection\n );\n const selectionAvailable = isLauncherSelectionAvailable(\n catalog,\n selectedQuantities\n );\n const summary = getSelectionSummary(catalog, draftSelection);\n const donationProducts = catalog.products.filter(\n (product) =>\n product.paymentOption === \"one-time\" && product.pricingMode === \"custom\"\n );\n const orderProducts = catalog.products.filter(\n (product) =>\n !donationProducts.includes(product) &&\n product.id !== catalog.widget.requiredShipping?.productId\n );\n\n return (\n <form\n className=\"lockerverse-launcher__products\"\n onSubmit={(event) => {\n event.preventDefault();\n if (draftSelection.length > 0 && selectionAvailable) {\n onContinue(draftSelection);\n }\n }}\n >\n {orderProducts.length > 0 ? (\n <section className=\"lockerverse-launcher__section\">\n <LauncherProductList\n {...selectionState}\n catalog={catalog}\n products={orderProducts}\n selectedQuantities={selectedQuantities}\n />\n </section>\n ) : null}\n {donationProducts.length > 0 ? (\n <section className=\"lockerverse-launcher__donation\">\n <header className=\"lockerverse-launcher__section-header\">\n <h3>Add a donation</h3>\n <p>Choose an amount to add to this order.</p>\n </header>\n <LauncherProductList\n {...selectionState}\n catalog={catalog}\n products={donationProducts}\n selectedQuantities={selectedQuantities}\n variant=\"donation\"\n />\n </section>\n ) : null}\n {orderProducts.length + donationProducts.length > 0 ? (\n <footer className=\"lockerverse-launcher__footer\">\n <p aria-live=\"polite\" className=\"lockerverse-launcher__summary\">\n <span>\n {summary.itemCount === 0\n ? \"No items selected\"\n : `${summary.itemCount} ${summary.itemCount === 1 ? \"item\" : \"items\"} selected`}\n </span>\n {summary.itemCount === 0 ? null : (\n <strong>{usd.format(summary.amountCents / 100)}</strong>\n )}\n </p>\n {summary.needsShipping ? (\n <p>Shipping is included once per order.</p>\n ) : null}\n {selectionAvailable ? null : (\n <p>\n Some selected items are no longer available. Reduce their quantity\n to continue.\n </p>\n )}\n <button\n className=\"lockerverse-launcher__continue\"\n disabled={draftSelection.length === 0 || !selectionAvailable}\n type=\"submit\"\n >\n Continue\n </button>\n </footer>\n ) : (\n <p>No products are available for this link.</p>\n )}\n </form>\n );\n}\n\ntype LauncherPaymentProps = Omit<\n LockerversePaymentProps,\n \"selection\" | \"widget\"\n>;\n\ntype LauncherCheckoutProps = {\n presentation: \"dialog\" | \"page\";\n onEdit: () => void;\n paymentProps: LauncherPaymentProps;\n selection: LockerversePaymentSelectionItem[];\n style: LockerversePaymentStyle;\n widget: UseLockerverseWidgetResult;\n};\n\nfunction LauncherCheckout({\n presentation,\n onEdit,\n paymentProps,\n selection,\n style,\n widget,\n}: LauncherCheckoutProps) {\n return (\n <div className=\"lockerverse-launcher__checkout\">\n <header className=\"lockerverse-launcher__checkout-toolbar\">\n <button\n className=\"lockerverse-launcher__back\"\n onClick={onEdit}\n type=\"button\"\n >\n Edit order\n </button>\n </header>\n <LockerversePayment\n {...paymentProps}\n className={presentation === \"page\" ? undefined : paymentProps.className}\n paymentSummaryPosition={paymentProps.paymentSummaryPosition ?? \"bottom\"}\n selection={selection}\n style={style}\n widget={widget}\n />\n </div>\n );\n}\n\nfunction LauncherDialogHeading({\n catalog,\n checkout,\n presentation = \"dialog\",\n showDescription = true,\n}: {\n presentation?: \"dialog\" | \"page\";\n showDescription?: boolean;\n catalog: LockerverseCatalog | null;\n checkout: boolean;\n}) {\n const Title = presentation === \"page\" ? \"h1\" : Dialog.Title;\n const Description = presentation === \"page\" ? \"p\" : Dialog.Description;\n if (checkout && presentation === \"dialog\") {\n return (\n <>\n <Title className=\"lockerverse-launcher__sr-only\">Checkout</Title>\n <Description className=\"lockerverse-launcher__sr-only\">\n Review the order and complete payment.\n </Description>\n </>\n );\n }\n\n if (!catalog) {\n return (\n <header className=\"lockerverse-launcher__header\">\n <Title className=\"lockerverse-launcher__title\">Donate</Title>\n <Description\n className=\"lockerverse-launcher__description\"\n hidden={!showDescription}\n >\n Choose your options, then continue to checkout.\n </Description>\n </header>\n );\n }\n\n return (\n <header className=\"lockerverse-launcher__header\">\n {catalog.community ? (\n <div className=\"lockerverse-launcher__brand\">\n {catalog.community.imageUrl ? (\n <img\n alt={`${catalog.community.name} logo`}\n height=\"28\"\n src={catalog.community.imageUrl}\n width=\"28\"\n />\n ) : null}\n <span>{catalog.community.name}</span>\n </div>\n ) : null}\n <Title className=\"lockerverse-launcher__title\">\n {catalog.widget.title ?? catalog.widget.name}\n </Title>\n <Description\n className=\"lockerverse-launcher__description\"\n hidden={!showDescription}\n >\n {catalog.widget.description ??\n \"Choose your options, then continue to checkout.\"}\n </Description>\n </header>\n );\n}\n\nfunction hasPageLoadingFallback(\n presentation: \"dialog\" | \"page\",\n loading: boolean,\n fallback: ReactNode\n) {\n return presentation === \"page\" && loading && fallback !== undefined;\n}\n\nconst TICKET_COLOR = /^#([\\da-f]{3}|[\\da-f]{6})$/i;\n\nfunction getTicketPaper(\n color: string | undefined,\n showBranding: boolean | undefined\n) {\n const normalized = normalizeAccentColor(color ?? \"\");\n return showBranding && TICKET_COLOR.test(normalized)\n ? `color-mix(in srgb, ${normalized} 18%, #f5f3ee)`\n : \"#f5f3ee\";\n}\n\nexport function LockerverseDonateLauncher({\n buttonLabel = \"Donate\",\n position = \"inline\",\n presentation = \"dialog\",\n loadingFallback,\n initialSelection = [],\n productIds,\n showDescription = true,\n widget,\n ...paymentProps\n}: LockerverseDonateLauncherProps) {\n const [selection, setSelection] = useState<\n LockerversePaymentSelectionItem[] | null\n >(null);\n const [customAmounts, setCustomAmounts] = useState<Record<string, string>>(\n {}\n );\n const [quantities, setQuantities] = useState<Record<string, number>>({});\n const [recurringProductId, setRecurringProductId] = useState<string | null>(\n null\n );\n const [linkConfiguration] = useState(() => ({\n initialSelection: initialSelection.map((item) => ({ ...item })),\n productIds: productIds ? [...productIds] : undefined,\n }));\n const [initialized, setInitialized] = useState(false);\n const { error, loading } = widget;\n const paymentCatalog = useMemo(\n () => launcherPaymentCatalog(widget.catalog, showDescription),\n [widget.catalog, showDescription]\n );\n const catalog = filterLauncherCatalog(\n widget.catalog,\n linkConfiguration.productIds\n );\n useEffect(() => {\n if (initialized || !widget.catalog) {\n return;\n }\n const initialCatalog = filterLauncherCatalog(\n widget.catalog,\n linkConfiguration.productIds\n );\n if (!initialCatalog) {\n return;\n }\n const choices = getInitialChoices(\n initialCatalog,\n linkConfiguration.initialSelection\n );\n setQuantities(choices.quantities);\n setCustomAmounts(choices.customAmounts);\n setRecurringProductId(choices.recurringProductId);\n setInitialized(true);\n }, [initialized, widget.catalog, linkConfiguration]);\n const accent = normalizeAccentColor(\n paymentProps.style?.[\"--lockerverse-accent\"] ??\n catalog?.community?.accentColor ??\n \"#38d77a\"\n );\n const accentContrast = getAccentContrast(accent);\n const launcherStyle: LockerversePaymentStyle & {\n \"--lockerverse-ticket-paper\": string;\n } = {\n ...paymentProps.style,\n \"--lockerverse-ticket-paper\": getTicketPaper(\n widget.catalog?.community?.accentColor,\n widget.catalog?.widget.showCommunityBranding\n ),\n };\n if (\n paymentProps.style?.[\"--lockerverse-accent\"] !== undefined ||\n catalog?.community?.accentColor\n ) {\n launcherStyle[\"--lockerverse-accent\"] = accent;\n }\n if (\n accentContrast &&\n paymentProps.style?.[\"--lockerverse-accent-contrast\"] === undefined\n ) {\n launcherStyle[\"--lockerverse-accent-contrast\"] = accentContrast;\n }\n\n const optionsLoading = loading || !(initialized || error);\n let content: ReactNode;\n if (optionsLoading) {\n content = <LauncherLoading />;\n } else if (error) {\n content = (\n <div role=\"alert\">\n <p>Unable to load donation options.</p>\n <button onClick={widget.refresh} type=\"button\">\n Retry\n </button>\n </div>\n );\n } else if (catalog) {\n content = (\n <LauncherCatalog\n catalog={catalog}\n customAmounts={customAmounts}\n onContinue={setSelection}\n quantities={quantities}\n recurringProductId={recurringProductId}\n setCustomAmounts={setCustomAmounts}\n setQuantities={setQuantities}\n setRecurringProductId={setRecurringProductId}\n />\n );\n } else {\n content = <LauncherLoading />;\n }\n if (!(loading || error) && selection && catalog) {\n content = (\n <LauncherCheckout\n onEdit={() => setSelection(null)}\n paymentProps={paymentProps}\n presentation={presentation}\n selection={selection}\n style={launcherStyle}\n widget={{ ...widget, catalog: paymentCatalog }}\n />\n );\n }\n\n if (hasPageLoadingFallback(presentation, optionsLoading, loadingFallback)) {\n return loadingFallback;\n }\n if (presentation === \"page\") {\n return (\n <section\n className={`lockerverse-launcher__dialog lockerverse-launcher__page ${paymentProps.className ?? \"\"}`}\n data-lockerverse-theme={paymentProps.theme ?? \"dark\"}\n style={launcherStyle}\n >\n <LauncherDialogHeading\n catalog={catalog}\n checkout={selection !== null}\n presentation=\"page\"\n showDescription={showDescription}\n />\n {content}\n </section>\n );\n }\n\n return (\n <Dialog.Root\n onOpenChange={(open) => {\n if (open && catalog && paymentProps.stripeLoader === undefined) {\n requestAnimationFrame(() => {\n preloadLockerversePayment(catalog);\n });\n }\n }}\n >\n <Dialog.Trigger\n className={`lockerverse-launcher lockerverse-launcher--${position}`}\n data-lockerverse-theme={paymentProps.theme ?? \"dark\"}\n style={launcherStyle}\n >\n {buttonLabel}\n </Dialog.Trigger>\n <Dialog.Portal>\n <Dialog.Backdrop className=\"lockerverse-launcher__backdrop\" />\n <Dialog.Viewport className=\"lockerverse-launcher__viewport\">\n <Dialog.Popup\n className=\"lockerverse-launcher__dialog\"\n data-lockerverse-theme={paymentProps.theme ?? \"dark\"}\n style={launcherStyle}\n >\n <LauncherDialogHeading\n catalog={catalog}\n checkout={selection !== null}\n showDescription={showDescription}\n />\n <Dialog.Close\n aria-label=\"Close donation dialog\"\n className=\"lockerverse-launcher__close\"\n >\n <span aria-hidden=\"true\">×</span>\n </Dialog.Close>\n {content}\n </Dialog.Popup>\n </Dialog.Viewport>\n </Dialog.Portal>\n </Dialog.Root>\n );\n}\n"],"mappings":"4WAOA,SAAgB,EACd,EACA,EACA,EAAqC,CAAC,EACtC,CACA,IAAM,EAAU,EAAQ,aAAa,SAAS,KAC3C,GAAU,EAAM,YAAc,EAAQ,SACzC,EACM,EAAsB,EAAQ,SAAS,QAC1C,EAAO,IACN,GACC,EAAM,KAAO,EAAQ,IAAM,EAAM,YAAc,EAAQ,UACnD,EAAW,EAAM,KAAO,EACzB,GACN,CACF,EACI,EAAU,KAAK,IACjB,EAAQ,iBAAmB,IAC3B,EAAQ,mBAAqB,KAC5B,GAAS,wBAA0B,KAClC,CACJ,EACA,GAAI,GAAS,SAAW,WACtB,MAAO,GAET,IAAK,IAAM,KAAS,EAAQ,aAAa,aAAc,CACrD,GAAI,CAAC,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,GAAS,CAClB,GAAQ,GAAW,EAAa,eAAiB,IAAA,IACnD,0BAA4B,CAC1B,EAA0B,CAAO,CACnC,CAAC,CAEL,EAPF,SAAA,CASE,EAAC,EAAO,QAAR,CACE,UAAW,8CAA8C,IACzD,yBAAwB,EAAa,OAAS,OAC9C,MAAO,EAEN,SAAA,CACa,CAAA,EAChB,EAAC,EAAO,OAAR,CAAA,SAAA,CACE,EAAC,EAAO,SAAR,CAAiB,UAAU,gCAAkC,CAAA,EAC7D,EAAC,EAAO,SAAR,CAAiB,UAAU,iCACzB,SAAA,EAAC,EAAO,MAAR,CACE,UAAU,+BACV,yBAAwB,EAAa,OAAS,OAC9C,MAAO,EAHT,SAAA,CAKE,EAAC,EAAD,CACW,UACT,SAAU,IAAc,KACP,iBAClB,CAAA,EACD,EAAC,EAAO,MAAR,CACE,aAAW,wBACX,UAAU,8BAEV,SAAA,EAAC,OAAD,CAAM,cAAY,OAAO,SAAA,GAAO,CAAA,CACpB,CAAA,EACb,CACW,GACC,CAAA,CACJ,CAAA,CAAA,CACJ,GAEjB"}
|
|
1
|
+
{"version":3,"file":"lockerverse-donate-launcher.js","names":[],"sources":["../src/launcher-configuration.ts","../src/lockerverse-donate-launcher.tsx"],"sourcesContent":["import {\n getLockerverseMinimumCustomAmountCents,\n type LockerverseCatalog,\n type LockerverseProduct,\n} from \"@lockerverse/sdk/checkout\";\nimport type { LockerversePaymentSelectionItem } from \"./types.ts\";\n\nexport function getLauncherMaximumQuantity(\n catalog: LockerverseCatalog,\n product: LockerverseProduct,\n quantities: Record<string, number> = {}\n) {\n const listing = catalog.availability.listings.find(\n (entry) => entry.listingId === product.listingId\n );\n const sameListingQuantity = catalog.products.reduce(\n (total, other) =>\n total +\n (other.id !== product.id && other.listingId === product.listingId\n ? (quantities[other.id] ?? 0)\n : 0),\n 0\n );\n let maximum = Math.min(\n product.maximumQuantity ?? Number.POSITIVE_INFINITY,\n product.inventoryQuantity ?? Number.POSITIVE_INFINITY,\n (listing?.maxPurchasableQuantity ?? Number.POSITIVE_INFINITY) -\n sameListingQuantity\n );\n if (listing?.status === \"sold_out\") {\n return 0;\n }\n for (const limit of catalog.availability.sharedLimits) {\n if (!limit.listingIds.includes(product.listingId)) {\n continue;\n }\n const used = catalog.products.reduce(\n (total, other) =>\n total +\n (other.id !== product.id && limit.listingIds.includes(other.listingId)\n ? (quantities[other.id] ?? 0)\n : 0),\n 0\n );\n maximum = Math.min(\n maximum,\n limit.status === \"sold_out\" ? 0 : limit.remainingQuantity - used\n );\n }\n return Math.max(0, maximum);\n}\n\nexport function getLauncherSelectedQuantities(\n catalog: LockerverseCatalog,\n selection: LockerversePaymentSelectionItem[]\n) {\n const quantities: Record<string, number> = {};\n for (const item of selection) {\n const product = catalog.products.find(\n (entry) => entry.slug === item.productSlug\n );\n if (product) {\n quantities[product.id] = \"quantity\" in item ? item.quantity : 1;\n }\n }\n const shipping = catalog.widget.requiredShipping;\n if (!shipping) {\n return quantities;\n }\n if (shipping.triggerProductIds.some((id) => (quantities[id] ?? 0) > 0)) {\n quantities[shipping.productId] = 1;\n }\n return quantities;\n}\n\nexport function isLauncherSelectionAvailable(\n catalog: LockerverseCatalog,\n quantities: Record<string, number>\n) {\n return catalog.products.every(\n (product) =>\n (quantities[product.id] ?? 0) <=\n getLauncherMaximumQuantity(catalog, product, quantities)\n );\n}\n\nfunction getInitialQuantity(\n product: LockerverseProduct,\n item: LockerversePaymentSelectionItem,\n maximum: number\n) {\n if (\n product.pricingMode !== \"fixed\" ||\n !(\"quantity\" in item) ||\n !Number.isSafeInteger(item.quantity) ||\n item.quantity <= 0\n ) {\n return 0;\n }\n return Math.min(\n maximum,\n Math.max(product.minimumQuantity ?? 1, item.quantity)\n );\n}\n\nfunction getInitialCustomAmount(\n product: LockerverseProduct,\n item: LockerversePaymentSelectionItem\n) {\n if (\n product.pricingMode === \"custom\" &&\n \"amountCents\" in item &&\n Number.isSafeInteger(item.amountCents) &&\n item.amountCents >= getLockerverseMinimumCustomAmountCents(product)\n ) {\n return (item.amountCents / 100).toFixed(2);\n }\n}\n\nexport function getInitialChoices(\n catalog: LockerverseCatalog,\n selection: LockerversePaymentSelectionItem[]\n) {\n const quantities: Record<string, number> = {};\n const customAmounts: Record<string, string> = {};\n let recurringProductId: string | null = null;\n const selectedQuantities: Record<string, number> = {};\n for (const item of selection) {\n const product = catalog.products.find(\n (candidate) => candidate.slug === item.productSlug\n );\n if (!product || product.id === catalog.widget.requiredShipping?.productId) {\n continue;\n }\n const maximum = getLauncherMaximumQuantity(\n catalog,\n product,\n product.paymentOption === \"one-time\" ? selectedQuantities : {}\n );\n if (maximum < (product.minimumQuantity ?? 1)) {\n continue;\n }\n if (product.paymentOption !== \"one-time\") {\n if (!(\"quantity\" in item || \"amountCents\" in item)) {\n recurringProductId = product.id;\n break;\n }\n continue;\n }\n const quantity = getInitialQuantity(product, item, maximum);\n if (quantity > 0) {\n quantities[product.id] = quantity;\n selectedQuantities[product.id] = quantity;\n }\n const customAmount = getInitialCustomAmount(product, item);\n if (customAmount !== undefined) {\n customAmounts[product.id] = customAmount;\n selectedQuantities[product.id] = 1;\n }\n }\n return recurringProductId\n ? { customAmounts: {}, quantities: {}, recurringProductId }\n : { customAmounts, quantities, recurringProductId };\n}\n\nexport function filterLauncherCatalog(\n catalog: LockerverseCatalog | null,\n productIds: string[] | undefined\n) {\n if (!catalog || productIds === undefined) {\n return catalog;\n }\n return {\n ...catalog,\n products: catalog.products.filter(\n (product) =>\n productIds.includes(product.id) ||\n product.id === catalog.widget.requiredShipping?.productId\n ),\n };\n}\n\nexport function launcherPaymentCatalog(\n catalog: LockerverseCatalog | null,\n showDescription: boolean\n) {\n if (showDescription || !catalog) {\n return catalog;\n }\n return { ...catalog, widget: { ...catalog.widget, description: null } };\n}\n","import { Dialog } from \"@base-ui/react/dialog\";\nimport {\n getLockerverseMinimumCustomAmountCents,\n type LockerverseCatalog,\n type LockerverseProduct,\n} from \"@lockerverse/sdk/checkout\";\nimport {\n type Dispatch,\n type ReactNode,\n type SetStateAction,\n useEffect,\n useMemo,\n useState,\n} from \"react\";\nimport { getAccentContrast, normalizeAccentColor } from \"./accent-contrast.ts\";\nimport {\n filterLauncherCatalog,\n getInitialChoices,\n getLauncherMaximumQuantity,\n getLauncherSelectedQuantities,\n isLauncherSelectionAvailable,\n launcherPaymentCatalog,\n} from \"./launcher-configuration.ts\";\nimport { LockerversePayment } from \"./lockerverse-payment.tsx\";\nimport { preloadLockerversePayment } from \"./payment-form.tsx\";\nimport type {\n LockerverseDonateLauncherProps,\n LockerversePaymentProps,\n LockerversePaymentSelectionItem,\n LockerversePaymentStyle,\n} from \"./types.ts\";\nimport type { UseLockerverseWidgetResult } from \"./use-lockerverse-widget.ts\";\n\nconst usd = new Intl.NumberFormat(\"en-US\", {\n currency: \"USD\",\n style: \"currency\",\n});\nconst decimalAmountPattern = /^(?:0|[1-9]\\d*)(?:\\.\\d{1,2})?$/;\nconst suggestedDonationAmountsCents = [1000, 2500, 5000, 10_000];\n\nfunction parseAmountCents(value: string) {\n if (!decimalAmountPattern.test(value)) {\n return null;\n }\n const amountCents = Math.round(Number(value) * 100);\n return Number.isSafeInteger(amountCents) && amountCents > 0\n ? amountCents\n : null;\n}\n\nfunction formatProductPrice(\n amountCents: number,\n paymentOption: \"one-time\" | \"monthly\" | \"annually\" | \"every-six-months\"\n) {\n let cadence = \"\";\n if (paymentOption === \"monthly\") {\n cadence = \"/month\";\n }\n if (paymentOption === \"annually\") {\n cadence = \"/year\";\n }\n if (paymentOption === \"every-six-months\") {\n cadence = \" every 6 months\";\n }\n return `${usd.format(amountCents / 100)}${cadence}`;\n}\n\ntype LauncherProductControlProps = {\n maximum: number;\n unavailableLabel: string | undefined;\n customAmounts: Record<string, string>;\n product: LockerverseProduct;\n quantities: Record<string, number>;\n recurringProductId: string | null;\n setCustomAmounts: Dispatch<SetStateAction<Record<string, string>>>;\n setQuantities: Dispatch<SetStateAction<Record<string, number>>>;\n setRecurringProductId: Dispatch<SetStateAction<string | null>>;\n};\n\nfunction LauncherOptionalProduct({\n maximum,\n product,\n quantities,\n setQuantities,\n setRecurringProductId,\n}: LauncherProductControlProps) {\n const included = (quantities[product.id] ?? 0) > 0;\n return (\n <span className=\"lockerverse-launcher__optional-control\">\n <input\n aria-label={product.name}\n checked={included}\n className=\"lockerverse-launcher__optional-switch\"\n disabled={!included && maximum < 1}\n onChange={() => {\n setRecurringProductId(null);\n setQuantities((current) => ({\n ...current,\n [product.id]: (current[product.id] ?? 0) > 0 ? 0 : 1,\n }));\n }}\n type=\"checkbox\"\n />\n </span>\n );\n}\n\nfunction LauncherProductControl({\n maximum,\n customAmounts,\n product,\n quantities,\n recurringProductId,\n setCustomAmounts,\n setQuantities,\n setRecurringProductId,\n}: LauncherProductControlProps) {\n const quantity = quantities[product.id] ?? 0;\n if (product.pricingMode === \"fixed\" && product.paymentOption === \"one-time\") {\n const minimum = product.minimumQuantity ?? 1;\n return (\n <span className=\"lockerverse-launcher__quantity\">\n <button\n aria-label={`Decrease ${product.name} quantity`}\n disabled={quantity === 0}\n onClick={() => {\n setRecurringProductId(null);\n setQuantities((current) => {\n const currentQuantity = current[product.id] ?? 0;\n return {\n ...current,\n [product.id]:\n currentQuantity <= minimum ? 0 : currentQuantity - 1,\n };\n });\n }}\n type=\"button\"\n >\n −\n </button>\n <output aria-label={`${product.name} quantity`}>{quantity}</output>\n <button\n aria-label={`Increase ${product.name} quantity`}\n disabled={maximum < minimum || quantity >= maximum}\n onClick={() => {\n setRecurringProductId(null);\n setQuantities((current) => {\n const currentQuantity = current[product.id] ?? 0;\n return {\n ...current,\n [product.id]:\n currentQuantity === 0 ? minimum : currentQuantity + 1,\n };\n });\n }}\n type=\"button\"\n >\n +\n </button>\n </span>\n );\n }\n\n if (\n product.pricingMode === \"custom\" &&\n product.paymentOption === \"one-time\"\n ) {\n return (\n <span className=\"lockerverse-launcher__custom-amount\">\n <span aria-hidden=\"true\">$</span>\n <input\n aria-label={`${product.name} amount`}\n min={getLockerverseMinimumCustomAmountCents(product) / 100}\n name={`amount-${product.slug}`}\n onChange={(event) => {\n setRecurringProductId(null);\n setCustomAmounts((current) => ({\n ...current,\n [product.id]: event.target.value,\n }));\n }}\n placeholder=\"0.00\"\n step=\"0.01\"\n type=\"number\"\n value={customAmounts[product.id] ?? \"\"}\n />\n {product.minimumAmountCents === null ? null : (\n <small>Minimum {usd.format(product.minimumAmountCents / 100)}</small>\n )}\n </span>\n );\n }\n\n return (\n <button\n aria-label={`Select ${product.name}`}\n aria-pressed={recurringProductId === product.id}\n className=\"lockerverse-launcher__select\"\n disabled={recurringProductId !== product.id && maximum < 1}\n onClick={() => {\n setQuantities({});\n setCustomAmounts({});\n setRecurringProductId((current) =>\n current === product.id ? null : product.id\n );\n }}\n type=\"button\"\n >\n Select\n </button>\n );\n}\n\ntype LauncherProductOptionProps = LauncherProductControlProps & {\n variant?: \"default\" | \"donation\";\n};\n\nfunction LauncherProductOption({\n variant = \"default\",\n ...props\n}: LauncherProductOptionProps) {\n const {\n customAmounts,\n product,\n quantities,\n recurringProductId,\n unavailableLabel,\n } = props;\n const customAmount = parseAmountCents(customAmounts[product.id] ?? \"\");\n const isSelected =\n recurringProductId === product.id ||\n (product.paymentOption === \"one-time\" &&\n ((product.pricingMode === \"fixed\" && (quantities[product.id] ?? 0) > 0) ||\n (product.pricingMode === \"custom\" &&\n customAmount !== null &&\n customAmount >= getLockerverseMinimumCustomAmountCents(product))));\n return (\n <article\n className={`lockerverse-launcher__product lockerverse-launcher__product--${variant}`}\n data-selected={isSelected || undefined}\n data-ticket={product.fulfillmentType === \"event_admission\" || undefined}\n >\n <span className=\"lockerverse-launcher__product-copy\">\n <strong className=\"lockerverse-launcher__product-name\">\n {product.name}\n </strong>\n {product.description ? <small>{product.description}</small> : null}\n {product.amountCents === null ? null : (\n <span className=\"lockerverse-launcher__product-price\">\n {formatProductPrice(product.amountCents, product.paymentOption)}\n </span>\n )}\n </span>\n <span className=\"lockerverse-launcher__product-control\">\n {unavailableLabel ? (\n <span className=\"lockerverse-launcher__availability\">\n {unavailableLabel}\n </span>\n ) : null}\n {(unavailableLabel !== \"Sold out\" || isSelected) &&\n (product.pricingMode === \"fixed\" &&\n product.paymentOption === \"one-time\" &&\n product.maximumQuantity === 1 &&\n (product.minimumQuantity ?? 1) <= 1 ? (\n <LauncherOptionalProduct {...props} />\n ) : (\n <LauncherProductControl {...props} />\n ))}\n </span>\n </article>\n );\n}\n\nfunction LauncherDonationOption({\n maximum,\n unavailableLabel,\n customAmounts,\n product,\n setCustomAmounts,\n setRecurringProductId,\n}: LauncherProductControlProps) {\n const amount = customAmounts[product.id] ?? \"\";\n const amountCents = parseAmountCents(amount);\n const suggestions = suggestedDonationAmountsCents.filter(\n (suggestion) =>\n suggestion >= getLockerverseMinimumCustomAmountCents(product)\n );\n const isSuggestedAmount = suggestions.includes(amountCents ?? 0);\n const setAmount = (value: string) => {\n setRecurringProductId(null);\n setCustomAmounts((current) => ({\n ...current,\n [product.id]: value,\n }));\n };\n\n return (\n <div className=\"lockerverse-launcher__donation-option\">\n {unavailableLabel ? <p>{unavailableLabel}</p> : null}\n <fieldset className=\"lockerverse-launcher__donation-choices\">\n <legend className=\"lockerverse-launcher__sr-only\">\n {product.name} amount\n </legend>\n <button\n aria-pressed={amount === \"\"}\n onClick={() => setAmount(\"\")}\n type=\"button\"\n >\n No thanks\n </button>\n {suggestions.map((suggestion) => (\n <button\n aria-pressed={amountCents === suggestion}\n disabled={maximum < 1}\n key={suggestion}\n onClick={() => setAmount(String(suggestion / 100))}\n type=\"button\"\n >\n {usd.format(suggestion / 100).replace(\".00\", \"\")}\n </button>\n ))}\n <label\n className=\"lockerverse-launcher__donation-other\"\n data-selected={amount !== \"\" && !isSuggestedAmount ? true : undefined}\n >\n <input\n aria-label={`${product.name} amount`}\n disabled={maximum < 1 && amount === \"\"}\n min={getLockerverseMinimumCustomAmountCents(product) / 100}\n name={`amount-${product.slug}`}\n onChange={(event) => setAmount(event.target.value)}\n placeholder=\"Other $\"\n step=\"0.01\"\n type=\"number\"\n value={isSuggestedAmount ? \"\" : amount}\n />\n </label>\n </fieldset>\n </div>\n );\n}\n\ntype LauncherProductListProps = Omit<\n LauncherProductControlProps,\n \"maximum\" | \"product\" | \"unavailableLabel\"\n> & {\n catalog: LockerverseCatalog;\n selectedQuantities: Record<string, number>;\n products: LockerverseProduct[];\n variant?: LauncherProductOptionProps[\"variant\"];\n};\n\nfunction LauncherProductList({\n catalog,\n selectedQuantities,\n products,\n variant = \"default\",\n ...controlProps\n}: LauncherProductListProps) {\n return (\n <div className=\"lockerverse-launcher__product-list\">\n {products.map((product) => {\n const maximum = getLauncherMaximumQuantity(\n catalog,\n product,\n product.paymentOption === \"one-time\" ? selectedQuantities : {}\n );\n const minimum = product.minimumQuantity ?? 1;\n let unavailableLabel: string | undefined;\n if (getLauncherMaximumQuantity(catalog, product) < minimum) {\n unavailableLabel = \"Sold out\";\n } else if (maximum < minimum) {\n unavailableLabel = \"Limit reached\";\n }\n return variant === \"donation\" ? (\n <LauncherDonationOption\n {...controlProps}\n key={product.id}\n maximum={maximum}\n product={product}\n unavailableLabel={unavailableLabel}\n />\n ) : (\n <LauncherProductOption\n {...controlProps}\n key={product.id}\n maximum={maximum}\n product={product}\n unavailableLabel={unavailableLabel}\n variant={variant}\n />\n );\n })}\n </div>\n );\n}\n\nfunction getSelectionSummary(\n catalog: LockerverseCatalog,\n selection: LockerversePaymentSelectionItem[]\n) {\n let itemCount = 0;\n let amountCents = 0;\n for (const item of selection) {\n const product = catalog.products.find(\n (candidate) => candidate.slug === item.productSlug\n );\n if (!product) {\n continue;\n }\n if (\"quantity\" in item) {\n itemCount += item.quantity;\n amountCents += (product.amountCents ?? 0) * item.quantity;\n continue;\n }\n itemCount += 1;\n amountCents +=\n \"amountCents\" in item ? item.amountCents : (product.amountCents ?? 0);\n }\n const shipping = catalog.widget.requiredShipping;\n const triggerQuantity = shipping\n ? selection.reduce((total, item) => {\n const product = catalog.products.find(\n (candidate) => candidate.slug === item.productSlug\n );\n if (!(product && shipping.triggerProductIds.includes(product.id))) {\n return total;\n }\n return total + (\"quantity\" in item ? item.quantity : 1);\n }, 0)\n : 0;\n const needsShipping = triggerQuantity > 0;\n if (shipping && needsShipping) {\n amountCents +=\n (catalog.products.find((product) => product.id === shipping.productId)\n ?.amountCents ?? 0) +\n Math.max(0, triggerQuantity - 1) *\n (shipping.additionalUnitAmountCents ?? 0);\n }\n return { amountCents, itemCount, needsShipping };\n}\n\nfunction LauncherLoading() {\n return (\n <div\n aria-label=\"Loading donation options\"\n className=\"lockerverse-launcher__loading\"\n role=\"status\"\n >\n {[0, 1, 2].map((item) => (\n <span\n aria-hidden=\"true\"\n className=\"lockerverse-launcher__loading-row\"\n key={item}\n />\n ))}\n </div>\n );\n}\n\nfunction createLauncherSelection(\n catalog: LockerverseCatalog,\n quantities: Record<string, number>,\n customAmounts: Record<string, string>,\n recurringProductId: string | null\n): LockerversePaymentSelectionItem[] {\n if (recurringProductId) {\n const product = catalog.products.find(\n (candidate) =>\n candidate.id === recurringProductId &&\n candidate.paymentOption !== \"one-time\"\n );\n return product ? [{ productSlug: product.slug }] : [];\n }\n\n return catalog.products.flatMap(\n (product): LockerversePaymentSelectionItem[] => {\n const quantity = quantities[product.id] ?? 0;\n if (\n product.pricingMode === \"fixed\" &&\n product.paymentOption === \"one-time\" &&\n quantity > 0\n ) {\n return [{ productSlug: product.slug, quantity }];\n }\n const amountCents = parseAmountCents(customAmounts[product.id] ?? \"\");\n if (\n product.pricingMode === \"custom\" &&\n product.paymentOption === \"one-time\" &&\n amountCents !== null &&\n amountCents >= getLockerverseMinimumCustomAmountCents(product)\n ) {\n return [{ amountCents, productSlug: product.slug }];\n }\n return [];\n }\n );\n}\n\ntype LauncherSelectionStateProps = Omit<\n LauncherProductControlProps,\n \"maximum\" | \"product\" | \"unavailableLabel\"\n>;\n\ntype LauncherCatalogProps = LauncherSelectionStateProps & {\n catalog: LockerverseCatalog;\n onContinue: (selection: LockerversePaymentSelectionItem[]) => void;\n};\n\nfunction LauncherCatalog({\n catalog,\n onContinue,\n ...selectionState\n}: LauncherCatalogProps) {\n const draftSelection = createLauncherSelection(\n catalog,\n selectionState.quantities,\n selectionState.customAmounts,\n selectionState.recurringProductId\n );\n const selectedQuantities = getLauncherSelectedQuantities(\n catalog,\n draftSelection\n );\n const selectionAvailable = isLauncherSelectionAvailable(\n catalog,\n selectedQuantities\n );\n const summary = getSelectionSummary(catalog, draftSelection);\n const donationProducts = catalog.products.filter(\n (product) =>\n product.paymentOption === \"one-time\" && product.pricingMode === \"custom\"\n );\n const orderProducts = catalog.products.filter(\n (product) =>\n !donationProducts.includes(product) &&\n product.id !== catalog.widget.requiredShipping?.productId\n );\n\n return (\n <form\n className=\"lockerverse-launcher__products\"\n onSubmit={(event) => {\n event.preventDefault();\n if (draftSelection.length > 0 && selectionAvailable) {\n onContinue(draftSelection);\n }\n }}\n >\n {orderProducts.length > 0 ? (\n <section className=\"lockerverse-launcher__section\">\n <LauncherProductList\n {...selectionState}\n catalog={catalog}\n products={orderProducts}\n selectedQuantities={selectedQuantities}\n />\n </section>\n ) : null}\n {donationProducts.length > 0 ? (\n <section className=\"lockerverse-launcher__donation\">\n <header className=\"lockerverse-launcher__section-header\">\n <h3>Add a donation</h3>\n </header>\n <LauncherProductList\n {...selectionState}\n catalog={catalog}\n products={donationProducts}\n selectedQuantities={selectedQuantities}\n variant=\"donation\"\n />\n </section>\n ) : null}\n {orderProducts.length + donationProducts.length > 0 ? (\n <footer className=\"lockerverse-launcher__footer\">\n <p aria-live=\"polite\" className=\"lockerverse-launcher__summary\">\n <span>\n {summary.itemCount === 0\n ? \"No items selected\"\n : `${summary.itemCount} ${summary.itemCount === 1 ? \"item\" : \"items\"} selected`}\n </span>\n {summary.itemCount === 0 ? null : (\n <strong>{usd.format(summary.amountCents / 100)}</strong>\n )}\n </p>\n {summary.needsShipping ? (\n <p>Shipping is included once per order.</p>\n ) : null}\n {selectionAvailable ? null : (\n <p>\n Some selected items are no longer available. Reduce their quantity\n to continue.\n </p>\n )}\n <button\n className=\"lockerverse-launcher__continue\"\n disabled={draftSelection.length === 0 || !selectionAvailable}\n type=\"submit\"\n >\n Continue\n </button>\n </footer>\n ) : (\n <p>No products are available for this link.</p>\n )}\n </form>\n );\n}\n\ntype LauncherPaymentProps = Omit<\n LockerversePaymentProps,\n \"selection\" | \"widget\"\n>;\n\ntype LauncherCheckoutProps = {\n presentation: \"dialog\" | \"page\";\n onEdit: () => void;\n paymentProps: LauncherPaymentProps;\n selection: LockerversePaymentSelectionItem[];\n style: LockerversePaymentStyle;\n widget: UseLockerverseWidgetResult;\n};\n\nfunction LauncherCheckout({\n presentation,\n onEdit,\n paymentProps,\n selection,\n style,\n widget,\n}: LauncherCheckoutProps) {\n return (\n <div className=\"lockerverse-launcher__checkout\">\n <header className=\"lockerverse-launcher__checkout-toolbar\">\n <button\n className=\"lockerverse-launcher__back\"\n onClick={onEdit}\n type=\"button\"\n >\n Edit order\n </button>\n </header>\n <LockerversePayment\n {...paymentProps}\n className={presentation === \"page\" ? undefined : paymentProps.className}\n paymentSummaryPosition={paymentProps.paymentSummaryPosition ?? \"bottom\"}\n selection={selection}\n style={style}\n widget={widget}\n />\n </div>\n );\n}\n\nfunction LauncherDialogHeading({\n catalog,\n checkout,\n presentation = \"dialog\",\n showDescription = true,\n}: {\n presentation?: \"dialog\" | \"page\";\n showDescription?: boolean;\n catalog: LockerverseCatalog | null;\n checkout: boolean;\n}) {\n const Title = presentation === \"page\" ? \"h1\" : Dialog.Title;\n const Description = presentation === \"page\" ? \"p\" : Dialog.Description;\n if (checkout && presentation === \"dialog\") {\n return (\n <>\n <Title className=\"lockerverse-launcher__sr-only\">Checkout</Title>\n <Description className=\"lockerverse-launcher__sr-only\">\n Review the order and complete payment.\n </Description>\n </>\n );\n }\n\n if (!catalog) {\n return (\n <header className=\"lockerverse-launcher__header\">\n <Title className=\"lockerverse-launcher__title\">Donate</Title>\n <Description\n className=\"lockerverse-launcher__description\"\n hidden={!showDescription}\n >\n Choose your options, then continue to checkout.\n </Description>\n </header>\n );\n }\n\n return (\n <header className=\"lockerverse-launcher__header\">\n {catalog.community ? (\n <div className=\"lockerverse-launcher__brand\">\n {catalog.community.imageUrl ? (\n <img\n alt={`${catalog.community.name} logo`}\n height=\"28\"\n src={catalog.community.imageUrl}\n width=\"28\"\n />\n ) : null}\n <span>{catalog.community.name}</span>\n </div>\n ) : null}\n <Title className=\"lockerverse-launcher__title\">\n {catalog.widget.title ?? catalog.widget.name}\n </Title>\n <Description\n className=\"lockerverse-launcher__description\"\n hidden={!showDescription}\n >\n {catalog.widget.description ??\n \"Choose your options, then continue to checkout.\"}\n </Description>\n </header>\n );\n}\n\nfunction hasPageLoadingFallback(\n presentation: \"dialog\" | \"page\",\n loading: boolean,\n fallback: ReactNode\n) {\n return presentation === \"page\" && loading && fallback !== undefined;\n}\n\nconst TICKET_COLOR = /^#([\\da-f]{3}|[\\da-f]{6})$/i;\n\nfunction getTicketPaper(\n color: string | undefined,\n showBranding: boolean | undefined\n) {\n const normalized = normalizeAccentColor(color ?? \"\");\n return showBranding && TICKET_COLOR.test(normalized)\n ? `color-mix(in srgb, ${normalized} 18%, #f5f3ee)`\n : \"#f5f3ee\";\n}\n\nexport function LockerverseDonateLauncher({\n buttonLabel = \"Donate\",\n position = \"inline\",\n presentation = \"dialog\",\n loadingFallback,\n initialSelection = [],\n productIds,\n showDescription = true,\n widget,\n ...paymentProps\n}: LockerverseDonateLauncherProps) {\n const [selection, setSelection] = useState<\n LockerversePaymentSelectionItem[] | null\n >(null);\n const [customAmounts, setCustomAmounts] = useState<Record<string, string>>(\n {}\n );\n const [quantities, setQuantities] = useState<Record<string, number>>({});\n const [recurringProductId, setRecurringProductId] = useState<string | null>(\n null\n );\n const [linkConfiguration] = useState(() => ({\n initialSelection: initialSelection.map((item) => ({ ...item })),\n productIds: productIds ? [...productIds] : undefined,\n }));\n const [initialized, setInitialized] = useState(false);\n const { error, loading } = widget;\n const paymentCatalog = useMemo(\n () => launcherPaymentCatalog(widget.catalog, showDescription),\n [widget.catalog, showDescription]\n );\n const catalog = filterLauncherCatalog(\n widget.catalog,\n linkConfiguration.productIds\n );\n useEffect(() => {\n if (initialized || !widget.catalog) {\n return;\n }\n const initialCatalog = filterLauncherCatalog(\n widget.catalog,\n linkConfiguration.productIds\n );\n if (!initialCatalog) {\n return;\n }\n const choices = getInitialChoices(\n initialCatalog,\n linkConfiguration.initialSelection\n );\n setQuantities(choices.quantities);\n setCustomAmounts(choices.customAmounts);\n setRecurringProductId(choices.recurringProductId);\n setInitialized(true);\n }, [initialized, widget.catalog, linkConfiguration]);\n const accent = normalizeAccentColor(\n paymentProps.style?.[\"--lockerverse-accent\"] ??\n catalog?.community?.accentColor ??\n \"#38d77a\"\n );\n const accentContrast = getAccentContrast(accent);\n const launcherStyle: LockerversePaymentStyle & {\n \"--lockerverse-ticket-paper\": string;\n } = {\n ...paymentProps.style,\n \"--lockerverse-ticket-paper\": getTicketPaper(\n widget.catalog?.community?.accentColor,\n widget.catalog?.widget.showCommunityBranding\n ),\n };\n if (\n paymentProps.style?.[\"--lockerverse-accent\"] !== undefined ||\n catalog?.community?.accentColor\n ) {\n launcherStyle[\"--lockerverse-accent\"] = accent;\n }\n if (\n accentContrast &&\n paymentProps.style?.[\"--lockerverse-accent-contrast\"] === undefined\n ) {\n launcherStyle[\"--lockerverse-accent-contrast\"] = accentContrast;\n }\n\n const optionsLoading = loading || !(initialized || error);\n let content: ReactNode;\n if (optionsLoading) {\n content = <LauncherLoading />;\n } else if (error) {\n content = (\n <div role=\"alert\">\n <p>Unable to load donation options.</p>\n <button onClick={widget.refresh} type=\"button\">\n Retry\n </button>\n </div>\n );\n } else if (catalog) {\n content = (\n <LauncherCatalog\n catalog={catalog}\n customAmounts={customAmounts}\n onContinue={setSelection}\n quantities={quantities}\n recurringProductId={recurringProductId}\n setCustomAmounts={setCustomAmounts}\n setQuantities={setQuantities}\n setRecurringProductId={setRecurringProductId}\n />\n );\n } else {\n content = <LauncherLoading />;\n }\n if (!(loading || error) && selection && catalog) {\n content = (\n <LauncherCheckout\n onEdit={() => setSelection(null)}\n paymentProps={paymentProps}\n presentation={presentation}\n selection={selection}\n style={launcherStyle}\n widget={{ ...widget, catalog: paymentCatalog }}\n />\n );\n }\n\n if (hasPageLoadingFallback(presentation, optionsLoading, loadingFallback)) {\n return loadingFallback;\n }\n if (presentation === \"page\") {\n return (\n <section\n className={`lockerverse-launcher__dialog lockerverse-launcher__page ${paymentProps.className ?? \"\"}`}\n data-lockerverse-theme={paymentProps.theme ?? \"dark\"}\n style={launcherStyle}\n >\n <LauncherDialogHeading\n catalog={catalog}\n checkout={selection !== null}\n presentation=\"page\"\n showDescription={showDescription}\n />\n {content}\n </section>\n );\n }\n\n return (\n <Dialog.Root\n onOpenChange={(open) => {\n if (open && catalog && paymentProps.stripeLoader === undefined) {\n requestAnimationFrame(() => {\n preloadLockerversePayment(catalog);\n });\n }\n }}\n >\n <Dialog.Trigger\n className={`lockerverse-launcher lockerverse-launcher--${position}`}\n data-lockerverse-theme={paymentProps.theme ?? \"dark\"}\n style={launcherStyle}\n >\n {buttonLabel}\n </Dialog.Trigger>\n <Dialog.Portal>\n <Dialog.Backdrop className=\"lockerverse-launcher__backdrop\" />\n <Dialog.Viewport className=\"lockerverse-launcher__viewport\">\n <Dialog.Popup\n className=\"lockerverse-launcher__dialog\"\n data-lockerverse-theme={paymentProps.theme ?? \"dark\"}\n style={launcherStyle}\n >\n <LauncherDialogHeading\n catalog={catalog}\n checkout={selection !== null}\n showDescription={showDescription}\n />\n <Dialog.Close\n aria-label=\"Close donation dialog\"\n className=\"lockerverse-launcher__close\"\n >\n <span aria-hidden=\"true\">×</span>\n </Dialog.Close>\n {content}\n </Dialog.Popup>\n </Dialog.Viewport>\n </Dialog.Portal>\n </Dialog.Root>\n );\n}\n"],"mappings":"4WAOA,SAAgB,EACd,EACA,EACA,EAAqC,CAAC,EACtC,CACA,IAAM,EAAU,EAAQ,aAAa,SAAS,KAC3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