@beamimpact/web-sdk 1.42.1 → 1.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/_share-dialog-dependencies-rnsPzR3i.esm.js +2 -0
- package/dist/chunks/_share-dialog-dependencies-rnsPzR3i.esm.js.map +1 -0
- package/dist/chunks/_share-dialog-dependencies-wDg8oxHJ.esm.js +2 -0
- package/dist/chunks/_share-dialog-dependencies-wDg8oxHJ.esm.js.map +1 -0
- package/dist/chunks/{cart-contents-sUhfwLAz.esm.d.ts → cart-contents-WB1BF6hG.esm.d.ts} +1 -1
- package/dist/chunks/{events-QJc86_5Y.esm.d.ts → events-MfRTtTVm.esm.d.ts} +1 -1
- package/dist/chunks/{index-qjhWIDcT.esm.js → index-0nQiFQrd.esm.js} +2 -2
- package/dist/chunks/{index-qjhWIDcT.esm.js.map → index-0nQiFQrd.esm.js.map} +1 -1
- package/dist/chunks/index-1Z7n574A.esm.js +2 -0
- package/dist/chunks/index-1Z7n574A.esm.js.map +1 -0
- package/dist/chunks/index-4HR3T_6I.esm.js +2 -0
- package/dist/chunks/index-4HR3T_6I.esm.js.map +1 -0
- package/dist/chunks/{index-giTGb0gn.esm.js → index-AaWfjJG7.esm.js} +2 -2
- package/dist/chunks/{index-giTGb0gn.esm.js.map → index-AaWfjJG7.esm.js.map} +1 -1
- package/dist/chunks/{index-M-0eAFA6.esm.d.ts → index-B9w02q6y.esm.d.ts} +1 -1
- package/dist/chunks/{index-_Hgu38MH.esm.d.ts → index-OaRsZJh7.esm.d.ts} +1 -1
- package/dist/chunks/{index-euJMrXIc.esm.d.ts → index-UggwPn9Q.esm.d.ts} +1 -1
- package/dist/chunks/index-ZN8EcPhA.esm.js +2 -0
- package/dist/chunks/index-ZN8EcPhA.esm.js.map +1 -0
- package/dist/chunks/index-evgmVzj9.esm.js +2 -0
- package/dist/chunks/index-evgmVzj9.esm.js.map +1 -0
- package/dist/chunks/index-m0mhJhiY.esm.js +2 -0
- package/dist/chunks/index-m0mhJhiY.esm.js.map +1 -0
- package/dist/chunks/index-ndhJISxP.esm.js +2 -0
- package/dist/chunks/index-ndhJISxP.esm.js.map +1 -0
- package/dist/chunks/{index-ZgCs6F4e.esm.d.ts → index-ozcDdIom.esm.d.ts} +4 -4
- package/dist/chunks/{index-VHXu2kRx.esm.d.ts → index-uqNCQVUx.esm.d.ts} +1 -1
- package/dist/chunks/{index-_UuYsIe9.esm.d.ts → index-yeW2w5bb.esm.d.ts} +1 -1
- package/dist/chunks/{openapi-spec--WoGcZgR.esm.d.ts → openapi-spec-GGEBbqAJ.esm.d.ts} +892 -27
- package/dist/chunks/order-page-A2VpvPTA.esm.js +2 -0
- package/dist/chunks/order-page-A2VpvPTA.esm.js.map +1 -0
- package/dist/chunks/{order-page-Ps8Qyjfg.esm.d.ts → order-page-LvE0Otsn.esm.d.ts} +3 -3
- package/dist/chunks/order-page-n_PrxspK.esm.js +2 -0
- package/dist/chunks/order-page-n_PrxspK.esm.js.map +1 -0
- package/dist/chunks/{routes-zzEfDMIn.esm.js → routes-2U31lJuH.esm.js} +2 -2
- package/dist/chunks/{routes-zzEfDMIn.esm.js.map → routes-2U31lJuH.esm.js.map} +1 -1
- package/dist/chunks/{routes-sc6xljWU.esm.js → routes-nWhY4Rgg.esm.js} +2 -2
- package/dist/chunks/{routes-sc6xljWU.esm.js.map → routes-nWhY4Rgg.esm.js.map} +1 -1
- package/dist/chunks/{routes-qbvie7oI.esm.d.ts → routes-wCCYf_uA.esm.d.ts} +31 -0
- package/dist/chunks/{share-button-AUvXGlky.esm.js → share-button--FOuz6Ka.esm.js} +2 -2
- package/dist/chunks/{share-button-AUvXGlky.esm.js.map → share-button--FOuz6Ka.esm.js.map} +1 -1
- package/dist/chunks/{share-button-wmGQW923.esm.js → share-button-t0XcS-C-.esm.js} +2 -2
- package/dist/chunks/{share-button-wmGQW923.esm.js.map → share-button-t0XcS-C-.esm.js.map} +1 -1
- package/dist/chunks/{shoelace-components-29N4dEDv.esm.js → shoelace-components-DDO9begn.esm.js} +2 -2
- package/dist/chunks/{shoelace-components-29N4dEDv.esm.js.map → shoelace-components-DDO9begn.esm.js.map} +1 -1
- package/dist/chunks/{shoelace-components-YboJNgEe.esm.js → shoelace-components-qmUjB2xP.esm.js} +2 -2
- package/dist/chunks/{shoelace-components-YboJNgEe.esm.js.map → shoelace-components-qmUjB2xP.esm.js.map} +1 -1
- package/dist/chunks/{update-cart-_5yw3Tg7.esm.js → update-cart-4A6AXGhP.esm.js} +2 -2
- package/dist/chunks/{update-cart-_5yw3Tg7.esm.js.map → update-cart-4A6AXGhP.esm.js.map} +1 -1
- package/dist/chunks/{update-cart-yfZE8kwS.esm.js → update-cart-oxNW7D6U.esm.js} +2 -2
- package/dist/chunks/{update-cart-yfZE8kwS.esm.js.map → update-cart-oxNW7D6U.esm.js.map} +1 -1
- package/dist/chunks/{update-cart-SajqAoez.esm.d.ts → update-cart-tjLR7pMx.esm.d.ts} +1 -1
- package/dist/components/community-impact.esm.js +1 -1
- package/dist/components/community-impact.js +1 -1
- package/dist/components/cumulative-impact.esm.js +1 -1
- package/dist/components/cumulative-impact.js +1 -1
- package/dist/components/impact-overview.d.ts +15 -0
- package/dist/components/impact-overview.esm.js +7 -7
- package/dist/components/impact-overview.esm.js.map +1 -1
- package/dist/components/impact-overview.js +7 -7
- package/dist/components/impact-overview.js.map +1 -1
- package/dist/components/index.d.ts +3 -3
- package/dist/components/index.esm.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/post-purchase.d.ts +10 -2
- package/dist/components/post-purchase.esm.js +2 -1
- package/dist/components/post-purchase.esm.js.map +1 -1
- package/dist/components/post-purchase.js +2 -1
- package/dist/components/post-purchase.js.map +1 -1
- package/dist/components/product-details-page.d.ts +3 -0
- package/dist/components/product-details-page.esm.js +1 -1
- package/dist/components/product-details-page.js +1 -1
- package/dist/components/redeem-transaction.d.ts +2 -2
- package/dist/components/redeem-transaction.esm.js +1 -1
- package/dist/components/redeem-transaction.js +1 -1
- package/dist/components/select-nonprofit.d.ts +2 -2
- package/dist/components/select-nonprofit.esm.js +1 -1
- package/dist/components/select-nonprofit.js +1 -1
- package/dist/components/select-subscription-nonprofit.esm.js +1 -1
- package/dist/components/select-subscription-nonprofit.js +1 -1
- package/dist/components/shopify.d.ts +6 -6
- package/dist/components/shopify.esm.js +1 -1
- package/dist/components/shopify.js +1 -1
- package/dist/components/social-share.d.ts +1 -0
- package/dist/components/social-share.esm.js +2 -2
- package/dist/components/social-share.esm.js.map +1 -1
- package/dist/components/social-share.js +2 -2
- package/dist/components/social-share.js.map +1 -1
- package/dist/components/subscription-impact.d.ts +14 -0
- package/dist/components/subscription-impact.esm.js +1 -1
- package/dist/components/subscription-impact.js +1 -1
- package/dist/components/subscription-management.d.ts +25 -3
- package/dist/components/subscription-management.esm.js +1 -1
- package/dist/components/subscription-management.js +1 -1
- package/dist/index.d.ts +12 -12
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/integrations/beam.esm.js +1 -1
- package/dist/integrations/beam.js +1 -1
- package/dist/integrations/cart.d.ts +3 -3
- package/dist/integrations/cart.esm.js +1 -1
- package/dist/integrations/cart.js +1 -1
- package/dist/integrations/index.d.ts +10 -10
- package/dist/integrations/index.esm.js +1 -1
- package/dist/integrations/index.js +1 -1
- package/dist/integrations/logs.d.ts +2 -2
- package/dist/integrations/logs.esm.js +1 -1
- package/dist/integrations/logs.js +1 -1
- package/dist/integrations/shopify.d.ts +5 -5
- package/dist/integrations/shopify.esm.js +1 -1
- package/dist/integrations/shopify.js +1 -1
- package/dist/integrations/statsig.esm.js +1 -1
- package/dist/integrations/statsig.js +1 -1
- package/dist/integrations/utils.d.ts +3 -3
- package/dist/react/community-impact.esm.js +1 -1
- package/dist/react/community-impact.js +1 -1
- package/dist/react/cumulative-impact.esm.js +1 -1
- package/dist/react/cumulative-impact.js +1 -1
- package/dist/react/impact-overview.esm.js +1 -1
- package/dist/react/impact-overview.js +1 -1
- package/dist/react/index.d.ts +4 -4
- package/dist/react/index.esm.js +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/post-purchase.d.ts +2 -2
- package/dist/react/post-purchase.esm.js +1 -1
- package/dist/react/post-purchase.js +1 -1
- package/dist/react/product-details-page.esm.js +1 -1
- package/dist/react/product-details-page.js +1 -1
- package/dist/react/redeem-transaction.d.ts +3 -3
- package/dist/react/redeem-transaction.esm.js +1 -1
- package/dist/react/redeem-transaction.js +1 -1
- package/dist/react/select-nonprofit.d.ts +3 -3
- package/dist/react/select-nonprofit.esm.js +1 -1
- package/dist/react/select-nonprofit.js +1 -1
- package/dist/react/select-subscription-nonprofit.d.ts +3 -3
- package/dist/react/select-subscription-nonprofit.esm.js +1 -1
- package/dist/react/select-subscription-nonprofit.js +1 -1
- package/dist/react/social-share.esm.js +1 -1
- package/dist/react/social-share.js +1 -1
- package/dist/react/subscription-impact.esm.js +1 -1
- package/dist/react/subscription-impact.js +1 -1
- package/dist/react/subscription-management.d.ts +3 -3
- package/dist/react/subscription-management.esm.js +1 -1
- package/dist/react/subscription-management.js +1 -1
- package/dist/utils/events.d.ts +3 -3
- package/dist/utils/index.d.ts +3 -3
- package/package.json +1 -1
- package/dist/chunks/_share-dialog-dependencies-KpCcT5X6.esm.js +0 -2
- package/dist/chunks/_share-dialog-dependencies-KpCcT5X6.esm.js.map +0 -1
- package/dist/chunks/_share-dialog-dependencies-vHG7OoOA.esm.js +0 -2
- package/dist/chunks/_share-dialog-dependencies-vHG7OoOA.esm.js.map +0 -1
- package/dist/chunks/index--iA4GcfC.esm.js +0 -2
- package/dist/chunks/index--iA4GcfC.esm.js.map +0 -1
- package/dist/chunks/index-F1U8ROKG.esm.js +0 -2
- package/dist/chunks/index-F1U8ROKG.esm.js.map +0 -1
- package/dist/chunks/index-LF_9YLx7.esm.js +0 -2
- package/dist/chunks/index-LF_9YLx7.esm.js.map +0 -1
- package/dist/chunks/index-MSOdvudi.esm.js +0 -2
- package/dist/chunks/index-MSOdvudi.esm.js.map +0 -1
- package/dist/chunks/index-QeW-IaK9.esm.js +0 -2
- package/dist/chunks/index-QeW-IaK9.esm.js.map +0 -1
- package/dist/chunks/index-e--9y-Sl.esm.js +0 -2
- package/dist/chunks/index-e--9y-Sl.esm.js.map +0 -1
- package/dist/chunks/order-page-HoZ7DC0L.esm.js +0 -2
- package/dist/chunks/order-page-HoZ7DC0L.esm.js.map +0 -1
- package/dist/chunks/order-page-m5hkOPEQ.esm.js +0 -2
- package/dist/chunks/order-page-m5hkOPEQ.esm.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"post-purchase.esm.js","sources":["../../src/components/post-purchase/index.ts"],"sourcesContent":["import { html, LitElement, PropertyValues } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\nimport { state } from \"lit/decorators/state.js\";\nimport { MissingConfig } from \"../../utils/beam-errors\";\nimport { deleteCookieValue, getCookieValue } from \"../../utils/cookies\";\nimport { cssReset } from \"../../shared/css-reset\";\nimport { defineCustomElement } from \"../../shared/defineCustomElement\";\nimport { createScopedLocalStorage } from \"../../utils/local-storage\";\nimport { AsyncController } from \"../../shared/controllers/async-controller\";\nimport { _errorMessage } from \"../../shared/fragments/error-message-template\";\nimport { enforceConfig } from \"../../shared/enforce-config\";\nimport { LANGUAGES } from \"../../api-sdk/types\";\nimport { DEFAULT_BASE_URL } from \"../../api-sdk/constants\";\nimport { postTransaction } from \"../../api-sdk/v3/routes\";\nimport \"../redeem-transaction\";\nimport \"../impact-overview\";\nimport { BEAM_CART_COOKIE_NAME, TBeamCartLocalStorage, TCart } from \"../../shared/cart-contents\";\nimport { BeamNonprofitSelectEvent, BeamOrderCreatedEvent } from \"../../utils/events\";\n\nconst REQUIRED_DATA_PROPS = [\"baseUrl\", \"apiKey\", \"orderId\", \"cartTotal\", \"currencyCode\", \"lang\"];\nconst OPTIONAL_DATA_PROPS = [\"storeId\", \"postalCode\", \"countryCode\", \"cart\", \"discountCodes\", \"email\", \"partnerUserId\"];\n\nexport class BeamPostPurchase extends LitElement {\n static tagName = \"beam-post-purchase\";\n\n @property({ type: String })\n public baseUrl: string = DEFAULT_BASE_URL;\n\n @property({ type: String })\n public apiKey!: string;\n\n @property({ type: Number, reflect: true })\n public storeId?: number; // Either storeId or postalCode, countryCode must be provided\n\n @property({ type: String })\n public postalCode?: string;\n\n @property({ type: String })\n public countryCode?: string;\n\n @property({ type: String })\n public orderId!: string;\n\n /**\n * Either email or partnerUserId is required\n */\n @property({ type: String })\n public email?: string;\n\n /**\n * Either email or partnerUserId is required\n */\n @property({ type: String })\n public partnerUserId?: string;\n\n @property({ type: Number })\n public cartTotal!: number;\n\n @property({ type: String })\n public currencyCode = \"USD\";\n\n @property({ type: String })\n public lang: LANGUAGES = \"en\";\n\n @property({ type: Object })\n public cart?: TCart;\n\n @property({ type: Array })\n public discountCodes?: string[];\n\n @property({ type: String })\n public domain?: string;\n\n @property({ type: Boolean })\n public debug = false;\n\n @state() private activeWidget: \"redeem-transaction\" | \"impact-overview\" | null = null; // wait for postTransaction\n @state() private nonprofitId: number | null = null; // from localStorage or redeem-transaction result\n @state() private selectionId: string | null = null; // from localStorage\n @state() private cartId: string | null = null; // from localStorage, external cart ID\n @state() private beamCartId: string | null = null; // from cookie, Beam cart ID\n @state() private userId: string | null = null; // from postTransaction\n @state() private transactionId: string | null = null; // from postTransaction\n\n private localStorage = createScopedLocalStorage(this);\n\n firstUpdated(_changedProperties: PropertyValues) {\n this.enforceConfig();\n this.nonprofitId = Number(this.localStorage.getItem(\"nonprofit\")) || null;\n this.selectionId = this.localStorage.getItem(\"transaction\") || null;\n this.cartId = this.localStorage.getItemJson<TBeamCartLocalStorage>(\"cart\")?.cartId || null;\n // Reading beamCartId from cookies instead of localStorage allows it to work across subdomains\n this.beamCartId = getCookieValue(BEAM_CART_COOKIE_NAME) || null;\n\n if (this.selectionId && this.nonprofitId) {\n this.activeWidget = \"impact-overview\";\n }\n }\n\n async updated(previousPropertyValues: PropertyValues) {\n // Also fires on first load as props go from undefined => value\n const refreshOnChangeProps = [...REQUIRED_DATA_PROPS, ...OPTIONAL_DATA_PROPS];\n if (refreshOnChangeProps.some((p) => previousPropertyValues.has(p))) {\n await this.transactionDataController.exec();\n }\n }\n\n enforceConfig() {\n enforceConfig(REQUIRED_DATA_PROPS, this);\n\n if (!this.email && !this.partnerUserId) {\n throw new MissingConfig(\n [this.email ? \"\" : \"email\", this.partnerUserId ? \"\" : \"partnerUserId\"].filter(Boolean),\n \"At least one of [email, partnerUserId] must be provided\"\n );\n }\n }\n\n handlePostTransaction = async () => {\n this.enforceConfig();\n const result = await postTransaction({\n baseUrl: this.baseUrl,\n headers: {\n authorization: `Api-Key ${this.apiKey}`,\n },\n requestBody: {\n nonprofitId: this.nonprofitId || undefined,\n selectionId: this.selectionId || undefined,\n cartId: this.cartId || undefined,\n beamCartId: this.beamCartId || undefined,\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n storeId: this.storeId,\n orderId: this.orderId,\n cartTotal: this.cartTotal,\n email: this.email, // One or both of email & partnerUserId should be defined\n partnerUserId: this.partnerUserId, // One or both of email & partnerUserId should be defined\n currencyCode: this.currencyCode,\n postalCode: this.postalCode,\n countryCode: this.countryCode,\n cart: this.cart,\n discountCodes: this.discountCodes,\n },\n });\n\n this.transactionId = result.transactionId;\n this.userId = result.beamUserId;\n this.nonprofitId = result.nonprofitId;\n\n this.activeWidget = this.nonprofitId ? \"impact-overview\" : \"redeem-transaction\";\n\n this.localStorage.removeItem(\"transaction\");\n this.localStorage.removeItem(\"cart\");\n deleteCookieValue({ name: BEAM_CART_COOKIE_NAME, path: \"/\", domain: this.domain });\n\n // Emit order created event only when order is registered with Beam for the first time\n if (result.transactionCreated) {\n dispatchEvent(\n new BeamOrderCreatedEvent({\n transactionId: result.transactionId,\n orderId: this.orderId,\n cartTotal: this.cartTotal,\n currencyCode: this.currencyCode,\n })\n );\n }\n return result;\n };\n\n private transactionDataController = new AsyncController<typeof this.handlePostTransaction>(\n this,\n this.handlePostTransaction\n );\n\n render() {\n if (this.transactionDataController.loading) {\n return \"\";\n }\n if (this.transactionDataController.error) {\n if (this.debug) {\n return _errorMessage({ error: this.transactionDataController.error });\n }\n return \"\";\n }\n if (this.activeWidget === \"redeem-transaction\") {\n return html`\n <beam-redeem-transaction\n part=\"redeem-transaction\"\n baseUrl=\"${this.baseUrl}\"\n apiKey=\"${this.apiKey}\"\n storeId=\"${this.storeId}\"\n postalCode=\"${this.postalCode}\"\n countryCode=\"${this.countryCode}\"\n transactionId=\"${this.transactionId}\"\n cart=\"${JSON.stringify(this.cart)}\"\n lang=\"${this.lang}\"\n ?debug=\"${this.debug}\"\n @beamnonprofitselect=\"${(event: Event) => {\n if (!(event instanceof CustomEvent)) return; // TS guard\n const { selectedNonprofitId } = (event as BeamNonprofitSelectEvent).detail;\n this.nonprofitId = selectedNonprofitId ?? null;\n this.activeWidget = \"impact-overview\";\n }}\"\n ></beam-redeem-transaction>\n `;\n }\n if (this.activeWidget === \"impact-overview\") {\n return html`\n <beam-impact-overview\n part=\"impact-overview\"\n storeId=\"${this.storeId}\"\n baseUrl=\"${this.baseUrl}\"\n apiKey=\"${this.apiKey}\"\n userId=\"${this.userId}\"\n nonprofitId=\"${this.nonprofitId}\"\n lang=\"${this.lang}\"\n discountCodes=\"${JSON.stringify(this.discountCodes)}\"\n ?debug=\"${this.debug}\"\n ></beam-impact-overview>\n `;\n }\n return \"\";\n }\n\n static styles = [cssReset];\n}\n\ndefineCustomElement(BeamPostPurchase);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"beam-post-purchase\": BeamPostPurchase;\n }\n}\n"],"names":["REQUIRED_DATA_PROPS","OPTIONAL_DATA_PROPS","BeamPostPurchase","LitElement","DEFAULT_BASE_URL","createScopedLocalStorage","result","postTransaction","deleteCookieValue","BEAM_CART_COOKIE_NAME","BeamOrderCreatedEvent","AsyncController","_changedProperties","getCookieValue","previousPropertyValues","p","enforceConfig","MissingConfig","_errorMessage","html","event","selectedNonprof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CAAE,KAAM,MAAO,CAAC,CAAA,EAjCftB,EAkCJ,UAAA,YAAA,CAAA,EAGAqB,EAAA,CADNC,EAAS,CAAE,KAAM,MAAO,CAAC,CApCf,EAAAtB,EAqCJ,UAGAqB,eAAAA,CAAAA,EAAAA,EAAA,CADNC,EAAS,CAAE,KAAM,MAAO,CAAC,CAvCf,EAAAtB,EAwCJ,oBAGAqB,EAAA,CADNC,EAAS,CAAE,KAAM,MAAO,CAAC,CA1Cf,EAAAtB,EA2CJ,oBAGAqB,EAAA,CADNC,EAAS,CAAE,KAAM,KAAM,CAAC,CA7Cd,EAAAtB,EA8CJ,6BAGAqB,EAAA,CADNC,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EAhDftB,EAiDJ,UAAA,SAAA,CAAA,EAGAqB,EAAA,CADNC,EAAS,CAAE,KAAM,OAAQ,CAAC,CAAA,EAnDhBtB,EAoDJ,UAEUqB,QAAAA,CAAAA,EAAAA,EAAA,CAAhBE,EAAAA,CAtDU,EAAAvB,EAsDM,4BACAqB,EAAA,CAAhBE,GAvDU,EAAAvB,EAuDM,2BACAqB,EAAA,CAAhBE,EAAM,CAAA,EAxDIvB,EAwDM,UAAA,cAAA,CAAA,EACAqB,EAAA,CAAhBE,EAAAA,GAzDUvB,EAyDM,UAAA,SAAA,CAAA,EACAqB,EAAA,CAAhBE,EA1DU,CAAA,EAAAvB,EA0DM,UACAqB,aAAAA,CAAAA,EAAAA,EAAA,CAAhBE,EAAM,CAAA,EA3DIvB,EA2DM,UAAA,SAAA,CAAA,EACAqB,EAAA,CAAhBE,EA5DU,CAAA,EAAAvB,EA4DM,UAgJnBwB,gBAAAA,CAAAA,EAAAA,EAAoBxB,CAAgB"}
|
|
1
|
+
{"version":3,"file":"post-purchase.esm.js","sources":["../../src/components/post-purchase/index.ts"],"sourcesContent":["import { html, LitElement, PropertyValues } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\nimport { state } from \"lit/decorators/state.js\";\nimport { MissingConfig } from \"../../utils/beam-errors\";\nimport { deleteCookieValue, getCookieValue } from \"../../utils/cookies\";\nimport { cssReset } from \"../../shared/css-reset\";\nimport { defineCustomElement } from \"../../shared/defineCustomElement\";\nimport { createScopedLocalStorage } from \"../../utils/local-storage\";\nimport { AsyncController } from \"../../shared/controllers/async-controller\";\nimport { _errorMessage } from \"../../shared/fragments/error-message-template\";\nimport { enforceConfig } from \"../../shared/enforce-config\";\nimport { LANGUAGES } from \"../../api-sdk/types\";\nimport { DEFAULT_BASE_URL } from \"../../api-sdk/constants\";\nimport { postTransaction } from \"../../api-sdk/v3/routes\";\nimport \"../redeem-transaction\";\nimport \"../impact-overview\";\nimport { BEAM_CART_COOKIE_NAME, TBeamCartLocalStorage, TCart } from \"../../shared/cart-contents\";\nimport { BeamNonprofitSelectEvent, BeamOrderCreatedEvent } from \"../../utils/events\";\n\nconst REQUIRED_DATA_PROPS = [\"baseUrl\", \"apiKey\", \"orderId\", \"cartTotal\", \"currencyCode\", \"lang\"];\nconst OPTIONAL_DATA_PROPS = [\"storeId\", \"postalCode\", \"countryCode\", \"cart\", \"discountCodes\", \"email\", \"partnerUserId\"];\n\nexport class BeamPostPurchase extends LitElement {\n static tagName = \"beam-post-purchase\";\n\n @property({ type: String })\n public baseUrl: string = DEFAULT_BASE_URL;\n\n @property({ type: String })\n public apiKey!: string;\n\n @property({ type: Number, reflect: true })\n public storeId?: number; // Either storeId or postalCode, countryCode must be provided\n\n @property({ type: String })\n public postalCode?: string;\n\n @property({ type: String })\n public countryCode?: string;\n\n @property({ type: String })\n public orderId!: string;\n\n /**\n * Either email or partnerUserId is required\n */\n @property({ type: String })\n public email?: string;\n\n /**\n * Either email or partnerUserId is required\n */\n @property({ type: String })\n public partnerUserId?: string;\n\n @property({ type: Number })\n public cartTotal!: number;\n\n @property({ type: String })\n public currencyCode = \"USD\";\n\n @property({ type: String })\n public lang: LANGUAGES = \"en\";\n\n @property({ type: Object })\n public cart?: TCart;\n\n @property({ type: Array })\n public discountCodes?: string[];\n\n @property({ type: String })\n public domain?: string;\n\n @property({ type: Boolean })\n public debug = false;\n\n @state() private activeWidget: \"redeem-transaction\" | \"impact-overview\" | null = null; // wait for postTransaction\n @state() private nonprofitId: number | null = null; // from localStorage or redeem-transaction result\n @state() private selectionId: string | null = null; // from localStorage\n @state() private cartId: string | null = null; // from localStorage, external cart ID\n @state() private beamCartId: string | null = null; // from cookie, Beam cart ID\n @state() private userId: string | null = null; // from postTransaction\n @state() private transactionId: string | null = null; // from postTransaction\n\n private localStorage = createScopedLocalStorage(this);\n\n firstUpdated(_changedProperties: PropertyValues) {\n this.enforceConfig();\n this.nonprofitId = Number(this.localStorage.getItem(\"nonprofit\")) || null;\n this.selectionId = this.localStorage.getItem(\"transaction\") || null;\n this.cartId = this.localStorage.getItemJson<TBeamCartLocalStorage>(\"cart\")?.cartId || null;\n // Reading beamCartId from cookies instead of localStorage allows it to work across subdomains\n this.beamCartId = getCookieValue(BEAM_CART_COOKIE_NAME) || null;\n\n if (this.selectionId && this.nonprofitId) {\n this.activeWidget = \"impact-overview\";\n }\n }\n\n async updated(previousPropertyValues: PropertyValues) {\n // Also fires on first load as props go from undefined => value\n const refreshOnChangeProps = [...REQUIRED_DATA_PROPS, ...OPTIONAL_DATA_PROPS];\n if (refreshOnChangeProps.some((p) => previousPropertyValues.has(p))) {\n await this.transactionDataController.exec();\n }\n }\n\n enforceConfig() {\n enforceConfig(REQUIRED_DATA_PROPS, this);\n\n if (!this.email && !this.partnerUserId) {\n throw new MissingConfig(\n [this.email ? \"\" : \"email\", this.partnerUserId ? \"\" : \"partnerUserId\"].filter(Boolean),\n \"At least one of [email, partnerUserId] must be provided\"\n );\n }\n }\n\n handlePostTransaction = async () => {\n this.enforceConfig();\n const result = await postTransaction({\n baseUrl: this.baseUrl,\n headers: {\n authorization: `Api-Key ${this.apiKey}`,\n },\n requestBody: {\n nonprofitId: this.nonprofitId || undefined,\n selectionId: this.selectionId || undefined,\n cartId: this.cartId || undefined,\n beamCartId: this.beamCartId || undefined,\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n storeId: this.storeId,\n orderId: this.orderId,\n cartTotal: this.cartTotal,\n email: this.email, // One or both of email & partnerUserId should be defined\n partnerUserId: this.partnerUserId, // One or both of email & partnerUserId should be defined\n currencyCode: this.currencyCode,\n postalCode: this.postalCode,\n countryCode: this.countryCode,\n cart: this.cart,\n discountCodes: this.discountCodes,\n },\n });\n\n this.transactionId = result.transactionId;\n this.userId = result.beamUserId;\n this.nonprofitId = result.nonprofitId;\n\n this.activeWidget = this.nonprofitId ? \"impact-overview\" : \"redeem-transaction\";\n\n this.localStorage.removeItem(\"transaction\");\n this.localStorage.removeItem(\"cart\");\n deleteCookieValue({ name: BEAM_CART_COOKIE_NAME, path: \"/\", domain: this.domain });\n\n // Emit order created event only when order is registered with Beam for the first time\n if (result.transactionCreated) {\n dispatchEvent(\n new BeamOrderCreatedEvent({\n transactionId: result.transactionId,\n orderId: this.orderId,\n cartTotal: this.cartTotal,\n currencyCode: this.currencyCode,\n })\n );\n }\n return result;\n };\n\n private transactionDataController = new AsyncController<typeof this.handlePostTransaction>(\n this,\n this.handlePostTransaction\n );\n\n render() {\n if (this.transactionDataController.loading) {\n return \"\";\n }\n if (this.transactionDataController.error) {\n if (this.debug) {\n return _errorMessage({ error: this.transactionDataController.error });\n }\n return \"\";\n }\n if (this.activeWidget === \"redeem-transaction\") {\n return html`\n <beam-redeem-transaction\n part=\"redeem-transaction\"\n baseUrl=\"${this.baseUrl}\"\n apiKey=\"${this.apiKey}\"\n storeId=\"${this.storeId}\"\n postalCode=\"${this.postalCode}\"\n countryCode=\"${this.countryCode}\"\n transactionId=\"${this.transactionId}\"\n cart=\"${JSON.stringify(this.cart)}\"\n lang=\"${this.lang}\"\n ?debug=\"${this.debug}\"\n @beamnonprofitselect=\"${(event: Event) => {\n if (!(event instanceof CustomEvent)) return; // TS guard\n const { selectedNonprofitId } = (event as BeamNonprofitSelectEvent).detail;\n this.nonprofitId = selectedNonprofitId ?? null;\n this.activeWidget = \"impact-overview\";\n }}\"\n ></beam-redeem-transaction>\n `;\n }\n if (this.activeWidget === \"impact-overview\") {\n return html`\n <beam-impact-overview\n part=\"impact-overview\"\n storeId=\"${this.storeId}\"\n baseUrl=\"${this.baseUrl}\"\n apiKey=\"${this.apiKey}\"\n userId=\"${this.userId}\"\n nonprofitId=\"${this.nonprofitId}\"\n lang=\"${this.lang}\"\n discountCodes=\"${JSON.stringify(this.discountCodes)}\"\n transactionId=\"${this.transactionId}\"\n ?debug=\"${this.debug}\"\n ></beam-impact-overview>\n `;\n }\n return \"\";\n }\n\n static styles = [cssReset];\n}\n\ndefineCustomElement(BeamPostPurchase);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"beam-post-purchase\": BeamPostPurchase;\n }\n}\n"],"names":["REQUIRED_DATA_PROPS","OPTIONAL_DATA_PROPS","BeamPostPurchase","LitElement","DEFAULT_BASE_URL","createScopedLocalStorage","result","postTransaction","deleteCookieValue","BEAM_CART_COOKIE_NAME","BeamOrderCreatedEvent","AsyncController","_changedProperties","getCookieValue","previousPropertyValues","p","enforceConfig","MissingConfig","_errorMessage","html","event","selectedNonprofitId","cssReset","__decorateClass","property","state","defineCustomElement"],"mappings":"k9CAmBA,MAAMA,EAAsB,CAAC,UAAW,SAAU,UAAW,YAAa,eAAgB,MAAM,EAC1FC,EAAsB,CAAC,UAAW,aAAc,cAAe,OAAQ,gBAAiB,QAAS,eAAe,EAE/G,MAAMC,UAAyBC,CAAW,CAA1C,kCAIL,KAAO,QAAkBC,EAiCzB,KAAO,aAAe,MAGtB,KAAO,KAAkB,KAYzB,KAAO,MAAQ,GAEN,KAAQ,aAAgE,KACxE,KAAQ,YAA6B,KACrC,KAAQ,YAA6B,KACrC,KAAQ,OAAwB,KAChC,KAAQ,WAA4B,KACpC,KAAQ,OAAwB,KAChC,KAAQ,cAA+B,KAEhD,KAAQ,aAAeC,EAAyB,IAAI,EAkCpD,KAAwB,sBAAA,SAAY,CAClC,KAA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AqB,EAAA,CADNC,EAAS,CAAE,KAAM,OAAQ,CAAC,CAAA,EAnDhBtB,EAoDJ,UAEUqB,QAAAA,CAAAA,EAAAA,EAAA,CAAhBE,EAAAA,CAtDU,EAAAvB,EAsDM,4BACAqB,EAAA,CAAhBE,GAvDU,EAAAvB,EAuDM,2BACAqB,EAAA,CAAhBE,EAAM,CAAA,EAxDIvB,EAwDM,UAAA,cAAA,CAAA,EACAqB,EAAA,CAAhBE,EAAAA,GAzDUvB,EAyDM,UAAA,SAAA,CAAA,EACAqB,EAAA,CAAhBE,EA1DU,CAAA,EAAAvB,EA0DM,UACAqB,aAAAA,CAAAA,EAAAA,EAAA,CAAhBE,EAAM,CAAA,EA3DIvB,EA2DM,UAAA,SAAA,CAAA,EACAqB,EAAA,CAAhBE,EA5DU,CAAA,EAAAvB,EA4DM,UAiJnBwB,gBAAAA,CAAAA,EAAAA,EAAoBxB,CAAgB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{g as o,t as s,h as I,y as l}from"../chunks/lit-3QHn3fwl.esm.js";import{M as y}from"../chunks/beam-errors-P-Lu07Ce.esm.js";import{deleteCookieValue as u,getCookieValue as g}from"../utils/cookies.js";import{c as C,d as f,e as v}from"../chunks/enforce-config-er6B5Gkj.esm.js";import{createScopedLocalStorage as b}from"../utils/local-storage.js";import{A as S,_ as U}from"../chunks/localize-SsJbTmMj.esm.js";import{D as $,p as w}from"../chunks/routes-
|
|
1
|
+
import{g as o,t as s,h as I,y as l}from"../chunks/lit-3QHn3fwl.esm.js";import{M as y}from"../chunks/beam-errors-P-Lu07Ce.esm.js";import{deleteCookieValue as u,getCookieValue as g}from"../utils/cookies.js";import{c as C,d as f,e as v}from"../chunks/enforce-config-er6B5Gkj.esm.js";import{createScopedLocalStorage as b}from"../utils/local-storage.js";import{A as S,_ as U}from"../chunks/localize-SsJbTmMj.esm.js";import{D as $,p as w}from"../chunks/routes-nWhY4Rgg.esm.js";import"./redeem-transaction.js";import"./impact-overview.js";import{B as h}from"../chunks/cart-contents-h60geKWa.esm.js";import{a as T}from"../chunks/events-_4nImo3u.esm.js";import"../utils/logger.js";import"../chunks/lodash-P8OIs-at.esm.js";import"../chunks/progress-bar-HVG_n8_6.esm.js";import"../chunks/promo-pill-label-3Xtr5ALT.esm.js";import"../chunks/vendor--f7lkyBk.esm.js";import"./beam-partner-logos.js";import"../chunks/loading-template-mLjOGXMj.esm.js";import"../chunks/css-card-grid-r6wxRbPV.esm.js";import"../chunks/checkbox-P2JYPqxl.esm.js";import"../chunks/shoelace-components-DDO9begn.esm.js";import"../chunks/share-button-t0XcS-C-.esm.js";import"../chunks/is-all-html-elements-SdSkxirh.esm.js";import"../chunks/share-button-CqTd80g8.esm.js";import"../chunks/responsive-KbDsZM6S.esm.js";var A=Object.defineProperty,D=Object.getOwnPropertyDescriptor,e=(d,r,i,n)=>{for(var a=n>1?void 0:n?D(r,i):r,p=d.length-1,c;p>=0;p--)(c=d[p])&&(a=(n?c(r,i,a):c(a))||a);return n&&a&&A(r,i,a),a};const m=["baseUrl","apiKey","orderId","cartTotal","currencyCode","lang"],E=["storeId","postalCode","countryCode","cart","discountCodes","email","partnerUserId"];class t extends I{constructor(){super(...arguments),this.baseUrl=$,this.currencyCode="USD",this.lang="en",this.debug=!1,this.activeWidget=null,this.nonprofitId=null,this.selectionId=null,this.cartId=null,this.beamCartId=null,this.userId=null,this.transactionId=null,this.localStorage=b(this),this.handlePostTransaction=async()=>{this.enforceConfig();const r=await w({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},requestBody:{nonprofitId:this.nonprofitId||void 0,selectionId:this.selectionId||void 0,cartId:this.cartId||void 0,beamCartId:this.beamCartId||void 0,storeId:this.storeId,orderId:this.orderId,cartTotal:this.cartTotal,email:this.email,partnerUserId:this.partnerUserId,currencyCode:this.currencyCode,postalCode:this.postalCode,countryCode:this.countryCode,cart:this.cart,discountCodes:this.discountCodes}});return this.transactionId=r.transactionId,this.userId=r.beamUserId,this.nonprofitId=r.nonprofitId,this.activeWidget=this.nonprofitId?"impact-overview":"redeem-transaction",this.localStorage.removeItem("transaction"),this.localStorage.removeItem("cart"),u({name:h,path:"/",domain:this.domain}),r.transactionCreated&&dispatchEvent(new T({transactionId:r.transactionId,orderId:this.orderId,cartTotal:this.cartTotal,currencyCode:this.currencyCode})),r},this.transactionDataController=new S(this,this.handlePostTransaction)}firstUpdated(r){this.enforceConfig(),this.nonprofitId=Number(this.localStorage.getItem("nonprofit"))||null,this.selectionId=this.localStorage.getItem("transaction")||null,this.cartId=this.localStorage.getItemJson("cart")?.cartId||null,this.beamCartId=g(h)||null,this.selectionId&&this.nonprofitId&&(this.activeWidget="impact-overview")}async updated(r){[...m,...E].some(i=>r.has(i))&&await this.transactionDataController.exec()}enforceConfig(){if(v(m,this),!this.email&&!this.partnerUserId)throw new y([this.email?"":"email",this.partnerUserId?"":"partnerUserId"].filter(Boolean),"At least one of [email, partnerUserId] must be provided")}render(){return this.transactionDataController.loading?"":this.transactionDataController.error?this.debug?U({error:this.transactionDataController.error}):"":this.activeWidget==="redeem-transaction"?l`
|
|
2
2
|
<beam-redeem-transaction
|
|
3
3
|
part="redeem-transaction"
|
|
4
4
|
baseUrl="${this.baseUrl}"
|
|
@@ -22,6 +22,7 @@ import{g as o,t as s,h as I,y as l}from"../chunks/lit-3QHn3fwl.esm.js";import{M
|
|
|
22
22
|
nonprofitId="${this.nonprofitId}"
|
|
23
23
|
lang="${this.lang}"
|
|
24
24
|
discountCodes="${JSON.stringify(this.discountCodes)}"
|
|
25
|
+
transactionId="${this.transactionId}"
|
|
25
26
|
?debug="${this.debug}"
|
|
26
27
|
></beam-impact-overview>
|
|
27
28
|
`:""}}t.tagName="beam-post-purchase",t.styles=[C],e([o({type:String})],t.prototype,"baseUrl",2),e([o({type:String})],t.prototype,"apiKey",2),e([o({type:Number,reflect:!0})],t.prototype,"storeId",2),e([o({type:String})],t.prototype,"postalCode",2),e([o({type:String})],t.prototype,"countryCode",2),e([o({type:String})],t.prototype,"orderId",2),e([o({type:String})],t.prototype,"email",2),e([o({type:String})],t.prototype,"partnerUserId",2),e([o({type:Number})],t.prototype,"cartTotal",2),e([o({type:String})],t.prototype,"currencyCode",2),e([o({type:String})],t.prototype,"lang",2),e([o({type:Object})],t.prototype,"cart",2),e([o({type:Array})],t.prototype,"discountCodes",2),e([o({type:String})],t.prototype,"domain",2),e([o({type:Boolean})],t.prototype,"debug",2),e([s()],t.prototype,"activeWidget",2),e([s()],t.prototype,"nonprofitId",2),e([s()],t.prototype,"selectionId",2),e([s()],t.prototype,"cartId",2),e([s()],t.prototype,"beamCartId",2),e([s()],t.prototype,"userId",2),e([s()],t.prototype,"transactionId",2),f(t);export{t as BeamPostPurchase};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"post-purchase.js","sources":["../../src/components/post-purchase/index.ts"],"sourcesContent":["import { html, LitElement, PropertyValues } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\nimport { state } from \"lit/decorators/state.js\";\nimport { MissingConfig } from \"../../utils/beam-errors\";\nimport { deleteCookieValue, getCookieValue } from \"../../utils/cookies\";\nimport { cssReset } from \"../../shared/css-reset\";\nimport { defineCustomElement } from \"../../shared/defineCustomElement\";\nimport { createScopedLocalStorage } from \"../../utils/local-storage\";\nimport { AsyncController } from \"../../shared/controllers/async-controller\";\nimport { _errorMessage } from \"../../shared/fragments/error-message-template\";\nimport { enforceConfig } from \"../../shared/enforce-config\";\nimport { LANGUAGES } from \"../../api-sdk/types\";\nimport { DEFAULT_BASE_URL } from \"../../api-sdk/constants\";\nimport { postTransaction } from \"../../api-sdk/v3/routes\";\nimport \"../redeem-transaction\";\nimport \"../impact-overview\";\nimport { BEAM_CART_COOKIE_NAME, TBeamCartLocalStorage, TCart } from \"../../shared/cart-contents\";\nimport { BeamNonprofitSelectEvent, BeamOrderCreatedEvent } from \"../../utils/events\";\n\nconst REQUIRED_DATA_PROPS = [\"baseUrl\", \"apiKey\", \"orderId\", \"cartTotal\", \"currencyCode\", \"lang\"];\nconst OPTIONAL_DATA_PROPS = [\"storeId\", \"postalCode\", \"countryCode\", \"cart\", \"discountCodes\", \"email\", \"partnerUserId\"];\n\nexport class BeamPostPurchase extends LitElement {\n static tagName = \"beam-post-purchase\";\n\n @property({ type: String })\n public baseUrl: string = DEFAULT_BASE_URL;\n\n @property({ type: String })\n public apiKey!: string;\n\n @property({ type: Number, reflect: true })\n public storeId?: number; // Either storeId or postalCode, countryCode must be provided\n\n @property({ type: String })\n public postalCode?: string;\n\n @property({ type: String })\n public countryCode?: string;\n\n @property({ type: String })\n public orderId!: string;\n\n /**\n * Either email or partnerUserId is required\n */\n @property({ type: String })\n public email?: string;\n\n /**\n * Either email or partnerUserId is required\n */\n @property({ type: String })\n public partnerUserId?: string;\n\n @property({ type: Number })\n public cartTotal!: number;\n\n @property({ type: String })\n public currencyCode = \"USD\";\n\n @property({ type: String })\n public lang: LANGUAGES = \"en\";\n\n @property({ type: Object })\n public cart?: TCart;\n\n @property({ type: Array })\n public discountCodes?: string[];\n\n @property({ type: String })\n public domain?: string;\n\n @property({ type: Boolean })\n public debug = false;\n\n @state() private activeWidget: \"redeem-transaction\" | \"impact-overview\" | null = null; // wait for postTransaction\n @state() private nonprofitId: number | null = null; // from localStorage or redeem-transaction result\n @state() private selectionId: string | null = null; // from localStorage\n @state() private cartId: string | null = null; // from localStorage, external cart ID\n @state() private beamCartId: string | null = null; // from cookie, Beam cart ID\n @state() private userId: string | null = null; // from postTransaction\n @state() private transactionId: string | null = null; // from postTransaction\n\n private localStorage = createScopedLocalStorage(this);\n\n firstUpdated(_changedProperties: PropertyValues) {\n this.enforceConfig();\n this.nonprofitId = Number(this.localStorage.getItem(\"nonprofit\")) || null;\n this.selectionId = this.localStorage.getItem(\"transaction\") || null;\n this.cartId = this.localStorage.getItemJson<TBeamCartLocalStorage>(\"cart\")?.cartId || null;\n // Reading beamCartId from cookies instead of localStorage allows it to work across subdomains\n this.beamCartId = getCookieValue(BEAM_CART_COOKIE_NAME) || null;\n\n if (this.selectionId && this.nonprofitId) {\n this.activeWidget = \"impact-overview\";\n }\n }\n\n async updated(previousPropertyValues: PropertyValues) {\n // Also fires on first load as props go from undefined => value\n const refreshOnChangeProps = [...REQUIRED_DATA_PROPS, ...OPTIONAL_DATA_PROPS];\n if (refreshOnChangeProps.some((p) => previousPropertyValues.has(p))) {\n await this.transactionDataController.exec();\n }\n }\n\n enforceConfig() {\n enforceConfig(REQUIRED_DATA_PROPS, this);\n\n if (!this.email && !this.partnerUserId) {\n throw new MissingConfig(\n [this.email ? \"\" : \"email\", this.partnerUserId ? \"\" : \"partnerUserId\"].filter(Boolean),\n \"At least one of [email, partnerUserId] must be provided\"\n );\n }\n }\n\n handlePostTransaction = async () => {\n this.enforceConfig();\n const result = await postTransaction({\n baseUrl: this.baseUrl,\n headers: {\n authorization: `Api-Key ${this.apiKey}`,\n },\n requestBody: {\n nonprofitId: this.nonprofitId || undefined,\n selectionId: this.selectionId || undefined,\n cartId: this.cartId || undefined,\n beamCartId: this.beamCartId || undefined,\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n storeId: this.storeId,\n orderId: this.orderId,\n cartTotal: this.cartTotal,\n email: this.email, // One or both of email & partnerUserId should be defined\n partnerUserId: this.partnerUserId, // One or both of email & partnerUserId should be defined\n currencyCode: this.currencyCode,\n postalCode: this.postalCode,\n countryCode: this.countryCode,\n cart: this.cart,\n discountCodes: this.discountCodes,\n },\n });\n\n this.transactionId = result.transactionId;\n this.userId = result.beamUserId;\n this.nonprofitId = result.nonprofitId;\n\n this.activeWidget = this.nonprofitId ? \"impact-overview\" : \"redeem-transaction\";\n\n this.localStorage.removeItem(\"transaction\");\n this.localStorage.removeItem(\"cart\");\n deleteCookieValue({ name: BEAM_CART_COOKIE_NAME, path: \"/\", domain: this.domain });\n\n // Emit order created event only when order is registered with Beam for the first time\n if (result.transactionCreated) {\n dispatchEvent(\n new BeamOrderCreatedEvent({\n transactionId: result.transactionId,\n orderId: this.orderId,\n cartTotal: this.cartTotal,\n currencyCode: this.currencyCode,\n })\n );\n }\n return result;\n };\n\n private transactionDataController = new AsyncController<typeof this.handlePostTransaction>(\n this,\n this.handlePostTransaction\n );\n\n render() {\n if (this.transactionDataController.loading) {\n return \"\";\n }\n if (this.transactionDataController.error) {\n if (this.debug) {\n return _errorMessage({ error: this.transactionDataController.error });\n }\n return \"\";\n }\n if (this.activeWidget === \"redeem-transaction\") {\n return html`\n <beam-redeem-transaction\n part=\"redeem-transaction\"\n baseUrl=\"${this.baseUrl}\"\n apiKey=\"${this.apiKey}\"\n storeId=\"${this.storeId}\"\n postalCode=\"${this.postalCode}\"\n countryCode=\"${this.countryCode}\"\n transactionId=\"${this.transactionId}\"\n cart=\"${JSON.stringify(this.cart)}\"\n lang=\"${this.lang}\"\n ?debug=\"${this.debug}\"\n @beamnonprofitselect=\"${(event: Event) => {\n if (!(event instanceof CustomEvent)) return; // TS guard\n const { selectedNonprofitId } = (event as BeamNonprofitSelectEvent).detail;\n this.nonprofitId = selectedNonprofitId ?? null;\n this.activeWidget = \"impact-overview\";\n }}\"\n ></beam-redeem-transaction>\n `;\n }\n if (this.activeWidget === \"impact-overview\") {\n return html`\n <beam-impact-overview\n part=\"impact-overview\"\n storeId=\"${this.storeId}\"\n baseUrl=\"${this.baseUrl}\"\n apiKey=\"${this.apiKey}\"\n userId=\"${this.userId}\"\n nonprofitId=\"${this.nonprofitId}\"\n lang=\"${this.lang}\"\n discountCodes=\"${JSON.stringify(this.discountCodes)}\"\n ?debug=\"${this.debug}\"\n ></beam-impact-overview>\n `;\n }\n return \"\";\n }\n\n static styles = [cssReset];\n}\n\ndefineCustomElement(BeamPostPurchase);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"beam-post-purchase\": BeamPostPurchase;\n }\n}\n"],"names":["REQUIRED_DATA_PROPS","OPTIONAL_DATA_PROPS","BeamPostPurchase","LitElement","DEFAULT_BASE_URL","createScopedLocalStorage","result","postTransaction","deleteCookieValue","BEAM_CART_COOKIE_NAME","BeamOrderCreatedEvent","AsyncController","_changedProperties","getCookieValue","previousPropertyValues","p","enforceConfig","MissingConfig","_errorMessage","html","event","selectedNonprofitId","cssReset","__decorateClass","property","state","defineCustomElement"],"mappings":"07CAmBA,MAAMA,EAAsB,CAAC,UAAW,SAAU,UAAW,YAAa,eAAgB,MAAM,EAC1FC,EAAsB,CAAC,UAAW,aAAc,cAAe,OAAQ,gBAAiB,QAAS,eAAe,EAE/G,MAAMC,UAAyBC,CAAW,CAA1C,kCAIL,KAAO,QAAkBC,EAiCzB,KAAO,aAAe,MAGtB,KAAO,KAAkB,KAYzB,KAAO,MAAQ,GAEN,KAAQ,aAAgE,KACxE,KAAQ,YAA6B,KACrC,KAAQ,YAA6B,KACrC,KAAQ,OAAwB,KAChC,KAAQ,WAA4B,KACpC,KAAQ,OAAwB,KAChC,KAAQ,cAA+B,KAEhD,KAAQ,aAAeC,EAAyB,IAAI,EAkCpD,KAAwB,sBAAA,SAAY,CAClC,KAAK,gBACL,MAAMC,EAAS,MAAMC,EAAgB,CACnC,QAAS,KAAK,QACd,QAAS,CACP,cAAe,WAAW,KAAK,MAAM,EACvC,EACA,YAAa,CACX,YAAa,KAAK,aAAe,OACjC,YAAa,KAAK,aAAe,OACjC,OAAQ,KAAK,QAAU,OACvB,WAAY,KAAK,YAAc,OAE/B,QAAS,KAAK,QACd,QAAS,KAAK,QACd,UAAW,KAAK,UAChB,MAAO,KAAK,MACZ,cAAe,KAAK,cACpB,aAAc,KAAK,aACnB,WAAY,KAAK,WACjB,YAAa,KAAK,YAClB,KAAM,KAAK,KACX,cAAe,KAAK,aACtB,CACF,CAAC,EAED,OAAK,KAAA,cAAgBD,EAAO,cAC5B,KAAK,OAASA,EAAO,WACrB,KAAK,YAAcA,EAAO,YAE1B,KAAK,aAAe,KAAK,YAAc,kBAAoB,qBAE3D,KAAK,aAAa,WAAW,aAAa,EAC1C,KAAK,aAAa,WAAW,MAAM,EACnCE,EAAkB,CAAE,KA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esContent":["import { html, LitElement, PropertyValues } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\nimport { state } from \"lit/decorators/state.js\";\nimport { MissingConfig } from \"../../utils/beam-errors\";\nimport { deleteCookieValue, getCookieValue } from \"../../utils/cookies\";\nimport { cssReset } from \"../../shared/css-reset\";\nimport { defineCustomElement } from \"../../shared/defineCustomElement\";\nimport { createScopedLocalStorage } from \"../../utils/local-storage\";\nimport { AsyncController } from \"../../shared/controllers/async-controller\";\nimport { _errorMessage } from \"../../shared/fragments/error-message-template\";\nimport { enforceConfig } from \"../../shared/enforce-config\";\nimport { LANGUAGES } from \"../../api-sdk/types\";\nimport { DEFAULT_BASE_URL } from \"../../api-sdk/constants\";\nimport { postTransaction } from \"../../api-sdk/v3/routes\";\nimport \"../redeem-transaction\";\nimport \"../impact-overview\";\nimport { BEAM_CART_COOKIE_NAME, TBeamCartLocalStorage, TCart } from \"../../shared/cart-contents\";\nimport { BeamNonprofitSelectEvent, BeamOrderCreatedEvent } from \"../../utils/events\";\n\nconst REQUIRED_DATA_PROPS = [\"baseUrl\", \"apiKey\", \"orderId\", \"cartTotal\", \"currencyCode\", \"lang\"];\nconst OPTIONAL_DATA_PROPS = [\"storeId\", \"postalCode\", \"countryCode\", \"cart\", \"discountCodes\", \"email\", \"partnerUserId\"];\n\nexport class BeamPostPurchase extends LitElement {\n static tagName = \"beam-post-purchase\";\n\n @property({ type: String })\n public baseUrl: string = DEFAULT_BASE_URL;\n\n @property({ type: String })\n public apiKey!: string;\n\n @property({ type: Number, reflect: true })\n public storeId?: number; // Either storeId or postalCode, countryCode must be provided\n\n @property({ type: String })\n public postalCode?: string;\n\n @property({ type: String })\n public countryCode?: string;\n\n @property({ type: String })\n public orderId!: string;\n\n /**\n * Either email or partnerUserId is required\n */\n @property({ type: String })\n public email?: string;\n\n /**\n * Either email or partnerUserId is required\n */\n @property({ type: String })\n public partnerUserId?: string;\n\n @property({ type: Number })\n public cartTotal!: number;\n\n @property({ type: String })\n public currencyCode = \"USD\";\n\n @property({ type: String })\n public lang: LANGUAGES = \"en\";\n\n @property({ type: Object })\n public cart?: TCart;\n\n @property({ type: Array })\n public discountCodes?: string[];\n\n @property({ type: String })\n public domain?: string;\n\n @property({ type: Boolean })\n public debug = false;\n\n @state() private activeWidget: \"redeem-transaction\" | \"impact-overview\" | null = null; // wait for postTransaction\n @state() private nonprofitId: number | null = null; // from localStorage or redeem-transaction result\n @state() private selectionId: string | null = null; // from localStorage\n @state() private cartId: string | null = null; // from localStorage, external cart ID\n @state() private beamCartId: string | null = null; // from cookie, Beam cart ID\n @state() private userId: string | null = null; // from postTransaction\n @state() private transactionId: string | null = null; // from postTransaction\n\n private localStorage = createScopedLocalStorage(this);\n\n firstUpdated(_changedProperties: PropertyValues) {\n this.enforceConfig();\n this.nonprofitId = Number(this.localStorage.getItem(\"nonprofit\")) || null;\n this.selectionId = this.localStorage.getItem(\"transaction\") || null;\n this.cartId = this.localStorage.getItemJson<TBeamCartLocalStorage>(\"cart\")?.cartId || null;\n // Reading beamCartId from cookies instead of localStorage allows it to work across subdomains\n this.beamCartId = getCookieValue(BEAM_CART_COOKIE_NAME) || null;\n\n if (this.selectionId && this.nonprofitId) {\n this.activeWidget = \"impact-overview\";\n }\n }\n\n async updated(previousPropertyValues: PropertyValues) {\n // Also fires on first load as props go from undefined => value\n const refreshOnChangeProps = [...REQUIRED_DATA_PROPS, ...OPTIONAL_DATA_PROPS];\n if (refreshOnChangeProps.some((p) => previousPropertyValues.has(p))) {\n await this.transactionDataController.exec();\n }\n }\n\n enforceConfig() {\n enforceConfig(REQUIRED_DATA_PROPS, this);\n\n if (!this.email && !this.partnerUserId) {\n throw new MissingConfig(\n [this.email ? \"\" : \"email\", this.partnerUserId ? \"\" : \"partnerUserId\"].filter(Boolean),\n \"At least one of [email, partnerUserId] must be provided\"\n );\n }\n }\n\n handlePostTransaction = async () => {\n this.enforceConfig();\n const result = await postTransaction({\n baseUrl: this.baseUrl,\n headers: {\n authorization: `Api-Key ${this.apiKey}`,\n },\n requestBody: {\n nonprofitId: this.nonprofitId || undefined,\n selectionId: this.selectionId || undefined,\n cartId: this.cartId || undefined,\n beamCartId: this.beamCartId || undefined,\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n storeId: this.storeId,\n orderId: this.orderId,\n cartTotal: this.cartTotal,\n email: this.email, // One or both of email & partnerUserId should be defined\n partnerUserId: this.partnerUserId, // One or both of email & partnerUserId should be defined\n currencyCode: this.currencyCode,\n postalCode: this.postalCode,\n countryCode: this.countryCode,\n cart: this.cart,\n discountCodes: this.discountCodes,\n },\n });\n\n this.transactionId = result.transactionId;\n this.userId = result.beamUserId;\n this.nonprofitId = result.nonprofitId;\n\n this.activeWidget = this.nonprofitId ? \"impact-overview\" : \"redeem-transaction\";\n\n this.localStorage.removeItem(\"transaction\");\n this.localStorage.removeItem(\"cart\");\n deleteCookieValue({ name: BEAM_CART_COOKIE_NAME, path: \"/\", domain: this.domain });\n\n // Emit order created event only when order is registered with Beam for the first time\n if (result.transactionCreated) {\n dispatchEvent(\n new BeamOrderCreatedEvent({\n transactionId: result.transactionId,\n orderId: this.orderId,\n cartTotal: this.cartTotal,\n currencyCode: this.currencyCode,\n })\n );\n }\n return result;\n };\n\n private transactionDataController = new AsyncController<typeof this.handlePostTransaction>(\n this,\n this.handlePostTransaction\n );\n\n render() {\n if (this.transactionDataController.loading) {\n return \"\";\n }\n if (this.transactionDataController.error) {\n if (this.debug) {\n return _errorMessage({ error: this.transactionDataController.error });\n }\n return \"\";\n }\n if (this.activeWidget === \"redeem-transaction\") {\n return html`\n <beam-redeem-transaction\n part=\"redeem-transaction\"\n baseUrl=\"${this.baseUrl}\"\n apiKey=\"${this.apiKey}\"\n storeId=\"${this.storeId}\"\n postalCode=\"${this.postalCode}\"\n countryCode=\"${this.countryCode}\"\n transactionId=\"${this.transactionId}\"\n cart=\"${JSON.stringify(this.cart)}\"\n lang=\"${this.lang}\"\n ?debug=\"${this.debug}\"\n @beamnonprofitselect=\"${(event: Event) => {\n if (!(event instanceof CustomEvent)) return; // TS guard\n const { selectedNonprofitId } = (event as BeamNonprofitSelectEvent).detail;\n this.nonprofitId = selectedNonprofitId ?? null;\n this.activeWidget = \"impact-overview\";\n }}\"\n ></beam-redeem-transaction>\n `;\n }\n if (this.activeWidget === \"impact-overview\") {\n return html`\n <beam-impact-overview\n part=\"impact-overview\"\n storeId=\"${this.storeId}\"\n baseUrl=\"${this.baseUrl}\"\n apiKey=\"${this.apiKey}\"\n userId=\"${this.userId}\"\n nonprofitId=\"${this.nonprofitId}\"\n lang=\"${this.lang}\"\n discountCodes=\"${JSON.stringify(this.discountCodes)}\"\n transactionId=\"${this.transactionId}\"\n ?debug=\"${this.debug}\"\n ></beam-impact-overview>\n `;\n }\n return \"\";\n }\n\n static styles = [cssReset];\n}\n\ndefineCustomElement(BeamPostPurchase);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"beam-post-purchase\": BeamPostPurchase;\n }\n}\n"],"names":["REQUIRED_DATA_PROPS","OPTIONAL_DATA_PROPS","BeamPostPurchase","LitElement","DEFAULT_BASE_URL","createScopedLocalStorage","result","postTransaction","deleteCookieValue","BEAM_CART_COOKIE_NAME","BeamOrderCreatedEvent","AsyncController","_changedProperties","getCookieValue","previousPropertyValues","p","enforceConfig","MissingConfig","_errorMessage","html","event","selectedNonprofitId","cssReset","__decorateClass","property","state","defineCustomElement"],"mappings":"07CAmBA,MAAMA,EAAsB,CAAC,UAAW,SAAU,UAAW,YAAa,eAAgB,MAAM,EAC1FC,EAAsB,CAAC,UAAW,aAAc,cAAe,OAAQ,gBAAiB,QAAS,eAAe,EAE/G,MAAMC,UAAyBC,CAAW,CAA1C,kCAIL,KAAO,QAAkBC,EAiCzB,KAAO,aAAe,MAGtB,KAAO,KAAkB,KAYzB,KAAO,MAAQ,GAEN,KAAQ,aAAgE,KACxE,KAAQ,YAA6B,KACrC,KAAQ,YAA6B,KACrC,KAAQ,OAAwB,KAChC,KAAQ,WAA4B,KACpC,KA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,EA8CJ,6BAGAqB,EAAA,CADNC,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EAhDftB,EAiDJ,UAAA,SAAA,CAAA,EAGAqB,EAAA,CADNC,EAAS,CAAE,KAAM,OAAQ,CAAC,CAAA,EAnDhBtB,EAoDJ,UAEUqB,QAAAA,CAAAA,EAAAA,EAAA,CAAhBE,EAAAA,CAtDU,EAAAvB,EAsDM,4BACAqB,EAAA,CAAhBE,GAvDU,EAAAvB,EAuDM,2BACAqB,EAAA,CAAhBE,EAAM,CAAA,EAxDIvB,EAwDM,UAAA,cAAA,CAAA,EACAqB,EAAA,CAAhBE,EAAAA,GAzDUvB,EAyDM,UAAA,SAAA,CAAA,EACAqB,EAAA,CAAhBE,EA1DU,CAAA,EAAAvB,EA0DM,UACAqB,aAAAA,CAAAA,EAAAA,EAAA,CAAhBE,EAAM,CAAA,EA3DIvB,EA2DM,UAAA,SAAA,CAAA,EACAqB,EAAA,CAAhBE,EA5DU,CAAA,EAAAvB,EA4DM,UAiJnBwB,gBAAAA,CAAAA,EAAAA,EAAoBxB,CAAgB"}
|
|
@@ -22,6 +22,9 @@ declare class BeamProductDetailsPage extends LitElement {
|
|
|
22
22
|
description: string;
|
|
23
23
|
promoDescriptionPrefix?: string | undefined;
|
|
24
24
|
promoDescription?: string | undefined;
|
|
25
|
+
confirmButton?: string | undefined;
|
|
26
|
+
confirmedButton?: string | undefined;
|
|
27
|
+
collapsedButton?: string | undefined;
|
|
25
28
|
theme?: {
|
|
26
29
|
[key: string]: unknown;
|
|
27
30
|
} | null | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as P,y as s,f as b,g as d,h as m,m as h}from"../chunks/lit-3QHn3fwl.esm.js";import{u as g,A as D,_ as f,i as u,d as p,a as v}from"../chunks/localize-IRs8JglT.esm.js";import{D as y,k as x,W as k,S as w}from"../chunks/routes-
|
|
1
|
+
import{j as P,y as s,f as b,g as d,h as m,m as h}from"../chunks/lit-3QHn3fwl.esm.js";import{u as g,A as D,_ as f,i as u,d as p,a as v}from"../chunks/localize-IRs8JglT.esm.js";import{D as y,k as x,W as k,S as w}from"../chunks/routes-2U31lJuH.esm.js";import{makeApiKeyHeader as C}from"../utils/makeApiKeyHeader.esm.js";import{c as $,d as F,e as T}from"../chunks/enforce-config-HksNiOMu.esm.js";import{c as S}from"../chunks/responsive-KbDsZM6S.esm.js";import"../chunks/vendor--f7lkyBk.esm.js";import"../chunks/beam-errors-P-Lu07Ce.esm.js";import"../utils/logger.esm.js";const G=(r="",{borderRadius:e="0px",borderStyle:t="unset",borderColor:o="#000000",borderWidth:i="1px"}={})=>{const a=r.startsWith("--beam-")?r:`--beam-${r}`;return{[`${a}-borderRadius`]:e,[`${a}-borderStyle`]:t,[`${a}-borderColor`]:o,[`${a}-borderWidth`]:i}},I=(r="",{borderRadius:e="0px",borderStyle:t="unset",borderColor:o="#000000",borderWidth:i="1px"}={})=>{const a=r.startsWith("--beam-")?r:`--beam-${r}`;return P(` border-radius: var(${a}-borderRadius, ${e});
|
|
2
2
|
border-style: var(${a}-borderStyle, ${t});
|
|
3
3
|
border-color: var(${a}-borderColor, ${o});
|
|
4
4
|
border-width: var(${a}-borderWidth, ${i});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as P,y as s,f as b,g as d,h as m,m as h}from"../chunks/lit-3QHn3fwl.esm.js";import{u as g,A as D,_ as f,i as u,d as p,a as v}from"../chunks/localize-SsJbTmMj.esm.js";import{D as y,k as x,W as k,S as w}from"../chunks/routes-
|
|
1
|
+
import{j as P,y as s,f as b,g as d,h as m,m as h}from"../chunks/lit-3QHn3fwl.esm.js";import{u as g,A as D,_ as f,i as u,d as p,a as v}from"../chunks/localize-SsJbTmMj.esm.js";import{D as y,k as x,W as k,S as w}from"../chunks/routes-nWhY4Rgg.esm.js";import{makeApiKeyHeader as C}from"../utils/makeApiKeyHeader.js";import{c as $,d as F,e as T}from"../chunks/enforce-config-er6B5Gkj.esm.js";import{c as S}from"../chunks/responsive-KbDsZM6S.esm.js";import"../chunks/vendor--f7lkyBk.esm.js";import"../chunks/beam-errors-P-Lu07Ce.esm.js";import"../utils/logger.js";const G=(r="",{borderRadius:e="0px",borderStyle:t="unset",borderColor:o="#000000",borderWidth:i="1px"}={})=>{const a=r.startsWith("--beam-")?r:`--beam-${r}`;return{[`${a}-borderRadius`]:e,[`${a}-borderStyle`]:t,[`${a}-borderColor`]:o,[`${a}-borderWidth`]:i}},I=(r="",{borderRadius:e="0px",borderStyle:t="unset",borderColor:o="#000000",borderWidth:i="1px"}={})=>{const a=r.startsWith("--beam-")?r:`--beam-${r}`;return P(` border-radius: var(${a}-borderRadius, ${e});
|
|
2
2
|
border-style: var(${a}-borderStyle, ${t});
|
|
3
3
|
border-color: var(${a}-borderColor, ${o});
|
|
4
4
|
border-width: var(${a}-borderWidth, ${i});
|
|
@@ -6,9 +6,9 @@ import '../chunks/progress-bar-0VS_AmEf.esm.js';
|
|
|
6
6
|
import '../chunks/promo-pill-label-3bA1z-la.esm.js';
|
|
7
7
|
import './beam-partner-logos.js';
|
|
8
8
|
import { T as TNumericId, a as TId } from '../chunks/types-zbTZ8-KP.esm.js';
|
|
9
|
-
import { T as TCart } from '../chunks/cart-contents-
|
|
9
|
+
import { T as TCart } from '../chunks/cart-contents-WB1BF6hG.esm.js';
|
|
10
10
|
import { L as LANGUAGES } from '../chunks/types-aju0qrRe.esm.js';
|
|
11
|
-
import '../chunks/openapi-spec
|
|
11
|
+
import '../chunks/openapi-spec-GGEBbqAJ.esm.js';
|
|
12
12
|
|
|
13
13
|
interface TransactionRequiredConfig {
|
|
14
14
|
apiKey: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{f as I,g as l,t as x,h as N,y as s,q as v,u as P,k as D,m as U}from"../chunks/lit-3QHn3fwl.esm.js";import{d as z}from"../chunks/lodash-P8OIs-at.esm.js";import{u as h,A as k,d as f,a as M,_ as C,i as m}from"../chunks/localize-IRs8JglT.esm.js";import{D as L,f as E,W as B,h as W,u as A,S as F}from"../chunks/routes-zzEfDMIn.esm.js";import{p as K}from"../chunks/progress-bar-HVG_n8_6.esm.js";import{p as _}from"../chunks/promo-pill-label-3Xtr5ALT.esm.js";import{partnerLogosConfigDefaults as O}from"./beam-partner-logos.esm.js";import{c as j,d as V,a as q,e as y,b as w}from"../chunks/enforce-config-HksNiOMu.esm.js";import{_ as G}from"../chunks/loading-template-mLjOGXMj.esm.js";import{M as H,B as J}from"../chunks/beam-errors-P-Lu07Ce.esm.js";import{createScopedLocalStorage as Z}from"../utils/local-storage.esm.js";import{c as Q}from"../chunks/css-card-grid-r6wxRbPV.esm.js";import{_ as X}from"../chunks/checkbox-P2JYPqxl.esm.js";import{c as Y}from"../chunks/events-_4nImo3u.esm.js";import"../utils/logger.esm.js";import"../chunks/vendor--f7lkyBk.esm.js";const u={en:{beamAttribution:()=>"Powered by Beam",ctaTitle:()=>"Choose your impact",ctaPromoPrefixMessage:()=>"At no extra cost,",ctaPromoMessage:({donationPercentage:n="1"}={})=>`select a nonprofit and ${n}% of your purchase will be donated.`,ctaMessage:({donationPercentage:n="1%"}={})=>`Select a nonprofit and ${n} of your purchase will be donated, at no extra cost.`,submitButtonText:()=>"Confirm",submitButtonTextCompleted:()=>"Confirmed!",chooseButtonText:()=>"Choose"},fr:{beamAttribution:()=>"Optimis\xE9 par Beam",ctaTitle:()=>"Choisissez votre cause",ctaPromoPrefixMessage:()=>"",ctaPromoMessage:()=>"",ctaMessage:({donationPercentage:n="1%"}={})=>`Choisissez un organisme \xE0 but non lucratif et ${n}% lui sera vers\xE9 en votre nom, sans frais suppl\xE9mentaires.`,submitButtonText:()=>"Confirmer",submitButtonTextCompleted:()=>"Confirm\xE9!",chooseButtonText:()=>"Choisissez"},de:{beamAttribution:()=>"Unterst\xFCtzt von Beam",ctaTitle:()=>"W\xE4hle deinen Impact",ctaPromoPrefixMessage:()=>"",ctaPromoMessage:()=>"",ctaMessage:({donationPercentage:n="1%"}={})=>`W\xE4hle eine der gemeinn\xFCtzigen Organisationen und spende ${n} deines Einkaufs ohne zus\xE4tzliche Kosten`,submitButtonText:()=>"Best\xE4tigen",submitButtonTextCompleted:()=>"Best\xE4tigt!",chooseButtonText:()=>"W\xE4hlen"},es:{ctaTitle:()=>"Elige tu contribuci\xF3n",ctaPromoPrefixMessage:()=>"",ctaPromoMessage:()=>"",ctaMessage:({donationPercentage:n="1%"}={})=>`Elige una organizaci\xF3n sin fines de lucro y donaremos ${n} de tu compra sin coste adicional.`,beamAttribution:()=>"Ofrecido por Beam",submitButtonText:()=>"Confirmar",submitButtonTextCompleted:()=>"\xA1Confirmado!",chooseButtonText:()=>"Elige"},it:{ctaTitle:()=>"Scegli dove fare la differenza",ctaPromoPrefixMessage:()=>"",ctaPromoMessage:()=>"",ctaMessage:({donationPercentage:n="1%"}={})=>`Seleziona un'organizzazione no-profit a cui devolvere l\u2019${n} del tuo acquisto, senza costi aggiuntivi`,beamAttribution:()=>"Gestito da Beam",submitButtonText:()=>"Confermare",submitButtonTextCompleted:()=>"Confermato!",chooseButtonText:()=>"Scegli"},pl:{beamAttribution:()=>"Wspierany przez Beam",ctaTitle:()=>"Wybierz inicjatyw\u0119, kt\xF3r\u0105 chcesz wesprze\u0107",ctaPromoPrefixMessage:()=>"",ctaPromoMessage:()=>"",ctaMessage:({donationPercentage:n="1%"}={})=>`Wybierz organizacj\u0119, kt\xF3rej przeka\u017Cesz ${n} warto\u015Bci Twoich zakup\xF3w \u2013 bez \u017Cadnych dodatkowych koszt\xF3w!`,submitButtonText:()=>"Zatwierd\u017A",submitButtonTextCompleted:()=>"Zatwierdzono!",chooseButtonText:()=>"Wybierz"}};var ee=Object.defineProperty,te=Object.getOwnPropertyDescriptor,d=(n,e,t,o)=>{for(var i=o>1?void 0:o?te(e,t):e,p=n.length-1,c;p>=0;p--)(c=n[p])&&(i=(o?c(e,t,i):c(i))||i);return o&&i&&ee(e,t,i),i};class r extends N{constructor(){super(...arguments),this.baseUrl=L,this.lang="en",this.debug=!1,this.isMobile=window.innerWidth<768,this.didUserExpandNonprofits=!1,this.shouldUseNewPromoUI=!1,this.getChainNonprofits=async()=>{if(q(["transactionId","subscriptionId"],this),!this.hasCorrectTransactionConfig&&!this.hasCorrectSubscriptionConfig)throw new H;const e=await E({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},requestBody:{storeId:this.storeId,postalCode:this.postalCode,countryCode:this.countryCode,cart:this.cart??void 0,widgetName:B.redeem_transaction,version:"1.0.0",lang:this.configLang}});return e.store?.id&&e.store.id!==this.storeId&&(this.storeId=e.store.id),this.localStorage.setItemJson("chainNonprofits",{createdAt:new Date,data:e}),e},this.updateNonprofitIdForRecord=async({selectedNonprofitId:e})=>this.transactionId?this.putTransaction({selectedNonprofitId:e}):this.subscriptionId?this.putSubscription({selectedNonprofitId:e}):null,this.putTransaction=async({selectedNonprofitId:e})=>(y(["apiKey","transactionId"],this),W({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},pathParams:{transactionId:Number(this.transactionId)},requestBody:{nonprofitId:e}})),this.putSubscription=async({selectedNonprofitId:e})=>(y(["apiKey","subscriptionId"],this),A({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},requestBody:{remoteSubscriptionId:this.subscriptionId,nonprofitId:e}})),this.nonprofitListDataController=new k(this,this.getChainNonprofits),this.selectionDataController=new k(this,this.updateNonprofitIdForRecord),this.localStorage=Z(this),this.makeHandleSelect=(e,t,o)=>async i=>{if(!this.allowChange)return;const p=this.selectedNonprofitId;if(i instanceof KeyboardEvent){let c=null;switch(i.key){case"ArrowUp":case"ArrowLeft":t===0?c=o[o.length-1]:c=o[t-1],i.preventDefault();break;case"ArrowRight":case"ArrowDown":t===o.length-1?c=o[0]:c=o[t+1],i.preventDefault();break;case"Enter":case" ":i.preventDefault();break;default:return}if(c){const b=this.renderRoot.querySelector(`[data-value="${c.nonprofit.id}"]`);b!==null&&(b.tabIndex=0,b.focus());return}}if(i.currentTarget instanceof HTMLElement){if(p===e)return;this.selectedNonprofitId=e}},this.handleSubmit=async()=>{const{selectedNonprofitId:e}=this;if(!this.allowSubmit||e==null)return;await this.selectionDataController.exec({selectedNonprofitId:e}),this.shouldUseStoredSelection&&(this.localStorage.setItem("nonprofit",e),this.localStorage.setItem("nonprofit_selected_at",new Date().toISOString()));const t=this.nonprofitListDataController?.data?.nonprofits.find(o=>o.nonprofit.id===e);this.dispatchEvent(new Y({selectedNonprofitId:e,nonprofitName:t?.nonprofit.name,source:B.redeem_transaction}))},this.evaluateBreakPoints=z(()=>{this.isMobile=window.innerWidth<768},50,{maxWait:50,leading:!0})}get configLang(){return F[this.lang]||"en"}get hasCorrectTransactionConfig(){return w(["apiKey","transactionId"],this)}get hasCorrectSubscriptionConfig(){return w(["apiKey","subscriptionId"],this)}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.evaluateBreakPoints)}async firstUpdated(e){await this.restoreStateFromCache()}async updated(e){const t=["baseUrl","storeId","apiKey","countryCode","postalCode","lang"];for(const o of t)if(e.has(o)){await this.nonprofitListDataController.exec();break}}disconnectedCallback(){super.disconnectedCallback()}restoreStateFromCache(){y(["apiKey"],this),this.shouldUseStoredSelection&&(this.selectedNonprofitId=parseInt(this.localStorage.getItem("nonprofit")||"")||void 0);try{const{createdAt:e=0,data:t}=this.localStorage.getItemJson("chainNonprofits")||{},o=2*60*60*1e3;new Date(e).valueOf()+o>new Date().valueOf()&&(this.nonprofitListDataController.data=t,this.nonprofitListDataController.loading=!1)}catch{}}get allowChange(){return this.selectionDataController.data==null&&!this.selectionDataController.loading}get allowSubmit(){return!!(this.selectedNonprofitId&&this.allowChange)}get shouldUseStoredSelection(){return!this.subscriptionId}get cssVariables(){const e={"--beam-fontFamily":"inherit","--beam-fontStyle":"inherit","--beam-fontSize":"inherit","--beam-textColor":"inherit","--beam-backgroundColor":"inherit",...O,...K,"--beam-RedeemTransaction-maxWidth":"1000px","--beam-RedeemTransaction-submitButton-color":"#fff","--beam-RedeemTransaction-submitButton-hover-color":"#fff","--beam-RedeemTransaction-submitButton-disabled-color":"#fff","--beam-RedeemTransaction-submitButton-backgroundColor":"#333","--beam-RedeemTransaction-submitButton-hover-backgroundColor":"#222","--beam-RedeemTransaction-submitButton-disabled-backgroundColor":"#767676","--beam-RedeemTransaction-submitButton-borderColor":"#333","--beam-RedeemTransaction-submitButton-hover-borderColor":"#222","--beam-RedeemTransaction-submitButton-disabled-borderColor":"#767676","--beam-RedeemTransaction-submitButton-fontSize":"14px","--beam-RedeemTransaction-submitButton-fontWeight":"inherit","--beam-RedeemTransaction-submitButton-fontFamily":"inherit","--beam-RedeemTransaction-submitButton-textTransform":"none","--beam-RedeemTransaction-submitButton-borderRadius":"0px","--beam-RedeemTransaction-submitButton-padding":"15px 30px","--beam-RedeemTransaction-submitButton-position":"right","--beam-RedeemTransaction-submitButton-positionRight-width":"auto","--beam-RedeemTransaction-submitButton-positionBottom-width":"100%","--beam-RedeemTransaction-submitButton-positionBottom-marginTop":"10px","--beam-RedeemTransaction-checkmark-color":"transparent","--beam-RedeemTransaction-checkmark-selected-color":"#fff","--beam-RedeemTransaction-checkmark-hover-color":"#fff","--beam-RedeemTransaction-checkmark-backgroundColor":"transparent","--beam-RedeemTransaction-checkmark-selected-backgroundColor":"#333","--beam-RedeemTransaction-checkmark-hover-backgroundColor":"#d9d9d9","--beam-RedeemTransaction-checkmark-borderColor":"transparent","--beam-RedeemTransaction-checkmark-selected-borderColor":"#333","--beam-RedeemTransaction-checkmark-hover-borderColor":"#d9d9d9","--beam-RedeemTransaction-options-minWidth":"250px","--beam-RedeemTransaction-options-columnCount":"2","--beam-RedeemTransaction-options-borderRadius":"0px","--beam-RedeemTransaction-options-borderWidth":"1px","--beam-RedeemTransaction-options-selected-borderWidth":"2px","--beam-RedeemTransaction-options-focus-borderWidth":"1px","--beam-RedeemTransaction-options-image-borderRadius":"0px","--beam-RedeemTransaction-options-borderColor":"#d9d9d9","--beam-RedeemTransaction-options-selected-borderColor":"currentColor","--beam-RedeemTransaction-options-hover-borderColor":"#ccc","--beam-RedeemTransaction-options-backgroundColor":"transparent","--beam-RedeemTransaction-options-selected-backgroundColor":"transparent","--beam-RedeemTransaction-options-hover-backgroundColor":"#f1f1f1","--beam-RedeemTransaction-options-marginTop":"15px",...f("--beam-RedeemTransaction-title",{fontSize:"1.25em",fontWeight:"bold"}),...f("--beam-RedeemTransaction-description",{marginTop:"0.5em"}),...f("--beam-RedeemTransaction-details-cause",{fontSize:"1em",fontWeight:"bold"}),...f("--beam-RedeemTransaction-details-impactDescription",{fontSize:"0.85em",marginTop:"10px"}),"--beam-RedeemTransaction-details-nonprofitName-fontWeight":"bold","--beam-RedeemTransaction-details-nonprofitName-fontStyle":"inherit","--beam-RedeemTransaction-details-fundingProgress-marginTop":"10px",...f("--beam-RedeemTransaction-details-fundingProgressLabel",{fontSize:"0.85em"}),"--beam-RedeemTransaction-cardStyle":"'image'","--beam-RedeemTransaction-options-icon-padding":"0px","--beam-RedeemTransaction-options-collapseNonprofits-mobile":"false","--beam-RedeemTransaction-options-collapseNonprofits-desktop":"false",..._},t=this.nonprofitListDataController?.data?.config?.web?.theme||{},o={...e,...t};return Object.assign(Object.create({toCSS(){return M(this)}}),o)}handleChooseClick(){this.didUserExpandNonprofits=!0}get shouldCollapse(){const e=this.cssVariables["--beam-RedeemTransaction-options-collapseNonprofits-mobile"]==="true",t=this.cssVariables["--beam-RedeemTransaction-options-collapseNonprofits-desktop"]==="true";return this.isMobile&&e||!this.isMobile&&t}renderSubmitButton(e){return s`
|
|
1
|
+
import{f as I,g as l,t as x,h as N,y as s,q as v,u as P,k as D,m as U}from"../chunks/lit-3QHn3fwl.esm.js";import{d as z}from"../chunks/lodash-P8OIs-at.esm.js";import{u as h,A as k,d as f,a as M,_ as C,i as m}from"../chunks/localize-IRs8JglT.esm.js";import{D as L,f as E,W as B,h as W,u as A,S as F}from"../chunks/routes-2U31lJuH.esm.js";import{p as K}from"../chunks/progress-bar-HVG_n8_6.esm.js";import{p as _}from"../chunks/promo-pill-label-3Xtr5ALT.esm.js";import{partnerLogosConfigDefaults as O}from"./beam-partner-logos.esm.js";import{c as j,d as V,a as q,e as y,b as w}from"../chunks/enforce-config-HksNiOMu.esm.js";import{_ as G}from"../chunks/loading-template-mLjOGXMj.esm.js";import{M as H,B as J}from"../chunks/beam-errors-P-Lu07Ce.esm.js";import{createScopedLocalStorage as Z}from"../utils/local-storage.esm.js";import{c as Q}from"../chunks/css-card-grid-r6wxRbPV.esm.js";import{_ as X}from"../chunks/checkbox-P2JYPqxl.esm.js";import{c as Y}from"../chunks/events-_4nImo3u.esm.js";import"../utils/logger.esm.js";import"../chunks/vendor--f7lkyBk.esm.js";const u={en:{beamAttribution:()=>"Powered by Beam",ctaTitle:()=>"Choose your impact",ctaPromoPrefixMessage:()=>"At no extra cost,",ctaPromoMessage:({donationPercentage:n="1"}={})=>`select a nonprofit and ${n}% of your purchase will be donated.`,ctaMessage:({donationPercentage:n="1%"}={})=>`Select a nonprofit and ${n} of your purchase will be donated, at no extra cost.`,submitButtonText:()=>"Confirm",submitButtonTextCompleted:()=>"Confirmed!",chooseButtonText:()=>"Choose"},fr:{beamAttribution:()=>"Optimis\xE9 par Beam",ctaTitle:()=>"Choisissez votre cause",ctaPromoPrefixMessage:()=>"",ctaPromoMessage:()=>"",ctaMessage:({donationPercentage:n="1%"}={})=>`Choisissez un organisme \xE0 but non lucratif et ${n}% lui sera vers\xE9 en votre nom, sans frais suppl\xE9mentaires.`,submitButtonText:()=>"Confirmer",submitButtonTextCompleted:()=>"Confirm\xE9!",chooseButtonText:()=>"Choisissez"},de:{beamAttribution:()=>"Unterst\xFCtzt von Beam",ctaTitle:()=>"W\xE4hle deinen Impact",ctaPromoPrefixMessage:()=>"",ctaPromoMessage:()=>"",ctaMessage:({donationPercentage:n="1%"}={})=>`W\xE4hle eine der gemeinn\xFCtzigen Organisationen und spende ${n} deines Einkaufs ohne zus\xE4tzliche Kosten`,submitButtonText:()=>"Best\xE4tigen",submitButtonTextCompleted:()=>"Best\xE4tigt!",chooseButtonText:()=>"W\xE4hlen"},es:{ctaTitle:()=>"Elige tu contribuci\xF3n",ctaPromoPrefixMessage:()=>"",ctaPromoMessage:()=>"",ctaMessage:({donationPercentage:n="1%"}={})=>`Elige una organizaci\xF3n sin fines de lucro y donaremos ${n} de tu compra sin coste adicional.`,beamAttribution:()=>"Ofrecido por Beam",submitButtonText:()=>"Confirmar",submitButtonTextCompleted:()=>"\xA1Confirmado!",chooseButtonText:()=>"Elige"},it:{ctaTitle:()=>"Scegli dove fare la differenza",ctaPromoPrefixMessage:()=>"",ctaPromoMessage:()=>"",ctaMessage:({donationPercentage:n="1%"}={})=>`Seleziona un'organizzazione no-profit a cui devolvere l\u2019${n} del tuo acquisto, senza costi aggiuntivi`,beamAttribution:()=>"Gestito da Beam",submitButtonText:()=>"Confermare",submitButtonTextCompleted:()=>"Confermato!",chooseButtonText:()=>"Scegli"},pl:{beamAttribution:()=>"Wspierany przez Beam",ctaTitle:()=>"Wybierz inicjatyw\u0119, kt\xF3r\u0105 chcesz wesprze\u0107",ctaPromoPrefixMessage:()=>"",ctaPromoMessage:()=>"",ctaMessage:({donationPercentage:n="1%"}={})=>`Wybierz organizacj\u0119, kt\xF3rej przeka\u017Cesz ${n} warto\u015Bci Twoich zakup\xF3w \u2013 bez \u017Cadnych dodatkowych koszt\xF3w!`,submitButtonText:()=>"Zatwierd\u017A",submitButtonTextCompleted:()=>"Zatwierdzono!",chooseButtonText:()=>"Wybierz"}};var ee=Object.defineProperty,te=Object.getOwnPropertyDescriptor,d=(n,e,t,o)=>{for(var i=o>1?void 0:o?te(e,t):e,p=n.length-1,c;p>=0;p--)(c=n[p])&&(i=(o?c(e,t,i):c(i))||i);return o&&i&&ee(e,t,i),i};class r extends N{constructor(){super(...arguments),this.baseUrl=L,this.lang="en",this.debug=!1,this.isMobile=window.innerWidth<768,this.didUserExpandNonprofits=!1,this.shouldUseNewPromoUI=!1,this.getChainNonprofits=async()=>{if(q(["transactionId","subscriptionId"],this),!this.hasCorrectTransactionConfig&&!this.hasCorrectSubscriptionConfig)throw new H;const e=await E({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},requestBody:{storeId:this.storeId,postalCode:this.postalCode,countryCode:this.countryCode,cart:this.cart??void 0,widgetName:B.redeem_transaction,version:"1.0.0",lang:this.configLang}});return e.store?.id&&e.store.id!==this.storeId&&(this.storeId=e.store.id),this.localStorage.setItemJson("chainNonprofits",{createdAt:new Date,data:e}),e},this.updateNonprofitIdForRecord=async({selectedNonprofitId:e})=>this.transactionId?this.putTransaction({selectedNonprofitId:e}):this.subscriptionId?this.putSubscription({selectedNonprofitId:e}):null,this.putTransaction=async({selectedNonprofitId:e})=>(y(["apiKey","transactionId"],this),W({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},pathParams:{transactionId:Number(this.transactionId)},requestBody:{nonprofitId:e}})),this.putSubscription=async({selectedNonprofitId:e})=>(y(["apiKey","subscriptionId"],this),A({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},requestBody:{remoteSubscriptionId:this.subscriptionId,nonprofitId:e}})),this.nonprofitListDataController=new k(this,this.getChainNonprofits),this.selectionDataController=new k(this,this.updateNonprofitIdForRecord),this.localStorage=Z(this),this.makeHandleSelect=(e,t,o)=>async i=>{if(!this.allowChange)return;const p=this.selectedNonprofitId;if(i instanceof KeyboardEvent){let c=null;switch(i.key){case"ArrowUp":case"ArrowLeft":t===0?c=o[o.length-1]:c=o[t-1],i.preventDefault();break;case"ArrowRight":case"ArrowDown":t===o.length-1?c=o[0]:c=o[t+1],i.preventDefault();break;case"Enter":case" ":i.preventDefault();break;default:return}if(c){const b=this.renderRoot.querySelector(`[data-value="${c.nonprofit.id}"]`);b!==null&&(b.tabIndex=0,b.focus());return}}if(i.currentTarget instanceof HTMLElement){if(p===e)return;this.selectedNonprofitId=e}},this.handleSubmit=async()=>{const{selectedNonprofitId:e}=this;if(!this.allowSubmit||e==null)return;await this.selectionDataController.exec({selectedNonprofitId:e}),this.shouldUseStoredSelection&&(this.localStorage.setItem("nonprofit",e),this.localStorage.setItem("nonprofit_selected_at",new Date().toISOString()));const t=this.nonprofitListDataController?.data?.nonprofits.find(o=>o.nonprofit.id===e);this.dispatchEvent(new Y({selectedNonprofitId:e,nonprofitName:t?.nonprofit.name,source:B.redeem_transaction}))},this.evaluateBreakPoints=z(()=>{this.isMobile=window.innerWidth<768},50,{maxWait:50,leading:!0})}get configLang(){return F[this.lang]||"en"}get hasCorrectTransactionConfig(){return w(["apiKey","transactionId"],this)}get hasCorrectSubscriptionConfig(){return w(["apiKey","subscriptionId"],this)}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.evaluateBreakPoints)}async firstUpdated(e){await this.restoreStateFromCache()}async updated(e){const t=["baseUrl","storeId","apiKey","countryCode","postalCode","lang"];for(const o of t)if(e.has(o)){await this.nonprofitListDataController.exec();break}}disconnectedCallback(){super.disconnectedCallback()}restoreStateFromCache(){y(["apiKey"],this),this.shouldUseStoredSelection&&(this.selectedNonprofitId=parseInt(this.localStorage.getItem("nonprofit")||"")||void 0);try{const{createdAt:e=0,data:t}=this.localStorage.getItemJson("chainNonprofits")||{},o=2*60*60*1e3;new Date(e).valueOf()+o>new Date().valueOf()&&(this.nonprofitListDataController.data=t,this.nonprofitListDataController.loading=!1)}catch{}}get allowChange(){return this.selectionDataController.data==null&&!this.selectionDataController.loading}get allowSubmit(){return!!(this.selectedNonprofitId&&this.allowChange)}get shouldUseStoredSelection(){return!this.subscriptionId}get cssVariables(){const e={"--beam-fontFamily":"inherit","--beam-fontStyle":"inherit","--beam-fontSize":"inherit","--beam-textColor":"inherit","--beam-backgroundColor":"inherit",...O,...K,"--beam-RedeemTransaction-maxWidth":"1000px","--beam-RedeemTransaction-submitButton-color":"#fff","--beam-RedeemTransaction-submitButton-hover-color":"#fff","--beam-RedeemTransaction-submitButton-disabled-color":"#fff","--beam-RedeemTransaction-submitButton-backgroundColor":"#333","--beam-RedeemTransaction-submitButton-hover-backgroundColor":"#222","--beam-RedeemTransaction-submitButton-disabled-backgroundColor":"#767676","--beam-RedeemTransaction-submitButton-borderColor":"#333","--beam-RedeemTransaction-submitButton-hover-borderColor":"#222","--beam-RedeemTransaction-submitButton-disabled-borderColor":"#767676","--beam-RedeemTransaction-submitButton-fontSize":"14px","--beam-RedeemTransaction-submitButton-fontWeight":"inherit","--beam-RedeemTransaction-submitButton-fontFamily":"inherit","--beam-RedeemTransaction-submitButton-textTransform":"none","--beam-RedeemTransaction-submitButton-borderRadius":"0px","--beam-RedeemTransaction-submitButton-padding":"15px 30px","--beam-RedeemTransaction-submitButton-position":"right","--beam-RedeemTransaction-submitButton-positionRight-width":"auto","--beam-RedeemTransaction-submitButton-positionBottom-width":"100%","--beam-RedeemTransaction-submitButton-positionBottom-marginTop":"10px","--beam-RedeemTransaction-checkmark-color":"transparent","--beam-RedeemTransaction-checkmark-selected-color":"#fff","--beam-RedeemTransaction-checkmark-hover-color":"#fff","--beam-RedeemTransaction-checkmark-backgroundColor":"transparent","--beam-RedeemTransaction-checkmark-selected-backgroundColor":"#333","--beam-RedeemTransaction-checkmark-hover-backgroundColor":"#d9d9d9","--beam-RedeemTransaction-checkmark-borderColor":"transparent","--beam-RedeemTransaction-checkmark-selected-borderColor":"#333","--beam-RedeemTransaction-checkmark-hover-borderColor":"#d9d9d9","--beam-RedeemTransaction-options-minWidth":"250px","--beam-RedeemTransaction-options-columnCount":"2","--beam-RedeemTransaction-options-borderRadius":"0px","--beam-RedeemTransaction-options-borderWidth":"1px","--beam-RedeemTransaction-options-selected-borderWidth":"2px","--beam-RedeemTransaction-options-focus-borderWidth":"1px","--beam-RedeemTransaction-options-image-borderRadius":"0px","--beam-RedeemTransaction-options-borderColor":"#d9d9d9","--beam-RedeemTransaction-options-selected-borderColor":"currentColor","--beam-RedeemTransaction-options-hover-borderColor":"#ccc","--beam-RedeemTransaction-options-backgroundColor":"transparent","--beam-RedeemTransaction-options-selected-backgroundColor":"transparent","--beam-RedeemTransaction-options-hover-backgroundColor":"#f1f1f1","--beam-RedeemTransaction-options-marginTop":"15px",...f("--beam-RedeemTransaction-title",{fontSize:"1.25em",fontWeight:"bold"}),...f("--beam-RedeemTransaction-description",{marginTop:"0.5em"}),...f("--beam-RedeemTransaction-details-cause",{fontSize:"1em",fontWeight:"bold"}),...f("--beam-RedeemTransaction-details-impactDescription",{fontSize:"0.85em",marginTop:"10px"}),"--beam-RedeemTransaction-details-nonprofitName-fontWeight":"bold","--beam-RedeemTransaction-details-nonprofitName-fontStyle":"inherit","--beam-RedeemTransaction-details-fundingProgress-marginTop":"10px",...f("--beam-RedeemTransaction-details-fundingProgressLabel",{fontSize:"0.85em"}),"--beam-RedeemTransaction-cardStyle":"'image'","--beam-RedeemTransaction-options-icon-padding":"0px","--beam-RedeemTransaction-options-collapseNonprofits-mobile":"false","--beam-RedeemTransaction-options-collapseNonprofits-desktop":"false",..._},t=this.nonprofitListDataController?.data?.config?.web?.theme||{},o={...e,...t};return Object.assign(Object.create({toCSS(){return M(this)}}),o)}handleChooseClick(){this.didUserExpandNonprofits=!0}get shouldCollapse(){const e=this.cssVariables["--beam-RedeemTransaction-options-collapseNonprofits-mobile"]==="true",t=this.cssVariables["--beam-RedeemTransaction-options-collapseNonprofits-desktop"]==="true";return this.isMobile&&e||!this.isMobile&&t}renderSubmitButton(e){return s`
|
|
2
2
|
${this.didUserExpandNonprofits||!this.shouldCollapse?s` <button
|
|
3
3
|
type="button"
|
|
4
4
|
?aria-disabled=${!this.allowSubmit}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{f as I,g as l,t as x,h as N,y as s,q as v,u as P,k as D,m as U}from"../chunks/lit-3QHn3fwl.esm.js";import{d as z}from"../chunks/lodash-P8OIs-at.esm.js";import{u as h,A as k,d as f,a as M,_ as C,i as m}from"../chunks/localize-SsJbTmMj.esm.js";import{D as L,f as E,W as B,h as W,u as A,S as F}from"../chunks/routes-sc6xljWU.esm.js";import{p as K}from"../chunks/progress-bar-HVG_n8_6.esm.js";import{p as _}from"../chunks/promo-pill-label-3Xtr5ALT.esm.js";import{partnerLogosConfigDefaults as O}from"./beam-partner-logos.js";import{c as j,d as V,a as q,e as y,b as w}from"../chunks/enforce-config-er6B5Gkj.esm.js";import{_ as G}from"../chunks/loading-template-mLjOGXMj.esm.js";import{M as H,B as J}from"../chunks/beam-errors-P-Lu07Ce.esm.js";import{createScopedLocalStorage as Z}from"../utils/local-storage.js";import{c as Q}from"../chunks/css-card-grid-r6wxRbPV.esm.js";import{_ as X}from"../chunks/checkbox-P2JYPqxl.esm.js";import{c as Y}from"../chunks/events-_4nImo3u.esm.js";import"../utils/logger.js";import"../chunks/vendor--f7lkyBk.esm.js";const u={en:{beamAttribution:()=>"Powered by Beam",ctaTitle:()=>"Choose your impact",ctaPromoPrefixMessage:()=>"At no extra cost,",ctaPromoMessage:({donationPercentage:n="1"}={})=>`select a nonprofit and ${n}% of your purchase will be donated.`,ctaMessage:({donationPercentage:n="1%"}={})=>`Select a nonprofit and ${n} of your purchase will be donated, at no extra cost.`,submitButtonText:()=>"Confirm",submitButtonTextCompleted:()=>"Confirmed!",chooseButtonText:()=>"Choose"},fr:{beamAttribution:()=>"Optimis\xE9 par Beam",ctaTitle:()=>"Choisissez votre cause",ctaPromoPrefixMessage:()=>"",ctaPromoMessage:()=>"",ctaMessage:({donationPercentage:n="1%"}={})=>`Choisissez un organisme \xE0 but non lucratif et ${n}% lui sera vers\xE9 en votre nom, sans frais suppl\xE9mentaires.`,submitButtonText:()=>"Confirmer",submitButtonTextCompleted:()=>"Confirm\xE9!",chooseButtonText:()=>"Choisissez"},de:{beamAttribution:()=>"Unterst\xFCtzt von Beam",ctaTitle:()=>"W\xE4hle deinen Impact",ctaPromoPrefixMessage:()=>"",ctaPromoMessage:()=>"",ctaMessage:({donationPercentage:n="1%"}={})=>`W\xE4hle eine der gemeinn\xFCtzigen Organisationen und spende ${n} deines Einkaufs ohne zus\xE4tzliche Kosten`,submitButtonText:()=>"Best\xE4tigen",submitButtonTextCompleted:()=>"Best\xE4tigt!",chooseButtonText:()=>"W\xE4hlen"},es:{ctaTitle:()=>"Elige tu contribuci\xF3n",ctaPromoPrefixMessage:()=>"",ctaPromoMessage:()=>"",ctaMessage:({donationPercentage:n="1%"}={})=>`Elige una organizaci\xF3n sin fines de lucro y donaremos ${n} de tu compra sin coste adicional.`,beamAttribution:()=>"Ofrecido por Beam",submitButtonText:()=>"Confirmar",submitButtonTextCompleted:()=>"\xA1Confirmado!",chooseButtonText:()=>"Elige"},it:{ctaTitle:()=>"Scegli dove fare la differenza",ctaPromoPrefixMessage:()=>"",ctaPromoMessage:()=>"",ctaMessage:({donationPercentage:n="1%"}={})=>`Seleziona un'organizzazione no-profit a cui devolvere l\u2019${n} del tuo acquisto, senza costi aggiuntivi`,beamAttribution:()=>"Gestito da Beam",submitButtonText:()=>"Confermare",submitButtonTextCompleted:()=>"Confermato!",chooseButtonText:()=>"Scegli"},pl:{beamAttribution:()=>"Wspierany przez Beam",ctaTitle:()=>"Wybierz inicjatyw\u0119, kt\xF3r\u0105 chcesz wesprze\u0107",ctaPromoPrefixMessage:()=>"",ctaPromoMessage:()=>"",ctaMessage:({donationPercentage:n="1%"}={})=>`Wybierz organizacj\u0119, kt\xF3rej przeka\u017Cesz ${n} warto\u015Bci Twoich zakup\xF3w \u2013 bez \u017Cadnych dodatkowych koszt\xF3w!`,submitButtonText:()=>"Zatwierd\u017A",submitButtonTextCompleted:()=>"Zatwierdzono!",chooseButtonText:()=>"Wybierz"}};var ee=Object.defineProperty,te=Object.getOwnPropertyDescriptor,d=(n,e,t,o)=>{for(var i=o>1?void 0:o?te(e,t):e,p=n.length-1,c;p>=0;p--)(c=n[p])&&(i=(o?c(e,t,i):c(i))||i);return o&&i&&ee(e,t,i),i};class r extends N{constructor(){super(...arguments),this.baseUrl=L,this.lang="en",this.debug=!1,this.isMobile=window.innerWidth<768,this.didUserExpandNonprofits=!1,this.shouldUseNewPromoUI=!1,this.getChainNonprofits=async()=>{if(q(["transactionId","subscriptionId"],this),!this.hasCorrectTransactionConfig&&!this.hasCorrectSubscriptionConfig)throw new H;const e=await E({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},requestBody:{storeId:this.storeId,postalCode:this.postalCode,countryCode:this.countryCode,cart:this.cart??void 0,widgetName:B.redeem_transaction,version:"1.0.0",lang:this.configLang}});return e.store?.id&&e.store.id!==this.storeId&&(this.storeId=e.store.id),this.localStorage.setItemJson("chainNonprofits",{createdAt:new Date,data:e}),e},this.updateNonprofitIdForRecord=async({selectedNonprofitId:e})=>this.transactionId?this.putTransaction({selectedNonprofitId:e}):this.subscriptionId?this.putSubscription({selectedNonprofitId:e}):null,this.putTransaction=async({selectedNonprofitId:e})=>(y(["apiKey","transactionId"],this),W({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},pathParams:{transactionId:Number(this.transactionId)},requestBody:{nonprofitId:e}})),this.putSubscription=async({selectedNonprofitId:e})=>(y(["apiKey","subscriptionId"],this),A({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},requestBody:{remoteSubscriptionId:this.subscriptionId,nonprofitId:e}})),this.nonprofitListDataController=new k(this,this.getChainNonprofits),this.selectionDataController=new k(this,this.updateNonprofitIdForRecord),this.localStorage=Z(this),this.makeHandleSelect=(e,t,o)=>async i=>{if(!this.allowChange)return;const p=this.selectedNonprofitId;if(i instanceof KeyboardEvent){let c=null;switch(i.key){case"ArrowUp":case"ArrowLeft":t===0?c=o[o.length-1]:c=o[t-1],i.preventDefault();break;case"ArrowRight":case"ArrowDown":t===o.length-1?c=o[0]:c=o[t+1],i.preventDefault();break;case"Enter":case" ":i.preventDefault();break;default:return}if(c){const b=this.renderRoot.querySelector(`[data-value="${c.nonprofit.id}"]`);b!==null&&(b.tabIndex=0,b.focus());return}}if(i.currentTarget instanceof HTMLElement){if(p===e)return;this.selectedNonprofitId=e}},this.handleSubmit=async()=>{const{selectedNonprofitId:e}=this;if(!this.allowSubmit||e==null)return;await this.selectionDataController.exec({selectedNonprofitId:e}),this.shouldUseStoredSelection&&(this.localStorage.setItem("nonprofit",e),this.localStorage.setItem("nonprofit_selected_at",new Date().toISOString()));const t=this.nonprofitListDataController?.data?.nonprofits.find(o=>o.nonprofit.id===e);this.dispatchEvent(new Y({selectedNonprofitId:e,nonprofitName:t?.nonprofit.name,source:B.redeem_transaction}))},this.evaluateBreakPoints=z(()=>{this.isMobile=window.innerWidth<768},50,{maxWait:50,leading:!0})}get configLang(){return F[this.lang]||"en"}get hasCorrectTransactionConfig(){return w(["apiKey","transactionId"],this)}get hasCorrectSubscriptionConfig(){return w(["apiKey","subscriptionId"],this)}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.evaluateBreakPoints)}async firstUpdated(e){await this.restoreStateFromCache()}async updated(e){const t=["baseUrl","storeId","apiKey","countryCode","postalCode","lang"];for(const o of t)if(e.has(o)){await this.nonprofitListDataController.exec();break}}disconnectedCallback(){super.disconnectedCallback()}restoreStateFromCache(){y(["apiKey"],this),this.shouldUseStoredSelection&&(this.selectedNonprofitId=parseInt(this.localStorage.getItem("nonprofit")||"")||void 0);try{const{createdAt:e=0,data:t}=this.localStorage.getItemJson("chainNonprofits")||{},o=2*60*60*1e3;new Date(e).valueOf()+o>new Date().valueOf()&&(this.nonprofitListDataController.data=t,this.nonprofitListDataController.loading=!1)}catch{}}get allowChange(){return this.selectionDataController.data==null&&!this.selectionDataController.loading}get allowSubmit(){return!!(this.selectedNonprofitId&&this.allowChange)}get shouldUseStoredSelection(){return!this.subscriptionId}get cssVariables(){const e={"--beam-fontFamily":"inherit","--beam-fontStyle":"inherit","--beam-fontSize":"inherit","--beam-textColor":"inherit","--beam-backgroundColor":"inherit",...O,...K,"--beam-RedeemTransaction-maxWidth":"1000px","--beam-RedeemTransaction-submitButton-color":"#fff","--beam-RedeemTransaction-submitButton-hover-color":"#fff","--beam-RedeemTransaction-submitButton-disabled-color":"#fff","--beam-RedeemTransaction-submitButton-backgroundColor":"#333","--beam-RedeemTransaction-submitButton-hover-backgroundColor":"#222","--beam-RedeemTransaction-submitButton-disabled-backgroundColor":"#767676","--beam-RedeemTransaction-submitButton-borderColor":"#333","--beam-RedeemTransaction-submitButton-hover-borderColor":"#222","--beam-RedeemTransaction-submitButton-disabled-borderColor":"#767676","--beam-RedeemTransaction-submitButton-fontSize":"14px","--beam-RedeemTransaction-submitButton-fontWeight":"inherit","--beam-RedeemTransaction-submitButton-fontFamily":"inherit","--beam-RedeemTransaction-submitButton-textTransform":"none","--beam-RedeemTransaction-submitButton-borderRadius":"0px","--beam-RedeemTransaction-submitButton-padding":"15px 30px","--beam-RedeemTransaction-submitButton-position":"right","--beam-RedeemTransaction-submitButton-positionRight-width":"auto","--beam-RedeemTransaction-submitButton-positionBottom-width":"100%","--beam-RedeemTransaction-submitButton-positionBottom-marginTop":"10px","--beam-RedeemTransaction-checkmark-color":"transparent","--beam-RedeemTransaction-checkmark-selected-color":"#fff","--beam-RedeemTransaction-checkmark-hover-color":"#fff","--beam-RedeemTransaction-checkmark-backgroundColor":"transparent","--beam-RedeemTransaction-checkmark-selected-backgroundColor":"#333","--beam-RedeemTransaction-checkmark-hover-backgroundColor":"#d9d9d9","--beam-RedeemTransaction-checkmark-borderColor":"transparent","--beam-RedeemTransaction-checkmark-selected-borderColor":"#333","--beam-RedeemTransaction-checkmark-hover-borderColor":"#d9d9d9","--beam-RedeemTransaction-options-minWidth":"250px","--beam-RedeemTransaction-options-columnCount":"2","--beam-RedeemTransaction-options-borderRadius":"0px","--beam-RedeemTransaction-options-borderWidth":"1px","--beam-RedeemTransaction-options-selected-borderWidth":"2px","--beam-RedeemTransaction-options-focus-borderWidth":"1px","--beam-RedeemTransaction-options-image-borderRadius":"0px","--beam-RedeemTransaction-options-borderColor":"#d9d9d9","--beam-RedeemTransaction-options-selected-borderColor":"currentColor","--beam-RedeemTransaction-options-hover-borderColor":"#ccc","--beam-RedeemTransaction-options-backgroundColor":"transparent","--beam-RedeemTransaction-options-selected-backgroundColor":"transparent","--beam-RedeemTransaction-options-hover-backgroundColor":"#f1f1f1","--beam-RedeemTransaction-options-marginTop":"15px",...f("--beam-RedeemTransaction-title",{fontSize:"1.25em",fontWeight:"bold"}),...f("--beam-RedeemTransaction-description",{marginTop:"0.5em"}),...f("--beam-RedeemTransaction-details-cause",{fontSize:"1em",fontWeight:"bold"}),...f("--beam-RedeemTransaction-details-impactDescription",{fontSize:"0.85em",marginTop:"10px"}),"--beam-RedeemTransaction-details-nonprofitName-fontWeight":"bold","--beam-RedeemTransaction-details-nonprofitName-fontStyle":"inherit","--beam-RedeemTransaction-details-fundingProgress-marginTop":"10px",...f("--beam-RedeemTransaction-details-fundingProgressLabel",{fontSize:"0.85em"}),"--beam-RedeemTransaction-cardStyle":"'image'","--beam-RedeemTransaction-options-icon-padding":"0px","--beam-RedeemTransaction-options-collapseNonprofits-mobile":"false","--beam-RedeemTransaction-options-collapseNonprofits-desktop":"false",..._},t=this.nonprofitListDataController?.data?.config?.web?.theme||{},o={...e,...t};return Object.assign(Object.create({toCSS(){return M(this)}}),o)}handleChooseClick(){this.didUserExpandNonprofits=!0}get shouldCollapse(){const e=this.cssVariables["--beam-RedeemTransaction-options-collapseNonprofits-mobile"]==="true",t=this.cssVariables["--beam-RedeemTransaction-options-collapseNonprofits-desktop"]==="true";return this.isMobile&&e||!this.isMobile&&t}renderSubmitButton(e){return s`
|
|
1
|
+
import{f as I,g as l,t as x,h as N,y as s,q as v,u as P,k as D,m as U}from"../chunks/lit-3QHn3fwl.esm.js";import{d as z}from"../chunks/lodash-P8OIs-at.esm.js";import{u as h,A as k,d as f,a as M,_ as C,i as m}from"../chunks/localize-SsJbTmMj.esm.js";import{D as L,f as E,W as B,h as W,u as A,S as F}from"../chunks/routes-nWhY4Rgg.esm.js";import{p as K}from"../chunks/progress-bar-HVG_n8_6.esm.js";import{p as _}from"../chunks/promo-pill-label-3Xtr5ALT.esm.js";import{partnerLogosConfigDefaults as O}from"./beam-partner-logos.js";import{c as j,d as V,a as q,e as y,b as w}from"../chunks/enforce-config-er6B5Gkj.esm.js";import{_ as G}from"../chunks/loading-template-mLjOGXMj.esm.js";import{M as H,B as J}from"../chunks/beam-errors-P-Lu07Ce.esm.js";import{createScopedLocalStorage as Z}from"../utils/local-storage.js";import{c as Q}from"../chunks/css-card-grid-r6wxRbPV.esm.js";import{_ as X}from"../chunks/checkbox-P2JYPqxl.esm.js";import{c as Y}from"../chunks/events-_4nImo3u.esm.js";import"../utils/logger.js";import"../chunks/vendor--f7lkyBk.esm.js";const u={en:{beamAttribution:()=>"Powered by Beam",ctaTitle:()=>"Choose your impact",ctaPromoPrefixMessage:()=>"At no extra cost,",ctaPromoMessage:({donationPercentage:n="1"}={})=>`select a nonprofit and ${n}% of your purchase will be donated.`,ctaMessage:({donationPercentage:n="1%"}={})=>`Select a nonprofit and ${n} of your purchase will be donated, at no extra cost.`,submitButtonText:()=>"Confirm",submitButtonTextCompleted:()=>"Confirmed!",chooseButtonText:()=>"Choose"},fr:{beamAttribution:()=>"Optimis\xE9 par Beam",ctaTitle:()=>"Choisissez votre cause",ctaPromoPrefixMessage:()=>"",ctaPromoMessage:()=>"",ctaMessage:({donationPercentage:n="1%"}={})=>`Choisissez un organisme \xE0 but non lucratif et ${n}% lui sera vers\xE9 en votre nom, sans frais suppl\xE9mentaires.`,submitButtonText:()=>"Confirmer",submitButtonTextCompleted:()=>"Confirm\xE9!",chooseButtonText:()=>"Choisissez"},de:{beamAttribution:()=>"Unterst\xFCtzt von Beam",ctaTitle:()=>"W\xE4hle deinen Impact",ctaPromoPrefixMessage:()=>"",ctaPromoMessage:()=>"",ctaMessage:({donationPercentage:n="1%"}={})=>`W\xE4hle eine der gemeinn\xFCtzigen Organisationen und spende ${n} deines Einkaufs ohne zus\xE4tzliche Kosten`,submitButtonText:()=>"Best\xE4tigen",submitButtonTextCompleted:()=>"Best\xE4tigt!",chooseButtonText:()=>"W\xE4hlen"},es:{ctaTitle:()=>"Elige tu contribuci\xF3n",ctaPromoPrefixMessage:()=>"",ctaPromoMessage:()=>"",ctaMessage:({donationPercentage:n="1%"}={})=>`Elige una organizaci\xF3n sin fines de lucro y donaremos ${n} de tu compra sin coste adicional.`,beamAttribution:()=>"Ofrecido por Beam",submitButtonText:()=>"Confirmar",submitButtonTextCompleted:()=>"\xA1Confirmado!",chooseButtonText:()=>"Elige"},it:{ctaTitle:()=>"Scegli dove fare la differenza",ctaPromoPrefixMessage:()=>"",ctaPromoMessage:()=>"",ctaMessage:({donationPercentage:n="1%"}={})=>`Seleziona un'organizzazione no-profit a cui devolvere l\u2019${n} del tuo acquisto, senza costi aggiuntivi`,beamAttribution:()=>"Gestito da Beam",submitButtonText:()=>"Confermare",submitButtonTextCompleted:()=>"Confermato!",chooseButtonText:()=>"Scegli"},pl:{beamAttribution:()=>"Wspierany przez Beam",ctaTitle:()=>"Wybierz inicjatyw\u0119, kt\xF3r\u0105 chcesz wesprze\u0107",ctaPromoPrefixMessage:()=>"",ctaPromoMessage:()=>"",ctaMessage:({donationPercentage:n="1%"}={})=>`Wybierz organizacj\u0119, kt\xF3rej przeka\u017Cesz ${n} warto\u015Bci Twoich zakup\xF3w \u2013 bez \u017Cadnych dodatkowych koszt\xF3w!`,submitButtonText:()=>"Zatwierd\u017A",submitButtonTextCompleted:()=>"Zatwierdzono!",chooseButtonText:()=>"Wybierz"}};var ee=Object.defineProperty,te=Object.getOwnPropertyDescriptor,d=(n,e,t,o)=>{for(var i=o>1?void 0:o?te(e,t):e,p=n.length-1,c;p>=0;p--)(c=n[p])&&(i=(o?c(e,t,i):c(i))||i);return o&&i&&ee(e,t,i),i};class r extends N{constructor(){super(...arguments),this.baseUrl=L,this.lang="en",this.debug=!1,this.isMobile=window.innerWidth<768,this.didUserExpandNonprofits=!1,this.shouldUseNewPromoUI=!1,this.getChainNonprofits=async()=>{if(q(["transactionId","subscriptionId"],this),!this.hasCorrectTransactionConfig&&!this.hasCorrectSubscriptionConfig)throw new H;const e=await E({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},requestBody:{storeId:this.storeId,postalCode:this.postalCode,countryCode:this.countryCode,cart:this.cart??void 0,widgetName:B.redeem_transaction,version:"1.0.0",lang:this.configLang}});return e.store?.id&&e.store.id!==this.storeId&&(this.storeId=e.store.id),this.localStorage.setItemJson("chainNonprofits",{createdAt:new Date,data:e}),e},this.updateNonprofitIdForRecord=async({selectedNonprofitId:e})=>this.transactionId?this.putTransaction({selectedNonprofitId:e}):this.subscriptionId?this.putSubscription({selectedNonprofitId:e}):null,this.putTransaction=async({selectedNonprofitId:e})=>(y(["apiKey","transactionId"],this),W({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},pathParams:{transactionId:Number(this.transactionId)},requestBody:{nonprofitId:e}})),this.putSubscription=async({selectedNonprofitId:e})=>(y(["apiKey","subscriptionId"],this),A({baseUrl:this.baseUrl,headers:{authorization:`Api-Key ${this.apiKey}`},requestBody:{remoteSubscriptionId:this.subscriptionId,nonprofitId:e}})),this.nonprofitListDataController=new k(this,this.getChainNonprofits),this.selectionDataController=new k(this,this.updateNonprofitIdForRecord),this.localStorage=Z(this),this.makeHandleSelect=(e,t,o)=>async i=>{if(!this.allowChange)return;const p=this.selectedNonprofitId;if(i instanceof KeyboardEvent){let c=null;switch(i.key){case"ArrowUp":case"ArrowLeft":t===0?c=o[o.length-1]:c=o[t-1],i.preventDefault();break;case"ArrowRight":case"ArrowDown":t===o.length-1?c=o[0]:c=o[t+1],i.preventDefault();break;case"Enter":case" ":i.preventDefault();break;default:return}if(c){const b=this.renderRoot.querySelector(`[data-value="${c.nonprofit.id}"]`);b!==null&&(b.tabIndex=0,b.focus());return}}if(i.currentTarget instanceof HTMLElement){if(p===e)return;this.selectedNonprofitId=e}},this.handleSubmit=async()=>{const{selectedNonprofitId:e}=this;if(!this.allowSubmit||e==null)return;await this.selectionDataController.exec({selectedNonprofitId:e}),this.shouldUseStoredSelection&&(this.localStorage.setItem("nonprofit",e),this.localStorage.setItem("nonprofit_selected_at",new Date().toISOString()));const t=this.nonprofitListDataController?.data?.nonprofits.find(o=>o.nonprofit.id===e);this.dispatchEvent(new Y({selectedNonprofitId:e,nonprofitName:t?.nonprofit.name,source:B.redeem_transaction}))},this.evaluateBreakPoints=z(()=>{this.isMobile=window.innerWidth<768},50,{maxWait:50,leading:!0})}get configLang(){return F[this.lang]||"en"}get hasCorrectTransactionConfig(){return w(["apiKey","transactionId"],this)}get hasCorrectSubscriptionConfig(){return w(["apiKey","subscriptionId"],this)}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.evaluateBreakPoints)}async firstUpdated(e){await this.restoreStateFromCache()}async updated(e){const t=["baseUrl","storeId","apiKey","countryCode","postalCode","lang"];for(const o of t)if(e.has(o)){await this.nonprofitListDataController.exec();break}}disconnectedCallback(){super.disconnectedCallback()}restoreStateFromCache(){y(["apiKey"],this),this.shouldUseStoredSelection&&(this.selectedNonprofitId=parseInt(this.localStorage.getItem("nonprofit")||"")||void 0);try{const{createdAt:e=0,data:t}=this.localStorage.getItemJson("chainNonprofits")||{},o=2*60*60*1e3;new Date(e).valueOf()+o>new Date().valueOf()&&(this.nonprofitListDataController.data=t,this.nonprofitListDataController.loading=!1)}catch{}}get allowChange(){return this.selectionDataController.data==null&&!this.selectionDataController.loading}get allowSubmit(){return!!(this.selectedNonprofitId&&this.allowChange)}get shouldUseStoredSelection(){return!this.subscriptionId}get cssVariables(){const e={"--beam-fontFamily":"inherit","--beam-fontStyle":"inherit","--beam-fontSize":"inherit","--beam-textColor":"inherit","--beam-backgroundColor":"inherit",...O,...K,"--beam-RedeemTransaction-maxWidth":"1000px","--beam-RedeemTransaction-submitButton-color":"#fff","--beam-RedeemTransaction-submitButton-hover-color":"#fff","--beam-RedeemTransaction-submitButton-disabled-color":"#fff","--beam-RedeemTransaction-submitButton-backgroundColor":"#333","--beam-RedeemTransaction-submitButton-hover-backgroundColor":"#222","--beam-RedeemTransaction-submitButton-disabled-backgroundColor":"#767676","--beam-RedeemTransaction-submitButton-borderColor":"#333","--beam-RedeemTransaction-submitButton-hover-borderColor":"#222","--beam-RedeemTransaction-submitButton-disabled-borderColor":"#767676","--beam-RedeemTransaction-submitButton-fontSize":"14px","--beam-RedeemTransaction-submitButton-fontWeight":"inherit","--beam-RedeemTransaction-submitButton-fontFamily":"inherit","--beam-RedeemTransaction-submitButton-textTransform":"none","--beam-RedeemTransaction-submitButton-borderRadius":"0px","--beam-RedeemTransaction-submitButton-padding":"15px 30px","--beam-RedeemTransaction-submitButton-position":"right","--beam-RedeemTransaction-submitButton-positionRight-width":"auto","--beam-RedeemTransaction-submitButton-positionBottom-width":"100%","--beam-RedeemTransaction-submitButton-positionBottom-marginTop":"10px","--beam-RedeemTransaction-checkmark-color":"transparent","--beam-RedeemTransaction-checkmark-selected-color":"#fff","--beam-RedeemTransaction-checkmark-hover-color":"#fff","--beam-RedeemTransaction-checkmark-backgroundColor":"transparent","--beam-RedeemTransaction-checkmark-selected-backgroundColor":"#333","--beam-RedeemTransaction-checkmark-hover-backgroundColor":"#d9d9d9","--beam-RedeemTransaction-checkmark-borderColor":"transparent","--beam-RedeemTransaction-checkmark-selected-borderColor":"#333","--beam-RedeemTransaction-checkmark-hover-borderColor":"#d9d9d9","--beam-RedeemTransaction-options-minWidth":"250px","--beam-RedeemTransaction-options-columnCount":"2","--beam-RedeemTransaction-options-borderRadius":"0px","--beam-RedeemTransaction-options-borderWidth":"1px","--beam-RedeemTransaction-options-selected-borderWidth":"2px","--beam-RedeemTransaction-options-focus-borderWidth":"1px","--beam-RedeemTransaction-options-image-borderRadius":"0px","--beam-RedeemTransaction-options-borderColor":"#d9d9d9","--beam-RedeemTransaction-options-selected-borderColor":"currentColor","--beam-RedeemTransaction-options-hover-borderColor":"#ccc","--beam-RedeemTransaction-options-backgroundColor":"transparent","--beam-RedeemTransaction-options-selected-backgroundColor":"transparent","--beam-RedeemTransaction-options-hover-backgroundColor":"#f1f1f1","--beam-RedeemTransaction-options-marginTop":"15px",...f("--beam-RedeemTransaction-title",{fontSize:"1.25em",fontWeight:"bold"}),...f("--beam-RedeemTransaction-description",{marginTop:"0.5em"}),...f("--beam-RedeemTransaction-details-cause",{fontSize:"1em",fontWeight:"bold"}),...f("--beam-RedeemTransaction-details-impactDescription",{fontSize:"0.85em",marginTop:"10px"}),"--beam-RedeemTransaction-details-nonprofitName-fontWeight":"bold","--beam-RedeemTransaction-details-nonprofitName-fontStyle":"inherit","--beam-RedeemTransaction-details-fundingProgress-marginTop":"10px",...f("--beam-RedeemTransaction-details-fundingProgressLabel",{fontSize:"0.85em"}),"--beam-RedeemTransaction-cardStyle":"'image'","--beam-RedeemTransaction-options-icon-padding":"0px","--beam-RedeemTransaction-options-collapseNonprofits-mobile":"false","--beam-RedeemTransaction-options-collapseNonprofits-desktop":"false",..._},t=this.nonprofitListDataController?.data?.config?.web?.theme||{},o={...e,...t};return Object.assign(Object.create({toCSS(){return M(this)}}),o)}handleChooseClick(){this.didUserExpandNonprofits=!0}get shouldCollapse(){const e=this.cssVariables["--beam-RedeemTransaction-options-collapseNonprofits-mobile"]==="true",t=this.cssVariables["--beam-RedeemTransaction-options-collapseNonprofits-desktop"]==="true";return this.isMobile&&e||!this.isMobile&&t}renderSubmitButton(e){return s`
|
|
2
2
|
${this.didUserExpandNonprofits||!this.shouldCollapse?s` <button
|
|
3
3
|
type="button"
|
|
4
4
|
?aria-disabled=${!this.allowSubmit}
|
|
@@ -5,8 +5,8 @@ import '../chunks/progress-bar-0VS_AmEf.esm.js';
|
|
|
5
5
|
import '../chunks/promo-pill-label-3bA1z-la.esm.js';
|
|
6
6
|
import { T as TNumericId } from '../chunks/types-zbTZ8-KP.esm.js';
|
|
7
7
|
import { L as LANGUAGES } from '../chunks/types-aju0qrRe.esm.js';
|
|
8
|
-
import { T as TCart } from '../chunks/cart-contents-
|
|
9
|
-
import '../chunks/openapi-spec
|
|
8
|
+
import { T as TCart } from '../chunks/cart-contents-WB1BF6hG.esm.js';
|
|
9
|
+
import '../chunks/openapi-spec-GGEBbqAJ.esm.js';
|
|
10
10
|
|
|
11
11
|
declare class BeamNotificationBlip extends LitElement {
|
|
12
12
|
static get styles(): lit.CSSResult;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{h as v,f as x,y as c,g as f,u as E,k as T,m as M}from"../chunks/lit-3QHn3fwl.esm.js";import{u as b,A as I,d as h,a as B,_ as w,i as p}from"../chunks/localize-IRs8JglT.esm.js";import{D as F,f as _,W as N,j as W,S as U}from"../chunks/routes-
|
|
1
|
+
import{h as v,f as x,y as c,g as f,u as E,k as T,m as M}from"../chunks/lit-3QHn3fwl.esm.js";import{u as b,A as I,d as h,a as B,_ as w,i as p}from"../chunks/localize-IRs8JglT.esm.js";import{D as F,f as _,W as N,j as W,S as U}from"../chunks/routes-2U31lJuH.esm.js";import{p as O}from"../chunks/progress-bar-HVG_n8_6.esm.js";import{p as R}from"../chunks/promo-pill-label-3Xtr5ALT.esm.js";import{c as j,d as K,e as y}from"../chunks/enforce-config-HksNiOMu.esm.js";import{_ as H}from"../chunks/loading-template-mLjOGXMj.esm.js";import{c as $,g as q,d as k}from"../chunks/events-_4nImo3u.esm.js";import{logger as G}from"../utils/logger.esm.js";import"../utils/network-listeners.esm.js";import{createScopedLocalStorage as J}from"../utils/local-storage.esm.js";import{getCookieValue as P}from"../utils/cookies.esm.js";import{i as V}from"../chunks/lodash-P8OIs-at.esm.js";import{c as Q}from"../chunks/responsive-KbDsZM6S.esm.js";import{B as X}from"../chunks/cart-contents-h60geKWa.esm.js";import"../chunks/beam-errors-P-Lu07Ce.esm.js";import"../chunks/vendor--f7lkyBk.esm.js";class Y extends v{static get styles(){return x`
|
|
2
2
|
:host {
|
|
3
3
|
position: relative;
|
|
4
4
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{h as v,f as x,y as c,g as f,u as E,k as T,m as M}from"../chunks/lit-3QHn3fwl.esm.js";import{u as b,A as I,d as h,a as B,_ as w,i as p}from"../chunks/localize-SsJbTmMj.esm.js";import{D as F,f as _,W as N,j as W,S as U}from"../chunks/routes-
|
|
1
|
+
import{h as v,f as x,y as c,g as f,u as E,k as T,m as M}from"../chunks/lit-3QHn3fwl.esm.js";import{u as b,A as I,d as h,a as B,_ as w,i as p}from"../chunks/localize-SsJbTmMj.esm.js";import{D as F,f as _,W as N,j as W,S as U}from"../chunks/routes-nWhY4Rgg.esm.js";import{p as O}from"../chunks/progress-bar-HVG_n8_6.esm.js";import{p as R}from"../chunks/promo-pill-label-3Xtr5ALT.esm.js";import{c as j,d as K,e as y}from"../chunks/enforce-config-er6B5Gkj.esm.js";import{_ as H}from"../chunks/loading-template-mLjOGXMj.esm.js";import{c as $,g as q,d as k}from"../chunks/events-_4nImo3u.esm.js";import{logger as G}from"../utils/logger.js";import"../utils/network-listeners.js";import{createScopedLocalStorage as J}from"../utils/local-storage.js";import{getCookieValue as P}from"../utils/cookies.js";import{i as V}from"../chunks/lodash-P8OIs-at.esm.js";import{c as Q}from"../chunks/responsive-KbDsZM6S.esm.js";import{B as X}from"../chunks/cart-contents-h60geKWa.esm.js";import"../chunks/beam-errors-P-Lu07Ce.esm.js";import"../chunks/vendor--f7lkyBk.esm.js";class Y extends v{static get styles(){return x`
|
|
2
2
|
:host {
|
|
3
3
|
position: relative;
|
|
4
4
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{f as I,g as p,t as D,h as L,y as S,u as M,q as x,m as F}from"../chunks/lit-3QHn3fwl.esm.js";import{d as P}from"../chunks/lodash-P8OIs-at.esm.js";import{D as A,f as U,u as W,S as R}from"../chunks/routes-zzEfDMIn.esm.js";import{u as d,A as k,d as u,a as z,_ as N,i as l}from"../chunks/localize-IRs8JglT.esm.js";import{p as E}from"../chunks/progress-bar-HVG_n8_6.esm.js";import{c as _,d as j,e as v}from"../chunks/enforce-config-HksNiOMu.esm.js";import{_ as H}from"../chunks/loading-template-mLjOGXMj.esm.js";import{makeApiKeyHeader as C}from"../utils/makeApiKeyHeader.esm.js";import{B as K}from"../chunks/beam-errors-P-Lu07Ce.esm.js";import{createScopedLocalStorage as O}from"../utils/local-storage.esm.js";import{c as Y}from"../chunks/css-card-grid-r6wxRbPV.esm.js";import{_ as G}from"../chunks/checkbox-P2JYPqxl.esm.js";import{c as q}from"../chunks/events-_4nImo3u.esm.js";import"./beam-partner-logos.esm.js";import"../utils/logger.esm.js";const m={en:{ctaTitle:()=>"Choose Your Impact",ctaMessagePrefix:()=>" at no extra cost.",ctaMessage:({donationPercentage:n="1%"}={})=>`Choose a nonprofit and ${n} will be donated there for you with every order of your subscription,`,submitButtonText:()=>"Confirm",submitButtonTextCompleted:()=>"Confirmed!",chooseButtonText:()=>"Choose"},fr:{ctaTitle:()=>"Choose Your Impact",ctaMessagePrefix:()=>" at no extra cost.",ctaMessage:({donationPercentage:n="1%"}={})=>`Choose a nonprofit and ${n} will be donated there for you with every order of your subscription,`,submitButtonText:()=>"Confirm",submitButtonTextCompleted:()=>"Confirmed!",chooseButtonText:()=>"Choose"},de:{ctaTitle:()=>"Choose Your Impact",ctaMessagePrefix:()=>" at no extra cost.",ctaMessage:({donationPercentage:n="1%"}={})=>`Choose a nonprofit and ${n} will be donated there for you with every order of your subscription,`,submitButtonText:()=>"Confirm",submitButtonTextCompleted:()=>"Confirmed!",chooseButtonText:()=>"Choose"},es:{ctaTitle:()=>"Choose Your Impact",ctaMessagePrefix:()=>" at no extra cost.",ctaMessage:({donationPercentage:n="1%"}={})=>`Choose a nonprofit and ${n} will be donated there for you with every order of your subscription,`,submitButtonText:()=>"Confirm",submitButtonTextCompleted:()=>"Confirmed!",chooseButtonText:()=>"Choose"},it:{ctaTitle:()=>"Choose Your Impact",ctaMessagePrefix:()=>" at no extra cost.",ctaMessage:({donationPercentage:n="1%"}={})=>`Choose a nonprofit and ${n} will be donated there for you with every order of your subscription,`,submitButtonText:()=>"Confirm",submitButtonTextCompleted:()=>"Confirmed!",chooseButtonText:()=>"Choose"},pl:{ctaTitle:()=>"Choose Your Impact",ctaMessagePrefix:()=>" at no extra cost.",ctaMessage:({donationPercentage:n="1%"}={})=>`Choose a nonprofit and ${n} will be donated there for you with every order of your subscription,`,submitButtonText:()=>"Confirm",submitButtonTextCompleted:()=>"Confirmed!",chooseButtonText:()=>"Choose"}};var V=Object.defineProperty,J=Object.getOwnPropertyDescriptor,c=(n,o,t,e)=>{for(var i=e>1?void 0:e?J(o,t):o,b=n.length-1,a;b>=0;b--)(a=n[b])&&(i=(e?a(o,t,i):a(i))||i);return e&&i&&V(o,t,i),i};const Q=2*60*60*1e3;class s extends L{constructor(){super(...arguments),this.baseUrl=A,this.lang="en",this.debug=!1,this.isMobile=window.innerWidth<768,this.getChainNonprofits=async()=>{v(["apiKey","subscriptionId","storeId"],this);const o=await U({baseUrl:this.baseUrl,headers:C(this.apiKey),requestBody:{storeId:this.storeId,postalCode:this.postalCode,countryCode:this.countryCode,widgetName:"select-subscription-nonprofit",version:"1.0.0",lang:this.configLang}});return this.localStorage.setItemJson("chainNonprofits",{createdAt:new Date,data:o}),o},this.updateNonprofitIdForSubscription=async({selectedNonprofitId:o})=>this.subscriptionId?(v(["apiKey","subscriptionId"],this),W({baseUrl:this.baseUrl,headers:C(this.apiKey),requestBody:{remoteSubscriptionId:this.subscriptionId,nonprofitId:o,selectionMethod:"dashboard"}})):null,this.nonprofitListDataController=new k(this,this.getChainNonprofits),this.subscriptionUpdateDataController=new k(this,this.updateNonprofitIdForSubscription),this.localStorage=O(this),this.makeHandleSelect=(o,t,e)=>async i=>{if(!this.allowChange)return;const b=this.selectedNonprofitId;if(i instanceof KeyboardEvent){let a=null;switch(i.key){case"ArrowUp":case"ArrowLeft":t===0?a=e[e.length-1]:a=e[t-1],i.preventDefault();break;case"ArrowRight":case"ArrowDown":t===e.length-1?a=e[0]:a=e[t+1],i.preventDefault();break;case"Enter":case" ":i.preventDefault();break;default:return}if(a){const f=this.renderRoot.querySelector(`[data-value="${a.nonprofit.id}"]`);f!==null&&(f.tabIndex=0,f.focus());return}}if(i.currentTarget instanceof HTMLElement){if(b===o)return;this.selectedNonprofitId=o}},this.handleSubmit=async()=>{const{selectedNonprofitId:o}=this;if(!this.allowSubmit||o==null)return;await this.subscriptionUpdateDataController.exec({selectedNonprofitId:o});const t=this.nonprofitListDataController?.data?.nonprofits.find(e=>e.nonprofit.id===o);this.dispatchEvent(new q({selectedNonprofitId:o,nonprofitName:t?.nonprofit.name}))},this.evaluateBreakPoints=P(()=>{this.isMobile=window.innerWidth<768},50,{maxWait:50,leading:!0})}get configLang(){return R[this.lang]||"en"}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.evaluateBreakPoints)}async firstUpdated(o){await this.restoreStateFromCache()}async updated(o){const t=["baseUrl","storeId","apiKey","countryCode","postalCode","lang"];for(const e of t)if(o.has(e)){await this.nonprofitListDataController.exec();break}}disconnectedCallback(){super.disconnectedCallback()}restoreStateFromCache(){v(["apiKey"],this);try{const{createdAt:o=0,data:t}=this.localStorage.getItemJson("chainNonprofits")||{};new Date(o).valueOf()+Q>new Date().valueOf()&&(this.nonprofitListDataController.data=t,this.nonprofitListDataController.loading=!1)}catch{}}get allowChange(){return this.subscriptionUpdateDataController.data==null&&!this.subscriptionUpdateDataController.loading}get allowSubmit(){return!!(this.selectedNonprofitId&&this.allowChange)}get cssVariables(){const o={...E,"--beam-fontFamily":"inherit","--beam-fontStyle":"inherit","--beam-fontSize":"inherit","--beam-textColor":"inherit","--beam-backgroundColor":"inherit","--beam-SelectSubscriptionNonprofit-maxWidth":"800px","--beam-SelectSubscriptionNonprofit-mobile-header-alignItems":"center","--beam-SelectSubscriptionNonprofit-desktop-header-alignItems":"center","--beam-SelectSubscriptionNonprofit-headerContainer-padding":"2px","--beam-SelectSubscriptionNonprofit-title-textAlign":"inherit","--beam-SelectSubscriptionNonprofit-description-textAlign":"center","--beam-SelectSubscriptionNonprofit-desktop-description-width":"80%","--beam-SelectSubscriptionNonprofit-mobile-description-width":"90%","--beam-SelectSubscriptionNonprofit-options-marginTop":"10px","--beam-SelectSubscriptionNonprofit-options-padding":"10px","--beam-SelectSubscriptionNonprofit-options-borderWidth":"1px","--beam-SelectSubscriptionNonprofit-options-borderColor":"transparent","--beam-SelectSubscriptionNonprofit-options-borderRadius":"8px","--beam-SelectSubscriptionNonprofit-options-backgroundColor":"#F9FBFB","--beam-SelectSubscriptionNonprofit-option-padding":"15px","--beam-SelectSubscriptionNonprofit-options-hover-backgroundColor":"#e1f1ee","--beam-SelectSubscriptionNonprofit-options-hover-borderWidth":"1px","--beam-SelectSubscriptionNonprofit-options-hover-borderColor":"#e1f1ee","--beam-SelectSubscriptionNonprofit-options-selected-borderWidth":"1px","--beam-SelectSubscriptionNonprofit-options-selected-borderColor":"#e1f1ee","--beam-SelectSubscriptionNonprofit-options-selected-backgroundColor":"#e1f1ee","--beam-SelectSubscriptionNonprofit-options-gap":"20px","--beam-SelectSubscriptionNonprofit-options-minWidth":"250px","--beam-SelectSubscriptionNonprofit-options-columnCount":"2","--beam-SelectSubscriptionNonprofit-options-icon-borderRadius":"4px","--beam-SelectSubscriptionNonprofit-options-icon-padding":"10px","--beam-SelectSubscriptionNonprofit-options-image-borderRadius":"4px","--beam-SelectSubscriptionNonprofit-cardIconContainer-height":"100%","--beam-SelectSubscriptionNonprofit-iconBackground-width":"50px","--beam-SelectSubscriptionNonprofit-iconBackground-height":"50px","--beam-SelectSubscriptionNonprofit-iconBackground-borderRadius":"50%","--beam-SelectSubscriptionNonprofit-iconBackground-background":"#0a323c","--beam-SelectSubscriptionNonprofit-icon-height":"50px","--beam-SelectSubscriptionNonprofit-checkmark-backgroundColor":"transparent","--beam-SelectSubscriptionNonprofit-checkmark-color":"transparent","--beam-SelectSubscriptionNonprofit-checkmark-borderColor":"#0A323C","--beam-SelectSubscriptionNonprofit-checkmark-selected-color":"#fff","--beam-SelectSubscriptionNonprofit-checkmark-selected-backgroundColor":"#0A323C","--beam-SelectSubscriptionNonprofit-checkmark-selected-borderColor":"#0A323C","--beam-SelectSubscriptionNonprofit-checkmark-hover-color":"#fff","--beam-SelectSubscriptionNonprofit-checkmark-hover-backgroundColor":"#0A323C","--beam-SelectSubscriptionNonprofit-checkmark-hover-borderColor":"#0A323C","--beam-SelectSubscriptionNonprofit-cardStyle":"'selected_icon'","--beam-SelectSubscriptionNonprofit-submitButton-color":"#fff","--beam-SelectSubscriptionNonprofit-submitButton-hover-color":"#fff","--beam-SelectSubscriptionNonprofit-submitButton-disabled-color":"#fff","--beam-SelectSubscriptionNonprofit-submitButton-backgroundColor":"#0A323C","--beam-SelectSubscriptionNonprofit-submitButton-hover-backgroundColor":"#222","--beam-SelectSubscriptionNonprofit-submitButton-disabled-backgroundColor":"#767676","--beam-SelectSubscriptionNonprofit-submitButton-borderColor":"#333","--beam-SelectSubscriptionNonprofit-submitButton-hover-borderColor":"#222","--beam-SelectSubscriptionNonprofit-submitButton-disabled-borderColor":"#767676","--beam-SelectSubscriptionNonprofit-submitButton-fontSize":"14px","--beam-SelectSubscriptionNonprofit-submitButton-fontWeight":"inherit","--beam-SelectSubscriptionNonprofit-submitButton-fontFamily":"inherit","--beam-SelectSubscriptionNonprofit-submitButton-textTransform":"none","--beam-SelectSubscriptionNonprofit-submitButton-borderRadius":"30px","--beam-SelectSubscriptionNonprofit-submitButton-padding":"10px 30px",...u("--beam-SelectSubscriptionNonprofit-title",{fontSize:"20px",fontWeight:"bold",lineHeight:"120%",textTransform:"capitalize",color:"#0a323c"}),...u("--beam-SelectSubscriptionNonprofit-descriptionPrefix",{marginTop:"3px",color:"#2f302d",fontSize:"14px",fontWeight:"bold",fontStyle:"normal",lineHeight:"138%"}),...u("--beam-SelectSubscriptionNonprofit-description",{marginTop:"3px",color:"#2f302d",fontSize:"14px",fontStyle:"normal",lineHeight:"138%"}),"--beam-SelectSubscriptionNonprofit-details-cause-letterSpacing":"0.36px",...u("--beam-SelectSubscriptionNonprofit-details-cause",{fontSize:"12px",fontWeight:"bold",color:"#0a323c",fontStyle:"normal",lineHeight:"120%"}),...u("--beam-SelectSubscriptionNonprofit-details-description",{fontSize:"12px",marginTop:"5px",fontStyle:"normal",lineHeight:"140%",fontWeight:"400"}),"--beam-SelectSubscriptionNonprofit-details-fundingProgress-marginTop":"7px",...u("--beam-SelectSubscriptionNonprofit-details-funding-progress-label",{fontSize:"12px",color:"#666666",fontWeight:"400",fontStyle:"normal"}),"--beam-SelectSubscriptionNonprofit-stickyFooter-boxShadow":"0px -20px 20px 0px rgba(0, 0, 0, 0.04)","--beam-SelectSubscriptionNonprofit-stickyFooter-padding":"15px 0px 45px","--beam-SelectSubscriptionNonprofit-stickyFooter-backgroundColor":"white","--beam-SelectSubscriptionNonprofit-stickyFooter-marginLeft":"-15px","--beam-SelectSubscriptionNonprofit-stickyFooter-marginRight":"-15px","--beam-SelectSubscriptionNonprofit-stickyFooter-width":"auto"},t=this.nonprofitListDataController?.data?.config?.web?.theme||{},e={...o,...t};return Object.assign(Object.create({toCSS(){return z(this)}}),e)}render(){const{selectedNonprofitId:o}=this,{data:t,loading:e}=this.nonprofitListDataController;if(e&&!t)return H();if(this.nonprofitListDataController.error)return this.debug?N({error:this.nonprofitListDataController.error}):"";if(this.subscriptionUpdateDataController.error&&this.debug)return N({error:this.subscriptionUpdateDataController.error});if(t==null)return this.debug?N({error:new K("No data")}):"";const i=t?.nonprofits||[],b=i.find(r=>r.nonprofit.id===o)||null,a=this.cssVariables["--beam-SelectSubscriptionNonprofit-cardStyle"],f=a==="'icon'"||a==="'selected_icon'";return S`
|
|
1
|
+
import{f as I,g as p,t as D,h as L,y as S,u as M,q as x,m as F}from"../chunks/lit-3QHn3fwl.esm.js";import{d as P}from"../chunks/lodash-P8OIs-at.esm.js";import{D as A,f as U,u as W,S as R}from"../chunks/routes-2U31lJuH.esm.js";import{u as d,A as k,d as u,a as z,_ as N,i as l}from"../chunks/localize-IRs8JglT.esm.js";import{p as E}from"../chunks/progress-bar-HVG_n8_6.esm.js";import{c as _,d as j,e as v}from"../chunks/enforce-config-HksNiOMu.esm.js";import{_ as H}from"../chunks/loading-template-mLjOGXMj.esm.js";import{makeApiKeyHeader as C}from"../utils/makeApiKeyHeader.esm.js";import{B as K}from"../chunks/beam-errors-P-Lu07Ce.esm.js";import{createScopedLocalStorage as O}from"../utils/local-storage.esm.js";import{c as Y}from"../chunks/css-card-grid-r6wxRbPV.esm.js";import{_ as G}from"../chunks/checkbox-P2JYPqxl.esm.js";import{c as q}from"../chunks/events-_4nImo3u.esm.js";import"./beam-partner-logos.esm.js";import"../utils/logger.esm.js";const m={en:{ctaTitle:()=>"Choose Your Impact",ctaMessagePrefix:()=>" at no extra cost.",ctaMessage:({donationPercentage:n="1%"}={})=>`Choose a nonprofit and ${n} will be donated there for you with every order of your subscription,`,submitButtonText:()=>"Confirm",submitButtonTextCompleted:()=>"Confirmed!",chooseButtonText:()=>"Choose"},fr:{ctaTitle:()=>"Choose Your Impact",ctaMessagePrefix:()=>" at no extra cost.",ctaMessage:({donationPercentage:n="1%"}={})=>`Choose a nonprofit and ${n} will be donated there for you with every order of your subscription,`,submitButtonText:()=>"Confirm",submitButtonTextCompleted:()=>"Confirmed!",chooseButtonText:()=>"Choose"},de:{ctaTitle:()=>"Choose Your Impact",ctaMessagePrefix:()=>" at no extra cost.",ctaMessage:({donationPercentage:n="1%"}={})=>`Choose a nonprofit and ${n} will be donated there for you with every order of your subscription,`,submitButtonText:()=>"Confirm",submitButtonTextCompleted:()=>"Confirmed!",chooseButtonText:()=>"Choose"},es:{ctaTitle:()=>"Choose Your Impact",ctaMessagePrefix:()=>" at no extra cost.",ctaMessage:({donationPercentage:n="1%"}={})=>`Choose a nonprofit and ${n} will be donated there for you with every order of your subscription,`,submitButtonText:()=>"Confirm",submitButtonTextCompleted:()=>"Confirmed!",chooseButtonText:()=>"Choose"},it:{ctaTitle:()=>"Choose Your Impact",ctaMessagePrefix:()=>" at no extra cost.",ctaMessage:({donationPercentage:n="1%"}={})=>`Choose a nonprofit and ${n} will be donated there for you with every order of your subscription,`,submitButtonText:()=>"Confirm",submitButtonTextCompleted:()=>"Confirmed!",chooseButtonText:()=>"Choose"},pl:{ctaTitle:()=>"Choose Your Impact",ctaMessagePrefix:()=>" at no extra cost.",ctaMessage:({donationPercentage:n="1%"}={})=>`Choose a nonprofit and ${n} will be donated there for you with every order of your subscription,`,submitButtonText:()=>"Confirm",submitButtonTextCompleted:()=>"Confirmed!",chooseButtonText:()=>"Choose"}};var V=Object.defineProperty,J=Object.getOwnPropertyDescriptor,c=(n,o,t,e)=>{for(var i=e>1?void 0:e?J(o,t):o,b=n.length-1,a;b>=0;b--)(a=n[b])&&(i=(e?a(o,t,i):a(i))||i);return e&&i&&V(o,t,i),i};const Q=2*60*60*1e3;class s extends L{constructor(){super(...arguments),this.baseUrl=A,this.lang="en",this.debug=!1,this.isMobile=window.innerWidth<768,this.getChainNonprofits=async()=>{v(["apiKey","subscriptionId","storeId"],this);const o=await U({baseUrl:this.baseUrl,headers:C(this.apiKey),requestBody:{storeId:this.storeId,postalCode:this.postalCode,countryCode:this.countryCode,widgetName:"select-subscription-nonprofit",version:"1.0.0",lang:this.configLang}});return this.localStorage.setItemJson("chainNonprofits",{createdAt:new Date,data:o}),o},this.updateNonprofitIdForSubscription=async({selectedNonprofitId:o})=>this.subscriptionId?(v(["apiKey","subscriptionId"],this),W({baseUrl:this.baseUrl,headers:C(this.apiKey),requestBody:{remoteSubscriptionId:this.subscriptionId,nonprofitId:o,selectionMethod:"dashboard"}})):null,this.nonprofitListDataController=new k(this,this.getChainNonprofits),this.subscriptionUpdateDataController=new k(this,this.updateNonprofitIdForSubscription),this.localStorage=O(this),this.makeHandleSelect=(o,t,e)=>async i=>{if(!this.allowChange)return;const b=this.selectedNonprofitId;if(i instanceof KeyboardEvent){let a=null;switch(i.key){case"ArrowUp":case"ArrowLeft":t===0?a=e[e.length-1]:a=e[t-1],i.preventDefault();break;case"ArrowRight":case"ArrowDown":t===e.length-1?a=e[0]:a=e[t+1],i.preventDefault();break;case"Enter":case" ":i.preventDefault();break;default:return}if(a){const f=this.renderRoot.querySelector(`[data-value="${a.nonprofit.id}"]`);f!==null&&(f.tabIndex=0,f.focus());return}}if(i.currentTarget instanceof HTMLElement){if(b===o)return;this.selectedNonprofitId=o}},this.handleSubmit=async()=>{const{selectedNonprofitId:o}=this;if(!this.allowSubmit||o==null)return;await this.subscriptionUpdateDataController.exec({selectedNonprofitId:o});const t=this.nonprofitListDataController?.data?.nonprofits.find(e=>e.nonprofit.id===o);this.dispatchEvent(new q({selectedNonprofitId:o,nonprofitName:t?.nonprofit.name}))},this.evaluateBreakPoints=P(()=>{this.isMobile=window.innerWidth<768},50,{maxWait:50,leading:!0})}get configLang(){return R[this.lang]||"en"}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.evaluateBreakPoints)}async firstUpdated(o){await this.restoreStateFromCache()}async updated(o){const t=["baseUrl","storeId","apiKey","countryCode","postalCode","lang"];for(const e of t)if(o.has(e)){await this.nonprofitListDataController.exec();break}}disconnectedCallback(){super.disconnectedCallback()}restoreStateFromCache(){v(["apiKey"],this);try{const{createdAt:o=0,data:t}=this.localStorage.getItemJson("chainNonprofits")||{};new Date(o).valueOf()+Q>new Date().valueOf()&&(this.nonprofitListDataController.data=t,this.nonprofitListDataController.loading=!1)}catch{}}get allowChange(){return this.subscriptionUpdateDataController.data==null&&!this.subscriptionUpdateDataController.loading}get allowSubmit(){return!!(this.selectedNonprofitId&&this.allowChange)}get cssVariables(){const o={...E,"--beam-fontFamily":"inherit","--beam-fontStyle":"inherit","--beam-fontSize":"inherit","--beam-textColor":"inherit","--beam-backgroundColor":"inherit","--beam-SelectSubscriptionNonprofit-maxWidth":"800px","--beam-SelectSubscriptionNonprofit-mobile-header-alignItems":"center","--beam-SelectSubscriptionNonprofit-desktop-header-alignItems":"center","--beam-SelectSubscriptionNonprofit-headerContainer-padding":"2px","--beam-SelectSubscriptionNonprofit-title-textAlign":"inherit","--beam-SelectSubscriptionNonprofit-description-textAlign":"center","--beam-SelectSubscriptionNonprofit-desktop-description-width":"80%","--beam-SelectSubscriptionNonprofit-mobile-description-width":"90%","--beam-SelectSubscriptionNonprofit-options-marginTop":"10px","--beam-SelectSubscriptionNonprofit-options-padding":"10px","--beam-SelectSubscriptionNonprofit-options-borderWidth":"1px","--beam-SelectSubscriptionNonprofit-options-borderColor":"transparent","--beam-SelectSubscriptionNonprofit-options-borderRadius":"8px","--beam-SelectSubscriptionNonprofit-options-backgroundColor":"#F9FBFB","--beam-SelectSubscriptionNonprofit-option-padding":"15px","--beam-SelectSubscriptionNonprofit-options-hover-backgroundColor":"#e1f1ee","--beam-SelectSubscriptionNonprofit-options-hover-borderWidth":"1px","--beam-SelectSubscriptionNonprofit-options-hover-borderColor":"#e1f1ee","--beam-SelectSubscriptionNonprofit-options-selected-borderWidth":"1px","--beam-SelectSubscriptionNonprofit-options-selected-borderColor":"#e1f1ee","--beam-SelectSubscriptionNonprofit-options-selected-backgroundColor":"#e1f1ee","--beam-SelectSubscriptionNonprofit-options-gap":"20px","--beam-SelectSubscriptionNonprofit-options-minWidth":"250px","--beam-SelectSubscriptionNonprofit-options-columnCount":"2","--beam-SelectSubscriptionNonprofit-options-icon-borderRadius":"4px","--beam-SelectSubscriptionNonprofit-options-icon-padding":"10px","--beam-SelectSubscriptionNonprofit-options-image-borderRadius":"4px","--beam-SelectSubscriptionNonprofit-cardIconContainer-height":"100%","--beam-SelectSubscriptionNonprofit-iconBackground-width":"50px","--beam-SelectSubscriptionNonprofit-iconBackground-height":"50px","--beam-SelectSubscriptionNonprofit-iconBackground-borderRadius":"50%","--beam-SelectSubscriptionNonprofit-iconBackground-background":"#0a323c","--beam-SelectSubscriptionNonprofit-icon-height":"50px","--beam-SelectSubscriptionNonprofit-checkmark-backgroundColor":"transparent","--beam-SelectSubscriptionNonprofit-checkmark-color":"transparent","--beam-SelectSubscriptionNonprofit-checkmark-borderColor":"#0A323C","--beam-SelectSubscriptionNonprofit-checkmark-selected-color":"#fff","--beam-SelectSubscriptionNonprofit-checkmark-selected-backgroundColor":"#0A323C","--beam-SelectSubscriptionNonprofit-checkmark-selected-borderColor":"#0A323C","--beam-SelectSubscriptionNonprofit-checkmark-hover-color":"#fff","--beam-SelectSubscriptionNonprofit-checkmark-hover-backgroundColor":"#0A323C","--beam-SelectSubscriptionNonprofit-checkmark-hover-borderColor":"#0A323C","--beam-SelectSubscriptionNonprofit-cardStyle":"'selected_icon'","--beam-SelectSubscriptionNonprofit-submitButton-color":"#fff","--beam-SelectSubscriptionNonprofit-submitButton-hover-color":"#fff","--beam-SelectSubscriptionNonprofit-submitButton-disabled-color":"#fff","--beam-SelectSubscriptionNonprofit-submitButton-backgroundColor":"#0A323C","--beam-SelectSubscriptionNonprofit-submitButton-hover-backgroundColor":"#222","--beam-SelectSubscriptionNonprofit-submitButton-disabled-backgroundColor":"#767676","--beam-SelectSubscriptionNonprofit-submitButton-borderColor":"#333","--beam-SelectSubscriptionNonprofit-submitButton-hover-borderColor":"#222","--beam-SelectSubscriptionNonprofit-submitButton-disabled-borderColor":"#767676","--beam-SelectSubscriptionNonprofit-submitButton-fontSize":"14px","--beam-SelectSubscriptionNonprofit-submitButton-fontWeight":"inherit","--beam-SelectSubscriptionNonprofit-submitButton-fontFamily":"inherit","--beam-SelectSubscriptionNonprofit-submitButton-textTransform":"none","--beam-SelectSubscriptionNonprofit-submitButton-borderRadius":"30px","--beam-SelectSubscriptionNonprofit-submitButton-padding":"10px 30px",...u("--beam-SelectSubscriptionNonprofit-title",{fontSize:"20px",fontWeight:"bold",lineHeight:"120%",textTransform:"capitalize",color:"#0a323c"}),...u("--beam-SelectSubscriptionNonprofit-descriptionPrefix",{marginTop:"3px",color:"#2f302d",fontSize:"14px",fontWeight:"bold",fontStyle:"normal",lineHeight:"138%"}),...u("--beam-SelectSubscriptionNonprofit-description",{marginTop:"3px",color:"#2f302d",fontSize:"14px",fontStyle:"normal",lineHeight:"138%"}),"--beam-SelectSubscriptionNonprofit-details-cause-letterSpacing":"0.36px",...u("--beam-SelectSubscriptionNonprofit-details-cause",{fontSize:"12px",fontWeight:"bold",color:"#0a323c",fontStyle:"normal",lineHeight:"120%"}),...u("--beam-SelectSubscriptionNonprofit-details-description",{fontSize:"12px",marginTop:"5px",fontStyle:"normal",lineHeight:"140%",fontWeight:"400"}),"--beam-SelectSubscriptionNonprofit-details-fundingProgress-marginTop":"7px",...u("--beam-SelectSubscriptionNonprofit-details-funding-progress-label",{fontSize:"12px",color:"#666666",fontWeight:"400",fontStyle:"normal"}),"--beam-SelectSubscriptionNonprofit-stickyFooter-boxShadow":"0px -20px 20px 0px rgba(0, 0, 0, 0.04)","--beam-SelectSubscriptionNonprofit-stickyFooter-padding":"15px 0px 45px","--beam-SelectSubscriptionNonprofit-stickyFooter-backgroundColor":"white","--beam-SelectSubscriptionNonprofit-stickyFooter-marginLeft":"-15px","--beam-SelectSubscriptionNonprofit-stickyFooter-marginRight":"-15px","--beam-SelectSubscriptionNonprofit-stickyFooter-width":"auto"},t=this.nonprofitListDataController?.data?.config?.web?.theme||{},e={...o,...t};return Object.assign(Object.create({toCSS(){return z(this)}}),e)}render(){const{selectedNonprofitId:o}=this,{data:t,loading:e}=this.nonprofitListDataController;if(e&&!t)return H();if(this.nonprofitListDataController.error)return this.debug?N({error:this.nonprofitListDataController.error}):"";if(this.subscriptionUpdateDataController.error&&this.debug)return N({error:this.subscriptionUpdateDataController.error});if(t==null)return this.debug?N({error:new K("No data")}):"";const i=t?.nonprofits||[],b=i.find(r=>r.nonprofit.id===o)||null,a=this.cssVariables["--beam-SelectSubscriptionNonprofit-cardStyle"],f=a==="'icon'"||a==="'selected_icon'";return S`
|
|
2
2
|
<style>
|
|
3
3
|
:host {
|
|
4
4
|
${this.cssVariables.toCSS()}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{f as I,g as p,t as D,h as L,y as S,u as M,q as x,m as F}from"../chunks/lit-3QHn3fwl.esm.js";import{d as P}from"../chunks/lodash-P8OIs-at.esm.js";import{D as A,f as U,u as W,S as R}from"../chunks/routes-sc6xljWU.esm.js";import{u as d,A as k,d as u,a as z,_ as N,i as l}from"../chunks/localize-SsJbTmMj.esm.js";import{p as E}from"../chunks/progress-bar-HVG_n8_6.esm.js";import{c as _,d as j,e as v}from"../chunks/enforce-config-er6B5Gkj.esm.js";import{_ as H}from"../chunks/loading-template-mLjOGXMj.esm.js";import{makeApiKeyHeader as C}from"../utils/makeApiKeyHeader.js";import{B as K}from"../chunks/beam-errors-P-Lu07Ce.esm.js";import{createScopedLocalStorage as O}from"../utils/local-storage.js";import{c as Y}from"../chunks/css-card-grid-r6wxRbPV.esm.js";import{_ as G}from"../chunks/checkbox-P2JYPqxl.esm.js";import{c as q}from"../chunks/events-_4nImo3u.esm.js";import"./beam-partner-logos.js";import"../utils/logger.js";const m={en:{ctaTitle:()=>"Choose Your Impact",ctaMessagePrefix:()=>" at no extra cost.",ctaMessage:({donationPercentage:n="1%"}={})=>`Choose a nonprofit and ${n} will be donated there for you with every order of your subscription,`,submitButtonText:()=>"Confirm",submitButtonTextCompleted:()=>"Confirmed!",chooseButtonText:()=>"Choose"},fr:{ctaTitle:()=>"Choose Your Impact",ctaMessagePrefix:()=>" at no extra cost.",ctaMessage:({donationPercentage:n="1%"}={})=>`Choose a nonprofit and ${n} will be donated there for you with every order of your subscription,`,submitButtonText:()=>"Confirm",submitButtonTextCompleted:()=>"Confirmed!",chooseButtonText:()=>"Choose"},de:{ctaTitle:()=>"Choose Your Impact",ctaMessagePrefix:()=>" at no extra cost.",ctaMessage:({donationPercentage:n="1%"}={})=>`Choose a nonprofit and ${n} will be donated there for you with every order of your subscription,`,submitButtonText:()=>"Confirm",submitButtonTextCompleted:()=>"Confirmed!",chooseButtonText:()=>"Choose"},es:{ctaTitle:()=>"Choose Your Impact",ctaMessagePrefix:()=>" at no extra cost.",ctaMessage:({donationPercentage:n="1%"}={})=>`Choose a nonprofit and ${n} will be donated there for you with every order of your subscription,`,submitButtonText:()=>"Confirm",submitButtonTextCompleted:()=>"Confirmed!",chooseButtonText:()=>"Choose"},it:{ctaTitle:()=>"Choose Your Impact",ctaMessagePrefix:()=>" at no extra cost.",ctaMessage:({donationPercentage:n="1%"}={})=>`Choose a nonprofit and ${n} will be donated there for you with every order of your subscription,`,submitButtonText:()=>"Confirm",submitButtonTextCompleted:()=>"Confirmed!",chooseButtonText:()=>"Choose"},pl:{ctaTitle:()=>"Choose Your Impact",ctaMessagePrefix:()=>" at no extra cost.",ctaMessage:({donationPercentage:n="1%"}={})=>`Choose a nonprofit and ${n} will be donated there for you with every order of your subscription,`,submitButtonText:()=>"Confirm",submitButtonTextCompleted:()=>"Confirmed!",chooseButtonText:()=>"Choose"}};var V=Object.defineProperty,J=Object.getOwnPropertyDescriptor,c=(n,o,t,e)=>{for(var i=e>1?void 0:e?J(o,t):o,b=n.length-1,a;b>=0;b--)(a=n[b])&&(i=(e?a(o,t,i):a(i))||i);return e&&i&&V(o,t,i),i};const Q=2*60*60*1e3;class s extends L{constructor(){super(...arguments),this.baseUrl=A,this.lang="en",this.debug=!1,this.isMobile=window.innerWidth<768,this.getChainNonprofits=async()=>{v(["apiKey","subscriptionId","storeId"],this);const o=await U({baseUrl:this.baseUrl,headers:C(this.apiKey),requestBody:{storeId:this.storeId,postalCode:this.postalCode,countryCode:this.countryCode,widgetName:"select-subscription-nonprofit",version:"1.0.0",lang:this.configLang}});return this.localStorage.setItemJson("chainNonprofits",{createdAt:new Date,data:o}),o},this.updateNonprofitIdForSubscription=async({selectedNonprofitId:o})=>this.subscriptionId?(v(["apiKey","subscriptionId"],this),W({baseUrl:this.baseUrl,headers:C(this.apiKey),requestBody:{remoteSubscriptionId:this.subscriptionId,nonprofitId:o,selectionMethod:"dashboard"}})):null,this.nonprofitListDataController=new k(this,this.getChainNonprofits),this.subscriptionUpdateDataController=new k(this,this.updateNonprofitIdForSubscription),this.localStorage=O(this),this.makeHandleSelect=(o,t,e)=>async i=>{if(!this.allowChange)return;const b=this.selectedNonprofitId;if(i instanceof KeyboardEvent){let a=null;switch(i.key){case"ArrowUp":case"ArrowLeft":t===0?a=e[e.length-1]:a=e[t-1],i.preventDefault();break;case"ArrowRight":case"ArrowDown":t===e.length-1?a=e[0]:a=e[t+1],i.preventDefault();break;case"Enter":case" ":i.preventDefault();break;default:return}if(a){const f=this.renderRoot.querySelector(`[data-value="${a.nonprofit.id}"]`);f!==null&&(f.tabIndex=0,f.focus());return}}if(i.currentTarget instanceof HTMLElement){if(b===o)return;this.selectedNonprofitId=o}},this.handleSubmit=async()=>{const{selectedNonprofitId:o}=this;if(!this.allowSubmit||o==null)return;await this.subscriptionUpdateDataController.exec({selectedNonprofitId:o});const t=this.nonprofitListDataController?.data?.nonprofits.find(e=>e.nonprofit.id===o);this.dispatchEvent(new q({selectedNonprofitId:o,nonprofitName:t?.nonprofit.name}))},this.evaluateBreakPoints=P(()=>{this.isMobile=window.innerWidth<768},50,{maxWait:50,leading:!0})}get configLang(){return R[this.lang]||"en"}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.evaluateBreakPoints)}async firstUpdated(o){await this.restoreStateFromCache()}async updated(o){const t=["baseUrl","storeId","apiKey","countryCode","postalCode","lang"];for(const e of t)if(o.has(e)){await this.nonprofitListDataController.exec();break}}disconnectedCallback(){super.disconnectedCallback()}restoreStateFromCache(){v(["apiKey"],this);try{const{createdAt:o=0,data:t}=this.localStorage.getItemJson("chainNonprofits")||{};new Date(o).valueOf()+Q>new Date().valueOf()&&(this.nonprofitListDataController.data=t,this.nonprofitListDataController.loading=!1)}catch{}}get allowChange(){return this.subscriptionUpdateDataController.data==null&&!this.subscriptionUpdateDataController.loading}get allowSubmit(){return!!(this.selectedNonprofitId&&this.allowChange)}get cssVariables(){const o={...E,"--beam-fontFamily":"inherit","--beam-fontStyle":"inherit","--beam-fontSize":"inherit","--beam-textColor":"inherit","--beam-backgroundColor":"inherit","--beam-SelectSubscriptionNonprofit-maxWidth":"800px","--beam-SelectSubscriptionNonprofit-mobile-header-alignItems":"center","--beam-SelectSubscriptionNonprofit-desktop-header-alignItems":"center","--beam-SelectSubscriptionNonprofit-headerContainer-padding":"2px","--beam-SelectSubscriptionNonprofit-title-textAlign":"inherit","--beam-SelectSubscriptionNonprofit-description-textAlign":"center","--beam-SelectSubscriptionNonprofit-desktop-description-width":"80%","--beam-SelectSubscriptionNonprofit-mobile-description-width":"90%","--beam-SelectSubscriptionNonprofit-options-marginTop":"10px","--beam-SelectSubscriptionNonprofit-options-padding":"10px","--beam-SelectSubscriptionNonprofit-options-borderWidth":"1px","--beam-SelectSubscriptionNonprofit-options-borderColor":"transparent","--beam-SelectSubscriptionNonprofit-options-borderRadius":"8px","--beam-SelectSubscriptionNonprofit-options-backgroundColor":"#F9FBFB","--beam-SelectSubscriptionNonprofit-option-padding":"15px","--beam-SelectSubscriptionNonprofit-options-hover-backgroundColor":"#e1f1ee","--beam-SelectSubscriptionNonprofit-options-hover-borderWidth":"1px","--beam-SelectSubscriptionNonprofit-options-hover-borderColor":"#e1f1ee","--beam-SelectSubscriptionNonprofit-options-selected-borderWidth":"1px","--beam-SelectSubscriptionNonprofit-options-selected-borderColor":"#e1f1ee","--beam-SelectSubscriptionNonprofit-options-selected-backgroundColor":"#e1f1ee","--beam-SelectSubscriptionNonprofit-options-gap":"20px","--beam-SelectSubscriptionNonprofit-options-minWidth":"250px","--beam-SelectSubscriptionNonprofit-options-columnCount":"2","--beam-SelectSubscriptionNonprofit-options-icon-borderRadius":"4px","--beam-SelectSubscriptionNonprofit-options-icon-padding":"10px","--beam-SelectSubscriptionNonprofit-options-image-borderRadius":"4px","--beam-SelectSubscriptionNonprofit-cardIconContainer-height":"100%","--beam-SelectSubscriptionNonprofit-iconBackground-width":"50px","--beam-SelectSubscriptionNonprofit-iconBackground-height":"50px","--beam-SelectSubscriptionNonprofit-iconBackground-borderRadius":"50%","--beam-SelectSubscriptionNonprofit-iconBackground-background":"#0a323c","--beam-SelectSubscriptionNonprofit-icon-height":"50px","--beam-SelectSubscriptionNonprofit-checkmark-backgroundColor":"transparent","--beam-SelectSubscriptionNonprofit-checkmark-color":"transparent","--beam-SelectSubscriptionNonprofit-checkmark-borderColor":"#0A323C","--beam-SelectSubscriptionNonprofit-checkmark-selected-color":"#fff","--beam-SelectSubscriptionNonprofit-checkmark-selected-backgroundColor":"#0A323C","--beam-SelectSubscriptionNonprofit-checkmark-selected-borderColor":"#0A323C","--beam-SelectSubscriptionNonprofit-checkmark-hover-color":"#fff","--beam-SelectSubscriptionNonprofit-checkmark-hover-backgroundColor":"#0A323C","--beam-SelectSubscriptionNonprofit-checkmark-hover-borderColor":"#0A323C","--beam-SelectSubscriptionNonprofit-cardStyle":"'selected_icon'","--beam-SelectSubscriptionNonprofit-submitButton-color":"#fff","--beam-SelectSubscriptionNonprofit-submitButton-hover-color":"#fff","--beam-SelectSubscriptionNonprofit-submitButton-disabled-color":"#fff","--beam-SelectSubscriptionNonprofit-submitButton-backgroundColor":"#0A323C","--beam-SelectSubscriptionNonprofit-submitButton-hover-backgroundColor":"#222","--beam-SelectSubscriptionNonprofit-submitButton-disabled-backgroundColor":"#767676","--beam-SelectSubscriptionNonprofit-submitButton-borderColor":"#333","--beam-SelectSubscriptionNonprofit-submitButton-hover-borderColor":"#222","--beam-SelectSubscriptionNonprofit-submitButton-disabled-borderColor":"#767676","--beam-SelectSubscriptionNonprofit-submitButton-fontSize":"14px","--beam-SelectSubscriptionNonprofit-submitButton-fontWeight":"inherit","--beam-SelectSubscriptionNonprofit-submitButton-fontFamily":"inherit","--beam-SelectSubscriptionNonprofit-submitButton-textTransform":"none","--beam-SelectSubscriptionNonprofit-submitButton-borderRadius":"30px","--beam-SelectSubscriptionNonprofit-submitButton-padding":"10px 30px",...u("--beam-SelectSubscriptionNonprofit-title",{fontSize:"20px",fontWeight:"bold",lineHeight:"120%",textTransform:"capitalize",color:"#0a323c"}),...u("--beam-SelectSubscriptionNonprofit-descriptionPrefix",{marginTop:"3px",color:"#2f302d",fontSize:"14px",fontWeight:"bold",fontStyle:"normal",lineHeight:"138%"}),...u("--beam-SelectSubscriptionNonprofit-description",{marginTop:"3px",color:"#2f302d",fontSize:"14px",fontStyle:"normal",lineHeight:"138%"}),"--beam-SelectSubscriptionNonprofit-details-cause-letterSpacing":"0.36px",...u("--beam-SelectSubscriptionNonprofit-details-cause",{fontSize:"12px",fontWeight:"bold",color:"#0a323c",fontStyle:"normal",lineHeight:"120%"}),...u("--beam-SelectSubscriptionNonprofit-details-description",{fontSize:"12px",marginTop:"5px",fontStyle:"normal",lineHeight:"140%",fontWeight:"400"}),"--beam-SelectSubscriptionNonprofit-details-fundingProgress-marginTop":"7px",...u("--beam-SelectSubscriptionNonprofit-details-funding-progress-label",{fontSize:"12px",color:"#666666",fontWeight:"400",fontStyle:"normal"}),"--beam-SelectSubscriptionNonprofit-stickyFooter-boxShadow":"0px -20px 20px 0px rgba(0, 0, 0, 0.04)","--beam-SelectSubscriptionNonprofit-stickyFooter-padding":"15px 0px 45px","--beam-SelectSubscriptionNonprofit-stickyFooter-backgroundColor":"white","--beam-SelectSubscriptionNonprofit-stickyFooter-marginLeft":"-15px","--beam-SelectSubscriptionNonprofit-stickyFooter-marginRight":"-15px","--beam-SelectSubscriptionNonprofit-stickyFooter-width":"auto"},t=this.nonprofitListDataController?.data?.config?.web?.theme||{},e={...o,...t};return Object.assign(Object.create({toCSS(){return z(this)}}),e)}render(){const{selectedNonprofitId:o}=this,{data:t,loading:e}=this.nonprofitListDataController;if(e&&!t)return H();if(this.nonprofitListDataController.error)return this.debug?N({error:this.nonprofitListDataController.error}):"";if(this.subscriptionUpdateDataController.error&&this.debug)return N({error:this.subscriptionUpdateDataController.error});if(t==null)return this.debug?N({error:new K("No data")}):"";const i=t?.nonprofits||[],b=i.find(r=>r.nonprofit.id===o)||null,a=this.cssVariables["--beam-SelectSubscriptionNonprofit-cardStyle"],f=a==="'icon'"||a==="'selected_icon'";return S`
|
|
1
|
+
import{f as I,g as p,t as D,h as L,y as S,u as M,q as x,m as F}from"../chunks/lit-3QHn3fwl.esm.js";import{d as P}from"../chunks/lodash-P8OIs-at.esm.js";import{D as A,f as U,u as W,S as R}from"../chunks/routes-nWhY4Rgg.esm.js";import{u as d,A as k,d as u,a as z,_ as N,i as l}from"../chunks/localize-SsJbTmMj.esm.js";import{p as E}from"../chunks/progress-bar-HVG_n8_6.esm.js";import{c as _,d as j,e as v}from"../chunks/enforce-config-er6B5Gkj.esm.js";import{_ as H}from"../chunks/loading-template-mLjOGXMj.esm.js";import{makeApiKeyHeader as C}from"../utils/makeApiKeyHeader.js";import{B as K}from"../chunks/beam-errors-P-Lu07Ce.esm.js";import{createScopedLocalStorage as O}from"../utils/local-storage.js";import{c as Y}from"../chunks/css-card-grid-r6wxRbPV.esm.js";import{_ as G}from"../chunks/checkbox-P2JYPqxl.esm.js";import{c as q}from"../chunks/events-_4nImo3u.esm.js";import"./beam-partner-logos.js";import"../utils/logger.js";const m={en:{ctaTitle:()=>"Choose Your Impact",ctaMessagePrefix:()=>" at no extra cost.",ctaMessage:({donationPercentage:n="1%"}={})=>`Choose a nonprofit and ${n} will be donated there for you with every order of your subscription,`,submitButtonText:()=>"Confirm",submitButtonTextCompleted:()=>"Confirmed!",chooseButtonText:()=>"Choose"},fr:{ctaTitle:()=>"Choose Your Impact",ctaMessagePrefix:()=>" at no extra cost.",ctaMessage:({donationPercentage:n="1%"}={})=>`Choose a nonprofit and ${n} will be donated there for you with every order of your subscription,`,submitButtonText:()=>"Confirm",submitButtonTextCompleted:()=>"Confirmed!",chooseButtonText:()=>"Choose"},de:{ctaTitle:()=>"Choose Your Impact",ctaMessagePrefix:()=>" at no extra cost.",ctaMessage:({donationPercentage:n="1%"}={})=>`Choose a nonprofit and ${n} will be donated there for you with every order of your subscription,`,submitButtonText:()=>"Confirm",submitButtonTextCompleted:()=>"Confirmed!",chooseButtonText:()=>"Choose"},es:{ctaTitle:()=>"Choose Your Impact",ctaMessagePrefix:()=>" at no extra cost.",ctaMessage:({donationPercentage:n="1%"}={})=>`Choose a nonprofit and ${n} will be donated there for you with every order of your subscription,`,submitButtonText:()=>"Confirm",submitButtonTextCompleted:()=>"Confirmed!",chooseButtonText:()=>"Choose"},it:{ctaTitle:()=>"Choose Your Impact",ctaMessagePrefix:()=>" at no extra cost.",ctaMessage:({donationPercentage:n="1%"}={})=>`Choose a nonprofit and ${n} will be donated there for you with every order of your subscription,`,submitButtonText:()=>"Confirm",submitButtonTextCompleted:()=>"Confirmed!",chooseButtonText:()=>"Choose"},pl:{ctaTitle:()=>"Choose Your Impact",ctaMessagePrefix:()=>" at no extra cost.",ctaMessage:({donationPercentage:n="1%"}={})=>`Choose a nonprofit and ${n} will be donated there for you with every order of your subscription,`,submitButtonText:()=>"Confirm",submitButtonTextCompleted:()=>"Confirmed!",chooseButtonText:()=>"Choose"}};var V=Object.defineProperty,J=Object.getOwnPropertyDescriptor,c=(n,o,t,e)=>{for(var i=e>1?void 0:e?J(o,t):o,b=n.length-1,a;b>=0;b--)(a=n[b])&&(i=(e?a(o,t,i):a(i))||i);return e&&i&&V(o,t,i),i};const Q=2*60*60*1e3;class s extends L{constructor(){super(...arguments),this.baseUrl=A,this.lang="en",this.debug=!1,this.isMobile=window.innerWidth<768,this.getChainNonprofits=async()=>{v(["apiKey","subscriptionId","storeId"],this);const o=await U({baseUrl:this.baseUrl,headers:C(this.apiKey),requestBody:{storeId:this.storeId,postalCode:this.postalCode,countryCode:this.countryCode,widgetName:"select-subscription-nonprofit",version:"1.0.0",lang:this.configLang}});return this.localStorage.setItemJson("chainNonprofits",{createdAt:new Date,data:o}),o},this.updateNonprofitIdForSubscription=async({selectedNonprofitId:o})=>this.subscriptionId?(v(["apiKey","subscriptionId"],this),W({baseUrl:this.baseUrl,headers:C(this.apiKey),requestBody:{remoteSubscriptionId:this.subscriptionId,nonprofitId:o,selectionMethod:"dashboard"}})):null,this.nonprofitListDataController=new k(this,this.getChainNonprofits),this.subscriptionUpdateDataController=new k(this,this.updateNonprofitIdForSubscription),this.localStorage=O(this),this.makeHandleSelect=(o,t,e)=>async i=>{if(!this.allowChange)return;const b=this.selectedNonprofitId;if(i instanceof KeyboardEvent){let a=null;switch(i.key){case"ArrowUp":case"ArrowLeft":t===0?a=e[e.length-1]:a=e[t-1],i.preventDefault();break;case"ArrowRight":case"ArrowDown":t===e.length-1?a=e[0]:a=e[t+1],i.preventDefault();break;case"Enter":case" ":i.preventDefault();break;default:return}if(a){const f=this.renderRoot.querySelector(`[data-value="${a.nonprofit.id}"]`);f!==null&&(f.tabIndex=0,f.focus());return}}if(i.currentTarget instanceof HTMLElement){if(b===o)return;this.selectedNonprofitId=o}},this.handleSubmit=async()=>{const{selectedNonprofitId:o}=this;if(!this.allowSubmit||o==null)return;await this.subscriptionUpdateDataController.exec({selectedNonprofitId:o});const t=this.nonprofitListDataController?.data?.nonprofits.find(e=>e.nonprofit.id===o);this.dispatchEvent(new q({selectedNonprofitId:o,nonprofitName:t?.nonprofit.name}))},this.evaluateBreakPoints=P(()=>{this.isMobile=window.innerWidth<768},50,{maxWait:50,leading:!0})}get configLang(){return R[this.lang]||"en"}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.evaluateBreakPoints)}async firstUpdated(o){await this.restoreStateFromCache()}async updated(o){const t=["baseUrl","storeId","apiKey","countryCode","postalCode","lang"];for(const e of t)if(o.has(e)){await this.nonprofitListDataController.exec();break}}disconnectedCallback(){super.disconnectedCallback()}restoreStateFromCache(){v(["apiKey"],this);try{const{createdAt:o=0,data:t}=this.localStorage.getItemJson("chainNonprofits")||{};new Date(o).valueOf()+Q>new Date().valueOf()&&(this.nonprofitListDataController.data=t,this.nonprofitListDataController.loading=!1)}catch{}}get allowChange(){return this.subscriptionUpdateDataController.data==null&&!this.subscriptionUpdateDataController.loading}get allowSubmit(){return!!(this.selectedNonprofitId&&this.allowChange)}get cssVariables(){const o={...E,"--beam-fontFamily":"inherit","--beam-fontStyle":"inherit","--beam-fontSize":"inherit","--beam-textColor":"inherit","--beam-backgroundColor":"inherit","--beam-SelectSubscriptionNonprofit-maxWidth":"800px","--beam-SelectSubscriptionNonprofit-mobile-header-alignItems":"center","--beam-SelectSubscriptionNonprofit-desktop-header-alignItems":"center","--beam-SelectSubscriptionNonprofit-headerContainer-padding":"2px","--beam-SelectSubscriptionNonprofit-title-textAlign":"inherit","--beam-SelectSubscriptionNonprofit-description-textAlign":"center","--beam-SelectSubscriptionNonprofit-desktop-description-width":"80%","--beam-SelectSubscriptionNonprofit-mobile-description-width":"90%","--beam-SelectSubscriptionNonprofit-options-marginTop":"10px","--beam-SelectSubscriptionNonprofit-options-padding":"10px","--beam-SelectSubscriptionNonprofit-options-borderWidth":"1px","--beam-SelectSubscriptionNonprofit-options-borderColor":"transparent","--beam-SelectSubscriptionNonprofit-options-borderRadius":"8px","--beam-SelectSubscriptionNonprofit-options-backgroundColor":"#F9FBFB","--beam-SelectSubscriptionNonprofit-option-padding":"15px","--beam-SelectSubscriptionNonprofit-options-hover-backgroundColor":"#e1f1ee","--beam-SelectSubscriptionNonprofit-options-hover-borderWidth":"1px","--beam-SelectSubscriptionNonprofit-options-hover-borderColor":"#e1f1ee","--beam-SelectSubscriptionNonprofit-options-selected-borderWidth":"1px","--beam-SelectSubscriptionNonprofit-options-selected-borderColor":"#e1f1ee","--beam-SelectSubscriptionNonprofit-options-selected-backgroundColor":"#e1f1ee","--beam-SelectSubscriptionNonprofit-options-gap":"20px","--beam-SelectSubscriptionNonprofit-options-minWidth":"250px","--beam-SelectSubscriptionNonprofit-options-columnCount":"2","--beam-SelectSubscriptionNonprofit-options-icon-borderRadius":"4px","--beam-SelectSubscriptionNonprofit-options-icon-padding":"10px","--beam-SelectSubscriptionNonprofit-options-image-borderRadius":"4px","--beam-SelectSubscriptionNonprofit-cardIconContainer-height":"100%","--beam-SelectSubscriptionNonprofit-iconBackground-width":"50px","--beam-SelectSubscriptionNonprofit-iconBackground-height":"50px","--beam-SelectSubscriptionNonprofit-iconBackground-borderRadius":"50%","--beam-SelectSubscriptionNonprofit-iconBackground-background":"#0a323c","--beam-SelectSubscriptionNonprofit-icon-height":"50px","--beam-SelectSubscriptionNonprofit-checkmark-backgroundColor":"transparent","--beam-SelectSubscriptionNonprofit-checkmark-color":"transparent","--beam-SelectSubscriptionNonprofit-checkmark-borderColor":"#0A323C","--beam-SelectSubscriptionNonprofit-checkmark-selected-color":"#fff","--beam-SelectSubscriptionNonprofit-checkmark-selected-backgroundColor":"#0A323C","--beam-SelectSubscriptionNonprofit-checkmark-selected-borderColor":"#0A323C","--beam-SelectSubscriptionNonprofit-checkmark-hover-color":"#fff","--beam-SelectSubscriptionNonprofit-checkmark-hover-backgroundColor":"#0A323C","--beam-SelectSubscriptionNonprofit-checkmark-hover-borderColor":"#0A323C","--beam-SelectSubscriptionNonprofit-cardStyle":"'selected_icon'","--beam-SelectSubscriptionNonprofit-submitButton-color":"#fff","--beam-SelectSubscriptionNonprofit-submitButton-hover-color":"#fff","--beam-SelectSubscriptionNonprofit-submitButton-disabled-color":"#fff","--beam-SelectSubscriptionNonprofit-submitButton-backgroundColor":"#0A323C","--beam-SelectSubscriptionNonprofit-submitButton-hover-backgroundColor":"#222","--beam-SelectSubscriptionNonprofit-submitButton-disabled-backgroundColor":"#767676","--beam-SelectSubscriptionNonprofit-submitButton-borderColor":"#333","--beam-SelectSubscriptionNonprofit-submitButton-hover-borderColor":"#222","--beam-SelectSubscriptionNonprofit-submitButton-disabled-borderColor":"#767676","--beam-SelectSubscriptionNonprofit-submitButton-fontSize":"14px","--beam-SelectSubscriptionNonprofit-submitButton-fontWeight":"inherit","--beam-SelectSubscriptionNonprofit-submitButton-fontFamily":"inherit","--beam-SelectSubscriptionNonprofit-submitButton-textTransform":"none","--beam-SelectSubscriptionNonprofit-submitButton-borderRadius":"30px","--beam-SelectSubscriptionNonprofit-submitButton-padding":"10px 30px",...u("--beam-SelectSubscriptionNonprofit-title",{fontSize:"20px",fontWeight:"bold",lineHeight:"120%",textTransform:"capitalize",color:"#0a323c"}),...u("--beam-SelectSubscriptionNonprofit-descriptionPrefix",{marginTop:"3px",color:"#2f302d",fontSize:"14px",fontWeight:"bold",fontStyle:"normal",lineHeight:"138%"}),...u("--beam-SelectSubscriptionNonprofit-description",{marginTop:"3px",color:"#2f302d",fontSize:"14px",fontStyle:"normal",lineHeight:"138%"}),"--beam-SelectSubscriptionNonprofit-details-cause-letterSpacing":"0.36px",...u("--beam-SelectSubscriptionNonprofit-details-cause",{fontSize:"12px",fontWeight:"bold",color:"#0a323c",fontStyle:"normal",lineHeight:"120%"}),...u("--beam-SelectSubscriptionNonprofit-details-description",{fontSize:"12px",marginTop:"5px",fontStyle:"normal",lineHeight:"140%",fontWeight:"400"}),"--beam-SelectSubscriptionNonprofit-details-fundingProgress-marginTop":"7px",...u("--beam-SelectSubscriptionNonprofit-details-funding-progress-label",{fontSize:"12px",color:"#666666",fontWeight:"400",fontStyle:"normal"}),"--beam-SelectSubscriptionNonprofit-stickyFooter-boxShadow":"0px -20px 20px 0px rgba(0, 0, 0, 0.04)","--beam-SelectSubscriptionNonprofit-stickyFooter-padding":"15px 0px 45px","--beam-SelectSubscriptionNonprofit-stickyFooter-backgroundColor":"white","--beam-SelectSubscriptionNonprofit-stickyFooter-marginLeft":"-15px","--beam-SelectSubscriptionNonprofit-stickyFooter-marginRight":"-15px","--beam-SelectSubscriptionNonprofit-stickyFooter-width":"auto"},t=this.nonprofitListDataController?.data?.config?.web?.theme||{},e={...o,...t};return Object.assign(Object.create({toCSS(){return z(this)}}),e)}render(){const{selectedNonprofitId:o}=this,{data:t,loading:e}=this.nonprofitListDataController;if(e&&!t)return H();if(this.nonprofitListDataController.error)return this.debug?N({error:this.nonprofitListDataController.error}):"";if(this.subscriptionUpdateDataController.error&&this.debug)return N({error:this.subscriptionUpdateDataController.error});if(t==null)return this.debug?N({error:new K("No data")}):"";const i=t?.nonprofits||[],b=i.find(r=>r.nonprofit.id===o)||null,a=this.cssVariables["--beam-SelectSubscriptionNonprofit-cardStyle"],f=a==="'icon'"||a==="'selected_icon'";return S`
|
|
2
2
|
<style>
|
|
3
3
|
:host {
|
|
4
4
|
${this.cssVariables.toCSS()}
|