@beamimpact/web-sdk 1.43.2 → 1.45.2
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-R9RsuSGx.esm.js +2 -0
- package/dist/chunks/_share-dialog-dependencies-R9RsuSGx.esm.js.map +1 -0
- package/dist/chunks/_share-dialog-dependencies-o5GBtNTA.esm.js +2 -0
- package/dist/chunks/_share-dialog-dependencies-o5GBtNTA.esm.js.map +1 -0
- package/dist/chunks/{cart-contents-WB1BF6hG.esm.d.ts → cart-contents-HAPzwbeL.esm.d.ts} +1 -1
- package/dist/chunks/{css-card-grid-r6wxRbPV.esm.js → css-card-grid-nEc--M5M.esm.js} +2 -2
- package/dist/chunks/{css-card-grid-r6wxRbPV.esm.js.map → css-card-grid-nEc--M5M.esm.js.map} +1 -1
- package/dist/chunks/{enforce-config-HksNiOMu.esm.js → enforce-config-ZAI7WYAd.esm.js} +2 -2
- package/dist/chunks/{enforce-config-HksNiOMu.esm.js.map → enforce-config-ZAI7WYAd.esm.js.map} +1 -1
- package/dist/chunks/{enforce-config-er6B5Gkj.esm.js → enforce-config-ZyPq_4CF.esm.js} +2 -2
- package/dist/chunks/{enforce-config-er6B5Gkj.esm.js.map → enforce-config-ZyPq_4CF.esm.js.map} +1 -1
- package/dist/chunks/{events-MfRTtTVm.esm.d.ts → events-fqRWfo7p.esm.d.ts} +1 -1
- package/dist/chunks/{index-keYXyTGw.esm.js → index--JacA4R2.esm.js} +2 -2
- package/dist/chunks/{index-keYXyTGw.esm.js.map → index--JacA4R2.esm.js.map} +1 -1
- package/dist/chunks/index-1WxwWfcp.esm.js +2 -0
- package/dist/chunks/index-1WxwWfcp.esm.js.map +1 -0
- package/dist/chunks/index-4fdLArZg.esm.js +2 -0
- package/dist/chunks/index-4fdLArZg.esm.js.map +1 -0
- package/dist/chunks/{index-UggwPn9Q.esm.d.ts → index-7mukhxz_.esm.d.ts} +1 -1
- package/dist/chunks/index-Hd_2hpsA.esm.js +2 -0
- package/dist/chunks/index-Hd_2hpsA.esm.js.map +1 -0
- package/dist/chunks/{index-1nI7l5vj.esm.js → index-JDZQClkA.esm.js} +2 -2
- package/dist/chunks/{index-1nI7l5vj.esm.js.map → index-JDZQClkA.esm.js.map} +1 -1
- package/dist/chunks/{index-OaRsZJh7.esm.d.ts → index-JG4nmG9U.esm.d.ts} +1 -1
- package/dist/chunks/index-MJNFm2RK.esm.js +2 -0
- package/dist/chunks/index-MJNFm2RK.esm.js.map +1 -0
- package/dist/chunks/{index-B9w02q6y.esm.d.ts → index-MSoONvC5.esm.d.ts} +1 -1
- package/dist/chunks/{index-uqNCQVUx.esm.d.ts → index-SExnliMs.esm.d.ts} +1 -1
- package/dist/chunks/{index-mw70Caof.esm.js → index-eXilYHHK.esm.js} +2 -2
- package/dist/chunks/{index-mw70Caof.esm.js.map → index-eXilYHHK.esm.js.map} +1 -1
- package/dist/chunks/index-gBAASIWa.esm.js +2 -0
- package/dist/chunks/index-gBAASIWa.esm.js.map +1 -0
- package/dist/chunks/index-lyf1T2wZ.esm.js +2 -0
- package/dist/chunks/index-lyf1T2wZ.esm.js.map +1 -0
- package/dist/chunks/{index-U3VWulKA.esm.js → index-qs-xQCeM.esm.js} +2 -2
- package/dist/chunks/{index-U3VWulKA.esm.js.map → index-qs-xQCeM.esm.js.map} +1 -1
- package/dist/chunks/index-qt5iD9Ok.esm.d.ts +14 -0
- package/dist/chunks/{index-ozcDdIom.esm.d.ts → index-tdUx2WLc.esm.d.ts} +4 -4
- package/dist/chunks/{lit-3QHn3fwl.esm.js → lit-iNN5L_Qk.esm.js} +2 -2
- package/dist/chunks/{lit-3QHn3fwl.esm.js.map → lit-iNN5L_Qk.esm.js.map} +1 -1
- package/dist/chunks/loading-template-t4fFsYtr.esm.js +2 -0
- package/dist/chunks/{loading-template-mLjOGXMj.esm.js.map → loading-template-t4fFsYtr.esm.js.map} +1 -1
- package/dist/chunks/localize-m-_ESmpk.esm.js +31 -0
- package/dist/chunks/localize-m-_ESmpk.esm.js.map +1 -0
- package/dist/chunks/localize-o-cYvHQf.esm.js +31 -0
- package/dist/chunks/localize-o-cYvHQf.esm.js.map +1 -0
- package/dist/chunks/{openapi-spec-GGEBbqAJ.esm.d.ts → openapi-spec-RlP2IT1i.esm.d.ts} +87 -33
- package/dist/chunks/{order-page-LvE0Otsn.esm.d.ts → order-page-FLhpaZg2.esm.d.ts} +4 -4
- package/dist/chunks/order-page-KZ7xLkRW.esm.js +2 -0
- package/dist/chunks/order-page-KZ7xLkRW.esm.js.map +1 -0
- package/dist/chunks/order-page-mlWRT5YL.esm.js +2 -0
- package/dist/chunks/order-page-mlWRT5YL.esm.js.map +1 -0
- package/dist/chunks/{progress-bar-HVG_n8_6.esm.js → progress-bar-PMU_xI3L.esm.js} +2 -2
- package/dist/chunks/{progress-bar-HVG_n8_6.esm.js.map → progress-bar-PMU_xI3L.esm.js.map} +1 -1
- package/dist/chunks/promo-pill-label-58PJRvSl.esm.js +15 -0
- package/dist/chunks/promo-pill-label-58PJRvSl.esm.js.map +1 -0
- package/dist/chunks/{responsive-KbDsZM6S.esm.js → responsive-2lC2Wrtg.esm.js} +2 -2
- package/dist/chunks/{responsive-KbDsZM6S.esm.js.map → responsive-2lC2Wrtg.esm.js.map} +1 -1
- package/dist/chunks/{routes-L-CN-xXC.esm.js → routes-FBB1GA4-.esm.js} +2 -2
- package/dist/chunks/{routes-L-CN-xXC.esm.js.map → routes-FBB1GA4-.esm.js.map} +1 -1
- package/dist/chunks/{routes-wCCYf_uA.esm.d.ts → routes-NIuAzAOC.esm.d.ts} +3 -1
- package/dist/chunks/{routes-t6bR6BdS.esm.js → routes-jmFlXAbv.esm.js} +2 -2
- package/dist/chunks/{routes-t6bR6BdS.esm.js.map → routes-jmFlXAbv.esm.js.map} +1 -1
- package/dist/chunks/share-button-SNvuFDC9.esm.js +2 -0
- package/dist/chunks/share-button-SNvuFDC9.esm.js.map +1 -0
- package/dist/chunks/{share-button-0N1lvlZT.esm.js → share-button-bQ8brpBZ.esm.js} +4 -3
- package/dist/chunks/{share-button-0N1lvlZT.esm.js.map → share-button-bQ8brpBZ.esm.js.map} +1 -1
- package/dist/chunks/{share-button-7wbogZGx.esm.js → share-button-hLOsYlSA.esm.js} +4 -3
- package/dist/chunks/{share-button-7wbogZGx.esm.js.map → share-button-hLOsYlSA.esm.js.map} +1 -1
- package/dist/chunks/{shoelace-components-BpI14CrA.esm.js → shoelace-components-leDI-Yop.esm.js} +2 -2
- package/dist/chunks/{shoelace-components-BpI14CrA.esm.js.map → shoelace-components-leDI-Yop.esm.js.map} +1 -1
- package/dist/chunks/{shoelace-components-VlhAe0ME.esm.js → shoelace-components-qjNlvvPx.esm.js} +2 -2
- package/dist/chunks/{shoelace-components-VlhAe0ME.esm.js.map → shoelace-components-qjNlvvPx.esm.js.map} +1 -1
- package/dist/chunks/{update-cart-tjLR7pMx.esm.d.ts → update-cart-Hebtxhto.esm.d.ts} +1 -1
- package/dist/chunks/update-cart-aKQ3Cjc8.esm.js +2 -0
- package/dist/chunks/update-cart-aKQ3Cjc8.esm.js.map +1 -0
- package/dist/chunks/update-cart-j9LPS5By.esm.js +2 -0
- package/dist/chunks/update-cart-j9LPS5By.esm.js.map +1 -0
- package/dist/chunks/{vendor--f7lkyBk.esm.js → vendor-GKiOHg2N.esm.js} +2 -2
- package/dist/chunks/{vendor--f7lkyBk.esm.js.map → vendor-GKiOHg2N.esm.js.map} +1 -1
- package/dist/components/beam-partner-logos.esm.js +1 -1
- package/dist/components/beam-partner-logos.js +1 -1
- package/dist/components/community-impact.d.ts +1 -0
- package/dist/components/community-impact.esm.js +13 -13
- package/dist/components/community-impact.esm.js.map +1 -1
- package/dist/components/community-impact.js +13 -13
- package/dist/components/community-impact.js.map +1 -1
- package/dist/components/cumulative-impact.d.ts +1 -0
- package/dist/components/cumulative-impact.esm.js +3 -3
- package/dist/components/cumulative-impact.esm.js.map +1 -1
- package/dist/components/cumulative-impact.js +3 -3
- package/dist/components/cumulative-impact.js.map +1 -1
- package/dist/components/impact-overview.d.ts +7 -1
- package/dist/components/impact-overview.esm.js +87 -73
- package/dist/components/impact-overview.esm.js.map +1 -1
- package/dist/components/impact-overview.js +87 -73
- 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 +4 -3
- package/dist/components/post-purchase.esm.js +4 -2
- package/dist/components/post-purchase.esm.js.map +1 -1
- package/dist/components/post-purchase.js +4 -2
- package/dist/components/post-purchase.js.map +1 -1
- package/dist/components/product-details-page.d.ts +2 -1
- package/dist/components/product-details-page.esm.js +3 -3
- package/dist/components/product-details-page.esm.js.map +1 -1
- package/dist/components/product-details-page.js +3 -3
- package/dist/components/product-details-page.js.map +1 -1
- package/dist/components/redeem-transaction.d.ts +11 -4
- package/dist/components/redeem-transaction.esm.js +256 -185
- package/dist/components/redeem-transaction.esm.js.map +1 -1
- package/dist/components/redeem-transaction.js +256 -185
- package/dist/components/redeem-transaction.js.map +1 -1
- package/dist/components/select-nonprofit.d.ts +7 -5
- package/dist/components/select-nonprofit.esm.js +55 -30
- package/dist/components/select-nonprofit.esm.js.map +1 -1
- package/dist/components/select-nonprofit.js +55 -30
- package/dist/components/select-nonprofit.js.map +1 -1
- package/dist/components/select-subscription-nonprofit.d.ts +2 -1
- package/dist/components/select-subscription-nonprofit.esm.js +34 -19
- package/dist/components/select-subscription-nonprofit.esm.js.map +1 -1
- package/dist/components/select-subscription-nonprofit.js +34 -19
- package/dist/components/select-subscription-nonprofit.js.map +1 -1
- package/dist/components/shopify.d.ts +6 -6
- package/dist/components/shopify.esm.js +1 -1
- package/dist/components/shopify.esm.js.map +1 -1
- package/dist/components/shopify.js +1 -1
- package/dist/components/shopify.js.map +1 -1
- package/dist/components/social-share.esm.js +1 -1
- package/dist/components/social-share.js +1 -1
- package/dist/components/subscription-impact.d.ts +2 -1
- package/dist/components/subscription-impact.esm.js +6 -6
- package/dist/components/subscription-impact.esm.js.map +1 -1
- package/dist/components/subscription-impact.js +6 -6
- package/dist/components/subscription-impact.js.map +1 -1
- package/dist/components/subscription-management.d.ts +5 -4
- package/dist/components/subscription-management.esm.js +4 -2
- package/dist/components/subscription-management.esm.js.map +1 -1
- package/dist/components/subscription-management.js +4 -2
- package/dist/components/subscription-management.js.map +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/session.esm.js +1 -1
- package/dist/integrations/session.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 +14 -14
- package/dist/integrations/statsig.esm.js.map +1 -1
- package/dist/integrations/statsig.js +14 -14
- package/dist/integrations/statsig.js.map +1 -1
- package/dist/integrations/utils.d.ts +3 -3
- package/dist/react/beam-partner-logos.esm.js +1 -1
- package/dist/react/beam-partner-logos.js +1 -1
- 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.esm.js.map +1 -1
- package/dist/react/post-purchase.js +1 -1
- package/dist/react/post-purchase.js.map +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.esm.js.map +1 -1
- package/dist/react/redeem-transaction.js +1 -1
- package/dist/react/redeem-transaction.js.map +1 -1
- package/dist/react/select-nonprofit.d.ts +4 -3
- package/dist/react/select-nonprofit.esm.js +1 -1
- package/dist/react/select-nonprofit.esm.js.map +1 -1
- package/dist/react/select-nonprofit.js +1 -1
- package/dist/react/select-nonprofit.js.map +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.esm.js.map +1 -1
- package/dist/react/select-subscription-nonprofit.js +1 -1
- package/dist/react/select-subscription-nonprofit.js.map +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.esm.js.map +1 -1
- package/dist/react/subscription-management.js +1 -1
- package/dist/react/subscription-management.js.map +1 -1
- package/dist/utils/cart.d.ts +18 -0
- package/dist/utils/cart.esm.js +2 -0
- package/dist/utils/cart.esm.js.map +1 -0
- package/dist/utils/cart.js +2 -0
- package/dist/utils/cart.js.map +1 -0
- 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-H1_GULvN.esm.js +0 -2
- package/dist/chunks/_share-dialog-dependencies-H1_GULvN.esm.js.map +0 -1
- package/dist/chunks/_share-dialog-dependencies-ww3ylfIF.esm.js +0 -2
- package/dist/chunks/_share-dialog-dependencies-ww3ylfIF.esm.js.map +0 -1
- package/dist/chunks/checkbox-P2JYPqxl.esm.js +0 -17
- package/dist/chunks/checkbox-P2JYPqxl.esm.js.map +0 -1
- package/dist/chunks/index-Gf_Ee-cU.esm.js +0 -2
- package/dist/chunks/index-Gf_Ee-cU.esm.js.map +0 -1
- package/dist/chunks/index-Mt-ELD4q.esm.js +0 -2
- package/dist/chunks/index-Mt-ELD4q.esm.js.map +0 -1
- package/dist/chunks/index-X9fTuRmg.esm.js +0 -2
- package/dist/chunks/index-X9fTuRmg.esm.js.map +0 -1
- package/dist/chunks/index-ixzz4bX7.esm.js +0 -2
- package/dist/chunks/index-ixzz4bX7.esm.js.map +0 -1
- package/dist/chunks/index-q7eo0lf1.esm.js +0 -2
- package/dist/chunks/index-q7eo0lf1.esm.js.map +0 -1
- package/dist/chunks/index-uKlidExq.esm.js +0 -2
- package/dist/chunks/index-uKlidExq.esm.js.map +0 -1
- package/dist/chunks/index-yeW2w5bb.esm.d.ts +0 -13
- package/dist/chunks/loading-template-mLjOGXMj.esm.js +0 -2
- package/dist/chunks/localize-IRs8JglT.esm.js +0 -29
- package/dist/chunks/localize-IRs8JglT.esm.js.map +0 -1
- package/dist/chunks/localize-SsJbTmMj.esm.js +0 -29
- package/dist/chunks/localize-SsJbTmMj.esm.js.map +0 -1
- package/dist/chunks/order-page-4Tj7yLdv.esm.js +0 -2
- package/dist/chunks/order-page-4Tj7yLdv.esm.js.map +0 -1
- package/dist/chunks/order-page-9qKR3-ys.esm.js +0 -2
- package/dist/chunks/order-page-9qKR3-ys.esm.js.map +0 -1
- package/dist/chunks/promo-pill-label-3Xtr5ALT.esm.js +0 -14
- package/dist/chunks/promo-pill-label-3Xtr5ALT.esm.js.map +0 -1
- package/dist/chunks/share-button-CqTd80g8.esm.js +0 -2
- package/dist/chunks/share-button-CqTd80g8.esm.js.map +0 -1
- package/dist/chunks/update-cart-Djv-AjNu.esm.js +0 -2
- package/dist/chunks/update-cart-Djv-AjNu.esm.js.map +0 -1
- package/dist/chunks/update-cart-G7FRM8DW.esm.js +0 -2
- package/dist/chunks/update-cart-G7FRM8DW.esm.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localize-m-_ESmpk.esm.js","sources":["../../src/shared/fragments/css-variable-map.ts","../../src/shared/controllers/async-controller.ts","../../src/shared/fragments/error-message-template.ts","../../src/shared/fragments/custom-text.ts","../../src/shared/localize.ts"],"sourcesContent":["export const _cssVariableMap = (variables: Record<string, string>) => {\n return Object.entries(variables)\n .map(([k, v]) => `${k}: ${v};`)\n .join(\"\\n\");\n};\n","import { ReactiveController, ReactiveControllerHost } from \"lit\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AsyncFunction = (...args: any[]) => Promise<any>;\n\n/**\n * Creates a declarative wrapper around async operations\n * @example\n * class MyElement extends LitElement {\n * private user = new AsyncController(\n * this,\n * async ({ id }) => get(url, { id }));\n *\n * async updated(changedProperties) {\n * if (changedProperties.has(\"userId\")) {\n * await this.user.exec({ id: this.userId })\n * }\n * }\n *\n * render() {\n * const { data, loading, error } = this.user;\n * if (loading) return html`Please wait...`\n * if (error) return html`Error! <button @click=${this.user.retry}>Reload</button>`;\n * return html`My name is: ${data.name}`\n * }\n * }\n */\nexport class AsyncController<TFn extends AsyncFunction> implements ReactiveController {\n public data: Awaited<ReturnType<TFn>> | null = null;\n public loading = false;\n public error: Error | null = null;\n\n private readonly host: ReactiveControllerHost;\n private readonly asyncFn: TFn;\n private lastArgs?: Parameters<TFn>;\n\n constructor(host: ReactiveControllerHost, asyncFn: TFn) {\n (this.host = host).addController(this);\n this.asyncFn = asyncFn;\n }\n\n public async exec(...args: Parameters<TFn>): Promise<ReturnType<TFn> | null> {\n this.lastArgs = args;\n this.loading = true;\n this.host.requestUpdate();\n try {\n // TODO: prevent race condition if later invocation returns before earlier\n this.data = await this.asyncFn(...args);\n this.error = null;\n } catch (err) {\n if (err instanceof Error) {\n this.error = err;\n this.data = null;\n }\n }\n this.loading = false;\n this.host.requestUpdate();\n return this.data;\n }\n\n public async retry() {\n return this.exec(...((this.lastArgs || []) as Parameters<TFn>));\n }\n\n hostDisconnected() {\n // TODO: cancel API calls\n }\n}\n","import { html } from \"lit\";\nimport { MissingConfig, NetworkError } from \"../../utils/beam-errors\";\n\nconst strings = {\n errorTitle: `Beam encountered an error. Please try again.`,\n retry: `Retry`,\n};\n\nexport const _errorMessage = ({ error, retry }: { error: Error; retry?: (...args: never) => void }) => {\n let details = html``;\n if (error instanceof NetworkError) {\n const response = JSON.stringify(\n {\n status: error.response.status,\n statusText: error.response.statusText,\n url: error.response.url,\n body: error.body,\n },\n null,\n 4\n );\n details = html`\n <p><b>Network Response:</b></p>\n <p>${response}</p>\n `;\n }\n if (error instanceof MissingConfig) {\n details = html`\n <p><b>Missing Required Config Options:</b></p>\n <p>${error.missingConfigKeyNames.join(\", \")}</p>\n `;\n }\n return html`<div class=\"beam-error\" style=\"text-align: left\">\n <p>${strings.errorTitle} ${retry ? html` <button type=\"reset\" @click=\"${retry}\">${strings.retry}</button>` : \"\"}</p>\n <br />\n <details>\n <div style=\"white-space: pre-wrap; font-family: monospace; line-height: 1;\">\n ${details}\n <p><b>Message:</b> ${error.message || html`<i>None</i>`}</p>\n <p><b>Stack:</b> ${error.stack}</p>\n </div>\n </details>\n <br />\n <p>Help: <a href=\"https://www.beamimpact.com\">www.beamimpact.com</a></p>\n </div>`;\n};\n","import { CSSResult, unsafeCSS } from \"lit\";\n\n/**\n * Create an object that can be passed to cssVariableMap\n * to define CSS variables in a style tag. The default properties\n * are the ones exposed for customization in the remote config interface.\n * @example\n * const variables = {\n * ...customizableTextJs(\"widget-header\",\n * \"widget-border-color\": \"red\"\n * };\n *\n * html`<style>:host { ${_cssVariableMap(variables)} }</style>`;\n * @returns {{[p: string]: string}}\n */\nexport const defineCustomText = (\n namespace = \"\",\n {\n fontFamily = \"inherit\",\n fontStyle = \"inherit\",\n fontSize = \"inherit\",\n fontWeight = \"inherit\",\n textTransform = \"none\",\n textDecoration = \"none\",\n marginTop = \"0\",\n lineHeight = \"inherit\",\n color = \"inherit\",\n letterSpacing = \"normal\",\n } = {}\n): Record<string, string> => {\n const prefix = namespace.startsWith(\"--beam-\") ? namespace : `--beam-${namespace}`;\n return {\n [`${prefix}-fontFamily`]: fontFamily,\n [`${prefix}-fontStyle`]: fontStyle,\n [`${prefix}-fontSize`]: fontSize,\n [`${prefix}-fontWeight`]: fontWeight,\n [`${prefix}-textTransform`]: textTransform,\n [`${prefix}-marginTop`]: marginTop,\n [`${prefix}-lineHeight`]: lineHeight,\n [`${prefix}-color`]: color,\n [`${prefix}-letterSpacing`]: letterSpacing,\n [`${prefix}-textDecoration`]: textDecoration,\n };\n};\n\n/**\n * Returns a string that defines css properties based on variables,\n * which can be used in a css`` template. The default properties are the\n * ones exposed for customization in the remote config interface.\n * @example\n * css`.widget-header { ${customizableTextCss(\"widget-header\")} border: none; }`\n * @returns {CSSResult}\n */\nexport const useCustomText = (\n namespace = \"\",\n {\n fontFamily = \"inherit\",\n fontStyle = \"inherit\",\n fontSize = \"inherit\",\n fontWeight = \"inherit\",\n textTransform = \"none\",\n textDecoration = \"none\",\n marginTop = \"0\",\n lineHeight = \"inherit\",\n color = \"inherit\",\n letterSpacing = \"normal\",\n } = {}\n): CSSResult => {\n const prefix = namespace.startsWith(\"--beam-\") ? namespace : `--beam-${namespace}`;\n return unsafeCSS(`\\\n font-family: var(${prefix}-fontFamily, ${fontFamily});\n font-style: var(${prefix}-fontStyle, ${fontStyle});\n font-size: var(${prefix}-fontSize, ${fontSize});\n font-weight: var(${prefix}-fontWeight, ${fontWeight});\n text-transform: var(${prefix}-textTransform, ${textTransform});\n margin-top: var(${prefix}-marginTop, ${marginTop});\n line-height: var(${prefix}-lineHeight, ${lineHeight});\n text-decoration: var(${prefix}-textDecoration, ${textDecoration});\n color: var(${prefix}-color, ${color});\n letter-spacing: var(${prefix}-letterSpacing, ${letterSpacing});\n `);\n};\n\n/**\n * Same as useCustomText except returns an object that can be passed to styleMap\n */\nexport const useCustomTextMap = (\n namespace = \"\",\n {\n fontSize = \"inherit\",\n fontStyle = \"inherit\",\n fontWeight = \"inherit\",\n textTransform = \"none\",\n textDecoration = \"none\",\n marginTop = \"0\",\n lineHeight = \"inherit\",\n letterSpacing = \"normal\",\n } = {}\n): Record<string, string> => {\n const prefix = namespace.startsWith(\"--beam-\") ? namespace : `--beam-${namespace}`;\n return {\n fontSize: `var(${prefix}-fontSize, ${fontSize})`,\n fontStyle: `var(${prefix}-fontStyle, ${fontStyle})`,\n fontWeight: `var(${prefix}-fontWeight, ${fontWeight})`,\n textTransform: `var(${prefix}-textTransform, ${textTransform})`,\n textDecoration: `var(${prefix}-textDecoration, ${textDecoration})`,\n marginTop: `var(${prefix}-marginTop, ${marginTop})`,\n lineHeight: `var(${prefix}-lineHeight, ${lineHeight})`,\n letterSpacing: `var(${prefix}-letterSpacing, ${letterSpacing})`,\n };\n};\n","import { LANGUAGES } from \"../api-sdk/types\";\nimport { logger } from \"../utils/logger\";\nimport { BeamError } from \"../utils/beam-errors\";\n\n/**\n * User-provided strings may include embedded translations in JSON form\n * This function extracts the string for the provided language\n * If it fails to parse, or the string is not json-like, it returns the whole string\n * TODO: consider returning unsafeHtml() or adding an option for it\n */\nconst localizeUserString = (lang: LANGUAGES, str: string): string => {\n const isJson = str.startsWith(\"{\");\n if (isJson) {\n try {\n const json = JSON.parse(str);\n return json[lang] ?? json[\"en\"] ?? str;\n } catch (err) {\n logger.error(new BeamError(\"Failed to extract JSON translation from string\"), str);\n return str;\n }\n }\n return str;\n};\n\nexport { localizeUserString };\n"],"names":["_cssVariableMap","variables","k","v","AsyncController","host","asyncFn","args","err","strings","_errorMessage","error","retry","details","html","NetworkError","response","MissingConfig","defineCustomText","namespace","fontFamily","fontStyle","fontSize","fontWeight","textTransform","textDecoration","marginTop","lineHeight","color","letterSpacing","prefix","useCustomText","unsafeCSS","localizeUserString","lang","str","json","logger","BeamError"],"mappings":"6JAAO,MAA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QF,CAAM,gBAAgBV,CAAU;AAAA,0BACjCU,CAAM,eAAeT,CAAS;AAAA,yBAC/BS,CAAM,cAAcR,CAAQ;AAAA,2BAC1BQ,CAAM,gBAAgBP,CAAU;AAAA,8BAC7BO,CAAM,mBAAmBN,CAAa;AAAA,0BAC1CM,CAAM,eAAeJ,CAAS;AAAA,2BAC7BI,CAAM,gBAAgBH,CAAU;AAAA,+BAC5BG,CAAM,oBAAoBL,CAAc;AAAA,qBAClDK,CAAM,WAAWF,CAAK;AAAA,8BACbE,CAAM,mBAAmBD,CAAa;AAAA,KAC/D,CACL,ECvEMI,EAAqB,CAACC,EAAiBC,IAAwB,CAEnE,GADeA,EAAI,WAAW,GAAG,EAE/B,GAAI,CACF,MAAMC,EAAO,KAAK,MAAMD,CAAG,EAC3B,OAAOC,EAAKF,CAAI,GAAKE,EAAK,IAASD,CACrC,MAAc,CACZ,OAAAE,EAAO,MAAM,IAAIC,EAAU,gDAAgD,EAAGH,CAAG,EAC1EA,CACT,CAEF,OAAOA,CACT"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import{y as i,j as $}from"./lit-iNN5L_Qk.esm.js";import{N as g,M as y,B as u}from"./beam-errors-P-Lu07Ce.esm.js";import{logger as d}from"../utils/logger.esm.js";const b=t=>Object.entries(t).map(([r,n])=>`${r}: ${n};`).join(`
|
|
2
|
+
`);class x{constructor(r,n){this.data=null,this.loading=!1,this.error=null,(this.host=r).addController(this),this.asyncFn=n}async exec(...r){this.lastArgs=r,this.loading=!0,this.host.requestUpdate();try{this.data=await this.asyncFn(...r),this.error=null}catch(n){n instanceof Error&&(this.error=n,this.data=null)}return this.loading=!1,this.host.requestUpdate(),this.data}async retry(){return this.exec(...this.lastArgs||[])}hostDisconnected(){}}const f={errorTitle:"Beam encountered an error. Please try again.",retry:"Retry"},S=({error:t,retry:r})=>{let n=i``;if(t instanceof g){const o=JSON.stringify({status:t.response.status,statusText:t.response.statusText,url:t.response.url,body:t.body},null,4);n=i`
|
|
3
|
+
<p><b>Network Response:</b></p>
|
|
4
|
+
<p>${o}</p>
|
|
5
|
+
`}return t instanceof y&&(n=i`
|
|
6
|
+
<p><b>Missing Required Config Options:</b></p>
|
|
7
|
+
<p>${t.missingConfigKeyNames.join(", ")}</p>
|
|
8
|
+
`),i`<div class="beam-error" style="text-align: left">
|
|
9
|
+
<p>${f.errorTitle} ${r?i` <button type="reset" @click="${r}">${f.retry}</button>`:""}</p>
|
|
10
|
+
<br />
|
|
11
|
+
<details>
|
|
12
|
+
<div style="white-space: pre-wrap; font-family: monospace; line-height: 1;">
|
|
13
|
+
${n}
|
|
14
|
+
<p><b>Message:</b> ${t.message||i`<i>None</i>`}</p>
|
|
15
|
+
<p><b>Stack:</b> ${t.stack}</p>
|
|
16
|
+
</div>
|
|
17
|
+
</details>
|
|
18
|
+
<br />
|
|
19
|
+
<p>Help: <a href="https://www.beamimpact.com">www.beamimpact.com</a></p>
|
|
20
|
+
</div>`},v=(t="",{fontFamily:r="inherit",fontStyle:n="inherit",fontSize:o="inherit",fontWeight:s="inherit",textTransform:a="none",textDecoration:l="none",marginTop:c="0",lineHeight:h="inherit",color:p="inherit",letterSpacing:m="normal"}={})=>{const e=t.startsWith("--beam-")?t:`--beam-${t}`;return{[`${e}-fontFamily`]:r,[`${e}-fontStyle`]:n,[`${e}-fontSize`]:o,[`${e}-fontWeight`]:s,[`${e}-textTransform`]:a,[`${e}-marginTop`]:c,[`${e}-lineHeight`]:h,[`${e}-color`]:p,[`${e}-letterSpacing`]:m,[`${e}-textDecoration`]:l}},T=(t="",{fontFamily:r="inherit",fontStyle:n="inherit",fontSize:o="inherit",fontWeight:s="inherit",textTransform:a="none",textDecoration:l="none",marginTop:c="0",lineHeight:h="inherit",color:p="inherit",letterSpacing:m="normal"}={})=>{const e=t.startsWith("--beam-")?t:`--beam-${t}`;return $(` font-family: var(${e}-fontFamily, ${r});
|
|
21
|
+
font-style: var(${e}-fontStyle, ${n});
|
|
22
|
+
font-size: var(${e}-fontSize, ${o});
|
|
23
|
+
font-weight: var(${e}-fontWeight, ${s});
|
|
24
|
+
text-transform: var(${e}-textTransform, ${a});
|
|
25
|
+
margin-top: var(${e}-marginTop, ${c});
|
|
26
|
+
line-height: var(${e}-lineHeight, ${h});
|
|
27
|
+
text-decoration: var(${e}-textDecoration, ${l});
|
|
28
|
+
color: var(${e}-color, ${p});
|
|
29
|
+
letter-spacing: var(${e}-letterSpacing, ${m});
|
|
30
|
+
`)},w=(t,r)=>{if(r.startsWith("{"))try{const n=JSON.parse(r);return n[t]??n.en??r}catch{return d.error(new u("Failed to extract JSON translation from string"),r),r}return r};export{x as A,S as _,b as a,v as d,w as i,T as u};
|
|
31
|
+
//# sourceMappingURL=localize-o-cYvHQf.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localize-o-cYvHQf.esm.js","sources":["../../src/shared/fragments/css-variable-map.ts","../../src/shared/controllers/async-controller.ts","../../src/shared/fragments/error-message-template.ts","../../src/shared/fragments/custom-text.ts","../../src/shared/localize.ts"],"sourcesContent":["export const _cssVariableMap = (variables: Record<string, string>) => {\n return Object.entries(variables)\n .map(([k, v]) => `${k}: ${v};`)\n .join(\"\\n\");\n};\n","import { ReactiveController, ReactiveControllerHost } from \"lit\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AsyncFunction = (...args: any[]) => Promise<any>;\n\n/**\n * Creates a declarative wrapper around async operations\n * @example\n * class MyElement extends LitElement {\n * private user = new AsyncController(\n * this,\n * async ({ id }) => get(url, { id }));\n *\n * async updated(changedProperties) {\n * if (changedProperties.has(\"userId\")) {\n * await this.user.exec({ id: this.userId })\n * }\n * }\n *\n * render() {\n * const { data, loading, error } = this.user;\n * if (loading) return html`Please wait...`\n * if (error) return html`Error! <button @click=${this.user.retry}>Reload</button>`;\n * return html`My name is: ${data.name}`\n * }\n * }\n */\nexport class AsyncController<TFn extends AsyncFunction> implements ReactiveController {\n public data: Awaited<ReturnType<TFn>> | null = null;\n public loading = false;\n public error: Error | null = null;\n\n private readonly host: ReactiveControllerHost;\n private readonly asyncFn: TFn;\n private lastArgs?: Parameters<TFn>;\n\n constructor(host: ReactiveControllerHost, asyncFn: TFn) {\n (this.host = host).addController(this);\n this.asyncFn = asyncFn;\n }\n\n public async exec(...args: Parameters<TFn>): Promise<ReturnType<TFn> | null> {\n this.lastArgs = args;\n this.loading = true;\n this.host.requestUpdate();\n try {\n // TODO: prevent race condition if later invocation returns before earlier\n this.data = await this.asyncFn(...args);\n this.error = null;\n } catch (err) {\n if (err instanceof Error) {\n this.error = err;\n this.data = null;\n }\n }\n this.loading = false;\n this.host.requestUpdate();\n return this.data;\n }\n\n public async retry() {\n return this.exec(...((this.lastArgs || []) as Parameters<TFn>));\n }\n\n hostDisconnected() {\n // TODO: cancel API calls\n }\n}\n","import { html } from \"lit\";\nimport { MissingConfig, NetworkError } from \"../../utils/beam-errors\";\n\nconst strings = {\n errorTitle: `Beam encountered an error. Please try again.`,\n retry: `Retry`,\n};\n\nexport const _errorMessage = ({ error, retry }: { error: Error; retry?: (...args: never) => void }) => {\n let details = html``;\n if (error instanceof NetworkError) {\n const response = JSON.stringify(\n {\n status: error.response.status,\n statusText: error.response.statusText,\n url: error.response.url,\n body: error.body,\n },\n null,\n 4\n );\n details = html`\n <p><b>Network Response:</b></p>\n <p>${response}</p>\n `;\n }\n if (error instanceof MissingConfig) {\n details = html`\n <p><b>Missing Required Config Options:</b></p>\n <p>${error.missingConfigKeyNames.join(\", \")}</p>\n `;\n }\n return html`<div class=\"beam-error\" style=\"text-align: left\">\n <p>${strings.errorTitle} ${retry ? html` <button type=\"reset\" @click=\"${retry}\">${strings.retry}</button>` : \"\"}</p>\n <br />\n <details>\n <div style=\"white-space: pre-wrap; font-family: monospace; line-height: 1;\">\n ${details}\n <p><b>Message:</b> ${error.message || html`<i>None</i>`}</p>\n <p><b>Stack:</b> ${error.stack}</p>\n </div>\n </details>\n <br />\n <p>Help: <a href=\"https://www.beamimpact.com\">www.beamimpact.com</a></p>\n </div>`;\n};\n","import { CSSResult, unsafeCSS } from \"lit\";\n\n/**\n * Create an object that can be passed to cssVariableMap\n * to define CSS variables in a style tag. The default properties\n * are the ones exposed for customization in the remote config interface.\n * @example\n * const variables = {\n * ...customizableTextJs(\"widget-header\",\n * \"widget-border-color\": \"red\"\n * };\n *\n * html`<style>:host { ${_cssVariableMap(variables)} }</style>`;\n * @returns {{[p: string]: string}}\n */\nexport const defineCustomText = (\n namespace = \"\",\n {\n fontFamily = \"inherit\",\n fontStyle = \"inherit\",\n fontSize = \"inherit\",\n fontWeight = \"inherit\",\n textTransform = \"none\",\n textDecoration = \"none\",\n marginTop = \"0\",\n lineHeight = \"inherit\",\n color = \"inherit\",\n letterSpacing = \"normal\",\n } = {}\n): Record<string, string> => {\n const prefix = namespace.startsWith(\"--beam-\") ? namespace : `--beam-${namespace}`;\n return {\n [`${prefix}-fontFamily`]: fontFamily,\n [`${prefix}-fontStyle`]: fontStyle,\n [`${prefix}-fontSize`]: fontSize,\n [`${prefix}-fontWeight`]: fontWeight,\n [`${prefix}-textTransform`]: textTransform,\n [`${prefix}-marginTop`]: marginTop,\n [`${prefix}-lineHeight`]: lineHeight,\n [`${prefix}-color`]: color,\n [`${prefix}-letterSpacing`]: letterSpacing,\n [`${prefix}-textDecoration`]: textDecoration,\n };\n};\n\n/**\n * Returns a string that defines css properties based on variables,\n * which can be used in a css`` template. The default properties are the\n * ones exposed for customization in the remote config interface.\n * @example\n * css`.widget-header { ${customizableTextCss(\"widget-header\")} border: none; }`\n * @returns {CSSResult}\n */\nexport const useCustomText = (\n namespace = \"\",\n {\n fontFamily = \"inherit\",\n fontStyle = \"inherit\",\n fontSize = \"inherit\",\n fontWeight = \"inherit\",\n textTransform = \"none\",\n textDecoration = \"none\",\n marginTop = \"0\",\n lineHeight = \"inherit\",\n color = \"inherit\",\n letterSpacing = \"normal\",\n } = {}\n): CSSResult => {\n const prefix = namespace.startsWith(\"--beam-\") ? namespace : `--beam-${namespace}`;\n return unsafeCSS(`\\\n font-family: var(${prefix}-fontFamily, ${fontFamily});\n font-style: var(${prefix}-fontStyle, ${fontStyle});\n font-size: var(${prefix}-fontSize, ${fontSize});\n font-weight: var(${prefix}-fontWeight, ${fontWeight});\n text-transform: var(${prefix}-textTransform, ${textTransform});\n margin-top: var(${prefix}-marginTop, ${marginTop});\n line-height: var(${prefix}-lineHeight, ${lineHeight});\n text-decoration: var(${prefix}-textDecoration, ${textDecoration});\n color: var(${prefix}-color, ${color});\n letter-spacing: var(${prefix}-letterSpacing, ${letterSpacing});\n `);\n};\n\n/**\n * Same as useCustomText except returns an object that can be passed to styleMap\n */\nexport const useCustomTextMap = (\n namespace = \"\",\n {\n fontSize = \"inherit\",\n fontStyle = \"inherit\",\n fontWeight = \"inherit\",\n textTransform = \"none\",\n textDecoration = \"none\",\n marginTop = \"0\",\n lineHeight = \"inherit\",\n letterSpacing = \"normal\",\n } = {}\n): Record<string, string> => {\n const prefix = namespace.startsWith(\"--beam-\") ? namespace : `--beam-${namespace}`;\n return {\n fontSize: `var(${prefix}-fontSize, ${fontSize})`,\n fontStyle: `var(${prefix}-fontStyle, ${fontStyle})`,\n fontWeight: `var(${prefix}-fontWeight, ${fontWeight})`,\n textTransform: `var(${prefix}-textTransform, ${textTransform})`,\n textDecoration: `var(${prefix}-textDecoration, ${textDecoration})`,\n marginTop: `var(${prefix}-marginTop, ${marginTop})`,\n lineHeight: `var(${prefix}-lineHeight, ${lineHeight})`,\n letterSpacing: `var(${prefix}-letterSpacing, ${letterSpacing})`,\n };\n};\n","import { LANGUAGES } from \"../api-sdk/types\";\nimport { logger } from \"../utils/logger\";\nimport { BeamError } from \"../utils/beam-errors\";\n\n/**\n * User-provided strings may include embedded translations in JSON form\n * This function extracts the string for the provided language\n * If it fails to parse, or the string is not json-like, it returns the whole string\n * TODO: consider returning unsafeHtml() or adding an option for it\n */\nconst localizeUserString = (lang: LANGUAGES, str: string): string => {\n const isJson = str.startsWith(\"{\");\n if (isJson) {\n try {\n const json = JSON.parse(str);\n return json[lang] ?? json[\"en\"] ?? str;\n } catch (err) {\n logger.error(new BeamError(\"Failed to extract JSON translation from string\"), str);\n return str;\n }\n }\n return str;\n};\n\nexport { localizeUserString };\n"],"names":["_cssVariableMap","variables","k","v","AsyncController","host","asyncFn","args","err","strings","_errorMessage","error","retry","details","html","NetworkError","response","MissingConfig","defineCustomText","namespace","fontFamily","fontStyle","fontSize","fontWeight","textTransform","textDecoration","marginTop","lineHeight","color","letterSpacing","prefix","useCustomText","unsafeCSS","localizeUserString","lang","str","json","logger","BeamError"],"mappings":"iKAAO,MAAMA,EAAmBC,GACvB,OAAO,QAAQA,CAAS,EAC5B,IAAI,CAAC,CAACC,EAAGC,CAAC,IAAM,GAAGD,CAAC,KAAKC,CAAC,GAAG,EAC7B,KAAK;AAAA,CAAI,ECwBP,MAAMC,CAAyE,CASpF,YAAYC,EAA8BC,EAAc,CARxD,KAAO,KAAwC,KAC/C,KAAO,QAAU,GACjB,KAAO,MAAsB,MAO1B,KAAK,KAAOD,GAAM,cAAc,IAAI,EACrC,KAAK,QAAUC,CACjB,CAEA,MAAa,QAAQC,EAAwD,CAC3E,KAAK,SAAWA,EAChB,KAAK,QAAU,GACf,KAAK,KAAK,gBACV,GAAI,CAEF,KAAK,KAAO,MAAM,KAAK,QAAQ,GAAGA,CAAI,EACtC,KAAK,MAAQ,IACf,OAASC,EAAK,CACRA,aAAe,QACjB,KAAK,MAAQA,EACb,KAAK,KAAO,KAEhB,CACA,YAAK,QAAU,GACf,KAAK,KAAK,gBACH,KAAK,IACd,CAEA,MAAa,OAAQ,CACnB,OAAO,KAAK,KAAK,GAAK,KAAK,UAAY,CAAuB,CAAA,CAChE,CAEA,kBAAmB,CAGrB,CAAA,CChEA,MAAMC,EAAU,CACd,WAAY,+CACZ,MAAO,OACT,EAEaC,EAAgB,CAAC,CAAE,MAAAC,EAAO,MAAAC,CAAM,IAA0D,CACrG,IAAIC,EAAUC,IACd,GAAIH,aA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7B,CAAC,GAAGC,CAAM,iBAAiB,EAAGL,CAChC,CACF,EAUaM,EAAgB,CAC3BZ,EAAY,GACZ,CACE,WAAAC,EAAa,UACb,UAAAC,EAAY,UACZ,SAAAC,EAAW,UACX,WAAAC,EAAa,UACb,cAAAC,EAAgB,OAChB,eAAAC,EAAiB,OACjB,UAAAC,EAAY,IACZ,WAAAC,EAAa,UACb,MAAAC,EAAQ,UACR,cAAAC,EAAgB,QAClB,EAAI,CAAA,IACU,CACd,MAAMC,EAASX,EAAU,WAAW,SAAS,EAAIA,EAAY,UAAUA,CAAS,GAChF,OAAOa,EAAU,4BACQF,CAAM,gBAAgBV,CAAU;AAAA,0BACjCU,CAAM,eAAeT,CAAS;AAAA,yBAC/BS,CAAM,cAAcR,CAAQ;AAAA,2BAC1BQ,CAAM,gBAAgBP,CAAU;AAAA,8BAC7BO,CAAM,mBAAmBN,CAAa;AAAA,0BAC1CM,CAAM,eAAeJ,CAAS;AAAA,2BAC7BI,CAAM,gBAAgBH,CAAU;AAAA,+BAC5BG,CAAM,oBAAoBL,CAAc;AAAA,qBAClDK,CAAM,WAAWF,CAAK;AAAA,8BACbE,CAAM,mBAAmBD,CAAa;AAAA,KAC/D,CACL,ECvEMI,EAAqB,CAACC,EAAiBC,IAAwB,CAEnE,GADeA,EAAI,WAAW,GAAG,EAE/B,GAAI,CACF,MAAMC,EAAO,KAAK,MAAMD,CAAG,EAC3B,OAAOC,EAAKF,CAAI,GAAKE,EAAK,IAASD,CACrC,MAAc,CACZ,OAAAE,EAAO,MAAM,IAAIC,EAAU,gDAAgD,EAAGH,CAAG,EAC1EA,CACT,CAEF,OAAOA,CACT"}
|
|
@@ -69,7 +69,7 @@ interface paths {
|
|
|
69
69
|
promoDescriptionPrefix?: string;
|
|
70
70
|
/**
|
|
71
71
|
* @description The promo description for the widget for web
|
|
72
|
-
* @example
|
|
72
|
+
* @example At no extra cost, select a nonprofit and 1% of your purchase will be donated
|
|
73
73
|
*/
|
|
74
74
|
promoDescription?: string;
|
|
75
75
|
/**
|
|
@@ -132,7 +132,7 @@ interface paths {
|
|
|
132
132
|
title: string;
|
|
133
133
|
/**
|
|
134
134
|
* @description Subtitle/description for the widget
|
|
135
|
-
* @example
|
|
135
|
+
* @example At no extra cost, select a nonprofit and 1% of your purchase will be donated
|
|
136
136
|
*/
|
|
137
137
|
description: string;
|
|
138
138
|
/**
|
|
@@ -154,7 +154,7 @@ interface paths {
|
|
|
154
154
|
title: string;
|
|
155
155
|
/**
|
|
156
156
|
* @description Subtitle/description for the widget
|
|
157
|
-
* @example
|
|
157
|
+
* @example At no extra cost, select a nonprofit and 1% of your purchase will be donated
|
|
158
158
|
*/
|
|
159
159
|
description: string;
|
|
160
160
|
/**
|
|
@@ -316,6 +316,8 @@ interface paths {
|
|
|
316
316
|
/** Language code. */
|
|
317
317
|
lang?: "en" | "fr" | "de" | "es" | "it" | "pl";
|
|
318
318
|
version: string;
|
|
319
|
+
/** When set to true, draft themes are returned */
|
|
320
|
+
draftConfig?: boolean;
|
|
319
321
|
};
|
|
320
322
|
};
|
|
321
323
|
responses: {
|
|
@@ -364,7 +366,7 @@ interface paths {
|
|
|
364
366
|
promoDescriptionPrefix?: string;
|
|
365
367
|
/**
|
|
366
368
|
* @description The promo description for the widget for web
|
|
367
|
-
* @example
|
|
369
|
+
* @example At no extra cost, select a nonprofit and 1% of your purchase will be donated
|
|
368
370
|
*/
|
|
369
371
|
promoDescription?: string;
|
|
370
372
|
/**
|
|
@@ -427,7 +429,7 @@ interface paths {
|
|
|
427
429
|
title: string;
|
|
428
430
|
/**
|
|
429
431
|
* @description Subtitle/description for the widget
|
|
430
|
-
* @example
|
|
432
|
+
* @example At no extra cost, select a nonprofit and 1% of your purchase will be donated
|
|
431
433
|
*/
|
|
432
434
|
description: string;
|
|
433
435
|
/**
|
|
@@ -449,7 +451,7 @@ interface paths {
|
|
|
449
451
|
title: string;
|
|
450
452
|
/**
|
|
451
453
|
* @description Subtitle/description for the widget
|
|
452
|
-
* @example
|
|
454
|
+
* @example At no extra cost, select a nonprofit and 1% of your purchase will be donated
|
|
453
455
|
*/
|
|
454
456
|
description: string;
|
|
455
457
|
/**
|
|
@@ -601,7 +603,7 @@ interface paths {
|
|
|
601
603
|
promoDescriptionPrefix?: string;
|
|
602
604
|
/**
|
|
603
605
|
* @description The promo description for the widget for web
|
|
604
|
-
* @example
|
|
606
|
+
* @example At no extra cost, select a nonprofit and 1% of your purchase will be donated
|
|
605
607
|
*/
|
|
606
608
|
promoDescription?: string;
|
|
607
609
|
/**
|
|
@@ -664,7 +666,7 @@ interface paths {
|
|
|
664
666
|
title: string;
|
|
665
667
|
/**
|
|
666
668
|
* @description Subtitle/description for the widget
|
|
667
|
-
* @example
|
|
669
|
+
* @example At no extra cost, select a nonprofit and 1% of your purchase will be donated
|
|
668
670
|
*/
|
|
669
671
|
description: string;
|
|
670
672
|
/**
|
|
@@ -686,7 +688,7 @@ interface paths {
|
|
|
686
688
|
title: string;
|
|
687
689
|
/**
|
|
688
690
|
* @description Subtitle/description for the widget
|
|
689
|
-
* @example
|
|
691
|
+
* @example At no extra cost, select a nonprofit and 1% of your purchase will be donated
|
|
690
692
|
*/
|
|
691
693
|
description: string;
|
|
692
694
|
/**
|
|
@@ -958,6 +960,7 @@ interface paths {
|
|
|
958
960
|
config?: {
|
|
959
961
|
/** @description Removes the themes object from the remote config object in the response. */
|
|
960
962
|
omitThemes?: boolean;
|
|
963
|
+
draftConfig?: boolean;
|
|
961
964
|
};
|
|
962
965
|
};
|
|
963
966
|
};
|
|
@@ -986,7 +989,9 @@ interface paths {
|
|
|
986
989
|
/** Language code. */
|
|
987
990
|
lang?: "en" | "fr" | "de" | "es" | "it" | "pl";
|
|
988
991
|
/** When set to true, themes are removed from widget config objects */
|
|
989
|
-
|
|
992
|
+
omitThemes?: boolean;
|
|
993
|
+
/** When set to true, draft themes are returned */
|
|
994
|
+
draftConfig?: boolean;
|
|
990
995
|
/** Discount codes applied to the order */
|
|
991
996
|
discountCodes?: string[];
|
|
992
997
|
/** The transactionId of the purchase */
|
|
@@ -1043,7 +1048,7 @@ interface paths {
|
|
|
1043
1048
|
promoDescriptionPrefix?: string;
|
|
1044
1049
|
/**
|
|
1045
1050
|
* @description The promo description for the widget for web
|
|
1046
|
-
* @example
|
|
1051
|
+
* @example At no extra cost, select a nonprofit and 1% of your purchase will be donated
|
|
1047
1052
|
*/
|
|
1048
1053
|
promoDescription?: string;
|
|
1049
1054
|
/**
|
|
@@ -1106,7 +1111,7 @@ interface paths {
|
|
|
1106
1111
|
title: string;
|
|
1107
1112
|
/**
|
|
1108
1113
|
* @description Subtitle/description for the widget
|
|
1109
|
-
* @example
|
|
1114
|
+
* @example At no extra cost, select a nonprofit and 1% of your purchase will be donated
|
|
1110
1115
|
*/
|
|
1111
1116
|
description: string;
|
|
1112
1117
|
/**
|
|
@@ -1128,7 +1133,7 @@ interface paths {
|
|
|
1128
1133
|
title: string;
|
|
1129
1134
|
/**
|
|
1130
1135
|
* @description Subtitle/description for the widget
|
|
1131
|
-
* @example
|
|
1136
|
+
* @example At no extra cost, select a nonprofit and 1% of your purchase will be donated
|
|
1132
1137
|
*/
|
|
1133
1138
|
description: string;
|
|
1134
1139
|
/**
|
|
@@ -1418,7 +1423,7 @@ interface paths {
|
|
|
1418
1423
|
promoDescriptionPrefix?: string;
|
|
1419
1424
|
/**
|
|
1420
1425
|
* @description The promo description for the widget for web
|
|
1421
|
-
* @example
|
|
1426
|
+
* @example At no extra cost, select a nonprofit and 1% of your purchase will be donated
|
|
1422
1427
|
*/
|
|
1423
1428
|
promoDescription?: string;
|
|
1424
1429
|
/**
|
|
@@ -1481,7 +1486,7 @@ interface paths {
|
|
|
1481
1486
|
title: string;
|
|
1482
1487
|
/**
|
|
1483
1488
|
* @description Subtitle/description for the widget
|
|
1484
|
-
* @example
|
|
1489
|
+
* @example At no extra cost, select a nonprofit and 1% of your purchase will be donated
|
|
1485
1490
|
*/
|
|
1486
1491
|
description: string;
|
|
1487
1492
|
/**
|
|
@@ -1503,7 +1508,7 @@ interface paths {
|
|
|
1503
1508
|
title: string;
|
|
1504
1509
|
/**
|
|
1505
1510
|
* @description Subtitle/description for the widget
|
|
1506
|
-
* @example
|
|
1511
|
+
* @example At no extra cost, select a nonprofit and 1% of your purchase will be donated
|
|
1507
1512
|
*/
|
|
1508
1513
|
description: string;
|
|
1509
1514
|
/**
|
|
@@ -2702,6 +2707,7 @@ interface paths {
|
|
|
2702
2707
|
config?: {
|
|
2703
2708
|
/** @description Removes the themes object from the remote config object in the response. */
|
|
2704
2709
|
omitThemes?: boolean;
|
|
2710
|
+
draftConfig?: boolean;
|
|
2705
2711
|
};
|
|
2706
2712
|
};
|
|
2707
2713
|
/** @enum {string} */
|
|
@@ -2851,7 +2857,7 @@ interface paths {
|
|
|
2851
2857
|
promoDescriptionPrefix?: string;
|
|
2852
2858
|
/**
|
|
2853
2859
|
* @description The promo description for the widget for web
|
|
2854
|
-
* @example
|
|
2860
|
+
* @example At no extra cost, select a nonprofit and 1% of your purchase will be donated
|
|
2855
2861
|
*/
|
|
2856
2862
|
promoDescription?: string;
|
|
2857
2863
|
/**
|
|
@@ -2914,7 +2920,7 @@ interface paths {
|
|
|
2914
2920
|
title: string;
|
|
2915
2921
|
/**
|
|
2916
2922
|
* @description Subtitle/description for the widget
|
|
2917
|
-
* @example
|
|
2923
|
+
* @example At no extra cost, select a nonprofit and 1% of your purchase will be donated
|
|
2918
2924
|
*/
|
|
2919
2925
|
description: string;
|
|
2920
2926
|
/**
|
|
@@ -2936,7 +2942,7 @@ interface paths {
|
|
|
2936
2942
|
title: string;
|
|
2937
2943
|
/**
|
|
2938
2944
|
* @description Subtitle/description for the widget
|
|
2939
|
-
* @example
|
|
2945
|
+
* @example At no extra cost, select a nonprofit and 1% of your purchase will be donated
|
|
2940
2946
|
*/
|
|
2941
2947
|
description: string;
|
|
2942
2948
|
/**
|
|
@@ -3352,6 +3358,7 @@ interface paths {
|
|
|
3352
3358
|
config?: {
|
|
3353
3359
|
/** @description Removes the themes object from the remote config object in the response. */
|
|
3354
3360
|
omitThemes?: boolean;
|
|
3361
|
+
draftConfig?: boolean;
|
|
3355
3362
|
};
|
|
3356
3363
|
};
|
|
3357
3364
|
}>;
|
|
@@ -3658,7 +3665,7 @@ interface paths {
|
|
|
3658
3665
|
promoDescriptionPrefix?: string;
|
|
3659
3666
|
/**
|
|
3660
3667
|
* @description The promo description for the widget for web
|
|
3661
|
-
* @example
|
|
3668
|
+
* @example At no extra cost, select a nonprofit and 1% of your purchase will be donated
|
|
3662
3669
|
*/
|
|
3663
3670
|
promoDescription?: string;
|
|
3664
3671
|
/**
|
|
@@ -3721,7 +3728,7 @@ interface paths {
|
|
|
3721
3728
|
title: string;
|
|
3722
3729
|
/**
|
|
3723
3730
|
* @description Subtitle/description for the widget
|
|
3724
|
-
* @example
|
|
3731
|
+
* @example At no extra cost, select a nonprofit and 1% of your purchase will be donated
|
|
3725
3732
|
*/
|
|
3726
3733
|
description: string;
|
|
3727
3734
|
/**
|
|
@@ -3743,7 +3750,7 @@ interface paths {
|
|
|
3743
3750
|
title: string;
|
|
3744
3751
|
/**
|
|
3745
3752
|
* @description Subtitle/description for the widget
|
|
3746
|
-
* @example
|
|
3753
|
+
* @example At no extra cost, select a nonprofit and 1% of your purchase will be donated
|
|
3747
3754
|
*/
|
|
3748
3755
|
description: string;
|
|
3749
3756
|
/**
|
|
@@ -3779,7 +3786,7 @@ interface paths {
|
|
|
3779
3786
|
promoDescriptionPrefix?: string;
|
|
3780
3787
|
/**
|
|
3781
3788
|
* @description The promo description for the widget for web
|
|
3782
|
-
* @example
|
|
3789
|
+
* @example At no extra cost, select a nonprofit and 1% of your purchase will be donated
|
|
3783
3790
|
*/
|
|
3784
3791
|
promoDescription?: string;
|
|
3785
3792
|
/**
|
|
@@ -3842,7 +3849,7 @@ interface paths {
|
|
|
3842
3849
|
title: string;
|
|
3843
3850
|
/**
|
|
3844
3851
|
* @description Subtitle/description for the widget
|
|
3845
|
-
* @example
|
|
3852
|
+
* @example At no extra cost, select a nonprofit and 1% of your purchase will be donated
|
|
3846
3853
|
*/
|
|
3847
3854
|
description: string;
|
|
3848
3855
|
/**
|
|
@@ -3864,7 +3871,7 @@ interface paths {
|
|
|
3864
3871
|
title: string;
|
|
3865
3872
|
/**
|
|
3866
3873
|
* @description Subtitle/description for the widget
|
|
3867
|
-
* @example
|
|
3874
|
+
* @example At no extra cost, select a nonprofit and 1% of your purchase will be donated
|
|
3868
3875
|
*/
|
|
3869
3876
|
description: string;
|
|
3870
3877
|
/**
|
|
@@ -3912,7 +3919,7 @@ interface paths {
|
|
|
3912
3919
|
title: string;
|
|
3913
3920
|
/**
|
|
3914
3921
|
* @description Subtitle/description for the widget
|
|
3915
|
-
* @example
|
|
3922
|
+
* @example At no extra cost, select a nonprofit and 1% of your purchase will be donated
|
|
3916
3923
|
*/
|
|
3917
3924
|
description: string;
|
|
3918
3925
|
/**
|
|
@@ -3934,7 +3941,7 @@ interface paths {
|
|
|
3934
3941
|
title: string;
|
|
3935
3942
|
/**
|
|
3936
3943
|
* @description Subtitle/description for the widget
|
|
3937
|
-
* @example
|
|
3944
|
+
* @example At no extra cost, select a nonprofit and 1% of your purchase will be donated
|
|
3938
3945
|
*/
|
|
3939
3946
|
description: string;
|
|
3940
3947
|
/**
|
|
@@ -3956,7 +3963,7 @@ interface paths {
|
|
|
3956
3963
|
title: string;
|
|
3957
3964
|
/**
|
|
3958
3965
|
* @description Subtitle/description for the widget
|
|
3959
|
-
* @example
|
|
3966
|
+
* @example At no extra cost, select a nonprofit and 1% of your purchase will be donated
|
|
3960
3967
|
*/
|
|
3961
3968
|
description: string;
|
|
3962
3969
|
/**
|
|
@@ -3978,7 +3985,7 @@ interface paths {
|
|
|
3978
3985
|
title: string;
|
|
3979
3986
|
/**
|
|
3980
3987
|
* @description Subtitle/description for the widget
|
|
3981
|
-
* @example
|
|
3988
|
+
* @example At no extra cost, select a nonprofit and 1% of your purchase will be donated
|
|
3982
3989
|
*/
|
|
3983
3990
|
description: string;
|
|
3984
3991
|
/**
|
|
@@ -4000,7 +4007,7 @@ interface paths {
|
|
|
4000
4007
|
title: string;
|
|
4001
4008
|
/**
|
|
4002
4009
|
* @description Subtitle/description for the widget
|
|
4003
|
-
* @example
|
|
4010
|
+
* @example At no extra cost, select a nonprofit and 1% of your purchase will be donated
|
|
4004
4011
|
*/
|
|
4005
4012
|
description: string;
|
|
4006
4013
|
/**
|
|
@@ -6685,6 +6692,8 @@ interface paths {
|
|
|
6685
6692
|
/** The version of the config */
|
|
6686
6693
|
version: string;
|
|
6687
6694
|
storeId: number;
|
|
6695
|
+
/** When set to true, draft themes are returned */
|
|
6696
|
+
draftConfig?: boolean;
|
|
6688
6697
|
widgetName?: "community-impact" | "impact-overview" | "select-nonprofit" | "redeem-transaction" | "cumulative-impact" | "mobile-full-screen-nonprofit-selection" | "mobile-impact-list" | "mobile-minimal-nonprofit-selection" | "mobile-personal-impact" | "mobile-selected-nonprofit" | "mobile-progress-bar" | "select-nonprofit-cta" | "mobile-share-button" | "subscription-management" | "product-details-page" | "select-subscription-nonprofit" | "subscription-impact";
|
|
6689
6698
|
};
|
|
6690
6699
|
};
|
|
@@ -6710,7 +6719,7 @@ interface paths {
|
|
|
6710
6719
|
promoDescriptionPrefix?: string;
|
|
6711
6720
|
/**
|
|
6712
6721
|
* @description The promo description for the widget for web
|
|
6713
|
-
* @example
|
|
6722
|
+
* @example At no extra cost, select a nonprofit and 1% of your purchase will be donated
|
|
6714
6723
|
*/
|
|
6715
6724
|
promoDescription?: string;
|
|
6716
6725
|
/**
|
|
@@ -6773,7 +6782,7 @@ interface paths {
|
|
|
6773
6782
|
title: string;
|
|
6774
6783
|
/**
|
|
6775
6784
|
* @description Subtitle/description for the widget
|
|
6776
|
-
* @example
|
|
6785
|
+
* @example At no extra cost, select a nonprofit and 1% of your purchase will be donated
|
|
6777
6786
|
*/
|
|
6778
6787
|
description: string;
|
|
6779
6788
|
/**
|
|
@@ -6795,7 +6804,7 @@ interface paths {
|
|
|
6795
6804
|
title: string;
|
|
6796
6805
|
/**
|
|
6797
6806
|
* @description Subtitle/description for the widget
|
|
6798
|
-
* @example
|
|
6807
|
+
* @example At no extra cost, select a nonprofit and 1% of your purchase will be donated
|
|
6799
6808
|
*/
|
|
6800
6809
|
description: string;
|
|
6801
6810
|
/**
|
|
@@ -6964,6 +6973,51 @@ interface paths {
|
|
|
6964
6973
|
};
|
|
6965
6974
|
};
|
|
6966
6975
|
};
|
|
6976
|
+
"/webhooks/shopify/orderCreated": {
|
|
6977
|
+
post: {
|
|
6978
|
+
responses: {
|
|
6979
|
+
/** Webhook received and verified */
|
|
6980
|
+
200: {
|
|
6981
|
+
content: {
|
|
6982
|
+
"application/json": {
|
|
6983
|
+
[key: string]: unknown;
|
|
6984
|
+
};
|
|
6985
|
+
};
|
|
6986
|
+
};
|
|
6987
|
+
/** Standard error */
|
|
6988
|
+
default: {
|
|
6989
|
+
content: {
|
|
6990
|
+
"application/json": {
|
|
6991
|
+
/** @description Beam code for the error, meant to be used programmatically */
|
|
6992
|
+
code: string;
|
|
6993
|
+
/** @description A short, human-readable summary of the problem that SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization */
|
|
6994
|
+
title: string;
|
|
6995
|
+
/** @description A human-readable explanation specific to this occurrence of the problem. Like title, this field's value can be localized */
|
|
6996
|
+
detail: string;
|
|
6997
|
+
/** @description a JSON Pointer to the associated entity in the request document */
|
|
6998
|
+
field?: string;
|
|
6999
|
+
/** @description A meta object containing non-standard meta-information about the error */
|
|
7000
|
+
metadata?: {
|
|
7001
|
+
[key: string]: unknown;
|
|
7002
|
+
};
|
|
7003
|
+
/** @description Whether the API or user can resend the request */
|
|
7004
|
+
retryable?: boolean;
|
|
7005
|
+
} & {
|
|
7006
|
+
source: unknown;
|
|
7007
|
+
meta: unknown;
|
|
7008
|
+
};
|
|
7009
|
+
};
|
|
7010
|
+
};
|
|
7011
|
+
};
|
|
7012
|
+
requestBody: {
|
|
7013
|
+
content: {
|
|
7014
|
+
"application/json": {
|
|
7015
|
+
[key: string]: unknown;
|
|
7016
|
+
};
|
|
7017
|
+
};
|
|
7018
|
+
};
|
|
7019
|
+
};
|
|
7020
|
+
};
|
|
6967
7021
|
}
|
|
6968
7022
|
|
|
6969
7023
|
export type { paths as p };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as lodash from 'lodash';
|
|
2
|
-
import { B as BeamCartAPIConfig, a as BeamCartValues } from './update-cart-
|
|
3
|
-
import { T as TCart } from './cart-contents-
|
|
2
|
+
import { B as BeamCartAPIConfig, a as BeamCartValues } from './update-cart-Hebtxhto.esm.js';
|
|
3
|
+
import { T as TCart } from './cart-contents-HAPzwbeL.esm.js';
|
|
4
4
|
import '../components/post-purchase.js';
|
|
5
|
-
import { p as postTransaction } from './routes-
|
|
5
|
+
import { p as postTransaction } from './routes-NIuAzAOC.esm.js';
|
|
6
6
|
import { T as TUrl, L as LANGUAGES } from './types-aju0qrRe.esm.js';
|
|
7
7
|
|
|
8
8
|
type BeamShopifyCartIntegrationConfig = BeamCartAPIConfig & {
|
|
@@ -71,4 +71,4 @@ type TBeamOrderPageParams = Parameters<typeof postTransaction>[0]["requestBody"]
|
|
|
71
71
|
};
|
|
72
72
|
declare function showBeamOrderPageWidgets({ parentSelector, apiKey, baseUrl, storeId, postalCode, countryCode, orderId, email, cartTotal, cart, discountCodes, currencyCode, domain, lang, debug, }: TBeamOrderPageParams): Promise<void>;
|
|
73
73
|
|
|
74
|
-
export { type TBeamOrderPageParams as T, addBeamAttributesToCart as a, getCurrentCart as g, registerCartIntegration as r, showBeamOrderPageWidgets as s, trackCart as t };
|
|
74
|
+
export { type BeamShopifyCartIntegrationConfig as B, type TBeamOrderPageParams as T, addBeamAttributesToCart as a, getCurrentCart as g, registerCartIntegration as r, showBeamOrderPageWidgets as s, trackCart as t };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i as U}from"./lodash-P8OIs-at.esm.js";import{b as J,d as O,c as j,g as k}from"./events-_4nImo3u.esm.js";import{logger as D}from"../utils/logger.esm.js";import{initNetworkListeners as K}from"../utils/network-listeners.esm.js";import{createScopedLocalStorage as S}from"../utils/local-storage.esm.js";import{getCookieValue as N}from"../utils/cookies.esm.js";import{memoizeLast as R}from"../utils/memoize-last.esm.js";import{B as C}from"./cart-contents-h60geKWa.esm.js";import{K as y}from"./update-cart-aKQ3Cjc8.esm.js";import{W as x,D as q}from"./routes-jmFlXAbv.esm.js";import{getExternalCartId as B,getBeamCartId as b}from"../utils/cart.esm.js";import"../components/post-purchase.esm.js";import{waitForElement as M}from"../utils/wait-for-element.esm.js";import{B as P}from"./beam-errors-P-Lu07Ce.esm.js";const L=window.Shopify?.routes?.root||"/";let T=!1;const E="cart";async function W(t){if(T)return!1;const l=await v(t),p=N(E);l.cart.cartId!==p&&await y(t,l.cart),await _({}),K(),window.addEventListener(J.eventName,async s=>{const r=s,n=/cart\/(add|change|update|clear)/,o=r.detail.type==="xhr"?r.detail.xhr.responseURL:r.detail.response.url,a=new URL(o);if(!n.test(a.pathname))return;const i=await v(t);if(!i.changed)return;const c={schema:i.cart.schema,content:{items:i.cart.content.items,discounts:i.cart.content.discounts}};window.dispatchEvent(new O(c)),await y(t,i.cart)});let d,m;return window.addEventListener(j.eventName,async s=>{const r=s,{source:n,selectedNonprofitId:o,selectionId:a}=r.detail;if(n===x.select_nonprofit){const i=B(E,t),c=b(C,t),{chainId:u,storeId:I}=t;if(d===o&&m===a)return;await _({selectedNonprofitId:o,selectionId:a,beamCartId:c||void 0,cartId:i||void 0,chainId:u,storeId:I}),m=a,d=o}}),window.addEventListener(k.eventName,async s=>{const r=s,{newNonprofitId:n,selectionId:o}=r.detail,a=B(E,t),i=b(C,t),{chainId:c,storeId:u}=t;d===n&&m===o||(await _({selectedNonprofitId:n,beamCartId:i||void 0,selectionId:o,cartId:a||void 0,chainId:c,storeId:u}),m=o,d=n)}),T=!0,!0}async function v(t){const{token:l,total_price:p,item_count:d,currency:m,items:s,cart_level_discount_applications:r}=await window.fetch(L+"cart.js",{method:"GET",headers:{"Content-Type":"application/json"}}).then(c=>c.json());let n=!1;const o=S(t).getItemJson("cart"),a=b(C,t),i={cartId:l,beamCartId:a,subtotal:p/100,itemCount:d,currencyCode:m,schema:{source:"generic"},content:{items:s.map(({sku:c,final_line_price:u,product_id:I,line_level_discount_allocations:g})=>{const f=c||String(I),w=u/100,e=g?.map(({discount_application:h})=>({code:h?.title,applicable:!0}));return{remoteProductIdentifier:f,localAmount:w,discounts:e}}),discounts:r.map(({title:c})=>({code:c,applicable:!0}))}};return U(i,{...o,beamCartId:o?.beamCartId})||(n=!0),{changed:n,cart:i}}const F=y,_=R(async function({selectedNonprofitId:t,selectionId:l,beamCartId:p,cartId:d,chainId:m,storeId:s}){let r,n;if(window.statsig){const a=window.statsig;r=a.getLayer("beam_trial_layer").get("show_beam",!1),n=a.getStableID()}const o={beam:JSON.stringify({nonprofit_id:t,selection_id:l,beam_cart_id:p,shopify_cart_id:d,chain_id:m,store_id:s,show_beam:r,remote_session_id:n})};try{await window.fetch(L+"cart/update.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({attributes:o})})}catch(a){D.error(a)}});async function G({parentSelector:t=".step__sections",apiKey:l,baseUrl:p=q,storeId:d,postalCode:m,countryCode:s,orderId:r,email:n,cartTotal:o,cart:a,discountCodes:i,currencyCode:c="USD",domain:u,lang:I="en",debug:g=!1}){const f=document.querySelector(t)||await M(t);if(!f)throw new P(`Timed out waiting for selector '${t}'. Could not render Beam post-purchase widget.`);const w=await N("cart");if(w){const h=S({apiKey:l}),A=h.getItemJson("cart")||{};h.setItemJson("cart",{...A,cartId:w})}const e=document.createElement("beam-post-purchase");e.apiKey=l,e.baseUrl=p,e.storeId=d,e.postalCode=m,e.countryCode=s,e.orderId=String(r),e.email=n,e.cartTotal=o,e.cart=a,e.discountCodes=i,e.currencyCode=c,e.domain=u,e.lang=I,e.debug=g,f.appendChild(e)}export{W as J,_ as p,F as q,G as s,v as w};
|
|
2
|
+
//# sourceMappingURL=order-page-KZ7xLkRW.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order-page-KZ7xLkRW.esm.js","sources":["../../src/integrations/shopify/cart-page.ts","../../src/integrations/shopify/order-page.ts"],"sourcesContent":["/* eslint-disable camelcase */\nimport isEqual from \"lodash-es/isEqual\";\nimport { logger, memoizeLast } from \"../../utils\";\nimport { getCookieValue } from \"../../utils/cookies\";\nimport { initNetworkListeners } from \"../../utils/network-listeners\";\nimport {\n BeamCartChangeEvent,\n BeamNetworkCallEvent,\n BeamNonprofitSelectEvent,\n BeamNonprofitSelectionRemovedEvent,\n} from \"../../utils/events\";\nimport { createScopedLocalStorage } from \"../../utils/local-storage\";\nimport { BEAM_CART_COOKIE_NAME, TBeamCartLocalStorage, TCart, TCartApi, TCartItems } from \"../../shared/cart-contents\";\nimport { BeamCartAPIConfig, updateCart } from \"../cart\";\nimport { WIDGET_NAMES } from \"../../api-sdk/constants\";\nimport { getBeamCartId, getExternalCartId } from \"../../utils/cart\";\n\nexport type BeamShopifyCartIntegrationConfig = BeamCartAPIConfig & {\n storeId: number; // will be added to cart custom_attributes, and used in cart API call\n chainId?: number; // will be added to cart custom_attributes\n};\n\ntype ShopifyDiscountApplication = {\n title: string;\n value: string;\n};\n\ntype ShopifyLineLevelDiscountAllocations = {\n amount?: string;\n discount_application: ShopifyDiscountApplication;\n};\n\nconst SHOPIFY_BASE_URL = window.Shopify?.routes?.root || \"/\"; // see window.d.ts\n\nlet isBeamCartIntegrationRegistered = false; // Skip registering event listeners if already set up\n\nconst SHOPIFY_CART_COOKIE_NAME = \"cart\";\n\n/**\n * @main registerCartIntegration - set up event listeners to integrate Beam with Shopify cart\n * @return {boolean} returns true if NEW listeners were created, false if setup was already done\n */\nasync function registerCartIntegration(config: BeamShopifyCartIntegrationConfig) {\n if (isBeamCartIntegrationRegistered) {\n return false; // Do nothing if listeners are already attached\n }\n\n // Handle full-page load, ie, first-time page load and reloads from form submit events\n // This creates a GET to /cart.js\n const currentCart = await getCurrentCart(config);\n const cartCookie = getCookieValue(SHOPIFY_CART_COOKIE_NAME);\n // only update on initial load if Shopify cart has changed since last visit\n if (currentCart.cart.cartId !== cartCookie) {\n await updateCart(config, currentCart.cart);\n }\n // pre load beam cart attribute to save statsig info\n await addBeamAttributesToCart({});\n // Set up event listeners for AJAX events\n initNetworkListeners();\n\n window.addEventListener(BeamNetworkCallEvent.eventName, async (_event: Event) => {\n const event = _event as BeamNetworkCallEvent;\n const cartChangePaths = /cart\\/(add|change|update|clear)/;\n // note: response urls below follow redirects\n const requestUrlStr = event.detail.type === \"xhr\" ? event.detail.xhr.responseURL : event.detail.response.url;\n const url = new URL(requestUrlStr);\n if (!cartChangePaths.test(url.pathname)) {\n return;\n }\n const currentCart = await getCurrentCart(config);\n if (!currentCart.changed) {\n return;\n }\n const eventDetail: TCartApi = {\n schema: currentCart.cart.schema as any, // TS union type can't figure out what variant applies here\n content: {\n items: currentCart.cart.content.items as any,\n discounts: currentCart.cart.content.discounts as any,\n },\n };\n window.dispatchEvent(new BeamCartChangeEvent(eventDetail));\n // Send cart to Beam to update timestamp, which is used for cart abandonment / ROI calc\n await updateCart(config, currentCart.cart);\n });\n\n // Listen to Beam's own events to integrate Beam data into Shopify order\n let lastNonprofitId: number | null | undefined;\n let lastSelectionId: string | null | undefined;\n window.addEventListener(BeamNonprofitSelectEvent.eventName, async (_event) => {\n const event = _event as BeamNonprofitSelectEvent;\n const { source, selectedNonprofitId, selectionId } = event.detail;\n\n if (source === WIDGET_NAMES.select_nonprofit) {\n const cartId = getExternalCartId(SHOPIFY_CART_COOKIE_NAME, config); // Shopify cart ID\n const beamCartId = getBeamCartId(BEAM_CART_COOKIE_NAME, config); // Beam cart ID\n const { chainId, storeId } = config;\n // Skip update if nothing changed (can happen if widget is re-initialized and\n // emits event after cache restoration, i.e., on cart re-render).\n if (lastNonprofitId === selectedNonprofitId && lastSelectionId === selectionId) {\n return;\n }\n await addBeamAttributesToCart({\n selectedNonprofitId,\n selectionId,\n beamCartId: beamCartId ? beamCartId : undefined,\n cartId: cartId ? cartId : undefined,\n chainId,\n storeId,\n });\n lastSelectionId = selectionId;\n lastNonprofitId = selectedNonprofitId;\n }\n });\n\n /**\n * Upon removal of the selected nonprofit from the widget and local storage,\n * an event is emitted and that event is then used to update the cart attributes accordingly\n * This event listener updates the cart attributes based on the emitted event\n */\n window.addEventListener(BeamNonprofitSelectionRemovedEvent.eventName, async (_event) => {\n const event = _event as BeamNonprofitSelectionRemovedEvent;\n const { newNonprofitId, selectionId } = event.detail;\n const cartId = getExternalCartId(SHOPIFY_CART_COOKIE_NAME, config);\n const beamCartId = getBeamCartId(BEAM_CART_COOKIE_NAME, config);\n const { chainId, storeId } = config;\n if (lastNonprofitId === newNonprofitId && lastSelectionId === selectionId) {\n return;\n }\n await addBeamAttributesToCart({\n selectedNonprofitId: newNonprofitId,\n beamCartId: beamCartId ? beamCartId : undefined,\n selectionId,\n cartId: cartId ? cartId : undefined,\n chainId,\n storeId,\n });\n lastSelectionId = selectionId;\n lastNonprofitId = newNonprofitId;\n });\n\n isBeamCartIntegrationRegistered = true;\n\n return true;\n}\n\n/* ***************************************** HELPER FUNCTIONS *****************************************\n These may be used individually to integrate with carts if the registerCartIntegration\n script doesn't work for some reason.\n ****************************************************************************************************/\n\n/**\n * Detects change in cart since last page load,\n * by calling GET /cart.js, and returns cart values.\n * Used for:\n * - Form-based carts where the page refreshes to modify cart instead of using AJAX calls\n * - Hydrogen/GraphQL based carts (needs to be integrated manually)\n */\nasync function getCurrentCart(config: BeamShopifyCartIntegrationConfig): Promise<{\n changed: boolean;\n cart: {\n cartId: string;\n subtotal: number;\n itemCount: number;\n currencyCode: string;\n } & TCart;\n}> {\n const {\n token, // equal to \"cart\" cookie\n total_price, // this is the pretax value, after discounts, and multiplied by 100 (integer from decimal)\n item_count,\n currency,\n items,\n cart_level_discount_applications,\n } = await window\n .fetch(SHOPIFY_BASE_URL + \"cart.js\", {\n method: \"GET\",\n headers: { \"Content-Type\": \"application/json\" },\n })\n .then((res) => res.json());\n\n let changed = false;\n\n const localStorage = createScopedLocalStorage(config);\n\n // The cart cache is used to detect changes after page refreshes / across tabs\n const cachedCart: TBeamCartLocalStorage | null = localStorage.getItemJson(\"cart\");\n // The Beam cart cookie is used to identify the cart across subdomains\n // Use explicit null if empty because API requires it\n const beamCartId: string | null = getBeamCartId(BEAM_CART_COOKIE_NAME, config);\n\n const cart = {\n cartId: token,\n beamCartId,\n subtotal: total_price / 100,\n itemCount: item_count,\n currencyCode: currency,\n schema: { source: \"generic\" } as const,\n content: {\n // pull out minimal fields from full line items\n items: (items as TCartItems).map(({ sku, final_line_price, product_id, line_level_discount_allocations }) => {\n const remoteProductIdentifier = sku || String(product_id);\n const localAmount = final_line_price / 100;\n const discounts = (line_level_discount_allocations as ShopifyLineLevelDiscountAllocations[])?.map(\n ({ discount_application }) => {\n return { code: discount_application?.title, applicable: true };\n }\n );\n return { remoteProductIdentifier, localAmount, discounts };\n }),\n discounts: (cart_level_discount_applications as ShopifyDiscountApplication[]).map(({ title }) => {\n return { code: title, applicable: true };\n }),\n },\n };\n\n if (\n !isEqual(cart, {\n ...cachedCart,\n beamCartId: cachedCart?.beamCartId,\n })\n ) {\n changed = true;\n }\n\n return { changed, cart };\n}\n\n/**\n * trackCart - Backwards-compatible alias for updateCart\n */\nconst trackCart = updateCart;\n\n/**\n * Sends Beam data to Shopify to integrate with order as custom attributes.\n * Memoized so that calls with the same data as the previous don't create additional API calls to Shopify.\n */\nconst addBeamAttributesToCart = memoizeLast(async function addBeamAttributesToCart({\n selectedNonprofitId,\n selectionId,\n beamCartId,\n cartId,\n chainId,\n storeId,\n}: {\n selectedNonprofitId?: number | null;\n selectionId?: string;\n beamCartId?: string;\n cartId?: string;\n chainId?: number;\n storeId?: number;\n}) {\n let showBeam;\n let remoteSessionId;\n if (window.statsig) {\n const statsig = window.statsig as any;\n showBeam = statsig.getLayer(\"beam_trial_layer\").get(\"show_beam\", false /* default to hide */) as boolean;\n remoteSessionId = statsig.getStableID();\n }\n const beamCartAttrs = {\n beam: JSON.stringify({\n nonprofit_id: selectedNonprofitId,\n selection_id: selectionId,\n beam_cart_id: beamCartId,\n shopify_cart_id: cartId,\n chain_id: chainId,\n store_id: storeId,\n show_beam: showBeam,\n remote_session_id: remoteSessionId,\n }),\n };\n\n try {\n await window.fetch(SHOPIFY_BASE_URL + \"cart/update.js\", {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ attributes: beamCartAttrs }),\n });\n } catch (err) {\n logger.error(err); // don't throw, allow later calls to continue\n }\n});\n\ndeclare global {\n interface Window {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n statsig?: any; // attached by Statsig CDN script\n }\n}\nexport { trackCart, getCurrentCart, addBeamAttributesToCart, registerCartIntegration };\n","import \"../../components/post-purchase\";\nimport { postTransaction } from \"../../api-sdk/v3/routes\";\nimport { DEFAULT_BASE_URL } from \"../../api-sdk/constants\";\nimport { LANGUAGES, TUrl } from \"../../api-sdk/types\";\nimport { waitForElement } from \"../../utils/wait-for-element\";\nimport { BeamError } from \"../../utils/beam-errors\";\nimport { getCookieValue } from \"../../utils/cookies\";\nimport { createScopedLocalStorage } from \"../../utils/local-storage\";\nimport { TCart } from \"../../shared/cart-contents\";\n\n// Shopify admin page: admin/settings/checkout\n\nexport type TBeamOrderPageParams = Parameters<typeof postTransaction>[0][\"requestBody\"] & {\n // Either storeId or postalCode + countryCode must be provided\n storeId?: number;\n postalCode?: string;\n countryCode?: string;\n orderId: string;\n email: string;\n cartTotal: number;\n cart: TCart;\n discountCodes: string[];\n currencyCode: string;\n parentSelector: string; // CSS Selector for parent of widget to be inserted into DOM\n apiKey: string;\n baseUrl: TUrl;\n domain?: string; // Base domain for setting cookies\n lang: LANGUAGES;\n debug: boolean;\n};\n\nexport async function showBeamOrderPageWidgets({\n parentSelector = \".step__sections\",\n apiKey,\n baseUrl = DEFAULT_BASE_URL,\n storeId,\n postalCode,\n countryCode,\n orderId,\n email,\n cartTotal,\n cart,\n discountCodes,\n currencyCode = \"USD\",\n domain,\n lang = \"en\",\n debug = false,\n}: TBeamOrderPageParams) {\n const parentElement = document.querySelector(parentSelector) || (await waitForElement(parentSelector));\n if (!parentElement) {\n throw new BeamError(\n `Timed out waiting for selector '${parentSelector}'. Could not render Beam post-purchase widget.`\n );\n }\n\n // If checkout and order page are on different subdomains, we can't access localStorage\n // We can make postTransaction work by copying the cart cookie to the expected localStorage key on the current domain\n const cartId = await getCookieValue(\"cart\"); // Shopify-only cart identifier\n if (cartId) {\n const beamLocalStorage = createScopedLocalStorage({ apiKey });\n const existingValue = beamLocalStorage.getItemJson(\"cart\") || {};\n beamLocalStorage.setItemJson(\"cart\", { ...existingValue, cartId });\n }\n\n // Note: assign properties one by one instead of bulk Object.assign to type check assignments\n const widget = document.createElement(\"beam-post-purchase\");\n widget.apiKey = apiKey;\n widget.baseUrl = baseUrl;\n widget.storeId = storeId;\n widget.postalCode = postalCode;\n widget.countryCode = countryCode;\n widget.orderId = String(orderId);\n widget.email = email;\n widget.cartTotal = cartTotal;\n widget.cart = cart;\n widget.discountCodes = discountCodes;\n widget.currencyCode = currencyCode;\n widget.domain = domain;\n widget.lang = lang;\n widget.debug = debug;\n\n // Insert widget into DOM\n parentElement.appendChild(widget);\n}\n"],"names":["SHOPIFY_BASE_URL","isBeamCartIntegrationRegistered","SHOPIFY_CART_COOKIE_NAME","registerCartIntegration","config","currentCart","getCurrentCart","cartCookie","getCookieValue","updateCart","addBeamAttributesToCart","initNetworkListeners","BeamNetworkCallEvent","_event","event","cartChangePaths","requestUrlStr","url","eventDetail","BeamCartChangeEvent","lastNonprofitId","lastSelectionId","BeamNonprofitSelectEvent","source","selectedNonprofitId","selectionId","WIDGET_NAMES","cartId","getExternalCartId","beamCartId","getBeamCartId","BEAM_CART_COOKIE_NAME","chainId","storeId","BeamNonprofitSelectionRemovedEvent","newNonprofitId","token","total_price","item_count","currency","items","cart_level_discount_applications","res","changed","cachedCart","createScopedLocalStorage","cart","sku","final_line_price","product_id","line_level_discount_allocations","remoteProductIdentifier","localAmount","discounts","discount_application","title","isEqual","trackCart","memoizeLast","showBeam","remoteSessionId","statsig","beamCartAttrs","err","logger","showBeamOrderPageWidgets","parentSelector","apiKey","baseUrl","DEFAULT_BASE_URL","postalCode","countryCode","orderId","email","cartTotal","discountCodes","currencyCode","domain","lang","debug","parentElement","waitForElement","BeamError","beamLocalStorage","existingValue","widget"],"mappings":"0yBAgCA,MAAMA,EAAmB,OAAO,SAAS,QAAQ,MAAQ,IAEzD,IAAIC,EAAkC,GAEtC,MAAMC,EAA2B,OAMjC,eAAeC,EAAwBC,EAA0C,CAC/E,GAAIH,EACF,MAAO,GAKT,MAAMI,EAAc,MAAMC,EAAeF,CAAM,EACzCG,EAAaC,EAAeN,CAAwB,EAEtDG,EAAY,KAAK,SAAWE,GAC9B,MAAME,EAAWL,EAAQC,EAAY,IAAI,EAG3C,MAAMK,EAAwB,CAAE,CAAA,EAEhCC,EAEA,EAAA,OAAO,iBAAiBC,EAAqB,UAAW,MAAOC,GAAkB,CAC/E,MAAMC,EAAQD,EACRE,EAAkB,kCAElBC,EAAgBF,EAAM,OAAO,OAAS,MAAQA,EAAM,OAAO,IAAI,YAAcA,EAAM,OAAO,SAAS,IACnGG,EAAM,IAAI,IAAID,CAAa,EACjC,GAAI,CAACD,EAAgB,KAAKE,EAAI,QAAQ,EACpC,OAEF,MAAMZ,EAAc,MAAMC,EAAeF,CAAM,EAC/C,GAAI,CAACC,EAAY,QACf,OAEF,MAAMa,EAAwB,CAC5B,OAAQb,EAAY,KAAK,OACzB,QAAS,CACP,MAAOA,EAAY,KAAK,QAAQ,MAChC,UAAWA,EAAY,KAAK,QAAQ,SACtC,CACF,EACA,OAAO,cAAc,IAAIc,EAAoBD,CAAW,CAAC,EAEzD,MAAMT,EAAWL,EAAQC,EAAY,IAAI,CAC3C,CAAC,EAGD,IAAIe,EACAC,EAC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tBS,EAAO,OAASR,EAChBQ,EAAO,KAAOP,EACdO,EAAO,MAAQN,EAGfC,EAAc,YAAYK,CAAM,CAClC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i as U}from"./lodash-P8OIs-at.esm.js";import{b as J,d as O,c as j,g as k}from"./events-_4nImo3u.esm.js";import{logger as D}from"../utils/logger.js";import{initNetworkListeners as K}from"../utils/network-listeners.js";import{createScopedLocalStorage as S}from"../utils/local-storage.js";import{getCookieValue as N}from"../utils/cookies.js";import{memoizeLast as R}from"../utils/memoize-last.js";import{B as C}from"./cart-contents-h60geKWa.esm.js";import{K as y}from"./update-cart-j9LPS5By.esm.js";import{W as x,D as q}from"./routes-FBB1GA4-.esm.js";import{getExternalCartId as B,getBeamCartId as b}from"../utils/cart.js";import"../components/post-purchase.js";import{waitForElement as M}from"../utils/wait-for-element.js";import{B as P}from"./beam-errors-P-Lu07Ce.esm.js";const L=window.Shopify?.routes?.root||"/";let T=!1;const E="cart";async function W(t){if(T)return!1;const l=await v(t),p=N(E);l.cart.cartId!==p&&await y(t,l.cart),await _({}),K(),window.addEventListener(J.eventName,async s=>{const r=s,n=/cart\/(add|change|update|clear)/,o=r.detail.type==="xhr"?r.detail.xhr.responseURL:r.detail.response.url,a=new URL(o);if(!n.test(a.pathname))return;const i=await v(t);if(!i.changed)return;const c={schema:i.cart.schema,content:{items:i.cart.content.items,discounts:i.cart.content.discounts}};window.dispatchEvent(new O(c)),await y(t,i.cart)});let d,m;return window.addEventListener(j.eventName,async s=>{const r=s,{source:n,selectedNonprofitId:o,selectionId:a}=r.detail;if(n===x.select_nonprofit){const i=B(E,t),c=b(C,t),{chainId:u,storeId:I}=t;if(d===o&&m===a)return;await _({selectedNonprofitId:o,selectionId:a,beamCartId:c||void 0,cartId:i||void 0,chainId:u,storeId:I}),m=a,d=o}}),window.addEventListener(k.eventName,async s=>{const r=s,{newNonprofitId:n,selectionId:o}=r.detail,a=B(E,t),i=b(C,t),{chainId:c,storeId:u}=t;d===n&&m===o||(await _({selectedNonprofitId:n,beamCartId:i||void 0,selectionId:o,cartId:a||void 0,chainId:c,storeId:u}),m=o,d=n)}),T=!0,!0}async function v(t){const{token:l,total_price:p,item_count:d,currency:m,items:s,cart_level_discount_applications:r}=await window.fetch(L+"cart.js",{method:"GET",headers:{"Content-Type":"application/json"}}).then(c=>c.json());let n=!1;const o=S(t).getItemJson("cart"),a=b(C,t),i={cartId:l,beamCartId:a,subtotal:p/100,itemCount:d,currencyCode:m,schema:{source:"generic"},content:{items:s.map(({sku:c,final_line_price:u,product_id:I,line_level_discount_allocations:g})=>{const f=c||String(I),w=u/100,e=g?.map(({discount_application:h})=>({code:h?.title,applicable:!0}));return{remoteProductIdentifier:f,localAmount:w,discounts:e}}),discounts:r.map(({title:c})=>({code:c,applicable:!0}))}};return U(i,{...o,beamCartId:o?.beamCartId})||(n=!0),{changed:n,cart:i}}const F=y,_=R(async function({selectedNonprofitId:t,selectionId:l,beamCartId:p,cartId:d,chainId:m,storeId:s}){let r,n;if(window.statsig){const a=window.statsig;r=a.getLayer("beam_trial_layer").get("show_beam",!1),n=a.getStableID()}const o={beam:JSON.stringify({nonprofit_id:t,selection_id:l,beam_cart_id:p,shopify_cart_id:d,chain_id:m,store_id:s,show_beam:r,remote_session_id:n})};try{await window.fetch(L+"cart/update.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({attributes:o})})}catch(a){D.error(a)}});async function G({parentSelector:t=".step__sections",apiKey:l,baseUrl:p=q,storeId:d,postalCode:m,countryCode:s,orderId:r,email:n,cartTotal:o,cart:a,discountCodes:i,currencyCode:c="USD",domain:u,lang:I="en",debug:g=!1}){const f=document.querySelector(t)||await M(t);if(!f)throw new P(`Timed out waiting for selector '${t}'. Could not render Beam post-purchase widget.`);const w=await N("cart");if(w){const h=S({apiKey:l}),A=h.getItemJson("cart")||{};h.setItemJson("cart",{...A,cartId:w})}const e=document.createElement("beam-post-purchase");e.apiKey=l,e.baseUrl=p,e.storeId=d,e.postalCode=m,e.countryCode=s,e.orderId=String(r),e.email=n,e.cartTotal=o,e.cart=a,e.discountCodes=i,e.currencyCode=c,e.domain=u,e.lang=I,e.debug=g,f.appendChild(e)}export{W as J,_ as p,F as q,G as s,v as w};
|
|
2
|
+
//# sourceMappingURL=order-page-mlWRT5YL.esm.js.map
|